@hatchet-dev/typescript-sdk 0.15.0 → 0.16.0-alpha.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.
@@ -45,6 +45,8 @@ export declare const ClientConfigSchema: z.ZodObject<{
45
45
  log_level: z.ZodOptional<z.ZodEnum<["OFF", "DEBUG", "INFO", "WARN", "ERROR"]>>;
46
46
  tenant_id: z.ZodString;
47
47
  namespace: z.ZodOptional<z.ZodString>;
48
+ runnable_actions: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
49
+ cloud_register_id: z.ZodOptional<z.ZodString>;
48
50
  }, "strip", z.ZodTypeAny, {
49
51
  token: string;
50
52
  tls_config: {
@@ -59,6 +61,8 @@ export declare const ClientConfigSchema: z.ZodObject<{
59
61
  tenant_id: string;
60
62
  log_level?: "OFF" | "DEBUG" | "INFO" | "WARN" | "ERROR" | undefined;
61
63
  namespace?: string | undefined;
64
+ runnable_actions?: string[] | undefined;
65
+ cloud_register_id?: string | undefined;
62
66
  }, {
63
67
  token: string;
64
68
  tls_config: {
@@ -73,6 +77,8 @@ export declare const ClientConfigSchema: z.ZodObject<{
73
77
  tenant_id: string;
74
78
  log_level?: "OFF" | "DEBUG" | "INFO" | "WARN" | "ERROR" | undefined;
75
79
  namespace?: string | undefined;
80
+ runnable_actions?: string[] | undefined;
81
+ cloud_register_id?: string | undefined;
76
82
  }>;
77
83
  export type ClientConfig = z.infer<typeof ClientConfigSchema> & {
78
84
  credentials?: ChannelCredentials;
@@ -17,4 +17,6 @@ exports.ClientConfigSchema = zod_1.z.object({
17
17
  log_level: zod_1.z.enum(['OFF', 'DEBUG', 'INFO', 'WARN', 'ERROR']).optional(),
18
18
  tenant_id: zod_1.z.string(),
19
19
  namespace: zod_1.z.string().optional(),
20
+ runnable_actions: zod_1.z.array(zod_1.z.string()).optional(),
21
+ cloud_register_id: zod_1.z.string().optional(),
20
22
  });
@@ -9,6 +9,7 @@ import { AxiosRequestConfig } from 'axios';
9
9
  import { ClientConfig } from './client-config';
10
10
  import { ListenerClient } from '../listener/listener-client';
11
11
  import { Api } from '../rest/generated/Api';
12
+ import { CloudApi } from '../rest';
12
13
  export interface HatchetClientOptions {
13
14
  config_path?: string;
14
15
  credentials?: ChannelCredentials;
@@ -22,6 +23,7 @@ export declare class HatchetClient {
22
23
  dispatcher: DispatcherClient;
23
24
  admin: AdminClient;
24
25
  api: Api;
26
+ cloudApi: CloudApi;
25
27
  listener: ListenerClient;
26
28
  tenantId: string;
27
29
  logger: Logger;
@@ -1,4 +1,27 @@
1
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
+ };
2
25
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
26
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
27
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -48,7 +71,7 @@ const worker_1 = require("../worker");
48
71
  const logger_1 = __importDefault(require("../../util/logger/logger"));
49
72
  const client_config_1 = require("./client-config");
50
73
  const listener_client_1 = require("../listener/listener-client");
51
- const rest_1 = __importDefault(require("../rest"));
74
+ const rest_1 = __importStar(require("../rest"));
52
75
  const channelFactory = (config, credentials) => (0, nice_grpc_1.createChannel)(config.host_port, credentials, {
53
76
  'grpc.ssl_target_name_override': config.tls_config.server_name,
54
77
  'grpc.keepalive_timeout_ms': 60 * 1000,
@@ -109,6 +132,7 @@ class HatchetClient {
109
132
  const clientFactory = (0, nice_grpc_1.createClientFactory)().use((0, exports.addTokenMiddleware)(this.config.token));
110
133
  this.tenantId = this.config.tenant_id;
111
134
  this.api = (0, rest_1.default)(this.config.api_url, this.config.token, axiosOpts);
135
+ this.cloudApi = (0, rest_1.cloudApi)(this.config.api_url, this.config.token, axiosOpts);
112
136
  this.event = new event_client_1.EventClient(this.config, (0, exports.channelFactory)(this.config, this.credentials), clientFactory);
113
137
  this.dispatcher = new dispatcher_client_1.DispatcherClient(this.config, (0, exports.channelFactory)(this.config, this.credentials), clientFactory);
114
138
  this.listener = new listener_client_1.ListenerClient(this.config, (0, exports.channelFactory)(this.config, this.credentials), clientFactory, this.api);
@@ -1,4 +1,7 @@
1
1
  import { AxiosRequestConfig } from 'axios';
2
2
  import { Api } from './generated/Api';
3
+ import { Api as CloudApi } from './generated/cloud/Api';
3
4
  declare const api: (serverUrl: string, token: string, axiosOpts?: AxiosRequestConfig) => Api<unknown>;
5
+ export declare const cloudApi: (serverUrl: string, token: string, axiosOpts?: AxiosRequestConfig) => CloudApi<unknown>;
6
+ export { api, CloudApi };
4
7
  export default api;
@@ -3,11 +3,21 @@ 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
+ exports.CloudApi = exports.api = exports.cloudApi = void 0;
6
7
  const qs_1 = __importDefault(require("qs"));
7
8
  const Api_1 = require("./generated/Api");
9
+ const Api_2 = require("./generated/cloud/Api");
10
+ Object.defineProperty(exports, "CloudApi", { enumerable: true, get: function () { return Api_2.Api; } });
8
11
  const api = (serverUrl, token, axiosOpts) => {
9
12
  return new Api_1.Api(Object.assign({ baseURL: serverUrl, headers: {
10
13
  Authorization: `Bearer ${token}`,
11
14
  }, paramsSerializer: (params) => qs_1.default.stringify(params, { arrayFormat: 'repeat' }) }, axiosOpts));
12
15
  };
16
+ exports.api = api;
17
+ const cloudApi = (serverUrl, token, axiosOpts) => {
18
+ return new Api_2.Api(Object.assign({ baseURL: serverUrl, headers: {
19
+ Authorization: `Bearer ${token}`,
20
+ }, paramsSerializer: (params) => qs_1.default.stringify(params, { arrayFormat: 'repeat' }) }, axiosOpts));
21
+ };
22
+ exports.cloudApi = cloudApi;
13
23
  exports.default = api;
@@ -0,0 +1,364 @@
1
+ import { APICloudMetadata, Build, CreateManagedWorkerRequest, FeatureFlags, InfraAsCodeRequest, InstanceList, ListGithubAppInstallationsResponse, ListGithubBranchesResponse, ListGithubReposResponse, LogLineList, ManagedWorker, ManagedWorkerEventList, ManagedWorkerList, Matrix, RuntimeConfigActionsResponse, TenantBillingState, TenantSubscription, UpdateManagedWorkerRequest, UpdateTenantSubscription, VectorPushRequest, WorkflowRunEventsMetricsCounts } from './data-contracts';
2
+ import { HttpClient, RequestParams } from './http-client';
3
+ export declare class Api<SecurityDataType = unknown> extends HttpClient<SecurityDataType> {
4
+ /**
5
+ * @description Gets metadata for the Hatchet instance
6
+ *
7
+ * @tags Metadata
8
+ * @name MetadataGet
9
+ * @summary Get metadata
10
+ * @request GET:/api/v1/cloud/metadata
11
+ */
12
+ metadataGet: (params?: RequestParams) => Promise<import("axios").AxiosResponse<APICloudMetadata, any>>;
13
+ /**
14
+ * @description Starts the OAuth flow
15
+ *
16
+ * @tags User
17
+ * @name UserUpdateGithubAppOauthStart
18
+ * @summary Start OAuth flow
19
+ * @request GET:/api/v1/cloud/users/github-app/start
20
+ * @secure
21
+ */
22
+ userUpdateGithubAppOauthStart: (params?: RequestParams) => Promise<import("axios").AxiosResponse<any, any>>;
23
+ /**
24
+ * @description Completes the OAuth flow
25
+ *
26
+ * @tags User
27
+ * @name UserUpdateGithubAppOauthCallback
28
+ * @summary Complete OAuth flow
29
+ * @request GET:/api/v1/cloud/users/github-app/callback
30
+ * @secure
31
+ */
32
+ userUpdateGithubAppOauthCallback: (params?: RequestParams) => Promise<import("axios").AxiosResponse<any, any>>;
33
+ /**
34
+ * @description Github App global webhook
35
+ *
36
+ * @tags Github
37
+ * @name GithubUpdateGlobalWebhook
38
+ * @summary Github app global webhook
39
+ * @request POST:/api/v1/cloud/github/webhook
40
+ */
41
+ githubUpdateGlobalWebhook: (params?: RequestParams) => Promise<import("axios").AxiosResponse<void, any>>;
42
+ /**
43
+ * @description Github App tenant webhook
44
+ *
45
+ * @tags Github
46
+ * @name GithubUpdateTenantWebhook
47
+ * @summary Github app tenant webhook
48
+ * @request POST:/api/v1/cloud/github/webhook/{webhook}
49
+ */
50
+ githubUpdateTenantWebhook: (webhook: string, params?: RequestParams) => Promise<import("axios").AxiosResponse<void, any>>;
51
+ /**
52
+ * @description List Github App installations
53
+ *
54
+ * @tags Github
55
+ * @name GithubAppListInstallations
56
+ * @summary List Github App installations
57
+ * @request GET:/api/v1/cloud/github-app/installations
58
+ * @secure
59
+ */
60
+ githubAppListInstallations: (params?: RequestParams) => Promise<import("axios").AxiosResponse<ListGithubAppInstallationsResponse, any>>;
61
+ /**
62
+ * @description List Github App repositories
63
+ *
64
+ * @tags Github
65
+ * @name GithubAppListRepos
66
+ * @summary List Github App repositories
67
+ * @request GET:/api/v1/cloud/github-app/installations/{gh-installation}/repos
68
+ * @secure
69
+ */
70
+ githubAppListRepos: (ghInstallation: string, params?: RequestParams) => Promise<import("axios").AxiosResponse<ListGithubReposResponse, any>>;
71
+ /**
72
+ * @description List Github App branches
73
+ *
74
+ * @tags Github
75
+ * @name GithubAppListBranches
76
+ * @summary List Github App branches
77
+ * @request GET:/api/v1/cloud/github-app/installations/{gh-installation}/repos/{gh-repo-owner}/{gh-repo-name}/branches
78
+ * @secure
79
+ */
80
+ githubAppListBranches: (ghInstallation: string, ghRepoOwner: string, ghRepoName: string, params?: RequestParams) => Promise<import("axios").AxiosResponse<ListGithubBranchesResponse, any>>;
81
+ /**
82
+ * @description Get all managed workers for the tenant
83
+ *
84
+ * @tags Managed Worker
85
+ * @name ManagedWorkerList
86
+ * @summary List Managed Workers
87
+ * @request GET:/api/v1/cloud/tenants/{tenant}/managed-worker
88
+ * @secure
89
+ */
90
+ managedWorkerList: (tenant: string, params?: RequestParams) => Promise<import("axios").AxiosResponse<ManagedWorkerList, any>>;
91
+ /**
92
+ * @description Create a managed worker for the tenant
93
+ *
94
+ * @tags Managed Worker
95
+ * @name ManagedWorkerCreate
96
+ * @summary Create Managed Worker
97
+ * @request POST:/api/v1/cloud/tenants/{tenant}/managed-worker
98
+ * @secure
99
+ */
100
+ managedWorkerCreate: (tenant: string, data: CreateManagedWorkerRequest, params?: RequestParams) => Promise<import("axios").AxiosResponse<ManagedWorker, any>>;
101
+ /**
102
+ * @description Get a managed worker for the tenant
103
+ *
104
+ * @tags Managed Worker
105
+ * @name ManagedWorkerGet
106
+ * @summary Get Managed Worker
107
+ * @request GET:/api/v1/cloud/managed-worker/{managed-worker}
108
+ * @secure
109
+ */
110
+ managedWorkerGet: (managedWorker: string, params?: RequestParams) => Promise<import("axios").AxiosResponse<ManagedWorker, any>>;
111
+ /**
112
+ * @description Update a managed worker for the tenant
113
+ *
114
+ * @tags Managed Worker
115
+ * @name ManagedWorkerUpdate
116
+ * @summary Update Managed Worker
117
+ * @request POST:/api/v1/cloud/managed-worker/{managed-worker}
118
+ * @secure
119
+ */
120
+ managedWorkerUpdate: (managedWorker: string, data: UpdateManagedWorkerRequest, params?: RequestParams) => Promise<import("axios").AxiosResponse<ManagedWorker, any>>;
121
+ /**
122
+ * @description Delete a managed worker for the tenant
123
+ *
124
+ * @tags Managed Worker
125
+ * @name ManagedWorkerDelete
126
+ * @summary Delete Managed Worker
127
+ * @request DELETE:/api/v1/cloud/managed-worker/{managed-worker}
128
+ * @secure
129
+ */
130
+ managedWorkerDelete: (managedWorker: string, params?: RequestParams) => Promise<import("axios").AxiosResponse<ManagedWorker, any>>;
131
+ /**
132
+ * @description Registers runtime configs via infra-as-code
133
+ *
134
+ * @tags Managed Worker
135
+ * @name InfraAsCodeCreate
136
+ * @summary Create Infra as Code
137
+ * @request POST:/api/v1/cloud/infra-as-code/{infra-as-code-request}
138
+ * @secure
139
+ */
140
+ infraAsCodeCreate: (infraAsCodeRequest: string, data: InfraAsCodeRequest, params?: RequestParams) => Promise<import("axios").AxiosResponse<void, any>>;
141
+ /**
142
+ * @description Get a list of runtime config actions for a managed worker
143
+ *
144
+ * @tags Managed Worker
145
+ * @name RuntimeConfigListActions
146
+ * @summary Get Runtime Config Actions
147
+ * @request GET:/api/v1/cloud/runtime-config/{runtime-config}/actions
148
+ * @secure
149
+ */
150
+ runtimeConfigListActions: (runtimeConfig: string, params?: RequestParams) => Promise<import("axios").AxiosResponse<RuntimeConfigActionsResponse, any>>;
151
+ /**
152
+ * @description Get CPU metrics for a managed worker
153
+ *
154
+ * @tags Metrics
155
+ * @name MetricsCpuGet
156
+ * @summary Get CPU Metrics
157
+ * @request GET:/api/v1/cloud/managed-worker/{managed-worker}/metrics/cpu
158
+ * @secure
159
+ */
160
+ metricsCpuGet: (managedWorker: string, query?: {
161
+ /**
162
+ * When the metrics should start
163
+ * @format date-time
164
+ */
165
+ after?: string;
166
+ /**
167
+ * When the metrics should end
168
+ * @format date-time
169
+ */
170
+ before?: string;
171
+ }, params?: RequestParams) => Promise<import("axios").AxiosResponse<Matrix, any>>;
172
+ /**
173
+ * @description Get memory metrics for a managed worker
174
+ *
175
+ * @tags Metrics
176
+ * @name MetricsMemoryGet
177
+ * @summary Get Memory Metrics
178
+ * @request GET:/api/v1/cloud/managed-worker/{managed-worker}/metrics/memory
179
+ * @secure
180
+ */
181
+ metricsMemoryGet: (managedWorker: string, query?: {
182
+ /**
183
+ * When the metrics should start
184
+ * @format date-time
185
+ */
186
+ after?: string;
187
+ /**
188
+ * When the metrics should end
189
+ * @format date-time
190
+ */
191
+ before?: string;
192
+ }, params?: RequestParams) => Promise<import("axios").AxiosResponse<Matrix, any>>;
193
+ /**
194
+ * @description Get disk metrics for a managed worker
195
+ *
196
+ * @tags Metrics
197
+ * @name MetricsDiskGet
198
+ * @summary Get Disk Metrics
199
+ * @request GET:/api/v1/cloud/managed-worker/{managed-worker}/metrics/disk
200
+ * @secure
201
+ */
202
+ metricsDiskGet: (managedWorker: string, query?: {
203
+ /**
204
+ * When the metrics should start
205
+ * @format date-time
206
+ */
207
+ after?: string;
208
+ /**
209
+ * When the metrics should end
210
+ * @format date-time
211
+ */
212
+ before?: string;
213
+ }, params?: RequestParams) => Promise<import("axios").AxiosResponse<Matrix, any>>;
214
+ /**
215
+ * @description Lists logs for a managed worker
216
+ *
217
+ * @tags Log
218
+ * @name LogList
219
+ * @summary List Logs
220
+ * @request GET:/api/v1/cloud/managed-worker/{managed-worker}/logs
221
+ * @secure
222
+ */
223
+ logList: (managedWorker: string, query?: {
224
+ /**
225
+ * When the logs should start
226
+ * @format date-time
227
+ */
228
+ after?: string;
229
+ /**
230
+ * When the logs should end
231
+ * @format date-time
232
+ */
233
+ before?: string;
234
+ /** The search query to filter for */
235
+ search?: string;
236
+ /** The direction to sort the logs */
237
+ direction?: "forward" | "backward";
238
+ }, params?: RequestParams) => Promise<import("axios").AxiosResponse<LogLineList, any>>;
239
+ /**
240
+ * @description Get all instances for a managed worker
241
+ *
242
+ * @tags Managed Worker
243
+ * @name ManagedWorkerInstancesList
244
+ * @summary List Instances
245
+ * @request GET:/api/v1/cloud/managed-worker/{managed-worker}/instances
246
+ * @secure
247
+ */
248
+ managedWorkerInstancesList: (managedWorker: string, params?: RequestParams) => Promise<import("axios").AxiosResponse<InstanceList, any>>;
249
+ /**
250
+ * @description Get a build
251
+ *
252
+ * @tags Build
253
+ * @name BuildGet
254
+ * @summary Get Build
255
+ * @request GET:/api/v1/cloud/build/{build}
256
+ * @secure
257
+ */
258
+ buildGet: (build: string, params?: RequestParams) => Promise<import("axios").AxiosResponse<Build, any>>;
259
+ /**
260
+ * @description Get the build logs for a specific build of a managed worker
261
+ *
262
+ * @tags Log
263
+ * @name BuildLogsList
264
+ * @summary Get Build Logs
265
+ * @request GET:/api/v1/cloud/build/{build}/logs
266
+ * @secure
267
+ */
268
+ buildLogsList: (build: string, params?: RequestParams) => Promise<import("axios").AxiosResponse<LogLineList, any>>;
269
+ /**
270
+ * @description Get events for a managed worker
271
+ *
272
+ * @tags Managed Worker
273
+ * @name ManagedWorkerEventsList
274
+ * @summary Get Managed Worker Events
275
+ * @request GET:/api/v1/cloud/managed-worker/{managed-worker}/events
276
+ * @secure
277
+ */
278
+ managedWorkerEventsList: (managedWorker: string, params?: RequestParams) => Promise<import("axios").AxiosResponse<ManagedWorkerEventList, any>>;
279
+ /**
280
+ * @description Receive a webhook message from Lago
281
+ *
282
+ * @tags Billing
283
+ * @name LagoMessageCreate
284
+ * @summary Receive a webhook message from Lago
285
+ * @request POST:/api/v1/billing/lago/webhook
286
+ */
287
+ lagoMessageCreate: (params?: RequestParams) => Promise<import("axios").AxiosResponse<void, any>>;
288
+ /**
289
+ * @description Gets the billing state for a tenant
290
+ *
291
+ * @tags Tenant
292
+ * @name TenantBillingStateGet
293
+ * @summary Get the billing state for a tenant
294
+ * @request GET:/api/v1/billing/tenants/{tenant}
295
+ * @secure
296
+ */
297
+ tenantBillingStateGet: (tenant: string, params?: RequestParams) => Promise<import("axios").AxiosResponse<TenantBillingState, any>>;
298
+ /**
299
+ * @description Update a subscription
300
+ *
301
+ * @tags Billing
302
+ * @name SubscriptionUpsert
303
+ * @summary Create a new subscription
304
+ * @request PATCH:/api/v1/billing/tenants/{tenant}/subscription
305
+ * @secure
306
+ */
307
+ subscriptionUpsert: (tenant: string, data: UpdateTenantSubscription, params?: RequestParams) => Promise<import("axios").AxiosResponse<TenantSubscription, any>>;
308
+ /**
309
+ * @description Get the billing portal link
310
+ *
311
+ * @tags Billing
312
+ * @name BillingPortalLinkGet
313
+ * @summary Create a link to the billing portal
314
+ * @request GET:/api/v1/billing/tenants/{tenant}/billing-portal-link
315
+ * @secure
316
+ */
317
+ billingPortalLinkGet: (tenant: string, params?: RequestParams) => Promise<import("axios").AxiosResponse<{
318
+ /** The url to the billing portal */
319
+ url?: string;
320
+ }, any>>;
321
+ /**
322
+ * @description Push a log entry for the tenant
323
+ *
324
+ * @tags Log
325
+ * @name LogCreate
326
+ * @summary Push Log Entry
327
+ * @request POST:/api/v1/cloud/tenants/{tenant}/logs
328
+ * @secure
329
+ */
330
+ logCreate: (tenant: string, data: VectorPushRequest, params?: RequestParams) => Promise<import("axios").AxiosResponse<void, any>>;
331
+ /**
332
+ * @description Get all feature flags for the tenant
333
+ *
334
+ * @tags Feature Flags
335
+ * @name FeatureFlagsList
336
+ * @summary List Feature Flags
337
+ * @request GET:/api/v1/cloud/tenants/{tenant}/feature-flags
338
+ * @secure
339
+ */
340
+ featureFlagsList: (tenant: string, params?: RequestParams) => Promise<import("axios").AxiosResponse<FeatureFlags, any>>;
341
+ /**
342
+ * @description Get a minute by minute breakdown of workflow run metrics for a tenant
343
+ *
344
+ * @tags Workflow
345
+ * @name WorkflowRunEventsGetMetrics
346
+ * @summary Get workflow runs
347
+ * @request GET:/api/v1/cloud/tenants/{tenant}/runs-metrics
348
+ * @secure
349
+ */
350
+ workflowRunEventsGetMetrics: (tenant: string, query?: {
351
+ /**
352
+ * The time after the workflow run was created
353
+ * @format date-time
354
+ * @example "2021-01-01T00:00:00Z"
355
+ */
356
+ createdAfter?: string;
357
+ /**
358
+ * The time before the workflow run was completed
359
+ * @format date-time
360
+ * @example "2021-01-01T00:00:00Z"
361
+ */
362
+ finishedBefore?: string;
363
+ }, params?: RequestParams) => Promise<import("axios").AxiosResponse<WorkflowRunEventsMetricsCounts, any>>;
364
+ }