@hatchet-dev/typescript-sdk 0.16.0-alpha.4 → 0.17.0

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 (59) hide show
  1. package/clients/dispatcher/dispatcher-client.d.ts +2 -1
  2. package/clients/dispatcher/dispatcher-client.js +10 -1
  3. package/clients/event/event-client.js +13 -8
  4. package/clients/hatchet-client/client-config.d.ts +0 -6
  5. package/clients/hatchet-client/client-config.js +0 -2
  6. package/clients/hatchet-client/features/cron-client.d.ts +79 -0
  7. package/clients/hatchet-client/features/cron-client.js +127 -0
  8. package/clients/hatchet-client/features/schedule-client.d.ts +76 -0
  9. package/clients/hatchet-client/features/schedule-client.js +120 -0
  10. package/clients/hatchet-client/hatchet-client.d.ts +4 -2
  11. package/clients/hatchet-client/hatchet-client.js +6 -25
  12. package/clients/listener/child-listener-client.js +16 -13
  13. package/clients/rest/api.d.ts +0 -3
  14. package/clients/rest/api.js +0 -10
  15. package/clients/rest/generated/Api.d.ts +152 -2
  16. package/clients/rest/generated/Api.js +81 -1
  17. package/clients/rest/generated/data-contracts.d.ts +86 -0
  18. package/clients/rest/generated/data-contracts.js +27 -1
  19. package/clients/rest/index.d.ts +2 -2
  20. package/clients/rest/index.js +21 -10
  21. package/clients/worker/handler.js +16 -11
  22. package/clients/worker/worker.d.ts +2 -10
  23. package/clients/worker/worker.js +24 -38
  24. package/examples/crons/cron-worker.d.ts +2 -0
  25. package/examples/crons/cron-worker.js +48 -0
  26. package/examples/crons/programatic-crons.js +55 -0
  27. package/examples/on-failure.js +15 -10
  28. package/examples/retries-with-backoff.d.ts +1 -0
  29. package/examples/{managed-worker.js → retries-with-backoff.js} +24 -33
  30. package/examples/scheduled-runs/programatic-schedules.d.ts +1 -0
  31. package/examples/scheduled-runs/programatic-schedules.js +54 -0
  32. package/examples/simple-worker.d.ts +2 -1
  33. package/examples/simple-worker.js +6 -3
  34. package/package.json +8 -8
  35. package/protoc/dispatcher/dispatcher.js +1 -1
  36. package/protoc/events/events.js +1 -1
  37. package/protoc/google/protobuf/timestamp.js +1 -1
  38. package/protoc/google/protobuf/wrappers.js +17 -7
  39. package/protoc/workflows/workflows.d.ts +13 -0
  40. package/protoc/workflows/workflows.js +160 -7
  41. package/step.d.ts +17 -121
  42. package/step.js +23 -9
  43. package/util/config-loader/config-loader.js +18 -26
  44. package/util/retrier.js +8 -3
  45. package/version.d.ts +1 -0
  46. package/version.js +4 -0
  47. package/workflow.d.ts +67 -459
  48. package/workflow.js +17 -7
  49. package/clients/rest/generated/cloud/Api.d.ts +0 -377
  50. package/clients/rest/generated/cloud/Api.js +0 -326
  51. package/clients/rest/generated/cloud/data-contracts.d.ts +0 -468
  52. package/clients/rest/generated/cloud/data-contracts.js +0 -68
  53. package/clients/rest/generated/cloud/http-client.d.ts +0 -41
  54. package/clients/rest/generated/cloud/http-client.js +0 -102
  55. package/clients/worker/compute/compute-config.d.ts +0 -156
  56. package/clients/worker/compute/compute-config.js +0 -82
  57. package/clients/worker/compute/managed-compute.d.ts +0 -15
  58. package/clients/worker/compute/managed-compute.js +0 -104
  59. /package/examples/{managed-worker.d.ts → crons/programatic-crons.d.ts} +0 -0
@@ -1,468 +0,0 @@
1
- export interface APICloudMetadata {
2
- /**
3
- * whether the tenant can be billed
4
- * @example true
5
- */
6
- canBill?: boolean;
7
- /**
8
- * whether the tenant can link to GitHub
9
- * @example true
10
- */
11
- canLinkGithub?: boolean;
12
- /**
13
- * whether metrics are enabled for the tenant
14
- * @example true
15
- */
16
- metricsEnabled?: boolean;
17
- }
18
- export interface APIErrors {
19
- errors: APIError[];
20
- }
21
- export interface APIError {
22
- /**
23
- * a custom Hatchet error code
24
- * @format uint64
25
- * @example 1400
26
- */
27
- code?: number;
28
- /**
29
- * the field that this error is associated with, if applicable
30
- * @example "name"
31
- */
32
- field?: string;
33
- /**
34
- * a description for this error
35
- * @example "A descriptive error message"
36
- */
37
- description: string;
38
- /**
39
- * a link to the documentation for this error, if it exists
40
- * @example "github.com/hatchet-dev/hatchet"
41
- */
42
- docs_link?: string;
43
- }
44
- /** @example {"next_page":3,"num_pages":10,"current_page":2} */
45
- export interface PaginationResponse {
46
- /**
47
- * the current page
48
- * @format int64
49
- * @example 2
50
- */
51
- current_page?: number;
52
- /**
53
- * the next page
54
- * @format int64
55
- * @example 3
56
- */
57
- next_page?: number;
58
- /**
59
- * the total number of pages for listing
60
- * @format int64
61
- * @example 10
62
- */
63
- num_pages?: number;
64
- }
65
- export interface APIResourceMeta {
66
- /**
67
- * the id of this resource, in UUID format
68
- * @format uuid
69
- * @minLength 36
70
- * @maxLength 36
71
- * @example "bb214807-246e-43a5-a25d-41761d1cff9e"
72
- */
73
- id: string;
74
- /**
75
- * the time that this resource was created
76
- * @format date-time
77
- * @example "2022-12-13T20:06:48.888Z"
78
- */
79
- createdAt: string;
80
- /**
81
- * the time that this resource was last updated
82
- * @format date-time
83
- * @example "2022-12-13T20:06:48.888Z"
84
- */
85
- updatedAt: string;
86
- }
87
- export interface GithubBranch {
88
- branch_name: string;
89
- is_default: boolean;
90
- }
91
- export interface GithubRepo {
92
- repo_owner: string;
93
- repo_name: string;
94
- }
95
- export interface GithubAppInstallation {
96
- metadata: APIResourceMeta;
97
- installation_settings_url: string;
98
- account_name: string;
99
- account_avatar_url: string;
100
- }
101
- export interface ListGithubAppInstallationsResponse {
102
- pagination: PaginationResponse;
103
- rows: GithubAppInstallation[];
104
- }
105
- export type ListGithubReposResponse = GithubRepo[];
106
- export type ListGithubBranchesResponse = GithubBranch[];
107
- export interface ManagedWorker {
108
- metadata: APIResourceMeta;
109
- name: string;
110
- buildConfig: ManagedWorkerBuildConfig;
111
- isIac: boolean;
112
- /** A map of environment variables to set for the worker */
113
- envVars: Record<string, string>;
114
- runtimeConfigs?: ManagedWorkerRuntimeConfig[];
115
- }
116
- export interface ManagedWorkerList {
117
- rows?: ManagedWorker[];
118
- pagination?: PaginationResponse;
119
- }
120
- export interface ManagedWorkerBuildConfig {
121
- metadata: APIResourceMeta;
122
- /**
123
- * @format uuid
124
- * @minLength 36
125
- * @maxLength 36
126
- */
127
- githubInstallationId: string;
128
- githubRepository: GithubRepo;
129
- githubRepositoryBranch: string;
130
- steps?: BuildStep[];
131
- }
132
- export interface BuildStep {
133
- metadata: APIResourceMeta;
134
- /** The relative path to the build directory */
135
- buildDir: string;
136
- /** The relative path from the build dir to the Dockerfile */
137
- dockerfilePath: string;
138
- }
139
- export interface ManagedWorkerRuntimeConfig {
140
- metadata: APIResourceMeta;
141
- numReplicas: number;
142
- /** The kind of CPU to use for the worker */
143
- cpuKind: string;
144
- /** The number of CPUs to use for the worker */
145
- cpus: number;
146
- /** The amount of memory in MB to use for the worker */
147
- memoryMb: number;
148
- /** The region that the worker is deployed to */
149
- region: ManagedWorkerRegion;
150
- /** A list of actions this runtime config corresponds to */
151
- actions?: string[];
152
- }
153
- export declare enum ManagedWorkerEventStatus {
154
- IN_PROGRESS = "IN_PROGRESS",
155
- SUCCEEDED = "SUCCEEDED",
156
- FAILED = "FAILED",
157
- CANCELLED = "CANCELLED"
158
- }
159
- export interface ManagedWorkerEvent {
160
- id: number;
161
- /** @format date-time */
162
- timeFirstSeen: string;
163
- /** @format date-time */
164
- timeLastSeen: string;
165
- managedWorkerId: string;
166
- status: ManagedWorkerEventStatus;
167
- message: string;
168
- data: object;
169
- }
170
- export interface ManagedWorkerEventList {
171
- pagination?: PaginationResponse;
172
- rows?: ManagedWorkerEvent[];
173
- }
174
- export interface CreateManagedWorkerRequest {
175
- name: string;
176
- buildConfig: CreateManagedWorkerBuildConfigRequest;
177
- /** A map of environment variables to set for the worker */
178
- envVars: Record<string, string>;
179
- isIac: boolean;
180
- runtimeConfig?: CreateManagedWorkerRuntimeConfigRequest;
181
- }
182
- export interface UpdateManagedWorkerRequest {
183
- name?: string;
184
- buildConfig?: CreateManagedWorkerBuildConfigRequest;
185
- /** A map of environment variables to set for the worker */
186
- envVars?: Record<string, string>;
187
- isIac?: boolean;
188
- runtimeConfig?: CreateManagedWorkerRuntimeConfigRequest;
189
- }
190
- export interface InfraAsCodeRequest {
191
- runtimeConfigs: CreateManagedWorkerRuntimeConfigRequest[];
192
- }
193
- export interface RuntimeConfigActionsResponse {
194
- actions: string[];
195
- }
196
- export interface CreateManagedWorkerBuildConfigRequest {
197
- /**
198
- * @format uuid
199
- * @minLength 36
200
- * @maxLength 36
201
- */
202
- githubInstallationId: string;
203
- githubRepositoryOwner: string;
204
- githubRepositoryName: string;
205
- githubRepositoryBranch: string;
206
- steps: CreateBuildStepRequest[];
207
- }
208
- export interface CreateBuildStepRequest {
209
- /** The relative path to the build directory */
210
- buildDir: string;
211
- /** The relative path from the build dir to the Dockerfile */
212
- dockerfilePath: string;
213
- }
214
- export declare enum ManagedWorkerRegion {
215
- Ams = "ams",
216
- Arn = "arn",
217
- Atl = "atl",
218
- Bog = "bog",
219
- Bos = "bos",
220
- Cdg = "cdg",
221
- Den = "den",
222
- Dfw = "dfw",
223
- Ewr = "ewr",
224
- Eze = "eze",
225
- Gdl = "gdl",
226
- Gig = "gig",
227
- Gru = "gru",
228
- Hkg = "hkg",
229
- Iad = "iad",
230
- Jnb = "jnb",
231
- Lax = "lax",
232
- Lhr = "lhr",
233
- Mad = "mad",
234
- Mia = "mia",
235
- Nrt = "nrt",
236
- Ord = "ord",
237
- Otp = "otp",
238
- Phx = "phx",
239
- Qro = "qro",
240
- Scl = "scl",
241
- Sea = "sea",
242
- Sin = "sin",
243
- Sjc = "sjc",
244
- Syd = "syd",
245
- Waw = "waw",
246
- Yul = "yul",
247
- Yyz = "yyz"
248
- }
249
- export interface CreateManagedWorkerRuntimeConfigRequest {
250
- /**
251
- * @min 0
252
- * @max 1000
253
- */
254
- numReplicas: number;
255
- /** The region to deploy the worker to */
256
- regions?: ManagedWorkerRegion[];
257
- /** The kind of CPU to use for the worker */
258
- cpuKind: string;
259
- /**
260
- * The number of CPUs to use for the worker
261
- * @min 1
262
- * @max 64
263
- */
264
- cpus: number;
265
- /**
266
- * The amount of memory in MB to use for the worker
267
- * @min 1024
268
- * @max 65536
269
- */
270
- memoryMb: number;
271
- /** The kind of GPU to use for the worker */
272
- gpuKind?: 'a10' | 'l40s' | 'a100-40gb' | 'a100-80gb';
273
- /**
274
- * The number of GPUs to use for the worker
275
- * @min 1
276
- * @max 8
277
- */
278
- gpus?: number;
279
- actions?: string[];
280
- /**
281
- * @min 1
282
- * @max 1000
283
- */
284
- slots?: number;
285
- }
286
- export interface TenantBillingState {
287
- paymentMethods?: TenantPaymentMethod[];
288
- /** The subscription associated with this policy. */
289
- subscription: TenantSubscription;
290
- /** A list of plans available for the tenant. */
291
- plans?: SubscriptionPlan[];
292
- /** A list of coupons applied to the tenant. */
293
- coupons?: Coupon[];
294
- }
295
- export interface SubscriptionPlan {
296
- /** The code of the plan. */
297
- plan_code: string;
298
- /** The name of the plan. */
299
- name: string;
300
- /** The description of the plan. */
301
- description: string;
302
- /** The price of the plan. */
303
- amount_cents: number;
304
- /** The period of the plan. */
305
- period?: string;
306
- }
307
- export interface UpdateTenantSubscription {
308
- /** The code of the plan. */
309
- plan?: string;
310
- /** The period of the plan. */
311
- period?: string;
312
- }
313
- export interface TenantSubscription {
314
- /** The plan code associated with the tenant subscription. */
315
- plan?: string;
316
- /** The period associated with the tenant subscription. */
317
- period?: string;
318
- /** The status of the tenant subscription. */
319
- status?: TenantSubscriptionStatus;
320
- /** A note associated with the tenant subscription. */
321
- note?: string;
322
- }
323
- export interface TenantPaymentMethod {
324
- /** The brand of the payment method. */
325
- brand: string;
326
- /** The last 4 digits of the card. */
327
- last4?: string;
328
- /** The expiration date of the card. */
329
- expiration?: string;
330
- /** The description of the payment method. */
331
- description?: string;
332
- }
333
- export declare enum TenantSubscriptionStatus {
334
- Active = "active",
335
- Pending = "pending",
336
- Terminated = "terminated",
337
- Canceled = "canceled"
338
- }
339
- export interface Coupon {
340
- /** The name of the coupon. */
341
- name: string;
342
- /** The amount off of the coupon. */
343
- amount_cents?: number;
344
- /** The amount remaining on the coupon. */
345
- amount_cents_remaining?: number;
346
- /** The currency of the coupon. */
347
- amount_currency?: string;
348
- /** The frequency of the coupon. */
349
- frequency: CouponFrequency;
350
- /** The frequency duration of the coupon. */
351
- frequency_duration?: number;
352
- /** The frequency duration remaining of the coupon. */
353
- frequency_duration_remaining?: number;
354
- /** The percentage off of the coupon. */
355
- percent?: number;
356
- }
357
- export declare enum CouponFrequency {
358
- Once = "once",
359
- Recurring = "recurring"
360
- }
361
- export type VectorPushRequest = EventObject[];
362
- export interface EventObject {
363
- event?: {
364
- provider?: string;
365
- };
366
- fly?: {
367
- app?: {
368
- instance?: string;
369
- name?: string;
370
- };
371
- region?: string;
372
- };
373
- host?: string;
374
- log?: {
375
- level?: string;
376
- };
377
- message?: string;
378
- /** @format date-time */
379
- timestamp?: string;
380
- }
381
- export interface LogLine {
382
- /** @format date-time */
383
- timestamp: string;
384
- instance: string;
385
- line: string;
386
- }
387
- export interface LogLineList {
388
- rows?: LogLine[];
389
- pagination?: PaginationResponse;
390
- }
391
- export type Matrix = SampleStream[];
392
- export interface SampleStream {
393
- metric?: Metric;
394
- values?: SamplePair[];
395
- histograms?: SampleHistogramPair[];
396
- }
397
- export type SamplePair = any[];
398
- /** @format float */
399
- export type SampleValue = number;
400
- export interface SampleHistogramPair {
401
- timestamp?: Time;
402
- histogram?: SampleHistogram;
403
- }
404
- export interface SampleHistogram {
405
- count?: FloatString;
406
- sum?: FloatString;
407
- buckets?: HistogramBuckets;
408
- }
409
- /** @format float */
410
- export type FloatString = number;
411
- export type HistogramBuckets = HistogramBucket[];
412
- export interface HistogramBucket {
413
- /** @format int32 */
414
- boundaries?: number;
415
- lower?: FloatString;
416
- upper?: FloatString;
417
- count?: FloatString;
418
- }
419
- export type Metric = Record<string, LabelValue>;
420
- export type LabelSet = Record<string, LabelValue>;
421
- export type LabelName = string;
422
- export type LabelValue = string;
423
- export type Time = number;
424
- export interface Build {
425
- metadata?: APIResourceMeta;
426
- status: string;
427
- statusDetail?: string;
428
- /** @format date-time */
429
- createTime: string;
430
- /** @format date-time */
431
- startTime?: string;
432
- /** @format date-time */
433
- finishTime?: string;
434
- /** @format uuid */
435
- buildConfigId: string;
436
- }
437
- export interface Instance {
438
- instanceId: string;
439
- name: string;
440
- region: string;
441
- state: string;
442
- cpuKind: string;
443
- cpus: number;
444
- memoryMb: number;
445
- diskGb: number;
446
- commitSha: string;
447
- }
448
- export interface InstanceList {
449
- pagination?: PaginationResponse;
450
- rows?: Instance[];
451
- }
452
- /**
453
- * a map of feature flags for the tenant
454
- * @example {"flag1":"value1","flag2":"value2"}
455
- */
456
- export type FeatureFlags = Record<string, string>;
457
- export interface WorkflowRunEventsMetric {
458
- /** @format date-time */
459
- time: string;
460
- PENDING: number;
461
- RUNNING: number;
462
- SUCCEEDED: number;
463
- FAILED: number;
464
- QUEUED: number;
465
- }
466
- export interface WorkflowRunEventsMetricsCounts {
467
- results?: WorkflowRunEventsMetric[];
468
- }
@@ -1,68 +0,0 @@
1
- "use strict";
2
- /* eslint-disable */
3
- /* tslint:disable */
4
- /*
5
- * ---------------------------------------------------------------
6
- * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ##
7
- * ## ##
8
- * ## AUTHOR: acacode ##
9
- * ## SOURCE: https://github.com/acacode/swagger-typescript-api ##
10
- * ---------------------------------------------------------------
11
- */
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.CouponFrequency = exports.TenantSubscriptionStatus = exports.ManagedWorkerRegion = exports.ManagedWorkerEventStatus = void 0;
14
- var ManagedWorkerEventStatus;
15
- (function (ManagedWorkerEventStatus) {
16
- ManagedWorkerEventStatus["IN_PROGRESS"] = "IN_PROGRESS";
17
- ManagedWorkerEventStatus["SUCCEEDED"] = "SUCCEEDED";
18
- ManagedWorkerEventStatus["FAILED"] = "FAILED";
19
- ManagedWorkerEventStatus["CANCELLED"] = "CANCELLED";
20
- })(ManagedWorkerEventStatus || (exports.ManagedWorkerEventStatus = ManagedWorkerEventStatus = {}));
21
- var ManagedWorkerRegion;
22
- (function (ManagedWorkerRegion) {
23
- ManagedWorkerRegion["Ams"] = "ams";
24
- ManagedWorkerRegion["Arn"] = "arn";
25
- ManagedWorkerRegion["Atl"] = "atl";
26
- ManagedWorkerRegion["Bog"] = "bog";
27
- ManagedWorkerRegion["Bos"] = "bos";
28
- ManagedWorkerRegion["Cdg"] = "cdg";
29
- ManagedWorkerRegion["Den"] = "den";
30
- ManagedWorkerRegion["Dfw"] = "dfw";
31
- ManagedWorkerRegion["Ewr"] = "ewr";
32
- ManagedWorkerRegion["Eze"] = "eze";
33
- ManagedWorkerRegion["Gdl"] = "gdl";
34
- ManagedWorkerRegion["Gig"] = "gig";
35
- ManagedWorkerRegion["Gru"] = "gru";
36
- ManagedWorkerRegion["Hkg"] = "hkg";
37
- ManagedWorkerRegion["Iad"] = "iad";
38
- ManagedWorkerRegion["Jnb"] = "jnb";
39
- ManagedWorkerRegion["Lax"] = "lax";
40
- ManagedWorkerRegion["Lhr"] = "lhr";
41
- ManagedWorkerRegion["Mad"] = "mad";
42
- ManagedWorkerRegion["Mia"] = "mia";
43
- ManagedWorkerRegion["Nrt"] = "nrt";
44
- ManagedWorkerRegion["Ord"] = "ord";
45
- ManagedWorkerRegion["Otp"] = "otp";
46
- ManagedWorkerRegion["Phx"] = "phx";
47
- ManagedWorkerRegion["Qro"] = "qro";
48
- ManagedWorkerRegion["Scl"] = "scl";
49
- ManagedWorkerRegion["Sea"] = "sea";
50
- ManagedWorkerRegion["Sin"] = "sin";
51
- ManagedWorkerRegion["Sjc"] = "sjc";
52
- ManagedWorkerRegion["Syd"] = "syd";
53
- ManagedWorkerRegion["Waw"] = "waw";
54
- ManagedWorkerRegion["Yul"] = "yul";
55
- ManagedWorkerRegion["Yyz"] = "yyz";
56
- })(ManagedWorkerRegion || (exports.ManagedWorkerRegion = ManagedWorkerRegion = {}));
57
- var TenantSubscriptionStatus;
58
- (function (TenantSubscriptionStatus) {
59
- TenantSubscriptionStatus["Active"] = "active";
60
- TenantSubscriptionStatus["Pending"] = "pending";
61
- TenantSubscriptionStatus["Terminated"] = "terminated";
62
- TenantSubscriptionStatus["Canceled"] = "canceled";
63
- })(TenantSubscriptionStatus || (exports.TenantSubscriptionStatus = TenantSubscriptionStatus = {}));
64
- var CouponFrequency;
65
- (function (CouponFrequency) {
66
- CouponFrequency["Once"] = "once";
67
- CouponFrequency["Recurring"] = "recurring";
68
- })(CouponFrequency || (exports.CouponFrequency = CouponFrequency = {}));
@@ -1,41 +0,0 @@
1
- import type { AxiosInstance, AxiosRequestConfig, AxiosResponse, ResponseType } from 'axios';
2
- export type QueryParamsType = Record<string | number, any>;
3
- export interface FullRequestParams extends Omit<AxiosRequestConfig, 'data' | 'params' | 'url' | 'responseType'> {
4
- /** set parameter to `true` for call `securityWorker` for this request */
5
- secure?: boolean;
6
- /** request path */
7
- path: string;
8
- /** content type of request body */
9
- type?: ContentType;
10
- /** query params */
11
- query?: QueryParamsType;
12
- /** format of response (i.e. response.json() -> format: "json") */
13
- format?: ResponseType;
14
- /** request body */
15
- body?: unknown;
16
- }
17
- export type RequestParams = Omit<FullRequestParams, 'body' | 'method' | 'query' | 'path'>;
18
- export interface ApiConfig<SecurityDataType = unknown> extends Omit<AxiosRequestConfig, 'data' | 'cancelToken'> {
19
- securityWorker?: (securityData: SecurityDataType | null) => Promise<AxiosRequestConfig | void> | AxiosRequestConfig | void;
20
- secure?: boolean;
21
- format?: ResponseType;
22
- }
23
- export declare enum ContentType {
24
- Json = "application/json",
25
- FormData = "multipart/form-data",
26
- UrlEncoded = "application/x-www-form-urlencoded",
27
- Text = "text/plain"
28
- }
29
- export declare class HttpClient<SecurityDataType = unknown> {
30
- instance: AxiosInstance;
31
- private securityData;
32
- private securityWorker?;
33
- private secure?;
34
- private format?;
35
- constructor({ securityWorker, secure, format, ...axiosConfig }?: ApiConfig<SecurityDataType>);
36
- setSecurityData: (data: SecurityDataType | null) => void;
37
- protected mergeRequestParams(params1: AxiosRequestConfig, params2?: AxiosRequestConfig): AxiosRequestConfig;
38
- protected stringifyFormItem(formItem: unknown): string;
39
- protected createFormData(input: Record<string, unknown>): FormData;
40
- request: <T = any, _E = any>({ secure, path, type, query, format, body, ...params }: FullRequestParams) => Promise<AxiosResponse<T>>;
41
- }
@@ -1,102 +0,0 @@
1
- "use strict";
2
- /* eslint-disable */
3
- /* tslint:disable */
4
- /*
5
- * ---------------------------------------------------------------
6
- * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ##
7
- * ## ##
8
- * ## AUTHOR: acacode ##
9
- * ## SOURCE: https://github.com/acacode/swagger-typescript-api ##
10
- * ---------------------------------------------------------------
11
- */
12
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
- return new (P || (P = Promise))(function (resolve, reject) {
15
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
- step((generator = generator.apply(thisArg, _arguments || [])).next());
19
- });
20
- };
21
- var __rest = (this && this.__rest) || function (s, e) {
22
- var t = {};
23
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
24
- t[p] = s[p];
25
- if (s != null && typeof Object.getOwnPropertySymbols === "function")
26
- for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
27
- if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
28
- t[p[i]] = s[p[i]];
29
- }
30
- return t;
31
- };
32
- var __importDefault = (this && this.__importDefault) || function (mod) {
33
- return (mod && mod.__esModule) ? mod : { "default": mod };
34
- };
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.HttpClient = exports.ContentType = void 0;
37
- const axios_1 = __importDefault(require("axios"));
38
- var ContentType;
39
- (function (ContentType) {
40
- ContentType["Json"] = "application/json";
41
- ContentType["FormData"] = "multipart/form-data";
42
- ContentType["UrlEncoded"] = "application/x-www-form-urlencoded";
43
- ContentType["Text"] = "text/plain";
44
- })(ContentType || (exports.ContentType = ContentType = {}));
45
- class HttpClient {
46
- constructor(_a = {}) {
47
- var { securityWorker, secure, format } = _a, axiosConfig = __rest(_a, ["securityWorker", "secure", "format"]);
48
- this.securityData = null;
49
- this.setSecurityData = (data) => {
50
- this.securityData = data;
51
- };
52
- this.request = (_a) => __awaiter(this, void 0, void 0, function* () {
53
- var { secure, path, type, query, format, body } = _a, params = __rest(_a, ["secure", "path", "type", "query", "format", "body"]);
54
- const secureParams = ((typeof secure === 'boolean' ? secure : this.secure) &&
55
- this.securityWorker &&
56
- (yield this.securityWorker(this.securityData))) ||
57
- {};
58
- const requestParams = this.mergeRequestParams(params, secureParams);
59
- const responseFormat = format || this.format || undefined;
60
- if (type === ContentType.FormData && body && body !== null && typeof body === 'object') {
61
- body = this.createFormData(body);
62
- }
63
- if (type === ContentType.Text && body && body !== null && typeof body !== 'string') {
64
- body = JSON.stringify(body);
65
- }
66
- return this.instance.request(Object.assign(Object.assign({}, requestParams), { headers: Object.assign(Object.assign({}, (requestParams.headers || {})), (type ? { 'Content-Type': type } : {})), params: query, responseType: responseFormat, data: body, url: path }));
67
- });
68
- this.instance = axios_1.default.create(Object.assign(Object.assign({}, axiosConfig), { baseURL: axiosConfig.baseURL || '' }));
69
- this.secure = secure;
70
- this.format = format;
71
- this.securityWorker = securityWorker;
72
- }
73
- mergeRequestParams(params1, params2) {
74
- const method = params1.method || (params2 && params2.method);
75
- return Object.assign(Object.assign(Object.assign(Object.assign({}, this.instance.defaults), params1), (params2 || {})), { headers: Object.assign(Object.assign(Object.assign({}, ((method &&
76
- this.instance.defaults.headers[method.toLowerCase()]) ||
77
- {})), (params1.headers || {})), ((params2 && params2.headers) || {})) });
78
- }
79
- stringifyFormItem(formItem) {
80
- if (typeof formItem === 'object' && formItem !== null) {
81
- return JSON.stringify(formItem);
82
- }
83
- else {
84
- return `${formItem}`;
85
- }
86
- }
87
- createFormData(input) {
88
- if (input instanceof FormData) {
89
- return input;
90
- }
91
- return Object.keys(input || {}).reduce((formData, key) => {
92
- const property = input[key];
93
- const propertyContent = property instanceof Array ? property : [property];
94
- for (const formItem of propertyContent) {
95
- const isFileType = formItem instanceof Blob || formItem instanceof File;
96
- formData.append(key, isFileType ? formItem : this.stringifyFormItem(formItem));
97
- }
98
- return formData;
99
- }, new FormData());
100
- }
101
- }
102
- exports.HttpClient = HttpClient;