n8n-nodes-shopify-custom 2.0.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/LICENSE.md +19 -0
- package/README.md +68 -0
- package/dist/credentials/ShopifyCustomAdminApi.credentials.d.ts +10 -0
- package/dist/credentials/ShopifyCustomAdminApi.credentials.js +65 -0
- package/dist/credentials/ShopifyCustomAdminApi.credentials.js.map +1 -0
- package/dist/icons/shopify.dark.svg +12 -0
- package/dist/icons/shopify.svg +12 -0
- package/dist/nodes/ShopifyCustom/ShopifyCustom.node.d.ts +15 -0
- package/dist/nodes/ShopifyCustom/ShopifyCustom.node.js +358 -0
- package/dist/nodes/ShopifyCustom/ShopifyCustom.node.js.map +1 -0
- package/dist/nodes/ShopifyCustom/ShopifyCustom.node.json +18 -0
- package/dist/nodes/ShopifyCustom/config/operations/collection.d.ts +2 -0
- package/dist/nodes/ShopifyCustom/config/operations/collection.js +306 -0
- package/dist/nodes/ShopifyCustom/config/operations/collection.js.map +1 -0
- package/dist/nodes/ShopifyCustom/config/operations/common.d.ts +13 -0
- package/dist/nodes/ShopifyCustom/config/operations/common.js +222 -0
- package/dist/nodes/ShopifyCustom/config/operations/common.js.map +1 -0
- package/dist/nodes/ShopifyCustom/config/operations/customer.d.ts +2 -0
- package/dist/nodes/ShopifyCustom/config/operations/customer.js +107 -0
- package/dist/nodes/ShopifyCustom/config/operations/customer.js.map +1 -0
- package/dist/nodes/ShopifyCustom/config/operations/draftOrder.d.ts +2 -0
- package/dist/nodes/ShopifyCustom/config/operations/draftOrder.js +118 -0
- package/dist/nodes/ShopifyCustom/config/operations/draftOrder.js.map +1 -0
- package/dist/nodes/ShopifyCustom/config/operations/index.d.ts +7 -0
- package/dist/nodes/ShopifyCustom/config/operations/index.js +48 -0
- package/dist/nodes/ShopifyCustom/config/operations/index.js.map +1 -0
- package/dist/nodes/ShopifyCustom/config/operations/metafieldDefinition.d.ts +2 -0
- package/dist/nodes/ShopifyCustom/config/operations/metafieldDefinition.js +192 -0
- package/dist/nodes/ShopifyCustom/config/operations/metafieldDefinition.js.map +1 -0
- package/dist/nodes/ShopifyCustom/config/operations/metafieldValue.d.ts +2 -0
- package/dist/nodes/ShopifyCustom/config/operations/metafieldValue.js +125 -0
- package/dist/nodes/ShopifyCustom/config/operations/metafieldValue.js.map +1 -0
- package/dist/nodes/ShopifyCustom/config/operations/metaobject.d.ts +2 -0
- package/dist/nodes/ShopifyCustom/config/operations/metaobject.js +198 -0
- package/dist/nodes/ShopifyCustom/config/operations/metaobject.js.map +1 -0
- package/dist/nodes/ShopifyCustom/config/operations/order.d.ts +2 -0
- package/dist/nodes/ShopifyCustom/config/operations/order.js +111 -0
- package/dist/nodes/ShopifyCustom/config/operations/order.js.map +1 -0
- package/dist/nodes/ShopifyCustom/config/operations/product.d.ts +2 -0
- package/dist/nodes/ShopifyCustom/config/operations/product.js +118 -0
- package/dist/nodes/ShopifyCustom/config/operations/product.js.map +1 -0
- package/dist/nodes/ShopifyCustom/config/operations/productVariant.d.ts +2 -0
- package/dist/nodes/ShopifyCustom/config/operations/productVariant.js +109 -0
- package/dist/nodes/ShopifyCustom/config/operations/productVariant.js.map +1 -0
- package/dist/nodes/ShopifyCustom/config/operations/service.d.ts +2 -0
- package/dist/nodes/ShopifyCustom/config/operations/service.js +14 -0
- package/dist/nodes/ShopifyCustom/config/operations/service.js.map +1 -0
- package/dist/nodes/ShopifyCustom/config/operations/types.d.ts +13 -0
- package/dist/nodes/ShopifyCustom/config/operations/types.js +3 -0
- package/dist/nodes/ShopifyCustom/config/operations/types.js.map +1 -0
- package/dist/nodes/ShopifyCustom/config/resources.d.ts +9 -0
- package/dist/nodes/ShopifyCustom/config/resources.js +62 -0
- package/dist/nodes/ShopifyCustom/config/resources.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shared/collections/ruleConditions.d.ts +17 -0
- package/dist/nodes/ShopifyCustom/shared/collections/ruleConditions.js +281 -0
- package/dist/nodes/ShopifyCustom/shared/collections/ruleConditions.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shared/errors.d.ts +8 -0
- package/dist/nodes/ShopifyCustom/shared/errors.js +37 -0
- package/dist/nodes/ShopifyCustom/shared/errors.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/client.d.ts +26 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/client.js +73 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/client.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/registry.d.ts +17 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/registry.js +962 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/registry.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/collection.d.ts +5 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/collection.js +99 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/collection.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/commonFragments.d.ts +7 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/commonFragments.js +69 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/commonFragments.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/customer.d.ts +5 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/customer.js +94 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/customer.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/draftOrder.d.ts +5 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/draftOrder.js +91 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/draftOrder.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/metafields.d.ts +10 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/metafields.js +223 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/metafields.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/metaobject.d.ts +5 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/metaobject.js +92 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/metaobject.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/order.d.ts +5 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/order.js +95 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/order.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/product.d.ts +5 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/product.js +107 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/product.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/productVariant.d.ts +5 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/productVariant.js +99 -0
- package/dist/nodes/ShopifyCustom/shared/graphql/templates/productVariant.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/definitions.d.ts +24 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/definitions.js +65 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/definitions.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/ownerTypeMap.d.ts +3 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/ownerTypeMap.js +19 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/ownerTypeMap.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/referenceLoaders.d.ts +2 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/referenceLoaders.js +122 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/referenceLoaders.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/types.d.ts +17 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/types.js +57 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/types.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/uiFactory.d.ts +2 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/uiFactory.js +395 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/uiFactory.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/valueAdapters/constants.d.ts +20 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/valueAdapters/constants.js +61 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/valueAdapters/constants.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/valueAdapters/index.d.ts +3 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/valueAdapters/index.js +43 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/valueAdapters/index.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/valueAdapters/list.d.ts +2 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/valueAdapters/list.js +103 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/valueAdapters/list.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/valueAdapters/reference.d.ts +2 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/valueAdapters/reference.js +80 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/valueAdapters/reference.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/valueAdapters/scalar.d.ts +2 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/valueAdapters/scalar.js +110 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/valueAdapters/scalar.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/valueAdapters/structured.d.ts +2 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/valueAdapters/structured.js +64 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/valueAdapters/structured.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/valuePayload.d.ts +3 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/valuePayload.js +89 -0
- package/dist/nodes/ShopifyCustom/shared/metafields/valuePayload.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shared/output/outputMapper.d.ts +3 -0
- package/dist/nodes/ShopifyCustom/shared/output/outputMapper.js +82 -0
- package/dist/nodes/ShopifyCustom/shared/output/outputMapper.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shared/themes/templateSuffixes.d.ts +2 -0
- package/dist/nodes/ShopifyCustom/shared/themes/templateSuffixes.js +83 -0
- package/dist/nodes/ShopifyCustom/shared/themes/templateSuffixes.js.map +1 -0
- package/dist/nodes/ShopifyCustom/shopify.dark.svg +12 -0
- package/dist/nodes/ShopifyCustom/shopify.svg +12 -0
- package/dist/package.json +62 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +62 -0
|
@@ -0,0 +1,962 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRegistryOperation = getRegistryOperation;
|
|
4
|
+
const collection_1 = require("./templates/collection");
|
|
5
|
+
const customer_1 = require("./templates/customer");
|
|
6
|
+
const draftOrder_1 = require("./templates/draftOrder");
|
|
7
|
+
const metafields_1 = require("./templates/metafields");
|
|
8
|
+
const metaobject_1 = require("./templates/metaobject");
|
|
9
|
+
const order_1 = require("./templates/order");
|
|
10
|
+
const product_1 = require("./templates/product");
|
|
11
|
+
const productVariant_1 = require("./templates/productVariant");
|
|
12
|
+
const ruleConditions_1 = require("../collections/ruleConditions");
|
|
13
|
+
const definitions_1 = require("../metafields/definitions");
|
|
14
|
+
function isObject(value) {
|
|
15
|
+
return !!value && typeof value === 'object' && !Array.isArray(value);
|
|
16
|
+
}
|
|
17
|
+
function asString(value) {
|
|
18
|
+
if (value === undefined || value === null) {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
const normalized = String(value).trim();
|
|
22
|
+
return normalized.length > 0 ? normalized : undefined;
|
|
23
|
+
}
|
|
24
|
+
function asBoolean(value) {
|
|
25
|
+
if (value === undefined || value === null) {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
return Boolean(value);
|
|
29
|
+
}
|
|
30
|
+
function asNumber(value) {
|
|
31
|
+
if (value === undefined || value === null || value === '') {
|
|
32
|
+
return undefined;
|
|
33
|
+
}
|
|
34
|
+
const parsed = Number(value);
|
|
35
|
+
return Number.isNaN(parsed) ? undefined : parsed;
|
|
36
|
+
}
|
|
37
|
+
function parseTags(value) {
|
|
38
|
+
const raw = asString(value);
|
|
39
|
+
if (!raw) {
|
|
40
|
+
return undefined;
|
|
41
|
+
}
|
|
42
|
+
const tags = raw
|
|
43
|
+
.split(',')
|
|
44
|
+
.map((tag) => tag.trim())
|
|
45
|
+
.filter((tag) => tag.length > 0);
|
|
46
|
+
return tags.length > 0 ? tags : undefined;
|
|
47
|
+
}
|
|
48
|
+
function parseSeoInput(parameters) {
|
|
49
|
+
const title = asString(parameters.seoTitle);
|
|
50
|
+
const description = asString(parameters.seoDescription);
|
|
51
|
+
if (!title && !description) {
|
|
52
|
+
return undefined;
|
|
53
|
+
}
|
|
54
|
+
return {
|
|
55
|
+
title,
|
|
56
|
+
description,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
function getPaginationOptions(parameters) {
|
|
60
|
+
if (isObject(parameters.paginationOptions)) {
|
|
61
|
+
return parameters.paginationOptions;
|
|
62
|
+
}
|
|
63
|
+
if (isObject(parameters.options)) {
|
|
64
|
+
return parameters.options;
|
|
65
|
+
}
|
|
66
|
+
return {};
|
|
67
|
+
}
|
|
68
|
+
function getConnectionVariables(parameters) {
|
|
69
|
+
var _a, _b, _c, _d, _e, _f;
|
|
70
|
+
const options = getPaginationOptions(parameters);
|
|
71
|
+
const sorting = isObject(options.sorting) ? options.sorting : {};
|
|
72
|
+
const limit = (_a = asNumber(parameters.limit)) !== null && _a !== void 0 ? _a : 50;
|
|
73
|
+
return {
|
|
74
|
+
first: Math.max(1, Math.trunc(limit)),
|
|
75
|
+
after: asString(options.afterCursor),
|
|
76
|
+
query: asString((_b = options.query) !== null && _b !== void 0 ? _b : parameters.query),
|
|
77
|
+
sortKey: asString((_d = (_c = sorting.sortKey) !== null && _c !== void 0 ? _c : options.sortKey) !== null && _d !== void 0 ? _d : parameters.sortKey),
|
|
78
|
+
reverse: asBoolean((_f = (_e = sorting.reverse) !== null && _e !== void 0 ? _e : options.reverse) !== null && _f !== void 0 ? _f : parameters.reverse),
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
function parseSelectedMetafieldKeys(value) {
|
|
82
|
+
if (!Array.isArray(value)) {
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
const keys = value
|
|
86
|
+
.map((item) => asString(item))
|
|
87
|
+
.filter((item) => !!item)
|
|
88
|
+
.map((item) => {
|
|
89
|
+
try {
|
|
90
|
+
const definition = (0, definitions_1.decodeDefinitionOptionValue)(item);
|
|
91
|
+
const namespace = asString(definition.namespace);
|
|
92
|
+
const key = asString(definition.key);
|
|
93
|
+
if (!namespace || !key) {
|
|
94
|
+
return undefined;
|
|
95
|
+
}
|
|
96
|
+
return `${namespace}.${key}`;
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
const fallback = asString(item);
|
|
100
|
+
if (!fallback || !fallback.includes('.')) {
|
|
101
|
+
return undefined;
|
|
102
|
+
}
|
|
103
|
+
return fallback;
|
|
104
|
+
}
|
|
105
|
+
})
|
|
106
|
+
.filter((item) => !!item);
|
|
107
|
+
if (keys.length === 0) {
|
|
108
|
+
return undefined;
|
|
109
|
+
}
|
|
110
|
+
return Array.from(new Set(keys));
|
|
111
|
+
}
|
|
112
|
+
function getMetafieldReadVariables(parameters) {
|
|
113
|
+
var _a, _b, _c, _d, _e, _f;
|
|
114
|
+
const options = getPaginationOptions(parameters);
|
|
115
|
+
const metafields = isObject(options.metafields) ? options.metafields : {};
|
|
116
|
+
const selectedMetafieldKeys = parseSelectedMetafieldKeys((_b = (_a = metafields.selectedMetafields) !== null && _a !== void 0 ? _a : options.selectedMetafields) !== null && _b !== void 0 ? _b : parameters.selectedMetafields);
|
|
117
|
+
return {
|
|
118
|
+
includeMetafields: Boolean((_d = (_c = metafields.includeMetafields) !== null && _c !== void 0 ? _c : options.includeMetafields) !== null && _d !== void 0 ? _d : parameters.includeMetafields),
|
|
119
|
+
metafieldsFirst: 250,
|
|
120
|
+
metafieldKeys: selectedMetafieldKeys,
|
|
121
|
+
resolveMetafieldReferences: Boolean((_f = (_e = metafields.resolveMetafieldReferences) !== null && _e !== void 0 ? _e : options.resolveMetafieldReferences) !== null && _f !== void 0 ? _f : parameters.resolveMetafieldReferences),
|
|
122
|
+
metafieldReferencesFirst: 50,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
function getPathValue(source, path) {
|
|
126
|
+
let current = source;
|
|
127
|
+
for (const chunk of path) {
|
|
128
|
+
if (Array.isArray(current)) {
|
|
129
|
+
const index = Number(chunk);
|
|
130
|
+
if (Number.isNaN(index)) {
|
|
131
|
+
return undefined;
|
|
132
|
+
}
|
|
133
|
+
current = current[index];
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
if (!isObject(current)) {
|
|
137
|
+
return undefined;
|
|
138
|
+
}
|
|
139
|
+
current = current[chunk];
|
|
140
|
+
}
|
|
141
|
+
return current;
|
|
142
|
+
}
|
|
143
|
+
const JSON_METAFIELD_TYPES = new Set([
|
|
144
|
+
'json',
|
|
145
|
+
'rich_text_field',
|
|
146
|
+
'money',
|
|
147
|
+
'rating',
|
|
148
|
+
'dimension',
|
|
149
|
+
'volume',
|
|
150
|
+
'weight',
|
|
151
|
+
]);
|
|
152
|
+
function shouldParseMetafieldValue(typeName) {
|
|
153
|
+
if (!typeName) {
|
|
154
|
+
return false;
|
|
155
|
+
}
|
|
156
|
+
return typeName.startsWith('list.') || JSON_METAFIELD_TYPES.has(typeName);
|
|
157
|
+
}
|
|
158
|
+
function parseMetafieldValue(typeName, value) {
|
|
159
|
+
if (!shouldParseMetafieldValue(typeName) || typeof value !== 'string') {
|
|
160
|
+
return value;
|
|
161
|
+
}
|
|
162
|
+
const trimmed = value.trim();
|
|
163
|
+
if (!trimmed) {
|
|
164
|
+
return value;
|
|
165
|
+
}
|
|
166
|
+
try {
|
|
167
|
+
return JSON.parse(trimmed);
|
|
168
|
+
}
|
|
169
|
+
catch {
|
|
170
|
+
return value;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
function normalizeMetafieldNode(metafield) {
|
|
174
|
+
const typeName = asString(metafield.type);
|
|
175
|
+
const parsedValue = parseMetafieldValue(typeName, metafield.value);
|
|
176
|
+
let changed = false;
|
|
177
|
+
const normalized = { ...metafield };
|
|
178
|
+
if (parsedValue !== metafield.value) {
|
|
179
|
+
normalized.value = parsedValue;
|
|
180
|
+
changed = true;
|
|
181
|
+
}
|
|
182
|
+
if (isObject(metafield.references) && Array.isArray(metafield.references.nodes)) {
|
|
183
|
+
normalized.references = metafield.references.nodes.filter(isObject);
|
|
184
|
+
changed = true;
|
|
185
|
+
}
|
|
186
|
+
if (Array.isArray(metafield.references)) {
|
|
187
|
+
normalized.references = metafield.references.filter(isObject);
|
|
188
|
+
changed = true;
|
|
189
|
+
}
|
|
190
|
+
if (isObject(metafield.reference)) {
|
|
191
|
+
normalized.reference = metafield.reference;
|
|
192
|
+
changed = true;
|
|
193
|
+
}
|
|
194
|
+
return changed ? normalized : metafield;
|
|
195
|
+
}
|
|
196
|
+
function normalizeMetafieldArray(value) {
|
|
197
|
+
if (!Array.isArray(value)) {
|
|
198
|
+
return [];
|
|
199
|
+
}
|
|
200
|
+
return value.filter(isObject).map(normalizeMetafieldNode);
|
|
201
|
+
}
|
|
202
|
+
function normalizeNode(node) {
|
|
203
|
+
const normalized = { ...node };
|
|
204
|
+
let changed = false;
|
|
205
|
+
if (isObject(node.metafield)) {
|
|
206
|
+
normalized.metafield = normalizeMetafieldNode(node.metafield);
|
|
207
|
+
changed = true;
|
|
208
|
+
}
|
|
209
|
+
if (isObject(node.metafields) && Array.isArray(node.metafields.nodes)) {
|
|
210
|
+
normalized.metafields = normalizeMetafieldArray(node.metafields.nodes);
|
|
211
|
+
changed = true;
|
|
212
|
+
}
|
|
213
|
+
if (Array.isArray(node.metafields)) {
|
|
214
|
+
normalized.metafields = normalizeMetafieldArray(node.metafields);
|
|
215
|
+
changed = true;
|
|
216
|
+
}
|
|
217
|
+
return changed ? normalized : node;
|
|
218
|
+
}
|
|
219
|
+
function mapNodesFromConnection(data, connectionPath) {
|
|
220
|
+
const connection = getPathValue(data, connectionPath);
|
|
221
|
+
if (!isObject(connection) || !Array.isArray(connection.nodes)) {
|
|
222
|
+
return [];
|
|
223
|
+
}
|
|
224
|
+
return connection.nodes.filter(isObject).map(normalizeNode);
|
|
225
|
+
}
|
|
226
|
+
function mapSingleNode(data, path) {
|
|
227
|
+
const node = getPathValue(data, path);
|
|
228
|
+
return isObject(node) ? normalizeNode(node) : undefined;
|
|
229
|
+
}
|
|
230
|
+
function mapMutationPayload(data, path) {
|
|
231
|
+
const payload = getPathValue(data, path);
|
|
232
|
+
return isObject(payload) ? payload : undefined;
|
|
233
|
+
}
|
|
234
|
+
function parseLineItems(value) {
|
|
235
|
+
if (!isObject(value) || !Array.isArray(value.items)) {
|
|
236
|
+
return [];
|
|
237
|
+
}
|
|
238
|
+
return value.items
|
|
239
|
+
.filter(isObject)
|
|
240
|
+
.map((item) => {
|
|
241
|
+
const variantId = asString(item.variantId);
|
|
242
|
+
const quantity = asNumber(item.quantity);
|
|
243
|
+
if (!variantId || !quantity) {
|
|
244
|
+
return undefined;
|
|
245
|
+
}
|
|
246
|
+
return {
|
|
247
|
+
variantId,
|
|
248
|
+
quantity: Math.max(1, Math.trunc(quantity)),
|
|
249
|
+
};
|
|
250
|
+
})
|
|
251
|
+
.filter((item) => item !== undefined);
|
|
252
|
+
}
|
|
253
|
+
function parseCollectionProductIds(value) {
|
|
254
|
+
if (!isObject(value) || !Array.isArray(value.items)) {
|
|
255
|
+
return undefined;
|
|
256
|
+
}
|
|
257
|
+
const productIds = value.items
|
|
258
|
+
.filter(isObject)
|
|
259
|
+
.map((item) => asString(item.productId))
|
|
260
|
+
.filter((item) => !!item);
|
|
261
|
+
return productIds.length > 0 ? Array.from(new Set(productIds)) : undefined;
|
|
262
|
+
}
|
|
263
|
+
function parseCollectionRules(value) {
|
|
264
|
+
if (!isObject(value) || !Array.isArray(value.items)) {
|
|
265
|
+
return undefined;
|
|
266
|
+
}
|
|
267
|
+
function resolveMetafieldConditionValue(item) {
|
|
268
|
+
const encodedRule = asString(item.metafieldRule);
|
|
269
|
+
if (!encodedRule) {
|
|
270
|
+
return undefined;
|
|
271
|
+
}
|
|
272
|
+
const decodedRule = (0, ruleConditions_1.decodeMetafieldRuleOptionValue)(encodedRule);
|
|
273
|
+
if (!decodedRule) {
|
|
274
|
+
return undefined;
|
|
275
|
+
}
|
|
276
|
+
switch (decodedRule.valueType) {
|
|
277
|
+
case 'boolean': {
|
|
278
|
+
const booleanValue = asBoolean(item.metafieldValueBoolean);
|
|
279
|
+
return booleanValue === undefined ? undefined : booleanValue ? 'true' : 'false';
|
|
280
|
+
}
|
|
281
|
+
case 'number': {
|
|
282
|
+
const numberValue = asNumber(item.metafieldValueNumber);
|
|
283
|
+
return numberValue === undefined ? undefined : String(numberValue);
|
|
284
|
+
}
|
|
285
|
+
case 'metaobject_reference':
|
|
286
|
+
return asString(item.metafieldValueMetaobjectId);
|
|
287
|
+
case 'text':
|
|
288
|
+
default:
|
|
289
|
+
return asString(item.metafieldValueText);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
const rules = value.items
|
|
293
|
+
.filter(isObject)
|
|
294
|
+
.map((item) => {
|
|
295
|
+
var _a;
|
|
296
|
+
const source = (_a = asString(item.ruleSource)) !== null && _a !== void 0 ? _a : 'native';
|
|
297
|
+
const nativeRelation = asString(item.nativeRelation);
|
|
298
|
+
if (source === 'metafield') {
|
|
299
|
+
const encodedRule = asString(item.metafieldRule);
|
|
300
|
+
const decodedRule = encodedRule ? (0, ruleConditions_1.decodeMetafieldRuleOptionValue)(encodedRule) : undefined;
|
|
301
|
+
const condition = resolveMetafieldConditionValue(item);
|
|
302
|
+
const effectiveRelation = asString(decodedRule === null || decodedRule === void 0 ? void 0 : decodedRule.defaultRelation);
|
|
303
|
+
if (!decodedRule || !effectiveRelation || condition === undefined) {
|
|
304
|
+
return undefined;
|
|
305
|
+
}
|
|
306
|
+
return {
|
|
307
|
+
column: decodedRule.ruleType,
|
|
308
|
+
relation: effectiveRelation,
|
|
309
|
+
condition,
|
|
310
|
+
conditionObjectId: decodedRule.definitionId,
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
const column = asString(item.nativeRuleType);
|
|
314
|
+
const condition = asString(item.nativeValue);
|
|
315
|
+
if (!column || !nativeRelation || condition === undefined) {
|
|
316
|
+
return undefined;
|
|
317
|
+
}
|
|
318
|
+
const parsedRule = {
|
|
319
|
+
column,
|
|
320
|
+
relation: nativeRelation,
|
|
321
|
+
condition,
|
|
322
|
+
};
|
|
323
|
+
return parsedRule;
|
|
324
|
+
})
|
|
325
|
+
.filter((item) => item !== undefined);
|
|
326
|
+
return rules.length > 0 ? rules : undefined;
|
|
327
|
+
}
|
|
328
|
+
function parseValidations(value) {
|
|
329
|
+
if (!isObject(value) || !Array.isArray(value.items)) {
|
|
330
|
+
return undefined;
|
|
331
|
+
}
|
|
332
|
+
const validations = value.items
|
|
333
|
+
.filter(isObject)
|
|
334
|
+
.map((item) => {
|
|
335
|
+
const name = asString(item.name);
|
|
336
|
+
const validationValue = asString(item.value);
|
|
337
|
+
if (!name || validationValue === undefined) {
|
|
338
|
+
return undefined;
|
|
339
|
+
}
|
|
340
|
+
return {
|
|
341
|
+
name,
|
|
342
|
+
value: validationValue,
|
|
343
|
+
};
|
|
344
|
+
})
|
|
345
|
+
.filter((validation) => validation !== undefined);
|
|
346
|
+
return validations.length > 0 ? validations : undefined;
|
|
347
|
+
}
|
|
348
|
+
function parseMetaobjectFieldInputs(value) {
|
|
349
|
+
if (!isObject(value) || !Array.isArray(value.items)) {
|
|
350
|
+
return undefined;
|
|
351
|
+
}
|
|
352
|
+
const fields = value.items
|
|
353
|
+
.filter(isObject)
|
|
354
|
+
.map((item) => {
|
|
355
|
+
const key = asString(item.key);
|
|
356
|
+
const fieldValue = asString(item.value);
|
|
357
|
+
if (!key || fieldValue === undefined) {
|
|
358
|
+
return undefined;
|
|
359
|
+
}
|
|
360
|
+
return {
|
|
361
|
+
key,
|
|
362
|
+
value: fieldValue,
|
|
363
|
+
};
|
|
364
|
+
})
|
|
365
|
+
.filter((field) => field !== undefined);
|
|
366
|
+
return fields.length > 0 ? fields : undefined;
|
|
367
|
+
}
|
|
368
|
+
function parseUserErrors(data, path) {
|
|
369
|
+
const payload = getPathValue(data, path);
|
|
370
|
+
if (!isObject(payload) || !Array.isArray(payload.userErrors)) {
|
|
371
|
+
return [];
|
|
372
|
+
}
|
|
373
|
+
return payload.userErrors
|
|
374
|
+
.filter(isObject)
|
|
375
|
+
.map((item) => {
|
|
376
|
+
var _a, _b;
|
|
377
|
+
return ({
|
|
378
|
+
field: Array.isArray(item.field)
|
|
379
|
+
? item.field.filter((fieldPart) => typeof fieldPart === 'string')
|
|
380
|
+
: null,
|
|
381
|
+
message: String((_a = item.message) !== null && _a !== void 0 ? _a : 'Unknown Shopify user error'),
|
|
382
|
+
code: (_b = asString(item.code)) !== null && _b !== void 0 ? _b : null,
|
|
383
|
+
});
|
|
384
|
+
});
|
|
385
|
+
}
|
|
386
|
+
function withId(idFieldName, input, parameters) {
|
|
387
|
+
const id = asString(parameters[idFieldName]);
|
|
388
|
+
if (!id) {
|
|
389
|
+
return input;
|
|
390
|
+
}
|
|
391
|
+
return {
|
|
392
|
+
...input,
|
|
393
|
+
id,
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
const operationRegistry = {
|
|
397
|
+
'product.create': {
|
|
398
|
+
document: product_1.PRODUCT_CREATE_MUTATION,
|
|
399
|
+
buildVariables: (parameters) => ({
|
|
400
|
+
product: {
|
|
401
|
+
title: asString(parameters.title),
|
|
402
|
+
handle: asString(parameters.handle),
|
|
403
|
+
descriptionHtml: asString(parameters.descriptionHtml),
|
|
404
|
+
seo: parseSeoInput(parameters),
|
|
405
|
+
templateSuffix: asString(parameters.templateSuffix),
|
|
406
|
+
vendor: asString(parameters.vendor),
|
|
407
|
+
productType: asString(parameters.productType),
|
|
408
|
+
status: asString(parameters.status),
|
|
409
|
+
tags: parseTags(parameters.tags),
|
|
410
|
+
},
|
|
411
|
+
}),
|
|
412
|
+
mapSimplified: (data) => mapSingleNode(data, ['productCreate', 'product']),
|
|
413
|
+
getUserErrors: (data) => parseUserErrors(data, ['productCreate']),
|
|
414
|
+
},
|
|
415
|
+
'product.get': {
|
|
416
|
+
document: product_1.PRODUCT_GET_QUERY,
|
|
417
|
+
buildVariables: (parameters) => ({
|
|
418
|
+
id: asString(parameters.productId),
|
|
419
|
+
...getMetafieldReadVariables(parameters),
|
|
420
|
+
}),
|
|
421
|
+
mapSimplified: (data) => mapSingleNode(data, ['product']),
|
|
422
|
+
},
|
|
423
|
+
'product.getMany': {
|
|
424
|
+
document: product_1.PRODUCT_GET_MANY_QUERY,
|
|
425
|
+
buildVariables: (parameters) => ({
|
|
426
|
+
...getConnectionVariables(parameters),
|
|
427
|
+
...getMetafieldReadVariables(parameters),
|
|
428
|
+
}),
|
|
429
|
+
mapSimplified: (data) => mapNodesFromConnection(data, ['products']),
|
|
430
|
+
pagination: {
|
|
431
|
+
connectionPath: ['products'],
|
|
432
|
+
},
|
|
433
|
+
},
|
|
434
|
+
'product.update': {
|
|
435
|
+
document: product_1.PRODUCT_UPDATE_MUTATION,
|
|
436
|
+
buildVariables: (parameters) => ({
|
|
437
|
+
product: withId('productId', {
|
|
438
|
+
title: asString(parameters.title),
|
|
439
|
+
handle: asString(parameters.handle),
|
|
440
|
+
descriptionHtml: asString(parameters.descriptionHtml),
|
|
441
|
+
seo: parseSeoInput(parameters),
|
|
442
|
+
templateSuffix: asString(parameters.templateSuffix),
|
|
443
|
+
vendor: asString(parameters.vendor),
|
|
444
|
+
productType: asString(parameters.productType),
|
|
445
|
+
status: asString(parameters.status),
|
|
446
|
+
tags: parseTags(parameters.tags),
|
|
447
|
+
}, parameters),
|
|
448
|
+
}),
|
|
449
|
+
mapSimplified: (data) => mapSingleNode(data, ['productUpdate', 'product']),
|
|
450
|
+
getUserErrors: (data) => parseUserErrors(data, ['productUpdate']),
|
|
451
|
+
},
|
|
452
|
+
'product.delete': {
|
|
453
|
+
document: product_1.PRODUCT_DELETE_MUTATION,
|
|
454
|
+
buildVariables: (parameters) => ({
|
|
455
|
+
input: {
|
|
456
|
+
id: asString(parameters.productId),
|
|
457
|
+
},
|
|
458
|
+
}),
|
|
459
|
+
mapSimplified: (data) => mapMutationPayload(data, ['productDelete']),
|
|
460
|
+
getUserErrors: (data) => parseUserErrors(data, ['productDelete']),
|
|
461
|
+
},
|
|
462
|
+
'productVariant.create': {
|
|
463
|
+
document: productVariant_1.PRODUCT_VARIANT_CREATE_MUTATION,
|
|
464
|
+
buildVariables: (parameters) => {
|
|
465
|
+
var _a, _b;
|
|
466
|
+
return ({
|
|
467
|
+
productId: asString(parameters.productId),
|
|
468
|
+
variants: [
|
|
469
|
+
{
|
|
470
|
+
title: asString(parameters.title),
|
|
471
|
+
sku: asString(parameters.sku),
|
|
472
|
+
barcode: asString(parameters.barcode),
|
|
473
|
+
price: (_a = asNumber(parameters.price)) === null || _a === void 0 ? void 0 : _a.toString(),
|
|
474
|
+
compareAtPrice: (_b = asNumber(parameters.compareAtPrice)) === null || _b === void 0 ? void 0 : _b.toString(),
|
|
475
|
+
taxable: asBoolean(parameters.taxable),
|
|
476
|
+
},
|
|
477
|
+
],
|
|
478
|
+
});
|
|
479
|
+
},
|
|
480
|
+
mapSimplified: (data) => { var _a; return (_a = getPathValue(data, ['productVariantsBulkCreate', 'productVariants'])) !== null && _a !== void 0 ? _a : []; },
|
|
481
|
+
getUserErrors: (data) => parseUserErrors(data, ['productVariantsBulkCreate']),
|
|
482
|
+
},
|
|
483
|
+
'productVariant.get': {
|
|
484
|
+
document: productVariant_1.PRODUCT_VARIANT_GET_QUERY,
|
|
485
|
+
buildVariables: (parameters) => ({
|
|
486
|
+
id: asString(parameters.variantId),
|
|
487
|
+
...getMetafieldReadVariables(parameters),
|
|
488
|
+
}),
|
|
489
|
+
mapSimplified: (data) => mapSingleNode(data, ['productVariant']),
|
|
490
|
+
},
|
|
491
|
+
'productVariant.getMany': {
|
|
492
|
+
document: productVariant_1.PRODUCT_VARIANT_GET_MANY_QUERY,
|
|
493
|
+
buildVariables: (parameters) => ({
|
|
494
|
+
...getConnectionVariables(parameters),
|
|
495
|
+
...getMetafieldReadVariables(parameters),
|
|
496
|
+
}),
|
|
497
|
+
mapSimplified: (data) => mapNodesFromConnection(data, ['productVariants']),
|
|
498
|
+
pagination: {
|
|
499
|
+
connectionPath: ['productVariants'],
|
|
500
|
+
},
|
|
501
|
+
},
|
|
502
|
+
'productVariant.update': {
|
|
503
|
+
document: productVariant_1.PRODUCT_VARIANT_UPDATE_MUTATION,
|
|
504
|
+
buildVariables: (parameters) => {
|
|
505
|
+
var _a, _b;
|
|
506
|
+
return ({
|
|
507
|
+
productId: asString(parameters.productId),
|
|
508
|
+
variants: [
|
|
509
|
+
{
|
|
510
|
+
id: asString(parameters.variantId),
|
|
511
|
+
title: asString(parameters.title),
|
|
512
|
+
sku: asString(parameters.sku),
|
|
513
|
+
barcode: asString(parameters.barcode),
|
|
514
|
+
price: (_a = asNumber(parameters.price)) === null || _a === void 0 ? void 0 : _a.toString(),
|
|
515
|
+
compareAtPrice: (_b = asNumber(parameters.compareAtPrice)) === null || _b === void 0 ? void 0 : _b.toString(),
|
|
516
|
+
taxable: asBoolean(parameters.taxable),
|
|
517
|
+
},
|
|
518
|
+
],
|
|
519
|
+
});
|
|
520
|
+
},
|
|
521
|
+
mapSimplified: (data) => { var _a; return (_a = getPathValue(data, ['productVariantsBulkUpdate', 'productVariants'])) !== null && _a !== void 0 ? _a : []; },
|
|
522
|
+
getUserErrors: (data) => parseUserErrors(data, ['productVariantsBulkUpdate']),
|
|
523
|
+
},
|
|
524
|
+
'productVariant.delete': {
|
|
525
|
+
document: productVariant_1.PRODUCT_VARIANT_DELETE_MUTATION,
|
|
526
|
+
buildVariables: (parameters) => ({
|
|
527
|
+
productId: asString(parameters.productId),
|
|
528
|
+
variantsIds: [asString(parameters.variantId)].filter((item) => typeof item === 'string'),
|
|
529
|
+
}),
|
|
530
|
+
mapSimplified: (data) => mapMutationPayload(data, ['productVariantsBulkDelete']),
|
|
531
|
+
getUserErrors: (data) => parseUserErrors(data, ['productVariantsBulkDelete']),
|
|
532
|
+
},
|
|
533
|
+
'collection.create': {
|
|
534
|
+
document: collection_1.COLLECTION_CREATE_MUTATION,
|
|
535
|
+
buildVariables: (parameters) => {
|
|
536
|
+
var _a, _b;
|
|
537
|
+
const collectionType = (_a = asString(parameters.collectionType)) !== null && _a !== void 0 ? _a : 'manual';
|
|
538
|
+
const products = parseCollectionProductIds(parameters.manualProducts);
|
|
539
|
+
const rules = parseCollectionRules(parameters.collectionRules);
|
|
540
|
+
const ruleSet = collectionType === 'smart' && rules
|
|
541
|
+
? {
|
|
542
|
+
appliedDisjunctively: ((_b = asString(parameters.smartRuleMatchMode)) !== null && _b !== void 0 ? _b : 'all') === 'any',
|
|
543
|
+
rules,
|
|
544
|
+
}
|
|
545
|
+
: undefined;
|
|
546
|
+
return {
|
|
547
|
+
input: {
|
|
548
|
+
title: asString(parameters.title),
|
|
549
|
+
handle: asString(parameters.handle),
|
|
550
|
+
descriptionHtml: asString(parameters.descriptionHtml),
|
|
551
|
+
seo: parseSeoInput(parameters),
|
|
552
|
+
templateSuffix: asString(parameters.templateSuffix),
|
|
553
|
+
products: collectionType === 'manual' ? products : undefined,
|
|
554
|
+
ruleSet,
|
|
555
|
+
},
|
|
556
|
+
};
|
|
557
|
+
},
|
|
558
|
+
mapSimplified: (data) => mapSingleNode(data, ['collectionCreate', 'collection']),
|
|
559
|
+
getUserErrors: (data) => parseUserErrors(data, ['collectionCreate']),
|
|
560
|
+
},
|
|
561
|
+
'collection.get': {
|
|
562
|
+
document: collection_1.COLLECTION_GET_QUERY,
|
|
563
|
+
buildVariables: (parameters) => ({
|
|
564
|
+
id: asString(parameters.collectionId),
|
|
565
|
+
...getMetafieldReadVariables(parameters),
|
|
566
|
+
}),
|
|
567
|
+
mapSimplified: (data) => mapSingleNode(data, ['collection']),
|
|
568
|
+
},
|
|
569
|
+
'collection.getMany': {
|
|
570
|
+
document: collection_1.COLLECTION_GET_MANY_QUERY,
|
|
571
|
+
buildVariables: (parameters) => ({
|
|
572
|
+
...getConnectionVariables(parameters),
|
|
573
|
+
...getMetafieldReadVariables(parameters),
|
|
574
|
+
}),
|
|
575
|
+
mapSimplified: (data) => mapNodesFromConnection(data, ['collections']),
|
|
576
|
+
pagination: {
|
|
577
|
+
connectionPath: ['collections'],
|
|
578
|
+
},
|
|
579
|
+
},
|
|
580
|
+
'collection.update': {
|
|
581
|
+
document: collection_1.COLLECTION_UPDATE_MUTATION,
|
|
582
|
+
buildVariables: (parameters) => ({
|
|
583
|
+
input: withId('collectionId', {
|
|
584
|
+
title: asString(parameters.title),
|
|
585
|
+
handle: asString(parameters.handle),
|
|
586
|
+
descriptionHtml: asString(parameters.descriptionHtml),
|
|
587
|
+
seo: parseSeoInput(parameters),
|
|
588
|
+
templateSuffix: asString(parameters.templateSuffix),
|
|
589
|
+
}, parameters),
|
|
590
|
+
}),
|
|
591
|
+
mapSimplified: (data) => mapSingleNode(data, ['collectionUpdate', 'collection']),
|
|
592
|
+
getUserErrors: (data) => parseUserErrors(data, ['collectionUpdate']),
|
|
593
|
+
},
|
|
594
|
+
'collection.delete': {
|
|
595
|
+
document: collection_1.COLLECTION_DELETE_MUTATION,
|
|
596
|
+
buildVariables: (parameters) => ({
|
|
597
|
+
input: {
|
|
598
|
+
id: asString(parameters.collectionId),
|
|
599
|
+
},
|
|
600
|
+
}),
|
|
601
|
+
mapSimplified: (data) => mapMutationPayload(data, ['collectionDelete']),
|
|
602
|
+
getUserErrors: (data) => parseUserErrors(data, ['collectionDelete']),
|
|
603
|
+
},
|
|
604
|
+
'customer.create': {
|
|
605
|
+
document: customer_1.CUSTOMER_CREATE_MUTATION,
|
|
606
|
+
buildVariables: (parameters) => ({
|
|
607
|
+
input: {
|
|
608
|
+
email: asString(parameters.email),
|
|
609
|
+
phone: asString(parameters.phone),
|
|
610
|
+
firstName: asString(parameters.firstName),
|
|
611
|
+
lastName: asString(parameters.lastName),
|
|
612
|
+
note: asString(parameters.note),
|
|
613
|
+
taxExempt: asBoolean(parameters.taxExempt),
|
|
614
|
+
tags: parseTags(parameters.tags),
|
|
615
|
+
},
|
|
616
|
+
}),
|
|
617
|
+
mapSimplified: (data) => mapSingleNode(data, ['customerCreate', 'customer']),
|
|
618
|
+
getUserErrors: (data) => parseUserErrors(data, ['customerCreate']),
|
|
619
|
+
},
|
|
620
|
+
'customer.get': {
|
|
621
|
+
document: customer_1.CUSTOMER_GET_QUERY,
|
|
622
|
+
buildVariables: (parameters) => ({
|
|
623
|
+
id: asString(parameters.customerId),
|
|
624
|
+
...getMetafieldReadVariables(parameters),
|
|
625
|
+
}),
|
|
626
|
+
mapSimplified: (data) => mapSingleNode(data, ['customer']),
|
|
627
|
+
},
|
|
628
|
+
'customer.getMany': {
|
|
629
|
+
document: customer_1.CUSTOMER_GET_MANY_QUERY,
|
|
630
|
+
buildVariables: (parameters) => ({
|
|
631
|
+
...getConnectionVariables(parameters),
|
|
632
|
+
...getMetafieldReadVariables(parameters),
|
|
633
|
+
}),
|
|
634
|
+
mapSimplified: (data) => mapNodesFromConnection(data, ['customers']),
|
|
635
|
+
pagination: {
|
|
636
|
+
connectionPath: ['customers'],
|
|
637
|
+
},
|
|
638
|
+
},
|
|
639
|
+
'customer.update': {
|
|
640
|
+
document: customer_1.CUSTOMER_UPDATE_MUTATION,
|
|
641
|
+
buildVariables: (parameters) => ({
|
|
642
|
+
input: withId('customerId', {
|
|
643
|
+
email: asString(parameters.email),
|
|
644
|
+
phone: asString(parameters.phone),
|
|
645
|
+
firstName: asString(parameters.firstName),
|
|
646
|
+
lastName: asString(parameters.lastName),
|
|
647
|
+
note: asString(parameters.note),
|
|
648
|
+
taxExempt: asBoolean(parameters.taxExempt),
|
|
649
|
+
tags: parseTags(parameters.tags),
|
|
650
|
+
}, parameters),
|
|
651
|
+
}),
|
|
652
|
+
mapSimplified: (data) => mapSingleNode(data, ['customerUpdate', 'customer']),
|
|
653
|
+
getUserErrors: (data) => parseUserErrors(data, ['customerUpdate']),
|
|
654
|
+
},
|
|
655
|
+
'customer.delete': {
|
|
656
|
+
document: customer_1.CUSTOMER_DELETE_MUTATION,
|
|
657
|
+
buildVariables: (parameters) => ({
|
|
658
|
+
input: {
|
|
659
|
+
id: asString(parameters.customerId),
|
|
660
|
+
},
|
|
661
|
+
}),
|
|
662
|
+
mapSimplified: (data) => mapMutationPayload(data, ['customerDelete']),
|
|
663
|
+
getUserErrors: (data) => parseUserErrors(data, ['customerDelete']),
|
|
664
|
+
},
|
|
665
|
+
'order.create': {
|
|
666
|
+
document: order_1.ORDER_CREATE_MUTATION,
|
|
667
|
+
buildVariables: (parameters) => ({
|
|
668
|
+
order: {
|
|
669
|
+
email: asString(parameters.email),
|
|
670
|
+
note: asString(parameters.note),
|
|
671
|
+
tags: parseTags(parameters.tags),
|
|
672
|
+
lineItems: parseLineItems(parameters.lineItems),
|
|
673
|
+
},
|
|
674
|
+
}),
|
|
675
|
+
mapSimplified: (data) => mapSingleNode(data, ['orderCreate', 'order']),
|
|
676
|
+
getUserErrors: (data) => parseUserErrors(data, ['orderCreate']),
|
|
677
|
+
},
|
|
678
|
+
'order.get': {
|
|
679
|
+
document: order_1.ORDER_GET_QUERY,
|
|
680
|
+
buildVariables: (parameters) => ({
|
|
681
|
+
id: asString(parameters.orderId),
|
|
682
|
+
...getMetafieldReadVariables(parameters),
|
|
683
|
+
}),
|
|
684
|
+
mapSimplified: (data) => mapSingleNode(data, ['order']),
|
|
685
|
+
},
|
|
686
|
+
'order.getMany': {
|
|
687
|
+
document: order_1.ORDER_GET_MANY_QUERY,
|
|
688
|
+
buildVariables: (parameters) => ({
|
|
689
|
+
...getConnectionVariables(parameters),
|
|
690
|
+
...getMetafieldReadVariables(parameters),
|
|
691
|
+
}),
|
|
692
|
+
mapSimplified: (data) => mapNodesFromConnection(data, ['orders']),
|
|
693
|
+
pagination: {
|
|
694
|
+
connectionPath: ['orders'],
|
|
695
|
+
},
|
|
696
|
+
},
|
|
697
|
+
'order.update': {
|
|
698
|
+
document: order_1.ORDER_UPDATE_MUTATION,
|
|
699
|
+
buildVariables: (parameters) => ({
|
|
700
|
+
input: {
|
|
701
|
+
id: asString(parameters.orderId),
|
|
702
|
+
email: asString(parameters.email),
|
|
703
|
+
note: asString(parameters.note),
|
|
704
|
+
tags: parseTags(parameters.tags),
|
|
705
|
+
},
|
|
706
|
+
}),
|
|
707
|
+
mapSimplified: (data) => mapSingleNode(data, ['orderUpdate', 'order']),
|
|
708
|
+
getUserErrors: (data) => parseUserErrors(data, ['orderUpdate']),
|
|
709
|
+
},
|
|
710
|
+
'order.delete': {
|
|
711
|
+
document: order_1.ORDER_DELETE_MUTATION,
|
|
712
|
+
buildVariables: (parameters) => ({
|
|
713
|
+
orderId: asString(parameters.orderId),
|
|
714
|
+
}),
|
|
715
|
+
mapSimplified: (data) => mapMutationPayload(data, ['orderDelete']),
|
|
716
|
+
getUserErrors: (data) => parseUserErrors(data, ['orderDelete']),
|
|
717
|
+
},
|
|
718
|
+
'draftOrder.create': {
|
|
719
|
+
document: draftOrder_1.DRAFT_ORDER_CREATE_MUTATION,
|
|
720
|
+
buildVariables: (parameters) => ({
|
|
721
|
+
input: {
|
|
722
|
+
email: asString(parameters.email),
|
|
723
|
+
note: asString(parameters.note),
|
|
724
|
+
tags: parseTags(parameters.tags),
|
|
725
|
+
lineItems: parseLineItems(parameters.lineItems),
|
|
726
|
+
},
|
|
727
|
+
}),
|
|
728
|
+
mapSimplified: (data) => mapSingleNode(data, ['draftOrderCreate', 'draftOrder']),
|
|
729
|
+
getUserErrors: (data) => parseUserErrors(data, ['draftOrderCreate']),
|
|
730
|
+
},
|
|
731
|
+
'draftOrder.get': {
|
|
732
|
+
document: draftOrder_1.DRAFT_ORDER_GET_QUERY,
|
|
733
|
+
buildVariables: (parameters) => ({
|
|
734
|
+
id: asString(parameters.draftOrderId),
|
|
735
|
+
...getMetafieldReadVariables(parameters),
|
|
736
|
+
}),
|
|
737
|
+
mapSimplified: (data) => mapSingleNode(data, ['draftOrder']),
|
|
738
|
+
},
|
|
739
|
+
'draftOrder.getMany': {
|
|
740
|
+
document: draftOrder_1.DRAFT_ORDER_GET_MANY_QUERY,
|
|
741
|
+
buildVariables: (parameters) => ({
|
|
742
|
+
...getConnectionVariables(parameters),
|
|
743
|
+
...getMetafieldReadVariables(parameters),
|
|
744
|
+
}),
|
|
745
|
+
mapSimplified: (data) => mapNodesFromConnection(data, ['draftOrders']),
|
|
746
|
+
pagination: {
|
|
747
|
+
connectionPath: ['draftOrders'],
|
|
748
|
+
},
|
|
749
|
+
},
|
|
750
|
+
'draftOrder.update': {
|
|
751
|
+
document: draftOrder_1.DRAFT_ORDER_UPDATE_MUTATION,
|
|
752
|
+
buildVariables: (parameters) => ({
|
|
753
|
+
id: asString(parameters.draftOrderId),
|
|
754
|
+
input: {
|
|
755
|
+
email: asString(parameters.email),
|
|
756
|
+
note: asString(parameters.note),
|
|
757
|
+
tags: parseTags(parameters.tags),
|
|
758
|
+
lineItems: parseLineItems(parameters.lineItems),
|
|
759
|
+
},
|
|
760
|
+
}),
|
|
761
|
+
mapSimplified: (data) => mapSingleNode(data, ['draftOrderUpdate', 'draftOrder']),
|
|
762
|
+
getUserErrors: (data) => parseUserErrors(data, ['draftOrderUpdate']),
|
|
763
|
+
},
|
|
764
|
+
'draftOrder.delete': {
|
|
765
|
+
document: draftOrder_1.DRAFT_ORDER_DELETE_MUTATION,
|
|
766
|
+
buildVariables: (parameters) => ({
|
|
767
|
+
input: {
|
|
768
|
+
id: asString(parameters.draftOrderId),
|
|
769
|
+
},
|
|
770
|
+
}),
|
|
771
|
+
mapSimplified: (data) => mapMutationPayload(data, ['draftOrderDelete']),
|
|
772
|
+
getUserErrors: (data) => parseUserErrors(data, ['draftOrderDelete']),
|
|
773
|
+
},
|
|
774
|
+
'metaobject.create': {
|
|
775
|
+
document: metaobject_1.METAOBJECT_CREATE_MUTATION,
|
|
776
|
+
buildVariables: (parameters) => ({
|
|
777
|
+
metaobject: {
|
|
778
|
+
type: asString(parameters.metaobjectType),
|
|
779
|
+
handle: asString(parameters.handle),
|
|
780
|
+
fields: parseMetaobjectFieldInputs(parameters.metaobjectFields),
|
|
781
|
+
},
|
|
782
|
+
}),
|
|
783
|
+
mapSimplified: (data) => mapSingleNode(data, ['metaobjectCreate', 'metaobject']),
|
|
784
|
+
getUserErrors: (data) => parseUserErrors(data, ['metaobjectCreate']),
|
|
785
|
+
},
|
|
786
|
+
'metaobject.get': {
|
|
787
|
+
document: metaobject_1.METAOBJECT_GET_QUERY,
|
|
788
|
+
buildVariables: (parameters) => ({
|
|
789
|
+
id: asString(parameters.metaobjectId),
|
|
790
|
+
}),
|
|
791
|
+
mapSimplified: (data) => mapSingleNode(data, ['metaobject']),
|
|
792
|
+
},
|
|
793
|
+
'metaobject.getMany': {
|
|
794
|
+
document: metaobject_1.METAOBJECT_GET_MANY_QUERY,
|
|
795
|
+
buildVariables: (parameters) => ({
|
|
796
|
+
type: asString(parameters.metaobjectType),
|
|
797
|
+
...getConnectionVariables(parameters),
|
|
798
|
+
}),
|
|
799
|
+
mapSimplified: (data) => mapNodesFromConnection(data, ['metaobjects']),
|
|
800
|
+
pagination: {
|
|
801
|
+
connectionPath: ['metaobjects'],
|
|
802
|
+
},
|
|
803
|
+
},
|
|
804
|
+
'metaobject.update': {
|
|
805
|
+
document: metaobject_1.METAOBJECT_UPDATE_MUTATION,
|
|
806
|
+
buildVariables: (parameters) => ({
|
|
807
|
+
id: asString(parameters.metaobjectId),
|
|
808
|
+
metaobject: {
|
|
809
|
+
handle: asString(parameters.handle),
|
|
810
|
+
fields: parseMetaobjectFieldInputs(parameters.metaobjectFields),
|
|
811
|
+
redirectNewHandle: isObject(parameters.metaobjectOptions)
|
|
812
|
+
? asBoolean(parameters.metaobjectOptions.redirectNewHandle)
|
|
813
|
+
: undefined,
|
|
814
|
+
},
|
|
815
|
+
}),
|
|
816
|
+
mapSimplified: (data) => mapSingleNode(data, ['metaobjectUpdate', 'metaobject']),
|
|
817
|
+
getUserErrors: (data) => parseUserErrors(data, ['metaobjectUpdate']),
|
|
818
|
+
},
|
|
819
|
+
'metaobject.delete': {
|
|
820
|
+
document: metaobject_1.METAOBJECT_DELETE_MUTATION,
|
|
821
|
+
buildVariables: (parameters) => ({
|
|
822
|
+
id: asString(parameters.metaobjectId),
|
|
823
|
+
}),
|
|
824
|
+
mapSimplified: (data) => mapMutationPayload(data, ['metaobjectDelete']),
|
|
825
|
+
getUserErrors: (data) => parseUserErrors(data, ['metaobjectDelete']),
|
|
826
|
+
},
|
|
827
|
+
'metafieldValue.set': {
|
|
828
|
+
document: metafields_1.METAFIELD_SET_MUTATION,
|
|
829
|
+
buildVariables: (parameters) => ({
|
|
830
|
+
metafields: Array.isArray(parameters.metafieldsPayload)
|
|
831
|
+
? parameters.metafieldsPayload
|
|
832
|
+
: [],
|
|
833
|
+
}),
|
|
834
|
+
mapSimplified: (data) => normalizeMetafieldArray(getPathValue(data, ['metafieldsSet', 'metafields'])),
|
|
835
|
+
getUserErrors: (data) => parseUserErrors(data, ['metafieldsSet']),
|
|
836
|
+
},
|
|
837
|
+
'metafieldValue.get': {
|
|
838
|
+
document: metafields_1.METAFIELD_GET_QUERY,
|
|
839
|
+
buildVariables: (parameters) => ({
|
|
840
|
+
ownerId: asString(parameters.ownerId),
|
|
841
|
+
namespace: asString(parameters.namespace),
|
|
842
|
+
key: asString(parameters.key),
|
|
843
|
+
}),
|
|
844
|
+
mapSimplified: (data) => {
|
|
845
|
+
var _a;
|
|
846
|
+
const nodes = getPathValue(data, ['nodes']);
|
|
847
|
+
if (!Array.isArray(nodes) || nodes.length === 0 || !isObject(nodes[0])) {
|
|
848
|
+
return undefined;
|
|
849
|
+
}
|
|
850
|
+
const node = nodes[0];
|
|
851
|
+
const metafield = (_a = node.metafield) !== null && _a !== void 0 ? _a : undefined;
|
|
852
|
+
return metafield ? normalizeMetafieldNode(metafield) : undefined;
|
|
853
|
+
},
|
|
854
|
+
},
|
|
855
|
+
'metafieldValue.getMany': {
|
|
856
|
+
document: metafields_1.METAFIELD_GET_MANY_QUERY,
|
|
857
|
+
buildVariables: (parameters) => {
|
|
858
|
+
var _a;
|
|
859
|
+
return ({
|
|
860
|
+
ownerId: asString(parameters.ownerId),
|
|
861
|
+
namespace: asString(parameters.namespace),
|
|
862
|
+
first: Math.max(1, Math.trunc((_a = asNumber(parameters.limit)) !== null && _a !== void 0 ? _a : 50)),
|
|
863
|
+
after: asString(parameters.afterCursor),
|
|
864
|
+
});
|
|
865
|
+
},
|
|
866
|
+
mapSimplified: (data) => {
|
|
867
|
+
const nodes = getPathValue(data, ['nodes']);
|
|
868
|
+
if (!Array.isArray(nodes) || nodes.length === 0 || !isObject(nodes[0])) {
|
|
869
|
+
return [];
|
|
870
|
+
}
|
|
871
|
+
const ownerNode = nodes[0];
|
|
872
|
+
const metafieldsConnection = ownerNode.metafields;
|
|
873
|
+
if (!isObject(metafieldsConnection) || !Array.isArray(metafieldsConnection.nodes)) {
|
|
874
|
+
return [];
|
|
875
|
+
}
|
|
876
|
+
return normalizeMetafieldArray(metafieldsConnection.nodes);
|
|
877
|
+
},
|
|
878
|
+
pagination: {
|
|
879
|
+
connectionPath: ['nodes', '0', 'metafields'],
|
|
880
|
+
},
|
|
881
|
+
},
|
|
882
|
+
'metafieldValue.delete': {
|
|
883
|
+
document: metafields_1.METAFIELD_DELETE_MUTATION,
|
|
884
|
+
buildVariables: (parameters) => ({
|
|
885
|
+
metafields: Array.isArray(parameters.metafieldsPayload)
|
|
886
|
+
? parameters.metafieldsPayload
|
|
887
|
+
: [],
|
|
888
|
+
}),
|
|
889
|
+
mapSimplified: (data) => { var _a; return (_a = getPathValue(data, ['metafieldsDelete', 'deletedMetafields'])) !== null && _a !== void 0 ? _a : []; },
|
|
890
|
+
getUserErrors: (data) => parseUserErrors(data, ['metafieldsDelete']),
|
|
891
|
+
},
|
|
892
|
+
'metafieldDefinition.list': {
|
|
893
|
+
document: metafields_1.METAFIELD_DEFINITION_LIST_QUERY,
|
|
894
|
+
buildVariables: (parameters) => {
|
|
895
|
+
var _a;
|
|
896
|
+
return ({
|
|
897
|
+
ownerType: asString(parameters.ownerType),
|
|
898
|
+
query: asString(parameters.query),
|
|
899
|
+
first: Math.max(1, Math.trunc((_a = asNumber(parameters.limit)) !== null && _a !== void 0 ? _a : 50)),
|
|
900
|
+
after: asString(parameters.afterCursor),
|
|
901
|
+
});
|
|
902
|
+
},
|
|
903
|
+
mapSimplified: (data) => mapNodesFromConnection(data, ['metafieldDefinitions']),
|
|
904
|
+
pagination: {
|
|
905
|
+
connectionPath: ['metafieldDefinitions'],
|
|
906
|
+
},
|
|
907
|
+
},
|
|
908
|
+
'metafieldDefinition.get': {
|
|
909
|
+
document: metafields_1.METAFIELD_DEFINITION_GET_QUERY,
|
|
910
|
+
buildVariables: (parameters) => ({
|
|
911
|
+
id: asString(parameters.definitionId),
|
|
912
|
+
}),
|
|
913
|
+
mapSimplified: (data) => mapSingleNode(data, ['node']),
|
|
914
|
+
},
|
|
915
|
+
'metafieldDefinition.create': {
|
|
916
|
+
document: metafields_1.METAFIELD_DEFINITION_CREATE_MUTATION,
|
|
917
|
+
buildVariables: (parameters) => ({
|
|
918
|
+
definition: {
|
|
919
|
+
ownerType: asString(parameters.ownerType),
|
|
920
|
+
name: asString(parameters.name),
|
|
921
|
+
namespace: asString(parameters.namespace),
|
|
922
|
+
key: asString(parameters.key),
|
|
923
|
+
type: asString(parameters.definitionType),
|
|
924
|
+
description: asString(parameters.description),
|
|
925
|
+
validations: parseValidations(parameters.validations),
|
|
926
|
+
},
|
|
927
|
+
}),
|
|
928
|
+
mapSimplified: (data) => mapSingleNode(data, ['metafieldDefinitionCreate', 'createdDefinition']),
|
|
929
|
+
getUserErrors: (data) => parseUserErrors(data, ['metafieldDefinitionCreate']),
|
|
930
|
+
},
|
|
931
|
+
'metafieldDefinition.update': {
|
|
932
|
+
document: metafields_1.METAFIELD_DEFINITION_UPDATE_MUTATION,
|
|
933
|
+
buildVariables: (parameters) => ({
|
|
934
|
+
definition: {
|
|
935
|
+
id: asString(parameters.definitionId),
|
|
936
|
+
name: asString(parameters.name),
|
|
937
|
+
description: asString(parameters.description),
|
|
938
|
+
validations: parseValidations(parameters.validations),
|
|
939
|
+
},
|
|
940
|
+
}),
|
|
941
|
+
mapSimplified: (data) => mapSingleNode(data, ['metafieldDefinitionUpdate', 'updatedDefinition']),
|
|
942
|
+
getUserErrors: (data) => parseUserErrors(data, ['metafieldDefinitionUpdate']),
|
|
943
|
+
},
|
|
944
|
+
'metafieldDefinition.delete': {
|
|
945
|
+
document: metafields_1.METAFIELD_DEFINITION_DELETE_MUTATION,
|
|
946
|
+
buildVariables: (parameters) => ({
|
|
947
|
+
id: asString(parameters.definitionId),
|
|
948
|
+
deleteAllAssociatedMetafields: asBoolean(parameters.deleteAllAssociatedMetafields),
|
|
949
|
+
}),
|
|
950
|
+
mapSimplified: (data) => mapMutationPayload(data, ['metafieldDefinitionDelete']),
|
|
951
|
+
getUserErrors: (data) => parseUserErrors(data, ['metafieldDefinitionDelete']),
|
|
952
|
+
},
|
|
953
|
+
'service.listDefinitionTypes': {
|
|
954
|
+
document: metafields_1.METAFIELD_DEFINITION_TYPES_QUERY,
|
|
955
|
+
buildVariables: () => ({}),
|
|
956
|
+
mapSimplified: (data) => { var _a; return (_a = getPathValue(data, ['metafieldDefinitionTypes'])) !== null && _a !== void 0 ? _a : []; },
|
|
957
|
+
},
|
|
958
|
+
};
|
|
959
|
+
function getRegistryOperation(operationKey) {
|
|
960
|
+
return operationRegistry[operationKey];
|
|
961
|
+
}
|
|
962
|
+
//# sourceMappingURL=registry.js.map
|