@infuro/cms-core 1.0.19 → 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/admin.cjs +661 -19
- package/dist/admin.cjs.map +1 -1
- package/dist/admin.js +681 -22
- package/dist/admin.js.map +1 -1
- package/dist/api.cjs +3745 -101
- package/dist/api.cjs.map +1 -1
- package/dist/api.d.cts +1 -1
- package/dist/api.d.ts +1 -1
- package/dist/api.js +3732 -83
- package/dist/api.js.map +1 -1
- package/dist/{index-D2C1O9b4.d.cts → index-BGAh4fPQ.d.cts} +102 -3
- package/dist/{index-GMn7-9PX.d.ts → index-Cnwh7B3r.d.ts} +102 -3
- package/dist/index.cjs +2301 -787
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +124 -13
- package/dist/index.d.ts +124 -13
- package/dist/index.js +2154 -648
- package/dist/index.js.map +1 -1
- package/dist/migrations/1775300000000-LlmAgents.ts +57 -0
- package/dist/migrations/1775300000001-LlmAgentsValidationRulesText.ts +43 -0
- package/dist/migrations/1775300000002-SeedLlmAgentsPermissions.ts +33 -0
- package/dist/migrations/1775300000003-LlmAgentKnowledgeDocuments.ts +50 -0
- package/dist/migrations/1775400000000-KnowledgeBaseVectorDimension384.ts +32 -0
- package/package.json +9 -6
package/dist/api.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
2
3
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
4
|
var __esm = (fn, res) => function __init() {
|
|
4
5
|
return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
|
|
@@ -7,6 +8,14 @@ var __export = (target, all) => {
|
|
|
7
8
|
for (var name in all)
|
|
8
9
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
10
|
};
|
|
11
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
12
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
13
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
14
|
+
if (decorator = decorators[i])
|
|
15
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
16
|
+
if (kind && result) __defProp(target, key, result);
|
|
17
|
+
return result;
|
|
18
|
+
};
|
|
10
19
|
|
|
11
20
|
// src/plugins/erp/erp-queue.ts
|
|
12
21
|
async function queueErp(cms, payload) {
|
|
@@ -468,6 +477,13 @@ async function queueErpProductUpsertIfEnabled(cms, dataSource, entityMap, produc
|
|
|
468
477
|
}
|
|
469
478
|
|
|
470
479
|
// src/api/crud.ts
|
|
480
|
+
var CRUD_LOG = "[cms-crud]";
|
|
481
|
+
function logCrudClientError(op, detail) {
|
|
482
|
+
console.warn(CRUD_LOG, op, detail);
|
|
483
|
+
}
|
|
484
|
+
function logCrudServerError(op, detail) {
|
|
485
|
+
console.error(CRUD_LOG, op, detail);
|
|
486
|
+
}
|
|
471
487
|
var DATE_COLUMN_TYPES = /* @__PURE__ */ new Set([
|
|
472
488
|
"date",
|
|
473
489
|
"datetime",
|
|
@@ -579,6 +595,13 @@ function createCrudHandler(dataSource, entityMap, options) {
|
|
|
579
595
|
if (authError) return authError;
|
|
580
596
|
const entity = entityMap[resource];
|
|
581
597
|
if (!resource || !entity) {
|
|
598
|
+
logCrudClientError("GET list", {
|
|
599
|
+
reason: "invalid_resource",
|
|
600
|
+
resource,
|
|
601
|
+
hasEntity: Boolean(entity),
|
|
602
|
+
entityMapHasLlmAgents: Boolean(entityMap.llm_agents),
|
|
603
|
+
entityMapKeyCount: Object.keys(entityMap).length
|
|
604
|
+
});
|
|
582
605
|
return json({ error: "Invalid resource" }, { status: 400 });
|
|
583
606
|
}
|
|
584
607
|
const { searchParams } = new URL(req.url);
|
|
@@ -786,12 +809,22 @@ function createCrudHandler(dataSource, entityMap, options) {
|
|
|
786
809
|
}
|
|
787
810
|
}
|
|
788
811
|
where = mergeDeletedFalseWhere(repo, where);
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
812
|
+
let data;
|
|
813
|
+
let total;
|
|
814
|
+
try {
|
|
815
|
+
const r = await repo.findAndCount({
|
|
816
|
+
skip,
|
|
817
|
+
take: limit,
|
|
818
|
+
order: { [sortField]: sortOrder },
|
|
819
|
+
where
|
|
820
|
+
});
|
|
821
|
+
data = r[0];
|
|
822
|
+
total = r[1];
|
|
823
|
+
} catch (err) {
|
|
824
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
825
|
+
logCrudServerError("GET list query failed", { resource, sortField, sortOrder, message });
|
|
826
|
+
throw err;
|
|
827
|
+
}
|
|
795
828
|
return json({ total, page, limit, totalPages: Math.ceil(total / limit), data });
|
|
796
829
|
},
|
|
797
830
|
async POST(req, resource) {
|
|
@@ -799,12 +832,25 @@ function createCrudHandler(dataSource, entityMap, options) {
|
|
|
799
832
|
if (authError) return authError;
|
|
800
833
|
const entity = entityMap[resource];
|
|
801
834
|
if (!resource || !entity) {
|
|
835
|
+
logCrudClientError("POST create", {
|
|
836
|
+
reason: "invalid_resource",
|
|
837
|
+
resource,
|
|
838
|
+
hasEntity: Boolean(entity),
|
|
839
|
+
entityMapHasLlmAgents: Boolean(entityMap.llm_agents)
|
|
840
|
+
});
|
|
802
841
|
return json({ error: "Invalid resource" }, { status: 400 });
|
|
803
842
|
}
|
|
804
|
-
const
|
|
805
|
-
if (!
|
|
843
|
+
const rawPostBody = await req.json();
|
|
844
|
+
if (!rawPostBody || typeof rawPostBody !== "object" || Object.keys(rawPostBody).length === 0) {
|
|
845
|
+
logCrudClientError("POST create", {
|
|
846
|
+
reason: "invalid_request_payload",
|
|
847
|
+
resource,
|
|
848
|
+
rawType: rawPostBody == null ? "nullish" : typeof rawPostBody,
|
|
849
|
+
keyCount: rawPostBody && typeof rawPostBody === "object" ? Object.keys(rawPostBody).length : 0
|
|
850
|
+
});
|
|
806
851
|
return json({ error: "Invalid request payload" }, { status: 400 });
|
|
807
852
|
}
|
|
853
|
+
const body = rawPostBody;
|
|
808
854
|
if (resource === "media") {
|
|
809
855
|
const b = body;
|
|
810
856
|
const kind = b.kind === "folder" ? "folder" : "file";
|
|
@@ -838,8 +884,24 @@ function createCrudHandler(dataSource, entityMap, options) {
|
|
|
838
884
|
}
|
|
839
885
|
}
|
|
840
886
|
const repo = dataSource.getRepository(entity);
|
|
841
|
-
|
|
842
|
-
|
|
887
|
+
const persistBody = resource === "media" ? body : pickColumnUpdates(repo, body);
|
|
888
|
+
if (resource !== "media" && Object.keys(persistBody).length === 0) {
|
|
889
|
+
logCrudClientError("POST create", {
|
|
890
|
+
reason: "no_scalar_columns_after_pick",
|
|
891
|
+
resource,
|
|
892
|
+
incomingKeys: Object.keys(body)
|
|
893
|
+
});
|
|
894
|
+
return json({ error: "Invalid request payload" }, { status: 400 });
|
|
895
|
+
}
|
|
896
|
+
sanitizeBodyForEntity(repo, persistBody);
|
|
897
|
+
let created;
|
|
898
|
+
try {
|
|
899
|
+
created = await repo.save(repo.create(persistBody));
|
|
900
|
+
} catch (err) {
|
|
901
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
902
|
+
logCrudServerError("POST create save failed", { resource, message, persistKeys: Object.keys(persistBody) });
|
|
903
|
+
throw err;
|
|
904
|
+
}
|
|
843
905
|
if (resource === "contacts") {
|
|
844
906
|
await syncContactRowToErp(created);
|
|
845
907
|
}
|
|
@@ -854,6 +916,7 @@ function createCrudHandler(dataSource, entityMap, options) {
|
|
|
854
916
|
if (authError) return authError;
|
|
855
917
|
const entity = entityMap[resource];
|
|
856
918
|
if (!resource || !entity) {
|
|
919
|
+
logCrudClientError("GET_METADATA", { reason: "invalid_resource", resource });
|
|
857
920
|
return json({ error: "Invalid resource" }, { status: 400 });
|
|
858
921
|
}
|
|
859
922
|
const repo = dataSource.getRepository(entity);
|
|
@@ -885,11 +948,18 @@ function createCrudHandler(dataSource, entityMap, options) {
|
|
|
885
948
|
if (authError) return authError;
|
|
886
949
|
const entity = entityMap[resource];
|
|
887
950
|
if (!resource || !entity) {
|
|
951
|
+
logCrudClientError("BULK_POST", { reason: "invalid_resource", resource });
|
|
888
952
|
return json({ error: "Invalid resource" }, { status: 400 });
|
|
889
953
|
}
|
|
890
954
|
const body = await req.json();
|
|
891
955
|
const { records, upsertKey = "id" } = body;
|
|
892
956
|
if (!Array.isArray(records) || records.length === 0) {
|
|
957
|
+
logCrudClientError("BULK_POST", {
|
|
958
|
+
reason: "records_required",
|
|
959
|
+
resource,
|
|
960
|
+
recordsIsArray: Array.isArray(records),
|
|
961
|
+
recordCount: Array.isArray(records) ? records.length : 0
|
|
962
|
+
});
|
|
893
963
|
return json({ error: "Records array is required" }, { status: 400 });
|
|
894
964
|
}
|
|
895
965
|
const repo = dataSource.getRepository(entity);
|
|
@@ -908,6 +978,7 @@ function createCrudHandler(dataSource, entityMap, options) {
|
|
|
908
978
|
});
|
|
909
979
|
} catch (error) {
|
|
910
980
|
const message = error instanceof Error ? error.message : "Bulk import failed";
|
|
981
|
+
logCrudClientError("BULK_POST upsert failed", { resource, upsertKey, message });
|
|
911
982
|
return json({ error: message }, { status: 400 });
|
|
912
983
|
}
|
|
913
984
|
},
|
|
@@ -916,6 +987,7 @@ function createCrudHandler(dataSource, entityMap, options) {
|
|
|
916
987
|
if (authError) return authError;
|
|
917
988
|
const entity = entityMap[resource];
|
|
918
989
|
if (!resource || !entity) {
|
|
990
|
+
logCrudClientError("GET_EXPORT", { reason: "invalid_resource", resource });
|
|
919
991
|
return json({ error: "Invalid resource" }, { status: 400 });
|
|
920
992
|
}
|
|
921
993
|
const { searchParams } = new URL(req.url);
|
|
@@ -970,7 +1042,10 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
|
|
|
970
1042
|
const authError = await authz(req, resource, "read");
|
|
971
1043
|
if (authError) return authError;
|
|
972
1044
|
const entity = entityMap[resource];
|
|
973
|
-
if (!entity)
|
|
1045
|
+
if (!entity) {
|
|
1046
|
+
logCrudClientError("GET by id", { reason: "invalid_resource", resource, id });
|
|
1047
|
+
return json({ error: "Invalid resource" }, { status: 400 });
|
|
1048
|
+
}
|
|
974
1049
|
const repo = dataSource.getRepository(entity);
|
|
975
1050
|
if (resource === "orders") {
|
|
976
1051
|
const order = await repo.findOne({
|
|
@@ -1029,7 +1104,10 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
|
|
|
1029
1104
|
const authError = await authz(req, resource, "update");
|
|
1030
1105
|
if (authError) return authError;
|
|
1031
1106
|
const entity = entityMap[resource];
|
|
1032
|
-
if (!entity)
|
|
1107
|
+
if (!entity) {
|
|
1108
|
+
logCrudClientError("PUT by id", { reason: "invalid_resource", resource, id });
|
|
1109
|
+
return json({ error: "Invalid resource" }, { status: 400 });
|
|
1110
|
+
}
|
|
1033
1111
|
const rawBody = await req.json();
|
|
1034
1112
|
const repo = dataSource.getRepository(entity);
|
|
1035
1113
|
const numericId = Number(id);
|
|
@@ -1142,7 +1220,10 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
|
|
|
1142
1220
|
const authError = await authz(req, resource, "delete");
|
|
1143
1221
|
if (authError) return authError;
|
|
1144
1222
|
const entity = entityMap[resource];
|
|
1145
|
-
if (!entity)
|
|
1223
|
+
if (!entity) {
|
|
1224
|
+
logCrudClientError("DELETE by id", { reason: "invalid_resource", resource, id });
|
|
1225
|
+
return json({ error: "Invalid resource" }, { status: 400 });
|
|
1226
|
+
}
|
|
1146
1227
|
const repo = dataSource.getRepository(entity);
|
|
1147
1228
|
const numericId = Number(id);
|
|
1148
1229
|
if (entityHasSoftDelete(repo)) {
|
|
@@ -1335,6 +1416,86 @@ async function assertCaptchaOk(getCms, body, req, json) {
|
|
|
1335
1416
|
return json({ error: result.message }, { status: result.status });
|
|
1336
1417
|
}
|
|
1337
1418
|
|
|
1419
|
+
// src/entities/llm-agent.entity.ts
|
|
1420
|
+
import { Entity, PrimaryGeneratedColumn, Column } from "typeorm";
|
|
1421
|
+
var LlmAgent = class {
|
|
1422
|
+
id;
|
|
1423
|
+
name;
|
|
1424
|
+
slug;
|
|
1425
|
+
systemInstruction;
|
|
1426
|
+
model;
|
|
1427
|
+
temperature;
|
|
1428
|
+
maxTokens;
|
|
1429
|
+
validationRules;
|
|
1430
|
+
enabled;
|
|
1431
|
+
createdAt;
|
|
1432
|
+
updatedAt;
|
|
1433
|
+
deletedAt;
|
|
1434
|
+
deleted;
|
|
1435
|
+
createdBy;
|
|
1436
|
+
updatedBy;
|
|
1437
|
+
deletedBy;
|
|
1438
|
+
};
|
|
1439
|
+
__decorateClass([
|
|
1440
|
+
PrimaryGeneratedColumn()
|
|
1441
|
+
], LlmAgent.prototype, "id", 2);
|
|
1442
|
+
__decorateClass([
|
|
1443
|
+
Column("varchar")
|
|
1444
|
+
], LlmAgent.prototype, "name", 2);
|
|
1445
|
+
__decorateClass([
|
|
1446
|
+
Column("varchar")
|
|
1447
|
+
], LlmAgent.prototype, "slug", 2);
|
|
1448
|
+
__decorateClass([
|
|
1449
|
+
Column("text", { name: "system_instruction", default: "" })
|
|
1450
|
+
], LlmAgent.prototype, "systemInstruction", 2);
|
|
1451
|
+
__decorateClass([
|
|
1452
|
+
Column("varchar", { nullable: true })
|
|
1453
|
+
], LlmAgent.prototype, "model", 2);
|
|
1454
|
+
__decorateClass([
|
|
1455
|
+
Column("double precision", { name: "temperature", nullable: true })
|
|
1456
|
+
], LlmAgent.prototype, "temperature", 2);
|
|
1457
|
+
__decorateClass([
|
|
1458
|
+
Column("int", { name: "max_tokens", nullable: true })
|
|
1459
|
+
], LlmAgent.prototype, "maxTokens", 2);
|
|
1460
|
+
__decorateClass([
|
|
1461
|
+
Column("text", { name: "validation_rules", nullable: true })
|
|
1462
|
+
], LlmAgent.prototype, "validationRules", 2);
|
|
1463
|
+
__decorateClass([
|
|
1464
|
+
Column("boolean", { default: true })
|
|
1465
|
+
], LlmAgent.prototype, "enabled", 2);
|
|
1466
|
+
__decorateClass([
|
|
1467
|
+
Column({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
1468
|
+
], LlmAgent.prototype, "createdAt", 2);
|
|
1469
|
+
__decorateClass([
|
|
1470
|
+
Column({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
1471
|
+
], LlmAgent.prototype, "updatedAt", 2);
|
|
1472
|
+
__decorateClass([
|
|
1473
|
+
Column({ type: "timestamp", nullable: true })
|
|
1474
|
+
], LlmAgent.prototype, "deletedAt", 2);
|
|
1475
|
+
__decorateClass([
|
|
1476
|
+
Column("boolean", { default: false })
|
|
1477
|
+
], LlmAgent.prototype, "deleted", 2);
|
|
1478
|
+
__decorateClass([
|
|
1479
|
+
Column("int", { nullable: true })
|
|
1480
|
+
], LlmAgent.prototype, "createdBy", 2);
|
|
1481
|
+
__decorateClass([
|
|
1482
|
+
Column("int", { nullable: true })
|
|
1483
|
+
], LlmAgent.prototype, "updatedBy", 2);
|
|
1484
|
+
__decorateClass([
|
|
1485
|
+
Column("int", { nullable: true })
|
|
1486
|
+
], LlmAgent.prototype, "deletedBy", 2);
|
|
1487
|
+
LlmAgent = __decorateClass([
|
|
1488
|
+
Entity("llm_agents")
|
|
1489
|
+
], LlmAgent);
|
|
1490
|
+
function llmAgentToChatAgentOptions(agent) {
|
|
1491
|
+
return {
|
|
1492
|
+
systemPrompt: agent.systemInstruction?.trim() || void 0,
|
|
1493
|
+
model: agent.model?.trim() || void 0,
|
|
1494
|
+
temperature: agent.temperature ?? void 0,
|
|
1495
|
+
max_tokens: agent.maxTokens ?? void 0
|
|
1496
|
+
};
|
|
1497
|
+
}
|
|
1498
|
+
|
|
1338
1499
|
// src/lib/media-folder-path.ts
|
|
1339
1500
|
function sanitizeMediaFolderPath(input) {
|
|
1340
1501
|
if (input == null) return "";
|
|
@@ -1524,6 +1685,82 @@ async function extractZipMediaIntoParentTree(opts) {
|
|
|
1524
1685
|
}
|
|
1525
1686
|
|
|
1526
1687
|
// src/api/cms-handlers.ts
|
|
1688
|
+
function historyBeforeCurrentUser(history, currentUserContent) {
|
|
1689
|
+
const last = history[history.length - 1];
|
|
1690
|
+
if (last?.role === "user" && last.content === currentUserContent) {
|
|
1691
|
+
return history.slice(0, -1);
|
|
1692
|
+
}
|
|
1693
|
+
return [...history];
|
|
1694
|
+
}
|
|
1695
|
+
function pickStructuredRules(rules) {
|
|
1696
|
+
return {
|
|
1697
|
+
maxUserChars: rules.maxUserChars,
|
|
1698
|
+
maxMessageLength: rules.maxMessageLength,
|
|
1699
|
+
minUserChars: rules.minUserChars,
|
|
1700
|
+
minMessageLength: rules.minMessageLength,
|
|
1701
|
+
blockedSubstrings: rules.blockedSubstrings
|
|
1702
|
+
};
|
|
1703
|
+
}
|
|
1704
|
+
function guardrailsTextFromJsonObject(rules) {
|
|
1705
|
+
const g = typeof rules.guardrails === "string" && rules.guardrails.trim() || typeof rules.outputRules === "string" && rules.outputRules.trim() || typeof rules.outputInstructions === "string" && rules.outputInstructions.trim() || "";
|
|
1706
|
+
return g || null;
|
|
1707
|
+
}
|
|
1708
|
+
function parseLlmAgentValidationRules(validationRulesText) {
|
|
1709
|
+
const raw = validationRulesText?.trim();
|
|
1710
|
+
if (!raw) return { structured: {}, guardrailsForPrompt: null };
|
|
1711
|
+
try {
|
|
1712
|
+
const parsed = JSON.parse(raw);
|
|
1713
|
+
if (typeof parsed === "string") {
|
|
1714
|
+
const s = parsed.trim();
|
|
1715
|
+
return { structured: {}, guardrailsForPrompt: s || null };
|
|
1716
|
+
}
|
|
1717
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
1718
|
+
return { structured: {}, guardrailsForPrompt: raw };
|
|
1719
|
+
}
|
|
1720
|
+
const rules = parsed;
|
|
1721
|
+
return {
|
|
1722
|
+
structured: pickStructuredRules(rules),
|
|
1723
|
+
guardrailsForPrompt: guardrailsTextFromJsonObject(rules)
|
|
1724
|
+
};
|
|
1725
|
+
} catch {
|
|
1726
|
+
return { structured: {}, guardrailsForPrompt: raw };
|
|
1727
|
+
}
|
|
1728
|
+
}
|
|
1729
|
+
function validateUserMessageAgainstStructuredRules(message, structured) {
|
|
1730
|
+
const maxLen = structured.maxUserChars ?? structured.maxMessageLength;
|
|
1731
|
+
if (typeof maxLen === "number" && Number.isFinite(maxLen) && maxLen >= 0 && message.length > maxLen) {
|
|
1732
|
+
return { ok: false, error: `Message exceeds maximum length (${maxLen} characters)` };
|
|
1733
|
+
}
|
|
1734
|
+
const minLen = structured.minUserChars ?? structured.minMessageLength;
|
|
1735
|
+
if (typeof minLen === "number" && Number.isFinite(minLen) && minLen > 0 && message.length < minLen) {
|
|
1736
|
+
return { ok: false, error: `Message is shorter than minimum length (${minLen} characters)` };
|
|
1737
|
+
}
|
|
1738
|
+
const blocked = structured.blockedSubstrings;
|
|
1739
|
+
if (Array.isArray(blocked) && blocked.length > 0) {
|
|
1740
|
+
const lower = message.toLowerCase();
|
|
1741
|
+
for (const s of blocked) {
|
|
1742
|
+
if (typeof s !== "string" || !s.trim()) continue;
|
|
1743
|
+
if (lower.includes(s.toLowerCase())) {
|
|
1744
|
+
return { ok: false, error: "Message contains disallowed content" };
|
|
1745
|
+
}
|
|
1746
|
+
}
|
|
1747
|
+
}
|
|
1748
|
+
return { ok: true };
|
|
1749
|
+
}
|
|
1750
|
+
function validateUserMessageAgainstAgentRules(message, validationRulesText) {
|
|
1751
|
+
const { structured } = parseLlmAgentValidationRules(validationRulesText);
|
|
1752
|
+
return validateUserMessageAgainstStructuredRules(message, structured);
|
|
1753
|
+
}
|
|
1754
|
+
function mergeGuardrailsIntoSystemPrompt(baseSystem, guardrailsForPrompt) {
|
|
1755
|
+
const g = guardrailsForPrompt?.trim();
|
|
1756
|
+
const b = (baseSystem ?? "").trim();
|
|
1757
|
+
if (!g) return b;
|
|
1758
|
+
const block = `### Output guardrails (follow in every reply)
|
|
1759
|
+
${g}`;
|
|
1760
|
+
return b ? `${b}
|
|
1761
|
+
|
|
1762
|
+
${block}` : block;
|
|
1763
|
+
}
|
|
1527
1764
|
function createDashboardStatsHandler(config) {
|
|
1528
1765
|
const { dataSource, entityMap, json, requireAuth, requirePermission, requireEntityPermission } = config;
|
|
1529
1766
|
return async function GET(req) {
|
|
@@ -2605,9 +2842,24 @@ function createSettingsApiHandlers(config) {
|
|
|
2605
2842
|
}
|
|
2606
2843
|
var KB_CHUNK_LIMIT = 10;
|
|
2607
2844
|
var KB_CONTEXT_MAX_CHARS = 4e3;
|
|
2845
|
+
var RAG_LOG = "[rag-context]";
|
|
2608
2846
|
function getQueryTerms(message) {
|
|
2609
2847
|
return message.replace(/[^\w\s]/g, " ").split(/\s+/).filter((w) => w.length > 2).slice(0, 6);
|
|
2610
2848
|
}
|
|
2849
|
+
function normalizeChatModeSetting(raw) {
|
|
2850
|
+
if (raw === "external" || raw === "llm") return raw;
|
|
2851
|
+
return "whatsapp";
|
|
2852
|
+
}
|
|
2853
|
+
async function loadLlmSettingsMap(dataSource, entityMap) {
|
|
2854
|
+
if (!entityMap.configs) return {};
|
|
2855
|
+
const repo = dataSource.getRepository(entityMap.configs);
|
|
2856
|
+
const rows = await repo.find({ where: { settings: "llm", deleted: false } });
|
|
2857
|
+
const out = {};
|
|
2858
|
+
for (const row of rows) {
|
|
2859
|
+
out[row.key] = row.value;
|
|
2860
|
+
}
|
|
2861
|
+
return out;
|
|
2862
|
+
}
|
|
2611
2863
|
function createChatHandlers(config) {
|
|
2612
2864
|
const { dataSource, entityMap, json, getCms } = config;
|
|
2613
2865
|
const contactRepo = () => dataSource.getRepository(entityMap.contacts);
|
|
@@ -2615,6 +2867,26 @@ function createChatHandlers(config) {
|
|
|
2615
2867
|
const msgRepo = () => dataSource.getRepository(entityMap.chat_messages);
|
|
2616
2868
|
const chunkRepo = () => dataSource.getRepository(entityMap.knowledge_base_chunks);
|
|
2617
2869
|
return {
|
|
2870
|
+
async publicConfig(_req) {
|
|
2871
|
+
try {
|
|
2872
|
+
const map = await loadLlmSettingsMap(dataSource, entityMap);
|
|
2873
|
+
const mode = normalizeChatModeSetting(map.chatMode);
|
|
2874
|
+
const body = {
|
|
2875
|
+
enabled: map.enabled !== "false",
|
|
2876
|
+
chatMode: mode,
|
|
2877
|
+
agentSlug: mode === "llm" ? (map.attachedAgentSlug ?? "").trim() : "",
|
|
2878
|
+
botName: map.botName ?? "",
|
|
2879
|
+
icon: map.icon ?? "",
|
|
2880
|
+
iconImageUrl: map.iconImageUrl ?? "",
|
|
2881
|
+
iconBackgroundColor: map.iconBackgroundColor ?? "#6366f1",
|
|
2882
|
+
headerColor: map.headerColor ?? "#6366f1",
|
|
2883
|
+
whatsappPhone: map.whatsappPhone ?? ""
|
|
2884
|
+
};
|
|
2885
|
+
return json(body);
|
|
2886
|
+
} catch {
|
|
2887
|
+
return json({ error: "Failed to load chat config" }, { status: 500 });
|
|
2888
|
+
}
|
|
2889
|
+
},
|
|
2618
2890
|
async identify(req) {
|
|
2619
2891
|
try {
|
|
2620
2892
|
const body = await req.json();
|
|
@@ -2662,20 +2934,78 @@ function createChatHandlers(config) {
|
|
|
2662
2934
|
relations: ["messages"]
|
|
2663
2935
|
});
|
|
2664
2936
|
if (!conv) return json({ error: "Conversation not found" }, { status: 404 });
|
|
2665
|
-
const msgRepoInst = msgRepo();
|
|
2666
|
-
await msgRepoInst.save(msgRepoInst.create({ conversationId, role: "user", content: message }));
|
|
2667
2937
|
const cms = await getCms();
|
|
2668
2938
|
const llm = cms.getPlugin("llm");
|
|
2669
2939
|
if (!llm?.chat) return json({ error: "LLM not configured" }, { status: 503 });
|
|
2940
|
+
const llmSettings = await loadLlmSettingsMap(dataSource, entityMap);
|
|
2941
|
+
const supportMode = normalizeChatModeSetting(llmSettings.chatMode);
|
|
2942
|
+
let effectiveSlug = (body?.agentSlug ?? "").trim();
|
|
2943
|
+
if (!effectiveSlug && supportMode === "llm" && entityMap.llm_agents) {
|
|
2944
|
+
effectiveSlug = (llmSettings.attachedAgentSlug ?? "").trim();
|
|
2945
|
+
}
|
|
2946
|
+
let agentRow = null;
|
|
2947
|
+
if (effectiveSlug) {
|
|
2948
|
+
if (!entityMap.llm_agents) {
|
|
2949
|
+
return json({ error: "LLM agents are not configured on this deployment" }, { status: 400 });
|
|
2950
|
+
}
|
|
2951
|
+
const agentRepo = dataSource.getRepository(
|
|
2952
|
+
entityMap.llm_agents
|
|
2953
|
+
);
|
|
2954
|
+
agentRow = await agentRepo.findOne({
|
|
2955
|
+
where: { slug: effectiveSlug, deleted: false, enabled: true }
|
|
2956
|
+
});
|
|
2957
|
+
if (!agentRow && (body?.agentSlug ?? "").trim()) {
|
|
2958
|
+
return json({ error: "Agent not found or disabled", agentSlug: effectiveSlug }, { status: 404 });
|
|
2959
|
+
}
|
|
2960
|
+
}
|
|
2961
|
+
console.info(RAG_LOG, "step 1 | resolve agent", {
|
|
2962
|
+
agentSlug: effectiveSlug || "(none)",
|
|
2963
|
+
agentFound: !!agentRow,
|
|
2964
|
+
agentId: agentRow?.id ?? null
|
|
2965
|
+
});
|
|
2966
|
+
const parsedValidation = agentRow ? parseLlmAgentValidationRules(agentRow.validationRules) : { structured: {}, guardrailsForPrompt: null };
|
|
2967
|
+
if (agentRow) {
|
|
2968
|
+
const v = validateUserMessageAgainstStructuredRules(message, parsedValidation.structured);
|
|
2969
|
+
if (!v.ok) return json({ error: v.error, reason: "validation_failed" }, { status: 400 });
|
|
2970
|
+
}
|
|
2971
|
+
let kbDocumentScope;
|
|
2972
|
+
const Junction = entityMap.llm_agent_knowledge_documents;
|
|
2973
|
+
if (agentRow && Junction) {
|
|
2974
|
+
const linkRepo = dataSource.getRepository(Junction);
|
|
2975
|
+
const links = await linkRepo.find({ where: { agentId: agentRow.id } });
|
|
2976
|
+
const ids = [...new Set(links.map((l) => l.documentId))];
|
|
2977
|
+
if (ids.length > 0) kbDocumentScope = ids;
|
|
2978
|
+
}
|
|
2979
|
+
console.info(RAG_LOG, "step 2 | knowledge scope", {
|
|
2980
|
+
scopedDocumentIds: kbDocumentScope ?? "(all documents)",
|
|
2981
|
+
documentCount: kbDocumentScope?.length ?? "all"
|
|
2982
|
+
});
|
|
2983
|
+
const msgRepoInst = msgRepo();
|
|
2984
|
+
await msgRepoInst.save(msgRepoInst.create({ conversationId, role: "user", content: message }));
|
|
2670
2985
|
let contextParts = [];
|
|
2986
|
+
console.info(RAG_LOG, "step 3 | embed user query", {
|
|
2987
|
+
messageChars: message.length,
|
|
2988
|
+
embedAvailable: !!llm.embed
|
|
2989
|
+
});
|
|
2671
2990
|
const queryEmbedding = llm.embed ? await llm.embed(message) : null;
|
|
2991
|
+
console.info(RAG_LOG, "step 4 | query embedding result", {
|
|
2992
|
+
dimensions: queryEmbedding?.length ?? 0,
|
|
2993
|
+
hasEmbedding: !!(queryEmbedding && queryEmbedding.length > 0)
|
|
2994
|
+
});
|
|
2672
2995
|
if (queryEmbedding && queryEmbedding.length > 0) {
|
|
2673
2996
|
const vectorStr = "[" + queryEmbedding.join(",") + "]";
|
|
2674
2997
|
try {
|
|
2675
|
-
const rows = await dataSource.query(
|
|
2998
|
+
const rows = kbDocumentScope?.length ? await dataSource.query(
|
|
2999
|
+
`SELECT id, content FROM knowledge_base_chunks WHERE embedding IS NOT NULL AND "documentId" = ANY($3::int[]) ORDER BY embedding <=> $1::vector LIMIT $2`,
|
|
3000
|
+
[vectorStr, KB_CHUNK_LIMIT, kbDocumentScope]
|
|
3001
|
+
) : await dataSource.query(
|
|
2676
3002
|
`SELECT id, content FROM knowledge_base_chunks WHERE embedding IS NOT NULL ORDER BY embedding <=> $1::vector LIMIT $2`,
|
|
2677
3003
|
[vectorStr, KB_CHUNK_LIMIT]
|
|
2678
3004
|
);
|
|
3005
|
+
console.info(RAG_LOG, "step 5 | vector search results", {
|
|
3006
|
+
rowsReturned: rows.length,
|
|
3007
|
+
chunkIds: rows.map((r) => r.id)
|
|
3008
|
+
});
|
|
2679
3009
|
let totalLen = 0;
|
|
2680
3010
|
for (const r of rows) {
|
|
2681
3011
|
const text = (r.content ?? "").trim();
|
|
@@ -2683,13 +3013,24 @@ function createChatHandlers(config) {
|
|
|
2683
3013
|
contextParts.push(text);
|
|
2684
3014
|
totalLen += text.length;
|
|
2685
3015
|
}
|
|
2686
|
-
|
|
3016
|
+
console.info(RAG_LOG, "step 5a | vector context selected", {
|
|
3017
|
+
chunksUsed: contextParts.length,
|
|
3018
|
+
totalChars: totalLen
|
|
3019
|
+
});
|
|
3020
|
+
} catch (vecErr) {
|
|
3021
|
+
console.warn(RAG_LOG, "step 5 | vector search failed; falling back to keyword", {
|
|
3022
|
+
err: vecErr instanceof Error ? vecErr.message : String(vecErr)
|
|
3023
|
+
});
|
|
2687
3024
|
}
|
|
2688
3025
|
}
|
|
2689
3026
|
if (contextParts.length === 0) {
|
|
2690
3027
|
const terms = getQueryTerms(message);
|
|
3028
|
+
console.info(RAG_LOG, "step 6 | keyword fallback", {
|
|
3029
|
+
reason: !(queryEmbedding && queryEmbedding.length > 0) ? "no embedding" : "vector search returned nothing",
|
|
3030
|
+
searchTerms: terms
|
|
3031
|
+
});
|
|
2691
3032
|
if (terms.length > 0) {
|
|
2692
|
-
const conditions = terms.map((t) => ({ content: ILike2(`%${t}%`) }));
|
|
3033
|
+
const conditions = kbDocumentScope?.length ? terms.map((t) => ({ content: ILike2(`%${t}%`), documentId: In(kbDocumentScope) })) : terms.map((t) => ({ content: ILike2(`%${t}%`) }));
|
|
2693
3034
|
const chunks = await chunkRepo().find({
|
|
2694
3035
|
where: conditions,
|
|
2695
3036
|
take: KB_CHUNK_LIMIT,
|
|
@@ -2704,19 +3045,66 @@ function createChatHandlers(config) {
|
|
|
2704
3045
|
contextParts.push(text);
|
|
2705
3046
|
totalLen += text.length;
|
|
2706
3047
|
}
|
|
3048
|
+
console.info(RAG_LOG, "step 6a | keyword results", {
|
|
3049
|
+
chunksFound: chunks.length,
|
|
3050
|
+
chunksUsed: contextParts.length,
|
|
3051
|
+
totalChars: totalLen
|
|
3052
|
+
});
|
|
2707
3053
|
}
|
|
2708
3054
|
}
|
|
2709
|
-
const
|
|
2710
|
-
const
|
|
3055
|
+
const historyRaw = (conv.messages ?? []).sort((a, b) => new Date(a.createdAt ?? 0).getTime() - new Date(b.createdAt ?? 0).getTime()).map((m) => ({ role: m.role, content: m.content }));
|
|
3056
|
+
const history = historyBeforeCurrentUser(historyRaw, message);
|
|
3057
|
+
let content;
|
|
3058
|
+
const ragContext = contextParts.length > 0 ? contextParts.join("\n\n") : void 0;
|
|
3059
|
+
console.info(RAG_LOG, "step 7 | final context", {
|
|
3060
|
+
method: contextParts.length > 0 ? "rag" : "none",
|
|
3061
|
+
contextChunks: contextParts.length,
|
|
3062
|
+
contextChars: ragContext?.length ?? 0,
|
|
3063
|
+
contextPreview: ragContext ? ragContext.slice(0, 200) + (ragContext.length > 200 ? "\u2026" : "") : "(no context)"
|
|
3064
|
+
});
|
|
3065
|
+
if (agentRow && llm.chatAgent) {
|
|
3066
|
+
const fromAgent = llmAgentToChatAgentOptions(agentRow);
|
|
3067
|
+
const systemPrompt = mergeGuardrailsIntoSystemPrompt(
|
|
3068
|
+
fromAgent.systemPrompt,
|
|
3069
|
+
parsedValidation.guardrailsForPrompt
|
|
3070
|
+
);
|
|
3071
|
+
const res = await llm.chatAgent({
|
|
3072
|
+
...fromAgent,
|
|
3073
|
+
systemPrompt: systemPrompt || void 0,
|
|
3074
|
+
context: ragContext,
|
|
3075
|
+
history,
|
|
3076
|
+
userPrompt: message
|
|
3077
|
+
});
|
|
3078
|
+
content = res.content;
|
|
3079
|
+
} else {
|
|
3080
|
+
const ragSystem = contextParts.length > 0 ? `Use the following context about the company and its products to answer. If the answer is not in the context, say so.
|
|
2711
3081
|
|
|
2712
3082
|
Context:
|
|
2713
|
-
${contextParts.join("\n\n")}` : "
|
|
2714
|
-
|
|
2715
|
-
|
|
2716
|
-
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
3083
|
+
${contextParts.join("\n\n")}` : "";
|
|
3084
|
+
const defaultSystem = "You are a helpful assistant for the company. If you do not have specific information, say so.";
|
|
3085
|
+
let systemContent;
|
|
3086
|
+
if (agentRow) {
|
|
3087
|
+
const base = agentRow.systemInstruction?.trim() || "";
|
|
3088
|
+
systemContent = mergeGuardrailsIntoSystemPrompt(
|
|
3089
|
+
[base, ragSystem].filter(Boolean).join("\n\n") || defaultSystem,
|
|
3090
|
+
parsedValidation.guardrailsForPrompt
|
|
3091
|
+
);
|
|
3092
|
+
} else {
|
|
3093
|
+
systemContent = ragSystem || defaultSystem;
|
|
3094
|
+
}
|
|
3095
|
+
const messages = [
|
|
3096
|
+
{ role: "system", content: systemContent },
|
|
3097
|
+
...history,
|
|
3098
|
+
{ role: "user", content: message }
|
|
3099
|
+
];
|
|
3100
|
+
const chatOpts = agentRow ? {
|
|
3101
|
+
model: agentRow.model ?? void 0,
|
|
3102
|
+
temperature: agentRow.temperature ?? void 0,
|
|
3103
|
+
max_tokens: agentRow.maxTokens ?? void 0
|
|
3104
|
+
} : {};
|
|
3105
|
+
const res = await llm.chat(messages, chatOpts);
|
|
3106
|
+
content = res.content;
|
|
3107
|
+
}
|
|
2720
3108
|
await msgRepoInst.save(msgRepoInst.create({ conversationId, role: "assistant", content }));
|
|
2721
3109
|
return json({ content });
|
|
2722
3110
|
} catch (err) {
|
|
@@ -2727,6 +3115,560 @@ ${contextParts.join("\n\n")}` : "You are a helpful assistant for the company. If
|
|
|
2727
3115
|
};
|
|
2728
3116
|
}
|
|
2729
3117
|
|
|
3118
|
+
// src/api/llm-agent-knowledge-handlers.ts
|
|
3119
|
+
import { In as In2 } from "typeorm";
|
|
3120
|
+
var INGEST_CHUNK_CHARS = 900;
|
|
3121
|
+
var MAX_CHUNKS_PER_UPLOAD = 400;
|
|
3122
|
+
var EMBED_CONCURRENCY = 5;
|
|
3123
|
+
var MAX_PDF_BYTES = 25 * 1024 * 1024;
|
|
3124
|
+
var TEXT_FILE_TYPES = /* @__PURE__ */ new Set(["text/plain", "text/markdown", "application/json"]);
|
|
3125
|
+
var KB_LOG = "[llm-agent-knowledge]";
|
|
3126
|
+
function logKbPipeline(step, meta) {
|
|
3127
|
+
console.info(`${KB_LOG} pipeline`, { step, ...meta });
|
|
3128
|
+
}
|
|
3129
|
+
function llmEmbedDebug() {
|
|
3130
|
+
const v = process.env.LLM_EMBED_DEBUG?.toLowerCase();
|
|
3131
|
+
return v === "1" || v === "true" || v === "yes";
|
|
3132
|
+
}
|
|
3133
|
+
function isPdfUpload(mime, fileName) {
|
|
3134
|
+
if (mime === "application/pdf") return true;
|
|
3135
|
+
const n = fileName.toLowerCase();
|
|
3136
|
+
return n.endsWith(".pdf");
|
|
3137
|
+
}
|
|
3138
|
+
async function extractTextFromPdf(buffer) {
|
|
3139
|
+
const pdfParse = await import("pdf-parse");
|
|
3140
|
+
const data = await pdfParse(buffer);
|
|
3141
|
+
return (data?.text ?? "").trim();
|
|
3142
|
+
}
|
|
3143
|
+
async function loadChunksMissingEmbeddings(dataSource, documentId, slug) {
|
|
3144
|
+
const rows = await dataSource.query(
|
|
3145
|
+
`SELECT id, content FROM knowledge_base_chunks WHERE "documentId" = $1 AND embedding IS NULL ORDER BY "chunkIndex" ASC`,
|
|
3146
|
+
[documentId]
|
|
3147
|
+
);
|
|
3148
|
+
const list = rows ?? [];
|
|
3149
|
+
logKbPipeline("07_query_chunks_missing_embedding", {
|
|
3150
|
+
slug,
|
|
3151
|
+
documentId,
|
|
3152
|
+
missingEmbeddingCount: list.length
|
|
3153
|
+
});
|
|
3154
|
+
return list;
|
|
3155
|
+
}
|
|
3156
|
+
async function writeEmbeddingsConcurrent(dataSource, embed, chunks, concurrency, slug) {
|
|
3157
|
+
let next = 0;
|
|
3158
|
+
let written = 0;
|
|
3159
|
+
let failed = 0;
|
|
3160
|
+
let skippedEmpty = 0;
|
|
3161
|
+
logKbPipeline("09_embedding_workers_start", {
|
|
3162
|
+
slug,
|
|
3163
|
+
chunkCount: chunks.length,
|
|
3164
|
+
concurrency: Math.max(1, Math.min(concurrency, chunks.length))
|
|
3165
|
+
});
|
|
3166
|
+
async function worker() {
|
|
3167
|
+
for (; ; ) {
|
|
3168
|
+
const i = next++;
|
|
3169
|
+
if (i >= chunks.length) return;
|
|
3170
|
+
const c = chunks[i];
|
|
3171
|
+
try {
|
|
3172
|
+
const emb = await embed(c.content);
|
|
3173
|
+
if (emb?.length) {
|
|
3174
|
+
const vectorStr = "[" + emb.join(",") + "]";
|
|
3175
|
+
await dataSource.query(
|
|
3176
|
+
`UPDATE knowledge_base_chunks SET embedding = $1::vector WHERE id = $2`,
|
|
3177
|
+
[vectorStr, c.id]
|
|
3178
|
+
);
|
|
3179
|
+
written++;
|
|
3180
|
+
} else {
|
|
3181
|
+
skippedEmpty++;
|
|
3182
|
+
if (llmEmbedDebug()) {
|
|
3183
|
+
console.warn(`${KB_LOG} embed() returned empty vector`, { chunkId: c.id });
|
|
3184
|
+
}
|
|
3185
|
+
}
|
|
3186
|
+
} catch (err) {
|
|
3187
|
+
failed++;
|
|
3188
|
+
console.error(`${KB_LOG} embedding DB update failed`, {
|
|
3189
|
+
chunkId: c.id,
|
|
3190
|
+
err: err instanceof Error ? err.message : String(err)
|
|
3191
|
+
});
|
|
3192
|
+
}
|
|
3193
|
+
}
|
|
3194
|
+
}
|
|
3195
|
+
const n = Math.max(1, Math.min(concurrency, chunks.length));
|
|
3196
|
+
await Promise.all(Array.from({ length: n }, () => worker()));
|
|
3197
|
+
const summary = {
|
|
3198
|
+
chunkCount: chunks.length,
|
|
3199
|
+
written,
|
|
3200
|
+
failed,
|
|
3201
|
+
skippedEmpty
|
|
3202
|
+
};
|
|
3203
|
+
if (skippedEmpty > 0 && written === 0) {
|
|
3204
|
+
summary.hint = "embed() returned empty vectors \u2014 see [LLM embed] / [LLM embed HF] logs (OpenAI gateway vs @huggingface/inference + legacy HTTP).";
|
|
3205
|
+
}
|
|
3206
|
+
logKbPipeline("10_embedding_workers_finished", { slug, ...summary });
|
|
3207
|
+
if (failed > 0 || skippedEmpty > 0 && written === 0) {
|
|
3208
|
+
console.error(`${KB_LOG} embedding pass finished with issues`, summary);
|
|
3209
|
+
}
|
|
3210
|
+
return { written, failed };
|
|
3211
|
+
}
|
|
3212
|
+
function splitIntoChunks(text, maxLen) {
|
|
3213
|
+
const t = text.trim();
|
|
3214
|
+
if (!t) return [];
|
|
3215
|
+
const chunks = [];
|
|
3216
|
+
for (let i = 0; i < t.length; i += maxLen) {
|
|
3217
|
+
chunks.push(t.slice(i, i + maxLen));
|
|
3218
|
+
}
|
|
3219
|
+
return chunks;
|
|
3220
|
+
}
|
|
3221
|
+
async function findAgentBySlug(dataSource, llmAgents, slug) {
|
|
3222
|
+
const repo = dataSource.getRepository(llmAgents);
|
|
3223
|
+
return repo.findOne({
|
|
3224
|
+
where: { slug, deleted: false }
|
|
3225
|
+
});
|
|
3226
|
+
}
|
|
3227
|
+
function createLlmAgentKnowledgeHandlers(config) {
|
|
3228
|
+
const { dataSource, entityMap, getCms, json, requireAuth, requireEntityPermission } = config;
|
|
3229
|
+
const kbDoc = entityMap.knowledge_base_documents;
|
|
3230
|
+
const kbChunk = entityMap.knowledge_base_chunks;
|
|
3231
|
+
const llmAgents = entityMap.llm_agents;
|
|
3232
|
+
const junction = entityMap.llm_agent_knowledge_documents;
|
|
3233
|
+
if (!kbDoc || !kbChunk || !llmAgents || !junction) {
|
|
3234
|
+
return null;
|
|
3235
|
+
}
|
|
3236
|
+
async function gate(req, action) {
|
|
3237
|
+
const a = await requireAuth(req);
|
|
3238
|
+
if (a) return a;
|
|
3239
|
+
if (requireEntityPermission) {
|
|
3240
|
+
const pe = await requireEntityPermission(req, "llm_agents", action);
|
|
3241
|
+
if (pe) return pe;
|
|
3242
|
+
}
|
|
3243
|
+
return null;
|
|
3244
|
+
}
|
|
3245
|
+
async function runEmbeddingPass(slug, savedChunks) {
|
|
3246
|
+
let embeddingsWritten = 0;
|
|
3247
|
+
let embeddingsFailed = 0;
|
|
3248
|
+
try {
|
|
3249
|
+
logKbPipeline("08_resolve_llm_plugin", { slug, chunkCount: savedChunks.length });
|
|
3250
|
+
const cms = await getCms();
|
|
3251
|
+
const llm = cms.getPlugin("llm");
|
|
3252
|
+
if (llm?.embed && savedChunks.length > 0) {
|
|
3253
|
+
logKbPipeline("08b_embed_fn_available", {
|
|
3254
|
+
slug,
|
|
3255
|
+
chunkCount: savedChunks.length,
|
|
3256
|
+
firstChunkId: savedChunks[0]?.id,
|
|
3257
|
+
lastChunkId: savedChunks[savedChunks.length - 1]?.id
|
|
3258
|
+
});
|
|
3259
|
+
const embedBound = (text) => llm.embed(text);
|
|
3260
|
+
const { written, failed } = await writeEmbeddingsConcurrent(
|
|
3261
|
+
dataSource,
|
|
3262
|
+
embedBound,
|
|
3263
|
+
savedChunks,
|
|
3264
|
+
EMBED_CONCURRENCY,
|
|
3265
|
+
slug
|
|
3266
|
+
);
|
|
3267
|
+
embeddingsWritten = written;
|
|
3268
|
+
embeddingsFailed = failed;
|
|
3269
|
+
} else {
|
|
3270
|
+
logKbPipeline("08c_embed_skipped", {
|
|
3271
|
+
slug,
|
|
3272
|
+
hasLlmPlugin: !!llm,
|
|
3273
|
+
hasEmbed: typeof llm?.embed === "function",
|
|
3274
|
+
chunkCount: savedChunks.length,
|
|
3275
|
+
reason: savedChunks.length === 0 ? "no_chunks" : !llm ? "no_llm_plugin" : "no_embed_method"
|
|
3276
|
+
});
|
|
3277
|
+
console.error(`${KB_LOG} embeddings skipped`, {
|
|
3278
|
+
slug,
|
|
3279
|
+
hasLlmPlugin: !!llm,
|
|
3280
|
+
hasEmbed: typeof llm?.embed === "function",
|
|
3281
|
+
chunkCount: savedChunks.length,
|
|
3282
|
+
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
|
|
3283
|
+
});
|
|
3284
|
+
}
|
|
3285
|
+
} catch (embErr) {
|
|
3286
|
+
const detail = embErr instanceof Error ? embErr.message : String(embErr);
|
|
3287
|
+
logKbPipeline("08d_embed_pass_exception", { slug, detail });
|
|
3288
|
+
console.error(`${KB_LOG} embedding step threw before/during batch`, { slug, detail, embErr });
|
|
3289
|
+
return {
|
|
3290
|
+
embeddingsWritten: 0,
|
|
3291
|
+
embeddingsFailed: savedChunks.length,
|
|
3292
|
+
embedError: detail
|
|
3293
|
+
};
|
|
3294
|
+
}
|
|
3295
|
+
return { embeddingsWritten, embeddingsFailed };
|
|
3296
|
+
}
|
|
3297
|
+
return {
|
|
3298
|
+
async list(req, slug) {
|
|
3299
|
+
const denied = await gate(req, "read");
|
|
3300
|
+
if (denied) return denied;
|
|
3301
|
+
try {
|
|
3302
|
+
const agent = await findAgentBySlug(dataSource, llmAgents, slug);
|
|
3303
|
+
if (!agent) return json({ error: "Agent not found" }, { status: 404 });
|
|
3304
|
+
const linkRepo = dataSource.getRepository(junction);
|
|
3305
|
+
const links = await linkRepo.find({ where: { agentId: agent.id } });
|
|
3306
|
+
const docIds = [...new Set(links.map((l) => l.documentId))];
|
|
3307
|
+
if (docIds.length === 0) return json({ documents: [] });
|
|
3308
|
+
const docRepo = dataSource.getRepository(kbDoc);
|
|
3309
|
+
const docs = await docRepo.find({ where: { id: In2(docIds) } });
|
|
3310
|
+
const byId = new Map(docs.map((d) => [d.id, d]));
|
|
3311
|
+
const documents = docIds.map((id) => {
|
|
3312
|
+
const d = byId.get(id);
|
|
3313
|
+
return d ? { id: d.id, name: d.name } : null;
|
|
3314
|
+
}).filter(Boolean);
|
|
3315
|
+
return json({ documents });
|
|
3316
|
+
} catch (err) {
|
|
3317
|
+
const msg = err instanceof Error ? err.message : "Failed to list knowledge";
|
|
3318
|
+
return json({ error: msg }, { status: 500 });
|
|
3319
|
+
}
|
|
3320
|
+
},
|
|
3321
|
+
async post(req, slug) {
|
|
3322
|
+
const denied = await gate(req, "update");
|
|
3323
|
+
if (denied) return denied;
|
|
3324
|
+
try {
|
|
3325
|
+
const ct0 = req.headers.get("content-type") || "";
|
|
3326
|
+
logKbPipeline("01_request", { slug, contentType: ct0.slice(0, 80) });
|
|
3327
|
+
const agent = await findAgentBySlug(dataSource, llmAgents, slug);
|
|
3328
|
+
if (!agent) return json({ error: "Agent not found" }, { status: 404 });
|
|
3329
|
+
logKbPipeline("02_agent_loaded", { slug, agentId: agent.id });
|
|
3330
|
+
let name = "";
|
|
3331
|
+
let text = "";
|
|
3332
|
+
let sourceUrl = null;
|
|
3333
|
+
let existingDocumentId = null;
|
|
3334
|
+
const ct = req.headers.get("content-type") || "";
|
|
3335
|
+
if (ct.includes("application/json")) {
|
|
3336
|
+
const body = await req.json();
|
|
3337
|
+
existingDocumentId = typeof body?.documentId === "number" && Number.isFinite(body.documentId) ? body.documentId : null;
|
|
3338
|
+
name = (body?.name ?? "").trim();
|
|
3339
|
+
text = (body?.text ?? "").trim();
|
|
3340
|
+
sourceUrl = typeof body?.sourceUrl === "string" && body.sourceUrl.trim() ? body.sourceUrl.trim() : null;
|
|
3341
|
+
logKbPipeline("03_body_parsed", {
|
|
3342
|
+
slug,
|
|
3343
|
+
mode: "json",
|
|
3344
|
+
existingDocumentId,
|
|
3345
|
+
nameLen: name.length,
|
|
3346
|
+
textChars: text.length,
|
|
3347
|
+
hasSourceUrl: !!sourceUrl
|
|
3348
|
+
});
|
|
3349
|
+
} else if (ct.includes("multipart/form-data")) {
|
|
3350
|
+
const form = await req.formData();
|
|
3351
|
+
name = form.get("name")?.trim() ?? "";
|
|
3352
|
+
text = form.get("text")?.trim() ?? "";
|
|
3353
|
+
const file = form.get("file");
|
|
3354
|
+
if (file && typeof file !== "string" && "arrayBuffer" in file) {
|
|
3355
|
+
const f = file;
|
|
3356
|
+
const mime = (f.type || "").split(";")[0].trim().toLowerCase();
|
|
3357
|
+
const buf = Buffer.from(await f.arrayBuffer());
|
|
3358
|
+
logKbPipeline("03_body_parsed", {
|
|
3359
|
+
slug,
|
|
3360
|
+
mode: "multipart",
|
|
3361
|
+
fileName: f.name || "(no name)",
|
|
3362
|
+
mime,
|
|
3363
|
+
fileBytes: buf.length
|
|
3364
|
+
});
|
|
3365
|
+
if (TEXT_FILE_TYPES.has(mime)) {
|
|
3366
|
+
const decoded = buf.toString("utf8");
|
|
3367
|
+
if (!text) text = decoded;
|
|
3368
|
+
logKbPipeline("04_file_decoded_text", { slug, mime, textChars: text.length });
|
|
3369
|
+
} else if (isPdfUpload(mime, f.name || "")) {
|
|
3370
|
+
if (buf.length > MAX_PDF_BYTES) {
|
|
3371
|
+
return json(
|
|
3372
|
+
{ error: `PDF too large (max ${Math.floor(MAX_PDF_BYTES / (1024 * 1024))}MB)` },
|
|
3373
|
+
{ status: 413 }
|
|
3374
|
+
);
|
|
3375
|
+
}
|
|
3376
|
+
try {
|
|
3377
|
+
logKbPipeline("04_pdf_extract_start", { slug, fileBytes: buf.length });
|
|
3378
|
+
const extracted = await extractTextFromPdf(buf);
|
|
3379
|
+
if (!text) text = extracted;
|
|
3380
|
+
logKbPipeline("04_pdf_extract_done", { slug, textChars: text.length });
|
|
3381
|
+
} catch {
|
|
3382
|
+
return json(
|
|
3383
|
+
{ error: "Could not read PDF text (file may be encrypted, corrupt, or image-only)" },
|
|
3384
|
+
{ status: 422 }
|
|
3385
|
+
);
|
|
3386
|
+
}
|
|
3387
|
+
} else {
|
|
3388
|
+
return json(
|
|
3389
|
+
{
|
|
3390
|
+
error: "Unsupported file type; use text/plain, text/markdown, application/json, or application/pdf"
|
|
3391
|
+
},
|
|
3392
|
+
{ status: 415 }
|
|
3393
|
+
);
|
|
3394
|
+
}
|
|
3395
|
+
if (!name && f.name) name = f.name.replace(/\.[^/.]+$/, "") || f.name;
|
|
3396
|
+
} else {
|
|
3397
|
+
logKbPipeline("03_body_parsed", { slug, mode: "multipart", hasFile: false, textChars: text.length });
|
|
3398
|
+
}
|
|
3399
|
+
} else {
|
|
3400
|
+
return json({ error: "Use application/json or multipart/form-data" }, { status: 400 });
|
|
3401
|
+
}
|
|
3402
|
+
const linkRepo = dataSource.getRepository(junction);
|
|
3403
|
+
if (existingDocumentId != null) {
|
|
3404
|
+
logKbPipeline("05_branch", { slug, branch: "link_existing_document", documentId: existingDocumentId });
|
|
3405
|
+
const docRepo2 = dataSource.getRepository(kbDoc);
|
|
3406
|
+
const existing = await docRepo2.findOne({ where: { id: existingDocumentId } });
|
|
3407
|
+
if (!existing) return json({ error: "documentId not found" }, { status: 404 });
|
|
3408
|
+
const dup2 = await linkRepo.findOne({
|
|
3409
|
+
where: { agentId: agent.id, documentId: existingDocumentId }
|
|
3410
|
+
});
|
|
3411
|
+
if (!dup2) {
|
|
3412
|
+
await linkRepo.save(linkRepo.create({ agentId: agent.id, documentId: existingDocumentId }));
|
|
3413
|
+
logKbPipeline("06_junction_link_created", {
|
|
3414
|
+
slug,
|
|
3415
|
+
agentId: agent.id,
|
|
3416
|
+
documentId: existingDocumentId
|
|
3417
|
+
});
|
|
3418
|
+
} else {
|
|
3419
|
+
logKbPipeline("06_junction_link_exists", {
|
|
3420
|
+
slug,
|
|
3421
|
+
agentId: agent.id,
|
|
3422
|
+
documentId: existingDocumentId
|
|
3423
|
+
});
|
|
3424
|
+
}
|
|
3425
|
+
const chunkRepo2 = dataSource.getRepository(kbChunk);
|
|
3426
|
+
const docRow = existing;
|
|
3427
|
+
const chunkCount = await chunkRepo2.count({ where: { documentId: existingDocumentId } });
|
|
3428
|
+
logKbPipeline("06b_chunks_existing_count", {
|
|
3429
|
+
slug,
|
|
3430
|
+
documentId: existingDocumentId,
|
|
3431
|
+
chunkCount
|
|
3432
|
+
});
|
|
3433
|
+
let chunksToEmbed = [];
|
|
3434
|
+
let chunksCreated = 0;
|
|
3435
|
+
if (chunkCount === 0) {
|
|
3436
|
+
const text2 = (docRow.content ?? "").trim();
|
|
3437
|
+
if (!text2) {
|
|
3438
|
+
logKbPipeline("07_ingest_aborted_empty_document", { slug, documentId: existingDocumentId });
|
|
3439
|
+
return json({
|
|
3440
|
+
documentId: existingDocumentId,
|
|
3441
|
+
linked: true,
|
|
3442
|
+
created: false,
|
|
3443
|
+
chunkCount: 0,
|
|
3444
|
+
embeddingsWritten: 0,
|
|
3445
|
+
embeddingsFailed: 0,
|
|
3446
|
+
warning: "Document has no text content; add content then attach again to build chunks and embeddings."
|
|
3447
|
+
});
|
|
3448
|
+
}
|
|
3449
|
+
const parts2 = splitIntoChunks(text2, INGEST_CHUNK_CHARS);
|
|
3450
|
+
if (parts2.length > MAX_CHUNKS_PER_UPLOAD) {
|
|
3451
|
+
return json(
|
|
3452
|
+
{
|
|
3453
|
+
error: `Document is too large for one ingest (${parts2.length} chunks; max ${MAX_CHUNKS_PER_UPLOAD}). Split into smaller files.`
|
|
3454
|
+
},
|
|
3455
|
+
{ status: 413 }
|
|
3456
|
+
);
|
|
3457
|
+
}
|
|
3458
|
+
logKbPipeline("07_chunk_split", {
|
|
3459
|
+
slug,
|
|
3460
|
+
documentId: existingDocumentId,
|
|
3461
|
+
partCount: parts2.length,
|
|
3462
|
+
maxChunkChars: INGEST_CHUNK_CHARS,
|
|
3463
|
+
totalChars: text2.length
|
|
3464
|
+
});
|
|
3465
|
+
const now2 = /* @__PURE__ */ new Date();
|
|
3466
|
+
const chunkRows2 = parts2.map(
|
|
3467
|
+
(content, i) => chunkRepo2.create({
|
|
3468
|
+
documentId: existingDocumentId,
|
|
3469
|
+
content,
|
|
3470
|
+
chunkIndex: i,
|
|
3471
|
+
createdAt: now2
|
|
3472
|
+
})
|
|
3473
|
+
);
|
|
3474
|
+
const savedList2 = await chunkRepo2.save(chunkRows2);
|
|
3475
|
+
chunksCreated = savedList2.length;
|
|
3476
|
+
chunksToEmbed = savedList2.map((row, i) => ({
|
|
3477
|
+
id: row.id,
|
|
3478
|
+
content: parts2[i]
|
|
3479
|
+
}));
|
|
3480
|
+
logKbPipeline("07b_chunks_persisted", {
|
|
3481
|
+
slug,
|
|
3482
|
+
documentId: existingDocumentId,
|
|
3483
|
+
rowsInserted: chunksCreated
|
|
3484
|
+
});
|
|
3485
|
+
} else {
|
|
3486
|
+
chunksToEmbed = await loadChunksMissingEmbeddings(dataSource, existingDocumentId, slug);
|
|
3487
|
+
if (chunksToEmbed.length === 0) {
|
|
3488
|
+
logKbPipeline("08_skip_embed_all_chunks_have_vectors", {
|
|
3489
|
+
slug,
|
|
3490
|
+
documentId: existingDocumentId,
|
|
3491
|
+
existingChunkCount: chunkCount
|
|
3492
|
+
});
|
|
3493
|
+
}
|
|
3494
|
+
}
|
|
3495
|
+
const embedResult2 = chunksToEmbed.length > 0 ? await runEmbeddingPass(slug, chunksToEmbed) : { embeddingsWritten: 0, embeddingsFailed: 0 };
|
|
3496
|
+
if (embedResult2.embedError) {
|
|
3497
|
+
logKbPipeline("11_response", {
|
|
3498
|
+
slug,
|
|
3499
|
+
branch: "link",
|
|
3500
|
+
documentId: existingDocumentId,
|
|
3501
|
+
ok: false,
|
|
3502
|
+
embeddingError: true
|
|
3503
|
+
});
|
|
3504
|
+
return json(
|
|
3505
|
+
{
|
|
3506
|
+
documentId: existingDocumentId,
|
|
3507
|
+
linked: true,
|
|
3508
|
+
created: false,
|
|
3509
|
+
chunkCount: chunkCount + chunksCreated,
|
|
3510
|
+
chunksCreated,
|
|
3511
|
+
embeddingAttempted: true,
|
|
3512
|
+
embeddingsWritten: 0,
|
|
3513
|
+
embeddingsFailed: chunksToEmbed.length,
|
|
3514
|
+
warning: "Document linked; embedding step failed. Fix LLM/embed config and attach again (or unlink and re-attach) to retry NULL embeddings.",
|
|
3515
|
+
detail: embedResult2.embedError
|
|
3516
|
+
},
|
|
3517
|
+
{ status: 201 }
|
|
3518
|
+
);
|
|
3519
|
+
}
|
|
3520
|
+
logKbPipeline("11_response", {
|
|
3521
|
+
slug,
|
|
3522
|
+
branch: "link",
|
|
3523
|
+
documentId: existingDocumentId,
|
|
3524
|
+
ok: true,
|
|
3525
|
+
chunkCount: chunkCount + chunksCreated,
|
|
3526
|
+
chunksCreated,
|
|
3527
|
+
chunksQueuedForEmbedding: chunksToEmbed.length,
|
|
3528
|
+
embeddingsWritten: embedResult2.embeddingsWritten,
|
|
3529
|
+
embeddingsFailed: embedResult2.embeddingsFailed
|
|
3530
|
+
});
|
|
3531
|
+
return json({
|
|
3532
|
+
documentId: existingDocumentId,
|
|
3533
|
+
linked: true,
|
|
3534
|
+
created: false,
|
|
3535
|
+
chunkCount: chunkCount + chunksCreated,
|
|
3536
|
+
chunksCreated: chunksCreated || void 0,
|
|
3537
|
+
chunksQueuedForEmbedding: chunksToEmbed.length,
|
|
3538
|
+
embeddingAttempted: chunksToEmbed.length > 0,
|
|
3539
|
+
embeddingsWritten: embedResult2.embeddingsWritten,
|
|
3540
|
+
embeddingsFailed: embedResult2.embeddingsFailed
|
|
3541
|
+
});
|
|
3542
|
+
}
|
|
3543
|
+
logKbPipeline("05_branch", { slug, branch: "new_upload_ingest" });
|
|
3544
|
+
if (!text) return json({ error: "text or file with text content is required" }, { status: 400 });
|
|
3545
|
+
if (!name) name = "Untitled";
|
|
3546
|
+
const parts = splitIntoChunks(text, INGEST_CHUNK_CHARS);
|
|
3547
|
+
if (parts.length === 0) {
|
|
3548
|
+
return json({ error: "text or file with text content is required" }, { status: 400 });
|
|
3549
|
+
}
|
|
3550
|
+
if (parts.length > MAX_CHUNKS_PER_UPLOAD) {
|
|
3551
|
+
return json(
|
|
3552
|
+
{
|
|
3553
|
+
error: `Document is too large for one upload (${parts.length} chunks; max ${MAX_CHUNKS_PER_UPLOAD}). Split into smaller files.`
|
|
3554
|
+
},
|
|
3555
|
+
{ status: 413 }
|
|
3556
|
+
);
|
|
3557
|
+
}
|
|
3558
|
+
logKbPipeline("07_chunk_split", {
|
|
3559
|
+
slug,
|
|
3560
|
+
partCount: parts.length,
|
|
3561
|
+
maxChunkChars: INGEST_CHUNK_CHARS,
|
|
3562
|
+
totalChars: text.length,
|
|
3563
|
+
documentName: name
|
|
3564
|
+
});
|
|
3565
|
+
const docRepo = dataSource.getRepository(kbDoc);
|
|
3566
|
+
const chunkRepo = dataSource.getRepository(kbChunk);
|
|
3567
|
+
const now = /* @__PURE__ */ new Date();
|
|
3568
|
+
const doc = await docRepo.save(
|
|
3569
|
+
docRepo.create({ name, content: text, sourceUrl, createdAt: now, updatedAt: now })
|
|
3570
|
+
);
|
|
3571
|
+
const docId = doc.id;
|
|
3572
|
+
logKbPipeline("06_knowledge_document_saved", {
|
|
3573
|
+
slug,
|
|
3574
|
+
documentId: docId,
|
|
3575
|
+
name,
|
|
3576
|
+
contentChars: text.length,
|
|
3577
|
+
hasSourceUrl: !!sourceUrl
|
|
3578
|
+
});
|
|
3579
|
+
const chunkRows = parts.map(
|
|
3580
|
+
(content, i) => chunkRepo.create({ documentId: docId, content, chunkIndex: i, createdAt: now })
|
|
3581
|
+
);
|
|
3582
|
+
const savedList = await chunkRepo.save(chunkRows);
|
|
3583
|
+
const savedChunks = savedList.map(
|
|
3584
|
+
(row, i) => ({
|
|
3585
|
+
id: row.id,
|
|
3586
|
+
content: parts[i]
|
|
3587
|
+
})
|
|
3588
|
+
);
|
|
3589
|
+
logKbPipeline("07b_chunks_persisted", {
|
|
3590
|
+
slug,
|
|
3591
|
+
documentId: docId,
|
|
3592
|
+
rowsInserted: savedChunks.length,
|
|
3593
|
+
firstChunkId: savedChunks[0]?.id,
|
|
3594
|
+
lastChunkId: savedChunks[savedChunks.length - 1]?.id
|
|
3595
|
+
});
|
|
3596
|
+
const dup = await linkRepo.findOne({ where: { agentId: agent.id, documentId: docId } });
|
|
3597
|
+
if (!dup) {
|
|
3598
|
+
await linkRepo.save(linkRepo.create({ agentId: agent.id, documentId: docId }));
|
|
3599
|
+
logKbPipeline("06c_junction_link_created", { slug, agentId: agent.id, documentId: docId });
|
|
3600
|
+
} else {
|
|
3601
|
+
logKbPipeline("06c_junction_link_exists", { slug, agentId: agent.id, documentId: docId });
|
|
3602
|
+
}
|
|
3603
|
+
const embedResult = await runEmbeddingPass(slug, savedChunks);
|
|
3604
|
+
if (embedResult.embedError) {
|
|
3605
|
+
logKbPipeline("11_response", {
|
|
3606
|
+
slug,
|
|
3607
|
+
branch: "ingest",
|
|
3608
|
+
documentId: docId,
|
|
3609
|
+
ok: false,
|
|
3610
|
+
embeddingError: true
|
|
3611
|
+
});
|
|
3612
|
+
return json(
|
|
3613
|
+
{
|
|
3614
|
+
documentId: docId,
|
|
3615
|
+
chunkCount: savedChunks.length,
|
|
3616
|
+
embeddingAttempted: true,
|
|
3617
|
+
created: true,
|
|
3618
|
+
linked: true,
|
|
3619
|
+
embeddingsWritten: 0,
|
|
3620
|
+
embeddingsFailed: savedChunks.length,
|
|
3621
|
+
warning: "Document saved and linked; embedding step failed.",
|
|
3622
|
+
detail: embedResult.embedError
|
|
3623
|
+
},
|
|
3624
|
+
{ status: 201 }
|
|
3625
|
+
);
|
|
3626
|
+
}
|
|
3627
|
+
logKbPipeline("11_response", {
|
|
3628
|
+
slug,
|
|
3629
|
+
branch: "ingest",
|
|
3630
|
+
documentId: docId,
|
|
3631
|
+
ok: true,
|
|
3632
|
+
chunkCount: savedChunks.length,
|
|
3633
|
+
embeddingsWritten: embedResult.embeddingsWritten,
|
|
3634
|
+
embeddingsFailed: embedResult.embeddingsFailed
|
|
3635
|
+
});
|
|
3636
|
+
return json({
|
|
3637
|
+
documentId: docId,
|
|
3638
|
+
chunkCount: savedChunks.length,
|
|
3639
|
+
embeddingAttempted: savedChunks.length > 0,
|
|
3640
|
+
created: true,
|
|
3641
|
+
linked: true,
|
|
3642
|
+
embeddingsWritten: embedResult.embeddingsWritten,
|
|
3643
|
+
embeddingsFailed: embedResult.embeddingsFailed
|
|
3644
|
+
});
|
|
3645
|
+
} catch (err) {
|
|
3646
|
+
const msg = err instanceof Error ? err.message : "Failed to ingest knowledge";
|
|
3647
|
+
const name = err instanceof Error ? err.name : "";
|
|
3648
|
+
logKbPipeline("99_pipeline_error", { slug, errorName: name, message: msg });
|
|
3649
|
+
return json({ error: msg, errorName: name || void 0 }, { status: 500 });
|
|
3650
|
+
}
|
|
3651
|
+
},
|
|
3652
|
+
async unlink(req, slug, documentIdStr) {
|
|
3653
|
+
const denied = await gate(req, "update");
|
|
3654
|
+
if (denied) return denied;
|
|
3655
|
+
const documentId = parseInt(documentIdStr, 10);
|
|
3656
|
+
if (!Number.isFinite(documentId)) return json({ error: "Invalid document id" }, { status: 400 });
|
|
3657
|
+
try {
|
|
3658
|
+
const agent = await findAgentBySlug(dataSource, llmAgents, slug);
|
|
3659
|
+
if (!agent) return json({ error: "Agent not found" }, { status: 404 });
|
|
3660
|
+
logKbPipeline("unlink_junction", { slug, agentId: agent.id, documentId });
|
|
3661
|
+
const linkRepo = dataSource.getRepository(junction);
|
|
3662
|
+
await linkRepo.delete({ agentId: agent.id, documentId });
|
|
3663
|
+
return json({ ok: true });
|
|
3664
|
+
} catch (err) {
|
|
3665
|
+
const msg = err instanceof Error ? err.message : "Failed to unlink";
|
|
3666
|
+
return json({ error: msg }, { status: 500 });
|
|
3667
|
+
}
|
|
3668
|
+
}
|
|
3669
|
+
};
|
|
3670
|
+
}
|
|
3671
|
+
|
|
2730
3672
|
// src/message-templates/sms-defaults.ts
|
|
2731
3673
|
var SMS_MESSAGE_TEMPLATE_DEFAULTS = [
|
|
2732
3674
|
{
|
|
@@ -3034,7 +3976,2632 @@ function createAdminRolesHandlers(config) {
|
|
|
3034
3976
|
};
|
|
3035
3977
|
}
|
|
3036
3978
|
|
|
3979
|
+
// src/entities/user.entity.ts
|
|
3980
|
+
import { Entity as Entity4, PrimaryGeneratedColumn as PrimaryGeneratedColumn4, Column as Column4, ManyToOne as ManyToOne2, JoinColumn as JoinColumn2 } from "typeorm";
|
|
3981
|
+
|
|
3982
|
+
// src/entities/user-group.entity.ts
|
|
3983
|
+
import { Entity as Entity3, PrimaryGeneratedColumn as PrimaryGeneratedColumn3, Column as Column3, OneToMany } from "typeorm";
|
|
3984
|
+
|
|
3985
|
+
// src/entities/permission.entity.ts
|
|
3986
|
+
import { Entity as Entity2, PrimaryGeneratedColumn as PrimaryGeneratedColumn2, Column as Column2, ManyToOne, JoinColumn } from "typeorm";
|
|
3987
|
+
var Permission = class {
|
|
3988
|
+
id;
|
|
3989
|
+
groupId;
|
|
3990
|
+
entity;
|
|
3991
|
+
canCreate;
|
|
3992
|
+
canRead;
|
|
3993
|
+
canUpdate;
|
|
3994
|
+
canDelete;
|
|
3995
|
+
createdAt;
|
|
3996
|
+
updatedAt;
|
|
3997
|
+
deletedAt;
|
|
3998
|
+
deleted;
|
|
3999
|
+
createdBy;
|
|
4000
|
+
updatedBy;
|
|
4001
|
+
deletedBy;
|
|
4002
|
+
group;
|
|
4003
|
+
};
|
|
4004
|
+
__decorateClass([
|
|
4005
|
+
PrimaryGeneratedColumn2()
|
|
4006
|
+
], Permission.prototype, "id", 2);
|
|
4007
|
+
__decorateClass([
|
|
4008
|
+
Column2("int")
|
|
4009
|
+
], Permission.prototype, "groupId", 2);
|
|
4010
|
+
__decorateClass([
|
|
4011
|
+
Column2("varchar")
|
|
4012
|
+
], Permission.prototype, "entity", 2);
|
|
4013
|
+
__decorateClass([
|
|
4014
|
+
Column2("boolean", { default: false })
|
|
4015
|
+
], Permission.prototype, "canCreate", 2);
|
|
4016
|
+
__decorateClass([
|
|
4017
|
+
Column2("boolean", { default: false })
|
|
4018
|
+
], Permission.prototype, "canRead", 2);
|
|
4019
|
+
__decorateClass([
|
|
4020
|
+
Column2("boolean", { default: false })
|
|
4021
|
+
], Permission.prototype, "canUpdate", 2);
|
|
4022
|
+
__decorateClass([
|
|
4023
|
+
Column2("boolean", { default: false })
|
|
4024
|
+
], Permission.prototype, "canDelete", 2);
|
|
4025
|
+
__decorateClass([
|
|
4026
|
+
Column2({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4027
|
+
], Permission.prototype, "createdAt", 2);
|
|
4028
|
+
__decorateClass([
|
|
4029
|
+
Column2({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4030
|
+
], Permission.prototype, "updatedAt", 2);
|
|
4031
|
+
__decorateClass([
|
|
4032
|
+
Column2({ type: "timestamp", nullable: true })
|
|
4033
|
+
], Permission.prototype, "deletedAt", 2);
|
|
4034
|
+
__decorateClass([
|
|
4035
|
+
Column2("boolean", { default: false })
|
|
4036
|
+
], Permission.prototype, "deleted", 2);
|
|
4037
|
+
__decorateClass([
|
|
4038
|
+
Column2("int", { nullable: true })
|
|
4039
|
+
], Permission.prototype, "createdBy", 2);
|
|
4040
|
+
__decorateClass([
|
|
4041
|
+
Column2("int", { nullable: true })
|
|
4042
|
+
], Permission.prototype, "updatedBy", 2);
|
|
4043
|
+
__decorateClass([
|
|
4044
|
+
Column2("int", { nullable: true })
|
|
4045
|
+
], Permission.prototype, "deletedBy", 2);
|
|
4046
|
+
__decorateClass([
|
|
4047
|
+
ManyToOne(() => UserGroup, (g) => g.permissions, { onDelete: "CASCADE" }),
|
|
4048
|
+
JoinColumn({ name: "groupId" })
|
|
4049
|
+
], Permission.prototype, "group", 2);
|
|
4050
|
+
Permission = __decorateClass([
|
|
4051
|
+
Entity2("permissions")
|
|
4052
|
+
], Permission);
|
|
4053
|
+
|
|
4054
|
+
// src/entities/user-group.entity.ts
|
|
4055
|
+
var UserGroup = class {
|
|
4056
|
+
id;
|
|
4057
|
+
name;
|
|
4058
|
+
createdAt;
|
|
4059
|
+
updatedAt;
|
|
4060
|
+
deletedAt;
|
|
4061
|
+
deleted;
|
|
4062
|
+
createdBy;
|
|
4063
|
+
updatedBy;
|
|
4064
|
+
deletedBy;
|
|
4065
|
+
permissions;
|
|
4066
|
+
users;
|
|
4067
|
+
};
|
|
4068
|
+
__decorateClass([
|
|
4069
|
+
PrimaryGeneratedColumn3()
|
|
4070
|
+
], UserGroup.prototype, "id", 2);
|
|
4071
|
+
__decorateClass([
|
|
4072
|
+
Column3("varchar", { unique: true })
|
|
4073
|
+
], UserGroup.prototype, "name", 2);
|
|
4074
|
+
__decorateClass([
|
|
4075
|
+
Column3({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4076
|
+
], UserGroup.prototype, "createdAt", 2);
|
|
4077
|
+
__decorateClass([
|
|
4078
|
+
Column3({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4079
|
+
], UserGroup.prototype, "updatedAt", 2);
|
|
4080
|
+
__decorateClass([
|
|
4081
|
+
Column3({ type: "timestamp", nullable: true })
|
|
4082
|
+
], UserGroup.prototype, "deletedAt", 2);
|
|
4083
|
+
__decorateClass([
|
|
4084
|
+
Column3("boolean", { default: false })
|
|
4085
|
+
], UserGroup.prototype, "deleted", 2);
|
|
4086
|
+
__decorateClass([
|
|
4087
|
+
Column3("int", { nullable: true })
|
|
4088
|
+
], UserGroup.prototype, "createdBy", 2);
|
|
4089
|
+
__decorateClass([
|
|
4090
|
+
Column3("int", { nullable: true })
|
|
4091
|
+
], UserGroup.prototype, "updatedBy", 2);
|
|
4092
|
+
__decorateClass([
|
|
4093
|
+
Column3("int", { nullable: true })
|
|
4094
|
+
], UserGroup.prototype, "deletedBy", 2);
|
|
4095
|
+
__decorateClass([
|
|
4096
|
+
OneToMany(() => Permission, (p) => p.group)
|
|
4097
|
+
], UserGroup.prototype, "permissions", 2);
|
|
4098
|
+
__decorateClass([
|
|
4099
|
+
OneToMany(() => User, (u) => u.group)
|
|
4100
|
+
], UserGroup.prototype, "users", 2);
|
|
4101
|
+
UserGroup = __decorateClass([
|
|
4102
|
+
Entity3("user_groups")
|
|
4103
|
+
], UserGroup);
|
|
4104
|
+
|
|
4105
|
+
// src/entities/user.entity.ts
|
|
4106
|
+
var User = class {
|
|
4107
|
+
id;
|
|
4108
|
+
name;
|
|
4109
|
+
email;
|
|
4110
|
+
phone;
|
|
4111
|
+
phoneVerifiedAt;
|
|
4112
|
+
emailVerifiedAt;
|
|
4113
|
+
password;
|
|
4114
|
+
blocked;
|
|
4115
|
+
adminAccess;
|
|
4116
|
+
groupId;
|
|
4117
|
+
createdAt;
|
|
4118
|
+
updatedAt;
|
|
4119
|
+
deletedAt;
|
|
4120
|
+
deleted;
|
|
4121
|
+
createdBy;
|
|
4122
|
+
updatedBy;
|
|
4123
|
+
deletedBy;
|
|
4124
|
+
group;
|
|
4125
|
+
};
|
|
4126
|
+
__decorateClass([
|
|
4127
|
+
PrimaryGeneratedColumn4()
|
|
4128
|
+
], User.prototype, "id", 2);
|
|
4129
|
+
__decorateClass([
|
|
4130
|
+
Column4("varchar")
|
|
4131
|
+
], User.prototype, "name", 2);
|
|
4132
|
+
__decorateClass([
|
|
4133
|
+
Column4("varchar", { unique: true })
|
|
4134
|
+
], User.prototype, "email", 2);
|
|
4135
|
+
__decorateClass([
|
|
4136
|
+
Column4("varchar", { nullable: true })
|
|
4137
|
+
], User.prototype, "phone", 2);
|
|
4138
|
+
__decorateClass([
|
|
4139
|
+
Column4({ type: "timestamp", nullable: true })
|
|
4140
|
+
], User.prototype, "phoneVerifiedAt", 2);
|
|
4141
|
+
__decorateClass([
|
|
4142
|
+
Column4({ type: "timestamp", nullable: true })
|
|
4143
|
+
], User.prototype, "emailVerifiedAt", 2);
|
|
4144
|
+
__decorateClass([
|
|
4145
|
+
Column4("varchar", { nullable: true })
|
|
4146
|
+
], User.prototype, "password", 2);
|
|
4147
|
+
__decorateClass([
|
|
4148
|
+
Column4("boolean", { default: false })
|
|
4149
|
+
], User.prototype, "blocked", 2);
|
|
4150
|
+
__decorateClass([
|
|
4151
|
+
Column4("boolean", { default: false })
|
|
4152
|
+
], User.prototype, "adminAccess", 2);
|
|
4153
|
+
__decorateClass([
|
|
4154
|
+
Column4("int", { nullable: true })
|
|
4155
|
+
], User.prototype, "groupId", 2);
|
|
4156
|
+
__decorateClass([
|
|
4157
|
+
Column4({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4158
|
+
], User.prototype, "createdAt", 2);
|
|
4159
|
+
__decorateClass([
|
|
4160
|
+
Column4({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4161
|
+
], User.prototype, "updatedAt", 2);
|
|
4162
|
+
__decorateClass([
|
|
4163
|
+
Column4({ type: "timestamp", nullable: true })
|
|
4164
|
+
], User.prototype, "deletedAt", 2);
|
|
4165
|
+
__decorateClass([
|
|
4166
|
+
Column4("boolean", { default: false })
|
|
4167
|
+
], User.prototype, "deleted", 2);
|
|
4168
|
+
__decorateClass([
|
|
4169
|
+
Column4("int", { nullable: true })
|
|
4170
|
+
], User.prototype, "createdBy", 2);
|
|
4171
|
+
__decorateClass([
|
|
4172
|
+
Column4("int", { nullable: true })
|
|
4173
|
+
], User.prototype, "updatedBy", 2);
|
|
4174
|
+
__decorateClass([
|
|
4175
|
+
Column4("int", { nullable: true })
|
|
4176
|
+
], User.prototype, "deletedBy", 2);
|
|
4177
|
+
__decorateClass([
|
|
4178
|
+
ManyToOne2(() => UserGroup, (g) => g.users, { onDelete: "SET NULL" }),
|
|
4179
|
+
JoinColumn2({ name: "groupId" })
|
|
4180
|
+
], User.prototype, "group", 2);
|
|
4181
|
+
User = __decorateClass([
|
|
4182
|
+
Entity4("users")
|
|
4183
|
+
], User);
|
|
4184
|
+
|
|
4185
|
+
// src/entities/otp-challenge.entity.ts
|
|
4186
|
+
import { Entity as Entity5, PrimaryGeneratedColumn as PrimaryGeneratedColumn5, Column as Column5, Index } from "typeorm";
|
|
4187
|
+
var OtpChallenge = class {
|
|
4188
|
+
id;
|
|
4189
|
+
purpose;
|
|
4190
|
+
channel;
|
|
4191
|
+
identifier;
|
|
4192
|
+
codeHash;
|
|
4193
|
+
expiresAt;
|
|
4194
|
+
attempts;
|
|
4195
|
+
consumedAt;
|
|
4196
|
+
createdAt;
|
|
4197
|
+
};
|
|
4198
|
+
__decorateClass([
|
|
4199
|
+
PrimaryGeneratedColumn5()
|
|
4200
|
+
], OtpChallenge.prototype, "id", 2);
|
|
4201
|
+
__decorateClass([
|
|
4202
|
+
Column5("varchar")
|
|
4203
|
+
], OtpChallenge.prototype, "purpose", 2);
|
|
4204
|
+
__decorateClass([
|
|
4205
|
+
Column5("varchar")
|
|
4206
|
+
], OtpChallenge.prototype, "channel", 2);
|
|
4207
|
+
__decorateClass([
|
|
4208
|
+
Column5("varchar")
|
|
4209
|
+
], OtpChallenge.prototype, "identifier", 2);
|
|
4210
|
+
__decorateClass([
|
|
4211
|
+
Column5("varchar")
|
|
4212
|
+
], OtpChallenge.prototype, "codeHash", 2);
|
|
4213
|
+
__decorateClass([
|
|
4214
|
+
Column5({ type: "timestamp" })
|
|
4215
|
+
], OtpChallenge.prototype, "expiresAt", 2);
|
|
4216
|
+
__decorateClass([
|
|
4217
|
+
Column5("int", { default: 0 })
|
|
4218
|
+
], OtpChallenge.prototype, "attempts", 2);
|
|
4219
|
+
__decorateClass([
|
|
4220
|
+
Column5({ type: "timestamp", nullable: true })
|
|
4221
|
+
], OtpChallenge.prototype, "consumedAt", 2);
|
|
4222
|
+
__decorateClass([
|
|
4223
|
+
Column5({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4224
|
+
], OtpChallenge.prototype, "createdAt", 2);
|
|
4225
|
+
OtpChallenge = __decorateClass([
|
|
4226
|
+
Entity5("otp_challenges"),
|
|
4227
|
+
Index(["purpose", "identifier"])
|
|
4228
|
+
], OtpChallenge);
|
|
4229
|
+
|
|
4230
|
+
// src/entities/password-reset-token.entity.ts
|
|
4231
|
+
import { Entity as Entity6, PrimaryGeneratedColumn as PrimaryGeneratedColumn6, Column as Column6 } from "typeorm";
|
|
4232
|
+
var PasswordResetToken = class {
|
|
4233
|
+
id;
|
|
4234
|
+
email;
|
|
4235
|
+
token;
|
|
4236
|
+
expiresAt;
|
|
4237
|
+
createdAt;
|
|
4238
|
+
};
|
|
4239
|
+
__decorateClass([
|
|
4240
|
+
PrimaryGeneratedColumn6()
|
|
4241
|
+
], PasswordResetToken.prototype, "id", 2);
|
|
4242
|
+
__decorateClass([
|
|
4243
|
+
Column6("varchar")
|
|
4244
|
+
], PasswordResetToken.prototype, "email", 2);
|
|
4245
|
+
__decorateClass([
|
|
4246
|
+
Column6("varchar", { unique: true })
|
|
4247
|
+
], PasswordResetToken.prototype, "token", 2);
|
|
4248
|
+
__decorateClass([
|
|
4249
|
+
Column6({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4250
|
+
], PasswordResetToken.prototype, "expiresAt", 2);
|
|
4251
|
+
__decorateClass([
|
|
4252
|
+
Column6({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4253
|
+
], PasswordResetToken.prototype, "createdAt", 2);
|
|
4254
|
+
PasswordResetToken = __decorateClass([
|
|
4255
|
+
Entity6("password_reset_tokens")
|
|
4256
|
+
], PasswordResetToken);
|
|
4257
|
+
|
|
4258
|
+
// src/entities/blog.entity.ts
|
|
4259
|
+
import {
|
|
4260
|
+
Entity as Entity11,
|
|
4261
|
+
PrimaryGeneratedColumn as PrimaryGeneratedColumn11,
|
|
4262
|
+
Column as Column11,
|
|
4263
|
+
ManyToOne as ManyToOne4,
|
|
4264
|
+
OneToMany as OneToMany4,
|
|
4265
|
+
ManyToMany as ManyToMany2,
|
|
4266
|
+
JoinTable,
|
|
4267
|
+
JoinColumn as JoinColumn4
|
|
4268
|
+
} from "typeorm";
|
|
4269
|
+
|
|
4270
|
+
// src/entities/category.entity.ts
|
|
4271
|
+
import { Entity as Entity7, PrimaryGeneratedColumn as PrimaryGeneratedColumn7, Column as Column7, OneToMany as OneToMany2 } from "typeorm";
|
|
4272
|
+
var Category = class {
|
|
4273
|
+
id;
|
|
4274
|
+
name;
|
|
4275
|
+
createdAt;
|
|
4276
|
+
updatedAt;
|
|
4277
|
+
deletedAt;
|
|
4278
|
+
deleted;
|
|
4279
|
+
createdBy;
|
|
4280
|
+
updatedBy;
|
|
4281
|
+
deletedBy;
|
|
4282
|
+
blogs;
|
|
4283
|
+
};
|
|
4284
|
+
__decorateClass([
|
|
4285
|
+
PrimaryGeneratedColumn7()
|
|
4286
|
+
], Category.prototype, "id", 2);
|
|
4287
|
+
__decorateClass([
|
|
4288
|
+
Column7("varchar", { unique: true })
|
|
4289
|
+
], Category.prototype, "name", 2);
|
|
4290
|
+
__decorateClass([
|
|
4291
|
+
Column7({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4292
|
+
], Category.prototype, "createdAt", 2);
|
|
4293
|
+
__decorateClass([
|
|
4294
|
+
Column7({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4295
|
+
], Category.prototype, "updatedAt", 2);
|
|
4296
|
+
__decorateClass([
|
|
4297
|
+
Column7({ type: "timestamp", nullable: true })
|
|
4298
|
+
], Category.prototype, "deletedAt", 2);
|
|
4299
|
+
__decorateClass([
|
|
4300
|
+
Column7("boolean", { default: false })
|
|
4301
|
+
], Category.prototype, "deleted", 2);
|
|
4302
|
+
__decorateClass([
|
|
4303
|
+
Column7("int", { nullable: true })
|
|
4304
|
+
], Category.prototype, "createdBy", 2);
|
|
4305
|
+
__decorateClass([
|
|
4306
|
+
Column7("int", { nullable: true })
|
|
4307
|
+
], Category.prototype, "updatedBy", 2);
|
|
4308
|
+
__decorateClass([
|
|
4309
|
+
Column7("int", { nullable: true })
|
|
4310
|
+
], Category.prototype, "deletedBy", 2);
|
|
4311
|
+
__decorateClass([
|
|
4312
|
+
OneToMany2("Blog", "category")
|
|
4313
|
+
], Category.prototype, "blogs", 2);
|
|
4314
|
+
Category = __decorateClass([
|
|
4315
|
+
Entity7("categories")
|
|
4316
|
+
], Category);
|
|
4317
|
+
|
|
4318
|
+
// src/entities/seo.entity.ts
|
|
4319
|
+
import { Entity as Entity8, PrimaryGeneratedColumn as PrimaryGeneratedColumn8, Column as Column8, OneToMany as OneToMany3 } from "typeorm";
|
|
4320
|
+
var Seo = class {
|
|
4321
|
+
id;
|
|
4322
|
+
title;
|
|
4323
|
+
description;
|
|
4324
|
+
keywords;
|
|
4325
|
+
ogTitle;
|
|
4326
|
+
ogDescription;
|
|
4327
|
+
ogImage;
|
|
4328
|
+
slug;
|
|
4329
|
+
createdAt;
|
|
4330
|
+
updatedAt;
|
|
4331
|
+
deletedAt;
|
|
4332
|
+
deleted;
|
|
4333
|
+
createdBy;
|
|
4334
|
+
updatedBy;
|
|
4335
|
+
deletedBy;
|
|
4336
|
+
blogs;
|
|
4337
|
+
};
|
|
4338
|
+
__decorateClass([
|
|
4339
|
+
PrimaryGeneratedColumn8()
|
|
4340
|
+
], Seo.prototype, "id", 2);
|
|
4341
|
+
__decorateClass([
|
|
4342
|
+
Column8("varchar", { nullable: true })
|
|
4343
|
+
], Seo.prototype, "title", 2);
|
|
4344
|
+
__decorateClass([
|
|
4345
|
+
Column8("varchar", { nullable: true })
|
|
4346
|
+
], Seo.prototype, "description", 2);
|
|
4347
|
+
__decorateClass([
|
|
4348
|
+
Column8("varchar", { nullable: true })
|
|
4349
|
+
], Seo.prototype, "keywords", 2);
|
|
4350
|
+
__decorateClass([
|
|
4351
|
+
Column8("varchar", { nullable: true })
|
|
4352
|
+
], Seo.prototype, "ogTitle", 2);
|
|
4353
|
+
__decorateClass([
|
|
4354
|
+
Column8("varchar", { nullable: true })
|
|
4355
|
+
], Seo.prototype, "ogDescription", 2);
|
|
4356
|
+
__decorateClass([
|
|
4357
|
+
Column8("varchar", { nullable: true })
|
|
4358
|
+
], Seo.prototype, "ogImage", 2);
|
|
4359
|
+
__decorateClass([
|
|
4360
|
+
Column8("varchar", { unique: true })
|
|
4361
|
+
], Seo.prototype, "slug", 2);
|
|
4362
|
+
__decorateClass([
|
|
4363
|
+
Column8({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4364
|
+
], Seo.prototype, "createdAt", 2);
|
|
4365
|
+
__decorateClass([
|
|
4366
|
+
Column8({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4367
|
+
], Seo.prototype, "updatedAt", 2);
|
|
4368
|
+
__decorateClass([
|
|
4369
|
+
Column8({ type: "timestamp", nullable: true })
|
|
4370
|
+
], Seo.prototype, "deletedAt", 2);
|
|
4371
|
+
__decorateClass([
|
|
4372
|
+
Column8("boolean", { default: false })
|
|
4373
|
+
], Seo.prototype, "deleted", 2);
|
|
4374
|
+
__decorateClass([
|
|
4375
|
+
Column8("int", { nullable: true })
|
|
4376
|
+
], Seo.prototype, "createdBy", 2);
|
|
4377
|
+
__decorateClass([
|
|
4378
|
+
Column8("int", { nullable: true })
|
|
4379
|
+
], Seo.prototype, "updatedBy", 2);
|
|
4380
|
+
__decorateClass([
|
|
4381
|
+
Column8("int", { nullable: true })
|
|
4382
|
+
], Seo.prototype, "deletedBy", 2);
|
|
4383
|
+
__decorateClass([
|
|
4384
|
+
OneToMany3(() => Blog, (blog) => blog.seo)
|
|
4385
|
+
], Seo.prototype, "blogs", 2);
|
|
4386
|
+
Seo = __decorateClass([
|
|
4387
|
+
Entity8("seos")
|
|
4388
|
+
], Seo);
|
|
4389
|
+
|
|
4390
|
+
// src/entities/comment.entity.ts
|
|
4391
|
+
import { Entity as Entity9, PrimaryGeneratedColumn as PrimaryGeneratedColumn9, Column as Column9, ManyToOne as ManyToOne3, JoinColumn as JoinColumn3 } from "typeorm";
|
|
4392
|
+
var Comment = class {
|
|
4393
|
+
id;
|
|
4394
|
+
content;
|
|
4395
|
+
blogId;
|
|
4396
|
+
authorId;
|
|
4397
|
+
createdAt;
|
|
4398
|
+
updatedAt;
|
|
4399
|
+
deletedAt;
|
|
4400
|
+
deleted;
|
|
4401
|
+
createdBy;
|
|
4402
|
+
updatedBy;
|
|
4403
|
+
deletedBy;
|
|
4404
|
+
author;
|
|
4405
|
+
blog;
|
|
4406
|
+
};
|
|
4407
|
+
__decorateClass([
|
|
4408
|
+
PrimaryGeneratedColumn9()
|
|
4409
|
+
], Comment.prototype, "id", 2);
|
|
4410
|
+
__decorateClass([
|
|
4411
|
+
Column9("text")
|
|
4412
|
+
], Comment.prototype, "content", 2);
|
|
4413
|
+
__decorateClass([
|
|
4414
|
+
Column9("int")
|
|
4415
|
+
], Comment.prototype, "blogId", 2);
|
|
4416
|
+
__decorateClass([
|
|
4417
|
+
Column9("int")
|
|
4418
|
+
], Comment.prototype, "authorId", 2);
|
|
4419
|
+
__decorateClass([
|
|
4420
|
+
Column9({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4421
|
+
], Comment.prototype, "createdAt", 2);
|
|
4422
|
+
__decorateClass([
|
|
4423
|
+
Column9({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4424
|
+
], Comment.prototype, "updatedAt", 2);
|
|
4425
|
+
__decorateClass([
|
|
4426
|
+
Column9({ type: "timestamp", nullable: true })
|
|
4427
|
+
], Comment.prototype, "deletedAt", 2);
|
|
4428
|
+
__decorateClass([
|
|
4429
|
+
Column9("boolean", { default: false })
|
|
4430
|
+
], Comment.prototype, "deleted", 2);
|
|
4431
|
+
__decorateClass([
|
|
4432
|
+
Column9("int", { nullable: true })
|
|
4433
|
+
], Comment.prototype, "createdBy", 2);
|
|
4434
|
+
__decorateClass([
|
|
4435
|
+
Column9("int", { nullable: true })
|
|
4436
|
+
], Comment.prototype, "updatedBy", 2);
|
|
4437
|
+
__decorateClass([
|
|
4438
|
+
Column9("int", { nullable: true })
|
|
4439
|
+
], Comment.prototype, "deletedBy", 2);
|
|
4440
|
+
__decorateClass([
|
|
4441
|
+
ManyToOne3(() => User, { onDelete: "CASCADE" }),
|
|
4442
|
+
JoinColumn3({ name: "authorId" })
|
|
4443
|
+
], Comment.prototype, "author", 2);
|
|
4444
|
+
__decorateClass([
|
|
4445
|
+
ManyToOne3(() => Blog, (b) => b.comments, { onDelete: "CASCADE" }),
|
|
4446
|
+
JoinColumn3({ name: "blogId" })
|
|
4447
|
+
], Comment.prototype, "blog", 2);
|
|
4448
|
+
Comment = __decorateClass([
|
|
4449
|
+
Entity9("comments")
|
|
4450
|
+
], Comment);
|
|
4451
|
+
|
|
4452
|
+
// src/entities/tag.entity.ts
|
|
4453
|
+
import { Entity as Entity10, PrimaryGeneratedColumn as PrimaryGeneratedColumn10, Column as Column10, ManyToMany } from "typeorm";
|
|
4454
|
+
var Tag = class {
|
|
4455
|
+
id;
|
|
4456
|
+
name;
|
|
4457
|
+
createdAt;
|
|
4458
|
+
updatedAt;
|
|
4459
|
+
deletedAt;
|
|
4460
|
+
deleted;
|
|
4461
|
+
createdBy;
|
|
4462
|
+
updatedBy;
|
|
4463
|
+
deletedBy;
|
|
4464
|
+
blogs;
|
|
4465
|
+
};
|
|
4466
|
+
__decorateClass([
|
|
4467
|
+
PrimaryGeneratedColumn10()
|
|
4468
|
+
], Tag.prototype, "id", 2);
|
|
4469
|
+
__decorateClass([
|
|
4470
|
+
Column10("varchar", { unique: true })
|
|
4471
|
+
], Tag.prototype, "name", 2);
|
|
4472
|
+
__decorateClass([
|
|
4473
|
+
Column10({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4474
|
+
], Tag.prototype, "createdAt", 2);
|
|
4475
|
+
__decorateClass([
|
|
4476
|
+
Column10({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4477
|
+
], Tag.prototype, "updatedAt", 2);
|
|
4478
|
+
__decorateClass([
|
|
4479
|
+
Column10({ type: "timestamp", nullable: true })
|
|
4480
|
+
], Tag.prototype, "deletedAt", 2);
|
|
4481
|
+
__decorateClass([
|
|
4482
|
+
Column10("boolean", { default: false })
|
|
4483
|
+
], Tag.prototype, "deleted", 2);
|
|
4484
|
+
__decorateClass([
|
|
4485
|
+
Column10("int", { nullable: true })
|
|
4486
|
+
], Tag.prototype, "createdBy", 2);
|
|
4487
|
+
__decorateClass([
|
|
4488
|
+
Column10("int", { nullable: true })
|
|
4489
|
+
], Tag.prototype, "updatedBy", 2);
|
|
4490
|
+
__decorateClass([
|
|
4491
|
+
Column10("int", { nullable: true })
|
|
4492
|
+
], Tag.prototype, "deletedBy", 2);
|
|
4493
|
+
__decorateClass([
|
|
4494
|
+
ManyToMany(() => Blog, (blog) => blog.tags)
|
|
4495
|
+
], Tag.prototype, "blogs", 2);
|
|
4496
|
+
Tag = __decorateClass([
|
|
4497
|
+
Entity10("tags")
|
|
4498
|
+
], Tag);
|
|
4499
|
+
|
|
4500
|
+
// src/entities/blog.entity.ts
|
|
4501
|
+
var Blog = class {
|
|
4502
|
+
id;
|
|
4503
|
+
title;
|
|
4504
|
+
content;
|
|
4505
|
+
coverImage;
|
|
4506
|
+
authorId;
|
|
4507
|
+
categoryId;
|
|
4508
|
+
seoId;
|
|
4509
|
+
published;
|
|
4510
|
+
createdAt;
|
|
4511
|
+
updatedAt;
|
|
4512
|
+
deletedAt;
|
|
4513
|
+
deleted;
|
|
4514
|
+
createdBy;
|
|
4515
|
+
updatedBy;
|
|
4516
|
+
deletedBy;
|
|
4517
|
+
slug;
|
|
4518
|
+
author;
|
|
4519
|
+
category;
|
|
4520
|
+
seo;
|
|
4521
|
+
comments;
|
|
4522
|
+
tags;
|
|
4523
|
+
};
|
|
4524
|
+
__decorateClass([
|
|
4525
|
+
PrimaryGeneratedColumn11()
|
|
4526
|
+
], Blog.prototype, "id", 2);
|
|
4527
|
+
__decorateClass([
|
|
4528
|
+
Column11("varchar")
|
|
4529
|
+
], Blog.prototype, "title", 2);
|
|
4530
|
+
__decorateClass([
|
|
4531
|
+
Column11("text")
|
|
4532
|
+
], Blog.prototype, "content", 2);
|
|
4533
|
+
__decorateClass([
|
|
4534
|
+
Column11("varchar", { nullable: true })
|
|
4535
|
+
], Blog.prototype, "coverImage", 2);
|
|
4536
|
+
__decorateClass([
|
|
4537
|
+
Column11("int")
|
|
4538
|
+
], Blog.prototype, "authorId", 2);
|
|
4539
|
+
__decorateClass([
|
|
4540
|
+
Column11("int", { nullable: true })
|
|
4541
|
+
], Blog.prototype, "categoryId", 2);
|
|
4542
|
+
__decorateClass([
|
|
4543
|
+
Column11("int", { nullable: true })
|
|
4544
|
+
], Blog.prototype, "seoId", 2);
|
|
4545
|
+
__decorateClass([
|
|
4546
|
+
Column11("boolean", { default: false })
|
|
4547
|
+
], Blog.prototype, "published", 2);
|
|
4548
|
+
__decorateClass([
|
|
4549
|
+
Column11({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4550
|
+
], Blog.prototype, "createdAt", 2);
|
|
4551
|
+
__decorateClass([
|
|
4552
|
+
Column11({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4553
|
+
], Blog.prototype, "updatedAt", 2);
|
|
4554
|
+
__decorateClass([
|
|
4555
|
+
Column11({ type: "timestamp", nullable: true })
|
|
4556
|
+
], Blog.prototype, "deletedAt", 2);
|
|
4557
|
+
__decorateClass([
|
|
4558
|
+
Column11("boolean", { default: false })
|
|
4559
|
+
], Blog.prototype, "deleted", 2);
|
|
4560
|
+
__decorateClass([
|
|
4561
|
+
Column11("int", { nullable: true })
|
|
4562
|
+
], Blog.prototype, "createdBy", 2);
|
|
4563
|
+
__decorateClass([
|
|
4564
|
+
Column11("int", { nullable: true })
|
|
4565
|
+
], Blog.prototype, "updatedBy", 2);
|
|
4566
|
+
__decorateClass([
|
|
4567
|
+
Column11("int", { nullable: true })
|
|
4568
|
+
], Blog.prototype, "deletedBy", 2);
|
|
4569
|
+
__decorateClass([
|
|
4570
|
+
Column11("varchar", { unique: true })
|
|
4571
|
+
], Blog.prototype, "slug", 2);
|
|
4572
|
+
__decorateClass([
|
|
4573
|
+
ManyToOne4(() => User, { onDelete: "CASCADE" }),
|
|
4574
|
+
JoinColumn4({ name: "authorId" })
|
|
4575
|
+
], Blog.prototype, "author", 2);
|
|
4576
|
+
__decorateClass([
|
|
4577
|
+
ManyToOne4(() => Category, (c) => c.blogs, { onDelete: "SET NULL" }),
|
|
4578
|
+
JoinColumn4({ name: "categoryId" })
|
|
4579
|
+
], Blog.prototype, "category", 2);
|
|
4580
|
+
__decorateClass([
|
|
4581
|
+
ManyToOne4(() => Seo, (s) => s.blogs, { onDelete: "SET NULL" }),
|
|
4582
|
+
JoinColumn4({ name: "seoId" })
|
|
4583
|
+
], Blog.prototype, "seo", 2);
|
|
4584
|
+
__decorateClass([
|
|
4585
|
+
OneToMany4(() => Comment, (c) => c.blog)
|
|
4586
|
+
], Blog.prototype, "comments", 2);
|
|
4587
|
+
__decorateClass([
|
|
4588
|
+
ManyToMany2(() => Tag, (t) => t.blogs),
|
|
4589
|
+
JoinTable({
|
|
4590
|
+
name: "blog_tags",
|
|
4591
|
+
joinColumn: { name: "blogId", referencedColumnName: "id" },
|
|
4592
|
+
inverseJoinColumn: { name: "tagId", referencedColumnName: "id" }
|
|
4593
|
+
})
|
|
4594
|
+
], Blog.prototype, "tags", 2);
|
|
4595
|
+
Blog = __decorateClass([
|
|
4596
|
+
Entity11("blogs")
|
|
4597
|
+
], Blog);
|
|
4598
|
+
|
|
4599
|
+
// src/entities/contact.entity.ts
|
|
4600
|
+
import { Entity as Entity20, PrimaryGeneratedColumn as PrimaryGeneratedColumn20, Column as Column20, OneToMany as OneToMany8, ManyToOne as ManyToOne12, JoinColumn as JoinColumn12 } from "typeorm";
|
|
4601
|
+
|
|
4602
|
+
// src/entities/form-submission.entity.ts
|
|
4603
|
+
import { Entity as Entity14, PrimaryGeneratedColumn as PrimaryGeneratedColumn14, Column as Column14, ManyToOne as ManyToOne6, JoinColumn as JoinColumn6 } from "typeorm";
|
|
4604
|
+
|
|
4605
|
+
// src/entities/form.entity.ts
|
|
4606
|
+
import { Entity as Entity13, PrimaryGeneratedColumn as PrimaryGeneratedColumn13, Column as Column13, OneToMany as OneToMany5 } from "typeorm";
|
|
4607
|
+
|
|
4608
|
+
// src/entities/form-field.entity.ts
|
|
4609
|
+
import { Entity as Entity12, PrimaryGeneratedColumn as PrimaryGeneratedColumn12, Column as Column12, ManyToOne as ManyToOne5, JoinColumn as JoinColumn5 } from "typeorm";
|
|
4610
|
+
var FormField = class {
|
|
4611
|
+
id;
|
|
4612
|
+
formId;
|
|
4613
|
+
label;
|
|
4614
|
+
type;
|
|
4615
|
+
placeholder;
|
|
4616
|
+
options;
|
|
4617
|
+
required;
|
|
4618
|
+
validation;
|
|
4619
|
+
order;
|
|
4620
|
+
groupId;
|
|
4621
|
+
columnWidth;
|
|
4622
|
+
createdAt;
|
|
4623
|
+
updatedAt;
|
|
4624
|
+
deletedAt;
|
|
4625
|
+
deleted;
|
|
4626
|
+
createdBy;
|
|
4627
|
+
updatedBy;
|
|
4628
|
+
deletedBy;
|
|
4629
|
+
form;
|
|
4630
|
+
};
|
|
4631
|
+
__decorateClass([
|
|
4632
|
+
PrimaryGeneratedColumn12()
|
|
4633
|
+
], FormField.prototype, "id", 2);
|
|
4634
|
+
__decorateClass([
|
|
4635
|
+
Column12("int")
|
|
4636
|
+
], FormField.prototype, "formId", 2);
|
|
4637
|
+
__decorateClass([
|
|
4638
|
+
Column12("varchar")
|
|
4639
|
+
], FormField.prototype, "label", 2);
|
|
4640
|
+
__decorateClass([
|
|
4641
|
+
Column12("varchar")
|
|
4642
|
+
], FormField.prototype, "type", 2);
|
|
4643
|
+
__decorateClass([
|
|
4644
|
+
Column12("varchar", { nullable: true })
|
|
4645
|
+
], FormField.prototype, "placeholder", 2);
|
|
4646
|
+
__decorateClass([
|
|
4647
|
+
Column12("varchar", { nullable: true })
|
|
4648
|
+
], FormField.prototype, "options", 2);
|
|
4649
|
+
__decorateClass([
|
|
4650
|
+
Column12("boolean", { default: false })
|
|
4651
|
+
], FormField.prototype, "required", 2);
|
|
4652
|
+
__decorateClass([
|
|
4653
|
+
Column12("varchar", { nullable: true })
|
|
4654
|
+
], FormField.prototype, "validation", 2);
|
|
4655
|
+
__decorateClass([
|
|
4656
|
+
Column12("int")
|
|
4657
|
+
], FormField.prototype, "order", 2);
|
|
4658
|
+
__decorateClass([
|
|
4659
|
+
Column12("int", { default: 1 })
|
|
4660
|
+
], FormField.prototype, "groupId", 2);
|
|
4661
|
+
__decorateClass([
|
|
4662
|
+
Column12("int", { default: 12 })
|
|
4663
|
+
], FormField.prototype, "columnWidth", 2);
|
|
4664
|
+
__decorateClass([
|
|
4665
|
+
Column12({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4666
|
+
], FormField.prototype, "createdAt", 2);
|
|
4667
|
+
__decorateClass([
|
|
4668
|
+
Column12({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4669
|
+
], FormField.prototype, "updatedAt", 2);
|
|
4670
|
+
__decorateClass([
|
|
4671
|
+
Column12({ type: "timestamp", nullable: true })
|
|
4672
|
+
], FormField.prototype, "deletedAt", 2);
|
|
4673
|
+
__decorateClass([
|
|
4674
|
+
Column12("boolean", { default: false })
|
|
4675
|
+
], FormField.prototype, "deleted", 2);
|
|
4676
|
+
__decorateClass([
|
|
4677
|
+
Column12("int", { nullable: true })
|
|
4678
|
+
], FormField.prototype, "createdBy", 2);
|
|
4679
|
+
__decorateClass([
|
|
4680
|
+
Column12("int", { nullable: true })
|
|
4681
|
+
], FormField.prototype, "updatedBy", 2);
|
|
4682
|
+
__decorateClass([
|
|
4683
|
+
Column12("int", { nullable: true })
|
|
4684
|
+
], FormField.prototype, "deletedBy", 2);
|
|
4685
|
+
__decorateClass([
|
|
4686
|
+
ManyToOne5(() => Form, (f) => f.fields, { onDelete: "CASCADE" }),
|
|
4687
|
+
JoinColumn5({ name: "formId" })
|
|
4688
|
+
], FormField.prototype, "form", 2);
|
|
4689
|
+
FormField = __decorateClass([
|
|
4690
|
+
Entity12("form_fields")
|
|
4691
|
+
], FormField);
|
|
4692
|
+
|
|
4693
|
+
// src/entities/form.entity.ts
|
|
4694
|
+
var Form = class {
|
|
4695
|
+
id;
|
|
4696
|
+
name;
|
|
4697
|
+
description;
|
|
4698
|
+
campaign;
|
|
4699
|
+
slug;
|
|
4700
|
+
published;
|
|
4701
|
+
createdAt;
|
|
4702
|
+
updatedAt;
|
|
4703
|
+
deletedAt;
|
|
4704
|
+
deleted;
|
|
4705
|
+
createdBy;
|
|
4706
|
+
updatedBy;
|
|
4707
|
+
deletedBy;
|
|
4708
|
+
fields;
|
|
4709
|
+
submissions;
|
|
4710
|
+
};
|
|
4711
|
+
__decorateClass([
|
|
4712
|
+
PrimaryGeneratedColumn13()
|
|
4713
|
+
], Form.prototype, "id", 2);
|
|
4714
|
+
__decorateClass([
|
|
4715
|
+
Column13("varchar")
|
|
4716
|
+
], Form.prototype, "name", 2);
|
|
4717
|
+
__decorateClass([
|
|
4718
|
+
Column13("text", { nullable: true })
|
|
4719
|
+
], Form.prototype, "description", 2);
|
|
4720
|
+
__decorateClass([
|
|
4721
|
+
Column13("varchar", { nullable: true })
|
|
4722
|
+
], Form.prototype, "campaign", 2);
|
|
4723
|
+
__decorateClass([
|
|
4724
|
+
Column13("varchar", { unique: true })
|
|
4725
|
+
], Form.prototype, "slug", 2);
|
|
4726
|
+
__decorateClass([
|
|
4727
|
+
Column13("boolean", { default: false })
|
|
4728
|
+
], Form.prototype, "published", 2);
|
|
4729
|
+
__decorateClass([
|
|
4730
|
+
Column13({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4731
|
+
], Form.prototype, "createdAt", 2);
|
|
4732
|
+
__decorateClass([
|
|
4733
|
+
Column13({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4734
|
+
], Form.prototype, "updatedAt", 2);
|
|
4735
|
+
__decorateClass([
|
|
4736
|
+
Column13({ type: "timestamp", nullable: true })
|
|
4737
|
+
], Form.prototype, "deletedAt", 2);
|
|
4738
|
+
__decorateClass([
|
|
4739
|
+
Column13("boolean", { default: false })
|
|
4740
|
+
], Form.prototype, "deleted", 2);
|
|
4741
|
+
__decorateClass([
|
|
4742
|
+
Column13("int", { nullable: true })
|
|
4743
|
+
], Form.prototype, "createdBy", 2);
|
|
4744
|
+
__decorateClass([
|
|
4745
|
+
Column13("int", { nullable: true })
|
|
4746
|
+
], Form.prototype, "updatedBy", 2);
|
|
4747
|
+
__decorateClass([
|
|
4748
|
+
Column13("int", { nullable: true })
|
|
4749
|
+
], Form.prototype, "deletedBy", 2);
|
|
4750
|
+
__decorateClass([
|
|
4751
|
+
OneToMany5(() => FormField, (f) => f.form)
|
|
4752
|
+
], Form.prototype, "fields", 2);
|
|
4753
|
+
__decorateClass([
|
|
4754
|
+
OneToMany5(() => FormSubmission, (s) => s.form)
|
|
4755
|
+
], Form.prototype, "submissions", 2);
|
|
4756
|
+
Form = __decorateClass([
|
|
4757
|
+
Entity13("forms")
|
|
4758
|
+
], Form);
|
|
4759
|
+
|
|
4760
|
+
// src/entities/form-submission.entity.ts
|
|
4761
|
+
var FormSubmission = class {
|
|
4762
|
+
id;
|
|
4763
|
+
formId;
|
|
4764
|
+
contactId;
|
|
4765
|
+
data;
|
|
4766
|
+
ipAddress;
|
|
4767
|
+
userAgent;
|
|
4768
|
+
createdAt;
|
|
4769
|
+
updatedAt;
|
|
4770
|
+
form;
|
|
4771
|
+
contact;
|
|
4772
|
+
};
|
|
4773
|
+
__decorateClass([
|
|
4774
|
+
PrimaryGeneratedColumn14()
|
|
4775
|
+
], FormSubmission.prototype, "id", 2);
|
|
4776
|
+
__decorateClass([
|
|
4777
|
+
Column14("int")
|
|
4778
|
+
], FormSubmission.prototype, "formId", 2);
|
|
4779
|
+
__decorateClass([
|
|
4780
|
+
Column14("int", { nullable: true })
|
|
4781
|
+
], FormSubmission.prototype, "contactId", 2);
|
|
4782
|
+
__decorateClass([
|
|
4783
|
+
Column14("jsonb")
|
|
4784
|
+
], FormSubmission.prototype, "data", 2);
|
|
4785
|
+
__decorateClass([
|
|
4786
|
+
Column14("varchar", { nullable: true })
|
|
4787
|
+
], FormSubmission.prototype, "ipAddress", 2);
|
|
4788
|
+
__decorateClass([
|
|
4789
|
+
Column14("varchar", { nullable: true })
|
|
4790
|
+
], FormSubmission.prototype, "userAgent", 2);
|
|
4791
|
+
__decorateClass([
|
|
4792
|
+
Column14({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4793
|
+
], FormSubmission.prototype, "createdAt", 2);
|
|
4794
|
+
__decorateClass([
|
|
4795
|
+
Column14({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4796
|
+
], FormSubmission.prototype, "updatedAt", 2);
|
|
4797
|
+
__decorateClass([
|
|
4798
|
+
ManyToOne6(() => Form, (f) => f.submissions, { onDelete: "CASCADE" }),
|
|
4799
|
+
JoinColumn6({ name: "formId" })
|
|
4800
|
+
], FormSubmission.prototype, "form", 2);
|
|
4801
|
+
__decorateClass([
|
|
4802
|
+
ManyToOne6(() => Contact, (c) => c.form_submissions, { onDelete: "SET NULL" }),
|
|
4803
|
+
JoinColumn6({ name: "contactId" })
|
|
4804
|
+
], FormSubmission.prototype, "contact", 2);
|
|
4805
|
+
FormSubmission = __decorateClass([
|
|
4806
|
+
Entity14("form_submissions")
|
|
4807
|
+
], FormSubmission);
|
|
4808
|
+
|
|
4809
|
+
// src/entities/address.entity.ts
|
|
4810
|
+
import { Entity as Entity15, PrimaryGeneratedColumn as PrimaryGeneratedColumn15, Column as Column15, ManyToOne as ManyToOne7, JoinColumn as JoinColumn7 } from "typeorm";
|
|
4811
|
+
var Address = class {
|
|
4812
|
+
id;
|
|
4813
|
+
contactId;
|
|
4814
|
+
tag;
|
|
4815
|
+
line1;
|
|
4816
|
+
line2;
|
|
4817
|
+
city;
|
|
4818
|
+
state;
|
|
4819
|
+
postalCode;
|
|
4820
|
+
country;
|
|
4821
|
+
createdAt;
|
|
4822
|
+
updatedAt;
|
|
4823
|
+
contact;
|
|
4824
|
+
};
|
|
4825
|
+
__decorateClass([
|
|
4826
|
+
PrimaryGeneratedColumn15()
|
|
4827
|
+
], Address.prototype, "id", 2);
|
|
4828
|
+
__decorateClass([
|
|
4829
|
+
Column15("int")
|
|
4830
|
+
], Address.prototype, "contactId", 2);
|
|
4831
|
+
__decorateClass([
|
|
4832
|
+
Column15("varchar", { nullable: true })
|
|
4833
|
+
], Address.prototype, "tag", 2);
|
|
4834
|
+
__decorateClass([
|
|
4835
|
+
Column15("varchar", { nullable: true })
|
|
4836
|
+
], Address.prototype, "line1", 2);
|
|
4837
|
+
__decorateClass([
|
|
4838
|
+
Column15("varchar", { nullable: true })
|
|
4839
|
+
], Address.prototype, "line2", 2);
|
|
4840
|
+
__decorateClass([
|
|
4841
|
+
Column15("varchar", { nullable: true })
|
|
4842
|
+
], Address.prototype, "city", 2);
|
|
4843
|
+
__decorateClass([
|
|
4844
|
+
Column15("varchar", { nullable: true })
|
|
4845
|
+
], Address.prototype, "state", 2);
|
|
4846
|
+
__decorateClass([
|
|
4847
|
+
Column15("varchar", { nullable: true })
|
|
4848
|
+
], Address.prototype, "postalCode", 2);
|
|
4849
|
+
__decorateClass([
|
|
4850
|
+
Column15("varchar", { nullable: true })
|
|
4851
|
+
], Address.prototype, "country", 2);
|
|
4852
|
+
__decorateClass([
|
|
4853
|
+
Column15({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4854
|
+
], Address.prototype, "createdAt", 2);
|
|
4855
|
+
__decorateClass([
|
|
4856
|
+
Column15({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4857
|
+
], Address.prototype, "updatedAt", 2);
|
|
4858
|
+
__decorateClass([
|
|
4859
|
+
ManyToOne7(() => Contact, (c) => c.addresses, { onDelete: "CASCADE" }),
|
|
4860
|
+
JoinColumn7({ name: "contactId" })
|
|
4861
|
+
], Address.prototype, "contact", 2);
|
|
4862
|
+
Address = __decorateClass([
|
|
4863
|
+
Entity15("addresses")
|
|
4864
|
+
], Address);
|
|
4865
|
+
|
|
4866
|
+
// src/entities/order.entity.ts
|
|
4867
|
+
import { Entity as Entity16, PrimaryGeneratedColumn as PrimaryGeneratedColumn16, Column as Column16, ManyToOne as ManyToOne8, OneToMany as OneToMany6, JoinColumn as JoinColumn8 } from "typeorm";
|
|
4868
|
+
var Order = class {
|
|
4869
|
+
id;
|
|
4870
|
+
orderNumber;
|
|
4871
|
+
orderKind;
|
|
4872
|
+
parentOrderId;
|
|
4873
|
+
contactId;
|
|
4874
|
+
billingAddressId;
|
|
4875
|
+
shippingAddressId;
|
|
4876
|
+
status;
|
|
4877
|
+
subtotal;
|
|
4878
|
+
tax;
|
|
4879
|
+
discount;
|
|
4880
|
+
total;
|
|
4881
|
+
currency;
|
|
4882
|
+
metadata;
|
|
4883
|
+
createdAt;
|
|
4884
|
+
updatedAt;
|
|
4885
|
+
deletedAt;
|
|
4886
|
+
deleted;
|
|
4887
|
+
createdBy;
|
|
4888
|
+
updatedBy;
|
|
4889
|
+
deletedBy;
|
|
4890
|
+
parentOrder;
|
|
4891
|
+
children;
|
|
4892
|
+
contact;
|
|
4893
|
+
billingAddress;
|
|
4894
|
+
shippingAddress;
|
|
4895
|
+
items;
|
|
4896
|
+
payments;
|
|
4897
|
+
};
|
|
4898
|
+
__decorateClass([
|
|
4899
|
+
PrimaryGeneratedColumn16()
|
|
4900
|
+
], Order.prototype, "id", 2);
|
|
4901
|
+
__decorateClass([
|
|
4902
|
+
Column16("varchar", { unique: true })
|
|
4903
|
+
], Order.prototype, "orderNumber", 2);
|
|
4904
|
+
__decorateClass([
|
|
4905
|
+
Column16("varchar", { default: "sale" })
|
|
4906
|
+
], Order.prototype, "orderKind", 2);
|
|
4907
|
+
__decorateClass([
|
|
4908
|
+
Column16("int", { nullable: true })
|
|
4909
|
+
], Order.prototype, "parentOrderId", 2);
|
|
4910
|
+
__decorateClass([
|
|
4911
|
+
Column16("int")
|
|
4912
|
+
], Order.prototype, "contactId", 2);
|
|
4913
|
+
__decorateClass([
|
|
4914
|
+
Column16("int", { nullable: true })
|
|
4915
|
+
], Order.prototype, "billingAddressId", 2);
|
|
4916
|
+
__decorateClass([
|
|
4917
|
+
Column16("int", { nullable: true })
|
|
4918
|
+
], Order.prototype, "shippingAddressId", 2);
|
|
4919
|
+
__decorateClass([
|
|
4920
|
+
Column16("varchar", { default: "pending" })
|
|
4921
|
+
], Order.prototype, "status", 2);
|
|
4922
|
+
__decorateClass([
|
|
4923
|
+
Column16("decimal", { precision: 12, scale: 2, default: 0 })
|
|
4924
|
+
], Order.prototype, "subtotal", 2);
|
|
4925
|
+
__decorateClass([
|
|
4926
|
+
Column16("decimal", { precision: 12, scale: 2, default: 0 })
|
|
4927
|
+
], Order.prototype, "tax", 2);
|
|
4928
|
+
__decorateClass([
|
|
4929
|
+
Column16("decimal", { precision: 12, scale: 2, default: 0 })
|
|
4930
|
+
], Order.prototype, "discount", 2);
|
|
4931
|
+
__decorateClass([
|
|
4932
|
+
Column16("decimal", { precision: 12, scale: 2, default: 0 })
|
|
4933
|
+
], Order.prototype, "total", 2);
|
|
4934
|
+
__decorateClass([
|
|
4935
|
+
Column16("varchar", { default: "INR" })
|
|
4936
|
+
], Order.prototype, "currency", 2);
|
|
4937
|
+
__decorateClass([
|
|
4938
|
+
Column16("jsonb", { nullable: true })
|
|
4939
|
+
], Order.prototype, "metadata", 2);
|
|
4940
|
+
__decorateClass([
|
|
4941
|
+
Column16({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4942
|
+
], Order.prototype, "createdAt", 2);
|
|
4943
|
+
__decorateClass([
|
|
4944
|
+
Column16({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4945
|
+
], Order.prototype, "updatedAt", 2);
|
|
4946
|
+
__decorateClass([
|
|
4947
|
+
Column16({ type: "timestamp", nullable: true })
|
|
4948
|
+
], Order.prototype, "deletedAt", 2);
|
|
4949
|
+
__decorateClass([
|
|
4950
|
+
Column16("boolean", { default: false })
|
|
4951
|
+
], Order.prototype, "deleted", 2);
|
|
4952
|
+
__decorateClass([
|
|
4953
|
+
Column16("int", { nullable: true })
|
|
4954
|
+
], Order.prototype, "createdBy", 2);
|
|
4955
|
+
__decorateClass([
|
|
4956
|
+
Column16("int", { nullable: true })
|
|
4957
|
+
], Order.prototype, "updatedBy", 2);
|
|
4958
|
+
__decorateClass([
|
|
4959
|
+
Column16("int", { nullable: true })
|
|
4960
|
+
], Order.prototype, "deletedBy", 2);
|
|
4961
|
+
__decorateClass([
|
|
4962
|
+
ManyToOne8(() => Order, (o) => o.children, { nullable: true, onDelete: "SET NULL" }),
|
|
4963
|
+
JoinColumn8({ name: "parentOrderId" })
|
|
4964
|
+
], Order.prototype, "parentOrder", 2);
|
|
4965
|
+
__decorateClass([
|
|
4966
|
+
OneToMany6(() => Order, (o) => o.parentOrder)
|
|
4967
|
+
], Order.prototype, "children", 2);
|
|
4968
|
+
__decorateClass([
|
|
4969
|
+
ManyToOne8(() => Contact, { onDelete: "CASCADE" }),
|
|
4970
|
+
JoinColumn8({ name: "contactId" })
|
|
4971
|
+
], Order.prototype, "contact", 2);
|
|
4972
|
+
__decorateClass([
|
|
4973
|
+
ManyToOne8(() => Address, { onDelete: "SET NULL" }),
|
|
4974
|
+
JoinColumn8({ name: "billingAddressId" })
|
|
4975
|
+
], Order.prototype, "billingAddress", 2);
|
|
4976
|
+
__decorateClass([
|
|
4977
|
+
ManyToOne8(() => Address, { onDelete: "SET NULL" }),
|
|
4978
|
+
JoinColumn8({ name: "shippingAddressId" })
|
|
4979
|
+
], Order.prototype, "shippingAddress", 2);
|
|
4980
|
+
__decorateClass([
|
|
4981
|
+
OneToMany6("OrderItem", "order")
|
|
4982
|
+
], Order.prototype, "items", 2);
|
|
4983
|
+
__decorateClass([
|
|
4984
|
+
OneToMany6("Payment", "order")
|
|
4985
|
+
], Order.prototype, "payments", 2);
|
|
4986
|
+
Order = __decorateClass([
|
|
4987
|
+
Entity16("orders")
|
|
4988
|
+
], Order);
|
|
4989
|
+
|
|
4990
|
+
// src/entities/payment.entity.ts
|
|
4991
|
+
import { Entity as Entity17, PrimaryGeneratedColumn as PrimaryGeneratedColumn17, Column as Column17, ManyToOne as ManyToOne9, JoinColumn as JoinColumn9 } from "typeorm";
|
|
4992
|
+
var Payment = class {
|
|
4993
|
+
id;
|
|
4994
|
+
orderId;
|
|
4995
|
+
contactId;
|
|
4996
|
+
amount;
|
|
4997
|
+
currency;
|
|
4998
|
+
status;
|
|
4999
|
+
method;
|
|
5000
|
+
externalReference;
|
|
5001
|
+
metadata;
|
|
5002
|
+
paidAt;
|
|
5003
|
+
createdAt;
|
|
5004
|
+
updatedAt;
|
|
5005
|
+
deletedAt;
|
|
5006
|
+
deleted;
|
|
5007
|
+
createdBy;
|
|
5008
|
+
updatedBy;
|
|
5009
|
+
deletedBy;
|
|
5010
|
+
order;
|
|
5011
|
+
contact;
|
|
5012
|
+
};
|
|
5013
|
+
__decorateClass([
|
|
5014
|
+
PrimaryGeneratedColumn17()
|
|
5015
|
+
], Payment.prototype, "id", 2);
|
|
5016
|
+
__decorateClass([
|
|
5017
|
+
Column17("int")
|
|
5018
|
+
], Payment.prototype, "orderId", 2);
|
|
5019
|
+
__decorateClass([
|
|
5020
|
+
Column17("int", { nullable: true })
|
|
5021
|
+
], Payment.prototype, "contactId", 2);
|
|
5022
|
+
__decorateClass([
|
|
5023
|
+
Column17("decimal", { precision: 12, scale: 2 })
|
|
5024
|
+
], Payment.prototype, "amount", 2);
|
|
5025
|
+
__decorateClass([
|
|
5026
|
+
Column17("varchar", { default: "INR" })
|
|
5027
|
+
], Payment.prototype, "currency", 2);
|
|
5028
|
+
__decorateClass([
|
|
5029
|
+
Column17("varchar", { default: "pending" })
|
|
5030
|
+
], Payment.prototype, "status", 2);
|
|
5031
|
+
__decorateClass([
|
|
5032
|
+
Column17("varchar", { nullable: true })
|
|
5033
|
+
], Payment.prototype, "method", 2);
|
|
5034
|
+
__decorateClass([
|
|
5035
|
+
Column17("varchar", { nullable: true })
|
|
5036
|
+
], Payment.prototype, "externalReference", 2);
|
|
5037
|
+
__decorateClass([
|
|
5038
|
+
Column17("jsonb", { nullable: true })
|
|
5039
|
+
], Payment.prototype, "metadata", 2);
|
|
5040
|
+
__decorateClass([
|
|
5041
|
+
Column17({ type: "timestamp", nullable: true })
|
|
5042
|
+
], Payment.prototype, "paidAt", 2);
|
|
5043
|
+
__decorateClass([
|
|
5044
|
+
Column17({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
5045
|
+
], Payment.prototype, "createdAt", 2);
|
|
5046
|
+
__decorateClass([
|
|
5047
|
+
Column17({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
5048
|
+
], Payment.prototype, "updatedAt", 2);
|
|
5049
|
+
__decorateClass([
|
|
5050
|
+
Column17({ type: "timestamp", nullable: true })
|
|
5051
|
+
], Payment.prototype, "deletedAt", 2);
|
|
5052
|
+
__decorateClass([
|
|
5053
|
+
Column17("boolean", { default: false })
|
|
5054
|
+
], Payment.prototype, "deleted", 2);
|
|
5055
|
+
__decorateClass([
|
|
5056
|
+
Column17("int", { nullable: true })
|
|
5057
|
+
], Payment.prototype, "createdBy", 2);
|
|
5058
|
+
__decorateClass([
|
|
5059
|
+
Column17("int", { nullable: true })
|
|
5060
|
+
], Payment.prototype, "updatedBy", 2);
|
|
5061
|
+
__decorateClass([
|
|
5062
|
+
Column17("int", { nullable: true })
|
|
5063
|
+
], Payment.prototype, "deletedBy", 2);
|
|
5064
|
+
__decorateClass([
|
|
5065
|
+
ManyToOne9(() => Order, (o) => o.payments, { onDelete: "CASCADE" }),
|
|
5066
|
+
JoinColumn9({ name: "orderId" })
|
|
5067
|
+
], Payment.prototype, "order", 2);
|
|
5068
|
+
__decorateClass([
|
|
5069
|
+
ManyToOne9(() => Contact, { onDelete: "SET NULL" }),
|
|
5070
|
+
JoinColumn9({ name: "contactId" })
|
|
5071
|
+
], Payment.prototype, "contact", 2);
|
|
5072
|
+
Payment = __decorateClass([
|
|
5073
|
+
Entity17("payments")
|
|
5074
|
+
], Payment);
|
|
5075
|
+
|
|
5076
|
+
// src/entities/chat-conversation.entity.ts
|
|
5077
|
+
import { Entity as Entity19, PrimaryGeneratedColumn as PrimaryGeneratedColumn19, Column as Column19, ManyToOne as ManyToOne11, OneToMany as OneToMany7, JoinColumn as JoinColumn11 } from "typeorm";
|
|
5078
|
+
|
|
5079
|
+
// src/entities/chat-message.entity.ts
|
|
5080
|
+
import { Entity as Entity18, PrimaryGeneratedColumn as PrimaryGeneratedColumn18, Column as Column18, ManyToOne as ManyToOne10, JoinColumn as JoinColumn10 } from "typeorm";
|
|
5081
|
+
var ChatMessage = class {
|
|
5082
|
+
id;
|
|
5083
|
+
conversationId;
|
|
5084
|
+
role;
|
|
5085
|
+
content;
|
|
5086
|
+
createdAt;
|
|
5087
|
+
conversation;
|
|
5088
|
+
};
|
|
5089
|
+
__decorateClass([
|
|
5090
|
+
PrimaryGeneratedColumn18()
|
|
5091
|
+
], ChatMessage.prototype, "id", 2);
|
|
5092
|
+
__decorateClass([
|
|
5093
|
+
Column18("int")
|
|
5094
|
+
], ChatMessage.prototype, "conversationId", 2);
|
|
5095
|
+
__decorateClass([
|
|
5096
|
+
Column18("varchar")
|
|
5097
|
+
], ChatMessage.prototype, "role", 2);
|
|
5098
|
+
__decorateClass([
|
|
5099
|
+
Column18("text")
|
|
5100
|
+
], ChatMessage.prototype, "content", 2);
|
|
5101
|
+
__decorateClass([
|
|
5102
|
+
Column18({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
5103
|
+
], ChatMessage.prototype, "createdAt", 2);
|
|
5104
|
+
__decorateClass([
|
|
5105
|
+
ManyToOne10(() => ChatConversation, (c) => c.messages, { onDelete: "CASCADE" }),
|
|
5106
|
+
JoinColumn10({ name: "conversationId" })
|
|
5107
|
+
], ChatMessage.prototype, "conversation", 2);
|
|
5108
|
+
ChatMessage = __decorateClass([
|
|
5109
|
+
Entity18("chat_messages")
|
|
5110
|
+
], ChatMessage);
|
|
5111
|
+
|
|
5112
|
+
// src/entities/chat-conversation.entity.ts
|
|
5113
|
+
var ChatConversation = class {
|
|
5114
|
+
id;
|
|
5115
|
+
contactId;
|
|
5116
|
+
createdAt;
|
|
5117
|
+
updatedAt;
|
|
5118
|
+
contact;
|
|
5119
|
+
messages;
|
|
5120
|
+
};
|
|
5121
|
+
__decorateClass([
|
|
5122
|
+
PrimaryGeneratedColumn19()
|
|
5123
|
+
], ChatConversation.prototype, "id", 2);
|
|
5124
|
+
__decorateClass([
|
|
5125
|
+
Column19("int")
|
|
5126
|
+
], ChatConversation.prototype, "contactId", 2);
|
|
5127
|
+
__decorateClass([
|
|
5128
|
+
Column19({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
5129
|
+
], ChatConversation.prototype, "createdAt", 2);
|
|
5130
|
+
__decorateClass([
|
|
5131
|
+
Column19({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
5132
|
+
], ChatConversation.prototype, "updatedAt", 2);
|
|
5133
|
+
__decorateClass([
|
|
5134
|
+
ManyToOne11(() => Contact, (c) => c.chatConversations, { onDelete: "CASCADE" }),
|
|
5135
|
+
JoinColumn11({ name: "contactId" })
|
|
5136
|
+
], ChatConversation.prototype, "contact", 2);
|
|
5137
|
+
__decorateClass([
|
|
5138
|
+
OneToMany7(() => ChatMessage, (m) => m.conversation)
|
|
5139
|
+
], ChatConversation.prototype, "messages", 2);
|
|
5140
|
+
ChatConversation = __decorateClass([
|
|
5141
|
+
Entity19("chat_conversations")
|
|
5142
|
+
], ChatConversation);
|
|
5143
|
+
|
|
5144
|
+
// src/entities/contact.entity.ts
|
|
5145
|
+
var Contact = class {
|
|
5146
|
+
id;
|
|
5147
|
+
name;
|
|
5148
|
+
email;
|
|
5149
|
+
phone;
|
|
5150
|
+
type;
|
|
5151
|
+
company;
|
|
5152
|
+
taxId;
|
|
5153
|
+
notes;
|
|
5154
|
+
createdAt;
|
|
5155
|
+
updatedAt;
|
|
5156
|
+
deletedAt;
|
|
5157
|
+
deleted;
|
|
5158
|
+
createdBy;
|
|
5159
|
+
updatedBy;
|
|
5160
|
+
deletedBy;
|
|
5161
|
+
userId;
|
|
5162
|
+
user;
|
|
5163
|
+
form_submissions;
|
|
5164
|
+
addresses;
|
|
5165
|
+
orders;
|
|
5166
|
+
payments;
|
|
5167
|
+
chatConversations;
|
|
5168
|
+
};
|
|
5169
|
+
__decorateClass([
|
|
5170
|
+
PrimaryGeneratedColumn20()
|
|
5171
|
+
], Contact.prototype, "id", 2);
|
|
5172
|
+
__decorateClass([
|
|
5173
|
+
Column20("varchar")
|
|
5174
|
+
], Contact.prototype, "name", 2);
|
|
5175
|
+
__decorateClass([
|
|
5176
|
+
Column20("varchar", { unique: true })
|
|
5177
|
+
], Contact.prototype, "email", 2);
|
|
5178
|
+
__decorateClass([
|
|
5179
|
+
Column20("varchar", { nullable: true })
|
|
5180
|
+
], Contact.prototype, "phone", 2);
|
|
5181
|
+
__decorateClass([
|
|
5182
|
+
Column20("varchar", { nullable: true })
|
|
5183
|
+
], Contact.prototype, "type", 2);
|
|
5184
|
+
__decorateClass([
|
|
5185
|
+
Column20("varchar", { nullable: true })
|
|
5186
|
+
], Contact.prototype, "company", 2);
|
|
5187
|
+
__decorateClass([
|
|
5188
|
+
Column20("varchar", { nullable: true })
|
|
5189
|
+
], Contact.prototype, "taxId", 2);
|
|
5190
|
+
__decorateClass([
|
|
5191
|
+
Column20("text", { nullable: true })
|
|
5192
|
+
], Contact.prototype, "notes", 2);
|
|
5193
|
+
__decorateClass([
|
|
5194
|
+
Column20({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
5195
|
+
], Contact.prototype, "createdAt", 2);
|
|
5196
|
+
__decorateClass([
|
|
5197
|
+
Column20({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
5198
|
+
], Contact.prototype, "updatedAt", 2);
|
|
5199
|
+
__decorateClass([
|
|
5200
|
+
Column20({ type: "timestamp", nullable: true })
|
|
5201
|
+
], Contact.prototype, "deletedAt", 2);
|
|
5202
|
+
__decorateClass([
|
|
5203
|
+
Column20("boolean", { default: false })
|
|
5204
|
+
], Contact.prototype, "deleted", 2);
|
|
5205
|
+
__decorateClass([
|
|
5206
|
+
Column20("int", { nullable: true })
|
|
5207
|
+
], Contact.prototype, "createdBy", 2);
|
|
5208
|
+
__decorateClass([
|
|
5209
|
+
Column20("int", { nullable: true })
|
|
5210
|
+
], Contact.prototype, "updatedBy", 2);
|
|
5211
|
+
__decorateClass([
|
|
5212
|
+
Column20("int", { nullable: true })
|
|
5213
|
+
], Contact.prototype, "deletedBy", 2);
|
|
5214
|
+
__decorateClass([
|
|
5215
|
+
Column20("int", { nullable: true })
|
|
5216
|
+
], Contact.prototype, "userId", 2);
|
|
5217
|
+
__decorateClass([
|
|
5218
|
+
ManyToOne12(() => User, { onDelete: "SET NULL" }),
|
|
5219
|
+
JoinColumn12({ name: "userId" })
|
|
5220
|
+
], Contact.prototype, "user", 2);
|
|
5221
|
+
__decorateClass([
|
|
5222
|
+
OneToMany8(() => FormSubmission, (fs) => fs.contact)
|
|
5223
|
+
], Contact.prototype, "form_submissions", 2);
|
|
5224
|
+
__decorateClass([
|
|
5225
|
+
OneToMany8(() => Address, (a) => a.contact)
|
|
5226
|
+
], Contact.prototype, "addresses", 2);
|
|
5227
|
+
__decorateClass([
|
|
5228
|
+
OneToMany8(() => Order, (o) => o.contact)
|
|
5229
|
+
], Contact.prototype, "orders", 2);
|
|
5230
|
+
__decorateClass([
|
|
5231
|
+
OneToMany8(() => Payment, (p) => p.contact)
|
|
5232
|
+
], Contact.prototype, "payments", 2);
|
|
5233
|
+
__decorateClass([
|
|
5234
|
+
OneToMany8(() => ChatConversation, (c) => c.contact)
|
|
5235
|
+
], Contact.prototype, "chatConversations", 2);
|
|
5236
|
+
Contact = __decorateClass([
|
|
5237
|
+
Entity20("contacts")
|
|
5238
|
+
], Contact);
|
|
5239
|
+
|
|
5240
|
+
// src/entities/config.entity.ts
|
|
5241
|
+
import { Entity as Entity21, PrimaryGeneratedColumn as PrimaryGeneratedColumn21, Column as Column21, Unique } from "typeorm";
|
|
5242
|
+
var Config = class {
|
|
5243
|
+
id;
|
|
5244
|
+
settings;
|
|
5245
|
+
key;
|
|
5246
|
+
value;
|
|
5247
|
+
type;
|
|
5248
|
+
encrypted;
|
|
5249
|
+
createdAt;
|
|
5250
|
+
updatedAt;
|
|
5251
|
+
deletedAt;
|
|
5252
|
+
deleted;
|
|
5253
|
+
createdBy;
|
|
5254
|
+
updatedBy;
|
|
5255
|
+
deletedBy;
|
|
5256
|
+
};
|
|
5257
|
+
__decorateClass([
|
|
5258
|
+
PrimaryGeneratedColumn21()
|
|
5259
|
+
], Config.prototype, "id", 2);
|
|
5260
|
+
__decorateClass([
|
|
5261
|
+
Column21("varchar")
|
|
5262
|
+
], Config.prototype, "settings", 2);
|
|
5263
|
+
__decorateClass([
|
|
5264
|
+
Column21("varchar")
|
|
5265
|
+
], Config.prototype, "key", 2);
|
|
5266
|
+
__decorateClass([
|
|
5267
|
+
Column21("varchar")
|
|
5268
|
+
], Config.prototype, "value", 2);
|
|
5269
|
+
__decorateClass([
|
|
5270
|
+
Column21("varchar", { default: "private" })
|
|
5271
|
+
], Config.prototype, "type", 2);
|
|
5272
|
+
__decorateClass([
|
|
5273
|
+
Column21("boolean", { default: false })
|
|
5274
|
+
], Config.prototype, "encrypted", 2);
|
|
5275
|
+
__decorateClass([
|
|
5276
|
+
Column21({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
5277
|
+
], Config.prototype, "createdAt", 2);
|
|
5278
|
+
__decorateClass([
|
|
5279
|
+
Column21({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
5280
|
+
], Config.prototype, "updatedAt", 2);
|
|
5281
|
+
__decorateClass([
|
|
5282
|
+
Column21({ type: "timestamp", nullable: true })
|
|
5283
|
+
], Config.prototype, "deletedAt", 2);
|
|
5284
|
+
__decorateClass([
|
|
5285
|
+
Column21("boolean", { default: false })
|
|
5286
|
+
], Config.prototype, "deleted", 2);
|
|
5287
|
+
__decorateClass([
|
|
5288
|
+
Column21("int", { nullable: true })
|
|
5289
|
+
], Config.prototype, "createdBy", 2);
|
|
5290
|
+
__decorateClass([
|
|
5291
|
+
Column21("int", { nullable: true })
|
|
5292
|
+
], Config.prototype, "updatedBy", 2);
|
|
5293
|
+
__decorateClass([
|
|
5294
|
+
Column21("int", { nullable: true })
|
|
5295
|
+
], Config.prototype, "deletedBy", 2);
|
|
5296
|
+
Config = __decorateClass([
|
|
5297
|
+
Entity21("configs"),
|
|
5298
|
+
Unique(["settings", "key"])
|
|
5299
|
+
], Config);
|
|
5300
|
+
|
|
5301
|
+
// src/entities/message-template.entity.ts
|
|
5302
|
+
import { Entity as Entity22, PrimaryGeneratedColumn as PrimaryGeneratedColumn22, Column as Column22 } from "typeorm";
|
|
5303
|
+
var MessageTemplate = class {
|
|
5304
|
+
id;
|
|
5305
|
+
channel;
|
|
5306
|
+
templateKey;
|
|
5307
|
+
name;
|
|
5308
|
+
subject;
|
|
5309
|
+
body;
|
|
5310
|
+
externalTemplateRef;
|
|
5311
|
+
providerMeta;
|
|
5312
|
+
enabled;
|
|
5313
|
+
createdAt;
|
|
5314
|
+
updatedAt;
|
|
5315
|
+
deletedAt;
|
|
5316
|
+
deleted;
|
|
5317
|
+
createdBy;
|
|
5318
|
+
updatedBy;
|
|
5319
|
+
deletedBy;
|
|
5320
|
+
};
|
|
5321
|
+
__decorateClass([
|
|
5322
|
+
PrimaryGeneratedColumn22()
|
|
5323
|
+
], MessageTemplate.prototype, "id", 2);
|
|
5324
|
+
__decorateClass([
|
|
5325
|
+
Column22("varchar")
|
|
5326
|
+
], MessageTemplate.prototype, "channel", 2);
|
|
5327
|
+
__decorateClass([
|
|
5328
|
+
Column22("varchar", { name: "template_key" })
|
|
5329
|
+
], MessageTemplate.prototype, "templateKey", 2);
|
|
5330
|
+
__decorateClass([
|
|
5331
|
+
Column22("varchar", { nullable: true })
|
|
5332
|
+
], MessageTemplate.prototype, "name", 2);
|
|
5333
|
+
__decorateClass([
|
|
5334
|
+
Column22("varchar", { nullable: true })
|
|
5335
|
+
], MessageTemplate.prototype, "subject", 2);
|
|
5336
|
+
__decorateClass([
|
|
5337
|
+
Column22("text", { default: "" })
|
|
5338
|
+
], MessageTemplate.prototype, "body", 2);
|
|
5339
|
+
__decorateClass([
|
|
5340
|
+
Column22("varchar", { name: "external_template_ref", nullable: true })
|
|
5341
|
+
], MessageTemplate.prototype, "externalTemplateRef", 2);
|
|
5342
|
+
__decorateClass([
|
|
5343
|
+
Column22({ type: "jsonb", nullable: true })
|
|
5344
|
+
], MessageTemplate.prototype, "providerMeta", 2);
|
|
5345
|
+
__decorateClass([
|
|
5346
|
+
Column22("boolean", { default: true })
|
|
5347
|
+
], MessageTemplate.prototype, "enabled", 2);
|
|
5348
|
+
__decorateClass([
|
|
5349
|
+
Column22({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
5350
|
+
], MessageTemplate.prototype, "createdAt", 2);
|
|
5351
|
+
__decorateClass([
|
|
5352
|
+
Column22({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
5353
|
+
], MessageTemplate.prototype, "updatedAt", 2);
|
|
5354
|
+
__decorateClass([
|
|
5355
|
+
Column22({ type: "timestamp", nullable: true })
|
|
5356
|
+
], MessageTemplate.prototype, "deletedAt", 2);
|
|
5357
|
+
__decorateClass([
|
|
5358
|
+
Column22("boolean", { default: false })
|
|
5359
|
+
], MessageTemplate.prototype, "deleted", 2);
|
|
5360
|
+
__decorateClass([
|
|
5361
|
+
Column22("int", { nullable: true })
|
|
5362
|
+
], MessageTemplate.prototype, "createdBy", 2);
|
|
5363
|
+
__decorateClass([
|
|
5364
|
+
Column22("int", { nullable: true })
|
|
5365
|
+
], MessageTemplate.prototype, "updatedBy", 2);
|
|
5366
|
+
__decorateClass([
|
|
5367
|
+
Column22("int", { nullable: true })
|
|
5368
|
+
], MessageTemplate.prototype, "deletedBy", 2);
|
|
5369
|
+
MessageTemplate = __decorateClass([
|
|
5370
|
+
Entity22("message_templates")
|
|
5371
|
+
], MessageTemplate);
|
|
5372
|
+
|
|
5373
|
+
// src/entities/media.entity.ts
|
|
5374
|
+
import { Entity as Entity23, PrimaryGeneratedColumn as PrimaryGeneratedColumn23, Column as Column23, ManyToOne as ManyToOne13, OneToMany as OneToMany9, JoinColumn as JoinColumn13 } from "typeorm";
|
|
5375
|
+
var Media = class {
|
|
5376
|
+
id;
|
|
5377
|
+
kind;
|
|
5378
|
+
parentId;
|
|
5379
|
+
parent;
|
|
5380
|
+
children;
|
|
5381
|
+
filename;
|
|
5382
|
+
url;
|
|
5383
|
+
mimeType;
|
|
5384
|
+
size;
|
|
5385
|
+
alt;
|
|
5386
|
+
isPublic;
|
|
5387
|
+
createdAt;
|
|
5388
|
+
updatedAt;
|
|
5389
|
+
deletedAt;
|
|
5390
|
+
deleted;
|
|
5391
|
+
};
|
|
5392
|
+
__decorateClass([
|
|
5393
|
+
PrimaryGeneratedColumn23()
|
|
5394
|
+
], Media.prototype, "id", 2);
|
|
5395
|
+
__decorateClass([
|
|
5396
|
+
Column23({ type: "varchar", length: 16, default: "file" })
|
|
5397
|
+
], Media.prototype, "kind", 2);
|
|
5398
|
+
__decorateClass([
|
|
5399
|
+
Column23({ type: "int", nullable: true })
|
|
5400
|
+
], Media.prototype, "parentId", 2);
|
|
5401
|
+
__decorateClass([
|
|
5402
|
+
ManyToOne13(() => Media, (m) => m.children, { onDelete: "CASCADE" }),
|
|
5403
|
+
JoinColumn13({ name: "parentId" })
|
|
5404
|
+
], Media.prototype, "parent", 2);
|
|
5405
|
+
__decorateClass([
|
|
5406
|
+
OneToMany9(() => Media, (m) => m.parent)
|
|
5407
|
+
], Media.prototype, "children", 2);
|
|
5408
|
+
__decorateClass([
|
|
5409
|
+
Column23("varchar")
|
|
5410
|
+
], Media.prototype, "filename", 2);
|
|
5411
|
+
__decorateClass([
|
|
5412
|
+
Column23("varchar", { nullable: true })
|
|
5413
|
+
], Media.prototype, "url", 2);
|
|
5414
|
+
__decorateClass([
|
|
5415
|
+
Column23("varchar", { nullable: true })
|
|
5416
|
+
], Media.prototype, "mimeType", 2);
|
|
5417
|
+
__decorateClass([
|
|
5418
|
+
Column23("int", { default: 0 })
|
|
5419
|
+
], Media.prototype, "size", 2);
|
|
5420
|
+
__decorateClass([
|
|
5421
|
+
Column23("varchar", { nullable: true })
|
|
5422
|
+
], Media.prototype, "alt", 2);
|
|
5423
|
+
__decorateClass([
|
|
5424
|
+
Column23("boolean", { default: false })
|
|
5425
|
+
], Media.prototype, "isPublic", 2);
|
|
5426
|
+
__decorateClass([
|
|
5427
|
+
Column23({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
5428
|
+
], Media.prototype, "createdAt", 2);
|
|
5429
|
+
__decorateClass([
|
|
5430
|
+
Column23({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
5431
|
+
], Media.prototype, "updatedAt", 2);
|
|
5432
|
+
__decorateClass([
|
|
5433
|
+
Column23({ type: "timestamp", nullable: true })
|
|
5434
|
+
], Media.prototype, "deletedAt", 2);
|
|
5435
|
+
__decorateClass([
|
|
5436
|
+
Column23("boolean", { default: false })
|
|
5437
|
+
], Media.prototype, "deleted", 2);
|
|
5438
|
+
Media = __decorateClass([
|
|
5439
|
+
Entity23("media")
|
|
5440
|
+
], Media);
|
|
5441
|
+
|
|
5442
|
+
// src/entities/page.entity.ts
|
|
5443
|
+
import { Entity as Entity24, PrimaryGeneratedColumn as PrimaryGeneratedColumn24, Column as Column24, ManyToOne as ManyToOne14, JoinColumn as JoinColumn14 } from "typeorm";
|
|
5444
|
+
var Page = class {
|
|
5445
|
+
id;
|
|
5446
|
+
title;
|
|
5447
|
+
slug;
|
|
5448
|
+
content;
|
|
5449
|
+
published;
|
|
5450
|
+
theme;
|
|
5451
|
+
parentId;
|
|
5452
|
+
parent;
|
|
5453
|
+
seoId;
|
|
5454
|
+
seo;
|
|
5455
|
+
createdAt;
|
|
5456
|
+
updatedAt;
|
|
5457
|
+
deletedAt;
|
|
5458
|
+
deleted;
|
|
5459
|
+
createdBy;
|
|
5460
|
+
updatedBy;
|
|
5461
|
+
deletedBy;
|
|
5462
|
+
};
|
|
5463
|
+
__decorateClass([
|
|
5464
|
+
PrimaryGeneratedColumn24()
|
|
5465
|
+
], Page.prototype, "id", 2);
|
|
5466
|
+
__decorateClass([
|
|
5467
|
+
Column24("varchar")
|
|
5468
|
+
], Page.prototype, "title", 2);
|
|
5469
|
+
__decorateClass([
|
|
5470
|
+
Column24("varchar", { unique: true })
|
|
5471
|
+
], Page.prototype, "slug", 2);
|
|
5472
|
+
__decorateClass([
|
|
5473
|
+
Column24({ type: "jsonb", default: {} })
|
|
5474
|
+
], Page.prototype, "content", 2);
|
|
5475
|
+
__decorateClass([
|
|
5476
|
+
Column24("boolean", { default: false })
|
|
5477
|
+
], Page.prototype, "published", 2);
|
|
5478
|
+
__decorateClass([
|
|
5479
|
+
Column24("varchar", { default: "default" })
|
|
5480
|
+
], Page.prototype, "theme", 2);
|
|
5481
|
+
__decorateClass([
|
|
5482
|
+
Column24("int", { nullable: true })
|
|
5483
|
+
], Page.prototype, "parentId", 2);
|
|
5484
|
+
__decorateClass([
|
|
5485
|
+
ManyToOne14(() => Page, { onDelete: "SET NULL" }),
|
|
5486
|
+
JoinColumn14({ name: "parentId" })
|
|
5487
|
+
], Page.prototype, "parent", 2);
|
|
5488
|
+
__decorateClass([
|
|
5489
|
+
Column24("int", { nullable: true })
|
|
5490
|
+
], Page.prototype, "seoId", 2);
|
|
5491
|
+
__decorateClass([
|
|
5492
|
+
ManyToOne14(() => Seo, { onDelete: "SET NULL" }),
|
|
5493
|
+
JoinColumn14({ name: "seoId" })
|
|
5494
|
+
], Page.prototype, "seo", 2);
|
|
5495
|
+
__decorateClass([
|
|
5496
|
+
Column24({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
5497
|
+
], Page.prototype, "createdAt", 2);
|
|
5498
|
+
__decorateClass([
|
|
5499
|
+
Column24({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
5500
|
+
], Page.prototype, "updatedAt", 2);
|
|
5501
|
+
__decorateClass([
|
|
5502
|
+
Column24({ type: "timestamp", nullable: true })
|
|
5503
|
+
], Page.prototype, "deletedAt", 2);
|
|
5504
|
+
__decorateClass([
|
|
5505
|
+
Column24("boolean", { default: false })
|
|
5506
|
+
], Page.prototype, "deleted", 2);
|
|
5507
|
+
__decorateClass([
|
|
5508
|
+
Column24("int", { nullable: true })
|
|
5509
|
+
], Page.prototype, "createdBy", 2);
|
|
5510
|
+
__decorateClass([
|
|
5511
|
+
Column24("int", { nullable: true })
|
|
5512
|
+
], Page.prototype, "updatedBy", 2);
|
|
5513
|
+
__decorateClass([
|
|
5514
|
+
Column24("int", { nullable: true })
|
|
5515
|
+
], Page.prototype, "deletedBy", 2);
|
|
5516
|
+
Page = __decorateClass([
|
|
5517
|
+
Entity24("pages")
|
|
5518
|
+
], Page);
|
|
5519
|
+
|
|
5520
|
+
// src/entities/product-category.entity.ts
|
|
5521
|
+
import { Entity as Entity25, PrimaryGeneratedColumn as PrimaryGeneratedColumn25, Column as Column25, ManyToOne as ManyToOne15, OneToMany as OneToMany10, JoinColumn as JoinColumn15 } from "typeorm";
|
|
5522
|
+
var ProductCategory = class {
|
|
5523
|
+
id;
|
|
5524
|
+
name;
|
|
5525
|
+
slug;
|
|
5526
|
+
parentId;
|
|
5527
|
+
image;
|
|
5528
|
+
description;
|
|
5529
|
+
metadata;
|
|
5530
|
+
active;
|
|
5531
|
+
sortOrder;
|
|
5532
|
+
createdAt;
|
|
5533
|
+
updatedAt;
|
|
5534
|
+
deletedAt;
|
|
5535
|
+
deleted;
|
|
5536
|
+
createdBy;
|
|
5537
|
+
updatedBy;
|
|
5538
|
+
deletedBy;
|
|
5539
|
+
parent;
|
|
5540
|
+
children;
|
|
5541
|
+
products;
|
|
5542
|
+
collections;
|
|
5543
|
+
};
|
|
5544
|
+
__decorateClass([
|
|
5545
|
+
PrimaryGeneratedColumn25()
|
|
5546
|
+
], ProductCategory.prototype, "id", 2);
|
|
5547
|
+
__decorateClass([
|
|
5548
|
+
Column25("varchar")
|
|
5549
|
+
], ProductCategory.prototype, "name", 2);
|
|
5550
|
+
__decorateClass([
|
|
5551
|
+
Column25("varchar", { unique: true })
|
|
5552
|
+
], ProductCategory.prototype, "slug", 2);
|
|
5553
|
+
__decorateClass([
|
|
5554
|
+
Column25("int", { nullable: true })
|
|
5555
|
+
], ProductCategory.prototype, "parentId", 2);
|
|
5556
|
+
__decorateClass([
|
|
5557
|
+
Column25("varchar", { nullable: true })
|
|
5558
|
+
], ProductCategory.prototype, "image", 2);
|
|
5559
|
+
__decorateClass([
|
|
5560
|
+
Column25("text", { nullable: true })
|
|
5561
|
+
], ProductCategory.prototype, "description", 2);
|
|
5562
|
+
__decorateClass([
|
|
5563
|
+
Column25("jsonb", { nullable: true })
|
|
5564
|
+
], ProductCategory.prototype, "metadata", 2);
|
|
5565
|
+
__decorateClass([
|
|
5566
|
+
Column25("boolean", { default: true })
|
|
5567
|
+
], ProductCategory.prototype, "active", 2);
|
|
5568
|
+
__decorateClass([
|
|
5569
|
+
Column25("int", { default: 0 })
|
|
5570
|
+
], ProductCategory.prototype, "sortOrder", 2);
|
|
5571
|
+
__decorateClass([
|
|
5572
|
+
Column25({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
5573
|
+
], ProductCategory.prototype, "createdAt", 2);
|
|
5574
|
+
__decorateClass([
|
|
5575
|
+
Column25({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
5576
|
+
], ProductCategory.prototype, "updatedAt", 2);
|
|
5577
|
+
__decorateClass([
|
|
5578
|
+
Column25({ type: "timestamp", nullable: true })
|
|
5579
|
+
], ProductCategory.prototype, "deletedAt", 2);
|
|
5580
|
+
__decorateClass([
|
|
5581
|
+
Column25("boolean", { default: false })
|
|
5582
|
+
], ProductCategory.prototype, "deleted", 2);
|
|
5583
|
+
__decorateClass([
|
|
5584
|
+
Column25("int", { nullable: true })
|
|
5585
|
+
], ProductCategory.prototype, "createdBy", 2);
|
|
5586
|
+
__decorateClass([
|
|
5587
|
+
Column25("int", { nullable: true })
|
|
5588
|
+
], ProductCategory.prototype, "updatedBy", 2);
|
|
5589
|
+
__decorateClass([
|
|
5590
|
+
Column25("int", { nullable: true })
|
|
5591
|
+
], ProductCategory.prototype, "deletedBy", 2);
|
|
5592
|
+
__decorateClass([
|
|
5593
|
+
ManyToOne15(() => ProductCategory, (c) => c.children, { onDelete: "SET NULL" }),
|
|
5594
|
+
JoinColumn15({ name: "parentId" })
|
|
5595
|
+
], ProductCategory.prototype, "parent", 2);
|
|
5596
|
+
__decorateClass([
|
|
5597
|
+
OneToMany10(() => ProductCategory, (c) => c.parent)
|
|
5598
|
+
], ProductCategory.prototype, "children", 2);
|
|
5599
|
+
__decorateClass([
|
|
5600
|
+
OneToMany10("Product", "category")
|
|
5601
|
+
], ProductCategory.prototype, "products", 2);
|
|
5602
|
+
__decorateClass([
|
|
5603
|
+
OneToMany10("Collection", "category")
|
|
5604
|
+
], ProductCategory.prototype, "collections", 2);
|
|
5605
|
+
ProductCategory = __decorateClass([
|
|
5606
|
+
Entity25("product_categories")
|
|
5607
|
+
], ProductCategory);
|
|
5608
|
+
|
|
5609
|
+
// src/entities/collection.entity.ts
|
|
5610
|
+
import { Entity as Entity27, PrimaryGeneratedColumn as PrimaryGeneratedColumn27, Column as Column27, ManyToOne as ManyToOne17, OneToMany as OneToMany12, JoinColumn as JoinColumn17 } from "typeorm";
|
|
5611
|
+
|
|
5612
|
+
// src/entities/brand.entity.ts
|
|
5613
|
+
import { Entity as Entity26, PrimaryGeneratedColumn as PrimaryGeneratedColumn26, Column as Column26, OneToMany as OneToMany11, ManyToOne as ManyToOne16, JoinColumn as JoinColumn16 } from "typeorm";
|
|
5614
|
+
var Brand = class {
|
|
5615
|
+
id;
|
|
5616
|
+
name;
|
|
5617
|
+
slug;
|
|
5618
|
+
logo;
|
|
5619
|
+
metadata;
|
|
5620
|
+
description;
|
|
5621
|
+
active;
|
|
5622
|
+
sortOrder;
|
|
5623
|
+
createdAt;
|
|
5624
|
+
updatedAt;
|
|
5625
|
+
deletedAt;
|
|
5626
|
+
deleted;
|
|
5627
|
+
createdBy;
|
|
5628
|
+
updatedBy;
|
|
5629
|
+
deletedBy;
|
|
5630
|
+
seoId;
|
|
5631
|
+
seo;
|
|
5632
|
+
products;
|
|
5633
|
+
collections;
|
|
5634
|
+
};
|
|
5635
|
+
__decorateClass([
|
|
5636
|
+
PrimaryGeneratedColumn26()
|
|
5637
|
+
], Brand.prototype, "id", 2);
|
|
5638
|
+
__decorateClass([
|
|
5639
|
+
Column26("varchar")
|
|
5640
|
+
], Brand.prototype, "name", 2);
|
|
5641
|
+
__decorateClass([
|
|
5642
|
+
Column26("varchar", { unique: true })
|
|
5643
|
+
], Brand.prototype, "slug", 2);
|
|
5644
|
+
__decorateClass([
|
|
5645
|
+
Column26("varchar", { nullable: true })
|
|
5646
|
+
], Brand.prototype, "logo", 2);
|
|
5647
|
+
__decorateClass([
|
|
5648
|
+
Column26("jsonb", { nullable: true })
|
|
5649
|
+
], Brand.prototype, "metadata", 2);
|
|
5650
|
+
__decorateClass([
|
|
5651
|
+
Column26("text", { nullable: true })
|
|
5652
|
+
], Brand.prototype, "description", 2);
|
|
5653
|
+
__decorateClass([
|
|
5654
|
+
Column26("boolean", { default: true })
|
|
5655
|
+
], Brand.prototype, "active", 2);
|
|
5656
|
+
__decorateClass([
|
|
5657
|
+
Column26("int", { default: 0 })
|
|
5658
|
+
], Brand.prototype, "sortOrder", 2);
|
|
5659
|
+
__decorateClass([
|
|
5660
|
+
Column26({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
5661
|
+
], Brand.prototype, "createdAt", 2);
|
|
5662
|
+
__decorateClass([
|
|
5663
|
+
Column26({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
5664
|
+
], Brand.prototype, "updatedAt", 2);
|
|
5665
|
+
__decorateClass([
|
|
5666
|
+
Column26({ type: "timestamp", nullable: true })
|
|
5667
|
+
], Brand.prototype, "deletedAt", 2);
|
|
5668
|
+
__decorateClass([
|
|
5669
|
+
Column26("boolean", { default: false })
|
|
5670
|
+
], Brand.prototype, "deleted", 2);
|
|
5671
|
+
__decorateClass([
|
|
5672
|
+
Column26("int", { nullable: true })
|
|
5673
|
+
], Brand.prototype, "createdBy", 2);
|
|
5674
|
+
__decorateClass([
|
|
5675
|
+
Column26("int", { nullable: true })
|
|
5676
|
+
], Brand.prototype, "updatedBy", 2);
|
|
5677
|
+
__decorateClass([
|
|
5678
|
+
Column26("int", { nullable: true })
|
|
5679
|
+
], Brand.prototype, "deletedBy", 2);
|
|
5680
|
+
__decorateClass([
|
|
5681
|
+
Column26("int", { nullable: true })
|
|
5682
|
+
], Brand.prototype, "seoId", 2);
|
|
5683
|
+
__decorateClass([
|
|
5684
|
+
ManyToOne16(() => Seo, { onDelete: "SET NULL" }),
|
|
5685
|
+
JoinColumn16({ name: "seoId" })
|
|
5686
|
+
], Brand.prototype, "seo", 2);
|
|
5687
|
+
__decorateClass([
|
|
5688
|
+
OneToMany11("Product", "brand")
|
|
5689
|
+
], Brand.prototype, "products", 2);
|
|
5690
|
+
__decorateClass([
|
|
5691
|
+
OneToMany11("Collection", "brand")
|
|
5692
|
+
], Brand.prototype, "collections", 2);
|
|
5693
|
+
Brand = __decorateClass([
|
|
5694
|
+
Entity26("brands")
|
|
5695
|
+
], Brand);
|
|
5696
|
+
|
|
5697
|
+
// src/entities/collection.entity.ts
|
|
5698
|
+
var Collection = class {
|
|
5699
|
+
id;
|
|
5700
|
+
categoryId;
|
|
5701
|
+
brandId;
|
|
5702
|
+
name;
|
|
5703
|
+
slug;
|
|
5704
|
+
hsn;
|
|
5705
|
+
description;
|
|
5706
|
+
image;
|
|
5707
|
+
metadata;
|
|
5708
|
+
variants;
|
|
5709
|
+
active;
|
|
5710
|
+
sortOrder;
|
|
5711
|
+
createdAt;
|
|
5712
|
+
updatedAt;
|
|
5713
|
+
deletedAt;
|
|
5714
|
+
deleted;
|
|
5715
|
+
createdBy;
|
|
5716
|
+
updatedBy;
|
|
5717
|
+
deletedBy;
|
|
5718
|
+
seoId;
|
|
5719
|
+
seo;
|
|
5720
|
+
category;
|
|
5721
|
+
brand;
|
|
5722
|
+
products;
|
|
5723
|
+
};
|
|
5724
|
+
__decorateClass([
|
|
5725
|
+
PrimaryGeneratedColumn27()
|
|
5726
|
+
], Collection.prototype, "id", 2);
|
|
5727
|
+
__decorateClass([
|
|
5728
|
+
Column27("int", { nullable: true })
|
|
5729
|
+
], Collection.prototype, "categoryId", 2);
|
|
5730
|
+
__decorateClass([
|
|
5731
|
+
Column27("int", { nullable: true })
|
|
5732
|
+
], Collection.prototype, "brandId", 2);
|
|
5733
|
+
__decorateClass([
|
|
5734
|
+
Column27("varchar")
|
|
5735
|
+
], Collection.prototype, "name", 2);
|
|
5736
|
+
__decorateClass([
|
|
5737
|
+
Column27("varchar", { unique: true })
|
|
5738
|
+
], Collection.prototype, "slug", 2);
|
|
5739
|
+
__decorateClass([
|
|
5740
|
+
Column27("varchar", { nullable: true })
|
|
5741
|
+
], Collection.prototype, "hsn", 2);
|
|
5742
|
+
__decorateClass([
|
|
5743
|
+
Column27("text", { nullable: true })
|
|
5744
|
+
], Collection.prototype, "description", 2);
|
|
5745
|
+
__decorateClass([
|
|
5746
|
+
Column27("varchar", { nullable: true })
|
|
5747
|
+
], Collection.prototype, "image", 2);
|
|
5748
|
+
__decorateClass([
|
|
5749
|
+
Column27("jsonb", { nullable: true })
|
|
5750
|
+
], Collection.prototype, "metadata", 2);
|
|
5751
|
+
__decorateClass([
|
|
5752
|
+
Column27("jsonb", { nullable: true })
|
|
5753
|
+
], Collection.prototype, "variants", 2);
|
|
5754
|
+
__decorateClass([
|
|
5755
|
+
Column27("boolean", { default: true })
|
|
5756
|
+
], Collection.prototype, "active", 2);
|
|
5757
|
+
__decorateClass([
|
|
5758
|
+
Column27("int", { default: 0 })
|
|
5759
|
+
], Collection.prototype, "sortOrder", 2);
|
|
5760
|
+
__decorateClass([
|
|
5761
|
+
Column27({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
5762
|
+
], Collection.prototype, "createdAt", 2);
|
|
5763
|
+
__decorateClass([
|
|
5764
|
+
Column27({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
5765
|
+
], Collection.prototype, "updatedAt", 2);
|
|
5766
|
+
__decorateClass([
|
|
5767
|
+
Column27({ type: "timestamp", nullable: true })
|
|
5768
|
+
], Collection.prototype, "deletedAt", 2);
|
|
5769
|
+
__decorateClass([
|
|
5770
|
+
Column27("boolean", { default: false })
|
|
5771
|
+
], Collection.prototype, "deleted", 2);
|
|
5772
|
+
__decorateClass([
|
|
5773
|
+
Column27("int", { nullable: true })
|
|
5774
|
+
], Collection.prototype, "createdBy", 2);
|
|
5775
|
+
__decorateClass([
|
|
5776
|
+
Column27("int", { nullable: true })
|
|
5777
|
+
], Collection.prototype, "updatedBy", 2);
|
|
5778
|
+
__decorateClass([
|
|
5779
|
+
Column27("int", { nullable: true })
|
|
5780
|
+
], Collection.prototype, "deletedBy", 2);
|
|
5781
|
+
__decorateClass([
|
|
5782
|
+
Column27("int", { nullable: true })
|
|
5783
|
+
], Collection.prototype, "seoId", 2);
|
|
5784
|
+
__decorateClass([
|
|
5785
|
+
ManyToOne17(() => Seo, { onDelete: "SET NULL" }),
|
|
5786
|
+
JoinColumn17({ name: "seoId" })
|
|
5787
|
+
], Collection.prototype, "seo", 2);
|
|
5788
|
+
__decorateClass([
|
|
5789
|
+
ManyToOne17(() => ProductCategory, (c) => c.collections, { onDelete: "SET NULL" }),
|
|
5790
|
+
JoinColumn17({ name: "categoryId" })
|
|
5791
|
+
], Collection.prototype, "category", 2);
|
|
5792
|
+
__decorateClass([
|
|
5793
|
+
ManyToOne17(() => Brand, (b) => b.collections, { onDelete: "SET NULL" }),
|
|
5794
|
+
JoinColumn17({ name: "brandId" })
|
|
5795
|
+
], Collection.prototype, "brand", 2);
|
|
5796
|
+
__decorateClass([
|
|
5797
|
+
OneToMany12("Product", "collection")
|
|
5798
|
+
], Collection.prototype, "products", 2);
|
|
5799
|
+
Collection = __decorateClass([
|
|
5800
|
+
Entity27("collections")
|
|
5801
|
+
], Collection);
|
|
5802
|
+
|
|
5803
|
+
// src/entities/product.entity.ts
|
|
5804
|
+
import { Entity as Entity28, PrimaryGeneratedColumn as PrimaryGeneratedColumn28, Column as Column28, ManyToOne as ManyToOne18, OneToMany as OneToMany13, JoinColumn as JoinColumn18 } from "typeorm";
|
|
5805
|
+
var Product = class {
|
|
5806
|
+
id;
|
|
5807
|
+
collectionId;
|
|
5808
|
+
brandId;
|
|
5809
|
+
categoryId;
|
|
5810
|
+
sku;
|
|
5811
|
+
hsn;
|
|
5812
|
+
uom;
|
|
5813
|
+
type;
|
|
5814
|
+
slug;
|
|
5815
|
+
name;
|
|
5816
|
+
price;
|
|
5817
|
+
compareAtPrice;
|
|
5818
|
+
quantity;
|
|
5819
|
+
status;
|
|
5820
|
+
featured;
|
|
5821
|
+
metadata;
|
|
5822
|
+
createdAt;
|
|
5823
|
+
updatedAt;
|
|
5824
|
+
deletedAt;
|
|
5825
|
+
deleted;
|
|
5826
|
+
createdBy;
|
|
5827
|
+
updatedBy;
|
|
5828
|
+
deletedBy;
|
|
5829
|
+
seoId;
|
|
5830
|
+
seo;
|
|
5831
|
+
collection;
|
|
5832
|
+
brand;
|
|
5833
|
+
category;
|
|
5834
|
+
attributes;
|
|
5835
|
+
taxes;
|
|
5836
|
+
};
|
|
5837
|
+
__decorateClass([
|
|
5838
|
+
PrimaryGeneratedColumn28()
|
|
5839
|
+
], Product.prototype, "id", 2);
|
|
5840
|
+
__decorateClass([
|
|
5841
|
+
Column28("int", { nullable: true })
|
|
5842
|
+
], Product.prototype, "collectionId", 2);
|
|
5843
|
+
__decorateClass([
|
|
5844
|
+
Column28("int", { nullable: true })
|
|
5845
|
+
], Product.prototype, "brandId", 2);
|
|
5846
|
+
__decorateClass([
|
|
5847
|
+
Column28("int", { nullable: true })
|
|
5848
|
+
], Product.prototype, "categoryId", 2);
|
|
5849
|
+
__decorateClass([
|
|
5850
|
+
Column28("varchar", { nullable: true })
|
|
5851
|
+
], Product.prototype, "sku", 2);
|
|
5852
|
+
__decorateClass([
|
|
5853
|
+
Column28("varchar", { nullable: true })
|
|
5854
|
+
], Product.prototype, "hsn", 2);
|
|
5855
|
+
__decorateClass([
|
|
5856
|
+
Column28("varchar", { nullable: true })
|
|
5857
|
+
], Product.prototype, "uom", 2);
|
|
5858
|
+
__decorateClass([
|
|
5859
|
+
Column28("varchar", { default: "product" })
|
|
5860
|
+
], Product.prototype, "type", 2);
|
|
5861
|
+
__decorateClass([
|
|
5862
|
+
Column28("varchar", { unique: true, nullable: true })
|
|
5863
|
+
], Product.prototype, "slug", 2);
|
|
5864
|
+
__decorateClass([
|
|
5865
|
+
Column28("varchar", { nullable: true })
|
|
5866
|
+
], Product.prototype, "name", 2);
|
|
5867
|
+
__decorateClass([
|
|
5868
|
+
Column28("decimal", { precision: 12, scale: 2 })
|
|
5869
|
+
], Product.prototype, "price", 2);
|
|
5870
|
+
__decorateClass([
|
|
5871
|
+
Column28("decimal", { precision: 12, scale: 2, nullable: true })
|
|
5872
|
+
], Product.prototype, "compareAtPrice", 2);
|
|
5873
|
+
__decorateClass([
|
|
5874
|
+
Column28("int", { default: 0 })
|
|
5875
|
+
], Product.prototype, "quantity", 2);
|
|
5876
|
+
__decorateClass([
|
|
5877
|
+
Column28("varchar", { default: "draft" })
|
|
5878
|
+
], Product.prototype, "status", 2);
|
|
5879
|
+
__decorateClass([
|
|
5880
|
+
Column28("boolean", { default: false })
|
|
5881
|
+
], Product.prototype, "featured", 2);
|
|
5882
|
+
__decorateClass([
|
|
5883
|
+
Column28("jsonb", { nullable: true })
|
|
5884
|
+
], Product.prototype, "metadata", 2);
|
|
5885
|
+
__decorateClass([
|
|
5886
|
+
Column28({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
5887
|
+
], Product.prototype, "createdAt", 2);
|
|
5888
|
+
__decorateClass([
|
|
5889
|
+
Column28({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
5890
|
+
], Product.prototype, "updatedAt", 2);
|
|
5891
|
+
__decorateClass([
|
|
5892
|
+
Column28({ type: "timestamp", nullable: true })
|
|
5893
|
+
], Product.prototype, "deletedAt", 2);
|
|
5894
|
+
__decorateClass([
|
|
5895
|
+
Column28("boolean", { default: false })
|
|
5896
|
+
], Product.prototype, "deleted", 2);
|
|
5897
|
+
__decorateClass([
|
|
5898
|
+
Column28("int", { nullable: true })
|
|
5899
|
+
], Product.prototype, "createdBy", 2);
|
|
5900
|
+
__decorateClass([
|
|
5901
|
+
Column28("int", { nullable: true })
|
|
5902
|
+
], Product.prototype, "updatedBy", 2);
|
|
5903
|
+
__decorateClass([
|
|
5904
|
+
Column28("int", { nullable: true })
|
|
5905
|
+
], Product.prototype, "deletedBy", 2);
|
|
5906
|
+
__decorateClass([
|
|
5907
|
+
Column28("int", { nullable: true })
|
|
5908
|
+
], Product.prototype, "seoId", 2);
|
|
5909
|
+
__decorateClass([
|
|
5910
|
+
ManyToOne18(() => Seo, { onDelete: "SET NULL" }),
|
|
5911
|
+
JoinColumn18({ name: "seoId" })
|
|
5912
|
+
], Product.prototype, "seo", 2);
|
|
5913
|
+
__decorateClass([
|
|
5914
|
+
ManyToOne18(() => Collection, (c) => c.products, { onDelete: "SET NULL" }),
|
|
5915
|
+
JoinColumn18({ name: "collectionId" })
|
|
5916
|
+
], Product.prototype, "collection", 2);
|
|
5917
|
+
__decorateClass([
|
|
5918
|
+
ManyToOne18(() => Brand, (b) => b.products, { onDelete: "SET NULL" }),
|
|
5919
|
+
JoinColumn18({ name: "brandId" })
|
|
5920
|
+
], Product.prototype, "brand", 2);
|
|
5921
|
+
__decorateClass([
|
|
5922
|
+
ManyToOne18(() => ProductCategory, (c) => c.products, { onDelete: "SET NULL" }),
|
|
5923
|
+
JoinColumn18({ name: "categoryId" })
|
|
5924
|
+
], Product.prototype, "category", 2);
|
|
5925
|
+
__decorateClass([
|
|
5926
|
+
OneToMany13("ProductAttribute", "product")
|
|
5927
|
+
], Product.prototype, "attributes", 2);
|
|
5928
|
+
__decorateClass([
|
|
5929
|
+
OneToMany13("ProductTax", "product")
|
|
5930
|
+
], Product.prototype, "taxes", 2);
|
|
5931
|
+
Product = __decorateClass([
|
|
5932
|
+
Entity28("products")
|
|
5933
|
+
], Product);
|
|
5934
|
+
|
|
5935
|
+
// src/entities/attribute.entity.ts
|
|
5936
|
+
import { Entity as Entity29, PrimaryGeneratedColumn as PrimaryGeneratedColumn29, Column as Column29 } from "typeorm";
|
|
5937
|
+
var Attribute = class {
|
|
5938
|
+
id;
|
|
5939
|
+
name;
|
|
5940
|
+
slug;
|
|
5941
|
+
type;
|
|
5942
|
+
options;
|
|
5943
|
+
metadata;
|
|
5944
|
+
active;
|
|
5945
|
+
sortOrder;
|
|
5946
|
+
createdAt;
|
|
5947
|
+
updatedAt;
|
|
5948
|
+
deletedAt;
|
|
5949
|
+
deleted;
|
|
5950
|
+
createdBy;
|
|
5951
|
+
updatedBy;
|
|
5952
|
+
deletedBy;
|
|
5953
|
+
};
|
|
5954
|
+
__decorateClass([
|
|
5955
|
+
PrimaryGeneratedColumn29()
|
|
5956
|
+
], Attribute.prototype, "id", 2);
|
|
5957
|
+
__decorateClass([
|
|
5958
|
+
Column29("varchar")
|
|
5959
|
+
], Attribute.prototype, "name", 2);
|
|
5960
|
+
__decorateClass([
|
|
5961
|
+
Column29("varchar", { unique: true })
|
|
5962
|
+
], Attribute.prototype, "slug", 2);
|
|
5963
|
+
__decorateClass([
|
|
5964
|
+
Column29("varchar", { default: "text" })
|
|
5965
|
+
], Attribute.prototype, "type", 2);
|
|
5966
|
+
__decorateClass([
|
|
5967
|
+
Column29("jsonb", { nullable: true })
|
|
5968
|
+
], Attribute.prototype, "options", 2);
|
|
5969
|
+
__decorateClass([
|
|
5970
|
+
Column29("jsonb", { nullable: true })
|
|
5971
|
+
], Attribute.prototype, "metadata", 2);
|
|
5972
|
+
__decorateClass([
|
|
5973
|
+
Column29("boolean", { default: true })
|
|
5974
|
+
], Attribute.prototype, "active", 2);
|
|
5975
|
+
__decorateClass([
|
|
5976
|
+
Column29("int", { default: 0 })
|
|
5977
|
+
], Attribute.prototype, "sortOrder", 2);
|
|
5978
|
+
__decorateClass([
|
|
5979
|
+
Column29({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
5980
|
+
], Attribute.prototype, "createdAt", 2);
|
|
5981
|
+
__decorateClass([
|
|
5982
|
+
Column29({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
5983
|
+
], Attribute.prototype, "updatedAt", 2);
|
|
5984
|
+
__decorateClass([
|
|
5985
|
+
Column29({ type: "timestamp", nullable: true })
|
|
5986
|
+
], Attribute.prototype, "deletedAt", 2);
|
|
5987
|
+
__decorateClass([
|
|
5988
|
+
Column29("boolean", { default: false })
|
|
5989
|
+
], Attribute.prototype, "deleted", 2);
|
|
5990
|
+
__decorateClass([
|
|
5991
|
+
Column29("int", { nullable: true })
|
|
5992
|
+
], Attribute.prototype, "createdBy", 2);
|
|
5993
|
+
__decorateClass([
|
|
5994
|
+
Column29("int", { nullable: true })
|
|
5995
|
+
], Attribute.prototype, "updatedBy", 2);
|
|
5996
|
+
__decorateClass([
|
|
5997
|
+
Column29("int", { nullable: true })
|
|
5998
|
+
], Attribute.prototype, "deletedBy", 2);
|
|
5999
|
+
Attribute = __decorateClass([
|
|
6000
|
+
Entity29("attributes")
|
|
6001
|
+
], Attribute);
|
|
6002
|
+
|
|
6003
|
+
// src/entities/product-attribute.entity.ts
|
|
6004
|
+
import { Entity as Entity30, PrimaryGeneratedColumn as PrimaryGeneratedColumn30, Column as Column30, ManyToOne as ManyToOne19, JoinColumn as JoinColumn19 } from "typeorm";
|
|
6005
|
+
var ProductAttribute = class {
|
|
6006
|
+
id;
|
|
6007
|
+
productId;
|
|
6008
|
+
attributeId;
|
|
6009
|
+
value;
|
|
6010
|
+
metadata;
|
|
6011
|
+
createdAt;
|
|
6012
|
+
updatedAt;
|
|
6013
|
+
product;
|
|
6014
|
+
attribute;
|
|
6015
|
+
};
|
|
6016
|
+
__decorateClass([
|
|
6017
|
+
PrimaryGeneratedColumn30()
|
|
6018
|
+
], ProductAttribute.prototype, "id", 2);
|
|
6019
|
+
__decorateClass([
|
|
6020
|
+
Column30("int")
|
|
6021
|
+
], ProductAttribute.prototype, "productId", 2);
|
|
6022
|
+
__decorateClass([
|
|
6023
|
+
Column30("int")
|
|
6024
|
+
], ProductAttribute.prototype, "attributeId", 2);
|
|
6025
|
+
__decorateClass([
|
|
6026
|
+
Column30("varchar")
|
|
6027
|
+
], ProductAttribute.prototype, "value", 2);
|
|
6028
|
+
__decorateClass([
|
|
6029
|
+
Column30("jsonb", { nullable: true })
|
|
6030
|
+
], ProductAttribute.prototype, "metadata", 2);
|
|
6031
|
+
__decorateClass([
|
|
6032
|
+
Column30({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
6033
|
+
], ProductAttribute.prototype, "createdAt", 2);
|
|
6034
|
+
__decorateClass([
|
|
6035
|
+
Column30({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
6036
|
+
], ProductAttribute.prototype, "updatedAt", 2);
|
|
6037
|
+
__decorateClass([
|
|
6038
|
+
ManyToOne19(() => Product, (p) => p.attributes, { onDelete: "CASCADE" }),
|
|
6039
|
+
JoinColumn19({ name: "productId" })
|
|
6040
|
+
], ProductAttribute.prototype, "product", 2);
|
|
6041
|
+
__decorateClass([
|
|
6042
|
+
ManyToOne19(() => Attribute, { onDelete: "CASCADE" }),
|
|
6043
|
+
JoinColumn19({ name: "attributeId" })
|
|
6044
|
+
], ProductAttribute.prototype, "attribute", 2);
|
|
6045
|
+
ProductAttribute = __decorateClass([
|
|
6046
|
+
Entity30("product_attributes")
|
|
6047
|
+
], ProductAttribute);
|
|
6048
|
+
|
|
6049
|
+
// src/entities/tax.entity.ts
|
|
6050
|
+
import { Entity as Entity31, PrimaryGeneratedColumn as PrimaryGeneratedColumn31, Column as Column31 } from "typeorm";
|
|
6051
|
+
var Tax = class {
|
|
6052
|
+
id;
|
|
6053
|
+
name;
|
|
6054
|
+
slug;
|
|
6055
|
+
rate;
|
|
6056
|
+
isDefault;
|
|
6057
|
+
description;
|
|
6058
|
+
active;
|
|
6059
|
+
metadata;
|
|
6060
|
+
createdAt;
|
|
6061
|
+
updatedAt;
|
|
6062
|
+
deletedAt;
|
|
6063
|
+
deleted;
|
|
6064
|
+
createdBy;
|
|
6065
|
+
updatedBy;
|
|
6066
|
+
deletedBy;
|
|
6067
|
+
};
|
|
6068
|
+
__decorateClass([
|
|
6069
|
+
PrimaryGeneratedColumn31()
|
|
6070
|
+
], Tax.prototype, "id", 2);
|
|
6071
|
+
__decorateClass([
|
|
6072
|
+
Column31("varchar")
|
|
6073
|
+
], Tax.prototype, "name", 2);
|
|
6074
|
+
__decorateClass([
|
|
6075
|
+
Column31("varchar", { unique: true })
|
|
6076
|
+
], Tax.prototype, "slug", 2);
|
|
6077
|
+
__decorateClass([
|
|
6078
|
+
Column31("decimal", { precision: 5, scale: 2 })
|
|
6079
|
+
], Tax.prototype, "rate", 2);
|
|
6080
|
+
__decorateClass([
|
|
6081
|
+
Column31("boolean", { default: false })
|
|
6082
|
+
], Tax.prototype, "isDefault", 2);
|
|
6083
|
+
__decorateClass([
|
|
6084
|
+
Column31("text", { nullable: true })
|
|
6085
|
+
], Tax.prototype, "description", 2);
|
|
6086
|
+
__decorateClass([
|
|
6087
|
+
Column31("boolean", { default: true })
|
|
6088
|
+
], Tax.prototype, "active", 2);
|
|
6089
|
+
__decorateClass([
|
|
6090
|
+
Column31("jsonb", { nullable: true })
|
|
6091
|
+
], Tax.prototype, "metadata", 2);
|
|
6092
|
+
__decorateClass([
|
|
6093
|
+
Column31({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
6094
|
+
], Tax.prototype, "createdAt", 2);
|
|
6095
|
+
__decorateClass([
|
|
6096
|
+
Column31({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
6097
|
+
], Tax.prototype, "updatedAt", 2);
|
|
6098
|
+
__decorateClass([
|
|
6099
|
+
Column31({ type: "timestamp", nullable: true })
|
|
6100
|
+
], Tax.prototype, "deletedAt", 2);
|
|
6101
|
+
__decorateClass([
|
|
6102
|
+
Column31("boolean", { default: false })
|
|
6103
|
+
], Tax.prototype, "deleted", 2);
|
|
6104
|
+
__decorateClass([
|
|
6105
|
+
Column31("int", { nullable: true })
|
|
6106
|
+
], Tax.prototype, "createdBy", 2);
|
|
6107
|
+
__decorateClass([
|
|
6108
|
+
Column31("int", { nullable: true })
|
|
6109
|
+
], Tax.prototype, "updatedBy", 2);
|
|
6110
|
+
__decorateClass([
|
|
6111
|
+
Column31("int", { nullable: true })
|
|
6112
|
+
], Tax.prototype, "deletedBy", 2);
|
|
6113
|
+
Tax = __decorateClass([
|
|
6114
|
+
Entity31("taxes")
|
|
6115
|
+
], Tax);
|
|
6116
|
+
|
|
6117
|
+
// src/entities/product-tax.entity.ts
|
|
6118
|
+
import { Entity as Entity32, PrimaryGeneratedColumn as PrimaryGeneratedColumn32, Column as Column32, ManyToOne as ManyToOne20, JoinColumn as JoinColumn20 } from "typeorm";
|
|
6119
|
+
var ProductTax = class {
|
|
6120
|
+
id;
|
|
6121
|
+
productId;
|
|
6122
|
+
taxId;
|
|
6123
|
+
rate;
|
|
6124
|
+
createdAt;
|
|
6125
|
+
updatedAt;
|
|
6126
|
+
product;
|
|
6127
|
+
tax;
|
|
6128
|
+
};
|
|
6129
|
+
__decorateClass([
|
|
6130
|
+
PrimaryGeneratedColumn32()
|
|
6131
|
+
], ProductTax.prototype, "id", 2);
|
|
6132
|
+
__decorateClass([
|
|
6133
|
+
Column32("int")
|
|
6134
|
+
], ProductTax.prototype, "productId", 2);
|
|
6135
|
+
__decorateClass([
|
|
6136
|
+
Column32("int")
|
|
6137
|
+
], ProductTax.prototype, "taxId", 2);
|
|
6138
|
+
__decorateClass([
|
|
6139
|
+
Column32("decimal", { precision: 5, scale: 2, nullable: true })
|
|
6140
|
+
], ProductTax.prototype, "rate", 2);
|
|
6141
|
+
__decorateClass([
|
|
6142
|
+
Column32({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
6143
|
+
], ProductTax.prototype, "createdAt", 2);
|
|
6144
|
+
__decorateClass([
|
|
6145
|
+
Column32({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
6146
|
+
], ProductTax.prototype, "updatedAt", 2);
|
|
6147
|
+
__decorateClass([
|
|
6148
|
+
ManyToOne20(() => Product, (p) => p.taxes, { onDelete: "CASCADE" }),
|
|
6149
|
+
JoinColumn20({ name: "productId" })
|
|
6150
|
+
], ProductTax.prototype, "product", 2);
|
|
6151
|
+
__decorateClass([
|
|
6152
|
+
ManyToOne20(() => Tax, { onDelete: "CASCADE" }),
|
|
6153
|
+
JoinColumn20({ name: "taxId" })
|
|
6154
|
+
], ProductTax.prototype, "tax", 2);
|
|
6155
|
+
ProductTax = __decorateClass([
|
|
6156
|
+
Entity32("product_taxes")
|
|
6157
|
+
], ProductTax);
|
|
6158
|
+
|
|
6159
|
+
// src/entities/order-item.entity.ts
|
|
6160
|
+
import { Entity as Entity33, PrimaryGeneratedColumn as PrimaryGeneratedColumn33, Column as Column33, ManyToOne as ManyToOne21, JoinColumn as JoinColumn21 } from "typeorm";
|
|
6161
|
+
var OrderItem = class {
|
|
6162
|
+
id;
|
|
6163
|
+
orderId;
|
|
6164
|
+
productId;
|
|
6165
|
+
quantity;
|
|
6166
|
+
unitPrice;
|
|
6167
|
+
tax;
|
|
6168
|
+
total;
|
|
6169
|
+
hsn;
|
|
6170
|
+
uom;
|
|
6171
|
+
productType;
|
|
6172
|
+
taxRate;
|
|
6173
|
+
taxCode;
|
|
6174
|
+
metadata;
|
|
6175
|
+
createdAt;
|
|
6176
|
+
updatedAt;
|
|
6177
|
+
order;
|
|
6178
|
+
product;
|
|
6179
|
+
};
|
|
6180
|
+
__decorateClass([
|
|
6181
|
+
PrimaryGeneratedColumn33()
|
|
6182
|
+
], OrderItem.prototype, "id", 2);
|
|
6183
|
+
__decorateClass([
|
|
6184
|
+
Column33("int")
|
|
6185
|
+
], OrderItem.prototype, "orderId", 2);
|
|
6186
|
+
__decorateClass([
|
|
6187
|
+
Column33("int")
|
|
6188
|
+
], OrderItem.prototype, "productId", 2);
|
|
6189
|
+
__decorateClass([
|
|
6190
|
+
Column33("int", { default: 1 })
|
|
6191
|
+
], OrderItem.prototype, "quantity", 2);
|
|
6192
|
+
__decorateClass([
|
|
6193
|
+
Column33("decimal", { precision: 12, scale: 2 })
|
|
6194
|
+
], OrderItem.prototype, "unitPrice", 2);
|
|
6195
|
+
__decorateClass([
|
|
6196
|
+
Column33("decimal", { precision: 12, scale: 2, default: 0 })
|
|
6197
|
+
], OrderItem.prototype, "tax", 2);
|
|
6198
|
+
__decorateClass([
|
|
6199
|
+
Column33("decimal", { precision: 12, scale: 2 })
|
|
6200
|
+
], OrderItem.prototype, "total", 2);
|
|
6201
|
+
__decorateClass([
|
|
6202
|
+
Column33("varchar", { nullable: true })
|
|
6203
|
+
], OrderItem.prototype, "hsn", 2);
|
|
6204
|
+
__decorateClass([
|
|
6205
|
+
Column33("varchar", { nullable: true })
|
|
6206
|
+
], OrderItem.prototype, "uom", 2);
|
|
6207
|
+
__decorateClass([
|
|
6208
|
+
Column33("varchar", { nullable: true })
|
|
6209
|
+
], OrderItem.prototype, "productType", 2);
|
|
6210
|
+
__decorateClass([
|
|
6211
|
+
Column33("decimal", { precision: 5, scale: 2, nullable: true })
|
|
6212
|
+
], OrderItem.prototype, "taxRate", 2);
|
|
6213
|
+
__decorateClass([
|
|
6214
|
+
Column33("varchar", { nullable: true })
|
|
6215
|
+
], OrderItem.prototype, "taxCode", 2);
|
|
6216
|
+
__decorateClass([
|
|
6217
|
+
Column33("jsonb", { nullable: true })
|
|
6218
|
+
], OrderItem.prototype, "metadata", 2);
|
|
6219
|
+
__decorateClass([
|
|
6220
|
+
Column33({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
6221
|
+
], OrderItem.prototype, "createdAt", 2);
|
|
6222
|
+
__decorateClass([
|
|
6223
|
+
Column33({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
6224
|
+
], OrderItem.prototype, "updatedAt", 2);
|
|
6225
|
+
__decorateClass([
|
|
6226
|
+
ManyToOne21(() => Order, (o) => o.items, { onDelete: "CASCADE" }),
|
|
6227
|
+
JoinColumn21({ name: "orderId" })
|
|
6228
|
+
], OrderItem.prototype, "order", 2);
|
|
6229
|
+
__decorateClass([
|
|
6230
|
+
ManyToOne21(() => Product, { onDelete: "CASCADE" }),
|
|
6231
|
+
JoinColumn21({ name: "productId" })
|
|
6232
|
+
], OrderItem.prototype, "product", 2);
|
|
6233
|
+
OrderItem = __decorateClass([
|
|
6234
|
+
Entity33("order_items")
|
|
6235
|
+
], OrderItem);
|
|
6236
|
+
|
|
6237
|
+
// src/entities/knowledge-base-document.entity.ts
|
|
6238
|
+
import { Entity as Entity35, PrimaryGeneratedColumn as PrimaryGeneratedColumn35, Column as Column35, OneToMany as OneToMany14 } from "typeorm";
|
|
6239
|
+
|
|
6240
|
+
// src/entities/knowledge-base-chunk.entity.ts
|
|
6241
|
+
import { Entity as Entity34, PrimaryGeneratedColumn as PrimaryGeneratedColumn34, Column as Column34, ManyToOne as ManyToOne22, JoinColumn as JoinColumn22 } from "typeorm";
|
|
6242
|
+
var KnowledgeBaseChunk = class {
|
|
6243
|
+
id;
|
|
6244
|
+
documentId;
|
|
6245
|
+
content;
|
|
6246
|
+
chunkIndex;
|
|
6247
|
+
createdAt;
|
|
6248
|
+
document;
|
|
6249
|
+
};
|
|
6250
|
+
__decorateClass([
|
|
6251
|
+
PrimaryGeneratedColumn34()
|
|
6252
|
+
], KnowledgeBaseChunk.prototype, "id", 2);
|
|
6253
|
+
__decorateClass([
|
|
6254
|
+
Column34("int")
|
|
6255
|
+
], KnowledgeBaseChunk.prototype, "documentId", 2);
|
|
6256
|
+
__decorateClass([
|
|
6257
|
+
Column34("text")
|
|
6258
|
+
], KnowledgeBaseChunk.prototype, "content", 2);
|
|
6259
|
+
__decorateClass([
|
|
6260
|
+
Column34("int", { default: 0 })
|
|
6261
|
+
], KnowledgeBaseChunk.prototype, "chunkIndex", 2);
|
|
6262
|
+
__decorateClass([
|
|
6263
|
+
Column34({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
6264
|
+
], KnowledgeBaseChunk.prototype, "createdAt", 2);
|
|
6265
|
+
__decorateClass([
|
|
6266
|
+
ManyToOne22(() => KnowledgeBaseDocument, (d) => d.chunks, { onDelete: "CASCADE" }),
|
|
6267
|
+
JoinColumn22({ name: "documentId" })
|
|
6268
|
+
], KnowledgeBaseChunk.prototype, "document", 2);
|
|
6269
|
+
KnowledgeBaseChunk = __decorateClass([
|
|
6270
|
+
Entity34("knowledge_base_chunks")
|
|
6271
|
+
], KnowledgeBaseChunk);
|
|
6272
|
+
|
|
6273
|
+
// src/entities/knowledge-base-document.entity.ts
|
|
6274
|
+
var KnowledgeBaseDocument = class {
|
|
6275
|
+
id;
|
|
6276
|
+
name;
|
|
6277
|
+
sourceUrl;
|
|
6278
|
+
content;
|
|
6279
|
+
createdAt;
|
|
6280
|
+
updatedAt;
|
|
6281
|
+
chunks;
|
|
6282
|
+
};
|
|
6283
|
+
__decorateClass([
|
|
6284
|
+
PrimaryGeneratedColumn35()
|
|
6285
|
+
], KnowledgeBaseDocument.prototype, "id", 2);
|
|
6286
|
+
__decorateClass([
|
|
6287
|
+
Column35("varchar")
|
|
6288
|
+
], KnowledgeBaseDocument.prototype, "name", 2);
|
|
6289
|
+
__decorateClass([
|
|
6290
|
+
Column35("varchar", { nullable: true })
|
|
6291
|
+
], KnowledgeBaseDocument.prototype, "sourceUrl", 2);
|
|
6292
|
+
__decorateClass([
|
|
6293
|
+
Column35("text")
|
|
6294
|
+
], KnowledgeBaseDocument.prototype, "content", 2);
|
|
6295
|
+
__decorateClass([
|
|
6296
|
+
Column35({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
6297
|
+
], KnowledgeBaseDocument.prototype, "createdAt", 2);
|
|
6298
|
+
__decorateClass([
|
|
6299
|
+
Column35({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
6300
|
+
], KnowledgeBaseDocument.prototype, "updatedAt", 2);
|
|
6301
|
+
__decorateClass([
|
|
6302
|
+
OneToMany14(() => KnowledgeBaseChunk, (c) => c.document)
|
|
6303
|
+
], KnowledgeBaseDocument.prototype, "chunks", 2);
|
|
6304
|
+
KnowledgeBaseDocument = __decorateClass([
|
|
6305
|
+
Entity35("knowledge_base_documents")
|
|
6306
|
+
], KnowledgeBaseDocument);
|
|
6307
|
+
|
|
6308
|
+
// src/entities/cart.entity.ts
|
|
6309
|
+
import { Entity as Entity36, PrimaryGeneratedColumn as PrimaryGeneratedColumn36, Column as Column36, ManyToOne as ManyToOne23, OneToMany as OneToMany15, JoinColumn as JoinColumn23 } from "typeorm";
|
|
6310
|
+
var Cart = class {
|
|
6311
|
+
id;
|
|
6312
|
+
guestToken;
|
|
6313
|
+
contactId;
|
|
6314
|
+
currency;
|
|
6315
|
+
expiresAt;
|
|
6316
|
+
createdAt;
|
|
6317
|
+
updatedAt;
|
|
6318
|
+
contact;
|
|
6319
|
+
items;
|
|
6320
|
+
};
|
|
6321
|
+
__decorateClass([
|
|
6322
|
+
PrimaryGeneratedColumn36()
|
|
6323
|
+
], Cart.prototype, "id", 2);
|
|
6324
|
+
__decorateClass([
|
|
6325
|
+
Column36("varchar", { nullable: true })
|
|
6326
|
+
], Cart.prototype, "guestToken", 2);
|
|
6327
|
+
__decorateClass([
|
|
6328
|
+
Column36("int", { nullable: true })
|
|
6329
|
+
], Cart.prototype, "contactId", 2);
|
|
6330
|
+
__decorateClass([
|
|
6331
|
+
Column36("varchar", { default: "INR" })
|
|
6332
|
+
], Cart.prototype, "currency", 2);
|
|
6333
|
+
__decorateClass([
|
|
6334
|
+
Column36({ type: "timestamp", nullable: true })
|
|
6335
|
+
], Cart.prototype, "expiresAt", 2);
|
|
6336
|
+
__decorateClass([
|
|
6337
|
+
Column36({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
6338
|
+
], Cart.prototype, "createdAt", 2);
|
|
6339
|
+
__decorateClass([
|
|
6340
|
+
Column36({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
6341
|
+
], Cart.prototype, "updatedAt", 2);
|
|
6342
|
+
__decorateClass([
|
|
6343
|
+
ManyToOne23(() => Contact, { onDelete: "CASCADE" }),
|
|
6344
|
+
JoinColumn23({ name: "contactId" })
|
|
6345
|
+
], Cart.prototype, "contact", 2);
|
|
6346
|
+
__decorateClass([
|
|
6347
|
+
OneToMany15("CartItem", "cart")
|
|
6348
|
+
], Cart.prototype, "items", 2);
|
|
6349
|
+
Cart = __decorateClass([
|
|
6350
|
+
Entity36("carts")
|
|
6351
|
+
], Cart);
|
|
6352
|
+
|
|
6353
|
+
// src/entities/cart-item.entity.ts
|
|
6354
|
+
import { Entity as Entity37, PrimaryGeneratedColumn as PrimaryGeneratedColumn37, Column as Column37, ManyToOne as ManyToOne24, JoinColumn as JoinColumn24 } from "typeorm";
|
|
6355
|
+
var CartItem = class {
|
|
6356
|
+
id;
|
|
6357
|
+
cartId;
|
|
6358
|
+
productId;
|
|
6359
|
+
quantity;
|
|
6360
|
+
metadata;
|
|
6361
|
+
createdAt;
|
|
6362
|
+
updatedAt;
|
|
6363
|
+
cart;
|
|
6364
|
+
product;
|
|
6365
|
+
};
|
|
6366
|
+
__decorateClass([
|
|
6367
|
+
PrimaryGeneratedColumn37()
|
|
6368
|
+
], CartItem.prototype, "id", 2);
|
|
6369
|
+
__decorateClass([
|
|
6370
|
+
Column37("int")
|
|
6371
|
+
], CartItem.prototype, "cartId", 2);
|
|
6372
|
+
__decorateClass([
|
|
6373
|
+
Column37("int")
|
|
6374
|
+
], CartItem.prototype, "productId", 2);
|
|
6375
|
+
__decorateClass([
|
|
6376
|
+
Column37("int", { default: 1 })
|
|
6377
|
+
], CartItem.prototype, "quantity", 2);
|
|
6378
|
+
__decorateClass([
|
|
6379
|
+
Column37("jsonb", { nullable: true })
|
|
6380
|
+
], CartItem.prototype, "metadata", 2);
|
|
6381
|
+
__decorateClass([
|
|
6382
|
+
Column37({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
6383
|
+
], CartItem.prototype, "createdAt", 2);
|
|
6384
|
+
__decorateClass([
|
|
6385
|
+
Column37({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
6386
|
+
], CartItem.prototype, "updatedAt", 2);
|
|
6387
|
+
__decorateClass([
|
|
6388
|
+
ManyToOne24(() => Cart, (c) => c.items, { onDelete: "CASCADE" }),
|
|
6389
|
+
JoinColumn24({ name: "cartId" })
|
|
6390
|
+
], CartItem.prototype, "cart", 2);
|
|
6391
|
+
__decorateClass([
|
|
6392
|
+
ManyToOne24(() => Product, { onDelete: "CASCADE" }),
|
|
6393
|
+
JoinColumn24({ name: "productId" })
|
|
6394
|
+
], CartItem.prototype, "product", 2);
|
|
6395
|
+
CartItem = __decorateClass([
|
|
6396
|
+
Entity37("cart_items")
|
|
6397
|
+
], CartItem);
|
|
6398
|
+
|
|
6399
|
+
// src/entities/wishlist.entity.ts
|
|
6400
|
+
import { Entity as Entity38, PrimaryGeneratedColumn as PrimaryGeneratedColumn38, Column as Column38, ManyToOne as ManyToOne25, OneToMany as OneToMany16, JoinColumn as JoinColumn25 } from "typeorm";
|
|
6401
|
+
var Wishlist = class {
|
|
6402
|
+
id;
|
|
6403
|
+
guestId;
|
|
6404
|
+
contactId;
|
|
6405
|
+
name;
|
|
6406
|
+
createdAt;
|
|
6407
|
+
updatedAt;
|
|
6408
|
+
contact;
|
|
6409
|
+
items;
|
|
6410
|
+
};
|
|
6411
|
+
__decorateClass([
|
|
6412
|
+
PrimaryGeneratedColumn38()
|
|
6413
|
+
], Wishlist.prototype, "id", 2);
|
|
6414
|
+
__decorateClass([
|
|
6415
|
+
Column38("varchar", { nullable: true })
|
|
6416
|
+
], Wishlist.prototype, "guestId", 2);
|
|
6417
|
+
__decorateClass([
|
|
6418
|
+
Column38("int", { nullable: true })
|
|
6419
|
+
], Wishlist.prototype, "contactId", 2);
|
|
6420
|
+
__decorateClass([
|
|
6421
|
+
Column38("varchar", { default: "default" })
|
|
6422
|
+
], Wishlist.prototype, "name", 2);
|
|
6423
|
+
__decorateClass([
|
|
6424
|
+
Column38({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
6425
|
+
], Wishlist.prototype, "createdAt", 2);
|
|
6426
|
+
__decorateClass([
|
|
6427
|
+
Column38({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
6428
|
+
], Wishlist.prototype, "updatedAt", 2);
|
|
6429
|
+
__decorateClass([
|
|
6430
|
+
ManyToOne25(() => Contact, { onDelete: "CASCADE" }),
|
|
6431
|
+
JoinColumn25({ name: "contactId" })
|
|
6432
|
+
], Wishlist.prototype, "contact", 2);
|
|
6433
|
+
__decorateClass([
|
|
6434
|
+
OneToMany16("WishlistItem", "wishlist")
|
|
6435
|
+
], Wishlist.prototype, "items", 2);
|
|
6436
|
+
Wishlist = __decorateClass([
|
|
6437
|
+
Entity38("wishlists")
|
|
6438
|
+
], Wishlist);
|
|
6439
|
+
|
|
6440
|
+
// src/entities/wishlist-item.entity.ts
|
|
6441
|
+
import { Entity as Entity39, PrimaryGeneratedColumn as PrimaryGeneratedColumn39, Column as Column39, ManyToOne as ManyToOne26, JoinColumn as JoinColumn26 } from "typeorm";
|
|
6442
|
+
var WishlistItem = class {
|
|
6443
|
+
id;
|
|
6444
|
+
wishlistId;
|
|
6445
|
+
productId;
|
|
6446
|
+
metadata;
|
|
6447
|
+
createdAt;
|
|
6448
|
+
updatedAt;
|
|
6449
|
+
wishlist;
|
|
6450
|
+
product;
|
|
6451
|
+
};
|
|
6452
|
+
__decorateClass([
|
|
6453
|
+
PrimaryGeneratedColumn39()
|
|
6454
|
+
], WishlistItem.prototype, "id", 2);
|
|
6455
|
+
__decorateClass([
|
|
6456
|
+
Column39("int")
|
|
6457
|
+
], WishlistItem.prototype, "wishlistId", 2);
|
|
6458
|
+
__decorateClass([
|
|
6459
|
+
Column39("int")
|
|
6460
|
+
], WishlistItem.prototype, "productId", 2);
|
|
6461
|
+
__decorateClass([
|
|
6462
|
+
Column39("jsonb", { nullable: true })
|
|
6463
|
+
], WishlistItem.prototype, "metadata", 2);
|
|
6464
|
+
__decorateClass([
|
|
6465
|
+
Column39({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
6466
|
+
], WishlistItem.prototype, "createdAt", 2);
|
|
6467
|
+
__decorateClass([
|
|
6468
|
+
Column39({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
6469
|
+
], WishlistItem.prototype, "updatedAt", 2);
|
|
6470
|
+
__decorateClass([
|
|
6471
|
+
ManyToOne26(() => Wishlist, (w) => w.items, { onDelete: "CASCADE" }),
|
|
6472
|
+
JoinColumn26({ name: "wishlistId" })
|
|
6473
|
+
], WishlistItem.prototype, "wishlist", 2);
|
|
6474
|
+
__decorateClass([
|
|
6475
|
+
ManyToOne26(() => Product, { onDelete: "CASCADE" }),
|
|
6476
|
+
JoinColumn26({ name: "productId" })
|
|
6477
|
+
], WishlistItem.prototype, "product", 2);
|
|
6478
|
+
WishlistItem = __decorateClass([
|
|
6479
|
+
Entity39("wishlist_items")
|
|
6480
|
+
], WishlistItem);
|
|
6481
|
+
|
|
6482
|
+
// src/entities/llm-agent-knowledge-document.entity.ts
|
|
6483
|
+
import { Entity as Entity40, PrimaryGeneratedColumn as PrimaryGeneratedColumn40, Column as Column40, ManyToOne as ManyToOne27, JoinColumn as JoinColumn27, Index as Index2, Unique as Unique2 } from "typeorm";
|
|
6484
|
+
var LlmAgentKnowledgeDocument = class {
|
|
6485
|
+
id;
|
|
6486
|
+
agentId;
|
|
6487
|
+
documentId;
|
|
6488
|
+
createdAt;
|
|
6489
|
+
agent;
|
|
6490
|
+
document;
|
|
6491
|
+
};
|
|
6492
|
+
__decorateClass([
|
|
6493
|
+
PrimaryGeneratedColumn40()
|
|
6494
|
+
], LlmAgentKnowledgeDocument.prototype, "id", 2);
|
|
6495
|
+
__decorateClass([
|
|
6496
|
+
Column40("int")
|
|
6497
|
+
], LlmAgentKnowledgeDocument.prototype, "agentId", 2);
|
|
6498
|
+
__decorateClass([
|
|
6499
|
+
Column40("int")
|
|
6500
|
+
], LlmAgentKnowledgeDocument.prototype, "documentId", 2);
|
|
6501
|
+
__decorateClass([
|
|
6502
|
+
Column40({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
6503
|
+
], LlmAgentKnowledgeDocument.prototype, "createdAt", 2);
|
|
6504
|
+
__decorateClass([
|
|
6505
|
+
ManyToOne27(() => LlmAgent, { onDelete: "CASCADE" }),
|
|
6506
|
+
JoinColumn27({ name: "agentId" })
|
|
6507
|
+
], LlmAgentKnowledgeDocument.prototype, "agent", 2);
|
|
6508
|
+
__decorateClass([
|
|
6509
|
+
ManyToOne27(() => KnowledgeBaseDocument, { onDelete: "CASCADE" }),
|
|
6510
|
+
JoinColumn27({ name: "documentId" })
|
|
6511
|
+
], LlmAgentKnowledgeDocument.prototype, "document", 2);
|
|
6512
|
+
LlmAgentKnowledgeDocument = __decorateClass([
|
|
6513
|
+
Entity40("llm_agent_knowledge_documents"),
|
|
6514
|
+
Unique2("UQ_llm_agent_knowledge_agent_document", ["agentId", "documentId"]),
|
|
6515
|
+
Index2("IDX_llm_agent_knowledge_agent", ["agentId"])
|
|
6516
|
+
], LlmAgentKnowledgeDocument);
|
|
6517
|
+
|
|
6518
|
+
// src/entities/index.ts
|
|
6519
|
+
var CMS_ENTITY_MAP = {
|
|
6520
|
+
users: User,
|
|
6521
|
+
otp_challenges: OtpChallenge,
|
|
6522
|
+
password_reset_tokens: PasswordResetToken,
|
|
6523
|
+
user_groups: UserGroup,
|
|
6524
|
+
permissions: Permission,
|
|
6525
|
+
blogs: Blog,
|
|
6526
|
+
tags: Tag,
|
|
6527
|
+
categories: Category,
|
|
6528
|
+
comments: Comment,
|
|
6529
|
+
contacts: Contact,
|
|
6530
|
+
addresses: Address,
|
|
6531
|
+
forms: Form,
|
|
6532
|
+
form_fields: FormField,
|
|
6533
|
+
form_submissions: FormSubmission,
|
|
6534
|
+
seos: Seo,
|
|
6535
|
+
configs: Config,
|
|
6536
|
+
message_templates: MessageTemplate,
|
|
6537
|
+
media: Media,
|
|
6538
|
+
pages: Page,
|
|
6539
|
+
product_categories: ProductCategory,
|
|
6540
|
+
collections: Collection,
|
|
6541
|
+
products: Product,
|
|
6542
|
+
attributes: Attribute,
|
|
6543
|
+
product_attributes: ProductAttribute,
|
|
6544
|
+
taxes: Tax,
|
|
6545
|
+
product_taxes: ProductTax,
|
|
6546
|
+
orders: Order,
|
|
6547
|
+
order_items: OrderItem,
|
|
6548
|
+
payments: Payment,
|
|
6549
|
+
brands: Brand,
|
|
6550
|
+
knowledge_base_documents: KnowledgeBaseDocument,
|
|
6551
|
+
knowledge_base_chunks: KnowledgeBaseChunk,
|
|
6552
|
+
chat_conversations: ChatConversation,
|
|
6553
|
+
chat_messages: ChatMessage,
|
|
6554
|
+
carts: Cart,
|
|
6555
|
+
cart_items: CartItem,
|
|
6556
|
+
wishlists: Wishlist,
|
|
6557
|
+
wishlist_items: WishlistItem,
|
|
6558
|
+
llm_agents: LlmAgent,
|
|
6559
|
+
llm_agent_knowledge_documents: LlmAgentKnowledgeDocument
|
|
6560
|
+
};
|
|
6561
|
+
|
|
3037
6562
|
// src/api/cms-api-handler.ts
|
|
6563
|
+
var KNOWLEDGE_SUFFIX = "knowledge";
|
|
6564
|
+
var CMS_API_LOG = "[cms-api]";
|
|
6565
|
+
function withLlmKnowledgeEntityFallbacks(base) {
|
|
6566
|
+
const keys = [
|
|
6567
|
+
"llm_agents",
|
|
6568
|
+
"llm_agent_knowledge_documents",
|
|
6569
|
+
"knowledge_base_documents",
|
|
6570
|
+
"knowledge_base_chunks"
|
|
6571
|
+
];
|
|
6572
|
+
const patch = {};
|
|
6573
|
+
for (const key of keys) {
|
|
6574
|
+
if (!(key in base) || base[key] == null) {
|
|
6575
|
+
const fallback = CMS_ENTITY_MAP[key];
|
|
6576
|
+
if (fallback) patch[key] = fallback;
|
|
6577
|
+
}
|
|
6578
|
+
}
|
|
6579
|
+
const merged = Object.keys(patch).length > 0 ? { ...base, ...patch } : base;
|
|
6580
|
+
if (!merged.llm_agents) {
|
|
6581
|
+
const agent = CMS_ENTITY_MAP.llm_agents ?? LlmAgent;
|
|
6582
|
+
return { ...merged, llm_agents: agent };
|
|
6583
|
+
}
|
|
6584
|
+
return merged;
|
|
6585
|
+
}
|
|
6586
|
+
function matchLlmAgentKnowledgeRoute(path) {
|
|
6587
|
+
const p = path[0] === "api" ? path.slice(1) : path;
|
|
6588
|
+
if (p[0] !== "llm_agents" || p.length < 2) return null;
|
|
6589
|
+
const seg1 = p[1];
|
|
6590
|
+
if (!seg1) return null;
|
|
6591
|
+
if (p[2] === KNOWLEDGE_SUFFIX) {
|
|
6592
|
+
return {
|
|
6593
|
+
slug: seg1,
|
|
6594
|
+
documentId: p.length >= 4 ? p[3] : void 0
|
|
6595
|
+
};
|
|
6596
|
+
}
|
|
6597
|
+
if (seg1.endsWith(KNOWLEDGE_SUFFIX) && seg1.length > KNOWLEDGE_SUFFIX.length) {
|
|
6598
|
+
const slug = seg1.slice(0, -KNOWLEDGE_SUFFIX.length);
|
|
6599
|
+
if (!slug) return null;
|
|
6600
|
+
if (p.length === 2) return { slug, documentId: void 0 };
|
|
6601
|
+
if (p.length === 3) return { slug, documentId: p[2] };
|
|
6602
|
+
}
|
|
6603
|
+
return null;
|
|
6604
|
+
}
|
|
3038
6605
|
var DEFAULT_EXCLUDE = /* @__PURE__ */ new Set([
|
|
3039
6606
|
"users",
|
|
3040
6607
|
"password_reset_tokens",
|
|
@@ -3047,14 +6614,15 @@ var DEFAULT_EXCLUDE = /* @__PURE__ */ new Set([
|
|
|
3047
6614
|
"cart_items",
|
|
3048
6615
|
"wishlists",
|
|
3049
6616
|
"wishlist_items",
|
|
3050
|
-
"message_templates"
|
|
6617
|
+
"message_templates",
|
|
6618
|
+
"llm_agent_knowledge_documents"
|
|
3051
6619
|
]);
|
|
3052
6620
|
function createCmsApiHandler(config) {
|
|
3053
6621
|
const {
|
|
3054
6622
|
dataSource,
|
|
3055
|
-
entityMap,
|
|
6623
|
+
entityMap: rawEntityMap,
|
|
3056
6624
|
pathToModel = (s) => s,
|
|
3057
|
-
crudResources
|
|
6625
|
+
crudResources: crudResourcesOverride,
|
|
3058
6626
|
getCms,
|
|
3059
6627
|
userAuth: userAuthConfig,
|
|
3060
6628
|
dashboard,
|
|
@@ -3071,9 +6639,13 @@ function createCmsApiHandler(config) {
|
|
|
3071
6639
|
userProfile,
|
|
3072
6640
|
settings: settingsConfig,
|
|
3073
6641
|
chat: chatConfig,
|
|
6642
|
+
llmAgentKnowledge: llmAgentKnowledgeConfig,
|
|
3074
6643
|
requireEntityPermission: userRequireEntityPermission,
|
|
3075
6644
|
getSessionUser
|
|
3076
6645
|
} = config;
|
|
6646
|
+
const entityMap = withLlmKnowledgeEntityFallbacks(rawEntityMap);
|
|
6647
|
+
const baseCrudResources = crudResourcesOverride ?? Object.keys(entityMap).filter((k) => !DEFAULT_EXCLUDE.has(k));
|
|
6648
|
+
const crudResources = entityMap.llm_agents && !baseCrudResources.includes("llm_agents") ? [...baseCrudResources, "llm_agents"] : baseCrudResources;
|
|
3077
6649
|
const requireEntityPermissionEffective = userRequireEntityPermission ?? (async (_req, entity, action) => config.json({ error: "Forbidden", reason: "entity_rbac_required", entity, action }, { status: 403 }));
|
|
3078
6650
|
const analytics = analyticsConfig ?? (getCms ? {
|
|
3079
6651
|
json: config.json,
|
|
@@ -3178,12 +6750,25 @@ function createCmsApiHandler(config) {
|
|
|
3178
6750
|
requireEntityPermission: requireEntityPermissionEffective
|
|
3179
6751
|
});
|
|
3180
6752
|
const chatHandlers = chatConfig ? createChatHandlers(chatConfig) : null;
|
|
6753
|
+
const llmAgentKnowledgeMerged = llmAgentKnowledgeConfig ?? (chatConfig ? {
|
|
6754
|
+
dataSource: chatConfig.dataSource,
|
|
6755
|
+
entityMap: withLlmKnowledgeEntityFallbacks(chatConfig.entityMap ?? rawEntityMap),
|
|
6756
|
+
getCms: chatConfig.getCms,
|
|
6757
|
+
json: chatConfig.json,
|
|
6758
|
+
requireAuth: chatConfig.requireAuth
|
|
6759
|
+
} : void 0);
|
|
6760
|
+
const llmAgentKnowledgeHandlers = llmAgentKnowledgeMerged ? createLlmAgentKnowledgeHandlers({
|
|
6761
|
+
...llmAgentKnowledgeMerged,
|
|
6762
|
+
requireEntityPermission: requireEntityPermissionEffective
|
|
6763
|
+
}) : null;
|
|
3181
6764
|
function resolveResource(segment) {
|
|
3182
6765
|
const model = pathToModel(segment);
|
|
3183
6766
|
return crudResources.includes(model) ? model : segment;
|
|
3184
6767
|
}
|
|
3185
6768
|
return {
|
|
3186
|
-
async handle(method,
|
|
6769
|
+
async handle(method, pathInput, req) {
|
|
6770
|
+
const m = typeof method === "string" ? method.toUpperCase() : "GET";
|
|
6771
|
+
const path = pathInput.length > 0 && pathInput[0] === "api" ? pathInput.slice(1) : pathInput;
|
|
3187
6772
|
async function analyticsGate() {
|
|
3188
6773
|
const a = await config.requireAuth(req);
|
|
3189
6774
|
if (a) return a;
|
|
@@ -3191,86 +6776,86 @@ function createCmsApiHandler(config) {
|
|
|
3191
6776
|
}
|
|
3192
6777
|
if (path[0] === "admin" && path[1] === "roles") {
|
|
3193
6778
|
if (!adminRoles) return config.json({ error: "Not found" }, { status: 404 });
|
|
3194
|
-
if (path.length === 2 &&
|
|
3195
|
-
if (path.length === 2 &&
|
|
3196
|
-
if (path.length === 3 &&
|
|
3197
|
-
if (path.length === 3 &&
|
|
3198
|
-
if (path.length === 4 && path[3] === "permissions" &&
|
|
6779
|
+
if (path.length === 2 && m === "GET") return adminRoles.list();
|
|
6780
|
+
if (path.length === 2 && m === "POST") return adminRoles.createGroup(req);
|
|
6781
|
+
if (path.length === 3 && m === "PATCH") return adminRoles.patchGroup(req, path[2]);
|
|
6782
|
+
if (path.length === 3 && m === "DELETE") return adminRoles.deleteGroup(path[2]);
|
|
6783
|
+
if (path.length === 4 && path[3] === "permissions" && m === "PUT") return adminRoles.putPermissions(req, path[2]);
|
|
3199
6784
|
return config.json({ error: "Not found" }, { status: 404 });
|
|
3200
6785
|
}
|
|
3201
|
-
if (path[0] === "dashboard" && path[1] === "stats" && path.length === 2 &&
|
|
6786
|
+
if (path[0] === "dashboard" && path[1] === "stats" && path.length === 2 && m === "GET" && dashboardGet) {
|
|
3202
6787
|
return dashboardGet(req);
|
|
3203
6788
|
}
|
|
3204
|
-
if (path[0] === "dashboard" && path[1] === "ecommerce" && path.length === 2 &&
|
|
6789
|
+
if (path[0] === "dashboard" && path[1] === "ecommerce" && path.length === 2 && m === "GET" && ecommerceAnalyticsGet) {
|
|
3205
6790
|
const g = await analyticsGate();
|
|
3206
6791
|
if (g) return g;
|
|
3207
6792
|
return ecommerceAnalyticsGet(req);
|
|
3208
6793
|
}
|
|
3209
6794
|
if (path[0] === "analytics" && analyticsHandlers) {
|
|
3210
|
-
if (path.length === 1 &&
|
|
6795
|
+
if (path.length === 1 && m === "GET") {
|
|
3211
6796
|
const g = await analyticsGate();
|
|
3212
6797
|
if (g) return g;
|
|
3213
6798
|
return analyticsHandlers.GET(req);
|
|
3214
6799
|
}
|
|
3215
|
-
if (path.length === 2 && path[1] === "property-id" &&
|
|
6800
|
+
if (path.length === 2 && path[1] === "property-id" && m === "GET") {
|
|
3216
6801
|
const g = await analyticsGate();
|
|
3217
6802
|
if (g) return g;
|
|
3218
6803
|
return analyticsHandlers.propertyId();
|
|
3219
6804
|
}
|
|
3220
|
-
if (path.length === 2 && path[1] === "permissions" &&
|
|
6805
|
+
if (path.length === 2 && path[1] === "permissions" && m === "GET") {
|
|
3221
6806
|
const g = await analyticsGate();
|
|
3222
6807
|
if (g) return g;
|
|
3223
6808
|
return analyticsHandlers.permissions();
|
|
3224
6809
|
}
|
|
3225
6810
|
}
|
|
3226
|
-
if (path[0] === "upload" && path.length === 1 &&
|
|
3227
|
-
if (path[0] === "media" && path[1] === "extract" && path.length === 3 &&
|
|
6811
|
+
if (path[0] === "upload" && path.length === 1 && m === "POST" && uploadPost) return uploadPost(req);
|
|
6812
|
+
if (path[0] === "media" && path[1] === "extract" && path.length === 3 && m === "POST" && zipExtractPost) {
|
|
3228
6813
|
return zipExtractPost(req, path[2]);
|
|
3229
6814
|
}
|
|
3230
|
-
if (path[0] === "blogs" && path[1] === "slug" && path.length === 3 &&
|
|
6815
|
+
if (path[0] === "blogs" && path[1] === "slug" && path.length === 3 && m === "GET" && blogBySlugGet) {
|
|
3231
6816
|
return blogBySlugGet(req, path[2]);
|
|
3232
6817
|
}
|
|
3233
|
-
if (path[0] === "forms" && path[1] === "slug" && path.length === 3 &&
|
|
6818
|
+
if (path[0] === "forms" && path[1] === "slug" && path.length === 3 && m === "GET" && formBySlugGet) {
|
|
3234
6819
|
return formBySlugGet(req, path[2]);
|
|
3235
6820
|
}
|
|
3236
6821
|
if (path[0] === "form-submissions") {
|
|
3237
6822
|
if (path.length === 1) {
|
|
3238
|
-
if (
|
|
3239
|
-
if (
|
|
6823
|
+
if (m === "GET" && formSubmissionList) return formSubmissionList(req);
|
|
6824
|
+
if (m === "POST" && formSubmissionPost) return formSubmissionPost(req);
|
|
3240
6825
|
}
|
|
3241
|
-
if (path.length === 2 &&
|
|
6826
|
+
if (path.length === 2 && m === "GET" && formSubmissionGetById) return formSubmissionGetById(req, path[1]);
|
|
3242
6827
|
}
|
|
3243
6828
|
if (path[0] === "forms" && formSaveHandlers) {
|
|
3244
|
-
if (path.length === 1 &&
|
|
6829
|
+
if (path.length === 1 && m === "POST") return formSaveHandlers.POST(req);
|
|
3245
6830
|
if (path.length === 2) {
|
|
3246
|
-
if (
|
|
3247
|
-
if (
|
|
6831
|
+
if (m === "GET") return formSaveHandlers.GET(req, path[1]);
|
|
6832
|
+
if (m === "PUT" || m === "PATCH") return formSaveHandlers.PUT(req, path[1]);
|
|
3248
6833
|
}
|
|
3249
6834
|
}
|
|
3250
6835
|
if (path[0] === "users" && usersHandlers) {
|
|
3251
6836
|
if (path.length === 1) {
|
|
3252
|
-
if (
|
|
3253
|
-
if (
|
|
6837
|
+
if (m === "GET") return usersHandlers.list(req);
|
|
6838
|
+
if (m === "POST") return usersHandlers.create(req);
|
|
3254
6839
|
}
|
|
3255
6840
|
if (path.length === 2) {
|
|
3256
|
-
if (path[1] === "avatar" &&
|
|
3257
|
-
if (path[1] === "profile" &&
|
|
6841
|
+
if (path[1] === "avatar" && m === "POST" && avatarPost) return avatarPost(req);
|
|
6842
|
+
if (path[1] === "profile" && m === "PUT" && profilePut) return profilePut(req);
|
|
3258
6843
|
const id = path[1];
|
|
3259
|
-
if (
|
|
3260
|
-
if (
|
|
3261
|
-
if (
|
|
6844
|
+
if (m === "GET") return usersHandlers.getById(req, id);
|
|
6845
|
+
if (m === "PUT" || m === "PATCH") return usersHandlers.update(req, id);
|
|
6846
|
+
if (m === "DELETE") return usersHandlers.delete(req, id);
|
|
3262
6847
|
}
|
|
3263
|
-
if (path.length === 3 && path[2] === "regenerate-invite" &&
|
|
6848
|
+
if (path.length === 3 && path[2] === "regenerate-invite" && m === "POST") {
|
|
3264
6849
|
return usersHandlers.regenerateInvite(req, path[1]);
|
|
3265
6850
|
}
|
|
3266
6851
|
}
|
|
3267
|
-
if (path[0] === "users" && path.length === 2 && userAuthRouter &&
|
|
6852
|
+
if (path[0] === "users" && path.length === 2 && userAuthRouter && m === "POST") {
|
|
3268
6853
|
return userAuthRouter.POST(req, path[1]);
|
|
3269
6854
|
}
|
|
3270
6855
|
if (path[0] === "settings" && path.length === 2 && settingsHandlers) {
|
|
3271
6856
|
const group = path[1];
|
|
3272
6857
|
const isPublic = settingsConfig?.publicGetGroups?.includes(group);
|
|
3273
|
-
if (
|
|
6858
|
+
if (m === "GET") {
|
|
3274
6859
|
if (!isPublic) {
|
|
3275
6860
|
const a = await config.requireAuth(req);
|
|
3276
6861
|
if (a) return a;
|
|
@@ -3279,22 +6864,70 @@ function createCmsApiHandler(config) {
|
|
|
3279
6864
|
}
|
|
3280
6865
|
return settingsHandlers.GET(req, group);
|
|
3281
6866
|
}
|
|
3282
|
-
if (
|
|
6867
|
+
if (m === "PUT") {
|
|
3283
6868
|
const pe = await requireEntityPermissionEffective(req, "settings", "update");
|
|
3284
6869
|
if (pe) return pe;
|
|
3285
6870
|
return settingsHandlers.PUT(req, group);
|
|
3286
6871
|
}
|
|
3287
6872
|
}
|
|
3288
6873
|
if (path[0] === "message-templates" && path[1] === "sms" && path.length === 2) {
|
|
3289
|
-
if (
|
|
3290
|
-
if (
|
|
6874
|
+
if (m === "GET") return smsMessageTemplateHandlers.GET(req);
|
|
6875
|
+
if (m === "PUT") return smsMessageTemplateHandlers.PUT(req);
|
|
6876
|
+
}
|
|
6877
|
+
if (path[0] === "llm_agents") {
|
|
6878
|
+
if (!entityMap.llm_agents) {
|
|
6879
|
+
console.error(CMS_API_LOG, "llm_agents route: entity missing after merge", {
|
|
6880
|
+
method: m,
|
|
6881
|
+
pathJoined: path.join("/"),
|
|
6882
|
+
entityMapKeyCount: Object.keys(entityMap).length
|
|
6883
|
+
});
|
|
6884
|
+
return config.json(
|
|
6885
|
+
{ error: "LlmAgent entity is not registered", hint: "Ensure migrations ran and entities include LlmAgent." },
|
|
6886
|
+
{ status: 503 }
|
|
6887
|
+
);
|
|
6888
|
+
}
|
|
6889
|
+
if (path.length === 1) {
|
|
6890
|
+
if (m === "GET") return crud.GET(req, "llm_agents");
|
|
6891
|
+
if (m === "POST") return crud.POST(req, "llm_agents");
|
|
6892
|
+
}
|
|
6893
|
+
if (path.length === 2 && !path[1]?.includes("knowledge")) {
|
|
6894
|
+
const id = path[1];
|
|
6895
|
+
if (m === "GET") return crudById.GET(req, "llm_agents", id);
|
|
6896
|
+
if (m === "PUT" || m === "PATCH") return crudById.PUT(req, "llm_agents", id);
|
|
6897
|
+
if (m === "DELETE") return crudById.DELETE(req, "llm_agents", id);
|
|
6898
|
+
}
|
|
6899
|
+
}
|
|
6900
|
+
{
|
|
6901
|
+
const kbMatch = matchLlmAgentKnowledgeRoute(path);
|
|
6902
|
+
if (kbMatch) {
|
|
6903
|
+
if (!llmAgentKnowledgeHandlers) {
|
|
6904
|
+
return config.json(
|
|
6905
|
+
{
|
|
6906
|
+
error: "LLM agent knowledge is not available",
|
|
6907
|
+
hint: "With chat enabled, routes usually work automatically. Otherwise pass llmAgentKnowledge. If this persists, ensure entityMap includes knowledge_base_documents, knowledge_base_chunks, llm_agent_knowledge_documents, and run migrations."
|
|
6908
|
+
},
|
|
6909
|
+
{ status: 503 }
|
|
6910
|
+
);
|
|
6911
|
+
}
|
|
6912
|
+
const { slug, documentId } = kbMatch;
|
|
6913
|
+
if (m === "DELETE" && documentId != null && documentId !== "") {
|
|
6914
|
+
return llmAgentKnowledgeHandlers.unlink(req, slug, documentId);
|
|
6915
|
+
}
|
|
6916
|
+
if (m === "GET" && (documentId == null || documentId === "")) {
|
|
6917
|
+
return llmAgentKnowledgeHandlers.list(req, slug);
|
|
6918
|
+
}
|
|
6919
|
+
if (m === "POST" && (documentId == null || documentId === "")) {
|
|
6920
|
+
return llmAgentKnowledgeHandlers.post(req, slug);
|
|
6921
|
+
}
|
|
6922
|
+
}
|
|
3291
6923
|
}
|
|
3292
6924
|
if (path[0] === "chat" && chatHandlers) {
|
|
3293
|
-
if (path.length === 2 && path[1] === "
|
|
3294
|
-
if (path.length ===
|
|
3295
|
-
if (path.length ===
|
|
6925
|
+
if (path.length === 2 && path[1] === "config" && m === "GET") return chatHandlers.publicConfig(req);
|
|
6926
|
+
if (path.length === 2 && path[1] === "identify" && m === "POST") return chatHandlers.identify(req);
|
|
6927
|
+
if (path.length === 4 && path[1] === "conversations" && path[3] === "messages" && m === "GET") return chatHandlers.getMessages(req, path[2]);
|
|
6928
|
+
if (path.length === 2 && path[1] === "messages" && m === "POST") return chatHandlers.postMessage(req);
|
|
3296
6929
|
}
|
|
3297
|
-
if (path[0] === "orders" && path.length === 3 && path[2] === "invoice" &&
|
|
6930
|
+
if (path[0] === "orders" && path.length === 3 && path[2] === "invoice" && m === "GET" && getCms) {
|
|
3298
6931
|
const a = await config.requireAuth(req);
|
|
3299
6932
|
if (a) return a;
|
|
3300
6933
|
const pe = await requireEntityPermissionEffective(req, "orders", "read");
|
|
@@ -3308,17 +6941,17 @@ function createCmsApiHandler(config) {
|
|
|
3308
6941
|
if (path[0] === "orders" && path.length === 3 && path[2] === "repost-erp" && getCms) {
|
|
3309
6942
|
const a = await config.requireAuth(req);
|
|
3310
6943
|
if (a) return a;
|
|
3311
|
-
const pe = await requireEntityPermissionEffective(req, "orders",
|
|
6944
|
+
const pe = await requireEntityPermissionEffective(req, "orders", m === "GET" ? "read" : "update");
|
|
3312
6945
|
if (pe) return pe;
|
|
3313
6946
|
const oid = Number(path[1]);
|
|
3314
6947
|
if (!Number.isFinite(oid)) return config.json({ error: "Invalid id" }, { status: 400 });
|
|
3315
6948
|
const cms = await getCms();
|
|
3316
6949
|
const { isErpIntegrationEnabled: isErpIntegrationEnabled3 } = await Promise.resolve().then(() => (init_erp_config_enabled(), erp_config_enabled_exports));
|
|
3317
6950
|
const enabled = await isErpIntegrationEnabled3(cms, dataSource, entityMap);
|
|
3318
|
-
if (
|
|
6951
|
+
if (m === "GET") {
|
|
3319
6952
|
return config.json({ enabled });
|
|
3320
6953
|
}
|
|
3321
|
-
if (
|
|
6954
|
+
if (m === "POST") {
|
|
3322
6955
|
if (!enabled) return config.json({ error: "ERP integration is disabled" }, { status: 409 });
|
|
3323
6956
|
const { queueErpPaidOrderForOrderId: queueErpPaidOrderForOrderId2 } = await Promise.resolve().then(() => (init_paid_order_erp(), paid_order_erp_exports));
|
|
3324
6957
|
await queueErpPaidOrderForOrderId2(cms, dataSource, entityMap, oid);
|
|
@@ -3328,28 +6961,39 @@ function createCmsApiHandler(config) {
|
|
|
3328
6961
|
}
|
|
3329
6962
|
if (path.length === 0) return config.json({ error: "Not found" }, { status: 404 });
|
|
3330
6963
|
const resource = resolveResource(path[0]);
|
|
3331
|
-
if (!crudResources.includes(resource))
|
|
6964
|
+
if (!crudResources.includes(resource)) {
|
|
6965
|
+
console.warn(CMS_API_LOG, "generic CRUD gate: Invalid resource (not in crudResources)", {
|
|
6966
|
+
method: m,
|
|
6967
|
+
pathJoined: path.join("/"),
|
|
6968
|
+
pathSegments: path,
|
|
6969
|
+
resource,
|
|
6970
|
+
hasLlmAgentsEntity: Boolean(entityMap.llm_agents),
|
|
6971
|
+
crudResourcesHasResource: crudResources.includes(resource),
|
|
6972
|
+
crudResourcesLength: crudResources.length
|
|
6973
|
+
});
|
|
6974
|
+
return config.json({ error: "Invalid resource" }, { status: 400 });
|
|
6975
|
+
}
|
|
3332
6976
|
if (path.length === 2) {
|
|
3333
|
-
if (path[1] === "metadata" &&
|
|
6977
|
+
if (path[1] === "metadata" && m === "GET") {
|
|
3334
6978
|
return crud.GET_METADATA(req, resource);
|
|
3335
6979
|
}
|
|
3336
|
-
if (path[1] === "bulk" &&
|
|
6980
|
+
if (path[1] === "bulk" && m === "POST") {
|
|
3337
6981
|
return crud.BULK_POST(req, resource);
|
|
3338
6982
|
}
|
|
3339
|
-
if (path[1] === "export" &&
|
|
6983
|
+
if (path[1] === "export" && m === "GET") {
|
|
3340
6984
|
return crud.GET_EXPORT(req, resource);
|
|
3341
6985
|
}
|
|
3342
6986
|
}
|
|
3343
6987
|
if (path.length === 1) {
|
|
3344
|
-
if (
|
|
3345
|
-
if (
|
|
6988
|
+
if (m === "GET") return crud.GET(req, resource);
|
|
6989
|
+
if (m === "POST") return crud.POST(req, resource);
|
|
3346
6990
|
return config.json({ error: "Method not allowed" }, { status: 405 });
|
|
3347
6991
|
}
|
|
3348
6992
|
if (path.length === 2) {
|
|
3349
6993
|
const id = path[1];
|
|
3350
|
-
if (
|
|
3351
|
-
if (
|
|
3352
|
-
if (
|
|
6994
|
+
if (m === "GET") return crudById.GET(req, resource, id);
|
|
6995
|
+
if (m === "PUT" || m === "PATCH") return crudById.PUT(req, resource, id);
|
|
6996
|
+
if (m === "DELETE") return crudById.DELETE(req, resource, id);
|
|
3353
6997
|
return config.json({ error: "Method not allowed" }, { status: 405 });
|
|
3354
6998
|
}
|
|
3355
6999
|
return config.json({ error: "Not found" }, { status: 404 });
|
|
@@ -3358,7 +7002,7 @@ function createCmsApiHandler(config) {
|
|
|
3358
7002
|
}
|
|
3359
7003
|
|
|
3360
7004
|
// src/api/storefront-handlers.ts
|
|
3361
|
-
import { In as
|
|
7005
|
+
import { In as In3, IsNull as IsNull4 } from "typeorm";
|
|
3362
7006
|
|
|
3363
7007
|
// src/lib/is-valid-signup-email.ts
|
|
3364
7008
|
var MAX_EMAIL = 254;
|
|
@@ -4962,7 +8606,7 @@ function createStorefrontApiHandler(config) {
|
|
|
4962
8606
|
const previewByOrder = {};
|
|
4963
8607
|
if (orderIds.length) {
|
|
4964
8608
|
const oItems = await orderItemRepo().find({
|
|
4965
|
-
where: { orderId:
|
|
8609
|
+
where: { orderId: In3(orderIds) },
|
|
4966
8610
|
relations: ["product"],
|
|
4967
8611
|
order: { id: "ASC" }
|
|
4968
8612
|
});
|
|
@@ -5098,6 +8742,7 @@ export {
|
|
|
5098
8742
|
createForgotPasswordHandler,
|
|
5099
8743
|
createFormBySlugHandler,
|
|
5100
8744
|
createInviteAcceptHandler,
|
|
8745
|
+
createLlmAgentKnowledgeHandlers,
|
|
5101
8746
|
createMediaZipExtractHandler,
|
|
5102
8747
|
createSetPasswordHandler,
|
|
5103
8748
|
createSettingsApiHandlers,
|
|
@@ -5107,6 +8752,10 @@ export {
|
|
|
5107
8752
|
createUserAvatarHandler,
|
|
5108
8753
|
createUserProfileHandler,
|
|
5109
8754
|
createUsersApiHandlers,
|
|
5110
|
-
getPublicSettingsGroup
|
|
8755
|
+
getPublicSettingsGroup,
|
|
8756
|
+
mergeGuardrailsIntoSystemPrompt,
|
|
8757
|
+
parseLlmAgentValidationRules,
|
|
8758
|
+
validateUserMessageAgainstAgentRules,
|
|
8759
|
+
validateUserMessageAgainstStructuredRules
|
|
5111
8760
|
};
|
|
5112
8761
|
//# sourceMappingURL=api.js.map
|