@classytic/cart 0.1.0 → 0.1.1

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 (32) hide show
  1. package/README.md +1 -10
  2. package/dist/{create-cart-q3CXxPP7.mjs → create-cart-DRYSw5Bj.mjs} +585 -539
  3. package/dist/domain/errors/index.d.mts +1 -1
  4. package/dist/domain/errors/index.mjs +2 -2
  5. package/dist/domain/events/index.mjs +1 -1
  6. package/dist/domain/index.d.mts +8 -8
  7. package/dist/domain/index.mjs +5 -5
  8. package/dist/domain/ports/index.d.mts +2 -2
  9. package/dist/domain/saga/index.d.mts +2 -2
  10. package/dist/domain/saga/index.mjs +2 -2
  11. package/dist/engine/index.d.mts +1 -1
  12. package/dist/engine/index.mjs +1 -1
  13. package/dist/{errors-CHR9RlbY.mjs → errors-iFWUnl8m.mjs} +26 -26
  14. package/dist/{index-Doi5uzux.d.mts → index-PD-kf5pR.d.mts} +67 -67
  15. package/dist/index.d.mts +70 -55
  16. package/dist/index.mjs +44 -44
  17. package/dist/{internal-event-bus-IkUfQJxn.d.mts → internal-event-bus-BGcwAeqK.d.mts} +108 -83
  18. package/dist/{line-item.entity-B3M_i-pw.d.mts → kind-registry-CqOJHV-2.d.mts} +52 -52
  19. package/dist/kinds/index.d.mts +1 -1
  20. package/dist/kinds/index.mjs +1 -1
  21. package/dist/{line-kind-Bndo6IS8.d.mts → line-kind-DOYygKG4.d.mts} +1 -1
  22. package/dist/{cart-event-catalog-BOP9aDhL.mjs → outbox-store-bP30uBXd.mjs} +30 -30
  23. package/dist/{idempotency-record.entity-DIFXjN1V.d.mts → reservation.entity-gmeCFe8a.d.mts} +71 -71
  24. package/dist/{saga-steps-B27LI7xp.mjs → saga-steps-aP8iTHT3.mjs} +1 -2
  25. package/dist/{shipping.bridge-DD4A_O0O.d.mts → shipping.bridge-_VwuKCSE.d.mts} +82 -82
  26. package/dist/{not-found.error-B6WYnAjX.mjs → state-transition.error-CML7cQSd.mjs} +22 -22
  27. package/dist/{saga-step-fn-Cyob38iU.d.mts → state-transitions-CbPYzeca.d.mts} +20 -29
  28. package/dist/{bundle.kind-DFydSxV_.mjs → variant.kind-BpEzENX-.mjs} +132 -132
  29. package/dist/{bundle.kind-BdgnyKZt.d.mts → variant.kind-CCwwWAB6.d.mts} +51 -51
  30. package/package.json +12 -5
  31. /package/dist/{id.port-DPXLrqb2.d.mts → id.port-CpYO7sc1.d.mts} +0 -0
  32. /package/dist/{index-DEHBdV_z.d.mts → index-DNLi60D-.d.mts} +0 -0
@@ -1,25 +1,34 @@
1
1
  import { t as KindError } from "./kind.error-CCjTB6kW.mjs";
2
2
  import { z } from "zod";
3
- //#region src/kinds/sku.kind.ts
4
- const skuPayloadSchema = z.object({ skuRef: z.string().min(1) });
5
- const skuKind = {
6
- name: "sku",
7
- payloadSchema: skuPayloadSchema,
8
- validity: { onStale: "extend" },
3
+ //#region src/kinds/bundle.kind.ts
4
+ const bundlePayloadSchema = z.object({
5
+ bundleRef: z.string().min(1),
6
+ components: z.array(z.object({
7
+ skuRef: z.string().min(1),
8
+ quantity: z.number().int().min(1)
9
+ })).min(1)
10
+ });
11
+ const bundleKind = {
12
+ name: "bundle",
13
+ payloadSchema: bundlePayloadSchema,
14
+ validity: {
15
+ maxAgeMs: 900 * 1e3,
16
+ onStale: "reprice"
17
+ },
9
18
  async validate(line, ctx) {
10
- const parsed = skuPayloadSchema.safeParse(line.payload);
11
- if (!parsed.success) throw new KindError(this.name, "invalid payload shape", { details: { issues: parsed.error.issues } });
19
+ const parsed = bundlePayloadSchema.safeParse(line.payload);
20
+ if (!parsed.success) throw new KindError(this.name, "invalid bundle payload", { details: { issues: parsed.error.issues } });
12
21
  if (line.quantity < 1) throw new KindError(this.name, `quantity must be >= 1, got ${line.quantity}`);
13
- const product = await ctx.bridges.catalog.resolve(parsed.data.skuRef, ctx);
14
- if (!product) throw new KindError(this.name, `unknown skuRef: ${parsed.data.skuRef}`);
15
- if (!product.purchasable) throw new KindError(this.name, `product ${parsed.data.skuRef} is not purchasable`);
22
+ const bundle = await ctx.bridges.catalog.resolve(parsed.data.bundleRef, ctx);
23
+ if (!bundle) throw new KindError(this.name, `unknown bundle: ${parsed.data.bundleRef}`);
24
+ if (!bundle.purchasable) throw new KindError(this.name, `bundle ${parsed.data.bundleRef} is not purchasable`);
16
25
  },
17
26
  async price(line, ctx) {
18
27
  const typed = line;
19
- const product = await ctx.bridges.catalog.resolve(typed.payload.skuRef, ctx);
20
- if (!product) throw new KindError(this.name, `price() called on unknown skuRef: ${typed.payload.skuRef}`);
21
- const unitPrice = typed.overrideUnitPrice ?? product.unitPrice;
22
- const lineTotal = {
28
+ const bundle = await ctx.bridges.catalog.resolve(typed.payload.bundleRef, ctx);
29
+ if (!bundle) throw new KindError(this.name, `price() on unknown bundle: ${typed.payload.bundleRef}`);
30
+ const unitPrice = typed.overrideUnitPrice ?? bundle.unitPrice;
31
+ const total = {
23
32
  amount: unitPrice.amount * typed.quantity,
24
33
  currency: unitPrice.currency
25
34
  };
@@ -28,9 +37,9 @@ const skuKind = {
28
37
  unitPrice,
29
38
  quantity: typed.quantity,
30
39
  subtotals: {
31
- prePromo: lineTotal,
32
- postPromo: lineTotal,
33
- postPromoPostTax: lineTotal
40
+ prePromo: total,
41
+ postPromo: total,
42
+ postPromoPostTax: total
34
43
  },
35
44
  discountTotal: {
36
45
  amount: 0,
@@ -40,61 +49,86 @@ const skuKind = {
40
49
  amount: 0,
41
50
  currency: unitPrice.currency
42
51
  },
43
- validUntil: null
52
+ validUntil: new Date(Date.now() + 900 * 1e3),
53
+ kindMeta: {
54
+ bundleRef: typed.payload.bundleRef,
55
+ componentCount: typed.payload.components.length
56
+ }
44
57
  };
45
58
  },
46
- async revalidate(_line, priced) {
59
+ async revalidate(line, priced, ctx) {
60
+ const typed = line;
61
+ const bundle = await ctx.bridges.catalog.resolve(typed.payload.bundleRef, ctx);
62
+ if (!bundle) return {
63
+ status: "invalid",
64
+ reason: "bundle no longer exists"
65
+ };
66
+ const currentPrice = bundle.unitPrice.amount;
67
+ const snapshotPrice = priced.unitPrice.amount;
68
+ if (currentPrice !== snapshotPrice) {
69
+ const delta = {
70
+ amount: (currentPrice - snapshotPrice) * typed.quantity,
71
+ currency: priced.unitPrice.currency
72
+ };
73
+ const newTotal = {
74
+ amount: currentPrice * typed.quantity,
75
+ currency: priced.unitPrice.currency
76
+ };
77
+ return {
78
+ status: "reprice",
79
+ priced: {
80
+ ...priced,
81
+ unitPrice: {
82
+ amount: currentPrice,
83
+ currency: priced.unitPrice.currency
84
+ },
85
+ subtotals: {
86
+ prePromo: newTotal,
87
+ postPromo: newTotal,
88
+ postPromoPostTax: newTotal
89
+ },
90
+ validUntil: new Date(Date.now() + 900 * 1e3)
91
+ },
92
+ delta
93
+ };
94
+ }
47
95
  return {
48
96
  status: "unchanged",
49
97
  priced
50
98
  };
51
99
  },
52
- mergeKey(line) {
53
- const typed = line;
54
- if (!typed.payload?.skuRef) return null;
55
- return `sku:${typed.payload.skuRef}`;
56
- },
57
- /**
58
- * Populate the display snapshot at add-time. Called by the draft
59
- * service; the resulting snapshot is stored on `LineItem.display` so
60
- * the UI renders the cart directly without a second catalog call.
61
- */
62
100
  async displayOf(line, ctx) {
63
101
  const typed = line;
64
- const product = await ctx.bridges.catalog.resolve(typed.payload.skuRef, ctx);
65
- if (!product) return null;
102
+ const bundle = await ctx.bridges.catalog.resolve(typed.payload.bundleRef, ctx);
103
+ if (!bundle) return null;
66
104
  return {
67
- name: product.name,
68
- imageUrl: product.primaryImage,
69
- slug: product.slug,
70
- variantLabel: product.variantLabel,
71
- compareAtPrice: product.compareAtPrice,
72
- capturedAt: ctx.bridges ? /* @__PURE__ */ new Date() : /* @__PURE__ */ new Date()
105
+ name: bundle.name,
106
+ imageUrl: bundle.primaryImage,
107
+ slug: bundle.slug,
108
+ variantLabel: `${typed.payload.components.length} items`,
109
+ capturedAt: /* @__PURE__ */ new Date()
73
110
  };
74
111
  }
75
112
  };
76
113
  //#endregion
77
- //#region src/kinds/variant.kind.ts
78
- const variantPayloadSchema = z.object({
79
- productRef: z.string().min(1),
80
- variantSku: z.string().min(1)
81
- });
82
- const variantKind = {
83
- name: "variant",
84
- payloadSchema: variantPayloadSchema,
114
+ //#region src/kinds/sku.kind.ts
115
+ const skuPayloadSchema = z.object({ skuRef: z.string().min(1) });
116
+ const skuKind = {
117
+ name: "sku",
118
+ payloadSchema: skuPayloadSchema,
85
119
  validity: { onStale: "extend" },
86
120
  async validate(line, ctx) {
87
- const parsed = variantPayloadSchema.safeParse(line.payload);
88
- if (!parsed.success) throw new KindError(this.name, "invalid variant payload", { details: { issues: parsed.error.issues } });
121
+ const parsed = skuPayloadSchema.safeParse(line.payload);
122
+ if (!parsed.success) throw new KindError(this.name, "invalid payload shape", { details: { issues: parsed.error.issues } });
89
123
  if (line.quantity < 1) throw new KindError(this.name, `quantity must be >= 1, got ${line.quantity}`);
90
- const product = await ctx.bridges.catalog.resolve(parsed.data.variantSku, ctx);
91
- if (!product) throw new KindError(this.name, `unknown variant SKU: ${parsed.data.variantSku}`);
92
- if (!product.purchasable) throw new KindError(this.name, `variant ${parsed.data.variantSku} is not purchasable`);
124
+ const product = await ctx.bridges.catalog.resolve(parsed.data.skuRef, ctx);
125
+ if (!product) throw new KindError(this.name, `unknown skuRef: ${parsed.data.skuRef}`);
126
+ if (!product.purchasable) throw new KindError(this.name, `product ${parsed.data.skuRef} is not purchasable`);
93
127
  },
94
128
  async price(line, ctx) {
95
129
  const typed = line;
96
- const product = await ctx.bridges.catalog.resolve(typed.payload.variantSku, ctx);
97
- if (!product) throw new KindError(this.name, `price() on unknown variant: ${typed.payload.variantSku}`);
130
+ const product = await ctx.bridges.catalog.resolve(typed.payload.skuRef, ctx);
131
+ if (!product) throw new KindError(this.name, `price() called on unknown skuRef: ${typed.payload.skuRef}`);
98
132
  const unitPrice = typed.overrideUnitPrice ?? product.unitPrice;
99
133
  const lineTotal = {
100
134
  amount: unitPrice.amount * typed.quantity,
@@ -127,13 +161,18 @@ const variantKind = {
127
161
  };
128
162
  },
129
163
  mergeKey(line) {
130
- const { productRef, variantSku } = line.payload ?? {};
131
- if (!productRef || !variantSku) return null;
132
- return `variant:${productRef}:${variantSku}`;
164
+ const typed = line;
165
+ if (!typed.payload?.skuRef) return null;
166
+ return `sku:${typed.payload.skuRef}`;
133
167
  },
168
+ /**
169
+ * Populate the display snapshot at add-time. Called by the draft
170
+ * service; the resulting snapshot is stored on `LineItem.display` so
171
+ * the UI renders the cart directly without a second catalog call.
172
+ */
134
173
  async displayOf(line, ctx) {
135
174
  const typed = line;
136
- const product = await ctx.bridges.catalog.resolve(typed.payload.variantSku, ctx);
175
+ const product = await ctx.bridges.catalog.resolve(typed.payload.skuRef, ctx);
137
176
  if (!product) return null;
138
177
  return {
139
178
  name: product.name,
@@ -141,7 +180,7 @@ const variantKind = {
141
180
  slug: product.slug,
142
181
  variantLabel: product.variantLabel,
143
182
  compareAtPrice: product.compareAtPrice,
144
- capturedAt: /* @__PURE__ */ new Date()
183
+ capturedAt: ctx.bridges ? /* @__PURE__ */ new Date() : /* @__PURE__ */ new Date()
145
184
  };
146
185
  }
147
186
  };
@@ -248,35 +287,29 @@ const timeslotKind = {
248
287
  }
249
288
  };
250
289
  //#endregion
251
- //#region src/kinds/bundle.kind.ts
252
- const bundlePayloadSchema = z.object({
253
- bundleRef: z.string().min(1),
254
- components: z.array(z.object({
255
- skuRef: z.string().min(1),
256
- quantity: z.number().int().min(1)
257
- })).min(1)
290
+ //#region src/kinds/variant.kind.ts
291
+ const variantPayloadSchema = z.object({
292
+ productRef: z.string().min(1),
293
+ variantSku: z.string().min(1)
258
294
  });
259
- const bundleKind = {
260
- name: "bundle",
261
- payloadSchema: bundlePayloadSchema,
262
- validity: {
263
- maxAgeMs: 900 * 1e3,
264
- onStale: "reprice"
265
- },
295
+ const variantKind = {
296
+ name: "variant",
297
+ payloadSchema: variantPayloadSchema,
298
+ validity: { onStale: "extend" },
266
299
  async validate(line, ctx) {
267
- const parsed = bundlePayloadSchema.safeParse(line.payload);
268
- if (!parsed.success) throw new KindError(this.name, "invalid bundle payload", { details: { issues: parsed.error.issues } });
300
+ const parsed = variantPayloadSchema.safeParse(line.payload);
301
+ if (!parsed.success) throw new KindError(this.name, "invalid variant payload", { details: { issues: parsed.error.issues } });
269
302
  if (line.quantity < 1) throw new KindError(this.name, `quantity must be >= 1, got ${line.quantity}`);
270
- const bundle = await ctx.bridges.catalog.resolve(parsed.data.bundleRef, ctx);
271
- if (!bundle) throw new KindError(this.name, `unknown bundle: ${parsed.data.bundleRef}`);
272
- if (!bundle.purchasable) throw new KindError(this.name, `bundle ${parsed.data.bundleRef} is not purchasable`);
303
+ const product = await ctx.bridges.catalog.resolve(parsed.data.variantSku, ctx);
304
+ if (!product) throw new KindError(this.name, `unknown variant SKU: ${parsed.data.variantSku}`);
305
+ if (!product.purchasable) throw new KindError(this.name, `variant ${parsed.data.variantSku} is not purchasable`);
273
306
  },
274
307
  async price(line, ctx) {
275
308
  const typed = line;
276
- const bundle = await ctx.bridges.catalog.resolve(typed.payload.bundleRef, ctx);
277
- if (!bundle) throw new KindError(this.name, `price() on unknown bundle: ${typed.payload.bundleRef}`);
278
- const unitPrice = typed.overrideUnitPrice ?? bundle.unitPrice;
279
- const total = {
309
+ const product = await ctx.bridges.catalog.resolve(typed.payload.variantSku, ctx);
310
+ if (!product) throw new KindError(this.name, `price() on unknown variant: ${typed.payload.variantSku}`);
311
+ const unitPrice = typed.overrideUnitPrice ?? product.unitPrice;
312
+ const lineTotal = {
280
313
  amount: unitPrice.amount * typed.quantity,
281
314
  currency: unitPrice.currency
282
315
  };
@@ -285,9 +318,9 @@ const bundleKind = {
285
318
  unitPrice,
286
319
  quantity: typed.quantity,
287
320
  subtotals: {
288
- prePromo: total,
289
- postPromo: total,
290
- postPromoPostTax: total
321
+ prePromo: lineTotal,
322
+ postPromo: lineTotal,
323
+ postPromoPostTax: lineTotal
291
324
  },
292
325
  discountTotal: {
293
326
  amount: 0,
@@ -297,66 +330,33 @@ const bundleKind = {
297
330
  amount: 0,
298
331
  currency: unitPrice.currency
299
332
  },
300
- validUntil: new Date(Date.now() + 900 * 1e3),
301
- kindMeta: {
302
- bundleRef: typed.payload.bundleRef,
303
- componentCount: typed.payload.components.length
304
- }
333
+ validUntil: null
305
334
  };
306
335
  },
307
- async revalidate(line, priced, ctx) {
308
- const typed = line;
309
- const bundle = await ctx.bridges.catalog.resolve(typed.payload.bundleRef, ctx);
310
- if (!bundle) return {
311
- status: "invalid",
312
- reason: "bundle no longer exists"
313
- };
314
- const currentPrice = bundle.unitPrice.amount;
315
- const snapshotPrice = priced.unitPrice.amount;
316
- if (currentPrice !== snapshotPrice) {
317
- const delta = {
318
- amount: (currentPrice - snapshotPrice) * typed.quantity,
319
- currency: priced.unitPrice.currency
320
- };
321
- const newTotal = {
322
- amount: currentPrice * typed.quantity,
323
- currency: priced.unitPrice.currency
324
- };
325
- return {
326
- status: "reprice",
327
- priced: {
328
- ...priced,
329
- unitPrice: {
330
- amount: currentPrice,
331
- currency: priced.unitPrice.currency
332
- },
333
- subtotals: {
334
- prePromo: newTotal,
335
- postPromo: newTotal,
336
- postPromoPostTax: newTotal
337
- },
338
- validUntil: new Date(Date.now() + 900 * 1e3)
339
- },
340
- delta
341
- };
342
- }
336
+ async revalidate(_line, priced) {
343
337
  return {
344
338
  status: "unchanged",
345
339
  priced
346
340
  };
347
341
  },
342
+ mergeKey(line) {
343
+ const { productRef, variantSku } = line.payload ?? {};
344
+ if (!productRef || !variantSku) return null;
345
+ return `variant:${productRef}:${variantSku}`;
346
+ },
348
347
  async displayOf(line, ctx) {
349
348
  const typed = line;
350
- const bundle = await ctx.bridges.catalog.resolve(typed.payload.bundleRef, ctx);
351
- if (!bundle) return null;
349
+ const product = await ctx.bridges.catalog.resolve(typed.payload.variantSku, ctx);
350
+ if (!product) return null;
352
351
  return {
353
- name: bundle.name,
354
- imageUrl: bundle.primaryImage,
355
- slug: bundle.slug,
356
- variantLabel: `${typed.payload.components.length} items`,
352
+ name: product.name,
353
+ imageUrl: product.primaryImage,
354
+ slug: product.slug,
355
+ variantLabel: product.variantLabel,
356
+ compareAtPrice: product.compareAtPrice,
357
357
  capturedAt: /* @__PURE__ */ new Date()
358
358
  };
359
359
  }
360
360
  };
361
361
  //#endregion
362
- export { variantKind as a, skuPayloadSchema as c, timeslotPayloadSchema as i, bundlePayloadSchema as n, variantPayloadSchema as o, timeslotKind as r, skuKind as s, bundleKind as t };
362
+ export { skuKind as a, bundlePayloadSchema as c, timeslotPayloadSchema as i, variantPayloadSchema as n, skuPayloadSchema as o, timeslotKind as r, bundleKind as s, variantKind as t };
@@ -1,6 +1,36 @@
1
- import { r as LineKind } from "./line-kind-Bndo6IS8.mjs";
1
+ import { r as LineKind } from "./line-kind-DOYygKG4.mjs";
2
2
  import { z } from "zod";
3
3
 
4
+ //#region src/kinds/bundle.kind.d.ts
5
+ /**
6
+ * `bundle` — a group of products sold together at a combined price.
7
+ *
8
+ * The bundle resolves as a single catalog entry whose `unitPrice` is the
9
+ * bundle price (not the sum of component prices). Components are stored
10
+ * in `payload.components` for display and fulfillment, but pricing uses
11
+ * only the bundle's catalog entry.
12
+ *
13
+ * Validity is `reprice` — bundle prices can drift when component prices
14
+ * change, and silent repricing is acceptable (unlike contested resources
15
+ * like seats).
16
+ */
17
+ interface BundleComponent {
18
+ skuRef: string;
19
+ quantity: number;
20
+ }
21
+ interface BundlePayload {
22
+ bundleRef: string;
23
+ components: BundleComponent[];
24
+ }
25
+ declare const bundlePayloadSchema: z.ZodObject<{
26
+ bundleRef: z.ZodString;
27
+ components: z.ZodArray<z.ZodObject<{
28
+ skuRef: z.ZodString;
29
+ quantity: z.ZodNumber;
30
+ }, z.core.$strip>>;
31
+ }, z.core.$strip>;
32
+ declare const bundleKind: LineKind<BundlePayload>;
33
+ //#endregion
4
34
  //#region src/kinds/sku.kind.d.ts
5
35
  /**
6
36
  * `sku` — the plain retail LineKind.
@@ -24,32 +54,6 @@ declare const skuPayloadSchema: z.ZodObject<{
24
54
  }, z.core.$strip>;
25
55
  declare const skuKind: LineKind<SkuPayload>;
26
56
  //#endregion
27
- //#region src/kinds/variant.kind.d.ts
28
- /**
29
- * `variant` — a catalog SKU with structured variant selection.
30
- *
31
- * Extends the `sku` kind with an explicit `variantSku` field (e.g.,
32
- * "shirt-m-blue") that maps to a specific product variant. The catalog
33
- * bridge resolves the variant SKU to a `ProductSummary` which carries
34
- * variant-specific pricing, images, and the pre-formatted
35
- * `variantLabel` ("Size: M, Color: Blue").
36
- *
37
- * Use this when the product has selectable options (size, color, material)
38
- * and each combination has its own price and stock. Use plain `sku` when
39
- * the product is a single item with no options.
40
- */
41
- interface VariantPayload {
42
- /** The parent product's stable identifier. */
43
- productRef: string;
44
- /** The specific variant's SKU — the one the catalog resolves for pricing. */
45
- variantSku: string;
46
- }
47
- declare const variantPayloadSchema: z.ZodObject<{
48
- productRef: z.ZodString;
49
- variantSku: z.ZodString;
50
- }, z.core.$strip>;
51
- declare const variantKind: LineKind<VariantPayload>;
52
- //#endregion
53
57
  //#region src/kinds/timeslot.kind.d.ts
54
58
  /**
55
59
  * `timeslot` — an appointment or booking slot in a mixed basket.
@@ -81,34 +85,30 @@ declare const timeslotPayloadSchema: z.ZodObject<{
81
85
  }, z.core.$strip>;
82
86
  declare const timeslotKind: LineKind<TimeslotPayload>;
83
87
  //#endregion
84
- //#region src/kinds/bundle.kind.d.ts
88
+ //#region src/kinds/variant.kind.d.ts
85
89
  /**
86
- * `bundle` — a group of products sold together at a combined price.
90
+ * `variant` — a catalog SKU with structured variant selection.
87
91
  *
88
- * The bundle resolves as a single catalog entry whose `unitPrice` is the
89
- * bundle price (not the sum of component prices). Components are stored
90
- * in `payload.components` for display and fulfillment, but pricing uses
91
- * only the bundle's catalog entry.
92
+ * Extends the `sku` kind with an explicit `variantSku` field (e.g.,
93
+ * "shirt-m-blue") that maps to a specific product variant. The catalog
94
+ * bridge resolves the variant SKU to a `ProductSummary` which carries
95
+ * variant-specific pricing, images, and the pre-formatted
96
+ * `variantLabel` ("Size: M, Color: Blue").
92
97
  *
93
- * Validity is `reprice` — bundle prices can drift when component prices
94
- * change, and silent repricing is acceptable (unlike contested resources
95
- * like seats).
98
+ * Use this when the product has selectable options (size, color, material)
99
+ * and each combination has its own price and stock. Use plain `sku` when
100
+ * the product is a single item with no options.
96
101
  */
97
- interface BundleComponent {
98
- skuRef: string;
99
- quantity: number;
100
- }
101
- interface BundlePayload {
102
- bundleRef: string;
103
- components: BundleComponent[];
102
+ interface VariantPayload {
103
+ /** The parent product's stable identifier. */
104
+ productRef: string;
105
+ /** The specific variant's SKU — the one the catalog resolves for pricing. */
106
+ variantSku: string;
104
107
  }
105
- declare const bundlePayloadSchema: z.ZodObject<{
106
- bundleRef: z.ZodString;
107
- components: z.ZodArray<z.ZodObject<{
108
- skuRef: z.ZodString;
109
- quantity: z.ZodNumber;
110
- }, z.core.$strip>>;
108
+ declare const variantPayloadSchema: z.ZodObject<{
109
+ productRef: z.ZodString;
110
+ variantSku: z.ZodString;
111
111
  }, z.core.$strip>;
112
- declare const bundleKind: LineKind<BundlePayload>;
112
+ declare const variantKind: LineKind<VariantPayload>;
113
113
  //#endregion
114
- export { TimeslotPayload as a, VariantPayload as c, SkuPayload as d, skuKind as f, bundlePayloadSchema as i, variantKind as l, BundlePayload as n, timeslotKind as o, skuPayloadSchema as p, bundleKind as r, timeslotPayloadSchema as s, BundleComponent as t, variantPayloadSchema as u };
114
+ export { timeslotKind as a, skuKind as c, BundlePayload as d, bundleKind as f, TimeslotPayload as i, skuPayloadSchema as l, variantKind as n, timeslotPayloadSchema as o, bundlePayloadSchema as p, variantPayloadSchema as r, SkuPayload as s, VariantPayload as t, BundleComponent as u };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@classytic/cart",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "Framework-agnostic universal cart engine for commerce — drafts, checkouts, reservations, the LineKind strategy, and a disciplined finalization saga. Powered by MongoDB via @classytic/mongokit. Zero framework deps — usable from Arc, Express, Nest, Next.js, or raw Node.",
5
5
  "author": "Classytic",
6
6
  "type": "module",
@@ -69,25 +69,32 @@
69
69
  "build": "tsdown",
70
70
  "dev": "tsdown --watch",
71
71
  "typecheck": "tsc --noEmit",
72
+ "lint": "biome check src/ tests/",
73
+ "format": "biome format --write src/ tests/",
74
+ "check": "biome check --write --unsafe src/ tests/",
72
75
  "test": "vitest run --project unit --project integration",
73
76
  "test:unit": "vitest run --project unit",
74
77
  "test:integration": "vitest run --project integration",
75
78
  "test:all": "vitest run",
76
- "test:watch": "vitest --project unit --project integration"
79
+ "test:watch": "vitest --project unit --project integration",
80
+ "prepublishOnly": "npm run lint && npm run typecheck && npm run test && npm run build",
81
+ "push": "classytic-push",
82
+ "release:tag": "node -e \"require('child_process').execSync('npm run push -- v'+require('./package.json').version,{stdio:'inherit'})\"",
83
+ "release": "npm run push -- main && npm run release:tag && npm publish"
77
84
  },
78
85
  "peerDependencies": {
79
86
  "@classytic/mongokit": ">=3.11.0",
80
87
  "@classytic/primitives": ">=0.1.0",
81
- "@classytic/repo-core": ">=0.2.0",
82
88
  "mongoose": ">=9.4.1",
83
89
  "zod": ">=4.0.0"
84
90
  },
85
91
  "devDependencies": {
92
+ "@biomejs/biome": "^2.4.13",
93
+ "@classytic/dev-tools": "^0.2.0",
86
94
  "@classytic/mongokit": "^3.11.0",
87
95
  "@classytic/primitives": "^0.1.0",
88
- "@classytic/repo-core": ">=0.2.0",
89
96
  "@types/node": "^25.5.0",
90
- "@vitest/coverage-v8": "^3.2.4",
97
+ "knip": "^6.7.0",
91
98
  "mongodb-memory-server": "^10.2.3",
92
99
  "mongoose": "^9.4.1",
93
100
  "tsdown": "^0.21.5",