@hatchet-dev/typescript-sdk 0.20.0 → 0.20.2
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.
|
@@ -4,6 +4,7 @@ import { CronWorkflows, CronWorkflowsList } from '../../rest/generated/data-cont
|
|
|
4
4
|
import { z } from 'zod';
|
|
5
5
|
import { Workflow } from '../../../workflow';
|
|
6
6
|
import { ClientConfig } from '../client-config';
|
|
7
|
+
export declare const CronRegex: RegExp;
|
|
7
8
|
/**
|
|
8
9
|
* Schema for creating a Cron Trigger.
|
|
9
10
|
*/
|
|
@@ -9,19 +9,16 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.CronClient = exports.CreateCronTriggerSchema = void 0;
|
|
12
|
+
exports.CronClient = exports.CreateCronTriggerSchema = exports.CronRegex = void 0;
|
|
13
13
|
const zod_1 = require("zod");
|
|
14
14
|
const axios_1 = require("axios");
|
|
15
|
+
exports.CronRegex = /^(\*|([0-9]|[1-5][0-9])(,([0-9]|[1-5][0-9]))*|([0-9]|[1-5][0-9])-([0-9]|[1-5][0-9])|\*\/([0-9]|[1-5][0-9])) (\*|([0-9]|1[0-9]|2[0-3])(,([0-9]|1[0-9]|2[0-3]))*|([0-9]|1[0-9]|2[0-3])-([0-9]|1[0-9]|2[0-3])|\*\/([0-9]|1[0-9]|2[0-3])) (\*|([1-9]|[12][0-9]|3[01])(,([1-9]|[12][0-9]|3[01]))*|([1-9]|[12][0-9]|3[01])-([1-9]|[12][0-9]|3[01])|\*\/([1-9]|[12][0-9]|3[01])) (\*|([1-9]|1[0-2])(,([1-9]|1[0-2]))*|([1-9]|1[0-2])-([1-9]|1[0-2])|\*\/([1-9]|1[0-2])) (\*|([0-7])(,([0-7]))*|([0-7])-([0-7])|\*\/([0-7]))$/;
|
|
15
16
|
/**
|
|
16
17
|
* Schema for creating a Cron Trigger.
|
|
17
18
|
*/
|
|
18
19
|
exports.CreateCronTriggerSchema = zod_1.z.object({
|
|
19
20
|
name: zod_1.z.string(),
|
|
20
|
-
expression: zod_1.z.string().refine((val) =>
|
|
21
|
-
// Basic cron validation regex
|
|
22
|
-
const cronRegex = /^(\*|([0-9]|1[0-9]|2[0-9]|3[0-9]|4[0-9]|5[0-9])|\*\/([0-9]|1[0-9]|2[0-3])) (\*|([0-9]|1[0-9]|2[0-3])|\*\/([0-9]|1[0-9]|2[0-3])) (\*|([1-9]|1[0-9]|2[0-9]|3[0-1])|\*\/([1-9]|1[0-9]|2[0-9]|3[0-1])) (\*|([1-9]|1[0-2])|\*\/([1-9]|1[0-2])) (\*|([0-6])|\*\/([0-6]))$/;
|
|
23
|
-
return cronRegex.test(val);
|
|
24
|
-
}, 'Invalid cron expression'),
|
|
21
|
+
expression: zod_1.z.string().refine((val) => exports.CronRegex.test(val), 'Invalid cron expression'),
|
|
25
22
|
input: zod_1.z.record(zod_1.z.any()).optional(),
|
|
26
23
|
additionalMetadata: zod_1.z.record(zod_1.z.string()).optional(),
|
|
27
24
|
});
|
|
@@ -62,7 +59,6 @@ class CronClient {
|
|
|
62
59
|
return __awaiter(this, void 0, void 0, function* () {
|
|
63
60
|
var _a, _b, _c;
|
|
64
61
|
const workflowId = typeof workflow === 'string' ? workflow : workflow.id;
|
|
65
|
-
console.log('workflowId', workflowId);
|
|
66
62
|
// Validate cron input with zod schema
|
|
67
63
|
try {
|
|
68
64
|
const parsedCron = exports.CreateCronTriggerSchema.parse(cron);
|
package/clients/worker/worker.js
CHANGED
|
@@ -83,7 +83,7 @@ class Worker {
|
|
|
83
83
|
registerWorkflow(initWorkflow) {
|
|
84
84
|
return __awaiter(this, void 0, void 0, function* () {
|
|
85
85
|
var _a, _b, _c;
|
|
86
|
-
const workflow = Object.assign(Object.assign({}, initWorkflow), { id: this.client.config.namespace + initWorkflow.id });
|
|
86
|
+
const workflow = Object.assign(Object.assign({}, initWorkflow), { id: (this.client.config.namespace + initWorkflow.id).toLowerCase() });
|
|
87
87
|
try {
|
|
88
88
|
if (((_a = workflow.concurrency) === null || _a === void 0 ? void 0 : _a.key) && workflow.concurrency.expression) {
|
|
89
89
|
throw new hatchet_error_1.default('Cannot have both key function and expression in workflow concurrency configuration');
|
package/package.json
CHANGED
package/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const HATCHET_VERSION = "0.20.
|
|
1
|
+
export declare const HATCHET_VERSION = "0.20.2";
|
package/version.js
CHANGED