@infuro/cms-core 1.0.7 → 1.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -256,6 +256,8 @@ __export(src_exports, {
256
256
  Brand: () => Brand,
257
257
  CMS_ENTITY_MAP: () => CMS_ENTITY_MAP,
258
258
  Category: () => Category,
259
+ ChatConversation: () => ChatConversation,
260
+ ChatMessage: () => ChatMessage,
259
261
  Collection: () => Collection,
260
262
  Comment: () => Comment,
261
263
  Config: () => Config,
@@ -265,6 +267,9 @@ __export(src_exports, {
265
267
  Form: () => Form,
266
268
  FormField: () => FormField,
267
269
  FormSubmission: () => FormSubmission,
270
+ KnowledgeBaseChunk: () => KnowledgeBaseChunk,
271
+ KnowledgeBaseDocument: () => KnowledgeBaseDocument,
272
+ LlmService: () => LlmService,
268
273
  Media: () => Media,
269
274
  OPEN_ENDPOINTS: () => OPEN_ENDPOINTS,
270
275
  Order: () => Order,
@@ -317,6 +322,7 @@ __export(src_exports, {
317
322
  getRequiredPermission: () => getRequiredPermission,
318
323
  isOpenEndpoint: () => isOpenEndpoint,
319
324
  isPublicMethod: () => isPublicMethod,
325
+ llmPlugin: () => llmPlugin,
320
326
  localStoragePlugin: () => localStoragePlugin,
321
327
  paymentPlugin: () => paymentPlugin,
322
328
  s3StoragePlugin: () => s3StoragePlugin,
@@ -878,6 +884,153 @@ function localStoragePlugin(config = {}) {
878
884
  };
879
885
  }
880
886
 
887
+ // src/plugins/llm/llm-service.ts
888
+ var LlmService = class _LlmService {
889
+ constructor(baseURL, apiKey, defaultEmbeddingModel) {
890
+ this.baseURL = baseURL;
891
+ this.apiKey = apiKey;
892
+ this.defaultEmbeddingModel = defaultEmbeddingModel;
893
+ }
894
+ static embedWarned = false;
895
+ get base() {
896
+ return this.baseURL.replace(/\/$/, "");
897
+ }
898
+ get url() {
899
+ return `${this.base}/v1/chat/completions`;
900
+ }
901
+ /**
902
+ * OpenAI-compatible embeddings. Returns [] if endpoint not available or unexpected response.
903
+ * Server must implement: POST /v1/embeddings
904
+ * Body: { model: string, input: string }
905
+ * Response: { data: [ { embedding: number[] } ] } or { embedding: number[] }
906
+ */
907
+ async embed(text, options = {}) {
908
+ const model = options.model ?? this.defaultEmbeddingModel ?? "text-embedding-3-small";
909
+ const input = text.slice(0, 8e3);
910
+ const res = await fetch(`${this.base}/v1/embeddings`, {
911
+ method: "POST",
912
+ headers: {
913
+ "Content-Type": "application/json",
914
+ Authorization: `Bearer ${this.apiKey}`
915
+ },
916
+ body: JSON.stringify({
917
+ model,
918
+ input
919
+ })
920
+ });
921
+ if (!res.ok) {
922
+ const body = await res.text();
923
+ if (!_LlmService.embedWarned) {
924
+ _LlmService.embedWarned = true;
925
+ console.warn(`[LLM embed] ${res.status} ${res.statusText}: ${body.slice(0, 400)}`);
926
+ }
927
+ return [];
928
+ }
929
+ let data;
930
+ try {
931
+ data = await res.json();
932
+ } catch {
933
+ console.warn("[LLM embed] Response is not JSON");
934
+ return [];
935
+ }
936
+ let embedding = data?.data?.[0]?.embedding;
937
+ if (!Array.isArray(embedding) && Array.isArray(data?.embedding)) {
938
+ embedding = data.embedding;
939
+ }
940
+ if (!Array.isArray(embedding) && Array.isArray(data?.data?.[0])) {
941
+ const first = data.data[0];
942
+ embedding = Array.isArray(first) ? first : first?.embedding;
943
+ }
944
+ if (!Array.isArray(embedding) && !_LlmService.embedWarned) {
945
+ _LlmService.embedWarned = true;
946
+ console.warn("[LLM embed] Unexpected response shape. Keys:", Object.keys(data), "data[0] type:", Array.isArray(data?.data) ? typeof data.data[0] : "n/a");
947
+ }
948
+ return Array.isArray(embedding) ? embedding : [];
949
+ }
950
+ async chat(messages, options = {}) {
951
+ const res = await fetch(this.url, {
952
+ method: "POST",
953
+ headers: {
954
+ "Content-Type": "application/json",
955
+ Authorization: `Bearer ${this.apiKey}`
956
+ },
957
+ body: JSON.stringify({
958
+ model: options.model ?? "qwen2.5:3b-instruct",
959
+ messages,
960
+ stream: false,
961
+ temperature: options.temperature,
962
+ max_tokens: options.max_tokens
963
+ })
964
+ });
965
+ if (!res.ok) {
966
+ const text = await res.text();
967
+ throw new Error(`LLM gateway error: ${res.status} ${text}`);
968
+ }
969
+ const data = await res.json();
970
+ const content = data.choices?.[0]?.message?.content ?? "";
971
+ return { content };
972
+ }
973
+ async *streamChat(messages, options = {}) {
974
+ const res = await fetch(this.url, {
975
+ method: "POST",
976
+ headers: {
977
+ "Content-Type": "application/json",
978
+ Authorization: `Bearer ${this.apiKey}`
979
+ },
980
+ body: JSON.stringify({
981
+ model: options.model ?? "qwen2.5:3b-instruct",
982
+ messages,
983
+ stream: true,
984
+ temperature: options.temperature,
985
+ max_tokens: options.max_tokens
986
+ })
987
+ });
988
+ if (!res.ok) {
989
+ const text = await res.text();
990
+ throw new Error(`LLM gateway error: ${res.status} ${text}`);
991
+ }
992
+ const reader = res.body?.getReader();
993
+ if (!reader) return;
994
+ const decoder = new TextDecoder();
995
+ let buffer = "";
996
+ while (true) {
997
+ const { value, done } = await reader.read();
998
+ if (done) break;
999
+ buffer += decoder.decode(value, { stream: true });
1000
+ const lines = buffer.split("\n");
1001
+ buffer = lines.pop() ?? "";
1002
+ for (const line of lines) {
1003
+ if (line.startsWith("data: ") && line !== "data: [DONE]") {
1004
+ try {
1005
+ const json = JSON.parse(line.slice(6));
1006
+ const content = json.choices?.[0]?.delta?.content;
1007
+ if (content) yield content;
1008
+ } catch {
1009
+ }
1010
+ }
1011
+ }
1012
+ }
1013
+ }
1014
+ };
1015
+
1016
+ // src/plugins/llm/index.ts
1017
+ function llmPlugin(config = {}) {
1018
+ return {
1019
+ name: "llm",
1020
+ version: "1.0.0",
1021
+ async init(context) {
1022
+ const baseURL = config.baseURL ?? context.config.LLM_GATEWAY_URL;
1023
+ const apiKey = config.apiKey ?? context.config.LLM_API_KEY;
1024
+ if (!baseURL || !apiKey) {
1025
+ context.logger.warn("LLM plugin skipped: LLM_GATEWAY_URL or LLM_API_KEY not set");
1026
+ return void 0;
1027
+ }
1028
+ const embeddingModel = config.embeddingModel ?? context.config.EMBEDDING_MODEL;
1029
+ return new LlmService(baseURL.replace(/\/$/, ""), apiKey, embeddingModel);
1030
+ }
1031
+ };
1032
+ }
1033
+
881
1034
  // src/lib/utils.ts
882
1035
  var import_clsx = require("clsx");
883
1036
  var import_tailwind_merge = require("tailwind-merge");
@@ -1465,7 +1618,7 @@ Blog = __decorateClass([
1465
1618
  ], Blog);
1466
1619
 
1467
1620
  // src/entities/contact.entity.ts
1468
- var import_typeorm16 = require("typeorm");
1621
+ var import_typeorm18 = require("typeorm");
1469
1622
 
1470
1623
  // src/entities/form-submission.entity.ts
1471
1624
  var import_typeorm12 = require("typeorm");
@@ -1924,6 +2077,74 @@ Payment = __decorateClass([
1924
2077
  (0, import_typeorm15.Entity)("payments")
1925
2078
  ], Payment);
1926
2079
 
2080
+ // src/entities/chat-conversation.entity.ts
2081
+ var import_typeorm17 = require("typeorm");
2082
+
2083
+ // src/entities/chat-message.entity.ts
2084
+ var import_typeorm16 = require("typeorm");
2085
+ var ChatMessage = class {
2086
+ id;
2087
+ conversationId;
2088
+ role;
2089
+ content;
2090
+ createdAt;
2091
+ conversation;
2092
+ };
2093
+ __decorateClass([
2094
+ (0, import_typeorm16.PrimaryGeneratedColumn)()
2095
+ ], ChatMessage.prototype, "id", 2);
2096
+ __decorateClass([
2097
+ (0, import_typeorm16.Column)("int")
2098
+ ], ChatMessage.prototype, "conversationId", 2);
2099
+ __decorateClass([
2100
+ (0, import_typeorm16.Column)("varchar")
2101
+ ], ChatMessage.prototype, "role", 2);
2102
+ __decorateClass([
2103
+ (0, import_typeorm16.Column)("text")
2104
+ ], ChatMessage.prototype, "content", 2);
2105
+ __decorateClass([
2106
+ (0, import_typeorm16.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2107
+ ], ChatMessage.prototype, "createdAt", 2);
2108
+ __decorateClass([
2109
+ (0, import_typeorm16.ManyToOne)(() => ChatConversation, (c) => c.messages, { onDelete: "CASCADE" }),
2110
+ (0, import_typeorm16.JoinColumn)({ name: "conversationId" })
2111
+ ], ChatMessage.prototype, "conversation", 2);
2112
+ ChatMessage = __decorateClass([
2113
+ (0, import_typeorm16.Entity)("chat_messages")
2114
+ ], ChatMessage);
2115
+
2116
+ // src/entities/chat-conversation.entity.ts
2117
+ var ChatConversation = class {
2118
+ id;
2119
+ contactId;
2120
+ createdAt;
2121
+ updatedAt;
2122
+ contact;
2123
+ messages;
2124
+ };
2125
+ __decorateClass([
2126
+ (0, import_typeorm17.PrimaryGeneratedColumn)()
2127
+ ], ChatConversation.prototype, "id", 2);
2128
+ __decorateClass([
2129
+ (0, import_typeorm17.Column)("int")
2130
+ ], ChatConversation.prototype, "contactId", 2);
2131
+ __decorateClass([
2132
+ (0, import_typeorm17.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2133
+ ], ChatConversation.prototype, "createdAt", 2);
2134
+ __decorateClass([
2135
+ (0, import_typeorm17.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2136
+ ], ChatConversation.prototype, "updatedAt", 2);
2137
+ __decorateClass([
2138
+ (0, import_typeorm17.ManyToOne)(() => Contact, (c) => c.chatConversations, { onDelete: "CASCADE" }),
2139
+ (0, import_typeorm17.JoinColumn)({ name: "contactId" })
2140
+ ], ChatConversation.prototype, "contact", 2);
2141
+ __decorateClass([
2142
+ (0, import_typeorm17.OneToMany)(() => ChatMessage, (m) => m.conversation)
2143
+ ], ChatConversation.prototype, "messages", 2);
2144
+ ChatConversation = __decorateClass([
2145
+ (0, import_typeorm17.Entity)("chat_conversations")
2146
+ ], ChatConversation);
2147
+
1927
2148
  // src/entities/contact.entity.ts
1928
2149
  var Contact = class {
1929
2150
  id;
@@ -1945,70 +2166,74 @@ var Contact = class {
1945
2166
  addresses;
1946
2167
  orders;
1947
2168
  payments;
2169
+ chatConversations;
1948
2170
  };
1949
2171
  __decorateClass([
1950
- (0, import_typeorm16.PrimaryGeneratedColumn)()
2172
+ (0, import_typeorm18.PrimaryGeneratedColumn)()
1951
2173
  ], Contact.prototype, "id", 2);
1952
2174
  __decorateClass([
1953
- (0, import_typeorm16.Column)("varchar")
2175
+ (0, import_typeorm18.Column)("varchar")
1954
2176
  ], Contact.prototype, "name", 2);
1955
2177
  __decorateClass([
1956
- (0, import_typeorm16.Column)("varchar", { unique: true })
2178
+ (0, import_typeorm18.Column)("varchar", { unique: true })
1957
2179
  ], Contact.prototype, "email", 2);
1958
2180
  __decorateClass([
1959
- (0, import_typeorm16.Column)("varchar", { nullable: true })
2181
+ (0, import_typeorm18.Column)("varchar", { nullable: true })
1960
2182
  ], Contact.prototype, "phone", 2);
1961
2183
  __decorateClass([
1962
- (0, import_typeorm16.Column)("varchar", { nullable: true })
2184
+ (0, import_typeorm18.Column)("varchar", { nullable: true })
1963
2185
  ], Contact.prototype, "type", 2);
1964
2186
  __decorateClass([
1965
- (0, import_typeorm16.Column)("varchar", { nullable: true })
2187
+ (0, import_typeorm18.Column)("varchar", { nullable: true })
1966
2188
  ], Contact.prototype, "company", 2);
1967
2189
  __decorateClass([
1968
- (0, import_typeorm16.Column)("varchar", { nullable: true })
2190
+ (0, import_typeorm18.Column)("varchar", { nullable: true })
1969
2191
  ], Contact.prototype, "taxId", 2);
1970
2192
  __decorateClass([
1971
- (0, import_typeorm16.Column)("text", { nullable: true })
2193
+ (0, import_typeorm18.Column)("text", { nullable: true })
1972
2194
  ], Contact.prototype, "notes", 2);
1973
2195
  __decorateClass([
1974
- (0, import_typeorm16.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2196
+ (0, import_typeorm18.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
1975
2197
  ], Contact.prototype, "createdAt", 2);
1976
2198
  __decorateClass([
1977
- (0, import_typeorm16.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2199
+ (0, import_typeorm18.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
1978
2200
  ], Contact.prototype, "updatedAt", 2);
1979
2201
  __decorateClass([
1980
- (0, import_typeorm16.Column)({ type: "timestamp", nullable: true })
2202
+ (0, import_typeorm18.Column)({ type: "timestamp", nullable: true })
1981
2203
  ], Contact.prototype, "deletedAt", 2);
1982
2204
  __decorateClass([
1983
- (0, import_typeorm16.Column)("boolean", { default: false })
2205
+ (0, import_typeorm18.Column)("boolean", { default: false })
1984
2206
  ], Contact.prototype, "deleted", 2);
1985
2207
  __decorateClass([
1986
- (0, import_typeorm16.Column)("int", { nullable: true })
2208
+ (0, import_typeorm18.Column)("int", { nullable: true })
1987
2209
  ], Contact.prototype, "createdBy", 2);
1988
2210
  __decorateClass([
1989
- (0, import_typeorm16.Column)("int", { nullable: true })
2211
+ (0, import_typeorm18.Column)("int", { nullable: true })
1990
2212
  ], Contact.prototype, "updatedBy", 2);
1991
2213
  __decorateClass([
1992
- (0, import_typeorm16.Column)("int", { nullable: true })
2214
+ (0, import_typeorm18.Column)("int", { nullable: true })
1993
2215
  ], Contact.prototype, "deletedBy", 2);
1994
2216
  __decorateClass([
1995
- (0, import_typeorm16.OneToMany)(() => FormSubmission, (fs) => fs.contact)
2217
+ (0, import_typeorm18.OneToMany)(() => FormSubmission, (fs) => fs.contact)
1996
2218
  ], Contact.prototype, "form_submissions", 2);
1997
2219
  __decorateClass([
1998
- (0, import_typeorm16.OneToMany)(() => Address, (a) => a.contact)
2220
+ (0, import_typeorm18.OneToMany)(() => Address, (a) => a.contact)
1999
2221
  ], Contact.prototype, "addresses", 2);
2000
2222
  __decorateClass([
2001
- (0, import_typeorm16.OneToMany)(() => Order, (o) => o.contact)
2223
+ (0, import_typeorm18.OneToMany)(() => Order, (o) => o.contact)
2002
2224
  ], Contact.prototype, "orders", 2);
2003
2225
  __decorateClass([
2004
- (0, import_typeorm16.OneToMany)(() => Payment, (p) => p.contact)
2226
+ (0, import_typeorm18.OneToMany)(() => Payment, (p) => p.contact)
2005
2227
  ], Contact.prototype, "payments", 2);
2228
+ __decorateClass([
2229
+ (0, import_typeorm18.OneToMany)(() => ChatConversation, (c) => c.contact)
2230
+ ], Contact.prototype, "chatConversations", 2);
2006
2231
  Contact = __decorateClass([
2007
- (0, import_typeorm16.Entity)("contacts")
2232
+ (0, import_typeorm18.Entity)("contacts")
2008
2233
  ], Contact);
2009
2234
 
2010
2235
  // src/entities/config.entity.ts
2011
- var import_typeorm17 = require("typeorm");
2236
+ var import_typeorm19 = require("typeorm");
2012
2237
  var Config = class {
2013
2238
  id;
2014
2239
  settings;
@@ -2025,51 +2250,51 @@ var Config = class {
2025
2250
  deletedBy;
2026
2251
  };
2027
2252
  __decorateClass([
2028
- (0, import_typeorm17.PrimaryGeneratedColumn)()
2253
+ (0, import_typeorm19.PrimaryGeneratedColumn)()
2029
2254
  ], Config.prototype, "id", 2);
2030
2255
  __decorateClass([
2031
- (0, import_typeorm17.Column)("varchar")
2256
+ (0, import_typeorm19.Column)("varchar")
2032
2257
  ], Config.prototype, "settings", 2);
2033
2258
  __decorateClass([
2034
- (0, import_typeorm17.Column)("varchar")
2259
+ (0, import_typeorm19.Column)("varchar")
2035
2260
  ], Config.prototype, "key", 2);
2036
2261
  __decorateClass([
2037
- (0, import_typeorm17.Column)("varchar")
2262
+ (0, import_typeorm19.Column)("varchar")
2038
2263
  ], Config.prototype, "value", 2);
2039
2264
  __decorateClass([
2040
- (0, import_typeorm17.Column)("varchar", { default: "private" })
2265
+ (0, import_typeorm19.Column)("varchar", { default: "private" })
2041
2266
  ], Config.prototype, "type", 2);
2042
2267
  __decorateClass([
2043
- (0, import_typeorm17.Column)("boolean", { default: false })
2268
+ (0, import_typeorm19.Column)("boolean", { default: false })
2044
2269
  ], Config.prototype, "encrypted", 2);
2045
2270
  __decorateClass([
2046
- (0, import_typeorm17.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2271
+ (0, import_typeorm19.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2047
2272
  ], Config.prototype, "createdAt", 2);
2048
2273
  __decorateClass([
2049
- (0, import_typeorm17.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2274
+ (0, import_typeorm19.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2050
2275
  ], Config.prototype, "updatedAt", 2);
2051
2276
  __decorateClass([
2052
- (0, import_typeorm17.Column)({ type: "timestamp", nullable: true })
2277
+ (0, import_typeorm19.Column)({ type: "timestamp", nullable: true })
2053
2278
  ], Config.prototype, "deletedAt", 2);
2054
2279
  __decorateClass([
2055
- (0, import_typeorm17.Column)("boolean", { default: false })
2280
+ (0, import_typeorm19.Column)("boolean", { default: false })
2056
2281
  ], Config.prototype, "deleted", 2);
2057
2282
  __decorateClass([
2058
- (0, import_typeorm17.Column)("int", { nullable: true })
2283
+ (0, import_typeorm19.Column)("int", { nullable: true })
2059
2284
  ], Config.prototype, "createdBy", 2);
2060
2285
  __decorateClass([
2061
- (0, import_typeorm17.Column)("int", { nullable: true })
2286
+ (0, import_typeorm19.Column)("int", { nullable: true })
2062
2287
  ], Config.prototype, "updatedBy", 2);
2063
2288
  __decorateClass([
2064
- (0, import_typeorm17.Column)("int", { nullable: true })
2289
+ (0, import_typeorm19.Column)("int", { nullable: true })
2065
2290
  ], Config.prototype, "deletedBy", 2);
2066
2291
  Config = __decorateClass([
2067
- (0, import_typeorm17.Entity)("configs"),
2068
- (0, import_typeorm17.Unique)(["settings", "key"])
2292
+ (0, import_typeorm19.Entity)("configs"),
2293
+ (0, import_typeorm19.Unique)(["settings", "key"])
2069
2294
  ], Config);
2070
2295
 
2071
2296
  // src/entities/media.entity.ts
2072
- var import_typeorm18 = require("typeorm");
2297
+ var import_typeorm20 = require("typeorm");
2073
2298
  var Media = class {
2074
2299
  id;
2075
2300
  filename;
@@ -2084,44 +2309,44 @@ var Media = class {
2084
2309
  deleted;
2085
2310
  };
2086
2311
  __decorateClass([
2087
- (0, import_typeorm18.PrimaryGeneratedColumn)()
2312
+ (0, import_typeorm20.PrimaryGeneratedColumn)()
2088
2313
  ], Media.prototype, "id", 2);
2089
2314
  __decorateClass([
2090
- (0, import_typeorm18.Column)("varchar")
2315
+ (0, import_typeorm20.Column)("varchar")
2091
2316
  ], Media.prototype, "filename", 2);
2092
2317
  __decorateClass([
2093
- (0, import_typeorm18.Column)("varchar")
2318
+ (0, import_typeorm20.Column)("varchar")
2094
2319
  ], Media.prototype, "url", 2);
2095
2320
  __decorateClass([
2096
- (0, import_typeorm18.Column)("varchar")
2321
+ (0, import_typeorm20.Column)("varchar")
2097
2322
  ], Media.prototype, "mimeType", 2);
2098
2323
  __decorateClass([
2099
- (0, import_typeorm18.Column)("int", { default: 0 })
2324
+ (0, import_typeorm20.Column)("int", { default: 0 })
2100
2325
  ], Media.prototype, "size", 2);
2101
2326
  __decorateClass([
2102
- (0, import_typeorm18.Column)("varchar", { nullable: true })
2327
+ (0, import_typeorm20.Column)("varchar", { nullable: true })
2103
2328
  ], Media.prototype, "alt", 2);
2104
2329
  __decorateClass([
2105
- (0, import_typeorm18.Column)("boolean", { default: false })
2330
+ (0, import_typeorm20.Column)("boolean", { default: false })
2106
2331
  ], Media.prototype, "isPublic", 2);
2107
2332
  __decorateClass([
2108
- (0, import_typeorm18.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2333
+ (0, import_typeorm20.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2109
2334
  ], Media.prototype, "createdAt", 2);
2110
2335
  __decorateClass([
2111
- (0, import_typeorm18.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2336
+ (0, import_typeorm20.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2112
2337
  ], Media.prototype, "updatedAt", 2);
2113
2338
  __decorateClass([
2114
- (0, import_typeorm18.Column)({ type: "timestamp", nullable: true })
2339
+ (0, import_typeorm20.Column)({ type: "timestamp", nullable: true })
2115
2340
  ], Media.prototype, "deletedAt", 2);
2116
2341
  __decorateClass([
2117
- (0, import_typeorm18.Column)("boolean", { default: false })
2342
+ (0, import_typeorm20.Column)("boolean", { default: false })
2118
2343
  ], Media.prototype, "deleted", 2);
2119
2344
  Media = __decorateClass([
2120
- (0, import_typeorm18.Entity)("media")
2345
+ (0, import_typeorm20.Entity)("media")
2121
2346
  ], Media);
2122
2347
 
2123
2348
  // src/entities/page.entity.ts
2124
- var import_typeorm19 = require("typeorm");
2349
+ var import_typeorm21 = require("typeorm");
2125
2350
  var Page = class {
2126
2351
  id;
2127
2352
  title;
@@ -2142,64 +2367,64 @@ var Page = class {
2142
2367
  deletedBy;
2143
2368
  };
2144
2369
  __decorateClass([
2145
- (0, import_typeorm19.PrimaryGeneratedColumn)()
2370
+ (0, import_typeorm21.PrimaryGeneratedColumn)()
2146
2371
  ], Page.prototype, "id", 2);
2147
2372
  __decorateClass([
2148
- (0, import_typeorm19.Column)("varchar")
2373
+ (0, import_typeorm21.Column)("varchar")
2149
2374
  ], Page.prototype, "title", 2);
2150
2375
  __decorateClass([
2151
- (0, import_typeorm19.Column)("varchar", { unique: true })
2376
+ (0, import_typeorm21.Column)("varchar", { unique: true })
2152
2377
  ], Page.prototype, "slug", 2);
2153
2378
  __decorateClass([
2154
- (0, import_typeorm19.Column)({ type: "jsonb", default: {} })
2379
+ (0, import_typeorm21.Column)({ type: "jsonb", default: {} })
2155
2380
  ], Page.prototype, "content", 2);
2156
2381
  __decorateClass([
2157
- (0, import_typeorm19.Column)("boolean", { default: false })
2382
+ (0, import_typeorm21.Column)("boolean", { default: false })
2158
2383
  ], Page.prototype, "published", 2);
2159
2384
  __decorateClass([
2160
- (0, import_typeorm19.Column)("varchar", { default: "default" })
2385
+ (0, import_typeorm21.Column)("varchar", { default: "default" })
2161
2386
  ], Page.prototype, "theme", 2);
2162
2387
  __decorateClass([
2163
- (0, import_typeorm19.Column)("int", { nullable: true })
2388
+ (0, import_typeorm21.Column)("int", { nullable: true })
2164
2389
  ], Page.prototype, "parentId", 2);
2165
2390
  __decorateClass([
2166
- (0, import_typeorm19.ManyToOne)(() => Page, { onDelete: "SET NULL" }),
2167
- (0, import_typeorm19.JoinColumn)({ name: "parentId" })
2391
+ (0, import_typeorm21.ManyToOne)(() => Page, { onDelete: "SET NULL" }),
2392
+ (0, import_typeorm21.JoinColumn)({ name: "parentId" })
2168
2393
  ], Page.prototype, "parent", 2);
2169
2394
  __decorateClass([
2170
- (0, import_typeorm19.Column)("int", { nullable: true })
2395
+ (0, import_typeorm21.Column)("int", { nullable: true })
2171
2396
  ], Page.prototype, "seoId", 2);
2172
2397
  __decorateClass([
2173
- (0, import_typeorm19.ManyToOne)(() => Seo, { onDelete: "SET NULL" }),
2174
- (0, import_typeorm19.JoinColumn)({ name: "seoId" })
2398
+ (0, import_typeorm21.ManyToOne)(() => Seo, { onDelete: "SET NULL" }),
2399
+ (0, import_typeorm21.JoinColumn)({ name: "seoId" })
2175
2400
  ], Page.prototype, "seo", 2);
2176
2401
  __decorateClass([
2177
- (0, import_typeorm19.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2402
+ (0, import_typeorm21.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2178
2403
  ], Page.prototype, "createdAt", 2);
2179
2404
  __decorateClass([
2180
- (0, import_typeorm19.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2405
+ (0, import_typeorm21.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2181
2406
  ], Page.prototype, "updatedAt", 2);
2182
2407
  __decorateClass([
2183
- (0, import_typeorm19.Column)({ type: "timestamp", nullable: true })
2408
+ (0, import_typeorm21.Column)({ type: "timestamp", nullable: true })
2184
2409
  ], Page.prototype, "deletedAt", 2);
2185
2410
  __decorateClass([
2186
- (0, import_typeorm19.Column)("boolean", { default: false })
2411
+ (0, import_typeorm21.Column)("boolean", { default: false })
2187
2412
  ], Page.prototype, "deleted", 2);
2188
2413
  __decorateClass([
2189
- (0, import_typeorm19.Column)("int", { nullable: true })
2414
+ (0, import_typeorm21.Column)("int", { nullable: true })
2190
2415
  ], Page.prototype, "createdBy", 2);
2191
2416
  __decorateClass([
2192
- (0, import_typeorm19.Column)("int", { nullable: true })
2417
+ (0, import_typeorm21.Column)("int", { nullable: true })
2193
2418
  ], Page.prototype, "updatedBy", 2);
2194
2419
  __decorateClass([
2195
- (0, import_typeorm19.Column)("int", { nullable: true })
2420
+ (0, import_typeorm21.Column)("int", { nullable: true })
2196
2421
  ], Page.prototype, "deletedBy", 2);
2197
2422
  Page = __decorateClass([
2198
- (0, import_typeorm19.Entity)("pages")
2423
+ (0, import_typeorm21.Entity)("pages")
2199
2424
  ], Page);
2200
2425
 
2201
2426
  // src/entities/product-category.entity.ts
2202
- var import_typeorm20 = require("typeorm");
2427
+ var import_typeorm22 = require("typeorm");
2203
2428
  var ProductCategory = class {
2204
2429
  id;
2205
2430
  name;
@@ -2223,75 +2448,75 @@ var ProductCategory = class {
2223
2448
  collections;
2224
2449
  };
2225
2450
  __decorateClass([
2226
- (0, import_typeorm20.PrimaryGeneratedColumn)()
2451
+ (0, import_typeorm22.PrimaryGeneratedColumn)()
2227
2452
  ], ProductCategory.prototype, "id", 2);
2228
2453
  __decorateClass([
2229
- (0, import_typeorm20.Column)("varchar")
2454
+ (0, import_typeorm22.Column)("varchar")
2230
2455
  ], ProductCategory.prototype, "name", 2);
2231
2456
  __decorateClass([
2232
- (0, import_typeorm20.Column)("varchar", { unique: true })
2457
+ (0, import_typeorm22.Column)("varchar", { unique: true })
2233
2458
  ], ProductCategory.prototype, "slug", 2);
2234
2459
  __decorateClass([
2235
- (0, import_typeorm20.Column)("int", { nullable: true })
2460
+ (0, import_typeorm22.Column)("int", { nullable: true })
2236
2461
  ], ProductCategory.prototype, "parentId", 2);
2237
2462
  __decorateClass([
2238
- (0, import_typeorm20.Column)("varchar", { nullable: true })
2463
+ (0, import_typeorm22.Column)("varchar", { nullable: true })
2239
2464
  ], ProductCategory.prototype, "image", 2);
2240
2465
  __decorateClass([
2241
- (0, import_typeorm20.Column)("text", { nullable: true })
2466
+ (0, import_typeorm22.Column)("text", { nullable: true })
2242
2467
  ], ProductCategory.prototype, "description", 2);
2243
2468
  __decorateClass([
2244
- (0, import_typeorm20.Column)("jsonb", { nullable: true })
2469
+ (0, import_typeorm22.Column)("jsonb", { nullable: true })
2245
2470
  ], ProductCategory.prototype, "metadata", 2);
2246
2471
  __decorateClass([
2247
- (0, import_typeorm20.Column)("boolean", { default: true })
2472
+ (0, import_typeorm22.Column)("boolean", { default: true })
2248
2473
  ], ProductCategory.prototype, "active", 2);
2249
2474
  __decorateClass([
2250
- (0, import_typeorm20.Column)("int", { default: 0 })
2475
+ (0, import_typeorm22.Column)("int", { default: 0 })
2251
2476
  ], ProductCategory.prototype, "sortOrder", 2);
2252
2477
  __decorateClass([
2253
- (0, import_typeorm20.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2478
+ (0, import_typeorm22.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2254
2479
  ], ProductCategory.prototype, "createdAt", 2);
2255
2480
  __decorateClass([
2256
- (0, import_typeorm20.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2481
+ (0, import_typeorm22.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2257
2482
  ], ProductCategory.prototype, "updatedAt", 2);
2258
2483
  __decorateClass([
2259
- (0, import_typeorm20.Column)({ type: "timestamp", nullable: true })
2484
+ (0, import_typeorm22.Column)({ type: "timestamp", nullable: true })
2260
2485
  ], ProductCategory.prototype, "deletedAt", 2);
2261
2486
  __decorateClass([
2262
- (0, import_typeorm20.Column)("boolean", { default: false })
2487
+ (0, import_typeorm22.Column)("boolean", { default: false })
2263
2488
  ], ProductCategory.prototype, "deleted", 2);
2264
2489
  __decorateClass([
2265
- (0, import_typeorm20.Column)("int", { nullable: true })
2490
+ (0, import_typeorm22.Column)("int", { nullable: true })
2266
2491
  ], ProductCategory.prototype, "createdBy", 2);
2267
2492
  __decorateClass([
2268
- (0, import_typeorm20.Column)("int", { nullable: true })
2493
+ (0, import_typeorm22.Column)("int", { nullable: true })
2269
2494
  ], ProductCategory.prototype, "updatedBy", 2);
2270
2495
  __decorateClass([
2271
- (0, import_typeorm20.Column)("int", { nullable: true })
2496
+ (0, import_typeorm22.Column)("int", { nullable: true })
2272
2497
  ], ProductCategory.prototype, "deletedBy", 2);
2273
2498
  __decorateClass([
2274
- (0, import_typeorm20.ManyToOne)(() => ProductCategory, (c) => c.children, { onDelete: "SET NULL" }),
2275
- (0, import_typeorm20.JoinColumn)({ name: "parentId" })
2499
+ (0, import_typeorm22.ManyToOne)(() => ProductCategory, (c) => c.children, { onDelete: "SET NULL" }),
2500
+ (0, import_typeorm22.JoinColumn)({ name: "parentId" })
2276
2501
  ], ProductCategory.prototype, "parent", 2);
2277
2502
  __decorateClass([
2278
- (0, import_typeorm20.OneToMany)(() => ProductCategory, (c) => c.parent)
2503
+ (0, import_typeorm22.OneToMany)(() => ProductCategory, (c) => c.parent)
2279
2504
  ], ProductCategory.prototype, "children", 2);
2280
2505
  __decorateClass([
2281
- (0, import_typeorm20.OneToMany)("Product", "category")
2506
+ (0, import_typeorm22.OneToMany)("Product", "category")
2282
2507
  ], ProductCategory.prototype, "products", 2);
2283
2508
  __decorateClass([
2284
- (0, import_typeorm20.OneToMany)("Collection", "category")
2509
+ (0, import_typeorm22.OneToMany)("Collection", "category")
2285
2510
  ], ProductCategory.prototype, "collections", 2);
2286
2511
  ProductCategory = __decorateClass([
2287
- (0, import_typeorm20.Entity)("product_categories")
2512
+ (0, import_typeorm22.Entity)("product_categories")
2288
2513
  ], ProductCategory);
2289
2514
 
2290
2515
  // src/entities/collection.entity.ts
2291
- var import_typeorm22 = require("typeorm");
2516
+ var import_typeorm24 = require("typeorm");
2292
2517
 
2293
2518
  // src/entities/brand.entity.ts
2294
- var import_typeorm21 = require("typeorm");
2519
+ var import_typeorm23 = require("typeorm");
2295
2520
  var Brand = class {
2296
2521
  id;
2297
2522
  name;
@@ -2314,65 +2539,65 @@ var Brand = class {
2314
2539
  collections;
2315
2540
  };
2316
2541
  __decorateClass([
2317
- (0, import_typeorm21.PrimaryGeneratedColumn)()
2542
+ (0, import_typeorm23.PrimaryGeneratedColumn)()
2318
2543
  ], Brand.prototype, "id", 2);
2319
2544
  __decorateClass([
2320
- (0, import_typeorm21.Column)("varchar")
2545
+ (0, import_typeorm23.Column)("varchar")
2321
2546
  ], Brand.prototype, "name", 2);
2322
2547
  __decorateClass([
2323
- (0, import_typeorm21.Column)("varchar", { unique: true })
2548
+ (0, import_typeorm23.Column)("varchar", { unique: true })
2324
2549
  ], Brand.prototype, "slug", 2);
2325
2550
  __decorateClass([
2326
- (0, import_typeorm21.Column)("varchar", { nullable: true })
2551
+ (0, import_typeorm23.Column)("varchar", { nullable: true })
2327
2552
  ], Brand.prototype, "logo", 2);
2328
2553
  __decorateClass([
2329
- (0, import_typeorm21.Column)("jsonb", { nullable: true })
2554
+ (0, import_typeorm23.Column)("jsonb", { nullable: true })
2330
2555
  ], Brand.prototype, "metadata", 2);
2331
2556
  __decorateClass([
2332
- (0, import_typeorm21.Column)("text", { nullable: true })
2557
+ (0, import_typeorm23.Column)("text", { nullable: true })
2333
2558
  ], Brand.prototype, "description", 2);
2334
2559
  __decorateClass([
2335
- (0, import_typeorm21.Column)("boolean", { default: true })
2560
+ (0, import_typeorm23.Column)("boolean", { default: true })
2336
2561
  ], Brand.prototype, "active", 2);
2337
2562
  __decorateClass([
2338
- (0, import_typeorm21.Column)("int", { default: 0 })
2563
+ (0, import_typeorm23.Column)("int", { default: 0 })
2339
2564
  ], Brand.prototype, "sortOrder", 2);
2340
2565
  __decorateClass([
2341
- (0, import_typeorm21.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2566
+ (0, import_typeorm23.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2342
2567
  ], Brand.prototype, "createdAt", 2);
2343
2568
  __decorateClass([
2344
- (0, import_typeorm21.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2569
+ (0, import_typeorm23.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2345
2570
  ], Brand.prototype, "updatedAt", 2);
2346
2571
  __decorateClass([
2347
- (0, import_typeorm21.Column)({ type: "timestamp", nullable: true })
2572
+ (0, import_typeorm23.Column)({ type: "timestamp", nullable: true })
2348
2573
  ], Brand.prototype, "deletedAt", 2);
2349
2574
  __decorateClass([
2350
- (0, import_typeorm21.Column)("boolean", { default: false })
2575
+ (0, import_typeorm23.Column)("boolean", { default: false })
2351
2576
  ], Brand.prototype, "deleted", 2);
2352
2577
  __decorateClass([
2353
- (0, import_typeorm21.Column)("int", { nullable: true })
2578
+ (0, import_typeorm23.Column)("int", { nullable: true })
2354
2579
  ], Brand.prototype, "createdBy", 2);
2355
2580
  __decorateClass([
2356
- (0, import_typeorm21.Column)("int", { nullable: true })
2581
+ (0, import_typeorm23.Column)("int", { nullable: true })
2357
2582
  ], Brand.prototype, "updatedBy", 2);
2358
2583
  __decorateClass([
2359
- (0, import_typeorm21.Column)("int", { nullable: true })
2584
+ (0, import_typeorm23.Column)("int", { nullable: true })
2360
2585
  ], Brand.prototype, "deletedBy", 2);
2361
2586
  __decorateClass([
2362
- (0, import_typeorm21.Column)("int", { nullable: true })
2587
+ (0, import_typeorm23.Column)("int", { nullable: true })
2363
2588
  ], Brand.prototype, "seoId", 2);
2364
2589
  __decorateClass([
2365
- (0, import_typeorm21.ManyToOne)(() => Seo, { onDelete: "SET NULL" }),
2366
- (0, import_typeorm21.JoinColumn)({ name: "seoId" })
2590
+ (0, import_typeorm23.ManyToOne)(() => Seo, { onDelete: "SET NULL" }),
2591
+ (0, import_typeorm23.JoinColumn)({ name: "seoId" })
2367
2592
  ], Brand.prototype, "seo", 2);
2368
2593
  __decorateClass([
2369
- (0, import_typeorm21.OneToMany)("Product", "brand")
2594
+ (0, import_typeorm23.OneToMany)("Product", "brand")
2370
2595
  ], Brand.prototype, "products", 2);
2371
2596
  __decorateClass([
2372
- (0, import_typeorm21.OneToMany)("Collection", "brand")
2597
+ (0, import_typeorm23.OneToMany)("Collection", "brand")
2373
2598
  ], Brand.prototype, "collections", 2);
2374
2599
  Brand = __decorateClass([
2375
- (0, import_typeorm21.Entity)("brands")
2600
+ (0, import_typeorm23.Entity)("brands")
2376
2601
  ], Brand);
2377
2602
 
2378
2603
  // src/entities/collection.entity.ts
@@ -2401,80 +2626,80 @@ var Collection = class {
2401
2626
  products;
2402
2627
  };
2403
2628
  __decorateClass([
2404
- (0, import_typeorm22.PrimaryGeneratedColumn)()
2629
+ (0, import_typeorm24.PrimaryGeneratedColumn)()
2405
2630
  ], Collection.prototype, "id", 2);
2406
2631
  __decorateClass([
2407
- (0, import_typeorm22.Column)("int", { nullable: true })
2632
+ (0, import_typeorm24.Column)("int", { nullable: true })
2408
2633
  ], Collection.prototype, "categoryId", 2);
2409
2634
  __decorateClass([
2410
- (0, import_typeorm22.Column)("int", { nullable: true })
2635
+ (0, import_typeorm24.Column)("int", { nullable: true })
2411
2636
  ], Collection.prototype, "brandId", 2);
2412
2637
  __decorateClass([
2413
- (0, import_typeorm22.Column)("varchar")
2638
+ (0, import_typeorm24.Column)("varchar")
2414
2639
  ], Collection.prototype, "name", 2);
2415
2640
  __decorateClass([
2416
- (0, import_typeorm22.Column)("varchar", { unique: true })
2641
+ (0, import_typeorm24.Column)("varchar", { unique: true })
2417
2642
  ], Collection.prototype, "slug", 2);
2418
2643
  __decorateClass([
2419
- (0, import_typeorm22.Column)("text", { nullable: true })
2644
+ (0, import_typeorm24.Column)("text", { nullable: true })
2420
2645
  ], Collection.prototype, "description", 2);
2421
2646
  __decorateClass([
2422
- (0, import_typeorm22.Column)("varchar", { nullable: true })
2647
+ (0, import_typeorm24.Column)("varchar", { nullable: true })
2423
2648
  ], Collection.prototype, "image", 2);
2424
2649
  __decorateClass([
2425
- (0, import_typeorm22.Column)("jsonb", { nullable: true })
2650
+ (0, import_typeorm24.Column)("jsonb", { nullable: true })
2426
2651
  ], Collection.prototype, "metadata", 2);
2427
2652
  __decorateClass([
2428
- (0, import_typeorm22.Column)("boolean", { default: true })
2653
+ (0, import_typeorm24.Column)("boolean", { default: true })
2429
2654
  ], Collection.prototype, "active", 2);
2430
2655
  __decorateClass([
2431
- (0, import_typeorm22.Column)("int", { default: 0 })
2656
+ (0, import_typeorm24.Column)("int", { default: 0 })
2432
2657
  ], Collection.prototype, "sortOrder", 2);
2433
2658
  __decorateClass([
2434
- (0, import_typeorm22.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2659
+ (0, import_typeorm24.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2435
2660
  ], Collection.prototype, "createdAt", 2);
2436
2661
  __decorateClass([
2437
- (0, import_typeorm22.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2662
+ (0, import_typeorm24.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2438
2663
  ], Collection.prototype, "updatedAt", 2);
2439
2664
  __decorateClass([
2440
- (0, import_typeorm22.Column)({ type: "timestamp", nullable: true })
2665
+ (0, import_typeorm24.Column)({ type: "timestamp", nullable: true })
2441
2666
  ], Collection.prototype, "deletedAt", 2);
2442
2667
  __decorateClass([
2443
- (0, import_typeorm22.Column)("boolean", { default: false })
2668
+ (0, import_typeorm24.Column)("boolean", { default: false })
2444
2669
  ], Collection.prototype, "deleted", 2);
2445
2670
  __decorateClass([
2446
- (0, import_typeorm22.Column)("int", { nullable: true })
2671
+ (0, import_typeorm24.Column)("int", { nullable: true })
2447
2672
  ], Collection.prototype, "createdBy", 2);
2448
2673
  __decorateClass([
2449
- (0, import_typeorm22.Column)("int", { nullable: true })
2674
+ (0, import_typeorm24.Column)("int", { nullable: true })
2450
2675
  ], Collection.prototype, "updatedBy", 2);
2451
2676
  __decorateClass([
2452
- (0, import_typeorm22.Column)("int", { nullable: true })
2677
+ (0, import_typeorm24.Column)("int", { nullable: true })
2453
2678
  ], Collection.prototype, "deletedBy", 2);
2454
2679
  __decorateClass([
2455
- (0, import_typeorm22.Column)("int", { nullable: true })
2680
+ (0, import_typeorm24.Column)("int", { nullable: true })
2456
2681
  ], Collection.prototype, "seoId", 2);
2457
2682
  __decorateClass([
2458
- (0, import_typeorm22.ManyToOne)(() => Seo, { onDelete: "SET NULL" }),
2459
- (0, import_typeorm22.JoinColumn)({ name: "seoId" })
2683
+ (0, import_typeorm24.ManyToOne)(() => Seo, { onDelete: "SET NULL" }),
2684
+ (0, import_typeorm24.JoinColumn)({ name: "seoId" })
2460
2685
  ], Collection.prototype, "seo", 2);
2461
2686
  __decorateClass([
2462
- (0, import_typeorm22.ManyToOne)(() => ProductCategory, (c) => c.collections, { onDelete: "SET NULL" }),
2463
- (0, import_typeorm22.JoinColumn)({ name: "categoryId" })
2687
+ (0, import_typeorm24.ManyToOne)(() => ProductCategory, (c) => c.collections, { onDelete: "SET NULL" }),
2688
+ (0, import_typeorm24.JoinColumn)({ name: "categoryId" })
2464
2689
  ], Collection.prototype, "category", 2);
2465
2690
  __decorateClass([
2466
- (0, import_typeorm22.ManyToOne)(() => Brand, (b) => b.collections, { onDelete: "SET NULL" }),
2467
- (0, import_typeorm22.JoinColumn)({ name: "brandId" })
2691
+ (0, import_typeorm24.ManyToOne)(() => Brand, (b) => b.collections, { onDelete: "SET NULL" }),
2692
+ (0, import_typeorm24.JoinColumn)({ name: "brandId" })
2468
2693
  ], Collection.prototype, "brand", 2);
2469
2694
  __decorateClass([
2470
- (0, import_typeorm22.OneToMany)("Product", "collection")
2695
+ (0, import_typeorm24.OneToMany)("Product", "collection")
2471
2696
  ], Collection.prototype, "products", 2);
2472
2697
  Collection = __decorateClass([
2473
- (0, import_typeorm22.Entity)("collections")
2698
+ (0, import_typeorm24.Entity)("collections")
2474
2699
  ], Collection);
2475
2700
 
2476
2701
  // src/entities/product.entity.ts
2477
- var import_typeorm23 = require("typeorm");
2702
+ var import_typeorm25 = require("typeorm");
2478
2703
  var Product = class {
2479
2704
  id;
2480
2705
  collectionId;
@@ -2505,96 +2730,96 @@ var Product = class {
2505
2730
  taxes;
2506
2731
  };
2507
2732
  __decorateClass([
2508
- (0, import_typeorm23.PrimaryGeneratedColumn)()
2733
+ (0, import_typeorm25.PrimaryGeneratedColumn)()
2509
2734
  ], Product.prototype, "id", 2);
2510
2735
  __decorateClass([
2511
- (0, import_typeorm23.Column)("int", { nullable: true })
2736
+ (0, import_typeorm25.Column)("int", { nullable: true })
2512
2737
  ], Product.prototype, "collectionId", 2);
2513
2738
  __decorateClass([
2514
- (0, import_typeorm23.Column)("int", { nullable: true })
2739
+ (0, import_typeorm25.Column)("int", { nullable: true })
2515
2740
  ], Product.prototype, "brandId", 2);
2516
2741
  __decorateClass([
2517
- (0, import_typeorm23.Column)("int", { nullable: true })
2742
+ (0, import_typeorm25.Column)("int", { nullable: true })
2518
2743
  ], Product.prototype, "categoryId", 2);
2519
2744
  __decorateClass([
2520
- (0, import_typeorm23.Column)("varchar", { nullable: true })
2745
+ (0, import_typeorm25.Column)("varchar", { nullable: true })
2521
2746
  ], Product.prototype, "sku", 2);
2522
2747
  __decorateClass([
2523
- (0, import_typeorm23.Column)("varchar", { unique: true, nullable: true })
2748
+ (0, import_typeorm25.Column)("varchar", { unique: true, nullable: true })
2524
2749
  ], Product.prototype, "slug", 2);
2525
2750
  __decorateClass([
2526
- (0, import_typeorm23.Column)("varchar", { nullable: true })
2751
+ (0, import_typeorm25.Column)("varchar", { nullable: true })
2527
2752
  ], Product.prototype, "name", 2);
2528
2753
  __decorateClass([
2529
- (0, import_typeorm23.Column)("decimal", { precision: 12, scale: 2 })
2754
+ (0, import_typeorm25.Column)("decimal", { precision: 12, scale: 2 })
2530
2755
  ], Product.prototype, "price", 2);
2531
2756
  __decorateClass([
2532
- (0, import_typeorm23.Column)("decimal", { precision: 12, scale: 2, nullable: true })
2757
+ (0, import_typeorm25.Column)("decimal", { precision: 12, scale: 2, nullable: true })
2533
2758
  ], Product.prototype, "compareAtPrice", 2);
2534
2759
  __decorateClass([
2535
- (0, import_typeorm23.Column)("int", { default: 0 })
2760
+ (0, import_typeorm25.Column)("int", { default: 0 })
2536
2761
  ], Product.prototype, "quantity", 2);
2537
2762
  __decorateClass([
2538
- (0, import_typeorm23.Column)("varchar", { default: "draft" })
2763
+ (0, import_typeorm25.Column)("varchar", { default: "draft" })
2539
2764
  ], Product.prototype, "status", 2);
2540
2765
  __decorateClass([
2541
- (0, import_typeorm23.Column)("boolean", { default: false })
2766
+ (0, import_typeorm25.Column)("boolean", { default: false })
2542
2767
  ], Product.prototype, "featured", 2);
2543
2768
  __decorateClass([
2544
- (0, import_typeorm23.Column)("jsonb", { nullable: true })
2769
+ (0, import_typeorm25.Column)("jsonb", { nullable: true })
2545
2770
  ], Product.prototype, "metadata", 2);
2546
2771
  __decorateClass([
2547
- (0, import_typeorm23.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2772
+ (0, import_typeorm25.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2548
2773
  ], Product.prototype, "createdAt", 2);
2549
2774
  __decorateClass([
2550
- (0, import_typeorm23.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2775
+ (0, import_typeorm25.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2551
2776
  ], Product.prototype, "updatedAt", 2);
2552
2777
  __decorateClass([
2553
- (0, import_typeorm23.Column)({ type: "timestamp", nullable: true })
2778
+ (0, import_typeorm25.Column)({ type: "timestamp", nullable: true })
2554
2779
  ], Product.prototype, "deletedAt", 2);
2555
2780
  __decorateClass([
2556
- (0, import_typeorm23.Column)("boolean", { default: false })
2781
+ (0, import_typeorm25.Column)("boolean", { default: false })
2557
2782
  ], Product.prototype, "deleted", 2);
2558
2783
  __decorateClass([
2559
- (0, import_typeorm23.Column)("int", { nullable: true })
2784
+ (0, import_typeorm25.Column)("int", { nullable: true })
2560
2785
  ], Product.prototype, "createdBy", 2);
2561
2786
  __decorateClass([
2562
- (0, import_typeorm23.Column)("int", { nullable: true })
2787
+ (0, import_typeorm25.Column)("int", { nullable: true })
2563
2788
  ], Product.prototype, "updatedBy", 2);
2564
2789
  __decorateClass([
2565
- (0, import_typeorm23.Column)("int", { nullable: true })
2790
+ (0, import_typeorm25.Column)("int", { nullable: true })
2566
2791
  ], Product.prototype, "deletedBy", 2);
2567
2792
  __decorateClass([
2568
- (0, import_typeorm23.Column)("int", { nullable: true })
2793
+ (0, import_typeorm25.Column)("int", { nullable: true })
2569
2794
  ], Product.prototype, "seoId", 2);
2570
2795
  __decorateClass([
2571
- (0, import_typeorm23.ManyToOne)(() => Seo, { onDelete: "SET NULL" }),
2572
- (0, import_typeorm23.JoinColumn)({ name: "seoId" })
2796
+ (0, import_typeorm25.ManyToOne)(() => Seo, { onDelete: "SET NULL" }),
2797
+ (0, import_typeorm25.JoinColumn)({ name: "seoId" })
2573
2798
  ], Product.prototype, "seo", 2);
2574
2799
  __decorateClass([
2575
- (0, import_typeorm23.ManyToOne)(() => Collection, (c) => c.products, { onDelete: "SET NULL" }),
2576
- (0, import_typeorm23.JoinColumn)({ name: "collectionId" })
2800
+ (0, import_typeorm25.ManyToOne)(() => Collection, (c) => c.products, { onDelete: "SET NULL" }),
2801
+ (0, import_typeorm25.JoinColumn)({ name: "collectionId" })
2577
2802
  ], Product.prototype, "collection", 2);
2578
2803
  __decorateClass([
2579
- (0, import_typeorm23.ManyToOne)(() => Brand, (b) => b.products, { onDelete: "SET NULL" }),
2580
- (0, import_typeorm23.JoinColumn)({ name: "brandId" })
2804
+ (0, import_typeorm25.ManyToOne)(() => Brand, (b) => b.products, { onDelete: "SET NULL" }),
2805
+ (0, import_typeorm25.JoinColumn)({ name: "brandId" })
2581
2806
  ], Product.prototype, "brand", 2);
2582
2807
  __decorateClass([
2583
- (0, import_typeorm23.ManyToOne)(() => ProductCategory, (c) => c.products, { onDelete: "SET NULL" }),
2584
- (0, import_typeorm23.JoinColumn)({ name: "categoryId" })
2808
+ (0, import_typeorm25.ManyToOne)(() => ProductCategory, (c) => c.products, { onDelete: "SET NULL" }),
2809
+ (0, import_typeorm25.JoinColumn)({ name: "categoryId" })
2585
2810
  ], Product.prototype, "category", 2);
2586
2811
  __decorateClass([
2587
- (0, import_typeorm23.OneToMany)("ProductAttribute", "product")
2812
+ (0, import_typeorm25.OneToMany)("ProductAttribute", "product")
2588
2813
  ], Product.prototype, "attributes", 2);
2589
2814
  __decorateClass([
2590
- (0, import_typeorm23.OneToMany)("ProductTax", "product")
2815
+ (0, import_typeorm25.OneToMany)("ProductTax", "product")
2591
2816
  ], Product.prototype, "taxes", 2);
2592
2817
  Product = __decorateClass([
2593
- (0, import_typeorm23.Entity)("products")
2818
+ (0, import_typeorm25.Entity)("products")
2594
2819
  ], Product);
2595
2820
 
2596
2821
  // src/entities/attribute.entity.ts
2597
- var import_typeorm24 = require("typeorm");
2822
+ var import_typeorm26 = require("typeorm");
2598
2823
  var Attribute = class {
2599
2824
  id;
2600
2825
  name;
@@ -2613,56 +2838,56 @@ var Attribute = class {
2613
2838
  deletedBy;
2614
2839
  };
2615
2840
  __decorateClass([
2616
- (0, import_typeorm24.PrimaryGeneratedColumn)()
2841
+ (0, import_typeorm26.PrimaryGeneratedColumn)()
2617
2842
  ], Attribute.prototype, "id", 2);
2618
2843
  __decorateClass([
2619
- (0, import_typeorm24.Column)("varchar")
2844
+ (0, import_typeorm26.Column)("varchar")
2620
2845
  ], Attribute.prototype, "name", 2);
2621
2846
  __decorateClass([
2622
- (0, import_typeorm24.Column)("varchar", { unique: true })
2847
+ (0, import_typeorm26.Column)("varchar", { unique: true })
2623
2848
  ], Attribute.prototype, "slug", 2);
2624
2849
  __decorateClass([
2625
- (0, import_typeorm24.Column)("varchar", { default: "text" })
2850
+ (0, import_typeorm26.Column)("varchar", { default: "text" })
2626
2851
  ], Attribute.prototype, "type", 2);
2627
2852
  __decorateClass([
2628
- (0, import_typeorm24.Column)("jsonb", { nullable: true })
2853
+ (0, import_typeorm26.Column)("jsonb", { nullable: true })
2629
2854
  ], Attribute.prototype, "options", 2);
2630
2855
  __decorateClass([
2631
- (0, import_typeorm24.Column)("jsonb", { nullable: true })
2856
+ (0, import_typeorm26.Column)("jsonb", { nullable: true })
2632
2857
  ], Attribute.prototype, "metadata", 2);
2633
2858
  __decorateClass([
2634
- (0, import_typeorm24.Column)("boolean", { default: true })
2859
+ (0, import_typeorm26.Column)("boolean", { default: true })
2635
2860
  ], Attribute.prototype, "active", 2);
2636
2861
  __decorateClass([
2637
- (0, import_typeorm24.Column)("int", { default: 0 })
2862
+ (0, import_typeorm26.Column)("int", { default: 0 })
2638
2863
  ], Attribute.prototype, "sortOrder", 2);
2639
2864
  __decorateClass([
2640
- (0, import_typeorm24.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2865
+ (0, import_typeorm26.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2641
2866
  ], Attribute.prototype, "createdAt", 2);
2642
2867
  __decorateClass([
2643
- (0, import_typeorm24.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2868
+ (0, import_typeorm26.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2644
2869
  ], Attribute.prototype, "updatedAt", 2);
2645
2870
  __decorateClass([
2646
- (0, import_typeorm24.Column)({ type: "timestamp", nullable: true })
2871
+ (0, import_typeorm26.Column)({ type: "timestamp", nullable: true })
2647
2872
  ], Attribute.prototype, "deletedAt", 2);
2648
2873
  __decorateClass([
2649
- (0, import_typeorm24.Column)("boolean", { default: false })
2874
+ (0, import_typeorm26.Column)("boolean", { default: false })
2650
2875
  ], Attribute.prototype, "deleted", 2);
2651
2876
  __decorateClass([
2652
- (0, import_typeorm24.Column)("int", { nullable: true })
2877
+ (0, import_typeorm26.Column)("int", { nullable: true })
2653
2878
  ], Attribute.prototype, "createdBy", 2);
2654
2879
  __decorateClass([
2655
- (0, import_typeorm24.Column)("int", { nullable: true })
2880
+ (0, import_typeorm26.Column)("int", { nullable: true })
2656
2881
  ], Attribute.prototype, "updatedBy", 2);
2657
2882
  __decorateClass([
2658
- (0, import_typeorm24.Column)("int", { nullable: true })
2883
+ (0, import_typeorm26.Column)("int", { nullable: true })
2659
2884
  ], Attribute.prototype, "deletedBy", 2);
2660
2885
  Attribute = __decorateClass([
2661
- (0, import_typeorm24.Entity)("attributes")
2886
+ (0, import_typeorm26.Entity)("attributes")
2662
2887
  ], Attribute);
2663
2888
 
2664
2889
  // src/entities/product-attribute.entity.ts
2665
- var import_typeorm25 = require("typeorm");
2890
+ var import_typeorm27 = require("typeorm");
2666
2891
  var ProductAttribute = class {
2667
2892
  id;
2668
2893
  productId;
@@ -2675,40 +2900,40 @@ var ProductAttribute = class {
2675
2900
  attribute;
2676
2901
  };
2677
2902
  __decorateClass([
2678
- (0, import_typeorm25.PrimaryGeneratedColumn)()
2903
+ (0, import_typeorm27.PrimaryGeneratedColumn)()
2679
2904
  ], ProductAttribute.prototype, "id", 2);
2680
2905
  __decorateClass([
2681
- (0, import_typeorm25.Column)("int")
2906
+ (0, import_typeorm27.Column)("int")
2682
2907
  ], ProductAttribute.prototype, "productId", 2);
2683
2908
  __decorateClass([
2684
- (0, import_typeorm25.Column)("int")
2909
+ (0, import_typeorm27.Column)("int")
2685
2910
  ], ProductAttribute.prototype, "attributeId", 2);
2686
2911
  __decorateClass([
2687
- (0, import_typeorm25.Column)("varchar")
2912
+ (0, import_typeorm27.Column)("varchar")
2688
2913
  ], ProductAttribute.prototype, "value", 2);
2689
2914
  __decorateClass([
2690
- (0, import_typeorm25.Column)("jsonb", { nullable: true })
2915
+ (0, import_typeorm27.Column)("jsonb", { nullable: true })
2691
2916
  ], ProductAttribute.prototype, "metadata", 2);
2692
2917
  __decorateClass([
2693
- (0, import_typeorm25.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2918
+ (0, import_typeorm27.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2694
2919
  ], ProductAttribute.prototype, "createdAt", 2);
2695
2920
  __decorateClass([
2696
- (0, import_typeorm25.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2921
+ (0, import_typeorm27.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2697
2922
  ], ProductAttribute.prototype, "updatedAt", 2);
2698
2923
  __decorateClass([
2699
- (0, import_typeorm25.ManyToOne)(() => Product, (p) => p.attributes, { onDelete: "CASCADE" }),
2700
- (0, import_typeorm25.JoinColumn)({ name: "productId" })
2924
+ (0, import_typeorm27.ManyToOne)(() => Product, (p) => p.attributes, { onDelete: "CASCADE" }),
2925
+ (0, import_typeorm27.JoinColumn)({ name: "productId" })
2701
2926
  ], ProductAttribute.prototype, "product", 2);
2702
2927
  __decorateClass([
2703
- (0, import_typeorm25.ManyToOne)(() => Attribute, { onDelete: "CASCADE" }),
2704
- (0, import_typeorm25.JoinColumn)({ name: "attributeId" })
2928
+ (0, import_typeorm27.ManyToOne)(() => Attribute, { onDelete: "CASCADE" }),
2929
+ (0, import_typeorm27.JoinColumn)({ name: "attributeId" })
2705
2930
  ], ProductAttribute.prototype, "attribute", 2);
2706
2931
  ProductAttribute = __decorateClass([
2707
- (0, import_typeorm25.Entity)("product_attributes")
2932
+ (0, import_typeorm27.Entity)("product_attributes")
2708
2933
  ], ProductAttribute);
2709
2934
 
2710
2935
  // src/entities/tax.entity.ts
2711
- var import_typeorm26 = require("typeorm");
2936
+ var import_typeorm28 = require("typeorm");
2712
2937
  var Tax = class {
2713
2938
  id;
2714
2939
  name;
@@ -2727,56 +2952,56 @@ var Tax = class {
2727
2952
  deletedBy;
2728
2953
  };
2729
2954
  __decorateClass([
2730
- (0, import_typeorm26.PrimaryGeneratedColumn)()
2955
+ (0, import_typeorm28.PrimaryGeneratedColumn)()
2731
2956
  ], Tax.prototype, "id", 2);
2732
2957
  __decorateClass([
2733
- (0, import_typeorm26.Column)("varchar")
2958
+ (0, import_typeorm28.Column)("varchar")
2734
2959
  ], Tax.prototype, "name", 2);
2735
2960
  __decorateClass([
2736
- (0, import_typeorm26.Column)("varchar", { unique: true })
2961
+ (0, import_typeorm28.Column)("varchar", { unique: true })
2737
2962
  ], Tax.prototype, "slug", 2);
2738
2963
  __decorateClass([
2739
- (0, import_typeorm26.Column)("decimal", { precision: 5, scale: 2 })
2964
+ (0, import_typeorm28.Column)("decimal", { precision: 5, scale: 2 })
2740
2965
  ], Tax.prototype, "rate", 2);
2741
2966
  __decorateClass([
2742
- (0, import_typeorm26.Column)("boolean", { default: false })
2967
+ (0, import_typeorm28.Column)("boolean", { default: false })
2743
2968
  ], Tax.prototype, "isDefault", 2);
2744
2969
  __decorateClass([
2745
- (0, import_typeorm26.Column)("text", { nullable: true })
2970
+ (0, import_typeorm28.Column)("text", { nullable: true })
2746
2971
  ], Tax.prototype, "description", 2);
2747
2972
  __decorateClass([
2748
- (0, import_typeorm26.Column)("boolean", { default: true })
2973
+ (0, import_typeorm28.Column)("boolean", { default: true })
2749
2974
  ], Tax.prototype, "active", 2);
2750
2975
  __decorateClass([
2751
- (0, import_typeorm26.Column)("jsonb", { nullable: true })
2976
+ (0, import_typeorm28.Column)("jsonb", { nullable: true })
2752
2977
  ], Tax.prototype, "metadata", 2);
2753
2978
  __decorateClass([
2754
- (0, import_typeorm26.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2979
+ (0, import_typeorm28.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2755
2980
  ], Tax.prototype, "createdAt", 2);
2756
2981
  __decorateClass([
2757
- (0, import_typeorm26.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2982
+ (0, import_typeorm28.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2758
2983
  ], Tax.prototype, "updatedAt", 2);
2759
2984
  __decorateClass([
2760
- (0, import_typeorm26.Column)({ type: "timestamp", nullable: true })
2985
+ (0, import_typeorm28.Column)({ type: "timestamp", nullable: true })
2761
2986
  ], Tax.prototype, "deletedAt", 2);
2762
2987
  __decorateClass([
2763
- (0, import_typeorm26.Column)("boolean", { default: false })
2988
+ (0, import_typeorm28.Column)("boolean", { default: false })
2764
2989
  ], Tax.prototype, "deleted", 2);
2765
2990
  __decorateClass([
2766
- (0, import_typeorm26.Column)("int", { nullable: true })
2991
+ (0, import_typeorm28.Column)("int", { nullable: true })
2767
2992
  ], Tax.prototype, "createdBy", 2);
2768
2993
  __decorateClass([
2769
- (0, import_typeorm26.Column)("int", { nullable: true })
2994
+ (0, import_typeorm28.Column)("int", { nullable: true })
2770
2995
  ], Tax.prototype, "updatedBy", 2);
2771
2996
  __decorateClass([
2772
- (0, import_typeorm26.Column)("int", { nullable: true })
2997
+ (0, import_typeorm28.Column)("int", { nullable: true })
2773
2998
  ], Tax.prototype, "deletedBy", 2);
2774
2999
  Tax = __decorateClass([
2775
- (0, import_typeorm26.Entity)("taxes")
3000
+ (0, import_typeorm28.Entity)("taxes")
2776
3001
  ], Tax);
2777
3002
 
2778
3003
  // src/entities/product-tax.entity.ts
2779
- var import_typeorm27 = require("typeorm");
3004
+ var import_typeorm29 = require("typeorm");
2780
3005
  var ProductTax = class {
2781
3006
  id;
2782
3007
  productId;
@@ -2788,37 +3013,37 @@ var ProductTax = class {
2788
3013
  tax;
2789
3014
  };
2790
3015
  __decorateClass([
2791
- (0, import_typeorm27.PrimaryGeneratedColumn)()
3016
+ (0, import_typeorm29.PrimaryGeneratedColumn)()
2792
3017
  ], ProductTax.prototype, "id", 2);
2793
3018
  __decorateClass([
2794
- (0, import_typeorm27.Column)("int")
3019
+ (0, import_typeorm29.Column)("int")
2795
3020
  ], ProductTax.prototype, "productId", 2);
2796
3021
  __decorateClass([
2797
- (0, import_typeorm27.Column)("int")
3022
+ (0, import_typeorm29.Column)("int")
2798
3023
  ], ProductTax.prototype, "taxId", 2);
2799
3024
  __decorateClass([
2800
- (0, import_typeorm27.Column)("decimal", { precision: 5, scale: 2, nullable: true })
3025
+ (0, import_typeorm29.Column)("decimal", { precision: 5, scale: 2, nullable: true })
2801
3026
  ], ProductTax.prototype, "rate", 2);
2802
3027
  __decorateClass([
2803
- (0, import_typeorm27.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
3028
+ (0, import_typeorm29.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2804
3029
  ], ProductTax.prototype, "createdAt", 2);
2805
3030
  __decorateClass([
2806
- (0, import_typeorm27.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
3031
+ (0, import_typeorm29.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2807
3032
  ], ProductTax.prototype, "updatedAt", 2);
2808
3033
  __decorateClass([
2809
- (0, import_typeorm27.ManyToOne)(() => Product, (p) => p.taxes, { onDelete: "CASCADE" }),
2810
- (0, import_typeorm27.JoinColumn)({ name: "productId" })
3034
+ (0, import_typeorm29.ManyToOne)(() => Product, (p) => p.taxes, { onDelete: "CASCADE" }),
3035
+ (0, import_typeorm29.JoinColumn)({ name: "productId" })
2811
3036
  ], ProductTax.prototype, "product", 2);
2812
3037
  __decorateClass([
2813
- (0, import_typeorm27.ManyToOne)(() => Tax, { onDelete: "CASCADE" }),
2814
- (0, import_typeorm27.JoinColumn)({ name: "taxId" })
3038
+ (0, import_typeorm29.ManyToOne)(() => Tax, { onDelete: "CASCADE" }),
3039
+ (0, import_typeorm29.JoinColumn)({ name: "taxId" })
2815
3040
  ], ProductTax.prototype, "tax", 2);
2816
3041
  ProductTax = __decorateClass([
2817
- (0, import_typeorm27.Entity)("product_taxes")
3042
+ (0, import_typeorm29.Entity)("product_taxes")
2818
3043
  ], ProductTax);
2819
3044
 
2820
3045
  // src/entities/order-item.entity.ts
2821
- var import_typeorm28 = require("typeorm");
3046
+ var import_typeorm30 = require("typeorm");
2822
3047
  var OrderItem = class {
2823
3048
  id;
2824
3049
  orderId;
@@ -2834,47 +3059,118 @@ var OrderItem = class {
2834
3059
  product;
2835
3060
  };
2836
3061
  __decorateClass([
2837
- (0, import_typeorm28.PrimaryGeneratedColumn)()
3062
+ (0, import_typeorm30.PrimaryGeneratedColumn)()
2838
3063
  ], OrderItem.prototype, "id", 2);
2839
3064
  __decorateClass([
2840
- (0, import_typeorm28.Column)("int")
3065
+ (0, import_typeorm30.Column)("int")
2841
3066
  ], OrderItem.prototype, "orderId", 2);
2842
3067
  __decorateClass([
2843
- (0, import_typeorm28.Column)("int")
3068
+ (0, import_typeorm30.Column)("int")
2844
3069
  ], OrderItem.prototype, "productId", 2);
2845
3070
  __decorateClass([
2846
- (0, import_typeorm28.Column)("int", { default: 1 })
3071
+ (0, import_typeorm30.Column)("int", { default: 1 })
2847
3072
  ], OrderItem.prototype, "quantity", 2);
2848
3073
  __decorateClass([
2849
- (0, import_typeorm28.Column)("decimal", { precision: 12, scale: 2 })
3074
+ (0, import_typeorm30.Column)("decimal", { precision: 12, scale: 2 })
2850
3075
  ], OrderItem.prototype, "unitPrice", 2);
2851
3076
  __decorateClass([
2852
- (0, import_typeorm28.Column)("decimal", { precision: 12, scale: 2, default: 0 })
3077
+ (0, import_typeorm30.Column)("decimal", { precision: 12, scale: 2, default: 0 })
2853
3078
  ], OrderItem.prototype, "tax", 2);
2854
3079
  __decorateClass([
2855
- (0, import_typeorm28.Column)("decimal", { precision: 12, scale: 2 })
3080
+ (0, import_typeorm30.Column)("decimal", { precision: 12, scale: 2 })
2856
3081
  ], OrderItem.prototype, "total", 2);
2857
3082
  __decorateClass([
2858
- (0, import_typeorm28.Column)("jsonb", { nullable: true })
3083
+ (0, import_typeorm30.Column)("jsonb", { nullable: true })
2859
3084
  ], OrderItem.prototype, "metadata", 2);
2860
3085
  __decorateClass([
2861
- (0, import_typeorm28.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
3086
+ (0, import_typeorm30.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2862
3087
  ], OrderItem.prototype, "createdAt", 2);
2863
3088
  __decorateClass([
2864
- (0, import_typeorm28.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
3089
+ (0, import_typeorm30.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2865
3090
  ], OrderItem.prototype, "updatedAt", 2);
2866
3091
  __decorateClass([
2867
- (0, import_typeorm28.ManyToOne)(() => Order, (o) => o.items, { onDelete: "CASCADE" }),
2868
- (0, import_typeorm28.JoinColumn)({ name: "orderId" })
3092
+ (0, import_typeorm30.ManyToOne)(() => Order, (o) => o.items, { onDelete: "CASCADE" }),
3093
+ (0, import_typeorm30.JoinColumn)({ name: "orderId" })
2869
3094
  ], OrderItem.prototype, "order", 2);
2870
3095
  __decorateClass([
2871
- (0, import_typeorm28.ManyToOne)(() => Product, { onDelete: "CASCADE" }),
2872
- (0, import_typeorm28.JoinColumn)({ name: "productId" })
3096
+ (0, import_typeorm30.ManyToOne)(() => Product, { onDelete: "CASCADE" }),
3097
+ (0, import_typeorm30.JoinColumn)({ name: "productId" })
2873
3098
  ], OrderItem.prototype, "product", 2);
2874
3099
  OrderItem = __decorateClass([
2875
- (0, import_typeorm28.Entity)("order_items")
3100
+ (0, import_typeorm30.Entity)("order_items")
2876
3101
  ], OrderItem);
2877
3102
 
3103
+ // src/entities/knowledge-base-document.entity.ts
3104
+ var import_typeorm32 = require("typeorm");
3105
+
3106
+ // src/entities/knowledge-base-chunk.entity.ts
3107
+ var import_typeorm31 = require("typeorm");
3108
+ var KnowledgeBaseChunk = class {
3109
+ id;
3110
+ documentId;
3111
+ content;
3112
+ chunkIndex;
3113
+ createdAt;
3114
+ document;
3115
+ };
3116
+ __decorateClass([
3117
+ (0, import_typeorm31.PrimaryGeneratedColumn)()
3118
+ ], KnowledgeBaseChunk.prototype, "id", 2);
3119
+ __decorateClass([
3120
+ (0, import_typeorm31.Column)("int")
3121
+ ], KnowledgeBaseChunk.prototype, "documentId", 2);
3122
+ __decorateClass([
3123
+ (0, import_typeorm31.Column)("text")
3124
+ ], KnowledgeBaseChunk.prototype, "content", 2);
3125
+ __decorateClass([
3126
+ (0, import_typeorm31.Column)("int", { default: 0 })
3127
+ ], KnowledgeBaseChunk.prototype, "chunkIndex", 2);
3128
+ __decorateClass([
3129
+ (0, import_typeorm31.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
3130
+ ], KnowledgeBaseChunk.prototype, "createdAt", 2);
3131
+ __decorateClass([
3132
+ (0, import_typeorm31.ManyToOne)(() => KnowledgeBaseDocument, (d) => d.chunks, { onDelete: "CASCADE" }),
3133
+ (0, import_typeorm31.JoinColumn)({ name: "documentId" })
3134
+ ], KnowledgeBaseChunk.prototype, "document", 2);
3135
+ KnowledgeBaseChunk = __decorateClass([
3136
+ (0, import_typeorm31.Entity)("knowledge_base_chunks")
3137
+ ], KnowledgeBaseChunk);
3138
+
3139
+ // src/entities/knowledge-base-document.entity.ts
3140
+ var KnowledgeBaseDocument = class {
3141
+ id;
3142
+ name;
3143
+ sourceUrl;
3144
+ content;
3145
+ createdAt;
3146
+ updatedAt;
3147
+ chunks;
3148
+ };
3149
+ __decorateClass([
3150
+ (0, import_typeorm32.PrimaryGeneratedColumn)()
3151
+ ], KnowledgeBaseDocument.prototype, "id", 2);
3152
+ __decorateClass([
3153
+ (0, import_typeorm32.Column)("varchar")
3154
+ ], KnowledgeBaseDocument.prototype, "name", 2);
3155
+ __decorateClass([
3156
+ (0, import_typeorm32.Column)("varchar", { nullable: true })
3157
+ ], KnowledgeBaseDocument.prototype, "sourceUrl", 2);
3158
+ __decorateClass([
3159
+ (0, import_typeorm32.Column)("text")
3160
+ ], KnowledgeBaseDocument.prototype, "content", 2);
3161
+ __decorateClass([
3162
+ (0, import_typeorm32.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
3163
+ ], KnowledgeBaseDocument.prototype, "createdAt", 2);
3164
+ __decorateClass([
3165
+ (0, import_typeorm32.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
3166
+ ], KnowledgeBaseDocument.prototype, "updatedAt", 2);
3167
+ __decorateClass([
3168
+ (0, import_typeorm32.OneToMany)(() => KnowledgeBaseChunk, (c) => c.document)
3169
+ ], KnowledgeBaseDocument.prototype, "chunks", 2);
3170
+ KnowledgeBaseDocument = __decorateClass([
3171
+ (0, import_typeorm32.Entity)("knowledge_base_documents")
3172
+ ], KnowledgeBaseDocument);
3173
+
2878
3174
  // src/entities/index.ts
2879
3175
  var CMS_ENTITY_MAP = {
2880
3176
  users: User,
@@ -2904,7 +3200,11 @@ var CMS_ENTITY_MAP = {
2904
3200
  orders: Order,
2905
3201
  order_items: OrderItem,
2906
3202
  payments: Payment,
2907
- brands: Brand
3203
+ brands: Brand,
3204
+ knowledge_base_documents: KnowledgeBaseDocument,
3205
+ knowledge_base_chunks: KnowledgeBaseChunk,
3206
+ chat_conversations: ChatConversation,
3207
+ chat_messages: ChatMessage
2908
3208
  };
2909
3209
 
2910
3210
  // src/auth/helpers.ts
@@ -3073,7 +3373,7 @@ function getNextAuthOptions(config) {
3073
3373
  }
3074
3374
 
3075
3375
  // src/api/crud.ts
3076
- var import_typeorm29 = require("typeorm");
3376
+ var import_typeorm33 = require("typeorm");
3077
3377
  var DATE_COLUMN_TYPES = /* @__PURE__ */ new Set([
3078
3378
  "date",
3079
3379
  "datetime",
@@ -3214,10 +3514,10 @@ function createCrudHandler(dataSource, entityMap, options) {
3214
3514
  const inventory = searchParams.get("inventory")?.trim();
3215
3515
  const productWhere = {};
3216
3516
  if (statusFilter) productWhere.status = statusFilter;
3217
- if (inventory === "in_stock") productWhere.quantity = (0, import_typeorm29.MoreThan)(0);
3517
+ if (inventory === "in_stock") productWhere.quantity = (0, import_typeorm33.MoreThan)(0);
3218
3518
  if (inventory === "out_of_stock") productWhere.quantity = 0;
3219
3519
  if (search && typeof search === "string" && search.trim()) {
3220
- productWhere.name = (0, import_typeorm29.ILike)(`%${search.trim()}%`);
3520
+ productWhere.name = (0, import_typeorm33.ILike)(`%${search.trim()}%`);
3221
3521
  }
3222
3522
  const [data2, total2] = await repo2.findAndCount({
3223
3523
  where: Object.keys(productWhere).length ? productWhere : void 0,
@@ -3272,11 +3572,11 @@ function createCrudHandler(dataSource, entityMap, options) {
3272
3572
  let where = {};
3273
3573
  if (resource === "media") {
3274
3574
  const mediaWhere = {};
3275
- if (search) mediaWhere.filename = (0, import_typeorm29.ILike)(`%${search}%`);
3276
- if (typeFilter) mediaWhere.mimeType = (0, import_typeorm29.Like)(`${typeFilter}/%`);
3575
+ if (search) mediaWhere.filename = (0, import_typeorm33.ILike)(`%${search}%`);
3576
+ if (typeFilter) mediaWhere.mimeType = (0, import_typeorm33.Like)(`${typeFilter}/%`);
3277
3577
  where = Object.keys(mediaWhere).length > 0 ? mediaWhere : {};
3278
3578
  } else if (search) {
3279
- where = [{ name: (0, import_typeorm29.ILike)(`%${search}%`) }, { title: (0, import_typeorm29.ILike)(`%${search}%`) }];
3579
+ where = [{ name: (0, import_typeorm33.ILike)(`%${search}%`) }, { title: (0, import_typeorm33.ILike)(`%${search}%`) }];
3280
3580
  }
3281
3581
  const [data, total] = await repo.findAndCount({
3282
3582
  skip,
@@ -3607,7 +3907,7 @@ function createUserAuthApiRouter(config) {
3607
3907
  }
3608
3908
 
3609
3909
  // src/api/cms-handlers.ts
3610
- var import_typeorm30 = require("typeorm");
3910
+ var import_typeorm34 = require("typeorm");
3611
3911
  function createDashboardStatsHandler(config) {
3612
3912
  const { dataSource, entityMap, json, requireAuth, requirePermission } = config;
3613
3913
  return async function GET(req) {
@@ -3626,8 +3926,8 @@ function createDashboardStatsHandler(config) {
3626
3926
  repo("form_submissions")?.count() ?? 0,
3627
3927
  repo("users")?.count({ where: { deleted: false } }) ?? 0,
3628
3928
  repo("blogs")?.count({ where: { deleted: false } }) ?? 0,
3629
- repo("contacts")?.count({ where: { createdAt: (0, import_typeorm30.MoreThanOrEqual)(sevenDaysAgo) } }) ?? 0,
3630
- repo("form_submissions")?.count({ where: { createdAt: (0, import_typeorm30.MoreThanOrEqual)(sevenDaysAgo) } }) ?? 0
3929
+ repo("contacts")?.count({ where: { createdAt: (0, import_typeorm34.MoreThanOrEqual)(sevenDaysAgo) } }) ?? 0,
3930
+ repo("form_submissions")?.count({ where: { createdAt: (0, import_typeorm34.MoreThanOrEqual)(sevenDaysAgo) } }) ?? 0
3631
3931
  ]);
3632
3932
  return json({
3633
3933
  contacts: { total: contactsCount, recent: recentContacts },
@@ -3980,7 +4280,7 @@ function createUsersApiHandlers(config) {
3980
4280
  const sortField = url.searchParams.get("sortField") || "createdAt";
3981
4281
  const sortOrder = url.searchParams.get("sortOrder") === "desc" ? "DESC" : "ASC";
3982
4282
  const search = url.searchParams.get("search");
3983
- const where = search ? [{ name: (0, import_typeorm30.ILike)(`%${search}%`) }, { email: (0, import_typeorm30.ILike)(`%${search}%`) }] : {};
4283
+ const where = search ? [{ name: (0, import_typeorm34.ILike)(`%${search}%`) }, { email: (0, import_typeorm34.ILike)(`%${search}%`) }] : {};
3984
4284
  const [data, total] = await userRepo().findAndCount({
3985
4285
  skip,
3986
4286
  take: limit,
@@ -4188,6 +4488,129 @@ function createSettingsApiHandlers(config) {
4188
4488
  }
4189
4489
  };
4190
4490
  }
4491
+ var KB_CHUNK_LIMIT = 10;
4492
+ var KB_CONTEXT_MAX_CHARS = 4e3;
4493
+ function getQueryTerms(message) {
4494
+ return message.replace(/[^\w\s]/g, " ").split(/\s+/).filter((w) => w.length > 2).slice(0, 6);
4495
+ }
4496
+ function createChatHandlers(config) {
4497
+ const { dataSource, entityMap, json, getCms } = config;
4498
+ const contactRepo = () => dataSource.getRepository(entityMap.contacts);
4499
+ const convRepo = () => dataSource.getRepository(entityMap.chat_conversations);
4500
+ const msgRepo = () => dataSource.getRepository(entityMap.chat_messages);
4501
+ const chunkRepo = () => dataSource.getRepository(entityMap.knowledge_base_chunks);
4502
+ return {
4503
+ async identify(req) {
4504
+ try {
4505
+ const body = await req.json();
4506
+ const name = body?.name?.trim();
4507
+ const email = body?.email?.trim();
4508
+ if (!name || !email) return json({ error: "name and email required" }, { status: 400 });
4509
+ const repo = contactRepo();
4510
+ let contact = await repo.findOne({ where: { email, deleted: false } });
4511
+ if (!contact) {
4512
+ const created = repo.create({ name, email, phone: body.phone?.trim() || null });
4513
+ contact = await repo.save(created);
4514
+ }
4515
+ const convRepoInst = convRepo();
4516
+ const conv = await convRepoInst.save(convRepoInst.create({ contactId: contact.id }));
4517
+ return json({
4518
+ contactId: contact.id,
4519
+ conversationId: conv.id
4520
+ });
4521
+ } catch (err) {
4522
+ const message = err instanceof Error ? err.message : "Failed to identify";
4523
+ return json({ error: "Failed to identify", detail: message }, { status: 500 });
4524
+ }
4525
+ },
4526
+ async getMessages(req, conversationId) {
4527
+ try {
4528
+ const conv = await convRepo().findOne({
4529
+ where: { id: parseInt(conversationId, 10) },
4530
+ relations: ["messages"]
4531
+ });
4532
+ if (!conv) return json({ error: "Conversation not found" }, { status: 404 });
4533
+ const messages = (conv.messages ?? []).sort((a, b) => new Date(a.createdAt).getTime() - new Date(b.createdAt).getTime()).map((m) => ({ role: m.role, content: m.content }));
4534
+ return json({ messages });
4535
+ } catch {
4536
+ return json({ error: "Failed to fetch messages" }, { status: 500 });
4537
+ }
4538
+ },
4539
+ async postMessage(req) {
4540
+ try {
4541
+ const body = await req.json();
4542
+ const conversationId = body?.conversationId;
4543
+ const message = body?.message?.trim();
4544
+ if (!conversationId || !message) return json({ error: "conversationId and message required" }, { status: 400 });
4545
+ const conv = await convRepo().findOne({
4546
+ where: { id: conversationId },
4547
+ relations: ["messages"]
4548
+ });
4549
+ if (!conv) return json({ error: "Conversation not found" }, { status: 404 });
4550
+ const msgRepoInst = msgRepo();
4551
+ await msgRepoInst.save(msgRepoInst.create({ conversationId, role: "user", content: message }));
4552
+ const cms = await getCms();
4553
+ const llm = cms.getPlugin("llm");
4554
+ if (!llm?.chat) return json({ error: "LLM not configured" }, { status: 503 });
4555
+ let contextParts = [];
4556
+ const queryEmbedding = llm.embed ? await llm.embed(message) : null;
4557
+ if (queryEmbedding && queryEmbedding.length > 0) {
4558
+ const vectorStr = "[" + queryEmbedding.join(",") + "]";
4559
+ try {
4560
+ const rows = await dataSource.query(
4561
+ `SELECT id, content FROM knowledge_base_chunks WHERE embedding IS NOT NULL ORDER BY embedding <=> $1::vector LIMIT $2`,
4562
+ [vectorStr, KB_CHUNK_LIMIT]
4563
+ );
4564
+ let totalLen = 0;
4565
+ for (const r of rows) {
4566
+ const text = (r.content ?? "").trim();
4567
+ if (!text || totalLen + text.length > KB_CONTEXT_MAX_CHARS) continue;
4568
+ contextParts.push(text);
4569
+ totalLen += text.length;
4570
+ }
4571
+ } catch {
4572
+ }
4573
+ }
4574
+ if (contextParts.length === 0) {
4575
+ const terms = getQueryTerms(message);
4576
+ if (terms.length > 0) {
4577
+ const conditions = terms.map((t) => ({ content: (0, import_typeorm34.ILike)(`%${t}%`) }));
4578
+ const chunks = await chunkRepo().find({
4579
+ where: conditions,
4580
+ take: KB_CHUNK_LIMIT,
4581
+ order: { id: "ASC" }
4582
+ });
4583
+ const seen = /* @__PURE__ */ new Set();
4584
+ let totalLen = 0;
4585
+ for (const c of chunks) {
4586
+ const text = c.content.trim();
4587
+ if (seen.has(text) || totalLen + text.length > KB_CONTEXT_MAX_CHARS) continue;
4588
+ seen.add(text);
4589
+ contextParts.push(text);
4590
+ totalLen += text.length;
4591
+ }
4592
+ }
4593
+ }
4594
+ const history = (conv.messages ?? []).sort((a, b) => new Date(a.createdAt ?? 0).getTime() - new Date(b.createdAt ?? 0).getTime()).map((m) => ({ role: m.role, content: m.content }));
4595
+ const systemContent = contextParts.length > 0 ? `Use the following context about the company and its products to answer. If the answer is not in the context, say so.
4596
+
4597
+ Context:
4598
+ ${contextParts.join("\n\n")}` : "You are a helpful assistant for the company. If you do not have specific information, say so.";
4599
+ const messages = [
4600
+ { role: "system", content: systemContent },
4601
+ ...history,
4602
+ { role: "user", content: message }
4603
+ ];
4604
+ const { content } = await llm.chat(messages);
4605
+ await msgRepoInst.save(msgRepoInst.create({ conversationId, role: "assistant", content }));
4606
+ return json({ content });
4607
+ } catch (err) {
4608
+ const msg = err instanceof Error ? err.message : "";
4609
+ return json({ error: msg || "Failed to send message" }, { status: 500 });
4610
+ }
4611
+ }
4612
+ };
4613
+ }
4191
4614
 
4192
4615
  // src/api/cms-api-handler.ts
4193
4616
  var DEFAULT_EXCLUDE = /* @__PURE__ */ new Set(["users", "password_reset_tokens", "user_groups", "permissions", "comments", "form_fields", "configs"]);
@@ -4210,7 +4633,8 @@ function createCmsApiHandler(config) {
4210
4633
  usersApi,
4211
4634
  userAvatar,
4212
4635
  userProfile,
4213
- settings: settingsConfig
4636
+ settings: settingsConfig,
4637
+ chat: chatConfig
4214
4638
  } = config;
4215
4639
  const analytics = analyticsConfig ?? (getCms ? {
4216
4640
  json: config.json,
@@ -4255,6 +4679,7 @@ function createCmsApiHandler(config) {
4255
4679
  const avatarPost = userAvatar ? createUserAvatarHandler(userAvatar) : null;
4256
4680
  const profilePut = userProfile ? createUserProfileHandler(userProfile) : null;
4257
4681
  const settingsHandlers = settingsConfig ? createSettingsApiHandlers(settingsConfig) : null;
4682
+ const chatHandlers = chatConfig ? createChatHandlers(chatConfig) : null;
4258
4683
  function resolveResource(segment) {
4259
4684
  const model = pathToModel(segment);
4260
4685
  return crudResources.includes(model) ? model : segment;
@@ -4314,6 +4739,11 @@ function createCmsApiHandler(config) {
4314
4739
  if (method === "GET") return settingsHandlers.GET(req, path[1]);
4315
4740
  if (method === "PUT") return settingsHandlers.PUT(req, path[1]);
4316
4741
  }
4742
+ if (path[0] === "chat" && chatHandlers) {
4743
+ if (path.length === 2 && path[1] === "identify" && method === "POST") return chatHandlers.identify(req);
4744
+ if (path.length === 4 && path[1] === "conversations" && path[3] === "messages" && method === "GET") return chatHandlers.getMessages(req, path[2]);
4745
+ if (path.length === 2 && path[1] === "messages" && method === "POST") return chatHandlers.postMessage(req);
4746
+ }
4317
4747
  if (path.length === 0) return config.json({ error: "Not found" }, { status: 404 });
4318
4748
  const resource = resolveResource(path[0]);
4319
4749
  if (!crudResources.includes(resource)) return config.json({ error: "Invalid resource" }, { status: 400 });
@@ -4362,6 +4792,8 @@ var DEFAULT_ADMIN_NAV = [
4362
4792
  Brand,
4363
4793
  CMS_ENTITY_MAP,
4364
4794
  Category,
4795
+ ChatConversation,
4796
+ ChatMessage,
4365
4797
  Collection,
4366
4798
  Comment,
4367
4799
  Config,
@@ -4371,6 +4803,9 @@ var DEFAULT_ADMIN_NAV = [
4371
4803
  Form,
4372
4804
  FormField,
4373
4805
  FormSubmission,
4806
+ KnowledgeBaseChunk,
4807
+ KnowledgeBaseDocument,
4808
+ LlmService,
4374
4809
  Media,
4375
4810
  OPEN_ENDPOINTS,
4376
4811
  Order,
@@ -4423,6 +4858,7 @@ var DEFAULT_ADMIN_NAV = [
4423
4858
  getRequiredPermission,
4424
4859
  isOpenEndpoint,
4425
4860
  isPublicMethod,
4861
+ llmPlugin,
4426
4862
  localStoragePlugin,
4427
4863
  paymentPlugin,
4428
4864
  s3StoragePlugin,