@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,119 @@
1
+ import { createClient } from "../lib/mock-smrt-client.js";
2
+ import * as $ from "svelte/internal/client";
3
+ //#region src/lib/stores/product-store.svelte.ts
4
+ var ProductStoreClass = class {
5
+ #data = $.state($.proxy({
6
+ items: [],
7
+ loading: false,
8
+ error: null,
9
+ selectedProduct: null
10
+ }));
11
+ get data() {
12
+ return $.get(this.#data);
13
+ }
14
+ set data(value) {
15
+ $.set(this.#data, value, true);
16
+ }
17
+ api = createClient("/api/v1");
18
+ get items() {
19
+ return this.data.items;
20
+ }
21
+ get loading() {
22
+ return this.data.loading;
23
+ }
24
+ get error() {
25
+ return this.data.error;
26
+ }
27
+ get selectedProduct() {
28
+ return this.data.selectedProduct;
29
+ }
30
+ get inStockCount() {
31
+ return this.data.items.filter((p) => p.inStock).length;
32
+ }
33
+ get totalValue() {
34
+ return this.data.items.reduce((sum, product) => sum + (product.price || 0), 0);
35
+ }
36
+ get categories() {
37
+ const categorySet = new Set(this.data.items.map((p) => p.category).filter(Boolean));
38
+ return Array.from(categorySet);
39
+ }
40
+ async loadProducts() {
41
+ this.data.loading = true;
42
+ this.data.error = null;
43
+ try {
44
+ const response = await this.api.products.list();
45
+ if (response.data) this.data.items = response.data;
46
+ } catch (err) {
47
+ this.data.error = err instanceof Error ? err.message : "Failed to load products";
48
+ } finally {
49
+ this.data.loading = false;
50
+ }
51
+ }
52
+ async createProduct(productData) {
53
+ this.data.loading = true;
54
+ this.data.error = null;
55
+ try {
56
+ const response = await this.api.products.create(productData);
57
+ if (response.data) this.data.items.push(response.data);
58
+ return response;
59
+ } catch (err) {
60
+ this.data.error = err instanceof Error ? err.message : "Failed to create product";
61
+ throw err;
62
+ } finally {
63
+ this.data.loading = false;
64
+ }
65
+ }
66
+ async updateProduct(id, updates) {
67
+ this.data.loading = true;
68
+ this.data.error = null;
69
+ try {
70
+ const response = await this.api.products.update(id, updates);
71
+ if (response.data) {
72
+ const index = this.data.items.findIndex((p) => p.id === id);
73
+ if (index !== -1) this.data.items[index] = response.data;
74
+ if (this.data.selectedProduct?.id === id) this.data.selectedProduct = response.data;
75
+ }
76
+ return response;
77
+ } catch (err) {
78
+ this.data.error = err instanceof Error ? err.message : "Failed to update product";
79
+ throw err;
80
+ } finally {
81
+ this.data.loading = false;
82
+ }
83
+ }
84
+ async deleteProduct(id) {
85
+ this.data.loading = true;
86
+ this.data.error = null;
87
+ try {
88
+ await this.api.products.delete(id);
89
+ this.data.items = this.data.items.filter((p) => p.id !== id);
90
+ if (this.data.selectedProduct?.id === id) this.data.selectedProduct = null;
91
+ } catch (err) {
92
+ this.data.error = err instanceof Error ? err.message : "Failed to delete product";
93
+ throw err;
94
+ } finally {
95
+ this.data.loading = false;
96
+ }
97
+ }
98
+ selectProduct(product) {
99
+ this.data.selectedProduct = product;
100
+ }
101
+ clearError() {
102
+ this.data.error = null;
103
+ }
104
+ filterByCategory(category) {
105
+ return this.data.items.filter((p) => p.category === category);
106
+ }
107
+ filterInStock() {
108
+ return this.data.items.filter((p) => p.inStock);
109
+ }
110
+ searchProducts(query) {
111
+ const lowercaseQuery = query.toLowerCase();
112
+ return this.data.items.filter((product) => product.name?.toLowerCase().includes(lowercaseQuery) || product.description?.toLowerCase().includes(lowercaseQuery) || product.tags?.some((tag) => tag.toLowerCase().includes(lowercaseQuery)));
113
+ }
114
+ };
115
+ var productStore = new ProductStoreClass();
116
+ //#endregion
117
+ export { productStore as n, ProductStoreClass as t };
118
+
119
+ //# sourceMappingURL=stores-CB0SI1c5.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stores-CB0SI1c5.js","names":[],"sources":["../../../src/lib/stores/product-store.svelte.ts"],"sourcesContent":["/**\n * Product Store - Svelte 5 Runes State Management\n *\n * Reactive store for managing product state with SMRT auto-generated client.\n * Uses Svelte 5 runes for reactive state management.\n */\n\nimport { createClient, type ProductData } from '../mock-smrt-client';\n\ninterface ProductStore {\n items: ProductData[];\n loading: boolean;\n error: string | null;\n selectedProduct: ProductData | null;\n}\n\nexport class ProductStoreClass {\n private data = $state<ProductStore>({\n items: [],\n loading: false,\n error: null,\n selectedProduct: null,\n });\n\n private api = createClient('/api/v1');\n\n // Reactive getters\n get items() {\n return this.data.items;\n }\n get loading() {\n return this.data.loading;\n }\n get error() {\n return this.data.error;\n }\n get selectedProduct() {\n return this.data.selectedProduct;\n }\n\n // Derived state\n get inStockCount() {\n return this.data.items.filter((p) => p.inStock).length;\n }\n\n get totalValue() {\n return this.data.items.reduce(\n (sum, product) => sum + (product.price || 0),\n 0,\n );\n }\n\n get categories() {\n const categorySet = new Set(\n this.data.items.map((p) => p.category).filter(Boolean),\n );\n return Array.from(categorySet);\n }\n\n // Actions\n async loadProducts() {\n this.data.loading = true;\n this.data.error = null;\n\n try {\n const response = await this.api.products.list();\n if (response.data) {\n this.data.items = response.data;\n }\n } catch (err) {\n this.data.error =\n err instanceof Error ? err.message : 'Failed to load products';\n } finally {\n this.data.loading = false;\n }\n }\n\n async createProduct(productData: Partial<ProductData>) {\n this.data.loading = true;\n this.data.error = null;\n\n try {\n const response = await this.api.products.create(productData);\n if (response.data) {\n this.data.items.push(response.data);\n }\n return response;\n } catch (err) {\n this.data.error =\n err instanceof Error ? err.message : 'Failed to create product';\n throw err;\n } finally {\n this.data.loading = false;\n }\n }\n\n async updateProduct(id: string, updates: Partial<ProductData>) {\n this.data.loading = true;\n this.data.error = null;\n\n try {\n const response = await this.api.products.update(id, updates);\n if (response.data) {\n const index = this.data.items.findIndex((p) => p.id === id);\n if (index !== -1) {\n this.data.items[index] = response.data;\n }\n\n // Update selected product if it's the one being updated\n if (this.data.selectedProduct?.id === id) {\n this.data.selectedProduct = response.data;\n }\n }\n return response;\n } catch (err) {\n this.data.error =\n err instanceof Error ? err.message : 'Failed to update product';\n throw err;\n } finally {\n this.data.loading = false;\n }\n }\n\n async deleteProduct(id: string) {\n this.data.loading = true;\n this.data.error = null;\n\n try {\n await this.api.products.delete(id);\n this.data.items = this.data.items.filter((p) => p.id !== id);\n\n // Clear selection if deleted product was selected\n if (this.data.selectedProduct?.id === id) {\n this.data.selectedProduct = null;\n }\n } catch (err) {\n this.data.error =\n err instanceof Error ? err.message : 'Failed to delete product';\n throw err;\n } finally {\n this.data.loading = false;\n }\n }\n\n selectProduct(product: ProductData | null) {\n this.data.selectedProduct = product;\n }\n\n clearError() {\n this.data.error = null;\n }\n\n // Filter methods (return derived arrays, don't mutate state)\n filterByCategory(category: string): ProductData[] {\n return this.data.items.filter((p) => p.category === category);\n }\n\n filterInStock(): ProductData[] {\n return this.data.items.filter((p) => p.inStock);\n }\n\n searchProducts(query: string): ProductData[] {\n const lowercaseQuery = query.toLowerCase();\n return this.data.items.filter(\n (product) =>\n product.name?.toLowerCase().includes(lowercaseQuery) ||\n product.description?.toLowerCase().includes(lowercaseQuery) ||\n product.tags?.some((tag) => tag.toLowerCase().includes(lowercaseQuery)),\n );\n }\n}\n\n// Export singleton instance\nexport const productStore = new ProductStoreClass();\n"],"mappings":"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"}
@@ -0,0 +1,30 @@
1
+ //#region src/lib/utils/index.ts
2
+ /**
3
+ * SMRT Template Utilities
4
+ *
5
+ * Shared utility functions for product management functionality.
6
+ */
7
+ function formatPrice(price) {
8
+ return new Intl.NumberFormat("en-US", {
9
+ style: "currency",
10
+ currency: "USD"
11
+ }).format(price);
12
+ }
13
+ function formatDate(date) {
14
+ const dateObj = typeof date === "string" ? new Date(date) : date;
15
+ return new Intl.DateTimeFormat("en-US", {
16
+ year: "numeric",
17
+ month: "short",
18
+ day: "numeric"
19
+ }).format(dateObj);
20
+ }
21
+ function slugify(text) {
22
+ return text.normalize("NFKD").replace(/[^\p{L}\p{N} ]+/gu, "").trim().toLowerCase().replace(/ +/g, "-").replace(/^-+|-+$/g, "");
23
+ }
24
+ function generateId() {
25
+ return Math.random().toString(36).substr(2, 9);
26
+ }
27
+ //#endregion
28
+ export { slugify as i, formatPrice as n, generateId as r, formatDate as t };
29
+
30
+ //# sourceMappingURL=utils-BgTqlQoH.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils-BgTqlQoH.js","names":[],"sources":["../../../src/lib/utils/index.ts"],"sourcesContent":["/**\n * SMRT Template Utilities\n *\n * Shared utility functions for product management functionality.\n */\n\nexport function formatPrice(price: number): string {\n return new Intl.NumberFormat('en-US', {\n style: 'currency',\n currency: 'USD',\n }).format(price);\n}\n\nexport function formatDate(date: string | Date): string {\n const dateObj = typeof date === 'string' ? new Date(date) : date;\n return new Intl.DateTimeFormat('en-US', {\n year: 'numeric',\n month: 'short',\n day: 'numeric',\n }).format(dateObj);\n}\n\nexport function slugify(text: string): string {\n return text\n .normalize('NFKD')\n .replace(/[^\\p{L}\\p{N} ]+/gu, '')\n .trim()\n .toLowerCase()\n .replace(/ +/g, '-')\n .replace(/^-+|-+$/g, '');\n}\n\nexport function generateId(): string {\n return Math.random().toString(36).substr(2, 9);\n}\n"],"mappings":";;;;;;AAMA,SAAgB,YAAY,OAAuB;CACjD,OAAO,IAAI,KAAK,aAAa,SAAS;EACpC,OAAO;EACP,UAAU;CACZ,CAAC,CAAC,CAAC,OAAO,KAAK;AACjB;AAEA,SAAgB,WAAW,MAA6B;CACtD,MAAM,UAAU,OAAO,SAAS,WAAW,IAAI,KAAK,IAAI,IAAI;CAC5D,OAAO,IAAI,KAAK,eAAe,SAAS;EACtC,MAAM;EACN,OAAO;EACP,KAAK;CACP,CAAC,CAAC,CAAC,OAAO,OAAO;AACnB;AAEA,SAAgB,QAAQ,MAAsB;CAC5C,OAAO,KACJ,UAAU,MAAM,CAAC,CACjB,QAAQ,qBAAqB,EAAE,CAAC,CAChC,KAAK,CAAC,CACN,YAAY,CAAC,CACb,QAAQ,OAAO,GAAG,CAAC,CACnB,QAAQ,YAAY,EAAE;AAC3B;AAEA,SAAgB,aAAqB;CACnC,OAAO,KAAK,OAAO,CAAC,CAAC,SAAS,EAAE,CAAC,CAAC,OAAO,GAAG,CAAC;AAC/C"}
@@ -1,12 +1,4 @@
1
- import "./chunks/__smrt-register__-BIgFaVKn.js";
2
- import { C, M, P, a, S } from "./chunks/SkuCollection-f_a3k93c.js";
3
- import { ProductAssetCollection } from "./chunks/ProductAssetCollection-B93HdSlX.js";
4
- export {
5
- C as CategoryCollection,
6
- M as MaterialCollection,
7
- ProductAssetCollection,
8
- P as ProductCollection,
9
- a as ProductVariantCollection,
10
- S as SkuCollection
11
- };
12
- //# sourceMappingURL=collections.js.map
1
+ import { i as CategoryCollection, n as ProductVariantCollection, r as MaterialCollection, t as SkuCollection } from "./chunks/collections-6PSqhUmZ.js";
2
+ import { t as ProductCollection } from "./chunks/ProductCollection-8QlfZ9ez.js";
3
+ import { t as ProductAssetCollection } from "./chunks/ProductAssetCollection-TbeaVxzc.js";
4
+ export { CategoryCollection, MaterialCollection, ProductAssetCollection, ProductCollection, ProductVariantCollection, SkuCollection };
@@ -1,6 +1,2 @@
1
- import { P, a } from "./chunks/ProductForm-CU0UvKEF.js";
2
- export {
3
- P as ProductCard,
4
- a as ProductForm
5
- };
6
- //# sourceMappingURL=components.js.map
1
+ import { n as ProductCard, t as ProductForm } from "./chunks/components-C6VpNVcg.js";
2
+ export { ProductCard, ProductForm };
@@ -1,5 +1,2 @@
1
- import { a } from "./chunks/index-i3-ci1FB.js";
2
- export {
3
- a as autoGeneratedComponents
4
- };
5
- //# sourceMappingURL=generated.js.map
1
+ import { t as autoGeneratedComponents } from "./chunks/generated-CM3rwUcw.js";
2
+ export { autoGeneratedComponents };
package/dist/lib/index.js CHANGED
@@ -1,228 +1,203 @@
1
- import "./chunks/__smrt-register__-BIgFaVKn.js";
2
- import createClient from "@happyvertical/smrt-virt-client";
3
- import { default as default2 } from "@smrt/client";
1
+ import { t as __exportAll } from "./chunks/rolldown-runtime-D7D4PA-g.js";
2
+ import "./chunks/__smrt-register__-DAo7IPPx.js";
3
+ import { a as Product, i as Material, n as ProductVariant, o as ProductType, r as ProductAsset, s as Category, t as Sku } from "./chunks/Sku-B0w2dfHb.js";
4
+ import { i as CategoryCollection, n as ProductVariantCollection, r as MaterialCollection, t as SkuCollection } from "./chunks/collections-6PSqhUmZ.js";
5
+ import { t as ProductCollection } from "./chunks/ProductCollection-8QlfZ9ez.js";
6
+ import { t as ProductAssetCollection } from "./chunks/ProductAssetCollection-TbeaVxzc.js";
7
+ import { n as ProductCard, t as ProductForm } from "./chunks/components-C6VpNVcg.js";
8
+ import { t as autoGeneratedComponents } from "./chunks/generated-CM3rwUcw.js";
9
+ import "./chunks/models-JPB-sld2.js";
10
+ import { n as productStore, t as ProductStoreClass } from "./chunks/stores-CB0SI1c5.js";
11
+ import { i as slugify, n as formatPrice, r as generateId, t as formatDate } from "./chunks/utils-BgTqlQoH.js";
12
+ import { startRestServer } from "@happyvertical/smrt-core";
13
+ import createClient$1 from "@happyvertical/smrt-virt-client";
14
+ import createClient from "@smrt/client";
4
15
  import { manifest } from "@smrt/manifest";
5
- import { default as default3 } from "@smrt/mcp";
6
- import { default as default4 } from "@smrt/routes";
7
- import { C, M, P, a, S } from "./chunks/SkuCollection-f_a3k93c.js";
8
- import { ProductAssetCollection } from "./chunks/ProductAssetCollection-B93HdSlX.js";
9
- import { P as P2, a as a2 } from "./chunks/ProductForm-CU0UvKEF.js";
10
- import { a as a3 } from "./chunks/index-i3-ci1FB.js";
11
- import { P as Product, C as Category } from "./chunks/Sku-sl6xf1PR.js";
12
- import { M as M2, a as a4, b, c, S as S2 } from "./chunks/Sku-sl6xf1PR.js";
13
- import { P as P3, p } from "./chunks/product-store.svelte-Dayd5n3W.js";
14
- import { formatDate, formatPrice, generateId, slugify } from "./utils.js";
16
+ import createMCPServer from "@smrt/mcp";
17
+ import setupRoutes from "@smrt/routes";
15
18
  import { MCPGenerator } from "@happyvertical/smrt-core/generators/mcp";
16
- import { startRestServer } from "@happyvertical/smrt-core";
19
+ //#region src/client.ts
20
+ /**
21
+ * SMRT Template Client
22
+ *
23
+ * Demonstrates auto-generated TypeScript client from SMRT objects.
24
+ * No manual client code needed - everything is generated from @smrt() decorated classes.
25
+ */
17
26
  async function demonstrateClient() {
18
- console.log("šŸ”Œ Creating auto-generated API client...");
19
- const api = createClient("http://localhost:3000/api/v1");
20
- try {
21
- console.log("\nšŸ“¦ Testing Product operations:");
22
- const newProduct = {
23
- name: "Demo Product",
24
- description: "A product created by the auto-generated client",
25
- price: 29.99,
26
- inStock: true,
27
- tags: ["demo", "auto-generated"]
28
- };
29
- console.log("Creating product:", newProduct);
30
- const createdProduct = await api.products.create(newProduct);
31
- console.log("āœ… Created:", createdProduct);
32
- console.log("\nšŸ“‹ Listing all products:");
33
- const products = await api.products.list();
34
- console.log("Products:", products);
35
- if (createdProduct?.id) {
36
- console.log(`
37
- šŸ” Getting product ${createdProduct.id}:`);
38
- const product = await api.products.get(createdProduct.id);
39
- console.log("Product:", product);
40
- console.log("\nāœļø Updating product:");
41
- const updatedProduct = await api.products.update(createdProduct.id, {
42
- price: 39.99,
43
- description: "Updated description"
44
- });
45
- console.log("Updated:", updatedProduct);
46
- }
47
- console.log("\nšŸ·ļø Testing Category operations:");
48
- const newCategory = {
49
- name: "Demo Category",
50
- description: "A category created by the auto-generated client",
51
- active: true
52
- };
53
- console.log("Creating category:", newCategory);
54
- const createdCategory = await api.categories.create(newCategory);
55
- console.log("āœ… Created:", createdCategory);
56
- console.log("\nšŸ“‹ Listing all categories:");
57
- const categories = await api.categories.list();
58
- console.log("Categories:", categories);
59
- } catch (error) {
60
- console.error("āŒ Client error:", error);
61
- }
62
- }
63
- if (import.meta.url === `file://${process.argv[1]}`) {
64
- demonstrateClient().catch(console.error);
27
+ console.log("šŸ”Œ Creating auto-generated API client...");
28
+ const api = createClient$1("http://localhost:3000/api/v1");
29
+ try {
30
+ console.log("\nšŸ“¦ Testing Product operations:");
31
+ const newProduct = {
32
+ name: "Demo Product",
33
+ description: "A product created by the auto-generated client",
34
+ price: 29.99,
35
+ inStock: true,
36
+ tags: ["demo", "auto-generated"]
37
+ };
38
+ console.log("Creating product:", newProduct);
39
+ const createdProduct = await api.products.create(newProduct);
40
+ console.log("āœ… Created:", createdProduct);
41
+ console.log("\nšŸ“‹ Listing all products:");
42
+ const products = await api.products.list();
43
+ console.log("Products:", products);
44
+ if (createdProduct?.id) {
45
+ console.log(`\nšŸ” Getting product ${createdProduct.id}:`);
46
+ const product = await api.products.get(createdProduct.id);
47
+ console.log("Product:", product);
48
+ console.log("\nāœļø Updating product:");
49
+ const updatedProduct = await api.products.update(createdProduct.id, {
50
+ price: 39.99,
51
+ description: "Updated description"
52
+ });
53
+ console.log("Updated:", updatedProduct);
54
+ }
55
+ console.log("\nšŸ·ļø Testing Category operations:");
56
+ const newCategory = {
57
+ name: "Demo Category",
58
+ description: "A category created by the auto-generated client",
59
+ active: true
60
+ };
61
+ console.log("Creating category:", newCategory);
62
+ const createdCategory = await api.categories.create(newCategory);
63
+ console.log("āœ… Created:", createdCategory);
64
+ console.log("\nšŸ“‹ Listing all categories:");
65
+ const categories = await api.categories.list();
66
+ console.log("Categories:", categories);
67
+ } catch (error) {
68
+ console.error("āŒ Client error:", error);
69
+ }
65
70
  }
71
+ if (import.meta.url === `file://${process.argv[1]}`) demonstrateClient().catch(console.error);
72
+ //#endregion
73
+ //#region src/mcp.ts
74
+ /**
75
+ * MCP Server Generator Script for @have/products
76
+ *
77
+ * This script generates a complete MCP server with stdio transport
78
+ * from the Product and Category SMRT objects.
79
+ *
80
+ * Run with: npm run generate:mcp
81
+ */
82
+ var mcp_exports = /* @__PURE__ */ __exportAll({ generateMCPServer: () => generateMCPServer });
83
+ /**
84
+ * Generate MCP server for products package
85
+ */
66
86
  async function generateMCPServer() {
67
- console.log("šŸ¤– Generating MCP Server for @have/products...\n");
68
- const generator = new MCPGenerator(
69
- {
70
- name: "products-mcp-server",
71
- version: "1.0.0",
72
- description: "MCP server exposing Product and Category SMRT objects"
73
- },
74
- {
75
- // Database and AI context will be configured via environment variables in generated server
76
- // DATABASE_URL - for database connection
77
- // OPENAI_API_KEY or ANTHROPIC_API_KEY - for AI client
78
- }
79
- );
80
- const tools = await generator.generateTools();
81
- console.log(`šŸ“ Discovered ${tools.length} tools from SMRT objects:`);
82
- tools.forEach((tool) => {
83
- console.log(` - ${tool.name}: ${tool.description}`);
84
- });
85
- console.log();
86
- await generator.generateServer({
87
- outputPath: "dist/mcp-server.js",
88
- serverName: "products-mcp",
89
- debug: false,
90
- // Set to true for debug logging
91
- generateClaudeConfigFile: true,
92
- generateReadme: true
93
- });
94
- console.log("\nāœ… MCP Server generation complete!");
95
- console.log("\nšŸ“š Next steps:");
96
- console.log(" 1. Build the server: npm run build");
97
- console.log(
98
- " 2. Add to Claude Desktop config (see dist/claude-config.example.json)"
99
- );
100
- console.log(" 3. Restart Claude Desktop");
101
- console.log(" 4. Use the tools in Claude Code!\n");
87
+ console.log("šŸ¤– Generating MCP Server for @have/products...\n");
88
+ const generator = new MCPGenerator({
89
+ name: "products-mcp-server",
90
+ version: "1.0.0",
91
+ description: "MCP server exposing Product and Category SMRT objects"
92
+ }, {});
93
+ const tools = await generator.generateTools();
94
+ console.log(`šŸ“ Discovered ${tools.length} tools from SMRT objects:`);
95
+ tools.forEach((tool) => {
96
+ console.log(` - ${tool.name}: ${tool.description}`);
97
+ });
98
+ console.log();
99
+ await generator.generateServer({
100
+ outputPath: "dist/mcp-server.js",
101
+ serverName: "products-mcp",
102
+ debug: false,
103
+ generateClaudeConfigFile: true,
104
+ generateReadme: true
105
+ });
106
+ console.log("\nāœ… MCP Server generation complete!");
107
+ console.log("\nšŸ“š Next steps:");
108
+ console.log(" 1. Build the server: npm run build");
109
+ console.log(" 2. Add to Claude Desktop config (see dist/claude-config.example.json)");
110
+ console.log(" 3. Restart Claude Desktop");
111
+ console.log(" 4. Use the tools in Claude Code!\n");
102
112
  }
103
- if (import.meta.url === `file://${process.argv[1]}`) {
104
- generateMCPServer().catch((error) => {
105
- console.error("āŒ MCP server generation failed:", error);
106
- process.exit(1);
107
- });
108
- }
109
- const mcp = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
110
- __proto__: null,
111
- generateMCPServer
112
- }, Symbol.toStringTag, { value: "Module" }));
113
+ if (import.meta.url === `file://${process.argv[1]}`) generateMCPServer().catch((error) => {
114
+ console.error("āŒ MCP server generation failed:", error);
115
+ process.exit(1);
116
+ });
117
+ //#endregion
118
+ //#region src/server.ts
119
+ /**
120
+ * SMRT Template Server
121
+ *
122
+ * Demonstrates auto-generated REST API from SMRT objects.
123
+ * No manual route definitions needed - everything is generated from @smrt() decorated classes.
124
+ */
125
+ var server_exports = /* @__PURE__ */ __exportAll({ startServer: () => startServer });
126
+ /**
127
+ * Reference auth stub (#1540). Generated routes are FAIL-CLOSED: without an
128
+ * `authMiddleware` (or `@smrt({ api: { public: true } })` on the model) every
129
+ * route returns 401. This stub demonstrates the contract — replace it with your
130
+ * real auth (verify a session cookie / bearer token, attach the principal).
131
+ *
132
+ * Returning the (optionally augmented) request allows the call; returning a
133
+ * `Response` rejects it.
134
+ */
113
135
  function demoAuthMiddleware(_objectName, _action) {
114
- return async (req) => {
115
- const token = req.headers.get("authorization");
116
- if (!token) {
117
- return new Response(
118
- JSON.stringify({ error: "Authentication required" }),
119
- {
120
- status: 401,
121
- headers: { "Content-Type": "application/json" }
122
- }
123
- );
124
- }
125
- return req;
126
- };
136
+ return async (req) => {
137
+ if (!req.headers.get("authorization")) return new Response(JSON.stringify({ error: "Authentication required" }), {
138
+ status: 401,
139
+ headers: { "Content-Type": "application/json" }
140
+ });
141
+ return req;
142
+ };
127
143
  }
128
144
  async function startServer() {
129
- console.log("šŸš€ Starting SMRT Template Server...");
130
- const shutdown = await startRestServer(
131
- [Product, Category],
132
- // SMRT objects to generate API for
133
- {},
134
- // context
135
- {
136
- port: 3e3,
137
- hostname: "127.0.0.1",
138
- basePath: "/api/v1",
139
- enableCors: true,
140
- allowedOrigins: ["http://localhost:3000"],
141
- authMiddleware: demoAuthMiddleware
142
- }
143
- );
144
- console.log("āœ… Server ready!");
145
- console.log("šŸ“” REST API: http://localhost:3000/api/v1");
146
- console.log("šŸ“š Endpoints:");
147
- console.log(" GET /api/v1/products - List products");
148
- console.log(" POST /api/v1/products - Create product");
149
- console.log(" GET /api/v1/products/:id - Get product");
150
- console.log(" PUT /api/v1/products/:id - Update product");
151
- console.log(" GET /api/v1/categories - List categories");
152
- console.log(" POST /api/v1/categories - Create category");
153
- console.log("\nšŸ’” Try these endpoints (auth required — send a token):");
154
- console.log(
155
- ' curl http://localhost:3000/api/v1/products -H "Authorization: Bearer <token>"'
156
- );
157
- console.log(
158
- ' curl http://localhost:3000/api/v1/categories -H "Authorization: Bearer <token>"'
159
- );
160
- console.log(
161
- ` curl -X POST http://localhost:3000/api/v1/products -H "Authorization: Bearer <token>" -H "Content-Type: application/json" -d '{"name":"Test Product","price":29.99}'`
162
- );
163
- return { shutdown };
164
- }
165
- if (import.meta.url === `file://${process.argv[1]}`) {
166
- startServer().catch(console.error);
145
+ console.log("šŸš€ Starting SMRT Template Server...");
146
+ const shutdown = await startRestServer([Product, Category], {}, {
147
+ port: 3e3,
148
+ hostname: "127.0.0.1",
149
+ basePath: "/api/v1",
150
+ enableCors: true,
151
+ allowedOrigins: ["http://localhost:3000"],
152
+ authMiddleware: demoAuthMiddleware
153
+ });
154
+ console.log("āœ… Server ready!");
155
+ console.log("šŸ“” REST API: http://localhost:3000/api/v1");
156
+ console.log("šŸ“š Endpoints:");
157
+ console.log(" GET /api/v1/products - List products");
158
+ console.log(" POST /api/v1/products - Create product");
159
+ console.log(" GET /api/v1/products/:id - Get product");
160
+ console.log(" PUT /api/v1/products/:id - Update product");
161
+ console.log(" GET /api/v1/categories - List categories");
162
+ console.log(" POST /api/v1/categories - Create category");
163
+ console.log("\nšŸ’” Try these endpoints (auth required — send a token):");
164
+ console.log(" curl http://localhost:3000/api/v1/products -H \"Authorization: Bearer <token>\"");
165
+ console.log(" curl http://localhost:3000/api/v1/categories -H \"Authorization: Bearer <token>\"");
166
+ console.log(" curl -X POST http://localhost:3000/api/v1/products -H \"Authorization: Bearer <token>\" -H \"Content-Type: application/json\" -d '{\"name\":\"Test Product\",\"price\":29.99}'");
167
+ return { shutdown };
167
168
  }
168
- const server = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
169
- __proto__: null,
170
- startServer
171
- }, Symbol.toStringTag, { value: "Module" }));
169
+ if (import.meta.url === `file://${process.argv[1]}`) startServer().catch(console.error);
170
+ //#endregion
171
+ //#region src/index.ts
172
+ /**
173
+ * Start all services for demonstration (legacy function)
174
+ */
172
175
  async function startAll() {
173
- const { startServer: startServer2 } = await Promise.resolve().then(() => server);
174
- const { generateMCPServer: generateMCPServer2 } = await Promise.resolve().then(() => mcp);
175
- console.log("šŸš€ Starting SMRT Template - Full Demo\n");
176
- console.log("1ļøāƒ£ Starting REST API...");
177
- const server$1 = await startServer2();
178
- console.log("\n2ļøāƒ£ Starting MCP Server...");
179
- const mcp$1 = await generateMCPServer2();
180
- console.log("\n✨ All services running!");
181
- console.log("\nšŸŽÆ What was auto-generated:");
182
- console.log(" • REST endpoints for Product and Category");
183
- console.log(" • TypeScript client with full type safety");
184
- console.log(" • MCP tools for AI model integration");
185
- console.log(" • OpenAPI/Swagger documentation");
186
- console.log(" • Live reloading during development");
187
- console.log("\nšŸ“ Next steps:");
188
- console.log(" • Modify src/lib/models/ to add new fields");
189
- console.log(" • Add new @smrt() classes to auto-generate more APIs");
190
- console.log(" • Run bun run dev to see live updates");
191
- return { server: server$1, mcp: mcp$1 };
192
- }
193
- if (import.meta.url === `file://${process.argv[1]}`) {
194
- startAll().catch(console.error);
176
+ const { startServer } = await Promise.resolve().then(() => server_exports);
177
+ const { generateMCPServer } = await Promise.resolve().then(() => mcp_exports);
178
+ console.log("šŸš€ Starting SMRT Template - Full Demo\n");
179
+ console.log("1ļøāƒ£ Starting REST API...");
180
+ const server = await startServer();
181
+ console.log("\n2ļøāƒ£ Starting MCP Server...");
182
+ const mcp = await generateMCPServer();
183
+ console.log("\n✨ All services running!");
184
+ console.log("\nšŸŽÆ What was auto-generated:");
185
+ console.log(" • REST endpoints for Product and Category");
186
+ console.log(" • TypeScript client with full type safety");
187
+ console.log(" • MCP tools for AI model integration");
188
+ console.log(" • OpenAPI/Swagger documentation");
189
+ console.log(" • Live reloading during development");
190
+ console.log("\nšŸ“ Next steps:");
191
+ console.log(" • Modify src/lib/models/ to add new fields");
192
+ console.log(" • Add new @smrt() classes to auto-generate more APIs");
193
+ console.log(" • Run bun run dev to see live updates");
194
+ return {
195
+ server,
196
+ mcp
197
+ };
195
198
  }
196
- export {
197
- Category,
198
- C as CategoryCollection,
199
- M2 as Material,
200
- M as MaterialCollection,
201
- Product,
202
- a4 as ProductAsset,
203
- ProductAssetCollection,
204
- P2 as ProductCard,
205
- P as ProductCollection,
206
- a2 as ProductForm,
207
- P3 as ProductStoreClass,
208
- b as ProductType,
209
- c as ProductVariant,
210
- a as ProductVariantCollection,
211
- S2 as Sku,
212
- S as SkuCollection,
213
- a3 as autoGeneratedComponents,
214
- default2 as createClient,
215
- default3 as createMCPServer,
216
- demonstrateClient,
217
- formatDate,
218
- formatPrice,
219
- generateId,
220
- generateMCPServer,
221
- manifest,
222
- p as productStore,
223
- default4 as setupRoutes,
224
- slugify,
225
- startAll,
226
- startServer
227
- };
228
- //# sourceMappingURL=index.js.map
199
+ if (import.meta.url === `file://${process.argv[1]}`) startAll().catch(console.error);
200
+ //#endregion
201
+ export { Category, CategoryCollection, Material, MaterialCollection, Product, ProductAsset, ProductAssetCollection, ProductCard, ProductCollection, ProductForm, ProductStoreClass, ProductType, ProductVariant, ProductVariantCollection, Sku, SkuCollection, autoGeneratedComponents, createClient, createMCPServer, demonstrateClient, formatDate, formatPrice, generateId, generateMCPServer, manifest, productStore, setupRoutes, slugify, startAll, startServer };
202
+
203
+ //# sourceMappingURL=index.js.map