@hatchet-dev/typescript-sdk 0.0.1 → 0.0.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.
Files changed (108) hide show
  1. package/dist/{hatchet/clients → clients}/admin/admin-client.d.ts +2 -2
  2. package/dist/{hatchet/clients → clients}/admin/admin-client.js +2 -2
  3. package/dist/{hatchet/clients → clients}/dispatcher/action-listener.d.ts +3 -3
  4. package/dist/{hatchet/clients → clients}/dispatcher/action-listener.js +2 -2
  5. package/dist/{hatchet/clients → clients}/dispatcher/action-listener.test.d.ts +1 -1
  6. package/dist/{hatchet/clients → clients}/dispatcher/action-listener.test.js +2 -2
  7. package/dist/{hatchet/clients → clients}/dispatcher/dispatcher-client.d.ts +3 -3
  8. package/dist/{hatchet/clients → clients}/dispatcher/dispatcher-client.js +2 -2
  9. package/dist/{hatchet/clients → clients}/dispatcher/dispatcher-client.test.js +1 -1
  10. package/dist/{hatchet/clients → clients}/event/event-client.d.ts +3 -3
  11. package/dist/{hatchet/clients → clients}/event/event-client.js +2 -2
  12. package/dist/{hatchet/clients → clients}/event/event-client.test.js +1 -1
  13. package/dist/{hatchet/clients → clients}/hatchet-client/hatchet-client.d.ts +4 -4
  14. package/dist/{hatchet/clients → clients}/hatchet-client/hatchet-client.js +5 -5
  15. package/dist/{hatchet/clients → clients}/worker/worker.d.ts +4 -4
  16. package/dist/{hatchet/clients → clients}/worker/worker.js +3 -3
  17. package/dist/{hatchet/clients → clients}/worker/worker.test.js +5 -5
  18. package/dist/index.d.ts +2 -0
  19. package/dist/{hatchet/index.js → index.js} +1 -1
  20. package/dist/protoc/events/index.js +17 -0
  21. package/dist/sdk.d.ts +2 -0
  22. package/dist/{hatchet/sdk.js → sdk.js} +1 -1
  23. package/dist/{hatchet/step.js → step.js} +1 -1
  24. package/dist/{hatchet/util → util}/config-loader/config-loader.d.ts +1 -1
  25. package/dist/{hatchet/util → util}/config-loader/config-loader.js +1 -1
  26. package/package.json +6 -5
  27. package/.eslintrc.json +0 -36
  28. package/.prettierrc.json +0 -6
  29. package/dist/hatchet/index.d.ts +0 -2
  30. package/dist/hatchet/sdk.d.ts +0 -2
  31. package/examples/dag-worker.ts +0 -55
  32. package/examples/example-event.ts +0 -7
  33. package/examples/simple-worker.ts +0 -39
  34. package/generate-protoc.sh +0 -10
  35. package/hatchet/clients/admin/admin-client.test.ts +0 -116
  36. package/hatchet/clients/admin/admin-client.ts +0 -43
  37. package/hatchet/clients/dispatcher/action-listener.test.ts +0 -270
  38. package/hatchet/clients/dispatcher/action-listener.ts +0 -91
  39. package/hatchet/clients/dispatcher/dispatcher-client.test.ts +0 -111
  40. package/hatchet/clients/dispatcher/dispatcher-client.ts +0 -47
  41. package/hatchet/clients/event/event-client.test.ts +0 -72
  42. package/hatchet/clients/event/event-client.ts +0 -32
  43. package/hatchet/clients/hatchet-client/client-config.ts +0 -22
  44. package/hatchet/clients/hatchet-client/fixtures/.hatchet-invalid.yaml +0 -6
  45. package/hatchet/clients/hatchet-client/fixtures/.hatchet.yaml +0 -8
  46. package/hatchet/clients/hatchet-client/hatchet-client.test.ts +0 -162
  47. package/hatchet/clients/hatchet-client/hatchet-client.ts +0 -136
  48. package/hatchet/clients/hatchet-client/index.ts +0 -2
  49. package/hatchet/clients/worker/index.ts +0 -1
  50. package/hatchet/clients/worker/worker.test.ts +0 -347
  51. package/hatchet/clients/worker/worker.ts +0 -229
  52. package/hatchet/index.ts +0 -3
  53. package/hatchet/sdk.ts +0 -3
  54. package/hatchet/step.ts +0 -48
  55. package/hatchet/util/config-loader/config-loader.test.ts +0 -79
  56. package/hatchet/util/config-loader/config-loader.ts +0 -91
  57. package/hatchet/util/config-loader/fixtures/.hatchet-invalid.yaml +0 -6
  58. package/hatchet/util/config-loader/fixtures/.hatchet.yaml +0 -8
  59. package/hatchet/util/config-loader/index.ts +0 -1
  60. package/hatchet/util/errors/hatchet-error.ts +0 -8
  61. package/hatchet/util/hatchet-promise/hatchet-promise.test.ts +0 -32
  62. package/hatchet/util/hatchet-promise/hatchet-promise.ts +0 -13
  63. package/hatchet/util/logger/index.ts +0 -1
  64. package/hatchet/util/logger/logger.ts +0 -44
  65. package/hatchet/util/sleep.ts +0 -6
  66. package/hatchet/workflow.ts +0 -30
  67. package/jest.config.ts +0 -205
  68. package/protoc/dispatcher/dispatcher.ts +0 -1101
  69. package/protoc/dispatcher/index.ts +0 -1
  70. package/protoc/events/events.ts +0 -519
  71. package/protoc/google/protobuf/timestamp.ts +0 -210
  72. package/protoc/google/protobuf/wrappers.ts +0 -657
  73. package/protoc/workflows/index.ts +0 -1
  74. package/protoc/workflows/workflows.ts +0 -2158
  75. package/tsconfig.json +0 -120
  76. /package/dist/{hatchet/clients → clients}/admin/admin-client.test.d.ts +0 -0
  77. /package/dist/{hatchet/clients → clients}/admin/admin-client.test.js +0 -0
  78. /package/dist/{hatchet/clients → clients}/dispatcher/dispatcher-client.test.d.ts +0 -0
  79. /package/dist/{hatchet/clients → clients}/event/event-client.test.d.ts +0 -0
  80. /package/dist/{hatchet/clients → clients}/hatchet-client/client-config.d.ts +0 -0
  81. /package/dist/{hatchet/clients → clients}/hatchet-client/client-config.js +0 -0
  82. /package/dist/{hatchet/clients → clients}/hatchet-client/hatchet-client.test.d.ts +0 -0
  83. /package/dist/{hatchet/clients → clients}/hatchet-client/hatchet-client.test.js +0 -0
  84. /package/dist/{hatchet/clients → clients}/hatchet-client/index.d.ts +0 -0
  85. /package/dist/{hatchet/clients → clients}/hatchet-client/index.js +0 -0
  86. /package/dist/{hatchet/clients → clients}/worker/index.d.ts +0 -0
  87. /package/dist/{hatchet/clients → clients}/worker/index.js +0 -0
  88. /package/dist/{hatchet/clients → clients}/worker/worker.test.d.ts +0 -0
  89. /package/{protoc/events/index.ts → dist/protoc/events/index.d.ts} +0 -0
  90. /package/dist/{hatchet/step.d.ts → step.d.ts} +0 -0
  91. /package/dist/{hatchet/util → util}/config-loader/config-loader.test.d.ts +0 -0
  92. /package/dist/{hatchet/util → util}/config-loader/config-loader.test.js +0 -0
  93. /package/dist/{hatchet/util → util}/config-loader/index.d.ts +0 -0
  94. /package/dist/{hatchet/util → util}/config-loader/index.js +0 -0
  95. /package/dist/{hatchet/util → util}/errors/hatchet-error.d.ts +0 -0
  96. /package/dist/{hatchet/util → util}/errors/hatchet-error.js +0 -0
  97. /package/dist/{hatchet/util → util}/hatchet-promise/hatchet-promise.d.ts +0 -0
  98. /package/dist/{hatchet/util → util}/hatchet-promise/hatchet-promise.js +0 -0
  99. /package/dist/{hatchet/util → util}/hatchet-promise/hatchet-promise.test.d.ts +0 -0
  100. /package/dist/{hatchet/util → util}/hatchet-promise/hatchet-promise.test.js +0 -0
  101. /package/dist/{hatchet/util → util}/logger/index.d.ts +0 -0
  102. /package/dist/{hatchet/util → util}/logger/index.js +0 -0
  103. /package/dist/{hatchet/util → util}/logger/logger.d.ts +0 -0
  104. /package/dist/{hatchet/util → util}/logger/logger.js +0 -0
  105. /package/dist/{hatchet/util → util}/sleep.d.ts +0 -0
  106. /package/dist/{hatchet/util → util}/sleep.js +0 -0
  107. /package/dist/{hatchet/workflow.d.ts → workflow.d.ts} +0 -0
  108. /package/dist/{hatchet/workflow.js → workflow.js} +0 -0
@@ -1,6 +1,6 @@
1
1
  import { Channel, ClientFactory } from 'nice-grpc';
2
- import { CreateWorkflowVersionOpts, WorkflowServiceClient } from '@protoc/workflows';
3
- import { ClientConfig } from '@clients/hatchet-client/client-config';
2
+ import { CreateWorkflowVersionOpts, WorkflowServiceClient } from '@hatchet/protoc/workflows';
3
+ import { ClientConfig } from '../hatchet-client/client-config';
4
4
  export declare class AdminClient {
5
5
  config: ClientConfig;
6
6
  client: WorkflowServiceClient;
@@ -13,8 +13,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.AdminClient = void 0;
16
- const workflows_1 = require("@protoc/workflows");
17
- const hatchet_error_1 = __importDefault(require("@util/errors/hatchet-error"));
16
+ const workflows_1 = require("@hatchet/protoc/workflows");
17
+ const hatchet_error_1 = __importDefault(require("../../util/errors/hatchet-error"));
18
18
  class AdminClient {
19
19
  constructor(config, channel, factory) {
20
20
  this.config = config;
@@ -1,5 +1,5 @@
1
- import { DispatcherClient as PbDispatcherClient, AssignedAction } from '@protoc/dispatcher';
2
- import { ClientConfig } from '@clients/hatchet-client/client-config';
1
+ import { DispatcherClient as PbDispatcherClient, AssignedAction } from '@hatchet/protoc/dispatcher';
2
+ import { ClientConfig } from '../hatchet-client/client-config';
3
3
  import { DispatcherClient } from './dispatcher-client';
4
4
  export interface Action {
5
5
  tenantId: string;
@@ -20,5 +20,5 @@ export declare class ActionListener {
20
20
  constructor(client: DispatcherClient, listener: AsyncIterable<AssignedAction>, workerId: string);
21
21
  actions: () => AsyncGenerator<Action, void, unknown>;
22
22
  retrySubscribe(): Promise<void>;
23
- unregister(): Promise<import("@protoc/dispatcher").WorkerUnsubscribeResponse>;
23
+ unregister(): Promise<import("@hatchet/protoc/dispatcher").WorkerUnsubscribeResponse>;
24
24
  }
@@ -34,8 +34,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
34
34
  Object.defineProperty(exports, "__esModule", { value: true });
35
35
  exports.ActionListener = void 0;
36
36
  const nice_grpc_1 = require("nice-grpc");
37
- const sleep_1 = __importDefault(require("@util/sleep"));
38
- const hatchet_error_1 = __importDefault(require("@util/errors/hatchet-error"));
37
+ const sleep_1 = __importDefault(require("../../util/sleep"));
38
+ const hatchet_error_1 = __importDefault(require("../../util/errors/hatchet-error"));
39
39
  const DEFAULT_ACTION_LISTENER_RETRY_INTERVAL = 5; // seconds
40
40
  const DEFAULT_ACTION_LISTENER_RETRY_COUNT = 5;
41
41
  class ActionListener {
@@ -1,4 +1,4 @@
1
- import { AssignedAction } from '@protoc/dispatcher';
1
+ import { AssignedAction } from '@hatchet/protoc/dispatcher';
2
2
  type AssignActionMock = AssignedAction | Error;
3
3
  export declare const mockListener: (fixture: AssignActionMock[]) => AsyncGenerator<AssignedAction, void, unknown>;
4
4
  export {};
@@ -33,8 +33,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
33
33
  };
34
34
  Object.defineProperty(exports, "__esModule", { value: true });
35
35
  exports.mockListener = void 0;
36
- const dispatcher_1 = require("@protoc/dispatcher");
37
- const sleep_1 = __importDefault(require("@util/sleep"));
36
+ const dispatcher_1 = require("@hatchet/protoc/dispatcher");
37
+ const sleep_1 = __importDefault(require("../../util/sleep"));
38
38
  const nice_grpc_common_1 = require("nice-grpc-common");
39
39
  const dispatcher_client_1 = require("./dispatcher-client");
40
40
  const action_listener_1 = require("./action-listener");
@@ -1,6 +1,6 @@
1
1
  import { Channel, ClientFactory } from 'nice-grpc';
2
- import { DispatcherClient as PbDispatcherClient, ActionEvent } from '@protoc/dispatcher';
3
- import { ClientConfig } from '@clients/hatchet-client/client-config';
2
+ import { DispatcherClient as PbDispatcherClient, ActionEvent } from '@hatchet/protoc/dispatcher';
3
+ import { ClientConfig } from '../hatchet-client/client-config';
4
4
  import { ActionListener } from './action-listener';
5
5
  interface GetActionListenerOptions {
6
6
  workerName: string;
@@ -12,6 +12,6 @@ export declare class DispatcherClient {
12
12
  client: PbDispatcherClient;
13
13
  constructor(config: ClientConfig, channel: Channel, factory: ClientFactory);
14
14
  get_action_listener(options: GetActionListenerOptions): Promise<ActionListener>;
15
- send_action_event(in_: ActionEvent): Promise<import("@protoc/dispatcher").ActionEventResponse>;
15
+ send_action_event(in_: ActionEvent): Promise<import("@hatchet/protoc/dispatcher").ActionEventResponse>;
16
16
  }
17
17
  export {};
@@ -13,8 +13,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.DispatcherClient = void 0;
16
- const dispatcher_1 = require("@protoc/dispatcher");
17
- const hatchet_error_1 = __importDefault(require("@util/errors/hatchet-error"));
16
+ const dispatcher_1 = require("@hatchet/protoc/dispatcher");
17
+ const hatchet_error_1 = __importDefault(require("../../util/errors/hatchet-error"));
18
18
  const action_listener_1 = require("./action-listener");
19
19
  class DispatcherClient {
20
20
  constructor(config, channel, factory) {
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
9
  });
10
10
  };
11
11
  Object.defineProperty(exports, "__esModule", { value: true });
12
- const dispatcher_1 = require("@protoc/dispatcher");
12
+ const dispatcher_1 = require("@hatchet/protoc/dispatcher");
13
13
  const dispatcher_client_1 = require("./dispatcher-client");
14
14
  const hatchet_client_test_1 = require("../hatchet-client/hatchet-client.test");
15
15
  let client;
@@ -1,9 +1,9 @@
1
1
  import { Channel, ClientFactory } from 'nice-grpc';
2
- import { EventsServiceClient } from '@protoc/events/events';
3
- import { ClientConfig } from '@clients/hatchet-client/client-config';
2
+ import { EventsServiceClient } from '@hatchet/protoc/events/events';
3
+ import { ClientConfig } from '../hatchet-client/client-config';
4
4
  export declare class EventClient {
5
5
  config: ClientConfig;
6
6
  client: EventsServiceClient;
7
7
  constructor(config: ClientConfig, channel: Channel, factory: ClientFactory);
8
- push<T>(type: string, input: T): Promise<import("@protoc/events/events").Event>;
8
+ push<T>(type: string, input: T): Promise<import("@hatchet/protoc/events/events").Event>;
9
9
  }
@@ -4,8 +4,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.EventClient = void 0;
7
- const events_1 = require("@protoc/events/events");
8
- const hatchet_error_1 = __importDefault(require("@util/errors/hatchet-error"));
7
+ const events_1 = require("@hatchet/protoc/events/events");
8
+ const hatchet_error_1 = __importDefault(require("../../util/errors/hatchet-error"));
9
9
  class EventClient {
10
10
  constructor(config, channel, factory) {
11
11
  this.config = config;
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- const hatchet_error_1 = __importDefault(require("@util/errors/hatchet-error"));
6
+ const hatchet_error_1 = __importDefault(require("../../util/errors/hatchet-error"));
7
7
  const event_client_1 = require("./event-client");
8
8
  const hatchet_client_test_1 = require("../hatchet-client/hatchet-client.test");
9
9
  let client;
@@ -1,9 +1,9 @@
1
- import { EventClient } from '@clients/event/event-client';
2
- import { DispatcherClient } from '@clients/dispatcher/dispatcher-client';
3
- import { AdminClient } from '@clients/admin/admin-client';
1
+ import { EventClient } from '../event/event-client';
2
+ import { DispatcherClient } from '../dispatcher/dispatcher-client';
3
+ import { AdminClient } from '../admin/admin-client';
4
4
  import { Channel, ChannelCredentials } from 'nice-grpc';
5
5
  import { Workflow } from '@hatchet/workflow';
6
- import { Worker } from '@clients/worker';
6
+ import { Worker } from '../worker';
7
7
  import Logger from '@hatchet/util/logger/logger';
8
8
  import { ClientConfig } from './client-config';
9
9
  export interface HatchetClientOptions {
@@ -39,12 +39,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
39
39
  Object.defineProperty(exports, "__esModule", { value: true });
40
40
  exports.HatchetClient = void 0;
41
41
  const zod_1 = require("zod");
42
- const config_loader_1 = require("@util/config-loader");
43
- const event_client_1 = require("@clients/event/event-client");
44
- const dispatcher_client_1 = require("@clients/dispatcher/dispatcher-client");
45
- const admin_client_1 = require("@clients/admin/admin-client");
42
+ const config_loader_1 = require("../../util/config-loader");
43
+ const event_client_1 = require("../event/event-client");
44
+ const dispatcher_client_1 = require("../dispatcher/dispatcher-client");
45
+ const admin_client_1 = require("../admin/admin-client");
46
46
  const nice_grpc_1 = require("nice-grpc");
47
- const worker_1 = require("@clients/worker");
47
+ const worker_1 = require("../worker");
48
48
  const logger_1 = __importDefault(require("@hatchet/util/logger/logger"));
49
49
  const client_config_1 = require("./client-config");
50
50
  const addTokenMiddleware = (token) => function _(call, options) {
@@ -1,7 +1,7 @@
1
- import { HatchetClient } from '@clients/hatchet-client';
2
- import { Action, ActionListener } from '@clients/dispatcher/action-listener';
3
- import { ActionEvent, ActionEventType } from '@protoc/dispatcher';
4
- import HatchetPromise from '@util/hatchet-promise/hatchet-promise';
1
+ import { HatchetClient } from '../hatchet-client';
2
+ import { Action, ActionListener } from '../dispatcher/action-listener';
3
+ import { ActionEvent, ActionEventType } from '@hatchet/protoc/dispatcher';
4
+ import HatchetPromise from '../../util/hatchet-promise/hatchet-promise';
5
5
  import { Workflow } from '@hatchet/workflow';
6
6
  import { Logger } from '@hatchet/util/logger';
7
7
  export type ActionRegistry = Record<Action['actionId'], Function>;
@@ -20,9 +20,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
20
20
  };
21
21
  Object.defineProperty(exports, "__esModule", { value: true });
22
22
  exports.Worker = void 0;
23
- const hatchet_error_1 = __importDefault(require("@util/errors/hatchet-error"));
24
- const dispatcher_1 = require("@protoc/dispatcher");
25
- const hatchet_promise_1 = __importDefault(require("@util/hatchet-promise/hatchet-promise"));
23
+ const hatchet_error_1 = __importDefault(require("../../util/errors/hatchet-error"));
24
+ const dispatcher_1 = require("@hatchet/protoc/dispatcher");
25
+ const hatchet_promise_1 = __importDefault(require("../../util/hatchet-promise/hatchet-promise"));
26
26
  const logger_1 = require("@hatchet/util/logger");
27
27
  const sleep_1 = __importDefault(require("@hatchet/util/sleep"));
28
28
  const step_1 = require("../../step");
@@ -12,13 +12,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
13
  };
14
14
  Object.defineProperty(exports, "__esModule", { value: true });
15
- const hatchet_client_1 = require("@clients/hatchet-client");
16
- const dispatcher_1 = require("@protoc/dispatcher");
17
- const action_listener_1 = require("@clients/dispatcher/action-listener");
15
+ const hatchet_client_1 = require("../hatchet-client");
16
+ const dispatcher_1 = require("@hatchet/protoc/dispatcher");
17
+ const action_listener_1 = require("../dispatcher/action-listener");
18
18
  const nice_grpc_common_1 = require("nice-grpc-common");
19
- const action_listener_test_1 = require("@clients/dispatcher/action-listener.test");
19
+ const action_listener_test_1 = require("../dispatcher/action-listener.test");
20
20
  const zod_1 = require("zod");
21
- const sleep_1 = __importDefault(require("@util/sleep"));
21
+ const sleep_1 = __importDefault(require("../../util/sleep"));
22
22
  const nice_grpc_1 = require("nice-grpc");
23
23
  const worker_1 = require("./worker");
24
24
  const mockStart = {
@@ -0,0 +1,2 @@
1
+ import { HatchetClient as Hatchet } from './clients/hatchet-client';
2
+ export default Hatchet;
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const hatchet_client_1 = require("@clients/hatchet-client");
3
+ const hatchet_client_1 = require("./clients/hatchet-client");
4
4
  exports.default = hatchet_client_1.HatchetClient;
@@ -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("./events"), exports);
package/dist/sdk.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import { HatchetClient as Hatchet } from './clients/hatchet-client';
2
+ export default Hatchet;
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const hatchet_client_1 = require("@clients/hatchet-client");
3
+ const hatchet_client_1 = require("./clients/hatchet-client");
4
4
  exports.default = hatchet_client_1.HatchetClient;
@@ -27,7 +27,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
27
27
  };
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.Context = exports.CreateStepSchema = void 0;
30
- const hatchet_error_1 = __importDefault(require("@util/errors/hatchet-error"));
30
+ const hatchet_error_1 = __importDefault(require("./util/errors/hatchet-error"));
31
31
  const z = __importStar(require("zod"));
32
32
  exports.CreateStepSchema = z.object({
33
33
  name: z.string(),
@@ -1,4 +1,4 @@
1
- import { ClientConfig } from '@clients/hatchet-client';
1
+ import { ClientConfig } from '../../clients/hatchet-client';
2
2
  import { ChannelCredentials } from 'nice-grpc';
3
3
  interface LoadClientConfigOptions {
4
4
  path?: string;
@@ -28,7 +28,7 @@ const yaml_1 = require("yaml");
28
28
  const fs_1 = require("fs");
29
29
  const p = __importStar(require("path"));
30
30
  const zod_1 = require("zod");
31
- const hatchet_client_1 = require("@clients/hatchet-client");
31
+ const hatchet_client_1 = require("../../clients/hatchet-client");
32
32
  const nice_grpc_1 = require("nice-grpc");
33
33
  const DEFAULT_CONFIG_FILE = '.hatchet.yaml';
34
34
  class ConfigLoader {
package/package.json CHANGED
@@ -1,16 +1,16 @@
1
1
  {
2
2
  "name": "@hatchet-dev/typescript-sdk",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "Background task orchestration & visibility for developers",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist"
9
+ ],
7
10
  "repository": {
8
11
  "type": "git",
9
12
  "url": "https://github.com/hatchet-dev/hatchet.git"
10
13
  },
11
- "publishConfig": {
12
- "@hatchet:registry": "https://npm.pkg.github.com"
13
- },
14
14
  "keywords": [],
15
15
  "author": "",
16
16
  "license": "MIT",
@@ -33,6 +33,7 @@
33
33
  "grpc-tools": "^1.12.4",
34
34
  "jest": "^29.7.0",
35
35
  "prettier": "^3.1.1",
36
+ "resolve-tspaths": "^0.8.17",
36
37
  "ts-jest": "^29.1.1",
37
38
  "ts-node": "^10.9.2",
38
39
  "ts-proto": "^1.167.0",
@@ -47,7 +48,7 @@
47
48
  "zod": "^3.22.4"
48
49
  },
49
50
  "scripts": {
50
- "build": "tsc",
51
+ "build": "tsc && resolve-tspaths",
51
52
  "test": "jest",
52
53
  "test:watch": "jest --watch",
53
54
  "generate": "./generate-protoc.sh",
package/.eslintrc.json DELETED
@@ -1,36 +0,0 @@
1
- {
2
- "env": {
3
- "es6": true,
4
- "node": true,
5
- "jest": true
6
- },
7
- "extends": ["airbnb-base", "prettier", "plugin:prettier/recommended"],
8
- "globals": {
9
- "Atomics": "readonly",
10
- "SharedArrayBuffer": "readonly"
11
- },
12
- "parser": "@typescript-eslint/parser",
13
- "parserOptions": {
14
- "ecmaVersion": 11,
15
- "sourceType": "module"
16
- },
17
- "plugins": ["@typescript-eslint", "import", "unused-imports", "prettier", "eslint-plugin-jest"],
18
- "rules": {
19
- "@typescript-eslint/no-shadow": "off",
20
- "@typescript-eslint/no-throw-literal": "off",
21
- "no-use-before-define": "off",
22
- "@typescript-eslint/no-use-before-define": "off",
23
- "import/extensions": "off",
24
- "unused-imports/no-unused-imports": "error",
25
- "no-unused-vars": "off",
26
- "prettier/prettier": "error",
27
- "@typescript-eslint/no-unused-vars": "warn",
28
- "curly": "error",
29
- "import/prefer-default-export": "off",
30
- "import/no-unresolved": "off",
31
- "lines-between-class-members": "off",
32
- "class-methods-use-this": "off",
33
- "no-await-in-loop": "off",
34
- "no-restricted-syntax": "off"
35
- }
36
- }
package/.prettierrc.json DELETED
@@ -1,6 +0,0 @@
1
- {
2
- "printWidth": 100,
3
- "tabWidth": 2,
4
- "singleQuote": true,
5
- "trailingComma": "es5"
6
- }
@@ -1,2 +0,0 @@
1
- import { HatchetClient as Hatchet } from '@clients/hatchet-client';
2
- export default Hatchet;
@@ -1,2 +0,0 @@
1
- import { HatchetClient as Hatchet } from '@clients/hatchet-client';
2
- export default Hatchet;
@@ -1,55 +0,0 @@
1
- import Hatchet from '@hatchet/sdk';
2
- import { Workflow } from '@hatchet/workflow';
3
-
4
- const hatchet = Hatchet.init({
5
- log_level: 'OFF',
6
- });
7
-
8
- const sleep = (ms: number) =>
9
- new Promise((resolve) => {
10
- setTimeout(resolve, ms);
11
- });
12
-
13
- const workflow: Workflow = {
14
- id: 'dag-example',
15
- description: 'test',
16
- on: {
17
- event: 'user:create',
18
- },
19
- steps: [
20
- {
21
- name: 'dag-step1',
22
- run: async (ctx) => {
23
- console.log('executed step1!');
24
- await sleep(5000);
25
- return { step1: 'step1' };
26
- },
27
- },
28
- {
29
- name: 'dag-step2',
30
- parents: ['dag-step1'],
31
- run: (ctx) => {
32
- console.log('executed step2!');
33
- return { step2: 'step2' };
34
- },
35
- },
36
- {
37
- name: 'dag-step3',
38
- parents: ['dag-step1', 'dag-step2'],
39
- run: (ctx) => {
40
- console.log('executed step3!');
41
- return { step3: 'step3' };
42
- },
43
- },
44
- {
45
- name: 'dag-step4',
46
- parents: ['dag-step1', 'dag-step3'],
47
- run: (ctx) => {
48
- console.log('executed step4!');
49
- return { step4: 'step4' };
50
- },
51
- },
52
- ],
53
- };
54
-
55
- hatchet.run(workflow);
@@ -1,7 +0,0 @@
1
- import Hatchet from '@hatchet/sdk';
2
-
3
- const hatchet = Hatchet.init();
4
-
5
- hatchet.event.push('user:create', {
6
- test: 'test',
7
- });
@@ -1,39 +0,0 @@
1
- import Hatchet from '@hatchet/sdk';
2
- import { Workflow } from '@hatchet/workflow';
3
-
4
- const hatchet = Hatchet.init();
5
-
6
- const sleep = (ms: number) =>
7
- new Promise((resolve) => {
8
- setTimeout(resolve, ms);
9
- });
10
-
11
- const workflow: Workflow = {
12
- id: 'example',
13
- description: 'test',
14
- on: {
15
- event: 'user:create',
16
- },
17
- steps: [
18
- {
19
- name: 'step1',
20
- run: async (ctx) => {
21
- console.log('starting step1 with the following input', ctx.workflowInput());
22
- console.log('waiting 5 seconds...');
23
- await sleep(5000);
24
- console.log('executed step1!');
25
- return { step1: 'step1 results!' };
26
- },
27
- },
28
- {
29
- name: 'step2',
30
- parents: ['step1'],
31
- run: (ctx) => {
32
- console.log('executed step2 after step1 returned ', ctx.stepOutput('step1'));
33
- return { step2: 'step2 results!' };
34
- },
35
- },
36
- ],
37
- };
38
-
39
- hatchet.run(workflow);
@@ -1,10 +0,0 @@
1
- # Directory to write generated code to (.js and .d.ts files)
2
- OUT_DIR="./protoc"
3
-
4
- # Generate code
5
- ./node_modules/.bin/grpc_tools_node_protoc \
6
- --plugin=protoc-gen-ts_proto=./node_modules/.bin/protoc-gen-ts_proto \
7
- --ts_proto_out=$OUT_DIR \
8
- --ts_proto_opt=outputServices=nice-grpc,outputServices=generic-definitions,useExactTypes=false \
9
- --proto_path=../api-contracts \
10
- ../api-contracts/**/*.proto
@@ -1,116 +0,0 @@
1
- import { CreateWorkflowVersionOpts, WorkflowVersion } from '@protoc/workflows';
2
- import { AdminClient } from './admin-client';
3
- import { mockChannel, mockFactory } from '../hatchet-client/hatchet-client.test';
4
-
5
- describe('AdminClient', () => {
6
- let client: AdminClient;
7
-
8
- it('should create a client', () => {
9
- const x = new AdminClient(
10
- {
11
- token: 'TOKEN',
12
- host_port: 'HOST_PORT',
13
- tls_config: {
14
- cert_file: 'TLS_CERT_FILE',
15
- key_file: 'TLS_KEY_FILE',
16
- ca_file: 'TLS_ROOT_CA_FILE',
17
- server_name: 'TLS_SERVER_NAME',
18
- },
19
- },
20
- mockChannel,
21
- mockFactory
22
- );
23
-
24
- expect(x).toBeDefined();
25
- });
26
-
27
- beforeEach(() => {
28
- client = new AdminClient(
29
- {
30
- token: 'TOKEN',
31
- host_port: 'HOST_PORT',
32
- tls_config: {
33
- cert_file: 'TLS_CERT_FILE',
34
- key_file: 'TLS_KEY_FILE',
35
- ca_file: 'TLS_ROOT_CA_FILE',
36
- server_name: 'TLS_SERVER_NAME',
37
- },
38
- },
39
- mockChannel,
40
- mockFactory
41
- );
42
- });
43
-
44
- describe('put_workflow', () => {
45
- it('should throw an error if no version and not auto version', async () => {
46
- const workflow: CreateWorkflowVersionOpts = {
47
- name: 'workflow1',
48
- version: '',
49
- description: 'description1',
50
- eventTriggers: [],
51
- cronTriggers: [],
52
- scheduledTriggers: [],
53
- jobs: [],
54
- };
55
-
56
- expect(() => client.put_workflow(workflow, { autoVersion: false })).rejects.toThrow(
57
- 'PutWorkflow error: workflow version is required, or use autoVersion'
58
- );
59
- });
60
-
61
- it('should attempt to put the workflow', async () => {
62
- const workflow: CreateWorkflowVersionOpts = {
63
- name: 'workflow1',
64
- version: 'v0.0.1',
65
- description: 'description1',
66
- eventTriggers: [],
67
- cronTriggers: [],
68
- scheduledTriggers: [],
69
- jobs: [],
70
- };
71
-
72
- const putSpy = jest.spyOn(client.client, 'putWorkflow').mockResolvedValue({
73
- id: 'workflow1',
74
- version: 'v0.1.0',
75
- order: 1,
76
- workflowId: 'workflow1',
77
- jobs: [],
78
- createdAt: undefined,
79
- updatedAt: undefined,
80
- triggers: undefined,
81
- });
82
-
83
- await client.put_workflow(workflow);
84
-
85
- expect(putSpy).toHaveBeenCalled();
86
- });
87
- });
88
-
89
- describe('schedule_workflow', () => {
90
- it('should schedule a workflow', () => {
91
- const res: WorkflowVersion = {
92
- id: 'string',
93
- version: 'v0.0.1',
94
- order: 1,
95
- workflowId: 'string',
96
- jobs: [],
97
- createdAt: undefined,
98
- updatedAt: undefined,
99
- triggers: undefined,
100
- };
101
-
102
- const spy = jest.spyOn(client.client, 'scheduleWorkflow').mockResolvedValue(res);
103
-
104
- const now = new Date();
105
-
106
- client.schedule_workflow('workflowId', {
107
- schedules: [now],
108
- });
109
-
110
- expect(spy).toHaveBeenCalledWith({
111
- workflowId: 'workflowId',
112
- schedules: [now],
113
- });
114
- });
115
- });
116
- });