@hatchet-dev/typescript-sdk 0.1.1 → 0.1.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.
- package/clients/admin/admin-client.d.ts +12 -0
- package/clients/admin/admin-client.js +47 -0
- package/clients/dispatcher/action-listener.d.ts +26 -0
- package/clients/dispatcher/action-listener.js +113 -0
- package/clients/dispatcher/dispatcher-client.d.ts +20 -0
- package/clients/dispatcher/dispatcher-client.js +58 -0
- package/clients/event/event-client.d.ts +11 -0
- package/clients/event/event-client.js +32 -0
- package/clients/hatchet-client/client-config.d.ts +72 -0
- package/clients/hatchet-client/client-config.js +17 -0
- package/clients/hatchet-client/hatchet-client.d.ts +26 -0
- package/clients/hatchet-client/hatchet-client.js +133 -0
- package/clients/hatchet-client/index.d.ts +2 -0
- package/clients/hatchet-client/index.js +18 -0
- package/clients/worker/index.d.ts +1 -0
- package/clients/worker/index.js +17 -0
- package/clients/worker/worker.d.ts +34 -0
- package/clients/worker/worker.js +317 -0
- package/index.d.ts +2 -0
- package/index.js +4 -0
- package/package.json +2 -2
- package/protoc/dispatcher/dispatcher.d.ts +333 -0
- package/protoc/dispatcher/dispatcher.js +1152 -0
- package/protoc/dispatcher/index.d.ts +1 -0
- package/protoc/dispatcher/index.js +17 -0
- package/protoc/events/events.d.ts +165 -0
- package/protoc/events/events.js +443 -0
- package/protoc/events/index.d.ts +1 -0
- package/protoc/events/index.js +17 -0
- package/protoc/google/protobuf/timestamp.d.ts +121 -0
- package/protoc/google/protobuf/timestamp.js +110 -0
- package/protoc/google/protobuf/wrappers.d.ts +160 -0
- package/protoc/google/protobuf/wrappers.js +527 -0
- package/protoc/workflows/index.d.ts +1 -0
- package/protoc/workflows/index.js +17 -0
- package/protoc/workflows/workflows.d.ts +464 -0
- package/protoc/workflows/workflows.js +1951 -0
- package/sdk.d.ts +2 -0
- package/sdk.js +4 -0
- package/step.d.ts +33 -0
- package/step.js +65 -0
- package/util/config-loader/config-loader.d.ts +13 -0
- package/util/config-loader/config-loader.js +85 -0
- package/util/config-loader/index.d.ts +1 -0
- package/util/config-loader/index.js +17 -0
- package/util/errors/hatchet-error.d.ts +4 -0
- package/util/errors/hatchet-error.js +9 -0
- package/util/hatchet-promise/hatchet-promise.d.ts +6 -0
- package/util/hatchet-promise/hatchet-promise.js +12 -0
- package/util/logger/index.d.ts +1 -0
- package/util/logger/index.js +17 -0
- package/util/logger/logger.d.ts +12 -0
- package/util/logger/logger.js +37 -0
- package/util/sleep.d.ts +2 -0
- package/util/sleep.js +6 -0
- package/workflow.d.ts +111 -0
- package/workflow.js +54 -0
package/sdk.d.ts
ADDED
package/sdk.js
ADDED
package/step.d.ts
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
export declare const CreateStepSchema: z.ZodObject<{
|
|
3
|
+
name: z.ZodString;
|
|
4
|
+
parents: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
5
|
+
timeout: z.ZodOptional<z.ZodString>;
|
|
6
|
+
}, "strip", z.ZodTypeAny, {
|
|
7
|
+
name: string;
|
|
8
|
+
parents?: string[] | undefined;
|
|
9
|
+
timeout?: string | undefined;
|
|
10
|
+
}, {
|
|
11
|
+
name: string;
|
|
12
|
+
parents?: string[] | undefined;
|
|
13
|
+
timeout?: string | undefined;
|
|
14
|
+
}>;
|
|
15
|
+
export type NextStep = {
|
|
16
|
+
[key: string]: string;
|
|
17
|
+
};
|
|
18
|
+
interface ContextData<T = unknown> {
|
|
19
|
+
input: T;
|
|
20
|
+
parents: Record<string, any>;
|
|
21
|
+
triggered_by_event: string;
|
|
22
|
+
}
|
|
23
|
+
export declare class Context<T = unknown> {
|
|
24
|
+
data: ContextData<T>;
|
|
25
|
+
constructor(payload: string);
|
|
26
|
+
stepOutput(step: string): string;
|
|
27
|
+
triggeredByEvent(): boolean;
|
|
28
|
+
workflowInput(): any;
|
|
29
|
+
}
|
|
30
|
+
export interface CreateStep<T> extends z.infer<typeof CreateStepSchema> {
|
|
31
|
+
run: (ctx: Context) => Promise<NextStep> | NextStep | void;
|
|
32
|
+
}
|
|
33
|
+
export {};
|
package/step.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.Context = exports.CreateStepSchema = void 0;
|
|
30
|
+
const hatchet_error_1 = __importDefault(require("../../src/util/errors/hatchet-error"));
|
|
31
|
+
const z = __importStar(require("zod"));
|
|
32
|
+
const workflow_1 = require("./workflow");
|
|
33
|
+
exports.CreateStepSchema = z.object({
|
|
34
|
+
name: z.string(),
|
|
35
|
+
parents: z.array(z.string()).optional(),
|
|
36
|
+
timeout: workflow_1.HatchetTimeoutSchema.optional(),
|
|
37
|
+
});
|
|
38
|
+
class Context {
|
|
39
|
+
constructor(payload) {
|
|
40
|
+
try {
|
|
41
|
+
this.data = JSON.parse(JSON.parse(payload));
|
|
42
|
+
}
|
|
43
|
+
catch (e) {
|
|
44
|
+
throw new hatchet_error_1.default(`Could not parse payload: ${e.message}`);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
stepOutput(step) {
|
|
48
|
+
if (!this.data.parents) {
|
|
49
|
+
throw new hatchet_error_1.default('Step output not found');
|
|
50
|
+
}
|
|
51
|
+
if (!this.data.parents[step]) {
|
|
52
|
+
throw new hatchet_error_1.default(`Step output for '${step}' not found`);
|
|
53
|
+
}
|
|
54
|
+
return this.data.parents[step];
|
|
55
|
+
}
|
|
56
|
+
triggeredByEvent() {
|
|
57
|
+
var _a;
|
|
58
|
+
return ((_a = this.data) === null || _a === void 0 ? void 0 : _a.triggered_by_event) === 'event';
|
|
59
|
+
}
|
|
60
|
+
workflowInput() {
|
|
61
|
+
var _a;
|
|
62
|
+
return ((_a = this.data) === null || _a === void 0 ? void 0 : _a.input) || {};
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.Context = Context;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ClientConfig } from '../../../../src/clients/hatchet-client';
|
|
2
|
+
import { ChannelCredentials } from 'nice-grpc';
|
|
3
|
+
interface LoadClientConfigOptions {
|
|
4
|
+
path?: string;
|
|
5
|
+
}
|
|
6
|
+
export declare class ConfigLoader {
|
|
7
|
+
static load_client_config(config?: LoadClientConfigOptions): Partial<ClientConfig>;
|
|
8
|
+
static get default_yaml_config_path(): string;
|
|
9
|
+
static createCredentials(config: ClientConfig['tls_config']): ChannelCredentials;
|
|
10
|
+
static load_yaml_config(path?: string): ClientConfig | undefined;
|
|
11
|
+
private static env;
|
|
12
|
+
}
|
|
13
|
+
export {};
|
|
@@ -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("../../../../src/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 @@
|
|
|
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,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 @@
|
|
|
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;
|
package/util/sleep.d.ts
ADDED
package/util/sleep.js
ADDED
package/workflow.d.ts
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import * as z from 'zod';
|
|
2
|
+
import { CreateStep } from './step';
|
|
3
|
+
import { ConcurrencyLimitStrategy as PbConcurrencyLimitStrategy } from './protoc/workflows';
|
|
4
|
+
declare const StepsSchema: z.ZodArray<z.ZodObject<{
|
|
5
|
+
name: z.ZodString;
|
|
6
|
+
parents: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
7
|
+
timeout: z.ZodOptional<z.ZodString>;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
name: string;
|
|
10
|
+
parents?: string[] | undefined;
|
|
11
|
+
timeout?: string | undefined;
|
|
12
|
+
}, {
|
|
13
|
+
name: string;
|
|
14
|
+
parents?: string[] | undefined;
|
|
15
|
+
timeout?: string | undefined;
|
|
16
|
+
}>, "many">;
|
|
17
|
+
export type Steps = z.infer<typeof StepsSchema>;
|
|
18
|
+
export declare const ConcurrencyLimitStrategy: typeof PbConcurrencyLimitStrategy;
|
|
19
|
+
export declare const WorkflowConcurrency: z.ZodObject<{
|
|
20
|
+
action: z.ZodOptional<z.ZodString>;
|
|
21
|
+
maxRuns: z.ZodOptional<z.ZodNumber>;
|
|
22
|
+
limitStrategy: z.ZodOptional<z.ZodNativeEnum<typeof PbConcurrencyLimitStrategy>>;
|
|
23
|
+
}, "strip", z.ZodTypeAny, {
|
|
24
|
+
action?: string | undefined;
|
|
25
|
+
maxRuns?: number | undefined;
|
|
26
|
+
limitStrategy?: PbConcurrencyLimitStrategy | undefined;
|
|
27
|
+
}, {
|
|
28
|
+
action?: string | undefined;
|
|
29
|
+
maxRuns?: number | undefined;
|
|
30
|
+
limitStrategy?: PbConcurrencyLimitStrategy | undefined;
|
|
31
|
+
}>;
|
|
32
|
+
export declare const HatchetTimeoutSchema: z.ZodString;
|
|
33
|
+
export declare const CreateWorkflowSchema: z.ZodObject<{
|
|
34
|
+
id: z.ZodString;
|
|
35
|
+
description: z.ZodString;
|
|
36
|
+
version: z.ZodOptional<z.ZodString>;
|
|
37
|
+
timeout: z.ZodOptional<z.ZodString>;
|
|
38
|
+
on: z.ZodUnion<[z.ZodObject<{
|
|
39
|
+
cron: z.ZodString;
|
|
40
|
+
event: z.ZodUndefined;
|
|
41
|
+
}, "strip", z.ZodTypeAny, {
|
|
42
|
+
cron: string;
|
|
43
|
+
event?: undefined;
|
|
44
|
+
}, {
|
|
45
|
+
cron: string;
|
|
46
|
+
event?: undefined;
|
|
47
|
+
}>, z.ZodObject<{
|
|
48
|
+
cron: z.ZodUndefined;
|
|
49
|
+
event: z.ZodString;
|
|
50
|
+
}, "strip", z.ZodTypeAny, {
|
|
51
|
+
event: string;
|
|
52
|
+
cron?: undefined;
|
|
53
|
+
}, {
|
|
54
|
+
event: string;
|
|
55
|
+
cron?: undefined;
|
|
56
|
+
}>]>;
|
|
57
|
+
steps: z.ZodArray<z.ZodObject<{
|
|
58
|
+
name: z.ZodString;
|
|
59
|
+
parents: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
60
|
+
timeout: z.ZodOptional<z.ZodString>;
|
|
61
|
+
}, "strip", z.ZodTypeAny, {
|
|
62
|
+
name: string;
|
|
63
|
+
parents?: string[] | undefined;
|
|
64
|
+
timeout?: string | undefined;
|
|
65
|
+
}, {
|
|
66
|
+
name: string;
|
|
67
|
+
parents?: string[] | undefined;
|
|
68
|
+
timeout?: string | undefined;
|
|
69
|
+
}>, "many">;
|
|
70
|
+
}, "strip", z.ZodTypeAny, {
|
|
71
|
+
description: string;
|
|
72
|
+
steps: {
|
|
73
|
+
name: string;
|
|
74
|
+
parents?: string[] | undefined;
|
|
75
|
+
timeout?: string | undefined;
|
|
76
|
+
}[];
|
|
77
|
+
id: string;
|
|
78
|
+
on: {
|
|
79
|
+
cron: string;
|
|
80
|
+
event?: undefined;
|
|
81
|
+
} | {
|
|
82
|
+
event: string;
|
|
83
|
+
cron?: undefined;
|
|
84
|
+
};
|
|
85
|
+
version?: string | undefined;
|
|
86
|
+
timeout?: string | undefined;
|
|
87
|
+
}, {
|
|
88
|
+
description: string;
|
|
89
|
+
steps: {
|
|
90
|
+
name: string;
|
|
91
|
+
parents?: string[] | undefined;
|
|
92
|
+
timeout?: string | undefined;
|
|
93
|
+
}[];
|
|
94
|
+
id: string;
|
|
95
|
+
on: {
|
|
96
|
+
cron: string;
|
|
97
|
+
event?: undefined;
|
|
98
|
+
} | {
|
|
99
|
+
event: string;
|
|
100
|
+
cron?: undefined;
|
|
101
|
+
};
|
|
102
|
+
version?: string | undefined;
|
|
103
|
+
timeout?: string | undefined;
|
|
104
|
+
}>;
|
|
105
|
+
export interface Workflow extends z.infer<typeof CreateWorkflowSchema> {
|
|
106
|
+
concurrency?: z.infer<typeof WorkflowConcurrency> & {
|
|
107
|
+
key: (ctx: any) => string;
|
|
108
|
+
};
|
|
109
|
+
steps: CreateStep<any>[];
|
|
110
|
+
}
|
|
111
|
+
export {};
|
package/workflow.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
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 = exports.HatchetTimeoutSchema = exports.WorkflowConcurrency = exports.ConcurrencyLimitStrategy = void 0;
|
|
27
|
+
const z = __importStar(require("zod"));
|
|
28
|
+
const step_1 = require("./step");
|
|
29
|
+
const workflows_1 = require("./protoc/workflows");
|
|
30
|
+
const CronConfigSchema = z.object({
|
|
31
|
+
cron: z.string(),
|
|
32
|
+
event: z.undefined(),
|
|
33
|
+
});
|
|
34
|
+
const EventConfigSchema = z.object({
|
|
35
|
+
cron: z.undefined(),
|
|
36
|
+
event: z.string(),
|
|
37
|
+
});
|
|
38
|
+
const OnConfigSchema = z.union([CronConfigSchema, EventConfigSchema]);
|
|
39
|
+
const StepsSchema = z.array(step_1.CreateStepSchema);
|
|
40
|
+
exports.ConcurrencyLimitStrategy = workflows_1.ConcurrencyLimitStrategy;
|
|
41
|
+
exports.WorkflowConcurrency = z.object({
|
|
42
|
+
action: z.string().optional(),
|
|
43
|
+
maxRuns: z.number().optional(),
|
|
44
|
+
limitStrategy: z.nativeEnum(exports.ConcurrencyLimitStrategy).optional(),
|
|
45
|
+
});
|
|
46
|
+
exports.HatchetTimeoutSchema = z.string();
|
|
47
|
+
exports.CreateWorkflowSchema = z.object({
|
|
48
|
+
id: z.string(),
|
|
49
|
+
description: z.string(),
|
|
50
|
+
version: z.string().optional(),
|
|
51
|
+
timeout: exports.HatchetTimeoutSchema.optional(),
|
|
52
|
+
on: OnConfigSchema,
|
|
53
|
+
steps: StepsSchema,
|
|
54
|
+
});
|