@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);
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hatchet-dev/typescript-sdk",
3
- "version": "0.20.0",
3
+ "version": "0.20.2",
4
4
  "description": "Background task orchestration & visibility for developers",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [
package/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const HATCHET_VERSION = "0.20.0";
1
+ export declare const HATCHET_VERSION = "0.20.2";
package/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.HATCHET_VERSION = void 0;
4
- exports.HATCHET_VERSION = '0.20.0';
4
+ exports.HATCHET_VERSION = '0.20.2';