cloudcommerce 0.0.97 → 0.0.98

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 (114) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/package.json +1 -1
  3. package/packages/api/package.json +1 -1
  4. package/packages/apps/correios/package.json +1 -1
  5. package/packages/apps/custom-shipping/package.json +1 -1
  6. package/packages/apps/discounts/package.json +1 -1
  7. package/packages/apps/frenet/package.json +1 -1
  8. package/packages/apps/tiny-erp/lib/event-to-tiny.js +94 -94
  9. package/packages/apps/tiny-erp/lib/index.js +1 -1
  10. package/packages/apps/tiny-erp/lib/integration/after-tiny-queue.js +74 -71
  11. package/packages/apps/tiny-erp/lib/integration/export-order-to-tiny.js +73 -70
  12. package/packages/apps/tiny-erp/lib/integration/export-product-to-tiny.js +53 -49
  13. package/packages/apps/tiny-erp/lib/integration/helpers/format-tiny-date.js +3 -3
  14. package/packages/apps/tiny-erp/lib/integration/import-order-from-tiny.js +75 -76
  15. package/packages/apps/tiny-erp/lib/integration/import-product-from-tiny.js +140 -137
  16. package/packages/apps/tiny-erp/lib/integration/parsers/order-from-tiny.js +39 -40
  17. package/packages/apps/tiny-erp/lib/integration/parsers/order-to-tiny.js +178 -173
  18. package/packages/apps/tiny-erp/lib/integration/parsers/product-from-tiny.js +171 -173
  19. package/packages/apps/tiny-erp/lib/integration/parsers/product-to-tiny.js +127 -123
  20. package/packages/apps/tiny-erp/lib/integration/parsers/status-from-tiny.js +32 -32
  21. package/packages/apps/tiny-erp/lib/integration/parsers/status-to-tiny.js +37 -37
  22. package/packages/apps/tiny-erp/lib/integration/post-tiny-erp.js +43 -42
  23. package/packages/apps/tiny-erp/lib/tiny-erp.js +6 -8
  24. package/packages/apps/tiny-erp/lib/tiny-webhook.js +73 -76
  25. package/packages/apps/tiny-erp/package.json +1 -1
  26. package/packages/cli/package.json +1 -1
  27. package/packages/config/package.json +1 -1
  28. package/packages/events/package.json +1 -1
  29. package/packages/firebase/lib/config.js +27 -25
  30. package/packages/firebase/lib/const.js +3 -2
  31. package/packages/firebase/lib/env.js +2 -1
  32. package/packages/firebase/lib/handlers/check-store-events.js +146 -145
  33. package/packages/firebase/lib/helpers/pubsub.js +20 -18
  34. package/packages/firebase/lib/helpers/update-app-data.js +38 -38
  35. package/packages/firebase/lib/index.js +9 -7
  36. package/packages/firebase/lib/init.js +2 -1
  37. package/packages/firebase/package.json +1 -1
  38. package/packages/modules/lib/firebase/ajv.js +19 -24
  39. package/packages/modules/lib/firebase/call-app-module.js +116 -110
  40. package/packages/modules/lib/firebase/checkout.js +151 -152
  41. package/packages/modules/lib/firebase/functions-checkout/fix-items.js +194 -187
  42. package/packages/modules/lib/firebase/functions-checkout/get-custumerId.js +25 -26
  43. package/packages/modules/lib/firebase/functions-checkout/handle-order-transaction.js +110 -109
  44. package/packages/modules/lib/firebase/functions-checkout/new-order.js +177 -177
  45. package/packages/modules/lib/firebase/functions-checkout/request-to-module.js +59 -59
  46. package/packages/modules/lib/firebase/functions-checkout/utils.js +195 -197
  47. package/packages/modules/lib/firebase/handle-module.js +144 -146
  48. package/packages/modules/lib/firebase/proxy-apps.js +2 -1
  49. package/packages/modules/lib/firebase/serve-modules-api.js +52 -53
  50. package/packages/modules/lib/firebase.js +4 -6
  51. package/packages/modules/lib/index.js +12 -15
  52. package/packages/modules/package.json +1 -1
  53. package/packages/passport/package.json +1 -1
  54. package/packages/ssr/package.json +1 -1
  55. package/packages/storefront/dist/client/LoginOffcanvas.daf3f717.js +1 -0
  56. package/packages/storefront/dist/client/admin/config.json +1 -0
  57. package/packages/storefront/dist/client/assets/_...522e6bf2.css +4 -0
  58. package/packages/storefront/dist/client/assets/_...a48b75c7.css +1 -0
  59. package/packages/storefront/dist/client/assets/cms-preview.css +274 -0
  60. package/packages/storefront/dist/client/assets/cms.css +114 -0
  61. package/packages/storefront/dist/client/assets/cvv.png +0 -0
  62. package/packages/storefront/dist/client/assets/icons/bootstrap-icons/font/storefront-icons.woff2 +0 -0
  63. package/packages/storefront/dist/client/assets/icons/feather-icons/font/storefront-icons.woff2 +0 -0
  64. package/packages/storefront/dist/client/assets/icons/font-awesome/font/storefront-icons.woff2 +0 -0
  65. package/packages/storefront/dist/client/assets/icons/line-awesome/font/storefront-icons.woff2 +0 -0
  66. package/packages/storefront/dist/client/assets/icons/tabler-icons/font/storefront-icons.woff2 +0 -0
  67. package/packages/storefront/dist/client/assets/img-placeholder.png +0 -0
  68. package/packages/storefront/dist/client/assets/payments.png +0 -0
  69. package/packages/storefront/dist/client/assets/ssl-safe.png +0 -0
  70. package/packages/storefront/dist/client/chunks/LoginForm.d9251274.js +1066 -0
  71. package/packages/storefront/dist/client/chunks/LoginOffcanvas.07fe6492.js +1 -0
  72. package/packages/storefront/dist/client/chunks/index.esm.84a649c7.js +331 -0
  73. package/packages/storefront/dist/client/chunks/preload-helper.f15ab524.js +1 -0
  74. package/packages/storefront/dist/client/chunks/runtime-dom.esm-bundler.738639ee.js +1 -0
  75. package/packages/storefront/dist/client/chunks/workbox-window.prod.es5.4b654ae6.js +2 -0
  76. package/packages/storefront/dist/client/client.b552d86a.js +1 -0
  77. package/packages/storefront/dist/client/hoisted.054c36ac.js +1 -0
  78. package/packages/storefront/dist/client/img/icon.png +0 -0
  79. package/packages/storefront/dist/client/img/large-icon.png +0 -0
  80. package/packages/storefront/dist/client/img/uploads/banner1.png +0 -0
  81. package/packages/storefront/dist/client/img/uploads/banner2.png +0 -0
  82. package/packages/storefront/dist/client/img/uploads/banner2.webp +0 -0
  83. package/packages/storefront/dist/client/img/uploads/favicon.png +0 -0
  84. package/packages/storefront/dist/client/img/uploads/headless.png +0 -0
  85. package/packages/storefront/dist/client/img/uploads/headphone.png +0 -0
  86. package/packages/storefront/dist/client/img/uploads/headphone.webp +0 -0
  87. package/packages/storefront/dist/client/img/uploads/icon.png +0 -0
  88. package/packages/storefront/dist/client/img/uploads/large-icon.png +0 -0
  89. package/packages/storefront/dist/client/img/uploads/logo.png +0 -0
  90. package/packages/storefront/dist/client/img/uploads/logo.webp +0 -0
  91. package/packages/storefront/dist/client/img/uploads/og-image.png +0 -0
  92. package/packages/storefront/dist/client/img/uploads/passion.png +0 -0
  93. package/packages/storefront/dist/client/img/uploads/passion.webp +0 -0
  94. package/packages/storefront/dist/client/img/uploads/pwa-reliable.png +0 -0
  95. package/packages/storefront/dist/client/img/uploads/rect8589.png +0 -0
  96. package/packages/storefront/dist/client/img/uploads/rect859.png +0 -0
  97. package/packages/storefront/dist/client/img/uploads/rect89.png +0 -0
  98. package/packages/storefront/dist/client/img/uploads/rect89.webp +0 -0
  99. package/packages/storefront/dist/client/img/uploads/ssl-safe.png +0 -0
  100. package/packages/storefront/dist/client/manifest.webmanifest +1 -0
  101. package/packages/storefront/dist/client/page.3aa82516.js +1 -0
  102. package/packages/storefront/dist/client/robots.txt +8 -0
  103. package/packages/storefront/dist/client/sw.js +1 -0
  104. package/packages/storefront/dist/client/workbox-6f0d1f78.js +1 -0
  105. package/packages/storefront/dist/client/~partytown/partytown-atomics.js +2 -0
  106. package/packages/storefront/dist/client/~partytown/partytown-media.js +2 -0
  107. package/packages/storefront/dist/client/~partytown/partytown-sw.js +2 -0
  108. package/packages/storefront/dist/client/~partytown/partytown.js +2 -0
  109. package/packages/storefront/dist/server/entry.mjs +2852 -0
  110. package/packages/storefront/dist/server/manifest.webmanifest +1 -0
  111. package/packages/storefront/dist/server/registerSW.js +1 -0
  112. package/packages/storefront/package.json +1 -1
  113. package/packages/storefront/src/lib/layouts/PagesHeader.astro +2 -1
  114. package/packages/types/package.json +1 -1
@@ -1,200 +1,207 @@
1
1
  import api from '@cloudcommerce/api';
2
-
3
2
  export default async (checkoutItems) => {
4
- const items = [...checkoutItems];
5
- // get each cart item
6
- // count done processes
7
- let itemsDone = 0;
8
- const itemsTodo = items.length;
9
- // eslint-disable-next-line consistent-return
10
- const doFinally = () => {
11
- // after each item
12
- itemsDone += 1;
13
- if (itemsDone === itemsTodo) {
14
- return items;
15
- }
16
- };
17
- // run item by item
18
- for (let i = 0; i < items.length; i++) {
19
- // i, item scoped
20
- const item = items[i];
21
- const removeItem = () => {
22
- // remove invalid item from list
23
- items.splice(i, 1);
24
- doFinally();
25
- };
26
- if (!item.quantity) {
27
- // ignore items without quantity or zero
28
- removeItem();
29
- i -= 1;
30
- continue;
31
- }
32
- const proceedItem = () => {
33
- // additions to final price
34
- if (Array.isArray(item.customizations)) {
35
- item.customizations.forEach((customization) => {
36
- if (item.final_price) {
37
- if (customization.add_to_price) {
38
- const { type, addition } = customization.add_to_price;
39
- item.final_price += type === 'fixed'
40
- ? addition
41
- : ((item.price * addition) / 100);
42
- }
43
- }
44
- });
45
- }
46
- // done
47
- doFinally();
3
+ const items = [...checkoutItems];
4
+ // get each cart item
5
+ // count done processes
6
+ let itemsDone = 0;
7
+ const itemsTodo = items.length;
8
+ // eslint-disable-next-line consistent-return
9
+ const doFinally = () => {
10
+ // after each item
11
+ itemsDone += 1;
12
+ if (itemsDone === itemsTodo) {
13
+ return items;
14
+ }
48
15
  };
49
- const checkItem = (product) => {
50
- if (!product.available) {
51
- removeItem();
52
- } else {
53
- let body;
54
- // check variation if any
55
- if (!item.variation_id) {
56
- body = product;
57
- } else {
58
- // find respective variation
59
- let variation;
60
- if (product.variations) {
61
- variation = product.variations.find((variationFind) => variationFind._id === item.variation_id);
62
- }
63
- if (variation) {
64
- // merge product body with variation object
65
- body = Object.assign(product, variation);
66
- }
16
+ // run item by item
17
+ for (let i = 0; i < items.length; i++) {
18
+ // i, item scoped
19
+ const item = items[i];
20
+ const removeItem = () => {
21
+ // remove invalid item from list
22
+ items.splice(i, 1);
23
+ doFinally();
24
+ };
25
+ if (!item.quantity) {
26
+ // ignore items without quantity or zero
27
+ removeItem();
28
+ i -= 1;
29
+ continue;
67
30
  }
68
- // logger.log(body._id)
69
- if (!body || (body.min_quantity && body.min_quantity > item.quantity)) {
70
- // cannot handle current item
71
- // invalid variation or quantity lower then minimum
72
- removeItem();
73
- } else {
74
- // check quantity
75
- if (body.quantity && body.quantity < item.quantity) {
76
- // reduce to max available quantity
77
- item.quantity = body.quantity;
78
- }
79
- // extend item properties with body
80
- [
81
- 'sku',
82
- 'name',
83
- 'currency_id',
84
- 'currency_symbol',
85
- 'price',
86
- 'dimensions',
87
- 'weight',
88
- 'production_time',
89
- ].forEach((prop) => {
90
- if (body && body[prop] !== undefined) {
91
- item[prop] = body[prop];
31
+ const proceedItem = () => {
32
+ // additions to final price
33
+ if (Array.isArray(item.customizations)) {
34
+ item.customizations.forEach((customization) => {
35
+ if (item.final_price) {
36
+ if (customization.add_to_price) {
37
+ const { type, addition } = customization.add_to_price;
38
+ item.final_price += type === 'fixed'
39
+ ? addition
40
+ : ((item.price * addition) / 100);
41
+ }
42
+ }
43
+ });
92
44
  }
93
- });
94
- // price is required
95
- if (!item.price) {
96
- item.price = 0;
97
- }
98
- if (Array.isArray(item.flags)) {
99
- // prevent error with repeated flags
100
- const flags = [];
101
- item.flags.forEach((flag) => {
102
- if (!flags.includes(flag)) {
103
- flags.push(flag);
104
- }
105
- });
106
- item.flags = flags;
107
- }
108
- //
109
- // item.final_price = getPrice(body);
110
- proceedItem();
111
- }
112
- }
113
- };
114
- const checkKitProduct = (kitProduct, kitProductId) => {
115
- if (item.kit_product) {
116
- if (kitProduct.available && kitProduct.kit_composition) {
117
- // check kit composition and quantities
118
- let packQuantity = 0;
119
- let isFixedQuantity = true;
120
- let kitItem;
121
- kitProduct.kit_composition.forEach((currentKitItem) => {
122
- if (currentKitItem.quantity) {
123
- packQuantity += currentKitItem.quantity;
124
- } else if (isFixedQuantity) {
125
- isFixedQuantity = false;
45
+ // done
46
+ doFinally();
47
+ };
48
+ const checkItem = (product) => {
49
+ if (!product.available) {
50
+ removeItem();
126
51
  }
127
- if (currentKitItem._id === item.product_id) {
128
- kitItem = currentKitItem;
52
+ else {
53
+ let body;
54
+ // check variation if any
55
+ if (!item.variation_id) {
56
+ body = product;
57
+ }
58
+ else {
59
+ // find respective variation
60
+ let variation;
61
+ if (product.variations) {
62
+ variation = product.variations.find((variationFind) => variationFind._id === item.variation_id);
63
+ }
64
+ if (variation) {
65
+ // merge product body with variation object
66
+ body = Object.assign(product, variation);
67
+ }
68
+ }
69
+ // logger.log(body._id)
70
+ if (!body || (body.min_quantity && body.min_quantity > item.quantity)) {
71
+ // cannot handle current item
72
+ // invalid variation or quantity lower then minimum
73
+ removeItem();
74
+ }
75
+ else {
76
+ // check quantity
77
+ if (body.quantity && body.quantity < item.quantity) {
78
+ // reduce to max available quantity
79
+ item.quantity = body.quantity;
80
+ }
81
+ // extend item properties with body
82
+ [
83
+ 'sku',
84
+ 'name',
85
+ 'currency_id',
86
+ 'currency_symbol',
87
+ 'price',
88
+ 'dimensions',
89
+ 'weight',
90
+ 'production_time',
91
+ ].forEach((prop) => {
92
+ if (body && body[prop] !== undefined) {
93
+ item[prop] = body[prop];
94
+ }
95
+ });
96
+ // price is required
97
+ if (!item.price) {
98
+ item.price = 0;
99
+ }
100
+ if (Array.isArray(item.flags)) {
101
+ // prevent error with repeated flags
102
+ const flags = [];
103
+ item.flags.forEach((flag) => {
104
+ if (!flags.includes(flag)) {
105
+ flags.push(flag);
106
+ }
107
+ });
108
+ item.flags = flags;
109
+ }
110
+ //
111
+ // item.final_price = getPrice(body);
112
+ proceedItem();
113
+ }
129
114
  }
130
- });
131
- if (!isFixedQuantity) {
132
- // use parent product min quantity
133
- packQuantity = kitProduct.min_quantity || 0;
134
- }
135
- if (kitItem && (kitItem.quantity === undefined
115
+ };
116
+ const checkKitProduct = (kitProduct, kitProductId) => {
117
+ if (item.kit_product) {
118
+ if (kitProduct.available && kitProduct.kit_composition) {
119
+ // check kit composition and quantities
120
+ let packQuantity = 0;
121
+ let isFixedQuantity = true;
122
+ let kitItem;
123
+ kitProduct.kit_composition.forEach((currentKitItem) => {
124
+ if (currentKitItem.quantity) {
125
+ packQuantity += currentKitItem.quantity;
126
+ }
127
+ else if (isFixedQuantity) {
128
+ isFixedQuantity = false;
129
+ }
130
+ if (currentKitItem._id === item.product_id) {
131
+ kitItem = currentKitItem;
132
+ }
133
+ });
134
+ if (!isFixedQuantity) {
135
+ // use parent product min quantity
136
+ packQuantity = kitProduct.min_quantity || 0;
137
+ }
138
+ if (kitItem && (kitItem.quantity === undefined
136
139
  || item.quantity % kitItem.quantity === 0)) {
137
- // valid kit item and quantity
138
- let kitTotalQuantity = 0;
139
- items.forEach((itemFind) => {
140
- if (itemFind.kit_product && itemFind.kit_product._id === kitProductId) {
141
- kitTotalQuantity += itemFind.quantity;
142
- }
143
- });
144
- const minPacks = kitItem.quantity
145
- ? item.quantity / kitItem.quantity
146
- : 1;
147
- if (kitTotalQuantity && kitTotalQuantity % (minPacks * packQuantity) === 0) {
148
- // matched pack quantity
149
- // item.kit_product.price = getPrice(kitProduct);
150
- item.kit_product.pack_quantity = packQuantity;
151
- if (item.kit_product.price) {
152
- // set final price from kit
153
- item.final_price = item.kit_product.price / packQuantity;
154
- }
155
- proceedItem();
140
+ // valid kit item and quantity
141
+ let kitTotalQuantity = 0;
142
+ items.forEach((itemFind) => {
143
+ if (itemFind.kit_product && itemFind.kit_product._id === kitProductId) {
144
+ kitTotalQuantity += itemFind.quantity;
145
+ }
146
+ });
147
+ const minPacks = kitItem.quantity
148
+ ? item.quantity / kitItem.quantity
149
+ : 1;
150
+ if (kitTotalQuantity && kitTotalQuantity % (minPacks * packQuantity) === 0) {
151
+ // matched pack quantity
152
+ // item.kit_product.price = getPrice(kitProduct);
153
+ item.kit_product.pack_quantity = packQuantity;
154
+ if (item.kit_product.price) {
155
+ // set final price from kit
156
+ item.final_price = item.kit_product.price / packQuantity;
157
+ }
158
+ proceedItem();
159
+ }
160
+ }
161
+ }
162
+ // remove items with invalid kit
163
+ let index = 0;
164
+ while (index < items.length) {
165
+ const itemKit = items[index].kit_product;
166
+ if (itemKit && itemKit._id === kitProductId) {
167
+ items.splice(index, 1);
168
+ }
169
+ else {
170
+ index += 1;
171
+ }
172
+ }
173
+ doFinally();
174
+ }
175
+ };
176
+ if (item.kit_product) {
177
+ // GET public kit product object
178
+ const kitProductId = item.kit_product._id;
179
+ // eslint-disable-next-line no-await-in-loop
180
+ const kitProduct = (await api.get(`products/${kitProductId}`, {
181
+ isNoAuth: true,
182
+ })).data;
183
+ if (kitProduct) {
184
+ checkKitProduct(kitProduct, kitProductId);
185
+ }
186
+ else {
187
+ removeItem();
156
188
  }
157
- }
158
189
  }
159
- // remove items with invalid kit
160
- let index = 0;
161
- while (index < items.length) {
162
- const itemKit = items[index].kit_product;
163
- if (itemKit && itemKit._id === kitProductId) {
164
- items.splice(index, 1);
165
- } else {
166
- index += 1;
167
- }
190
+ else {
191
+ // GET public product object
192
+ // eslint-disable-next-line no-await-in-loop
193
+ const product = (await api.get(`products/${item.product_id}`, {
194
+ isNoAuth: true,
195
+ })).data;
196
+ if (product) {
197
+ checkItem(product);
198
+ }
199
+ else {
200
+ // remove cart item
201
+ removeItem();
202
+ }
168
203
  }
169
- doFinally();
170
- }
171
- };
172
- if (item.kit_product) {
173
- // GET public kit product object
174
- const kitProductId = item.kit_product._id;
175
- // eslint-disable-next-line no-await-in-loop
176
- const kitProduct = (await api.get(`products/${kitProductId}`, {
177
- isNoAuth: true,
178
- })).data;
179
- if (kitProduct) {
180
- checkKitProduct(kitProduct, kitProductId);
181
- } else {
182
- removeItem();
183
- }
184
- } else {
185
- // GET public product object
186
- // eslint-disable-next-line no-await-in-loop
187
- const product = (await api.get(`products/${item.product_id}`, {
188
- isNoAuth: true,
189
- })).data;
190
- if (product) {
191
- checkItem(product);
192
- } else {
193
- // remove cart item
194
- removeItem();
195
- }
196
204
  }
197
- }
198
- return items;
205
+ return items;
199
206
  };
200
- // # sourceMappingURL=fix-items.js.map
207
+ //# sourceMappingURL=fix-items.js.map
@@ -1,34 +1,33 @@
1
1
  import api from '@cloudcommerce/api';
2
2
  import { logger } from 'firebase-functions';
3
-
4
3
  const findCustomerByEmail = async (email, accessToken) => {
5
- try {
6
- const { data } = await api.get(`customers?main_email=${email}`, {
7
- accessToken,
8
- });
9
- if (data.result.length) {
10
- return data.result[0]._id;
4
+ try {
5
+ const { data } = await api.get(`customers?main_email=${email}`, {
6
+ accessToken,
7
+ });
8
+ if (data.result.length) {
9
+ return data.result[0]._id;
10
+ }
11
+ return null;
12
+ }
13
+ catch (e) {
14
+ logger.error(e);
15
+ return null;
11
16
  }
12
- return null;
13
- } catch (e) {
14
- logger.error(e);
15
- return null;
16
- }
17
17
  };
18
-
19
18
  export default (accessToken, customer) => {
20
- if (customer) {
21
- if (!customer._id) {
22
- // try to find customer by e-mail
23
- // GET customer object
24
- return customer.main_email ? findCustomerByEmail(customer.main_email, accessToken) : null;
25
- // use first resulted customer ID
19
+ if (customer) {
20
+ if (!customer._id) {
21
+ // try to find customer by e-mail
22
+ // GET customer object
23
+ return customer.main_email ? findCustomerByEmail(customer.main_email, accessToken) : null;
24
+ // use first resulted customer ID
25
+ }
26
+ if (customer._id && (typeof customer._id === 'string') && customer._id.length === 24) {
27
+ // customer ID already defined
28
+ return customer._id;
29
+ }
26
30
  }
27
- if (customer._id && (typeof customer._id === 'string') && customer._id.length === 24) {
28
- // customer ID already defined
29
- return customer._id;
30
- }
31
- }
32
- return null;
31
+ return null;
33
32
  };
34
- // # sourceMappingURL=get-custumerId.js.map
33
+ //# sourceMappingURL=get-custumerId.js.map