@skedulo/pulse-solution-services 0.0.6 → 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.
Files changed (81) hide show
  1. package/CHANGELOG.md +13 -1
  2. package/README.md +321 -25
  3. package/dist/clients/artifact-client.js +1 -1
  4. package/dist/clients/availability-api-client.js +1 -0
  5. package/dist/clients/base-client.js +1 -1
  6. package/dist/clients/geo-api-client.js +1 -0
  7. package/dist/clients/graphql-client.js +1 -1
  8. package/dist/constants/graphql-constants.js +1 -0
  9. package/dist/constants/index.js +1 -1
  10. package/dist/constants/tenant-endpoints.js +1 -1
  11. package/dist/core/entity-factory.js +1 -0
  12. package/dist/core/execution-context.js +1 -1
  13. package/dist/core/execution-options.js +1 -0
  14. package/dist/core/index.js +1 -1
  15. package/dist/core/request-context.js +1 -0
  16. package/dist/core/request-header-constants.js +1 -0
  17. package/dist/core/tenant-objects.js +1 -0
  18. package/dist/index.d.ts +708 -151
  19. package/dist/interfaces/api-client.js +1 -0
  20. package/dist/interfaces/availability.js +1 -0
  21. package/dist/interfaces/geoservice-interfaces.js +1 -0
  22. package/dist/interfaces/index.js +1 -1
  23. package/dist/services/batch-processor/fetching-strategies/cursor-based-fetching-strategy.js +1 -1
  24. package/dist/services/batch-processor/fetching-strategies/date-based-fetching-strategy.js +1 -1
  25. package/dist/services/geoservice.js +1 -0
  26. package/dist/services/graph-batch/graph-batch-config.d.ts +34 -0
  27. package/dist/services/graph-batch/graph-batch-config.js +1 -0
  28. package/dist/services/graph-batch/graph-batch.d.ts +56 -0
  29. package/dist/services/graph-batch/graph-batch.js +1 -0
  30. package/dist/services/graph-batch/index.d.ts +3 -0
  31. package/dist/services/graph-batch/index.js +1 -0
  32. package/dist/services/graph-batch/pagination-strategy.d.ts +5 -0
  33. package/dist/services/graph-batch/pagination-strategy.js +1 -0
  34. package/dist/services/graphql/graphql-query-builder.d.ts +17 -28
  35. package/dist/services/graphql/graphql-query-builder.js +1 -1
  36. package/dist/services/graphql/graphql-service.d.ts +20 -13
  37. package/dist/services/graphql/graphql-service.js +1 -1
  38. package/dist/services/graphql/queries.d.ts +5 -4
  39. package/dist/services/graphql/queries.js +1 -1
  40. package/dist/services/index.js +1 -1
  41. package/dist/services/resource-availability/builder/data-service.d.ts +10 -0
  42. package/dist/services/resource-availability/builder/data-service.js +1 -0
  43. package/dist/services/resource-availability/builder/index.d.ts +3 -0
  44. package/dist/services/resource-availability/builder/index.js +1 -0
  45. package/dist/services/resource-availability/builder/resource-availability-service.d.ts +8 -0
  46. package/dist/services/resource-availability/builder/resource-availability-service.js +1 -0
  47. package/dist/services/resource-availability/builder/resource-builder.d.ts +17 -0
  48. package/dist/services/resource-availability/builder/resource-builder.js +1 -0
  49. package/dist/services/resource-availability/builder/resource-query-param.d.ts +23 -0
  50. package/dist/services/resource-availability/builder/resource-query-param.js +1 -0
  51. package/dist/services/resource-availability/index.d.ts +2 -0
  52. package/dist/services/resource-availability/index.js +1 -0
  53. package/dist/services/resource-availability/validator/index.d.ts +3 -0
  54. package/dist/services/resource-availability/validator/index.js +1 -0
  55. package/dist/services/resource-availability/validator/resource-job-validation.d.ts +11 -0
  56. package/dist/services/resource-availability/validator/resource-job-validation.js +1 -0
  57. package/dist/services/resource-availability/validator/resource-validation-option.d.ts +5 -0
  58. package/dist/services/resource-availability/validator/resource-validation-option.js +1 -0
  59. package/dist/services/resource-availability/validator/resource-validator.d.ts +13 -0
  60. package/dist/services/resource-availability/validator/resource-validator.js +1 -0
  61. package/dist/services/resource-availability/validator/validation-result.d.ts +12 -0
  62. package/dist/services/resource-availability/validator/validation-result.js +1 -0
  63. package/dist/utils/datetime-utils.js +1 -0
  64. package/dist/utils/index.js +1 -1
  65. package/package.json +7 -2
  66. package/yarn.lock +38 -0
  67. package/dist/clients/artifacts/artifact-client.d.ts +0 -19
  68. package/dist/clients/artifacts/artifact-client.js +0 -1
  69. package/dist/clients/artifacts/base-artifact-client.d.ts +0 -14
  70. package/dist/clients/artifacts/base-artifact-client.js +0 -1
  71. package/dist/clients/artifacts/object-based-artifact-client.d.ts +0 -11
  72. package/dist/clients/artifacts/object-based-artifact-client.js +0 -1
  73. package/dist/clients/custom-field-client.js +0 -1
  74. package/dist/clients/custom-schema-client.js +0 -1
  75. package/dist/constants/artifact.js +0 -1
  76. package/dist/constants/config-var.js +0 -1
  77. package/dist/constants/config-variable-constants.js +0 -1
  78. package/dist/constants/mobile-notification.js +0 -1
  79. package/dist/constants/tenant-objects.js +0 -1
  80. /package/dist/{interfaces/custom-field.js → core/base-config.js} +0 -0
  81. /package/dist/{interfaces/custom-schema.js → core/tenant-entities.js} +0 -0
package/CHANGELOG.md CHANGED
@@ -1,9 +1,21 @@
1
1
  # Changelog
2
2
 
3
+ ## [v0.0.8] - 2025-02-17
4
+ ### Added
5
+ - GraphBatch
6
+
7
+ ### Deprecated
8
+ - BatchOrchestrator
9
+
10
+
11
+ ## [v0.0.7] - 2025-02-13
12
+ ### Added
13
+ - Geo API Client, Geo Service, Resource Builder, Resource Validator
14
+
3
15
  ## [v0.0.6] - 2025-02-06
4
16
  ### Added
5
17
  - API Clients for Artifact, Vocabulary, Config Templates, and Org Preference, Notification APIs.
6
18
 
7
- ## [v0.0.5] - 2025-03-03
19
+ ## [v0.0.5] - 2025-02-03
8
20
  ### Initial Release
9
21
  - First version of the project.
package/README.md CHANGED
@@ -13,12 +13,17 @@
13
13
  - [Config Features (Feature Flags) Client](#config-features-feature-flags-client)
14
14
  - [Mobile Notification Client](#mobile-notification-client)
15
15
  - [Configuration Templates](#configuration-templates)
16
+ - [Geoservices Client](#geoservices-client)
16
17
  - [Artifact Client](#artifact-client)
17
18
  - [GraphQL Service](#graphql-service)
18
19
  - [Query Data](#query-data)
19
20
  - [Update Data](#update-data)
20
21
  - [Pagination with Offset](#pagination-with-offset)
21
22
  - [Pagination with Cursor](#pagination-with-cursor)
23
+ - [Resource Service](#resource-service)
24
+ - [Resource Builder](#resource-builder)
25
+ - [Resource Validator](#resource-validator)
26
+ - [GeoService](#geoservice)
22
27
  - [Batch Service](#batch-service)
23
28
  - [Cache Service](#cache-service)
24
29
  - [Logging Utils](#logging-utils)
@@ -42,15 +47,25 @@ yarn add @skedulo/pulse-solution-services
42
47
 
43
48
  **From a function**
44
49
  ```javascript
45
- const context = ExecutionContext.fromContext(skedToken);
50
+ const context = ExecutionContext.fromContext(skedToken, {
51
+ requestSource: "my-cool-project",
52
+ userAgent: "my-cool-function"
53
+ } as ExecutionOptions);
46
54
  ```
55
+
56
+ The `requestSource` and `userAgent` options are important for observability and debugging, as they set the value for the `X-Skedulo-Source` and `User-Agent` headers that are automatically included in all requests made within this context.
57
+
47
58
  **From other execution contexts**
48
59
  ```javascript
49
60
  const context = ExecutionContext.fromCredentials({
50
61
  apiServer: user.apiBasePath,
51
- apiToken: user.user.accessToken,
52
- });
62
+ apiToken: user.accessToken,
63
+ }, {
64
+ requestSource: "my-cool-project",
65
+ userAgent: "my-cool-function"
66
+ } as ExecutionOptions);
53
67
  ```
68
+ Once initialized, the context object provides access to the various services detailed in subsequent sections.
54
69
  ### API Clients
55
70
 
56
71
  #### Metadata Client
@@ -89,7 +104,7 @@ const updatedVocabularyItem = await context.vocabularyClient.updateVocabularyIte
89
104
  #### GraphQL Client
90
105
  Executes GraphQL queries and mutations against `/graphql/graphql`.
91
106
  ```javascript
92
- const queryResult = await context.graphqlClient.query(queryParams);
107
+ const queryResult = await context.graphqlClient.execute(queryString, {readOnly: true});
93
108
  ```
94
109
 
95
110
  #### Config Variable Client
@@ -207,7 +222,7 @@ const result: Record<string,string> = await context.configTemplateClient.delete(
207
222
  **Template Values**
208
223
  ```javascript
209
224
  // Get template values
210
- const values: {result: ConfigValue[]} = await context.configTemplateClient.getTemmplateValues(templateId);
225
+ const values: ConfigValue[] = await context.configTemplateClient.getTemmplateValues(templateId);
211
226
 
212
227
  // Create a new template and values
213
228
  const newTemplate: ConfigTemplate = {
@@ -236,6 +251,73 @@ const newValues = await context.configTemplateClient.upsertTemplateValues(create
236
251
  console.log(JSON.stringify(newValues, null, 2));
237
252
  ```
238
253
 
254
+ #### Geo API Client
255
+ Provides access to geolocation-related services via the `/geoservices` endpoints.
256
+
257
+ ```javascript
258
+ // Calls /distanceMatrix endpoint to compute travel distance and time
259
+ const distanceMatrix: DistanceMatrixResponse = await context.geoAPIClient.getDistanceMatrix({
260
+ origins: [{ lat: 37.7749, lng: -122.4194 }],
261
+ destinations: [{ lat: 34.0522, lng: -118.2437 }],
262
+ avoid: ["highway"],
263
+ });
264
+
265
+ // Calls /directions endpoint to fetch directions between two locations
266
+ const directions: DirectionsResponse = await context.geoAPIClient.getDirections({
267
+ requests: [{
268
+ origin: { lat: 37.7749, lng: -122.4194 },
269
+ destination: { lat: 34.0522, lng: -118.2437 },
270
+ waypoints: [{ lat: 36.7783, lng: -119.4179 }],
271
+ avoid: ["toll"],
272
+ }],
273
+ });
274
+
275
+ // Calls /geocode endpoint to retrieve latitude and longitude for an address
276
+ const geocode: GeocodeResponse = await context.geoAPIClient.geocodeAddress({
277
+ addresses: ["1600 Amphitheatre Parkway, Mountain View, CA"],
278
+ });
279
+
280
+ // Calls /autocomplete endpoint to get address suggestions
281
+ const autocomplete = await context.geoAPIClient.autocompleteAddress({
282
+ input: "1600 Amphi",
283
+ sessionId: "unique-session-id",
284
+ location: { lat: 37.7749, lng: -122.4194 },
285
+ radius: 5000,
286
+ country: "US",
287
+ });
288
+
289
+ // Calls /place endpoint to fetch place details using a place ID
290
+ const placeDetails = await context.geoAPIClient.getPlaceDetails({
291
+ placeId: "ChIJ2eUgeAK6j4ARbn5u_wAGqWA",
292
+ sessionId: "unique-session-id",
293
+ });
294
+
295
+ // Calls /timezone endpoint to fetch timezone information for a location
296
+ const timezone: TimezoneResponse = await context.geoAPIClient.getTimezone({
297
+ location: [37.7749, -122.4194],
298
+ timestamp: Math.floor(Date.now() / 1000),
299
+ });
300
+ ```
301
+
302
+ #### Availability API Client
303
+ ```javascript
304
+ // Calls /availability/simple endpoint to retrieve availability for resources
305
+ const resourceAvailability: AvailabilityResult[] = await context.availabilityAPIClient.fetchAvailability({
306
+ resourceIds: ["resource_123", "resource_456"],
307
+ start: "2024-06-01T00:00:00Z",
308
+ end: "2024-06-02T00:00:00Z",
309
+ mergedAvailabilities: false, // Optional, defaults to false
310
+ entries: true // Optional, defaults to true
311
+ });
312
+
313
+ // Example: Accessing merged availability intervals
314
+ console.log(availability[0].mergedAvailabilities);
315
+
316
+ // Example: Accessing detailed availability entries
317
+ console.log(availability[0].entries);
318
+
319
+ ```
320
+
239
321
  #### Artifact Client
240
322
  The `ArtifactClient` provides a unified way to manage various artifact types.
241
323
  ```javascript
@@ -305,12 +387,16 @@ await client.delete(
305
387
  #### Query data
306
388
  ```javascript
307
389
  // Create a query builder for the Resources object
308
- const queryBuilder = context.newQueryBuilder('Resources')
309
- .withFields(['UID', 'Name'])
310
- .withFilter('IsActive == true')
311
- .withLimit(1)
312
- .withOffset(1)
313
- .withOrderBy('Name ASC');
390
+ const queryBuilder = context.newQueryBuilder({
391
+ objectName: 'Resources',
392
+ operationName: 'fetchJobWithJobAllocations',
393
+ readOnly: true
394
+ });
395
+ queryBuilder.withFields(['UID', 'Name'])
396
+ .withFilter('IsActive == true')
397
+ .withLimit(1)
398
+ .withOffset(1)
399
+ .withOrderBy('Name ASC');
314
400
  // Add a child query for Job Allocations
315
401
  queryBuilder.withChildQuery('JobAllocations')
316
402
  .withFields(['UID', 'Name'])
@@ -319,7 +405,7 @@ queryBuilder.withChildQuery('JobAllocations')
319
405
  // Add a parent query for Primary Region
320
406
  queryBuilder.withParentQuery('PrimaryRegion')
321
407
  .withFields(['UID', 'Name']);
322
- // Finally, execute the query via your GraphQL service
408
+ // Finally, execute the query
323
409
  let queryResult = await queryBuilder.execute();
324
410
 
325
411
  console.log(queryResult.records);
@@ -328,6 +414,9 @@ console.log(queryResult.pageInfo.hasNextPage); // true
328
414
  console.log(queryResult.endCursor); // Mg==
329
415
  console.log(queryResult.endOffset); // 1
330
416
  ```
417
+
418
+ The `X-Graphql-Operation` header is added to all GraphQL requests and contains the value of `operationName`.
419
+
331
420
  #### Update data
332
421
  ```javascript
333
422
  const recordsToUpdate = queryResult.records.map((record) => {
@@ -336,8 +425,17 @@ const recordsToUpdate = queryResult.records.map((record) => {
336
425
  Name: record.Name + " - Updated"
337
426
  }
338
427
  });
339
- const updateResult = await context.graphqlService.update('Resources', recordsToUpdate);
428
+ const updateResult = await context.graphqlService.mutate({
429
+ objectName: 'Resources',
430
+ operation: GraphqlOperations.UPDATE,
431
+ operationName: 'updateResources',
432
+ records: recordsToUpdate,
433
+ bulkOperation: true // optional
434
+ });
340
435
  ```
436
+
437
+ The `bulkOperation` and `readOnly` options help optimize large-scale mutations and read-heavy queries. When enabled, they automatically add the `X-Skedulo-Bulk-Operation` (for mutations) and `X-Skedulo-Read-Only` (for queries) headers to improve performance.
438
+
341
439
  #### Pagination with offset
342
440
  ```javascript
343
441
  while(queryResult.pageInfo.hasNextPage) {
@@ -353,27 +451,225 @@ while(queryResult.pageInfo.hasNextPage) {
353
451
  }
354
452
  ```
355
453
 
454
+ ### Resource Service
455
+ The Resource Service consists of two main components:
456
+
457
+ - **Resource Builder**: Retrieves resource information, including availability, scheduled jobs, activities, tags, etc
458
+ - **Resource Validator**: Validates which resources are available for which jobs based on given conditions.
459
+
460
+ #### Resource Builder
461
+
462
+ The Resource Builder retrieves resource data, including availability, activities, scheduled jobs, tags, and other relevant details. By default, it enables the following options: `useTag`, `useJobAllocation`, `useResourceShift`, `useActivity`, `useAvailabilityPattern`, and `useHoliday`, with a time range set to 14 days from the current time.
463
+
464
+ **Usage**
465
+ ```javascript
466
+ // Define query parameters for resource fetching
467
+ const params = new ResourceQueryParam();
468
+ params.regionIds = new Set(['<region_id>']);
469
+ // Override default values
470
+ params.useTag = false;
471
+ params.startTime = new Date();
472
+ params.endTime = new Date(new Date().getTime() + 7 * 24 * 60 * 60 * 1000);// next 7 days from now
473
+
474
+ // Build resources with the given parameters
475
+ const resources = await context.resourceBuilder.build(params);
476
+ console.log(resources);
477
+ ```
478
+
479
+ #### Resource Validator
480
+ The Resource Validator takes a list of resources and jobs, and determines which resources are qualified to perform the jobs based on:
481
+
482
+ - Availability: Is the resource available during the job's timeframe?
483
+ - Conflict Detection: Does the resource already have conflicting events (e.g., another job, activity, or time-off)?
484
+ - Tag Matching: Does the resource have the required skills for the job?
485
+
486
+ **Usage**
487
+ ```javascript
488
+ // Fetch jobs using GraphQL
489
+ const jobQueryResult = await context
490
+ .newQueryBuilder({ objectName: "Jobs", operationName: "fetchJobs", readOnly: true })
491
+ .withLimit(2)
492
+ .withFields(TenantObjects.Jobs.Fields)
493
+ .execute();
494
+
495
+ // Convert raw job data into structured Job entities
496
+ const jobs: Job[] = jobQueryResult.records.map((job) => EntityFactory.createJob(job));
497
+
498
+ // Define validation options
499
+ const validationOptions = {
500
+ checkAvailability: true, // Check if the resource is available
501
+ checkConflict: true, // Check for conflicting events
502
+ checkTag: true // Check if the resource has the required skills
503
+ };
504
+
505
+ // Create a validator instance
506
+ const validator = new ResourceValidator(validationOptions);
507
+
508
+ // Run validation
509
+ const result: ValidationResult = validator.validate(resources, jobs);
510
+
511
+ // Output results
512
+ console.log(JSON.stringify(result, null, 2));
513
+
514
+ const resourcesQualifiedForAtleastOneJob = result.getQualifiedResources();
515
+ const jobsWithAtLeastXQualifiedResources = result.getJobsWithXQualifiedResources(2);
516
+ const unqualifiedJobsWithReasons = result.getUnqualifiedJobsWithReasons();
517
+ ```
518
+ **Validation Output**
519
+ The Resource Validator returns a structured JSON output indicating which resources are qualified, and the reasons why certain jobs are not assigned. The results can be formatted to present a clearer qualification status along with detailed reasons.
520
+ ```javascript
521
+ console.log(JSON.stringify(result.format(), null, 2));
522
+
523
+ /*
524
+ [
525
+ {
526
+ "resource": {
527
+ "id": "0005fcae-3c63-46c0-8533-b2e154c25040",
528
+ "name": "Tracey Rodriguez"
529
+ },
530
+ "job": {
531
+ "id": "00143a8e-7958-4df1-8ade-767b19e9aff8",
532
+ "name": "JOB-71777"
533
+ },
534
+ "qualificationStatus": "Qualified",
535
+ "reasons": []
536
+ },
537
+ {
538
+ "resource": {
539
+ "id": "0005fcae-3c63-46c0-8533-b2e154c25040",
540
+ "name": "Tracey Rodriguez"
541
+ },
542
+ "job": {
543
+ "id": "0014bfb0-2993-4d6a-ad25-ed5d9c79de14",
544
+ "name": "JOB-71743"
545
+ },
546
+ "qualificationStatus": "Not Qualified",
547
+ "reasons": [
548
+ {
549
+ "reason": "Conflict Detected",
550
+ "conflictingEvents": [
551
+ {
552
+ "id": "2025-02-13T14:00:00.000Z_2025-02-14T14:00:00.000Z",
553
+ "name": "Regional Holiday",
554
+ "eventType": "holiday"
555
+ }
556
+ ]
557
+ }
558
+ ]
559
+ }
560
+ ]
561
+ */
562
+ ```
563
+
564
+ ### GeoService
565
+ Provides a high-level interface for geolocation-related operations, built on top of `GeoAPIClient`.
566
+
567
+ **Get Distance Matrix**
568
+ Computes travel distance and duration between origins and destinations. Handles cases where no route is available.
569
+ ```javascript
570
+ const origins = [{ lat: 55.93, lng: -3.118 }, { lat: 50.087, lng: 14.421 }];
571
+ const destinations = [{ lat: 50.087, lng: 14.421 }, { lat: 0, lng: 0 }];
572
+
573
+ const distanceMatrix: Map<string, DistanceMatrixEntry> = await context.geoService.getDistanceMatrix(origins, destinations);
574
+
575
+ for(const origin of origins) {
576
+ for(const destination of destinations) {
577
+ const key = context.geoService.createKey(origin, destination);
578
+ const entry = distanceMatrix.get(key);
579
+ console.log(`Origin-Destination: ${key} - Status: ${entry?.status}`);
580
+ if(entry?.status === "OK") {
581
+ console.log(`Distance: ${entry?.distance?.distanceInMeters} meters`);
582
+ console.log(`Duration: ${entry?.duration?.durationInSeconds} seconds`);
583
+ }
584
+ }
585
+ }
586
+ ```
587
+
588
+ **Get Address Suggestions**
589
+ Fetches address autocomplete suggestions and retrieves detailed place information.
590
+ ```javascript
591
+ const input = "1600 Amphitheatre Pkwy";
592
+ const suggestions: PlaceResponse[]|null = await context.geoService.getAddressSuggestions({ input, country: 'US' }, 2);
593
+
594
+ if (suggestions) {
595
+ suggestions.forEach((place, index) => {
596
+ console.log(`Place ${index + 1}: ${place.formattedAddress}`);
597
+ console.log(`Latitude: ${place.geometry.lat}, Longitude: ${place.geometry.lng}`);
598
+ });
599
+ } else {
600
+ console.log("No place details found.");
601
+ }
602
+ ```
603
+
356
604
  ### Batch Service
357
605
  The Batch Service offers a flexible and scalable solution for large-scale data processing.
606
+
607
+ #### How to Use
608
+ 1. Create a subclass of GraphBatch that encapsulates the specific logic for your batch job.
609
+ 2. Override the `start` method to return a configured GraphQLQueryBuilder object. This builder should set up the query fields, filters, and any required ordering.
610
+ 3. Override the `execute` method to implement the logic to process each batch of records (e.g., updates, deletes, logging).
611
+ 4. Optionally override the `finish` method to perform any final cleanup, such as logging the results or sending notifications.
612
+ 5. Run the batch.
613
+
614
+ #### Example
615
+ Below is an example of bulk job update.
358
616
  ```javascript
359
- const job = {
360
- CreatedDate: new Date().toISOString(),
361
- JobType: 'Delete',
362
- ObjectName: 'Accounts',
363
- Fields: "UID",
364
- BatchSize: 100,
365
- MaximumBatches: 10
366
- };
617
+ import {
618
+ GraphBatch,
619
+ GraphqlOperations,
620
+ GraphQLQueryBuilder,
621
+ } from "@skedulo/pulse-solution-services";
622
+
623
+ export class BulkJobUpdate extends GraphBatch {
624
+ public result: string[] = [];
625
+
626
+ // This method is called once at the beginning of the batch process.
627
+ protected async start(): Promise<GraphQLQueryBuilder> {
628
+ const queryBuilder = this.context
629
+ .newQueryBuilder({objectName: "Jobs", operationName: "fetchJobsWithRegion"})
630
+ .withFields(["UID", "Name", "Start"])
631
+ .withOrderBy("Name ASC");
632
+ queryBuilder.withParentQuery("Region").withFields(["UID", "Name"]);
633
+
634
+ return queryBuilder;
635
+ }
636
+
637
+ // This method is called for each batch of records.
638
+ protected async execute(records: any[]): Promise<void> {
639
+
640
+ const recordsToUpdate = records.map((record) => ({
641
+ UID: record.UID,
642
+ Description: `${record.Name} scheduled for ${new Date(record.Start).toLocaleDateString("en-GB")} in ${record.Region.Name}`,
643
+ }));
644
+ await this.context.graphqlService.mutate({
645
+ objectName: "Jobs",
646
+ operation: GraphqlOperations.UPDATE,
647
+ operationName: "updateJobs",
648
+ records: recordsToUpdate
649
+ });
650
+ this.result.push(...records.map((record) => record.Name));
651
+ }
367
652
 
653
+ // This method is called once at the end of the batch process.
654
+ protected async finish(): Promise<void> {
655
+ this.context.logger.info(`Processed ${this.result.length} records.`);
656
+ }
657
+ }
658
+ ```
659
+
660
+ Run the batch
661
+ ```javascript
368
662
  const context = ExecutionContext.fromCredentials({
369
663
  apiServer: user.apiBasePath,
370
664
  apiToken: user.user.accessToken,
371
665
  });
372
- context.contextData.job = job;
373
- const orchestrator = new BatchOrchestrator(context, {
374
- isAsyncProcessing: false,
666
+ const batch = new BulkJobUpdate(context, {
667
+ batchSize: 10,
668
+ maxBatches: 10,
669
+ strategy: PaginationStrategy.CURSOR,
670
+ delaySeconds: 1,
375
671
  });
376
- await orchestrator.processBatchJob();
672
+ await batch.run();
377
673
  ```
378
674
 
379
675
  ### Cache Service
@@ -1 +1 @@
1
- "use strict";var __awaiter=this&&this.__awaiter||function(t,e,i,n){return new(i||(i=Promise))((function(o,r){function s(t){try{d(n.next(t))}catch(t){r(t)}}function a(t){try{d(n.throw(t))}catch(t){r(t)}}function d(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}d((n=n.apply(t,e||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.ArtifactClient=void 0;const constants_1=require("../constants"),base_client_1=require("./base-client");class ArtifactClient extends base_client_1.BaseClient{constructor(t,e){super(t),this.artifactType=e,this.baseEndpoint=`artifacts/${this.artifactType}`}list(){return __awaiter(this,void 0,void 0,(function*(){return this.performRequest({endpoint:this.baseEndpoint})}))}get(){return __awaiter(this,arguments,void 0,(function*(t={}){return this.performRequest({endpoint:this.buildEndpoint(t)})}))}create(t,e){return __awaiter(this,void 0,void 0,(function*(){return this.performRequest({method:constants_1.HttpMethod.POST,endpoint:this.buildEndpoint(t),body:e})}))}update(t,e){return __awaiter(this,void 0,void 0,(function*(){return this.performRequest({method:constants_1.HttpMethod.PUT,endpoint:this.buildEndpoint(t),body:e})}))}delete(t){return __awaiter(this,void 0,void 0,(function*(){yield this.performRequest({method:constants_1.HttpMethod.DELETE,endpoint:this.buildEndpoint(t)})}))}buildEndpoint(t){const{objectName:e,viewTypeName:i,name:n,scope:o}=t;let r=this.baseEndpoint;return e&&(r+=`/${e}`),i&&(r+=`/${i}`),n&&(r+=`/${n}`),o&&(r+=`/${o}`),r}}exports.ArtifactClient=ArtifactClient;
1
+ "use strict";var __awaiter=this&&this.__awaiter||function(t,e,i,n){return new(i||(i=Promise))((function(o,r){function s(t){try{d(n.next(t))}catch(t){r(t)}}function a(t){try{d(n.throw(t))}catch(t){r(t)}}function d(t){var e;t.done?o(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(s,a)}d((n=n.apply(t,e||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.ArtifactClient=void 0;const constants_1=require("../constants"),base_client_1=require("./base-client");class ArtifactClient extends base_client_1.BaseClient{constructor(t,e,i={}){super(t,i),this.artifactType=e,this.baseEndpoint=`artifacts/${this.artifactType}`}list(){return __awaiter(this,void 0,void 0,(function*(){return this.performRequest({endpoint:this.baseEndpoint})}))}get(){return __awaiter(this,arguments,void 0,(function*(t={}){return this.performRequest({endpoint:this.buildEndpoint(t)})}))}create(t,e){return __awaiter(this,void 0,void 0,(function*(){return this.performRequest({method:constants_1.HttpMethod.POST,endpoint:this.buildEndpoint(t),body:e})}))}update(t,e){return __awaiter(this,void 0,void 0,(function*(){return this.performRequest({method:constants_1.HttpMethod.PUT,endpoint:this.buildEndpoint(t),body:e})}))}delete(t){return __awaiter(this,void 0,void 0,(function*(){yield this.performRequest({method:constants_1.HttpMethod.DELETE,endpoint:this.buildEndpoint(t)})}))}buildEndpoint(t){const{objectName:e,viewTypeName:i,name:n,scope:o}=t;let r=this.baseEndpoint;return e&&(r+=`/${e}`),i&&(r+=`/${i}`),n&&(r+=`/${n}`),o&&(r+=`/${o}`),r}}exports.ArtifactClient=ArtifactClient;
@@ -0,0 +1 @@
1
+ "use strict";var __awaiter=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))((function(r,s){function a(e){try{l(n.next(e))}catch(e){s(e)}}function o(e){try{l(n.throw(e))}catch(e){s(e)}}function l(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(a,o)}l((n=n.apply(e,t||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.AvailabilityAPIClient=void 0;const constants_1=require("../constants"),base_client_1=require("./base-client");class AvailabilityAPIClient extends base_client_1.BaseClient{fetchAvailability(e){return __awaiter(this,void 0,void 0,(function*(){var t,i,n,r;if(!e.resourceIds.length)throw new Error("At least one resource ID must be provided.");const s={resource_ids:e.resourceIds.join(","),start:e.start,end:e.end,mergedAvailabilities:null!==(i=null===(t=e.mergedAvailabilities)||void 0===t?void 0:t.toString())&&void 0!==i?i:"false",entries:null!==(r=null===(n=e.entries)||void 0===n?void 0:n.toString())&&void 0!==r?r:"true"};return yield this.performRequest({endpoint:constants_1.TENANT_ENDPOINTS.AVAILABILITY.SIMPLE,queryParams:s})}))}}exports.AvailabilityAPIClient=AvailabilityAPIClient;
@@ -1 +1 @@
1
- "use strict";var __decorate=this&&this.__decorate||function(e,t,n,r){var o,i=arguments.length,a=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,n,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,n,a):o(t,n))||a);return i>3&&a&&Object.defineProperty(t,n,a),a},__metadata=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},__awaiter=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function a(e){try{c(r.next(e))}catch(e){i(e)}}function s(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(a,s)}c((r=r.apply(e,t||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.BaseClient=void 0;const logging_1=require("../logging");class BaseClient{constructor(e){this.config=e}getHeaders(){return{Authorization:`Bearer ${this.config.apiToken}`,"Content-Type":"application/json"}}buildUrl(e,t){const n=new URL(`${this.config.apiServer}/${e}`);return t&&Object.entries(t).forEach((([e,t])=>{n.searchParams.append(e,t)})),n.toString()}performRequest(e){return __awaiter(this,arguments,void 0,(function*({method:e="GET",endpoint:t,headers:n={},body:r,queryParams:o}){try{const i=Object.assign(Object.assign({},this.getHeaders()),n),a=this.buildUrl(t,o),s=yield fetch(a,{method:e,headers:i,body:r&&"GET"!==e?JSON.stringify(r):void 0});let c;const d=s.headers.get("content-type");if(d&&d.includes("application/json")?(c=yield s.json(),c.result&&(c=c.result)):c=yield s.text(),!s.ok)throw new Error(`HTTP error! Status: ${s.status}. Response: ${JSON.stringify(c)}`);return c}catch(e){throw this.handleException(e),e}}))}handleException(e){}}exports.BaseClient=BaseClient,__decorate([(0,logging_1.LogMethod)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],BaseClient.prototype,"performRequest",null);
1
+ "use strict";var __decorate=this&&this.__decorate||function(e,t,n,r){var o,i=arguments.length,s=i<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,r);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(s=(i<3?o(s):i>3?o(t,n,s):o(t,n))||s);return i>3&&s&&Object.defineProperty(t,n,s),s},__metadata=this&&this.__metadata||function(e,t){if("object"==typeof Reflect&&"function"==typeof Reflect.metadata)return Reflect.metadata(e,t)},__awaiter=this&&this.__awaiter||function(e,t,n,r){return new(n||(n=Promise))((function(o,i){function s(e){try{c(r.next(e))}catch(e){i(e)}}function a(e){try{c(r.throw(e))}catch(e){i(e)}}function c(e){var t;e.done?o(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,a)}c((r=r.apply(e,t||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.BaseClient=void 0;const request_header_constants_1=require("../core/request-header-constants"),logging_1=require("../logging");class BaseClient{constructor(e,t={}){this.config=e,this.executionOptions=t}performRequest(e){return __awaiter(this,arguments,void 0,(function*({method:e="GET",endpoint:t,headers:n={},body:r,queryParams:o},i=this.executionOptions){try{const s=Object.assign(Object.assign({},this.getHeaders(i)),n),a=this.buildUrl(t,o),c=yield fetch(a,{method:e,headers:s,body:r&&"GET"!==e?JSON.stringify(r):void 0});let u;const d=c.headers.get("content-type");if(d&&d.includes("application/json")?(u=yield c.json(),u.result&&(u=u.result)):u=yield c.text(),!c.ok)throw new Error(`HTTP error! Status: ${c.status}. Response: ${JSON.stringify(u)}`);return u}catch(e){throw this.handleException(e),e}}))}getHeaders(e){var t,n;const r={Authorization:`Bearer ${this.config.apiToken}`,"Content-Type":"application/json"},o=e.requestSource||(null===(t=this.executionOptions)||void 0===t?void 0:t.requestSource),i=e.userAgent||(null===(n=this.executionOptions)||void 0===n?void 0:n.userAgent);return o&&(r[request_header_constants_1.REQUEST_HEADERS.X_SKEDULO_SOURCE]=o),i&&(r[request_header_constants_1.REQUEST_HEADERS.USER_AGENT]=i),r}buildUrl(e,t){const n=new URL(`${this.config.apiServer}/${e}`);return t&&Object.entries(t).forEach((([e,t])=>{n.searchParams.append(e,t)})),n.toString()}handleException(e){}}exports.BaseClient=BaseClient,__decorate([(0,logging_1.LogMethod)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object,Object]),__metadata("design:returntype",Promise)],BaseClient.prototype,"performRequest",null);
@@ -0,0 +1 @@
1
+ "use strict";var __awaiter=this&&this.__awaiter||function(t,e,n,o){return new(n||(n=Promise))((function(i,s){function r(t){try{c(o.next(t))}catch(t){s(t)}}function a(t){try{c(o.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(r,a)}c((o=o.apply(t,e||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.GeoAPIClient=void 0;const constants_1=require("../constants"),base_client_1=require("./base-client");class GeoAPIClient extends base_client_1.BaseClient{getDistanceMatrix(t){return __awaiter(this,void 0,void 0,(function*(){return this.performRequest({method:constants_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.GEOSERVICES.DISTANCE_MATRIX,body:t})}))}getDirections(t){return __awaiter(this,void 0,void 0,(function*(){return this.performRequest({method:constants_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.GEOSERVICES.DIRECTIONS,body:t})}))}geocodeAddress(t){return __awaiter(this,void 0,void 0,(function*(){return this.performRequest({method:constants_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.GEOSERVICES.GEOCODE,body:t})}))}autocompleteAddress(t){return __awaiter(this,void 0,void 0,(function*(){return this.performRequest({method:constants_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.GEOSERVICES.AUTOCOMPLETE,body:t})}))}getPlaceDetails(t){return __awaiter(this,void 0,void 0,(function*(){return this.performRequest({method:constants_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.GEOSERVICES.PLACE,body:t})}))}getTimezone(t){return __awaiter(this,void 0,void 0,(function*(){return this.performRequest({method:constants_1.HttpMethod.GET,endpoint:constants_1.TENANT_ENDPOINTS.GEOSERVICES.TIMEZONE,queryParams:{location:t.location.join(","),timestamp:t.timestamp.toString()}})}))}}exports.GeoAPIClient=GeoAPIClient;
@@ -1 +1 @@
1
- "use strict";var __awaiter=this&&this.__awaiter||function(t,e,n,i){return new(n||(n=Promise))((function(r,o){function s(t){try{c(i.next(t))}catch(t){o(t)}}function a(t){try{c(i.throw(t))}catch(t){o(t)}}function c(t){var e;t.done?r(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}c((i=i.apply(t,e||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.GraphQLClient=void 0;const constants_1=require("../constants"),http_1=require("../constants/http"),base_client_1=require("./base-client");class GraphQLClient extends base_client_1.BaseClient{execute(t){return __awaiter(this,void 0,void 0,(function*(){return yield this.performRequest({method:http_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.GRAPHQL,body:{query:t}})}))}}exports.GraphQLClient=GraphQLClient;
1
+ "use strict";var __awaiter=this&&this.__awaiter||function(t,e,n,r){return new(n||(n=Promise))((function(i,s){function a(t){try{c(r.next(t))}catch(t){s(t)}}function o(t){try{c(r.throw(t))}catch(t){s(t)}}function c(t){var e;t.done?i(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(a,o)}c((r=r.apply(t,e||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.GraphQLClient=void 0;const constants_1=require("../constants"),http_1=require("../constants/http"),base_client_1=require("./base-client");class GraphQLClient extends base_client_1.BaseClient{execute(t){return __awaiter(this,arguments,void 0,(function*(t,e={}){return yield this.performRequest({method:http_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.GRAPHQL,body:{query:t},headers:e})}))}}exports.GraphQLClient=GraphQLClient;
@@ -0,0 +1 @@
1
+ "use strict";var GraphqlOperations;Object.defineProperty(exports,"__esModule",{value:!0}),exports.GraphqlOperations=void 0,function(e){e.INSERT="insert",e.UPDATE="update",e.DELETE="delete",e.UPSERT="upsert"}(GraphqlOperations||(exports.GraphqlOperations=GraphqlOperations={}));
@@ -1 +1 @@
1
- "use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(t,e,r,o){void 0===o&&(o=r);var n=Object.getOwnPropertyDescriptor(e,r);n&&!("get"in n?!e.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,o,n)}:function(t,e,r,o){void 0===o&&(o=r),t[o]=e[r]}),__exportStar=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||__createBinding(e,t,r)};Object.defineProperty(exports,"__esModule",{value:!0}),__exportStar(require("./artifact-constants"),exports),__exportStar(require("./config-var-constants"),exports),__exportStar(require("./http"),exports),__exportStar(require("./mobile-notification-constants"),exports),__exportStar(require("./tenant-endpoints"),exports),__exportStar(require("./tenant-objects"),exports);
1
+ "use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(t,e,r,o){void 0===o&&(o=r);var n=Object.getOwnPropertyDescriptor(e,r);n&&!("get"in n?!e.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return e[r]}}),Object.defineProperty(t,o,n)}:function(t,e,r,o){void 0===o&&(o=r),t[o]=e[r]}),__exportStar=this&&this.__exportStar||function(t,e){for(var r in t)"default"===r||Object.prototype.hasOwnProperty.call(e,r)||__createBinding(e,t,r)};Object.defineProperty(exports,"__esModule",{value:!0}),__exportStar(require("./artifact-constants"),exports),__exportStar(require("./config-var-constants"),exports),__exportStar(require("./graphql-constants"),exports),__exportStar(require("./http"),exports),__exportStar(require("./mobile-notification-constants"),exports),__exportStar(require("./tenant-endpoints"),exports);
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.TENANT_ENDPOINTS=void 0,exports.TENANT_ENDPOINTS={CONFIG_VAR:{CREATE:"configuration/extension",GET:t=>`configuration/extension/${t}`,UPDATE:t=>`configuration/extension/${t}`,DELETE:t=>`configuration/extension/${t}`,SEARCH:"configuration/extension/search"},GRAPHQL:"graphql/graphql",METADATA:{ALL:"custom/metadata",OBJECT:t=>`custom/metadata/${t}`},ORG_PREFERENCE:{GET:"config/org_preference",UPDATE:"config/org_preference"},CONFIG_TEMPLATE:{GET_TEMPLATES:t=>`config/templates/${t}`,GET_VALUES:t=>`config/template/${t}/values`,UPDATE_VALUES:t=>`config/template/${t}/values`,CREATE:"config/template",DELETE:t=>`config/template/${t}`},CONFIG_FEATURES:{GET:"config/features",UPDATE:t=>`config/features/${t}`},VOCABULARY:{GET_ITEMS:(t,o)=>`custom/vocabulary/${t}/${o}`,ADD_ITEM:(t,o)=>`custom/vocabulary/${t}/${o}`,UPDATE_ITEM:(t,o,i)=>`custom/vocabulary/${t}/${o}/${i}`},NOTIFICATIONS:{GET_TEMPLATES:"notifications/v2/templates",DELETE_TEMPLATE:(t,o)=>`notifications/v2/template/${t}/${o}`,SET_TEMPLATE:(t,o)=>`notifications/v2/template/${t}/${o}`,DISPATCH:"notifications/dispatch",NOTIFY:"notifications/notify",NOTIFY_CANCEL:"notifications/notify_cancel",ONE_OFF:"notifications/oneoff",SEND_SMS:"notifications/sms",SMS_CONFIRMATION_REQUEST:"notifications/sms/confirmation_request"}};
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.TENANT_ENDPOINTS=void 0,exports.TENANT_ENDPOINTS={CONFIG_VAR:{CREATE:"configuration/extension",GET:e=>`configuration/extension/${e}`,UPDATE:e=>`configuration/extension/${e}`,DELETE:e=>`configuration/extension/${e}`,SEARCH:"configuration/extension/search"},GRAPHQL:"graphql/graphql",METADATA:{ALL:"custom/metadata",OBJECT:e=>`custom/metadata/${e}`},ORG_PREFERENCE:{GET:"config/org_preference",UPDATE:"config/org_preference"},CONFIG_TEMPLATE:{GET_TEMPLATES:e=>`config/templates/${e}`,GET_VALUES:e=>`config/template/${e}/values`,UPDATE_VALUES:e=>`config/template/${e}/values`,CREATE:"config/template",DELETE:e=>`config/template/${e}`},CONFIG_FEATURES:{GET:"config/features",UPDATE:e=>`config/features/${e}`},VOCABULARY:{GET_ITEMS:(e,o)=>`custom/vocabulary/${e}/${o}`,ADD_ITEM:(e,o)=>`custom/vocabulary/${e}/${o}`,UPDATE_ITEM:(e,o,i)=>`custom/vocabulary/${e}/${o}/${i}`},NOTIFICATIONS:{GET_TEMPLATES:"notifications/v2/templates",DELETE_TEMPLATE:(e,o)=>`notifications/v2/template/${e}/${o}`,SET_TEMPLATE:(e,o)=>`notifications/v2/template/${e}/${o}`,DISPATCH:"notifications/dispatch",NOTIFY:"notifications/notify",NOTIFY_CANCEL:"notifications/notify_cancel",ONE_OFF:"notifications/oneoff",SEND_SMS:"notifications/sms",SMS_CONFIRMATION_REQUEST:"notifications/sms/confirmation_request"},GEOSERVICES:{DISTANCE_MATRIX:"geoservices/distanceMatrix",DIRECTIONS:"geoservices/directions",GEOCODE:"geoservices/geocode",AUTOCOMPLETE:"geoservices/autocomplete",PLACE:"geoservices/place",TIMEZONE:"geoservices/timezone"},AVAILABILITY:{SIMPLE:"availability/simple"}};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.EntityFactory=void 0;class EntityFactory{static createBaseObject(e){return{id:e.UID||"",name:e.Name||"",propertyMap:{}}}static createBaseEvent(e){const t=e.Finish?e.Finish:e.End;return Object.assign(Object.assign({},this.createBaseObject(e)),{start:new Date(e.Start),finish:new Date(t),eventType:e.Type||""})}static createTag(e){return this.createBaseObject(e)}static createResource(e){var t;return Object.assign(Object.assign({},this.createBaseObject(e)),{category:e.Category||"",employmentType:e.EmploymentType||"",resourceType:e.ResourceType||"",userId:e.UserId||"",regionId:e.PrimaryRegionId||"",timezone:(null===(t=e.PrimaryRegion)||void 0===t?void 0:t.Timezone)||"",tags:(e.ResourceTags||[]).map((e=>this.createTag(e.Tag))),availabilities:[],events:[]})}static createJob(e){return Object.assign(Object.assign({},this.createBaseEvent(e)),{jobStatus:e.JobStatus||"",regionId:e.RegionId||"",contactId:e.ContactId||"",geoLocation:e.GeoLocation||{lat:e.GeoLatitude,lng:e.GeoLongitude},address:e.Address,eventType:"job",tags:(e.JobTags||[]).map((e=>this.createTag(e.Tag)))})}static createAvailability(e){return Object.assign(Object.assign({},this.createBaseEvent(e)),{resourceId:e.resourceId||"",isAvailable:!0===e.isAvailable||"true"===e.isAvailable,status:e.status||"",availabilityType:e.availabilityType||""})}static createActivity(e){return Object.assign(Object.assign({},this.createBaseEvent(e)),{resourceId:e.resourceId||"",activityType:e.activityType||""})}static createJobAllocation(e){return Object.assign(Object.assign({},this.createBaseEvent(e)),{jobId:e.jobId||"",resourceId:e.resourceId||"",status:e.status||""})}static createResourceShift(e){return Object.assign(Object.assign({},this.createBaseEvent(e)),{resourceId:e.resourceId||"",shift:this.createShift(e.shift||{})})}static createShift(e){return Object.assign(Object.assign({},this.createBaseEvent(e)),{regionId:e.regionId||"",displayName:e.displayName||"",isDraft:!0===e.isDraft||"true"===e.isDraft})}}exports.EntityFactory=EntityFactory;
@@ -1 +1 @@
1
- "use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.ExecutionContext=void 0;const function_utilities_1=require("@skedulo/function-utilities"),artifact_client_1=require("../clients/artifact-client"),config_features_client_1=require("../clients/config-features-client"),config_template_client_1=require("../clients/config-template-client"),config_var_client_1=require("../clients/config-var-client"),graphql_client_1=require("../clients/graphql-client"),metadata_client_1=require("../clients/metadata-client"),mobile_notification_client_1=require("../clients/mobile-notification-client"),org_preference_client_1=require("../clients/org-preference-client"),vocabulary_client_1=require("../clients/vocabulary-client"),logger_1=__importDefault(require("../logging/logger")),cache_service_1=require("../services/cache/cache-service"),storage_1=require("../services/cache/storage"),graphql_1=require("../services/graphql"),metadata_service_1=require("../services/metadata-service"),utils_1=require("../utils");class ExecutionContext{constructor(e){this.logger=logger_1.default,this.services=new Map,this.skedContext=e,this.contextData={},this.baseConfig={apiToken:e.auth.token,apiServer:e.auth.baseUrl}}static fromContext(e){return new ExecutionContext(e)}static fromCredentials(e){const t={Authorization:`Bearer ${e.apiToken}`,"sked-api-server":e.apiServer},i=(0,function_utilities_1.createSkedContext)(t),r=new ExecutionContext(i);return r.baseConfig=Object.assign(Object.assign({},e),r.baseConfig),r}getOrCreateService(e,t){return this.services.has(e)||this.services.set(e,t()),this.services.get(e)}get configHelper(){return this.getOrCreateService("configHelper",(()=>new utils_1.ConfigHelper(this.skedContext.configVars)))}get graphqlClient(){return this.getOrCreateService("graphqlClient",(()=>new graphql_client_1.GraphQLClient(this.baseConfig)))}get graphqlService(){return this.getOrCreateService("graphqlService",(()=>new graphql_1.GraphQLService(this.graphqlClient)))}get metadataClient(){return this.getOrCreateService("metadataClient",(()=>new metadata_client_1.MetadataClient(this.baseConfig)))}get metadataService(){return this.getOrCreateService("metadataService",(()=>new metadata_service_1.MetadataService(this.metadataClient)))}get vocabularyClient(){return this.getOrCreateService("vocabularyClient",(()=>new vocabulary_client_1.VocabularyClient(this.baseConfig)))}get orgPreferencesClient(){return this.getOrCreateService("orgPreferencesClient",(()=>new org_preference_client_1.OrgPreferenceClient(this.baseConfig)))}get configTemplateClient(){return this.getOrCreateService("configTemplateClient",(()=>new config_template_client_1.ConfigTemplateClient(this.baseConfig)))}get configFeaturesClient(){return this.getOrCreateService("configFeaturesClient",(()=>new config_features_client_1.ConfigFeaturesClient(this.baseConfig)))}get configVarClient(){return this.getOrCreateService("configVarClient",(()=>new config_var_client_1.ConfigVarClient(this.baseConfig)))}get mobileNotificationClient(){return this.getOrCreateService("mobileNotificationClient",(()=>new mobile_notification_client_1.MobileNotificationClient(this.baseConfig)))}get configVarCache(){return this.getOrCreateService("configVarCache",(()=>new cache_service_1.CacheService(new storage_1.ConfigVarCacheStorage(this.configVarClient))))}get inMemoryCache(){return this.getOrCreateService("inMemoryCache",(()=>{const e=new cache_service_1.CacheService(new storage_1.InMemoryCacheStorage);return e.setSecondaryCache(this.configVarCache),e}))}newQueryBuilder(e){const t=new graphql_1.GraphQLQueryBuilder(e);return t.setGraphqlService(this.graphqlService),t}newArtifactClient(e){return this.getOrCreateService(`${e}Client`,(()=>new artifact_client_1.ArtifactClient(this.baseConfig,e)))}dispose(){this.services.clear()}}exports.ExecutionContext=ExecutionContext;
1
+ "use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.ExecutionContext=void 0;const function_utilities_1=require("@skedulo/function-utilities"),clients_1=require("../clients"),artifact_client_1=require("../clients/artifact-client"),availability_api_client_1=require("../clients/availability-api-client"),config_features_client_1=require("../clients/config-features-client"),config_template_client_1=require("../clients/config-template-client"),config_var_client_1=require("../clients/config-var-client"),geo_api_client_1=require("../clients/geo-api-client"),graphql_client_1=require("../clients/graphql-client"),metadata_client_1=require("../clients/metadata-client"),mobile_notification_client_1=require("../clients/mobile-notification-client"),org_preference_client_1=require("../clients/org-preference-client"),vocabulary_client_1=require("../clients/vocabulary-client"),logger_1=__importDefault(require("../logging/logger")),cache_service_1=require("../services/cache/cache-service"),storage_1=require("../services/cache/storage"),geoservice_1=require("../services/geoservice"),graphql_1=require("../services/graphql"),metadata_service_1=require("../services/metadata-service"),data_service_1=require("../services/resource-availability/builder/data-service"),resource_availability_service_1=require("../services/resource-availability/builder/resource-availability-service"),resource_builder_1=require("../services/resource-availability/builder/resource-builder"),utils_1=require("../utils"),request_header_constants_1=require("./request-header-constants");class ExecutionContext{constructor(e,i={}){this.logger=logger_1.default,this.services=new Map,this.skedContext=e,this.contextData={},this._executionOptions=i,this.baseConfig={apiToken:e.auth.token,apiServer:e.auth.baseUrl}}static fromContext(e,i={}){return new ExecutionContext(e,i)}static fromCredentials(e,i={}){const t={Authorization:`Bearer ${e.apiToken}`,[request_header_constants_1.REQUEST_HEADERS.SKED_API_SERVER]:e.apiServer},r=(0,function_utilities_1.createSkedContext)(t),n=new ExecutionContext(r,i);return n.baseConfig=Object.assign(Object.assign({},e),n.baseConfig),n}set executionOptions(e){this._executionOptions=Object.assign(Object.assign({},this._executionOptions),e)}get executionOptions(){return this._executionOptions}getOrCreateService(e,i){return this.services.has(e)||this.services.set(e,i()),this.services.get(e)}get configHelper(){return this.getOrCreateService("configHelper",(()=>new utils_1.ConfigHelper(this.skedContext.configVars)))}get baseClient(){return this.getOrCreateService("baseClient",(()=>new clients_1.BaseClient(this.baseConfig,this.executionOptions)))}get graphqlClient(){return this.getOrCreateService("graphqlClient",(()=>new graphql_client_1.GraphQLClient(this.baseConfig,this.executionOptions)))}get graphqlService(){return this.getOrCreateService("graphqlService",(()=>new graphql_1.GraphQLService(this.graphqlClient)))}get metadataClient(){return this.getOrCreateService("metadataClient",(()=>new metadata_client_1.MetadataClient(this.baseConfig,this.executionOptions)))}get metadataService(){return this.getOrCreateService("metadataService",(()=>new metadata_service_1.MetadataService(this.metadataClient)))}get vocabularyClient(){return this.getOrCreateService("vocabularyClient",(()=>new vocabulary_client_1.VocabularyClient(this.baseConfig,this.executionOptions)))}get orgPreferencesClient(){return this.getOrCreateService("orgPreferencesClient",(()=>new org_preference_client_1.OrgPreferenceClient(this.baseConfig,this.executionOptions)))}get configTemplateClient(){return this.getOrCreateService("configTemplateClient",(()=>new config_template_client_1.ConfigTemplateClient(this.baseConfig,this.executionOptions)))}get configFeaturesClient(){return this.getOrCreateService("configFeaturesClient",(()=>new config_features_client_1.ConfigFeaturesClient(this.baseConfig,this.executionOptions)))}get configVarClient(){return this.getOrCreateService("configVarClient",(()=>new config_var_client_1.ConfigVarClient(this.baseConfig,this.executionOptions)))}get mobileNotificationClient(){return this.getOrCreateService("mobileNotificationClient",(()=>new mobile_notification_client_1.MobileNotificationClient(this.baseConfig,this.executionOptions)))}get geoAPIClient(){return this.getOrCreateService("geoAPIClient",(()=>new geo_api_client_1.GeoAPIClient(this.baseConfig,this.executionOptions)))}get availabilityAPIClient(){return this.getOrCreateService("availabilityAPIClient",(()=>new availability_api_client_1.AvailabilityAPIClient(this.baseConfig,this.executionOptions)))}get geoService(){return this.getOrCreateService("geoService",(()=>new geoservice_1.GeoService(this.geoAPIClient)))}get configVarCache(){return this.getOrCreateService("configVarCache",(()=>new cache_service_1.CacheService(new storage_1.ConfigVarCacheStorage(this.configVarClient))))}get inMemoryCache(){return this.getOrCreateService("inMemoryCache",(()=>{const e=new cache_service_1.CacheService(new storage_1.InMemoryCacheStorage);return e.setSecondaryCache(this.configVarCache),e}))}get resourceAvailabilityService(){return this.getOrCreateService("resourceAvailabilityService",(()=>new resource_availability_service_1.ResourceAvailabilityService(this.availabilityAPIClient)))}get dataService(){return this.getOrCreateService("dataService",(()=>new data_service_1.DataService(this.graphqlService)))}get resourceBuilder(){return this.getOrCreateService("resourceBuilder",(()=>new resource_builder_1.ResourceBuilder(this.dataService,this.resourceAvailabilityService)))}newQueryBuilder(e){const i=new graphql_1.GraphQLQueryBuilder(e);return i.setGraphqlService(this.graphqlService),i}newArtifactClient(e){return this.getOrCreateService(`${e}Client`,(()=>new artifact_client_1.ArtifactClient(this.baseConfig,e,this.executionOptions)))}dispose(){this.services.clear()}}exports.ExecutionContext=ExecutionContext;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.ExecutionOptions=void 0;class ExecutionOptions{constructor(t){this.requestSource="",this.userAgent="",t&&Object.assign(this,t)}}exports.ExecutionOptions=ExecutionOptions;
@@ -1 +1 @@
1
- "use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var n=Object.getOwnPropertyDescriptor(t,r);n&&!("get"in n?!t.__esModule:n.writable||n.configurable)||(n={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,n)}: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("./execution-context"),exports);
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("./entity-factory"),exports),__exportStar(require("./execution-context"),exports),__exportStar(require("./request-header-constants"),exports),__exportStar(require("./tenant-entities"),exports),__exportStar(require("./tenant-objects"),exports);
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.RequestContext=void 0;class RequestContext{constructor(e){this.bulkOperation=!1,this.readOnly=!1,this.additionalHeaders={},e&&Object.assign(this,e)}}exports.RequestContext=RequestContext;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.REQUEST_HEADERS=void 0,exports.REQUEST_HEADERS={X_SKEDULO_BULK_OPERATION:"X-Skedulo-Bulk-Operation",X_SKEDULO_READ_ONLY:"X-Skedulo-Read-Only",X_SKEDULO_SOURCE:"X-Skedulo-Source",X_GRAPHQL_OPERATION:"X-Graphql-Operation",SKED_FUNCTION_EXECUTION_TYPE:"Sked-Function-Execution-Type",SKED_API_SERVER:"sked-api-server",USER_AGENT:"User-Agent"};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.TenantObjects=void 0,exports.TenantObjects={Accounts:{Name:"Accounts",Fields:["UID","Name","Industry","OwnerId"]},Jobs:{Name:"Jobs",Fields:["UID","Name","Start","End","Type"]},JobTags:{Name:"JobTags",Fields:["UID","Name"]},JobAllocations:{Name:"JobAllocations",Fields:["UID","Name","Start","End","JobId"]},Regions:{Name:"Regions",Fields:["UID","Name","Timezone"]},Contacts:{Name:"Contacts",Fields:["UID","FirstName","LastName","Email"]},Locations:{Name:"Locations",Fields:["UID","Name","Address"]},Resources:{Name:"Resources",Fields:["UID","Name","Category","ResourceType","EmploymentType","UserId","PrimaryRegionId"]},Tags:{Name:"Tags",Fields:["UID","Name"]},Activities:{Name:"Activities",Fields:["UID","Name","Start","End","Type"]},Availabilities:{Name:"Availabilities",Fields:["UID","Start","Finish","Type","IsAvailable"]},Holidays:{Name:"Holidays",Fields:["UID","Name","StartDate","EndDate","Global"]},ResourceTags:{Name:"ResourceTags",Fields:["UID","Name"]},HolidayRegions:{Name:"HolidayRegions",Fields:["UID","RegionId","HolidayId"]}};