@hatchet-dev/typescript-sdk 0.0.1

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.
Files changed (120) hide show
  1. package/.eslintrc.json +36 -0
  2. package/.prettierrc.json +6 -0
  3. package/README.md +4 -0
  4. package/dist/hatchet/clients/admin/admin-client.d.ts +14 -0
  5. package/dist/hatchet/clients/admin/admin-client.js +50 -0
  6. package/dist/hatchet/clients/admin/admin-client.test.d.ts +1 -0
  7. package/dist/hatchet/clients/admin/admin-client.test.js +101 -0
  8. package/dist/hatchet/clients/dispatcher/action-listener.d.ts +24 -0
  9. package/dist/hatchet/clients/dispatcher/action-listener.js +113 -0
  10. package/dist/hatchet/clients/dispatcher/action-listener.test.d.ts +4 -0
  11. package/dist/hatchet/clients/dispatcher/action-listener.test.js +277 -0
  12. package/dist/hatchet/clients/dispatcher/dispatcher-client.d.ts +17 -0
  13. package/dist/hatchet/clients/dispatcher/dispatcher-client.js +46 -0
  14. package/dist/hatchet/clients/dispatcher/dispatcher-client.test.d.ts +1 -0
  15. package/dist/hatchet/clients/dispatcher/dispatcher-client.test.js +99 -0
  16. package/dist/hatchet/clients/event/event-client.d.ts +9 -0
  17. package/dist/hatchet/clients/event/event-client.js +28 -0
  18. package/dist/hatchet/clients/event/event-client.test.d.ts +1 -0
  19. package/dist/hatchet/clients/event/event-client.test.js +60 -0
  20. package/dist/hatchet/clients/hatchet-client/client-config.d.ts +72 -0
  21. package/dist/hatchet/clients/hatchet-client/client-config.js +17 -0
  22. package/dist/hatchet/clients/hatchet-client/hatchet-client.d.ts +26 -0
  23. package/dist/hatchet/clients/hatchet-client/hatchet-client.js +133 -0
  24. package/dist/hatchet/clients/hatchet-client/hatchet-client.test.d.ts +2 -0
  25. package/dist/hatchet/clients/hatchet-client/hatchet-client.test.js +135 -0
  26. package/dist/hatchet/clients/hatchet-client/index.d.ts +2 -0
  27. package/dist/hatchet/clients/hatchet-client/index.js +18 -0
  28. package/dist/hatchet/clients/worker/index.d.ts +1 -0
  29. package/dist/hatchet/clients/worker/index.js +17 -0
  30. package/dist/hatchet/clients/worker/worker.d.ts +31 -0
  31. package/dist/hatchet/clients/worker/worker.js +228 -0
  32. package/dist/hatchet/clients/worker/worker.test.d.ts +1 -0
  33. package/dist/hatchet/clients/worker/worker.test.js +256 -0
  34. package/dist/hatchet/index.d.ts +2 -0
  35. package/dist/hatchet/index.js +4 -0
  36. package/dist/hatchet/sdk.d.ts +2 -0
  37. package/dist/hatchet/sdk.js +4 -0
  38. package/dist/hatchet/step.d.ts +30 -0
  39. package/dist/hatchet/step.js +63 -0
  40. package/dist/hatchet/util/config-loader/config-loader.d.ts +13 -0
  41. package/dist/hatchet/util/config-loader/config-loader.js +85 -0
  42. package/dist/hatchet/util/config-loader/config-loader.test.d.ts +1 -0
  43. package/dist/hatchet/util/config-loader/config-loader.test.js +72 -0
  44. package/dist/hatchet/util/config-loader/index.d.ts +1 -0
  45. package/dist/hatchet/util/config-loader/index.js +17 -0
  46. package/dist/hatchet/util/errors/hatchet-error.d.ts +4 -0
  47. package/dist/hatchet/util/errors/hatchet-error.js +9 -0
  48. package/dist/hatchet/util/hatchet-promise/hatchet-promise.d.ts +6 -0
  49. package/dist/hatchet/util/hatchet-promise/hatchet-promise.js +12 -0
  50. package/dist/hatchet/util/hatchet-promise/hatchet-promise.test.d.ts +1 -0
  51. package/dist/hatchet/util/hatchet-promise/hatchet-promise.test.js +40 -0
  52. package/dist/hatchet/util/logger/index.d.ts +1 -0
  53. package/dist/hatchet/util/logger/index.js +17 -0
  54. package/dist/hatchet/util/logger/logger.d.ts +12 -0
  55. package/dist/hatchet/util/logger/logger.js +37 -0
  56. package/dist/hatchet/util/sleep.d.ts +2 -0
  57. package/dist/hatchet/util/sleep.js +6 -0
  58. package/dist/hatchet/workflow.d.ts +78 -0
  59. package/dist/hatchet/workflow.js +44 -0
  60. package/dist/protoc/dispatcher/dispatcher.d.ts +273 -0
  61. package/dist/protoc/dispatcher/dispatcher.js +918 -0
  62. package/dist/protoc/dispatcher/index.d.ts +1 -0
  63. package/dist/protoc/dispatcher/index.js +17 -0
  64. package/dist/protoc/events/events.d.ts +165 -0
  65. package/dist/protoc/events/events.js +443 -0
  66. package/dist/protoc/google/protobuf/timestamp.d.ts +121 -0
  67. package/dist/protoc/google/protobuf/timestamp.js +110 -0
  68. package/dist/protoc/google/protobuf/wrappers.d.ts +160 -0
  69. package/dist/protoc/google/protobuf/wrappers.js +527 -0
  70. package/dist/protoc/workflows/index.d.ts +1 -0
  71. package/dist/protoc/workflows/index.js +17 -0
  72. package/dist/protoc/workflows/workflows.d.ts +438 -0
  73. package/dist/protoc/workflows/workflows.js +1814 -0
  74. package/examples/dag-worker.ts +55 -0
  75. package/examples/example-event.ts +7 -0
  76. package/examples/simple-worker.ts +39 -0
  77. package/generate-protoc.sh +10 -0
  78. package/hatchet/clients/admin/admin-client.test.ts +116 -0
  79. package/hatchet/clients/admin/admin-client.ts +43 -0
  80. package/hatchet/clients/dispatcher/action-listener.test.ts +270 -0
  81. package/hatchet/clients/dispatcher/action-listener.ts +91 -0
  82. package/hatchet/clients/dispatcher/dispatcher-client.test.ts +111 -0
  83. package/hatchet/clients/dispatcher/dispatcher-client.ts +47 -0
  84. package/hatchet/clients/event/event-client.test.ts +72 -0
  85. package/hatchet/clients/event/event-client.ts +32 -0
  86. package/hatchet/clients/hatchet-client/client-config.ts +22 -0
  87. package/hatchet/clients/hatchet-client/fixtures/.hatchet-invalid.yaml +6 -0
  88. package/hatchet/clients/hatchet-client/fixtures/.hatchet.yaml +8 -0
  89. package/hatchet/clients/hatchet-client/hatchet-client.test.ts +162 -0
  90. package/hatchet/clients/hatchet-client/hatchet-client.ts +136 -0
  91. package/hatchet/clients/hatchet-client/index.ts +2 -0
  92. package/hatchet/clients/worker/index.ts +1 -0
  93. package/hatchet/clients/worker/worker.test.ts +347 -0
  94. package/hatchet/clients/worker/worker.ts +229 -0
  95. package/hatchet/index.ts +3 -0
  96. package/hatchet/sdk.ts +3 -0
  97. package/hatchet/step.ts +48 -0
  98. package/hatchet/util/config-loader/config-loader.test.ts +79 -0
  99. package/hatchet/util/config-loader/config-loader.ts +91 -0
  100. package/hatchet/util/config-loader/fixtures/.hatchet-invalid.yaml +6 -0
  101. package/hatchet/util/config-loader/fixtures/.hatchet.yaml +8 -0
  102. package/hatchet/util/config-loader/index.ts +1 -0
  103. package/hatchet/util/errors/hatchet-error.ts +8 -0
  104. package/hatchet/util/hatchet-promise/hatchet-promise.test.ts +32 -0
  105. package/hatchet/util/hatchet-promise/hatchet-promise.ts +13 -0
  106. package/hatchet/util/logger/index.ts +1 -0
  107. package/hatchet/util/logger/logger.ts +44 -0
  108. package/hatchet/util/sleep.ts +6 -0
  109. package/hatchet/workflow.ts +30 -0
  110. package/jest.config.ts +205 -0
  111. package/package.json +65 -0
  112. package/protoc/dispatcher/dispatcher.ts +1101 -0
  113. package/protoc/dispatcher/index.ts +1 -0
  114. package/protoc/events/events.ts +519 -0
  115. package/protoc/events/index.ts +1 -0
  116. package/protoc/google/protobuf/timestamp.ts +210 -0
  117. package/protoc/google/protobuf/wrappers.ts +657 -0
  118. package/protoc/workflows/index.ts +1 -0
  119. package/protoc/workflows/workflows.ts +2158 -0
  120. package/tsconfig.json +120 -0
@@ -0,0 +1,85 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.ConfigLoader = void 0;
27
+ const yaml_1 = require("yaml");
28
+ const fs_1 = require("fs");
29
+ const p = __importStar(require("path"));
30
+ const zod_1 = require("zod");
31
+ const hatchet_client_1 = require("@clients/hatchet-client");
32
+ const nice_grpc_1 = require("nice-grpc");
33
+ const DEFAULT_CONFIG_FILE = '.hatchet.yaml';
34
+ class ConfigLoader {
35
+ static load_client_config(config) {
36
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
37
+ const yaml = this.load_yaml_config(config === null || config === void 0 ? void 0 : config.path);
38
+ const tlsConfig = {
39
+ tls_strategy: (_c = (_b = (_a = yaml === null || yaml === void 0 ? void 0 : yaml.tls_config) === null || _a === void 0 ? void 0 : _a.tls_strategy) !== null && _b !== void 0 ? _b : this.env('HATCHET_CLIENT_TLS_STRATEGY')) !== null && _c !== void 0 ? _c : 'tls',
40
+ cert_file: (_e = (_d = yaml === null || yaml === void 0 ? void 0 : yaml.tls_config) === null || _d === void 0 ? void 0 : _d.cert_file) !== null && _e !== void 0 ? _e : this.env('HATCHET_CLIENT_TLS_CERT_FILE'),
41
+ key_file: (_g = (_f = yaml === null || yaml === void 0 ? void 0 : yaml.tls_config) === null || _f === void 0 ? void 0 : _f.key_file) !== null && _g !== void 0 ? _g : this.env('HATCHET_CLIENT_TLS_KEY_FILE'),
42
+ ca_file: (_j = (_h = yaml === null || yaml === void 0 ? void 0 : yaml.tls_config) === null || _h === void 0 ? void 0 : _h.ca_file) !== null && _j !== void 0 ? _j : this.env('HATCHET_CLIENT_TLS_ROOT_CA_FILE'),
43
+ server_name: (_l = (_k = yaml === null || yaml === void 0 ? void 0 : yaml.tls_config) === null || _k === void 0 ? void 0 : _k.server_name) !== null && _l !== void 0 ? _l : this.env('HATCHET_CLIENT_TLS_SERVER_NAME'),
44
+ };
45
+ return {
46
+ token: (_m = yaml === null || yaml === void 0 ? void 0 : yaml.token) !== null && _m !== void 0 ? _m : this.env('HATCHET_CLIENT_TOKEN'),
47
+ host_port: (_o = yaml === null || yaml === void 0 ? void 0 : yaml.host_port) !== null && _o !== void 0 ? _o : this.env('HATCHET_CLIENT_HOST_PORT'),
48
+ tls_config: tlsConfig,
49
+ log_level: (_q = (_p = yaml === null || yaml === void 0 ? void 0 : yaml.log_level) !== null && _p !== void 0 ? _p : this.env('HATCHET_CLIENT_LOG_LEVEL')) !== null && _q !== void 0 ? _q : 'INFO',
50
+ };
51
+ }
52
+ static get default_yaml_config_path() {
53
+ return p.join(process.cwd(), DEFAULT_CONFIG_FILE);
54
+ }
55
+ static createCredentials(config) {
56
+ if (config.tls_strategy === 'tls') {
57
+ const rootCerts = config.ca_file ? (0, fs_1.readFileSync)(config.ca_file) : undefined;
58
+ return nice_grpc_1.ChannelCredentials.createSsl(rootCerts);
59
+ }
60
+ const rootCerts = config.ca_file ? (0, fs_1.readFileSync)(config.ca_file) : null;
61
+ const privateKey = config.key_file ? (0, fs_1.readFileSync)(config.key_file) : null;
62
+ const certChain = config.cert_file ? (0, fs_1.readFileSync)(config.cert_file) : null;
63
+ return nice_grpc_1.ChannelCredentials.createSsl(rootCerts, privateKey, certChain);
64
+ }
65
+ static load_yaml_config(path) {
66
+ try {
67
+ const configFile = (0, fs_1.readFileSync)(p.join(__dirname, path !== null && path !== void 0 ? path : this.default_yaml_config_path), 'utf8');
68
+ const config = (0, yaml_1.parse)(configFile);
69
+ hatchet_client_1.ClientConfigSchema.partial().parse(config);
70
+ return config;
71
+ }
72
+ catch (e) {
73
+ if (!path)
74
+ return undefined;
75
+ if (e instanceof zod_1.z.ZodError) {
76
+ throw new Error(`Invalid yaml config: ${e.message}`);
77
+ }
78
+ throw e;
79
+ }
80
+ }
81
+ static env(name) {
82
+ return process.env[name];
83
+ }
84
+ }
85
+ exports.ConfigLoader = ConfigLoader;
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const config_loader_1 = require("./config-loader");
4
+ fdescribe('ConfigLoader', () => {
5
+ beforeEach(() => {
6
+ process.env.HATCHET_CLIENT_HOST_PORT = 'HOST_PORT';
7
+ process.env.HATCHET_CLIENT_TLS_CERT_FILE = 'TLS_CERT_FILE';
8
+ process.env.HATCHET_CLIENT_TLS_KEY_FILE = 'TLS_KEY_FILE';
9
+ process.env.HATCHET_CLIENT_TLS_ROOT_CA_FILE = 'TLS_ROOT_CA_FILE';
10
+ process.env.HATCHET_CLIENT_TLS_SERVER_NAME = 'TLS_SERVER_NAME';
11
+ });
12
+ it('should load from environment variables', () => {
13
+ const config = config_loader_1.ConfigLoader.load_client_config();
14
+ expect(config).toEqual({
15
+ host_port: 'HOST_PORT',
16
+ log_level: 'INFO',
17
+ tls_config: {
18
+ tls_strategy: 'tls',
19
+ cert_file: 'TLS_CERT_FILE',
20
+ key_file: 'TLS_KEY_FILE',
21
+ ca_file: 'TLS_ROOT_CA_FILE',
22
+ server_name: 'TLS_SERVER_NAME',
23
+ },
24
+ });
25
+ });
26
+ it('should throw an error if the file is not found', () => {
27
+ expect(() => config_loader_1.ConfigLoader.load_client_config({
28
+ path: './fixtures/not-found.yaml',
29
+ })).toThrow();
30
+ });
31
+ xit('should throw an error if the yaml file fails validation', () => {
32
+ expect(() =>
33
+ // This test is failing because there is no invalid state of the yaml file, need to update with tls and mtls settings
34
+ config_loader_1.ConfigLoader.load_client_config({
35
+ path: './fixtures/.hatchet-invalid.yaml',
36
+ })).toThrow();
37
+ });
38
+ it('should favor yaml config over env vars', () => {
39
+ const config = config_loader_1.ConfigLoader.load_client_config({
40
+ path: './fixtures/.hatchet.yaml',
41
+ });
42
+ expect(config).toEqual({
43
+ token: 'TOKEN_YAML',
44
+ host_port: 'HOST_PORT_YAML',
45
+ log_level: 'INFO',
46
+ tls_config: {
47
+ tls_strategy: 'tls',
48
+ cert_file: 'TLS_CERT_FILE_YAML',
49
+ key_file: 'TLS_KEY_FILE_YAML',
50
+ ca_file: 'TLS_ROOT_CA_FILE_YAML',
51
+ server_name: 'TLS_SERVER_NAME_YAML',
52
+ },
53
+ });
54
+ });
55
+ xit('should attempt to load the root .hatchet.yaml config', () => {
56
+ // i'm not sure the best way to test this, maybe spy on readFileSync called with
57
+ const config = config_loader_1.ConfigLoader.load_client_config({
58
+ path: './fixtures/.hatchet.yaml',
59
+ });
60
+ expect(config).toEqual({
61
+ token: 'TOKEN_YAML',
62
+ host_port: 'HOST_PORT_YAML',
63
+ tls_config: {
64
+ tls_strategy: 'tls',
65
+ cert_file: 'TLS_CERT_FILE_YAML',
66
+ key_file: 'TLS_KEY_FILE_YAML',
67
+ ca_file: 'TLS_ROOT_CA_FILE_YAML',
68
+ server_name: 'TLS_SERVER_NAME_YAML',
69
+ },
70
+ });
71
+ });
72
+ });
@@ -0,0 +1 @@
1
+ export * from './config-loader';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./config-loader"), exports);
@@ -0,0 +1,4 @@
1
+ declare class HatchetError extends Error {
2
+ constructor(message: string);
3
+ }
4
+ export default HatchetError;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class HatchetError extends Error {
4
+ constructor(message) {
5
+ super(message);
6
+ this.name = 'HatchetError';
7
+ }
8
+ }
9
+ exports.default = HatchetError;
@@ -0,0 +1,6 @@
1
+ declare class HatchetPromise<T> {
2
+ cancel: Function;
3
+ promise: Promise<T>;
4
+ constructor(promise: Promise<T>);
5
+ }
6
+ export default HatchetPromise;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ class HatchetPromise {
4
+ constructor(promise) {
5
+ this.cancel = (reason) => { };
6
+ this.promise = new Promise((resolve, reject) => {
7
+ this.cancel = reject;
8
+ Promise.resolve(promise).then(resolve).catch(reject);
9
+ });
10
+ }
11
+ }
12
+ exports.default = HatchetPromise;
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ const hatchet_promise_1 = __importDefault(require("./hatchet-promise"));
16
+ describe('HatchetPromise', () => {
17
+ it('should resolve the original promise if not canceled', () => __awaiter(void 0, void 0, void 0, function* () {
18
+ const hatchetPromise = new hatchet_promise_1.default(new Promise((resolve) => {
19
+ setTimeout(() => resolve('RESOLVED'), 500);
20
+ }));
21
+ const result = yield hatchetPromise.promise;
22
+ expect(result).toEqual('RESOLVED');
23
+ }));
24
+ it('should resolve the cancel promise if canceled', () => __awaiter(void 0, void 0, void 0, function* () {
25
+ const hatchetPromise = new hatchet_promise_1.default(new Promise((resolve) => {
26
+ setTimeout(() => resolve('RESOLVED'), 500);
27
+ }));
28
+ const result = hatchetPromise.promise;
29
+ setTimeout(() => {
30
+ hatchetPromise.cancel();
31
+ }, 100);
32
+ try {
33
+ yield result;
34
+ expect(true).toEqual(false); // this should not be reached
35
+ }
36
+ catch (e) {
37
+ expect(e).toEqual(undefined);
38
+ }
39
+ }));
40
+ });
@@ -0,0 +1 @@
1
+ export * from './logger';
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./logger"), exports);
@@ -0,0 +1,12 @@
1
+ export type LogLevel = 'OFF' | 'DEBUG' | 'INFO' | 'WARN' | 'ERROR';
2
+ export declare class Logger {
3
+ private logLevel;
4
+ private context;
5
+ constructor(context: string, logLevel?: LogLevel);
6
+ private log;
7
+ debug(message: string): void;
8
+ info(message: string): void;
9
+ warn(message: string): void;
10
+ error(message: string): void;
11
+ }
12
+ export default Logger;
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Logger = void 0;
4
+ // eslint-disable-next-line no-shadow
5
+ var LogLevelEnum;
6
+ (function (LogLevelEnum) {
7
+ LogLevelEnum[LogLevelEnum["OFF"] = -1] = "OFF";
8
+ LogLevelEnum[LogLevelEnum["DEBUG"] = 0] = "DEBUG";
9
+ LogLevelEnum[LogLevelEnum["INFO"] = 1] = "INFO";
10
+ LogLevelEnum[LogLevelEnum["WARN"] = 2] = "WARN";
11
+ LogLevelEnum[LogLevelEnum["ERROR"] = 3] = "ERROR";
12
+ })(LogLevelEnum || (LogLevelEnum = {}));
13
+ class Logger {
14
+ constructor(context, logLevel = 'INFO') {
15
+ this.logLevel = logLevel;
16
+ this.context = context;
17
+ }
18
+ log(level, message) {
19
+ if (LogLevelEnum[level] >= LogLevelEnum[this.logLevel]) {
20
+ console.log(`🪓 [${level}/${this.context}] ${message}`);
21
+ }
22
+ }
23
+ debug(message) {
24
+ this.log('DEBUG', message);
25
+ }
26
+ info(message) {
27
+ this.log('INFO', message);
28
+ }
29
+ warn(message) {
30
+ this.log('WARN', message);
31
+ }
32
+ error(message) {
33
+ this.log('ERROR', message);
34
+ }
35
+ }
36
+ exports.Logger = Logger;
37
+ exports.default = Logger;
@@ -0,0 +1,2 @@
1
+ declare const sleep: (ms: number) => Promise<unknown>;
2
+ export default sleep;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const sleep = (ms) => new Promise((resolve) => {
4
+ setTimeout(resolve, ms);
5
+ });
6
+ exports.default = sleep;
@@ -0,0 +1,78 @@
1
+ import * as z from 'zod';
2
+ import { CreateStep } from './step';
3
+ declare const StepsSchema: z.ZodArray<z.ZodObject<{
4
+ name: z.ZodString;
5
+ parents: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
6
+ }, "strip", z.ZodTypeAny, {
7
+ name: string;
8
+ parents?: string[] | undefined;
9
+ }, {
10
+ name: string;
11
+ parents?: string[] | undefined;
12
+ }>, "many">;
13
+ export type Steps = z.infer<typeof StepsSchema>;
14
+ export declare const CreateWorkflowSchema: z.ZodObject<{
15
+ id: z.ZodString;
16
+ description: z.ZodString;
17
+ on: z.ZodUnion<[z.ZodObject<{
18
+ cron: z.ZodString;
19
+ event: z.ZodUndefined;
20
+ }, "strip", z.ZodTypeAny, {
21
+ cron: string;
22
+ event?: undefined;
23
+ }, {
24
+ cron: string;
25
+ event?: undefined;
26
+ }>, z.ZodObject<{
27
+ cron: z.ZodUndefined;
28
+ event: z.ZodString;
29
+ }, "strip", z.ZodTypeAny, {
30
+ event: string;
31
+ cron?: undefined;
32
+ }, {
33
+ event: string;
34
+ cron?: undefined;
35
+ }>]>;
36
+ steps: z.ZodArray<z.ZodObject<{
37
+ name: z.ZodString;
38
+ parents: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
39
+ }, "strip", z.ZodTypeAny, {
40
+ name: string;
41
+ parents?: string[] | undefined;
42
+ }, {
43
+ name: string;
44
+ parents?: string[] | undefined;
45
+ }>, "many">;
46
+ }, "strip", z.ZodTypeAny, {
47
+ description: string;
48
+ steps: {
49
+ name: string;
50
+ parents?: string[] | undefined;
51
+ }[];
52
+ id: string;
53
+ on: {
54
+ cron: string;
55
+ event?: undefined;
56
+ } | {
57
+ event: string;
58
+ cron?: undefined;
59
+ };
60
+ }, {
61
+ description: string;
62
+ steps: {
63
+ name: string;
64
+ parents?: string[] | undefined;
65
+ }[];
66
+ id: string;
67
+ on: {
68
+ cron: string;
69
+ event?: undefined;
70
+ } | {
71
+ event: string;
72
+ cron?: undefined;
73
+ };
74
+ }>;
75
+ export interface Workflow extends z.infer<typeof CreateWorkflowSchema> {
76
+ steps: CreateStep<any>[];
77
+ }
78
+ export {};
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.CreateWorkflowSchema = void 0;
27
+ const z = __importStar(require("zod"));
28
+ const step_1 = require("./step");
29
+ const CronConfigSchema = z.object({
30
+ cron: z.string(),
31
+ event: z.undefined(),
32
+ });
33
+ const EventConfigSchema = z.object({
34
+ cron: z.undefined(),
35
+ event: z.string(),
36
+ });
37
+ const OnConfigSchema = z.union([CronConfigSchema, EventConfigSchema]);
38
+ const StepsSchema = z.array(step_1.CreateStepSchema);
39
+ exports.CreateWorkflowSchema = z.object({
40
+ id: z.string(),
41
+ description: z.string(),
42
+ on: OnConfigSchema,
43
+ steps: StepsSchema,
44
+ });