@zauru-sdk/services 1.0.52 → 1.0.60
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.
- package/LICENCE.md +11 -11
- package/dist/cjs/zauru/zauru-forms.js +36 -1
- package/dist/esm/zauru/zauru-forms.js +34 -1
- package/dist/zauru/zauru-forms.d.ts +7 -0
- package/dist/zauru/zauru-lotes.d.ts +0 -20
- package/package.json +6 -6
package/LICENCE.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
# Released under MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2013 Mark Otto.
|
|
4
|
-
|
|
5
|
-
Copyright (c) 2017 Andrew Fong.
|
|
6
|
-
|
|
7
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
8
|
-
|
|
9
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
10
|
-
|
|
11
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
1
|
+
# Released under MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2013 Mark Otto.
|
|
4
|
+
|
|
5
|
+
Copyright (c) 2017 Andrew Fong.
|
|
6
|
+
|
|
7
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
8
|
+
|
|
9
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
10
|
+
|
|
11
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.deleteFormSubmission = exports.updateSubmissionInvoiceFormSubmission = exports.createFormSubmission = exports.updateForm = exports.deleteForm = exports.createForm = exports.getInvoiceFormSubmissionsByInvoiceId = exports.getLastInvoiceFormSubmission = exports.getMyCaseFormSubmissions = exports.getInvoiceFormSubmissionsByAgencyId = exports.getFormSubmissionById = exports.getFormsByDocumentType = exports.getFormByName = exports.getForms = void 0;
|
|
6
|
+
exports.deleteFormSubmission = exports.updateSubmissionInvoiceFormSubmission = exports.createFormSubmission = exports.updateForm = exports.deleteForm = exports.createForm = exports.getFormSubmissionAPIZauru = exports.getInvoiceFormSubmissionsByInvoiceId = exports.getLastInvoiceFormSubmission = exports.getMyCaseFormSubmissions = exports.getInvoiceFormSubmissionsByAgencyId = exports.getFormSubmissionById = exports.getFormsByDocumentType = exports.getAllForms = exports.getFormByName = exports.getForms = void 0;
|
|
7
7
|
const common_1 = require("@zauru-sdk/common");
|
|
8
8
|
const common_js_1 = require("../common.js");
|
|
9
9
|
const httpGraphQL_js_1 = __importDefault(require("./httpGraphQL.js"));
|
|
@@ -49,6 +49,34 @@ async function getFormByName(session, name) {
|
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
51
|
exports.getFormByName = getFormByName;
|
|
52
|
+
/**
|
|
53
|
+
* getAllForms
|
|
54
|
+
*/
|
|
55
|
+
async function getAllForms(session, filters = { withSubmissions: false }) {
|
|
56
|
+
return (0, common_1.handlePossibleAxiosErrors)(async () => {
|
|
57
|
+
const headers = await (0, common_js_1.getGraphQLAPIHeaders)(session);
|
|
58
|
+
const response = await httpGraphQL_js_1.default.post("", {
|
|
59
|
+
query: (0, graphql_1.getAllFormsStringQuery)({
|
|
60
|
+
withSubmissions: filters.withSubmissions,
|
|
61
|
+
}),
|
|
62
|
+
}, { headers });
|
|
63
|
+
if (response.data.errors) {
|
|
64
|
+
throw new Error(response.data.errors.map((x) => x.message).join(";"));
|
|
65
|
+
}
|
|
66
|
+
const registers = response?.data?.data?.settings_forms;
|
|
67
|
+
// Filtrar los registros para obtener sólo los de la versión más alta.
|
|
68
|
+
const groupedByVersion = registers.reduce((acc, record) => {
|
|
69
|
+
const zid = record.zid;
|
|
70
|
+
if (!acc[zid]) {
|
|
71
|
+
acc[zid] = record;
|
|
72
|
+
}
|
|
73
|
+
return acc;
|
|
74
|
+
}, {});
|
|
75
|
+
const latestVersionRecords = Object.values(groupedByVersion).reverse();
|
|
76
|
+
return latestVersionRecords;
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
exports.getAllForms = getAllForms;
|
|
52
80
|
/**
|
|
53
81
|
* getFormsByDocumentType
|
|
54
82
|
*/
|
|
@@ -256,6 +284,13 @@ async function getInvoiceFormSubmissionsByInvoiceId(session, invoice_id, filters
|
|
|
256
284
|
});
|
|
257
285
|
}
|
|
258
286
|
exports.getInvoiceFormSubmissionsByInvoiceId = getInvoiceFormSubmissionsByInvoiceId;
|
|
287
|
+
const getFormSubmissionAPIZauru = async (headers, id) => {
|
|
288
|
+
return (0, common_1.handlePossibleAxiosErrors)(async () => {
|
|
289
|
+
const responseZauru = await httpZauru_js_1.default.get(`/settings/forms/form_submissions/${id}.json`, { headers });
|
|
290
|
+
return responseZauru.data;
|
|
291
|
+
});
|
|
292
|
+
};
|
|
293
|
+
exports.getFormSubmissionAPIZauru = getFormSubmissionAPIZauru;
|
|
259
294
|
/**
|
|
260
295
|
* createForm
|
|
261
296
|
* @param headers
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { arrayToObject, convertToFormData, handlePossibleAxiosErrors, } from "@zauru-sdk/common";
|
|
2
2
|
import { getGraphQLAPIHeaders } from "../common.js";
|
|
3
3
|
import httpGraphQLAPI from "./httpGraphQL.js";
|
|
4
|
-
import { getFormByNameStringQuery, getFormSubmissionByIdStringQuery, getFormsByDocumentTypeStringQuery, getFormsStringQuery, getInvoiceFormSubmissionsByAgencyIdStringQuery, getInvoiceFormSubmissionsByInvoiceIdStringQuery, getLastInvoiceFormSubmissionStringQuery, getMyCaseFormSubmissionsStringQuery, } from "@zauru-sdk/graphql";
|
|
4
|
+
import { getAllFormsStringQuery, getFormByNameStringQuery, getFormSubmissionByIdStringQuery, getFormsByDocumentTypeStringQuery, getFormsStringQuery, getInvoiceFormSubmissionsByAgencyIdStringQuery, getInvoiceFormSubmissionsByInvoiceIdStringQuery, getLastInvoiceFormSubmissionStringQuery, getMyCaseFormSubmissionsStringQuery, } from "@zauru-sdk/graphql";
|
|
5
5
|
import httpZauru from "./httpZauru.js";
|
|
6
6
|
/**
|
|
7
7
|
* getForms
|
|
@@ -41,6 +41,33 @@ export async function getFormByName(session, name) {
|
|
|
41
41
|
return register;
|
|
42
42
|
});
|
|
43
43
|
}
|
|
44
|
+
/**
|
|
45
|
+
* getAllForms
|
|
46
|
+
*/
|
|
47
|
+
export async function getAllForms(session, filters = { withSubmissions: false }) {
|
|
48
|
+
return handlePossibleAxiosErrors(async () => {
|
|
49
|
+
const headers = await getGraphQLAPIHeaders(session);
|
|
50
|
+
const response = await httpGraphQLAPI.post("", {
|
|
51
|
+
query: getAllFormsStringQuery({
|
|
52
|
+
withSubmissions: filters.withSubmissions,
|
|
53
|
+
}),
|
|
54
|
+
}, { headers });
|
|
55
|
+
if (response.data.errors) {
|
|
56
|
+
throw new Error(response.data.errors.map((x) => x.message).join(";"));
|
|
57
|
+
}
|
|
58
|
+
const registers = response?.data?.data?.settings_forms;
|
|
59
|
+
// Filtrar los registros para obtener sólo los de la versión más alta.
|
|
60
|
+
const groupedByVersion = registers.reduce((acc, record) => {
|
|
61
|
+
const zid = record.zid;
|
|
62
|
+
if (!acc[zid]) {
|
|
63
|
+
acc[zid] = record;
|
|
64
|
+
}
|
|
65
|
+
return acc;
|
|
66
|
+
}, {});
|
|
67
|
+
const latestVersionRecords = Object.values(groupedByVersion).reverse();
|
|
68
|
+
return latestVersionRecords;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
44
71
|
/**
|
|
45
72
|
* getFormsByDocumentType
|
|
46
73
|
*/
|
|
@@ -242,6 +269,12 @@ export async function getInvoiceFormSubmissionsByInvoiceId(session, invoice_id,
|
|
|
242
269
|
return latestVersionRecords;
|
|
243
270
|
});
|
|
244
271
|
}
|
|
272
|
+
export const getFormSubmissionAPIZauru = async (headers, id) => {
|
|
273
|
+
return handlePossibleAxiosErrors(async () => {
|
|
274
|
+
const responseZauru = await httpZauru.get(`/settings/forms/form_submissions/${id}.json`, { headers });
|
|
275
|
+
return responseZauru.data;
|
|
276
|
+
});
|
|
277
|
+
};
|
|
245
278
|
/**
|
|
246
279
|
* createForm
|
|
247
280
|
* @param headers
|
|
@@ -8,6 +8,12 @@ export declare function getForms(session: Session): Promise<AxiosUtilsResponse<F
|
|
|
8
8
|
* getFormByName
|
|
9
9
|
*/
|
|
10
10
|
export declare function getFormByName(session: Session, name: string): Promise<AxiosUtilsResponse<FormGraphQL>>;
|
|
11
|
+
/**
|
|
12
|
+
* getAllForms
|
|
13
|
+
*/
|
|
14
|
+
export declare function getAllForms(session: Session, filters?: {
|
|
15
|
+
withSubmissions: boolean;
|
|
16
|
+
}): Promise<AxiosUtilsResponse<FormGraphQL[]>>;
|
|
11
17
|
/**
|
|
12
18
|
* getFormsByDocumentType
|
|
13
19
|
*/
|
|
@@ -56,6 +62,7 @@ export declare function getLastInvoiceFormSubmission(session: Session, filters?:
|
|
|
56
62
|
export declare function getInvoiceFormSubmissionsByInvoiceId(session: Session, invoice_id: string, filters?: {
|
|
57
63
|
formZid?: number;
|
|
58
64
|
}): Promise<AxiosUtilsResponse<SubmissionInvoicesGraphQL[]>>;
|
|
65
|
+
export declare const getFormSubmissionAPIZauru: (headers: any, id: number | string) => Promise<AxiosUtilsResponse<any>>;
|
|
59
66
|
/**
|
|
60
67
|
* createForm
|
|
61
68
|
* @param headers
|
|
@@ -15,16 +15,6 @@ export declare const getBasketsLots: (headers: any, session: Session) => Promise
|
|
|
15
15
|
* @returns
|
|
16
16
|
*/
|
|
17
17
|
export declare const retenerLote: (headers: any, session: Session, lot_id: string, lot_name: string) => Promise<{
|
|
18
|
-
/**
|
|
19
|
-
*
|
|
20
|
-
* @param headers
|
|
21
|
-
* @param agency_id
|
|
22
|
-
* @param basket_id
|
|
23
|
-
* @param orders
|
|
24
|
-
* @param desde
|
|
25
|
-
* @param hasta
|
|
26
|
-
* @returns
|
|
27
|
-
*/
|
|
28
18
|
Nombre: string;
|
|
29
19
|
}>;
|
|
30
20
|
/**
|
|
@@ -35,16 +25,6 @@ export declare const retenerLote: (headers: any, session: Session, lot_id: strin
|
|
|
35
25
|
* @returns
|
|
36
26
|
*/
|
|
37
27
|
export declare const liberarLote: (headers: any, session: Session, lot_id: string, lot_name: string) => Promise<{
|
|
38
|
-
/**
|
|
39
|
-
*
|
|
40
|
-
* @param headers
|
|
41
|
-
* @param agency_id
|
|
42
|
-
* @param basket_id
|
|
43
|
-
* @param orders
|
|
44
|
-
* @param desde
|
|
45
|
-
* @param hasta
|
|
46
|
-
* @returns
|
|
47
|
-
*/
|
|
48
28
|
Nombre: string;
|
|
49
29
|
}>;
|
|
50
30
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zauru-sdk/services",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.60",
|
|
4
4
|
"description": "Servicios de consulta a Zauru",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -25,12 +25,12 @@
|
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
27
|
"@remix-run/node": "^2.8.1",
|
|
28
|
-
"@zauru-sdk/common": "^1.0.
|
|
29
|
-
"@zauru-sdk/config": "^1.0.
|
|
30
|
-
"@zauru-sdk/graphql": "^1.0.
|
|
31
|
-
"@zauru-sdk/types": "^1.0.
|
|
28
|
+
"@zauru-sdk/common": "^1.0.60",
|
|
29
|
+
"@zauru-sdk/config": "^1.0.60",
|
|
30
|
+
"@zauru-sdk/graphql": "^1.0.60",
|
|
31
|
+
"@zauru-sdk/types": "^1.0.60",
|
|
32
32
|
"axios": "^1.6.7",
|
|
33
33
|
"chalk": "5.3.0"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "8f9219bf94b9171f79ba4d5ddcab512d2715f314"
|
|
36
36
|
}
|