@zauru-sdk/graphql 6.6.0 → 6.8.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.
- package/dist/GraphQL.queries.d.ts +11 -2
- package/dist/esm/GraphQL.queries.js +56 -14
- package/package.json +2 -2
|
@@ -87,11 +87,20 @@ export type GetWebAppRowsByTableIdOptions = {
|
|
|
87
87
|
/**
|
|
88
88
|
* JSONB `_contains` filters against `webapp_rows.data`.
|
|
89
89
|
* Multiple keys are AND-ed. An array value becomes an OR of `_contains`.
|
|
90
|
+
* Numeric scalars also match the string form (`1` or `"1"`), because JSONB is typed.
|
|
90
91
|
*/
|
|
91
92
|
data?: Record<string, WebAppRowDataFilterValue>;
|
|
93
|
+
/**
|
|
94
|
+
* Filter the row timestamp (`webapp_rows.created_at`), not `data`.
|
|
95
|
+
* Values are GraphQL string literals (`YYYY-MM-DD` or ISO-8601).
|
|
96
|
+
*/
|
|
97
|
+
createdAt?: {
|
|
98
|
+
gte?: string;
|
|
99
|
+
lte?: string;
|
|
100
|
+
lt?: string;
|
|
101
|
+
};
|
|
92
102
|
};
|
|
93
|
-
export declare const
|
|
94
|
-
export declare const getWebAppRowsByWebAppTableIdStringQuery: (webapp_table_id: number, limitOrOptions?: number | GetWebAppRowsByTableIdOptions) => string;
|
|
103
|
+
export declare const getWebAppRowsByWebAppTableIdStringQuery: (webapp_table_id: number, options?: GetWebAppRowsByTableIdOptions) => string;
|
|
95
104
|
export declare const getPayeeCategoryByIdStringQuery: (id: number) => string;
|
|
96
105
|
export declare const getPayeeCategoriesByNotesMatchStringQuery: (match: string) => string;
|
|
97
106
|
export declare const getPayeeCategoriesStringQuery = "\nquery getPayeeCategories {\n payee_categories {\n id\n name\n notes\n payees_count\n price_list_id\n }\n}\n";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getCasesStringQuery = exports.getInvoicesByAgencyIdStringQuery = exports.getPaymentTermByIdStringQuery = exports.getPaymentMethodsStringQuery = exports.getPaymentTermsStringQuery = exports.getSuggestedPricesStringQuery = exports.getCurrenciesStringQuery = exports.getInvoiceFormSubmissionsByInvoiceIdStringQuery = exports.getCaseFormSubmissionsByCaseIdStringQuery = exports.getLastInvoiceFormSubmissionStringQuery = exports.getInvoiceFormSubmissionsByAgencyIdStringQuery = exports.getFormSubmissionByIdStringQuery = exports.getMyCaseFormSubmissionsStringQuery = exports.getFormsByDocumentTypeStringQuery = exports.getFormsStringQuery = exports.getFormByNameStringQuery = exports.getAllFormsStringQuery = exports.getItemByNameStringQuery = exports.getBundleByNameStringQuery = exports.getBundlesByItemCategoryIdStringQuery = exports.getEmployeesByAgencyIdStringQuery = exports.getEmployeesStringQuery = exports.getEmployeeProfileStringQuery = exports.getConsolidatesBetweenDatesStringQuery = exports.getItemsBySuperCategoryStringQuery = exports.getItemsStringQuery = exports.getItemsByCategoryStringQuery = exports.getItemCategoryByIdStringQuery = exports.getSuperCategoryByIdStringQuery = exports.getPayeeByIdStringQuery = exports.getClientCategoriesStringQuery = exports.getProviderCategoriesStringQuery = exports.getPayeeCategoriesStringQuery = exports.getPayeeCategoriesByNotesMatchStringQuery = exports.getPayeeCategoryByIdStringQuery = exports.getWebAppRowsByWebAppTableIdStringQuery = exports.
|
|
4
|
-
exports.getProductionWorkOrderStringQuery =
|
|
3
|
+
exports.getPrintTemplatesStringQuery = exports.getCasesStringQuery = exports.getInvoicesByAgencyIdStringQuery = exports.getPaymentTermByIdStringQuery = exports.getPaymentMethodsStringQuery = exports.getPaymentTermsStringQuery = exports.getSuggestedPricesStringQuery = exports.getCurrenciesStringQuery = exports.getInvoiceFormSubmissionsByInvoiceIdStringQuery = exports.getCaseFormSubmissionsByCaseIdStringQuery = exports.getLastInvoiceFormSubmissionStringQuery = exports.getInvoiceFormSubmissionsByAgencyIdStringQuery = exports.getFormSubmissionByIdStringQuery = exports.getMyCaseFormSubmissionsStringQuery = exports.getFormsByDocumentTypeStringQuery = exports.getFormsStringQuery = exports.getFormByNameStringQuery = exports.getAllFormsStringQuery = exports.getItemByNameStringQuery = exports.getBundleByNameStringQuery = exports.getBundlesByItemCategoryIdStringQuery = exports.getEmployeesByAgencyIdStringQuery = exports.getEmployeesStringQuery = exports.getEmployeeProfileStringQuery = exports.getConsolidatesBetweenDatesStringQuery = exports.getItemsBySuperCategoryStringQuery = exports.getItemsStringQuery = exports.getItemsByCategoryStringQuery = exports.getItemCategoryByIdStringQuery = exports.getSuperCategoryByIdStringQuery = exports.getPayeeByIdStringQuery = exports.getClientCategoriesStringQuery = exports.getProviderCategoriesStringQuery = exports.getPayeeCategoriesStringQuery = exports.getPayeeCategoriesByNotesMatchStringQuery = exports.getPayeeCategoryByIdStringQuery = exports.getWebAppRowsByWebAppTableIdStringQuery = exports.getWebAppRowStringQuery = exports.getAgenciesStringQuery = exports.getProvidersStringQuery = exports.getPayeesStringQuery = exports.getPurchaseOrdersBetweenDatesStringQuery = exports.getSerialsStringQuery = exports.getLotStocksByAgencyIdStringQuery = exports.getLotsByNameStringQuery = exports.getBookingByPurchaseOrderAndReferenceStringQuery = exports.getShipmentsStringQuery = exports.getPurchaseOrderStringQuery = exports.getPurchaseOrderByIdNumberStringQuery = exports.getLast100ReceptionsStringQuery = void 0;
|
|
4
|
+
exports.getProductionWorkOrderStringQuery = void 0;
|
|
5
5
|
const getLast100ReceptionsStringQuery = (agency_id) => {
|
|
6
6
|
const conditions = ["voided: {_eq: false}"];
|
|
7
7
|
if (agency_id) {
|
|
@@ -677,13 +677,7 @@ query getWebAppRow {
|
|
|
677
677
|
`;
|
|
678
678
|
exports.getWebAppRowStringQuery = getWebAppRowStringQuery;
|
|
679
679
|
const GRAPHQL_NAME_RE = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
680
|
-
const
|
|
681
|
-
if (typeof limitOrOptions === "number") {
|
|
682
|
-
return { limit: limitOrOptions };
|
|
683
|
-
}
|
|
684
|
-
return limitOrOptions ?? {};
|
|
685
|
-
};
|
|
686
|
-
exports.toGetWebAppRowsByTableIdOptions = toGetWebAppRowsByTableIdOptions;
|
|
680
|
+
const GRAPHQL_TIMESTAMP_RE = /^\d{4}-\d{2}-\d{2}(T\d{2}:\d{2}(:\d{2}(\.\d+)?)?(Z|[+-]\d{2}:\d{2})?)?$/;
|
|
687
681
|
const serializeGraphQLLiteral = (value) => {
|
|
688
682
|
if (value === null) {
|
|
689
683
|
return "null";
|
|
@@ -705,6 +699,28 @@ const buildDataContainsClause = (key, value) => {
|
|
|
705
699
|
}
|
|
706
700
|
return `{ data: { _contains: { ${key}: ${serializeGraphQLLiteral(value)} } } }`;
|
|
707
701
|
};
|
|
702
|
+
const expandJsonbContainsValue = (value) => {
|
|
703
|
+
if (typeof value === "number" && Number.isFinite(value)) {
|
|
704
|
+
return [value, String(value)];
|
|
705
|
+
}
|
|
706
|
+
if (typeof value === "string" && value !== "" && Number.isFinite(Number(value))) {
|
|
707
|
+
return [Number(value), value];
|
|
708
|
+
}
|
|
709
|
+
return [value];
|
|
710
|
+
};
|
|
711
|
+
const uniqueJsonbContainsValues = (values) => {
|
|
712
|
+
const seen = new Set();
|
|
713
|
+
const unique = [];
|
|
714
|
+
for (const value of values) {
|
|
715
|
+
const identity = `${typeof value}:${String(value)}`;
|
|
716
|
+
if (seen.has(identity)) {
|
|
717
|
+
continue;
|
|
718
|
+
}
|
|
719
|
+
seen.add(identity);
|
|
720
|
+
unique.push(value);
|
|
721
|
+
}
|
|
722
|
+
return unique;
|
|
723
|
+
};
|
|
708
724
|
const buildDataFilterAndClauses = (data) => {
|
|
709
725
|
if (!data) {
|
|
710
726
|
return [];
|
|
@@ -714,7 +730,7 @@ const buildDataFilterAndClauses = (data) => {
|
|
|
714
730
|
if (raw === undefined) {
|
|
715
731
|
continue;
|
|
716
732
|
}
|
|
717
|
-
const values = Array.isArray(raw) ? raw : [raw];
|
|
733
|
+
const values = uniqueJsonbContainsValues((Array.isArray(raw) ? raw : [raw]).flatMap(expandJsonbContainsValue));
|
|
718
734
|
if (values.length === 0) {
|
|
719
735
|
continue;
|
|
720
736
|
}
|
|
@@ -728,21 +744,47 @@ const buildDataFilterAndClauses = (data) => {
|
|
|
728
744
|
}
|
|
729
745
|
return andParts;
|
|
730
746
|
};
|
|
731
|
-
const
|
|
732
|
-
|
|
747
|
+
const serializeGraphQLTimestamp = (value, bound) => {
|
|
748
|
+
if (!GRAPHQL_TIMESTAMP_RE.test(value)) {
|
|
749
|
+
throw new Error(`Invalid webapp row created_at ${bound}: ${value}`);
|
|
750
|
+
}
|
|
751
|
+
return JSON.stringify(value);
|
|
752
|
+
};
|
|
753
|
+
const buildCreatedAtClause = (createdAt) => {
|
|
754
|
+
if (!createdAt) {
|
|
755
|
+
return "";
|
|
756
|
+
}
|
|
757
|
+
const bounds = [];
|
|
758
|
+
if (createdAt.gte) {
|
|
759
|
+
bounds.push(`_gte: ${serializeGraphQLTimestamp(createdAt.gte, "gte")}`);
|
|
760
|
+
}
|
|
761
|
+
if (createdAt.lte) {
|
|
762
|
+
bounds.push(`_lte: ${serializeGraphQLTimestamp(createdAt.lte, "lte")}`);
|
|
763
|
+
}
|
|
764
|
+
if (createdAt.lt) {
|
|
765
|
+
bounds.push(`_lt: ${serializeGraphQLTimestamp(createdAt.lt, "lt")}`);
|
|
766
|
+
}
|
|
767
|
+
return bounds.length ? `created_at: { ${bounds.join(", ")} }` : "";
|
|
768
|
+
};
|
|
769
|
+
const getWebAppRowsByWebAppTableIdStringQuery = (webapp_table_id, options) => {
|
|
770
|
+
const { limit, data, createdAt } = options ?? {};
|
|
733
771
|
const tableId = Number(webapp_table_id);
|
|
734
772
|
const conditions = [];
|
|
735
773
|
if (tableId) {
|
|
736
774
|
conditions.push(`webapp_table_id: {_eq: ${tableId}}`);
|
|
737
775
|
}
|
|
738
|
-
const
|
|
776
|
+
const createdAtClause = buildCreatedAtClause(createdAt);
|
|
777
|
+
if (createdAtClause) {
|
|
778
|
+
conditions.push(createdAtClause);
|
|
779
|
+
}
|
|
780
|
+
const dataAnd = buildDataFilterAndClauses(data);
|
|
739
781
|
if (dataAnd.length > 0) {
|
|
740
782
|
conditions.push(`_and: [${dataAnd.join(", ")}]`);
|
|
741
783
|
}
|
|
742
784
|
const whereClause = conditions.length
|
|
743
785
|
? `where: { ${conditions.join(", ")} }`
|
|
744
786
|
: "";
|
|
745
|
-
const limitClause =
|
|
787
|
+
const limitClause = limit ? `limit: ${Number(limit)}` : "";
|
|
746
788
|
const orderByClause = `order_by: { id: desc }`;
|
|
747
789
|
return `
|
|
748
790
|
query getWebAppRowsByWebAppTableId {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zauru-sdk/graphql",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.8.0",
|
|
4
4
|
"description": "Queries de uso común para las aplicación de Zauru.",
|
|
5
5
|
"main": "./dist/esm/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -22,5 +22,5 @@
|
|
|
22
22
|
"devDependencies": {
|
|
23
23
|
"typescript": "^5.1.6"
|
|
24
24
|
},
|
|
25
|
-
"gitHead": "
|
|
25
|
+
"gitHead": "a5b35540efd2b3395e05ea0182c97d78f059c3c4"
|
|
26
26
|
}
|