@firfi/voila-sdk 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +165 -0
  3. package/dist/src/domain/cart.d.ts +10 -0
  4. package/dist/src/domain/cart.d.ts.map +1 -0
  5. package/dist/src/domain/cart.js +14 -0
  6. package/dist/src/domain/cart.js.map +1 -0
  7. package/dist/src/domain/checkout-readiness.d.ts +3 -0
  8. package/dist/src/domain/checkout-readiness.d.ts.map +1 -0
  9. package/dist/src/domain/checkout-readiness.js +18 -0
  10. package/dist/src/domain/checkout-readiness.js.map +1 -0
  11. package/dist/src/domain/parse.d.ts +5 -0
  12. package/dist/src/domain/parse.d.ts.map +1 -0
  13. package/dist/src/domain/parse.js +11 -0
  14. package/dist/src/domain/parse.js.map +1 -0
  15. package/dist/src/domain/schemas/auth.d.ts +123 -0
  16. package/dist/src/domain/schemas/auth.d.ts.map +1 -0
  17. package/dist/src/domain/schemas/auth.js +36 -0
  18. package/dist/src/domain/schemas/auth.js.map +1 -0
  19. package/dist/src/domain/schemas/cart.d.ts +1224 -0
  20. package/dist/src/domain/schemas/cart.d.ts.map +1 -0
  21. package/dist/src/domain/schemas/cart.js +123 -0
  22. package/dist/src/domain/schemas/cart.js.map +1 -0
  23. package/dist/src/domain/schemas/category-page.d.ts +187 -0
  24. package/dist/src/domain/schemas/category-page.d.ts.map +1 -0
  25. package/dist/src/domain/schemas/category-page.js +43 -0
  26. package/dist/src/domain/schemas/category-page.js.map +1 -0
  27. package/dist/src/domain/schemas/category.d.ts +25 -0
  28. package/dist/src/domain/schemas/category.d.ts.map +1 -0
  29. package/dist/src/domain/schemas/category.js +30 -0
  30. package/dist/src/domain/schemas/category.js.map +1 -0
  31. package/dist/src/domain/schemas/checkout-summary.d.ts +1035 -0
  32. package/dist/src/domain/schemas/checkout-summary.d.ts.map +1 -0
  33. package/dist/src/domain/schemas/checkout-summary.js +103 -0
  34. package/dist/src/domain/schemas/checkout-summary.js.map +1 -0
  35. package/dist/src/domain/schemas/delivery-destination.d.ts +176 -0
  36. package/dist/src/domain/schemas/delivery-destination.d.ts.map +1 -0
  37. package/dist/src/domain/schemas/delivery-destination.js +52 -0
  38. package/dist/src/domain/schemas/delivery-destination.js.map +1 -0
  39. package/dist/src/domain/schemas/index.d.ts +13 -0
  40. package/dist/src/domain/schemas/index.d.ts.map +1 -0
  41. package/dist/src/domain/schemas/index.js +13 -0
  42. package/dist/src/domain/schemas/index.js.map +1 -0
  43. package/dist/src/domain/schemas/money.d.ts +18 -0
  44. package/dist/src/domain/schemas/money.d.ts.map +1 -0
  45. package/dist/src/domain/schemas/money.js +11 -0
  46. package/dist/src/domain/schemas/money.js.map +1 -0
  47. package/dist/src/domain/schemas/product.d.ts +230 -0
  48. package/dist/src/domain/schemas/product.d.ts.map +1 -0
  49. package/dist/src/domain/schemas/product.js +32 -0
  50. package/dist/src/domain/schemas/product.js.map +1 -0
  51. package/dist/src/domain/schemas/proposition.d.ts +746 -0
  52. package/dist/src/domain/schemas/proposition.d.ts.map +1 -0
  53. package/dist/src/domain/schemas/proposition.js +110 -0
  54. package/dist/src/domain/schemas/proposition.js.map +1 -0
  55. package/dist/src/domain/schemas/search.d.ts +31 -0
  56. package/dist/src/domain/schemas/search.d.ts.map +1 -0
  57. package/dist/src/domain/schemas/search.js +16 -0
  58. package/dist/src/domain/schemas/search.js.map +1 -0
  59. package/dist/src/domain/schemas/session.d.ts +1341 -0
  60. package/dist/src/domain/schemas/session.d.ts.map +1 -0
  61. package/dist/src/domain/schemas/session.js +140 -0
  62. package/dist/src/domain/schemas/session.js.map +1 -0
  63. package/dist/src/domain/schemas/slot.d.ts +844 -0
  64. package/dist/src/domain/schemas/slot.d.ts.map +1 -0
  65. package/dist/src/domain/schemas/slot.js +130 -0
  66. package/dist/src/domain/schemas/slot.js.map +1 -0
  67. package/dist/src/index.d.ts +26 -0
  68. package/dist/src/index.d.ts.map +1 -0
  69. package/dist/src/index.js +26 -0
  70. package/dist/src/index.js.map +1 -0
  71. package/dist/src/voila/browser-login-adapter.d.ts +108 -0
  72. package/dist/src/voila/browser-login-adapter.d.ts.map +1 -0
  73. package/dist/src/voila/browser-login-adapter.js +128 -0
  74. package/dist/src/voila/browser-login-adapter.js.map +1 -0
  75. package/dist/src/voila/browser-login.d.ts +32 -0
  76. package/dist/src/voila/browser-login.d.ts.map +1 -0
  77. package/dist/src/voila/browser-login.js +86 -0
  78. package/dist/src/voila/browser-login.js.map +1 -0
  79. package/dist/src/voila/cart-mutation.d.ts +23 -0
  80. package/dist/src/voila/cart-mutation.d.ts.map +1 -0
  81. package/dist/src/voila/cart-mutation.js +52 -0
  82. package/dist/src/voila/cart-mutation.js.map +1 -0
  83. package/dist/src/voila/cart-view.d.ts +14 -0
  84. package/dist/src/voila/cart-view.d.ts.map +1 -0
  85. package/dist/src/voila/cart-view.js +45 -0
  86. package/dist/src/voila/cart-view.js.map +1 -0
  87. package/dist/src/voila/catalog-search.d.ts +27 -0
  88. package/dist/src/voila/catalog-search.d.ts.map +1 -0
  89. package/dist/src/voila/catalog-search.js +40 -0
  90. package/dist/src/voila/catalog-search.js.map +1 -0
  91. package/dist/src/voila/categories.d.ts +4 -0
  92. package/dist/src/voila/categories.d.ts.map +1 -0
  93. package/dist/src/voila/categories.js +22 -0
  94. package/dist/src/voila/categories.js.map +1 -0
  95. package/dist/src/voila/category-products.d.ts +22 -0
  96. package/dist/src/voila/category-products.d.ts.map +1 -0
  97. package/dist/src/voila/category-products.js +32 -0
  98. package/dist/src/voila/category-products.js.map +1 -0
  99. package/dist/src/voila/checkout-summary.d.ts +15 -0
  100. package/dist/src/voila/checkout-summary.d.ts.map +1 -0
  101. package/dist/src/voila/checkout-summary.js +93 -0
  102. package/dist/src/voila/checkout-summary.js.map +1 -0
  103. package/dist/src/voila/checkout-urls.d.ts +11 -0
  104. package/dist/src/voila/checkout-urls.d.ts.map +1 -0
  105. package/dist/src/voila/checkout-urls.js +23 -0
  106. package/dist/src/voila/checkout-urls.js.map +1 -0
  107. package/dist/src/voila/delivery-destinations.d.ts +22 -0
  108. package/dist/src/voila/delivery-destinations.d.ts.map +1 -0
  109. package/dist/src/voila/delivery-destinations.js +70 -0
  110. package/dist/src/voila/delivery-destinations.js.map +1 -0
  111. package/dist/src/voila/guest-bootstrap.d.ts +40 -0
  112. package/dist/src/voila/guest-bootstrap.d.ts.map +1 -0
  113. package/dist/src/voila/guest-bootstrap.js +108 -0
  114. package/dist/src/voila/guest-bootstrap.js.map +1 -0
  115. package/dist/src/voila/headers.d.ts +5 -0
  116. package/dist/src/voila/headers.d.ts.map +1 -0
  117. package/dist/src/voila/headers.js +20 -0
  118. package/dist/src/voila/headers.js.map +1 -0
  119. package/dist/src/voila/http-client.d.ts +60 -0
  120. package/dist/src/voila/http-client.d.ts.map +1 -0
  121. package/dist/src/voila/http-client.js +124 -0
  122. package/dist/src/voila/http-client.js.map +1 -0
  123. package/dist/src/voila/initial-state.d.ts +19 -0
  124. package/dist/src/voila/initial-state.d.ts.map +1 -0
  125. package/dist/src/voila/initial-state.js +117 -0
  126. package/dist/src/voila/initial-state.js.map +1 -0
  127. package/dist/src/voila/session-health.d.ts +10 -0
  128. package/dist/src/voila/session-health.d.ts.map +1 -0
  129. package/dist/src/voila/session-health.js +176 -0
  130. package/dist/src/voila/session-health.js.map +1 -0
  131. package/dist/src/voila/session-snapshot.d.ts +41 -0
  132. package/dist/src/voila/session-snapshot.d.ts.map +1 -0
  133. package/dist/src/voila/session-snapshot.js +101 -0
  134. package/dist/src/voila/session-snapshot.js.map +1 -0
  135. package/dist/src/voila/session-storage.d.ts +22 -0
  136. package/dist/src/voila/session-storage.d.ts.map +1 -0
  137. package/dist/src/voila/session-storage.js +54 -0
  138. package/dist/src/voila/session-storage.js.map +1 -0
  139. package/dist/src/voila/shopping-context.d.ts +33 -0
  140. package/dist/src/voila/shopping-context.d.ts.map +1 -0
  141. package/dist/src/voila/shopping-context.js +159 -0
  142. package/dist/src/voila/shopping-context.js.map +1 -0
  143. package/dist/src/voila/slot-urls.d.ts +22 -0
  144. package/dist/src/voila/slot-urls.d.ts.map +1 -0
  145. package/dist/src/voila/slot-urls.js +51 -0
  146. package/dist/src/voila/slot-urls.js.map +1 -0
  147. package/dist/src/voila/slots.d.ts +41 -0
  148. package/dist/src/voila/slots.d.ts.map +1 -0
  149. package/dist/src/voila/slots.js +137 -0
  150. package/dist/src/voila/slots.js.map +1 -0
  151. package/dist/src/voila/urls.d.ts +114 -0
  152. package/dist/src/voila/urls.d.ts.map +1 -0
  153. package/dist/src/voila/urls.js +197 -0
  154. package/dist/src/voila/urls.js.map +1 -0
  155. package/package.json +66 -0
@@ -0,0 +1,52 @@
1
+ import { Either, Schema } from "effect";
2
+ import { makeAddToCartDelta, makeRemoveFromCartDelta } from "../domain/cart.js";
3
+ import { parseUnknown } from "../domain/parse.js";
4
+ import { CartItemQuantityInputSchema, CartUpdateResponseSchema, NormalizedCartMutationResultSchema } from "../domain/schemas/index.js";
5
+ import { requestVoilaJson } from "./http-client.js";
6
+ import { makeApplyQuantityRequest } from "./urls.js";
7
+ const CartItemQuantityInputArraySchema = Schema.Array(CartItemQuantityInputSchema);
8
+ const cartItemsInputInvalid = () => ({
9
+ _tag: "CartItemsInputInvalid",
10
+ message: "Cart item input does not match the SDK schema"
11
+ });
12
+ const cartMutationResponseSchemaMismatch = () => ({
13
+ _tag: "CartMutationResponseSchemaMismatch",
14
+ message: "Voila cart mutation response does not match the SDK schema"
15
+ });
16
+ const countCartItems = (response) => (response.basketUpdateResult.itemGroups ?? []).reduce((total, group) => total + group.items.reduce((groupTotal, item) => groupTotal + item.quantity, 0), 0);
17
+ export const normalizeCartMutationResponse = (response) => ({
18
+ itemCount: countCartItems(response),
19
+ itemGroups: response.basketUpdateResult.itemGroups ?? [],
20
+ limitedItems: response.limitedItems,
21
+ limitedPromotionIds: response.limitedPromotionIds,
22
+ pricingNotifications: response.pricingNotifications,
23
+ totals: response.basketUpdateResult.totals,
24
+ unavailableData: response.unavailableData
25
+ });
26
+ export const parseCartMutationResponse = (input) => Either.flatMap(Either.mapLeft(parseUnknown(CartUpdateResponseSchema, input), cartMutationResponseSchemaMismatch), (response) => Either.mapLeft(parseUnknown(NormalizedCartMutationResultSchema, normalizeCartMutationResponse(response)), cartMutationResponseSchemaMismatch));
27
+ export const applyCartDeltas = async (session, deltas, transport, cookieJarPort) => {
28
+ const request = makeApplyQuantityRequest(deltas);
29
+ if (Either.isLeft(request)) {
30
+ return Either.left(request.left);
31
+ }
32
+ const response = await requestVoilaJson(CartUpdateResponseSchema, session, request.right, transport, cookieJarPort);
33
+ return Either.map(response, (result) => ({
34
+ session: result.session,
35
+ value: normalizeCartMutationResponse(result.value)
36
+ }));
37
+ };
38
+ const makeCartDeltas = (items, makeDelta) => items.reduce((deltas, item) => Either.flatMap(deltas, (current) => Either.map(makeDelta(item.productId, item.quantity), (delta) => [...current, delta])), Either.right([]));
39
+ const applyCartItemOperation = async (session, items, transport, makeDelta, cookieJarPort) => {
40
+ const parsedItems = Either.mapLeft(parseUnknown(CartItemQuantityInputArraySchema, items), cartItemsInputInvalid);
41
+ if (Either.isLeft(parsedItems)) {
42
+ return Either.left(parsedItems.left);
43
+ }
44
+ const deltas = makeCartDeltas(parsedItems.right, makeDelta);
45
+ if (Either.isLeft(deltas)) {
46
+ return Either.left(deltas.left);
47
+ }
48
+ return applyCartDeltas(session, deltas.right, transport, cookieJarPort);
49
+ };
50
+ export const addCartItems = async (session, items, transport, cookieJarPort) => applyCartItemOperation(session, items, transport, makeAddToCartDelta, cookieJarPort);
51
+ export const removeCartItems = async (session, items, transport, cookieJarPort) => applyCartItemOperation(session, items, transport, makeRemoveFromCartDelta, cookieJarPort);
52
+ //# sourceMappingURL=cart-mutation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cart-mutation.js","sourceRoot":"","sources":["../../../src/voila/cart-mutation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MA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;AAEtF,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,EAClC,OAAwB,EACxB,KAAc,EACd,SAAyB,EACzB,aAA6B,EAC2C,EAAE,CAC1E,sBAAsB,CAAC,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,uBAAuB,EAAE,aAAa,CAAC,CAAA"}
@@ -0,0 +1,14 @@
1
+ import { Either } from "effect";
2
+ import { type AnyCartViewResponse, type NormalizedCartView, type SessionSnapshot } from "../domain/schemas/index.js";
3
+ import type { VoilaJsonResult, VoilaSdkError, VoilaTransport } from "./http-client.js";
4
+ import type { CookieJarPort } from "./session-snapshot.js";
5
+ export type CartViewResponseNormalizationError = {
6
+ readonly _tag: "CartViewResponseSchemaMismatch";
7
+ readonly message: string;
8
+ };
9
+ export type GetCartError = VoilaSdkError;
10
+ export type GetCartResult = VoilaJsonResult<NormalizedCartView>;
11
+ export declare const normalizeCartViewResponse: (response: AnyCartViewResponse) => NormalizedCartView;
12
+ export declare const parseCartViewResponse: (input: unknown) => Either.Either<NormalizedCartView, CartViewResponseNormalizationError>;
13
+ export declare const getCart: (session: SessionSnapshot, transport: VoilaTransport, cookieJarPort?: CookieJarPort) => Promise<Either.Either<GetCartResult, GetCartError>>;
14
+ //# sourceMappingURL=cart-view.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cart-view.d.ts","sourceRoot":"","sources":["../../../src/voila/cart-view.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAG/B,OAAO,EAGL,KAAK,mBAAmB,EAKxB,KAAK,kBAAkB,EAEvB,KAAK,eAAe,EACrB,MAAM,4BAA4B,CAAA;AACnC,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEtF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAG1D,MAAM,MAAM,kCAAkC,GAAG;IAC/C,QAAQ,CAAC,IAAI,EAAE,gCAAgC,CAAA;IAC/C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CACzB,CAAA;AAED,MAAM,MAAM,YAAY,GAAG,aAAa,CAAA;AAExC,MAAM,MAAM,aAAa,GAAG,eAAe,CAAC,kBAAkB,CAAC,CAAA;AAoC/D,eAAO,MAAM,yBAAyB,GACpC,UAAU,mBAAmB,KAC5B,kBAmBF,CAAA;AAED,eAAO,MAAM,qBAAqB,GAChC,OAAO,OAAO,KACb,MAAM,CAAC,MAAM,CAAC,kBAAkB,EAAE,kCAAkC,CAQpE,CAAA;AAEH,eAAO,MAAM,OAAO,GAClB,SAAS,eAAe,EACxB,WAAW,cAAc,EACzB,gBAAgB,aAAa,KAC5B,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,aAAa,EAAE,YAAY,CAAC,CAapD,CAAA"}
@@ -0,0 +1,45 @@
1
+ import { Either } from "effect";
2
+ import { parseUnknown } from "../domain/parse.js";
3
+ import { AnyCartViewResponseSchema, NormalizedCartViewSchema } from "../domain/schemas/index.js";
4
+ import { requestVoilaJson } from "./http-client.js";
5
+ import { makeCartViewRequest } from "./urls.js";
6
+ const cartViewResponseSchemaMismatch = () => ({
7
+ _tag: "CartViewResponseSchemaMismatch",
8
+ message: "Voila cart view response does not match the SDK schema"
9
+ });
10
+ const normalizeCartViewItemGroup = (group) => group.items.map((item) => ({
11
+ ...item,
12
+ ...(group.name === undefined ? {} : { groupName: group.name })
13
+ }));
14
+ const normalizeLegacyCartViewItemGroups = (itemGroups) => (itemGroups ?? []).flatMap(normalizeCartViewItemGroup);
15
+ const normalizeActiveCartViewItemGroups = (checkoutGroups) => (checkoutGroups ?? []).flatMap((checkoutGroup) => (checkoutGroup.itemGroups ?? []).flatMap(normalizeCartViewItemGroup));
16
+ const normalizeCheckoutRestrictions = (restrictions) => (restrictions ?? []).map((restriction) => typeof restriction === "string"
17
+ ? { code: restriction }
18
+ : restriction);
19
+ const isActiveCartViewResponse = (response) => "cartId" in response;
20
+ export const normalizeCartViewResponse = (response) => {
21
+ const items = isActiveCartViewResponse(response)
22
+ ? normalizeActiveCartViewItemGroups(response.checkoutGroups?.assignedCheckoutGroups)
23
+ : normalizeLegacyCartViewItemGroups(response.basket.itemGroups);
24
+ return {
25
+ basketId: isActiveCartViewResponse(response) ? response.cartId : response.basket.basketId,
26
+ checkoutRestrictions: normalizeCheckoutRestrictions(isActiveCartViewResponse(response)
27
+ ? response.activeCheckoutGroup?.checkoutRestrictions
28
+ : response.checkoutRestrictions),
29
+ itemCount: items.reduce((total, item) => total + item.quantity, 0),
30
+ items,
31
+ limitedItems: isActiveCartViewResponse(response) ? [] : response.limitedItems ?? [],
32
+ pricingNotifications: response.pricingNotifications ?? [],
33
+ totals: isActiveCartViewResponse(response) ? response.totals : response.basket.totals,
34
+ unavailableData: response.unavailableData ?? []
35
+ };
36
+ };
37
+ export const parseCartViewResponse = (input) => Either.flatMap(Either.mapLeft(parseUnknown(AnyCartViewResponseSchema, input), cartViewResponseSchemaMismatch), (response) => Either.mapLeft(parseUnknown(NormalizedCartViewSchema, normalizeCartViewResponse(response)), cartViewResponseSchemaMismatch));
38
+ export const getCart = async (session, transport, cookieJarPort) => {
39
+ const response = await requestVoilaJson(AnyCartViewResponseSchema, session, makeCartViewRequest(), transport, cookieJarPort);
40
+ return Either.map(response, (result) => ({
41
+ session: result.session,
42
+ value: normalizeCartViewResponse(result.value)
43
+ }));
44
+ };
45
+ //# sourceMappingURL=cart-view.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cart-view.js","sourceRoot":"","sources":["../../../src/voila/cart-view.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAIL,yBAAyB,EAKzB,wBAAwB,EAEzB,MAAM,4BAA4B,CAAA;AAEnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAE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,EAAE,EAAE,CACX,MAAM,CAAC,OAAO,CACZ,YAAY,CAAC,wBAAwB,EAAE,yBAAyB,CAAC,QAAQ,CAAC,CAAC,EAC3E,8BAA8B,CAC/B,CACJ,CAAA;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,EAC1B,OAAwB,EACxB,SAAyB,EACzB,aAA6B,EACwB,EAAE;IACvD,MAAM,QAAQ,GAAG,MAAM,gBAAgB,CACrC,yBAAyB,EACzB,OAAO,EACP,mBAAmB,EAAE,EACrB,SAAS,EACT,aAAa,CACd,CAAA;IAED,OAAO,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QACvC,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,KAAK,EAAE,yBAAyB,CAAC,MAAM,CAAC,KAAK,CAAC;KAC/C,CAAC,CAAC,CAAA;AACL,CAAC,CAAA"}
@@ -0,0 +1,27 @@
1
+ import { Either } from "effect";
2
+ import { type Product, type ProductSearchResponse, type SessionSnapshot } from "../domain/schemas/index.js";
3
+ import type { VoilaJsonResult, VoilaSdkError, VoilaTransport } from "./http-client.js";
4
+ import type { CookieJarPort } from "./session-snapshot.js";
5
+ import type { SearchRequestError } from "./urls.js";
6
+ export interface NormalizedSearchProduct extends Product {
7
+ readonly sourceGroupName?: string;
8
+ readonly sourceGroupType: string;
9
+ }
10
+ export interface SearchPagination {
11
+ readonly nextPageToken?: string;
12
+ readonly totalProducts?: number;
13
+ }
14
+ export interface NormalizedSearchResult {
15
+ readonly pagination: SearchPagination;
16
+ readonly products: ReadonlyArray<NormalizedSearchProduct>;
17
+ }
18
+ export type SearchResponseNormalizationError = {
19
+ readonly _tag: "SearchResponseSchemaMismatch";
20
+ readonly message: string;
21
+ };
22
+ export type SearchProductsError = SearchRequestError | VoilaSdkError;
23
+ export type SearchProductsResult = VoilaJsonResult<NormalizedSearchResult>;
24
+ export declare const normalizeSearchResponse: (response: ProductSearchResponse) => NormalizedSearchResult;
25
+ export declare const parseSearchResponse: (input: unknown) => Either.Either<NormalizedSearchResult, SearchResponseNormalizationError>;
26
+ export declare const searchProducts: (session: SessionSnapshot, input: unknown, transport: VoilaTransport, cookieJarPort?: CookieJarPort) => Promise<Either.Either<SearchProductsResult, SearchProductsError>>;
27
+ //# sourceMappingURL=catalog-search.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog-search.d.ts","sourceRoot":"","sources":["../../../src/voila/catalog-search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAG/B,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,qBAAqB,EAE1B,KAAK,eAAe,EACrB,MAAM,4BAA4B,CAAA;AACnC,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEtF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAC1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAA;AAGnD,MAAM,WAAW,uBAAwB,SAAQ,OAAO;IACtD,QAAQ,CAAC,eAAe,CAAC,EAAE,MAAM,CAAA;IACjC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAA;CACjC;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAA;IAC/B,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAA;CAChC;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,UAAU,EAAE,gBAAgB,CAAA;IACrC,QAAQ,CAAC,QAAQ,EAAE,aAAa,CAAC,uBAAuB,CAAC,CAAA;CAC1D;AAED,MAAM,MAAM,gCAAgC,GAAG;IAC7C,QAAQ,CAAC,IAAI,EAAE,8BAA8B,CAAA;IAC7C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CACzB,CAAA;AAED,MAAM,MAAM,mBAAmB,GAAG,kBAAkB,GAAG,aAAa,CAAA;AAEpE,MAAM,MAAM,oBAAoB,GAAG,eAAe,CAAC,sBAAsB,CAAC,CAAA;AAsB1E,eAAO,MAAM,uBAAuB,GAClC,UAAU,qBAAqB,KAC9B,sBAMD,CAAA;AAEF,eAAO,MAAM,mBAAmB,GAC9B,OAAO,OAAO,KACb,MAAM,CAAC,MAAM,CAAC,sBAAsB,EAAE,gCAAgC,CAItE,CAAA;AAEH,eAAO,MAAM,cAAc,GACzB,SAAS,eAAe,EACxB,OAAO,OAAO,EACd,WAAW,cAAc,EACzB,gBAAgB,aAAa,KAC5B,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,oBAAoB,EAAE,mBAAmB,CAAC,CAalE,CAAA"}
@@ -0,0 +1,40 @@
1
+ import { Either } from "effect";
2
+ import { parseUnknown } from "../domain/parse.js";
3
+ import { ProductSearchResponseSchema } from "../domain/schemas/index.js";
4
+ import { requestVoilaJson } from "./http-client.js";
5
+ import { makeSearchRequest } from "./urls.js";
6
+ const searchResponseSchemaMismatch = () => ({
7
+ _tag: "SearchResponseSchemaMismatch",
8
+ message: "Voila search response does not match the SDK schema"
9
+ });
10
+ const normalizeGroupProducts = (group) => {
11
+ const products = [
12
+ ...(group.decoratedProducts ?? []),
13
+ ...(group.products ?? [])
14
+ ];
15
+ return products.map((product) => ({
16
+ ...product,
17
+ ...(group.name === undefined ? {} : { sourceGroupName: group.name }),
18
+ sourceGroupType: group.type
19
+ }));
20
+ };
21
+ export const normalizeSearchResponse = (response) => ({
22
+ pagination: {
23
+ ...(response.nextPageToken === undefined ? {} : { nextPageToken: response.nextPageToken }),
24
+ ...(response.totalProducts === undefined ? {} : { totalProducts: response.totalProducts })
25
+ },
26
+ products: response.productGroups.flatMap(normalizeGroupProducts)
27
+ });
28
+ export const parseSearchResponse = (input) => Either.map(Either.mapLeft(parseUnknown(ProductSearchResponseSchema, input), searchResponseSchemaMismatch), normalizeSearchResponse);
29
+ export const searchProducts = async (session, input, transport, cookieJarPort) => {
30
+ const request = makeSearchRequest(input);
31
+ if (Either.isLeft(request)) {
32
+ return Either.left(request.left);
33
+ }
34
+ const response = await requestVoilaJson(ProductSearchResponseSchema, session, request.right, transport, cookieJarPort);
35
+ return Either.map(response, (result) => ({
36
+ session: result.session,
37
+ value: normalizeSearchResponse(result.value)
38
+ }));
39
+ };
40
+ //# sourceMappingURL=catalog-search.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog-search.js","sourceRoot":"","sources":["../../../src/voila/catalog-search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAGL,2BAA2B,EAE5B,MAAM,4BAA4B,CAAA;AAEnC,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAA;AAGnD,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAA;AA0B7C,MAAM,4BAA4B,GAAG,GAAqC,EAAE,CAAC,CAAC;IAC5E,IAAI,EAAE,8BAA8B;IACpC,OAAO,EAAE,qDAAqD;CAC/D,CAAC,CAAA;AAEF,MAAM,sBAAsB,GAAG,CAC7B,KAAqD,EACb,EAAE;IAC1C,MAAM,QAAQ,GAAG;QACf,GAAG,CAAC,KAAK,CAAC,iBAAiB,IAAI,EAAE,CAAC;QAClC,GAAG,CAAC,KAAK,CAAC,QAAQ,IAAI,EAAE,CAAC;KAC1B,CAAA;IAED,OAAO,QAAQ,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QAChC,GAAG,OAAO;QACV,GAAG,CAAC,KAAK,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC;QACpE,eAAe,EAAE,KAAK,CAAC,IAAI;KAC5B,CAAC,CAAC,CAAA;AACL,C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;QACvB,KAAK,EAAE,uBAAuB,CAAC,MAAM,CAAC,KAAK,CAAC;KAC7C,CAAC,CAAC,CAAA;AACL,CAAC,CAAA"}
@@ -0,0 +1,4 @@
1
+ import type { InitialState, NormalizedCategoryTree, RawCategory } from "../domain/schemas/index.js";
2
+ export declare const normalizeCategoryTree: (categories: ReadonlyArray<RawCategory>) => NormalizedCategoryTree;
3
+ export declare const getInitialStateCategories: (initialState: InitialState) => NormalizedCategoryTree;
4
+ //# sourceMappingURL=categories.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"categories.d.ts","sourceRoot":"","sources":["../../../src/voila/categories.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAsB,sBAAsB,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAA;AA+BvH,eAAO,MAAM,qBAAqB,GAChC,YAAY,aAAa,CAAC,WAAW,CAAC,KACrC,sBAA8F,CAAA;AAEjG,eAAO,MAAM,yBAAyB,GACpC,cAAc,YAAY,KACzB,sBAAmF,CAAA"}
@@ -0,0 +1,22 @@
1
+ const slash = "/";
2
+ const trimSlashes = (path) => path.replace(/^\/+|\/+$/g, "");
3
+ const makeFullUrlPath = (parentPath, urlPath) => {
4
+ const normalizedPath = trimSlashes(urlPath);
5
+ if (parentPath === undefined || urlPath.startsWith(slash)) {
6
+ return `${slash}${normalizedPath}`;
7
+ }
8
+ return `${slash}${[trimSlashes(parentPath), normalizedPath].filter(Boolean).join(slash)}`;
9
+ };
10
+ const normalizeCategory = (category, parentPath) => {
11
+ const fullUrlPath = makeFullUrlPath(parentPath, category.urlPath);
12
+ return {
13
+ categoryId: category.categoryId,
14
+ children: (category.categories ?? []).map((child) => normalizeCategory(child, fullUrlPath)),
15
+ fullUrlPath,
16
+ name: category.name,
17
+ retailerCategoryId: category.retailerCategoryId
18
+ };
19
+ };
20
+ export const normalizeCategoryTree = (categories) => categories.map((category) => normalizeCategory(category, undefined));
21
+ export const getInitialStateCategories = (initialState) => normalizeCategoryTree(initialState.data.categories ?? []);
22
+ //# sourceMappingURL=categories.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"categories.js","sourceRoot":"","sources":["../../../src/voila/categories.ts"],"names":[],"mappings":"AAEA,MAAM,KAAK,GAAG,GAAG,CAAA;AAEjB,MAAM,WAAW,GAAG,CAAC,IAAY,EAAU,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAA;AAE5E,MAAM,eAAe,GAAG,CAAC,UAA8B,EAAE,OAAe,EAAU,EAAE;IAClF,MAAM,cAAc,GAAG,WAAW,CAAC,OAAO,CAAC,CAAA;IAE3C,IAAI,UAAU,KAAK,SAAS,IAAI,OAAO,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QAC1D,OAAO,GAAG,KAAK,GAAG,cAAc,EAAE,CAAA;IACpC,CAAC;IAED,OAAO,GAAG,KAAK,GAAG,CAAC,WAAW,CAAC,UAAU,CAAC,EAAE,cAAc,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAA;AAC3F,CAAC,CAAA;AAED,MAAM,iBAAiB,GAAG,CACxB,QAAqB,EACrB,UAA8B,EACV,EAAE;IACtB,MAAM,WAAW,GAAG,eAAe,CAAC,UAAU,EAAE,QAAQ,CAAC,OAAO,CAAC,CAAA;IAEjE,OAAO;QACL,UAAU,EAAE,QAAQ,CAAC,UAAU;QAC/B,QAAQ,EAAE,CAAC,QAAQ,CAAC,UAAU,IAAI,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,iBAAiB,CAAC,KAAK,EAAE,WAAW,CAAC,CAAC;QAC3F,WAAW;QACX,IAAI,EAAE,QAAQ,CAAC,IAAI;QACnB,kBAAkB,EAAE,QAAQ,CAAC,kBAAkB;KAChD,CAAA;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,UAAsC,EACd,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,iBAAiB,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,CAAA;AAEjG,MAAM,CAAC,MAAM,yBAAyB,GAAG,CACvC,YAA0B,EACF,EAAE,CAAC,qBAAqB,CAAC,YAAY,CAAC,IAAI,CAAC,UAAU,IAAI,EAAE,CAAC,CAAA"}
@@ -0,0 +1,22 @@
1
+ import { Either } from "effect";
2
+ import { type CategoryPageFilter, type CategoryPageSummary, type CategoryProductPageResponse, type SessionSnapshot } from "../domain/schemas/index.js";
3
+ import type { NormalizedSearchProduct, SearchPagination } from "./catalog-search.js";
4
+ import type { VoilaJsonResult, VoilaSdkError, VoilaTransport } from "./http-client.js";
5
+ import type { CookieJarPort } from "./session-snapshot.js";
6
+ import type { CategoryProductsRequestError } from "./urls.js";
7
+ export interface NormalizedCategoryProductsResult {
8
+ readonly category: CategoryPageSummary;
9
+ readonly filters: ReadonlyArray<CategoryPageFilter>;
10
+ readonly pagination: SearchPagination;
11
+ readonly products: ReadonlyArray<NormalizedSearchProduct>;
12
+ }
13
+ export type CategoryProductsResponseNormalizationError = {
14
+ readonly _tag: "CategoryProductsResponseSchemaMismatch";
15
+ readonly message: string;
16
+ };
17
+ export type GetCategoryProductsError = CategoryProductsRequestError | VoilaSdkError;
18
+ export type GetCategoryProductsResult = VoilaJsonResult<NormalizedCategoryProductsResult>;
19
+ export declare const normalizeCategoryProductsResponse: (response: CategoryProductPageResponse) => NormalizedCategoryProductsResult;
20
+ export declare const parseCategoryProductsResponse: (input: unknown) => Either.Either<NormalizedCategoryProductsResult, CategoryProductsResponseNormalizationError>;
21
+ export declare const getCategoryProducts: (session: SessionSnapshot, input: unknown, transport: VoilaTransport, cookieJarPort?: CookieJarPort) => Promise<Either.Either<GetCategoryProductsResult, GetCategoryProductsError>>;
22
+ //# sourceMappingURL=category-products.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"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AAe,EACxB,OAAO,OAAO,EACd,WAAW,cAAc,EACzB,gBAAgB,aAAa,KAC5B,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,yBAAyB,EAAE,wBAAwB,CAAC,CAmB5E,CAAA"}
@@ -0,0 +1,32 @@
1
+ import { Either } from "effect";
2
+ import { parseUnknown } from "../domain/parse.js";
3
+ import { CategoryProductPageResponseSchema } from "../domain/schemas/index.js";
4
+ import { normalizeSearchResponse } from "./catalog-search.js";
5
+ import { requestVoilaJson } from "./http-client.js";
6
+ import { makeCategoryProductsRequest } from "./urls.js";
7
+ const categoryProductsResponseSchemaMismatch = () => ({
8
+ _tag: "CategoryProductsResponseSchemaMismatch",
9
+ message: "Voila category products response does not match the SDK schema"
10
+ });
11
+ export const normalizeCategoryProductsResponse = (response) => {
12
+ const searchResult = normalizeSearchResponse(response);
13
+ return {
14
+ category: response.category,
15
+ filters: response.filters ?? [],
16
+ pagination: searchResult.pagination,
17
+ products: searchResult.products
18
+ };
19
+ };
20
+ export const parseCategoryProductsResponse = (input) => Either.map(Either.mapLeft(parseUnknown(CategoryProductPageResponseSchema, input), categoryProductsResponseSchemaMismatch), normalizeCategoryProductsResponse);
21
+ export const getCategoryProducts = async (session, input, transport, cookieJarPort) => {
22
+ const request = makeCategoryProductsRequest(input);
23
+ if (Either.isLeft(request)) {
24
+ return Either.left(request.left);
25
+ }
26
+ const response = await requestVoilaJson(CategoryProductPageResponseSchema, session, request.right, transport, cookieJarPort);
27
+ return Either.map(response, (result) => ({
28
+ session: result.session,
29
+ value: normalizeCategoryProductsResponse(result.value)
30
+ }));
31
+ };
32
+ //# sourceMappingURL=category-products.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"category-products.js","sourceRoot":"","sources":["../../../src/voila/category-products.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAIL,iC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,CAAC,KAAK,EACb,SAAS,EACT,aAAa,CACd,CAAA;IAED,OAAO,MAAM,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;QACvC,OAAO,EAAE,MAAM,CAAC,OAAO;QACvB,KAAK,EAAE,iCAAiC,CAAC,MAAM,CAAC,KAAK,CAAC;KACvD,CAAC,CAAC,CAAA;AACL,CAAC,CAAA"}
@@ -0,0 +1,15 @@
1
+ import { Either } from "effect";
2
+ import { type NormalizedCheckoutSummary, type RawCheckoutSummaryResponse, type SessionSnapshot } from "../domain/schemas/index.js";
3
+ import type { CheckoutSummaryRequestError } from "./checkout-urls.js";
4
+ import type { VoilaJsonResult, VoilaSdkError, VoilaTransport } from "./http-client.js";
5
+ import type { CookieJarPort } from "./session-snapshot.js";
6
+ export type CheckoutSummaryNormalizationError = {
7
+ readonly _tag: "CheckoutSummarySchemaMismatch";
8
+ readonly message: string;
9
+ };
10
+ export type GetCheckoutSummaryError = CheckoutSummaryRequestError | VoilaSdkError;
11
+ export type GetCheckoutSummaryResult = VoilaJsonResult<NormalizedCheckoutSummary>;
12
+ export declare const normalizeCheckoutSummaryResponse: (response: RawCheckoutSummaryResponse) => NormalizedCheckoutSummary;
13
+ export declare const parseCheckoutSummaryResponse: (input: unknown) => Either.Either<NormalizedCheckoutSummary, CheckoutSummaryNormalizationError>;
14
+ export declare const getCheckoutSummary: (session: SessionSnapshot, input: unknown, transport: VoilaTransport, cookieJarPort?: CookieJarPort) => Promise<Either.Either<GetCheckoutSummaryResult, GetCheckoutSummaryError>>;
15
+ //# sourceMappingURL=checkout-summary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkout-summary.d.ts","sourceRoot":"","sources":["../../../src/voila/checkout-summary.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAG/B,OAAO,EAOL,KAAK,yBAAyB,EAG9B,KAAK,0BAA0B,EAE/B,KAAK,eAAe,EACrB,MAAM,4BAA4B,CAAA;AAEnC,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,oBAAoB,CAAA;AAErE,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEtF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAE1D,MAAM,MAAM,iCAAiC,GAAG;IAC9C,QAAQ,CAAC,IAAI,EAAE,+BAA+B,CAAA;IAC9C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CACzB,CAAA;AAED,MAAM,MAAM,uBAAuB,GAAG,2BAA2B,GAAG,aAAa,CAAA;AAEjF,MAAM,MAAM,wBAAwB,GAAG,eAAe,CAAC,yBAAyB,CAAC,CAAA;AAgDjF,eAAO,MAAM,gCAAgC,GAC3C,UAAU,0BAA0B,KACnC,yBAyCF,CAAA;AAED,eAAO,MAAM,4BAA4B,GACvC,OAAO,OAAO,KACb,MAAM,CAAC,MAAM,CAAC,yBAAyB,EAAE,iCAAiC,CAQ1E,CAAA;AAEH,eAAO,MAAM,kBAAkB,GAC7B,SAAS,eAAe,EACxB,OAAO,OAAO,EACd,WAAW,cAAc,EACzB,gBAAgB,aAAa,KAC5B,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,wBAAwB,EAAE,uBAAuB,CAAC,CAmB1E,CAAA"}
@@ -0,0 +1,93 @@
1
+ import { Either } from "effect";
2
+ import { parseUnknown } from "../domain/parse.js";
3
+ import { NormalizedCheckoutSummarySchema, RawCheckoutSummaryResponseSchema } from "../domain/schemas/index.js";
4
+ import { makeCheckoutSummaryRequest } from "./checkout-urls.js";
5
+ import { requestVoilaJson } from "./http-client.js";
6
+ const checkoutSummarySchemaMismatch = () => ({
7
+ _tag: "CheckoutSummarySchemaMismatch",
8
+ message: "Voila checkout summary response does not match the SDK schema"
9
+ });
10
+ const chargeAmount = (charge) => charge?.finalPrice ?? charge?.price;
11
+ const normalizeFees = (charges) => {
12
+ const carrierBag = chargeAmount(charges?.carrierBag);
13
+ const delivery = chargeAmount(charges?.delivery);
14
+ const invoice = chargeAmount(charges?.invoice);
15
+ const preparation = chargeAmount(charges?.preparation);
16
+ const smallOrder = chargeAmount(charges?.smallOrder);
17
+ return {
18
+ ...(carrierBag === undefined ? {} : { carrierBag }),
19
+ ...(delivery === undefined ? {} : { delivery }),
20
+ ...(invoice === undefined ? {} : { invoice }),
21
+ ...(preparation === undefined ? {} : { preparation }),
22
+ ...(smallOrder === undefined ? {} : { smallOrder })
23
+ };
24
+ };
25
+ const normalizeSelectedSlot = (delivery) => delivery === undefined
26
+ ? undefined
27
+ : {
28
+ ...(delivery.deliveryPriceChanged === undefined ? {} : { deliveryPriceChanged: delivery.deliveryPriceChanged }),
29
+ ...(delivery.endTime === undefined ? {} : { endTime: delivery.endTime }),
30
+ ...(delivery.expiryTime === undefined ? {} : { expiryTime: delivery.expiryTime }),
31
+ ...(delivery.price === undefined ? {} : { price: delivery.price }),
32
+ ...(delivery.slotId === undefined ? {} : { slotId: delivery.slotId }),
33
+ ...(delivery.startTime === undefined ? {} : { startTime: delivery.startTime }),
34
+ ...(delivery.timeZoneId === undefined ? {} : { timeZoneId: delivery.timeZoneId })
35
+ };
36
+ const tagWarnings = (kind, signals) => signals.map((signal) => ({
37
+ kind,
38
+ signal
39
+ }));
40
+ export const normalizeCheckoutSummaryResponse = (response) => {
41
+ const checkoutRestrictions = response.checkout.checkoutRestrictions ?? [];
42
+ const limitedItems = response.limitedItems ?? [];
43
+ const pricingNotifications = response.pricingNotifications ?? [];
44
+ const selectedSlot = normalizeSelectedSlot(response.checkout.delivery);
45
+ const substitutions = response.substitutions ?? [];
46
+ const unavailableData = response.unavailableData ?? [];
47
+ return {
48
+ basketAboveThreshold: response.checkout.basketAboveThreshold ?? false,
49
+ ...(response.cartId === undefined ? {} : { basketId: response.cartId }),
50
+ canCheckout: response.checkout.canCheckout ?? false,
51
+ ...(response.checkoutCorrelationId === undefined
52
+ ? {}
53
+ : { checkoutCorrelationId: response.checkoutCorrelationId }),
54
+ checkoutRestrictions,
55
+ fees: normalizeFees(response.charges),
56
+ limitedItems,
57
+ ...(response.checkout.minimumCheckoutThreshold === undefined
58
+ ? {}
59
+ : { minimumCheckoutThreshold: response.checkout.minimumCheckoutThreshold }),
60
+ ...(response.orderId === undefined ? {} : { orderId: response.orderId }),
61
+ pricingNotifications,
62
+ ...(selectedSlot === undefined ? {} : { selectedSlot }),
63
+ ...(response.checkout.shippingGroupType === undefined
64
+ ? {}
65
+ : { shippingGroupType: response.checkout.shippingGroupType }),
66
+ ...(response.checkout.shippingGroupTypeDisplayName === undefined
67
+ ? {}
68
+ : { shippingGroupTypeDisplayName: response.checkout.shippingGroupTypeDisplayName }),
69
+ substitutions,
70
+ ...(response.totals === undefined ? {} : { totals: response.totals }),
71
+ unavailableData,
72
+ warnings: [
73
+ ...tagWarnings("checkout-restriction", checkoutRestrictions),
74
+ ...tagWarnings("limited-item", limitedItems),
75
+ ...tagWarnings("pricing-notification", pricingNotifications),
76
+ ...tagWarnings("substitution", substitutions),
77
+ ...tagWarnings("unavailable-item", unavailableData)
78
+ ]
79
+ };
80
+ };
81
+ export const parseCheckoutSummaryResponse = (input) => Either.flatMap(Either.mapLeft(parseUnknown(RawCheckoutSummaryResponseSchema, input), checkoutSummarySchemaMismatch), (response) => Either.mapLeft(parseUnknown(NormalizedCheckoutSummarySchema, normalizeCheckoutSummaryResponse(response)), checkoutSummarySchemaMismatch));
82
+ export const getCheckoutSummary = async (session, input, transport, cookieJarPort) => {
83
+ const request = makeCheckoutSummaryRequest(input);
84
+ if (Either.isLeft(request)) {
85
+ return Either.left(request.left);
86
+ }
87
+ const response = await requestVoilaJson(RawCheckoutSummaryResponseSchema, session, request.right, transport, cookieJarPort);
88
+ return Either.map(response, (result) => ({
89
+ session: result.session,
90
+ value: normalizeCheckoutSummaryResponse(result.value)
91
+ }));
92
+ };
93
+ //# sourceMappingURL=checkout-summary.js.map
@@ -0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url: URL;
5
+ }
6
+ export type CheckoutSummaryRequestError = {
7
+ readonly _tag: "CheckoutSummaryInputInvalid";
8
+ readonly message: string;
9
+ };
10
+ export declare const makeCheckoutSummaryRequest: (input?: unknown) => Either.Either<CheckoutSummaryRequest, CheckoutSummaryRequestError>;
11
+ //# sourceMappingURL=checkout-urls.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkout-urls.d.ts","sourceRoot":"","sources":["../../../src/voila/checkout-urls.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAQ/B,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,MAAM,EAAE,KAAK,CAAA;IACtB,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAA;CAClB;AAED,MAAM,MAAM,2BAA2B,GAAG;IACxC,QAAQ,CAAC,IAAI,EAAE,6BAA6B,CAAA;IAC5C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CACzB,CAAA;AAOD,eAAO,MAAM,0BAA0B,GACrC,QAAO,OAAY,KAClB,MAAM,CAAC,MAAM,CAAC,sBAAsB,EAAE,2BAA2B,CAmBjE,CAAA"}
@@ -0,0 +1,23 @@
1
+ import { Either } from "effect";
2
+ import { parseUnknown } from "../domain/parse.js";
3
+ import { CheckoutSummaryInputSchema } from "../domain/schemas/index.js";
4
+ import { VOILA_BASE_URL } from "./urls.js";
5
+ const CHECKOUT_SUMMARY_PATH = "/api/cart/v1/carts/active/checkout-summary";
6
+ const checkoutSummaryInputInvalid = () => ({
7
+ _tag: "CheckoutSummaryInputInvalid",
8
+ message: "Checkout summary request input does not match the SDK schema"
9
+ });
10
+ export const makeCheckoutSummaryRequest = (input = {}) => Either.map(Either.mapLeft(parseUnknown(CheckoutSummaryInputSchema, input), checkoutSummaryInputInvalid), (summaryInput) => {
11
+ const url = new URL(CHECKOUT_SUMMARY_PATH, VOILA_BASE_URL);
12
+ if (summaryInput.fetchAllocatedPaymentChecks === true) {
13
+ url.searchParams.set("fetchAllocatedPaymentChecks", "true");
14
+ }
15
+ if (summaryInput.appliedPaymentCheckId !== undefined) {
16
+ url.searchParams.set("paymentCheckId", summaryInput.appliedPaymentCheckId);
17
+ }
18
+ return {
19
+ method: "GET",
20
+ url
21
+ };
22
+ });
23
+ //# sourceMappingURL=checkout-urls.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkout-urls.js","sourceRoot":"","sources":["../../../src/voila/checkout-urls.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAE/B,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,0BAA0B,EAAE,MAAM,4BAA4B,CAAA;AACvE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAE1C,MAAM,qBAAqB,GAAG,4CAA4C,CAAA;AAY1E,MAAM,2BAA2B,GAAG,GAAgC,EAAE,CAAC,CAAC;IACtE,IAAI,EAAE,6BAA6B;IACnC,OAAO,EAAE,8DAA8D;CACxE,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,0BAA0B,GAAG,CACxC,QAAiB,EAAE,EACiD,EAAE,CACtE,MAAM,CAAC,GAAG,CACR,MAAM,CAAC,OAAO,CAAC,YAAY,CAAC,0BAA0B,EAAE,KAAK,CAAC,EAAE,2BAA2B,CAAC,EAC5F,CAAC,YAAY,EAAE,EAAE;IACf,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,qBAAqB,EAAE,cAAc,CAAC,CAAA;IAE1D,IAAI,YAAY,CAAC,2BAA2B,KAAK,IAAI,EAAE,CAAC;QACtD,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,6BAA6B,EAAE,MAAM,CAAC,CAAA;IAC7D,CAAC;IAED,IAAI,YAAY,CAAC,qBAAqB,KAAK,SAAS,EAAE,CAAC;QACrD,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,gBAAgB,EAAE,YAAY,CAAC,qBAAqB,CAAC,CAAA;IAC5E,CAAC;IAED,OAAO;QACL,MAAM,EAAE,KAAK;QACb,GAAG;KACJ,CAAA;AACH,CAAC,CACF,CAAA"}
@@ -0,0 +1,22 @@
1
+ import { Either } from "effect";
2
+ import { type DeliveryDestination, type DeliveryDestinationsDiagnostic, type NormalizedDeliveryDestinations, type RawDeliveryDestination, type RawDeliveryDestinationsResponse, type SessionSnapshot } from "../domain/schemas/index.js";
3
+ import type { VoilaJsonResult, VoilaSdkError, VoilaTransport } from "./http-client.js";
4
+ import type { CookieJarPort } from "./session-snapshot.js";
5
+ import type { DeliveryDestinationRequestError, DeliveryDestinationsRequestError } from "./urls.js";
6
+ export type DeliveryDestinationsResponseNormalizationError = {
7
+ readonly _tag: "DeliveryDestinationsResponseSchemaMismatch";
8
+ readonly message: string;
9
+ };
10
+ export type GetDeliveryDestinationsError = DeliveryDestinationsRequestError | VoilaSdkError;
11
+ export type GetDeliveryDestinationsResult = VoilaJsonResult<NormalizedDeliveryDestinations>;
12
+ export type GetDeliveryDestinationError = DeliveryDestinationRequestError | VoilaSdkError;
13
+ export type GetDeliveryDestinationResult = VoilaJsonResult<DeliveryDestination>;
14
+ export declare const normalizeDeliveryDestination: (destination: RawDeliveryDestination) => DeliveryDestination;
15
+ export declare const normalizeDeliveryDestinationsResponse: (response: RawDeliveryDestinationsResponse) => NormalizedDeliveryDestinations;
16
+ export declare const parseDeliveryDestinationsResponse: (input: unknown) => Either.Either<NormalizedDeliveryDestinations, DeliveryDestinationsResponseNormalizationError>;
17
+ export declare const parseDeliveryDestinationResponse: (input: unknown) => Either.Either<DeliveryDestination, DeliveryDestinationsResponseNormalizationError>;
18
+ export declare const makeDeliveryDestinationsDiagnostic: (destinations: NormalizedDeliveryDestinations) => DeliveryDestinationsDiagnostic;
19
+ export declare const parseDeliveryDestinationsDiagnostic: (input: unknown) => Either.Either<DeliveryDestinationsDiagnostic, DeliveryDestinationsResponseNormalizationError>;
20
+ export declare const getDeliveryDestinations: (session: SessionSnapshot, input: unknown, transport: VoilaTransport, cookieJarPort?: CookieJarPort) => Promise<Either.Either<GetDeliveryDestinationsResult, GetDeliveryDestinationsError>>;
21
+ export declare const getDeliveryDestination: (session: SessionSnapshot, input: unknown, transport: VoilaTransport, cookieJarPort?: CookieJarPort) => Promise<Either.Either<GetDeliveryDestinationResult, GetDeliveryDestinationError>>;
22
+ //# sourceMappingURL=delivery-destinations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"delivery-destinations.d.ts","sourceRoot":"","sources":["../../../src/voila/delivery-destinations.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAA;AAG/B,OAAO,EACL,KAAK,mBAAmB,EAExB,KAAK,8BAA8B,EAEnC,KAAK,8BAA8B,EAEnC,KAAK,sBAAsB,EAE3B,KAAK,+BAA+B,EAEpC,KAAK,eAAe,EACrB,MAAM,4BAA4B,CAAA;AACnC,OAAO,KAAK,EAAE,eAAe,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEtF,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAA;AAC1D,OAAO,KAAK,EAAE,+BAA+B,EAAE,gCAAgC,EAAE,MAAM,WAAW,CAAA;AAGlG,MAAM,MAAM,8CAA8C,GAAG;IAC3D,QAAQ,CAAC,IAAI,EAAE,4CAA4C,CAAA;IAC3D,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;CACzB,CAAA;AAED,MAAM,MAAM,4BAA4B,GAAG,gCAAgC,GAAG,aAAa,CAAA;AAE3F,MAAM,MAAM,6BAA6B,GAAG,eAAe,CAAC,8BAA8B,CAAC,CAAA;AAE3F,MAAM,MAAM,2BAA2B,GAAG,+BAA+B,GAAG,aAAa,CAAA;AAEzF,MAAM,MAAM,4BAA4B,GAAG,eAAe,CAAC,mBAAmB,CAAC,CAAA;AAS/E,eAAO,MAAM,4BAA4B,GACvC,aAAa,sBAAsB,KAClC,mBAgBF,CAAA;AAED,eAAO,MAAM,qCAAqC,GAChD,UAAU,+BAA+B,KACxC,8BAED,CAAA;AAEF,eAAO,MAAM,iCAAiC,GAC5C,OAAO,OAAO,KACb,MAAM,CAAC,MAAM,CAAC,8BAA8B,EAAE,8CAA8C,CAW5F,CAAA;AAEH,eAAO,MAAM,gCAAgC,GAC3C,OAAO,OAAO,KACb,MAAM,CAAC,MAAM,CAAC,mBAAmB,EAAE,8CAA8C,CAQjF,CAAA;AAgBH,eAAO,MAAM,kCAAkC,GAC7C,cAAc,8BAA8B,KAC3C,8BAGD,CAAA;AAEF,eAAO,MAAM,mCAAmC,GAC9C,OAAO,OAAO,KACb,MAAM,CAAC,MAAM,CAAC,8BAA8B,EAAE,8CAA8C,CAI5F,CAAA;AAEH,eAAO,MAAM,uBAAuB,GAClC,SAAS,eAAe,EACxB,OAAO,OAAO,EACd,WAAW,cAAc,EACzB,gBAAgB,aAAa,KAC5B,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,6BAA6B,EAAE,4BAA4B,CAAC,CAmBpF,CAAA;AAED,eAAO,MAAM,sBAAsB,GACjC,SAAS,eAAe,EACxB,OAAO,OAAO,EACd,WAAW,cAAc,EACzB,gBAAgB,aAAa,KAC5B,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,4BAA4B,EAAE,2BAA2B,CAAC,CAmBlF,CAAA"}
@@ -0,0 +1,70 @@
1
+ import { Either } from "effect";
2
+ import { parseUnknown } from "../domain/parse.js";
3
+ import { DeliveryDestinationSchema, DeliveryDestinationsDiagnosticSchema, NormalizedDeliveryDestinationsSchema, RawDeliveryDestinationSchema, RawDeliveryDestinationsResponseSchema } from "../domain/schemas/index.js";
4
+ import { requestVoilaJson } from "./http-client.js";
5
+ import { makeDeliveryDestinationRequest, makeDeliveryDestinationsRequest } from "./urls.js";
6
+ const deliverableValue = "DELIVERABLE";
7
+ const deliveryDestinationsResponseSchemaMismatch = () => ({
8
+ _tag: "DeliveryDestinationsResponseSchemaMismatch",
9
+ message: "Voila delivery destinations response does not match the SDK schema"
10
+ });
11
+ export const normalizeDeliveryDestination = (destination) => {
12
+ const regionId = destination.resolvedRegionId ?? destination.regionId;
13
+ return {
14
+ ...(destination.addressId === undefined ? {} : { addressId: destination.addressId }),
15
+ ...(destination.deliverability === undefined ? {} : { deliverability: destination.deliverability }),
16
+ deliverable: destination.deliverability === deliverableValue,
17
+ deliveryDestinationId: destination.deliveryDestinationId,
18
+ ...(destination.deliveryInstructions === undefined
19
+ ? {}
20
+ : { deliveryInstructions: destination.deliveryInstructions }),
21
+ ...(destination.deliveryMethod === undefined ? {} : { deliveryMethod: destination.deliveryMethod }),
22
+ ...(destination.formattedAddress === undefined ? {} : { formattedAddress: destination.formattedAddress }),
23
+ ...(destination.name === undefined ? {} : { nickname: destination.name }),
24
+ ...(regionId === undefined ? {} : { regionId })
25
+ };
26
+ };
27
+ export const normalizeDeliveryDestinationsResponse = (response) => ({
28
+ destinations: response.map(normalizeDeliveryDestination)
29
+ });
30
+ export const parseDeliveryDestinationsResponse = (input) => Either.flatMap(Either.mapLeft(parseUnknown(RawDeliveryDestinationsResponseSchema, input), deliveryDestinationsResponseSchemaMismatch), (response) => Either.mapLeft(parseUnknown(NormalizedDeliveryDestinationsSchema, normalizeDeliveryDestinationsResponse(response)), deliveryDestinationsResponseSchemaMismatch));
31
+ export const parseDeliveryDestinationResponse = (input) => Either.flatMap(Either.mapLeft(parseUnknown(RawDeliveryDestinationSchema, input), deliveryDestinationsResponseSchemaMismatch), (response) => Either.mapLeft(parseUnknown(DeliveryDestinationSchema, normalizeDeliveryDestination(response)), deliveryDestinationsResponseSchemaMismatch));
32
+ const redactDestinationForDiagnostic = (destination) => ({
33
+ ...(destination.addressId === undefined ? {} : { addressId: "[redacted]" }),
34
+ ...(destination.deliverability === undefined ? {} : { deliverability: destination.deliverability }),
35
+ deliverable: destination.deliverable,
36
+ deliveryDestinationId: "[redacted]",
37
+ ...(destination.deliveryInstructions === undefined ? {} : { deliveryInstructions: "[redacted]" }),
38
+ ...(destination.deliveryMethod === undefined ? {} : { deliveryMethod: destination.deliveryMethod }),
39
+ ...(destination.formattedAddress === undefined ? {} : { formattedAddress: "[redacted]" }),
40
+ ...(destination.nickname === undefined ? {} : { nickname: "[redacted]" }),
41
+ ...(destination.regionId === undefined ? {} : { regionId: "[redacted]" })
42
+ });
43
+ export const makeDeliveryDestinationsDiagnostic = (destinations) => ({
44
+ count: destinations.destinations.length,
45
+ destinations: destinations.destinations.map(redactDestinationForDiagnostic)
46
+ });
47
+ export const parseDeliveryDestinationsDiagnostic = (input) => Either.mapLeft(parseUnknown(DeliveryDestinationsDiagnosticSchema, input), deliveryDestinationsResponseSchemaMismatch);
48
+ export const getDeliveryDestinations = async (session, input, transport, cookieJarPort) => {
49
+ const request = makeDeliveryDestinationsRequest(input);
50
+ if (Either.isLeft(request)) {
51
+ return Either.left(request.left);
52
+ }
53
+ const response = await requestVoilaJson(RawDeliveryDestinationsResponseSchema, session, request.right, transport, cookieJarPort);
54
+ return Either.map(response, (result) => ({
55
+ session: result.session,
56
+ value: normalizeDeliveryDestinationsResponse(result.value)
57
+ }));
58
+ };
59
+ export const getDeliveryDestination = async (session, input, transport, cookieJarPort) => {
60
+ const request = makeDeliveryDestinationRequest(input);
61
+ if (Either.isLeft(request)) {
62
+ return Either.left(request.left);
63
+ }
64
+ const response = await requestVoilaJson(RawDeliveryDestinationSchema, session, request.right, transport, cookieJarPort);
65
+ return Either.map(response, (result) => ({
66
+ session: result.session,
67
+ value: normalizeDeliveryDestination(result.value)
68
+ }));
69
+ };
70
+ //# sourceMappingURL=delivery-destinations.js.map