@reactionary/hcl 0.9.8 → 0.9.11

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 (43) hide show
  1. package/capabilities/cart.capability.js +411 -0
  2. package/capabilities/category.capability.js +111 -35
  3. package/capabilities/checkout.capability.js +337 -0
  4. package/capabilities/identity.capability.js +214 -0
  5. package/capabilities/inventory.capability.js +75 -0
  6. package/capabilities/price.capability.js +122 -0
  7. package/capabilities/product-search.capability.js +64 -13
  8. package/capabilities/product.capability.js +114 -28
  9. package/core/client.js +81 -90
  10. package/core/initialize.js +111 -5
  11. package/core/session-keys.js +14 -0
  12. package/factories/cart/cart.factory.js +135 -0
  13. package/factories/checkout/checkout.factory.js +131 -0
  14. package/factories/identity/identity.factory.js +12 -0
  15. package/factories/index.js +5 -0
  16. package/factories/inventory/inventory.factory.js +38 -0
  17. package/factories/price/price.factory.js +39 -0
  18. package/index.js +5 -0
  19. package/package.json +8 -5
  20. package/schema/capabilities.schema.js +2 -0
  21. package/schema/configuration.schema.js +9 -1
  22. package/src/capabilities/cart.capability.d.ts +69 -0
  23. package/src/capabilities/category.capability.d.ts +20 -1
  24. package/src/capabilities/checkout.capability.d.ts +41 -0
  25. package/src/capabilities/identity.capability.d.ts +29 -0
  26. package/src/capabilities/inventory.capability.d.ts +13 -0
  27. package/src/capabilities/price.capability.d.ts +16 -0
  28. package/src/capabilities/product-search.capability.d.ts +7 -2
  29. package/src/capabilities/product.capability.d.ts +14 -2
  30. package/src/core/client.d.ts +41 -14
  31. package/src/core/initialize.types.d.ts +11 -5
  32. package/src/core/session-keys.d.ts +14 -0
  33. package/src/factories/cart/cart.factory.d.ts +11 -0
  34. package/src/factories/checkout/checkout.factory.d.ts +11 -0
  35. package/src/factories/identity/identity.factory.d.ts +7 -0
  36. package/src/factories/index.d.ts +5 -0
  37. package/src/factories/inventory/inventory.factory.d.ts +29 -0
  38. package/src/factories/price/price.factory.d.ts +26 -0
  39. package/src/index.d.ts +5 -0
  40. package/src/schema/capabilities.schema.d.ts +7 -1
  41. package/src/schema/configuration.schema.d.ts +6 -0
  42. package/src/schema/hcl.schema.d.ts +321 -0
  43. package/src/test/test-utils.d.ts +2 -1
@@ -8,6 +8,108 @@ export interface HclPrice {
8
8
  description: string;
9
9
  currency: string;
10
10
  value: string;
11
+ /** B2B contract identifier. Present on Offer-usage entries when a contract price applies. */
12
+ contractId?: string;
13
+ }
14
+ /**
15
+ * A single unit price entry in a /display_price response item.
16
+ * `value` is already a number (unlike the inline `HclPrice.value` which is a string).
17
+ */
18
+ export interface HclDisplayPriceUnitPrice {
19
+ price?: {
20
+ currency?: string;
21
+ /** Numeric value — already a number, not a string. */
22
+ value?: number;
23
+ };
24
+ quantity?: {
25
+ value?: number;
26
+ uom?: string;
27
+ };
28
+ }
29
+ /**
30
+ * A single item in the `resultList` of a /display_price response.
31
+ * Returned for both `byPartNumbersAndPriceRuleId` and `byCatalogEntryIds*` query variants.
32
+ */
33
+ export interface HclDisplayPriceItem {
34
+ partNumber: string;
35
+ priceRuleId?: string;
36
+ priceRuleName?: string;
37
+ catalogEntryId?: string;
38
+ unitPrice?: HclDisplayPriceUnitPrice[];
39
+ userDataField?: {
40
+ value?: string;
41
+ key: string;
42
+ }[];
43
+ }
44
+ /** Top-level response from GET /wcs/resources/store/{storeId}/display_price */
45
+ export interface HclDisplayPriceResponse {
46
+ resourceId?: string;
47
+ resourceName?: string;
48
+ resultList?: HclDisplayPriceItem[];
49
+ }
50
+ /**
51
+ * A single unit price entry in a /price?q=byPartNumbers response item.
52
+ * Note: HCL uses `UnitPrice` (capital U) on this endpoint.
53
+ */
54
+ export interface HclEntitledPriceUnitPrice {
55
+ price?: {
56
+ currency?: string;
57
+ /** Numeric value. */
58
+ value?: number;
59
+ };
60
+ quantity?: {
61
+ value?: number;
62
+ uom?: string;
63
+ };
64
+ }
65
+ /**
66
+ * A single item in the `EntitledPrice` array of a /price?q=byPartNumbers response.
67
+ */
68
+ export interface HclEntitledPriceItem {
69
+ partNumber?: string;
70
+ productId?: string;
71
+ contractId?: string;
72
+ UnitPrice?: HclEntitledPriceUnitPrice[];
73
+ }
74
+ /** Top-level response from GET /wcs/resources/store/{storeId}/price?q=byPartNumbers */
75
+ export interface HclEntitledPriceResponse {
76
+ resourceId?: string;
77
+ resourceName?: string;
78
+ EntitledPrice?: HclEntitledPriceItem[];
79
+ }
80
+ /**
81
+ * A single item in the `InventoryAvailability` array of the inventoryavailability response.
82
+ */
83
+ export interface HclInventoryAvailabilityItem {
84
+ /** Internal HCL product ID (numeric string). */
85
+ productId?: string;
86
+ /** Inventory status string, e.g. 'Available'. */
87
+ inventoryStatus?: string;
88
+ /** Available quantity as a string (format: double). */
89
+ availableQuantity?: string;
90
+ unitOfMeasure?: string;
91
+ /** ID of the physical store, if this is a store-specific record. */
92
+ physicalStoreId?: string;
93
+ /** Name/key of the physical store, e.g. '1004/0001'. */
94
+ physicalStoreName?: string;
95
+ /** Name/key of the online store. Present on online inventory records. */
96
+ onlineStoreName?: string;
97
+ /** Online store ID. Present on online inventory records. */
98
+ onlineStoreId?: string;
99
+ availabilityDateTime?: string;
100
+ x_customField1?: string | null;
101
+ x_customField2?: string | null;
102
+ x_customField3?: string | null;
103
+ userDataField?: {
104
+ value?: string;
105
+ key: string;
106
+ }[];
107
+ }
108
+ /** Top-level response from GET /wcs/resources/store/{storeId}/inventoryavailability/byPartNumber/{partNumbers} */
109
+ export interface HclInventoryAvailabilityResponse {
110
+ resourceId: string;
111
+ resourceName: string;
112
+ InventoryAvailability?: HclInventoryAvailabilityItem[];
11
113
  }
12
114
  export interface HclProductAttributeValue {
13
115
  identifier: string | string[];
@@ -310,3 +412,222 @@ export interface HclFindProductsQuery {
310
412
  */
311
413
  facets?: string[];
312
414
  }
415
+ /**
416
+ * Response from POST /wcs/resources/store/{storeId}/guestidentity
417
+ * and POST /wcs/resources/store/{storeId}/loginidentity.
418
+ */
419
+ export interface HclWcsIdentityResponse {
420
+ /** Opaque session token — must be forwarded as `WCToken` header on subsequent requests. */
421
+ WCToken: string;
422
+ /** Trusted token — must be forwarded as `WCTrustedToken` header. */
423
+ WCTrustedToken: string;
424
+ /** Numeric user ID string assigned by WCS. */
425
+ userId: string;
426
+ /** Personalization tracking ID. */
427
+ personalizationID?: string;
428
+ resourceName?: string;
429
+ }
430
+ /**
431
+ * Response from GET /wcs/resources/store/{storeId}/person/@self.
432
+ * Only the fields we use are typed; the full WCS schema has many more.
433
+ */
434
+ export interface HclPersonResponse {
435
+ /** Numeric user ID string. */
436
+ userId: string;
437
+ /** Customer's email / logon ID. Only populated for registered users. */
438
+ logonId?: string;
439
+ email1?: string;
440
+ firstName?: string;
441
+ lastName?: string;
442
+ resourceName?: string;
443
+ /** Organization ID. `-2000` indicates the default anonymous org. */
444
+ orgizationId?: string;
445
+ }
446
+ /** A single order item embedded in a WCS cart/@self response. */
447
+ export interface HclWcsOrderItem {
448
+ orderItemId: string;
449
+ /** Internal HCL catalog entry ID (numeric string). */
450
+ productId?: string;
451
+ /** SKU part number. Use this as the variant identifier. */
452
+ partNumber: string;
453
+ /** Quantity as a string — coerce with Number(). */
454
+ quantity: string;
455
+ /** Total line price as a string (unitPrice × quantity). */
456
+ orderItemPrice: string;
457
+ /** Price per single unit as a string. */
458
+ unitPrice: string;
459
+ /** ISO 4217 currency code. */
460
+ currency: string;
461
+ orderItemInventoryStatus?: string;
462
+ /** 'true' | 'false' — marks free-gift promotional items. */
463
+ freeGift?: string;
464
+ comments?: string;
465
+ /** Ship mode ID assigned to this item (present in shipping_info response). */
466
+ shipModeId?: string;
467
+ shipModeCode?: string;
468
+ shipModeDescription?: string;
469
+ carrier?: string;
470
+ shippingCharge?: string;
471
+ }
472
+ /** A single price adjustment on a WCS cart (discount, surcharge, tax, shipping). */
473
+ export interface HclWcsAdjustment {
474
+ code: string;
475
+ /** Adjustment amount as a string — negative for discounts. */
476
+ amount: string;
477
+ currency: string;
478
+ /** 'Order' | 'OrderItem' | 'Shipping' */
479
+ displayLevel?: string;
480
+ /** 'Discount' | 'Tax' | 'Surcharge' | 'Shipping' */
481
+ usage?: string;
482
+ description?: string;
483
+ }
484
+ /** A promotion/coupon code applied to a WCS cart. */
485
+ export interface HclWcsPromoCode {
486
+ code: string;
487
+ reason?: string;
488
+ associatedPromotion?: {
489
+ promotionId?: string;
490
+ promotionCode?: string;
491
+ }[];
492
+ }
493
+ /** Key-value pair carried in a WCS payment instruction. */
494
+ export interface HclWcsPaymentProtocolData {
495
+ name: string;
496
+ value: string;
497
+ }
498
+ /** A payment instruction attached to a WCS cart. */
499
+ export interface HclWcsPaymentInstruction {
500
+ piId: string;
501
+ payMethodId: string;
502
+ /** Authorized amount as a string. */
503
+ piAmount?: string;
504
+ currency?: string;
505
+ protocolData?: HclWcsPaymentProtocolData[];
506
+ piStatus?: string;
507
+ piDescription?: string;
508
+ }
509
+ /** An address embedded in a WCS cart/order response. */
510
+ export interface HclWcsAddress {
511
+ addressId?: string;
512
+ firstName?: string;
513
+ lastName?: string;
514
+ /** Array of street address lines — index 0 is the primary line. */
515
+ addressLine?: string[];
516
+ /** Single-field street address (some WCS endpoints prefer this over addressLine). */
517
+ address1?: string;
518
+ city?: string;
519
+ /** State/province/region code. */
520
+ state?: string;
521
+ zipCode?: string;
522
+ country?: string;
523
+ phone1?: string;
524
+ email1?: string;
525
+ addressType?: string;
526
+ nickName?: string;
527
+ }
528
+ /** A single available ship mode returned by the WCS shipping_info endpoint. */
529
+ export interface HclWcsShipMode {
530
+ shipModeId: string;
531
+ carrier: string;
532
+ shipModeCode: string;
533
+ shipModeDescription: string;
534
+ /** Store-defined extra field (varies by HCL configuration). */
535
+ field1?: string;
536
+ /** Estimated delivery time (store-defined). */
537
+ field2?: string;
538
+ }
539
+ /**
540
+ * Top-level response from GET /wcs/resources/store/{storeId}/cart/@self.
541
+ * All monetary amounts are returned as strings and must be parsed with Number().
542
+ */
543
+ export interface HclWcsCartResponse {
544
+ orderId: string;
545
+ storeId?: string;
546
+ buyerId?: string;
547
+ orgUniqueID?: string;
548
+ grandTotal?: string;
549
+ grandTotalCurrency?: string;
550
+ totalProductPrice?: string;
551
+ totalProductPriceCurrency?: string;
552
+ totalShippingCharge?: string;
553
+ totalShippingChargeCurrency?: string;
554
+ totalAdjustment?: string;
555
+ totalAdjustmentCurrency?: string;
556
+ totalSalesTax?: string;
557
+ totalSalesTaxCurrency?: string;
558
+ totalShippingTax?: string;
559
+ /** Shipping address embedded in the cart (when set). */
560
+ x_shippingAddress?: HclWcsAddress;
561
+ /** Billing address embedded in the cart (when set). */
562
+ x_billingAddress?: HclWcsAddress;
563
+ orderItem?: HclWcsOrderItem[];
564
+ adjustment?: HclWcsAdjustment[];
565
+ promotionCode?: HclWcsPromoCode[];
566
+ paymentInstruction?: HclWcsPaymentInstruction[];
567
+ /** Currently selected shipping mode ID. */
568
+ shipModeId?: string;
569
+ shipModeCode?: string;
570
+ shipModeDescription?: string;
571
+ carrier?: string;
572
+ /** '0' | '1' — locked orders cannot be modified. */
573
+ x_isPurchaseLocked?: string;
574
+ /** WCS order status, e.g. 'P' = pending, 'C' = submitted. */
575
+ orderStatus?: string;
576
+ lastUpdateDate?: string;
577
+ /** Order description / name as persisted in WCS. Returned by GET /order/{orderId} and GET /order/byStatus/P. */
578
+ orderDescription?: string;
579
+ }
580
+ /**
581
+ * Response from GET /store/{storeId}/order/byStatus/P.
582
+ * Returns a list of pending orders (multi-cart B2B support).
583
+ */
584
+ export interface HclWcsOrderListResponse {
585
+ Order: HclWcsCartResponse[];
586
+ recordSetTotal?: string;
587
+ recordSetCount?: string;
588
+ recordSetComplete?: string;
589
+ recordSetStartNumber?: string;
590
+ }
591
+ /** Response from the precheckout / checkout endpoints. */
592
+ export interface HclWcsOrderIdContainer {
593
+ orderId: string;
594
+ resourceName?: string;
595
+ }
596
+ /** Response from GET cart/@self/shipping_info with usable shipping modes. */
597
+ export interface HclWcsShipModesResponse {
598
+ /** Present in newer WCS versions when using IBM_usableShippingMode profile. */
599
+ usableShippingMode?: HclWcsShipMode[];
600
+ /** Present in older WCS versions — shipping mode embedded per orderItem. */
601
+ orderItem?: Array<{
602
+ orderItemId: string;
603
+ shipModeId?: string;
604
+ shipModeCode?: string;
605
+ shipModeDescription?: string;
606
+ carrier?: string;
607
+ description?: string;
608
+ }>;
609
+ }
610
+ /** A single usable payment method entry returned by WCS. */
611
+ export interface HclWcsPaymentMethod {
612
+ paymentMethodName: string;
613
+ xucc?: string;
614
+ description?: string;
615
+ }
616
+ /** Response listing available payment methods for the store. */
617
+ export interface HclWcsPaymentMethodsResponse {
618
+ usablePaymentInformation?: HclWcsPaymentMethod[];
619
+ }
620
+ /** Minimal response from addOrderItem / updateOrderItem operations. */
621
+ export interface HclWcsOrderItemUpdateResponse {
622
+ orderId: string;
623
+ orderItem?: {
624
+ orderItemId: string;
625
+ }[];
626
+ }
627
+ /** Response from POST /store/{storeId}/cart/create_order */
628
+ export interface HclWcsCreateOrderResponse {
629
+ /** The newly created order ID. */
630
+ outOrderId: string;
631
+ redirecturl?: string;
632
+ viewTaskName?: string;
633
+ }
@@ -7,9 +7,10 @@ export declare function createHclClient(contextOverrides?: Partial<RequestContex
7
7
  price?: false | undefined;
8
8
  cart?: false | undefined;
9
9
  checkout?: false | undefined;
10
+ identity?: false | undefined;
10
11
  inventory?: false | undefined;
11
12
  category?: true | undefined;
12
- }>, "product" | "productSearch" | "price" | "cart" | "checkout" | "inventory" | "category"> & {
13
+ }>, "product" | "productSearch" | "price" | "cart" | "checkout" | "identity" | "inventory" | "category"> & {
13
14
  product: import("../index.js").HclProductCapability<import("../index.js").HclProductFactory<import("zod").ZodObject<{
14
15
  identifier: import("zod").ZodObject<{
15
16
  key: import("zod").ZodString;