@misiki/gocommerce-connector 0.23.0 → 0.25.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 +2 -1
- package/dist/{index-BM6hYdQs.d.cts → index-BWg1KptA.d.cts} +237 -3
- package/dist/{index-BM6hYdQs.d.ts → index-BWg1KptA.d.ts} +237 -3
- package/dist/index.cjs +75 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +74 -14
- package/dist/index.js.map +1 -1
- package/dist/services/index.cjs +75 -13
- package/dist/services/index.cjs.map +1 -1
- package/dist/services/index.d.cts +1 -1
- package/dist/services/index.d.ts +1 -1
- package/dist/services/index.js +74 -14
- package/dist/services/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -257,6 +257,9 @@ type CartLine = {
|
|
|
257
257
|
/** The add-on this line was bought as (D133), and the product it is offered with. */
|
|
258
258
|
add_on_id?: number;
|
|
259
259
|
add_on_for?: number;
|
|
260
|
+
/** The shopper's own design this line is made to (D162), and its picture. */
|
|
261
|
+
design_id?: string;
|
|
262
|
+
design_preview_url?: string;
|
|
260
263
|
compare_at_price?: Money;
|
|
261
264
|
};
|
|
262
265
|
/** A variant offered with a product, optionally at an offer price (D133). */
|
|
@@ -346,6 +349,13 @@ type OrderLine = {
|
|
|
346
349
|
shipped_quantity: number;
|
|
347
350
|
unit_price: Money;
|
|
348
351
|
total: Money;
|
|
352
|
+
/** `design` is a copy of the design a line was made to (D162), kept whatever later happens to it. */
|
|
353
|
+
metadata?: {
|
|
354
|
+
design?: {
|
|
355
|
+
id: string;
|
|
356
|
+
preview_url: string;
|
|
357
|
+
};
|
|
358
|
+
} & Record<string, unknown>;
|
|
349
359
|
};
|
|
350
360
|
type Fulfillment = {
|
|
351
361
|
id: number;
|
|
@@ -448,6 +458,97 @@ type GoogleSurvey = {
|
|
|
448
458
|
estimated_delivery_date: string;
|
|
449
459
|
opt_in_style?: string;
|
|
450
460
|
};
|
|
461
|
+
/** `GET /x/customizer/products/{id}` (ext/customizer, D162): a product's design editor, in the mockup's pixels. */
|
|
462
|
+
type CustomizerSetup = {
|
|
463
|
+
product_id: number;
|
|
464
|
+
mockup: {
|
|
465
|
+
url: string;
|
|
466
|
+
width: number;
|
|
467
|
+
height: number;
|
|
468
|
+
};
|
|
469
|
+
overlay_url: string | null;
|
|
470
|
+
print_area: {
|
|
471
|
+
x: number;
|
|
472
|
+
y: number;
|
|
473
|
+
width: number;
|
|
474
|
+
height: number;
|
|
475
|
+
radius: number;
|
|
476
|
+
};
|
|
477
|
+
print_size: {
|
|
478
|
+
width_mm: number;
|
|
479
|
+
height_mm: number;
|
|
480
|
+
dpi: number;
|
|
481
|
+
};
|
|
482
|
+
tools: {
|
|
483
|
+
upload: boolean;
|
|
484
|
+
text: boolean;
|
|
485
|
+
shapes: boolean;
|
|
486
|
+
background: boolean;
|
|
487
|
+
stickers: boolean;
|
|
488
|
+
};
|
|
489
|
+
fonts: {
|
|
490
|
+
key: string;
|
|
491
|
+
family: string;
|
|
492
|
+
}[];
|
|
493
|
+
stickers: {
|
|
494
|
+
id: number;
|
|
495
|
+
url: string;
|
|
496
|
+
width: number;
|
|
497
|
+
height: number;
|
|
498
|
+
}[];
|
|
499
|
+
min_photo_px: number;
|
|
500
|
+
consent: string;
|
|
501
|
+
};
|
|
502
|
+
/** `POST /x/customizer/uploads`: the file as the engine kept it, turned upright, so its size is as seen. */
|
|
503
|
+
type CustomizerUpload = {
|
|
504
|
+
upload_id: string;
|
|
505
|
+
url: string;
|
|
506
|
+
width: number;
|
|
507
|
+
height: number;
|
|
508
|
+
};
|
|
509
|
+
/** `POST /x/customizer/designs`. */
|
|
510
|
+
type CustomizerDesign = {
|
|
511
|
+
design_id: string;
|
|
512
|
+
preview_url: string;
|
|
513
|
+
};
|
|
514
|
+
/**
|
|
515
|
+
* A design, version 1, as the engine checks it and stores it on the order:
|
|
516
|
+
* coordinates in the mockup's pixels from the print area's top left corner,
|
|
517
|
+
* layers drawn first to last. The engine refuses a field a layer's type does
|
|
518
|
+
* not carry.
|
|
519
|
+
*/
|
|
520
|
+
type CustomizerDocument = {
|
|
521
|
+
version: 1;
|
|
522
|
+
background?: string | null;
|
|
523
|
+
layers: CustomizerLayer[];
|
|
524
|
+
};
|
|
525
|
+
type CustomizerLayer = {
|
|
526
|
+
id: string;
|
|
527
|
+
x: number;
|
|
528
|
+
y: number;
|
|
529
|
+
width: number;
|
|
530
|
+
height: number;
|
|
531
|
+
/** Degrees clockwise about the box's centre. */
|
|
532
|
+
rotation: number;
|
|
533
|
+
opacity: number;
|
|
534
|
+
} & ({
|
|
535
|
+
type: 'image';
|
|
536
|
+
upload_id: string;
|
|
537
|
+
} | {
|
|
538
|
+
type: 'text';
|
|
539
|
+
text: string;
|
|
540
|
+
font: string;
|
|
541
|
+
color: string;
|
|
542
|
+
font_size: number;
|
|
543
|
+
align?: 'left' | 'center' | 'right';
|
|
544
|
+
} | {
|
|
545
|
+
type: 'shape';
|
|
546
|
+
shape: 'rect' | 'circle' | 'heart' | 'star';
|
|
547
|
+
color: string;
|
|
548
|
+
} | {
|
|
549
|
+
type: 'sticker';
|
|
550
|
+
sticker_media_id: number;
|
|
551
|
+
});
|
|
451
552
|
/** `GET /api/store`: what anyone may read about the shop. */
|
|
452
553
|
type StoreProfile = {
|
|
453
554
|
name: string;
|
|
@@ -1021,6 +1122,9 @@ declare function toCartLine(l: CartLine, extra?: {
|
|
|
1021
1122
|
/** The add-on this line was bought as (D133), or null on an ordinary line. */
|
|
1022
1123
|
addOnId: string | null;
|
|
1023
1124
|
addOnFor: string | null;
|
|
1125
|
+
/** The shopper's own design this line is made to (D162) and its picture, or null on a line sold as it is. */
|
|
1126
|
+
designId: string | null;
|
|
1127
|
+
designPreview: string | null;
|
|
1024
1128
|
subtotal: number;
|
|
1025
1129
|
total: number;
|
|
1026
1130
|
inStock: boolean;
|
|
@@ -1072,6 +1176,9 @@ declare function toCart(c: Cart, extras?: CartExtras, lineExtra?: (l: CartLine)
|
|
|
1072
1176
|
/** The add-on this line was bought as (D133), or null on an ordinary line. */
|
|
1073
1177
|
addOnId: string | null;
|
|
1074
1178
|
addOnFor: string | null;
|
|
1179
|
+
/** The shopper's own design this line is made to (D162) and its picture, or null on a line sold as it is. */
|
|
1180
|
+
designId: string | null;
|
|
1181
|
+
designPreview: string | null;
|
|
1075
1182
|
subtotal: number;
|
|
1076
1183
|
total: number;
|
|
1077
1184
|
inStock: boolean;
|
|
@@ -1214,6 +1321,8 @@ declare function toOrder(o: Order): {
|
|
|
1214
1321
|
total: number;
|
|
1215
1322
|
currencyCode: string;
|
|
1216
1323
|
status: string;
|
|
1324
|
+
designId: string | null;
|
|
1325
|
+
designPreview: string | null;
|
|
1217
1326
|
files: never[];
|
|
1218
1327
|
usedOptions: never[];
|
|
1219
1328
|
}[];
|
|
@@ -3282,6 +3391,8 @@ declare class CartService extends BaseService {
|
|
|
3282
3391
|
mrp: number;
|
|
3283
3392
|
addOnId: string | null;
|
|
3284
3393
|
addOnFor: string | null;
|
|
3394
|
+
designId: string | null;
|
|
3395
|
+
designPreview: string | null;
|
|
3285
3396
|
subtotal: number;
|
|
3286
3397
|
total: number;
|
|
3287
3398
|
inStock: boolean;
|
|
@@ -3368,6 +3479,8 @@ declare class CartService extends BaseService {
|
|
|
3368
3479
|
mrp: number;
|
|
3369
3480
|
addOnId: string | null;
|
|
3370
3481
|
addOnFor: string | null;
|
|
3482
|
+
designId: string | null;
|
|
3483
|
+
designPreview: string | null;
|
|
3371
3484
|
subtotal: number;
|
|
3372
3485
|
total: number;
|
|
3373
3486
|
inStock: boolean;
|
|
@@ -3459,6 +3572,8 @@ declare class CartService extends BaseService {
|
|
|
3459
3572
|
mrp: number;
|
|
3460
3573
|
addOnId: string | null;
|
|
3461
3574
|
addOnFor: string | null;
|
|
3575
|
+
designId: string | null;
|
|
3576
|
+
designPreview: string | null;
|
|
3462
3577
|
subtotal: number;
|
|
3463
3578
|
total: number;
|
|
3464
3579
|
inStock: boolean;
|
|
@@ -3526,14 +3641,17 @@ declare class CartService extends BaseService {
|
|
|
3526
3641
|
}>;
|
|
3527
3642
|
/**
|
|
3528
3643
|
* `qty` is a change, not a total: +1 from a product page, −1 from a card's
|
|
3529
|
-
* minus button. With no cart yet, one is opened and remembered.
|
|
3644
|
+
* minus button. With no cart yet, one is opened and remembered. A
|
|
3645
|
+
* `designId` from `customizerService.saveDesign` makes the variant to the
|
|
3646
|
+
* shopper's design, on a line of its own.
|
|
3530
3647
|
*/
|
|
3531
|
-
addToCart({ cartId, lineId, qty, variantId, }: {
|
|
3648
|
+
addToCart({ cartId, lineId, qty, variantId, designId, }: {
|
|
3532
3649
|
cartId?: string | null;
|
|
3533
3650
|
lineId?: string | null;
|
|
3534
3651
|
qty?: number;
|
|
3535
3652
|
productId?: string;
|
|
3536
3653
|
variantId?: string;
|
|
3654
|
+
designId?: string;
|
|
3537
3655
|
}): Promise<{
|
|
3538
3656
|
id: string;
|
|
3539
3657
|
status: "open" | "converted" | "abandoned";
|
|
@@ -3555,6 +3673,8 @@ declare class CartService extends BaseService {
|
|
|
3555
3673
|
mrp: number;
|
|
3556
3674
|
addOnId: string | null;
|
|
3557
3675
|
addOnFor: string | null;
|
|
3676
|
+
designId: string | null;
|
|
3677
|
+
designPreview: string | null;
|
|
3558
3678
|
subtotal: number;
|
|
3559
3679
|
total: number;
|
|
3560
3680
|
inStock: boolean;
|
|
@@ -3651,6 +3771,8 @@ declare class CartService extends BaseService {
|
|
|
3651
3771
|
mrp: number;
|
|
3652
3772
|
addOnId: string | null;
|
|
3653
3773
|
addOnFor: string | null;
|
|
3774
|
+
designId: string | null;
|
|
3775
|
+
designPreview: string | null;
|
|
3654
3776
|
subtotal: number;
|
|
3655
3777
|
total: number;
|
|
3656
3778
|
inStock: boolean;
|
|
@@ -3768,6 +3890,8 @@ declare class CartService extends BaseService {
|
|
|
3768
3890
|
mrp: number;
|
|
3769
3891
|
addOnId: string | null;
|
|
3770
3892
|
addOnFor: string | null;
|
|
3893
|
+
designId: string | null;
|
|
3894
|
+
designPreview: string | null;
|
|
3771
3895
|
subtotal: number;
|
|
3772
3896
|
total: number;
|
|
3773
3897
|
inStock: boolean;
|
|
@@ -3857,6 +3981,8 @@ declare class CartService extends BaseService {
|
|
|
3857
3981
|
mrp: number;
|
|
3858
3982
|
addOnId: string | null;
|
|
3859
3983
|
addOnFor: string | null;
|
|
3984
|
+
designId: string | null;
|
|
3985
|
+
designPreview: string | null;
|
|
3860
3986
|
subtotal: number;
|
|
3861
3987
|
total: number;
|
|
3862
3988
|
inStock: boolean;
|
|
@@ -3955,6 +4081,8 @@ declare class CartService extends BaseService {
|
|
|
3955
4081
|
mrp: number;
|
|
3956
4082
|
addOnId: string | null;
|
|
3957
4083
|
addOnFor: string | null;
|
|
4084
|
+
designId: string | null;
|
|
4085
|
+
designPreview: string | null;
|
|
3958
4086
|
subtotal: number;
|
|
3959
4087
|
total: number;
|
|
3960
4088
|
inStock: boolean;
|
|
@@ -4049,6 +4177,8 @@ declare class CartService extends BaseService {
|
|
|
4049
4177
|
mrp: number;
|
|
4050
4178
|
addOnId: string | null;
|
|
4051
4179
|
addOnFor: string | null;
|
|
4180
|
+
designId: string | null;
|
|
4181
|
+
designPreview: string | null;
|
|
4052
4182
|
subtotal: number;
|
|
4053
4183
|
total: number;
|
|
4054
4184
|
inStock: boolean;
|
|
@@ -4116,6 +4246,8 @@ declare class CartService extends BaseService {
|
|
|
4116
4246
|
mrp: number;
|
|
4117
4247
|
addOnId: string | null;
|
|
4118
4248
|
addOnFor: string | null;
|
|
4249
|
+
designId: string | null;
|
|
4250
|
+
designPreview: string | null;
|
|
4119
4251
|
subtotal: number;
|
|
4120
4252
|
total: number;
|
|
4121
4253
|
inStock: boolean;
|
|
@@ -4206,6 +4338,8 @@ declare class CartService extends BaseService {
|
|
|
4206
4338
|
mrp: number;
|
|
4207
4339
|
addOnId: string | null;
|
|
4208
4340
|
addOnFor: string | null;
|
|
4341
|
+
designId: string | null;
|
|
4342
|
+
designPreview: string | null;
|
|
4209
4343
|
subtotal: number;
|
|
4210
4344
|
total: number;
|
|
4211
4345
|
inStock: boolean;
|
|
@@ -4296,6 +4430,8 @@ declare class CartService extends BaseService {
|
|
|
4296
4430
|
mrp: number;
|
|
4297
4431
|
addOnId: string | null;
|
|
4298
4432
|
addOnFor: string | null;
|
|
4433
|
+
designId: string | null;
|
|
4434
|
+
designPreview: string | null;
|
|
4299
4435
|
subtotal: number;
|
|
4300
4436
|
total: number;
|
|
4301
4437
|
inStock: boolean;
|
|
@@ -4372,6 +4508,82 @@ declare class CartService extends BaseService {
|
|
|
4372
4508
|
}
|
|
4373
4509
|
declare const cartService: CartService;
|
|
4374
4510
|
|
|
4511
|
+
/** What a product's design editor draws and offers, in the mockup's pixels. */
|
|
4512
|
+
type CustomizerEditor = {
|
|
4513
|
+
productId: string;
|
|
4514
|
+
mockup: {
|
|
4515
|
+
url: string;
|
|
4516
|
+
width: number;
|
|
4517
|
+
height: number;
|
|
4518
|
+
};
|
|
4519
|
+
/** Drawn above the design: the camera cut-out, the case's edges. */
|
|
4520
|
+
overlayUrl: string | null;
|
|
4521
|
+
printArea: {
|
|
4522
|
+
x: number;
|
|
4523
|
+
y: number;
|
|
4524
|
+
width: number;
|
|
4525
|
+
height: number;
|
|
4526
|
+
radius: number;
|
|
4527
|
+
};
|
|
4528
|
+
printSize: {
|
|
4529
|
+
widthMm: number;
|
|
4530
|
+
heightMm: number;
|
|
4531
|
+
dpi: number;
|
|
4532
|
+
};
|
|
4533
|
+
tools: {
|
|
4534
|
+
upload: boolean;
|
|
4535
|
+
text: boolean;
|
|
4536
|
+
shapes: boolean;
|
|
4537
|
+
background: boolean;
|
|
4538
|
+
stickers: boolean;
|
|
4539
|
+
};
|
|
4540
|
+
fonts: {
|
|
4541
|
+
key: string;
|
|
4542
|
+
family: string;
|
|
4543
|
+
}[];
|
|
4544
|
+
stickers: {
|
|
4545
|
+
id: number;
|
|
4546
|
+
url: string;
|
|
4547
|
+
width: number;
|
|
4548
|
+
height: number;
|
|
4549
|
+
}[];
|
|
4550
|
+
/** A photo whose shorter side is below this is likely to print soft: warn, the engine still takes it. */
|
|
4551
|
+
minPhotoPx: number;
|
|
4552
|
+
/** Shown before the shopper chooses a photo. */
|
|
4553
|
+
consent: string;
|
|
4554
|
+
};
|
|
4555
|
+
type CustomizerFile = {
|
|
4556
|
+
uploadId: string;
|
|
4557
|
+
url: string;
|
|
4558
|
+
width: number;
|
|
4559
|
+
height: number;
|
|
4560
|
+
};
|
|
4561
|
+
type CustomizerSavedDesign = {
|
|
4562
|
+
designId: string;
|
|
4563
|
+
previewUrl: string;
|
|
4564
|
+
};
|
|
4565
|
+
/**
|
|
4566
|
+
* A shopper's own design on a product (ext/customizer, D162). Every URL goes
|
|
4567
|
+
* through the proxy path when one is set, so it is same-origin and a canvas
|
|
4568
|
+
* that draws it can still be exported.
|
|
4569
|
+
*/
|
|
4570
|
+
declare class CustomizerService extends BaseService {
|
|
4571
|
+
private readonly facts;
|
|
4572
|
+
/** Null when the product cannot be designed, or on any failure: the page draws without the editor. */
|
|
4573
|
+
setup(productId: string | number): Promise<CustomizerEditor | null>;
|
|
4574
|
+
/** A photo, or the finished preview or print file. The engine's refusal is thrown with its message. */
|
|
4575
|
+
upload(file: Blob, filename?: string): Promise<CustomizerFile>;
|
|
4576
|
+
/** The document goes as it is: the order keeps it, and whatever renders the print reads it there. */
|
|
4577
|
+
saveDesign(design: {
|
|
4578
|
+
productId: string | number;
|
|
4579
|
+
variantId: string | number;
|
|
4580
|
+
previewUploadId: string;
|
|
4581
|
+
printUploadId: string;
|
|
4582
|
+
document: CustomizerDocument;
|
|
4583
|
+
}): Promise<CustomizerSavedDesign>;
|
|
4584
|
+
}
|
|
4585
|
+
declare const customizerService: CustomizerService;
|
|
4586
|
+
|
|
4375
4587
|
/**
|
|
4376
4588
|
* Placing an order.
|
|
4377
4589
|
*
|
|
@@ -4571,6 +4783,8 @@ declare class CheckoutService extends BaseService {
|
|
|
4571
4783
|
total: number;
|
|
4572
4784
|
currencyCode: string;
|
|
4573
4785
|
status: string;
|
|
4786
|
+
designId: string | null;
|
|
4787
|
+
designPreview: string | null;
|
|
4574
4788
|
files: never[];
|
|
4575
4789
|
usedOptions: never[];
|
|
4576
4790
|
}[];
|
|
@@ -4780,6 +4994,8 @@ declare class OrderService extends BaseService {
|
|
|
4780
4994
|
total: number;
|
|
4781
4995
|
currencyCode: string;
|
|
4782
4996
|
status: string;
|
|
4997
|
+
designId: string | null;
|
|
4998
|
+
designPreview: string | null;
|
|
4783
4999
|
files: never[];
|
|
4784
5000
|
usedOptions: never[];
|
|
4785
5001
|
}[];
|
|
@@ -4884,6 +5100,8 @@ declare class OrderService extends BaseService {
|
|
|
4884
5100
|
total: number;
|
|
4885
5101
|
currencyCode: string;
|
|
4886
5102
|
status: string;
|
|
5103
|
+
designId: string | null;
|
|
5104
|
+
designPreview: string | null;
|
|
4887
5105
|
files: never[];
|
|
4888
5106
|
usedOptions: never[];
|
|
4889
5107
|
}[];
|
|
@@ -4986,6 +5204,8 @@ declare class OrderService extends BaseService {
|
|
|
4986
5204
|
total: number;
|
|
4987
5205
|
currencyCode: string;
|
|
4988
5206
|
status: string;
|
|
5207
|
+
designId: string | null;
|
|
5208
|
+
designPreview: string | null;
|
|
4989
5209
|
files: never[];
|
|
4990
5210
|
usedOptions: never[];
|
|
4991
5211
|
}[];
|
|
@@ -5110,6 +5330,8 @@ declare class OrderService extends BaseService {
|
|
|
5110
5330
|
total: number;
|
|
5111
5331
|
currencyCode: string;
|
|
5112
5332
|
status: string;
|
|
5333
|
+
designId: string | null;
|
|
5334
|
+
designPreview: string | null;
|
|
5113
5335
|
files: never[];
|
|
5114
5336
|
usedOptions: never[];
|
|
5115
5337
|
}[];
|
|
@@ -5216,6 +5438,8 @@ declare class OrderService extends BaseService {
|
|
|
5216
5438
|
total: number;
|
|
5217
5439
|
currencyCode: string;
|
|
5218
5440
|
status: string;
|
|
5441
|
+
designId: string | null;
|
|
5442
|
+
designPreview: string | null;
|
|
5219
5443
|
files: never[];
|
|
5220
5444
|
usedOptions: never[];
|
|
5221
5445
|
}[];
|
|
@@ -5334,6 +5558,8 @@ declare class OrderService extends BaseService {
|
|
|
5334
5558
|
total: number;
|
|
5335
5559
|
currencyCode: string;
|
|
5336
5560
|
status: string;
|
|
5561
|
+
designId: string | null;
|
|
5562
|
+
designPreview: string | null;
|
|
5337
5563
|
files: never[];
|
|
5338
5564
|
usedOptions: never[];
|
|
5339
5565
|
}[];
|
|
@@ -5593,6 +5819,8 @@ declare class UserService extends BaseService {
|
|
|
5593
5819
|
total: number;
|
|
5594
5820
|
currencyCode: string;
|
|
5595
5821
|
status: string;
|
|
5822
|
+
designId: string | null;
|
|
5823
|
+
designPreview: string | null;
|
|
5596
5824
|
files: never[];
|
|
5597
5825
|
usedOptions: never[];
|
|
5598
5826
|
}[];
|
|
@@ -7433,6 +7661,8 @@ declare class B2bService extends BaseService {
|
|
|
7433
7661
|
mrp: number;
|
|
7434
7662
|
addOnId: string | null;
|
|
7435
7663
|
addOnFor: string | null;
|
|
7664
|
+
designId: string | null;
|
|
7665
|
+
designPreview: string | null;
|
|
7436
7666
|
subtotal: number;
|
|
7437
7667
|
total: number;
|
|
7438
7668
|
inStock: boolean;
|
|
@@ -7504,6 +7734,8 @@ declare class B2bService extends BaseService {
|
|
|
7504
7734
|
mrp: number;
|
|
7505
7735
|
addOnId: string | null;
|
|
7506
7736
|
addOnFor: string | null;
|
|
7737
|
+
designId: string | null;
|
|
7738
|
+
designPreview: string | null;
|
|
7507
7739
|
subtotal: number;
|
|
7508
7740
|
total: number;
|
|
7509
7741
|
inStock: boolean;
|
|
@@ -7663,6 +7895,8 @@ declare class B2bService extends BaseService {
|
|
|
7663
7895
|
total: number;
|
|
7664
7896
|
currencyCode: string;
|
|
7665
7897
|
status: string;
|
|
7898
|
+
designId: string | null;
|
|
7899
|
+
designPreview: string | null;
|
|
7666
7900
|
files: never[];
|
|
7667
7901
|
usedOptions: never[];
|
|
7668
7902
|
}[];
|
|
@@ -7739,4 +7973,4 @@ declare class B2bService extends BaseService {
|
|
|
7739
7973
|
}
|
|
7740
7974
|
declare const b2bService: B2bService;
|
|
7741
7975
|
|
|
7742
|
-
export {
|
|
7976
|
+
export { FaqService as $, type AddOn as A, type B2bPlaced as B, type Cart as C, type CompanyOrder as D, ContactService as E, CountryService as F, CouponService as G, type Credentials as H, type Credit as I, CurrencyService as J, type Customer as K, type CustomizerDesign as L, type CustomizerDocument as M, type CustomizerEditor as N, type CustomizerFile as O, type CustomizerLayer as P, type CustomizerSavedDesign as Q, CustomizerService as R, type CustomizerSetup as S, type CustomizerUpload as T, DealService as U, DemoRequestService as V, type EngineRequest as W, EnquiryService as X, type Envelope as Y, type FacetValue as Z, type Faq as _, type Address as a, type SiteFooter as a$, FeedbackService as a0, type FooterSettings as a1, type FreeShipping as a2, type Fulfillment as a3, GalleryService as a4, type GooglePlace as a5, type GoogleReview as a6, GoogleReviewService as a7, type GoogleReviews as a8, type GoogleSurvey as a9, PageService as aA, type PaymentIntent as aB, PaymentMethodService as aC, type Plugin as aD, PluginService as aE, PopularSearchService as aF, PopularityService as aG, type Postcode as aH, type Product as aI, type ProductFacets as aJ, type ProductOption as aK, ProductService as aL, ProfileService as aM, type Quote as aN, REDIRECT_GATEWAYS as aO, ReelsService as aP, RegionService as aQ, type RejectedLine as aR, type Review as aS, type ReviewPage as aT, ReviewService as aU, type SearchDoc as aV, type SearchResult as aW, SearchService as aX, SettingService as aY, type ShippingRate as aZ, type SiteChrome as a_, type HeaderSettings as aa, type HomeLayout as ab, type HomeLayoutSection as ac, HomeService as ad, type IdentityAddress as ae, InitService as af, type Invitation as ag, type LayoutCollection as ah, type LayoutPage as ai, LayoutService as aj, type Lead as ak, type ListMeta as al, MeilisearchService as am, type Member as an, type Menu as ao, type MenuItem as ap, MenuService as aq, type MenuSummary as ar, type Money as as, NewsletterService as at, type Offer as au, type OpeningHours as av, type Order as aw, type OrderLine as ax, OrderService as ay, type PageLayout as az, AddressService as b, newsletterService as b$, type SiteHeader as b0, type SocialLink as b1, StateService as b2, type StoreProfile as b3, StoreService as b4, type StorefrontCategory as b5, type StorefrontMenu as b6, type StorefrontOrder as b7, type StorefrontProduct as b8, type ThemeSettings as b9, checkoutService as bA, collectionService as bB, contactService as bC, countryService as bD, couponService as bE, currencyExponent as bF, currencyService as bG, customizerService as bH, dealService as bI, demoRequestService as bJ, emptyCart as bK, emptyPage as bL, enquiryService as bM, faqService as bN, feedbackService as bO, fromEngineAddress as bP, fromIdentityAddress as bQ, fromSearchDoc as bR, galleryService as bS, googleReviewService as bT, homeService as bU, initService as bV, layoutService as bW, mediaUrl as bX, meilisearchService as bY, menuService as bZ, minorToMajor as b_, type ThemeSettingsResult as ba, UploadService as bb, UserService as bc, type Variant as bd, type VariantImage as be, VariantService as bf, VarniCustomDesignService as bg, VarniCustomProductService as bh, type Vendor as bi, VendorService as bj, WarrantyService as bk, type WhatsappConsent as bl, type WhatsappConsentOffer as bm, WhatsappService as bn, type Wishlist as bo, type WishlistItem as bp, WishlistService as bq, addressService as br, authService as bs, autocompleteService as bt, b2bService as bu, bannerService as bv, blogService as bw, cartService as bx, categoryService as by, chatService as bz, type AppliedDiscount as c, orderService as c0, ownDomain as c1, pageService as c2, paymentMethodService as c3, pluginService as c4, pluginsService as c5, popularSearchService as c6, popularityService as c7, priceOf as c8, productImages as c9, toMinor as cA, toOrder as cB, toPage as cC, toProduct as cD, toRating as cE, toStorefrontFacets as cF, toUser as cG, toVariant as cH, toVendor as cI, uploadService as cJ, userService as cK, variantService as cL, varniCustomDesignService as cM, varniCustomProductService as cN, vendorService as cO, warrantyService as cP, whatsappService as cQ, wishlistService as cR, productService as ca, productVideos as cb, profileService as cc, qs as cd, reelsService as ce, regionService as cf, reviewService as cg, searchService as ch, setRequestHost as ci, settingService as cj, settingsService as ck, stateService as cl, staticStore as cm, storeForHost as cn, storeService as co, toAddOn as cp, toCart as cq, toCartLine as cr, toCartOffer as cs, toCategory as ct, toCmsPage as cu, toCollection as cv, toEngineAddress as cw, toFreeShipping as cx, toIdentityAddress as cy, toMajor as cz, type Approval as d, type AuthResponse as e, AuthService as f, AutocompleteService as g, type B2bRole as h, B2bService as i, BannerService as j, BaseService as k, BlogService as l, type CartLine as m, type CartOffer as n, CartService as o, CatalogService as p, type Category as q, CategoryService as r, ChatService as s, type CheckoutOptions as t, type CheckoutResult as u, CheckoutService as v, type CmsPage as w, type Collection as x, CollectionService as y, type Company as z };
|
package/dist/index.cjs
CHANGED
|
@@ -377,7 +377,8 @@ var BaseService = class _BaseService {
|
|
|
377
377
|
const lang = (req.method ?? "GET") === "GET" ? this.creds.language : void 0;
|
|
378
378
|
const url = this.engineURL(path, lang ? { lang, ...req.query } : req.query);
|
|
379
379
|
const headers = { Accept: "application/json", ...req.headers };
|
|
380
|
-
|
|
380
|
+
const form = req.body instanceof FormData ? req.body : void 0;
|
|
381
|
+
if (req.body !== void 0 && !form) headers["Content-Type"] = "application/json";
|
|
381
382
|
const store = this.store;
|
|
382
383
|
if (store) headers["X-Store"] = store;
|
|
383
384
|
if (req.auth) {
|
|
@@ -388,7 +389,7 @@ var BaseService = class _BaseService {
|
|
|
388
389
|
const init = {
|
|
389
390
|
method: req.method ?? "GET",
|
|
390
391
|
headers,
|
|
391
|
-
body: req.body === void 0 ? void 0 : JSON.stringify(req.body)
|
|
392
|
+
body: form ?? (req.body === void 0 ? void 0 : JSON.stringify(req.body))
|
|
392
393
|
};
|
|
393
394
|
let res;
|
|
394
395
|
try {
|
|
@@ -844,6 +845,9 @@ function toCartLine(l, extra = {}) {
|
|
|
844
845
|
/** The add-on this line was bought as (D133), or null on an ordinary line. */
|
|
845
846
|
addOnId: l.add_on_id ? str(l.add_on_id) : null,
|
|
846
847
|
addOnFor: l.add_on_for ? str(l.add_on_for) : null,
|
|
848
|
+
/** The shopper's own design this line is made to (D162) and its picture, or null on a line sold as it is. */
|
|
849
|
+
designId: l.design_id ?? null,
|
|
850
|
+
designPreview: mediaUrl(l.design_preview_url),
|
|
847
851
|
subtotal: toMajor(l.total),
|
|
848
852
|
total: toMajor(l.total),
|
|
849
853
|
inStock: l.in_stock,
|
|
@@ -958,6 +962,8 @@ function toOrderLine(l, currency) {
|
|
|
958
962
|
total: toMajor(l.total),
|
|
959
963
|
currencyCode: currency,
|
|
960
964
|
status: l.shipped_quantity >= l.quantity ? "Shipped" : "Pending",
|
|
965
|
+
designId: l.metadata?.design?.id ?? null,
|
|
966
|
+
designPreview: mediaUrl(l.metadata?.design?.preview_url),
|
|
961
967
|
files: [],
|
|
962
968
|
usedOptions: []
|
|
963
969
|
};
|
|
@@ -1775,13 +1781,16 @@ var CartService = class extends BaseService {
|
|
|
1775
1781
|
}
|
|
1776
1782
|
/**
|
|
1777
1783
|
* `qty` is a change, not a total: +1 from a product page, −1 from a card's
|
|
1778
|
-
* minus button. With no cart yet, one is opened and remembered.
|
|
1784
|
+
* minus button. With no cart yet, one is opened and remembered. A
|
|
1785
|
+
* `designId` from `customizerService.saveDesign` makes the variant to the
|
|
1786
|
+
* shopper's design, on a line of its own.
|
|
1779
1787
|
*/
|
|
1780
1788
|
async addToCart({
|
|
1781
1789
|
cartId,
|
|
1782
1790
|
lineId,
|
|
1783
1791
|
qty = 1,
|
|
1784
|
-
variantId
|
|
1792
|
+
variantId,
|
|
1793
|
+
designId
|
|
1785
1794
|
}) {
|
|
1786
1795
|
let id2 = clean(cartId) ?? storedCartId();
|
|
1787
1796
|
if (lineId && id2) {
|
|
@@ -1795,21 +1804,16 @@ var CartService = class extends BaseService {
|
|
|
1795
1804
|
if (qty === REMOVE || Number(qty) <= 0) return this.getCartByCartId(id2);
|
|
1796
1805
|
if (!variantId) throw new GoCommerceError("Please choose an option before adding this to your bag.", 400);
|
|
1797
1806
|
if (!id2) id2 = await this.open();
|
|
1807
|
+
const body = { variant_id: Number(variantId), quantity: Number(qty), ...designId ? { design_id: designId } : {} };
|
|
1798
1808
|
try {
|
|
1799
1809
|
return await this.present(
|
|
1800
|
-
await this.data(`/api/carts/${encodeURIComponent(id2)}/line-items`, {
|
|
1801
|
-
method: "POST",
|
|
1802
|
-
body: { variant_id: Number(variantId), quantity: Number(qty) }
|
|
1803
|
-
})
|
|
1810
|
+
await this.data(`/api/carts/${encodeURIComponent(id2)}/line-items`, { method: "POST", body })
|
|
1804
1811
|
);
|
|
1805
1812
|
} catch (err) {
|
|
1806
|
-
if (err instanceof GoCommerceError &&
|
|
1813
|
+
if (err instanceof GoCommerceError && /cart not found|checked out/.test(err.message)) {
|
|
1807
1814
|
const fresh = await this.open();
|
|
1808
1815
|
return this.present(
|
|
1809
|
-
await this.data(`/api/carts/${encodeURIComponent(fresh)}/line-items`, {
|
|
1810
|
-
method: "POST",
|
|
1811
|
-
body: { variant_id: Number(variantId), quantity: Number(qty) }
|
|
1812
|
-
})
|
|
1816
|
+
await this.data(`/api/carts/${encodeURIComponent(fresh)}/line-items`, { method: "POST", body })
|
|
1813
1817
|
);
|
|
1814
1818
|
}
|
|
1815
1819
|
throw err;
|
|
@@ -2046,6 +2050,54 @@ var CartService = class extends BaseService {
|
|
|
2046
2050
|
var clean = (id2) => id2 && id2 !== "undefined" && id2 !== "null" ? id2 : null;
|
|
2047
2051
|
var cartService = new CartService();
|
|
2048
2052
|
|
|
2053
|
+
// src/services/customizer-service.ts
|
|
2054
|
+
var CustomizerService = class extends BaseService {
|
|
2055
|
+
facts = new StoreFacts(this._fetch);
|
|
2056
|
+
/** Null when the product cannot be designed, or on any failure: the page draws without the editor. */
|
|
2057
|
+
async setup(productId) {
|
|
2058
|
+
const plugins = await this.facts.plugins().catch(() => null);
|
|
2059
|
+
if (plugins && !plugins.has("customizer")) return null;
|
|
2060
|
+
const path = `/x/customizer/products/${encodeURIComponent(String(productId))}`;
|
|
2061
|
+
const s = await this.data(path).catch(() => null);
|
|
2062
|
+
if (!s) return null;
|
|
2063
|
+
return {
|
|
2064
|
+
productId: String(s.product_id),
|
|
2065
|
+
mockup: { ...s.mockup, url: media(s.mockup.url) },
|
|
2066
|
+
overlayUrl: mediaUrl(s.overlay_url),
|
|
2067
|
+
printArea: s.print_area,
|
|
2068
|
+
printSize: { widthMm: s.print_size.width_mm, heightMm: s.print_size.height_mm, dpi: s.print_size.dpi },
|
|
2069
|
+
tools: s.tools,
|
|
2070
|
+
fonts: s.fonts,
|
|
2071
|
+
stickers: s.stickers.map((k) => ({ ...k, url: media(k.url) })),
|
|
2072
|
+
minPhotoPx: s.min_photo_px,
|
|
2073
|
+
consent: s.consent
|
|
2074
|
+
};
|
|
2075
|
+
}
|
|
2076
|
+
/** A photo, or the finished preview or print file. The engine's refusal is thrown with its message. */
|
|
2077
|
+
async upload(file, filename) {
|
|
2078
|
+
const body = new FormData();
|
|
2079
|
+
body.append("file", file, filename);
|
|
2080
|
+
const u = await this.data("/x/customizer/uploads", { method: "POST", body });
|
|
2081
|
+
return { uploadId: u.upload_id, url: media(u.url), width: u.width, height: u.height };
|
|
2082
|
+
}
|
|
2083
|
+
/** The document goes as it is: the order keeps it, and whatever renders the print reads it there. */
|
|
2084
|
+
async saveDesign(design) {
|
|
2085
|
+
const d = await this.data("/x/customizer/designs", {
|
|
2086
|
+
method: "POST",
|
|
2087
|
+
body: {
|
|
2088
|
+
product_id: Number(design.productId),
|
|
2089
|
+
variant_id: Number(design.variantId),
|
|
2090
|
+
preview_upload_id: design.previewUploadId,
|
|
2091
|
+
print_upload_id: design.printUploadId,
|
|
2092
|
+
document: design.document
|
|
2093
|
+
}
|
|
2094
|
+
});
|
|
2095
|
+
return { designId: d.design_id, previewUrl: media(d.preview_url) };
|
|
2096
|
+
}
|
|
2097
|
+
};
|
|
2098
|
+
var media = (url) => mediaUrl(url) ?? url;
|
|
2099
|
+
var customizerService = new CustomizerService();
|
|
2100
|
+
|
|
2049
2101
|
// src/services/checkout-service.ts
|
|
2050
2102
|
var CheckoutService = class extends BaseService {
|
|
2051
2103
|
/** Delivery options for the address on the cart: `{ data: [{ id, name, base_rate }] }`. */
|
|
@@ -3208,6 +3260,14 @@ var StoreService = class extends BaseService {
|
|
|
3208
3260
|
message: String(plugins.get("whatsapp-chat")?.settings?.message ?? "")
|
|
3209
3261
|
} : {}
|
|
3210
3262
|
},
|
|
3263
|
+
// Criteo's OneTag, for this store's own account. The engine decides: on a shared
|
|
3264
|
+
// deployment the static record is every store's, and one store's account must
|
|
3265
|
+
// never load on another's pages.
|
|
3266
|
+
criteo: {
|
|
3267
|
+
...basePlugins.criteo,
|
|
3268
|
+
...flag(plugins.has("criteo")),
|
|
3269
|
+
...plugins.has("criteo") ? { accountId: String(plugins.get("criteo")?.settings?.account_id ?? "") } : {}
|
|
3270
|
+
},
|
|
3211
3271
|
isProductReviewsAndRatings: {
|
|
3212
3272
|
...basePlugins.isProductReviewsAndRatings,
|
|
3213
3273
|
...flag(plugins.has("product-reviews"))
|
|
@@ -4042,6 +4102,7 @@ exports.ContactService = ContactService;
|
|
|
4042
4102
|
exports.CountryService = CountryService;
|
|
4043
4103
|
exports.CouponService = CouponService;
|
|
4044
4104
|
exports.CurrencyService = CurrencyService;
|
|
4105
|
+
exports.CustomizerService = CustomizerService;
|
|
4045
4106
|
exports.DealService = DealService;
|
|
4046
4107
|
exports.DemoRequestService = DemoRequestService;
|
|
4047
4108
|
exports.EnquiryService = EnquiryService;
|
|
@@ -4102,6 +4163,7 @@ exports.countryService = countryService;
|
|
|
4102
4163
|
exports.couponService = couponService;
|
|
4103
4164
|
exports.currencyExponent = currencyExponent;
|
|
4104
4165
|
exports.currencyService = currencyService;
|
|
4166
|
+
exports.customizerService = customizerService;
|
|
4105
4167
|
exports.dealService = dealService;
|
|
4106
4168
|
exports.demoRequestService = demoRequestService;
|
|
4107
4169
|
exports.emptyCart = emptyCart;
|