ce-storefront 0.12.0 → 0.12.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 (63) hide show
  1. package/docs/sdks/carts/README.md +1 -0
  2. package/docs/sdks/shipping/README.md +1 -1
  3. package/esm/funcs/cartsApplyCoupon.d.ts +1 -1
  4. package/esm/funcs/cartsApplyCoupon.d.ts.map +1 -1
  5. package/esm/funcs/cartsApplyCoupon.js +2 -2
  6. package/esm/funcs/cartsApplyCoupon.js.map +1 -1
  7. package/esm/funcs/shippingCheckServiceability.d.ts +1 -1
  8. package/esm/funcs/shippingCheckServiceability.js +1 -1
  9. package/esm/lib/config.d.ts +2 -2
  10. package/esm/lib/config.js +2 -2
  11. package/esm/models/components/cartbasedserviceabilitycheck.d.ts +31 -0
  12. package/esm/models/components/cartbasedserviceabilitycheck.d.ts.map +1 -0
  13. package/esm/models/components/cartbasedserviceabilitycheck.js +44 -0
  14. package/esm/models/components/cartbasedserviceabilitycheck.js.map +1 -0
  15. package/esm/models/components/index.d.ts +2 -0
  16. package/esm/models/components/index.d.ts.map +1 -1
  17. package/esm/models/components/index.js +2 -0
  18. package/esm/models/components/index.js.map +1 -1
  19. package/esm/models/components/order.d.ts +4 -4
  20. package/esm/models/components/order.d.ts.map +1 -1
  21. package/esm/models/components/order.js +8 -8
  22. package/esm/models/components/order.js.map +1 -1
  23. package/esm/models/components/orderdetail.d.ts +4 -4
  24. package/esm/models/components/orderdetail.d.ts.map +1 -1
  25. package/esm/models/components/orderdetail.js +8 -8
  26. package/esm/models/components/orderdetail.js.map +1 -1
  27. package/esm/models/components/productsbasedserviceabilitycheck.d.ts +95 -0
  28. package/esm/models/components/productsbasedserviceabilitycheck.d.ts.map +1 -0
  29. package/esm/models/components/productsbasedserviceabilitycheck.js +132 -0
  30. package/esm/models/components/productsbasedserviceabilitycheck.js.map +1 -0
  31. package/esm/models/errors/badrequest.d.ts +8 -8
  32. package/esm/models/errors/badrequest.d.ts.map +1 -1
  33. package/esm/models/errors/badrequest.js +8 -10
  34. package/esm/models/errors/badrequest.js.map +1 -1
  35. package/esm/models/errors/notfound.d.ts +8 -8
  36. package/esm/models/errors/notfound.d.ts.map +1 -1
  37. package/esm/models/errors/notfound.js +8 -10
  38. package/esm/models/errors/notfound.js.map +1 -1
  39. package/esm/models/errors/unauthorized.d.ts +5 -5
  40. package/esm/models/errors/unauthorized.d.ts.map +1 -1
  41. package/esm/models/errors/unauthorized.js +5 -6
  42. package/esm/models/errors/unauthorized.js.map +1 -1
  43. package/esm/models/operations/shippingmethods.d.ts +2 -8
  44. package/esm/models/operations/shippingmethods.d.ts.map +1 -1
  45. package/esm/models/operations/shippingmethods.js +8 -19
  46. package/esm/models/operations/shippingmethods.js.map +1 -1
  47. package/esm/sdk/shipping.d.ts +1 -1
  48. package/esm/sdk/shipping.js +1 -1
  49. package/jsr.json +1 -1
  50. package/package.json +1 -1
  51. package/src/funcs/cartsApplyCoupon.ts +5 -1
  52. package/src/funcs/shippingCheckServiceability.ts +1 -1
  53. package/src/lib/config.ts +2 -2
  54. package/src/models/components/cartbasedserviceabilitycheck.ts +83 -0
  55. package/src/models/components/index.ts +2 -0
  56. package/src/models/components/order.ts +12 -12
  57. package/src/models/components/orderdetail.ts +12 -12
  58. package/src/models/components/productsbasedserviceabilitycheck.ts +243 -0
  59. package/src/models/errors/badrequest.ts +16 -16
  60. package/src/models/errors/notfound.ts +16 -16
  61. package/src/models/errors/unauthorized.ts +10 -10
  62. package/src/models/operations/shippingmethods.ts +14 -27
  63. package/src/sdk/shipping.ts +1 -1
@@ -0,0 +1,243 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod";
6
+ import { remap as remap$ } from "../../lib/primitives.js";
7
+ import { safeParse } from "../../lib/schemas.js";
8
+ import { Result as SafeParseResult } from "../../types/fp.js";
9
+ import { SDKValidationError } from "../errors/sdkvalidationerror.js";
10
+
11
+ export type Packaging = {
12
+ packWidth: number;
13
+ packHeight: number;
14
+ packLength: number;
15
+ packDryWeight: number;
16
+ };
17
+
18
+ export type Products = {
19
+ productId: string;
20
+ variantId: string | null;
21
+ quantity: number;
22
+ packaging: Packaging;
23
+ };
24
+
25
+ export type ProductsBasedServiceabilityCheck = {
26
+ pickupPincode: string;
27
+ deliveryPincode: string;
28
+ products: Array<Products>;
29
+ };
30
+
31
+ /** @internal */
32
+ export const Packaging$inboundSchema: z.ZodType<
33
+ Packaging,
34
+ z.ZodTypeDef,
35
+ unknown
36
+ > = z.object({
37
+ pack_width: z.number(),
38
+ pack_height: z.number(),
39
+ pack_length: z.number(),
40
+ pack_dry_weight: z.number(),
41
+ }).transform((v) => {
42
+ return remap$(v, {
43
+ "pack_width": "packWidth",
44
+ "pack_height": "packHeight",
45
+ "pack_length": "packLength",
46
+ "pack_dry_weight": "packDryWeight",
47
+ });
48
+ });
49
+
50
+ /** @internal */
51
+ export type Packaging$Outbound = {
52
+ pack_width: number;
53
+ pack_height: number;
54
+ pack_length: number;
55
+ pack_dry_weight: number;
56
+ };
57
+
58
+ /** @internal */
59
+ export const Packaging$outboundSchema: z.ZodType<
60
+ Packaging$Outbound,
61
+ z.ZodTypeDef,
62
+ Packaging
63
+ > = z.object({
64
+ packWidth: z.number(),
65
+ packHeight: z.number(),
66
+ packLength: z.number(),
67
+ packDryWeight: z.number(),
68
+ }).transform((v) => {
69
+ return remap$(v, {
70
+ packWidth: "pack_width",
71
+ packHeight: "pack_height",
72
+ packLength: "pack_length",
73
+ packDryWeight: "pack_dry_weight",
74
+ });
75
+ });
76
+
77
+ /**
78
+ * @internal
79
+ * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
80
+ */
81
+ export namespace Packaging$ {
82
+ /** @deprecated use `Packaging$inboundSchema` instead. */
83
+ export const inboundSchema = Packaging$inboundSchema;
84
+ /** @deprecated use `Packaging$outboundSchema` instead. */
85
+ export const outboundSchema = Packaging$outboundSchema;
86
+ /** @deprecated use `Packaging$Outbound` instead. */
87
+ export type Outbound = Packaging$Outbound;
88
+ }
89
+
90
+ export function packagingToJSON(packaging: Packaging): string {
91
+ return JSON.stringify(Packaging$outboundSchema.parse(packaging));
92
+ }
93
+
94
+ export function packagingFromJSON(
95
+ jsonString: string,
96
+ ): SafeParseResult<Packaging, SDKValidationError> {
97
+ return safeParse(
98
+ jsonString,
99
+ (x) => Packaging$inboundSchema.parse(JSON.parse(x)),
100
+ `Failed to parse 'Packaging' from JSON`,
101
+ );
102
+ }
103
+
104
+ /** @internal */
105
+ export const Products$inboundSchema: z.ZodType<
106
+ Products,
107
+ z.ZodTypeDef,
108
+ unknown
109
+ > = z.object({
110
+ product_id: z.string(),
111
+ variant_id: z.nullable(z.string()),
112
+ quantity: z.number().int(),
113
+ packaging: z.lazy(() => Packaging$inboundSchema),
114
+ }).transform((v) => {
115
+ return remap$(v, {
116
+ "product_id": "productId",
117
+ "variant_id": "variantId",
118
+ });
119
+ });
120
+
121
+ /** @internal */
122
+ export type Products$Outbound = {
123
+ product_id: string;
124
+ variant_id: string | null;
125
+ quantity: number;
126
+ packaging: Packaging$Outbound;
127
+ };
128
+
129
+ /** @internal */
130
+ export const Products$outboundSchema: z.ZodType<
131
+ Products$Outbound,
132
+ z.ZodTypeDef,
133
+ Products
134
+ > = z.object({
135
+ productId: z.string(),
136
+ variantId: z.nullable(z.string()),
137
+ quantity: z.number().int(),
138
+ packaging: z.lazy(() => Packaging$outboundSchema),
139
+ }).transform((v) => {
140
+ return remap$(v, {
141
+ productId: "product_id",
142
+ variantId: "variant_id",
143
+ });
144
+ });
145
+
146
+ /**
147
+ * @internal
148
+ * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
149
+ */
150
+ export namespace Products$ {
151
+ /** @deprecated use `Products$inboundSchema` instead. */
152
+ export const inboundSchema = Products$inboundSchema;
153
+ /** @deprecated use `Products$outboundSchema` instead. */
154
+ export const outboundSchema = Products$outboundSchema;
155
+ /** @deprecated use `Products$Outbound` instead. */
156
+ export type Outbound = Products$Outbound;
157
+ }
158
+
159
+ export function productsToJSON(products: Products): string {
160
+ return JSON.stringify(Products$outboundSchema.parse(products));
161
+ }
162
+
163
+ export function productsFromJSON(
164
+ jsonString: string,
165
+ ): SafeParseResult<Products, SDKValidationError> {
166
+ return safeParse(
167
+ jsonString,
168
+ (x) => Products$inboundSchema.parse(JSON.parse(x)),
169
+ `Failed to parse 'Products' from JSON`,
170
+ );
171
+ }
172
+
173
+ /** @internal */
174
+ export const ProductsBasedServiceabilityCheck$inboundSchema: z.ZodType<
175
+ ProductsBasedServiceabilityCheck,
176
+ z.ZodTypeDef,
177
+ unknown
178
+ > = z.object({
179
+ pickup_pincode: z.string(),
180
+ delivery_pincode: z.string(),
181
+ products: z.array(z.lazy(() => Products$inboundSchema)),
182
+ }).transform((v) => {
183
+ return remap$(v, {
184
+ "pickup_pincode": "pickupPincode",
185
+ "delivery_pincode": "deliveryPincode",
186
+ });
187
+ });
188
+
189
+ /** @internal */
190
+ export type ProductsBasedServiceabilityCheck$Outbound = {
191
+ pickup_pincode: string;
192
+ delivery_pincode: string;
193
+ products: Array<Products$Outbound>;
194
+ };
195
+
196
+ /** @internal */
197
+ export const ProductsBasedServiceabilityCheck$outboundSchema: z.ZodType<
198
+ ProductsBasedServiceabilityCheck$Outbound,
199
+ z.ZodTypeDef,
200
+ ProductsBasedServiceabilityCheck
201
+ > = z.object({
202
+ pickupPincode: z.string(),
203
+ deliveryPincode: z.string(),
204
+ products: z.array(z.lazy(() => Products$outboundSchema)),
205
+ }).transform((v) => {
206
+ return remap$(v, {
207
+ pickupPincode: "pickup_pincode",
208
+ deliveryPincode: "delivery_pincode",
209
+ });
210
+ });
211
+
212
+ /**
213
+ * @internal
214
+ * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
215
+ */
216
+ export namespace ProductsBasedServiceabilityCheck$ {
217
+ /** @deprecated use `ProductsBasedServiceabilityCheck$inboundSchema` instead. */
218
+ export const inboundSchema = ProductsBasedServiceabilityCheck$inboundSchema;
219
+ /** @deprecated use `ProductsBasedServiceabilityCheck$outboundSchema` instead. */
220
+ export const outboundSchema = ProductsBasedServiceabilityCheck$outboundSchema;
221
+ /** @deprecated use `ProductsBasedServiceabilityCheck$Outbound` instead. */
222
+ export type Outbound = ProductsBasedServiceabilityCheck$Outbound;
223
+ }
224
+
225
+ export function productsBasedServiceabilityCheckToJSON(
226
+ productsBasedServiceabilityCheck: ProductsBasedServiceabilityCheck,
227
+ ): string {
228
+ return JSON.stringify(
229
+ ProductsBasedServiceabilityCheck$outboundSchema.parse(
230
+ productsBasedServiceabilityCheck,
231
+ ),
232
+ );
233
+ }
234
+
235
+ export function productsBasedServiceabilityCheckFromJSON(
236
+ jsonString: string,
237
+ ): SafeParseResult<ProductsBasedServiceabilityCheck, SDKValidationError> {
238
+ return safeParse(
239
+ jsonString,
240
+ (x) => ProductsBasedServiceabilityCheck$inboundSchema.parse(JSON.parse(x)),
241
+ `Failed to parse 'ProductsBasedServiceabilityCheck' from JSON`,
242
+ );
243
+ }
@@ -15,9 +15,9 @@ export type ErrorT = {
15
15
  * Bad request
16
16
  */
17
17
  export type BadRequestData = {
18
- message?: string | undefined;
19
- success?: boolean | undefined;
20
- code?: string | undefined;
18
+ message: string;
19
+ success: boolean;
20
+ code: string;
21
21
  error?: ErrorT | undefined;
22
22
  };
23
23
 
@@ -25,8 +25,8 @@ export type BadRequestData = {
25
25
  * Bad request
26
26
  */
27
27
  export class BadRequest extends Error {
28
- success?: boolean | undefined;
29
- code?: string | undefined;
28
+ success: boolean;
29
+ code: string;
30
30
  error?: ErrorT | undefined;
31
31
 
32
32
  /** The original data that was passed to this error instance. */
@@ -37,8 +37,8 @@ export class BadRequest extends Error {
37
37
  super(message);
38
38
  this.data$ = err;
39
39
 
40
- if (err.success != null) this.success = err.success;
41
- if (err.code != null) this.code = err.code;
40
+ this.success = err.success;
41
+ this.code = err.code;
42
42
  if (err.error != null) this.error = err.error;
43
43
 
44
44
  this.name = "BadRequest";
@@ -98,9 +98,9 @@ export const BadRequest$inboundSchema: z.ZodType<
98
98
  z.ZodTypeDef,
99
99
  unknown
100
100
  > = z.object({
101
- message: z.string().optional(),
102
- success: z.boolean().optional(),
103
- code: z.string().optional(),
101
+ message: z.string(),
102
+ success: z.boolean(),
103
+ code: z.string(),
104
104
  error: z.lazy(() => ErrorT$inboundSchema).optional(),
105
105
  })
106
106
  .transform((v) => {
@@ -109,9 +109,9 @@ export const BadRequest$inboundSchema: z.ZodType<
109
109
 
110
110
  /** @internal */
111
111
  export type BadRequest$Outbound = {
112
- message?: string | undefined;
113
- success?: boolean | undefined;
114
- code?: string | undefined;
112
+ message: string;
113
+ success: boolean;
114
+ code: string;
115
115
  error?: ErrorT$Outbound | undefined;
116
116
  };
117
117
 
@@ -123,9 +123,9 @@ export const BadRequest$outboundSchema: z.ZodType<
123
123
  > = z.instanceof(BadRequest)
124
124
  .transform(v => v.data$)
125
125
  .pipe(z.object({
126
- message: z.string().optional(),
127
- success: z.boolean().optional(),
128
- code: z.string().optional(),
126
+ message: z.string(),
127
+ success: z.boolean(),
128
+ code: z.string(),
129
129
  error: z.lazy(() => ErrorT$outboundSchema).optional(),
130
130
  }));
131
131
 
@@ -8,17 +8,17 @@ import * as z from "zod";
8
8
  * Requested resource not found
9
9
  */
10
10
  export type NotFoundData = {
11
- message?: string | undefined;
12
- success?: boolean | undefined;
13
- code?: string | undefined;
11
+ message: string;
12
+ success: boolean;
13
+ code: string;
14
14
  };
15
15
 
16
16
  /**
17
17
  * Requested resource not found
18
18
  */
19
19
  export class NotFound extends Error {
20
- success?: boolean | undefined;
21
- code?: string | undefined;
20
+ success: boolean;
21
+ code: string;
22
22
 
23
23
  /** The original data that was passed to this error instance. */
24
24
  data$: NotFoundData;
@@ -28,8 +28,8 @@ export class NotFound extends Error {
28
28
  super(message);
29
29
  this.data$ = err;
30
30
 
31
- if (err.success != null) this.success = err.success;
32
- if (err.code != null) this.code = err.code;
31
+ this.success = err.success;
32
+ this.code = err.code;
33
33
 
34
34
  this.name = "NotFound";
35
35
  }
@@ -41,9 +41,9 @@ export const NotFound$inboundSchema: z.ZodType<
41
41
  z.ZodTypeDef,
42
42
  unknown
43
43
  > = z.object({
44
- message: z.string().optional(),
45
- success: z.boolean().optional(),
46
- code: z.string().optional(),
44
+ message: z.string(),
45
+ success: z.boolean(),
46
+ code: z.string(),
47
47
  })
48
48
  .transform((v) => {
49
49
  return new NotFound(v);
@@ -51,9 +51,9 @@ export const NotFound$inboundSchema: z.ZodType<
51
51
 
52
52
  /** @internal */
53
53
  export type NotFound$Outbound = {
54
- message?: string | undefined;
55
- success?: boolean | undefined;
56
- code?: string | undefined;
54
+ message: string;
55
+ success: boolean;
56
+ code: string;
57
57
  };
58
58
 
59
59
  /** @internal */
@@ -64,9 +64,9 @@ export const NotFound$outboundSchema: z.ZodType<
64
64
  > = z.instanceof(NotFound)
65
65
  .transform(v => v.data$)
66
66
  .pipe(z.object({
67
- message: z.string().optional(),
68
- success: z.boolean().optional(),
69
- code: z.string().optional(),
67
+ message: z.string(),
68
+ success: z.boolean(),
69
+ code: z.string(),
70
70
  }));
71
71
 
72
72
  /**
@@ -8,9 +8,9 @@ import * as z from "zod";
8
8
  * Not authorized for given operation on the Resource
9
9
  */
10
10
  export type UnauthorizedData = {
11
- message?: string | undefined;
11
+ message: string;
12
12
  success?: boolean;
13
- code?: string | undefined;
13
+ code: string;
14
14
  };
15
15
 
16
16
  /**
@@ -18,7 +18,7 @@ export type UnauthorizedData = {
18
18
  */
19
19
  export class Unauthorized extends Error {
20
20
  success?: boolean;
21
- code?: string | undefined;
21
+ code: string;
22
22
 
23
23
  /** The original data that was passed to this error instance. */
24
24
  data$: UnauthorizedData;
@@ -29,7 +29,7 @@ export class Unauthorized extends Error {
29
29
  this.data$ = err;
30
30
 
31
31
  if (err.success != null) this.success = err.success;
32
- if (err.code != null) this.code = err.code;
32
+ this.code = err.code;
33
33
 
34
34
  this.name = "Unauthorized";
35
35
  }
@@ -41,9 +41,9 @@ export const Unauthorized$inboundSchema: z.ZodType<
41
41
  z.ZodTypeDef,
42
42
  unknown
43
43
  > = z.object({
44
- message: z.string().optional(),
44
+ message: z.string(),
45
45
  success: z.boolean().default(false),
46
- code: z.string().optional(),
46
+ code: z.string(),
47
47
  })
48
48
  .transform((v) => {
49
49
  return new Unauthorized(v);
@@ -51,9 +51,9 @@ export const Unauthorized$inboundSchema: z.ZodType<
51
51
 
52
52
  /** @internal */
53
53
  export type Unauthorized$Outbound = {
54
- message?: string | undefined;
54
+ message: string;
55
55
  success?: boolean;
56
- code?: string | undefined;
56
+ code: string;
57
57
  };
58
58
 
59
59
  /** @internal */
@@ -64,9 +64,9 @@ export const Unauthorized$outboundSchema: z.ZodType<
64
64
  > = z.instanceof(Unauthorized)
65
65
  .transform(v => v.data$)
66
66
  .pipe(z.object({
67
- message: z.string().optional(),
67
+ message: z.string(),
68
68
  success: z.boolean().default(false),
69
- code: z.string().optional(),
69
+ code: z.string(),
70
70
  }));
71
71
 
72
72
  /**
@@ -3,16 +3,14 @@
3
3
  */
4
4
 
5
5
  import * as z from "zod";
6
- import { remap as remap$ } from "../../lib/primitives.js";
7
6
  import { safeParse } from "../../lib/schemas.js";
8
7
  import { Result as SafeParseResult } from "../../types/fp.js";
9
8
  import * as components from "../components/index.js";
10
9
  import { SDKValidationError } from "../errors/sdkvalidationerror.js";
11
10
 
12
- export type ShippingMethodsRequestBody = {
13
- deliveryPincode: string;
14
- cartId: string;
15
- };
11
+ export type ShippingMethodsRequestBody =
12
+ | components.CartBasedServiceabilityCheck
13
+ | components.ProductsBasedServiceabilityCheck;
16
14
 
17
15
  /**
18
16
  * OK
@@ -28,36 +26,25 @@ export const ShippingMethodsRequestBody$inboundSchema: z.ZodType<
28
26
  ShippingMethodsRequestBody,
29
27
  z.ZodTypeDef,
30
28
  unknown
31
- > = z.object({
32
- delivery_pincode: z.string(),
33
- cart_id: z.string(),
34
- }).transform((v) => {
35
- return remap$(v, {
36
- "delivery_pincode": "deliveryPincode",
37
- "cart_id": "cartId",
38
- });
39
- });
29
+ > = z.union([
30
+ components.CartBasedServiceabilityCheck$inboundSchema,
31
+ components.ProductsBasedServiceabilityCheck$inboundSchema,
32
+ ]);
40
33
 
41
34
  /** @internal */
42
- export type ShippingMethodsRequestBody$Outbound = {
43
- delivery_pincode: string;
44
- cart_id: string;
45
- };
35
+ export type ShippingMethodsRequestBody$Outbound =
36
+ | components.CartBasedServiceabilityCheck$Outbound
37
+ | components.ProductsBasedServiceabilityCheck$Outbound;
46
38
 
47
39
  /** @internal */
48
40
  export const ShippingMethodsRequestBody$outboundSchema: z.ZodType<
49
41
  ShippingMethodsRequestBody$Outbound,
50
42
  z.ZodTypeDef,
51
43
  ShippingMethodsRequestBody
52
- > = z.object({
53
- deliveryPincode: z.string(),
54
- cartId: z.string(),
55
- }).transform((v) => {
56
- return remap$(v, {
57
- deliveryPincode: "delivery_pincode",
58
- cartId: "cart_id",
59
- });
60
- });
44
+ > = z.union([
45
+ components.CartBasedServiceabilityCheck$outboundSchema,
46
+ components.ProductsBasedServiceabilityCheck$outboundSchema,
47
+ ]);
61
48
 
62
49
  /**
63
50
  * @internal
@@ -30,7 +30,7 @@ export class Shipping extends ClientSDK {
30
30
  * Check serviceability
31
31
  *
32
32
  * @remarks
33
- * Checking serviceability for a given pincode based provided cart_id.
33
+ * Checking serviceability for a given pincode based provided cart_id or based on products list & pickup pincode provided.
34
34
  */
35
35
  async checkServiceability(
36
36
  request?: operations.ShippingMethodsRequestBody | undefined,