@zauru-sdk/services 6.12.0 → 6.14.0

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,10 +1,34 @@
1
- import { AsyncLocalStorage } from "node:async_hooks";
2
1
  import { bindHttpClientPolicyRuntime, getHttpClientPolicy, httpTimeoutMsForClient, isRetryableHttpError, } from "@zauru-sdk/common";
3
- const als = new AsyncLocalStorage();
4
- bindHttpClientPolicyRuntime({
5
- get: () => als.getStore(),
6
- run: (policy, fn) => als.run(policy, fn),
7
- });
2
+ /**
3
+ * Bind Node ALS without a static `node:async_hooks` import. Vite's client
4
+ * bundle stubs that builtin as `__vite-browser-external` and fails named
5
+ * exports. `process.getBuiltinModule` is runtime-only (Node 20.16+/22+).
6
+ * Older Node and the browser keep common's fallback store.
7
+ */
8
+ function tryBindNodeAls() {
9
+ const processRef = globalThis.process;
10
+ if (!processRef?.versions?.node ||
11
+ typeof processRef.getBuiltinModule !== "function") {
12
+ return;
13
+ }
14
+ try {
15
+ const hooks = processRef.getBuiltinModule("async_hooks") ??
16
+ processRef.getBuiltinModule("node:async_hooks");
17
+ const AsyncLocalStorage = hooks?.AsyncLocalStorage;
18
+ if (!AsyncLocalStorage) {
19
+ return;
20
+ }
21
+ const als = new AsyncLocalStorage();
22
+ bindHttpClientPolicyRuntime({
23
+ get: () => als.getStore(),
24
+ run: (policy, fn) => als.run(policy, fn),
25
+ });
26
+ }
27
+ catch {
28
+ // Keep common's in-process fallback.
29
+ }
30
+ }
31
+ tryBindNodeAls();
8
32
  export function applyHttpClientTimeout(request, client) {
9
33
  if (request.timeout != null && request.timeout > 0) {
10
34
  return request;
@@ -23,9 +23,9 @@ export const createDischarge = async (session, headers, body) => {
23
23
  */
24
24
  export const generateDischargePDF = async (headers, session, body) => {
25
25
  return handlePossibleAxiosErrors(async () => {
26
- const { consolidated_template_id } = await getVariablesByName(headers, session, ["consolidated_template_id"]);
27
- body.print_template = consolidated_template_id;
28
- const response = await httpZauru.post("/purchases/consolidates/gen_print_all.json", body, { headers });
26
+ const { discharge_template_id } = await getVariablesByName(headers, session, ["discharge_template_id"]);
27
+ body.print_template = discharge_template_id;
28
+ const response = await httpZauru.post("/purchases/discharges/gen_print_all.json", body, { headers });
29
29
  return response.data;
30
30
  });
31
31
  };
@@ -37,7 +37,7 @@ export const generateDischargePDF = async (headers, session, body) => {
37
37
  */
38
38
  export const getDischargePDFResult = async (headers, zid) => {
39
39
  return handlePossibleAxiosErrors(async () => {
40
- const response = await httpZauru.get("purchases/consolidates/check_print_all", {
40
+ const response = await httpZauru.get("purchases/discharges/check_print_all", {
41
41
  headers,
42
42
  params: { zid },
43
43
  });
@@ -2,6 +2,7 @@ import { handlePossibleAxiosErrors } from "@zauru-sdk/common";
2
2
  import { httpGraphQLAPI } from "./httpGraphQL.js";
3
3
  import { getGraphQLAPIHeaders } from "../common.js";
4
4
  import { getPrintTemplatesStringQuery } from "@zauru-sdk/graphql";
5
+ import { httpZauru } from "./httpZauru.js";
5
6
  /**
6
7
  * getPayees
7
8
  * @param headers
@@ -18,3 +19,27 @@ export async function getPrintTemplates(session) {
18
19
  return response.data?.data.print_templates;
19
20
  });
20
21
  }
22
+ export const getPrintTemplate = async (headers, id) => {
23
+ return handlePossibleAxiosErrors(async () => {
24
+ const response = await httpZauru.get(`/settings/templates/print_templates/${id}.json`, { headers });
25
+ return response.data;
26
+ });
27
+ };
28
+ export const createPrintTemplate = async (headers, body) => {
29
+ return handlePossibleAxiosErrors(async () => {
30
+ const response = await httpZauru.post(`/settings/templates/print_templates.json`, { print_template: body }, { headers });
31
+ return response.data;
32
+ });
33
+ };
34
+ export const updatePrintTemplate = async (headers, id, body) => {
35
+ return handlePossibleAxiosErrors(async () => {
36
+ const response = await httpZauru.patch(`/settings/templates/print_templates/${id}.json`, { print_template: body }, { headers });
37
+ return response.data;
38
+ });
39
+ };
40
+ export const createDocumentPrint = async (headers, body) => {
41
+ return handlePossibleAxiosErrors(async () => {
42
+ const response = await httpZauru.post(`/settings/templates/document_prints.json`, { document_print: body }, { headers });
43
+ return response.data;
44
+ });
45
+ };
@@ -1,8 +1,12 @@
1
1
  import type { Session } from "@remix-run/node";
2
- import { AxiosUtilsResponse, PrintTemplateGraphQL } from "@zauru-sdk/types";
2
+ import { AxiosUtilsResponse, DocumentPrint, NewDocumentPrintBody, NewPrintTemplateBody, PrintTemplate, PrintTemplateGraphQL } from "@zauru-sdk/types";
3
3
  /**
4
4
  * getPayees
5
5
  * @param headers
6
6
  * @returns
7
7
  */
8
8
  export declare function getPrintTemplates(session: Session): Promise<AxiosUtilsResponse<PrintTemplateGraphQL[]>>;
9
+ export declare const getPrintTemplate: (headers: any, id: number | string) => Promise<AxiosUtilsResponse<PrintTemplate>>;
10
+ export declare const createPrintTemplate: (headers: any, body: NewPrintTemplateBody) => Promise<AxiosUtilsResponse<PrintTemplate>>;
11
+ export declare const updatePrintTemplate: (headers: any, id: number | string, body: Partial<NewPrintTemplateBody>) => Promise<AxiosUtilsResponse<PrintTemplate>>;
12
+ export declare const createDocumentPrint: (headers: any, body: NewDocumentPrintBody) => Promise<AxiosUtilsResponse<DocumentPrint>>;
@@ -12,6 +12,7 @@ export declare function getShipments(session: Session, config: {
12
12
  id_number_not_null?: boolean;
13
13
  id_number_not_empty?: boolean;
14
14
  withMovementLots?: boolean;
15
+ withMovements?: boolean;
15
16
  memoILike?: string;
16
17
  voided?: boolean;
17
18
  delivered?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zauru-sdk/services",
3
- "version": "6.12.0",
3
+ "version": "6.14.0",
4
4
  "description": "Servicios de consulta a Zauru",
5
5
  "main": "./dist/esm/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -13,7 +13,7 @@
13
13
  "scripts": {
14
14
  "build": "npm run build:esm",
15
15
  "build:esm": "tsc -p tsconfig.esm.json",
16
- "test": "echo \"Error: no test specified\" && exit 1"
16
+ "test": "tsx --test src/zauru/*.test.ts"
17
17
  },
18
18
  "files": [
19
19
  "dist"
@@ -21,6 +21,7 @@
21
21
  "author": "Oscar Cuéllar",
22
22
  "license": "MIT",
23
23
  "devDependencies": {
24
+ "tsx": "^4.23.15",
24
25
  "typescript": "^5.1.6"
25
26
  },
26
27
  "dependencies": {
@@ -28,11 +29,11 @@
28
29
  "@upstash/redis": "^1.34.5",
29
30
  "@zauru-sdk/common": "^6.10.0",
30
31
  "@zauru-sdk/config": "^6.0.0",
31
- "@zauru-sdk/graphql": "^6.8.0",
32
- "@zauru-sdk/types": "^6.24.0",
32
+ "@zauru-sdk/graphql": "^6.9.0",
33
+ "@zauru-sdk/types": "^6.25.0",
33
34
  "axios": "^1.6.7",
34
35
  "chalk": "5.3.0",
35
36
  "moment": "^2.30.1"
36
37
  },
37
- "gitHead": "8df8d97cb33e23e09198c617a95cffdff96cd05b"
38
+ "gitHead": "d730b568712c88b6e62f9113630c24c6bff5cb7d"
38
39
  }