@infuro/cms-core 1.0.20 → 1.0.21

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/api.cjs CHANGED
@@ -530,6 +530,13 @@ async function queueErpProductUpsertIfEnabled(cms, dataSource, entityMap, produc
530
530
  }
531
531
 
532
532
  // src/api/crud.ts
533
+ var CRUD_LOG = "[cms-crud]";
534
+ function logCrudClientError(op, detail) {
535
+ console.warn(CRUD_LOG, op, detail);
536
+ }
537
+ function logCrudServerError(op, detail) {
538
+ console.error(CRUD_LOG, op, detail);
539
+ }
533
540
  var DATE_COLUMN_TYPES = /* @__PURE__ */ new Set([
534
541
  "date",
535
542
  "datetime",
@@ -641,6 +648,13 @@ function createCrudHandler(dataSource, entityMap, options) {
641
648
  if (authError) return authError;
642
649
  const entity = entityMap[resource];
643
650
  if (!resource || !entity) {
651
+ logCrudClientError("GET list", {
652
+ reason: "invalid_resource",
653
+ resource,
654
+ hasEntity: Boolean(entity),
655
+ entityMapHasLlmAgents: Boolean(entityMap.llm_agents),
656
+ entityMapKeyCount: Object.keys(entityMap).length
657
+ });
644
658
  return json({ error: "Invalid resource" }, { status: 400 });
645
659
  }
646
660
  const { searchParams } = new URL(req.url);
@@ -848,12 +862,22 @@ function createCrudHandler(dataSource, entityMap, options) {
848
862
  }
849
863
  }
850
864
  where = mergeDeletedFalseWhere(repo, where);
851
- const [data, total] = await repo.findAndCount({
852
- skip,
853
- take: limit,
854
- order: { [sortField]: sortOrder },
855
- where
856
- });
865
+ let data;
866
+ let total;
867
+ try {
868
+ const r = await repo.findAndCount({
869
+ skip,
870
+ take: limit,
871
+ order: { [sortField]: sortOrder },
872
+ where
873
+ });
874
+ data = r[0];
875
+ total = r[1];
876
+ } catch (err) {
877
+ const message = err instanceof Error ? err.message : String(err);
878
+ logCrudServerError("GET list query failed", { resource, sortField, sortOrder, message });
879
+ throw err;
880
+ }
857
881
  return json({ total, page, limit, totalPages: Math.ceil(total / limit), data });
858
882
  },
859
883
  async POST(req, resource) {
@@ -861,12 +885,25 @@ function createCrudHandler(dataSource, entityMap, options) {
861
885
  if (authError) return authError;
862
886
  const entity = entityMap[resource];
863
887
  if (!resource || !entity) {
888
+ logCrudClientError("POST create", {
889
+ reason: "invalid_resource",
890
+ resource,
891
+ hasEntity: Boolean(entity),
892
+ entityMapHasLlmAgents: Boolean(entityMap.llm_agents)
893
+ });
864
894
  return json({ error: "Invalid resource" }, { status: 400 });
865
895
  }
866
- const body = await req.json();
867
- if (!body || typeof body !== "object" || Object.keys(body).length === 0) {
896
+ const rawPostBody = await req.json();
897
+ if (!rawPostBody || typeof rawPostBody !== "object" || Object.keys(rawPostBody).length === 0) {
898
+ logCrudClientError("POST create", {
899
+ reason: "invalid_request_payload",
900
+ resource,
901
+ rawType: rawPostBody == null ? "nullish" : typeof rawPostBody,
902
+ keyCount: rawPostBody && typeof rawPostBody === "object" ? Object.keys(rawPostBody).length : 0
903
+ });
868
904
  return json({ error: "Invalid request payload" }, { status: 400 });
869
905
  }
906
+ const body = rawPostBody;
870
907
  if (resource === "media") {
871
908
  const b = body;
872
909
  const kind = b.kind === "folder" ? "folder" : "file";
@@ -900,8 +937,24 @@ function createCrudHandler(dataSource, entityMap, options) {
900
937
  }
901
938
  }
902
939
  const repo = dataSource.getRepository(entity);
903
- sanitizeBodyForEntity(repo, body);
904
- const created = await repo.save(repo.create(body));
940
+ const persistBody = resource === "media" ? body : pickColumnUpdates(repo, body);
941
+ if (resource !== "media" && Object.keys(persistBody).length === 0) {
942
+ logCrudClientError("POST create", {
943
+ reason: "no_scalar_columns_after_pick",
944
+ resource,
945
+ incomingKeys: Object.keys(body)
946
+ });
947
+ return json({ error: "Invalid request payload" }, { status: 400 });
948
+ }
949
+ sanitizeBodyForEntity(repo, persistBody);
950
+ let created;
951
+ try {
952
+ created = await repo.save(repo.create(persistBody));
953
+ } catch (err) {
954
+ const message = err instanceof Error ? err.message : String(err);
955
+ logCrudServerError("POST create save failed", { resource, message, persistKeys: Object.keys(persistBody) });
956
+ throw err;
957
+ }
905
958
  if (resource === "contacts") {
906
959
  await syncContactRowToErp(created);
907
960
  }
@@ -916,6 +969,7 @@ function createCrudHandler(dataSource, entityMap, options) {
916
969
  if (authError) return authError;
917
970
  const entity = entityMap[resource];
918
971
  if (!resource || !entity) {
972
+ logCrudClientError("GET_METADATA", { reason: "invalid_resource", resource });
919
973
  return json({ error: "Invalid resource" }, { status: 400 });
920
974
  }
921
975
  const repo = dataSource.getRepository(entity);
@@ -947,11 +1001,18 @@ function createCrudHandler(dataSource, entityMap, options) {
947
1001
  if (authError) return authError;
948
1002
  const entity = entityMap[resource];
949
1003
  if (!resource || !entity) {
1004
+ logCrudClientError("BULK_POST", { reason: "invalid_resource", resource });
950
1005
  return json({ error: "Invalid resource" }, { status: 400 });
951
1006
  }
952
1007
  const body = await req.json();
953
1008
  const { records, upsertKey = "id" } = body;
954
1009
  if (!Array.isArray(records) || records.length === 0) {
1010
+ logCrudClientError("BULK_POST", {
1011
+ reason: "records_required",
1012
+ resource,
1013
+ recordsIsArray: Array.isArray(records),
1014
+ recordCount: Array.isArray(records) ? records.length : 0
1015
+ });
955
1016
  return json({ error: "Records array is required" }, { status: 400 });
956
1017
  }
957
1018
  const repo = dataSource.getRepository(entity);
@@ -970,6 +1031,7 @@ function createCrudHandler(dataSource, entityMap, options) {
970
1031
  });
971
1032
  } catch (error) {
972
1033
  const message = error instanceof Error ? error.message : "Bulk import failed";
1034
+ logCrudClientError("BULK_POST upsert failed", { resource, upsertKey, message });
973
1035
  return json({ error: message }, { status: 400 });
974
1036
  }
975
1037
  },
@@ -978,6 +1040,7 @@ function createCrudHandler(dataSource, entityMap, options) {
978
1040
  if (authError) return authError;
979
1041
  const entity = entityMap[resource];
980
1042
  if (!resource || !entity) {
1043
+ logCrudClientError("GET_EXPORT", { reason: "invalid_resource", resource });
981
1044
  return json({ error: "Invalid resource" }, { status: 400 });
982
1045
  }
983
1046
  const { searchParams } = new URL(req.url);
@@ -1032,7 +1095,10 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
1032
1095
  const authError = await authz(req, resource, "read");
1033
1096
  if (authError) return authError;
1034
1097
  const entity = entityMap[resource];
1035
- if (!entity) return json({ error: "Invalid resource" }, { status: 400 });
1098
+ if (!entity) {
1099
+ logCrudClientError("GET by id", { reason: "invalid_resource", resource, id });
1100
+ return json({ error: "Invalid resource" }, { status: 400 });
1101
+ }
1036
1102
  const repo = dataSource.getRepository(entity);
1037
1103
  if (resource === "orders") {
1038
1104
  const order = await repo.findOne({
@@ -1091,7 +1157,10 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
1091
1157
  const authError = await authz(req, resource, "update");
1092
1158
  if (authError) return authError;
1093
1159
  const entity = entityMap[resource];
1094
- if (!entity) return json({ error: "Invalid resource" }, { status: 400 });
1160
+ if (!entity) {
1161
+ logCrudClientError("PUT by id", { reason: "invalid_resource", resource, id });
1162
+ return json({ error: "Invalid resource" }, { status: 400 });
1163
+ }
1095
1164
  const rawBody = await req.json();
1096
1165
  const repo = dataSource.getRepository(entity);
1097
1166
  const numericId = Number(id);
@@ -1204,7 +1273,10 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
1204
1273
  const authError = await authz(req, resource, "delete");
1205
1274
  if (authError) return authError;
1206
1275
  const entity = entityMap[resource];
1207
- if (!entity) return json({ error: "Invalid resource" }, { status: 400 });
1276
+ if (!entity) {
1277
+ logCrudClientError("DELETE by id", { reason: "invalid_resource", resource, id });
1278
+ return json({ error: "Invalid resource" }, { status: 400 });
1279
+ }
1208
1280
  const repo = dataSource.getRepository(entity);
1209
1281
  const numericId = Number(id);
1210
1282
  if (entityHasSoftDelete(repo)) {
@@ -3104,6 +3176,9 @@ var EMBED_CONCURRENCY = 5;
3104
3176
  var MAX_PDF_BYTES = 25 * 1024 * 1024;
3105
3177
  var TEXT_FILE_TYPES = /* @__PURE__ */ new Set(["text/plain", "text/markdown", "application/json"]);
3106
3178
  var KB_LOG = "[llm-agent-knowledge]";
3179
+ function logKbPipeline(step, meta) {
3180
+ console.info(`${KB_LOG} pipeline`, { step, ...meta });
3181
+ }
3107
3182
  function llmEmbedDebug() {
3108
3183
  const v = process.env.LLM_EMBED_DEBUG?.toLowerCase();
3109
3184
  return v === "1" || v === "true" || v === "yes";
@@ -3118,11 +3193,29 @@ async function extractTextFromPdf(buffer) {
3118
3193
  const data = await pdfParse(buffer);
3119
3194
  return (data?.text ?? "").trim();
3120
3195
  }
3121
- async function writeEmbeddingsConcurrent(dataSource, embed, chunks, concurrency) {
3196
+ async function loadChunksMissingEmbeddings(dataSource, documentId, slug) {
3197
+ const rows = await dataSource.query(
3198
+ `SELECT id, content FROM knowledge_base_chunks WHERE "documentId" = $1 AND embedding IS NULL ORDER BY "chunkIndex" ASC`,
3199
+ [documentId]
3200
+ );
3201
+ const list = rows ?? [];
3202
+ logKbPipeline("07_query_chunks_missing_embedding", {
3203
+ slug,
3204
+ documentId,
3205
+ missingEmbeddingCount: list.length
3206
+ });
3207
+ return list;
3208
+ }
3209
+ async function writeEmbeddingsConcurrent(dataSource, embed, chunks, concurrency, slug) {
3122
3210
  let next = 0;
3123
3211
  let written = 0;
3124
3212
  let failed = 0;
3125
3213
  let skippedEmpty = 0;
3214
+ logKbPipeline("09_embedding_workers_start", {
3215
+ slug,
3216
+ chunkCount: chunks.length,
3217
+ concurrency: Math.max(1, Math.min(concurrency, chunks.length))
3218
+ });
3126
3219
  async function worker() {
3127
3220
  for (; ; ) {
3128
3221
  const i = next++;
@@ -3161,9 +3254,12 @@ async function writeEmbeddingsConcurrent(dataSource, embed, chunks, concurrency)
3161
3254
  skippedEmpty
3162
3255
  };
3163
3256
  if (skippedEmpty > 0 && written === 0) {
3164
- summary.hint = "embed() returned empty vectors \u2014 see [LLM embed] logs (often HTTP 404 on /v1/embeddings, or wrong response shape).";
3257
+ summary.hint = "embed() returned empty vectors \u2014 see [LLM embed] / [LLM embed HF] logs (OpenAI gateway vs @huggingface/inference + legacy HTTP).";
3258
+ }
3259
+ logKbPipeline("10_embedding_workers_finished", { slug, ...summary });
3260
+ if (failed > 0 || skippedEmpty > 0 && written === 0) {
3261
+ console.error(`${KB_LOG} embedding pass finished with issues`, summary);
3165
3262
  }
3166
- console.error(`${KB_LOG} embedding pass finished`, summary);
3167
3263
  return { written, failed };
3168
3264
  }
3169
3265
  function splitIntoChunks(text, maxLen) {
@@ -3199,6 +3295,58 @@ function createLlmAgentKnowledgeHandlers(config) {
3199
3295
  }
3200
3296
  return null;
3201
3297
  }
3298
+ async function runEmbeddingPass(slug, savedChunks) {
3299
+ let embeddingsWritten = 0;
3300
+ let embeddingsFailed = 0;
3301
+ try {
3302
+ logKbPipeline("08_resolve_llm_plugin", { slug, chunkCount: savedChunks.length });
3303
+ const cms = await getCms();
3304
+ const llm = cms.getPlugin("llm");
3305
+ if (llm?.embed && savedChunks.length > 0) {
3306
+ logKbPipeline("08b_embed_fn_available", {
3307
+ slug,
3308
+ chunkCount: savedChunks.length,
3309
+ firstChunkId: savedChunks[0]?.id,
3310
+ lastChunkId: savedChunks[savedChunks.length - 1]?.id
3311
+ });
3312
+ const embedBound = (text) => llm.embed(text);
3313
+ const { written, failed } = await writeEmbeddingsConcurrent(
3314
+ dataSource,
3315
+ embedBound,
3316
+ savedChunks,
3317
+ EMBED_CONCURRENCY,
3318
+ slug
3319
+ );
3320
+ embeddingsWritten = written;
3321
+ embeddingsFailed = failed;
3322
+ } else {
3323
+ logKbPipeline("08c_embed_skipped", {
3324
+ slug,
3325
+ hasLlmPlugin: !!llm,
3326
+ hasEmbed: typeof llm?.embed === "function",
3327
+ chunkCount: savedChunks.length,
3328
+ reason: savedChunks.length === 0 ? "no_chunks" : !llm ? "no_llm_plugin" : "no_embed_method"
3329
+ });
3330
+ console.error(`${KB_LOG} embeddings skipped`, {
3331
+ slug,
3332
+ hasLlmPlugin: !!llm,
3333
+ hasEmbed: typeof llm?.embed === "function",
3334
+ chunkCount: savedChunks.length,
3335
+ 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
3336
+ });
3337
+ }
3338
+ } catch (embErr) {
3339
+ const detail = embErr instanceof Error ? embErr.message : String(embErr);
3340
+ logKbPipeline("08d_embed_pass_exception", { slug, detail });
3341
+ console.error(`${KB_LOG} embedding step threw before/during batch`, { slug, detail, embErr });
3342
+ return {
3343
+ embeddingsWritten: 0,
3344
+ embeddingsFailed: savedChunks.length,
3345
+ embedError: detail
3346
+ };
3347
+ }
3348
+ return { embeddingsWritten, embeddingsFailed };
3349
+ }
3202
3350
  return {
3203
3351
  async list(req, slug) {
3204
3352
  const denied = await gate(req, "read");
@@ -3227,8 +3375,11 @@ function createLlmAgentKnowledgeHandlers(config) {
3227
3375
  const denied = await gate(req, "update");
3228
3376
  if (denied) return denied;
3229
3377
  try {
3378
+ const ct0 = req.headers.get("content-type") || "";
3379
+ logKbPipeline("01_request", { slug, contentType: ct0.slice(0, 80) });
3230
3380
  const agent = await findAgentBySlug(dataSource, llmAgents, slug);
3231
3381
  if (!agent) return json({ error: "Agent not found" }, { status: 404 });
3382
+ logKbPipeline("02_agent_loaded", { slug, agentId: agent.id });
3232
3383
  let name = "";
3233
3384
  let text = "";
3234
3385
  let sourceUrl = null;
@@ -3240,6 +3391,14 @@ function createLlmAgentKnowledgeHandlers(config) {
3240
3391
  name = (body?.name ?? "").trim();
3241
3392
  text = (body?.text ?? "").trim();
3242
3393
  sourceUrl = typeof body?.sourceUrl === "string" && body.sourceUrl.trim() ? body.sourceUrl.trim() : null;
3394
+ logKbPipeline("03_body_parsed", {
3395
+ slug,
3396
+ mode: "json",
3397
+ existingDocumentId,
3398
+ nameLen: name.length,
3399
+ textChars: text.length,
3400
+ hasSourceUrl: !!sourceUrl
3401
+ });
3243
3402
  } else if (ct.includes("multipart/form-data")) {
3244
3403
  const form = await req.formData();
3245
3404
  name = form.get("name")?.trim() ?? "";
@@ -3249,9 +3408,17 @@ function createLlmAgentKnowledgeHandlers(config) {
3249
3408
  const f = file;
3250
3409
  const mime = (f.type || "").split(";")[0].trim().toLowerCase();
3251
3410
  const buf = Buffer.from(await f.arrayBuffer());
3411
+ logKbPipeline("03_body_parsed", {
3412
+ slug,
3413
+ mode: "multipart",
3414
+ fileName: f.name || "(no name)",
3415
+ mime,
3416
+ fileBytes: buf.length
3417
+ });
3252
3418
  if (TEXT_FILE_TYPES.has(mime)) {
3253
3419
  const decoded = buf.toString("utf8");
3254
3420
  if (!text) text = decoded;
3421
+ logKbPipeline("04_file_decoded_text", { slug, mime, textChars: text.length });
3255
3422
  } else if (isPdfUpload(mime, f.name || "")) {
3256
3423
  if (buf.length > MAX_PDF_BYTES) {
3257
3424
  return json(
@@ -3260,8 +3427,10 @@ function createLlmAgentKnowledgeHandlers(config) {
3260
3427
  );
3261
3428
  }
3262
3429
  try {
3430
+ logKbPipeline("04_pdf_extract_start", { slug, fileBytes: buf.length });
3263
3431
  const extracted = await extractTextFromPdf(buf);
3264
3432
  if (!text) text = extracted;
3433
+ logKbPipeline("04_pdf_extract_done", { slug, textChars: text.length });
3265
3434
  } catch {
3266
3435
  return json(
3267
3436
  { error: "Could not read PDF text (file may be encrypted, corrupt, or image-only)" },
@@ -3277,12 +3446,15 @@ function createLlmAgentKnowledgeHandlers(config) {
3277
3446
  );
3278
3447
  }
3279
3448
  if (!name && f.name) name = f.name.replace(/\.[^/.]+$/, "") || f.name;
3449
+ } else {
3450
+ logKbPipeline("03_body_parsed", { slug, mode: "multipart", hasFile: false, textChars: text.length });
3280
3451
  }
3281
3452
  } else {
3282
3453
  return json({ error: "Use application/json or multipart/form-data" }, { status: 400 });
3283
3454
  }
3284
3455
  const linkRepo = dataSource.getRepository(junction);
3285
3456
  if (existingDocumentId != null) {
3457
+ logKbPipeline("05_branch", { slug, branch: "link_existing_document", documentId: existingDocumentId });
3286
3458
  const docRepo2 = dataSource.getRepository(kbDoc);
3287
3459
  const existing = await docRepo2.findOne({ where: { id: existingDocumentId } });
3288
3460
  if (!existing) return json({ error: "documentId not found" }, { status: 404 });
@@ -3291,9 +3463,137 @@ function createLlmAgentKnowledgeHandlers(config) {
3291
3463
  });
3292
3464
  if (!dup2) {
3293
3465
  await linkRepo.save(linkRepo.create({ agentId: agent.id, documentId: existingDocumentId }));
3466
+ logKbPipeline("06_junction_link_created", {
3467
+ slug,
3468
+ agentId: agent.id,
3469
+ documentId: existingDocumentId
3470
+ });
3471
+ } else {
3472
+ logKbPipeline("06_junction_link_exists", {
3473
+ slug,
3474
+ agentId: agent.id,
3475
+ documentId: existingDocumentId
3476
+ });
3477
+ }
3478
+ const chunkRepo2 = dataSource.getRepository(kbChunk);
3479
+ const docRow = existing;
3480
+ const chunkCount = await chunkRepo2.count({ where: { documentId: existingDocumentId } });
3481
+ logKbPipeline("06b_chunks_existing_count", {
3482
+ slug,
3483
+ documentId: existingDocumentId,
3484
+ chunkCount
3485
+ });
3486
+ let chunksToEmbed = [];
3487
+ let chunksCreated = 0;
3488
+ if (chunkCount === 0) {
3489
+ const text2 = (docRow.content ?? "").trim();
3490
+ if (!text2) {
3491
+ logKbPipeline("07_ingest_aborted_empty_document", { slug, documentId: existingDocumentId });
3492
+ return json({
3493
+ documentId: existingDocumentId,
3494
+ linked: true,
3495
+ created: false,
3496
+ chunkCount: 0,
3497
+ embeddingsWritten: 0,
3498
+ embeddingsFailed: 0,
3499
+ warning: "Document has no text content; add content then attach again to build chunks and embeddings."
3500
+ });
3501
+ }
3502
+ const parts2 = splitIntoChunks(text2, INGEST_CHUNK_CHARS);
3503
+ if (parts2.length > MAX_CHUNKS_PER_UPLOAD) {
3504
+ return json(
3505
+ {
3506
+ error: `Document is too large for one ingest (${parts2.length} chunks; max ${MAX_CHUNKS_PER_UPLOAD}). Split into smaller files.`
3507
+ },
3508
+ { status: 413 }
3509
+ );
3510
+ }
3511
+ logKbPipeline("07_chunk_split", {
3512
+ slug,
3513
+ documentId: existingDocumentId,
3514
+ partCount: parts2.length,
3515
+ maxChunkChars: INGEST_CHUNK_CHARS,
3516
+ totalChars: text2.length
3517
+ });
3518
+ const now2 = /* @__PURE__ */ new Date();
3519
+ const chunkRows2 = parts2.map(
3520
+ (content, i) => chunkRepo2.create({
3521
+ documentId: existingDocumentId,
3522
+ content,
3523
+ chunkIndex: i,
3524
+ createdAt: now2
3525
+ })
3526
+ );
3527
+ const savedList2 = await chunkRepo2.save(chunkRows2);
3528
+ chunksCreated = savedList2.length;
3529
+ chunksToEmbed = savedList2.map((row, i) => ({
3530
+ id: row.id,
3531
+ content: parts2[i]
3532
+ }));
3533
+ logKbPipeline("07b_chunks_persisted", {
3534
+ slug,
3535
+ documentId: existingDocumentId,
3536
+ rowsInserted: chunksCreated
3537
+ });
3538
+ } else {
3539
+ chunksToEmbed = await loadChunksMissingEmbeddings(dataSource, existingDocumentId, slug);
3540
+ if (chunksToEmbed.length === 0) {
3541
+ logKbPipeline("08_skip_embed_all_chunks_have_vectors", {
3542
+ slug,
3543
+ documentId: existingDocumentId,
3544
+ existingChunkCount: chunkCount
3545
+ });
3546
+ }
3294
3547
  }
3295
- return json({ documentId: existingDocumentId, linked: true, created: false });
3548
+ const embedResult2 = chunksToEmbed.length > 0 ? await runEmbeddingPass(slug, chunksToEmbed) : { embeddingsWritten: 0, embeddingsFailed: 0 };
3549
+ if (embedResult2.embedError) {
3550
+ logKbPipeline("11_response", {
3551
+ slug,
3552
+ branch: "link",
3553
+ documentId: existingDocumentId,
3554
+ ok: false,
3555
+ embeddingError: true
3556
+ });
3557
+ return json(
3558
+ {
3559
+ documentId: existingDocumentId,
3560
+ linked: true,
3561
+ created: false,
3562
+ chunkCount: chunkCount + chunksCreated,
3563
+ chunksCreated,
3564
+ embeddingAttempted: true,
3565
+ embeddingsWritten: 0,
3566
+ embeddingsFailed: chunksToEmbed.length,
3567
+ warning: "Document linked; embedding step failed. Fix LLM/embed config and attach again (or unlink and re-attach) to retry NULL embeddings.",
3568
+ detail: embedResult2.embedError
3569
+ },
3570
+ { status: 201 }
3571
+ );
3572
+ }
3573
+ logKbPipeline("11_response", {
3574
+ slug,
3575
+ branch: "link",
3576
+ documentId: existingDocumentId,
3577
+ ok: true,
3578
+ chunkCount: chunkCount + chunksCreated,
3579
+ chunksCreated,
3580
+ chunksQueuedForEmbedding: chunksToEmbed.length,
3581
+ embeddingsWritten: embedResult2.embeddingsWritten,
3582
+ embeddingsFailed: embedResult2.embeddingsFailed
3583
+ });
3584
+ return json({
3585
+ documentId: existingDocumentId,
3586
+ linked: true,
3587
+ created: false,
3588
+ chunkCount: chunkCount + chunksCreated,
3589
+ chunksCreated: chunksCreated || void 0,
3590
+ chunksQueuedForEmbedding: chunksToEmbed.length,
3591
+ embeddingAttempted: chunksToEmbed.length > 0,
3592
+ embeddingsWritten: embedResult2.embeddingsWritten,
3593
+ embeddingsFailed: embedResult2.embeddingsFailed
3594
+ });
3296
3595
  }
3596
+ logKbPipeline("05_branch", { slug, branch: "new_upload_ingest" });
3297
3597
  if (!text) return json({ error: "text or file with text content is required" }, { status: 400 });
3298
3598
  if (!name) name = "Untitled";
3299
3599
  const parts = splitIntoChunks(text, INGEST_CHUNK_CHARS);
@@ -3308,6 +3608,13 @@ function createLlmAgentKnowledgeHandlers(config) {
3308
3608
  { status: 413 }
3309
3609
  );
3310
3610
  }
3611
+ logKbPipeline("07_chunk_split", {
3612
+ slug,
3613
+ partCount: parts.length,
3614
+ maxChunkChars: INGEST_CHUNK_CHARS,
3615
+ totalChars: text.length,
3616
+ documentName: name
3617
+ });
3311
3618
  const docRepo = dataSource.getRepository(kbDoc);
3312
3619
  const chunkRepo = dataSource.getRepository(kbChunk);
3313
3620
  const now = /* @__PURE__ */ new Date();
@@ -3315,6 +3622,13 @@ function createLlmAgentKnowledgeHandlers(config) {
3315
3622
  docRepo.create({ name, content: text, sourceUrl, createdAt: now, updatedAt: now })
3316
3623
  );
3317
3624
  const docId = doc.id;
3625
+ logKbPipeline("06_knowledge_document_saved", {
3626
+ slug,
3627
+ documentId: docId,
3628
+ name,
3629
+ contentChars: text.length,
3630
+ hasSourceUrl: !!sourceUrl
3631
+ });
3318
3632
  const chunkRows = parts.map(
3319
3633
  (content, i) => chunkRepo.create({ documentId: docId, content, chunkIndex: i, createdAt: now })
3320
3634
  );
@@ -3325,63 +3639,66 @@ function createLlmAgentKnowledgeHandlers(config) {
3325
3639
  content: parts[i]
3326
3640
  })
3327
3641
  );
3642
+ logKbPipeline("07b_chunks_persisted", {
3643
+ slug,
3644
+ documentId: docId,
3645
+ rowsInserted: savedChunks.length,
3646
+ firstChunkId: savedChunks[0]?.id,
3647
+ lastChunkId: savedChunks[savedChunks.length - 1]?.id
3648
+ });
3328
3649
  const dup = await linkRepo.findOne({ where: { agentId: agent.id, documentId: docId } });
3329
3650
  if (!dup) {
3330
3651
  await linkRepo.save(linkRepo.create({ agentId: agent.id, documentId: docId }));
3652
+ logKbPipeline("06c_junction_link_created", { slug, agentId: agent.id, documentId: docId });
3653
+ } else {
3654
+ logKbPipeline("06c_junction_link_exists", { slug, agentId: agent.id, documentId: docId });
3331
3655
  }
3332
- let embeddingsWritten = 0;
3333
- let embeddingsFailed = 0;
3334
- try {
3335
- const cms = await getCms();
3336
- const llm = cms.getPlugin("llm");
3337
- if (llm?.embed && savedChunks.length > 0) {
3338
- console.info(`${KB_LOG} starting embedding pass`, { slug, chunkCount: savedChunks.length });
3339
- const embedBound = (text2) => llm.embed(text2);
3340
- const { written, failed } = await writeEmbeddingsConcurrent(
3341
- dataSource,
3342
- embedBound,
3343
- savedChunks,
3344
- EMBED_CONCURRENCY
3345
- );
3346
- embeddingsWritten = written;
3347
- embeddingsFailed = failed;
3348
- } else {
3349
- console.error(`${KB_LOG} embeddings skipped`, {
3350
- slug,
3351
- hasLlmPlugin: !!llm,
3352
- hasEmbed: typeof llm?.embed === "function",
3353
- chunkCount: savedChunks.length,
3354
- 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
3355
- });
3356
- }
3357
- } catch (embErr) {
3358
- const detail = embErr instanceof Error ? embErr.message : String(embErr);
3359
- console.error(`${KB_LOG} embedding step threw before/during batch`, { slug, detail, embErr });
3656
+ const embedResult = await runEmbeddingPass(slug, savedChunks);
3657
+ if (embedResult.embedError) {
3658
+ logKbPipeline("11_response", {
3659
+ slug,
3660
+ branch: "ingest",
3661
+ documentId: docId,
3662
+ ok: false,
3663
+ embeddingError: true
3664
+ });
3360
3665
  return json(
3361
3666
  {
3362
3667
  documentId: docId,
3363
3668
  chunkCount: savedChunks.length,
3669
+ embeddingAttempted: true,
3364
3670
  created: true,
3365
3671
  linked: true,
3366
3672
  embeddingsWritten: 0,
3367
3673
  embeddingsFailed: savedChunks.length,
3368
3674
  warning: "Document saved and linked; embedding step failed.",
3369
- detail
3675
+ detail: embedResult.embedError
3370
3676
  },
3371
3677
  { status: 201 }
3372
3678
  );
3373
3679
  }
3680
+ logKbPipeline("11_response", {
3681
+ slug,
3682
+ branch: "ingest",
3683
+ documentId: docId,
3684
+ ok: true,
3685
+ chunkCount: savedChunks.length,
3686
+ embeddingsWritten: embedResult.embeddingsWritten,
3687
+ embeddingsFailed: embedResult.embeddingsFailed
3688
+ });
3374
3689
  return json({
3375
3690
  documentId: docId,
3376
3691
  chunkCount: savedChunks.length,
3692
+ embeddingAttempted: savedChunks.length > 0,
3377
3693
  created: true,
3378
3694
  linked: true,
3379
- embeddingsWritten,
3380
- embeddingsFailed
3695
+ embeddingsWritten: embedResult.embeddingsWritten,
3696
+ embeddingsFailed: embedResult.embeddingsFailed
3381
3697
  });
3382
3698
  } catch (err) {
3383
3699
  const msg = err instanceof Error ? err.message : "Failed to ingest knowledge";
3384
3700
  const name = err instanceof Error ? err.name : "";
3701
+ logKbPipeline("99_pipeline_error", { slug, errorName: name, message: msg });
3385
3702
  return json({ error: msg, errorName: name || void 0 }, { status: 500 });
3386
3703
  }
3387
3704
  },
@@ -3393,6 +3710,7 @@ function createLlmAgentKnowledgeHandlers(config) {
3393
3710
  try {
3394
3711
  const agent = await findAgentBySlug(dataSource, llmAgents, slug);
3395
3712
  if (!agent) return json({ error: "Agent not found" }, { status: 404 });
3713
+ logKbPipeline("unlink_junction", { slug, agentId: agent.id, documentId });
3396
3714
  const linkRepo = dataSource.getRepository(junction);
3397
3715
  await linkRepo.delete({ agentId: agent.id, documentId });
3398
3716
  return json({ ok: true });
@@ -3711,155 +4029,2754 @@ function createAdminRolesHandlers(config) {
3711
4029
  };
3712
4030
  }
3713
4031
 
3714
- // src/api/cms-api-handler.ts
3715
- var KNOWLEDGE_SUFFIX = "knowledge";
3716
- function matchLlmAgentKnowledgeRoute(path) {
3717
- const p = path[0] === "api" ? path.slice(1) : path;
3718
- if (p[0] !== "llm_agents" || p.length < 2) return null;
3719
- const seg1 = p[1];
3720
- if (!seg1) return null;
3721
- if (p[2] === KNOWLEDGE_SUFFIX) {
3722
- return {
3723
- slug: seg1,
3724
- documentId: p.length >= 4 ? p[3] : void 0
3725
- };
3726
- }
3727
- if (seg1.endsWith(KNOWLEDGE_SUFFIX) && seg1.length > KNOWLEDGE_SUFFIX.length) {
3728
- const slug = seg1.slice(0, -KNOWLEDGE_SUFFIX.length);
3729
- if (!slug) return null;
3730
- if (p.length === 2) return { slug, documentId: void 0 };
3731
- if (p.length === 3) return { slug, documentId: p[2] };
3732
- }
3733
- return null;
3734
- }
3735
- var DEFAULT_EXCLUDE = /* @__PURE__ */ new Set([
3736
- "users",
3737
- "password_reset_tokens",
3738
- "user_groups",
3739
- "permissions",
3740
- "comments",
3741
- "form_fields",
3742
- "configs",
3743
- "carts",
3744
- "cart_items",
3745
- "wishlists",
3746
- "wishlist_items",
3747
- "message_templates",
3748
- "llm_agent_knowledge_documents"
3749
- ]);
3750
- function createCmsApiHandler(config) {
3751
- const {
3752
- dataSource,
3753
- entityMap,
3754
- pathToModel = (s) => s,
3755
- crudResources = Object.keys(entityMap).filter((k) => !DEFAULT_EXCLUDE.has(k)),
3756
- getCms,
3757
- userAuth: userAuthConfig,
3758
- dashboard,
3759
- ecommerceAnalytics,
3760
- analytics: analyticsConfig,
3761
- upload,
3762
- blogBySlug,
3763
- formBySlug,
3764
- formSave: formSaveConfig,
3765
- formSubmission: formSubmissionConfig,
3766
- formSubmissionGetById: formSubmissionGetByIdConfig,
3767
- usersApi,
3768
- userAvatar,
3769
- userProfile,
3770
- settings: settingsConfig,
3771
- chat: chatConfig,
3772
- llmAgentKnowledge: llmAgentKnowledgeConfig,
3773
- requireEntityPermission: userRequireEntityPermission,
3774
- getSessionUser
3775
- } = config;
3776
- const requireEntityPermissionEffective = userRequireEntityPermission ?? (async (_req, entity, action) => config.json({ error: "Forbidden", reason: "entity_rbac_required", entity, action }, { status: 403 }));
3777
- const analytics = analyticsConfig ?? (getCms ? {
3778
- json: config.json,
3779
- requireAuth: async () => null,
3780
- getAnalyticsData: async (days) => {
3781
- const cms = await getCms();
3782
- const a = cms.getPlugin("analytics");
3783
- if (!a?.getAnalyticsData) throw new Error("Analytics not configured");
3784
- return a.getAnalyticsData(days);
3785
- },
3786
- getPropertyId: () => ({ currentViewId: process.env.GOOGLE_ANALYTICS_VIEW_ID }),
3787
- getPermissions: () => ({
3788
- serviceAccountEmail: process.env.GOOGLE_ANALYTICS_CLIENT_EMAIL,
3789
- currentViewId: process.env.GOOGLE_ANALYTICS_VIEW_ID
3790
- })
3791
- } : void 0);
3792
- const userAuth = userAuthConfig && getCms && userAuthConfig.sendEmail === void 0 ? {
3793
- ...userAuthConfig,
3794
- sendEmail: async (opts) => {
3795
- const cms = await getCms();
3796
- const queue = cms.getPlugin("queue");
3797
- const companyDetails = config.getCompanyDetails ? await config.getCompanyDetails() : {};
3798
- const resetLink = typeof opts.resetLink === "string" && opts.resetLink.trim() || typeof opts.text === "string" && opts.text.trim() || (typeof opts.html === "string" ? opts.html.match(/href\s*=\s*["']([^"']+)["']/)?.[1] ?? "" : "");
3799
- const ctx = { resetLink, companyDetails };
3800
- if (queue) {
3801
- const { queueEmail: queueEmail2 } = await Promise.resolve().then(() => (init_email_queue(), email_queue_exports));
3802
- await queueEmail2(cms, { to: opts.to, templateName: "passwordReset", ctx });
3803
- return;
3804
- }
3805
- const email = cms.getPlugin("email");
3806
- if (!email?.send) return;
3807
- const rendered = email.renderTemplate("passwordReset", ctx);
3808
- await email.send({ subject: rendered.subject, html: rendered.html, text: rendered.text, to: opts.to });
3809
- }
3810
- } : userAuthConfig;
3811
- const crudOpts = {
3812
- requireAuth: config.requireAuth,
3813
- json: config.json,
3814
- requireEntityPermission: requireEntityPermissionEffective,
3815
- getCms,
3816
- ...getSessionUser ? {
3817
- getDeletedByUserId: async () => {
3818
- const u = await getSessionUser();
3819
- if (!u?.id) return null;
3820
- const n = Number(u.id);
3821
- return Number.isFinite(n) ? n : null;
3822
- }
3823
- } : {}
3824
- };
3825
- const crud = createCrudHandler(dataSource, entityMap, crudOpts);
3826
- const crudById = createCrudByIdHandler(dataSource, entityMap, crudOpts);
3827
- const mergePerm = (c) => !c ? void 0 : { ...c, requireEntityPermission: requireEntityPermissionEffective };
3828
- const adminRoles = getSessionUser && createAdminRolesHandlers({
3829
- dataSource,
3830
- entityMap,
3831
- json: config.json,
3832
- getSessionUser
3833
- });
3834
- const userAuthRouter = userAuth ? createUserAuthApiRouter(userAuth) : null;
3835
- const dashboardGet = dashboard ? createDashboardStatsHandler(mergePerm(dashboard) ?? dashboard) : null;
3836
- const ecommerceAnalyticsResolved = mergePerm(
3837
- ecommerceAnalytics ?? {
3838
- dataSource,
3839
- entityMap,
3840
- json: config.json,
3841
- requireAuth: config.requireAuth
3842
- }
3843
- );
3844
- const ecommerceAnalyticsGet = createEcommerceAnalyticsHandler(ecommerceAnalyticsResolved);
3845
- const analyticsHandlers = analytics ? createAnalyticsHandlers(analytics) : null;
3846
- const uploadMerged = upload ? {
3847
- ...mergePerm(upload) ?? upload,
3848
- dataSource: upload.dataSource ?? dataSource,
3849
- entityMap: upload.entityMap ?? entityMap
3850
- } : null;
3851
- const uploadPost = uploadMerged ? createUploadHandler(uploadMerged) : null;
3852
- const zipExtractPost = uploadMerged ? createMediaZipExtractHandler(uploadMerged) : null;
3853
- const blogBySlugGet = blogBySlug ? createBlogBySlugHandler(blogBySlug) : null;
3854
- const formBySlugGet = formBySlug ? createFormBySlugHandler(formBySlug) : null;
3855
- const formSaveHandlers = formSaveConfig ? createFormSaveHandlers(mergePerm(formSaveConfig) ?? formSaveConfig) : null;
3856
- const formSubmissionPost = formSubmissionConfig ? createFormSubmissionHandler(formSubmissionConfig) : null;
3857
- const formSubmissionGetById = formSubmissionGetByIdConfig ? createFormSubmissionGetByIdHandler(mergePerm(formSubmissionGetByIdConfig) ?? formSubmissionGetByIdConfig) : null;
3858
- const formSubmissionList = formSubmissionGetByIdConfig ? createFormSubmissionListHandler(mergePerm(formSubmissionGetByIdConfig) ?? formSubmissionGetByIdConfig) : null;
3859
- const usersApiMerged = usersApi && getCms ? {
3860
- ...usersApi,
3861
- getCms: usersApi.getCms ?? getCms,
3862
- getCompanyDetails: usersApi.getCompanyDetails ?? config.getCompanyDetails,
4032
+ // src/entities/user.entity.ts
4033
+ var import_typeorm9 = require("typeorm");
4034
+
4035
+ // src/entities/user-group.entity.ts
4036
+ var import_typeorm8 = require("typeorm");
4037
+
4038
+ // src/entities/permission.entity.ts
4039
+ var import_typeorm7 = require("typeorm");
4040
+ var Permission = class {
4041
+ id;
4042
+ groupId;
4043
+ entity;
4044
+ canCreate;
4045
+ canRead;
4046
+ canUpdate;
4047
+ canDelete;
4048
+ createdAt;
4049
+ updatedAt;
4050
+ deletedAt;
4051
+ deleted;
4052
+ createdBy;
4053
+ updatedBy;
4054
+ deletedBy;
4055
+ group;
4056
+ };
4057
+ __decorateClass([
4058
+ (0, import_typeorm7.PrimaryGeneratedColumn)()
4059
+ ], Permission.prototype, "id", 2);
4060
+ __decorateClass([
4061
+ (0, import_typeorm7.Column)("int")
4062
+ ], Permission.prototype, "groupId", 2);
4063
+ __decorateClass([
4064
+ (0, import_typeorm7.Column)("varchar")
4065
+ ], Permission.prototype, "entity", 2);
4066
+ __decorateClass([
4067
+ (0, import_typeorm7.Column)("boolean", { default: false })
4068
+ ], Permission.prototype, "canCreate", 2);
4069
+ __decorateClass([
4070
+ (0, import_typeorm7.Column)("boolean", { default: false })
4071
+ ], Permission.prototype, "canRead", 2);
4072
+ __decorateClass([
4073
+ (0, import_typeorm7.Column)("boolean", { default: false })
4074
+ ], Permission.prototype, "canUpdate", 2);
4075
+ __decorateClass([
4076
+ (0, import_typeorm7.Column)("boolean", { default: false })
4077
+ ], Permission.prototype, "canDelete", 2);
4078
+ __decorateClass([
4079
+ (0, import_typeorm7.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
4080
+ ], Permission.prototype, "createdAt", 2);
4081
+ __decorateClass([
4082
+ (0, import_typeorm7.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
4083
+ ], Permission.prototype, "updatedAt", 2);
4084
+ __decorateClass([
4085
+ (0, import_typeorm7.Column)({ type: "timestamp", nullable: true })
4086
+ ], Permission.prototype, "deletedAt", 2);
4087
+ __decorateClass([
4088
+ (0, import_typeorm7.Column)("boolean", { default: false })
4089
+ ], Permission.prototype, "deleted", 2);
4090
+ __decorateClass([
4091
+ (0, import_typeorm7.Column)("int", { nullable: true })
4092
+ ], Permission.prototype, "createdBy", 2);
4093
+ __decorateClass([
4094
+ (0, import_typeorm7.Column)("int", { nullable: true })
4095
+ ], Permission.prototype, "updatedBy", 2);
4096
+ __decorateClass([
4097
+ (0, import_typeorm7.Column)("int", { nullable: true })
4098
+ ], Permission.prototype, "deletedBy", 2);
4099
+ __decorateClass([
4100
+ (0, import_typeorm7.ManyToOne)(() => UserGroup, (g) => g.permissions, { onDelete: "CASCADE" }),
4101
+ (0, import_typeorm7.JoinColumn)({ name: "groupId" })
4102
+ ], Permission.prototype, "group", 2);
4103
+ Permission = __decorateClass([
4104
+ (0, import_typeorm7.Entity)("permissions")
4105
+ ], Permission);
4106
+
4107
+ // src/entities/user-group.entity.ts
4108
+ var UserGroup = class {
4109
+ id;
4110
+ name;
4111
+ createdAt;
4112
+ updatedAt;
4113
+ deletedAt;
4114
+ deleted;
4115
+ createdBy;
4116
+ updatedBy;
4117
+ deletedBy;
4118
+ permissions;
4119
+ users;
4120
+ };
4121
+ __decorateClass([
4122
+ (0, import_typeorm8.PrimaryGeneratedColumn)()
4123
+ ], UserGroup.prototype, "id", 2);
4124
+ __decorateClass([
4125
+ (0, import_typeorm8.Column)("varchar", { unique: true })
4126
+ ], UserGroup.prototype, "name", 2);
4127
+ __decorateClass([
4128
+ (0, import_typeorm8.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
4129
+ ], UserGroup.prototype, "createdAt", 2);
4130
+ __decorateClass([
4131
+ (0, import_typeorm8.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
4132
+ ], UserGroup.prototype, "updatedAt", 2);
4133
+ __decorateClass([
4134
+ (0, import_typeorm8.Column)({ type: "timestamp", nullable: true })
4135
+ ], UserGroup.prototype, "deletedAt", 2);
4136
+ __decorateClass([
4137
+ (0, import_typeorm8.Column)("boolean", { default: false })
4138
+ ], UserGroup.prototype, "deleted", 2);
4139
+ __decorateClass([
4140
+ (0, import_typeorm8.Column)("int", { nullable: true })
4141
+ ], UserGroup.prototype, "createdBy", 2);
4142
+ __decorateClass([
4143
+ (0, import_typeorm8.Column)("int", { nullable: true })
4144
+ ], UserGroup.prototype, "updatedBy", 2);
4145
+ __decorateClass([
4146
+ (0, import_typeorm8.Column)("int", { nullable: true })
4147
+ ], UserGroup.prototype, "deletedBy", 2);
4148
+ __decorateClass([
4149
+ (0, import_typeorm8.OneToMany)(() => Permission, (p) => p.group)
4150
+ ], UserGroup.prototype, "permissions", 2);
4151
+ __decorateClass([
4152
+ (0, import_typeorm8.OneToMany)(() => User, (u) => u.group)
4153
+ ], UserGroup.prototype, "users", 2);
4154
+ UserGroup = __decorateClass([
4155
+ (0, import_typeorm8.Entity)("user_groups")
4156
+ ], UserGroup);
4157
+
4158
+ // src/entities/user.entity.ts
4159
+ var User = class {
4160
+ id;
4161
+ name;
4162
+ email;
4163
+ phone;
4164
+ phoneVerifiedAt;
4165
+ emailVerifiedAt;
4166
+ password;
4167
+ blocked;
4168
+ adminAccess;
4169
+ groupId;
4170
+ createdAt;
4171
+ updatedAt;
4172
+ deletedAt;
4173
+ deleted;
4174
+ createdBy;
4175
+ updatedBy;
4176
+ deletedBy;
4177
+ group;
4178
+ };
4179
+ __decorateClass([
4180
+ (0, import_typeorm9.PrimaryGeneratedColumn)()
4181
+ ], User.prototype, "id", 2);
4182
+ __decorateClass([
4183
+ (0, import_typeorm9.Column)("varchar")
4184
+ ], User.prototype, "name", 2);
4185
+ __decorateClass([
4186
+ (0, import_typeorm9.Column)("varchar", { unique: true })
4187
+ ], User.prototype, "email", 2);
4188
+ __decorateClass([
4189
+ (0, import_typeorm9.Column)("varchar", { nullable: true })
4190
+ ], User.prototype, "phone", 2);
4191
+ __decorateClass([
4192
+ (0, import_typeorm9.Column)({ type: "timestamp", nullable: true })
4193
+ ], User.prototype, "phoneVerifiedAt", 2);
4194
+ __decorateClass([
4195
+ (0, import_typeorm9.Column)({ type: "timestamp", nullable: true })
4196
+ ], User.prototype, "emailVerifiedAt", 2);
4197
+ __decorateClass([
4198
+ (0, import_typeorm9.Column)("varchar", { nullable: true })
4199
+ ], User.prototype, "password", 2);
4200
+ __decorateClass([
4201
+ (0, import_typeorm9.Column)("boolean", { default: false })
4202
+ ], User.prototype, "blocked", 2);
4203
+ __decorateClass([
4204
+ (0, import_typeorm9.Column)("boolean", { default: false })
4205
+ ], User.prototype, "adminAccess", 2);
4206
+ __decorateClass([
4207
+ (0, import_typeorm9.Column)("int", { nullable: true })
4208
+ ], User.prototype, "groupId", 2);
4209
+ __decorateClass([
4210
+ (0, import_typeorm9.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
4211
+ ], User.prototype, "createdAt", 2);
4212
+ __decorateClass([
4213
+ (0, import_typeorm9.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
4214
+ ], User.prototype, "updatedAt", 2);
4215
+ __decorateClass([
4216
+ (0, import_typeorm9.Column)({ type: "timestamp", nullable: true })
4217
+ ], User.prototype, "deletedAt", 2);
4218
+ __decorateClass([
4219
+ (0, import_typeorm9.Column)("boolean", { default: false })
4220
+ ], User.prototype, "deleted", 2);
4221
+ __decorateClass([
4222
+ (0, import_typeorm9.Column)("int", { nullable: true })
4223
+ ], User.prototype, "createdBy", 2);
4224
+ __decorateClass([
4225
+ (0, import_typeorm9.Column)("int", { nullable: true })
4226
+ ], User.prototype, "updatedBy", 2);
4227
+ __decorateClass([
4228
+ (0, import_typeorm9.Column)("int", { nullable: true })
4229
+ ], User.prototype, "deletedBy", 2);
4230
+ __decorateClass([
4231
+ (0, import_typeorm9.ManyToOne)(() => UserGroup, (g) => g.users, { onDelete: "SET NULL" }),
4232
+ (0, import_typeorm9.JoinColumn)({ name: "groupId" })
4233
+ ], User.prototype, "group", 2);
4234
+ User = __decorateClass([
4235
+ (0, import_typeorm9.Entity)("users")
4236
+ ], User);
4237
+
4238
+ // src/entities/otp-challenge.entity.ts
4239
+ var import_typeorm10 = require("typeorm");
4240
+ var OtpChallenge = class {
4241
+ id;
4242
+ purpose;
4243
+ channel;
4244
+ identifier;
4245
+ codeHash;
4246
+ expiresAt;
4247
+ attempts;
4248
+ consumedAt;
4249
+ createdAt;
4250
+ };
4251
+ __decorateClass([
4252
+ (0, import_typeorm10.PrimaryGeneratedColumn)()
4253
+ ], OtpChallenge.prototype, "id", 2);
4254
+ __decorateClass([
4255
+ (0, import_typeorm10.Column)("varchar")
4256
+ ], OtpChallenge.prototype, "purpose", 2);
4257
+ __decorateClass([
4258
+ (0, import_typeorm10.Column)("varchar")
4259
+ ], OtpChallenge.prototype, "channel", 2);
4260
+ __decorateClass([
4261
+ (0, import_typeorm10.Column)("varchar")
4262
+ ], OtpChallenge.prototype, "identifier", 2);
4263
+ __decorateClass([
4264
+ (0, import_typeorm10.Column)("varchar")
4265
+ ], OtpChallenge.prototype, "codeHash", 2);
4266
+ __decorateClass([
4267
+ (0, import_typeorm10.Column)({ type: "timestamp" })
4268
+ ], OtpChallenge.prototype, "expiresAt", 2);
4269
+ __decorateClass([
4270
+ (0, import_typeorm10.Column)("int", { default: 0 })
4271
+ ], OtpChallenge.prototype, "attempts", 2);
4272
+ __decorateClass([
4273
+ (0, import_typeorm10.Column)({ type: "timestamp", nullable: true })
4274
+ ], OtpChallenge.prototype, "consumedAt", 2);
4275
+ __decorateClass([
4276
+ (0, import_typeorm10.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
4277
+ ], OtpChallenge.prototype, "createdAt", 2);
4278
+ OtpChallenge = __decorateClass([
4279
+ (0, import_typeorm10.Entity)("otp_challenges"),
4280
+ (0, import_typeorm10.Index)(["purpose", "identifier"])
4281
+ ], OtpChallenge);
4282
+
4283
+ // src/entities/password-reset-token.entity.ts
4284
+ var import_typeorm11 = require("typeorm");
4285
+ var PasswordResetToken = class {
4286
+ id;
4287
+ email;
4288
+ token;
4289
+ expiresAt;
4290
+ createdAt;
4291
+ };
4292
+ __decorateClass([
4293
+ (0, import_typeorm11.PrimaryGeneratedColumn)()
4294
+ ], PasswordResetToken.prototype, "id", 2);
4295
+ __decorateClass([
4296
+ (0, import_typeorm11.Column)("varchar")
4297
+ ], PasswordResetToken.prototype, "email", 2);
4298
+ __decorateClass([
4299
+ (0, import_typeorm11.Column)("varchar", { unique: true })
4300
+ ], PasswordResetToken.prototype, "token", 2);
4301
+ __decorateClass([
4302
+ (0, import_typeorm11.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
4303
+ ], PasswordResetToken.prototype, "expiresAt", 2);
4304
+ __decorateClass([
4305
+ (0, import_typeorm11.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
4306
+ ], PasswordResetToken.prototype, "createdAt", 2);
4307
+ PasswordResetToken = __decorateClass([
4308
+ (0, import_typeorm11.Entity)("password_reset_tokens")
4309
+ ], PasswordResetToken);
4310
+
4311
+ // src/entities/blog.entity.ts
4312
+ var import_typeorm16 = require("typeorm");
4313
+
4314
+ // src/entities/category.entity.ts
4315
+ var import_typeorm12 = require("typeorm");
4316
+ var Category = class {
4317
+ id;
4318
+ name;
4319
+ createdAt;
4320
+ updatedAt;
4321
+ deletedAt;
4322
+ deleted;
4323
+ createdBy;
4324
+ updatedBy;
4325
+ deletedBy;
4326
+ blogs;
4327
+ };
4328
+ __decorateClass([
4329
+ (0, import_typeorm12.PrimaryGeneratedColumn)()
4330
+ ], Category.prototype, "id", 2);
4331
+ __decorateClass([
4332
+ (0, import_typeorm12.Column)("varchar", { unique: true })
4333
+ ], Category.prototype, "name", 2);
4334
+ __decorateClass([
4335
+ (0, import_typeorm12.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
4336
+ ], Category.prototype, "createdAt", 2);
4337
+ __decorateClass([
4338
+ (0, import_typeorm12.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
4339
+ ], Category.prototype, "updatedAt", 2);
4340
+ __decorateClass([
4341
+ (0, import_typeorm12.Column)({ type: "timestamp", nullable: true })
4342
+ ], Category.prototype, "deletedAt", 2);
4343
+ __decorateClass([
4344
+ (0, import_typeorm12.Column)("boolean", { default: false })
4345
+ ], Category.prototype, "deleted", 2);
4346
+ __decorateClass([
4347
+ (0, import_typeorm12.Column)("int", { nullable: true })
4348
+ ], Category.prototype, "createdBy", 2);
4349
+ __decorateClass([
4350
+ (0, import_typeorm12.Column)("int", { nullable: true })
4351
+ ], Category.prototype, "updatedBy", 2);
4352
+ __decorateClass([
4353
+ (0, import_typeorm12.Column)("int", { nullable: true })
4354
+ ], Category.prototype, "deletedBy", 2);
4355
+ __decorateClass([
4356
+ (0, import_typeorm12.OneToMany)("Blog", "category")
4357
+ ], Category.prototype, "blogs", 2);
4358
+ Category = __decorateClass([
4359
+ (0, import_typeorm12.Entity)("categories")
4360
+ ], Category);
4361
+
4362
+ // src/entities/seo.entity.ts
4363
+ var import_typeorm13 = require("typeorm");
4364
+ var Seo = class {
4365
+ id;
4366
+ title;
4367
+ description;
4368
+ keywords;
4369
+ ogTitle;
4370
+ ogDescription;
4371
+ ogImage;
4372
+ slug;
4373
+ createdAt;
4374
+ updatedAt;
4375
+ deletedAt;
4376
+ deleted;
4377
+ createdBy;
4378
+ updatedBy;
4379
+ deletedBy;
4380
+ blogs;
4381
+ };
4382
+ __decorateClass([
4383
+ (0, import_typeorm13.PrimaryGeneratedColumn)()
4384
+ ], Seo.prototype, "id", 2);
4385
+ __decorateClass([
4386
+ (0, import_typeorm13.Column)("varchar", { nullable: true })
4387
+ ], Seo.prototype, "title", 2);
4388
+ __decorateClass([
4389
+ (0, import_typeorm13.Column)("varchar", { nullable: true })
4390
+ ], Seo.prototype, "description", 2);
4391
+ __decorateClass([
4392
+ (0, import_typeorm13.Column)("varchar", { nullable: true })
4393
+ ], Seo.prototype, "keywords", 2);
4394
+ __decorateClass([
4395
+ (0, import_typeorm13.Column)("varchar", { nullable: true })
4396
+ ], Seo.prototype, "ogTitle", 2);
4397
+ __decorateClass([
4398
+ (0, import_typeorm13.Column)("varchar", { nullable: true })
4399
+ ], Seo.prototype, "ogDescription", 2);
4400
+ __decorateClass([
4401
+ (0, import_typeorm13.Column)("varchar", { nullable: true })
4402
+ ], Seo.prototype, "ogImage", 2);
4403
+ __decorateClass([
4404
+ (0, import_typeorm13.Column)("varchar", { unique: true })
4405
+ ], Seo.prototype, "slug", 2);
4406
+ __decorateClass([
4407
+ (0, import_typeorm13.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
4408
+ ], Seo.prototype, "createdAt", 2);
4409
+ __decorateClass([
4410
+ (0, import_typeorm13.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
4411
+ ], Seo.prototype, "updatedAt", 2);
4412
+ __decorateClass([
4413
+ (0, import_typeorm13.Column)({ type: "timestamp", nullable: true })
4414
+ ], Seo.prototype, "deletedAt", 2);
4415
+ __decorateClass([
4416
+ (0, import_typeorm13.Column)("boolean", { default: false })
4417
+ ], Seo.prototype, "deleted", 2);
4418
+ __decorateClass([
4419
+ (0, import_typeorm13.Column)("int", { nullable: true })
4420
+ ], Seo.prototype, "createdBy", 2);
4421
+ __decorateClass([
4422
+ (0, import_typeorm13.Column)("int", { nullable: true })
4423
+ ], Seo.prototype, "updatedBy", 2);
4424
+ __decorateClass([
4425
+ (0, import_typeorm13.Column)("int", { nullable: true })
4426
+ ], Seo.prototype, "deletedBy", 2);
4427
+ __decorateClass([
4428
+ (0, import_typeorm13.OneToMany)(() => Blog, (blog) => blog.seo)
4429
+ ], Seo.prototype, "blogs", 2);
4430
+ Seo = __decorateClass([
4431
+ (0, import_typeorm13.Entity)("seos")
4432
+ ], Seo);
4433
+
4434
+ // src/entities/comment.entity.ts
4435
+ var import_typeorm14 = require("typeorm");
4436
+ var Comment = class {
4437
+ id;
4438
+ content;
4439
+ blogId;
4440
+ authorId;
4441
+ createdAt;
4442
+ updatedAt;
4443
+ deletedAt;
4444
+ deleted;
4445
+ createdBy;
4446
+ updatedBy;
4447
+ deletedBy;
4448
+ author;
4449
+ blog;
4450
+ };
4451
+ __decorateClass([
4452
+ (0, import_typeorm14.PrimaryGeneratedColumn)()
4453
+ ], Comment.prototype, "id", 2);
4454
+ __decorateClass([
4455
+ (0, import_typeorm14.Column)("text")
4456
+ ], Comment.prototype, "content", 2);
4457
+ __decorateClass([
4458
+ (0, import_typeorm14.Column)("int")
4459
+ ], Comment.prototype, "blogId", 2);
4460
+ __decorateClass([
4461
+ (0, import_typeorm14.Column)("int")
4462
+ ], Comment.prototype, "authorId", 2);
4463
+ __decorateClass([
4464
+ (0, import_typeorm14.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
4465
+ ], Comment.prototype, "createdAt", 2);
4466
+ __decorateClass([
4467
+ (0, import_typeorm14.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
4468
+ ], Comment.prototype, "updatedAt", 2);
4469
+ __decorateClass([
4470
+ (0, import_typeorm14.Column)({ type: "timestamp", nullable: true })
4471
+ ], Comment.prototype, "deletedAt", 2);
4472
+ __decorateClass([
4473
+ (0, import_typeorm14.Column)("boolean", { default: false })
4474
+ ], Comment.prototype, "deleted", 2);
4475
+ __decorateClass([
4476
+ (0, import_typeorm14.Column)("int", { nullable: true })
4477
+ ], Comment.prototype, "createdBy", 2);
4478
+ __decorateClass([
4479
+ (0, import_typeorm14.Column)("int", { nullable: true })
4480
+ ], Comment.prototype, "updatedBy", 2);
4481
+ __decorateClass([
4482
+ (0, import_typeorm14.Column)("int", { nullable: true })
4483
+ ], Comment.prototype, "deletedBy", 2);
4484
+ __decorateClass([
4485
+ (0, import_typeorm14.ManyToOne)(() => User, { onDelete: "CASCADE" }),
4486
+ (0, import_typeorm14.JoinColumn)({ name: "authorId" })
4487
+ ], Comment.prototype, "author", 2);
4488
+ __decorateClass([
4489
+ (0, import_typeorm14.ManyToOne)(() => Blog, (b) => b.comments, { onDelete: "CASCADE" }),
4490
+ (0, import_typeorm14.JoinColumn)({ name: "blogId" })
4491
+ ], Comment.prototype, "blog", 2);
4492
+ Comment = __decorateClass([
4493
+ (0, import_typeorm14.Entity)("comments")
4494
+ ], Comment);
4495
+
4496
+ // src/entities/tag.entity.ts
4497
+ var import_typeorm15 = require("typeorm");
4498
+ var Tag = class {
4499
+ id;
4500
+ name;
4501
+ createdAt;
4502
+ updatedAt;
4503
+ deletedAt;
4504
+ deleted;
4505
+ createdBy;
4506
+ updatedBy;
4507
+ deletedBy;
4508
+ blogs;
4509
+ };
4510
+ __decorateClass([
4511
+ (0, import_typeorm15.PrimaryGeneratedColumn)()
4512
+ ], Tag.prototype, "id", 2);
4513
+ __decorateClass([
4514
+ (0, import_typeorm15.Column)("varchar", { unique: true })
4515
+ ], Tag.prototype, "name", 2);
4516
+ __decorateClass([
4517
+ (0, import_typeorm15.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
4518
+ ], Tag.prototype, "createdAt", 2);
4519
+ __decorateClass([
4520
+ (0, import_typeorm15.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
4521
+ ], Tag.prototype, "updatedAt", 2);
4522
+ __decorateClass([
4523
+ (0, import_typeorm15.Column)({ type: "timestamp", nullable: true })
4524
+ ], Tag.prototype, "deletedAt", 2);
4525
+ __decorateClass([
4526
+ (0, import_typeorm15.Column)("boolean", { default: false })
4527
+ ], Tag.prototype, "deleted", 2);
4528
+ __decorateClass([
4529
+ (0, import_typeorm15.Column)("int", { nullable: true })
4530
+ ], Tag.prototype, "createdBy", 2);
4531
+ __decorateClass([
4532
+ (0, import_typeorm15.Column)("int", { nullable: true })
4533
+ ], Tag.prototype, "updatedBy", 2);
4534
+ __decorateClass([
4535
+ (0, import_typeorm15.Column)("int", { nullable: true })
4536
+ ], Tag.prototype, "deletedBy", 2);
4537
+ __decorateClass([
4538
+ (0, import_typeorm15.ManyToMany)(() => Blog, (blog) => blog.tags)
4539
+ ], Tag.prototype, "blogs", 2);
4540
+ Tag = __decorateClass([
4541
+ (0, import_typeorm15.Entity)("tags")
4542
+ ], Tag);
4543
+
4544
+ // src/entities/blog.entity.ts
4545
+ var Blog = class {
4546
+ id;
4547
+ title;
4548
+ content;
4549
+ coverImage;
4550
+ authorId;
4551
+ categoryId;
4552
+ seoId;
4553
+ published;
4554
+ createdAt;
4555
+ updatedAt;
4556
+ deletedAt;
4557
+ deleted;
4558
+ createdBy;
4559
+ updatedBy;
4560
+ deletedBy;
4561
+ slug;
4562
+ author;
4563
+ category;
4564
+ seo;
4565
+ comments;
4566
+ tags;
4567
+ };
4568
+ __decorateClass([
4569
+ (0, import_typeorm16.PrimaryGeneratedColumn)()
4570
+ ], Blog.prototype, "id", 2);
4571
+ __decorateClass([
4572
+ (0, import_typeorm16.Column)("varchar")
4573
+ ], Blog.prototype, "title", 2);
4574
+ __decorateClass([
4575
+ (0, import_typeorm16.Column)("text")
4576
+ ], Blog.prototype, "content", 2);
4577
+ __decorateClass([
4578
+ (0, import_typeorm16.Column)("varchar", { nullable: true })
4579
+ ], Blog.prototype, "coverImage", 2);
4580
+ __decorateClass([
4581
+ (0, import_typeorm16.Column)("int")
4582
+ ], Blog.prototype, "authorId", 2);
4583
+ __decorateClass([
4584
+ (0, import_typeorm16.Column)("int", { nullable: true })
4585
+ ], Blog.prototype, "categoryId", 2);
4586
+ __decorateClass([
4587
+ (0, import_typeorm16.Column)("int", { nullable: true })
4588
+ ], Blog.prototype, "seoId", 2);
4589
+ __decorateClass([
4590
+ (0, import_typeorm16.Column)("boolean", { default: false })
4591
+ ], Blog.prototype, "published", 2);
4592
+ __decorateClass([
4593
+ (0, import_typeorm16.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
4594
+ ], Blog.prototype, "createdAt", 2);
4595
+ __decorateClass([
4596
+ (0, import_typeorm16.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
4597
+ ], Blog.prototype, "updatedAt", 2);
4598
+ __decorateClass([
4599
+ (0, import_typeorm16.Column)({ type: "timestamp", nullable: true })
4600
+ ], Blog.prototype, "deletedAt", 2);
4601
+ __decorateClass([
4602
+ (0, import_typeorm16.Column)("boolean", { default: false })
4603
+ ], Blog.prototype, "deleted", 2);
4604
+ __decorateClass([
4605
+ (0, import_typeorm16.Column)("int", { nullable: true })
4606
+ ], Blog.prototype, "createdBy", 2);
4607
+ __decorateClass([
4608
+ (0, import_typeorm16.Column)("int", { nullable: true })
4609
+ ], Blog.prototype, "updatedBy", 2);
4610
+ __decorateClass([
4611
+ (0, import_typeorm16.Column)("int", { nullable: true })
4612
+ ], Blog.prototype, "deletedBy", 2);
4613
+ __decorateClass([
4614
+ (0, import_typeorm16.Column)("varchar", { unique: true })
4615
+ ], Blog.prototype, "slug", 2);
4616
+ __decorateClass([
4617
+ (0, import_typeorm16.ManyToOne)(() => User, { onDelete: "CASCADE" }),
4618
+ (0, import_typeorm16.JoinColumn)({ name: "authorId" })
4619
+ ], Blog.prototype, "author", 2);
4620
+ __decorateClass([
4621
+ (0, import_typeorm16.ManyToOne)(() => Category, (c) => c.blogs, { onDelete: "SET NULL" }),
4622
+ (0, import_typeorm16.JoinColumn)({ name: "categoryId" })
4623
+ ], Blog.prototype, "category", 2);
4624
+ __decorateClass([
4625
+ (0, import_typeorm16.ManyToOne)(() => Seo, (s) => s.blogs, { onDelete: "SET NULL" }),
4626
+ (0, import_typeorm16.JoinColumn)({ name: "seoId" })
4627
+ ], Blog.prototype, "seo", 2);
4628
+ __decorateClass([
4629
+ (0, import_typeorm16.OneToMany)(() => Comment, (c) => c.blog)
4630
+ ], Blog.prototype, "comments", 2);
4631
+ __decorateClass([
4632
+ (0, import_typeorm16.ManyToMany)(() => Tag, (t) => t.blogs),
4633
+ (0, import_typeorm16.JoinTable)({
4634
+ name: "blog_tags",
4635
+ joinColumn: { name: "blogId", referencedColumnName: "id" },
4636
+ inverseJoinColumn: { name: "tagId", referencedColumnName: "id" }
4637
+ })
4638
+ ], Blog.prototype, "tags", 2);
4639
+ Blog = __decorateClass([
4640
+ (0, import_typeorm16.Entity)("blogs")
4641
+ ], Blog);
4642
+
4643
+ // src/entities/contact.entity.ts
4644
+ var import_typeorm25 = require("typeorm");
4645
+
4646
+ // src/entities/form-submission.entity.ts
4647
+ var import_typeorm19 = require("typeorm");
4648
+
4649
+ // src/entities/form.entity.ts
4650
+ var import_typeorm18 = require("typeorm");
4651
+
4652
+ // src/entities/form-field.entity.ts
4653
+ var import_typeorm17 = require("typeorm");
4654
+ var FormField = class {
4655
+ id;
4656
+ formId;
4657
+ label;
4658
+ type;
4659
+ placeholder;
4660
+ options;
4661
+ required;
4662
+ validation;
4663
+ order;
4664
+ groupId;
4665
+ columnWidth;
4666
+ createdAt;
4667
+ updatedAt;
4668
+ deletedAt;
4669
+ deleted;
4670
+ createdBy;
4671
+ updatedBy;
4672
+ deletedBy;
4673
+ form;
4674
+ };
4675
+ __decorateClass([
4676
+ (0, import_typeorm17.PrimaryGeneratedColumn)()
4677
+ ], FormField.prototype, "id", 2);
4678
+ __decorateClass([
4679
+ (0, import_typeorm17.Column)("int")
4680
+ ], FormField.prototype, "formId", 2);
4681
+ __decorateClass([
4682
+ (0, import_typeorm17.Column)("varchar")
4683
+ ], FormField.prototype, "label", 2);
4684
+ __decorateClass([
4685
+ (0, import_typeorm17.Column)("varchar")
4686
+ ], FormField.prototype, "type", 2);
4687
+ __decorateClass([
4688
+ (0, import_typeorm17.Column)("varchar", { nullable: true })
4689
+ ], FormField.prototype, "placeholder", 2);
4690
+ __decorateClass([
4691
+ (0, import_typeorm17.Column)("varchar", { nullable: true })
4692
+ ], FormField.prototype, "options", 2);
4693
+ __decorateClass([
4694
+ (0, import_typeorm17.Column)("boolean", { default: false })
4695
+ ], FormField.prototype, "required", 2);
4696
+ __decorateClass([
4697
+ (0, import_typeorm17.Column)("varchar", { nullable: true })
4698
+ ], FormField.prototype, "validation", 2);
4699
+ __decorateClass([
4700
+ (0, import_typeorm17.Column)("int")
4701
+ ], FormField.prototype, "order", 2);
4702
+ __decorateClass([
4703
+ (0, import_typeorm17.Column)("int", { default: 1 })
4704
+ ], FormField.prototype, "groupId", 2);
4705
+ __decorateClass([
4706
+ (0, import_typeorm17.Column)("int", { default: 12 })
4707
+ ], FormField.prototype, "columnWidth", 2);
4708
+ __decorateClass([
4709
+ (0, import_typeorm17.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
4710
+ ], FormField.prototype, "createdAt", 2);
4711
+ __decorateClass([
4712
+ (0, import_typeorm17.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
4713
+ ], FormField.prototype, "updatedAt", 2);
4714
+ __decorateClass([
4715
+ (0, import_typeorm17.Column)({ type: "timestamp", nullable: true })
4716
+ ], FormField.prototype, "deletedAt", 2);
4717
+ __decorateClass([
4718
+ (0, import_typeorm17.Column)("boolean", { default: false })
4719
+ ], FormField.prototype, "deleted", 2);
4720
+ __decorateClass([
4721
+ (0, import_typeorm17.Column)("int", { nullable: true })
4722
+ ], FormField.prototype, "createdBy", 2);
4723
+ __decorateClass([
4724
+ (0, import_typeorm17.Column)("int", { nullable: true })
4725
+ ], FormField.prototype, "updatedBy", 2);
4726
+ __decorateClass([
4727
+ (0, import_typeorm17.Column)("int", { nullable: true })
4728
+ ], FormField.prototype, "deletedBy", 2);
4729
+ __decorateClass([
4730
+ (0, import_typeorm17.ManyToOne)(() => Form, (f) => f.fields, { onDelete: "CASCADE" }),
4731
+ (0, import_typeorm17.JoinColumn)({ name: "formId" })
4732
+ ], FormField.prototype, "form", 2);
4733
+ FormField = __decorateClass([
4734
+ (0, import_typeorm17.Entity)("form_fields")
4735
+ ], FormField);
4736
+
4737
+ // src/entities/form.entity.ts
4738
+ var Form = class {
4739
+ id;
4740
+ name;
4741
+ description;
4742
+ campaign;
4743
+ slug;
4744
+ published;
4745
+ createdAt;
4746
+ updatedAt;
4747
+ deletedAt;
4748
+ deleted;
4749
+ createdBy;
4750
+ updatedBy;
4751
+ deletedBy;
4752
+ fields;
4753
+ submissions;
4754
+ };
4755
+ __decorateClass([
4756
+ (0, import_typeorm18.PrimaryGeneratedColumn)()
4757
+ ], Form.prototype, "id", 2);
4758
+ __decorateClass([
4759
+ (0, import_typeorm18.Column)("varchar")
4760
+ ], Form.prototype, "name", 2);
4761
+ __decorateClass([
4762
+ (0, import_typeorm18.Column)("text", { nullable: true })
4763
+ ], Form.prototype, "description", 2);
4764
+ __decorateClass([
4765
+ (0, import_typeorm18.Column)("varchar", { nullable: true })
4766
+ ], Form.prototype, "campaign", 2);
4767
+ __decorateClass([
4768
+ (0, import_typeorm18.Column)("varchar", { unique: true })
4769
+ ], Form.prototype, "slug", 2);
4770
+ __decorateClass([
4771
+ (0, import_typeorm18.Column)("boolean", { default: false })
4772
+ ], Form.prototype, "published", 2);
4773
+ __decorateClass([
4774
+ (0, import_typeorm18.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
4775
+ ], Form.prototype, "createdAt", 2);
4776
+ __decorateClass([
4777
+ (0, import_typeorm18.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
4778
+ ], Form.prototype, "updatedAt", 2);
4779
+ __decorateClass([
4780
+ (0, import_typeorm18.Column)({ type: "timestamp", nullable: true })
4781
+ ], Form.prototype, "deletedAt", 2);
4782
+ __decorateClass([
4783
+ (0, import_typeorm18.Column)("boolean", { default: false })
4784
+ ], Form.prototype, "deleted", 2);
4785
+ __decorateClass([
4786
+ (0, import_typeorm18.Column)("int", { nullable: true })
4787
+ ], Form.prototype, "createdBy", 2);
4788
+ __decorateClass([
4789
+ (0, import_typeorm18.Column)("int", { nullable: true })
4790
+ ], Form.prototype, "updatedBy", 2);
4791
+ __decorateClass([
4792
+ (0, import_typeorm18.Column)("int", { nullable: true })
4793
+ ], Form.prototype, "deletedBy", 2);
4794
+ __decorateClass([
4795
+ (0, import_typeorm18.OneToMany)(() => FormField, (f) => f.form)
4796
+ ], Form.prototype, "fields", 2);
4797
+ __decorateClass([
4798
+ (0, import_typeorm18.OneToMany)(() => FormSubmission, (s) => s.form)
4799
+ ], Form.prototype, "submissions", 2);
4800
+ Form = __decorateClass([
4801
+ (0, import_typeorm18.Entity)("forms")
4802
+ ], Form);
4803
+
4804
+ // src/entities/form-submission.entity.ts
4805
+ var FormSubmission = class {
4806
+ id;
4807
+ formId;
4808
+ contactId;
4809
+ data;
4810
+ ipAddress;
4811
+ userAgent;
4812
+ createdAt;
4813
+ updatedAt;
4814
+ form;
4815
+ contact;
4816
+ };
4817
+ __decorateClass([
4818
+ (0, import_typeorm19.PrimaryGeneratedColumn)()
4819
+ ], FormSubmission.prototype, "id", 2);
4820
+ __decorateClass([
4821
+ (0, import_typeorm19.Column)("int")
4822
+ ], FormSubmission.prototype, "formId", 2);
4823
+ __decorateClass([
4824
+ (0, import_typeorm19.Column)("int", { nullable: true })
4825
+ ], FormSubmission.prototype, "contactId", 2);
4826
+ __decorateClass([
4827
+ (0, import_typeorm19.Column)("jsonb")
4828
+ ], FormSubmission.prototype, "data", 2);
4829
+ __decorateClass([
4830
+ (0, import_typeorm19.Column)("varchar", { nullable: true })
4831
+ ], FormSubmission.prototype, "ipAddress", 2);
4832
+ __decorateClass([
4833
+ (0, import_typeorm19.Column)("varchar", { nullable: true })
4834
+ ], FormSubmission.prototype, "userAgent", 2);
4835
+ __decorateClass([
4836
+ (0, import_typeorm19.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
4837
+ ], FormSubmission.prototype, "createdAt", 2);
4838
+ __decorateClass([
4839
+ (0, import_typeorm19.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
4840
+ ], FormSubmission.prototype, "updatedAt", 2);
4841
+ __decorateClass([
4842
+ (0, import_typeorm19.ManyToOne)(() => Form, (f) => f.submissions, { onDelete: "CASCADE" }),
4843
+ (0, import_typeorm19.JoinColumn)({ name: "formId" })
4844
+ ], FormSubmission.prototype, "form", 2);
4845
+ __decorateClass([
4846
+ (0, import_typeorm19.ManyToOne)(() => Contact, (c) => c.form_submissions, { onDelete: "SET NULL" }),
4847
+ (0, import_typeorm19.JoinColumn)({ name: "contactId" })
4848
+ ], FormSubmission.prototype, "contact", 2);
4849
+ FormSubmission = __decorateClass([
4850
+ (0, import_typeorm19.Entity)("form_submissions")
4851
+ ], FormSubmission);
4852
+
4853
+ // src/entities/address.entity.ts
4854
+ var import_typeorm20 = require("typeorm");
4855
+ var Address = class {
4856
+ id;
4857
+ contactId;
4858
+ tag;
4859
+ line1;
4860
+ line2;
4861
+ city;
4862
+ state;
4863
+ postalCode;
4864
+ country;
4865
+ createdAt;
4866
+ updatedAt;
4867
+ contact;
4868
+ };
4869
+ __decorateClass([
4870
+ (0, import_typeorm20.PrimaryGeneratedColumn)()
4871
+ ], Address.prototype, "id", 2);
4872
+ __decorateClass([
4873
+ (0, import_typeorm20.Column)("int")
4874
+ ], Address.prototype, "contactId", 2);
4875
+ __decorateClass([
4876
+ (0, import_typeorm20.Column)("varchar", { nullable: true })
4877
+ ], Address.prototype, "tag", 2);
4878
+ __decorateClass([
4879
+ (0, import_typeorm20.Column)("varchar", { nullable: true })
4880
+ ], Address.prototype, "line1", 2);
4881
+ __decorateClass([
4882
+ (0, import_typeorm20.Column)("varchar", { nullable: true })
4883
+ ], Address.prototype, "line2", 2);
4884
+ __decorateClass([
4885
+ (0, import_typeorm20.Column)("varchar", { nullable: true })
4886
+ ], Address.prototype, "city", 2);
4887
+ __decorateClass([
4888
+ (0, import_typeorm20.Column)("varchar", { nullable: true })
4889
+ ], Address.prototype, "state", 2);
4890
+ __decorateClass([
4891
+ (0, import_typeorm20.Column)("varchar", { nullable: true })
4892
+ ], Address.prototype, "postalCode", 2);
4893
+ __decorateClass([
4894
+ (0, import_typeorm20.Column)("varchar", { nullable: true })
4895
+ ], Address.prototype, "country", 2);
4896
+ __decorateClass([
4897
+ (0, import_typeorm20.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
4898
+ ], Address.prototype, "createdAt", 2);
4899
+ __decorateClass([
4900
+ (0, import_typeorm20.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
4901
+ ], Address.prototype, "updatedAt", 2);
4902
+ __decorateClass([
4903
+ (0, import_typeorm20.ManyToOne)(() => Contact, (c) => c.addresses, { onDelete: "CASCADE" }),
4904
+ (0, import_typeorm20.JoinColumn)({ name: "contactId" })
4905
+ ], Address.prototype, "contact", 2);
4906
+ Address = __decorateClass([
4907
+ (0, import_typeorm20.Entity)("addresses")
4908
+ ], Address);
4909
+
4910
+ // src/entities/order.entity.ts
4911
+ var import_typeorm21 = require("typeorm");
4912
+ var Order = class {
4913
+ id;
4914
+ orderNumber;
4915
+ orderKind;
4916
+ parentOrderId;
4917
+ contactId;
4918
+ billingAddressId;
4919
+ shippingAddressId;
4920
+ status;
4921
+ subtotal;
4922
+ tax;
4923
+ discount;
4924
+ total;
4925
+ currency;
4926
+ metadata;
4927
+ createdAt;
4928
+ updatedAt;
4929
+ deletedAt;
4930
+ deleted;
4931
+ createdBy;
4932
+ updatedBy;
4933
+ deletedBy;
4934
+ parentOrder;
4935
+ children;
4936
+ contact;
4937
+ billingAddress;
4938
+ shippingAddress;
4939
+ items;
4940
+ payments;
4941
+ };
4942
+ __decorateClass([
4943
+ (0, import_typeorm21.PrimaryGeneratedColumn)()
4944
+ ], Order.prototype, "id", 2);
4945
+ __decorateClass([
4946
+ (0, import_typeorm21.Column)("varchar", { unique: true })
4947
+ ], Order.prototype, "orderNumber", 2);
4948
+ __decorateClass([
4949
+ (0, import_typeorm21.Column)("varchar", { default: "sale" })
4950
+ ], Order.prototype, "orderKind", 2);
4951
+ __decorateClass([
4952
+ (0, import_typeorm21.Column)("int", { nullable: true })
4953
+ ], Order.prototype, "parentOrderId", 2);
4954
+ __decorateClass([
4955
+ (0, import_typeorm21.Column)("int")
4956
+ ], Order.prototype, "contactId", 2);
4957
+ __decorateClass([
4958
+ (0, import_typeorm21.Column)("int", { nullable: true })
4959
+ ], Order.prototype, "billingAddressId", 2);
4960
+ __decorateClass([
4961
+ (0, import_typeorm21.Column)("int", { nullable: true })
4962
+ ], Order.prototype, "shippingAddressId", 2);
4963
+ __decorateClass([
4964
+ (0, import_typeorm21.Column)("varchar", { default: "pending" })
4965
+ ], Order.prototype, "status", 2);
4966
+ __decorateClass([
4967
+ (0, import_typeorm21.Column)("decimal", { precision: 12, scale: 2, default: 0 })
4968
+ ], Order.prototype, "subtotal", 2);
4969
+ __decorateClass([
4970
+ (0, import_typeorm21.Column)("decimal", { precision: 12, scale: 2, default: 0 })
4971
+ ], Order.prototype, "tax", 2);
4972
+ __decorateClass([
4973
+ (0, import_typeorm21.Column)("decimal", { precision: 12, scale: 2, default: 0 })
4974
+ ], Order.prototype, "discount", 2);
4975
+ __decorateClass([
4976
+ (0, import_typeorm21.Column)("decimal", { precision: 12, scale: 2, default: 0 })
4977
+ ], Order.prototype, "total", 2);
4978
+ __decorateClass([
4979
+ (0, import_typeorm21.Column)("varchar", { default: "INR" })
4980
+ ], Order.prototype, "currency", 2);
4981
+ __decorateClass([
4982
+ (0, import_typeorm21.Column)("jsonb", { nullable: true })
4983
+ ], Order.prototype, "metadata", 2);
4984
+ __decorateClass([
4985
+ (0, import_typeorm21.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
4986
+ ], Order.prototype, "createdAt", 2);
4987
+ __decorateClass([
4988
+ (0, import_typeorm21.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
4989
+ ], Order.prototype, "updatedAt", 2);
4990
+ __decorateClass([
4991
+ (0, import_typeorm21.Column)({ type: "timestamp", nullable: true })
4992
+ ], Order.prototype, "deletedAt", 2);
4993
+ __decorateClass([
4994
+ (0, import_typeorm21.Column)("boolean", { default: false })
4995
+ ], Order.prototype, "deleted", 2);
4996
+ __decorateClass([
4997
+ (0, import_typeorm21.Column)("int", { nullable: true })
4998
+ ], Order.prototype, "createdBy", 2);
4999
+ __decorateClass([
5000
+ (0, import_typeorm21.Column)("int", { nullable: true })
5001
+ ], Order.prototype, "updatedBy", 2);
5002
+ __decorateClass([
5003
+ (0, import_typeorm21.Column)("int", { nullable: true })
5004
+ ], Order.prototype, "deletedBy", 2);
5005
+ __decorateClass([
5006
+ (0, import_typeorm21.ManyToOne)(() => Order, (o) => o.children, { nullable: true, onDelete: "SET NULL" }),
5007
+ (0, import_typeorm21.JoinColumn)({ name: "parentOrderId" })
5008
+ ], Order.prototype, "parentOrder", 2);
5009
+ __decorateClass([
5010
+ (0, import_typeorm21.OneToMany)(() => Order, (o) => o.parentOrder)
5011
+ ], Order.prototype, "children", 2);
5012
+ __decorateClass([
5013
+ (0, import_typeorm21.ManyToOne)(() => Contact, { onDelete: "CASCADE" }),
5014
+ (0, import_typeorm21.JoinColumn)({ name: "contactId" })
5015
+ ], Order.prototype, "contact", 2);
5016
+ __decorateClass([
5017
+ (0, import_typeorm21.ManyToOne)(() => Address, { onDelete: "SET NULL" }),
5018
+ (0, import_typeorm21.JoinColumn)({ name: "billingAddressId" })
5019
+ ], Order.prototype, "billingAddress", 2);
5020
+ __decorateClass([
5021
+ (0, import_typeorm21.ManyToOne)(() => Address, { onDelete: "SET NULL" }),
5022
+ (0, import_typeorm21.JoinColumn)({ name: "shippingAddressId" })
5023
+ ], Order.prototype, "shippingAddress", 2);
5024
+ __decorateClass([
5025
+ (0, import_typeorm21.OneToMany)("OrderItem", "order")
5026
+ ], Order.prototype, "items", 2);
5027
+ __decorateClass([
5028
+ (0, import_typeorm21.OneToMany)("Payment", "order")
5029
+ ], Order.prototype, "payments", 2);
5030
+ Order = __decorateClass([
5031
+ (0, import_typeorm21.Entity)("orders")
5032
+ ], Order);
5033
+
5034
+ // src/entities/payment.entity.ts
5035
+ var import_typeorm22 = require("typeorm");
5036
+ var Payment = class {
5037
+ id;
5038
+ orderId;
5039
+ contactId;
5040
+ amount;
5041
+ currency;
5042
+ status;
5043
+ method;
5044
+ externalReference;
5045
+ metadata;
5046
+ paidAt;
5047
+ createdAt;
5048
+ updatedAt;
5049
+ deletedAt;
5050
+ deleted;
5051
+ createdBy;
5052
+ updatedBy;
5053
+ deletedBy;
5054
+ order;
5055
+ contact;
5056
+ };
5057
+ __decorateClass([
5058
+ (0, import_typeorm22.PrimaryGeneratedColumn)()
5059
+ ], Payment.prototype, "id", 2);
5060
+ __decorateClass([
5061
+ (0, import_typeorm22.Column)("int")
5062
+ ], Payment.prototype, "orderId", 2);
5063
+ __decorateClass([
5064
+ (0, import_typeorm22.Column)("int", { nullable: true })
5065
+ ], Payment.prototype, "contactId", 2);
5066
+ __decorateClass([
5067
+ (0, import_typeorm22.Column)("decimal", { precision: 12, scale: 2 })
5068
+ ], Payment.prototype, "amount", 2);
5069
+ __decorateClass([
5070
+ (0, import_typeorm22.Column)("varchar", { default: "INR" })
5071
+ ], Payment.prototype, "currency", 2);
5072
+ __decorateClass([
5073
+ (0, import_typeorm22.Column)("varchar", { default: "pending" })
5074
+ ], Payment.prototype, "status", 2);
5075
+ __decorateClass([
5076
+ (0, import_typeorm22.Column)("varchar", { nullable: true })
5077
+ ], Payment.prototype, "method", 2);
5078
+ __decorateClass([
5079
+ (0, import_typeorm22.Column)("varchar", { nullable: true })
5080
+ ], Payment.prototype, "externalReference", 2);
5081
+ __decorateClass([
5082
+ (0, import_typeorm22.Column)("jsonb", { nullable: true })
5083
+ ], Payment.prototype, "metadata", 2);
5084
+ __decorateClass([
5085
+ (0, import_typeorm22.Column)({ type: "timestamp", nullable: true })
5086
+ ], Payment.prototype, "paidAt", 2);
5087
+ __decorateClass([
5088
+ (0, import_typeorm22.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5089
+ ], Payment.prototype, "createdAt", 2);
5090
+ __decorateClass([
5091
+ (0, import_typeorm22.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5092
+ ], Payment.prototype, "updatedAt", 2);
5093
+ __decorateClass([
5094
+ (0, import_typeorm22.Column)({ type: "timestamp", nullable: true })
5095
+ ], Payment.prototype, "deletedAt", 2);
5096
+ __decorateClass([
5097
+ (0, import_typeorm22.Column)("boolean", { default: false })
5098
+ ], Payment.prototype, "deleted", 2);
5099
+ __decorateClass([
5100
+ (0, import_typeorm22.Column)("int", { nullable: true })
5101
+ ], Payment.prototype, "createdBy", 2);
5102
+ __decorateClass([
5103
+ (0, import_typeorm22.Column)("int", { nullable: true })
5104
+ ], Payment.prototype, "updatedBy", 2);
5105
+ __decorateClass([
5106
+ (0, import_typeorm22.Column)("int", { nullable: true })
5107
+ ], Payment.prototype, "deletedBy", 2);
5108
+ __decorateClass([
5109
+ (0, import_typeorm22.ManyToOne)(() => Order, (o) => o.payments, { onDelete: "CASCADE" }),
5110
+ (0, import_typeorm22.JoinColumn)({ name: "orderId" })
5111
+ ], Payment.prototype, "order", 2);
5112
+ __decorateClass([
5113
+ (0, import_typeorm22.ManyToOne)(() => Contact, { onDelete: "SET NULL" }),
5114
+ (0, import_typeorm22.JoinColumn)({ name: "contactId" })
5115
+ ], Payment.prototype, "contact", 2);
5116
+ Payment = __decorateClass([
5117
+ (0, import_typeorm22.Entity)("payments")
5118
+ ], Payment);
5119
+
5120
+ // src/entities/chat-conversation.entity.ts
5121
+ var import_typeorm24 = require("typeorm");
5122
+
5123
+ // src/entities/chat-message.entity.ts
5124
+ var import_typeorm23 = require("typeorm");
5125
+ var ChatMessage = class {
5126
+ id;
5127
+ conversationId;
5128
+ role;
5129
+ content;
5130
+ createdAt;
5131
+ conversation;
5132
+ };
5133
+ __decorateClass([
5134
+ (0, import_typeorm23.PrimaryGeneratedColumn)()
5135
+ ], ChatMessage.prototype, "id", 2);
5136
+ __decorateClass([
5137
+ (0, import_typeorm23.Column)("int")
5138
+ ], ChatMessage.prototype, "conversationId", 2);
5139
+ __decorateClass([
5140
+ (0, import_typeorm23.Column)("varchar")
5141
+ ], ChatMessage.prototype, "role", 2);
5142
+ __decorateClass([
5143
+ (0, import_typeorm23.Column)("text")
5144
+ ], ChatMessage.prototype, "content", 2);
5145
+ __decorateClass([
5146
+ (0, import_typeorm23.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5147
+ ], ChatMessage.prototype, "createdAt", 2);
5148
+ __decorateClass([
5149
+ (0, import_typeorm23.ManyToOne)(() => ChatConversation, (c) => c.messages, { onDelete: "CASCADE" }),
5150
+ (0, import_typeorm23.JoinColumn)({ name: "conversationId" })
5151
+ ], ChatMessage.prototype, "conversation", 2);
5152
+ ChatMessage = __decorateClass([
5153
+ (0, import_typeorm23.Entity)("chat_messages")
5154
+ ], ChatMessage);
5155
+
5156
+ // src/entities/chat-conversation.entity.ts
5157
+ var ChatConversation = class {
5158
+ id;
5159
+ contactId;
5160
+ createdAt;
5161
+ updatedAt;
5162
+ contact;
5163
+ messages;
5164
+ };
5165
+ __decorateClass([
5166
+ (0, import_typeorm24.PrimaryGeneratedColumn)()
5167
+ ], ChatConversation.prototype, "id", 2);
5168
+ __decorateClass([
5169
+ (0, import_typeorm24.Column)("int")
5170
+ ], ChatConversation.prototype, "contactId", 2);
5171
+ __decorateClass([
5172
+ (0, import_typeorm24.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5173
+ ], ChatConversation.prototype, "createdAt", 2);
5174
+ __decorateClass([
5175
+ (0, import_typeorm24.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5176
+ ], ChatConversation.prototype, "updatedAt", 2);
5177
+ __decorateClass([
5178
+ (0, import_typeorm24.ManyToOne)(() => Contact, (c) => c.chatConversations, { onDelete: "CASCADE" }),
5179
+ (0, import_typeorm24.JoinColumn)({ name: "contactId" })
5180
+ ], ChatConversation.prototype, "contact", 2);
5181
+ __decorateClass([
5182
+ (0, import_typeorm24.OneToMany)(() => ChatMessage, (m) => m.conversation)
5183
+ ], ChatConversation.prototype, "messages", 2);
5184
+ ChatConversation = __decorateClass([
5185
+ (0, import_typeorm24.Entity)("chat_conversations")
5186
+ ], ChatConversation);
5187
+
5188
+ // src/entities/contact.entity.ts
5189
+ var Contact = class {
5190
+ id;
5191
+ name;
5192
+ email;
5193
+ phone;
5194
+ type;
5195
+ company;
5196
+ taxId;
5197
+ notes;
5198
+ createdAt;
5199
+ updatedAt;
5200
+ deletedAt;
5201
+ deleted;
5202
+ createdBy;
5203
+ updatedBy;
5204
+ deletedBy;
5205
+ userId;
5206
+ user;
5207
+ form_submissions;
5208
+ addresses;
5209
+ orders;
5210
+ payments;
5211
+ chatConversations;
5212
+ };
5213
+ __decorateClass([
5214
+ (0, import_typeorm25.PrimaryGeneratedColumn)()
5215
+ ], Contact.prototype, "id", 2);
5216
+ __decorateClass([
5217
+ (0, import_typeorm25.Column)("varchar")
5218
+ ], Contact.prototype, "name", 2);
5219
+ __decorateClass([
5220
+ (0, import_typeorm25.Column)("varchar", { unique: true })
5221
+ ], Contact.prototype, "email", 2);
5222
+ __decorateClass([
5223
+ (0, import_typeorm25.Column)("varchar", { nullable: true })
5224
+ ], Contact.prototype, "phone", 2);
5225
+ __decorateClass([
5226
+ (0, import_typeorm25.Column)("varchar", { nullable: true })
5227
+ ], Contact.prototype, "type", 2);
5228
+ __decorateClass([
5229
+ (0, import_typeorm25.Column)("varchar", { nullable: true })
5230
+ ], Contact.prototype, "company", 2);
5231
+ __decorateClass([
5232
+ (0, import_typeorm25.Column)("varchar", { nullable: true })
5233
+ ], Contact.prototype, "taxId", 2);
5234
+ __decorateClass([
5235
+ (0, import_typeorm25.Column)("text", { nullable: true })
5236
+ ], Contact.prototype, "notes", 2);
5237
+ __decorateClass([
5238
+ (0, import_typeorm25.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5239
+ ], Contact.prototype, "createdAt", 2);
5240
+ __decorateClass([
5241
+ (0, import_typeorm25.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5242
+ ], Contact.prototype, "updatedAt", 2);
5243
+ __decorateClass([
5244
+ (0, import_typeorm25.Column)({ type: "timestamp", nullable: true })
5245
+ ], Contact.prototype, "deletedAt", 2);
5246
+ __decorateClass([
5247
+ (0, import_typeorm25.Column)("boolean", { default: false })
5248
+ ], Contact.prototype, "deleted", 2);
5249
+ __decorateClass([
5250
+ (0, import_typeorm25.Column)("int", { nullable: true })
5251
+ ], Contact.prototype, "createdBy", 2);
5252
+ __decorateClass([
5253
+ (0, import_typeorm25.Column)("int", { nullable: true })
5254
+ ], Contact.prototype, "updatedBy", 2);
5255
+ __decorateClass([
5256
+ (0, import_typeorm25.Column)("int", { nullable: true })
5257
+ ], Contact.prototype, "deletedBy", 2);
5258
+ __decorateClass([
5259
+ (0, import_typeorm25.Column)("int", { nullable: true })
5260
+ ], Contact.prototype, "userId", 2);
5261
+ __decorateClass([
5262
+ (0, import_typeorm25.ManyToOne)(() => User, { onDelete: "SET NULL" }),
5263
+ (0, import_typeorm25.JoinColumn)({ name: "userId" })
5264
+ ], Contact.prototype, "user", 2);
5265
+ __decorateClass([
5266
+ (0, import_typeorm25.OneToMany)(() => FormSubmission, (fs) => fs.contact)
5267
+ ], Contact.prototype, "form_submissions", 2);
5268
+ __decorateClass([
5269
+ (0, import_typeorm25.OneToMany)(() => Address, (a) => a.contact)
5270
+ ], Contact.prototype, "addresses", 2);
5271
+ __decorateClass([
5272
+ (0, import_typeorm25.OneToMany)(() => Order, (o) => o.contact)
5273
+ ], Contact.prototype, "orders", 2);
5274
+ __decorateClass([
5275
+ (0, import_typeorm25.OneToMany)(() => Payment, (p) => p.contact)
5276
+ ], Contact.prototype, "payments", 2);
5277
+ __decorateClass([
5278
+ (0, import_typeorm25.OneToMany)(() => ChatConversation, (c) => c.contact)
5279
+ ], Contact.prototype, "chatConversations", 2);
5280
+ Contact = __decorateClass([
5281
+ (0, import_typeorm25.Entity)("contacts")
5282
+ ], Contact);
5283
+
5284
+ // src/entities/config.entity.ts
5285
+ var import_typeorm26 = require("typeorm");
5286
+ var Config = class {
5287
+ id;
5288
+ settings;
5289
+ key;
5290
+ value;
5291
+ type;
5292
+ encrypted;
5293
+ createdAt;
5294
+ updatedAt;
5295
+ deletedAt;
5296
+ deleted;
5297
+ createdBy;
5298
+ updatedBy;
5299
+ deletedBy;
5300
+ };
5301
+ __decorateClass([
5302
+ (0, import_typeorm26.PrimaryGeneratedColumn)()
5303
+ ], Config.prototype, "id", 2);
5304
+ __decorateClass([
5305
+ (0, import_typeorm26.Column)("varchar")
5306
+ ], Config.prototype, "settings", 2);
5307
+ __decorateClass([
5308
+ (0, import_typeorm26.Column)("varchar")
5309
+ ], Config.prototype, "key", 2);
5310
+ __decorateClass([
5311
+ (0, import_typeorm26.Column)("varchar")
5312
+ ], Config.prototype, "value", 2);
5313
+ __decorateClass([
5314
+ (0, import_typeorm26.Column)("varchar", { default: "private" })
5315
+ ], Config.prototype, "type", 2);
5316
+ __decorateClass([
5317
+ (0, import_typeorm26.Column)("boolean", { default: false })
5318
+ ], Config.prototype, "encrypted", 2);
5319
+ __decorateClass([
5320
+ (0, import_typeorm26.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5321
+ ], Config.prototype, "createdAt", 2);
5322
+ __decorateClass([
5323
+ (0, import_typeorm26.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5324
+ ], Config.prototype, "updatedAt", 2);
5325
+ __decorateClass([
5326
+ (0, import_typeorm26.Column)({ type: "timestamp", nullable: true })
5327
+ ], Config.prototype, "deletedAt", 2);
5328
+ __decorateClass([
5329
+ (0, import_typeorm26.Column)("boolean", { default: false })
5330
+ ], Config.prototype, "deleted", 2);
5331
+ __decorateClass([
5332
+ (0, import_typeorm26.Column)("int", { nullable: true })
5333
+ ], Config.prototype, "createdBy", 2);
5334
+ __decorateClass([
5335
+ (0, import_typeorm26.Column)("int", { nullable: true })
5336
+ ], Config.prototype, "updatedBy", 2);
5337
+ __decorateClass([
5338
+ (0, import_typeorm26.Column)("int", { nullable: true })
5339
+ ], Config.prototype, "deletedBy", 2);
5340
+ Config = __decorateClass([
5341
+ (0, import_typeorm26.Entity)("configs"),
5342
+ (0, import_typeorm26.Unique)(["settings", "key"])
5343
+ ], Config);
5344
+
5345
+ // src/entities/message-template.entity.ts
5346
+ var import_typeorm27 = require("typeorm");
5347
+ var MessageTemplate = class {
5348
+ id;
5349
+ channel;
5350
+ templateKey;
5351
+ name;
5352
+ subject;
5353
+ body;
5354
+ externalTemplateRef;
5355
+ providerMeta;
5356
+ enabled;
5357
+ createdAt;
5358
+ updatedAt;
5359
+ deletedAt;
5360
+ deleted;
5361
+ createdBy;
5362
+ updatedBy;
5363
+ deletedBy;
5364
+ };
5365
+ __decorateClass([
5366
+ (0, import_typeorm27.PrimaryGeneratedColumn)()
5367
+ ], MessageTemplate.prototype, "id", 2);
5368
+ __decorateClass([
5369
+ (0, import_typeorm27.Column)("varchar")
5370
+ ], MessageTemplate.prototype, "channel", 2);
5371
+ __decorateClass([
5372
+ (0, import_typeorm27.Column)("varchar", { name: "template_key" })
5373
+ ], MessageTemplate.prototype, "templateKey", 2);
5374
+ __decorateClass([
5375
+ (0, import_typeorm27.Column)("varchar", { nullable: true })
5376
+ ], MessageTemplate.prototype, "name", 2);
5377
+ __decorateClass([
5378
+ (0, import_typeorm27.Column)("varchar", { nullable: true })
5379
+ ], MessageTemplate.prototype, "subject", 2);
5380
+ __decorateClass([
5381
+ (0, import_typeorm27.Column)("text", { default: "" })
5382
+ ], MessageTemplate.prototype, "body", 2);
5383
+ __decorateClass([
5384
+ (0, import_typeorm27.Column)("varchar", { name: "external_template_ref", nullable: true })
5385
+ ], MessageTemplate.prototype, "externalTemplateRef", 2);
5386
+ __decorateClass([
5387
+ (0, import_typeorm27.Column)({ type: "jsonb", nullable: true })
5388
+ ], MessageTemplate.prototype, "providerMeta", 2);
5389
+ __decorateClass([
5390
+ (0, import_typeorm27.Column)("boolean", { default: true })
5391
+ ], MessageTemplate.prototype, "enabled", 2);
5392
+ __decorateClass([
5393
+ (0, import_typeorm27.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5394
+ ], MessageTemplate.prototype, "createdAt", 2);
5395
+ __decorateClass([
5396
+ (0, import_typeorm27.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5397
+ ], MessageTemplate.prototype, "updatedAt", 2);
5398
+ __decorateClass([
5399
+ (0, import_typeorm27.Column)({ type: "timestamp", nullable: true })
5400
+ ], MessageTemplate.prototype, "deletedAt", 2);
5401
+ __decorateClass([
5402
+ (0, import_typeorm27.Column)("boolean", { default: false })
5403
+ ], MessageTemplate.prototype, "deleted", 2);
5404
+ __decorateClass([
5405
+ (0, import_typeorm27.Column)("int", { nullable: true })
5406
+ ], MessageTemplate.prototype, "createdBy", 2);
5407
+ __decorateClass([
5408
+ (0, import_typeorm27.Column)("int", { nullable: true })
5409
+ ], MessageTemplate.prototype, "updatedBy", 2);
5410
+ __decorateClass([
5411
+ (0, import_typeorm27.Column)("int", { nullable: true })
5412
+ ], MessageTemplate.prototype, "deletedBy", 2);
5413
+ MessageTemplate = __decorateClass([
5414
+ (0, import_typeorm27.Entity)("message_templates")
5415
+ ], MessageTemplate);
5416
+
5417
+ // src/entities/media.entity.ts
5418
+ var import_typeorm28 = require("typeorm");
5419
+ var Media = class {
5420
+ id;
5421
+ kind;
5422
+ parentId;
5423
+ parent;
5424
+ children;
5425
+ filename;
5426
+ url;
5427
+ mimeType;
5428
+ size;
5429
+ alt;
5430
+ isPublic;
5431
+ createdAt;
5432
+ updatedAt;
5433
+ deletedAt;
5434
+ deleted;
5435
+ };
5436
+ __decorateClass([
5437
+ (0, import_typeorm28.PrimaryGeneratedColumn)()
5438
+ ], Media.prototype, "id", 2);
5439
+ __decorateClass([
5440
+ (0, import_typeorm28.Column)({ type: "varchar", length: 16, default: "file" })
5441
+ ], Media.prototype, "kind", 2);
5442
+ __decorateClass([
5443
+ (0, import_typeorm28.Column)({ type: "int", nullable: true })
5444
+ ], Media.prototype, "parentId", 2);
5445
+ __decorateClass([
5446
+ (0, import_typeorm28.ManyToOne)(() => Media, (m) => m.children, { onDelete: "CASCADE" }),
5447
+ (0, import_typeorm28.JoinColumn)({ name: "parentId" })
5448
+ ], Media.prototype, "parent", 2);
5449
+ __decorateClass([
5450
+ (0, import_typeorm28.OneToMany)(() => Media, (m) => m.parent)
5451
+ ], Media.prototype, "children", 2);
5452
+ __decorateClass([
5453
+ (0, import_typeorm28.Column)("varchar")
5454
+ ], Media.prototype, "filename", 2);
5455
+ __decorateClass([
5456
+ (0, import_typeorm28.Column)("varchar", { nullable: true })
5457
+ ], Media.prototype, "url", 2);
5458
+ __decorateClass([
5459
+ (0, import_typeorm28.Column)("varchar", { nullable: true })
5460
+ ], Media.prototype, "mimeType", 2);
5461
+ __decorateClass([
5462
+ (0, import_typeorm28.Column)("int", { default: 0 })
5463
+ ], Media.prototype, "size", 2);
5464
+ __decorateClass([
5465
+ (0, import_typeorm28.Column)("varchar", { nullable: true })
5466
+ ], Media.prototype, "alt", 2);
5467
+ __decorateClass([
5468
+ (0, import_typeorm28.Column)("boolean", { default: false })
5469
+ ], Media.prototype, "isPublic", 2);
5470
+ __decorateClass([
5471
+ (0, import_typeorm28.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5472
+ ], Media.prototype, "createdAt", 2);
5473
+ __decorateClass([
5474
+ (0, import_typeorm28.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5475
+ ], Media.prototype, "updatedAt", 2);
5476
+ __decorateClass([
5477
+ (0, import_typeorm28.Column)({ type: "timestamp", nullable: true })
5478
+ ], Media.prototype, "deletedAt", 2);
5479
+ __decorateClass([
5480
+ (0, import_typeorm28.Column)("boolean", { default: false })
5481
+ ], Media.prototype, "deleted", 2);
5482
+ Media = __decorateClass([
5483
+ (0, import_typeorm28.Entity)("media")
5484
+ ], Media);
5485
+
5486
+ // src/entities/page.entity.ts
5487
+ var import_typeorm29 = require("typeorm");
5488
+ var Page = class {
5489
+ id;
5490
+ title;
5491
+ slug;
5492
+ content;
5493
+ published;
5494
+ theme;
5495
+ parentId;
5496
+ parent;
5497
+ seoId;
5498
+ seo;
5499
+ createdAt;
5500
+ updatedAt;
5501
+ deletedAt;
5502
+ deleted;
5503
+ createdBy;
5504
+ updatedBy;
5505
+ deletedBy;
5506
+ };
5507
+ __decorateClass([
5508
+ (0, import_typeorm29.PrimaryGeneratedColumn)()
5509
+ ], Page.prototype, "id", 2);
5510
+ __decorateClass([
5511
+ (0, import_typeorm29.Column)("varchar")
5512
+ ], Page.prototype, "title", 2);
5513
+ __decorateClass([
5514
+ (0, import_typeorm29.Column)("varchar", { unique: true })
5515
+ ], Page.prototype, "slug", 2);
5516
+ __decorateClass([
5517
+ (0, import_typeorm29.Column)({ type: "jsonb", default: {} })
5518
+ ], Page.prototype, "content", 2);
5519
+ __decorateClass([
5520
+ (0, import_typeorm29.Column)("boolean", { default: false })
5521
+ ], Page.prototype, "published", 2);
5522
+ __decorateClass([
5523
+ (0, import_typeorm29.Column)("varchar", { default: "default" })
5524
+ ], Page.prototype, "theme", 2);
5525
+ __decorateClass([
5526
+ (0, import_typeorm29.Column)("int", { nullable: true })
5527
+ ], Page.prototype, "parentId", 2);
5528
+ __decorateClass([
5529
+ (0, import_typeorm29.ManyToOne)(() => Page, { onDelete: "SET NULL" }),
5530
+ (0, import_typeorm29.JoinColumn)({ name: "parentId" })
5531
+ ], Page.prototype, "parent", 2);
5532
+ __decorateClass([
5533
+ (0, import_typeorm29.Column)("int", { nullable: true })
5534
+ ], Page.prototype, "seoId", 2);
5535
+ __decorateClass([
5536
+ (0, import_typeorm29.ManyToOne)(() => Seo, { onDelete: "SET NULL" }),
5537
+ (0, import_typeorm29.JoinColumn)({ name: "seoId" })
5538
+ ], Page.prototype, "seo", 2);
5539
+ __decorateClass([
5540
+ (0, import_typeorm29.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5541
+ ], Page.prototype, "createdAt", 2);
5542
+ __decorateClass([
5543
+ (0, import_typeorm29.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5544
+ ], Page.prototype, "updatedAt", 2);
5545
+ __decorateClass([
5546
+ (0, import_typeorm29.Column)({ type: "timestamp", nullable: true })
5547
+ ], Page.prototype, "deletedAt", 2);
5548
+ __decorateClass([
5549
+ (0, import_typeorm29.Column)("boolean", { default: false })
5550
+ ], Page.prototype, "deleted", 2);
5551
+ __decorateClass([
5552
+ (0, import_typeorm29.Column)("int", { nullable: true })
5553
+ ], Page.prototype, "createdBy", 2);
5554
+ __decorateClass([
5555
+ (0, import_typeorm29.Column)("int", { nullable: true })
5556
+ ], Page.prototype, "updatedBy", 2);
5557
+ __decorateClass([
5558
+ (0, import_typeorm29.Column)("int", { nullable: true })
5559
+ ], Page.prototype, "deletedBy", 2);
5560
+ Page = __decorateClass([
5561
+ (0, import_typeorm29.Entity)("pages")
5562
+ ], Page);
5563
+
5564
+ // src/entities/product-category.entity.ts
5565
+ var import_typeorm30 = require("typeorm");
5566
+ var ProductCategory = class {
5567
+ id;
5568
+ name;
5569
+ slug;
5570
+ parentId;
5571
+ image;
5572
+ description;
5573
+ metadata;
5574
+ active;
5575
+ sortOrder;
5576
+ createdAt;
5577
+ updatedAt;
5578
+ deletedAt;
5579
+ deleted;
5580
+ createdBy;
5581
+ updatedBy;
5582
+ deletedBy;
5583
+ parent;
5584
+ children;
5585
+ products;
5586
+ collections;
5587
+ };
5588
+ __decorateClass([
5589
+ (0, import_typeorm30.PrimaryGeneratedColumn)()
5590
+ ], ProductCategory.prototype, "id", 2);
5591
+ __decorateClass([
5592
+ (0, import_typeorm30.Column)("varchar")
5593
+ ], ProductCategory.prototype, "name", 2);
5594
+ __decorateClass([
5595
+ (0, import_typeorm30.Column)("varchar", { unique: true })
5596
+ ], ProductCategory.prototype, "slug", 2);
5597
+ __decorateClass([
5598
+ (0, import_typeorm30.Column)("int", { nullable: true })
5599
+ ], ProductCategory.prototype, "parentId", 2);
5600
+ __decorateClass([
5601
+ (0, import_typeorm30.Column)("varchar", { nullable: true })
5602
+ ], ProductCategory.prototype, "image", 2);
5603
+ __decorateClass([
5604
+ (0, import_typeorm30.Column)("text", { nullable: true })
5605
+ ], ProductCategory.prototype, "description", 2);
5606
+ __decorateClass([
5607
+ (0, import_typeorm30.Column)("jsonb", { nullable: true })
5608
+ ], ProductCategory.prototype, "metadata", 2);
5609
+ __decorateClass([
5610
+ (0, import_typeorm30.Column)("boolean", { default: true })
5611
+ ], ProductCategory.prototype, "active", 2);
5612
+ __decorateClass([
5613
+ (0, import_typeorm30.Column)("int", { default: 0 })
5614
+ ], ProductCategory.prototype, "sortOrder", 2);
5615
+ __decorateClass([
5616
+ (0, import_typeorm30.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5617
+ ], ProductCategory.prototype, "createdAt", 2);
5618
+ __decorateClass([
5619
+ (0, import_typeorm30.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5620
+ ], ProductCategory.prototype, "updatedAt", 2);
5621
+ __decorateClass([
5622
+ (0, import_typeorm30.Column)({ type: "timestamp", nullable: true })
5623
+ ], ProductCategory.prototype, "deletedAt", 2);
5624
+ __decorateClass([
5625
+ (0, import_typeorm30.Column)("boolean", { default: false })
5626
+ ], ProductCategory.prototype, "deleted", 2);
5627
+ __decorateClass([
5628
+ (0, import_typeorm30.Column)("int", { nullable: true })
5629
+ ], ProductCategory.prototype, "createdBy", 2);
5630
+ __decorateClass([
5631
+ (0, import_typeorm30.Column)("int", { nullable: true })
5632
+ ], ProductCategory.prototype, "updatedBy", 2);
5633
+ __decorateClass([
5634
+ (0, import_typeorm30.Column)("int", { nullable: true })
5635
+ ], ProductCategory.prototype, "deletedBy", 2);
5636
+ __decorateClass([
5637
+ (0, import_typeorm30.ManyToOne)(() => ProductCategory, (c) => c.children, { onDelete: "SET NULL" }),
5638
+ (0, import_typeorm30.JoinColumn)({ name: "parentId" })
5639
+ ], ProductCategory.prototype, "parent", 2);
5640
+ __decorateClass([
5641
+ (0, import_typeorm30.OneToMany)(() => ProductCategory, (c) => c.parent)
5642
+ ], ProductCategory.prototype, "children", 2);
5643
+ __decorateClass([
5644
+ (0, import_typeorm30.OneToMany)("Product", "category")
5645
+ ], ProductCategory.prototype, "products", 2);
5646
+ __decorateClass([
5647
+ (0, import_typeorm30.OneToMany)("Collection", "category")
5648
+ ], ProductCategory.prototype, "collections", 2);
5649
+ ProductCategory = __decorateClass([
5650
+ (0, import_typeorm30.Entity)("product_categories")
5651
+ ], ProductCategory);
5652
+
5653
+ // src/entities/collection.entity.ts
5654
+ var import_typeorm32 = require("typeorm");
5655
+
5656
+ // src/entities/brand.entity.ts
5657
+ var import_typeorm31 = require("typeorm");
5658
+ var Brand = class {
5659
+ id;
5660
+ name;
5661
+ slug;
5662
+ logo;
5663
+ metadata;
5664
+ description;
5665
+ active;
5666
+ sortOrder;
5667
+ createdAt;
5668
+ updatedAt;
5669
+ deletedAt;
5670
+ deleted;
5671
+ createdBy;
5672
+ updatedBy;
5673
+ deletedBy;
5674
+ seoId;
5675
+ seo;
5676
+ products;
5677
+ collections;
5678
+ };
5679
+ __decorateClass([
5680
+ (0, import_typeorm31.PrimaryGeneratedColumn)()
5681
+ ], Brand.prototype, "id", 2);
5682
+ __decorateClass([
5683
+ (0, import_typeorm31.Column)("varchar")
5684
+ ], Brand.prototype, "name", 2);
5685
+ __decorateClass([
5686
+ (0, import_typeorm31.Column)("varchar", { unique: true })
5687
+ ], Brand.prototype, "slug", 2);
5688
+ __decorateClass([
5689
+ (0, import_typeorm31.Column)("varchar", { nullable: true })
5690
+ ], Brand.prototype, "logo", 2);
5691
+ __decorateClass([
5692
+ (0, import_typeorm31.Column)("jsonb", { nullable: true })
5693
+ ], Brand.prototype, "metadata", 2);
5694
+ __decorateClass([
5695
+ (0, import_typeorm31.Column)("text", { nullable: true })
5696
+ ], Brand.prototype, "description", 2);
5697
+ __decorateClass([
5698
+ (0, import_typeorm31.Column)("boolean", { default: true })
5699
+ ], Brand.prototype, "active", 2);
5700
+ __decorateClass([
5701
+ (0, import_typeorm31.Column)("int", { default: 0 })
5702
+ ], Brand.prototype, "sortOrder", 2);
5703
+ __decorateClass([
5704
+ (0, import_typeorm31.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5705
+ ], Brand.prototype, "createdAt", 2);
5706
+ __decorateClass([
5707
+ (0, import_typeorm31.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5708
+ ], Brand.prototype, "updatedAt", 2);
5709
+ __decorateClass([
5710
+ (0, import_typeorm31.Column)({ type: "timestamp", nullable: true })
5711
+ ], Brand.prototype, "deletedAt", 2);
5712
+ __decorateClass([
5713
+ (0, import_typeorm31.Column)("boolean", { default: false })
5714
+ ], Brand.prototype, "deleted", 2);
5715
+ __decorateClass([
5716
+ (0, import_typeorm31.Column)("int", { nullable: true })
5717
+ ], Brand.prototype, "createdBy", 2);
5718
+ __decorateClass([
5719
+ (0, import_typeorm31.Column)("int", { nullable: true })
5720
+ ], Brand.prototype, "updatedBy", 2);
5721
+ __decorateClass([
5722
+ (0, import_typeorm31.Column)("int", { nullable: true })
5723
+ ], Brand.prototype, "deletedBy", 2);
5724
+ __decorateClass([
5725
+ (0, import_typeorm31.Column)("int", { nullable: true })
5726
+ ], Brand.prototype, "seoId", 2);
5727
+ __decorateClass([
5728
+ (0, import_typeorm31.ManyToOne)(() => Seo, { onDelete: "SET NULL" }),
5729
+ (0, import_typeorm31.JoinColumn)({ name: "seoId" })
5730
+ ], Brand.prototype, "seo", 2);
5731
+ __decorateClass([
5732
+ (0, import_typeorm31.OneToMany)("Product", "brand")
5733
+ ], Brand.prototype, "products", 2);
5734
+ __decorateClass([
5735
+ (0, import_typeorm31.OneToMany)("Collection", "brand")
5736
+ ], Brand.prototype, "collections", 2);
5737
+ Brand = __decorateClass([
5738
+ (0, import_typeorm31.Entity)("brands")
5739
+ ], Brand);
5740
+
5741
+ // src/entities/collection.entity.ts
5742
+ var Collection = class {
5743
+ id;
5744
+ categoryId;
5745
+ brandId;
5746
+ name;
5747
+ slug;
5748
+ hsn;
5749
+ description;
5750
+ image;
5751
+ metadata;
5752
+ variants;
5753
+ active;
5754
+ sortOrder;
5755
+ createdAt;
5756
+ updatedAt;
5757
+ deletedAt;
5758
+ deleted;
5759
+ createdBy;
5760
+ updatedBy;
5761
+ deletedBy;
5762
+ seoId;
5763
+ seo;
5764
+ category;
5765
+ brand;
5766
+ products;
5767
+ };
5768
+ __decorateClass([
5769
+ (0, import_typeorm32.PrimaryGeneratedColumn)()
5770
+ ], Collection.prototype, "id", 2);
5771
+ __decorateClass([
5772
+ (0, import_typeorm32.Column)("int", { nullable: true })
5773
+ ], Collection.prototype, "categoryId", 2);
5774
+ __decorateClass([
5775
+ (0, import_typeorm32.Column)("int", { nullable: true })
5776
+ ], Collection.prototype, "brandId", 2);
5777
+ __decorateClass([
5778
+ (0, import_typeorm32.Column)("varchar")
5779
+ ], Collection.prototype, "name", 2);
5780
+ __decorateClass([
5781
+ (0, import_typeorm32.Column)("varchar", { unique: true })
5782
+ ], Collection.prototype, "slug", 2);
5783
+ __decorateClass([
5784
+ (0, import_typeorm32.Column)("varchar", { nullable: true })
5785
+ ], Collection.prototype, "hsn", 2);
5786
+ __decorateClass([
5787
+ (0, import_typeorm32.Column)("text", { nullable: true })
5788
+ ], Collection.prototype, "description", 2);
5789
+ __decorateClass([
5790
+ (0, import_typeorm32.Column)("varchar", { nullable: true })
5791
+ ], Collection.prototype, "image", 2);
5792
+ __decorateClass([
5793
+ (0, import_typeorm32.Column)("jsonb", { nullable: true })
5794
+ ], Collection.prototype, "metadata", 2);
5795
+ __decorateClass([
5796
+ (0, import_typeorm32.Column)("jsonb", { nullable: true })
5797
+ ], Collection.prototype, "variants", 2);
5798
+ __decorateClass([
5799
+ (0, import_typeorm32.Column)("boolean", { default: true })
5800
+ ], Collection.prototype, "active", 2);
5801
+ __decorateClass([
5802
+ (0, import_typeorm32.Column)("int", { default: 0 })
5803
+ ], Collection.prototype, "sortOrder", 2);
5804
+ __decorateClass([
5805
+ (0, import_typeorm32.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5806
+ ], Collection.prototype, "createdAt", 2);
5807
+ __decorateClass([
5808
+ (0, import_typeorm32.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5809
+ ], Collection.prototype, "updatedAt", 2);
5810
+ __decorateClass([
5811
+ (0, import_typeorm32.Column)({ type: "timestamp", nullable: true })
5812
+ ], Collection.prototype, "deletedAt", 2);
5813
+ __decorateClass([
5814
+ (0, import_typeorm32.Column)("boolean", { default: false })
5815
+ ], Collection.prototype, "deleted", 2);
5816
+ __decorateClass([
5817
+ (0, import_typeorm32.Column)("int", { nullable: true })
5818
+ ], Collection.prototype, "createdBy", 2);
5819
+ __decorateClass([
5820
+ (0, import_typeorm32.Column)("int", { nullable: true })
5821
+ ], Collection.prototype, "updatedBy", 2);
5822
+ __decorateClass([
5823
+ (0, import_typeorm32.Column)("int", { nullable: true })
5824
+ ], Collection.prototype, "deletedBy", 2);
5825
+ __decorateClass([
5826
+ (0, import_typeorm32.Column)("int", { nullable: true })
5827
+ ], Collection.prototype, "seoId", 2);
5828
+ __decorateClass([
5829
+ (0, import_typeorm32.ManyToOne)(() => Seo, { onDelete: "SET NULL" }),
5830
+ (0, import_typeorm32.JoinColumn)({ name: "seoId" })
5831
+ ], Collection.prototype, "seo", 2);
5832
+ __decorateClass([
5833
+ (0, import_typeorm32.ManyToOne)(() => ProductCategory, (c) => c.collections, { onDelete: "SET NULL" }),
5834
+ (0, import_typeorm32.JoinColumn)({ name: "categoryId" })
5835
+ ], Collection.prototype, "category", 2);
5836
+ __decorateClass([
5837
+ (0, import_typeorm32.ManyToOne)(() => Brand, (b) => b.collections, { onDelete: "SET NULL" }),
5838
+ (0, import_typeorm32.JoinColumn)({ name: "brandId" })
5839
+ ], Collection.prototype, "brand", 2);
5840
+ __decorateClass([
5841
+ (0, import_typeorm32.OneToMany)("Product", "collection")
5842
+ ], Collection.prototype, "products", 2);
5843
+ Collection = __decorateClass([
5844
+ (0, import_typeorm32.Entity)("collections")
5845
+ ], Collection);
5846
+
5847
+ // src/entities/product.entity.ts
5848
+ var import_typeorm33 = require("typeorm");
5849
+ var Product = class {
5850
+ id;
5851
+ collectionId;
5852
+ brandId;
5853
+ categoryId;
5854
+ sku;
5855
+ hsn;
5856
+ uom;
5857
+ type;
5858
+ slug;
5859
+ name;
5860
+ price;
5861
+ compareAtPrice;
5862
+ quantity;
5863
+ status;
5864
+ featured;
5865
+ metadata;
5866
+ createdAt;
5867
+ updatedAt;
5868
+ deletedAt;
5869
+ deleted;
5870
+ createdBy;
5871
+ updatedBy;
5872
+ deletedBy;
5873
+ seoId;
5874
+ seo;
5875
+ collection;
5876
+ brand;
5877
+ category;
5878
+ attributes;
5879
+ taxes;
5880
+ };
5881
+ __decorateClass([
5882
+ (0, import_typeorm33.PrimaryGeneratedColumn)()
5883
+ ], Product.prototype, "id", 2);
5884
+ __decorateClass([
5885
+ (0, import_typeorm33.Column)("int", { nullable: true })
5886
+ ], Product.prototype, "collectionId", 2);
5887
+ __decorateClass([
5888
+ (0, import_typeorm33.Column)("int", { nullable: true })
5889
+ ], Product.prototype, "brandId", 2);
5890
+ __decorateClass([
5891
+ (0, import_typeorm33.Column)("int", { nullable: true })
5892
+ ], Product.prototype, "categoryId", 2);
5893
+ __decorateClass([
5894
+ (0, import_typeorm33.Column)("varchar", { nullable: true })
5895
+ ], Product.prototype, "sku", 2);
5896
+ __decorateClass([
5897
+ (0, import_typeorm33.Column)("varchar", { nullable: true })
5898
+ ], Product.prototype, "hsn", 2);
5899
+ __decorateClass([
5900
+ (0, import_typeorm33.Column)("varchar", { nullable: true })
5901
+ ], Product.prototype, "uom", 2);
5902
+ __decorateClass([
5903
+ (0, import_typeorm33.Column)("varchar", { default: "product" })
5904
+ ], Product.prototype, "type", 2);
5905
+ __decorateClass([
5906
+ (0, import_typeorm33.Column)("varchar", { unique: true, nullable: true })
5907
+ ], Product.prototype, "slug", 2);
5908
+ __decorateClass([
5909
+ (0, import_typeorm33.Column)("varchar", { nullable: true })
5910
+ ], Product.prototype, "name", 2);
5911
+ __decorateClass([
5912
+ (0, import_typeorm33.Column)("decimal", { precision: 12, scale: 2 })
5913
+ ], Product.prototype, "price", 2);
5914
+ __decorateClass([
5915
+ (0, import_typeorm33.Column)("decimal", { precision: 12, scale: 2, nullable: true })
5916
+ ], Product.prototype, "compareAtPrice", 2);
5917
+ __decorateClass([
5918
+ (0, import_typeorm33.Column)("int", { default: 0 })
5919
+ ], Product.prototype, "quantity", 2);
5920
+ __decorateClass([
5921
+ (0, import_typeorm33.Column)("varchar", { default: "draft" })
5922
+ ], Product.prototype, "status", 2);
5923
+ __decorateClass([
5924
+ (0, import_typeorm33.Column)("boolean", { default: false })
5925
+ ], Product.prototype, "featured", 2);
5926
+ __decorateClass([
5927
+ (0, import_typeorm33.Column)("jsonb", { nullable: true })
5928
+ ], Product.prototype, "metadata", 2);
5929
+ __decorateClass([
5930
+ (0, import_typeorm33.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5931
+ ], Product.prototype, "createdAt", 2);
5932
+ __decorateClass([
5933
+ (0, import_typeorm33.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
5934
+ ], Product.prototype, "updatedAt", 2);
5935
+ __decorateClass([
5936
+ (0, import_typeorm33.Column)({ type: "timestamp", nullable: true })
5937
+ ], Product.prototype, "deletedAt", 2);
5938
+ __decorateClass([
5939
+ (0, import_typeorm33.Column)("boolean", { default: false })
5940
+ ], Product.prototype, "deleted", 2);
5941
+ __decorateClass([
5942
+ (0, import_typeorm33.Column)("int", { nullable: true })
5943
+ ], Product.prototype, "createdBy", 2);
5944
+ __decorateClass([
5945
+ (0, import_typeorm33.Column)("int", { nullable: true })
5946
+ ], Product.prototype, "updatedBy", 2);
5947
+ __decorateClass([
5948
+ (0, import_typeorm33.Column)("int", { nullable: true })
5949
+ ], Product.prototype, "deletedBy", 2);
5950
+ __decorateClass([
5951
+ (0, import_typeorm33.Column)("int", { nullable: true })
5952
+ ], Product.prototype, "seoId", 2);
5953
+ __decorateClass([
5954
+ (0, import_typeorm33.ManyToOne)(() => Seo, { onDelete: "SET NULL" }),
5955
+ (0, import_typeorm33.JoinColumn)({ name: "seoId" })
5956
+ ], Product.prototype, "seo", 2);
5957
+ __decorateClass([
5958
+ (0, import_typeorm33.ManyToOne)(() => Collection, (c) => c.products, { onDelete: "SET NULL" }),
5959
+ (0, import_typeorm33.JoinColumn)({ name: "collectionId" })
5960
+ ], Product.prototype, "collection", 2);
5961
+ __decorateClass([
5962
+ (0, import_typeorm33.ManyToOne)(() => Brand, (b) => b.products, { onDelete: "SET NULL" }),
5963
+ (0, import_typeorm33.JoinColumn)({ name: "brandId" })
5964
+ ], Product.prototype, "brand", 2);
5965
+ __decorateClass([
5966
+ (0, import_typeorm33.ManyToOne)(() => ProductCategory, (c) => c.products, { onDelete: "SET NULL" }),
5967
+ (0, import_typeorm33.JoinColumn)({ name: "categoryId" })
5968
+ ], Product.prototype, "category", 2);
5969
+ __decorateClass([
5970
+ (0, import_typeorm33.OneToMany)("ProductAttribute", "product")
5971
+ ], Product.prototype, "attributes", 2);
5972
+ __decorateClass([
5973
+ (0, import_typeorm33.OneToMany)("ProductTax", "product")
5974
+ ], Product.prototype, "taxes", 2);
5975
+ Product = __decorateClass([
5976
+ (0, import_typeorm33.Entity)("products")
5977
+ ], Product);
5978
+
5979
+ // src/entities/attribute.entity.ts
5980
+ var import_typeorm34 = require("typeorm");
5981
+ var Attribute = class {
5982
+ id;
5983
+ name;
5984
+ slug;
5985
+ type;
5986
+ options;
5987
+ metadata;
5988
+ active;
5989
+ sortOrder;
5990
+ createdAt;
5991
+ updatedAt;
5992
+ deletedAt;
5993
+ deleted;
5994
+ createdBy;
5995
+ updatedBy;
5996
+ deletedBy;
5997
+ };
5998
+ __decorateClass([
5999
+ (0, import_typeorm34.PrimaryGeneratedColumn)()
6000
+ ], Attribute.prototype, "id", 2);
6001
+ __decorateClass([
6002
+ (0, import_typeorm34.Column)("varchar")
6003
+ ], Attribute.prototype, "name", 2);
6004
+ __decorateClass([
6005
+ (0, import_typeorm34.Column)("varchar", { unique: true })
6006
+ ], Attribute.prototype, "slug", 2);
6007
+ __decorateClass([
6008
+ (0, import_typeorm34.Column)("varchar", { default: "text" })
6009
+ ], Attribute.prototype, "type", 2);
6010
+ __decorateClass([
6011
+ (0, import_typeorm34.Column)("jsonb", { nullable: true })
6012
+ ], Attribute.prototype, "options", 2);
6013
+ __decorateClass([
6014
+ (0, import_typeorm34.Column)("jsonb", { nullable: true })
6015
+ ], Attribute.prototype, "metadata", 2);
6016
+ __decorateClass([
6017
+ (0, import_typeorm34.Column)("boolean", { default: true })
6018
+ ], Attribute.prototype, "active", 2);
6019
+ __decorateClass([
6020
+ (0, import_typeorm34.Column)("int", { default: 0 })
6021
+ ], Attribute.prototype, "sortOrder", 2);
6022
+ __decorateClass([
6023
+ (0, import_typeorm34.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6024
+ ], Attribute.prototype, "createdAt", 2);
6025
+ __decorateClass([
6026
+ (0, import_typeorm34.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6027
+ ], Attribute.prototype, "updatedAt", 2);
6028
+ __decorateClass([
6029
+ (0, import_typeorm34.Column)({ type: "timestamp", nullable: true })
6030
+ ], Attribute.prototype, "deletedAt", 2);
6031
+ __decorateClass([
6032
+ (0, import_typeorm34.Column)("boolean", { default: false })
6033
+ ], Attribute.prototype, "deleted", 2);
6034
+ __decorateClass([
6035
+ (0, import_typeorm34.Column)("int", { nullable: true })
6036
+ ], Attribute.prototype, "createdBy", 2);
6037
+ __decorateClass([
6038
+ (0, import_typeorm34.Column)("int", { nullable: true })
6039
+ ], Attribute.prototype, "updatedBy", 2);
6040
+ __decorateClass([
6041
+ (0, import_typeorm34.Column)("int", { nullable: true })
6042
+ ], Attribute.prototype, "deletedBy", 2);
6043
+ Attribute = __decorateClass([
6044
+ (0, import_typeorm34.Entity)("attributes")
6045
+ ], Attribute);
6046
+
6047
+ // src/entities/product-attribute.entity.ts
6048
+ var import_typeorm35 = require("typeorm");
6049
+ var ProductAttribute = class {
6050
+ id;
6051
+ productId;
6052
+ attributeId;
6053
+ value;
6054
+ metadata;
6055
+ createdAt;
6056
+ updatedAt;
6057
+ product;
6058
+ attribute;
6059
+ };
6060
+ __decorateClass([
6061
+ (0, import_typeorm35.PrimaryGeneratedColumn)()
6062
+ ], ProductAttribute.prototype, "id", 2);
6063
+ __decorateClass([
6064
+ (0, import_typeorm35.Column)("int")
6065
+ ], ProductAttribute.prototype, "productId", 2);
6066
+ __decorateClass([
6067
+ (0, import_typeorm35.Column)("int")
6068
+ ], ProductAttribute.prototype, "attributeId", 2);
6069
+ __decorateClass([
6070
+ (0, import_typeorm35.Column)("varchar")
6071
+ ], ProductAttribute.prototype, "value", 2);
6072
+ __decorateClass([
6073
+ (0, import_typeorm35.Column)("jsonb", { nullable: true })
6074
+ ], ProductAttribute.prototype, "metadata", 2);
6075
+ __decorateClass([
6076
+ (0, import_typeorm35.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6077
+ ], ProductAttribute.prototype, "createdAt", 2);
6078
+ __decorateClass([
6079
+ (0, import_typeorm35.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6080
+ ], ProductAttribute.prototype, "updatedAt", 2);
6081
+ __decorateClass([
6082
+ (0, import_typeorm35.ManyToOne)(() => Product, (p) => p.attributes, { onDelete: "CASCADE" }),
6083
+ (0, import_typeorm35.JoinColumn)({ name: "productId" })
6084
+ ], ProductAttribute.prototype, "product", 2);
6085
+ __decorateClass([
6086
+ (0, import_typeorm35.ManyToOne)(() => Attribute, { onDelete: "CASCADE" }),
6087
+ (0, import_typeorm35.JoinColumn)({ name: "attributeId" })
6088
+ ], ProductAttribute.prototype, "attribute", 2);
6089
+ ProductAttribute = __decorateClass([
6090
+ (0, import_typeorm35.Entity)("product_attributes")
6091
+ ], ProductAttribute);
6092
+
6093
+ // src/entities/tax.entity.ts
6094
+ var import_typeorm36 = require("typeorm");
6095
+ var Tax = class {
6096
+ id;
6097
+ name;
6098
+ slug;
6099
+ rate;
6100
+ isDefault;
6101
+ description;
6102
+ active;
6103
+ metadata;
6104
+ createdAt;
6105
+ updatedAt;
6106
+ deletedAt;
6107
+ deleted;
6108
+ createdBy;
6109
+ updatedBy;
6110
+ deletedBy;
6111
+ };
6112
+ __decorateClass([
6113
+ (0, import_typeorm36.PrimaryGeneratedColumn)()
6114
+ ], Tax.prototype, "id", 2);
6115
+ __decorateClass([
6116
+ (0, import_typeorm36.Column)("varchar")
6117
+ ], Tax.prototype, "name", 2);
6118
+ __decorateClass([
6119
+ (0, import_typeorm36.Column)("varchar", { unique: true })
6120
+ ], Tax.prototype, "slug", 2);
6121
+ __decorateClass([
6122
+ (0, import_typeorm36.Column)("decimal", { precision: 5, scale: 2 })
6123
+ ], Tax.prototype, "rate", 2);
6124
+ __decorateClass([
6125
+ (0, import_typeorm36.Column)("boolean", { default: false })
6126
+ ], Tax.prototype, "isDefault", 2);
6127
+ __decorateClass([
6128
+ (0, import_typeorm36.Column)("text", { nullable: true })
6129
+ ], Tax.prototype, "description", 2);
6130
+ __decorateClass([
6131
+ (0, import_typeorm36.Column)("boolean", { default: true })
6132
+ ], Tax.prototype, "active", 2);
6133
+ __decorateClass([
6134
+ (0, import_typeorm36.Column)("jsonb", { nullable: true })
6135
+ ], Tax.prototype, "metadata", 2);
6136
+ __decorateClass([
6137
+ (0, import_typeorm36.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6138
+ ], Tax.prototype, "createdAt", 2);
6139
+ __decorateClass([
6140
+ (0, import_typeorm36.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6141
+ ], Tax.prototype, "updatedAt", 2);
6142
+ __decorateClass([
6143
+ (0, import_typeorm36.Column)({ type: "timestamp", nullable: true })
6144
+ ], Tax.prototype, "deletedAt", 2);
6145
+ __decorateClass([
6146
+ (0, import_typeorm36.Column)("boolean", { default: false })
6147
+ ], Tax.prototype, "deleted", 2);
6148
+ __decorateClass([
6149
+ (0, import_typeorm36.Column)("int", { nullable: true })
6150
+ ], Tax.prototype, "createdBy", 2);
6151
+ __decorateClass([
6152
+ (0, import_typeorm36.Column)("int", { nullable: true })
6153
+ ], Tax.prototype, "updatedBy", 2);
6154
+ __decorateClass([
6155
+ (0, import_typeorm36.Column)("int", { nullable: true })
6156
+ ], Tax.prototype, "deletedBy", 2);
6157
+ Tax = __decorateClass([
6158
+ (0, import_typeorm36.Entity)("taxes")
6159
+ ], Tax);
6160
+
6161
+ // src/entities/product-tax.entity.ts
6162
+ var import_typeorm37 = require("typeorm");
6163
+ var ProductTax = class {
6164
+ id;
6165
+ productId;
6166
+ taxId;
6167
+ rate;
6168
+ createdAt;
6169
+ updatedAt;
6170
+ product;
6171
+ tax;
6172
+ };
6173
+ __decorateClass([
6174
+ (0, import_typeorm37.PrimaryGeneratedColumn)()
6175
+ ], ProductTax.prototype, "id", 2);
6176
+ __decorateClass([
6177
+ (0, import_typeorm37.Column)("int")
6178
+ ], ProductTax.prototype, "productId", 2);
6179
+ __decorateClass([
6180
+ (0, import_typeorm37.Column)("int")
6181
+ ], ProductTax.prototype, "taxId", 2);
6182
+ __decorateClass([
6183
+ (0, import_typeorm37.Column)("decimal", { precision: 5, scale: 2, nullable: true })
6184
+ ], ProductTax.prototype, "rate", 2);
6185
+ __decorateClass([
6186
+ (0, import_typeorm37.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6187
+ ], ProductTax.prototype, "createdAt", 2);
6188
+ __decorateClass([
6189
+ (0, import_typeorm37.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6190
+ ], ProductTax.prototype, "updatedAt", 2);
6191
+ __decorateClass([
6192
+ (0, import_typeorm37.ManyToOne)(() => Product, (p) => p.taxes, { onDelete: "CASCADE" }),
6193
+ (0, import_typeorm37.JoinColumn)({ name: "productId" })
6194
+ ], ProductTax.prototype, "product", 2);
6195
+ __decorateClass([
6196
+ (0, import_typeorm37.ManyToOne)(() => Tax, { onDelete: "CASCADE" }),
6197
+ (0, import_typeorm37.JoinColumn)({ name: "taxId" })
6198
+ ], ProductTax.prototype, "tax", 2);
6199
+ ProductTax = __decorateClass([
6200
+ (0, import_typeorm37.Entity)("product_taxes")
6201
+ ], ProductTax);
6202
+
6203
+ // src/entities/order-item.entity.ts
6204
+ var import_typeorm38 = require("typeorm");
6205
+ var OrderItem = class {
6206
+ id;
6207
+ orderId;
6208
+ productId;
6209
+ quantity;
6210
+ unitPrice;
6211
+ tax;
6212
+ total;
6213
+ hsn;
6214
+ uom;
6215
+ productType;
6216
+ taxRate;
6217
+ taxCode;
6218
+ metadata;
6219
+ createdAt;
6220
+ updatedAt;
6221
+ order;
6222
+ product;
6223
+ };
6224
+ __decorateClass([
6225
+ (0, import_typeorm38.PrimaryGeneratedColumn)()
6226
+ ], OrderItem.prototype, "id", 2);
6227
+ __decorateClass([
6228
+ (0, import_typeorm38.Column)("int")
6229
+ ], OrderItem.prototype, "orderId", 2);
6230
+ __decorateClass([
6231
+ (0, import_typeorm38.Column)("int")
6232
+ ], OrderItem.prototype, "productId", 2);
6233
+ __decorateClass([
6234
+ (0, import_typeorm38.Column)("int", { default: 1 })
6235
+ ], OrderItem.prototype, "quantity", 2);
6236
+ __decorateClass([
6237
+ (0, import_typeorm38.Column)("decimal", { precision: 12, scale: 2 })
6238
+ ], OrderItem.prototype, "unitPrice", 2);
6239
+ __decorateClass([
6240
+ (0, import_typeorm38.Column)("decimal", { precision: 12, scale: 2, default: 0 })
6241
+ ], OrderItem.prototype, "tax", 2);
6242
+ __decorateClass([
6243
+ (0, import_typeorm38.Column)("decimal", { precision: 12, scale: 2 })
6244
+ ], OrderItem.prototype, "total", 2);
6245
+ __decorateClass([
6246
+ (0, import_typeorm38.Column)("varchar", { nullable: true })
6247
+ ], OrderItem.prototype, "hsn", 2);
6248
+ __decorateClass([
6249
+ (0, import_typeorm38.Column)("varchar", { nullable: true })
6250
+ ], OrderItem.prototype, "uom", 2);
6251
+ __decorateClass([
6252
+ (0, import_typeorm38.Column)("varchar", { nullable: true })
6253
+ ], OrderItem.prototype, "productType", 2);
6254
+ __decorateClass([
6255
+ (0, import_typeorm38.Column)("decimal", { precision: 5, scale: 2, nullable: true })
6256
+ ], OrderItem.prototype, "taxRate", 2);
6257
+ __decorateClass([
6258
+ (0, import_typeorm38.Column)("varchar", { nullable: true })
6259
+ ], OrderItem.prototype, "taxCode", 2);
6260
+ __decorateClass([
6261
+ (0, import_typeorm38.Column)("jsonb", { nullable: true })
6262
+ ], OrderItem.prototype, "metadata", 2);
6263
+ __decorateClass([
6264
+ (0, import_typeorm38.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6265
+ ], OrderItem.prototype, "createdAt", 2);
6266
+ __decorateClass([
6267
+ (0, import_typeorm38.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6268
+ ], OrderItem.prototype, "updatedAt", 2);
6269
+ __decorateClass([
6270
+ (0, import_typeorm38.ManyToOne)(() => Order, (o) => o.items, { onDelete: "CASCADE" }),
6271
+ (0, import_typeorm38.JoinColumn)({ name: "orderId" })
6272
+ ], OrderItem.prototype, "order", 2);
6273
+ __decorateClass([
6274
+ (0, import_typeorm38.ManyToOne)(() => Product, { onDelete: "CASCADE" }),
6275
+ (0, import_typeorm38.JoinColumn)({ name: "productId" })
6276
+ ], OrderItem.prototype, "product", 2);
6277
+ OrderItem = __decorateClass([
6278
+ (0, import_typeorm38.Entity)("order_items")
6279
+ ], OrderItem);
6280
+
6281
+ // src/entities/knowledge-base-document.entity.ts
6282
+ var import_typeorm40 = require("typeorm");
6283
+
6284
+ // src/entities/knowledge-base-chunk.entity.ts
6285
+ var import_typeorm39 = require("typeorm");
6286
+ var KnowledgeBaseChunk = class {
6287
+ id;
6288
+ documentId;
6289
+ content;
6290
+ chunkIndex;
6291
+ createdAt;
6292
+ document;
6293
+ };
6294
+ __decorateClass([
6295
+ (0, import_typeorm39.PrimaryGeneratedColumn)()
6296
+ ], KnowledgeBaseChunk.prototype, "id", 2);
6297
+ __decorateClass([
6298
+ (0, import_typeorm39.Column)("int")
6299
+ ], KnowledgeBaseChunk.prototype, "documentId", 2);
6300
+ __decorateClass([
6301
+ (0, import_typeorm39.Column)("text")
6302
+ ], KnowledgeBaseChunk.prototype, "content", 2);
6303
+ __decorateClass([
6304
+ (0, import_typeorm39.Column)("int", { default: 0 })
6305
+ ], KnowledgeBaseChunk.prototype, "chunkIndex", 2);
6306
+ __decorateClass([
6307
+ (0, import_typeorm39.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6308
+ ], KnowledgeBaseChunk.prototype, "createdAt", 2);
6309
+ __decorateClass([
6310
+ (0, import_typeorm39.ManyToOne)(() => KnowledgeBaseDocument, (d) => d.chunks, { onDelete: "CASCADE" }),
6311
+ (0, import_typeorm39.JoinColumn)({ name: "documentId" })
6312
+ ], KnowledgeBaseChunk.prototype, "document", 2);
6313
+ KnowledgeBaseChunk = __decorateClass([
6314
+ (0, import_typeorm39.Entity)("knowledge_base_chunks")
6315
+ ], KnowledgeBaseChunk);
6316
+
6317
+ // src/entities/knowledge-base-document.entity.ts
6318
+ var KnowledgeBaseDocument = class {
6319
+ id;
6320
+ name;
6321
+ sourceUrl;
6322
+ content;
6323
+ createdAt;
6324
+ updatedAt;
6325
+ chunks;
6326
+ };
6327
+ __decorateClass([
6328
+ (0, import_typeorm40.PrimaryGeneratedColumn)()
6329
+ ], KnowledgeBaseDocument.prototype, "id", 2);
6330
+ __decorateClass([
6331
+ (0, import_typeorm40.Column)("varchar")
6332
+ ], KnowledgeBaseDocument.prototype, "name", 2);
6333
+ __decorateClass([
6334
+ (0, import_typeorm40.Column)("varchar", { nullable: true })
6335
+ ], KnowledgeBaseDocument.prototype, "sourceUrl", 2);
6336
+ __decorateClass([
6337
+ (0, import_typeorm40.Column)("text")
6338
+ ], KnowledgeBaseDocument.prototype, "content", 2);
6339
+ __decorateClass([
6340
+ (0, import_typeorm40.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6341
+ ], KnowledgeBaseDocument.prototype, "createdAt", 2);
6342
+ __decorateClass([
6343
+ (0, import_typeorm40.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6344
+ ], KnowledgeBaseDocument.prototype, "updatedAt", 2);
6345
+ __decorateClass([
6346
+ (0, import_typeorm40.OneToMany)(() => KnowledgeBaseChunk, (c) => c.document)
6347
+ ], KnowledgeBaseDocument.prototype, "chunks", 2);
6348
+ KnowledgeBaseDocument = __decorateClass([
6349
+ (0, import_typeorm40.Entity)("knowledge_base_documents")
6350
+ ], KnowledgeBaseDocument);
6351
+
6352
+ // src/entities/cart.entity.ts
6353
+ var import_typeorm41 = require("typeorm");
6354
+ var Cart = class {
6355
+ id;
6356
+ guestToken;
6357
+ contactId;
6358
+ currency;
6359
+ expiresAt;
6360
+ createdAt;
6361
+ updatedAt;
6362
+ contact;
6363
+ items;
6364
+ };
6365
+ __decorateClass([
6366
+ (0, import_typeorm41.PrimaryGeneratedColumn)()
6367
+ ], Cart.prototype, "id", 2);
6368
+ __decorateClass([
6369
+ (0, import_typeorm41.Column)("varchar", { nullable: true })
6370
+ ], Cart.prototype, "guestToken", 2);
6371
+ __decorateClass([
6372
+ (0, import_typeorm41.Column)("int", { nullable: true })
6373
+ ], Cart.prototype, "contactId", 2);
6374
+ __decorateClass([
6375
+ (0, import_typeorm41.Column)("varchar", { default: "INR" })
6376
+ ], Cart.prototype, "currency", 2);
6377
+ __decorateClass([
6378
+ (0, import_typeorm41.Column)({ type: "timestamp", nullable: true })
6379
+ ], Cart.prototype, "expiresAt", 2);
6380
+ __decorateClass([
6381
+ (0, import_typeorm41.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6382
+ ], Cart.prototype, "createdAt", 2);
6383
+ __decorateClass([
6384
+ (0, import_typeorm41.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6385
+ ], Cart.prototype, "updatedAt", 2);
6386
+ __decorateClass([
6387
+ (0, import_typeorm41.ManyToOne)(() => Contact, { onDelete: "CASCADE" }),
6388
+ (0, import_typeorm41.JoinColumn)({ name: "contactId" })
6389
+ ], Cart.prototype, "contact", 2);
6390
+ __decorateClass([
6391
+ (0, import_typeorm41.OneToMany)("CartItem", "cart")
6392
+ ], Cart.prototype, "items", 2);
6393
+ Cart = __decorateClass([
6394
+ (0, import_typeorm41.Entity)("carts")
6395
+ ], Cart);
6396
+
6397
+ // src/entities/cart-item.entity.ts
6398
+ var import_typeorm42 = require("typeorm");
6399
+ var CartItem = class {
6400
+ id;
6401
+ cartId;
6402
+ productId;
6403
+ quantity;
6404
+ metadata;
6405
+ createdAt;
6406
+ updatedAt;
6407
+ cart;
6408
+ product;
6409
+ };
6410
+ __decorateClass([
6411
+ (0, import_typeorm42.PrimaryGeneratedColumn)()
6412
+ ], CartItem.prototype, "id", 2);
6413
+ __decorateClass([
6414
+ (0, import_typeorm42.Column)("int")
6415
+ ], CartItem.prototype, "cartId", 2);
6416
+ __decorateClass([
6417
+ (0, import_typeorm42.Column)("int")
6418
+ ], CartItem.prototype, "productId", 2);
6419
+ __decorateClass([
6420
+ (0, import_typeorm42.Column)("int", { default: 1 })
6421
+ ], CartItem.prototype, "quantity", 2);
6422
+ __decorateClass([
6423
+ (0, import_typeorm42.Column)("jsonb", { nullable: true })
6424
+ ], CartItem.prototype, "metadata", 2);
6425
+ __decorateClass([
6426
+ (0, import_typeorm42.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6427
+ ], CartItem.prototype, "createdAt", 2);
6428
+ __decorateClass([
6429
+ (0, import_typeorm42.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6430
+ ], CartItem.prototype, "updatedAt", 2);
6431
+ __decorateClass([
6432
+ (0, import_typeorm42.ManyToOne)(() => Cart, (c) => c.items, { onDelete: "CASCADE" }),
6433
+ (0, import_typeorm42.JoinColumn)({ name: "cartId" })
6434
+ ], CartItem.prototype, "cart", 2);
6435
+ __decorateClass([
6436
+ (0, import_typeorm42.ManyToOne)(() => Product, { onDelete: "CASCADE" }),
6437
+ (0, import_typeorm42.JoinColumn)({ name: "productId" })
6438
+ ], CartItem.prototype, "product", 2);
6439
+ CartItem = __decorateClass([
6440
+ (0, import_typeorm42.Entity)("cart_items")
6441
+ ], CartItem);
6442
+
6443
+ // src/entities/wishlist.entity.ts
6444
+ var import_typeorm43 = require("typeorm");
6445
+ var Wishlist = class {
6446
+ id;
6447
+ guestId;
6448
+ contactId;
6449
+ name;
6450
+ createdAt;
6451
+ updatedAt;
6452
+ contact;
6453
+ items;
6454
+ };
6455
+ __decorateClass([
6456
+ (0, import_typeorm43.PrimaryGeneratedColumn)()
6457
+ ], Wishlist.prototype, "id", 2);
6458
+ __decorateClass([
6459
+ (0, import_typeorm43.Column)("varchar", { nullable: true })
6460
+ ], Wishlist.prototype, "guestId", 2);
6461
+ __decorateClass([
6462
+ (0, import_typeorm43.Column)("int", { nullable: true })
6463
+ ], Wishlist.prototype, "contactId", 2);
6464
+ __decorateClass([
6465
+ (0, import_typeorm43.Column)("varchar", { default: "default" })
6466
+ ], Wishlist.prototype, "name", 2);
6467
+ __decorateClass([
6468
+ (0, import_typeorm43.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6469
+ ], Wishlist.prototype, "createdAt", 2);
6470
+ __decorateClass([
6471
+ (0, import_typeorm43.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6472
+ ], Wishlist.prototype, "updatedAt", 2);
6473
+ __decorateClass([
6474
+ (0, import_typeorm43.ManyToOne)(() => Contact, { onDelete: "CASCADE" }),
6475
+ (0, import_typeorm43.JoinColumn)({ name: "contactId" })
6476
+ ], Wishlist.prototype, "contact", 2);
6477
+ __decorateClass([
6478
+ (0, import_typeorm43.OneToMany)("WishlistItem", "wishlist")
6479
+ ], Wishlist.prototype, "items", 2);
6480
+ Wishlist = __decorateClass([
6481
+ (0, import_typeorm43.Entity)("wishlists")
6482
+ ], Wishlist);
6483
+
6484
+ // src/entities/wishlist-item.entity.ts
6485
+ var import_typeorm44 = require("typeorm");
6486
+ var WishlistItem = class {
6487
+ id;
6488
+ wishlistId;
6489
+ productId;
6490
+ metadata;
6491
+ createdAt;
6492
+ updatedAt;
6493
+ wishlist;
6494
+ product;
6495
+ };
6496
+ __decorateClass([
6497
+ (0, import_typeorm44.PrimaryGeneratedColumn)()
6498
+ ], WishlistItem.prototype, "id", 2);
6499
+ __decorateClass([
6500
+ (0, import_typeorm44.Column)("int")
6501
+ ], WishlistItem.prototype, "wishlistId", 2);
6502
+ __decorateClass([
6503
+ (0, import_typeorm44.Column)("int")
6504
+ ], WishlistItem.prototype, "productId", 2);
6505
+ __decorateClass([
6506
+ (0, import_typeorm44.Column)("jsonb", { nullable: true })
6507
+ ], WishlistItem.prototype, "metadata", 2);
6508
+ __decorateClass([
6509
+ (0, import_typeorm44.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6510
+ ], WishlistItem.prototype, "createdAt", 2);
6511
+ __decorateClass([
6512
+ (0, import_typeorm44.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6513
+ ], WishlistItem.prototype, "updatedAt", 2);
6514
+ __decorateClass([
6515
+ (0, import_typeorm44.ManyToOne)(() => Wishlist, (w) => w.items, { onDelete: "CASCADE" }),
6516
+ (0, import_typeorm44.JoinColumn)({ name: "wishlistId" })
6517
+ ], WishlistItem.prototype, "wishlist", 2);
6518
+ __decorateClass([
6519
+ (0, import_typeorm44.ManyToOne)(() => Product, { onDelete: "CASCADE" }),
6520
+ (0, import_typeorm44.JoinColumn)({ name: "productId" })
6521
+ ], WishlistItem.prototype, "product", 2);
6522
+ WishlistItem = __decorateClass([
6523
+ (0, import_typeorm44.Entity)("wishlist_items")
6524
+ ], WishlistItem);
6525
+
6526
+ // src/entities/llm-agent-knowledge-document.entity.ts
6527
+ var import_typeorm45 = require("typeorm");
6528
+ var LlmAgentKnowledgeDocument = class {
6529
+ id;
6530
+ agentId;
6531
+ documentId;
6532
+ createdAt;
6533
+ agent;
6534
+ document;
6535
+ };
6536
+ __decorateClass([
6537
+ (0, import_typeorm45.PrimaryGeneratedColumn)()
6538
+ ], LlmAgentKnowledgeDocument.prototype, "id", 2);
6539
+ __decorateClass([
6540
+ (0, import_typeorm45.Column)("int")
6541
+ ], LlmAgentKnowledgeDocument.prototype, "agentId", 2);
6542
+ __decorateClass([
6543
+ (0, import_typeorm45.Column)("int")
6544
+ ], LlmAgentKnowledgeDocument.prototype, "documentId", 2);
6545
+ __decorateClass([
6546
+ (0, import_typeorm45.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
6547
+ ], LlmAgentKnowledgeDocument.prototype, "createdAt", 2);
6548
+ __decorateClass([
6549
+ (0, import_typeorm45.ManyToOne)(() => LlmAgent, { onDelete: "CASCADE" }),
6550
+ (0, import_typeorm45.JoinColumn)({ name: "agentId" })
6551
+ ], LlmAgentKnowledgeDocument.prototype, "agent", 2);
6552
+ __decorateClass([
6553
+ (0, import_typeorm45.ManyToOne)(() => KnowledgeBaseDocument, { onDelete: "CASCADE" }),
6554
+ (0, import_typeorm45.JoinColumn)({ name: "documentId" })
6555
+ ], LlmAgentKnowledgeDocument.prototype, "document", 2);
6556
+ LlmAgentKnowledgeDocument = __decorateClass([
6557
+ (0, import_typeorm45.Entity)("llm_agent_knowledge_documents"),
6558
+ (0, import_typeorm45.Unique)("UQ_llm_agent_knowledge_agent_document", ["agentId", "documentId"]),
6559
+ (0, import_typeorm45.Index)("IDX_llm_agent_knowledge_agent", ["agentId"])
6560
+ ], LlmAgentKnowledgeDocument);
6561
+
6562
+ // src/entities/index.ts
6563
+ var CMS_ENTITY_MAP = {
6564
+ users: User,
6565
+ otp_challenges: OtpChallenge,
6566
+ password_reset_tokens: PasswordResetToken,
6567
+ user_groups: UserGroup,
6568
+ permissions: Permission,
6569
+ blogs: Blog,
6570
+ tags: Tag,
6571
+ categories: Category,
6572
+ comments: Comment,
6573
+ contacts: Contact,
6574
+ addresses: Address,
6575
+ forms: Form,
6576
+ form_fields: FormField,
6577
+ form_submissions: FormSubmission,
6578
+ seos: Seo,
6579
+ configs: Config,
6580
+ message_templates: MessageTemplate,
6581
+ media: Media,
6582
+ pages: Page,
6583
+ product_categories: ProductCategory,
6584
+ collections: Collection,
6585
+ products: Product,
6586
+ attributes: Attribute,
6587
+ product_attributes: ProductAttribute,
6588
+ taxes: Tax,
6589
+ product_taxes: ProductTax,
6590
+ orders: Order,
6591
+ order_items: OrderItem,
6592
+ payments: Payment,
6593
+ brands: Brand,
6594
+ knowledge_base_documents: KnowledgeBaseDocument,
6595
+ knowledge_base_chunks: KnowledgeBaseChunk,
6596
+ chat_conversations: ChatConversation,
6597
+ chat_messages: ChatMessage,
6598
+ carts: Cart,
6599
+ cart_items: CartItem,
6600
+ wishlists: Wishlist,
6601
+ wishlist_items: WishlistItem,
6602
+ llm_agents: LlmAgent,
6603
+ llm_agent_knowledge_documents: LlmAgentKnowledgeDocument
6604
+ };
6605
+
6606
+ // src/api/cms-api-handler.ts
6607
+ var KNOWLEDGE_SUFFIX = "knowledge";
6608
+ var CMS_API_LOG = "[cms-api]";
6609
+ function withLlmKnowledgeEntityFallbacks(base) {
6610
+ const keys = [
6611
+ "llm_agents",
6612
+ "llm_agent_knowledge_documents",
6613
+ "knowledge_base_documents",
6614
+ "knowledge_base_chunks"
6615
+ ];
6616
+ const patch = {};
6617
+ for (const key of keys) {
6618
+ if (!(key in base) || base[key] == null) {
6619
+ const fallback = CMS_ENTITY_MAP[key];
6620
+ if (fallback) patch[key] = fallback;
6621
+ }
6622
+ }
6623
+ const merged = Object.keys(patch).length > 0 ? { ...base, ...patch } : base;
6624
+ if (!merged.llm_agents) {
6625
+ const agent = CMS_ENTITY_MAP.llm_agents ?? LlmAgent;
6626
+ return { ...merged, llm_agents: agent };
6627
+ }
6628
+ return merged;
6629
+ }
6630
+ function matchLlmAgentKnowledgeRoute(path) {
6631
+ const p = path[0] === "api" ? path.slice(1) : path;
6632
+ if (p[0] !== "llm_agents" || p.length < 2) return null;
6633
+ const seg1 = p[1];
6634
+ if (!seg1) return null;
6635
+ if (p[2] === KNOWLEDGE_SUFFIX) {
6636
+ return {
6637
+ slug: seg1,
6638
+ documentId: p.length >= 4 ? p[3] : void 0
6639
+ };
6640
+ }
6641
+ if (seg1.endsWith(KNOWLEDGE_SUFFIX) && seg1.length > KNOWLEDGE_SUFFIX.length) {
6642
+ const slug = seg1.slice(0, -KNOWLEDGE_SUFFIX.length);
6643
+ if (!slug) return null;
6644
+ if (p.length === 2) return { slug, documentId: void 0 };
6645
+ if (p.length === 3) return { slug, documentId: p[2] };
6646
+ }
6647
+ return null;
6648
+ }
6649
+ var DEFAULT_EXCLUDE = /* @__PURE__ */ new Set([
6650
+ "users",
6651
+ "password_reset_tokens",
6652
+ "user_groups",
6653
+ "permissions",
6654
+ "comments",
6655
+ "form_fields",
6656
+ "configs",
6657
+ "carts",
6658
+ "cart_items",
6659
+ "wishlists",
6660
+ "wishlist_items",
6661
+ "message_templates",
6662
+ "llm_agent_knowledge_documents"
6663
+ ]);
6664
+ function createCmsApiHandler(config) {
6665
+ const {
6666
+ dataSource,
6667
+ entityMap: rawEntityMap,
6668
+ pathToModel = (s) => s,
6669
+ crudResources: crudResourcesOverride,
6670
+ getCms,
6671
+ userAuth: userAuthConfig,
6672
+ dashboard,
6673
+ ecommerceAnalytics,
6674
+ analytics: analyticsConfig,
6675
+ upload,
6676
+ blogBySlug,
6677
+ formBySlug,
6678
+ formSave: formSaveConfig,
6679
+ formSubmission: formSubmissionConfig,
6680
+ formSubmissionGetById: formSubmissionGetByIdConfig,
6681
+ usersApi,
6682
+ userAvatar,
6683
+ userProfile,
6684
+ settings: settingsConfig,
6685
+ chat: chatConfig,
6686
+ llmAgentKnowledge: llmAgentKnowledgeConfig,
6687
+ requireEntityPermission: userRequireEntityPermission,
6688
+ getSessionUser
6689
+ } = config;
6690
+ const entityMap = withLlmKnowledgeEntityFallbacks(rawEntityMap);
6691
+ const baseCrudResources = crudResourcesOverride ?? Object.keys(entityMap).filter((k) => !DEFAULT_EXCLUDE.has(k));
6692
+ const crudResources = entityMap.llm_agents && !baseCrudResources.includes("llm_agents") ? [...baseCrudResources, "llm_agents"] : baseCrudResources;
6693
+ const requireEntityPermissionEffective = userRequireEntityPermission ?? (async (_req, entity, action) => config.json({ error: "Forbidden", reason: "entity_rbac_required", entity, action }, { status: 403 }));
6694
+ const analytics = analyticsConfig ?? (getCms ? {
6695
+ json: config.json,
6696
+ requireAuth: async () => null,
6697
+ getAnalyticsData: async (days) => {
6698
+ const cms = await getCms();
6699
+ const a = cms.getPlugin("analytics");
6700
+ if (!a?.getAnalyticsData) throw new Error("Analytics not configured");
6701
+ return a.getAnalyticsData(days);
6702
+ },
6703
+ getPropertyId: () => ({ currentViewId: process.env.GOOGLE_ANALYTICS_VIEW_ID }),
6704
+ getPermissions: () => ({
6705
+ serviceAccountEmail: process.env.GOOGLE_ANALYTICS_CLIENT_EMAIL,
6706
+ currentViewId: process.env.GOOGLE_ANALYTICS_VIEW_ID
6707
+ })
6708
+ } : void 0);
6709
+ const userAuth = userAuthConfig && getCms && userAuthConfig.sendEmail === void 0 ? {
6710
+ ...userAuthConfig,
6711
+ sendEmail: async (opts) => {
6712
+ const cms = await getCms();
6713
+ const queue = cms.getPlugin("queue");
6714
+ const companyDetails = config.getCompanyDetails ? await config.getCompanyDetails() : {};
6715
+ const resetLink = typeof opts.resetLink === "string" && opts.resetLink.trim() || typeof opts.text === "string" && opts.text.trim() || (typeof opts.html === "string" ? opts.html.match(/href\s*=\s*["']([^"']+)["']/)?.[1] ?? "" : "");
6716
+ const ctx = { resetLink, companyDetails };
6717
+ if (queue) {
6718
+ const { queueEmail: queueEmail2 } = await Promise.resolve().then(() => (init_email_queue(), email_queue_exports));
6719
+ await queueEmail2(cms, { to: opts.to, templateName: "passwordReset", ctx });
6720
+ return;
6721
+ }
6722
+ const email = cms.getPlugin("email");
6723
+ if (!email?.send) return;
6724
+ const rendered = email.renderTemplate("passwordReset", ctx);
6725
+ await email.send({ subject: rendered.subject, html: rendered.html, text: rendered.text, to: opts.to });
6726
+ }
6727
+ } : userAuthConfig;
6728
+ const crudOpts = {
6729
+ requireAuth: config.requireAuth,
6730
+ json: config.json,
6731
+ requireEntityPermission: requireEntityPermissionEffective,
6732
+ getCms,
6733
+ ...getSessionUser ? {
6734
+ getDeletedByUserId: async () => {
6735
+ const u = await getSessionUser();
6736
+ if (!u?.id) return null;
6737
+ const n = Number(u.id);
6738
+ return Number.isFinite(n) ? n : null;
6739
+ }
6740
+ } : {}
6741
+ };
6742
+ const crud = createCrudHandler(dataSource, entityMap, crudOpts);
6743
+ const crudById = createCrudByIdHandler(dataSource, entityMap, crudOpts);
6744
+ const mergePerm = (c) => !c ? void 0 : { ...c, requireEntityPermission: requireEntityPermissionEffective };
6745
+ const adminRoles = getSessionUser && createAdminRolesHandlers({
6746
+ dataSource,
6747
+ entityMap,
6748
+ json: config.json,
6749
+ getSessionUser
6750
+ });
6751
+ const userAuthRouter = userAuth ? createUserAuthApiRouter(userAuth) : null;
6752
+ const dashboardGet = dashboard ? createDashboardStatsHandler(mergePerm(dashboard) ?? dashboard) : null;
6753
+ const ecommerceAnalyticsResolved = mergePerm(
6754
+ ecommerceAnalytics ?? {
6755
+ dataSource,
6756
+ entityMap,
6757
+ json: config.json,
6758
+ requireAuth: config.requireAuth
6759
+ }
6760
+ );
6761
+ const ecommerceAnalyticsGet = createEcommerceAnalyticsHandler(ecommerceAnalyticsResolved);
6762
+ const analyticsHandlers = analytics ? createAnalyticsHandlers(analytics) : null;
6763
+ const uploadMerged = upload ? {
6764
+ ...mergePerm(upload) ?? upload,
6765
+ dataSource: upload.dataSource ?? dataSource,
6766
+ entityMap: upload.entityMap ?? entityMap
6767
+ } : null;
6768
+ const uploadPost = uploadMerged ? createUploadHandler(uploadMerged) : null;
6769
+ const zipExtractPost = uploadMerged ? createMediaZipExtractHandler(uploadMerged) : null;
6770
+ const blogBySlugGet = blogBySlug ? createBlogBySlugHandler(blogBySlug) : null;
6771
+ const formBySlugGet = formBySlug ? createFormBySlugHandler(formBySlug) : null;
6772
+ const formSaveHandlers = formSaveConfig ? createFormSaveHandlers(mergePerm(formSaveConfig) ?? formSaveConfig) : null;
6773
+ const formSubmissionPost = formSubmissionConfig ? createFormSubmissionHandler(formSubmissionConfig) : null;
6774
+ const formSubmissionGetById = formSubmissionGetByIdConfig ? createFormSubmissionGetByIdHandler(mergePerm(formSubmissionGetByIdConfig) ?? formSubmissionGetByIdConfig) : null;
6775
+ const formSubmissionList = formSubmissionGetByIdConfig ? createFormSubmissionListHandler(mergePerm(formSubmissionGetByIdConfig) ?? formSubmissionGetByIdConfig) : null;
6776
+ const usersApiMerged = usersApi && getCms ? {
6777
+ ...usersApi,
6778
+ getCms: usersApi.getCms ?? getCms,
6779
+ getCompanyDetails: usersApi.getCompanyDetails ?? config.getCompanyDetails,
3863
6780
  ...getSessionUser ? { getSessionUser: usersApi.getSessionUser ?? getSessionUser } : {}
3864
6781
  } : usersApi ? {
3865
6782
  ...usersApi,
@@ -3879,7 +6796,7 @@ function createCmsApiHandler(config) {
3879
6796
  const chatHandlers = chatConfig ? createChatHandlers(chatConfig) : null;
3880
6797
  const llmAgentKnowledgeMerged = llmAgentKnowledgeConfig ?? (chatConfig ? {
3881
6798
  dataSource: chatConfig.dataSource,
3882
- entityMap: chatConfig.entityMap,
6799
+ entityMap: withLlmKnowledgeEntityFallbacks(chatConfig.entityMap ?? rawEntityMap),
3883
6800
  getCms: chatConfig.getCms,
3884
6801
  json: chatConfig.json,
3885
6802
  requireAuth: chatConfig.requireAuth
@@ -3893,7 +6810,9 @@ function createCmsApiHandler(config) {
3893
6810
  return crudResources.includes(model) ? model : segment;
3894
6811
  }
3895
6812
  return {
3896
- async handle(method, path, req) {
6813
+ async handle(method, pathInput, req) {
6814
+ const m = typeof method === "string" ? method.toUpperCase() : "GET";
6815
+ const path = pathInput.length > 0 && pathInput[0] === "api" ? pathInput.slice(1) : pathInput;
3897
6816
  async function analyticsGate() {
3898
6817
  const a = await config.requireAuth(req);
3899
6818
  if (a) return a;
@@ -3901,86 +6820,86 @@ function createCmsApiHandler(config) {
3901
6820
  }
3902
6821
  if (path[0] === "admin" && path[1] === "roles") {
3903
6822
  if (!adminRoles) return config.json({ error: "Not found" }, { status: 404 });
3904
- if (path.length === 2 && method === "GET") return adminRoles.list();
3905
- if (path.length === 2 && method === "POST") return adminRoles.createGroup(req);
3906
- if (path.length === 3 && method === "PATCH") return adminRoles.patchGroup(req, path[2]);
3907
- if (path.length === 3 && method === "DELETE") return adminRoles.deleteGroup(path[2]);
3908
- if (path.length === 4 && path[3] === "permissions" && method === "PUT") return adminRoles.putPermissions(req, path[2]);
6823
+ if (path.length === 2 && m === "GET") return adminRoles.list();
6824
+ if (path.length === 2 && m === "POST") return adminRoles.createGroup(req);
6825
+ if (path.length === 3 && m === "PATCH") return adminRoles.patchGroup(req, path[2]);
6826
+ if (path.length === 3 && m === "DELETE") return adminRoles.deleteGroup(path[2]);
6827
+ if (path.length === 4 && path[3] === "permissions" && m === "PUT") return adminRoles.putPermissions(req, path[2]);
3909
6828
  return config.json({ error: "Not found" }, { status: 404 });
3910
6829
  }
3911
- if (path[0] === "dashboard" && path[1] === "stats" && path.length === 2 && method === "GET" && dashboardGet) {
6830
+ if (path[0] === "dashboard" && path[1] === "stats" && path.length === 2 && m === "GET" && dashboardGet) {
3912
6831
  return dashboardGet(req);
3913
6832
  }
3914
- if (path[0] === "dashboard" && path[1] === "ecommerce" && path.length === 2 && method === "GET" && ecommerceAnalyticsGet) {
6833
+ if (path[0] === "dashboard" && path[1] === "ecommerce" && path.length === 2 && m === "GET" && ecommerceAnalyticsGet) {
3915
6834
  const g = await analyticsGate();
3916
6835
  if (g) return g;
3917
6836
  return ecommerceAnalyticsGet(req);
3918
6837
  }
3919
6838
  if (path[0] === "analytics" && analyticsHandlers) {
3920
- if (path.length === 1 && method === "GET") {
6839
+ if (path.length === 1 && m === "GET") {
3921
6840
  const g = await analyticsGate();
3922
6841
  if (g) return g;
3923
6842
  return analyticsHandlers.GET(req);
3924
6843
  }
3925
- if (path.length === 2 && path[1] === "property-id" && method === "GET") {
6844
+ if (path.length === 2 && path[1] === "property-id" && m === "GET") {
3926
6845
  const g = await analyticsGate();
3927
6846
  if (g) return g;
3928
6847
  return analyticsHandlers.propertyId();
3929
6848
  }
3930
- if (path.length === 2 && path[1] === "permissions" && method === "GET") {
6849
+ if (path.length === 2 && path[1] === "permissions" && m === "GET") {
3931
6850
  const g = await analyticsGate();
3932
6851
  if (g) return g;
3933
6852
  return analyticsHandlers.permissions();
3934
6853
  }
3935
6854
  }
3936
- if (path[0] === "upload" && path.length === 1 && method === "POST" && uploadPost) return uploadPost(req);
3937
- if (path[0] === "media" && path[1] === "extract" && path.length === 3 && method === "POST" && zipExtractPost) {
6855
+ if (path[0] === "upload" && path.length === 1 && m === "POST" && uploadPost) return uploadPost(req);
6856
+ if (path[0] === "media" && path[1] === "extract" && path.length === 3 && m === "POST" && zipExtractPost) {
3938
6857
  return zipExtractPost(req, path[2]);
3939
6858
  }
3940
- if (path[0] === "blogs" && path[1] === "slug" && path.length === 3 && method === "GET" && blogBySlugGet) {
6859
+ if (path[0] === "blogs" && path[1] === "slug" && path.length === 3 && m === "GET" && blogBySlugGet) {
3941
6860
  return blogBySlugGet(req, path[2]);
3942
6861
  }
3943
- if (path[0] === "forms" && path[1] === "slug" && path.length === 3 && method === "GET" && formBySlugGet) {
6862
+ if (path[0] === "forms" && path[1] === "slug" && path.length === 3 && m === "GET" && formBySlugGet) {
3944
6863
  return formBySlugGet(req, path[2]);
3945
6864
  }
3946
6865
  if (path[0] === "form-submissions") {
3947
6866
  if (path.length === 1) {
3948
- if (method === "GET" && formSubmissionList) return formSubmissionList(req);
3949
- if (method === "POST" && formSubmissionPost) return formSubmissionPost(req);
6867
+ if (m === "GET" && formSubmissionList) return formSubmissionList(req);
6868
+ if (m === "POST" && formSubmissionPost) return formSubmissionPost(req);
3950
6869
  }
3951
- if (path.length === 2 && method === "GET" && formSubmissionGetById) return formSubmissionGetById(req, path[1]);
6870
+ if (path.length === 2 && m === "GET" && formSubmissionGetById) return formSubmissionGetById(req, path[1]);
3952
6871
  }
3953
6872
  if (path[0] === "forms" && formSaveHandlers) {
3954
- if (path.length === 1 && method === "POST") return formSaveHandlers.POST(req);
6873
+ if (path.length === 1 && m === "POST") return formSaveHandlers.POST(req);
3955
6874
  if (path.length === 2) {
3956
- if (method === "GET") return formSaveHandlers.GET(req, path[1]);
3957
- if (method === "PUT" || method === "PATCH") return formSaveHandlers.PUT(req, path[1]);
6875
+ if (m === "GET") return formSaveHandlers.GET(req, path[1]);
6876
+ if (m === "PUT" || m === "PATCH") return formSaveHandlers.PUT(req, path[1]);
3958
6877
  }
3959
6878
  }
3960
6879
  if (path[0] === "users" && usersHandlers) {
3961
6880
  if (path.length === 1) {
3962
- if (method === "GET") return usersHandlers.list(req);
3963
- if (method === "POST") return usersHandlers.create(req);
6881
+ if (m === "GET") return usersHandlers.list(req);
6882
+ if (m === "POST") return usersHandlers.create(req);
3964
6883
  }
3965
6884
  if (path.length === 2) {
3966
- if (path[1] === "avatar" && method === "POST" && avatarPost) return avatarPost(req);
3967
- if (path[1] === "profile" && method === "PUT" && profilePut) return profilePut(req);
6885
+ if (path[1] === "avatar" && m === "POST" && avatarPost) return avatarPost(req);
6886
+ if (path[1] === "profile" && m === "PUT" && profilePut) return profilePut(req);
3968
6887
  const id = path[1];
3969
- if (method === "GET") return usersHandlers.getById(req, id);
3970
- if (method === "PUT" || method === "PATCH") return usersHandlers.update(req, id);
3971
- if (method === "DELETE") return usersHandlers.delete(req, id);
6888
+ if (m === "GET") return usersHandlers.getById(req, id);
6889
+ if (m === "PUT" || m === "PATCH") return usersHandlers.update(req, id);
6890
+ if (m === "DELETE") return usersHandlers.delete(req, id);
3972
6891
  }
3973
- if (path.length === 3 && path[2] === "regenerate-invite" && method === "POST") {
6892
+ if (path.length === 3 && path[2] === "regenerate-invite" && m === "POST") {
3974
6893
  return usersHandlers.regenerateInvite(req, path[1]);
3975
6894
  }
3976
6895
  }
3977
- if (path[0] === "users" && path.length === 2 && userAuthRouter && method === "POST") {
6896
+ if (path[0] === "users" && path.length === 2 && userAuthRouter && m === "POST") {
3978
6897
  return userAuthRouter.POST(req, path[1]);
3979
6898
  }
3980
6899
  if (path[0] === "settings" && path.length === 2 && settingsHandlers) {
3981
6900
  const group = path[1];
3982
6901
  const isPublic = settingsConfig?.publicGetGroups?.includes(group);
3983
- if (method === "GET") {
6902
+ if (m === "GET") {
3984
6903
  if (!isPublic) {
3985
6904
  const a = await config.requireAuth(req);
3986
6905
  if (a) return a;
@@ -3989,15 +6908,38 @@ function createCmsApiHandler(config) {
3989
6908
  }
3990
6909
  return settingsHandlers.GET(req, group);
3991
6910
  }
3992
- if (method === "PUT") {
6911
+ if (m === "PUT") {
3993
6912
  const pe = await requireEntityPermissionEffective(req, "settings", "update");
3994
6913
  if (pe) return pe;
3995
6914
  return settingsHandlers.PUT(req, group);
3996
6915
  }
3997
6916
  }
3998
6917
  if (path[0] === "message-templates" && path[1] === "sms" && path.length === 2) {
3999
- if (method === "GET") return smsMessageTemplateHandlers.GET(req);
4000
- if (method === "PUT") return smsMessageTemplateHandlers.PUT(req);
6918
+ if (m === "GET") return smsMessageTemplateHandlers.GET(req);
6919
+ if (m === "PUT") return smsMessageTemplateHandlers.PUT(req);
6920
+ }
6921
+ if (path[0] === "llm_agents") {
6922
+ if (!entityMap.llm_agents) {
6923
+ console.error(CMS_API_LOG, "llm_agents route: entity missing after merge", {
6924
+ method: m,
6925
+ pathJoined: path.join("/"),
6926
+ entityMapKeyCount: Object.keys(entityMap).length
6927
+ });
6928
+ return config.json(
6929
+ { error: "LlmAgent entity is not registered", hint: "Ensure migrations ran and entities include LlmAgent." },
6930
+ { status: 503 }
6931
+ );
6932
+ }
6933
+ if (path.length === 1) {
6934
+ if (m === "GET") return crud.GET(req, "llm_agents");
6935
+ if (m === "POST") return crud.POST(req, "llm_agents");
6936
+ }
6937
+ if (path.length === 2 && !path[1]?.includes("knowledge")) {
6938
+ const id = path[1];
6939
+ if (m === "GET") return crudById.GET(req, "llm_agents", id);
6940
+ if (m === "PUT" || m === "PATCH") return crudById.PUT(req, "llm_agents", id);
6941
+ if (m === "DELETE") return crudById.DELETE(req, "llm_agents", id);
6942
+ }
4001
6943
  }
4002
6944
  {
4003
6945
  const kbMatch = matchLlmAgentKnowledgeRoute(path);
@@ -4012,24 +6954,24 @@ function createCmsApiHandler(config) {
4012
6954
  );
4013
6955
  }
4014
6956
  const { slug, documentId } = kbMatch;
4015
- if (method === "DELETE" && documentId != null && documentId !== "") {
6957
+ if (m === "DELETE" && documentId != null && documentId !== "") {
4016
6958
  return llmAgentKnowledgeHandlers.unlink(req, slug, documentId);
4017
6959
  }
4018
- if (method === "GET" && (documentId == null || documentId === "")) {
6960
+ if (m === "GET" && (documentId == null || documentId === "")) {
4019
6961
  return llmAgentKnowledgeHandlers.list(req, slug);
4020
6962
  }
4021
- if (method === "POST" && (documentId == null || documentId === "")) {
6963
+ if (m === "POST" && (documentId == null || documentId === "")) {
4022
6964
  return llmAgentKnowledgeHandlers.post(req, slug);
4023
6965
  }
4024
6966
  }
4025
6967
  }
4026
6968
  if (path[0] === "chat" && chatHandlers) {
4027
- if (path.length === 2 && path[1] === "config" && method === "GET") return chatHandlers.publicConfig(req);
4028
- if (path.length === 2 && path[1] === "identify" && method === "POST") return chatHandlers.identify(req);
4029
- if (path.length === 4 && path[1] === "conversations" && path[3] === "messages" && method === "GET") return chatHandlers.getMessages(req, path[2]);
4030
- if (path.length === 2 && path[1] === "messages" && method === "POST") return chatHandlers.postMessage(req);
6969
+ if (path.length === 2 && path[1] === "config" && m === "GET") return chatHandlers.publicConfig(req);
6970
+ if (path.length === 2 && path[1] === "identify" && m === "POST") return chatHandlers.identify(req);
6971
+ if (path.length === 4 && path[1] === "conversations" && path[3] === "messages" && m === "GET") return chatHandlers.getMessages(req, path[2]);
6972
+ if (path.length === 2 && path[1] === "messages" && m === "POST") return chatHandlers.postMessage(req);
4031
6973
  }
4032
- if (path[0] === "orders" && path.length === 3 && path[2] === "invoice" && method === "GET" && getCms) {
6974
+ if (path[0] === "orders" && path.length === 3 && path[2] === "invoice" && m === "GET" && getCms) {
4033
6975
  const a = await config.requireAuth(req);
4034
6976
  if (a) return a;
4035
6977
  const pe = await requireEntityPermissionEffective(req, "orders", "read");
@@ -4043,17 +6985,17 @@ function createCmsApiHandler(config) {
4043
6985
  if (path[0] === "orders" && path.length === 3 && path[2] === "repost-erp" && getCms) {
4044
6986
  const a = await config.requireAuth(req);
4045
6987
  if (a) return a;
4046
- const pe = await requireEntityPermissionEffective(req, "orders", method === "GET" ? "read" : "update");
6988
+ const pe = await requireEntityPermissionEffective(req, "orders", m === "GET" ? "read" : "update");
4047
6989
  if (pe) return pe;
4048
6990
  const oid = Number(path[1]);
4049
6991
  if (!Number.isFinite(oid)) return config.json({ error: "Invalid id" }, { status: 400 });
4050
6992
  const cms = await getCms();
4051
6993
  const { isErpIntegrationEnabled: isErpIntegrationEnabled3 } = await Promise.resolve().then(() => (init_erp_config_enabled(), erp_config_enabled_exports));
4052
6994
  const enabled = await isErpIntegrationEnabled3(cms, dataSource, entityMap);
4053
- if (method === "GET") {
6995
+ if (m === "GET") {
4054
6996
  return config.json({ enabled });
4055
6997
  }
4056
- if (method === "POST") {
6998
+ if (m === "POST") {
4057
6999
  if (!enabled) return config.json({ error: "ERP integration is disabled" }, { status: 409 });
4058
7000
  const { queueErpPaidOrderForOrderId: queueErpPaidOrderForOrderId2 } = await Promise.resolve().then(() => (init_paid_order_erp(), paid_order_erp_exports));
4059
7001
  await queueErpPaidOrderForOrderId2(cms, dataSource, entityMap, oid);
@@ -4063,28 +7005,39 @@ function createCmsApiHandler(config) {
4063
7005
  }
4064
7006
  if (path.length === 0) return config.json({ error: "Not found" }, { status: 404 });
4065
7007
  const resource = resolveResource(path[0]);
4066
- if (!crudResources.includes(resource)) return config.json({ error: "Invalid resource" }, { status: 400 });
7008
+ if (!crudResources.includes(resource)) {
7009
+ console.warn(CMS_API_LOG, "generic CRUD gate: Invalid resource (not in crudResources)", {
7010
+ method: m,
7011
+ pathJoined: path.join("/"),
7012
+ pathSegments: path,
7013
+ resource,
7014
+ hasLlmAgentsEntity: Boolean(entityMap.llm_agents),
7015
+ crudResourcesHasResource: crudResources.includes(resource),
7016
+ crudResourcesLength: crudResources.length
7017
+ });
7018
+ return config.json({ error: "Invalid resource" }, { status: 400 });
7019
+ }
4067
7020
  if (path.length === 2) {
4068
- if (path[1] === "metadata" && method === "GET") {
7021
+ if (path[1] === "metadata" && m === "GET") {
4069
7022
  return crud.GET_METADATA(req, resource);
4070
7023
  }
4071
- if (path[1] === "bulk" && method === "POST") {
7024
+ if (path[1] === "bulk" && m === "POST") {
4072
7025
  return crud.BULK_POST(req, resource);
4073
7026
  }
4074
- if (path[1] === "export" && method === "GET") {
7027
+ if (path[1] === "export" && m === "GET") {
4075
7028
  return crud.GET_EXPORT(req, resource);
4076
7029
  }
4077
7030
  }
4078
7031
  if (path.length === 1) {
4079
- if (method === "GET") return crud.GET(req, resource);
4080
- if (method === "POST") return crud.POST(req, resource);
7032
+ if (m === "GET") return crud.GET(req, resource);
7033
+ if (m === "POST") return crud.POST(req, resource);
4081
7034
  return config.json({ error: "Method not allowed" }, { status: 405 });
4082
7035
  }
4083
7036
  if (path.length === 2) {
4084
7037
  const id = path[1];
4085
- if (method === "GET") return crudById.GET(req, resource, id);
4086
- if (method === "PUT" || method === "PATCH") return crudById.PUT(req, resource, id);
4087
- if (method === "DELETE") return crudById.DELETE(req, resource, id);
7038
+ if (m === "GET") return crudById.GET(req, resource, id);
7039
+ if (m === "PUT" || m === "PATCH") return crudById.PUT(req, resource, id);
7040
+ if (m === "DELETE") return crudById.DELETE(req, resource, id);
4088
7041
  return config.json({ error: "Method not allowed" }, { status: 405 });
4089
7042
  }
4090
7043
  return config.json({ error: "Not found" }, { status: 404 });
@@ -4093,7 +7046,7 @@ function createCmsApiHandler(config) {
4093
7046
  }
4094
7047
 
4095
7048
  // src/api/storefront-handlers.ts
4096
- var import_typeorm8 = require("typeorm");
7049
+ var import_typeorm47 = require("typeorm");
4097
7050
 
4098
7051
  // src/lib/is-valid-signup-email.ts
4099
7052
  var MAX_EMAIL = 254;
@@ -4353,7 +7306,7 @@ async function queueSms(cms, payload) {
4353
7306
 
4354
7307
  // src/lib/otp-challenge.ts
4355
7308
  var import_crypto = require("crypto");
4356
- var import_typeorm7 = require("typeorm");
7309
+ var import_typeorm46 = require("typeorm");
4357
7310
  var OTP_TTL_MS = 10 * 60 * 1e3;
4358
7311
  var MAX_SENDS_PER_HOUR = 5;
4359
7312
  var MAX_VERIFY_ATTEMPTS = 8;
@@ -4387,7 +7340,7 @@ function normalizePhoneE164(raw, defaultCountryCode) {
4387
7340
  async function countRecentOtpSends(dataSource, entityMap, purpose, identifier, since) {
4388
7341
  const repo = dataSource.getRepository(entityMap.otp_challenges);
4389
7342
  return repo.count({
4390
- where: { purpose, identifier, createdAt: (0, import_typeorm7.MoreThan)(since) }
7343
+ where: { purpose, identifier, createdAt: (0, import_typeorm46.MoreThan)(since) }
4391
7344
  });
4392
7345
  }
4393
7346
  async function createOtpChallenge(dataSource, entityMap, input) {
@@ -4401,7 +7354,7 @@ async function createOtpChallenge(dataSource, entityMap, input) {
4401
7354
  await repo.delete({
4402
7355
  purpose,
4403
7356
  identifier,
4404
- consumedAt: (0, import_typeorm7.IsNull)()
7357
+ consumedAt: (0, import_typeorm46.IsNull)()
4405
7358
  });
4406
7359
  const expiresAt = new Date(Date.now() + OTP_TTL_MS);
4407
7360
  const codeHash = hashOtpCode(code, purpose, identifier, pepper);
@@ -4422,7 +7375,7 @@ async function verifyAndConsumeOtpChallenge(dataSource, entityMap, input) {
4422
7375
  const { purpose, identifier, code, pepper } = input;
4423
7376
  const repo = dataSource.getRepository(entityMap.otp_challenges);
4424
7377
  const row = await repo.findOne({
4425
- where: { purpose, identifier, consumedAt: (0, import_typeorm7.IsNull)() },
7378
+ where: { purpose, identifier, consumedAt: (0, import_typeorm46.IsNull)() },
4426
7379
  order: { id: "DESC" }
4427
7380
  });
4428
7381
  if (!row) {
@@ -4656,7 +7609,7 @@ function createStorefrontApiHandler(config) {
4656
7609
  const u = await userRepo().findOne({ where: { id: userId } });
4657
7610
  if (!u) return null;
4658
7611
  const unclaimed = await contactRepo().findOne({
4659
- where: { email: u.email, userId: (0, import_typeorm8.IsNull)(), deleted: false }
7612
+ where: { email: u.email, userId: (0, import_typeorm47.IsNull)(), deleted: false }
4660
7613
  });
4661
7614
  if (unclaimed) {
4662
7615
  await contactRepo().update(unclaimed.id, { userId });
@@ -5697,7 +8650,7 @@ function createStorefrontApiHandler(config) {
5697
8650
  const previewByOrder = {};
5698
8651
  if (orderIds.length) {
5699
8652
  const oItems = await orderItemRepo().find({
5700
- where: { orderId: (0, import_typeorm8.In)(orderIds) },
8653
+ where: { orderId: (0, import_typeorm47.In)(orderIds) },
5701
8654
  relations: ["product"],
5702
8655
  order: { id: "ASC" }
5703
8656
  });