ce-storefront 0.5.0 → 0.5.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 (144) hide show
  1. package/README.md +12 -11
  2. package/docs/sdks/carts/README.md +480 -5
  3. package/docs/sdks/customers/README.md +4 -0
  4. package/esm/funcs/cartsApplyCoupon.d.ts +16 -0
  5. package/esm/funcs/cartsApplyCoupon.d.ts.map +1 -0
  6. package/esm/funcs/{checkoutApplyCoupon.js → cartsApplyCoupon.js} +12 -6
  7. package/esm/funcs/cartsApplyCoupon.js.map +1 -0
  8. package/esm/funcs/{checkoutCreateCheckoutAddress.d.ts → cartsCreateCartAddress.d.ts} +2 -2
  9. package/esm/funcs/cartsCreateCartAddress.d.ts.map +1 -0
  10. package/esm/funcs/{checkoutCreateCheckoutAddress.js → cartsCreateCartAddress.js} +16 -12
  11. package/esm/funcs/cartsCreateCartAddress.js.map +1 -0
  12. package/esm/funcs/cartsDeleteCart.js +2 -2
  13. package/esm/funcs/cartsDeleteCart.js.map +1 -1
  14. package/esm/funcs/cartsGetCart.d.ts +1 -1
  15. package/esm/funcs/cartsGetCart.js +3 -3
  16. package/esm/funcs/cartsGetCart.js.map +1 -1
  17. package/esm/funcs/cartsGetUserCart.d.ts +16 -0
  18. package/esm/funcs/cartsGetUserCart.d.ts.map +1 -0
  19. package/esm/funcs/cartsGetUserCart.js +85 -0
  20. package/esm/funcs/cartsGetUserCart.js.map +1 -0
  21. package/esm/funcs/{checkoutRemoveCoupon.d.ts → cartsRemoveCoupon.d.ts} +2 -2
  22. package/esm/funcs/cartsRemoveCoupon.d.ts.map +1 -0
  23. package/esm/funcs/{checkoutRemoveCoupon.js → cartsRemoveCoupon.js} +12 -7
  24. package/esm/funcs/{checkoutRemoveCoupon.js.map → cartsRemoveCoupon.js.map} +1 -1
  25. package/esm/funcs/{checkoutApplyCoupon.d.ts → cartsRemoveUserCart.d.ts} +4 -4
  26. package/esm/funcs/{checkoutApplyCoupon.d.ts.map → cartsRemoveUserCart.d.ts.map} +1 -1
  27. package/esm/funcs/cartsRemoveUserCart.js +85 -0
  28. package/esm/funcs/cartsRemoveUserCart.js.map +1 -0
  29. package/esm/lib/config.d.ts +3 -3
  30. package/esm/lib/config.js +3 -3
  31. package/esm/models/components/cart.d.ts +4 -4
  32. package/esm/models/components/cart.d.ts.map +1 -1
  33. package/esm/models/components/cart.js +4 -4
  34. package/esm/models/components/cart.js.map +1 -1
  35. package/esm/models/components/cartitem.d.ts +0 -5
  36. package/esm/models/components/cartitem.d.ts.map +1 -1
  37. package/esm/models/components/cartitem.js +0 -2
  38. package/esm/models/components/cartitem.js.map +1 -1
  39. package/esm/models/components/customeraddress.d.ts +7 -4
  40. package/esm/models/components/customeraddress.d.ts.map +1 -1
  41. package/esm/models/components/customeraddress.js +4 -4
  42. package/esm/models/components/customeraddress.js.map +1 -1
  43. package/esm/models/components/customeraddressinput.d.ts +7 -2
  44. package/esm/models/components/customeraddressinput.d.ts.map +1 -1
  45. package/esm/models/components/customeraddressinput.js +4 -2
  46. package/esm/models/components/customeraddressinput.js.map +1 -1
  47. package/esm/models/operations/applycoupon.d.ts +30 -2
  48. package/esm/models/operations/applycoupon.d.ts.map +1 -1
  49. package/esm/models/operations/applycoupon.js +35 -4
  50. package/esm/models/operations/applycoupon.js.map +1 -1
  51. package/esm/models/operations/createaddress.d.ts +7 -2
  52. package/esm/models/operations/createaddress.d.ts.map +1 -1
  53. package/esm/models/operations/createaddress.js +4 -2
  54. package/esm/models/operations/createaddress.js.map +1 -1
  55. package/esm/models/operations/createcartaddress.d.ts +183 -0
  56. package/esm/models/operations/createcartaddress.d.ts.map +1 -0
  57. package/esm/models/operations/createcartaddress.js +214 -0
  58. package/esm/models/operations/createcartaddress.js.map +1 -0
  59. package/esm/models/operations/deletecart.d.ts +3 -3
  60. package/esm/models/operations/deletecart.d.ts.map +1 -1
  61. package/esm/models/operations/deletecart.js +2 -11
  62. package/esm/models/operations/deletecart.js.map +1 -1
  63. package/esm/models/operations/deleteusercart.d.ts +63 -0
  64. package/esm/models/operations/deleteusercart.d.ts.map +1 -0
  65. package/esm/models/operations/deleteusercart.js +77 -0
  66. package/esm/models/operations/deleteusercart.js.map +1 -0
  67. package/esm/models/operations/getaddressdetail.d.ts +7 -4
  68. package/esm/models/operations/getaddressdetail.d.ts.map +1 -1
  69. package/esm/models/operations/getaddressdetail.js +4 -4
  70. package/esm/models/operations/getaddressdetail.js.map +1 -1
  71. package/esm/models/operations/getcart.d.ts +3 -3
  72. package/esm/models/operations/getcart.d.ts.map +1 -1
  73. package/esm/models/operations/getcart.js +2 -11
  74. package/esm/models/operations/getcart.js.map +1 -1
  75. package/esm/models/operations/getusercart.d.ts +94 -0
  76. package/esm/models/operations/getusercart.d.ts.map +1 -0
  77. package/esm/models/operations/getusercart.js +105 -0
  78. package/esm/models/operations/getusercart.js.map +1 -0
  79. package/esm/models/operations/index.d.ts +3 -1
  80. package/esm/models/operations/index.d.ts.map +1 -1
  81. package/esm/models/operations/index.js +3 -1
  82. package/esm/models/operations/index.js.map +1 -1
  83. package/esm/models/operations/listaddresses.d.ts +7 -4
  84. package/esm/models/operations/listaddresses.d.ts.map +1 -1
  85. package/esm/models/operations/listaddresses.js +4 -4
  86. package/esm/models/operations/listaddresses.js.map +1 -1
  87. package/esm/models/operations/removecoupon.d.ts +18 -17
  88. package/esm/models/operations/removecoupon.d.ts.map +1 -1
  89. package/esm/models/operations/removecoupon.js +15 -28
  90. package/esm/models/operations/removecoupon.js.map +1 -1
  91. package/esm/models/operations/updateaddressdetail.d.ts +7 -2
  92. package/esm/models/operations/updateaddressdetail.d.ts.map +1 -1
  93. package/esm/models/operations/updateaddressdetail.js +4 -2
  94. package/esm/models/operations/updateaddressdetail.js.map +1 -1
  95. package/esm/sdk/carts.d.ts +36 -1
  96. package/esm/sdk/carts.d.ts.map +1 -1
  97. package/esm/sdk/carts.js +51 -1
  98. package/esm/sdk/carts.js.map +1 -1
  99. package/esm/sdk/sdk.d.ts +0 -3
  100. package/esm/sdk/sdk.d.ts.map +1 -1
  101. package/esm/sdk/sdk.js +0 -4
  102. package/esm/sdk/sdk.js.map +1 -1
  103. package/jsr.json +1 -1
  104. package/package.json +1 -1
  105. package/src/funcs/{checkoutApplyCoupon.ts → cartsApplyCoupon.ts} +13 -6
  106. package/src/funcs/{checkoutCreateCheckoutAddress.ts → cartsCreateCartAddress.ts} +19 -15
  107. package/src/funcs/cartsDeleteCart.ts +2 -2
  108. package/src/funcs/cartsGetCart.ts +3 -3
  109. package/src/funcs/cartsGetUserCart.ts +149 -0
  110. package/src/funcs/{checkoutRemoveCoupon.ts → cartsRemoveCoupon.ts} +13 -7
  111. package/src/funcs/cartsRemoveUserCart.ts +149 -0
  112. package/src/lib/config.ts +3 -3
  113. package/src/models/components/cart.ts +9 -9
  114. package/src/models/components/cartitem.ts +0 -7
  115. package/src/models/components/customeraddress.ts +11 -8
  116. package/src/models/components/customeraddressinput.ts +11 -4
  117. package/src/models/operations/applycoupon.ts +73 -6
  118. package/src/models/operations/createaddress.ts +11 -4
  119. package/src/models/operations/{createcheckoutaddress.ts → createcartaddress.ts} +152 -85
  120. package/src/models/operations/deletecart.ts +5 -14
  121. package/src/models/operations/deleteusercart.ts +154 -0
  122. package/src/models/operations/getaddressdetail.ts +11 -8
  123. package/src/models/operations/getcart.ts +5 -14
  124. package/src/models/operations/getusercart.ts +220 -0
  125. package/src/models/operations/index.ts +3 -1
  126. package/src/models/operations/listaddresses.ts +11 -8
  127. package/src/models/operations/removecoupon.ts +28 -40
  128. package/src/models/operations/updateaddressdetail.ts +11 -4
  129. package/src/sdk/carts.ts +91 -1
  130. package/src/sdk/sdk.ts +0 -6
  131. package/docs/sdks/checkout/README.md +0 -310
  132. package/esm/funcs/checkoutApplyCoupon.js.map +0 -1
  133. package/esm/funcs/checkoutCreateCheckoutAddress.d.ts.map +0 -1
  134. package/esm/funcs/checkoutCreateCheckoutAddress.js.map +0 -1
  135. package/esm/funcs/checkoutRemoveCoupon.d.ts.map +0 -1
  136. package/esm/models/operations/createcheckoutaddress.d.ts +0 -154
  137. package/esm/models/operations/createcheckoutaddress.d.ts.map +0 -1
  138. package/esm/models/operations/createcheckoutaddress.js +0 -181
  139. package/esm/models/operations/createcheckoutaddress.js.map +0 -1
  140. package/esm/sdk/checkout.d.ts +0 -26
  141. package/esm/sdk/checkout.d.ts.map +0 -1
  142. package/esm/sdk/checkout.js +0 -38
  143. package/esm/sdk/checkout.js.map +0 -1
  144. package/src/sdk/checkout.ts +0 -63
@@ -3,7 +3,7 @@
3
3
  */
4
4
 
5
5
  import { CeStorefrontCore } from "../core.js";
6
- import { encodeJSON } from "../lib/encodings.js";
6
+ import { encodeJSON, encodeSimple } from "../lib/encodings.js";
7
7
  import * as M from "../lib/matchers.js";
8
8
  import { compactMap } from "../lib/primitives.js";
9
9
  import { safeParse } from "../lib/schemas.js";
@@ -20,7 +20,7 @@ import {
20
20
  } from "../models/errors/httpclienterrors.js";
21
21
  import * as errors from "../models/errors/index.js";
22
22
  import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
23
- import { CreateCheckoutAddressServerList } from "../models/operations/createcheckoutaddress.js";
23
+ import { CreateCartAddressServerList } from "../models/operations/createcartaddress.js";
24
24
  import * as operations from "../models/operations/index.js";
25
25
  import { Result } from "../types/fp.js";
26
26
 
@@ -30,13 +30,13 @@ import { Result } from "../types/fp.js";
30
30
  * @remarks
31
31
  * Update billing and shipping address
32
32
  */
33
- export async function checkoutCreateCheckoutAddress(
33
+ export async function cartsCreateCartAddress(
34
34
  client: CeStorefrontCore,
35
- request: operations.CreateCheckoutAddressRequestBody,
35
+ request: operations.CreateCartAddressRequest,
36
36
  options?: RequestOptions,
37
37
  ): Promise<
38
38
  Result<
39
- operations.CreateCheckoutAddressResponseBody,
39
+ operations.CreateCartAddressResponseBody,
40
40
  | errors.BadRequest
41
41
  | errors.Unauthorized
42
42
  | errors.NotFound
@@ -51,24 +51,28 @@ export async function checkoutCreateCheckoutAddress(
51
51
  > {
52
52
  const parsed = safeParse(
53
53
  request,
54
- (value) =>
55
- operations.CreateCheckoutAddressRequestBody$outboundSchema.parse(value),
54
+ (value) => operations.CreateCartAddressRequest$outboundSchema.parse(value),
56
55
  "Input validation failed",
57
56
  );
58
57
  if (!parsed.ok) {
59
58
  return parsed;
60
59
  }
61
60
  const payload = parsed.value;
62
- const body = encodeJSON("body", payload, { explode: true });
61
+ const body = encodeJSON("body", payload.RequestBody, { explode: true });
63
62
 
64
63
  const baseURL = options?.serverURL
65
- || pathToFunc(CreateCheckoutAddressServerList[0], {
66
- charEncoding: "percent",
67
- })({
64
+ || pathToFunc(CreateCartAddressServerList[0], { charEncoding: "percent" })({
68
65
  store_id: "x2yh61zw4k",
69
66
  });
70
67
 
71
- const path = pathToFunc("/checkout/address")();
68
+ const pathParams = {
69
+ id: encodeSimple("id", payload.id, {
70
+ explode: false,
71
+ charEncoding: "percent",
72
+ }),
73
+ };
74
+
75
+ const path = pathToFunc("/carts/{id}/address")(pathParams);
72
76
 
73
77
  const headers = new Headers(compactMap({
74
78
  "Content-Type": "application/json",
@@ -80,7 +84,7 @@ export async function checkoutCreateCheckoutAddress(
80
84
  const requestSecurity = resolveGlobalSecurity(securityInput);
81
85
 
82
86
  const context = {
83
- operationID: "create-checkout-address",
87
+ operationID: "create-cart-address",
84
88
  oAuth2Scopes: [],
85
89
 
86
90
  resolvedSecurity: requestSecurity,
@@ -122,7 +126,7 @@ export async function checkoutCreateCheckoutAddress(
122
126
  };
123
127
 
124
128
  const [result] = await M.match<
125
- operations.CreateCheckoutAddressResponseBody,
129
+ operations.CreateCartAddressResponseBody,
126
130
  | errors.BadRequest
127
131
  | errors.Unauthorized
128
132
  | errors.NotFound
@@ -134,7 +138,7 @@ export async function checkoutCreateCheckoutAddress(
134
138
  | RequestTimeoutError
135
139
  | ConnectionError
136
140
  >(
137
- M.json(200, operations.CreateCheckoutAddressResponseBody$inboundSchema),
141
+ M.json(200, operations.CreateCartAddressResponseBody$inboundSchema),
138
142
  M.jsonErr(400, errors.BadRequest$inboundSchema),
139
143
  M.jsonErr(401, errors.Unauthorized$inboundSchema),
140
144
  M.jsonErr(404, errors.NotFound$inboundSchema),
@@ -65,13 +65,13 @@ export async function cartsDeleteCart(
65
65
  });
66
66
 
67
67
  const pathParams = {
68
- user_id: encodeSimple("user_id", payload.user_id, {
68
+ id: encodeSimple("id", payload.id, {
69
69
  explode: false,
70
70
  charEncoding: "percent",
71
71
  }),
72
72
  };
73
73
 
74
- const path = pathToFunc("/carts/{user_id}")(pathParams);
74
+ const path = pathToFunc("/carts/{id}")(pathParams);
75
75
 
76
76
  const headers = new Headers(compactMap({
77
77
  Accept: "application/json",
@@ -25,7 +25,7 @@ import * as operations from "../models/operations/index.js";
25
25
  import { Result } from "../types/fp.js";
26
26
 
27
27
  /**
28
- * Retrieve cart details
28
+ * Retrieve cart detail
29
29
  *
30
30
  * @remarks
31
31
  * Retrieve cart detail
@@ -65,13 +65,13 @@ export async function cartsGetCart(
65
65
  });
66
66
 
67
67
  const pathParams = {
68
- user_id: encodeSimple("user_id", payload.user_id, {
68
+ id: encodeSimple("id", payload.id, {
69
69
  explode: false,
70
70
  charEncoding: "percent",
71
71
  }),
72
72
  };
73
73
 
74
- const path = pathToFunc("/carts/{user_id}")(pathParams);
74
+ const path = pathToFunc("/carts/{id}")(pathParams);
75
75
 
76
76
  const headers = new Headers(compactMap({
77
77
  Accept: "application/json",
@@ -0,0 +1,149 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { CeStorefrontCore } from "../core.js";
6
+ import { encodeSimple } from "../lib/encodings.js";
7
+ import * as M from "../lib/matchers.js";
8
+ import { compactMap } from "../lib/primitives.js";
9
+ import { safeParse } from "../lib/schemas.js";
10
+ import { RequestOptions } from "../lib/sdks.js";
11
+ import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
12
+ import { pathToFunc } from "../lib/url.js";
13
+ import { CeError } from "../models/errors/ceerror.js";
14
+ import {
15
+ ConnectionError,
16
+ InvalidRequestError,
17
+ RequestAbortedError,
18
+ RequestTimeoutError,
19
+ UnexpectedClientError,
20
+ } from "../models/errors/httpclienterrors.js";
21
+ import * as errors from "../models/errors/index.js";
22
+ import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
23
+ import { GetUserCartServerList } from "../models/operations/getusercart.js";
24
+ import * as operations from "../models/operations/index.js";
25
+ import { Result } from "../types/fp.js";
26
+
27
+ /**
28
+ * Retrieve cart using user id
29
+ *
30
+ * @remarks
31
+ * Retrieve cart detail using user id
32
+ */
33
+ export async function cartsGetUserCart(
34
+ client: CeStorefrontCore,
35
+ request: operations.GetUserCartRequest,
36
+ options?: RequestOptions,
37
+ ): Promise<
38
+ Result<
39
+ operations.GetUserCartResponseBody,
40
+ | errors.Unauthorized
41
+ | errors.NotFound
42
+ | CeError
43
+ | SDKValidationError
44
+ | UnexpectedClientError
45
+ | InvalidRequestError
46
+ | RequestAbortedError
47
+ | RequestTimeoutError
48
+ | ConnectionError
49
+ >
50
+ > {
51
+ const parsed = safeParse(
52
+ request,
53
+ (value) => operations.GetUserCartRequest$outboundSchema.parse(value),
54
+ "Input validation failed",
55
+ );
56
+ if (!parsed.ok) {
57
+ return parsed;
58
+ }
59
+ const payload = parsed.value;
60
+ const body = null;
61
+
62
+ const baseURL = options?.serverURL
63
+ || pathToFunc(GetUserCartServerList[0], { charEncoding: "percent" })({
64
+ store_id: "x2yh61zw4k",
65
+ });
66
+
67
+ const pathParams = {
68
+ user_id: encodeSimple("user_id", payload.user_id, {
69
+ explode: false,
70
+ charEncoding: "percent",
71
+ }),
72
+ };
73
+
74
+ const path = pathToFunc("/carts/users/{user_id}")(pathParams);
75
+
76
+ const headers = new Headers(compactMap({
77
+ Accept: "application/json",
78
+ }));
79
+
80
+ const secConfig = await extractSecurity(client._options.authorization);
81
+ const securityInput = secConfig == null ? {} : { authorization: secConfig };
82
+ const requestSecurity = resolveGlobalSecurity(securityInput);
83
+
84
+ const context = {
85
+ operationID: "get-user-cart",
86
+ oAuth2Scopes: [],
87
+
88
+ resolvedSecurity: requestSecurity,
89
+
90
+ securitySource: client._options.authorization,
91
+ retryConfig: options?.retries
92
+ || client._options.retryConfig
93
+ || { strategy: "none" },
94
+ retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
95
+ };
96
+
97
+ const requestRes = client._createRequest(context, {
98
+ security: requestSecurity,
99
+ method: "GET",
100
+ baseURL: baseURL,
101
+ path: path,
102
+ headers: headers,
103
+ body: body,
104
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
105
+ }, options);
106
+ if (!requestRes.ok) {
107
+ return requestRes;
108
+ }
109
+ const req = requestRes.value;
110
+
111
+ const doResult = await client._do(req, {
112
+ context,
113
+ errorCodes: ["401", "404", "4XX", "5XX"],
114
+ retryConfig: context.retryConfig,
115
+ retryCodes: context.retryCodes,
116
+ });
117
+ if (!doResult.ok) {
118
+ return doResult;
119
+ }
120
+ const response = doResult.value;
121
+
122
+ const responseFields = {
123
+ HttpMeta: { Response: response, Request: req },
124
+ };
125
+
126
+ const [result] = await M.match<
127
+ operations.GetUserCartResponseBody,
128
+ | errors.Unauthorized
129
+ | errors.NotFound
130
+ | CeError
131
+ | SDKValidationError
132
+ | UnexpectedClientError
133
+ | InvalidRequestError
134
+ | RequestAbortedError
135
+ | RequestTimeoutError
136
+ | ConnectionError
137
+ >(
138
+ M.json(200, operations.GetUserCartResponseBody$inboundSchema),
139
+ M.jsonErr(401, errors.Unauthorized$inboundSchema),
140
+ M.jsonErr(404, errors.NotFound$inboundSchema),
141
+ M.fail("4XX"),
142
+ M.fail("5XX"),
143
+ )(response, { extraFields: responseFields });
144
+ if (!result.ok) {
145
+ return result;
146
+ }
147
+
148
+ return result;
149
+ }
@@ -3,7 +3,7 @@
3
3
  */
4
4
 
5
5
  import { CeStorefrontCore } from "../core.js";
6
- import { encodeJSON } from "../lib/encodings.js";
6
+ import { encodeSimple } from "../lib/encodings.js";
7
7
  import * as M from "../lib/matchers.js";
8
8
  import { compactMap } from "../lib/primitives.js";
9
9
  import { safeParse } from "../lib/schemas.js";
@@ -30,9 +30,9 @@ import { Result } from "../types/fp.js";
30
30
  * @remarks
31
31
  * remove coupon from cart
32
32
  */
33
- export async function checkoutRemoveCoupon(
33
+ export async function cartsRemoveCoupon(
34
34
  client: CeStorefrontCore,
35
- request: operations.RemoveCouponRequestBody,
35
+ request: operations.RemoveCouponRequest,
36
36
  options?: RequestOptions,
37
37
  ): Promise<
38
38
  Result<
@@ -50,24 +50,30 @@ export async function checkoutRemoveCoupon(
50
50
  > {
51
51
  const parsed = safeParse(
52
52
  request,
53
- (value) => operations.RemoveCouponRequestBody$outboundSchema.parse(value),
53
+ (value) => operations.RemoveCouponRequest$outboundSchema.parse(value),
54
54
  "Input validation failed",
55
55
  );
56
56
  if (!parsed.ok) {
57
57
  return parsed;
58
58
  }
59
59
  const payload = parsed.value;
60
- const body = encodeJSON("body", payload, { explode: true });
60
+ const body = null;
61
61
 
62
62
  const baseURL = options?.serverURL
63
63
  || pathToFunc(RemoveCouponServerList[0], { charEncoding: "percent" })({
64
64
  store_id: "x2yh61zw4k",
65
65
  });
66
66
 
67
- const path = pathToFunc("/checkout/coupon")();
67
+ const pathParams = {
68
+ id: encodeSimple("id", payload.id, {
69
+ explode: false,
70
+ charEncoding: "percent",
71
+ }),
72
+ };
73
+
74
+ const path = pathToFunc("/carts/{id}/coupon")(pathParams);
68
75
 
69
76
  const headers = new Headers(compactMap({
70
- "Content-Type": "application/json",
71
77
  Accept: "application/json",
72
78
  }));
73
79
 
@@ -0,0 +1,149 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { CeStorefrontCore } from "../core.js";
6
+ import { encodeSimple } from "../lib/encodings.js";
7
+ import * as M from "../lib/matchers.js";
8
+ import { compactMap } from "../lib/primitives.js";
9
+ import { safeParse } from "../lib/schemas.js";
10
+ import { RequestOptions } from "../lib/sdks.js";
11
+ import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
12
+ import { pathToFunc } from "../lib/url.js";
13
+ import { CeError } from "../models/errors/ceerror.js";
14
+ import {
15
+ ConnectionError,
16
+ InvalidRequestError,
17
+ RequestAbortedError,
18
+ RequestTimeoutError,
19
+ UnexpectedClientError,
20
+ } from "../models/errors/httpclienterrors.js";
21
+ import * as errors from "../models/errors/index.js";
22
+ import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
23
+ import { DeleteUserCartServerList } from "../models/operations/deleteusercart.js";
24
+ import * as operations from "../models/operations/index.js";
25
+ import { Result } from "../types/fp.js";
26
+
27
+ /**
28
+ * Delete cart using user id
29
+ *
30
+ * @remarks
31
+ * delete all items from the cart using user id.
32
+ */
33
+ export async function cartsRemoveUserCart(
34
+ client: CeStorefrontCore,
35
+ request: operations.DeleteUserCartRequest,
36
+ options?: RequestOptions,
37
+ ): Promise<
38
+ Result<
39
+ operations.DeleteUserCartResponseBody,
40
+ | errors.Unauthorized
41
+ | errors.NotFound
42
+ | CeError
43
+ | SDKValidationError
44
+ | UnexpectedClientError
45
+ | InvalidRequestError
46
+ | RequestAbortedError
47
+ | RequestTimeoutError
48
+ | ConnectionError
49
+ >
50
+ > {
51
+ const parsed = safeParse(
52
+ request,
53
+ (value) => operations.DeleteUserCartRequest$outboundSchema.parse(value),
54
+ "Input validation failed",
55
+ );
56
+ if (!parsed.ok) {
57
+ return parsed;
58
+ }
59
+ const payload = parsed.value;
60
+ const body = null;
61
+
62
+ const baseURL = options?.serverURL
63
+ || pathToFunc(DeleteUserCartServerList[0], { charEncoding: "percent" })({
64
+ store_id: "x2yh61zw4k",
65
+ });
66
+
67
+ const pathParams = {
68
+ user_id: encodeSimple("user_id", payload.user_id, {
69
+ explode: false,
70
+ charEncoding: "percent",
71
+ }),
72
+ };
73
+
74
+ const path = pathToFunc("/carts/users/{user_id}")(pathParams);
75
+
76
+ const headers = new Headers(compactMap({
77
+ Accept: "application/json",
78
+ }));
79
+
80
+ const secConfig = await extractSecurity(client._options.authorization);
81
+ const securityInput = secConfig == null ? {} : { authorization: secConfig };
82
+ const requestSecurity = resolveGlobalSecurity(securityInput);
83
+
84
+ const context = {
85
+ operationID: "delete-user-cart",
86
+ oAuth2Scopes: [],
87
+
88
+ resolvedSecurity: requestSecurity,
89
+
90
+ securitySource: client._options.authorization,
91
+ retryConfig: options?.retries
92
+ || client._options.retryConfig
93
+ || { strategy: "none" },
94
+ retryCodes: options?.retryCodes || ["429", "500", "502", "503", "504"],
95
+ };
96
+
97
+ const requestRes = client._createRequest(context, {
98
+ security: requestSecurity,
99
+ method: "DELETE",
100
+ baseURL: baseURL,
101
+ path: path,
102
+ headers: headers,
103
+ body: body,
104
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
105
+ }, options);
106
+ if (!requestRes.ok) {
107
+ return requestRes;
108
+ }
109
+ const req = requestRes.value;
110
+
111
+ const doResult = await client._do(req, {
112
+ context,
113
+ errorCodes: ["401", "404", "4XX", "5XX"],
114
+ retryConfig: context.retryConfig,
115
+ retryCodes: context.retryCodes,
116
+ });
117
+ if (!doResult.ok) {
118
+ return doResult;
119
+ }
120
+ const response = doResult.value;
121
+
122
+ const responseFields = {
123
+ HttpMeta: { Response: response, Request: req },
124
+ };
125
+
126
+ const [result] = await M.match<
127
+ operations.DeleteUserCartResponseBody,
128
+ | errors.Unauthorized
129
+ | errors.NotFound
130
+ | CeError
131
+ | SDKValidationError
132
+ | UnexpectedClientError
133
+ | InvalidRequestError
134
+ | RequestAbortedError
135
+ | RequestTimeoutError
136
+ | ConnectionError
137
+ >(
138
+ M.json(200, operations.DeleteUserCartResponseBody$inboundSchema),
139
+ M.jsonErr(401, errors.Unauthorized$inboundSchema),
140
+ M.jsonErr(404, errors.NotFound$inboundSchema),
141
+ M.fail("4XX"),
142
+ M.fail("5XX"),
143
+ )(response, { extraFields: responseFields });
144
+ if (!result.ok) {
145
+ return result;
146
+ }
147
+
148
+ return result;
149
+ }
package/src/lib/config.ts CHANGED
@@ -74,7 +74,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null {
74
74
  export const SDK_METADATA = {
75
75
  language: "typescript",
76
76
  openapiDocVersion: "1.0",
77
- sdkVersion: "0.5.0",
78
- genVersion: "2.499.1",
79
- userAgent: "speakeasy-sdk/typescript 0.5.0 2.499.1 1.0 ce-storefront",
77
+ sdkVersion: "0.5.2",
78
+ genVersion: "2.500.5",
79
+ userAgent: "speakeasy-sdk/typescript 0.5.2 2.500.5 1.0 ce-storefront",
80
80
  } as const;
@@ -132,13 +132,13 @@ export type Cart = {
132
132
  /**
133
133
  * Additional metadata associated with the cart. The example includes an empty object in the list.
134
134
  */
135
- metadata: { [k: string]: string };
135
+ metadata: { [k: string]: string } | null;
136
136
  /**
137
137
  * the expiration timestamp of the shopping cart. .
138
138
  *
139
139
  * @remarks
140
140
  */
141
- expiresAt: Date;
141
+ expiresAt: Date | null;
142
142
  };
143
143
 
144
144
  /** @internal */
@@ -171,9 +171,9 @@ export const Cart$inboundSchema: z.ZodType<Cart, z.ZodTypeDef, unknown> = z
171
171
  billing_address: z.nullable(CustomerAddress$inboundSchema),
172
172
  shipping_address: z.nullable(CustomerAddress$inboundSchema),
173
173
  currency: Currency$inboundSchema,
174
- metadata: z.record(z.string()),
175
- expires_at: z.string().datetime({ offset: true }).transform(v =>
176
- new Date(v)
174
+ metadata: z.nullable(z.record(z.string())),
175
+ expires_at: z.nullable(
176
+ z.string().datetime({ offset: true }).transform(v => new Date(v)),
177
177
  ),
178
178
  }).transform((v) => {
179
179
  return remap$(v, {
@@ -233,8 +233,8 @@ export type Cart$Outbound = {
233
233
  billing_address: CustomerAddress$Outbound | null;
234
234
  shipping_address: CustomerAddress$Outbound | null;
235
235
  currency: Currency$Outbound;
236
- metadata: { [k: string]: string };
237
- expires_at: string;
236
+ metadata: { [k: string]: string } | null;
237
+ expires_at: string | null;
238
238
  };
239
239
 
240
240
  /** @internal */
@@ -267,8 +267,8 @@ export const Cart$outboundSchema: z.ZodType<Cart$Outbound, z.ZodTypeDef, Cart> =
267
267
  billingAddress: z.nullable(CustomerAddress$outboundSchema),
268
268
  shippingAddress: z.nullable(CustomerAddress$outboundSchema),
269
269
  currency: Currency$outboundSchema,
270
- metadata: z.record(z.string()),
271
- expiresAt: z.date().transform(v => v.toISOString()),
270
+ metadata: z.nullable(z.record(z.string())),
271
+ expiresAt: z.nullable(z.date().transform(v => v.toISOString())),
272
272
  }).transform((v) => {
273
273
  return remap$(v, {
274
274
  customerEmail: "customer_email",
@@ -61,10 +61,6 @@ export type CartItem = {
61
61
  * URL pointing to the product image.
62
62
  */
63
63
  productImageUrl: string;
64
- /**
65
- * Indicates whether the product is currently active.
66
- */
67
- active: boolean;
68
64
  /**
69
65
  * Indicates whether the product is currently in stock.
70
66
  */
@@ -163,7 +159,6 @@ export const CartItem$inboundSchema: z.ZodType<
163
159
  variant_name: z.nullable(z.string()),
164
160
  product_type: CartItemProductType$inboundSchema,
165
161
  product_image_url: z.string(),
166
- active: z.boolean(),
167
162
  stock_available: z.boolean(),
168
163
  on_offer: z.boolean(),
169
164
  on_subscription: z.boolean(),
@@ -227,7 +222,6 @@ export type CartItem$Outbound = {
227
222
  variant_name: string | null;
228
223
  product_type: string;
229
224
  product_image_url: string;
230
- active: boolean;
231
225
  stock_available: boolean;
232
226
  on_offer: boolean;
233
227
  on_subscription: boolean;
@@ -266,7 +260,6 @@ export const CartItem$outboundSchema: z.ZodType<
266
260
  variantName: z.nullable(z.string()),
267
261
  productType: CartItemProductType$outboundSchema,
268
262
  productImageUrl: z.string(),
269
- active: z.boolean(),
270
263
  stockAvailable: z.boolean(),
271
264
  onOffer: z.boolean(),
272
265
  onSubscription: z.boolean(),
@@ -9,9 +9,12 @@ import { Result as SafeParseResult } from "../../types/fp.js";
9
9
  import { SDKValidationError } from "../errors/sdkvalidationerror.js";
10
10
 
11
11
  export type CustomerAddress = {
12
- id: string;
12
+ /**
13
+ * null value for guest checkout.
14
+ */
15
+ id: string | null;
13
16
  firstName: string;
14
- lastName: string;
17
+ lastName: string | null;
15
18
  /**
16
19
  * Two-letter code begin with a plus sign prefix that identifies different countries. By default it will be +91 if not provided.
17
20
  *
@@ -48,9 +51,9 @@ export const CustomerAddress$inboundSchema: z.ZodType<
48
51
  z.ZodTypeDef,
49
52
  unknown
50
53
  > = z.object({
51
- id: z.string(),
54
+ id: z.nullable(z.string()),
52
55
  first_name: z.string(),
53
- last_name: z.string(),
56
+ last_name: z.nullable(z.string()),
54
57
  country_code: z.string(),
55
58
  phone: z.string(),
56
59
  email: z.string(),
@@ -81,9 +84,9 @@ export const CustomerAddress$inboundSchema: z.ZodType<
81
84
 
82
85
  /** @internal */
83
86
  export type CustomerAddress$Outbound = {
84
- id: string;
87
+ id: string | null;
85
88
  first_name: string;
86
- last_name: string;
89
+ last_name: string | null;
87
90
  country_code: string;
88
91
  phone: string;
89
92
  email: string;
@@ -106,9 +109,9 @@ export const CustomerAddress$outboundSchema: z.ZodType<
106
109
  z.ZodTypeDef,
107
110
  CustomerAddress
108
111
  > = z.object({
109
- id: z.string(),
112
+ id: z.nullable(z.string()),
110
113
  firstName: z.string(),
111
- lastName: z.string(),
114
+ lastName: z.nullable(z.string()),
112
115
  countryCode: z.string(),
113
116
  phone: z.string(),
114
117
  email: z.string(),
@@ -9,8 +9,12 @@ import { Result as SafeParseResult } from "../../types/fp.js";
9
9
  import { SDKValidationError } from "../errors/sdkvalidationerror.js";
10
10
 
11
11
  export type CustomerAddressInput = {
12
+ /**
13
+ * null value for guest checkout.
14
+ */
15
+ id: string | null;
12
16
  firstName: string;
13
- lastName: string;
17
+ lastName: string | null;
14
18
  /**
15
19
  * Two-letter code begin with a plus sign prefix that identifies different countries. By default it will be +91 if not provided.
16
20
  *
@@ -45,8 +49,9 @@ export const CustomerAddressInput$inboundSchema: z.ZodType<
45
49
  z.ZodTypeDef,
46
50
  unknown
47
51
  > = z.object({
52
+ id: z.nullable(z.string()),
48
53
  first_name: z.string(),
49
- last_name: z.string(),
54
+ last_name: z.nullable(z.string()),
50
55
  country_code: z.string(),
51
56
  phone: z.string(),
52
57
  email: z.string(),
@@ -73,8 +78,9 @@ export const CustomerAddressInput$inboundSchema: z.ZodType<
73
78
 
74
79
  /** @internal */
75
80
  export type CustomerAddressInput$Outbound = {
81
+ id: string | null;
76
82
  first_name: string;
77
- last_name: string;
83
+ last_name: string | null;
78
84
  country_code: string;
79
85
  phone: string;
80
86
  email: string;
@@ -95,8 +101,9 @@ export const CustomerAddressInput$outboundSchema: z.ZodType<
95
101
  z.ZodTypeDef,
96
102
  CustomerAddressInput
97
103
  > = z.object({
104
+ id: z.nullable(z.string()),
98
105
  firstName: z.string(),
99
- lastName: z.string(),
106
+ lastName: z.nullable(z.string()),
100
107
  countryCode: z.string(),
101
108
  phone: z.string(),
102
109
  email: z.string(),