@innvoid/getmarket-sdk 0.2.5 → 0.2.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.
@@ -35,6 +35,7 @@ __export(clients_exports, {
35
35
  createMdClient: () => createMdClient,
36
36
  createMediaClient: () => createMediaClient,
37
37
  createMkpClient: () => createMkpClient,
38
+ createPayClient: () => createPayClient,
38
39
  createPlatformClient: () => createPlatformClient,
39
40
  createResClient: () => createResClient,
40
41
  readServiceEnv: () => readServiceEnv
@@ -597,8 +598,43 @@ function createResClient() {
597
598
  apiPrefix: env.apiPrefix,
598
599
  path: "/refs/varieties"
599
600
  });
601
+ const resources = createBulkRefsClient({
602
+ namespace: "res:resource",
603
+ baseURL: env.baseURL,
604
+ apiPrefix: env.apiPrefix,
605
+ path: "/refs/resources"
606
+ });
607
+ const categories = createBulkRefsClient({
608
+ namespace: "res:category",
609
+ baseURL: env.baseURL,
610
+ apiPrefix: env.apiPrefix,
611
+ path: "/refs/categories"
612
+ });
613
+ const attributes = createBulkRefsClient({
614
+ namespace: "res:attribute",
615
+ baseURL: env.baseURL,
616
+ apiPrefix: env.apiPrefix,
617
+ path: "/refs/attributes"
618
+ });
619
+ const attributeOptions = createBulkRefsClient({
620
+ namespace: "res:attribute_option",
621
+ baseURL: env.baseURL,
622
+ apiPrefix: env.apiPrefix,
623
+ path: "/refs/attribute-options"
624
+ });
625
+ const attributeValues = createBulkRefsClient({
626
+ namespace: "res:attribute_value",
627
+ baseURL: env.baseURL,
628
+ apiPrefix: env.apiPrefix,
629
+ path: "/refs/attribute-values"
630
+ });
600
631
  return {
601
- varietiesRefs: (uids, opts) => varieties.bulkRefs(uids, opts)
632
+ varietiesRefs: (uids, opts) => varieties.bulkRefs(uids, opts),
633
+ resourcesRefs: (uids, opts) => resources.bulkRefs(uids, opts),
634
+ categoriesRefs: (uids, opts) => categories.bulkRefs(uids, opts),
635
+ attributesRefs: (uids, opts) => attributes.bulkRefs(uids, opts),
636
+ attributeOptionsRefs: (uids, opts) => attributeOptions.bulkRefs(uids, opts),
637
+ attributeValuesRefs: (uids, opts) => attributeValues.bulkRefs(uids, opts)
602
638
  };
603
639
  }
604
640
 
@@ -623,10 +659,31 @@ function createMdClient() {
623
659
  apiPrefix: env.apiPrefix,
624
660
  path: "/refs/countries"
625
661
  });
662
+ const currencies = createBulkRefsClient({
663
+ namespace: "md:currency",
664
+ baseURL: env.baseURL,
665
+ apiPrefix: env.apiPrefix,
666
+ path: "/refs/currencies"
667
+ });
668
+ const regions = createBulkRefsClient({
669
+ namespace: "md:region",
670
+ baseURL: env.baseURL,
671
+ apiPrefix: env.apiPrefix,
672
+ path: "/refs/regions"
673
+ });
674
+ const communes = createBulkRefsClient({
675
+ namespace: "md:commune",
676
+ baseURL: env.baseURL,
677
+ apiPrefix: env.apiPrefix,
678
+ path: "/refs/communes"
679
+ });
626
680
  return {
627
681
  measuresRefs: (uids, opts) => measures.bulkRefs(uids, opts),
628
682
  measureTypesRefs: (uids, opts) => measureTypes.bulkRefs(uids, opts),
629
- countriesRefs: (uids, opts) => countries.bulkRefs(uids, opts)
683
+ countriesRefs: (uids, opts) => countries.bulkRefs(uids, opts),
684
+ currenciesRefs: (uids, opts) => currencies.bulkRefs(uids, opts),
685
+ regionsRefs: (uids, opts) => regions.bulkRefs(uids, opts),
686
+ communesRefs: (uids, opts) => communes.bulkRefs(uids, opts)
630
687
  };
631
688
  }
632
689
 
@@ -647,11 +704,11 @@ function createFisClient() {
647
704
  baseURL: `${env.baseURL}${env.apiPrefix}`,
648
705
  timeoutMs: 8e3
649
706
  });
650
- const taxes = createBulkRefsClient({
651
- namespace: "fis:tax",
707
+ const profiles = createBulkRefsClient({
708
+ namespace: "fis:profile",
652
709
  baseURL: env.baseURL,
653
710
  apiPrefix: env.apiPrefix,
654
- path: "/refs/taxes"
711
+ path: "/refs/profiles"
655
712
  });
656
713
  const documents = createBulkRefsClient({
657
714
  namespace: "fis:document",
@@ -659,77 +716,113 @@ function createFisClient() {
659
716
  apiPrefix: env.apiPrefix,
660
717
  path: "/refs/documents"
661
718
  });
719
+ const snapshots = createBulkRefsClient({
720
+ namespace: "fis:snapshot",
721
+ baseURL: env.baseURL,
722
+ apiPrefix: env.apiPrefix,
723
+ path: "/refs/snapshots"
724
+ });
662
725
  const submissions = createBulkRefsClient({
663
726
  namespace: "fis:submission",
664
727
  baseURL: env.baseURL,
665
728
  apiPrefix: env.apiPrefix,
666
729
  path: "/refs/submissions"
667
730
  });
731
+ const folioPools = createBulkRefsClient({
732
+ namespace: "fis:folio_pool",
733
+ baseURL: env.baseURL,
734
+ apiPrefix: env.apiPrefix,
735
+ path: "/refs/folio-pools"
736
+ });
737
+ const taxRules = createBulkRefsClient({
738
+ namespace: "fis:tax_rule",
739
+ baseURL: env.baseURL,
740
+ apiPrefix: env.apiPrefix,
741
+ path: "/refs/tax-rules"
742
+ });
668
743
  return {
669
744
  // -----------------------------------------------------------------------
670
745
  // Bulk refs
671
746
  // -----------------------------------------------------------------------
672
- taxesRefs: (uids, opts) => taxes.bulkRefs(uids, opts),
747
+ profilesRefs: (uids, opts) => profiles.bulkRefs(uids, opts),
673
748
  documentsRefs: (uids, opts) => documents.bulkRefs(uids, opts),
749
+ snapshotsRefs: (uids, opts) => snapshots.bulkRefs(uids, opts),
674
750
  submissionsRefs: (uids, opts) => submissions.bulkRefs(uids, opts),
751
+ folioPoolsRefs: (uids, opts) => folioPools.bulkRefs(uids, opts),
752
+ taxRulesRefs: (uids, opts) => taxRules.bulkRefs(uids, opts),
675
753
  // -----------------------------------------------------------------------
676
754
  // Fiscal calculation / build / lifecycle
677
755
  // -----------------------------------------------------------------------
678
- calculate: async (body) => {
756
+ async calculate(body) {
679
757
  const { data } = await http.post("/calculate", body);
680
758
  return data;
681
759
  },
682
- buildDocument: async (body) => {
683
- const { data } = await http.post("/documents/build", body);
760
+ async calculateTaxes(body) {
761
+ const { data } = await http.post("/tax/calculate", body);
684
762
  return data;
685
763
  },
686
- signDocument: async (body) => {
687
- const { data } = await http.post("/documents/sign", body);
764
+ async buildDocument(body) {
765
+ const { data } = await http.post("/documents", body);
766
+ return data;
767
+ },
768
+ async signDocument(body) {
769
+ const { data } = await http.post(
770
+ `/documents/${body.document_uid}/sign`,
771
+ body
772
+ );
688
773
  return data;
689
774
  },
690
- submitDocument: async (body) => {
691
- const { data } = await http.post("/documents/submit", body);
775
+ async submitDocument(body) {
776
+ const { data } = await http.post(
777
+ `/documents/${body.document_uid}/submit`,
778
+ body
779
+ );
692
780
  return data;
693
781
  },
694
- cancelDocument: async (body) => {
695
- const { data } = await http.post("/documents/cancel", body);
782
+ async cancelDocument(body) {
783
+ const { data } = await http.post(
784
+ `/documents/${body.document_uid}/cancel`,
785
+ body
786
+ );
696
787
  return data;
697
788
  },
698
789
  // -----------------------------------------------------------------------
699
790
  // Folios / series
700
791
  // -----------------------------------------------------------------------
701
- reserveFolio: async (body) => {
792
+ async reserveFolio(body) {
702
793
  const { data } = await http.post("/folios/reserve", body);
703
794
  return data;
704
795
  },
705
- consumeFolio: async (body) => {
796
+ async consumeFolio(body) {
706
797
  const { data } = await http.post("/folios/consume", body);
707
798
  return data;
708
799
  },
709
800
  // -----------------------------------------------------------------------
710
801
  // Queries / detail
711
802
  // -----------------------------------------------------------------------
712
- queryDocuments: async (params) => {
713
- const { data } = await http.get("/documents", { params });
803
+ async queryDocuments(body) {
804
+ const { data } = await http.post("/documents/query", body);
714
805
  return data;
715
806
  },
716
- getDocumentByUid: async (uid) => {
807
+ async getDocumentByUid(uid) {
717
808
  const { data } = await http.get(`/documents/${uid}`);
718
809
  return data;
719
810
  },
720
- getSnapshotByUid: async (uid) => {
811
+ async getSnapshotByUid(uid) {
721
812
  const { data } = await http.get(`/snapshots/${uid}`);
722
813
  return data;
723
814
  },
724
- getSubmissionByUid: async (uid) => {
815
+ async getSubmissionByUid(uid) {
725
816
  const { data } = await http.get(`/submissions/${uid}`);
726
817
  return data;
727
818
  },
728
- getStatusEventsByDocumentUid: async (documentUid) => {
729
- const { data } = await http.get(`/documents/${documentUid}/status-events`);
819
+ async getStatusEventsByDocumentUid(documentUid) {
820
+ const { data } = await http.get(
821
+ `/documents/${documentUid}/status-events`
822
+ );
730
823
  return data;
731
824
  },
732
- retrySubmission: async (body) => {
825
+ async retrySubmission(body) {
733
826
  const { data } = await http.post("/submissions/retry", body);
734
827
  return data;
735
828
  }
@@ -777,6 +870,117 @@ function createMkpClient() {
777
870
  promotionsRefs: (uids, opts) => promotions.bulkRefs(uids, opts)
778
871
  };
779
872
  }
873
+
874
+ // src/clients/payClient.ts
875
+ function createPayClient() {
876
+ const env = readServiceEnv("PAY", { apiPrefix: "/internal/v1" });
877
+ const http = createHttpClient({
878
+ baseURL: `${env.baseURL}${env.apiPrefix}`,
879
+ timeoutMs: 8e3
880
+ });
881
+ const intents = createBulkRefsClient({
882
+ namespace: "pay:intent",
883
+ baseURL: env.baseURL,
884
+ apiPrefix: env.apiPrefix,
885
+ path: "/refs/intents"
886
+ });
887
+ const attempts = createBulkRefsClient({
888
+ namespace: "pay:attempt",
889
+ baseURL: env.baseURL,
890
+ apiPrefix: env.apiPrefix,
891
+ path: "/refs/attempts"
892
+ });
893
+ const transactions = createBulkRefsClient({
894
+ namespace: "pay:transaction",
895
+ baseURL: env.baseURL,
896
+ apiPrefix: env.apiPrefix,
897
+ path: "/refs/transactions"
898
+ });
899
+ const refunds = createBulkRefsClient({
900
+ namespace: "pay:refund",
901
+ baseURL: env.baseURL,
902
+ apiPrefix: env.apiPrefix,
903
+ path: "/refs/refunds"
904
+ });
905
+ const allocations = createBulkRefsClient({
906
+ namespace: "pay:allocation",
907
+ baseURL: env.baseURL,
908
+ apiPrefix: env.apiPrefix,
909
+ path: "/refs/allocations"
910
+ });
911
+ const providerAccounts = createBulkRefsClient({
912
+ namespace: "pay:provider_account",
913
+ baseURL: env.baseURL,
914
+ apiPrefix: env.apiPrefix,
915
+ path: "/refs/provider-accounts"
916
+ });
917
+ const paymentMethods = createBulkRefsClient({
918
+ namespace: "pay:payment_method",
919
+ baseURL: env.baseURL,
920
+ apiPrefix: env.apiPrefix,
921
+ path: "/refs/payment-methods"
922
+ });
923
+ return {
924
+ // -----------------------------------------------------------------------
925
+ // Payment intents
926
+ // -----------------------------------------------------------------------
927
+ async createIntent(body) {
928
+ const { data } = await http.post("/payment-intents", body);
929
+ return data;
930
+ },
931
+ async getIntentByUid(uid) {
932
+ const { data } = await http.get(`/payment-intents/${uid}`);
933
+ return data;
934
+ },
935
+ async confirmIntent(body) {
936
+ const { data } = await http.post(
937
+ `/payment-intents/${body.intent_uid}/confirm`,
938
+ body
939
+ );
940
+ return data;
941
+ },
942
+ // -----------------------------------------------------------------------
943
+ // Attempts
944
+ // -----------------------------------------------------------------------
945
+ async startAttempt(body) {
946
+ const { data } = await http.post("/attempts", body);
947
+ return data;
948
+ },
949
+ // -----------------------------------------------------------------------
950
+ // Methods / availability
951
+ // -----------------------------------------------------------------------
952
+ async getAvailableMethods(params) {
953
+ const { data } = await http.get("/methods/available", {
954
+ params
955
+ });
956
+ return data;
957
+ },
958
+ // -----------------------------------------------------------------------
959
+ // Queries / allocations
960
+ // -----------------------------------------------------------------------
961
+ async queryPayments(body) {
962
+ const { data } = await http.post("/payments/query", body);
963
+ return data;
964
+ },
965
+ async getAllocationsByTarget(body) {
966
+ const { data } = await http.post(
967
+ "/allocations/by-target",
968
+ body
969
+ );
970
+ return data;
971
+ },
972
+ // -----------------------------------------------------------------------
973
+ // Bulk refs
974
+ // -----------------------------------------------------------------------
975
+ intentsRefs: (uids, opts) => intents.bulkRefs(uids, opts),
976
+ attemptsRefs: (uids, opts) => attempts.bulkRefs(uids, opts),
977
+ transactionsRefs: (uids, opts) => transactions.bulkRefs(uids, opts),
978
+ refundsRefs: (uids, opts) => refunds.bulkRefs(uids, opts),
979
+ allocationsRefs: (uids, opts) => allocations.bulkRefs(uids, opts),
980
+ providerAccountsRefs: (uids, opts) => providerAccounts.bulkRefs(uids, opts),
981
+ paymentMethodsRefs: (uids, opts) => paymentMethods.bulkRefs(uids, opts)
982
+ };
983
+ }
780
984
  // Annotate the CommonJS export names for ESM import in node:
781
985
  0 && (module.exports = {
782
986
  createBulkRefsClient,
@@ -784,6 +988,7 @@ function createMkpClient() {
784
988
  createMdClient,
785
989
  createMediaClient,
786
990
  createMkpClient,
991
+ createPayClient,
787
992
  createPlatformClient,
788
993
  createResClient,
789
994
  readServiceEnv