@skedulo/pulse-solution-services 0.0.7 → 0.0.8
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/CHANGELOG.md +8 -0
- package/README.md +96 -23
- package/dist/clients/artifact-client.js +1 -1
- package/dist/clients/base-client.js +1 -1
- package/dist/clients/graphql-client.js +1 -1
- package/dist/constants/graphql-constants.js +1 -0
- package/dist/constants/index.js +1 -1
- package/dist/core/execution-context.js +1 -1
- package/dist/core/execution-options.js +1 -0
- package/dist/core/index.js +1 -1
- package/dist/core/request-context.js +1 -0
- package/dist/core/request-header-constants.js +1 -0
- package/dist/index.d.ts +240 -108
- package/dist/interfaces/api-client.js +1 -0
- package/dist/interfaces/index.js +1 -1
- package/dist/services/batch-processor/fetching-strategies/cursor-based-fetching-strategy.js +1 -1
- package/dist/services/batch-processor/fetching-strategies/date-based-fetching-strategy.js +1 -1
- package/dist/services/graph-batch/graph-batch-config.d.ts +34 -0
- package/dist/services/graph-batch/graph-batch-config.js +1 -0
- package/dist/services/graph-batch/graph-batch.d.ts +56 -0
- package/dist/services/graph-batch/graph-batch.js +1 -0
- package/dist/services/graph-batch/index.d.ts +3 -0
- package/dist/services/graph-batch/index.js +1 -0
- package/dist/services/graph-batch/pagination-strategy.d.ts +5 -0
- package/dist/services/graph-batch/pagination-strategy.js +1 -0
- package/dist/services/graphql/graphql-query-builder.d.ts +6 -4
- package/dist/services/graphql/graphql-query-builder.js +1 -1
- package/dist/services/graphql/graphql-service.d.ts +20 -13
- package/dist/services/graphql/graphql-service.js +1 -1
- package/dist/services/graphql/queries.d.ts +5 -4
- package/dist/services/graphql/queries.js +1 -1
- package/dist/services/index.js +1 -1
- package/dist/services/resource-availability/builder/data-service.d.ts +2 -1
- package/dist/services/resource-availability/builder/data-service.js +1 -1
- package/package.json +4 -2
- package/yarn.lock +23 -0
- package/dist/constants/tenant-objects.js +0 -1
- package/dist/services/data-service.js +0 -1
- package/dist/services/resource-availability/object-factory.d.ts +0 -13
- package/dist/services/resource-availability/object-factory.js +0 -1
- package/dist/services/resource-availability/resource-availability-service.d.ts +0 -7
- package/dist/services/resource-availability/resource-availability-service.js +0 -1
- package/dist/services/resource-availability/resource-builder.d.ts +0 -16
- package/dist/services/resource-availability/resource-builder.js +0 -1
- package/dist/services/resource-availability/resource-query-service.d.ts +0 -7
- package/dist/services/resource-availability/resource-query-service.js +0 -1
- package/dist/services/resource-availability/resource-validator.d.ts +0 -29
- package/dist/services/resource-availability/resource-validator.js +0 -1
- /package/dist/{interfaces/resource-availability.js → core/base-config.js} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
// Generated by dts-bundle-generator v9.5.1
|
|
2
2
|
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
6
|
* Interface representing the structure of metadata for an object.
|
|
5
7
|
*/
|
|
@@ -50,40 +52,49 @@ export interface PicklistValue {
|
|
|
50
52
|
active: boolean;
|
|
51
53
|
defaultValue: boolean;
|
|
52
54
|
}
|
|
53
|
-
/**
|
|
54
|
-
* Interface defining the base configuration for API clients.
|
|
55
|
-
*/
|
|
56
55
|
export interface BaseConfig {
|
|
57
56
|
apiServer: string;
|
|
58
57
|
apiToken: string;
|
|
59
58
|
internalApiToken?: string;
|
|
60
59
|
}
|
|
60
|
+
declare class ExecutionOptions {
|
|
61
|
+
/**
|
|
62
|
+
* Identifies the origin of the request (e.g., the system, application, or project that initiated the call).
|
|
63
|
+
* Helps in tracking and debugging requests across different systems.
|
|
64
|
+
*/
|
|
65
|
+
requestSource?: string;
|
|
66
|
+
/**
|
|
67
|
+
* Identifies the client service or Lambda function making the request.
|
|
68
|
+
* Useful for debugging and log filtering to trace which service handled the request.
|
|
69
|
+
*/
|
|
70
|
+
userAgent?: string;
|
|
71
|
+
/**
|
|
72
|
+
* Creates an instance of ExecutionOptions.
|
|
73
|
+
* Allows initializing with partial values for flexibility.
|
|
74
|
+
*
|
|
75
|
+
* @param initialValues - Partial execution options for initialization.
|
|
76
|
+
*/
|
|
77
|
+
constructor(initialValues?: Partial<ExecutionOptions>);
|
|
78
|
+
}
|
|
79
|
+
export interface RequestParams {
|
|
80
|
+
method?: string;
|
|
81
|
+
endpoint: string;
|
|
82
|
+
body?: object;
|
|
83
|
+
headers?: Record<string, string>;
|
|
84
|
+
queryParams?: Record<string, string>;
|
|
85
|
+
}
|
|
61
86
|
/**
|
|
62
87
|
* Base client for making API requests with standardized error handling.
|
|
63
88
|
* Provides methods for setting up headers and performing API requests using fetch.
|
|
64
89
|
*/
|
|
65
90
|
export declare class BaseClient {
|
|
66
91
|
protected config: BaseConfig;
|
|
92
|
+
protected executionOptions: Partial<ExecutionOptions>;
|
|
67
93
|
/**
|
|
68
94
|
* Creates an instance of BaseClient.
|
|
69
95
|
* @param {BaseConfig} config - The configuration object containing API server and token.
|
|
70
96
|
*/
|
|
71
|
-
constructor(config: BaseConfig);
|
|
72
|
-
/**
|
|
73
|
-
* Constructs the headers for API requests.
|
|
74
|
-
* @returns {Record<string, string>} - The headers including authorization and content type.
|
|
75
|
-
*/
|
|
76
|
-
protected getHeaders(): {
|
|
77
|
-
Authorization: string;
|
|
78
|
-
"Content-Type": string;
|
|
79
|
-
};
|
|
80
|
-
/**
|
|
81
|
-
* Builds a URL with query parameters.
|
|
82
|
-
* @param {string} endpoint - The API endpoint.
|
|
83
|
-
* @param {Record<string, string>} [queryParams] - Optional query parameters.
|
|
84
|
-
* @returns {string} - The full URL with query parameters.
|
|
85
|
-
*/
|
|
86
|
-
private buildUrl;
|
|
97
|
+
constructor(config: BaseConfig, executionOptions?: Partial<ExecutionOptions>);
|
|
87
98
|
/**
|
|
88
99
|
* Performs an API request with standardized error handling using fetch.
|
|
89
100
|
* @template T
|
|
@@ -96,13 +107,19 @@ export declare class BaseClient {
|
|
|
96
107
|
* @returns {Promise<T>} - The parsed response data.
|
|
97
108
|
* @throws {Error} - If the request fails or the response is not OK.
|
|
98
109
|
*/
|
|
99
|
-
protected performRequest<T = any>({ method, endpoint, headers, body, queryParams
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
110
|
+
protected performRequest<T = any>({ method, endpoint, headers, body, queryParams }: RequestParams, executionOptions?: Partial<ExecutionOptions>): Promise<T>;
|
|
111
|
+
/**
|
|
112
|
+
* Constructs the headers for API requests.
|
|
113
|
+
* @returns {Record<string, string>} - The headers including authorization and content type.
|
|
114
|
+
*/
|
|
115
|
+
protected getHeaders(executionOptions: Partial<ExecutionOptions>): Record<string, string>;
|
|
116
|
+
/**
|
|
117
|
+
* Builds a URL with query parameters.
|
|
118
|
+
* @param {string} endpoint - The API endpoint.
|
|
119
|
+
* @param {Record<string, string>} [queryParams] - Optional query parameters.
|
|
120
|
+
* @returns {string} - The full URL with query parameters.
|
|
121
|
+
*/
|
|
122
|
+
private buildUrl;
|
|
106
123
|
/**
|
|
107
124
|
* Handles exceptions encountered during API requests.
|
|
108
125
|
* @param {any} error - The error to handle.
|
|
@@ -243,67 +260,6 @@ export declare class ConfigVarClient extends BaseClient {
|
|
|
243
260
|
*/
|
|
244
261
|
delete(key: string): Promise<string>;
|
|
245
262
|
}
|
|
246
|
-
export interface HasId {
|
|
247
|
-
UID?: string;
|
|
248
|
-
[key: string]: any;
|
|
249
|
-
}
|
|
250
|
-
export interface GraphQlResponse<T = any> {
|
|
251
|
-
data: T;
|
|
252
|
-
errors?: object[];
|
|
253
|
-
}
|
|
254
|
-
export interface FetchRecordsQueryParams {
|
|
255
|
-
objectName: string;
|
|
256
|
-
first?: number;
|
|
257
|
-
offset?: number;
|
|
258
|
-
orderBy?: string;
|
|
259
|
-
filter?: string;
|
|
260
|
-
after?: string;
|
|
261
|
-
fields?: string;
|
|
262
|
-
}
|
|
263
|
-
export interface QueryResult {
|
|
264
|
-
records: HasId[];
|
|
265
|
-
totalCount: number;
|
|
266
|
-
pageInfo: any;
|
|
267
|
-
endCursor: string;
|
|
268
|
-
endOffset: number;
|
|
269
|
-
}
|
|
270
|
-
export interface MutationResult {
|
|
271
|
-
data: {
|
|
272
|
-
schema: {
|
|
273
|
-
[alias: string]: string;
|
|
274
|
-
};
|
|
275
|
-
};
|
|
276
|
-
}
|
|
277
|
-
/**
|
|
278
|
-
* A client for executing GraphQL queries and mutations.
|
|
279
|
-
* Extends the BaseClient to interact with the GraphQL API.
|
|
280
|
-
*/
|
|
281
|
-
export declare class GraphQLClient extends BaseClient {
|
|
282
|
-
/**
|
|
283
|
-
* Executes a GraphQL query or mutation.
|
|
284
|
-
* @param {string} graphqlQuery - The GraphQL query or mutation string.
|
|
285
|
-
* @returns {Promise<GraphQlResponse>} - The response from the GraphQL API.
|
|
286
|
-
* @throws {Error} - If the request fails or if there are errors in the response.
|
|
287
|
-
*/
|
|
288
|
-
execute(graphqlQuery: string): Promise<GraphQlResponse>;
|
|
289
|
-
}
|
|
290
|
-
/**
|
|
291
|
-
* OrgPreferencesClient class to handle API requests related to organization preferences.
|
|
292
|
-
* Extends BaseClient to perform API operations.
|
|
293
|
-
*/
|
|
294
|
-
export declare class OrgPreferenceClient extends BaseClient {
|
|
295
|
-
/**
|
|
296
|
-
* Fetches the organization preferences configuration.
|
|
297
|
-
* @returns {Promise<Record<string, any>>} - A promise resolving to the sorted organization preferences.
|
|
298
|
-
*/
|
|
299
|
-
get(): Promise<Record<string, any>>;
|
|
300
|
-
/**
|
|
301
|
-
* Deploys the organization preferences configuration.
|
|
302
|
-
* @param {Record<string, any>} newConfig - The new configuration to be deployed.
|
|
303
|
-
* @returns {Promise<Record<string, any>>} - A promise resolving when the configuration is successfully deployed.
|
|
304
|
-
*/
|
|
305
|
-
deploy(newConfig: Record<string, any>): Promise<Record<string, any>>;
|
|
306
|
-
}
|
|
307
263
|
export declare enum ArtifactType {
|
|
308
264
|
CUSTOM_OBJECT = "custom-object",
|
|
309
265
|
CUSTOM_FIELD = "custom-field",
|
|
@@ -335,6 +291,12 @@ export declare enum ConfigVariableStatus {
|
|
|
335
291
|
INACTIVE = "inactive",
|
|
336
292
|
EXPIRED = "expired"
|
|
337
293
|
}
|
|
294
|
+
export declare enum GraphqlOperations {
|
|
295
|
+
INSERT = "insert",
|
|
296
|
+
UPDATE = "update",
|
|
297
|
+
DELETE = "delete",
|
|
298
|
+
UPSERT = "upsert"
|
|
299
|
+
}
|
|
338
300
|
export declare enum HttpMethod {
|
|
339
301
|
GET = "GET",
|
|
340
302
|
POST = "POST",
|
|
@@ -408,6 +370,77 @@ export declare const TENANT_ENDPOINTS: {
|
|
|
408
370
|
readonly SIMPLE: "availability/simple";
|
|
409
371
|
};
|
|
410
372
|
};
|
|
373
|
+
export interface HasId {
|
|
374
|
+
UID?: string;
|
|
375
|
+
[key: string]: any;
|
|
376
|
+
}
|
|
377
|
+
export interface GraphQlResponse<T = any> {
|
|
378
|
+
data: T;
|
|
379
|
+
errors?: object[];
|
|
380
|
+
}
|
|
381
|
+
export interface GraphqlParams {
|
|
382
|
+
objectName: string;
|
|
383
|
+
operationName: string;
|
|
384
|
+
}
|
|
385
|
+
export interface GraphqlMurationParams extends GraphqlParams {
|
|
386
|
+
records: HasId[];
|
|
387
|
+
operation: GraphqlOperations;
|
|
388
|
+
bulkOperation?: boolean;
|
|
389
|
+
}
|
|
390
|
+
export interface GraphqlQueryParams extends GraphqlParams {
|
|
391
|
+
first?: number;
|
|
392
|
+
offset?: number;
|
|
393
|
+
orderBy?: string;
|
|
394
|
+
filter?: string;
|
|
395
|
+
after?: string;
|
|
396
|
+
fields?: string;
|
|
397
|
+
readOnly?: boolean;
|
|
398
|
+
}
|
|
399
|
+
export interface QueryResult {
|
|
400
|
+
records: HasId[];
|
|
401
|
+
totalCount: number;
|
|
402
|
+
pageInfo: any;
|
|
403
|
+
endCursor: string;
|
|
404
|
+
endOffset: number;
|
|
405
|
+
}
|
|
406
|
+
export interface MutationResult {
|
|
407
|
+
data: {
|
|
408
|
+
schema: {
|
|
409
|
+
[alias: string]: string;
|
|
410
|
+
};
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
/**
|
|
414
|
+
* A client for executing GraphQL queries and mutations.
|
|
415
|
+
* Extends the BaseClient to interact with the GraphQL API.
|
|
416
|
+
*/
|
|
417
|
+
export declare class GraphQLClient extends BaseClient {
|
|
418
|
+
/**
|
|
419
|
+
* Executes a GraphQL query or mutation.
|
|
420
|
+
* @param {string} graphqlQuery - The GraphQL query or mutation string.
|
|
421
|
+
* @param {Record<string, string>} headers - Additional headers to include in the request.
|
|
422
|
+
* @returns {Promise<GraphQlResponse>} - The response from the GraphQL API.
|
|
423
|
+
* @throws {Error} - If the request fails or if there are errors in the response.
|
|
424
|
+
*/
|
|
425
|
+
execute(graphqlQuery: string, headers?: Record<string, string>): Promise<GraphQlResponse>;
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* OrgPreferencesClient class to handle API requests related to organization preferences.
|
|
429
|
+
* Extends BaseClient to perform API operations.
|
|
430
|
+
*/
|
|
431
|
+
export declare class OrgPreferenceClient extends BaseClient {
|
|
432
|
+
/**
|
|
433
|
+
* Fetches the organization preferences configuration.
|
|
434
|
+
* @returns {Promise<Record<string, any>>} - A promise resolving to the sorted organization preferences.
|
|
435
|
+
*/
|
|
436
|
+
get(): Promise<Record<string, any>>;
|
|
437
|
+
/**
|
|
438
|
+
* Deploys the organization preferences configuration.
|
|
439
|
+
* @param {Record<string, any>} newConfig - The new configuration to be deployed.
|
|
440
|
+
* @returns {Promise<Record<string, any>>} - A promise resolving when the configuration is successfully deployed.
|
|
441
|
+
*/
|
|
442
|
+
deploy(newConfig: Record<string, any>): Promise<Record<string, any>>;
|
|
443
|
+
}
|
|
411
444
|
export interface LatLng {
|
|
412
445
|
lat: number;
|
|
413
446
|
lng: number;
|
|
@@ -589,7 +622,7 @@ export type ArtifactParams = {
|
|
|
589
622
|
declare class ArtifactClient extends BaseClient {
|
|
590
623
|
private artifactType;
|
|
591
624
|
private baseEndpoint;
|
|
592
|
-
constructor(config: any, artifactType: ArtifactType);
|
|
625
|
+
constructor(config: any, artifactType: ArtifactType, executionOptions?: Partial<ExecutionOptions>);
|
|
593
626
|
list<T>(): Promise<T[]>;
|
|
594
627
|
get<T>(params?: ArtifactParams): Promise<T>;
|
|
595
628
|
create<T>(params: ArtifactParams, artifactData: Partial<T>): Promise<T>;
|
|
@@ -943,43 +976,51 @@ export declare class GraphQLService {
|
|
|
943
976
|
constructor(client: GraphQLClient);
|
|
944
977
|
/**
|
|
945
978
|
* Executes a GraphQL query to fetch records.
|
|
946
|
-
* @param {
|
|
979
|
+
* @param {GraphqlQueryParams} params - The query parameters.
|
|
947
980
|
* @returns {Promise<QueryResult>} - The query result including records, total count, page info, and cursors.
|
|
948
981
|
*/
|
|
949
|
-
query(params:
|
|
982
|
+
query(params: GraphqlQueryParams): Promise<QueryResult>;
|
|
950
983
|
/**
|
|
951
|
-
*
|
|
984
|
+
* Performs a mutation operation on the GraphQL API.
|
|
952
985
|
* @param {string} objectName - The name of the object.
|
|
953
986
|
* @param {HasId[]} records - The records to delete.
|
|
954
987
|
* @returns {Promise<any>} - The response from the delete operation.
|
|
955
988
|
*/
|
|
956
|
-
|
|
989
|
+
mutate(params: GraphqlMurationParams): Promise<any>;
|
|
990
|
+
/**
|
|
991
|
+
* Deletes records from the GraphQL API.
|
|
992
|
+
*/
|
|
993
|
+
delete(params: GraphqlMurationParams): Promise<any>;
|
|
957
994
|
/**
|
|
958
995
|
* Updates records in the GraphQL API.
|
|
959
|
-
* @param {string} objectName - The name of the object.
|
|
960
|
-
* @param {HasId[]} records - The records to update.
|
|
961
|
-
* @returns {Promise<any>} - The response from the update operation.
|
|
962
996
|
*/
|
|
963
|
-
update(
|
|
997
|
+
update(params: GraphqlMurationParams): Promise<any>;
|
|
964
998
|
/**
|
|
965
999
|
* Inserts records into the GraphQL API.
|
|
966
|
-
* @param {string} objectName - The name of the object.
|
|
967
|
-
* @param {HasId[]} records - The records to insert.
|
|
968
|
-
* @returns {Promise<any>} - The response from the insert operation.
|
|
969
1000
|
*/
|
|
970
|
-
insert(
|
|
1001
|
+
insert(params: GraphqlMurationParams): Promise<any>;
|
|
971
1002
|
/**
|
|
972
1003
|
* Extracts job UIDs from a GraphQL mutation response.
|
|
973
1004
|
* @param {MutationResult} response - The response object.
|
|
974
1005
|
* @returns {string[]} - An array of job UIDs.
|
|
975
1006
|
*/
|
|
976
1007
|
extractJobUIDs(response: MutationResult): string[];
|
|
1008
|
+
/**
|
|
1009
|
+
* Formats the object name to follow GraphQL naming conventions.
|
|
1010
|
+
* @param {string} objectName - The object name to format.
|
|
1011
|
+
* @returns {string} - The formatted object name.
|
|
1012
|
+
*/
|
|
1013
|
+
private getQueryName;
|
|
1014
|
+
private getQueryHeaders;
|
|
1015
|
+
private getMutationHeaders;
|
|
1016
|
+
private getOperationHeader;
|
|
977
1017
|
}
|
|
978
1018
|
/**
|
|
979
1019
|
* A utility class for building GraphQL queries dynamically.
|
|
980
1020
|
*/
|
|
981
1021
|
export declare class GraphQLQueryBuilder {
|
|
982
1022
|
private objectName;
|
|
1023
|
+
operationName: string;
|
|
983
1024
|
private fields;
|
|
984
1025
|
private filters;
|
|
985
1026
|
private first?;
|
|
@@ -990,12 +1031,13 @@ export declare class GraphQLQueryBuilder {
|
|
|
990
1031
|
private childQueries;
|
|
991
1032
|
private isParent;
|
|
992
1033
|
private graphqlService;
|
|
1034
|
+
private queryParams;
|
|
993
1035
|
/**
|
|
994
1036
|
* Creates an instance of GraphQLQueryBuilder.
|
|
995
|
-
* @param {string}
|
|
1037
|
+
* @param {string} graphqlQueryParams - The necessary parameters for the query.
|
|
996
1038
|
* @param {boolean} [isParent=false] - Indicates if this query is a parent query.
|
|
997
1039
|
*/
|
|
998
|
-
constructor(
|
|
1040
|
+
constructor(queryParams: GraphqlQueryParams, isParent?: boolean);
|
|
999
1041
|
/**
|
|
1000
1042
|
* Sets the GraphQL service to use for executing the query.
|
|
1001
1043
|
*/
|
|
@@ -1039,7 +1081,7 @@ export declare class GraphQLQueryBuilder {
|
|
|
1039
1081
|
/**
|
|
1040
1082
|
* Builds the GraphQL query parameters in a more structured format.
|
|
1041
1083
|
*/
|
|
1042
|
-
build():
|
|
1084
|
+
build(): GraphqlQueryParams;
|
|
1043
1085
|
/**
|
|
1044
1086
|
* Executes the query using the GraphQL service, with improved error handling.
|
|
1045
1087
|
*/
|
|
@@ -1077,7 +1119,7 @@ declare class DataService {
|
|
|
1077
1119
|
constructor(graphqlService: GraphQLService);
|
|
1078
1120
|
getResources(param: ResourceQueryParam): Promise<Record<string, any>[]>;
|
|
1079
1121
|
getHolidays(regionIds: string[], startTime?: Date, endTime?: Date): Promise<Record<string, any>>;
|
|
1080
|
-
newQueryBuilder(
|
|
1122
|
+
newQueryBuilder(params: GraphqlQueryParams): GraphQLQueryBuilder;
|
|
1081
1123
|
}
|
|
1082
1124
|
export declare class ResourceAvailabilityService {
|
|
1083
1125
|
private availabilityAPIClient;
|
|
@@ -1154,14 +1196,18 @@ export declare class ExecutionContext {
|
|
|
1154
1196
|
private baseConfig;
|
|
1155
1197
|
logger: typeof logger;
|
|
1156
1198
|
private services;
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
static
|
|
1199
|
+
private _executionOptions;
|
|
1200
|
+
protected constructor(skedContext: any, executionOptions?: Partial<ExecutionOptions>);
|
|
1201
|
+
static fromContext(skedContext: any, executionOptions?: Partial<ExecutionOptions>): ExecutionContext;
|
|
1202
|
+
static fromCredentials(config: BaseConfig, executionOptions?: Partial<ExecutionOptions>): ExecutionContext;
|
|
1203
|
+
set executionOptions(executionOptions: Partial<ExecutionOptions>);
|
|
1204
|
+
get executionOptions(): Partial<ExecutionOptions>;
|
|
1160
1205
|
/**
|
|
1161
1206
|
* Generic method to retrieve or initialize a service.
|
|
1162
1207
|
*/
|
|
1163
1208
|
private getOrCreateService;
|
|
1164
1209
|
get configHelper(): ConfigHelper;
|
|
1210
|
+
get baseClient(): BaseClient;
|
|
1165
1211
|
get graphqlClient(): GraphQLClient;
|
|
1166
1212
|
get graphqlService(): GraphQLService;
|
|
1167
1213
|
get metadataClient(): MetadataClient;
|
|
@@ -1180,10 +1226,11 @@ export declare class ExecutionContext {
|
|
|
1180
1226
|
get resourceAvailabilityService(): ResourceAvailabilityService;
|
|
1181
1227
|
get dataService(): DataService;
|
|
1182
1228
|
get resourceBuilder(): ResourceBuilder;
|
|
1183
|
-
newQueryBuilder(
|
|
1229
|
+
newQueryBuilder(params: GraphqlQueryParams): GraphQLQueryBuilder;
|
|
1184
1230
|
newArtifactClient(artifactType: ArtifactType): ArtifactClient;
|
|
1185
1231
|
dispose(): void;
|
|
1186
1232
|
}
|
|
1233
|
+
export declare const REQUEST_HEADERS: Record<string, string>;
|
|
1187
1234
|
export declare const TenantObjects: {
|
|
1188
1235
|
Accounts: {
|
|
1189
1236
|
Name: string;
|
|
@@ -1297,6 +1344,91 @@ export declare class BatchOrchestrator {
|
|
|
1297
1344
|
protected updateJobStatus(): Promise<void>;
|
|
1298
1345
|
private isCompleted;
|
|
1299
1346
|
}
|
|
1347
|
+
export declare enum PaginationStrategy {
|
|
1348
|
+
CURSOR = "cursor",
|
|
1349
|
+
OFFSET = "offset",
|
|
1350
|
+
NONE = "none"
|
|
1351
|
+
}
|
|
1352
|
+
/**
|
|
1353
|
+
* Default configuration values for `GraphBatchConfig`.
|
|
1354
|
+
*/
|
|
1355
|
+
export declare const DEFAULT_GRAPH_BATCH_CONFIG: GraphBatchConfig;
|
|
1356
|
+
declare const GraphBatchConfigSchema: z.ZodObject<{
|
|
1357
|
+
strategy: z.ZodNativeEnum<typeof PaginationStrategy>;
|
|
1358
|
+
batchSize: z.ZodDefault<z.ZodNumber>;
|
|
1359
|
+
maxBatches: z.ZodDefault<z.ZodNumber>;
|
|
1360
|
+
delaySeconds: z.ZodDefault<z.ZodNumber>;
|
|
1361
|
+
}, "strip", z.ZodTypeAny, {
|
|
1362
|
+
strategy: PaginationStrategy;
|
|
1363
|
+
batchSize: number;
|
|
1364
|
+
maxBatches: number;
|
|
1365
|
+
delaySeconds: number;
|
|
1366
|
+
}, {
|
|
1367
|
+
strategy: PaginationStrategy;
|
|
1368
|
+
batchSize?: number | undefined;
|
|
1369
|
+
maxBatches?: number | undefined;
|
|
1370
|
+
delaySeconds?: number | undefined;
|
|
1371
|
+
}>;
|
|
1372
|
+
/**
|
|
1373
|
+
* Configuration options for `GraphBatch`.
|
|
1374
|
+
*/
|
|
1375
|
+
export type GraphBatchConfig = z.infer<typeof GraphBatchConfigSchema>;
|
|
1376
|
+
/**
|
|
1377
|
+
* Merges user-provided config with default values.
|
|
1378
|
+
*/
|
|
1379
|
+
export declare function initializeConfig(config: Partial<GraphBatchConfig> | undefined): GraphBatchConfig;
|
|
1380
|
+
/**
|
|
1381
|
+
* Base class for batch processing with pagination support.
|
|
1382
|
+
*/
|
|
1383
|
+
export declare abstract class GraphBatch {
|
|
1384
|
+
protected context: ExecutionContext;
|
|
1385
|
+
protected config: GraphBatchConfig;
|
|
1386
|
+
protected queryBuilder?: GraphQLQueryBuilder;
|
|
1387
|
+
protected queryResult?: QueryResult;
|
|
1388
|
+
private startTime;
|
|
1389
|
+
constructor(context: ExecutionContext, config?: Partial<GraphBatchConfig>);
|
|
1390
|
+
/**
|
|
1391
|
+
* Runs the batch process, handling pagination, execution, and accumulation of results.
|
|
1392
|
+
*
|
|
1393
|
+
* @returns The accumulated result of the batch process.
|
|
1394
|
+
*/
|
|
1395
|
+
run(): Promise<void>;
|
|
1396
|
+
/**
|
|
1397
|
+
* Initializes the query builder. This method must be overridden in subclasses.
|
|
1398
|
+
*
|
|
1399
|
+
* @returns A configured GraphQL query builder.
|
|
1400
|
+
*/
|
|
1401
|
+
protected abstract start(): Promise<GraphQLQueryBuilder>;
|
|
1402
|
+
/**
|
|
1403
|
+
* Processes a batch of records and accumulates the result.
|
|
1404
|
+
*
|
|
1405
|
+
* @param records The batch of records retrieved from the query.
|
|
1406
|
+
*/
|
|
1407
|
+
protected abstract execute(records: any[]): Promise<void>;
|
|
1408
|
+
/**
|
|
1409
|
+
* Final cleanup or logging after the batch process completes.
|
|
1410
|
+
*/
|
|
1411
|
+
protected finish(): Promise<void>;
|
|
1412
|
+
/**
|
|
1413
|
+
* Fetches the next page of data based on the pagination strategy.
|
|
1414
|
+
*
|
|
1415
|
+
* @returns The result of the query execution.
|
|
1416
|
+
*/
|
|
1417
|
+
protected fetchNextPage(): Promise<QueryResult>;
|
|
1418
|
+
/**
|
|
1419
|
+
* Checks if the maximum number of batches has been reached.
|
|
1420
|
+
*
|
|
1421
|
+
* @param currentBatchCount The number of batches processed so far.
|
|
1422
|
+
* @returns `true` if the maximum limit is reached, otherwise `false`.
|
|
1423
|
+
*/
|
|
1424
|
+
protected isMaxBatchesReached(currentBatchCount: number): boolean;
|
|
1425
|
+
/**
|
|
1426
|
+
* Delays execution for a specified time.
|
|
1427
|
+
*
|
|
1428
|
+
* @param ms The time in milliseconds to delay.
|
|
1429
|
+
*/
|
|
1430
|
+
protected delay(ms: number): Promise<void>;
|
|
1431
|
+
}
|
|
1300
1432
|
export interface ResourceValidationOption {
|
|
1301
1433
|
checkAvailability: boolean;
|
|
1302
1434
|
checkConflict: boolean;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});
|
package/dist/interfaces/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,r,t,i){void 0===i&&(i=t);var o=Object.getOwnPropertyDescriptor(r,t);o&&!("get"in o?!r.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return r[t]}}),Object.defineProperty(e,i,o)}:function(e,r,t,i){void 0===i&&(i=t),e[i]=r[t]}),__exportStar=this&&this.__exportStar||function(e,r){for(var t in e)"default"===t||Object.prototype.hasOwnProperty.call(r,t)||__createBinding(r,e,t)};Object.defineProperty(exports,"__esModule",{value:!0}),__exportStar(require("../core/tenant-entities"),exports),__exportStar(require("./availability"),exports),__exportStar(require("./config-template"),exports),__exportStar(require("./config-var"),exports),__exportStar(require("./geoservice-interfaces"),exports),__exportStar(require("./graphql"),exports),__exportStar(require("./metadata"),exports),__exportStar(require("./mobile-notification"),exports);
|
|
1
|
+
"use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,r,t,i){void 0===i&&(i=t);var o=Object.getOwnPropertyDescriptor(r,t);o&&!("get"in o?!r.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return r[t]}}),Object.defineProperty(e,i,o)}:function(e,r,t,i){void 0===i&&(i=t),e[i]=r[t]}),__exportStar=this&&this.__exportStar||function(e,r){for(var t in e)"default"===t||Object.prototype.hasOwnProperty.call(r,t)||__createBinding(r,e,t)};Object.defineProperty(exports,"__esModule",{value:!0}),__exportStar(require("../core/tenant-entities"),exports),__exportStar(require("./api-client"),exports),__exportStar(require("./availability"),exports),__exportStar(require("./config-template"),exports),__exportStar(require("./config-var"),exports),__exportStar(require("./geoservice-interfaces"),exports),__exportStar(require("./graphql"),exports),__exportStar(require("./metadata"),exports),__exportStar(require("./mobile-notification"),exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var __awaiter=this&&this.__awaiter||function(t,e,o,r){return new(o||(o=Promise))((function(a,
|
|
1
|
+
"use strict";var __awaiter=this&&this.__awaiter||function(t,e,o,r){return new(o||(o=Promise))((function(a,i){function n(t){try{s(r.next(t))}catch(t){i(t)}}function c(t){try{s(r.throw(t))}catch(t){i(t)}}function s(t){var e;t.done?a(t.value):(e=t.value,e instanceof o?e:new o((function(t){t(e)}))).then(n,c)}s((r=r.apply(t,e||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.CursorBasedFetchingStrategy=void 0,exports.CursorBasedFetchingStrategy={execute(t){return __awaiter(this,void 0,void 0,(function*(){var e,o,r,a,i,n;const c=t.contextData.job.BatchSize||200,s=(t.contextData.job.Fields||"UID").split(",").map((t=>t.trim()));s.includes("UID")||s.push("UID");let u={objectName:t.contextData.job.ObjectName,operationName:t.contextData.job.ObjectName,first:c,orderBy:t.contextData.job.OrderBy,after:null===(o=null===(e=t.contextData.batchState)||void 0===e?void 0:e.processor)||void 0===o?void 0:o.cursor,filter:t.contextData.job.FilterCondition,fields:s.join("\n")};const d=t.newQueryBuilder(u);d.withFields(s).withLimit(c).withOrderBy(t.contextData.job.OrderBy).withFilter(t.contextData.job.FilterCondition);const l=yield t.graphqlService.query(d.build()),h=l.records,v=l.endCursor;return null===(i=null===(a=null===(r=t.contextData.batchState)||void 0===r?void 0:r.processor)||void 0===a?void 0:a.allCursors)||void 0===i||i.push(v),(null===(n=t.contextData.batchState)||void 0===n?void 0:n.processor)&&(t.contextData.batchState.processor.cursor=v),h}))}};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var __awaiter=this&&this.__awaiter||function(e,t,i,r){return new(i||(i=Promise))((function(n,a){function o(e){try{s(r.next(e))}catch(e){a(e)}}function c(e){try{s(r.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,c)}s((r=r.apply(e,t||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.DateBasedFetchingStrategy=void 0,exports.DateBasedFetchingStrategy={execute(e){return __awaiter(this,void 0,void 0,(function*(){const t=e.contextData.job;let i=`LastModifiedDate <= ${t.CreatedDate} `;t.FilterCondition&&(i+=` AND ${t.FilterCondition}`);const r=t.OrderBy||"CreatedDate ASC",n=t.BatchSize||10,a=(t.Fields||"UID").split(",").map((e=>e.trim()));return(yield e.graphqlService.query({objectName:t.ObjectName,first:n,filter:i,orderBy:r,fields:a.join("\n")})).records}))}};
|
|
1
|
+
"use strict";var __awaiter=this&&this.__awaiter||function(e,t,i,r){return new(i||(i=Promise))((function(n,a){function o(e){try{s(r.next(e))}catch(e){a(e)}}function c(e){try{s(r.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?n(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,c)}s((r=r.apply(e,t||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.DateBasedFetchingStrategy=void 0,exports.DateBasedFetchingStrategy={execute(e){return __awaiter(this,void 0,void 0,(function*(){const t=e.contextData.job;let i=`LastModifiedDate <= ${t.CreatedDate} `;t.FilterCondition&&(i+=` AND ${t.FilterCondition}`);const r=t.OrderBy||"CreatedDate ASC",n=t.BatchSize||10,a=(t.Fields||"UID").split(",").map((e=>e.trim()));return(yield e.graphqlService.query({objectName:t.ObjectName,operationName:t.ObjectName,first:n,filter:i,orderBy:r,fields:a.join("\n")})).records}))}};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { PaginationStrategy } from "./pagination-strategy";
|
|
3
|
+
/**
|
|
4
|
+
* Default configuration values for `GraphBatchConfig`.
|
|
5
|
+
*/
|
|
6
|
+
export declare const DEFAULT_GRAPH_BATCH_CONFIG: GraphBatchConfig;
|
|
7
|
+
/**
|
|
8
|
+
* Schema validation using `zod`
|
|
9
|
+
*/
|
|
10
|
+
declare const GraphBatchConfigSchema: z.ZodObject<{
|
|
11
|
+
strategy: z.ZodNativeEnum<typeof PaginationStrategy>;
|
|
12
|
+
batchSize: z.ZodDefault<z.ZodNumber>;
|
|
13
|
+
maxBatches: z.ZodDefault<z.ZodNumber>;
|
|
14
|
+
delaySeconds: z.ZodDefault<z.ZodNumber>;
|
|
15
|
+
}, "strip", z.ZodTypeAny, {
|
|
16
|
+
strategy: PaginationStrategy;
|
|
17
|
+
batchSize: number;
|
|
18
|
+
maxBatches: number;
|
|
19
|
+
delaySeconds: number;
|
|
20
|
+
}, {
|
|
21
|
+
strategy: PaginationStrategy;
|
|
22
|
+
batchSize?: number | undefined;
|
|
23
|
+
maxBatches?: number | undefined;
|
|
24
|
+
delaySeconds?: number | undefined;
|
|
25
|
+
}>;
|
|
26
|
+
/**
|
|
27
|
+
* Configuration options for `GraphBatch`.
|
|
28
|
+
*/
|
|
29
|
+
export type GraphBatchConfig = z.infer<typeof GraphBatchConfigSchema>;
|
|
30
|
+
/**
|
|
31
|
+
* Merges user-provided config with default values.
|
|
32
|
+
*/
|
|
33
|
+
export declare function initializeConfig(config: Partial<GraphBatchConfig> | undefined): GraphBatchConfig;
|
|
34
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.DEFAULT_GRAPH_BATCH_CONFIG=void 0,exports.initializeConfig=initializeConfig;const zod_1=require("zod"),pagination_strategy_1=require("./pagination-strategy");exports.DEFAULT_GRAPH_BATCH_CONFIG={strategy:pagination_strategy_1.PaginationStrategy.NONE,batchSize:200,maxBatches:100,delaySeconds:0};const GraphBatchConfigSchema=zod_1.z.object({strategy:zod_1.z.nativeEnum(pagination_strategy_1.PaginationStrategy),batchSize:zod_1.z.number().min(1).max(200).default(200),maxBatches:zod_1.z.number().min(1).max(500).default(100),delaySeconds:zod_1.z.number().min(0).max(15).default(0)});function initializeConfig(t){return GraphBatchConfigSchema.parse(Object.assign(Object.assign({},exports.DEFAULT_GRAPH_BATCH_CONFIG),t))}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { ExecutionContext } from "../../core";
|
|
2
|
+
import { QueryResult } from "../../interfaces";
|
|
3
|
+
import { GraphQLQueryBuilder } from "../graphql";
|
|
4
|
+
import { GraphBatchConfig } from "./graph-batch-config";
|
|
5
|
+
/**
|
|
6
|
+
* Base class for batch processing with pagination support.
|
|
7
|
+
*/
|
|
8
|
+
export declare abstract class GraphBatch {
|
|
9
|
+
protected context: ExecutionContext;
|
|
10
|
+
protected config: GraphBatchConfig;
|
|
11
|
+
protected queryBuilder?: GraphQLQueryBuilder;
|
|
12
|
+
protected queryResult?: QueryResult;
|
|
13
|
+
private startTime;
|
|
14
|
+
constructor(context: ExecutionContext, config?: Partial<GraphBatchConfig>);
|
|
15
|
+
/**
|
|
16
|
+
* Runs the batch process, handling pagination, execution, and accumulation of results.
|
|
17
|
+
*
|
|
18
|
+
* @returns The accumulated result of the batch process.
|
|
19
|
+
*/
|
|
20
|
+
run(): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Initializes the query builder. This method must be overridden in subclasses.
|
|
23
|
+
*
|
|
24
|
+
* @returns A configured GraphQL query builder.
|
|
25
|
+
*/
|
|
26
|
+
protected abstract start(): Promise<GraphQLQueryBuilder>;
|
|
27
|
+
/**
|
|
28
|
+
* Processes a batch of records and accumulates the result.
|
|
29
|
+
*
|
|
30
|
+
* @param records The batch of records retrieved from the query.
|
|
31
|
+
*/
|
|
32
|
+
protected abstract execute(records: any[]): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Final cleanup or logging after the batch process completes.
|
|
35
|
+
*/
|
|
36
|
+
protected finish(): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Fetches the next page of data based on the pagination strategy.
|
|
39
|
+
*
|
|
40
|
+
* @returns The result of the query execution.
|
|
41
|
+
*/
|
|
42
|
+
protected fetchNextPage(): Promise<QueryResult>;
|
|
43
|
+
/**
|
|
44
|
+
* Checks if the maximum number of batches has been reached.
|
|
45
|
+
*
|
|
46
|
+
* @param currentBatchCount The number of batches processed so far.
|
|
47
|
+
* @returns `true` if the maximum limit is reached, otherwise `false`.
|
|
48
|
+
*/
|
|
49
|
+
protected isMaxBatchesReached(currentBatchCount: number): boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Delays execution for a specified time.
|
|
52
|
+
*
|
|
53
|
+
* @param ms The time in milliseconds to delay.
|
|
54
|
+
*/
|
|
55
|
+
protected delay(ms: number): Promise<void>;
|
|
56
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var __awaiter=this&&this.__awaiter||function(t,e,i,r){return new(i||(i=Promise))((function(a,s){function n(t){try{o(r.next(t))}catch(t){s(t)}}function h(t){try{o(r.throw(t))}catch(t){s(t)}}function o(t){var e;t.done?a(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(n,h)}o((r=r.apply(t,e||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.GraphBatch=void 0;const graph_batch_config_1=require("./graph-batch-config"),pagination_strategy_1=require("./pagination-strategy");class GraphBatch{constructor(t,e){this.startTime=new Date,this.context=t,this.config=(0,graph_batch_config_1.initializeConfig)(e),this.startTime=new Date}run(){return __awaiter(this,void 0,void 0,(function*(){var t,e;if(this.queryBuilder=yield this.start(),!this.queryBuilder)throw new Error("Query builder was not defined in start().");this.queryBuilder.withLimit(this.config.batchSize);let i=0,r=!0;for(;r&&!this.isMaxBatchesReached(i)&&(this.queryResult=yield this.fetchNextPage(),this.queryResult.records&&0!==this.queryResult.records.length);)yield this.execute(this.queryResult.records),i++,r=null!==(e=null===(t=this.queryResult.pageInfo)||void 0===t?void 0:t.hasNextPage)&&void 0!==e&&e;yield Promise.all([]),yield this.finish()}))}finish(){return __awaiter(this,void 0,void 0,(function*(){this.context.logger.info("Batch process completed.")}))}fetchNextPage(){return __awaiter(this,void 0,void 0,(function*(){var t,e,i;switch(this.config.strategy){case pagination_strategy_1.PaginationStrategy.OFFSET:this.queryResult&&(null===(t=this.queryBuilder)||void 0===t||t.withOffset(this.queryResult.endOffset+1));break;case pagination_strategy_1.PaginationStrategy.CURSOR:this.queryResult&&(null===(e=this.queryBuilder)||void 0===e||e.withCursor(this.queryResult.endCursor));break;case pagination_strategy_1.PaginationStrategy.NONE:default:null===(i=this.queryBuilder)||void 0===i||i.withFilter(`LastModifiedDate < ${this.startTime.toISOString()}`)}return this.queryBuilder.execute()}))}isMaxBatchesReached(t){return!!this.config.maxBatches&&t>=this.config.maxBatches}delay(t){return __awaiter(this,void 0,void 0,(function*(){return new Promise((e=>setTimeout(e,t)))}))}}exports.GraphBatch=GraphBatch;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,o)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),__exportStar=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||__createBinding(t,e,r)};Object.defineProperty(exports,"__esModule",{value:!0}),__exportStar(require("./graph-batch"),exports),__exportStar(require("./graph-batch-config"),exports),__exportStar(require("./pagination-strategy"),exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var PaginationStrategy;Object.defineProperty(exports,"__esModule",{value:!0}),exports.PaginationStrategy=void 0,function(t){t.CURSOR="cursor",t.OFFSET="offset",t.NONE="none"}(PaginationStrategy||(exports.PaginationStrategy=PaginationStrategy={}));
|