@skedulo/pulse-solution-services 0.0.19 → 0.0.20

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 (43) hide show
  1. package/README.md +59 -4
  2. package/dist/clients/availability-api-client.js +1 -1
  3. package/dist/clients/base-client.js +1 -1
  4. package/dist/clients/graphql-client.js +1 -1
  5. package/dist/constants/tenant-endpoints.js +1 -1
  6. package/dist/index.d.ts +158 -15
  7. package/dist/services/graphql/graphql-query-builder.js +1 -1
  8. package/dist/services/graphql/graphql-service.js +1 -1
  9. package/dist/services/graphql/queries.js +1 -1
  10. package/package.json +2 -2
  11. package/CHANGELOG.md +0 -59
  12. package/dist/logging/decorators/index.d.ts +0 -1
  13. package/dist/logging/decorators/log-method.d.ts +0 -7
  14. package/dist/monitoring/decorators/monitor-call.d.ts +0 -6
  15. package/dist/services/cache/cache-service.d.ts +0 -70
  16. package/dist/services/cache/index.d.ts +0 -1
  17. package/dist/services/cache/storage/config-var-cache-storage.d.ts +0 -40
  18. package/dist/services/cache/storage/in-memory-cache-storage.d.ts +0 -32
  19. package/dist/services/cache/storage/index.d.ts +0 -2
  20. package/dist/services/graph-batch/configs/graph-batch-config.d.ts +0 -18
  21. package/dist/services/graph-batch/configs/unique-graph-batch-config.d.ts +0 -16
  22. package/dist/services/graph-batch/graph-batch.d.ts +0 -56
  23. package/dist/services/graph-batch/index.d.ts +0 -5
  24. package/dist/services/graph-batch/pagination-strategy.d.ts +0 -5
  25. package/dist/services/graph-batch/unique-graph-batch.d.ts +0 -28
  26. package/dist/services/graphql/graphql-batch-builder.d.ts +0 -138
  27. package/dist/services/graphql/graphql-query-batch.d.ts +0 -10
  28. package/dist/services/graphql/graphql-query-builder.d.ts +0 -86
  29. package/dist/services/graphql/graphql-service.d.ts +0 -106
  30. package/dist/services/graphql/index.d.ts +0 -2
  31. package/dist/services/graphql/queries.d.ts +0 -20
  32. package/dist/services/resource-availability/builder/data-service.d.ts +0 -10
  33. package/dist/services/resource-availability/builder/index.d.ts +0 -3
  34. package/dist/services/resource-availability/builder/resource-availability-service.d.ts +0 -8
  35. package/dist/services/resource-availability/builder/resource-builder.d.ts +0 -17
  36. package/dist/services/resource-availability/builder/resource-query-param.d.ts +0 -23
  37. package/dist/services/resource-availability/index.d.ts +0 -2
  38. package/dist/services/resource-availability/validator/index.d.ts +0 -4
  39. package/dist/services/resource-availability/validator/resource-job-validation.d.ts +0 -11
  40. package/dist/services/resource-availability/validator/resource-validation-option.d.ts +0 -5
  41. package/dist/services/resource-availability/validator/resource-validator.d.ts +0 -13
  42. package/dist/services/resource-availability/validator/validation-result.d.ts +0 -12
  43. package/yarn.lock +0 -3461
package/README.md CHANGED
@@ -15,6 +15,7 @@
15
15
  - [Mobile Notification Client](#mobile-notification-client)
16
16
  - [Configuration Templates](#configuration-templates)
17
17
  - [Geo API Client](#geo-api-client)
18
+ - [Availability API Client](#availability-api-client)
18
19
  - [Files API Client](#files-api-client)
19
20
  - [Artifact Client](#artifact-client)
20
21
  - [GraphQL Service](#graphql-service)
@@ -400,6 +401,7 @@ const timezone: TimezoneResponse = await context.geoAPIClient.getTimezone({
400
401
  ```
401
402
 
402
403
  #### Availability API Client
404
+ **Fetch Resource Availability**
403
405
  ```javascript
404
406
  // Calls /availability/simple endpoint to retrieve availability for resources
405
407
  const resourceAvailability: AvailabilityResult[] = await context.availabilityAPIClient.fetchAvailability({
@@ -415,7 +417,36 @@ console.log(availability[0].mergedAvailabilities);
415
417
 
416
418
  // Example: Accessing detailed availability entries
417
419
  console.log(availability[0].entries);
420
+ ```
421
+
422
+ **Upsert Availability Patterns**
423
+ ```javascript
424
+ // Calls /availability/patterns endpoint to create or update availability patterns
425
+ const patternRequest = {
426
+ pattern: {
427
+ // UID: "existing-pattern-id", // Include UID to update existing pattern
428
+ name: "Availability Pattern - MON",
429
+ pattern: {
430
+ type: "weekly" as const,
431
+ repeatWeeks: 1,
432
+ days: [
433
+ {
434
+ weekday: "MON" as const,
435
+ intervals: [{ startTime: "08:00", endTime: "18:00" }]
436
+ }
437
+ ]
438
+ }
439
+ },
440
+ resources: [
441
+ {
442
+ resourceId: "<resource_id>",
443
+ start: "2025-08-31T14:00:00.000Z",
444
+ end: "2025-09-28T13:59:59.999Z"
445
+ }
446
+ ]
447
+ };
418
448
 
449
+ const patternId = await context.availabilityAPIClient.upsertPattern(patternRequest);
419
450
  ```
420
451
 
421
452
  #### Files API Client
@@ -514,7 +545,7 @@ const queryBuilder = context.newQueryBuilder({
514
545
  readOnly: true
515
546
  });
516
547
  queryBuilder.withFields(['UID', 'Name'])
517
- .withFilter('IsActive == true')
548
+ .withFilter("JobStatus != 'Complete'")
518
549
  .withLimit(1)
519
550
  .withOffset(1)
520
551
  .withOrderBy('Name ASC');
@@ -524,13 +555,14 @@ queryBuilder.withChildQuery('JobAllocations')
524
555
  .withParentQuery('Job')
525
556
  .withFields(['UID', 'Name']);
526
557
  // Add a parent query for Primary Region
527
- queryBuilder.withParentQuery('PrimaryRegion')
558
+ queryBuilder.withParentQuery('Region')
528
559
  .withFields(['UID', 'Name']);
529
560
  // Finally, execute the query
530
561
  let queryResult = await queryBuilder.execute();
531
562
 
532
563
  console.log(queryResult.records);
533
564
  console.log(queryResult.totalCount); // 5
565
+ console.log(queryResult.queryLimit); // maximum allowed limit returned in the X-Skedulo-Dynamic-Query-Limit response header
534
566
  console.log(queryResult.pageInfo.hasNextPage); // true
535
567
  console.log(queryResult.endCursor); // Mg==
536
568
  console.log(queryResult.endOffset); // 1
@@ -538,6 +570,31 @@ console.log(queryResult.endOffset); // 1
538
570
 
539
571
  The `X-Graphql-Operation` header is added to all GraphQL requests and contains the value of `operationName`.
540
572
 
573
+ #### Query Builder Methods
574
+
575
+ The `GraphQLQueryBuilder` provides several methods to configure your queries:
576
+
577
+ **Limiting Results:**
578
+ - `withLimit(limit: number)` - Sets the maximum number of records using the `limit` parameter (recommended)
579
+ - `withFirst(first: number)` - Sets the maximum number of records using the `first` parameter (use when `first` is specifically needed)
580
+
581
+ ```javascript
582
+ // Recommended: Use withLimit() for the 'limit' parameter
583
+ queryBuilder.withLimit(100); // → GraphQL query uses: limit: 100
584
+
585
+ // When specifically needed: Use withFirst() for the 'first' parameter
586
+ queryBuilder.withFirst(100); // → GraphQL query uses: first: 100
587
+ ```
588
+
589
+ **Filtering and Ordering:**
590
+ - `withFields(fields: string[])` - Specify which fields to retrieve
591
+ - `withFilter(condition: string)` - Add filter conditions to limit results
592
+ - `withOrderBy(orderBy: string)` - Set the sort order (e.g., `'Name ASC'`, `'CreatedDate DESC'`)
593
+
594
+ **Pagination:**
595
+ - `withOffset(offset: number)` - Set the starting position for results
596
+ - `withCursor(after: string)` - Use cursor-based pagination
597
+
541
598
  #### Query by Pages
542
599
  ```javascript
543
600
  // Create a query builder for the Jobs object
@@ -567,7 +624,6 @@ const jobQueryBuilder = context.newQueryBuilder({
567
624
  readOnly: true
568
625
  });
569
626
  jobQueryBuilder.withFields(['UID', 'Name'])
570
- .withFilter('IsActive == true')
571
627
  .withLimit(10);
572
628
 
573
629
  const contactQueryBuilder = context.newQueryBuilder({
@@ -576,7 +632,6 @@ const contactQueryBuilder = context.newQueryBuilder({
576
632
  readOnly: true
577
633
  });
578
634
  contactQueryBuilder.withFields(['UID', 'FirstName', 'LastName'])
579
- .withFilter('LastName != null')
580
635
  .withLimit(5);
581
636
 
582
637
  // Execute batch query
@@ -1 +1 @@
1
- "use strict";var __decorate=this&&this.__decorate||function(e,t,i,n){var r,a=arguments.length,o=a<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,i):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,i,n);else for(var l=e.length-1;l>=0;l--)(r=e[l])&&(o=(a<3?r(o):a>3?r(t,i,o):r(t,i))||o);return a>3&&o&&Object.defineProperty(t,i,o),o},__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,i,n){return new(i||(i=Promise))((function(r,a){function o(e){try{s(n.next(e))}catch(e){a(e)}}function l(e){try{s(n.throw(e))}catch(e){a(e)}}function s(e){var t;e.done?r(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(o,l)}s((n=n.apply(e,t||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.AvailabilityAPIClient=void 0;const constants_1=require("../constants"),monitor_call_1=require("../monitoring/decorators/monitor-call"),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 a={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:a})}))}}exports.AvailabilityAPIClient=AvailabilityAPIClient,__decorate([(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],AvailabilityAPIClient.prototype,"fetchAvailability",null);
1
+ "use strict";var __decorate=this&&this.__decorate||function(e,t,r,i){var n,a=arguments.length,o=a<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)o=Reflect.decorate(e,t,r,i);else for(var s=e.length-1;s>=0;s--)(n=e[s])&&(o=(a<3?n(o):a>3?n(t,r,o):n(t,r))||o);return a>3&&o&&Object.defineProperty(t,r,o),o},__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,r,i){return new(r||(r=Promise))((function(n,a){function o(e){try{l(i.next(e))}catch(e){a(e)}}function s(e){try{l(i.throw(e))}catch(e){a(e)}}function l(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,s)}l((i=i.apply(e,t||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.AvailabilityAPIClient=void 0;const constants_1=require("../constants"),monitor_call_1=require("../monitoring/decorators/monitor-call"),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,r,i,n;if(!e.resourceIds.length)throw new Error("At least one resource ID must be provided.");const a={resource_ids:e.resourceIds.join(","),start:e.start,end:e.end,mergedAvailabilities:null!==(r=null===(t=e.mergedAvailabilities)||void 0===t?void 0:t.toString())&&void 0!==r?r:"false",entries:null!==(n=null===(i=e.entries)||void 0===i?void 0:i.toString())&&void 0!==n?n:"true"};return yield this._performRequest({endpoint:constants_1.TENANT_ENDPOINTS.AVAILABILITY.SIMPLE,queryParams:a})}))}upsertPattern(e){return __awaiter(this,void 0,void 0,(function*(){if(!e.pattern.name)throw new Error("Pattern name is required.");if(!e.resources.length)throw new Error("At least one resource must be provided.");const t=yield this._performRequest({endpoint:constants_1.TENANT_ENDPOINTS.AVAILABILITY.PATTERNS,method:"POST",body:e});if("string"==typeof t)return t;if(t&&"object"==typeof t&&"created"in t)return t.created;throw new Error("Unexpected response format from patterns API")}))}}exports.AvailabilityAPIClient=AvailabilityAPIClient,__decorate([(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],AvailabilityAPIClient.prototype,"fetchAvailability",null),__decorate([(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],AvailabilityAPIClient.prototype,"upsertPattern",null);
@@ -1 +1 @@
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"),monitor_call_1=require("../monitoring/decorators/monitor-call");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){return this._performRequest({method:e,endpoint:t,headers:n,body:r,queryParams:o},i)}))}_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 this.handleResponseData(u),u}catch(e){throw this.handleException(e),e}}))}handleResponseData(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=e.startsWith("http")?new URL(e):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)(),(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object,Object]),__metadata("design:returntype",Promise)],BaseClient.prototype,"performRequest",null);
1
+ "use strict";var __decorate=this&&this.__decorate||function(e,t,r,n){var o,i=arguments.length,a=i<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)a=Reflect.decorate(e,t,r,n);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(a=(i<3?o(a):i>3?o(t,r,a):o(t,r))||a);return i>3&&a&&Object.defineProperty(t,r,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,r,n){return new(r||(r=Promise))((function(o,i){function a(e){try{d(n.next(e))}catch(e){i(e)}}function s(e){try{d(n.throw(e))}catch(e){i(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(a,s)}d((n=n.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"),monitor_call_1=require("../monitoring/decorators/monitor-call");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:r={},body:n,queryParams:o},i=this.executionOptions){return this._performRequest({method:e,endpoint:t,headers:r,body:n,queryParams:o},i)}))}performRequestWithHeaders(e){return __awaiter(this,arguments,void 0,(function*({method:e="GET",endpoint:t,headers:r={},body:n,queryParams:o},i=this.executionOptions){return this._performRequestWithHeaders({method:e,endpoint:t,headers:r,body:n,queryParams:o},i)}))}_performRequest(e){return __awaiter(this,arguments,void 0,(function*({method:e="GET",endpoint:t,headers:r={},body:n,queryParams:o},i=this.executionOptions){return(yield this._performRequestWithHeaders({method:e,endpoint:t,headers:r,body:n,queryParams:o},i)).data}))}_performRequestWithHeaders(e){return __awaiter(this,arguments,void 0,(function*({method:e="GET",endpoint:t,headers:r={},body:n,queryParams:o},i=this.executionOptions){try{const a=Object.assign(Object.assign({},this.getHeaders(i)),r),s=this.buildUrl(t,o),d=yield fetch(s,{method:e,headers:a,body:n&&"GET"!==e?JSON.stringify(n):void 0});let c;const u=d.headers.get("content-type");if(u&&u.includes("application/json")?(c=yield d.json(),c.result&&(c=c.result)):c=yield d.text(),!d.ok)throw new Error(`HTTP error! Status: ${d.status}. Response: ${JSON.stringify(c)}`);return this.handleResponseData(c),{data:c,headers:d.headers}}catch(e){throw this.handleException(e),e}}))}handleResponseData(e){}getHeaders(e){var t,r;const n={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===(r=this.executionOptions)||void 0===r?void 0:r.userAgent);return o&&(n[request_header_constants_1.REQUEST_HEADERS.X_SKEDULO_SOURCE]=o),i&&(n[request_header_constants_1.REQUEST_HEADERS.USER_AGENT]=i),n}buildUrl(e,t){const r=e.startsWith("http")?new URL(e):new URL(`${this.config.apiServer}/${e}`);return t&&Object.entries(t).forEach((([e,t])=>{r.searchParams.append(e,t)})),r.toString()}handleException(e){}}exports.BaseClient=BaseClient,__decorate([(0,logging_1.LogMethod)(),(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object,Object]),__metadata("design:returntype",Promise)],BaseClient.prototype,"performRequest",null),__decorate([(0,logging_1.LogMethod)(),(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object,Object]),__metadata("design:returntype",Promise)],BaseClient.prototype,"performRequestWithHeaders",null);
@@ -1 +1 @@
1
- "use strict";var __decorate=this&&this.__decorate||function(e,t,r,a){var n,o=arguments.length,i=o<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,r):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,a);else for(var s=e.length-1;s>=0;s--)(n=e[s])&&(i=(o<3?n(i):o>3?n(t,r,i):n(t,r))||i);return o>3&&i&&Object.defineProperty(t,r,i),i},__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,r,a){return new(r||(r=Promise))((function(n,o){function i(e){try{c(a.next(e))}catch(e){o(e)}}function s(e){try{c(a.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,s)}c((a=a.apply(e,t||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.GraphQLClient=void 0;const constants_1=require("../constants"),http_1=require("../constants/http"),monitor_call_1=require("../monitoring/decorators/monitor-call"),base_client_1=require("./base-client");class GraphQLClient extends base_client_1.BaseClient{execute(e){return __awaiter(this,arguments,void 0,(function*(e,t={}){return yield this._performRequest({method:http_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.GRAPHQL.SINGLE,body:"string"==typeof e?{query:e}:{query:e.query,variables:e.variables},headers:t})}))}executeBatch(e){return __awaiter(this,arguments,void 0,(function*(e,t={}){const r=e.map((e=>"string"==typeof e?{query:e}:{query:e.query,variables:e.variables})),a=yield this._performRequest({method:http_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.GRAPHQL.BATCH,body:r,headers:t});return a.forEach(((e,t)=>{if(!e.data&&e.errors)throw new Error(`GraphQL batch error at index ${t}: ${JSON.stringify(e.errors)}`)})),a}))}handleResponseData(e){if(Array.isArray(e));else if(!e.data&&e.errors)throw new Error(`GraphQL error: ${JSON.stringify(e.errors)}`)}}exports.GraphQLClient=GraphQLClient,__decorate([(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object,Object]),__metadata("design:returntype",Promise)],GraphQLClient.prototype,"execute",null),__decorate([(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Array,Object]),__metadata("design:returntype",Promise)],GraphQLClient.prototype,"executeBatch",null);
1
+ "use strict";var __decorate=this&&this.__decorate||function(e,t,r,a){var n,o=arguments.length,i=o<3?t:null===a?a=Object.getOwnPropertyDescriptor(t,r):a;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,r,a);else for(var s=e.length-1;s>=0;s--)(n=e[s])&&(i=(o<3?n(i):o>3?n(t,r,i):n(t,r))||i);return o>3&&i&&Object.defineProperty(t,r,i),i},__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,r,a){return new(r||(r=Promise))((function(n,o){function i(e){try{c(a.next(e))}catch(e){o(e)}}function s(e){try{c(a.throw(e))}catch(e){o(e)}}function c(e){var t;e.done?n(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(i,s)}c((a=a.apply(e,t||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.GraphQLClient=void 0;const constants_1=require("../constants"),http_1=require("../constants/http"),monitor_call_1=require("../monitoring/decorators/monitor-call"),base_client_1=require("./base-client");class GraphQLClient extends base_client_1.BaseClient{execute(e){return __awaiter(this,arguments,void 0,(function*(e,t={}){const r=yield this._performRequestWithHeaders({method:http_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.GRAPHQL.SINGLE,body:"string"==typeof e?{query:e}:{query:e.query,variables:e.variables},headers:t}),a=r.headers.get("X-Skedulo-Dynamic-Query-Limit"),n=r.data;return a&&(n.queryLimit=parseInt(a,10)),n}))}executeBatch(e){return __awaiter(this,arguments,void 0,(function*(e,t={}){const r=e.map((e=>"string"==typeof e?{query:e}:{query:e.query,variables:e.variables})),a=yield this._performRequest({method:http_1.HttpMethod.POST,endpoint:constants_1.TENANT_ENDPOINTS.GRAPHQL.BATCH,body:r,headers:t});return a.forEach(((e,t)=>{if(!e.data&&e.errors)throw new Error(`GraphQL batch error at index ${t}: ${JSON.stringify(e.errors)}`)})),a}))}handleResponseData(e){if(Array.isArray(e));else if(!e.data&&e.errors)throw new Error(`GraphQL error: ${JSON.stringify(e.errors)}`)}}exports.GraphQLClient=GraphQLClient,__decorate([(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object,Object]),__metadata("design:returntype",Promise)],GraphQLClient.prototype,"execute",null),__decorate([(0,monitor_call_1.MonitorCall)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Array,Object]),__metadata("design:returntype",Promise)],GraphQLClient.prototype,"executeBatch",null);
@@ -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:e=>`configuration/extension/${e}`,UPDATE:e=>`configuration/extension/${e}`,DELETE:e=>`configuration/extension/${e}`,SEARCH:"configuration/extension/search"},GRAPHQL:{SINGLE:"graphql/graphql",BATCH:"graphql/graphql/batch"},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,t)=>`custom/vocabulary/${e}/${t}`,ADD_ITEM:(e,t)=>`custom/vocabulary/${e}/${t}`,UPDATE_ITEM:(e,t,i)=>`custom/vocabulary/${e}/${t}/${i}`},NOTIFICATIONS:{GET_TEMPLATES:"notifications/v2/templates",DELETE_TEMPLATE:(e,t)=>`notifications/v2/template/${e}/${t}`,SET_TEMPLATE:(e,t)=>`notifications/v2/template/${e}/${t}`,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"},FILES:{AVATAR:"files/avatar",ATTACHMENTS:e=>`files/attachments/${e}`}};
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:{SINGLE:"graphql/graphql",BATCH:"graphql/graphql/batch"},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,t)=>`custom/vocabulary/${e}/${t}`,ADD_ITEM:(e,t)=>`custom/vocabulary/${e}/${t}`,UPDATE_ITEM:(e,t,i)=>`custom/vocabulary/${e}/${t}/${i}`},NOTIFICATIONS:{GET_TEMPLATES:"notifications/v2/templates",DELETE_TEMPLATE:(e,t)=>`notifications/v2/template/${e}/${t}`,SET_TEMPLATE:(e,t)=>`notifications/v2/template/${e}/${t}`,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",PATTERNS:"availability/patterns"},FILES:{AVATAR:"files/avatar",ATTACHMENTS:e=>`files/attachments/${e}`}};
package/dist/index.d.ts CHANGED
@@ -111,6 +111,7 @@ export declare const TENANT_ENDPOINTS: {
111
111
  };
112
112
  readonly AVAILABILITY: {
113
113
  readonly SIMPLE: "availability/simple";
114
+ readonly PATTERNS: "availability/patterns";
114
115
  };
115
116
  readonly FILES: {
116
117
  readonly AVATAR: "files/avatar";
@@ -178,7 +179,22 @@ export declare class BaseClient {
178
179
  * @throws {Error} - If the request fails or the response is not OK.
179
180
  */
180
181
  performRequest<T = any>({ method, endpoint, headers, body, queryParams }: RequestParams, executionOptions?: Partial<ExecutionOptions>): Promise<T>;
182
+ /**
183
+ * Performs an API request and returns both data and headers.
184
+ * @template T
185
+ * @param {RequestParams} requestParams - The request parameters.
186
+ * @param {Partial<ExecutionOptions>} executionOptions - Execution options.
187
+ * @returns {Promise<{data: T, headers: Headers}>} - The response data and headers.
188
+ */
189
+ performRequestWithHeaders<T = any>({ method, endpoint, headers, body, queryParams }: RequestParams, executionOptions?: Partial<ExecutionOptions>): Promise<{
190
+ data: T;
191
+ headers: Headers;
192
+ }>;
181
193
  protected _performRequest<T = any>({ method, endpoint, headers, body, queryParams }: RequestParams, executionOptions?: Partial<ExecutionOptions>): Promise<T>;
194
+ protected _performRequestWithHeaders<T = any>({ method, endpoint, headers, body, queryParams }: RequestParams, executionOptions?: Partial<ExecutionOptions>): Promise<{
195
+ data: T;
196
+ headers: Headers;
197
+ }>;
182
198
  protected handleResponseData(response: Response): void;
183
199
  /**
184
200
  * Constructs the headers for API requests.
@@ -262,6 +278,112 @@ export interface AvailabilityEntry {
262
278
  patternId?: string;
263
279
  patternRecordId?: string;
264
280
  }
281
+ export interface TimeInterval {
282
+ /**
283
+ * Start time of the interval in local time (24-hour ISO format).
284
+ */
285
+ startTime: string;
286
+ /**
287
+ * End time of the interval in local time (24-hour ISO format).
288
+ * Start time must be before end time, except for full days.
289
+ */
290
+ endTime: string;
291
+ }
292
+ export interface CustomPatternDay {
293
+ /**
294
+ * The N-th number of day in the pattern. The index is 1-based (the first day of the pattern is day 1).
295
+ */
296
+ day: number;
297
+ /**
298
+ * A list of time intervals that determine when a resource is available on the day.
299
+ * At least one time interval must be specified.
300
+ */
301
+ intervals: TimeInterval[];
302
+ }
303
+ export interface WeeklyPatternDay {
304
+ /**
305
+ * The days of the week
306
+ */
307
+ weekday: "MON" | "TUE" | "WED" | "THU" | "FRI" | "SAT" | "SUN";
308
+ /**
309
+ * A list of time intervals that determine when a resource is available on the day.
310
+ * At least one time interval must be specified.
311
+ */
312
+ intervals: TimeInterval[];
313
+ }
314
+ export interface CustomPattern {
315
+ /**
316
+ * Pattern type
317
+ */
318
+ type: "custom";
319
+ /**
320
+ * The length of the pattern in days, must be a positive integer.
321
+ */
322
+ lengthDays: number;
323
+ /**
324
+ * Days that make up the pattern. Days can be specified in any order.
325
+ * A day with the same index cannot appear more than once.
326
+ */
327
+ days: CustomPatternDay[];
328
+ }
329
+ export interface WeeklyPattern {
330
+ /**
331
+ * Pattern type
332
+ */
333
+ type: "weekly";
334
+ /**
335
+ * The repeat frequency of a single week pattern, must be a positive integer.
336
+ * The single weekly pattern is applied from Monday to Sunday.
337
+ */
338
+ repeatWeeks: number;
339
+ /**
340
+ * Weekdays that make up the pattern. Weekdays can be specified in any order.
341
+ * Not all weekdays must be specified.
342
+ */
343
+ days: WeeklyPatternDay[];
344
+ }
345
+ export interface PatternDefinition {
346
+ /**
347
+ * The ID of the Pattern Resource that is to be updated.
348
+ */
349
+ UID?: string;
350
+ /**
351
+ * The name of the pattern.
352
+ */
353
+ name: string;
354
+ /**
355
+ * The description of the pattern.
356
+ */
357
+ description?: string;
358
+ /**
359
+ * The pattern of availabilities to determine availability.
360
+ */
361
+ pattern: CustomPattern | WeeklyPattern;
362
+ }
363
+ export interface PatternResource {
364
+ /**
365
+ * The ID of the resource to assign to this pattern.
366
+ */
367
+ resourceId: string;
368
+ /**
369
+ * The UTC datetime at which the pattern begins applying to the resource.
370
+ */
371
+ start: string;
372
+ /**
373
+ * The UTC datetime at which the pattern stops applying to the resource.
374
+ */
375
+ end: string;
376
+ }
377
+ export interface UpsertPatternRequest {
378
+ /**
379
+ * The pattern of availabilities to determine availability.
380
+ */
381
+ pattern: PatternDefinition;
382
+ /**
383
+ * A resource has times they will be made available. This contains the period that a resource will have the pattern applied.
384
+ */
385
+ resources: PatternResource[];
386
+ }
265
387
  /**
266
388
  * AvailabilityClient class to handle API requests related to availability.
267
389
  * Extends BaseClient to perform API operations.
@@ -273,6 +395,15 @@ export declare class AvailabilityAPIClient extends BaseClient {
273
395
  * @returns {Promise<AvailabilityResult[]>} - The availability data for the requested resources.
274
396
  */
275
397
  fetchAvailability(params: AvailabilityRequestParams): Promise<AvailabilityResult[]>;
398
+ /**
399
+ * Creates or updates an availability pattern and assigns it to resources.
400
+ * - To create a new pattern: omit the UID in the pattern definition
401
+ * - To update an existing pattern: include the UID in the pattern definition
402
+ *
403
+ * @param {UpsertPatternRequest} request - The pattern and resource assignment data.
404
+ * @returns {Promise<string>} - The ID of the created or updated pattern.
405
+ */
406
+ upsertPattern(request: UpsertPatternRequest): Promise<string>;
276
407
  }
277
408
  /**
278
409
  * ConfigFeatureClient class to handle API requests related to feature flags.
@@ -460,21 +591,23 @@ export interface DirectionsRequest {
460
591
  }[];
461
592
  }
462
593
  export interface DirectionsResponse {
463
- routes: {
464
- leg: {
465
- origin: LatLng;
466
- destination: LatLng;
467
- };
468
- travelInfo: {
469
- status: "OK" | "NO_ROUTE";
470
- duration: {
471
- durationInSeconds: number;
594
+ routes: [
595
+ {
596
+ leg: {
597
+ origin: LatLng;
598
+ destination: LatLng;
472
599
  };
473
- distance: {
474
- distanceInMeters: number;
600
+ travelInfo: {
601
+ status: "OK" | "NO_ROUTE";
602
+ duration: {
603
+ durationInSeconds: number;
604
+ };
605
+ distance: {
606
+ distanceInMeters: number;
607
+ };
475
608
  };
476
- };
477
- }[];
609
+ }
610
+ ][];
478
611
  }
479
612
  export interface GeocodeRequest {
480
613
  addresses: string[];
@@ -565,6 +698,7 @@ export interface HasId {
565
698
  export interface GraphQlResponse<T = any> {
566
699
  data: T;
567
700
  errors?: object[];
701
+ queryLimit?: number;
568
702
  }
569
703
  export interface GraphqlParams {
570
704
  objectName: string;
@@ -579,6 +713,7 @@ export interface GraphqlMutationParams extends GraphqlParams {
579
713
  }
580
714
  export interface GraphqlQueryParams extends GraphqlParams {
581
715
  first?: number;
716
+ limit?: number;
582
717
  offset?: number;
583
718
  orderBy?: string;
584
719
  filter?: string;
@@ -592,6 +727,7 @@ export interface QueryResult {
592
727
  pageInfo: any;
593
728
  endCursor: string;
594
729
  endOffset: number;
730
+ queryLimit?: number;
595
731
  }
596
732
  export interface MutationResult {
597
733
  data: {
@@ -1155,6 +1291,7 @@ export declare class GraphQLQueryBuilder {
1155
1291
  private fields;
1156
1292
  private filters;
1157
1293
  private first?;
1294
+ private limit?;
1158
1295
  private offset?;
1159
1296
  private orderBy?;
1160
1297
  private after?;
@@ -1182,9 +1319,15 @@ export declare class GraphQLQueryBuilder {
1182
1319
  */
1183
1320
  withFilter(condition: string): this;
1184
1321
  /**
1185
- * Sets a limit on the number of records to retrieve.
1322
+ * Sets a limit on the number of records to retrieve using 'limit' parameter.
1323
+ * This is the recommended approach.
1324
+ */
1325
+ withLimit(limit: number): this;
1326
+ /**
1327
+ * Sets a limit on the number of records to retrieve using 'first' parameter.
1328
+ * Use this when you specifically need the 'first' parameter.
1186
1329
  */
1187
- withLimit(first: number): this;
1330
+ withFirst(first: number): this;
1188
1331
  /**
1189
1332
  * Sets an offset for pagination.
1190
1333
  */
@@ -1 +1 @@
1
- "use strict";var __awaiter=this&&this.__awaiter||function(e,t,r,i){return new(r||(r=Promise))((function(s,a){function o(e){try{h(i.next(e))}catch(e){a(e)}}function n(e){try{h(i.throw(e))}catch(e){a(e)}}function h(e){var t;e.done?s(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,n)}h((i=i.apply(e,t||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.GraphQLQueryBuilder=void 0;class GraphQLQueryBuilder{constructor(e,t=!1){this.fields=new Set(["UID"]),this.filters=[],this.parentQueries={},this.childQueries={},this.graphqlService=null,this.queryParams=e,this.objectName=e.objectName.charAt(0).toLowerCase()+e.objectName.slice(1),this.operationName=e.operationName,this.isParent=t}setGraphqlService(e){this.graphqlService=e}withFields(e){return e.forEach((e=>this.fields.add(e))),this}withFilter(e){if(this.isParent)throw new Error("Cannot apply filters to a parent query.");return this.filters.push(e),this}withLimit(e){if(this.isParent)throw new Error("Cannot apply limit to a parent query.");return this.first=e,this}withOffset(e){if(this.isParent)throw new Error("Cannot apply offset to a parent query.");return this.offset=e,this}withOrderBy(e){if(this.isParent)throw new Error("Cannot apply orderBy to a parent query.");return this.orderBy=e,this}withCursor(e){if(this.isParent)throw new Error("Cannot apply cursor to a parent query.");return this.after=e,this}withParentQuery(e){const t=new GraphQLQueryBuilder({objectName:e,operationName:this.operationName},!0);return this.parentQueries[e]=t,t}withChildQuery(e){const t=new GraphQLQueryBuilder({objectName:e,operationName:this.operationName});return this.childQueries[e]=t,t}formatQueryFields(){const e=Object.entries(this.parentQueries).map((([e,t])=>`${e} { ${t.formatQueryFields()} }`)).join(", "),t=Object.entries(this.childQueries).map((([e,t])=>{const r=t.build();return`${e} ${r.filter?`(filter: "${r.filter}")`:""} { ${r.fields||"UID"} }`})).join(", ");return[...this.fields,e,t].filter(Boolean).join(", ")}build(){return{objectName:this.objectName,operationName:this.operationName,fields:this.formatQueryFields(),filter:this.filters.length>0?this.filters.join(" AND "):void 0,first:this.first,offset:this.offset,orderBy:this.orderBy,after:this.after,readOnly:this.queryParams.readOnly}}execute(){if(!this.graphqlService)return Promise.reject(new Error("No GraphQL service set for query execution."));const e=this.build();return e.readOnly=this.queryParams.readOnly,this.graphqlService.query(e)}executeAll(){return __awaiter(this,arguments,void 0,(function*(e=1,t=20){if(!this.graphqlService)throw new Error("No GraphQL service set for query execution.");if(e<1)throw new Error("fromPage must be at least 1.");if(t<e)throw new Error("toPage must be greater than or equal to fromPage.");const r=Math.min(t,20),i=this.build(),s=yield this.graphqlService.query(i),a=s.totalCount;if(0===a)return{records:[],totalCount:0,pageInfo:{hasNextPage:!1},endCursor:"",endOffset:0};const o=this.first||200,n=Math.ceil(a/o),h=Math.min(r,n);if(0===Math.max(0,h-e+1))return{records:[],totalCount:a,pageInfo:{hasNextPage:h<n},endCursor:"",endOffset:(e-1)*o};const u=[];for(let t=e-1;t<h;t++){const e=new GraphQLQueryBuilder({objectName:this.objectName,operationName:this.operationName,readOnly:this.queryParams.readOnly});e.setGraphqlService(this.graphqlService),e.fields=new Set(this.fields),e.filters=[...this.filters],e.first=o,e.offset=t*o,e.orderBy=this.orderBy,e.after=this.after,u.push(e)}const l=yield this.graphqlService.queryBatch(u),f=l.flatMap((e=>e.records)),c=l[l.length-1];return{records:f,totalCount:s.totalCount,pageInfo:c.pageInfo,endCursor:c.endCursor,endOffset:c.endOffset}}))}toString(){return`{ ${this.objectName} { ${this.formatQueryFields()} } }`}}exports.GraphQLQueryBuilder=GraphQLQueryBuilder;
1
+ "use strict";var __awaiter=this&&this.__awaiter||function(e,t,r,i){return new(r||(r=Promise))((function(s,a){function o(e){try{h(i.next(e))}catch(e){a(e)}}function n(e){try{h(i.throw(e))}catch(e){a(e)}}function h(e){var t;e.done?s(e.value):(t=e.value,t instanceof r?t:new r((function(e){e(t)}))).then(o,n)}h((i=i.apply(e,t||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.GraphQLQueryBuilder=void 0;class GraphQLQueryBuilder{constructor(e,t=!1){this.fields=new Set(["UID"]),this.filters=[],this.parentQueries={},this.childQueries={},this.graphqlService=null,this.queryParams=e,this.objectName=e.objectName.charAt(0).toLowerCase()+e.objectName.slice(1),this.operationName=e.operationName,this.isParent=t}setGraphqlService(e){this.graphqlService=e}withFields(e){return e.forEach((e=>this.fields.add(e))),this}withFilter(e){if(this.isParent)throw new Error("Cannot apply filters to a parent query.");return this.filters.push(e),this}withLimit(e){if(this.isParent)throw new Error("Cannot apply limit to a parent query.");return this.limit=e,this}withFirst(e){if(this.isParent)throw new Error("Cannot apply limit to a parent query.");return this.first=e,this}withOffset(e){if(this.isParent)throw new Error("Cannot apply offset to a parent query.");return this.offset=e,this}withOrderBy(e){if(this.isParent)throw new Error("Cannot apply orderBy to a parent query.");return this.orderBy=e,this}withCursor(e){if(this.isParent)throw new Error("Cannot apply cursor to a parent query.");return this.after=e,this}withParentQuery(e){const t=new GraphQLQueryBuilder({objectName:e,operationName:this.operationName},!0);return this.parentQueries[e]=t,t}withChildQuery(e){const t=new GraphQLQueryBuilder({objectName:e,operationName:this.operationName});return this.childQueries[e]=t,t}formatQueryFields(){const e=Object.entries(this.parentQueries).map((([e,t])=>`${e} { ${t.formatQueryFields()} }`)).join(", "),t=Object.entries(this.childQueries).map((([e,t])=>{const r=t.build();return`${e} ${r.filter?`(filter: "${r.filter}")`:""} { ${r.fields||"UID"} }`})).join(", ");return[...this.fields,e,t].filter(Boolean).join(", ")}build(){return{objectName:this.objectName,operationName:this.operationName,fields:this.formatQueryFields(),filter:this.filters.length>0?this.filters.join(" AND "):void 0,first:this.first,limit:this.limit,offset:this.offset,orderBy:this.orderBy,after:this.after,readOnly:this.queryParams.readOnly}}execute(){return __awaiter(this,void 0,void 0,(function*(){if(!this.graphqlService)return Promise.reject(new Error("No GraphQL service set for query execution."));const e=this.build();return e.readOnly=this.queryParams.readOnly,yield this.graphqlService.query(e)}))}executeAll(){return __awaiter(this,arguments,void 0,(function*(e=1,t=20){if(!this.graphqlService)throw new Error("No GraphQL service set for query execution.");if(e<1)throw new Error("fromPage must be at least 1.");if(t<e)throw new Error("toPage must be greater than or equal to fromPage.");const r=Math.min(t,20),i=this.build(),s=yield this.graphqlService.query(i),a=s.totalCount;if(0===a)return{records:[],totalCount:0,pageInfo:{hasNextPage:!1},endCursor:"",endOffset:0};const o=this.limit||this.first||200,n=Math.ceil(a/o),h=Math.min(r,n);if(0===Math.max(0,h-e+1))return{records:[],totalCount:a,pageInfo:{hasNextPage:h<n},endCursor:"",endOffset:(e-1)*o};const u=[];for(let t=e-1;t<h;t++){const e=new GraphQLQueryBuilder({objectName:this.objectName,operationName:this.operationName,readOnly:this.queryParams.readOnly});e.setGraphqlService(this.graphqlService),e.fields=new Set(this.fields),e.filters=[...this.filters],void 0!==this.limit?e.limit=o:e.first=o,e.offset=t*o,e.orderBy=this.orderBy,e.after=this.after,u.push(e)}const l=yield this.graphqlService.queryBatch(u),f=l.flatMap((e=>e.records)),c=l[l.length-1];return{records:f,totalCount:s.totalCount,pageInfo:c.pageInfo,endCursor:c.endCursor,endOffset:c.endOffset}}))}toString(){return`{ ${this.objectName} { ${this.formatQueryFields()} } }`}}exports.GraphQLQueryBuilder=GraphQLQueryBuilder;
@@ -1 +1 @@
1
- "use strict";var __decorate=this&&this.__decorate||function(e,t,a,r){var o,n=arguments.length,i=n<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,a):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,a,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(i=(n<3?o(i):n>3?o(t,a,i):o(t,a))||i);return n>3&&i&&Object.defineProperty(t,a,i),i},__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,a,r){return new(a||(a=Promise))((function(o,n){function i(e){try{d(r.next(e))}catch(e){n(e)}}function s(e){try{d(r.throw(e))}catch(e){n(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof a?t:new a((function(e){e(t)}))).then(i,s)}d((r=r.apply(e,t||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.GraphQLService=void 0;const constants_1=require("../../constants"),request_header_constants_1=require("../../core/request-header-constants"),logging_1=require("../../logging"),queries_1=require("./queries");class GraphQLService{constructor(e){this.client=e}query(e){return __awaiter(this,void 0,void 0,(function*(){var t,a,r,o,n,i,s,d,u,c,_,l;e.objectName=this.getQueryName(e.objectName);const p=(0,queries_1.FETCH_RECORDS_QUERY)(e),h=this.getQueryHeaders(e),v=yield this.client.execute(p,h),g={records:(null===(a=null===(t=null==v?void 0:v.data)||void 0===t?void 0:t[e.objectName])||void 0===a?void 0:a.edges.map((e=>e.node)))||[],totalCount:(null===(o=null===(r=null==v?void 0:v.data)||void 0===r?void 0:r[e.objectName])||void 0===o?void 0:o.totalCount)||0,pageInfo:(null===(i=null===(n=null==v?void 0:v.data)||void 0===n?void 0:n[e.objectName])||void 0===i?void 0:i.pageInfo)||{}};if(g.records.length>0){const t=(null===(u=null===(d=null===(s=null==v?void 0:v.data)||void 0===s?void 0:s[e.objectName])||void 0===d?void 0:d.edges)||void 0===u?void 0:u.map((e=>e.offset)))||[],a=(null===(l=null===(_=null===(c=null==v?void 0:v.data)||void 0===c?void 0:c[e.objectName])||void 0===_?void 0:_.edges)||void 0===l?void 0:l.map((e=>e.cursor)))||[];g.endOffset=t[t.length-1],g.endCursor=a[a.length-1]}return g}))}queryBatch(e){return __awaiter(this,void 0,void 0,(function*(){if(!e.length)return[];const t=e.map((e=>e.build()));return this.executeBatchQueries(t)}))}executeBatchQueries(e){return __awaiter(this,void 0,void 0,(function*(){if(!e.length)return[];const t=e.map((e=>{const t=Object.assign(Object.assign({},e),{objectName:this.getQueryName(e.objectName)});return(0,queries_1.FETCH_RECORDS_QUERY)(t)})),a=this.getQueryHeaders(e[0]);return(yield this.client.executeBatch(t,a)).map(((t,a)=>{var r,o,n,i,s,d,u,c,_,l,p,h;const v=e[a],g={records:(null===(o=null===(r=null==t?void 0:t.data)||void 0===r?void 0:r[v.objectName])||void 0===o?void 0:o.edges.map((e=>e.node)))||[],totalCount:(null===(i=null===(n=null==t?void 0:t.data)||void 0===n?void 0:n[v.objectName])||void 0===i?void 0:i.totalCount)||0,pageInfo:(null===(d=null===(s=null==t?void 0:t.data)||void 0===s?void 0:s[v.objectName])||void 0===d?void 0:d.pageInfo)||{}};if(g.records.length>0){const e=(null===(_=null===(c=null===(u=null==t?void 0:t.data)||void 0===u?void 0:u[v.objectName])||void 0===c?void 0:c.edges)||void 0===_?void 0:_.map((e=>e.offset)))||[],a=(null===(h=null===(p=null===(l=null==t?void 0:t.data)||void 0===l?void 0:l[v.objectName])||void 0===p?void 0:p.edges)||void 0===h?void 0:h.map((e=>e.cursor)))||[];g.endOffset=e[e.length-1],g.endCursor=a[a.length-1]}return g}))}))}mutate(e){return __awaiter(this,void 0,void 0,(function*(){if(!e.records||0===e.records.length)return Promise.resolve({data:{schema:{}}});let t="";switch(e.operation){case constants_1.GraphqlOperations.DELETE:t=(0,queries_1.DELETE_OBJECTS_MUTATION)(e);break;case constants_1.GraphqlOperations.INSERT:case constants_1.GraphqlOperations.UPDATE:case constants_1.GraphqlOperations.UPSERT:t=(0,queries_1.MUTATE_OBJECTS_MUTATION)(e);break;default:throw new Error(`Invalid operation: ${e.operation}`)}const a=this.getMutationHeaders(e);return yield this.client.execute(t,a)}))}mutateBatch(e){return __awaiter(this,void 0,void 0,(function*(){if(!e.length)return[];e.forEach(((e,t)=>{if(!e.records||0===e.records.length)throw new Error(`Mutation at index ${t} has empty or null records for operation '${e.operationName}'`)}));const t=e.map((e=>{switch(e.operation){case constants_1.GraphqlOperations.DELETE:return(0,queries_1.DELETE_OBJECTS_MUTATION)(e);case constants_1.GraphqlOperations.INSERT:case constants_1.GraphqlOperations.UPDATE:case constants_1.GraphqlOperations.UPSERT:return(0,queries_1.MUTATE_OBJECTS_MUTATION)(e);default:throw new Error(`Invalid operation: ${e.operation}`)}})),a=this.getMutationHeaders(e[0]);return yield this.client.executeBatch(t,a)}))}delete(e){return __awaiter(this,void 0,void 0,(function*(){return e.operation=constants_1.GraphqlOperations.DELETE,this.mutate(e)}))}update(e){return __awaiter(this,void 0,void 0,(function*(){return e.operation=constants_1.GraphqlOperations.UPDATE,this.mutate(e)}))}insert(e){return __awaiter(this,void 0,void 0,(function*(){return e.operation=constants_1.GraphqlOperations.INSERT,this.mutate(e)}))}upsert(e){return __awaiter(this,void 0,void 0,(function*(){return e.operation=constants_1.GraphqlOperations.UPSERT,this.mutate(e)}))}extractUIDs(e){var t;return(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.schema)?Object.values(e.data.schema):[]}getQueryName(e){return e.charAt(0).toLowerCase()+e.slice(1)}getQueryHeaders(e){const t=this.getOperationHeader(e.operationName);return e.readOnly&&(t[request_header_constants_1.REQUEST_HEADERS.X_SKEDULO_READ_ONLY]="true"),t}getMutationHeaders(e){const t=this.getOperationHeader(e.operationName);return e.bulkOperation&&(t[request_header_constants_1.REQUEST_HEADERS.X_SKEDULO_BULK_OPERATION]="true"),e.suppressChangeEvents&&(t[request_header_constants_1.REQUEST_HEADERS.X_SKEDULO_SUPPRESS_CHANGE_EVENTS]="true"),t}getOperationHeader(e){return{[request_header_constants_1.REQUEST_HEADERS.X_GRAPHQL_OPERATION]:e}}}exports.GraphQLService=GraphQLService,__decorate([(0,logging_1.LogMethod)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],GraphQLService.prototype,"query",null),__decorate([(0,logging_1.LogMethod)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Array]),__metadata("design:returntype",Promise)],GraphQLService.prototype,"queryBatch",null),__decorate([(0,logging_1.LogMethod)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],GraphQLService.prototype,"mutate",null),__decorate([(0,logging_1.LogMethod)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Array]),__metadata("design:returntype",Promise)],GraphQLService.prototype,"mutateBatch",null),__decorate([(0,logging_1.LogMethod)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],GraphQLService.prototype,"delete",null),__decorate([(0,logging_1.LogMethod)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],GraphQLService.prototype,"update",null),__decorate([(0,logging_1.LogMethod)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],GraphQLService.prototype,"insert",null),__decorate([(0,logging_1.LogMethod)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],GraphQLService.prototype,"upsert",null);
1
+ "use strict";var __decorate=this&&this.__decorate||function(e,t,a,r){var o,n=arguments.length,i=n<3?t:null===r?r=Object.getOwnPropertyDescriptor(t,a):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)i=Reflect.decorate(e,t,a,r);else for(var s=e.length-1;s>=0;s--)(o=e[s])&&(i=(n<3?o(i):n>3?o(t,a,i):o(t,a))||i);return n>3&&i&&Object.defineProperty(t,a,i),i},__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,a,r){return new(a||(a=Promise))((function(o,n){function i(e){try{d(r.next(e))}catch(e){n(e)}}function s(e){try{d(r.throw(e))}catch(e){n(e)}}function d(e){var t;e.done?o(e.value):(t=e.value,t instanceof a?t:new a((function(e){e(t)}))).then(i,s)}d((r=r.apply(e,t||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.GraphQLService=void 0;const constants_1=require("../../constants"),request_header_constants_1=require("../../core/request-header-constants"),logging_1=require("../../logging"),queries_1=require("./queries");class GraphQLService{constructor(e){this.client=e}query(e){return __awaiter(this,void 0,void 0,(function*(){var t,a,r,o,n,i,s,d,u,c,l,_;e.objectName=this.getQueryName(e.objectName);const p=(0,queries_1.FETCH_RECORDS_QUERY)(e),v=this.getQueryHeaders(e),h=yield this.client.execute(p,v),g={records:(null===(a=null===(t=null==h?void 0:h.data)||void 0===t?void 0:t[e.objectName])||void 0===a?void 0:a.edges.map((e=>e.node)))||[],totalCount:(null===(o=null===(r=null==h?void 0:h.data)||void 0===r?void 0:r[e.objectName])||void 0===o?void 0:o.totalCount)||0,pageInfo:(null===(i=null===(n=null==h?void 0:h.data)||void 0===n?void 0:n[e.objectName])||void 0===i?void 0:i.pageInfo)||{}};if(g.records.length>0){const t=(null===(u=null===(d=null===(s=null==h?void 0:h.data)||void 0===s?void 0:s[e.objectName])||void 0===d?void 0:d.edges)||void 0===u?void 0:u.map((e=>e.offset)))||[],a=(null===(_=null===(l=null===(c=null==h?void 0:h.data)||void 0===c?void 0:c[e.objectName])||void 0===l?void 0:l.edges)||void 0===_?void 0:_.map((e=>e.cursor)))||[];g.endOffset=t[t.length-1],g.endCursor=a[a.length-1]}return(null==h?void 0:h.queryLimit)&&(g.queryLimit=h.queryLimit),g}))}queryBatch(e){return __awaiter(this,void 0,void 0,(function*(){if(!e.length)return[];const t=e.map((e=>e.build()));return this.executeBatchQueries(t)}))}executeBatchQueries(e){return __awaiter(this,void 0,void 0,(function*(){if(!e.length)return[];const t=e.map((e=>{const t=Object.assign(Object.assign({},e),{objectName:this.getQueryName(e.objectName)});return(0,queries_1.FETCH_RECORDS_QUERY)(t)})),a=this.getQueryHeaders(e[0]);return(yield this.client.executeBatch(t,a)).map(((t,a)=>{var r,o,n,i,s,d,u,c,l,_,p,v;const h=e[a],g={records:(null===(o=null===(r=null==t?void 0:t.data)||void 0===r?void 0:r[h.objectName])||void 0===o?void 0:o.edges.map((e=>e.node)))||[],totalCount:(null===(i=null===(n=null==t?void 0:t.data)||void 0===n?void 0:n[h.objectName])||void 0===i?void 0:i.totalCount)||0,pageInfo:(null===(d=null===(s=null==t?void 0:t.data)||void 0===s?void 0:s[h.objectName])||void 0===d?void 0:d.pageInfo)||{}};if(g.records.length>0){const e=(null===(l=null===(c=null===(u=null==t?void 0:t.data)||void 0===u?void 0:u[h.objectName])||void 0===c?void 0:c.edges)||void 0===l?void 0:l.map((e=>e.offset)))||[],a=(null===(v=null===(p=null===(_=null==t?void 0:t.data)||void 0===_?void 0:_[h.objectName])||void 0===p?void 0:p.edges)||void 0===v?void 0:v.map((e=>e.cursor)))||[];g.endOffset=e[e.length-1],g.endCursor=a[a.length-1]}return(null==t?void 0:t.queryLimit)&&(g.queryLimit=t.queryLimit),g}))}))}mutate(e){return __awaiter(this,void 0,void 0,(function*(){if(!e.records||0===e.records.length)return Promise.resolve({data:{schema:{}}});let t="";switch(e.operation){case constants_1.GraphqlOperations.DELETE:t=(0,queries_1.DELETE_OBJECTS_MUTATION)(e);break;case constants_1.GraphqlOperations.INSERT:case constants_1.GraphqlOperations.UPDATE:case constants_1.GraphqlOperations.UPSERT:t=(0,queries_1.MUTATE_OBJECTS_MUTATION)(e);break;default:throw new Error(`Invalid operation: ${e.operation}`)}const a=this.getMutationHeaders(e);return yield this.client.execute(t,a)}))}mutateBatch(e){return __awaiter(this,void 0,void 0,(function*(){if(!e.length)return[];e.forEach(((e,t)=>{if(!e.records||0===e.records.length)throw new Error(`Mutation at index ${t} has empty or null records for operation '${e.operationName}'`)}));const t=e.map((e=>{switch(e.operation){case constants_1.GraphqlOperations.DELETE:return(0,queries_1.DELETE_OBJECTS_MUTATION)(e);case constants_1.GraphqlOperations.INSERT:case constants_1.GraphqlOperations.UPDATE:case constants_1.GraphqlOperations.UPSERT:return(0,queries_1.MUTATE_OBJECTS_MUTATION)(e);default:throw new Error(`Invalid operation: ${e.operation}`)}})),a=this.getMutationHeaders(e[0]);return yield this.client.executeBatch(t,a)}))}delete(e){return __awaiter(this,void 0,void 0,(function*(){return e.operation=constants_1.GraphqlOperations.DELETE,this.mutate(e)}))}update(e){return __awaiter(this,void 0,void 0,(function*(){return e.operation=constants_1.GraphqlOperations.UPDATE,this.mutate(e)}))}insert(e){return __awaiter(this,void 0,void 0,(function*(){return e.operation=constants_1.GraphqlOperations.INSERT,this.mutate(e)}))}upsert(e){return __awaiter(this,void 0,void 0,(function*(){return e.operation=constants_1.GraphqlOperations.UPSERT,this.mutate(e)}))}extractUIDs(e){var t;return(null===(t=null==e?void 0:e.data)||void 0===t?void 0:t.schema)?Object.values(e.data.schema):[]}getQueryName(e){return e.charAt(0).toLowerCase()+e.slice(1)}getQueryHeaders(e){const t=this.getOperationHeader(e.operationName);return e.readOnly&&(t[request_header_constants_1.REQUEST_HEADERS.X_SKEDULO_READ_ONLY]="true"),t}getMutationHeaders(e){const t=this.getOperationHeader(e.operationName);return e.bulkOperation&&(t[request_header_constants_1.REQUEST_HEADERS.X_SKEDULO_BULK_OPERATION]="true"),e.suppressChangeEvents&&(t[request_header_constants_1.REQUEST_HEADERS.X_SKEDULO_SUPPRESS_CHANGE_EVENTS]="true"),t}getOperationHeader(e){return{[request_header_constants_1.REQUEST_HEADERS.X_GRAPHQL_OPERATION]:e}}}exports.GraphQLService=GraphQLService,__decorate([(0,logging_1.LogMethod)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],GraphQLService.prototype,"query",null),__decorate([(0,logging_1.LogMethod)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Array]),__metadata("design:returntype",Promise)],GraphQLService.prototype,"queryBatch",null),__decorate([(0,logging_1.LogMethod)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],GraphQLService.prototype,"mutate",null),__decorate([(0,logging_1.LogMethod)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Array]),__metadata("design:returntype",Promise)],GraphQLService.prototype,"mutateBatch",null),__decorate([(0,logging_1.LogMethod)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],GraphQLService.prototype,"delete",null),__decorate([(0,logging_1.LogMethod)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],GraphQLService.prototype,"update",null),__decorate([(0,logging_1.LogMethod)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],GraphQLService.prototype,"insert",null),__decorate([(0,logging_1.LogMethod)(),__metadata("design:type",Function),__metadata("design:paramtypes",[Object]),__metadata("design:returntype",Promise)],GraphQLService.prototype,"upsert",null);
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MUTATE_OBJECTS_MUTATION=exports.DELETE_OBJECTS_MUTATION=exports.FETCH_RECORDS_QUERY=void 0;const FETCH_RECORDS_QUERY=({objectName:e,operationName:n,filter:t,first:o=200,offset:r=0,after:T,orderBy:E,fields:s})=>`\n query ${n} {\n ${e}(${[t?`filter: "${t}"`:"",T?`after: "${T}"`:"",`first: ${o}`,r?`offset: ${r}`:"",E?`orderBy: "${E}"`:""].filter((e=>e)).join(", ")}) {\n totalCount\n pageInfo{\n hasNextPage\n }\n edges {\n cursor\n offset\n node {\n ${s||"UID"}\n }\n }\n }\n }\n `;exports.FETCH_RECORDS_QUERY=FETCH_RECORDS_QUERY;const DELETE_OBJECTS_MUTATION=({objectName:e,operationName:n,records:t})=>`\n mutation ${n} {\n schema {\n ${t.map(((n,t)=>`alias${t+1}:delete${e}(UID: "${n.UID}")`)).join("\n ")}\n }\n }`;exports.DELETE_OBJECTS_MUTATION=DELETE_OBJECTS_MUTATION;const MUTATE_OBJECTS_MUTATION=({objectName:e,operationName:n,records:t,operation:o,keyField:r})=>{let T;return T="upsert"===o?t.map(((n,t)=>`\n alias${t+1}:upsert${e}(\n keyField: "${r||"UID"}",\n input: {\n ${Object.entries(n).map((([e,n])=>`${e}: ${"string"==typeof n?`"${n}"`:n}`)).join(", ")}\n }\n )\n `)).join("\n "):t.map(((n,t)=>`\n alias${t+1}:${o}${e}(\n input: {\n ${Object.entries(n).map((([e,n])=>`${e}: ${"string"==typeof n?`"${n}"`:n}`)).join(", ")}\n }\n )\n `)).join("\n "),`\n mutation ${n} {\n schema {\n ${T}\n }\n }\n `};exports.MUTATE_OBJECTS_MUTATION=MUTATE_OBJECTS_MUTATION;
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.MUTATE_OBJECTS_MUTATION=exports.DELETE_OBJECTS_MUTATION=exports.FETCH_RECORDS_QUERY=void 0;const FETCH_RECORDS_QUERY=({objectName:n,operationName:e,filter:t,first:o=200,limit:r,offset:T=0,after:i,orderBy:s,fields:E})=>{const a=void 0!==r,$=a?r:o;return`\n query ${e} {\n ${n}(${[t?`filter: "${t}"`:"",i?`after: "${i}"`:"",a?`limit: ${$}`:`first: ${$}`,T?`offset: ${T}`:"",s?`orderBy: "${s}"`:""].filter((n=>n)).join(", ")}) {\n totalCount\n pageInfo{\n hasNextPage\n }\n edges {\n cursor\n offset\n node {\n ${E||"UID"}\n }\n }\n }\n }\n `};exports.FETCH_RECORDS_QUERY=FETCH_RECORDS_QUERY;const DELETE_OBJECTS_MUTATION=({objectName:n,operationName:e,records:t})=>`\n mutation ${e} {\n schema {\n ${t.map(((e,t)=>`alias${t+1}:delete${n}(UID: "${e.UID}")`)).join("\n ")}\n }\n }`;exports.DELETE_OBJECTS_MUTATION=DELETE_OBJECTS_MUTATION;const MUTATE_OBJECTS_MUTATION=({objectName:n,operationName:e,records:t,operation:o,keyField:r})=>{let T;return T="upsert"===o?t.map(((e,t)=>`\n alias${t+1}:upsert${n}(\n keyField: "${r||"UID"}",\n input: {\n ${Object.entries(e).map((([n,e])=>`${n}: ${"string"==typeof e?`"${e}"`:e}`)).join(", ")}\n }\n )\n `)).join("\n "):t.map(((e,t)=>`\n alias${t+1}:${o}${n}(\n input: {\n ${Object.entries(e).map((([n,e])=>`${n}: ${"string"==typeof e?`"${e}"`:e}`)).join(", ")}\n }\n )\n `)).join("\n "),`\n mutation ${e} {\n schema {\n ${T}\n }\n }\n `};exports.MUTATE_OBJECTS_MUTATION=MUTATE_OBJECTS_MUTATION;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@skedulo/pulse-solution-services",
3
- "version": "0.0.19",
3
+ "version": "0.0.20",
4
4
  "description": "A collection of services and utilities to support solution development on the Pulse platform.",
5
5
  "author": "Skedulo",
6
6
  "license": "MIT",
@@ -16,7 +16,7 @@
16
16
  "format": "prettier --write './**/*.ts'",
17
17
  "format:check": "prettier --check './**/*.ts'",
18
18
  "prepare-release": "yarn format && yarn build",
19
- "release-package": "yarn build && yarn clean:types && yarn publish --access public"
19
+ "release-package": "yarn build && yarn clean:types && npm publish --access public"
20
20
  },
21
21
  "files": [
22
22
  "dist/",
package/CHANGELOG.md DELETED
@@ -1,59 +0,0 @@
1
- # Changelog
2
-
3
- ## [v0.0.19] - 2025-08-04
4
- ### Fixed
5
- - Fixed unique batch issue
6
-
7
- ## [v0.0.18] - 2025-07-16
8
- ### Update
9
- - Support upsert and status polling in artifact client
10
-
11
- ## [v0.0.16] - 2025-06-19
12
- ### Added
13
- - Support upsert mutation.
14
- - Support batch queries and mutations.
15
-
16
- ## [v0.0.15] - 2025-05-21
17
- ### Updated
18
- - Enable GraphQLRequest with variable to graphqlClient
19
-
20
- ## [v0.0.14] - 2025-05-21
21
- ### Added
22
- - Add graphql mutation option to suppress change events.
23
-
24
- ## [v0.0.12] - 2025-03-19
25
- ### Updated
26
- - Include `baseClient.performRequest` in execution limits calculation.
27
- - Create a singleton instance for `ExecutionContext`.
28
-
29
- ## [v0.0.11] - 2025-03-17
30
- ### Added
31
- - Execution Limits
32
-
33
- ## [v0.0.10] - 2025-03-03
34
- ### Changed
35
- - Minor changes
36
-
37
- ## [v0.0.9] - 2025-02-28
38
- ### Added
39
- - Lock Service, Unique Batch
40
-
41
- ## [v0.0.8] - 2025-02-17
42
- ### Added
43
- - GraphBatch
44
-
45
- ### Deprecated
46
- - BatchOrchestrator
47
-
48
-
49
- ## [v0.0.7] - 2025-02-13
50
- ### Added
51
- - Geo API Client, Geo Service, Resource Builder, Resource Validator
52
-
53
- ## [v0.0.6] - 2025-02-06
54
- ### Added
55
- - API Clients for Artifact, Vocabulary, Config Templates, and Org Preference, Notification APIs.
56
-
57
- ## [v0.0.5] - 2025-02-03
58
- ### Initial Release
59
- - First version of the project.
@@ -1 +0,0 @@
1
- export * from "./log-method";
@@ -1,7 +0,0 @@
1
- /**
2
- * This decorator logs the input arguments and output results of a method,
3
- * including error handling with ANSI color-coded logs for better console readability.
4
- * It allows selective logging based on the `LOG_NAMESPACE` environment variable.
5
- * Uses Winston logger but retains ANSI colors for console logs.
6
- */
7
- export declare function LogMethod(namespace?: string): (target: any, propertyKey: any, descriptor: any) => any;
@@ -1,6 +0,0 @@
1
- /**
2
- * Decorator factory that takes a MonitoringManager instance and an optional
3
- * explicit methodIdentifier override. If not provided, the decorator will
4
- * default to ClassName.MethodName.
5
- */
6
- export declare function MonitorCall(methodIdentifier?: string): (target: any, propertyKey: string, descriptor: PropertyDescriptor) => PropertyDescriptor;