nitrostack 1.0.55 โ†’ 1.0.56

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 (222) hide show
  1. package/dist/cli/commands/init.d.ts.map +1 -1
  2. package/dist/cli/commands/init.js +14 -9
  3. package/dist/cli/commands/init.js.map +1 -1
  4. package/dist/widgets/hooks/index.d.ts +7 -0
  5. package/dist/widgets/hooks/index.d.ts.map +1 -0
  6. package/dist/widgets/hooks/index.js +7 -0
  7. package/dist/widgets/hooks/index.js.map +1 -0
  8. package/dist/widgets/hooks/use-display-mode.d.ts +11 -0
  9. package/dist/widgets/hooks/use-display-mode.d.ts.map +1 -0
  10. package/dist/widgets/hooks/use-display-mode.js +13 -0
  11. package/dist/widgets/hooks/use-display-mode.js.map +1 -0
  12. package/dist/widgets/hooks/use-max-height.d.ts +10 -0
  13. package/dist/widgets/hooks/use-max-height.d.ts.map +1 -0
  14. package/dist/widgets/hooks/use-max-height.js +13 -0
  15. package/dist/widgets/hooks/use-max-height.js.map +1 -0
  16. package/dist/widgets/hooks/use-openai-global.d.ts +12 -0
  17. package/dist/widgets/hooks/use-openai-global.d.ts.map +1 -0
  18. package/dist/widgets/hooks/use-openai-global.js +32 -0
  19. package/dist/widgets/hooks/use-openai-global.js.map +1 -0
  20. package/dist/widgets/hooks/use-theme.d.ts +10 -0
  21. package/dist/widgets/hooks/use-theme.d.ts.map +1 -0
  22. package/dist/widgets/hooks/use-theme.js +12 -0
  23. package/dist/widgets/hooks/use-theme.js.map +1 -0
  24. package/dist/widgets/hooks/use-widget-state.d.ts +18 -0
  25. package/dist/widgets/hooks/use-widget-state.d.ts.map +1 -0
  26. package/dist/widgets/hooks/use-widget-state.js +27 -0
  27. package/dist/widgets/hooks/use-widget-state.js.map +1 -0
  28. package/dist/widgets/hooks/useWidgetSDK.d.ts +47 -0
  29. package/dist/widgets/hooks/useWidgetSDK.d.ts.map +1 -0
  30. package/dist/widgets/hooks/useWidgetSDK.js +67 -0
  31. package/dist/widgets/hooks/useWidgetSDK.js.map +1 -0
  32. package/dist/widgets/index.d.ts +7 -1
  33. package/dist/widgets/index.d.ts.map +1 -1
  34. package/dist/widgets/index.js +11 -1
  35. package/dist/widgets/index.js.map +1 -1
  36. package/dist/widgets/runtime/WidgetLayout.d.ts +32 -0
  37. package/dist/widgets/runtime/WidgetLayout.d.ts.map +1 -0
  38. package/dist/widgets/runtime/WidgetLayout.js +143 -0
  39. package/dist/widgets/runtime/WidgetLayout.js.map +1 -0
  40. package/dist/widgets/runtime/widget-polyfill.d.ts +1 -0
  41. package/dist/widgets/runtime/widget-polyfill.d.ts.map +1 -0
  42. package/dist/widgets/runtime/widget-polyfill.js +28 -0
  43. package/dist/widgets/runtime/widget-polyfill.js.map +1 -0
  44. package/dist/widgets/sdk.d.ts +109 -0
  45. package/dist/widgets/sdk.d.ts.map +1 -0
  46. package/dist/widgets/sdk.js +221 -0
  47. package/dist/widgets/sdk.js.map +1 -0
  48. package/dist/widgets/types.d.ts +89 -0
  49. package/dist/widgets/types.d.ts.map +1 -0
  50. package/dist/widgets/types.js +8 -0
  51. package/dist/widgets/types.js.map +1 -0
  52. package/dist/widgets/utils/media-queries.d.ts +34 -0
  53. package/dist/widgets/utils/media-queries.d.ts.map +1 -0
  54. package/dist/widgets/utils/media-queries.js +42 -0
  55. package/dist/widgets/utils/media-queries.js.map +1 -0
  56. package/package.json +1 -1
  57. package/src/studio/app/chat/page.tsx +274 -137
  58. package/src/studio/app/globals.css +140 -64
  59. package/src/studio/branding.md +807 -0
  60. package/src/studio/components/WidgetRenderer.tsx +222 -16
  61. package/src/studio/lib/llm-service.ts +39 -39
  62. package/templates/typescript-oauth/{env.example โ†’ .env.example} +4 -10
  63. package/templates/typescript-oauth/README.md +226 -306
  64. package/templates/typescript-oauth/package-lock.json +4253 -0
  65. package/templates/typescript-oauth/package.json +10 -5
  66. package/templates/typescript-oauth/src/app.module.ts +39 -36
  67. package/templates/typescript-oauth/src/guards/oauth.guard.ts +0 -1
  68. package/templates/typescript-oauth/src/index.ts +22 -30
  69. package/templates/typescript-oauth/src/modules/flights/booking.tools.ts +323 -0
  70. package/templates/typescript-oauth/src/modules/flights/flights.module.ts +14 -0
  71. package/templates/typescript-oauth/src/modules/flights/flights.prompts.ts +231 -0
  72. package/templates/typescript-oauth/src/modules/flights/flights.resources.ts +215 -0
  73. package/templates/typescript-oauth/src/modules/flights/flights.tools.ts +457 -0
  74. package/templates/typescript-oauth/src/services/duffel.service.ts +285 -0
  75. package/templates/typescript-oauth/src/widgets/app/airport-search/page.tsx +270 -0
  76. package/templates/typescript-oauth/src/widgets/app/flight-details/page.tsx +261 -0
  77. package/templates/typescript-oauth/src/widgets/app/flight-search-results/page.tsx +378 -0
  78. package/templates/typescript-oauth/src/widgets/app/globals.css +167 -0
  79. package/templates/typescript-oauth/src/widgets/app/layout.tsx +6 -2
  80. package/templates/typescript-oauth/src/widgets/app/order-cancellation/page.tsx +207 -0
  81. package/templates/typescript-oauth/src/widgets/app/order-summary/page.tsx +245 -0
  82. package/templates/typescript-oauth/src/widgets/app/payment-confirmation/page.tsx +152 -0
  83. package/templates/typescript-oauth/src/widgets/app/seat-selection/page.tsx +486 -0
  84. package/templates/typescript-oauth/src/widgets/next-env.d.ts +5 -0
  85. package/templates/typescript-oauth/src/widgets/package-lock.json +155 -126
  86. package/templates/typescript-oauth/src/widgets/widget-manifest.json +374 -27
  87. package/templates/typescript-pizzaz/IMPLEMENTATION.md +98 -0
  88. package/templates/typescript-pizzaz/README.md +233 -0
  89. package/templates/typescript-pizzaz/package.json +31 -0
  90. package/templates/typescript-pizzaz/src/app.module.ts +28 -0
  91. package/templates/typescript-pizzaz/src/index.ts +30 -0
  92. package/templates/typescript-pizzaz/src/modules/pizzaz/pizzaz.data.ts +106 -0
  93. package/templates/typescript-pizzaz/src/modules/pizzaz/pizzaz.module.ts +11 -0
  94. package/templates/typescript-pizzaz/src/modules/pizzaz/pizzaz.service.ts +60 -0
  95. package/templates/typescript-pizzaz/src/modules/pizzaz/pizzaz.tools.ts +197 -0
  96. package/templates/typescript-pizzaz/src/widgets/app/layout.tsx +18 -0
  97. package/templates/typescript-pizzaz/src/widgets/app/pizza-list/page.tsx +272 -0
  98. package/templates/typescript-pizzaz/src/widgets/app/pizza-map/page.tsx +216 -0
  99. package/templates/typescript-pizzaz/src/widgets/app/pizza-shop/page.tsx +374 -0
  100. package/templates/typescript-pizzaz/src/widgets/components/CompactShopCard.tsx +144 -0
  101. package/templates/typescript-pizzaz/src/widgets/components/PizzaCard.tsx +191 -0
  102. package/templates/typescript-pizzaz/src/widgets/package.json +30 -0
  103. package/templates/typescript-pizzaz/src/widgets/widget-manifest.json +253 -0
  104. package/templates/typescript-pizzaz/tsconfig.json +30 -0
  105. package/templates/typescript-starter/src/modules/calculator/calculator.resources.ts +0 -1
  106. package/templates/typescript-starter/src/widgets/app/calculator-result/page.tsx +102 -56
  107. package/templates/typescript-starter/src/widgets/app/layout.tsx +6 -2
  108. package/templates/typescript-auth/AI_AGENT_CLI_REFERENCE.md +0 -702
  109. package/templates/typescript-auth/AI_AGENT_SDK_REFERENCE.md +0 -1260
  110. package/templates/typescript-auth/README.md +0 -402
  111. package/templates/typescript-auth/env.example +0 -25
  112. package/templates/typescript-auth/package.json +0 -36
  113. package/templates/typescript-auth/src/app.module.ts +0 -103
  114. package/templates/typescript-auth/src/db/database.ts +0 -160
  115. package/templates/typescript-auth/src/db/seed.ts +0 -374
  116. package/templates/typescript-auth/src/db/setup.ts +0 -87
  117. package/templates/typescript-auth/src/events/analytics.service.ts +0 -52
  118. package/templates/typescript-auth/src/events/notification.service.ts +0 -40
  119. package/templates/typescript-auth/src/filters/global-exception.filter.ts +0 -28
  120. package/templates/typescript-auth/src/guards/README.md +0 -75
  121. package/templates/typescript-auth/src/guards/jwt.guard.ts +0 -105
  122. package/templates/typescript-auth/src/health/database.health.ts +0 -41
  123. package/templates/typescript-auth/src/index.ts +0 -29
  124. package/templates/typescript-auth/src/interceptors/transform.interceptor.ts +0 -24
  125. package/templates/typescript-auth/src/middleware/logging.middleware.ts +0 -42
  126. package/templates/typescript-auth/src/modules/addresses/addresses.module.ts +0 -16
  127. package/templates/typescript-auth/src/modules/addresses/addresses.prompts.ts +0 -114
  128. package/templates/typescript-auth/src/modules/addresses/addresses.resources.ts +0 -40
  129. package/templates/typescript-auth/src/modules/addresses/addresses.tools.ts +0 -284
  130. package/templates/typescript-auth/src/modules/auth/auth.module.ts +0 -16
  131. package/templates/typescript-auth/src/modules/auth/auth.prompts.ts +0 -147
  132. package/templates/typescript-auth/src/modules/auth/auth.resources.ts +0 -84
  133. package/templates/typescript-auth/src/modules/auth/auth.tools.ts +0 -139
  134. package/templates/typescript-auth/src/modules/cart/cart.module.ts +0 -16
  135. package/templates/typescript-auth/src/modules/cart/cart.prompts.ts +0 -95
  136. package/templates/typescript-auth/src/modules/cart/cart.resources.ts +0 -44
  137. package/templates/typescript-auth/src/modules/cart/cart.tools.ts +0 -277
  138. package/templates/typescript-auth/src/modules/orders/orders.module.ts +0 -16
  139. package/templates/typescript-auth/src/modules/orders/orders.prompts.ts +0 -88
  140. package/templates/typescript-auth/src/modules/orders/orders.resources.ts +0 -48
  141. package/templates/typescript-auth/src/modules/orders/orders.tools.ts +0 -303
  142. package/templates/typescript-auth/src/modules/products/products.module.ts +0 -16
  143. package/templates/typescript-auth/src/modules/products/products.prompts.ts +0 -146
  144. package/templates/typescript-auth/src/modules/products/products.resources.ts +0 -98
  145. package/templates/typescript-auth/src/modules/products/products.tools.ts +0 -266
  146. package/templates/typescript-auth/src/pipes/validation.pipe.ts +0 -42
  147. package/templates/typescript-auth/src/services/database.service.ts +0 -90
  148. package/templates/typescript-auth/src/widgets/app/add-to-cart/page.tsx +0 -122
  149. package/templates/typescript-auth/src/widgets/app/address-added/page.tsx +0 -116
  150. package/templates/typescript-auth/src/widgets/app/address-deleted/page.tsx +0 -105
  151. package/templates/typescript-auth/src/widgets/app/address-list/page.tsx +0 -139
  152. package/templates/typescript-auth/src/widgets/app/address-updated/page.tsx +0 -153
  153. package/templates/typescript-auth/src/widgets/app/cart-cleared/page.tsx +0 -86
  154. package/templates/typescript-auth/src/widgets/app/cart-updated/page.tsx +0 -116
  155. package/templates/typescript-auth/src/widgets/app/categories/page.tsx +0 -134
  156. package/templates/typescript-auth/src/widgets/app/layout.tsx +0 -21
  157. package/templates/typescript-auth/src/widgets/app/login-result/page.tsx +0 -129
  158. package/templates/typescript-auth/src/widgets/app/order-confirmation/page.tsx +0 -231
  159. package/templates/typescript-auth/src/widgets/app/order-details/page.tsx +0 -225
  160. package/templates/typescript-auth/src/widgets/app/order-history/page.tsx +0 -218
  161. package/templates/typescript-auth/src/widgets/app/product-card/page.tsx +0 -121
  162. package/templates/typescript-auth/src/widgets/app/products-grid/page.tsx +0 -198
  163. package/templates/typescript-auth/src/widgets/app/shopping-cart/page.tsx +0 -187
  164. package/templates/typescript-auth/src/widgets/app/whoami/page.tsx +0 -165
  165. package/templates/typescript-auth/src/widgets/next.config.js +0 -38
  166. package/templates/typescript-auth/src/widgets/package.json +0 -18
  167. package/templates/typescript-auth/src/widgets/styles/ecommerce.ts +0 -169
  168. package/templates/typescript-auth/src/widgets/tsconfig.json +0 -28
  169. package/templates/typescript-auth/src/widgets/types/tool-data.ts +0 -141
  170. package/templates/typescript-auth/src/widgets/widget-manifest.json +0 -464
  171. package/templates/typescript-auth/tsconfig.json +0 -27
  172. package/templates/typescript-auth-api-key/AI_AGENT_CLI_REFERENCE.md +0 -701
  173. package/templates/typescript-auth-api-key/AI_AGENT_SDK_REFERENCE.md +0 -1260
  174. package/templates/typescript-auth-api-key/README.md +0 -485
  175. package/templates/typescript-auth-api-key/env.example +0 -17
  176. package/templates/typescript-auth-api-key/package.json +0 -21
  177. package/templates/typescript-auth-api-key/src/app.module.ts +0 -38
  178. package/templates/typescript-auth-api-key/src/guards/apikey.guard.ts +0 -47
  179. package/templates/typescript-auth-api-key/src/guards/multi-auth.guard.ts +0 -157
  180. package/templates/typescript-auth-api-key/src/index.ts +0 -47
  181. package/templates/typescript-auth-api-key/src/modules/calculator/calculator.module.ts +0 -12
  182. package/templates/typescript-auth-api-key/src/modules/calculator/calculator.prompts.ts +0 -73
  183. package/templates/typescript-auth-api-key/src/modules/calculator/calculator.resources.ts +0 -60
  184. package/templates/typescript-auth-api-key/src/modules/calculator/calculator.tools.ts +0 -71
  185. package/templates/typescript-auth-api-key/src/modules/demo/demo.module.ts +0 -18
  186. package/templates/typescript-auth-api-key/src/modules/demo/demo.tools.ts +0 -155
  187. package/templates/typescript-auth-api-key/src/modules/demo/multi-auth.tools.ts +0 -123
  188. package/templates/typescript-auth-api-key/src/widgets/app/calculator-operations/page.tsx +0 -133
  189. package/templates/typescript-auth-api-key/src/widgets/app/calculator-result/page.tsx +0 -134
  190. package/templates/typescript-auth-api-key/src/widgets/app/layout.tsx +0 -14
  191. package/templates/typescript-auth-api-key/src/widgets/package.json +0 -24
  192. package/templates/typescript-auth-api-key/src/widgets/widget-manifest.json +0 -48
  193. package/templates/typescript-auth-api-key/tsconfig.json +0 -23
  194. package/templates/typescript-oauth/OAUTH_SETUP.md +0 -592
  195. package/templates/typescript-oauth/src/modules/demo/demo.module.ts +0 -16
  196. package/templates/typescript-oauth/src/modules/demo/demo.tools.ts +0 -190
  197. package/templates/typescript-oauth/src/widgets/app/calculator-operations/page.tsx +0 -133
  198. package/templates/typescript-oauth/src/widgets/app/calculator-result/page.tsx +0 -134
  199. package/templates/typescript-oauth/src/widgets/out/404.html +0 -1
  200. package/templates/typescript-oauth/src/widgets/out/_next/static/WU9THacVqL52RZbrZOLS1/_buildManifest.js +0 -1
  201. package/templates/typescript-oauth/src/widgets/out/_next/static/WU9THacVqL52RZbrZOLS1/_ssgManifest.js +0 -1
  202. package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/117-eb57c7ef86f964a4.js +0 -2
  203. package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/app/_not-found/page-dcb83ba3e4d0aafd.js +0 -1
  204. package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/app/calculator-operations/page-b8913a740073ea8a.js +0 -1
  205. package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/app/calculator-result/page-ddaaab2fce95dea2.js +0 -1
  206. package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/app/layout-cbd3ebdc4ecc5247.js +0 -1
  207. package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/fd9d1056-749e5812300142af.js +0 -1
  208. package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/framework-f66176bb897dc684.js +0 -1
  209. package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/main-76df43fcef3db344.js +0 -1
  210. package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/main-app-f9c40224d04023c5.js +0 -1
  211. package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/pages/_app-72b849fbd24ac258.js +0 -1
  212. package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/pages/_error-7ba65e1336b92748.js +0 -1
  213. package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/polyfills-42372ed130431b0a.js +0 -1
  214. package/templates/typescript-oauth/src/widgets/out/_next/static/chunks/webpack-100b9e646d9c912e.js +0 -1
  215. package/templates/typescript-oauth/src/widgets/out/calculator-operations.html +0 -1
  216. package/templates/typescript-oauth/src/widgets/out/calculator-operations.txt +0 -7
  217. package/templates/typescript-oauth/src/widgets/out/calculator-result.html +0 -1
  218. package/templates/typescript-oauth/src/widgets/out/calculator-result.txt +0 -7
  219. package/templates/typescript-starter/src/widgets/app/calculator-operations/page.tsx +0 -133
  220. /package/templates/{typescript-auth-api-key โ†’ typescript-oauth}/src/health/system.health.ts +0 -0
  221. /package/templates/{typescript-auth-api-key โ†’ typescript-pizzaz}/src/widgets/next.config.js +0 -0
  222. /package/templates/{typescript-auth-api-key โ†’ typescript-pizzaz}/src/widgets/tsconfig.json +0 -0
@@ -1,160 +0,0 @@
1
- import Database from 'better-sqlite3';
2
- import path from 'path';
3
- import fs from 'fs';
4
-
5
- /**
6
- * Database connection and utilities
7
- */
8
-
9
- let db: Database.Database | null = null;
10
-
11
- export function getDatabase(): Database.Database {
12
- if (!db) {
13
- const envPath = process.env.DATABASE_PATH || './data/ecommerce.db';
14
-
15
- // Resolve relative paths from the project root (process.cwd())
16
- // Absolute paths are used as-is
17
- const dbPath = path.isAbsolute(envPath)
18
- ? envPath
19
- : path.resolve(process.cwd(), envPath);
20
-
21
- const dbDir = path.dirname(dbPath);
22
-
23
- // Ensure data directory exists
24
- if (!fs.existsSync(dbDir)) {
25
- fs.mkdirSync(dbDir, { recursive: true });
26
- }
27
-
28
- db = new Database(dbPath);
29
- db.pragma('journal_mode = WAL');
30
- db.pragma('foreign_keys = ON');
31
- }
32
-
33
- return db;
34
- }
35
-
36
- export function closeDatabase(): void {
37
- if (db) {
38
- db.close();
39
- db = null;
40
- }
41
- }
42
-
43
- /**
44
- * Initialize database schema
45
- */
46
- export function initializeSchema(): void {
47
- const db = getDatabase();
48
-
49
- // Users table
50
- db.exec(`
51
- CREATE TABLE IF NOT EXISTS users (
52
- id TEXT PRIMARY KEY,
53
- email TEXT UNIQUE NOT NULL,
54
- password_hash TEXT NOT NULL,
55
- name TEXT NOT NULL,
56
- profile_picture TEXT,
57
- created_at DATETIME DEFAULT CURRENT_TIMESTAMP
58
- )
59
- `);
60
-
61
- // Products table
62
- db.exec(`
63
- CREATE TABLE IF NOT EXISTS products (
64
- id TEXT PRIMARY KEY,
65
- name TEXT NOT NULL,
66
- description TEXT,
67
- price REAL NOT NULL,
68
- category TEXT NOT NULL,
69
- stock INTEGER NOT NULL DEFAULT 0,
70
- image_url TEXT,
71
- created_at DATETIME DEFAULT CURRENT_TIMESTAMP
72
- )
73
- `);
74
-
75
- // Addresses table
76
- db.exec(`
77
- CREATE TABLE IF NOT EXISTS addresses (
78
- id TEXT PRIMARY KEY,
79
- user_id TEXT NOT NULL,
80
- full_name TEXT NOT NULL,
81
- street TEXT NOT NULL,
82
- city TEXT NOT NULL,
83
- state TEXT NOT NULL,
84
- zip_code TEXT NOT NULL,
85
- country TEXT NOT NULL DEFAULT 'USA',
86
- phone TEXT NOT NULL,
87
- is_default INTEGER DEFAULT 0,
88
- created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
89
- FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
90
- )
91
- `);
92
-
93
- // Carts table
94
- db.exec(`
95
- CREATE TABLE IF NOT EXISTS carts (
96
- id TEXT PRIMARY KEY,
97
- user_id TEXT NOT NULL,
98
- product_id TEXT NOT NULL,
99
- quantity INTEGER NOT NULL DEFAULT 1,
100
- added_at DATETIME DEFAULT CURRENT_TIMESTAMP,
101
- FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
102
- FOREIGN KEY (product_id) REFERENCES products(id) ON DELETE CASCADE,
103
- UNIQUE(user_id, product_id)
104
- )
105
- `);
106
-
107
- // Orders table
108
- db.exec(`
109
- CREATE TABLE IF NOT EXISTS orders (
110
- id TEXT PRIMARY KEY,
111
- user_id TEXT NOT NULL,
112
- shipping_address_id TEXT NOT NULL,
113
- total REAL NOT NULL,
114
- status TEXT NOT NULL DEFAULT 'pending',
115
- payment_method TEXT NOT NULL DEFAULT 'credit_card',
116
- created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
117
- FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
118
- FOREIGN KEY (shipping_address_id) REFERENCES addresses(id)
119
- )
120
- `);
121
-
122
- // Order items table
123
- db.exec(`
124
- CREATE TABLE IF NOT EXISTS order_items (
125
- id TEXT PRIMARY KEY,
126
- order_id TEXT NOT NULL,
127
- product_id TEXT NOT NULL,
128
- quantity INTEGER NOT NULL,
129
- price REAL NOT NULL,
130
- FOREIGN KEY (order_id) REFERENCES orders(id) ON DELETE CASCADE,
131
- FOREIGN KEY (product_id) REFERENCES products(id)
132
- )
133
- `);
134
-
135
- // Create indexes
136
- db.exec(`
137
- CREATE INDEX IF NOT EXISTS idx_carts_user_id ON carts(user_id);
138
- CREATE INDEX IF NOT EXISTS idx_orders_user_id ON orders(user_id);
139
- CREATE INDEX IF NOT EXISTS idx_order_items_order_id ON order_items(order_id);
140
- CREATE INDEX IF NOT EXISTS idx_addresses_user_id ON addresses(user_id);
141
- `);
142
- }
143
-
144
- /**
145
- * Clear all data (for testing)
146
- */
147
- export function clearAllData(): void {
148
- const db = getDatabase();
149
-
150
- db.exec(`
151
- DELETE FROM order_items;
152
- DELETE FROM orders;
153
- DELETE FROM carts;
154
- DELETE FROM addresses;
155
- DELETE FROM products;
156
- DELETE FROM users;
157
- `);
158
- }
159
-
160
-
@@ -1,374 +0,0 @@
1
- import { v4 as uuidv4 } from 'uuid';
2
- import bcrypt from 'bcryptjs';
3
- import { getDatabase } from './database.js';
4
-
5
- /**
6
- * Seed database with initial data
7
- */
8
-
9
- export function seedUsers(): void {
10
- const db = getDatabase();
11
-
12
- // Data from https://dummyjson.com/users
13
- const users = [
14
- {
15
- id: 'user-emily',
16
- email: 'emily.johnson@x.dummyjson.com',
17
- password: 'password123',
18
- name: 'Emily Johnson',
19
- profile_picture: 'https://dummyjson.com/icon/emilys/128',
20
- },
21
- {
22
- id: 'user-michael',
23
- email: 'michael.williams@x.dummyjson.com',
24
- password: 'password123',
25
- name: 'Michael Williams',
26
- profile_picture: 'https://dummyjson.com/icon/michaelw/128',
27
- },
28
- {
29
- id: 'user-sophia',
30
- email: 'sophia.brown@x.dummyjson.com',
31
- password: 'password123',
32
- name: 'Sophia Brown',
33
- profile_picture: 'https://dummyjson.com/icon/sophiab/128',
34
- },
35
- {
36
- id: 'user-james',
37
- email: 'james.davis@x.dummyjson.com',
38
- password: 'password123',
39
- name: 'James Davis',
40
- profile_picture: 'https://dummyjson.com/icon/jamesd/128',
41
- },
42
- {
43
- id: 'user-emma',
44
- email: 'emma.miller@x.dummyjson.com',
45
- password: 'password123',
46
- name: 'Emma Miller',
47
- profile_picture: 'https://dummyjson.com/icon/emmaj/128',
48
- },
49
- ];
50
-
51
- const stmt = db.prepare(`
52
- INSERT OR REPLACE INTO users (id, email, password_hash, name, profile_picture)
53
- VALUES (?, ?, ?, ?, ?)
54
- `);
55
-
56
- for (const user of users) {
57
- const passwordHash = bcrypt.hashSync(user.password, 10);
58
- stmt.run(user.id, user.email, passwordHash, user.name, user.profile_picture);
59
- }
60
-
61
- console.log(`โœ… Seeded ${users.length} users (from DummyJSON)`);
62
- }
63
-
64
- export function seedProducts(): void {
65
- const db = getDatabase();
66
-
67
- // Data from https://dummyjson.com/products
68
- const products = [
69
- // Beauty Products
70
- {
71
- id: 'prod-1',
72
- name: 'Essence Mascara Lash Princess',
73
- description: 'The Essence Mascara Lash Princess is a popular mascara known for its volumizing and lengthening effects.',
74
- price: 9.99,
75
- category: 'Beauty',
76
- stock: 99,
77
- image_url: 'https://cdn.dummyjson.com/product-images/beauty/essence-mascara-lash-princess/thumbnail.webp',
78
- },
79
- {
80
- id: 'prod-2',
81
- name: 'Eyeshadow Palette with Mirror',
82
- description: 'The Eyeshadow Palette offers a versatile range of eyeshadow shades for creating stunning eye looks.',
83
- price: 19.99,
84
- category: 'Beauty',
85
- stock: 34,
86
- image_url: 'https://cdn.dummyjson.com/product-images/beauty/eyeshadow-palette-with-mirror/thumbnail.webp',
87
- },
88
- {
89
- id: 'prod-3',
90
- name: 'Powder Canister',
91
- description: 'The Powder Canister is a finely milled setting powder designed to set makeup and control shine.',
92
- price: 14.99,
93
- category: 'Beauty',
94
- stock: 89,
95
- image_url: 'https://cdn.dummyjson.com/product-images/beauty/powder-canister/thumbnail.webp',
96
- },
97
- {
98
- id: 'prod-4',
99
- name: 'Red Lipstick',
100
- description: 'The Red Lipstick is a classic and bold choice for adding a pop of color to your lips.',
101
- price: 12.99,
102
- category: 'Beauty',
103
- stock: 91,
104
- image_url: 'https://cdn.dummyjson.com/product-images/beauty/red-lipstick/thumbnail.webp',
105
- },
106
- {
107
- id: 'prod-5',
108
- name: 'Red Nail Polish',
109
- description: 'The Red Nail Polish offers a rich and glossy red hue for vibrant and polished nails.',
110
- price: 8.99,
111
- category: 'Beauty',
112
- stock: 79,
113
- image_url: 'https://cdn.dummyjson.com/product-images/beauty/red-nail-polish/thumbnail.webp',
114
- },
115
-
116
- // Fragrances
117
- {
118
- id: 'prod-6',
119
- name: 'Calvin Klein CK One',
120
- description: 'CK One by Calvin Klein is a classic unisex fragrance, known for its fresh and clean scent.',
121
- price: 49.99,
122
- category: 'Fragrances',
123
- stock: 17,
124
- image_url: 'https://cdn.dummyjson.com/product-images/fragrances/calvin-klein-ck-one/thumbnail.webp',
125
- },
126
- {
127
- id: 'prod-7',
128
- name: 'Chanel Coco Noir Eau De',
129
- description: 'Coco Noir by Chanel is an elegant and mysterious fragrance, featuring notes of grapefruit and rose.',
130
- price: 129.99,
131
- category: 'Fragrances',
132
- stock: 41,
133
- image_url: 'https://cdn.dummyjson.com/product-images/fragrances/chanel-coco-noir-eau-de/thumbnail.webp',
134
- },
135
- {
136
- id: 'prod-8',
137
- name: 'Dior J\'adore',
138
- description: 'J\'adore by Dior is a luxurious and floral fragrance, known for its sophisticated blend of ylang-ylang.',
139
- price: 89.99,
140
- category: 'Fragrances',
141
- stock: 91,
142
- image_url: 'https://cdn.dummyjson.com/product-images/fragrances/dior-j-adore/thumbnail.webp',
143
- },
144
- {
145
- id: 'prod-9',
146
- name: 'Dolce Shine Eau de',
147
- description: 'Dolce Shine by Dolce & Gabbana is a vibrant and fruity fragrance, featuring notes of mango and jasmine.',
148
- price: 69.99,
149
- category: 'Fragrances',
150
- stock: 3,
151
- image_url: 'https://cdn.dummyjson.com/product-images/fragrances/dolce-shine-eau-de/thumbnail.webp',
152
- },
153
- {
154
- id: 'prod-10',
155
- name: 'Gucci Bloom Eau de',
156
- description: 'Gucci Bloom by Gucci is a floral and captivating fragrance, with notes of tuberose and jasmine.',
157
- price: 79.99,
158
- category: 'Fragrances',
159
- stock: 93,
160
- image_url: 'https://cdn.dummyjson.com/product-images/fragrances/gucci-bloom-eau-de/thumbnail.webp',
161
- },
162
-
163
- // Furniture
164
- {
165
- id: 'prod-11',
166
- name: 'Annibale Colombo Bed',
167
- description: 'The Annibale Colombo Bed is a luxurious and elegant bed frame, crafted with high-quality materials.',
168
- price: 1899.99,
169
- category: 'Furniture',
170
- stock: 47,
171
- image_url: 'https://cdn.dummyjson.com/product-images/furniture/annibale-colombo-bed/thumbnail.webp',
172
- },
173
- {
174
- id: 'prod-12',
175
- name: 'Annibale Colombo Sofa',
176
- description: 'The Annibale Colombo Sofa is a sophisticated and comfortable seating option, featuring exquisite design.',
177
- price: 2499.99,
178
- category: 'Furniture',
179
- stock: 16,
180
- image_url: 'https://cdn.dummyjson.com/product-images/furniture/annibale-colombo-sofa/thumbnail.webp',
181
- },
182
- {
183
- id: 'prod-13',
184
- name: 'Bedside Table African Cherry',
185
- description: 'The Bedside Table in African Cherry is a stylish and functional addition to your bedroom.',
186
- price: 299.99,
187
- category: 'Furniture',
188
- stock: 16,
189
- image_url: 'https://cdn.dummyjson.com/product-images/furniture/bedside-table-african-cherry/thumbnail.webp',
190
- },
191
- {
192
- id: 'prod-14',
193
- name: 'Knoll Saarinen Executive Conference Chair',
194
- description: 'The Knoll Saarinen Executive Conference Chair is a modern and ergonomic chair, perfect for your office.',
195
- price: 499.99,
196
- category: 'Furniture',
197
- stock: 47,
198
- image_url: 'https://cdn.dummyjson.com/product-images/furniture/knoll-saarinen-executive-conference-chair/thumbnail.webp',
199
- },
200
- {
201
- id: 'prod-15',
202
- name: 'Wooden Bathroom Sink With Mirror',
203
- description: 'The Wooden Bathroom Sink with Mirror is a unique and stylish addition to your bathroom.',
204
- price: 799.99,
205
- category: 'Furniture',
206
- stock: 95,
207
- image_url: 'https://cdn.dummyjson.com/product-images/furniture/wooden-bathroom-sink-with-mirror/thumbnail.webp',
208
- },
209
-
210
- // Groceries
211
- {
212
- id: 'prod-16',
213
- name: 'Apple',
214
- description: 'Fresh and crisp apples, perfect for snacking or incorporating into various recipes.',
215
- price: 1.99,
216
- category: 'Groceries',
217
- stock: 9,
218
- image_url: 'https://cdn.dummyjson.com/product-images/groceries/apple/thumbnail.webp',
219
- },
220
- {
221
- id: 'prod-17',
222
- name: 'Beef Steak',
223
- description: 'High-quality beef steak, great for grilling or cooking to your preferred level of doneness.',
224
- price: 12.99,
225
- category: 'Groceries',
226
- stock: 96,
227
- image_url: 'https://cdn.dummyjson.com/product-images/groceries/beef-steak/thumbnail.webp',
228
- },
229
- {
230
- id: 'prod-18',
231
- name: 'Cat Food',
232
- description: 'Nutritious cat food formulated to meet the dietary needs of your feline friend.',
233
- price: 8.99,
234
- category: 'Groceries',
235
- stock: 13,
236
- image_url: 'https://cdn.dummyjson.com/product-images/groceries/cat-food/thumbnail.webp',
237
- },
238
- {
239
- id: 'prod-19',
240
- name: 'Chicken Meat',
241
- description: 'Fresh and tender chicken meat, suitable for various culinary preparations.',
242
- price: 9.99,
243
- category: 'Groceries',
244
- stock: 69,
245
- image_url: 'https://cdn.dummyjson.com/product-images/groceries/chicken-meat/thumbnail.webp',
246
- },
247
- {
248
- id: 'prod-20',
249
- name: 'Cooking Oil',
250
- description: 'Versatile cooking oil suitable for frying, sautรฉing, and various culinary applications.',
251
- price: 4.99,
252
- category: 'Groceries',
253
- stock: 22,
254
- image_url: 'https://cdn.dummyjson.com/product-images/groceries/cooking-oil/thumbnail.webp',
255
- },
256
- {
257
- id: 'prod-21',
258
- name: 'Cucumber',
259
- description: 'Crisp and hydrating cucumbers, ideal for salads, snacks, or as a refreshing side.',
260
- price: 1.49,
261
- category: 'Groceries',
262
- stock: 22,
263
- image_url: 'https://cdn.dummyjson.com/product-images/groceries/cucumber/thumbnail.webp',
264
- },
265
- {
266
- id: 'prod-22',
267
- name: 'Dog Food',
268
- description: 'Specially formulated dog food designed to provide essential nutrients for your canine companion.',
269
- price: 10.99,
270
- category: 'Groceries',
271
- stock: 40,
272
- image_url: 'https://cdn.dummyjson.com/product-images/groceries/dog-food/thumbnail.webp',
273
- },
274
- {
275
- id: 'prod-23',
276
- name: 'Eggs',
277
- description: 'Fresh eggs, a versatile ingredient for baking, cooking, or breakfast.',
278
- price: 2.99,
279
- category: 'Groceries',
280
- stock: 10,
281
- image_url: 'https://cdn.dummyjson.com/product-images/groceries/eggs/thumbnail.webp',
282
- },
283
- {
284
- id: 'prod-24',
285
- name: 'Fish Steak',
286
- description: 'Quality fish steak, suitable for grilling, baking, or pan-searing.',
287
- price: 14.99,
288
- category: 'Groceries',
289
- stock: 99,
290
- image_url: 'https://cdn.dummyjson.com/product-images/groceries/fish-steak/thumbnail.webp',
291
- },
292
- {
293
- id: 'prod-25',
294
- name: 'Green Bell Pepper',
295
- description: 'Fresh green bell pepper, perfect for adding color and flavor to your dishes.',
296
- price: 1.29,
297
- category: 'Groceries',
298
- stock: 89,
299
- image_url: 'https://cdn.dummyjson.com/product-images/groceries/green-bell-pepper/thumbnail.webp',
300
- },
301
- {
302
- id: 'prod-26',
303
- name: 'Green Chili Pepper',
304
- description: 'Spicy green chili pepper, ideal for adding heat to your favorite recipes.',
305
- price: 0.99,
306
- category: 'Groceries',
307
- stock: 8,
308
- image_url: 'https://cdn.dummyjson.com/product-images/groceries/green-chili-pepper/thumbnail.webp',
309
- },
310
- {
311
- id: 'prod-27',
312
- name: 'Honey Jar',
313
- description: 'Pure and natural honey in a convenient jar, perfect for sweetening beverages or drizzling over food.',
314
- price: 6.99,
315
- category: 'Groceries',
316
- stock: 34,
317
- image_url: 'https://cdn.dummyjson.com/product-images/groceries/honey-jar/thumbnail.webp',
318
- },
319
- {
320
- id: 'prod-28',
321
- name: 'Ice Cream',
322
- description: 'Creamy and delicious ice cream, available in various flavors for a delightful treat.',
323
- price: 5.49,
324
- category: 'Groceries',
325
- stock: 27,
326
- image_url: 'https://cdn.dummyjson.com/product-images/groceries/ice-cream/thumbnail.webp',
327
- },
328
- {
329
- id: 'prod-29',
330
- name: 'Juice',
331
- description: 'Refreshing fruit juice, packed with vitamins and great for staying hydrated.',
332
- price: 3.99,
333
- category: 'Groceries',
334
- stock: 50,
335
- image_url: 'https://cdn.dummyjson.com/product-images/groceries/juice/thumbnail.webp',
336
- },
337
- {
338
- id: 'prod-30',
339
- name: 'Kiwi',
340
- description: 'Nutrient-rich kiwi, perfect for snacking or adding a tropical twist to your dishes.',
341
- price: 2.49,
342
- category: 'Groceries',
343
- stock: 99,
344
- image_url: 'https://cdn.dummyjson.com/product-images/groceries/kiwi/thumbnail.webp',
345
- },
346
- ];
347
-
348
- const stmt = db.prepare(`
349
- INSERT OR REPLACE INTO products (id, name, description, price, category, stock, image_url)
350
- VALUES (?, ?, ?, ?, ?, ?, ?)
351
- `);
352
-
353
- for (const product of products) {
354
- stmt.run(
355
- product.id,
356
- product.name,
357
- product.description,
358
- product.price,
359
- product.category,
360
- product.stock,
361
- product.image_url
362
- );
363
- }
364
-
365
- console.log(`โœ… Seeded ${products.length} products (from DummyJSON)`);
366
- }
367
-
368
- export function seedAll(): void {
369
- console.log('๐ŸŒฑ Seeding database...');
370
- seedUsers();
371
- seedProducts();
372
- console.log('โœ… Database seeding complete!');
373
- }
374
-
@@ -1,87 +0,0 @@
1
- import * as dotenv from 'dotenv';
2
- import { initializeSchema, clearAllData } from './database.js';
3
- import { seedAll } from './seed.js';
4
- import crypto from 'crypto';
5
- import fs from 'fs';
6
- import path from 'path';
7
-
8
- /**
9
- * Database setup script
10
- * Run with: npm run setup-db
11
- */
12
-
13
- // Load environment variables
14
- dotenv.config();
15
-
16
- console.log('โ•”โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•—');
17
- console.log('โ•‘ โ•‘');
18
- console.log('โ•‘ E-COMMERCE MCP SERVER - DATABASE SETUP โ•‘');
19
- console.log('โ•‘ โ•‘');
20
- console.log('โ•šโ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•\n');
21
-
22
- try {
23
- // 1. Initialize schema
24
- console.log('๐Ÿ“ฆ Initializing database schema...');
25
- initializeSchema();
26
- console.log('โœ… Schema initialized\n');
27
-
28
- // 2. Clear existing data (optional)
29
- console.log('๐Ÿ—‘๏ธ Clearing existing data...');
30
- clearAllData();
31
- console.log('โœ… Data cleared\n');
32
-
33
- // 3. Seed data
34
- seedAll();
35
- console.log('');
36
-
37
- // 4. Generate JWT secret if not exists
38
- const envPath = path.join(process.cwd(), '.env');
39
- const envExamplePath = path.join(process.cwd(), '.env.example');
40
-
41
- if (!fs.existsSync(envPath) && fs.existsSync(envExamplePath)) {
42
- console.log('๐Ÿ“ Creating .env file...');
43
- let envContent = fs.readFileSync(envExamplePath, 'utf-8');
44
-
45
- // Generate JWT secret (64 random bytes encoded as base64url)
46
- const jwtSecret = 'jwt_secret_' + crypto.randomBytes(32).toString('base64url');
47
- envContent = envContent.replace('your-jwt-secret-here-change-this', jwtSecret);
48
-
49
- fs.writeFileSync(envPath, envContent);
50
- console.log('โœ… .env file created with JWT secret\n');
51
- }
52
-
53
- // 5. Print test credentials
54
- console.log('โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•');
55
- console.log(' TEST CREDENTIALS ');
56
- console.log('โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•\n');
57
-
58
- console.log('๐Ÿงช Test Users (use these in the inspector):');
59
- console.log('');
60
- console.log(' ๐Ÿ‘ค Alice Johnson');
61
- console.log(' Email: alice@example.com');
62
- console.log(' Password: password123');
63
- console.log('');
64
- console.log(' ๐Ÿ‘ค Bob Smith');
65
- console.log(' Email: bob@example.com');
66
- console.log(' Password: password123');
67
- console.log('');
68
- console.log(' ๐Ÿ‘ค Charlie Brown');
69
- console.log(' Email: charlie@example.com');
70
- console.log(' Password: password123');
71
- console.log('');
72
-
73
- console.log('โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•โ•\n');
74
-
75
- console.log('๐ŸŽ‰ Database setup complete!\n');
76
- console.log('Next steps:');
77
- console.log(' 1. npm install');
78
- console.log(' 2. npm run build');
79
- console.log(' 3. npm run dev');
80
- console.log(' 4. Test in inspector with the credentials above\n');
81
-
82
- process.exit(0);
83
- } catch (error) {
84
- console.error('โŒ Setup failed:', error);
85
- process.exit(1);
86
- }
87
-
@@ -1,52 +0,0 @@
1
- import { Injectable, OnEvent } from 'nitrostack';
2
-
3
- /**
4
- * Analytics Service
5
- *
6
- * Tracks events for analytics
7
- */
8
- @Injectable()
9
- export class AnalyticsService {
10
- private events: any[] = [];
11
-
12
- /**
13
- * Track order creation
14
- */
15
- @OnEvent('order.created')
16
- async trackOrderCreated(order: any): Promise<void> {
17
- this.events.push({
18
- type: 'order_created',
19
- timestamp: new Date().toISOString(),
20
- data: {
21
- order_id: order.id,
22
- total: order.total,
23
- item_count: order.items?.length || 0,
24
- },
25
- });
26
- console.log(`๐Ÿ“Š Tracked: Order Created #${order.id}`);
27
- }
28
-
29
- /**
30
- * Track product viewed
31
- */
32
- @OnEvent('product.viewed')
33
- async trackProductViewed(product: any): Promise<void> {
34
- this.events.push({
35
- type: 'product_viewed',
36
- timestamp: new Date().toISOString(),
37
- data: {
38
- product_id: product.id,
39
- product_name: product.name,
40
- },
41
- });
42
- console.log(`๐Ÿ“Š Tracked: Product Viewed - ${product.name}`);
43
- }
44
-
45
- /**
46
- * Get analytics data
47
- */
48
- getAnalytics(): any[] {
49
- return this.events;
50
- }
51
- }
52
-