@stackone/connect-sdk 1.38.0 → 1.40.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.
package/dist/index.d.ts CHANGED
@@ -1,7 +1,549 @@
1
- import { Account, Block, BlockContext, Category, Connector, Cursor, Operation, Step, StepFunctionName, StepFunctionParams, StepFunctionsFactory } from "@stackone/core";
2
- import { ILogger } from "@stackone/logger";
3
- import { HttpMethod, IHttpClient } from "@stackone/transport";
1
+ import { ZodType } from "zod/v4";
2
+ import http from "node:http";
3
+ import https from "node:https";
4
4
 
5
+ //#region ../core/src/categories/types.d.ts
6
+ type Category = 'hris' | 'crm' | 'ats' | 'lms' | 'marketing' | 'filestorage' | 'internal';
7
+ //#endregion
8
+ //#region ../core/src/compositeIds/types.d.ts
9
+
10
+ type ComponentConfig = {
11
+ name: string;
12
+ alias?: string;
13
+ };
14
+ type ComponentFieldConfig = {
15
+ targetFieldKey: string;
16
+ remote?: string;
17
+ components: ComponentConfig[];
18
+ };
19
+ type CompositeIdentifierConnectorConfig = {
20
+ enabled: boolean;
21
+ version?: number;
22
+ fields?: ComponentFieldConfig[];
23
+ };
24
+ //#endregion
25
+ //#region ../core/src/cursor/types.d.ts
26
+ type Position = {
27
+ pageNumber?: number | null;
28
+ providerPageCursor?: string | null;
29
+ position?: number | null;
30
+ };
31
+ type Cursor = {
32
+ remote: Record<number, Position>;
33
+ version: number;
34
+ timestamp: number;
35
+ };
36
+ //#endregion
37
+ //#region ../logger/src/types.d.ts
38
+ interface ILogger {
39
+ debug({
40
+ category,
41
+ message,
42
+ traceId,
43
+ context
44
+ }: {
45
+ category?: string;
46
+ message: string;
47
+ traceId?: string;
48
+ context?: Record<string, unknown>;
49
+ }): void;
50
+ info({
51
+ category,
52
+ message,
53
+ traceId,
54
+ context
55
+ }: {
56
+ category?: string;
57
+ message: string;
58
+ traceId?: string;
59
+ context?: Record<string, unknown>;
60
+ }): void;
61
+ warning({
62
+ category,
63
+ message,
64
+ traceId,
65
+ error,
66
+ code,
67
+ context
68
+ }: {
69
+ category?: string;
70
+ message: string;
71
+ traceId?: string;
72
+ error?: LogError;
73
+ code?: string;
74
+ context?: Record<string, unknown>;
75
+ }): void;
76
+ error({
77
+ category,
78
+ message,
79
+ traceId,
80
+ error,
81
+ code,
82
+ context
83
+ }: {
84
+ category?: string;
85
+ message: string;
86
+ traceId?: string;
87
+ error?: LogError;
88
+ code: string;
89
+ context?: Record<string, unknown>;
90
+ }): void;
91
+ }
92
+ type LogError = Error & {
93
+ response?: {
94
+ data?: unknown;
95
+ };
96
+ context?: Record<string, unknown>;
97
+ url?: string;
98
+ };
99
+ //#endregion
100
+ //#region ../transport/src/concurrencyManager/types.d.ts
101
+ type ConcurrencySubPoolConfig = {
102
+ subPoolKey: string;
103
+ urlPattern: RegExp | string;
104
+ maxConcurrency: number;
105
+ };
106
+ type ConcurrencyConfig = {
107
+ mainMaxConcurrency: number;
108
+ subPools?: ConcurrencySubPoolConfig[];
109
+ };
110
+ //#endregion
111
+ //#region ../transport/src/rateLimitManager/types.d.ts
112
+ type RateLimitSubPoolConfig = {
113
+ subPoolKey: string;
114
+ urlPattern: RegExp | string;
115
+ rateLimit: number;
116
+ };
117
+ type RetryUnit = 'seconds' | 'milliseconds' | 'date';
118
+ type MappedRateLimitErrorConfig = {
119
+ errorStatus: number;
120
+ errorMessage: string | RegExp;
121
+ errorMessagePath?: string;
122
+ retryAfterPath?: string;
123
+ retryAfterUnit?: RetryUnit;
124
+ retryAfterValue?: number;
125
+ };
126
+ type RateLimitConfig = {
127
+ mainRatelimit: number;
128
+ subPools?: RateLimitSubPoolConfig[];
129
+ mappedRateLimitErrors?: MappedRateLimitErrorConfig[];
130
+ };
131
+ //#endregion
132
+ //#region ../transport/src/interceptors/types.d.ts
133
+ type RequestConfig = {
134
+ rateLimits?: RateLimitConfig;
135
+ concurrency?: ConcurrencyConfig;
136
+ };
137
+ //#endregion
138
+ //#region ../transport/src/httpClient/types.d.ts
139
+ type HttpHeaders = {
140
+ [key: string]: string;
141
+ };
142
+ type HttpQueryParams = {
143
+ [key: string]: string;
144
+ };
145
+ declare const HttpMethods: readonly ["get", "post", "put", "delete", "patch"];
146
+ type HttpMethod = (typeof HttpMethods)[number];
147
+ type HttpResponse<T = any> = {
148
+ data: T;
149
+ status: number;
150
+ headers: HttpHeaders;
151
+ requestUrl: string;
152
+ responseType?: string;
153
+ responseTime?: Date;
154
+ message?: string;
155
+ };
156
+ interface IHttpClient {
157
+ request<P, T>({
158
+ headers,
159
+ url,
160
+ method,
161
+ queryParams,
162
+ maxRedirects,
163
+ responseType,
164
+ cacheTTL,
165
+ context,
166
+ payload,
167
+ httpsAgent,
168
+ httpAgent,
169
+ requestConfig,
170
+ httpsAgentConfig
171
+ }: {
172
+ headers?: HttpHeaders;
173
+ url: string;
174
+ method?: HttpMethod;
175
+ queryParams?: HttpQueryParams;
176
+ maxRedirects?: number;
177
+ responseType?: 'arraybuffer' | 'blob' | 'document' | 'json' | 'text';
178
+ cacheTTL?: number;
179
+ context?: RequestContext;
180
+ payload?: P;
181
+ httpsAgent?: https.Agent;
182
+ httpAgent?: http.Agent;
183
+ requestConfig?: RequestConfig;
184
+ httpsAgentConfig?: https.AgentOptions;
185
+ }): Promise<HttpResponse<T>>;
186
+ get<T>({
187
+ headers,
188
+ url,
189
+ queryParams,
190
+ maxRedirects,
191
+ cacheTTL,
192
+ context,
193
+ requestConfig
194
+ }: {
195
+ headers?: HttpHeaders;
196
+ url: string;
197
+ queryParams?: HttpQueryParams;
198
+ maxRedirects?: number;
199
+ cacheTTL?: number;
200
+ context?: RequestContext;
201
+ requestConfig?: RequestConfig;
202
+ }): Promise<HttpResponse<T>>;
203
+ post<P, T>({
204
+ headers,
205
+ url,
206
+ maxRedirects,
207
+ cacheTTL,
208
+ context,
209
+ payload,
210
+ requestConfig
211
+ }: {
212
+ headers?: HttpHeaders;
213
+ url: string;
214
+ maxRedirects?: number;
215
+ cacheTTL?: number;
216
+ context?: RequestContext;
217
+ payload?: P;
218
+ requestConfig?: RequestConfig;
219
+ }): Promise<HttpResponse<T>>;
220
+ }
221
+ interface OperationSetting {
222
+ url?: string;
223
+ query?: Record<string, string>;
224
+ config?: Partial<APIConfig>;
225
+ custom_settings?: Record<string, unknown>;
226
+ }
227
+ type OperationSettings = Record<string, OperationSetting>;
228
+ type AccountSettings = Record<string, string | number | boolean | object>;
229
+ type HttpClientBehaviour = 'CONCURRENCY' | 'RETRY';
230
+ type APIConfig = Record<string, unknown>;
231
+ type RequestContext = {
232
+ accountSecureId?: string;
233
+ projectSecureId?: string;
234
+ organizationId?: number;
235
+ environment?: string;
236
+ authConfigKey?: string;
237
+ provider?: string;
238
+ service?: string;
239
+ resource?: string;
240
+ subResource?: string;
241
+ childResource?: string;
242
+ operation?: string;
243
+ action?: string;
244
+ mode?: string;
245
+ testerUniqueToken?: string;
246
+ externalKey?: string;
247
+ dataKey?: string;
248
+ isDataSync?: boolean;
249
+ operationSettings?: OperationSettings;
250
+ accountSettings?: AccountSettings;
251
+ behaviours?: HttpClientBehaviour[];
252
+ };
253
+ //#endregion
254
+ //#region ../core/src/schema/types.d.ts
255
+ type Schema = {
256
+ name: string;
257
+ key: string;
258
+ version: string;
259
+ description?: string;
260
+ category: Category;
261
+ fields: {
262
+ [name: string]: SchemaField;
263
+ };
264
+ };
265
+ type SchemaField = {
266
+ name: string;
267
+ type: string;
268
+ required: boolean;
269
+ description?: string;
270
+ };
271
+ //#endregion
272
+ //#region ../core/src/stepFunctions/stepFunctionsList.d.ts
273
+ declare enum StepFunctionName {
274
+ TYPECAST = "typecast",
275
+ MAP_FIELDS = "map_fields",
276
+ GROUP_DATA = "group_data",
277
+ REQUEST = "request",
278
+ PAGINATED_REQUEST = "paginated_request",
279
+ }
280
+ //#endregion
281
+ //#region ../core/src/stepFunctions/types.d.ts
282
+ type StepFunction = ({
283
+ block,
284
+ params
285
+ }: {
286
+ block: Readonly<Block>;
287
+ params?: StepFunctionParams;
288
+ }) => Promise<StepFunctionOutput>;
289
+ type StepFunctionParams = {
290
+ [key: string]: unknown;
291
+ };
292
+ type StepFunctionMeta = {
293
+ functionName: StepFunctionName;
294
+ params?: StepFunctionParams;
295
+ version?: string;
296
+ };
297
+ type StepFunctionInstance = {
298
+ fn: StepFunction;
299
+ inputSchema?: ZodType;
300
+ outputSchema?: ZodType;
301
+ };
302
+ type StepFunctionOutput = {
303
+ block: Block;
304
+ successful: boolean;
305
+ errors?: StepError[];
306
+ output?: {
307
+ [name: string]: unknown;
308
+ };
309
+ };
310
+ //#endregion
311
+ //#region ../core/src/steps/types.d.ts
312
+ type StepSnapshot = {
313
+ output?: {
314
+ [name: string]: unknown;
315
+ };
316
+ successful: boolean;
317
+ skipped?: boolean;
318
+ message?: string;
319
+ errors?: StepError[];
320
+ };
321
+ type StepsSnapshots = {
322
+ [stepId: string]: StepSnapshot;
323
+ };
324
+ type StepError = {
325
+ [key: string]: unknown;
326
+ };
327
+ type Step = {
328
+ id: string;
329
+ description: string;
330
+ stepFunction: StepFunctionMeta;
331
+ ignoreError?: boolean;
332
+ async?: boolean;
333
+ successCriteria?: string;
334
+ condition?: string;
335
+ };
336
+ //#endregion
337
+ //#region ../core/src/connector/types.d.ts
338
+ type Connector = {
339
+ title: string;
340
+ version: string;
341
+ key: string;
342
+ assets: Assets;
343
+ description?: string;
344
+ categories?: Category[];
345
+ authentication?: Authentication;
346
+ operations?: {
347
+ [entrypointUrl: string]: Operation;
348
+ };
349
+ };
350
+ type Assets = {
351
+ icon: string;
352
+ };
353
+ type OperationType = 'list' | 'get' | 'create' | 'update' | 'delete' | 'custom' | 'refresh_token' | 'unknown';
354
+ type InputLocation = 'body' | 'query' | 'path' | 'headers';
355
+ type Input = {
356
+ name: string;
357
+ type: string;
358
+ required: boolean;
359
+ description: string;
360
+ in: InputLocation;
361
+ };
362
+ type Operation = {
363
+ id: string;
364
+ categories: Category[];
365
+ description: string;
366
+ schema?: Schema;
367
+ operationType: OperationType;
368
+ entrypointUrl?: string;
369
+ entrypointHttpMethod?: HttpMethod;
370
+ inputs?: Input[];
371
+ steps: {
372
+ [stepId: string]: Step;
373
+ };
374
+ result?: string | Record<string, unknown>;
375
+ responses: {
376
+ success: OperationResponse;
377
+ errors: Record<number, OperationResponse>;
378
+ };
379
+ cursor: {
380
+ enabled: boolean;
381
+ pageSize: number;
382
+ };
383
+ compositeIdentifiers: CompositeIdentifierConnectorConfig;
384
+ scheduledJobs?: ScheduledJobConfig[];
385
+ };
386
+ type ScheduledJobConfig = {
387
+ enabled: boolean;
388
+ type: ScheduledJobType;
389
+ schedule: string;
390
+ description: string;
391
+ requestParams?: ScheduledJobRequestParams;
392
+ syncFilter?: SyncFilterConfig;
393
+ };
394
+ type ScheduledJobRequestParams = {
395
+ fields?: string[];
396
+ expand?: string[];
397
+ filter?: Record<string, string>;
398
+ };
399
+ type ScheduledJobType = 'data_sync';
400
+ type SyncFilterName = 'updated_after' | 'created_after';
401
+ type SyncFilterConfig = {
402
+ name: SyncFilterName;
403
+ initialLoopbackPeriod: string;
404
+ incrementalLoopbackPeriod: string;
405
+ };
406
+ type OperationResponse = {
407
+ statusCode: number;
408
+ description?: string;
409
+ };
410
+ type AuthenticationField = {
411
+ key: string;
412
+ label: string;
413
+ type: 'text' | 'password' | 'select';
414
+ options?: {
415
+ value: string;
416
+ label: string;
417
+ }[];
418
+ required: boolean;
419
+ secret: boolean;
420
+ readOnly: boolean;
421
+ placeholder?: string;
422
+ description?: string;
423
+ tooltip?: string;
424
+ };
425
+ type SupportConfig = {
426
+ link: string;
427
+ description?: string;
428
+ };
429
+ type AuthenticationConfig = {
430
+ envKey: string;
431
+ envName: string;
432
+ type: 'custom' | 'oauth2';
433
+ label: string;
434
+ authorization: {
435
+ type: 'basic' | 'bearer' | 'oauth2';
436
+ [authParam: string]: unknown;
437
+ };
438
+ support?: SupportConfig;
439
+ configFields?: AuthenticationField[];
440
+ setupFields?: AuthenticationField[];
441
+ refreshAuthentication?: {
442
+ schedule?: string;
443
+ operation: Operation;
444
+ };
445
+ testOperationsIds?: string[];
446
+ };
447
+ type Authentication = {
448
+ [authType: string]: {
449
+ production: AuthenticationConfig;
450
+ [envKey: string]: AuthenticationConfig;
451
+ };
452
+ };
453
+ //#endregion
454
+ //#region ../core/src/blocks/types.d.ts
455
+ type Block = {
456
+ inputs?: {
457
+ [key: string]: unknown;
458
+ };
459
+ connector?: Connector;
460
+ context: BlockContext;
461
+ debug?: DebugParams;
462
+ steps?: StepsSnapshots;
463
+ httpClient?: IHttpClient;
464
+ logger?: ILogger;
465
+ operation?: Operation;
466
+ credentials?: Credentials;
467
+ outputs?: unknown;
468
+ nextCursor?: Cursor | null;
469
+ response?: {
470
+ statusCode: number;
471
+ successful: boolean;
472
+ message?: string;
473
+ };
474
+ fieldConfigs?: FieldConfig[];
475
+ result?: BlockIndexedRecord[] | BlockIndexedRecord;
476
+ };
477
+ type BlockContext = {
478
+ projectSecureId: string;
479
+ accountSecureId: string;
480
+ connectorKey: string;
481
+ connectorVersion: string;
482
+ category: Category;
483
+ schema?: string;
484
+ operationType: OperationType;
485
+ authenticationType: string;
486
+ environment: string;
487
+ service: string;
488
+ resource: string;
489
+ subResource?: string;
490
+ childResource?: string;
491
+ };
492
+ type BlockIndexedRecord = {
493
+ id: string;
494
+ remote_id?: string;
495
+ [key: string]: unknown;
496
+ unified_custom_fields?: {
497
+ [key: string]: unknown;
498
+ };
499
+ };
500
+ type EnumMatcherExpression = {
501
+ matchExpression: string;
502
+ value: string;
503
+ };
504
+ type FieldConfig = {
505
+ expression?: string;
506
+ targetFieldKey: string;
507
+ alias?: string;
508
+ type: string;
509
+ custom: boolean;
510
+ hidden: boolean;
511
+ enumMapper?: {
512
+ matcher: string | EnumMatcherExpression[];
513
+ };
514
+ };
515
+ type DebugParams = {
516
+ custom_mappings?: 'disabled' | 'enabled';
517
+ };
518
+ type Credentials = Record<string, unknown>;
519
+ //#endregion
520
+ //#region ../core/src/stepFunctions/factory.d.ts
521
+ declare const StepFunctionsFactory: {
522
+ build({
523
+ functionName,
524
+ version,
525
+ validateSchemas,
526
+ stepFunctionsList
527
+ }: {
528
+ functionName: StepFunctionName;
529
+ version?: string;
530
+ validateSchemas?: boolean;
531
+ stepFunctionsList?: Record<string, Record<string, StepFunctionInstance>>;
532
+ }): StepFunctionInstance;
533
+ };
534
+ //#endregion
535
+ //#region ../core/src/accounts/types.d.ts
536
+ type Account = {
537
+ providerKey: string;
538
+ providerVersion: string;
539
+ authConfigKey: string;
540
+ environment: string;
541
+ organizationId: number;
542
+ secureId: string;
543
+ credentials?: Record<string, unknown>;
544
+ projectSecureId: string;
545
+ };
546
+ //#endregion
5
547
  //#region src/blocks/createBlock.d.ts
6
548
  declare const createBlock: ({
7
549
  inputs,
@@ -21,6 +563,9 @@ declare const createBlock: ({
21
563
  getHttpClient?: () => Promise<IHttpClient>;
22
564
  }) => Promise<Block>;
23
565
  //#endregion
566
+ //#region src/connectors/fileReader.d.ts
567
+ declare const loadConnector: (filePath: string) => string;
568
+ //#endregion
24
569
  //#region src/connectors/operations.d.ts
25
570
  declare const getOperationFromUrl: (connector: Connector, url: string, method: HttpMethod) => {
26
571
  operation: Operation;
@@ -153,4 +698,4 @@ declare const runConnectorOperation: ({
153
698
  runStepOperationFn?: typeof runStepOperation;
154
699
  }) => Promise<Block>;
155
700
  //#endregion
156
- export { ConnectSDKError, ErrorType, createBlock, executeStepFunction, getOperationFromUrl, parseOperationInputs, parseYamlConnector, runConnectorOperation, runStepOperation, validateYamlConnector };
701
+ export { ConnectSDKError, type ErrorType, createBlock, executeStepFunction, getOperationFromUrl, loadConnector, parseOperationInputs, parseYamlConnector, runConnectorOperation, runStepOperation, validateYamlConnector };