sails-hook-quest 0.0.4 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/types.js ADDED
@@ -0,0 +1,301 @@
1
+ /**
2
+ * Shared TypeScript-consumable JSDoc typedefs for Quest's public API.
3
+ *
4
+ * These comments are intentionally colocated with the JavaScript source so JSDoc
5
+ * stays the source of truth for editor autocomplete and local type checks.
6
+ *
7
+ * @typedef {Record<string, any>} AnyRecord
8
+ *
9
+ * @typedef {string | number | boolean | null} JsonPrimitive
10
+ *
11
+ * @typedef {JsonPrimitive | any[] | AnyRecord} JsonValue
12
+ *
13
+ * @typedef {string | number | false} QuestInterval
14
+ *
15
+ * @typedef {string | number | false} QuestTimeout
16
+ *
17
+ * @typedef {string | number | Date | false} QuestDateInput
18
+ *
19
+ * @typedef {Record<string, any>} QuestCronOptions
20
+ *
21
+ * @typedef {{
22
+ * defaultsTo?: any,
23
+ * type?: string,
24
+ * description?: string,
25
+ * required?: boolean,
26
+ * allowNull?: boolean,
27
+ * [key: string]: any,
28
+ * }} QuestMachineInputDefinition
29
+ *
30
+ * @typedef {Record<string, QuestMachineInputDefinition>} QuestMachineInputs
31
+ *
32
+ * @typedef {{
33
+ * name?: string,
34
+ * friendlyName?: string,
35
+ * description?: string,
36
+ * interval?: QuestInterval,
37
+ * timeout?: QuestTimeout,
38
+ * cron?: string,
39
+ * cronOptions?: QuestCronOptions,
40
+ * date?: QuestDateInput,
41
+ * timezone?: string,
42
+ * inputs?: AnyRecord,
43
+ * scriptInputs?: AnyRecord,
44
+ * withoutOverlapping?: boolean,
45
+ * paused?: boolean,
46
+ * [key: string]: any,
47
+ * }} QuestJobDefinition
48
+ *
49
+ * @typedef {QuestJobDefinition & { name: string }} QuestNamedJobDefinition
50
+ *
51
+ * @typedef {string | QuestNamedJobDefinition} QuestJobDefinitionInput
52
+ *
53
+ * @typedef {{
54
+ * name: string,
55
+ * script?: string,
56
+ * inputSchema?: QuestMachineInputs,
57
+ * friendlyName: string,
58
+ * description?: string,
59
+ * interval?: QuestInterval,
60
+ * timeout?: QuestTimeout,
61
+ * cron?: string,
62
+ * cronOptions?: QuestCronOptions,
63
+ * date?: QuestDateInput,
64
+ * timezone?: string,
65
+ * inputs: AnyRecord,
66
+ * scriptInputs: AnyRecord,
67
+ * paused: boolean,
68
+ * withoutOverlapping: boolean,
69
+ * }} QuestJob
70
+ *
71
+ * @typedef {{
72
+ * name: string,
73
+ * script?: string,
74
+ * inputSchema?: QuestMachineInputs,
75
+ * inputs?: AnyRecord,
76
+ * scriptInputs?: AnyRecord,
77
+ * paused?: boolean,
78
+ * withoutOverlapping?: boolean,
79
+ * }} QuestExecutableJob
80
+ *
81
+ * @typedef {{
82
+ * friendlyName?: string,
83
+ * description?: string,
84
+ * quest?: QuestJobDefinition,
85
+ * inputs?: QuestMachineInputs,
86
+ * fn?: Function,
87
+ * [key: string]: any,
88
+ * }} QuestScriptDefinition
89
+ *
90
+ * @typedef {string | string[] | null | undefined} QuestJobNameInput
91
+ *
92
+ * @typedef {{
93
+ * autoStart?: boolean,
94
+ * timezone?: string,
95
+ * withoutOverlapping?: boolean,
96
+ * sailsPath?: string,
97
+ * environment?: string,
98
+ * scriptsDir?: string,
99
+ * appPath?: string,
100
+ * diagnosticTailBytes?: number,
101
+ * jobs?: QuestJobDefinitionInput[],
102
+ * [key: string]: any,
103
+ * }} QuestConfig
104
+ *
105
+ * @typedef {{
106
+ * skipped: true,
107
+ * reason: 'already_running' | 'paused',
108
+ * runId?: string,
109
+ * runtimeId?: string,
110
+ * startedAt?: Date,
111
+ * trigger?: 'manual' | 'scheduled',
112
+ * finishedAt?: Date,
113
+ * exitCode?: number | null,
114
+ * signal?: string | null,
115
+ * }} QuestSkippedResult
116
+ *
117
+ * @typedef {{
118
+ * success: true,
119
+ * duration: number,
120
+ * runId?: string,
121
+ * runtimeId?: string,
122
+ * sequence?: number,
123
+ * startedAt?: Date,
124
+ * trigger?: 'manual' | 'scheduled',
125
+ * finishedAt?: Date,
126
+ * exitCode?: number | null,
127
+ * signal?: string | null,
128
+ * result?: QuestBusinessResult,
129
+ * logs?: QuestLogs,
130
+ * }} QuestSuccessResult
131
+ *
132
+ * @typedef {{status: string, value?: any, reason?: string, exit?: string}} QuestBusinessResult
133
+ *
134
+ * @typedef {{stdout: string, stderr: string, stdoutTruncated: boolean, stderrTruncated: boolean, limitBytes: number}} QuestLogs
135
+ *
136
+ * @typedef {{runtimeId: string, sequence: number, active: Map<string, Map<string, number>>}} QuestRuntime
137
+ *
138
+ * @typedef {QuestSkippedResult | QuestSuccessResult} QuestExecutionResult
139
+ *
140
+ * @typedef {{
141
+ * name: string,
142
+ * runId?: string,
143
+ * runtimeId?: string,
144
+ * sequence?: number,
145
+ * startedAt?: Date,
146
+ * trigger?: 'manual' | 'scheduled',
147
+ * finishedAt?: Date,
148
+ * exitCode?: number | null,
149
+ * signal?: string | null,
150
+ * result?: QuestBusinessResult,
151
+ * logs?: QuestLogs,
152
+ * inputs: AnyRecord,
153
+ * timestamp: Date,
154
+ * }} QuestJobStartEvent
155
+ *
156
+ * @typedef {{
157
+ * name: string,
158
+ * runId?: string,
159
+ * runtimeId?: string,
160
+ * sequence?: number,
161
+ * startedAt?: Date,
162
+ * trigger?: 'manual' | 'scheduled',
163
+ * finishedAt?: Date,
164
+ * exitCode?: number | null,
165
+ * signal?: string | null,
166
+ * result?: QuestBusinessResult,
167
+ * logs?: QuestLogs,
168
+ * inputs: AnyRecord,
169
+ * duration: number,
170
+ * timestamp: Date,
171
+ * }} QuestJobCompleteEvent
172
+ *
173
+ * @typedef {{
174
+ * message: string,
175
+ * code?: number | null,
176
+ * stack?: string,
177
+ * diagnostic?: string,
178
+ * }} QuestJobErrorDetails
179
+ *
180
+ * @typedef {{
181
+ * name: string,
182
+ * runId?: string,
183
+ * runtimeId?: string,
184
+ * sequence?: number,
185
+ * startedAt?: Date,
186
+ * trigger?: 'manual' | 'scheduled',
187
+ * finishedAt?: Date,
188
+ * exitCode?: number | null,
189
+ * signal?: string | null,
190
+ * result?: QuestBusinessResult,
191
+ * logs?: QuestLogs,
192
+ * inputs: AnyRecord,
193
+ * error: QuestJobErrorDetails,
194
+ * duration: number,
195
+ * timestamp: Date,
196
+ * }} QuestJobErrorEvent
197
+ *
198
+ * @typedef {{
199
+ * start(jobNames?: QuestJobNameInput): Promise<void>,
200
+ * stop(jobNames?: QuestJobNameInput): void,
201
+ * run(jobNames?: QuestJobNameInput, inputs?: AnyRecord): Promise<QuestExecutionResult[]>,
202
+ * add(jobDefs: QuestJobDefinitionInput | QuestJobDefinitionInput[]): string[],
203
+ * remove(jobNames: QuestJobNameInput): string[],
204
+ * getRuntime(): AnyRecord,
205
+ * metadata(name?: string): AnyRecord | AnyRecord[] | undefined,
206
+ * jobs: QuestJob[],
207
+ * list(): QuestJob[],
208
+ * get(name: string): QuestJob | undefined,
209
+ * isRunning(name: string): boolean,
210
+ * pause(name: string): boolean,
211
+ * resume(name: string): boolean,
212
+ * }} QuestApi
213
+ *
214
+ * @typedef {Map<string, QuestJob>} QuestJobsMap
215
+ *
216
+ * @typedef {Map<string, ReturnType<typeof setTimeout>>} QuestTimersMap
217
+ *
218
+ * @typedef {Map<string, number>} QuestRunningMap
219
+ *
220
+ * @typedef {{
221
+ * jobs: QuestJobsMap,
222
+ * timers: QuestTimersMap,
223
+ * running: QuestRunningMap,
224
+ * sails: QuestSailsApp,
225
+ * runtime: QuestRuntime,
226
+ * dueTimes: Map<string, Date>,
227
+ * scheduleStates?: Map<string, AnyRecord>,
228
+ * config: QuestConfig | null,
229
+ * scheduleJob: ((name: string) => void) | null,
230
+ * executeJob: ((name: string, customInputs?: AnyRecord, trigger?: 'manual' | 'scheduled') => Promise<QuestExecutionResult>) | null,
231
+ * getNextRunTime: ((job: QuestJob) => Date | null) | null,
232
+ * }} QuestContext
233
+ *
234
+ * @typedef {{
235
+ * jobs?: QuestJobsMap,
236
+ * timers?: QuestTimersMap,
237
+ * dueTimes?: Map<string, Date>,
238
+ * scheduleStates?: Map<string, AnyRecord>,
239
+ * getNextRunTime?: (job: QuestJob) => Date | null,
240
+ * executeJob?: (name: string, customInputs?: AnyRecord, trigger?: 'manual' | 'scheduled') => Promise<QuestExecutionResult>,
241
+ * }} QuestScheduleContext
242
+ *
243
+ * @typedef {{
244
+ * jobs?: QuestJobsMap,
245
+ * scheduleJob?: (name: string) => void,
246
+ * }} QuestStartContext
247
+ *
248
+ * @typedef {{
249
+ * jobs?: QuestJobsMap,
250
+ * timers?: QuestTimersMap,
251
+ * dueTimes?: Map<string, Date>,
252
+ * scheduleStates?: Map<string, AnyRecord>,
253
+ * }} QuestStopContext
254
+ *
255
+ * @typedef {{
256
+ * jobs?: QuestJobsMap,
257
+ * executeJob?: (name: string, customInputs?: AnyRecord, trigger?: 'manual' | 'scheduled') => Promise<QuestExecutionResult>,
258
+ * }} QuestRunContext
259
+ *
260
+ * @typedef {{
261
+ * trigger?: 'manual' | 'scheduled',
262
+ * running?: QuestRunningMap,
263
+ * sails?: QuestSailsApp,
264
+ * runtime?: QuestRuntime,
265
+ * config?: QuestConfig | null,
266
+ * stdout?: NodeJS.WritableStream,
267
+ * stderr?: NodeJS.WritableStream,
268
+ * }} QuestExecutorContext
269
+ *
270
+ * @typedef {{
271
+ * info(...args: any[]): void,
272
+ * warn(...args: any[]): void,
273
+ * error(...args: any[]): void,
274
+ * verbose(...args: any[]): void,
275
+ * [key: string]: any,
276
+ * }} QuestLogger
277
+ *
278
+ * @typedef {{
279
+ * config: {
280
+ * quest: QuestConfig,
281
+ * [key: string]: any,
282
+ * },
283
+ * log: QuestLogger,
284
+ * after(eventName: string, handler: Function): void,
285
+ * on(eventName: string, handler: Function): void,
286
+ * emit(eventName: 'quest:job:start', payload: QuestJobStartEvent): void,
287
+ * emit(eventName: 'quest:job:complete', payload: QuestJobCompleteEvent): void,
288
+ * emit(eventName: 'quest:job:error', payload: QuestJobErrorEvent): void,
289
+ * emit(eventName: string, payload?: any): void,
290
+ * quest?: QuestApi,
291
+ * [key: string]: any,
292
+ * }} QuestSailsApp
293
+ *
294
+ * @typedef {{
295
+ * defaults: { quest: QuestConfig },
296
+ * initialize(): Promise<void>,
297
+ * [key: string]: any,
298
+ * }} QuestSailsHook
299
+ */
300
+
301
+ module.exports = {}
package/package.json CHANGED
@@ -1,11 +1,20 @@
1
1
  {
2
2
  "name": "sails-hook-quest",
3
- "version": "0.0.4",
3
+ "version": "0.0.6",
4
4
  "description": "Elegant job scheduling for Sails.js applications with human-readable intervals, cron expressions, and full Sails context",
5
5
  "main": "lib/index.js",
6
+ "files": [
7
+ "lib",
8
+ "README.md",
9
+ "CONTRACT.md",
10
+ "CHANGELOG.md",
11
+ "LICENSE"
12
+ ],
6
13
  "scripts": {
14
+ "test": "sounding test",
7
15
  "lint": "prettier --check .",
8
16
  "lint:fix": "prettier --write .",
17
+ "typecheck": "tsc -p jsconfig.json --noEmit",
9
18
  "prepare": "husky"
10
19
  },
11
20
  "repository": {
@@ -50,8 +59,13 @@
50
59
  "devDependencies": {
51
60
  "@commitlint/cli": "^19.5.0",
52
61
  "@commitlint/config-conventional": "^19.5.0",
62
+ "@types/node": "^22.7.5",
53
63
  "husky": "^9.1.6",
54
64
  "lint-staged": "^15.2.10",
55
- "prettier": "^3.3.3"
65
+ "prettier": "^3.3.3",
66
+ "sails": "^1.5.18",
67
+ "sails-hook-orm": "^4.0.3",
68
+ "sounding": "^0.2.0",
69
+ "typescript": "^5.6.2"
56
70
  }
57
71
  }
@@ -1,7 +0,0 @@
1
- {
2
- "permissions": {
3
- "allow": ["WebFetch(domain:github.com)"],
4
- "deny": [],
5
- "ask": []
6
- }
7
- }
package/.commitlintrc.js DELETED
@@ -1 +0,0 @@
1
- module.exports = { extends: ['@commitlint/config-conventional'] }
@@ -1 +0,0 @@
1
- github: DominusKelvin
@@ -1,22 +0,0 @@
1
- name: Prettier
2
-
3
- on: [push, pull_request]
4
-
5
- jobs:
6
- prettier:
7
- runs-on: ubuntu-latest
8
-
9
- steps:
10
- - name: Checkout code
11
- uses: actions/checkout@v3
12
-
13
- - name: Setup Node.js
14
- uses: actions/setup-node@v3
15
- with:
16
- node-version: 18
17
-
18
- - name: Run npm ci
19
- run: npm ci
20
-
21
- - name: Run Prettier
22
- run: npx prettier --config ./.prettierrc.js --write .
package/.husky/pre-commit DELETED
@@ -1 +0,0 @@
1
- npx lint-staged
package/.prettierrc.js DELETED
@@ -1,5 +0,0 @@
1
- module.exports = {
2
- semi: false,
3
- singleQuote: true,
4
- trailingComma: 'none'
5
- }
Binary file