@happyvertical/smrt-products 0.37.2 → 0.37.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/dist/lib/chunks/ProductAssetCollection-TbeaVxzc.js +38 -0
  2. package/dist/lib/chunks/ProductAssetCollection-TbeaVxzc.js.map +1 -0
  3. package/dist/lib/chunks/ProductCollection-8QlfZ9ez.js +28 -0
  4. package/dist/lib/chunks/ProductCollection-8QlfZ9ez.js.map +1 -0
  5. package/dist/lib/chunks/Sku-B0w2dfHb.js +467 -0
  6. package/dist/lib/chunks/Sku-B0w2dfHb.js.map +1 -0
  7. package/dist/lib/chunks/__smrt-register__-DAo7IPPx.js +22 -0
  8. package/dist/lib/chunks/__smrt-register__-DAo7IPPx.js.map +1 -0
  9. package/dist/lib/chunks/collections-6PSqhUmZ.js +162 -0
  10. package/dist/lib/chunks/collections-6PSqhUmZ.js.map +1 -0
  11. package/dist/lib/chunks/components-C6VpNVcg.js +398 -0
  12. package/dist/lib/chunks/components-C6VpNVcg.js.map +1 -0
  13. package/dist/lib/chunks/decorate-C25O10I-.js +9 -0
  14. package/dist/lib/chunks/generated-CM3rwUcw.js +7 -0
  15. package/dist/lib/chunks/generated-CM3rwUcw.js.map +1 -0
  16. package/dist/lib/chunks/models-JPB-sld2.js +2 -0
  17. package/dist/lib/chunks/rolldown-runtime-D7D4PA-g.js +13 -0
  18. package/dist/lib/chunks/stores-CB0SI1c5.js +119 -0
  19. package/dist/lib/chunks/stores-CB0SI1c5.js.map +1 -0
  20. package/dist/lib/chunks/utils-BgTqlQoH.js +30 -0
  21. package/dist/lib/chunks/utils-BgTqlQoH.js.map +1 -0
  22. package/dist/lib/collections.js +4 -12
  23. package/dist/lib/components.js +2 -6
  24. package/dist/lib/generated.js +2 -5
  25. package/dist/lib/index.js +191 -216
  26. package/dist/lib/index.js.map +1 -1
  27. package/dist/lib/lib/i18n.js +82 -91
  28. package/dist/lib/lib/i18n.js.map +1 -1
  29. package/dist/lib/lib/mock-smrt-client.js +116 -129
  30. package/dist/lib/lib/mock-smrt-client.js.map +1 -1
  31. package/dist/lib/lib/stores/product-store.svelte.d.ts.map +1 -1
  32. package/dist/lib/manifest.json +2 -2
  33. package/dist/lib/models.js +3 -12
  34. package/dist/lib/smrt-knowledge.json +14 -14
  35. package/dist/lib/smrt-products.css +1 -0
  36. package/dist/lib/stores.js +2 -6
  37. package/dist/lib/utils.js +2 -27
  38. package/package.json +23 -23
  39. package/dist/lib/chunks/ProductAssetCollection-B93HdSlX.js +0 -64
  40. package/dist/lib/chunks/ProductAssetCollection-B93HdSlX.js.map +0 -1
  41. package/dist/lib/chunks/ProductForm-CU0UvKEF.js +0 -430
  42. package/dist/lib/chunks/ProductForm-CU0UvKEF.js.map +0 -1
  43. package/dist/lib/chunks/Sku-sl6xf1PR.js +0 -494
  44. package/dist/lib/chunks/Sku-sl6xf1PR.js.map +0 -1
  45. package/dist/lib/chunks/SkuCollection-f_a3k93c.js +0 -160
  46. package/dist/lib/chunks/SkuCollection-f_a3k93c.js.map +0 -1
  47. package/dist/lib/chunks/__smrt-register__-BIgFaVKn.js +0 -5
  48. package/dist/lib/chunks/__smrt-register__-BIgFaVKn.js.map +0 -1
  49. package/dist/lib/chunks/index-i3-ci1FB.js +0 -6
  50. package/dist/lib/chunks/index-i3-ci1FB.js.map +0 -1
  51. package/dist/lib/chunks/product-store.svelte-Dayd5n3W.js +0 -132
  52. package/dist/lib/chunks/product-store.svelte-Dayd5n3W.js.map +0 -1
  53. package/dist/lib/collections.js.map +0 -1
  54. package/dist/lib/components.js.map +0 -1
  55. package/dist/lib/generated.js.map +0 -1
  56. package/dist/lib/models.js.map +0 -1
  57. package/dist/lib/stores.js.map +0 -1
  58. package/dist/lib/utils.js.map +0 -1
@@ -0,0 +1,38 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
2
+ import { t as __decorate } from "./decorate-C25O10I-.js";
3
+ import { r as ProductAsset } from "./Sku-B0w2dfHb.js";
4
+ import { SmrtJunction, smrt } from "@happyvertical/smrt-core";
5
+ import { addOwnedAssetFromCollection, getOwnedAssetsFromCollection, removeOwnedAssetFromCollection } from "@happyvertical/smrt-assets";
6
+ //#region src/lib/collections/ProductAssetCollection.ts
7
+ var ProductAssetCollection_exports = /* @__PURE__ */ __exportAll({ ProductAssetCollection: () => ProductAssetCollection });
8
+ var ProductAssetCollection = class ProductAssetCollection extends SmrtJunction {
9
+ static _itemClass = ProductAsset;
10
+ leftField = "productId";
11
+ rightField = "assetId";
12
+ productCollectionPromise = null;
13
+ async getProductCollection() {
14
+ if (!this.productCollectionPromise) {
15
+ const { ProductCollection } = await import("./ProductCollection-8QlfZ9ez.js").then((n) => n.n);
16
+ this.productCollectionPromise = ProductCollection.create({ db: this.db });
17
+ }
18
+ return this.productCollectionPromise;
19
+ }
20
+ async getAssets(productId, relationship) {
21
+ return getOwnedAssetsFromCollection(await this.getProductCollection(), productId, relationship);
22
+ }
23
+ async addAsset(productId, asset, relationship = "attachment", sortOrder = 0) {
24
+ await addOwnedAssetFromCollection(await this.getProductCollection(), "Product", productId, asset, relationship, sortOrder);
25
+ }
26
+ async removeAsset(productId, assetId, relationship) {
27
+ await removeOwnedAssetFromCollection(await this.getProductCollection(), "Product", productId, assetId, relationship);
28
+ }
29
+ };
30
+ ProductAssetCollection = __decorate([smrt({
31
+ api: false,
32
+ mcp: false,
33
+ cli: false
34
+ })], ProductAssetCollection);
35
+ //#endregion
36
+ export { ProductAssetCollection_exports as n, ProductAssetCollection as t };
37
+
38
+ //# sourceMappingURL=ProductAssetCollection-TbeaVxzc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProductAssetCollection-TbeaVxzc.js","names":[],"sources":["../../../src/lib/collections/ProductAssetCollection.ts"],"sourcesContent":["import type { Asset } from '@happyvertical/smrt-assets';\nimport {\n addOwnedAssetFromCollection,\n getOwnedAssetsFromCollection,\n removeOwnedAssetFromCollection,\n} from '@happyvertical/smrt-assets';\nimport type { SmrtCollectionOptions } from '@happyvertical/smrt-core';\nimport { SmrtJunction, smrt } from '@happyvertical/smrt-core';\nimport { ProductAsset } from '../models/ProductAsset';\nimport type { ProductCollection } from './ProductCollection';\n\nexport interface ProductAssetCollectionOptions extends SmrtCollectionOptions {}\n\n@smrt({\n api: false,\n mcp: false,\n cli: false,\n})\nexport class ProductAssetCollection extends SmrtJunction<ProductAsset> {\n static readonly _itemClass = ProductAsset;\n protected leftField = 'productId';\n protected rightField = 'assetId';\n\n private productCollectionPromise: Promise<ProductCollection> | null = null;\n\n private async getProductCollection(): Promise<ProductCollection> {\n if (!this.productCollectionPromise) {\n const { ProductCollection } = await import('./ProductCollection');\n this.productCollectionPromise = ProductCollection.create({ db: this.db });\n }\n\n return this.productCollectionPromise;\n }\n\n async getAssets(productId: string, relationship?: string): Promise<Asset[]> {\n return getOwnedAssetsFromCollection(\n await this.getProductCollection(),\n productId,\n relationship,\n );\n }\n\n async addAsset(\n productId: string,\n asset: Asset,\n relationship = 'attachment',\n sortOrder = 0,\n ): Promise<void> {\n await addOwnedAssetFromCollection(\n await this.getProductCollection(),\n 'Product',\n productId,\n asset,\n relationship,\n sortOrder,\n );\n }\n\n async removeAsset(\n productId: string,\n assetId: string,\n relationship?: string,\n ): Promise<void> {\n await removeOwnedAssetFromCollection(\n await this.getProductCollection(),\n 'Product',\n productId,\n assetId,\n relationship,\n );\n }\n}\n"],"mappings":";;;;;;;AAkBO,IAAA,yBAAA,MAAM,+BAA+B,aAA2B;CACrE,OAAgB,aAAa;CAC7B,YAAsB;CACtB,aAAuB;CAEvB,2BAAsE;CAEtE,MAAc,uBAAmD;EAC/D,IAAI,CAAC,KAAK,0BAA0B;GAClC,MAAM,EAAE,sBAAsB,MAAM,OAAO,kCAAA,CAAA,MAAA,MAAA,EAAA,CAAA;GAC3C,KAAK,2BAA2B,kBAAkB,OAAO,EAAE,IAAI,KAAK,GAAG,CAAC;EAC1E;EAEA,OAAO,KAAK;CACd;CAEA,MAAM,UAAU,WAAmB,cAAyC;EAC1E,OAAO,6BACL,MAAM,KAAK,qBAAqB,GAChC,WACA,YACF;CACF;CAEA,MAAM,SACJ,WACA,OACA,eAAe,cACf,YAAY,GACG;EACf,MAAM,4BACJ,MAAM,KAAK,qBAAqB,GAChC,WACA,WACA,OACA,cACA,SACF;CACF;CAEA,MAAM,YACJ,WACA,SACA,cACe;EACf,MAAM,+BACJ,MAAM,KAAK,qBAAqB,GAChC,WACA,WACA,SACA,YACF;CACF;AACF;qCA1DC,KAAK;CACJ,KAAK;CACL,KAAK;CACL,KAAK;AACP,CAAC,CAAA,GAAA,sBAAA"}
@@ -0,0 +1,28 @@
1
+ import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.js";
2
+ import { a as Product } from "./Sku-B0w2dfHb.js";
3
+ import { SmrtCollection } from "@happyvertical/smrt-core";
4
+ import { addOwnedAssetFromCollection, getOwnedAssetsFromCollection, removeOwnedAssetFromCollection } from "@happyvertical/smrt-assets";
5
+ //#region src/lib/collections/ProductCollection.ts
6
+ var ProductCollection_exports = /* @__PURE__ */ __exportAll({ ProductCollection: () => ProductCollection });
7
+ var ProductCollection = class extends SmrtCollection {
8
+ static _itemClass = Product;
9
+ async findByManufacturer(manufacturer) {
10
+ return this.list({ where: { manufacturer } });
11
+ }
12
+ async findInStock() {
13
+ return this.list({ where: { inStock: true } });
14
+ }
15
+ async getAssets(productId, relationship) {
16
+ return getOwnedAssetsFromCollection(this, productId, relationship);
17
+ }
18
+ async addAsset(productId, asset, relationship = "attachment", sortOrder = 0) {
19
+ await addOwnedAssetFromCollection(this, "Product", productId, asset, relationship, sortOrder);
20
+ }
21
+ async removeAsset(productId, assetId, relationship) {
22
+ await removeOwnedAssetFromCollection(this, "Product", productId, assetId, relationship);
23
+ }
24
+ };
25
+ //#endregion
26
+ export { ProductCollection_exports as n, ProductCollection as t };
27
+
28
+ //# sourceMappingURL=ProductCollection-8QlfZ9ez.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProductCollection-8QlfZ9ez.js","names":[],"sources":["../../../src/lib/collections/ProductCollection.ts"],"sourcesContent":["import type { Asset } from '@happyvertical/smrt-assets';\nimport {\n addOwnedAssetFromCollection,\n getOwnedAssetsFromCollection,\n removeOwnedAssetFromCollection,\n} from '@happyvertical/smrt-assets';\nimport { SmrtCollection } from '@happyvertical/smrt-core';\nimport { Product } from '../models/Product';\n\nexport class ProductCollection extends SmrtCollection<Product> {\n static readonly _itemClass = Product;\n\n async findByManufacturer(manufacturer: string): Promise<Product[]> {\n return this.list({ where: { manufacturer } });\n }\n\n async findInStock(): Promise<Product[]> {\n return this.list({ where: { inStock: true } });\n }\n\n async getAssets(productId: string, relationship?: string): Promise<Asset[]> {\n return getOwnedAssetsFromCollection(this, productId, relationship);\n }\n\n async addAsset(\n productId: string,\n asset: Asset,\n relationship = 'attachment',\n sortOrder = 0,\n ): Promise<void> {\n await addOwnedAssetFromCollection(\n this,\n 'Product',\n productId,\n asset,\n relationship,\n sortOrder,\n );\n }\n\n async removeAsset(\n productId: string,\n assetId: string,\n relationship?: string,\n ): Promise<void> {\n await removeOwnedAssetFromCollection(\n this,\n 'Product',\n productId,\n assetId,\n relationship,\n );\n }\n}\n"],"mappings":";;;;;;AASA,IAAa,oBAAb,cAAuC,eAAwB;CAC7D,OAAgB,aAAa;CAE7B,MAAM,mBAAmB,cAA0C;EACjE,OAAO,KAAK,KAAK,EAAE,OAAO,EAAE,aAAa,EAAE,CAAC;CAC9C;CAEA,MAAM,cAAkC;EACtC,OAAO,KAAK,KAAK,EAAE,OAAO,EAAE,SAAS,KAAK,EAAE,CAAC;CAC/C;CAEA,MAAM,UAAU,WAAmB,cAAyC;EAC1E,OAAO,6BAA6B,MAAM,WAAW,YAAY;CACnE;CAEA,MAAM,SACJ,WACA,OACA,eAAe,cACf,YAAY,GACG;EACf,MAAM,4BACJ,MACA,WACA,WACA,OACA,cACA,SACF;CACF;CAEA,MAAM,YACJ,WACA,SACA,cACe;EACf,MAAM,+BACJ,MACA,WACA,WACA,SACA,YACF;CACF;AACF"}
@@ -0,0 +1,467 @@
1
+ import { t as __decorate } from "./decorate-C25O10I-.js";
2
+ import { SmrtObject, crossPackageRef, field, foreignKey, smrt } from "@happyvertical/smrt-core";
3
+ import { TenantScoped, getCurrentTenant, tenantId } from "@happyvertical/smrt-tenancy";
4
+ import { assertValidOwnedAssetRelationship, assertValidOwnedAssetSortOrder, resolveOwnedAssetsById } from "@happyvertical/smrt-assets";
5
+ //#region src/lib/models/Category.ts
6
+ /**
7
+ * Product knowledge base category model
8
+ *
9
+ * SMRT auto-generates REST APIs, MCP tools, and TypeScript clients from this class.
10
+ */
11
+ var Category = class Category extends SmrtObject {
12
+ /**
13
+ * Tenant ID for multi-tenant isolation.
14
+ * Nullable to support both tenant-scoped and global categories.
15
+ */
16
+ tenantId = null;
17
+ name = "";
18
+ description = "";
19
+ parentId;
20
+ level = 0;
21
+ productCount = 0;
22
+ active = true;
23
+ constructor(options = {}) {
24
+ super(options);
25
+ if (options.tenantId !== void 0) this.tenantId = options.tenantId;
26
+ this.name = options.name || "";
27
+ this.description = options.description || "";
28
+ this.parentId = options.parentId;
29
+ this.level = options.level || 0;
30
+ this.productCount = options.productCount || 0;
31
+ this.active = options.active !== void 0 ? options.active : true;
32
+ }
33
+ };
34
+ __decorate([tenantId({ nullable: true })], Category.prototype, "tenantId", void 0);
35
+ __decorate([foreignKey("Category")], Category.prototype, "parentId", void 0);
36
+ Category = __decorate([TenantScoped({ mode: "optional" }), smrt({
37
+ tableStrategy: "sti",
38
+ api: { include: [
39
+ "list",
40
+ "get",
41
+ "create",
42
+ "update"
43
+ ] },
44
+ mcp: { include: ["list", "get"] },
45
+ cli: true
46
+ })], Category);
47
+ //#endregion
48
+ //#region src/lib/models/types.ts
49
+ /**
50
+ * Shared types for the products package.
51
+ *
52
+ * @packageDocumentation
53
+ */
54
+ /**
55
+ * Discriminator for Product STI subtypes.
56
+ *
57
+ * Industry-vertical templates extend `Product` with their own STI subtypes
58
+ * (apparel uses `Style`/`Makeup`; furniture might use `Design`/`Finish`;
59
+ * automotive `Model`/`Trim`) — the upstream package only ships the truly
60
+ * generic primitives:
61
+ *
62
+ * - {@link ProductType.PRODUCT} — plain catalog item (base)
63
+ * - {@link ProductType.MATERIAL} — raw input consumed by manufacturing
64
+ *
65
+ * The axis-declaration concept ("this product varies along `size` with
66
+ * values `[XS, S, M, L, XL]`") is NOT a Product STI subtype — it lives in
67
+ * its own model, {@link ProductVariant}, with a separate table. Per-SKU
68
+ * value pins live on `Sku.attributes` (also in this package — `Sku` was
69
+ * relocated from `@happyvertical/smrt-inventory` to here in Phase 1 so
70
+ * every catalog primitive lives under one roof; inventory only holds
71
+ * stock levels and movements now).
72
+ */
73
+ var ProductType = /* @__PURE__ */ function(ProductType) {
74
+ /** Generic catalog item (default). */
75
+ ProductType["PRODUCT"] = "product";
76
+ /** A raw input — fabric, trim, packaging, etc. — consumed by manufacturing. */
77
+ ProductType["MATERIAL"] = "material";
78
+ return ProductType;
79
+ }({});
80
+ //#endregion
81
+ //#region src/lib/models/Product.ts
82
+ var Product = class Product extends SmrtObject {
83
+ /**
84
+ * Tenant ID for multi-tenant isolation.
85
+ * Nullable to support both tenant-scoped and global catalogs.
86
+ */
87
+ tenantId = null;
88
+ /**
89
+ * STI discriminator. Subclasses override this with their type.
90
+ */
91
+ productType = ProductType.PRODUCT;
92
+ name = "";
93
+ description = "";
94
+ category = "";
95
+ manufacturer = "";
96
+ model = "";
97
+ price = 0;
98
+ inStock = true;
99
+ specifications = {};
100
+ tags = [];
101
+ constructor(options = {}) {
102
+ super(options);
103
+ if (options.tenantId !== void 0) this.tenantId = options.tenantId;
104
+ if (options.productType !== void 0 && options.productType !== null) this.productType = options.productType;
105
+ this.name = options.name || "";
106
+ this.description = options.description || "";
107
+ this.category = options.category || "";
108
+ this.manufacturer = options.manufacturer || "";
109
+ this.model = options.model || "";
110
+ this.price = options.price || 0;
111
+ this.inStock = options.inStock !== void 0 ? options.inStock : true;
112
+ this.specifications = options.specifications || {};
113
+ this.tags = options.tags || [];
114
+ }
115
+ async getSpecification(key) {
116
+ return this.specifications[key];
117
+ }
118
+ async updateSpecification(key, value) {
119
+ this.specifications[key] = value;
120
+ }
121
+ async getProductAssetCollection() {
122
+ const { ProductAssetCollection } = await import("./ProductAssetCollection-TbeaVxzc.js").then((n) => n.n);
123
+ return ProductAssetCollection.create({ db: this.db });
124
+ }
125
+ async getAssets(relationship) {
126
+ if (!this.id) return [];
127
+ const linkedAssets = await (await this.getProductAssetCollection()).byLeft(this.id, relationship ? { relationship } : {});
128
+ const ctxTenantId = getCurrentTenant()?.tenantId ?? null;
129
+ return resolveOwnedAssetsById(this.db, linkedAssets.map((link) => link.assetId), ctxTenantId);
130
+ }
131
+ async addAsset(asset, relationship = "attachment", sortOrder = 0) {
132
+ if (!this.id || !asset.id) throw new Error("Cannot associate unsaved product or asset");
133
+ assertValidOwnedAssetRelationship(relationship);
134
+ assertValidOwnedAssetSortOrder(sortOrder);
135
+ await (await this.getProductAssetCollection()).attach(this.id, asset.id, {
136
+ relationship,
137
+ sortOrder
138
+ });
139
+ }
140
+ async removeAsset(assetId, relationship) {
141
+ if (!this.id) return;
142
+ await (await this.getProductAssetCollection()).detach(this.id, assetId, relationship ? { relationship } : {});
143
+ }
144
+ };
145
+ __decorate([tenantId({ nullable: true })], Product.prototype, "tenantId", void 0);
146
+ Product = __decorate([TenantScoped({ mode: "optional" }), smrt({
147
+ tableStrategy: "sti",
148
+ api: { include: [
149
+ "list",
150
+ "get",
151
+ "create",
152
+ "update"
153
+ ] },
154
+ mcp: { include: ["list", "get"] },
155
+ cli: true
156
+ })], Product);
157
+ //#endregion
158
+ //#region src/lib/models/Material.ts
159
+ /**
160
+ * Material — STI subtype of Product representing a raw input consumed by
161
+ * manufacturing: fabric, thread, trim, labels, packaging, components.
162
+ *
163
+ * Materials are first-class products in the catalog (the SAP/NetSuite pattern):
164
+ * they have a name, description, vendor, unit cost, and live in inventory just
165
+ * like finished goods. Bills of materials in `@happyvertical/smrt-manufacturing`
166
+ * reference Materials by id.
167
+ *
168
+ * @packageDocumentation
169
+ */
170
+ var Material = class Material extends Product {
171
+ productType = ProductType.MATERIAL;
172
+ /** Classification — fabric, trim, thread, label, packaging, component, ... */
173
+ materialKind = "component";
174
+ /** Unit of measure — "yards", "meters", "each", "grams", "lbs". */
175
+ uom = "each";
176
+ /**
177
+ * Latest known cost per UOM. For sophisticated cost rollup, manufacturing
178
+ * may pull from purchase-order history instead of this denormalised value.
179
+ */
180
+ costPerUnit = 0;
181
+ constructor(options = {}) {
182
+ super(options);
183
+ if (options.materialKind !== void 0) this.materialKind = options.materialKind;
184
+ if (options.uom !== void 0) this.uom = options.uom;
185
+ if (options.costPerUnit !== void 0) this.costPerUnit = options.costPerUnit;
186
+ }
187
+ };
188
+ Material = __decorate([TenantScoped({ mode: "optional" }), smrt({
189
+ api: { include: [
190
+ "list",
191
+ "get",
192
+ "create",
193
+ "update"
194
+ ] },
195
+ mcp: { include: ["list", "get"] },
196
+ cli: true
197
+ })], Material);
198
+ //#endregion
199
+ //#region src/lib/models/ProductAsset.ts
200
+ var ProductAsset = class ProductAsset extends SmrtObject {
201
+ tenantId = null;
202
+ productId = "";
203
+ assetId = "";
204
+ relationship = "attachment";
205
+ sortOrder = 0;
206
+ constructor(options = {}) {
207
+ super(options);
208
+ if (options.tenantId !== void 0) this.tenantId = options.tenantId;
209
+ if (options.productId) this.productId = options.productId;
210
+ if (options.assetId) this.assetId = options.assetId;
211
+ if (options.relationship) this.relationship = options.relationship;
212
+ if (options.sortOrder !== void 0) this.sortOrder = options.sortOrder;
213
+ }
214
+ };
215
+ __decorate([tenantId({ nullable: true })], ProductAsset.prototype, "tenantId", void 0);
216
+ __decorate([foreignKey("Product", { required: true })], ProductAsset.prototype, "productId", void 0);
217
+ __decorate([crossPackageRef("@happyvertical/smrt-assets:Asset", { required: true })], ProductAsset.prototype, "assetId", void 0);
218
+ __decorate([field({ required: true })], ProductAsset.prototype, "relationship", void 0);
219
+ __decorate([field()], ProductAsset.prototype, "sortOrder", void 0);
220
+ ProductAsset = __decorate([TenantScoped({ mode: "optional" }), smrt({
221
+ tableName: "product_assets",
222
+ conflictColumns: [
223
+ "product_id",
224
+ "asset_id",
225
+ "relationship",
226
+ "tenant_id"
227
+ ],
228
+ api: false,
229
+ mcp: false,
230
+ cli: false
231
+ })], ProductAsset);
232
+ //#endregion
233
+ //#region src/lib/models/ProductVariant.ts
234
+ /**
235
+ * ProductVariant — declarative description of one axis along which a
236
+ * product's SKUs differ.
237
+ *
238
+ * A `ProductVariant` row says "for product X, axis Y has the following
239
+ * allowed values". The actual per-SKU value lives on `Sku.attributes`
240
+ * (also in this package — `Sku` was relocated to `@happyvertical/smrt-products`
241
+ * in Phase 1; inventory only holds stock motion now), keyed by `axisName`.
242
+ * This split keeps the axis catalog (form choices, UI grouping, ordering)
243
+ * separate from the per-unit instances.
244
+ *
245
+ * Deliberately generic. `axisName` is free-form — apparel teams might
246
+ * use `'size'` and `'color'`, automotive teams `'trim'` and `'engine'`,
247
+ * CPG teams `'packSize'` and `'flavor'`. The framework never inspects
248
+ * the axis name.
249
+ *
250
+ * NOT a Product STI subtype — it's its own model with its own table,
251
+ * because the shape (axis declaration) doesn't fit the Product schema
252
+ * (no name, no price, no category — it's metadata about a Product, not
253
+ * a Product itself).
254
+ *
255
+ * @packageDocumentation
256
+ */
257
+ var ProductVariant = class ProductVariant extends SmrtObject {
258
+ /** Tenant scope. `null` means the variant axis is global. */
259
+ tenantId = null;
260
+ /**
261
+ * Plain string reference to the {@link Product} this axis belongs to
262
+ * (or any Product STI subtype — `Material`, or vertical subtypes
263
+ * defined in templates such as the apparel `Style` / `Makeup`).
264
+ */
265
+ productId = "";
266
+ /**
267
+ * The name of the axis (`'size'`, `'color'`, `'finish'`, `'voltage'`,
268
+ * `'packSize'`, …). Free-form — the framework treats this as opaque.
269
+ */
270
+ axisName = "";
271
+ /** Optional human-friendly label for forms / UIs (defaults to `axisName`). */
272
+ label = "";
273
+ /**
274
+ * Allowed values for this axis, stored as a JSON string. Named
275
+ * `allowedValues` (rather than `values`) because the unprefixed name
276
+ * collides with the SQL `VALUES` keyword on several engines. Use
277
+ * {@link getValues} / {@link setValues} to round-trip the array form.
278
+ */
279
+ allowedValues = "[]";
280
+ /** Sort order for displaying multiple axes in a consistent column order. */
281
+ sortOrder = 0;
282
+ constructor(options = {}) {
283
+ super(options);
284
+ if (options.tenantId !== void 0) this.tenantId = options.tenantId;
285
+ if (options.productId !== void 0) this.productId = options.productId;
286
+ if (options.axisName !== void 0) this.axisName = options.axisName;
287
+ if (options.label !== void 0) this.label = options.label;
288
+ if (options.allowedValues !== void 0) this.setValues(options.allowedValues);
289
+ if (options.sortOrder !== void 0) this.sortOrder = options.sortOrder;
290
+ if (!this.label && this.axisName) this.label = this.axisName;
291
+ }
292
+ /**
293
+ * Parse and return the {@link allowedValues} JSON array. Returns an
294
+ * empty array if the stored value cannot be parsed as an array.
295
+ */
296
+ getValues() {
297
+ if (!this.allowedValues) return [];
298
+ try {
299
+ const parsed = JSON.parse(this.allowedValues);
300
+ return Array.isArray(parsed) ? parsed.map((value) => String(value)) : [];
301
+ } catch {
302
+ return [];
303
+ }
304
+ }
305
+ /**
306
+ * Serialize the allowed values back into the stored
307
+ * {@link allowedValues} string. Accepts either an array or a
308
+ * pre-serialized JSON string.
309
+ */
310
+ setValues(value) {
311
+ if (typeof value === "string") {
312
+ this.allowedValues = value;
313
+ return;
314
+ }
315
+ this.allowedValues = JSON.stringify(Array.isArray(value) ? value : []);
316
+ }
317
+ };
318
+ __decorate([tenantId({ nullable: true })], ProductVariant.prototype, "tenantId", void 0);
319
+ __decorate([field({ required: true })], ProductVariant.prototype, "productId", void 0);
320
+ __decorate([field({ required: true })], ProductVariant.prototype, "axisName", void 0);
321
+ ProductVariant = __decorate([TenantScoped({ mode: "optional" }), smrt({
322
+ tableName: "product_variants",
323
+ conflictColumns: [
324
+ "product_id",
325
+ "axis_name",
326
+ "tenant_id"
327
+ ],
328
+ api: { include: [
329
+ "list",
330
+ "get",
331
+ "create",
332
+ "update"
333
+ ] },
334
+ mcp: { include: ["list", "get"] },
335
+ cli: true
336
+ })], ProductVariant);
337
+ //#endregion
338
+ //#region src/lib/models/Sku.ts
339
+ /**
340
+ * Sku — smallest sellable and countable unit.
341
+ *
342
+ * A SKU is the concrete catalog row that downstream inventory counts.
343
+ * It references a higher-level concept in this same package (a
344
+ * {@link Product} or any of its STI subtypes) via the plain string
345
+ * `productId` field. The same pattern serves apparel (one SKU per
346
+ * size/color), furniture (one SKU per finish), automotive parts,
347
+ * grocery (one SKU per pack size), or any other vertical that needs
348
+ * to count discrete units.
349
+ *
350
+ * Axis values such as `{ size: 'M', color: 'navy' }`, `{ finish: 'walnut' }`,
351
+ * or `{ packSize: '12oz' }` are stored as opaque JSON in `attributes`;
352
+ * the declarative axis catalog lives in {@link ProductVariant} in this
353
+ * same package.
354
+ *
355
+ * Stock balance and movement history for a SKU live in
356
+ * `@happyvertical/smrt-inventory` as `StockLevel` and `StockMovement`.
357
+ *
358
+ * @packageDocumentation
359
+ */
360
+ var Sku = class Sku extends SmrtObject {
361
+ /** Tenant scope. `null` means the SKU is a global record. */
362
+ tenantId = null;
363
+ /**
364
+ * Plain string reference to a row in this package — typically a
365
+ * `Product` id (or any of its STI subtypes, such as `Material`
366
+ * upstream or `Style` / `Makeup` in the apparel template).
367
+ *
368
+ * Marked required so the framework rejects a save with `productId`
369
+ * empty or unset. Without this, downstream consumers (inventory
370
+ * stock motion, manufacturing BOM resolution) would have to filter
371
+ * out orphan SKU rows that point at no product — a sharp footgun
372
+ * the moment one slips through. The `@field({ required: true })`
373
+ * decorator also surfaces the constraint in generated REST/MCP
374
+ * schemas.
375
+ */
376
+ productId = "";
377
+ /**
378
+ * Stable, human-meaningful identifier such as a UPC, internal SKU
379
+ * code, or part number. Together with `tenantId` this is the natural
380
+ * key (`conflictColumns: ['code', 'tenant_id']`), so re-saving an
381
+ * identical row is an upsert rather than a UNIQUE violation.
382
+ */
383
+ code = "";
384
+ /** Optional scannable barcode (EAN/UPC/Code-128/etc.). */
385
+ barcode = "";
386
+ /** Display name for UIs. Optional — `code` is enough for machines. */
387
+ name = "";
388
+ /**
389
+ * Axis values for this SKU expressed as JSON, e.g. `{ size: 'M' }`,
390
+ * `{ finish: 'walnut' }`, or `{ voltage: '230V' }`.
391
+ *
392
+ * The persisted column type is text; use {@link getAttributes} and
393
+ * {@link setAttributes} to round-trip parsed values without worrying
394
+ * about parse errors.
395
+ */
396
+ attributes = "{}";
397
+ /** Optional physical weight in grams for shipping / cost calculations. */
398
+ weightGrams = 0;
399
+ /**
400
+ * Optional self-reference for bundles / kits — set to the id of the
401
+ * "parent" SKU that this SKU is a component of.
402
+ */
403
+ parentSkuId = "";
404
+ /**
405
+ * Soft-active flag. Inactive SKUs stay queryable for history but
406
+ * should not be offered for sale or production planning.
407
+ */
408
+ active = true;
409
+ constructor(options = {}) {
410
+ super(options);
411
+ if (options.tenantId !== void 0) this.tenantId = options.tenantId;
412
+ if (options.productId !== void 0) this.productId = options.productId;
413
+ if (options.code !== void 0) this.code = options.code;
414
+ if (options.barcode !== void 0) this.barcode = options.barcode;
415
+ if (options.name !== void 0) this.name = options.name;
416
+ if (options.attributes !== void 0) this.setAttributes(options.attributes);
417
+ if (options.weightGrams !== void 0) this.weightGrams = options.weightGrams;
418
+ if (options.parentSkuId !== void 0) this.parentSkuId = options.parentSkuId;
419
+ if (options.active !== void 0) this.active = options.active;
420
+ }
421
+ /**
422
+ * Parse and return the {@link attributes} JSON. Returns an empty
423
+ * object if the stored value is invalid JSON so callers don't have
424
+ * to wrap every read in a try/catch.
425
+ */
426
+ getAttributes() {
427
+ if (!this.attributes) return {};
428
+ try {
429
+ const parsed = JSON.parse(this.attributes);
430
+ return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {};
431
+ } catch {
432
+ return {};
433
+ }
434
+ }
435
+ /**
436
+ * Serialize axis values back into the stored {@link attributes}
437
+ * string. Accepts either an object (will be `JSON.stringify`'d) or a
438
+ * raw JSON string that the caller has already serialized.
439
+ */
440
+ setAttributes(value) {
441
+ if (typeof value === "string") {
442
+ this.attributes = value;
443
+ return;
444
+ }
445
+ this.attributes = JSON.stringify(value ?? {});
446
+ }
447
+ };
448
+ __decorate([tenantId({ nullable: true })], Sku.prototype, "tenantId", void 0);
449
+ __decorate([field({ required: true })], Sku.prototype, "productId", void 0);
450
+ __decorate([field({ required: true })], Sku.prototype, "code", void 0);
451
+ __decorate([field({ type: "decimal" })], Sku.prototype, "weightGrams", void 0);
452
+ Sku = __decorate([TenantScoped({ mode: "optional" }), smrt({
453
+ tableName: "product_skus",
454
+ conflictColumns: ["code", "tenant_id"],
455
+ api: { include: [
456
+ "list",
457
+ "get",
458
+ "create",
459
+ "update"
460
+ ] },
461
+ mcp: { include: ["list", "get"] },
462
+ cli: true
463
+ })], Sku);
464
+ //#endregion
465
+ export { Product as a, Material as i, ProductVariant as n, ProductType as o, ProductAsset as r, Category as s, Sku as t };
466
+
467
+ //# sourceMappingURL=Sku-B0w2dfHb.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Sku-B0w2dfHb.js","names":[],"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"],"mappings":";;;;;;;;;;AAmDO,IAAA,WAAA,MAAM,iBAAiB,WAAW;;;;;CAKvC,WAC0B;CAE1B,OAAO;CACP,cAAc;CACd;CAEA,QAAQ;CACR,eAAe;CACf,SAAS;CAET,YAAY,UAA2B,CAAC,GAAG;EACzC,MAAM,OAAO;EACb,IAAI,QAAQ,aAAa,KAAA,GAAW,KAAK,WAAW,QAAQ;EAC5D,KAAK,OAAO,QAAQ,QAAQ;EAC5B,KAAK,cAAc,QAAQ,eAAe;EAC1C,KAAK,WAAW,QAAQ;EACxB,KAAK,QAAQ,QAAQ,SAA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;CAAQ,EAAE;CACpD,KAAK,EAAE,SAAS,CAAC,QAAQ,KAAK,EAAE;CAChC,KAAK;AACP,CAAC,CAAA,GAAA,GAAA"}
@@ -0,0 +1,22 @@
1
+ import { ObjectRegistry } from "@happyvertical/smrt-core";
2
+ //#region src/__smrt-register__.ts
3
+ /**
4
+ * Self-registers this package's build-time manifest before any @smrt() decorator
5
+ * in the package fires. Fixes issue #1132: in consumer runtimes (tsx, SvelteKit
6
+ * SSR, plain `vite dev`) the decorator's synchronous manifest lookup previously
7
+ * missed because no step populated the global manifest cache — classes got
8
+ * registered with zero fields and `save()` / `toJSON()` silently dropped every
9
+ * declared property.
10
+ *
11
+ * Import this module as the first statement in `src/index.ts` so its top-level
12
+ * side effect runs ahead of any class module's @smrt() decorator.
13
+ *
14
+ * Silent no-op in dev/test, where the vitest plugin already populates manifests
15
+ * via a different path. Only needs to succeed in the published dist output.
16
+ *
17
+ * @see https://github.com/happyvertical/smrt/issues/1132
18
+ */
19
+ ObjectRegistry.registerPackageManifest(new URL("./manifest.json", "" + import.meta.url));
20
+ //#endregion
21
+
22
+ //# sourceMappingURL=__smrt-register__-DAo7IPPx.js.map