@deenruv/merchant-plugin 1.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.
Files changed (78) hide show
  1. package/LICENSE +23 -0
  2. package/README.md +55 -0
  3. package/dist/plugin-server/api/platform-integration-admin-resolver.d.ts +26 -0
  4. package/dist/plugin-server/api/platform-integration-admin-resolver.js +103 -0
  5. package/dist/plugin-server/constants.d.ts +1 -0
  6. package/dist/plugin-server/constants.js +4 -0
  7. package/dist/plugin-server/e2e/plugin.e2e.test.d.ts +1 -0
  8. package/dist/plugin-server/e2e/plugin.e2e.test.js +36 -0
  9. package/dist/plugin-server/entities/platform-integration-setting.entity.d.ts +10 -0
  10. package/dist/plugin-server/entities/platform-integration-setting.entity.js +37 -0
  11. package/dist/plugin-server/entities/platform-integration-settings.entity.d.ts +9 -0
  12. package/dist/plugin-server/entities/platform-integration-settings.entity.js +33 -0
  13. package/dist/plugin-server/extensions/api-extensions.d.ts +2 -0
  14. package/dist/plugin-server/extensions/api-extensions.js +49 -0
  15. package/dist/plugin-server/index.d.ts +14 -0
  16. package/dist/plugin-server/index.js +100 -0
  17. package/dist/plugin-server/services/facebook-platform-integration.service.d.ts +51 -0
  18. package/dist/plugin-server/services/facebook-platform-integration.service.js +219 -0
  19. package/dist/plugin-server/services/google-platform-integration.service.d.ts +63 -0
  20. package/dist/plugin-server/services/google-platform-integration.service.js +352 -0
  21. package/dist/plugin-server/services/merchant-strategy.service.d.ts +10 -0
  22. package/dist/plugin-server/services/merchant-strategy.service.js +39 -0
  23. package/dist/plugin-server/services/platform-integration.service.d.ts +43 -0
  24. package/dist/plugin-server/services/platform-integration.service.js +282 -0
  25. package/dist/plugin-server/services/subscriber.service.d.ts +30 -0
  26. package/dist/plugin-server/services/subscriber.service.js +90 -0
  27. package/dist/plugin-server/strategies/default-merchant-export-strategy.d.ts +21 -0
  28. package/dist/plugin-server/strategies/default-merchant-export-strategy.js +34 -0
  29. package/dist/plugin-server/types.d.ts +29 -0
  30. package/dist/plugin-server/types.js +2 -0
  31. package/dist/plugin-server/ui/graphql/mutations.ts +23 -0
  32. package/dist/plugin-server/ui/graphql/queries.ts +18 -0
  33. package/dist/plugin-server/ui/graphql/scalars.ts +12 -0
  34. package/dist/plugin-server/ui/pages/FacebookPage.tsx +259 -0
  35. package/dist/plugin-server/ui/pages/GooglePage.tsx +281 -0
  36. package/dist/plugin-server/ui/providers.ts +42 -0
  37. package/dist/plugin-server/ui/routes.ts +18 -0
  38. package/dist/plugin-server/ui/styles/styles.css +3 -0
  39. package/dist/plugin-server/ui/styles/tailwind.css +1297 -0
  40. package/dist/plugin-server/ui/zeus/const.ts +3981 -0
  41. package/dist/plugin-server/ui/zeus/index.ts +18354 -0
  42. package/dist/plugin-server/ui/zeus/typedDocumentNode.ts +30 -0
  43. package/dist/plugin-server/ui.d.ts +2 -0
  44. package/dist/plugin-server/ui.js +15 -0
  45. package/dist/plugin-server/zeus/const.d.ts +6 -0
  46. package/dist/plugin-server/zeus/const.js +3687 -0
  47. package/dist/plugin-server/zeus/index.d.ts +18769 -0
  48. package/dist/plugin-server/zeus/index.js +466 -0
  49. package/dist/plugin-server/zeus/selectors.d.ts +52 -0
  50. package/dist/plugin-server/zeus/selectors.js +51 -0
  51. package/dist/plugin-ui/graphql/mutations.d.ts +29 -0
  52. package/dist/plugin-ui/graphql/mutations.js +17 -0
  53. package/dist/plugin-ui/graphql/queries.d.ts +19 -0
  54. package/dist/plugin-ui/graphql/queries.js +17 -0
  55. package/dist/plugin-ui/graphql/scalars.d.ts +10 -0
  56. package/dist/plugin-ui/graphql/scalars.js +11 -0
  57. package/dist/plugin-ui/index.d.ts +1 -0
  58. package/dist/plugin-ui/index.js +40 -0
  59. package/dist/plugin-ui/locales/en/index.d.ts +8 -0
  60. package/dist/plugin-ui/locales/en/index.js +2 -0
  61. package/dist/plugin-ui/locales/en/merchant.json +7 -0
  62. package/dist/plugin-ui/locales/pl/index.d.ts +8 -0
  63. package/dist/plugin-ui/locales/pl/index.js +2 -0
  64. package/dist/plugin-ui/locales/pl/merchant.json +7 -0
  65. package/dist/plugin-ui/pages/FacebookPage.d.ts +1 -0
  66. package/dist/plugin-ui/pages/FacebookPage.js +130 -0
  67. package/dist/plugin-ui/pages/GooglePage.d.ts +1 -0
  68. package/dist/plugin-ui/pages/GooglePage.js +155 -0
  69. package/dist/plugin-ui/translation-ns.d.ts +1 -0
  70. package/dist/plugin-ui/translation-ns.js +1 -0
  71. package/dist/plugin-ui/tsconfig.json +18 -0
  72. package/dist/plugin-ui/zeus/const.d.ts +6 -0
  73. package/dist/plugin-ui/zeus/const.js +3684 -0
  74. package/dist/plugin-ui/zeus/index.d.ts +18769 -0
  75. package/dist/plugin-ui/zeus/index.js +459 -0
  76. package/dist/plugin-ui/zeus/typedDocumentNode.d.ts +3 -0
  77. package/dist/plugin-ui/zeus/typedDocumentNode.js +9 -0
  78. package/package.json +63 -0
@@ -0,0 +1,466 @@
1
+ "use strict";
2
+ /* eslint-disable */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.$ = exports.GRAPHQL_TYPE_SEPARATOR = exports.START_VAR_NAME = exports.resolverFor = exports.InternalArgsBuilt = exports.ResolveFromPath = exports.purifyGraphQLKey = exports.PrepareScalarPaths = exports.GraphQLError = exports.SEPARATOR = exports.traverseResponse = exports.decodeScalarsInResponse = exports.ZeusScalars = exports.Gql = exports.TypeFromSelector = exports.Selector = exports.ZeusSelect = exports.Zeus = exports.Subscription = exports.SubscriptionThunder = exports.Chain = exports.Thunder = exports.InternalsBuildQuery = exports.apiFetch = exports.apiSubscription = exports.HEADERS = exports.HOST = void 0;
5
+ const const_js_1 = require("./const.js");
6
+ exports.HOST = "http://localhost:3000/admin-api";
7
+ exports.HEADERS = {};
8
+ const apiSubscription = (options) => (query) => {
9
+ var _a, _b, _c;
10
+ try {
11
+ const queryString = options[0] + '?query=' + encodeURIComponent(query);
12
+ const wsString = queryString.replace('http', 'ws');
13
+ const host = (options.length > 1 && ((_b = (_a = options[1]) === null || _a === void 0 ? void 0 : _a.websocket) === null || _b === void 0 ? void 0 : _b[0])) || wsString;
14
+ const webSocketOptions = ((_c = options[1]) === null || _c === void 0 ? void 0 : _c.websocket) || [host];
15
+ const ws = new WebSocket(...webSocketOptions);
16
+ return {
17
+ ws,
18
+ on: (e) => {
19
+ ws.onmessage = (event) => {
20
+ if (event.data) {
21
+ const parsed = JSON.parse(event.data);
22
+ const data = parsed.data;
23
+ return e(data);
24
+ }
25
+ };
26
+ },
27
+ off: (e) => {
28
+ ws.onclose = e;
29
+ },
30
+ error: (e) => {
31
+ ws.onerror = e;
32
+ },
33
+ open: (e) => {
34
+ ws.onopen = e;
35
+ },
36
+ };
37
+ }
38
+ catch (_d) {
39
+ throw new Error('No websockets implemented');
40
+ }
41
+ };
42
+ exports.apiSubscription = apiSubscription;
43
+ const handleFetchResponse = (response) => {
44
+ if (!response.ok) {
45
+ return new Promise((_, reject) => {
46
+ response
47
+ .text()
48
+ .then((text) => {
49
+ try {
50
+ reject(JSON.parse(text));
51
+ }
52
+ catch (err) {
53
+ reject(text);
54
+ }
55
+ })
56
+ .catch(reject);
57
+ });
58
+ }
59
+ return response.json();
60
+ };
61
+ const apiFetch = (options) => (query, variables = {}) => {
62
+ const fetchOptions = options[1] || {};
63
+ if (fetchOptions.method && fetchOptions.method === 'GET') {
64
+ return fetch(`${options[0]}?query=${encodeURIComponent(query)}`, fetchOptions)
65
+ .then(handleFetchResponse)
66
+ .then((response) => {
67
+ if (response.errors) {
68
+ throw new GraphQLError(response);
69
+ }
70
+ return response.data;
71
+ });
72
+ }
73
+ return fetch(`${options[0]}`, Object.assign({ body: JSON.stringify({ query, variables }), method: 'POST', headers: {
74
+ 'Content-Type': 'application/json',
75
+ } }, fetchOptions))
76
+ .then(handleFetchResponse)
77
+ .then((response) => {
78
+ if (response.errors) {
79
+ throw new GraphQLError(response);
80
+ }
81
+ return response.data;
82
+ });
83
+ };
84
+ exports.apiFetch = apiFetch;
85
+ const InternalsBuildQuery = ({ ops, props, returns, options, scalars, }) => {
86
+ const ibb = (k, o, p = '', root = true, vars = []) => {
87
+ var _a;
88
+ const keyForPath = (0, exports.purifyGraphQLKey)(k);
89
+ const newPath = [p, keyForPath].join(exports.SEPARATOR);
90
+ if (!o) {
91
+ return '';
92
+ }
93
+ if (typeof o === 'boolean' || typeof o === 'number') {
94
+ return k;
95
+ }
96
+ if (typeof o === 'string') {
97
+ return `${k} ${o}`;
98
+ }
99
+ if (Array.isArray(o)) {
100
+ const args = (0, exports.InternalArgsBuilt)({
101
+ props,
102
+ returns,
103
+ ops,
104
+ scalars,
105
+ vars,
106
+ })(o[0], newPath);
107
+ return `${ibb(args ? `${k}(${args})` : k, o[1], p, false, vars)}`;
108
+ }
109
+ if (k === '__alias') {
110
+ return Object.entries(o)
111
+ .map(([alias, objectUnderAlias]) => {
112
+ if (typeof objectUnderAlias !== 'object' || Array.isArray(objectUnderAlias)) {
113
+ throw new Error('Invalid alias it should be __alias:{ YOUR_ALIAS_NAME: { OPERATION_NAME: { ...selectors }}}');
114
+ }
115
+ const operationName = Object.keys(objectUnderAlias)[0];
116
+ const operation = objectUnderAlias[operationName];
117
+ return ibb(`${alias}:${operationName}`, operation, p, false, vars);
118
+ })
119
+ .join('\n');
120
+ }
121
+ const hasOperationName = root && (options === null || options === void 0 ? void 0 : options.operationName) ? ' ' + options.operationName : '';
122
+ const keyForDirectives = (_a = o.__directives) !== null && _a !== void 0 ? _a : '';
123
+ const query = `{${Object.entries(o)
124
+ .filter(([k]) => k !== '__directives')
125
+ .map((e) => ibb(...e, [p, `field<>${keyForPath}`].join(exports.SEPARATOR), false, vars))
126
+ .join('\n')}}`;
127
+ if (!root) {
128
+ return `${k} ${keyForDirectives}${hasOperationName} ${query}`;
129
+ }
130
+ const varsString = vars.map((v) => `${v.name}: ${v.graphQLType}`).join(', ');
131
+ return `${k} ${keyForDirectives}${hasOperationName}${varsString ? `(${varsString})` : ''} ${query}`;
132
+ };
133
+ return ibb;
134
+ };
135
+ exports.InternalsBuildQuery = InternalsBuildQuery;
136
+ const Thunder = (fn, thunderGraphQLOptions) => (operation, graphqlOptions) => (o, ops) => {
137
+ const options = Object.assign(Object.assign({}, thunderGraphQLOptions), graphqlOptions);
138
+ return fn((0, exports.Zeus)(operation, o, {
139
+ operationOptions: ops,
140
+ scalars: options === null || options === void 0 ? void 0 : options.scalars,
141
+ }), ops === null || ops === void 0 ? void 0 : ops.variables).then((data) => {
142
+ if (options === null || options === void 0 ? void 0 : options.scalars) {
143
+ return (0, exports.decodeScalarsInResponse)({
144
+ response: data,
145
+ initialOp: operation,
146
+ initialZeusQuery: o,
147
+ returns: const_js_1.ReturnTypes,
148
+ scalars: options.scalars,
149
+ ops: const_js_1.Ops,
150
+ });
151
+ }
152
+ return data;
153
+ });
154
+ };
155
+ exports.Thunder = Thunder;
156
+ const Chain = (...options) => (0, exports.Thunder)((0, exports.apiFetch)(options));
157
+ exports.Chain = Chain;
158
+ const SubscriptionThunder = (fn, thunderGraphQLOptions) => (operation, graphqlOptions) => (o, ops) => {
159
+ const options = Object.assign(Object.assign({}, thunderGraphQLOptions), graphqlOptions);
160
+ const returnedFunction = fn((0, exports.Zeus)(operation, o, {
161
+ operationOptions: ops,
162
+ scalars: options === null || options === void 0 ? void 0 : options.scalars,
163
+ }));
164
+ if ((returnedFunction === null || returnedFunction === void 0 ? void 0 : returnedFunction.on) && (options === null || options === void 0 ? void 0 : options.scalars)) {
165
+ const wrapped = returnedFunction.on;
166
+ returnedFunction.on = (fnToCall) => wrapped((data) => {
167
+ if (options === null || options === void 0 ? void 0 : options.scalars) {
168
+ return fnToCall((0, exports.decodeScalarsInResponse)({
169
+ response: data,
170
+ initialOp: operation,
171
+ initialZeusQuery: o,
172
+ returns: const_js_1.ReturnTypes,
173
+ scalars: options.scalars,
174
+ ops: const_js_1.Ops,
175
+ }));
176
+ }
177
+ return fnToCall(data);
178
+ });
179
+ }
180
+ return returnedFunction;
181
+ };
182
+ exports.SubscriptionThunder = SubscriptionThunder;
183
+ const Subscription = (...options) => (0, exports.SubscriptionThunder)((0, exports.apiSubscription)(options));
184
+ exports.Subscription = Subscription;
185
+ const Zeus = (operation, o, ops) => (0, exports.InternalsBuildQuery)({
186
+ props: const_js_1.AllTypesProps,
187
+ returns: const_js_1.ReturnTypes,
188
+ ops: const_js_1.Ops,
189
+ options: ops === null || ops === void 0 ? void 0 : ops.operationOptions,
190
+ scalars: ops === null || ops === void 0 ? void 0 : ops.scalars,
191
+ })(operation, o);
192
+ exports.Zeus = Zeus;
193
+ const ZeusSelect = () => ((t) => t);
194
+ exports.ZeusSelect = ZeusSelect;
195
+ const Selector = (key) => key && (0, exports.ZeusSelect)();
196
+ exports.Selector = Selector;
197
+ const TypeFromSelector = (key) => key && (0, exports.ZeusSelect)();
198
+ exports.TypeFromSelector = TypeFromSelector;
199
+ exports.Gql = (0, exports.Chain)(exports.HOST, {
200
+ headers: Object.assign({ 'Content-Type': 'application/json' }, exports.HEADERS),
201
+ });
202
+ exports.ZeusScalars = (0, exports.ZeusSelect)();
203
+ const decodeScalarsInResponse = ({ response, scalars, returns, ops, initialZeusQuery, initialOp, }) => {
204
+ if (!scalars) {
205
+ return response;
206
+ }
207
+ const builder = (0, exports.PrepareScalarPaths)({
208
+ ops,
209
+ returns,
210
+ });
211
+ const scalarPaths = builder(initialOp, ops[initialOp], initialZeusQuery);
212
+ if (scalarPaths) {
213
+ const r = (0, exports.traverseResponse)({ scalarPaths, resolvers: scalars })(initialOp, response, [ops[initialOp]]);
214
+ return r;
215
+ }
216
+ return response;
217
+ };
218
+ exports.decodeScalarsInResponse = decodeScalarsInResponse;
219
+ const traverseResponse = ({ resolvers, scalarPaths, }) => {
220
+ const ibb = (k, o, p = []) => {
221
+ var _a;
222
+ if (Array.isArray(o)) {
223
+ return o.map((eachO) => ibb(k, eachO, p));
224
+ }
225
+ if (o == null) {
226
+ return o;
227
+ }
228
+ const scalarPathString = p.join(exports.SEPARATOR);
229
+ const currentScalarString = scalarPaths[scalarPathString];
230
+ if (currentScalarString) {
231
+ const currentDecoder = (_a = resolvers[currentScalarString.split('.')[1]]) === null || _a === void 0 ? void 0 : _a.decode;
232
+ if (currentDecoder) {
233
+ return currentDecoder(o);
234
+ }
235
+ }
236
+ if (typeof o === 'boolean' || typeof o === 'number' || typeof o === 'string' || !o) {
237
+ return o;
238
+ }
239
+ const entries = Object.entries(o).map(([k, v]) => [k, ibb(k, v, [...p, (0, exports.purifyGraphQLKey)(k)])]);
240
+ const objectFromEntries = entries.reduce((a, [k, v]) => {
241
+ a[k] = v;
242
+ return a;
243
+ }, {});
244
+ return objectFromEntries;
245
+ };
246
+ return ibb;
247
+ };
248
+ exports.traverseResponse = traverseResponse;
249
+ exports.SEPARATOR = '|';
250
+ class GraphQLError extends Error {
251
+ constructor(response) {
252
+ super('');
253
+ this.response = response;
254
+ console.error(response);
255
+ }
256
+ toString() {
257
+ return 'GraphQL Response Error';
258
+ }
259
+ }
260
+ exports.GraphQLError = GraphQLError;
261
+ const ExtractScalar = (mappedParts, returns) => {
262
+ if (mappedParts.length === 0) {
263
+ return;
264
+ }
265
+ const oKey = mappedParts[0];
266
+ const returnP1 = returns[oKey];
267
+ if (typeof returnP1 === 'object') {
268
+ const returnP2 = returnP1[mappedParts[1]];
269
+ if (returnP2) {
270
+ return ExtractScalar([returnP2, ...mappedParts.slice(2)], returns);
271
+ }
272
+ return undefined;
273
+ }
274
+ return returnP1;
275
+ };
276
+ const PrepareScalarPaths = ({ ops, returns }) => {
277
+ const ibb = (k, originalKey, o, p = [], pOriginals = [], root = true) => {
278
+ if (!o) {
279
+ return;
280
+ }
281
+ if (typeof o === 'boolean' || typeof o === 'number' || typeof o === 'string') {
282
+ const extractionArray = [...pOriginals, originalKey];
283
+ const isScalar = ExtractScalar(extractionArray, returns);
284
+ if (isScalar === null || isScalar === void 0 ? void 0 : isScalar.startsWith('scalar')) {
285
+ const partOfTree = {
286
+ [[...p, k].join(exports.SEPARATOR)]: isScalar,
287
+ };
288
+ return partOfTree;
289
+ }
290
+ return {};
291
+ }
292
+ if (Array.isArray(o)) {
293
+ return ibb(k, k, o[1], p, pOriginals, false);
294
+ }
295
+ if (k === '__alias') {
296
+ return Object.entries(o)
297
+ .map(([alias, objectUnderAlias]) => {
298
+ if (typeof objectUnderAlias !== 'object' || Array.isArray(objectUnderAlias)) {
299
+ throw new Error('Invalid alias it should be __alias:{ YOUR_ALIAS_NAME: { OPERATION_NAME: { ...selectors }}}');
300
+ }
301
+ const operationName = Object.keys(objectUnderAlias)[0];
302
+ const operation = objectUnderAlias[operationName];
303
+ return ibb(alias, operationName, operation, p, pOriginals, false);
304
+ })
305
+ .reduce((a, b) => (Object.assign(Object.assign({}, a), b)));
306
+ }
307
+ const keyName = root ? ops[k] : k;
308
+ return Object.entries(o)
309
+ .filter(([k]) => k !== '__directives')
310
+ .map(([k, v]) => {
311
+ // Inline fragments shouldn't be added to the path as they aren't a field
312
+ const isInlineFragment = originalKey.match(/^...\s*on/) != null;
313
+ return ibb(k, k, v, isInlineFragment ? p : [...p, (0, exports.purifyGraphQLKey)(keyName || k)], isInlineFragment ? pOriginals : [...pOriginals, (0, exports.purifyGraphQLKey)(originalKey)], false);
314
+ })
315
+ .reduce((a, b) => (Object.assign(Object.assign({}, a), b)));
316
+ };
317
+ return ibb;
318
+ };
319
+ exports.PrepareScalarPaths = PrepareScalarPaths;
320
+ const purifyGraphQLKey = (k) => k.replace(/\([^)]*\)/g, '').replace(/^[^:]*\:/g, '');
321
+ exports.purifyGraphQLKey = purifyGraphQLKey;
322
+ const mapPart = (p) => {
323
+ const [isArg, isField] = p.split('<>');
324
+ if (isField) {
325
+ return {
326
+ v: isField,
327
+ __type: 'field',
328
+ };
329
+ }
330
+ return {
331
+ v: isArg,
332
+ __type: 'arg',
333
+ };
334
+ };
335
+ const ResolveFromPath = (props, returns, ops) => {
336
+ const ResolvePropsType = (mappedParts) => {
337
+ const oKey = ops[mappedParts[0].v];
338
+ const propsP1 = oKey ? props[oKey] : props[mappedParts[0].v];
339
+ if (propsP1 === 'enum' && mappedParts.length === 1) {
340
+ return 'enum';
341
+ }
342
+ if (typeof propsP1 === 'string' && propsP1.startsWith('scalar.') && mappedParts.length === 1) {
343
+ return propsP1;
344
+ }
345
+ if (typeof propsP1 === 'object') {
346
+ if (mappedParts.length < 2) {
347
+ return 'not';
348
+ }
349
+ const propsP2 = propsP1[mappedParts[1].v];
350
+ if (typeof propsP2 === 'string') {
351
+ return rpp(`${propsP2}${exports.SEPARATOR}${mappedParts
352
+ .slice(2)
353
+ .map((mp) => mp.v)
354
+ .join(exports.SEPARATOR)}`);
355
+ }
356
+ if (typeof propsP2 === 'object') {
357
+ if (mappedParts.length < 3) {
358
+ return 'not';
359
+ }
360
+ const propsP3 = propsP2[mappedParts[2].v];
361
+ if (propsP3 && mappedParts[2].__type === 'arg') {
362
+ return rpp(`${propsP3}${exports.SEPARATOR}${mappedParts
363
+ .slice(3)
364
+ .map((mp) => mp.v)
365
+ .join(exports.SEPARATOR)}`);
366
+ }
367
+ }
368
+ }
369
+ };
370
+ const ResolveReturnType = (mappedParts) => {
371
+ if (mappedParts.length === 0) {
372
+ return 'not';
373
+ }
374
+ const oKey = ops[mappedParts[0].v];
375
+ const returnP1 = oKey ? returns[oKey] : returns[mappedParts[0].v];
376
+ if (typeof returnP1 === 'object') {
377
+ if (mappedParts.length < 2)
378
+ return 'not';
379
+ const returnP2 = returnP1[mappedParts[1].v];
380
+ if (returnP2) {
381
+ return rpp(`${returnP2}${exports.SEPARATOR}${mappedParts
382
+ .slice(2)
383
+ .map((mp) => mp.v)
384
+ .join(exports.SEPARATOR)}`);
385
+ }
386
+ }
387
+ };
388
+ const rpp = (path) => {
389
+ const parts = path.split(exports.SEPARATOR).filter((l) => l.length > 0);
390
+ const mappedParts = parts.map(mapPart);
391
+ const propsP1 = ResolvePropsType(mappedParts);
392
+ if (propsP1) {
393
+ return propsP1;
394
+ }
395
+ const returnP1 = ResolveReturnType(mappedParts);
396
+ if (returnP1) {
397
+ return returnP1;
398
+ }
399
+ return 'not';
400
+ };
401
+ return rpp;
402
+ };
403
+ exports.ResolveFromPath = ResolveFromPath;
404
+ const InternalArgsBuilt = ({ props, ops, returns, scalars, vars, }) => {
405
+ const arb = (a, p = '', root = true) => {
406
+ var _a, _b;
407
+ if (typeof a === 'string') {
408
+ if (a.startsWith(exports.START_VAR_NAME)) {
409
+ const [varName, graphQLType] = a.replace(exports.START_VAR_NAME, '$').split(exports.GRAPHQL_TYPE_SEPARATOR);
410
+ const v = vars.find((v) => v.name === varName);
411
+ if (!v) {
412
+ vars.push({
413
+ name: varName,
414
+ graphQLType,
415
+ });
416
+ }
417
+ else {
418
+ if (v.graphQLType !== graphQLType) {
419
+ throw new Error(`Invalid variable exists with two different GraphQL Types, "${v.graphQLType}" and ${graphQLType}`);
420
+ }
421
+ }
422
+ return varName;
423
+ }
424
+ }
425
+ const checkType = (0, exports.ResolveFromPath)(props, returns, ops)(p);
426
+ if (checkType.startsWith('scalar.')) {
427
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
428
+ const [_, ...splittedScalar] = checkType.split('.');
429
+ const scalarKey = splittedScalar.join('.');
430
+ return ((_b = (_a = scalars === null || scalars === void 0 ? void 0 : scalars[scalarKey]) === null || _a === void 0 ? void 0 : _a.encode) === null || _b === void 0 ? void 0 : _b.call(_a, a)) || JSON.stringify(a);
431
+ }
432
+ if (Array.isArray(a)) {
433
+ return `[${a.map((arr) => arb(arr, p, false)).join(', ')}]`;
434
+ }
435
+ if (typeof a === 'string') {
436
+ if (checkType === 'enum') {
437
+ return a;
438
+ }
439
+ return `${JSON.stringify(a)}`;
440
+ }
441
+ if (typeof a === 'object') {
442
+ if (a === null) {
443
+ return `null`;
444
+ }
445
+ const returnedObjectString = Object.entries(a)
446
+ .filter(([, v]) => typeof v !== 'undefined')
447
+ .map(([k, v]) => `${k}: ${arb(v, [p, k].join(exports.SEPARATOR), false)}`)
448
+ .join(',\n');
449
+ if (!root) {
450
+ return `{${returnedObjectString}}`;
451
+ }
452
+ return returnedObjectString;
453
+ }
454
+ return `${a}`;
455
+ };
456
+ return arb;
457
+ };
458
+ exports.InternalArgsBuilt = InternalArgsBuilt;
459
+ const resolverFor = (type, field, fn) => fn;
460
+ exports.resolverFor = resolverFor;
461
+ exports.START_VAR_NAME = `$ZEUS_VAR`;
462
+ exports.GRAPHQL_TYPE_SEPARATOR = `__$GRAPHQL__`;
463
+ const $ = (name, graphqlType) => {
464
+ return (exports.START_VAR_NAME + name + exports.GRAPHQL_TYPE_SEPARATOR + graphqlType);
465
+ };
466
+ exports.$ = $;
@@ -0,0 +1,52 @@
1
+ import { FromSelector, GraphQLTypes } from "./index.js";
2
+ export declare const scalars: {
3
+ Money: {
4
+ decode: (e: unknown) => number;
5
+ };
6
+ JSON: {
7
+ encode: (e: unknown) => string;
8
+ decode: (e: unknown) => any;
9
+ };
10
+ DateTime: {
11
+ decode: (e: unknown) => string;
12
+ encode: (e: unknown) => string;
13
+ };
14
+ };
15
+ export type ScalarsType = typeof scalars;
16
+ export type FromSelectorWithScalars<SELECTOR, NAME extends keyof GraphQLTypes> = FromSelector<SELECTOR, NAME, ScalarsType>;
17
+ export declare const ProductSearchSelector: {
18
+ productName: true;
19
+ slug: true;
20
+ collectionIds: true;
21
+ currencyCode: true;
22
+ productVariantId: true;
23
+ productVariantName: true;
24
+ productId: true;
25
+ price: {
26
+ "...on PriceRange": {
27
+ max: true;
28
+ min: true;
29
+ };
30
+ "...on SinglePrice": {
31
+ value: true;
32
+ };
33
+ };
34
+ priceWithTax: {
35
+ "...on PriceRange": {
36
+ max: true;
37
+ min: true;
38
+ };
39
+ "...on SinglePrice": {
40
+ value: true;
41
+ };
42
+ };
43
+ facetIds: true;
44
+ facetValueIds: true;
45
+ productAsset: {
46
+ preview: true;
47
+ };
48
+ description: true;
49
+ sku: true;
50
+ score: true;
51
+ };
52
+ export type ProductSearchType = FromSelectorWithScalars<typeof ProductSearchSelector, "SearchResult">;
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ProductSearchSelector = exports.scalars = void 0;
4
+ const index_js_1 = require("./index.js");
5
+ exports.scalars = (0, index_js_1.ZeusScalars)({
6
+ Money: {
7
+ decode: (e) => e,
8
+ },
9
+ JSON: {
10
+ encode: (e) => JSON.stringify(JSON.stringify(e)),
11
+ decode: (e) => JSON.parse(e),
12
+ },
13
+ DateTime: {
14
+ decode: (e) => new Date(e).toISOString(),
15
+ encode: (e) => e.toISOString(),
16
+ },
17
+ });
18
+ exports.ProductSearchSelector = (0, index_js_1.Selector)("SearchResult")({
19
+ productName: true,
20
+ slug: true,
21
+ collectionIds: true,
22
+ currencyCode: true,
23
+ productVariantId: true,
24
+ productVariantName: true,
25
+ productId: true,
26
+ price: {
27
+ "...on PriceRange": {
28
+ max: true,
29
+ min: true,
30
+ },
31
+ "...on SinglePrice": {
32
+ value: true,
33
+ },
34
+ },
35
+ priceWithTax: {
36
+ "...on PriceRange": {
37
+ max: true,
38
+ min: true,
39
+ },
40
+ "...on SinglePrice": {
41
+ value: true,
42
+ },
43
+ },
44
+ facetIds: true,
45
+ facetValueIds: true,
46
+ productAsset: { preview: true,
47
+ },
48
+ description: true,
49
+ sku: true,
50
+ score: true,
51
+ });
@@ -0,0 +1,29 @@
1
+ export declare const merchantPlatformSettingsSelector: {
2
+ platform: true;
3
+ entries: {
4
+ key: true;
5
+ value: true;
6
+ };
7
+ };
8
+ export declare const saveMerchantPlatformSettings: import("@graphql-typed-document-node/core").TypedDocumentNode<{
9
+ saveMerchantPlatformSettings: {
10
+ entries?: {
11
+ value: string;
12
+ key: string;
13
+ }[] | undefined;
14
+ platform: string;
15
+ };
16
+ }, {} & {
17
+ input: {
18
+ platform: string | import("../zeus/index").Variable<any, string>;
19
+ entries?: import("../zeus/index").Variable<any, string> | {
20
+ key: string | import("../zeus/index").Variable<any, string>;
21
+ value: string | import("../zeus/index").Variable<any, string>;
22
+ }[] | null | undefined;
23
+ };
24
+ }>;
25
+ export declare const removeOrphanItems: import("@graphql-typed-document-node/core").TypedDocumentNode<{
26
+ removeOrphanItems?: boolean | undefined;
27
+ }, {} & {
28
+ platform: string;
29
+ }>;
@@ -0,0 +1,17 @@
1
+ import { $, Selector } from "../zeus/index";
2
+ import { typedGql } from "../zeus/typedDocumentNode";
3
+ import { scalars } from "./scalars";
4
+ const mutation = typedGql("mutation", { scalars });
5
+ export const merchantPlatformSettingsSelector = Selector("MerchantPlatformSettingsEntity")({
6
+ platform: true,
7
+ entries: { key: true, value: true },
8
+ });
9
+ export const saveMerchantPlatformSettings = mutation({
10
+ saveMerchantPlatformSettings: [
11
+ { input: $("input", "SaveMerchantPlatformSettingInput!") },
12
+ merchantPlatformSettingsSelector,
13
+ ],
14
+ });
15
+ export const removeOrphanItems = mutation({
16
+ removeOrphanItems: [{ platform: $("platform", "String!") }, true],
17
+ });
@@ -0,0 +1,19 @@
1
+ export declare const getMerchantPlatformSettings: import("@graphql-typed-document-node/core").TypedDocumentNode<{
2
+ getMerchantPlatformSettings?: {
3
+ entries?: {
4
+ value: string;
5
+ key: string;
6
+ }[] | undefined;
7
+ platform: string;
8
+ } | undefined;
9
+ }, {} & {
10
+ platform: string;
11
+ }>;
12
+ export declare const getMerchantPlatformInfo: import("@graphql-typed-document-node/core").TypedDocumentNode<{
13
+ getMerchantPlatformInfo?: {
14
+ isValidConnection: boolean;
15
+ productsCount: number;
16
+ }[] | undefined;
17
+ }, {} & {
18
+ platform: string;
19
+ }>;
@@ -0,0 +1,17 @@
1
+ import { typedGql } from "../zeus/typedDocumentNode";
2
+ import { scalars } from "./scalars";
3
+ import { merchantPlatformSettingsSelector } from "./mutations";
4
+ import { $ } from "../zeus/index";
5
+ const query = typedGql("query", { scalars });
6
+ export const getMerchantPlatformSettings = query({
7
+ getMerchantPlatformSettings: [
8
+ { platform: $("platform", "String!") },
9
+ merchantPlatformSettingsSelector,
10
+ ],
11
+ });
12
+ export const getMerchantPlatformInfo = query({
13
+ getMerchantPlatformInfo: [
14
+ { platform: $("platform", "String!") },
15
+ { isValidConnection: true, productsCount: true },
16
+ ],
17
+ });
@@ -0,0 +1,10 @@
1
+ export declare const scalars: {
2
+ DateTime: {
3
+ decode: (e: unknown) => string;
4
+ encode: (e: unknown) => string;
5
+ };
6
+ JSON: {
7
+ decode: (e: unknown) => any;
8
+ encode: (e: unknown) => string;
9
+ };
10
+ };
@@ -0,0 +1,11 @@
1
+ import { ZeusScalars } from "../zeus/index";
2
+ export const scalars = ZeusScalars({
3
+ DateTime: {
4
+ decode: (e) => new Date(e).toISOString(),
5
+ encode: (e) => e.toISOString(),
6
+ },
7
+ JSON: {
8
+ decode: (e) => JSON.parse(e),
9
+ encode: (e) => JSON.stringify(e),
10
+ },
11
+ });
@@ -0,0 +1 @@
1
+ export declare const MerchantPluginUI: import("@deenruv/react-ui-devkit").DeenruvUIPlugin<{}>;