@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.cjs CHANGED
@@ -653,6 +653,7 @@ __export(src_exports, {
653
653
  FormSubmission: () => FormSubmission,
654
654
  KnowledgeBaseChunk: () => KnowledgeBaseChunk,
655
655
  KnowledgeBaseDocument: () => KnowledgeBaseDocument,
656
+ LlmAgent: () => LlmAgent,
656
657
  LlmService: () => LlmService,
657
658
  Media: () => Media,
658
659
  MessageTemplate: () => MessageTemplate,
@@ -702,6 +703,7 @@ __export(src_exports, {
702
703
  createForgotPasswordHandler: () => createForgotPasswordHandler,
703
704
  createFormBySlugHandler: () => createFormBySlugHandler,
704
705
  createInviteAcceptHandler: () => createInviteAcceptHandler,
706
+ createLlmAgentKnowledgeHandlers: () => createLlmAgentKnowledgeHandlers,
705
707
  createMediaZipExtractHandler: () => createMediaZipExtractHandler,
706
708
  createOtpChallenge: () => createOtpChallenge,
707
709
  createSetPasswordHandler: () => createSetPasswordHandler,
@@ -735,13 +737,17 @@ __export(src_exports, {
735
737
  isZipMedia: () => isZipMedia,
736
738
  joinRecipientsForSend: () => joinRecipientsForSend,
737
739
  linkUnclaimedContactToUser: () => linkUnclaimedContactToUser,
740
+ llmAgentToChatAgentOptions: () => llmAgentToChatAgentOptions,
738
741
  llmPlugin: () => llmPlugin,
739
742
  loadPublicThemeSettings: () => loadPublicThemeSettings,
740
743
  localStoragePlugin: () => localStoragePlugin,
741
744
  mergeEmailLayoutCompanyDetails: () => mergeEmailLayoutCompanyDetails,
745
+ mergeGuardrailsIntoSystemPrompt: () => mergeGuardrailsIntoSystemPrompt,
742
746
  mergeSeoBySlug: () => mergeSeoBySlug,
743
747
  normalizePhoneE164: () => normalizePhoneE164,
744
748
  parseEmailRecipientsFromConfig: () => parseEmailRecipientsFromConfig,
749
+ parseHfInferenceEmbeddingBody: () => parseHfInferenceEmbeddingBody,
750
+ parseLlmAgentValidationRules: () => parseLlmAgentValidationRules,
745
751
  paymentPlugin: () => paymentPlugin,
746
752
  permissionRowsToRecord: () => permissionRowsToRecord,
747
753
  queueEmail: () => queueEmail,
@@ -773,6 +779,8 @@ __export(src_exports, {
773
779
  smsPlugin: () => smsPlugin,
774
780
  truncateText: () => truncateText,
775
781
  validateSlug: () => validateSlug,
782
+ validateUserMessageAgainstAgentRules: () => validateUserMessageAgainstAgentRules,
783
+ validateUserMessageAgainstStructuredRules: () => validateUserMessageAgainstStructuredRules,
776
784
  verifyAndConsumeOtpChallenge: () => verifyAndConsumeOtpChallenge,
777
785
  verifyOtpCodeHash: () => verifyOtpCodeHash
778
786
  });
@@ -2605,29 +2613,111 @@ function localStoragePlugin(config = {}) {
2605
2613
  }
2606
2614
 
2607
2615
  // src/plugins/llm/llm-service.ts
2616
+ function parseHfInferenceEmbeddingBody(data) {
2617
+ if (data === null || data === void 0) return null;
2618
+ if (Array.isArray(data)) {
2619
+ if (data.length === 0) return null;
2620
+ const first = data[0];
2621
+ if (typeof first === "number") return data;
2622
+ if (Array.isArray(first) && first.length > 0 && typeof first[0] === "number") {
2623
+ return first;
2624
+ }
2625
+ if (Array.isArray(first) && Array.isArray(first[0]) && typeof first[0][0] === "number") {
2626
+ return first[0];
2627
+ }
2628
+ return null;
2629
+ }
2630
+ if (typeof data === "object" && data !== null && !Array.isArray(data)) {
2631
+ const o = data;
2632
+ if (typeof o.error === "string") return null;
2633
+ if ("embeddings" in o) return parseHfInferenceEmbeddingBody(o.embeddings);
2634
+ }
2635
+ return null;
2636
+ }
2608
2637
  var LlmService = class _LlmService {
2609
- constructor(baseURL, apiKey, defaultEmbeddingModel) {
2610
- this.baseURL = baseURL;
2638
+ static embedHttpErrorLogged = false;
2639
+ static embedShapeErrorLogged = false;
2640
+ static embedSuccessLogged = false;
2641
+ static hfDimensionMismatchWarned = false;
2642
+ baseURL;
2643
+ apiKey;
2644
+ defaultEmbeddingModel;
2645
+ embeddingProvider;
2646
+ hfInferenceBaseURL;
2647
+ embeddingApiKey;
2648
+ constructor(baseURL, apiKey, defaultEmbeddingModel, embedOpts) {
2649
+ this.baseURL = baseURL.replace(/\/$/, "");
2611
2650
  this.apiKey = apiKey;
2612
2651
  this.defaultEmbeddingModel = defaultEmbeddingModel;
2652
+ const p = (embedOpts?.embeddingProvider ?? "openai").toLowerCase();
2653
+ this.embeddingProvider = p === "huggingface" ? "huggingface" : "openai";
2654
+ this.hfInferenceBaseURL = (embedOpts?.hfInferenceBaseUrl ?? "https://api-inference.huggingface.co").replace(
2655
+ /\/$/,
2656
+ ""
2657
+ );
2658
+ this.embeddingApiKey = (embedOpts?.embeddingApiKey ?? apiKey).trim();
2613
2659
  }
2614
- static embedWarned = false;
2615
2660
  get base() {
2616
2661
  return this.baseURL.replace(/\/$/, "");
2617
2662
  }
2618
2663
  get url() {
2619
2664
  return `${this.base}/v1/chat/completions`;
2620
2665
  }
2621
- /**
2622
- * OpenAI-compatible embeddings. Returns [] if endpoint not available or unexpected response.
2623
- * Server must implement: POST /v1/embeddings
2624
- * Body: { model: string, input: string }
2625
- * Response: { data: [ { embedding: number[] } ] } or { embedding: number[] }
2626
- */
2666
+ llmDebugEnabled() {
2667
+ const v = process.env.LLM_DEBUG?.toLowerCase();
2668
+ return v === "1" || v === "true" || v === "yes";
2669
+ }
2670
+ /** Per-request embedding logs (noisy with many chunks). Set `LLM_EMBED_DEBUG=1`. */
2671
+ embedDebugEnabled() {
2672
+ const v = process.env.LLM_EMBED_DEBUG?.toLowerCase();
2673
+ return v === "1" || v === "true" || v === "yes";
2674
+ }
2675
+ logAgentComposition(options) {
2676
+ if (!this.llmDebugEnabled()) return;
2677
+ const { systemPrompt, context, history = [], userPrompt, model, temperature, max_tokens } = options;
2678
+ console.log("\n[LLM chatAgent] composing request");
2679
+ if (systemPrompt?.trim()) {
2680
+ console.log("[System instruction]\n", systemPrompt.trim());
2681
+ }
2682
+ if (context?.trim()) {
2683
+ console.log("[Context \u2014 merged into system message by chatAgent]\n", context.trim());
2684
+ }
2685
+ if (history.length > 0) {
2686
+ console.log("[Conversation so far]");
2687
+ for (const m of history) {
2688
+ console.log(` ${m.role}: ${m.content}`);
2689
+ }
2690
+ }
2691
+ console.log("[Current user message]\n", userPrompt);
2692
+ if (model !== void 0 || temperature !== void 0 || max_tokens !== void 0) {
2693
+ console.log("[Agent options]", { model, temperature, max_tokens });
2694
+ }
2695
+ }
2696
+ logChatCompletionsRequest(kind, messages, options, stream) {
2697
+ if (!this.llmDebugEnabled()) return;
2698
+ const model = options.model ?? "meta-llama/Meta-Llama-3-8B-Instruct";
2699
+ console.log(`
2700
+ [LLM ${kind}] POST`, this.url);
2701
+ console.log("[Request options]", {
2702
+ model,
2703
+ temperature: options.temperature,
2704
+ max_tokens: options.max_tokens,
2705
+ stream
2706
+ });
2707
+ console.log("[Messages \u2014 wire payload]\n", JSON.stringify(messages, null, 2));
2708
+ }
2627
2709
  async embed(text, options = {}) {
2628
- const model = options.model ?? this.defaultEmbeddingModel ?? "text-embedding-3-small";
2629
2710
  const input = text.slice(0, 8e3);
2630
- const res = await fetch(`${this.base}/v1/embeddings`, {
2711
+ if (this.embeddingProvider === "huggingface") {
2712
+ const model2 = options.model ?? this.defaultEmbeddingModel ?? "sentence-transformers/all-MiniLM-L6-v2";
2713
+ return this.embedHuggingFaceInference(input, model2);
2714
+ }
2715
+ const model = options.model ?? this.defaultEmbeddingModel ?? "text-embedding-3-small";
2716
+ const embedUrl = `${this.base}/v1/embeddings`;
2717
+ if (this.embedDebugEnabled()) {
2718
+ console.info("[LLM embed] request", { url: embedUrl, model, inputChars: input.length });
2719
+ }
2720
+ const res = await fetch(embedUrl, {
2631
2721
  method: "POST",
2632
2722
  headers: {
2633
2723
  "Content-Type": "application/json",
@@ -2640,9 +2730,17 @@ var LlmService = class _LlmService {
2640
2730
  });
2641
2731
  if (!res.ok) {
2642
2732
  const body = await res.text();
2643
- if (!_LlmService.embedWarned) {
2644
- _LlmService.embedWarned = true;
2645
- console.warn(`[LLM embed] ${res.status} ${res.statusText}: ${body.slice(0, 400)}`);
2733
+ 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.";
2734
+ if (!_LlmService.embedHttpErrorLogged) {
2735
+ _LlmService.embedHttpErrorLogged = true;
2736
+ console.error("[LLM embed]", hint404, {
2737
+ url: embedUrl,
2738
+ status: res.status,
2739
+ statusText: res.statusText,
2740
+ bodyPreview: body.slice(0, 800)
2741
+ });
2742
+ } else if (this.embedDebugEnabled()) {
2743
+ console.warn("[LLM embed] repeat HTTP error", { status: res.status, bodyPreview: body.slice(0, 200) });
2646
2744
  }
2647
2745
  return [];
2648
2746
  }
@@ -2650,7 +2748,10 @@ var LlmService = class _LlmService {
2650
2748
  try {
2651
2749
  data = await res.json();
2652
2750
  } catch {
2653
- console.warn("[LLM embed] Response is not JSON");
2751
+ if (!_LlmService.embedShapeErrorLogged) {
2752
+ _LlmService.embedShapeErrorLogged = true;
2753
+ console.error("[LLM embed] Response body is not JSON \u2014 treating as no embedding.");
2754
+ }
2654
2755
  return [];
2655
2756
  }
2656
2757
  let embedding = data?.data?.[0]?.embedding;
@@ -2661,13 +2762,154 @@ var LlmService = class _LlmService {
2661
2762
  const first = data.data[0];
2662
2763
  embedding = Array.isArray(first) ? first : first?.embedding;
2663
2764
  }
2664
- if (!Array.isArray(embedding) && !_LlmService.embedWarned) {
2665
- _LlmService.embedWarned = true;
2666
- console.warn("[LLM embed] Unexpected response shape. Keys:", Object.keys(data), "data[0] type:", Array.isArray(data?.data) ? typeof data.data[0] : "n/a");
2765
+ if (!Array.isArray(embedding)) {
2766
+ if (!_LlmService.embedShapeErrorLogged) {
2767
+ _LlmService.embedShapeErrorLogged = true;
2768
+ console.error(
2769
+ "[LLM embed] Response OK but no parseable embedding array (OpenAI shape expected). knowledge_base_chunks will not update.",
2770
+ {
2771
+ url: embedUrl,
2772
+ topKeys: Object.keys(data),
2773
+ data0Type: Array.isArray(data?.data) ? typeof data.data[0] : "n/a"
2774
+ }
2775
+ );
2776
+ }
2777
+ return [];
2778
+ }
2779
+ if (!_LlmService.embedSuccessLogged) {
2780
+ _LlmService.embedSuccessLogged = true;
2781
+ console.info("[LLM embed] first success", { dimension: embedding.length, model });
2782
+ } else if (this.embedDebugEnabled()) {
2783
+ console.info("[LLM embed] ok", { dimension: embedding.length });
2784
+ }
2785
+ return embedding;
2786
+ }
2787
+ async embedHuggingFaceInference(input, model) {
2788
+ const normalizedBase = this.hfInferenceBaseURL.replace(/\/$/, "");
2789
+ const baseWithProvider = /router\.huggingface\.co\/hf-inference$/i.test(normalizedBase) ? normalizedBase : /router\.huggingface\.co$/i.test(normalizedBase) ? `${normalizedBase}/hf-inference` : normalizedBase;
2790
+ const requestBody = JSON.stringify({
2791
+ inputs: input,
2792
+ options: { wait_for_model: true }
2793
+ });
2794
+ const pipelineUrl = `${baseWithProvider}/pipeline/feature-extraction/${model}`;
2795
+ const modelUrl = `${baseWithProvider}/models/${model}`;
2796
+ if (this.embedDebugEnabled()) {
2797
+ console.info("[LLM embed HF]", { url: pipelineUrl, model, inputChars: input.length });
2798
+ }
2799
+ let embedUrl = pipelineUrl;
2800
+ let res = await fetch(embedUrl, {
2801
+ method: "POST",
2802
+ headers: {
2803
+ "Content-Type": "application/json",
2804
+ Authorization: `Bearer ${this.embeddingApiKey}`
2805
+ },
2806
+ body: requestBody
2807
+ });
2808
+ let bodyText = await res.text();
2809
+ if (res.status === 404) {
2810
+ embedUrl = modelUrl;
2811
+ if (this.embedDebugEnabled()) {
2812
+ console.warn("[LLM embed HF] /pipeline route returned 404; retrying with /models.", {
2813
+ model,
2814
+ fallbackUrl: embedUrl
2815
+ });
2816
+ }
2817
+ res = await fetch(embedUrl, {
2818
+ method: "POST",
2819
+ headers: {
2820
+ "Content-Type": "application/json",
2821
+ Authorization: `Bearer ${this.embeddingApiKey}`
2822
+ },
2823
+ body: requestBody
2824
+ });
2825
+ bodyText = await res.text();
2826
+ }
2827
+ if (!res.ok) {
2828
+ if (!_LlmService.embedHttpErrorLogged) {
2829
+ _LlmService.embedHttpErrorLogged = true;
2830
+ console.error(
2831
+ "[LLM embed HF] Hugging Face Inference request failed \u2014 knowledge chunks stay without vectors.",
2832
+ {
2833
+ url: embedUrl,
2834
+ status: res.status,
2835
+ statusText: res.statusText,
2836
+ bodyPreview: bodyText.slice(0, 800),
2837
+ 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
2838
+ }
2839
+ );
2840
+ } else if (this.embedDebugEnabled()) {
2841
+ console.warn("[LLM embed HF] repeat HTTP error", { status: res.status, bodyPreview: bodyText.slice(0, 200) });
2842
+ }
2843
+ return [];
2844
+ }
2845
+ let data;
2846
+ try {
2847
+ data = JSON.parse(bodyText);
2848
+ } catch {
2849
+ if (!_LlmService.embedShapeErrorLogged) {
2850
+ _LlmService.embedShapeErrorLogged = true;
2851
+ console.error("[LLM embed HF] Response is not JSON \u2014 treating as no embedding.");
2852
+ }
2853
+ return [];
2854
+ }
2855
+ const embedding = parseHfInferenceEmbeddingBody(data);
2856
+ if (!embedding?.length) {
2857
+ if (!_LlmService.embedShapeErrorLogged) {
2858
+ _LlmService.embedShapeErrorLogged = true;
2859
+ const preview = typeof data === "object" && data !== null && !Array.isArray(data) ? Object.keys(data) : typeof data;
2860
+ console.error("[LLM embed HF] Unrecognized embedding shape from Inference API.", { url: embedUrl, preview });
2861
+ }
2862
+ return [];
2863
+ }
2864
+ if (!_LlmService.embedSuccessLogged) {
2865
+ _LlmService.embedSuccessLogged = true;
2866
+ console.info("[LLM embed HF] first success", { dimension: embedding.length, model });
2867
+ if (!_LlmService.hfDimensionMismatchWarned && embedding.length !== 1536) {
2868
+ _LlmService.hfDimensionMismatchWarned = true;
2869
+ console.warn(
2870
+ `[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});`
2871
+ );
2872
+ }
2873
+ } else if (this.embedDebugEnabled()) {
2874
+ console.info("[LLM embed HF] ok", { dimension: embedding.length });
2875
+ }
2876
+ return embedding;
2877
+ }
2878
+ buildAgentMessages(options) {
2879
+ const { systemPrompt, userPrompt, history = [], context } = options;
2880
+ const messages = [];
2881
+ let systemContent = systemPrompt?.trim();
2882
+ if (context) {
2883
+ systemContent = systemContent ? `${systemContent}
2884
+
2885
+ Context:
2886
+ ${context}` : `Use the following context to answer:
2887
+
2888
+ ${context}`;
2889
+ }
2890
+ if (systemContent) {
2891
+ messages.push({ role: "system", content: systemContent });
2667
2892
  }
2668
- return Array.isArray(embedding) ? embedding : [];
2893
+ if (history.length > 0) {
2894
+ messages.push(...history);
2895
+ }
2896
+ messages.push({ role: "user", content: userPrompt });
2897
+ return messages;
2898
+ }
2899
+ async chatAgent(options) {
2900
+ this.logAgentComposition(options);
2901
+ const messages = this.buildAgentMessages(options);
2902
+ const { model, temperature, max_tokens } = options;
2903
+ return this.chat(messages, { model, temperature, max_tokens });
2904
+ }
2905
+ async *streamChatAgent(options) {
2906
+ this.logAgentComposition(options);
2907
+ const messages = this.buildAgentMessages(options);
2908
+ const { model, temperature, max_tokens } = options;
2909
+ yield* this.streamChat(messages, { model, temperature, max_tokens });
2669
2910
  }
2670
2911
  async chat(messages, options = {}) {
2912
+ this.logChatCompletionsRequest("chat", messages, options, false);
2671
2913
  const res = await fetch(this.url, {
2672
2914
  method: "POST",
2673
2915
  headers: {
@@ -2675,7 +2917,7 @@ var LlmService = class _LlmService {
2675
2917
  Authorization: `Bearer ${this.apiKey}`
2676
2918
  },
2677
2919
  body: JSON.stringify({
2678
- model: options.model ?? "qwen2.5:3b-instruct",
2920
+ model: options.model ?? "meta-llama/Meta-Llama-3-8B-Instruct",
2679
2921
  messages,
2680
2922
  stream: false,
2681
2923
  temperature: options.temperature,
@@ -2688,9 +2930,13 @@ var LlmService = class _LlmService {
2688
2930
  }
2689
2931
  const data = await res.json();
2690
2932
  const content = data.choices?.[0]?.message?.content ?? "";
2933
+ if (this.llmDebugEnabled()) {
2934
+ console.log("\n[LLM chat] assistant reply\n", content);
2935
+ }
2691
2936
  return { content };
2692
2937
  }
2693
2938
  async *streamChat(messages, options = {}) {
2939
+ this.logChatCompletionsRequest("streamChat", messages, options, true);
2694
2940
  const res = await fetch(this.url, {
2695
2941
  method: "POST",
2696
2942
  headers: {
@@ -2698,7 +2944,7 @@ var LlmService = class _LlmService {
2698
2944
  Authorization: `Bearer ${this.apiKey}`
2699
2945
  },
2700
2946
  body: JSON.stringify({
2701
- model: options.model ?? "qwen2.5:3b-instruct",
2947
+ model: options.model ?? "meta-llama/Meta-Llama-3-8B-Instruct",
2702
2948
  messages,
2703
2949
  stream: true,
2704
2950
  temperature: options.temperature,
@@ -2713,6 +2959,8 @@ var LlmService = class _LlmService {
2713
2959
  if (!reader) return;
2714
2960
  const decoder = new TextDecoder();
2715
2961
  let buffer = "";
2962
+ const debug = this.llmDebugEnabled();
2963
+ let streamedReply = "";
2716
2964
  while (true) {
2717
2965
  const { value, done } = await reader.read();
2718
2966
  if (done) break;
@@ -2724,16 +2972,28 @@ var LlmService = class _LlmService {
2724
2972
  try {
2725
2973
  const json = JSON.parse(line.slice(6));
2726
2974
  const content = json.choices?.[0]?.delta?.content;
2727
- if (content) yield content;
2975
+ if (content) {
2976
+ if (debug) streamedReply += content;
2977
+ yield content;
2978
+ }
2728
2979
  } catch {
2729
2980
  }
2730
2981
  }
2731
2982
  }
2732
2983
  }
2984
+ if (debug) {
2985
+ console.log("\n[LLM streamChat] assistant reply (full)\n", streamedReply);
2986
+ }
2733
2987
  }
2734
2988
  };
2735
2989
 
2736
2990
  // src/plugins/llm/index.ts
2991
+ function normalizeEmbeddingProvider(raw) {
2992
+ if (!raw) return "openai";
2993
+ const s = raw.toLowerCase().trim();
2994
+ if (s === "huggingface" || s === "hf" || s === "hf_inference" || s === "inference") return "huggingface";
2995
+ return "openai";
2996
+ }
2737
2997
  function llmPlugin(config = {}) {
2738
2998
  return {
2739
2999
  name: "llm",
@@ -2746,7 +3006,16 @@ function llmPlugin(config = {}) {
2746
3006
  return void 0;
2747
3007
  }
2748
3008
  const embeddingModel = config.embeddingModel ?? context.config.EMBEDDING_MODEL;
2749
- return new LlmService(baseURL.replace(/\/$/, ""), apiKey, embeddingModel);
3009
+ const embeddingProvider = normalizeEmbeddingProvider(
3010
+ config.embeddingProvider ?? context.config.EMBEDDING_PROVIDER
3011
+ );
3012
+ const hfInferenceBaseUrl = config.hfInferenceBaseUrl ?? context.config.HF_INFERENCE_URL;
3013
+ const embeddingApiKey = config.embeddingApiKey ?? context.config.EMBEDDING_API_KEY;
3014
+ return new LlmService(baseURL.replace(/\/$/, ""), apiKey, embeddingModel, {
3015
+ embeddingProvider,
3016
+ hfInferenceBaseUrl,
3017
+ embeddingApiKey
3018
+ });
2750
3019
  }
2751
3020
  };
2752
3021
  }
@@ -3606,10 +3875,90 @@ async function seedDefaultAdmin(ds, entityMap, opts) {
3606
3875
  }
3607
3876
 
3608
3877
  // src/api/cms-handlers.ts
3609
- var import_typeorm5 = require("typeorm");
3878
+ var import_typeorm6 = require("typeorm");
3610
3879
  init_email_queue();
3611
3880
  init_erp_queue();
3612
3881
 
3882
+ // src/entities/llm-agent.entity.ts
3883
+ var import_typeorm4 = require("typeorm");
3884
+ var LlmAgent = class {
3885
+ id;
3886
+ name;
3887
+ slug;
3888
+ systemInstruction;
3889
+ model;
3890
+ temperature;
3891
+ maxTokens;
3892
+ validationRules;
3893
+ enabled;
3894
+ createdAt;
3895
+ updatedAt;
3896
+ deletedAt;
3897
+ deleted;
3898
+ createdBy;
3899
+ updatedBy;
3900
+ deletedBy;
3901
+ };
3902
+ __decorateClass([
3903
+ (0, import_typeorm4.PrimaryGeneratedColumn)()
3904
+ ], LlmAgent.prototype, "id", 2);
3905
+ __decorateClass([
3906
+ (0, import_typeorm4.Column)("varchar")
3907
+ ], LlmAgent.prototype, "name", 2);
3908
+ __decorateClass([
3909
+ (0, import_typeorm4.Column)("varchar")
3910
+ ], LlmAgent.prototype, "slug", 2);
3911
+ __decorateClass([
3912
+ (0, import_typeorm4.Column)("text", { name: "system_instruction", default: "" })
3913
+ ], LlmAgent.prototype, "systemInstruction", 2);
3914
+ __decorateClass([
3915
+ (0, import_typeorm4.Column)("varchar", { nullable: true })
3916
+ ], LlmAgent.prototype, "model", 2);
3917
+ __decorateClass([
3918
+ (0, import_typeorm4.Column)("double precision", { name: "temperature", nullable: true })
3919
+ ], LlmAgent.prototype, "temperature", 2);
3920
+ __decorateClass([
3921
+ (0, import_typeorm4.Column)("int", { name: "max_tokens", nullable: true })
3922
+ ], LlmAgent.prototype, "maxTokens", 2);
3923
+ __decorateClass([
3924
+ (0, import_typeorm4.Column)("text", { name: "validation_rules", nullable: true })
3925
+ ], LlmAgent.prototype, "validationRules", 2);
3926
+ __decorateClass([
3927
+ (0, import_typeorm4.Column)("boolean", { default: true })
3928
+ ], LlmAgent.prototype, "enabled", 2);
3929
+ __decorateClass([
3930
+ (0, import_typeorm4.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
3931
+ ], LlmAgent.prototype, "createdAt", 2);
3932
+ __decorateClass([
3933
+ (0, import_typeorm4.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
3934
+ ], LlmAgent.prototype, "updatedAt", 2);
3935
+ __decorateClass([
3936
+ (0, import_typeorm4.Column)({ type: "timestamp", nullable: true })
3937
+ ], LlmAgent.prototype, "deletedAt", 2);
3938
+ __decorateClass([
3939
+ (0, import_typeorm4.Column)("boolean", { default: false })
3940
+ ], LlmAgent.prototype, "deleted", 2);
3941
+ __decorateClass([
3942
+ (0, import_typeorm4.Column)("int", { nullable: true })
3943
+ ], LlmAgent.prototype, "createdBy", 2);
3944
+ __decorateClass([
3945
+ (0, import_typeorm4.Column)("int", { nullable: true })
3946
+ ], LlmAgent.prototype, "updatedBy", 2);
3947
+ __decorateClass([
3948
+ (0, import_typeorm4.Column)("int", { nullable: true })
3949
+ ], LlmAgent.prototype, "deletedBy", 2);
3950
+ LlmAgent = __decorateClass([
3951
+ (0, import_typeorm4.Entity)("llm_agents")
3952
+ ], LlmAgent);
3953
+ function llmAgentToChatAgentOptions(agent) {
3954
+ return {
3955
+ systemPrompt: agent.systemInstruction?.trim() || void 0,
3956
+ model: agent.model?.trim() || void 0,
3957
+ temperature: agent.temperature ?? void 0,
3958
+ max_tokens: agent.maxTokens ?? void 0
3959
+ };
3960
+ }
3961
+
3613
3962
  // src/lib/media-folder-path.ts
3614
3963
  function sanitizeMediaFolderPath(input) {
3615
3964
  if (input == null) return "";
@@ -3641,7 +3990,7 @@ async function relativePathFromMediaParentId(dataSource, entityMap, parentId) {
3641
3990
  }
3642
3991
 
3643
3992
  // src/lib/media-zip-extract.ts
3644
- var import_typeorm4 = require("typeorm");
3993
+ var import_typeorm5 = require("typeorm");
3645
3994
  var ZIP_MIME_TYPES = /* @__PURE__ */ new Set(["application/zip", "application/x-zip-compressed"]);
3646
3995
  var MAX_ENTRIES = 2e3;
3647
3996
  var MAX_TOTAL_UNCOMPRESSED = 80 * 1024 * 1024;
@@ -3692,7 +4041,7 @@ function guessMimeType(fileName) {
3692
4041
  async function findOrCreateFolder(dataSource, entityMap, parentId, name) {
3693
4042
  const safe = sanitizeStorageSegment(name);
3694
4043
  const repo = dataSource.getRepository(entityMap.media);
3695
- const where = parentId == null ? { kind: "folder", filename: safe, parentId: (0, import_typeorm4.IsNull)() } : { kind: "folder", filename: safe, parentId };
4044
+ const where = parentId == null ? { kind: "folder", filename: safe, parentId: (0, import_typeorm5.IsNull)() } : { kind: "folder", filename: safe, parentId };
3696
4045
  const existing = await repo.findOne({ where });
3697
4046
  if (existing) return existing.id;
3698
4047
  const row = await repo.save(
@@ -3799,6 +4148,82 @@ async function extractZipMediaIntoParentTree(opts) {
3799
4148
  }
3800
4149
 
3801
4150
  // src/api/cms-handlers.ts
4151
+ function historyBeforeCurrentUser(history, currentUserContent) {
4152
+ const last = history[history.length - 1];
4153
+ if (last?.role === "user" && last.content === currentUserContent) {
4154
+ return history.slice(0, -1);
4155
+ }
4156
+ return [...history];
4157
+ }
4158
+ function pickStructuredRules(rules) {
4159
+ return {
4160
+ maxUserChars: rules.maxUserChars,
4161
+ maxMessageLength: rules.maxMessageLength,
4162
+ minUserChars: rules.minUserChars,
4163
+ minMessageLength: rules.minMessageLength,
4164
+ blockedSubstrings: rules.blockedSubstrings
4165
+ };
4166
+ }
4167
+ function guardrailsTextFromJsonObject(rules) {
4168
+ const g = typeof rules.guardrails === "string" && rules.guardrails.trim() || typeof rules.outputRules === "string" && rules.outputRules.trim() || typeof rules.outputInstructions === "string" && rules.outputInstructions.trim() || "";
4169
+ return g || null;
4170
+ }
4171
+ function parseLlmAgentValidationRules(validationRulesText) {
4172
+ const raw = validationRulesText?.trim();
4173
+ if (!raw) return { structured: {}, guardrailsForPrompt: null };
4174
+ try {
4175
+ const parsed = JSON.parse(raw);
4176
+ if (typeof parsed === "string") {
4177
+ const s = parsed.trim();
4178
+ return { structured: {}, guardrailsForPrompt: s || null };
4179
+ }
4180
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
4181
+ return { structured: {}, guardrailsForPrompt: raw };
4182
+ }
4183
+ const rules = parsed;
4184
+ return {
4185
+ structured: pickStructuredRules(rules),
4186
+ guardrailsForPrompt: guardrailsTextFromJsonObject(rules)
4187
+ };
4188
+ } catch {
4189
+ return { structured: {}, guardrailsForPrompt: raw };
4190
+ }
4191
+ }
4192
+ function validateUserMessageAgainstStructuredRules(message, structured) {
4193
+ const maxLen = structured.maxUserChars ?? structured.maxMessageLength;
4194
+ if (typeof maxLen === "number" && Number.isFinite(maxLen) && maxLen >= 0 && message.length > maxLen) {
4195
+ return { ok: false, error: `Message exceeds maximum length (${maxLen} characters)` };
4196
+ }
4197
+ const minLen = structured.minUserChars ?? structured.minMessageLength;
4198
+ if (typeof minLen === "number" && Number.isFinite(minLen) && minLen > 0 && message.length < minLen) {
4199
+ return { ok: false, error: `Message is shorter than minimum length (${minLen} characters)` };
4200
+ }
4201
+ const blocked = structured.blockedSubstrings;
4202
+ if (Array.isArray(blocked) && blocked.length > 0) {
4203
+ const lower = message.toLowerCase();
4204
+ for (const s of blocked) {
4205
+ if (typeof s !== "string" || !s.trim()) continue;
4206
+ if (lower.includes(s.toLowerCase())) {
4207
+ return { ok: false, error: "Message contains disallowed content" };
4208
+ }
4209
+ }
4210
+ }
4211
+ return { ok: true };
4212
+ }
4213
+ function validateUserMessageAgainstAgentRules(message, validationRulesText) {
4214
+ const { structured } = parseLlmAgentValidationRules(validationRulesText);
4215
+ return validateUserMessageAgainstStructuredRules(message, structured);
4216
+ }
4217
+ function mergeGuardrailsIntoSystemPrompt(baseSystem, guardrailsForPrompt) {
4218
+ const g = guardrailsForPrompt?.trim();
4219
+ const b = (baseSystem ?? "").trim();
4220
+ if (!g) return b;
4221
+ const block = `### Output guardrails (follow in every reply)
4222
+ ${g}`;
4223
+ return b ? `${b}
4224
+
4225
+ ${block}` : block;
4226
+ }
3802
4227
  function createDashboardStatsHandler(config) {
3803
4228
  const { dataSource, entityMap, json, requireAuth, requirePermission, requireEntityPermission } = config;
3804
4229
  return async function GET(req) {
@@ -3821,8 +4246,8 @@ function createDashboardStatsHandler(config) {
3821
4246
  repo("form_submissions")?.count() ?? 0,
3822
4247
  repo("users")?.count({ where: { deleted: false } }) ?? 0,
3823
4248
  repo("blogs")?.count({ where: { deleted: false } }) ?? 0,
3824
- repo("contacts")?.count({ where: { createdAt: (0, import_typeorm5.MoreThanOrEqual)(sevenDaysAgo) } }) ?? 0,
3825
- repo("form_submissions")?.count({ where: { createdAt: (0, import_typeorm5.MoreThanOrEqual)(sevenDaysAgo) } }) ?? 0,
4249
+ repo("contacts")?.count({ where: { createdAt: (0, import_typeorm6.MoreThanOrEqual)(sevenDaysAgo) } }) ?? 0,
4250
+ repo("form_submissions")?.count({ where: { createdAt: (0, import_typeorm6.MoreThanOrEqual)(sevenDaysAgo) } }) ?? 0,
3826
4251
  repo("contacts")?.createQueryBuilder("c").select("COALESCE(NULLIF(TRIM(c.type), ''), 'unknown')", "type").addSelect("COUNT(*)", "count").where("c.deleted = :deleted", { deleted: false }).groupBy("COALESCE(NULLIF(TRIM(c.type), ''), 'unknown')").getRawMany() ?? []
3827
4252
  ]);
3828
4253
  return json({
@@ -3871,19 +4296,19 @@ function createEcommerceAnalyticsHandler(config) {
3871
4296
  const productRepo = dataSource.getRepository(entityMap.products);
3872
4297
  const [salesOrders, returnOrders, replacementOrders, payments, products] = await Promise.all([
3873
4298
  orderRepo.find({
3874
- where: { deleted: false, createdAt: (0, import_typeorm5.MoreThanOrEqual)(start), orderKind: "sale", status: (0, import_typeorm5.In)(["confirmed", "processing", "completed"]) },
4299
+ where: { deleted: false, createdAt: (0, import_typeorm6.MoreThanOrEqual)(start), orderKind: "sale", status: (0, import_typeorm6.In)(["confirmed", "processing", "completed"]) },
3875
4300
  select: ["id", "contactId", "createdAt", "subtotal", "discount", "tax", "total", "status"]
3876
4301
  }),
3877
4302
  orderRepo.find({
3878
- where: { deleted: false, createdAt: (0, import_typeorm5.MoreThanOrEqual)(start), orderKind: "return" },
4303
+ where: { deleted: false, createdAt: (0, import_typeorm6.MoreThanOrEqual)(start), orderKind: "return" },
3879
4304
  select: ["id", "createdAt", "total"]
3880
4305
  }),
3881
4306
  orderRepo.find({
3882
- where: { deleted: false, createdAt: (0, import_typeorm5.MoreThanOrEqual)(start), orderKind: "replacement" },
4307
+ where: { deleted: false, createdAt: (0, import_typeorm6.MoreThanOrEqual)(start), orderKind: "replacement" },
3883
4308
  select: ["id", "createdAt", "total"]
3884
4309
  }),
3885
4310
  paymentRepo.find({
3886
- where: { deleted: false, createdAt: (0, import_typeorm5.MoreThanOrEqual)(start) },
4311
+ where: { deleted: false, createdAt: (0, import_typeorm6.MoreThanOrEqual)(start) },
3887
4312
  select: ["id", "status", "method", "amount", "createdAt"]
3888
4313
  }),
3889
4314
  productRepo.find({
@@ -3893,7 +4318,7 @@ function createEcommerceAnalyticsHandler(config) {
3893
4318
  ]);
3894
4319
  const saleOrderIds = salesOrders.map((o) => o.id);
3895
4320
  const orderItems = saleOrderIds.length ? await itemRepo.find({
3896
- where: { orderId: (0, import_typeorm5.In)(saleOrderIds) },
4321
+ where: { orderId: (0, import_typeorm6.In)(saleOrderIds) },
3897
4322
  select: ["id", "orderId", "productId", "quantity", "total"]
3898
4323
  }) : [];
3899
4324
  const grossSales = salesOrders.reduce((sum, o) => sum + toNum(o.subtotal), 0);
@@ -4581,8 +5006,8 @@ function createUsersApiHandlers(config) {
4581
5006
  const sortOrder = url.searchParams.get("sortOrder") === "desc" ? "DESC" : "ASC";
4582
5007
  const search = url.searchParams.get("search");
4583
5008
  const where = search ? [
4584
- { name: (0, import_typeorm5.ILike)(`%${search}%`), deleted: false },
4585
- { email: (0, import_typeorm5.ILike)(`%${search}%`), deleted: false }
5009
+ { name: (0, import_typeorm6.ILike)(`%${search}%`), deleted: false },
5010
+ { email: (0, import_typeorm6.ILike)(`%${search}%`), deleted: false }
4586
5011
  ] : { deleted: false };
4587
5012
  const [data, total] = await userRepo().findAndCount({
4588
5013
  skip,
@@ -4880,9 +5305,24 @@ function createSettingsApiHandlers(config) {
4880
5305
  }
4881
5306
  var KB_CHUNK_LIMIT = 10;
4882
5307
  var KB_CONTEXT_MAX_CHARS = 4e3;
5308
+ var RAG_LOG = "[rag-context]";
4883
5309
  function getQueryTerms(message) {
4884
5310
  return message.replace(/[^\w\s]/g, " ").split(/\s+/).filter((w) => w.length > 2).slice(0, 6);
4885
5311
  }
5312
+ function normalizeChatModeSetting(raw) {
5313
+ if (raw === "external" || raw === "llm") return raw;
5314
+ return "whatsapp";
5315
+ }
5316
+ async function loadLlmSettingsMap(dataSource, entityMap) {
5317
+ if (!entityMap.configs) return {};
5318
+ const repo = dataSource.getRepository(entityMap.configs);
5319
+ const rows = await repo.find({ where: { settings: "llm", deleted: false } });
5320
+ const out = {};
5321
+ for (const row of rows) {
5322
+ out[row.key] = row.value;
5323
+ }
5324
+ return out;
5325
+ }
4886
5326
  function createChatHandlers(config) {
4887
5327
  const { dataSource, entityMap, json, getCms } = config;
4888
5328
  const contactRepo = () => dataSource.getRepository(entityMap.contacts);
@@ -4890,6 +5330,26 @@ function createChatHandlers(config) {
4890
5330
  const msgRepo = () => dataSource.getRepository(entityMap.chat_messages);
4891
5331
  const chunkRepo = () => dataSource.getRepository(entityMap.knowledge_base_chunks);
4892
5332
  return {
5333
+ async publicConfig(_req) {
5334
+ try {
5335
+ const map = await loadLlmSettingsMap(dataSource, entityMap);
5336
+ const mode = normalizeChatModeSetting(map.chatMode);
5337
+ const body = {
5338
+ enabled: map.enabled !== "false",
5339
+ chatMode: mode,
5340
+ agentSlug: mode === "llm" ? (map.attachedAgentSlug ?? "").trim() : "",
5341
+ botName: map.botName ?? "",
5342
+ icon: map.icon ?? "",
5343
+ iconImageUrl: map.iconImageUrl ?? "",
5344
+ iconBackgroundColor: map.iconBackgroundColor ?? "#6366f1",
5345
+ headerColor: map.headerColor ?? "#6366f1",
5346
+ whatsappPhone: map.whatsappPhone ?? ""
5347
+ };
5348
+ return json(body);
5349
+ } catch {
5350
+ return json({ error: "Failed to load chat config" }, { status: 500 });
5351
+ }
5352
+ },
4893
5353
  async identify(req) {
4894
5354
  try {
4895
5355
  const body = await req.json();
@@ -4937,20 +5397,78 @@ function createChatHandlers(config) {
4937
5397
  relations: ["messages"]
4938
5398
  });
4939
5399
  if (!conv) return json({ error: "Conversation not found" }, { status: 404 });
4940
- const msgRepoInst = msgRepo();
4941
- await msgRepoInst.save(msgRepoInst.create({ conversationId, role: "user", content: message }));
4942
5400
  const cms = await getCms();
4943
5401
  const llm = cms.getPlugin("llm");
4944
5402
  if (!llm?.chat) return json({ error: "LLM not configured" }, { status: 503 });
5403
+ const llmSettings = await loadLlmSettingsMap(dataSource, entityMap);
5404
+ const supportMode = normalizeChatModeSetting(llmSettings.chatMode);
5405
+ let effectiveSlug = (body?.agentSlug ?? "").trim();
5406
+ if (!effectiveSlug && supportMode === "llm" && entityMap.llm_agents) {
5407
+ effectiveSlug = (llmSettings.attachedAgentSlug ?? "").trim();
5408
+ }
5409
+ let agentRow = null;
5410
+ if (effectiveSlug) {
5411
+ if (!entityMap.llm_agents) {
5412
+ return json({ error: "LLM agents are not configured on this deployment" }, { status: 400 });
5413
+ }
5414
+ const agentRepo = dataSource.getRepository(
5415
+ entityMap.llm_agents
5416
+ );
5417
+ agentRow = await agentRepo.findOne({
5418
+ where: { slug: effectiveSlug, deleted: false, enabled: true }
5419
+ });
5420
+ if (!agentRow && (body?.agentSlug ?? "").trim()) {
5421
+ return json({ error: "Agent not found or disabled", agentSlug: effectiveSlug }, { status: 404 });
5422
+ }
5423
+ }
5424
+ console.info(RAG_LOG, "step 1 | resolve agent", {
5425
+ agentSlug: effectiveSlug || "(none)",
5426
+ agentFound: !!agentRow,
5427
+ agentId: agentRow?.id ?? null
5428
+ });
5429
+ const parsedValidation = agentRow ? parseLlmAgentValidationRules(agentRow.validationRules) : { structured: {}, guardrailsForPrompt: null };
5430
+ if (agentRow) {
5431
+ const v = validateUserMessageAgainstStructuredRules(message, parsedValidation.structured);
5432
+ if (!v.ok) return json({ error: v.error, reason: "validation_failed" }, { status: 400 });
5433
+ }
5434
+ let kbDocumentScope;
5435
+ const Junction = entityMap.llm_agent_knowledge_documents;
5436
+ if (agentRow && Junction) {
5437
+ const linkRepo = dataSource.getRepository(Junction);
5438
+ const links = await linkRepo.find({ where: { agentId: agentRow.id } });
5439
+ const ids = [...new Set(links.map((l) => l.documentId))];
5440
+ if (ids.length > 0) kbDocumentScope = ids;
5441
+ }
5442
+ console.info(RAG_LOG, "step 2 | knowledge scope", {
5443
+ scopedDocumentIds: kbDocumentScope ?? "(all documents)",
5444
+ documentCount: kbDocumentScope?.length ?? "all"
5445
+ });
5446
+ const msgRepoInst = msgRepo();
5447
+ await msgRepoInst.save(msgRepoInst.create({ conversationId, role: "user", content: message }));
4945
5448
  let contextParts = [];
5449
+ console.info(RAG_LOG, "step 3 | embed user query", {
5450
+ messageChars: message.length,
5451
+ embedAvailable: !!llm.embed
5452
+ });
4946
5453
  const queryEmbedding = llm.embed ? await llm.embed(message) : null;
5454
+ console.info(RAG_LOG, "step 4 | query embedding result", {
5455
+ dimensions: queryEmbedding?.length ?? 0,
5456
+ hasEmbedding: !!(queryEmbedding && queryEmbedding.length > 0)
5457
+ });
4947
5458
  if (queryEmbedding && queryEmbedding.length > 0) {
4948
5459
  const vectorStr = "[" + queryEmbedding.join(",") + "]";
4949
5460
  try {
4950
- const rows = await dataSource.query(
5461
+ const rows = kbDocumentScope?.length ? await dataSource.query(
5462
+ `SELECT id, content FROM knowledge_base_chunks WHERE embedding IS NOT NULL AND "documentId" = ANY($3::int[]) ORDER BY embedding <=> $1::vector LIMIT $2`,
5463
+ [vectorStr, KB_CHUNK_LIMIT, kbDocumentScope]
5464
+ ) : await dataSource.query(
4951
5465
  `SELECT id, content FROM knowledge_base_chunks WHERE embedding IS NOT NULL ORDER BY embedding <=> $1::vector LIMIT $2`,
4952
5466
  [vectorStr, KB_CHUNK_LIMIT]
4953
5467
  );
5468
+ console.info(RAG_LOG, "step 5 | vector search results", {
5469
+ rowsReturned: rows.length,
5470
+ chunkIds: rows.map((r) => r.id)
5471
+ });
4954
5472
  let totalLen = 0;
4955
5473
  for (const r of rows) {
4956
5474
  const text = (r.content ?? "").trim();
@@ -4958,13 +5476,24 @@ function createChatHandlers(config) {
4958
5476
  contextParts.push(text);
4959
5477
  totalLen += text.length;
4960
5478
  }
4961
- } catch {
5479
+ console.info(RAG_LOG, "step 5a | vector context selected", {
5480
+ chunksUsed: contextParts.length,
5481
+ totalChars: totalLen
5482
+ });
5483
+ } catch (vecErr) {
5484
+ console.warn(RAG_LOG, "step 5 | vector search failed; falling back to keyword", {
5485
+ err: vecErr instanceof Error ? vecErr.message : String(vecErr)
5486
+ });
4962
5487
  }
4963
5488
  }
4964
5489
  if (contextParts.length === 0) {
4965
5490
  const terms = getQueryTerms(message);
5491
+ console.info(RAG_LOG, "step 6 | keyword fallback", {
5492
+ reason: !(queryEmbedding && queryEmbedding.length > 0) ? "no embedding" : "vector search returned nothing",
5493
+ searchTerms: terms
5494
+ });
4966
5495
  if (terms.length > 0) {
4967
- const conditions = terms.map((t) => ({ content: (0, import_typeorm5.ILike)(`%${t}%`) }));
5496
+ const conditions = kbDocumentScope?.length ? terms.map((t) => ({ content: (0, import_typeorm6.ILike)(`%${t}%`), documentId: (0, import_typeorm6.In)(kbDocumentScope) })) : terms.map((t) => ({ content: (0, import_typeorm6.ILike)(`%${t}%`) }));
4968
5497
  const chunks = await chunkRepo().find({
4969
5498
  where: conditions,
4970
5499
  take: KB_CHUNK_LIMIT,
@@ -4979,19 +5508,66 @@ function createChatHandlers(config) {
4979
5508
  contextParts.push(text);
4980
5509
  totalLen += text.length;
4981
5510
  }
5511
+ console.info(RAG_LOG, "step 6a | keyword results", {
5512
+ chunksFound: chunks.length,
5513
+ chunksUsed: contextParts.length,
5514
+ totalChars: totalLen
5515
+ });
4982
5516
  }
4983
5517
  }
4984
- 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 }));
4985
- 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.
5518
+ 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 }));
5519
+ const history = historyBeforeCurrentUser(historyRaw, message);
5520
+ let content;
5521
+ const ragContext = contextParts.length > 0 ? contextParts.join("\n\n") : void 0;
5522
+ console.info(RAG_LOG, "step 7 | final context", {
5523
+ method: contextParts.length > 0 ? "rag" : "none",
5524
+ contextChunks: contextParts.length,
5525
+ contextChars: ragContext?.length ?? 0,
5526
+ contextPreview: ragContext ? ragContext.slice(0, 200) + (ragContext.length > 200 ? "\u2026" : "") : "(no context)"
5527
+ });
5528
+ if (agentRow && llm.chatAgent) {
5529
+ const fromAgent = llmAgentToChatAgentOptions(agentRow);
5530
+ const systemPrompt = mergeGuardrailsIntoSystemPrompt(
5531
+ fromAgent.systemPrompt,
5532
+ parsedValidation.guardrailsForPrompt
5533
+ );
5534
+ const res = await llm.chatAgent({
5535
+ ...fromAgent,
5536
+ systemPrompt: systemPrompt || void 0,
5537
+ context: ragContext,
5538
+ history,
5539
+ userPrompt: message
5540
+ });
5541
+ content = res.content;
5542
+ } else {
5543
+ 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.
4986
5544
 
4987
5545
  Context:
4988
- ${contextParts.join("\n\n")}` : "You are a helpful assistant for the company. If you do not have specific information, say so.";
4989
- const messages = [
4990
- { role: "system", content: systemContent },
4991
- ...history,
4992
- { role: "user", content: message }
4993
- ];
4994
- const { content } = await llm.chat(messages);
5546
+ ${contextParts.join("\n\n")}` : "";
5547
+ const defaultSystem = "You are a helpful assistant for the company. If you do not have specific information, say so.";
5548
+ let systemContent;
5549
+ if (agentRow) {
5550
+ const base = agentRow.systemInstruction?.trim() || "";
5551
+ systemContent = mergeGuardrailsIntoSystemPrompt(
5552
+ [base, ragSystem].filter(Boolean).join("\n\n") || defaultSystem,
5553
+ parsedValidation.guardrailsForPrompt
5554
+ );
5555
+ } else {
5556
+ systemContent = ragSystem || defaultSystem;
5557
+ }
5558
+ const messages = [
5559
+ { role: "system", content: systemContent },
5560
+ ...history,
5561
+ { role: "user", content: message }
5562
+ ];
5563
+ const chatOpts = agentRow ? {
5564
+ model: agentRow.model ?? void 0,
5565
+ temperature: agentRow.temperature ?? void 0,
5566
+ max_tokens: agentRow.maxTokens ?? void 0
5567
+ } : {};
5568
+ const res = await llm.chat(messages, chatOpts);
5569
+ content = res.content;
5570
+ }
4995
5571
  await msgRepoInst.save(msgRepoInst.create({ conversationId, role: "assistant", content }));
4996
5572
  return json({ content });
4997
5573
  } catch (err) {
@@ -5050,13 +5626,13 @@ async function loadPublicThemeSettings(config) {
5050
5626
  }
5051
5627
 
5052
5628
  // src/entities/user.entity.ts
5053
- var import_typeorm8 = require("typeorm");
5629
+ var import_typeorm9 = require("typeorm");
5054
5630
 
5055
5631
  // src/entities/user-group.entity.ts
5056
- var import_typeorm7 = require("typeorm");
5632
+ var import_typeorm8 = require("typeorm");
5057
5633
 
5058
5634
  // src/entities/permission.entity.ts
5059
- var import_typeorm6 = require("typeorm");
5635
+ var import_typeorm7 = require("typeorm");
5060
5636
  var Permission = class {
5061
5637
  id;
5062
5638
  groupId;
@@ -5075,53 +5651,53 @@ var Permission = class {
5075
5651
  group;
5076
5652
  };
5077
5653
  __decorateClass([
5078
- (0, import_typeorm6.PrimaryGeneratedColumn)()
5654
+ (0, import_typeorm7.PrimaryGeneratedColumn)()
5079
5655
  ], Permission.prototype, "id", 2);
5080
5656
  __decorateClass([
5081
- (0, import_typeorm6.Column)("int")
5657
+ (0, import_typeorm7.Column)("int")
5082
5658
  ], Permission.prototype, "groupId", 2);
5083
5659
  __decorateClass([
5084
- (0, import_typeorm6.Column)("varchar")
5660
+ (0, import_typeorm7.Column)("varchar")
5085
5661
  ], Permission.prototype, "entity", 2);
5086
5662
  __decorateClass([
5087
- (0, import_typeorm6.Column)("boolean", { default: false })
5663
+ (0, import_typeorm7.Column)("boolean", { default: false })
5088
5664
  ], Permission.prototype, "canCreate", 2);
5089
5665
  __decorateClass([
5090
- (0, import_typeorm6.Column)("boolean", { default: false })
5666
+ (0, import_typeorm7.Column)("boolean", { default: false })
5091
5667
  ], Permission.prototype, "canRead", 2);
5092
5668
  __decorateClass([
5093
- (0, import_typeorm6.Column)("boolean", { default: false })
5669
+ (0, import_typeorm7.Column)("boolean", { default: false })
5094
5670
  ], Permission.prototype, "canUpdate", 2);
5095
5671
  __decorateClass([
5096
- (0, import_typeorm6.Column)("boolean", { default: false })
5672
+ (0, import_typeorm7.Column)("boolean", { default: false })
5097
5673
  ], Permission.prototype, "canDelete", 2);
5098
5674
  __decorateClass([
5099
- (0, import_typeorm6.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5675
+ (0, import_typeorm7.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5100
5676
  ], Permission.prototype, "createdAt", 2);
5101
5677
  __decorateClass([
5102
- (0, import_typeorm6.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5678
+ (0, import_typeorm7.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5103
5679
  ], Permission.prototype, "updatedAt", 2);
5104
5680
  __decorateClass([
5105
- (0, import_typeorm6.Column)({ type: "timestamp", nullable: true })
5681
+ (0, import_typeorm7.Column)({ type: "timestamp", nullable: true })
5106
5682
  ], Permission.prototype, "deletedAt", 2);
5107
5683
  __decorateClass([
5108
- (0, import_typeorm6.Column)("boolean", { default: false })
5684
+ (0, import_typeorm7.Column)("boolean", { default: false })
5109
5685
  ], Permission.prototype, "deleted", 2);
5110
5686
  __decorateClass([
5111
- (0, import_typeorm6.Column)("int", { nullable: true })
5687
+ (0, import_typeorm7.Column)("int", { nullable: true })
5112
5688
  ], Permission.prototype, "createdBy", 2);
5113
5689
  __decorateClass([
5114
- (0, import_typeorm6.Column)("int", { nullable: true })
5690
+ (0, import_typeorm7.Column)("int", { nullable: true })
5115
5691
  ], Permission.prototype, "updatedBy", 2);
5116
5692
  __decorateClass([
5117
- (0, import_typeorm6.Column)("int", { nullable: true })
5693
+ (0, import_typeorm7.Column)("int", { nullable: true })
5118
5694
  ], Permission.prototype, "deletedBy", 2);
5119
5695
  __decorateClass([
5120
- (0, import_typeorm6.ManyToOne)(() => UserGroup, (g) => g.permissions, { onDelete: "CASCADE" }),
5121
- (0, import_typeorm6.JoinColumn)({ name: "groupId" })
5696
+ (0, import_typeorm7.ManyToOne)(() => UserGroup, (g) => g.permissions, { onDelete: "CASCADE" }),
5697
+ (0, import_typeorm7.JoinColumn)({ name: "groupId" })
5122
5698
  ], Permission.prototype, "group", 2);
5123
5699
  Permission = __decorateClass([
5124
- (0, import_typeorm6.Entity)("permissions")
5700
+ (0, import_typeorm7.Entity)("permissions")
5125
5701
  ], Permission);
5126
5702
 
5127
5703
  // src/entities/user-group.entity.ts
@@ -5139,40 +5715,40 @@ var UserGroup = class {
5139
5715
  users;
5140
5716
  };
5141
5717
  __decorateClass([
5142
- (0, import_typeorm7.PrimaryGeneratedColumn)()
5718
+ (0, import_typeorm8.PrimaryGeneratedColumn)()
5143
5719
  ], UserGroup.prototype, "id", 2);
5144
5720
  __decorateClass([
5145
- (0, import_typeorm7.Column)("varchar", { unique: true })
5721
+ (0, import_typeorm8.Column)("varchar", { unique: true })
5146
5722
  ], UserGroup.prototype, "name", 2);
5147
5723
  __decorateClass([
5148
- (0, import_typeorm7.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5724
+ (0, import_typeorm8.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5149
5725
  ], UserGroup.prototype, "createdAt", 2);
5150
5726
  __decorateClass([
5151
- (0, import_typeorm7.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5727
+ (0, import_typeorm8.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5152
5728
  ], UserGroup.prototype, "updatedAt", 2);
5153
5729
  __decorateClass([
5154
- (0, import_typeorm7.Column)({ type: "timestamp", nullable: true })
5730
+ (0, import_typeorm8.Column)({ type: "timestamp", nullable: true })
5155
5731
  ], UserGroup.prototype, "deletedAt", 2);
5156
5732
  __decorateClass([
5157
- (0, import_typeorm7.Column)("boolean", { default: false })
5733
+ (0, import_typeorm8.Column)("boolean", { default: false })
5158
5734
  ], UserGroup.prototype, "deleted", 2);
5159
5735
  __decorateClass([
5160
- (0, import_typeorm7.Column)("int", { nullable: true })
5736
+ (0, import_typeorm8.Column)("int", { nullable: true })
5161
5737
  ], UserGroup.prototype, "createdBy", 2);
5162
5738
  __decorateClass([
5163
- (0, import_typeorm7.Column)("int", { nullable: true })
5739
+ (0, import_typeorm8.Column)("int", { nullable: true })
5164
5740
  ], UserGroup.prototype, "updatedBy", 2);
5165
5741
  __decorateClass([
5166
- (0, import_typeorm7.Column)("int", { nullable: true })
5742
+ (0, import_typeorm8.Column)("int", { nullable: true })
5167
5743
  ], UserGroup.prototype, "deletedBy", 2);
5168
5744
  __decorateClass([
5169
- (0, import_typeorm7.OneToMany)(() => Permission, (p) => p.group)
5745
+ (0, import_typeorm8.OneToMany)(() => Permission, (p) => p.group)
5170
5746
  ], UserGroup.prototype, "permissions", 2);
5171
5747
  __decorateClass([
5172
- (0, import_typeorm7.OneToMany)(() => User, (u) => u.group)
5748
+ (0, import_typeorm8.OneToMany)(() => User, (u) => u.group)
5173
5749
  ], UserGroup.prototype, "users", 2);
5174
5750
  UserGroup = __decorateClass([
5175
- (0, import_typeorm7.Entity)("user_groups")
5751
+ (0, import_typeorm8.Entity)("user_groups")
5176
5752
  ], UserGroup);
5177
5753
 
5178
5754
  // src/entities/user.entity.ts
@@ -5197,66 +5773,66 @@ var User = class {
5197
5773
  group;
5198
5774
  };
5199
5775
  __decorateClass([
5200
- (0, import_typeorm8.PrimaryGeneratedColumn)()
5776
+ (0, import_typeorm9.PrimaryGeneratedColumn)()
5201
5777
  ], User.prototype, "id", 2);
5202
5778
  __decorateClass([
5203
- (0, import_typeorm8.Column)("varchar")
5779
+ (0, import_typeorm9.Column)("varchar")
5204
5780
  ], User.prototype, "name", 2);
5205
5781
  __decorateClass([
5206
- (0, import_typeorm8.Column)("varchar", { unique: true })
5782
+ (0, import_typeorm9.Column)("varchar", { unique: true })
5207
5783
  ], User.prototype, "email", 2);
5208
5784
  __decorateClass([
5209
- (0, import_typeorm8.Column)("varchar", { nullable: true })
5785
+ (0, import_typeorm9.Column)("varchar", { nullable: true })
5210
5786
  ], User.prototype, "phone", 2);
5211
5787
  __decorateClass([
5212
- (0, import_typeorm8.Column)({ type: "timestamp", nullable: true })
5788
+ (0, import_typeorm9.Column)({ type: "timestamp", nullable: true })
5213
5789
  ], User.prototype, "phoneVerifiedAt", 2);
5214
5790
  __decorateClass([
5215
- (0, import_typeorm8.Column)({ type: "timestamp", nullable: true })
5791
+ (0, import_typeorm9.Column)({ type: "timestamp", nullable: true })
5216
5792
  ], User.prototype, "emailVerifiedAt", 2);
5217
5793
  __decorateClass([
5218
- (0, import_typeorm8.Column)("varchar", { nullable: true })
5794
+ (0, import_typeorm9.Column)("varchar", { nullable: true })
5219
5795
  ], User.prototype, "password", 2);
5220
5796
  __decorateClass([
5221
- (0, import_typeorm8.Column)("boolean", { default: false })
5797
+ (0, import_typeorm9.Column)("boolean", { default: false })
5222
5798
  ], User.prototype, "blocked", 2);
5223
5799
  __decorateClass([
5224
- (0, import_typeorm8.Column)("boolean", { default: false })
5800
+ (0, import_typeorm9.Column)("boolean", { default: false })
5225
5801
  ], User.prototype, "adminAccess", 2);
5226
5802
  __decorateClass([
5227
- (0, import_typeorm8.Column)("int", { nullable: true })
5803
+ (0, import_typeorm9.Column)("int", { nullable: true })
5228
5804
  ], User.prototype, "groupId", 2);
5229
5805
  __decorateClass([
5230
- (0, import_typeorm8.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5806
+ (0, import_typeorm9.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5231
5807
  ], User.prototype, "createdAt", 2);
5232
5808
  __decorateClass([
5233
- (0, import_typeorm8.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5809
+ (0, import_typeorm9.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5234
5810
  ], User.prototype, "updatedAt", 2);
5235
5811
  __decorateClass([
5236
- (0, import_typeorm8.Column)({ type: "timestamp", nullable: true })
5812
+ (0, import_typeorm9.Column)({ type: "timestamp", nullable: true })
5237
5813
  ], User.prototype, "deletedAt", 2);
5238
5814
  __decorateClass([
5239
- (0, import_typeorm8.Column)("boolean", { default: false })
5815
+ (0, import_typeorm9.Column)("boolean", { default: false })
5240
5816
  ], User.prototype, "deleted", 2);
5241
5817
  __decorateClass([
5242
- (0, import_typeorm8.Column)("int", { nullable: true })
5818
+ (0, import_typeorm9.Column)("int", { nullable: true })
5243
5819
  ], User.prototype, "createdBy", 2);
5244
5820
  __decorateClass([
5245
- (0, import_typeorm8.Column)("int", { nullable: true })
5821
+ (0, import_typeorm9.Column)("int", { nullable: true })
5246
5822
  ], User.prototype, "updatedBy", 2);
5247
5823
  __decorateClass([
5248
- (0, import_typeorm8.Column)("int", { nullable: true })
5824
+ (0, import_typeorm9.Column)("int", { nullable: true })
5249
5825
  ], User.prototype, "deletedBy", 2);
5250
5826
  __decorateClass([
5251
- (0, import_typeorm8.ManyToOne)(() => UserGroup, (g) => g.users, { onDelete: "SET NULL" }),
5252
- (0, import_typeorm8.JoinColumn)({ name: "groupId" })
5827
+ (0, import_typeorm9.ManyToOne)(() => UserGroup, (g) => g.users, { onDelete: "SET NULL" }),
5828
+ (0, import_typeorm9.JoinColumn)({ name: "groupId" })
5253
5829
  ], User.prototype, "group", 2);
5254
5830
  User = __decorateClass([
5255
- (0, import_typeorm8.Entity)("users")
5831
+ (0, import_typeorm9.Entity)("users")
5256
5832
  ], User);
5257
5833
 
5258
5834
  // src/entities/otp-challenge.entity.ts
5259
- var import_typeorm9 = require("typeorm");
5835
+ var import_typeorm10 = require("typeorm");
5260
5836
  var OtpChallenge = class {
5261
5837
  id;
5262
5838
  purpose;
@@ -5269,39 +5845,39 @@ var OtpChallenge = class {
5269
5845
  createdAt;
5270
5846
  };
5271
5847
  __decorateClass([
5272
- (0, import_typeorm9.PrimaryGeneratedColumn)()
5848
+ (0, import_typeorm10.PrimaryGeneratedColumn)()
5273
5849
  ], OtpChallenge.prototype, "id", 2);
5274
5850
  __decorateClass([
5275
- (0, import_typeorm9.Column)("varchar")
5851
+ (0, import_typeorm10.Column)("varchar")
5276
5852
  ], OtpChallenge.prototype, "purpose", 2);
5277
5853
  __decorateClass([
5278
- (0, import_typeorm9.Column)("varchar")
5854
+ (0, import_typeorm10.Column)("varchar")
5279
5855
  ], OtpChallenge.prototype, "channel", 2);
5280
5856
  __decorateClass([
5281
- (0, import_typeorm9.Column)("varchar")
5857
+ (0, import_typeorm10.Column)("varchar")
5282
5858
  ], OtpChallenge.prototype, "identifier", 2);
5283
5859
  __decorateClass([
5284
- (0, import_typeorm9.Column)("varchar")
5860
+ (0, import_typeorm10.Column)("varchar")
5285
5861
  ], OtpChallenge.prototype, "codeHash", 2);
5286
5862
  __decorateClass([
5287
- (0, import_typeorm9.Column)({ type: "timestamp" })
5863
+ (0, import_typeorm10.Column)({ type: "timestamp" })
5288
5864
  ], OtpChallenge.prototype, "expiresAt", 2);
5289
5865
  __decorateClass([
5290
- (0, import_typeorm9.Column)("int", { default: 0 })
5866
+ (0, import_typeorm10.Column)("int", { default: 0 })
5291
5867
  ], OtpChallenge.prototype, "attempts", 2);
5292
5868
  __decorateClass([
5293
- (0, import_typeorm9.Column)({ type: "timestamp", nullable: true })
5869
+ (0, import_typeorm10.Column)({ type: "timestamp", nullable: true })
5294
5870
  ], OtpChallenge.prototype, "consumedAt", 2);
5295
5871
  __decorateClass([
5296
- (0, import_typeorm9.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5872
+ (0, import_typeorm10.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5297
5873
  ], OtpChallenge.prototype, "createdAt", 2);
5298
5874
  OtpChallenge = __decorateClass([
5299
- (0, import_typeorm9.Entity)("otp_challenges"),
5300
- (0, import_typeorm9.Index)(["purpose", "identifier"])
5875
+ (0, import_typeorm10.Entity)("otp_challenges"),
5876
+ (0, import_typeorm10.Index)(["purpose", "identifier"])
5301
5877
  ], OtpChallenge);
5302
5878
 
5303
5879
  // src/entities/password-reset-token.entity.ts
5304
- var import_typeorm10 = require("typeorm");
5880
+ var import_typeorm11 = require("typeorm");
5305
5881
  var PasswordResetToken = class {
5306
5882
  id;
5307
5883
  email;
@@ -5310,29 +5886,29 @@ var PasswordResetToken = class {
5310
5886
  createdAt;
5311
5887
  };
5312
5888
  __decorateClass([
5313
- (0, import_typeorm10.PrimaryGeneratedColumn)()
5889
+ (0, import_typeorm11.PrimaryGeneratedColumn)()
5314
5890
  ], PasswordResetToken.prototype, "id", 2);
5315
5891
  __decorateClass([
5316
- (0, import_typeorm10.Column)("varchar")
5892
+ (0, import_typeorm11.Column)("varchar")
5317
5893
  ], PasswordResetToken.prototype, "email", 2);
5318
5894
  __decorateClass([
5319
- (0, import_typeorm10.Column)("varchar", { unique: true })
5895
+ (0, import_typeorm11.Column)("varchar", { unique: true })
5320
5896
  ], PasswordResetToken.prototype, "token", 2);
5321
5897
  __decorateClass([
5322
- (0, import_typeorm10.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5898
+ (0, import_typeorm11.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5323
5899
  ], PasswordResetToken.prototype, "expiresAt", 2);
5324
5900
  __decorateClass([
5325
- (0, import_typeorm10.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5901
+ (0, import_typeorm11.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5326
5902
  ], PasswordResetToken.prototype, "createdAt", 2);
5327
5903
  PasswordResetToken = __decorateClass([
5328
- (0, import_typeorm10.Entity)("password_reset_tokens")
5904
+ (0, import_typeorm11.Entity)("password_reset_tokens")
5329
5905
  ], PasswordResetToken);
5330
5906
 
5331
5907
  // src/entities/blog.entity.ts
5332
- var import_typeorm15 = require("typeorm");
5908
+ var import_typeorm16 = require("typeorm");
5333
5909
 
5334
5910
  // src/entities/category.entity.ts
5335
- var import_typeorm11 = require("typeorm");
5911
+ var import_typeorm12 = require("typeorm");
5336
5912
  var Category = class {
5337
5913
  id;
5338
5914
  name;
@@ -5346,41 +5922,41 @@ var Category = class {
5346
5922
  blogs;
5347
5923
  };
5348
5924
  __decorateClass([
5349
- (0, import_typeorm11.PrimaryGeneratedColumn)()
5925
+ (0, import_typeorm12.PrimaryGeneratedColumn)()
5350
5926
  ], Category.prototype, "id", 2);
5351
5927
  __decorateClass([
5352
- (0, import_typeorm11.Column)("varchar", { unique: true })
5928
+ (0, import_typeorm12.Column)("varchar", { unique: true })
5353
5929
  ], Category.prototype, "name", 2);
5354
5930
  __decorateClass([
5355
- (0, import_typeorm11.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5931
+ (0, import_typeorm12.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5356
5932
  ], Category.prototype, "createdAt", 2);
5357
5933
  __decorateClass([
5358
- (0, import_typeorm11.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5934
+ (0, import_typeorm12.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5359
5935
  ], Category.prototype, "updatedAt", 2);
5360
5936
  __decorateClass([
5361
- (0, import_typeorm11.Column)({ type: "timestamp", nullable: true })
5937
+ (0, import_typeorm12.Column)({ type: "timestamp", nullable: true })
5362
5938
  ], Category.prototype, "deletedAt", 2);
5363
5939
  __decorateClass([
5364
- (0, import_typeorm11.Column)("boolean", { default: false })
5940
+ (0, import_typeorm12.Column)("boolean", { default: false })
5365
5941
  ], Category.prototype, "deleted", 2);
5366
5942
  __decorateClass([
5367
- (0, import_typeorm11.Column)("int", { nullable: true })
5943
+ (0, import_typeorm12.Column)("int", { nullable: true })
5368
5944
  ], Category.prototype, "createdBy", 2);
5369
5945
  __decorateClass([
5370
- (0, import_typeorm11.Column)("int", { nullable: true })
5946
+ (0, import_typeorm12.Column)("int", { nullable: true })
5371
5947
  ], Category.prototype, "updatedBy", 2);
5372
5948
  __decorateClass([
5373
- (0, import_typeorm11.Column)("int", { nullable: true })
5949
+ (0, import_typeorm12.Column)("int", { nullable: true })
5374
5950
  ], Category.prototype, "deletedBy", 2);
5375
5951
  __decorateClass([
5376
- (0, import_typeorm11.OneToMany)("Blog", "category")
5952
+ (0, import_typeorm12.OneToMany)("Blog", "category")
5377
5953
  ], Category.prototype, "blogs", 2);
5378
5954
  Category = __decorateClass([
5379
- (0, import_typeorm11.Entity)("categories")
5955
+ (0, import_typeorm12.Entity)("categories")
5380
5956
  ], Category);
5381
5957
 
5382
5958
  // src/entities/seo.entity.ts
5383
- var import_typeorm12 = require("typeorm");
5959
+ var import_typeorm13 = require("typeorm");
5384
5960
  var Seo = class {
5385
5961
  id;
5386
5962
  title;
@@ -5400,59 +5976,59 @@ var Seo = class {
5400
5976
  blogs;
5401
5977
  };
5402
5978
  __decorateClass([
5403
- (0, import_typeorm12.PrimaryGeneratedColumn)()
5979
+ (0, import_typeorm13.PrimaryGeneratedColumn)()
5404
5980
  ], Seo.prototype, "id", 2);
5405
5981
  __decorateClass([
5406
- (0, import_typeorm12.Column)("varchar", { nullable: true })
5982
+ (0, import_typeorm13.Column)("varchar", { nullable: true })
5407
5983
  ], Seo.prototype, "title", 2);
5408
5984
  __decorateClass([
5409
- (0, import_typeorm12.Column)("varchar", { nullable: true })
5985
+ (0, import_typeorm13.Column)("varchar", { nullable: true })
5410
5986
  ], Seo.prototype, "description", 2);
5411
5987
  __decorateClass([
5412
- (0, import_typeorm12.Column)("varchar", { nullable: true })
5988
+ (0, import_typeorm13.Column)("varchar", { nullable: true })
5413
5989
  ], Seo.prototype, "keywords", 2);
5414
5990
  __decorateClass([
5415
- (0, import_typeorm12.Column)("varchar", { nullable: true })
5991
+ (0, import_typeorm13.Column)("varchar", { nullable: true })
5416
5992
  ], Seo.prototype, "ogTitle", 2);
5417
5993
  __decorateClass([
5418
- (0, import_typeorm12.Column)("varchar", { nullable: true })
5994
+ (0, import_typeorm13.Column)("varchar", { nullable: true })
5419
5995
  ], Seo.prototype, "ogDescription", 2);
5420
5996
  __decorateClass([
5421
- (0, import_typeorm12.Column)("varchar", { nullable: true })
5997
+ (0, import_typeorm13.Column)("varchar", { nullable: true })
5422
5998
  ], Seo.prototype, "ogImage", 2);
5423
5999
  __decorateClass([
5424
- (0, import_typeorm12.Column)("varchar", { unique: true })
6000
+ (0, import_typeorm13.Column)("varchar", { unique: true })
5425
6001
  ], Seo.prototype, "slug", 2);
5426
6002
  __decorateClass([
5427
- (0, import_typeorm12.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6003
+ (0, import_typeorm13.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5428
6004
  ], Seo.prototype, "createdAt", 2);
5429
6005
  __decorateClass([
5430
- (0, import_typeorm12.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6006
+ (0, import_typeorm13.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5431
6007
  ], Seo.prototype, "updatedAt", 2);
5432
6008
  __decorateClass([
5433
- (0, import_typeorm12.Column)({ type: "timestamp", nullable: true })
6009
+ (0, import_typeorm13.Column)({ type: "timestamp", nullable: true })
5434
6010
  ], Seo.prototype, "deletedAt", 2);
5435
6011
  __decorateClass([
5436
- (0, import_typeorm12.Column)("boolean", { default: false })
6012
+ (0, import_typeorm13.Column)("boolean", { default: false })
5437
6013
  ], Seo.prototype, "deleted", 2);
5438
6014
  __decorateClass([
5439
- (0, import_typeorm12.Column)("int", { nullable: true })
6015
+ (0, import_typeorm13.Column)("int", { nullable: true })
5440
6016
  ], Seo.prototype, "createdBy", 2);
5441
6017
  __decorateClass([
5442
- (0, import_typeorm12.Column)("int", { nullable: true })
6018
+ (0, import_typeorm13.Column)("int", { nullable: true })
5443
6019
  ], Seo.prototype, "updatedBy", 2);
5444
6020
  __decorateClass([
5445
- (0, import_typeorm12.Column)("int", { nullable: true })
6021
+ (0, import_typeorm13.Column)("int", { nullable: true })
5446
6022
  ], Seo.prototype, "deletedBy", 2);
5447
6023
  __decorateClass([
5448
- (0, import_typeorm12.OneToMany)(() => Blog, (blog) => blog.seo)
6024
+ (0, import_typeorm13.OneToMany)(() => Blog, (blog) => blog.seo)
5449
6025
  ], Seo.prototype, "blogs", 2);
5450
6026
  Seo = __decorateClass([
5451
- (0, import_typeorm12.Entity)("seos")
6027
+ (0, import_typeorm13.Entity)("seos")
5452
6028
  ], Seo);
5453
6029
 
5454
6030
  // src/entities/comment.entity.ts
5455
- var import_typeorm13 = require("typeorm");
6031
+ var import_typeorm14 = require("typeorm");
5456
6032
  var Comment = class {
5457
6033
  id;
5458
6034
  content;
@@ -5469,52 +6045,52 @@ var Comment = class {
5469
6045
  blog;
5470
6046
  };
5471
6047
  __decorateClass([
5472
- (0, import_typeorm13.PrimaryGeneratedColumn)()
6048
+ (0, import_typeorm14.PrimaryGeneratedColumn)()
5473
6049
  ], Comment.prototype, "id", 2);
5474
6050
  __decorateClass([
5475
- (0, import_typeorm13.Column)("text")
6051
+ (0, import_typeorm14.Column)("text")
5476
6052
  ], Comment.prototype, "content", 2);
5477
6053
  __decorateClass([
5478
- (0, import_typeorm13.Column)("int")
6054
+ (0, import_typeorm14.Column)("int")
5479
6055
  ], Comment.prototype, "blogId", 2);
5480
6056
  __decorateClass([
5481
- (0, import_typeorm13.Column)("int")
6057
+ (0, import_typeorm14.Column)("int")
5482
6058
  ], Comment.prototype, "authorId", 2);
5483
6059
  __decorateClass([
5484
- (0, import_typeorm13.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6060
+ (0, import_typeorm14.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5485
6061
  ], Comment.prototype, "createdAt", 2);
5486
6062
  __decorateClass([
5487
- (0, import_typeorm13.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6063
+ (0, import_typeorm14.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5488
6064
  ], Comment.prototype, "updatedAt", 2);
5489
6065
  __decorateClass([
5490
- (0, import_typeorm13.Column)({ type: "timestamp", nullable: true })
6066
+ (0, import_typeorm14.Column)({ type: "timestamp", nullable: true })
5491
6067
  ], Comment.prototype, "deletedAt", 2);
5492
6068
  __decorateClass([
5493
- (0, import_typeorm13.Column)("boolean", { default: false })
6069
+ (0, import_typeorm14.Column)("boolean", { default: false })
5494
6070
  ], Comment.prototype, "deleted", 2);
5495
6071
  __decorateClass([
5496
- (0, import_typeorm13.Column)("int", { nullable: true })
6072
+ (0, import_typeorm14.Column)("int", { nullable: true })
5497
6073
  ], Comment.prototype, "createdBy", 2);
5498
6074
  __decorateClass([
5499
- (0, import_typeorm13.Column)("int", { nullable: true })
6075
+ (0, import_typeorm14.Column)("int", { nullable: true })
5500
6076
  ], Comment.prototype, "updatedBy", 2);
5501
6077
  __decorateClass([
5502
- (0, import_typeorm13.Column)("int", { nullable: true })
6078
+ (0, import_typeorm14.Column)("int", { nullable: true })
5503
6079
  ], Comment.prototype, "deletedBy", 2);
5504
6080
  __decorateClass([
5505
- (0, import_typeorm13.ManyToOne)(() => User, { onDelete: "CASCADE" }),
5506
- (0, import_typeorm13.JoinColumn)({ name: "authorId" })
6081
+ (0, import_typeorm14.ManyToOne)(() => User, { onDelete: "CASCADE" }),
6082
+ (0, import_typeorm14.JoinColumn)({ name: "authorId" })
5507
6083
  ], Comment.prototype, "author", 2);
5508
6084
  __decorateClass([
5509
- (0, import_typeorm13.ManyToOne)(() => Blog, (b) => b.comments, { onDelete: "CASCADE" }),
5510
- (0, import_typeorm13.JoinColumn)({ name: "blogId" })
6085
+ (0, import_typeorm14.ManyToOne)(() => Blog, (b) => b.comments, { onDelete: "CASCADE" }),
6086
+ (0, import_typeorm14.JoinColumn)({ name: "blogId" })
5511
6087
  ], Comment.prototype, "blog", 2);
5512
6088
  Comment = __decorateClass([
5513
- (0, import_typeorm13.Entity)("comments")
6089
+ (0, import_typeorm14.Entity)("comments")
5514
6090
  ], Comment);
5515
6091
 
5516
6092
  // src/entities/tag.entity.ts
5517
- var import_typeorm14 = require("typeorm");
6093
+ var import_typeorm15 = require("typeorm");
5518
6094
  var Tag = class {
5519
6095
  id;
5520
6096
  name;
@@ -5528,37 +6104,37 @@ var Tag = class {
5528
6104
  blogs;
5529
6105
  };
5530
6106
  __decorateClass([
5531
- (0, import_typeorm14.PrimaryGeneratedColumn)()
6107
+ (0, import_typeorm15.PrimaryGeneratedColumn)()
5532
6108
  ], Tag.prototype, "id", 2);
5533
6109
  __decorateClass([
5534
- (0, import_typeorm14.Column)("varchar", { unique: true })
6110
+ (0, import_typeorm15.Column)("varchar", { unique: true })
5535
6111
  ], Tag.prototype, "name", 2);
5536
6112
  __decorateClass([
5537
- (0, import_typeorm14.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6113
+ (0, import_typeorm15.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5538
6114
  ], Tag.prototype, "createdAt", 2);
5539
6115
  __decorateClass([
5540
- (0, import_typeorm14.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6116
+ (0, import_typeorm15.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5541
6117
  ], Tag.prototype, "updatedAt", 2);
5542
6118
  __decorateClass([
5543
- (0, import_typeorm14.Column)({ type: "timestamp", nullable: true })
6119
+ (0, import_typeorm15.Column)({ type: "timestamp", nullable: true })
5544
6120
  ], Tag.prototype, "deletedAt", 2);
5545
6121
  __decorateClass([
5546
- (0, import_typeorm14.Column)("boolean", { default: false })
6122
+ (0, import_typeorm15.Column)("boolean", { default: false })
5547
6123
  ], Tag.prototype, "deleted", 2);
5548
6124
  __decorateClass([
5549
- (0, import_typeorm14.Column)("int", { nullable: true })
6125
+ (0, import_typeorm15.Column)("int", { nullable: true })
5550
6126
  ], Tag.prototype, "createdBy", 2);
5551
6127
  __decorateClass([
5552
- (0, import_typeorm14.Column)("int", { nullable: true })
6128
+ (0, import_typeorm15.Column)("int", { nullable: true })
5553
6129
  ], Tag.prototype, "updatedBy", 2);
5554
6130
  __decorateClass([
5555
- (0, import_typeorm14.Column)("int", { nullable: true })
6131
+ (0, import_typeorm15.Column)("int", { nullable: true })
5556
6132
  ], Tag.prototype, "deletedBy", 2);
5557
6133
  __decorateClass([
5558
- (0, import_typeorm14.ManyToMany)(() => Blog, (blog) => blog.tags)
6134
+ (0, import_typeorm15.ManyToMany)(() => Blog, (blog) => blog.tags)
5559
6135
  ], Tag.prototype, "blogs", 2);
5560
6136
  Tag = __decorateClass([
5561
- (0, import_typeorm14.Entity)("tags")
6137
+ (0, import_typeorm15.Entity)("tags")
5562
6138
  ], Tag);
5563
6139
 
5564
6140
  // src/entities/blog.entity.ts
@@ -5586,91 +6162,91 @@ var Blog = class {
5586
6162
  tags;
5587
6163
  };
5588
6164
  __decorateClass([
5589
- (0, import_typeorm15.PrimaryGeneratedColumn)()
6165
+ (0, import_typeorm16.PrimaryGeneratedColumn)()
5590
6166
  ], Blog.prototype, "id", 2);
5591
6167
  __decorateClass([
5592
- (0, import_typeorm15.Column)("varchar")
6168
+ (0, import_typeorm16.Column)("varchar")
5593
6169
  ], Blog.prototype, "title", 2);
5594
6170
  __decorateClass([
5595
- (0, import_typeorm15.Column)("text")
6171
+ (0, import_typeorm16.Column)("text")
5596
6172
  ], Blog.prototype, "content", 2);
5597
6173
  __decorateClass([
5598
- (0, import_typeorm15.Column)("varchar", { nullable: true })
6174
+ (0, import_typeorm16.Column)("varchar", { nullable: true })
5599
6175
  ], Blog.prototype, "coverImage", 2);
5600
6176
  __decorateClass([
5601
- (0, import_typeorm15.Column)("int")
6177
+ (0, import_typeorm16.Column)("int")
5602
6178
  ], Blog.prototype, "authorId", 2);
5603
6179
  __decorateClass([
5604
- (0, import_typeorm15.Column)("int", { nullable: true })
6180
+ (0, import_typeorm16.Column)("int", { nullable: true })
5605
6181
  ], Blog.prototype, "categoryId", 2);
5606
6182
  __decorateClass([
5607
- (0, import_typeorm15.Column)("int", { nullable: true })
6183
+ (0, import_typeorm16.Column)("int", { nullable: true })
5608
6184
  ], Blog.prototype, "seoId", 2);
5609
6185
  __decorateClass([
5610
- (0, import_typeorm15.Column)("boolean", { default: false })
6186
+ (0, import_typeorm16.Column)("boolean", { default: false })
5611
6187
  ], Blog.prototype, "published", 2);
5612
6188
  __decorateClass([
5613
- (0, import_typeorm15.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6189
+ (0, import_typeorm16.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5614
6190
  ], Blog.prototype, "createdAt", 2);
5615
6191
  __decorateClass([
5616
- (0, import_typeorm15.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6192
+ (0, import_typeorm16.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5617
6193
  ], Blog.prototype, "updatedAt", 2);
5618
6194
  __decorateClass([
5619
- (0, import_typeorm15.Column)({ type: "timestamp", nullable: true })
6195
+ (0, import_typeorm16.Column)({ type: "timestamp", nullable: true })
5620
6196
  ], Blog.prototype, "deletedAt", 2);
5621
6197
  __decorateClass([
5622
- (0, import_typeorm15.Column)("boolean", { default: false })
6198
+ (0, import_typeorm16.Column)("boolean", { default: false })
5623
6199
  ], Blog.prototype, "deleted", 2);
5624
6200
  __decorateClass([
5625
- (0, import_typeorm15.Column)("int", { nullable: true })
6201
+ (0, import_typeorm16.Column)("int", { nullable: true })
5626
6202
  ], Blog.prototype, "createdBy", 2);
5627
6203
  __decorateClass([
5628
- (0, import_typeorm15.Column)("int", { nullable: true })
6204
+ (0, import_typeorm16.Column)("int", { nullable: true })
5629
6205
  ], Blog.prototype, "updatedBy", 2);
5630
6206
  __decorateClass([
5631
- (0, import_typeorm15.Column)("int", { nullable: true })
6207
+ (0, import_typeorm16.Column)("int", { nullable: true })
5632
6208
  ], Blog.prototype, "deletedBy", 2);
5633
6209
  __decorateClass([
5634
- (0, import_typeorm15.Column)("varchar", { unique: true })
6210
+ (0, import_typeorm16.Column)("varchar", { unique: true })
5635
6211
  ], Blog.prototype, "slug", 2);
5636
6212
  __decorateClass([
5637
- (0, import_typeorm15.ManyToOne)(() => User, { onDelete: "CASCADE" }),
5638
- (0, import_typeorm15.JoinColumn)({ name: "authorId" })
6213
+ (0, import_typeorm16.ManyToOne)(() => User, { onDelete: "CASCADE" }),
6214
+ (0, import_typeorm16.JoinColumn)({ name: "authorId" })
5639
6215
  ], Blog.prototype, "author", 2);
5640
6216
  __decorateClass([
5641
- (0, import_typeorm15.ManyToOne)(() => Category, (c) => c.blogs, { onDelete: "SET NULL" }),
5642
- (0, import_typeorm15.JoinColumn)({ name: "categoryId" })
6217
+ (0, import_typeorm16.ManyToOne)(() => Category, (c) => c.blogs, { onDelete: "SET NULL" }),
6218
+ (0, import_typeorm16.JoinColumn)({ name: "categoryId" })
5643
6219
  ], Blog.prototype, "category", 2);
5644
6220
  __decorateClass([
5645
- (0, import_typeorm15.ManyToOne)(() => Seo, (s) => s.blogs, { onDelete: "SET NULL" }),
5646
- (0, import_typeorm15.JoinColumn)({ name: "seoId" })
6221
+ (0, import_typeorm16.ManyToOne)(() => Seo, (s) => s.blogs, { onDelete: "SET NULL" }),
6222
+ (0, import_typeorm16.JoinColumn)({ name: "seoId" })
5647
6223
  ], Blog.prototype, "seo", 2);
5648
6224
  __decorateClass([
5649
- (0, import_typeorm15.OneToMany)(() => Comment, (c) => c.blog)
6225
+ (0, import_typeorm16.OneToMany)(() => Comment, (c) => c.blog)
5650
6226
  ], Blog.prototype, "comments", 2);
5651
6227
  __decorateClass([
5652
- (0, import_typeorm15.ManyToMany)(() => Tag, (t) => t.blogs),
5653
- (0, import_typeorm15.JoinTable)({
6228
+ (0, import_typeorm16.ManyToMany)(() => Tag, (t) => t.blogs),
6229
+ (0, import_typeorm16.JoinTable)({
5654
6230
  name: "blog_tags",
5655
6231
  joinColumn: { name: "blogId", referencedColumnName: "id" },
5656
6232
  inverseJoinColumn: { name: "tagId", referencedColumnName: "id" }
5657
6233
  })
5658
6234
  ], Blog.prototype, "tags", 2);
5659
6235
  Blog = __decorateClass([
5660
- (0, import_typeorm15.Entity)("blogs")
6236
+ (0, import_typeorm16.Entity)("blogs")
5661
6237
  ], Blog);
5662
6238
 
5663
6239
  // src/entities/contact.entity.ts
5664
- var import_typeorm24 = require("typeorm");
6240
+ var import_typeorm25 = require("typeorm");
5665
6241
 
5666
6242
  // src/entities/form-submission.entity.ts
5667
- var import_typeorm18 = require("typeorm");
6243
+ var import_typeorm19 = require("typeorm");
5668
6244
 
5669
6245
  // src/entities/form.entity.ts
5670
- var import_typeorm17 = require("typeorm");
6246
+ var import_typeorm18 = require("typeorm");
5671
6247
 
5672
6248
  // src/entities/form-field.entity.ts
5673
- var import_typeorm16 = require("typeorm");
6249
+ var import_typeorm17 = require("typeorm");
5674
6250
  var FormField = class {
5675
6251
  id;
5676
6252
  formId;
@@ -5693,65 +6269,65 @@ var FormField = class {
5693
6269
  form;
5694
6270
  };
5695
6271
  __decorateClass([
5696
- (0, import_typeorm16.PrimaryGeneratedColumn)()
6272
+ (0, import_typeorm17.PrimaryGeneratedColumn)()
5697
6273
  ], FormField.prototype, "id", 2);
5698
6274
  __decorateClass([
5699
- (0, import_typeorm16.Column)("int")
6275
+ (0, import_typeorm17.Column)("int")
5700
6276
  ], FormField.prototype, "formId", 2);
5701
6277
  __decorateClass([
5702
- (0, import_typeorm16.Column)("varchar")
6278
+ (0, import_typeorm17.Column)("varchar")
5703
6279
  ], FormField.prototype, "label", 2);
5704
6280
  __decorateClass([
5705
- (0, import_typeorm16.Column)("varchar")
6281
+ (0, import_typeorm17.Column)("varchar")
5706
6282
  ], FormField.prototype, "type", 2);
5707
6283
  __decorateClass([
5708
- (0, import_typeorm16.Column)("varchar", { nullable: true })
6284
+ (0, import_typeorm17.Column)("varchar", { nullable: true })
5709
6285
  ], FormField.prototype, "placeholder", 2);
5710
6286
  __decorateClass([
5711
- (0, import_typeorm16.Column)("varchar", { nullable: true })
6287
+ (0, import_typeorm17.Column)("varchar", { nullable: true })
5712
6288
  ], FormField.prototype, "options", 2);
5713
6289
  __decorateClass([
5714
- (0, import_typeorm16.Column)("boolean", { default: false })
6290
+ (0, import_typeorm17.Column)("boolean", { default: false })
5715
6291
  ], FormField.prototype, "required", 2);
5716
6292
  __decorateClass([
5717
- (0, import_typeorm16.Column)("varchar", { nullable: true })
6293
+ (0, import_typeorm17.Column)("varchar", { nullable: true })
5718
6294
  ], FormField.prototype, "validation", 2);
5719
6295
  __decorateClass([
5720
- (0, import_typeorm16.Column)("int")
6296
+ (0, import_typeorm17.Column)("int")
5721
6297
  ], FormField.prototype, "order", 2);
5722
6298
  __decorateClass([
5723
- (0, import_typeorm16.Column)("int", { default: 1 })
6299
+ (0, import_typeorm17.Column)("int", { default: 1 })
5724
6300
  ], FormField.prototype, "groupId", 2);
5725
6301
  __decorateClass([
5726
- (0, import_typeorm16.Column)("int", { default: 12 })
6302
+ (0, import_typeorm17.Column)("int", { default: 12 })
5727
6303
  ], FormField.prototype, "columnWidth", 2);
5728
6304
  __decorateClass([
5729
- (0, import_typeorm16.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6305
+ (0, import_typeorm17.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5730
6306
  ], FormField.prototype, "createdAt", 2);
5731
6307
  __decorateClass([
5732
- (0, import_typeorm16.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6308
+ (0, import_typeorm17.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5733
6309
  ], FormField.prototype, "updatedAt", 2);
5734
6310
  __decorateClass([
5735
- (0, import_typeorm16.Column)({ type: "timestamp", nullable: true })
6311
+ (0, import_typeorm17.Column)({ type: "timestamp", nullable: true })
5736
6312
  ], FormField.prototype, "deletedAt", 2);
5737
6313
  __decorateClass([
5738
- (0, import_typeorm16.Column)("boolean", { default: false })
6314
+ (0, import_typeorm17.Column)("boolean", { default: false })
5739
6315
  ], FormField.prototype, "deleted", 2);
5740
6316
  __decorateClass([
5741
- (0, import_typeorm16.Column)("int", { nullable: true })
6317
+ (0, import_typeorm17.Column)("int", { nullable: true })
5742
6318
  ], FormField.prototype, "createdBy", 2);
5743
6319
  __decorateClass([
5744
- (0, import_typeorm16.Column)("int", { nullable: true })
6320
+ (0, import_typeorm17.Column)("int", { nullable: true })
5745
6321
  ], FormField.prototype, "updatedBy", 2);
5746
6322
  __decorateClass([
5747
- (0, import_typeorm16.Column)("int", { nullable: true })
6323
+ (0, import_typeorm17.Column)("int", { nullable: true })
5748
6324
  ], FormField.prototype, "deletedBy", 2);
5749
6325
  __decorateClass([
5750
- (0, import_typeorm16.ManyToOne)(() => Form, (f) => f.fields, { onDelete: "CASCADE" }),
5751
- (0, import_typeorm16.JoinColumn)({ name: "formId" })
6326
+ (0, import_typeorm17.ManyToOne)(() => Form, (f) => f.fields, { onDelete: "CASCADE" }),
6327
+ (0, import_typeorm17.JoinColumn)({ name: "formId" })
5752
6328
  ], FormField.prototype, "form", 2);
5753
6329
  FormField = __decorateClass([
5754
- (0, import_typeorm16.Entity)("form_fields")
6330
+ (0, import_typeorm17.Entity)("form_fields")
5755
6331
  ], FormField);
5756
6332
 
5757
6333
  // src/entities/form.entity.ts
@@ -5773,52 +6349,52 @@ var Form = class {
5773
6349
  submissions;
5774
6350
  };
5775
6351
  __decorateClass([
5776
- (0, import_typeorm17.PrimaryGeneratedColumn)()
6352
+ (0, import_typeorm18.PrimaryGeneratedColumn)()
5777
6353
  ], Form.prototype, "id", 2);
5778
6354
  __decorateClass([
5779
- (0, import_typeorm17.Column)("varchar")
6355
+ (0, import_typeorm18.Column)("varchar")
5780
6356
  ], Form.prototype, "name", 2);
5781
6357
  __decorateClass([
5782
- (0, import_typeorm17.Column)("text", { nullable: true })
6358
+ (0, import_typeorm18.Column)("text", { nullable: true })
5783
6359
  ], Form.prototype, "description", 2);
5784
6360
  __decorateClass([
5785
- (0, import_typeorm17.Column)("varchar", { nullable: true })
6361
+ (0, import_typeorm18.Column)("varchar", { nullable: true })
5786
6362
  ], Form.prototype, "campaign", 2);
5787
6363
  __decorateClass([
5788
- (0, import_typeorm17.Column)("varchar", { unique: true })
6364
+ (0, import_typeorm18.Column)("varchar", { unique: true })
5789
6365
  ], Form.prototype, "slug", 2);
5790
6366
  __decorateClass([
5791
- (0, import_typeorm17.Column)("boolean", { default: false })
6367
+ (0, import_typeorm18.Column)("boolean", { default: false })
5792
6368
  ], Form.prototype, "published", 2);
5793
6369
  __decorateClass([
5794
- (0, import_typeorm17.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6370
+ (0, import_typeorm18.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5795
6371
  ], Form.prototype, "createdAt", 2);
5796
6372
  __decorateClass([
5797
- (0, import_typeorm17.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6373
+ (0, import_typeorm18.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5798
6374
  ], Form.prototype, "updatedAt", 2);
5799
6375
  __decorateClass([
5800
- (0, import_typeorm17.Column)({ type: "timestamp", nullable: true })
6376
+ (0, import_typeorm18.Column)({ type: "timestamp", nullable: true })
5801
6377
  ], Form.prototype, "deletedAt", 2);
5802
6378
  __decorateClass([
5803
- (0, import_typeorm17.Column)("boolean", { default: false })
6379
+ (0, import_typeorm18.Column)("boolean", { default: false })
5804
6380
  ], Form.prototype, "deleted", 2);
5805
6381
  __decorateClass([
5806
- (0, import_typeorm17.Column)("int", { nullable: true })
6382
+ (0, import_typeorm18.Column)("int", { nullable: true })
5807
6383
  ], Form.prototype, "createdBy", 2);
5808
6384
  __decorateClass([
5809
- (0, import_typeorm17.Column)("int", { nullable: true })
6385
+ (0, import_typeorm18.Column)("int", { nullable: true })
5810
6386
  ], Form.prototype, "updatedBy", 2);
5811
6387
  __decorateClass([
5812
- (0, import_typeorm17.Column)("int", { nullable: true })
6388
+ (0, import_typeorm18.Column)("int", { nullable: true })
5813
6389
  ], Form.prototype, "deletedBy", 2);
5814
6390
  __decorateClass([
5815
- (0, import_typeorm17.OneToMany)(() => FormField, (f) => f.form)
6391
+ (0, import_typeorm18.OneToMany)(() => FormField, (f) => f.form)
5816
6392
  ], Form.prototype, "fields", 2);
5817
6393
  __decorateClass([
5818
- (0, import_typeorm17.OneToMany)(() => FormSubmission, (s) => s.form)
6394
+ (0, import_typeorm18.OneToMany)(() => FormSubmission, (s) => s.form)
5819
6395
  ], Form.prototype, "submissions", 2);
5820
6396
  Form = __decorateClass([
5821
- (0, import_typeorm17.Entity)("forms")
6397
+ (0, import_typeorm18.Entity)("forms")
5822
6398
  ], Form);
5823
6399
 
5824
6400
  // src/entities/form-submission.entity.ts
@@ -5835,43 +6411,43 @@ var FormSubmission = class {
5835
6411
  contact;
5836
6412
  };
5837
6413
  __decorateClass([
5838
- (0, import_typeorm18.PrimaryGeneratedColumn)()
6414
+ (0, import_typeorm19.PrimaryGeneratedColumn)()
5839
6415
  ], FormSubmission.prototype, "id", 2);
5840
6416
  __decorateClass([
5841
- (0, import_typeorm18.Column)("int")
6417
+ (0, import_typeorm19.Column)("int")
5842
6418
  ], FormSubmission.prototype, "formId", 2);
5843
6419
  __decorateClass([
5844
- (0, import_typeorm18.Column)("int", { nullable: true })
6420
+ (0, import_typeorm19.Column)("int", { nullable: true })
5845
6421
  ], FormSubmission.prototype, "contactId", 2);
5846
6422
  __decorateClass([
5847
- (0, import_typeorm18.Column)("jsonb")
6423
+ (0, import_typeorm19.Column)("jsonb")
5848
6424
  ], FormSubmission.prototype, "data", 2);
5849
6425
  __decorateClass([
5850
- (0, import_typeorm18.Column)("varchar", { nullable: true })
6426
+ (0, import_typeorm19.Column)("varchar", { nullable: true })
5851
6427
  ], FormSubmission.prototype, "ipAddress", 2);
5852
6428
  __decorateClass([
5853
- (0, import_typeorm18.Column)("varchar", { nullable: true })
6429
+ (0, import_typeorm19.Column)("varchar", { nullable: true })
5854
6430
  ], FormSubmission.prototype, "userAgent", 2);
5855
6431
  __decorateClass([
5856
- (0, import_typeorm18.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6432
+ (0, import_typeorm19.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5857
6433
  ], FormSubmission.prototype, "createdAt", 2);
5858
6434
  __decorateClass([
5859
- (0, import_typeorm18.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6435
+ (0, import_typeorm19.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5860
6436
  ], FormSubmission.prototype, "updatedAt", 2);
5861
6437
  __decorateClass([
5862
- (0, import_typeorm18.ManyToOne)(() => Form, (f) => f.submissions, { onDelete: "CASCADE" }),
5863
- (0, import_typeorm18.JoinColumn)({ name: "formId" })
6438
+ (0, import_typeorm19.ManyToOne)(() => Form, (f) => f.submissions, { onDelete: "CASCADE" }),
6439
+ (0, import_typeorm19.JoinColumn)({ name: "formId" })
5864
6440
  ], FormSubmission.prototype, "form", 2);
5865
6441
  __decorateClass([
5866
- (0, import_typeorm18.ManyToOne)(() => Contact, (c) => c.form_submissions, { onDelete: "SET NULL" }),
5867
- (0, import_typeorm18.JoinColumn)({ name: "contactId" })
6442
+ (0, import_typeorm19.ManyToOne)(() => Contact, (c) => c.form_submissions, { onDelete: "SET NULL" }),
6443
+ (0, import_typeorm19.JoinColumn)({ name: "contactId" })
5868
6444
  ], FormSubmission.prototype, "contact", 2);
5869
6445
  FormSubmission = __decorateClass([
5870
- (0, import_typeorm18.Entity)("form_submissions")
6446
+ (0, import_typeorm19.Entity)("form_submissions")
5871
6447
  ], FormSubmission);
5872
6448
 
5873
6449
  // src/entities/address.entity.ts
5874
- var import_typeorm19 = require("typeorm");
6450
+ var import_typeorm20 = require("typeorm");
5875
6451
  var Address = class {
5876
6452
  id;
5877
6453
  contactId;
@@ -5887,48 +6463,48 @@ var Address = class {
5887
6463
  contact;
5888
6464
  };
5889
6465
  __decorateClass([
5890
- (0, import_typeorm19.PrimaryGeneratedColumn)()
6466
+ (0, import_typeorm20.PrimaryGeneratedColumn)()
5891
6467
  ], Address.prototype, "id", 2);
5892
6468
  __decorateClass([
5893
- (0, import_typeorm19.Column)("int")
6469
+ (0, import_typeorm20.Column)("int")
5894
6470
  ], Address.prototype, "contactId", 2);
5895
6471
  __decorateClass([
5896
- (0, import_typeorm19.Column)("varchar", { nullable: true })
6472
+ (0, import_typeorm20.Column)("varchar", { nullable: true })
5897
6473
  ], Address.prototype, "tag", 2);
5898
6474
  __decorateClass([
5899
- (0, import_typeorm19.Column)("varchar", { nullable: true })
6475
+ (0, import_typeorm20.Column)("varchar", { nullable: true })
5900
6476
  ], Address.prototype, "line1", 2);
5901
6477
  __decorateClass([
5902
- (0, import_typeorm19.Column)("varchar", { nullable: true })
6478
+ (0, import_typeorm20.Column)("varchar", { nullable: true })
5903
6479
  ], Address.prototype, "line2", 2);
5904
6480
  __decorateClass([
5905
- (0, import_typeorm19.Column)("varchar", { nullable: true })
6481
+ (0, import_typeorm20.Column)("varchar", { nullable: true })
5906
6482
  ], Address.prototype, "city", 2);
5907
6483
  __decorateClass([
5908
- (0, import_typeorm19.Column)("varchar", { nullable: true })
6484
+ (0, import_typeorm20.Column)("varchar", { nullable: true })
5909
6485
  ], Address.prototype, "state", 2);
5910
6486
  __decorateClass([
5911
- (0, import_typeorm19.Column)("varchar", { nullable: true })
6487
+ (0, import_typeorm20.Column)("varchar", { nullable: true })
5912
6488
  ], Address.prototype, "postalCode", 2);
5913
6489
  __decorateClass([
5914
- (0, import_typeorm19.Column)("varchar", { nullable: true })
6490
+ (0, import_typeorm20.Column)("varchar", { nullable: true })
5915
6491
  ], Address.prototype, "country", 2);
5916
6492
  __decorateClass([
5917
- (0, import_typeorm19.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6493
+ (0, import_typeorm20.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5918
6494
  ], Address.prototype, "createdAt", 2);
5919
6495
  __decorateClass([
5920
- (0, import_typeorm19.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6496
+ (0, import_typeorm20.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5921
6497
  ], Address.prototype, "updatedAt", 2);
5922
6498
  __decorateClass([
5923
- (0, import_typeorm19.ManyToOne)(() => Contact, (c) => c.addresses, { onDelete: "CASCADE" }),
5924
- (0, import_typeorm19.JoinColumn)({ name: "contactId" })
6499
+ (0, import_typeorm20.ManyToOne)(() => Contact, (c) => c.addresses, { onDelete: "CASCADE" }),
6500
+ (0, import_typeorm20.JoinColumn)({ name: "contactId" })
5925
6501
  ], Address.prototype, "contact", 2);
5926
6502
  Address = __decorateClass([
5927
- (0, import_typeorm19.Entity)("addresses")
6503
+ (0, import_typeorm20.Entity)("addresses")
5928
6504
  ], Address);
5929
6505
 
5930
6506
  // src/entities/order.entity.ts
5931
- var import_typeorm20 = require("typeorm");
6507
+ var import_typeorm21 = require("typeorm");
5932
6508
  var Order = class {
5933
6509
  id;
5934
6510
  orderNumber;
@@ -5960,99 +6536,99 @@ var Order = class {
5960
6536
  payments;
5961
6537
  };
5962
6538
  __decorateClass([
5963
- (0, import_typeorm20.PrimaryGeneratedColumn)()
6539
+ (0, import_typeorm21.PrimaryGeneratedColumn)()
5964
6540
  ], Order.prototype, "id", 2);
5965
6541
  __decorateClass([
5966
- (0, import_typeorm20.Column)("varchar", { unique: true })
6542
+ (0, import_typeorm21.Column)("varchar", { unique: true })
5967
6543
  ], Order.prototype, "orderNumber", 2);
5968
6544
  __decorateClass([
5969
- (0, import_typeorm20.Column)("varchar", { default: "sale" })
6545
+ (0, import_typeorm21.Column)("varchar", { default: "sale" })
5970
6546
  ], Order.prototype, "orderKind", 2);
5971
6547
  __decorateClass([
5972
- (0, import_typeorm20.Column)("int", { nullable: true })
6548
+ (0, import_typeorm21.Column)("int", { nullable: true })
5973
6549
  ], Order.prototype, "parentOrderId", 2);
5974
6550
  __decorateClass([
5975
- (0, import_typeorm20.Column)("int")
6551
+ (0, import_typeorm21.Column)("int")
5976
6552
  ], Order.prototype, "contactId", 2);
5977
6553
  __decorateClass([
5978
- (0, import_typeorm20.Column)("int", { nullable: true })
6554
+ (0, import_typeorm21.Column)("int", { nullable: true })
5979
6555
  ], Order.prototype, "billingAddressId", 2);
5980
6556
  __decorateClass([
5981
- (0, import_typeorm20.Column)("int", { nullable: true })
6557
+ (0, import_typeorm21.Column)("int", { nullable: true })
5982
6558
  ], Order.prototype, "shippingAddressId", 2);
5983
6559
  __decorateClass([
5984
- (0, import_typeorm20.Column)("varchar", { default: "pending" })
6560
+ (0, import_typeorm21.Column)("varchar", { default: "pending" })
5985
6561
  ], Order.prototype, "status", 2);
5986
6562
  __decorateClass([
5987
- (0, import_typeorm20.Column)("decimal", { precision: 12, scale: 2, default: 0 })
6563
+ (0, import_typeorm21.Column)("decimal", { precision: 12, scale: 2, default: 0 })
5988
6564
  ], Order.prototype, "subtotal", 2);
5989
6565
  __decorateClass([
5990
- (0, import_typeorm20.Column)("decimal", { precision: 12, scale: 2, default: 0 })
6566
+ (0, import_typeorm21.Column)("decimal", { precision: 12, scale: 2, default: 0 })
5991
6567
  ], Order.prototype, "tax", 2);
5992
6568
  __decorateClass([
5993
- (0, import_typeorm20.Column)("decimal", { precision: 12, scale: 2, default: 0 })
6569
+ (0, import_typeorm21.Column)("decimal", { precision: 12, scale: 2, default: 0 })
5994
6570
  ], Order.prototype, "discount", 2);
5995
6571
  __decorateClass([
5996
- (0, import_typeorm20.Column)("decimal", { precision: 12, scale: 2, default: 0 })
6572
+ (0, import_typeorm21.Column)("decimal", { precision: 12, scale: 2, default: 0 })
5997
6573
  ], Order.prototype, "total", 2);
5998
6574
  __decorateClass([
5999
- (0, import_typeorm20.Column)("varchar", { default: "INR" })
6575
+ (0, import_typeorm21.Column)("varchar", { default: "INR" })
6000
6576
  ], Order.prototype, "currency", 2);
6001
6577
  __decorateClass([
6002
- (0, import_typeorm20.Column)("jsonb", { nullable: true })
6578
+ (0, import_typeorm21.Column)("jsonb", { nullable: true })
6003
6579
  ], Order.prototype, "metadata", 2);
6004
6580
  __decorateClass([
6005
- (0, import_typeorm20.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6581
+ (0, import_typeorm21.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6006
6582
  ], Order.prototype, "createdAt", 2);
6007
6583
  __decorateClass([
6008
- (0, import_typeorm20.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6584
+ (0, import_typeorm21.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6009
6585
  ], Order.prototype, "updatedAt", 2);
6010
6586
  __decorateClass([
6011
- (0, import_typeorm20.Column)({ type: "timestamp", nullable: true })
6587
+ (0, import_typeorm21.Column)({ type: "timestamp", nullable: true })
6012
6588
  ], Order.prototype, "deletedAt", 2);
6013
6589
  __decorateClass([
6014
- (0, import_typeorm20.Column)("boolean", { default: false })
6590
+ (0, import_typeorm21.Column)("boolean", { default: false })
6015
6591
  ], Order.prototype, "deleted", 2);
6016
6592
  __decorateClass([
6017
- (0, import_typeorm20.Column)("int", { nullable: true })
6593
+ (0, import_typeorm21.Column)("int", { nullable: true })
6018
6594
  ], Order.prototype, "createdBy", 2);
6019
6595
  __decorateClass([
6020
- (0, import_typeorm20.Column)("int", { nullable: true })
6596
+ (0, import_typeorm21.Column)("int", { nullable: true })
6021
6597
  ], Order.prototype, "updatedBy", 2);
6022
6598
  __decorateClass([
6023
- (0, import_typeorm20.Column)("int", { nullable: true })
6599
+ (0, import_typeorm21.Column)("int", { nullable: true })
6024
6600
  ], Order.prototype, "deletedBy", 2);
6025
6601
  __decorateClass([
6026
- (0, import_typeorm20.ManyToOne)(() => Order, (o) => o.children, { nullable: true, onDelete: "SET NULL" }),
6027
- (0, import_typeorm20.JoinColumn)({ name: "parentOrderId" })
6602
+ (0, import_typeorm21.ManyToOne)(() => Order, (o) => o.children, { nullable: true, onDelete: "SET NULL" }),
6603
+ (0, import_typeorm21.JoinColumn)({ name: "parentOrderId" })
6028
6604
  ], Order.prototype, "parentOrder", 2);
6029
6605
  __decorateClass([
6030
- (0, import_typeorm20.OneToMany)(() => Order, (o) => o.parentOrder)
6606
+ (0, import_typeorm21.OneToMany)(() => Order, (o) => o.parentOrder)
6031
6607
  ], Order.prototype, "children", 2);
6032
6608
  __decorateClass([
6033
- (0, import_typeorm20.ManyToOne)(() => Contact, { onDelete: "CASCADE" }),
6034
- (0, import_typeorm20.JoinColumn)({ name: "contactId" })
6609
+ (0, import_typeorm21.ManyToOne)(() => Contact, { onDelete: "CASCADE" }),
6610
+ (0, import_typeorm21.JoinColumn)({ name: "contactId" })
6035
6611
  ], Order.prototype, "contact", 2);
6036
6612
  __decorateClass([
6037
- (0, import_typeorm20.ManyToOne)(() => Address, { onDelete: "SET NULL" }),
6038
- (0, import_typeorm20.JoinColumn)({ name: "billingAddressId" })
6613
+ (0, import_typeorm21.ManyToOne)(() => Address, { onDelete: "SET NULL" }),
6614
+ (0, import_typeorm21.JoinColumn)({ name: "billingAddressId" })
6039
6615
  ], Order.prototype, "billingAddress", 2);
6040
6616
  __decorateClass([
6041
- (0, import_typeorm20.ManyToOne)(() => Address, { onDelete: "SET NULL" }),
6042
- (0, import_typeorm20.JoinColumn)({ name: "shippingAddressId" })
6617
+ (0, import_typeorm21.ManyToOne)(() => Address, { onDelete: "SET NULL" }),
6618
+ (0, import_typeorm21.JoinColumn)({ name: "shippingAddressId" })
6043
6619
  ], Order.prototype, "shippingAddress", 2);
6044
6620
  __decorateClass([
6045
- (0, import_typeorm20.OneToMany)("OrderItem", "order")
6621
+ (0, import_typeorm21.OneToMany)("OrderItem", "order")
6046
6622
  ], Order.prototype, "items", 2);
6047
6623
  __decorateClass([
6048
- (0, import_typeorm20.OneToMany)("Payment", "order")
6624
+ (0, import_typeorm21.OneToMany)("Payment", "order")
6049
6625
  ], Order.prototype, "payments", 2);
6050
6626
  Order = __decorateClass([
6051
- (0, import_typeorm20.Entity)("orders")
6627
+ (0, import_typeorm21.Entity)("orders")
6052
6628
  ], Order);
6053
6629
 
6054
6630
  // src/entities/payment.entity.ts
6055
- var import_typeorm21 = require("typeorm");
6631
+ var import_typeorm22 = require("typeorm");
6056
6632
  var Payment = class {
6057
6633
  id;
6058
6634
  orderId;
@@ -6075,73 +6651,73 @@ var Payment = class {
6075
6651
  contact;
6076
6652
  };
6077
6653
  __decorateClass([
6078
- (0, import_typeorm21.PrimaryGeneratedColumn)()
6654
+ (0, import_typeorm22.PrimaryGeneratedColumn)()
6079
6655
  ], Payment.prototype, "id", 2);
6080
6656
  __decorateClass([
6081
- (0, import_typeorm21.Column)("int")
6657
+ (0, import_typeorm22.Column)("int")
6082
6658
  ], Payment.prototype, "orderId", 2);
6083
6659
  __decorateClass([
6084
- (0, import_typeorm21.Column)("int", { nullable: true })
6660
+ (0, import_typeorm22.Column)("int", { nullable: true })
6085
6661
  ], Payment.prototype, "contactId", 2);
6086
6662
  __decorateClass([
6087
- (0, import_typeorm21.Column)("decimal", { precision: 12, scale: 2 })
6663
+ (0, import_typeorm22.Column)("decimal", { precision: 12, scale: 2 })
6088
6664
  ], Payment.prototype, "amount", 2);
6089
6665
  __decorateClass([
6090
- (0, import_typeorm21.Column)("varchar", { default: "INR" })
6666
+ (0, import_typeorm22.Column)("varchar", { default: "INR" })
6091
6667
  ], Payment.prototype, "currency", 2);
6092
6668
  __decorateClass([
6093
- (0, import_typeorm21.Column)("varchar", { default: "pending" })
6669
+ (0, import_typeorm22.Column)("varchar", { default: "pending" })
6094
6670
  ], Payment.prototype, "status", 2);
6095
6671
  __decorateClass([
6096
- (0, import_typeorm21.Column)("varchar", { nullable: true })
6672
+ (0, import_typeorm22.Column)("varchar", { nullable: true })
6097
6673
  ], Payment.prototype, "method", 2);
6098
6674
  __decorateClass([
6099
- (0, import_typeorm21.Column)("varchar", { nullable: true })
6675
+ (0, import_typeorm22.Column)("varchar", { nullable: true })
6100
6676
  ], Payment.prototype, "externalReference", 2);
6101
6677
  __decorateClass([
6102
- (0, import_typeorm21.Column)("jsonb", { nullable: true })
6678
+ (0, import_typeorm22.Column)("jsonb", { nullable: true })
6103
6679
  ], Payment.prototype, "metadata", 2);
6104
6680
  __decorateClass([
6105
- (0, import_typeorm21.Column)({ type: "timestamp", nullable: true })
6681
+ (0, import_typeorm22.Column)({ type: "timestamp", nullable: true })
6106
6682
  ], Payment.prototype, "paidAt", 2);
6107
6683
  __decorateClass([
6108
- (0, import_typeorm21.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6684
+ (0, import_typeorm22.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6109
6685
  ], Payment.prototype, "createdAt", 2);
6110
6686
  __decorateClass([
6111
- (0, import_typeorm21.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6687
+ (0, import_typeorm22.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6112
6688
  ], Payment.prototype, "updatedAt", 2);
6113
6689
  __decorateClass([
6114
- (0, import_typeorm21.Column)({ type: "timestamp", nullable: true })
6690
+ (0, import_typeorm22.Column)({ type: "timestamp", nullable: true })
6115
6691
  ], Payment.prototype, "deletedAt", 2);
6116
6692
  __decorateClass([
6117
- (0, import_typeorm21.Column)("boolean", { default: false })
6693
+ (0, import_typeorm22.Column)("boolean", { default: false })
6118
6694
  ], Payment.prototype, "deleted", 2);
6119
6695
  __decorateClass([
6120
- (0, import_typeorm21.Column)("int", { nullable: true })
6696
+ (0, import_typeorm22.Column)("int", { nullable: true })
6121
6697
  ], Payment.prototype, "createdBy", 2);
6122
6698
  __decorateClass([
6123
- (0, import_typeorm21.Column)("int", { nullable: true })
6699
+ (0, import_typeorm22.Column)("int", { nullable: true })
6124
6700
  ], Payment.prototype, "updatedBy", 2);
6125
6701
  __decorateClass([
6126
- (0, import_typeorm21.Column)("int", { nullable: true })
6702
+ (0, import_typeorm22.Column)("int", { nullable: true })
6127
6703
  ], Payment.prototype, "deletedBy", 2);
6128
6704
  __decorateClass([
6129
- (0, import_typeorm21.ManyToOne)(() => Order, (o) => o.payments, { onDelete: "CASCADE" }),
6130
- (0, import_typeorm21.JoinColumn)({ name: "orderId" })
6705
+ (0, import_typeorm22.ManyToOne)(() => Order, (o) => o.payments, { onDelete: "CASCADE" }),
6706
+ (0, import_typeorm22.JoinColumn)({ name: "orderId" })
6131
6707
  ], Payment.prototype, "order", 2);
6132
6708
  __decorateClass([
6133
- (0, import_typeorm21.ManyToOne)(() => Contact, { onDelete: "SET NULL" }),
6134
- (0, import_typeorm21.JoinColumn)({ name: "contactId" })
6709
+ (0, import_typeorm22.ManyToOne)(() => Contact, { onDelete: "SET NULL" }),
6710
+ (0, import_typeorm22.JoinColumn)({ name: "contactId" })
6135
6711
  ], Payment.prototype, "contact", 2);
6136
6712
  Payment = __decorateClass([
6137
- (0, import_typeorm21.Entity)("payments")
6713
+ (0, import_typeorm22.Entity)("payments")
6138
6714
  ], Payment);
6139
6715
 
6140
6716
  // src/entities/chat-conversation.entity.ts
6141
- var import_typeorm23 = require("typeorm");
6717
+ var import_typeorm24 = require("typeorm");
6142
6718
 
6143
6719
  // src/entities/chat-message.entity.ts
6144
- var import_typeorm22 = require("typeorm");
6720
+ var import_typeorm23 = require("typeorm");
6145
6721
  var ChatMessage = class {
6146
6722
  id;
6147
6723
  conversationId;
@@ -6151,26 +6727,26 @@ var ChatMessage = class {
6151
6727
  conversation;
6152
6728
  };
6153
6729
  __decorateClass([
6154
- (0, import_typeorm22.PrimaryGeneratedColumn)()
6730
+ (0, import_typeorm23.PrimaryGeneratedColumn)()
6155
6731
  ], ChatMessage.prototype, "id", 2);
6156
6732
  __decorateClass([
6157
- (0, import_typeorm22.Column)("int")
6733
+ (0, import_typeorm23.Column)("int")
6158
6734
  ], ChatMessage.prototype, "conversationId", 2);
6159
6735
  __decorateClass([
6160
- (0, import_typeorm22.Column)("varchar")
6736
+ (0, import_typeorm23.Column)("varchar")
6161
6737
  ], ChatMessage.prototype, "role", 2);
6162
6738
  __decorateClass([
6163
- (0, import_typeorm22.Column)("text")
6739
+ (0, import_typeorm23.Column)("text")
6164
6740
  ], ChatMessage.prototype, "content", 2);
6165
6741
  __decorateClass([
6166
- (0, import_typeorm22.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6742
+ (0, import_typeorm23.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6167
6743
  ], ChatMessage.prototype, "createdAt", 2);
6168
6744
  __decorateClass([
6169
- (0, import_typeorm22.ManyToOne)(() => ChatConversation, (c) => c.messages, { onDelete: "CASCADE" }),
6170
- (0, import_typeorm22.JoinColumn)({ name: "conversationId" })
6745
+ (0, import_typeorm23.ManyToOne)(() => ChatConversation, (c) => c.messages, { onDelete: "CASCADE" }),
6746
+ (0, import_typeorm23.JoinColumn)({ name: "conversationId" })
6171
6747
  ], ChatMessage.prototype, "conversation", 2);
6172
6748
  ChatMessage = __decorateClass([
6173
- (0, import_typeorm22.Entity)("chat_messages")
6749
+ (0, import_typeorm23.Entity)("chat_messages")
6174
6750
  ], ChatMessage);
6175
6751
 
6176
6752
  // src/entities/chat-conversation.entity.ts
@@ -6183,26 +6759,26 @@ var ChatConversation = class {
6183
6759
  messages;
6184
6760
  };
6185
6761
  __decorateClass([
6186
- (0, import_typeorm23.PrimaryGeneratedColumn)()
6762
+ (0, import_typeorm24.PrimaryGeneratedColumn)()
6187
6763
  ], ChatConversation.prototype, "id", 2);
6188
6764
  __decorateClass([
6189
- (0, import_typeorm23.Column)("int")
6765
+ (0, import_typeorm24.Column)("int")
6190
6766
  ], ChatConversation.prototype, "contactId", 2);
6191
6767
  __decorateClass([
6192
- (0, import_typeorm23.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6768
+ (0, import_typeorm24.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6193
6769
  ], ChatConversation.prototype, "createdAt", 2);
6194
6770
  __decorateClass([
6195
- (0, import_typeorm23.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6771
+ (0, import_typeorm24.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6196
6772
  ], ChatConversation.prototype, "updatedAt", 2);
6197
6773
  __decorateClass([
6198
- (0, import_typeorm23.ManyToOne)(() => Contact, (c) => c.chatConversations, { onDelete: "CASCADE" }),
6199
- (0, import_typeorm23.JoinColumn)({ name: "contactId" })
6774
+ (0, import_typeorm24.ManyToOne)(() => Contact, (c) => c.chatConversations, { onDelete: "CASCADE" }),
6775
+ (0, import_typeorm24.JoinColumn)({ name: "contactId" })
6200
6776
  ], ChatConversation.prototype, "contact", 2);
6201
6777
  __decorateClass([
6202
- (0, import_typeorm23.OneToMany)(() => ChatMessage, (m) => m.conversation)
6778
+ (0, import_typeorm24.OneToMany)(() => ChatMessage, (m) => m.conversation)
6203
6779
  ], ChatConversation.prototype, "messages", 2);
6204
6780
  ChatConversation = __decorateClass([
6205
- (0, import_typeorm23.Entity)("chat_conversations")
6781
+ (0, import_typeorm24.Entity)("chat_conversations")
6206
6782
  ], ChatConversation);
6207
6783
 
6208
6784
  // src/entities/contact.entity.ts
@@ -6231,78 +6807,78 @@ var Contact = class {
6231
6807
  chatConversations;
6232
6808
  };
6233
6809
  __decorateClass([
6234
- (0, import_typeorm24.PrimaryGeneratedColumn)()
6810
+ (0, import_typeorm25.PrimaryGeneratedColumn)()
6235
6811
  ], Contact.prototype, "id", 2);
6236
6812
  __decorateClass([
6237
- (0, import_typeorm24.Column)("varchar")
6813
+ (0, import_typeorm25.Column)("varchar")
6238
6814
  ], Contact.prototype, "name", 2);
6239
6815
  __decorateClass([
6240
- (0, import_typeorm24.Column)("varchar", { unique: true })
6816
+ (0, import_typeorm25.Column)("varchar", { unique: true })
6241
6817
  ], Contact.prototype, "email", 2);
6242
6818
  __decorateClass([
6243
- (0, import_typeorm24.Column)("varchar", { nullable: true })
6819
+ (0, import_typeorm25.Column)("varchar", { nullable: true })
6244
6820
  ], Contact.prototype, "phone", 2);
6245
6821
  __decorateClass([
6246
- (0, import_typeorm24.Column)("varchar", { nullable: true })
6822
+ (0, import_typeorm25.Column)("varchar", { nullable: true })
6247
6823
  ], Contact.prototype, "type", 2);
6248
6824
  __decorateClass([
6249
- (0, import_typeorm24.Column)("varchar", { nullable: true })
6825
+ (0, import_typeorm25.Column)("varchar", { nullable: true })
6250
6826
  ], Contact.prototype, "company", 2);
6251
6827
  __decorateClass([
6252
- (0, import_typeorm24.Column)("varchar", { nullable: true })
6828
+ (0, import_typeorm25.Column)("varchar", { nullable: true })
6253
6829
  ], Contact.prototype, "taxId", 2);
6254
6830
  __decorateClass([
6255
- (0, import_typeorm24.Column)("text", { nullable: true })
6831
+ (0, import_typeorm25.Column)("text", { nullable: true })
6256
6832
  ], Contact.prototype, "notes", 2);
6257
6833
  __decorateClass([
6258
- (0, import_typeorm24.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6834
+ (0, import_typeorm25.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6259
6835
  ], Contact.prototype, "createdAt", 2);
6260
6836
  __decorateClass([
6261
- (0, import_typeorm24.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6837
+ (0, import_typeorm25.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6262
6838
  ], Contact.prototype, "updatedAt", 2);
6263
6839
  __decorateClass([
6264
- (0, import_typeorm24.Column)({ type: "timestamp", nullable: true })
6840
+ (0, import_typeorm25.Column)({ type: "timestamp", nullable: true })
6265
6841
  ], Contact.prototype, "deletedAt", 2);
6266
6842
  __decorateClass([
6267
- (0, import_typeorm24.Column)("boolean", { default: false })
6843
+ (0, import_typeorm25.Column)("boolean", { default: false })
6268
6844
  ], Contact.prototype, "deleted", 2);
6269
6845
  __decorateClass([
6270
- (0, import_typeorm24.Column)("int", { nullable: true })
6846
+ (0, import_typeorm25.Column)("int", { nullable: true })
6271
6847
  ], Contact.prototype, "createdBy", 2);
6272
6848
  __decorateClass([
6273
- (0, import_typeorm24.Column)("int", { nullable: true })
6849
+ (0, import_typeorm25.Column)("int", { nullable: true })
6274
6850
  ], Contact.prototype, "updatedBy", 2);
6275
6851
  __decorateClass([
6276
- (0, import_typeorm24.Column)("int", { nullable: true })
6852
+ (0, import_typeorm25.Column)("int", { nullable: true })
6277
6853
  ], Contact.prototype, "deletedBy", 2);
6278
6854
  __decorateClass([
6279
- (0, import_typeorm24.Column)("int", { nullable: true })
6855
+ (0, import_typeorm25.Column)("int", { nullable: true })
6280
6856
  ], Contact.prototype, "userId", 2);
6281
6857
  __decorateClass([
6282
- (0, import_typeorm24.ManyToOne)(() => User, { onDelete: "SET NULL" }),
6283
- (0, import_typeorm24.JoinColumn)({ name: "userId" })
6858
+ (0, import_typeorm25.ManyToOne)(() => User, { onDelete: "SET NULL" }),
6859
+ (0, import_typeorm25.JoinColumn)({ name: "userId" })
6284
6860
  ], Contact.prototype, "user", 2);
6285
6861
  __decorateClass([
6286
- (0, import_typeorm24.OneToMany)(() => FormSubmission, (fs) => fs.contact)
6862
+ (0, import_typeorm25.OneToMany)(() => FormSubmission, (fs) => fs.contact)
6287
6863
  ], Contact.prototype, "form_submissions", 2);
6288
6864
  __decorateClass([
6289
- (0, import_typeorm24.OneToMany)(() => Address, (a) => a.contact)
6865
+ (0, import_typeorm25.OneToMany)(() => Address, (a) => a.contact)
6290
6866
  ], Contact.prototype, "addresses", 2);
6291
6867
  __decorateClass([
6292
- (0, import_typeorm24.OneToMany)(() => Order, (o) => o.contact)
6868
+ (0, import_typeorm25.OneToMany)(() => Order, (o) => o.contact)
6293
6869
  ], Contact.prototype, "orders", 2);
6294
6870
  __decorateClass([
6295
- (0, import_typeorm24.OneToMany)(() => Payment, (p) => p.contact)
6871
+ (0, import_typeorm25.OneToMany)(() => Payment, (p) => p.contact)
6296
6872
  ], Contact.prototype, "payments", 2);
6297
6873
  __decorateClass([
6298
- (0, import_typeorm24.OneToMany)(() => ChatConversation, (c) => c.contact)
6874
+ (0, import_typeorm25.OneToMany)(() => ChatConversation, (c) => c.contact)
6299
6875
  ], Contact.prototype, "chatConversations", 2);
6300
6876
  Contact = __decorateClass([
6301
- (0, import_typeorm24.Entity)("contacts")
6877
+ (0, import_typeorm25.Entity)("contacts")
6302
6878
  ], Contact);
6303
6879
 
6304
6880
  // src/entities/config.entity.ts
6305
- var import_typeorm25 = require("typeorm");
6881
+ var import_typeorm26 = require("typeorm");
6306
6882
  var Config = class {
6307
6883
  id;
6308
6884
  settings;
@@ -6319,51 +6895,51 @@ var Config = class {
6319
6895
  deletedBy;
6320
6896
  };
6321
6897
  __decorateClass([
6322
- (0, import_typeorm25.PrimaryGeneratedColumn)()
6898
+ (0, import_typeorm26.PrimaryGeneratedColumn)()
6323
6899
  ], Config.prototype, "id", 2);
6324
6900
  __decorateClass([
6325
- (0, import_typeorm25.Column)("varchar")
6901
+ (0, import_typeorm26.Column)("varchar")
6326
6902
  ], Config.prototype, "settings", 2);
6327
6903
  __decorateClass([
6328
- (0, import_typeorm25.Column)("varchar")
6904
+ (0, import_typeorm26.Column)("varchar")
6329
6905
  ], Config.prototype, "key", 2);
6330
6906
  __decorateClass([
6331
- (0, import_typeorm25.Column)("varchar")
6907
+ (0, import_typeorm26.Column)("varchar")
6332
6908
  ], Config.prototype, "value", 2);
6333
6909
  __decorateClass([
6334
- (0, import_typeorm25.Column)("varchar", { default: "private" })
6910
+ (0, import_typeorm26.Column)("varchar", { default: "private" })
6335
6911
  ], Config.prototype, "type", 2);
6336
6912
  __decorateClass([
6337
- (0, import_typeorm25.Column)("boolean", { default: false })
6913
+ (0, import_typeorm26.Column)("boolean", { default: false })
6338
6914
  ], Config.prototype, "encrypted", 2);
6339
6915
  __decorateClass([
6340
- (0, import_typeorm25.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6916
+ (0, import_typeorm26.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6341
6917
  ], Config.prototype, "createdAt", 2);
6342
6918
  __decorateClass([
6343
- (0, import_typeorm25.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6919
+ (0, import_typeorm26.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6344
6920
  ], Config.prototype, "updatedAt", 2);
6345
6921
  __decorateClass([
6346
- (0, import_typeorm25.Column)({ type: "timestamp", nullable: true })
6922
+ (0, import_typeorm26.Column)({ type: "timestamp", nullable: true })
6347
6923
  ], Config.prototype, "deletedAt", 2);
6348
6924
  __decorateClass([
6349
- (0, import_typeorm25.Column)("boolean", { default: false })
6925
+ (0, import_typeorm26.Column)("boolean", { default: false })
6350
6926
  ], Config.prototype, "deleted", 2);
6351
6927
  __decorateClass([
6352
- (0, import_typeorm25.Column)("int", { nullable: true })
6928
+ (0, import_typeorm26.Column)("int", { nullable: true })
6353
6929
  ], Config.prototype, "createdBy", 2);
6354
6930
  __decorateClass([
6355
- (0, import_typeorm25.Column)("int", { nullable: true })
6931
+ (0, import_typeorm26.Column)("int", { nullable: true })
6356
6932
  ], Config.prototype, "updatedBy", 2);
6357
6933
  __decorateClass([
6358
- (0, import_typeorm25.Column)("int", { nullable: true })
6934
+ (0, import_typeorm26.Column)("int", { nullable: true })
6359
6935
  ], Config.prototype, "deletedBy", 2);
6360
6936
  Config = __decorateClass([
6361
- (0, import_typeorm25.Entity)("configs"),
6362
- (0, import_typeorm25.Unique)(["settings", "key"])
6937
+ (0, import_typeorm26.Entity)("configs"),
6938
+ (0, import_typeorm26.Unique)(["settings", "key"])
6363
6939
  ], Config);
6364
6940
 
6365
6941
  // src/entities/message-template.entity.ts
6366
- var import_typeorm26 = require("typeorm");
6942
+ var import_typeorm27 = require("typeorm");
6367
6943
  var MessageTemplate = class {
6368
6944
  id;
6369
6945
  channel;
@@ -6383,59 +6959,59 @@ var MessageTemplate = class {
6383
6959
  deletedBy;
6384
6960
  };
6385
6961
  __decorateClass([
6386
- (0, import_typeorm26.PrimaryGeneratedColumn)()
6962
+ (0, import_typeorm27.PrimaryGeneratedColumn)()
6387
6963
  ], MessageTemplate.prototype, "id", 2);
6388
6964
  __decorateClass([
6389
- (0, import_typeorm26.Column)("varchar")
6965
+ (0, import_typeorm27.Column)("varchar")
6390
6966
  ], MessageTemplate.prototype, "channel", 2);
6391
6967
  __decorateClass([
6392
- (0, import_typeorm26.Column)("varchar", { name: "template_key" })
6968
+ (0, import_typeorm27.Column)("varchar", { name: "template_key" })
6393
6969
  ], MessageTemplate.prototype, "templateKey", 2);
6394
6970
  __decorateClass([
6395
- (0, import_typeorm26.Column)("varchar", { nullable: true })
6971
+ (0, import_typeorm27.Column)("varchar", { nullable: true })
6396
6972
  ], MessageTemplate.prototype, "name", 2);
6397
6973
  __decorateClass([
6398
- (0, import_typeorm26.Column)("varchar", { nullable: true })
6974
+ (0, import_typeorm27.Column)("varchar", { nullable: true })
6399
6975
  ], MessageTemplate.prototype, "subject", 2);
6400
6976
  __decorateClass([
6401
- (0, import_typeorm26.Column)("text", { default: "" })
6977
+ (0, import_typeorm27.Column)("text", { default: "" })
6402
6978
  ], MessageTemplate.prototype, "body", 2);
6403
6979
  __decorateClass([
6404
- (0, import_typeorm26.Column)("varchar", { name: "external_template_ref", nullable: true })
6980
+ (0, import_typeorm27.Column)("varchar", { name: "external_template_ref", nullable: true })
6405
6981
  ], MessageTemplate.prototype, "externalTemplateRef", 2);
6406
6982
  __decorateClass([
6407
- (0, import_typeorm26.Column)({ type: "jsonb", nullable: true })
6983
+ (0, import_typeorm27.Column)({ type: "jsonb", nullable: true })
6408
6984
  ], MessageTemplate.prototype, "providerMeta", 2);
6409
6985
  __decorateClass([
6410
- (0, import_typeorm26.Column)("boolean", { default: true })
6986
+ (0, import_typeorm27.Column)("boolean", { default: true })
6411
6987
  ], MessageTemplate.prototype, "enabled", 2);
6412
6988
  __decorateClass([
6413
- (0, import_typeorm26.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6989
+ (0, import_typeorm27.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6414
6990
  ], MessageTemplate.prototype, "createdAt", 2);
6415
6991
  __decorateClass([
6416
- (0, import_typeorm26.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6992
+ (0, import_typeorm27.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6417
6993
  ], MessageTemplate.prototype, "updatedAt", 2);
6418
6994
  __decorateClass([
6419
- (0, import_typeorm26.Column)({ type: "timestamp", nullable: true })
6995
+ (0, import_typeorm27.Column)({ type: "timestamp", nullable: true })
6420
6996
  ], MessageTemplate.prototype, "deletedAt", 2);
6421
6997
  __decorateClass([
6422
- (0, import_typeorm26.Column)("boolean", { default: false })
6998
+ (0, import_typeorm27.Column)("boolean", { default: false })
6423
6999
  ], MessageTemplate.prototype, "deleted", 2);
6424
7000
  __decorateClass([
6425
- (0, import_typeorm26.Column)("int", { nullable: true })
7001
+ (0, import_typeorm27.Column)("int", { nullable: true })
6426
7002
  ], MessageTemplate.prototype, "createdBy", 2);
6427
7003
  __decorateClass([
6428
- (0, import_typeorm26.Column)("int", { nullable: true })
7004
+ (0, import_typeorm27.Column)("int", { nullable: true })
6429
7005
  ], MessageTemplate.prototype, "updatedBy", 2);
6430
7006
  __decorateClass([
6431
- (0, import_typeorm26.Column)("int", { nullable: true })
7007
+ (0, import_typeorm27.Column)("int", { nullable: true })
6432
7008
  ], MessageTemplate.prototype, "deletedBy", 2);
6433
7009
  MessageTemplate = __decorateClass([
6434
- (0, import_typeorm26.Entity)("message_templates")
7010
+ (0, import_typeorm27.Entity)("message_templates")
6435
7011
  ], MessageTemplate);
6436
7012
 
6437
7013
  // src/entities/media.entity.ts
6438
- var import_typeorm27 = require("typeorm");
7014
+ var import_typeorm28 = require("typeorm");
6439
7015
  var Media = class {
6440
7016
  id;
6441
7017
  kind;
@@ -6454,57 +7030,57 @@ var Media = class {
6454
7030
  deleted;
6455
7031
  };
6456
7032
  __decorateClass([
6457
- (0, import_typeorm27.PrimaryGeneratedColumn)()
7033
+ (0, import_typeorm28.PrimaryGeneratedColumn)()
6458
7034
  ], Media.prototype, "id", 2);
6459
7035
  __decorateClass([
6460
- (0, import_typeorm27.Column)({ type: "varchar", length: 16, default: "file" })
7036
+ (0, import_typeorm28.Column)({ type: "varchar", length: 16, default: "file" })
6461
7037
  ], Media.prototype, "kind", 2);
6462
7038
  __decorateClass([
6463
- (0, import_typeorm27.Column)({ type: "int", nullable: true })
7039
+ (0, import_typeorm28.Column)({ type: "int", nullable: true })
6464
7040
  ], Media.prototype, "parentId", 2);
6465
7041
  __decorateClass([
6466
- (0, import_typeorm27.ManyToOne)(() => Media, (m) => m.children, { onDelete: "CASCADE" }),
6467
- (0, import_typeorm27.JoinColumn)({ name: "parentId" })
7042
+ (0, import_typeorm28.ManyToOne)(() => Media, (m) => m.children, { onDelete: "CASCADE" }),
7043
+ (0, import_typeorm28.JoinColumn)({ name: "parentId" })
6468
7044
  ], Media.prototype, "parent", 2);
6469
7045
  __decorateClass([
6470
- (0, import_typeorm27.OneToMany)(() => Media, (m) => m.parent)
7046
+ (0, import_typeorm28.OneToMany)(() => Media, (m) => m.parent)
6471
7047
  ], Media.prototype, "children", 2);
6472
7048
  __decorateClass([
6473
- (0, import_typeorm27.Column)("varchar")
7049
+ (0, import_typeorm28.Column)("varchar")
6474
7050
  ], Media.prototype, "filename", 2);
6475
7051
  __decorateClass([
6476
- (0, import_typeorm27.Column)("varchar", { nullable: true })
7052
+ (0, import_typeorm28.Column)("varchar", { nullable: true })
6477
7053
  ], Media.prototype, "url", 2);
6478
7054
  __decorateClass([
6479
- (0, import_typeorm27.Column)("varchar", { nullable: true })
7055
+ (0, import_typeorm28.Column)("varchar", { nullable: true })
6480
7056
  ], Media.prototype, "mimeType", 2);
6481
7057
  __decorateClass([
6482
- (0, import_typeorm27.Column)("int", { default: 0 })
7058
+ (0, import_typeorm28.Column)("int", { default: 0 })
6483
7059
  ], Media.prototype, "size", 2);
6484
7060
  __decorateClass([
6485
- (0, import_typeorm27.Column)("varchar", { nullable: true })
7061
+ (0, import_typeorm28.Column)("varchar", { nullable: true })
6486
7062
  ], Media.prototype, "alt", 2);
6487
7063
  __decorateClass([
6488
- (0, import_typeorm27.Column)("boolean", { default: false })
7064
+ (0, import_typeorm28.Column)("boolean", { default: false })
6489
7065
  ], Media.prototype, "isPublic", 2);
6490
7066
  __decorateClass([
6491
- (0, import_typeorm27.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7067
+ (0, import_typeorm28.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6492
7068
  ], Media.prototype, "createdAt", 2);
6493
7069
  __decorateClass([
6494
- (0, import_typeorm27.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7070
+ (0, import_typeorm28.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6495
7071
  ], Media.prototype, "updatedAt", 2);
6496
7072
  __decorateClass([
6497
- (0, import_typeorm27.Column)({ type: "timestamp", nullable: true })
7073
+ (0, import_typeorm28.Column)({ type: "timestamp", nullable: true })
6498
7074
  ], Media.prototype, "deletedAt", 2);
6499
7075
  __decorateClass([
6500
- (0, import_typeorm27.Column)("boolean", { default: false })
7076
+ (0, import_typeorm28.Column)("boolean", { default: false })
6501
7077
  ], Media.prototype, "deleted", 2);
6502
7078
  Media = __decorateClass([
6503
- (0, import_typeorm27.Entity)("media")
7079
+ (0, import_typeorm28.Entity)("media")
6504
7080
  ], Media);
6505
7081
 
6506
7082
  // src/entities/page.entity.ts
6507
- var import_typeorm28 = require("typeorm");
7083
+ var import_typeorm29 = require("typeorm");
6508
7084
  var Page = class {
6509
7085
  id;
6510
7086
  title;
@@ -6525,64 +7101,64 @@ var Page = class {
6525
7101
  deletedBy;
6526
7102
  };
6527
7103
  __decorateClass([
6528
- (0, import_typeorm28.PrimaryGeneratedColumn)()
7104
+ (0, import_typeorm29.PrimaryGeneratedColumn)()
6529
7105
  ], Page.prototype, "id", 2);
6530
7106
  __decorateClass([
6531
- (0, import_typeorm28.Column)("varchar")
7107
+ (0, import_typeorm29.Column)("varchar")
6532
7108
  ], Page.prototype, "title", 2);
6533
7109
  __decorateClass([
6534
- (0, import_typeorm28.Column)("varchar", { unique: true })
7110
+ (0, import_typeorm29.Column)("varchar", { unique: true })
6535
7111
  ], Page.prototype, "slug", 2);
6536
7112
  __decorateClass([
6537
- (0, import_typeorm28.Column)({ type: "jsonb", default: {} })
7113
+ (0, import_typeorm29.Column)({ type: "jsonb", default: {} })
6538
7114
  ], Page.prototype, "content", 2);
6539
7115
  __decorateClass([
6540
- (0, import_typeorm28.Column)("boolean", { default: false })
7116
+ (0, import_typeorm29.Column)("boolean", { default: false })
6541
7117
  ], Page.prototype, "published", 2);
6542
7118
  __decorateClass([
6543
- (0, import_typeorm28.Column)("varchar", { default: "default" })
7119
+ (0, import_typeorm29.Column)("varchar", { default: "default" })
6544
7120
  ], Page.prototype, "theme", 2);
6545
7121
  __decorateClass([
6546
- (0, import_typeorm28.Column)("int", { nullable: true })
7122
+ (0, import_typeorm29.Column)("int", { nullable: true })
6547
7123
  ], Page.prototype, "parentId", 2);
6548
7124
  __decorateClass([
6549
- (0, import_typeorm28.ManyToOne)(() => Page, { onDelete: "SET NULL" }),
6550
- (0, import_typeorm28.JoinColumn)({ name: "parentId" })
7125
+ (0, import_typeorm29.ManyToOne)(() => Page, { onDelete: "SET NULL" }),
7126
+ (0, import_typeorm29.JoinColumn)({ name: "parentId" })
6551
7127
  ], Page.prototype, "parent", 2);
6552
7128
  __decorateClass([
6553
- (0, import_typeorm28.Column)("int", { nullable: true })
7129
+ (0, import_typeorm29.Column)("int", { nullable: true })
6554
7130
  ], Page.prototype, "seoId", 2);
6555
7131
  __decorateClass([
6556
- (0, import_typeorm28.ManyToOne)(() => Seo, { onDelete: "SET NULL" }),
6557
- (0, import_typeorm28.JoinColumn)({ name: "seoId" })
7132
+ (0, import_typeorm29.ManyToOne)(() => Seo, { onDelete: "SET NULL" }),
7133
+ (0, import_typeorm29.JoinColumn)({ name: "seoId" })
6558
7134
  ], Page.prototype, "seo", 2);
6559
7135
  __decorateClass([
6560
- (0, import_typeorm28.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7136
+ (0, import_typeorm29.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6561
7137
  ], Page.prototype, "createdAt", 2);
6562
7138
  __decorateClass([
6563
- (0, import_typeorm28.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7139
+ (0, import_typeorm29.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6564
7140
  ], Page.prototype, "updatedAt", 2);
6565
7141
  __decorateClass([
6566
- (0, import_typeorm28.Column)({ type: "timestamp", nullable: true })
7142
+ (0, import_typeorm29.Column)({ type: "timestamp", nullable: true })
6567
7143
  ], Page.prototype, "deletedAt", 2);
6568
7144
  __decorateClass([
6569
- (0, import_typeorm28.Column)("boolean", { default: false })
7145
+ (0, import_typeorm29.Column)("boolean", { default: false })
6570
7146
  ], Page.prototype, "deleted", 2);
6571
7147
  __decorateClass([
6572
- (0, import_typeorm28.Column)("int", { nullable: true })
7148
+ (0, import_typeorm29.Column)("int", { nullable: true })
6573
7149
  ], Page.prototype, "createdBy", 2);
6574
7150
  __decorateClass([
6575
- (0, import_typeorm28.Column)("int", { nullable: true })
7151
+ (0, import_typeorm29.Column)("int", { nullable: true })
6576
7152
  ], Page.prototype, "updatedBy", 2);
6577
7153
  __decorateClass([
6578
- (0, import_typeorm28.Column)("int", { nullable: true })
7154
+ (0, import_typeorm29.Column)("int", { nullable: true })
6579
7155
  ], Page.prototype, "deletedBy", 2);
6580
7156
  Page = __decorateClass([
6581
- (0, import_typeorm28.Entity)("pages")
7157
+ (0, import_typeorm29.Entity)("pages")
6582
7158
  ], Page);
6583
7159
 
6584
7160
  // src/entities/product-category.entity.ts
6585
- var import_typeorm29 = require("typeorm");
7161
+ var import_typeorm30 = require("typeorm");
6586
7162
  var ProductCategory = class {
6587
7163
  id;
6588
7164
  name;
@@ -6606,75 +7182,75 @@ var ProductCategory = class {
6606
7182
  collections;
6607
7183
  };
6608
7184
  __decorateClass([
6609
- (0, import_typeorm29.PrimaryGeneratedColumn)()
7185
+ (0, import_typeorm30.PrimaryGeneratedColumn)()
6610
7186
  ], ProductCategory.prototype, "id", 2);
6611
7187
  __decorateClass([
6612
- (0, import_typeorm29.Column)("varchar")
7188
+ (0, import_typeorm30.Column)("varchar")
6613
7189
  ], ProductCategory.prototype, "name", 2);
6614
7190
  __decorateClass([
6615
- (0, import_typeorm29.Column)("varchar", { unique: true })
7191
+ (0, import_typeorm30.Column)("varchar", { unique: true })
6616
7192
  ], ProductCategory.prototype, "slug", 2);
6617
7193
  __decorateClass([
6618
- (0, import_typeorm29.Column)("int", { nullable: true })
7194
+ (0, import_typeorm30.Column)("int", { nullable: true })
6619
7195
  ], ProductCategory.prototype, "parentId", 2);
6620
7196
  __decorateClass([
6621
- (0, import_typeorm29.Column)("varchar", { nullable: true })
7197
+ (0, import_typeorm30.Column)("varchar", { nullable: true })
6622
7198
  ], ProductCategory.prototype, "image", 2);
6623
7199
  __decorateClass([
6624
- (0, import_typeorm29.Column)("text", { nullable: true })
7200
+ (0, import_typeorm30.Column)("text", { nullable: true })
6625
7201
  ], ProductCategory.prototype, "description", 2);
6626
7202
  __decorateClass([
6627
- (0, import_typeorm29.Column)("jsonb", { nullable: true })
7203
+ (0, import_typeorm30.Column)("jsonb", { nullable: true })
6628
7204
  ], ProductCategory.prototype, "metadata", 2);
6629
7205
  __decorateClass([
6630
- (0, import_typeorm29.Column)("boolean", { default: true })
7206
+ (0, import_typeorm30.Column)("boolean", { default: true })
6631
7207
  ], ProductCategory.prototype, "active", 2);
6632
7208
  __decorateClass([
6633
- (0, import_typeorm29.Column)("int", { default: 0 })
7209
+ (0, import_typeorm30.Column)("int", { default: 0 })
6634
7210
  ], ProductCategory.prototype, "sortOrder", 2);
6635
7211
  __decorateClass([
6636
- (0, import_typeorm29.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7212
+ (0, import_typeorm30.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6637
7213
  ], ProductCategory.prototype, "createdAt", 2);
6638
7214
  __decorateClass([
6639
- (0, import_typeorm29.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7215
+ (0, import_typeorm30.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6640
7216
  ], ProductCategory.prototype, "updatedAt", 2);
6641
7217
  __decorateClass([
6642
- (0, import_typeorm29.Column)({ type: "timestamp", nullable: true })
7218
+ (0, import_typeorm30.Column)({ type: "timestamp", nullable: true })
6643
7219
  ], ProductCategory.prototype, "deletedAt", 2);
6644
7220
  __decorateClass([
6645
- (0, import_typeorm29.Column)("boolean", { default: false })
7221
+ (0, import_typeorm30.Column)("boolean", { default: false })
6646
7222
  ], ProductCategory.prototype, "deleted", 2);
6647
7223
  __decorateClass([
6648
- (0, import_typeorm29.Column)("int", { nullable: true })
7224
+ (0, import_typeorm30.Column)("int", { nullable: true })
6649
7225
  ], ProductCategory.prototype, "createdBy", 2);
6650
7226
  __decorateClass([
6651
- (0, import_typeorm29.Column)("int", { nullable: true })
7227
+ (0, import_typeorm30.Column)("int", { nullable: true })
6652
7228
  ], ProductCategory.prototype, "updatedBy", 2);
6653
7229
  __decorateClass([
6654
- (0, import_typeorm29.Column)("int", { nullable: true })
7230
+ (0, import_typeorm30.Column)("int", { nullable: true })
6655
7231
  ], ProductCategory.prototype, "deletedBy", 2);
6656
7232
  __decorateClass([
6657
- (0, import_typeorm29.ManyToOne)(() => ProductCategory, (c) => c.children, { onDelete: "SET NULL" }),
6658
- (0, import_typeorm29.JoinColumn)({ name: "parentId" })
7233
+ (0, import_typeorm30.ManyToOne)(() => ProductCategory, (c) => c.children, { onDelete: "SET NULL" }),
7234
+ (0, import_typeorm30.JoinColumn)({ name: "parentId" })
6659
7235
  ], ProductCategory.prototype, "parent", 2);
6660
7236
  __decorateClass([
6661
- (0, import_typeorm29.OneToMany)(() => ProductCategory, (c) => c.parent)
7237
+ (0, import_typeorm30.OneToMany)(() => ProductCategory, (c) => c.parent)
6662
7238
  ], ProductCategory.prototype, "children", 2);
6663
7239
  __decorateClass([
6664
- (0, import_typeorm29.OneToMany)("Product", "category")
7240
+ (0, import_typeorm30.OneToMany)("Product", "category")
6665
7241
  ], ProductCategory.prototype, "products", 2);
6666
7242
  __decorateClass([
6667
- (0, import_typeorm29.OneToMany)("Collection", "category")
7243
+ (0, import_typeorm30.OneToMany)("Collection", "category")
6668
7244
  ], ProductCategory.prototype, "collections", 2);
6669
7245
  ProductCategory = __decorateClass([
6670
- (0, import_typeorm29.Entity)("product_categories")
7246
+ (0, import_typeorm30.Entity)("product_categories")
6671
7247
  ], ProductCategory);
6672
7248
 
6673
7249
  // src/entities/collection.entity.ts
6674
- var import_typeorm31 = require("typeorm");
7250
+ var import_typeorm32 = require("typeorm");
6675
7251
 
6676
7252
  // src/entities/brand.entity.ts
6677
- var import_typeorm30 = require("typeorm");
7253
+ var import_typeorm31 = require("typeorm");
6678
7254
  var Brand = class {
6679
7255
  id;
6680
7256
  name;
@@ -6697,65 +7273,65 @@ var Brand = class {
6697
7273
  collections;
6698
7274
  };
6699
7275
  __decorateClass([
6700
- (0, import_typeorm30.PrimaryGeneratedColumn)()
7276
+ (0, import_typeorm31.PrimaryGeneratedColumn)()
6701
7277
  ], Brand.prototype, "id", 2);
6702
7278
  __decorateClass([
6703
- (0, import_typeorm30.Column)("varchar")
7279
+ (0, import_typeorm31.Column)("varchar")
6704
7280
  ], Brand.prototype, "name", 2);
6705
7281
  __decorateClass([
6706
- (0, import_typeorm30.Column)("varchar", { unique: true })
7282
+ (0, import_typeorm31.Column)("varchar", { unique: true })
6707
7283
  ], Brand.prototype, "slug", 2);
6708
7284
  __decorateClass([
6709
- (0, import_typeorm30.Column)("varchar", { nullable: true })
7285
+ (0, import_typeorm31.Column)("varchar", { nullable: true })
6710
7286
  ], Brand.prototype, "logo", 2);
6711
7287
  __decorateClass([
6712
- (0, import_typeorm30.Column)("jsonb", { nullable: true })
7288
+ (0, import_typeorm31.Column)("jsonb", { nullable: true })
6713
7289
  ], Brand.prototype, "metadata", 2);
6714
7290
  __decorateClass([
6715
- (0, import_typeorm30.Column)("text", { nullable: true })
7291
+ (0, import_typeorm31.Column)("text", { nullable: true })
6716
7292
  ], Brand.prototype, "description", 2);
6717
7293
  __decorateClass([
6718
- (0, import_typeorm30.Column)("boolean", { default: true })
7294
+ (0, import_typeorm31.Column)("boolean", { default: true })
6719
7295
  ], Brand.prototype, "active", 2);
6720
7296
  __decorateClass([
6721
- (0, import_typeorm30.Column)("int", { default: 0 })
7297
+ (0, import_typeorm31.Column)("int", { default: 0 })
6722
7298
  ], Brand.prototype, "sortOrder", 2);
6723
7299
  __decorateClass([
6724
- (0, import_typeorm30.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7300
+ (0, import_typeorm31.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6725
7301
  ], Brand.prototype, "createdAt", 2);
6726
7302
  __decorateClass([
6727
- (0, import_typeorm30.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7303
+ (0, import_typeorm31.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6728
7304
  ], Brand.prototype, "updatedAt", 2);
6729
7305
  __decorateClass([
6730
- (0, import_typeorm30.Column)({ type: "timestamp", nullable: true })
7306
+ (0, import_typeorm31.Column)({ type: "timestamp", nullable: true })
6731
7307
  ], Brand.prototype, "deletedAt", 2);
6732
7308
  __decorateClass([
6733
- (0, import_typeorm30.Column)("boolean", { default: false })
7309
+ (0, import_typeorm31.Column)("boolean", { default: false })
6734
7310
  ], Brand.prototype, "deleted", 2);
6735
7311
  __decorateClass([
6736
- (0, import_typeorm30.Column)("int", { nullable: true })
7312
+ (0, import_typeorm31.Column)("int", { nullable: true })
6737
7313
  ], Brand.prototype, "createdBy", 2);
6738
7314
  __decorateClass([
6739
- (0, import_typeorm30.Column)("int", { nullable: true })
7315
+ (0, import_typeorm31.Column)("int", { nullable: true })
6740
7316
  ], Brand.prototype, "updatedBy", 2);
6741
7317
  __decorateClass([
6742
- (0, import_typeorm30.Column)("int", { nullable: true })
7318
+ (0, import_typeorm31.Column)("int", { nullable: true })
6743
7319
  ], Brand.prototype, "deletedBy", 2);
6744
7320
  __decorateClass([
6745
- (0, import_typeorm30.Column)("int", { nullable: true })
7321
+ (0, import_typeorm31.Column)("int", { nullable: true })
6746
7322
  ], Brand.prototype, "seoId", 2);
6747
7323
  __decorateClass([
6748
- (0, import_typeorm30.ManyToOne)(() => Seo, { onDelete: "SET NULL" }),
6749
- (0, import_typeorm30.JoinColumn)({ name: "seoId" })
7324
+ (0, import_typeorm31.ManyToOne)(() => Seo, { onDelete: "SET NULL" }),
7325
+ (0, import_typeorm31.JoinColumn)({ name: "seoId" })
6750
7326
  ], Brand.prototype, "seo", 2);
6751
7327
  __decorateClass([
6752
- (0, import_typeorm30.OneToMany)("Product", "brand")
7328
+ (0, import_typeorm31.OneToMany)("Product", "brand")
6753
7329
  ], Brand.prototype, "products", 2);
6754
7330
  __decorateClass([
6755
- (0, import_typeorm30.OneToMany)("Collection", "brand")
7331
+ (0, import_typeorm31.OneToMany)("Collection", "brand")
6756
7332
  ], Brand.prototype, "collections", 2);
6757
7333
  Brand = __decorateClass([
6758
- (0, import_typeorm30.Entity)("brands")
7334
+ (0, import_typeorm31.Entity)("brands")
6759
7335
  ], Brand);
6760
7336
 
6761
7337
  // src/entities/collection.entity.ts
@@ -6769,6 +7345,7 @@ var Collection = class {
6769
7345
  description;
6770
7346
  image;
6771
7347
  metadata;
7348
+ variants;
6772
7349
  active;
6773
7350
  sortOrder;
6774
7351
  createdAt;
@@ -6785,83 +7362,86 @@ var Collection = class {
6785
7362
  products;
6786
7363
  };
6787
7364
  __decorateClass([
6788
- (0, import_typeorm31.PrimaryGeneratedColumn)()
7365
+ (0, import_typeorm32.PrimaryGeneratedColumn)()
6789
7366
  ], Collection.prototype, "id", 2);
6790
7367
  __decorateClass([
6791
- (0, import_typeorm31.Column)("int", { nullable: true })
7368
+ (0, import_typeorm32.Column)("int", { nullable: true })
6792
7369
  ], Collection.prototype, "categoryId", 2);
6793
7370
  __decorateClass([
6794
- (0, import_typeorm31.Column)("int", { nullable: true })
7371
+ (0, import_typeorm32.Column)("int", { nullable: true })
6795
7372
  ], Collection.prototype, "brandId", 2);
6796
7373
  __decorateClass([
6797
- (0, import_typeorm31.Column)("varchar")
7374
+ (0, import_typeorm32.Column)("varchar")
6798
7375
  ], Collection.prototype, "name", 2);
6799
7376
  __decorateClass([
6800
- (0, import_typeorm31.Column)("varchar", { unique: true })
7377
+ (0, import_typeorm32.Column)("varchar", { unique: true })
6801
7378
  ], Collection.prototype, "slug", 2);
6802
7379
  __decorateClass([
6803
- (0, import_typeorm31.Column)("varchar", { nullable: true })
7380
+ (0, import_typeorm32.Column)("varchar", { nullable: true })
6804
7381
  ], Collection.prototype, "hsn", 2);
6805
7382
  __decorateClass([
6806
- (0, import_typeorm31.Column)("text", { nullable: true })
7383
+ (0, import_typeorm32.Column)("text", { nullable: true })
6807
7384
  ], Collection.prototype, "description", 2);
6808
7385
  __decorateClass([
6809
- (0, import_typeorm31.Column)("varchar", { nullable: true })
7386
+ (0, import_typeorm32.Column)("varchar", { nullable: true })
6810
7387
  ], Collection.prototype, "image", 2);
6811
7388
  __decorateClass([
6812
- (0, import_typeorm31.Column)("jsonb", { nullable: true })
7389
+ (0, import_typeorm32.Column)("jsonb", { nullable: true })
6813
7390
  ], Collection.prototype, "metadata", 2);
6814
7391
  __decorateClass([
6815
- (0, import_typeorm31.Column)("boolean", { default: true })
7392
+ (0, import_typeorm32.Column)("jsonb", { nullable: true })
7393
+ ], Collection.prototype, "variants", 2);
7394
+ __decorateClass([
7395
+ (0, import_typeorm32.Column)("boolean", { default: true })
6816
7396
  ], Collection.prototype, "active", 2);
6817
7397
  __decorateClass([
6818
- (0, import_typeorm31.Column)("int", { default: 0 })
7398
+ (0, import_typeorm32.Column)("int", { default: 0 })
6819
7399
  ], Collection.prototype, "sortOrder", 2);
6820
7400
  __decorateClass([
6821
- (0, import_typeorm31.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7401
+ (0, import_typeorm32.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6822
7402
  ], Collection.prototype, "createdAt", 2);
6823
7403
  __decorateClass([
6824
- (0, import_typeorm31.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7404
+ (0, import_typeorm32.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6825
7405
  ], Collection.prototype, "updatedAt", 2);
6826
7406
  __decorateClass([
6827
- (0, import_typeorm31.Column)({ type: "timestamp", nullable: true })
7407
+ (0, import_typeorm32.Column)({ type: "timestamp", nullable: true })
6828
7408
  ], Collection.prototype, "deletedAt", 2);
6829
7409
  __decorateClass([
6830
- (0, import_typeorm31.Column)("boolean", { default: false })
7410
+ (0, import_typeorm32.Column)("boolean", { default: false })
6831
7411
  ], Collection.prototype, "deleted", 2);
6832
7412
  __decorateClass([
6833
- (0, import_typeorm31.Column)("int", { nullable: true })
7413
+ (0, import_typeorm32.Column)("int", { nullable: true })
6834
7414
  ], Collection.prototype, "createdBy", 2);
6835
7415
  __decorateClass([
6836
- (0, import_typeorm31.Column)("int", { nullable: true })
7416
+ (0, import_typeorm32.Column)("int", { nullable: true })
6837
7417
  ], Collection.prototype, "updatedBy", 2);
6838
7418
  __decorateClass([
6839
- (0, import_typeorm31.Column)("int", { nullable: true })
7419
+ (0, import_typeorm32.Column)("int", { nullable: true })
6840
7420
  ], Collection.prototype, "deletedBy", 2);
6841
7421
  __decorateClass([
6842
- (0, import_typeorm31.Column)("int", { nullable: true })
7422
+ (0, import_typeorm32.Column)("int", { nullable: true })
6843
7423
  ], Collection.prototype, "seoId", 2);
6844
7424
  __decorateClass([
6845
- (0, import_typeorm31.ManyToOne)(() => Seo, { onDelete: "SET NULL" }),
6846
- (0, import_typeorm31.JoinColumn)({ name: "seoId" })
7425
+ (0, import_typeorm32.ManyToOne)(() => Seo, { onDelete: "SET NULL" }),
7426
+ (0, import_typeorm32.JoinColumn)({ name: "seoId" })
6847
7427
  ], Collection.prototype, "seo", 2);
6848
7428
  __decorateClass([
6849
- (0, import_typeorm31.ManyToOne)(() => ProductCategory, (c) => c.collections, { onDelete: "SET NULL" }),
6850
- (0, import_typeorm31.JoinColumn)({ name: "categoryId" })
7429
+ (0, import_typeorm32.ManyToOne)(() => ProductCategory, (c) => c.collections, { onDelete: "SET NULL" }),
7430
+ (0, import_typeorm32.JoinColumn)({ name: "categoryId" })
6851
7431
  ], Collection.prototype, "category", 2);
6852
7432
  __decorateClass([
6853
- (0, import_typeorm31.ManyToOne)(() => Brand, (b) => b.collections, { onDelete: "SET NULL" }),
6854
- (0, import_typeorm31.JoinColumn)({ name: "brandId" })
7433
+ (0, import_typeorm32.ManyToOne)(() => Brand, (b) => b.collections, { onDelete: "SET NULL" }),
7434
+ (0, import_typeorm32.JoinColumn)({ name: "brandId" })
6855
7435
  ], Collection.prototype, "brand", 2);
6856
7436
  __decorateClass([
6857
- (0, import_typeorm31.OneToMany)("Product", "collection")
7437
+ (0, import_typeorm32.OneToMany)("Product", "collection")
6858
7438
  ], Collection.prototype, "products", 2);
6859
7439
  Collection = __decorateClass([
6860
- (0, import_typeorm31.Entity)("collections")
7440
+ (0, import_typeorm32.Entity)("collections")
6861
7441
  ], Collection);
6862
7442
 
6863
7443
  // src/entities/product.entity.ts
6864
- var import_typeorm32 = require("typeorm");
7444
+ var import_typeorm33 = require("typeorm");
6865
7445
  var Product = class {
6866
7446
  id;
6867
7447
  collectionId;
@@ -6895,105 +7475,105 @@ var Product = class {
6895
7475
  taxes;
6896
7476
  };
6897
7477
  __decorateClass([
6898
- (0, import_typeorm32.PrimaryGeneratedColumn)()
7478
+ (0, import_typeorm33.PrimaryGeneratedColumn)()
6899
7479
  ], Product.prototype, "id", 2);
6900
7480
  __decorateClass([
6901
- (0, import_typeorm32.Column)("int", { nullable: true })
7481
+ (0, import_typeorm33.Column)("int", { nullable: true })
6902
7482
  ], Product.prototype, "collectionId", 2);
6903
7483
  __decorateClass([
6904
- (0, import_typeorm32.Column)("int", { nullable: true })
7484
+ (0, import_typeorm33.Column)("int", { nullable: true })
6905
7485
  ], Product.prototype, "brandId", 2);
6906
7486
  __decorateClass([
6907
- (0, import_typeorm32.Column)("int", { nullable: true })
7487
+ (0, import_typeorm33.Column)("int", { nullable: true })
6908
7488
  ], Product.prototype, "categoryId", 2);
6909
7489
  __decorateClass([
6910
- (0, import_typeorm32.Column)("varchar", { nullable: true })
7490
+ (0, import_typeorm33.Column)("varchar", { nullable: true })
6911
7491
  ], Product.prototype, "sku", 2);
6912
7492
  __decorateClass([
6913
- (0, import_typeorm32.Column)("varchar", { nullable: true })
7493
+ (0, import_typeorm33.Column)("varchar", { nullable: true })
6914
7494
  ], Product.prototype, "hsn", 2);
6915
7495
  __decorateClass([
6916
- (0, import_typeorm32.Column)("varchar", { nullable: true })
7496
+ (0, import_typeorm33.Column)("varchar", { nullable: true })
6917
7497
  ], Product.prototype, "uom", 2);
6918
7498
  __decorateClass([
6919
- (0, import_typeorm32.Column)("varchar", { default: "product" })
7499
+ (0, import_typeorm33.Column)("varchar", { default: "product" })
6920
7500
  ], Product.prototype, "type", 2);
6921
7501
  __decorateClass([
6922
- (0, import_typeorm32.Column)("varchar", { unique: true, nullable: true })
7502
+ (0, import_typeorm33.Column)("varchar", { unique: true, nullable: true })
6923
7503
  ], Product.prototype, "slug", 2);
6924
7504
  __decorateClass([
6925
- (0, import_typeorm32.Column)("varchar", { nullable: true })
7505
+ (0, import_typeorm33.Column)("varchar", { nullable: true })
6926
7506
  ], Product.prototype, "name", 2);
6927
7507
  __decorateClass([
6928
- (0, import_typeorm32.Column)("decimal", { precision: 12, scale: 2 })
7508
+ (0, import_typeorm33.Column)("decimal", { precision: 12, scale: 2 })
6929
7509
  ], Product.prototype, "price", 2);
6930
7510
  __decorateClass([
6931
- (0, import_typeorm32.Column)("decimal", { precision: 12, scale: 2, nullable: true })
7511
+ (0, import_typeorm33.Column)("decimal", { precision: 12, scale: 2, nullable: true })
6932
7512
  ], Product.prototype, "compareAtPrice", 2);
6933
7513
  __decorateClass([
6934
- (0, import_typeorm32.Column)("int", { default: 0 })
7514
+ (0, import_typeorm33.Column)("int", { default: 0 })
6935
7515
  ], Product.prototype, "quantity", 2);
6936
7516
  __decorateClass([
6937
- (0, import_typeorm32.Column)("varchar", { default: "draft" })
7517
+ (0, import_typeorm33.Column)("varchar", { default: "draft" })
6938
7518
  ], Product.prototype, "status", 2);
6939
7519
  __decorateClass([
6940
- (0, import_typeorm32.Column)("boolean", { default: false })
7520
+ (0, import_typeorm33.Column)("boolean", { default: false })
6941
7521
  ], Product.prototype, "featured", 2);
6942
7522
  __decorateClass([
6943
- (0, import_typeorm32.Column)("jsonb", { nullable: true })
7523
+ (0, import_typeorm33.Column)("jsonb", { nullable: true })
6944
7524
  ], Product.prototype, "metadata", 2);
6945
7525
  __decorateClass([
6946
- (0, import_typeorm32.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7526
+ (0, import_typeorm33.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6947
7527
  ], Product.prototype, "createdAt", 2);
6948
7528
  __decorateClass([
6949
- (0, import_typeorm32.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7529
+ (0, import_typeorm33.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6950
7530
  ], Product.prototype, "updatedAt", 2);
6951
7531
  __decorateClass([
6952
- (0, import_typeorm32.Column)({ type: "timestamp", nullable: true })
7532
+ (0, import_typeorm33.Column)({ type: "timestamp", nullable: true })
6953
7533
  ], Product.prototype, "deletedAt", 2);
6954
7534
  __decorateClass([
6955
- (0, import_typeorm32.Column)("boolean", { default: false })
7535
+ (0, import_typeorm33.Column)("boolean", { default: false })
6956
7536
  ], Product.prototype, "deleted", 2);
6957
7537
  __decorateClass([
6958
- (0, import_typeorm32.Column)("int", { nullable: true })
7538
+ (0, import_typeorm33.Column)("int", { nullable: true })
6959
7539
  ], Product.prototype, "createdBy", 2);
6960
7540
  __decorateClass([
6961
- (0, import_typeorm32.Column)("int", { nullable: true })
7541
+ (0, import_typeorm33.Column)("int", { nullable: true })
6962
7542
  ], Product.prototype, "updatedBy", 2);
6963
7543
  __decorateClass([
6964
- (0, import_typeorm32.Column)("int", { nullable: true })
7544
+ (0, import_typeorm33.Column)("int", { nullable: true })
6965
7545
  ], Product.prototype, "deletedBy", 2);
6966
7546
  __decorateClass([
6967
- (0, import_typeorm32.Column)("int", { nullable: true })
7547
+ (0, import_typeorm33.Column)("int", { nullable: true })
6968
7548
  ], Product.prototype, "seoId", 2);
6969
7549
  __decorateClass([
6970
- (0, import_typeorm32.ManyToOne)(() => Seo, { onDelete: "SET NULL" }),
6971
- (0, import_typeorm32.JoinColumn)({ name: "seoId" })
7550
+ (0, import_typeorm33.ManyToOne)(() => Seo, { onDelete: "SET NULL" }),
7551
+ (0, import_typeorm33.JoinColumn)({ name: "seoId" })
6972
7552
  ], Product.prototype, "seo", 2);
6973
7553
  __decorateClass([
6974
- (0, import_typeorm32.ManyToOne)(() => Collection, (c) => c.products, { onDelete: "SET NULL" }),
6975
- (0, import_typeorm32.JoinColumn)({ name: "collectionId" })
7554
+ (0, import_typeorm33.ManyToOne)(() => Collection, (c) => c.products, { onDelete: "SET NULL" }),
7555
+ (0, import_typeorm33.JoinColumn)({ name: "collectionId" })
6976
7556
  ], Product.prototype, "collection", 2);
6977
7557
  __decorateClass([
6978
- (0, import_typeorm32.ManyToOne)(() => Brand, (b) => b.products, { onDelete: "SET NULL" }),
6979
- (0, import_typeorm32.JoinColumn)({ name: "brandId" })
7558
+ (0, import_typeorm33.ManyToOne)(() => Brand, (b) => b.products, { onDelete: "SET NULL" }),
7559
+ (0, import_typeorm33.JoinColumn)({ name: "brandId" })
6980
7560
  ], Product.prototype, "brand", 2);
6981
7561
  __decorateClass([
6982
- (0, import_typeorm32.ManyToOne)(() => ProductCategory, (c) => c.products, { onDelete: "SET NULL" }),
6983
- (0, import_typeorm32.JoinColumn)({ name: "categoryId" })
7562
+ (0, import_typeorm33.ManyToOne)(() => ProductCategory, (c) => c.products, { onDelete: "SET NULL" }),
7563
+ (0, import_typeorm33.JoinColumn)({ name: "categoryId" })
6984
7564
  ], Product.prototype, "category", 2);
6985
7565
  __decorateClass([
6986
- (0, import_typeorm32.OneToMany)("ProductAttribute", "product")
7566
+ (0, import_typeorm33.OneToMany)("ProductAttribute", "product")
6987
7567
  ], Product.prototype, "attributes", 2);
6988
7568
  __decorateClass([
6989
- (0, import_typeorm32.OneToMany)("ProductTax", "product")
7569
+ (0, import_typeorm33.OneToMany)("ProductTax", "product")
6990
7570
  ], Product.prototype, "taxes", 2);
6991
7571
  Product = __decorateClass([
6992
- (0, import_typeorm32.Entity)("products")
7572
+ (0, import_typeorm33.Entity)("products")
6993
7573
  ], Product);
6994
7574
 
6995
7575
  // src/entities/attribute.entity.ts
6996
- var import_typeorm33 = require("typeorm");
7576
+ var import_typeorm34 = require("typeorm");
6997
7577
  var Attribute = class {
6998
7578
  id;
6999
7579
  name;
@@ -7012,56 +7592,56 @@ var Attribute = class {
7012
7592
  deletedBy;
7013
7593
  };
7014
7594
  __decorateClass([
7015
- (0, import_typeorm33.PrimaryGeneratedColumn)()
7595
+ (0, import_typeorm34.PrimaryGeneratedColumn)()
7016
7596
  ], Attribute.prototype, "id", 2);
7017
7597
  __decorateClass([
7018
- (0, import_typeorm33.Column)("varchar")
7598
+ (0, import_typeorm34.Column)("varchar")
7019
7599
  ], Attribute.prototype, "name", 2);
7020
7600
  __decorateClass([
7021
- (0, import_typeorm33.Column)("varchar", { unique: true })
7601
+ (0, import_typeorm34.Column)("varchar", { unique: true })
7022
7602
  ], Attribute.prototype, "slug", 2);
7023
7603
  __decorateClass([
7024
- (0, import_typeorm33.Column)("varchar", { default: "text" })
7604
+ (0, import_typeorm34.Column)("varchar", { default: "text" })
7025
7605
  ], Attribute.prototype, "type", 2);
7026
7606
  __decorateClass([
7027
- (0, import_typeorm33.Column)("jsonb", { nullable: true })
7607
+ (0, import_typeorm34.Column)("jsonb", { nullable: true })
7028
7608
  ], Attribute.prototype, "options", 2);
7029
7609
  __decorateClass([
7030
- (0, import_typeorm33.Column)("jsonb", { nullable: true })
7610
+ (0, import_typeorm34.Column)("jsonb", { nullable: true })
7031
7611
  ], Attribute.prototype, "metadata", 2);
7032
7612
  __decorateClass([
7033
- (0, import_typeorm33.Column)("boolean", { default: true })
7613
+ (0, import_typeorm34.Column)("boolean", { default: true })
7034
7614
  ], Attribute.prototype, "active", 2);
7035
7615
  __decorateClass([
7036
- (0, import_typeorm33.Column)("int", { default: 0 })
7616
+ (0, import_typeorm34.Column)("int", { default: 0 })
7037
7617
  ], Attribute.prototype, "sortOrder", 2);
7038
7618
  __decorateClass([
7039
- (0, import_typeorm33.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7619
+ (0, import_typeorm34.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7040
7620
  ], Attribute.prototype, "createdAt", 2);
7041
7621
  __decorateClass([
7042
- (0, import_typeorm33.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7622
+ (0, import_typeorm34.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7043
7623
  ], Attribute.prototype, "updatedAt", 2);
7044
7624
  __decorateClass([
7045
- (0, import_typeorm33.Column)({ type: "timestamp", nullable: true })
7625
+ (0, import_typeorm34.Column)({ type: "timestamp", nullable: true })
7046
7626
  ], Attribute.prototype, "deletedAt", 2);
7047
7627
  __decorateClass([
7048
- (0, import_typeorm33.Column)("boolean", { default: false })
7628
+ (0, import_typeorm34.Column)("boolean", { default: false })
7049
7629
  ], Attribute.prototype, "deleted", 2);
7050
7630
  __decorateClass([
7051
- (0, import_typeorm33.Column)("int", { nullable: true })
7631
+ (0, import_typeorm34.Column)("int", { nullable: true })
7052
7632
  ], Attribute.prototype, "createdBy", 2);
7053
7633
  __decorateClass([
7054
- (0, import_typeorm33.Column)("int", { nullable: true })
7634
+ (0, import_typeorm34.Column)("int", { nullable: true })
7055
7635
  ], Attribute.prototype, "updatedBy", 2);
7056
7636
  __decorateClass([
7057
- (0, import_typeorm33.Column)("int", { nullable: true })
7637
+ (0, import_typeorm34.Column)("int", { nullable: true })
7058
7638
  ], Attribute.prototype, "deletedBy", 2);
7059
7639
  Attribute = __decorateClass([
7060
- (0, import_typeorm33.Entity)("attributes")
7640
+ (0, import_typeorm34.Entity)("attributes")
7061
7641
  ], Attribute);
7062
7642
 
7063
7643
  // src/entities/product-attribute.entity.ts
7064
- var import_typeorm34 = require("typeorm");
7644
+ var import_typeorm35 = require("typeorm");
7065
7645
  var ProductAttribute = class {
7066
7646
  id;
7067
7647
  productId;
@@ -7074,40 +7654,40 @@ var ProductAttribute = class {
7074
7654
  attribute;
7075
7655
  };
7076
7656
  __decorateClass([
7077
- (0, import_typeorm34.PrimaryGeneratedColumn)()
7657
+ (0, import_typeorm35.PrimaryGeneratedColumn)()
7078
7658
  ], ProductAttribute.prototype, "id", 2);
7079
7659
  __decorateClass([
7080
- (0, import_typeorm34.Column)("int")
7660
+ (0, import_typeorm35.Column)("int")
7081
7661
  ], ProductAttribute.prototype, "productId", 2);
7082
7662
  __decorateClass([
7083
- (0, import_typeorm34.Column)("int")
7663
+ (0, import_typeorm35.Column)("int")
7084
7664
  ], ProductAttribute.prototype, "attributeId", 2);
7085
7665
  __decorateClass([
7086
- (0, import_typeorm34.Column)("varchar")
7666
+ (0, import_typeorm35.Column)("varchar")
7087
7667
  ], ProductAttribute.prototype, "value", 2);
7088
7668
  __decorateClass([
7089
- (0, import_typeorm34.Column)("jsonb", { nullable: true })
7669
+ (0, import_typeorm35.Column)("jsonb", { nullable: true })
7090
7670
  ], ProductAttribute.prototype, "metadata", 2);
7091
7671
  __decorateClass([
7092
- (0, import_typeorm34.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7672
+ (0, import_typeorm35.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7093
7673
  ], ProductAttribute.prototype, "createdAt", 2);
7094
7674
  __decorateClass([
7095
- (0, import_typeorm34.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7675
+ (0, import_typeorm35.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7096
7676
  ], ProductAttribute.prototype, "updatedAt", 2);
7097
7677
  __decorateClass([
7098
- (0, import_typeorm34.ManyToOne)(() => Product, (p) => p.attributes, { onDelete: "CASCADE" }),
7099
- (0, import_typeorm34.JoinColumn)({ name: "productId" })
7678
+ (0, import_typeorm35.ManyToOne)(() => Product, (p) => p.attributes, { onDelete: "CASCADE" }),
7679
+ (0, import_typeorm35.JoinColumn)({ name: "productId" })
7100
7680
  ], ProductAttribute.prototype, "product", 2);
7101
7681
  __decorateClass([
7102
- (0, import_typeorm34.ManyToOne)(() => Attribute, { onDelete: "CASCADE" }),
7103
- (0, import_typeorm34.JoinColumn)({ name: "attributeId" })
7682
+ (0, import_typeorm35.ManyToOne)(() => Attribute, { onDelete: "CASCADE" }),
7683
+ (0, import_typeorm35.JoinColumn)({ name: "attributeId" })
7104
7684
  ], ProductAttribute.prototype, "attribute", 2);
7105
7685
  ProductAttribute = __decorateClass([
7106
- (0, import_typeorm34.Entity)("product_attributes")
7686
+ (0, import_typeorm35.Entity)("product_attributes")
7107
7687
  ], ProductAttribute);
7108
7688
 
7109
7689
  // src/entities/tax.entity.ts
7110
- var import_typeorm35 = require("typeorm");
7690
+ var import_typeorm36 = require("typeorm");
7111
7691
  var Tax = class {
7112
7692
  id;
7113
7693
  name;
@@ -7126,56 +7706,56 @@ var Tax = class {
7126
7706
  deletedBy;
7127
7707
  };
7128
7708
  __decorateClass([
7129
- (0, import_typeorm35.PrimaryGeneratedColumn)()
7709
+ (0, import_typeorm36.PrimaryGeneratedColumn)()
7130
7710
  ], Tax.prototype, "id", 2);
7131
7711
  __decorateClass([
7132
- (0, import_typeorm35.Column)("varchar")
7712
+ (0, import_typeorm36.Column)("varchar")
7133
7713
  ], Tax.prototype, "name", 2);
7134
7714
  __decorateClass([
7135
- (0, import_typeorm35.Column)("varchar", { unique: true })
7715
+ (0, import_typeorm36.Column)("varchar", { unique: true })
7136
7716
  ], Tax.prototype, "slug", 2);
7137
7717
  __decorateClass([
7138
- (0, import_typeorm35.Column)("decimal", { precision: 5, scale: 2 })
7718
+ (0, import_typeorm36.Column)("decimal", { precision: 5, scale: 2 })
7139
7719
  ], Tax.prototype, "rate", 2);
7140
7720
  __decorateClass([
7141
- (0, import_typeorm35.Column)("boolean", { default: false })
7721
+ (0, import_typeorm36.Column)("boolean", { default: false })
7142
7722
  ], Tax.prototype, "isDefault", 2);
7143
7723
  __decorateClass([
7144
- (0, import_typeorm35.Column)("text", { nullable: true })
7724
+ (0, import_typeorm36.Column)("text", { nullable: true })
7145
7725
  ], Tax.prototype, "description", 2);
7146
7726
  __decorateClass([
7147
- (0, import_typeorm35.Column)("boolean", { default: true })
7727
+ (0, import_typeorm36.Column)("boolean", { default: true })
7148
7728
  ], Tax.prototype, "active", 2);
7149
7729
  __decorateClass([
7150
- (0, import_typeorm35.Column)("jsonb", { nullable: true })
7730
+ (0, import_typeorm36.Column)("jsonb", { nullable: true })
7151
7731
  ], Tax.prototype, "metadata", 2);
7152
7732
  __decorateClass([
7153
- (0, import_typeorm35.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7733
+ (0, import_typeorm36.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7154
7734
  ], Tax.prototype, "createdAt", 2);
7155
7735
  __decorateClass([
7156
- (0, import_typeorm35.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7736
+ (0, import_typeorm36.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7157
7737
  ], Tax.prototype, "updatedAt", 2);
7158
7738
  __decorateClass([
7159
- (0, import_typeorm35.Column)({ type: "timestamp", nullable: true })
7739
+ (0, import_typeorm36.Column)({ type: "timestamp", nullable: true })
7160
7740
  ], Tax.prototype, "deletedAt", 2);
7161
7741
  __decorateClass([
7162
- (0, import_typeorm35.Column)("boolean", { default: false })
7742
+ (0, import_typeorm36.Column)("boolean", { default: false })
7163
7743
  ], Tax.prototype, "deleted", 2);
7164
7744
  __decorateClass([
7165
- (0, import_typeorm35.Column)("int", { nullable: true })
7745
+ (0, import_typeorm36.Column)("int", { nullable: true })
7166
7746
  ], Tax.prototype, "createdBy", 2);
7167
7747
  __decorateClass([
7168
- (0, import_typeorm35.Column)("int", { nullable: true })
7748
+ (0, import_typeorm36.Column)("int", { nullable: true })
7169
7749
  ], Tax.prototype, "updatedBy", 2);
7170
7750
  __decorateClass([
7171
- (0, import_typeorm35.Column)("int", { nullable: true })
7751
+ (0, import_typeorm36.Column)("int", { nullable: true })
7172
7752
  ], Tax.prototype, "deletedBy", 2);
7173
7753
  Tax = __decorateClass([
7174
- (0, import_typeorm35.Entity)("taxes")
7754
+ (0, import_typeorm36.Entity)("taxes")
7175
7755
  ], Tax);
7176
7756
 
7177
7757
  // src/entities/product-tax.entity.ts
7178
- var import_typeorm36 = require("typeorm");
7758
+ var import_typeorm37 = require("typeorm");
7179
7759
  var ProductTax = class {
7180
7760
  id;
7181
7761
  productId;
@@ -7187,37 +7767,37 @@ var ProductTax = class {
7187
7767
  tax;
7188
7768
  };
7189
7769
  __decorateClass([
7190
- (0, import_typeorm36.PrimaryGeneratedColumn)()
7770
+ (0, import_typeorm37.PrimaryGeneratedColumn)()
7191
7771
  ], ProductTax.prototype, "id", 2);
7192
7772
  __decorateClass([
7193
- (0, import_typeorm36.Column)("int")
7773
+ (0, import_typeorm37.Column)("int")
7194
7774
  ], ProductTax.prototype, "productId", 2);
7195
7775
  __decorateClass([
7196
- (0, import_typeorm36.Column)("int")
7776
+ (0, import_typeorm37.Column)("int")
7197
7777
  ], ProductTax.prototype, "taxId", 2);
7198
7778
  __decorateClass([
7199
- (0, import_typeorm36.Column)("decimal", { precision: 5, scale: 2, nullable: true })
7779
+ (0, import_typeorm37.Column)("decimal", { precision: 5, scale: 2, nullable: true })
7200
7780
  ], ProductTax.prototype, "rate", 2);
7201
7781
  __decorateClass([
7202
- (0, import_typeorm36.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7782
+ (0, import_typeorm37.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7203
7783
  ], ProductTax.prototype, "createdAt", 2);
7204
7784
  __decorateClass([
7205
- (0, import_typeorm36.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7785
+ (0, import_typeorm37.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7206
7786
  ], ProductTax.prototype, "updatedAt", 2);
7207
7787
  __decorateClass([
7208
- (0, import_typeorm36.ManyToOne)(() => Product, (p) => p.taxes, { onDelete: "CASCADE" }),
7209
- (0, import_typeorm36.JoinColumn)({ name: "productId" })
7788
+ (0, import_typeorm37.ManyToOne)(() => Product, (p) => p.taxes, { onDelete: "CASCADE" }),
7789
+ (0, import_typeorm37.JoinColumn)({ name: "productId" })
7210
7790
  ], ProductTax.prototype, "product", 2);
7211
7791
  __decorateClass([
7212
- (0, import_typeorm36.ManyToOne)(() => Tax, { onDelete: "CASCADE" }),
7213
- (0, import_typeorm36.JoinColumn)({ name: "taxId" })
7792
+ (0, import_typeorm37.ManyToOne)(() => Tax, { onDelete: "CASCADE" }),
7793
+ (0, import_typeorm37.JoinColumn)({ name: "taxId" })
7214
7794
  ], ProductTax.prototype, "tax", 2);
7215
7795
  ProductTax = __decorateClass([
7216
- (0, import_typeorm36.Entity)("product_taxes")
7796
+ (0, import_typeorm37.Entity)("product_taxes")
7217
7797
  ], ProductTax);
7218
7798
 
7219
7799
  // src/entities/order-item.entity.ts
7220
- var import_typeorm37 = require("typeorm");
7800
+ var import_typeorm38 = require("typeorm");
7221
7801
  var OrderItem = class {
7222
7802
  id;
7223
7803
  orderId;
@@ -7238,67 +7818,67 @@ var OrderItem = class {
7238
7818
  product;
7239
7819
  };
7240
7820
  __decorateClass([
7241
- (0, import_typeorm37.PrimaryGeneratedColumn)()
7821
+ (0, import_typeorm38.PrimaryGeneratedColumn)()
7242
7822
  ], OrderItem.prototype, "id", 2);
7243
7823
  __decorateClass([
7244
- (0, import_typeorm37.Column)("int")
7824
+ (0, import_typeorm38.Column)("int")
7245
7825
  ], OrderItem.prototype, "orderId", 2);
7246
7826
  __decorateClass([
7247
- (0, import_typeorm37.Column)("int")
7827
+ (0, import_typeorm38.Column)("int")
7248
7828
  ], OrderItem.prototype, "productId", 2);
7249
7829
  __decorateClass([
7250
- (0, import_typeorm37.Column)("int", { default: 1 })
7830
+ (0, import_typeorm38.Column)("int", { default: 1 })
7251
7831
  ], OrderItem.prototype, "quantity", 2);
7252
7832
  __decorateClass([
7253
- (0, import_typeorm37.Column)("decimal", { precision: 12, scale: 2 })
7833
+ (0, import_typeorm38.Column)("decimal", { precision: 12, scale: 2 })
7254
7834
  ], OrderItem.prototype, "unitPrice", 2);
7255
7835
  __decorateClass([
7256
- (0, import_typeorm37.Column)("decimal", { precision: 12, scale: 2, default: 0 })
7836
+ (0, import_typeorm38.Column)("decimal", { precision: 12, scale: 2, default: 0 })
7257
7837
  ], OrderItem.prototype, "tax", 2);
7258
7838
  __decorateClass([
7259
- (0, import_typeorm37.Column)("decimal", { precision: 12, scale: 2 })
7839
+ (0, import_typeorm38.Column)("decimal", { precision: 12, scale: 2 })
7260
7840
  ], OrderItem.prototype, "total", 2);
7261
7841
  __decorateClass([
7262
- (0, import_typeorm37.Column)("varchar", { nullable: true })
7842
+ (0, import_typeorm38.Column)("varchar", { nullable: true })
7263
7843
  ], OrderItem.prototype, "hsn", 2);
7264
7844
  __decorateClass([
7265
- (0, import_typeorm37.Column)("varchar", { nullable: true })
7845
+ (0, import_typeorm38.Column)("varchar", { nullable: true })
7266
7846
  ], OrderItem.prototype, "uom", 2);
7267
7847
  __decorateClass([
7268
- (0, import_typeorm37.Column)("varchar", { nullable: true })
7848
+ (0, import_typeorm38.Column)("varchar", { nullable: true })
7269
7849
  ], OrderItem.prototype, "productType", 2);
7270
7850
  __decorateClass([
7271
- (0, import_typeorm37.Column)("decimal", { precision: 5, scale: 2, nullable: true })
7851
+ (0, import_typeorm38.Column)("decimal", { precision: 5, scale: 2, nullable: true })
7272
7852
  ], OrderItem.prototype, "taxRate", 2);
7273
7853
  __decorateClass([
7274
- (0, import_typeorm37.Column)("varchar", { nullable: true })
7854
+ (0, import_typeorm38.Column)("varchar", { nullable: true })
7275
7855
  ], OrderItem.prototype, "taxCode", 2);
7276
7856
  __decorateClass([
7277
- (0, import_typeorm37.Column)("jsonb", { nullable: true })
7857
+ (0, import_typeorm38.Column)("jsonb", { nullable: true })
7278
7858
  ], OrderItem.prototype, "metadata", 2);
7279
7859
  __decorateClass([
7280
- (0, import_typeorm37.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7860
+ (0, import_typeorm38.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7281
7861
  ], OrderItem.prototype, "createdAt", 2);
7282
7862
  __decorateClass([
7283
- (0, import_typeorm37.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7863
+ (0, import_typeorm38.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7284
7864
  ], OrderItem.prototype, "updatedAt", 2);
7285
7865
  __decorateClass([
7286
- (0, import_typeorm37.ManyToOne)(() => Order, (o) => o.items, { onDelete: "CASCADE" }),
7287
- (0, import_typeorm37.JoinColumn)({ name: "orderId" })
7866
+ (0, import_typeorm38.ManyToOne)(() => Order, (o) => o.items, { onDelete: "CASCADE" }),
7867
+ (0, import_typeorm38.JoinColumn)({ name: "orderId" })
7288
7868
  ], OrderItem.prototype, "order", 2);
7289
7869
  __decorateClass([
7290
- (0, import_typeorm37.ManyToOne)(() => Product, { onDelete: "CASCADE" }),
7291
- (0, import_typeorm37.JoinColumn)({ name: "productId" })
7870
+ (0, import_typeorm38.ManyToOne)(() => Product, { onDelete: "CASCADE" }),
7871
+ (0, import_typeorm38.JoinColumn)({ name: "productId" })
7292
7872
  ], OrderItem.prototype, "product", 2);
7293
7873
  OrderItem = __decorateClass([
7294
- (0, import_typeorm37.Entity)("order_items")
7874
+ (0, import_typeorm38.Entity)("order_items")
7295
7875
  ], OrderItem);
7296
7876
 
7297
7877
  // src/entities/knowledge-base-document.entity.ts
7298
- var import_typeorm39 = require("typeorm");
7878
+ var import_typeorm40 = require("typeorm");
7299
7879
 
7300
7880
  // src/entities/knowledge-base-chunk.entity.ts
7301
- var import_typeorm38 = require("typeorm");
7881
+ var import_typeorm39 = require("typeorm");
7302
7882
  var KnowledgeBaseChunk = class {
7303
7883
  id;
7304
7884
  documentId;
@@ -7308,26 +7888,26 @@ var KnowledgeBaseChunk = class {
7308
7888
  document;
7309
7889
  };
7310
7890
  __decorateClass([
7311
- (0, import_typeorm38.PrimaryGeneratedColumn)()
7891
+ (0, import_typeorm39.PrimaryGeneratedColumn)()
7312
7892
  ], KnowledgeBaseChunk.prototype, "id", 2);
7313
7893
  __decorateClass([
7314
- (0, import_typeorm38.Column)("int")
7894
+ (0, import_typeorm39.Column)("int")
7315
7895
  ], KnowledgeBaseChunk.prototype, "documentId", 2);
7316
7896
  __decorateClass([
7317
- (0, import_typeorm38.Column)("text")
7897
+ (0, import_typeorm39.Column)("text")
7318
7898
  ], KnowledgeBaseChunk.prototype, "content", 2);
7319
7899
  __decorateClass([
7320
- (0, import_typeorm38.Column)("int", { default: 0 })
7900
+ (0, import_typeorm39.Column)("int", { default: 0 })
7321
7901
  ], KnowledgeBaseChunk.prototype, "chunkIndex", 2);
7322
7902
  __decorateClass([
7323
- (0, import_typeorm38.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7903
+ (0, import_typeorm39.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7324
7904
  ], KnowledgeBaseChunk.prototype, "createdAt", 2);
7325
7905
  __decorateClass([
7326
- (0, import_typeorm38.ManyToOne)(() => KnowledgeBaseDocument, (d) => d.chunks, { onDelete: "CASCADE" }),
7327
- (0, import_typeorm38.JoinColumn)({ name: "documentId" })
7906
+ (0, import_typeorm39.ManyToOne)(() => KnowledgeBaseDocument, (d) => d.chunks, { onDelete: "CASCADE" }),
7907
+ (0, import_typeorm39.JoinColumn)({ name: "documentId" })
7328
7908
  ], KnowledgeBaseChunk.prototype, "document", 2);
7329
7909
  KnowledgeBaseChunk = __decorateClass([
7330
- (0, import_typeorm38.Entity)("knowledge_base_chunks")
7910
+ (0, import_typeorm39.Entity)("knowledge_base_chunks")
7331
7911
  ], KnowledgeBaseChunk);
7332
7912
 
7333
7913
  // src/entities/knowledge-base-document.entity.ts
@@ -7341,32 +7921,32 @@ var KnowledgeBaseDocument = class {
7341
7921
  chunks;
7342
7922
  };
7343
7923
  __decorateClass([
7344
- (0, import_typeorm39.PrimaryGeneratedColumn)()
7924
+ (0, import_typeorm40.PrimaryGeneratedColumn)()
7345
7925
  ], KnowledgeBaseDocument.prototype, "id", 2);
7346
7926
  __decorateClass([
7347
- (0, import_typeorm39.Column)("varchar")
7927
+ (0, import_typeorm40.Column)("varchar")
7348
7928
  ], KnowledgeBaseDocument.prototype, "name", 2);
7349
7929
  __decorateClass([
7350
- (0, import_typeorm39.Column)("varchar", { nullable: true })
7930
+ (0, import_typeorm40.Column)("varchar", { nullable: true })
7351
7931
  ], KnowledgeBaseDocument.prototype, "sourceUrl", 2);
7352
7932
  __decorateClass([
7353
- (0, import_typeorm39.Column)("text")
7933
+ (0, import_typeorm40.Column)("text")
7354
7934
  ], KnowledgeBaseDocument.prototype, "content", 2);
7355
7935
  __decorateClass([
7356
- (0, import_typeorm39.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7936
+ (0, import_typeorm40.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7357
7937
  ], KnowledgeBaseDocument.prototype, "createdAt", 2);
7358
7938
  __decorateClass([
7359
- (0, import_typeorm39.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7939
+ (0, import_typeorm40.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7360
7940
  ], KnowledgeBaseDocument.prototype, "updatedAt", 2);
7361
7941
  __decorateClass([
7362
- (0, import_typeorm39.OneToMany)(() => KnowledgeBaseChunk, (c) => c.document)
7942
+ (0, import_typeorm40.OneToMany)(() => KnowledgeBaseChunk, (c) => c.document)
7363
7943
  ], KnowledgeBaseDocument.prototype, "chunks", 2);
7364
7944
  KnowledgeBaseDocument = __decorateClass([
7365
- (0, import_typeorm39.Entity)("knowledge_base_documents")
7945
+ (0, import_typeorm40.Entity)("knowledge_base_documents")
7366
7946
  ], KnowledgeBaseDocument);
7367
7947
 
7368
7948
  // src/entities/cart.entity.ts
7369
- var import_typeorm40 = require("typeorm");
7949
+ var import_typeorm41 = require("typeorm");
7370
7950
  var Cart = class {
7371
7951
  id;
7372
7952
  guestToken;
@@ -7379,39 +7959,39 @@ var Cart = class {
7379
7959
  items;
7380
7960
  };
7381
7961
  __decorateClass([
7382
- (0, import_typeorm40.PrimaryGeneratedColumn)()
7962
+ (0, import_typeorm41.PrimaryGeneratedColumn)()
7383
7963
  ], Cart.prototype, "id", 2);
7384
7964
  __decorateClass([
7385
- (0, import_typeorm40.Column)("varchar", { nullable: true })
7965
+ (0, import_typeorm41.Column)("varchar", { nullable: true })
7386
7966
  ], Cart.prototype, "guestToken", 2);
7387
7967
  __decorateClass([
7388
- (0, import_typeorm40.Column)("int", { nullable: true })
7968
+ (0, import_typeorm41.Column)("int", { nullable: true })
7389
7969
  ], Cart.prototype, "contactId", 2);
7390
7970
  __decorateClass([
7391
- (0, import_typeorm40.Column)("varchar", { default: "INR" })
7971
+ (0, import_typeorm41.Column)("varchar", { default: "INR" })
7392
7972
  ], Cart.prototype, "currency", 2);
7393
7973
  __decorateClass([
7394
- (0, import_typeorm40.Column)({ type: "timestamp", nullable: true })
7974
+ (0, import_typeorm41.Column)({ type: "timestamp", nullable: true })
7395
7975
  ], Cart.prototype, "expiresAt", 2);
7396
7976
  __decorateClass([
7397
- (0, import_typeorm40.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7977
+ (0, import_typeorm41.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7398
7978
  ], Cart.prototype, "createdAt", 2);
7399
7979
  __decorateClass([
7400
- (0, import_typeorm40.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7980
+ (0, import_typeorm41.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7401
7981
  ], Cart.prototype, "updatedAt", 2);
7402
7982
  __decorateClass([
7403
- (0, import_typeorm40.ManyToOne)(() => Contact, { onDelete: "CASCADE" }),
7404
- (0, import_typeorm40.JoinColumn)({ name: "contactId" })
7983
+ (0, import_typeorm41.ManyToOne)(() => Contact, { onDelete: "CASCADE" }),
7984
+ (0, import_typeorm41.JoinColumn)({ name: "contactId" })
7405
7985
  ], Cart.prototype, "contact", 2);
7406
7986
  __decorateClass([
7407
- (0, import_typeorm40.OneToMany)("CartItem", "cart")
7987
+ (0, import_typeorm41.OneToMany)("CartItem", "cart")
7408
7988
  ], Cart.prototype, "items", 2);
7409
7989
  Cart = __decorateClass([
7410
- (0, import_typeorm40.Entity)("carts")
7990
+ (0, import_typeorm41.Entity)("carts")
7411
7991
  ], Cart);
7412
7992
 
7413
7993
  // src/entities/cart-item.entity.ts
7414
- var import_typeorm41 = require("typeorm");
7994
+ var import_typeorm42 = require("typeorm");
7415
7995
  var CartItem = class {
7416
7996
  id;
7417
7997
  cartId;
@@ -7424,40 +8004,40 @@ var CartItem = class {
7424
8004
  product;
7425
8005
  };
7426
8006
  __decorateClass([
7427
- (0, import_typeorm41.PrimaryGeneratedColumn)()
8007
+ (0, import_typeorm42.PrimaryGeneratedColumn)()
7428
8008
  ], CartItem.prototype, "id", 2);
7429
8009
  __decorateClass([
7430
- (0, import_typeorm41.Column)("int")
8010
+ (0, import_typeorm42.Column)("int")
7431
8011
  ], CartItem.prototype, "cartId", 2);
7432
8012
  __decorateClass([
7433
- (0, import_typeorm41.Column)("int")
8013
+ (0, import_typeorm42.Column)("int")
7434
8014
  ], CartItem.prototype, "productId", 2);
7435
8015
  __decorateClass([
7436
- (0, import_typeorm41.Column)("int", { default: 1 })
8016
+ (0, import_typeorm42.Column)("int", { default: 1 })
7437
8017
  ], CartItem.prototype, "quantity", 2);
7438
8018
  __decorateClass([
7439
- (0, import_typeorm41.Column)("jsonb", { nullable: true })
8019
+ (0, import_typeorm42.Column)("jsonb", { nullable: true })
7440
8020
  ], CartItem.prototype, "metadata", 2);
7441
8021
  __decorateClass([
7442
- (0, import_typeorm41.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
8022
+ (0, import_typeorm42.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7443
8023
  ], CartItem.prototype, "createdAt", 2);
7444
8024
  __decorateClass([
7445
- (0, import_typeorm41.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
8025
+ (0, import_typeorm42.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7446
8026
  ], CartItem.prototype, "updatedAt", 2);
7447
8027
  __decorateClass([
7448
- (0, import_typeorm41.ManyToOne)(() => Cart, (c) => c.items, { onDelete: "CASCADE" }),
7449
- (0, import_typeorm41.JoinColumn)({ name: "cartId" })
8028
+ (0, import_typeorm42.ManyToOne)(() => Cart, (c) => c.items, { onDelete: "CASCADE" }),
8029
+ (0, import_typeorm42.JoinColumn)({ name: "cartId" })
7450
8030
  ], CartItem.prototype, "cart", 2);
7451
8031
  __decorateClass([
7452
- (0, import_typeorm41.ManyToOne)(() => Product, { onDelete: "CASCADE" }),
7453
- (0, import_typeorm41.JoinColumn)({ name: "productId" })
8032
+ (0, import_typeorm42.ManyToOne)(() => Product, { onDelete: "CASCADE" }),
8033
+ (0, import_typeorm42.JoinColumn)({ name: "productId" })
7454
8034
  ], CartItem.prototype, "product", 2);
7455
8035
  CartItem = __decorateClass([
7456
- (0, import_typeorm41.Entity)("cart_items")
8036
+ (0, import_typeorm42.Entity)("cart_items")
7457
8037
  ], CartItem);
7458
8038
 
7459
8039
  // src/entities/wishlist.entity.ts
7460
- var import_typeorm42 = require("typeorm");
8040
+ var import_typeorm43 = require("typeorm");
7461
8041
  var Wishlist = class {
7462
8042
  id;
7463
8043
  guestId;
@@ -7469,36 +8049,36 @@ var Wishlist = class {
7469
8049
  items;
7470
8050
  };
7471
8051
  __decorateClass([
7472
- (0, import_typeorm42.PrimaryGeneratedColumn)()
8052
+ (0, import_typeorm43.PrimaryGeneratedColumn)()
7473
8053
  ], Wishlist.prototype, "id", 2);
7474
8054
  __decorateClass([
7475
- (0, import_typeorm42.Column)("varchar", { nullable: true })
8055
+ (0, import_typeorm43.Column)("varchar", { nullable: true })
7476
8056
  ], Wishlist.prototype, "guestId", 2);
7477
8057
  __decorateClass([
7478
- (0, import_typeorm42.Column)("int", { nullable: true })
8058
+ (0, import_typeorm43.Column)("int", { nullable: true })
7479
8059
  ], Wishlist.prototype, "contactId", 2);
7480
8060
  __decorateClass([
7481
- (0, import_typeorm42.Column)("varchar", { default: "default" })
8061
+ (0, import_typeorm43.Column)("varchar", { default: "default" })
7482
8062
  ], Wishlist.prototype, "name", 2);
7483
8063
  __decorateClass([
7484
- (0, import_typeorm42.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
8064
+ (0, import_typeorm43.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7485
8065
  ], Wishlist.prototype, "createdAt", 2);
7486
8066
  __decorateClass([
7487
- (0, import_typeorm42.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
8067
+ (0, import_typeorm43.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7488
8068
  ], Wishlist.prototype, "updatedAt", 2);
7489
8069
  __decorateClass([
7490
- (0, import_typeorm42.ManyToOne)(() => Contact, { onDelete: "CASCADE" }),
7491
- (0, import_typeorm42.JoinColumn)({ name: "contactId" })
8070
+ (0, import_typeorm43.ManyToOne)(() => Contact, { onDelete: "CASCADE" }),
8071
+ (0, import_typeorm43.JoinColumn)({ name: "contactId" })
7492
8072
  ], Wishlist.prototype, "contact", 2);
7493
8073
  __decorateClass([
7494
- (0, import_typeorm42.OneToMany)("WishlistItem", "wishlist")
8074
+ (0, import_typeorm43.OneToMany)("WishlistItem", "wishlist")
7495
8075
  ], Wishlist.prototype, "items", 2);
7496
8076
  Wishlist = __decorateClass([
7497
- (0, import_typeorm42.Entity)("wishlists")
8077
+ (0, import_typeorm43.Entity)("wishlists")
7498
8078
  ], Wishlist);
7499
8079
 
7500
8080
  // src/entities/wishlist-item.entity.ts
7501
- var import_typeorm43 = require("typeorm");
8081
+ var import_typeorm44 = require("typeorm");
7502
8082
  var WishlistItem = class {
7503
8083
  id;
7504
8084
  wishlistId;
@@ -7510,35 +8090,71 @@ var WishlistItem = class {
7510
8090
  product;
7511
8091
  };
7512
8092
  __decorateClass([
7513
- (0, import_typeorm43.PrimaryGeneratedColumn)()
8093
+ (0, import_typeorm44.PrimaryGeneratedColumn)()
7514
8094
  ], WishlistItem.prototype, "id", 2);
7515
8095
  __decorateClass([
7516
- (0, import_typeorm43.Column)("int")
8096
+ (0, import_typeorm44.Column)("int")
7517
8097
  ], WishlistItem.prototype, "wishlistId", 2);
7518
8098
  __decorateClass([
7519
- (0, import_typeorm43.Column)("int")
8099
+ (0, import_typeorm44.Column)("int")
7520
8100
  ], WishlistItem.prototype, "productId", 2);
7521
8101
  __decorateClass([
7522
- (0, import_typeorm43.Column)("jsonb", { nullable: true })
8102
+ (0, import_typeorm44.Column)("jsonb", { nullable: true })
7523
8103
  ], WishlistItem.prototype, "metadata", 2);
7524
8104
  __decorateClass([
7525
- (0, import_typeorm43.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
8105
+ (0, import_typeorm44.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7526
8106
  ], WishlistItem.prototype, "createdAt", 2);
7527
8107
  __decorateClass([
7528
- (0, import_typeorm43.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
8108
+ (0, import_typeorm44.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
7529
8109
  ], WishlistItem.prototype, "updatedAt", 2);
7530
8110
  __decorateClass([
7531
- (0, import_typeorm43.ManyToOne)(() => Wishlist, (w) => w.items, { onDelete: "CASCADE" }),
7532
- (0, import_typeorm43.JoinColumn)({ name: "wishlistId" })
8111
+ (0, import_typeorm44.ManyToOne)(() => Wishlist, (w) => w.items, { onDelete: "CASCADE" }),
8112
+ (0, import_typeorm44.JoinColumn)({ name: "wishlistId" })
7533
8113
  ], WishlistItem.prototype, "wishlist", 2);
7534
8114
  __decorateClass([
7535
- (0, import_typeorm43.ManyToOne)(() => Product, { onDelete: "CASCADE" }),
7536
- (0, import_typeorm43.JoinColumn)({ name: "productId" })
8115
+ (0, import_typeorm44.ManyToOne)(() => Product, { onDelete: "CASCADE" }),
8116
+ (0, import_typeorm44.JoinColumn)({ name: "productId" })
7537
8117
  ], WishlistItem.prototype, "product", 2);
7538
8118
  WishlistItem = __decorateClass([
7539
- (0, import_typeorm43.Entity)("wishlist_items")
8119
+ (0, import_typeorm44.Entity)("wishlist_items")
7540
8120
  ], WishlistItem);
7541
8121
 
8122
+ // src/entities/llm-agent-knowledge-document.entity.ts
8123
+ var import_typeorm45 = require("typeorm");
8124
+ var LlmAgentKnowledgeDocument = class {
8125
+ id;
8126
+ agentId;
8127
+ documentId;
8128
+ createdAt;
8129
+ agent;
8130
+ document;
8131
+ };
8132
+ __decorateClass([
8133
+ (0, import_typeorm45.PrimaryGeneratedColumn)()
8134
+ ], LlmAgentKnowledgeDocument.prototype, "id", 2);
8135
+ __decorateClass([
8136
+ (0, import_typeorm45.Column)("int")
8137
+ ], LlmAgentKnowledgeDocument.prototype, "agentId", 2);
8138
+ __decorateClass([
8139
+ (0, import_typeorm45.Column)("int")
8140
+ ], LlmAgentKnowledgeDocument.prototype, "documentId", 2);
8141
+ __decorateClass([
8142
+ (0, import_typeorm45.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
8143
+ ], LlmAgentKnowledgeDocument.prototype, "createdAt", 2);
8144
+ __decorateClass([
8145
+ (0, import_typeorm45.ManyToOne)(() => LlmAgent, { onDelete: "CASCADE" }),
8146
+ (0, import_typeorm45.JoinColumn)({ name: "agentId" })
8147
+ ], LlmAgentKnowledgeDocument.prototype, "agent", 2);
8148
+ __decorateClass([
8149
+ (0, import_typeorm45.ManyToOne)(() => KnowledgeBaseDocument, { onDelete: "CASCADE" }),
8150
+ (0, import_typeorm45.JoinColumn)({ name: "documentId" })
8151
+ ], LlmAgentKnowledgeDocument.prototype, "document", 2);
8152
+ LlmAgentKnowledgeDocument = __decorateClass([
8153
+ (0, import_typeorm45.Entity)("llm_agent_knowledge_documents"),
8154
+ (0, import_typeorm45.Unique)("UQ_llm_agent_knowledge_agent_document", ["agentId", "documentId"]),
8155
+ (0, import_typeorm45.Index)("IDX_llm_agent_knowledge_agent", ["agentId"])
8156
+ ], LlmAgentKnowledgeDocument);
8157
+
7542
8158
  // src/entities/index.ts
7543
8159
  var CMS_ENTITY_MAP = {
7544
8160
  users: User,
@@ -7578,7 +8194,9 @@ var CMS_ENTITY_MAP = {
7578
8194
  carts: Cart,
7579
8195
  cart_items: CartItem,
7580
8196
  wishlists: Wishlist,
7581
- wishlist_items: WishlistItem
8197
+ wishlist_items: WishlistItem,
8198
+ llm_agents: LlmAgent,
8199
+ llm_agent_knowledge_documents: LlmAgentKnowledgeDocument
7582
8200
  };
7583
8201
 
7584
8202
  // src/auth/permission-entities.ts
@@ -7916,7 +8534,7 @@ function getNextAuthOptions(config) {
7916
8534
  }
7917
8535
 
7918
8536
  // src/api/crud.ts
7919
- var import_typeorm44 = require("typeorm");
8537
+ var import_typeorm46 = require("typeorm");
7920
8538
  var DATE_COLUMN_TYPES = /* @__PURE__ */ new Set([
7921
8539
  "date",
7922
8540
  "datetime",
@@ -7961,7 +8579,7 @@ function pickColumnUpdates(repo, body) {
7961
8579
  }
7962
8580
  function buildSearchWhereClause(repo, search) {
7963
8581
  const cols = new Set(repo.metadata.columns.map((c) => c.propertyName));
7964
- const term = (0, import_typeorm44.ILike)(`%${search}%`);
8582
+ const term = (0, import_typeorm46.ILike)(`%${search}%`);
7965
8583
  const ors = [];
7966
8584
  for (const field of ["name", "title", "slug", "email", "filename"]) {
7967
8585
  if (cols.has(field)) ors.push({ [field]: term });
@@ -8126,10 +8744,10 @@ function createCrudHandler(dataSource, entityMap, options) {
8126
8744
  const inventory = searchParams.get("inventory")?.trim();
8127
8745
  const productWhere = { deleted: false };
8128
8746
  if (statusFilter) productWhere.status = statusFilter;
8129
- if (inventory === "in_stock") productWhere.quantity = (0, import_typeorm44.MoreThan)(0);
8747
+ if (inventory === "in_stock") productWhere.quantity = (0, import_typeorm46.MoreThan)(0);
8130
8748
  if (inventory === "out_of_stock") productWhere.quantity = 0;
8131
8749
  if (search && typeof search === "string" && search.trim()) {
8132
- productWhere.name = (0, import_typeorm44.ILike)(`%${search.trim()}%`);
8750
+ productWhere.name = (0, import_typeorm46.ILike)(`%${search.trim()}%`);
8133
8751
  }
8134
8752
  const [data2, total2] = await repo2.findAndCount({
8135
8753
  where: Object.keys(productWhere).length ? productWhere : void 0,
@@ -8197,7 +8815,7 @@ function createCrudHandler(dataSource, entityMap, options) {
8197
8815
  }
8198
8816
  if (typeFilter) {
8199
8817
  qb.andWhere(
8200
- new import_typeorm44.Brackets((sq) => {
8818
+ new import_typeorm46.Brackets((sq) => {
8201
8819
  sq.where("m.kind = :folderKind", { folderKind: "folder" }).orWhere("m.mimeType LIKE :mtp", {
8202
8820
  mtp: `${typeFilter}/%`
8203
8821
  });
@@ -8753,6 +9371,314 @@ function createUserAuthApiRouter(config) {
8753
9371
  };
8754
9372
  }
8755
9373
 
9374
+ // src/api/llm-agent-knowledge-handlers.ts
9375
+ var import_typeorm47 = require("typeorm");
9376
+ var INGEST_CHUNK_CHARS = 900;
9377
+ var MAX_CHUNKS_PER_UPLOAD = 400;
9378
+ var EMBED_CONCURRENCY = 5;
9379
+ var MAX_PDF_BYTES = 25 * 1024 * 1024;
9380
+ var TEXT_FILE_TYPES = /* @__PURE__ */ new Set(["text/plain", "text/markdown", "application/json"]);
9381
+ var KB_LOG = "[llm-agent-knowledge]";
9382
+ function llmEmbedDebug() {
9383
+ const v = process.env.LLM_EMBED_DEBUG?.toLowerCase();
9384
+ return v === "1" || v === "true" || v === "yes";
9385
+ }
9386
+ function isPdfUpload(mime, fileName) {
9387
+ if (mime === "application/pdf") return true;
9388
+ const n = fileName.toLowerCase();
9389
+ return n.endsWith(".pdf");
9390
+ }
9391
+ async function extractTextFromPdf(buffer) {
9392
+ const pdfParse = await import("pdf-parse");
9393
+ const data = await pdfParse(buffer);
9394
+ return (data?.text ?? "").trim();
9395
+ }
9396
+ async function writeEmbeddingsConcurrent(dataSource, embed, chunks, concurrency) {
9397
+ let next = 0;
9398
+ let written = 0;
9399
+ let failed = 0;
9400
+ let skippedEmpty = 0;
9401
+ async function worker() {
9402
+ for (; ; ) {
9403
+ const i = next++;
9404
+ if (i >= chunks.length) return;
9405
+ const c = chunks[i];
9406
+ try {
9407
+ const emb = await embed(c.content);
9408
+ if (emb?.length) {
9409
+ const vectorStr = "[" + emb.join(",") + "]";
9410
+ await dataSource.query(
9411
+ `UPDATE knowledge_base_chunks SET embedding = $1::vector WHERE id = $2`,
9412
+ [vectorStr, c.id]
9413
+ );
9414
+ written++;
9415
+ } else {
9416
+ skippedEmpty++;
9417
+ if (llmEmbedDebug()) {
9418
+ console.warn(`${KB_LOG} embed() returned empty vector`, { chunkId: c.id });
9419
+ }
9420
+ }
9421
+ } catch (err) {
9422
+ failed++;
9423
+ console.error(`${KB_LOG} embedding DB update failed`, {
9424
+ chunkId: c.id,
9425
+ err: err instanceof Error ? err.message : String(err)
9426
+ });
9427
+ }
9428
+ }
9429
+ }
9430
+ const n = Math.max(1, Math.min(concurrency, chunks.length));
9431
+ await Promise.all(Array.from({ length: n }, () => worker()));
9432
+ const summary = {
9433
+ chunkCount: chunks.length,
9434
+ written,
9435
+ failed,
9436
+ skippedEmpty
9437
+ };
9438
+ if (skippedEmpty > 0 && written === 0) {
9439
+ summary.hint = "embed() returned empty vectors \u2014 see [LLM embed] logs (often HTTP 404 on /v1/embeddings, or wrong response shape).";
9440
+ }
9441
+ console.error(`${KB_LOG} embedding pass finished`, summary);
9442
+ return { written, failed };
9443
+ }
9444
+ function splitIntoChunks(text, maxLen) {
9445
+ const t = text.trim();
9446
+ if (!t) return [];
9447
+ const chunks = [];
9448
+ for (let i = 0; i < t.length; i += maxLen) {
9449
+ chunks.push(t.slice(i, i + maxLen));
9450
+ }
9451
+ return chunks;
9452
+ }
9453
+ async function findAgentBySlug(dataSource, llmAgents, slug) {
9454
+ const repo = dataSource.getRepository(llmAgents);
9455
+ return repo.findOne({
9456
+ where: { slug, deleted: false }
9457
+ });
9458
+ }
9459
+ function createLlmAgentKnowledgeHandlers(config) {
9460
+ const { dataSource, entityMap, getCms, json, requireAuth, requireEntityPermission } = config;
9461
+ const kbDoc = entityMap.knowledge_base_documents;
9462
+ const kbChunk = entityMap.knowledge_base_chunks;
9463
+ const llmAgents = entityMap.llm_agents;
9464
+ const junction = entityMap.llm_agent_knowledge_documents;
9465
+ if (!kbDoc || !kbChunk || !llmAgents || !junction) {
9466
+ return null;
9467
+ }
9468
+ async function gate(req, action) {
9469
+ const a = await requireAuth(req);
9470
+ if (a) return a;
9471
+ if (requireEntityPermission) {
9472
+ const pe = await requireEntityPermission(req, "llm_agents", action);
9473
+ if (pe) return pe;
9474
+ }
9475
+ return null;
9476
+ }
9477
+ return {
9478
+ async list(req, slug) {
9479
+ const denied = await gate(req, "read");
9480
+ if (denied) return denied;
9481
+ try {
9482
+ const agent = await findAgentBySlug(dataSource, llmAgents, slug);
9483
+ if (!agent) return json({ error: "Agent not found" }, { status: 404 });
9484
+ const linkRepo = dataSource.getRepository(junction);
9485
+ const links = await linkRepo.find({ where: { agentId: agent.id } });
9486
+ const docIds = [...new Set(links.map((l) => l.documentId))];
9487
+ if (docIds.length === 0) return json({ documents: [] });
9488
+ const docRepo = dataSource.getRepository(kbDoc);
9489
+ const docs = await docRepo.find({ where: { id: (0, import_typeorm47.In)(docIds) } });
9490
+ const byId = new Map(docs.map((d) => [d.id, d]));
9491
+ const documents = docIds.map((id) => {
9492
+ const d = byId.get(id);
9493
+ return d ? { id: d.id, name: d.name } : null;
9494
+ }).filter(Boolean);
9495
+ return json({ documents });
9496
+ } catch (err) {
9497
+ const msg = err instanceof Error ? err.message : "Failed to list knowledge";
9498
+ return json({ error: msg }, { status: 500 });
9499
+ }
9500
+ },
9501
+ async post(req, slug) {
9502
+ const denied = await gate(req, "update");
9503
+ if (denied) return denied;
9504
+ try {
9505
+ const agent = await findAgentBySlug(dataSource, llmAgents, slug);
9506
+ if (!agent) return json({ error: "Agent not found" }, { status: 404 });
9507
+ let name = "";
9508
+ let text = "";
9509
+ let sourceUrl = null;
9510
+ let existingDocumentId = null;
9511
+ const ct = req.headers.get("content-type") || "";
9512
+ if (ct.includes("application/json")) {
9513
+ const body = await req.json();
9514
+ existingDocumentId = typeof body?.documentId === "number" && Number.isFinite(body.documentId) ? body.documentId : null;
9515
+ name = (body?.name ?? "").trim();
9516
+ text = (body?.text ?? "").trim();
9517
+ sourceUrl = typeof body?.sourceUrl === "string" && body.sourceUrl.trim() ? body.sourceUrl.trim() : null;
9518
+ } else if (ct.includes("multipart/form-data")) {
9519
+ const form = await req.formData();
9520
+ name = form.get("name")?.trim() ?? "";
9521
+ text = form.get("text")?.trim() ?? "";
9522
+ const file = form.get("file");
9523
+ if (file && typeof file !== "string" && "arrayBuffer" in file) {
9524
+ const f = file;
9525
+ const mime = (f.type || "").split(";")[0].trim().toLowerCase();
9526
+ const buf = Buffer.from(await f.arrayBuffer());
9527
+ if (TEXT_FILE_TYPES.has(mime)) {
9528
+ const decoded = buf.toString("utf8");
9529
+ if (!text) text = decoded;
9530
+ } else if (isPdfUpload(mime, f.name || "")) {
9531
+ if (buf.length > MAX_PDF_BYTES) {
9532
+ return json(
9533
+ { error: `PDF too large (max ${Math.floor(MAX_PDF_BYTES / (1024 * 1024))}MB)` },
9534
+ { status: 413 }
9535
+ );
9536
+ }
9537
+ try {
9538
+ const extracted = await extractTextFromPdf(buf);
9539
+ if (!text) text = extracted;
9540
+ } catch {
9541
+ return json(
9542
+ { error: "Could not read PDF text (file may be encrypted, corrupt, or image-only)" },
9543
+ { status: 422 }
9544
+ );
9545
+ }
9546
+ } else {
9547
+ return json(
9548
+ {
9549
+ error: "Unsupported file type; use text/plain, text/markdown, application/json, or application/pdf"
9550
+ },
9551
+ { status: 415 }
9552
+ );
9553
+ }
9554
+ if (!name && f.name) name = f.name.replace(/\.[^/.]+$/, "") || f.name;
9555
+ }
9556
+ } else {
9557
+ return json({ error: "Use application/json or multipart/form-data" }, { status: 400 });
9558
+ }
9559
+ const linkRepo = dataSource.getRepository(junction);
9560
+ if (existingDocumentId != null) {
9561
+ const docRepo2 = dataSource.getRepository(kbDoc);
9562
+ const existing = await docRepo2.findOne({ where: { id: existingDocumentId } });
9563
+ if (!existing) return json({ error: "documentId not found" }, { status: 404 });
9564
+ const dup2 = await linkRepo.findOne({
9565
+ where: { agentId: agent.id, documentId: existingDocumentId }
9566
+ });
9567
+ if (!dup2) {
9568
+ await linkRepo.save(linkRepo.create({ agentId: agent.id, documentId: existingDocumentId }));
9569
+ }
9570
+ return json({ documentId: existingDocumentId, linked: true, created: false });
9571
+ }
9572
+ if (!text) return json({ error: "text or file with text content is required" }, { status: 400 });
9573
+ if (!name) name = "Untitled";
9574
+ const parts = splitIntoChunks(text, INGEST_CHUNK_CHARS);
9575
+ if (parts.length === 0) {
9576
+ return json({ error: "text or file with text content is required" }, { status: 400 });
9577
+ }
9578
+ if (parts.length > MAX_CHUNKS_PER_UPLOAD) {
9579
+ return json(
9580
+ {
9581
+ error: `Document is too large for one upload (${parts.length} chunks; max ${MAX_CHUNKS_PER_UPLOAD}). Split into smaller files.`
9582
+ },
9583
+ { status: 413 }
9584
+ );
9585
+ }
9586
+ const docRepo = dataSource.getRepository(kbDoc);
9587
+ const chunkRepo = dataSource.getRepository(kbChunk);
9588
+ const now = /* @__PURE__ */ new Date();
9589
+ const doc = await docRepo.save(
9590
+ docRepo.create({ name, content: text, sourceUrl, createdAt: now, updatedAt: now })
9591
+ );
9592
+ const docId = doc.id;
9593
+ const chunkRows = parts.map(
9594
+ (content, i) => chunkRepo.create({ documentId: docId, content, chunkIndex: i, createdAt: now })
9595
+ );
9596
+ const savedList = await chunkRepo.save(chunkRows);
9597
+ const savedChunks = savedList.map(
9598
+ (row, i) => ({
9599
+ id: row.id,
9600
+ content: parts[i]
9601
+ })
9602
+ );
9603
+ const dup = await linkRepo.findOne({ where: { agentId: agent.id, documentId: docId } });
9604
+ if (!dup) {
9605
+ await linkRepo.save(linkRepo.create({ agentId: agent.id, documentId: docId }));
9606
+ }
9607
+ let embeddingsWritten = 0;
9608
+ let embeddingsFailed = 0;
9609
+ try {
9610
+ const cms = await getCms();
9611
+ const llm = cms.getPlugin("llm");
9612
+ if (llm?.embed && savedChunks.length > 0) {
9613
+ console.info(`${KB_LOG} starting embedding pass`, { slug, chunkCount: savedChunks.length });
9614
+ const embedBound = (text2) => llm.embed(text2);
9615
+ const { written, failed } = await writeEmbeddingsConcurrent(
9616
+ dataSource,
9617
+ embedBound,
9618
+ savedChunks,
9619
+ EMBED_CONCURRENCY
9620
+ );
9621
+ embeddingsWritten = written;
9622
+ embeddingsFailed = failed;
9623
+ } else {
9624
+ console.error(`${KB_LOG} embeddings skipped`, {
9625
+ slug,
9626
+ hasLlmPlugin: !!llm,
9627
+ hasEmbed: typeof llm?.embed === "function",
9628
+ chunkCount: savedChunks.length,
9629
+ 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
9630
+ });
9631
+ }
9632
+ } catch (embErr) {
9633
+ const detail = embErr instanceof Error ? embErr.message : String(embErr);
9634
+ console.error(`${KB_LOG} embedding step threw before/during batch`, { slug, detail, embErr });
9635
+ return json(
9636
+ {
9637
+ documentId: docId,
9638
+ chunkCount: savedChunks.length,
9639
+ created: true,
9640
+ linked: true,
9641
+ embeddingsWritten: 0,
9642
+ embeddingsFailed: savedChunks.length,
9643
+ warning: "Document saved and linked; embedding step failed.",
9644
+ detail
9645
+ },
9646
+ { status: 201 }
9647
+ );
9648
+ }
9649
+ return json({
9650
+ documentId: docId,
9651
+ chunkCount: savedChunks.length,
9652
+ created: true,
9653
+ linked: true,
9654
+ embeddingsWritten,
9655
+ embeddingsFailed
9656
+ });
9657
+ } catch (err) {
9658
+ const msg = err instanceof Error ? err.message : "Failed to ingest knowledge";
9659
+ const name = err instanceof Error ? err.name : "";
9660
+ return json({ error: msg, errorName: name || void 0 }, { status: 500 });
9661
+ }
9662
+ },
9663
+ async unlink(req, slug, documentIdStr) {
9664
+ const denied = await gate(req, "update");
9665
+ if (denied) return denied;
9666
+ const documentId = parseInt(documentIdStr, 10);
9667
+ if (!Number.isFinite(documentId)) return json({ error: "Invalid document id" }, { status: 400 });
9668
+ try {
9669
+ const agent = await findAgentBySlug(dataSource, llmAgents, slug);
9670
+ if (!agent) return json({ error: "Agent not found" }, { status: 404 });
9671
+ const linkRepo = dataSource.getRepository(junction);
9672
+ await linkRepo.delete({ agentId: agent.id, documentId });
9673
+ return json({ ok: true });
9674
+ } catch (err) {
9675
+ const msg = err instanceof Error ? err.message : "Failed to unlink";
9676
+ return json({ error: msg }, { status: 500 });
9677
+ }
9678
+ }
9679
+ };
9680
+ }
9681
+
8756
9682
  // src/api/message-template-admin-handlers.ts
8757
9683
  init_sms_defaults();
8758
9684
  function createSmsMessageTemplateHandlers(config) {
@@ -9002,6 +9928,26 @@ function createAdminRolesHandlers(config) {
9002
9928
  }
9003
9929
 
9004
9930
  // src/api/cms-api-handler.ts
9931
+ var KNOWLEDGE_SUFFIX = "knowledge";
9932
+ function matchLlmAgentKnowledgeRoute(path) {
9933
+ const p = path[0] === "api" ? path.slice(1) : path;
9934
+ if (p[0] !== "llm_agents" || p.length < 2) return null;
9935
+ const seg1 = p[1];
9936
+ if (!seg1) return null;
9937
+ if (p[2] === KNOWLEDGE_SUFFIX) {
9938
+ return {
9939
+ slug: seg1,
9940
+ documentId: p.length >= 4 ? p[3] : void 0
9941
+ };
9942
+ }
9943
+ if (seg1.endsWith(KNOWLEDGE_SUFFIX) && seg1.length > KNOWLEDGE_SUFFIX.length) {
9944
+ const slug = seg1.slice(0, -KNOWLEDGE_SUFFIX.length);
9945
+ if (!slug) return null;
9946
+ if (p.length === 2) return { slug, documentId: void 0 };
9947
+ if (p.length === 3) return { slug, documentId: p[2] };
9948
+ }
9949
+ return null;
9950
+ }
9005
9951
  var DEFAULT_EXCLUDE = /* @__PURE__ */ new Set([
9006
9952
  "users",
9007
9953
  "password_reset_tokens",
@@ -9014,7 +9960,8 @@ var DEFAULT_EXCLUDE = /* @__PURE__ */ new Set([
9014
9960
  "cart_items",
9015
9961
  "wishlists",
9016
9962
  "wishlist_items",
9017
- "message_templates"
9963
+ "message_templates",
9964
+ "llm_agent_knowledge_documents"
9018
9965
  ]);
9019
9966
  function createCmsApiHandler(config) {
9020
9967
  const {
@@ -9038,6 +9985,7 @@ function createCmsApiHandler(config) {
9038
9985
  userProfile,
9039
9986
  settings: settingsConfig,
9040
9987
  chat: chatConfig,
9988
+ llmAgentKnowledge: llmAgentKnowledgeConfig,
9041
9989
  requireEntityPermission: userRequireEntityPermission,
9042
9990
  getSessionUser
9043
9991
  } = config;
@@ -9145,6 +10093,17 @@ function createCmsApiHandler(config) {
9145
10093
  requireEntityPermission: requireEntityPermissionEffective
9146
10094
  });
9147
10095
  const chatHandlers = chatConfig ? createChatHandlers(chatConfig) : null;
10096
+ const llmAgentKnowledgeMerged = llmAgentKnowledgeConfig ?? (chatConfig ? {
10097
+ dataSource: chatConfig.dataSource,
10098
+ entityMap: chatConfig.entityMap,
10099
+ getCms: chatConfig.getCms,
10100
+ json: chatConfig.json,
10101
+ requireAuth: chatConfig.requireAuth
10102
+ } : void 0);
10103
+ const llmAgentKnowledgeHandlers = llmAgentKnowledgeMerged ? createLlmAgentKnowledgeHandlers({
10104
+ ...llmAgentKnowledgeMerged,
10105
+ requireEntityPermission: requireEntityPermissionEffective
10106
+ }) : null;
9148
10107
  function resolveResource(segment) {
9149
10108
  const model = pathToModel(segment);
9150
10109
  return crudResources.includes(model) ? model : segment;
@@ -9256,7 +10215,32 @@ function createCmsApiHandler(config) {
9256
10215
  if (method === "GET") return smsMessageTemplateHandlers.GET(req);
9257
10216
  if (method === "PUT") return smsMessageTemplateHandlers.PUT(req);
9258
10217
  }
10218
+ {
10219
+ const kbMatch = matchLlmAgentKnowledgeRoute(path);
10220
+ if (kbMatch) {
10221
+ if (!llmAgentKnowledgeHandlers) {
10222
+ return config.json(
10223
+ {
10224
+ error: "LLM agent knowledge is not available",
10225
+ 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."
10226
+ },
10227
+ { status: 503 }
10228
+ );
10229
+ }
10230
+ const { slug, documentId } = kbMatch;
10231
+ if (method === "DELETE" && documentId != null && documentId !== "") {
10232
+ return llmAgentKnowledgeHandlers.unlink(req, slug, documentId);
10233
+ }
10234
+ if (method === "GET" && (documentId == null || documentId === "")) {
10235
+ return llmAgentKnowledgeHandlers.list(req, slug);
10236
+ }
10237
+ if (method === "POST" && (documentId == null || documentId === "")) {
10238
+ return llmAgentKnowledgeHandlers.post(req, slug);
10239
+ }
10240
+ }
10241
+ }
9259
10242
  if (path[0] === "chat" && chatHandlers) {
10243
+ if (path.length === 2 && path[1] === "config" && method === "GET") return chatHandlers.publicConfig(req);
9260
10244
  if (path.length === 2 && path[1] === "identify" && method === "POST") return chatHandlers.identify(req);
9261
10245
  if (path.length === 4 && path[1] === "conversations" && path[3] === "messages" && method === "GET") return chatHandlers.getMessages(req, path[2]);
9262
10246
  if (path.length === 2 && path[1] === "messages" && method === "POST") return chatHandlers.postMessage(req);
@@ -9325,7 +10309,7 @@ function createCmsApiHandler(config) {
9325
10309
  }
9326
10310
 
9327
10311
  // src/api/storefront-handlers.ts
9328
- var import_typeorm45 = require("typeorm");
10312
+ var import_typeorm48 = require("typeorm");
9329
10313
 
9330
10314
  // src/lib/is-valid-signup-email.ts
9331
10315
  var MAX_EMAIL = 254;
@@ -9556,7 +10540,7 @@ function createStorefrontApiHandler(config) {
9556
10540
  const u = await userRepo().findOne({ where: { id: userId } });
9557
10541
  if (!u) return null;
9558
10542
  const unclaimed = await contactRepo().findOne({
9559
- where: { email: u.email, userId: (0, import_typeorm45.IsNull)(), deleted: false }
10543
+ where: { email: u.email, userId: (0, import_typeorm48.IsNull)(), deleted: false }
9560
10544
  });
9561
10545
  if (unclaimed) {
9562
10546
  await contactRepo().update(unclaimed.id, { userId });
@@ -10597,7 +11581,7 @@ function createStorefrontApiHandler(config) {
10597
11581
  const previewByOrder = {};
10598
11582
  if (orderIds.length) {
10599
11583
  const oItems = await orderItemRepo().find({
10600
- where: { orderId: (0, import_typeorm45.In)(orderIds) },
11584
+ where: { orderId: (0, import_typeorm48.In)(orderIds) },
10601
11585
  relations: ["product"],
10602
11586
  order: { id: "ASC" }
10603
11587
  });
@@ -10762,6 +11746,7 @@ console.log("\u{1F525} USING LOCAL CMS CORE (index.ts loaded) \u{1F525}");
10762
11746
  FormSubmission,
10763
11747
  KnowledgeBaseChunk,
10764
11748
  KnowledgeBaseDocument,
11749
+ LlmAgent,
10765
11750
  LlmService,
10766
11751
  Media,
10767
11752
  MessageTemplate,
@@ -10811,6 +11796,7 @@ console.log("\u{1F525} USING LOCAL CMS CORE (index.ts loaded) \u{1F525}");
10811
11796
  createForgotPasswordHandler,
10812
11797
  createFormBySlugHandler,
10813
11798
  createInviteAcceptHandler,
11799
+ createLlmAgentKnowledgeHandlers,
10814
11800
  createMediaZipExtractHandler,
10815
11801
  createOtpChallenge,
10816
11802
  createSetPasswordHandler,
@@ -10844,13 +11830,17 @@ console.log("\u{1F525} USING LOCAL CMS CORE (index.ts loaded) \u{1F525}");
10844
11830
  isZipMedia,
10845
11831
  joinRecipientsForSend,
10846
11832
  linkUnclaimedContactToUser,
11833
+ llmAgentToChatAgentOptions,
10847
11834
  llmPlugin,
10848
11835
  loadPublicThemeSettings,
10849
11836
  localStoragePlugin,
10850
11837
  mergeEmailLayoutCompanyDetails,
11838
+ mergeGuardrailsIntoSystemPrompt,
10851
11839
  mergeSeoBySlug,
10852
11840
  normalizePhoneE164,
10853
11841
  parseEmailRecipientsFromConfig,
11842
+ parseHfInferenceEmbeddingBody,
11843
+ parseLlmAgentValidationRules,
10854
11844
  paymentPlugin,
10855
11845
  permissionRowsToRecord,
10856
11846
  queueEmail,
@@ -10882,6 +11872,8 @@ console.log("\u{1F525} USING LOCAL CMS CORE (index.ts loaded) \u{1F525}");
10882
11872
  smsPlugin,
10883
11873
  truncateText,
10884
11874
  validateSlug,
11875
+ validateUserMessageAgainstAgentRules,
11876
+ validateUserMessageAgainstStructuredRules,
10885
11877
  verifyAndConsumeOtpChallenge,
10886
11878
  verifyOtpCodeHash
10887
11879
  });