diff --git a/index.d.ts b/index.d.ts index dea34c7..dce415d 100644 --- a/index.d.ts +++ b/index.d.ts @@ -68,6 +68,35 @@ interface PostHookData { data?: CollectionDocument } +interface JobConfig { + /** + * meta object + */ + meta?: any + + /** + * cron job interval specification + */ + cron?: string + + /** + * job program type + */ + type: "javascript" + + /** + * jobs program file + */ + file?: string +} + +interface JobData { + /** + * job is object of job config + */ + job?: JobConfig +} + interface DbPackage { /** * read results from a collection @@ -529,7 +558,8 @@ interface PdfPackage { export interface HookContext extends GetHookData, GetHookGetOnlyData, - PostHookData { + PostHookData, + JobData { request(): { method: string remoteAddr: string diff --git a/schemas/api-config/config.json b/schemas/api-config/config.json index 8789fa2..2628c84 100644 --- a/schemas/api-config/config.json +++ b/schemas/api-config/config.json @@ -34,6 +34,21 @@ } ] } + }, + "jobs": { + "type": "array", + "description": "list of jobs in this project", + "items": { + "oneOf": [ + { + "$comment": "for include tag", + "type": "string" + }, + { + "$ref": "job.json" + } + ] + } } }, "required": ["namespace"] diff --git a/schemas/api-config/job.json b/schemas/api-config/job.json new file mode 100644 index 0000000..cf479f7 --- /dev/null +++ b/schemas/api-config/job.json @@ -0,0 +1,27 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "title": "JSON Schema WMBasic cronjob configuration", + "description": "WMBasic cronjob linter", + "type": "object", + "additionalProperties": false, + "properties": { + "meta": { + "type": "object", + "description": "meta object used to pass parameters to identify cronjob", + "additionalProperties": true + }, + "cron": { + "type": "string", + "description": "cronjob time/interval specification" + }, + "type": { + "const": "javascript", + "description": "type of job" + }, + "file": { + "type": "string", + "description": "javascript file relative to config.yml" + } + }, + "required": ["type", "file"] +} \ No newline at end of file