@happyvertical/smrt-products 0.35.3 → 0.36.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/lib/chunks/Sku-sl6xf1PR.js.map +1 -1
- package/dist/lib/lib/components/auto-generated/AutoForm.svelte +4 -2
- package/dist/lib/lib/components/auto-generated/AutoForm.svelte.d.ts.map +1 -1
- package/dist/lib/lib/components/auto-generated/FieldRenderer.svelte +6 -6
- package/dist/lib/lib/components/auto-generated/FieldRenderer.svelte.d.ts +2 -2
- package/dist/lib/lib/components/auto-generated/FieldRenderer.svelte.d.ts.map +1 -1
- package/dist/lib/lib/mock-smrt-client.js.map +1 -1
- package/dist/lib/lib/models/Product.d.ts +4 -4
- package/dist/lib/lib/models/Product.d.ts.map +1 -1
- package/dist/lib/lib/stores/product-store.client.svelte.d.ts +1 -1
- package/dist/lib/lib/types.d.ts +4 -4
- package/dist/lib/lib/types.d.ts.map +1 -1
- package/dist/lib/main.d.ts +6 -0
- package/dist/lib/main.d.ts.map +1 -1
- package/dist/lib/manifest.json +4 -4
- package/dist/lib/smrt-knowledge.json +4 -4
- package/package.json +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Sku-sl6xf1PR.js","sources":["../../../src/lib/models/Category.ts","../../../src/lib/models/types.ts","../../../src/lib/models/Product.ts","../../../src/lib/models/Material.ts","../../../src/lib/models/ProductAsset.ts","../../../src/lib/models/ProductVariant.ts","../../../src/lib/models/Sku.ts"],"sourcesContent":["/**\n * Product knowledge base category model\n *\n * SMRT auto-generates REST APIs, MCP tools, and TypeScript clients from this class.\n */\n\nimport {\n foreignKey,\n SmrtObject,\n type SmrtObjectOptions,\n smrt,\n} from '@happyvertical/smrt-core';\nimport { TenantScoped, tenantId } from '@happyvertical/smrt-tenancy';\n\n/**\n * Options for Category initialization\n */\nexport interface CategoryOptions extends SmrtObjectOptions {\n tenantId?: string | null;\n name?: string;\n description?: string;\n parentId?: string;\n level?: number;\n productCount?: number;\n active?: boolean;\n}\n\n/**\n * Product knowledge base category for organizing product information.\n *\n * Optional tenancy — categories may be shared globally (tenantId=null) or\n * scoped to a tenant. Hierarchical via parentId.\n */\n@TenantScoped({ mode: 'optional' })\n@smrt({\n tableStrategy: 'sti',\n // See the matching note on `Product` — overriding `conflictColumns`\n // to include `tenant_id` causes a SQLite `ON CONFLICT clause does not\n // match any … UNIQUE constraint` error because the core schema\n // generator's hardcoded STI unique index is `(slug, context,\n // _meta_type)` and does not include the tenant column. Until the\n // upstream framework fix lands, two tenants cannot share a category\n // slug at the schema level.\n api: {\n include: ['list', 'get', 'create', 'update'], // Standard CRUD except delete\n },\n mcp: {\n include: ['list', 'get'], // AI tools for category discovery\n },\n cli: true, // Enable CLI commands for admin\n})\nexport class Category extends SmrtObject {\n /**\n * Tenant ID for multi-tenant isolation.\n * Nullable to support both tenant-scoped and global categories.\n */\n @tenantId({ nullable: true })\n tenantId: string | null = null;\n\n name = '';\n description = '';\n @foreignKey('Category')\n parentId?: string; // For hierarchical categories\n level = 0; // Category depth in hierarchy\n productCount = 0; // Number of products in this category\n active = true;\n\n constructor(options: CategoryOptions = {}) {\n super(options);\n if (options.tenantId !== undefined) this.tenantId = options.tenantId;\n this.name = options.name || '';\n this.description = options.description || '';\n this.parentId = options.parentId;\n this.level = options.level || 0;\n this.productCount = options.productCount || 0;\n this.active = options.active !== undefined ? options.active : true;\n }\n}\n","/**\n * Shared types for the products package.\n *\n * @packageDocumentation\n */\n\n/**\n * Discriminator for Product STI subtypes.\n *\n * Industry-vertical templates extend `Product` with their own STI subtypes\n * (apparel uses `Style`/`Makeup`; furniture might use `Design`/`Finish`;\n * automotive `Model`/`Trim`) — the upstream package only ships the truly\n * generic primitives:\n *\n * - {@link ProductType.PRODUCT} — plain catalog item (base)\n * - {@link ProductType.MATERIAL} — raw input consumed by manufacturing\n *\n * The axis-declaration concept (\"this product varies along `size` with\n * values `[XS, S, M, L, XL]`\") is NOT a Product STI subtype — it lives in\n * its own model, {@link ProductVariant}, with a separate table. Per-SKU\n * value pins live on `Sku.attributes` (also in this package — `Sku` was\n * relocated from `@happyvertical/smrt-inventory` to here in Phase 1 so\n * every catalog primitive lives under one roof; inventory only holds\n * stock levels and movements now).\n */\nexport enum ProductType {\n /** Generic catalog item (default). */\n PRODUCT = 'product',\n /** A raw input — fabric, trim, packaging, etc. — consumed by manufacturing. */\n MATERIAL = 'material',\n}\n\n/**\n * High-level classification of a {@link ProductType.MATERIAL} item.\n *\n * Open string so consumers can extend with vertical-specific kinds without\n * an enum change. The `(string & {})` branch preserves the literal-string\n * autocomplete suggestions in IDEs — a bare `| string` would collapse the\n * whole union to `string` and erase the named hints (same pattern as\n * `StockMovementReason` in `@happyvertical/smrt-inventory`).\n */\nexport type MaterialKind =\n | 'fabric'\n | 'trim'\n | 'thread'\n | 'label'\n | 'packaging'\n | 'component'\n | (string & {});\n","/**\n * Product knowledge base model\n *\n * SMRT auto-generates REST APIs, MCP tools, and TypeScript clients from this class.\n */\n\nimport type { Asset } from '@happyvertical/smrt-assets';\nimport {\n assertValidOwnedAssetRelationship,\n assertValidOwnedAssetSortOrder,\n resolveOwnedAssetsById,\n} from '@happyvertical/smrt-assets';\nimport {\n SmrtObject,\n type SmrtObjectOptions,\n smrt,\n} from '@happyvertical/smrt-core';\nimport {\n getCurrentTenant,\n TenantScoped,\n tenantId,\n} from '@happyvertical/smrt-tenancy';\nimport { ProductType } from './types';\n\n/**\n * Options for Product initialization\n */\nexport interface ProductOptions extends SmrtObjectOptions {\n tenantId?: string | null;\n productType?: ProductType;\n name?: string;\n description?: string;\n category?: string;\n manufacturer?: string;\n model?: string;\n price?: number;\n inStock?: boolean;\n specifications?: Record<string, any>;\n tags?: string[];\n}\n\n/**\n * Product information for knowledge base queries.\n *\n * STI base — subclasses (e.g. `Material` upstream, `Style`/`Makeup` in the\n * apparel template) share this table via the `_meta_type` discriminator\n * and `productType` field. Optional tenancy lets the same package serve\n * shared global catalogs OR per-merchant catalogs.\n */\n@TenantScoped({ mode: 'optional' })\n@smrt({\n tableStrategy: 'sti',\n // KNOWN LIMITATION (tracked for framework follow-up): the core schema\n // generator hardcodes the STI unique index as\n // `(slug, context, _meta_type)` and does not include `tenant_id`\n // even when the class is `@TenantScoped`. As a result two tenants\n // cannot save a row with the same slug+context+type — the UNIQUE\n // constraint at the SQL layer rejects the second insert.\n //\n // We deliberately do NOT override `conflictColumns` here to add\n // `tenant_id`: doing so would put the runtime upsert path\n // (`ON CONFLICT ('slug','context','_meta_type','tenant_id')`) out of\n // step with the actual unique index, producing `SQLITE_ERROR: ON\n // CONFLICT clause does not match any … UNIQUE constraint` on every\n // save. Production callers should either (a) namespace their slugs\n // per tenant on the application side (e.g. `${tenantId}-widget`), or\n // (b) wait for the upstream framework fix that extends the STI\n // unique index with `tenant_id` for tenant-scoped tables.\n api: {\n include: ['list', 'get', 'create', 'update'], // Standard CRUD except delete\n },\n mcp: {\n include: ['list', 'get'], // AI tools for product discovery\n },\n cli: true, // Enable CLI commands for admin\n})\nexport class Product extends SmrtObject {\n /**\n * Tenant ID for multi-tenant isolation.\n * Nullable to support both tenant-scoped and global catalogs.\n */\n @tenantId({ nullable: true })\n tenantId: string | null = null;\n\n /**\n * STI discriminator. Subclasses override this with their type.\n */\n productType: ProductType = ProductType.PRODUCT;\n\n name = '';\n description = '';\n category = ''; // Reference to category\n manufacturer = '';\n model = '';\n price = 0;\n inStock = true;\n specifications: Record<string, any> = {};\n tags: string[] = [];\n\n constructor(options: ProductOptions = {}) {\n super(options);\n if (options.tenantId !== undefined) this.tenantId = options.tenantId;\n // Treat `null` like `undefined`: existing product rows written\n // before the `product_type` column existed hydrate with the field\n // as SQL `NULL`, and without this guard the SmrtObject loader would\n // overwrite the `ProductType.PRODUCT` initializer with `null`. The\n // STI discriminator `_meta_type` still identifies the row's\n // subtype; `productType` is the secondary human-readable label and\n // should fall back to the base default for legacy rows.\n if (options.productType !== undefined && options.productType !== null) {\n this.productType = options.productType;\n }\n this.name = options.name || '';\n this.description = options.description || '';\n this.category = options.category || '';\n this.manufacturer = options.manufacturer || '';\n this.model = options.model || '';\n this.price = options.price || 0;\n this.inStock = options.inStock !== undefined ? options.inStock : true;\n this.specifications = options.specifications || {};\n this.tags = options.tags || [];\n }\n\n async getSpecification(key: string): Promise<any> {\n return this.specifications[key];\n }\n\n async updateSpecification(key: string, value: any): Promise<void> {\n this.specifications[key] = value;\n }\n\n private async getProductAssetCollection() {\n const { ProductAssetCollection } = await import(\n '../collections/ProductAssetCollection'\n );\n return ProductAssetCollection.create({ db: this.db });\n }\n async getAssets(relationship?: string): Promise<Asset[]> {\n if (!this.id) {\n return [];\n }\n\n const productAssets = await this.getProductAssetCollection();\n // Don't pass `this.tenantId` here. ProductAsset is @TenantScoped, so the\n // tenancy interceptor auto-filters the underlying list() by the active\n // context. Passing `this.tenantId` would apply a second explicit filter on\n // TOP of the interceptor's — and when this Product is a global/shared row\n // (`tenantId === null`), that second filter would drop every per-tenant\n // link to it. The interceptor is the right boundary: in a tenant scope it\n // returns that tenant's links; outside any scope it returns everything. See\n // the `ProductAsset` model comment about cross-tenant linking.\n const linkedAssets = await productAssets.byLeft(\n this.id,\n relationship ? { relationship } : {},\n );\n\n // Use the ACTIVE tenant context's tenantId, not `this.tenantId`,\n // when resolving the underlying assets. `resolveOwnedAssetsById`\n // treats its `tenantId` arg as the caller's identity: when set, it\n // enters `withSystemContext` to bypass the interceptor and then\n // includes both that-tenant-owned AND global (tenantId === null)\n // assets in the visible set. Passing `this.tenantId` would force\n // a global Product (`tenantId === null`) running inside a tenant\n // request into the \"no caller tenant\" branch — the interceptor\n // would then filter to only the tenant's own assets and drop\n // every global asset linked to the shared product. Reading the\n // active context fixes both directions: tenant requests see\n // tenant + global assets; system requests see everything.\n const ctxTenantId = getCurrentTenant()?.tenantId ?? null;\n return resolveOwnedAssetsById(\n this.db,\n linkedAssets.map((link) => link.assetId),\n ctxTenantId,\n );\n }\n\n async addAsset(\n asset: Asset,\n relationship = 'attachment',\n sortOrder = 0,\n ): Promise<void> {\n if (!this.id || !asset.id) {\n throw new Error('Cannot associate unsaved product or asset');\n }\n\n assertValidOwnedAssetRelationship(relationship);\n assertValidOwnedAssetSortOrder(sortOrder);\n\n const productAssets = await this.getProductAssetCollection();\n // Same rationale as `getAssets` — the interceptor's auto-populate sets the\n // new row's `tenantId` from the active context, so we don't hard-wire\n // `this.tenantId`. When this Product is global (`tenantId === null`) but a\n // tenant is linking it, the link should land under that tenant, not under\n // the global namespace.\n await productAssets.attach(this.id, asset.id, {\n relationship,\n sortOrder,\n });\n }\n\n async removeAsset(assetId: string, relationship?: string): Promise<void> {\n if (!this.id) {\n return;\n }\n\n const productAssets = await this.getProductAssetCollection();\n // Tenant-scoped delete: pass only the relationship filter and let the\n // interceptor scope the underlying list() to the active tenant, rather\n // than constraining to `this.tenantId` (which on a global product would\n // never match a tenant-owned link). System-style callers without a tenant\n // context sweep every matching row — the existing `detach` semantics.\n await productAssets.detach(\n this.id,\n assetId,\n relationship ? { relationship } : {},\n );\n }\n}\n","/**\n * Material — STI subtype of Product representing a raw input consumed by\n * manufacturing: fabric, thread, trim, labels, packaging, components.\n *\n * Materials are first-class products in the catalog (the SAP/NetSuite pattern):\n * they have a name, description, vendor, unit cost, and live in inventory just\n * like finished goods. Bills of materials in `@happyvertical/smrt-manufacturing`\n * reference Materials by id.\n *\n * @packageDocumentation\n */\n\nimport { type Meta, smrt } from '@happyvertical/smrt-core';\nimport { TenantScoped } from '@happyvertical/smrt-tenancy';\nimport { Product, type ProductOptions } from './Product';\nimport { type MaterialKind, ProductType } from './types';\n\nexport interface MaterialOptions extends ProductOptions {\n materialKind?: MaterialKind;\n uom?: string;\n costPerUnit?: number;\n}\n\n// @TenantScoped is registered per concrete class, so inheriting from\n// Product is NOT enough — `MaterialCollection.list()` passes 'Material'\n// (not 'Product') to the interceptor, which then fails its\n// `isTenantScopedClass(className)` lookup and skips tenant auto-filter\n// + auto-populate. Repeat the decorator here so material rows\n// participate in the same tenant isolation as their Product parent.\n@TenantScoped({ mode: 'optional' })\n// SECURITY (S5 #1406): @smrt() generation config is ALSO registered per\n// concrete class and is NOT inherited from the STI parent. An empty\n// `@smrt()` here would resolve `getConfig('Material').api/.mcp` to\n// `undefined`, which the REST + MCP generators treat as \"expose\n// EVERYTHING\" — including `delete`, `create`, and `update` MCP tools —\n// even though the `Product` base deliberately restricts itself to CRUD\n// (no delete) over REST and read-only (`list`/`get`) over MCP. The\n// products `mcp.ts` generator enumerates the whole registry, so a\n// silently-wide-open Material surface ships the moment the package's own\n// server is generated. Re-declare the parent's restricted posture so the\n// STI child matches its base — and so consumers copying this canonical\n// subtype example (apparel `Style`/`Makeup`, automotive `Model`/`Trim`,\n// …) inherit the secure pattern instead of an accidental open surface.\n@smrt({\n api: {\n include: ['list', 'get', 'create', 'update'], // no delete, matches Product\n },\n mcp: {\n include: ['list', 'get'], // read-only AI tools, matches Product\n },\n cli: true,\n})\nexport class Material extends Product {\n override productType: ProductType = ProductType.MATERIAL;\n\n // STI child-specific fields use the `Meta<T>` type wrapper rather than\n // the runtime `@meta()` decorator. The scanner detects the wrapper at\n // build time (via the type annotation) and emits the field with\n // `type: 'meta'` in the manifest, which routes it through `_meta_data`\n // JSON storage at schema-generation time. The runtime decorator path\n // doesn't reach the manifest, so STI children that only use `@meta()`\n // get materialized as ordinary columns on the parent's table.\n\n /** Classification — fabric, trim, thread, label, packaging, component, ... */\n materialKind: Meta<MaterialKind> = 'component';\n\n /** Unit of measure — \"yards\", \"meters\", \"each\", \"grams\", \"lbs\". */\n uom: Meta<string> = 'each';\n\n /**\n * Latest known cost per UOM. For sophisticated cost rollup, manufacturing\n * may pull from purchase-order history instead of this denormalised value.\n */\n costPerUnit: Meta<number> = 0.0;\n\n constructor(options: MaterialOptions = {}) {\n super(options);\n if (options.materialKind !== undefined)\n this.materialKind = options.materialKind;\n if (options.uom !== undefined) this.uom = options.uom;\n if (options.costPerUnit !== undefined)\n this.costPerUnit = options.costPerUnit;\n }\n}\n","import type { SmrtObjectOptions } from '@happyvertical/smrt-core';\nimport {\n crossPackageRef,\n field,\n foreignKey,\n SmrtObject,\n smrt,\n} from '@happyvertical/smrt-core';\nimport { TenantScoped, tenantId } from '@happyvertical/smrt-tenancy';\n\nexport interface ProductAssetOptions extends SmrtObjectOptions {\n tenantId?: string | null;\n productId?: string;\n assetId?: string;\n relationship?: string;\n sortOrder?: number;\n}\n\n@TenantScoped({ mode: 'optional' })\n@smrt({\n tableName: 'product_assets',\n // tenant_id is included so two tenants can independently link the same\n // shared product/asset under the same relationship without their rows\n // colliding (or worse, one tenant silently overwriting another's link\n // via UPSERT).\n conflictColumns: ['product_id', 'asset_id', 'relationship', 'tenant_id'],\n api: false,\n mcp: false,\n cli: false,\n})\nexport class ProductAsset extends SmrtObject {\n @tenantId({ nullable: true })\n tenantId: string | null = null;\n\n @foreignKey('Product', { required: true })\n productId = '';\n\n @crossPackageRef('@happyvertical/smrt-assets:Asset', { required: true })\n assetId = '';\n\n @field({ required: true })\n relationship = 'attachment';\n\n @field()\n sortOrder = 0;\n\n constructor(options: ProductAssetOptions = {}) {\n super(options);\n if (options.tenantId !== undefined) this.tenantId = options.tenantId;\n if (options.productId) this.productId = options.productId;\n if (options.assetId) this.assetId = options.assetId;\n if (options.relationship) this.relationship = options.relationship;\n if (options.sortOrder !== undefined) this.sortOrder = options.sortOrder;\n }\n}\n","/**\n * ProductVariant — declarative description of one axis along which a\n * product's SKUs differ.\n *\n * A `ProductVariant` row says \"for product X, axis Y has the following\n * allowed values\". The actual per-SKU value lives on `Sku.attributes`\n * (also in this package — `Sku` was relocated to `@happyvertical/smrt-products`\n * in Phase 1; inventory only holds stock motion now), keyed by `axisName`.\n * This split keeps the axis catalog (form choices, UI grouping, ordering)\n * separate from the per-unit instances.\n *\n * Deliberately generic. `axisName` is free-form — apparel teams might\n * use `'size'` and `'color'`, automotive teams `'trim'` and `'engine'`,\n * CPG teams `'packSize'` and `'flavor'`. The framework never inspects\n * the axis name.\n *\n * NOT a Product STI subtype — it's its own model with its own table,\n * because the shape (axis declaration) doesn't fit the Product schema\n * (no name, no price, no category — it's metadata about a Product, not\n * a Product itself).\n *\n * @packageDocumentation\n */\n\nimport {\n field,\n SmrtObject,\n type SmrtObjectOptions,\n smrt,\n} from '@happyvertical/smrt-core';\nimport { TenantScoped, tenantId } from '@happyvertical/smrt-tenancy';\n\n/**\n * Options accepted by the {@link ProductVariant} constructor.\n */\nexport interface ProductVariantOptions extends SmrtObjectOptions {\n tenantId?: string | null;\n productId?: string;\n axisName?: string;\n label?: string;\n allowedValues?: string[] | string;\n sortOrder?: number;\n}\n\n@TenantScoped({ mode: 'optional' })\n@smrt({\n tableName: 'product_variants',\n conflictColumns: ['product_id', 'axis_name', 'tenant_id'],\n api: { include: ['list', 'get', 'create', 'update'] },\n mcp: { include: ['list', 'get'] },\n cli: true,\n})\nexport class ProductVariant extends SmrtObject {\n /** Tenant scope. `null` means the variant axis is global. */\n @tenantId({ nullable: true })\n tenantId: string | null = null;\n\n /**\n * Plain string reference to the {@link Product} this axis belongs to\n * (or any Product STI subtype — `Material`, or vertical subtypes\n * defined in templates such as the apparel `Style` / `Makeup`).\n */\n @field({ required: true })\n productId: string = '';\n\n /**\n * The name of the axis (`'size'`, `'color'`, `'finish'`, `'voltage'`,\n * `'packSize'`, …). Free-form — the framework treats this as opaque.\n */\n @field({ required: true })\n axisName: string = '';\n\n /** Optional human-friendly label for forms / UIs (defaults to `axisName`). */\n label: string = '';\n\n /**\n * Allowed values for this axis, stored as a JSON string. Named\n * `allowedValues` (rather than `values`) because the unprefixed name\n * collides with the SQL `VALUES` keyword on several engines. Use\n * {@link getValues} / {@link setValues} to round-trip the array form.\n */\n allowedValues: string = '[]';\n\n /** Sort order for displaying multiple axes in a consistent column order. */\n sortOrder: number = 0;\n\n constructor(options: ProductVariantOptions = {}) {\n super(options);\n if (options.tenantId !== undefined) this.tenantId = options.tenantId;\n if (options.productId !== undefined) this.productId = options.productId;\n if (options.axisName !== undefined) this.axisName = options.axisName;\n if (options.label !== undefined) this.label = options.label;\n if (options.allowedValues !== undefined)\n this.setValues(options.allowedValues);\n if (options.sortOrder !== undefined) this.sortOrder = options.sortOrder;\n\n // Default the label to axisName when no explicit label was supplied.\n // The field docstring promises this behavior and admin UIs render\n // `variant.label` directly; without this fallback an axis declared\n // as `{ axisName: 'size' }` would render with a blank label.\n if (!this.label && this.axisName) {\n this.label = this.axisName;\n }\n }\n\n /**\n * Parse and return the {@link allowedValues} JSON array. Returns an\n * empty array if the stored value cannot be parsed as an array.\n */\n getValues(): string[] {\n if (!this.allowedValues) return [];\n try {\n const parsed = JSON.parse(this.allowedValues);\n return Array.isArray(parsed) ? parsed.map((value) => String(value)) : [];\n } catch {\n return [];\n }\n }\n\n /**\n * Serialize the allowed values back into the stored\n * {@link allowedValues} string. Accepts either an array or a\n * pre-serialized JSON string.\n */\n setValues(value: string[] | string): void {\n if (typeof value === 'string') {\n this.allowedValues = value;\n return;\n }\n this.allowedValues = JSON.stringify(Array.isArray(value) ? value : []);\n }\n}\n","/**\n * Sku — smallest sellable and countable unit.\n *\n * A SKU is the concrete catalog row that downstream inventory counts.\n * It references a higher-level concept in this same package (a\n * {@link Product} or any of its STI subtypes) via the plain string\n * `productId` field. The same pattern serves apparel (one SKU per\n * size/color), furniture (one SKU per finish), automotive parts,\n * grocery (one SKU per pack size), or any other vertical that needs\n * to count discrete units.\n *\n * Axis values such as `{ size: 'M', color: 'navy' }`, `{ finish: 'walnut' }`,\n * or `{ packSize: '12oz' }` are stored as opaque JSON in `attributes`;\n * the declarative axis catalog lives in {@link ProductVariant} in this\n * same package.\n *\n * Stock balance and movement history for a SKU live in\n * `@happyvertical/smrt-inventory` as `StockLevel` and `StockMovement`.\n *\n * @packageDocumentation\n */\n\nimport {\n field,\n SmrtObject,\n type SmrtObjectOptions,\n smrt,\n} from '@happyvertical/smrt-core';\nimport { TenantScoped, tenantId } from '@happyvertical/smrt-tenancy';\n\n/**\n * Options accepted by the {@link Sku} constructor.\n */\nexport interface SkuOptions extends SmrtObjectOptions {\n tenantId?: string | null;\n productId?: string;\n code?: string;\n barcode?: string;\n name?: string;\n attributes?: Record<string, unknown> | string;\n weightGrams?: number;\n parentSkuId?: string;\n active?: boolean;\n}\n\n@TenantScoped({ mode: 'optional' })\n@smrt({\n tableName: 'product_skus',\n conflictColumns: ['code', 'tenant_id'],\n api: { include: ['list', 'get', 'create', 'update'] },\n mcp: { include: ['list', 'get'] },\n cli: true,\n})\nexport class Sku extends SmrtObject {\n /** Tenant scope. `null` means the SKU is a global record. */\n @tenantId({ nullable: true })\n tenantId: string | null = null;\n\n /**\n * Plain string reference to a row in this package — typically a\n * `Product` id (or any of its STI subtypes, such as `Material`\n * upstream or `Style` / `Makeup` in the apparel template).\n *\n * Marked required so the framework rejects a save with `productId`\n * empty or unset. Without this, downstream consumers (inventory\n * stock motion, manufacturing BOM resolution) would have to filter\n * out orphan SKU rows that point at no product — a sharp footgun\n * the moment one slips through. The `@field({ required: true })`\n * decorator also surfaces the constraint in generated REST/MCP\n * schemas.\n */\n @field({ required: true })\n productId: string = '';\n\n /**\n * Stable, human-meaningful identifier such as a UPC, internal SKU\n * code, or part number. Together with `tenantId` this is the natural\n * key (`conflictColumns: ['code', 'tenant_id']`), so re-saving an\n * identical row is an upsert rather than a UNIQUE violation.\n */\n @field({ required: true })\n code: string = '';\n\n /** Optional scannable barcode (EAN/UPC/Code-128/etc.). */\n barcode: string = '';\n\n /** Display name for UIs. Optional — `code` is enough for machines. */\n name: string = '';\n\n /**\n * Axis values for this SKU expressed as JSON, e.g. `{ size: 'M' }`,\n * `{ finish: 'walnut' }`, or `{ voltage: '230V' }`.\n *\n * The persisted column type is text; use {@link getAttributes} and\n * {@link setAttributes} to round-trip parsed values without worrying\n * about parse errors.\n */\n attributes: string = '{}';\n\n /** Optional physical weight in grams for shipping / cost calculations. */\n @field({ type: 'decimal' })\n weightGrams: number = 0.0;\n\n /**\n * Optional self-reference for bundles / kits — set to the id of the\n * \"parent\" SKU that this SKU is a component of.\n */\n parentSkuId: string = '';\n\n /**\n * Soft-active flag. Inactive SKUs stay queryable for history but\n * should not be offered for sale or production planning.\n */\n active: boolean = true;\n\n constructor(options: SkuOptions = {}) {\n super(options);\n if (options.tenantId !== undefined) this.tenantId = options.tenantId;\n if (options.productId !== undefined) this.productId = options.productId;\n if (options.code !== undefined) this.code = options.code;\n if (options.barcode !== undefined) this.barcode = options.barcode;\n if (options.name !== undefined) this.name = options.name;\n if (options.attributes !== undefined)\n this.setAttributes(options.attributes);\n if (options.weightGrams !== undefined)\n this.weightGrams = options.weightGrams;\n if (options.parentSkuId !== undefined)\n this.parentSkuId = options.parentSkuId;\n if (options.active !== undefined) this.active = options.active;\n }\n\n /**\n * Parse and return the {@link attributes} JSON. Returns an empty\n * object if the stored value is invalid JSON so callers don't have\n * to wrap every read in a try/catch.\n */\n getAttributes(): Record<string, unknown> {\n if (!this.attributes) return {};\n try {\n const parsed = JSON.parse(this.attributes);\n return parsed && typeof parsed === 'object' && !Array.isArray(parsed)\n ? (parsed as Record<string, unknown>)\n : {};\n } catch {\n return {};\n }\n }\n\n /**\n * Serialize axis values back into the stored {@link attributes}\n * string. Accepts either an object (will be `JSON.stringify`'d) or a\n * raw JSON string that the caller has already serialized.\n */\n setAttributes(value: Record<string, unknown> | string): void {\n if (typeof value === 'string') {\n this.attributes = value;\n return;\n }\n this.attributes = JSON.stringify(value ?? {});\n }\n}\n"],"names":["__decorateClass","ProductType"],"mappings":";;;;;;;;;;;;;AAmDO,IAAM,WAAN,cAAuB,WAAW;AAAA,EAMvC,WAA0B;AAAA,EAE1B,OAAO;AAAA,EACP,cAAc;AAAA,EAEd;AAAA;AAAA,EACA,QAAQ;AAAA;AAAA,EACR,eAAe;AAAA;AAAA,EACf,SAAS;AAAA,EAET,YAAY,UAA2B,IAAI;AACzC,UAAM,OAAO;AACb,QAAI,QAAQ,aAAa,OAAW,MAAK,WAAW,QAAQ;AAC5D,SAAK,OAAO,QAAQ,QAA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Bd,IA4BX,WAAA,QAAA,CAAA;AAoBA,gBAAA;AAAA,EADC,MAAM,EAAE,MAAM,UAAA,CAAW;AAAA,GA/Cf,IAgDX,WAAA,eAAA,CAAA;AAhDW,MAAN,gBAAA;AAAA,EARN,aAAa,EAAE,MAAM,YAAY;AAAA,EACjC,KAAK;AAAA,IACJ,WAAW;AAAA,IACX,iBAAiB,CAAC,QAAQ,WAAW;AAAA,IACrC,KAAK,EAAE,SAAS,CAAC,QAAQ,OAAO,UAAU,QAAQ,EAAA;AAAA,IAClD,KAAK,EAAE,SAAS,CAAC,QAAQ,KAAK,EAAA;AAAA,IAC9B,KAAK;AAAA,EAAA,CACN;AAAA,GACY,GAAA;"}
|
|
1
|
+
{"version":3,"file":"Sku-sl6xf1PR.js","sources":["../../../src/lib/models/Category.ts","../../../src/lib/models/types.ts","../../../src/lib/models/Product.ts","../../../src/lib/models/Material.ts","../../../src/lib/models/ProductAsset.ts","../../../src/lib/models/ProductVariant.ts","../../../src/lib/models/Sku.ts"],"sourcesContent":["/**\n * Product knowledge base category model\n *\n * SMRT auto-generates REST APIs, MCP tools, and TypeScript clients from this class.\n */\n\nimport {\n foreignKey,\n SmrtObject,\n type SmrtObjectOptions,\n smrt,\n} from '@happyvertical/smrt-core';\nimport { TenantScoped, tenantId } from '@happyvertical/smrt-tenancy';\n\n/**\n * Options for Category initialization\n */\nexport interface CategoryOptions extends SmrtObjectOptions {\n tenantId?: string | null;\n name?: string;\n description?: string;\n parentId?: string;\n level?: number;\n productCount?: number;\n active?: boolean;\n}\n\n/**\n * Product knowledge base category for organizing product information.\n *\n * Optional tenancy — categories may be shared globally (tenantId=null) or\n * scoped to a tenant. Hierarchical via parentId.\n */\n@TenantScoped({ mode: 'optional' })\n@smrt({\n tableStrategy: 'sti',\n // See the matching note on `Product` — overriding `conflictColumns`\n // to include `tenant_id` causes a SQLite `ON CONFLICT clause does not\n // match any … UNIQUE constraint` error because the core schema\n // generator's hardcoded STI unique index is `(slug, context,\n // _meta_type)` and does not include the tenant column. Until the\n // upstream framework fix lands, two tenants cannot share a category\n // slug at the schema level.\n api: {\n include: ['list', 'get', 'create', 'update'], // Standard CRUD except delete\n },\n mcp: {\n include: ['list', 'get'], // AI tools for category discovery\n },\n cli: true, // Enable CLI commands for admin\n})\nexport class Category extends SmrtObject {\n /**\n * Tenant ID for multi-tenant isolation.\n * Nullable to support both tenant-scoped and global categories.\n */\n @tenantId({ nullable: true })\n tenantId: string | null = null;\n\n name = '';\n description = '';\n @foreignKey('Category')\n parentId?: string; // For hierarchical categories\n level = 0; // Category depth in hierarchy\n productCount = 0; // Number of products in this category\n active = true;\n\n constructor(options: CategoryOptions = {}) {\n super(options);\n if (options.tenantId !== undefined) this.tenantId = options.tenantId;\n this.name = options.name || '';\n this.description = options.description || '';\n this.parentId = options.parentId;\n this.level = options.level || 0;\n this.productCount = options.productCount || 0;\n this.active = options.active !== undefined ? options.active : true;\n }\n}\n","/**\n * Shared types for the products package.\n *\n * @packageDocumentation\n */\n\n/**\n * Discriminator for Product STI subtypes.\n *\n * Industry-vertical templates extend `Product` with their own STI subtypes\n * (apparel uses `Style`/`Makeup`; furniture might use `Design`/`Finish`;\n * automotive `Model`/`Trim`) — the upstream package only ships the truly\n * generic primitives:\n *\n * - {@link ProductType.PRODUCT} — plain catalog item (base)\n * - {@link ProductType.MATERIAL} — raw input consumed by manufacturing\n *\n * The axis-declaration concept (\"this product varies along `size` with\n * values `[XS, S, M, L, XL]`\") is NOT a Product STI subtype — it lives in\n * its own model, {@link ProductVariant}, with a separate table. Per-SKU\n * value pins live on `Sku.attributes` (also in this package — `Sku` was\n * relocated from `@happyvertical/smrt-inventory` to here in Phase 1 so\n * every catalog primitive lives under one roof; inventory only holds\n * stock levels and movements now).\n */\nexport enum ProductType {\n /** Generic catalog item (default). */\n PRODUCT = 'product',\n /** A raw input — fabric, trim, packaging, etc. — consumed by manufacturing. */\n MATERIAL = 'material',\n}\n\n/**\n * High-level classification of a {@link ProductType.MATERIAL} item.\n *\n * Open string so consumers can extend with vertical-specific kinds without\n * an enum change. The `(string & {})` branch preserves the literal-string\n * autocomplete suggestions in IDEs — a bare `| string` would collapse the\n * whole union to `string` and erase the named hints (same pattern as\n * `StockMovementReason` in `@happyvertical/smrt-inventory`).\n */\nexport type MaterialKind =\n | 'fabric'\n | 'trim'\n | 'thread'\n | 'label'\n | 'packaging'\n | 'component'\n | (string & {});\n","/**\n * Product knowledge base model\n *\n * SMRT auto-generates REST APIs, MCP tools, and TypeScript clients from this class.\n */\n\nimport type { Asset } from '@happyvertical/smrt-assets';\nimport {\n assertValidOwnedAssetRelationship,\n assertValidOwnedAssetSortOrder,\n resolveOwnedAssetsById,\n} from '@happyvertical/smrt-assets';\nimport {\n SmrtObject,\n type SmrtObjectOptions,\n smrt,\n} from '@happyvertical/smrt-core';\nimport {\n getCurrentTenant,\n TenantScoped,\n tenantId,\n} from '@happyvertical/smrt-tenancy';\nimport { ProductType } from './types';\n\n/**\n * Options for Product initialization\n */\nexport interface ProductOptions extends SmrtObjectOptions {\n tenantId?: string | null;\n productType?: ProductType;\n name?: string;\n description?: string;\n category?: string;\n manufacturer?: string;\n model?: string;\n price?: number;\n inStock?: boolean;\n specifications?: Record<string, unknown>;\n tags?: string[];\n}\n\n/**\n * Product information for knowledge base queries.\n *\n * STI base — subclasses (e.g. `Material` upstream, `Style`/`Makeup` in the\n * apparel template) share this table via the `_meta_type` discriminator\n * and `productType` field. Optional tenancy lets the same package serve\n * shared global catalogs OR per-merchant catalogs.\n */\n@TenantScoped({ mode: 'optional' })\n@smrt({\n tableStrategy: 'sti',\n // KNOWN LIMITATION (tracked for framework follow-up): the core schema\n // generator hardcodes the STI unique index as\n // `(slug, context, _meta_type)` and does not include `tenant_id`\n // even when the class is `@TenantScoped`. As a result two tenants\n // cannot save a row with the same slug+context+type — the UNIQUE\n // constraint at the SQL layer rejects the second insert.\n //\n // We deliberately do NOT override `conflictColumns` here to add\n // `tenant_id`: doing so would put the runtime upsert path\n // (`ON CONFLICT ('slug','context','_meta_type','tenant_id')`) out of\n // step with the actual unique index, producing `SQLITE_ERROR: ON\n // CONFLICT clause does not match any … UNIQUE constraint` on every\n // save. Production callers should either (a) namespace their slugs\n // per tenant on the application side (e.g. `${tenantId}-widget`), or\n // (b) wait for the upstream framework fix that extends the STI\n // unique index with `tenant_id` for tenant-scoped tables.\n api: {\n include: ['list', 'get', 'create', 'update'], // Standard CRUD except delete\n },\n mcp: {\n include: ['list', 'get'], // AI tools for product discovery\n },\n cli: true, // Enable CLI commands for admin\n})\nexport class Product extends SmrtObject {\n /**\n * Tenant ID for multi-tenant isolation.\n * Nullable to support both tenant-scoped and global catalogs.\n */\n @tenantId({ nullable: true })\n tenantId: string | null = null;\n\n /**\n * STI discriminator. Subclasses override this with their type.\n */\n productType: ProductType = ProductType.PRODUCT;\n\n name = '';\n description = '';\n category = ''; // Reference to category\n manufacturer = '';\n model = '';\n price = 0;\n inStock = true;\n specifications: Record<string, unknown> = {};\n tags: string[] = [];\n\n constructor(options: ProductOptions = {}) {\n super(options);\n if (options.tenantId !== undefined) this.tenantId = options.tenantId;\n // Treat `null` like `undefined`: existing product rows written\n // before the `product_type` column existed hydrate with the field\n // as SQL `NULL`, and without this guard the SmrtObject loader would\n // overwrite the `ProductType.PRODUCT` initializer with `null`. The\n // STI discriminator `_meta_type` still identifies the row's\n // subtype; `productType` is the secondary human-readable label and\n // should fall back to the base default for legacy rows.\n if (options.productType !== undefined && options.productType !== null) {\n this.productType = options.productType;\n }\n this.name = options.name || '';\n this.description = options.description || '';\n this.category = options.category || '';\n this.manufacturer = options.manufacturer || '';\n this.model = options.model || '';\n this.price = options.price || 0;\n this.inStock = options.inStock !== undefined ? options.inStock : true;\n this.specifications = options.specifications || {};\n this.tags = options.tags || [];\n }\n\n async getSpecification(key: string): Promise<unknown> {\n return this.specifications[key];\n }\n\n async updateSpecification(key: string, value: unknown): Promise<void> {\n this.specifications[key] = value;\n }\n\n private async getProductAssetCollection() {\n const { ProductAssetCollection } = await import(\n '../collections/ProductAssetCollection'\n );\n return ProductAssetCollection.create({ db: this.db });\n }\n async getAssets(relationship?: string): Promise<Asset[]> {\n if (!this.id) {\n return [];\n }\n\n const productAssets = await this.getProductAssetCollection();\n // Don't pass `this.tenantId` here. ProductAsset is @TenantScoped, so the\n // tenancy interceptor auto-filters the underlying list() by the active\n // context. Passing `this.tenantId` would apply a second explicit filter on\n // TOP of the interceptor's — and when this Product is a global/shared row\n // (`tenantId === null`), that second filter would drop every per-tenant\n // link to it. The interceptor is the right boundary: in a tenant scope it\n // returns that tenant's links; outside any scope it returns everything. See\n // the `ProductAsset` model comment about cross-tenant linking.\n const linkedAssets = await productAssets.byLeft(\n this.id,\n relationship ? { relationship } : {},\n );\n\n // Use the ACTIVE tenant context's tenantId, not `this.tenantId`,\n // when resolving the underlying assets. `resolveOwnedAssetsById`\n // treats its `tenantId` arg as the caller's identity: when set, it\n // enters `withSystemContext` to bypass the interceptor and then\n // includes both that-tenant-owned AND global (tenantId === null)\n // assets in the visible set. Passing `this.tenantId` would force\n // a global Product (`tenantId === null`) running inside a tenant\n // request into the \"no caller tenant\" branch — the interceptor\n // would then filter to only the tenant's own assets and drop\n // every global asset linked to the shared product. Reading the\n // active context fixes both directions: tenant requests see\n // tenant + global assets; system requests see everything.\n const ctxTenantId = getCurrentTenant()?.tenantId ?? null;\n return resolveOwnedAssetsById(\n this.db,\n linkedAssets.map((link) => link.assetId),\n ctxTenantId,\n );\n }\n\n async addAsset(\n asset: Asset,\n relationship = 'attachment',\n sortOrder = 0,\n ): Promise<void> {\n if (!this.id || !asset.id) {\n throw new Error('Cannot associate unsaved product or asset');\n }\n\n assertValidOwnedAssetRelationship(relationship);\n assertValidOwnedAssetSortOrder(sortOrder);\n\n const productAssets = await this.getProductAssetCollection();\n // Same rationale as `getAssets` — the interceptor's auto-populate sets the\n // new row's `tenantId` from the active context, so we don't hard-wire\n // `this.tenantId`. When this Product is global (`tenantId === null`) but a\n // tenant is linking it, the link should land under that tenant, not under\n // the global namespace.\n await productAssets.attach(this.id, asset.id, {\n relationship,\n sortOrder,\n });\n }\n\n async removeAsset(assetId: string, relationship?: string): Promise<void> {\n if (!this.id) {\n return;\n }\n\n const productAssets = await this.getProductAssetCollection();\n // Tenant-scoped delete: pass only the relationship filter and let the\n // interceptor scope the underlying list() to the active tenant, rather\n // than constraining to `this.tenantId` (which on a global product would\n // never match a tenant-owned link). System-style callers without a tenant\n // context sweep every matching row — the existing `detach` semantics.\n await productAssets.detach(\n this.id,\n assetId,\n relationship ? { relationship } : {},\n );\n }\n}\n","/**\n * Material — STI subtype of Product representing a raw input consumed by\n * manufacturing: fabric, thread, trim, labels, packaging, components.\n *\n * Materials are first-class products in the catalog (the SAP/NetSuite pattern):\n * they have a name, description, vendor, unit cost, and live in inventory just\n * like finished goods. Bills of materials in `@happyvertical/smrt-manufacturing`\n * reference Materials by id.\n *\n * @packageDocumentation\n */\n\nimport { type Meta, smrt } from '@happyvertical/smrt-core';\nimport { TenantScoped } from '@happyvertical/smrt-tenancy';\nimport { Product, type ProductOptions } from './Product';\nimport { type MaterialKind, ProductType } from './types';\n\nexport interface MaterialOptions extends ProductOptions {\n materialKind?: MaterialKind;\n uom?: string;\n costPerUnit?: number;\n}\n\n// @TenantScoped is registered per concrete class, so inheriting from\n// Product is NOT enough — `MaterialCollection.list()` passes 'Material'\n// (not 'Product') to the interceptor, which then fails its\n// `isTenantScopedClass(className)` lookup and skips tenant auto-filter\n// + auto-populate. Repeat the decorator here so material rows\n// participate in the same tenant isolation as their Product parent.\n@TenantScoped({ mode: 'optional' })\n// SECURITY (S5 #1406): @smrt() generation config is ALSO registered per\n// concrete class and is NOT inherited from the STI parent. An empty\n// `@smrt()` here would resolve `getConfig('Material').api/.mcp` to\n// `undefined`, which the REST + MCP generators treat as \"expose\n// EVERYTHING\" — including `delete`, `create`, and `update` MCP tools —\n// even though the `Product` base deliberately restricts itself to CRUD\n// (no delete) over REST and read-only (`list`/`get`) over MCP. The\n// products `mcp.ts` generator enumerates the whole registry, so a\n// silently-wide-open Material surface ships the moment the package's own\n// server is generated. Re-declare the parent's restricted posture so the\n// STI child matches its base — and so consumers copying this canonical\n// subtype example (apparel `Style`/`Makeup`, automotive `Model`/`Trim`,\n// …) inherit the secure pattern instead of an accidental open surface.\n@smrt({\n api: {\n include: ['list', 'get', 'create', 'update'], // no delete, matches Product\n },\n mcp: {\n include: ['list', 'get'], // read-only AI tools, matches Product\n },\n cli: true,\n})\nexport class Material extends Product {\n override productType: ProductType = ProductType.MATERIAL;\n\n // STI child-specific fields use the `Meta<T>` type wrapper rather than\n // the runtime `@meta()` decorator. The scanner detects the wrapper at\n // build time (via the type annotation) and emits the field with\n // `type: 'meta'` in the manifest, which routes it through `_meta_data`\n // JSON storage at schema-generation time. The runtime decorator path\n // doesn't reach the manifest, so STI children that only use `@meta()`\n // get materialized as ordinary columns on the parent's table.\n\n /** Classification — fabric, trim, thread, label, packaging, component, ... */\n materialKind: Meta<MaterialKind> = 'component';\n\n /** Unit of measure — \"yards\", \"meters\", \"each\", \"grams\", \"lbs\". */\n uom: Meta<string> = 'each';\n\n /**\n * Latest known cost per UOM. For sophisticated cost rollup, manufacturing\n * may pull from purchase-order history instead of this denormalised value.\n */\n costPerUnit: Meta<number> = 0.0;\n\n constructor(options: MaterialOptions = {}) {\n super(options);\n if (options.materialKind !== undefined)\n this.materialKind = options.materialKind;\n if (options.uom !== undefined) this.uom = options.uom;\n if (options.costPerUnit !== undefined)\n this.costPerUnit = options.costPerUnit;\n }\n}\n","import type { SmrtObjectOptions } from '@happyvertical/smrt-core';\nimport {\n crossPackageRef,\n field,\n foreignKey,\n SmrtObject,\n smrt,\n} from '@happyvertical/smrt-core';\nimport { TenantScoped, tenantId } from '@happyvertical/smrt-tenancy';\n\nexport interface ProductAssetOptions extends SmrtObjectOptions {\n tenantId?: string | null;\n productId?: string;\n assetId?: string;\n relationship?: string;\n sortOrder?: number;\n}\n\n@TenantScoped({ mode: 'optional' })\n@smrt({\n tableName: 'product_assets',\n // tenant_id is included so two tenants can independently link the same\n // shared product/asset under the same relationship without their rows\n // colliding (or worse, one tenant silently overwriting another's link\n // via UPSERT).\n conflictColumns: ['product_id', 'asset_id', 'relationship', 'tenant_id'],\n api: false,\n mcp: false,\n cli: false,\n})\nexport class ProductAsset extends SmrtObject {\n @tenantId({ nullable: true })\n tenantId: string | null = null;\n\n @foreignKey('Product', { required: true })\n productId = '';\n\n @crossPackageRef('@happyvertical/smrt-assets:Asset', { required: true })\n assetId = '';\n\n @field({ required: true })\n relationship = 'attachment';\n\n @field()\n sortOrder = 0;\n\n constructor(options: ProductAssetOptions = {}) {\n super(options);\n if (options.tenantId !== undefined) this.tenantId = options.tenantId;\n if (options.productId) this.productId = options.productId;\n if (options.assetId) this.assetId = options.assetId;\n if (options.relationship) this.relationship = options.relationship;\n if (options.sortOrder !== undefined) this.sortOrder = options.sortOrder;\n }\n}\n","/**\n * ProductVariant — declarative description of one axis along which a\n * product's SKUs differ.\n *\n * A `ProductVariant` row says \"for product X, axis Y has the following\n * allowed values\". The actual per-SKU value lives on `Sku.attributes`\n * (also in this package — `Sku` was relocated to `@happyvertical/smrt-products`\n * in Phase 1; inventory only holds stock motion now), keyed by `axisName`.\n * This split keeps the axis catalog (form choices, UI grouping, ordering)\n * separate from the per-unit instances.\n *\n * Deliberately generic. `axisName` is free-form — apparel teams might\n * use `'size'` and `'color'`, automotive teams `'trim'` and `'engine'`,\n * CPG teams `'packSize'` and `'flavor'`. The framework never inspects\n * the axis name.\n *\n * NOT a Product STI subtype — it's its own model with its own table,\n * because the shape (axis declaration) doesn't fit the Product schema\n * (no name, no price, no category — it's metadata about a Product, not\n * a Product itself).\n *\n * @packageDocumentation\n */\n\nimport {\n field,\n SmrtObject,\n type SmrtObjectOptions,\n smrt,\n} from '@happyvertical/smrt-core';\nimport { TenantScoped, tenantId } from '@happyvertical/smrt-tenancy';\n\n/**\n * Options accepted by the {@link ProductVariant} constructor.\n */\nexport interface ProductVariantOptions extends SmrtObjectOptions {\n tenantId?: string | null;\n productId?: string;\n axisName?: string;\n label?: string;\n allowedValues?: string[] | string;\n sortOrder?: number;\n}\n\n@TenantScoped({ mode: 'optional' })\n@smrt({\n tableName: 'product_variants',\n conflictColumns: ['product_id', 'axis_name', 'tenant_id'],\n api: { include: ['list', 'get', 'create', 'update'] },\n mcp: { include: ['list', 'get'] },\n cli: true,\n})\nexport class ProductVariant extends SmrtObject {\n /** Tenant scope. `null` means the variant axis is global. */\n @tenantId({ nullable: true })\n tenantId: string | null = null;\n\n /**\n * Plain string reference to the {@link Product} this axis belongs to\n * (or any Product STI subtype — `Material`, or vertical subtypes\n * defined in templates such as the apparel `Style` / `Makeup`).\n */\n @field({ required: true })\n productId: string = '';\n\n /**\n * The name of the axis (`'size'`, `'color'`, `'finish'`, `'voltage'`,\n * `'packSize'`, …). Free-form — the framework treats this as opaque.\n */\n @field({ required: true })\n axisName: string = '';\n\n /** Optional human-friendly label for forms / UIs (defaults to `axisName`). */\n label: string = '';\n\n /**\n * Allowed values for this axis, stored as a JSON string. Named\n * `allowedValues` (rather than `values`) because the unprefixed name\n * collides with the SQL `VALUES` keyword on several engines. Use\n * {@link getValues} / {@link setValues} to round-trip the array form.\n */\n allowedValues: string = '[]';\n\n /** Sort order for displaying multiple axes in a consistent column order. */\n sortOrder: number = 0;\n\n constructor(options: ProductVariantOptions = {}) {\n super(options);\n if (options.tenantId !== undefined) this.tenantId = options.tenantId;\n if (options.productId !== undefined) this.productId = options.productId;\n if (options.axisName !== undefined) this.axisName = options.axisName;\n if (options.label !== undefined) this.label = options.label;\n if (options.allowedValues !== undefined)\n this.setValues(options.allowedValues);\n if (options.sortOrder !== undefined) this.sortOrder = options.sortOrder;\n\n // Default the label to axisName when no explicit label was supplied.\n // The field docstring promises this behavior and admin UIs render\n // `variant.label` directly; without this fallback an axis declared\n // as `{ axisName: 'size' }` would render with a blank label.\n if (!this.label && this.axisName) {\n this.label = this.axisName;\n }\n }\n\n /**\n * Parse and return the {@link allowedValues} JSON array. Returns an\n * empty array if the stored value cannot be parsed as an array.\n */\n getValues(): string[] {\n if (!this.allowedValues) return [];\n try {\n const parsed = JSON.parse(this.allowedValues);\n return Array.isArray(parsed) ? parsed.map((value) => String(value)) : [];\n } catch {\n return [];\n }\n }\n\n /**\n * Serialize the allowed values back into the stored\n * {@link allowedValues} string. Accepts either an array or a\n * pre-serialized JSON string.\n */\n setValues(value: string[] | string): void {\n if (typeof value === 'string') {\n this.allowedValues = value;\n return;\n }\n this.allowedValues = JSON.stringify(Array.isArray(value) ? value : []);\n }\n}\n","/**\n * Sku — smallest sellable and countable unit.\n *\n * A SKU is the concrete catalog row that downstream inventory counts.\n * It references a higher-level concept in this same package (a\n * {@link Product} or any of its STI subtypes) via the plain string\n * `productId` field. The same pattern serves apparel (one SKU per\n * size/color), furniture (one SKU per finish), automotive parts,\n * grocery (one SKU per pack size), or any other vertical that needs\n * to count discrete units.\n *\n * Axis values such as `{ size: 'M', color: 'navy' }`, `{ finish: 'walnut' }`,\n * or `{ packSize: '12oz' }` are stored as opaque JSON in `attributes`;\n * the declarative axis catalog lives in {@link ProductVariant} in this\n * same package.\n *\n * Stock balance and movement history for a SKU live in\n * `@happyvertical/smrt-inventory` as `StockLevel` and `StockMovement`.\n *\n * @packageDocumentation\n */\n\nimport {\n field,\n SmrtObject,\n type SmrtObjectOptions,\n smrt,\n} from '@happyvertical/smrt-core';\nimport { TenantScoped, tenantId } from '@happyvertical/smrt-tenancy';\n\n/**\n * Options accepted by the {@link Sku} constructor.\n */\nexport interface SkuOptions extends SmrtObjectOptions {\n tenantId?: string | null;\n productId?: string;\n code?: string;\n barcode?: string;\n name?: string;\n attributes?: Record<string, unknown> | string;\n weightGrams?: number;\n parentSkuId?: string;\n active?: boolean;\n}\n\n@TenantScoped({ mode: 'optional' })\n@smrt({\n tableName: 'product_skus',\n conflictColumns: ['code', 'tenant_id'],\n api: { include: ['list', 'get', 'create', 'update'] },\n mcp: { include: ['list', 'get'] },\n cli: true,\n})\nexport class Sku extends SmrtObject {\n /** Tenant scope. `null` means the SKU is a global record. */\n @tenantId({ nullable: true })\n tenantId: string | null = null;\n\n /**\n * Plain string reference to a row in this package — typically a\n * `Product` id (or any of its STI subtypes, such as `Material`\n * upstream or `Style` / `Makeup` in the apparel template).\n *\n * Marked required so the framework rejects a save with `productId`\n * empty or unset. Without this, downstream consumers (inventory\n * stock motion, manufacturing BOM resolution) would have to filter\n * out orphan SKU rows that point at no product — a sharp footgun\n * the moment one slips through. The `@field({ required: true })`\n * decorator also surfaces the constraint in generated REST/MCP\n * schemas.\n */\n @field({ required: true })\n productId: string = '';\n\n /**\n * Stable, human-meaningful identifier such as a UPC, internal SKU\n * code, or part number. Together with `tenantId` this is the natural\n * key (`conflictColumns: ['code', 'tenant_id']`), so re-saving an\n * identical row is an upsert rather than a UNIQUE violation.\n */\n @field({ required: true })\n code: string = '';\n\n /** Optional scannable barcode (EAN/UPC/Code-128/etc.). */\n barcode: string = '';\n\n /** Display name for UIs. Optional — `code` is enough for machines. */\n name: string = '';\n\n /**\n * Axis values for this SKU expressed as JSON, e.g. `{ size: 'M' }`,\n * `{ finish: 'walnut' }`, or `{ voltage: '230V' }`.\n *\n * The persisted column type is text; use {@link getAttributes} and\n * {@link setAttributes} to round-trip parsed values without worrying\n * about parse errors.\n */\n attributes: string = '{}';\n\n /** Optional physical weight in grams for shipping / cost calculations. */\n @field({ type: 'decimal' })\n weightGrams: number = 0.0;\n\n /**\n * Optional self-reference for bundles / kits — set to the id of the\n * \"parent\" SKU that this SKU is a component of.\n */\n parentSkuId: string = '';\n\n /**\n * Soft-active flag. Inactive SKUs stay queryable for history but\n * should not be offered for sale or production planning.\n */\n active: boolean = true;\n\n constructor(options: SkuOptions = {}) {\n super(options);\n if (options.tenantId !== undefined) this.tenantId = options.tenantId;\n if (options.productId !== undefined) this.productId = options.productId;\n if (options.code !== undefined) this.code = options.code;\n if (options.barcode !== undefined) this.barcode = options.barcode;\n if (options.name !== undefined) this.name = options.name;\n if (options.attributes !== undefined)\n this.setAttributes(options.attributes);\n if (options.weightGrams !== undefined)\n this.weightGrams = options.weightGrams;\n if (options.parentSkuId !== undefined)\n this.parentSkuId = options.parentSkuId;\n if (options.active !== undefined) this.active = options.active;\n }\n\n /**\n * Parse and return the {@link attributes} JSON. Returns an empty\n * object if the stored value is invalid JSON so callers don't have\n * to wrap every read in a try/catch.\n */\n getAttributes(): Record<string, unknown> {\n if (!this.attributes) return {};\n try {\n const parsed = JSON.parse(this.attributes);\n return parsed && typeof parsed === 'object' && !Array.isArray(parsed)\n ? (parsed as Record<string, unknown>)\n : {};\n } catch {\n return {};\n }\n }\n\n /**\n * Serialize axis values back into the stored {@link attributes}\n * string. Accepts either an object (will be `JSON.stringify`'d) or a\n * raw JSON string that the caller has already serialized.\n */\n setAttributes(value: Record<string, unknown> | string): void {\n if (typeof value === 'string') {\n this.attributes = value;\n return;\n }\n this.attributes = JSON.stringify(value ?? {});\n }\n}\n"],"names":["__decorateClass","ProductType"],"mappings":";;;;;;;;;;;;;AAmDO,IAAM,WAAN,cAAuB,WAAW;AAAA,EAMvC,WAA0B;AAAA,EAE1B,OAAO;AAAA,EACP,cAAc;AAAA,EAEd;AAAA;AAAA,EACA,QAAQ;AAAA;AAAA,EACR,eAAe;AAAA;AAAA,EACf,SAAS;AAAA,EAET,YAAY,UAA2B,IAAI;AACzC,UAAM,OAAO;AACb,QAAI,QAAQ,aAAa,OAAW,MAAK,WAAW,QAAQ;AAC5D,SAAK,OAAO,QAAQ,QAAQ;AAC5B,SAAK,cAAc,QAAQ,eAAe;AAC1C,SAAK,WAAW,QAAQ;AACxB,SAAK,QAAQ,QAAQ,SAAS;AAC9B,SAAK,eAAe,QAAQ,gBAAgB;AAC5C,SAAK,SAAS,QAAQ,WAAW,SAAY,QAAQ,SAAS;AAAA,EAChE;AACF;AApBEA,kBAAA;AAAA,EADC,SAAS,EAAE,UAAU,KAAA,CAAM;AAAA,GALjB,SAMX,WAAA,YAAA,CAAA;AAKAA,kB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OAAO,UAAU,QAAQ,EAAA;AAAA,IAClD,KAAK,EAAE,SAAS,CAAC,QAAQ,KAAK,EAAA;AAAA,IAC9B,KAAK;AAAA,EAAA,CACN;AAAA,GACY,GAAA;"}
|
|
@@ -82,8 +82,10 @@ $effect(() => {
|
|
|
82
82
|
formData = { ...data };
|
|
83
83
|
});
|
|
84
84
|
|
|
85
|
-
function updateField(fieldName: string, value:
|
|
86
|
-
|
|
85
|
+
function updateField(fieldName: string, value: unknown) {
|
|
86
|
+
// Dynamic write keyed by field name; the schema guarantees the key/value
|
|
87
|
+
// pairing at runtime, so cast the target to a writable string-keyed record.
|
|
88
|
+
(formData as Record<string, unknown>)[fieldName] = value;
|
|
87
89
|
|
|
88
90
|
// Trigger change callback
|
|
89
91
|
if (onChange) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutoForm.svelte.d.ts","sourceRoot":"","sources":["../../../../../src/lib/components/auto-generated/AutoForm.svelte.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI/C,UAAU,KAAK;IACb,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,CAAC;IACvC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,CAAC;CACxC;
|
|
1
|
+
{"version":3,"file":"AutoForm.svelte.d.ts","sourceRoot":"","sources":["../../../../../src/lib/components/auto-generated/AutoForm.svelte.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAI/C,UAAU,KAAK;IACb,IAAI,CAAC,EAAE,WAAW,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,CAAC;IACvC,QAAQ,CAAC,EAAE,CAAC,IAAI,EAAE,WAAW,KAAK,IAAI,CAAC;CACxC;AAyID,QAAA,MAAM,QAAQ,2CAAwC,CAAC;AACvD,KAAK,QAAQ,GAAG,UAAU,CAAC,OAAO,QAAQ,CAAC,CAAC;AAC5C,eAAe,QAAQ,CAAC"}
|
|
@@ -13,12 +13,12 @@ const { t } = useI18n();
|
|
|
13
13
|
interface Props {
|
|
14
14
|
fieldName: string;
|
|
15
15
|
fieldType: 'string' | 'number' | 'boolean' | 'array' | 'object';
|
|
16
|
-
value:
|
|
16
|
+
value: unknown;
|
|
17
17
|
label?: string;
|
|
18
18
|
placeholder?: string;
|
|
19
19
|
required?: boolean;
|
|
20
20
|
readonly?: boolean;
|
|
21
|
-
onUpdate?: (value:
|
|
21
|
+
onUpdate?: (value: unknown) => void;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
const {
|
|
@@ -41,7 +41,7 @@ const displayLabel = $derived(
|
|
|
41
41
|
);
|
|
42
42
|
const fieldId = $derived(`field-${fieldName}`);
|
|
43
43
|
|
|
44
|
-
function handleUpdate(newValue:
|
|
44
|
+
function handleUpdate(newValue: unknown) {
|
|
45
45
|
if (onUpdate && !readonly) {
|
|
46
46
|
onUpdate(newValue);
|
|
47
47
|
}
|
|
@@ -97,7 +97,7 @@ function handleObjectInput(event: Event) {
|
|
|
97
97
|
<Input
|
|
98
98
|
id={fieldId}
|
|
99
99
|
type="text"
|
|
100
|
-
{value}
|
|
100
|
+
value={String(value ?? '')}
|
|
101
101
|
{placeholder}
|
|
102
102
|
{readonly}
|
|
103
103
|
{required}
|
|
@@ -107,7 +107,7 @@ function handleObjectInput(event: Event) {
|
|
|
107
107
|
<Input
|
|
108
108
|
id={fieldId}
|
|
109
109
|
type="number"
|
|
110
|
-
value={value || 0}
|
|
110
|
+
value={typeof value === 'number' ? value : Number(value) || 0}
|
|
111
111
|
{placeholder}
|
|
112
112
|
{readonly}
|
|
113
113
|
{required}
|
|
@@ -119,7 +119,7 @@ function handleObjectInput(event: Event) {
|
|
|
119
119
|
id={fieldId}
|
|
120
120
|
type="checkbox"
|
|
121
121
|
class="field-checkbox"
|
|
122
|
-
checked={value
|
|
122
|
+
checked={Boolean(value)}
|
|
123
123
|
{readonly}
|
|
124
124
|
onchange={handleBooleanInput}
|
|
125
125
|
/>
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
interface Props {
|
|
2
2
|
fieldName: string;
|
|
3
3
|
fieldType: 'string' | 'number' | 'boolean' | 'array' | 'object';
|
|
4
|
-
value:
|
|
4
|
+
value: unknown;
|
|
5
5
|
label?: string;
|
|
6
6
|
placeholder?: string;
|
|
7
7
|
required?: boolean;
|
|
8
8
|
readonly?: boolean;
|
|
9
|
-
onUpdate?: (value:
|
|
9
|
+
onUpdate?: (value: unknown) => void;
|
|
10
10
|
}
|
|
11
11
|
declare const FieldRenderer: import("svelte").Component<Props, {}, "">;
|
|
12
12
|
type FieldRenderer = ReturnType<typeof FieldRenderer>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldRenderer.svelte.d.ts","sourceRoot":"","sources":["../../../../../src/lib/components/auto-generated/FieldRenderer.svelte.ts"],"names":[],"mappings":"AAYA,UAAU,KAAK;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,CAAC;IAChE,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"FieldRenderer.svelte.d.ts","sourceRoot":"","sources":["../../../../../src/lib/components/auto-generated/FieldRenderer.svelte.ts"],"names":[],"mappings":"AAYA,UAAU,KAAK;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,GAAG,OAAO,GAAG,QAAQ,CAAC;IAChE,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CACrC;AAsGD,QAAA,MAAM,aAAa,2CAAwC,CAAC;AAC5D,KAAK,aAAa,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC;AACtD,eAAe,aAAa,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mock-smrt-client.js","sources":["../../../src/lib/mock-smrt-client.ts"],"sourcesContent":["/**\n * Mock SMRT Client - Temporary implementation for demo purposes\n *\n * This replaces the missing @smrt/client virtual module with a working implementation\n * that demonstrates the intended functionality.\n */\n\n// Re-use the canonical UI ProductData shape so the mock client, the stores,\n// and the components all agree on one type. The shape uses snake_case\n// timestamps (`created_at`/`updated_at`) to match the SMRT server payload.\nimport type { ProductData } from './types';\n\nexport type { ProductData } from './types';\n\nexport interface ApiResponse<T> {\n data: T;\n success: boolean;\n message?: string;\n}\n\n// Mock data store\nconst mockProducts: ProductData[] = [\n {\n id: '1',\n name: 'Demo Product',\n description: 'A sample product for demonstration',\n category: 'Electronics',\n manufacturer: 'Demo Corp',\n model: 'DM-100',\n price: 29.99,\n inStock: true,\n specifications: { weight: '1.2kg', color: 'Black' },\n tags: ['demo', 'sample'],\n created_at: new Date().toISOString(),\n updated_at: new Date().toISOString(),\n },\n {\n id: '2',\n name: 'Budget Item',\n description: 'An affordable option',\n category: 'Accessories',\n manufacturer: 'Budget Inc',\n model: 'BI-200',\n price: 19.99,\n inStock: false,\n specifications: { size: 'small' },\n tags: ['budget', 'affordable'],\n created_at: new Date().toISOString(),\n updated_at: new Date().toISOString(),\n },\n];\n\nclass MockApiClient {\n products = {\n async list(): Promise<ApiResponse<ProductData[]>> {\n // Simulate API delay\n await new Promise((resolve) => setTimeout(resolve, 500));\n\n return {\n data: [...mockProducts],\n success: true,\n message: 'Products retrieved successfully',\n };\n },\n\n async get(id: string): Promise<ApiResponse<ProductData>> {\n await new Promise((resolve) => setTimeout(resolve, 200));\n\n const product = mockProducts.find((p) => p.id === id);\n if (!product) {\n throw new Error(`Product with id ${id} not found`);\n }\n\n return {\n data: product,\n success: true,\n message: 'Product retrieved successfully',\n };\n },\n\n async create(\n productData: Partial<ProductData>,\n ): Promise<ApiResponse<ProductData>> {\n await new Promise((resolve) => setTimeout(resolve, 300));\n\n const newProduct: ProductData = {\n id: (mockProducts.length + 1).toString(),\n name: productData.name || 'Untitled Product',\n description: productData.description || '',\n category: productData.category || 'Uncategorized',\n manufacturer: productData.manufacturer || '',\n model: productData.model || '',\n price: productData.price || 0,\n inStock: productData.inStock ?? true,\n specifications: productData.specifications || {},\n tags: productData.tags || [],\n created_at: new Date().toISOString(),\n updated_at: new Date().toISOString(),\n };\n\n mockProducts.push(newProduct);\n\n return {\n data: newProduct,\n success: true,\n message: 'Product created successfully',\n };\n },\n\n async update(\n id: string,\n updates: Partial<ProductData>,\n ): Promise<ApiResponse<ProductData>> {\n await new Promise((resolve) => setTimeout(resolve, 300));\n\n const index = mockProducts.findIndex((p) => p.id === id);\n if (index === -1) {\n throw new Error(`Product with id ${id} not found`);\n }\n\n const updatedProduct = {\n ...mockProducts[index],\n ...updates,\n updated_at: new Date().toISOString(),\n };\n\n mockProducts[index] = updatedProduct;\n\n return {\n data: updatedProduct,\n success: true,\n message: 'Product updated successfully',\n };\n },\n\n async delete(id: string): Promise<ApiResponse<void>> {\n await new Promise((resolve) => setTimeout(resolve, 200));\n\n const index = mockProducts.findIndex((p) => p.id === id);\n if (index === -1) {\n throw new Error(`Product with id ${id} not found`);\n }\n\n mockProducts.splice(index, 1);\n\n return {\n data: undefined
|
|
1
|
+
{"version":3,"file":"mock-smrt-client.js","sources":["../../../src/lib/mock-smrt-client.ts"],"sourcesContent":["/**\n * Mock SMRT Client - Temporary implementation for demo purposes\n *\n * This replaces the missing @smrt/client virtual module with a working implementation\n * that demonstrates the intended functionality.\n */\n\n// Re-use the canonical UI ProductData shape so the mock client, the stores,\n// and the components all agree on one type. The shape uses snake_case\n// timestamps (`created_at`/`updated_at`) to match the SMRT server payload.\nimport type { ProductData } from './types';\n\nexport type { ProductData } from './types';\n\nexport interface ApiResponse<T> {\n data: T;\n success: boolean;\n message?: string;\n}\n\n// Mock data store\nconst mockProducts: ProductData[] = [\n {\n id: '1',\n name: 'Demo Product',\n description: 'A sample product for demonstration',\n category: 'Electronics',\n manufacturer: 'Demo Corp',\n model: 'DM-100',\n price: 29.99,\n inStock: true,\n specifications: { weight: '1.2kg', color: 'Black' },\n tags: ['demo', 'sample'],\n created_at: new Date().toISOString(),\n updated_at: new Date().toISOString(),\n },\n {\n id: '2',\n name: 'Budget Item',\n description: 'An affordable option',\n category: 'Accessories',\n manufacturer: 'Budget Inc',\n model: 'BI-200',\n price: 19.99,\n inStock: false,\n specifications: { size: 'small' },\n tags: ['budget', 'affordable'],\n created_at: new Date().toISOString(),\n updated_at: new Date().toISOString(),\n },\n];\n\nclass MockApiClient {\n products = {\n async list(): Promise<ApiResponse<ProductData[]>> {\n // Simulate API delay\n await new Promise((resolve) => setTimeout(resolve, 500));\n\n return {\n data: [...mockProducts],\n success: true,\n message: 'Products retrieved successfully',\n };\n },\n\n async get(id: string): Promise<ApiResponse<ProductData>> {\n await new Promise((resolve) => setTimeout(resolve, 200));\n\n const product = mockProducts.find((p) => p.id === id);\n if (!product) {\n throw new Error(`Product with id ${id} not found`);\n }\n\n return {\n data: product,\n success: true,\n message: 'Product retrieved successfully',\n };\n },\n\n async create(\n productData: Partial<ProductData>,\n ): Promise<ApiResponse<ProductData>> {\n await new Promise((resolve) => setTimeout(resolve, 300));\n\n const newProduct: ProductData = {\n id: (mockProducts.length + 1).toString(),\n name: productData.name || 'Untitled Product',\n description: productData.description || '',\n category: productData.category || 'Uncategorized',\n manufacturer: productData.manufacturer || '',\n model: productData.model || '',\n price: productData.price || 0,\n inStock: productData.inStock ?? true,\n specifications: productData.specifications || {},\n tags: productData.tags || [],\n created_at: new Date().toISOString(),\n updated_at: new Date().toISOString(),\n };\n\n mockProducts.push(newProduct);\n\n return {\n data: newProduct,\n success: true,\n message: 'Product created successfully',\n };\n },\n\n async update(\n id: string,\n updates: Partial<ProductData>,\n ): Promise<ApiResponse<ProductData>> {\n await new Promise((resolve) => setTimeout(resolve, 300));\n\n const index = mockProducts.findIndex((p) => p.id === id);\n if (index === -1) {\n throw new Error(`Product with id ${id} not found`);\n }\n\n const updatedProduct = {\n ...mockProducts[index],\n ...updates,\n updated_at: new Date().toISOString(),\n };\n\n mockProducts[index] = updatedProduct;\n\n return {\n data: updatedProduct,\n success: true,\n message: 'Product updated successfully',\n };\n },\n\n async delete(id: string): Promise<ApiResponse<void>> {\n await new Promise((resolve) => setTimeout(resolve, 200));\n\n const index = mockProducts.findIndex((p) => p.id === id);\n if (index === -1) {\n throw new Error(`Product with id ${id} not found`);\n }\n\n mockProducts.splice(index, 1);\n\n return {\n data: undefined,\n success: true,\n message: 'Product deleted successfully',\n };\n },\n };\n\n categories = {\n async list(): Promise<ApiResponse<string[]>> {\n await new Promise((resolve) => setTimeout(resolve, 200));\n\n const categories = Array.from(\n new Set(\n mockProducts\n .map((p) => p.category)\n .filter((c): c is string => Boolean(c)),\n ),\n );\n\n return {\n data: categories,\n success: true,\n message: 'Categories retrieved successfully',\n };\n },\n };\n}\n\nexport function createClient(baseUrl = '/api/v1'): MockApiClient {\n return new MockApiClient();\n}\n\nexport default createClient;\n"],"names":[],"mappings":"AAqBA,MAAM,eAA8B;AAAA,EAClC;AAAA,IACE,IAAI;AAAA,IACJ,MAAM;AAAA,IACN,aAAa;AAAA,IACb,UAAU;AAAA,IACV,cAAc;AAAA,IACd,OAAO;AAAA,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;AAAA,MACnD;AAEA,mBAAa,OAAO,OAAO,CAAC;AAE5B,aAAO;AAAA,QACL,MAAM;AAAA,QACN,SAAS;AAAA,QACT,SAAS;AAAA,MAAA;AAAA,IAEb;AAAA,EAAA;AAAA,EAGF,aAAa;AAAA,IACX,MAAM,OAAuC;AAC3C,YAAM,IAAI,QAAQ,CAAC,YAAY,WAAW,SAAS,GAAG,CAAC;AAEvD,YAAM,aAAa,MAAM;AAAA,QACvB,IAAI;AAAA,UACF,aACG,IAAI,CAAC,MAAM,EAAE,QAAQ,EACrB,OAAO,CAAC,MAAmB,QAAQ,CAAC,CAAC;AAAA,QAAA;AAAA,MAC1C;AAGF,aAAO;AAAA,QACL,MAAM;AAAA,QACN,SAAS;AAAA,QACT,SAAS;AAAA,MAAA;AAAA,IAEb;AAAA,EAAA;AAEJ;AAEO,SAAS,aAAa,UAAU,WAA0B;AAC/D,SAAO,IAAI,cAAA;AACb;"}
|
|
@@ -14,7 +14,7 @@ export interface ProductOptions extends SmrtObjectOptions {
|
|
|
14
14
|
model?: string;
|
|
15
15
|
price?: number;
|
|
16
16
|
inStock?: boolean;
|
|
17
|
-
specifications?: Record<string,
|
|
17
|
+
specifications?: Record<string, unknown>;
|
|
18
18
|
tags?: string[];
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
@@ -42,11 +42,11 @@ export declare class Product extends SmrtObject {
|
|
|
42
42
|
model: string;
|
|
43
43
|
price: number;
|
|
44
44
|
inStock: boolean;
|
|
45
|
-
specifications: Record<string,
|
|
45
|
+
specifications: Record<string, unknown>;
|
|
46
46
|
tags: string[];
|
|
47
47
|
constructor(options?: ProductOptions);
|
|
48
|
-
getSpecification(key: string): Promise<
|
|
49
|
-
updateSpecification(key: string, value:
|
|
48
|
+
getSpecification(key: string): Promise<unknown>;
|
|
49
|
+
updateSpecification(key: string, value: unknown): Promise<void>;
|
|
50
50
|
private getProductAssetCollection;
|
|
51
51
|
getAssets(relationship?: string): Promise<Asset[]>;
|
|
52
52
|
addAsset(asset: Asset, relationship?: string, sortOrder?: number): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Product.d.ts","sourceRoot":"","sources":["../../../../src/lib/models/Product.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAMxD,OAAO,EACL,UAAU,EACV,KAAK,iBAAiB,EAEvB,MAAM,0BAA0B,CAAC;AAMlC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,iBAAiB;IACvD,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"Product.d.ts","sourceRoot":"","sources":["../../../../src/lib/models/Product.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAMxD,OAAO,EACL,UAAU,EACV,KAAK,iBAAiB,EAEvB,MAAM,0BAA0B,CAAC;AAMlC,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC;;GAEG;AACH,MAAM,WAAW,cAAe,SAAQ,iBAAiB;IACvD,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;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ANGED
|
@@ -14,7 +14,7 @@ export interface ProductData {
|
|
|
14
14
|
model?: string;
|
|
15
15
|
price?: number;
|
|
16
16
|
inStock?: boolean;
|
|
17
|
-
specifications?: Record<string,
|
|
17
|
+
specifications?: Record<string, unknown>;
|
|
18
18
|
tags?: string[];
|
|
19
19
|
}
|
|
20
20
|
export interface CategoryData {
|
|
@@ -31,11 +31,11 @@ export interface CategoryData {
|
|
|
31
31
|
}
|
|
32
32
|
export interface Request {
|
|
33
33
|
params: Record<string, string>;
|
|
34
|
-
query: Record<string,
|
|
35
|
-
json(): Promise<
|
|
34
|
+
query: Record<string, unknown>;
|
|
35
|
+
json(): Promise<unknown>;
|
|
36
36
|
}
|
|
37
37
|
export interface Response {
|
|
38
|
-
json(data:
|
|
38
|
+
json(data: unknown, init?: {
|
|
39
39
|
status?: number;
|
|
40
40
|
}): Response;
|
|
41
41
|
status(code: number): Response;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lib/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,WAAW;IAC1B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/lib/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,MAAM,WAAW,WAAW;IAC1B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E,MAAM,GAAG,QAAQ,CAAC;CAChC"}
|
package/dist/lib/main.d.ts
CHANGED
package/dist/lib/main.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/main.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../src/main.ts"],"names":[],"mappings":"AAAA;;GAEG;AAQH,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,YAAY,EAAE,MAAM,IAAI,CAAC;QACzB,cAAc,EAAE,MAAM,IAAI,CAAC;KAC5B;CACF"}
|
package/dist/lib/manifest.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": "1.0.0",
|
|
3
|
-
"timestamp":
|
|
3
|
+
"timestamp": 1782368726680,
|
|
4
4
|
"packageName": "@happyvertical/smrt-products",
|
|
5
|
-
"packageVersion": "0.
|
|
5
|
+
"packageVersion": "0.36.0",
|
|
6
6
|
"objects": {
|
|
7
7
|
"@happyvertical/smrt-products:CategoryCollection": {
|
|
8
8
|
"name": "categorycollection",
|
|
@@ -2030,7 +2030,7 @@
|
|
|
2030
2030
|
"optional": false
|
|
2031
2031
|
}
|
|
2032
2032
|
],
|
|
2033
|
-
"returnType": "Promise
|
|
2033
|
+
"returnType": "Promise",
|
|
2034
2034
|
"isStatic": false,
|
|
2035
2035
|
"isPublic": true
|
|
2036
2036
|
},
|
|
@@ -2808,7 +2808,7 @@
|
|
|
2808
2808
|
"optional": false
|
|
2809
2809
|
}
|
|
2810
2810
|
],
|
|
2811
|
-
"returnType": "Promise
|
|
2811
|
+
"returnType": "Promise",
|
|
2812
2812
|
"isStatic": false,
|
|
2813
2813
|
"isPublic": true
|
|
2814
2814
|
},
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schemaVersion": 1,
|
|
3
|
-
"generatedAt": "2026-06-
|
|
3
|
+
"generatedAt": "2026-06-25T06:25:28.186Z",
|
|
4
4
|
"packageName": "@happyvertical/smrt-products",
|
|
5
|
-
"packageVersion": "0.
|
|
5
|
+
"packageVersion": "0.36.0",
|
|
6
6
|
"sourceManifestPath": "dist/lib/manifest.json",
|
|
7
7
|
"agentDocPath": "AGENTS.md",
|
|
8
8
|
"sourceHashes": {
|
|
9
|
-
"manifest": "
|
|
10
|
-
"packageJson": "
|
|
9
|
+
"manifest": "69af764181d68658049131adbe45de177683f2b128b61eefdd6fa363e514bb86",
|
|
10
|
+
"packageJson": "3f38cc8fbf47745e5251a4f6e4c159d4ad7685912c50e60ba8148b6badfe83d5",
|
|
11
11
|
"agents": "ede6063b72600b84908e1e32216fbbdd69d70d309f0b23c2add338ad080702d4"
|
|
12
12
|
},
|
|
13
13
|
"exports": [
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@happyvertical/smrt-products",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.36.0",
|
|
4
4
|
"description": "SMRT products module: triple-purpose microservice template for standalone apps, federated modules, and NPM libraries",
|
|
5
5
|
"author": "HappyVertical",
|
|
6
6
|
"type": "module",
|
|
@@ -55,11 +55,11 @@
|
|
|
55
55
|
"@happyvertical/utils": "^0.74.7",
|
|
56
56
|
"cors": "^2.8.5",
|
|
57
57
|
"express": "^5.2.1",
|
|
58
|
-
"@happyvertical/smrt-assets": "0.
|
|
59
|
-
"@happyvertical/smrt-
|
|
60
|
-
"@happyvertical/smrt-
|
|
61
|
-
"@happyvertical/smrt-
|
|
62
|
-
"@happyvertical/smrt-
|
|
58
|
+
"@happyvertical/smrt-assets": "0.36.0",
|
|
59
|
+
"@happyvertical/smrt-tenancy": "0.36.0",
|
|
60
|
+
"@happyvertical/smrt-core": "0.36.0",
|
|
61
|
+
"@happyvertical/smrt-ui": "0.36.0",
|
|
62
|
+
"@happyvertical/smrt-scanner": "0.36.0"
|
|
63
63
|
},
|
|
64
64
|
"peerDependencies": {
|
|
65
65
|
"svelte": "^5.46.4"
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"typescript": "^5.9.3",
|
|
83
83
|
"vite": "^7.3.1",
|
|
84
84
|
"vitest": "^4.0.17",
|
|
85
|
-
"@happyvertical/smrt-vitest": "0.
|
|
85
|
+
"@happyvertical/smrt-vitest": "0.36.0"
|
|
86
86
|
},
|
|
87
87
|
"keywords": [
|
|
88
88
|
"smrt",
|