@happyvertical/smrt-products 0.30.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. package/AGENTS.md +122 -0
  2. package/CLAUDE.md +1 -0
  3. package/LICENSE +7 -0
  4. package/README.md +115 -0
  5. package/dist/lib/__smrt-register__.d.ts +2 -0
  6. package/dist/lib/__smrt-register__.d.ts.map +1 -0
  7. package/dist/lib/app/main.d.ts +6 -0
  8. package/dist/lib/app/main.d.ts.map +1 -0
  9. package/dist/lib/chunks/ProductAssetCollection-DFPXN43q.js +64 -0
  10. package/dist/lib/chunks/ProductAssetCollection-DFPXN43q.js.map +1 -0
  11. package/dist/lib/chunks/ProductForm-DHeb2L24.js +371 -0
  12. package/dist/lib/chunks/ProductForm-DHeb2L24.js.map +1 -0
  13. package/dist/lib/chunks/Sku-DUKtbYWT.js +511 -0
  14. package/dist/lib/chunks/Sku-DUKtbYWT.js.map +1 -0
  15. package/dist/lib/chunks/SkuCollection-C0tdkEdL.js +160 -0
  16. package/dist/lib/chunks/SkuCollection-C0tdkEdL.js.map +1 -0
  17. package/dist/lib/chunks/__smrt-register__-BIgFaVKn.js +5 -0
  18. package/dist/lib/chunks/__smrt-register__-BIgFaVKn.js.map +1 -0
  19. package/dist/lib/chunks/index-i3-ci1FB.js +6 -0
  20. package/dist/lib/chunks/index-i3-ci1FB.js.map +1 -0
  21. package/dist/lib/chunks/product-store.svelte-Dayd5n3W.js +132 -0
  22. package/dist/lib/chunks/product-store.svelte-Dayd5n3W.js.map +1 -0
  23. package/dist/lib/client.d.ts +9 -0
  24. package/dist/lib/client.d.ts.map +1 -0
  25. package/dist/lib/collections.d.ts +2 -0
  26. package/dist/lib/collections.d.ts.map +1 -0
  27. package/dist/lib/collections.js +12 -0
  28. package/dist/lib/collections.js.map +1 -0
  29. package/dist/lib/components.d.ts +2 -0
  30. package/dist/lib/components.d.ts.map +1 -0
  31. package/dist/lib/components.js +6 -0
  32. package/dist/lib/components.js.map +1 -0
  33. package/dist/lib/generated.d.ts +2 -0
  34. package/dist/lib/generated.d.ts.map +1 -0
  35. package/dist/lib/generated.js +5 -0
  36. package/dist/lib/generated.js.map +1 -0
  37. package/dist/lib/index.d.ts +14 -0
  38. package/dist/lib/index.d.ts.map +1 -0
  39. package/dist/lib/index.js +228 -0
  40. package/dist/lib/index.js.map +1 -0
  41. package/dist/lib/lib/collections/CategoryCollection.d.ts +20 -0
  42. package/dist/lib/lib/collections/CategoryCollection.d.ts.map +1 -0
  43. package/dist/lib/lib/collections/MaterialCollection.d.ts +20 -0
  44. package/dist/lib/lib/collections/MaterialCollection.d.ts.map +1 -0
  45. package/dist/lib/lib/collections/ProductAssetCollection.d.ts +16 -0
  46. package/dist/lib/lib/collections/ProductAssetCollection.d.ts.map +1 -0
  47. package/dist/lib/lib/collections/ProductCollection.d.ts +12 -0
  48. package/dist/lib/lib/collections/ProductCollection.d.ts.map +1 -0
  49. package/dist/lib/lib/collections/ProductVariantCollection.d.ts +10 -0
  50. package/dist/lib/lib/collections/ProductVariantCollection.d.ts.map +1 -0
  51. package/dist/lib/lib/collections/SkuCollection.d.ts +31 -0
  52. package/dist/lib/lib/collections/SkuCollection.d.ts.map +1 -0
  53. package/dist/lib/lib/collections/index.d.ts +7 -0
  54. package/dist/lib/lib/collections/index.d.ts.map +1 -0
  55. package/dist/lib/lib/components/ProductCard.svelte +173 -0
  56. package/dist/lib/lib/components/ProductCard.svelte.d.ts +10 -0
  57. package/dist/lib/lib/components/ProductCard.svelte.d.ts.map +1 -0
  58. package/dist/lib/lib/components/ProductForm.svelte +289 -0
  59. package/dist/lib/lib/components/ProductForm.svelte.d.ts +11 -0
  60. package/dist/lib/lib/components/ProductForm.svelte.d.ts.map +1 -0
  61. package/dist/lib/lib/components/TestComponent.svelte +25 -0
  62. package/dist/lib/lib/components/TestComponent.svelte.d.ts +7 -0
  63. package/dist/lib/lib/components/TestComponent.svelte.d.ts.map +1 -0
  64. package/dist/lib/lib/components/auto-generated/AutoForm.svelte +240 -0
  65. package/dist/lib/lib/components/auto-generated/AutoForm.svelte.d.ts +13 -0
  66. package/dist/lib/lib/components/auto-generated/AutoForm.svelte.d.ts.map +1 -0
  67. package/dist/lib/lib/components/auto-generated/FieldRenderer.svelte +205 -0
  68. package/dist/lib/lib/components/auto-generated/FieldRenderer.svelte.d.ts +14 -0
  69. package/dist/lib/lib/components/auto-generated/FieldRenderer.svelte.d.ts.map +1 -0
  70. package/dist/lib/lib/components/index.d.ts +12 -0
  71. package/dist/lib/lib/components/index.d.ts.map +1 -0
  72. package/dist/lib/lib/components/index.js +11 -0
  73. package/dist/lib/lib/features/CategoryManager.svelte +80 -0
  74. package/dist/lib/lib/features/CategoryManager.svelte.d.ts +7 -0
  75. package/dist/lib/lib/features/CategoryManager.svelte.d.ts.map +1 -0
  76. package/dist/lib/lib/features/ProductCatalog.svelte +299 -0
  77. package/dist/lib/lib/features/ProductCatalog.svelte.d.ts +8 -0
  78. package/dist/lib/lib/features/ProductCatalog.svelte.d.ts.map +1 -0
  79. package/dist/lib/lib/federation-entry.d.ts +11 -0
  80. package/dist/lib/lib/federation-entry.d.ts.map +1 -0
  81. package/dist/lib/lib/generated/index.d.ts +2 -0
  82. package/dist/lib/lib/generated/index.d.ts.map +1 -0
  83. package/dist/lib/lib/i18n.d.ts +79 -0
  84. package/dist/lib/lib/i18n.d.ts.map +1 -0
  85. package/dist/lib/lib/index.d.ts +20 -0
  86. package/dist/lib/lib/index.d.ts.map +1 -0
  87. package/dist/lib/lib/mock-smrt-client.d.ts +40 -0
  88. package/dist/lib/lib/mock-smrt-client.d.ts.map +1 -0
  89. package/dist/lib/lib/mock-smrt-client.js +129 -0
  90. package/dist/lib/lib/mock-smrt-client.js.map +1 -0
  91. package/dist/lib/lib/models/Category.d.ts +38 -0
  92. package/dist/lib/lib/models/Category.d.ts.map +1 -0
  93. package/dist/lib/lib/models/Material.d.ts +22 -0
  94. package/dist/lib/lib/models/Material.d.ts.map +1 -0
  95. package/dist/lib/lib/models/Product.d.ts +57 -0
  96. package/dist/lib/lib/models/Product.d.ts.map +1 -0
  97. package/dist/lib/lib/models/ProductAsset.d.ts +17 -0
  98. package/dist/lib/lib/models/ProductAsset.d.ts.map +1 -0
  99. package/dist/lib/lib/models/ProductVariant.d.ts +51 -0
  100. package/dist/lib/lib/models/ProductVariant.d.ts.map +1 -0
  101. package/dist/lib/lib/models/Sku.d.ts +79 -0
  102. package/dist/lib/lib/models/Sku.d.ts.map +1 -0
  103. package/dist/lib/lib/models/index.d.ts +15 -0
  104. package/dist/lib/lib/models/index.d.ts.map +1 -0
  105. package/dist/lib/lib/models/types.d.ts +41 -0
  106. package/dist/lib/lib/models/types.d.ts.map +1 -0
  107. package/dist/lib/lib/stores/index.d.ts +8 -0
  108. package/dist/lib/lib/stores/index.d.ts.map +1 -0
  109. package/dist/lib/lib/stores/index.js +7 -0
  110. package/dist/lib/lib/stores/product-store.client.svelte.d.ts +45 -0
  111. package/dist/lib/lib/stores/product-store.client.svelte.d.ts.map +1 -0
  112. package/dist/lib/lib/stores/product-store.client.svelte.js +147 -0
  113. package/dist/lib/lib/stores/product-store.svelte.d.ts +29 -0
  114. package/dist/lib/lib/stores/product-store.svelte.d.ts.map +1 -0
  115. package/dist/lib/lib/stores/product-store.svelte.js +144 -0
  116. package/dist/lib/lib/types.d.ts +43 -0
  117. package/dist/lib/lib/types.d.ts.map +1 -0
  118. package/dist/lib/lib/utils/index.d.ts +10 -0
  119. package/dist/lib/lib/utils/index.d.ts.map +1 -0
  120. package/dist/lib/main.d.ts +5 -0
  121. package/dist/lib/main.d.ts.map +1 -0
  122. package/dist/lib/manifest.json +3758 -0
  123. package/dist/lib/mcp.d.ts +14 -0
  124. package/dist/lib/mcp.d.ts.map +1 -0
  125. package/dist/lib/models.d.ts +2 -0
  126. package/dist/lib/models.d.ts.map +1 -0
  127. package/dist/lib/models.js +12 -0
  128. package/dist/lib/models.js.map +1 -0
  129. package/dist/lib/native-api-server.d.ts +7 -0
  130. package/dist/lib/native-api-server.d.ts.map +1 -0
  131. package/dist/lib/server.d.ts +11 -0
  132. package/dist/lib/server.d.ts.map +1 -0
  133. package/dist/lib/simple-api-server.d.ts +7 -0
  134. package/dist/lib/simple-api-server.d.ts.map +1 -0
  135. package/dist/lib/simple-server.d.ts +6 -0
  136. package/dist/lib/simple-server.d.ts.map +1 -0
  137. package/dist/lib/smrt-knowledge.json +1584 -0
  138. package/dist/lib/smrt-products.css +233 -0
  139. package/dist/lib/stores.d.ts +2 -0
  140. package/dist/lib/stores.d.ts.map +1 -0
  141. package/dist/lib/stores.js +6 -0
  142. package/dist/lib/stores.js.map +1 -0
  143. package/dist/lib/utils.d.ts +2 -0
  144. package/dist/lib/utils.d.ts.map +1 -0
  145. package/dist/lib/utils.js +27 -0
  146. package/dist/lib/utils.js.map +1 -0
  147. package/package.json +127 -0
@@ -0,0 +1,228 @@
1
+ import "./chunks/__smrt-register__-BIgFaVKn.js";
2
+ import createClient from "@happyvertical/smrt-virt-client";
3
+ import { default as default2 } from "@smrt/client";
4
+ 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-C0tdkEdL.js";
8
+ import { ProductAssetCollection } from "./chunks/ProductAssetCollection-DFPXN43q.js";
9
+ import { P as P2, a as a2 } from "./chunks/ProductForm-DHeb2L24.js";
10
+ import { a as a3 } from "./chunks/index-i3-ci1FB.js";
11
+ import { P as Product, C as Category } from "./chunks/Sku-DUKtbYWT.js";
12
+ import { M as M2, a as a4, b, c, S as S2 } from "./chunks/Sku-DUKtbYWT.js";
13
+ import { P as P3, p } from "./chunks/product-store.svelte-Dayd5n3W.js";
14
+ import { formatDate, formatPrice, generateId, slugify } from "./utils.js";
15
+ import { MCPGenerator } from "@happyvertical/smrt-core/generators/mcp";
16
+ import { startRestServer } from "@happyvertical/smrt-core";
17
+ 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);
65
+ }
66
+ 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");
102
+ }
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
+ 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
+ };
127
+ }
128
+ 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);
167
+ }
168
+ const server = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
169
+ __proto__: null,
170
+ startServer
171
+ }, Symbol.toStringTag, { value: "Module" }));
172
+ 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);
195
+ }
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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../src/client.ts","../../src/mcp.ts","../../src/server.ts","../../src/index.ts"],"sourcesContent":["/**\n * SMRT Template Client\n *\n * Demonstrates auto-generated TypeScript client from SMRT objects.\n * No manual client code needed - everything is generated from @smrt() decorated classes.\n */\n\nimport createClient from '@happyvertical/smrt-virt-client'; // Virtual module from Vite plugin\nimport type { CategoryData, ProductData } from '@happyvertical/smrt-virt-types'; // Virtual module from Vite plugin\n\nasync function demonstrateClient() {\n console.log('🔌 Creating auto-generated API client...');\n\n // Create client pointing to local server\n const api = createClient('http://localhost:3000/api/v1');\n\n try {\n console.log('\\n📦 Testing Product operations:');\n\n // Create a product\n const newProduct: Partial<ProductData> = {\n name: 'Demo Product',\n description: 'A product created by the auto-generated client',\n price: 29.99,\n inStock: true,\n tags: ['demo', 'auto-generated'],\n };\n\n console.log('Creating product:', newProduct);\n const createdProduct = await api.products.create(newProduct);\n console.log('✅ Created:', createdProduct);\n\n // List products\n console.log('\\n📋 Listing all products:');\n const products = await api.products.list();\n console.log('Products:', products);\n\n // Get specific product\n if (createdProduct?.id) {\n console.log(`\\n🔍 Getting product ${createdProduct.id}:`);\n const product = await api.products.get(createdProduct.id);\n console.log('Product:', product);\n\n // Update product\n console.log('\\n✏️ Updating product:');\n const updatedProduct = await api.products.update(createdProduct.id, {\n price: 39.99,\n description: 'Updated description',\n });\n console.log('Updated:', updatedProduct);\n }\n\n console.log('\\n🏷️ Testing Category operations:');\n\n // Create a category\n const newCategory: Partial<CategoryData> = {\n name: 'Demo Category',\n description: 'A category created by the auto-generated client',\n active: true,\n };\n\n console.log('Creating category:', newCategory);\n const createdCategory = await api.categories.create(newCategory);\n console.log('✅ Created:', createdCategory);\n\n // List categories\n console.log('\\n📋 Listing all categories:');\n const categories = await api.categories.list();\n console.log('Categories:', categories);\n } catch (error) {\n console.error('❌ Client error:', error);\n }\n}\n\n// Run demonstration if called directly\nif (import.meta.url === `file://${process.argv[1]}`) {\n demonstrateClient().catch(console.error);\n}\n\nexport { demonstrateClient };\n","/**\n * MCP Server Generator Script for @have/products\n *\n * This script generates a complete MCP server with stdio transport\n * from the Product and Category SMRT objects.\n *\n * Run with: npm run generate:mcp\n */\n\nimport { MCPGenerator } from '@happyvertical/smrt-core/generators/mcp';\n\n/**\n * Generate MCP server for products package\n */\nasync function generateMCPServer() {\n console.log('🤖 Generating MCP Server for @have/products...\\n');\n\n // Create generator instance\n const generator = new MCPGenerator(\n {\n name: 'products-mcp-server',\n version: '1.0.0',\n description: 'MCP server exposing Product and Category SMRT objects',\n },\n {\n // Database and AI context will be configured via environment variables in generated server\n // DATABASE_URL - for database connection\n // OPENAI_API_KEY or ANTHROPIC_API_KEY - for AI client\n },\n );\n\n // Generate tools to preview what will be available\n const tools = await generator.generateTools();\n console.log(`📝 Discovered ${tools.length} tools from SMRT objects:`);\n tools.forEach((tool) => {\n console.log(` - ${tool.name}: ${tool.description}`);\n });\n console.log();\n\n // Generate complete MCP server with stdio transport\n await generator.generateServer({\n outputPath: 'dist/mcp-server.js',\n serverName: 'products-mcp',\n debug: false, // Set to true for debug logging\n generateClaudeConfigFile: true,\n generateReadme: true,\n });\n\n console.log('\\n✅ MCP Server generation complete!');\n console.log('\\n📚 Next steps:');\n console.log(' 1. Build the server: npm run build');\n console.log(\n ' 2. Add to Claude Desktop config (see dist/claude-config.example.json)',\n );\n console.log(' 3. Restart Claude Desktop');\n console.log(' 4. Use the tools in Claude Code!\\n');\n}\n\n// Run if executed directly\nif (import.meta.url === `file://${process.argv[1]}`) {\n generateMCPServer().catch((error) => {\n console.error('❌ MCP server generation failed:', error);\n process.exit(1);\n });\n}\n\nexport { generateMCPServer };\n","/**\n * SMRT Template Server\n *\n * Demonstrates auto-generated REST API from SMRT objects.\n * No manual route definitions needed - everything is generated from @smrt() decorated classes.\n */\n\nimport { startRestServer } from '@happyvertical/smrt-core';\nimport { Category } from './lib/models/Category';\nimport { Product } from './lib/models/Product';\n\n/**\n * Reference auth stub (#1540). Generated routes are FAIL-CLOSED: without an\n * `authMiddleware` (or `@smrt({ api: { public: true } })` on the model) every\n * route returns 401. This stub demonstrates the contract — replace it with your\n * real auth (verify a session cookie / bearer token, attach the principal).\n *\n * Returning the (optionally augmented) request allows the call; returning a\n * `Response` rejects it.\n */\nfunction demoAuthMiddleware(_objectName: string, _action: string) {\n return async (req: Request): Promise<Request | Response> => {\n const token = req.headers.get('authorization');\n if (!token) {\n return new Response(\n JSON.stringify({ error: 'Authentication required' }),\n {\n status: 401,\n headers: { 'Content-Type': 'application/json' },\n },\n );\n }\n // TODO: verify `token` and attach the resolved principal to the request.\n return req;\n };\n}\n\nasync function startServer() {\n console.log('🚀 Starting SMRT Template Server...');\n\n // Start server with registered SMRT objects. Secure defaults (#1540): bind to\n // loopback, an explicit CORS origin allowlist (never `*`), and a fail-closed\n // auth middleware.\n const shutdown = await startRestServer(\n [Product, Category], // SMRT objects to generate API for\n {}, // context\n {\n port: 3000,\n hostname: '127.0.0.1',\n basePath: '/api/v1',\n enableCors: true,\n allowedOrigins: ['http://localhost:3000'],\n authMiddleware: demoAuthMiddleware,\n },\n );\n\n console.log('✅ Server ready!');\n console.log('📡 REST API: http://localhost:3000/api/v1');\n console.log('📚 Endpoints:');\n console.log(' GET /api/v1/products - List products');\n console.log(' POST /api/v1/products - Create product');\n console.log(' GET /api/v1/products/:id - Get product');\n console.log(' PUT /api/v1/products/:id - Update product');\n console.log(' GET /api/v1/categories - List categories');\n console.log(' POST /api/v1/categories - Create category');\n\n console.log('\\n💡 Try these endpoints (auth required — send a token):');\n console.log(\n ' curl http://localhost:3000/api/v1/products -H \"Authorization: Bearer <token>\"',\n );\n console.log(\n ' curl http://localhost:3000/api/v1/categories -H \"Authorization: Bearer <token>\"',\n );\n console.log(\n ' 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}\\'',\n );\n\n return { shutdown };\n}\n\n// Start if running directly\nif (import.meta.url === `file://${process.argv[1]}`) {\n startServer().catch(console.error);\n}\n\nexport { startServer };\n","/**\n * SMRT Template: Triple-Purpose Export\n *\n * This is the main entry point when this template is used as an NPM library.\n * It re-exports everything from the lib directory for easy consumption.\n *\n * Usage examples:\n *\n * // Import models\n * import { Product, Category } from '@happyvertical/core-template';\n *\n * // Import UI components\n * import { ProductCard, ProductForm } from '@happyvertical/core-template/components';\n *\n * // Import stores\n * import { ProductStoreClass } from '@happyvertical/core-template/stores';\n */\n\n// Self-register this package's manifest before any @smrt() decorator fires\n// downstream. Must come first so the side effect runs ahead of the class\n// module loads below. See __smrt-register__.ts for issue #1132 context.\nimport './__smrt-register__.js';\n\nexport { demonstrateClient } from './client';\n// Re-export everything from the lib directory\nexport * from './lib/index';\nexport { generateMCPServer } from './mcp';\n// Legacy exports for backward compatibility\nexport { startServer } from './server';\n\n/**\n * Start all services for demonstration (legacy function)\n */\nexport async function startAll() {\n const { startServer } = await import('./server');\n const { generateMCPServer } = await import('./mcp');\n\n console.log('🚀 Starting SMRT Template - Full Demo\\n');\n\n // Start REST API server\n console.log('1️⃣ Starting REST API...');\n const server = await startServer();\n\n // Start MCP server\n console.log('\\n2️⃣ Starting MCP Server...');\n const mcp = await generateMCPServer();\n\n console.log('\\n✨ All services running!');\n console.log('\\n🎯 What was auto-generated:');\n console.log(' • REST endpoints for Product and Category');\n console.log(' • TypeScript client with full type safety');\n console.log(' • MCP tools for AI model integration');\n console.log(' • OpenAPI/Swagger documentation');\n console.log(' • Live reloading during development');\n\n console.log('\\n📝 Next steps:');\n console.log(' • Modify src/lib/models/ to add new fields');\n console.log(' • Add new @smrt() classes to auto-generate more APIs');\n console.log(' • Run bun run dev to see live updates');\n\n return { server, mcp };\n}\n\n// Auto-start if running directly\nif (import.meta.url === `file://${process.argv[1]}`) {\n startAll().catch(console.error);\n}\n"],"names":["startServer","generateMCPServer","server","mcp"],"mappings":";;;;;;;;;;;;;;;;AAUA,eAAe,oBAAoB;AACjC,UAAQ,IAAI,0CAA0C;AAGtD,QAAM,MAAM,aAAa,8BAA8B;AAEvD,MAAI;AACF,YAAQ,IAAI,kCAAkC;AAG9C,UAAM,aAAmC;AAAA,MACvC,MAAM;AAAA,MACN,aAAa;AAAA,MACb,OAAO;AAAA,MACP,SAAS;AAAA,MACT,MAAM,CAAC,QAAQ,gBAAgB;AAAA,IAAA;AAGjC,YAAQ,IAAI,qBAAqB,UAAU;AAC3C,UAAM,iBAAiB,MAAM,IAAI,SAAS,OAAO,UAAU;AAC3D,YAAQ,IAAI,cAAc,cAAc;AAGxC,YAAQ,IAAI,4BAA4B;AACxC,UAAM,WAAW,MAAM,IAAI,SAAS,KAAA;AACpC,YAAQ,IAAI,aAAa,QAAQ;AAGjC,QAAI,gBAAgB,IAAI;AACtB,cAAQ,IAAI;AAAA,qBAAwB,eAAe,EAAE,GAAG;AACxD,YAAM,UAAU,MAAM,IAAI,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models/Category';
3
+ export declare class CategoryCollection extends SmrtCollection<Category> {
4
+ static readonly _itemClass: typeof Category;
5
+ /**
6
+ * Return every top-level category. `parentId` on `Category` is typed
7
+ * `string | undefined`; SMRT serializes undefined string fields as `''`
8
+ * rather than `NULL`, so a category created without an explicit
9
+ * `parentId` lands in the DB with `parent_id = ''`, not `parent_id IS NULL`.
10
+ *
11
+ * We accept both shapes — historical data, migrations, and direct DB
12
+ * imports can produce either — so consumers don't have to normalize
13
+ * `parentId` on write to be discoverable as a root. SQL's `IN` operator
14
+ * does NOT match `NULL` (NULL is not equal to anything, including itself
15
+ * inside an IN list), so the empty-string and NULL cases must run as
16
+ * separate queries and merge.
17
+ */
18
+ getRootCategories(): Promise<Category[]>;
19
+ }
20
+ //# sourceMappingURL=CategoryCollection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CategoryCollection.d.ts","sourceRoot":"","sources":["../../../../src/lib/collections/CategoryCollection.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C,qBAAa,kBAAmB,SAAQ,cAAc,CAAC,QAAQ,CAAC;IAC9D,MAAM,CAAC,QAAQ,CAAC,UAAU,kBAAY;IAEtC;;;;;;;;;;;;OAYG;IACG,iBAAiB,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;CAoB/C"}
@@ -0,0 +1,20 @@
1
+ import { Material } from '../models/Material';
2
+ import { MaterialKind } from '../models/types';
3
+ import { ProductCollection } from './ProductCollection';
4
+ export declare class MaterialCollection extends ProductCollection {
5
+ static readonly _itemClass: typeof Material;
6
+ /**
7
+ * Find every {@link Material} with the given kind.
8
+ *
9
+ * `materialKind` is an `@meta()` field — it lives inside the shared
10
+ * `_meta_data` JSON column on `products`, not as its own SQL column.
11
+ * That means a naive `list({ where: { materialKind } })` would generate
12
+ * a WHERE on a non-existent column. We list every Material STI row and
13
+ * filter the hydrated instances in JS.
14
+ *
15
+ * For very large catalogs, consumers should add a generated column or
16
+ * an expression index over the JSON path and override this helper.
17
+ */
18
+ findByKind(materialKind: MaterialKind): Promise<Material[]>;
19
+ }
20
+ //# sourceMappingURL=MaterialCollection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MaterialCollection.d.ts","sourceRoot":"","sources":["../../../../src/lib/collections/MaterialCollection.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAExD,qBAAa,kBAAmB,SAAQ,iBAAiB;IACvD,gBAAyB,UAAU,kBAAY;IAE/C;;;;;;;;;;;OAWG;IACG,UAAU,CAAC,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;CAIlE"}
@@ -0,0 +1,16 @@
1
+ import { Asset } from '@happyvertical/smrt-assets';
2
+ import { SmrtCollectionOptions, SmrtJunction } from '@happyvertical/smrt-core';
3
+ import { ProductAsset } from '../models/ProductAsset';
4
+ export interface ProductAssetCollectionOptions extends SmrtCollectionOptions {
5
+ }
6
+ export declare class ProductAssetCollection extends SmrtJunction<ProductAsset> {
7
+ static readonly _itemClass: typeof ProductAsset;
8
+ protected leftField: string;
9
+ protected rightField: string;
10
+ private productCollectionPromise;
11
+ private getProductCollection;
12
+ getAssets(productId: string, relationship?: string): Promise<Asset[]>;
13
+ addAsset(productId: string, asset: Asset, relationship?: string, sortOrder?: number): Promise<void>;
14
+ removeAsset(productId: string, assetId: string, relationship?: string): Promise<void>;
15
+ }
16
+ //# sourceMappingURL=ProductAssetCollection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProductAssetCollection.d.ts","sourceRoot":"","sources":["../../../../src/lib/collections/ProductAssetCollection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAMxD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AACtE,OAAO,EAAE,YAAY,EAAQ,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAGtD,MAAM,WAAW,6BAA8B,SAAQ,qBAAqB;CAAG;AAE/E,qBAKa,sBAAuB,SAAQ,YAAY,CAAC,YAAY,CAAC;IACpE,MAAM,CAAC,QAAQ,CAAC,UAAU,sBAAgB;IAC1C,SAAS,CAAC,SAAS,SAAe;IAClC,SAAS,CAAC,UAAU,SAAa;IAEjC,OAAO,CAAC,wBAAwB,CAA2C;YAE7D,oBAAoB;IAS5B,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;IAQrE,QAAQ,CACZ,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,KAAK,EACZ,YAAY,SAAe,EAC3B,SAAS,SAAI,GACZ,OAAO,CAAC,IAAI,CAAC;IAWV,WAAW,CACf,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC,IAAI,CAAC;CASjB"}
@@ -0,0 +1,12 @@
1
+ import { Asset } from '@happyvertical/smrt-assets';
2
+ import { SmrtCollection } from '@happyvertical/smrt-core';
3
+ import { Product } from '../models/Product';
4
+ export declare class ProductCollection extends SmrtCollection<Product> {
5
+ static readonly _itemClass: typeof Product;
6
+ findByManufacturer(manufacturer: string): Promise<Product[]>;
7
+ findInStock(): Promise<Product[]>;
8
+ getAssets(productId: string, relationship?: string): Promise<Asset[]>;
9
+ addAsset(productId: string, asset: Asset, relationship?: string, sortOrder?: number): Promise<void>;
10
+ removeAsset(productId: string, assetId: string, relationship?: string): Promise<void>;
11
+ }
12
+ //# sourceMappingURL=ProductCollection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProductCollection.d.ts","sourceRoot":"","sources":["../../../../src/lib/collections/ProductCollection.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AAMxD,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAE5C,qBAAa,iBAAkB,SAAQ,cAAc,CAAC,OAAO,CAAC;IAC5D,MAAM,CAAC,QAAQ,CAAC,UAAU,iBAAW;IAE/B,kBAAkB,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAI5D,WAAW,IAAI,OAAO,CAAC,OAAO,EAAE,CAAC;IAIjC,SAAS,CAAC,SAAS,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,EAAE,CAAC;IAIrE,QAAQ,CACZ,SAAS,EAAE,MAAM,EACjB,KAAK,EAAE,KAAK,EACZ,YAAY,SAAe,EAC3B,SAAS,SAAI,GACZ,OAAO,CAAC,IAAI,CAAC;IAWV,WAAW,CACf,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,MAAM,EACf,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC,IAAI,CAAC;CASjB"}
@@ -0,0 +1,10 @@
1
+ import { SmrtCollection } from '@happyvertical/smrt-core';
2
+ import { ProductVariant } from '../models/ProductVariant';
3
+ export declare class ProductVariantCollection extends SmrtCollection<ProductVariant> {
4
+ static readonly _itemClass: typeof ProductVariant;
5
+ /** Every axis declaration for a given product, in display order. */
6
+ findForProduct(productId: string): Promise<ProductVariant[]>;
7
+ /** The axis declaration for a `(productId, axisName)` pair, or null. */
8
+ findAxis(productId: string, axisName: string): Promise<ProductVariant | null>;
9
+ }
10
+ //# sourceMappingURL=ProductVariantCollection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProductVariantCollection.d.ts","sourceRoot":"","sources":["../../../../src/lib/collections/ProductVariantCollection.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAE1D,qBAAa,wBAAyB,SAAQ,cAAc,CAAC,cAAc,CAAC;IAC1E,MAAM,CAAC,QAAQ,CAAC,UAAU,wBAAkB;IAE5C,oEAAoE;IAC9D,cAAc,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAOlE,wEAAwE;IAClE,QAAQ,CACZ,SAAS,EAAE,MAAM,EACjB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;CAOlC"}
@@ -0,0 +1,31 @@
1
+ import { SmrtCollection } from '@happyvertical/smrt-core';
2
+ import { Sku } from '../models/Sku';
3
+ export declare class SkuCollection extends SmrtCollection<Sku> {
4
+ static readonly _itemClass: typeof Sku;
5
+ /**
6
+ * Look up a SKU by its tenant-scoped `code` (UPC, internal part
7
+ * number, etc.). Returns `null` when no row matches.
8
+ */
9
+ findByCode(code: string): Promise<Sku | null>;
10
+ /**
11
+ * Look up a SKU by its scannable barcode. Returns `null` when no row
12
+ * matches; pass `''` to skip the query early.
13
+ */
14
+ findByBarcode(barcode: string): Promise<Sku | null>;
15
+ /**
16
+ * Find every SKU pointing at the given `Product` id (or any Product
17
+ * STI subtype id — `Material` upstream, vertical subtypes defined in
18
+ * templates). Useful for listing the SKUs that back a single product
19
+ * card.
20
+ */
21
+ findByProduct(productId: string): Promise<Sku[]>;
22
+ /**
23
+ * Find every SKU that is a component of the given parent SKU (for
24
+ * bundles / kits). Returns an empty array when the parent has no
25
+ * children.
26
+ */
27
+ findByParent(parentSkuId: string): Promise<Sku[]>;
28
+ /** Find every active SKU, optionally narrowed by parent product id. */
29
+ findActive(productId?: string): Promise<Sku[]>;
30
+ }
31
+ //# sourceMappingURL=SkuCollection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SkuCollection.d.ts","sourceRoot":"","sources":["../../../../src/lib/collections/SkuCollection.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,GAAG,EAAE,MAAM,eAAe,CAAC;AAEpC,qBAAa,aAAc,SAAQ,cAAc,CAAC,GAAG,CAAC;IACpD,MAAM,CAAC,QAAQ,CAAC,UAAU,aAAO;IAEjC;;;OAGG;IACG,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,GAAG,IAAI,CAAC;IAKnD;;;OAGG;IACG,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,GAAG,IAAI,CAAC;IAMzD;;;;;OAKG;IACG,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAItD;;;;OAIG;IACG,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAIvD,uEAAuE;IACjE,UAAU,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;CAKrD"}
@@ -0,0 +1,7 @@
1
+ export { CategoryCollection } from './CategoryCollection';
2
+ export { MaterialCollection } from './MaterialCollection';
3
+ export { ProductAssetCollection } from './ProductAssetCollection';
4
+ export { ProductCollection } from './ProductCollection';
5
+ export { ProductVariantCollection } from './ProductVariantCollection';
6
+ export { SkuCollection } from './SkuCollection';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/lib/collections/index.ts"],"names":[],"mappings":"AAEA,OAAO,4BAA4B,CAAC;AAEpC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AACxD,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,173 @@
1
+ <script lang="ts">
2
+ import type { ProductData } from '../types';
3
+
4
+ interface Props {
5
+ product: ProductData;
6
+ onEdit?: (product: ProductData) => void;
7
+ onDelete?: (id: string) => void;
8
+ }
9
+
10
+ const { product, onEdit, onDelete }: Props = $props();
11
+ </script>
12
+
13
+ <div class="product-card">
14
+ <div class="product-header">
15
+ <h3 class="product-name">{product.name}</h3>
16
+ {#if product.manufacturer}
17
+ <div class="product-manufacturer">{product.manufacturer}</div>
18
+ {/if}
19
+ </div>
20
+
21
+ {#if product.model}
22
+ <div class="product-model">Model: {product.model}</div>
23
+ {/if}
24
+
25
+ {#if product.description}
26
+ <p class="product-description">{product.description}</p>
27
+ {/if}
28
+
29
+ <div class="product-meta">
30
+ {#if product.category}
31
+ <div class="product-category">Category: {product.category}</div>
32
+ {/if}
33
+
34
+ {#if product.tags && product.tags.length > 0}
35
+ <div class="product-tags">
36
+ {#each product.tags as tag}
37
+ <span class="tag">{tag}</span>
38
+ {/each}
39
+ </div>
40
+ {/if}
41
+ </div>
42
+
43
+ <div class="product-actions">
44
+ {#if onEdit}
45
+ <button type="button" onclick={() => onEdit?.(product)} class="edit-btn">
46
+ Edit
47
+ </button>
48
+ {/if}
49
+
50
+ {#if onDelete}
51
+ <button type="button" onclick={() => onDelete?.(product.id)} class="delete-btn">
52
+ Delete
53
+ </button>
54
+ {/if}
55
+ </div>
56
+ </div>
57
+
58
+ <style>
59
+ .product-card {
60
+ border: 1px solid var(--smrt-color-outline-variant, #e2e8f0);
61
+ border-radius: var(--smrt-radius-md, 8px);
62
+ padding: 1rem;
63
+ background: white;
64
+ box-shadow: var(--smrt-elevation-1, 0 1px 3px color-mix(in srgb, var(--smrt-color-shadow, #000) 10%, transparent));
65
+ transition: box-shadow 0.2s;
66
+ }
67
+
68
+ .product-card:hover {
69
+ box-shadow: var(--smrt-elevation-2, 0 4px 6px color-mix(in srgb, var(--smrt-color-shadow, #000) 10%, transparent));
70
+ }
71
+
72
+ .product-header {
73
+ display: flex;
74
+ justify-content: space-between;
75
+ align-items: flex-start;
76
+ margin-bottom: 0.5rem;
77
+ }
78
+
79
+ .product-name {
80
+ margin: 0;
81
+ font-size: var(--smrt-typography-title-medium-size, 1.125rem);
82
+ font-weight: var(--smrt-typography-weight-semibold, 600);
83
+ color: var(--smrt-color-on-surface, #1f2937);
84
+ }
85
+
86
+ .product-manufacturer {
87
+ font-size: var(--smrt-typography-title-small-size, 0.875rem);
88
+ font-weight: var(--smrt-typography-weight-medium, 500);
89
+ color: var(--smrt-color-on-surface-variant, #6b7280);
90
+ }
91
+
92
+ .product-model {
93
+ font-size: var(--smrt-typography-body-medium-size, 0.875rem);
94
+ color: var(--smrt-color-on-surface-variant, #6b7280);
95
+ margin-bottom: 0.5rem;
96
+ }
97
+
98
+ .product-category {
99
+ font-size: var(--smrt-typography-label-medium-size, 0.75rem);
100
+ font-weight: var(--smrt-typography-weight-medium, 500);
101
+ color: var(--smrt-color-on-surface, #374151);
102
+ background: var(--smrt-color-surface-container, #f3f4f6);
103
+ padding: 0.25rem 0.5rem;
104
+ border-radius: var(--smrt-radius-sm, 4px);
105
+ display: inline-block;
106
+ margin-bottom: 0.5rem;
107
+ }
108
+
109
+ .product-description {
110
+ margin: 0.5rem 0;
111
+ color: var(--smrt-color-on-surface-variant, #6b7280);
112
+ font-size: var(--smrt-typography-body-medium-size, 0.875rem);
113
+ line-height: var(--smrt-typography-body-medium-line-height, 1.4);
114
+ }
115
+
116
+ .product-meta {
117
+ margin: 0.75rem 0;
118
+ }
119
+
120
+
121
+ .product-tags {
122
+ margin-top: 0.5rem;
123
+ display: flex;
124
+ flex-wrap: wrap;
125
+ gap: 0.25rem;
126
+ }
127
+
128
+ .tag {
129
+ background: var(--smrt-color-surface-container, #f3f4f6);
130
+ color: var(--smrt-color-on-surface, #374151);
131
+ padding: 0.125rem 0.5rem;
132
+ border-radius: var(--smrt-radius-full, 9999px);
133
+ font-size: var(--smrt-typography-label-medium-size, 0.75rem);
134
+ }
135
+
136
+ .product-actions {
137
+ display: flex;
138
+ gap: 0.5rem;
139
+ margin-top: 1rem;
140
+ padding-top: 0.75rem;
141
+ border-top: 1px solid var(--smrt-color-outline-variant, #f3f4f6);
142
+ }
143
+
144
+ .edit-btn, .delete-btn {
145
+ padding: 0.375rem 0.75rem;
146
+ border-radius: var(--smrt-radius-sm, 4px);
147
+ font-size: var(--smrt-typography-label-large-size, 0.875rem);
148
+ font-weight: var(--smrt-typography-weight-medium, 500);
149
+ border: 1px solid;
150
+ cursor: pointer;
151
+ transition: all 0.2s;
152
+ }
153
+
154
+ .edit-btn {
155
+ background: var(--smrt-color-surface-container-low, #f9fafb);
156
+ border-color: var(--smrt-color-outline-variant, #d1d5db);
157
+ color: var(--smrt-color-on-surface, #374151);
158
+ }
159
+
160
+ .edit-btn:hover {
161
+ background: var(--smrt-color-surface-container, #f3f4f6);
162
+ }
163
+
164
+ .delete-btn {
165
+ background: var(--smrt-color-error-container, #fef2f2);
166
+ border-color: var(--smrt-color-error, #fecaca);
167
+ color: var(--smrt-color-error, #dc2626);
168
+ }
169
+
170
+ .delete-btn:hover {
171
+ background: var(--smrt-color-error-container, #fee2e2);
172
+ }
173
+ </style>
@@ -0,0 +1,10 @@
1
+ import type { ProductData } from '../types';
2
+ interface Props {
3
+ product: ProductData;
4
+ onEdit?: (product: ProductData) => void;
5
+ onDelete?: (id: string) => void;
6
+ }
7
+ declare const ProductCard: import("svelte").Component<Props, {}, "">;
8
+ type ProductCard = ReturnType<typeof ProductCard>;
9
+ export default ProductCard;
10
+ //# sourceMappingURL=ProductCard.svelte.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ProductCard.svelte.d.ts","sourceRoot":"","sources":["../../../../src/lib/components/ProductCard.svelte"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAG5C,UAAU,KAAK;IACb,OAAO,EAAE,WAAW,CAAC;IACrB,MAAM,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,KAAK,IAAI,CAAC;IACxC,QAAQ,CAAC,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,IAAI,CAAC;CACjC;AAwDD,QAAA,MAAM,WAAW,2CAAwC,CAAC;AAC1D,KAAK,WAAW,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC;AAClD,eAAe,WAAW,CAAC"}