@innvoid/getmarket-sdk 0.2.4 → 0.2.5

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.
@@ -1,5 +1,5 @@
1
1
  import { R as RequestContext } from '../parse-C4vk-fmH.js';
2
- import { BulkRefsResponse, PlatformServiceCode, PlatformResolveTenantResponse, ResVarietiesRefsResponse, MdMeasuresRefsResponse, MdMeasureTypesRefsResponse, MdCountriesRefsResponse, FisTaxesRefsResponse, MediaFilesRefsResponse, MkpPublicationsRefsResponse, MkpEventsRefsResponse, MkpPromotionsRefsResponse } from '@innvoid/getmarket-contracts';
2
+ import { BulkRefsResponse, PlatformServiceCode, PlatformResolveTenantResponse, ResVarietiesRefsResponse, MdMeasuresRefsResponse, MdMeasureTypesRefsResponse, MdCountriesRefsResponse, FisTaxesRefsResponse, FisDocumentsRefsResponse, FisSubmissionsRefsResponse, FisCalculateRequest, FisCalculateResponse, FisBuildDocumentRequest, FisBuildDocumentResponse, FisSignDocumentRequest, FisSignDocumentResponse, FisSubmitDocumentRequest, FisSubmitDocumentResponse, FisCancelDocumentRequest, FisCancelDocumentResponse, FisReserveFolioRequest, FisReserveFolioResponse, FisConsumeFolioRequest, FisConsumeFolioResponse, FisDocumentsQueryRequest, FisDocumentsQueryResponse, UID, FisDocumentResponse, FisSnapshotResponse, FisSubmissionResponse, FisStatusEventsResponse, FisSubmissionRetryRequest, FisSubmissionRetryResponse, MediaFilesRefsResponse, MkpPublicationsRefsResponse, MkpEventsRefsResponse, MkpPromotionsRefsResponse } from '@innvoid/getmarket-contracts';
3
3
  export { BulkRefsResponse, BulkUidsRequest } from '@innvoid/getmarket-contracts';
4
4
 
5
5
  /**
@@ -60,6 +60,21 @@ declare function createMdClient(): {
60
60
 
61
61
  declare function createFisClient(): {
62
62
  taxesRefs: (uids: string[], opts?: any) => Promise<FisTaxesRefsResponse>;
63
+ documentsRefs: (uids: string[], opts?: any) => Promise<FisDocumentsRefsResponse>;
64
+ submissionsRefs: (uids: string[], opts?: any) => Promise<FisSubmissionsRefsResponse>;
65
+ calculate: (body: FisCalculateRequest) => Promise<FisCalculateResponse>;
66
+ buildDocument: (body: FisBuildDocumentRequest) => Promise<FisBuildDocumentResponse>;
67
+ signDocument: (body: FisSignDocumentRequest) => Promise<FisSignDocumentResponse>;
68
+ submitDocument: (body: FisSubmitDocumentRequest) => Promise<FisSubmitDocumentResponse>;
69
+ cancelDocument: (body: FisCancelDocumentRequest) => Promise<FisCancelDocumentResponse>;
70
+ reserveFolio: (body: FisReserveFolioRequest) => Promise<FisReserveFolioResponse>;
71
+ consumeFolio: (body: FisConsumeFolioRequest) => Promise<FisConsumeFolioResponse>;
72
+ queryDocuments: (params: FisDocumentsQueryRequest) => Promise<FisDocumentsQueryResponse>;
73
+ getDocumentByUid: (uid: UID) => Promise<FisDocumentResponse>;
74
+ getSnapshotByUid: (uid: UID) => Promise<FisSnapshotResponse>;
75
+ getSubmissionByUid: (uid: UID) => Promise<FisSubmissionResponse>;
76
+ getStatusEventsByDocumentUid: (documentUid: UID) => Promise<FisStatusEventsResponse>;
77
+ retrySubmission: (body: FisSubmissionRetryRequest) => Promise<FisSubmissionRetryResponse>;
63
78
  };
64
79
 
65
80
  declare function createMediaClient(): {
@@ -7,8 +7,9 @@ import {
7
7
  createPlatformClient,
8
8
  createResClient,
9
9
  readServiceEnv
10
- } from "../chunk-UK6LHHJQ.js";
10
+ } from "../chunk-HA2XKSTP.js";
11
11
  import "../chunk-QVPPDOXY.js";
12
+ import "../chunk-5S2JP7PR.js";
12
13
  import "../chunk-KXXIMSON.js";
13
14
  export {
14
15
  createBulkRefsClient,
package/dist/index.cjs CHANGED
@@ -66,7 +66,10 @@ __export(src_exports, {
66
66
  getRequestContextFromHeaders: () => getRequestContextFromHeaders,
67
67
  getTwoLevelCache: () => getTwoLevelCache,
68
68
  internalAuth: () => internalAuth,
69
+ isUid: () => isUid,
69
70
  mapAxiosToUpstreamError: () => mapAxiosToUpstreamError,
71
+ newUid: () => newUid,
72
+ newUidV4: () => newUidV4,
70
73
  parseHeaders: () => parseHeaders,
71
74
  readRs256PublicKey: () => readRs256PublicKey,
72
75
  readServiceEnv: () => readServiceEnv,
@@ -1513,14 +1516,96 @@ function createMdClient() {
1513
1516
  // src/clients/fisClient.ts
1514
1517
  function createFisClient() {
1515
1518
  const env = readServiceEnv("FIS", { apiPrefix: "/internal/v1" });
1519
+ const http = createHttpClient({
1520
+ baseURL: `${env.baseURL}${env.apiPrefix}`,
1521
+ timeoutMs: 8e3
1522
+ });
1516
1523
  const taxes = createBulkRefsClient({
1517
1524
  namespace: "fis:tax",
1518
1525
  baseURL: env.baseURL,
1519
1526
  apiPrefix: env.apiPrefix,
1520
1527
  path: "/refs/taxes"
1521
1528
  });
1529
+ const documents = createBulkRefsClient({
1530
+ namespace: "fis:document",
1531
+ baseURL: env.baseURL,
1532
+ apiPrefix: env.apiPrefix,
1533
+ path: "/refs/documents"
1534
+ });
1535
+ const submissions = createBulkRefsClient({
1536
+ namespace: "fis:submission",
1537
+ baseURL: env.baseURL,
1538
+ apiPrefix: env.apiPrefix,
1539
+ path: "/refs/submissions"
1540
+ });
1522
1541
  return {
1523
- taxesRefs: (uids, opts) => taxes.bulkRefs(uids, opts)
1542
+ // -----------------------------------------------------------------------
1543
+ // Bulk refs
1544
+ // -----------------------------------------------------------------------
1545
+ taxesRefs: (uids, opts) => taxes.bulkRefs(uids, opts),
1546
+ documentsRefs: (uids, opts) => documents.bulkRefs(uids, opts),
1547
+ submissionsRefs: (uids, opts) => submissions.bulkRefs(uids, opts),
1548
+ // -----------------------------------------------------------------------
1549
+ // Fiscal calculation / build / lifecycle
1550
+ // -----------------------------------------------------------------------
1551
+ calculate: async (body) => {
1552
+ const { data } = await http.post("/calculate", body);
1553
+ return data;
1554
+ },
1555
+ buildDocument: async (body) => {
1556
+ const { data } = await http.post("/documents/build", body);
1557
+ return data;
1558
+ },
1559
+ signDocument: async (body) => {
1560
+ const { data } = await http.post("/documents/sign", body);
1561
+ return data;
1562
+ },
1563
+ submitDocument: async (body) => {
1564
+ const { data } = await http.post("/documents/submit", body);
1565
+ return data;
1566
+ },
1567
+ cancelDocument: async (body) => {
1568
+ const { data } = await http.post("/documents/cancel", body);
1569
+ return data;
1570
+ },
1571
+ // -----------------------------------------------------------------------
1572
+ // Folios / series
1573
+ // -----------------------------------------------------------------------
1574
+ reserveFolio: async (body) => {
1575
+ const { data } = await http.post("/folios/reserve", body);
1576
+ return data;
1577
+ },
1578
+ consumeFolio: async (body) => {
1579
+ const { data } = await http.post("/folios/consume", body);
1580
+ return data;
1581
+ },
1582
+ // -----------------------------------------------------------------------
1583
+ // Queries / detail
1584
+ // -----------------------------------------------------------------------
1585
+ queryDocuments: async (params) => {
1586
+ const { data } = await http.get("/documents", { params });
1587
+ return data;
1588
+ },
1589
+ getDocumentByUid: async (uid) => {
1590
+ const { data } = await http.get(`/documents/${uid}`);
1591
+ return data;
1592
+ },
1593
+ getSnapshotByUid: async (uid) => {
1594
+ const { data } = await http.get(`/snapshots/${uid}`);
1595
+ return data;
1596
+ },
1597
+ getSubmissionByUid: async (uid) => {
1598
+ const { data } = await http.get(`/submissions/${uid}`);
1599
+ return data;
1600
+ },
1601
+ getStatusEventsByDocumentUid: async (documentUid) => {
1602
+ const { data } = await http.get(`/documents/${documentUid}/status-events`);
1603
+ return data;
1604
+ },
1605
+ retrySubmission: async (body) => {
1606
+ const { data } = await http.post("/submissions/retry", body);
1607
+ return data;
1608
+ }
1524
1609
  };
1525
1610
  }
1526
1611
 
@@ -1565,6 +1650,18 @@ function createMkpClient() {
1565
1650
  promotionsRefs: (uids, opts) => promotions.bulkRefs(uids, opts)
1566
1651
  };
1567
1652
  }
1653
+
1654
+ // src/common/ids.ts
1655
+ var import_uuid = require("uuid");
1656
+ function newUid() {
1657
+ return (0, import_uuid.v7)();
1658
+ }
1659
+ function newUidV4() {
1660
+ return (0, import_uuid.v4)();
1661
+ }
1662
+ function isUid(value) {
1663
+ return (0, import_uuid.validate)(value) && ((0, import_uuid.version)(value) === 7 || (0, import_uuid.version)(value) === 4);
1664
+ }
1568
1665
  // Annotate the CommonJS export names for ESM import in node:
1569
1666
  0 && (module.exports = {
1570
1667
  HEADER_AUTHORIZATION,
@@ -1603,7 +1700,10 @@ function createMkpClient() {
1603
1700
  getRequestContextFromHeaders,
1604
1701
  getTwoLevelCache,
1605
1702
  internalAuth,
1703
+ isUid,
1606
1704
  mapAxiosToUpstreamError,
1705
+ newUid,
1706
+ newUidV4,
1607
1707
  parseHeaders,
1608
1708
  readRs256PublicKey,
1609
1709
  readServiceEnv,