@nimee/api-clients 1.1.98 → 1.1.103

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.
@@ -45,4 +45,22 @@ export declare class EndUserClient {
45
45
  sellerId: string;
46
46
  customerId?: string;
47
47
  }): Promise<import("axios").AxiosResponse<any, any>>;
48
+ saveSavedCard(params: {
49
+ endUserId: string;
50
+ jwt: string;
51
+ marketplaceId: string;
52
+ sellerId: string;
53
+ buyerKey: string;
54
+ buyerCardMask?: string;
55
+ buyerCardExp?: string;
56
+ buyerName?: string;
57
+ }): Promise<any>;
58
+ clearSavedCard(params: {
59
+ endUserId: string;
60
+ jwt: string;
61
+ marketplaceId: string;
62
+ sellerId: string;
63
+ buyerCardMask?: string;
64
+ buyerCardExp?: string;
65
+ }): Promise<any>;
48
66
  }
@@ -91,6 +91,29 @@ class EndUserClient {
91
91
  return axios_1.default.put(`${endUserUrl}/updateExternalPurchaseToken/${marketplaceId}/${sellerId}/${endUserId}`, { token, customerId }, { headers: { jwt } });
92
92
  });
93
93
  }
94
+ // Stores the card as the customer's card on file. Writes the display fields AND the token in one update,
95
+ // so the card shown to the customer can never drift from the one a SAVED_CARD checkout charges — which is
96
+ // what happens if only the token is written (see updateExternalPurchaseToken).
97
+ saveSavedCard(params) {
98
+ return __awaiter(this, void 0, void 0, function* () {
99
+ const { endUserId, jwt, marketplaceId, sellerId, buyerKey, buyerCardMask, buyerCardExp, buyerName } = params;
100
+ const response = yield axios_1.default.post(`${endUserUrl}/saved-card/${marketplaceId}/${sellerId}/${endUserId}`, { buyerKey, buyerCardMask, buyerCardExp, buyerName }, { headers: { jwt } });
101
+ return response === null || response === void 0 ? void 0 : response.data;
102
+ });
103
+ }
104
+ // Clears the card-on-file DISPLAY slot (endUser.savedCard) only — externalPurchaseToken is deliberately
105
+ // untouched (live season-ticket billing charges that slot). mask/exp narrow the clear to that exact card,
106
+ // so the user service atomically no-ops when the slot already holds a different (newer) card.
107
+ clearSavedCard(params) {
108
+ return __awaiter(this, void 0, void 0, function* () {
109
+ const { endUserId, jwt, marketplaceId, sellerId, buyerCardMask, buyerCardExp } = params;
110
+ const response = yield axios_1.default.delete(`${endUserUrl}/saved-card/${marketplaceId}/${sellerId}/${endUserId}`, {
111
+ headers: { jwt },
112
+ params: { buyerCardMask, buyerCardExp },
113
+ });
114
+ return response === null || response === void 0 ? void 0 : response.data;
115
+ });
116
+ }
94
117
  }
95
118
  exports.EndUserClient = EndUserClient;
96
119
  //# sourceMappingURL=endUser.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"endUser.js","sourceRoot":"","sources":["../../src/endUser.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,kDAA0B;AAC1B,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC;AACnC,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC,oBAAoB,IAAI,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC;AAC9F,MAAM,UAAU,GAAG,GAAG,QAAQ,eAAe,CAAC;AAE9C,MAAa,aAAa;IAClB,uCAAuC,CAAC,MAM7C;;YACC,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,aAAa,EAAE,qBAAqB,EAAE,GAAG,MAAM,CAAC;YACjF,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,IAAI,CAC/B,GAAG,UAAU,4CAA4C,aAAa,IAAI,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,EAAE,EAClG;gBACE,OAAO;gBACP,SAAS;gBACT,qBAAqB,EAAE,qBAAqB;aAC7C,EACD;gBACE,OAAO,EAAE,EAAE,GAAG,EAAE;aACjB,CACF,CAAC;YACF,OAAO,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,CAAC;QACxB,CAAC;KAAA;IACK,OAAO,CAAC,MAAoF;;YAChG,MAAM,EAAE,SAAS,EAAE,G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xF,cAAc,CAAC,MAOpB;;YACC,MAAM,EAAE,SAAS,EAAE,GAAG,EAAE,aAAa,EAAE,QAAQ,EAAE,aAAa,EAAE,YAAY,EAAE,GAAG,MAAM,CAAC;YACxF,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,MAAM,CAAC,GAAG,UAAU,eAAe,aAAa,IAAI,QAAQ,IAAI,SAAS,EAAE,EAAE;gBACxG,OAAO,EAAE,EAAE,GAAG,EAAE;gBAChB,MAAM,EAAE,EAAE,aAAa,EAAE,YAAY,EAAE;aACxC,CAAC,CAAC;YACH,OAAO,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,CAAC;QACxB,CAAC;KAAA;CACF;AA7HD,sCA6HC"}
@@ -13,3 +13,4 @@ export { CrmClient } from "./crm";
13
13
  export { AnalyticsClient, UtmData } from "./analytics";
14
14
  export { ScannerSessionClient } from "./scannerSession";
15
15
  export { VoucherSourceClient } from "./voucherSource";
16
+ export { InvoiceClient } from "./invoice";
package/dist/src/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.VoucherSourceClient = exports.ScannerSessionClient = exports.AnalyticsClient = exports.CrmClient = exports.EndUserSeasonTicketClient = exports.SegmentClient = exports.EndUserClient = exports.MarketplaceClient = exports.PaymentClient = exports.EventOrderClient = exports.AccountClient = exports.UserEventClient = exports.TicketClient = exports.EventClient = exports.UserClient = void 0;
3
+ exports.InvoiceClient = exports.VoucherSourceClient = exports.ScannerSessionClient = exports.AnalyticsClient = exports.CrmClient = exports.EndUserSeasonTicketClient = exports.SegmentClient = exports.EndUserClient = exports.MarketplaceClient = exports.PaymentClient = exports.EventOrderClient = exports.AccountClient = exports.UserEventClient = exports.TicketClient = exports.EventClient = exports.UserClient = void 0;
4
4
  var user_1 = require("./user");
5
5
  Object.defineProperty(exports, "UserClient", { enumerable: true, get: function () { return user_1.UserClient; } });
6
6
  var event_1 = require("./event");
@@ -31,4 +31,6 @@ var scannerSession_1 = require("./scannerSession");
31
31
  Object.defineProperty(exports, "ScannerSessionClient", { enumerable: true, get: function () { return scannerSession_1.ScannerSessionClient; } });
32
32
  var voucherSource_1 = require("./voucherSource");
33
33
  Object.defineProperty(exports, "VoucherSourceClient", { enumerable: true, get: function () { return voucherSource_1.VoucherSourceClient; } });
34
+ var invoice_1 = require("./invoice");
35
+ Object.defineProperty(exports, "InvoiceClient", { enumerable: true, get: function () { return invoice_1.InvoiceClient; } });
34
36
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,+BAAoC;AAA3B,kGAAA,UAAU,OAAA;AACnB,iCAAsC;AAA7B,oGAAA,WAAW,OAAA;AACpB,mCAAwC;AAA/B,sGAAA,YAAY,OAAA;AACrB,yCAA8C;AAArC,4GAAA,eAAe,OAAA;AACxB,qCAA0C;AAAjC,wGAAA,aAAa,OAAA;AACtB,2CAAgD;AAAvC,8GAAA,gBAAgB,OAAA;AACzB,qCAA0C;AAAjC,wGAAA,aAAa,OAAA;AACtB,6CAAkD;AAAzC,gHAAA,iBAAiB,OAAA;AAC1B,qCAA0C;AAAjC,wGAAA,aAAa,OAAA;AACtB,qCAA0C;AAAjC,wGAAA,aAAa,OAAA;AACtB,6DAAkE;AAAzD,gIAAA,yBAAyB,OAAA;AAClC,6BAAkC;AAAzB,gGAAA,SAAS,OAAA;AAClB,yCAAuD;AAA9C,4GAAA,eAAe,OAAA;AACxB,mDAAwD;AAA/C,sHAAA,oBAAoB,OAAA;AAE7B,iDAAsD;AAA7C,oHAAA,mBAAmB,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,+BAAoC;AAA3B,kGAAA,UAAU,OAAA;AACnB,iCAAsC;AAA7B,oGAAA,WAAW,OAAA;AACpB,mCAAwC;AAA/B,sGAAA,YAAY,OAAA;AACrB,yCAA8C;AAArC,4GAAA,eAAe,OAAA;AACxB,qCAA0C;AAAjC,wGAAA,aAAa,OAAA;AACtB,2CAAgD;AAAvC,8GAAA,gBAAgB,OAAA;AACzB,qCAA0C;AAAjC,wGAAA,aAAa,OAAA;AACtB,6CAAkD;AAAzC,gHAAA,iBAAiB,OAAA;AAC1B,qCAA0C;AAAjC,wGAAA,aAAa,OAAA;AACtB,qCAA0C;AAAjC,wGAAA,aAAa,OAAA;AACtB,6DAAkE;AAAzD,gIAAA,yBAAyB,OAAA;AAClC,6BAAkC;AAAzB,gGAAA,SAAS,OAAA;AAClB,yCAAuD;AAA9C,4GAAA,eAAe,OAAA;AACxB,mDAAwD;AAA/C,sHAAA,oBAAoB,OAAA;AAE7B,iDAAsD;AAA7C,oHAAA,mBAAmB,OAAA;AAE5B,qCAA0C;AAAjC,wGAAA,aAAa,OAAA"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Client for the invoices microservice (Nimi self-issued fiscal documents).
3
+ * doc/create and doc/cancel are internal-only routes gated to the fixed
4
+ * JWT_ADMIN service token - always call them with jwt: process.env.JWT_ADMIN.
5
+ */
6
+ export declare class InvoiceClient {
7
+ /** Create a fiscal document (invoice / receipt / credit note). Idempotent on body.sanity_string. */
8
+ createDoc(params: {
9
+ jwt: string;
10
+ body: Record<string, unknown>;
11
+ }): Promise<any>;
12
+ /** Cancel a document by issuing a reversing credit note. */
13
+ cancelDoc(params: {
14
+ jwt: string;
15
+ body: {
16
+ sellerId: string;
17
+ doctype: string;
18
+ docnum: number;
19
+ reason?: string;
20
+ };
21
+ }): Promise<any>;
22
+ }
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.InvoiceClient = void 0;
16
+ const axios_1 = __importDefault(require("axios"));
17
+ const error_handler_1 = require("@nimee/error-handler");
18
+ const port = process.env.INVOICES_PORT || "3009"; // default keeps IS_LOCAL dev working without env setup
19
+ const basePath = process.env.IS_LOCAL === "true" ? `http://127.0.0.1:${port}` : "http://invoices";
20
+ /**
21
+ * Client for the invoices microservice (Nimi self-issued fiscal documents).
22
+ * doc/create and doc/cancel are internal-only routes gated to the fixed
23
+ * JWT_ADMIN service token - always call them with jwt: process.env.JWT_ADMIN.
24
+ */
25
+ class InvoiceClient {
26
+ /** Create a fiscal document (invoice / receipt / credit note). Idempotent on body.sanity_string. */
27
+ createDoc(params) {
28
+ return __awaiter(this, void 0, void 0, function* () {
29
+ const { jwt, body } = params;
30
+ if (!jwt || !body) {
31
+ throw new error_handler_1.CustomError("params_missing_invoice_create_doc", 400, "jwt and body are required");
32
+ }
33
+ const response = yield axios_1.default.post(`${basePath}/invoices-internal/doc/create`, body, { headers: { jwt } });
34
+ return response === null || response === void 0 ? void 0 : response.data;
35
+ });
36
+ }
37
+ /** Cancel a document by issuing a reversing credit note. */
38
+ cancelDoc(params) {
39
+ return __awaiter(this, void 0, void 0, function* () {
40
+ const { jwt, body } = params;
41
+ if (!jwt || !body) {
42
+ throw new error_handler_1.CustomError("params_missing_invoice_cancel_doc", 400, "jwt and body are required");
43
+ }
44
+ const response = yield axios_1.default.post(`${basePath}/invoices-internal/doc/cancel`, body, { headers: { jwt } });
45
+ return response === null || response === void 0 ? void 0 : response.data;
46
+ });
47
+ }
48
+ }
49
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AG,QAAQ,+BAA+B,EAAE,IAAI,EAAE,EAAE,OAAO,EAAE,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC;YAC1G,OAAO,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,CAAC;QACxB,CAAC;KAAA;CACF;AApBD,sCAoBC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nimee/api-clients",
3
- "version": "1.1.98",
3
+ "version": "1.1.103",
4
4
  "description": "communication http for each ms",
5
5
  "main": "dist/src/index.js",
6
6
  "author": "dan goldberg",
@@ -14,12 +14,12 @@
14
14
  "prettier-format": "prettier --config .prettierrc 'src/**/*.ts' --write",
15
15
  "incVersionAndPublish": "npm run test:deploy && npm version patch && npm run publish-it && npm run i-all-workspaces",
16
16
  "publish-it": "npm run build && npm publish --scope=nimee --access public",
17
- "i-all-workspaces": "version=${npm_package_version} npm i @nimee/api-clients@$version --workspace=@nimee/event --workspace=@nimee/user-event --workspace=@nimee/send-notification --workspace=@nimee/user --workspace=@nimee/payment --workspace=@nimee/analytics --workspace=@nimee/crm",
17
+ "i-all-workspaces": "version=${npm_package_version} npm i @nimee/api-clients@$version --workspace=@nimee/event --workspace=@nimee/user-event --workspace=@nimee/send-notification --workspace=@nimee/user --workspace=@nimee/payment --workspace=@nimee/analytics --workspace=@nimee/crm --workspace=@nimee/invoices",
18
18
  "test": "jest --detectOpenHandles --watch",
19
19
  "test:deploy": "jest --ci --coverage"
20
20
  },
21
21
  "devDependencies": {
22
- "@nimee/tests": "^0.0.39",
22
+ "@nimee/tests": "^0.0.41",
23
23
  "@typescript-eslint/eslint-plugin": "^5.18.0",
24
24
  "@typescript-eslint/eslint-plugin-tslint": "^5.18.0",
25
25
  "@typescript-eslint/parser": "^5.18.0",
@@ -38,7 +38,7 @@
38
38
  "dependencies": {
39
39
  "@nimee/error-handler": "0.0.14",
40
40
  "@nimee/logger": "^1.0.27",
41
- "@nimee/shared-types": "^1.0.207",
41
+ "@nimee/shared-types": "^1.0.317",
42
42
  "axios": "1.2.1"
43
43
  }
44
44
  }
package/src/endUser.ts CHANGED
@@ -89,4 +89,44 @@ export class EndUserClient {
89
89
  { headers: { jwt } }
90
90
  );
91
91
  }
92
+ // Stores the card as the customer's card on file. Writes the display fields AND the token in one update,
93
+ // so the card shown to the customer can never drift from the one a SAVED_CARD checkout charges — which is
94
+ // what happens if only the token is written (see updateExternalPurchaseToken).
95
+ async saveSavedCard(params: {
96
+ endUserId: string;
97
+ jwt: string;
98
+ marketplaceId: string;
99
+ sellerId: string;
100
+ buyerKey: string;
101
+ buyerCardMask?: string;
102
+ buyerCardExp?: string;
103
+ buyerName?: string;
104
+ }) {
105
+ const { endUserId, jwt, marketplaceId, sellerId, buyerKey, buyerCardMask, buyerCardExp, buyerName } = params;
106
+ const response = await axios.post(
107
+ `${endUserUrl}/saved-card/${marketplaceId}/${sellerId}/${endUserId}`,
108
+ { buyerKey, buyerCardMask, buyerCardExp, buyerName },
109
+ { headers: { jwt } }
110
+ );
111
+ return response?.data;
112
+ }
113
+
114
+ // Clears the card-on-file DISPLAY slot (endUser.savedCard) only — externalPurchaseToken is deliberately
115
+ // untouched (live season-ticket billing charges that slot). mask/exp narrow the clear to that exact card,
116
+ // so the user service atomically no-ops when the slot already holds a different (newer) card.
117
+ async clearSavedCard(params: {
118
+ endUserId: string;
119
+ jwt: string;
120
+ marketplaceId: string;
121
+ sellerId: string;
122
+ buyerCardMask?: string;
123
+ buyerCardExp?: string;
124
+ }) {
125
+ const { endUserId, jwt, marketplaceId, sellerId, buyerCardMask, buyerCardExp } = params;
126
+ const response = await axios.delete(`${endUserUrl}/saved-card/${marketplaceId}/${sellerId}/${endUserId}`, {
127
+ headers: { jwt },
128
+ params: { buyerCardMask, buyerCardExp },
129
+ });
130
+ return response?.data;
131
+ }
92
132
  }
package/src/index.ts CHANGED
@@ -14,3 +14,5 @@ export { AnalyticsClient, UtmData } from "./analytics";
14
14
  export { ScannerSessionClient } from "./scannerSession";
15
15
 
16
16
  export { VoucherSourceClient } from "./voucherSource";
17
+
18
+ export { InvoiceClient } from "./invoice";
package/src/invoice.ts ADDED
@@ -0,0 +1,32 @@
1
+ import axios from "axios";
2
+ import { CustomError } from "@nimee/error-handler";
3
+
4
+ const port = process.env.INVOICES_PORT || "3009"; // default keeps IS_LOCAL dev working without env setup
5
+ const basePath = process.env.IS_LOCAL === "true" ? `http://127.0.0.1:${port}` : "http://invoices";
6
+
7
+ /**
8
+ * Client for the invoices microservice (Nimi self-issued fiscal documents).
9
+ * doc/create and doc/cancel are internal-only routes gated to the fixed
10
+ * JWT_ADMIN service token - always call them with jwt: process.env.JWT_ADMIN.
11
+ */
12
+ export class InvoiceClient {
13
+ /** Create a fiscal document (invoice / receipt / credit note). Idempotent on body.sanity_string. */
14
+ async createDoc(params: { jwt: string; body: Record<string, unknown> }) {
15
+ const { jwt, body } = params;
16
+ if (!jwt || !body) {
17
+ throw new CustomError("params_missing_invoice_create_doc", 400, "jwt and body are required");
18
+ }
19
+ const response = await axios.post(`${basePath}/invoices-internal/doc/create`, body, { headers: { jwt } });
20
+ return response?.data;
21
+ }
22
+
23
+ /** Cancel a document by issuing a reversing credit note. */
24
+ async cancelDoc(params: { jwt: string; body: { sellerId: string; doctype: string; docnum: number; reason?: string } }) {
25
+ const { jwt, body } = params;
26
+ if (!jwt || !body) {
27
+ throw new CustomError("params_missing_invoice_cancel_doc", 400, "jwt and body are required");
28
+ }
29
+ const response = await axios.post(`${basePath}/invoices-internal/doc/cancel`, body, { headers: { jwt } });
30
+ return response?.data;
31
+ }
32
+ }