@infuro/cms-core 1.0.18 → 1.0.20

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.js CHANGED
@@ -2432,29 +2432,111 @@ function localStoragePlugin(config = {}) {
2432
2432
  }
2433
2433
 
2434
2434
  // src/plugins/llm/llm-service.ts
2435
+ function parseHfInferenceEmbeddingBody(data) {
2436
+ if (data === null || data === void 0) return null;
2437
+ if (Array.isArray(data)) {
2438
+ if (data.length === 0) return null;
2439
+ const first = data[0];
2440
+ if (typeof first === "number") return data;
2441
+ if (Array.isArray(first) && first.length > 0 && typeof first[0] === "number") {
2442
+ return first;
2443
+ }
2444
+ if (Array.isArray(first) && Array.isArray(first[0]) && typeof first[0][0] === "number") {
2445
+ return first[0];
2446
+ }
2447
+ return null;
2448
+ }
2449
+ if (typeof data === "object" && data !== null && !Array.isArray(data)) {
2450
+ const o = data;
2451
+ if (typeof o.error === "string") return null;
2452
+ if ("embeddings" in o) return parseHfInferenceEmbeddingBody(o.embeddings);
2453
+ }
2454
+ return null;
2455
+ }
2435
2456
  var LlmService = class _LlmService {
2436
- constructor(baseURL, apiKey, defaultEmbeddingModel) {
2437
- this.baseURL = baseURL;
2457
+ static embedHttpErrorLogged = false;
2458
+ static embedShapeErrorLogged = false;
2459
+ static embedSuccessLogged = false;
2460
+ static hfDimensionMismatchWarned = false;
2461
+ baseURL;
2462
+ apiKey;
2463
+ defaultEmbeddingModel;
2464
+ embeddingProvider;
2465
+ hfInferenceBaseURL;
2466
+ embeddingApiKey;
2467
+ constructor(baseURL, apiKey, defaultEmbeddingModel, embedOpts) {
2468
+ this.baseURL = baseURL.replace(/\/$/, "");
2438
2469
  this.apiKey = apiKey;
2439
2470
  this.defaultEmbeddingModel = defaultEmbeddingModel;
2471
+ const p = (embedOpts?.embeddingProvider ?? "openai").toLowerCase();
2472
+ this.embeddingProvider = p === "huggingface" ? "huggingface" : "openai";
2473
+ this.hfInferenceBaseURL = (embedOpts?.hfInferenceBaseUrl ?? "https://api-inference.huggingface.co").replace(
2474
+ /\/$/,
2475
+ ""
2476
+ );
2477
+ this.embeddingApiKey = (embedOpts?.embeddingApiKey ?? apiKey).trim();
2440
2478
  }
2441
- static embedWarned = false;
2442
2479
  get base() {
2443
2480
  return this.baseURL.replace(/\/$/, "");
2444
2481
  }
2445
2482
  get url() {
2446
2483
  return `${this.base}/v1/chat/completions`;
2447
2484
  }
2448
- /**
2449
- * OpenAI-compatible embeddings. Returns [] if endpoint not available or unexpected response.
2450
- * Server must implement: POST /v1/embeddings
2451
- * Body: { model: string, input: string }
2452
- * Response: { data: [ { embedding: number[] } ] } or { embedding: number[] }
2453
- */
2485
+ llmDebugEnabled() {
2486
+ const v = process.env.LLM_DEBUG?.toLowerCase();
2487
+ return v === "1" || v === "true" || v === "yes";
2488
+ }
2489
+ /** Per-request embedding logs (noisy with many chunks). Set `LLM_EMBED_DEBUG=1`. */
2490
+ embedDebugEnabled() {
2491
+ const v = process.env.LLM_EMBED_DEBUG?.toLowerCase();
2492
+ return v === "1" || v === "true" || v === "yes";
2493
+ }
2494
+ logAgentComposition(options) {
2495
+ if (!this.llmDebugEnabled()) return;
2496
+ const { systemPrompt, context, history = [], userPrompt, model, temperature, max_tokens } = options;
2497
+ console.log("\n[LLM chatAgent] composing request");
2498
+ if (systemPrompt?.trim()) {
2499
+ console.log("[System instruction]\n", systemPrompt.trim());
2500
+ }
2501
+ if (context?.trim()) {
2502
+ console.log("[Context \u2014 merged into system message by chatAgent]\n", context.trim());
2503
+ }
2504
+ if (history.length > 0) {
2505
+ console.log("[Conversation so far]");
2506
+ for (const m of history) {
2507
+ console.log(` ${m.role}: ${m.content}`);
2508
+ }
2509
+ }
2510
+ console.log("[Current user message]\n", userPrompt);
2511
+ if (model !== void 0 || temperature !== void 0 || max_tokens !== void 0) {
2512
+ console.log("[Agent options]", { model, temperature, max_tokens });
2513
+ }
2514
+ }
2515
+ logChatCompletionsRequest(kind, messages, options, stream) {
2516
+ if (!this.llmDebugEnabled()) return;
2517
+ const model = options.model ?? "meta-llama/Meta-Llama-3-8B-Instruct";
2518
+ console.log(`
2519
+ [LLM ${kind}] POST`, this.url);
2520
+ console.log("[Request options]", {
2521
+ model,
2522
+ temperature: options.temperature,
2523
+ max_tokens: options.max_tokens,
2524
+ stream
2525
+ });
2526
+ console.log("[Messages \u2014 wire payload]\n", JSON.stringify(messages, null, 2));
2527
+ }
2454
2528
  async embed(text, options = {}) {
2455
- const model = options.model ?? this.defaultEmbeddingModel ?? "text-embedding-3-small";
2456
2529
  const input = text.slice(0, 8e3);
2457
- const res = await fetch(`${this.base}/v1/embeddings`, {
2530
+ if (this.embeddingProvider === "huggingface") {
2531
+ const model2 = options.model ?? this.defaultEmbeddingModel ?? "sentence-transformers/all-MiniLM-L6-v2";
2532
+ return this.embedHuggingFaceInference(input, model2);
2533
+ }
2534
+ const model = options.model ?? this.defaultEmbeddingModel ?? "text-embedding-3-small";
2535
+ const embedUrl = `${this.base}/v1/embeddings`;
2536
+ if (this.embedDebugEnabled()) {
2537
+ console.info("[LLM embed] request", { url: embedUrl, model, inputChars: input.length });
2538
+ }
2539
+ const res = await fetch(embedUrl, {
2458
2540
  method: "POST",
2459
2541
  headers: {
2460
2542
  "Content-Type": "application/json",
@@ -2467,9 +2549,17 @@ var LlmService = class _LlmService {
2467
2549
  });
2468
2550
  if (!res.ok) {
2469
2551
  const body = await res.text();
2470
- if (!_LlmService.embedWarned) {
2471
- _LlmService.embedWarned = true;
2472
- console.warn(`[LLM embed] ${res.status} ${res.statusText}: ${body.slice(0, 400)}`);
2552
+ const hint404 = res.status === 404 ? "This base URL does not expose OpenAI-compatible POST /v1/embeddings (e.g. router.huggingface.co). Set EMBEDDING_PROVIDER=huggingface and EMBEDDING_MODEL to a HF Inference\u2013supported embedding model, or use a host with /v1/embeddings." : "Embeddings HTTP error \u2014 knowledge_base_chunks.embedding will stay NULL for failed calls.";
2553
+ if (!_LlmService.embedHttpErrorLogged) {
2554
+ _LlmService.embedHttpErrorLogged = true;
2555
+ console.error("[LLM embed]", hint404, {
2556
+ url: embedUrl,
2557
+ status: res.status,
2558
+ statusText: res.statusText,
2559
+ bodyPreview: body.slice(0, 800)
2560
+ });
2561
+ } else if (this.embedDebugEnabled()) {
2562
+ console.warn("[LLM embed] repeat HTTP error", { status: res.status, bodyPreview: body.slice(0, 200) });
2473
2563
  }
2474
2564
  return [];
2475
2565
  }
@@ -2477,7 +2567,10 @@ var LlmService = class _LlmService {
2477
2567
  try {
2478
2568
  data = await res.json();
2479
2569
  } catch {
2480
- console.warn("[LLM embed] Response is not JSON");
2570
+ if (!_LlmService.embedShapeErrorLogged) {
2571
+ _LlmService.embedShapeErrorLogged = true;
2572
+ console.error("[LLM embed] Response body is not JSON \u2014 treating as no embedding.");
2573
+ }
2481
2574
  return [];
2482
2575
  }
2483
2576
  let embedding = data?.data?.[0]?.embedding;
@@ -2488,13 +2581,154 @@ var LlmService = class _LlmService {
2488
2581
  const first = data.data[0];
2489
2582
  embedding = Array.isArray(first) ? first : first?.embedding;
2490
2583
  }
2491
- if (!Array.isArray(embedding) && !_LlmService.embedWarned) {
2492
- _LlmService.embedWarned = true;
2493
- console.warn("[LLM embed] Unexpected response shape. Keys:", Object.keys(data), "data[0] type:", Array.isArray(data?.data) ? typeof data.data[0] : "n/a");
2584
+ if (!Array.isArray(embedding)) {
2585
+ if (!_LlmService.embedShapeErrorLogged) {
2586
+ _LlmService.embedShapeErrorLogged = true;
2587
+ console.error(
2588
+ "[LLM embed] Response OK but no parseable embedding array (OpenAI shape expected). knowledge_base_chunks will not update.",
2589
+ {
2590
+ url: embedUrl,
2591
+ topKeys: Object.keys(data),
2592
+ data0Type: Array.isArray(data?.data) ? typeof data.data[0] : "n/a"
2593
+ }
2594
+ );
2595
+ }
2596
+ return [];
2597
+ }
2598
+ if (!_LlmService.embedSuccessLogged) {
2599
+ _LlmService.embedSuccessLogged = true;
2600
+ console.info("[LLM embed] first success", { dimension: embedding.length, model });
2601
+ } else if (this.embedDebugEnabled()) {
2602
+ console.info("[LLM embed] ok", { dimension: embedding.length });
2603
+ }
2604
+ return embedding;
2605
+ }
2606
+ async embedHuggingFaceInference(input, model) {
2607
+ const normalizedBase = this.hfInferenceBaseURL.replace(/\/$/, "");
2608
+ const baseWithProvider = /router\.huggingface\.co\/hf-inference$/i.test(normalizedBase) ? normalizedBase : /router\.huggingface\.co$/i.test(normalizedBase) ? `${normalizedBase}/hf-inference` : normalizedBase;
2609
+ const requestBody = JSON.stringify({
2610
+ inputs: input,
2611
+ options: { wait_for_model: true }
2612
+ });
2613
+ const pipelineUrl = `${baseWithProvider}/pipeline/feature-extraction/${model}`;
2614
+ const modelUrl = `${baseWithProvider}/models/${model}`;
2615
+ if (this.embedDebugEnabled()) {
2616
+ console.info("[LLM embed HF]", { url: pipelineUrl, model, inputChars: input.length });
2617
+ }
2618
+ let embedUrl = pipelineUrl;
2619
+ let res = await fetch(embedUrl, {
2620
+ method: "POST",
2621
+ headers: {
2622
+ "Content-Type": "application/json",
2623
+ Authorization: `Bearer ${this.embeddingApiKey}`
2624
+ },
2625
+ body: requestBody
2626
+ });
2627
+ let bodyText = await res.text();
2628
+ if (res.status === 404) {
2629
+ embedUrl = modelUrl;
2630
+ if (this.embedDebugEnabled()) {
2631
+ console.warn("[LLM embed HF] /pipeline route returned 404; retrying with /models.", {
2632
+ model,
2633
+ fallbackUrl: embedUrl
2634
+ });
2635
+ }
2636
+ res = await fetch(embedUrl, {
2637
+ method: "POST",
2638
+ headers: {
2639
+ "Content-Type": "application/json",
2640
+ Authorization: `Bearer ${this.embeddingApiKey}`
2641
+ },
2642
+ body: requestBody
2643
+ });
2644
+ bodyText = await res.text();
2645
+ }
2646
+ if (!res.ok) {
2647
+ if (!_LlmService.embedHttpErrorLogged) {
2648
+ _LlmService.embedHttpErrorLogged = true;
2649
+ console.error(
2650
+ "[LLM embed HF] Hugging Face Inference request failed \u2014 knowledge chunks stay without vectors.",
2651
+ {
2652
+ url: embedUrl,
2653
+ status: res.status,
2654
+ statusText: res.statusText,
2655
+ bodyPreview: bodyText.slice(0, 800),
2656
+ hint: res.status === 410 || res.status === 404 ? "Model or route unavailable on Inference API; pick another EMBEDDING_MODEL (e.g. sentence-transformers/all-MiniLM-L6-v2)." : void 0
2657
+ }
2658
+ );
2659
+ } else if (this.embedDebugEnabled()) {
2660
+ console.warn("[LLM embed HF] repeat HTTP error", { status: res.status, bodyPreview: bodyText.slice(0, 200) });
2661
+ }
2662
+ return [];
2663
+ }
2664
+ let data;
2665
+ try {
2666
+ data = JSON.parse(bodyText);
2667
+ } catch {
2668
+ if (!_LlmService.embedShapeErrorLogged) {
2669
+ _LlmService.embedShapeErrorLogged = true;
2670
+ console.error("[LLM embed HF] Response is not JSON \u2014 treating as no embedding.");
2671
+ }
2672
+ return [];
2673
+ }
2674
+ const embedding = parseHfInferenceEmbeddingBody(data);
2675
+ if (!embedding?.length) {
2676
+ if (!_LlmService.embedShapeErrorLogged) {
2677
+ _LlmService.embedShapeErrorLogged = true;
2678
+ const preview = typeof data === "object" && data !== null && !Array.isArray(data) ? Object.keys(data) : typeof data;
2679
+ console.error("[LLM embed HF] Unrecognized embedding shape from Inference API.", { url: embedUrl, preview });
2680
+ }
2681
+ return [];
2682
+ }
2683
+ if (!_LlmService.embedSuccessLogged) {
2684
+ _LlmService.embedSuccessLogged = true;
2685
+ console.info("[LLM embed HF] first success", { dimension: embedding.length, model });
2686
+ if (!_LlmService.hfDimensionMismatchWarned && embedding.length !== 1536) {
2687
+ _LlmService.hfDimensionMismatchWarned = true;
2688
+ console.warn(
2689
+ `[LLM embed HF] Embedding dimensions=${embedding.length}; default CMS migration uses vector(1536). If pgvector updates fail, alter the column, e.g. ALTER TABLE knowledge_base_chunks ALTER COLUMN embedding TYPE vector(${embedding.length});`
2690
+ );
2691
+ }
2692
+ } else if (this.embedDebugEnabled()) {
2693
+ console.info("[LLM embed HF] ok", { dimension: embedding.length });
2694
+ }
2695
+ return embedding;
2696
+ }
2697
+ buildAgentMessages(options) {
2698
+ const { systemPrompt, userPrompt, history = [], context } = options;
2699
+ const messages = [];
2700
+ let systemContent = systemPrompt?.trim();
2701
+ if (context) {
2702
+ systemContent = systemContent ? `${systemContent}
2703
+
2704
+ Context:
2705
+ ${context}` : `Use the following context to answer:
2706
+
2707
+ ${context}`;
2708
+ }
2709
+ if (systemContent) {
2710
+ messages.push({ role: "system", content: systemContent });
2494
2711
  }
2495
- return Array.isArray(embedding) ? embedding : [];
2712
+ if (history.length > 0) {
2713
+ messages.push(...history);
2714
+ }
2715
+ messages.push({ role: "user", content: userPrompt });
2716
+ return messages;
2717
+ }
2718
+ async chatAgent(options) {
2719
+ this.logAgentComposition(options);
2720
+ const messages = this.buildAgentMessages(options);
2721
+ const { model, temperature, max_tokens } = options;
2722
+ return this.chat(messages, { model, temperature, max_tokens });
2723
+ }
2724
+ async *streamChatAgent(options) {
2725
+ this.logAgentComposition(options);
2726
+ const messages = this.buildAgentMessages(options);
2727
+ const { model, temperature, max_tokens } = options;
2728
+ yield* this.streamChat(messages, { model, temperature, max_tokens });
2496
2729
  }
2497
2730
  async chat(messages, options = {}) {
2731
+ this.logChatCompletionsRequest("chat", messages, options, false);
2498
2732
  const res = await fetch(this.url, {
2499
2733
  method: "POST",
2500
2734
  headers: {
@@ -2502,7 +2736,7 @@ var LlmService = class _LlmService {
2502
2736
  Authorization: `Bearer ${this.apiKey}`
2503
2737
  },
2504
2738
  body: JSON.stringify({
2505
- model: options.model ?? "qwen2.5:3b-instruct",
2739
+ model: options.model ?? "meta-llama/Meta-Llama-3-8B-Instruct",
2506
2740
  messages,
2507
2741
  stream: false,
2508
2742
  temperature: options.temperature,
@@ -2515,9 +2749,13 @@ var LlmService = class _LlmService {
2515
2749
  }
2516
2750
  const data = await res.json();
2517
2751
  const content = data.choices?.[0]?.message?.content ?? "";
2752
+ if (this.llmDebugEnabled()) {
2753
+ console.log("\n[LLM chat] assistant reply\n", content);
2754
+ }
2518
2755
  return { content };
2519
2756
  }
2520
2757
  async *streamChat(messages, options = {}) {
2758
+ this.logChatCompletionsRequest("streamChat", messages, options, true);
2521
2759
  const res = await fetch(this.url, {
2522
2760
  method: "POST",
2523
2761
  headers: {
@@ -2525,7 +2763,7 @@ var LlmService = class _LlmService {
2525
2763
  Authorization: `Bearer ${this.apiKey}`
2526
2764
  },
2527
2765
  body: JSON.stringify({
2528
- model: options.model ?? "qwen2.5:3b-instruct",
2766
+ model: options.model ?? "meta-llama/Meta-Llama-3-8B-Instruct",
2529
2767
  messages,
2530
2768
  stream: true,
2531
2769
  temperature: options.temperature,
@@ -2540,6 +2778,8 @@ var LlmService = class _LlmService {
2540
2778
  if (!reader) return;
2541
2779
  const decoder = new TextDecoder();
2542
2780
  let buffer = "";
2781
+ const debug = this.llmDebugEnabled();
2782
+ let streamedReply = "";
2543
2783
  while (true) {
2544
2784
  const { value, done } = await reader.read();
2545
2785
  if (done) break;
@@ -2551,16 +2791,28 @@ var LlmService = class _LlmService {
2551
2791
  try {
2552
2792
  const json = JSON.parse(line.slice(6));
2553
2793
  const content = json.choices?.[0]?.delta?.content;
2554
- if (content) yield content;
2794
+ if (content) {
2795
+ if (debug) streamedReply += content;
2796
+ yield content;
2797
+ }
2555
2798
  } catch {
2556
2799
  }
2557
2800
  }
2558
2801
  }
2559
2802
  }
2803
+ if (debug) {
2804
+ console.log("\n[LLM streamChat] assistant reply (full)\n", streamedReply);
2805
+ }
2560
2806
  }
2561
2807
  };
2562
2808
 
2563
2809
  // src/plugins/llm/index.ts
2810
+ function normalizeEmbeddingProvider(raw) {
2811
+ if (!raw) return "openai";
2812
+ const s = raw.toLowerCase().trim();
2813
+ if (s === "huggingface" || s === "hf" || s === "hf_inference" || s === "inference") return "huggingface";
2814
+ return "openai";
2815
+ }
2564
2816
  function llmPlugin(config = {}) {
2565
2817
  return {
2566
2818
  name: "llm",
@@ -2573,7 +2825,16 @@ function llmPlugin(config = {}) {
2573
2825
  return void 0;
2574
2826
  }
2575
2827
  const embeddingModel = config.embeddingModel ?? context.config.EMBEDDING_MODEL;
2576
- return new LlmService(baseURL.replace(/\/$/, ""), apiKey, embeddingModel);
2828
+ const embeddingProvider = normalizeEmbeddingProvider(
2829
+ config.embeddingProvider ?? context.config.EMBEDDING_PROVIDER
2830
+ );
2831
+ const hfInferenceBaseUrl = config.hfInferenceBaseUrl ?? context.config.HF_INFERENCE_URL;
2832
+ const embeddingApiKey = config.embeddingApiKey ?? context.config.EMBEDDING_API_KEY;
2833
+ return new LlmService(baseURL.replace(/\/$/, ""), apiKey, embeddingModel, {
2834
+ embeddingProvider,
2835
+ hfInferenceBaseUrl,
2836
+ embeddingApiKey
2837
+ });
2577
2838
  }
2578
2839
  };
2579
2840
  }
@@ -3437,6 +3698,86 @@ init_email_queue();
3437
3698
  init_erp_queue();
3438
3699
  import { MoreThanOrEqual, ILike, In } from "typeorm";
3439
3700
 
3701
+ // src/entities/llm-agent.entity.ts
3702
+ import { Entity, PrimaryGeneratedColumn, Column } from "typeorm";
3703
+ var LlmAgent = class {
3704
+ id;
3705
+ name;
3706
+ slug;
3707
+ systemInstruction;
3708
+ model;
3709
+ temperature;
3710
+ maxTokens;
3711
+ validationRules;
3712
+ enabled;
3713
+ createdAt;
3714
+ updatedAt;
3715
+ deletedAt;
3716
+ deleted;
3717
+ createdBy;
3718
+ updatedBy;
3719
+ deletedBy;
3720
+ };
3721
+ __decorateClass([
3722
+ PrimaryGeneratedColumn()
3723
+ ], LlmAgent.prototype, "id", 2);
3724
+ __decorateClass([
3725
+ Column("varchar")
3726
+ ], LlmAgent.prototype, "name", 2);
3727
+ __decorateClass([
3728
+ Column("varchar")
3729
+ ], LlmAgent.prototype, "slug", 2);
3730
+ __decorateClass([
3731
+ Column("text", { name: "system_instruction", default: "" })
3732
+ ], LlmAgent.prototype, "systemInstruction", 2);
3733
+ __decorateClass([
3734
+ Column("varchar", { nullable: true })
3735
+ ], LlmAgent.prototype, "model", 2);
3736
+ __decorateClass([
3737
+ Column("double precision", { name: "temperature", nullable: true })
3738
+ ], LlmAgent.prototype, "temperature", 2);
3739
+ __decorateClass([
3740
+ Column("int", { name: "max_tokens", nullable: true })
3741
+ ], LlmAgent.prototype, "maxTokens", 2);
3742
+ __decorateClass([
3743
+ Column("text", { name: "validation_rules", nullable: true })
3744
+ ], LlmAgent.prototype, "validationRules", 2);
3745
+ __decorateClass([
3746
+ Column("boolean", { default: true })
3747
+ ], LlmAgent.prototype, "enabled", 2);
3748
+ __decorateClass([
3749
+ Column({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
3750
+ ], LlmAgent.prototype, "createdAt", 2);
3751
+ __decorateClass([
3752
+ Column({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
3753
+ ], LlmAgent.prototype, "updatedAt", 2);
3754
+ __decorateClass([
3755
+ Column({ type: "timestamp", nullable: true })
3756
+ ], LlmAgent.prototype, "deletedAt", 2);
3757
+ __decorateClass([
3758
+ Column("boolean", { default: false })
3759
+ ], LlmAgent.prototype, "deleted", 2);
3760
+ __decorateClass([
3761
+ Column("int", { nullable: true })
3762
+ ], LlmAgent.prototype, "createdBy", 2);
3763
+ __decorateClass([
3764
+ Column("int", { nullable: true })
3765
+ ], LlmAgent.prototype, "updatedBy", 2);
3766
+ __decorateClass([
3767
+ Column("int", { nullable: true })
3768
+ ], LlmAgent.prototype, "deletedBy", 2);
3769
+ LlmAgent = __decorateClass([
3770
+ Entity("llm_agents")
3771
+ ], LlmAgent);
3772
+ function llmAgentToChatAgentOptions(agent) {
3773
+ return {
3774
+ systemPrompt: agent.systemInstruction?.trim() || void 0,
3775
+ model: agent.model?.trim() || void 0,
3776
+ temperature: agent.temperature ?? void 0,
3777
+ max_tokens: agent.maxTokens ?? void 0
3778
+ };
3779
+ }
3780
+
3440
3781
  // src/lib/media-folder-path.ts
3441
3782
  function sanitizeMediaFolderPath(input) {
3442
3783
  if (input == null) return "";
@@ -3626,6 +3967,82 @@ async function extractZipMediaIntoParentTree(opts) {
3626
3967
  }
3627
3968
 
3628
3969
  // src/api/cms-handlers.ts
3970
+ function historyBeforeCurrentUser(history, currentUserContent) {
3971
+ const last = history[history.length - 1];
3972
+ if (last?.role === "user" && last.content === currentUserContent) {
3973
+ return history.slice(0, -1);
3974
+ }
3975
+ return [...history];
3976
+ }
3977
+ function pickStructuredRules(rules) {
3978
+ return {
3979
+ maxUserChars: rules.maxUserChars,
3980
+ maxMessageLength: rules.maxMessageLength,
3981
+ minUserChars: rules.minUserChars,
3982
+ minMessageLength: rules.minMessageLength,
3983
+ blockedSubstrings: rules.blockedSubstrings
3984
+ };
3985
+ }
3986
+ function guardrailsTextFromJsonObject(rules) {
3987
+ const g = typeof rules.guardrails === "string" && rules.guardrails.trim() || typeof rules.outputRules === "string" && rules.outputRules.trim() || typeof rules.outputInstructions === "string" && rules.outputInstructions.trim() || "";
3988
+ return g || null;
3989
+ }
3990
+ function parseLlmAgentValidationRules(validationRulesText) {
3991
+ const raw = validationRulesText?.trim();
3992
+ if (!raw) return { structured: {}, guardrailsForPrompt: null };
3993
+ try {
3994
+ const parsed = JSON.parse(raw);
3995
+ if (typeof parsed === "string") {
3996
+ const s = parsed.trim();
3997
+ return { structured: {}, guardrailsForPrompt: s || null };
3998
+ }
3999
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
4000
+ return { structured: {}, guardrailsForPrompt: raw };
4001
+ }
4002
+ const rules = parsed;
4003
+ return {
4004
+ structured: pickStructuredRules(rules),
4005
+ guardrailsForPrompt: guardrailsTextFromJsonObject(rules)
4006
+ };
4007
+ } catch {
4008
+ return { structured: {}, guardrailsForPrompt: raw };
4009
+ }
4010
+ }
4011
+ function validateUserMessageAgainstStructuredRules(message, structured) {
4012
+ const maxLen = structured.maxUserChars ?? structured.maxMessageLength;
4013
+ if (typeof maxLen === "number" && Number.isFinite(maxLen) && maxLen >= 0 && message.length > maxLen) {
4014
+ return { ok: false, error: `Message exceeds maximum length (${maxLen} characters)` };
4015
+ }
4016
+ const minLen = structured.minUserChars ?? structured.minMessageLength;
4017
+ if (typeof minLen === "number" && Number.isFinite(minLen) && minLen > 0 && message.length < minLen) {
4018
+ return { ok: false, error: `Message is shorter than minimum length (${minLen} characters)` };
4019
+ }
4020
+ const blocked = structured.blockedSubstrings;
4021
+ if (Array.isArray(blocked) && blocked.length > 0) {
4022
+ const lower = message.toLowerCase();
4023
+ for (const s of blocked) {
4024
+ if (typeof s !== "string" || !s.trim()) continue;
4025
+ if (lower.includes(s.toLowerCase())) {
4026
+ return { ok: false, error: "Message contains disallowed content" };
4027
+ }
4028
+ }
4029
+ }
4030
+ return { ok: true };
4031
+ }
4032
+ function validateUserMessageAgainstAgentRules(message, validationRulesText) {
4033
+ const { structured } = parseLlmAgentValidationRules(validationRulesText);
4034
+ return validateUserMessageAgainstStructuredRules(message, structured);
4035
+ }
4036
+ function mergeGuardrailsIntoSystemPrompt(baseSystem, guardrailsForPrompt) {
4037
+ const g = guardrailsForPrompt?.trim();
4038
+ const b = (baseSystem ?? "").trim();
4039
+ if (!g) return b;
4040
+ const block = `### Output guardrails (follow in every reply)
4041
+ ${g}`;
4042
+ return b ? `${b}
4043
+
4044
+ ${block}` : block;
4045
+ }
3629
4046
  function createDashboardStatsHandler(config) {
3630
4047
  const { dataSource, entityMap, json, requireAuth, requirePermission, requireEntityPermission } = config;
3631
4048
  return async function GET(req) {
@@ -4707,9 +5124,24 @@ function createSettingsApiHandlers(config) {
4707
5124
  }
4708
5125
  var KB_CHUNK_LIMIT = 10;
4709
5126
  var KB_CONTEXT_MAX_CHARS = 4e3;
5127
+ var RAG_LOG = "[rag-context]";
4710
5128
  function getQueryTerms(message) {
4711
5129
  return message.replace(/[^\w\s]/g, " ").split(/\s+/).filter((w) => w.length > 2).slice(0, 6);
4712
5130
  }
5131
+ function normalizeChatModeSetting(raw) {
5132
+ if (raw === "external" || raw === "llm") return raw;
5133
+ return "whatsapp";
5134
+ }
5135
+ async function loadLlmSettingsMap(dataSource, entityMap) {
5136
+ if (!entityMap.configs) return {};
5137
+ const repo = dataSource.getRepository(entityMap.configs);
5138
+ const rows = await repo.find({ where: { settings: "llm", deleted: false } });
5139
+ const out = {};
5140
+ for (const row of rows) {
5141
+ out[row.key] = row.value;
5142
+ }
5143
+ return out;
5144
+ }
4713
5145
  function createChatHandlers(config) {
4714
5146
  const { dataSource, entityMap, json, getCms } = config;
4715
5147
  const contactRepo = () => dataSource.getRepository(entityMap.contacts);
@@ -4717,6 +5149,26 @@ function createChatHandlers(config) {
4717
5149
  const msgRepo = () => dataSource.getRepository(entityMap.chat_messages);
4718
5150
  const chunkRepo = () => dataSource.getRepository(entityMap.knowledge_base_chunks);
4719
5151
  return {
5152
+ async publicConfig(_req) {
5153
+ try {
5154
+ const map = await loadLlmSettingsMap(dataSource, entityMap);
5155
+ const mode = normalizeChatModeSetting(map.chatMode);
5156
+ const body = {
5157
+ enabled: map.enabled !== "false",
5158
+ chatMode: mode,
5159
+ agentSlug: mode === "llm" ? (map.attachedAgentSlug ?? "").trim() : "",
5160
+ botName: map.botName ?? "",
5161
+ icon: map.icon ?? "",
5162
+ iconImageUrl: map.iconImageUrl ?? "",
5163
+ iconBackgroundColor: map.iconBackgroundColor ?? "#6366f1",
5164
+ headerColor: map.headerColor ?? "#6366f1",
5165
+ whatsappPhone: map.whatsappPhone ?? ""
5166
+ };
5167
+ return json(body);
5168
+ } catch {
5169
+ return json({ error: "Failed to load chat config" }, { status: 500 });
5170
+ }
5171
+ },
4720
5172
  async identify(req) {
4721
5173
  try {
4722
5174
  const body = await req.json();
@@ -4764,20 +5216,78 @@ function createChatHandlers(config) {
4764
5216
  relations: ["messages"]
4765
5217
  });
4766
5218
  if (!conv) return json({ error: "Conversation not found" }, { status: 404 });
4767
- const msgRepoInst = msgRepo();
4768
- await msgRepoInst.save(msgRepoInst.create({ conversationId, role: "user", content: message }));
4769
5219
  const cms = await getCms();
4770
5220
  const llm = cms.getPlugin("llm");
4771
5221
  if (!llm?.chat) return json({ error: "LLM not configured" }, { status: 503 });
5222
+ const llmSettings = await loadLlmSettingsMap(dataSource, entityMap);
5223
+ const supportMode = normalizeChatModeSetting(llmSettings.chatMode);
5224
+ let effectiveSlug = (body?.agentSlug ?? "").trim();
5225
+ if (!effectiveSlug && supportMode === "llm" && entityMap.llm_agents) {
5226
+ effectiveSlug = (llmSettings.attachedAgentSlug ?? "").trim();
5227
+ }
5228
+ let agentRow = null;
5229
+ if (effectiveSlug) {
5230
+ if (!entityMap.llm_agents) {
5231
+ return json({ error: "LLM agents are not configured on this deployment" }, { status: 400 });
5232
+ }
5233
+ const agentRepo = dataSource.getRepository(
5234
+ entityMap.llm_agents
5235
+ );
5236
+ agentRow = await agentRepo.findOne({
5237
+ where: { slug: effectiveSlug, deleted: false, enabled: true }
5238
+ });
5239
+ if (!agentRow && (body?.agentSlug ?? "").trim()) {
5240
+ return json({ error: "Agent not found or disabled", agentSlug: effectiveSlug }, { status: 404 });
5241
+ }
5242
+ }
5243
+ console.info(RAG_LOG, "step 1 | resolve agent", {
5244
+ agentSlug: effectiveSlug || "(none)",
5245
+ agentFound: !!agentRow,
5246
+ agentId: agentRow?.id ?? null
5247
+ });
5248
+ const parsedValidation = agentRow ? parseLlmAgentValidationRules(agentRow.validationRules) : { structured: {}, guardrailsForPrompt: null };
5249
+ if (agentRow) {
5250
+ const v = validateUserMessageAgainstStructuredRules(message, parsedValidation.structured);
5251
+ if (!v.ok) return json({ error: v.error, reason: "validation_failed" }, { status: 400 });
5252
+ }
5253
+ let kbDocumentScope;
5254
+ const Junction = entityMap.llm_agent_knowledge_documents;
5255
+ if (agentRow && Junction) {
5256
+ const linkRepo = dataSource.getRepository(Junction);
5257
+ const links = await linkRepo.find({ where: { agentId: agentRow.id } });
5258
+ const ids = [...new Set(links.map((l) => l.documentId))];
5259
+ if (ids.length > 0) kbDocumentScope = ids;
5260
+ }
5261
+ console.info(RAG_LOG, "step 2 | knowledge scope", {
5262
+ scopedDocumentIds: kbDocumentScope ?? "(all documents)",
5263
+ documentCount: kbDocumentScope?.length ?? "all"
5264
+ });
5265
+ const msgRepoInst = msgRepo();
5266
+ await msgRepoInst.save(msgRepoInst.create({ conversationId, role: "user", content: message }));
4772
5267
  let contextParts = [];
5268
+ console.info(RAG_LOG, "step 3 | embed user query", {
5269
+ messageChars: message.length,
5270
+ embedAvailable: !!llm.embed
5271
+ });
4773
5272
  const queryEmbedding = llm.embed ? await llm.embed(message) : null;
5273
+ console.info(RAG_LOG, "step 4 | query embedding result", {
5274
+ dimensions: queryEmbedding?.length ?? 0,
5275
+ hasEmbedding: !!(queryEmbedding && queryEmbedding.length > 0)
5276
+ });
4774
5277
  if (queryEmbedding && queryEmbedding.length > 0) {
4775
5278
  const vectorStr = "[" + queryEmbedding.join(",") + "]";
4776
5279
  try {
4777
- const rows = await dataSource.query(
5280
+ const rows = kbDocumentScope?.length ? await dataSource.query(
5281
+ `SELECT id, content FROM knowledge_base_chunks WHERE embedding IS NOT NULL AND "documentId" = ANY($3::int[]) ORDER BY embedding <=> $1::vector LIMIT $2`,
5282
+ [vectorStr, KB_CHUNK_LIMIT, kbDocumentScope]
5283
+ ) : await dataSource.query(
4778
5284
  `SELECT id, content FROM knowledge_base_chunks WHERE embedding IS NOT NULL ORDER BY embedding <=> $1::vector LIMIT $2`,
4779
5285
  [vectorStr, KB_CHUNK_LIMIT]
4780
5286
  );
5287
+ console.info(RAG_LOG, "step 5 | vector search results", {
5288
+ rowsReturned: rows.length,
5289
+ chunkIds: rows.map((r) => r.id)
5290
+ });
4781
5291
  let totalLen = 0;
4782
5292
  for (const r of rows) {
4783
5293
  const text = (r.content ?? "").trim();
@@ -4785,13 +5295,24 @@ function createChatHandlers(config) {
4785
5295
  contextParts.push(text);
4786
5296
  totalLen += text.length;
4787
5297
  }
4788
- } catch {
5298
+ console.info(RAG_LOG, "step 5a | vector context selected", {
5299
+ chunksUsed: contextParts.length,
5300
+ totalChars: totalLen
5301
+ });
5302
+ } catch (vecErr) {
5303
+ console.warn(RAG_LOG, "step 5 | vector search failed; falling back to keyword", {
5304
+ err: vecErr instanceof Error ? vecErr.message : String(vecErr)
5305
+ });
4789
5306
  }
4790
5307
  }
4791
5308
  if (contextParts.length === 0) {
4792
5309
  const terms = getQueryTerms(message);
5310
+ console.info(RAG_LOG, "step 6 | keyword fallback", {
5311
+ reason: !(queryEmbedding && queryEmbedding.length > 0) ? "no embedding" : "vector search returned nothing",
5312
+ searchTerms: terms
5313
+ });
4793
5314
  if (terms.length > 0) {
4794
- const conditions = terms.map((t) => ({ content: ILike(`%${t}%`) }));
5315
+ const conditions = kbDocumentScope?.length ? terms.map((t) => ({ content: ILike(`%${t}%`), documentId: In(kbDocumentScope) })) : terms.map((t) => ({ content: ILike(`%${t}%`) }));
4795
5316
  const chunks = await chunkRepo().find({
4796
5317
  where: conditions,
4797
5318
  take: KB_CHUNK_LIMIT,
@@ -4806,19 +5327,66 @@ function createChatHandlers(config) {
4806
5327
  contextParts.push(text);
4807
5328
  totalLen += text.length;
4808
5329
  }
5330
+ console.info(RAG_LOG, "step 6a | keyword results", {
5331
+ chunksFound: chunks.length,
5332
+ chunksUsed: contextParts.length,
5333
+ totalChars: totalLen
5334
+ });
4809
5335
  }
4810
5336
  }
4811
- 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 }));
4812
- 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.
5337
+ const historyRaw = (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 }));
5338
+ const history = historyBeforeCurrentUser(historyRaw, message);
5339
+ let content;
5340
+ const ragContext = contextParts.length > 0 ? contextParts.join("\n\n") : void 0;
5341
+ console.info(RAG_LOG, "step 7 | final context", {
5342
+ method: contextParts.length > 0 ? "rag" : "none",
5343
+ contextChunks: contextParts.length,
5344
+ contextChars: ragContext?.length ?? 0,
5345
+ contextPreview: ragContext ? ragContext.slice(0, 200) + (ragContext.length > 200 ? "\u2026" : "") : "(no context)"
5346
+ });
5347
+ if (agentRow && llm.chatAgent) {
5348
+ const fromAgent = llmAgentToChatAgentOptions(agentRow);
5349
+ const systemPrompt = mergeGuardrailsIntoSystemPrompt(
5350
+ fromAgent.systemPrompt,
5351
+ parsedValidation.guardrailsForPrompt
5352
+ );
5353
+ const res = await llm.chatAgent({
5354
+ ...fromAgent,
5355
+ systemPrompt: systemPrompt || void 0,
5356
+ context: ragContext,
5357
+ history,
5358
+ userPrompt: message
5359
+ });
5360
+ content = res.content;
5361
+ } else {
5362
+ const ragSystem = 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.
4813
5363
 
4814
5364
  Context:
4815
- ${contextParts.join("\n\n")}` : "You are a helpful assistant for the company. If you do not have specific information, say so.";
4816
- const messages = [
4817
- { role: "system", content: systemContent },
4818
- ...history,
4819
- { role: "user", content: message }
4820
- ];
4821
- const { content } = await llm.chat(messages);
5365
+ ${contextParts.join("\n\n")}` : "";
5366
+ const defaultSystem = "You are a helpful assistant for the company. If you do not have specific information, say so.";
5367
+ let systemContent;
5368
+ if (agentRow) {
5369
+ const base = agentRow.systemInstruction?.trim() || "";
5370
+ systemContent = mergeGuardrailsIntoSystemPrompt(
5371
+ [base, ragSystem].filter(Boolean).join("\n\n") || defaultSystem,
5372
+ parsedValidation.guardrailsForPrompt
5373
+ );
5374
+ } else {
5375
+ systemContent = ragSystem || defaultSystem;
5376
+ }
5377
+ const messages = [
5378
+ { role: "system", content: systemContent },
5379
+ ...history,
5380
+ { role: "user", content: message }
5381
+ ];
5382
+ const chatOpts = agentRow ? {
5383
+ model: agentRow.model ?? void 0,
5384
+ temperature: agentRow.temperature ?? void 0,
5385
+ max_tokens: agentRow.maxTokens ?? void 0
5386
+ } : {};
5387
+ const res = await llm.chat(messages, chatOpts);
5388
+ content = res.content;
5389
+ }
4822
5390
  await msgRepoInst.save(msgRepoInst.create({ conversationId, role: "assistant", content }));
4823
5391
  return json({ content });
4824
5392
  } catch (err) {
@@ -4877,13 +5445,13 @@ async function loadPublicThemeSettings(config) {
4877
5445
  }
4878
5446
 
4879
5447
  // src/entities/user.entity.ts
4880
- import { Entity as Entity3, PrimaryGeneratedColumn as PrimaryGeneratedColumn3, Column as Column3, ManyToOne as ManyToOne2, JoinColumn as JoinColumn2 } from "typeorm";
5448
+ import { Entity as Entity4, PrimaryGeneratedColumn as PrimaryGeneratedColumn4, Column as Column4, ManyToOne as ManyToOne2, JoinColumn as JoinColumn2 } from "typeorm";
4881
5449
 
4882
5450
  // src/entities/user-group.entity.ts
4883
- import { Entity as Entity2, PrimaryGeneratedColumn as PrimaryGeneratedColumn2, Column as Column2, OneToMany } from "typeorm";
5451
+ import { Entity as Entity3, PrimaryGeneratedColumn as PrimaryGeneratedColumn3, Column as Column3, OneToMany } from "typeorm";
4884
5452
 
4885
5453
  // src/entities/permission.entity.ts
4886
- import { Entity, PrimaryGeneratedColumn, Column, ManyToOne, JoinColumn } from "typeorm";
5454
+ import { Entity as Entity2, PrimaryGeneratedColumn as PrimaryGeneratedColumn2, Column as Column2, ManyToOne, JoinColumn } from "typeorm";
4887
5455
  var Permission = class {
4888
5456
  id;
4889
5457
  groupId;
@@ -4902,53 +5470,53 @@ var Permission = class {
4902
5470
  group;
4903
5471
  };
4904
5472
  __decorateClass([
4905
- PrimaryGeneratedColumn()
5473
+ PrimaryGeneratedColumn2()
4906
5474
  ], Permission.prototype, "id", 2);
4907
5475
  __decorateClass([
4908
- Column("int")
5476
+ Column2("int")
4909
5477
  ], Permission.prototype, "groupId", 2);
4910
5478
  __decorateClass([
4911
- Column("varchar")
5479
+ Column2("varchar")
4912
5480
  ], Permission.prototype, "entity", 2);
4913
5481
  __decorateClass([
4914
- Column("boolean", { default: false })
5482
+ Column2("boolean", { default: false })
4915
5483
  ], Permission.prototype, "canCreate", 2);
4916
5484
  __decorateClass([
4917
- Column("boolean", { default: false })
5485
+ Column2("boolean", { default: false })
4918
5486
  ], Permission.prototype, "canRead", 2);
4919
5487
  __decorateClass([
4920
- Column("boolean", { default: false })
5488
+ Column2("boolean", { default: false })
4921
5489
  ], Permission.prototype, "canUpdate", 2);
4922
5490
  __decorateClass([
4923
- Column("boolean", { default: false })
5491
+ Column2("boolean", { default: false })
4924
5492
  ], Permission.prototype, "canDelete", 2);
4925
5493
  __decorateClass([
4926
- Column({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5494
+ Column2({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
4927
5495
  ], Permission.prototype, "createdAt", 2);
4928
5496
  __decorateClass([
4929
- Column({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5497
+ Column2({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
4930
5498
  ], Permission.prototype, "updatedAt", 2);
4931
5499
  __decorateClass([
4932
- Column({ type: "timestamp", nullable: true })
5500
+ Column2({ type: "timestamp", nullable: true })
4933
5501
  ], Permission.prototype, "deletedAt", 2);
4934
5502
  __decorateClass([
4935
- Column("boolean", { default: false })
5503
+ Column2("boolean", { default: false })
4936
5504
  ], Permission.prototype, "deleted", 2);
4937
5505
  __decorateClass([
4938
- Column("int", { nullable: true })
5506
+ Column2("int", { nullable: true })
4939
5507
  ], Permission.prototype, "createdBy", 2);
4940
5508
  __decorateClass([
4941
- Column("int", { nullable: true })
5509
+ Column2("int", { nullable: true })
4942
5510
  ], Permission.prototype, "updatedBy", 2);
4943
5511
  __decorateClass([
4944
- Column("int", { nullable: true })
5512
+ Column2("int", { nullable: true })
4945
5513
  ], Permission.prototype, "deletedBy", 2);
4946
5514
  __decorateClass([
4947
5515
  ManyToOne(() => UserGroup, (g) => g.permissions, { onDelete: "CASCADE" }),
4948
5516
  JoinColumn({ name: "groupId" })
4949
5517
  ], Permission.prototype, "group", 2);
4950
5518
  Permission = __decorateClass([
4951
- Entity("permissions")
5519
+ Entity2("permissions")
4952
5520
  ], Permission);
4953
5521
 
4954
5522
  // src/entities/user-group.entity.ts
@@ -4966,31 +5534,31 @@ var UserGroup = class {
4966
5534
  users;
4967
5535
  };
4968
5536
  __decorateClass([
4969
- PrimaryGeneratedColumn2()
5537
+ PrimaryGeneratedColumn3()
4970
5538
  ], UserGroup.prototype, "id", 2);
4971
5539
  __decorateClass([
4972
- Column2("varchar", { unique: true })
5540
+ Column3("varchar", { unique: true })
4973
5541
  ], UserGroup.prototype, "name", 2);
4974
5542
  __decorateClass([
4975
- Column2({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5543
+ Column3({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
4976
5544
  ], UserGroup.prototype, "createdAt", 2);
4977
5545
  __decorateClass([
4978
- Column2({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5546
+ Column3({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
4979
5547
  ], UserGroup.prototype, "updatedAt", 2);
4980
5548
  __decorateClass([
4981
- Column2({ type: "timestamp", nullable: true })
5549
+ Column3({ type: "timestamp", nullable: true })
4982
5550
  ], UserGroup.prototype, "deletedAt", 2);
4983
5551
  __decorateClass([
4984
- Column2("boolean", { default: false })
5552
+ Column3("boolean", { default: false })
4985
5553
  ], UserGroup.prototype, "deleted", 2);
4986
5554
  __decorateClass([
4987
- Column2("int", { nullable: true })
5555
+ Column3("int", { nullable: true })
4988
5556
  ], UserGroup.prototype, "createdBy", 2);
4989
5557
  __decorateClass([
4990
- Column2("int", { nullable: true })
5558
+ Column3("int", { nullable: true })
4991
5559
  ], UserGroup.prototype, "updatedBy", 2);
4992
5560
  __decorateClass([
4993
- Column2("int", { nullable: true })
5561
+ Column3("int", { nullable: true })
4994
5562
  ], UserGroup.prototype, "deletedBy", 2);
4995
5563
  __decorateClass([
4996
5564
  OneToMany(() => Permission, (p) => p.group)
@@ -4999,7 +5567,7 @@ __decorateClass([
4999
5567
  OneToMany(() => User, (u) => u.group)
5000
5568
  ], UserGroup.prototype, "users", 2);
5001
5569
  UserGroup = __decorateClass([
5002
- Entity2("user_groups")
5570
+ Entity3("user_groups")
5003
5571
  ], UserGroup);
5004
5572
 
5005
5573
  // src/entities/user.entity.ts
@@ -5024,66 +5592,66 @@ var User = class {
5024
5592
  group;
5025
5593
  };
5026
5594
  __decorateClass([
5027
- PrimaryGeneratedColumn3()
5595
+ PrimaryGeneratedColumn4()
5028
5596
  ], User.prototype, "id", 2);
5029
5597
  __decorateClass([
5030
- Column3("varchar")
5598
+ Column4("varchar")
5031
5599
  ], User.prototype, "name", 2);
5032
5600
  __decorateClass([
5033
- Column3("varchar", { unique: true })
5601
+ Column4("varchar", { unique: true })
5034
5602
  ], User.prototype, "email", 2);
5035
5603
  __decorateClass([
5036
- Column3("varchar", { nullable: true })
5604
+ Column4("varchar", { nullable: true })
5037
5605
  ], User.prototype, "phone", 2);
5038
5606
  __decorateClass([
5039
- Column3({ type: "timestamp", nullable: true })
5607
+ Column4({ type: "timestamp", nullable: true })
5040
5608
  ], User.prototype, "phoneVerifiedAt", 2);
5041
5609
  __decorateClass([
5042
- Column3({ type: "timestamp", nullable: true })
5610
+ Column4({ type: "timestamp", nullable: true })
5043
5611
  ], User.prototype, "emailVerifiedAt", 2);
5044
5612
  __decorateClass([
5045
- Column3("varchar", { nullable: true })
5613
+ Column4("varchar", { nullable: true })
5046
5614
  ], User.prototype, "password", 2);
5047
5615
  __decorateClass([
5048
- Column3("boolean", { default: false })
5616
+ Column4("boolean", { default: false })
5049
5617
  ], User.prototype, "blocked", 2);
5050
5618
  __decorateClass([
5051
- Column3("boolean", { default: false })
5619
+ Column4("boolean", { default: false })
5052
5620
  ], User.prototype, "adminAccess", 2);
5053
5621
  __decorateClass([
5054
- Column3("int", { nullable: true })
5622
+ Column4("int", { nullable: true })
5055
5623
  ], User.prototype, "groupId", 2);
5056
5624
  __decorateClass([
5057
- Column3({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5625
+ Column4({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5058
5626
  ], User.prototype, "createdAt", 2);
5059
5627
  __decorateClass([
5060
- Column3({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5628
+ Column4({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5061
5629
  ], User.prototype, "updatedAt", 2);
5062
5630
  __decorateClass([
5063
- Column3({ type: "timestamp", nullable: true })
5631
+ Column4({ type: "timestamp", nullable: true })
5064
5632
  ], User.prototype, "deletedAt", 2);
5065
5633
  __decorateClass([
5066
- Column3("boolean", { default: false })
5634
+ Column4("boolean", { default: false })
5067
5635
  ], User.prototype, "deleted", 2);
5068
5636
  __decorateClass([
5069
- Column3("int", { nullable: true })
5637
+ Column4("int", { nullable: true })
5070
5638
  ], User.prototype, "createdBy", 2);
5071
5639
  __decorateClass([
5072
- Column3("int", { nullable: true })
5640
+ Column4("int", { nullable: true })
5073
5641
  ], User.prototype, "updatedBy", 2);
5074
5642
  __decorateClass([
5075
- Column3("int", { nullable: true })
5643
+ Column4("int", { nullable: true })
5076
5644
  ], User.prototype, "deletedBy", 2);
5077
5645
  __decorateClass([
5078
5646
  ManyToOne2(() => UserGroup, (g) => g.users, { onDelete: "SET NULL" }),
5079
5647
  JoinColumn2({ name: "groupId" })
5080
5648
  ], User.prototype, "group", 2);
5081
5649
  User = __decorateClass([
5082
- Entity3("users")
5650
+ Entity4("users")
5083
5651
  ], User);
5084
5652
 
5085
5653
  // src/entities/otp-challenge.entity.ts
5086
- import { Entity as Entity4, PrimaryGeneratedColumn as PrimaryGeneratedColumn4, Column as Column4, Index } from "typeorm";
5654
+ import { Entity as Entity5, PrimaryGeneratedColumn as PrimaryGeneratedColumn5, Column as Column5, Index } from "typeorm";
5087
5655
  var OtpChallenge = class {
5088
5656
  id;
5089
5657
  purpose;
@@ -5096,39 +5664,39 @@ var OtpChallenge = class {
5096
5664
  createdAt;
5097
5665
  };
5098
5666
  __decorateClass([
5099
- PrimaryGeneratedColumn4()
5667
+ PrimaryGeneratedColumn5()
5100
5668
  ], OtpChallenge.prototype, "id", 2);
5101
5669
  __decorateClass([
5102
- Column4("varchar")
5670
+ Column5("varchar")
5103
5671
  ], OtpChallenge.prototype, "purpose", 2);
5104
5672
  __decorateClass([
5105
- Column4("varchar")
5673
+ Column5("varchar")
5106
5674
  ], OtpChallenge.prototype, "channel", 2);
5107
5675
  __decorateClass([
5108
- Column4("varchar")
5676
+ Column5("varchar")
5109
5677
  ], OtpChallenge.prototype, "identifier", 2);
5110
5678
  __decorateClass([
5111
- Column4("varchar")
5679
+ Column5("varchar")
5112
5680
  ], OtpChallenge.prototype, "codeHash", 2);
5113
5681
  __decorateClass([
5114
- Column4({ type: "timestamp" })
5682
+ Column5({ type: "timestamp" })
5115
5683
  ], OtpChallenge.prototype, "expiresAt", 2);
5116
5684
  __decorateClass([
5117
- Column4("int", { default: 0 })
5685
+ Column5("int", { default: 0 })
5118
5686
  ], OtpChallenge.prototype, "attempts", 2);
5119
5687
  __decorateClass([
5120
- Column4({ type: "timestamp", nullable: true })
5688
+ Column5({ type: "timestamp", nullable: true })
5121
5689
  ], OtpChallenge.prototype, "consumedAt", 2);
5122
5690
  __decorateClass([
5123
- Column4({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5691
+ Column5({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5124
5692
  ], OtpChallenge.prototype, "createdAt", 2);
5125
5693
  OtpChallenge = __decorateClass([
5126
- Entity4("otp_challenges"),
5694
+ Entity5("otp_challenges"),
5127
5695
  Index(["purpose", "identifier"])
5128
5696
  ], OtpChallenge);
5129
5697
 
5130
5698
  // src/entities/password-reset-token.entity.ts
5131
- import { Entity as Entity5, PrimaryGeneratedColumn as PrimaryGeneratedColumn5, Column as Column5 } from "typeorm";
5699
+ import { Entity as Entity6, PrimaryGeneratedColumn as PrimaryGeneratedColumn6, Column as Column6 } from "typeorm";
5132
5700
  var PasswordResetToken = class {
5133
5701
  id;
5134
5702
  email;
@@ -5137,29 +5705,29 @@ var PasswordResetToken = class {
5137
5705
  createdAt;
5138
5706
  };
5139
5707
  __decorateClass([
5140
- PrimaryGeneratedColumn5()
5708
+ PrimaryGeneratedColumn6()
5141
5709
  ], PasswordResetToken.prototype, "id", 2);
5142
5710
  __decorateClass([
5143
- Column5("varchar")
5711
+ Column6("varchar")
5144
5712
  ], PasswordResetToken.prototype, "email", 2);
5145
5713
  __decorateClass([
5146
- Column5("varchar", { unique: true })
5714
+ Column6("varchar", { unique: true })
5147
5715
  ], PasswordResetToken.prototype, "token", 2);
5148
5716
  __decorateClass([
5149
- Column5({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5717
+ Column6({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5150
5718
  ], PasswordResetToken.prototype, "expiresAt", 2);
5151
5719
  __decorateClass([
5152
- Column5({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5720
+ Column6({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5153
5721
  ], PasswordResetToken.prototype, "createdAt", 2);
5154
5722
  PasswordResetToken = __decorateClass([
5155
- Entity5("password_reset_tokens")
5723
+ Entity6("password_reset_tokens")
5156
5724
  ], PasswordResetToken);
5157
5725
 
5158
5726
  // src/entities/blog.entity.ts
5159
5727
  import {
5160
- Entity as Entity10,
5161
- PrimaryGeneratedColumn as PrimaryGeneratedColumn10,
5162
- Column as Column10,
5728
+ Entity as Entity11,
5729
+ PrimaryGeneratedColumn as PrimaryGeneratedColumn11,
5730
+ Column as Column11,
5163
5731
  ManyToOne as ManyToOne4,
5164
5732
  OneToMany as OneToMany4,
5165
5733
  ManyToMany as ManyToMany2,
@@ -5168,7 +5736,7 @@ import {
5168
5736
  } from "typeorm";
5169
5737
 
5170
5738
  // src/entities/category.entity.ts
5171
- import { Entity as Entity6, PrimaryGeneratedColumn as PrimaryGeneratedColumn6, Column as Column6, OneToMany as OneToMany2 } from "typeorm";
5739
+ import { Entity as Entity7, PrimaryGeneratedColumn as PrimaryGeneratedColumn7, Column as Column7, OneToMany as OneToMany2 } from "typeorm";
5172
5740
  var Category = class {
5173
5741
  id;
5174
5742
  name;
@@ -5182,41 +5750,41 @@ var Category = class {
5182
5750
  blogs;
5183
5751
  };
5184
5752
  __decorateClass([
5185
- PrimaryGeneratedColumn6()
5753
+ PrimaryGeneratedColumn7()
5186
5754
  ], Category.prototype, "id", 2);
5187
5755
  __decorateClass([
5188
- Column6("varchar", { unique: true })
5756
+ Column7("varchar", { unique: true })
5189
5757
  ], Category.prototype, "name", 2);
5190
5758
  __decorateClass([
5191
- Column6({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5759
+ Column7({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5192
5760
  ], Category.prototype, "createdAt", 2);
5193
5761
  __decorateClass([
5194
- Column6({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5762
+ Column7({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5195
5763
  ], Category.prototype, "updatedAt", 2);
5196
5764
  __decorateClass([
5197
- Column6({ type: "timestamp", nullable: true })
5765
+ Column7({ type: "timestamp", nullable: true })
5198
5766
  ], Category.prototype, "deletedAt", 2);
5199
5767
  __decorateClass([
5200
- Column6("boolean", { default: false })
5768
+ Column7("boolean", { default: false })
5201
5769
  ], Category.prototype, "deleted", 2);
5202
5770
  __decorateClass([
5203
- Column6("int", { nullable: true })
5771
+ Column7("int", { nullable: true })
5204
5772
  ], Category.prototype, "createdBy", 2);
5205
5773
  __decorateClass([
5206
- Column6("int", { nullable: true })
5774
+ Column7("int", { nullable: true })
5207
5775
  ], Category.prototype, "updatedBy", 2);
5208
5776
  __decorateClass([
5209
- Column6("int", { nullable: true })
5777
+ Column7("int", { nullable: true })
5210
5778
  ], Category.prototype, "deletedBy", 2);
5211
5779
  __decorateClass([
5212
5780
  OneToMany2("Blog", "category")
5213
5781
  ], Category.prototype, "blogs", 2);
5214
5782
  Category = __decorateClass([
5215
- Entity6("categories")
5783
+ Entity7("categories")
5216
5784
  ], Category);
5217
5785
 
5218
5786
  // src/entities/seo.entity.ts
5219
- import { Entity as Entity7, PrimaryGeneratedColumn as PrimaryGeneratedColumn7, Column as Column7, OneToMany as OneToMany3 } from "typeorm";
5787
+ import { Entity as Entity8, PrimaryGeneratedColumn as PrimaryGeneratedColumn8, Column as Column8, OneToMany as OneToMany3 } from "typeorm";
5220
5788
  var Seo = class {
5221
5789
  id;
5222
5790
  title;
@@ -5236,59 +5804,59 @@ var Seo = class {
5236
5804
  blogs;
5237
5805
  };
5238
5806
  __decorateClass([
5239
- PrimaryGeneratedColumn7()
5807
+ PrimaryGeneratedColumn8()
5240
5808
  ], Seo.prototype, "id", 2);
5241
5809
  __decorateClass([
5242
- Column7("varchar", { nullable: true })
5810
+ Column8("varchar", { nullable: true })
5243
5811
  ], Seo.prototype, "title", 2);
5244
5812
  __decorateClass([
5245
- Column7("varchar", { nullable: true })
5813
+ Column8("varchar", { nullable: true })
5246
5814
  ], Seo.prototype, "description", 2);
5247
5815
  __decorateClass([
5248
- Column7("varchar", { nullable: true })
5816
+ Column8("varchar", { nullable: true })
5249
5817
  ], Seo.prototype, "keywords", 2);
5250
5818
  __decorateClass([
5251
- Column7("varchar", { nullable: true })
5819
+ Column8("varchar", { nullable: true })
5252
5820
  ], Seo.prototype, "ogTitle", 2);
5253
5821
  __decorateClass([
5254
- Column7("varchar", { nullable: true })
5822
+ Column8("varchar", { nullable: true })
5255
5823
  ], Seo.prototype, "ogDescription", 2);
5256
5824
  __decorateClass([
5257
- Column7("varchar", { nullable: true })
5825
+ Column8("varchar", { nullable: true })
5258
5826
  ], Seo.prototype, "ogImage", 2);
5259
5827
  __decorateClass([
5260
- Column7("varchar", { unique: true })
5828
+ Column8("varchar", { unique: true })
5261
5829
  ], Seo.prototype, "slug", 2);
5262
5830
  __decorateClass([
5263
- Column7({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5831
+ Column8({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5264
5832
  ], Seo.prototype, "createdAt", 2);
5265
5833
  __decorateClass([
5266
- Column7({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5834
+ Column8({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5267
5835
  ], Seo.prototype, "updatedAt", 2);
5268
5836
  __decorateClass([
5269
- Column7({ type: "timestamp", nullable: true })
5837
+ Column8({ type: "timestamp", nullable: true })
5270
5838
  ], Seo.prototype, "deletedAt", 2);
5271
5839
  __decorateClass([
5272
- Column7("boolean", { default: false })
5840
+ Column8("boolean", { default: false })
5273
5841
  ], Seo.prototype, "deleted", 2);
5274
5842
  __decorateClass([
5275
- Column7("int", { nullable: true })
5843
+ Column8("int", { nullable: true })
5276
5844
  ], Seo.prototype, "createdBy", 2);
5277
5845
  __decorateClass([
5278
- Column7("int", { nullable: true })
5846
+ Column8("int", { nullable: true })
5279
5847
  ], Seo.prototype, "updatedBy", 2);
5280
5848
  __decorateClass([
5281
- Column7("int", { nullable: true })
5849
+ Column8("int", { nullable: true })
5282
5850
  ], Seo.prototype, "deletedBy", 2);
5283
5851
  __decorateClass([
5284
5852
  OneToMany3(() => Blog, (blog) => blog.seo)
5285
5853
  ], Seo.prototype, "blogs", 2);
5286
5854
  Seo = __decorateClass([
5287
- Entity7("seos")
5855
+ Entity8("seos")
5288
5856
  ], Seo);
5289
5857
 
5290
5858
  // src/entities/comment.entity.ts
5291
- import { Entity as Entity8, PrimaryGeneratedColumn as PrimaryGeneratedColumn8, Column as Column8, ManyToOne as ManyToOne3, JoinColumn as JoinColumn3 } from "typeorm";
5859
+ import { Entity as Entity9, PrimaryGeneratedColumn as PrimaryGeneratedColumn9, Column as Column9, ManyToOne as ManyToOne3, JoinColumn as JoinColumn3 } from "typeorm";
5292
5860
  var Comment = class {
5293
5861
  id;
5294
5862
  content;
@@ -5305,37 +5873,37 @@ var Comment = class {
5305
5873
  blog;
5306
5874
  };
5307
5875
  __decorateClass([
5308
- PrimaryGeneratedColumn8()
5876
+ PrimaryGeneratedColumn9()
5309
5877
  ], Comment.prototype, "id", 2);
5310
5878
  __decorateClass([
5311
- Column8("text")
5879
+ Column9("text")
5312
5880
  ], Comment.prototype, "content", 2);
5313
5881
  __decorateClass([
5314
- Column8("int")
5882
+ Column9("int")
5315
5883
  ], Comment.prototype, "blogId", 2);
5316
5884
  __decorateClass([
5317
- Column8("int")
5885
+ Column9("int")
5318
5886
  ], Comment.prototype, "authorId", 2);
5319
5887
  __decorateClass([
5320
- Column8({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5888
+ Column9({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5321
5889
  ], Comment.prototype, "createdAt", 2);
5322
5890
  __decorateClass([
5323
- Column8({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5891
+ Column9({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5324
5892
  ], Comment.prototype, "updatedAt", 2);
5325
5893
  __decorateClass([
5326
- Column8({ type: "timestamp", nullable: true })
5894
+ Column9({ type: "timestamp", nullable: true })
5327
5895
  ], Comment.prototype, "deletedAt", 2);
5328
5896
  __decorateClass([
5329
- Column8("boolean", { default: false })
5897
+ Column9("boolean", { default: false })
5330
5898
  ], Comment.prototype, "deleted", 2);
5331
5899
  __decorateClass([
5332
- Column8("int", { nullable: true })
5900
+ Column9("int", { nullable: true })
5333
5901
  ], Comment.prototype, "createdBy", 2);
5334
5902
  __decorateClass([
5335
- Column8("int", { nullable: true })
5903
+ Column9("int", { nullable: true })
5336
5904
  ], Comment.prototype, "updatedBy", 2);
5337
5905
  __decorateClass([
5338
- Column8("int", { nullable: true })
5906
+ Column9("int", { nullable: true })
5339
5907
  ], Comment.prototype, "deletedBy", 2);
5340
5908
  __decorateClass([
5341
5909
  ManyToOne3(() => User, { onDelete: "CASCADE" }),
@@ -5346,11 +5914,11 @@ __decorateClass([
5346
5914
  JoinColumn3({ name: "blogId" })
5347
5915
  ], Comment.prototype, "blog", 2);
5348
5916
  Comment = __decorateClass([
5349
- Entity8("comments")
5917
+ Entity9("comments")
5350
5918
  ], Comment);
5351
5919
 
5352
5920
  // src/entities/tag.entity.ts
5353
- import { Entity as Entity9, PrimaryGeneratedColumn as PrimaryGeneratedColumn9, Column as Column9, ManyToMany } from "typeorm";
5921
+ import { Entity as Entity10, PrimaryGeneratedColumn as PrimaryGeneratedColumn10, Column as Column10, ManyToMany } from "typeorm";
5354
5922
  var Tag = class {
5355
5923
  id;
5356
5924
  name;
@@ -5364,37 +5932,37 @@ var Tag = class {
5364
5932
  blogs;
5365
5933
  };
5366
5934
  __decorateClass([
5367
- PrimaryGeneratedColumn9()
5935
+ PrimaryGeneratedColumn10()
5368
5936
  ], Tag.prototype, "id", 2);
5369
5937
  __decorateClass([
5370
- Column9("varchar", { unique: true })
5938
+ Column10("varchar", { unique: true })
5371
5939
  ], Tag.prototype, "name", 2);
5372
5940
  __decorateClass([
5373
- Column9({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5941
+ Column10({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5374
5942
  ], Tag.prototype, "createdAt", 2);
5375
5943
  __decorateClass([
5376
- Column9({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5944
+ Column10({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5377
5945
  ], Tag.prototype, "updatedAt", 2);
5378
5946
  __decorateClass([
5379
- Column9({ type: "timestamp", nullable: true })
5947
+ Column10({ type: "timestamp", nullable: true })
5380
5948
  ], Tag.prototype, "deletedAt", 2);
5381
5949
  __decorateClass([
5382
- Column9("boolean", { default: false })
5950
+ Column10("boolean", { default: false })
5383
5951
  ], Tag.prototype, "deleted", 2);
5384
5952
  __decorateClass([
5385
- Column9("int", { nullable: true })
5953
+ Column10("int", { nullable: true })
5386
5954
  ], Tag.prototype, "createdBy", 2);
5387
5955
  __decorateClass([
5388
- Column9("int", { nullable: true })
5956
+ Column10("int", { nullable: true })
5389
5957
  ], Tag.prototype, "updatedBy", 2);
5390
5958
  __decorateClass([
5391
- Column9("int", { nullable: true })
5959
+ Column10("int", { nullable: true })
5392
5960
  ], Tag.prototype, "deletedBy", 2);
5393
5961
  __decorateClass([
5394
5962
  ManyToMany(() => Blog, (blog) => blog.tags)
5395
5963
  ], Tag.prototype, "blogs", 2);
5396
5964
  Tag = __decorateClass([
5397
- Entity9("tags")
5965
+ Entity10("tags")
5398
5966
  ], Tag);
5399
5967
 
5400
5968
  // src/entities/blog.entity.ts
@@ -5422,52 +5990,52 @@ var Blog = class {
5422
5990
  tags;
5423
5991
  };
5424
5992
  __decorateClass([
5425
- PrimaryGeneratedColumn10()
5993
+ PrimaryGeneratedColumn11()
5426
5994
  ], Blog.prototype, "id", 2);
5427
5995
  __decorateClass([
5428
- Column10("varchar")
5996
+ Column11("varchar")
5429
5997
  ], Blog.prototype, "title", 2);
5430
5998
  __decorateClass([
5431
- Column10("text")
5999
+ Column11("text")
5432
6000
  ], Blog.prototype, "content", 2);
5433
6001
  __decorateClass([
5434
- Column10("varchar", { nullable: true })
6002
+ Column11("varchar", { nullable: true })
5435
6003
  ], Blog.prototype, "coverImage", 2);
5436
6004
  __decorateClass([
5437
- Column10("int")
6005
+ Column11("int")
5438
6006
  ], Blog.prototype, "authorId", 2);
5439
6007
  __decorateClass([
5440
- Column10("int", { nullable: true })
6008
+ Column11("int", { nullable: true })
5441
6009
  ], Blog.prototype, "categoryId", 2);
5442
6010
  __decorateClass([
5443
- Column10("int", { nullable: true })
6011
+ Column11("int", { nullable: true })
5444
6012
  ], Blog.prototype, "seoId", 2);
5445
6013
  __decorateClass([
5446
- Column10("boolean", { default: false })
6014
+ Column11("boolean", { default: false })
5447
6015
  ], Blog.prototype, "published", 2);
5448
6016
  __decorateClass([
5449
- Column10({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6017
+ Column11({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5450
6018
  ], Blog.prototype, "createdAt", 2);
5451
6019
  __decorateClass([
5452
- Column10({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6020
+ Column11({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5453
6021
  ], Blog.prototype, "updatedAt", 2);
5454
6022
  __decorateClass([
5455
- Column10({ type: "timestamp", nullable: true })
6023
+ Column11({ type: "timestamp", nullable: true })
5456
6024
  ], Blog.prototype, "deletedAt", 2);
5457
6025
  __decorateClass([
5458
- Column10("boolean", { default: false })
6026
+ Column11("boolean", { default: false })
5459
6027
  ], Blog.prototype, "deleted", 2);
5460
6028
  __decorateClass([
5461
- Column10("int", { nullable: true })
6029
+ Column11("int", { nullable: true })
5462
6030
  ], Blog.prototype, "createdBy", 2);
5463
6031
  __decorateClass([
5464
- Column10("int", { nullable: true })
6032
+ Column11("int", { nullable: true })
5465
6033
  ], Blog.prototype, "updatedBy", 2);
5466
6034
  __decorateClass([
5467
- Column10("int", { nullable: true })
6035
+ Column11("int", { nullable: true })
5468
6036
  ], Blog.prototype, "deletedBy", 2);
5469
6037
  __decorateClass([
5470
- Column10("varchar", { unique: true })
6038
+ Column11("varchar", { unique: true })
5471
6039
  ], Blog.prototype, "slug", 2);
5472
6040
  __decorateClass([
5473
6041
  ManyToOne4(() => User, { onDelete: "CASCADE" }),
@@ -5493,20 +6061,20 @@ __decorateClass([
5493
6061
  })
5494
6062
  ], Blog.prototype, "tags", 2);
5495
6063
  Blog = __decorateClass([
5496
- Entity10("blogs")
6064
+ Entity11("blogs")
5497
6065
  ], Blog);
5498
6066
 
5499
6067
  // src/entities/contact.entity.ts
5500
- import { Entity as Entity19, PrimaryGeneratedColumn as PrimaryGeneratedColumn19, Column as Column19, OneToMany as OneToMany8, ManyToOne as ManyToOne12, JoinColumn as JoinColumn12 } from "typeorm";
6068
+ import { Entity as Entity20, PrimaryGeneratedColumn as PrimaryGeneratedColumn20, Column as Column20, OneToMany as OneToMany8, ManyToOne as ManyToOne12, JoinColumn as JoinColumn12 } from "typeorm";
5501
6069
 
5502
6070
  // src/entities/form-submission.entity.ts
5503
- import { Entity as Entity13, PrimaryGeneratedColumn as PrimaryGeneratedColumn13, Column as Column13, ManyToOne as ManyToOne6, JoinColumn as JoinColumn6 } from "typeorm";
6071
+ import { Entity as Entity14, PrimaryGeneratedColumn as PrimaryGeneratedColumn14, Column as Column14, ManyToOne as ManyToOne6, JoinColumn as JoinColumn6 } from "typeorm";
5504
6072
 
5505
6073
  // src/entities/form.entity.ts
5506
- import { Entity as Entity12, PrimaryGeneratedColumn as PrimaryGeneratedColumn12, Column as Column12, OneToMany as OneToMany5 } from "typeorm";
6074
+ import { Entity as Entity13, PrimaryGeneratedColumn as PrimaryGeneratedColumn13, Column as Column13, OneToMany as OneToMany5 } from "typeorm";
5507
6075
 
5508
6076
  // src/entities/form-field.entity.ts
5509
- import { Entity as Entity11, PrimaryGeneratedColumn as PrimaryGeneratedColumn11, Column as Column11, ManyToOne as ManyToOne5, JoinColumn as JoinColumn5 } from "typeorm";
6077
+ import { Entity as Entity12, PrimaryGeneratedColumn as PrimaryGeneratedColumn12, Column as Column12, ManyToOne as ManyToOne5, JoinColumn as JoinColumn5 } from "typeorm";
5510
6078
  var FormField = class {
5511
6079
  id;
5512
6080
  formId;
@@ -5529,65 +6097,65 @@ var FormField = class {
5529
6097
  form;
5530
6098
  };
5531
6099
  __decorateClass([
5532
- PrimaryGeneratedColumn11()
6100
+ PrimaryGeneratedColumn12()
5533
6101
  ], FormField.prototype, "id", 2);
5534
6102
  __decorateClass([
5535
- Column11("int")
6103
+ Column12("int")
5536
6104
  ], FormField.prototype, "formId", 2);
5537
6105
  __decorateClass([
5538
- Column11("varchar")
6106
+ Column12("varchar")
5539
6107
  ], FormField.prototype, "label", 2);
5540
6108
  __decorateClass([
5541
- Column11("varchar")
6109
+ Column12("varchar")
5542
6110
  ], FormField.prototype, "type", 2);
5543
6111
  __decorateClass([
5544
- Column11("varchar", { nullable: true })
6112
+ Column12("varchar", { nullable: true })
5545
6113
  ], FormField.prototype, "placeholder", 2);
5546
6114
  __decorateClass([
5547
- Column11("varchar", { nullable: true })
6115
+ Column12("varchar", { nullable: true })
5548
6116
  ], FormField.prototype, "options", 2);
5549
6117
  __decorateClass([
5550
- Column11("boolean", { default: false })
6118
+ Column12("boolean", { default: false })
5551
6119
  ], FormField.prototype, "required", 2);
5552
6120
  __decorateClass([
5553
- Column11("varchar", { nullable: true })
6121
+ Column12("varchar", { nullable: true })
5554
6122
  ], FormField.prototype, "validation", 2);
5555
6123
  __decorateClass([
5556
- Column11("int")
6124
+ Column12("int")
5557
6125
  ], FormField.prototype, "order", 2);
5558
6126
  __decorateClass([
5559
- Column11("int", { default: 1 })
6127
+ Column12("int", { default: 1 })
5560
6128
  ], FormField.prototype, "groupId", 2);
5561
6129
  __decorateClass([
5562
- Column11("int", { default: 12 })
6130
+ Column12("int", { default: 12 })
5563
6131
  ], FormField.prototype, "columnWidth", 2);
5564
6132
  __decorateClass([
5565
- Column11({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6133
+ Column12({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5566
6134
  ], FormField.prototype, "createdAt", 2);
5567
6135
  __decorateClass([
5568
- Column11({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6136
+ Column12({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5569
6137
  ], FormField.prototype, "updatedAt", 2);
5570
6138
  __decorateClass([
5571
- Column11({ type: "timestamp", nullable: true })
6139
+ Column12({ type: "timestamp", nullable: true })
5572
6140
  ], FormField.prototype, "deletedAt", 2);
5573
6141
  __decorateClass([
5574
- Column11("boolean", { default: false })
6142
+ Column12("boolean", { default: false })
5575
6143
  ], FormField.prototype, "deleted", 2);
5576
6144
  __decorateClass([
5577
- Column11("int", { nullable: true })
6145
+ Column12("int", { nullable: true })
5578
6146
  ], FormField.prototype, "createdBy", 2);
5579
6147
  __decorateClass([
5580
- Column11("int", { nullable: true })
6148
+ Column12("int", { nullable: true })
5581
6149
  ], FormField.prototype, "updatedBy", 2);
5582
6150
  __decorateClass([
5583
- Column11("int", { nullable: true })
6151
+ Column12("int", { nullable: true })
5584
6152
  ], FormField.prototype, "deletedBy", 2);
5585
6153
  __decorateClass([
5586
6154
  ManyToOne5(() => Form, (f) => f.fields, { onDelete: "CASCADE" }),
5587
6155
  JoinColumn5({ name: "formId" })
5588
6156
  ], FormField.prototype, "form", 2);
5589
6157
  FormField = __decorateClass([
5590
- Entity11("form_fields")
6158
+ Entity12("form_fields")
5591
6159
  ], FormField);
5592
6160
 
5593
6161
  // src/entities/form.entity.ts
@@ -5609,43 +6177,43 @@ var Form = class {
5609
6177
  submissions;
5610
6178
  };
5611
6179
  __decorateClass([
5612
- PrimaryGeneratedColumn12()
6180
+ PrimaryGeneratedColumn13()
5613
6181
  ], Form.prototype, "id", 2);
5614
6182
  __decorateClass([
5615
- Column12("varchar")
6183
+ Column13("varchar")
5616
6184
  ], Form.prototype, "name", 2);
5617
6185
  __decorateClass([
5618
- Column12("text", { nullable: true })
6186
+ Column13("text", { nullable: true })
5619
6187
  ], Form.prototype, "description", 2);
5620
6188
  __decorateClass([
5621
- Column12("varchar", { nullable: true })
6189
+ Column13("varchar", { nullable: true })
5622
6190
  ], Form.prototype, "campaign", 2);
5623
6191
  __decorateClass([
5624
- Column12("varchar", { unique: true })
6192
+ Column13("varchar", { unique: true })
5625
6193
  ], Form.prototype, "slug", 2);
5626
6194
  __decorateClass([
5627
- Column12("boolean", { default: false })
6195
+ Column13("boolean", { default: false })
5628
6196
  ], Form.prototype, "published", 2);
5629
6197
  __decorateClass([
5630
- Column12({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6198
+ Column13({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5631
6199
  ], Form.prototype, "createdAt", 2);
5632
6200
  __decorateClass([
5633
- Column12({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6201
+ Column13({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5634
6202
  ], Form.prototype, "updatedAt", 2);
5635
6203
  __decorateClass([
5636
- Column12({ type: "timestamp", nullable: true })
6204
+ Column13({ type: "timestamp", nullable: true })
5637
6205
  ], Form.prototype, "deletedAt", 2);
5638
6206
  __decorateClass([
5639
- Column12("boolean", { default: false })
6207
+ Column13("boolean", { default: false })
5640
6208
  ], Form.prototype, "deleted", 2);
5641
6209
  __decorateClass([
5642
- Column12("int", { nullable: true })
6210
+ Column13("int", { nullable: true })
5643
6211
  ], Form.prototype, "createdBy", 2);
5644
6212
  __decorateClass([
5645
- Column12("int", { nullable: true })
6213
+ Column13("int", { nullable: true })
5646
6214
  ], Form.prototype, "updatedBy", 2);
5647
6215
  __decorateClass([
5648
- Column12("int", { nullable: true })
6216
+ Column13("int", { nullable: true })
5649
6217
  ], Form.prototype, "deletedBy", 2);
5650
6218
  __decorateClass([
5651
6219
  OneToMany5(() => FormField, (f) => f.form)
@@ -5654,7 +6222,7 @@ __decorateClass([
5654
6222
  OneToMany5(() => FormSubmission, (s) => s.form)
5655
6223
  ], Form.prototype, "submissions", 2);
5656
6224
  Form = __decorateClass([
5657
- Entity12("forms")
6225
+ Entity13("forms")
5658
6226
  ], Form);
5659
6227
 
5660
6228
  // src/entities/form-submission.entity.ts
@@ -5671,28 +6239,28 @@ var FormSubmission = class {
5671
6239
  contact;
5672
6240
  };
5673
6241
  __decorateClass([
5674
- PrimaryGeneratedColumn13()
6242
+ PrimaryGeneratedColumn14()
5675
6243
  ], FormSubmission.prototype, "id", 2);
5676
6244
  __decorateClass([
5677
- Column13("int")
6245
+ Column14("int")
5678
6246
  ], FormSubmission.prototype, "formId", 2);
5679
6247
  __decorateClass([
5680
- Column13("int", { nullable: true })
6248
+ Column14("int", { nullable: true })
5681
6249
  ], FormSubmission.prototype, "contactId", 2);
5682
6250
  __decorateClass([
5683
- Column13("jsonb")
6251
+ Column14("jsonb")
5684
6252
  ], FormSubmission.prototype, "data", 2);
5685
6253
  __decorateClass([
5686
- Column13("varchar", { nullable: true })
6254
+ Column14("varchar", { nullable: true })
5687
6255
  ], FormSubmission.prototype, "ipAddress", 2);
5688
6256
  __decorateClass([
5689
- Column13("varchar", { nullable: true })
6257
+ Column14("varchar", { nullable: true })
5690
6258
  ], FormSubmission.prototype, "userAgent", 2);
5691
6259
  __decorateClass([
5692
- Column13({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6260
+ Column14({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5693
6261
  ], FormSubmission.prototype, "createdAt", 2);
5694
6262
  __decorateClass([
5695
- Column13({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6263
+ Column14({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5696
6264
  ], FormSubmission.prototype, "updatedAt", 2);
5697
6265
  __decorateClass([
5698
6266
  ManyToOne6(() => Form, (f) => f.submissions, { onDelete: "CASCADE" }),
@@ -5703,11 +6271,11 @@ __decorateClass([
5703
6271
  JoinColumn6({ name: "contactId" })
5704
6272
  ], FormSubmission.prototype, "contact", 2);
5705
6273
  FormSubmission = __decorateClass([
5706
- Entity13("form_submissions")
6274
+ Entity14("form_submissions")
5707
6275
  ], FormSubmission);
5708
6276
 
5709
6277
  // src/entities/address.entity.ts
5710
- import { Entity as Entity14, PrimaryGeneratedColumn as PrimaryGeneratedColumn14, Column as Column14, ManyToOne as ManyToOne7, JoinColumn as JoinColumn7 } from "typeorm";
6278
+ import { Entity as Entity15, PrimaryGeneratedColumn as PrimaryGeneratedColumn15, Column as Column15, ManyToOne as ManyToOne7, JoinColumn as JoinColumn7 } from "typeorm";
5711
6279
  var Address = class {
5712
6280
  id;
5713
6281
  contactId;
@@ -5723,48 +6291,48 @@ var Address = class {
5723
6291
  contact;
5724
6292
  };
5725
6293
  __decorateClass([
5726
- PrimaryGeneratedColumn14()
6294
+ PrimaryGeneratedColumn15()
5727
6295
  ], Address.prototype, "id", 2);
5728
6296
  __decorateClass([
5729
- Column14("int")
6297
+ Column15("int")
5730
6298
  ], Address.prototype, "contactId", 2);
5731
6299
  __decorateClass([
5732
- Column14("varchar", { nullable: true })
6300
+ Column15("varchar", { nullable: true })
5733
6301
  ], Address.prototype, "tag", 2);
5734
6302
  __decorateClass([
5735
- Column14("varchar", { nullable: true })
6303
+ Column15("varchar", { nullable: true })
5736
6304
  ], Address.prototype, "line1", 2);
5737
6305
  __decorateClass([
5738
- Column14("varchar", { nullable: true })
6306
+ Column15("varchar", { nullable: true })
5739
6307
  ], Address.prototype, "line2", 2);
5740
6308
  __decorateClass([
5741
- Column14("varchar", { nullable: true })
6309
+ Column15("varchar", { nullable: true })
5742
6310
  ], Address.prototype, "city", 2);
5743
6311
  __decorateClass([
5744
- Column14("varchar", { nullable: true })
6312
+ Column15("varchar", { nullable: true })
5745
6313
  ], Address.prototype, "state", 2);
5746
6314
  __decorateClass([
5747
- Column14("varchar", { nullable: true })
6315
+ Column15("varchar", { nullable: true })
5748
6316
  ], Address.prototype, "postalCode", 2);
5749
6317
  __decorateClass([
5750
- Column14("varchar", { nullable: true })
6318
+ Column15("varchar", { nullable: true })
5751
6319
  ], Address.prototype, "country", 2);
5752
6320
  __decorateClass([
5753
- Column14({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6321
+ Column15({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5754
6322
  ], Address.prototype, "createdAt", 2);
5755
6323
  __decorateClass([
5756
- Column14({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6324
+ Column15({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5757
6325
  ], Address.prototype, "updatedAt", 2);
5758
6326
  __decorateClass([
5759
6327
  ManyToOne7(() => Contact, (c) => c.addresses, { onDelete: "CASCADE" }),
5760
6328
  JoinColumn7({ name: "contactId" })
5761
6329
  ], Address.prototype, "contact", 2);
5762
6330
  Address = __decorateClass([
5763
- Entity14("addresses")
6331
+ Entity15("addresses")
5764
6332
  ], Address);
5765
6333
 
5766
6334
  // src/entities/order.entity.ts
5767
- import { Entity as Entity15, PrimaryGeneratedColumn as PrimaryGeneratedColumn15, Column as Column15, ManyToOne as ManyToOne8, OneToMany as OneToMany6, JoinColumn as JoinColumn8 } from "typeorm";
6335
+ import { Entity as Entity16, PrimaryGeneratedColumn as PrimaryGeneratedColumn16, Column as Column16, ManyToOne as ManyToOne8, OneToMany as OneToMany6, JoinColumn as JoinColumn8 } from "typeorm";
5768
6336
  var Order = class {
5769
6337
  id;
5770
6338
  orderNumber;
@@ -5796,67 +6364,67 @@ var Order = class {
5796
6364
  payments;
5797
6365
  };
5798
6366
  __decorateClass([
5799
- PrimaryGeneratedColumn15()
6367
+ PrimaryGeneratedColumn16()
5800
6368
  ], Order.prototype, "id", 2);
5801
6369
  __decorateClass([
5802
- Column15("varchar", { unique: true })
6370
+ Column16("varchar", { unique: true })
5803
6371
  ], Order.prototype, "orderNumber", 2);
5804
6372
  __decorateClass([
5805
- Column15("varchar", { default: "sale" })
6373
+ Column16("varchar", { default: "sale" })
5806
6374
  ], Order.prototype, "orderKind", 2);
5807
6375
  __decorateClass([
5808
- Column15("int", { nullable: true })
6376
+ Column16("int", { nullable: true })
5809
6377
  ], Order.prototype, "parentOrderId", 2);
5810
6378
  __decorateClass([
5811
- Column15("int")
6379
+ Column16("int")
5812
6380
  ], Order.prototype, "contactId", 2);
5813
6381
  __decorateClass([
5814
- Column15("int", { nullable: true })
6382
+ Column16("int", { nullable: true })
5815
6383
  ], Order.prototype, "billingAddressId", 2);
5816
6384
  __decorateClass([
5817
- Column15("int", { nullable: true })
6385
+ Column16("int", { nullable: true })
5818
6386
  ], Order.prototype, "shippingAddressId", 2);
5819
6387
  __decorateClass([
5820
- Column15("varchar", { default: "pending" })
6388
+ Column16("varchar", { default: "pending" })
5821
6389
  ], Order.prototype, "status", 2);
5822
6390
  __decorateClass([
5823
- Column15("decimal", { precision: 12, scale: 2, default: 0 })
6391
+ Column16("decimal", { precision: 12, scale: 2, default: 0 })
5824
6392
  ], Order.prototype, "subtotal", 2);
5825
6393
  __decorateClass([
5826
- Column15("decimal", { precision: 12, scale: 2, default: 0 })
6394
+ Column16("decimal", { precision: 12, scale: 2, default: 0 })
5827
6395
  ], Order.prototype, "tax", 2);
5828
6396
  __decorateClass([
5829
- Column15("decimal", { precision: 12, scale: 2, default: 0 })
6397
+ Column16("decimal", { precision: 12, scale: 2, default: 0 })
5830
6398
  ], Order.prototype, "discount", 2);
5831
6399
  __decorateClass([
5832
- Column15("decimal", { precision: 12, scale: 2, default: 0 })
6400
+ Column16("decimal", { precision: 12, scale: 2, default: 0 })
5833
6401
  ], Order.prototype, "total", 2);
5834
6402
  __decorateClass([
5835
- Column15("varchar", { default: "INR" })
6403
+ Column16("varchar", { default: "INR" })
5836
6404
  ], Order.prototype, "currency", 2);
5837
6405
  __decorateClass([
5838
- Column15("jsonb", { nullable: true })
6406
+ Column16("jsonb", { nullable: true })
5839
6407
  ], Order.prototype, "metadata", 2);
5840
6408
  __decorateClass([
5841
- Column15({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6409
+ Column16({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5842
6410
  ], Order.prototype, "createdAt", 2);
5843
6411
  __decorateClass([
5844
- Column15({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6412
+ Column16({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5845
6413
  ], Order.prototype, "updatedAt", 2);
5846
6414
  __decorateClass([
5847
- Column15({ type: "timestamp", nullable: true })
6415
+ Column16({ type: "timestamp", nullable: true })
5848
6416
  ], Order.prototype, "deletedAt", 2);
5849
6417
  __decorateClass([
5850
- Column15("boolean", { default: false })
6418
+ Column16("boolean", { default: false })
5851
6419
  ], Order.prototype, "deleted", 2);
5852
6420
  __decorateClass([
5853
- Column15("int", { nullable: true })
6421
+ Column16("int", { nullable: true })
5854
6422
  ], Order.prototype, "createdBy", 2);
5855
6423
  __decorateClass([
5856
- Column15("int", { nullable: true })
6424
+ Column16("int", { nullable: true })
5857
6425
  ], Order.prototype, "updatedBy", 2);
5858
6426
  __decorateClass([
5859
- Column15("int", { nullable: true })
6427
+ Column16("int", { nullable: true })
5860
6428
  ], Order.prototype, "deletedBy", 2);
5861
6429
  __decorateClass([
5862
6430
  ManyToOne8(() => Order, (o) => o.children, { nullable: true, onDelete: "SET NULL" }),
@@ -5884,11 +6452,11 @@ __decorateClass([
5884
6452
  OneToMany6("Payment", "order")
5885
6453
  ], Order.prototype, "payments", 2);
5886
6454
  Order = __decorateClass([
5887
- Entity15("orders")
6455
+ Entity16("orders")
5888
6456
  ], Order);
5889
6457
 
5890
6458
  // src/entities/payment.entity.ts
5891
- import { Entity as Entity16, PrimaryGeneratedColumn as PrimaryGeneratedColumn16, Column as Column16, ManyToOne as ManyToOne9, JoinColumn as JoinColumn9 } from "typeorm";
6459
+ import { Entity as Entity17, PrimaryGeneratedColumn as PrimaryGeneratedColumn17, Column as Column17, ManyToOne as ManyToOne9, JoinColumn as JoinColumn9 } from "typeorm";
5892
6460
  var Payment = class {
5893
6461
  id;
5894
6462
  orderId;
@@ -5911,55 +6479,55 @@ var Payment = class {
5911
6479
  contact;
5912
6480
  };
5913
6481
  __decorateClass([
5914
- PrimaryGeneratedColumn16()
6482
+ PrimaryGeneratedColumn17()
5915
6483
  ], Payment.prototype, "id", 2);
5916
6484
  __decorateClass([
5917
- Column16("int")
6485
+ Column17("int")
5918
6486
  ], Payment.prototype, "orderId", 2);
5919
6487
  __decorateClass([
5920
- Column16("int", { nullable: true })
6488
+ Column17("int", { nullable: true })
5921
6489
  ], Payment.prototype, "contactId", 2);
5922
6490
  __decorateClass([
5923
- Column16("decimal", { precision: 12, scale: 2 })
6491
+ Column17("decimal", { precision: 12, scale: 2 })
5924
6492
  ], Payment.prototype, "amount", 2);
5925
6493
  __decorateClass([
5926
- Column16("varchar", { default: "INR" })
6494
+ Column17("varchar", { default: "INR" })
5927
6495
  ], Payment.prototype, "currency", 2);
5928
6496
  __decorateClass([
5929
- Column16("varchar", { default: "pending" })
6497
+ Column17("varchar", { default: "pending" })
5930
6498
  ], Payment.prototype, "status", 2);
5931
6499
  __decorateClass([
5932
- Column16("varchar", { nullable: true })
6500
+ Column17("varchar", { nullable: true })
5933
6501
  ], Payment.prototype, "method", 2);
5934
6502
  __decorateClass([
5935
- Column16("varchar", { nullable: true })
6503
+ Column17("varchar", { nullable: true })
5936
6504
  ], Payment.prototype, "externalReference", 2);
5937
6505
  __decorateClass([
5938
- Column16("jsonb", { nullable: true })
6506
+ Column17("jsonb", { nullable: true })
5939
6507
  ], Payment.prototype, "metadata", 2);
5940
6508
  __decorateClass([
5941
- Column16({ type: "timestamp", nullable: true })
6509
+ Column17({ type: "timestamp", nullable: true })
5942
6510
  ], Payment.prototype, "paidAt", 2);
5943
6511
  __decorateClass([
5944
- Column16({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6512
+ Column17({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5945
6513
  ], Payment.prototype, "createdAt", 2);
5946
6514
  __decorateClass([
5947
- Column16({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6515
+ Column17({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5948
6516
  ], Payment.prototype, "updatedAt", 2);
5949
6517
  __decorateClass([
5950
- Column16({ type: "timestamp", nullable: true })
6518
+ Column17({ type: "timestamp", nullable: true })
5951
6519
  ], Payment.prototype, "deletedAt", 2);
5952
6520
  __decorateClass([
5953
- Column16("boolean", { default: false })
6521
+ Column17("boolean", { default: false })
5954
6522
  ], Payment.prototype, "deleted", 2);
5955
6523
  __decorateClass([
5956
- Column16("int", { nullable: true })
6524
+ Column17("int", { nullable: true })
5957
6525
  ], Payment.prototype, "createdBy", 2);
5958
6526
  __decorateClass([
5959
- Column16("int", { nullable: true })
6527
+ Column17("int", { nullable: true })
5960
6528
  ], Payment.prototype, "updatedBy", 2);
5961
6529
  __decorateClass([
5962
- Column16("int", { nullable: true })
6530
+ Column17("int", { nullable: true })
5963
6531
  ], Payment.prototype, "deletedBy", 2);
5964
6532
  __decorateClass([
5965
6533
  ManyToOne9(() => Order, (o) => o.payments, { onDelete: "CASCADE" }),
@@ -5970,14 +6538,14 @@ __decorateClass([
5970
6538
  JoinColumn9({ name: "contactId" })
5971
6539
  ], Payment.prototype, "contact", 2);
5972
6540
  Payment = __decorateClass([
5973
- Entity16("payments")
6541
+ Entity17("payments")
5974
6542
  ], Payment);
5975
6543
 
5976
6544
  // src/entities/chat-conversation.entity.ts
5977
- import { Entity as Entity18, PrimaryGeneratedColumn as PrimaryGeneratedColumn18, Column as Column18, ManyToOne as ManyToOne11, OneToMany as OneToMany7, JoinColumn as JoinColumn11 } from "typeorm";
6545
+ import { Entity as Entity19, PrimaryGeneratedColumn as PrimaryGeneratedColumn19, Column as Column19, ManyToOne as ManyToOne11, OneToMany as OneToMany7, JoinColumn as JoinColumn11 } from "typeorm";
5978
6546
 
5979
6547
  // src/entities/chat-message.entity.ts
5980
- import { Entity as Entity17, PrimaryGeneratedColumn as PrimaryGeneratedColumn17, Column as Column17, ManyToOne as ManyToOne10, JoinColumn as JoinColumn10 } from "typeorm";
6548
+ import { Entity as Entity18, PrimaryGeneratedColumn as PrimaryGeneratedColumn18, Column as Column18, ManyToOne as ManyToOne10, JoinColumn as JoinColumn10 } from "typeorm";
5981
6549
  var ChatMessage = class {
5982
6550
  id;
5983
6551
  conversationId;
@@ -5987,26 +6555,26 @@ var ChatMessage = class {
5987
6555
  conversation;
5988
6556
  };
5989
6557
  __decorateClass([
5990
- PrimaryGeneratedColumn17()
6558
+ PrimaryGeneratedColumn18()
5991
6559
  ], ChatMessage.prototype, "id", 2);
5992
6560
  __decorateClass([
5993
- Column17("int")
6561
+ Column18("int")
5994
6562
  ], ChatMessage.prototype, "conversationId", 2);
5995
6563
  __decorateClass([
5996
- Column17("varchar")
6564
+ Column18("varchar")
5997
6565
  ], ChatMessage.prototype, "role", 2);
5998
6566
  __decorateClass([
5999
- Column17("text")
6567
+ Column18("text")
6000
6568
  ], ChatMessage.prototype, "content", 2);
6001
6569
  __decorateClass([
6002
- Column17({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6570
+ Column18({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6003
6571
  ], ChatMessage.prototype, "createdAt", 2);
6004
6572
  __decorateClass([
6005
6573
  ManyToOne10(() => ChatConversation, (c) => c.messages, { onDelete: "CASCADE" }),
6006
6574
  JoinColumn10({ name: "conversationId" })
6007
6575
  ], ChatMessage.prototype, "conversation", 2);
6008
6576
  ChatMessage = __decorateClass([
6009
- Entity17("chat_messages")
6577
+ Entity18("chat_messages")
6010
6578
  ], ChatMessage);
6011
6579
 
6012
6580
  // src/entities/chat-conversation.entity.ts
@@ -6019,16 +6587,16 @@ var ChatConversation = class {
6019
6587
  messages;
6020
6588
  };
6021
6589
  __decorateClass([
6022
- PrimaryGeneratedColumn18()
6590
+ PrimaryGeneratedColumn19()
6023
6591
  ], ChatConversation.prototype, "id", 2);
6024
6592
  __decorateClass([
6025
- Column18("int")
6593
+ Column19("int")
6026
6594
  ], ChatConversation.prototype, "contactId", 2);
6027
6595
  __decorateClass([
6028
- Column18({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6596
+ Column19({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6029
6597
  ], ChatConversation.prototype, "createdAt", 2);
6030
6598
  __decorateClass([
6031
- Column18({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6599
+ Column19({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6032
6600
  ], ChatConversation.prototype, "updatedAt", 2);
6033
6601
  __decorateClass([
6034
6602
  ManyToOne11(() => Contact, (c) => c.chatConversations, { onDelete: "CASCADE" }),
@@ -6038,7 +6606,7 @@ __decorateClass([
6038
6606
  OneToMany7(() => ChatMessage, (m) => m.conversation)
6039
6607
  ], ChatConversation.prototype, "messages", 2);
6040
6608
  ChatConversation = __decorateClass([
6041
- Entity18("chat_conversations")
6609
+ Entity19("chat_conversations")
6042
6610
  ], ChatConversation);
6043
6611
 
6044
6612
  // src/entities/contact.entity.ts
@@ -6067,52 +6635,52 @@ var Contact = class {
6067
6635
  chatConversations;
6068
6636
  };
6069
6637
  __decorateClass([
6070
- PrimaryGeneratedColumn19()
6638
+ PrimaryGeneratedColumn20()
6071
6639
  ], Contact.prototype, "id", 2);
6072
6640
  __decorateClass([
6073
- Column19("varchar")
6641
+ Column20("varchar")
6074
6642
  ], Contact.prototype, "name", 2);
6075
6643
  __decorateClass([
6076
- Column19("varchar", { unique: true })
6644
+ Column20("varchar", { unique: true })
6077
6645
  ], Contact.prototype, "email", 2);
6078
6646
  __decorateClass([
6079
- Column19("varchar", { nullable: true })
6647
+ Column20("varchar", { nullable: true })
6080
6648
  ], Contact.prototype, "phone", 2);
6081
6649
  __decorateClass([
6082
- Column19("varchar", { nullable: true })
6650
+ Column20("varchar", { nullable: true })
6083
6651
  ], Contact.prototype, "type", 2);
6084
6652
  __decorateClass([
6085
- Column19("varchar", { nullable: true })
6653
+ Column20("varchar", { nullable: true })
6086
6654
  ], Contact.prototype, "company", 2);
6087
6655
  __decorateClass([
6088
- Column19("varchar", { nullable: true })
6656
+ Column20("varchar", { nullable: true })
6089
6657
  ], Contact.prototype, "taxId", 2);
6090
6658
  __decorateClass([
6091
- Column19("text", { nullable: true })
6659
+ Column20("text", { nullable: true })
6092
6660
  ], Contact.prototype, "notes", 2);
6093
6661
  __decorateClass([
6094
- Column19({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6662
+ Column20({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6095
6663
  ], Contact.prototype, "createdAt", 2);
6096
6664
  __decorateClass([
6097
- Column19({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6665
+ Column20({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6098
6666
  ], Contact.prototype, "updatedAt", 2);
6099
6667
  __decorateClass([
6100
- Column19({ type: "timestamp", nullable: true })
6668
+ Column20({ type: "timestamp", nullable: true })
6101
6669
  ], Contact.prototype, "deletedAt", 2);
6102
6670
  __decorateClass([
6103
- Column19("boolean", { default: false })
6671
+ Column20("boolean", { default: false })
6104
6672
  ], Contact.prototype, "deleted", 2);
6105
6673
  __decorateClass([
6106
- Column19("int", { nullable: true })
6674
+ Column20("int", { nullable: true })
6107
6675
  ], Contact.prototype, "createdBy", 2);
6108
6676
  __decorateClass([
6109
- Column19("int", { nullable: true })
6677
+ Column20("int", { nullable: true })
6110
6678
  ], Contact.prototype, "updatedBy", 2);
6111
6679
  __decorateClass([
6112
- Column19("int", { nullable: true })
6680
+ Column20("int", { nullable: true })
6113
6681
  ], Contact.prototype, "deletedBy", 2);
6114
6682
  __decorateClass([
6115
- Column19("int", { nullable: true })
6683
+ Column20("int", { nullable: true })
6116
6684
  ], Contact.prototype, "userId", 2);
6117
6685
  __decorateClass([
6118
6686
  ManyToOne12(() => User, { onDelete: "SET NULL" }),
@@ -6134,11 +6702,11 @@ __decorateClass([
6134
6702
  OneToMany8(() => ChatConversation, (c) => c.contact)
6135
6703
  ], Contact.prototype, "chatConversations", 2);
6136
6704
  Contact = __decorateClass([
6137
- Entity19("contacts")
6705
+ Entity20("contacts")
6138
6706
  ], Contact);
6139
6707
 
6140
6708
  // src/entities/config.entity.ts
6141
- import { Entity as Entity20, PrimaryGeneratedColumn as PrimaryGeneratedColumn20, Column as Column20, Unique } from "typeorm";
6709
+ import { Entity as Entity21, PrimaryGeneratedColumn as PrimaryGeneratedColumn21, Column as Column21, Unique } from "typeorm";
6142
6710
  var Config = class {
6143
6711
  id;
6144
6712
  settings;
@@ -6155,51 +6723,51 @@ var Config = class {
6155
6723
  deletedBy;
6156
6724
  };
6157
6725
  __decorateClass([
6158
- PrimaryGeneratedColumn20()
6726
+ PrimaryGeneratedColumn21()
6159
6727
  ], Config.prototype, "id", 2);
6160
6728
  __decorateClass([
6161
- Column20("varchar")
6729
+ Column21("varchar")
6162
6730
  ], Config.prototype, "settings", 2);
6163
6731
  __decorateClass([
6164
- Column20("varchar")
6732
+ Column21("varchar")
6165
6733
  ], Config.prototype, "key", 2);
6166
6734
  __decorateClass([
6167
- Column20("varchar")
6735
+ Column21("varchar")
6168
6736
  ], Config.prototype, "value", 2);
6169
6737
  __decorateClass([
6170
- Column20("varchar", { default: "private" })
6738
+ Column21("varchar", { default: "private" })
6171
6739
  ], Config.prototype, "type", 2);
6172
6740
  __decorateClass([
6173
- Column20("boolean", { default: false })
6741
+ Column21("boolean", { default: false })
6174
6742
  ], Config.prototype, "encrypted", 2);
6175
6743
  __decorateClass([
6176
- Column20({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6744
+ Column21({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6177
6745
  ], Config.prototype, "createdAt", 2);
6178
6746
  __decorateClass([
6179
- Column20({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6747
+ Column21({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6180
6748
  ], Config.prototype, "updatedAt", 2);
6181
6749
  __decorateClass([
6182
- Column20({ type: "timestamp", nullable: true })
6750
+ Column21({ type: "timestamp", nullable: true })
6183
6751
  ], Config.prototype, "deletedAt", 2);
6184
6752
  __decorateClass([
6185
- Column20("boolean", { default: false })
6753
+ Column21("boolean", { default: false })
6186
6754
  ], Config.prototype, "deleted", 2);
6187
6755
  __decorateClass([
6188
- Column20("int", { nullable: true })
6756
+ Column21("int", { nullable: true })
6189
6757
  ], Config.prototype, "createdBy", 2);
6190
6758
  __decorateClass([
6191
- Column20("int", { nullable: true })
6759
+ Column21("int", { nullable: true })
6192
6760
  ], Config.prototype, "updatedBy", 2);
6193
6761
  __decorateClass([
6194
- Column20("int", { nullable: true })
6762
+ Column21("int", { nullable: true })
6195
6763
  ], Config.prototype, "deletedBy", 2);
6196
6764
  Config = __decorateClass([
6197
- Entity20("configs"),
6765
+ Entity21("configs"),
6198
6766
  Unique(["settings", "key"])
6199
6767
  ], Config);
6200
6768
 
6201
6769
  // src/entities/message-template.entity.ts
6202
- import { Entity as Entity21, PrimaryGeneratedColumn as PrimaryGeneratedColumn21, Column as Column21 } from "typeorm";
6770
+ import { Entity as Entity22, PrimaryGeneratedColumn as PrimaryGeneratedColumn22, Column as Column22 } from "typeorm";
6203
6771
  var MessageTemplate = class {
6204
6772
  id;
6205
6773
  channel;
@@ -6219,59 +6787,59 @@ var MessageTemplate = class {
6219
6787
  deletedBy;
6220
6788
  };
6221
6789
  __decorateClass([
6222
- PrimaryGeneratedColumn21()
6790
+ PrimaryGeneratedColumn22()
6223
6791
  ], MessageTemplate.prototype, "id", 2);
6224
6792
  __decorateClass([
6225
- Column21("varchar")
6793
+ Column22("varchar")
6226
6794
  ], MessageTemplate.prototype, "channel", 2);
6227
6795
  __decorateClass([
6228
- Column21("varchar", { name: "template_key" })
6796
+ Column22("varchar", { name: "template_key" })
6229
6797
  ], MessageTemplate.prototype, "templateKey", 2);
6230
6798
  __decorateClass([
6231
- Column21("varchar", { nullable: true })
6799
+ Column22("varchar", { nullable: true })
6232
6800
  ], MessageTemplate.prototype, "name", 2);
6233
6801
  __decorateClass([
6234
- Column21("varchar", { nullable: true })
6802
+ Column22("varchar", { nullable: true })
6235
6803
  ], MessageTemplate.prototype, "subject", 2);
6236
6804
  __decorateClass([
6237
- Column21("text", { default: "" })
6805
+ Column22("text", { default: "" })
6238
6806
  ], MessageTemplate.prototype, "body", 2);
6239
6807
  __decorateClass([
6240
- Column21("varchar", { name: "external_template_ref", nullable: true })
6808
+ Column22("varchar", { name: "external_template_ref", nullable: true })
6241
6809
  ], MessageTemplate.prototype, "externalTemplateRef", 2);
6242
6810
  __decorateClass([
6243
- Column21({ type: "jsonb", nullable: true })
6811
+ Column22({ type: "jsonb", nullable: true })
6244
6812
  ], MessageTemplate.prototype, "providerMeta", 2);
6245
6813
  __decorateClass([
6246
- Column21("boolean", { default: true })
6814
+ Column22("boolean", { default: true })
6247
6815
  ], MessageTemplate.prototype, "enabled", 2);
6248
6816
  __decorateClass([
6249
- Column21({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6817
+ Column22({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6250
6818
  ], MessageTemplate.prototype, "createdAt", 2);
6251
6819
  __decorateClass([
6252
- Column21({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6820
+ Column22({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6253
6821
  ], MessageTemplate.prototype, "updatedAt", 2);
6254
6822
  __decorateClass([
6255
- Column21({ type: "timestamp", nullable: true })
6823
+ Column22({ type: "timestamp", nullable: true })
6256
6824
  ], MessageTemplate.prototype, "deletedAt", 2);
6257
6825
  __decorateClass([
6258
- Column21("boolean", { default: false })
6826
+ Column22("boolean", { default: false })
6259
6827
  ], MessageTemplate.prototype, "deleted", 2);
6260
6828
  __decorateClass([
6261
- Column21("int", { nullable: true })
6829
+ Column22("int", { nullable: true })
6262
6830
  ], MessageTemplate.prototype, "createdBy", 2);
6263
6831
  __decorateClass([
6264
- Column21("int", { nullable: true })
6832
+ Column22("int", { nullable: true })
6265
6833
  ], MessageTemplate.prototype, "updatedBy", 2);
6266
6834
  __decorateClass([
6267
- Column21("int", { nullable: true })
6835
+ Column22("int", { nullable: true })
6268
6836
  ], MessageTemplate.prototype, "deletedBy", 2);
6269
6837
  MessageTemplate = __decorateClass([
6270
- Entity21("message_templates")
6838
+ Entity22("message_templates")
6271
6839
  ], MessageTemplate);
6272
6840
 
6273
6841
  // src/entities/media.entity.ts
6274
- import { Entity as Entity22, PrimaryGeneratedColumn as PrimaryGeneratedColumn22, Column as Column22, ManyToOne as ManyToOne13, OneToMany as OneToMany9, JoinColumn as JoinColumn13 } from "typeorm";
6842
+ import { Entity as Entity23, PrimaryGeneratedColumn as PrimaryGeneratedColumn23, Column as Column23, ManyToOne as ManyToOne13, OneToMany as OneToMany9, JoinColumn as JoinColumn13 } from "typeorm";
6275
6843
  var Media = class {
6276
6844
  id;
6277
6845
  kind;
@@ -6290,13 +6858,13 @@ var Media = class {
6290
6858
  deleted;
6291
6859
  };
6292
6860
  __decorateClass([
6293
- PrimaryGeneratedColumn22()
6861
+ PrimaryGeneratedColumn23()
6294
6862
  ], Media.prototype, "id", 2);
6295
6863
  __decorateClass([
6296
- Column22({ type: "varchar", length: 16, default: "file" })
6864
+ Column23({ type: "varchar", length: 16, default: "file" })
6297
6865
  ], Media.prototype, "kind", 2);
6298
6866
  __decorateClass([
6299
- Column22({ type: "int", nullable: true })
6867
+ Column23({ type: "int", nullable: true })
6300
6868
  ], Media.prototype, "parentId", 2);
6301
6869
  __decorateClass([
6302
6870
  ManyToOne13(() => Media, (m) => m.children, { onDelete: "CASCADE" }),
@@ -6306,41 +6874,41 @@ __decorateClass([
6306
6874
  OneToMany9(() => Media, (m) => m.parent)
6307
6875
  ], Media.prototype, "children", 2);
6308
6876
  __decorateClass([
6309
- Column22("varchar")
6877
+ Column23("varchar")
6310
6878
  ], Media.prototype, "filename", 2);
6311
6879
  __decorateClass([
6312
- Column22("varchar", { nullable: true })
6880
+ Column23("varchar", { nullable: true })
6313
6881
  ], Media.prototype, "url", 2);
6314
6882
  __decorateClass([
6315
- Column22("varchar", { nullable: true })
6883
+ Column23("varchar", { nullable: true })
6316
6884
  ], Media.prototype, "mimeType", 2);
6317
6885
  __decorateClass([
6318
- Column22("int", { default: 0 })
6886
+ Column23("int", { default: 0 })
6319
6887
  ], Media.prototype, "size", 2);
6320
6888
  __decorateClass([
6321
- Column22("varchar", { nullable: true })
6889
+ Column23("varchar", { nullable: true })
6322
6890
  ], Media.prototype, "alt", 2);
6323
6891
  __decorateClass([
6324
- Column22("boolean", { default: false })
6892
+ Column23("boolean", { default: false })
6325
6893
  ], Media.prototype, "isPublic", 2);
6326
6894
  __decorateClass([
6327
- Column22({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6895
+ Column23({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6328
6896
  ], Media.prototype, "createdAt", 2);
6329
6897
  __decorateClass([
6330
- Column22({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6898
+ Column23({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6331
6899
  ], Media.prototype, "updatedAt", 2);
6332
6900
  __decorateClass([
6333
- Column22({ type: "timestamp", nullable: true })
6901
+ Column23({ type: "timestamp", nullable: true })
6334
6902
  ], Media.prototype, "deletedAt", 2);
6335
6903
  __decorateClass([
6336
- Column22("boolean", { default: false })
6904
+ Column23("boolean", { default: false })
6337
6905
  ], Media.prototype, "deleted", 2);
6338
6906
  Media = __decorateClass([
6339
- Entity22("media")
6907
+ Entity23("media")
6340
6908
  ], Media);
6341
6909
 
6342
6910
  // src/entities/page.entity.ts
6343
- import { Entity as Entity23, PrimaryGeneratedColumn as PrimaryGeneratedColumn23, Column as Column23, ManyToOne as ManyToOne14, JoinColumn as JoinColumn14 } from "typeorm";
6911
+ import { Entity as Entity24, PrimaryGeneratedColumn as PrimaryGeneratedColumn24, Column as Column24, ManyToOne as ManyToOne14, JoinColumn as JoinColumn14 } from "typeorm";
6344
6912
  var Page = class {
6345
6913
  id;
6346
6914
  title;
@@ -6361,64 +6929,64 @@ var Page = class {
6361
6929
  deletedBy;
6362
6930
  };
6363
6931
  __decorateClass([
6364
- PrimaryGeneratedColumn23()
6932
+ PrimaryGeneratedColumn24()
6365
6933
  ], Page.prototype, "id", 2);
6366
6934
  __decorateClass([
6367
- Column23("varchar")
6935
+ Column24("varchar")
6368
6936
  ], Page.prototype, "title", 2);
6369
6937
  __decorateClass([
6370
- Column23("varchar", { unique: true })
6938
+ Column24("varchar", { unique: true })
6371
6939
  ], Page.prototype, "slug", 2);
6372
6940
  __decorateClass([
6373
- Column23({ type: "jsonb", default: {} })
6941
+ Column24({ type: "jsonb", default: {} })
6374
6942
  ], Page.prototype, "content", 2);
6375
6943
  __decorateClass([
6376
- Column23("boolean", { default: false })
6944
+ Column24("boolean", { default: false })
6377
6945
  ], Page.prototype, "published", 2);
6378
6946
  __decorateClass([
6379
- Column23("varchar", { default: "default" })
6947
+ Column24("varchar", { default: "default" })
6380
6948
  ], Page.prototype, "theme", 2);
6381
6949
  __decorateClass([
6382
- Column23("int", { nullable: true })
6950
+ Column24("int", { nullable: true })
6383
6951
  ], Page.prototype, "parentId", 2);
6384
6952
  __decorateClass([
6385
6953
  ManyToOne14(() => Page, { onDelete: "SET NULL" }),
6386
6954
  JoinColumn14({ name: "parentId" })
6387
6955
  ], Page.prototype, "parent", 2);
6388
6956
  __decorateClass([
6389
- Column23("int", { nullable: true })
6957
+ Column24("int", { nullable: true })
6390
6958
  ], Page.prototype, "seoId", 2);
6391
6959
  __decorateClass([
6392
6960
  ManyToOne14(() => Seo, { onDelete: "SET NULL" }),
6393
6961
  JoinColumn14({ name: "seoId" })
6394
6962
  ], Page.prototype, "seo", 2);
6395
6963
  __decorateClass([
6396
- Column23({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6964
+ Column24({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6397
6965
  ], Page.prototype, "createdAt", 2);
6398
6966
  __decorateClass([
6399
- Column23({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6967
+ Column24({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6400
6968
  ], Page.prototype, "updatedAt", 2);
6401
6969
  __decorateClass([
6402
- Column23({ type: "timestamp", nullable: true })
6970
+ Column24({ type: "timestamp", nullable: true })
6403
6971
  ], Page.prototype, "deletedAt", 2);
6404
6972
  __decorateClass([
6405
- Column23("boolean", { default: false })
6973
+ Column24("boolean", { default: false })
6406
6974
  ], Page.prototype, "deleted", 2);
6407
6975
  __decorateClass([
6408
- Column23("int", { nullable: true })
6976
+ Column24("int", { nullable: true })
6409
6977
  ], Page.prototype, "createdBy", 2);
6410
6978
  __decorateClass([
6411
- Column23("int", { nullable: true })
6979
+ Column24("int", { nullable: true })
6412
6980
  ], Page.prototype, "updatedBy", 2);
6413
6981
  __decorateClass([
6414
- Column23("int", { nullable: true })
6982
+ Column24("int", { nullable: true })
6415
6983
  ], Page.prototype, "deletedBy", 2);
6416
6984
  Page = __decorateClass([
6417
- Entity23("pages")
6985
+ Entity24("pages")
6418
6986
  ], Page);
6419
6987
 
6420
6988
  // src/entities/product-category.entity.ts
6421
- import { Entity as Entity24, PrimaryGeneratedColumn as PrimaryGeneratedColumn24, Column as Column24, ManyToOne as ManyToOne15, OneToMany as OneToMany10, JoinColumn as JoinColumn15 } from "typeorm";
6989
+ import { Entity as Entity25, PrimaryGeneratedColumn as PrimaryGeneratedColumn25, Column as Column25, ManyToOne as ManyToOne15, OneToMany as OneToMany10, JoinColumn as JoinColumn15 } from "typeorm";
6422
6990
  var ProductCategory = class {
6423
6991
  id;
6424
6992
  name;
@@ -6442,52 +7010,52 @@ var ProductCategory = class {
6442
7010
  collections;
6443
7011
  };
6444
7012
  __decorateClass([
6445
- PrimaryGeneratedColumn24()
7013
+ PrimaryGeneratedColumn25()
6446
7014
  ], ProductCategory.prototype, "id", 2);
6447
7015
  __decorateClass([
6448
- Column24("varchar")
7016
+ Column25("varchar")
6449
7017
  ], ProductCategory.prototype, "name", 2);
6450
7018
  __decorateClass([
6451
- Column24("varchar", { unique: true })
7019
+ Column25("varchar", { unique: true })
6452
7020
  ], ProductCategory.prototype, "slug", 2);
6453
7021
  __decorateClass([
6454
- Column24("int", { nullable: true })
7022
+ Column25("int", { nullable: true })
6455
7023
  ], ProductCategory.prototype, "parentId", 2);
6456
7024
  __decorateClass([
6457
- Column24("varchar", { nullable: true })
7025
+ Column25("varchar", { nullable: true })
6458
7026
  ], ProductCategory.prototype, "image", 2);
6459
7027
  __decorateClass([
6460
- Column24("text", { nullable: true })
7028
+ Column25("text", { nullable: true })
6461
7029
  ], ProductCategory.prototype, "description", 2);
6462
7030
  __decorateClass([
6463
- Column24("jsonb", { nullable: true })
7031
+ Column25("jsonb", { nullable: true })
6464
7032
  ], ProductCategory.prototype, "metadata", 2);
6465
7033
  __decorateClass([
6466
- Column24("boolean", { default: true })
7034
+ Column25("boolean", { default: true })
6467
7035
  ], ProductCategory.prototype, "active", 2);
6468
7036
  __decorateClass([
6469
- Column24("int", { default: 0 })
7037
+ Column25("int", { default: 0 })
6470
7038
  ], ProductCategory.prototype, "sortOrder", 2);
6471
7039
  __decorateClass([
6472
- Column24({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7040
+ Column25({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6473
7041
  ], ProductCategory.prototype, "createdAt", 2);
6474
7042
  __decorateClass([
6475
- Column24({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7043
+ Column25({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6476
7044
  ], ProductCategory.prototype, "updatedAt", 2);
6477
7045
  __decorateClass([
6478
- Column24({ type: "timestamp", nullable: true })
7046
+ Column25({ type: "timestamp", nullable: true })
6479
7047
  ], ProductCategory.prototype, "deletedAt", 2);
6480
7048
  __decorateClass([
6481
- Column24("boolean", { default: false })
7049
+ Column25("boolean", { default: false })
6482
7050
  ], ProductCategory.prototype, "deleted", 2);
6483
7051
  __decorateClass([
6484
- Column24("int", { nullable: true })
7052
+ Column25("int", { nullable: true })
6485
7053
  ], ProductCategory.prototype, "createdBy", 2);
6486
7054
  __decorateClass([
6487
- Column24("int", { nullable: true })
7055
+ Column25("int", { nullable: true })
6488
7056
  ], ProductCategory.prototype, "updatedBy", 2);
6489
7057
  __decorateClass([
6490
- Column24("int", { nullable: true })
7058
+ Column25("int", { nullable: true })
6491
7059
  ], ProductCategory.prototype, "deletedBy", 2);
6492
7060
  __decorateClass([
6493
7061
  ManyToOne15(() => ProductCategory, (c) => c.children, { onDelete: "SET NULL" }),
@@ -6503,14 +7071,14 @@ __decorateClass([
6503
7071
  OneToMany10("Collection", "category")
6504
7072
  ], ProductCategory.prototype, "collections", 2);
6505
7073
  ProductCategory = __decorateClass([
6506
- Entity24("product_categories")
7074
+ Entity25("product_categories")
6507
7075
  ], ProductCategory);
6508
7076
 
6509
7077
  // src/entities/collection.entity.ts
6510
- import { Entity as Entity26, PrimaryGeneratedColumn as PrimaryGeneratedColumn26, Column as Column26, ManyToOne as ManyToOne17, OneToMany as OneToMany12, JoinColumn as JoinColumn17 } from "typeorm";
7078
+ import { Entity as Entity27, PrimaryGeneratedColumn as PrimaryGeneratedColumn27, Column as Column27, ManyToOne as ManyToOne17, OneToMany as OneToMany12, JoinColumn as JoinColumn17 } from "typeorm";
6511
7079
 
6512
7080
  // src/entities/brand.entity.ts
6513
- import { Entity as Entity25, PrimaryGeneratedColumn as PrimaryGeneratedColumn25, Column as Column25, OneToMany as OneToMany11, ManyToOne as ManyToOne16, JoinColumn as JoinColumn16 } from "typeorm";
7081
+ import { Entity as Entity26, PrimaryGeneratedColumn as PrimaryGeneratedColumn26, Column as Column26, OneToMany as OneToMany11, ManyToOne as ManyToOne16, JoinColumn as JoinColumn16 } from "typeorm";
6514
7082
  var Brand = class {
6515
7083
  id;
6516
7084
  name;
@@ -6533,52 +7101,52 @@ var Brand = class {
6533
7101
  collections;
6534
7102
  };
6535
7103
  __decorateClass([
6536
- PrimaryGeneratedColumn25()
7104
+ PrimaryGeneratedColumn26()
6537
7105
  ], Brand.prototype, "id", 2);
6538
7106
  __decorateClass([
6539
- Column25("varchar")
7107
+ Column26("varchar")
6540
7108
  ], Brand.prototype, "name", 2);
6541
7109
  __decorateClass([
6542
- Column25("varchar", { unique: true })
7110
+ Column26("varchar", { unique: true })
6543
7111
  ], Brand.prototype, "slug", 2);
6544
7112
  __decorateClass([
6545
- Column25("varchar", { nullable: true })
7113
+ Column26("varchar", { nullable: true })
6546
7114
  ], Brand.prototype, "logo", 2);
6547
7115
  __decorateClass([
6548
- Column25("jsonb", { nullable: true })
7116
+ Column26("jsonb", { nullable: true })
6549
7117
  ], Brand.prototype, "metadata", 2);
6550
7118
  __decorateClass([
6551
- Column25("text", { nullable: true })
7119
+ Column26("text", { nullable: true })
6552
7120
  ], Brand.prototype, "description", 2);
6553
7121
  __decorateClass([
6554
- Column25("boolean", { default: true })
7122
+ Column26("boolean", { default: true })
6555
7123
  ], Brand.prototype, "active", 2);
6556
7124
  __decorateClass([
6557
- Column25("int", { default: 0 })
7125
+ Column26("int", { default: 0 })
6558
7126
  ], Brand.prototype, "sortOrder", 2);
6559
7127
  __decorateClass([
6560
- Column25({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7128
+ Column26({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6561
7129
  ], Brand.prototype, "createdAt", 2);
6562
7130
  __decorateClass([
6563
- Column25({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7131
+ Column26({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6564
7132
  ], Brand.prototype, "updatedAt", 2);
6565
7133
  __decorateClass([
6566
- Column25({ type: "timestamp", nullable: true })
7134
+ Column26({ type: "timestamp", nullable: true })
6567
7135
  ], Brand.prototype, "deletedAt", 2);
6568
7136
  __decorateClass([
6569
- Column25("boolean", { default: false })
7137
+ Column26("boolean", { default: false })
6570
7138
  ], Brand.prototype, "deleted", 2);
6571
7139
  __decorateClass([
6572
- Column25("int", { nullable: true })
7140
+ Column26("int", { nullable: true })
6573
7141
  ], Brand.prototype, "createdBy", 2);
6574
7142
  __decorateClass([
6575
- Column25("int", { nullable: true })
7143
+ Column26("int", { nullable: true })
6576
7144
  ], Brand.prototype, "updatedBy", 2);
6577
7145
  __decorateClass([
6578
- Column25("int", { nullable: true })
7146
+ Column26("int", { nullable: true })
6579
7147
  ], Brand.prototype, "deletedBy", 2);
6580
7148
  __decorateClass([
6581
- Column25("int", { nullable: true })
7149
+ Column26("int", { nullable: true })
6582
7150
  ], Brand.prototype, "seoId", 2);
6583
7151
  __decorateClass([
6584
7152
  ManyToOne16(() => Seo, { onDelete: "SET NULL" }),
@@ -6591,7 +7159,7 @@ __decorateClass([
6591
7159
  OneToMany11("Collection", "brand")
6592
7160
  ], Brand.prototype, "collections", 2);
6593
7161
  Brand = __decorateClass([
6594
- Entity25("brands")
7162
+ Entity26("brands")
6595
7163
  ], Brand);
6596
7164
 
6597
7165
  // src/entities/collection.entity.ts
@@ -6605,6 +7173,7 @@ var Collection = class {
6605
7173
  description;
6606
7174
  image;
6607
7175
  metadata;
7176
+ variants;
6608
7177
  active;
6609
7178
  sortOrder;
6610
7179
  createdAt;
@@ -6621,61 +7190,64 @@ var Collection = class {
6621
7190
  products;
6622
7191
  };
6623
7192
  __decorateClass([
6624
- PrimaryGeneratedColumn26()
7193
+ PrimaryGeneratedColumn27()
6625
7194
  ], Collection.prototype, "id", 2);
6626
7195
  __decorateClass([
6627
- Column26("int", { nullable: true })
7196
+ Column27("int", { nullable: true })
6628
7197
  ], Collection.prototype, "categoryId", 2);
6629
7198
  __decorateClass([
6630
- Column26("int", { nullable: true })
7199
+ Column27("int", { nullable: true })
6631
7200
  ], Collection.prototype, "brandId", 2);
6632
7201
  __decorateClass([
6633
- Column26("varchar")
7202
+ Column27("varchar")
6634
7203
  ], Collection.prototype, "name", 2);
6635
7204
  __decorateClass([
6636
- Column26("varchar", { unique: true })
7205
+ Column27("varchar", { unique: true })
6637
7206
  ], Collection.prototype, "slug", 2);
6638
7207
  __decorateClass([
6639
- Column26("varchar", { nullable: true })
7208
+ Column27("varchar", { nullable: true })
6640
7209
  ], Collection.prototype, "hsn", 2);
6641
7210
  __decorateClass([
6642
- Column26("text", { nullable: true })
7211
+ Column27("text", { nullable: true })
6643
7212
  ], Collection.prototype, "description", 2);
6644
7213
  __decorateClass([
6645
- Column26("varchar", { nullable: true })
7214
+ Column27("varchar", { nullable: true })
6646
7215
  ], Collection.prototype, "image", 2);
6647
7216
  __decorateClass([
6648
- Column26("jsonb", { nullable: true })
7217
+ Column27("jsonb", { nullable: true })
6649
7218
  ], Collection.prototype, "metadata", 2);
6650
7219
  __decorateClass([
6651
- Column26("boolean", { default: true })
7220
+ Column27("jsonb", { nullable: true })
7221
+ ], Collection.prototype, "variants", 2);
7222
+ __decorateClass([
7223
+ Column27("boolean", { default: true })
6652
7224
  ], Collection.prototype, "active", 2);
6653
7225
  __decorateClass([
6654
- Column26("int", { default: 0 })
7226
+ Column27("int", { default: 0 })
6655
7227
  ], Collection.prototype, "sortOrder", 2);
6656
7228
  __decorateClass([
6657
- Column26({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7229
+ Column27({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6658
7230
  ], Collection.prototype, "createdAt", 2);
6659
7231
  __decorateClass([
6660
- Column26({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7232
+ Column27({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6661
7233
  ], Collection.prototype, "updatedAt", 2);
6662
7234
  __decorateClass([
6663
- Column26({ type: "timestamp", nullable: true })
7235
+ Column27({ type: "timestamp", nullable: true })
6664
7236
  ], Collection.prototype, "deletedAt", 2);
6665
7237
  __decorateClass([
6666
- Column26("boolean", { default: false })
7238
+ Column27("boolean", { default: false })
6667
7239
  ], Collection.prototype, "deleted", 2);
6668
7240
  __decorateClass([
6669
- Column26("int", { nullable: true })
7241
+ Column27("int", { nullable: true })
6670
7242
  ], Collection.prototype, "createdBy", 2);
6671
7243
  __decorateClass([
6672
- Column26("int", { nullable: true })
7244
+ Column27("int", { nullable: true })
6673
7245
  ], Collection.prototype, "updatedBy", 2);
6674
7246
  __decorateClass([
6675
- Column26("int", { nullable: true })
7247
+ Column27("int", { nullable: true })
6676
7248
  ], Collection.prototype, "deletedBy", 2);
6677
7249
  __decorateClass([
6678
- Column26("int", { nullable: true })
7250
+ Column27("int", { nullable: true })
6679
7251
  ], Collection.prototype, "seoId", 2);
6680
7252
  __decorateClass([
6681
7253
  ManyToOne17(() => Seo, { onDelete: "SET NULL" }),
@@ -6693,11 +7265,11 @@ __decorateClass([
6693
7265
  OneToMany12("Product", "collection")
6694
7266
  ], Collection.prototype, "products", 2);
6695
7267
  Collection = __decorateClass([
6696
- Entity26("collections")
7268
+ Entity27("collections")
6697
7269
  ], Collection);
6698
7270
 
6699
7271
  // src/entities/product.entity.ts
6700
- import { Entity as Entity27, PrimaryGeneratedColumn as PrimaryGeneratedColumn27, Column as Column27, ManyToOne as ManyToOne18, OneToMany as OneToMany13, JoinColumn as JoinColumn18 } from "typeorm";
7272
+ import { Entity as Entity28, PrimaryGeneratedColumn as PrimaryGeneratedColumn28, Column as Column28, ManyToOne as ManyToOne18, OneToMany as OneToMany13, JoinColumn as JoinColumn18 } from "typeorm";
6701
7273
  var Product = class {
6702
7274
  id;
6703
7275
  collectionId;
@@ -6731,76 +7303,76 @@ var Product = class {
6731
7303
  taxes;
6732
7304
  };
6733
7305
  __decorateClass([
6734
- PrimaryGeneratedColumn27()
7306
+ PrimaryGeneratedColumn28()
6735
7307
  ], Product.prototype, "id", 2);
6736
7308
  __decorateClass([
6737
- Column27("int", { nullable: true })
7309
+ Column28("int", { nullable: true })
6738
7310
  ], Product.prototype, "collectionId", 2);
6739
7311
  __decorateClass([
6740
- Column27("int", { nullable: true })
7312
+ Column28("int", { nullable: true })
6741
7313
  ], Product.prototype, "brandId", 2);
6742
7314
  __decorateClass([
6743
- Column27("int", { nullable: true })
7315
+ Column28("int", { nullable: true })
6744
7316
  ], Product.prototype, "categoryId", 2);
6745
7317
  __decorateClass([
6746
- Column27("varchar", { nullable: true })
7318
+ Column28("varchar", { nullable: true })
6747
7319
  ], Product.prototype, "sku", 2);
6748
7320
  __decorateClass([
6749
- Column27("varchar", { nullable: true })
7321
+ Column28("varchar", { nullable: true })
6750
7322
  ], Product.prototype, "hsn", 2);
6751
7323
  __decorateClass([
6752
- Column27("varchar", { nullable: true })
7324
+ Column28("varchar", { nullable: true })
6753
7325
  ], Product.prototype, "uom", 2);
6754
7326
  __decorateClass([
6755
- Column27("varchar", { default: "product" })
7327
+ Column28("varchar", { default: "product" })
6756
7328
  ], Product.prototype, "type", 2);
6757
7329
  __decorateClass([
6758
- Column27("varchar", { unique: true, nullable: true })
7330
+ Column28("varchar", { unique: true, nullable: true })
6759
7331
  ], Product.prototype, "slug", 2);
6760
7332
  __decorateClass([
6761
- Column27("varchar", { nullable: true })
7333
+ Column28("varchar", { nullable: true })
6762
7334
  ], Product.prototype, "name", 2);
6763
7335
  __decorateClass([
6764
- Column27("decimal", { precision: 12, scale: 2 })
7336
+ Column28("decimal", { precision: 12, scale: 2 })
6765
7337
  ], Product.prototype, "price", 2);
6766
7338
  __decorateClass([
6767
- Column27("decimal", { precision: 12, scale: 2, nullable: true })
7339
+ Column28("decimal", { precision: 12, scale: 2, nullable: true })
6768
7340
  ], Product.prototype, "compareAtPrice", 2);
6769
7341
  __decorateClass([
6770
- Column27("int", { default: 0 })
7342
+ Column28("int", { default: 0 })
6771
7343
  ], Product.prototype, "quantity", 2);
6772
7344
  __decorateClass([
6773
- Column27("varchar", { default: "draft" })
7345
+ Column28("varchar", { default: "draft" })
6774
7346
  ], Product.prototype, "status", 2);
6775
7347
  __decorateClass([
6776
- Column27("boolean", { default: false })
7348
+ Column28("boolean", { default: false })
6777
7349
  ], Product.prototype, "featured", 2);
6778
7350
  __decorateClass([
6779
- Column27("jsonb", { nullable: true })
7351
+ Column28("jsonb", { nullable: true })
6780
7352
  ], Product.prototype, "metadata", 2);
6781
7353
  __decorateClass([
6782
- Column27({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7354
+ Column28({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6783
7355
  ], Product.prototype, "createdAt", 2);
6784
7356
  __decorateClass([
6785
- Column27({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7357
+ Column28({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6786
7358
  ], Product.prototype, "updatedAt", 2);
6787
7359
  __decorateClass([
6788
- Column27({ type: "timestamp", nullable: true })
7360
+ Column28({ type: "timestamp", nullable: true })
6789
7361
  ], Product.prototype, "deletedAt", 2);
6790
7362
  __decorateClass([
6791
- Column27("boolean", { default: false })
7363
+ Column28("boolean", { default: false })
6792
7364
  ], Product.prototype, "deleted", 2);
6793
7365
  __decorateClass([
6794
- Column27("int", { nullable: true })
7366
+ Column28("int", { nullable: true })
6795
7367
  ], Product.prototype, "createdBy", 2);
6796
7368
  __decorateClass([
6797
- Column27("int", { nullable: true })
7369
+ Column28("int", { nullable: true })
6798
7370
  ], Product.prototype, "updatedBy", 2);
6799
7371
  __decorateClass([
6800
- Column27("int", { nullable: true })
7372
+ Column28("int", { nullable: true })
6801
7373
  ], Product.prototype, "deletedBy", 2);
6802
7374
  __decorateClass([
6803
- Column27("int", { nullable: true })
7375
+ Column28("int", { nullable: true })
6804
7376
  ], Product.prototype, "seoId", 2);
6805
7377
  __decorateClass([
6806
7378
  ManyToOne18(() => Seo, { onDelete: "SET NULL" }),
@@ -6825,11 +7397,11 @@ __decorateClass([
6825
7397
  OneToMany13("ProductTax", "product")
6826
7398
  ], Product.prototype, "taxes", 2);
6827
7399
  Product = __decorateClass([
6828
- Entity27("products")
7400
+ Entity28("products")
6829
7401
  ], Product);
6830
7402
 
6831
7403
  // src/entities/attribute.entity.ts
6832
- import { Entity as Entity28, PrimaryGeneratedColumn as PrimaryGeneratedColumn28, Column as Column28 } from "typeorm";
7404
+ import { Entity as Entity29, PrimaryGeneratedColumn as PrimaryGeneratedColumn29, Column as Column29 } from "typeorm";
6833
7405
  var Attribute = class {
6834
7406
  id;
6835
7407
  name;
@@ -6848,56 +7420,56 @@ var Attribute = class {
6848
7420
  deletedBy;
6849
7421
  };
6850
7422
  __decorateClass([
6851
- PrimaryGeneratedColumn28()
7423
+ PrimaryGeneratedColumn29()
6852
7424
  ], Attribute.prototype, "id", 2);
6853
7425
  __decorateClass([
6854
- Column28("varchar")
7426
+ Column29("varchar")
6855
7427
  ], Attribute.prototype, "name", 2);
6856
7428
  __decorateClass([
6857
- Column28("varchar", { unique: true })
7429
+ Column29("varchar", { unique: true })
6858
7430
  ], Attribute.prototype, "slug", 2);
6859
7431
  __decorateClass([
6860
- Column28("varchar", { default: "text" })
7432
+ Column29("varchar", { default: "text" })
6861
7433
  ], Attribute.prototype, "type", 2);
6862
7434
  __decorateClass([
6863
- Column28("jsonb", { nullable: true })
7435
+ Column29("jsonb", { nullable: true })
6864
7436
  ], Attribute.prototype, "options", 2);
6865
7437
  __decorateClass([
6866
- Column28("jsonb", { nullable: true })
7438
+ Column29("jsonb", { nullable: true })
6867
7439
  ], Attribute.prototype, "metadata", 2);
6868
7440
  __decorateClass([
6869
- Column28("boolean", { default: true })
7441
+ Column29("boolean", { default: true })
6870
7442
  ], Attribute.prototype, "active", 2);
6871
7443
  __decorateClass([
6872
- Column28("int", { default: 0 })
7444
+ Column29("int", { default: 0 })
6873
7445
  ], Attribute.prototype, "sortOrder", 2);
6874
7446
  __decorateClass([
6875
- Column28({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7447
+ Column29({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6876
7448
  ], Attribute.prototype, "createdAt", 2);
6877
7449
  __decorateClass([
6878
- Column28({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7450
+ Column29({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6879
7451
  ], Attribute.prototype, "updatedAt", 2);
6880
7452
  __decorateClass([
6881
- Column28({ type: "timestamp", nullable: true })
7453
+ Column29({ type: "timestamp", nullable: true })
6882
7454
  ], Attribute.prototype, "deletedAt", 2);
6883
7455
  __decorateClass([
6884
- Column28("boolean", { default: false })
7456
+ Column29("boolean", { default: false })
6885
7457
  ], Attribute.prototype, "deleted", 2);
6886
7458
  __decorateClass([
6887
- Column28("int", { nullable: true })
7459
+ Column29("int", { nullable: true })
6888
7460
  ], Attribute.prototype, "createdBy", 2);
6889
7461
  __decorateClass([
6890
- Column28("int", { nullable: true })
7462
+ Column29("int", { nullable: true })
6891
7463
  ], Attribute.prototype, "updatedBy", 2);
6892
7464
  __decorateClass([
6893
- Column28("int", { nullable: true })
7465
+ Column29("int", { nullable: true })
6894
7466
  ], Attribute.prototype, "deletedBy", 2);
6895
7467
  Attribute = __decorateClass([
6896
- Entity28("attributes")
7468
+ Entity29("attributes")
6897
7469
  ], Attribute);
6898
7470
 
6899
7471
  // src/entities/product-attribute.entity.ts
6900
- import { Entity as Entity29, PrimaryGeneratedColumn as PrimaryGeneratedColumn29, Column as Column29, ManyToOne as ManyToOne19, JoinColumn as JoinColumn19 } from "typeorm";
7472
+ import { Entity as Entity30, PrimaryGeneratedColumn as PrimaryGeneratedColumn30, Column as Column30, ManyToOne as ManyToOne19, JoinColumn as JoinColumn19 } from "typeorm";
6901
7473
  var ProductAttribute = class {
6902
7474
  id;
6903
7475
  productId;
@@ -6910,25 +7482,25 @@ var ProductAttribute = class {
6910
7482
  attribute;
6911
7483
  };
6912
7484
  __decorateClass([
6913
- PrimaryGeneratedColumn29()
7485
+ PrimaryGeneratedColumn30()
6914
7486
  ], ProductAttribute.prototype, "id", 2);
6915
7487
  __decorateClass([
6916
- Column29("int")
7488
+ Column30("int")
6917
7489
  ], ProductAttribute.prototype, "productId", 2);
6918
7490
  __decorateClass([
6919
- Column29("int")
7491
+ Column30("int")
6920
7492
  ], ProductAttribute.prototype, "attributeId", 2);
6921
7493
  __decorateClass([
6922
- Column29("varchar")
7494
+ Column30("varchar")
6923
7495
  ], ProductAttribute.prototype, "value", 2);
6924
7496
  __decorateClass([
6925
- Column29("jsonb", { nullable: true })
7497
+ Column30("jsonb", { nullable: true })
6926
7498
  ], ProductAttribute.prototype, "metadata", 2);
6927
7499
  __decorateClass([
6928
- Column29({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7500
+ Column30({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6929
7501
  ], ProductAttribute.prototype, "createdAt", 2);
6930
7502
  __decorateClass([
6931
- Column29({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7503
+ Column30({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6932
7504
  ], ProductAttribute.prototype, "updatedAt", 2);
6933
7505
  __decorateClass([
6934
7506
  ManyToOne19(() => Product, (p) => p.attributes, { onDelete: "CASCADE" }),
@@ -6939,11 +7511,11 @@ __decorateClass([
6939
7511
  JoinColumn19({ name: "attributeId" })
6940
7512
  ], ProductAttribute.prototype, "attribute", 2);
6941
7513
  ProductAttribute = __decorateClass([
6942
- Entity29("product_attributes")
7514
+ Entity30("product_attributes")
6943
7515
  ], ProductAttribute);
6944
7516
 
6945
7517
  // src/entities/tax.entity.ts
6946
- import { Entity as Entity30, PrimaryGeneratedColumn as PrimaryGeneratedColumn30, Column as Column30 } from "typeorm";
7518
+ import { Entity as Entity31, PrimaryGeneratedColumn as PrimaryGeneratedColumn31, Column as Column31 } from "typeorm";
6947
7519
  var Tax = class {
6948
7520
  id;
6949
7521
  name;
@@ -6962,56 +7534,56 @@ var Tax = class {
6962
7534
  deletedBy;
6963
7535
  };
6964
7536
  __decorateClass([
6965
- PrimaryGeneratedColumn30()
7537
+ PrimaryGeneratedColumn31()
6966
7538
  ], Tax.prototype, "id", 2);
6967
7539
  __decorateClass([
6968
- Column30("varchar")
7540
+ Column31("varchar")
6969
7541
  ], Tax.prototype, "name", 2);
6970
7542
  __decorateClass([
6971
- Column30("varchar", { unique: true })
7543
+ Column31("varchar", { unique: true })
6972
7544
  ], Tax.prototype, "slug", 2);
6973
7545
  __decorateClass([
6974
- Column30("decimal", { precision: 5, scale: 2 })
7546
+ Column31("decimal", { precision: 5, scale: 2 })
6975
7547
  ], Tax.prototype, "rate", 2);
6976
7548
  __decorateClass([
6977
- Column30("boolean", { default: false })
7549
+ Column31("boolean", { default: false })
6978
7550
  ], Tax.prototype, "isDefault", 2);
6979
7551
  __decorateClass([
6980
- Column30("text", { nullable: true })
7552
+ Column31("text", { nullable: true })
6981
7553
  ], Tax.prototype, "description", 2);
6982
7554
  __decorateClass([
6983
- Column30("boolean", { default: true })
7555
+ Column31("boolean", { default: true })
6984
7556
  ], Tax.prototype, "active", 2);
6985
7557
  __decorateClass([
6986
- Column30("jsonb", { nullable: true })
7558
+ Column31("jsonb", { nullable: true })
6987
7559
  ], Tax.prototype, "metadata", 2);
6988
7560
  __decorateClass([
6989
- Column30({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7561
+ Column31({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6990
7562
  ], Tax.prototype, "createdAt", 2);
6991
7563
  __decorateClass([
6992
- Column30({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7564
+ Column31({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6993
7565
  ], Tax.prototype, "updatedAt", 2);
6994
7566
  __decorateClass([
6995
- Column30({ type: "timestamp", nullable: true })
7567
+ Column31({ type: "timestamp", nullable: true })
6996
7568
  ], Tax.prototype, "deletedAt", 2);
6997
7569
  __decorateClass([
6998
- Column30("boolean", { default: false })
7570
+ Column31("boolean", { default: false })
6999
7571
  ], Tax.prototype, "deleted", 2);
7000
7572
  __decorateClass([
7001
- Column30("int", { nullable: true })
7573
+ Column31("int", { nullable: true })
7002
7574
  ], Tax.prototype, "createdBy", 2);
7003
7575
  __decorateClass([
7004
- Column30("int", { nullable: true })
7576
+ Column31("int", { nullable: true })
7005
7577
  ], Tax.prototype, "updatedBy", 2);
7006
7578
  __decorateClass([
7007
- Column30("int", { nullable: true })
7579
+ Column31("int", { nullable: true })
7008
7580
  ], Tax.prototype, "deletedBy", 2);
7009
7581
  Tax = __decorateClass([
7010
- Entity30("taxes")
7582
+ Entity31("taxes")
7011
7583
  ], Tax);
7012
7584
 
7013
7585
  // src/entities/product-tax.entity.ts
7014
- import { Entity as Entity31, PrimaryGeneratedColumn as PrimaryGeneratedColumn31, Column as Column31, ManyToOne as ManyToOne20, JoinColumn as JoinColumn20 } from "typeorm";
7586
+ import { Entity as Entity32, PrimaryGeneratedColumn as PrimaryGeneratedColumn32, Column as Column32, ManyToOne as ManyToOne20, JoinColumn as JoinColumn20 } from "typeorm";
7015
7587
  var ProductTax = class {
7016
7588
  id;
7017
7589
  productId;
@@ -7023,22 +7595,22 @@ var ProductTax = class {
7023
7595
  tax;
7024
7596
  };
7025
7597
  __decorateClass([
7026
- PrimaryGeneratedColumn31()
7598
+ PrimaryGeneratedColumn32()
7027
7599
  ], ProductTax.prototype, "id", 2);
7028
7600
  __decorateClass([
7029
- Column31("int")
7601
+ Column32("int")
7030
7602
  ], ProductTax.prototype, "productId", 2);
7031
7603
  __decorateClass([
7032
- Column31("int")
7604
+ Column32("int")
7033
7605
  ], ProductTax.prototype, "taxId", 2);
7034
7606
  __decorateClass([
7035
- Column31("decimal", { precision: 5, scale: 2, nullable: true })
7607
+ Column32("decimal", { precision: 5, scale: 2, nullable: true })
7036
7608
  ], ProductTax.prototype, "rate", 2);
7037
7609
  __decorateClass([
7038
- Column31({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7610
+ Column32({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7039
7611
  ], ProductTax.prototype, "createdAt", 2);
7040
7612
  __decorateClass([
7041
- Column31({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7613
+ Column32({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7042
7614
  ], ProductTax.prototype, "updatedAt", 2);
7043
7615
  __decorateClass([
7044
7616
  ManyToOne20(() => Product, (p) => p.taxes, { onDelete: "CASCADE" }),
@@ -7049,11 +7621,11 @@ __decorateClass([
7049
7621
  JoinColumn20({ name: "taxId" })
7050
7622
  ], ProductTax.prototype, "tax", 2);
7051
7623
  ProductTax = __decorateClass([
7052
- Entity31("product_taxes")
7624
+ Entity32("product_taxes")
7053
7625
  ], ProductTax);
7054
7626
 
7055
7627
  // src/entities/order-item.entity.ts
7056
- import { Entity as Entity32, PrimaryGeneratedColumn as PrimaryGeneratedColumn32, Column as Column32, ManyToOne as ManyToOne21, JoinColumn as JoinColumn21 } from "typeorm";
7628
+ import { Entity as Entity33, PrimaryGeneratedColumn as PrimaryGeneratedColumn33, Column as Column33, ManyToOne as ManyToOne21, JoinColumn as JoinColumn21 } from "typeorm";
7057
7629
  var OrderItem = class {
7058
7630
  id;
7059
7631
  orderId;
@@ -7074,49 +7646,49 @@ var OrderItem = class {
7074
7646
  product;
7075
7647
  };
7076
7648
  __decorateClass([
7077
- PrimaryGeneratedColumn32()
7649
+ PrimaryGeneratedColumn33()
7078
7650
  ], OrderItem.prototype, "id", 2);
7079
7651
  __decorateClass([
7080
- Column32("int")
7652
+ Column33("int")
7081
7653
  ], OrderItem.prototype, "orderId", 2);
7082
7654
  __decorateClass([
7083
- Column32("int")
7655
+ Column33("int")
7084
7656
  ], OrderItem.prototype, "productId", 2);
7085
7657
  __decorateClass([
7086
- Column32("int", { default: 1 })
7658
+ Column33("int", { default: 1 })
7087
7659
  ], OrderItem.prototype, "quantity", 2);
7088
7660
  __decorateClass([
7089
- Column32("decimal", { precision: 12, scale: 2 })
7661
+ Column33("decimal", { precision: 12, scale: 2 })
7090
7662
  ], OrderItem.prototype, "unitPrice", 2);
7091
7663
  __decorateClass([
7092
- Column32("decimal", { precision: 12, scale: 2, default: 0 })
7664
+ Column33("decimal", { precision: 12, scale: 2, default: 0 })
7093
7665
  ], OrderItem.prototype, "tax", 2);
7094
7666
  __decorateClass([
7095
- Column32("decimal", { precision: 12, scale: 2 })
7667
+ Column33("decimal", { precision: 12, scale: 2 })
7096
7668
  ], OrderItem.prototype, "total", 2);
7097
7669
  __decorateClass([
7098
- Column32("varchar", { nullable: true })
7670
+ Column33("varchar", { nullable: true })
7099
7671
  ], OrderItem.prototype, "hsn", 2);
7100
7672
  __decorateClass([
7101
- Column32("varchar", { nullable: true })
7673
+ Column33("varchar", { nullable: true })
7102
7674
  ], OrderItem.prototype, "uom", 2);
7103
7675
  __decorateClass([
7104
- Column32("varchar", { nullable: true })
7676
+ Column33("varchar", { nullable: true })
7105
7677
  ], OrderItem.prototype, "productType", 2);
7106
7678
  __decorateClass([
7107
- Column32("decimal", { precision: 5, scale: 2, nullable: true })
7679
+ Column33("decimal", { precision: 5, scale: 2, nullable: true })
7108
7680
  ], OrderItem.prototype, "taxRate", 2);
7109
7681
  __decorateClass([
7110
- Column32("varchar", { nullable: true })
7682
+ Column33("varchar", { nullable: true })
7111
7683
  ], OrderItem.prototype, "taxCode", 2);
7112
7684
  __decorateClass([
7113
- Column32("jsonb", { nullable: true })
7685
+ Column33("jsonb", { nullable: true })
7114
7686
  ], OrderItem.prototype, "metadata", 2);
7115
7687
  __decorateClass([
7116
- Column32({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7688
+ Column33({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7117
7689
  ], OrderItem.prototype, "createdAt", 2);
7118
7690
  __decorateClass([
7119
- Column32({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7691
+ Column33({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7120
7692
  ], OrderItem.prototype, "updatedAt", 2);
7121
7693
  __decorateClass([
7122
7694
  ManyToOne21(() => Order, (o) => o.items, { onDelete: "CASCADE" }),
@@ -7127,14 +7699,14 @@ __decorateClass([
7127
7699
  JoinColumn21({ name: "productId" })
7128
7700
  ], OrderItem.prototype, "product", 2);
7129
7701
  OrderItem = __decorateClass([
7130
- Entity32("order_items")
7702
+ Entity33("order_items")
7131
7703
  ], OrderItem);
7132
7704
 
7133
7705
  // src/entities/knowledge-base-document.entity.ts
7134
- import { Entity as Entity34, PrimaryGeneratedColumn as PrimaryGeneratedColumn34, Column as Column34, OneToMany as OneToMany14 } from "typeorm";
7706
+ import { Entity as Entity35, PrimaryGeneratedColumn as PrimaryGeneratedColumn35, Column as Column35, OneToMany as OneToMany14 } from "typeorm";
7135
7707
 
7136
7708
  // src/entities/knowledge-base-chunk.entity.ts
7137
- import { Entity as Entity33, PrimaryGeneratedColumn as PrimaryGeneratedColumn33, Column as Column33, ManyToOne as ManyToOne22, JoinColumn as JoinColumn22 } from "typeorm";
7709
+ import { Entity as Entity34, PrimaryGeneratedColumn as PrimaryGeneratedColumn34, Column as Column34, ManyToOne as ManyToOne22, JoinColumn as JoinColumn22 } from "typeorm";
7138
7710
  var KnowledgeBaseChunk = class {
7139
7711
  id;
7140
7712
  documentId;
@@ -7144,26 +7716,26 @@ var KnowledgeBaseChunk = class {
7144
7716
  document;
7145
7717
  };
7146
7718
  __decorateClass([
7147
- PrimaryGeneratedColumn33()
7719
+ PrimaryGeneratedColumn34()
7148
7720
  ], KnowledgeBaseChunk.prototype, "id", 2);
7149
7721
  __decorateClass([
7150
- Column33("int")
7722
+ Column34("int")
7151
7723
  ], KnowledgeBaseChunk.prototype, "documentId", 2);
7152
7724
  __decorateClass([
7153
- Column33("text")
7725
+ Column34("text")
7154
7726
  ], KnowledgeBaseChunk.prototype, "content", 2);
7155
7727
  __decorateClass([
7156
- Column33("int", { default: 0 })
7728
+ Column34("int", { default: 0 })
7157
7729
  ], KnowledgeBaseChunk.prototype, "chunkIndex", 2);
7158
7730
  __decorateClass([
7159
- Column33({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7731
+ Column34({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7160
7732
  ], KnowledgeBaseChunk.prototype, "createdAt", 2);
7161
7733
  __decorateClass([
7162
7734
  ManyToOne22(() => KnowledgeBaseDocument, (d) => d.chunks, { onDelete: "CASCADE" }),
7163
7735
  JoinColumn22({ name: "documentId" })
7164
7736
  ], KnowledgeBaseChunk.prototype, "document", 2);
7165
7737
  KnowledgeBaseChunk = __decorateClass([
7166
- Entity33("knowledge_base_chunks")
7738
+ Entity34("knowledge_base_chunks")
7167
7739
  ], KnowledgeBaseChunk);
7168
7740
 
7169
7741
  // src/entities/knowledge-base-document.entity.ts
@@ -7177,32 +7749,32 @@ var KnowledgeBaseDocument = class {
7177
7749
  chunks;
7178
7750
  };
7179
7751
  __decorateClass([
7180
- PrimaryGeneratedColumn34()
7752
+ PrimaryGeneratedColumn35()
7181
7753
  ], KnowledgeBaseDocument.prototype, "id", 2);
7182
7754
  __decorateClass([
7183
- Column34("varchar")
7755
+ Column35("varchar")
7184
7756
  ], KnowledgeBaseDocument.prototype, "name", 2);
7185
7757
  __decorateClass([
7186
- Column34("varchar", { nullable: true })
7758
+ Column35("varchar", { nullable: true })
7187
7759
  ], KnowledgeBaseDocument.prototype, "sourceUrl", 2);
7188
7760
  __decorateClass([
7189
- Column34("text")
7761
+ Column35("text")
7190
7762
  ], KnowledgeBaseDocument.prototype, "content", 2);
7191
7763
  __decorateClass([
7192
- Column34({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7764
+ Column35({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7193
7765
  ], KnowledgeBaseDocument.prototype, "createdAt", 2);
7194
7766
  __decorateClass([
7195
- Column34({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7767
+ Column35({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7196
7768
  ], KnowledgeBaseDocument.prototype, "updatedAt", 2);
7197
7769
  __decorateClass([
7198
7770
  OneToMany14(() => KnowledgeBaseChunk, (c) => c.document)
7199
7771
  ], KnowledgeBaseDocument.prototype, "chunks", 2);
7200
7772
  KnowledgeBaseDocument = __decorateClass([
7201
- Entity34("knowledge_base_documents")
7773
+ Entity35("knowledge_base_documents")
7202
7774
  ], KnowledgeBaseDocument);
7203
7775
 
7204
7776
  // src/entities/cart.entity.ts
7205
- import { Entity as Entity35, PrimaryGeneratedColumn as PrimaryGeneratedColumn35, Column as Column35, ManyToOne as ManyToOne23, OneToMany as OneToMany15, JoinColumn as JoinColumn23 } from "typeorm";
7777
+ import { Entity as Entity36, PrimaryGeneratedColumn as PrimaryGeneratedColumn36, Column as Column36, ManyToOne as ManyToOne23, OneToMany as OneToMany15, JoinColumn as JoinColumn23 } from "typeorm";
7206
7778
  var Cart = class {
7207
7779
  id;
7208
7780
  guestToken;
@@ -7215,25 +7787,25 @@ var Cart = class {
7215
7787
  items;
7216
7788
  };
7217
7789
  __decorateClass([
7218
- PrimaryGeneratedColumn35()
7790
+ PrimaryGeneratedColumn36()
7219
7791
  ], Cart.prototype, "id", 2);
7220
7792
  __decorateClass([
7221
- Column35("varchar", { nullable: true })
7793
+ Column36("varchar", { nullable: true })
7222
7794
  ], Cart.prototype, "guestToken", 2);
7223
7795
  __decorateClass([
7224
- Column35("int", { nullable: true })
7796
+ Column36("int", { nullable: true })
7225
7797
  ], Cart.prototype, "contactId", 2);
7226
7798
  __decorateClass([
7227
- Column35("varchar", { default: "INR" })
7799
+ Column36("varchar", { default: "INR" })
7228
7800
  ], Cart.prototype, "currency", 2);
7229
7801
  __decorateClass([
7230
- Column35({ type: "timestamp", nullable: true })
7802
+ Column36({ type: "timestamp", nullable: true })
7231
7803
  ], Cart.prototype, "expiresAt", 2);
7232
7804
  __decorateClass([
7233
- Column35({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7805
+ Column36({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7234
7806
  ], Cart.prototype, "createdAt", 2);
7235
7807
  __decorateClass([
7236
- Column35({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7808
+ Column36({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7237
7809
  ], Cart.prototype, "updatedAt", 2);
7238
7810
  __decorateClass([
7239
7811
  ManyToOne23(() => Contact, { onDelete: "CASCADE" }),
@@ -7243,11 +7815,11 @@ __decorateClass([
7243
7815
  OneToMany15("CartItem", "cart")
7244
7816
  ], Cart.prototype, "items", 2);
7245
7817
  Cart = __decorateClass([
7246
- Entity35("carts")
7818
+ Entity36("carts")
7247
7819
  ], Cart);
7248
7820
 
7249
7821
  // src/entities/cart-item.entity.ts
7250
- import { Entity as Entity36, PrimaryGeneratedColumn as PrimaryGeneratedColumn36, Column as Column36, ManyToOne as ManyToOne24, JoinColumn as JoinColumn24 } from "typeorm";
7822
+ import { Entity as Entity37, PrimaryGeneratedColumn as PrimaryGeneratedColumn37, Column as Column37, ManyToOne as ManyToOne24, JoinColumn as JoinColumn24 } from "typeorm";
7251
7823
  var CartItem = class {
7252
7824
  id;
7253
7825
  cartId;
@@ -7260,25 +7832,25 @@ var CartItem = class {
7260
7832
  product;
7261
7833
  };
7262
7834
  __decorateClass([
7263
- PrimaryGeneratedColumn36()
7835
+ PrimaryGeneratedColumn37()
7264
7836
  ], CartItem.prototype, "id", 2);
7265
7837
  __decorateClass([
7266
- Column36("int")
7838
+ Column37("int")
7267
7839
  ], CartItem.prototype, "cartId", 2);
7268
7840
  __decorateClass([
7269
- Column36("int")
7841
+ Column37("int")
7270
7842
  ], CartItem.prototype, "productId", 2);
7271
7843
  __decorateClass([
7272
- Column36("int", { default: 1 })
7844
+ Column37("int", { default: 1 })
7273
7845
  ], CartItem.prototype, "quantity", 2);
7274
7846
  __decorateClass([
7275
- Column36("jsonb", { nullable: true })
7847
+ Column37("jsonb", { nullable: true })
7276
7848
  ], CartItem.prototype, "metadata", 2);
7277
7849
  __decorateClass([
7278
- Column36({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7850
+ Column37({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7279
7851
  ], CartItem.prototype, "createdAt", 2);
7280
7852
  __decorateClass([
7281
- Column36({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7853
+ Column37({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7282
7854
  ], CartItem.prototype, "updatedAt", 2);
7283
7855
  __decorateClass([
7284
7856
  ManyToOne24(() => Cart, (c) => c.items, { onDelete: "CASCADE" }),
@@ -7289,11 +7861,11 @@ __decorateClass([
7289
7861
  JoinColumn24({ name: "productId" })
7290
7862
  ], CartItem.prototype, "product", 2);
7291
7863
  CartItem = __decorateClass([
7292
- Entity36("cart_items")
7864
+ Entity37("cart_items")
7293
7865
  ], CartItem);
7294
7866
 
7295
7867
  // src/entities/wishlist.entity.ts
7296
- import { Entity as Entity37, PrimaryGeneratedColumn as PrimaryGeneratedColumn37, Column as Column37, ManyToOne as ManyToOne25, OneToMany as OneToMany16, JoinColumn as JoinColumn25 } from "typeorm";
7868
+ import { Entity as Entity38, PrimaryGeneratedColumn as PrimaryGeneratedColumn38, Column as Column38, ManyToOne as ManyToOne25, OneToMany as OneToMany16, JoinColumn as JoinColumn25 } from "typeorm";
7297
7869
  var Wishlist = class {
7298
7870
  id;
7299
7871
  guestId;
@@ -7305,22 +7877,22 @@ var Wishlist = class {
7305
7877
  items;
7306
7878
  };
7307
7879
  __decorateClass([
7308
- PrimaryGeneratedColumn37()
7880
+ PrimaryGeneratedColumn38()
7309
7881
  ], Wishlist.prototype, "id", 2);
7310
7882
  __decorateClass([
7311
- Column37("varchar", { nullable: true })
7883
+ Column38("varchar", { nullable: true })
7312
7884
  ], Wishlist.prototype, "guestId", 2);
7313
7885
  __decorateClass([
7314
- Column37("int", { nullable: true })
7886
+ Column38("int", { nullable: true })
7315
7887
  ], Wishlist.prototype, "contactId", 2);
7316
7888
  __decorateClass([
7317
- Column37("varchar", { default: "default" })
7889
+ Column38("varchar", { default: "default" })
7318
7890
  ], Wishlist.prototype, "name", 2);
7319
7891
  __decorateClass([
7320
- Column37({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7892
+ Column38({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7321
7893
  ], Wishlist.prototype, "createdAt", 2);
7322
7894
  __decorateClass([
7323
- Column37({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7895
+ Column38({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7324
7896
  ], Wishlist.prototype, "updatedAt", 2);
7325
7897
  __decorateClass([
7326
7898
  ManyToOne25(() => Contact, { onDelete: "CASCADE" }),
@@ -7330,11 +7902,11 @@ __decorateClass([
7330
7902
  OneToMany16("WishlistItem", "wishlist")
7331
7903
  ], Wishlist.prototype, "items", 2);
7332
7904
  Wishlist = __decorateClass([
7333
- Entity37("wishlists")
7905
+ Entity38("wishlists")
7334
7906
  ], Wishlist);
7335
7907
 
7336
7908
  // src/entities/wishlist-item.entity.ts
7337
- import { Entity as Entity38, PrimaryGeneratedColumn as PrimaryGeneratedColumn38, Column as Column38, ManyToOne as ManyToOne26, JoinColumn as JoinColumn26 } from "typeorm";
7909
+ import { Entity as Entity39, PrimaryGeneratedColumn as PrimaryGeneratedColumn39, Column as Column39, ManyToOne as ManyToOne26, JoinColumn as JoinColumn26 } from "typeorm";
7338
7910
  var WishlistItem = class {
7339
7911
  id;
7340
7912
  wishlistId;
@@ -7346,22 +7918,22 @@ var WishlistItem = class {
7346
7918
  product;
7347
7919
  };
7348
7920
  __decorateClass([
7349
- PrimaryGeneratedColumn38()
7921
+ PrimaryGeneratedColumn39()
7350
7922
  ], WishlistItem.prototype, "id", 2);
7351
7923
  __decorateClass([
7352
- Column38("int")
7924
+ Column39("int")
7353
7925
  ], WishlistItem.prototype, "wishlistId", 2);
7354
7926
  __decorateClass([
7355
- Column38("int")
7927
+ Column39("int")
7356
7928
  ], WishlistItem.prototype, "productId", 2);
7357
7929
  __decorateClass([
7358
- Column38("jsonb", { nullable: true })
7930
+ Column39("jsonb", { nullable: true })
7359
7931
  ], WishlistItem.prototype, "metadata", 2);
7360
7932
  __decorateClass([
7361
- Column38({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7933
+ Column39({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7362
7934
  ], WishlistItem.prototype, "createdAt", 2);
7363
7935
  __decorateClass([
7364
- Column38({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7936
+ Column39({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7365
7937
  ], WishlistItem.prototype, "updatedAt", 2);
7366
7938
  __decorateClass([
7367
7939
  ManyToOne26(() => Wishlist, (w) => w.items, { onDelete: "CASCADE" }),
@@ -7372,9 +7944,45 @@ __decorateClass([
7372
7944
  JoinColumn26({ name: "productId" })
7373
7945
  ], WishlistItem.prototype, "product", 2);
7374
7946
  WishlistItem = __decorateClass([
7375
- Entity38("wishlist_items")
7947
+ Entity39("wishlist_items")
7376
7948
  ], WishlistItem);
7377
7949
 
7950
+ // src/entities/llm-agent-knowledge-document.entity.ts
7951
+ import { Entity as Entity40, PrimaryGeneratedColumn as PrimaryGeneratedColumn40, Column as Column40, ManyToOne as ManyToOne27, JoinColumn as JoinColumn27, Index as Index2, Unique as Unique2 } from "typeorm";
7952
+ var LlmAgentKnowledgeDocument = class {
7953
+ id;
7954
+ agentId;
7955
+ documentId;
7956
+ createdAt;
7957
+ agent;
7958
+ document;
7959
+ };
7960
+ __decorateClass([
7961
+ PrimaryGeneratedColumn40()
7962
+ ], LlmAgentKnowledgeDocument.prototype, "id", 2);
7963
+ __decorateClass([
7964
+ Column40("int")
7965
+ ], LlmAgentKnowledgeDocument.prototype, "agentId", 2);
7966
+ __decorateClass([
7967
+ Column40("int")
7968
+ ], LlmAgentKnowledgeDocument.prototype, "documentId", 2);
7969
+ __decorateClass([
7970
+ Column40({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7971
+ ], LlmAgentKnowledgeDocument.prototype, "createdAt", 2);
7972
+ __decorateClass([
7973
+ ManyToOne27(() => LlmAgent, { onDelete: "CASCADE" }),
7974
+ JoinColumn27({ name: "agentId" })
7975
+ ], LlmAgentKnowledgeDocument.prototype, "agent", 2);
7976
+ __decorateClass([
7977
+ ManyToOne27(() => KnowledgeBaseDocument, { onDelete: "CASCADE" }),
7978
+ JoinColumn27({ name: "documentId" })
7979
+ ], LlmAgentKnowledgeDocument.prototype, "document", 2);
7980
+ LlmAgentKnowledgeDocument = __decorateClass([
7981
+ Entity40("llm_agent_knowledge_documents"),
7982
+ Unique2("UQ_llm_agent_knowledge_agent_document", ["agentId", "documentId"]),
7983
+ Index2("IDX_llm_agent_knowledge_agent", ["agentId"])
7984
+ ], LlmAgentKnowledgeDocument);
7985
+
7378
7986
  // src/entities/index.ts
7379
7987
  var CMS_ENTITY_MAP = {
7380
7988
  users: User,
@@ -7414,7 +8022,9 @@ var CMS_ENTITY_MAP = {
7414
8022
  carts: Cart,
7415
8023
  cart_items: CartItem,
7416
8024
  wishlists: Wishlist,
7417
- wishlist_items: WishlistItem
8025
+ wishlist_items: WishlistItem,
8026
+ llm_agents: LlmAgent,
8027
+ llm_agent_knowledge_documents: LlmAgentKnowledgeDocument
7418
8028
  };
7419
8029
 
7420
8030
  // src/auth/permission-entities.ts
@@ -8589,6 +9199,314 @@ function createUserAuthApiRouter(config) {
8589
9199
  };
8590
9200
  }
8591
9201
 
9202
+ // src/api/llm-agent-knowledge-handlers.ts
9203
+ import { In as In2 } from "typeorm";
9204
+ var INGEST_CHUNK_CHARS = 900;
9205
+ var MAX_CHUNKS_PER_UPLOAD = 400;
9206
+ var EMBED_CONCURRENCY = 5;
9207
+ var MAX_PDF_BYTES = 25 * 1024 * 1024;
9208
+ var TEXT_FILE_TYPES = /* @__PURE__ */ new Set(["text/plain", "text/markdown", "application/json"]);
9209
+ var KB_LOG = "[llm-agent-knowledge]";
9210
+ function llmEmbedDebug() {
9211
+ const v = process.env.LLM_EMBED_DEBUG?.toLowerCase();
9212
+ return v === "1" || v === "true" || v === "yes";
9213
+ }
9214
+ function isPdfUpload(mime, fileName) {
9215
+ if (mime === "application/pdf") return true;
9216
+ const n = fileName.toLowerCase();
9217
+ return n.endsWith(".pdf");
9218
+ }
9219
+ async function extractTextFromPdf(buffer) {
9220
+ const pdfParse = await import("pdf-parse");
9221
+ const data = await pdfParse(buffer);
9222
+ return (data?.text ?? "").trim();
9223
+ }
9224
+ async function writeEmbeddingsConcurrent(dataSource, embed, chunks, concurrency) {
9225
+ let next = 0;
9226
+ let written = 0;
9227
+ let failed = 0;
9228
+ let skippedEmpty = 0;
9229
+ async function worker() {
9230
+ for (; ; ) {
9231
+ const i = next++;
9232
+ if (i >= chunks.length) return;
9233
+ const c = chunks[i];
9234
+ try {
9235
+ const emb = await embed(c.content);
9236
+ if (emb?.length) {
9237
+ const vectorStr = "[" + emb.join(",") + "]";
9238
+ await dataSource.query(
9239
+ `UPDATE knowledge_base_chunks SET embedding = $1::vector WHERE id = $2`,
9240
+ [vectorStr, c.id]
9241
+ );
9242
+ written++;
9243
+ } else {
9244
+ skippedEmpty++;
9245
+ if (llmEmbedDebug()) {
9246
+ console.warn(`${KB_LOG} embed() returned empty vector`, { chunkId: c.id });
9247
+ }
9248
+ }
9249
+ } catch (err) {
9250
+ failed++;
9251
+ console.error(`${KB_LOG} embedding DB update failed`, {
9252
+ chunkId: c.id,
9253
+ err: err instanceof Error ? err.message : String(err)
9254
+ });
9255
+ }
9256
+ }
9257
+ }
9258
+ const n = Math.max(1, Math.min(concurrency, chunks.length));
9259
+ await Promise.all(Array.from({ length: n }, () => worker()));
9260
+ const summary = {
9261
+ chunkCount: chunks.length,
9262
+ written,
9263
+ failed,
9264
+ skippedEmpty
9265
+ };
9266
+ if (skippedEmpty > 0 && written === 0) {
9267
+ summary.hint = "embed() returned empty vectors \u2014 see [LLM embed] logs (often HTTP 404 on /v1/embeddings, or wrong response shape).";
9268
+ }
9269
+ console.error(`${KB_LOG} embedding pass finished`, summary);
9270
+ return { written, failed };
9271
+ }
9272
+ function splitIntoChunks(text, maxLen) {
9273
+ const t = text.trim();
9274
+ if (!t) return [];
9275
+ const chunks = [];
9276
+ for (let i = 0; i < t.length; i += maxLen) {
9277
+ chunks.push(t.slice(i, i + maxLen));
9278
+ }
9279
+ return chunks;
9280
+ }
9281
+ async function findAgentBySlug(dataSource, llmAgents, slug) {
9282
+ const repo = dataSource.getRepository(llmAgents);
9283
+ return repo.findOne({
9284
+ where: { slug, deleted: false }
9285
+ });
9286
+ }
9287
+ function createLlmAgentKnowledgeHandlers(config) {
9288
+ const { dataSource, entityMap, getCms, json, requireAuth, requireEntityPermission } = config;
9289
+ const kbDoc = entityMap.knowledge_base_documents;
9290
+ const kbChunk = entityMap.knowledge_base_chunks;
9291
+ const llmAgents = entityMap.llm_agents;
9292
+ const junction = entityMap.llm_agent_knowledge_documents;
9293
+ if (!kbDoc || !kbChunk || !llmAgents || !junction) {
9294
+ return null;
9295
+ }
9296
+ async function gate(req, action) {
9297
+ const a = await requireAuth(req);
9298
+ if (a) return a;
9299
+ if (requireEntityPermission) {
9300
+ const pe = await requireEntityPermission(req, "llm_agents", action);
9301
+ if (pe) return pe;
9302
+ }
9303
+ return null;
9304
+ }
9305
+ return {
9306
+ async list(req, slug) {
9307
+ const denied = await gate(req, "read");
9308
+ if (denied) return denied;
9309
+ try {
9310
+ const agent = await findAgentBySlug(dataSource, llmAgents, slug);
9311
+ if (!agent) return json({ error: "Agent not found" }, { status: 404 });
9312
+ const linkRepo = dataSource.getRepository(junction);
9313
+ const links = await linkRepo.find({ where: { agentId: agent.id } });
9314
+ const docIds = [...new Set(links.map((l) => l.documentId))];
9315
+ if (docIds.length === 0) return json({ documents: [] });
9316
+ const docRepo = dataSource.getRepository(kbDoc);
9317
+ const docs = await docRepo.find({ where: { id: In2(docIds) } });
9318
+ const byId = new Map(docs.map((d) => [d.id, d]));
9319
+ const documents = docIds.map((id) => {
9320
+ const d = byId.get(id);
9321
+ return d ? { id: d.id, name: d.name } : null;
9322
+ }).filter(Boolean);
9323
+ return json({ documents });
9324
+ } catch (err) {
9325
+ const msg = err instanceof Error ? err.message : "Failed to list knowledge";
9326
+ return json({ error: msg }, { status: 500 });
9327
+ }
9328
+ },
9329
+ async post(req, slug) {
9330
+ const denied = await gate(req, "update");
9331
+ if (denied) return denied;
9332
+ try {
9333
+ const agent = await findAgentBySlug(dataSource, llmAgents, slug);
9334
+ if (!agent) return json({ error: "Agent not found" }, { status: 404 });
9335
+ let name = "";
9336
+ let text = "";
9337
+ let sourceUrl = null;
9338
+ let existingDocumentId = null;
9339
+ const ct = req.headers.get("content-type") || "";
9340
+ if (ct.includes("application/json")) {
9341
+ const body = await req.json();
9342
+ existingDocumentId = typeof body?.documentId === "number" && Number.isFinite(body.documentId) ? body.documentId : null;
9343
+ name = (body?.name ?? "").trim();
9344
+ text = (body?.text ?? "").trim();
9345
+ sourceUrl = typeof body?.sourceUrl === "string" && body.sourceUrl.trim() ? body.sourceUrl.trim() : null;
9346
+ } else if (ct.includes("multipart/form-data")) {
9347
+ const form = await req.formData();
9348
+ name = form.get("name")?.trim() ?? "";
9349
+ text = form.get("text")?.trim() ?? "";
9350
+ const file = form.get("file");
9351
+ if (file && typeof file !== "string" && "arrayBuffer" in file) {
9352
+ const f = file;
9353
+ const mime = (f.type || "").split(";")[0].trim().toLowerCase();
9354
+ const buf = Buffer.from(await f.arrayBuffer());
9355
+ if (TEXT_FILE_TYPES.has(mime)) {
9356
+ const decoded = buf.toString("utf8");
9357
+ if (!text) text = decoded;
9358
+ } else if (isPdfUpload(mime, f.name || "")) {
9359
+ if (buf.length > MAX_PDF_BYTES) {
9360
+ return json(
9361
+ { error: `PDF too large (max ${Math.floor(MAX_PDF_BYTES / (1024 * 1024))}MB)` },
9362
+ { status: 413 }
9363
+ );
9364
+ }
9365
+ try {
9366
+ const extracted = await extractTextFromPdf(buf);
9367
+ if (!text) text = extracted;
9368
+ } catch {
9369
+ return json(
9370
+ { error: "Could not read PDF text (file may be encrypted, corrupt, or image-only)" },
9371
+ { status: 422 }
9372
+ );
9373
+ }
9374
+ } else {
9375
+ return json(
9376
+ {
9377
+ error: "Unsupported file type; use text/plain, text/markdown, application/json, or application/pdf"
9378
+ },
9379
+ { status: 415 }
9380
+ );
9381
+ }
9382
+ if (!name && f.name) name = f.name.replace(/\.[^/.]+$/, "") || f.name;
9383
+ }
9384
+ } else {
9385
+ return json({ error: "Use application/json or multipart/form-data" }, { status: 400 });
9386
+ }
9387
+ const linkRepo = dataSource.getRepository(junction);
9388
+ if (existingDocumentId != null) {
9389
+ const docRepo2 = dataSource.getRepository(kbDoc);
9390
+ const existing = await docRepo2.findOne({ where: { id: existingDocumentId } });
9391
+ if (!existing) return json({ error: "documentId not found" }, { status: 404 });
9392
+ const dup2 = await linkRepo.findOne({
9393
+ where: { agentId: agent.id, documentId: existingDocumentId }
9394
+ });
9395
+ if (!dup2) {
9396
+ await linkRepo.save(linkRepo.create({ agentId: agent.id, documentId: existingDocumentId }));
9397
+ }
9398
+ return json({ documentId: existingDocumentId, linked: true, created: false });
9399
+ }
9400
+ if (!text) return json({ error: "text or file with text content is required" }, { status: 400 });
9401
+ if (!name) name = "Untitled";
9402
+ const parts = splitIntoChunks(text, INGEST_CHUNK_CHARS);
9403
+ if (parts.length === 0) {
9404
+ return json({ error: "text or file with text content is required" }, { status: 400 });
9405
+ }
9406
+ if (parts.length > MAX_CHUNKS_PER_UPLOAD) {
9407
+ return json(
9408
+ {
9409
+ error: `Document is too large for one upload (${parts.length} chunks; max ${MAX_CHUNKS_PER_UPLOAD}). Split into smaller files.`
9410
+ },
9411
+ { status: 413 }
9412
+ );
9413
+ }
9414
+ const docRepo = dataSource.getRepository(kbDoc);
9415
+ const chunkRepo = dataSource.getRepository(kbChunk);
9416
+ const now = /* @__PURE__ */ new Date();
9417
+ const doc = await docRepo.save(
9418
+ docRepo.create({ name, content: text, sourceUrl, createdAt: now, updatedAt: now })
9419
+ );
9420
+ const docId = doc.id;
9421
+ const chunkRows = parts.map(
9422
+ (content, i) => chunkRepo.create({ documentId: docId, content, chunkIndex: i, createdAt: now })
9423
+ );
9424
+ const savedList = await chunkRepo.save(chunkRows);
9425
+ const savedChunks = savedList.map(
9426
+ (row, i) => ({
9427
+ id: row.id,
9428
+ content: parts[i]
9429
+ })
9430
+ );
9431
+ const dup = await linkRepo.findOne({ where: { agentId: agent.id, documentId: docId } });
9432
+ if (!dup) {
9433
+ await linkRepo.save(linkRepo.create({ agentId: agent.id, documentId: docId }));
9434
+ }
9435
+ let embeddingsWritten = 0;
9436
+ let embeddingsFailed = 0;
9437
+ try {
9438
+ const cms = await getCms();
9439
+ const llm = cms.getPlugin("llm");
9440
+ if (llm?.embed && savedChunks.length > 0) {
9441
+ console.info(`${KB_LOG} starting embedding pass`, { slug, chunkCount: savedChunks.length });
9442
+ const embedBound = (text2) => llm.embed(text2);
9443
+ const { written, failed } = await writeEmbeddingsConcurrent(
9444
+ dataSource,
9445
+ embedBound,
9446
+ savedChunks,
9447
+ EMBED_CONCURRENCY
9448
+ );
9449
+ embeddingsWritten = written;
9450
+ embeddingsFailed = failed;
9451
+ } else {
9452
+ console.error(`${KB_LOG} embeddings skipped`, {
9453
+ slug,
9454
+ hasLlmPlugin: !!llm,
9455
+ hasEmbed: typeof llm?.embed === "function",
9456
+ chunkCount: savedChunks.length,
9457
+ hint: !llm || typeof llm.embed !== "function" ? "LLM plugin missing or no embed(); check LLM_GATEWAY_URL + LLM_API_KEY so llm plugin initializes." : void 0
9458
+ });
9459
+ }
9460
+ } catch (embErr) {
9461
+ const detail = embErr instanceof Error ? embErr.message : String(embErr);
9462
+ console.error(`${KB_LOG} embedding step threw before/during batch`, { slug, detail, embErr });
9463
+ return json(
9464
+ {
9465
+ documentId: docId,
9466
+ chunkCount: savedChunks.length,
9467
+ created: true,
9468
+ linked: true,
9469
+ embeddingsWritten: 0,
9470
+ embeddingsFailed: savedChunks.length,
9471
+ warning: "Document saved and linked; embedding step failed.",
9472
+ detail
9473
+ },
9474
+ { status: 201 }
9475
+ );
9476
+ }
9477
+ return json({
9478
+ documentId: docId,
9479
+ chunkCount: savedChunks.length,
9480
+ created: true,
9481
+ linked: true,
9482
+ embeddingsWritten,
9483
+ embeddingsFailed
9484
+ });
9485
+ } catch (err) {
9486
+ const msg = err instanceof Error ? err.message : "Failed to ingest knowledge";
9487
+ const name = err instanceof Error ? err.name : "";
9488
+ return json({ error: msg, errorName: name || void 0 }, { status: 500 });
9489
+ }
9490
+ },
9491
+ async unlink(req, slug, documentIdStr) {
9492
+ const denied = await gate(req, "update");
9493
+ if (denied) return denied;
9494
+ const documentId = parseInt(documentIdStr, 10);
9495
+ if (!Number.isFinite(documentId)) return json({ error: "Invalid document id" }, { status: 400 });
9496
+ try {
9497
+ const agent = await findAgentBySlug(dataSource, llmAgents, slug);
9498
+ if (!agent) return json({ error: "Agent not found" }, { status: 404 });
9499
+ const linkRepo = dataSource.getRepository(junction);
9500
+ await linkRepo.delete({ agentId: agent.id, documentId });
9501
+ return json({ ok: true });
9502
+ } catch (err) {
9503
+ const msg = err instanceof Error ? err.message : "Failed to unlink";
9504
+ return json({ error: msg }, { status: 500 });
9505
+ }
9506
+ }
9507
+ };
9508
+ }
9509
+
8592
9510
  // src/api/message-template-admin-handlers.ts
8593
9511
  init_sms_defaults();
8594
9512
  function createSmsMessageTemplateHandlers(config) {
@@ -8838,6 +9756,26 @@ function createAdminRolesHandlers(config) {
8838
9756
  }
8839
9757
 
8840
9758
  // src/api/cms-api-handler.ts
9759
+ var KNOWLEDGE_SUFFIX = "knowledge";
9760
+ function matchLlmAgentKnowledgeRoute(path) {
9761
+ const p = path[0] === "api" ? path.slice(1) : path;
9762
+ if (p[0] !== "llm_agents" || p.length < 2) return null;
9763
+ const seg1 = p[1];
9764
+ if (!seg1) return null;
9765
+ if (p[2] === KNOWLEDGE_SUFFIX) {
9766
+ return {
9767
+ slug: seg1,
9768
+ documentId: p.length >= 4 ? p[3] : void 0
9769
+ };
9770
+ }
9771
+ if (seg1.endsWith(KNOWLEDGE_SUFFIX) && seg1.length > KNOWLEDGE_SUFFIX.length) {
9772
+ const slug = seg1.slice(0, -KNOWLEDGE_SUFFIX.length);
9773
+ if (!slug) return null;
9774
+ if (p.length === 2) return { slug, documentId: void 0 };
9775
+ if (p.length === 3) return { slug, documentId: p[2] };
9776
+ }
9777
+ return null;
9778
+ }
8841
9779
  var DEFAULT_EXCLUDE = /* @__PURE__ */ new Set([
8842
9780
  "users",
8843
9781
  "password_reset_tokens",
@@ -8850,7 +9788,8 @@ var DEFAULT_EXCLUDE = /* @__PURE__ */ new Set([
8850
9788
  "cart_items",
8851
9789
  "wishlists",
8852
9790
  "wishlist_items",
8853
- "message_templates"
9791
+ "message_templates",
9792
+ "llm_agent_knowledge_documents"
8854
9793
  ]);
8855
9794
  function createCmsApiHandler(config) {
8856
9795
  const {
@@ -8874,6 +9813,7 @@ function createCmsApiHandler(config) {
8874
9813
  userProfile,
8875
9814
  settings: settingsConfig,
8876
9815
  chat: chatConfig,
9816
+ llmAgentKnowledge: llmAgentKnowledgeConfig,
8877
9817
  requireEntityPermission: userRequireEntityPermission,
8878
9818
  getSessionUser
8879
9819
  } = config;
@@ -8981,6 +9921,17 @@ function createCmsApiHandler(config) {
8981
9921
  requireEntityPermission: requireEntityPermissionEffective
8982
9922
  });
8983
9923
  const chatHandlers = chatConfig ? createChatHandlers(chatConfig) : null;
9924
+ const llmAgentKnowledgeMerged = llmAgentKnowledgeConfig ?? (chatConfig ? {
9925
+ dataSource: chatConfig.dataSource,
9926
+ entityMap: chatConfig.entityMap,
9927
+ getCms: chatConfig.getCms,
9928
+ json: chatConfig.json,
9929
+ requireAuth: chatConfig.requireAuth
9930
+ } : void 0);
9931
+ const llmAgentKnowledgeHandlers = llmAgentKnowledgeMerged ? createLlmAgentKnowledgeHandlers({
9932
+ ...llmAgentKnowledgeMerged,
9933
+ requireEntityPermission: requireEntityPermissionEffective
9934
+ }) : null;
8984
9935
  function resolveResource(segment) {
8985
9936
  const model = pathToModel(segment);
8986
9937
  return crudResources.includes(model) ? model : segment;
@@ -9092,7 +10043,32 @@ function createCmsApiHandler(config) {
9092
10043
  if (method === "GET") return smsMessageTemplateHandlers.GET(req);
9093
10044
  if (method === "PUT") return smsMessageTemplateHandlers.PUT(req);
9094
10045
  }
10046
+ {
10047
+ const kbMatch = matchLlmAgentKnowledgeRoute(path);
10048
+ if (kbMatch) {
10049
+ if (!llmAgentKnowledgeHandlers) {
10050
+ return config.json(
10051
+ {
10052
+ error: "LLM agent knowledge is not available",
10053
+ hint: "With chat enabled, routes usually work automatically. Otherwise pass llmAgentKnowledge. If this persists, ensure entityMap includes knowledge_base_documents, knowledge_base_chunks, llm_agent_knowledge_documents, and run migrations."
10054
+ },
10055
+ { status: 503 }
10056
+ );
10057
+ }
10058
+ const { slug, documentId } = kbMatch;
10059
+ if (method === "DELETE" && documentId != null && documentId !== "") {
10060
+ return llmAgentKnowledgeHandlers.unlink(req, slug, documentId);
10061
+ }
10062
+ if (method === "GET" && (documentId == null || documentId === "")) {
10063
+ return llmAgentKnowledgeHandlers.list(req, slug);
10064
+ }
10065
+ if (method === "POST" && (documentId == null || documentId === "")) {
10066
+ return llmAgentKnowledgeHandlers.post(req, slug);
10067
+ }
10068
+ }
10069
+ }
9095
10070
  if (path[0] === "chat" && chatHandlers) {
10071
+ if (path.length === 2 && path[1] === "config" && method === "GET") return chatHandlers.publicConfig(req);
9096
10072
  if (path.length === 2 && path[1] === "identify" && method === "POST") return chatHandlers.identify(req);
9097
10073
  if (path.length === 4 && path[1] === "conversations" && path[3] === "messages" && method === "GET") return chatHandlers.getMessages(req, path[2]);
9098
10074
  if (path.length === 2 && path[1] === "messages" && method === "POST") return chatHandlers.postMessage(req);
@@ -9161,7 +10137,7 @@ function createCmsApiHandler(config) {
9161
10137
  }
9162
10138
 
9163
10139
  // src/api/storefront-handlers.ts
9164
- import { In as In2, IsNull as IsNull4 } from "typeorm";
10140
+ import { In as In3, IsNull as IsNull4 } from "typeorm";
9165
10141
 
9166
10142
  // src/lib/is-valid-signup-email.ts
9167
10143
  var MAX_EMAIL = 254;
@@ -10433,7 +11409,7 @@ function createStorefrontApiHandler(config) {
10433
11409
  const previewByOrder = {};
10434
11410
  if (orderIds.length) {
10435
11411
  const oItems = await orderItemRepo().find({
10436
- where: { orderId: In2(orderIds) },
11412
+ where: { orderId: In3(orderIds) },
10437
11413
  relations: ["product"],
10438
11414
  order: { id: "ASC" }
10439
11415
  });
@@ -10597,6 +11573,7 @@ export {
10597
11573
  FormSubmission,
10598
11574
  KnowledgeBaseChunk,
10599
11575
  KnowledgeBaseDocument,
11576
+ LlmAgent,
10600
11577
  LlmService,
10601
11578
  Media,
10602
11579
  MessageTemplate,
@@ -10646,6 +11623,7 @@ export {
10646
11623
  createForgotPasswordHandler,
10647
11624
  createFormBySlugHandler,
10648
11625
  createInviteAcceptHandler,
11626
+ createLlmAgentKnowledgeHandlers,
10649
11627
  createMediaZipExtractHandler,
10650
11628
  createOtpChallenge,
10651
11629
  createSetPasswordHandler,
@@ -10679,13 +11657,17 @@ export {
10679
11657
  isZipMedia,
10680
11658
  joinRecipientsForSend,
10681
11659
  linkUnclaimedContactToUser,
11660
+ llmAgentToChatAgentOptions,
10682
11661
  llmPlugin,
10683
11662
  loadPublicThemeSettings,
10684
11663
  localStoragePlugin,
10685
11664
  mergeEmailLayoutCompanyDetails,
11665
+ mergeGuardrailsIntoSystemPrompt,
10686
11666
  mergeSeoBySlug,
10687
11667
  normalizePhoneE164,
10688
11668
  parseEmailRecipientsFromConfig,
11669
+ parseHfInferenceEmbeddingBody,
11670
+ parseLlmAgentValidationRules,
10689
11671
  paymentPlugin,
10690
11672
  permissionRowsToRecord,
10691
11673
  queueEmail,
@@ -10717,6 +11699,8 @@ export {
10717
11699
  smsPlugin,
10718
11700
  truncateText,
10719
11701
  validateSlug,
11702
+ validateUserMessageAgainstAgentRules,
11703
+ validateUserMessageAgainstStructuredRules,
10720
11704
  verifyAndConsumeOtpChallenge,
10721
11705
  verifyOtpCodeHash
10722
11706
  };