@ehrenkind/shopify-lib 0.0.7 → 0.2.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/README.md +2 -34
- package/dist/generated-api-types/2025-04/admin.generated.d.ts +283 -0
- package/dist/generated-api-types/2025-04/admin.generated.d.ts.map +1 -0
- package/dist/generated-api-types/2025-04/admin.generated.js +5 -0
- package/dist/generated-api-types/2025-04/admin.generated.js.map +1 -0
- package/dist/generated-api-types/2025-04/admin.types.d.ts +60044 -0
- package/dist/generated-api-types/2025-04/admin.types.d.ts.map +1 -0
- package/dist/generated-api-types/2025-04/admin.types.js +11451 -0
- package/dist/generated-api-types/2025-04/admin.types.js.map +1 -0
- package/dist/index.cjs +370 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +328 -58
- package/dist/index.d.ts +6 -18874
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +368 -41
- package/dist/index.mjs.map +1 -1
- package/dist/mutations/customers/deleteCustomerById.d.ts +4 -0
- package/dist/mutations/customers/deleteCustomerById.d.ts.map +1 -0
- package/dist/mutations/customers/deleteCustomerById.js +38 -0
- package/dist/mutations/customers/deleteCustomerById.js.map +1 -0
- package/dist/mutations/customers/deleteCustomerById.mock.d.ts +4 -0
- package/dist/mutations/customers/deleteCustomerById.mock.d.ts.map +1 -0
- package/dist/mutations/customers/deleteCustomerById.mock.js +8 -0
- package/dist/mutations/customers/deleteCustomerById.mock.js.map +1 -0
- package/dist/mutations/customers/deleteCustomerById.test.d.ts +2 -0
- package/dist/mutations/customers/deleteCustomerById.test.d.ts.map +1 -0
- package/dist/mutations/customers/deleteCustomerById.test.js +10 -0
- package/dist/mutations/customers/deleteCustomerById.test.js.map +1 -0
- package/dist/mutations/productVariantsBulkUpdate/connectMetaObjectToProductVariant.d.ts +4 -0
- package/dist/mutations/productVariantsBulkUpdate/connectMetaObjectToProductVariant.d.ts.map +1 -0
- package/dist/mutations/productVariantsBulkUpdate/connectMetaObjectToProductVariant.js +56 -0
- package/dist/mutations/productVariantsBulkUpdate/connectMetaObjectToProductVariant.js.map +1 -0
- package/dist/mutations/productVariantsBulkUpdate/connectMetaObjectToProductVariant.mock.d.ts +3 -0
- package/dist/mutations/productVariantsBulkUpdate/connectMetaObjectToProductVariant.mock.d.ts.map +1 -0
- package/dist/mutations/productVariantsBulkUpdate/connectMetaObjectToProductVariant.mock.js +11 -0
- package/dist/mutations/productVariantsBulkUpdate/connectMetaObjectToProductVariant.mock.js.map +1 -0
- package/dist/mutations/productVariantsBulkUpdate/connectMetaObjectToProductVariant.test.d.ts +2 -0
- package/dist/mutations/productVariantsBulkUpdate/connectMetaObjectToProductVariant.test.d.ts.map +1 -0
- package/dist/mutations/productVariantsBulkUpdate/connectMetaObjectToProductVariant.test.js +11 -0
- package/dist/mutations/productVariantsBulkUpdate/connectMetaObjectToProductVariant.test.js.map +1 -0
- package/dist/queries/orders/getOrderById.d.ts +136 -0
- package/dist/queries/orders/getOrderById.d.ts.map +1 -0
- package/dist/queries/orders/getOrderById.js +125 -0
- package/dist/queries/orders/getOrderById.js.map +1 -0
- package/dist/queries/orders/getOrderById.mock.d.ts +82 -0
- package/dist/queries/orders/getOrderById.mock.d.ts.map +1 -0
- package/dist/queries/orders/getOrderById.mock.js +204 -0
- package/dist/queries/orders/getOrderById.mock.js.map +1 -0
- package/dist/queries/orders/getOrderById.queries.d.ts +3 -0
- package/dist/queries/orders/getOrderById.queries.d.ts.map +1 -0
- package/dist/queries/orders/getOrderById.queries.js +174 -0
- package/dist/queries/orders/getOrderById.queries.js.map +1 -0
- package/dist/queries/orders/getOrderById.test.d.ts +2 -0
- package/dist/queries/orders/getOrderById.test.d.ts.map +1 -0
- package/dist/queries/orders/getOrderById.test.js +46 -0
- package/dist/queries/orders/getOrderById.test.js.map +1 -0
- package/dist/queries/orders/getOrderByName.d.ts +72 -0
- package/dist/queries/orders/getOrderByName.d.ts.map +1 -0
- package/dist/queries/orders/getOrderByName.js +117 -0
- package/dist/queries/orders/getOrderByName.js.map +1 -0
- package/dist/queries/orders/getOrderByName.mock.d.ts +21 -0
- package/dist/queries/orders/getOrderByName.mock.d.ts.map +1 -0
- package/dist/queries/orders/getOrderByName.mock.js +55 -0
- package/dist/queries/orders/getOrderByName.mock.js.map +1 -0
- package/dist/queries/orders/getOrderByName.queries.d.ts +3 -0
- package/dist/queries/orders/getOrderByName.queries.d.ts.map +1 -0
- package/dist/queries/orders/getOrderByName.queries.js +335 -0
- package/dist/queries/orders/getOrderByName.queries.js.map +1 -0
- package/dist/queries/orders/getOrderByName.test.d.ts +2 -0
- package/dist/queries/orders/getOrderByName.test.d.ts.map +1 -0
- package/dist/queries/orders/getOrderByName.test.js +30 -0
- package/dist/queries/orders/getOrderByName.test.js.map +1 -0
- package/dist/queries/orders/getOrderPaymentDetails.d.ts +130 -0
- package/dist/queries/orders/getOrderPaymentDetails.d.ts.map +1 -0
- package/dist/queries/orders/getOrderPaymentDetails.js +45 -0
- package/dist/queries/orders/getOrderPaymentDetails.js.map +1 -0
- package/dist/queries/orders/getOrderPaymentDetails.mock.d.ts +12 -0
- package/dist/queries/orders/getOrderPaymentDetails.mock.d.ts.map +1 -0
- package/dist/queries/orders/getOrderPaymentDetails.mock.js +24 -0
- package/dist/queries/orders/getOrderPaymentDetails.mock.js.map +1 -0
- package/dist/queries/orders/getOrderPaymentDetails.queries.d.ts +2 -0
- package/dist/queries/orders/getOrderPaymentDetails.queries.d.ts.map +1 -0
- package/dist/queries/orders/getOrderPaymentDetails.queries.js +21 -0
- package/dist/queries/orders/getOrderPaymentDetails.queries.js.map +1 -0
- package/dist/queries/orders/getOrderPaymentDetails.test.d.ts +2 -0
- package/dist/queries/orders/getOrderPaymentDetails.test.d.ts.map +1 -0
- package/dist/queries/orders/getOrderPaymentDetails.test.js +19 -0
- package/dist/queries/orders/getOrderPaymentDetails.test.js.map +1 -0
- package/dist/queries/productVariants/getLeanProductVariants.d.ts +33 -0
- package/dist/queries/productVariants/getLeanProductVariants.d.ts.map +1 -0
- package/dist/queries/productVariants/getLeanProductVariants.js +81 -0
- package/dist/queries/productVariants/getLeanProductVariants.js.map +1 -0
- package/dist/queries/productVariants/getLeanProductVariants.mock.d.ts +3 -0
- package/dist/queries/productVariants/getLeanProductVariants.mock.d.ts.map +1 -0
- package/dist/queries/productVariants/getLeanProductVariants.mock.js +33 -0
- package/dist/queries/productVariants/getLeanProductVariants.mock.js.map +1 -0
- package/dist/queries/productVariants/getLeanProductVariants.test.d.ts +2 -0
- package/dist/queries/productVariants/getLeanProductVariants.test.d.ts.map +1 -0
- package/dist/queries/productVariants/getLeanProductVariants.test.js +38 -0
- package/dist/queries/productVariants/getLeanProductVariants.test.js.map +1 -0
- package/dist/utils/logger.d.ts +11 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +50 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/mswHandlers.d.ts +2 -0
- package/dist/utils/mswHandlers.d.ts.map +1 -0
- package/dist/utils/mswHandlers.js +46 -0
- package/dist/utils/mswHandlers.js.map +1 -0
- package/dist/utils/shopifyClient.d.ts +6 -0
- package/dist/utils/shopifyClient.d.ts.map +1 -0
- package/dist/utils/shopifyClient.js +82 -0
- package/dist/utils/shopifyClient.js.map +1 -0
- package/dist/utils/shopifyClient.mock.d.ts +3 -0
- package/dist/utils/shopifyClient.mock.d.ts.map +1 -0
- package/dist/utils/shopifyClient.mock.js +19 -0
- package/dist/utils/shopifyClient.mock.js.map +1 -0
- package/dist/utils/shopifyClient.test.d.ts +2 -0
- package/dist/utils/shopifyClient.test.d.ts.map +1 -0
- package/dist/utils/shopifyClient.test.js +27 -0
- package/dist/utils/shopifyClient.test.js.map +1 -0
- package/dist/utils/shopifyFetch.d.ts +24 -0
- package/dist/utils/shopifyFetch.d.ts.map +1 -0
- package/dist/utils/shopifyFetch.js +67 -0
- package/dist/utils/shopifyFetch.js.map +1 -0
- package/dist/utils/shopifyFetch.test.d.ts +2 -0
- package/dist/utils/shopifyFetch.test.d.ts.map +1 -0
- package/dist/utils/shopifyFetch.test.js +17 -0
- package/dist/utils/shopifyFetch.test.js.map +1 -0
- package/dist/utils/test-setup.d.ts +2 -0
- package/dist/utils/test-setup.d.ts.map +1 -0
- package/dist/utils/test-setup.js +13 -0
- package/dist/utils/test-setup.js.map +1 -0
- package/dist/utils/zod.d.ts +3 -0
- package/dist/utils/zod.d.ts.map +1 -0
- package/dist/utils/zod.js +19 -0
- package/dist/utils/zod.js.map +1 -0
- package/package.json +8 -5
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
declare const GetOrderPaymentDetailsByIdReturn: z.ZodObject<{
|
|
3
|
+
order: z.ZodObject<{
|
|
4
|
+
transactions: z.ZodArray<z.ZodObject<{
|
|
5
|
+
amountSet: z.ZodObject<{
|
|
6
|
+
shopMoney: z.ZodObject<{
|
|
7
|
+
amount: z.ZodString;
|
|
8
|
+
currencyCode: z.ZodString;
|
|
9
|
+
}, "strip", z.ZodTypeAny, {
|
|
10
|
+
currencyCode: string;
|
|
11
|
+
amount: string;
|
|
12
|
+
}, {
|
|
13
|
+
currencyCode: string;
|
|
14
|
+
amount: string;
|
|
15
|
+
}>;
|
|
16
|
+
}, "strip", z.ZodTypeAny, {
|
|
17
|
+
shopMoney: {
|
|
18
|
+
currencyCode: string;
|
|
19
|
+
amount: string;
|
|
20
|
+
};
|
|
21
|
+
}, {
|
|
22
|
+
shopMoney: {
|
|
23
|
+
currencyCode: string;
|
|
24
|
+
amount: string;
|
|
25
|
+
};
|
|
26
|
+
}>;
|
|
27
|
+
createdAt: z.ZodString;
|
|
28
|
+
gateway: z.ZodString;
|
|
29
|
+
formattedGateway: z.ZodString;
|
|
30
|
+
kind: z.ZodString;
|
|
31
|
+
paymentId: z.ZodString;
|
|
32
|
+
}, "strip", z.ZodTypeAny, {
|
|
33
|
+
createdAt: string;
|
|
34
|
+
gateway: string;
|
|
35
|
+
formattedGateway: string;
|
|
36
|
+
kind: string;
|
|
37
|
+
paymentId: string;
|
|
38
|
+
amountSet: {
|
|
39
|
+
shopMoney: {
|
|
40
|
+
currencyCode: string;
|
|
41
|
+
amount: string;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
}, {
|
|
45
|
+
createdAt: string;
|
|
46
|
+
gateway: string;
|
|
47
|
+
formattedGateway: string;
|
|
48
|
+
kind: string;
|
|
49
|
+
paymentId: string;
|
|
50
|
+
amountSet: {
|
|
51
|
+
shopMoney: {
|
|
52
|
+
currencyCode: string;
|
|
53
|
+
amount: string;
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
}>, "many">;
|
|
57
|
+
}, "strip", z.ZodTypeAny, {
|
|
58
|
+
transactions: {
|
|
59
|
+
createdAt: string;
|
|
60
|
+
gateway: string;
|
|
61
|
+
formattedGateway: string;
|
|
62
|
+
kind: string;
|
|
63
|
+
paymentId: string;
|
|
64
|
+
amountSet: {
|
|
65
|
+
shopMoney: {
|
|
66
|
+
currencyCode: string;
|
|
67
|
+
amount: string;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
}[];
|
|
71
|
+
}, {
|
|
72
|
+
transactions: {
|
|
73
|
+
createdAt: string;
|
|
74
|
+
gateway: string;
|
|
75
|
+
formattedGateway: string;
|
|
76
|
+
kind: string;
|
|
77
|
+
paymentId: string;
|
|
78
|
+
amountSet: {
|
|
79
|
+
shopMoney: {
|
|
80
|
+
currencyCode: string;
|
|
81
|
+
amount: string;
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
}[];
|
|
85
|
+
}>;
|
|
86
|
+
}, "strip", z.ZodTypeAny, {
|
|
87
|
+
order: {
|
|
88
|
+
transactions: {
|
|
89
|
+
createdAt: string;
|
|
90
|
+
gateway: string;
|
|
91
|
+
formattedGateway: string;
|
|
92
|
+
kind: string;
|
|
93
|
+
paymentId: string;
|
|
94
|
+
amountSet: {
|
|
95
|
+
shopMoney: {
|
|
96
|
+
currencyCode: string;
|
|
97
|
+
amount: string;
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
}[];
|
|
101
|
+
};
|
|
102
|
+
}, {
|
|
103
|
+
order: {
|
|
104
|
+
transactions: {
|
|
105
|
+
createdAt: string;
|
|
106
|
+
gateway: string;
|
|
107
|
+
formattedGateway: string;
|
|
108
|
+
kind: string;
|
|
109
|
+
paymentId: string;
|
|
110
|
+
amountSet: {
|
|
111
|
+
shopMoney: {
|
|
112
|
+
currencyCode: string;
|
|
113
|
+
amount: string;
|
|
114
|
+
};
|
|
115
|
+
};
|
|
116
|
+
}[];
|
|
117
|
+
};
|
|
118
|
+
}>;
|
|
119
|
+
type GetOrderPaymentDetailsByIdReturnType = z.infer<typeof GetOrderPaymentDetailsByIdReturn>;
|
|
120
|
+
/**
|
|
121
|
+
* Retrieves payment details for a single order from Shopify by its ID.
|
|
122
|
+
* Returns null if no order is found with the specified ID.
|
|
123
|
+
*
|
|
124
|
+
* @param {bigint} id - The numerical Shopify order ID (e.g., 12345678n).
|
|
125
|
+
* @returns {Promise<GetOrderPaymentDetailsByIdReturnType | null>} A promise that resolves to the order payment data or null if not found.
|
|
126
|
+
* @throws {Error} If the GraphQL query fails or if the response structure is invalid.
|
|
127
|
+
*/
|
|
128
|
+
export declare function getOrderPaymentDetailsById(id: bigint): Promise<GetOrderPaymentDetailsByIdReturnType | null>;
|
|
129
|
+
export {};
|
|
130
|
+
//# sourceMappingURL=getOrderPaymentDetails.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getOrderPaymentDetails.d.ts","sourceRoot":"","sources":["../../../src/queries/orders/getOrderPaymentDetails.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAA;AAanB,QAAA,MAAM,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAkBpC,CAAA;AAEF,KAAK,oCAAoC,GAAG,CAAC,CAAC,KAAK,CACjD,OAAO,gCAAgC,CACxC,CAAA;AAED;;;;;;;GAOG;AACH,wBAAsB,0BAA0B,CAC9C,EAAE,EAAE,MAAM,GACT,OAAO,CAAC,oCAAoC,GAAG,IAAI,CAAC,CAgBtD"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
import { logger } from '../../utils/logger.js';
|
|
3
|
+
import { convertIdIntoGid, fetchShopifyGraphql, } from '../../utils/shopifyFetch.js';
|
|
4
|
+
import { returnOutputParsed } from '../../utils/zod.js';
|
|
5
|
+
import { queryOrderPaymentDetails } from './getOrderPaymentDetails.queries.js';
|
|
6
|
+
const GetOrderPaymentDetailsByIdReturn = z.object({
|
|
7
|
+
order: z.object({
|
|
8
|
+
transactions: z.array(z.object({
|
|
9
|
+
amountSet: z.object({
|
|
10
|
+
shopMoney: z.object({
|
|
11
|
+
amount: z.string(),
|
|
12
|
+
currencyCode: z.string(),
|
|
13
|
+
}),
|
|
14
|
+
}),
|
|
15
|
+
createdAt: z.string(),
|
|
16
|
+
gateway: z.string(),
|
|
17
|
+
formattedGateway: z.string(),
|
|
18
|
+
kind: z.string(),
|
|
19
|
+
paymentId: z.string(),
|
|
20
|
+
})),
|
|
21
|
+
}),
|
|
22
|
+
});
|
|
23
|
+
/**
|
|
24
|
+
* Retrieves payment details for a single order from Shopify by its ID.
|
|
25
|
+
* Returns null if no order is found with the specified ID.
|
|
26
|
+
*
|
|
27
|
+
* @param {bigint} id - The numerical Shopify order ID (e.g., 12345678n).
|
|
28
|
+
* @returns {Promise<GetOrderPaymentDetailsByIdReturnType | null>} A promise that resolves to the order payment data or null if not found.
|
|
29
|
+
* @throws {Error} If the GraphQL query fails or if the response structure is invalid.
|
|
30
|
+
*/
|
|
31
|
+
export async function getOrderPaymentDetailsById(id) {
|
|
32
|
+
const variables = {
|
|
33
|
+
id: convertIdIntoGid(id, 'Order'),
|
|
34
|
+
};
|
|
35
|
+
const response = await fetchShopifyGraphql({
|
|
36
|
+
query: queryOrderPaymentDetails,
|
|
37
|
+
variables,
|
|
38
|
+
});
|
|
39
|
+
if (!response.order) {
|
|
40
|
+
logger.debug(`No order found with ID: ${id}`);
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
return await returnOutputParsed(response, GetOrderPaymentDetailsByIdReturn);
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=getOrderPaymentDetails.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getOrderPaymentDetails.js","sourceRoot":"","sources":["../../../src/queries/orders/getOrderPaymentDetails.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAA;AAKnB,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AAC9C,OAAO,EACL,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,6BAA6B,CAAA;AACpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AACvD,OAAO,EAAE,wBAAwB,EAAE,MAAM,qCAAqC,CAAA;AAE9E,MAAM,gCAAgC,GAAG,CAAC,CAAC,MAAM,CAAC;IAChD,KAAK,EAAE,CAAC,CAAC,MAAM,CAAC;QACd,YAAY,EAAE,CAAC,CAAC,KAAK,CACnB,CAAC,CAAC,MAAM,CAAC;YACP,SAAS,EAAE,CAAC,CAAC,MAAM,CAAC;gBAClB,SAAS,EAAE,CAAC,CAAC,MAAM,CAAC;oBAClB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;oBAClB,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE;iBACzB,CAAC;aACH,CAAC;YACF,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;YACrB,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;YACnB,gBAAgB,EAAE,CAAC,CAAC,MAAM,EAAE;YAC5B,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;YAChB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;SACtB,CAAC,CACH;KACF,CAAC;CACH,CAAC,CAAA;AAMF;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,0BAA0B,CAC9C,EAAU;IAEV,MAAM,SAAS,GAA0C;QACvD,EAAE,EAAE,gBAAgB,CAAC,EAAE,EAAE,OAAO,CAAC;KAClC,CAAA;IAED,MAAM,QAAQ,GAAG,MAAM,mBAAmB,CAA+B;QACvE,KAAK,EAAE,wBAAwB;QAC/B,SAAS;KACV,CAAC,CAAA;IAEF,IAAI,CAAC,QAAQ,CAAC,KAAK,EAAE,CAAC;QACpB,MAAM,CAAC,KAAK,CAAC,2BAA2B,EAAE,EAAE,CAAC,CAAA;QAC7C,OAAO,IAAI,CAAA;IACb,CAAC;IAED,OAAO,MAAM,kBAAkB,CAAC,QAAQ,EAAE,gCAAgC,CAAC,CAAA;AAC7E,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { OrderPaymentDetailsByIdQuery } from '../../generated-api-types/2025-04/admin.generated';
|
|
2
|
+
export declare const orderPaymentDetailsMock: OrderPaymentDetailsByIdQuery;
|
|
3
|
+
export declare const expectedPaymentDetails: {
|
|
4
|
+
order: import("../../generated-api-types/2025-04/admin.types").Maybe<{
|
|
5
|
+
transactions: Array<(Pick<import("../../generated-api-types/2025-04/admin.types").OrderTransaction, "createdAt" | "gateway" | "formattedGateway" | "kind" | "paymentId"> & {
|
|
6
|
+
amountSet: {
|
|
7
|
+
shopMoney: Pick<import("../../generated-api-types/2025-04/admin.types").MoneyV2, "amount" | "currencyCode">;
|
|
8
|
+
};
|
|
9
|
+
})>;
|
|
10
|
+
}> | undefined;
|
|
11
|
+
};
|
|
12
|
+
//# sourceMappingURL=getOrderPaymentDetails.mock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getOrderPaymentDetails.mock.d.ts","sourceRoot":"","sources":["../../../src/queries/orders/getOrderPaymentDetails.mock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,mDAAmD,CAAA;AAMrG,eAAO,MAAM,uBAAuB,EAAE,4BAkBrC,CAAA;AAED,eAAO,MAAM,sBAAsB;;;;;;;;CAElC,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { CurrencyCode, OrderTransactionKind, } from '../../generated-api-types/2025-04/admin.types';
|
|
2
|
+
export const orderPaymentDetailsMock = {
|
|
3
|
+
order: {
|
|
4
|
+
transactions: [
|
|
5
|
+
{
|
|
6
|
+
amountSet: {
|
|
7
|
+
shopMoney: {
|
|
8
|
+
amount: '139.0',
|
|
9
|
+
currencyCode: CurrencyCode.Eur,
|
|
10
|
+
},
|
|
11
|
+
},
|
|
12
|
+
createdAt: '2000-01-01T00:00:00Z',
|
|
13
|
+
gateway: 'paypal',
|
|
14
|
+
formattedGateway: 'Pay Pal Express Checkout',
|
|
15
|
+
kind: OrderTransactionKind.Sale,
|
|
16
|
+
paymentId: 'mock-payment-id-1',
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
},
|
|
20
|
+
};
|
|
21
|
+
export const expectedPaymentDetails = {
|
|
22
|
+
order: orderPaymentDetailsMock.order,
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=getOrderPaymentDetails.mock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getOrderPaymentDetails.mock.js","sourceRoot":"","sources":["../../../src/queries/orders/getOrderPaymentDetails.mock.ts"],"names":[],"mappings":"AACA,OAAO,EACL,YAAY,EACZ,oBAAoB,GACrB,MAAM,+CAA+C,CAAA;AAEtD,MAAM,CAAC,MAAM,uBAAuB,GAAiC;IACnE,KAAK,EAAE;QACL,YAAY,EAAE;YACZ;gBACE,SAAS,EAAE;oBACT,SAAS,EAAE;wBACT,MAAM,EAAE,OAAO;wBACf,YAAY,EAAE,YAAY,CAAC,GAAG;qBAC/B;iBACF;gBACD,SAAS,EAAE,sBAAsB;gBACjC,OAAO,EAAE,QAAQ;gBACjB,gBAAgB,EAAE,0BAA0B;gBAC5C,IAAI,EAAE,oBAAoB,CAAC,IAAI;gBAC/B,SAAS,EAAE,mBAAmB;aAC/B;SACF;KACF;CACF,CAAA;AAED,MAAM,CAAC,MAAM,sBAAsB,GAAG;IACpC,KAAK,EAAE,uBAAuB,CAAC,KAAK;CACrC,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getOrderPaymentDetails.queries.d.ts","sourceRoot":"","sources":["../../../src/queries/orders/getOrderPaymentDetails.queries.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,wBAAwB,QAkBpC,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { gql } from '../../utils/logger.js';
|
|
2
|
+
export const queryOrderPaymentDetails = gql `#graphql
|
|
3
|
+
query orderPaymentDetailsById($id: ID!) {
|
|
4
|
+
order(id: $id) {
|
|
5
|
+
transactions {
|
|
6
|
+
amountSet {
|
|
7
|
+
shopMoney {
|
|
8
|
+
amount
|
|
9
|
+
currencyCode
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
createdAt
|
|
13
|
+
gateway
|
|
14
|
+
formattedGateway
|
|
15
|
+
kind
|
|
16
|
+
paymentId
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
`;
|
|
21
|
+
//# sourceMappingURL=getOrderPaymentDetails.queries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getOrderPaymentDetails.queries.js","sourceRoot":"","sources":["../../../src/queries/orders/getOrderPaymentDetails.queries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAA;AAE3C,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;CAkB1C,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getOrderPaymentDetails.test.d.ts","sourceRoot":"","sources":["../../../src/queries/orders/getOrderPaymentDetails.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { graphql, passthrough } from 'msw';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
|
+
import { server } from '../../utils/mswHandlers';
|
|
4
|
+
import { getOrderPaymentDetailsById } from './getOrderPaymentDetails';
|
|
5
|
+
import { expectedPaymentDetails } from './getOrderPaymentDetails.mock';
|
|
6
|
+
describe('getOrderPaymentDetailsById', () => {
|
|
7
|
+
it('should return payment details when order found', async () => {
|
|
8
|
+
const result = await getOrderPaymentDetailsById(12345n);
|
|
9
|
+
expect(result).toEqual(expectedPaymentDetails);
|
|
10
|
+
});
|
|
11
|
+
describe('Live', () => {
|
|
12
|
+
it('should return null when order not found', async () => {
|
|
13
|
+
server.use(graphql.query('orderPaymentDetailsById', () => passthrough()));
|
|
14
|
+
const result = await getOrderPaymentDetailsById(99999999999n);
|
|
15
|
+
expect(result).toBeNull();
|
|
16
|
+
});
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
//# sourceMappingURL=getOrderPaymentDetails.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getOrderPaymentDetails.test.js","sourceRoot":"","sources":["../../../src/queries/orders/getOrderPaymentDetails.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,KAAK,CAAA;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAC7C,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAChD,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAA;AACrE,OAAO,EAAE,sBAAsB,EAAE,MAAM,+BAA+B,CAAA;AAEtE,QAAQ,CAAC,4BAA4B,EAAE,GAAG,EAAE;IAC1C,EAAE,CAAC,gDAAgD,EAAE,KAAK,IAAI,EAAE;QAC9D,MAAM,MAAM,GAAG,MAAM,0BAA0B,CAAC,MAAM,CAAC,CAAA;QACvD,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAAA;IAChD,CAAC,CAAC,CAAA;IAEF,QAAQ,CAAC,MAAM,EAAE,GAAG,EAAE;QACpB,EAAE,CAAC,yCAAyC,EAAE,KAAK,IAAI,EAAE;YACvD,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,yBAAyB,EAAE,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC,CAAA;YACzE,MAAM,MAAM,GAAG,MAAM,0BAA0B,CAAC,YAAY,CAAC,CAAA;YAC7D,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAA;QAC3B,CAAC,CAAC,CAAA;IACJ,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
declare const GetLeanProductVariantsReturn: z.ZodArray<z.ZodObject<{
|
|
3
|
+
productId: z.ZodString;
|
|
4
|
+
productTitle: z.ZodString;
|
|
5
|
+
variantId: z.ZodString;
|
|
6
|
+
variantTitle: z.ZodString;
|
|
7
|
+
sku: z.ZodString;
|
|
8
|
+
}, "strip", z.ZodTypeAny, {
|
|
9
|
+
productId: string;
|
|
10
|
+
variantId: string;
|
|
11
|
+
sku: string;
|
|
12
|
+
variantTitle: string;
|
|
13
|
+
productTitle: string;
|
|
14
|
+
}, {
|
|
15
|
+
productId: string;
|
|
16
|
+
variantId: string;
|
|
17
|
+
sku: string;
|
|
18
|
+
variantTitle: string;
|
|
19
|
+
productTitle: string;
|
|
20
|
+
}>, "many">;
|
|
21
|
+
type GetLeanProductVariantsReturnType = z.infer<typeof GetLeanProductVariantsReturn>;
|
|
22
|
+
/**
|
|
23
|
+
* Retrieves a lean list of product variants from Shopify, optionally filtered by SKUs.
|
|
24
|
+
* Product variants are mapped to a simpler output structure.
|
|
25
|
+
* Variants missing essential properties (e.g., SKU) will be filtered out and logged.
|
|
26
|
+
*
|
|
27
|
+
* @param {string[]} [skus] - An optional array of SKUs to filter by. If provided, only variants matching these SKUs will be fetched.
|
|
28
|
+
* @returns {Promise<GetLeanProductVariantsReturnType>} A promise that resolves to an array of lean product variant data.
|
|
29
|
+
* @throws {Error} If the GraphQL query fails, returns no data, or if the `productVariants` field is missing in the response.
|
|
30
|
+
*/
|
|
31
|
+
export declare function getLeanProductVariants(skus?: string[]): Promise<GetLeanProductVariantsReturnType>;
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=getLeanProductVariants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getLeanProductVariants.d.ts","sourceRoot":"","sources":["../../../src/queries/productVariants/getLeanProductVariants.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAA;AASnB,QAAA,MAAM,4BAA4B;;;;;;;;;;;;;;;;;;WAQjC,CAAA;AAED,KAAK,gCAAgC,GAAG,CAAC,CAAC,KAAK,CAC7C,OAAO,4BAA4B,CACpC,CAAA;AAED;;;;;;;;GAQG;AACH,wBAAsB,sBAAsB,CAC1C,IAAI,CAAC,EAAE,MAAM,EAAE,GACd,OAAO,CAAC,gCAAgC,CAAC,CAiF3C"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import z from 'zod';
|
|
2
|
+
import { gql, logger } from '../../utils/logger.js';
|
|
3
|
+
import { fetchShopifyGraphql } from '../../utils/shopifyFetch.js';
|
|
4
|
+
import { returnOutputParsed } from '../../utils/zod.js';
|
|
5
|
+
const GetLeanProductVariantsReturn = z.array(z.object({
|
|
6
|
+
productId: z.string(),
|
|
7
|
+
productTitle: z.string(),
|
|
8
|
+
variantId: z.string(),
|
|
9
|
+
variantTitle: z.string(),
|
|
10
|
+
sku: z.string(),
|
|
11
|
+
}));
|
|
12
|
+
/**
|
|
13
|
+
* Retrieves a lean list of product variants from Shopify, optionally filtered by SKUs.
|
|
14
|
+
* Product variants are mapped to a simpler output structure.
|
|
15
|
+
* Variants missing essential properties (e.g., SKU) will be filtered out and logged.
|
|
16
|
+
*
|
|
17
|
+
* @param {string[]} [skus] - An optional array of SKUs to filter by. If provided, only variants matching these SKUs will be fetched.
|
|
18
|
+
* @returns {Promise<GetLeanProductVariantsReturnType>} A promise that resolves to an array of lean product variant data.
|
|
19
|
+
* @throws {Error} If the GraphQL query fails, returns no data, or if the `productVariants` field is missing in the response.
|
|
20
|
+
*/
|
|
21
|
+
export async function getLeanProductVariants(skus) {
|
|
22
|
+
const queryGql = gql `#graphql
|
|
23
|
+
query leanProductVariants($first: Int!, $after: String, $queryFilter: String) {
|
|
24
|
+
productVariants(first: $first, after: $after, query: $queryFilter) {
|
|
25
|
+
edges {
|
|
26
|
+
node {
|
|
27
|
+
id
|
|
28
|
+
title
|
|
29
|
+
sku
|
|
30
|
+
product {
|
|
31
|
+
id
|
|
32
|
+
title
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
pageInfo {
|
|
37
|
+
hasNextPage
|
|
38
|
+
endCursor
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
`;
|
|
43
|
+
const initialVariables = { first: 250 };
|
|
44
|
+
if (skus && skus.length > 0) {
|
|
45
|
+
initialVariables.queryFilter = skus
|
|
46
|
+
.map((sku) => `sku:${sku}`)
|
|
47
|
+
.join(' OR ');
|
|
48
|
+
}
|
|
49
|
+
const extractedNodes = await fetchShopifyGraphql({
|
|
50
|
+
query: queryGql,
|
|
51
|
+
variables: initialVariables,
|
|
52
|
+
dataExtractor: (pageData) => {
|
|
53
|
+
if (!pageData.productVariants) {
|
|
54
|
+
throw new Error("GraphQL response for product variants is missing the 'productVariants' field.");
|
|
55
|
+
}
|
|
56
|
+
const nodes = pageData.productVariants.edges.map((edge) => edge.node);
|
|
57
|
+
return {
|
|
58
|
+
nodes,
|
|
59
|
+
pageInfo: pageData.productVariants.pageInfo,
|
|
60
|
+
};
|
|
61
|
+
},
|
|
62
|
+
fetchAllPages: true,
|
|
63
|
+
});
|
|
64
|
+
const allVariants = extractedNodes.flatMap((v) => {
|
|
65
|
+
if (v.sku) {
|
|
66
|
+
return [
|
|
67
|
+
{
|
|
68
|
+
productId: v.product.id,
|
|
69
|
+
productTitle: v.product.title,
|
|
70
|
+
variantId: v.id,
|
|
71
|
+
variantTitle: v.title,
|
|
72
|
+
sku: v.sku,
|
|
73
|
+
},
|
|
74
|
+
];
|
|
75
|
+
}
|
|
76
|
+
logger.debug(`Product ${v.product.title} (ID: ${v.product.id}) has a variant (ID: ${v.id}) with no SKU. Filtering out.`);
|
|
77
|
+
return [];
|
|
78
|
+
});
|
|
79
|
+
return await returnOutputParsed(allVariants, GetLeanProductVariantsReturn);
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=getLeanProductVariants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getLeanProductVariants.js","sourceRoot":"","sources":["../../../src/queries/productVariants/getLeanProductVariants.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,KAAK,CAAA;AAKnB,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAA;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AACjE,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AAEvD,MAAM,4BAA4B,GAAG,CAAC,CAAC,KAAK,CAC1C,CAAC,CAAC,MAAM,CAAC;IACP,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;IACrB,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE;IACxB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;IACrB,YAAY,EAAE,CAA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,YAAY,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK;oBAC7B,SAAS,EAAE,CAAC,CAAC,EAAE;oBACf,YAAY,EAAE,CAAC,CAAC,KAAK;oBACrB,GAAG,EAAE,CAAC,CAAC,GAAG;iBACX;aACF,CAAA;QACH,CAAC;QACD,MAAM,CAAC,KAAK,CACV,WAAW,CAAC,CAAC,OAAO,CAAC,KAAK,SAAS,CAAC,CAAC,OAAO,CAAC,EAAE,wBAAwB,CAAC,CAAC,EAAE,+BAA+B,CAC3G,CAAA;QACD,OAAO,EAAE,CAAA;IACX,CAAC,CAAC,CAAA;IAEF,OAAO,MAAM,kBAAkB,CAAC,WAAW,EAAE,4BAA4B,CAAC,CAAA;AAC5E,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getLeanProductVariants.mock.d.ts","sourceRoot":"","sources":["../../../src/queries/productVariants/getLeanProductVariants.mock.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,mDAAmD,CAAA;AAEjG,eAAO,MAAM,uBAAuB,EAAE,wBA+BrC,CAAA"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export const leanProductVariantsMock = {
|
|
2
|
+
productVariants: {
|
|
3
|
+
edges: [
|
|
4
|
+
{
|
|
5
|
+
node: {
|
|
6
|
+
id: 'gid://shopify/ProductVariant/1',
|
|
7
|
+
title: 'Default Title',
|
|
8
|
+
sku: 'SKU123',
|
|
9
|
+
product: {
|
|
10
|
+
id: 'gid://shopify/Product/1',
|
|
11
|
+
title: 'Test Product 1',
|
|
12
|
+
},
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
node: {
|
|
17
|
+
id: 'gid://shopify/ProductVariant/2',
|
|
18
|
+
title: 'Another Variant',
|
|
19
|
+
sku: 'SKU456',
|
|
20
|
+
product: {
|
|
21
|
+
id: 'gid://shopify/Product/2',
|
|
22
|
+
title: 'Test Product 2',
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
pageInfo: {
|
|
28
|
+
hasNextPage: false,
|
|
29
|
+
endCursor: 'eyJsYXN0X2lkIjoxfQ==',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=getLeanProductVariants.mock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getLeanProductVariants.mock.js","sourceRoot":"","sources":["../../../src/queries/productVariants/getLeanProductVariants.mock.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,uBAAuB,GAA6B;IAC/D,eAAe,EAAE;QACf,KAAK,EAAE;YACL;gBACE,IAAI,EAAE;oBACJ,EAAE,EAAE,gCAAgC;oBACpC,KAAK,EAAE,eAAe;oBACtB,GAAG,EAAE,QAAQ;oBACb,OAAO,EAAE;wBACP,EAAE,EAAE,yBAAyB;wBAC7B,KAAK,EAAE,gBAAgB;qBACxB;iBACF;aACF;YACD;gBACE,IAAI,EAAE;oBACJ,EAAE,EAAE,gCAAgC;oBACpC,KAAK,EAAE,iBAAiB;oBACxB,GAAG,EAAE,QAAQ;oBACb,OAAO,EAAE;wBACP,EAAE,EAAE,yBAAyB;wBAC7B,KAAK,EAAE,gBAAgB;qBACxB;iBACF;aACF;SACF;QACD,QAAQ,EAAE;YACR,WAAW,EAAE,KAAK;YAClB,SAAS,EAAE,sBAAsB;SAClC;KACF;CACF,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getLeanProductVariants.test.d.ts","sourceRoot":"","sources":["../../../src/queries/productVariants/getLeanProductVariants.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { graphql, passthrough } from 'msw';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
|
+
import { server } from '../../utils/mswHandlers';
|
|
4
|
+
import { getLeanProductVariants } from './getLeanProductVariants';
|
|
5
|
+
import { leanProductVariantsMock } from './getLeanProductVariants.mock';
|
|
6
|
+
describe('getLeanProductVariants', () => {
|
|
7
|
+
describe('Mocked', () => {
|
|
8
|
+
const skus = ['SKU123', 'SKU456'];
|
|
9
|
+
const variants = leanProductVariantsMock.productVariants.edges.map((edge) => edge.node);
|
|
10
|
+
const reformattedVariants = variants.map((variant) => ({
|
|
11
|
+
productId: variant.product.id,
|
|
12
|
+
productTitle: variant.product.title,
|
|
13
|
+
variantId: variant.id,
|
|
14
|
+
variantTitle: variant.title,
|
|
15
|
+
sku: variant.sku,
|
|
16
|
+
}));
|
|
17
|
+
it('should work with multiple SKUs', async () => {
|
|
18
|
+
const result = await getLeanProductVariants(skus);
|
|
19
|
+
expect(result).toEqual(reformattedVariants);
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
describe('Live', () => {
|
|
23
|
+
it('should return an empty array for non-existent SKUs', async () => {
|
|
24
|
+
server.use(graphql.query('leanProductVariants', () => passthrough()));
|
|
25
|
+
const result = await getLeanProductVariants(['not-a-sku']);
|
|
26
|
+
expect(result).toEqual([]);
|
|
27
|
+
});
|
|
28
|
+
it('should work without SKUs and fetch more than is on one page (250)', {
|
|
29
|
+
timeout: 20000,
|
|
30
|
+
skip: false,
|
|
31
|
+
}, async () => {
|
|
32
|
+
server.use(graphql.query('leanProductVariants', () => passthrough()));
|
|
33
|
+
const result = await getLeanProductVariants();
|
|
34
|
+
expect(result.length).toBeGreaterThan(251);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
});
|
|
38
|
+
//# sourceMappingURL=getLeanProductVariants.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getLeanProductVariants.test.js","sourceRoot":"","sources":["../../../src/queries/productVariants/getLeanProductVariants.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,KAAK,CAAA;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM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C,CAAC,CAAA;YACrE,MAAM,MAAM,GAAG,MAAM,sBAAsB,CAAC,CAAC,WAAW,CAAC,CAAC,CAAA;YAC1D,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;QAC5B,CAAC,CAAC,CAAA;QAEF,EAAE,CACA,mEAAmE,EACnE;YACE,OAAO,EAAE,KAAK;YACd,IAAI,EAAE,KAAK;SACZ,EACD,KAAK,IAAI,EAAE;YACT,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,qBAAqB,EAAE,GAAG,EAAE,CAAC,WAAW,EAAE,CAAC,CAAC,CAAA;YAErE,MAAM,MAAM,GAAG,MAAM,sBAAsB,EAAE,CAAA;YAC7C,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,eAAe,CAAC,GAAG,CAAC,CAAA;QAC5C,CAAC,CACF,CAAA;IACH,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare const gql: (template: {
|
|
2
|
+
raw: readonly string[] | ArrayLike<string>;
|
|
3
|
+
}, ...substitutions: any[]) => string;
|
|
4
|
+
export declare const activeLogLevelName: "silent" | "error" | "warn" | "info" | "debug";
|
|
5
|
+
export declare const logger: {
|
|
6
|
+
debug: (...args: unknown[]) => void;
|
|
7
|
+
info: (...args: unknown[]) => void;
|
|
8
|
+
warn: (...args: unknown[]) => void;
|
|
9
|
+
error: (...args: unknown[]) => void;
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,GAAG;;qCAAa,CAAA;AA8B7B,eAAO,MAAM,kBAAkB,gDAA2C,CAAA;AAG1E,eAAO,MAAM,MAAM;qBACA,OAAO,EAAE;oBAMV,OAAO,EAAE;oBAMT,OAAO,EAAE;qBAMR,OAAO,EAAE;CAM3B,CAAA"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
const { env } = process;
|
|
2
|
+
export const gql = String.raw;
|
|
3
|
+
const logLevels = {
|
|
4
|
+
silent: 0,
|
|
5
|
+
error: 1,
|
|
6
|
+
warn: 2,
|
|
7
|
+
info: 3,
|
|
8
|
+
debug: 4,
|
|
9
|
+
};
|
|
10
|
+
function getLogLevel(nodeEnv, logLevelEnv) {
|
|
11
|
+
if (logLevelEnv && logLevelEnv in logLevels) {
|
|
12
|
+
return logLevelEnv;
|
|
13
|
+
}
|
|
14
|
+
if (nodeEnv === 'test') {
|
|
15
|
+
return 'silent';
|
|
16
|
+
}
|
|
17
|
+
if (nodeEnv === 'production') {
|
|
18
|
+
return 'info';
|
|
19
|
+
}
|
|
20
|
+
return 'debug';
|
|
21
|
+
}
|
|
22
|
+
export const activeLogLevelName = getLogLevel(env.NODE_ENV, env.LOG_LEVEL);
|
|
23
|
+
const activeLogLevelValue = logLevels[activeLogLevelName];
|
|
24
|
+
export const logger = {
|
|
25
|
+
debug: (...args) => {
|
|
26
|
+
if (logLevels.debug <= activeLogLevelValue) {
|
|
27
|
+
// biome-ignore lint/suspicious/noConsole: <explanation>
|
|
28
|
+
console.debug(...args);
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
info: (...args) => {
|
|
32
|
+
if (logLevels.info <= activeLogLevelValue) {
|
|
33
|
+
// biome-ignore lint/suspicious/noConsole: <explanation>
|
|
34
|
+
console.info(...args);
|
|
35
|
+
}
|
|
36
|
+
},
|
|
37
|
+
warn: (...args) => {
|
|
38
|
+
if (logLevels.warn <= activeLogLevelValue) {
|
|
39
|
+
// biome-ignore lint/suspicious/noConsole: <explanation>
|
|
40
|
+
console.warn(...args);
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
error: (...args) => {
|
|
44
|
+
if (logLevels.error <= activeLogLevelValue) {
|
|
45
|
+
// biome-ignore lint/suspicious/noConsole: <explanation>
|
|
46
|
+
console.error(...args);
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../../src/utils/logger.ts"],"names":[],"mappings":"AAAA,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,CAAA;AAEvB,MAAM,CAAC,MAAM,GAAG,GAAG,MAAM,CAAC,GAAG,CAAA;AAE7B,MAAM,SAAS,GAAG;IAChB,MAAM,EAAE,CAAC;IACT,KAAK,EAAE,CAAC;IACR,IAAI,EAAE,CAAC;IACP,IAAI,EAAE,CAAC;IACP,KAAK,EAAE,CAAC;CACA,CAAA;AAIV,SAAS,WAAW,CAClB,OAA2B,EAC3B,WAA+B;IAE/B,IAAI,WAAW,IAAI,WAAW,IAAI,SAAS,EAAE,CAAC;QAC5C,OAAO,WAA2B,CAAA;IACpC,CAAC;IAED,IAAI,OAAO,KAAK,MAAM,EAAE,CAAC;QACvB,OAAO,QAAQ,CAAA;IACjB,CAAC;IAED,IAAI,OAAO,KAAK,YAAY,EAAE,CAAC;QAC7B,OAAO,MAAM,CAAA;IACf,CAAC;IACD,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,MAAM,CAAC,MAAM,kBAAkB,GAAG,WAAW,CAAC,GAAG,CAAC,QAAQ,EAAE,GAAG,CAAC,SAAS,CAAC,CAAA;AAC1E,MAAM,mBAAmB,GAAG,SAAS,CAAC,kBAAkB,CAAC,CAAA;AAEzD,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,KAAK,EAAE,CAAC,GAAG,IAAe,EAAE,EAAE;QAC5B,IAAI,SAAS,CAAC,KAAK,IAAI,mBAAmB,EAAE,CAAC;YAC3C,wDAAwD;YACxD,OAAO,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,CAAA;QACxB,CAAC;IACH,CAAC;IACD,IAAI,EAAE,CA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