@skedulo/pulse-solution-services 0.0.6 → 0.0.7

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 (69) hide show
  1. package/CHANGELOG.md +5 -1
  2. package/README.md +226 -3
  3. package/dist/clients/availability-api-client.js +1 -0
  4. package/dist/clients/geo-api-client.js +1 -0
  5. package/dist/constants/index.js +1 -1
  6. package/dist/constants/tenant-endpoints.js +1 -1
  7. package/dist/core/entity-factory.js +1 -0
  8. package/dist/core/execution-context.js +1 -1
  9. package/dist/core/index.js +1 -1
  10. package/dist/core/tenant-objects.js +1 -0
  11. package/dist/index.d.ts +469 -44
  12. package/dist/interfaces/geoservice-interfaces.js +1 -0
  13. package/dist/interfaces/index.js +1 -1
  14. package/dist/interfaces/resource-availability.js +1 -0
  15. package/dist/services/data-service.js +1 -0
  16. package/dist/services/geoservice.js +1 -0
  17. package/dist/services/graphql/graphql-query-builder.d.ts +11 -24
  18. package/dist/services/graphql/graphql-query-builder.js +1 -1
  19. package/dist/services/index.js +1 -1
  20. package/dist/services/resource-availability/builder/data-service.d.ts +9 -0
  21. package/dist/services/resource-availability/builder/data-service.js +1 -0
  22. package/dist/services/resource-availability/builder/index.d.ts +3 -0
  23. package/dist/services/resource-availability/builder/index.js +1 -0
  24. package/dist/services/resource-availability/builder/resource-availability-service.d.ts +8 -0
  25. package/dist/services/resource-availability/builder/resource-availability-service.js +1 -0
  26. package/dist/services/resource-availability/builder/resource-builder.d.ts +17 -0
  27. package/dist/services/resource-availability/builder/resource-builder.js +1 -0
  28. package/dist/services/resource-availability/builder/resource-query-param.d.ts +23 -0
  29. package/dist/services/resource-availability/builder/resource-query-param.js +1 -0
  30. package/dist/services/resource-availability/index.d.ts +2 -0
  31. package/dist/services/resource-availability/index.js +1 -0
  32. package/dist/services/resource-availability/object-factory.d.ts +13 -0
  33. package/dist/services/resource-availability/object-factory.js +1 -0
  34. package/dist/services/resource-availability/resource-availability-service.d.ts +7 -0
  35. package/dist/services/resource-availability/resource-availability-service.js +1 -0
  36. package/dist/services/resource-availability/resource-builder.d.ts +16 -0
  37. package/dist/services/resource-availability/resource-builder.js +1 -0
  38. package/dist/services/resource-availability/resource-query-service.d.ts +7 -0
  39. package/dist/services/resource-availability/resource-query-service.js +1 -0
  40. package/dist/services/resource-availability/resource-validator.d.ts +29 -0
  41. package/dist/services/resource-availability/resource-validator.js +1 -0
  42. package/dist/services/resource-availability/validator/index.d.ts +3 -0
  43. package/dist/services/resource-availability/validator/index.js +1 -0
  44. package/dist/services/resource-availability/validator/resource-job-validation.d.ts +11 -0
  45. package/dist/services/resource-availability/validator/resource-job-validation.js +1 -0
  46. package/dist/services/resource-availability/validator/resource-validation-option.d.ts +5 -0
  47. package/dist/services/resource-availability/validator/resource-validation-option.js +1 -0
  48. package/dist/services/resource-availability/validator/resource-validator.d.ts +13 -0
  49. package/dist/services/resource-availability/validator/resource-validator.js +1 -0
  50. package/dist/services/resource-availability/validator/validation-result.d.ts +12 -0
  51. package/dist/services/resource-availability/validator/validation-result.js +1 -0
  52. package/dist/utils/datetime-utils.js +1 -0
  53. package/dist/utils/index.js +1 -1
  54. package/package.json +4 -1
  55. package/yarn.lock +15 -0
  56. package/dist/clients/artifacts/artifact-client.d.ts +0 -19
  57. package/dist/clients/artifacts/artifact-client.js +0 -1
  58. package/dist/clients/artifacts/base-artifact-client.d.ts +0 -14
  59. package/dist/clients/artifacts/base-artifact-client.js +0 -1
  60. package/dist/clients/artifacts/object-based-artifact-client.d.ts +0 -11
  61. package/dist/clients/artifacts/object-based-artifact-client.js +0 -1
  62. package/dist/clients/custom-field-client.js +0 -1
  63. package/dist/clients/custom-schema-client.js +0 -1
  64. package/dist/constants/artifact.js +0 -1
  65. package/dist/constants/config-var.js +0 -1
  66. package/dist/constants/config-variable-constants.js +0 -1
  67. package/dist/constants/mobile-notification.js +0 -1
  68. /package/dist/{interfaces/custom-field.js → core/tenant-entities.js} +0 -0
  69. /package/dist/interfaces/{custom-schema.js → availability.js} +0 -0
package/dist/index.d.ts CHANGED
@@ -396,27 +396,189 @@ export declare const TENANT_ENDPOINTS: {
396
396
  readonly SEND_SMS: "notifications/sms";
397
397
  readonly SMS_CONFIRMATION_REQUEST: "notifications/sms/confirmation_request";
398
398
  };
399
+ readonly GEOSERVICES: {
400
+ readonly DISTANCE_MATRIX: "geoservices/distanceMatrix";
401
+ readonly DIRECTIONS: "geoservices/directions";
402
+ readonly GEOCODE: "geoservices/geocode";
403
+ readonly AUTOCOMPLETE: "geoservices/autocomplete";
404
+ readonly PLACE: "geoservices/place";
405
+ readonly TIMEZONE: "geoservices/timezone";
406
+ };
407
+ readonly AVAILABILITY: {
408
+ readonly SIMPLE: "availability/simple";
409
+ };
399
410
  };
400
- export declare enum TenantObject {
401
- Accounts = "Accounts",
402
- Jobs = "Jobs",
403
- JobAllocations = "JobAllocations",
404
- Regions = "Regions",
405
- Contacts = "Contacts",
406
- Locations = "Locations",
407
- Resources = "Resources",
408
- Tags = "Tags",
409
- JobTags = "JobTags",
410
- ResourceTags = "ResourceTags",
411
- Activities = "Activities",
412
- Availabilities = "Availabilities",
413
- Holidays = "Holidays",
414
- AvailabilityPatterns = "AvailabilityPatterns",
415
- AvailabilityPatternResources = "AvailabilityPatternResources",
416
- AccountResourceScores = "AccountResourceScores",
417
- LocationResourceScores = "LocationResourceScores",
418
- Products = "Products",
419
- JobProducts = "JobProducts"
411
+ export interface LatLng {
412
+ lat: number;
413
+ lng: number;
414
+ }
415
+ export interface DistanceMatrixRequest {
416
+ origins: LatLng[];
417
+ destinations: LatLng[];
418
+ avoid?: ("ferry" | "highway" | "toll")[];
419
+ departureTime?: string;
420
+ }
421
+ export interface DistanceMatrixResponse {
422
+ matrix: DistanceMatrixEntry[][];
423
+ vendor: string;
424
+ }
425
+ export interface DistanceMatrixEntry {
426
+ status: "OK" | "NO_ROUTE";
427
+ duration?: {
428
+ durationInSeconds: number;
429
+ };
430
+ distance?: {
431
+ distanceInMeters: number;
432
+ };
433
+ }
434
+ export interface DirectionsRequest {
435
+ requests: {
436
+ origin: LatLng;
437
+ destination: LatLng;
438
+ waypoints?: LatLng[];
439
+ avoid?: ("ferry" | "highway" | "toll")[];
440
+ }[];
441
+ }
442
+ export interface DirectionsResponse {
443
+ routes: {
444
+ leg: {
445
+ origin: LatLng;
446
+ destination: LatLng;
447
+ };
448
+ travelInfo: {
449
+ status: "OK" | "NO_ROUTE";
450
+ duration: {
451
+ durationInSeconds: number;
452
+ };
453
+ distance: {
454
+ distanceInMeters: number;
455
+ };
456
+ };
457
+ }[];
458
+ }
459
+ export interface GeocodeRequest {
460
+ addresses: string[];
461
+ language?: string;
462
+ responseType?: "allMatches";
463
+ }
464
+ export interface GeocodeResponse {
465
+ result: {
466
+ address: string;
467
+ latLng: LatLng;
468
+ granularity?: string;
469
+ }[];
470
+ }
471
+ export interface AutocompleteRequest {
472
+ input: string;
473
+ sessionId?: string;
474
+ location?: LatLng;
475
+ radius?: number;
476
+ country?: string;
477
+ }
478
+ export interface AutocompleteResponse {
479
+ predictions: {
480
+ description: string;
481
+ placeId: string;
482
+ }[];
483
+ status: "OK" | "ZERO_RESULTS";
484
+ errorMessage?: string;
485
+ }
486
+ export interface PlaceRequest {
487
+ placeId: string;
488
+ sessionId: string;
489
+ }
490
+ export interface PlaceResponse {
491
+ addressComponents: {
492
+ streetNumber: string;
493
+ route: string;
494
+ localCity: string;
495
+ area2: string;
496
+ area1: string;
497
+ country: string;
498
+ postalCode: string;
499
+ };
500
+ formattedAddress: string;
501
+ geometry: LatLng;
502
+ }
503
+ export interface TimezoneRequest {
504
+ location: [
505
+ number,
506
+ number
507
+ ];
508
+ timestamp: number;
509
+ }
510
+ export interface TimezoneResponse {
511
+ dstOffset: number;
512
+ rawOffset: number;
513
+ timeZoneId: string;
514
+ }
515
+ export interface BaseObject {
516
+ id: string;
517
+ name: string;
518
+ propertyMap?: Record<string, any>;
519
+ }
520
+ export interface BaseEvent extends BaseObject {
521
+ start: Date;
522
+ finish: Date;
523
+ eventType?: string;
524
+ description?: string;
525
+ geoLocation?: LatLng;
526
+ }
527
+ export interface Resource extends BaseObject {
528
+ category?: string;
529
+ employmentType?: string;
530
+ resourceType?: string;
531
+ userId?: string;
532
+ regionId?: string;
533
+ timezone: string;
534
+ tags: Tag[];
535
+ availabilities: BaseEvent[];
536
+ events: BaseEvent[];
537
+ }
538
+ export interface Tag extends BaseObject {
539
+ }
540
+ export interface Availability extends BaseEvent {
541
+ resourceId: string;
542
+ isAvailable: boolean;
543
+ status: string;
544
+ availabilityType: string;
545
+ }
546
+ export interface Activity extends BaseEvent {
547
+ resourceId: string;
548
+ activityType: string;
549
+ }
550
+ export interface JobAllocation extends BaseEvent {
551
+ jobId: string;
552
+ resourceId: string;
553
+ status: string;
554
+ }
555
+ export interface Job extends BaseEvent {
556
+ address: string;
557
+ contactId: string;
558
+ jobStatus: string;
559
+ regionId: string;
560
+ tags: Tag[];
561
+ }
562
+ export interface ResourceShift extends BaseEvent {
563
+ resourceId: string;
564
+ shift: Shift;
565
+ }
566
+ export interface Shift extends BaseEvent {
567
+ regionId: string;
568
+ displayName: string;
569
+ isDraft: boolean;
570
+ }
571
+ export declare class EntityFactory {
572
+ static createBaseObject(data: Record<string, string>): BaseObject;
573
+ static createBaseEvent(data: Record<string, string>): BaseEvent;
574
+ static createTag(data: Record<string, any>): Tag;
575
+ static createResource(data: Record<string, any>): Resource;
576
+ static createJob(data: Record<string, any>): Job;
577
+ static createAvailability(data: Record<string, any>): Availability;
578
+ static createActivity(data: Record<string, any>): Activity;
579
+ static createJobAllocation(data: Record<string, any>): JobAllocation;
580
+ static createResourceShift(data: Record<string, any>): ResourceShift;
581
+ static createShift(data: Record<string, any>): Shift;
420
582
  }
421
583
  export type ArtifactParams = {
422
584
  objectName?: string;
@@ -435,6 +597,58 @@ declare class ArtifactClient extends BaseClient {
435
597
  delete(params: ArtifactParams): Promise<void>;
436
598
  private buildEndpoint;
437
599
  }
600
+ export interface AvailabilityRequestParams {
601
+ /**
602
+ * Array of resource IDs for which availability is requested.
603
+ * Must contain at least one and at most 200 resource IDs.
604
+ */
605
+ resourceIds: string[];
606
+ /**
607
+ * The UTC datetime from which to start fetching availability (ISO 8601 format).
608
+ */
609
+ start: string;
610
+ /**
611
+ * The UTC datetime until which to fetch availability (ISO 8601 format).
612
+ * Must be after start and within 375 days.
613
+ */
614
+ end: string;
615
+ /**
616
+ * If true, merged availability time intervals are returned in the response.
617
+ * Defaults to false.
618
+ */
619
+ mergedAvailabilities?: boolean;
620
+ /**
621
+ * If true (or omitted), a list of availability entries is returned.
622
+ * Defaults to true.
623
+ */
624
+ entries?: boolean;
625
+ }
626
+ export interface AvailabilityResult {
627
+ resourceId: string;
628
+ mergedAvailabilities?: {
629
+ start: string;
630
+ end: string;
631
+ }[];
632
+ entries?: AvailabilityEntry[];
633
+ }
634
+ export interface AvailabilityEntry {
635
+ type: "template" | "pattern" | "override" | "holiday";
636
+ start: string;
637
+ end: string;
638
+ available: boolean;
639
+ templateEntryId?: string;
640
+ name?: string;
641
+ patternId?: string;
642
+ patternRecordId?: string;
643
+ }
644
+ declare class AvailabilityAPIClient extends BaseClient {
645
+ /**
646
+ * Fetches resource availability based on the given request parameters.
647
+ * @param {AvailabilityRequestParams} params - The request parameters for availability.
648
+ * @returns {Promise<AvailabilityResult[]>} - The availability data for the requested resources.
649
+ */
650
+ fetchAvailability(params: AvailabilityRequestParams): Promise<AvailabilityResult[]>;
651
+ }
438
652
  declare class ConfigFeaturesClient extends BaseClient {
439
653
  /**
440
654
  * Fetches feature flags configuration.
@@ -448,6 +662,32 @@ declare class ConfigFeaturesClient extends BaseClient {
448
662
  */
449
663
  update(tenantId: string, newConfig: Record<string, any>): Promise<Record<string, any>>;
450
664
  }
665
+ declare class GeoAPIClient extends BaseClient {
666
+ /**
667
+ * Computes travel distance and time for all combinations of origin and destination locations.
668
+ */
669
+ getDistanceMatrix(data: DistanceMatrixRequest): Promise<DistanceMatrixResponse>;
670
+ /**
671
+ * Calculates directions between source and destination addresses, possibly including waypoints en route.
672
+ */
673
+ getDirections(data: DirectionsRequest): Promise<DirectionsResponse>;
674
+ /**
675
+ * Geocodes a given list of addresses and returns their latitude and longitude coordinates.
676
+ */
677
+ geocodeAddress(data: GeocodeRequest): Promise<GeocodeResponse>;
678
+ /**
679
+ * Provides address autocomplete suggestions based on an input string.
680
+ */
681
+ autocompleteAddress(data: AutocompleteRequest): Promise<AutocompleteResponse>;
682
+ /**
683
+ * Fetches detailed information for a given place ID.
684
+ */
685
+ getPlaceDetails(data: PlaceRequest): Promise<PlaceResponse>;
686
+ /**
687
+ * Retrieves timezone information for a given location and timestamp.
688
+ */
689
+ getTimezone(data: TimezoneRequest): Promise<TimezoneResponse>;
690
+ }
451
691
  export interface JobRequest {
452
692
  jobId: string;
453
693
  }
@@ -654,6 +894,43 @@ export interface CacheOptions<T> {
654
894
  ttl?: number;
655
895
  useSecondaryCache?: boolean;
656
896
  }
897
+ declare class GeoService {
898
+ private geoAPIClient;
899
+ private sessionId;
900
+ constructor(geoAPIClient: GeoAPIClient);
901
+ /**
902
+ * Gets distance matrix and returns a structured result map.
903
+ */
904
+ getDistanceMatrix(origins: LatLng[], destinations: LatLng[]): Promise<Map<string, any>>;
905
+ /**
906
+ * Fetches address suggestions and automatically retrieves place details for the first result.
907
+ */
908
+ getAddressSuggestions(request: AutocompleteRequest, maxResults?: number): Promise<PlaceResponse[] | null>;
909
+ /**
910
+ * Gets timezone information for a given location.
911
+ */
912
+ getTimezone(data: TimezoneRequest): Promise<string>;
913
+ /**
914
+ * Generates a new session ID.
915
+ */
916
+ generateNewSessionId(): string;
917
+ /**
918
+ * Strips trailing zeros from latitude and longitude values.
919
+ *
920
+ * This is necessary because some systems, like Salesforce, may automatically remove trailing zeros
921
+ * when storing or processing geolocation values. If we use raw geocodes (e.g., -78.729880, 35.897187),
922
+ * they might be altered to -78.72988, 35.897187 when retrieved later.
923
+ *
924
+ * Since the Distance Matrix API uses the exact string representation of coordinates as keys for caching
925
+ * and lookup, a mismatch due to trailing zeros can cause unexpected errors or failed lookups.
926
+ * Removing trailing zeros ensures consistency in coordinate representation and prevents key mismatches.
927
+ */
928
+ stripTrailingZeros(value: number): string;
929
+ /**
930
+ * Creates a unique key for origin and destination pair, ensuring stripped trailing zeros.
931
+ */
932
+ createKey(origin: LatLng, destination: LatLng): string;
933
+ }
657
934
  /**
658
935
  * A service class for handling GraphQL operations.
659
936
  */
@@ -721,69 +998,104 @@ export declare class GraphQLQueryBuilder {
721
998
  constructor(objectName: string, isParent?: boolean);
722
999
  /**
723
1000
  * Sets the GraphQL service to use for executing the query.
724
- * @param {GraphQLService} graphqlService - The GraphQL service instance.
725
- * @returns {void}
726
1001
  */
727
1002
  setGraphqlService(graphqlService: GraphQLService): void;
728
1003
  /**
729
- * Specifies the fields to be retrieved.
730
- * @param {string[]} fields - The list of fields to select.
731
- * @returns {this} - The query builder instance.
1004
+ * Specifies the fields to be retrieved. Prevents duplicates.
732
1005
  */
733
1006
  withFields(fields: string[]): this;
734
1007
  /**
735
1008
  * Adds a filter condition to the query.
736
- * @param {string} condition - The filter condition.
737
- * @returns {this} - The query builder instance.
738
1009
  */
739
1010
  withFilter(condition: string): this;
740
1011
  /**
741
1012
  * Sets a limit on the number of records to retrieve.
742
- * @param {number} first - The number of records to fetch.
743
- * @returns {this} - The query builder instance.
744
1013
  */
745
1014
  withLimit(first: number): this;
746
1015
  /**
747
1016
  * Sets an offset for pagination.
748
- * @param {number} offset - The offset value.
749
- * @returns {this} - The query builder instance.
750
1017
  */
751
1018
  withOffset(offset: number): this;
752
1019
  /**
753
1020
  * Sets the order in which records should be retrieved.
754
- * @param {string} orderBy - The field to order by.
755
- * @returns {this} - The query builder instance.
756
1021
  */
757
1022
  withOrderBy(orderBy: string): this;
758
1023
  /**
759
1024
  * Applies cursor-based pagination.
760
- * @param {string} after - The cursor position.
761
- * @returns {this} - The query builder instance.
762
1025
  */
763
1026
  withCursor(after: string): this;
764
1027
  /**
765
1028
  * Creates a parent query.
766
- * @param {string} objectName - The name of the parent object.
767
- * @returns {GraphQLQueryBuilder} - A new query builder instance for the parent.
768
1029
  */
769
1030
  withParentQuery(objectName: string): GraphQLQueryBuilder;
770
1031
  /**
771
1032
  * Creates a child query.
772
- * @param {string} objectName - The name of the child object.
773
- * @returns {GraphQLQueryBuilder} - A new query builder instance for the child.
774
1033
  */
775
1034
  withChildQuery(objectName: string): GraphQLQueryBuilder;
776
1035
  /**
777
- * Builds the GraphQL query parameters.
778
- * @returns {FetchRecordsQueryParams} - The formatted query parameters.
1036
+ * Recursively builds the GraphQL query fields, handling nested queries.
1037
+ */
1038
+ private formatQueryFields;
1039
+ /**
1040
+ * Builds the GraphQL query parameters in a more structured format.
779
1041
  */
780
1042
  build(): FetchRecordsQueryParams;
781
1043
  /**
782
- * Executes the query using the GraphQL service.
783
- * @returns {Promise<QueryResult>} - The query result.
784
- * @throws {Error} - If no GraphQL service is set.
1044
+ * Executes the query using the GraphQL service, with improved error handling.
785
1045
  */
786
1046
  execute(): Promise<QueryResult>;
1047
+ /**
1048
+ * Generates a string representation of the GraphQL query for debugging.
1049
+ */
1050
+ toString(): string;
1051
+ }
1052
+ export declare class ResourceQueryParam {
1053
+ resourceIds?: Set<string>;
1054
+ regionIds?: Set<string>;
1055
+ startTime: Date;
1056
+ endTime: Date;
1057
+ timezone: string;
1058
+ respectResourceTimezone: boolean;
1059
+ mergeAvailability: boolean;
1060
+ mergeEvents: boolean;
1061
+ useTag: boolean;
1062
+ useJobAllocation: boolean;
1063
+ useResourceShift: boolean;
1064
+ useActivity: boolean;
1065
+ useAvailability: boolean;
1066
+ useAvailabilityTemplate: boolean;
1067
+ useAvailabilityPattern: boolean;
1068
+ useHoliday: boolean;
1069
+ excludedJAStatus: Set<string>;
1070
+ excludedJobStatus: Set<string>;
1071
+ availabilityStatus: Set<string>;
1072
+ resourceTypes: Set<string>;
1073
+ constructor();
1074
+ }
1075
+ declare class DataService {
1076
+ private graphqlService;
1077
+ constructor(graphqlService: GraphQLService);
1078
+ getResources(param: ResourceQueryParam): Promise<Record<string, any>[]>;
1079
+ getHolidays(regionIds: string[], startTime?: Date, endTime?: Date): Promise<Record<string, any>>;
1080
+ newQueryBuilder(objectName: string): GraphQLQueryBuilder;
1081
+ }
1082
+ export declare class ResourceAvailabilityService {
1083
+ private availabilityAPIClient;
1084
+ constructor(availabilityAPIClient: AvailabilityAPIClient);
1085
+ getAvailabilityPatterns(param: ResourceQueryParam): Promise<Map<string, BaseEvent[]>>;
1086
+ }
1087
+ export declare class ResourceBuilder {
1088
+ private dataService;
1089
+ private availabilityService;
1090
+ constructor(dataService: DataService, availabilityService: ResourceAvailabilityService);
1091
+ build(queryParam: ResourceQueryParam): Promise<Resource[]>;
1092
+ private loadAvailabilityPatterns;
1093
+ private loadActivityEvents;
1094
+ private loadAvailabilityEvents;
1095
+ private loadJobAllocationEvents;
1096
+ private loadResourceShiftEvents;
1097
+ private loadHolidayEvents;
1098
+ protected buildMore(resources: Resource[]): Resource[];
787
1099
  }
788
1100
  /**
789
1101
  * ConfigHelper class provides methods to access and parse configuration variables.
@@ -820,6 +1132,22 @@ export declare class ConfigHelper {
820
1132
  */
821
1133
  getString(varName: string): string;
822
1134
  }
1135
+ export declare class DateTimeUtils {
1136
+ static toTimezone(input: Date, toTimezone: string): Date;
1137
+ static switchTimezone(input: Date, fromTimezone: string, toTimezone: string): Date;
1138
+ static addMinutes(input: Date, minutes: number, timezone: string): Date;
1139
+ static addDays(input: Date, days: number, timezone: string): Date;
1140
+ static addMonths(input: Date, months: number, timezone: string): Date;
1141
+ static addYears(input: Date, years: number, timezone: string): Date;
1142
+ static getDate(input: Date, timezone: string): Date;
1143
+ static getDateFromIsoString(isoString: string): Date;
1144
+ static getDateTimeFromIsoString(isoString: string): Date;
1145
+ static getStartOfDate(input: Date | string, timezone: string): Date;
1146
+ static getEndOfDate(input: Date | string, timezone: string): Date;
1147
+ static isIncluding(event: BaseEvent, job: BaseEvent): boolean;
1148
+ static isOverlapping(event: BaseEvent, job: BaseEvent): boolean;
1149
+ static mergeEvents(events: BaseEvent[]): BaseEvent[];
1150
+ }
823
1151
  export declare class ExecutionContext {
824
1152
  skedContext: any;
825
1153
  contextData: any;
@@ -844,12 +1172,76 @@ export declare class ExecutionContext {
844
1172
  get configFeaturesClient(): ConfigFeaturesClient;
845
1173
  get configVarClient(): ConfigVarClient;
846
1174
  get mobileNotificationClient(): MobileNotificationClient;
1175
+ get geoAPIClient(): GeoAPIClient;
1176
+ get availabilityAPIClient(): AvailabilityAPIClient;
1177
+ get geoService(): GeoService;
847
1178
  get configVarCache(): CacheService<any>;
848
1179
  get inMemoryCache(): CacheService<any>;
1180
+ get resourceAvailabilityService(): ResourceAvailabilityService;
1181
+ get dataService(): DataService;
1182
+ get resourceBuilder(): ResourceBuilder;
849
1183
  newQueryBuilder(objectName: string): GraphQLQueryBuilder;
850
1184
  newArtifactClient(artifactType: ArtifactType): ArtifactClient;
851
1185
  dispose(): void;
852
1186
  }
1187
+ export declare const TenantObjects: {
1188
+ Accounts: {
1189
+ Name: string;
1190
+ Fields: string[];
1191
+ };
1192
+ Jobs: {
1193
+ Name: string;
1194
+ Fields: string[];
1195
+ };
1196
+ JobTags: {
1197
+ Name: string;
1198
+ Fields: string[];
1199
+ };
1200
+ JobAllocations: {
1201
+ Name: string;
1202
+ Fields: string[];
1203
+ };
1204
+ Regions: {
1205
+ Name: string;
1206
+ Fields: string[];
1207
+ };
1208
+ Contacts: {
1209
+ Name: string;
1210
+ Fields: string[];
1211
+ };
1212
+ Locations: {
1213
+ Name: string;
1214
+ Fields: string[];
1215
+ };
1216
+ Resources: {
1217
+ Name: string;
1218
+ Fields: string[];
1219
+ };
1220
+ Tags: {
1221
+ Name: string;
1222
+ Fields: string[];
1223
+ };
1224
+ Activities: {
1225
+ Name: string;
1226
+ Fields: string[];
1227
+ };
1228
+ Availabilities: {
1229
+ Name: string;
1230
+ Fields: string[];
1231
+ };
1232
+ Holidays: {
1233
+ Name: string;
1234
+ Fields: string[];
1235
+ };
1236
+ ResourceTags: {
1237
+ Name: string;
1238
+ Fields: string[];
1239
+ };
1240
+ HolidayRegions: {
1241
+ Name: string;
1242
+ Fields: string[];
1243
+ };
1244
+ };
853
1245
  /**
854
1246
  * This decorator logs the input arguments and output results of a method,
855
1247
  * including error handling with ANSI color-coded logs for better console readability.
@@ -905,5 +1297,38 @@ export declare class BatchOrchestrator {
905
1297
  protected updateJobStatus(): Promise<void>;
906
1298
  private isCompleted;
907
1299
  }
1300
+ export interface ResourceValidationOption {
1301
+ checkAvailability: boolean;
1302
+ checkConflict: boolean;
1303
+ checkTag: boolean;
1304
+ }
1305
+ export declare class ResourceJobValidation {
1306
+ resource: Partial<Resource>;
1307
+ job: Partial<Job>;
1308
+ availableEvent: BaseEvent | null;
1309
+ conflictEvents: BaseEvent[];
1310
+ missingTags: Tag[];
1311
+ constructor(resource: Partial<Resource>, job: Partial<Job>, availableEvent?: BaseEvent | null, conflictEvents?: BaseEvent[], missingTags?: Tag[]);
1312
+ isQualified(option: ResourceValidationOption): boolean;
1313
+ }
1314
+ export declare class ValidationResult {
1315
+ private readonly validations;
1316
+ private readonly option;
1317
+ constructor(validations: ResourceJobValidation[], option: ResourceValidationOption);
1318
+ getQualifiedResources(): Partial<Resource>[];
1319
+ getJobsWithXQualifiedResources(minQualifiedResources: number): Partial<Job>[];
1320
+ getUnqualifiedJobsWithReasons(): ResourceJobValidation[];
1321
+ format(): any[];
1322
+ }
1323
+ export declare class ResourceValidator {
1324
+ private readonly option;
1325
+ constructor(option: ResourceValidationOption);
1326
+ validate(resources: Resource[], jobs: Job[]): ValidationResult;
1327
+ private validateResource;
1328
+ private findAvailableEvent;
1329
+ private findConflictingEvents;
1330
+ private findMissingTags;
1331
+ private prepareData;
1332
+ }
908
1333
 
909
1334
  export {};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
@@ -1 +1 @@
1
- "use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,t,r,i){void 0===i&&(i=r);var o=Object.getOwnPropertyDescriptor(t,r);o&&!("get"in o?!t.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return t[r]}}),Object.defineProperty(e,i,o)}:function(e,t,r,i){void 0===i&&(i=r),e[i]=t[r]}),__exportStar=this&&this.__exportStar||function(e,t){for(var r in e)"default"===r||Object.prototype.hasOwnProperty.call(t,r)||__createBinding(t,e,r)};Object.defineProperty(exports,"__esModule",{value:!0}),__exportStar(require("./config-template"),exports),__exportStar(require("./config-var"),exports),__exportStar(require("./graphql"),exports),__exportStar(require("./metadata"),exports),__exportStar(require("./mobile-notification"),exports);
1
+ "use strict";var __createBinding=this&&this.__createBinding||(Object.create?function(e,r,t,i){void 0===i&&(i=t);var o=Object.getOwnPropertyDescriptor(r,t);o&&!("get"in o?!r.__esModule:o.writable||o.configurable)||(o={enumerable:!0,get:function(){return r[t]}}),Object.defineProperty(e,i,o)}:function(e,r,t,i){void 0===i&&(i=t),e[i]=r[t]}),__exportStar=this&&this.__exportStar||function(e,r){for(var t in e)"default"===t||Object.prototype.hasOwnProperty.call(r,t)||__createBinding(r,e,t)};Object.defineProperty(exports,"__esModule",{value:!0}),__exportStar(require("../core/tenant-entities"),exports),__exportStar(require("./availability"),exports),__exportStar(require("./config-template"),exports),__exportStar(require("./config-var"),exports),__exportStar(require("./geoservice-interfaces"),exports),__exportStar(require("./graphql"),exports),__exportStar(require("./metadata"),exports),__exportStar(require("./mobile-notification"),exports);
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});
@@ -0,0 +1 @@
1
+ "use strict";var __awaiter=this&&this.__awaiter||function(e,t,i,r){return new(i||(i=Promise))((function(a,o){function s(e){try{l(r.next(e))}catch(e){o(e)}}function n(e){try{l(r.throw(e))}catch(e){o(e)}}function l(e){var t;e.done?a(e.value):(t=e.value,t instanceof i?t:new i((function(e){e(t)}))).then(s,n)}l((r=r.apply(e,t||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.DataService=void 0;const graphql_1=require("./graphql");class DataService{constructor(e){this.graphqlService=e}getResources(e){return __awaiter(this,void 0,void 0,(function*(){const t=this.newQueryBuilder("Resources");return t.withFields(["UID","Name","Category","ResourceType","EmploymentType","UserId","PrimaryRegionId"]).withFilter("IsActive == true"),t.withParentQuery("PrimaryRegion").withFields(["UID","Name","Timezone"]),e.resourceIds&&e.resourceIds.size>0?t.withFilter(`UID IN ${JSON.stringify(Array.from(e.resourceIds))}`):e.regionIds&&e.regionIds.size>0&&t.withFilter(`PrimaryRegionId IN [${Array.from(e.regionIds).map((e=>`'${e}'`)).join(",")}]`),e.useTag&&t.withChildQuery("ResourceTags").withParentQuery("Tag").withFields(["UID","Name"]),e.useActivity&&t.withChildQuery("Activities").withFields(["UID","Name","Start","End","Type"]),e.useAvailability&&t.withChildQuery("Availabilities").withFields(["UID","Start","Finish","Type","IsAvailable"]),e.useJobAllocation&&t.withChildQuery("JobAllocations").withFields(["UID","Name","Start","End","JobId"]).withFilter("Status NOTIN ['Deleted', 'Declined']").withParentQuery("Job").withFields(["UID","Name","Start","End","Type"]),(yield t.execute()).records}))}getHolidays(e,t,i){return __awaiter(this,void 0,void 0,(function*(){const r={},a=t?t.toISOString().split("T")[0]:null,o=i?i.toISOString().split("T")[0]:null,s=this.newQueryBuilder("Holidays");s.withFields(["UID","Name","StartDate","EndDate","Global"]),s.withFilter("Global == true"),a&&s.withFilter(`EndDate >= ${a}`),o&&s.withFilter(`StartDate <= ${o}`);const n=yield s.execute();if(r.GLOBAL=n.records||[],e&&e.length>0){const t=this.newQueryBuilder("Holidays");t.withFields(["UID","Name","StartDate","EndDate"]),t.withChildQuery("HolidayRegions").withFields(["RegionId"]).withFilter(`RegionId IN [${e.map((e=>`'${e}'`)).join(",")}]`),a&&t.withFilter(`EndDate >= ${a}`),o&&t.withFilter(`StartDate <= ${o}`);const i=yield t.execute();for(const e of i.records||[])for(const t of e.HolidayRegions||[]){const i=t.RegionId;r[i]||(r[i]=[]),r[i].push(e)}}return r}))}newQueryBuilder(e){const t=new graphql_1.GraphQLQueryBuilder(e);return t.setGraphqlService(this.graphqlService),t}}exports.DataService=DataService;
@@ -0,0 +1 @@
1
+ "use strict";var __awaiter=this&&this.__awaiter||function(e,t,i,s){return new(i||(i=Promise))((function(r,n){function o(e){try{l(s.next(e))}catch(e){n(e)}}function a(e){try{l(s.throw(e))}catch(e){n(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(o,a)}l((s=s.apply(e,t||[])).next())}))};Object.defineProperty(exports,"__esModule",{value:!0}),exports.GeoService=void 0;const uuid_1=require("uuid");class GeoService{constructor(e){this.sessionId="",this.geoAPIClient=e,this.sessionId=this.generateNewSessionId()}getDistanceMatrix(e,t){return __awaiter(this,void 0,void 0,(function*(){const i=e.map((e=>({lat:parseFloat(this.stripTrailingZeros(e.lat)),lng:parseFloat(this.stripTrailingZeros(e.lng))}))),s=t.map((e=>({lat:parseFloat(this.stripTrailingZeros(e.lat)),lng:parseFloat(this.stripTrailingZeros(e.lng))}))),r=yield this.geoAPIClient.getDistanceMatrix({origins:i,destinations:s});if(!r||!r.matrix||0===r.matrix.length)throw new Error("Failed to retrieve distance matrix data");const n=new Map;for(let o=0;o<e.length;o++)for(let e=0;e<t.length;e++){const t=this.createKey(i[o],s[e]),a=r.matrix[o][e];n.set(t,a)}return n}))}getAddressSuggestions(e){return __awaiter(this,arguments,void 0,(function*(e,t=1){const i=e.sessionId||this.sessionId;e.sessionId||(e.sessionId=this.sessionId);const s=yield this.geoAPIClient.autocompleteAddress(e);if(0===s.predictions.length)return null;const r=s.predictions.slice(0,t);return Promise.all(r.map((e=>this.geoAPIClient.getPlaceDetails({placeId:e.placeId,sessionId:i}))))}))}getTimezone(e){return __awaiter(this,void 0,void 0,(function*(){return(yield this.geoAPIClient.getTimezone(e)).timeZoneId}))}generateNewSessionId(){return(0,uuid_1.v4)()}stripTrailingZeros(e){return parseFloat(e.toFixed(8)).toString()}createKey(e,t){return`${this.stripTrailingZeros(e.lat)},${this.stripTrailingZeros(e.lng)}-${this.stripTrailingZeros(t.lat)},${this.stripTrailingZeros(t.lng)}`}}exports.GeoService=GeoService;