@cimplify/sdk 0.94.2 → 0.96.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.
package/dist/testing.js CHANGED
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var chunkRQMCRU4C_js = require('./chunk-RQMCRU4C.js');
3
+ var chunkWEEGNH7K_js = require('./chunk-WEEGNH7K.js');
4
4
  require('./chunk-FECGCIVV.js');
5
5
  require('./chunk-XREIZ56K.js');
6
- require('./chunk-QLGZIBRO.js');
6
+ require('./chunk-W5PH7SPK.js');
7
7
  require('./chunk-VEOAMBEX.js');
8
8
  require('./chunk-PTPOQVXS.js');
9
9
  require('./chunk-AETVRBKI.js');
@@ -11,20 +11,20 @@ require('./chunk-OWW5GUSB.js');
11
11
  var zod = require('zod');
12
12
 
13
13
  var PUBLIC_SCHEMAS = {
14
- Brand: chunkRQMCRU4C_js.BrandSchema,
15
- AddItemPayload: chunkRQMCRU4C_js.AddItemPayloadSchema,
16
- Cart: chunkRQMCRU4C_js.CartSchema,
17
- CartItem: chunkRQMCRU4C_js.CartItemSchema,
18
- CartPricing: chunkRQMCRU4C_js.CartPricingSchema,
19
- CheckoutBody: chunkRQMCRU4C_js.CheckoutBodySchema,
20
- CheckoutResponse: chunkRQMCRU4C_js.CheckoutResponseSchema,
21
- VariantInfo: chunkRQMCRU4C_js.VariantInfoSchema
14
+ Brand: chunkWEEGNH7K_js.BrandSchema,
15
+ AddItemPayload: chunkWEEGNH7K_js.AddItemPayloadSchema,
16
+ Cart: chunkWEEGNH7K_js.CartSchema,
17
+ CartItem: chunkWEEGNH7K_js.CartItemSchema,
18
+ CartPricing: chunkWEEGNH7K_js.CartPricingSchema,
19
+ CheckoutBody: chunkWEEGNH7K_js.CheckoutBodySchema,
20
+ CheckoutResponse: chunkWEEGNH7K_js.CheckoutResponseSchema,
21
+ VariantInfo: chunkWEEGNH7K_js.VariantInfoSchema
22
22
  };
23
23
  function exportJsonSchemas() {
24
24
  const out = {};
25
25
  for (const [name, schema] of Object.entries(PUBLIC_SCHEMAS)) {
26
- const meta = chunkRQMCRU4C_js.cimplifyRegistry.get(schema);
27
- const json = zod.z.toJSONSchema(schema, { metadata: chunkRQMCRU4C_js.cimplifyRegistry });
26
+ const meta = chunkWEEGNH7K_js.cimplifyRegistry.get(schema);
27
+ const json = zod.z.toJSONSchema(schema, { metadata: chunkWEEGNH7K_js.cimplifyRegistry });
28
28
  if (meta) {
29
29
  json.$id = meta.id;
30
30
  json["x-cimplify-version"] = meta.version;
@@ -36,16 +36,16 @@ function exportJsonSchemas() {
36
36
  function listRegisteredSchemas() {
37
37
  const entries = [];
38
38
  for (const schema of [
39
- chunkRQMCRU4C_js.BrandSchema,
40
- chunkRQMCRU4C_js.AddItemPayloadSchema,
41
- chunkRQMCRU4C_js.CartSchema,
42
- chunkRQMCRU4C_js.CartItemSchema,
43
- chunkRQMCRU4C_js.CartPricingSchema,
44
- chunkRQMCRU4C_js.CheckoutBodySchema,
45
- chunkRQMCRU4C_js.CheckoutResponseSchema,
46
- chunkRQMCRU4C_js.VariantInfoSchema
39
+ chunkWEEGNH7K_js.BrandSchema,
40
+ chunkWEEGNH7K_js.AddItemPayloadSchema,
41
+ chunkWEEGNH7K_js.CartSchema,
42
+ chunkWEEGNH7K_js.CartItemSchema,
43
+ chunkWEEGNH7K_js.CartPricingSchema,
44
+ chunkWEEGNH7K_js.CheckoutBodySchema,
45
+ chunkWEEGNH7K_js.CheckoutResponseSchema,
46
+ chunkWEEGNH7K_js.VariantInfoSchema
47
47
  ]) {
48
- const meta = chunkRQMCRU4C_js.cimplifyRegistry.get(schema);
48
+ const meta = chunkWEEGNH7K_js.cimplifyRegistry.get(schema);
49
49
  if (meta) entries.push({ schema, meta });
50
50
  }
51
51
  return entries;
@@ -53,227 +53,227 @@ function listRegisteredSchemas() {
53
53
 
54
54
  Object.defineProperty(exports, "AddItemPayloadSchema", {
55
55
  enumerable: true,
56
- get: function () { return chunkRQMCRU4C_js.AddItemPayloadSchema; }
56
+ get: function () { return chunkWEEGNH7K_js.AddItemPayloadSchema; }
57
57
  });
58
58
  Object.defineProperty(exports, "AddOnDetailsSchema", {
59
59
  enumerable: true,
60
- get: function () { return chunkRQMCRU4C_js.AddOnDetailsSchema; }
60
+ get: function () { return chunkWEEGNH7K_js.AddOnDetailsSchema; }
61
61
  });
62
62
  Object.defineProperty(exports, "AddOnGroupDetailsSchema", {
63
63
  enumerable: true,
64
- get: function () { return chunkRQMCRU4C_js.AddOnGroupDetailsSchema; }
64
+ get: function () { return chunkWEEGNH7K_js.AddOnGroupDetailsSchema; }
65
65
  });
66
66
  Object.defineProperty(exports, "AddOnInDetailsSchema", {
67
67
  enumerable: true,
68
- get: function () { return chunkRQMCRU4C_js.AddOnInDetailsSchema; }
68
+ get: function () { return chunkWEEGNH7K_js.AddOnInDetailsSchema; }
69
69
  });
70
70
  Object.defineProperty(exports, "AddOnOptionDetailsSchema", {
71
71
  enumerable: true,
72
- get: function () { return chunkRQMCRU4C_js.AddOnOptionDetailsSchema; }
72
+ get: function () { return chunkWEEGNH7K_js.AddOnOptionDetailsSchema; }
73
73
  });
74
74
  Object.defineProperty(exports, "AuthorizationTypeSchema", {
75
75
  enumerable: true,
76
- get: function () { return chunkRQMCRU4C_js.AuthorizationTypeSchema; }
76
+ get: function () { return chunkWEEGNH7K_js.AuthorizationTypeSchema; }
77
77
  });
78
78
  Object.defineProperty(exports, "BrandContactSchema", {
79
79
  enumerable: true,
80
- get: function () { return chunkRQMCRU4C_js.BrandContactSchema; }
80
+ get: function () { return chunkWEEGNH7K_js.BrandContactSchema; }
81
81
  });
82
82
  Object.defineProperty(exports, "BrandFaqSchema", {
83
83
  enumerable: true,
84
- get: function () { return chunkRQMCRU4C_js.BrandFaqSchema; }
84
+ get: function () { return chunkWEEGNH7K_js.BrandFaqSchema; }
85
85
  });
86
86
  Object.defineProperty(exports, "BrandHeroSchema", {
87
87
  enumerable: true,
88
- get: function () { return chunkRQMCRU4C_js.BrandHeroSchema; }
88
+ get: function () { return chunkWEEGNH7K_js.BrandHeroSchema; }
89
89
  });
90
90
  Object.defineProperty(exports, "BrandNavLinkSchema", {
91
91
  enumerable: true,
92
- get: function () { return chunkRQMCRU4C_js.BrandNavLinkSchema; }
92
+ get: function () { return chunkWEEGNH7K_js.BrandNavLinkSchema; }
93
93
  });
94
94
  Object.defineProperty(exports, "BrandPolicyPageSchema", {
95
95
  enumerable: true,
96
- get: function () { return chunkRQMCRU4C_js.BrandPolicyPageSchema; }
96
+ get: function () { return chunkWEEGNH7K_js.BrandPolicyPageSchema; }
97
97
  });
98
98
  Object.defineProperty(exports, "BrandPolicySectionSchema", {
99
99
  enumerable: true,
100
- get: function () { return chunkRQMCRU4C_js.BrandPolicySectionSchema; }
100
+ get: function () { return chunkWEEGNH7K_js.BrandPolicySectionSchema; }
101
101
  });
102
102
  Object.defineProperty(exports, "BrandSchema", {
103
103
  enumerable: true,
104
- get: function () { return chunkRQMCRU4C_js.BrandSchema; }
104
+ get: function () { return chunkWEEGNH7K_js.BrandSchema; }
105
105
  });
106
106
  Object.defineProperty(exports, "BrandSocialSchema", {
107
107
  enumerable: true,
108
- get: function () { return chunkRQMCRU4C_js.BrandSocialSchema; }
108
+ get: function () { return chunkWEEGNH7K_js.BrandSocialSchema; }
109
109
  });
110
110
  Object.defineProperty(exports, "BundleResolvedSchema", {
111
111
  enumerable: true,
112
- get: function () { return chunkRQMCRU4C_js.BundleResolvedSchema; }
112
+ get: function () { return chunkWEEGNH7K_js.BundleResolvedSchema; }
113
113
  });
114
114
  Object.defineProperty(exports, "BundleSelectionInputSchema", {
115
115
  enumerable: true,
116
- get: function () { return chunkRQMCRU4C_js.BundleSelectionInputSchema; }
116
+ get: function () { return chunkWEEGNH7K_js.BundleSelectionInputSchema; }
117
117
  });
118
118
  Object.defineProperty(exports, "CartItemSchema", {
119
119
  enumerable: true,
120
- get: function () { return chunkRQMCRU4C_js.CartItemSchema; }
120
+ get: function () { return chunkWEEGNH7K_js.CartItemSchema; }
121
121
  });
122
122
  Object.defineProperty(exports, "CartPricingSchema", {
123
123
  enumerable: true,
124
- get: function () { return chunkRQMCRU4C_js.CartPricingSchema; }
124
+ get: function () { return chunkWEEGNH7K_js.CartPricingSchema; }
125
125
  });
126
126
  Object.defineProperty(exports, "CartSchema", {
127
127
  enumerable: true,
128
- get: function () { return chunkRQMCRU4C_js.CartSchema; }
128
+ get: function () { return chunkWEEGNH7K_js.CartSchema; }
129
129
  });
130
130
  Object.defineProperty(exports, "CheckoutBodySchema", {
131
131
  enumerable: true,
132
- get: function () { return chunkRQMCRU4C_js.CheckoutBodySchema; }
132
+ get: function () { return chunkWEEGNH7K_js.CheckoutBodySchema; }
133
133
  });
134
134
  Object.defineProperty(exports, "CheckoutCustomerSchema", {
135
135
  enumerable: true,
136
- get: function () { return chunkRQMCRU4C_js.CheckoutCustomerSchema; }
136
+ get: function () { return chunkWEEGNH7K_js.CheckoutCustomerSchema; }
137
137
  });
138
138
  Object.defineProperty(exports, "CheckoutResponseSchema", {
139
139
  enumerable: true,
140
- get: function () { return chunkRQMCRU4C_js.CheckoutResponseSchema; }
140
+ get: function () { return chunkWEEGNH7K_js.CheckoutResponseSchema; }
141
141
  });
142
142
  Object.defineProperty(exports, "ChosenPriceSchema", {
143
143
  enumerable: true,
144
- get: function () { return chunkRQMCRU4C_js.ChosenPriceSchema; }
144
+ get: function () { return chunkWEEGNH7K_js.ChosenPriceSchema; }
145
145
  });
146
146
  Object.defineProperty(exports, "CompositeResolvedSchema", {
147
147
  enumerable: true,
148
- get: function () { return chunkRQMCRU4C_js.CompositeResolvedSchema; }
148
+ get: function () { return chunkWEEGNH7K_js.CompositeResolvedSchema; }
149
149
  });
150
150
  Object.defineProperty(exports, "CompositeSelectionInputSchema", {
151
151
  enumerable: true,
152
- get: function () { return chunkRQMCRU4C_js.CompositeSelectionInputSchema; }
152
+ get: function () { return chunkWEEGNH7K_js.CompositeSelectionInputSchema; }
153
153
  });
154
154
  Object.defineProperty(exports, "CountryCodeSchema", {
155
155
  enumerable: true,
156
- get: function () { return chunkRQMCRU4C_js.CountryCodeSchema; }
156
+ get: function () { return chunkWEEGNH7K_js.CountryCodeSchema; }
157
157
  });
158
158
  Object.defineProperty(exports, "CurrencyCodeSchema", {
159
159
  enumerable: true,
160
- get: function () { return chunkRQMCRU4C_js.CurrencyCodeSchema; }
160
+ get: function () { return chunkWEEGNH7K_js.CurrencyCodeSchema; }
161
161
  });
162
162
  Object.defineProperty(exports, "CustomerInputValueSchema", {
163
163
  enumerable: true,
164
- get: function () { return chunkRQMCRU4C_js.CustomerInputValueSchema; }
164
+ get: function () { return chunkWEEGNH7K_js.CustomerInputValueSchema; }
165
165
  });
166
166
  Object.defineProperty(exports, "DiscountDetailsSchema", {
167
167
  enumerable: true,
168
- get: function () { return chunkRQMCRU4C_js.DiscountDetailsSchema; }
168
+ get: function () { return chunkWEEGNH7K_js.DiscountDetailsSchema; }
169
169
  });
170
170
  Object.defineProperty(exports, "IsoDateTimeSchema", {
171
171
  enumerable: true,
172
- get: function () { return chunkRQMCRU4C_js.IsoDateTimeSchema; }
172
+ get: function () { return chunkWEEGNH7K_js.IsoDateTimeSchema; }
173
173
  });
174
174
  Object.defineProperty(exports, "LineTypeSchema", {
175
175
  enumerable: true,
176
- get: function () { return chunkRQMCRU4C_js.LineTypeSchema; }
176
+ get: function () { return chunkWEEGNH7K_js.LineTypeSchema; }
177
177
  });
178
178
  Object.defineProperty(exports, "LocaleSchema", {
179
179
  enumerable: true,
180
- get: function () { return chunkRQMCRU4C_js.LocaleSchema; }
180
+ get: function () { return chunkWEEGNH7K_js.LocaleSchema; }
181
181
  });
182
182
  Object.defineProperty(exports, "MoneyLooseSchema", {
183
183
  enumerable: true,
184
- get: function () { return chunkRQMCRU4C_js.MoneyLooseSchema; }
184
+ get: function () { return chunkWEEGNH7K_js.MoneyLooseSchema; }
185
185
  });
186
186
  Object.defineProperty(exports, "MoneySchema", {
187
187
  enumerable: true,
188
- get: function () { return chunkRQMCRU4C_js.MoneySchema; }
188
+ get: function () { return chunkWEEGNH7K_js.MoneySchema; }
189
189
  });
190
190
  Object.defineProperty(exports, "NextActionSchema", {
191
191
  enumerable: true,
192
- get: function () { return chunkRQMCRU4C_js.NextActionSchema; }
192
+ get: function () { return chunkWEEGNH7K_js.NextActionSchema; }
193
193
  });
194
194
  Object.defineProperty(exports, "PhoneE164Schema", {
195
195
  enumerable: true,
196
- get: function () { return chunkRQMCRU4C_js.PhoneE164Schema; }
196
+ get: function () { return chunkWEEGNH7K_js.PhoneE164Schema; }
197
197
  });
198
198
  Object.defineProperty(exports, "ProductTypeSchema", {
199
199
  enumerable: true,
200
- get: function () { return chunkRQMCRU4C_js.ProductTypeSchema; }
200
+ get: function () { return chunkWEEGNH7K_js.ProductTypeSchema; }
201
201
  });
202
202
  Object.defineProperty(exports, "SchemaViolationError", {
203
203
  enumerable: true,
204
- get: function () { return chunkRQMCRU4C_js.SchemaViolationError; }
204
+ get: function () { return chunkWEEGNH7K_js.SchemaViolationError; }
205
205
  });
206
206
  Object.defineProperty(exports, "SeedNameSchema", {
207
207
  enumerable: true,
208
- get: function () { return chunkRQMCRU4C_js.SeedNameSchema; }
208
+ get: function () { return chunkWEEGNH7K_js.SeedNameSchema; }
209
209
  });
210
210
  Object.defineProperty(exports, "SelectedAddOnOptionSchema", {
211
211
  enumerable: true,
212
- get: function () { return chunkRQMCRU4C_js.SelectedAddOnOptionSchema; }
212
+ get: function () { return chunkWEEGNH7K_js.SelectedAddOnOptionSchema; }
213
213
  });
214
214
  Object.defineProperty(exports, "ServiceStatusSchema", {
215
215
  enumerable: true,
216
- get: function () { return chunkRQMCRU4C_js.ServiceStatusSchema; }
216
+ get: function () { return chunkWEEGNH7K_js.ServiceStatusSchema; }
217
217
  });
218
218
  Object.defineProperty(exports, "TimestampSchema", {
219
219
  enumerable: true,
220
- get: function () { return chunkRQMCRU4C_js.TimestampSchema; }
220
+ get: function () { return chunkWEEGNH7K_js.TimestampSchema; }
221
221
  });
222
222
  Object.defineProperty(exports, "VariantDetailsSchema", {
223
223
  enumerable: true,
224
- get: function () { return chunkRQMCRU4C_js.VariantDetailsSchema; }
224
+ get: function () { return chunkWEEGNH7K_js.VariantDetailsSchema; }
225
225
  });
226
226
  Object.defineProperty(exports, "VariantDisplayAttributeSchema", {
227
227
  enumerable: true,
228
- get: function () { return chunkRQMCRU4C_js.VariantDisplayAttributeSchema; }
228
+ get: function () { return chunkWEEGNH7K_js.VariantDisplayAttributeSchema; }
229
229
  });
230
230
  Object.defineProperty(exports, "VariantInfoSchema", {
231
231
  enumerable: true,
232
- get: function () { return chunkRQMCRU4C_js.VariantInfoSchema; }
232
+ get: function () { return chunkWEEGNH7K_js.VariantInfoSchema; }
233
233
  });
234
234
  Object.defineProperty(exports, "assertAddItemPayload", {
235
235
  enumerable: true,
236
- get: function () { return chunkRQMCRU4C_js.assertAddItemPayload; }
236
+ get: function () { return chunkWEEGNH7K_js.assertAddItemPayload; }
237
237
  });
238
238
  Object.defineProperty(exports, "assertBrand", {
239
239
  enumerable: true,
240
- get: function () { return chunkRQMCRU4C_js.assertBrand; }
240
+ get: function () { return chunkWEEGNH7K_js.assertBrand; }
241
241
  });
242
242
  Object.defineProperty(exports, "assertCart", {
243
243
  enumerable: true,
244
- get: function () { return chunkRQMCRU4C_js.assertCart; }
244
+ get: function () { return chunkWEEGNH7K_js.assertCart; }
245
245
  });
246
246
  Object.defineProperty(exports, "assertCartItem", {
247
247
  enumerable: true,
248
- get: function () { return chunkRQMCRU4C_js.assertCartItem; }
248
+ get: function () { return chunkWEEGNH7K_js.assertCartItem; }
249
249
  });
250
250
  Object.defineProperty(exports, "assertCheckoutBody", {
251
251
  enumerable: true,
252
- get: function () { return chunkRQMCRU4C_js.assertCheckoutBody; }
252
+ get: function () { return chunkWEEGNH7K_js.assertCheckoutBody; }
253
253
  });
254
254
  Object.defineProperty(exports, "assertCheckoutResponse", {
255
255
  enumerable: true,
256
- get: function () { return chunkRQMCRU4C_js.assertCheckoutResponse; }
256
+ get: function () { return chunkWEEGNH7K_js.assertCheckoutResponse; }
257
257
  });
258
258
  Object.defineProperty(exports, "cimplifyRegistry", {
259
259
  enumerable: true,
260
- get: function () { return chunkRQMCRU4C_js.cimplifyRegistry; }
260
+ get: function () { return chunkWEEGNH7K_js.cimplifyRegistry; }
261
261
  });
262
262
  Object.defineProperty(exports, "createTestClient", {
263
263
  enumerable: true,
264
- get: function () { return chunkRQMCRU4C_js.createTestClient; }
264
+ get: function () { return chunkWEEGNH7K_js.createTestClient; }
265
265
  });
266
266
  Object.defineProperty(exports, "fixtures", {
267
267
  enumerable: true,
268
- get: function () { return chunkRQMCRU4C_js.fixtures; }
268
+ get: function () { return chunkWEEGNH7K_js.fixtures; }
269
269
  });
270
270
  Object.defineProperty(exports, "makeAssertion", {
271
271
  enumerable: true,
272
- get: function () { return chunkRQMCRU4C_js.makeAssertion; }
272
+ get: function () { return chunkWEEGNH7K_js.makeAssertion; }
273
273
  });
274
274
  Object.defineProperty(exports, "registerSchema", {
275
275
  enumerable: true,
276
- get: function () { return chunkRQMCRU4C_js.registerSchema; }
276
+ get: function () { return chunkWEEGNH7K_js.registerSchema; }
277
277
  });
278
278
  exports.exportJsonSchemas = exportJsonSchemas;
279
279
  exports.listRegisteredSchemas = listRegisteredSchemas;
package/dist/testing.mjs CHANGED
@@ -1,8 +1,8 @@
1
- import { VariantInfoSchema, CheckoutResponseSchema, CheckoutBodySchema, CartPricingSchema, CartItemSchema, CartSchema, AddItemPayloadSchema, BrandSchema, cimplifyRegistry } from './chunk-VZWK2FJM.mjs';
2
- export { AddItemPayloadSchema, AddOnDetailsSchema, AddOnGroupDetailsSchema, AddOnInDetailsSchema, AddOnOptionDetailsSchema, AuthorizationTypeSchema, BrandContactSchema, BrandFaqSchema, BrandHeroSchema, BrandNavLinkSchema, BrandPolicyPageSchema, BrandPolicySectionSchema, BrandSchema, BrandSocialSchema, BundleResolvedSchema, BundleSelectionInputSchema, CartItemSchema, CartPricingSchema, CartSchema, CheckoutBodySchema, CheckoutCustomerSchema, CheckoutResponseSchema, ChosenPriceSchema, CompositeResolvedSchema, CompositeSelectionInputSchema, CountryCodeSchema, CurrencyCodeSchema, CustomerInputValueSchema, DiscountDetailsSchema, IsoDateTimeSchema, LineTypeSchema, LocaleSchema, MoneyLooseSchema, MoneySchema, NextActionSchema, PhoneE164Schema, ProductTypeSchema, SchemaViolationError, SeedNameSchema, SelectedAddOnOptionSchema, ServiceStatusSchema, TimestampSchema, VariantDetailsSchema, VariantDisplayAttributeSchema, VariantInfoSchema, assertAddItemPayload, assertBrand, assertCart, assertCartItem, assertCheckoutBody, assertCheckoutResponse, cimplifyRegistry, createTestClient, fixtures, makeAssertion, registerSchema } from './chunk-VZWK2FJM.mjs';
1
+ import { VariantInfoSchema, CheckoutResponseSchema, CheckoutBodySchema, CartPricingSchema, CartItemSchema, CartSchema, AddItemPayloadSchema, BrandSchema, cimplifyRegistry } from './chunk-BUPCMMRR.mjs';
2
+ export { AddItemPayloadSchema, AddOnDetailsSchema, AddOnGroupDetailsSchema, AddOnInDetailsSchema, AddOnOptionDetailsSchema, AuthorizationTypeSchema, BrandContactSchema, BrandFaqSchema, BrandHeroSchema, BrandNavLinkSchema, BrandPolicyPageSchema, BrandPolicySectionSchema, BrandSchema, BrandSocialSchema, BundleResolvedSchema, BundleSelectionInputSchema, CartItemSchema, CartPricingSchema, CartSchema, CheckoutBodySchema, CheckoutCustomerSchema, CheckoutResponseSchema, ChosenPriceSchema, CompositeResolvedSchema, CompositeSelectionInputSchema, CountryCodeSchema, CurrencyCodeSchema, CustomerInputValueSchema, DiscountDetailsSchema, IsoDateTimeSchema, LineTypeSchema, LocaleSchema, MoneyLooseSchema, MoneySchema, NextActionSchema, PhoneE164Schema, ProductTypeSchema, SchemaViolationError, SeedNameSchema, SelectedAddOnOptionSchema, ServiceStatusSchema, TimestampSchema, VariantDetailsSchema, VariantDisplayAttributeSchema, VariantInfoSchema, assertAddItemPayload, assertBrand, assertCart, assertCartItem, assertCheckoutBody, assertCheckoutResponse, cimplifyRegistry, createTestClient, fixtures, makeAssertion, registerSchema } from './chunk-BUPCMMRR.mjs';
3
3
  import './chunk-7TEMLVDT.mjs';
4
4
  import './chunk-U4MW6PYU.mjs';
5
- import './chunk-FKARGZK3.mjs';
5
+ import './chunk-XMDLF5Y6.mjs';
6
6
  import './chunk-VUSHG3HA.mjs';
7
7
  import './chunk-KFLGQGMC.mjs';
8
8
  import './chunk-K5EN2W2Q.mjs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cimplify/sdk",
3
- "version": "0.94.2",
3
+ "version": "0.96.0",
4
4
  "description": "Cimplify Commerce SDK for storefronts",
5
5
  "keywords": [
6
6
  "cimplify",
@@ -10,7 +10,7 @@
10
10
  "files": [
11
11
  {
12
12
  "path": "date-slot-picker.tsx",
13
- "content": "\"use client\";\n\nimport React, { useState, useMemo, useCallback } from \"react\";\nimport { Tabs } from \"@base-ui/react/tabs\";\nimport type { AvailableSlot, DayAvailability } from \"@cimplify/sdk\";\nimport type { DurationUnit, SchedulingMode } from \"@cimplify/sdk\";\nimport type { CurrencyCode } from \"@cimplify/sdk\";\nimport { useServiceAvailability } from \"@cimplify/sdk/react\";\nimport { SlotPicker } from \"@cimplify/sdk/react\";\nimport { cn } from \"@cimplify/sdk/react\";\n\nexport interface DateSlotPickerClassNames {\n root?: string;\n dateStrip?: string;\n dateButton?: string;\n nav?: string;\n navButton?: string;\n slots?: string;\n loading?: string;\n}\n\nexport interface DateSlotPickerProps {\n /** Service ID to fetch availability and slots for. */\n serviceId: string;\n /** Number of days to show in the date strip. Default: 7. */\n daysToShow?: number;\n /** Number of participants. */\n participantCount?: number;\n /** Whole units needed — forwarded to availability so short days drop out. */\n units?: number;\n /** Currently selected slot. */\n selectedSlot?: AvailableSlot | null;\n /** Called when a slot is selected. */\n onSlotSelect?: (slot: AvailableSlot, date: string) => void;\n /** Pre-fetched availability data (skips fetch). */\n availability?: DayAvailability[];\n /** Show price on slots. Default: true. */\n showPrice?: boolean;\n /** Currency the slot prices are denominated in. */\n currency?: CurrencyCode;\n /** Forwarded to `<SlotPicker>` to render multi-day stay labels. */\n schedulingMode?: SchedulingMode;\n /** Forwarded to `<SlotPicker>` — unit for the stay summary in multi-day mode. */\n durationUnit?: DurationUnit;\n /** Forwarded to `<SlotPicker>` — value for the stay summary in multi-day mode. */\n durationValue?: number;\n /** Forwarded to `<SlotPicker>` — hide slots already in the past. Default: true. */\n hideElapsedSlots?: boolean;\n /** Forwarded to `<SlotPicker>` — minimum lead time in minutes. Default: 0. */\n minLeadMinutes?: number;\n className?: string;\n classNames?: DateSlotPickerClassNames;\n}\n\nfunction formatDate(dateStr: string): string {\n const date = new Date(dateStr + \"T00:00:00\");\n return date.toLocaleDateString(undefined, { weekday: \"short\", month: \"short\", day: \"numeric\" });\n}\n\nfunction toDateString(date: Date): string {\n return date.toISOString().split(\"T\")[0];\n}\n\nfunction addDays(date: Date, days: number): Date {\n const result = new Date(date);\n result.setDate(result.getDate() + days);\n return result;\n}\n\nexport function DateSlotPicker({\n serviceId,\n daysToShow = 7,\n participantCount,\n units,\n selectedSlot,\n onSlotSelect,\n availability: availabilityProp,\n showPrice = true,\n currency,\n schedulingMode,\n durationUnit,\n durationValue,\n hideElapsedSlots = true,\n minLeadMinutes = 0,\n className,\n classNames,\n}: DateSlotPickerProps): React.ReactElement {\n const [offset, setOffset] = useState(0);\n const [selectedDate, setSelectedDate] = useState<string>(toDateString(new Date()));\n\n const dateRange = useMemo(() => {\n const today = new Date();\n const start = addDays(today, offset);\n const dates: string[] = [];\n for (let i = 0; i < daysToShow; i++) {\n dates.push(toDateString(addDays(start, i)));\n }\n return {\n dates,\n startDate: dates[0],\n endDate: dates[dates.length - 1],\n };\n }, [offset, daysToShow]);\n\n const { days: fetchedDays, isLoading: availabilityLoading } = useServiceAvailability(\n serviceId,\n dateRange.startDate,\n dateRange.endDate,\n {\n participantCount,\n units,\n enabled: availabilityProp === undefined,\n },\n );\n\n const days = availabilityProp ?? fetchedDays;\n\n const availabilityMap = useMemo(() => {\n const map = new Map<string, DayAvailability>();\n for (const day of days) {\n map.set(day.date, day);\n }\n return map;\n }, [days]);\n\n const handlePrev = useCallback(() => {\n setOffset((prev) => Math.max(0, prev - daysToShow));\n }, [daysToShow]);\n\n const handleNext = useCallback(() => {\n setOffset((prev) => prev + daysToShow);\n }, [daysToShow]);\n\n const handleDateChange = useCallback((value: string | number | null) => {\n if (typeof value === \"string\") {\n setSelectedDate(value);\n }\n }, []);\n\n const handleSlotSelect = useCallback(\n (slot: AvailableSlot) => {\n onSlotSelect?.(slot, selectedDate);\n },\n [onSlotSelect, selectedDate],\n );\n\n return (\n <Tabs.Root\n value={selectedDate}\n onValueChange={handleDateChange}\n data-cimplify-date-slot-picker\n className={cn(\"flex flex-col gap-4\", className, classNames?.root)}\n >\n <div\n data-cimplify-date-nav\n className={cn(\"flex items-center justify-end gap-2\", classNames?.nav)}\n >\n <button\n type=\"button\"\n onClick={handlePrev}\n disabled={offset === 0}\n aria-label=\"Previous dates\"\n data-cimplify-date-nav-prev\n className={cn(\n \"grid place-items-center w-8 h-8 rounded-md border border-border text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-40\",\n classNames?.navButton,\n )}\n >\n &larr;\n </button>\n <button\n type=\"button\"\n onClick={handleNext}\n aria-label=\"Next dates\"\n data-cimplify-date-nav-next\n className={cn(\n \"grid place-items-center w-8 h-8 rounded-md border border-border text-muted-foreground transition-colors hover:bg-muted hover:text-foreground\",\n classNames?.navButton,\n )}\n >\n &rarr;\n </button>\n </div>\n\n <Tabs.List\n data-cimplify-date-strip\n className={cn(\"grid grid-cols-7 gap-1 sm:gap-2\", classNames?.dateStrip)}\n >\n {dateRange.dates.map((date) => {\n const dayInfo = availabilityMap.get(date);\n const hasAvailability = dayInfo?.has_availability !== false;\n const isSelected = selectedDate === date;\n return (\n <Tabs.Tab\n key={date}\n value={date}\n data-cimplify-date-button\n data-selected={isSelected || undefined}\n data-available={hasAvailability || undefined}\n data-fully-booked={(!hasAvailability) || undefined}\n className={cn(\n \"flex flex-col items-center justify-center rounded-md border border-border bg-background px-1 py-2 text-center text-xs font-medium text-foreground transition-colors hover:border-foreground/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring data-[selected]:border-foreground data-[selected]:bg-foreground data-[selected]:text-background data-[fully-booked]:cursor-not-allowed data-[fully-booked]:opacity-40\",\n classNames?.dateButton,\n )}\n >\n {formatDate(date)}\n </Tabs.Tab>\n );\n })}\n </Tabs.List>\n\n {availabilityLoading && (\n <div\n data-cimplify-date-slot-loading\n aria-busy=\"true\"\n className={cn(\"h-32 rounded-md bg-muted/40 animate-pulse\", classNames?.loading)}\n />\n )}\n\n <div data-cimplify-date-slots className={classNames?.slots}>\n <SlotPicker\n serviceId={serviceId}\n date={selectedDate}\n participantCount={participantCount}\n selectedSlot={selectedSlot}\n onSlotSelect={handleSlotSelect}\n showPrice={showPrice}\n currency={currency}\n schedulingMode={schedulingMode}\n durationUnit={durationUnit}\n durationValue={durationValue}\n hideElapsedSlots={hideElapsedSlots}\n minLeadMinutes={minLeadMinutes}\n />\n </div>\n </Tabs.Root>\n );\n}\n"
13
+ "content": "\"use client\";\n\nimport React, { useState, useMemo, useCallback } from \"react\";\nimport { Tabs } from \"@base-ui/react/tabs\";\nimport type { AvailableSlot, DayAvailability } from \"@cimplify/sdk\";\nimport type { DurationUnit, SchedulingMode } from \"@cimplify/sdk\";\nimport type { CurrencyCode } from \"@cimplify/sdk\";\nimport { useServiceAvailability } from \"@cimplify/sdk/react\";\nimport { SlotPicker } from \"@cimplify/sdk/react\";\nimport { cn } from \"@cimplify/sdk/react\";\n\nexport interface DateSlotPickerClassNames {\n root?: string;\n dateStrip?: string;\n dateButton?: string;\n nav?: string;\n navButton?: string;\n slots?: string;\n loading?: string;\n}\n\nexport interface DateSlotPickerProps {\n /** Service ID to fetch availability and slots for. */\n serviceId: string;\n /** Number of days to show in the date strip. Default: 7. */\n daysToShow?: number;\n /** Number of participants. */\n participantCount?: number;\n /** Whole units needed — forwarded to availability so short days drop out. */\n units?: number;\n /** Currently selected slot. */\n selectedSlot?: AvailableSlot | null;\n /** Called when a slot is selected. */\n onSlotSelect?: (slot: AvailableSlot, date: string) => void;\n /** Pre-fetched availability data (skips fetch). */\n availability?: DayAvailability[];\n /** Show price on slots. Default: true. */\n showPrice?: boolean;\n /** Currency the slot prices are denominated in. */\n currency?: CurrencyCode;\n /** Forwarded to `<SlotPicker>` to render multi-day stay labels. */\n schedulingMode?: SchedulingMode;\n /** Forwarded to `<SlotPicker>` — unit for the stay summary in multi-day mode. */\n durationUnit?: DurationUnit;\n /** Forwarded to `<SlotPicker>` — value for the stay summary in multi-day mode. */\n durationValue?: number;\n /** Forwarded to `<SlotPicker>` — hide slots already in the past. Default: true. */\n hideElapsedSlots?: boolean;\n /** Forwarded to `<SlotPicker>` — minimum lead time in minutes. Default: 0. */\n minLeadMinutes?: number;\n /** Forwarded to `<SlotPicker>` — offered when a day has no bookable times. */\n contactPhone?: string;\n className?: string;\n classNames?: DateSlotPickerClassNames;\n}\n\nfunction formatDate(dateStr: string): string {\n const date = new Date(dateStr + \"T00:00:00\");\n return date.toLocaleDateString(undefined, { weekday: \"short\", month: \"short\", day: \"numeric\" });\n}\n\nfunction toDateString(date: Date): string {\n return date.toISOString().split(\"T\")[0];\n}\n\nfunction addDays(date: Date, days: number): Date {\n const result = new Date(date);\n result.setDate(result.getDate() + days);\n return result;\n}\n\nexport function DateSlotPicker({\n serviceId,\n daysToShow = 7,\n participantCount,\n units,\n selectedSlot,\n onSlotSelect,\n availability: availabilityProp,\n showPrice = true,\n currency,\n schedulingMode,\n durationUnit,\n durationValue,\n hideElapsedSlots = true,\n minLeadMinutes = 0,\n contactPhone,\n className,\n classNames,\n}: DateSlotPickerProps): React.ReactElement {\n const [offset, setOffset] = useState(0);\n const [selectedDate, setSelectedDate] = useState<string>(toDateString(new Date()));\n\n const dateRange = useMemo(() => {\n const today = new Date();\n const start = addDays(today, offset);\n const dates: string[] = [];\n for (let i = 0; i < daysToShow; i++) {\n dates.push(toDateString(addDays(start, i)));\n }\n return {\n dates,\n startDate: dates[0],\n endDate: dates[dates.length - 1],\n };\n }, [offset, daysToShow]);\n\n const { days: fetchedDays, isLoading: availabilityLoading } = useServiceAvailability(\n serviceId,\n dateRange.startDate,\n dateRange.endDate,\n {\n participantCount,\n units,\n enabled: availabilityProp === undefined,\n },\n );\n\n const days = availabilityProp ?? fetchedDays;\n\n const availabilityMap = useMemo(() => {\n const map = new Map<string, DayAvailability>();\n for (const day of days) {\n map.set(day.date, day);\n }\n return map;\n }, [days]);\n\n const handlePrev = useCallback(() => {\n setOffset((prev) => Math.max(0, prev - daysToShow));\n }, [daysToShow]);\n\n const handleNext = useCallback(() => {\n setOffset((prev) => prev + daysToShow);\n }, [daysToShow]);\n\n const handleDateChange = useCallback((value: string | number | null) => {\n if (typeof value === \"string\") {\n setSelectedDate(value);\n }\n }, []);\n\n const handleSlotSelect = useCallback(\n (slot: AvailableSlot) => {\n onSlotSelect?.(slot, selectedDate);\n },\n [onSlotSelect, selectedDate],\n );\n\n return (\n <Tabs.Root\n value={selectedDate}\n onValueChange={handleDateChange}\n data-cimplify-date-slot-picker\n className={cn(\"flex flex-col gap-4\", className, classNames?.root)}\n >\n <div\n data-cimplify-date-nav\n className={cn(\"flex items-center justify-end gap-2\", classNames?.nav)}\n >\n <button\n type=\"button\"\n onClick={handlePrev}\n disabled={offset === 0}\n aria-label=\"Previous dates\"\n data-cimplify-date-nav-prev\n className={cn(\n \"grid place-items-center w-8 h-8 rounded-md border border-border text-muted-foreground transition-colors hover:bg-muted hover:text-foreground disabled:cursor-not-allowed disabled:opacity-40\",\n classNames?.navButton,\n )}\n >\n &larr;\n </button>\n <button\n type=\"button\"\n onClick={handleNext}\n aria-label=\"Next dates\"\n data-cimplify-date-nav-next\n className={cn(\n \"grid place-items-center w-8 h-8 rounded-md border border-border text-muted-foreground transition-colors hover:bg-muted hover:text-foreground\",\n classNames?.navButton,\n )}\n >\n &rarr;\n </button>\n </div>\n\n <Tabs.List\n data-cimplify-date-strip\n className={cn(\"grid grid-cols-7 gap-1 sm:gap-2\", classNames?.dateStrip)}\n >\n {dateRange.dates.map((date) => {\n const dayInfo = availabilityMap.get(date);\n const hasAvailability = dayInfo?.has_availability !== false;\n const isSelected = selectedDate === date;\n return (\n <Tabs.Tab\n key={date}\n value={date}\n data-cimplify-date-button\n data-selected={isSelected || undefined}\n data-available={hasAvailability || undefined}\n data-fully-booked={(!hasAvailability) || undefined}\n className={cn(\n \"flex flex-col items-center justify-center rounded-md border border-border bg-background px-1 py-2 text-center text-xs font-medium text-foreground transition-colors hover:border-foreground/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring data-[selected]:border-foreground data-[selected]:bg-foreground data-[selected]:text-background data-[fully-booked]:cursor-not-allowed data-[fully-booked]:opacity-40\",\n classNames?.dateButton,\n )}\n >\n {formatDate(date)}\n </Tabs.Tab>\n );\n })}\n </Tabs.List>\n\n {availabilityLoading && (\n <div\n data-cimplify-date-slot-loading\n aria-busy=\"true\"\n className={cn(\"h-32 rounded-md bg-muted/40 animate-pulse\", classNames?.loading)}\n />\n )}\n\n <div data-cimplify-date-slots className={classNames?.slots}>\n <SlotPicker\n serviceId={serviceId}\n date={selectedDate}\n participantCount={participantCount}\n selectedSlot={selectedSlot}\n onSlotSelect={handleSlotSelect}\n showPrice={showPrice}\n currency={currency}\n schedulingMode={schedulingMode}\n durationUnit={durationUnit}\n durationValue={durationValue}\n hideElapsedSlots={hideElapsedSlots}\n minLeadMinutes={minLeadMinutes}\n contactPhone={contactPhone}\n />\n </div>\n </Tabs.Root>\n );\n}\n"
14
14
  }
15
15
  ]
16
16
  }
@@ -10,7 +10,7 @@
10
10
  "files": [
11
11
  {
12
12
  "path": "slot-picker.tsx",
13
- "content": "\"use client\";\n\nimport { Radio } from \"@base-ui/react/radio\";\nimport { RadioGroup } from \"@base-ui/react/radio-group\";\nimport React, { useMemo } from \"react\";\nimport type { AvailableSlot } from \"@cimplify/sdk\";\nimport type { DurationUnit, SchedulingMode } from \"@cimplify/sdk\";\nimport type { CurrencyCode } from \"@cimplify/sdk\";\nimport { useAvailableSlots } from \"@cimplify/sdk/react\";\nimport { Price } from \"@cimplify/sdk/react\";\nimport { cn } from \"@cimplify/sdk/react\";\n\nexport interface SlotPickerClassNames {\n root?: string;\n group?: string;\n groupLabel?: string;\n slot?: string;\n slotTime?: string;\n slotPrice?: string;\n slotScarcity?: string;\n loading?: string;\n empty?: string;\n}\n\nexport interface SlotPickerProps {\n /** Pre-fetched slots (skips fetch). */\n slots?: AvailableSlot[];\n /** Service ID — used to fetch slots when `slots` prop is not provided. */\n serviceId?: string;\n /** Date string (YYYY-MM-DD) — used to fetch slots when `slots` prop is not provided. */\n date?: string;\n /** Number of participants for capacity-based availability. */\n participantCount?: number;\n /** Currently selected slot. */\n selectedSlot?: AvailableSlot | null;\n /** Called when a slot is selected. */\n onSlotSelect?: (slot: AvailableSlot) => void;\n /** Whether to group slots by time of day. Default: true. Ignored when `schedulingMode` is `\"multi_day\"`. */\n groupByTimeOfDay?: boolean;\n /** Show price on each slot. Default: true. */\n showPrice?: boolean;\n /**\n * Show a \"N left\" urgency tag when a slot's remaining capacity is at or below\n * this number (and above zero). Slots at zero capacity render as sold out.\n * Default: 3. Set to 0 to disable scarcity tags.\n */\n lowCapacityThreshold?: number;\n /** Currency the slot prices are denominated in. */\n currency?: CurrencyCode;\n /**\n * Hide slots whose `start_time` is already in the past. Default: true.\n * Set to false to show elapsed slots greyed-out (still un-selectable).\n */\n hideElapsedSlots?: boolean;\n /**\n * Minimum lead time (in minutes) before a slot can be booked. Slots whose\n * start is sooner than `now + minLeadMinutes` are filtered out (when\n * `hideElapsedSlots` is true) or marked unavailable. Default: 0.\n */\n minLeadMinutes?: number;\n /**\n * Service scheduling mode. When `\"multi_day\"`, each slot renders as a\n * stay summary (`\"3 nights: Fri Apr 5, 3:00 PM → Mon Apr 8, 11:00 AM\"`)\n * instead of the time-of-day label. Defaults to `\"intraday\"`.\n */\n schedulingMode?: SchedulingMode;\n /** Service duration unit — used for the stay summary in multi-day mode. */\n durationUnit?: DurationUnit;\n /** Service duration value — used for the stay summary in multi-day mode. */\n durationValue?: number;\n /** Text shown when no slots available. */\n emptyMessage?: string;\n className?: string;\n classNames?: SlotPickerClassNames;\n}\n\ninterface SlotGroup {\n label: string;\n slots: AvailableSlot[];\n}\n\nfunction getTimeOfDay(timeStr: string): \"morning\" | \"afternoon\" | \"evening\" {\n const hour = parseInt(timeStr.split(\"T\").pop()?.split(\":\")[0] ?? timeStr.split(\":\")[0], 10);\n if (hour < 12) return \"morning\";\n if (hour < 17) return \"afternoon\";\n return \"evening\";\n}\n\nconst TIME_OF_DAY_LABELS: Record<string, string> = {\n morning: \"Morning\",\n afternoon: \"Afternoon\",\n evening: \"Evening\",\n};\n\nfunction groupSlots(slots: AvailableSlot[]): SlotGroup[] {\n const groups: Record<string, AvailableSlot[]> = {};\n for (const slot of slots) {\n const tod = getTimeOfDay(slot.start_time);\n if (!groups[tod]) groups[tod] = [];\n groups[tod].push(slot);\n }\n return ([\"morning\", \"afternoon\", \"evening\"] as const)\n .filter((tod) => groups[tod]?.length)\n .map((tod) => ({ label: TIME_OF_DAY_LABELS[tod], slots: groups[tod] }));\n}\n\nfunction formatTime(timeStr: string): string {\n try {\n const date = new Date(timeStr);\n if (!isNaN(date.getTime())) {\n return date.toLocaleTimeString(undefined, { hour: \"numeric\", minute: \"2-digit\" });\n }\n } catch {\n // noop\n }\n\n const parts = timeStr.split(\":\");\n if (parts.length >= 2) {\n const hour = parseInt(parts[0], 10);\n const minute = parts[1];\n const ampm = hour >= 12 ? \"PM\" : \"AM\";\n const displayHour = hour % 12 || 12;\n return `${displayHour}:${minute} ${ampm}`;\n }\n return timeStr;\n}\n\nfunction pluralizeUnit(unit: DurationUnit | undefined, value: number | undefined): string {\n if (!unit) return value === 1 ? \"day\" : \"days\";\n const v = value ?? 1;\n if (unit === \"minutes\") return v === 1 ? \"minute\" : \"minutes\";\n if (unit === \"hours\") return v === 1 ? \"hour\" : \"hours\";\n if (unit === \"days\") return v === 1 ? \"day\" : \"days\";\n if (unit === \"weeks\") return v === 1 ? \"week\" : \"weeks\";\n if (unit === \"months\") return v === 1 ? \"month\" : \"months\";\n return unit;\n}\n\nfunction formatStaySummary(\n slot: AvailableSlot,\n durationUnit: DurationUnit | undefined,\n durationValue: number | undefined,\n): string {\n const start = new Date(slot.start_time);\n const end = new Date(slot.end_time);\n const startLabel = start.toLocaleString(undefined, {\n weekday: \"short\",\n month: \"short\",\n day: \"numeric\",\n hour: \"numeric\",\n minute: \"2-digit\",\n });\n const endLabel = end.toLocaleString(undefined, {\n weekday: \"short\",\n month: \"short\",\n day: \"numeric\",\n hour: \"numeric\",\n minute: \"2-digit\",\n });\n const unitLabel = pluralizeUnit(durationUnit, durationValue);\n if (durationValue !== undefined) {\n return `${durationValue} ${unitLabel}: ${startLabel} → ${endLabel}`;\n }\n return `${startLabel} → ${endLabel}`;\n}\n\nfunction slotToValue(slot: AvailableSlot): string {\n return `${slot.start_time}|${slot.end_time}`;\n}\n\nexport function SlotPicker({\n slots: slotsProp,\n serviceId,\n date,\n participantCount,\n selectedSlot,\n onSlotSelect,\n groupByTimeOfDay = true,\n showPrice = true,\n lowCapacityThreshold = 3,\n currency,\n schedulingMode = \"intraday\",\n durationUnit,\n durationValue,\n hideElapsedSlots = true,\n minLeadMinutes = 0,\n emptyMessage = \"No available slots\",\n className,\n classNames,\n}: SlotPickerProps): React.ReactElement {\n const isMultiDay = schedulingMode === \"multi_day\";\n const { slots: fetched, isLoading } = useAvailableSlots(\n serviceId ?? null,\n date ?? null,\n {\n participantCount,\n enabled: slotsProp === undefined && !!serviceId && !!date,\n },\n );\n\n const rawSlots = slotsProp ?? fetched;\n // Drop slots that have already elapsed (or fall within the lead-time\n // window). Default behaviour because nothing the merchant can do at\n // the backend stops a client clock from being slightly ahead of the\n // last availability response — this is the same defence other\n // booking flows ship by default.\n const slots = useMemo(() => {\n if (!hideElapsedSlots) return rawSlots;\n const cutoff = Date.now() + minLeadMinutes * 60_000;\n return rawSlots.filter((slot) => {\n const start = Date.parse(slot.start_time);\n return Number.isNaN(start) || start >= cutoff;\n });\n }, [rawSlots, hideElapsedSlots, minLeadMinutes]);\n\n if (isLoading && slots.length === 0) {\n return (\n <div\n data-cimplify-slot-picker\n aria-busy=\"true\"\n className={cn(className, classNames?.root, classNames?.loading)}\n />\n );\n }\n\n if (slots.length === 0) {\n return (\n <div\n data-cimplify-slot-picker\n data-empty\n className={cn(className, classNames?.root, classNames?.empty)}\n >\n <p>{emptyMessage}</p>\n </div>\n );\n }\n\n const groups = groupByTimeOfDay && !isMultiDay\n ? groupSlots(slots)\n : [{ label: \"\", slots }];\n\n const slotsByValue = new Map<string, AvailableSlot>();\n for (const slot of slots) {\n slotsByValue.set(slotToValue(slot), slot);\n }\n\n const selectedValue = selectedSlot ? slotToValue(selectedSlot) : \"\";\n\n return (\n <RadioGroup\n data-cimplify-slot-picker\n className={cn(\"flex flex-col gap-4\", className, classNames?.root)}\n value={selectedValue}\n onValueChange={(value: string) => {\n const slot = slotsByValue.get(value);\n // Slots default to available; treat as unavailable only when the\n // backend explicitly returns `is_available: false`.\n if (slot && slot.is_available !== false) {\n onSlotSelect?.(slot);\n }\n }}\n >\n {groups.map((group) => (\n <div\n key={group.label || \"all\"}\n data-cimplify-slot-group\n className={cn(\"flex flex-col gap-2\", classNames?.group)}\n >\n {group.label && (\n <div\n data-cimplify-slot-group-label\n className={cn(\n \"text-xs font-medium uppercase tracking-[0.12em] text-muted-foreground\",\n classNames?.groupLabel,\n )}\n >\n {group.label}\n </div>\n )}\n <div\n className={cn(\n isMultiDay\n ? \"flex flex-col gap-2\"\n : \"grid grid-cols-3 sm:grid-cols-4 gap-2\",\n )}\n >\n {group.slots.map((slot) => {\n const value = slotToValue(slot);\n const isSelected =\n selectedSlot?.start_time === slot.start_time &&\n selectedSlot?.end_time === slot.end_time;\n const capacity = slot.capacity_available ?? slot.remaining_capacity;\n const soldOut = capacity === 0;\n const unavailable = slot.is_available === false || soldOut;\n const lowCapacity =\n lowCapacityThreshold > 0 &&\n capacity != null &&\n capacity > 0 &&\n capacity <= lowCapacityThreshold;\n return (\n <Radio.Root\n key={value}\n value={value}\n disabled={unavailable}\n data-cimplify-slot\n data-selected={isSelected || undefined}\n data-unavailable={unavailable || undefined}\n className={cn(\n \"inline-flex items-center justify-center gap-2 rounded-md border border-border bg-background px-3 py-2 text-sm font-medium text-foreground transition-colors hover:border-foreground/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring data-[selected]:border-foreground data-[selected]:bg-foreground data-[selected]:text-background data-[unavailable]:cursor-not-allowed data-[unavailable]:opacity-40 data-[unavailable]:line-through\",\n isMultiDay && \"justify-between text-left\",\n classNames?.slot,\n )}\n >\n <span data-cimplify-slot-time className={classNames?.slotTime}>\n {isMultiDay\n ? formatStaySummary(slot, durationUnit, durationValue)\n : formatTime(slot.start_time)}\n </span>\n {showPrice && slot.price && (\n <span\n data-cimplify-slot-price\n className={cn(\"text-xs opacity-70\", classNames?.slotPrice)}\n >\n <Price amount={slot.price} currency={currency} />\n </span>\n )}\n {lowCapacity && (\n <span\n data-cimplify-slot-scarcity\n className={cn(\"text-xs font-medium text-amber-600\", classNames?.slotScarcity)}\n >\n {capacity} left\n </span>\n )}\n </Radio.Root>\n );\n })}\n </div>\n </div>\n ))}\n </RadioGroup>\n );\n}\n"
13
+ "content": "\"use client\";\n\nimport { Radio } from \"@base-ui/react/radio\";\nimport { RadioGroup } from \"@base-ui/react/radio-group\";\nimport React, { useMemo } from \"react\";\nimport type { AvailableSlot } from \"@cimplify/sdk\";\nimport type { DurationUnit, SchedulingMode } from \"@cimplify/sdk\";\nimport type { CurrencyCode } from \"@cimplify/sdk\";\nimport { useAvailableSlots } from \"@cimplify/sdk/react\";\nimport { Price } from \"@cimplify/sdk/react\";\nimport { cn } from \"@cimplify/sdk/react\";\n\nexport interface SlotPickerClassNames {\n root?: string;\n group?: string;\n groupLabel?: string;\n slot?: string;\n slotTime?: string;\n slotPrice?: string;\n slotScarcity?: string;\n loading?: string;\n empty?: string;\n}\n\nexport interface SlotPickerProps {\n /** Pre-fetched slots (skips fetch). */\n slots?: AvailableSlot[];\n /** Service ID — used to fetch slots when `slots` prop is not provided. */\n serviceId?: string;\n /** Date string (YYYY-MM-DD) — used to fetch slots when `slots` prop is not provided. */\n date?: string;\n /** Number of participants for capacity-based availability. */\n participantCount?: number;\n /** Currently selected slot. */\n selectedSlot?: AvailableSlot | null;\n /** Called when a slot is selected. */\n onSlotSelect?: (slot: AvailableSlot) => void;\n /** Whether to group slots by time of day. Default: true. Ignored when `schedulingMode` is `\"multi_day\"`. */\n groupByTimeOfDay?: boolean;\n /** Show price on each slot. Default: true. */\n showPrice?: boolean;\n /**\n * Show a \"N left\" urgency tag when a slot's remaining capacity is at or below\n * this number (and above zero). Slots at zero capacity render as sold out.\n * Default: 3. Set to 0 to disable scarcity tags.\n */\n lowCapacityThreshold?: number;\n /** Currency the slot prices are denominated in. */\n currency?: CurrencyCode;\n /**\n * Hide slots whose `start_time` is already in the past. Default: true.\n * Set to false to show elapsed slots greyed-out (still un-selectable).\n */\n hideElapsedSlots?: boolean;\n /**\n * Minimum lead time (in minutes) before a slot can be booked. Slots whose\n * start is sooner than `now + minLeadMinutes` are filtered out (when\n * `hideElapsedSlots` is true) or marked unavailable. Default: 0.\n */\n minLeadMinutes?: number;\n /**\n * Service scheduling mode. When `\"multi_day\"`, each slot renders as a\n * stay summary (`\"3 nights: Fri Apr 5, 3:00 PM → Mon Apr 8, 11:00 AM\"`)\n * instead of the time-of-day label. Defaults to `\"intraday\"`.\n */\n schedulingMode?: SchedulingMode;\n /** Service duration unit — used for the stay summary in multi-day mode. */\n durationUnit?: DurationUnit;\n /** Service duration value — used for the stay summary in multi-day mode. */\n durationValue?: number;\n /** Text shown when no slots available. */\n emptyMessage?: string;\n /**\n * Phone number offered when a day has no bookable times. A service can be\n * unbookable for reasons the storefront cannot see, and a bare empty grid\n * reads as a broken site rather than a shop to call.\n */\n contactPhone?: string;\n className?: string;\n classNames?: SlotPickerClassNames;\n}\n\ninterface SlotGroup {\n label: string;\n slots: AvailableSlot[];\n}\n\nfunction getTimeOfDay(timeStr: string): \"morning\" | \"afternoon\" | \"evening\" {\n const hour = parseInt(timeStr.split(\"T\").pop()?.split(\":\")[0] ?? timeStr.split(\":\")[0], 10);\n if (hour < 12) return \"morning\";\n if (hour < 17) return \"afternoon\";\n return \"evening\";\n}\n\nconst TIME_OF_DAY_LABELS: Record<string, string> = {\n morning: \"Morning\",\n afternoon: \"Afternoon\",\n evening: \"Evening\",\n};\n\nfunction groupSlots(slots: AvailableSlot[]): SlotGroup[] {\n const groups: Record<string, AvailableSlot[]> = {};\n for (const slot of slots) {\n const tod = getTimeOfDay(slot.start_time);\n if (!groups[tod]) groups[tod] = [];\n groups[tod].push(slot);\n }\n return ([\"morning\", \"afternoon\", \"evening\"] as const)\n .filter((tod) => groups[tod]?.length)\n .map((tod) => ({ label: TIME_OF_DAY_LABELS[tod], slots: groups[tod] }));\n}\n\nfunction formatTime(timeStr: string): string {\n try {\n const date = new Date(timeStr);\n if (!isNaN(date.getTime())) {\n return date.toLocaleTimeString(undefined, { hour: \"numeric\", minute: \"2-digit\" });\n }\n } catch {\n // noop\n }\n\n const parts = timeStr.split(\":\");\n if (parts.length >= 2) {\n const hour = parseInt(parts[0], 10);\n const minute = parts[1];\n const ampm = hour >= 12 ? \"PM\" : \"AM\";\n const displayHour = hour % 12 || 12;\n return `${displayHour}:${minute} ${ampm}`;\n }\n return timeStr;\n}\n\nfunction pluralizeUnit(unit: DurationUnit | undefined, value: number | undefined): string {\n if (!unit) return value === 1 ? \"day\" : \"days\";\n const v = value ?? 1;\n if (unit === \"minutes\") return v === 1 ? \"minute\" : \"minutes\";\n if (unit === \"hours\") return v === 1 ? \"hour\" : \"hours\";\n if (unit === \"days\") return v === 1 ? \"day\" : \"days\";\n if (unit === \"weeks\") return v === 1 ? \"week\" : \"weeks\";\n if (unit === \"months\") return v === 1 ? \"month\" : \"months\";\n return unit;\n}\n\nfunction formatStaySummary(\n slot: AvailableSlot,\n durationUnit: DurationUnit | undefined,\n durationValue: number | undefined,\n): string {\n const start = new Date(slot.start_time);\n const end = new Date(slot.end_time);\n const startLabel = start.toLocaleString(undefined, {\n weekday: \"short\",\n month: \"short\",\n day: \"numeric\",\n hour: \"numeric\",\n minute: \"2-digit\",\n });\n const endLabel = end.toLocaleString(undefined, {\n weekday: \"short\",\n month: \"short\",\n day: \"numeric\",\n hour: \"numeric\",\n minute: \"2-digit\",\n });\n const unitLabel = pluralizeUnit(durationUnit, durationValue);\n if (durationValue !== undefined) {\n return `${durationValue} ${unitLabel}: ${startLabel} → ${endLabel}`;\n }\n return `${startLabel} → ${endLabel}`;\n}\n\nfunction slotToValue(slot: AvailableSlot): string {\n return `${slot.start_time}|${slot.end_time}`;\n}\n\nexport function SlotPicker({\n slots: slotsProp,\n serviceId,\n date,\n participantCount,\n selectedSlot,\n onSlotSelect,\n groupByTimeOfDay = true,\n showPrice = true,\n lowCapacityThreshold = 3,\n currency,\n schedulingMode = \"intraday\",\n durationUnit,\n durationValue,\n hideElapsedSlots = true,\n minLeadMinutes = 0,\n emptyMessage = \"No available slots\",\n contactPhone,\n className,\n classNames,\n}: SlotPickerProps): React.ReactElement {\n const isMultiDay = schedulingMode === \"multi_day\";\n const { slots: fetched, isLoading } = useAvailableSlots(\n serviceId ?? null,\n date ?? null,\n {\n participantCount,\n enabled: slotsProp === undefined && !!serviceId && !!date,\n },\n );\n\n const rawSlots = slotsProp ?? fetched;\n // Drop slots that have already elapsed (or fall within the lead-time\n // window). Default behaviour because nothing the merchant can do at\n // the backend stops a client clock from being slightly ahead of the\n // last availability response — this is the same defence other\n // booking flows ship by default.\n const slots = useMemo(() => {\n if (!hideElapsedSlots) return rawSlots;\n const cutoff = Date.now() + minLeadMinutes * 60_000;\n return rawSlots.filter((slot) => {\n const start = Date.parse(slot.start_time);\n return Number.isNaN(start) || start >= cutoff;\n });\n }, [rawSlots, hideElapsedSlots, minLeadMinutes]);\n\n if (isLoading && slots.length === 0) {\n return (\n <div\n data-cimplify-slot-picker\n aria-busy=\"true\"\n className={cn(className, classNames?.root, classNames?.loading)}\n />\n );\n }\n\n if (slots.length === 0) {\n return (\n <div\n data-cimplify-slot-picker\n data-empty\n className={cn(className, classNames?.root, classNames?.empty)}\n >\n <p>{emptyMessage}</p>\n {contactPhone ? (\n <p>\n <a href={`tel:${contactPhone.replace(/\\s+/g, \"\")}`}>Call {contactPhone} to book</a>\n </p>\n ) : null}\n </div>\n );\n }\n\n const groups = groupByTimeOfDay && !isMultiDay\n ? groupSlots(slots)\n : [{ label: \"\", slots }];\n\n const slotsByValue = new Map<string, AvailableSlot>();\n for (const slot of slots) {\n slotsByValue.set(slotToValue(slot), slot);\n }\n\n const selectedValue = selectedSlot ? slotToValue(selectedSlot) : \"\";\n\n return (\n <RadioGroup\n data-cimplify-slot-picker\n className={cn(\"flex flex-col gap-4\", className, classNames?.root)}\n value={selectedValue}\n onValueChange={(value: string) => {\n const slot = slotsByValue.get(value);\n // Slots default to available; treat as unavailable only when the\n // backend explicitly returns `is_available: false`.\n if (slot && slot.is_available !== false) {\n onSlotSelect?.(slot);\n }\n }}\n >\n {groups.map((group) => (\n <div\n key={group.label || \"all\"}\n data-cimplify-slot-group\n className={cn(\"flex flex-col gap-2\", classNames?.group)}\n >\n {group.label && (\n <div\n data-cimplify-slot-group-label\n className={cn(\n \"text-xs font-medium uppercase tracking-[0.12em] text-muted-foreground\",\n classNames?.groupLabel,\n )}\n >\n {group.label}\n </div>\n )}\n <div\n className={cn(\n isMultiDay\n ? \"flex flex-col gap-2\"\n : \"grid grid-cols-3 sm:grid-cols-4 gap-2\",\n )}\n >\n {group.slots.map((slot) => {\n const value = slotToValue(slot);\n const isSelected =\n selectedSlot?.start_time === slot.start_time &&\n selectedSlot?.end_time === slot.end_time;\n const capacity = slot.capacity_available ?? slot.remaining_capacity;\n const soldOut = capacity === 0;\n const unavailable = slot.is_available === false || soldOut;\n const lowCapacity =\n lowCapacityThreshold > 0 &&\n capacity != null &&\n capacity > 0 &&\n capacity <= lowCapacityThreshold;\n return (\n <Radio.Root\n key={value}\n value={value}\n disabled={unavailable}\n data-cimplify-slot\n data-selected={isSelected || undefined}\n data-unavailable={unavailable || undefined}\n className={cn(\n \"inline-flex items-center justify-center gap-2 rounded-md border border-border bg-background px-3 py-2 text-sm font-medium text-foreground transition-colors hover:border-foreground/40 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring data-[selected]:border-foreground data-[selected]:bg-foreground data-[selected]:text-background data-[unavailable]:cursor-not-allowed data-[unavailable]:opacity-40 data-[unavailable]:line-through\",\n isMultiDay && \"justify-between text-left\",\n classNames?.slot,\n )}\n >\n <span data-cimplify-slot-time className={classNames?.slotTime}>\n {isMultiDay\n ? formatStaySummary(slot, durationUnit, durationValue)\n : formatTime(slot.start_time)}\n </span>\n {showPrice && slot.price && (\n <span\n data-cimplify-slot-price\n className={cn(\"text-xs opacity-70\", classNames?.slotPrice)}\n >\n <Price amount={slot.price} currency={currency} />\n </span>\n )}\n {lowCapacity && (\n <span\n data-cimplify-slot-scarcity\n className={cn(\"text-xs font-medium text-amber-600\", classNames?.slotScarcity)}\n >\n {capacity} left\n </span>\n )}\n </Radio.Root>\n );\n })}\n </div>\n </div>\n ))}\n </RadioGroup>\n );\n}\n"
14
14
  }
15
15
  ]
16
16
  }