@skedulo/pulse-solution-services 0.0.5
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/README.md +161 -0
- package/dist/clients/base-client.js +1 -0
- package/dist/clients/config-var-client.js +1 -0
- package/dist/clients/graphql-client.js +1 -0
- package/dist/clients/index.js +1 -0
- package/dist/clients/metadata-client.js +1 -0
- package/dist/constants/config-var.js +1 -0
- package/dist/constants/http.js +1 -0
- package/dist/constants/index.js +1 -0
- package/dist/constants/tenant-endpoints.js +1 -0
- package/dist/constants/tenant-objects.js +1 -0
- package/dist/core/execution-context.js +1 -0
- package/dist/core/index.js +1 -0
- package/dist/index.d.ts +644 -0
- package/dist/index.js +1 -0
- package/dist/interfaces/config-var.js +1 -0
- package/dist/interfaces/graphql.js +1 -0
- package/dist/interfaces/index.js +1 -0
- package/dist/interfaces/metadata.js +1 -0
- package/dist/logging/decorators/index.d.ts +1 -0
- package/dist/logging/decorators/index.js +1 -0
- package/dist/logging/decorators/log-method.d.ts +7 -0
- package/dist/logging/decorators/log-method.js +1 -0
- package/dist/logging/index.js +1 -0
- package/dist/logging/logger.js +1 -0
- package/dist/services/batch-processor/batch-orchestrator.d.ts +18 -0
- package/dist/services/batch-processor/batch-orchestrator.js +1 -0
- package/dist/services/batch-processor/constants.d.ts +22 -0
- package/dist/services/batch-processor/constants.js +1 -0
- package/dist/services/batch-processor/fetching-strategies/batch-number-fetching-strategy.d.ts +6 -0
- package/dist/services/batch-processor/fetching-strategies/batch-number-fetching-strategy.js +1 -0
- package/dist/services/batch-processor/fetching-strategies/cursor-based-fetching-strategy.d.ts +8 -0
- package/dist/services/batch-processor/fetching-strategies/cursor-based-fetching-strategy.js +1 -0
- package/dist/services/batch-processor/fetching-strategies/date-based-fetching-strategy.d.ts +4 -0
- package/dist/services/batch-processor/fetching-strategies/date-based-fetching-strategy.js +1 -0
- package/dist/services/batch-processor/fetching-strategies/fetching-strategy-factory.d.ts +9 -0
- package/dist/services/batch-processor/fetching-strategies/fetching-strategy-factory.js +1 -0
- package/dist/services/batch-processor/fetching-strategies/index.d.ts +1 -0
- package/dist/services/batch-processor/fetching-strategies/index.js +1 -0
- package/dist/services/batch-processor/index.d.ts +2 -0
- package/dist/services/batch-processor/index.js +1 -0
- package/dist/services/batch-processor/interfaces.d.ts +33 -0
- package/dist/services/batch-processor/interfaces.js +1 -0
- package/dist/services/batch-processor/workers/custom-worker.d.ts +5 -0
- package/dist/services/batch-processor/workers/custom-worker.js +1 -0
- package/dist/services/batch-processor/workers/delete-worker.d.ts +4 -0
- package/dist/services/batch-processor/workers/delete-worker.js +1 -0
- package/dist/services/batch-processor/workers/index.d.ts +2 -0
- package/dist/services/batch-processor/workers/index.js +1 -0
- package/dist/services/batch-processor/workers/update-worker.d.ts +4 -0
- package/dist/services/batch-processor/workers/update-worker.js +1 -0
- package/dist/services/batch-processor/workers/worker-factory.d.ts +6 -0
- package/dist/services/batch-processor/workers/worker-factory.js +1 -0
- package/dist/services/batch-processor/workers/worker-interfaces.d.ts +4 -0
- package/dist/services/batch-processor/workers/worker-interfaces.js +1 -0
- package/dist/services/cache/cache-service.d.ts +70 -0
- package/dist/services/cache/cache-service.js +1 -0
- package/dist/services/cache/index.d.ts +1 -0
- package/dist/services/cache/index.js +1 -0
- package/dist/services/cache/storage/config-var-cache-storage.d.ts +40 -0
- package/dist/services/cache/storage/config-var-cache-storage.js +1 -0
- package/dist/services/cache/storage/in-memory-cache-storage.d.ts +32 -0
- package/dist/services/cache/storage/in-memory-cache-storage.js +1 -0
- package/dist/services/cache/storage/index.d.ts +2 -0
- package/dist/services/cache/storage/index.js +1 -0
- package/dist/services/graphql/graphql-query-builder.d.ts +75 -0
- package/dist/services/graphql/graphql-query-builder.js +1 -0
- package/dist/services/graphql/graphql-service.d.ts +46 -0
- package/dist/services/graphql/graphql-service.js +1 -0
- package/dist/services/graphql/index.d.ts +2 -0
- package/dist/services/graphql/index.js +1 -0
- package/dist/services/graphql/queries.d.ts +25 -0
- package/dist/services/graphql/queries.js +1 -0
- package/dist/services/index.js +1 -0
- package/dist/services/metadata-service.js +1 -0
- package/dist/utils/config-helper.js +1 -0
- package/dist/utils/index.js +1 -0
- package/package.json +42 -0
- package/yarn.lock +2836 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,644 @@
|
|
|
1
|
+
// Generated by dts-bundle-generator v9.5.1
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Interface representing the structure of metadata for an object.
|
|
5
|
+
*/
|
|
6
|
+
export interface Metadata {
|
|
7
|
+
label: string;
|
|
8
|
+
labelPlural: string | null;
|
|
9
|
+
mapping: string;
|
|
10
|
+
name: string;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Interface representing the metadata for a specific object, extending the base Metadata interface.
|
|
14
|
+
*/
|
|
15
|
+
export interface ObjectMetadata extends Metadata {
|
|
16
|
+
relationships: any[];
|
|
17
|
+
fields: any[];
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Interface representing the structure of a relationship.
|
|
21
|
+
*/
|
|
22
|
+
export interface RelationshipMapping {
|
|
23
|
+
schemaMapping: string;
|
|
24
|
+
mapping: string;
|
|
25
|
+
fieldMapping: string;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Interface representing the structure of a field.
|
|
29
|
+
*/
|
|
30
|
+
export interface FieldMetadata {
|
|
31
|
+
label: string;
|
|
32
|
+
mapping: string;
|
|
33
|
+
type: string;
|
|
34
|
+
nillable: boolean;
|
|
35
|
+
length: number;
|
|
36
|
+
maxLength: number | null;
|
|
37
|
+
precision: number | null;
|
|
38
|
+
scale: number | null;
|
|
39
|
+
upsertKey: boolean;
|
|
40
|
+
unique: boolean;
|
|
41
|
+
readOnly: boolean;
|
|
42
|
+
accessMode: "read_only" | "read_write";
|
|
43
|
+
relationship: RelationshipMapping | null;
|
|
44
|
+
values: Array<PicklistValue>;
|
|
45
|
+
name: string;
|
|
46
|
+
}
|
|
47
|
+
export interface PicklistValue {
|
|
48
|
+
label: string;
|
|
49
|
+
value: string;
|
|
50
|
+
active: boolean;
|
|
51
|
+
defaultValue: boolean;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Interface defining the base configuration for API clients.
|
|
55
|
+
*/
|
|
56
|
+
export interface BaseConfig {
|
|
57
|
+
apiServer: string;
|
|
58
|
+
apiToken: string;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Base client for making API requests with standardized error handling.
|
|
62
|
+
* Provides methods for setting up headers and performing API requests using fetch.
|
|
63
|
+
*/
|
|
64
|
+
export declare class BaseClient {
|
|
65
|
+
protected config: BaseConfig;
|
|
66
|
+
/**
|
|
67
|
+
* Creates an instance of BaseClient.
|
|
68
|
+
* @param {BaseConfig} config - The configuration object containing API server and token.
|
|
69
|
+
*/
|
|
70
|
+
constructor(config: BaseConfig);
|
|
71
|
+
/**
|
|
72
|
+
* Constructs the headers for API requests.
|
|
73
|
+
* @returns {Record<string, string>} - The headers including authorization and content type.
|
|
74
|
+
*/
|
|
75
|
+
protected getHeaders(): {
|
|
76
|
+
Authorization: string;
|
|
77
|
+
"Content-Type": string;
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Performs an API request with standardized error handling using fetch.
|
|
81
|
+
* @template T
|
|
82
|
+
* @param {Object} options - The request options.
|
|
83
|
+
* @param {string} options.method - HTTP method (default: GET).
|
|
84
|
+
* @param {string} options.endpoint - The API endpoint to call.
|
|
85
|
+
* @param {object} [options.body] - The request body.
|
|
86
|
+
* @param {Record<string, string>} [options.headers] - Additional headers.
|
|
87
|
+
* @returns {Promise<T>} - The parsed response data.
|
|
88
|
+
* @throws {Error} - If the request fails or the response is not OK.
|
|
89
|
+
*/
|
|
90
|
+
protected performRequest<T = any>({ method, endpoint, headers, body, }: {
|
|
91
|
+
method?: string;
|
|
92
|
+
endpoint: string;
|
|
93
|
+
body?: object;
|
|
94
|
+
headers?: Record<string, string>;
|
|
95
|
+
}): Promise<T>;
|
|
96
|
+
/**
|
|
97
|
+
* Handles exceptions encountered during API requests.
|
|
98
|
+
* @param {any} error - The error to handle.
|
|
99
|
+
*/
|
|
100
|
+
protected handleException(error: any): void;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* MetadataClient class to handle API requests related to metadata.
|
|
104
|
+
* Extends BaseClient to perform API operations.
|
|
105
|
+
*/
|
|
106
|
+
export declare class MetadataClient extends BaseClient {
|
|
107
|
+
/**
|
|
108
|
+
* Fetches all metadata mappings from the metadata endpoint.
|
|
109
|
+
* @returns {Promise<{ result: Metadata[] }>} - A promise resolving to an object containing an array of Metadata.
|
|
110
|
+
*/
|
|
111
|
+
fetchAllMetadata(): Promise<{
|
|
112
|
+
result: Metadata[];
|
|
113
|
+
}>;
|
|
114
|
+
/**
|
|
115
|
+
* Fetches metadata for a specific object using its mapping.
|
|
116
|
+
* @param {string} mapping - The API mapping for the object.
|
|
117
|
+
* @returns {Promise<{ result: ObjectMetadata }>} - A promise resolving to an object containing the metadata of the requested object.
|
|
118
|
+
*/
|
|
119
|
+
fetchObjectMetadata(mapping: string): Promise<{
|
|
120
|
+
result: ObjectMetadata;
|
|
121
|
+
}>;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* MetadataService class to process and filter metadata.
|
|
125
|
+
*/
|
|
126
|
+
export declare class MetadataService {
|
|
127
|
+
private client;
|
|
128
|
+
constructor(client: MetadataClient);
|
|
129
|
+
/**
|
|
130
|
+
* Retrieves metadata for specific objects.
|
|
131
|
+
*
|
|
132
|
+
* @param objectNames - The names of the objects.
|
|
133
|
+
* @returns A promise that resolves to metadata records.
|
|
134
|
+
*/
|
|
135
|
+
getObjectMetadata(objectNames: string[]): Promise<Record<string, ObjectMetadata>>;
|
|
136
|
+
/**
|
|
137
|
+
* Extracts picklist values from the object metadata.
|
|
138
|
+
*
|
|
139
|
+
* @param metadata - The metadata of the object.
|
|
140
|
+
* @returns An object containing the picklist values for each picklist field.
|
|
141
|
+
*/
|
|
142
|
+
getPicklistValues(metadata: ObjectMetadata): Record<string, string[]>;
|
|
143
|
+
}
|
|
144
|
+
export interface ConfigVar {
|
|
145
|
+
key?: string;
|
|
146
|
+
configType: string;
|
|
147
|
+
value: string;
|
|
148
|
+
description?: string;
|
|
149
|
+
status?: "active" | "inactive" | "expired";
|
|
150
|
+
updatedBy?: string;
|
|
151
|
+
createdBy?: string;
|
|
152
|
+
createdAt?: string;
|
|
153
|
+
updatedAt?: string;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Client for managing configuration variables through API requests.
|
|
157
|
+
* Provides methods to create, retrieve, update, search, and delete configuration variables.
|
|
158
|
+
*/
|
|
159
|
+
export declare class ConfigVarClient extends BaseClient {
|
|
160
|
+
/**
|
|
161
|
+
* Creates a new configuration variable.
|
|
162
|
+
* @param {ConfigVar} configVar - The configuration variable to create.
|
|
163
|
+
* @returns {Promise<ConfigVar>} - The created configuration variable.
|
|
164
|
+
*/
|
|
165
|
+
create(configVar: ConfigVar): Promise<ConfigVar>;
|
|
166
|
+
/**
|
|
167
|
+
* Retrieves a configuration variable by key.
|
|
168
|
+
* @param {string} key - The key of the configuration variable.
|
|
169
|
+
* @returns {Promise<ConfigVar>} - The retrieved configuration variable.
|
|
170
|
+
*/
|
|
171
|
+
get(key: string): Promise<ConfigVar>;
|
|
172
|
+
/**
|
|
173
|
+
* Updates an existing configuration variable.
|
|
174
|
+
* @param {ConfigVar} configVar - The configuration variable with updated values. Only the value and description can be updated.
|
|
175
|
+
* @returns {Promise<ConfigVar>} - A promise that resolves when the update is complete.
|
|
176
|
+
*/
|
|
177
|
+
update(configVar: ConfigVar): Promise<ConfigVar>;
|
|
178
|
+
/**
|
|
179
|
+
* Searches for configuration variables with pagination.
|
|
180
|
+
* @param {number} [pageSize] - The number of results per page (default max is 1000).
|
|
181
|
+
* @returns {Promise<ConfigVar[]>} - A list of configuration variables.
|
|
182
|
+
*/
|
|
183
|
+
search(pageSize?: number): Promise<ConfigVar[]>;
|
|
184
|
+
/**
|
|
185
|
+
* Deletes a configuration variable by key.
|
|
186
|
+
* @param {string} key - The key of the configuration variable to delete.
|
|
187
|
+
* @returns {Promise<string>} - A response indicating the result of the delete operation.
|
|
188
|
+
*/
|
|
189
|
+
delete(key: string): Promise<string>;
|
|
190
|
+
}
|
|
191
|
+
export interface HasId {
|
|
192
|
+
UID?: string;
|
|
193
|
+
[key: string]: any;
|
|
194
|
+
}
|
|
195
|
+
export interface GraphQlResponse<T = any> {
|
|
196
|
+
data: T;
|
|
197
|
+
errors?: object[];
|
|
198
|
+
}
|
|
199
|
+
export interface FetchRecordsQueryParams {
|
|
200
|
+
objectName: string;
|
|
201
|
+
first?: number;
|
|
202
|
+
offset?: number;
|
|
203
|
+
orderBy?: string;
|
|
204
|
+
filter?: string;
|
|
205
|
+
after?: string;
|
|
206
|
+
fields?: string;
|
|
207
|
+
}
|
|
208
|
+
export interface QueryResult {
|
|
209
|
+
records: HasId[];
|
|
210
|
+
totalCount: number;
|
|
211
|
+
pageInfo: any;
|
|
212
|
+
endCursor?: string;
|
|
213
|
+
endOffset?: number;
|
|
214
|
+
}
|
|
215
|
+
export interface MutationResult {
|
|
216
|
+
data: {
|
|
217
|
+
schema: {
|
|
218
|
+
[alias: string]: string;
|
|
219
|
+
};
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* A client for executing GraphQL queries and mutations.
|
|
224
|
+
* Extends the BaseClient to interact with the GraphQL API.
|
|
225
|
+
*/
|
|
226
|
+
export declare class GraphQLClient extends BaseClient {
|
|
227
|
+
/**
|
|
228
|
+
* Executes a GraphQL query or mutation.
|
|
229
|
+
* @param {string} graphqlQuery - The GraphQL query or mutation string.
|
|
230
|
+
* @returns {Promise<GraphQlResponse>} - The response from the GraphQL API.
|
|
231
|
+
* @throws {Error} - If the request fails or if there are errors in the response.
|
|
232
|
+
*/
|
|
233
|
+
execute(graphqlQuery: string): Promise<GraphQlResponse>;
|
|
234
|
+
}
|
|
235
|
+
export declare const CONFIG_VAR_TYPE: {
|
|
236
|
+
PLAIN_TEXT: string;
|
|
237
|
+
SECRET: string;
|
|
238
|
+
};
|
|
239
|
+
export declare const CONFIG_VAR_STATUS: {
|
|
240
|
+
ACTIVE: string;
|
|
241
|
+
INACTIVE: string;
|
|
242
|
+
EXPIRED: string;
|
|
243
|
+
};
|
|
244
|
+
export declare const HTTP_METHOD: {
|
|
245
|
+
GET: string;
|
|
246
|
+
POST: string;
|
|
247
|
+
PUT: string;
|
|
248
|
+
DELETE: string;
|
|
249
|
+
PATCH: string;
|
|
250
|
+
};
|
|
251
|
+
export declare const TENANT_ENDPOINTS: {
|
|
252
|
+
readonly CONFIG_VAR: {
|
|
253
|
+
readonly CREATE: "configuration/extension";
|
|
254
|
+
readonly GET: (key: string) => string;
|
|
255
|
+
readonly UPDATE: (key: string) => string;
|
|
256
|
+
readonly DELETE: (key: string) => string;
|
|
257
|
+
readonly SEARCH: "configuration/extension/search";
|
|
258
|
+
};
|
|
259
|
+
readonly GRAPHQL: "graphql/graphql";
|
|
260
|
+
readonly METADATA: {
|
|
261
|
+
readonly ALL: "custom/metadata";
|
|
262
|
+
readonly OBJECT: (objectMapping: string) => string;
|
|
263
|
+
};
|
|
264
|
+
};
|
|
265
|
+
export declare const TENANT_OBJECTS: {
|
|
266
|
+
Accounts: string;
|
|
267
|
+
Jobs: string;
|
|
268
|
+
JobAllocations: string;
|
|
269
|
+
Regions: string;
|
|
270
|
+
Contacts: string;
|
|
271
|
+
Locations: string;
|
|
272
|
+
Resources: string;
|
|
273
|
+
Tags: string;
|
|
274
|
+
JobTags: string;
|
|
275
|
+
ResourceTags: string;
|
|
276
|
+
Activities: string;
|
|
277
|
+
Availabilities: string;
|
|
278
|
+
Holidays: string;
|
|
279
|
+
AvailabilityPatterns: string;
|
|
280
|
+
AvailabilityPatternResources: string;
|
|
281
|
+
AccountResourceScores: string;
|
|
282
|
+
LocationResourceScores: string;
|
|
283
|
+
Products: string;
|
|
284
|
+
JobProducts: string;
|
|
285
|
+
};
|
|
286
|
+
export declare const PULSE_SOLUTION_NAMESPACE = "PSS";
|
|
287
|
+
/**
|
|
288
|
+
* This decorator logs the input arguments and output results of a method,
|
|
289
|
+
* including error handling with ANSI color-coded logs for better console readability.
|
|
290
|
+
* It allows selective logging based on the `LOG_NAMESPACE` environment variable.
|
|
291
|
+
*/
|
|
292
|
+
export declare function LogMethod(namespace?: string): MethodDecorator;
|
|
293
|
+
/**
|
|
294
|
+
* Logger class for managing log messages.
|
|
295
|
+
* Provides methods for logging information and errors, retrieving logs, and formatting logs.
|
|
296
|
+
*/
|
|
297
|
+
export declare class Logger {
|
|
298
|
+
logs: {
|
|
299
|
+
level: string;
|
|
300
|
+
message: string;
|
|
301
|
+
}[];
|
|
302
|
+
/**
|
|
303
|
+
* Constructs an instance of Logger.
|
|
304
|
+
* Initializes an empty array for storing log messages.
|
|
305
|
+
*/
|
|
306
|
+
constructor();
|
|
307
|
+
/**
|
|
308
|
+
* Logs an informational message.
|
|
309
|
+
*
|
|
310
|
+
* @param message - The message to log.
|
|
311
|
+
*/
|
|
312
|
+
info(message: string): void;
|
|
313
|
+
/**
|
|
314
|
+
* Logs an error message.
|
|
315
|
+
*
|
|
316
|
+
* @param message - The message to log.
|
|
317
|
+
*/
|
|
318
|
+
error(message: string): void;
|
|
319
|
+
/**
|
|
320
|
+
* Retrieves all log messages.
|
|
321
|
+
*
|
|
322
|
+
* @returns An array of log messages.
|
|
323
|
+
*/
|
|
324
|
+
getLogs(): {
|
|
325
|
+
level: string;
|
|
326
|
+
message: string;
|
|
327
|
+
}[];
|
|
328
|
+
/**
|
|
329
|
+
* Formats and retrieves all log messages as a single string.
|
|
330
|
+
*
|
|
331
|
+
* @param separator - The separator to use between log messages. Defaults to a newline character.
|
|
332
|
+
* @returns A formatted string of all log messages.
|
|
333
|
+
*/
|
|
334
|
+
getFormattedLogs(separator?: string): string;
|
|
335
|
+
/**
|
|
336
|
+
* Clears all log messages.
|
|
337
|
+
*/
|
|
338
|
+
clear(): void;
|
|
339
|
+
}
|
|
340
|
+
export declare class CacheService<T> {
|
|
341
|
+
private storage;
|
|
342
|
+
private secondaryCache?;
|
|
343
|
+
/**
|
|
344
|
+
* Creates an instance of CacheService.
|
|
345
|
+
* @param {CacheStorage<string>} storage - The cache storage implementation.
|
|
346
|
+
*/
|
|
347
|
+
constructor(storage: CacheStorage<string>);
|
|
348
|
+
/**
|
|
349
|
+
* Sets a secondary cache service to use as a fallback.
|
|
350
|
+
* @param {CacheService<T>} secondaryCache - The secondary cache service.
|
|
351
|
+
* @returns {void}
|
|
352
|
+
*/
|
|
353
|
+
setSecondaryCache(secondaryCache: CacheService<T>): void;
|
|
354
|
+
/**
|
|
355
|
+
* Retrieves a cached value by key.
|
|
356
|
+
* If the value is not found, it attempts to retrieve it from a secondary service or loader.
|
|
357
|
+
* @param {string} key - The cache key.
|
|
358
|
+
* @param {object} options - Optional parameters.
|
|
359
|
+
* @param {CacheLoader<T>} [options.loader] - A function to load the value if not cached.
|
|
360
|
+
* @param {boolean} [options.useSecondaryCache] - Whether to use the secondary cache service.
|
|
361
|
+
* @returns {Promise<T | null>} - The cached value or null if not found or expired.
|
|
362
|
+
*/
|
|
363
|
+
get(key: string, options?: CacheOptions<T>): Promise<T | null>;
|
|
364
|
+
/**
|
|
365
|
+
* Stores a value in the cache with an optional TTL.
|
|
366
|
+
* @param {string} key - The cache key.
|
|
367
|
+
* @param {T} value - The value to store.
|
|
368
|
+
* @param {object} options - Optional parameters.
|
|
369
|
+
* @returns {Promise<void>}
|
|
370
|
+
*/
|
|
371
|
+
set(key: string, value: T, options?: CacheOptions<T>): Promise<void>;
|
|
372
|
+
/**
|
|
373
|
+
* Deletes a specific key from the cache.
|
|
374
|
+
* @param {string} key - The cache key to delete.
|
|
375
|
+
* @returns {Promise<void>}
|
|
376
|
+
*/
|
|
377
|
+
delete(key: string): Promise<void>;
|
|
378
|
+
/**
|
|
379
|
+
* Clears all cache entries.
|
|
380
|
+
* @returns {Promise<void>}
|
|
381
|
+
*/
|
|
382
|
+
clear(): Promise<void>;
|
|
383
|
+
/**
|
|
384
|
+
* Adds the cache key prefix to a key if it is not already present.
|
|
385
|
+
* @param {string} key - The cache key.
|
|
386
|
+
* @returns {string} - The key with the prefix
|
|
387
|
+
*/
|
|
388
|
+
addPrefix(key: string): string;
|
|
389
|
+
/**
|
|
390
|
+
* Deserializes the cached metadata and returns the original value in the correct type.
|
|
391
|
+
* @param {any} metadata - The cached metadata object.
|
|
392
|
+
* @returns {T} - The deserialized value.
|
|
393
|
+
*/
|
|
394
|
+
private deserialize;
|
|
395
|
+
}
|
|
396
|
+
/**
|
|
397
|
+
* Interface for cache storage.
|
|
398
|
+
* This defines the basic storage operations without loader logic.
|
|
399
|
+
*/
|
|
400
|
+
export interface CacheStorage<T = any> {
|
|
401
|
+
set(key: string, value: T): Promise<void>;
|
|
402
|
+
get(key: string): Promise<T | null>;
|
|
403
|
+
delete(key: string): Promise<void>;
|
|
404
|
+
clear(): Promise<void>;
|
|
405
|
+
}
|
|
406
|
+
export interface CacheOptions<T> {
|
|
407
|
+
ttl?: number;
|
|
408
|
+
useSecondaryCache?: boolean;
|
|
409
|
+
}
|
|
410
|
+
/**
|
|
411
|
+
* A utility class for building GraphQL queries dynamically.
|
|
412
|
+
*/
|
|
413
|
+
export declare class GraphQLQueryBuilder {
|
|
414
|
+
private objectName;
|
|
415
|
+
private fields;
|
|
416
|
+
private filters;
|
|
417
|
+
private first?;
|
|
418
|
+
private offset?;
|
|
419
|
+
private orderBy?;
|
|
420
|
+
private after?;
|
|
421
|
+
private parentQueries;
|
|
422
|
+
private childQueries;
|
|
423
|
+
private isParent;
|
|
424
|
+
/**
|
|
425
|
+
* Creates an instance of GraphQLQueryBuilder.
|
|
426
|
+
* @param {string} objectName - The name of the object being queried.
|
|
427
|
+
* @param {boolean} [isParent=false] - Indicates if this query is a parent query.
|
|
428
|
+
*/
|
|
429
|
+
constructor(objectName: string, isParent?: boolean);
|
|
430
|
+
/**
|
|
431
|
+
* Specifies the fields to be retrieved.
|
|
432
|
+
* @param {string[]} fields - The list of fields to select.
|
|
433
|
+
* @returns {this} - The query builder instance.
|
|
434
|
+
*/
|
|
435
|
+
withFields(fields: string[]): this;
|
|
436
|
+
/**
|
|
437
|
+
* Adds a filter condition to the query.
|
|
438
|
+
* @param {string} condition - The filter condition.
|
|
439
|
+
* @returns {this} - The query builder instance.
|
|
440
|
+
*/
|
|
441
|
+
withFilter(condition: string): this;
|
|
442
|
+
/**
|
|
443
|
+
* Sets a limit on the number of records to retrieve.
|
|
444
|
+
* @param {number} first - The number of records to fetch.
|
|
445
|
+
* @returns {this} - The query builder instance.
|
|
446
|
+
*/
|
|
447
|
+
withLimit(first: number): this;
|
|
448
|
+
/**
|
|
449
|
+
* Sets an offset for pagination.
|
|
450
|
+
* @param {number} offset - The offset value.
|
|
451
|
+
* @returns {this} - The query builder instance.
|
|
452
|
+
*/
|
|
453
|
+
withOffset(offset: number): this;
|
|
454
|
+
/**
|
|
455
|
+
* Sets the order in which records should be retrieved.
|
|
456
|
+
* @param {string} orderBy - The field to order by.
|
|
457
|
+
* @returns {this} - The query builder instance.
|
|
458
|
+
*/
|
|
459
|
+
withOrderBy(orderBy: string): this;
|
|
460
|
+
/**
|
|
461
|
+
* Applies cursor-based pagination.
|
|
462
|
+
* @param {string} after - The cursor position.
|
|
463
|
+
* @returns {this} - The query builder instance.
|
|
464
|
+
*/
|
|
465
|
+
withCursor(after: string): this;
|
|
466
|
+
/**
|
|
467
|
+
* Creates a parent query.
|
|
468
|
+
* @param {string} objectName - The name of the parent object.
|
|
469
|
+
* @returns {GraphQLQueryBuilder} - A new query builder instance for the parent.
|
|
470
|
+
*/
|
|
471
|
+
withParentQuery(objectName: string): GraphQLQueryBuilder;
|
|
472
|
+
/**
|
|
473
|
+
* Creates a child query.
|
|
474
|
+
* @param {string} objectName - The name of the child object.
|
|
475
|
+
* @returns {GraphQLQueryBuilder} - A new query builder instance for the child.
|
|
476
|
+
*/
|
|
477
|
+
withChildQuery(objectName: string): GraphQLQueryBuilder;
|
|
478
|
+
/**
|
|
479
|
+
* Builds the GraphQL query parameters.
|
|
480
|
+
* @returns {FetchRecordsQueryParams} - The formatted query parameters.
|
|
481
|
+
*/
|
|
482
|
+
build(): FetchRecordsQueryParams;
|
|
483
|
+
}
|
|
484
|
+
/**
|
|
485
|
+
* A service class for handling GraphQL operations.
|
|
486
|
+
*/
|
|
487
|
+
export declare class GraphQLService {
|
|
488
|
+
private client;
|
|
489
|
+
/**
|
|
490
|
+
* Creates an instance of GraphQLService.
|
|
491
|
+
* @param {GraphQLClient} client - The GraphQL client to use for queries and mutations.
|
|
492
|
+
*/
|
|
493
|
+
constructor(client: GraphQLClient);
|
|
494
|
+
/**
|
|
495
|
+
* Executes a GraphQL query to fetch records.
|
|
496
|
+
* @param {FetchRecordsQueryParams} params - The query parameters.
|
|
497
|
+
* @returns {Promise<QueryResult>} - The query result including records, total count, page info, and cursors.
|
|
498
|
+
*/
|
|
499
|
+
query(params: FetchRecordsQueryParams): Promise<QueryResult>;
|
|
500
|
+
/**
|
|
501
|
+
* Deletes records from the GraphQL API.
|
|
502
|
+
* @param {string} objectName - The name of the object.
|
|
503
|
+
* @param {HasId[]} records - The records to delete.
|
|
504
|
+
* @returns {Promise<any>} - The response from the delete operation.
|
|
505
|
+
*/
|
|
506
|
+
delete(objectName: string, records: HasId[]): Promise<any>;
|
|
507
|
+
/**
|
|
508
|
+
* Updates records in the GraphQL API.
|
|
509
|
+
* @param {string} objectName - The name of the object.
|
|
510
|
+
* @param {HasId[]} records - The records to update.
|
|
511
|
+
* @returns {Promise<any>} - The response from the update operation.
|
|
512
|
+
*/
|
|
513
|
+
update(objectName: string, records: HasId[]): Promise<any>;
|
|
514
|
+
/**
|
|
515
|
+
* Inserts records into the GraphQL API.
|
|
516
|
+
* @param {string} objectName - The name of the object.
|
|
517
|
+
* @param {HasId[]} records - The records to insert.
|
|
518
|
+
* @returns {Promise<any>} - The response from the insert operation.
|
|
519
|
+
*/
|
|
520
|
+
insert(objectName: string, records: HasId[]): Promise<any>;
|
|
521
|
+
/**
|
|
522
|
+
* Extracts job UIDs from a GraphQL mutation response.
|
|
523
|
+
* @param {MutationResult} response - The response object.
|
|
524
|
+
* @returns {string[]} - An array of job UIDs.
|
|
525
|
+
*/
|
|
526
|
+
extractJobUIDs(response: MutationResult): string[];
|
|
527
|
+
}
|
|
528
|
+
/**
|
|
529
|
+
* ConfigHelper class provides methods to access and parse configuration variables.
|
|
530
|
+
* It supports retrieving configuration values as numbers, JSON objects, and strings.
|
|
531
|
+
* This ensures that configuration values are correctly parsed and validated.
|
|
532
|
+
*/
|
|
533
|
+
export declare class ConfigHelper {
|
|
534
|
+
private vars;
|
|
535
|
+
/**
|
|
536
|
+
* Constructs an instance of ConfigHelper.
|
|
537
|
+
*
|
|
538
|
+
* @param vars - The configuration variables.
|
|
539
|
+
*/
|
|
540
|
+
constructor(vars: any);
|
|
541
|
+
/**
|
|
542
|
+
* Retrieves a configuration variable as a number.
|
|
543
|
+
*
|
|
544
|
+
* @param varName - The name of the configuration variable.
|
|
545
|
+
* @returns The configuration value as a number, or null if it cannot be parsed as a number.
|
|
546
|
+
*/
|
|
547
|
+
getNumber(varName: string): number | null;
|
|
548
|
+
/**
|
|
549
|
+
* Retrieves a configuration variable as a JSON object.
|
|
550
|
+
*
|
|
551
|
+
* @param varName - The name of the configuration variable.
|
|
552
|
+
* @returns The configuration value as a JSON object, or null if it cannot be parsed as JSON.
|
|
553
|
+
*/
|
|
554
|
+
getJson(varName: string): any;
|
|
555
|
+
/**
|
|
556
|
+
* Retrieves a configuration variable as a string.
|
|
557
|
+
*
|
|
558
|
+
* @param varName - The name of the configuration variable.
|
|
559
|
+
* @returns The configuration value as a string.
|
|
560
|
+
*/
|
|
561
|
+
getString(varName: string): string;
|
|
562
|
+
}
|
|
563
|
+
export declare class ExecutionContext {
|
|
564
|
+
skedContext: any;
|
|
565
|
+
contextData: any;
|
|
566
|
+
private baseConfig;
|
|
567
|
+
private _logger?;
|
|
568
|
+
private _configHelper?;
|
|
569
|
+
private _graphqlClient?;
|
|
570
|
+
private _graphqlService?;
|
|
571
|
+
private _metadataClient?;
|
|
572
|
+
private _metadataService?;
|
|
573
|
+
private _configVarClient?;
|
|
574
|
+
private _configVarCache?;
|
|
575
|
+
private _inMemoryCache?;
|
|
576
|
+
protected constructor(skedContext: any);
|
|
577
|
+
static fromContext(skedContext: any): ExecutionContext;
|
|
578
|
+
static fromCredentials({ apiServer, apiToken }: {
|
|
579
|
+
apiServer: string;
|
|
580
|
+
apiToken: string;
|
|
581
|
+
}): ExecutionContext;
|
|
582
|
+
get logger(): Logger;
|
|
583
|
+
get configHelper(): ConfigHelper;
|
|
584
|
+
get graphqlClient(): GraphQLClient;
|
|
585
|
+
get graphqlService(): GraphQLService;
|
|
586
|
+
newQueryBuilder(objectName: string): GraphQLQueryBuilder;
|
|
587
|
+
get metadataClient(): MetadataClient;
|
|
588
|
+
get metadataService(): MetadataService;
|
|
589
|
+
get configVarClient(): ConfigVarClient;
|
|
590
|
+
get configVarCache(): CacheService<any>;
|
|
591
|
+
get inMemoryCache(): CacheService<any>;
|
|
592
|
+
dispose(): void;
|
|
593
|
+
private lazyInit;
|
|
594
|
+
}
|
|
595
|
+
export interface BatchJobSchemaData extends HasId {
|
|
596
|
+
StatusDetails?: string;
|
|
597
|
+
MaximumBatches?: number;
|
|
598
|
+
Status?: string;
|
|
599
|
+
ProcessedBatches?: number;
|
|
600
|
+
ObjectName?: string;
|
|
601
|
+
JobType?: string;
|
|
602
|
+
BatchProcessor?: string;
|
|
603
|
+
CreatedDate?: string;
|
|
604
|
+
FilterCondition?: string;
|
|
605
|
+
OrderBy?: string;
|
|
606
|
+
Fields?: string;
|
|
607
|
+
JobHandler?: string;
|
|
608
|
+
State?: string;
|
|
609
|
+
DelaySeconds?: number;
|
|
610
|
+
CallbackURL?: string;
|
|
611
|
+
ProcessingAt?: string;
|
|
612
|
+
CompletedAt?: string;
|
|
613
|
+
FailedBatches?: number;
|
|
614
|
+
FetchingStrategy?: string;
|
|
615
|
+
}
|
|
616
|
+
export interface BatchOrchestratorConfig {
|
|
617
|
+
isAsyncProcessing?: boolean;
|
|
618
|
+
}
|
|
619
|
+
export interface BatchState {
|
|
620
|
+
processor?: {
|
|
621
|
+
cursor?: string;
|
|
622
|
+
allCursors?: string[];
|
|
623
|
+
batchNumber?: number;
|
|
624
|
+
};
|
|
625
|
+
worker?: any;
|
|
626
|
+
}
|
|
627
|
+
export declare class BatchOrchestrator {
|
|
628
|
+
protected context: ExecutionContext;
|
|
629
|
+
protected config: BatchOrchestratorConfig;
|
|
630
|
+
constructor(context: ExecutionContext, config?: BatchOrchestratorConfig);
|
|
631
|
+
processBatchJob(): Promise<void>;
|
|
632
|
+
protected validateJob(): void;
|
|
633
|
+
protected prepareData(): Promise<void>;
|
|
634
|
+
protected sendWorkerStateToCallbackUrl(): Promise<void>;
|
|
635
|
+
protected getWorkerState(): object;
|
|
636
|
+
protected delay(ms: number): Promise<void>;
|
|
637
|
+
protected processWorker(): Promise<void>;
|
|
638
|
+
protected processNextBatch(): Promise<void>;
|
|
639
|
+
protected postProcess(): Promise<void>;
|
|
640
|
+
protected updateJobStatus(): Promise<void>;
|
|
641
|
+
private isCompleted;
|
|
642
|
+
}
|
|
643
|
+
|
|
644
|
+
export {};
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,r,t,o){void 0===o&&(o=t);var i=Object.getOwnPropertyDescriptor(r,t);i&&!("get"in i?!r.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return r[t]}}),Object.defineProperty(e,o,i)}:function(e,r,t,o){void 0===o&&(o=t),e[o]=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("./clients"),exports),__exportStar(require("./constants"),exports),__exportStar(require("./core"),exports),__exportStar(require("./interfaces"),exports),__exportStar(require("./logging"),exports),__exportStar(require("./services"),exports),__exportStar(require("./utils"),exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});
|
|
@@ -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("./config-var"),exports),__exportStar(require("./graphql"),exports),__exportStar(require("./metadata"),exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./log-method";
|
|
@@ -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("./log-method"),exports);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const PULSE_SOLUTION_NAMESPACE = "PSS";
|
|
2
|
+
/**
|
|
3
|
+
* This decorator logs the input arguments and output results of a method,
|
|
4
|
+
* including error handling with ANSI color-coded logs for better console readability.
|
|
5
|
+
* It allows selective logging based on the `LOG_NAMESPACE` environment variable.
|
|
6
|
+
*/
|
|
7
|
+
export declare function LogMethod(namespace?: string): MethodDecorator;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.PULSE_SOLUTION_NAMESPACE=void 0,exports.LogMethod=LogMethod,exports.PULSE_SOLUTION_NAMESPACE="PSS";const COLORS={RESET:"[0m",GREEN:"[32m",YELLOW:"[33m",RED:"[31m",CYAN:"[36m",MAGENTA:"[35m"};function LogMethod(t=exports.PULSE_SOLUTION_NAMESPACE){return function(o,n,e){const O=e.value,r=process.env.LOG_NAMESPACE||"",E=parseInt(process.env.LOG_ENTRY_MAX_LENGTH||"120",10),S=r===t||"ALL"===r.toUpperCase();function s(o,n,e,O,r){const S=(new Date).toISOString(),s="ERROR"===o?COLORS.RED:"INPUT"===O?COLORS.CYAN:COLORS.MAGENTA;console.log(`${COLORS.GREEN}[${o}]${COLORS.RESET} | ${COLORS.YELLOW}${S}${COLORS.RESET} | ${COLORS.GREEN}${t}${COLORS.RESET} | ${n} | ${e} - ${s}${O}${COLORS.RESET}: ${function(t){if(!t)return"";const o="string"==typeof t?t:JSON.stringify(t);return o.length>E?`${o.substring(0,E-3)}...`:o}(r)}`)}return e.value=function(...t){S&&s("INFO",o.constructor.name,n.toString(),"INPUT",t);try{const e=O.apply(this,t);return e instanceof Promise?e.then((t=>(S&&s("INFO",o.constructor.name,n.toString(),"OUTPUT",t),t))):(S&&s("INFO",o.constructor.name,n.toString(),"OUTPUT",e),e)}catch(t){throw s("ERROR",o.constructor.name,n.toString(),"ERROR",t.message||t),t}},e}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,t,r,o){void 0===o&&(o=r);var i=Object.getOwnPropertyDescriptor(t,r);i&&!("get"in i?!t.__esModule:i.writable||i.configurable)||(i={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,o,i)}:function(e,t,r,o){void 0===o&&(o=r),e[o]=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("./decorators"),exports),__exportStar(require("./logger"),exports);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.Logger=void 0;class Logger{constructor(){this.logs=[]}info(e){this.logs.push({level:"info",message:e})}error(e){this.logs.push({level:"error",message:e}),console.error(`ERROR: ${this.getFormattedLogs()}`)}getLogs(){return this.logs}getFormattedLogs(e="\n"){return this.logs.map((e=>`${e.level.toUpperCase()}: ${e.message}`)).join(e)}clear(){this.logs=[]}}exports.Logger=Logger;
|