@mailbiz/onsite-ecomplus-vendor 0.1.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/README.md ADDED
@@ -0,0 +1,5 @@
1
+ # @mailbiz/onsite-ecomplus-vendor
2
+
3
+ Vendor docs: https://developers.e-com.plus/docs/reference/store/
4
+
5
+ Copyright (c) 2023 Mailbiz.
@@ -0,0 +1,526 @@
1
+ import { OnsiteCoreWindow } from "@mailbiz/onsite-core";
2
+ //#region [Window]
3
+ interface EcomplusWindow extends OnsiteCoreWindow {
4
+ _context: EcomProductPageContext;
5
+ ecomPassport: EcomPassport;
6
+ ecomCart: EcomCart;
7
+ storefrontApp: EcomStorefrontApp;
8
+ }
9
+ //#endregion
10
+ //#region [Pubsub and Events]
11
+ type PubSubMethod = (eventName: string, cb: Function) => void;
12
+ interface EcomPubSub {
13
+ off: PubSubMethod;
14
+ on: PubSubMethod;
15
+ once: PubSubMethod;
16
+ }
17
+ //#endregion
18
+ //#region [Ecom Product Page]
19
+ interface EcomProductPageContext extends EcomPubSub {
20
+ body?: EcomProductPage;
21
+ resource?: string;
22
+ }
23
+ interface EcomProductPage extends EcomProduct {
24
+ notes?: string;
25
+ body_html: string;
26
+ body_text: string;
27
+ inventory_records: Array<any>;
28
+ variations?: EcomProductVariations[];
29
+ }
30
+ //#endregion
31
+ //#region [Ecom Passport]
32
+ interface EcomPassport extends EcomPubSub {
33
+ lang: string;
34
+ customer: Partial<EcomCustomer>;
35
+ getCustomer: () => Partial<EcomCustomer>;
36
+ getCustomerName: () => string;
37
+ }
38
+ interface EcomCustomer {
39
+ _id: string;
40
+ main_email: string;
41
+ display_name: string;
42
+ registry_type: string;
43
+ enabled: boolean;
44
+ login: boolean;
45
+ accepts_marketing: boolean;
46
+ currency_id: string;
47
+ currency_symbol: string;
48
+ name: {
49
+ given_name: string;
50
+ family_name: string;
51
+ middle_name: string;
52
+ };
53
+ birth_date: {
54
+ day: number;
55
+ month: number;
56
+ year: number;
57
+ };
58
+ phones: Array<{
59
+ number: string;
60
+ }>;
61
+ doc_number: string;
62
+ addresses: Array<{
63
+ _id: string;
64
+ zip: string;
65
+ province_code: string;
66
+ name: string;
67
+ number: number;
68
+ complement?: string;
69
+ near_to?: string;
70
+ street: string;
71
+ city: string;
72
+ borough: string;
73
+ default: boolean;
74
+ }>;
75
+ orders: EcomCustomerOrder[];
76
+ }
77
+ //#endregion
78
+ //#region [Ecom Cart]
79
+ interface EcomCart extends EcomPubSub, EcomCartData {
80
+ storeId: string;
81
+ addProduct: (product: GetProductDataResponse, variationId: string | undefined, quantity: string) => void;
82
+ }
83
+ interface EcomCartData {
84
+ data: {
85
+ items: EcomCartProduct[] | EcomOrderProduct[];
86
+ subtotal: number;
87
+ _id: string;
88
+ orders?: string[];
89
+ flags?: string[];
90
+ customers?: string[];
91
+ permalink?: string;
92
+ };
93
+ }
94
+ interface EcomCartProduct extends EcomProduct {
95
+ variation_id: string;
96
+ product_id: string;
97
+ picture: EcomPicture;
98
+ max_quantity: number;
99
+ final_price: number;
100
+ specifications: EcomProductVariationSpecifications;
101
+ }
102
+ //#endregion
103
+ //#region [Ecom Product]
104
+ interface EcomProduct {
105
+ _id: string;
106
+ name: string;
107
+ available: boolean;
108
+ sku: string;
109
+ slug: string;
110
+ base_price?: number;
111
+ price: number;
112
+ quantity: number;
113
+ min_quantity?: number;
114
+ pictures: EcomPicture[];
115
+ meta_title: string;
116
+ subtitle: string;
117
+ meta_description?: string;
118
+ cost_price?: number;
119
+ weight: {
120
+ value: number;
121
+ unit: string;
122
+ };
123
+ dimensions: {
124
+ height: {
125
+ value: number;
126
+ unit: string;
127
+ };
128
+ width: {
129
+ value: number;
130
+ unit: string;
131
+ };
132
+ length: {
133
+ value: number;
134
+ unit: string;
135
+ };
136
+ };
137
+ brands?: Array<{
138
+ _id: string;
139
+ name: string;
140
+ slug: string;
141
+ logo?: {
142
+ url: string;
143
+ size: string;
144
+ alt: string;
145
+ };
146
+ }>;
147
+ commodity_type: string;
148
+ visible: boolean;
149
+ ad_relevance: number;
150
+ currency_id: string;
151
+ currency_symbol: string;
152
+ manage_stock: boolean;
153
+ condition: string;
154
+ adult: boolean;
155
+ auto_fill_related_products: boolean;
156
+ videos?: Array<{
157
+ url: string;
158
+ }>;
159
+ keywords: Array<string>;
160
+ views: number;
161
+ sales: number;
162
+ total_sold: number;
163
+ categories: Array<{
164
+ _id: string;
165
+ name: string;
166
+ slug: string;
167
+ google_product_category_id?: number;
168
+ }>;
169
+ updated_at: string;
170
+ store_id: number;
171
+ created_at: string;
172
+ customizations?: any[];
173
+ short_description?: string;
174
+ }
175
+ interface EcomProductVariations {
176
+ _id: string;
177
+ specifications?: EcomProductVariationSpecifications;
178
+ name: string;
179
+ sku: string;
180
+ quantity: number;
181
+ picture_id?: string;
182
+ gtin?: string;
183
+ mpn?: string;
184
+ weight?: {
185
+ value: number;
186
+ unit: string;
187
+ };
188
+ dimensions?: {
189
+ width: {
190
+ value: number;
191
+ unit: string;
192
+ };
193
+ height: {
194
+ value: number;
195
+ unit: string;
196
+ };
197
+ length: {
198
+ value: number;
199
+ unit: string;
200
+ };
201
+ };
202
+ price?: number;
203
+ }
204
+ interface EcomProductVariationSpecifications {
205
+ [property: string]: EcomProductVariationSpecificationProperties[];
206
+ }
207
+ interface EcomProductVariationSpecificationProperties {
208
+ text: string;
209
+ value: string;
210
+ }
211
+ //#endregion
212
+ //#region [Ecom Storefront App]
213
+ interface EcomStorefrontApp {
214
+ amount: EcomStorefrontAmount; // This data is incorrect
215
+ router: {
216
+ currentRoute: {
217
+ matched: {
218
+ 0: {
219
+ instances: {
220
+ default: EcomStorefrontAppDefault;
221
+ };
222
+ };
223
+ };
224
+ };
225
+ };
226
+ }
227
+ interface EcomStorefrontAppDefault {
228
+ discountCoupon?: string;
229
+ amount?: EcomStorefrontAmount;
230
+ selectedAddress?: EcomStorefrontAddress;
231
+ order?: EcomStorefrontOrder;
232
+ }
233
+ interface EcomStorefrontAmount {
234
+ discount: number;
235
+ freight: number;
236
+ subtotal: number;
237
+ total: number;
238
+ }
239
+ interface EcomStorefrontAddress {
240
+ borough: string;
241
+ city: string;
242
+ complement: string;
243
+ default: boolean;
244
+ name: string;
245
+ near_to: string;
246
+ number: number;
247
+ province_code: string;
248
+ street: string;
249
+ zip: string;
250
+ _id: string;
251
+ }
252
+ interface EcomStorefrontOrder {
253
+ status: string;
254
+ _id: string;
255
+ number: number;
256
+ transactions: Array<{
257
+ amount: number;
258
+ intermediator: {
259
+ payment_method: {
260
+ code: string;
261
+ };
262
+ transaction_id: string;
263
+ transaction_code: string;
264
+ buyer_id: string;
265
+ };
266
+ notes: string;
267
+ account_deposit: {
268
+ valid_thru: string;
269
+ };
270
+ status: {
271
+ updated_at: string;
272
+ current: string;
273
+ };
274
+ type: string;
275
+ payment_method: {
276
+ code: string;
277
+ name: string;
278
+ };
279
+ currency_id: string;
280
+ currency_symbol: string;
281
+ app: {
282
+ _id: string;
283
+ label: string;
284
+ intermediator: {
285
+ name: string;
286
+ link: string;
287
+ code: string;
288
+ };
289
+ };
290
+ _id: string;
291
+ }>;
292
+ opened_at: string;
293
+ buyers: Array<{
294
+ main_email: string;
295
+ display_name: string;
296
+ name: {
297
+ given_name: string;
298
+ family_name: string;
299
+ middle_name: string;
300
+ };
301
+ photos: Array<any>;
302
+ phones: Array<{
303
+ number: string;
304
+ }>;
305
+ registry_type: string;
306
+ doc_number: string;
307
+ _id: string;
308
+ }>;
309
+ items: Array<{
310
+ quantity: number;
311
+ customizations: Array<any>;
312
+ product_id: string;
313
+ variation_id: string;
314
+ picture: {
315
+ zoom: {
316
+ url: string;
317
+ size: string;
318
+ alt: string;
319
+ };
320
+ big: {
321
+ url: string;
322
+ size: string;
323
+ alt: string;
324
+ };
325
+ normal: {
326
+ url: string;
327
+ size: string;
328
+ alt: string;
329
+ };
330
+ };
331
+ sku: string;
332
+ name: string;
333
+ price: number;
334
+ final_price: number;
335
+ _id: string;
336
+ stock_status: string;
337
+ }>;
338
+ utm: {};
339
+ browser_ip: string;
340
+ client_user_agent: string;
341
+ channel_type: string;
342
+ domain: string;
343
+ checkout_link: string;
344
+ status_link: string;
345
+ amount: {
346
+ subtotal: number;
347
+ discount: number;
348
+ freight: number;
349
+ extra: number;
350
+ total: number;
351
+ };
352
+ shipping_lines: Array<{
353
+ _id: string;
354
+ app: {
355
+ _id: string;
356
+ label: string;
357
+ carrier: string;
358
+ service_name: string;
359
+ service_code: string;
360
+ icon: string;
361
+ };
362
+ to: {
363
+ zip: string;
364
+ province_code: string;
365
+ name: string;
366
+ city: string;
367
+ borough: string;
368
+ street: string;
369
+ number: number;
370
+ complement: string;
371
+ near_to: string;
372
+ };
373
+ from: {
374
+ zip: string;
375
+ street: string;
376
+ number: number;
377
+ };
378
+ own_hand: boolean;
379
+ receipt: boolean;
380
+ discount: number;
381
+ total_price: number;
382
+ delivery_time: {
383
+ days: number;
384
+ working_days: boolean;
385
+ };
386
+ posting_deadline: {
387
+ days: number;
388
+ working_days: boolean;
389
+ after_approval: boolean;
390
+ };
391
+ custom_fields: Array<{
392
+ field: string;
393
+ value: string;
394
+ }>;
395
+ package: {
396
+ dimensions: {
397
+ width: {
398
+ value: number;
399
+ unit: string;
400
+ };
401
+ height: {
402
+ value: number;
403
+ unit: string;
404
+ };
405
+ length: {
406
+ value: number;
407
+ unit: string;
408
+ };
409
+ };
410
+ weight: {
411
+ value: number;
412
+ unit: string;
413
+ };
414
+ };
415
+ }>;
416
+ shipping_method_label: string;
417
+ extra_discount: {
418
+ discount_coupon: string;
419
+ value: number;
420
+ flags: Array<string>;
421
+ app: {
422
+ label: string;
423
+ _id: string;
424
+ };
425
+ };
426
+ payment_method_label: string;
427
+ staff_signature: boolean;
428
+ source_name: string;
429
+ currency_id: string;
430
+ currency_symbol: string;
431
+ budget_only: boolean;
432
+ store_id: number;
433
+ created_at: string;
434
+ updated_at: string;
435
+ financial_status: {
436
+ current: string;
437
+ updated_at: string;
438
+ };
439
+ payments_history: Array<{
440
+ _id: string;
441
+ transaction_id: string;
442
+ status: string;
443
+ date_time: string;
444
+ flags: Array<string>;
445
+ notification_code?: string;
446
+ customer_notified?: boolean;
447
+ }>;
448
+ metafields: Array<{}>;
449
+ }
450
+ //#endregion
451
+ //#region [Order]
452
+ interface EcomOrderProduct {
453
+ _id: string;
454
+ product_id: string;
455
+ sku: string;
456
+ name: string;
457
+ picture: {
458
+ zoom: {
459
+ url: string;
460
+ size: string;
461
+ alt: string;
462
+ };
463
+ big: {
464
+ url: string;
465
+ size: string;
466
+ alt: string;
467
+ };
468
+ normal: {
469
+ url: string;
470
+ size: string;
471
+ alt: string;
472
+ };
473
+ };
474
+ quantity: number;
475
+ min_quantity: number;
476
+ max_quantity: number;
477
+ currency_id: string;
478
+ currency_symbol: string;
479
+ price: number;
480
+ final_price: number;
481
+ keep_item_quantity: boolean;
482
+ keep_item_price: boolean;
483
+ }
484
+ interface EcomCustomerOrder {
485
+ _id: string;
486
+ amount: {
487
+ subtotal: number;
488
+ discount: number;
489
+ freight: number;
490
+ extra: number;
491
+ total: number;
492
+ };
493
+ shipping_method_label: string;
494
+ payment_method_label: string;
495
+ number: number;
496
+ currency_id: string;
497
+ currency_symbol: string;
498
+ created_at: string;
499
+ }
500
+ interface GetProductDataResponse extends EcomProduct {
501
+ variations?: EcomProductVariations[];
502
+ }
503
+ //#endregion
504
+ //#region [Generics]
505
+ interface EcomPicture {
506
+ zoom: {
507
+ url: string;
508
+ size: string;
509
+ alt: string;
510
+ };
511
+ big: {
512
+ url: string;
513
+ size: string;
514
+ alt: string;
515
+ };
516
+ normal: {
517
+ url: string;
518
+ size: string;
519
+ alt: string;
520
+ };
521
+ _id?: string;
522
+ }
523
+ declare global {
524
+ interface Window extends EcomplusWindow {
525
+ }
526
+ }