b23-lib 1.7.0 → 1.7.2

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 (127) hide show
  1. package/dist/Auth/index.d.mts +130 -0
  2. package/dist/Auth/index.d.ts +130 -0
  3. package/dist/Auth/index.js +2 -0
  4. package/dist/Auth/index.js.map +1 -0
  5. package/dist/Auth/index.mjs +2 -0
  6. package/dist/Auth/index.mjs.map +1 -0
  7. package/dist/Classes/Address.d.mts +142 -0
  8. package/dist/Classes/Address.d.ts +142 -0
  9. package/dist/Classes/Address.js +2 -0
  10. package/dist/Classes/Address.js.map +1 -0
  11. package/dist/Classes/Address.mjs +2 -0
  12. package/dist/Classes/Address.mjs.map +1 -0
  13. package/dist/Classes/Base.d.mts +98 -0
  14. package/dist/Classes/Base.d.ts +98 -0
  15. package/dist/Classes/Base.js +2 -0
  16. package/dist/Classes/Base.js.map +1 -0
  17. package/dist/Classes/Base.mjs +2 -0
  18. package/dist/Classes/Base.mjs.map +1 -0
  19. package/dist/Classes/Cart.d.mts +68 -0
  20. package/dist/Classes/Cart.d.ts +68 -0
  21. package/dist/Classes/Cart.js +2 -0
  22. package/dist/Classes/Cart.js.map +1 -0
  23. package/dist/Classes/Cart.mjs +2 -0
  24. package/dist/Classes/Cart.mjs.map +1 -0
  25. package/dist/Classes/Common.d.mts +75 -0
  26. package/dist/Classes/Common.d.ts +75 -0
  27. package/dist/Classes/Common.js +2 -0
  28. package/dist/Classes/Common.js.map +1 -0
  29. package/dist/Classes/Common.mjs +2 -0
  30. package/dist/Classes/Common.mjs.map +1 -0
  31. package/dist/Classes/Coupon.d.mts +142 -0
  32. package/dist/Classes/Coupon.d.ts +142 -0
  33. package/dist/Classes/Coupon.js +2 -0
  34. package/dist/Classes/Coupon.js.map +1 -0
  35. package/dist/Classes/Coupon.mjs +2 -0
  36. package/dist/Classes/Coupon.mjs.map +1 -0
  37. package/dist/Classes/Customer.d.mts +97 -0
  38. package/dist/Classes/Customer.d.ts +97 -0
  39. package/dist/Classes/Customer.js +2 -0
  40. package/dist/Classes/Customer.js.map +1 -0
  41. package/dist/Classes/Customer.mjs +2 -0
  42. package/dist/Classes/Customer.mjs.map +1 -0
  43. package/dist/Classes/CustomerAddress.d.mts +71 -0
  44. package/dist/Classes/CustomerAddress.d.ts +71 -0
  45. package/dist/Classes/CustomerAddress.js +2 -0
  46. package/dist/Classes/CustomerAddress.js.map +1 -0
  47. package/dist/Classes/CustomerAddress.mjs +2 -0
  48. package/dist/Classes/CustomerAddress.mjs.map +1 -0
  49. package/dist/Classes/Enum.d.mts +34 -0
  50. package/dist/Classes/Enum.d.ts +34 -0
  51. package/dist/Classes/Enum.js +2 -0
  52. package/dist/Classes/Enum.js.map +1 -0
  53. package/dist/Classes/Enum.mjs +2 -0
  54. package/dist/Classes/Enum.mjs.map +1 -0
  55. package/dist/Classes/ImageInfo.d.mts +92 -0
  56. package/dist/Classes/ImageInfo.d.ts +92 -0
  57. package/dist/Classes/ImageInfo.js +2 -0
  58. package/dist/Classes/ImageInfo.js.map +1 -0
  59. package/dist/Classes/ImageInfo.mjs +2 -0
  60. package/dist/Classes/ImageInfo.mjs.map +1 -0
  61. package/dist/Classes/LineItem.d.mts +124 -0
  62. package/dist/Classes/LineItem.d.ts +124 -0
  63. package/dist/Classes/LineItem.js +2 -0
  64. package/dist/Classes/LineItem.js.map +1 -0
  65. package/dist/Classes/LineItem.mjs +2 -0
  66. package/dist/Classes/LineItem.mjs.map +1 -0
  67. package/dist/Classes/Order.d.mts +83 -0
  68. package/dist/Classes/Order.d.ts +83 -0
  69. package/dist/Classes/Order.js +2 -0
  70. package/dist/Classes/Order.js.map +1 -0
  71. package/dist/Classes/Order.mjs +2 -0
  72. package/dist/Classes/Order.mjs.map +1 -0
  73. package/dist/Classes/Payment.d.mts +161 -0
  74. package/dist/Classes/Payment.d.ts +161 -0
  75. package/dist/Classes/Payment.js +2 -0
  76. package/dist/Classes/Payment.js.map +1 -0
  77. package/dist/Classes/Payment.mjs +2 -0
  78. package/dist/Classes/Payment.mjs.map +1 -0
  79. package/dist/Classes/Price.d.mts +70 -0
  80. package/dist/Classes/Price.d.ts +70 -0
  81. package/dist/Classes/Price.js +2 -0
  82. package/dist/Classes/Price.js.map +1 -0
  83. package/dist/Classes/Price.mjs +2 -0
  84. package/dist/Classes/Price.mjs.map +1 -0
  85. package/dist/Classes/Product.d.mts +209 -0
  86. package/dist/Classes/Product.d.ts +209 -0
  87. package/dist/Classes/Product.js +2 -0
  88. package/dist/Classes/Product.js.map +1 -0
  89. package/dist/Classes/Product.mjs +2 -0
  90. package/dist/Classes/Product.mjs.map +1 -0
  91. package/dist/Classes/ShoppingContainer.d.mts +194 -0
  92. package/dist/Classes/ShoppingContainer.d.ts +194 -0
  93. package/dist/Classes/ShoppingContainer.js +2 -0
  94. package/dist/Classes/ShoppingContainer.js.map +1 -0
  95. package/dist/Classes/ShoppingContainer.mjs +2 -0
  96. package/dist/Classes/ShoppingContainer.mjs.map +1 -0
  97. package/dist/Dynamodb/index.d.mts +58 -0
  98. package/dist/Dynamodb/index.d.ts +58 -0
  99. package/dist/Dynamodb/index.js +2 -0
  100. package/dist/Dynamodb/index.js.map +1 -0
  101. package/dist/Dynamodb/index.mjs +2 -0
  102. package/dist/Dynamodb/index.mjs.map +1 -0
  103. package/dist/chunk-4H4LJ3UL.mjs +2 -0
  104. package/dist/chunk-4H4LJ3UL.mjs.map +1 -0
  105. package/dist/chunk-65X54TKF.mjs +2 -0
  106. package/dist/chunk-65X54TKF.mjs.map +1 -0
  107. package/dist/chunk-763MN5XV.mjs +2 -0
  108. package/dist/chunk-763MN5XV.mjs.map +1 -0
  109. package/dist/chunk-CWKGR4AF.mjs +2 -0
  110. package/dist/chunk-CWKGR4AF.mjs.map +1 -0
  111. package/dist/chunk-DKI6BDWK.mjs +2 -0
  112. package/dist/chunk-DKI6BDWK.mjs.map +1 -0
  113. package/dist/chunk-SPLTJRHG.mjs +2 -0
  114. package/dist/chunk-SPLTJRHG.mjs.map +1 -0
  115. package/dist/chunk-T6IVHYQQ.mjs +2 -0
  116. package/dist/chunk-T6IVHYQQ.mjs.map +1 -0
  117. package/dist/chunk-T6YCHB3K.mjs +2 -0
  118. package/dist/chunk-T6YCHB3K.mjs.map +1 -0
  119. package/dist/chunk-WU6FFDBS.mjs +2 -0
  120. package/dist/chunk-WU6FFDBS.mjs.map +1 -0
  121. package/dist/index.d.mts +1 -624
  122. package/dist/index.d.ts +1 -624
  123. package/dist/index.js +2 -1
  124. package/dist/index.js.map +1 -1
  125. package/dist/index.mjs +2 -1
  126. package/dist/index.mjs.map +1 -1
  127. package/package.json +163 -1
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/Classes/Base.ts","../../src/Classes/Address.ts","../../src/Classes/CustomerAddress.ts"],"names":["BaseModel","data","date","modifiedBy","fieldName","value","AddressModel","addressType","CustomerAddressModel","address","a","b","withId","explicitDefault"],"mappings":"aA0BA,IAAqBA,EAArB,KAA+B,CACnB,YACA,CAAA,OAAA,CACA,UACA,UACA,CAAA,UAAA,CAQV,WAAYC,CAAAA,CAAAA,CAAsBC,EAAa,IAAI,IAAA,CAAQ,CACzD,IAAA,CAAK,aAAe,CAAE,GAAGD,CAAK,CAAA,YAAa,EAC3C,IAAK,CAAA,OAAA,CAAUA,CAAK,CAAA,OAAA,EAAW,EAC/B,IAAK,CAAA,SAAA,CAAYA,CAAK,CAAA,SAAA,EAAa,CAAC,KAAM,CAAA,IAAA,CAAK,KAAMA,CAAAA,CAAAA,CAAK,SAAS,CAAC,CAAA,CAElE,IAAI,IAAA,CAAKA,EAAK,SAAS,CAAA,CAAE,WAAY,EAAA,CAErCC,EAAK,WAAY,EAAA,CACnB,IAAK,CAAA,UAAA,CAAaD,EAAK,UAAc,EAAA,CAAC,KAAM,CAAA,IAAA,CAAK,MAAMA,CAAK,CAAA,UAAU,CAAC,CAAA,CACnE,IAAI,IAAKA,CAAAA,CAAAA,CAAK,UAAU,CAAA,CAAE,aA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EAAA,IACrF,CAQA,2BAAA,EAA6C,CAE3C,IAAMI,CAAAA,CAAkB,IAAK,CAAA,SAAA,CAAU,KACpCJ,CAAYA,EAAAA,CAAAA,CAAQ,KAAM,EAAA,GAAM,KAAK,wBAA4BA,EAAAA,CAAAA,CAAQ,oBAAqB,EACjG,EACA,OAAII,CAAAA,CACKA,CAAgB,CAAA,KAAA,GAGlB,IAAK,CAAA,SAAA,CAAU,IAAMJ,CAAAA,CAAAA,EAAYA,EAAQ,oBAAqB,EAAC,GAAG,KAAM,EAAA,EAAK,IACtF,CACF","file":"CustomerAddress.js","sourcesContent":["import { ISODateTime } from \"./Common\";\r\n\r\nexport interface CustomFields {\r\n [key: string]: any;\r\n}\r\n\r\nexport type BaseAttributes = {\r\n customFields?: CustomFields;\r\n version?: number;\r\n createdAt?: ISODateTime;\r\n modifiedAt?: ISODateTime;\r\n modifiedBy?: string;\r\n};\r\n\r\nexport type BaseData = {\r\n customFields: CustomFields;\r\n version: number;\r\n createdAt: ISODateTime;\r\n modifiedAt: ISODateTime;\r\n modifiedBy: string;\r\n};\r\n\r\n/**\r\n * Provides common foundational properties and methods for other data models.\r\n * Handles tracking of custom fields, versioning, and timestamps.\r\n */\r\nexport default class BaseModel {\r\n protected customFields: CustomFields;\r\n protected version: number;\r\n protected createdAt: ISODateTime;\r\n protected modifiedAt: ISODateTime;\r\n protected modifiedBy: string;\r\n\r\n /**\r\n * Creates an instance of BaseModel.\r\n * Initializes common properties like timestamps, version, and custom fields.\r\n * @param data - Optional initial attributes for the base model.\r\n * @param date - Optional date object to use for default timestamps (defaults to current time).\r\n */\r\n constructor(data: BaseAttributes, date: Date = new Date()) {\r\n this.customFields = { ...data.customFields };\r\n this.version = data.version ?? 1;\r\n this.createdAt = data.createdAt && !isNaN(Date.parse(data.createdAt))\r\n ?\r\n new Date(data.createdAt).toISOString()\r\n :\r\n date.toISOString();\r\n this.modifiedAt = data.modifiedAt && !isNaN(Date.parse(data.modifiedAt))\r\n ? new Date(data.modifiedAt).toISOString()\r\n : date.toISOString();\r\n\r\n this.modifiedBy = data.modifiedBy ?? '';\r\n }\r\n\r\n /**\r\n * Gets a plain data object representing the base model's current state.\r\n * @returns BaseData object containing common properties.\r\n */\r\n getDetails(): BaseData {\r\n return {\r\n customFields: this.getAllCustomFields(), // Use getter to return a copy\r\n version: this.getVersion(),\r\n createdAt: this.getCreatedAt(),\r\n modifiedAt: this.getModifiedAt(),\r\n modifiedBy: this.getModifiedBy(),\r\n }\r\n }\r\n\r\n /**\r\n * Gets the current version number of the model instance.\r\n * @returns The version number.\r\n */\r\n getVersion(): number {\r\n return this.version;\r\n }\r\n\r\n /**\r\n * Gets the creation timestamp as an ISO 8601 string.\r\n * @returns The creation timestamp string.\r\n */\r\n getCreatedAt(): string {\r\n return this.createdAt;\r\n }\r\n\r\n /**\r\n * Gets the creation timestamp as a Unix epoch time (milliseconds).\r\n * @returns The creation time in milliseconds since the epoch.\r\n */\r\n getCreatedAtTime(): number {\r\n return new Date(this.createdAt).getTime();\r\n }\r\n\r\n\r\n /**\r\n * Gets the last modification timestamp as an ISO 8601 string.\r\n * @returns The last modification timestamp string.\r\n */\r\n getModifiedAt(): string {\r\n return this.modifiedAt;\r\n }\r\n\r\n /**\r\n * Gets the last modification timestamp as a Unix epoch time (milliseconds).\r\n * @returns The last modification time in milliseconds since the epoch.\r\n */\r\n getModifiedAtTime(): number {\r\n return new Date(this.modifiedAt).getTime();\r\n }\r\n\r\n /**\r\n * Gets the identifier of the user or process that last modified the instance.\r\n * @returns The modifier identifier string.\r\n */\r\n getModifiedBy(): string {\r\n return this.modifiedBy;\r\n }\r\n\r\n /**\r\n * Sets the identifier of the user or process that last modified the instance.\r\n * @param modifiedBy - The identifier string.\r\n */\r\n setModifiedBy(modifiedBy: string): void {\r\n this.modifiedBy = modifiedBy;\r\n }\r\n\r\n /**\r\n * Retrieves the value of a specific custom field.\r\n * @param fieldName - The name (key) of the custom field to retrieve.\r\n * @returns The value of the custom field, or null if the field does not exist.\r\n */\r\n getCustomField(fieldName: string): any {\r\n return this.customFields[fieldName] ?? null;\r\n }\r\n\r\n /**\r\n * Sets the value of a specific custom field.\r\n * Also updates the modification timestamp and increments the version.\r\n * @param fieldName - The name (key) of the custom field to set.\r\n * @param value - The value to assign to the custom field.\r\n */\r\n setCustomField(fieldName: string, value: any): void {\r\n this.customFields[fieldName] = value;\r\n }\r\n\r\n /**\r\n * Retrieves a shallow copy of all custom fields associated with the instance.\r\n * @returns An object containing all custom fields.\r\n */\r\n getAllCustomFields(): CustomFields {\r\n return { ...this.customFields };\r\n }\r\n}\r\n","import BaseModel, { BaseAttributes } from \"./Base\";\r\n\r\nexport enum AddressType {\r\n BILLING = \"billing\",\r\n SHIPPING = \"shipping\",\r\n BILLING_AND_SHIPPING = \"billing&shipping\",\r\n NONE = \"none\",\r\n}\r\n\r\nexport type AddressAttributes = BaseAttributes & {\r\n id: string;\r\n firstName: string;\r\n lastName: string;\r\n phone: string;\r\n email: string;\r\n addressLine1: string;\r\n addressLine2?: string;\r\n city: string;\r\n postalCode: string\r\n state: string;\r\n country: string;\r\n isBillingAddress: boolean;\r\n isShippingAddress: boolean;\r\n};\r\n\r\nexport type AddressData = Required<AddressAttributes>;\r\n\r\n/**\r\n * Represents a physical address associated with a customer or order.\r\n * Handles both billing and shipping address types.\r\n */\r\nexport default class AddressModel extends BaseModel {\r\n protected id: string;\r\n protected firstName: string;\r\n protected lastName: string;\r\n protected phone: string;\r\n protected email: string;\r\n protected addressLine1: string;\r\n protected addressLine2: string;\r\n protected city: string;\r\n protected postalCode: string\r\n protected state: string;\r\n protected country: string;\r\n protected isBillingAddress: boolean;\r\n protected isShippingAddress: boolean;\r\n\r\n /**\r\n * Creates an instance of AddressModel.\r\n * @param data - The initial address attributes.\r\n * @param date - Optional date for setting creation/modification times (defaults to now).\r\n */\r\n constructor(data: AddressAttributes, date: Date = new Date()) {\r\n super(data, date);\r\n this.id = data.id;\r\n this.firstName = data.firstName;\r\n this.lastName = data.lastName;\r\n this.phone = data.phone;\r\n this.email = data.email;\r\n this.addressLine1 = data.addressLine1;\r\n this.addressLine2 = data.addressLine2 || '';\r\n this.city = data.city;\r\n this.postalCode = data.postalCode;\r\n this.state = data.state;\r\n this.country = data.country;\r\n this.isBillingAddress = data.isBillingAddress;\r\n this.isShippingAddress = data.isShippingAddress;\r\n }\r\n\r\n /**\r\n * Gets a plain data object representing the address's current state.\r\n * Includes all address fields and base model fields.\r\n * @returns AddressData object suitable for serialization or API responses.\r\n */\r\n getDetails(): AddressData {\r\n return {\r\n ...super.getDetails(),\r\n id: this.getId(),\r\n firstName: this.getFirstName(),\r\n lastName: this.getLastName(),\r\n phone: this.getPhone(),\r\n email: this.getEmail(),\r\n addressLine1: this.getAddressLine1(),\r\n addressLine2: this.getAddressLine2(),\r\n city: this.getCity(),\r\n postalCode: this.getPostalCode(),\r\n state: this.getState(),\r\n country: this.getCountry(),\r\n isBillingAddress: this.getIsBillingAddress(),\r\n isShippingAddress: this.getIsShippingAddress(),\r\n }\r\n }\r\n\r\n /**\r\n * Gets the unique identifier for the address.\r\n * @returns The address ID.\r\n */\r\n getId(): string {\r\n return this.id;\r\n }\r\n\r\n /**\r\n * Gets the first name associated with the address.\r\n * @returns The first name.\r\n */\r\n getFirstName(): string {\r\n return this.firstName;\r\n }\r\n\r\n /**\r\n * Gets the last name associated with the address.\r\n * @returns The last name.\r\n */\r\n getLastName(): string {\r\n return this.lastName;\r\n }\r\n\r\n /**\r\n * Gets the phone number associated with the address.\r\n * @returns The phone number.\r\n */\r\n getPhone(): string {\r\n return this.phone;\r\n }\r\n\r\n /**\r\n * Gets the email address associated with the address.\r\n * @returns The email address.\r\n */\r\n getEmail(): string {\r\n return this.email;\r\n }\r\n\r\n /**\r\n * Gets the primary address line (e.g., street address).\r\n * @returns The first address line.\r\n */\r\n getAddressLine1(): string {\r\n return this.addressLine1;\r\n }\r\n\r\n /**\r\n * Gets the secondary address line (e.g., apartment, suite).\r\n * Returns an empty string if not provided.\r\n * @returns The second address line or an empty string.\r\n */\r\n getAddressLine2(): string {\r\n return this.addressLine2;\r\n }\r\n\r\n /**\r\n * Gets the city name.\r\n * @returns The city.\r\n */\r\n getCity(): string {\r\n return this.city;\r\n }\r\n\r\n /**\r\n * Gets the postal code (e.g., ZIP code).\r\n * @returns The postal code.\r\n */\r\n getPostalCode(): string {\r\n return this.postalCode;\r\n }\r\n\r\n /**\r\n * Gets the state, province, or region.\r\n * @returns The state.\r\n */\r\n getState(): string {\r\n return this.state;\r\n }\r\n\r\n /**\r\n * Gets the country name or code.\r\n * @returns The country.\r\n */\r\n getCountry(): string {\r\n return this.country;\r\n }\r\n\r\n /**\r\n * Checks if this address is designated as a billing address.\r\n * @returns True if it's a billing address, false otherwise.\r\n */\r\n getIsBillingAddress(): boolean {\r\n return this.isBillingAddress;\r\n }\r\n\r\n /**\r\n * Checks if this address is designated as a shipping address.\r\n * @returns True if it's a shipping address, false otherwise.\r\n */\r\n getIsShippingAddress(): boolean {\r\n return this.isShippingAddress;\r\n }\r\n\r\n /**\r\n * Determines the type of the address based on its billing and shipping flags.\r\n * @returns The AddressType enum value representing the address's role.\r\n */\r\n getAddressType(): AddressType {\r\n if (this.isBillingAddress && this.isShippingAddress) {\r\n return AddressType.BILLING_AND_SHIPPING;\r\n } else if (this.isBillingAddress) {\r\n return AddressType.BILLING;\r\n } else if (this.isShippingAddress) {\r\n return AddressType.SHIPPING;\r\n } else {\r\n return AddressType.NONE;\r\n }\r\n }\r\n\r\n /**\r\n * Static method to check if a given AddressType includes shipping.\r\n * @param addressType - The address type to check.\r\n * @returns True if the type is SHIPPING or BILLING_AND_SHIPPING.\r\n */\r\n static checkIfShippingAddress(addressType: AddressType): boolean {\r\n return addressType === AddressType.SHIPPING || addressType === AddressType.BILLING_AND_SHIPPING;\r\n }\r\n\r\n /**\r\n * Static method to check if a given AddressType includes billing.\r\n * @param addressType - The address type to check.\r\n * @returns True if the type is BILLING or BILLING_AND_SHIPPING.\r\n */\r\n static checkIfBillingAddress(addressType: AddressType): boolean {\r\n return addressType === AddressType.BILLING || addressType === AddressType.BILLING_AND_SHIPPING;\r\n }\r\n}","import AddressModel, { AddressData } from \"./Address\";\r\nimport BaseModel, { BaseAttributes } from \"./Base\";\r\n\r\nexport type CustomerAddressAttributes = BaseAttributes & {\r\n id: string;\r\n addresses: AddressData[];\r\n defaultBillingAddressId: string;\r\n defaultShippingAddressId: string;\r\n}\r\n\r\ntype CustomerAddressWithoutDefaultAddress = Omit<CustomerAddressAttributes, \r\n'addresses' | 'defaultBillingAddressId' | 'defaultShippingAddressId'> & {\r\n addresses: AddressData[];\r\n defaultBillingAddressId: string | null;\r\n defaultShippingAddressId: string | null;\r\n};\r\nexport type CustomerAddressDataWithOutId = Required<Omit<CustomerAddressWithoutDefaultAddress, 'id'>>;\r\nexport type CustomerAddressData = Required<CustomerAddressWithoutDefaultAddress>;\r\n\r\n\r\nexport default class CustomerAddressModel extends BaseModel {\r\n protected id: string;\r\n protected addresses: AddressModel[];\r\n protected defaultBillingAddressId: string;\r\n protected defaultShippingAddressId: string;\r\n\r\n /**\r\n * Creates an instance of CustomerAddressModel.\r\n * Initializes the address list, sorting them by modification date (most recent first).\r\n * @param data - The initial attributes for the customer's addresses.\r\n * @param date - Optional date object for setting creation/modification times (defaults to now).\r\n */\r\n constructor(data: CustomerAddressAttributes, date: Date = new Date()) {\r\n super(data, date);\r\n this.id = data.id;\r\n this.addresses = data.addresses\r\n .map((address: AddressData) => new AddressModel(address, date))\r\n .sort((a, b) => b.getModifiedAtTime() - a.getModifiedAtTime());\r\n this.defaultBillingAddressId = data.defaultBillingAddressId;\r\n this.defaultShippingAddressId = data.defaultShippingAddressId;\r\n }\r\n\r\n /**\r\n * Gets a plain data object representing the customer's addresses.\r\n * Can optionally exclude the customer address collection ID. Includes base model details.\r\n * @param withId - If true, includes the 'id' field of the CustomerAddressModel. Defaults to false.\r\n * @returns CustomerAddressData or CustomerAddressDataWithOutId object suitable for serialization.\r\n */\r\n getDetails(withId?: false): CustomerAddressDataWithOutId;\r\n getDetails(withId: true): CustomerAddressData;\r\n getDetails(withId: boolean = false): CustomerAddressData | CustomerAddressDataWithOutId {\r\n return {\r\n ...(withId ? { id: this.getId() } : {}),\r\n addresses: this.getAddresses().map((address) => address.getDetails()),\r\n defaultBillingAddressId: this.getDefaultBillingAddressId(),\r\n defaultShippingAddressId: this.getDefaultShippingAddressId(),\r\n ...super.getDetails()\r\n }\r\n }\r\n \r\n getId(): string {\r\n return this.id;\r\n }\r\n\r\n /**\r\n * Gets the list of all associated address models, sorted by modification date (most recent first).\r\n * @returns An array of AddressModel instances.\r\n */\r\n getAddresses(): AddressModel[] {\r\n return [...this.addresses];\r\n }\r\n\r\n /**\r\n * Gets a filtered list of addresses designated as shipping addresses.\r\n * @returns An array of AddressModel instances marked as shipping addresses.\r\n */\r\n getShippingAddresses(): AddressModel[] {\r\n return this.addresses.filter((address) => address.getIsShippingAddress());\r\n }\r\n\r\n /**\r\n * Gets a filtered list of addresses designated as billing addresses.\r\n * @returns An array of AddressModel instances marked as billing addresses.\r\n */\r\n getBillingAddresses(): AddressModel[] {\r\n return this.addresses.filter((address) => address.getIsBillingAddress());\r\n }\r\n\r\n /**\r\n * Gets the ID of the default billing address.\r\n * If the stored default ID is invalid or doesn't correspond to a billing address,\r\n * it falls back to the most recently modified billing address.\r\n * @returns The ID of the default billing address, or null if no valid billing address exists.\r\n */\r\n getDefaultBillingAddressId(): string | null {\r\n const explicitDefault = this.addresses.find(\r\n (address) => address.getId() === this.defaultBillingAddressId && address.getIsBillingAddress()\r\n );\r\n if (explicitDefault) {\r\n return explicitDefault.getId();\r\n }\r\n // Fallback: Find the first address marked as billing (already sorted by most recent)\r\n return this.addresses.find((address) => address.getIsBillingAddress())?.getId() || null;\r\n }\r\n\r\n /**\r\n * Gets the ID of the default shipping address.\r\n * If the stored default ID is invalid or doesn't correspond to a shipping address,\r\n * it falls back to the most recently modified shipping address.\r\n * @returns The ID of the default shipping address, or null if no valid shipping address exists.\r\n */\r\n getDefaultShippingAddressId(): string | null {\r\n // Check if the explicitly set default exists, is valid, and is a shipping address\r\n const explicitDefault = this.addresses.find(\r\n (address) => address.getId() === this.defaultShippingAddressId && address.getIsShippingAddress()\r\n );\r\n if (explicitDefault) {\r\n return explicitDefault.getId();\r\n }\r\n // Fallback: Find the first address marked as shipping (already sorted by most recent)\r\n return this.addresses.find((address) => address.getIsShippingAddress())?.getId() || null;\r\n }\r\n}\r\n"]}
@@ -0,0 +1,2 @@
1
+ import {b}from'../chunk-CWKGR4AF.mjs';import {a}from'../chunk-SPLTJRHG.mjs';var t=class extends a{id;addresses;defaultBillingAddressId;defaultShippingAddressId;constructor(s,e=new Date){super(s,e),this.id=s.id,this.addresses=s.addresses.map(d=>new b(d,e)).sort((d,l)=>l.getModifiedAtTime()-d.getModifiedAtTime()),this.defaultBillingAddressId=s.defaultBillingAddressId,this.defaultShippingAddressId=s.defaultShippingAddressId;}getDetails(s=!1){return {...s?{id:this.getId()}:{},addresses:this.getAddresses().map(e=>e.getDetails()),defaultBillingAddressId:this.getDefaultBillingAddressId(),defaultShippingAddressId:this.getDefaultShippingAddressId(),...super.getDetails()}}getId(){return this.id}getAddresses(){return [...this.addresses]}getShippingAddresses(){return this.addresses.filter(s=>s.getIsShippingAddress())}getBillingAddresses(){return this.addresses.filter(s=>s.getIsBillingAddress())}getDefaultBillingAddressId(){let s=this.addresses.find(e=>e.getId()===this.defaultBillingAddressId&&e.getIsBillingAddress());return s?s.getId():this.addresses.find(e=>e.getIsBillingAddress())?.getId()||null}getDefaultShippingAddressId(){let s=this.addresses.find(e=>e.getId()===this.defaultShippingAddressId&&e.getIsShippingAddress());return s?s.getId():this.addresses.find(e=>e.getIsShippingAddress())?.getId()||null}};export{t as default};//# sourceMappingURL=CustomerAddress.mjs.map
2
+ //# sourceMappingURL=CustomerAddress.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/Classes/CustomerAddress.ts"],"names":["CustomerAddressModel","BaseModel","data","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Q,mBAAoB,EAAC,CACzE,CAQA,0BAAA,EAA4C,CAC1C,IAAMK,CAAkB,CAAA,IAAA,CAAK,UAAU,IACpCL,CAAAA,CAAAA,EAAYA,EAAQ,KAAM,EAAA,GAAM,KAAK,uBAA2BA,EAAAA,CAAAA,CAAQ,mBAAoB,EAC/F,CACA,CAAA,OAAIK,EACKA,CAAgB,CAAA,KAAA,GAGlB,IAAK,CAAA,SAAA,CAAU,KAAML,CAAYA,EAAAA,CAAAA,CAAQ,qBAAqB,CAAA,EAAG,OAAW,EAAA,IACrF,CAQA,2BAA6C,EAAA,CAE3C,IAAMK,CAAkB,CAAA,IAAA,CAAK,SAAU,CAAA,IAAA,CACpCL,CAAYA,EAAAA,CAAAA,CAAQ,OAAY,GAAA,IAAA,CAAK,0BAA4BA,CAAQ,CAAA,oBAAA,EAC5E,CACA,CAAA,OAAIK,CACKA,CAAAA,CAAAA,CAAgB,KAAM,EAAA,CAGxB,KAAK,SAAU,CAAA,IAAA,CAAML,GAAYA,CAAQ,CAAA,oBAAA,EAAsB,CAAG,EAAA,KAAA,EAAW,EAAA,IACtF,CACF","file":"CustomerAddress.mjs","sourcesContent":["import AddressModel, { AddressData } from \"./Address\";\r\nimport BaseModel, { BaseAttributes } from \"./Base\";\r\n\r\nexport type CustomerAddressAttributes = BaseAttributes & {\r\n id: string;\r\n addresses: AddressData[];\r\n defaultBillingAddressId: string;\r\n defaultShippingAddressId: string;\r\n}\r\n\r\ntype CustomerAddressWithoutDefaultAddress = Omit<CustomerAddressAttributes, \r\n'addresses' | 'defaultBillingAddressId' | 'defaultShippingAddressId'> & {\r\n addresses: AddressData[];\r\n defaultBillingAddressId: string | null;\r\n defaultShippingAddressId: string | null;\r\n};\r\nexport type CustomerAddressDataWithOutId = Required<Omit<CustomerAddressWithoutDefaultAddress, 'id'>>;\r\nexport type CustomerAddressData = Required<CustomerAddressWithoutDefaultAddress>;\r\n\r\n\r\nexport default class CustomerAddressModel extends BaseModel {\r\n protected id: string;\r\n protected addresses: AddressModel[];\r\n protected defaultBillingAddressId: string;\r\n protected defaultShippingAddressId: string;\r\n\r\n /**\r\n * Creates an instance of CustomerAddressModel.\r\n * Initializes the address list, sorting them by modification date (most recent first).\r\n * @param data - The initial attributes for the customer's addresses.\r\n * @param date - Optional date object for setting creation/modification times (defaults to now).\r\n */\r\n constructor(data: CustomerAddressAttributes, date: Date = new Date()) {\r\n super(data, date);\r\n this.id = data.id;\r\n this.addresses = data.addresses\r\n .map((address: AddressData) => new AddressModel(address, date))\r\n .sort((a, b) => b.getModifiedAtTime() - a.getModifiedAtTime());\r\n this.defaultBillingAddressId = data.defaultBillingAddressId;\r\n this.defaultShippingAddressId = data.defaultShippingAddressId;\r\n }\r\n\r\n /**\r\n * Gets a plain data object representing the customer's addresses.\r\n * Can optionally exclude the customer address collection ID. Includes base model details.\r\n * @param withId - If true, includes the 'id' field of the CustomerAddressModel. Defaults to false.\r\n * @returns CustomerAddressData or CustomerAddressDataWithOutId object suitable for serialization.\r\n */\r\n getDetails(withId?: false): CustomerAddressDataWithOutId;\r\n getDetails(withId: true): CustomerAddressData;\r\n getDetails(withId: boolean = false): CustomerAddressData | CustomerAddressDataWithOutId {\r\n return {\r\n ...(withId ? { id: this.getId() } : {}),\r\n addresses: this.getAddresses().map((address) => address.getDetails()),\r\n defaultBillingAddressId: this.getDefaultBillingAddressId(),\r\n defaultShippingAddressId: this.getDefaultShippingAddressId(),\r\n ...super.getDetails()\r\n }\r\n }\r\n \r\n getId(): string {\r\n return this.id;\r\n }\r\n\r\n /**\r\n * Gets the list of all associated address models, sorted by modification date (most recent first).\r\n * @returns An array of AddressModel instances.\r\n */\r\n getAddresses(): AddressModel[] {\r\n return [...this.addresses];\r\n }\r\n\r\n /**\r\n * Gets a filtered list of addresses designated as shipping addresses.\r\n * @returns An array of AddressModel instances marked as shipping addresses.\r\n */\r\n getShippingAddresses(): AddressModel[] {\r\n return this.addresses.filter((address) => address.getIsShippingAddress());\r\n }\r\n\r\n /**\r\n * Gets a filtered list of addresses designated as billing addresses.\r\n * @returns An array of AddressModel instances marked as billing addresses.\r\n */\r\n getBillingAddresses(): AddressModel[] {\r\n return this.addresses.filter((address) => address.getIsBillingAddress());\r\n }\r\n\r\n /**\r\n * Gets the ID of the default billing address.\r\n * If the stored default ID is invalid or doesn't correspond to a billing address,\r\n * it falls back to the most recently modified billing address.\r\n * @returns The ID of the default billing address, or null if no valid billing address exists.\r\n */\r\n getDefaultBillingAddressId(): string | null {\r\n const explicitDefault = this.addresses.find(\r\n (address) => address.getId() === this.defaultBillingAddressId && address.getIsBillingAddress()\r\n );\r\n if (explicitDefault) {\r\n return explicitDefault.getId();\r\n }\r\n // Fallback: Find the first address marked as billing (already sorted by most recent)\r\n return this.addresses.find((address) => address.getIsBillingAddress())?.getId() || null;\r\n }\r\n\r\n /**\r\n * Gets the ID of the default shipping address.\r\n * If the stored default ID is invalid or doesn't correspond to a shipping address,\r\n * it falls back to the most recently modified shipping address.\r\n * @returns The ID of the default shipping address, or null if no valid shipping address exists.\r\n */\r\n getDefaultShippingAddressId(): string | null {\r\n // Check if the explicitly set default exists, is valid, and is a shipping address\r\n const explicitDefault = this.addresses.find(\r\n (address) => address.getId() === this.defaultShippingAddressId && address.getIsShippingAddress()\r\n );\r\n if (explicitDefault) {\r\n return explicitDefault.getId();\r\n }\r\n // Fallback: Find the first address marked as shipping (already sorted by most recent)\r\n return this.addresses.find((address) => address.getIsShippingAddress())?.getId() || null;\r\n }\r\n}\r\n"]}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Represents the countries where the application operates or products are available.
3
+ */
4
+ declare enum OperationalCountry {
5
+ /** India */ IN = "IN"
6
+ }
7
+ declare enum OperationalCountryCurrency {
8
+ /** India */ INR = "INR"
9
+ }
10
+ declare enum OperationalLocale {
11
+ /** India */ 'en-IN' = "en-IN"
12
+ }
13
+ /**
14
+ * Defines the supported ISO 4217 currency codes as an enumeration.
15
+ */
16
+ declare const CountryCurrencyMap: {
17
+ /** India */ IN: OperationalCountryCurrency;
18
+ };
19
+ declare const CurrencySymbolMap: {
20
+ INR: string;
21
+ };
22
+ /**
23
+ * Defines standard gender categories for product targeting.
24
+ */
25
+ declare enum GenderCategory {
26
+ MALE = "Male",
27
+ FEMALE = "Female",
28
+ UNISEX = "Unisex",
29
+ KIDS = "Kids",
30
+ BOY = "Boy",
31
+ GIRL = "Girl"
32
+ }
33
+
34
+ export { CountryCurrencyMap, CurrencySymbolMap, GenderCategory, OperationalCountry, OperationalCountryCurrency, OperationalLocale };
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Represents the countries where the application operates or products are available.
3
+ */
4
+ declare enum OperationalCountry {
5
+ /** India */ IN = "IN"
6
+ }
7
+ declare enum OperationalCountryCurrency {
8
+ /** India */ INR = "INR"
9
+ }
10
+ declare enum OperationalLocale {
11
+ /** India */ 'en-IN' = "en-IN"
12
+ }
13
+ /**
14
+ * Defines the supported ISO 4217 currency codes as an enumeration.
15
+ */
16
+ declare const CountryCurrencyMap: {
17
+ /** India */ IN: OperationalCountryCurrency;
18
+ };
19
+ declare const CurrencySymbolMap: {
20
+ INR: string;
21
+ };
22
+ /**
23
+ * Defines standard gender categories for product targeting.
24
+ */
25
+ declare enum GenderCategory {
26
+ MALE = "Male",
27
+ FEMALE = "Female",
28
+ UNISEX = "Unisex",
29
+ KIDS = "Kids",
30
+ BOY = "Boy",
31
+ GIRL = "Girl"
32
+ }
33
+
34
+ export { CountryCurrencyMap, CurrencySymbolMap, GenderCategory, OperationalCountry, OperationalCountryCurrency, OperationalLocale };
@@ -0,0 +1,2 @@
1
+ 'use strict';var n=(N=>(N.IN="IN",N))(n||{}),p=(N=>(N.INR="INR",N))(p||{}),x=(u=>(u["en-IN"]="en-IN",u))(x||{}),M={IN:"INR"},R={INR:"\u20B9"},m=(I=>(I.MALE="Male",I.FEMALE="Female",I.UNISEX="Unisex",I.KIDS="Kids",I.BOY="Boy",I.GIRL="Girl",I))(m||{});exports.CountryCurrencyMap=M;exports.CurrencySymbolMap=R;exports.GenderCategory=m;exports.OperationalCountry=n;exports.OperationalCountryCurrency=p;exports.OperationalLocale=x;//# sourceMappingURL=Enum.js.map
2
+ //# sourceMappingURL=Enum.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/Classes/Enum.ts"],"names":["OperationalCountry","OperationalCountryCurrency","OperationalLocale","CountryCurrencyMap","CurrencySymbolMap","GenderCategory"],"mappings":"aAGYA,IAAAA,CAAAA,CAAAA,CAAAA,CAAAA,GACGA,EAAA,EAAK,CAAA,IAAA,CADRA,OAAA,EAIAC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,GACGA,EAAA,GAAM,CAAA,KAAA,CADTA,OAAA,EAIAC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,GACGA,EAAA,OAAU,CAAA,CAAA,OAAA,CADbA,OAAA,EAOCC,CAAAA,CAAAA,CAAAA,CAAqB,CAClB,EAAA,CAAwB,KACxC,CAAA,CAEaC,EAAoB,CAC9B,GAAA,CAAiC,QACpC,CAKYC,CAAAA,CAAAA,CAAAA,CAAAA,CAAAA,GACVA,EAAA,IAAO,CAAA,MAAA,CACPA,CAAA,CAAA,MAAA,CAAS,QACTA,CAAAA,CAAAA,CAAA,OAAS,QACTA,CAAAA,CAAAA,CAAA,KAAO,MACPA,CAAAA,CAAAA,CAAA,IAAM,KACNA,CAAAA,CAAAA,CAAA,IAAO,CAAA,MAAA,CANGA,CAAA,CAAA,EAAA,CAAA,EAAA,EAAA","file":"Enum.js","sourcesContent":["/**\r\n * Represents the countries where the application operates or products are available.\r\n */\r\nexport enum OperationalCountry {\r\n /** India */ IN = 'IN',\r\n}\r\n \r\nexport enum OperationalCountryCurrency {\r\n /** India */ INR = 'INR',\r\n}\r\n\r\nexport enum OperationalLocale {\r\n /** India */ 'en-IN' = 'en-IN',\r\n}\r\n\r\n/**\r\n * Defines the supported ISO 4217 currency codes as an enumeration.\r\n */\r\nexport const CountryCurrencyMap = {\r\n /** India */ [OperationalCountry.IN]: OperationalCountryCurrency.INR,\r\n};\r\n\r\nexport const CurrencySymbolMap = {\r\n [OperationalCountryCurrency.INR]: '₹',\r\n}\r\n\r\n/**\r\n * Defines standard gender categories for product targeting.\r\n */\r\nexport enum GenderCategory {\r\n MALE = 'Male',\r\n FEMALE = 'Female',\r\n UNISEX = 'Unisex',\r\n KIDS = 'Kids',\r\n BOY = 'Boy',\r\n GIRL = 'Girl',\r\n}"]}
@@ -0,0 +1,2 @@
1
+ export{d as CountryCurrencyMap,e as CurrencySymbolMap,f as GenderCategory,a as OperationalCountry,b as OperationalCountryCurrency,c as OperationalLocale}from'../chunk-65X54TKF.mjs';//# sourceMappingURL=Enum.mjs.map
2
+ //# sourceMappingURL=Enum.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"Enum.mjs"}
@@ -0,0 +1,92 @@
1
+ declare enum ImageResolution {
2
+ THUMBNAIL = "thumbnail",
3
+ SMALL = "small",
4
+ MEDIUM = "medium",
5
+ LARGE = "large",
6
+ ORIGINAL = "original"
7
+ }
8
+ type ImageInfoAttribute = {
9
+ sources: {
10
+ [key in ImageResolution]?: string;
11
+ } & {
12
+ original: string;
13
+ };
14
+ alt?: string;
15
+ order?: number;
16
+ label?: string;
17
+ };
18
+ type ImageInfoData = ImageInfoAttribute;
19
+ /**
20
+ * Represents and manages structured image data, including multiple resolutions.
21
+ */
22
+ declare class ImageInfoModel {
23
+ protected sources: {
24
+ [key in ImageResolution]?: string;
25
+ } & {
26
+ original: string;
27
+ };
28
+ protected alt?: string;
29
+ protected order?: number;
30
+ protected label?: string;
31
+ /**
32
+ * Creates an instance of ImageInfoModel.
33
+ * @param data - The initial image data.
34
+ */
35
+ constructor(data: ImageInfoAttribute);
36
+ /**
37
+ * Gets the sources object containing URLs for different resolutions.
38
+ * Returns a copy to prevent external modification.
39
+ */
40
+ getSources(): {
41
+ thumbnail?: string | undefined;
42
+ small?: string | undefined;
43
+ medium?: string | undefined;
44
+ large?: string | undefined;
45
+ original: string;
46
+ };
47
+ /**
48
+ * Gets the URL for a specific resolution key.
49
+ * @param resolutionKey - The key of the desired resolution (e.g., 'thumbnail', 'medium').
50
+ * @returns The URL string if the key doesn't exist, otherwise original image URL will be returned.
51
+ */
52
+ getSource(resolutionKey: ImageResolution): string;
53
+ /**
54
+ * Gets the alternative text for the image.
55
+ */
56
+ getAlt(): string | undefined;
57
+ /**
58
+ * Gets the display order number for the image.
59
+ */
60
+ getOrder(): number | undefined;
61
+ /**
62
+ * Gets the display label or caption for the image.
63
+ */
64
+ getLabel(): string | undefined;
65
+ /**
66
+ * Sets the alternative text for the image.
67
+ * @param altText - The new alt text.
68
+ */
69
+ setAlt(altText: string | undefined): void;
70
+ /**
71
+ * Sets the display order for the image.
72
+ * @param order - The new order number.
73
+ */
74
+ setOrder(order: number | undefined): void;
75
+ /**
76
+ * Sets the display label for the image.
77
+ * @param label - The new label text.
78
+ */
79
+ setLabel(label: string | undefined): void;
80
+ /**
81
+ * Updates or adds a URL for a specific resolution.
82
+ * @param resolutionKey - The key of the resolution to update/add.
83
+ * @param url - The URL for the resolution. Set to undefined to remove.
84
+ */
85
+ setSource(resolutionKey: ImageResolution, url: string | undefined): void;
86
+ /**
87
+ * Returns a plain JavaScript object representation of the image info.
88
+ */
89
+ getDetails(): ImageInfoData;
90
+ }
91
+
92
+ export { type ImageInfoAttribute, type ImageInfoData, ImageResolution, ImageInfoModel as default };
@@ -0,0 +1,92 @@
1
+ declare enum ImageResolution {
2
+ THUMBNAIL = "thumbnail",
3
+ SMALL = "small",
4
+ MEDIUM = "medium",
5
+ LARGE = "large",
6
+ ORIGINAL = "original"
7
+ }
8
+ type ImageInfoAttribute = {
9
+ sources: {
10
+ [key in ImageResolution]?: string;
11
+ } & {
12
+ original: string;
13
+ };
14
+ alt?: string;
15
+ order?: number;
16
+ label?: string;
17
+ };
18
+ type ImageInfoData = ImageInfoAttribute;
19
+ /**
20
+ * Represents and manages structured image data, including multiple resolutions.
21
+ */
22
+ declare class ImageInfoModel {
23
+ protected sources: {
24
+ [key in ImageResolution]?: string;
25
+ } & {
26
+ original: string;
27
+ };
28
+ protected alt?: string;
29
+ protected order?: number;
30
+ protected label?: string;
31
+ /**
32
+ * Creates an instance of ImageInfoModel.
33
+ * @param data - The initial image data.
34
+ */
35
+ constructor(data: ImageInfoAttribute);
36
+ /**
37
+ * Gets the sources object containing URLs for different resolutions.
38
+ * Returns a copy to prevent external modification.
39
+ */
40
+ getSources(): {
41
+ thumbnail?: string | undefined;
42
+ small?: string | undefined;
43
+ medium?: string | undefined;
44
+ large?: string | undefined;
45
+ original: string;
46
+ };
47
+ /**
48
+ * Gets the URL for a specific resolution key.
49
+ * @param resolutionKey - The key of the desired resolution (e.g., 'thumbnail', 'medium').
50
+ * @returns The URL string if the key doesn't exist, otherwise original image URL will be returned.
51
+ */
52
+ getSource(resolutionKey: ImageResolution): string;
53
+ /**
54
+ * Gets the alternative text for the image.
55
+ */
56
+ getAlt(): string | undefined;
57
+ /**
58
+ * Gets the display order number for the image.
59
+ */
60
+ getOrder(): number | undefined;
61
+ /**
62
+ * Gets the display label or caption for the image.
63
+ */
64
+ getLabel(): string | undefined;
65
+ /**
66
+ * Sets the alternative text for the image.
67
+ * @param altText - The new alt text.
68
+ */
69
+ setAlt(altText: string | undefined): void;
70
+ /**
71
+ * Sets the display order for the image.
72
+ * @param order - The new order number.
73
+ */
74
+ setOrder(order: number | undefined): void;
75
+ /**
76
+ * Sets the display label for the image.
77
+ * @param label - The new label text.
78
+ */
79
+ setLabel(label: string | undefined): void;
80
+ /**
81
+ * Updates or adds a URL for a specific resolution.
82
+ * @param resolutionKey - The key of the resolution to update/add.
83
+ * @param url - The URL for the resolution. Set to undefined to remove.
84
+ */
85
+ setSource(resolutionKey: ImageResolution, url: string | undefined): void;
86
+ /**
87
+ * Returns a plain JavaScript object representation of the image info.
88
+ */
89
+ getDetails(): ImageInfoData;
90
+ }
91
+
92
+ export { type ImageInfoAttribute, type ImageInfoData, ImageResolution, ImageInfoModel as default };
@@ -0,0 +1,2 @@
1
+ 'use strict';Object.defineProperty(exports,'__esModule',{value:true});var s=(t=>(t.THUMBNAIL="thumbnail",t.SMALL="small",t.MEDIUM="medium",t.LARGE="large",t.ORIGINAL="original",t))(s||{}),r=class{sources;alt;order;label;constructor(e){if(this.sources={...e.sources},this.alt=e.alt,this.order=e.order,this.label=e.label,!this.sources.original)throw "ImageInfoModel cannot be created without an 'original' source URL."}getSources(){return {...this.sources}}getSource(e){return this.sources[e]||this.sources.original}getAlt(){return this.alt}getOrder(){return this.order}getLabel(){return this.label}setAlt(e){this.alt=e;}setOrder(e){this.order=e;}setLabel(e){this.label=e;}setSource(e,i){if(i===void 0){if(e==="original")throw "Cannot remove the 'original' image source.";delete this.sources[e];}else this.sources[e]=i;}getDetails(){return {sources:this.getSources(),alt:this.getAlt(),order:this.getOrder(),label:this.getLabel()}}};exports.ImageResolution=s;exports.default=r;//# sourceMappingURL=ImageInfo.js.map
2
+ //# sourceMappingURL=ImageInfo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/Classes/ImageInfo.ts"],"names":["ImageResolution","ImageInfoModel","data","resolutionKey","altText","order","label","url"],"mappings":"sEAAO,IAAKA,OACVA,CAAA,CAAA,SAAA,CAAY,WACZA,CAAAA,CAAAA,CAAA,MAAQ,OACRA,CAAAA,CAAAA,CAAA,MAAS,CAAA,QAAA,CACTA,EAAA,KAAQ,CAAA,OAAA,CACRA,CAAA,CAAA,QAAA,CAAW,WALDA,CAAA,CAAA,EAAA,CAAA,EAAA,EAAA,CAAA,CAoBSC,CAArB,CAAA,KAAoC,CACxB,OACA,CAAA,GAAA,CACA,KACA,CAAA,KAAA,CAMV,YAAYC,CAA0B,CAAA,CAMpC,GALA,IAAA,CAAK,QAAU,CAAE,GAAGA,EAAK,OAAQ,CAAA,CACjC,KAAK,GAAMA,CAAAA,CAAAA,CAAK,GAChB,CAAA,IAAA,CAAK,MAAQA,CAAK,CAAA,KAAA,CAClB,IAAK,CAAA,KAAA,CAAQA,EAAK,KAEd,CAAA,CAAC,IAAK,CAAA,OAAA,CAAQ,SACd,MAAO,oEAEb,CAMA,UAAA,EAAa,CACX,OAAO,CAAE,GAAG,IAAA,CAAK,OAAQ,CAC3B,CAOA,SAAUC,CAAAA,CAAAA,CAAuC,CAC/C,OAAO,IAAA,CAAK,OAAQA,CAAAA,CAAa,GAAK,IAAK,CAAA,OAAA,CAAQ,QACrD,CAKA,MAAA,EAA6B,CAC3B,OAAO,IAAA,CAAK,GACd,CAKA,UAA+B,CAC7B,OAAO,IAAK,CAAA,KACd,CAKA,QAA+B,EAAA,CAC7B,OAAO,IAAA,CAAK,KACd,CAMA,MAAA,CAAOC,CAAmC,CAAA,CACxC,KAAK,GAAMA,CAAAA,EAEb,CAMA,QAAA,CAASC,EAAiC,CACxC,IAAA,CAAK,KAAQA,CAAAA,EACf,CAMA,QAASC,CAAAA,CAAAA,CAAiC,CACxC,IAAA,CAAK,MAAQA,EACf,CAOA,UAAUH,CAAgCI,CAAAA,CAAAA,CAA+B,CACrE,GAAIA,CAAAA,GAAQ,KAAW,CAAA,CAAA,CAEnB,GAAIJ,CAAkB,GAAA,UAAA,CAClB,MAAO,4CAAA,CAGX,OAAO,IAAK,CAAA,OAAA,CAAQA,CAAa,EACrC,MACI,IAAK,CAAA,OAAA,CAAQA,CAAa,CAAII,CAAAA,EAEtC,CAKA,UAA4B,EAAA,CAC1B,OAAO,CACL,QAAS,IAAK,CAAA,UAAA,EACd,CAAA,GAAA,CAAK,KAAK,MAAO,EAAA,CACjB,KAAO,CAAA,IAAA,CAAK,UACZ,CAAA,KAAA,CAAO,KAAK,QAAS,EACvB,CACF,CACF","file":"ImageInfo.js","sourcesContent":["export enum ImageResolution {\r\n THUMBNAIL = 'thumbnail',\r\n SMALL = 'small',\r\n MEDIUM = 'medium',\r\n LARGE = 'large',\r\n ORIGINAL = 'original',\r\n}\r\n\r\nexport type ImageInfoAttribute = {\r\n sources: { [key in ImageResolution]?: string } & { original: string };\r\n alt?: string;\r\n order?: number;\r\n label?: string;\r\n};\r\n\r\nexport type ImageInfoData = ImageInfoAttribute;\r\n\r\n/**\r\n * Represents and manages structured image data, including multiple resolutions.\r\n */\r\nexport default class ImageInfoModel {\r\n protected sources: { [key in ImageResolution]?: string } & { original: string };\r\n protected alt?: string;\r\n protected order?: number;\r\n protected label?: string;\r\n\r\n /**\r\n * Creates an instance of ImageInfoModel.\r\n * @param data - The initial image data.\r\n */\r\n constructor(data: ImageInfoAttribute) {\r\n this.sources = { ...data.sources };\r\n this.alt = data.alt;\r\n this.order = data.order;\r\n this.label = data.label;\r\n\r\n if (!this.sources.original) {\r\n throw (\"ImageInfoModel cannot be created without an 'original' source URL.\");\r\n }\r\n }\r\n\r\n /**\r\n * Gets the sources object containing URLs for different resolutions.\r\n * Returns a copy to prevent external modification.\r\n */\r\n getSources() {\r\n return { ...this.sources };\r\n }\r\n\r\n /**\r\n * Gets the URL for a specific resolution key.\r\n * @param resolutionKey - The key of the desired resolution (e.g., 'thumbnail', 'medium').\r\n * @returns The URL string if the key doesn't exist, otherwise original image URL will be returned.\r\n */\r\n getSource(resolutionKey: ImageResolution): string{\r\n return this.sources[resolutionKey] || this.sources.original;\r\n }\r\n\r\n /**\r\n * Gets the alternative text for the image.\r\n */\r\n getAlt(): string | undefined {\r\n return this.alt;\r\n }\r\n\r\n /**\r\n * Gets the display order number for the image.\r\n */\r\n getOrder(): number | undefined {\r\n return this.order;\r\n }\r\n\r\n /**\r\n * Gets the display label or caption for the image.\r\n */\r\n getLabel(): string | undefined {\r\n return this.label;\r\n }\r\n\r\n /**\r\n * Sets the alternative text for the image.\r\n * @param altText - The new alt text.\r\n */\r\n setAlt(altText: string | undefined): void {\r\n this.alt = altText;\r\n // Potentially add logic here to trigger updates if needed\r\n }\r\n\r\n /**\r\n * Sets the display order for the image.\r\n * @param order - The new order number.\r\n */\r\n setOrder(order: number | undefined): void {\r\n this.order = order;\r\n }\r\n\r\n /**\r\n * Sets the display label for the image.\r\n * @param label - The new label text.\r\n */\r\n setLabel(label: string | undefined): void {\r\n this.label = label;\r\n }\r\n\r\n /**\r\n * Updates or adds a URL for a specific resolution.\r\n * @param resolutionKey - The key of the resolution to update/add.\r\n * @param url - The URL for the resolution. Set to undefined to remove.\r\n */\r\n setSource(resolutionKey: ImageResolution, url: string | undefined): void {\r\n if (url === undefined) {\r\n // Prevent deleting the 'original' key if it's required\r\n if (resolutionKey === 'original') {\r\n throw (\"Cannot remove the 'original' image source.\");\r\n return;\r\n }\r\n delete this.sources[resolutionKey];\r\n } else {\r\n this.sources[resolutionKey] = url;\r\n }\r\n }\r\n\r\n /**\r\n * Returns a plain JavaScript object representation of the image info.\r\n */\r\n getDetails(): ImageInfoData {\r\n return {\r\n sources: this.getSources(),\r\n alt: this.getAlt(),\r\n order: this.getOrder(),\r\n label: this.getLabel(),\r\n };\r\n }\r\n}"]}
@@ -0,0 +1,2 @@
1
+ export{a as ImageResolution,b as default}from'../chunk-DKI6BDWK.mjs';//# sourceMappingURL=ImageInfo.mjs.map
2
+ //# sourceMappingURL=ImageInfo.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"names":[],"mappings":"","file":"ImageInfo.mjs"}
@@ -0,0 +1,124 @@
1
+ import { LocalizedString, Color, BasePrice, PriceTier, LocaleCode } from './Common.mjs';
2
+ import ImageInfoModel, { ImageInfoData } from './ImageInfo.mjs';
3
+ import './Enum.mjs';
4
+
5
+ type SubItem = {
6
+ size: string;
7
+ quantity: number;
8
+ };
9
+ type LineItemAttributes = {
10
+ id: string;
11
+ productKey: string;
12
+ variantId: string;
13
+ name: LocalizedString;
14
+ attributes: {
15
+ color: Color;
16
+ };
17
+ primaryImage: ImageInfoData;
18
+ subItems: SubItem[];
19
+ basePrice: BasePrice;
20
+ priceTiers: PriceTier[];
21
+ };
22
+ type LineItemData = LineItemAttributes & {
23
+ totalQuantity: number;
24
+ priceTotals: {
25
+ subtotal: number;
26
+ mrpTotal: number;
27
+ };
28
+ };
29
+ /**
30
+ * Represents a line item within a shopping cart.
31
+ */
32
+ declare class LineItemModel {
33
+ protected id: string;
34
+ protected productKey: string;
35
+ protected variantId: string;
36
+ protected name: LocalizedString;
37
+ protected attributes: {
38
+ color: Color;
39
+ };
40
+ protected primaryImage: ImageInfoModel;
41
+ protected subItems: SubItem[];
42
+ protected totalQuantity: number;
43
+ protected basePrice: BasePrice;
44
+ protected priceTotals: {
45
+ subtotal: number;
46
+ mrpTotal: number;
47
+ };
48
+ protected priceTiers: PriceTier[];
49
+ /**
50
+ * Creates an instance of LineItemModel.
51
+ * @param data - The initial line item attributes.
52
+ */
53
+ constructor(data: LineItemAttributes);
54
+ /** Gets the unique identifier of the line item. */
55
+ getId(): string;
56
+ /** Gets the product key associated with this line item. */
57
+ getProductKey(): string;
58
+ /** Gets the product variant ID associated with this line item. */
59
+ getVariantId(): string;
60
+ /**
61
+ * Gets the full localized product name object.
62
+ * @returns A copy of the LocalizedString object for the name.
63
+ */
64
+ getName(): LocalizedString;
65
+ /**
66
+ * Gets the product name for a specific locale, falling back to English ('en').
67
+ * @param locale - The desired locale code.
68
+ * @returns The name string for the specified locale.
69
+ */
70
+ getName(locale: LocaleCode): string;
71
+ /** Gets the variant attributes. */
72
+ getAttributes(): {
73
+ color: Color;
74
+ };
75
+ /** Gets the image information model for this line item. */
76
+ getImage(): ImageInfoModel;
77
+ /** Gets the sub-items (size/quantity breakdown). */
78
+ getSubItems(): SubItem[];
79
+ /** Gets the total quantity for this line item across all sub-items. */
80
+ getTotalQuantity(): number;
81
+ /** Gets the base price for a single unit. */
82
+ getBasePrice(): BasePrice;
83
+ /** Gets the calculated price details (subtotal, mrpTotal) for this line item. */
84
+ getPriceTotals(): {
85
+ subtotal: number;
86
+ mrpTotal: number;
87
+ };
88
+ /** Gets the applicable price tiers for this product variant. */
89
+ getPriceTiers(): PriceTier[];
90
+ /**
91
+ * Recalculates the total quantity based on the quantities in subItems.
92
+ */
93
+ protected recalculateTotalQuantity(): void;
94
+ /**
95
+ * Recalculates the line item's price (subtotal and mrpTotal)
96
+ * based on total quantity, base price, and applicable price tiers.
97
+ */
98
+ protected recalculatePriceTotal(): void;
99
+ /**
100
+ * Gets a plain data object representing the line item's details.
101
+ * @returns LineItemData.
102
+ */
103
+ getDetails(): LineItemData;
104
+ /**
105
+ * Adds or updates sub-items (e.g., sizes with quantities) to the line item.
106
+ * If a sub-item with the same size already exists, its quantity is either
107
+ * updated by adding the new quantity or replaced entirely, based on the `addQuantity` flag.
108
+ * Sub-items with a resulting quantity of 0 are removed.
109
+ * Recalculates total quantity and price totals afterwards.
110
+ *
111
+ * @param subItems - An array of `SubItem` objects to add or update.
112
+ * @param addQuantity - If true, adds the quantity from `subItem` to the existing quantity.
113
+ * If false, replaces the existing quantity with the one from `subItem`.
114
+ */
115
+ addSubItems(subItems: SubItem[], addQuantity: boolean): void;
116
+ /**
117
+ * Resets the line item's properties to their default empty or initial state.
118
+ * Useful for clearing out line item data without creating a new instance.
119
+ * Recalculates total quantity and price totals afterwards (which will be zero).
120
+ */
121
+ clearLineItem(): void;
122
+ }
123
+
124
+ export { type LineItemAttributes, type LineItemData, type SubItem, LineItemModel as default };
@@ -0,0 +1,124 @@
1
+ import { LocalizedString, Color, BasePrice, PriceTier, LocaleCode } from './Common.js';
2
+ import ImageInfoModel, { ImageInfoData } from './ImageInfo.js';
3
+ import './Enum.js';
4
+
5
+ type SubItem = {
6
+ size: string;
7
+ quantity: number;
8
+ };
9
+ type LineItemAttributes = {
10
+ id: string;
11
+ productKey: string;
12
+ variantId: string;
13
+ name: LocalizedString;
14
+ attributes: {
15
+ color: Color;
16
+ };
17
+ primaryImage: ImageInfoData;
18
+ subItems: SubItem[];
19
+ basePrice: BasePrice;
20
+ priceTiers: PriceTier[];
21
+ };
22
+ type LineItemData = LineItemAttributes & {
23
+ totalQuantity: number;
24
+ priceTotals: {
25
+ subtotal: number;
26
+ mrpTotal: number;
27
+ };
28
+ };
29
+ /**
30
+ * Represents a line item within a shopping cart.
31
+ */
32
+ declare class LineItemModel {
33
+ protected id: string;
34
+ protected productKey: string;
35
+ protected variantId: string;
36
+ protected name: LocalizedString;
37
+ protected attributes: {
38
+ color: Color;
39
+ };
40
+ protected primaryImage: ImageInfoModel;
41
+ protected subItems: SubItem[];
42
+ protected totalQuantity: number;
43
+ protected basePrice: BasePrice;
44
+ protected priceTotals: {
45
+ subtotal: number;
46
+ mrpTotal: number;
47
+ };
48
+ protected priceTiers: PriceTier[];
49
+ /**
50
+ * Creates an instance of LineItemModel.
51
+ * @param data - The initial line item attributes.
52
+ */
53
+ constructor(data: LineItemAttributes);
54
+ /** Gets the unique identifier of the line item. */
55
+ getId(): string;
56
+ /** Gets the product key associated with this line item. */
57
+ getProductKey(): string;
58
+ /** Gets the product variant ID associated with this line item. */
59
+ getVariantId(): string;
60
+ /**
61
+ * Gets the full localized product name object.
62
+ * @returns A copy of the LocalizedString object for the name.
63
+ */
64
+ getName(): LocalizedString;
65
+ /**
66
+ * Gets the product name for a specific locale, falling back to English ('en').
67
+ * @param locale - The desired locale code.
68
+ * @returns The name string for the specified locale.
69
+ */
70
+ getName(locale: LocaleCode): string;
71
+ /** Gets the variant attributes. */
72
+ getAttributes(): {
73
+ color: Color;
74
+ };
75
+ /** Gets the image information model for this line item. */
76
+ getImage(): ImageInfoModel;
77
+ /** Gets the sub-items (size/quantity breakdown). */
78
+ getSubItems(): SubItem[];
79
+ /** Gets the total quantity for this line item across all sub-items. */
80
+ getTotalQuantity(): number;
81
+ /** Gets the base price for a single unit. */
82
+ getBasePrice(): BasePrice;
83
+ /** Gets the calculated price details (subtotal, mrpTotal) for this line item. */
84
+ getPriceTotals(): {
85
+ subtotal: number;
86
+ mrpTotal: number;
87
+ };
88
+ /** Gets the applicable price tiers for this product variant. */
89
+ getPriceTiers(): PriceTier[];
90
+ /**
91
+ * Recalculates the total quantity based on the quantities in subItems.
92
+ */
93
+ protected recalculateTotalQuantity(): void;
94
+ /**
95
+ * Recalculates the line item's price (subtotal and mrpTotal)
96
+ * based on total quantity, base price, and applicable price tiers.
97
+ */
98
+ protected recalculatePriceTotal(): void;
99
+ /**
100
+ * Gets a plain data object representing the line item's details.
101
+ * @returns LineItemData.
102
+ */
103
+ getDetails(): LineItemData;
104
+ /**
105
+ * Adds or updates sub-items (e.g., sizes with quantities) to the line item.
106
+ * If a sub-item with the same size already exists, its quantity is either
107
+ * updated by adding the new quantity or replaced entirely, based on the `addQuantity` flag.
108
+ * Sub-items with a resulting quantity of 0 are removed.
109
+ * Recalculates total quantity and price totals afterwards.
110
+ *
111
+ * @param subItems - An array of `SubItem` objects to add or update.
112
+ * @param addQuantity - If true, adds the quantity from `subItem` to the existing quantity.
113
+ * If false, replaces the existing quantity with the one from `subItem`.
114
+ */
115
+ addSubItems(subItems: SubItem[], addQuantity: boolean): void;
116
+ /**
117
+ * Resets the line item's properties to their default empty or initial state.
118
+ * Useful for clearing out line item data without creating a new instance.
119
+ * Recalculates total quantity and price totals afterwards (which will be zero).
120
+ */
121
+ clearLineItem(): void;
122
+ }
123
+
124
+ export { type LineItemAttributes, type LineItemData, type SubItem, LineItemModel as default };
@@ -0,0 +1,2 @@
1
+ 'use strict';var s=class{sources;alt;order;label;constructor(t){if(this.sources={...t.sources},this.alt=t.alt,this.order=t.order,this.label=t.label,!this.sources.original)throw "ImageInfoModel cannot be created without an 'original' source URL."}getSources(){return {...this.sources}}getSource(t){return this.sources[t]||this.sources.original}getAlt(){return this.alt}getOrder(){return this.order}getLabel(){return this.label}setAlt(t){this.alt=t;}setOrder(t){this.order=t;}setLabel(t){this.label=t;}setSource(t,e){if(e===void 0){if(t==="original")throw "Cannot remove the 'original' image source.";delete this.sources[t];}else this.sources[t]=e;}getDetails(){return {sources:this.getSources(),alt:this.getAlt(),order:this.getOrder(),label:this.getLabel()}}};var n=class{id;productKey;variantId;name;attributes;primaryImage;subItems;totalQuantity;basePrice;priceTotals;priceTiers;constructor(t){this.id=t.id,this.productKey=t.productKey,this.variantId=t.variantId,this.name={...t.name},this.attributes={...t.attributes},this.primaryImage=new s(t.primaryImage),this.subItems=t.subItems.map(e=>({...e})),this.basePrice={...t.basePrice},this.priceTiers=t.priceTiers.map(e=>({...e})),this.totalQuantity=0,this.priceTotals={subtotal:0,mrpTotal:0},this.recalculateTotalQuantity(),this.recalculatePriceTotal();}getId(){return this.id}getProductKey(){return this.productKey}getVariantId(){return this.variantId}getName(t){return t?this.name[t]??this.name.en:{...this.name}}getAttributes(){return {...this.attributes}}getImage(){return this.primaryImage}getSubItems(){return this.subItems.map(t=>({...t}))}getTotalQuantity(){return this.totalQuantity}getBasePrice(){return {...this.basePrice}}getPriceTotals(){return {...this.priceTotals}}getPriceTiers(){return this.priceTiers.map(t=>({...t}))}recalculateTotalQuantity(){this.totalQuantity=this.subItems.reduce((t,e)=>t+e.quantity,0);}recalculatePriceTotal(){let t=this.totalQuantity,e=this.basePrice.unitPrice,i=null;for(let r of this.priceTiers.sort((a,u)=>u.minQuantity-a.minQuantity))if(t>=r.minQuantity){i=r;break}i&&(e=i.unitPrice),this.priceTotals.mrpTotal=this.basePrice.unitPrice*t,this.priceTotals.subtotal=e*t;}getDetails(){return {id:this.getId(),productKey:this.getProductKey(),variantId:this.getVariantId(),name:this.getName(),attributes:this.getAttributes(),primaryImage:this.getImage().getDetails(),subItems:this.getSubItems(),totalQuantity:this.getTotalQuantity(),basePrice:this.getBasePrice(),priceTotals:this.getPriceTotals(),priceTiers:this.getPriceTiers()}}addSubItems(t,e){t.forEach(i=>{let r=this.subItems.find(a=>a.size===i.size);r?r.quantity=e?r.quantity+i.quantity:i.quantity:this.subItems.push(i);}),this.subItems=this.subItems.filter(i=>i.quantity),this.recalculateTotalQuantity(),this.recalculatePriceTotal();}clearLineItem(){this.id="",this.productKey="",this.variantId="",this.name={en:""},this.attributes={color:{name:"",hex:""}},this.primaryImage=new s({sources:{original:""}}),this.subItems=[],this.recalculateTotalQuantity(),this.recalculatePriceTotal();}};module.exports=n;//# sourceMappingURL=LineItem.js.map
2
+ //# sourceMappingURL=LineItem.js.map