cloudcommerce 2.2.3 → 2.3.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 (56) hide show
  1. package/CHANGELOG.md +17 -0
  2. package/ecomplus-stores/barra-doce/functions/many/package.json +3 -3
  3. package/ecomplus-stores/barra-doce/functions/ssr/package.json +6 -6
  4. package/ecomplus-stores/barra-doce/functions/with-apps/package.json +3 -3
  5. package/ecomplus-stores/barra-doce/package.json +2 -2
  6. package/package.json +2 -2
  7. package/packages/api/package.json +1 -1
  8. package/packages/apps/affiliate-program/package.json +1 -1
  9. package/packages/apps/correios/package.json +1 -1
  10. package/packages/apps/custom-payment/package.json +1 -1
  11. package/packages/apps/custom-shipping/package.json +1 -1
  12. package/packages/apps/datafrete/package.json +1 -1
  13. package/packages/apps/discounts/package.json +1 -1
  14. package/packages/apps/emails/package.json +1 -1
  15. package/packages/apps/fb-conversions/package.json +1 -1
  16. package/packages/apps/flash-courier/package.json +1 -1
  17. package/packages/apps/frenet/package.json +1 -1
  18. package/packages/apps/galaxpay/package.json +1 -1
  19. package/packages/apps/google-analytics/package.json +1 -1
  20. package/packages/apps/jadlog/package.json +1 -1
  21. package/packages/apps/loyalty-points/package.json +1 -1
  22. package/packages/apps/mandae/package.json +1 -1
  23. package/packages/apps/melhor-envio/package.json +1 -1
  24. package/packages/apps/mercadopago/package.json +1 -1
  25. package/packages/apps/pagarme/package.json +1 -1
  26. package/packages/apps/pagarme-v5/package.json +1 -1
  27. package/packages/apps/paghiper/package.json +1 -1
  28. package/packages/apps/pix/package.json +1 -1
  29. package/packages/apps/tiny-erp/package.json +1 -1
  30. package/packages/apps/webhooks/package.json +1 -1
  31. package/packages/cli/package.json +1 -1
  32. package/packages/config/package.json +1 -1
  33. package/packages/emails/package.json +1 -1
  34. package/packages/eslint/package.json +1 -1
  35. package/packages/events/package.json +1 -1
  36. package/packages/feeds/package.json +1 -1
  37. package/packages/firebase/package.json +1 -1
  38. package/packages/i18n/package.json +1 -1
  39. package/packages/modules/lib/firebase/handle-module.js +28 -7
  40. package/packages/modules/lib/firebase/handle-module.js.map +1 -1
  41. package/packages/modules/package.json +1 -1
  42. package/packages/modules/src/firebase/handle-module.ts +37 -9
  43. package/packages/passport/package.json +1 -1
  44. package/packages/ssr/lib/lib/cron-ssr-save-views.js +6 -0
  45. package/packages/ssr/lib/lib/cron-ssr-save-views.js.map +1 -1
  46. package/packages/ssr/package.json +2 -2
  47. package/packages/ssr/src/lib/cron-ssr-save-views.ts +6 -0
  48. package/packages/storefront/package.json +2 -2
  49. package/packages/storefront/src/helpers/afetch.ts +22 -5
  50. package/packages/storefront/src/lib/composables/use-pagination.ts +1 -1
  51. package/packages/storefront/src/lib/composables/use-shipping-calculator.ts +273 -0
  52. package/packages/storefront/src/lib/scripts/push-analytics-events.ts +1 -1
  53. package/packages/storefront/src/lib/state/modules-info.ts +34 -10
  54. package/packages/test-base/package.json +1 -1
  55. package/packages/types/index.ts +82 -53
  56. package/packages/types/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"cron-ssr-save-views.js","sourceRoot":"","sources":["../../src/lib/cron-ssr-save-views.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,KAAK,EAAE,MAAM,2BAA2B,CAAC;AAClD,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,GAAG,MAAM,oBAAoB,CAAC;AACrC,OAAO,MAAM,MAAM,oCAAoC,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,+CAA+C,CAAC;AAEjF,MAAM,SAAS,GAAG,KAAK,IAAI,EAAE;IAC3B,qCAAqC;IACrC,MAAM,EAAE,GAAG,YAAY,EAAE,CAAC;IAC1B,MAAM,oBAAoB,GAAG,MAAM,EAAE,CAAC,UAAU,CAAC,iBAAiB,CAAC;SAChE,KAAK,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAA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G,EAAE;YAAE,OAAO;KAClD;IACD,MAAM,cAAc,GAAG,EAAE,CAAC,UAAU,CAAC,cAAc,CAAC;SACjD,KAAK,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;IACrE,MAAM,gBAAgB,CAAC,EAAE,EAAE,cAAc,CAAC,CAAC;AAC7C,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC"}
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/ssr",
3
3
  "type": "module",
4
- "version": "2.2.3",
4
+ "version": "2.3.0",
5
5
  "description": "E-Com Plus Cloud Commerce storefront SSR",
6
6
  "main": "lib/index.js",
7
7
  "exports": {
@@ -32,7 +32,7 @@
32
32
  "@cloudcommerce/i18n": "workspace:*",
33
33
  "@ecomplus/utils": "1.5.0-rc.6",
34
34
  "@vueuse/core": "10.7.2",
35
- "astro": "4.2.7",
35
+ "astro": "4.2.8",
36
36
  "astro-capo": "^0.0.1",
37
37
  "axios": "^1.6.7",
38
38
  "firebase-admin": "^12.0.0",
@@ -148,6 +148,12 @@ const saveViews = async () => {
148
148
  }
149
149
  }
150
150
  }
151
+ const date = new Date();
152
+ if (date.getHours() > 1) return;
153
+ if (!process.env.CRONTAB_SSR_SAVE_VIEWS) {
154
+ const dateMinutes = date.getMinutes();
155
+ if (dateMinutes < 48 || dateMinutes > 50) return;
156
+ }
151
157
  const pageViewsQuery = db.collection('ssrPageViews')
152
158
  .where('at', '<', new Date(Date.now() - 1000 * 60 * 60 * 24 * 90));
153
159
  await deleteQueryBatch(db, pageViewsQuery);
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/storefront",
3
3
  "type": "module",
4
- "version": "2.2.3",
4
+ "version": "2.3.0",
5
5
  "description": "E-Com Plus Cloud Commerce storefront with Astro",
6
6
  "bin": {
7
7
  "storefront": "./scripts/build-prod.sh"
@@ -43,7 +43,7 @@
43
43
  "@types/gtag.js": "^0.0.18",
44
44
  "@vite-pwa/astro": "^0.2.0",
45
45
  "@vueuse/core": "10.7.2",
46
- "astro": "4.2.7",
46
+ "astro": "4.2.8",
47
47
  "astro-capo": "^0.0.1",
48
48
  "chroma-js": "^2.4.2",
49
49
  "dotenv": "^16.4.1",
@@ -1,12 +1,12 @@
1
1
  type FetchParams = Parameters<typeof fetch>;
2
2
  type RequestInit = Exclude<FetchParams[1], undefined>;
3
3
  type BodyInit = RequestInit['body'] | Record<string, any> | Array<any>;
4
+ type AFetchInit = Omit<RequestInit, 'body'> & {
5
+ body?: BodyInit,
6
+ params?: Record<string, string | number | (string | number)[]>,
7
+ };
4
8
 
5
- const afetch = (
6
- url: FetchParams[0],
7
- init?: Omit<RequestInit, 'body'> & { body?: BodyInit },
8
- timeout = 10000,
9
- ) => {
9
+ const afetch = (url: FetchParams[0], init?: AFetchInit, timeout = 10000) => {
10
10
  let abortController: AbortController | undefined;
11
11
  let timer: NodeJS.Timeout | undefined;
12
12
  if (timeout) {
@@ -28,6 +28,23 @@ const afetch = (
28
28
  body = init.body;
29
29
  }
30
30
  }
31
+ if (init?.params && typeof url === 'string') {
32
+ let query = '';
33
+ Object.keys(init.params).forEach((key) => {
34
+ const value: string | number | (string | number)[] = init.params![key];
35
+ if (Array.isArray(value)) {
36
+ value.forEach((val) => {
37
+ query += `&${key}=${val}`;
38
+ });
39
+ return;
40
+ }
41
+ query += `&${key}=${value}`;
42
+ });
43
+ if (query) {
44
+ if (!url.includes('?')) url += `?${query.slice(1)}`;
45
+ else url += query;
46
+ }
47
+ }
31
48
  const promise = fetch(url, {
32
49
  ...init,
33
50
  body,
@@ -56,7 +56,7 @@ const usePagination = (props: Props) => {
56
56
  });
57
57
 
58
58
  const baseUrl = ref('');
59
- watch(toRef(props.isUrlPath), () => {
59
+ watch(toRef(props, 'isUrlPath'), () => {
60
60
  const url = import.meta.env.SSR
61
61
  ? global.astroUrl
62
62
  : new URL(window.location.toString());
@@ -0,0 +1,273 @@
1
+ import type { Ref } from 'vue';
2
+ import type {
3
+ Products,
4
+ Carts,
5
+ CalculateShippingParams,
6
+ CalculateShippingResponse,
7
+ ModuleApiResult,
8
+ } from '@cloudcommerce/types';
9
+ import {
10
+ ref,
11
+ computed,
12
+ shallowReactive,
13
+ watch,
14
+ toRef,
15
+ } from 'vue';
16
+ import { useDebounceFn, watchOnce } from '@vueuse/core';
17
+ import { price as getPrice } from '@ecomplus/utils';
18
+ import config from '@cloudcommerce/config';
19
+ import { fetchModule } from '@@sf/state/modules-info';
20
+
21
+ export type ShippedItem = Exclude<CalculateShippingParams['items'], undefined>[0];
22
+
23
+ export type ShippingService = CalculateShippingResponse['shipping_services'][0];
24
+
25
+ type CartOrProductItem = Carts['items'][0] | (Partial<Products> & {
26
+ product_id: string & { length: 24 },
27
+ price: number,
28
+ quantity: number,
29
+ });
30
+
31
+ export interface Props {
32
+ zipInput?: Ref<HTMLInputElement | null>;
33
+ zipCode?: string;
34
+ canSelectService?: boolean;
35
+ countryCode?: string;
36
+ shippedItems?: (ShippedItem | CartOrProductItem)[];
37
+ shippingResult?: ModuleApiResult<'calculate_shipping'>['result'];
38
+ baseParams?: Partial<CalculateShippingParams>;
39
+ skippedAppIds?: number[];
40
+ appIdsOrder?: number[];
41
+ }
42
+
43
+ const localStorage = typeof window === 'object' && window.localStorage;
44
+
45
+ export const ZIP_STORAGE_KEY = 'shipping-to-zip';
46
+
47
+ const sortApps = (results: any, order: number[]) => {
48
+ return results.sort((a: any, b: any) => {
49
+ if (a.app_id === b.app_id) {
50
+ return 0;
51
+ }
52
+ const indexA = order.indexOf(a.app_id);
53
+ const indexB = order.indexOf(b.app_id);
54
+ if (indexA > -1) {
55
+ if (indexB > -1) {
56
+ return indexA < indexB ? -1 : 1;
57
+ }
58
+ return -1;
59
+ }
60
+ if (indexB > -1) return 1;
61
+ return 0;
62
+ });
63
+ };
64
+ const reduceItemBody = (itemOrProduct: Record<string, any>) => {
65
+ const shippedItem = {};
66
+ const fields: (keyof ShippedItem)[] = [
67
+ 'product_id',
68
+ 'variation_id',
69
+ 'sku',
70
+ 'name',
71
+ 'quantity',
72
+ 'inventory',
73
+ 'currency_id',
74
+ 'currency_symbol',
75
+ 'price',
76
+ 'final_price',
77
+ 'dimensions',
78
+ 'weight',
79
+ ];
80
+ fields.forEach((field) => {
81
+ if (itemOrProduct[field] !== undefined) {
82
+ shippedItem[field] = itemOrProduct[field];
83
+ }
84
+ });
85
+ return shippedItem as ShippedItem;
86
+ };
87
+
88
+ export const useShippingCalculator = (props: Props) => {
89
+ const localZipCode = ref(props.zipCode);
90
+ const zipCode = ref<string | null>(null);
91
+ if (!localZipCode.value && localStorage) {
92
+ const storedZip = localStorage.getItem(ZIP_STORAGE_KEY);
93
+ if (storedZip) {
94
+ localZipCode.value = storedZip;
95
+ }
96
+ }
97
+ const countryCode = props.countryCode || config.get().countryCode;
98
+ const _shippedItems = toRef(props, 'shippedItems');
99
+ const shippedItems = computed(() => {
100
+ return _shippedItems.value?.map(reduceItemBody) || [];
101
+ });
102
+ const amountSubtotal = computed(() => {
103
+ return shippedItems.value.reduce((subtotal, item) => {
104
+ return subtotal + getPrice(item) * item.quantity;
105
+ }, 0);
106
+ });
107
+
108
+ const isFetching = ref(false);
109
+ const fetchShippingServices = useDebounceFn((isRetry?: boolean) => {
110
+ if (isFetching.value) {
111
+ watchOnce((isFetching), (_isFetching) => {
112
+ if (!_isFetching) fetchShippingServices();
113
+ });
114
+ return;
115
+ }
116
+ const body: CalculateShippingParams = {
117
+ ...props.baseParams,
118
+ to: {
119
+ ...props.baseParams?.to,
120
+ zip: localZipCode.value!,
121
+ },
122
+ };
123
+ if (shippedItems.value.length) {
124
+ body.items = shippedItems.value;
125
+ body.subtotal = amountSubtotal.value;
126
+ }
127
+ isFetching.value = true;
128
+ fetchModule('calculate_shipping', {
129
+ method: 'POST',
130
+ params: {
131
+ skip_ids: props.skippedAppIds,
132
+ },
133
+ body,
134
+ })
135
+ .then(async (response) => {
136
+ const data = await response.json();
137
+ // eslint-disable-next-line no-use-before-define
138
+ parseShippingResult(data.result, isRetry);
139
+ })
140
+ .catch((err) => {
141
+ if (!isRetry) {
142
+ // eslint-disable-next-line no-use-before-define
143
+ scheduleRetry(4000);
144
+ }
145
+ console.error(err);
146
+ })
147
+ .finally(() => {
148
+ isFetching.value = false;
149
+ });
150
+ }, 100);
151
+ let retryTimer: NodeJS.Timeout | null = null;
152
+ const scheduleRetry = (timeout = 10000) => {
153
+ if (retryTimer) clearTimeout(retryTimer);
154
+ retryTimer = setTimeout(() => {
155
+ fetchShippingServices(true);
156
+ }, timeout);
157
+ };
158
+
159
+ const shippingServices = shallowReactive<(ShippingService & { app_id: number })[]>([]);
160
+ const freeFromValue = ref<number | null>(null);
161
+ const hasPaidOption = ref<boolean | undefined>();
162
+ const parseShippingResult = (
163
+ shippingResult: ModuleApiResult<'calculate_shipping'>['result'] = [],
164
+ isRetry = false,
165
+ ) => {
166
+ freeFromValue.value = null;
167
+ shippingServices.splice(0);
168
+ if (shippingResult.length) {
169
+ let hasSomeFailedApp = false;
170
+ shippingResult.forEach((appResult) => {
171
+ const { validated, error, response } = appResult;
172
+ if (!validated || error) {
173
+ hasSomeFailedApp = true;
174
+ return;
175
+ }
176
+ if (props.skippedAppIds?.includes(appResult.app_id)) {
177
+ return;
178
+ }
179
+ response.shipping_services.forEach((service) => {
180
+ shippingServices.push({
181
+ app_id: appResult.app_id,
182
+ ...service,
183
+ });
184
+ });
185
+ const freeShippingFromValue = response.free_shipping_from_value;
186
+ if (
187
+ freeShippingFromValue
188
+ && (!freeFromValue.value || freeFromValue.value > freeShippingFromValue)
189
+ ) {
190
+ freeFromValue.value = freeShippingFromValue;
191
+ }
192
+ });
193
+ if (!shippingServices.length) {
194
+ if (hasSomeFailedApp) {
195
+ if (!isRetry) {
196
+ fetchShippingServices(true);
197
+ } else {
198
+ scheduleRetry();
199
+ }
200
+ }
201
+ return;
202
+ }
203
+ shippingServices.sort((a, b) => {
204
+ const lineA = a.shipping_line;
205
+ const lineB = b.shipping_line;
206
+ const priceDiff = lineA.total_price! - lineB.total_price!;
207
+ if (priceDiff < 0) return -1;
208
+ if (priceDiff > 0) return 1;
209
+ return lineA.delivery_time?.days! < lineB.delivery_time?.days!
210
+ ? -1 : 1;
211
+ });
212
+ hasPaidOption.value = Boolean(shippingServices.find((service) => {
213
+ return service.shipping_line.total_price || service.shipping_line.price;
214
+ }));
215
+ const appIdsOrder = props.appIdsOrder || globalThis.ecomShippingApps || [];
216
+ if (Array.isArray(appIdsOrder) && appIdsOrder.length) {
217
+ sortApps(shippingServices, appIdsOrder);
218
+ }
219
+ }
220
+ };
221
+
222
+ const submitZipCode = () => {
223
+ const _zipCode = localZipCode.value;
224
+ if (countryCode === 'BR') {
225
+ if (_zipCode?.replace(/\D/g, '').length !== 8) return;
226
+ } else if (!_zipCode) {
227
+ return;
228
+ }
229
+ zipCode.value = _zipCode;
230
+ if (localStorage) {
231
+ localStorage.setItem(ZIP_STORAGE_KEY, zipCode.value);
232
+ }
233
+ fetchShippingServices();
234
+ };
235
+ watch(localZipCode, submitZipCode, {
236
+ immediate: !props.shippingResult,
237
+ });
238
+ watch(toRef(props, 'shippingResult'), (shippingResult) => {
239
+ if (!shippingResult?.length) return;
240
+ if (localZipCode.value) zipCode.value = localZipCode.value;
241
+ parseShippingResult(shippingResult);
242
+ }, {
243
+ immediate: true,
244
+ });
245
+ const zipInput = props.zipInput?.value;
246
+ if (zipInput) {
247
+ zipInput.addEventListener('input', (ev) => {
248
+ const value = (ev.target as HTMLInputElement).value;
249
+ if (value.length) {
250
+ if (countryCode === 'BR') {
251
+ const fmt = value.replace(/\D/g, '').padEnd(8, '_');
252
+ zipInput.innerHTML = fmt.substring(0, 5) + '-' + fmt.substring(5, 8);
253
+ } else {
254
+ zipInput.innerHTML = value.substring(0, 30);
255
+ }
256
+ }
257
+ localZipCode.value = value;
258
+ });
259
+ }
260
+
261
+ return {
262
+ zipCode,
263
+ shippedItems,
264
+ amountSubtotal,
265
+ submitZipCode,
266
+ fetchShippingServices,
267
+ freeFromValue,
268
+ shippingServices,
269
+ parseShippingResult,
270
+ };
271
+ };
272
+
273
+ export default useShippingCalculator;
@@ -19,7 +19,7 @@ type AnalyticsEvent = {
19
19
  let eventsToSend: Array<AnalyticsEvent> = [];
20
20
  const _sendServerEvents = useDebounceFn(() => {
21
21
  afetch(`/_analytics`, {
22
- method: 'post',
22
+ method: 'POST',
23
23
  body: {
24
24
  ...getAnalyticsContext(),
25
25
  events: eventsToSend,
@@ -2,6 +2,9 @@ import type {
2
2
  ListPaymentsResponse,
3
3
  CalculateShippingResponse,
4
4
  ApplyDiscountResponse,
5
+ ModuleApiEndpoint,
6
+ ModuleApiParams,
7
+ ModuleApiResult,
5
8
  } from '@cloudcommerce/types';
6
9
  import { reactive, computed } from 'vue';
7
10
  import { formatMoney } from '@ecomplus/utils';
@@ -32,6 +35,32 @@ loadingGlobalInfoPreset.then((modulesInfoPreset) => {
32
35
  Object.assign(modulesInfo, modulesInfoPreset);
33
36
  });
34
37
 
38
+ type FetchModule = <M extends ModuleApiEndpoint>(
39
+ modName: M,
40
+ reqOptions?: {
41
+ method: 'GET',
42
+ params?: Record<string, string | number | (string | number)[]>,
43
+ } | {
44
+ method: 'POST',
45
+ params?: {
46
+ app_id?: number,
47
+ skip_ids?: number | number[],
48
+ },
49
+ body: ModuleApiParams<M>,
50
+ },
51
+ ) => Promise<Omit<Response, 'json'> & {
52
+ json(): Promise<ModuleApiResult<M>>,
53
+ }>;
54
+
55
+ export const fetchModule: FetchModule = (modName, reqOptions) => {
56
+ const { hostname } = window.location;
57
+ const { domain } = globalThis.$storefront.settings;
58
+ const modulesBaseUri = hostname !== 'localhost' && hostname !== '127.0.0.1'
59
+ ? `https://${domain}/_api/modules/`
60
+ : '/_api/modules/';
61
+ return afetch(`${modulesBaseUri}${modName}`, reqOptions);
62
+ };
63
+
35
64
  if (!import.meta.env.SSR) {
36
65
  const storageKey = 'MODULES_INFO';
37
66
  const sessionJson = sessionStorage.getItem(storageKey);
@@ -50,8 +79,8 @@ if (!import.meta.env.SSR) {
50
79
  }
51
80
 
52
81
  const fetchInfo = () => {
53
- const modulesToFetch: { modName: string, reqOptions?: Record<string, any> }[] = [];
54
- ['list_payments', 'calculate_shipping'].forEach((modName) => {
82
+ const modulesToFetch: { modName: ModuleApiEndpoint, reqOptions?: any }[] = [];
83
+ (['list_payments', 'calculate_shipping'] as const).forEach((modName) => {
55
84
  if (!Object.keys(modulesInfo[modName]).length) {
56
85
  modulesToFetch.push({ modName });
57
86
  }
@@ -60,19 +89,14 @@ if (!import.meta.env.SSR) {
60
89
  modulesToFetch.push({
61
90
  modName: 'apply_discount',
62
91
  reqOptions: {
63
- method: 'post',
92
+ method: 'POST',
64
93
  body: { utm },
65
94
  },
66
95
  });
67
96
  }
68
97
 
69
98
  modulesToFetch.forEach(({ modName, reqOptions }) => {
70
- const { hostname } = window.location;
71
- const { domain } = globalThis.$storefront.settings;
72
- const modulesBaseUri = hostname !== 'localhost' && hostname !== '127.0.0.1'
73
- ? `https://${domain}/_api/modules/`
74
- : '/_api/modules/';
75
- afetch(`${modulesBaseUri}${modName}`, reqOptions)
99
+ fetchModule(modName, reqOptions)
76
100
  .then(async (response) => {
77
101
  if (response.ok) {
78
102
  const modInfo = {};
@@ -108,7 +132,7 @@ if (!import.meta.env.SSR) {
108
132
  field = 'discount_option';
109
133
  val = data[field];
110
134
  if (val && (!modInfo[field] || val.value > modInfo[field].value)) {
111
- data.payment_gateways.forEach(({ discount }) => {
135
+ (data as ListPaymentsResponse).payment_gateways.forEach(({ discount }) => {
112
136
  if (
113
137
  discount && discount.apply_at !== 'freight'
114
138
  && discount.value === val.value
@@ -2,7 +2,7 @@
2
2
  "name": "@cloudcommerce/test-base",
3
3
  "private": true,
4
4
  "type": "module",
5
- "version": "2.2.3",
5
+ "version": "2.3.0",
6
6
  "description": "E-Com Plus Cloud Commerce basic setup for testing",
7
7
  "main": "lib/index.js",
8
8
  "repository": {
@@ -38,7 +38,47 @@ import type { CreateTransactionParams } from './modules/create_transaction:param
38
38
  import type { CreateTransactionResponse } from './modules/create_transaction:response';
39
39
  import type { CheckoutBody } from './modules/@checkout:params';
40
40
 
41
- type ApiEventName = 'orders-new'
41
+ export type {
42
+ Products,
43
+ Categories,
44
+ Brands,
45
+ Collections,
46
+ Grids,
47
+ Carts,
48
+ Orders,
49
+ Customers,
50
+ Stores,
51
+ Applications,
52
+ Authentications,
53
+ ProductSet,
54
+ CategorySet,
55
+ BrandSet,
56
+ CollectionSet,
57
+ GridSet,
58
+ CartSet,
59
+ OrderSet,
60
+ CustomerSet,
61
+ StoreSet,
62
+ ApplicationSet,
63
+ AuthenticationSet,
64
+ Resource,
65
+ ResourceId,
66
+ ResourceListResult,
67
+ SearchItem,
68
+ SearchResult,
69
+ EventsResult,
70
+ ApplyDiscountParams,
71
+ ApplyDiscountResponse,
72
+ CalculateShippingParams,
73
+ CalculateShippingResponse,
74
+ ListPaymentsParams,
75
+ ListPaymentsResponse,
76
+ CreateTransactionParams,
77
+ CreateTransactionResponse,
78
+ CheckoutBody,
79
+ };
80
+
81
+ export type ApiEventName = 'orders-new'
42
82
  | 'orders-anyStatusSet'
43
83
  | 'orders-paid'
44
84
  | 'orders-readyForShipping'
@@ -54,7 +94,7 @@ type ApiEventName = 'orders-new'
54
94
  | 'customers-new'
55
95
  | 'applications-dataSet';
56
96
 
57
- type AppEventsPayload = {
97
+ export type AppEventsPayload = {
58
98
  evName: ApiEventName,
59
99
  apiEvent: EventsResult<'events/orders'>['result'][0],
60
100
  apiDoc: Record<string, any>,
@@ -67,20 +107,54 @@ type AppEventsPayload = {
67
107
  isInternal?: boolean,
68
108
  };
69
109
 
70
- type AppModuleName = 'apply_discount'
110
+ export type AppModuleName = 'apply_discount'
71
111
  | 'calculate_shipping'
72
112
  | 'list_payments'
73
113
  | 'create_transaction';
74
114
 
75
- type AppModuleBody = {
115
+ export type AppModuleBody<M extends AppModuleName | undefined = undefined> = {
76
116
  storeId: number,
77
117
  module: AppModuleName,
78
- params: {
79
- [key: string]: any,
80
- },
118
+ params:
119
+ M extends 'list_payments' ? ListPaymentsParams :
120
+ M extends 'calculate_shipping' ? CalculateShippingParams :
121
+ M extends 'apply_discount' ? ApplyDiscountParams :
122
+ M extends 'create_transaction' ? CreateTransactionParams :
123
+ Record<string, any>,
81
124
  application: Applications,
82
125
  };
83
126
 
127
+ export type AppModuleResponse<M extends AppModuleName | undefined = undefined> =
128
+ M extends 'list_payments' ? ListPaymentsResponse :
129
+ M extends 'calculate_shipping' ? CalculateShippingResponse :
130
+ M extends 'apply_discount' ? ApplyDiscountResponse :
131
+ M extends 'create_transaction' ? CreateTransactionResponse :
132
+ Record<string, any>;
133
+
134
+ export type ModuleApiEndpoint = Exclude<AppModuleName, 'create_transaction'> | '@checkout';
135
+
136
+ export type ModuleApiParams<M extends ModuleApiEndpoint> =
137
+ M extends 'list_payments' ? ListPaymentsParams :
138
+ M extends 'calculate_shipping' ? CalculateShippingParams :
139
+ M extends 'apply_discount' ? ApplyDiscountParams :
140
+ M extends '@checkout' ? CheckoutBody :
141
+ never;
142
+
143
+ export type ModuleApiResult<M extends ModuleApiEndpoint> = {
144
+ result: {
145
+ _id: Applications['_id'],
146
+ app_id: Applications['app_id'],
147
+ took: number,
148
+ version: Applications['version'],
149
+ validated: boolean,
150
+ response_errors: null | string,
151
+ error: boolean,
152
+ error_message: null | string,
153
+ response: M extends AppModuleName ? AppModuleResponse<M> : Record<string, any>,
154
+ }[],
155
+ meta: ModuleApiParams<M>,
156
+ };
157
+
84
158
  type PaymentMethodFlag = 'pix'
85
159
  | 'visa'
86
160
  | 'mastercard'
@@ -91,7 +165,7 @@ type PaymentMethodFlag = 'pix'
91
165
  | 'diners'
92
166
  | 'discover';
93
167
 
94
- type SettingsContent = {
168
+ export type SettingsContent = {
95
169
  domain: string,
96
170
  name: string,
97
171
  description: string,
@@ -147,48 +221,3 @@ type SettingsContent = {
147
221
  favoritesUrl?: string,
148
222
  metafields?: Record<string, any>,
149
223
  };
150
-
151
- export type {
152
- Products,
153
- Categories,
154
- Brands,
155
- Collections,
156
- Grids,
157
- Carts,
158
- Orders,
159
- Customers,
160
- Stores,
161
- Applications,
162
- Authentications,
163
- ProductSet,
164
- CategorySet,
165
- BrandSet,
166
- CollectionSet,
167
- GridSet,
168
- CartSet,
169
- OrderSet,
170
- CustomerSet,
171
- StoreSet,
172
- ApplicationSet,
173
- AuthenticationSet,
174
- Resource,
175
- ResourceId,
176
- ResourceListResult,
177
- SearchItem,
178
- SearchResult,
179
- EventsResult,
180
- ApiEventName,
181
- AppEventsPayload,
182
- AppModuleName,
183
- AppModuleBody,
184
- ApplyDiscountParams,
185
- ApplyDiscountResponse,
186
- CalculateShippingParams,
187
- CalculateShippingResponse,
188
- ListPaymentsParams,
189
- ListPaymentsResponse,
190
- CreateTransactionParams,
191
- CreateTransactionResponse,
192
- CheckoutBody,
193
- SettingsContent,
194
- };
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@cloudcommerce/types",
3
3
  "type": "module",
4
- "version": "2.2.3",
4
+ "version": "2.3.0",
5
5
  "description": "E-Com Plus Cloud Commerce reusable type definitions",
6
6
  "main": "index.ts",
7
7
  "repository": {