cloudcommerce 2.2.2 → 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 +24 -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 +11 -3
  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 +14 -3
  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
@@ -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.2",
4
+ "version": "2.3.0",
5
5
  "description": "E-Com Plus Cloud Commerce reusable type definitions",
6
6
  "main": "index.ts",
7
7
  "repository": {