@ductape/sdk 0.0.4-v55 → 0.0.4-v57
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/brokers/brokers.service.d.ts +24 -0
- package/dist/brokers/brokers.service.js +72 -0
- package/dist/brokers/brokers.service.js.map +1 -1
- package/dist/graph/graphs.service.d.ts +1 -1
- package/dist/graph/graphs.service.js +1 -1
- package/dist/graph/graphs.service.js.map +1 -1
- package/dist/index.d.ts +542 -58
- package/dist/index.js +773 -97
- package/dist/index.js.map +1 -1
- package/dist/products/services/products.service.d.ts +2 -2
- package/dist/resilience/fallback.service.d.ts +60 -11
- package/dist/resilience/fallback.service.js +278 -23
- package/dist/resilience/fallback.service.js.map +1 -1
- package/dist/resilience/healthcheck.service.d.ts +48 -0
- package/dist/resilience/healthcheck.service.js +556 -1
- package/dist/resilience/healthcheck.service.js.map +1 -1
- package/dist/resilience/quota.service.d.ts +42 -53
- package/dist/resilience/quota.service.js +364 -369
- package/dist/resilience/quota.service.js.map +1 -1
- package/dist/resilience/resilience.service.js +38 -3
- package/dist/resilience/resilience.service.js.map +1 -1
- package/dist/resilience/types/index.d.ts +35 -1
- package/dist/resilience/types/index.js +3 -0
- package/dist/resilience/types/index.js.map +1 -1
- package/dist/storage/storage.service.d.ts +25 -0
- package/dist/storage/storage.service.js +39 -0
- package/dist/storage/storage.service.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -422,6 +422,9 @@ class Ductape {
|
|
|
422
422
|
this._cacheService = null;
|
|
423
423
|
this._jobsService = null;
|
|
424
424
|
this._secretsService = null;
|
|
425
|
+
this._quotaService = null;
|
|
426
|
+
this._fallbackService = null;
|
|
427
|
+
this._healthcheckService = null;
|
|
425
428
|
/**
|
|
426
429
|
* Product-related operations for managing products.
|
|
427
430
|
*/
|
|
@@ -603,50 +606,6 @@ class Ductape {
|
|
|
603
606
|
return processorService.generateWebhookLink(data);
|
|
604
607
|
},
|
|
605
608
|
},
|
|
606
|
-
health: {
|
|
607
|
-
/**
|
|
608
|
-
* Creates a health check for an app.
|
|
609
|
-
* @param {string} product - The product tag.
|
|
610
|
-
* @param {Partial<IProductAppHealth>} data - The health check data.
|
|
611
|
-
* @returns {Promise<void>} Resolves when the health check is created. Throws on error.
|
|
612
|
-
*/
|
|
613
|
-
create: async (product, data) => {
|
|
614
|
-
const builder = await this.getProductBuilder(product);
|
|
615
|
-
return builder.createHealthcheck(data);
|
|
616
|
-
},
|
|
617
|
-
/**
|
|
618
|
-
* Updates a health check by tag.
|
|
619
|
-
* @param {string} product - The product tag.
|
|
620
|
-
* @param {string} tag - The health check tag.
|
|
621
|
-
* @param {Partial<IProductAppHealth>} data - The health check data to update.
|
|
622
|
-
* @returns {Promise<void>} Resolves when the health check is updated. Throws on error.
|
|
623
|
-
*/
|
|
624
|
-
update: async (product, tag, data) => {
|
|
625
|
-
const builder = await this.getProductBuilder(product);
|
|
626
|
-
return builder.updateHealthcheck(tag, data);
|
|
627
|
-
},
|
|
628
|
-
/**
|
|
629
|
-
* Fetches a health check by access tag and tag.
|
|
630
|
-
* @param {string} product - The product tag.
|
|
631
|
-
* @param {string} access_tag - The app access tag.
|
|
632
|
-
* @param {string} tag - The health check tag.
|
|
633
|
-
* @returns {Promise<IProductAppHealth|null>} The fetched health check, or null if not found.
|
|
634
|
-
*/
|
|
635
|
-
fetch: async (product, access_tag, tag) => {
|
|
636
|
-
const builder = await this.getProductBuilder(product);
|
|
637
|
-
return builder.fetchHealthcheck(access_tag, tag);
|
|
638
|
-
},
|
|
639
|
-
/**
|
|
640
|
-
* Fetches all health checks for an app by access tag.
|
|
641
|
-
* @param {string} product - The product tag.
|
|
642
|
-
* @param {string} access_tag - The app access tag.
|
|
643
|
-
* @returns {Promise<IProductAppHealth[]>} The list of health checks.
|
|
644
|
-
*/
|
|
645
|
-
list: async (product, access_tag) => {
|
|
646
|
-
const builder = await this.getProductBuilder(product);
|
|
647
|
-
return builder.fetchHealthchecks(access_tag);
|
|
648
|
-
},
|
|
649
|
-
},
|
|
650
609
|
},
|
|
651
610
|
};
|
|
652
611
|
/**
|
|
@@ -760,58 +719,73 @@ class Ductape {
|
|
|
760
719
|
},
|
|
761
720
|
};
|
|
762
721
|
/**
|
|
763
|
-
* Quota-related operations for managing product quotas.
|
|
722
|
+
* Quota-related operations for managing product quotas with weighted distribution.
|
|
764
723
|
*/
|
|
765
724
|
this.quota = {
|
|
725
|
+
/**
|
|
726
|
+
* Defines a quota using code-first API.
|
|
727
|
+
* @param {IQuotaDefineOptions} options - The quota definition options.
|
|
728
|
+
* @param {string} [options.product] - The product tag (if provided, registers immediately).
|
|
729
|
+
* @param {string} options.tag - The quota tag.
|
|
730
|
+
* @param {string} [options.name] - The quota name.
|
|
731
|
+
* @param {string} [options.description] - The quota description.
|
|
732
|
+
* @param {Object} [options.input] - The input schema definition.
|
|
733
|
+
* @param {Function} options.handler - The handler function to configure the quota.
|
|
734
|
+
* @returns {Promise<IDefinedQuota>} The defined quota.
|
|
735
|
+
*/
|
|
736
|
+
define: async (options) => {
|
|
737
|
+
const quotaService = await this.createNewQuotaService();
|
|
738
|
+
return quotaService.define(options);
|
|
739
|
+
},
|
|
766
740
|
/**
|
|
767
741
|
* Creates a quota for a product.
|
|
768
742
|
* @param {string} product - The product tag.
|
|
769
|
-
* @param {
|
|
770
|
-
* @returns {Promise<
|
|
743
|
+
* @param {any} data - The quota data (schema or defined quota).
|
|
744
|
+
* @returns {Promise<any>} The created quota schema.
|
|
771
745
|
*/
|
|
772
746
|
create: async (product, data) => {
|
|
773
|
-
const
|
|
774
|
-
return
|
|
747
|
+
const quotaService = await this.createNewQuotaService();
|
|
748
|
+
return quotaService.create(product, data);
|
|
775
749
|
},
|
|
776
750
|
/**
|
|
777
751
|
* Fetches a quota by tag.
|
|
778
752
|
* @param {string} product - The product tag.
|
|
779
753
|
* @param {string} tag - The quota tag.
|
|
780
|
-
* @returns {
|
|
754
|
+
* @returns {Promise<any>} The fetched quota.
|
|
781
755
|
*/
|
|
782
756
|
fetch: async (product, tag) => {
|
|
783
|
-
const
|
|
784
|
-
return
|
|
757
|
+
const quotaService = await this.createNewQuotaService();
|
|
758
|
+
return quotaService.fetch(product, tag);
|
|
785
759
|
},
|
|
786
760
|
/**
|
|
787
761
|
* Fetches all quotas for a product.
|
|
788
762
|
* @param {string} product - The product tag.
|
|
789
|
-
* @returns {
|
|
763
|
+
* @returns {Promise<any[]>} The list of quotas.
|
|
790
764
|
*/
|
|
791
765
|
list: async (product) => {
|
|
792
|
-
const
|
|
793
|
-
return
|
|
766
|
+
const quotaService = await this.createNewQuotaService();
|
|
767
|
+
return quotaService.fetchAll(product);
|
|
794
768
|
},
|
|
795
769
|
/**
|
|
796
770
|
* Updates a quota by tag.
|
|
797
771
|
* @param {string} product - The product tag.
|
|
798
772
|
* @param {string} tag - The quota tag.
|
|
799
|
-
* @param {
|
|
800
|
-
* @returns {Promise<
|
|
773
|
+
* @param {any} data - The quota data to update.
|
|
774
|
+
* @returns {Promise<any>} The updated quota schema.
|
|
801
775
|
*/
|
|
802
776
|
update: async (product, tag, data) => {
|
|
803
|
-
const
|
|
804
|
-
return
|
|
777
|
+
const quotaService = await this.createNewQuotaService();
|
|
778
|
+
return quotaService.update(product, tag, data);
|
|
805
779
|
},
|
|
806
780
|
/**
|
|
807
781
|
* Deletes a quota by tag.
|
|
808
782
|
* @param {string} product - The product tag.
|
|
809
783
|
* @param {string} tag - The quota tag.
|
|
810
|
-
* @returns {Promise<void>} Resolves when the quota is deleted.
|
|
784
|
+
* @returns {Promise<void>} Resolves when the quota is deleted.
|
|
811
785
|
*/
|
|
812
786
|
delete: async (product, tag) => {
|
|
813
|
-
const
|
|
814
|
-
return
|
|
787
|
+
const quotaService = await this.createNewQuotaService();
|
|
788
|
+
return quotaService.delete(product, tag);
|
|
815
789
|
},
|
|
816
790
|
/**
|
|
817
791
|
* Runs a quota with weighted distribution.
|
|
@@ -826,60 +800,89 @@ class Ductape {
|
|
|
826
800
|
const quotaService = await this.createNewQuotaService();
|
|
827
801
|
return quotaService.run(data);
|
|
828
802
|
},
|
|
803
|
+
/**
|
|
804
|
+
* Dispatches a quota for deferred execution.
|
|
805
|
+
* @param {Object} data - The quota dispatch input.
|
|
806
|
+
* @param {string} data.product - The product tag.
|
|
807
|
+
* @param {string} data.env - The environment slug.
|
|
808
|
+
* @param {string} data.tag - The quota tag.
|
|
809
|
+
* @param {Record<string, unknown>} data.input - The input data for the quota.
|
|
810
|
+
* @param {IDispatchSchedule} [data.schedule] - Optional schedule for deferred execution.
|
|
811
|
+
* @returns {Promise<{ jobId: string }>} The dispatch result with job ID.
|
|
812
|
+
*/
|
|
813
|
+
dispatch: async (data) => {
|
|
814
|
+
const quotaService = await this.createNewQuotaService();
|
|
815
|
+
return quotaService.dispatch(data);
|
|
816
|
+
},
|
|
829
817
|
};
|
|
830
818
|
/**
|
|
831
|
-
* Fallback-related operations for managing product fallbacks.
|
|
819
|
+
* Fallback-related operations for managing product fallbacks with sequential failover.
|
|
832
820
|
*/
|
|
833
821
|
this.fallback = {
|
|
822
|
+
/**
|
|
823
|
+
* Defines a fallback using code-first API.
|
|
824
|
+
* @param {IFallbackDefineOptions} options - The fallback definition options.
|
|
825
|
+
* @param {string} [options.product] - The product tag (if provided, registers immediately).
|
|
826
|
+
* @param {string} options.tag - The fallback tag.
|
|
827
|
+
* @param {string} [options.name] - The fallback name.
|
|
828
|
+
* @param {string} [options.description] - The fallback description.
|
|
829
|
+
* @param {Object} [options.input] - The input schema definition.
|
|
830
|
+
* @param {Function} options.handler - The handler function to configure the fallback.
|
|
831
|
+
* @returns {Promise<IDefinedFallback>} The defined fallback.
|
|
832
|
+
*/
|
|
833
|
+
define: async (options) => {
|
|
834
|
+
const fallbackService = await this.createNewFallbackService();
|
|
835
|
+
return fallbackService.define(options);
|
|
836
|
+
},
|
|
834
837
|
/**
|
|
835
838
|
* Creates a fallback for a product.
|
|
836
839
|
* @param {string} product - The product tag.
|
|
837
|
-
* @param {
|
|
838
|
-
* @returns {Promise<
|
|
840
|
+
* @param {any} data - The fallback data (schema or defined fallback).
|
|
841
|
+
* @returns {Promise<any>} The created fallback schema.
|
|
839
842
|
*/
|
|
840
843
|
create: async (product, data) => {
|
|
841
|
-
const
|
|
842
|
-
return
|
|
844
|
+
const fallbackService = await this.createNewFallbackService();
|
|
845
|
+
return fallbackService.create(product, data);
|
|
843
846
|
},
|
|
844
847
|
/**
|
|
845
848
|
* Fetches a fallback by tag.
|
|
846
849
|
* @param {string} product - The product tag.
|
|
847
850
|
* @param {string} tag - The fallback tag.
|
|
848
|
-
* @returns {
|
|
851
|
+
* @returns {Promise<any>} The fetched fallback.
|
|
849
852
|
*/
|
|
850
853
|
fetch: async (product, tag) => {
|
|
851
|
-
const
|
|
852
|
-
return
|
|
854
|
+
const fallbackService = await this.createNewFallbackService();
|
|
855
|
+
return fallbackService.fetch(product, tag);
|
|
853
856
|
},
|
|
854
857
|
/**
|
|
855
858
|
* Fetches all fallbacks for a product.
|
|
856
859
|
* @param {string} product - The product tag.
|
|
857
|
-
* @returns {
|
|
860
|
+
* @returns {Promise<any[]>} The list of fallbacks.
|
|
858
861
|
*/
|
|
859
862
|
list: async (product) => {
|
|
860
|
-
const
|
|
861
|
-
return
|
|
863
|
+
const fallbackService = await this.createNewFallbackService();
|
|
864
|
+
return fallbackService.fetchAll(product);
|
|
862
865
|
},
|
|
863
866
|
/**
|
|
864
867
|
* Updates a fallback by tag.
|
|
865
868
|
* @param {string} product - The product tag.
|
|
866
869
|
* @param {string} tag - The fallback tag.
|
|
867
|
-
* @param {
|
|
868
|
-
* @returns {Promise<
|
|
870
|
+
* @param {any} data - The fallback data to update.
|
|
871
|
+
* @returns {Promise<any>} The updated fallback schema.
|
|
869
872
|
*/
|
|
870
873
|
update: async (product, tag, data) => {
|
|
871
|
-
const
|
|
872
|
-
return
|
|
874
|
+
const fallbackService = await this.createNewFallbackService();
|
|
875
|
+
return fallbackService.update(product, tag, data);
|
|
873
876
|
},
|
|
874
877
|
/**
|
|
875
878
|
* Deletes a fallback by tag.
|
|
876
879
|
* @param {string} product - The product tag.
|
|
877
880
|
* @param {string} tag - The fallback tag.
|
|
878
|
-
* @returns {Promise<void>} Resolves when the fallback is deleted.
|
|
881
|
+
* @returns {Promise<void>} Resolves when the fallback is deleted.
|
|
879
882
|
*/
|
|
880
883
|
delete: async (product, tag) => {
|
|
881
|
-
const
|
|
882
|
-
return
|
|
884
|
+
const fallbackService = await this.createNewFallbackService();
|
|
885
|
+
return fallbackService.delete(product, tag);
|
|
883
886
|
},
|
|
884
887
|
/**
|
|
885
888
|
* Runs a fallback with sequential failover.
|
|
@@ -894,6 +897,125 @@ class Ductape {
|
|
|
894
897
|
const fallbackService = await this.createNewFallbackService();
|
|
895
898
|
return fallbackService.run(data);
|
|
896
899
|
},
|
|
900
|
+
/**
|
|
901
|
+
* Dispatches a fallback for deferred execution.
|
|
902
|
+
* @param {Object} data - The fallback dispatch input.
|
|
903
|
+
* @param {string} data.product - The product tag.
|
|
904
|
+
* @param {string} data.env - The environment slug.
|
|
905
|
+
* @param {string} data.tag - The fallback tag.
|
|
906
|
+
* @param {Record<string, unknown>} data.input - The input data for the fallback.
|
|
907
|
+
* @param {IDispatchSchedule} [data.schedule] - Optional schedule for deferred execution.
|
|
908
|
+
* @returns {Promise<{ jobId: string }>} The dispatch result with job ID.
|
|
909
|
+
*/
|
|
910
|
+
dispatch: async (data) => {
|
|
911
|
+
const fallbackService = await this.createNewFallbackService();
|
|
912
|
+
return fallbackService.dispatch(data);
|
|
913
|
+
},
|
|
914
|
+
};
|
|
915
|
+
/**
|
|
916
|
+
* Healthcheck-related operations for managing product healthchecks.
|
|
917
|
+
*/
|
|
918
|
+
this.health = {
|
|
919
|
+
/**
|
|
920
|
+
* Defines a healthcheck using code-first API.
|
|
921
|
+
* @param {IHealthcheckDefineOptions} options - The healthcheck definition options.
|
|
922
|
+
* @param {string} [options.product] - The product tag (if provided, registers immediately).
|
|
923
|
+
* @param {string} options.tag - The healthcheck tag.
|
|
924
|
+
* @param {string} [options.name] - The healthcheck name.
|
|
925
|
+
* @param {string} [options.description] - The healthcheck description.
|
|
926
|
+
* @param {Function} options.handler - The handler function to configure the healthcheck.
|
|
927
|
+
* @returns {Promise<IDefinedHealthcheck>} The defined healthcheck.
|
|
928
|
+
*/
|
|
929
|
+
define: async (options) => {
|
|
930
|
+
const healthcheckService = await this.createNewHealthcheckService();
|
|
931
|
+
return healthcheckService.define(options);
|
|
932
|
+
},
|
|
933
|
+
/**
|
|
934
|
+
* Creates a healthcheck for a product.
|
|
935
|
+
* @param {string} product - The product tag.
|
|
936
|
+
* @param {Object} data - The healthcheck data (schema or defined healthcheck).
|
|
937
|
+
* @returns {Promise<IHealthcheckSchema>} The created healthcheck schema.
|
|
938
|
+
*/
|
|
939
|
+
create: async (product, data) => {
|
|
940
|
+
const healthcheckService = await this.createNewHealthcheckService();
|
|
941
|
+
return healthcheckService.create(product, data);
|
|
942
|
+
},
|
|
943
|
+
/**
|
|
944
|
+
* Fetches a healthcheck by tag.
|
|
945
|
+
* @param {string} product - The product tag.
|
|
946
|
+
* @param {string} tag - The healthcheck tag.
|
|
947
|
+
* @returns {Promise<IHealthcheckSchema>} The fetched healthcheck.
|
|
948
|
+
*/
|
|
949
|
+
fetch: async (product, tag) => {
|
|
950
|
+
const healthcheckService = await this.createNewHealthcheckService();
|
|
951
|
+
return healthcheckService.fetch(product, tag);
|
|
952
|
+
},
|
|
953
|
+
/**
|
|
954
|
+
* Fetches all healthchecks for a product.
|
|
955
|
+
* @param {string} product - The product tag.
|
|
956
|
+
* @returns {Promise<IHealthcheckSchema[]>} The list of healthchecks.
|
|
957
|
+
*/
|
|
958
|
+
list: async (product) => {
|
|
959
|
+
const healthcheckService = await this.createNewHealthcheckService();
|
|
960
|
+
return healthcheckService.fetchAll(product);
|
|
961
|
+
},
|
|
962
|
+
/**
|
|
963
|
+
* Updates a healthcheck by tag.
|
|
964
|
+
* @param {string} product - The product tag.
|
|
965
|
+
* @param {string} tag - The healthcheck tag.
|
|
966
|
+
* @param {Object} data - The healthcheck data to update.
|
|
967
|
+
* @returns {Promise<IHealthcheckSchema>} The updated healthcheck schema.
|
|
968
|
+
*/
|
|
969
|
+
update: async (product, tag, data) => {
|
|
970
|
+
const healthcheckService = await this.createNewHealthcheckService();
|
|
971
|
+
return healthcheckService.update(product, tag, data);
|
|
972
|
+
},
|
|
973
|
+
/**
|
|
974
|
+
* Deletes a healthcheck by tag.
|
|
975
|
+
* @param {string} product - The product tag.
|
|
976
|
+
* @param {string} tag - The healthcheck tag.
|
|
977
|
+
* @returns {Promise<void>} Resolves when the healthcheck is deleted.
|
|
978
|
+
*/
|
|
979
|
+
delete: async (product, tag) => {
|
|
980
|
+
const healthcheckService = await this.createNewHealthcheckService();
|
|
981
|
+
return healthcheckService.delete(product, tag);
|
|
982
|
+
},
|
|
983
|
+
/**
|
|
984
|
+
* Gets the current status of a healthcheck.
|
|
985
|
+
* @param {Object} options - The status check options.
|
|
986
|
+
* @param {string} options.product - The product tag.
|
|
987
|
+
* @param {string} options.env - The environment slug.
|
|
988
|
+
* @param {string} options.tag - The healthcheck tag.
|
|
989
|
+
* @returns {Promise<IHealthcheckStatus>} The healthcheck status.
|
|
990
|
+
*/
|
|
991
|
+
status: async (options) => {
|
|
992
|
+
const healthcheckService = await this.createNewHealthcheckService();
|
|
993
|
+
return healthcheckService.getStatus(options);
|
|
994
|
+
},
|
|
995
|
+
/**
|
|
996
|
+
* Manually triggers a healthcheck run.
|
|
997
|
+
* @param {Object} options - The run options.
|
|
998
|
+
* @param {string} options.product - The product tag.
|
|
999
|
+
* @param {string} options.env - The environment slug.
|
|
1000
|
+
* @param {string} options.tag - The healthcheck tag.
|
|
1001
|
+
* @returns {Promise<IHealthcheckRunResult>} The result of the healthcheck run.
|
|
1002
|
+
*/
|
|
1003
|
+
run: async (options) => {
|
|
1004
|
+
const healthcheckService = await this.createNewHealthcheckService();
|
|
1005
|
+
return healthcheckService.run(options);
|
|
1006
|
+
},
|
|
1007
|
+
/**
|
|
1008
|
+
* Checks the health of a service (alias for status).
|
|
1009
|
+
* @param {Object} options - The check options.
|
|
1010
|
+
* @param {string} options.product - The product tag.
|
|
1011
|
+
* @param {string} options.env - The environment slug.
|
|
1012
|
+
* @param {string} options.tag - The healthcheck tag.
|
|
1013
|
+
* @returns {Promise<IHealthcheckStatus>} The healthcheck status.
|
|
1014
|
+
*/
|
|
1015
|
+
check: async (options) => {
|
|
1016
|
+
const healthcheckService = await this.createNewHealthcheckService();
|
|
1017
|
+
return healthcheckService.check(options);
|
|
1018
|
+
},
|
|
897
1019
|
};
|
|
898
1020
|
/**
|
|
899
1021
|
* Storage-related operations for managing product storages.
|
|
@@ -1980,11 +2102,535 @@ class Ductape {
|
|
|
1980
2102
|
*/
|
|
1981
2103
|
this.graph = {
|
|
1982
2104
|
/**
|
|
1983
|
-
* Get the underlying GraphService instance
|
|
2105
|
+
* Get the underlying GraphService instance for advanced operations.
|
|
2106
|
+
* @returns {Promise<GraphService>} The graph service instance.
|
|
1984
2107
|
*/
|
|
1985
2108
|
getService: async () => {
|
|
1986
2109
|
return this.createNewGraphService();
|
|
1987
2110
|
},
|
|
2111
|
+
// ==================== CRUD OPERATIONS ====================
|
|
2112
|
+
/**
|
|
2113
|
+
* Creates a graph configuration for a product.
|
|
2114
|
+
* @param {any} graphConfig - The graph configuration.
|
|
2115
|
+
* @param {string} [productTag] - The product tag.
|
|
2116
|
+
* @returns {Promise<void>} Resolves when the graph is created.
|
|
2117
|
+
*/
|
|
2118
|
+
create: async (graphConfig, productTag) => {
|
|
2119
|
+
const graphService = await this.createNewGraphService();
|
|
2120
|
+
return graphService.create(graphConfig, productTag);
|
|
2121
|
+
},
|
|
2122
|
+
/**
|
|
2123
|
+
* Fetches a graph configuration by tag.
|
|
2124
|
+
* @param {string} graphTag - The graph tag.
|
|
2125
|
+
* @param {string} [productTag] - The product tag.
|
|
2126
|
+
* @returns {Promise<any>} The fetched graph configuration.
|
|
2127
|
+
*/
|
|
2128
|
+
fetch: async (graphTag, productTag) => {
|
|
2129
|
+
const graphService = await this.createNewGraphService();
|
|
2130
|
+
return graphService.fetch(graphTag, productTag);
|
|
2131
|
+
},
|
|
2132
|
+
/**
|
|
2133
|
+
* Fetches all graph configurations for a product.
|
|
2134
|
+
* @param {string} [productTag] - The product tag.
|
|
2135
|
+
* @returns {Promise<any[]>} The list of graph configurations.
|
|
2136
|
+
*/
|
|
2137
|
+
list: async (productTag) => {
|
|
2138
|
+
const graphService = await this.createNewGraphService();
|
|
2139
|
+
return graphService.fetchAll(productTag);
|
|
2140
|
+
},
|
|
2141
|
+
/**
|
|
2142
|
+
* Updates a graph configuration by tag.
|
|
2143
|
+
* @param {string} graphTag - The graph tag.
|
|
2144
|
+
* @param {any} updates - The updates to apply.
|
|
2145
|
+
* @param {string} [productTag] - The product tag.
|
|
2146
|
+
* @returns {Promise<void>} Resolves when the graph is updated.
|
|
2147
|
+
*/
|
|
2148
|
+
update: async (graphTag, updates, productTag) => {
|
|
2149
|
+
const graphService = await this.createNewGraphService();
|
|
2150
|
+
return graphService.update(graphTag, updates, productTag);
|
|
2151
|
+
},
|
|
2152
|
+
/**
|
|
2153
|
+
* Deletes a graph configuration by tag.
|
|
2154
|
+
* @param {string} graphTag - The graph tag.
|
|
2155
|
+
* @param {string} [productTag] - The product tag.
|
|
2156
|
+
* @returns {Promise<void>} Resolves when the graph is deleted.
|
|
2157
|
+
*/
|
|
2158
|
+
delete: async (graphTag, productTag) => {
|
|
2159
|
+
const graphService = await this.createNewGraphService();
|
|
2160
|
+
return graphService.delete(graphTag, productTag);
|
|
2161
|
+
},
|
|
2162
|
+
// ==================== CONNECTION MANAGEMENT ====================
|
|
2163
|
+
/**
|
|
2164
|
+
* Connects to a graph database.
|
|
2165
|
+
* @param {any} config - The connection configuration.
|
|
2166
|
+
* @returns {Promise<any>} The connection result.
|
|
2167
|
+
*/
|
|
2168
|
+
connect: async (config) => {
|
|
2169
|
+
const graphService = await this.createNewGraphService();
|
|
2170
|
+
return graphService.connect(config);
|
|
2171
|
+
},
|
|
2172
|
+
/**
|
|
2173
|
+
* Disconnects from the current graph database.
|
|
2174
|
+
* @returns {Promise<void>} Resolves when disconnected.
|
|
2175
|
+
*/
|
|
2176
|
+
disconnect: async () => {
|
|
2177
|
+
const graphService = await this.createNewGraphService();
|
|
2178
|
+
return graphService.disconnect();
|
|
2179
|
+
},
|
|
2180
|
+
/**
|
|
2181
|
+
* Closes all graph database connections.
|
|
2182
|
+
* @returns {Promise<void>} Resolves when all connections are closed.
|
|
2183
|
+
*/
|
|
2184
|
+
closeAll: async () => {
|
|
2185
|
+
const graphService = await this.createNewGraphService();
|
|
2186
|
+
return graphService.closeAll();
|
|
2187
|
+
},
|
|
2188
|
+
/**
|
|
2189
|
+
* Tests a connection to a graph database without persisting.
|
|
2190
|
+
* @param {any} config - The connection configuration.
|
|
2191
|
+
* @returns {Promise<any>} The test connection result.
|
|
2192
|
+
*/
|
|
2193
|
+
testConnection: async (config) => {
|
|
2194
|
+
const graphService = await this.createNewGraphService();
|
|
2195
|
+
return graphService.testConnection(config);
|
|
2196
|
+
},
|
|
2197
|
+
// ==================== NODE OPERATIONS ====================
|
|
2198
|
+
/**
|
|
2199
|
+
* Creates a node in the graph.
|
|
2200
|
+
* @param {any} options - The node creation options.
|
|
2201
|
+
* @param {any} [transaction] - Optional transaction.
|
|
2202
|
+
* @returns {Promise<any>} The created node result.
|
|
2203
|
+
*/
|
|
2204
|
+
createNode: async (options, transaction) => {
|
|
2205
|
+
const graphService = await this.createNewGraphService();
|
|
2206
|
+
return graphService.createNode(options, transaction);
|
|
2207
|
+
},
|
|
2208
|
+
/**
|
|
2209
|
+
* Finds nodes by criteria.
|
|
2210
|
+
* @param {any} options - The find options.
|
|
2211
|
+
* @param {any} [transaction] - Optional transaction.
|
|
2212
|
+
* @returns {Promise<any>} The found nodes result.
|
|
2213
|
+
*/
|
|
2214
|
+
findNodes: async (options, transaction) => {
|
|
2215
|
+
const graphService = await this.createNewGraphService();
|
|
2216
|
+
return graphService.findNodes(options, transaction);
|
|
2217
|
+
},
|
|
2218
|
+
/**
|
|
2219
|
+
* Finds a node by ID.
|
|
2220
|
+
* @param {string | number} id - The node ID.
|
|
2221
|
+
* @param {any} [transaction] - Optional transaction.
|
|
2222
|
+
* @returns {Promise<any>} The found node or null.
|
|
2223
|
+
*/
|
|
2224
|
+
findNodeById: async (id, transaction) => {
|
|
2225
|
+
const graphService = await this.createNewGraphService();
|
|
2226
|
+
return graphService.findNodeById(id, transaction);
|
|
2227
|
+
},
|
|
2228
|
+
/**
|
|
2229
|
+
* Updates a node.
|
|
2230
|
+
* @param {any} options - The update options.
|
|
2231
|
+
* @param {any} [transaction] - Optional transaction.
|
|
2232
|
+
* @returns {Promise<any>} The updated node result.
|
|
2233
|
+
*/
|
|
2234
|
+
updateNode: async (options, transaction) => {
|
|
2235
|
+
const graphService = await this.createNewGraphService();
|
|
2236
|
+
return graphService.updateNode(options, transaction);
|
|
2237
|
+
},
|
|
2238
|
+
/**
|
|
2239
|
+
* Deletes a node.
|
|
2240
|
+
* @param {any} options - The delete options.
|
|
2241
|
+
* @param {any} [transaction] - Optional transaction.
|
|
2242
|
+
* @returns {Promise<any>} The delete result.
|
|
2243
|
+
*/
|
|
2244
|
+
deleteNode: async (options, transaction) => {
|
|
2245
|
+
const graphService = await this.createNewGraphService();
|
|
2246
|
+
return graphService.deleteNode(options, transaction);
|
|
2247
|
+
},
|
|
2248
|
+
/**
|
|
2249
|
+
* Merges a node (create or update).
|
|
2250
|
+
* @param {any} options - The merge options.
|
|
2251
|
+
* @param {any} [transaction] - Optional transaction.
|
|
2252
|
+
* @returns {Promise<any>} The merge result.
|
|
2253
|
+
*/
|
|
2254
|
+
mergeNode: async (options, transaction) => {
|
|
2255
|
+
const graphService = await this.createNewGraphService();
|
|
2256
|
+
return graphService.mergeNode(options, transaction);
|
|
2257
|
+
},
|
|
2258
|
+
/**
|
|
2259
|
+
* Adds labels to an existing node.
|
|
2260
|
+
* @param {any} options - The add labels options (id, labels).
|
|
2261
|
+
* @param {any} [transaction] - Optional transaction.
|
|
2262
|
+
* @returns {Promise<any>} The result with added labels.
|
|
2263
|
+
*/
|
|
2264
|
+
addLabels: async (options, transaction) => {
|
|
2265
|
+
const graphService = await this.createNewGraphService();
|
|
2266
|
+
return graphService.addLabels(options, transaction);
|
|
2267
|
+
},
|
|
2268
|
+
/**
|
|
2269
|
+
* Removes labels from an existing node.
|
|
2270
|
+
* @param {any} options - The remove labels options (id, labels).
|
|
2271
|
+
* @param {any} [transaction] - Optional transaction.
|
|
2272
|
+
* @returns {Promise<any>} The result with removed labels.
|
|
2273
|
+
*/
|
|
2274
|
+
removeLabels: async (options, transaction) => {
|
|
2275
|
+
const graphService = await this.createNewGraphService();
|
|
2276
|
+
return graphService.removeLabels(options, transaction);
|
|
2277
|
+
},
|
|
2278
|
+
/**
|
|
2279
|
+
* Sets labels on a node (replaces all existing labels).
|
|
2280
|
+
* @param {any} options - The set labels options (id, labels).
|
|
2281
|
+
* @param {any} [transaction] - Optional transaction.
|
|
2282
|
+
* @returns {Promise<any>} The result with previous and new labels.
|
|
2283
|
+
*/
|
|
2284
|
+
setLabels: async (options, transaction) => {
|
|
2285
|
+
const graphService = await this.createNewGraphService();
|
|
2286
|
+
return graphService.setLabels(options, transaction);
|
|
2287
|
+
},
|
|
2288
|
+
// ==================== RELATIONSHIP OPERATIONS ====================
|
|
2289
|
+
/**
|
|
2290
|
+
* Creates a relationship between nodes.
|
|
2291
|
+
* @param {any} options - The relationship creation options.
|
|
2292
|
+
* @param {any} [transaction] - Optional transaction.
|
|
2293
|
+
* @returns {Promise<any>} The created relationship result.
|
|
2294
|
+
*/
|
|
2295
|
+
createRelationship: async (options, transaction) => {
|
|
2296
|
+
const graphService = await this.createNewGraphService();
|
|
2297
|
+
return graphService.createRelationship(options, transaction);
|
|
2298
|
+
},
|
|
2299
|
+
/**
|
|
2300
|
+
* Finds relationships by criteria.
|
|
2301
|
+
* @param {any} options - The find options.
|
|
2302
|
+
* @param {any} [transaction] - Optional transaction.
|
|
2303
|
+
* @returns {Promise<any>} The found relationships result.
|
|
2304
|
+
*/
|
|
2305
|
+
findRelationships: async (options, transaction) => {
|
|
2306
|
+
const graphService = await this.createNewGraphService();
|
|
2307
|
+
return graphService.findRelationships(options, transaction);
|
|
2308
|
+
},
|
|
2309
|
+
/**
|
|
2310
|
+
* Finds a relationship by ID.
|
|
2311
|
+
* @param {string | number} id - The relationship ID.
|
|
2312
|
+
* @param {any} [transaction] - Optional transaction.
|
|
2313
|
+
* @returns {Promise<any>} The found relationship or null.
|
|
2314
|
+
*/
|
|
2315
|
+
findRelationshipById: async (id, transaction) => {
|
|
2316
|
+
const graphService = await this.createNewGraphService();
|
|
2317
|
+
return graphService.findRelationshipById(id, transaction);
|
|
2318
|
+
},
|
|
2319
|
+
/**
|
|
2320
|
+
* Updates a relationship.
|
|
2321
|
+
* @param {any} options - The update options.
|
|
2322
|
+
* @param {any} [transaction] - Optional transaction.
|
|
2323
|
+
* @returns {Promise<any>} The updated relationship result.
|
|
2324
|
+
*/
|
|
2325
|
+
updateRelationship: async (options, transaction) => {
|
|
2326
|
+
const graphService = await this.createNewGraphService();
|
|
2327
|
+
return graphService.updateRelationship(options, transaction);
|
|
2328
|
+
},
|
|
2329
|
+
/**
|
|
2330
|
+
* Deletes a relationship.
|
|
2331
|
+
* @param {any} options - The delete options.
|
|
2332
|
+
* @param {any} [transaction] - Optional transaction.
|
|
2333
|
+
* @returns {Promise<any>} The delete result.
|
|
2334
|
+
*/
|
|
2335
|
+
deleteRelationship: async (options, transaction) => {
|
|
2336
|
+
const graphService = await this.createNewGraphService();
|
|
2337
|
+
return graphService.deleteRelationship(options, transaction);
|
|
2338
|
+
},
|
|
2339
|
+
/**
|
|
2340
|
+
* Merges a relationship (create or update).
|
|
2341
|
+
* @param {any} options - The merge options.
|
|
2342
|
+
* @param {any} [transaction] - Optional transaction.
|
|
2343
|
+
* @returns {Promise<any>} The merge result.
|
|
2344
|
+
*/
|
|
2345
|
+
mergeRelationship: async (options, transaction) => {
|
|
2346
|
+
const graphService = await this.createNewGraphService();
|
|
2347
|
+
return graphService.mergeRelationship(options, transaction);
|
|
2348
|
+
},
|
|
2349
|
+
// ==================== TRAVERSAL OPERATIONS ====================
|
|
2350
|
+
/**
|
|
2351
|
+
* Traverses the graph from a starting node.
|
|
2352
|
+
* @param {any} options - The traversal options.
|
|
2353
|
+
* @param {any} [transaction] - Optional transaction.
|
|
2354
|
+
* @returns {Promise<any>} The traversal result.
|
|
2355
|
+
*/
|
|
2356
|
+
traverse: async (options, transaction) => {
|
|
2357
|
+
const graphService = await this.createNewGraphService();
|
|
2358
|
+
return graphService.traverse(options, transaction);
|
|
2359
|
+
},
|
|
2360
|
+
/**
|
|
2361
|
+
* Finds the shortest path between two nodes.
|
|
2362
|
+
* @param {any} options - The shortest path options.
|
|
2363
|
+
* @param {any} [transaction] - Optional transaction.
|
|
2364
|
+
* @returns {Promise<any>} The shortest path result.
|
|
2365
|
+
*/
|
|
2366
|
+
shortestPath: async (options, transaction) => {
|
|
2367
|
+
const graphService = await this.createNewGraphService();
|
|
2368
|
+
return graphService.shortestPath(options, transaction);
|
|
2369
|
+
},
|
|
2370
|
+
/**
|
|
2371
|
+
* Finds all paths between two nodes.
|
|
2372
|
+
* @param {any} options - The all paths options.
|
|
2373
|
+
* @param {any} [transaction] - Optional transaction.
|
|
2374
|
+
* @returns {Promise<any>} The all paths result.
|
|
2375
|
+
*/
|
|
2376
|
+
allPaths: async (options, transaction) => {
|
|
2377
|
+
const graphService = await this.createNewGraphService();
|
|
2378
|
+
return graphService.allPaths(options, transaction);
|
|
2379
|
+
},
|
|
2380
|
+
/**
|
|
2381
|
+
* Gets the neighborhood of a node.
|
|
2382
|
+
* @param {any} options - The neighborhood options.
|
|
2383
|
+
* @param {any} [transaction] - Optional transaction.
|
|
2384
|
+
* @returns {Promise<any>} The neighborhood result.
|
|
2385
|
+
*/
|
|
2386
|
+
getNeighborhood: async (options, transaction) => {
|
|
2387
|
+
const graphService = await this.createNewGraphService();
|
|
2388
|
+
return graphService.getNeighborhood(options, transaction);
|
|
2389
|
+
},
|
|
2390
|
+
/**
|
|
2391
|
+
* Finds connected components in the graph.
|
|
2392
|
+
* @param {any} options - The connected components options.
|
|
2393
|
+
* @param {any} [transaction] - Optional transaction.
|
|
2394
|
+
* @returns {Promise<any>} The connected components result.
|
|
2395
|
+
*/
|
|
2396
|
+
findConnectedComponents: async (options, transaction) => {
|
|
2397
|
+
const graphService = await this.createNewGraphService();
|
|
2398
|
+
return graphService.findConnectedComponents(options, transaction);
|
|
2399
|
+
},
|
|
2400
|
+
// ==================== QUERY OPERATIONS ====================
|
|
2401
|
+
/**
|
|
2402
|
+
* Executes a raw Cypher query against the graph database.
|
|
2403
|
+
* @param {string} query - The Cypher query string.
|
|
2404
|
+
* @param {Record<string, any>} [params] - Query parameters.
|
|
2405
|
+
* @param {any} [transaction] - Optional transaction.
|
|
2406
|
+
* @returns {Promise<any>} The query result.
|
|
2407
|
+
*/
|
|
2408
|
+
query: async (query, params, transaction) => {
|
|
2409
|
+
const graphService = await this.createNewGraphService();
|
|
2410
|
+
return graphService.query(query, params, transaction);
|
|
2411
|
+
},
|
|
2412
|
+
/**
|
|
2413
|
+
* Gets graph statistics.
|
|
2414
|
+
* @param {any} [transaction] - Optional transaction.
|
|
2415
|
+
* @returns {Promise<any>} The graph statistics.
|
|
2416
|
+
*/
|
|
2417
|
+
getStatistics: async (transaction) => {
|
|
2418
|
+
const graphService = await this.createNewGraphService();
|
|
2419
|
+
return graphService.getStatistics(transaction);
|
|
2420
|
+
},
|
|
2421
|
+
/**
|
|
2422
|
+
* Counts nodes matching criteria.
|
|
2423
|
+
* @param {string[]} [labels] - Node labels to filter by.
|
|
2424
|
+
* @param {any} [where] - Where clause for filtering.
|
|
2425
|
+
* @param {any} [transaction] - Optional transaction.
|
|
2426
|
+
* @returns {Promise<any>} The count result.
|
|
2427
|
+
*/
|
|
2428
|
+
countNodes: async (labels, where, transaction) => {
|
|
2429
|
+
const graphService = await this.createNewGraphService();
|
|
2430
|
+
return graphService.countNodes(labels, where, transaction);
|
|
2431
|
+
},
|
|
2432
|
+
/**
|
|
2433
|
+
* Counts relationships matching criteria.
|
|
2434
|
+
* @param {string[]} [types] - Relationship types to filter by.
|
|
2435
|
+
* @param {any} [where] - Where clause for filtering.
|
|
2436
|
+
* @param {any} [transaction] - Optional transaction.
|
|
2437
|
+
* @returns {Promise<any>} The count result.
|
|
2438
|
+
*/
|
|
2439
|
+
countRelationships: async (types, where, transaction) => {
|
|
2440
|
+
const graphService = await this.createNewGraphService();
|
|
2441
|
+
return graphService.countRelationships(types, where, transaction);
|
|
2442
|
+
},
|
|
2443
|
+
/**
|
|
2444
|
+
* Performs full-text search.
|
|
2445
|
+
* @param {any} options - The search options.
|
|
2446
|
+
* @param {any} [transaction] - Optional transaction.
|
|
2447
|
+
* @returns {Promise<any>} The search result.
|
|
2448
|
+
*/
|
|
2449
|
+
fullTextSearch: async (options, transaction) => {
|
|
2450
|
+
const graphService = await this.createNewGraphService();
|
|
2451
|
+
return graphService.fullTextSearch(options, transaction);
|
|
2452
|
+
},
|
|
2453
|
+
/**
|
|
2454
|
+
* Performs vector similarity search.
|
|
2455
|
+
* @param {any} options - The search options.
|
|
2456
|
+
* @param {any} [transaction] - Optional transaction.
|
|
2457
|
+
* @returns {Promise<any>} The search result.
|
|
2458
|
+
*/
|
|
2459
|
+
vectorSearch: async (options, transaction) => {
|
|
2460
|
+
const graphService = await this.createNewGraphService();
|
|
2461
|
+
return graphService.vectorSearch(options, transaction);
|
|
2462
|
+
},
|
|
2463
|
+
// ==================== SCHEMA OPERATIONS ====================
|
|
2464
|
+
/**
|
|
2465
|
+
* Creates a node index.
|
|
2466
|
+
* @param {any} options - The index creation options.
|
|
2467
|
+
* @returns {Promise<any>} The index creation result.
|
|
2468
|
+
*/
|
|
2469
|
+
createNodeIndex: async (options) => {
|
|
2470
|
+
const graphService = await this.createNewGraphService();
|
|
2471
|
+
return graphService.createNodeIndex(options);
|
|
2472
|
+
},
|
|
2473
|
+
/**
|
|
2474
|
+
* Creates a node constraint.
|
|
2475
|
+
* @param {any} options - The constraint creation options.
|
|
2476
|
+
* @returns {Promise<any>} The constraint creation result.
|
|
2477
|
+
*/
|
|
2478
|
+
createNodeConstraint: async (options) => {
|
|
2479
|
+
const graphService = await this.createNewGraphService();
|
|
2480
|
+
return graphService.createNodeConstraint(options);
|
|
2481
|
+
},
|
|
2482
|
+
/**
|
|
2483
|
+
* Creates a relationship index.
|
|
2484
|
+
* @param {any} options - The index creation options.
|
|
2485
|
+
* @returns {Promise<any>} The index creation result.
|
|
2486
|
+
*/
|
|
2487
|
+
createRelationshipIndex: async (options) => {
|
|
2488
|
+
const graphService = await this.createNewGraphService();
|
|
2489
|
+
return graphService.createRelationshipIndex(options);
|
|
2490
|
+
},
|
|
2491
|
+
/**
|
|
2492
|
+
* Lists all indexes.
|
|
2493
|
+
* @returns {Promise<any>} The list of indexes.
|
|
2494
|
+
*/
|
|
2495
|
+
listIndexes: async () => {
|
|
2496
|
+
const graphService = await this.createNewGraphService();
|
|
2497
|
+
return graphService.listIndexes();
|
|
2498
|
+
},
|
|
2499
|
+
/**
|
|
2500
|
+
* Lists all constraints.
|
|
2501
|
+
* @returns {Promise<any>} The list of constraints.
|
|
2502
|
+
*/
|
|
2503
|
+
listConstraints: async () => {
|
|
2504
|
+
const graphService = await this.createNewGraphService();
|
|
2505
|
+
return graphService.listConstraints();
|
|
2506
|
+
},
|
|
2507
|
+
/**
|
|
2508
|
+
* Drops an index by name.
|
|
2509
|
+
* @param {string} name - The index name.
|
|
2510
|
+
* @returns {Promise<any>} The drop result.
|
|
2511
|
+
*/
|
|
2512
|
+
dropIndex: async (name) => {
|
|
2513
|
+
const graphService = await this.createNewGraphService();
|
|
2514
|
+
return graphService.dropIndex(name);
|
|
2515
|
+
},
|
|
2516
|
+
/**
|
|
2517
|
+
* Drops a constraint by name.
|
|
2518
|
+
* @param {string} name - The constraint name.
|
|
2519
|
+
* @returns {Promise<any>} The drop result.
|
|
2520
|
+
*/
|
|
2521
|
+
dropConstraint: async (name) => {
|
|
2522
|
+
const graphService = await this.createNewGraphService();
|
|
2523
|
+
return graphService.dropConstraint(name);
|
|
2524
|
+
},
|
|
2525
|
+
/**
|
|
2526
|
+
* Lists all node labels.
|
|
2527
|
+
* @returns {Promise<any>} The list of labels.
|
|
2528
|
+
*/
|
|
2529
|
+
listLabels: async () => {
|
|
2530
|
+
const graphService = await this.createNewGraphService();
|
|
2531
|
+
return graphService.listLabels();
|
|
2532
|
+
},
|
|
2533
|
+
/**
|
|
2534
|
+
* Lists all relationship types.
|
|
2535
|
+
* @returns {Promise<any>} The list of relationship types.
|
|
2536
|
+
*/
|
|
2537
|
+
listRelationshipTypes: async () => {
|
|
2538
|
+
const graphService = await this.createNewGraphService();
|
|
2539
|
+
return graphService.listRelationshipTypes();
|
|
2540
|
+
},
|
|
2541
|
+
// ==================== ACTION OPERATIONS ====================
|
|
2542
|
+
/**
|
|
2543
|
+
* Creates a graph action.
|
|
2544
|
+
* @param {any} options - The action creation options.
|
|
2545
|
+
* @param {string} [productTag] - The product tag.
|
|
2546
|
+
* @returns {Promise<any>} The created action.
|
|
2547
|
+
*/
|
|
2548
|
+
createAction: async (options, productTag) => {
|
|
2549
|
+
const graphService = await this.createNewGraphService();
|
|
2550
|
+
return graphService.createAction(options, productTag);
|
|
2551
|
+
},
|
|
2552
|
+
/**
|
|
2553
|
+
* Lists graph actions.
|
|
2554
|
+
* @param {string} [graphTag] - The graph tag.
|
|
2555
|
+
* @param {string} [productTag] - The product tag.
|
|
2556
|
+
* @returns {Promise<any>} The list of actions.
|
|
2557
|
+
*/
|
|
2558
|
+
listActions: async (graphTag, productTag) => {
|
|
2559
|
+
const graphService = await this.createNewGraphService();
|
|
2560
|
+
return graphService.listActions(graphTag, productTag);
|
|
2561
|
+
},
|
|
2562
|
+
/**
|
|
2563
|
+
* Gets a graph action by tag.
|
|
2564
|
+
* @param {string} actionTag - The action tag.
|
|
2565
|
+
* @param {string} [graphTag] - The graph tag.
|
|
2566
|
+
* @param {string} [productTag] - The product tag.
|
|
2567
|
+
* @returns {Promise<any>} The action or null.
|
|
2568
|
+
*/
|
|
2569
|
+
getAction: async (actionTag, graphTag, productTag) => {
|
|
2570
|
+
const graphService = await this.createNewGraphService();
|
|
2571
|
+
return graphService.getAction(actionTag, graphTag, productTag);
|
|
2572
|
+
},
|
|
2573
|
+
/**
|
|
2574
|
+
* Updates a graph action.
|
|
2575
|
+
* @param {string} actionTag - The action tag.
|
|
2576
|
+
* @param {any} updates - The updates to apply.
|
|
2577
|
+
* @param {string} [graphTag] - The graph tag.
|
|
2578
|
+
* @param {string} [productTag] - The product tag.
|
|
2579
|
+
* @returns {Promise<any>} The updated action.
|
|
2580
|
+
*/
|
|
2581
|
+
updateAction: async (actionTag, updates, graphTag, productTag) => {
|
|
2582
|
+
const graphService = await this.createNewGraphService();
|
|
2583
|
+
return graphService.updateAction(actionTag, updates, graphTag, productTag);
|
|
2584
|
+
},
|
|
2585
|
+
/**
|
|
2586
|
+
* Deletes a graph action.
|
|
2587
|
+
* @param {string} actionTag - The action tag.
|
|
2588
|
+
* @param {string} [graphTag] - The graph tag.
|
|
2589
|
+
* @param {string} [productTag] - The product tag.
|
|
2590
|
+
* @returns {Promise<void>} Resolves when the action is deleted.
|
|
2591
|
+
*/
|
|
2592
|
+
deleteAction: async (actionTag, graphTag, productTag) => {
|
|
2593
|
+
const graphService = await this.createNewGraphService();
|
|
2594
|
+
return graphService.deleteAction(actionTag, graphTag, productTag);
|
|
2595
|
+
},
|
|
2596
|
+
// ==================== TRANSACTION OPERATIONS ====================
|
|
2597
|
+
/**
|
|
2598
|
+
* Begins a new transaction.
|
|
2599
|
+
* @param {any} [options] - Transaction options.
|
|
2600
|
+
* @returns {Promise<any>} The transaction object.
|
|
2601
|
+
*/
|
|
2602
|
+
beginTransaction: async (options) => {
|
|
2603
|
+
const graphService = await this.createNewGraphService();
|
|
2604
|
+
return graphService.beginTransaction(options);
|
|
2605
|
+
},
|
|
2606
|
+
/**
|
|
2607
|
+
* Commits a transaction.
|
|
2608
|
+
* @param {any} transaction - The transaction to commit.
|
|
2609
|
+
* @returns {Promise<void>} Resolves when committed.
|
|
2610
|
+
*/
|
|
2611
|
+
commitTransaction: async (transaction) => {
|
|
2612
|
+
const graphService = await this.createNewGraphService();
|
|
2613
|
+
return graphService.commitTransaction(transaction);
|
|
2614
|
+
},
|
|
2615
|
+
/**
|
|
2616
|
+
* Rolls back a transaction.
|
|
2617
|
+
* @param {any} transaction - The transaction to rollback.
|
|
2618
|
+
* @returns {Promise<void>} Resolves when rolled back.
|
|
2619
|
+
*/
|
|
2620
|
+
rollbackTransaction: async (transaction) => {
|
|
2621
|
+
const graphService = await this.createNewGraphService();
|
|
2622
|
+
return graphService.rollbackTransaction(transaction);
|
|
2623
|
+
},
|
|
2624
|
+
// ==================== DISPATCH OPERATIONS ====================
|
|
2625
|
+
/**
|
|
2626
|
+
* Dispatches a graph operation for deferred execution.
|
|
2627
|
+
* @param {any} data - The dispatch input.
|
|
2628
|
+
* @returns {Promise<any>} The dispatch result.
|
|
2629
|
+
*/
|
|
2630
|
+
dispatch: async (data) => {
|
|
2631
|
+
const graphService = await this.createNewGraphService();
|
|
2632
|
+
return graphService.dispatch(data);
|
|
2633
|
+
},
|
|
1988
2634
|
};
|
|
1989
2635
|
/**
|
|
1990
2636
|
* Workflow service for building and executing durable workflows.
|
|
@@ -3745,33 +4391,63 @@ class Ductape {
|
|
|
3745
4391
|
}
|
|
3746
4392
|
/**
|
|
3747
4393
|
* Create a new QuotaService instance with authenticated config
|
|
3748
|
-
* @returns QuotaService instance
|
|
4394
|
+
* @returns QuotaService instance (cached)
|
|
3749
4395
|
*/
|
|
3750
4396
|
async createNewQuotaService() {
|
|
3751
4397
|
const subCheck = false;
|
|
3752
4398
|
await this.initUserAuth(subCheck);
|
|
3753
|
-
|
|
3754
|
-
|
|
3755
|
-
|
|
3756
|
-
|
|
3757
|
-
|
|
3758
|
-
|
|
3759
|
-
|
|
4399
|
+
if (!this._quotaService) {
|
|
4400
|
+
this._quotaService = new resilience_1.QuotaService({
|
|
4401
|
+
workspace_id: this.workspace_id,
|
|
4402
|
+
public_key: this.public_key,
|
|
4403
|
+
user_id: this.user_id,
|
|
4404
|
+
token: this.token,
|
|
4405
|
+
env_type: this.environment,
|
|
4406
|
+
redis_client: this.redisClient,
|
|
4407
|
+
queues: { health: this.healthCheckQueue, jobs: this.jobsQueue },
|
|
4408
|
+
});
|
|
4409
|
+
}
|
|
4410
|
+
return this._quotaService;
|
|
3760
4411
|
}
|
|
3761
4412
|
/**
|
|
3762
4413
|
* Create a new FallbackService instance with authenticated config
|
|
3763
|
-
* @returns FallbackService instance
|
|
4414
|
+
* @returns FallbackService instance (cached)
|
|
3764
4415
|
*/
|
|
3765
4416
|
async createNewFallbackService() {
|
|
3766
4417
|
const subCheck = false;
|
|
3767
4418
|
await this.initUserAuth(subCheck);
|
|
3768
|
-
|
|
3769
|
-
|
|
3770
|
-
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
4419
|
+
if (!this._fallbackService) {
|
|
4420
|
+
this._fallbackService = new resilience_1.FallbackService({
|
|
4421
|
+
workspace_id: this.workspace_id,
|
|
4422
|
+
public_key: this.public_key,
|
|
4423
|
+
user_id: this.user_id,
|
|
4424
|
+
token: this.token,
|
|
4425
|
+
env_type: this.environment,
|
|
4426
|
+
redis_client: this.redisClient,
|
|
4427
|
+
queues: { health: this.healthCheckQueue, jobs: this.jobsQueue },
|
|
4428
|
+
});
|
|
4429
|
+
}
|
|
4430
|
+
return this._fallbackService;
|
|
4431
|
+
}
|
|
4432
|
+
/**
|
|
4433
|
+
* Create a new HealthcheckService instance with authenticated config
|
|
4434
|
+
* @returns HealthcheckService instance (cached)
|
|
4435
|
+
*/
|
|
4436
|
+
async createNewHealthcheckService() {
|
|
4437
|
+
const subCheck = false;
|
|
4438
|
+
await this.initUserAuth(subCheck);
|
|
4439
|
+
if (!this._healthcheckService) {
|
|
4440
|
+
this._healthcheckService = new resilience_1.HealthcheckService({
|
|
4441
|
+
workspace_id: this.workspace_id,
|
|
4442
|
+
public_key: this.public_key,
|
|
4443
|
+
user_id: this.user_id,
|
|
4444
|
+
token: this.token,
|
|
4445
|
+
env_type: this.environment,
|
|
4446
|
+
redis_client: this.redisClient,
|
|
4447
|
+
queues: { health: this.healthCheckQueue, jobs: this.jobsQueue },
|
|
4448
|
+
});
|
|
4449
|
+
}
|
|
4450
|
+
return this._healthcheckService;
|
|
3775
4451
|
}
|
|
3776
4452
|
async fetchSession() {
|
|
3777
4453
|
try {
|