@infuro/cms-core 1.0.6 → 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,
@@ -850,14 +856,15 @@ function s3StoragePlugin(config) {
850
856
  // src/plugins/storage/local.ts
851
857
  function getLocalStorage(config) {
852
858
  const dir = (config.dir ?? "public/uploads").replace(/\/$/, "");
853
- const publicPath = config.publicPath ?? `/${dir.replace(/^\/+/, "").replace(/\\/g, "/")}`;
859
+ const publicPath = config.publicPath ?? (dir === "public/uploads" ? "/uploads" : `/${dir.replace(/^\/+/, "").replace(/\\/g, "/")}`);
854
860
  return {
855
861
  async upload(buffer, key, _contentType) {
856
862
  const fs = await import("fs/promises");
857
863
  const path = await import("path");
864
+ const normalizedKey = key.replace(/^\/+/, "").replace(/\.\./g, "");
865
+ const fileName = normalizedKey.replace(/^uploads\//, "");
858
866
  const fullDir = path.join(process.cwd(), dir);
859
867
  await fs.mkdir(fullDir, { recursive: true });
860
- const fileName = key.replace(/^\/+/, "").replace(/\.\./g, "");
861
868
  const filePath = path.join(fullDir, fileName);
862
869
  const fileDir = path.dirname(filePath);
863
870
  await fs.mkdir(fileDir, { recursive: true });
@@ -877,6 +884,153 @@ function localStoragePlugin(config = {}) {
877
884
  };
878
885
  }
879
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
+
880
1034
  // src/lib/utils.ts
881
1035
  var import_clsx = require("clsx");
882
1036
  var import_tailwind_merge = require("tailwind-merge");
@@ -1464,7 +1618,7 @@ Blog = __decorateClass([
1464
1618
  ], Blog);
1465
1619
 
1466
1620
  // src/entities/contact.entity.ts
1467
- var import_typeorm16 = require("typeorm");
1621
+ var import_typeorm18 = require("typeorm");
1468
1622
 
1469
1623
  // src/entities/form-submission.entity.ts
1470
1624
  var import_typeorm12 = require("typeorm");
@@ -1923,6 +2077,74 @@ Payment = __decorateClass([
1923
2077
  (0, import_typeorm15.Entity)("payments")
1924
2078
  ], Payment);
1925
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
+
1926
2148
  // src/entities/contact.entity.ts
1927
2149
  var Contact = class {
1928
2150
  id;
@@ -1944,70 +2166,74 @@ var Contact = class {
1944
2166
  addresses;
1945
2167
  orders;
1946
2168
  payments;
2169
+ chatConversations;
1947
2170
  };
1948
2171
  __decorateClass([
1949
- (0, import_typeorm16.PrimaryGeneratedColumn)()
2172
+ (0, import_typeorm18.PrimaryGeneratedColumn)()
1950
2173
  ], Contact.prototype, "id", 2);
1951
2174
  __decorateClass([
1952
- (0, import_typeorm16.Column)("varchar")
2175
+ (0, import_typeorm18.Column)("varchar")
1953
2176
  ], Contact.prototype, "name", 2);
1954
2177
  __decorateClass([
1955
- (0, import_typeorm16.Column)("varchar", { unique: true })
2178
+ (0, import_typeorm18.Column)("varchar", { unique: true })
1956
2179
  ], Contact.prototype, "email", 2);
1957
2180
  __decorateClass([
1958
- (0, import_typeorm16.Column)("varchar", { nullable: true })
2181
+ (0, import_typeorm18.Column)("varchar", { nullable: true })
1959
2182
  ], Contact.prototype, "phone", 2);
1960
2183
  __decorateClass([
1961
- (0, import_typeorm16.Column)("varchar", { nullable: true })
2184
+ (0, import_typeorm18.Column)("varchar", { nullable: true })
1962
2185
  ], Contact.prototype, "type", 2);
1963
2186
  __decorateClass([
1964
- (0, import_typeorm16.Column)("varchar", { nullable: true })
2187
+ (0, import_typeorm18.Column)("varchar", { nullable: true })
1965
2188
  ], Contact.prototype, "company", 2);
1966
2189
  __decorateClass([
1967
- (0, import_typeorm16.Column)("varchar", { nullable: true })
2190
+ (0, import_typeorm18.Column)("varchar", { nullable: true })
1968
2191
  ], Contact.prototype, "taxId", 2);
1969
2192
  __decorateClass([
1970
- (0, import_typeorm16.Column)("text", { nullable: true })
2193
+ (0, import_typeorm18.Column)("text", { nullable: true })
1971
2194
  ], Contact.prototype, "notes", 2);
1972
2195
  __decorateClass([
1973
- (0, import_typeorm16.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2196
+ (0, import_typeorm18.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
1974
2197
  ], Contact.prototype, "createdAt", 2);
1975
2198
  __decorateClass([
1976
- (0, import_typeorm16.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2199
+ (0, import_typeorm18.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
1977
2200
  ], Contact.prototype, "updatedAt", 2);
1978
2201
  __decorateClass([
1979
- (0, import_typeorm16.Column)({ type: "timestamp", nullable: true })
2202
+ (0, import_typeorm18.Column)({ type: "timestamp", nullable: true })
1980
2203
  ], Contact.prototype, "deletedAt", 2);
1981
2204
  __decorateClass([
1982
- (0, import_typeorm16.Column)("boolean", { default: false })
2205
+ (0, import_typeorm18.Column)("boolean", { default: false })
1983
2206
  ], Contact.prototype, "deleted", 2);
1984
2207
  __decorateClass([
1985
- (0, import_typeorm16.Column)("int", { nullable: true })
2208
+ (0, import_typeorm18.Column)("int", { nullable: true })
1986
2209
  ], Contact.prototype, "createdBy", 2);
1987
2210
  __decorateClass([
1988
- (0, import_typeorm16.Column)("int", { nullable: true })
2211
+ (0, import_typeorm18.Column)("int", { nullable: true })
1989
2212
  ], Contact.prototype, "updatedBy", 2);
1990
2213
  __decorateClass([
1991
- (0, import_typeorm16.Column)("int", { nullable: true })
2214
+ (0, import_typeorm18.Column)("int", { nullable: true })
1992
2215
  ], Contact.prototype, "deletedBy", 2);
1993
2216
  __decorateClass([
1994
- (0, import_typeorm16.OneToMany)(() => FormSubmission, (fs) => fs.contact)
2217
+ (0, import_typeorm18.OneToMany)(() => FormSubmission, (fs) => fs.contact)
1995
2218
  ], Contact.prototype, "form_submissions", 2);
1996
2219
  __decorateClass([
1997
- (0, import_typeorm16.OneToMany)(() => Address, (a) => a.contact)
2220
+ (0, import_typeorm18.OneToMany)(() => Address, (a) => a.contact)
1998
2221
  ], Contact.prototype, "addresses", 2);
1999
2222
  __decorateClass([
2000
- (0, import_typeorm16.OneToMany)(() => Order, (o) => o.contact)
2223
+ (0, import_typeorm18.OneToMany)(() => Order, (o) => o.contact)
2001
2224
  ], Contact.prototype, "orders", 2);
2002
2225
  __decorateClass([
2003
- (0, import_typeorm16.OneToMany)(() => Payment, (p) => p.contact)
2226
+ (0, import_typeorm18.OneToMany)(() => Payment, (p) => p.contact)
2004
2227
  ], Contact.prototype, "payments", 2);
2228
+ __decorateClass([
2229
+ (0, import_typeorm18.OneToMany)(() => ChatConversation, (c) => c.contact)
2230
+ ], Contact.prototype, "chatConversations", 2);
2005
2231
  Contact = __decorateClass([
2006
- (0, import_typeorm16.Entity)("contacts")
2232
+ (0, import_typeorm18.Entity)("contacts")
2007
2233
  ], Contact);
2008
2234
 
2009
2235
  // src/entities/config.entity.ts
2010
- var import_typeorm17 = require("typeorm");
2236
+ var import_typeorm19 = require("typeorm");
2011
2237
  var Config = class {
2012
2238
  id;
2013
2239
  settings;
@@ -2024,51 +2250,51 @@ var Config = class {
2024
2250
  deletedBy;
2025
2251
  };
2026
2252
  __decorateClass([
2027
- (0, import_typeorm17.PrimaryGeneratedColumn)()
2253
+ (0, import_typeorm19.PrimaryGeneratedColumn)()
2028
2254
  ], Config.prototype, "id", 2);
2029
2255
  __decorateClass([
2030
- (0, import_typeorm17.Column)("varchar")
2256
+ (0, import_typeorm19.Column)("varchar")
2031
2257
  ], Config.prototype, "settings", 2);
2032
2258
  __decorateClass([
2033
- (0, import_typeorm17.Column)("varchar")
2259
+ (0, import_typeorm19.Column)("varchar")
2034
2260
  ], Config.prototype, "key", 2);
2035
2261
  __decorateClass([
2036
- (0, import_typeorm17.Column)("varchar")
2262
+ (0, import_typeorm19.Column)("varchar")
2037
2263
  ], Config.prototype, "value", 2);
2038
2264
  __decorateClass([
2039
- (0, import_typeorm17.Column)("varchar", { default: "private" })
2265
+ (0, import_typeorm19.Column)("varchar", { default: "private" })
2040
2266
  ], Config.prototype, "type", 2);
2041
2267
  __decorateClass([
2042
- (0, import_typeorm17.Column)("boolean", { default: false })
2268
+ (0, import_typeorm19.Column)("boolean", { default: false })
2043
2269
  ], Config.prototype, "encrypted", 2);
2044
2270
  __decorateClass([
2045
- (0, import_typeorm17.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2271
+ (0, import_typeorm19.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2046
2272
  ], Config.prototype, "createdAt", 2);
2047
2273
  __decorateClass([
2048
- (0, import_typeorm17.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2274
+ (0, import_typeorm19.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2049
2275
  ], Config.prototype, "updatedAt", 2);
2050
2276
  __decorateClass([
2051
- (0, import_typeorm17.Column)({ type: "timestamp", nullable: true })
2277
+ (0, import_typeorm19.Column)({ type: "timestamp", nullable: true })
2052
2278
  ], Config.prototype, "deletedAt", 2);
2053
2279
  __decorateClass([
2054
- (0, import_typeorm17.Column)("boolean", { default: false })
2280
+ (0, import_typeorm19.Column)("boolean", { default: false })
2055
2281
  ], Config.prototype, "deleted", 2);
2056
2282
  __decorateClass([
2057
- (0, import_typeorm17.Column)("int", { nullable: true })
2283
+ (0, import_typeorm19.Column)("int", { nullable: true })
2058
2284
  ], Config.prototype, "createdBy", 2);
2059
2285
  __decorateClass([
2060
- (0, import_typeorm17.Column)("int", { nullable: true })
2286
+ (0, import_typeorm19.Column)("int", { nullable: true })
2061
2287
  ], Config.prototype, "updatedBy", 2);
2062
2288
  __decorateClass([
2063
- (0, import_typeorm17.Column)("int", { nullable: true })
2289
+ (0, import_typeorm19.Column)("int", { nullable: true })
2064
2290
  ], Config.prototype, "deletedBy", 2);
2065
2291
  Config = __decorateClass([
2066
- (0, import_typeorm17.Entity)("configs"),
2067
- (0, import_typeorm17.Unique)(["settings", "key"])
2292
+ (0, import_typeorm19.Entity)("configs"),
2293
+ (0, import_typeorm19.Unique)(["settings", "key"])
2068
2294
  ], Config);
2069
2295
 
2070
2296
  // src/entities/media.entity.ts
2071
- var import_typeorm18 = require("typeorm");
2297
+ var import_typeorm20 = require("typeorm");
2072
2298
  var Media = class {
2073
2299
  id;
2074
2300
  filename;
@@ -2083,44 +2309,44 @@ var Media = class {
2083
2309
  deleted;
2084
2310
  };
2085
2311
  __decorateClass([
2086
- (0, import_typeorm18.PrimaryGeneratedColumn)()
2312
+ (0, import_typeorm20.PrimaryGeneratedColumn)()
2087
2313
  ], Media.prototype, "id", 2);
2088
2314
  __decorateClass([
2089
- (0, import_typeorm18.Column)("varchar")
2315
+ (0, import_typeorm20.Column)("varchar")
2090
2316
  ], Media.prototype, "filename", 2);
2091
2317
  __decorateClass([
2092
- (0, import_typeorm18.Column)("varchar")
2318
+ (0, import_typeorm20.Column)("varchar")
2093
2319
  ], Media.prototype, "url", 2);
2094
2320
  __decorateClass([
2095
- (0, import_typeorm18.Column)("varchar")
2321
+ (0, import_typeorm20.Column)("varchar")
2096
2322
  ], Media.prototype, "mimeType", 2);
2097
2323
  __decorateClass([
2098
- (0, import_typeorm18.Column)("int", { default: 0 })
2324
+ (0, import_typeorm20.Column)("int", { default: 0 })
2099
2325
  ], Media.prototype, "size", 2);
2100
2326
  __decorateClass([
2101
- (0, import_typeorm18.Column)("varchar", { nullable: true })
2327
+ (0, import_typeorm20.Column)("varchar", { nullable: true })
2102
2328
  ], Media.prototype, "alt", 2);
2103
2329
  __decorateClass([
2104
- (0, import_typeorm18.Column)("boolean", { default: false })
2330
+ (0, import_typeorm20.Column)("boolean", { default: false })
2105
2331
  ], Media.prototype, "isPublic", 2);
2106
2332
  __decorateClass([
2107
- (0, import_typeorm18.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2333
+ (0, import_typeorm20.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2108
2334
  ], Media.prototype, "createdAt", 2);
2109
2335
  __decorateClass([
2110
- (0, import_typeorm18.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2336
+ (0, import_typeorm20.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2111
2337
  ], Media.prototype, "updatedAt", 2);
2112
2338
  __decorateClass([
2113
- (0, import_typeorm18.Column)({ type: "timestamp", nullable: true })
2339
+ (0, import_typeorm20.Column)({ type: "timestamp", nullable: true })
2114
2340
  ], Media.prototype, "deletedAt", 2);
2115
2341
  __decorateClass([
2116
- (0, import_typeorm18.Column)("boolean", { default: false })
2342
+ (0, import_typeorm20.Column)("boolean", { default: false })
2117
2343
  ], Media.prototype, "deleted", 2);
2118
2344
  Media = __decorateClass([
2119
- (0, import_typeorm18.Entity)("media")
2345
+ (0, import_typeorm20.Entity)("media")
2120
2346
  ], Media);
2121
2347
 
2122
2348
  // src/entities/page.entity.ts
2123
- var import_typeorm19 = require("typeorm");
2349
+ var import_typeorm21 = require("typeorm");
2124
2350
  var Page = class {
2125
2351
  id;
2126
2352
  title;
@@ -2141,64 +2367,64 @@ var Page = class {
2141
2367
  deletedBy;
2142
2368
  };
2143
2369
  __decorateClass([
2144
- (0, import_typeorm19.PrimaryGeneratedColumn)()
2370
+ (0, import_typeorm21.PrimaryGeneratedColumn)()
2145
2371
  ], Page.prototype, "id", 2);
2146
2372
  __decorateClass([
2147
- (0, import_typeorm19.Column)("varchar")
2373
+ (0, import_typeorm21.Column)("varchar")
2148
2374
  ], Page.prototype, "title", 2);
2149
2375
  __decorateClass([
2150
- (0, import_typeorm19.Column)("varchar", { unique: true })
2376
+ (0, import_typeorm21.Column)("varchar", { unique: true })
2151
2377
  ], Page.prototype, "slug", 2);
2152
2378
  __decorateClass([
2153
- (0, import_typeorm19.Column)({ type: "jsonb", default: {} })
2379
+ (0, import_typeorm21.Column)({ type: "jsonb", default: {} })
2154
2380
  ], Page.prototype, "content", 2);
2155
2381
  __decorateClass([
2156
- (0, import_typeorm19.Column)("boolean", { default: false })
2382
+ (0, import_typeorm21.Column)("boolean", { default: false })
2157
2383
  ], Page.prototype, "published", 2);
2158
2384
  __decorateClass([
2159
- (0, import_typeorm19.Column)("varchar", { default: "default" })
2385
+ (0, import_typeorm21.Column)("varchar", { default: "default" })
2160
2386
  ], Page.prototype, "theme", 2);
2161
2387
  __decorateClass([
2162
- (0, import_typeorm19.Column)("int", { nullable: true })
2388
+ (0, import_typeorm21.Column)("int", { nullable: true })
2163
2389
  ], Page.prototype, "parentId", 2);
2164
2390
  __decorateClass([
2165
- (0, import_typeorm19.ManyToOne)(() => Page, { onDelete: "SET NULL" }),
2166
- (0, import_typeorm19.JoinColumn)({ name: "parentId" })
2391
+ (0, import_typeorm21.ManyToOne)(() => Page, { onDelete: "SET NULL" }),
2392
+ (0, import_typeorm21.JoinColumn)({ name: "parentId" })
2167
2393
  ], Page.prototype, "parent", 2);
2168
2394
  __decorateClass([
2169
- (0, import_typeorm19.Column)("int", { nullable: true })
2395
+ (0, import_typeorm21.Column)("int", { nullable: true })
2170
2396
  ], Page.prototype, "seoId", 2);
2171
2397
  __decorateClass([
2172
- (0, import_typeorm19.ManyToOne)(() => Seo, { onDelete: "SET NULL" }),
2173
- (0, import_typeorm19.JoinColumn)({ name: "seoId" })
2398
+ (0, import_typeorm21.ManyToOne)(() => Seo, { onDelete: "SET NULL" }),
2399
+ (0, import_typeorm21.JoinColumn)({ name: "seoId" })
2174
2400
  ], Page.prototype, "seo", 2);
2175
2401
  __decorateClass([
2176
- (0, import_typeorm19.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2402
+ (0, import_typeorm21.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2177
2403
  ], Page.prototype, "createdAt", 2);
2178
2404
  __decorateClass([
2179
- (0, import_typeorm19.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2405
+ (0, import_typeorm21.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2180
2406
  ], Page.prototype, "updatedAt", 2);
2181
2407
  __decorateClass([
2182
- (0, import_typeorm19.Column)({ type: "timestamp", nullable: true })
2408
+ (0, import_typeorm21.Column)({ type: "timestamp", nullable: true })
2183
2409
  ], Page.prototype, "deletedAt", 2);
2184
2410
  __decorateClass([
2185
- (0, import_typeorm19.Column)("boolean", { default: false })
2411
+ (0, import_typeorm21.Column)("boolean", { default: false })
2186
2412
  ], Page.prototype, "deleted", 2);
2187
2413
  __decorateClass([
2188
- (0, import_typeorm19.Column)("int", { nullable: true })
2414
+ (0, import_typeorm21.Column)("int", { nullable: true })
2189
2415
  ], Page.prototype, "createdBy", 2);
2190
2416
  __decorateClass([
2191
- (0, import_typeorm19.Column)("int", { nullable: true })
2417
+ (0, import_typeorm21.Column)("int", { nullable: true })
2192
2418
  ], Page.prototype, "updatedBy", 2);
2193
2419
  __decorateClass([
2194
- (0, import_typeorm19.Column)("int", { nullable: true })
2420
+ (0, import_typeorm21.Column)("int", { nullable: true })
2195
2421
  ], Page.prototype, "deletedBy", 2);
2196
2422
  Page = __decorateClass([
2197
- (0, import_typeorm19.Entity)("pages")
2423
+ (0, import_typeorm21.Entity)("pages")
2198
2424
  ], Page);
2199
2425
 
2200
2426
  // src/entities/product-category.entity.ts
2201
- var import_typeorm20 = require("typeorm");
2427
+ var import_typeorm22 = require("typeorm");
2202
2428
  var ProductCategory = class {
2203
2429
  id;
2204
2430
  name;
@@ -2222,75 +2448,75 @@ var ProductCategory = class {
2222
2448
  collections;
2223
2449
  };
2224
2450
  __decorateClass([
2225
- (0, import_typeorm20.PrimaryGeneratedColumn)()
2451
+ (0, import_typeorm22.PrimaryGeneratedColumn)()
2226
2452
  ], ProductCategory.prototype, "id", 2);
2227
2453
  __decorateClass([
2228
- (0, import_typeorm20.Column)("varchar")
2454
+ (0, import_typeorm22.Column)("varchar")
2229
2455
  ], ProductCategory.prototype, "name", 2);
2230
2456
  __decorateClass([
2231
- (0, import_typeorm20.Column)("varchar", { unique: true })
2457
+ (0, import_typeorm22.Column)("varchar", { unique: true })
2232
2458
  ], ProductCategory.prototype, "slug", 2);
2233
2459
  __decorateClass([
2234
- (0, import_typeorm20.Column)("int", { nullable: true })
2460
+ (0, import_typeorm22.Column)("int", { nullable: true })
2235
2461
  ], ProductCategory.prototype, "parentId", 2);
2236
2462
  __decorateClass([
2237
- (0, import_typeorm20.Column)("varchar", { nullable: true })
2463
+ (0, import_typeorm22.Column)("varchar", { nullable: true })
2238
2464
  ], ProductCategory.prototype, "image", 2);
2239
2465
  __decorateClass([
2240
- (0, import_typeorm20.Column)("text", { nullable: true })
2466
+ (0, import_typeorm22.Column)("text", { nullable: true })
2241
2467
  ], ProductCategory.prototype, "description", 2);
2242
2468
  __decorateClass([
2243
- (0, import_typeorm20.Column)("jsonb", { nullable: true })
2469
+ (0, import_typeorm22.Column)("jsonb", { nullable: true })
2244
2470
  ], ProductCategory.prototype, "metadata", 2);
2245
2471
  __decorateClass([
2246
- (0, import_typeorm20.Column)("boolean", { default: true })
2472
+ (0, import_typeorm22.Column)("boolean", { default: true })
2247
2473
  ], ProductCategory.prototype, "active", 2);
2248
2474
  __decorateClass([
2249
- (0, import_typeorm20.Column)("int", { default: 0 })
2475
+ (0, import_typeorm22.Column)("int", { default: 0 })
2250
2476
  ], ProductCategory.prototype, "sortOrder", 2);
2251
2477
  __decorateClass([
2252
- (0, import_typeorm20.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2478
+ (0, import_typeorm22.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2253
2479
  ], ProductCategory.prototype, "createdAt", 2);
2254
2480
  __decorateClass([
2255
- (0, import_typeorm20.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2481
+ (0, import_typeorm22.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2256
2482
  ], ProductCategory.prototype, "updatedAt", 2);
2257
2483
  __decorateClass([
2258
- (0, import_typeorm20.Column)({ type: "timestamp", nullable: true })
2484
+ (0, import_typeorm22.Column)({ type: "timestamp", nullable: true })
2259
2485
  ], ProductCategory.prototype, "deletedAt", 2);
2260
2486
  __decorateClass([
2261
- (0, import_typeorm20.Column)("boolean", { default: false })
2487
+ (0, import_typeorm22.Column)("boolean", { default: false })
2262
2488
  ], ProductCategory.prototype, "deleted", 2);
2263
2489
  __decorateClass([
2264
- (0, import_typeorm20.Column)("int", { nullable: true })
2490
+ (0, import_typeorm22.Column)("int", { nullable: true })
2265
2491
  ], ProductCategory.prototype, "createdBy", 2);
2266
2492
  __decorateClass([
2267
- (0, import_typeorm20.Column)("int", { nullable: true })
2493
+ (0, import_typeorm22.Column)("int", { nullable: true })
2268
2494
  ], ProductCategory.prototype, "updatedBy", 2);
2269
2495
  __decorateClass([
2270
- (0, import_typeorm20.Column)("int", { nullable: true })
2496
+ (0, import_typeorm22.Column)("int", { nullable: true })
2271
2497
  ], ProductCategory.prototype, "deletedBy", 2);
2272
2498
  __decorateClass([
2273
- (0, import_typeorm20.ManyToOne)(() => ProductCategory, (c) => c.children, { onDelete: "SET NULL" }),
2274
- (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" })
2275
2501
  ], ProductCategory.prototype, "parent", 2);
2276
2502
  __decorateClass([
2277
- (0, import_typeorm20.OneToMany)(() => ProductCategory, (c) => c.parent)
2503
+ (0, import_typeorm22.OneToMany)(() => ProductCategory, (c) => c.parent)
2278
2504
  ], ProductCategory.prototype, "children", 2);
2279
2505
  __decorateClass([
2280
- (0, import_typeorm20.OneToMany)("Product", "category")
2506
+ (0, import_typeorm22.OneToMany)("Product", "category")
2281
2507
  ], ProductCategory.prototype, "products", 2);
2282
2508
  __decorateClass([
2283
- (0, import_typeorm20.OneToMany)("Collection", "category")
2509
+ (0, import_typeorm22.OneToMany)("Collection", "category")
2284
2510
  ], ProductCategory.prototype, "collections", 2);
2285
2511
  ProductCategory = __decorateClass([
2286
- (0, import_typeorm20.Entity)("product_categories")
2512
+ (0, import_typeorm22.Entity)("product_categories")
2287
2513
  ], ProductCategory);
2288
2514
 
2289
2515
  // src/entities/collection.entity.ts
2290
- var import_typeorm22 = require("typeorm");
2516
+ var import_typeorm24 = require("typeorm");
2291
2517
 
2292
2518
  // src/entities/brand.entity.ts
2293
- var import_typeorm21 = require("typeorm");
2519
+ var import_typeorm23 = require("typeorm");
2294
2520
  var Brand = class {
2295
2521
  id;
2296
2522
  name;
@@ -2313,65 +2539,65 @@ var Brand = class {
2313
2539
  collections;
2314
2540
  };
2315
2541
  __decorateClass([
2316
- (0, import_typeorm21.PrimaryGeneratedColumn)()
2542
+ (0, import_typeorm23.PrimaryGeneratedColumn)()
2317
2543
  ], Brand.prototype, "id", 2);
2318
2544
  __decorateClass([
2319
- (0, import_typeorm21.Column)("varchar")
2545
+ (0, import_typeorm23.Column)("varchar")
2320
2546
  ], Brand.prototype, "name", 2);
2321
2547
  __decorateClass([
2322
- (0, import_typeorm21.Column)("varchar", { unique: true })
2548
+ (0, import_typeorm23.Column)("varchar", { unique: true })
2323
2549
  ], Brand.prototype, "slug", 2);
2324
2550
  __decorateClass([
2325
- (0, import_typeorm21.Column)("varchar", { nullable: true })
2551
+ (0, import_typeorm23.Column)("varchar", { nullable: true })
2326
2552
  ], Brand.prototype, "logo", 2);
2327
2553
  __decorateClass([
2328
- (0, import_typeorm21.Column)("jsonb", { nullable: true })
2554
+ (0, import_typeorm23.Column)("jsonb", { nullable: true })
2329
2555
  ], Brand.prototype, "metadata", 2);
2330
2556
  __decorateClass([
2331
- (0, import_typeorm21.Column)("text", { nullable: true })
2557
+ (0, import_typeorm23.Column)("text", { nullable: true })
2332
2558
  ], Brand.prototype, "description", 2);
2333
2559
  __decorateClass([
2334
- (0, import_typeorm21.Column)("boolean", { default: true })
2560
+ (0, import_typeorm23.Column)("boolean", { default: true })
2335
2561
  ], Brand.prototype, "active", 2);
2336
2562
  __decorateClass([
2337
- (0, import_typeorm21.Column)("int", { default: 0 })
2563
+ (0, import_typeorm23.Column)("int", { default: 0 })
2338
2564
  ], Brand.prototype, "sortOrder", 2);
2339
2565
  __decorateClass([
2340
- (0, import_typeorm21.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2566
+ (0, import_typeorm23.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2341
2567
  ], Brand.prototype, "createdAt", 2);
2342
2568
  __decorateClass([
2343
- (0, import_typeorm21.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2569
+ (0, import_typeorm23.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2344
2570
  ], Brand.prototype, "updatedAt", 2);
2345
2571
  __decorateClass([
2346
- (0, import_typeorm21.Column)({ type: "timestamp", nullable: true })
2572
+ (0, import_typeorm23.Column)({ type: "timestamp", nullable: true })
2347
2573
  ], Brand.prototype, "deletedAt", 2);
2348
2574
  __decorateClass([
2349
- (0, import_typeorm21.Column)("boolean", { default: false })
2575
+ (0, import_typeorm23.Column)("boolean", { default: false })
2350
2576
  ], Brand.prototype, "deleted", 2);
2351
2577
  __decorateClass([
2352
- (0, import_typeorm21.Column)("int", { nullable: true })
2578
+ (0, import_typeorm23.Column)("int", { nullable: true })
2353
2579
  ], Brand.prototype, "createdBy", 2);
2354
2580
  __decorateClass([
2355
- (0, import_typeorm21.Column)("int", { nullable: true })
2581
+ (0, import_typeorm23.Column)("int", { nullable: true })
2356
2582
  ], Brand.prototype, "updatedBy", 2);
2357
2583
  __decorateClass([
2358
- (0, import_typeorm21.Column)("int", { nullable: true })
2584
+ (0, import_typeorm23.Column)("int", { nullable: true })
2359
2585
  ], Brand.prototype, "deletedBy", 2);
2360
2586
  __decorateClass([
2361
- (0, import_typeorm21.Column)("int", { nullable: true })
2587
+ (0, import_typeorm23.Column)("int", { nullable: true })
2362
2588
  ], Brand.prototype, "seoId", 2);
2363
2589
  __decorateClass([
2364
- (0, import_typeorm21.ManyToOne)(() => Seo, { onDelete: "SET NULL" }),
2365
- (0, import_typeorm21.JoinColumn)({ name: "seoId" })
2590
+ (0, import_typeorm23.ManyToOne)(() => Seo, { onDelete: "SET NULL" }),
2591
+ (0, import_typeorm23.JoinColumn)({ name: "seoId" })
2366
2592
  ], Brand.prototype, "seo", 2);
2367
2593
  __decorateClass([
2368
- (0, import_typeorm21.OneToMany)("Product", "brand")
2594
+ (0, import_typeorm23.OneToMany)("Product", "brand")
2369
2595
  ], Brand.prototype, "products", 2);
2370
2596
  __decorateClass([
2371
- (0, import_typeorm21.OneToMany)("Collection", "brand")
2597
+ (0, import_typeorm23.OneToMany)("Collection", "brand")
2372
2598
  ], Brand.prototype, "collections", 2);
2373
2599
  Brand = __decorateClass([
2374
- (0, import_typeorm21.Entity)("brands")
2600
+ (0, import_typeorm23.Entity)("brands")
2375
2601
  ], Brand);
2376
2602
 
2377
2603
  // src/entities/collection.entity.ts
@@ -2400,80 +2626,80 @@ var Collection = class {
2400
2626
  products;
2401
2627
  };
2402
2628
  __decorateClass([
2403
- (0, import_typeorm22.PrimaryGeneratedColumn)()
2629
+ (0, import_typeorm24.PrimaryGeneratedColumn)()
2404
2630
  ], Collection.prototype, "id", 2);
2405
2631
  __decorateClass([
2406
- (0, import_typeorm22.Column)("int", { nullable: true })
2632
+ (0, import_typeorm24.Column)("int", { nullable: true })
2407
2633
  ], Collection.prototype, "categoryId", 2);
2408
2634
  __decorateClass([
2409
- (0, import_typeorm22.Column)("int", { nullable: true })
2635
+ (0, import_typeorm24.Column)("int", { nullable: true })
2410
2636
  ], Collection.prototype, "brandId", 2);
2411
2637
  __decorateClass([
2412
- (0, import_typeorm22.Column)("varchar")
2638
+ (0, import_typeorm24.Column)("varchar")
2413
2639
  ], Collection.prototype, "name", 2);
2414
2640
  __decorateClass([
2415
- (0, import_typeorm22.Column)("varchar", { unique: true })
2641
+ (0, import_typeorm24.Column)("varchar", { unique: true })
2416
2642
  ], Collection.prototype, "slug", 2);
2417
2643
  __decorateClass([
2418
- (0, import_typeorm22.Column)("text", { nullable: true })
2644
+ (0, import_typeorm24.Column)("text", { nullable: true })
2419
2645
  ], Collection.prototype, "description", 2);
2420
2646
  __decorateClass([
2421
- (0, import_typeorm22.Column)("varchar", { nullable: true })
2647
+ (0, import_typeorm24.Column)("varchar", { nullable: true })
2422
2648
  ], Collection.prototype, "image", 2);
2423
2649
  __decorateClass([
2424
- (0, import_typeorm22.Column)("jsonb", { nullable: true })
2650
+ (0, import_typeorm24.Column)("jsonb", { nullable: true })
2425
2651
  ], Collection.prototype, "metadata", 2);
2426
2652
  __decorateClass([
2427
- (0, import_typeorm22.Column)("boolean", { default: true })
2653
+ (0, import_typeorm24.Column)("boolean", { default: true })
2428
2654
  ], Collection.prototype, "active", 2);
2429
2655
  __decorateClass([
2430
- (0, import_typeorm22.Column)("int", { default: 0 })
2656
+ (0, import_typeorm24.Column)("int", { default: 0 })
2431
2657
  ], Collection.prototype, "sortOrder", 2);
2432
2658
  __decorateClass([
2433
- (0, import_typeorm22.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2659
+ (0, import_typeorm24.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2434
2660
  ], Collection.prototype, "createdAt", 2);
2435
2661
  __decorateClass([
2436
- (0, import_typeorm22.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2662
+ (0, import_typeorm24.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2437
2663
  ], Collection.prototype, "updatedAt", 2);
2438
2664
  __decorateClass([
2439
- (0, import_typeorm22.Column)({ type: "timestamp", nullable: true })
2665
+ (0, import_typeorm24.Column)({ type: "timestamp", nullable: true })
2440
2666
  ], Collection.prototype, "deletedAt", 2);
2441
2667
  __decorateClass([
2442
- (0, import_typeorm22.Column)("boolean", { default: false })
2668
+ (0, import_typeorm24.Column)("boolean", { default: false })
2443
2669
  ], Collection.prototype, "deleted", 2);
2444
2670
  __decorateClass([
2445
- (0, import_typeorm22.Column)("int", { nullable: true })
2671
+ (0, import_typeorm24.Column)("int", { nullable: true })
2446
2672
  ], Collection.prototype, "createdBy", 2);
2447
2673
  __decorateClass([
2448
- (0, import_typeorm22.Column)("int", { nullable: true })
2674
+ (0, import_typeorm24.Column)("int", { nullable: true })
2449
2675
  ], Collection.prototype, "updatedBy", 2);
2450
2676
  __decorateClass([
2451
- (0, import_typeorm22.Column)("int", { nullable: true })
2677
+ (0, import_typeorm24.Column)("int", { nullable: true })
2452
2678
  ], Collection.prototype, "deletedBy", 2);
2453
2679
  __decorateClass([
2454
- (0, import_typeorm22.Column)("int", { nullable: true })
2680
+ (0, import_typeorm24.Column)("int", { nullable: true })
2455
2681
  ], Collection.prototype, "seoId", 2);
2456
2682
  __decorateClass([
2457
- (0, import_typeorm22.ManyToOne)(() => Seo, { onDelete: "SET NULL" }),
2458
- (0, import_typeorm22.JoinColumn)({ name: "seoId" })
2683
+ (0, import_typeorm24.ManyToOne)(() => Seo, { onDelete: "SET NULL" }),
2684
+ (0, import_typeorm24.JoinColumn)({ name: "seoId" })
2459
2685
  ], Collection.prototype, "seo", 2);
2460
2686
  __decorateClass([
2461
- (0, import_typeorm22.ManyToOne)(() => ProductCategory, (c) => c.collections, { onDelete: "SET NULL" }),
2462
- (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" })
2463
2689
  ], Collection.prototype, "category", 2);
2464
2690
  __decorateClass([
2465
- (0, import_typeorm22.ManyToOne)(() => Brand, (b) => b.collections, { onDelete: "SET NULL" }),
2466
- (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" })
2467
2693
  ], Collection.prototype, "brand", 2);
2468
2694
  __decorateClass([
2469
- (0, import_typeorm22.OneToMany)("Product", "collection")
2695
+ (0, import_typeorm24.OneToMany)("Product", "collection")
2470
2696
  ], Collection.prototype, "products", 2);
2471
2697
  Collection = __decorateClass([
2472
- (0, import_typeorm22.Entity)("collections")
2698
+ (0, import_typeorm24.Entity)("collections")
2473
2699
  ], Collection);
2474
2700
 
2475
2701
  // src/entities/product.entity.ts
2476
- var import_typeorm23 = require("typeorm");
2702
+ var import_typeorm25 = require("typeorm");
2477
2703
  var Product = class {
2478
2704
  id;
2479
2705
  collectionId;
@@ -2504,96 +2730,96 @@ var Product = class {
2504
2730
  taxes;
2505
2731
  };
2506
2732
  __decorateClass([
2507
- (0, import_typeorm23.PrimaryGeneratedColumn)()
2733
+ (0, import_typeorm25.PrimaryGeneratedColumn)()
2508
2734
  ], Product.prototype, "id", 2);
2509
2735
  __decorateClass([
2510
- (0, import_typeorm23.Column)("int", { nullable: true })
2736
+ (0, import_typeorm25.Column)("int", { nullable: true })
2511
2737
  ], Product.prototype, "collectionId", 2);
2512
2738
  __decorateClass([
2513
- (0, import_typeorm23.Column)("int", { nullable: true })
2739
+ (0, import_typeorm25.Column)("int", { nullable: true })
2514
2740
  ], Product.prototype, "brandId", 2);
2515
2741
  __decorateClass([
2516
- (0, import_typeorm23.Column)("int", { nullable: true })
2742
+ (0, import_typeorm25.Column)("int", { nullable: true })
2517
2743
  ], Product.prototype, "categoryId", 2);
2518
2744
  __decorateClass([
2519
- (0, import_typeorm23.Column)("varchar", { nullable: true })
2745
+ (0, import_typeorm25.Column)("varchar", { nullable: true })
2520
2746
  ], Product.prototype, "sku", 2);
2521
2747
  __decorateClass([
2522
- (0, import_typeorm23.Column)("varchar", { unique: true, nullable: true })
2748
+ (0, import_typeorm25.Column)("varchar", { unique: true, nullable: true })
2523
2749
  ], Product.prototype, "slug", 2);
2524
2750
  __decorateClass([
2525
- (0, import_typeorm23.Column)("varchar", { nullable: true })
2751
+ (0, import_typeorm25.Column)("varchar", { nullable: true })
2526
2752
  ], Product.prototype, "name", 2);
2527
2753
  __decorateClass([
2528
- (0, import_typeorm23.Column)("decimal", { precision: 12, scale: 2 })
2754
+ (0, import_typeorm25.Column)("decimal", { precision: 12, scale: 2 })
2529
2755
  ], Product.prototype, "price", 2);
2530
2756
  __decorateClass([
2531
- (0, import_typeorm23.Column)("decimal", { precision: 12, scale: 2, nullable: true })
2757
+ (0, import_typeorm25.Column)("decimal", { precision: 12, scale: 2, nullable: true })
2532
2758
  ], Product.prototype, "compareAtPrice", 2);
2533
2759
  __decorateClass([
2534
- (0, import_typeorm23.Column)("int", { default: 0 })
2760
+ (0, import_typeorm25.Column)("int", { default: 0 })
2535
2761
  ], Product.prototype, "quantity", 2);
2536
2762
  __decorateClass([
2537
- (0, import_typeorm23.Column)("varchar", { default: "draft" })
2763
+ (0, import_typeorm25.Column)("varchar", { default: "draft" })
2538
2764
  ], Product.prototype, "status", 2);
2539
2765
  __decorateClass([
2540
- (0, import_typeorm23.Column)("boolean", { default: false })
2766
+ (0, import_typeorm25.Column)("boolean", { default: false })
2541
2767
  ], Product.prototype, "featured", 2);
2542
2768
  __decorateClass([
2543
- (0, import_typeorm23.Column)("jsonb", { nullable: true })
2769
+ (0, import_typeorm25.Column)("jsonb", { nullable: true })
2544
2770
  ], Product.prototype, "metadata", 2);
2545
2771
  __decorateClass([
2546
- (0, import_typeorm23.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2772
+ (0, import_typeorm25.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2547
2773
  ], Product.prototype, "createdAt", 2);
2548
2774
  __decorateClass([
2549
- (0, import_typeorm23.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2775
+ (0, import_typeorm25.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2550
2776
  ], Product.prototype, "updatedAt", 2);
2551
2777
  __decorateClass([
2552
- (0, import_typeorm23.Column)({ type: "timestamp", nullable: true })
2778
+ (0, import_typeorm25.Column)({ type: "timestamp", nullable: true })
2553
2779
  ], Product.prototype, "deletedAt", 2);
2554
2780
  __decorateClass([
2555
- (0, import_typeorm23.Column)("boolean", { default: false })
2781
+ (0, import_typeorm25.Column)("boolean", { default: false })
2556
2782
  ], Product.prototype, "deleted", 2);
2557
2783
  __decorateClass([
2558
- (0, import_typeorm23.Column)("int", { nullable: true })
2784
+ (0, import_typeorm25.Column)("int", { nullable: true })
2559
2785
  ], Product.prototype, "createdBy", 2);
2560
2786
  __decorateClass([
2561
- (0, import_typeorm23.Column)("int", { nullable: true })
2787
+ (0, import_typeorm25.Column)("int", { nullable: true })
2562
2788
  ], Product.prototype, "updatedBy", 2);
2563
2789
  __decorateClass([
2564
- (0, import_typeorm23.Column)("int", { nullable: true })
2790
+ (0, import_typeorm25.Column)("int", { nullable: true })
2565
2791
  ], Product.prototype, "deletedBy", 2);
2566
2792
  __decorateClass([
2567
- (0, import_typeorm23.Column)("int", { nullable: true })
2793
+ (0, import_typeorm25.Column)("int", { nullable: true })
2568
2794
  ], Product.prototype, "seoId", 2);
2569
2795
  __decorateClass([
2570
- (0, import_typeorm23.ManyToOne)(() => Seo, { onDelete: "SET NULL" }),
2571
- (0, import_typeorm23.JoinColumn)({ name: "seoId" })
2796
+ (0, import_typeorm25.ManyToOne)(() => Seo, { onDelete: "SET NULL" }),
2797
+ (0, import_typeorm25.JoinColumn)({ name: "seoId" })
2572
2798
  ], Product.prototype, "seo", 2);
2573
2799
  __decorateClass([
2574
- (0, import_typeorm23.ManyToOne)(() => Collection, (c) => c.products, { onDelete: "SET NULL" }),
2575
- (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" })
2576
2802
  ], Product.prototype, "collection", 2);
2577
2803
  __decorateClass([
2578
- (0, import_typeorm23.ManyToOne)(() => Brand, (b) => b.products, { onDelete: "SET NULL" }),
2579
- (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" })
2580
2806
  ], Product.prototype, "brand", 2);
2581
2807
  __decorateClass([
2582
- (0, import_typeorm23.ManyToOne)(() => ProductCategory, (c) => c.products, { onDelete: "SET NULL" }),
2583
- (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" })
2584
2810
  ], Product.prototype, "category", 2);
2585
2811
  __decorateClass([
2586
- (0, import_typeorm23.OneToMany)("ProductAttribute", "product")
2812
+ (0, import_typeorm25.OneToMany)("ProductAttribute", "product")
2587
2813
  ], Product.prototype, "attributes", 2);
2588
2814
  __decorateClass([
2589
- (0, import_typeorm23.OneToMany)("ProductTax", "product")
2815
+ (0, import_typeorm25.OneToMany)("ProductTax", "product")
2590
2816
  ], Product.prototype, "taxes", 2);
2591
2817
  Product = __decorateClass([
2592
- (0, import_typeorm23.Entity)("products")
2818
+ (0, import_typeorm25.Entity)("products")
2593
2819
  ], Product);
2594
2820
 
2595
2821
  // src/entities/attribute.entity.ts
2596
- var import_typeorm24 = require("typeorm");
2822
+ var import_typeorm26 = require("typeorm");
2597
2823
  var Attribute = class {
2598
2824
  id;
2599
2825
  name;
@@ -2612,56 +2838,56 @@ var Attribute = class {
2612
2838
  deletedBy;
2613
2839
  };
2614
2840
  __decorateClass([
2615
- (0, import_typeorm24.PrimaryGeneratedColumn)()
2841
+ (0, import_typeorm26.PrimaryGeneratedColumn)()
2616
2842
  ], Attribute.prototype, "id", 2);
2617
2843
  __decorateClass([
2618
- (0, import_typeorm24.Column)("varchar")
2844
+ (0, import_typeorm26.Column)("varchar")
2619
2845
  ], Attribute.prototype, "name", 2);
2620
2846
  __decorateClass([
2621
- (0, import_typeorm24.Column)("varchar", { unique: true })
2847
+ (0, import_typeorm26.Column)("varchar", { unique: true })
2622
2848
  ], Attribute.prototype, "slug", 2);
2623
2849
  __decorateClass([
2624
- (0, import_typeorm24.Column)("varchar", { default: "text" })
2850
+ (0, import_typeorm26.Column)("varchar", { default: "text" })
2625
2851
  ], Attribute.prototype, "type", 2);
2626
2852
  __decorateClass([
2627
- (0, import_typeorm24.Column)("jsonb", { nullable: true })
2853
+ (0, import_typeorm26.Column)("jsonb", { nullable: true })
2628
2854
  ], Attribute.prototype, "options", 2);
2629
2855
  __decorateClass([
2630
- (0, import_typeorm24.Column)("jsonb", { nullable: true })
2856
+ (0, import_typeorm26.Column)("jsonb", { nullable: true })
2631
2857
  ], Attribute.prototype, "metadata", 2);
2632
2858
  __decorateClass([
2633
- (0, import_typeorm24.Column)("boolean", { default: true })
2859
+ (0, import_typeorm26.Column)("boolean", { default: true })
2634
2860
  ], Attribute.prototype, "active", 2);
2635
2861
  __decorateClass([
2636
- (0, import_typeorm24.Column)("int", { default: 0 })
2862
+ (0, import_typeorm26.Column)("int", { default: 0 })
2637
2863
  ], Attribute.prototype, "sortOrder", 2);
2638
2864
  __decorateClass([
2639
- (0, import_typeorm24.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2865
+ (0, import_typeorm26.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2640
2866
  ], Attribute.prototype, "createdAt", 2);
2641
2867
  __decorateClass([
2642
- (0, import_typeorm24.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2868
+ (0, import_typeorm26.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2643
2869
  ], Attribute.prototype, "updatedAt", 2);
2644
2870
  __decorateClass([
2645
- (0, import_typeorm24.Column)({ type: "timestamp", nullable: true })
2871
+ (0, import_typeorm26.Column)({ type: "timestamp", nullable: true })
2646
2872
  ], Attribute.prototype, "deletedAt", 2);
2647
2873
  __decorateClass([
2648
- (0, import_typeorm24.Column)("boolean", { default: false })
2874
+ (0, import_typeorm26.Column)("boolean", { default: false })
2649
2875
  ], Attribute.prototype, "deleted", 2);
2650
2876
  __decorateClass([
2651
- (0, import_typeorm24.Column)("int", { nullable: true })
2877
+ (0, import_typeorm26.Column)("int", { nullable: true })
2652
2878
  ], Attribute.prototype, "createdBy", 2);
2653
2879
  __decorateClass([
2654
- (0, import_typeorm24.Column)("int", { nullable: true })
2880
+ (0, import_typeorm26.Column)("int", { nullable: true })
2655
2881
  ], Attribute.prototype, "updatedBy", 2);
2656
2882
  __decorateClass([
2657
- (0, import_typeorm24.Column)("int", { nullable: true })
2883
+ (0, import_typeorm26.Column)("int", { nullable: true })
2658
2884
  ], Attribute.prototype, "deletedBy", 2);
2659
2885
  Attribute = __decorateClass([
2660
- (0, import_typeorm24.Entity)("attributes")
2886
+ (0, import_typeorm26.Entity)("attributes")
2661
2887
  ], Attribute);
2662
2888
 
2663
2889
  // src/entities/product-attribute.entity.ts
2664
- var import_typeorm25 = require("typeorm");
2890
+ var import_typeorm27 = require("typeorm");
2665
2891
  var ProductAttribute = class {
2666
2892
  id;
2667
2893
  productId;
@@ -2674,40 +2900,40 @@ var ProductAttribute = class {
2674
2900
  attribute;
2675
2901
  };
2676
2902
  __decorateClass([
2677
- (0, import_typeorm25.PrimaryGeneratedColumn)()
2903
+ (0, import_typeorm27.PrimaryGeneratedColumn)()
2678
2904
  ], ProductAttribute.prototype, "id", 2);
2679
2905
  __decorateClass([
2680
- (0, import_typeorm25.Column)("int")
2906
+ (0, import_typeorm27.Column)("int")
2681
2907
  ], ProductAttribute.prototype, "productId", 2);
2682
2908
  __decorateClass([
2683
- (0, import_typeorm25.Column)("int")
2909
+ (0, import_typeorm27.Column)("int")
2684
2910
  ], ProductAttribute.prototype, "attributeId", 2);
2685
2911
  __decorateClass([
2686
- (0, import_typeorm25.Column)("varchar")
2912
+ (0, import_typeorm27.Column)("varchar")
2687
2913
  ], ProductAttribute.prototype, "value", 2);
2688
2914
  __decorateClass([
2689
- (0, import_typeorm25.Column)("jsonb", { nullable: true })
2915
+ (0, import_typeorm27.Column)("jsonb", { nullable: true })
2690
2916
  ], ProductAttribute.prototype, "metadata", 2);
2691
2917
  __decorateClass([
2692
- (0, import_typeorm25.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2918
+ (0, import_typeorm27.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2693
2919
  ], ProductAttribute.prototype, "createdAt", 2);
2694
2920
  __decorateClass([
2695
- (0, import_typeorm25.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2921
+ (0, import_typeorm27.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2696
2922
  ], ProductAttribute.prototype, "updatedAt", 2);
2697
2923
  __decorateClass([
2698
- (0, import_typeorm25.ManyToOne)(() => Product, (p) => p.attributes, { onDelete: "CASCADE" }),
2699
- (0, import_typeorm25.JoinColumn)({ name: "productId" })
2924
+ (0, import_typeorm27.ManyToOne)(() => Product, (p) => p.attributes, { onDelete: "CASCADE" }),
2925
+ (0, import_typeorm27.JoinColumn)({ name: "productId" })
2700
2926
  ], ProductAttribute.prototype, "product", 2);
2701
2927
  __decorateClass([
2702
- (0, import_typeorm25.ManyToOne)(() => Attribute, { onDelete: "CASCADE" }),
2703
- (0, import_typeorm25.JoinColumn)({ name: "attributeId" })
2928
+ (0, import_typeorm27.ManyToOne)(() => Attribute, { onDelete: "CASCADE" }),
2929
+ (0, import_typeorm27.JoinColumn)({ name: "attributeId" })
2704
2930
  ], ProductAttribute.prototype, "attribute", 2);
2705
2931
  ProductAttribute = __decorateClass([
2706
- (0, import_typeorm25.Entity)("product_attributes")
2932
+ (0, import_typeorm27.Entity)("product_attributes")
2707
2933
  ], ProductAttribute);
2708
2934
 
2709
2935
  // src/entities/tax.entity.ts
2710
- var import_typeorm26 = require("typeorm");
2936
+ var import_typeorm28 = require("typeorm");
2711
2937
  var Tax = class {
2712
2938
  id;
2713
2939
  name;
@@ -2726,56 +2952,56 @@ var Tax = class {
2726
2952
  deletedBy;
2727
2953
  };
2728
2954
  __decorateClass([
2729
- (0, import_typeorm26.PrimaryGeneratedColumn)()
2955
+ (0, import_typeorm28.PrimaryGeneratedColumn)()
2730
2956
  ], Tax.prototype, "id", 2);
2731
2957
  __decorateClass([
2732
- (0, import_typeorm26.Column)("varchar")
2958
+ (0, import_typeorm28.Column)("varchar")
2733
2959
  ], Tax.prototype, "name", 2);
2734
2960
  __decorateClass([
2735
- (0, import_typeorm26.Column)("varchar", { unique: true })
2961
+ (0, import_typeorm28.Column)("varchar", { unique: true })
2736
2962
  ], Tax.prototype, "slug", 2);
2737
2963
  __decorateClass([
2738
- (0, import_typeorm26.Column)("decimal", { precision: 5, scale: 2 })
2964
+ (0, import_typeorm28.Column)("decimal", { precision: 5, scale: 2 })
2739
2965
  ], Tax.prototype, "rate", 2);
2740
2966
  __decorateClass([
2741
- (0, import_typeorm26.Column)("boolean", { default: false })
2967
+ (0, import_typeorm28.Column)("boolean", { default: false })
2742
2968
  ], Tax.prototype, "isDefault", 2);
2743
2969
  __decorateClass([
2744
- (0, import_typeorm26.Column)("text", { nullable: true })
2970
+ (0, import_typeorm28.Column)("text", { nullable: true })
2745
2971
  ], Tax.prototype, "description", 2);
2746
2972
  __decorateClass([
2747
- (0, import_typeorm26.Column)("boolean", { default: true })
2973
+ (0, import_typeorm28.Column)("boolean", { default: true })
2748
2974
  ], Tax.prototype, "active", 2);
2749
2975
  __decorateClass([
2750
- (0, import_typeorm26.Column)("jsonb", { nullable: true })
2976
+ (0, import_typeorm28.Column)("jsonb", { nullable: true })
2751
2977
  ], Tax.prototype, "metadata", 2);
2752
2978
  __decorateClass([
2753
- (0, import_typeorm26.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2979
+ (0, import_typeorm28.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2754
2980
  ], Tax.prototype, "createdAt", 2);
2755
2981
  __decorateClass([
2756
- (0, import_typeorm26.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2982
+ (0, import_typeorm28.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2757
2983
  ], Tax.prototype, "updatedAt", 2);
2758
2984
  __decorateClass([
2759
- (0, import_typeorm26.Column)({ type: "timestamp", nullable: true })
2985
+ (0, import_typeorm28.Column)({ type: "timestamp", nullable: true })
2760
2986
  ], Tax.prototype, "deletedAt", 2);
2761
2987
  __decorateClass([
2762
- (0, import_typeorm26.Column)("boolean", { default: false })
2988
+ (0, import_typeorm28.Column)("boolean", { default: false })
2763
2989
  ], Tax.prototype, "deleted", 2);
2764
2990
  __decorateClass([
2765
- (0, import_typeorm26.Column)("int", { nullable: true })
2991
+ (0, import_typeorm28.Column)("int", { nullable: true })
2766
2992
  ], Tax.prototype, "createdBy", 2);
2767
2993
  __decorateClass([
2768
- (0, import_typeorm26.Column)("int", { nullable: true })
2994
+ (0, import_typeorm28.Column)("int", { nullable: true })
2769
2995
  ], Tax.prototype, "updatedBy", 2);
2770
2996
  __decorateClass([
2771
- (0, import_typeorm26.Column)("int", { nullable: true })
2997
+ (0, import_typeorm28.Column)("int", { nullable: true })
2772
2998
  ], Tax.prototype, "deletedBy", 2);
2773
2999
  Tax = __decorateClass([
2774
- (0, import_typeorm26.Entity)("taxes")
3000
+ (0, import_typeorm28.Entity)("taxes")
2775
3001
  ], Tax);
2776
3002
 
2777
3003
  // src/entities/product-tax.entity.ts
2778
- var import_typeorm27 = require("typeorm");
3004
+ var import_typeorm29 = require("typeorm");
2779
3005
  var ProductTax = class {
2780
3006
  id;
2781
3007
  productId;
@@ -2787,37 +3013,37 @@ var ProductTax = class {
2787
3013
  tax;
2788
3014
  };
2789
3015
  __decorateClass([
2790
- (0, import_typeorm27.PrimaryGeneratedColumn)()
3016
+ (0, import_typeorm29.PrimaryGeneratedColumn)()
2791
3017
  ], ProductTax.prototype, "id", 2);
2792
3018
  __decorateClass([
2793
- (0, import_typeorm27.Column)("int")
3019
+ (0, import_typeorm29.Column)("int")
2794
3020
  ], ProductTax.prototype, "productId", 2);
2795
3021
  __decorateClass([
2796
- (0, import_typeorm27.Column)("int")
3022
+ (0, import_typeorm29.Column)("int")
2797
3023
  ], ProductTax.prototype, "taxId", 2);
2798
3024
  __decorateClass([
2799
- (0, import_typeorm27.Column)("decimal", { precision: 5, scale: 2, nullable: true })
3025
+ (0, import_typeorm29.Column)("decimal", { precision: 5, scale: 2, nullable: true })
2800
3026
  ], ProductTax.prototype, "rate", 2);
2801
3027
  __decorateClass([
2802
- (0, import_typeorm27.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
3028
+ (0, import_typeorm29.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2803
3029
  ], ProductTax.prototype, "createdAt", 2);
2804
3030
  __decorateClass([
2805
- (0, import_typeorm27.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
3031
+ (0, import_typeorm29.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2806
3032
  ], ProductTax.prototype, "updatedAt", 2);
2807
3033
  __decorateClass([
2808
- (0, import_typeorm27.ManyToOne)(() => Product, (p) => p.taxes, { onDelete: "CASCADE" }),
2809
- (0, import_typeorm27.JoinColumn)({ name: "productId" })
3034
+ (0, import_typeorm29.ManyToOne)(() => Product, (p) => p.taxes, { onDelete: "CASCADE" }),
3035
+ (0, import_typeorm29.JoinColumn)({ name: "productId" })
2810
3036
  ], ProductTax.prototype, "product", 2);
2811
3037
  __decorateClass([
2812
- (0, import_typeorm27.ManyToOne)(() => Tax, { onDelete: "CASCADE" }),
2813
- (0, import_typeorm27.JoinColumn)({ name: "taxId" })
3038
+ (0, import_typeorm29.ManyToOne)(() => Tax, { onDelete: "CASCADE" }),
3039
+ (0, import_typeorm29.JoinColumn)({ name: "taxId" })
2814
3040
  ], ProductTax.prototype, "tax", 2);
2815
3041
  ProductTax = __decorateClass([
2816
- (0, import_typeorm27.Entity)("product_taxes")
3042
+ (0, import_typeorm29.Entity)("product_taxes")
2817
3043
  ], ProductTax);
2818
3044
 
2819
3045
  // src/entities/order-item.entity.ts
2820
- var import_typeorm28 = require("typeorm");
3046
+ var import_typeorm30 = require("typeorm");
2821
3047
  var OrderItem = class {
2822
3048
  id;
2823
3049
  orderId;
@@ -2833,47 +3059,118 @@ var OrderItem = class {
2833
3059
  product;
2834
3060
  };
2835
3061
  __decorateClass([
2836
- (0, import_typeorm28.PrimaryGeneratedColumn)()
3062
+ (0, import_typeorm30.PrimaryGeneratedColumn)()
2837
3063
  ], OrderItem.prototype, "id", 2);
2838
3064
  __decorateClass([
2839
- (0, import_typeorm28.Column)("int")
3065
+ (0, import_typeorm30.Column)("int")
2840
3066
  ], OrderItem.prototype, "orderId", 2);
2841
3067
  __decorateClass([
2842
- (0, import_typeorm28.Column)("int")
3068
+ (0, import_typeorm30.Column)("int")
2843
3069
  ], OrderItem.prototype, "productId", 2);
2844
3070
  __decorateClass([
2845
- (0, import_typeorm28.Column)("int", { default: 1 })
3071
+ (0, import_typeorm30.Column)("int", { default: 1 })
2846
3072
  ], OrderItem.prototype, "quantity", 2);
2847
3073
  __decorateClass([
2848
- (0, import_typeorm28.Column)("decimal", { precision: 12, scale: 2 })
3074
+ (0, import_typeorm30.Column)("decimal", { precision: 12, scale: 2 })
2849
3075
  ], OrderItem.prototype, "unitPrice", 2);
2850
3076
  __decorateClass([
2851
- (0, import_typeorm28.Column)("decimal", { precision: 12, scale: 2, default: 0 })
3077
+ (0, import_typeorm30.Column)("decimal", { precision: 12, scale: 2, default: 0 })
2852
3078
  ], OrderItem.prototype, "tax", 2);
2853
3079
  __decorateClass([
2854
- (0, import_typeorm28.Column)("decimal", { precision: 12, scale: 2 })
3080
+ (0, import_typeorm30.Column)("decimal", { precision: 12, scale: 2 })
2855
3081
  ], OrderItem.prototype, "total", 2);
2856
3082
  __decorateClass([
2857
- (0, import_typeorm28.Column)("jsonb", { nullable: true })
3083
+ (0, import_typeorm30.Column)("jsonb", { nullable: true })
2858
3084
  ], OrderItem.prototype, "metadata", 2);
2859
3085
  __decorateClass([
2860
- (0, import_typeorm28.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
3086
+ (0, import_typeorm30.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2861
3087
  ], OrderItem.prototype, "createdAt", 2);
2862
3088
  __decorateClass([
2863
- (0, import_typeorm28.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
3089
+ (0, import_typeorm30.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
2864
3090
  ], OrderItem.prototype, "updatedAt", 2);
2865
3091
  __decorateClass([
2866
- (0, import_typeorm28.ManyToOne)(() => Order, (o) => o.items, { onDelete: "CASCADE" }),
2867
- (0, import_typeorm28.JoinColumn)({ name: "orderId" })
3092
+ (0, import_typeorm30.ManyToOne)(() => Order, (o) => o.items, { onDelete: "CASCADE" }),
3093
+ (0, import_typeorm30.JoinColumn)({ name: "orderId" })
2868
3094
  ], OrderItem.prototype, "order", 2);
2869
3095
  __decorateClass([
2870
- (0, import_typeorm28.ManyToOne)(() => Product, { onDelete: "CASCADE" }),
2871
- (0, import_typeorm28.JoinColumn)({ name: "productId" })
3096
+ (0, import_typeorm30.ManyToOne)(() => Product, { onDelete: "CASCADE" }),
3097
+ (0, import_typeorm30.JoinColumn)({ name: "productId" })
2872
3098
  ], OrderItem.prototype, "product", 2);
2873
3099
  OrderItem = __decorateClass([
2874
- (0, import_typeorm28.Entity)("order_items")
3100
+ (0, import_typeorm30.Entity)("order_items")
2875
3101
  ], OrderItem);
2876
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
+
2877
3174
  // src/entities/index.ts
2878
3175
  var CMS_ENTITY_MAP = {
2879
3176
  users: User,
@@ -2903,7 +3200,11 @@ var CMS_ENTITY_MAP = {
2903
3200
  orders: Order,
2904
3201
  order_items: OrderItem,
2905
3202
  payments: Payment,
2906
- brands: Brand
3203
+ brands: Brand,
3204
+ knowledge_base_documents: KnowledgeBaseDocument,
3205
+ knowledge_base_chunks: KnowledgeBaseChunk,
3206
+ chat_conversations: ChatConversation,
3207
+ chat_messages: ChatMessage
2907
3208
  };
2908
3209
 
2909
3210
  // src/auth/helpers.ts
@@ -3072,7 +3373,7 @@ function getNextAuthOptions(config) {
3072
3373
  }
3073
3374
 
3074
3375
  // src/api/crud.ts
3075
- var import_typeorm29 = require("typeorm");
3376
+ var import_typeorm33 = require("typeorm");
3076
3377
  var DATE_COLUMN_TYPES = /* @__PURE__ */ new Set([
3077
3378
  "date",
3078
3379
  "datetime",
@@ -3213,10 +3514,10 @@ function createCrudHandler(dataSource, entityMap, options) {
3213
3514
  const inventory = searchParams.get("inventory")?.trim();
3214
3515
  const productWhere = {};
3215
3516
  if (statusFilter) productWhere.status = statusFilter;
3216
- if (inventory === "in_stock") productWhere.quantity = (0, import_typeorm29.MoreThan)(0);
3517
+ if (inventory === "in_stock") productWhere.quantity = (0, import_typeorm33.MoreThan)(0);
3217
3518
  if (inventory === "out_of_stock") productWhere.quantity = 0;
3218
3519
  if (search && typeof search === "string" && search.trim()) {
3219
- productWhere.name = (0, import_typeorm29.ILike)(`%${search.trim()}%`);
3520
+ productWhere.name = (0, import_typeorm33.ILike)(`%${search.trim()}%`);
3220
3521
  }
3221
3522
  const [data2, total2] = await repo2.findAndCount({
3222
3523
  where: Object.keys(productWhere).length ? productWhere : void 0,
@@ -3271,11 +3572,11 @@ function createCrudHandler(dataSource, entityMap, options) {
3271
3572
  let where = {};
3272
3573
  if (resource === "media") {
3273
3574
  const mediaWhere = {};
3274
- if (search) mediaWhere.filename = (0, import_typeorm29.ILike)(`%${search}%`);
3275
- 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}/%`);
3276
3577
  where = Object.keys(mediaWhere).length > 0 ? mediaWhere : {};
3277
3578
  } else if (search) {
3278
- 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}%`) }];
3279
3580
  }
3280
3581
  const [data, total] = await repo.findAndCount({
3281
3582
  skip,
@@ -3606,7 +3907,7 @@ function createUserAuthApiRouter(config) {
3606
3907
  }
3607
3908
 
3608
3909
  // src/api/cms-handlers.ts
3609
- var import_typeorm30 = require("typeorm");
3910
+ var import_typeorm34 = require("typeorm");
3610
3911
  function createDashboardStatsHandler(config) {
3611
3912
  const { dataSource, entityMap, json, requireAuth, requirePermission } = config;
3612
3913
  return async function GET(req) {
@@ -3625,8 +3926,8 @@ function createDashboardStatsHandler(config) {
3625
3926
  repo("form_submissions")?.count() ?? 0,
3626
3927
  repo("users")?.count({ where: { deleted: false } }) ?? 0,
3627
3928
  repo("blogs")?.count({ where: { deleted: false } }) ?? 0,
3628
- repo("contacts")?.count({ where: { createdAt: (0, import_typeorm30.MoreThanOrEqual)(sevenDaysAgo) } }) ?? 0,
3629
- 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
3630
3931
  ]);
3631
3932
  return json({
3632
3933
  contacts: { total: contactsCount, recent: recentContacts },
@@ -3979,7 +4280,7 @@ function createUsersApiHandlers(config) {
3979
4280
  const sortField = url.searchParams.get("sortField") || "createdAt";
3980
4281
  const sortOrder = url.searchParams.get("sortOrder") === "desc" ? "DESC" : "ASC";
3981
4282
  const search = url.searchParams.get("search");
3982
- 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}%`) }] : {};
3983
4284
  const [data, total] = await userRepo().findAndCount({
3984
4285
  skip,
3985
4286
  take: limit,
@@ -4187,6 +4488,129 @@ function createSettingsApiHandlers(config) {
4187
4488
  }
4188
4489
  };
4189
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
+ }
4190
4614
 
4191
4615
  // src/api/cms-api-handler.ts
4192
4616
  var DEFAULT_EXCLUDE = /* @__PURE__ */ new Set(["users", "password_reset_tokens", "user_groups", "permissions", "comments", "form_fields", "configs"]);
@@ -4209,7 +4633,8 @@ function createCmsApiHandler(config) {
4209
4633
  usersApi,
4210
4634
  userAvatar,
4211
4635
  userProfile,
4212
- settings: settingsConfig
4636
+ settings: settingsConfig,
4637
+ chat: chatConfig
4213
4638
  } = config;
4214
4639
  const analytics = analyticsConfig ?? (getCms ? {
4215
4640
  json: config.json,
@@ -4254,6 +4679,7 @@ function createCmsApiHandler(config) {
4254
4679
  const avatarPost = userAvatar ? createUserAvatarHandler(userAvatar) : null;
4255
4680
  const profilePut = userProfile ? createUserProfileHandler(userProfile) : null;
4256
4681
  const settingsHandlers = settingsConfig ? createSettingsApiHandlers(settingsConfig) : null;
4682
+ const chatHandlers = chatConfig ? createChatHandlers(chatConfig) : null;
4257
4683
  function resolveResource(segment) {
4258
4684
  const model = pathToModel(segment);
4259
4685
  return crudResources.includes(model) ? model : segment;
@@ -4313,6 +4739,11 @@ function createCmsApiHandler(config) {
4313
4739
  if (method === "GET") return settingsHandlers.GET(req, path[1]);
4314
4740
  if (method === "PUT") return settingsHandlers.PUT(req, path[1]);
4315
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
+ }
4316
4747
  if (path.length === 0) return config.json({ error: "Not found" }, { status: 404 });
4317
4748
  const resource = resolveResource(path[0]);
4318
4749
  if (!crudResources.includes(resource)) return config.json({ error: "Invalid resource" }, { status: 400 });
@@ -4361,6 +4792,8 @@ var DEFAULT_ADMIN_NAV = [
4361
4792
  Brand,
4362
4793
  CMS_ENTITY_MAP,
4363
4794
  Category,
4795
+ ChatConversation,
4796
+ ChatMessage,
4364
4797
  Collection,
4365
4798
  Comment,
4366
4799
  Config,
@@ -4370,6 +4803,9 @@ var DEFAULT_ADMIN_NAV = [
4370
4803
  Form,
4371
4804
  FormField,
4372
4805
  FormSubmission,
4806
+ KnowledgeBaseChunk,
4807
+ KnowledgeBaseDocument,
4808
+ LlmService,
4373
4809
  Media,
4374
4810
  OPEN_ENDPOINTS,
4375
4811
  Order,
@@ -4422,6 +4858,7 @@ var DEFAULT_ADMIN_NAV = [
4422
4858
  getRequiredPermission,
4423
4859
  isOpenEndpoint,
4424
4860
  isPublicMethod,
4861
+ llmPlugin,
4425
4862
  localStoragePlugin,
4426
4863
  paymentPlugin,
4427
4864
  s3StoragePlugin,