inputschema
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import type { Config, TaskHandlerArgs, VersionedCollectionSlug } from 'payload'
|
||||
import type { Config, Field, TaskHandlerArgs, VersionedCollectionSlug } from 'payload'
|
||||
|
||||
type Options = {
|
||||
collections: Partial<Record<VersionedCollectionSlug, true>>
|
||||
@@ -11,6 +11,34 @@ type PublishDocumentInput = {
|
||||
}
|
||||
|
||||
export const pluginScheduledPublish = (options: Options) => {
|
||||
const inputSchema: Field[] = [
|
||||
{
|
||||
name: 'collectionSlug',
|
||||
type: 'select',
|
||||
options: Object.keys(options.collections),
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
name: 'documentID',
|
||||
type: 'json',
|
||||
jsonSchema: {
|
||||
fileMatch: ['a://b/foo.json'],
|
||||
schema: {
|
||||
oneOf: [
|
||||
{
|
||||
type: 'string',
|
||||
},
|
||||
{
|
||||
type: 'number',
|
||||
},
|
||||
],
|
||||
},
|
||||
uri: 'a://b/foo.json',
|
||||
},
|
||||
required: true,
|
||||
},
|
||||
]
|
||||
|
||||
return (config: Config) => {
|
||||
if (options.disabled) {
|
||||
return config
|
||||
@@ -33,8 +61,6 @@ export const pluginScheduledPublish = (options: Options) => {
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
return config
|
||||
}
|
||||
|
||||
if (!config.jobs) {
|
||||
@@ -65,33 +91,7 @@ export const pluginScheduledPublish = (options: Options) => {
|
||||
state: 'succeeded',
|
||||
}
|
||||
},
|
||||
inputSchema: [
|
||||
{
|
||||
name: 'collectionSlug',
|
||||
type: 'select',
|
||||
options: Object.keys(options.collections),
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
name: 'documentID',
|
||||
type: 'json',
|
||||
jsonSchema: {
|
||||
fileMatch: ['a://b/foo.json'],
|
||||
schema: {
|
||||
oneOf: [
|
||||
{
|
||||
type: 'string',
|
||||
},
|
||||
{
|
||||
type: 'number',
|
||||
},
|
||||
],
|
||||
required: true,
|
||||
},
|
||||
uri: 'a://b/foo.json',
|
||||
},
|
||||
},
|
||||
],
|
||||
inputSchema,
|
||||
})
|
||||
|
||||
config.jobs.tasks.push({
|
||||
@@ -116,33 +116,7 @@ export const pluginScheduledPublish = (options: Options) => {
|
||||
state: 'succeeded',
|
||||
}
|
||||
},
|
||||
inputSchema: [
|
||||
{
|
||||
name: 'collectionSlug',
|
||||
type: 'select',
|
||||
options: Object.keys(options.collections),
|
||||
required: true,
|
||||
},
|
||||
{
|
||||
name: 'documentID',
|
||||
type: 'json',
|
||||
jsonSchema: {
|
||||
fileMatch: ['a://b/foo.json'],
|
||||
schema: {
|
||||
oneOf: [
|
||||
{
|
||||
type: 'string',
|
||||
},
|
||||
{
|
||||
type: 'number',
|
||||
},
|
||||
],
|
||||
required: true,
|
||||
},
|
||||
uri: 'a://b/foo.json',
|
||||
},
|
||||
},
|
||||
],
|
||||
inputSchema,
|
||||
})
|
||||
|
||||
return config
|
||||
|
||||
@@ -13,6 +13,7 @@ export interface Config {
|
||||
collections: {
|
||||
posts: Post;
|
||||
users: User;
|
||||
'payload-jobs': PayloadJob;
|
||||
'payload-locked-documents': PayloadLockedDocument;
|
||||
'payload-preferences': PayloadPreference;
|
||||
'payload-migrations': PayloadMigration;
|
||||
@@ -21,6 +22,7 @@ export interface Config {
|
||||
collectionsSelect: {
|
||||
posts: PostsSelect<false> | PostsSelect<true>;
|
||||
users: UsersSelect<false> | UsersSelect<true>;
|
||||
'payload-jobs': PayloadJobsSelect<false> | PayloadJobsSelect<true>;
|
||||
'payload-locked-documents': PayloadLockedDocumentsSelect<false> | PayloadLockedDocumentsSelect<true>;
|
||||
'payload-preferences': PayloadPreferencesSelect<false> | PayloadPreferencesSelect<true>;
|
||||
'payload-migrations': PayloadMigrationsSelect<false> | PayloadMigrationsSelect<true>;
|
||||
@@ -35,7 +37,14 @@ export interface Config {
|
||||
collection: 'users';
|
||||
};
|
||||
jobs: {
|
||||
tasks: unknown;
|
||||
tasks: {
|
||||
PublishDocument: TaskPublishDocument;
|
||||
UnpublishDocument: TaskUnpublishDocument;
|
||||
inline: {
|
||||
input: unknown;
|
||||
output: unknown;
|
||||
};
|
||||
};
|
||||
workflows: unknown;
|
||||
};
|
||||
}
|
||||
@@ -85,6 +94,98 @@ export interface User {
|
||||
lockUntil?: string | null;
|
||||
password?: string | null;
|
||||
}
|
||||
/**
|
||||
* This interface was referenced by `Config`'s JSON-Schema
|
||||
* via the `definition` "payload-jobs".
|
||||
*/
|
||||
export interface PayloadJob {
|
||||
id: string;
|
||||
/**
|
||||
* Input data provided to the job
|
||||
*/
|
||||
input?:
|
||||
| {
|
||||
[k: string]: unknown;
|
||||
}
|
||||
| unknown[]
|
||||
| string
|
||||
| number
|
||||
| boolean
|
||||
| null;
|
||||
taskStatus?:
|
||||
| {
|
||||
[k: string]: unknown;
|
||||
}
|
||||
| unknown[]
|
||||
| string
|
||||
| number
|
||||
| boolean
|
||||
| null;
|
||||
completedAt?: string | null;
|
||||
totalTried?: number | null;
|
||||
/**
|
||||
* If hasError is true this job will not be retried
|
||||
*/
|
||||
hasError?: boolean | null;
|
||||
/**
|
||||
* If hasError is true, this is the error that caused it
|
||||
*/
|
||||
error?:
|
||||
| {
|
||||
[k: string]: unknown;
|
||||
}
|
||||
| unknown[]
|
||||
| string
|
||||
| number
|
||||
| boolean
|
||||
| null;
|
||||
/**
|
||||
* Task execution log
|
||||
*/
|
||||
log?:
|
||||
| {
|
||||
executedAt: string;
|
||||
completedAt: string;
|
||||
taskSlug: 'inline' | 'PublishDocument' | 'UnpublishDocument';
|
||||
taskID: string;
|
||||
input?:
|
||||
| {
|
||||
[k: string]: unknown;
|
||||
}
|
||||
| unknown[]
|
||||
| string
|
||||
| number
|
||||
| boolean
|
||||
| null;
|
||||
output?:
|
||||
| {
|
||||
[k: string]: unknown;
|
||||
}
|
||||
| unknown[]
|
||||
| string
|
||||
| number
|
||||
| boolean
|
||||
| null;
|
||||
state: 'failed' | 'succeeded';
|
||||
error?:
|
||||
| {
|
||||
[k: string]: unknown;
|
||||
}
|
||||
| unknown[]
|
||||
| string
|
||||
| number
|
||||
| boolean
|
||||
| null;
|
||||
id?: string | null;
|
||||
}[]
|
||||
| null;
|
||||
taskSlug?: ('inline' | 'PublishDocument' | 'UnpublishDocument') | null;
|
||||
queue?: string | null;
|
||||
waitUntil?: string | null;
|
||||
processing?: boolean | null;
|
||||
updatedAt: string;
|
||||
createdAt: string;
|
||||
}
|
||||
/**
|
||||
* This interface was referenced by `Config`'s JSON-Schema
|
||||
* via the `definition` "payload-locked-documents".
|
||||
@@ -99,6 +200,10 @@ export interface PayloadLockedDocument {
|
||||
| ({
|
||||
relationTo: 'users';
|
||||
value: string | User;
|
||||
} | null)
|
||||
| ({
|
||||
relationTo: 'payload-jobs';
|
||||
value: string | PayloadJob;
|
||||
} | null);
|
||||
globalSlug?: string | null;
|
||||
user: {
|
||||
@@ -167,6 +272,37 @@ export interface UsersSelect<T extends boolean = true> {
|
||||
loginAttempts?: T;
|
||||
lockUntil?: T;
|
||||
}
|
||||
/**
|
||||
* This interface was referenced by `Config`'s JSON-Schema
|
||||
* via the `definition` "payload-jobs_select".
|
||||
*/
|
||||
export interface PayloadJobsSelect<T extends boolean = true> {
|
||||
input?: T;
|
||||
taskStatus?: T;
|
||||
completedAt?: T;
|
||||
totalTried?: T;
|
||||
hasError?: T;
|
||||
error?: T;
|
||||
log?:
|
||||
| T
|
||||
| {
|
||||
executedAt?: T;
|
||||
completedAt?: T;
|
||||
taskSlug?: T;
|
||||
taskID?: T;
|
||||
input?: T;
|
||||
output?: T;
|
||||
state?: T;
|
||||
error?: T;
|
||||
id?: T;
|
||||
};
|
||||
taskSlug?: T;
|
||||
queue?: T;
|
||||
waitUntil?: T;
|
||||
processing?: T;
|
||||
updatedAt?: T;
|
||||
createdAt?: T;
|
||||
}
|
||||
/**
|
||||
* This interface was referenced by `Config`'s JSON-Schema
|
||||
* via the `definition` "payload-locked-documents_select".
|
||||
@@ -199,6 +335,28 @@ export interface PayloadMigrationsSelect<T extends boolean = true> {
|
||||
updatedAt?: T;
|
||||
createdAt?: T;
|
||||
}
|
||||
/**
|
||||
* This interface was referenced by `Config`'s JSON-Schema
|
||||
* via the `definition` "TaskPublishDocument".
|
||||
*/
|
||||
export interface TaskPublishDocument {
|
||||
input: {
|
||||
collectionSlug: 'posts';
|
||||
documentID: string | number;
|
||||
};
|
||||
output?: unknown;
|
||||
}
|
||||
/**
|
||||
* This interface was referenced by `Config`'s JSON-Schema
|
||||
* via the `definition` "TaskUnpublishDocument".
|
||||
*/
|
||||
export interface TaskUnpublishDocument {
|
||||
input: {
|
||||
collectionSlug: 'posts';
|
||||
documentID: string | number;
|
||||
};
|
||||
output?: unknown;
|
||||
}
|
||||
/**
|
||||
* This interface was referenced by `Config`'s JSON-Schema
|
||||
* via the `definition` "auth".
|
||||
|
||||
Reference in New Issue
Block a user