@classytic/cart 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/dist/{define-cart-BPq2kb_V.mjs → define-cart-Cr9VMeVc.mjs} +31 -28
- package/dist/engine/index.d.mts +1 -1
- package/dist/engine/index.mjs +1 -1
- package/dist/index.d.mts +14 -8
- package/dist/index.mjs +18 -2
- package/dist/{internal-event-bus-Bu7Xj7j6.d.mts → internal-event-bus-BA-WrtE0.d.mts} +5 -18
- package/package.json +7 -7
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,13 @@
|
|
|
3
3
|
Format based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
4
4
|
adhering to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
5
5
|
|
|
6
|
+
## 1.1.0 - 2026-08-17
|
|
7
|
+
|
|
8
|
+
### Changed
|
|
9
|
+
- `cleanup/steps.ts`: bare calendar-date `before` param refused — must be a full ISO instant (prevents silent UTC-midnight misfire in non-UTC deployments)
|
|
10
|
+
- `define-cart`: `resolveCartTenant` wired; tenant injection centralised
|
|
11
|
+
- `inject-tenant` refactored; models and repositories simplified
|
|
12
|
+
|
|
6
13
|
## 1.0.0 - 2026-07-29
|
|
7
14
|
|
|
8
15
|
### Changed
|
|
@@ -9,7 +9,7 @@ import { money } from "@classytic/primitives/money";
|
|
|
9
9
|
import { Repository, customIdPlugin, defineModels, isDuplicateKeyError, multiTenantPlugin, prefixedId, withTransaction } from "@classytic/mongokit";
|
|
10
10
|
import { CURRENCY_PATTERN, currencyCode } from "@classytic/primitives/currency";
|
|
11
11
|
import mongoose, { Schema } from "mongoose";
|
|
12
|
-
import { resolveTenantConfig } from "@classytic/repo-core/tenant";
|
|
12
|
+
import { assertNoLegacyTenantKeys, resolveTenantConfig } from "@classytic/repo-core/tenant";
|
|
13
13
|
import { createHash } from "node:crypto";
|
|
14
14
|
import { InProcessEventBus } from "@classytic/primitives/event-infra";
|
|
15
15
|
//#region src/domain/ports/common.ts
|
|
@@ -450,15 +450,9 @@ function buildIdempotencySchema() {
|
|
|
450
450
|
* own without a mongoose dependency.
|
|
451
451
|
*/
|
|
452
452
|
function resolveCartTenant(input = {}) {
|
|
453
|
-
|
|
454
|
-
if ("
|
|
455
|
-
|
|
456
|
-
return resolveTenantConfig({
|
|
457
|
-
enabled: legacy.multiTenant !== false,
|
|
458
|
-
fieldType: legacy.tenantFieldType ?? "objectId"
|
|
459
|
-
});
|
|
460
|
-
}
|
|
461
|
-
return resolveTenantConfig(input);
|
|
453
|
+
const resolved = resolveTenantConfig(input);
|
|
454
|
+
if (resolved.strategy === "custom") throw new Error("[cart] tenant.strategy 'custom' is unsupported: cart repositories require one concrete tenant field");
|
|
455
|
+
return resolved;
|
|
462
456
|
}
|
|
463
457
|
/**
|
|
464
458
|
* Inject the tenant field into a Mongoose schema, and (when `enabled` +
|
|
@@ -616,10 +610,7 @@ function resolveAutoIndex(key, autoIndex) {
|
|
|
616
610
|
* schema and registers nothing until `.bind(connection)`.
|
|
617
611
|
*/
|
|
618
612
|
function defineCartModels(config = {}) {
|
|
619
|
-
const tenant = resolveCartTenant(
|
|
620
|
-
multiTenant: config.multiTenant,
|
|
621
|
-
tenantFieldType: config.tenantFieldType ?? "objectId"
|
|
622
|
-
});
|
|
613
|
+
const tenant = config.tenant ?? resolveCartTenant(true);
|
|
623
614
|
const prefix = config.collectionPrefix ?? "";
|
|
624
615
|
return defineModels({
|
|
625
616
|
models: [
|
|
@@ -1941,23 +1932,23 @@ function isNotFound(err) {
|
|
|
1941
1932
|
}
|
|
1942
1933
|
//#endregion
|
|
1943
1934
|
//#region src/repositories/index.ts
|
|
1944
|
-
function tenantPlugin(
|
|
1935
|
+
function tenantPlugin(tenant) {
|
|
1945
1936
|
return multiTenantPlugin({
|
|
1946
|
-
tenantField:
|
|
1947
|
-
contextKey:
|
|
1937
|
+
tenantField: tenant.tenantField,
|
|
1938
|
+
contextKey: tenant.contextKey,
|
|
1948
1939
|
required: false,
|
|
1949
1940
|
skipWhen: (ctx) => ctx.skipTenant === true,
|
|
1950
|
-
fieldType
|
|
1941
|
+
fieldType: tenant.fieldType
|
|
1951
1942
|
});
|
|
1952
1943
|
}
|
|
1953
1944
|
function createCartRepositories(models, config) {
|
|
1954
|
-
const { kinds, bridges, clock, id, defaultCurrency, events, outbox, plugins = {},
|
|
1945
|
+
const { kinds, bridges, clock, id, defaultCurrency, events, outbox, plugins = {}, tenant, staleOpenCheckoutMs } = config;
|
|
1955
1946
|
const eventPublisher = new CartEventPublisher({
|
|
1956
1947
|
events,
|
|
1957
1948
|
outbox,
|
|
1958
1949
|
clock
|
|
1959
1950
|
});
|
|
1960
|
-
const tenantPlugins =
|
|
1951
|
+
const tenantPlugins = tenant.enabled ? [tenantPlugin(tenant)] : [];
|
|
1961
1952
|
const draft = new DraftRepository(models.Draft, [
|
|
1962
1953
|
...tenantPlugins,
|
|
1963
1954
|
customIdPlugin({
|
|
@@ -2075,13 +2066,27 @@ function requireKinds(shape) {
|
|
|
2075
2066
|
* performs no I/O.
|
|
2076
2067
|
*/
|
|
2077
2068
|
function defineCart(shape) {
|
|
2069
|
+
/**
|
|
2070
|
+
* The pre-consolidation tenant keys are REFUSED, never absorbed.
|
|
2071
|
+
*
|
|
2072
|
+
* This entry reads `shape.tenant`, so a leftover `multiTenant` is invisible and
|
|
2073
|
+
* the `?? true` default applies repo-core's defaults instead. Both outcomes
|
|
2074
|
+
* return plausible data:
|
|
2075
|
+
* - `multiTenant: false` -> tenancy ON, and the host loses its company-wide reads;
|
|
2076
|
+
* - `multiTenant: { tenantField: 'business' }` -> scoping on `organizationId`,
|
|
2077
|
+
* a field those documents do not carry.
|
|
2078
|
+
*
|
|
2079
|
+
* tsc cannot cover this: excess-property checking does not fire for a typed
|
|
2080
|
+
* variable, a spread, or a shape handed over from a dependency's dist — which is
|
|
2081
|
+
* how every real host composes one. Hence a describe-time check, shared from
|
|
2082
|
+
* repo-core so the nine kernels making this same rename cannot each forget it.
|
|
2083
|
+
*/
|
|
2084
|
+
assertNoLegacyTenantKeys(shape, "defineCart", [["tenantFieldType", "tenant.fieldType"]]);
|
|
2078
2085
|
requireKinds(shape);
|
|
2079
|
-
const
|
|
2080
|
-
const tenantFieldType = shape.tenantFieldType ?? "objectId";
|
|
2086
|
+
const tenant = resolveCartTenant(shape.tenant ?? true);
|
|
2081
2087
|
const defaultCurrency = currencyCode(shape.defaultCurrency ?? "USD");
|
|
2082
2088
|
const modelBlueprint = defineCartModels({
|
|
2083
|
-
|
|
2084
|
-
tenantFieldType,
|
|
2089
|
+
tenant,
|
|
2085
2090
|
...shape.autoIndex !== void 0 ? { autoIndex: shape.autoIndex } : {},
|
|
2086
2091
|
...shape.collectionPrefix !== void 0 ? { collectionPrefix: shape.collectionPrefix } : {},
|
|
2087
2092
|
...shape.forceRecreate !== void 0 ? { forceRecreate: shape.forceRecreate } : {}
|
|
@@ -2129,15 +2134,13 @@ function defineCart(shape) {
|
|
|
2129
2134
|
events,
|
|
2130
2135
|
...runtime.outbox !== void 0 ? { outbox: runtime.outbox } : {},
|
|
2131
2136
|
...runtime.repositoryPlugins !== void 0 ? { plugins: runtime.repositoryPlugins } : {},
|
|
2132
|
-
|
|
2133
|
-
multiTenant,
|
|
2137
|
+
tenant,
|
|
2134
2138
|
...staleOpenCheckoutMs !== void 0 ? { staleOpenCheckoutMs } : {}
|
|
2135
2139
|
});
|
|
2136
2140
|
assertCartCapabilities(repositories);
|
|
2137
2141
|
const allowNonTransactional = runtime.allowNonTransactional ?? false;
|
|
2138
2142
|
const resolved = {
|
|
2139
|
-
|
|
2140
|
-
tenantFieldType,
|
|
2143
|
+
tenant,
|
|
2141
2144
|
forceRecreate: shape.forceRecreate ?? false,
|
|
2142
2145
|
defaultCurrency,
|
|
2143
2146
|
allowNonTransactional,
|
package/dist/engine/index.d.mts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { CartConfigShape, cartConfigSchema, checkoutConfigSchema, idempotencyConfigSchema, reservationConfigSchema, scopeConfigSchema } from "./cart-config.schema.mjs";
|
|
2
|
-
import { a as defineCart, c as CartEngine, d as CartShape, f as ResolvedCartConfig, i as createCartDomain, l as CartLogger, n as CartBlueprint, o as CartBridges, r as CartDomainRuntime, s as CartDomain, t as InProcessCartEventBus, u as CartRuntime } from "../internal-event-bus-
|
|
2
|
+
import { a as defineCart, c as CartEngine, d as CartShape, f as ResolvedCartConfig, i as createCartDomain, l as CartLogger, n as CartBlueprint, o as CartBridges, r as CartDomainRuntime, s as CartDomain, t as InProcessCartEventBus, u as CartRuntime } from "../internal-event-bus-BA-WrtE0.mjs";
|
|
3
3
|
export { type CartBlueprint, type CartBridges, type CartConfigShape, type CartDomain, type CartDomainRuntime, type CartEngine, type CartLogger, type CartRuntime, type CartShape, InProcessCartEventBus, type ResolvedCartConfig, cartConfigSchema, checkoutConfigSchema, createCartDomain, defineCart, idempotencyConfigSchema, reservationConfigSchema, scopeConfigSchema };
|
package/dist/engine/index.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { n as defineCart, r as InProcessCartEventBus, t as createCartDomain } from "../define-cart-
|
|
1
|
+
import { n as defineCart, r as InProcessCartEventBus, t as createCartDomain } from "../define-cart-Cr9VMeVc.mjs";
|
|
2
2
|
import { cartConfigSchema, checkoutConfigSchema, idempotencyConfigSchema, reservationConfigSchema, scopeConfigSchema } from "./cart-config.schema.mjs";
|
|
3
3
|
export { InProcessCartEventBus, cartConfigSchema, checkoutConfigSchema, createCartDomain, defineCart, idempotencyConfigSchema, reservationConfigSchema, scopeConfigSchema };
|
package/dist/index.d.mts
CHANGED
|
@@ -9,7 +9,7 @@ import { a as RevalidationResult, c as ValidityPolicy, i as LineLike, l as LineD
|
|
|
9
9
|
import { a as IdempotencyReplay, c as LineItem, i as IdempotencyIdentity, n as createKindRegistry, o as OperationName, r as CART_REF_NEW, s as TotalsSnapshot, t as KindRegistry } from "./kind-registry-DFvNDb81.mjs";
|
|
10
10
|
import { n as createCounterIdPort, r as cryptoIdPort, t as IdPort } from "./id.port-DzgWy8sy.mjs";
|
|
11
11
|
import { CartConfigShape, cartConfigSchema, checkoutConfigSchema, idempotencyConfigSchema, reservationConfigSchema, scopeConfigSchema } from "./engine/cart-config.schema.mjs";
|
|
12
|
-
import { A as buildReservationSchema, C as DraftRepositoryDeps, D as DefineCartModelsConfig, E as CartModels, F as CheckoutDocument, I as buildCheckoutSchema, M as buildIdempotencySchema, N as DraftDocument, O as defineCartModels, P as buildDraftSchema, S as DraftRepository, T as CartModelName, _ as ReservationRepository, a as defineCart, b as CheckoutRepositoryDeps, c as CartEngine, d as CartShape, f as ResolvedCartConfig, g as createCartRepositories, h as CreateCartRepositoriesConfig, i as createCartDomain, j as IdempotencyDocument, k as ReservationDocument, l as CartLogger, m as CartRepositoryPluginBundle, n as CartBlueprint, o as CartBridges, p as CartRepositories, r as CartDomainRuntime, s as CartDomain, t as InProcessCartEventBus, u as CartRuntime, v as IdempotencyRepository, w as CartEventPublisherDeps, x as DEFAULT_STALE_OPEN_CHECKOUT_MS, y as CheckoutRepository } from "./internal-event-bus-
|
|
12
|
+
import { A as buildReservationSchema, C as DraftRepositoryDeps, D as DefineCartModelsConfig, E as CartModels, F as CheckoutDocument, I as buildCheckoutSchema, M as buildIdempotencySchema, N as DraftDocument, O as defineCartModels, P as buildDraftSchema, S as DraftRepository, T as CartModelName, _ as ReservationRepository, a as defineCart, b as CheckoutRepositoryDeps, c as CartEngine, d as CartShape, f as ResolvedCartConfig, g as createCartRepositories, h as CreateCartRepositoriesConfig, i as createCartDomain, j as IdempotencyDocument, k as ReservationDocument, l as CartLogger, m as CartRepositoryPluginBundle, n as CartBlueprint, o as CartBridges, p as CartRepositories, r as CartDomainRuntime, s as CartDomain, t as InProcessCartEventBus, u as CartRuntime, v as IdempotencyRepository, w as CartEventPublisherDeps, x as DEFAULT_STALE_OPEN_CHECKOUT_MS, y as CheckoutRepository } from "./internal-event-bus-BA-WrtE0.mjs";
|
|
13
13
|
import { a as timeslotKind, c as skuKind, d as serviceFeeKind, f as serviceFeePayloadSchema, g as bundlePayloadSchema, h as bundleKind, i as TimeslotPayload, l as skuPayloadSchema, m as BundlePayload, n as variantKind, o as timeslotPayloadSchema, p as BundleComponent, r as variantPayloadSchema, s as SkuPayload, t as VariantPayload, u as ServiceFeePayload } from "./variant.kind-CClf8MTF.mjs";
|
|
14
14
|
import { Money, Money as Money$1, addMoney, fromMajor, money, multiplyMoney, subtractMoney, sumMoney, toMajor } from "@classytic/primitives/money";
|
|
15
15
|
import { DomainEvent, EventHandler, EventTransport, EventTransport as EventTransport$1, PublishManyResult } from "@classytic/primitives/events";
|
|
@@ -143,14 +143,20 @@ declare function runPricing(opts: {
|
|
|
143
143
|
//#endregion
|
|
144
144
|
//#region src/models/inject-tenant.d.ts
|
|
145
145
|
/**
|
|
146
|
-
* Accept the
|
|
147
|
-
*
|
|
148
|
-
*
|
|
146
|
+
* Accept the config surface every kernel uses: `TenantConfig | boolean`.
|
|
147
|
+
*
|
|
148
|
+
* This docblock used to add "and additionally support the legacy
|
|
149
|
+
* `{ tenantFieldType, multiTenant }` shape so the engine factory can forward its
|
|
150
|
+
* own config shorthand". That was never true of this code — the type is
|
|
151
|
+
* `TenantConfig | boolean` and the body delegates straight to
|
|
152
|
+
* `resolveTenantConfig`. A docblock promising back-compat the implementation
|
|
153
|
+
* does not have is worse than no docblock: the next reader composes against the
|
|
154
|
+
* promise, passes the old key, and gets default scoping with no error.
|
|
155
|
+
*
|
|
156
|
+
* The old keys are now REFUSED at the engine's describe-time entry
|
|
157
|
+
* (`assertNoLegacyTenantKeys`). There is no back-compat path by design.
|
|
149
158
|
*/
|
|
150
|
-
type CartTenantInput = TenantConfig | boolean
|
|
151
|
-
tenantFieldType?: 'objectId' | 'string';
|
|
152
|
-
multiTenant?: boolean;
|
|
153
|
-
};
|
|
159
|
+
type CartTenantInput = TenantConfig | boolean;
|
|
154
160
|
/** Re-export of primitives' resolved shape under the legacy name. */
|
|
155
161
|
type ResolvedTenant = ResolvedTenantConfig;
|
|
156
162
|
//#endregion
|
package/dist/index.mjs
CHANGED
|
@@ -7,7 +7,7 @@ import { t as StateTransitionError } from "./state-transition.error-BssJiRoW.mjs
|
|
|
7
7
|
import { n as CartEvents, t as createCartEvent } from "./domain-event-DBFsiHNJ.mjs";
|
|
8
8
|
import { a as cartEventsByName, i as cartEventDefinitions, n as MemoryOutboxStore, o as createCartEventRegistry, r as OutboxOwnershipError, s as defineCartEvent, t as InvalidOutboxEventError } from "./outbox-store-DLxCPOUN.mjs";
|
|
9
9
|
import { n as cryptoIdPort, r as systemClock, t as createCounterIdPort } from "./id.port-DYAnXbfV.mjs";
|
|
10
|
-
import { _ as PENDING_EVENTS, a as ReservationRepository, c as runPricing, d as defineCartModels, f as buildReservationSchema, g as flushPending, h as buildCheckoutSchema, i as createCartRepositories, l as CheckoutRepository, m as buildDraftSchema, n as defineCart, o as IdempotencyRepository, p as buildIdempotencySchema, r as InProcessCartEventBus, s as DraftRepository, t as createCartDomain, u as DEFAULT_STALE_OPEN_CHECKOUT_MS } from "./define-cart-
|
|
10
|
+
import { _ as PENDING_EVENTS, a as ReservationRepository, c as runPricing, d as defineCartModels, f as buildReservationSchema, g as flushPending, h as buildCheckoutSchema, i as createCartRepositories, l as CheckoutRepository, m as buildDraftSchema, n as defineCart, o as IdempotencyRepository, p as buildIdempotencySchema, r as InProcessCartEventBus, s as DraftRepository, t as createCartDomain, u as DEFAULT_STALE_OPEN_CHECKOUT_MS } from "./define-cart-Cr9VMeVc.mjs";
|
|
11
11
|
import { t as createKindRegistry } from "./kind-registry-DQYqRQZU.mjs";
|
|
12
12
|
import { i as CheckoutStep, n as CHECKOUT_STATE_TRANSITIONS, r as isLegalCheckoutTransition } from "./state-transitions-wunwhjap.mjs";
|
|
13
13
|
import { a as skuKind, c as serviceFeePayloadSchema, i as timeslotPayloadSchema, l as bundleKind, n as variantPayloadSchema, o as skuPayloadSchema, r as timeslotKind, s as serviceFeeKind, t as variantKind, u as bundlePayloadSchema } from "./variant.kind-NmWSslu-.mjs";
|
|
@@ -206,7 +206,23 @@ function parseParams(ctx, op) {
|
|
|
206
206
|
const out = {};
|
|
207
207
|
const before = p.before;
|
|
208
208
|
if (before !== void 0) {
|
|
209
|
-
if (typeof before !== "string" || Number.isNaN(Date.parse(before))) throw invalidParam(op, "before", before, "
|
|
209
|
+
if (typeof before !== "string" || Number.isNaN(Date.parse(before))) throw invalidParam(op, "before", before, "a full ISO instant (e.g. 2026-08-01T00:00:00.000Z)");
|
|
210
|
+
/**
|
|
211
|
+
* A DATE-ONLY string is refused, not silently read as UTC midnight.
|
|
212
|
+
*
|
|
213
|
+
* This was `new Date(before)` for both forms. `new Date('2026-08-01')` is
|
|
214
|
+
* UTC midnight — 06:00 that day in Asia/Dhaka — so "remove abandoned carts
|
|
215
|
+
* before 1 August" swept the first six hours of a day the operator had
|
|
216
|
+
* excluded. Nothing errored and a plausible count came back.
|
|
217
|
+
*
|
|
218
|
+
* A kernel cannot fix that by picking a calendar: it does not know the
|
|
219
|
+
* deployment's timezone, and guessing UTC is exactly the bug. So the
|
|
220
|
+
* ambiguity is REFUSED here and resolved by the host, which does know —
|
|
221
|
+
* be-prod converts a civil date through `businessDayStartUtc` before the
|
|
222
|
+
* parameter ever reaches a step. Refusing is what makes that conversion
|
|
223
|
+
* mandatory rather than merely available.
|
|
224
|
+
*/
|
|
225
|
+
if (/^\d{4}-\d{2}-\d{2}$/.test(before)) throw invalidParam(op, "before", before, "a full ISO instant — a bare calendar date is ambiguous without a timezone, so the host must resolve it against its business calendar first");
|
|
210
226
|
out.before = new Date(before);
|
|
211
227
|
}
|
|
212
228
|
const org = p.organizationId;
|
|
@@ -9,6 +9,7 @@ import { EventTransport } from "@classytic/primitives/events";
|
|
|
9
9
|
import { ModelBlueprint, PluginType, Repository } from "@classytic/mongokit";
|
|
10
10
|
import { CurrencyCode } from "@classytic/primitives/currency";
|
|
11
11
|
import { Connection, Document, Model, Schema, Types } from "mongoose";
|
|
12
|
+
import { ResolvedTenantConfig, TenantConfig } from "@classytic/repo-core/tenant";
|
|
12
13
|
import { InProcessEventBus } from "@classytic/primitives/event-infra";
|
|
13
14
|
//#region src/models/checkout.model.d.ts
|
|
14
15
|
/**
|
|
@@ -164,8 +165,7 @@ declare function buildReservationSchema(): Schema<ReservationDocument>;
|
|
|
164
165
|
/** Union of all cart model names used as keys in `CartModels`. */
|
|
165
166
|
type CartModelName = 'Draft' | 'Checkout' | 'Reservation' | 'Idempotency';
|
|
166
167
|
interface DefineCartModelsConfig {
|
|
167
|
-
|
|
168
|
-
multiTenant?: boolean;
|
|
168
|
+
tenant?: ResolvedTenantConfig;
|
|
169
169
|
autoIndex?: boolean | Partial<Record<CartModelName, boolean>>;
|
|
170
170
|
/**
|
|
171
171
|
* Optional prefix prepended to every physical collection this package
|
|
@@ -582,12 +582,7 @@ interface CreateCartRepositoriesConfig {
|
|
|
582
582
|
/** Validated + branded once at the config edge in `defineCart`. */
|
|
583
583
|
defaultCurrency: CurrencyCode;
|
|
584
584
|
events: EventTransport;
|
|
585
|
-
|
|
586
|
-
/**
|
|
587
|
-
* When `false`, the tenant plugin is omitted entirely — cart is
|
|
588
|
-
* company-wide. Default `true` keeps branch scoping.
|
|
589
|
-
*/
|
|
590
|
-
multiTenant?: boolean;
|
|
585
|
+
tenant: ResolvedTenantConfig;
|
|
591
586
|
outbox?: OutboxStore;
|
|
592
587
|
plugins?: CartRepositoryPluginBundle;
|
|
593
588
|
/** Zombie window for lazy open-checkout expiry. See `CheckoutRepositoryDeps`. */
|
|
@@ -639,14 +634,7 @@ interface CartShape extends Partial<CartConfigShape> {
|
|
|
639
634
|
* Use when cart is company-wide — a customer's cart follows them across
|
|
640
635
|
* branches and no tenant filter applies.
|
|
641
636
|
*/
|
|
642
|
-
|
|
643
|
-
/**
|
|
644
|
-
* Mongoose schema type for the `organizationId` field on all models.
|
|
645
|
-
*
|
|
646
|
-
* - `'objectId'` (default): `Schema.Types.ObjectId` + `ref: 'organization'`
|
|
647
|
-
* - `'string'`: plain `String` — for UUID/slug-based auth
|
|
648
|
-
*/
|
|
649
|
-
tenantFieldType?: 'objectId' | 'string' | undefined;
|
|
637
|
+
tenant?: boolean | TenantConfig | undefined;
|
|
650
638
|
/**
|
|
651
639
|
* Control Mongoose `autoIndex` per model or globally.
|
|
652
640
|
*
|
|
@@ -712,8 +700,7 @@ interface CartRuntime {
|
|
|
712
700
|
}
|
|
713
701
|
/** Resolved configuration captured on the bound engine (frozen). */
|
|
714
702
|
interface ResolvedCartConfig {
|
|
715
|
-
|
|
716
|
-
tenantFieldType: 'objectId' | 'string';
|
|
703
|
+
tenant: ResolvedTenantConfig;
|
|
717
704
|
forceRecreate: boolean;
|
|
718
705
|
/** Validated + branded once at the config edge in `defineCart`. */
|
|
719
706
|
defaultCurrency: CurrencyCode;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@classytic/cart",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
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",
|
|
@@ -83,18 +83,18 @@
|
|
|
83
83
|
"release": "npm run push -- main && npm run release:tag && npm publish"
|
|
84
84
|
},
|
|
85
85
|
"peerDependencies": {
|
|
86
|
-
"@classytic/mongokit": ">=3.
|
|
87
|
-
"@classytic/primitives": ">=0.
|
|
88
|
-
"@classytic/repo-core": ">=0.
|
|
86
|
+
"@classytic/mongokit": ">=3.33.0",
|
|
87
|
+
"@classytic/primitives": ">=0.23.0",
|
|
88
|
+
"@classytic/repo-core": ">=0.24.0",
|
|
89
89
|
"mongoose": ">=9.4.1",
|
|
90
90
|
"zod": ">=4.0.0"
|
|
91
91
|
},
|
|
92
92
|
"devDependencies": {
|
|
93
93
|
"@biomejs/biome": "^2.4.13",
|
|
94
94
|
"@classytic/dev-tools": "^0.2.0",
|
|
95
|
-
"@classytic/mongokit": "^3.
|
|
96
|
-
"@classytic/primitives": ">=0.
|
|
97
|
-
"@classytic/repo-core": ">=0.
|
|
95
|
+
"@classytic/mongokit": "^3.33.0",
|
|
96
|
+
"@classytic/primitives": ">=0.23.0",
|
|
97
|
+
"@classytic/repo-core": ">=0.24.0",
|
|
98
98
|
"@types/node": "^25.5.0",
|
|
99
99
|
"knip": "^6.7.0",
|
|
100
100
|
"mongodb-memory-server": "^10.2.3",
|