@nimee/api-clients 1.1.98 → 1.1.99

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.
@@ -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
+ exports.InvoiceClient = InvoiceClient;
50
+ //# sourceMappingURL=invoice.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"invoice.js","sourceRoot":"","sources":["../../src/invoice.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,kDAA0B;AAC1B,wDAAmD;AAEnD,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,aAAa,IAAI,MAAM,CAAC,CAAC,uDAAuD;AACzG,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC,oBAAoB,IAAI,EAAE,CAAC,CAAC,CAAC,iBAAiB,CAAC;AAElG;;;;GAIG;AACH,MAAa,aAAa;IACxB,oGAAoG;IAC9F,SAAS,CAAC,MAAsD;;YACpE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC;YAC7B,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;gBAClB,MAAM,IAAI,2BAAW,CAAC,mCAAmC,EAAE,GAAG,EAAE,2BAA2B,CAAC,CAAC;YAC/F,CAAC;YACD,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,IAAI,CAAC,GAAG,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;IAED,4DAA4D;IACtD,SAAS,CAAC,MAAqG;;YACnH,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,MAAM,CAAC;YAC7B,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;gBAClB,MAAM,IAAI,2BAAW,CAAC,mCAAmC,EAAE,GAAG,EAAE,2BAA2B,CAAC,CAAC;YAC/F,CAAC;YACD,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,IAAI,CAAC,GAAG,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.99",
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.40",
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",
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
+ }