@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.cjs
CHANGED
|
@@ -29,6 +29,14 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
29
29
|
mod
|
|
30
30
|
));
|
|
31
31
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
33
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
34
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
35
|
+
if (decorator = decorators[i])
|
|
36
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
37
|
+
if (kind && result) __defProp(target, key, result);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
32
40
|
|
|
33
41
|
// src/plugins/erp/erp-queue.ts
|
|
34
42
|
async function queueErp(cms, payload) {
|
|
@@ -432,6 +440,7 @@ __export(api_exports, {
|
|
|
432
440
|
createForgotPasswordHandler: () => createForgotPasswordHandler,
|
|
433
441
|
createFormBySlugHandler: () => createFormBySlugHandler,
|
|
434
442
|
createInviteAcceptHandler: () => createInviteAcceptHandler,
|
|
443
|
+
createLlmAgentKnowledgeHandlers: () => createLlmAgentKnowledgeHandlers,
|
|
435
444
|
createMediaZipExtractHandler: () => createMediaZipExtractHandler,
|
|
436
445
|
createSetPasswordHandler: () => createSetPasswordHandler,
|
|
437
446
|
createSettingsApiHandlers: () => createSettingsApiHandlers,
|
|
@@ -441,7 +450,11 @@ __export(api_exports, {
|
|
|
441
450
|
createUserAvatarHandler: () => createUserAvatarHandler,
|
|
442
451
|
createUserProfileHandler: () => createUserProfileHandler,
|
|
443
452
|
createUsersApiHandlers: () => createUsersApiHandlers,
|
|
444
|
-
getPublicSettingsGroup: () => getPublicSettingsGroup
|
|
453
|
+
getPublicSettingsGroup: () => getPublicSettingsGroup,
|
|
454
|
+
mergeGuardrailsIntoSystemPrompt: () => mergeGuardrailsIntoSystemPrompt,
|
|
455
|
+
parseLlmAgentValidationRules: () => parseLlmAgentValidationRules,
|
|
456
|
+
validateUserMessageAgainstAgentRules: () => validateUserMessageAgainstAgentRules,
|
|
457
|
+
validateUserMessageAgainstStructuredRules: () => validateUserMessageAgainstStructuredRules
|
|
445
458
|
});
|
|
446
459
|
module.exports = __toCommonJS(api_exports);
|
|
447
460
|
|
|
@@ -517,6 +530,13 @@ async function queueErpProductUpsertIfEnabled(cms, dataSource, entityMap, produc
|
|
|
517
530
|
}
|
|
518
531
|
|
|
519
532
|
// src/api/crud.ts
|
|
533
|
+
var CRUD_LOG = "[cms-crud]";
|
|
534
|
+
function logCrudClientError(op, detail) {
|
|
535
|
+
console.warn(CRUD_LOG, op, detail);
|
|
536
|
+
}
|
|
537
|
+
function logCrudServerError(op, detail) {
|
|
538
|
+
console.error(CRUD_LOG, op, detail);
|
|
539
|
+
}
|
|
520
540
|
var DATE_COLUMN_TYPES = /* @__PURE__ */ new Set([
|
|
521
541
|
"date",
|
|
522
542
|
"datetime",
|
|
@@ -628,6 +648,13 @@ function createCrudHandler(dataSource, entityMap, options) {
|
|
|
628
648
|
if (authError) return authError;
|
|
629
649
|
const entity = entityMap[resource];
|
|
630
650
|
if (!resource || !entity) {
|
|
651
|
+
logCrudClientError("GET list", {
|
|
652
|
+
reason: "invalid_resource",
|
|
653
|
+
resource,
|
|
654
|
+
hasEntity: Boolean(entity),
|
|
655
|
+
entityMapHasLlmAgents: Boolean(entityMap.llm_agents),
|
|
656
|
+
entityMapKeyCount: Object.keys(entityMap).length
|
|
657
|
+
});
|
|
631
658
|
return json({ error: "Invalid resource" }, { status: 400 });
|
|
632
659
|
}
|
|
633
660
|
const { searchParams } = new URL(req.url);
|
|
@@ -835,12 +862,22 @@ function createCrudHandler(dataSource, entityMap, options) {
|
|
|
835
862
|
}
|
|
836
863
|
}
|
|
837
864
|
where = mergeDeletedFalseWhere(repo, where);
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
865
|
+
let data;
|
|
866
|
+
let total;
|
|
867
|
+
try {
|
|
868
|
+
const r = await repo.findAndCount({
|
|
869
|
+
skip,
|
|
870
|
+
take: limit,
|
|
871
|
+
order: { [sortField]: sortOrder },
|
|
872
|
+
where
|
|
873
|
+
});
|
|
874
|
+
data = r[0];
|
|
875
|
+
total = r[1];
|
|
876
|
+
} catch (err) {
|
|
877
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
878
|
+
logCrudServerError("GET list query failed", { resource, sortField, sortOrder, message });
|
|
879
|
+
throw err;
|
|
880
|
+
}
|
|
844
881
|
return json({ total, page, limit, totalPages: Math.ceil(total / limit), data });
|
|
845
882
|
},
|
|
846
883
|
async POST(req, resource) {
|
|
@@ -848,12 +885,25 @@ function createCrudHandler(dataSource, entityMap, options) {
|
|
|
848
885
|
if (authError) return authError;
|
|
849
886
|
const entity = entityMap[resource];
|
|
850
887
|
if (!resource || !entity) {
|
|
888
|
+
logCrudClientError("POST create", {
|
|
889
|
+
reason: "invalid_resource",
|
|
890
|
+
resource,
|
|
891
|
+
hasEntity: Boolean(entity),
|
|
892
|
+
entityMapHasLlmAgents: Boolean(entityMap.llm_agents)
|
|
893
|
+
});
|
|
851
894
|
return json({ error: "Invalid resource" }, { status: 400 });
|
|
852
895
|
}
|
|
853
|
-
const
|
|
854
|
-
if (!
|
|
896
|
+
const rawPostBody = await req.json();
|
|
897
|
+
if (!rawPostBody || typeof rawPostBody !== "object" || Object.keys(rawPostBody).length === 0) {
|
|
898
|
+
logCrudClientError("POST create", {
|
|
899
|
+
reason: "invalid_request_payload",
|
|
900
|
+
resource,
|
|
901
|
+
rawType: rawPostBody == null ? "nullish" : typeof rawPostBody,
|
|
902
|
+
keyCount: rawPostBody && typeof rawPostBody === "object" ? Object.keys(rawPostBody).length : 0
|
|
903
|
+
});
|
|
855
904
|
return json({ error: "Invalid request payload" }, { status: 400 });
|
|
856
905
|
}
|
|
906
|
+
const body = rawPostBody;
|
|
857
907
|
if (resource === "media") {
|
|
858
908
|
const b = body;
|
|
859
909
|
const kind = b.kind === "folder" ? "folder" : "file";
|
|
@@ -887,8 +937,24 @@ function createCrudHandler(dataSource, entityMap, options) {
|
|
|
887
937
|
}
|
|
888
938
|
}
|
|
889
939
|
const repo = dataSource.getRepository(entity);
|
|
890
|
-
|
|
891
|
-
|
|
940
|
+
const persistBody = resource === "media" ? body : pickColumnUpdates(repo, body);
|
|
941
|
+
if (resource !== "media" && Object.keys(persistBody).length === 0) {
|
|
942
|
+
logCrudClientError("POST create", {
|
|
943
|
+
reason: "no_scalar_columns_after_pick",
|
|
944
|
+
resource,
|
|
945
|
+
incomingKeys: Object.keys(body)
|
|
946
|
+
});
|
|
947
|
+
return json({ error: "Invalid request payload" }, { status: 400 });
|
|
948
|
+
}
|
|
949
|
+
sanitizeBodyForEntity(repo, persistBody);
|
|
950
|
+
let created;
|
|
951
|
+
try {
|
|
952
|
+
created = await repo.save(repo.create(persistBody));
|
|
953
|
+
} catch (err) {
|
|
954
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
955
|
+
logCrudServerError("POST create save failed", { resource, message, persistKeys: Object.keys(persistBody) });
|
|
956
|
+
throw err;
|
|
957
|
+
}
|
|
892
958
|
if (resource === "contacts") {
|
|
893
959
|
await syncContactRowToErp(created);
|
|
894
960
|
}
|
|
@@ -903,6 +969,7 @@ function createCrudHandler(dataSource, entityMap, options) {
|
|
|
903
969
|
if (authError) return authError;
|
|
904
970
|
const entity = entityMap[resource];
|
|
905
971
|
if (!resource || !entity) {
|
|
972
|
+
logCrudClientError("GET_METADATA", { reason: "invalid_resource", resource });
|
|
906
973
|
return json({ error: "Invalid resource" }, { status: 400 });
|
|
907
974
|
}
|
|
908
975
|
const repo = dataSource.getRepository(entity);
|
|
@@ -934,11 +1001,18 @@ function createCrudHandler(dataSource, entityMap, options) {
|
|
|
934
1001
|
if (authError) return authError;
|
|
935
1002
|
const entity = entityMap[resource];
|
|
936
1003
|
if (!resource || !entity) {
|
|
1004
|
+
logCrudClientError("BULK_POST", { reason: "invalid_resource", resource });
|
|
937
1005
|
return json({ error: "Invalid resource" }, { status: 400 });
|
|
938
1006
|
}
|
|
939
1007
|
const body = await req.json();
|
|
940
1008
|
const { records, upsertKey = "id" } = body;
|
|
941
1009
|
if (!Array.isArray(records) || records.length === 0) {
|
|
1010
|
+
logCrudClientError("BULK_POST", {
|
|
1011
|
+
reason: "records_required",
|
|
1012
|
+
resource,
|
|
1013
|
+
recordsIsArray: Array.isArray(records),
|
|
1014
|
+
recordCount: Array.isArray(records) ? records.length : 0
|
|
1015
|
+
});
|
|
942
1016
|
return json({ error: "Records array is required" }, { status: 400 });
|
|
943
1017
|
}
|
|
944
1018
|
const repo = dataSource.getRepository(entity);
|
|
@@ -957,6 +1031,7 @@ function createCrudHandler(dataSource, entityMap, options) {
|
|
|
957
1031
|
});
|
|
958
1032
|
} catch (error) {
|
|
959
1033
|
const message = error instanceof Error ? error.message : "Bulk import failed";
|
|
1034
|
+
logCrudClientError("BULK_POST upsert failed", { resource, upsertKey, message });
|
|
960
1035
|
return json({ error: message }, { status: 400 });
|
|
961
1036
|
}
|
|
962
1037
|
},
|
|
@@ -965,6 +1040,7 @@ function createCrudHandler(dataSource, entityMap, options) {
|
|
|
965
1040
|
if (authError) return authError;
|
|
966
1041
|
const entity = entityMap[resource];
|
|
967
1042
|
if (!resource || !entity) {
|
|
1043
|
+
logCrudClientError("GET_EXPORT", { reason: "invalid_resource", resource });
|
|
968
1044
|
return json({ error: "Invalid resource" }, { status: 400 });
|
|
969
1045
|
}
|
|
970
1046
|
const { searchParams } = new URL(req.url);
|
|
@@ -1019,7 +1095,10 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
|
|
|
1019
1095
|
const authError = await authz(req, resource, "read");
|
|
1020
1096
|
if (authError) return authError;
|
|
1021
1097
|
const entity = entityMap[resource];
|
|
1022
|
-
if (!entity)
|
|
1098
|
+
if (!entity) {
|
|
1099
|
+
logCrudClientError("GET by id", { reason: "invalid_resource", resource, id });
|
|
1100
|
+
return json({ error: "Invalid resource" }, { status: 400 });
|
|
1101
|
+
}
|
|
1023
1102
|
const repo = dataSource.getRepository(entity);
|
|
1024
1103
|
if (resource === "orders") {
|
|
1025
1104
|
const order = await repo.findOne({
|
|
@@ -1078,7 +1157,10 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
|
|
|
1078
1157
|
const authError = await authz(req, resource, "update");
|
|
1079
1158
|
if (authError) return authError;
|
|
1080
1159
|
const entity = entityMap[resource];
|
|
1081
|
-
if (!entity)
|
|
1160
|
+
if (!entity) {
|
|
1161
|
+
logCrudClientError("PUT by id", { reason: "invalid_resource", resource, id });
|
|
1162
|
+
return json({ error: "Invalid resource" }, { status: 400 });
|
|
1163
|
+
}
|
|
1082
1164
|
const rawBody = await req.json();
|
|
1083
1165
|
const repo = dataSource.getRepository(entity);
|
|
1084
1166
|
const numericId = Number(id);
|
|
@@ -1191,7 +1273,10 @@ function createCrudByIdHandler(dataSource, entityMap, options) {
|
|
|
1191
1273
|
const authError = await authz(req, resource, "delete");
|
|
1192
1274
|
if (authError) return authError;
|
|
1193
1275
|
const entity = entityMap[resource];
|
|
1194
|
-
if (!entity)
|
|
1276
|
+
if (!entity) {
|
|
1277
|
+
logCrudClientError("DELETE by id", { reason: "invalid_resource", resource, id });
|
|
1278
|
+
return json({ error: "Invalid resource" }, { status: 400 });
|
|
1279
|
+
}
|
|
1195
1280
|
const repo = dataSource.getRepository(entity);
|
|
1196
1281
|
const numericId = Number(id);
|
|
1197
1282
|
if (entityHasSoftDelete(repo)) {
|
|
@@ -1364,7 +1449,7 @@ function createUserAuthApiRouter(config) {
|
|
|
1364
1449
|
}
|
|
1365
1450
|
|
|
1366
1451
|
// src/api/cms-handlers.ts
|
|
1367
|
-
var
|
|
1452
|
+
var import_typeorm5 = require("typeorm");
|
|
1368
1453
|
init_email_queue();
|
|
1369
1454
|
init_erp_queue();
|
|
1370
1455
|
|
|
@@ -1384,6 +1469,86 @@ async function assertCaptchaOk(getCms, body, req, json) {
|
|
|
1384
1469
|
return json({ error: result.message }, { status: result.status });
|
|
1385
1470
|
}
|
|
1386
1471
|
|
|
1472
|
+
// src/entities/llm-agent.entity.ts
|
|
1473
|
+
var import_typeorm3 = require("typeorm");
|
|
1474
|
+
var LlmAgent = class {
|
|
1475
|
+
id;
|
|
1476
|
+
name;
|
|
1477
|
+
slug;
|
|
1478
|
+
systemInstruction;
|
|
1479
|
+
model;
|
|
1480
|
+
temperature;
|
|
1481
|
+
maxTokens;
|
|
1482
|
+
validationRules;
|
|
1483
|
+
enabled;
|
|
1484
|
+
createdAt;
|
|
1485
|
+
updatedAt;
|
|
1486
|
+
deletedAt;
|
|
1487
|
+
deleted;
|
|
1488
|
+
createdBy;
|
|
1489
|
+
updatedBy;
|
|
1490
|
+
deletedBy;
|
|
1491
|
+
};
|
|
1492
|
+
__decorateClass([
|
|
1493
|
+
(0, import_typeorm3.PrimaryGeneratedColumn)()
|
|
1494
|
+
], LlmAgent.prototype, "id", 2);
|
|
1495
|
+
__decorateClass([
|
|
1496
|
+
(0, import_typeorm3.Column)("varchar")
|
|
1497
|
+
], LlmAgent.prototype, "name", 2);
|
|
1498
|
+
__decorateClass([
|
|
1499
|
+
(0, import_typeorm3.Column)("varchar")
|
|
1500
|
+
], LlmAgent.prototype, "slug", 2);
|
|
1501
|
+
__decorateClass([
|
|
1502
|
+
(0, import_typeorm3.Column)("text", { name: "system_instruction", default: "" })
|
|
1503
|
+
], LlmAgent.prototype, "systemInstruction", 2);
|
|
1504
|
+
__decorateClass([
|
|
1505
|
+
(0, import_typeorm3.Column)("varchar", { nullable: true })
|
|
1506
|
+
], LlmAgent.prototype, "model", 2);
|
|
1507
|
+
__decorateClass([
|
|
1508
|
+
(0, import_typeorm3.Column)("double precision", { name: "temperature", nullable: true })
|
|
1509
|
+
], LlmAgent.prototype, "temperature", 2);
|
|
1510
|
+
__decorateClass([
|
|
1511
|
+
(0, import_typeorm3.Column)("int", { name: "max_tokens", nullable: true })
|
|
1512
|
+
], LlmAgent.prototype, "maxTokens", 2);
|
|
1513
|
+
__decorateClass([
|
|
1514
|
+
(0, import_typeorm3.Column)("text", { name: "validation_rules", nullable: true })
|
|
1515
|
+
], LlmAgent.prototype, "validationRules", 2);
|
|
1516
|
+
__decorateClass([
|
|
1517
|
+
(0, import_typeorm3.Column)("boolean", { default: true })
|
|
1518
|
+
], LlmAgent.prototype, "enabled", 2);
|
|
1519
|
+
__decorateClass([
|
|
1520
|
+
(0, import_typeorm3.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
1521
|
+
], LlmAgent.prototype, "createdAt", 2);
|
|
1522
|
+
__decorateClass([
|
|
1523
|
+
(0, import_typeorm3.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
1524
|
+
], LlmAgent.prototype, "updatedAt", 2);
|
|
1525
|
+
__decorateClass([
|
|
1526
|
+
(0, import_typeorm3.Column)({ type: "timestamp", nullable: true })
|
|
1527
|
+
], LlmAgent.prototype, "deletedAt", 2);
|
|
1528
|
+
__decorateClass([
|
|
1529
|
+
(0, import_typeorm3.Column)("boolean", { default: false })
|
|
1530
|
+
], LlmAgent.prototype, "deleted", 2);
|
|
1531
|
+
__decorateClass([
|
|
1532
|
+
(0, import_typeorm3.Column)("int", { nullable: true })
|
|
1533
|
+
], LlmAgent.prototype, "createdBy", 2);
|
|
1534
|
+
__decorateClass([
|
|
1535
|
+
(0, import_typeorm3.Column)("int", { nullable: true })
|
|
1536
|
+
], LlmAgent.prototype, "updatedBy", 2);
|
|
1537
|
+
__decorateClass([
|
|
1538
|
+
(0, import_typeorm3.Column)("int", { nullable: true })
|
|
1539
|
+
], LlmAgent.prototype, "deletedBy", 2);
|
|
1540
|
+
LlmAgent = __decorateClass([
|
|
1541
|
+
(0, import_typeorm3.Entity)("llm_agents")
|
|
1542
|
+
], LlmAgent);
|
|
1543
|
+
function llmAgentToChatAgentOptions(agent) {
|
|
1544
|
+
return {
|
|
1545
|
+
systemPrompt: agent.systemInstruction?.trim() || void 0,
|
|
1546
|
+
model: agent.model?.trim() || void 0,
|
|
1547
|
+
temperature: agent.temperature ?? void 0,
|
|
1548
|
+
max_tokens: agent.maxTokens ?? void 0
|
|
1549
|
+
};
|
|
1550
|
+
}
|
|
1551
|
+
|
|
1387
1552
|
// src/lib/media-folder-path.ts
|
|
1388
1553
|
function sanitizeMediaFolderPath(input) {
|
|
1389
1554
|
if (input == null) return "";
|
|
@@ -1415,7 +1580,7 @@ async function relativePathFromMediaParentId(dataSource, entityMap, parentId) {
|
|
|
1415
1580
|
}
|
|
1416
1581
|
|
|
1417
1582
|
// src/lib/media-zip-extract.ts
|
|
1418
|
-
var
|
|
1583
|
+
var import_typeorm4 = require("typeorm");
|
|
1419
1584
|
var ZIP_MIME_TYPES = /* @__PURE__ */ new Set(["application/zip", "application/x-zip-compressed"]);
|
|
1420
1585
|
var MAX_ENTRIES = 2e3;
|
|
1421
1586
|
var MAX_TOTAL_UNCOMPRESSED = 80 * 1024 * 1024;
|
|
@@ -1466,7 +1631,7 @@ function guessMimeType(fileName) {
|
|
|
1466
1631
|
async function findOrCreateFolder(dataSource, entityMap, parentId, name) {
|
|
1467
1632
|
const safe = sanitizeStorageSegment(name);
|
|
1468
1633
|
const repo = dataSource.getRepository(entityMap.media);
|
|
1469
|
-
const where = parentId == null ? { kind: "folder", filename: safe, parentId: (0,
|
|
1634
|
+
const where = parentId == null ? { kind: "folder", filename: safe, parentId: (0, import_typeorm4.IsNull)() } : { kind: "folder", filename: safe, parentId };
|
|
1470
1635
|
const existing = await repo.findOne({ where });
|
|
1471
1636
|
if (existing) return existing.id;
|
|
1472
1637
|
const row = await repo.save(
|
|
@@ -1573,6 +1738,82 @@ async function extractZipMediaIntoParentTree(opts) {
|
|
|
1573
1738
|
}
|
|
1574
1739
|
|
|
1575
1740
|
// src/api/cms-handlers.ts
|
|
1741
|
+
function historyBeforeCurrentUser(history, currentUserContent) {
|
|
1742
|
+
const last = history[history.length - 1];
|
|
1743
|
+
if (last?.role === "user" && last.content === currentUserContent) {
|
|
1744
|
+
return history.slice(0, -1);
|
|
1745
|
+
}
|
|
1746
|
+
return [...history];
|
|
1747
|
+
}
|
|
1748
|
+
function pickStructuredRules(rules) {
|
|
1749
|
+
return {
|
|
1750
|
+
maxUserChars: rules.maxUserChars,
|
|
1751
|
+
maxMessageLength: rules.maxMessageLength,
|
|
1752
|
+
minUserChars: rules.minUserChars,
|
|
1753
|
+
minMessageLength: rules.minMessageLength,
|
|
1754
|
+
blockedSubstrings: rules.blockedSubstrings
|
|
1755
|
+
};
|
|
1756
|
+
}
|
|
1757
|
+
function guardrailsTextFromJsonObject(rules) {
|
|
1758
|
+
const g = typeof rules.guardrails === "string" && rules.guardrails.trim() || typeof rules.outputRules === "string" && rules.outputRules.trim() || typeof rules.outputInstructions === "string" && rules.outputInstructions.trim() || "";
|
|
1759
|
+
return g || null;
|
|
1760
|
+
}
|
|
1761
|
+
function parseLlmAgentValidationRules(validationRulesText) {
|
|
1762
|
+
const raw = validationRulesText?.trim();
|
|
1763
|
+
if (!raw) return { structured: {}, guardrailsForPrompt: null };
|
|
1764
|
+
try {
|
|
1765
|
+
const parsed = JSON.parse(raw);
|
|
1766
|
+
if (typeof parsed === "string") {
|
|
1767
|
+
const s = parsed.trim();
|
|
1768
|
+
return { structured: {}, guardrailsForPrompt: s || null };
|
|
1769
|
+
}
|
|
1770
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
1771
|
+
return { structured: {}, guardrailsForPrompt: raw };
|
|
1772
|
+
}
|
|
1773
|
+
const rules = parsed;
|
|
1774
|
+
return {
|
|
1775
|
+
structured: pickStructuredRules(rules),
|
|
1776
|
+
guardrailsForPrompt: guardrailsTextFromJsonObject(rules)
|
|
1777
|
+
};
|
|
1778
|
+
} catch {
|
|
1779
|
+
return { structured: {}, guardrailsForPrompt: raw };
|
|
1780
|
+
}
|
|
1781
|
+
}
|
|
1782
|
+
function validateUserMessageAgainstStructuredRules(message, structured) {
|
|
1783
|
+
const maxLen = structured.maxUserChars ?? structured.maxMessageLength;
|
|
1784
|
+
if (typeof maxLen === "number" && Number.isFinite(maxLen) && maxLen >= 0 && message.length > maxLen) {
|
|
1785
|
+
return { ok: false, error: `Message exceeds maximum length (${maxLen} characters)` };
|
|
1786
|
+
}
|
|
1787
|
+
const minLen = structured.minUserChars ?? structured.minMessageLength;
|
|
1788
|
+
if (typeof minLen === "number" && Number.isFinite(minLen) && minLen > 0 && message.length < minLen) {
|
|
1789
|
+
return { ok: false, error: `Message is shorter than minimum length (${minLen} characters)` };
|
|
1790
|
+
}
|
|
1791
|
+
const blocked = structured.blockedSubstrings;
|
|
1792
|
+
if (Array.isArray(blocked) && blocked.length > 0) {
|
|
1793
|
+
const lower = message.toLowerCase();
|
|
1794
|
+
for (const s of blocked) {
|
|
1795
|
+
if (typeof s !== "string" || !s.trim()) continue;
|
|
1796
|
+
if (lower.includes(s.toLowerCase())) {
|
|
1797
|
+
return { ok: false, error: "Message contains disallowed content" };
|
|
1798
|
+
}
|
|
1799
|
+
}
|
|
1800
|
+
}
|
|
1801
|
+
return { ok: true };
|
|
1802
|
+
}
|
|
1803
|
+
function validateUserMessageAgainstAgentRules(message, validationRulesText) {
|
|
1804
|
+
const { structured } = parseLlmAgentValidationRules(validationRulesText);
|
|
1805
|
+
return validateUserMessageAgainstStructuredRules(message, structured);
|
|
1806
|
+
}
|
|
1807
|
+
function mergeGuardrailsIntoSystemPrompt(baseSystem, guardrailsForPrompt) {
|
|
1808
|
+
const g = guardrailsForPrompt?.trim();
|
|
1809
|
+
const b = (baseSystem ?? "").trim();
|
|
1810
|
+
if (!g) return b;
|
|
1811
|
+
const block = `### Output guardrails (follow in every reply)
|
|
1812
|
+
${g}`;
|
|
1813
|
+
return b ? `${b}
|
|
1814
|
+
|
|
1815
|
+
${block}` : block;
|
|
1816
|
+
}
|
|
1576
1817
|
function createDashboardStatsHandler(config) {
|
|
1577
1818
|
const { dataSource, entityMap, json, requireAuth, requirePermission, requireEntityPermission } = config;
|
|
1578
1819
|
return async function GET(req) {
|
|
@@ -1595,8 +1836,8 @@ function createDashboardStatsHandler(config) {
|
|
|
1595
1836
|
repo("form_submissions")?.count() ?? 0,
|
|
1596
1837
|
repo("users")?.count({ where: { deleted: false } }) ?? 0,
|
|
1597
1838
|
repo("blogs")?.count({ where: { deleted: false } }) ?? 0,
|
|
1598
|
-
repo("contacts")?.count({ where: { createdAt: (0,
|
|
1599
|
-
repo("form_submissions")?.count({ where: { createdAt: (0,
|
|
1839
|
+
repo("contacts")?.count({ where: { createdAt: (0, import_typeorm5.MoreThanOrEqual)(sevenDaysAgo) } }) ?? 0,
|
|
1840
|
+
repo("form_submissions")?.count({ where: { createdAt: (0, import_typeorm5.MoreThanOrEqual)(sevenDaysAgo) } }) ?? 0,
|
|
1600
1841
|
repo("contacts")?.createQueryBuilder("c").select("COALESCE(NULLIF(TRIM(c.type), ''), 'unknown')", "type").addSelect("COUNT(*)", "count").where("c.deleted = :deleted", { deleted: false }).groupBy("COALESCE(NULLIF(TRIM(c.type), ''), 'unknown')").getRawMany() ?? []
|
|
1601
1842
|
]);
|
|
1602
1843
|
return json({
|
|
@@ -1645,19 +1886,19 @@ function createEcommerceAnalyticsHandler(config) {
|
|
|
1645
1886
|
const productRepo = dataSource.getRepository(entityMap.products);
|
|
1646
1887
|
const [salesOrders, returnOrders, replacementOrders, payments, products] = await Promise.all([
|
|
1647
1888
|
orderRepo.find({
|
|
1648
|
-
where: { deleted: false, createdAt: (0,
|
|
1889
|
+
where: { deleted: false, createdAt: (0, import_typeorm5.MoreThanOrEqual)(start), orderKind: "sale", status: (0, import_typeorm5.In)(["confirmed", "processing", "completed"]) },
|
|
1649
1890
|
select: ["id", "contactId", "createdAt", "subtotal", "discount", "tax", "total", "status"]
|
|
1650
1891
|
}),
|
|
1651
1892
|
orderRepo.find({
|
|
1652
|
-
where: { deleted: false, createdAt: (0,
|
|
1893
|
+
where: { deleted: false, createdAt: (0, import_typeorm5.MoreThanOrEqual)(start), orderKind: "return" },
|
|
1653
1894
|
select: ["id", "createdAt", "total"]
|
|
1654
1895
|
}),
|
|
1655
1896
|
orderRepo.find({
|
|
1656
|
-
where: { deleted: false, createdAt: (0,
|
|
1897
|
+
where: { deleted: false, createdAt: (0, import_typeorm5.MoreThanOrEqual)(start), orderKind: "replacement" },
|
|
1657
1898
|
select: ["id", "createdAt", "total"]
|
|
1658
1899
|
}),
|
|
1659
1900
|
paymentRepo.find({
|
|
1660
|
-
where: { deleted: false, createdAt: (0,
|
|
1901
|
+
where: { deleted: false, createdAt: (0, import_typeorm5.MoreThanOrEqual)(start) },
|
|
1661
1902
|
select: ["id", "status", "method", "amount", "createdAt"]
|
|
1662
1903
|
}),
|
|
1663
1904
|
productRepo.find({
|
|
@@ -1667,7 +1908,7 @@ function createEcommerceAnalyticsHandler(config) {
|
|
|
1667
1908
|
]);
|
|
1668
1909
|
const saleOrderIds = salesOrders.map((o) => o.id);
|
|
1669
1910
|
const orderItems = saleOrderIds.length ? await itemRepo.find({
|
|
1670
|
-
where: { orderId: (0,
|
|
1911
|
+
where: { orderId: (0, import_typeorm5.In)(saleOrderIds) },
|
|
1671
1912
|
select: ["id", "orderId", "productId", "quantity", "total"]
|
|
1672
1913
|
}) : [];
|
|
1673
1914
|
const grossSales = salesOrders.reduce((sum, o) => sum + toNum(o.subtotal), 0);
|
|
@@ -2355,8 +2596,8 @@ function createUsersApiHandlers(config) {
|
|
|
2355
2596
|
const sortOrder = url.searchParams.get("sortOrder") === "desc" ? "DESC" : "ASC";
|
|
2356
2597
|
const search = url.searchParams.get("search");
|
|
2357
2598
|
const where = search ? [
|
|
2358
|
-
{ name: (0,
|
|
2359
|
-
{ email: (0,
|
|
2599
|
+
{ name: (0, import_typeorm5.ILike)(`%${search}%`), deleted: false },
|
|
2600
|
+
{ email: (0, import_typeorm5.ILike)(`%${search}%`), deleted: false }
|
|
2360
2601
|
] : { deleted: false };
|
|
2361
2602
|
const [data, total] = await userRepo().findAndCount({
|
|
2362
2603
|
skip,
|
|
@@ -2654,9 +2895,24 @@ function createSettingsApiHandlers(config) {
|
|
|
2654
2895
|
}
|
|
2655
2896
|
var KB_CHUNK_LIMIT = 10;
|
|
2656
2897
|
var KB_CONTEXT_MAX_CHARS = 4e3;
|
|
2898
|
+
var RAG_LOG = "[rag-context]";
|
|
2657
2899
|
function getQueryTerms(message) {
|
|
2658
2900
|
return message.replace(/[^\w\s]/g, " ").split(/\s+/).filter((w) => w.length > 2).slice(0, 6);
|
|
2659
2901
|
}
|
|
2902
|
+
function normalizeChatModeSetting(raw) {
|
|
2903
|
+
if (raw === "external" || raw === "llm") return raw;
|
|
2904
|
+
return "whatsapp";
|
|
2905
|
+
}
|
|
2906
|
+
async function loadLlmSettingsMap(dataSource, entityMap) {
|
|
2907
|
+
if (!entityMap.configs) return {};
|
|
2908
|
+
const repo = dataSource.getRepository(entityMap.configs);
|
|
2909
|
+
const rows = await repo.find({ where: { settings: "llm", deleted: false } });
|
|
2910
|
+
const out = {};
|
|
2911
|
+
for (const row of rows) {
|
|
2912
|
+
out[row.key] = row.value;
|
|
2913
|
+
}
|
|
2914
|
+
return out;
|
|
2915
|
+
}
|
|
2660
2916
|
function createChatHandlers(config) {
|
|
2661
2917
|
const { dataSource, entityMap, json, getCms } = config;
|
|
2662
2918
|
const contactRepo = () => dataSource.getRepository(entityMap.contacts);
|
|
@@ -2664,6 +2920,26 @@ function createChatHandlers(config) {
|
|
|
2664
2920
|
const msgRepo = () => dataSource.getRepository(entityMap.chat_messages);
|
|
2665
2921
|
const chunkRepo = () => dataSource.getRepository(entityMap.knowledge_base_chunks);
|
|
2666
2922
|
return {
|
|
2923
|
+
async publicConfig(_req) {
|
|
2924
|
+
try {
|
|
2925
|
+
const map = await loadLlmSettingsMap(dataSource, entityMap);
|
|
2926
|
+
const mode = normalizeChatModeSetting(map.chatMode);
|
|
2927
|
+
const body = {
|
|
2928
|
+
enabled: map.enabled !== "false",
|
|
2929
|
+
chatMode: mode,
|
|
2930
|
+
agentSlug: mode === "llm" ? (map.attachedAgentSlug ?? "").trim() : "",
|
|
2931
|
+
botName: map.botName ?? "",
|
|
2932
|
+
icon: map.icon ?? "",
|
|
2933
|
+
iconImageUrl: map.iconImageUrl ?? "",
|
|
2934
|
+
iconBackgroundColor: map.iconBackgroundColor ?? "#6366f1",
|
|
2935
|
+
headerColor: map.headerColor ?? "#6366f1",
|
|
2936
|
+
whatsappPhone: map.whatsappPhone ?? ""
|
|
2937
|
+
};
|
|
2938
|
+
return json(body);
|
|
2939
|
+
} catch {
|
|
2940
|
+
return json({ error: "Failed to load chat config" }, { status: 500 });
|
|
2941
|
+
}
|
|
2942
|
+
},
|
|
2667
2943
|
async identify(req) {
|
|
2668
2944
|
try {
|
|
2669
2945
|
const body = await req.json();
|
|
@@ -2711,20 +2987,78 @@ function createChatHandlers(config) {
|
|
|
2711
2987
|
relations: ["messages"]
|
|
2712
2988
|
});
|
|
2713
2989
|
if (!conv) return json({ error: "Conversation not found" }, { status: 404 });
|
|
2714
|
-
const msgRepoInst = msgRepo();
|
|
2715
|
-
await msgRepoInst.save(msgRepoInst.create({ conversationId, role: "user", content: message }));
|
|
2716
2990
|
const cms = await getCms();
|
|
2717
2991
|
const llm = cms.getPlugin("llm");
|
|
2718
2992
|
if (!llm?.chat) return json({ error: "LLM not configured" }, { status: 503 });
|
|
2993
|
+
const llmSettings = await loadLlmSettingsMap(dataSource, entityMap);
|
|
2994
|
+
const supportMode = normalizeChatModeSetting(llmSettings.chatMode);
|
|
2995
|
+
let effectiveSlug = (body?.agentSlug ?? "").trim();
|
|
2996
|
+
if (!effectiveSlug && supportMode === "llm" && entityMap.llm_agents) {
|
|
2997
|
+
effectiveSlug = (llmSettings.attachedAgentSlug ?? "").trim();
|
|
2998
|
+
}
|
|
2999
|
+
let agentRow = null;
|
|
3000
|
+
if (effectiveSlug) {
|
|
3001
|
+
if (!entityMap.llm_agents) {
|
|
3002
|
+
return json({ error: "LLM agents are not configured on this deployment" }, { status: 400 });
|
|
3003
|
+
}
|
|
3004
|
+
const agentRepo = dataSource.getRepository(
|
|
3005
|
+
entityMap.llm_agents
|
|
3006
|
+
);
|
|
3007
|
+
agentRow = await agentRepo.findOne({
|
|
3008
|
+
where: { slug: effectiveSlug, deleted: false, enabled: true }
|
|
3009
|
+
});
|
|
3010
|
+
if (!agentRow && (body?.agentSlug ?? "").trim()) {
|
|
3011
|
+
return json({ error: "Agent not found or disabled", agentSlug: effectiveSlug }, { status: 404 });
|
|
3012
|
+
}
|
|
3013
|
+
}
|
|
3014
|
+
console.info(RAG_LOG, "step 1 | resolve agent", {
|
|
3015
|
+
agentSlug: effectiveSlug || "(none)",
|
|
3016
|
+
agentFound: !!agentRow,
|
|
3017
|
+
agentId: agentRow?.id ?? null
|
|
3018
|
+
});
|
|
3019
|
+
const parsedValidation = agentRow ? parseLlmAgentValidationRules(agentRow.validationRules) : { structured: {}, guardrailsForPrompt: null };
|
|
3020
|
+
if (agentRow) {
|
|
3021
|
+
const v = validateUserMessageAgainstStructuredRules(message, parsedValidation.structured);
|
|
3022
|
+
if (!v.ok) return json({ error: v.error, reason: "validation_failed" }, { status: 400 });
|
|
3023
|
+
}
|
|
3024
|
+
let kbDocumentScope;
|
|
3025
|
+
const Junction = entityMap.llm_agent_knowledge_documents;
|
|
3026
|
+
if (agentRow && Junction) {
|
|
3027
|
+
const linkRepo = dataSource.getRepository(Junction);
|
|
3028
|
+
const links = await linkRepo.find({ where: { agentId: agentRow.id } });
|
|
3029
|
+
const ids = [...new Set(links.map((l) => l.documentId))];
|
|
3030
|
+
if (ids.length > 0) kbDocumentScope = ids;
|
|
3031
|
+
}
|
|
3032
|
+
console.info(RAG_LOG, "step 2 | knowledge scope", {
|
|
3033
|
+
scopedDocumentIds: kbDocumentScope ?? "(all documents)",
|
|
3034
|
+
documentCount: kbDocumentScope?.length ?? "all"
|
|
3035
|
+
});
|
|
3036
|
+
const msgRepoInst = msgRepo();
|
|
3037
|
+
await msgRepoInst.save(msgRepoInst.create({ conversationId, role: "user", content: message }));
|
|
2719
3038
|
let contextParts = [];
|
|
3039
|
+
console.info(RAG_LOG, "step 3 | embed user query", {
|
|
3040
|
+
messageChars: message.length,
|
|
3041
|
+
embedAvailable: !!llm.embed
|
|
3042
|
+
});
|
|
2720
3043
|
const queryEmbedding = llm.embed ? await llm.embed(message) : null;
|
|
3044
|
+
console.info(RAG_LOG, "step 4 | query embedding result", {
|
|
3045
|
+
dimensions: queryEmbedding?.length ?? 0,
|
|
3046
|
+
hasEmbedding: !!(queryEmbedding && queryEmbedding.length > 0)
|
|
3047
|
+
});
|
|
2721
3048
|
if (queryEmbedding && queryEmbedding.length > 0) {
|
|
2722
3049
|
const vectorStr = "[" + queryEmbedding.join(",") + "]";
|
|
2723
3050
|
try {
|
|
2724
|
-
const rows = await dataSource.query(
|
|
3051
|
+
const rows = kbDocumentScope?.length ? await dataSource.query(
|
|
3052
|
+
`SELECT id, content FROM knowledge_base_chunks WHERE embedding IS NOT NULL AND "documentId" = ANY($3::int[]) ORDER BY embedding <=> $1::vector LIMIT $2`,
|
|
3053
|
+
[vectorStr, KB_CHUNK_LIMIT, kbDocumentScope]
|
|
3054
|
+
) : await dataSource.query(
|
|
2725
3055
|
`SELECT id, content FROM knowledge_base_chunks WHERE embedding IS NOT NULL ORDER BY embedding <=> $1::vector LIMIT $2`,
|
|
2726
3056
|
[vectorStr, KB_CHUNK_LIMIT]
|
|
2727
3057
|
);
|
|
3058
|
+
console.info(RAG_LOG, "step 5 | vector search results", {
|
|
3059
|
+
rowsReturned: rows.length,
|
|
3060
|
+
chunkIds: rows.map((r) => r.id)
|
|
3061
|
+
});
|
|
2728
3062
|
let totalLen = 0;
|
|
2729
3063
|
for (const r of rows) {
|
|
2730
3064
|
const text = (r.content ?? "").trim();
|
|
@@ -2732,13 +3066,24 @@ function createChatHandlers(config) {
|
|
|
2732
3066
|
contextParts.push(text);
|
|
2733
3067
|
totalLen += text.length;
|
|
2734
3068
|
}
|
|
2735
|
-
|
|
3069
|
+
console.info(RAG_LOG, "step 5a | vector context selected", {
|
|
3070
|
+
chunksUsed: contextParts.length,
|
|
3071
|
+
totalChars: totalLen
|
|
3072
|
+
});
|
|
3073
|
+
} catch (vecErr) {
|
|
3074
|
+
console.warn(RAG_LOG, "step 5 | vector search failed; falling back to keyword", {
|
|
3075
|
+
err: vecErr instanceof Error ? vecErr.message : String(vecErr)
|
|
3076
|
+
});
|
|
2736
3077
|
}
|
|
2737
3078
|
}
|
|
2738
3079
|
if (contextParts.length === 0) {
|
|
2739
3080
|
const terms = getQueryTerms(message);
|
|
3081
|
+
console.info(RAG_LOG, "step 6 | keyword fallback", {
|
|
3082
|
+
reason: !(queryEmbedding && queryEmbedding.length > 0) ? "no embedding" : "vector search returned nothing",
|
|
3083
|
+
searchTerms: terms
|
|
3084
|
+
});
|
|
2740
3085
|
if (terms.length > 0) {
|
|
2741
|
-
const conditions = terms.map((t) => ({ content: (0,
|
|
3086
|
+
const conditions = kbDocumentScope?.length ? terms.map((t) => ({ content: (0, import_typeorm5.ILike)(`%${t}%`), documentId: (0, import_typeorm5.In)(kbDocumentScope) })) : terms.map((t) => ({ content: (0, import_typeorm5.ILike)(`%${t}%`) }));
|
|
2742
3087
|
const chunks = await chunkRepo().find({
|
|
2743
3088
|
where: conditions,
|
|
2744
3089
|
take: KB_CHUNK_LIMIT,
|
|
@@ -2753,19 +3098,66 @@ function createChatHandlers(config) {
|
|
|
2753
3098
|
contextParts.push(text);
|
|
2754
3099
|
totalLen += text.length;
|
|
2755
3100
|
}
|
|
3101
|
+
console.info(RAG_LOG, "step 6a | keyword results", {
|
|
3102
|
+
chunksFound: chunks.length,
|
|
3103
|
+
chunksUsed: contextParts.length,
|
|
3104
|
+
totalChars: totalLen
|
|
3105
|
+
});
|
|
2756
3106
|
}
|
|
2757
3107
|
}
|
|
2758
|
-
const
|
|
2759
|
-
const
|
|
3108
|
+
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 }));
|
|
3109
|
+
const history = historyBeforeCurrentUser(historyRaw, message);
|
|
3110
|
+
let content;
|
|
3111
|
+
const ragContext = contextParts.length > 0 ? contextParts.join("\n\n") : void 0;
|
|
3112
|
+
console.info(RAG_LOG, "step 7 | final context", {
|
|
3113
|
+
method: contextParts.length > 0 ? "rag" : "none",
|
|
3114
|
+
contextChunks: contextParts.length,
|
|
3115
|
+
contextChars: ragContext?.length ?? 0,
|
|
3116
|
+
contextPreview: ragContext ? ragContext.slice(0, 200) + (ragContext.length > 200 ? "\u2026" : "") : "(no context)"
|
|
3117
|
+
});
|
|
3118
|
+
if (agentRow && llm.chatAgent) {
|
|
3119
|
+
const fromAgent = llmAgentToChatAgentOptions(agentRow);
|
|
3120
|
+
const systemPrompt = mergeGuardrailsIntoSystemPrompt(
|
|
3121
|
+
fromAgent.systemPrompt,
|
|
3122
|
+
parsedValidation.guardrailsForPrompt
|
|
3123
|
+
);
|
|
3124
|
+
const res = await llm.chatAgent({
|
|
3125
|
+
...fromAgent,
|
|
3126
|
+
systemPrompt: systemPrompt || void 0,
|
|
3127
|
+
context: ragContext,
|
|
3128
|
+
history,
|
|
3129
|
+
userPrompt: message
|
|
3130
|
+
});
|
|
3131
|
+
content = res.content;
|
|
3132
|
+
} else {
|
|
3133
|
+
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.
|
|
2760
3134
|
|
|
2761
3135
|
Context:
|
|
2762
|
-
${contextParts.join("\n\n")}` : "
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
3136
|
+
${contextParts.join("\n\n")}` : "";
|
|
3137
|
+
const defaultSystem = "You are a helpful assistant for the company. If you do not have specific information, say so.";
|
|
3138
|
+
let systemContent;
|
|
3139
|
+
if (agentRow) {
|
|
3140
|
+
const base = agentRow.systemInstruction?.trim() || "";
|
|
3141
|
+
systemContent = mergeGuardrailsIntoSystemPrompt(
|
|
3142
|
+
[base, ragSystem].filter(Boolean).join("\n\n") || defaultSystem,
|
|
3143
|
+
parsedValidation.guardrailsForPrompt
|
|
3144
|
+
);
|
|
3145
|
+
} else {
|
|
3146
|
+
systemContent = ragSystem || defaultSystem;
|
|
3147
|
+
}
|
|
3148
|
+
const messages = [
|
|
3149
|
+
{ role: "system", content: systemContent },
|
|
3150
|
+
...history,
|
|
3151
|
+
{ role: "user", content: message }
|
|
3152
|
+
];
|
|
3153
|
+
const chatOpts = agentRow ? {
|
|
3154
|
+
model: agentRow.model ?? void 0,
|
|
3155
|
+
temperature: agentRow.temperature ?? void 0,
|
|
3156
|
+
max_tokens: agentRow.maxTokens ?? void 0
|
|
3157
|
+
} : {};
|
|
3158
|
+
const res = await llm.chat(messages, chatOpts);
|
|
3159
|
+
content = res.content;
|
|
3160
|
+
}
|
|
2769
3161
|
await msgRepoInst.save(msgRepoInst.create({ conversationId, role: "assistant", content }));
|
|
2770
3162
|
return json({ content });
|
|
2771
3163
|
} catch (err) {
|
|
@@ -2776,6 +3168,560 @@ ${contextParts.join("\n\n")}` : "You are a helpful assistant for the company. If
|
|
|
2776
3168
|
};
|
|
2777
3169
|
}
|
|
2778
3170
|
|
|
3171
|
+
// src/api/llm-agent-knowledge-handlers.ts
|
|
3172
|
+
var import_typeorm6 = require("typeorm");
|
|
3173
|
+
var INGEST_CHUNK_CHARS = 900;
|
|
3174
|
+
var MAX_CHUNKS_PER_UPLOAD = 400;
|
|
3175
|
+
var EMBED_CONCURRENCY = 5;
|
|
3176
|
+
var MAX_PDF_BYTES = 25 * 1024 * 1024;
|
|
3177
|
+
var TEXT_FILE_TYPES = /* @__PURE__ */ new Set(["text/plain", "text/markdown", "application/json"]);
|
|
3178
|
+
var KB_LOG = "[llm-agent-knowledge]";
|
|
3179
|
+
function logKbPipeline(step, meta) {
|
|
3180
|
+
console.info(`${KB_LOG} pipeline`, { step, ...meta });
|
|
3181
|
+
}
|
|
3182
|
+
function llmEmbedDebug() {
|
|
3183
|
+
const v = process.env.LLM_EMBED_DEBUG?.toLowerCase();
|
|
3184
|
+
return v === "1" || v === "true" || v === "yes";
|
|
3185
|
+
}
|
|
3186
|
+
function isPdfUpload(mime, fileName) {
|
|
3187
|
+
if (mime === "application/pdf") return true;
|
|
3188
|
+
const n = fileName.toLowerCase();
|
|
3189
|
+
return n.endsWith(".pdf");
|
|
3190
|
+
}
|
|
3191
|
+
async function extractTextFromPdf(buffer) {
|
|
3192
|
+
const pdfParse = await import("pdf-parse");
|
|
3193
|
+
const data = await pdfParse(buffer);
|
|
3194
|
+
return (data?.text ?? "").trim();
|
|
3195
|
+
}
|
|
3196
|
+
async function loadChunksMissingEmbeddings(dataSource, documentId, slug) {
|
|
3197
|
+
const rows = await dataSource.query(
|
|
3198
|
+
`SELECT id, content FROM knowledge_base_chunks WHERE "documentId" = $1 AND embedding IS NULL ORDER BY "chunkIndex" ASC`,
|
|
3199
|
+
[documentId]
|
|
3200
|
+
);
|
|
3201
|
+
const list = rows ?? [];
|
|
3202
|
+
logKbPipeline("07_query_chunks_missing_embedding", {
|
|
3203
|
+
slug,
|
|
3204
|
+
documentId,
|
|
3205
|
+
missingEmbeddingCount: list.length
|
|
3206
|
+
});
|
|
3207
|
+
return list;
|
|
3208
|
+
}
|
|
3209
|
+
async function writeEmbeddingsConcurrent(dataSource, embed, chunks, concurrency, slug) {
|
|
3210
|
+
let next = 0;
|
|
3211
|
+
let written = 0;
|
|
3212
|
+
let failed = 0;
|
|
3213
|
+
let skippedEmpty = 0;
|
|
3214
|
+
logKbPipeline("09_embedding_workers_start", {
|
|
3215
|
+
slug,
|
|
3216
|
+
chunkCount: chunks.length,
|
|
3217
|
+
concurrency: Math.max(1, Math.min(concurrency, chunks.length))
|
|
3218
|
+
});
|
|
3219
|
+
async function worker() {
|
|
3220
|
+
for (; ; ) {
|
|
3221
|
+
const i = next++;
|
|
3222
|
+
if (i >= chunks.length) return;
|
|
3223
|
+
const c = chunks[i];
|
|
3224
|
+
try {
|
|
3225
|
+
const emb = await embed(c.content);
|
|
3226
|
+
if (emb?.length) {
|
|
3227
|
+
const vectorStr = "[" + emb.join(",") + "]";
|
|
3228
|
+
await dataSource.query(
|
|
3229
|
+
`UPDATE knowledge_base_chunks SET embedding = $1::vector WHERE id = $2`,
|
|
3230
|
+
[vectorStr, c.id]
|
|
3231
|
+
);
|
|
3232
|
+
written++;
|
|
3233
|
+
} else {
|
|
3234
|
+
skippedEmpty++;
|
|
3235
|
+
if (llmEmbedDebug()) {
|
|
3236
|
+
console.warn(`${KB_LOG} embed() returned empty vector`, { chunkId: c.id });
|
|
3237
|
+
}
|
|
3238
|
+
}
|
|
3239
|
+
} catch (err) {
|
|
3240
|
+
failed++;
|
|
3241
|
+
console.error(`${KB_LOG} embedding DB update failed`, {
|
|
3242
|
+
chunkId: c.id,
|
|
3243
|
+
err: err instanceof Error ? err.message : String(err)
|
|
3244
|
+
});
|
|
3245
|
+
}
|
|
3246
|
+
}
|
|
3247
|
+
}
|
|
3248
|
+
const n = Math.max(1, Math.min(concurrency, chunks.length));
|
|
3249
|
+
await Promise.all(Array.from({ length: n }, () => worker()));
|
|
3250
|
+
const summary = {
|
|
3251
|
+
chunkCount: chunks.length,
|
|
3252
|
+
written,
|
|
3253
|
+
failed,
|
|
3254
|
+
skippedEmpty
|
|
3255
|
+
};
|
|
3256
|
+
if (skippedEmpty > 0 && written === 0) {
|
|
3257
|
+
summary.hint = "embed() returned empty vectors \u2014 see [LLM embed] / [LLM embed HF] logs (OpenAI gateway vs @huggingface/inference + legacy HTTP).";
|
|
3258
|
+
}
|
|
3259
|
+
logKbPipeline("10_embedding_workers_finished", { slug, ...summary });
|
|
3260
|
+
if (failed > 0 || skippedEmpty > 0 && written === 0) {
|
|
3261
|
+
console.error(`${KB_LOG} embedding pass finished with issues`, summary);
|
|
3262
|
+
}
|
|
3263
|
+
return { written, failed };
|
|
3264
|
+
}
|
|
3265
|
+
function splitIntoChunks(text, maxLen) {
|
|
3266
|
+
const t = text.trim();
|
|
3267
|
+
if (!t) return [];
|
|
3268
|
+
const chunks = [];
|
|
3269
|
+
for (let i = 0; i < t.length; i += maxLen) {
|
|
3270
|
+
chunks.push(t.slice(i, i + maxLen));
|
|
3271
|
+
}
|
|
3272
|
+
return chunks;
|
|
3273
|
+
}
|
|
3274
|
+
async function findAgentBySlug(dataSource, llmAgents, slug) {
|
|
3275
|
+
const repo = dataSource.getRepository(llmAgents);
|
|
3276
|
+
return repo.findOne({
|
|
3277
|
+
where: { slug, deleted: false }
|
|
3278
|
+
});
|
|
3279
|
+
}
|
|
3280
|
+
function createLlmAgentKnowledgeHandlers(config) {
|
|
3281
|
+
const { dataSource, entityMap, getCms, json, requireAuth, requireEntityPermission } = config;
|
|
3282
|
+
const kbDoc = entityMap.knowledge_base_documents;
|
|
3283
|
+
const kbChunk = entityMap.knowledge_base_chunks;
|
|
3284
|
+
const llmAgents = entityMap.llm_agents;
|
|
3285
|
+
const junction = entityMap.llm_agent_knowledge_documents;
|
|
3286
|
+
if (!kbDoc || !kbChunk || !llmAgents || !junction) {
|
|
3287
|
+
return null;
|
|
3288
|
+
}
|
|
3289
|
+
async function gate(req, action) {
|
|
3290
|
+
const a = await requireAuth(req);
|
|
3291
|
+
if (a) return a;
|
|
3292
|
+
if (requireEntityPermission) {
|
|
3293
|
+
const pe = await requireEntityPermission(req, "llm_agents", action);
|
|
3294
|
+
if (pe) return pe;
|
|
3295
|
+
}
|
|
3296
|
+
return null;
|
|
3297
|
+
}
|
|
3298
|
+
async function runEmbeddingPass(slug, savedChunks) {
|
|
3299
|
+
let embeddingsWritten = 0;
|
|
3300
|
+
let embeddingsFailed = 0;
|
|
3301
|
+
try {
|
|
3302
|
+
logKbPipeline("08_resolve_llm_plugin", { slug, chunkCount: savedChunks.length });
|
|
3303
|
+
const cms = await getCms();
|
|
3304
|
+
const llm = cms.getPlugin("llm");
|
|
3305
|
+
if (llm?.embed && savedChunks.length > 0) {
|
|
3306
|
+
logKbPipeline("08b_embed_fn_available", {
|
|
3307
|
+
slug,
|
|
3308
|
+
chunkCount: savedChunks.length,
|
|
3309
|
+
firstChunkId: savedChunks[0]?.id,
|
|
3310
|
+
lastChunkId: savedChunks[savedChunks.length - 1]?.id
|
|
3311
|
+
});
|
|
3312
|
+
const embedBound = (text) => llm.embed(text);
|
|
3313
|
+
const { written, failed } = await writeEmbeddingsConcurrent(
|
|
3314
|
+
dataSource,
|
|
3315
|
+
embedBound,
|
|
3316
|
+
savedChunks,
|
|
3317
|
+
EMBED_CONCURRENCY,
|
|
3318
|
+
slug
|
|
3319
|
+
);
|
|
3320
|
+
embeddingsWritten = written;
|
|
3321
|
+
embeddingsFailed = failed;
|
|
3322
|
+
} else {
|
|
3323
|
+
logKbPipeline("08c_embed_skipped", {
|
|
3324
|
+
slug,
|
|
3325
|
+
hasLlmPlugin: !!llm,
|
|
3326
|
+
hasEmbed: typeof llm?.embed === "function",
|
|
3327
|
+
chunkCount: savedChunks.length,
|
|
3328
|
+
reason: savedChunks.length === 0 ? "no_chunks" : !llm ? "no_llm_plugin" : "no_embed_method"
|
|
3329
|
+
});
|
|
3330
|
+
console.error(`${KB_LOG} embeddings skipped`, {
|
|
3331
|
+
slug,
|
|
3332
|
+
hasLlmPlugin: !!llm,
|
|
3333
|
+
hasEmbed: typeof llm?.embed === "function",
|
|
3334
|
+
chunkCount: savedChunks.length,
|
|
3335
|
+
hint: !llm || typeof llm.embed !== "function" ? "LLM plugin missing or no embed(); check LLM_GATEWAY_URL + LLM_API_KEY so llm plugin initializes." : void 0
|
|
3336
|
+
});
|
|
3337
|
+
}
|
|
3338
|
+
} catch (embErr) {
|
|
3339
|
+
const detail = embErr instanceof Error ? embErr.message : String(embErr);
|
|
3340
|
+
logKbPipeline("08d_embed_pass_exception", { slug, detail });
|
|
3341
|
+
console.error(`${KB_LOG} embedding step threw before/during batch`, { slug, detail, embErr });
|
|
3342
|
+
return {
|
|
3343
|
+
embeddingsWritten: 0,
|
|
3344
|
+
embeddingsFailed: savedChunks.length,
|
|
3345
|
+
embedError: detail
|
|
3346
|
+
};
|
|
3347
|
+
}
|
|
3348
|
+
return { embeddingsWritten, embeddingsFailed };
|
|
3349
|
+
}
|
|
3350
|
+
return {
|
|
3351
|
+
async list(req, slug) {
|
|
3352
|
+
const denied = await gate(req, "read");
|
|
3353
|
+
if (denied) return denied;
|
|
3354
|
+
try {
|
|
3355
|
+
const agent = await findAgentBySlug(dataSource, llmAgents, slug);
|
|
3356
|
+
if (!agent) return json({ error: "Agent not found" }, { status: 404 });
|
|
3357
|
+
const linkRepo = dataSource.getRepository(junction);
|
|
3358
|
+
const links = await linkRepo.find({ where: { agentId: agent.id } });
|
|
3359
|
+
const docIds = [...new Set(links.map((l) => l.documentId))];
|
|
3360
|
+
if (docIds.length === 0) return json({ documents: [] });
|
|
3361
|
+
const docRepo = dataSource.getRepository(kbDoc);
|
|
3362
|
+
const docs = await docRepo.find({ where: { id: (0, import_typeorm6.In)(docIds) } });
|
|
3363
|
+
const byId = new Map(docs.map((d) => [d.id, d]));
|
|
3364
|
+
const documents = docIds.map((id) => {
|
|
3365
|
+
const d = byId.get(id);
|
|
3366
|
+
return d ? { id: d.id, name: d.name } : null;
|
|
3367
|
+
}).filter(Boolean);
|
|
3368
|
+
return json({ documents });
|
|
3369
|
+
} catch (err) {
|
|
3370
|
+
const msg = err instanceof Error ? err.message : "Failed to list knowledge";
|
|
3371
|
+
return json({ error: msg }, { status: 500 });
|
|
3372
|
+
}
|
|
3373
|
+
},
|
|
3374
|
+
async post(req, slug) {
|
|
3375
|
+
const denied = await gate(req, "update");
|
|
3376
|
+
if (denied) return denied;
|
|
3377
|
+
try {
|
|
3378
|
+
const ct0 = req.headers.get("content-type") || "";
|
|
3379
|
+
logKbPipeline("01_request", { slug, contentType: ct0.slice(0, 80) });
|
|
3380
|
+
const agent = await findAgentBySlug(dataSource, llmAgents, slug);
|
|
3381
|
+
if (!agent) return json({ error: "Agent not found" }, { status: 404 });
|
|
3382
|
+
logKbPipeline("02_agent_loaded", { slug, agentId: agent.id });
|
|
3383
|
+
let name = "";
|
|
3384
|
+
let text = "";
|
|
3385
|
+
let sourceUrl = null;
|
|
3386
|
+
let existingDocumentId = null;
|
|
3387
|
+
const ct = req.headers.get("content-type") || "";
|
|
3388
|
+
if (ct.includes("application/json")) {
|
|
3389
|
+
const body = await req.json();
|
|
3390
|
+
existingDocumentId = typeof body?.documentId === "number" && Number.isFinite(body.documentId) ? body.documentId : null;
|
|
3391
|
+
name = (body?.name ?? "").trim();
|
|
3392
|
+
text = (body?.text ?? "").trim();
|
|
3393
|
+
sourceUrl = typeof body?.sourceUrl === "string" && body.sourceUrl.trim() ? body.sourceUrl.trim() : null;
|
|
3394
|
+
logKbPipeline("03_body_parsed", {
|
|
3395
|
+
slug,
|
|
3396
|
+
mode: "json",
|
|
3397
|
+
existingDocumentId,
|
|
3398
|
+
nameLen: name.length,
|
|
3399
|
+
textChars: text.length,
|
|
3400
|
+
hasSourceUrl: !!sourceUrl
|
|
3401
|
+
});
|
|
3402
|
+
} else if (ct.includes("multipart/form-data")) {
|
|
3403
|
+
const form = await req.formData();
|
|
3404
|
+
name = form.get("name")?.trim() ?? "";
|
|
3405
|
+
text = form.get("text")?.trim() ?? "";
|
|
3406
|
+
const file = form.get("file");
|
|
3407
|
+
if (file && typeof file !== "string" && "arrayBuffer" in file) {
|
|
3408
|
+
const f = file;
|
|
3409
|
+
const mime = (f.type || "").split(";")[0].trim().toLowerCase();
|
|
3410
|
+
const buf = Buffer.from(await f.arrayBuffer());
|
|
3411
|
+
logKbPipeline("03_body_parsed", {
|
|
3412
|
+
slug,
|
|
3413
|
+
mode: "multipart",
|
|
3414
|
+
fileName: f.name || "(no name)",
|
|
3415
|
+
mime,
|
|
3416
|
+
fileBytes: buf.length
|
|
3417
|
+
});
|
|
3418
|
+
if (TEXT_FILE_TYPES.has(mime)) {
|
|
3419
|
+
const decoded = buf.toString("utf8");
|
|
3420
|
+
if (!text) text = decoded;
|
|
3421
|
+
logKbPipeline("04_file_decoded_text", { slug, mime, textChars: text.length });
|
|
3422
|
+
} else if (isPdfUpload(mime, f.name || "")) {
|
|
3423
|
+
if (buf.length > MAX_PDF_BYTES) {
|
|
3424
|
+
return json(
|
|
3425
|
+
{ error: `PDF too large (max ${Math.floor(MAX_PDF_BYTES / (1024 * 1024))}MB)` },
|
|
3426
|
+
{ status: 413 }
|
|
3427
|
+
);
|
|
3428
|
+
}
|
|
3429
|
+
try {
|
|
3430
|
+
logKbPipeline("04_pdf_extract_start", { slug, fileBytes: buf.length });
|
|
3431
|
+
const extracted = await extractTextFromPdf(buf);
|
|
3432
|
+
if (!text) text = extracted;
|
|
3433
|
+
logKbPipeline("04_pdf_extract_done", { slug, textChars: text.length });
|
|
3434
|
+
} catch {
|
|
3435
|
+
return json(
|
|
3436
|
+
{ error: "Could not read PDF text (file may be encrypted, corrupt, or image-only)" },
|
|
3437
|
+
{ status: 422 }
|
|
3438
|
+
);
|
|
3439
|
+
}
|
|
3440
|
+
} else {
|
|
3441
|
+
return json(
|
|
3442
|
+
{
|
|
3443
|
+
error: "Unsupported file type; use text/plain, text/markdown, application/json, or application/pdf"
|
|
3444
|
+
},
|
|
3445
|
+
{ status: 415 }
|
|
3446
|
+
);
|
|
3447
|
+
}
|
|
3448
|
+
if (!name && f.name) name = f.name.replace(/\.[^/.]+$/, "") || f.name;
|
|
3449
|
+
} else {
|
|
3450
|
+
logKbPipeline("03_body_parsed", { slug, mode: "multipart", hasFile: false, textChars: text.length });
|
|
3451
|
+
}
|
|
3452
|
+
} else {
|
|
3453
|
+
return json({ error: "Use application/json or multipart/form-data" }, { status: 400 });
|
|
3454
|
+
}
|
|
3455
|
+
const linkRepo = dataSource.getRepository(junction);
|
|
3456
|
+
if (existingDocumentId != null) {
|
|
3457
|
+
logKbPipeline("05_branch", { slug, branch: "link_existing_document", documentId: existingDocumentId });
|
|
3458
|
+
const docRepo2 = dataSource.getRepository(kbDoc);
|
|
3459
|
+
const existing = await docRepo2.findOne({ where: { id: existingDocumentId } });
|
|
3460
|
+
if (!existing) return json({ error: "documentId not found" }, { status: 404 });
|
|
3461
|
+
const dup2 = await linkRepo.findOne({
|
|
3462
|
+
where: { agentId: agent.id, documentId: existingDocumentId }
|
|
3463
|
+
});
|
|
3464
|
+
if (!dup2) {
|
|
3465
|
+
await linkRepo.save(linkRepo.create({ agentId: agent.id, documentId: existingDocumentId }));
|
|
3466
|
+
logKbPipeline("06_junction_link_created", {
|
|
3467
|
+
slug,
|
|
3468
|
+
agentId: agent.id,
|
|
3469
|
+
documentId: existingDocumentId
|
|
3470
|
+
});
|
|
3471
|
+
} else {
|
|
3472
|
+
logKbPipeline("06_junction_link_exists", {
|
|
3473
|
+
slug,
|
|
3474
|
+
agentId: agent.id,
|
|
3475
|
+
documentId: existingDocumentId
|
|
3476
|
+
});
|
|
3477
|
+
}
|
|
3478
|
+
const chunkRepo2 = dataSource.getRepository(kbChunk);
|
|
3479
|
+
const docRow = existing;
|
|
3480
|
+
const chunkCount = await chunkRepo2.count({ where: { documentId: existingDocumentId } });
|
|
3481
|
+
logKbPipeline("06b_chunks_existing_count", {
|
|
3482
|
+
slug,
|
|
3483
|
+
documentId: existingDocumentId,
|
|
3484
|
+
chunkCount
|
|
3485
|
+
});
|
|
3486
|
+
let chunksToEmbed = [];
|
|
3487
|
+
let chunksCreated = 0;
|
|
3488
|
+
if (chunkCount === 0) {
|
|
3489
|
+
const text2 = (docRow.content ?? "").trim();
|
|
3490
|
+
if (!text2) {
|
|
3491
|
+
logKbPipeline("07_ingest_aborted_empty_document", { slug, documentId: existingDocumentId });
|
|
3492
|
+
return json({
|
|
3493
|
+
documentId: existingDocumentId,
|
|
3494
|
+
linked: true,
|
|
3495
|
+
created: false,
|
|
3496
|
+
chunkCount: 0,
|
|
3497
|
+
embeddingsWritten: 0,
|
|
3498
|
+
embeddingsFailed: 0,
|
|
3499
|
+
warning: "Document has no text content; add content then attach again to build chunks and embeddings."
|
|
3500
|
+
});
|
|
3501
|
+
}
|
|
3502
|
+
const parts2 = splitIntoChunks(text2, INGEST_CHUNK_CHARS);
|
|
3503
|
+
if (parts2.length > MAX_CHUNKS_PER_UPLOAD) {
|
|
3504
|
+
return json(
|
|
3505
|
+
{
|
|
3506
|
+
error: `Document is too large for one ingest (${parts2.length} chunks; max ${MAX_CHUNKS_PER_UPLOAD}). Split into smaller files.`
|
|
3507
|
+
},
|
|
3508
|
+
{ status: 413 }
|
|
3509
|
+
);
|
|
3510
|
+
}
|
|
3511
|
+
logKbPipeline("07_chunk_split", {
|
|
3512
|
+
slug,
|
|
3513
|
+
documentId: existingDocumentId,
|
|
3514
|
+
partCount: parts2.length,
|
|
3515
|
+
maxChunkChars: INGEST_CHUNK_CHARS,
|
|
3516
|
+
totalChars: text2.length
|
|
3517
|
+
});
|
|
3518
|
+
const now2 = /* @__PURE__ */ new Date();
|
|
3519
|
+
const chunkRows2 = parts2.map(
|
|
3520
|
+
(content, i) => chunkRepo2.create({
|
|
3521
|
+
documentId: existingDocumentId,
|
|
3522
|
+
content,
|
|
3523
|
+
chunkIndex: i,
|
|
3524
|
+
createdAt: now2
|
|
3525
|
+
})
|
|
3526
|
+
);
|
|
3527
|
+
const savedList2 = await chunkRepo2.save(chunkRows2);
|
|
3528
|
+
chunksCreated = savedList2.length;
|
|
3529
|
+
chunksToEmbed = savedList2.map((row, i) => ({
|
|
3530
|
+
id: row.id,
|
|
3531
|
+
content: parts2[i]
|
|
3532
|
+
}));
|
|
3533
|
+
logKbPipeline("07b_chunks_persisted", {
|
|
3534
|
+
slug,
|
|
3535
|
+
documentId: existingDocumentId,
|
|
3536
|
+
rowsInserted: chunksCreated
|
|
3537
|
+
});
|
|
3538
|
+
} else {
|
|
3539
|
+
chunksToEmbed = await loadChunksMissingEmbeddings(dataSource, existingDocumentId, slug);
|
|
3540
|
+
if (chunksToEmbed.length === 0) {
|
|
3541
|
+
logKbPipeline("08_skip_embed_all_chunks_have_vectors", {
|
|
3542
|
+
slug,
|
|
3543
|
+
documentId: existingDocumentId,
|
|
3544
|
+
existingChunkCount: chunkCount
|
|
3545
|
+
});
|
|
3546
|
+
}
|
|
3547
|
+
}
|
|
3548
|
+
const embedResult2 = chunksToEmbed.length > 0 ? await runEmbeddingPass(slug, chunksToEmbed) : { embeddingsWritten: 0, embeddingsFailed: 0 };
|
|
3549
|
+
if (embedResult2.embedError) {
|
|
3550
|
+
logKbPipeline("11_response", {
|
|
3551
|
+
slug,
|
|
3552
|
+
branch: "link",
|
|
3553
|
+
documentId: existingDocumentId,
|
|
3554
|
+
ok: false,
|
|
3555
|
+
embeddingError: true
|
|
3556
|
+
});
|
|
3557
|
+
return json(
|
|
3558
|
+
{
|
|
3559
|
+
documentId: existingDocumentId,
|
|
3560
|
+
linked: true,
|
|
3561
|
+
created: false,
|
|
3562
|
+
chunkCount: chunkCount + chunksCreated,
|
|
3563
|
+
chunksCreated,
|
|
3564
|
+
embeddingAttempted: true,
|
|
3565
|
+
embeddingsWritten: 0,
|
|
3566
|
+
embeddingsFailed: chunksToEmbed.length,
|
|
3567
|
+
warning: "Document linked; embedding step failed. Fix LLM/embed config and attach again (or unlink and re-attach) to retry NULL embeddings.",
|
|
3568
|
+
detail: embedResult2.embedError
|
|
3569
|
+
},
|
|
3570
|
+
{ status: 201 }
|
|
3571
|
+
);
|
|
3572
|
+
}
|
|
3573
|
+
logKbPipeline("11_response", {
|
|
3574
|
+
slug,
|
|
3575
|
+
branch: "link",
|
|
3576
|
+
documentId: existingDocumentId,
|
|
3577
|
+
ok: true,
|
|
3578
|
+
chunkCount: chunkCount + chunksCreated,
|
|
3579
|
+
chunksCreated,
|
|
3580
|
+
chunksQueuedForEmbedding: chunksToEmbed.length,
|
|
3581
|
+
embeddingsWritten: embedResult2.embeddingsWritten,
|
|
3582
|
+
embeddingsFailed: embedResult2.embeddingsFailed
|
|
3583
|
+
});
|
|
3584
|
+
return json({
|
|
3585
|
+
documentId: existingDocumentId,
|
|
3586
|
+
linked: true,
|
|
3587
|
+
created: false,
|
|
3588
|
+
chunkCount: chunkCount + chunksCreated,
|
|
3589
|
+
chunksCreated: chunksCreated || void 0,
|
|
3590
|
+
chunksQueuedForEmbedding: chunksToEmbed.length,
|
|
3591
|
+
embeddingAttempted: chunksToEmbed.length > 0,
|
|
3592
|
+
embeddingsWritten: embedResult2.embeddingsWritten,
|
|
3593
|
+
embeddingsFailed: embedResult2.embeddingsFailed
|
|
3594
|
+
});
|
|
3595
|
+
}
|
|
3596
|
+
logKbPipeline("05_branch", { slug, branch: "new_upload_ingest" });
|
|
3597
|
+
if (!text) return json({ error: "text or file with text content is required" }, { status: 400 });
|
|
3598
|
+
if (!name) name = "Untitled";
|
|
3599
|
+
const parts = splitIntoChunks(text, INGEST_CHUNK_CHARS);
|
|
3600
|
+
if (parts.length === 0) {
|
|
3601
|
+
return json({ error: "text or file with text content is required" }, { status: 400 });
|
|
3602
|
+
}
|
|
3603
|
+
if (parts.length > MAX_CHUNKS_PER_UPLOAD) {
|
|
3604
|
+
return json(
|
|
3605
|
+
{
|
|
3606
|
+
error: `Document is too large for one upload (${parts.length} chunks; max ${MAX_CHUNKS_PER_UPLOAD}). Split into smaller files.`
|
|
3607
|
+
},
|
|
3608
|
+
{ status: 413 }
|
|
3609
|
+
);
|
|
3610
|
+
}
|
|
3611
|
+
logKbPipeline("07_chunk_split", {
|
|
3612
|
+
slug,
|
|
3613
|
+
partCount: parts.length,
|
|
3614
|
+
maxChunkChars: INGEST_CHUNK_CHARS,
|
|
3615
|
+
totalChars: text.length,
|
|
3616
|
+
documentName: name
|
|
3617
|
+
});
|
|
3618
|
+
const docRepo = dataSource.getRepository(kbDoc);
|
|
3619
|
+
const chunkRepo = dataSource.getRepository(kbChunk);
|
|
3620
|
+
const now = /* @__PURE__ */ new Date();
|
|
3621
|
+
const doc = await docRepo.save(
|
|
3622
|
+
docRepo.create({ name, content: text, sourceUrl, createdAt: now, updatedAt: now })
|
|
3623
|
+
);
|
|
3624
|
+
const docId = doc.id;
|
|
3625
|
+
logKbPipeline("06_knowledge_document_saved", {
|
|
3626
|
+
slug,
|
|
3627
|
+
documentId: docId,
|
|
3628
|
+
name,
|
|
3629
|
+
contentChars: text.length,
|
|
3630
|
+
hasSourceUrl: !!sourceUrl
|
|
3631
|
+
});
|
|
3632
|
+
const chunkRows = parts.map(
|
|
3633
|
+
(content, i) => chunkRepo.create({ documentId: docId, content, chunkIndex: i, createdAt: now })
|
|
3634
|
+
);
|
|
3635
|
+
const savedList = await chunkRepo.save(chunkRows);
|
|
3636
|
+
const savedChunks = savedList.map(
|
|
3637
|
+
(row, i) => ({
|
|
3638
|
+
id: row.id,
|
|
3639
|
+
content: parts[i]
|
|
3640
|
+
})
|
|
3641
|
+
);
|
|
3642
|
+
logKbPipeline("07b_chunks_persisted", {
|
|
3643
|
+
slug,
|
|
3644
|
+
documentId: docId,
|
|
3645
|
+
rowsInserted: savedChunks.length,
|
|
3646
|
+
firstChunkId: savedChunks[0]?.id,
|
|
3647
|
+
lastChunkId: savedChunks[savedChunks.length - 1]?.id
|
|
3648
|
+
});
|
|
3649
|
+
const dup = await linkRepo.findOne({ where: { agentId: agent.id, documentId: docId } });
|
|
3650
|
+
if (!dup) {
|
|
3651
|
+
await linkRepo.save(linkRepo.create({ agentId: agent.id, documentId: docId }));
|
|
3652
|
+
logKbPipeline("06c_junction_link_created", { slug, agentId: agent.id, documentId: docId });
|
|
3653
|
+
} else {
|
|
3654
|
+
logKbPipeline("06c_junction_link_exists", { slug, agentId: agent.id, documentId: docId });
|
|
3655
|
+
}
|
|
3656
|
+
const embedResult = await runEmbeddingPass(slug, savedChunks);
|
|
3657
|
+
if (embedResult.embedError) {
|
|
3658
|
+
logKbPipeline("11_response", {
|
|
3659
|
+
slug,
|
|
3660
|
+
branch: "ingest",
|
|
3661
|
+
documentId: docId,
|
|
3662
|
+
ok: false,
|
|
3663
|
+
embeddingError: true
|
|
3664
|
+
});
|
|
3665
|
+
return json(
|
|
3666
|
+
{
|
|
3667
|
+
documentId: docId,
|
|
3668
|
+
chunkCount: savedChunks.length,
|
|
3669
|
+
embeddingAttempted: true,
|
|
3670
|
+
created: true,
|
|
3671
|
+
linked: true,
|
|
3672
|
+
embeddingsWritten: 0,
|
|
3673
|
+
embeddingsFailed: savedChunks.length,
|
|
3674
|
+
warning: "Document saved and linked; embedding step failed.",
|
|
3675
|
+
detail: embedResult.embedError
|
|
3676
|
+
},
|
|
3677
|
+
{ status: 201 }
|
|
3678
|
+
);
|
|
3679
|
+
}
|
|
3680
|
+
logKbPipeline("11_response", {
|
|
3681
|
+
slug,
|
|
3682
|
+
branch: "ingest",
|
|
3683
|
+
documentId: docId,
|
|
3684
|
+
ok: true,
|
|
3685
|
+
chunkCount: savedChunks.length,
|
|
3686
|
+
embeddingsWritten: embedResult.embeddingsWritten,
|
|
3687
|
+
embeddingsFailed: embedResult.embeddingsFailed
|
|
3688
|
+
});
|
|
3689
|
+
return json({
|
|
3690
|
+
documentId: docId,
|
|
3691
|
+
chunkCount: savedChunks.length,
|
|
3692
|
+
embeddingAttempted: savedChunks.length > 0,
|
|
3693
|
+
created: true,
|
|
3694
|
+
linked: true,
|
|
3695
|
+
embeddingsWritten: embedResult.embeddingsWritten,
|
|
3696
|
+
embeddingsFailed: embedResult.embeddingsFailed
|
|
3697
|
+
});
|
|
3698
|
+
} catch (err) {
|
|
3699
|
+
const msg = err instanceof Error ? err.message : "Failed to ingest knowledge";
|
|
3700
|
+
const name = err instanceof Error ? err.name : "";
|
|
3701
|
+
logKbPipeline("99_pipeline_error", { slug, errorName: name, message: msg });
|
|
3702
|
+
return json({ error: msg, errorName: name || void 0 }, { status: 500 });
|
|
3703
|
+
}
|
|
3704
|
+
},
|
|
3705
|
+
async unlink(req, slug, documentIdStr) {
|
|
3706
|
+
const denied = await gate(req, "update");
|
|
3707
|
+
if (denied) return denied;
|
|
3708
|
+
const documentId = parseInt(documentIdStr, 10);
|
|
3709
|
+
if (!Number.isFinite(documentId)) return json({ error: "Invalid document id" }, { status: 400 });
|
|
3710
|
+
try {
|
|
3711
|
+
const agent = await findAgentBySlug(dataSource, llmAgents, slug);
|
|
3712
|
+
if (!agent) return json({ error: "Agent not found" }, { status: 404 });
|
|
3713
|
+
logKbPipeline("unlink_junction", { slug, agentId: agent.id, documentId });
|
|
3714
|
+
const linkRepo = dataSource.getRepository(junction);
|
|
3715
|
+
await linkRepo.delete({ agentId: agent.id, documentId });
|
|
3716
|
+
return json({ ok: true });
|
|
3717
|
+
} catch (err) {
|
|
3718
|
+
const msg = err instanceof Error ? err.message : "Failed to unlink";
|
|
3719
|
+
return json({ error: msg }, { status: 500 });
|
|
3720
|
+
}
|
|
3721
|
+
}
|
|
3722
|
+
};
|
|
3723
|
+
}
|
|
3724
|
+
|
|
2779
3725
|
// src/message-templates/sms-defaults.ts
|
|
2780
3726
|
var SMS_MESSAGE_TEMPLATE_DEFAULTS = [
|
|
2781
3727
|
{
|
|
@@ -3083,7 +4029,2623 @@ function createAdminRolesHandlers(config) {
|
|
|
3083
4029
|
};
|
|
3084
4030
|
}
|
|
3085
4031
|
|
|
4032
|
+
// src/entities/user.entity.ts
|
|
4033
|
+
var import_typeorm9 = require("typeorm");
|
|
4034
|
+
|
|
4035
|
+
// src/entities/user-group.entity.ts
|
|
4036
|
+
var import_typeorm8 = require("typeorm");
|
|
4037
|
+
|
|
4038
|
+
// src/entities/permission.entity.ts
|
|
4039
|
+
var import_typeorm7 = require("typeorm");
|
|
4040
|
+
var Permission = class {
|
|
4041
|
+
id;
|
|
4042
|
+
groupId;
|
|
4043
|
+
entity;
|
|
4044
|
+
canCreate;
|
|
4045
|
+
canRead;
|
|
4046
|
+
canUpdate;
|
|
4047
|
+
canDelete;
|
|
4048
|
+
createdAt;
|
|
4049
|
+
updatedAt;
|
|
4050
|
+
deletedAt;
|
|
4051
|
+
deleted;
|
|
4052
|
+
createdBy;
|
|
4053
|
+
updatedBy;
|
|
4054
|
+
deletedBy;
|
|
4055
|
+
group;
|
|
4056
|
+
};
|
|
4057
|
+
__decorateClass([
|
|
4058
|
+
(0, import_typeorm7.PrimaryGeneratedColumn)()
|
|
4059
|
+
], Permission.prototype, "id", 2);
|
|
4060
|
+
__decorateClass([
|
|
4061
|
+
(0, import_typeorm7.Column)("int")
|
|
4062
|
+
], Permission.prototype, "groupId", 2);
|
|
4063
|
+
__decorateClass([
|
|
4064
|
+
(0, import_typeorm7.Column)("varchar")
|
|
4065
|
+
], Permission.prototype, "entity", 2);
|
|
4066
|
+
__decorateClass([
|
|
4067
|
+
(0, import_typeorm7.Column)("boolean", { default: false })
|
|
4068
|
+
], Permission.prototype, "canCreate", 2);
|
|
4069
|
+
__decorateClass([
|
|
4070
|
+
(0, import_typeorm7.Column)("boolean", { default: false })
|
|
4071
|
+
], Permission.prototype, "canRead", 2);
|
|
4072
|
+
__decorateClass([
|
|
4073
|
+
(0, import_typeorm7.Column)("boolean", { default: false })
|
|
4074
|
+
], Permission.prototype, "canUpdate", 2);
|
|
4075
|
+
__decorateClass([
|
|
4076
|
+
(0, import_typeorm7.Column)("boolean", { default: false })
|
|
4077
|
+
], Permission.prototype, "canDelete", 2);
|
|
4078
|
+
__decorateClass([
|
|
4079
|
+
(0, import_typeorm7.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4080
|
+
], Permission.prototype, "createdAt", 2);
|
|
4081
|
+
__decorateClass([
|
|
4082
|
+
(0, import_typeorm7.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4083
|
+
], Permission.prototype, "updatedAt", 2);
|
|
4084
|
+
__decorateClass([
|
|
4085
|
+
(0, import_typeorm7.Column)({ type: "timestamp", nullable: true })
|
|
4086
|
+
], Permission.prototype, "deletedAt", 2);
|
|
4087
|
+
__decorateClass([
|
|
4088
|
+
(0, import_typeorm7.Column)("boolean", { default: false })
|
|
4089
|
+
], Permission.prototype, "deleted", 2);
|
|
4090
|
+
__decorateClass([
|
|
4091
|
+
(0, import_typeorm7.Column)("int", { nullable: true })
|
|
4092
|
+
], Permission.prototype, "createdBy", 2);
|
|
4093
|
+
__decorateClass([
|
|
4094
|
+
(0, import_typeorm7.Column)("int", { nullable: true })
|
|
4095
|
+
], Permission.prototype, "updatedBy", 2);
|
|
4096
|
+
__decorateClass([
|
|
4097
|
+
(0, import_typeorm7.Column)("int", { nullable: true })
|
|
4098
|
+
], Permission.prototype, "deletedBy", 2);
|
|
4099
|
+
__decorateClass([
|
|
4100
|
+
(0, import_typeorm7.ManyToOne)(() => UserGroup, (g) => g.permissions, { onDelete: "CASCADE" }),
|
|
4101
|
+
(0, import_typeorm7.JoinColumn)({ name: "groupId" })
|
|
4102
|
+
], Permission.prototype, "group", 2);
|
|
4103
|
+
Permission = __decorateClass([
|
|
4104
|
+
(0, import_typeorm7.Entity)("permissions")
|
|
4105
|
+
], Permission);
|
|
4106
|
+
|
|
4107
|
+
// src/entities/user-group.entity.ts
|
|
4108
|
+
var UserGroup = class {
|
|
4109
|
+
id;
|
|
4110
|
+
name;
|
|
4111
|
+
createdAt;
|
|
4112
|
+
updatedAt;
|
|
4113
|
+
deletedAt;
|
|
4114
|
+
deleted;
|
|
4115
|
+
createdBy;
|
|
4116
|
+
updatedBy;
|
|
4117
|
+
deletedBy;
|
|
4118
|
+
permissions;
|
|
4119
|
+
users;
|
|
4120
|
+
};
|
|
4121
|
+
__decorateClass([
|
|
4122
|
+
(0, import_typeorm8.PrimaryGeneratedColumn)()
|
|
4123
|
+
], UserGroup.prototype, "id", 2);
|
|
4124
|
+
__decorateClass([
|
|
4125
|
+
(0, import_typeorm8.Column)("varchar", { unique: true })
|
|
4126
|
+
], UserGroup.prototype, "name", 2);
|
|
4127
|
+
__decorateClass([
|
|
4128
|
+
(0, import_typeorm8.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4129
|
+
], UserGroup.prototype, "createdAt", 2);
|
|
4130
|
+
__decorateClass([
|
|
4131
|
+
(0, import_typeorm8.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4132
|
+
], UserGroup.prototype, "updatedAt", 2);
|
|
4133
|
+
__decorateClass([
|
|
4134
|
+
(0, import_typeorm8.Column)({ type: "timestamp", nullable: true })
|
|
4135
|
+
], UserGroup.prototype, "deletedAt", 2);
|
|
4136
|
+
__decorateClass([
|
|
4137
|
+
(0, import_typeorm8.Column)("boolean", { default: false })
|
|
4138
|
+
], UserGroup.prototype, "deleted", 2);
|
|
4139
|
+
__decorateClass([
|
|
4140
|
+
(0, import_typeorm8.Column)("int", { nullable: true })
|
|
4141
|
+
], UserGroup.prototype, "createdBy", 2);
|
|
4142
|
+
__decorateClass([
|
|
4143
|
+
(0, import_typeorm8.Column)("int", { nullable: true })
|
|
4144
|
+
], UserGroup.prototype, "updatedBy", 2);
|
|
4145
|
+
__decorateClass([
|
|
4146
|
+
(0, import_typeorm8.Column)("int", { nullable: true })
|
|
4147
|
+
], UserGroup.prototype, "deletedBy", 2);
|
|
4148
|
+
__decorateClass([
|
|
4149
|
+
(0, import_typeorm8.OneToMany)(() => Permission, (p) => p.group)
|
|
4150
|
+
], UserGroup.prototype, "permissions", 2);
|
|
4151
|
+
__decorateClass([
|
|
4152
|
+
(0, import_typeorm8.OneToMany)(() => User, (u) => u.group)
|
|
4153
|
+
], UserGroup.prototype, "users", 2);
|
|
4154
|
+
UserGroup = __decorateClass([
|
|
4155
|
+
(0, import_typeorm8.Entity)("user_groups")
|
|
4156
|
+
], UserGroup);
|
|
4157
|
+
|
|
4158
|
+
// src/entities/user.entity.ts
|
|
4159
|
+
var User = class {
|
|
4160
|
+
id;
|
|
4161
|
+
name;
|
|
4162
|
+
email;
|
|
4163
|
+
phone;
|
|
4164
|
+
phoneVerifiedAt;
|
|
4165
|
+
emailVerifiedAt;
|
|
4166
|
+
password;
|
|
4167
|
+
blocked;
|
|
4168
|
+
adminAccess;
|
|
4169
|
+
groupId;
|
|
4170
|
+
createdAt;
|
|
4171
|
+
updatedAt;
|
|
4172
|
+
deletedAt;
|
|
4173
|
+
deleted;
|
|
4174
|
+
createdBy;
|
|
4175
|
+
updatedBy;
|
|
4176
|
+
deletedBy;
|
|
4177
|
+
group;
|
|
4178
|
+
};
|
|
4179
|
+
__decorateClass([
|
|
4180
|
+
(0, import_typeorm9.PrimaryGeneratedColumn)()
|
|
4181
|
+
], User.prototype, "id", 2);
|
|
4182
|
+
__decorateClass([
|
|
4183
|
+
(0, import_typeorm9.Column)("varchar")
|
|
4184
|
+
], User.prototype, "name", 2);
|
|
4185
|
+
__decorateClass([
|
|
4186
|
+
(0, import_typeorm9.Column)("varchar", { unique: true })
|
|
4187
|
+
], User.prototype, "email", 2);
|
|
4188
|
+
__decorateClass([
|
|
4189
|
+
(0, import_typeorm9.Column)("varchar", { nullable: true })
|
|
4190
|
+
], User.prototype, "phone", 2);
|
|
4191
|
+
__decorateClass([
|
|
4192
|
+
(0, import_typeorm9.Column)({ type: "timestamp", nullable: true })
|
|
4193
|
+
], User.prototype, "phoneVerifiedAt", 2);
|
|
4194
|
+
__decorateClass([
|
|
4195
|
+
(0, import_typeorm9.Column)({ type: "timestamp", nullable: true })
|
|
4196
|
+
], User.prototype, "emailVerifiedAt", 2);
|
|
4197
|
+
__decorateClass([
|
|
4198
|
+
(0, import_typeorm9.Column)("varchar", { nullable: true })
|
|
4199
|
+
], User.prototype, "password", 2);
|
|
4200
|
+
__decorateClass([
|
|
4201
|
+
(0, import_typeorm9.Column)("boolean", { default: false })
|
|
4202
|
+
], User.prototype, "blocked", 2);
|
|
4203
|
+
__decorateClass([
|
|
4204
|
+
(0, import_typeorm9.Column)("boolean", { default: false })
|
|
4205
|
+
], User.prototype, "adminAccess", 2);
|
|
4206
|
+
__decorateClass([
|
|
4207
|
+
(0, import_typeorm9.Column)("int", { nullable: true })
|
|
4208
|
+
], User.prototype, "groupId", 2);
|
|
4209
|
+
__decorateClass([
|
|
4210
|
+
(0, import_typeorm9.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4211
|
+
], User.prototype, "createdAt", 2);
|
|
4212
|
+
__decorateClass([
|
|
4213
|
+
(0, import_typeorm9.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4214
|
+
], User.prototype, "updatedAt", 2);
|
|
4215
|
+
__decorateClass([
|
|
4216
|
+
(0, import_typeorm9.Column)({ type: "timestamp", nullable: true })
|
|
4217
|
+
], User.prototype, "deletedAt", 2);
|
|
4218
|
+
__decorateClass([
|
|
4219
|
+
(0, import_typeorm9.Column)("boolean", { default: false })
|
|
4220
|
+
], User.prototype, "deleted", 2);
|
|
4221
|
+
__decorateClass([
|
|
4222
|
+
(0, import_typeorm9.Column)("int", { nullable: true })
|
|
4223
|
+
], User.prototype, "createdBy", 2);
|
|
4224
|
+
__decorateClass([
|
|
4225
|
+
(0, import_typeorm9.Column)("int", { nullable: true })
|
|
4226
|
+
], User.prototype, "updatedBy", 2);
|
|
4227
|
+
__decorateClass([
|
|
4228
|
+
(0, import_typeorm9.Column)("int", { nullable: true })
|
|
4229
|
+
], User.prototype, "deletedBy", 2);
|
|
4230
|
+
__decorateClass([
|
|
4231
|
+
(0, import_typeorm9.ManyToOne)(() => UserGroup, (g) => g.users, { onDelete: "SET NULL" }),
|
|
4232
|
+
(0, import_typeorm9.JoinColumn)({ name: "groupId" })
|
|
4233
|
+
], User.prototype, "group", 2);
|
|
4234
|
+
User = __decorateClass([
|
|
4235
|
+
(0, import_typeorm9.Entity)("users")
|
|
4236
|
+
], User);
|
|
4237
|
+
|
|
4238
|
+
// src/entities/otp-challenge.entity.ts
|
|
4239
|
+
var import_typeorm10 = require("typeorm");
|
|
4240
|
+
var OtpChallenge = class {
|
|
4241
|
+
id;
|
|
4242
|
+
purpose;
|
|
4243
|
+
channel;
|
|
4244
|
+
identifier;
|
|
4245
|
+
codeHash;
|
|
4246
|
+
expiresAt;
|
|
4247
|
+
attempts;
|
|
4248
|
+
consumedAt;
|
|
4249
|
+
createdAt;
|
|
4250
|
+
};
|
|
4251
|
+
__decorateClass([
|
|
4252
|
+
(0, import_typeorm10.PrimaryGeneratedColumn)()
|
|
4253
|
+
], OtpChallenge.prototype, "id", 2);
|
|
4254
|
+
__decorateClass([
|
|
4255
|
+
(0, import_typeorm10.Column)("varchar")
|
|
4256
|
+
], OtpChallenge.prototype, "purpose", 2);
|
|
4257
|
+
__decorateClass([
|
|
4258
|
+
(0, import_typeorm10.Column)("varchar")
|
|
4259
|
+
], OtpChallenge.prototype, "channel", 2);
|
|
4260
|
+
__decorateClass([
|
|
4261
|
+
(0, import_typeorm10.Column)("varchar")
|
|
4262
|
+
], OtpChallenge.prototype, "identifier", 2);
|
|
4263
|
+
__decorateClass([
|
|
4264
|
+
(0, import_typeorm10.Column)("varchar")
|
|
4265
|
+
], OtpChallenge.prototype, "codeHash", 2);
|
|
4266
|
+
__decorateClass([
|
|
4267
|
+
(0, import_typeorm10.Column)({ type: "timestamp" })
|
|
4268
|
+
], OtpChallenge.prototype, "expiresAt", 2);
|
|
4269
|
+
__decorateClass([
|
|
4270
|
+
(0, import_typeorm10.Column)("int", { default: 0 })
|
|
4271
|
+
], OtpChallenge.prototype, "attempts", 2);
|
|
4272
|
+
__decorateClass([
|
|
4273
|
+
(0, import_typeorm10.Column)({ type: "timestamp", nullable: true })
|
|
4274
|
+
], OtpChallenge.prototype, "consumedAt", 2);
|
|
4275
|
+
__decorateClass([
|
|
4276
|
+
(0, import_typeorm10.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4277
|
+
], OtpChallenge.prototype, "createdAt", 2);
|
|
4278
|
+
OtpChallenge = __decorateClass([
|
|
4279
|
+
(0, import_typeorm10.Entity)("otp_challenges"),
|
|
4280
|
+
(0, import_typeorm10.Index)(["purpose", "identifier"])
|
|
4281
|
+
], OtpChallenge);
|
|
4282
|
+
|
|
4283
|
+
// src/entities/password-reset-token.entity.ts
|
|
4284
|
+
var import_typeorm11 = require("typeorm");
|
|
4285
|
+
var PasswordResetToken = class {
|
|
4286
|
+
id;
|
|
4287
|
+
email;
|
|
4288
|
+
token;
|
|
4289
|
+
expiresAt;
|
|
4290
|
+
createdAt;
|
|
4291
|
+
};
|
|
4292
|
+
__decorateClass([
|
|
4293
|
+
(0, import_typeorm11.PrimaryGeneratedColumn)()
|
|
4294
|
+
], PasswordResetToken.prototype, "id", 2);
|
|
4295
|
+
__decorateClass([
|
|
4296
|
+
(0, import_typeorm11.Column)("varchar")
|
|
4297
|
+
], PasswordResetToken.prototype, "email", 2);
|
|
4298
|
+
__decorateClass([
|
|
4299
|
+
(0, import_typeorm11.Column)("varchar", { unique: true })
|
|
4300
|
+
], PasswordResetToken.prototype, "token", 2);
|
|
4301
|
+
__decorateClass([
|
|
4302
|
+
(0, import_typeorm11.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4303
|
+
], PasswordResetToken.prototype, "expiresAt", 2);
|
|
4304
|
+
__decorateClass([
|
|
4305
|
+
(0, import_typeorm11.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4306
|
+
], PasswordResetToken.prototype, "createdAt", 2);
|
|
4307
|
+
PasswordResetToken = __decorateClass([
|
|
4308
|
+
(0, import_typeorm11.Entity)("password_reset_tokens")
|
|
4309
|
+
], PasswordResetToken);
|
|
4310
|
+
|
|
4311
|
+
// src/entities/blog.entity.ts
|
|
4312
|
+
var import_typeorm16 = require("typeorm");
|
|
4313
|
+
|
|
4314
|
+
// src/entities/category.entity.ts
|
|
4315
|
+
var import_typeorm12 = require("typeorm");
|
|
4316
|
+
var Category = class {
|
|
4317
|
+
id;
|
|
4318
|
+
name;
|
|
4319
|
+
createdAt;
|
|
4320
|
+
updatedAt;
|
|
4321
|
+
deletedAt;
|
|
4322
|
+
deleted;
|
|
4323
|
+
createdBy;
|
|
4324
|
+
updatedBy;
|
|
4325
|
+
deletedBy;
|
|
4326
|
+
blogs;
|
|
4327
|
+
};
|
|
4328
|
+
__decorateClass([
|
|
4329
|
+
(0, import_typeorm12.PrimaryGeneratedColumn)()
|
|
4330
|
+
], Category.prototype, "id", 2);
|
|
4331
|
+
__decorateClass([
|
|
4332
|
+
(0, import_typeorm12.Column)("varchar", { unique: true })
|
|
4333
|
+
], Category.prototype, "name", 2);
|
|
4334
|
+
__decorateClass([
|
|
4335
|
+
(0, import_typeorm12.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4336
|
+
], Category.prototype, "createdAt", 2);
|
|
4337
|
+
__decorateClass([
|
|
4338
|
+
(0, import_typeorm12.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4339
|
+
], Category.prototype, "updatedAt", 2);
|
|
4340
|
+
__decorateClass([
|
|
4341
|
+
(0, import_typeorm12.Column)({ type: "timestamp", nullable: true })
|
|
4342
|
+
], Category.prototype, "deletedAt", 2);
|
|
4343
|
+
__decorateClass([
|
|
4344
|
+
(0, import_typeorm12.Column)("boolean", { default: false })
|
|
4345
|
+
], Category.prototype, "deleted", 2);
|
|
4346
|
+
__decorateClass([
|
|
4347
|
+
(0, import_typeorm12.Column)("int", { nullable: true })
|
|
4348
|
+
], Category.prototype, "createdBy", 2);
|
|
4349
|
+
__decorateClass([
|
|
4350
|
+
(0, import_typeorm12.Column)("int", { nullable: true })
|
|
4351
|
+
], Category.prototype, "updatedBy", 2);
|
|
4352
|
+
__decorateClass([
|
|
4353
|
+
(0, import_typeorm12.Column)("int", { nullable: true })
|
|
4354
|
+
], Category.prototype, "deletedBy", 2);
|
|
4355
|
+
__decorateClass([
|
|
4356
|
+
(0, import_typeorm12.OneToMany)("Blog", "category")
|
|
4357
|
+
], Category.prototype, "blogs", 2);
|
|
4358
|
+
Category = __decorateClass([
|
|
4359
|
+
(0, import_typeorm12.Entity)("categories")
|
|
4360
|
+
], Category);
|
|
4361
|
+
|
|
4362
|
+
// src/entities/seo.entity.ts
|
|
4363
|
+
var import_typeorm13 = require("typeorm");
|
|
4364
|
+
var Seo = class {
|
|
4365
|
+
id;
|
|
4366
|
+
title;
|
|
4367
|
+
description;
|
|
4368
|
+
keywords;
|
|
4369
|
+
ogTitle;
|
|
4370
|
+
ogDescription;
|
|
4371
|
+
ogImage;
|
|
4372
|
+
slug;
|
|
4373
|
+
createdAt;
|
|
4374
|
+
updatedAt;
|
|
4375
|
+
deletedAt;
|
|
4376
|
+
deleted;
|
|
4377
|
+
createdBy;
|
|
4378
|
+
updatedBy;
|
|
4379
|
+
deletedBy;
|
|
4380
|
+
blogs;
|
|
4381
|
+
};
|
|
4382
|
+
__decorateClass([
|
|
4383
|
+
(0, import_typeorm13.PrimaryGeneratedColumn)()
|
|
4384
|
+
], Seo.prototype, "id", 2);
|
|
4385
|
+
__decorateClass([
|
|
4386
|
+
(0, import_typeorm13.Column)("varchar", { nullable: true })
|
|
4387
|
+
], Seo.prototype, "title", 2);
|
|
4388
|
+
__decorateClass([
|
|
4389
|
+
(0, import_typeorm13.Column)("varchar", { nullable: true })
|
|
4390
|
+
], Seo.prototype, "description", 2);
|
|
4391
|
+
__decorateClass([
|
|
4392
|
+
(0, import_typeorm13.Column)("varchar", { nullable: true })
|
|
4393
|
+
], Seo.prototype, "keywords", 2);
|
|
4394
|
+
__decorateClass([
|
|
4395
|
+
(0, import_typeorm13.Column)("varchar", { nullable: true })
|
|
4396
|
+
], Seo.prototype, "ogTitle", 2);
|
|
4397
|
+
__decorateClass([
|
|
4398
|
+
(0, import_typeorm13.Column)("varchar", { nullable: true })
|
|
4399
|
+
], Seo.prototype, "ogDescription", 2);
|
|
4400
|
+
__decorateClass([
|
|
4401
|
+
(0, import_typeorm13.Column)("varchar", { nullable: true })
|
|
4402
|
+
], Seo.prototype, "ogImage", 2);
|
|
4403
|
+
__decorateClass([
|
|
4404
|
+
(0, import_typeorm13.Column)("varchar", { unique: true })
|
|
4405
|
+
], Seo.prototype, "slug", 2);
|
|
4406
|
+
__decorateClass([
|
|
4407
|
+
(0, import_typeorm13.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4408
|
+
], Seo.prototype, "createdAt", 2);
|
|
4409
|
+
__decorateClass([
|
|
4410
|
+
(0, import_typeorm13.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4411
|
+
], Seo.prototype, "updatedAt", 2);
|
|
4412
|
+
__decorateClass([
|
|
4413
|
+
(0, import_typeorm13.Column)({ type: "timestamp", nullable: true })
|
|
4414
|
+
], Seo.prototype, "deletedAt", 2);
|
|
4415
|
+
__decorateClass([
|
|
4416
|
+
(0, import_typeorm13.Column)("boolean", { default: false })
|
|
4417
|
+
], Seo.prototype, "deleted", 2);
|
|
4418
|
+
__decorateClass([
|
|
4419
|
+
(0, import_typeorm13.Column)("int", { nullable: true })
|
|
4420
|
+
], Seo.prototype, "createdBy", 2);
|
|
4421
|
+
__decorateClass([
|
|
4422
|
+
(0, import_typeorm13.Column)("int", { nullable: true })
|
|
4423
|
+
], Seo.prototype, "updatedBy", 2);
|
|
4424
|
+
__decorateClass([
|
|
4425
|
+
(0, import_typeorm13.Column)("int", { nullable: true })
|
|
4426
|
+
], Seo.prototype, "deletedBy", 2);
|
|
4427
|
+
__decorateClass([
|
|
4428
|
+
(0, import_typeorm13.OneToMany)(() => Blog, (blog) => blog.seo)
|
|
4429
|
+
], Seo.prototype, "blogs", 2);
|
|
4430
|
+
Seo = __decorateClass([
|
|
4431
|
+
(0, import_typeorm13.Entity)("seos")
|
|
4432
|
+
], Seo);
|
|
4433
|
+
|
|
4434
|
+
// src/entities/comment.entity.ts
|
|
4435
|
+
var import_typeorm14 = require("typeorm");
|
|
4436
|
+
var Comment = class {
|
|
4437
|
+
id;
|
|
4438
|
+
content;
|
|
4439
|
+
blogId;
|
|
4440
|
+
authorId;
|
|
4441
|
+
createdAt;
|
|
4442
|
+
updatedAt;
|
|
4443
|
+
deletedAt;
|
|
4444
|
+
deleted;
|
|
4445
|
+
createdBy;
|
|
4446
|
+
updatedBy;
|
|
4447
|
+
deletedBy;
|
|
4448
|
+
author;
|
|
4449
|
+
blog;
|
|
4450
|
+
};
|
|
4451
|
+
__decorateClass([
|
|
4452
|
+
(0, import_typeorm14.PrimaryGeneratedColumn)()
|
|
4453
|
+
], Comment.prototype, "id", 2);
|
|
4454
|
+
__decorateClass([
|
|
4455
|
+
(0, import_typeorm14.Column)("text")
|
|
4456
|
+
], Comment.prototype, "content", 2);
|
|
4457
|
+
__decorateClass([
|
|
4458
|
+
(0, import_typeorm14.Column)("int")
|
|
4459
|
+
], Comment.prototype, "blogId", 2);
|
|
4460
|
+
__decorateClass([
|
|
4461
|
+
(0, import_typeorm14.Column)("int")
|
|
4462
|
+
], Comment.prototype, "authorId", 2);
|
|
4463
|
+
__decorateClass([
|
|
4464
|
+
(0, import_typeorm14.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4465
|
+
], Comment.prototype, "createdAt", 2);
|
|
4466
|
+
__decorateClass([
|
|
4467
|
+
(0, import_typeorm14.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4468
|
+
], Comment.prototype, "updatedAt", 2);
|
|
4469
|
+
__decorateClass([
|
|
4470
|
+
(0, import_typeorm14.Column)({ type: "timestamp", nullable: true })
|
|
4471
|
+
], Comment.prototype, "deletedAt", 2);
|
|
4472
|
+
__decorateClass([
|
|
4473
|
+
(0, import_typeorm14.Column)("boolean", { default: false })
|
|
4474
|
+
], Comment.prototype, "deleted", 2);
|
|
4475
|
+
__decorateClass([
|
|
4476
|
+
(0, import_typeorm14.Column)("int", { nullable: true })
|
|
4477
|
+
], Comment.prototype, "createdBy", 2);
|
|
4478
|
+
__decorateClass([
|
|
4479
|
+
(0, import_typeorm14.Column)("int", { nullable: true })
|
|
4480
|
+
], Comment.prototype, "updatedBy", 2);
|
|
4481
|
+
__decorateClass([
|
|
4482
|
+
(0, import_typeorm14.Column)("int", { nullable: true })
|
|
4483
|
+
], Comment.prototype, "deletedBy", 2);
|
|
4484
|
+
__decorateClass([
|
|
4485
|
+
(0, import_typeorm14.ManyToOne)(() => User, { onDelete: "CASCADE" }),
|
|
4486
|
+
(0, import_typeorm14.JoinColumn)({ name: "authorId" })
|
|
4487
|
+
], Comment.prototype, "author", 2);
|
|
4488
|
+
__decorateClass([
|
|
4489
|
+
(0, import_typeorm14.ManyToOne)(() => Blog, (b) => b.comments, { onDelete: "CASCADE" }),
|
|
4490
|
+
(0, import_typeorm14.JoinColumn)({ name: "blogId" })
|
|
4491
|
+
], Comment.prototype, "blog", 2);
|
|
4492
|
+
Comment = __decorateClass([
|
|
4493
|
+
(0, import_typeorm14.Entity)("comments")
|
|
4494
|
+
], Comment);
|
|
4495
|
+
|
|
4496
|
+
// src/entities/tag.entity.ts
|
|
4497
|
+
var import_typeorm15 = require("typeorm");
|
|
4498
|
+
var Tag = class {
|
|
4499
|
+
id;
|
|
4500
|
+
name;
|
|
4501
|
+
createdAt;
|
|
4502
|
+
updatedAt;
|
|
4503
|
+
deletedAt;
|
|
4504
|
+
deleted;
|
|
4505
|
+
createdBy;
|
|
4506
|
+
updatedBy;
|
|
4507
|
+
deletedBy;
|
|
4508
|
+
blogs;
|
|
4509
|
+
};
|
|
4510
|
+
__decorateClass([
|
|
4511
|
+
(0, import_typeorm15.PrimaryGeneratedColumn)()
|
|
4512
|
+
], Tag.prototype, "id", 2);
|
|
4513
|
+
__decorateClass([
|
|
4514
|
+
(0, import_typeorm15.Column)("varchar", { unique: true })
|
|
4515
|
+
], Tag.prototype, "name", 2);
|
|
4516
|
+
__decorateClass([
|
|
4517
|
+
(0, import_typeorm15.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4518
|
+
], Tag.prototype, "createdAt", 2);
|
|
4519
|
+
__decorateClass([
|
|
4520
|
+
(0, import_typeorm15.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4521
|
+
], Tag.prototype, "updatedAt", 2);
|
|
4522
|
+
__decorateClass([
|
|
4523
|
+
(0, import_typeorm15.Column)({ type: "timestamp", nullable: true })
|
|
4524
|
+
], Tag.prototype, "deletedAt", 2);
|
|
4525
|
+
__decorateClass([
|
|
4526
|
+
(0, import_typeorm15.Column)("boolean", { default: false })
|
|
4527
|
+
], Tag.prototype, "deleted", 2);
|
|
4528
|
+
__decorateClass([
|
|
4529
|
+
(0, import_typeorm15.Column)("int", { nullable: true })
|
|
4530
|
+
], Tag.prototype, "createdBy", 2);
|
|
4531
|
+
__decorateClass([
|
|
4532
|
+
(0, import_typeorm15.Column)("int", { nullable: true })
|
|
4533
|
+
], Tag.prototype, "updatedBy", 2);
|
|
4534
|
+
__decorateClass([
|
|
4535
|
+
(0, import_typeorm15.Column)("int", { nullable: true })
|
|
4536
|
+
], Tag.prototype, "deletedBy", 2);
|
|
4537
|
+
__decorateClass([
|
|
4538
|
+
(0, import_typeorm15.ManyToMany)(() => Blog, (blog) => blog.tags)
|
|
4539
|
+
], Tag.prototype, "blogs", 2);
|
|
4540
|
+
Tag = __decorateClass([
|
|
4541
|
+
(0, import_typeorm15.Entity)("tags")
|
|
4542
|
+
], Tag);
|
|
4543
|
+
|
|
4544
|
+
// src/entities/blog.entity.ts
|
|
4545
|
+
var Blog = class {
|
|
4546
|
+
id;
|
|
4547
|
+
title;
|
|
4548
|
+
content;
|
|
4549
|
+
coverImage;
|
|
4550
|
+
authorId;
|
|
4551
|
+
categoryId;
|
|
4552
|
+
seoId;
|
|
4553
|
+
published;
|
|
4554
|
+
createdAt;
|
|
4555
|
+
updatedAt;
|
|
4556
|
+
deletedAt;
|
|
4557
|
+
deleted;
|
|
4558
|
+
createdBy;
|
|
4559
|
+
updatedBy;
|
|
4560
|
+
deletedBy;
|
|
4561
|
+
slug;
|
|
4562
|
+
author;
|
|
4563
|
+
category;
|
|
4564
|
+
seo;
|
|
4565
|
+
comments;
|
|
4566
|
+
tags;
|
|
4567
|
+
};
|
|
4568
|
+
__decorateClass([
|
|
4569
|
+
(0, import_typeorm16.PrimaryGeneratedColumn)()
|
|
4570
|
+
], Blog.prototype, "id", 2);
|
|
4571
|
+
__decorateClass([
|
|
4572
|
+
(0, import_typeorm16.Column)("varchar")
|
|
4573
|
+
], Blog.prototype, "title", 2);
|
|
4574
|
+
__decorateClass([
|
|
4575
|
+
(0, import_typeorm16.Column)("text")
|
|
4576
|
+
], Blog.prototype, "content", 2);
|
|
4577
|
+
__decorateClass([
|
|
4578
|
+
(0, import_typeorm16.Column)("varchar", { nullable: true })
|
|
4579
|
+
], Blog.prototype, "coverImage", 2);
|
|
4580
|
+
__decorateClass([
|
|
4581
|
+
(0, import_typeorm16.Column)("int")
|
|
4582
|
+
], Blog.prototype, "authorId", 2);
|
|
4583
|
+
__decorateClass([
|
|
4584
|
+
(0, import_typeorm16.Column)("int", { nullable: true })
|
|
4585
|
+
], Blog.prototype, "categoryId", 2);
|
|
4586
|
+
__decorateClass([
|
|
4587
|
+
(0, import_typeorm16.Column)("int", { nullable: true })
|
|
4588
|
+
], Blog.prototype, "seoId", 2);
|
|
4589
|
+
__decorateClass([
|
|
4590
|
+
(0, import_typeorm16.Column)("boolean", { default: false })
|
|
4591
|
+
], Blog.prototype, "published", 2);
|
|
4592
|
+
__decorateClass([
|
|
4593
|
+
(0, import_typeorm16.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4594
|
+
], Blog.prototype, "createdAt", 2);
|
|
4595
|
+
__decorateClass([
|
|
4596
|
+
(0, import_typeorm16.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4597
|
+
], Blog.prototype, "updatedAt", 2);
|
|
4598
|
+
__decorateClass([
|
|
4599
|
+
(0, import_typeorm16.Column)({ type: "timestamp", nullable: true })
|
|
4600
|
+
], Blog.prototype, "deletedAt", 2);
|
|
4601
|
+
__decorateClass([
|
|
4602
|
+
(0, import_typeorm16.Column)("boolean", { default: false })
|
|
4603
|
+
], Blog.prototype, "deleted", 2);
|
|
4604
|
+
__decorateClass([
|
|
4605
|
+
(0, import_typeorm16.Column)("int", { nullable: true })
|
|
4606
|
+
], Blog.prototype, "createdBy", 2);
|
|
4607
|
+
__decorateClass([
|
|
4608
|
+
(0, import_typeorm16.Column)("int", { nullable: true })
|
|
4609
|
+
], Blog.prototype, "updatedBy", 2);
|
|
4610
|
+
__decorateClass([
|
|
4611
|
+
(0, import_typeorm16.Column)("int", { nullable: true })
|
|
4612
|
+
], Blog.prototype, "deletedBy", 2);
|
|
4613
|
+
__decorateClass([
|
|
4614
|
+
(0, import_typeorm16.Column)("varchar", { unique: true })
|
|
4615
|
+
], Blog.prototype, "slug", 2);
|
|
4616
|
+
__decorateClass([
|
|
4617
|
+
(0, import_typeorm16.ManyToOne)(() => User, { onDelete: "CASCADE" }),
|
|
4618
|
+
(0, import_typeorm16.JoinColumn)({ name: "authorId" })
|
|
4619
|
+
], Blog.prototype, "author", 2);
|
|
4620
|
+
__decorateClass([
|
|
4621
|
+
(0, import_typeorm16.ManyToOne)(() => Category, (c) => c.blogs, { onDelete: "SET NULL" }),
|
|
4622
|
+
(0, import_typeorm16.JoinColumn)({ name: "categoryId" })
|
|
4623
|
+
], Blog.prototype, "category", 2);
|
|
4624
|
+
__decorateClass([
|
|
4625
|
+
(0, import_typeorm16.ManyToOne)(() => Seo, (s) => s.blogs, { onDelete: "SET NULL" }),
|
|
4626
|
+
(0, import_typeorm16.JoinColumn)({ name: "seoId" })
|
|
4627
|
+
], Blog.prototype, "seo", 2);
|
|
4628
|
+
__decorateClass([
|
|
4629
|
+
(0, import_typeorm16.OneToMany)(() => Comment, (c) => c.blog)
|
|
4630
|
+
], Blog.prototype, "comments", 2);
|
|
4631
|
+
__decorateClass([
|
|
4632
|
+
(0, import_typeorm16.ManyToMany)(() => Tag, (t) => t.blogs),
|
|
4633
|
+
(0, import_typeorm16.JoinTable)({
|
|
4634
|
+
name: "blog_tags",
|
|
4635
|
+
joinColumn: { name: "blogId", referencedColumnName: "id" },
|
|
4636
|
+
inverseJoinColumn: { name: "tagId", referencedColumnName: "id" }
|
|
4637
|
+
})
|
|
4638
|
+
], Blog.prototype, "tags", 2);
|
|
4639
|
+
Blog = __decorateClass([
|
|
4640
|
+
(0, import_typeorm16.Entity)("blogs")
|
|
4641
|
+
], Blog);
|
|
4642
|
+
|
|
4643
|
+
// src/entities/contact.entity.ts
|
|
4644
|
+
var import_typeorm25 = require("typeorm");
|
|
4645
|
+
|
|
4646
|
+
// src/entities/form-submission.entity.ts
|
|
4647
|
+
var import_typeorm19 = require("typeorm");
|
|
4648
|
+
|
|
4649
|
+
// src/entities/form.entity.ts
|
|
4650
|
+
var import_typeorm18 = require("typeorm");
|
|
4651
|
+
|
|
4652
|
+
// src/entities/form-field.entity.ts
|
|
4653
|
+
var import_typeorm17 = require("typeorm");
|
|
4654
|
+
var FormField = class {
|
|
4655
|
+
id;
|
|
4656
|
+
formId;
|
|
4657
|
+
label;
|
|
4658
|
+
type;
|
|
4659
|
+
placeholder;
|
|
4660
|
+
options;
|
|
4661
|
+
required;
|
|
4662
|
+
validation;
|
|
4663
|
+
order;
|
|
4664
|
+
groupId;
|
|
4665
|
+
columnWidth;
|
|
4666
|
+
createdAt;
|
|
4667
|
+
updatedAt;
|
|
4668
|
+
deletedAt;
|
|
4669
|
+
deleted;
|
|
4670
|
+
createdBy;
|
|
4671
|
+
updatedBy;
|
|
4672
|
+
deletedBy;
|
|
4673
|
+
form;
|
|
4674
|
+
};
|
|
4675
|
+
__decorateClass([
|
|
4676
|
+
(0, import_typeorm17.PrimaryGeneratedColumn)()
|
|
4677
|
+
], FormField.prototype, "id", 2);
|
|
4678
|
+
__decorateClass([
|
|
4679
|
+
(0, import_typeorm17.Column)("int")
|
|
4680
|
+
], FormField.prototype, "formId", 2);
|
|
4681
|
+
__decorateClass([
|
|
4682
|
+
(0, import_typeorm17.Column)("varchar")
|
|
4683
|
+
], FormField.prototype, "label", 2);
|
|
4684
|
+
__decorateClass([
|
|
4685
|
+
(0, import_typeorm17.Column)("varchar")
|
|
4686
|
+
], FormField.prototype, "type", 2);
|
|
4687
|
+
__decorateClass([
|
|
4688
|
+
(0, import_typeorm17.Column)("varchar", { nullable: true })
|
|
4689
|
+
], FormField.prototype, "placeholder", 2);
|
|
4690
|
+
__decorateClass([
|
|
4691
|
+
(0, import_typeorm17.Column)("varchar", { nullable: true })
|
|
4692
|
+
], FormField.prototype, "options", 2);
|
|
4693
|
+
__decorateClass([
|
|
4694
|
+
(0, import_typeorm17.Column)("boolean", { default: false })
|
|
4695
|
+
], FormField.prototype, "required", 2);
|
|
4696
|
+
__decorateClass([
|
|
4697
|
+
(0, import_typeorm17.Column)("varchar", { nullable: true })
|
|
4698
|
+
], FormField.prototype, "validation", 2);
|
|
4699
|
+
__decorateClass([
|
|
4700
|
+
(0, import_typeorm17.Column)("int")
|
|
4701
|
+
], FormField.prototype, "order", 2);
|
|
4702
|
+
__decorateClass([
|
|
4703
|
+
(0, import_typeorm17.Column)("int", { default: 1 })
|
|
4704
|
+
], FormField.prototype, "groupId", 2);
|
|
4705
|
+
__decorateClass([
|
|
4706
|
+
(0, import_typeorm17.Column)("int", { default: 12 })
|
|
4707
|
+
], FormField.prototype, "columnWidth", 2);
|
|
4708
|
+
__decorateClass([
|
|
4709
|
+
(0, import_typeorm17.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4710
|
+
], FormField.prototype, "createdAt", 2);
|
|
4711
|
+
__decorateClass([
|
|
4712
|
+
(0, import_typeorm17.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4713
|
+
], FormField.prototype, "updatedAt", 2);
|
|
4714
|
+
__decorateClass([
|
|
4715
|
+
(0, import_typeorm17.Column)({ type: "timestamp", nullable: true })
|
|
4716
|
+
], FormField.prototype, "deletedAt", 2);
|
|
4717
|
+
__decorateClass([
|
|
4718
|
+
(0, import_typeorm17.Column)("boolean", { default: false })
|
|
4719
|
+
], FormField.prototype, "deleted", 2);
|
|
4720
|
+
__decorateClass([
|
|
4721
|
+
(0, import_typeorm17.Column)("int", { nullable: true })
|
|
4722
|
+
], FormField.prototype, "createdBy", 2);
|
|
4723
|
+
__decorateClass([
|
|
4724
|
+
(0, import_typeorm17.Column)("int", { nullable: true })
|
|
4725
|
+
], FormField.prototype, "updatedBy", 2);
|
|
4726
|
+
__decorateClass([
|
|
4727
|
+
(0, import_typeorm17.Column)("int", { nullable: true })
|
|
4728
|
+
], FormField.prototype, "deletedBy", 2);
|
|
4729
|
+
__decorateClass([
|
|
4730
|
+
(0, import_typeorm17.ManyToOne)(() => Form, (f) => f.fields, { onDelete: "CASCADE" }),
|
|
4731
|
+
(0, import_typeorm17.JoinColumn)({ name: "formId" })
|
|
4732
|
+
], FormField.prototype, "form", 2);
|
|
4733
|
+
FormField = __decorateClass([
|
|
4734
|
+
(0, import_typeorm17.Entity)("form_fields")
|
|
4735
|
+
], FormField);
|
|
4736
|
+
|
|
4737
|
+
// src/entities/form.entity.ts
|
|
4738
|
+
var Form = class {
|
|
4739
|
+
id;
|
|
4740
|
+
name;
|
|
4741
|
+
description;
|
|
4742
|
+
campaign;
|
|
4743
|
+
slug;
|
|
4744
|
+
published;
|
|
4745
|
+
createdAt;
|
|
4746
|
+
updatedAt;
|
|
4747
|
+
deletedAt;
|
|
4748
|
+
deleted;
|
|
4749
|
+
createdBy;
|
|
4750
|
+
updatedBy;
|
|
4751
|
+
deletedBy;
|
|
4752
|
+
fields;
|
|
4753
|
+
submissions;
|
|
4754
|
+
};
|
|
4755
|
+
__decorateClass([
|
|
4756
|
+
(0, import_typeorm18.PrimaryGeneratedColumn)()
|
|
4757
|
+
], Form.prototype, "id", 2);
|
|
4758
|
+
__decorateClass([
|
|
4759
|
+
(0, import_typeorm18.Column)("varchar")
|
|
4760
|
+
], Form.prototype, "name", 2);
|
|
4761
|
+
__decorateClass([
|
|
4762
|
+
(0, import_typeorm18.Column)("text", { nullable: true })
|
|
4763
|
+
], Form.prototype, "description", 2);
|
|
4764
|
+
__decorateClass([
|
|
4765
|
+
(0, import_typeorm18.Column)("varchar", { nullable: true })
|
|
4766
|
+
], Form.prototype, "campaign", 2);
|
|
4767
|
+
__decorateClass([
|
|
4768
|
+
(0, import_typeorm18.Column)("varchar", { unique: true })
|
|
4769
|
+
], Form.prototype, "slug", 2);
|
|
4770
|
+
__decorateClass([
|
|
4771
|
+
(0, import_typeorm18.Column)("boolean", { default: false })
|
|
4772
|
+
], Form.prototype, "published", 2);
|
|
4773
|
+
__decorateClass([
|
|
4774
|
+
(0, import_typeorm18.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4775
|
+
], Form.prototype, "createdAt", 2);
|
|
4776
|
+
__decorateClass([
|
|
4777
|
+
(0, import_typeorm18.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4778
|
+
], Form.prototype, "updatedAt", 2);
|
|
4779
|
+
__decorateClass([
|
|
4780
|
+
(0, import_typeorm18.Column)({ type: "timestamp", nullable: true })
|
|
4781
|
+
], Form.prototype, "deletedAt", 2);
|
|
4782
|
+
__decorateClass([
|
|
4783
|
+
(0, import_typeorm18.Column)("boolean", { default: false })
|
|
4784
|
+
], Form.prototype, "deleted", 2);
|
|
4785
|
+
__decorateClass([
|
|
4786
|
+
(0, import_typeorm18.Column)("int", { nullable: true })
|
|
4787
|
+
], Form.prototype, "createdBy", 2);
|
|
4788
|
+
__decorateClass([
|
|
4789
|
+
(0, import_typeorm18.Column)("int", { nullable: true })
|
|
4790
|
+
], Form.prototype, "updatedBy", 2);
|
|
4791
|
+
__decorateClass([
|
|
4792
|
+
(0, import_typeorm18.Column)("int", { nullable: true })
|
|
4793
|
+
], Form.prototype, "deletedBy", 2);
|
|
4794
|
+
__decorateClass([
|
|
4795
|
+
(0, import_typeorm18.OneToMany)(() => FormField, (f) => f.form)
|
|
4796
|
+
], Form.prototype, "fields", 2);
|
|
4797
|
+
__decorateClass([
|
|
4798
|
+
(0, import_typeorm18.OneToMany)(() => FormSubmission, (s) => s.form)
|
|
4799
|
+
], Form.prototype, "submissions", 2);
|
|
4800
|
+
Form = __decorateClass([
|
|
4801
|
+
(0, import_typeorm18.Entity)("forms")
|
|
4802
|
+
], Form);
|
|
4803
|
+
|
|
4804
|
+
// src/entities/form-submission.entity.ts
|
|
4805
|
+
var FormSubmission = class {
|
|
4806
|
+
id;
|
|
4807
|
+
formId;
|
|
4808
|
+
contactId;
|
|
4809
|
+
data;
|
|
4810
|
+
ipAddress;
|
|
4811
|
+
userAgent;
|
|
4812
|
+
createdAt;
|
|
4813
|
+
updatedAt;
|
|
4814
|
+
form;
|
|
4815
|
+
contact;
|
|
4816
|
+
};
|
|
4817
|
+
__decorateClass([
|
|
4818
|
+
(0, import_typeorm19.PrimaryGeneratedColumn)()
|
|
4819
|
+
], FormSubmission.prototype, "id", 2);
|
|
4820
|
+
__decorateClass([
|
|
4821
|
+
(0, import_typeorm19.Column)("int")
|
|
4822
|
+
], FormSubmission.prototype, "formId", 2);
|
|
4823
|
+
__decorateClass([
|
|
4824
|
+
(0, import_typeorm19.Column)("int", { nullable: true })
|
|
4825
|
+
], FormSubmission.prototype, "contactId", 2);
|
|
4826
|
+
__decorateClass([
|
|
4827
|
+
(0, import_typeorm19.Column)("jsonb")
|
|
4828
|
+
], FormSubmission.prototype, "data", 2);
|
|
4829
|
+
__decorateClass([
|
|
4830
|
+
(0, import_typeorm19.Column)("varchar", { nullable: true })
|
|
4831
|
+
], FormSubmission.prototype, "ipAddress", 2);
|
|
4832
|
+
__decorateClass([
|
|
4833
|
+
(0, import_typeorm19.Column)("varchar", { nullable: true })
|
|
4834
|
+
], FormSubmission.prototype, "userAgent", 2);
|
|
4835
|
+
__decorateClass([
|
|
4836
|
+
(0, import_typeorm19.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4837
|
+
], FormSubmission.prototype, "createdAt", 2);
|
|
4838
|
+
__decorateClass([
|
|
4839
|
+
(0, import_typeorm19.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4840
|
+
], FormSubmission.prototype, "updatedAt", 2);
|
|
4841
|
+
__decorateClass([
|
|
4842
|
+
(0, import_typeorm19.ManyToOne)(() => Form, (f) => f.submissions, { onDelete: "CASCADE" }),
|
|
4843
|
+
(0, import_typeorm19.JoinColumn)({ name: "formId" })
|
|
4844
|
+
], FormSubmission.prototype, "form", 2);
|
|
4845
|
+
__decorateClass([
|
|
4846
|
+
(0, import_typeorm19.ManyToOne)(() => Contact, (c) => c.form_submissions, { onDelete: "SET NULL" }),
|
|
4847
|
+
(0, import_typeorm19.JoinColumn)({ name: "contactId" })
|
|
4848
|
+
], FormSubmission.prototype, "contact", 2);
|
|
4849
|
+
FormSubmission = __decorateClass([
|
|
4850
|
+
(0, import_typeorm19.Entity)("form_submissions")
|
|
4851
|
+
], FormSubmission);
|
|
4852
|
+
|
|
4853
|
+
// src/entities/address.entity.ts
|
|
4854
|
+
var import_typeorm20 = require("typeorm");
|
|
4855
|
+
var Address = class {
|
|
4856
|
+
id;
|
|
4857
|
+
contactId;
|
|
4858
|
+
tag;
|
|
4859
|
+
line1;
|
|
4860
|
+
line2;
|
|
4861
|
+
city;
|
|
4862
|
+
state;
|
|
4863
|
+
postalCode;
|
|
4864
|
+
country;
|
|
4865
|
+
createdAt;
|
|
4866
|
+
updatedAt;
|
|
4867
|
+
contact;
|
|
4868
|
+
};
|
|
4869
|
+
__decorateClass([
|
|
4870
|
+
(0, import_typeorm20.PrimaryGeneratedColumn)()
|
|
4871
|
+
], Address.prototype, "id", 2);
|
|
4872
|
+
__decorateClass([
|
|
4873
|
+
(0, import_typeorm20.Column)("int")
|
|
4874
|
+
], Address.prototype, "contactId", 2);
|
|
4875
|
+
__decorateClass([
|
|
4876
|
+
(0, import_typeorm20.Column)("varchar", { nullable: true })
|
|
4877
|
+
], Address.prototype, "tag", 2);
|
|
4878
|
+
__decorateClass([
|
|
4879
|
+
(0, import_typeorm20.Column)("varchar", { nullable: true })
|
|
4880
|
+
], Address.prototype, "line1", 2);
|
|
4881
|
+
__decorateClass([
|
|
4882
|
+
(0, import_typeorm20.Column)("varchar", { nullable: true })
|
|
4883
|
+
], Address.prototype, "line2", 2);
|
|
4884
|
+
__decorateClass([
|
|
4885
|
+
(0, import_typeorm20.Column)("varchar", { nullable: true })
|
|
4886
|
+
], Address.prototype, "city", 2);
|
|
4887
|
+
__decorateClass([
|
|
4888
|
+
(0, import_typeorm20.Column)("varchar", { nullable: true })
|
|
4889
|
+
], Address.prototype, "state", 2);
|
|
4890
|
+
__decorateClass([
|
|
4891
|
+
(0, import_typeorm20.Column)("varchar", { nullable: true })
|
|
4892
|
+
], Address.prototype, "postalCode", 2);
|
|
4893
|
+
__decorateClass([
|
|
4894
|
+
(0, import_typeorm20.Column)("varchar", { nullable: true })
|
|
4895
|
+
], Address.prototype, "country", 2);
|
|
4896
|
+
__decorateClass([
|
|
4897
|
+
(0, import_typeorm20.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4898
|
+
], Address.prototype, "createdAt", 2);
|
|
4899
|
+
__decorateClass([
|
|
4900
|
+
(0, import_typeorm20.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4901
|
+
], Address.prototype, "updatedAt", 2);
|
|
4902
|
+
__decorateClass([
|
|
4903
|
+
(0, import_typeorm20.ManyToOne)(() => Contact, (c) => c.addresses, { onDelete: "CASCADE" }),
|
|
4904
|
+
(0, import_typeorm20.JoinColumn)({ name: "contactId" })
|
|
4905
|
+
], Address.prototype, "contact", 2);
|
|
4906
|
+
Address = __decorateClass([
|
|
4907
|
+
(0, import_typeorm20.Entity)("addresses")
|
|
4908
|
+
], Address);
|
|
4909
|
+
|
|
4910
|
+
// src/entities/order.entity.ts
|
|
4911
|
+
var import_typeorm21 = require("typeorm");
|
|
4912
|
+
var Order = class {
|
|
4913
|
+
id;
|
|
4914
|
+
orderNumber;
|
|
4915
|
+
orderKind;
|
|
4916
|
+
parentOrderId;
|
|
4917
|
+
contactId;
|
|
4918
|
+
billingAddressId;
|
|
4919
|
+
shippingAddressId;
|
|
4920
|
+
status;
|
|
4921
|
+
subtotal;
|
|
4922
|
+
tax;
|
|
4923
|
+
discount;
|
|
4924
|
+
total;
|
|
4925
|
+
currency;
|
|
4926
|
+
metadata;
|
|
4927
|
+
createdAt;
|
|
4928
|
+
updatedAt;
|
|
4929
|
+
deletedAt;
|
|
4930
|
+
deleted;
|
|
4931
|
+
createdBy;
|
|
4932
|
+
updatedBy;
|
|
4933
|
+
deletedBy;
|
|
4934
|
+
parentOrder;
|
|
4935
|
+
children;
|
|
4936
|
+
contact;
|
|
4937
|
+
billingAddress;
|
|
4938
|
+
shippingAddress;
|
|
4939
|
+
items;
|
|
4940
|
+
payments;
|
|
4941
|
+
};
|
|
4942
|
+
__decorateClass([
|
|
4943
|
+
(0, import_typeorm21.PrimaryGeneratedColumn)()
|
|
4944
|
+
], Order.prototype, "id", 2);
|
|
4945
|
+
__decorateClass([
|
|
4946
|
+
(0, import_typeorm21.Column)("varchar", { unique: true })
|
|
4947
|
+
], Order.prototype, "orderNumber", 2);
|
|
4948
|
+
__decorateClass([
|
|
4949
|
+
(0, import_typeorm21.Column)("varchar", { default: "sale" })
|
|
4950
|
+
], Order.prototype, "orderKind", 2);
|
|
4951
|
+
__decorateClass([
|
|
4952
|
+
(0, import_typeorm21.Column)("int", { nullable: true })
|
|
4953
|
+
], Order.prototype, "parentOrderId", 2);
|
|
4954
|
+
__decorateClass([
|
|
4955
|
+
(0, import_typeorm21.Column)("int")
|
|
4956
|
+
], Order.prototype, "contactId", 2);
|
|
4957
|
+
__decorateClass([
|
|
4958
|
+
(0, import_typeorm21.Column)("int", { nullable: true })
|
|
4959
|
+
], Order.prototype, "billingAddressId", 2);
|
|
4960
|
+
__decorateClass([
|
|
4961
|
+
(0, import_typeorm21.Column)("int", { nullable: true })
|
|
4962
|
+
], Order.prototype, "shippingAddressId", 2);
|
|
4963
|
+
__decorateClass([
|
|
4964
|
+
(0, import_typeorm21.Column)("varchar", { default: "pending" })
|
|
4965
|
+
], Order.prototype, "status", 2);
|
|
4966
|
+
__decorateClass([
|
|
4967
|
+
(0, import_typeorm21.Column)("decimal", { precision: 12, scale: 2, default: 0 })
|
|
4968
|
+
], Order.prototype, "subtotal", 2);
|
|
4969
|
+
__decorateClass([
|
|
4970
|
+
(0, import_typeorm21.Column)("decimal", { precision: 12, scale: 2, default: 0 })
|
|
4971
|
+
], Order.prototype, "tax", 2);
|
|
4972
|
+
__decorateClass([
|
|
4973
|
+
(0, import_typeorm21.Column)("decimal", { precision: 12, scale: 2, default: 0 })
|
|
4974
|
+
], Order.prototype, "discount", 2);
|
|
4975
|
+
__decorateClass([
|
|
4976
|
+
(0, import_typeorm21.Column)("decimal", { precision: 12, scale: 2, default: 0 })
|
|
4977
|
+
], Order.prototype, "total", 2);
|
|
4978
|
+
__decorateClass([
|
|
4979
|
+
(0, import_typeorm21.Column)("varchar", { default: "INR" })
|
|
4980
|
+
], Order.prototype, "currency", 2);
|
|
4981
|
+
__decorateClass([
|
|
4982
|
+
(0, import_typeorm21.Column)("jsonb", { nullable: true })
|
|
4983
|
+
], Order.prototype, "metadata", 2);
|
|
4984
|
+
__decorateClass([
|
|
4985
|
+
(0, import_typeorm21.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4986
|
+
], Order.prototype, "createdAt", 2);
|
|
4987
|
+
__decorateClass([
|
|
4988
|
+
(0, import_typeorm21.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
4989
|
+
], Order.prototype, "updatedAt", 2);
|
|
4990
|
+
__decorateClass([
|
|
4991
|
+
(0, import_typeorm21.Column)({ type: "timestamp", nullable: true })
|
|
4992
|
+
], Order.prototype, "deletedAt", 2);
|
|
4993
|
+
__decorateClass([
|
|
4994
|
+
(0, import_typeorm21.Column)("boolean", { default: false })
|
|
4995
|
+
], Order.prototype, "deleted", 2);
|
|
4996
|
+
__decorateClass([
|
|
4997
|
+
(0, import_typeorm21.Column)("int", { nullable: true })
|
|
4998
|
+
], Order.prototype, "createdBy", 2);
|
|
4999
|
+
__decorateClass([
|
|
5000
|
+
(0, import_typeorm21.Column)("int", { nullable: true })
|
|
5001
|
+
], Order.prototype, "updatedBy", 2);
|
|
5002
|
+
__decorateClass([
|
|
5003
|
+
(0, import_typeorm21.Column)("int", { nullable: true })
|
|
5004
|
+
], Order.prototype, "deletedBy", 2);
|
|
5005
|
+
__decorateClass([
|
|
5006
|
+
(0, import_typeorm21.ManyToOne)(() => Order, (o) => o.children, { nullable: true, onDelete: "SET NULL" }),
|
|
5007
|
+
(0, import_typeorm21.JoinColumn)({ name: "parentOrderId" })
|
|
5008
|
+
], Order.prototype, "parentOrder", 2);
|
|
5009
|
+
__decorateClass([
|
|
5010
|
+
(0, import_typeorm21.OneToMany)(() => Order, (o) => o.parentOrder)
|
|
5011
|
+
], Order.prototype, "children", 2);
|
|
5012
|
+
__decorateClass([
|
|
5013
|
+
(0, import_typeorm21.ManyToOne)(() => Contact, { onDelete: "CASCADE" }),
|
|
5014
|
+
(0, import_typeorm21.JoinColumn)({ name: "contactId" })
|
|
5015
|
+
], Order.prototype, "contact", 2);
|
|
5016
|
+
__decorateClass([
|
|
5017
|
+
(0, import_typeorm21.ManyToOne)(() => Address, { onDelete: "SET NULL" }),
|
|
5018
|
+
(0, import_typeorm21.JoinColumn)({ name: "billingAddressId" })
|
|
5019
|
+
], Order.prototype, "billingAddress", 2);
|
|
5020
|
+
__decorateClass([
|
|
5021
|
+
(0, import_typeorm21.ManyToOne)(() => Address, { onDelete: "SET NULL" }),
|
|
5022
|
+
(0, import_typeorm21.JoinColumn)({ name: "shippingAddressId" })
|
|
5023
|
+
], Order.prototype, "shippingAddress", 2);
|
|
5024
|
+
__decorateClass([
|
|
5025
|
+
(0, import_typeorm21.OneToMany)("OrderItem", "order")
|
|
5026
|
+
], Order.prototype, "items", 2);
|
|
5027
|
+
__decorateClass([
|
|
5028
|
+
(0, import_typeorm21.OneToMany)("Payment", "order")
|
|
5029
|
+
], Order.prototype, "payments", 2);
|
|
5030
|
+
Order = __decorateClass([
|
|
5031
|
+
(0, import_typeorm21.Entity)("orders")
|
|
5032
|
+
], Order);
|
|
5033
|
+
|
|
5034
|
+
// src/entities/payment.entity.ts
|
|
5035
|
+
var import_typeorm22 = require("typeorm");
|
|
5036
|
+
var Payment = class {
|
|
5037
|
+
id;
|
|
5038
|
+
orderId;
|
|
5039
|
+
contactId;
|
|
5040
|
+
amount;
|
|
5041
|
+
currency;
|
|
5042
|
+
status;
|
|
5043
|
+
method;
|
|
5044
|
+
externalReference;
|
|
5045
|
+
metadata;
|
|
5046
|
+
paidAt;
|
|
5047
|
+
createdAt;
|
|
5048
|
+
updatedAt;
|
|
5049
|
+
deletedAt;
|
|
5050
|
+
deleted;
|
|
5051
|
+
createdBy;
|
|
5052
|
+
updatedBy;
|
|
5053
|
+
deletedBy;
|
|
5054
|
+
order;
|
|
5055
|
+
contact;
|
|
5056
|
+
};
|
|
5057
|
+
__decorateClass([
|
|
5058
|
+
(0, import_typeorm22.PrimaryGeneratedColumn)()
|
|
5059
|
+
], Payment.prototype, "id", 2);
|
|
5060
|
+
__decorateClass([
|
|
5061
|
+
(0, import_typeorm22.Column)("int")
|
|
5062
|
+
], Payment.prototype, "orderId", 2);
|
|
5063
|
+
__decorateClass([
|
|
5064
|
+
(0, import_typeorm22.Column)("int", { nullable: true })
|
|
5065
|
+
], Payment.prototype, "contactId", 2);
|
|
5066
|
+
__decorateClass([
|
|
5067
|
+
(0, import_typeorm22.Column)("decimal", { precision: 12, scale: 2 })
|
|
5068
|
+
], Payment.prototype, "amount", 2);
|
|
5069
|
+
__decorateClass([
|
|
5070
|
+
(0, import_typeorm22.Column)("varchar", { default: "INR" })
|
|
5071
|
+
], Payment.prototype, "currency", 2);
|
|
5072
|
+
__decorateClass([
|
|
5073
|
+
(0, import_typeorm22.Column)("varchar", { default: "pending" })
|
|
5074
|
+
], Payment.prototype, "status", 2);
|
|
5075
|
+
__decorateClass([
|
|
5076
|
+
(0, import_typeorm22.Column)("varchar", { nullable: true })
|
|
5077
|
+
], Payment.prototype, "method", 2);
|
|
5078
|
+
__decorateClass([
|
|
5079
|
+
(0, import_typeorm22.Column)("varchar", { nullable: true })
|
|
5080
|
+
], Payment.prototype, "externalReference", 2);
|
|
5081
|
+
__decorateClass([
|
|
5082
|
+
(0, import_typeorm22.Column)("jsonb", { nullable: true })
|
|
5083
|
+
], Payment.prototype, "metadata", 2);
|
|
5084
|
+
__decorateClass([
|
|
5085
|
+
(0, import_typeorm22.Column)({ type: "timestamp", nullable: true })
|
|
5086
|
+
], Payment.prototype, "paidAt", 2);
|
|
5087
|
+
__decorateClass([
|
|
5088
|
+
(0, import_typeorm22.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
5089
|
+
], Payment.prototype, "createdAt", 2);
|
|
5090
|
+
__decorateClass([
|
|
5091
|
+
(0, import_typeorm22.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
5092
|
+
], Payment.prototype, "updatedAt", 2);
|
|
5093
|
+
__decorateClass([
|
|
5094
|
+
(0, import_typeorm22.Column)({ type: "timestamp", nullable: true })
|
|
5095
|
+
], Payment.prototype, "deletedAt", 2);
|
|
5096
|
+
__decorateClass([
|
|
5097
|
+
(0, import_typeorm22.Column)("boolean", { default: false })
|
|
5098
|
+
], Payment.prototype, "deleted", 2);
|
|
5099
|
+
__decorateClass([
|
|
5100
|
+
(0, import_typeorm22.Column)("int", { nullable: true })
|
|
5101
|
+
], Payment.prototype, "createdBy", 2);
|
|
5102
|
+
__decorateClass([
|
|
5103
|
+
(0, import_typeorm22.Column)("int", { nullable: true })
|
|
5104
|
+
], Payment.prototype, "updatedBy", 2);
|
|
5105
|
+
__decorateClass([
|
|
5106
|
+
(0, import_typeorm22.Column)("int", { nullable: true })
|
|
5107
|
+
], Payment.prototype, "deletedBy", 2);
|
|
5108
|
+
__decorateClass([
|
|
5109
|
+
(0, import_typeorm22.ManyToOne)(() => Order, (o) => o.payments, { onDelete: "CASCADE" }),
|
|
5110
|
+
(0, import_typeorm22.JoinColumn)({ name: "orderId" })
|
|
5111
|
+
], Payment.prototype, "order", 2);
|
|
5112
|
+
__decorateClass([
|
|
5113
|
+
(0, import_typeorm22.ManyToOne)(() => Contact, { onDelete: "SET NULL" }),
|
|
5114
|
+
(0, import_typeorm22.JoinColumn)({ name: "contactId" })
|
|
5115
|
+
], Payment.prototype, "contact", 2);
|
|
5116
|
+
Payment = __decorateClass([
|
|
5117
|
+
(0, import_typeorm22.Entity)("payments")
|
|
5118
|
+
], Payment);
|
|
5119
|
+
|
|
5120
|
+
// src/entities/chat-conversation.entity.ts
|
|
5121
|
+
var import_typeorm24 = require("typeorm");
|
|
5122
|
+
|
|
5123
|
+
// src/entities/chat-message.entity.ts
|
|
5124
|
+
var import_typeorm23 = require("typeorm");
|
|
5125
|
+
var ChatMessage = class {
|
|
5126
|
+
id;
|
|
5127
|
+
conversationId;
|
|
5128
|
+
role;
|
|
5129
|
+
content;
|
|
5130
|
+
createdAt;
|
|
5131
|
+
conversation;
|
|
5132
|
+
};
|
|
5133
|
+
__decorateClass([
|
|
5134
|
+
(0, import_typeorm23.PrimaryGeneratedColumn)()
|
|
5135
|
+
], ChatMessage.prototype, "id", 2);
|
|
5136
|
+
__decorateClass([
|
|
5137
|
+
(0, import_typeorm23.Column)("int")
|
|
5138
|
+
], ChatMessage.prototype, "conversationId", 2);
|
|
5139
|
+
__decorateClass([
|
|
5140
|
+
(0, import_typeorm23.Column)("varchar")
|
|
5141
|
+
], ChatMessage.prototype, "role", 2);
|
|
5142
|
+
__decorateClass([
|
|
5143
|
+
(0, import_typeorm23.Column)("text")
|
|
5144
|
+
], ChatMessage.prototype, "content", 2);
|
|
5145
|
+
__decorateClass([
|
|
5146
|
+
(0, import_typeorm23.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
5147
|
+
], ChatMessage.prototype, "createdAt", 2);
|
|
5148
|
+
__decorateClass([
|
|
5149
|
+
(0, import_typeorm23.ManyToOne)(() => ChatConversation, (c) => c.messages, { onDelete: "CASCADE" }),
|
|
5150
|
+
(0, import_typeorm23.JoinColumn)({ name: "conversationId" })
|
|
5151
|
+
], ChatMessage.prototype, "conversation", 2);
|
|
5152
|
+
ChatMessage = __decorateClass([
|
|
5153
|
+
(0, import_typeorm23.Entity)("chat_messages")
|
|
5154
|
+
], ChatMessage);
|
|
5155
|
+
|
|
5156
|
+
// src/entities/chat-conversation.entity.ts
|
|
5157
|
+
var ChatConversation = class {
|
|
5158
|
+
id;
|
|
5159
|
+
contactId;
|
|
5160
|
+
createdAt;
|
|
5161
|
+
updatedAt;
|
|
5162
|
+
contact;
|
|
5163
|
+
messages;
|
|
5164
|
+
};
|
|
5165
|
+
__decorateClass([
|
|
5166
|
+
(0, import_typeorm24.PrimaryGeneratedColumn)()
|
|
5167
|
+
], ChatConversation.prototype, "id", 2);
|
|
5168
|
+
__decorateClass([
|
|
5169
|
+
(0, import_typeorm24.Column)("int")
|
|
5170
|
+
], ChatConversation.prototype, "contactId", 2);
|
|
5171
|
+
__decorateClass([
|
|
5172
|
+
(0, import_typeorm24.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
5173
|
+
], ChatConversation.prototype, "createdAt", 2);
|
|
5174
|
+
__decorateClass([
|
|
5175
|
+
(0, import_typeorm24.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
5176
|
+
], ChatConversation.prototype, "updatedAt", 2);
|
|
5177
|
+
__decorateClass([
|
|
5178
|
+
(0, import_typeorm24.ManyToOne)(() => Contact, (c) => c.chatConversations, { onDelete: "CASCADE" }),
|
|
5179
|
+
(0, import_typeorm24.JoinColumn)({ name: "contactId" })
|
|
5180
|
+
], ChatConversation.prototype, "contact", 2);
|
|
5181
|
+
__decorateClass([
|
|
5182
|
+
(0, import_typeorm24.OneToMany)(() => ChatMessage, (m) => m.conversation)
|
|
5183
|
+
], ChatConversation.prototype, "messages", 2);
|
|
5184
|
+
ChatConversation = __decorateClass([
|
|
5185
|
+
(0, import_typeorm24.Entity)("chat_conversations")
|
|
5186
|
+
], ChatConversation);
|
|
5187
|
+
|
|
5188
|
+
// src/entities/contact.entity.ts
|
|
5189
|
+
var Contact = class {
|
|
5190
|
+
id;
|
|
5191
|
+
name;
|
|
5192
|
+
email;
|
|
5193
|
+
phone;
|
|
5194
|
+
type;
|
|
5195
|
+
company;
|
|
5196
|
+
taxId;
|
|
5197
|
+
notes;
|
|
5198
|
+
createdAt;
|
|
5199
|
+
updatedAt;
|
|
5200
|
+
deletedAt;
|
|
5201
|
+
deleted;
|
|
5202
|
+
createdBy;
|
|
5203
|
+
updatedBy;
|
|
5204
|
+
deletedBy;
|
|
5205
|
+
userId;
|
|
5206
|
+
user;
|
|
5207
|
+
form_submissions;
|
|
5208
|
+
addresses;
|
|
5209
|
+
orders;
|
|
5210
|
+
payments;
|
|
5211
|
+
chatConversations;
|
|
5212
|
+
};
|
|
5213
|
+
__decorateClass([
|
|
5214
|
+
(0, import_typeorm25.PrimaryGeneratedColumn)()
|
|
5215
|
+
], Contact.prototype, "id", 2);
|
|
5216
|
+
__decorateClass([
|
|
5217
|
+
(0, import_typeorm25.Column)("varchar")
|
|
5218
|
+
], Contact.prototype, "name", 2);
|
|
5219
|
+
__decorateClass([
|
|
5220
|
+
(0, import_typeorm25.Column)("varchar", { unique: true })
|
|
5221
|
+
], Contact.prototype, "email", 2);
|
|
5222
|
+
__decorateClass([
|
|
5223
|
+
(0, import_typeorm25.Column)("varchar", { nullable: true })
|
|
5224
|
+
], Contact.prototype, "phone", 2);
|
|
5225
|
+
__decorateClass([
|
|
5226
|
+
(0, import_typeorm25.Column)("varchar", { nullable: true })
|
|
5227
|
+
], Contact.prototype, "type", 2);
|
|
5228
|
+
__decorateClass([
|
|
5229
|
+
(0, import_typeorm25.Column)("varchar", { nullable: true })
|
|
5230
|
+
], Contact.prototype, "company", 2);
|
|
5231
|
+
__decorateClass([
|
|
5232
|
+
(0, import_typeorm25.Column)("varchar", { nullable: true })
|
|
5233
|
+
], Contact.prototype, "taxId", 2);
|
|
5234
|
+
__decorateClass([
|
|
5235
|
+
(0, import_typeorm25.Column)("text", { nullable: true })
|
|
5236
|
+
], Contact.prototype, "notes", 2);
|
|
5237
|
+
__decorateClass([
|
|
5238
|
+
(0, import_typeorm25.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
5239
|
+
], Contact.prototype, "createdAt", 2);
|
|
5240
|
+
__decorateClass([
|
|
5241
|
+
(0, import_typeorm25.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
5242
|
+
], Contact.prototype, "updatedAt", 2);
|
|
5243
|
+
__decorateClass([
|
|
5244
|
+
(0, import_typeorm25.Column)({ type: "timestamp", nullable: true })
|
|
5245
|
+
], Contact.prototype, "deletedAt", 2);
|
|
5246
|
+
__decorateClass([
|
|
5247
|
+
(0, import_typeorm25.Column)("boolean", { default: false })
|
|
5248
|
+
], Contact.prototype, "deleted", 2);
|
|
5249
|
+
__decorateClass([
|
|
5250
|
+
(0, import_typeorm25.Column)("int", { nullable: true })
|
|
5251
|
+
], Contact.prototype, "createdBy", 2);
|
|
5252
|
+
__decorateClass([
|
|
5253
|
+
(0, import_typeorm25.Column)("int", { nullable: true })
|
|
5254
|
+
], Contact.prototype, "updatedBy", 2);
|
|
5255
|
+
__decorateClass([
|
|
5256
|
+
(0, import_typeorm25.Column)("int", { nullable: true })
|
|
5257
|
+
], Contact.prototype, "deletedBy", 2);
|
|
5258
|
+
__decorateClass([
|
|
5259
|
+
(0, import_typeorm25.Column)("int", { nullable: true })
|
|
5260
|
+
], Contact.prototype, "userId", 2);
|
|
5261
|
+
__decorateClass([
|
|
5262
|
+
(0, import_typeorm25.ManyToOne)(() => User, { onDelete: "SET NULL" }),
|
|
5263
|
+
(0, import_typeorm25.JoinColumn)({ name: "userId" })
|
|
5264
|
+
], Contact.prototype, "user", 2);
|
|
5265
|
+
__decorateClass([
|
|
5266
|
+
(0, import_typeorm25.OneToMany)(() => FormSubmission, (fs) => fs.contact)
|
|
5267
|
+
], Contact.prototype, "form_submissions", 2);
|
|
5268
|
+
__decorateClass([
|
|
5269
|
+
(0, import_typeorm25.OneToMany)(() => Address, (a) => a.contact)
|
|
5270
|
+
], Contact.prototype, "addresses", 2);
|
|
5271
|
+
__decorateClass([
|
|
5272
|
+
(0, import_typeorm25.OneToMany)(() => Order, (o) => o.contact)
|
|
5273
|
+
], Contact.prototype, "orders", 2);
|
|
5274
|
+
__decorateClass([
|
|
5275
|
+
(0, import_typeorm25.OneToMany)(() => Payment, (p) => p.contact)
|
|
5276
|
+
], Contact.prototype, "payments", 2);
|
|
5277
|
+
__decorateClass([
|
|
5278
|
+
(0, import_typeorm25.OneToMany)(() => ChatConversation, (c) => c.contact)
|
|
5279
|
+
], Contact.prototype, "chatConversations", 2);
|
|
5280
|
+
Contact = __decorateClass([
|
|
5281
|
+
(0, import_typeorm25.Entity)("contacts")
|
|
5282
|
+
], Contact);
|
|
5283
|
+
|
|
5284
|
+
// src/entities/config.entity.ts
|
|
5285
|
+
var import_typeorm26 = require("typeorm");
|
|
5286
|
+
var Config = class {
|
|
5287
|
+
id;
|
|
5288
|
+
settings;
|
|
5289
|
+
key;
|
|
5290
|
+
value;
|
|
5291
|
+
type;
|
|
5292
|
+
encrypted;
|
|
5293
|
+
createdAt;
|
|
5294
|
+
updatedAt;
|
|
5295
|
+
deletedAt;
|
|
5296
|
+
deleted;
|
|
5297
|
+
createdBy;
|
|
5298
|
+
updatedBy;
|
|
5299
|
+
deletedBy;
|
|
5300
|
+
};
|
|
5301
|
+
__decorateClass([
|
|
5302
|
+
(0, import_typeorm26.PrimaryGeneratedColumn)()
|
|
5303
|
+
], Config.prototype, "id", 2);
|
|
5304
|
+
__decorateClass([
|
|
5305
|
+
(0, import_typeorm26.Column)("varchar")
|
|
5306
|
+
], Config.prototype, "settings", 2);
|
|
5307
|
+
__decorateClass([
|
|
5308
|
+
(0, import_typeorm26.Column)("varchar")
|
|
5309
|
+
], Config.prototype, "key", 2);
|
|
5310
|
+
__decorateClass([
|
|
5311
|
+
(0, import_typeorm26.Column)("varchar")
|
|
5312
|
+
], Config.prototype, "value", 2);
|
|
5313
|
+
__decorateClass([
|
|
5314
|
+
(0, import_typeorm26.Column)("varchar", { default: "private" })
|
|
5315
|
+
], Config.prototype, "type", 2);
|
|
5316
|
+
__decorateClass([
|
|
5317
|
+
(0, import_typeorm26.Column)("boolean", { default: false })
|
|
5318
|
+
], Config.prototype, "encrypted", 2);
|
|
5319
|
+
__decorateClass([
|
|
5320
|
+
(0, import_typeorm26.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
5321
|
+
], Config.prototype, "createdAt", 2);
|
|
5322
|
+
__decorateClass([
|
|
5323
|
+
(0, import_typeorm26.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
5324
|
+
], Config.prototype, "updatedAt", 2);
|
|
5325
|
+
__decorateClass([
|
|
5326
|
+
(0, import_typeorm26.Column)({ type: "timestamp", nullable: true })
|
|
5327
|
+
], Config.prototype, "deletedAt", 2);
|
|
5328
|
+
__decorateClass([
|
|
5329
|
+
(0, import_typeorm26.Column)("boolean", { default: false })
|
|
5330
|
+
], Config.prototype, "deleted", 2);
|
|
5331
|
+
__decorateClass([
|
|
5332
|
+
(0, import_typeorm26.Column)("int", { nullable: true })
|
|
5333
|
+
], Config.prototype, "createdBy", 2);
|
|
5334
|
+
__decorateClass([
|
|
5335
|
+
(0, import_typeorm26.Column)("int", { nullable: true })
|
|
5336
|
+
], Config.prototype, "updatedBy", 2);
|
|
5337
|
+
__decorateClass([
|
|
5338
|
+
(0, import_typeorm26.Column)("int", { nullable: true })
|
|
5339
|
+
], Config.prototype, "deletedBy", 2);
|
|
5340
|
+
Config = __decorateClass([
|
|
5341
|
+
(0, import_typeorm26.Entity)("configs"),
|
|
5342
|
+
(0, import_typeorm26.Unique)(["settings", "key"])
|
|
5343
|
+
], Config);
|
|
5344
|
+
|
|
5345
|
+
// src/entities/message-template.entity.ts
|
|
5346
|
+
var import_typeorm27 = require("typeorm");
|
|
5347
|
+
var MessageTemplate = class {
|
|
5348
|
+
id;
|
|
5349
|
+
channel;
|
|
5350
|
+
templateKey;
|
|
5351
|
+
name;
|
|
5352
|
+
subject;
|
|
5353
|
+
body;
|
|
5354
|
+
externalTemplateRef;
|
|
5355
|
+
providerMeta;
|
|
5356
|
+
enabled;
|
|
5357
|
+
createdAt;
|
|
5358
|
+
updatedAt;
|
|
5359
|
+
deletedAt;
|
|
5360
|
+
deleted;
|
|
5361
|
+
createdBy;
|
|
5362
|
+
updatedBy;
|
|
5363
|
+
deletedBy;
|
|
5364
|
+
};
|
|
5365
|
+
__decorateClass([
|
|
5366
|
+
(0, import_typeorm27.PrimaryGeneratedColumn)()
|
|
5367
|
+
], MessageTemplate.prototype, "id", 2);
|
|
5368
|
+
__decorateClass([
|
|
5369
|
+
(0, import_typeorm27.Column)("varchar")
|
|
5370
|
+
], MessageTemplate.prototype, "channel", 2);
|
|
5371
|
+
__decorateClass([
|
|
5372
|
+
(0, import_typeorm27.Column)("varchar", { name: "template_key" })
|
|
5373
|
+
], MessageTemplate.prototype, "templateKey", 2);
|
|
5374
|
+
__decorateClass([
|
|
5375
|
+
(0, import_typeorm27.Column)("varchar", { nullable: true })
|
|
5376
|
+
], MessageTemplate.prototype, "name", 2);
|
|
5377
|
+
__decorateClass([
|
|
5378
|
+
(0, import_typeorm27.Column)("varchar", { nullable: true })
|
|
5379
|
+
], MessageTemplate.prototype, "subject", 2);
|
|
5380
|
+
__decorateClass([
|
|
5381
|
+
(0, import_typeorm27.Column)("text", { default: "" })
|
|
5382
|
+
], MessageTemplate.prototype, "body", 2);
|
|
5383
|
+
__decorateClass([
|
|
5384
|
+
(0, import_typeorm27.Column)("varchar", { name: "external_template_ref", nullable: true })
|
|
5385
|
+
], MessageTemplate.prototype, "externalTemplateRef", 2);
|
|
5386
|
+
__decorateClass([
|
|
5387
|
+
(0, import_typeorm27.Column)({ type: "jsonb", nullable: true })
|
|
5388
|
+
], MessageTemplate.prototype, "providerMeta", 2);
|
|
5389
|
+
__decorateClass([
|
|
5390
|
+
(0, import_typeorm27.Column)("boolean", { default: true })
|
|
5391
|
+
], MessageTemplate.prototype, "enabled", 2);
|
|
5392
|
+
__decorateClass([
|
|
5393
|
+
(0, import_typeorm27.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
5394
|
+
], MessageTemplate.prototype, "createdAt", 2);
|
|
5395
|
+
__decorateClass([
|
|
5396
|
+
(0, import_typeorm27.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
5397
|
+
], MessageTemplate.prototype, "updatedAt", 2);
|
|
5398
|
+
__decorateClass([
|
|
5399
|
+
(0, import_typeorm27.Column)({ type: "timestamp", nullable: true })
|
|
5400
|
+
], MessageTemplate.prototype, "deletedAt", 2);
|
|
5401
|
+
__decorateClass([
|
|
5402
|
+
(0, import_typeorm27.Column)("boolean", { default: false })
|
|
5403
|
+
], MessageTemplate.prototype, "deleted", 2);
|
|
5404
|
+
__decorateClass([
|
|
5405
|
+
(0, import_typeorm27.Column)("int", { nullable: true })
|
|
5406
|
+
], MessageTemplate.prototype, "createdBy", 2);
|
|
5407
|
+
__decorateClass([
|
|
5408
|
+
(0, import_typeorm27.Column)("int", { nullable: true })
|
|
5409
|
+
], MessageTemplate.prototype, "updatedBy", 2);
|
|
5410
|
+
__decorateClass([
|
|
5411
|
+
(0, import_typeorm27.Column)("int", { nullable: true })
|
|
5412
|
+
], MessageTemplate.prototype, "deletedBy", 2);
|
|
5413
|
+
MessageTemplate = __decorateClass([
|
|
5414
|
+
(0, import_typeorm27.Entity)("message_templates")
|
|
5415
|
+
], MessageTemplate);
|
|
5416
|
+
|
|
5417
|
+
// src/entities/media.entity.ts
|
|
5418
|
+
var import_typeorm28 = require("typeorm");
|
|
5419
|
+
var Media = class {
|
|
5420
|
+
id;
|
|
5421
|
+
kind;
|
|
5422
|
+
parentId;
|
|
5423
|
+
parent;
|
|
5424
|
+
children;
|
|
5425
|
+
filename;
|
|
5426
|
+
url;
|
|
5427
|
+
mimeType;
|
|
5428
|
+
size;
|
|
5429
|
+
alt;
|
|
5430
|
+
isPublic;
|
|
5431
|
+
createdAt;
|
|
5432
|
+
updatedAt;
|
|
5433
|
+
deletedAt;
|
|
5434
|
+
deleted;
|
|
5435
|
+
};
|
|
5436
|
+
__decorateClass([
|
|
5437
|
+
(0, import_typeorm28.PrimaryGeneratedColumn)()
|
|
5438
|
+
], Media.prototype, "id", 2);
|
|
5439
|
+
__decorateClass([
|
|
5440
|
+
(0, import_typeorm28.Column)({ type: "varchar", length: 16, default: "file" })
|
|
5441
|
+
], Media.prototype, "kind", 2);
|
|
5442
|
+
__decorateClass([
|
|
5443
|
+
(0, import_typeorm28.Column)({ type: "int", nullable: true })
|
|
5444
|
+
], Media.prototype, "parentId", 2);
|
|
5445
|
+
__decorateClass([
|
|
5446
|
+
(0, import_typeorm28.ManyToOne)(() => Media, (m) => m.children, { onDelete: "CASCADE" }),
|
|
5447
|
+
(0, import_typeorm28.JoinColumn)({ name: "parentId" })
|
|
5448
|
+
], Media.prototype, "parent", 2);
|
|
5449
|
+
__decorateClass([
|
|
5450
|
+
(0, import_typeorm28.OneToMany)(() => Media, (m) => m.parent)
|
|
5451
|
+
], Media.prototype, "children", 2);
|
|
5452
|
+
__decorateClass([
|
|
5453
|
+
(0, import_typeorm28.Column)("varchar")
|
|
5454
|
+
], Media.prototype, "filename", 2);
|
|
5455
|
+
__decorateClass([
|
|
5456
|
+
(0, import_typeorm28.Column)("varchar", { nullable: true })
|
|
5457
|
+
], Media.prototype, "url", 2);
|
|
5458
|
+
__decorateClass([
|
|
5459
|
+
(0, import_typeorm28.Column)("varchar", { nullable: true })
|
|
5460
|
+
], Media.prototype, "mimeType", 2);
|
|
5461
|
+
__decorateClass([
|
|
5462
|
+
(0, import_typeorm28.Column)("int", { default: 0 })
|
|
5463
|
+
], Media.prototype, "size", 2);
|
|
5464
|
+
__decorateClass([
|
|
5465
|
+
(0, import_typeorm28.Column)("varchar", { nullable: true })
|
|
5466
|
+
], Media.prototype, "alt", 2);
|
|
5467
|
+
__decorateClass([
|
|
5468
|
+
(0, import_typeorm28.Column)("boolean", { default: false })
|
|
5469
|
+
], Media.prototype, "isPublic", 2);
|
|
5470
|
+
__decorateClass([
|
|
5471
|
+
(0, import_typeorm28.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
5472
|
+
], Media.prototype, "createdAt", 2);
|
|
5473
|
+
__decorateClass([
|
|
5474
|
+
(0, import_typeorm28.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
5475
|
+
], Media.prototype, "updatedAt", 2);
|
|
5476
|
+
__decorateClass([
|
|
5477
|
+
(0, import_typeorm28.Column)({ type: "timestamp", nullable: true })
|
|
5478
|
+
], Media.prototype, "deletedAt", 2);
|
|
5479
|
+
__decorateClass([
|
|
5480
|
+
(0, import_typeorm28.Column)("boolean", { default: false })
|
|
5481
|
+
], Media.prototype, "deleted", 2);
|
|
5482
|
+
Media = __decorateClass([
|
|
5483
|
+
(0, import_typeorm28.Entity)("media")
|
|
5484
|
+
], Media);
|
|
5485
|
+
|
|
5486
|
+
// src/entities/page.entity.ts
|
|
5487
|
+
var import_typeorm29 = require("typeorm");
|
|
5488
|
+
var Page = class {
|
|
5489
|
+
id;
|
|
5490
|
+
title;
|
|
5491
|
+
slug;
|
|
5492
|
+
content;
|
|
5493
|
+
published;
|
|
5494
|
+
theme;
|
|
5495
|
+
parentId;
|
|
5496
|
+
parent;
|
|
5497
|
+
seoId;
|
|
5498
|
+
seo;
|
|
5499
|
+
createdAt;
|
|
5500
|
+
updatedAt;
|
|
5501
|
+
deletedAt;
|
|
5502
|
+
deleted;
|
|
5503
|
+
createdBy;
|
|
5504
|
+
updatedBy;
|
|
5505
|
+
deletedBy;
|
|
5506
|
+
};
|
|
5507
|
+
__decorateClass([
|
|
5508
|
+
(0, import_typeorm29.PrimaryGeneratedColumn)()
|
|
5509
|
+
], Page.prototype, "id", 2);
|
|
5510
|
+
__decorateClass([
|
|
5511
|
+
(0, import_typeorm29.Column)("varchar")
|
|
5512
|
+
], Page.prototype, "title", 2);
|
|
5513
|
+
__decorateClass([
|
|
5514
|
+
(0, import_typeorm29.Column)("varchar", { unique: true })
|
|
5515
|
+
], Page.prototype, "slug", 2);
|
|
5516
|
+
__decorateClass([
|
|
5517
|
+
(0, import_typeorm29.Column)({ type: "jsonb", default: {} })
|
|
5518
|
+
], Page.prototype, "content", 2);
|
|
5519
|
+
__decorateClass([
|
|
5520
|
+
(0, import_typeorm29.Column)("boolean", { default: false })
|
|
5521
|
+
], Page.prototype, "published", 2);
|
|
5522
|
+
__decorateClass([
|
|
5523
|
+
(0, import_typeorm29.Column)("varchar", { default: "default" })
|
|
5524
|
+
], Page.prototype, "theme", 2);
|
|
5525
|
+
__decorateClass([
|
|
5526
|
+
(0, import_typeorm29.Column)("int", { nullable: true })
|
|
5527
|
+
], Page.prototype, "parentId", 2);
|
|
5528
|
+
__decorateClass([
|
|
5529
|
+
(0, import_typeorm29.ManyToOne)(() => Page, { onDelete: "SET NULL" }),
|
|
5530
|
+
(0, import_typeorm29.JoinColumn)({ name: "parentId" })
|
|
5531
|
+
], Page.prototype, "parent", 2);
|
|
5532
|
+
__decorateClass([
|
|
5533
|
+
(0, import_typeorm29.Column)("int", { nullable: true })
|
|
5534
|
+
], Page.prototype, "seoId", 2);
|
|
5535
|
+
__decorateClass([
|
|
5536
|
+
(0, import_typeorm29.ManyToOne)(() => Seo, { onDelete: "SET NULL" }),
|
|
5537
|
+
(0, import_typeorm29.JoinColumn)({ name: "seoId" })
|
|
5538
|
+
], Page.prototype, "seo", 2);
|
|
5539
|
+
__decorateClass([
|
|
5540
|
+
(0, import_typeorm29.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
5541
|
+
], Page.prototype, "createdAt", 2);
|
|
5542
|
+
__decorateClass([
|
|
5543
|
+
(0, import_typeorm29.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
5544
|
+
], Page.prototype, "updatedAt", 2);
|
|
5545
|
+
__decorateClass([
|
|
5546
|
+
(0, import_typeorm29.Column)({ type: "timestamp", nullable: true })
|
|
5547
|
+
], Page.prototype, "deletedAt", 2);
|
|
5548
|
+
__decorateClass([
|
|
5549
|
+
(0, import_typeorm29.Column)("boolean", { default: false })
|
|
5550
|
+
], Page.prototype, "deleted", 2);
|
|
5551
|
+
__decorateClass([
|
|
5552
|
+
(0, import_typeorm29.Column)("int", { nullable: true })
|
|
5553
|
+
], Page.prototype, "createdBy", 2);
|
|
5554
|
+
__decorateClass([
|
|
5555
|
+
(0, import_typeorm29.Column)("int", { nullable: true })
|
|
5556
|
+
], Page.prototype, "updatedBy", 2);
|
|
5557
|
+
__decorateClass([
|
|
5558
|
+
(0, import_typeorm29.Column)("int", { nullable: true })
|
|
5559
|
+
], Page.prototype, "deletedBy", 2);
|
|
5560
|
+
Page = __decorateClass([
|
|
5561
|
+
(0, import_typeorm29.Entity)("pages")
|
|
5562
|
+
], Page);
|
|
5563
|
+
|
|
5564
|
+
// src/entities/product-category.entity.ts
|
|
5565
|
+
var import_typeorm30 = require("typeorm");
|
|
5566
|
+
var ProductCategory = class {
|
|
5567
|
+
id;
|
|
5568
|
+
name;
|
|
5569
|
+
slug;
|
|
5570
|
+
parentId;
|
|
5571
|
+
image;
|
|
5572
|
+
description;
|
|
5573
|
+
metadata;
|
|
5574
|
+
active;
|
|
5575
|
+
sortOrder;
|
|
5576
|
+
createdAt;
|
|
5577
|
+
updatedAt;
|
|
5578
|
+
deletedAt;
|
|
5579
|
+
deleted;
|
|
5580
|
+
createdBy;
|
|
5581
|
+
updatedBy;
|
|
5582
|
+
deletedBy;
|
|
5583
|
+
parent;
|
|
5584
|
+
children;
|
|
5585
|
+
products;
|
|
5586
|
+
collections;
|
|
5587
|
+
};
|
|
5588
|
+
__decorateClass([
|
|
5589
|
+
(0, import_typeorm30.PrimaryGeneratedColumn)()
|
|
5590
|
+
], ProductCategory.prototype, "id", 2);
|
|
5591
|
+
__decorateClass([
|
|
5592
|
+
(0, import_typeorm30.Column)("varchar")
|
|
5593
|
+
], ProductCategory.prototype, "name", 2);
|
|
5594
|
+
__decorateClass([
|
|
5595
|
+
(0, import_typeorm30.Column)("varchar", { unique: true })
|
|
5596
|
+
], ProductCategory.prototype, "slug", 2);
|
|
5597
|
+
__decorateClass([
|
|
5598
|
+
(0, import_typeorm30.Column)("int", { nullable: true })
|
|
5599
|
+
], ProductCategory.prototype, "parentId", 2);
|
|
5600
|
+
__decorateClass([
|
|
5601
|
+
(0, import_typeorm30.Column)("varchar", { nullable: true })
|
|
5602
|
+
], ProductCategory.prototype, "image", 2);
|
|
5603
|
+
__decorateClass([
|
|
5604
|
+
(0, import_typeorm30.Column)("text", { nullable: true })
|
|
5605
|
+
], ProductCategory.prototype, "description", 2);
|
|
5606
|
+
__decorateClass([
|
|
5607
|
+
(0, import_typeorm30.Column)("jsonb", { nullable: true })
|
|
5608
|
+
], ProductCategory.prototype, "metadata", 2);
|
|
5609
|
+
__decorateClass([
|
|
5610
|
+
(0, import_typeorm30.Column)("boolean", { default: true })
|
|
5611
|
+
], ProductCategory.prototype, "active", 2);
|
|
5612
|
+
__decorateClass([
|
|
5613
|
+
(0, import_typeorm30.Column)("int", { default: 0 })
|
|
5614
|
+
], ProductCategory.prototype, "sortOrder", 2);
|
|
5615
|
+
__decorateClass([
|
|
5616
|
+
(0, import_typeorm30.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
5617
|
+
], ProductCategory.prototype, "createdAt", 2);
|
|
5618
|
+
__decorateClass([
|
|
5619
|
+
(0, import_typeorm30.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
5620
|
+
], ProductCategory.prototype, "updatedAt", 2);
|
|
5621
|
+
__decorateClass([
|
|
5622
|
+
(0, import_typeorm30.Column)({ type: "timestamp", nullable: true })
|
|
5623
|
+
], ProductCategory.prototype, "deletedAt", 2);
|
|
5624
|
+
__decorateClass([
|
|
5625
|
+
(0, import_typeorm30.Column)("boolean", { default: false })
|
|
5626
|
+
], ProductCategory.prototype, "deleted", 2);
|
|
5627
|
+
__decorateClass([
|
|
5628
|
+
(0, import_typeorm30.Column)("int", { nullable: true })
|
|
5629
|
+
], ProductCategory.prototype, "createdBy", 2);
|
|
5630
|
+
__decorateClass([
|
|
5631
|
+
(0, import_typeorm30.Column)("int", { nullable: true })
|
|
5632
|
+
], ProductCategory.prototype, "updatedBy", 2);
|
|
5633
|
+
__decorateClass([
|
|
5634
|
+
(0, import_typeorm30.Column)("int", { nullable: true })
|
|
5635
|
+
], ProductCategory.prototype, "deletedBy", 2);
|
|
5636
|
+
__decorateClass([
|
|
5637
|
+
(0, import_typeorm30.ManyToOne)(() => ProductCategory, (c) => c.children, { onDelete: "SET NULL" }),
|
|
5638
|
+
(0, import_typeorm30.JoinColumn)({ name: "parentId" })
|
|
5639
|
+
], ProductCategory.prototype, "parent", 2);
|
|
5640
|
+
__decorateClass([
|
|
5641
|
+
(0, import_typeorm30.OneToMany)(() => ProductCategory, (c) => c.parent)
|
|
5642
|
+
], ProductCategory.prototype, "children", 2);
|
|
5643
|
+
__decorateClass([
|
|
5644
|
+
(0, import_typeorm30.OneToMany)("Product", "category")
|
|
5645
|
+
], ProductCategory.prototype, "products", 2);
|
|
5646
|
+
__decorateClass([
|
|
5647
|
+
(0, import_typeorm30.OneToMany)("Collection", "category")
|
|
5648
|
+
], ProductCategory.prototype, "collections", 2);
|
|
5649
|
+
ProductCategory = __decorateClass([
|
|
5650
|
+
(0, import_typeorm30.Entity)("product_categories")
|
|
5651
|
+
], ProductCategory);
|
|
5652
|
+
|
|
5653
|
+
// src/entities/collection.entity.ts
|
|
5654
|
+
var import_typeorm32 = require("typeorm");
|
|
5655
|
+
|
|
5656
|
+
// src/entities/brand.entity.ts
|
|
5657
|
+
var import_typeorm31 = require("typeorm");
|
|
5658
|
+
var Brand = class {
|
|
5659
|
+
id;
|
|
5660
|
+
name;
|
|
5661
|
+
slug;
|
|
5662
|
+
logo;
|
|
5663
|
+
metadata;
|
|
5664
|
+
description;
|
|
5665
|
+
active;
|
|
5666
|
+
sortOrder;
|
|
5667
|
+
createdAt;
|
|
5668
|
+
updatedAt;
|
|
5669
|
+
deletedAt;
|
|
5670
|
+
deleted;
|
|
5671
|
+
createdBy;
|
|
5672
|
+
updatedBy;
|
|
5673
|
+
deletedBy;
|
|
5674
|
+
seoId;
|
|
5675
|
+
seo;
|
|
5676
|
+
products;
|
|
5677
|
+
collections;
|
|
5678
|
+
};
|
|
5679
|
+
__decorateClass([
|
|
5680
|
+
(0, import_typeorm31.PrimaryGeneratedColumn)()
|
|
5681
|
+
], Brand.prototype, "id", 2);
|
|
5682
|
+
__decorateClass([
|
|
5683
|
+
(0, import_typeorm31.Column)("varchar")
|
|
5684
|
+
], Brand.prototype, "name", 2);
|
|
5685
|
+
__decorateClass([
|
|
5686
|
+
(0, import_typeorm31.Column)("varchar", { unique: true })
|
|
5687
|
+
], Brand.prototype, "slug", 2);
|
|
5688
|
+
__decorateClass([
|
|
5689
|
+
(0, import_typeorm31.Column)("varchar", { nullable: true })
|
|
5690
|
+
], Brand.prototype, "logo", 2);
|
|
5691
|
+
__decorateClass([
|
|
5692
|
+
(0, import_typeorm31.Column)("jsonb", { nullable: true })
|
|
5693
|
+
], Brand.prototype, "metadata", 2);
|
|
5694
|
+
__decorateClass([
|
|
5695
|
+
(0, import_typeorm31.Column)("text", { nullable: true })
|
|
5696
|
+
], Brand.prototype, "description", 2);
|
|
5697
|
+
__decorateClass([
|
|
5698
|
+
(0, import_typeorm31.Column)("boolean", { default: true })
|
|
5699
|
+
], Brand.prototype, "active", 2);
|
|
5700
|
+
__decorateClass([
|
|
5701
|
+
(0, import_typeorm31.Column)("int", { default: 0 })
|
|
5702
|
+
], Brand.prototype, "sortOrder", 2);
|
|
5703
|
+
__decorateClass([
|
|
5704
|
+
(0, import_typeorm31.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
5705
|
+
], Brand.prototype, "createdAt", 2);
|
|
5706
|
+
__decorateClass([
|
|
5707
|
+
(0, import_typeorm31.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
5708
|
+
], Brand.prototype, "updatedAt", 2);
|
|
5709
|
+
__decorateClass([
|
|
5710
|
+
(0, import_typeorm31.Column)({ type: "timestamp", nullable: true })
|
|
5711
|
+
], Brand.prototype, "deletedAt", 2);
|
|
5712
|
+
__decorateClass([
|
|
5713
|
+
(0, import_typeorm31.Column)("boolean", { default: false })
|
|
5714
|
+
], Brand.prototype, "deleted", 2);
|
|
5715
|
+
__decorateClass([
|
|
5716
|
+
(0, import_typeorm31.Column)("int", { nullable: true })
|
|
5717
|
+
], Brand.prototype, "createdBy", 2);
|
|
5718
|
+
__decorateClass([
|
|
5719
|
+
(0, import_typeorm31.Column)("int", { nullable: true })
|
|
5720
|
+
], Brand.prototype, "updatedBy", 2);
|
|
5721
|
+
__decorateClass([
|
|
5722
|
+
(0, import_typeorm31.Column)("int", { nullable: true })
|
|
5723
|
+
], Brand.prototype, "deletedBy", 2);
|
|
5724
|
+
__decorateClass([
|
|
5725
|
+
(0, import_typeorm31.Column)("int", { nullable: true })
|
|
5726
|
+
], Brand.prototype, "seoId", 2);
|
|
5727
|
+
__decorateClass([
|
|
5728
|
+
(0, import_typeorm31.ManyToOne)(() => Seo, { onDelete: "SET NULL" }),
|
|
5729
|
+
(0, import_typeorm31.JoinColumn)({ name: "seoId" })
|
|
5730
|
+
], Brand.prototype, "seo", 2);
|
|
5731
|
+
__decorateClass([
|
|
5732
|
+
(0, import_typeorm31.OneToMany)("Product", "brand")
|
|
5733
|
+
], Brand.prototype, "products", 2);
|
|
5734
|
+
__decorateClass([
|
|
5735
|
+
(0, import_typeorm31.OneToMany)("Collection", "brand")
|
|
5736
|
+
], Brand.prototype, "collections", 2);
|
|
5737
|
+
Brand = __decorateClass([
|
|
5738
|
+
(0, import_typeorm31.Entity)("brands")
|
|
5739
|
+
], Brand);
|
|
5740
|
+
|
|
5741
|
+
// src/entities/collection.entity.ts
|
|
5742
|
+
var Collection = class {
|
|
5743
|
+
id;
|
|
5744
|
+
categoryId;
|
|
5745
|
+
brandId;
|
|
5746
|
+
name;
|
|
5747
|
+
slug;
|
|
5748
|
+
hsn;
|
|
5749
|
+
description;
|
|
5750
|
+
image;
|
|
5751
|
+
metadata;
|
|
5752
|
+
variants;
|
|
5753
|
+
active;
|
|
5754
|
+
sortOrder;
|
|
5755
|
+
createdAt;
|
|
5756
|
+
updatedAt;
|
|
5757
|
+
deletedAt;
|
|
5758
|
+
deleted;
|
|
5759
|
+
createdBy;
|
|
5760
|
+
updatedBy;
|
|
5761
|
+
deletedBy;
|
|
5762
|
+
seoId;
|
|
5763
|
+
seo;
|
|
5764
|
+
category;
|
|
5765
|
+
brand;
|
|
5766
|
+
products;
|
|
5767
|
+
};
|
|
5768
|
+
__decorateClass([
|
|
5769
|
+
(0, import_typeorm32.PrimaryGeneratedColumn)()
|
|
5770
|
+
], Collection.prototype, "id", 2);
|
|
5771
|
+
__decorateClass([
|
|
5772
|
+
(0, import_typeorm32.Column)("int", { nullable: true })
|
|
5773
|
+
], Collection.prototype, "categoryId", 2);
|
|
5774
|
+
__decorateClass([
|
|
5775
|
+
(0, import_typeorm32.Column)("int", { nullable: true })
|
|
5776
|
+
], Collection.prototype, "brandId", 2);
|
|
5777
|
+
__decorateClass([
|
|
5778
|
+
(0, import_typeorm32.Column)("varchar")
|
|
5779
|
+
], Collection.prototype, "name", 2);
|
|
5780
|
+
__decorateClass([
|
|
5781
|
+
(0, import_typeorm32.Column)("varchar", { unique: true })
|
|
5782
|
+
], Collection.prototype, "slug", 2);
|
|
5783
|
+
__decorateClass([
|
|
5784
|
+
(0, import_typeorm32.Column)("varchar", { nullable: true })
|
|
5785
|
+
], Collection.prototype, "hsn", 2);
|
|
5786
|
+
__decorateClass([
|
|
5787
|
+
(0, import_typeorm32.Column)("text", { nullable: true })
|
|
5788
|
+
], Collection.prototype, "description", 2);
|
|
5789
|
+
__decorateClass([
|
|
5790
|
+
(0, import_typeorm32.Column)("varchar", { nullable: true })
|
|
5791
|
+
], Collection.prototype, "image", 2);
|
|
5792
|
+
__decorateClass([
|
|
5793
|
+
(0, import_typeorm32.Column)("jsonb", { nullable: true })
|
|
5794
|
+
], Collection.prototype, "metadata", 2);
|
|
5795
|
+
__decorateClass([
|
|
5796
|
+
(0, import_typeorm32.Column)("jsonb", { nullable: true })
|
|
5797
|
+
], Collection.prototype, "variants", 2);
|
|
5798
|
+
__decorateClass([
|
|
5799
|
+
(0, import_typeorm32.Column)("boolean", { default: true })
|
|
5800
|
+
], Collection.prototype, "active", 2);
|
|
5801
|
+
__decorateClass([
|
|
5802
|
+
(0, import_typeorm32.Column)("int", { default: 0 })
|
|
5803
|
+
], Collection.prototype, "sortOrder", 2);
|
|
5804
|
+
__decorateClass([
|
|
5805
|
+
(0, import_typeorm32.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
5806
|
+
], Collection.prototype, "createdAt", 2);
|
|
5807
|
+
__decorateClass([
|
|
5808
|
+
(0, import_typeorm32.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
5809
|
+
], Collection.prototype, "updatedAt", 2);
|
|
5810
|
+
__decorateClass([
|
|
5811
|
+
(0, import_typeorm32.Column)({ type: "timestamp", nullable: true })
|
|
5812
|
+
], Collection.prototype, "deletedAt", 2);
|
|
5813
|
+
__decorateClass([
|
|
5814
|
+
(0, import_typeorm32.Column)("boolean", { default: false })
|
|
5815
|
+
], Collection.prototype, "deleted", 2);
|
|
5816
|
+
__decorateClass([
|
|
5817
|
+
(0, import_typeorm32.Column)("int", { nullable: true })
|
|
5818
|
+
], Collection.prototype, "createdBy", 2);
|
|
5819
|
+
__decorateClass([
|
|
5820
|
+
(0, import_typeorm32.Column)("int", { nullable: true })
|
|
5821
|
+
], Collection.prototype, "updatedBy", 2);
|
|
5822
|
+
__decorateClass([
|
|
5823
|
+
(0, import_typeorm32.Column)("int", { nullable: true })
|
|
5824
|
+
], Collection.prototype, "deletedBy", 2);
|
|
5825
|
+
__decorateClass([
|
|
5826
|
+
(0, import_typeorm32.Column)("int", { nullable: true })
|
|
5827
|
+
], Collection.prototype, "seoId", 2);
|
|
5828
|
+
__decorateClass([
|
|
5829
|
+
(0, import_typeorm32.ManyToOne)(() => Seo, { onDelete: "SET NULL" }),
|
|
5830
|
+
(0, import_typeorm32.JoinColumn)({ name: "seoId" })
|
|
5831
|
+
], Collection.prototype, "seo", 2);
|
|
5832
|
+
__decorateClass([
|
|
5833
|
+
(0, import_typeorm32.ManyToOne)(() => ProductCategory, (c) => c.collections, { onDelete: "SET NULL" }),
|
|
5834
|
+
(0, import_typeorm32.JoinColumn)({ name: "categoryId" })
|
|
5835
|
+
], Collection.prototype, "category", 2);
|
|
5836
|
+
__decorateClass([
|
|
5837
|
+
(0, import_typeorm32.ManyToOne)(() => Brand, (b) => b.collections, { onDelete: "SET NULL" }),
|
|
5838
|
+
(0, import_typeorm32.JoinColumn)({ name: "brandId" })
|
|
5839
|
+
], Collection.prototype, "brand", 2);
|
|
5840
|
+
__decorateClass([
|
|
5841
|
+
(0, import_typeorm32.OneToMany)("Product", "collection")
|
|
5842
|
+
], Collection.prototype, "products", 2);
|
|
5843
|
+
Collection = __decorateClass([
|
|
5844
|
+
(0, import_typeorm32.Entity)("collections")
|
|
5845
|
+
], Collection);
|
|
5846
|
+
|
|
5847
|
+
// src/entities/product.entity.ts
|
|
5848
|
+
var import_typeorm33 = require("typeorm");
|
|
5849
|
+
var Product = class {
|
|
5850
|
+
id;
|
|
5851
|
+
collectionId;
|
|
5852
|
+
brandId;
|
|
5853
|
+
categoryId;
|
|
5854
|
+
sku;
|
|
5855
|
+
hsn;
|
|
5856
|
+
uom;
|
|
5857
|
+
type;
|
|
5858
|
+
slug;
|
|
5859
|
+
name;
|
|
5860
|
+
price;
|
|
5861
|
+
compareAtPrice;
|
|
5862
|
+
quantity;
|
|
5863
|
+
status;
|
|
5864
|
+
featured;
|
|
5865
|
+
metadata;
|
|
5866
|
+
createdAt;
|
|
5867
|
+
updatedAt;
|
|
5868
|
+
deletedAt;
|
|
5869
|
+
deleted;
|
|
5870
|
+
createdBy;
|
|
5871
|
+
updatedBy;
|
|
5872
|
+
deletedBy;
|
|
5873
|
+
seoId;
|
|
5874
|
+
seo;
|
|
5875
|
+
collection;
|
|
5876
|
+
brand;
|
|
5877
|
+
category;
|
|
5878
|
+
attributes;
|
|
5879
|
+
taxes;
|
|
5880
|
+
};
|
|
5881
|
+
__decorateClass([
|
|
5882
|
+
(0, import_typeorm33.PrimaryGeneratedColumn)()
|
|
5883
|
+
], Product.prototype, "id", 2);
|
|
5884
|
+
__decorateClass([
|
|
5885
|
+
(0, import_typeorm33.Column)("int", { nullable: true })
|
|
5886
|
+
], Product.prototype, "collectionId", 2);
|
|
5887
|
+
__decorateClass([
|
|
5888
|
+
(0, import_typeorm33.Column)("int", { nullable: true })
|
|
5889
|
+
], Product.prototype, "brandId", 2);
|
|
5890
|
+
__decorateClass([
|
|
5891
|
+
(0, import_typeorm33.Column)("int", { nullable: true })
|
|
5892
|
+
], Product.prototype, "categoryId", 2);
|
|
5893
|
+
__decorateClass([
|
|
5894
|
+
(0, import_typeorm33.Column)("varchar", { nullable: true })
|
|
5895
|
+
], Product.prototype, "sku", 2);
|
|
5896
|
+
__decorateClass([
|
|
5897
|
+
(0, import_typeorm33.Column)("varchar", { nullable: true })
|
|
5898
|
+
], Product.prototype, "hsn", 2);
|
|
5899
|
+
__decorateClass([
|
|
5900
|
+
(0, import_typeorm33.Column)("varchar", { nullable: true })
|
|
5901
|
+
], Product.prototype, "uom", 2);
|
|
5902
|
+
__decorateClass([
|
|
5903
|
+
(0, import_typeorm33.Column)("varchar", { default: "product" })
|
|
5904
|
+
], Product.prototype, "type", 2);
|
|
5905
|
+
__decorateClass([
|
|
5906
|
+
(0, import_typeorm33.Column)("varchar", { unique: true, nullable: true })
|
|
5907
|
+
], Product.prototype, "slug", 2);
|
|
5908
|
+
__decorateClass([
|
|
5909
|
+
(0, import_typeorm33.Column)("varchar", { nullable: true })
|
|
5910
|
+
], Product.prototype, "name", 2);
|
|
5911
|
+
__decorateClass([
|
|
5912
|
+
(0, import_typeorm33.Column)("decimal", { precision: 12, scale: 2 })
|
|
5913
|
+
], Product.prototype, "price", 2);
|
|
5914
|
+
__decorateClass([
|
|
5915
|
+
(0, import_typeorm33.Column)("decimal", { precision: 12, scale: 2, nullable: true })
|
|
5916
|
+
], Product.prototype, "compareAtPrice", 2);
|
|
5917
|
+
__decorateClass([
|
|
5918
|
+
(0, import_typeorm33.Column)("int", { default: 0 })
|
|
5919
|
+
], Product.prototype, "quantity", 2);
|
|
5920
|
+
__decorateClass([
|
|
5921
|
+
(0, import_typeorm33.Column)("varchar", { default: "draft" })
|
|
5922
|
+
], Product.prototype, "status", 2);
|
|
5923
|
+
__decorateClass([
|
|
5924
|
+
(0, import_typeorm33.Column)("boolean", { default: false })
|
|
5925
|
+
], Product.prototype, "featured", 2);
|
|
5926
|
+
__decorateClass([
|
|
5927
|
+
(0, import_typeorm33.Column)("jsonb", { nullable: true })
|
|
5928
|
+
], Product.prototype, "metadata", 2);
|
|
5929
|
+
__decorateClass([
|
|
5930
|
+
(0, import_typeorm33.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
5931
|
+
], Product.prototype, "createdAt", 2);
|
|
5932
|
+
__decorateClass([
|
|
5933
|
+
(0, import_typeorm33.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
5934
|
+
], Product.prototype, "updatedAt", 2);
|
|
5935
|
+
__decorateClass([
|
|
5936
|
+
(0, import_typeorm33.Column)({ type: "timestamp", nullable: true })
|
|
5937
|
+
], Product.prototype, "deletedAt", 2);
|
|
5938
|
+
__decorateClass([
|
|
5939
|
+
(0, import_typeorm33.Column)("boolean", { default: false })
|
|
5940
|
+
], Product.prototype, "deleted", 2);
|
|
5941
|
+
__decorateClass([
|
|
5942
|
+
(0, import_typeorm33.Column)("int", { nullable: true })
|
|
5943
|
+
], Product.prototype, "createdBy", 2);
|
|
5944
|
+
__decorateClass([
|
|
5945
|
+
(0, import_typeorm33.Column)("int", { nullable: true })
|
|
5946
|
+
], Product.prototype, "updatedBy", 2);
|
|
5947
|
+
__decorateClass([
|
|
5948
|
+
(0, import_typeorm33.Column)("int", { nullable: true })
|
|
5949
|
+
], Product.prototype, "deletedBy", 2);
|
|
5950
|
+
__decorateClass([
|
|
5951
|
+
(0, import_typeorm33.Column)("int", { nullable: true })
|
|
5952
|
+
], Product.prototype, "seoId", 2);
|
|
5953
|
+
__decorateClass([
|
|
5954
|
+
(0, import_typeorm33.ManyToOne)(() => Seo, { onDelete: "SET NULL" }),
|
|
5955
|
+
(0, import_typeorm33.JoinColumn)({ name: "seoId" })
|
|
5956
|
+
], Product.prototype, "seo", 2);
|
|
5957
|
+
__decorateClass([
|
|
5958
|
+
(0, import_typeorm33.ManyToOne)(() => Collection, (c) => c.products, { onDelete: "SET NULL" }),
|
|
5959
|
+
(0, import_typeorm33.JoinColumn)({ name: "collectionId" })
|
|
5960
|
+
], Product.prototype, "collection", 2);
|
|
5961
|
+
__decorateClass([
|
|
5962
|
+
(0, import_typeorm33.ManyToOne)(() => Brand, (b) => b.products, { onDelete: "SET NULL" }),
|
|
5963
|
+
(0, import_typeorm33.JoinColumn)({ name: "brandId" })
|
|
5964
|
+
], Product.prototype, "brand", 2);
|
|
5965
|
+
__decorateClass([
|
|
5966
|
+
(0, import_typeorm33.ManyToOne)(() => ProductCategory, (c) => c.products, { onDelete: "SET NULL" }),
|
|
5967
|
+
(0, import_typeorm33.JoinColumn)({ name: "categoryId" })
|
|
5968
|
+
], Product.prototype, "category", 2);
|
|
5969
|
+
__decorateClass([
|
|
5970
|
+
(0, import_typeorm33.OneToMany)("ProductAttribute", "product")
|
|
5971
|
+
], Product.prototype, "attributes", 2);
|
|
5972
|
+
__decorateClass([
|
|
5973
|
+
(0, import_typeorm33.OneToMany)("ProductTax", "product")
|
|
5974
|
+
], Product.prototype, "taxes", 2);
|
|
5975
|
+
Product = __decorateClass([
|
|
5976
|
+
(0, import_typeorm33.Entity)("products")
|
|
5977
|
+
], Product);
|
|
5978
|
+
|
|
5979
|
+
// src/entities/attribute.entity.ts
|
|
5980
|
+
var import_typeorm34 = require("typeorm");
|
|
5981
|
+
var Attribute = class {
|
|
5982
|
+
id;
|
|
5983
|
+
name;
|
|
5984
|
+
slug;
|
|
5985
|
+
type;
|
|
5986
|
+
options;
|
|
5987
|
+
metadata;
|
|
5988
|
+
active;
|
|
5989
|
+
sortOrder;
|
|
5990
|
+
createdAt;
|
|
5991
|
+
updatedAt;
|
|
5992
|
+
deletedAt;
|
|
5993
|
+
deleted;
|
|
5994
|
+
createdBy;
|
|
5995
|
+
updatedBy;
|
|
5996
|
+
deletedBy;
|
|
5997
|
+
};
|
|
5998
|
+
__decorateClass([
|
|
5999
|
+
(0, import_typeorm34.PrimaryGeneratedColumn)()
|
|
6000
|
+
], Attribute.prototype, "id", 2);
|
|
6001
|
+
__decorateClass([
|
|
6002
|
+
(0, import_typeorm34.Column)("varchar")
|
|
6003
|
+
], Attribute.prototype, "name", 2);
|
|
6004
|
+
__decorateClass([
|
|
6005
|
+
(0, import_typeorm34.Column)("varchar", { unique: true })
|
|
6006
|
+
], Attribute.prototype, "slug", 2);
|
|
6007
|
+
__decorateClass([
|
|
6008
|
+
(0, import_typeorm34.Column)("varchar", { default: "text" })
|
|
6009
|
+
], Attribute.prototype, "type", 2);
|
|
6010
|
+
__decorateClass([
|
|
6011
|
+
(0, import_typeorm34.Column)("jsonb", { nullable: true })
|
|
6012
|
+
], Attribute.prototype, "options", 2);
|
|
6013
|
+
__decorateClass([
|
|
6014
|
+
(0, import_typeorm34.Column)("jsonb", { nullable: true })
|
|
6015
|
+
], Attribute.prototype, "metadata", 2);
|
|
6016
|
+
__decorateClass([
|
|
6017
|
+
(0, import_typeorm34.Column)("boolean", { default: true })
|
|
6018
|
+
], Attribute.prototype, "active", 2);
|
|
6019
|
+
__decorateClass([
|
|
6020
|
+
(0, import_typeorm34.Column)("int", { default: 0 })
|
|
6021
|
+
], Attribute.prototype, "sortOrder", 2);
|
|
6022
|
+
__decorateClass([
|
|
6023
|
+
(0, import_typeorm34.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
6024
|
+
], Attribute.prototype, "createdAt", 2);
|
|
6025
|
+
__decorateClass([
|
|
6026
|
+
(0, import_typeorm34.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
6027
|
+
], Attribute.prototype, "updatedAt", 2);
|
|
6028
|
+
__decorateClass([
|
|
6029
|
+
(0, import_typeorm34.Column)({ type: "timestamp", nullable: true })
|
|
6030
|
+
], Attribute.prototype, "deletedAt", 2);
|
|
6031
|
+
__decorateClass([
|
|
6032
|
+
(0, import_typeorm34.Column)("boolean", { default: false })
|
|
6033
|
+
], Attribute.prototype, "deleted", 2);
|
|
6034
|
+
__decorateClass([
|
|
6035
|
+
(0, import_typeorm34.Column)("int", { nullable: true })
|
|
6036
|
+
], Attribute.prototype, "createdBy", 2);
|
|
6037
|
+
__decorateClass([
|
|
6038
|
+
(0, import_typeorm34.Column)("int", { nullable: true })
|
|
6039
|
+
], Attribute.prototype, "updatedBy", 2);
|
|
6040
|
+
__decorateClass([
|
|
6041
|
+
(0, import_typeorm34.Column)("int", { nullable: true })
|
|
6042
|
+
], Attribute.prototype, "deletedBy", 2);
|
|
6043
|
+
Attribute = __decorateClass([
|
|
6044
|
+
(0, import_typeorm34.Entity)("attributes")
|
|
6045
|
+
], Attribute);
|
|
6046
|
+
|
|
6047
|
+
// src/entities/product-attribute.entity.ts
|
|
6048
|
+
var import_typeorm35 = require("typeorm");
|
|
6049
|
+
var ProductAttribute = class {
|
|
6050
|
+
id;
|
|
6051
|
+
productId;
|
|
6052
|
+
attributeId;
|
|
6053
|
+
value;
|
|
6054
|
+
metadata;
|
|
6055
|
+
createdAt;
|
|
6056
|
+
updatedAt;
|
|
6057
|
+
product;
|
|
6058
|
+
attribute;
|
|
6059
|
+
};
|
|
6060
|
+
__decorateClass([
|
|
6061
|
+
(0, import_typeorm35.PrimaryGeneratedColumn)()
|
|
6062
|
+
], ProductAttribute.prototype, "id", 2);
|
|
6063
|
+
__decorateClass([
|
|
6064
|
+
(0, import_typeorm35.Column)("int")
|
|
6065
|
+
], ProductAttribute.prototype, "productId", 2);
|
|
6066
|
+
__decorateClass([
|
|
6067
|
+
(0, import_typeorm35.Column)("int")
|
|
6068
|
+
], ProductAttribute.prototype, "attributeId", 2);
|
|
6069
|
+
__decorateClass([
|
|
6070
|
+
(0, import_typeorm35.Column)("varchar")
|
|
6071
|
+
], ProductAttribute.prototype, "value", 2);
|
|
6072
|
+
__decorateClass([
|
|
6073
|
+
(0, import_typeorm35.Column)("jsonb", { nullable: true })
|
|
6074
|
+
], ProductAttribute.prototype, "metadata", 2);
|
|
6075
|
+
__decorateClass([
|
|
6076
|
+
(0, import_typeorm35.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
6077
|
+
], ProductAttribute.prototype, "createdAt", 2);
|
|
6078
|
+
__decorateClass([
|
|
6079
|
+
(0, import_typeorm35.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
6080
|
+
], ProductAttribute.prototype, "updatedAt", 2);
|
|
6081
|
+
__decorateClass([
|
|
6082
|
+
(0, import_typeorm35.ManyToOne)(() => Product, (p) => p.attributes, { onDelete: "CASCADE" }),
|
|
6083
|
+
(0, import_typeorm35.JoinColumn)({ name: "productId" })
|
|
6084
|
+
], ProductAttribute.prototype, "product", 2);
|
|
6085
|
+
__decorateClass([
|
|
6086
|
+
(0, import_typeorm35.ManyToOne)(() => Attribute, { onDelete: "CASCADE" }),
|
|
6087
|
+
(0, import_typeorm35.JoinColumn)({ name: "attributeId" })
|
|
6088
|
+
], ProductAttribute.prototype, "attribute", 2);
|
|
6089
|
+
ProductAttribute = __decorateClass([
|
|
6090
|
+
(0, import_typeorm35.Entity)("product_attributes")
|
|
6091
|
+
], ProductAttribute);
|
|
6092
|
+
|
|
6093
|
+
// src/entities/tax.entity.ts
|
|
6094
|
+
var import_typeorm36 = require("typeorm");
|
|
6095
|
+
var Tax = class {
|
|
6096
|
+
id;
|
|
6097
|
+
name;
|
|
6098
|
+
slug;
|
|
6099
|
+
rate;
|
|
6100
|
+
isDefault;
|
|
6101
|
+
description;
|
|
6102
|
+
active;
|
|
6103
|
+
metadata;
|
|
6104
|
+
createdAt;
|
|
6105
|
+
updatedAt;
|
|
6106
|
+
deletedAt;
|
|
6107
|
+
deleted;
|
|
6108
|
+
createdBy;
|
|
6109
|
+
updatedBy;
|
|
6110
|
+
deletedBy;
|
|
6111
|
+
};
|
|
6112
|
+
__decorateClass([
|
|
6113
|
+
(0, import_typeorm36.PrimaryGeneratedColumn)()
|
|
6114
|
+
], Tax.prototype, "id", 2);
|
|
6115
|
+
__decorateClass([
|
|
6116
|
+
(0, import_typeorm36.Column)("varchar")
|
|
6117
|
+
], Tax.prototype, "name", 2);
|
|
6118
|
+
__decorateClass([
|
|
6119
|
+
(0, import_typeorm36.Column)("varchar", { unique: true })
|
|
6120
|
+
], Tax.prototype, "slug", 2);
|
|
6121
|
+
__decorateClass([
|
|
6122
|
+
(0, import_typeorm36.Column)("decimal", { precision: 5, scale: 2 })
|
|
6123
|
+
], Tax.prototype, "rate", 2);
|
|
6124
|
+
__decorateClass([
|
|
6125
|
+
(0, import_typeorm36.Column)("boolean", { default: false })
|
|
6126
|
+
], Tax.prototype, "isDefault", 2);
|
|
6127
|
+
__decorateClass([
|
|
6128
|
+
(0, import_typeorm36.Column)("text", { nullable: true })
|
|
6129
|
+
], Tax.prototype, "description", 2);
|
|
6130
|
+
__decorateClass([
|
|
6131
|
+
(0, import_typeorm36.Column)("boolean", { default: true })
|
|
6132
|
+
], Tax.prototype, "active", 2);
|
|
6133
|
+
__decorateClass([
|
|
6134
|
+
(0, import_typeorm36.Column)("jsonb", { nullable: true })
|
|
6135
|
+
], Tax.prototype, "metadata", 2);
|
|
6136
|
+
__decorateClass([
|
|
6137
|
+
(0, import_typeorm36.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
6138
|
+
], Tax.prototype, "createdAt", 2);
|
|
6139
|
+
__decorateClass([
|
|
6140
|
+
(0, import_typeorm36.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
6141
|
+
], Tax.prototype, "updatedAt", 2);
|
|
6142
|
+
__decorateClass([
|
|
6143
|
+
(0, import_typeorm36.Column)({ type: "timestamp", nullable: true })
|
|
6144
|
+
], Tax.prototype, "deletedAt", 2);
|
|
6145
|
+
__decorateClass([
|
|
6146
|
+
(0, import_typeorm36.Column)("boolean", { default: false })
|
|
6147
|
+
], Tax.prototype, "deleted", 2);
|
|
6148
|
+
__decorateClass([
|
|
6149
|
+
(0, import_typeorm36.Column)("int", { nullable: true })
|
|
6150
|
+
], Tax.prototype, "createdBy", 2);
|
|
6151
|
+
__decorateClass([
|
|
6152
|
+
(0, import_typeorm36.Column)("int", { nullable: true })
|
|
6153
|
+
], Tax.prototype, "updatedBy", 2);
|
|
6154
|
+
__decorateClass([
|
|
6155
|
+
(0, import_typeorm36.Column)("int", { nullable: true })
|
|
6156
|
+
], Tax.prototype, "deletedBy", 2);
|
|
6157
|
+
Tax = __decorateClass([
|
|
6158
|
+
(0, import_typeorm36.Entity)("taxes")
|
|
6159
|
+
], Tax);
|
|
6160
|
+
|
|
6161
|
+
// src/entities/product-tax.entity.ts
|
|
6162
|
+
var import_typeorm37 = require("typeorm");
|
|
6163
|
+
var ProductTax = class {
|
|
6164
|
+
id;
|
|
6165
|
+
productId;
|
|
6166
|
+
taxId;
|
|
6167
|
+
rate;
|
|
6168
|
+
createdAt;
|
|
6169
|
+
updatedAt;
|
|
6170
|
+
product;
|
|
6171
|
+
tax;
|
|
6172
|
+
};
|
|
6173
|
+
__decorateClass([
|
|
6174
|
+
(0, import_typeorm37.PrimaryGeneratedColumn)()
|
|
6175
|
+
], ProductTax.prototype, "id", 2);
|
|
6176
|
+
__decorateClass([
|
|
6177
|
+
(0, import_typeorm37.Column)("int")
|
|
6178
|
+
], ProductTax.prototype, "productId", 2);
|
|
6179
|
+
__decorateClass([
|
|
6180
|
+
(0, import_typeorm37.Column)("int")
|
|
6181
|
+
], ProductTax.prototype, "taxId", 2);
|
|
6182
|
+
__decorateClass([
|
|
6183
|
+
(0, import_typeorm37.Column)("decimal", { precision: 5, scale: 2, nullable: true })
|
|
6184
|
+
], ProductTax.prototype, "rate", 2);
|
|
6185
|
+
__decorateClass([
|
|
6186
|
+
(0, import_typeorm37.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
6187
|
+
], ProductTax.prototype, "createdAt", 2);
|
|
6188
|
+
__decorateClass([
|
|
6189
|
+
(0, import_typeorm37.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
6190
|
+
], ProductTax.prototype, "updatedAt", 2);
|
|
6191
|
+
__decorateClass([
|
|
6192
|
+
(0, import_typeorm37.ManyToOne)(() => Product, (p) => p.taxes, { onDelete: "CASCADE" }),
|
|
6193
|
+
(0, import_typeorm37.JoinColumn)({ name: "productId" })
|
|
6194
|
+
], ProductTax.prototype, "product", 2);
|
|
6195
|
+
__decorateClass([
|
|
6196
|
+
(0, import_typeorm37.ManyToOne)(() => Tax, { onDelete: "CASCADE" }),
|
|
6197
|
+
(0, import_typeorm37.JoinColumn)({ name: "taxId" })
|
|
6198
|
+
], ProductTax.prototype, "tax", 2);
|
|
6199
|
+
ProductTax = __decorateClass([
|
|
6200
|
+
(0, import_typeorm37.Entity)("product_taxes")
|
|
6201
|
+
], ProductTax);
|
|
6202
|
+
|
|
6203
|
+
// src/entities/order-item.entity.ts
|
|
6204
|
+
var import_typeorm38 = require("typeorm");
|
|
6205
|
+
var OrderItem = class {
|
|
6206
|
+
id;
|
|
6207
|
+
orderId;
|
|
6208
|
+
productId;
|
|
6209
|
+
quantity;
|
|
6210
|
+
unitPrice;
|
|
6211
|
+
tax;
|
|
6212
|
+
total;
|
|
6213
|
+
hsn;
|
|
6214
|
+
uom;
|
|
6215
|
+
productType;
|
|
6216
|
+
taxRate;
|
|
6217
|
+
taxCode;
|
|
6218
|
+
metadata;
|
|
6219
|
+
createdAt;
|
|
6220
|
+
updatedAt;
|
|
6221
|
+
order;
|
|
6222
|
+
product;
|
|
6223
|
+
};
|
|
6224
|
+
__decorateClass([
|
|
6225
|
+
(0, import_typeorm38.PrimaryGeneratedColumn)()
|
|
6226
|
+
], OrderItem.prototype, "id", 2);
|
|
6227
|
+
__decorateClass([
|
|
6228
|
+
(0, import_typeorm38.Column)("int")
|
|
6229
|
+
], OrderItem.prototype, "orderId", 2);
|
|
6230
|
+
__decorateClass([
|
|
6231
|
+
(0, import_typeorm38.Column)("int")
|
|
6232
|
+
], OrderItem.prototype, "productId", 2);
|
|
6233
|
+
__decorateClass([
|
|
6234
|
+
(0, import_typeorm38.Column)("int", { default: 1 })
|
|
6235
|
+
], OrderItem.prototype, "quantity", 2);
|
|
6236
|
+
__decorateClass([
|
|
6237
|
+
(0, import_typeorm38.Column)("decimal", { precision: 12, scale: 2 })
|
|
6238
|
+
], OrderItem.prototype, "unitPrice", 2);
|
|
6239
|
+
__decorateClass([
|
|
6240
|
+
(0, import_typeorm38.Column)("decimal", { precision: 12, scale: 2, default: 0 })
|
|
6241
|
+
], OrderItem.prototype, "tax", 2);
|
|
6242
|
+
__decorateClass([
|
|
6243
|
+
(0, import_typeorm38.Column)("decimal", { precision: 12, scale: 2 })
|
|
6244
|
+
], OrderItem.prototype, "total", 2);
|
|
6245
|
+
__decorateClass([
|
|
6246
|
+
(0, import_typeorm38.Column)("varchar", { nullable: true })
|
|
6247
|
+
], OrderItem.prototype, "hsn", 2);
|
|
6248
|
+
__decorateClass([
|
|
6249
|
+
(0, import_typeorm38.Column)("varchar", { nullable: true })
|
|
6250
|
+
], OrderItem.prototype, "uom", 2);
|
|
6251
|
+
__decorateClass([
|
|
6252
|
+
(0, import_typeorm38.Column)("varchar", { nullable: true })
|
|
6253
|
+
], OrderItem.prototype, "productType", 2);
|
|
6254
|
+
__decorateClass([
|
|
6255
|
+
(0, import_typeorm38.Column)("decimal", { precision: 5, scale: 2, nullable: true })
|
|
6256
|
+
], OrderItem.prototype, "taxRate", 2);
|
|
6257
|
+
__decorateClass([
|
|
6258
|
+
(0, import_typeorm38.Column)("varchar", { nullable: true })
|
|
6259
|
+
], OrderItem.prototype, "taxCode", 2);
|
|
6260
|
+
__decorateClass([
|
|
6261
|
+
(0, import_typeorm38.Column)("jsonb", { nullable: true })
|
|
6262
|
+
], OrderItem.prototype, "metadata", 2);
|
|
6263
|
+
__decorateClass([
|
|
6264
|
+
(0, import_typeorm38.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
6265
|
+
], OrderItem.prototype, "createdAt", 2);
|
|
6266
|
+
__decorateClass([
|
|
6267
|
+
(0, import_typeorm38.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
6268
|
+
], OrderItem.prototype, "updatedAt", 2);
|
|
6269
|
+
__decorateClass([
|
|
6270
|
+
(0, import_typeorm38.ManyToOne)(() => Order, (o) => o.items, { onDelete: "CASCADE" }),
|
|
6271
|
+
(0, import_typeorm38.JoinColumn)({ name: "orderId" })
|
|
6272
|
+
], OrderItem.prototype, "order", 2);
|
|
6273
|
+
__decorateClass([
|
|
6274
|
+
(0, import_typeorm38.ManyToOne)(() => Product, { onDelete: "CASCADE" }),
|
|
6275
|
+
(0, import_typeorm38.JoinColumn)({ name: "productId" })
|
|
6276
|
+
], OrderItem.prototype, "product", 2);
|
|
6277
|
+
OrderItem = __decorateClass([
|
|
6278
|
+
(0, import_typeorm38.Entity)("order_items")
|
|
6279
|
+
], OrderItem);
|
|
6280
|
+
|
|
6281
|
+
// src/entities/knowledge-base-document.entity.ts
|
|
6282
|
+
var import_typeorm40 = require("typeorm");
|
|
6283
|
+
|
|
6284
|
+
// src/entities/knowledge-base-chunk.entity.ts
|
|
6285
|
+
var import_typeorm39 = require("typeorm");
|
|
6286
|
+
var KnowledgeBaseChunk = class {
|
|
6287
|
+
id;
|
|
6288
|
+
documentId;
|
|
6289
|
+
content;
|
|
6290
|
+
chunkIndex;
|
|
6291
|
+
createdAt;
|
|
6292
|
+
document;
|
|
6293
|
+
};
|
|
6294
|
+
__decorateClass([
|
|
6295
|
+
(0, import_typeorm39.PrimaryGeneratedColumn)()
|
|
6296
|
+
], KnowledgeBaseChunk.prototype, "id", 2);
|
|
6297
|
+
__decorateClass([
|
|
6298
|
+
(0, import_typeorm39.Column)("int")
|
|
6299
|
+
], KnowledgeBaseChunk.prototype, "documentId", 2);
|
|
6300
|
+
__decorateClass([
|
|
6301
|
+
(0, import_typeorm39.Column)("text")
|
|
6302
|
+
], KnowledgeBaseChunk.prototype, "content", 2);
|
|
6303
|
+
__decorateClass([
|
|
6304
|
+
(0, import_typeorm39.Column)("int", { default: 0 })
|
|
6305
|
+
], KnowledgeBaseChunk.prototype, "chunkIndex", 2);
|
|
6306
|
+
__decorateClass([
|
|
6307
|
+
(0, import_typeorm39.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
6308
|
+
], KnowledgeBaseChunk.prototype, "createdAt", 2);
|
|
6309
|
+
__decorateClass([
|
|
6310
|
+
(0, import_typeorm39.ManyToOne)(() => KnowledgeBaseDocument, (d) => d.chunks, { onDelete: "CASCADE" }),
|
|
6311
|
+
(0, import_typeorm39.JoinColumn)({ name: "documentId" })
|
|
6312
|
+
], KnowledgeBaseChunk.prototype, "document", 2);
|
|
6313
|
+
KnowledgeBaseChunk = __decorateClass([
|
|
6314
|
+
(0, import_typeorm39.Entity)("knowledge_base_chunks")
|
|
6315
|
+
], KnowledgeBaseChunk);
|
|
6316
|
+
|
|
6317
|
+
// src/entities/knowledge-base-document.entity.ts
|
|
6318
|
+
var KnowledgeBaseDocument = class {
|
|
6319
|
+
id;
|
|
6320
|
+
name;
|
|
6321
|
+
sourceUrl;
|
|
6322
|
+
content;
|
|
6323
|
+
createdAt;
|
|
6324
|
+
updatedAt;
|
|
6325
|
+
chunks;
|
|
6326
|
+
};
|
|
6327
|
+
__decorateClass([
|
|
6328
|
+
(0, import_typeorm40.PrimaryGeneratedColumn)()
|
|
6329
|
+
], KnowledgeBaseDocument.prototype, "id", 2);
|
|
6330
|
+
__decorateClass([
|
|
6331
|
+
(0, import_typeorm40.Column)("varchar")
|
|
6332
|
+
], KnowledgeBaseDocument.prototype, "name", 2);
|
|
6333
|
+
__decorateClass([
|
|
6334
|
+
(0, import_typeorm40.Column)("varchar", { nullable: true })
|
|
6335
|
+
], KnowledgeBaseDocument.prototype, "sourceUrl", 2);
|
|
6336
|
+
__decorateClass([
|
|
6337
|
+
(0, import_typeorm40.Column)("text")
|
|
6338
|
+
], KnowledgeBaseDocument.prototype, "content", 2);
|
|
6339
|
+
__decorateClass([
|
|
6340
|
+
(0, import_typeorm40.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
6341
|
+
], KnowledgeBaseDocument.prototype, "createdAt", 2);
|
|
6342
|
+
__decorateClass([
|
|
6343
|
+
(0, import_typeorm40.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
6344
|
+
], KnowledgeBaseDocument.prototype, "updatedAt", 2);
|
|
6345
|
+
__decorateClass([
|
|
6346
|
+
(0, import_typeorm40.OneToMany)(() => KnowledgeBaseChunk, (c) => c.document)
|
|
6347
|
+
], KnowledgeBaseDocument.prototype, "chunks", 2);
|
|
6348
|
+
KnowledgeBaseDocument = __decorateClass([
|
|
6349
|
+
(0, import_typeorm40.Entity)("knowledge_base_documents")
|
|
6350
|
+
], KnowledgeBaseDocument);
|
|
6351
|
+
|
|
6352
|
+
// src/entities/cart.entity.ts
|
|
6353
|
+
var import_typeorm41 = require("typeorm");
|
|
6354
|
+
var Cart = class {
|
|
6355
|
+
id;
|
|
6356
|
+
guestToken;
|
|
6357
|
+
contactId;
|
|
6358
|
+
currency;
|
|
6359
|
+
expiresAt;
|
|
6360
|
+
createdAt;
|
|
6361
|
+
updatedAt;
|
|
6362
|
+
contact;
|
|
6363
|
+
items;
|
|
6364
|
+
};
|
|
6365
|
+
__decorateClass([
|
|
6366
|
+
(0, import_typeorm41.PrimaryGeneratedColumn)()
|
|
6367
|
+
], Cart.prototype, "id", 2);
|
|
6368
|
+
__decorateClass([
|
|
6369
|
+
(0, import_typeorm41.Column)("varchar", { nullable: true })
|
|
6370
|
+
], Cart.prototype, "guestToken", 2);
|
|
6371
|
+
__decorateClass([
|
|
6372
|
+
(0, import_typeorm41.Column)("int", { nullable: true })
|
|
6373
|
+
], Cart.prototype, "contactId", 2);
|
|
6374
|
+
__decorateClass([
|
|
6375
|
+
(0, import_typeorm41.Column)("varchar", { default: "INR" })
|
|
6376
|
+
], Cart.prototype, "currency", 2);
|
|
6377
|
+
__decorateClass([
|
|
6378
|
+
(0, import_typeorm41.Column)({ type: "timestamp", nullable: true })
|
|
6379
|
+
], Cart.prototype, "expiresAt", 2);
|
|
6380
|
+
__decorateClass([
|
|
6381
|
+
(0, import_typeorm41.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
6382
|
+
], Cart.prototype, "createdAt", 2);
|
|
6383
|
+
__decorateClass([
|
|
6384
|
+
(0, import_typeorm41.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
6385
|
+
], Cart.prototype, "updatedAt", 2);
|
|
6386
|
+
__decorateClass([
|
|
6387
|
+
(0, import_typeorm41.ManyToOne)(() => Contact, { onDelete: "CASCADE" }),
|
|
6388
|
+
(0, import_typeorm41.JoinColumn)({ name: "contactId" })
|
|
6389
|
+
], Cart.prototype, "contact", 2);
|
|
6390
|
+
__decorateClass([
|
|
6391
|
+
(0, import_typeorm41.OneToMany)("CartItem", "cart")
|
|
6392
|
+
], Cart.prototype, "items", 2);
|
|
6393
|
+
Cart = __decorateClass([
|
|
6394
|
+
(0, import_typeorm41.Entity)("carts")
|
|
6395
|
+
], Cart);
|
|
6396
|
+
|
|
6397
|
+
// src/entities/cart-item.entity.ts
|
|
6398
|
+
var import_typeorm42 = require("typeorm");
|
|
6399
|
+
var CartItem = class {
|
|
6400
|
+
id;
|
|
6401
|
+
cartId;
|
|
6402
|
+
productId;
|
|
6403
|
+
quantity;
|
|
6404
|
+
metadata;
|
|
6405
|
+
createdAt;
|
|
6406
|
+
updatedAt;
|
|
6407
|
+
cart;
|
|
6408
|
+
product;
|
|
6409
|
+
};
|
|
6410
|
+
__decorateClass([
|
|
6411
|
+
(0, import_typeorm42.PrimaryGeneratedColumn)()
|
|
6412
|
+
], CartItem.prototype, "id", 2);
|
|
6413
|
+
__decorateClass([
|
|
6414
|
+
(0, import_typeorm42.Column)("int")
|
|
6415
|
+
], CartItem.prototype, "cartId", 2);
|
|
6416
|
+
__decorateClass([
|
|
6417
|
+
(0, import_typeorm42.Column)("int")
|
|
6418
|
+
], CartItem.prototype, "productId", 2);
|
|
6419
|
+
__decorateClass([
|
|
6420
|
+
(0, import_typeorm42.Column)("int", { default: 1 })
|
|
6421
|
+
], CartItem.prototype, "quantity", 2);
|
|
6422
|
+
__decorateClass([
|
|
6423
|
+
(0, import_typeorm42.Column)("jsonb", { nullable: true })
|
|
6424
|
+
], CartItem.prototype, "metadata", 2);
|
|
6425
|
+
__decorateClass([
|
|
6426
|
+
(0, import_typeorm42.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
6427
|
+
], CartItem.prototype, "createdAt", 2);
|
|
6428
|
+
__decorateClass([
|
|
6429
|
+
(0, import_typeorm42.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
6430
|
+
], CartItem.prototype, "updatedAt", 2);
|
|
6431
|
+
__decorateClass([
|
|
6432
|
+
(0, import_typeorm42.ManyToOne)(() => Cart, (c) => c.items, { onDelete: "CASCADE" }),
|
|
6433
|
+
(0, import_typeorm42.JoinColumn)({ name: "cartId" })
|
|
6434
|
+
], CartItem.prototype, "cart", 2);
|
|
6435
|
+
__decorateClass([
|
|
6436
|
+
(0, import_typeorm42.ManyToOne)(() => Product, { onDelete: "CASCADE" }),
|
|
6437
|
+
(0, import_typeorm42.JoinColumn)({ name: "productId" })
|
|
6438
|
+
], CartItem.prototype, "product", 2);
|
|
6439
|
+
CartItem = __decorateClass([
|
|
6440
|
+
(0, import_typeorm42.Entity)("cart_items")
|
|
6441
|
+
], CartItem);
|
|
6442
|
+
|
|
6443
|
+
// src/entities/wishlist.entity.ts
|
|
6444
|
+
var import_typeorm43 = require("typeorm");
|
|
6445
|
+
var Wishlist = class {
|
|
6446
|
+
id;
|
|
6447
|
+
guestId;
|
|
6448
|
+
contactId;
|
|
6449
|
+
name;
|
|
6450
|
+
createdAt;
|
|
6451
|
+
updatedAt;
|
|
6452
|
+
contact;
|
|
6453
|
+
items;
|
|
6454
|
+
};
|
|
6455
|
+
__decorateClass([
|
|
6456
|
+
(0, import_typeorm43.PrimaryGeneratedColumn)()
|
|
6457
|
+
], Wishlist.prototype, "id", 2);
|
|
6458
|
+
__decorateClass([
|
|
6459
|
+
(0, import_typeorm43.Column)("varchar", { nullable: true })
|
|
6460
|
+
], Wishlist.prototype, "guestId", 2);
|
|
6461
|
+
__decorateClass([
|
|
6462
|
+
(0, import_typeorm43.Column)("int", { nullable: true })
|
|
6463
|
+
], Wishlist.prototype, "contactId", 2);
|
|
6464
|
+
__decorateClass([
|
|
6465
|
+
(0, import_typeorm43.Column)("varchar", { default: "default" })
|
|
6466
|
+
], Wishlist.prototype, "name", 2);
|
|
6467
|
+
__decorateClass([
|
|
6468
|
+
(0, import_typeorm43.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
6469
|
+
], Wishlist.prototype, "createdAt", 2);
|
|
6470
|
+
__decorateClass([
|
|
6471
|
+
(0, import_typeorm43.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
6472
|
+
], Wishlist.prototype, "updatedAt", 2);
|
|
6473
|
+
__decorateClass([
|
|
6474
|
+
(0, import_typeorm43.ManyToOne)(() => Contact, { onDelete: "CASCADE" }),
|
|
6475
|
+
(0, import_typeorm43.JoinColumn)({ name: "contactId" })
|
|
6476
|
+
], Wishlist.prototype, "contact", 2);
|
|
6477
|
+
__decorateClass([
|
|
6478
|
+
(0, import_typeorm43.OneToMany)("WishlistItem", "wishlist")
|
|
6479
|
+
], Wishlist.prototype, "items", 2);
|
|
6480
|
+
Wishlist = __decorateClass([
|
|
6481
|
+
(0, import_typeorm43.Entity)("wishlists")
|
|
6482
|
+
], Wishlist);
|
|
6483
|
+
|
|
6484
|
+
// src/entities/wishlist-item.entity.ts
|
|
6485
|
+
var import_typeorm44 = require("typeorm");
|
|
6486
|
+
var WishlistItem = class {
|
|
6487
|
+
id;
|
|
6488
|
+
wishlistId;
|
|
6489
|
+
productId;
|
|
6490
|
+
metadata;
|
|
6491
|
+
createdAt;
|
|
6492
|
+
updatedAt;
|
|
6493
|
+
wishlist;
|
|
6494
|
+
product;
|
|
6495
|
+
};
|
|
6496
|
+
__decorateClass([
|
|
6497
|
+
(0, import_typeorm44.PrimaryGeneratedColumn)()
|
|
6498
|
+
], WishlistItem.prototype, "id", 2);
|
|
6499
|
+
__decorateClass([
|
|
6500
|
+
(0, import_typeorm44.Column)("int")
|
|
6501
|
+
], WishlistItem.prototype, "wishlistId", 2);
|
|
6502
|
+
__decorateClass([
|
|
6503
|
+
(0, import_typeorm44.Column)("int")
|
|
6504
|
+
], WishlistItem.prototype, "productId", 2);
|
|
6505
|
+
__decorateClass([
|
|
6506
|
+
(0, import_typeorm44.Column)("jsonb", { nullable: true })
|
|
6507
|
+
], WishlistItem.prototype, "metadata", 2);
|
|
6508
|
+
__decorateClass([
|
|
6509
|
+
(0, import_typeorm44.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
6510
|
+
], WishlistItem.prototype, "createdAt", 2);
|
|
6511
|
+
__decorateClass([
|
|
6512
|
+
(0, import_typeorm44.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
6513
|
+
], WishlistItem.prototype, "updatedAt", 2);
|
|
6514
|
+
__decorateClass([
|
|
6515
|
+
(0, import_typeorm44.ManyToOne)(() => Wishlist, (w) => w.items, { onDelete: "CASCADE" }),
|
|
6516
|
+
(0, import_typeorm44.JoinColumn)({ name: "wishlistId" })
|
|
6517
|
+
], WishlistItem.prototype, "wishlist", 2);
|
|
6518
|
+
__decorateClass([
|
|
6519
|
+
(0, import_typeorm44.ManyToOne)(() => Product, { onDelete: "CASCADE" }),
|
|
6520
|
+
(0, import_typeorm44.JoinColumn)({ name: "productId" })
|
|
6521
|
+
], WishlistItem.prototype, "product", 2);
|
|
6522
|
+
WishlistItem = __decorateClass([
|
|
6523
|
+
(0, import_typeorm44.Entity)("wishlist_items")
|
|
6524
|
+
], WishlistItem);
|
|
6525
|
+
|
|
6526
|
+
// src/entities/llm-agent-knowledge-document.entity.ts
|
|
6527
|
+
var import_typeorm45 = require("typeorm");
|
|
6528
|
+
var LlmAgentKnowledgeDocument = class {
|
|
6529
|
+
id;
|
|
6530
|
+
agentId;
|
|
6531
|
+
documentId;
|
|
6532
|
+
createdAt;
|
|
6533
|
+
agent;
|
|
6534
|
+
document;
|
|
6535
|
+
};
|
|
6536
|
+
__decorateClass([
|
|
6537
|
+
(0, import_typeorm45.PrimaryGeneratedColumn)()
|
|
6538
|
+
], LlmAgentKnowledgeDocument.prototype, "id", 2);
|
|
6539
|
+
__decorateClass([
|
|
6540
|
+
(0, import_typeorm45.Column)("int")
|
|
6541
|
+
], LlmAgentKnowledgeDocument.prototype, "agentId", 2);
|
|
6542
|
+
__decorateClass([
|
|
6543
|
+
(0, import_typeorm45.Column)("int")
|
|
6544
|
+
], LlmAgentKnowledgeDocument.prototype, "documentId", 2);
|
|
6545
|
+
__decorateClass([
|
|
6546
|
+
(0, import_typeorm45.Column)({ type: "timestamp", default: () => "CURRENT_TIMESTAMP" })
|
|
6547
|
+
], LlmAgentKnowledgeDocument.prototype, "createdAt", 2);
|
|
6548
|
+
__decorateClass([
|
|
6549
|
+
(0, import_typeorm45.ManyToOne)(() => LlmAgent, { onDelete: "CASCADE" }),
|
|
6550
|
+
(0, import_typeorm45.JoinColumn)({ name: "agentId" })
|
|
6551
|
+
], LlmAgentKnowledgeDocument.prototype, "agent", 2);
|
|
6552
|
+
__decorateClass([
|
|
6553
|
+
(0, import_typeorm45.ManyToOne)(() => KnowledgeBaseDocument, { onDelete: "CASCADE" }),
|
|
6554
|
+
(0, import_typeorm45.JoinColumn)({ name: "documentId" })
|
|
6555
|
+
], LlmAgentKnowledgeDocument.prototype, "document", 2);
|
|
6556
|
+
LlmAgentKnowledgeDocument = __decorateClass([
|
|
6557
|
+
(0, import_typeorm45.Entity)("llm_agent_knowledge_documents"),
|
|
6558
|
+
(0, import_typeorm45.Unique)("UQ_llm_agent_knowledge_agent_document", ["agentId", "documentId"]),
|
|
6559
|
+
(0, import_typeorm45.Index)("IDX_llm_agent_knowledge_agent", ["agentId"])
|
|
6560
|
+
], LlmAgentKnowledgeDocument);
|
|
6561
|
+
|
|
6562
|
+
// src/entities/index.ts
|
|
6563
|
+
var CMS_ENTITY_MAP = {
|
|
6564
|
+
users: User,
|
|
6565
|
+
otp_challenges: OtpChallenge,
|
|
6566
|
+
password_reset_tokens: PasswordResetToken,
|
|
6567
|
+
user_groups: UserGroup,
|
|
6568
|
+
permissions: Permission,
|
|
6569
|
+
blogs: Blog,
|
|
6570
|
+
tags: Tag,
|
|
6571
|
+
categories: Category,
|
|
6572
|
+
comments: Comment,
|
|
6573
|
+
contacts: Contact,
|
|
6574
|
+
addresses: Address,
|
|
6575
|
+
forms: Form,
|
|
6576
|
+
form_fields: FormField,
|
|
6577
|
+
form_submissions: FormSubmission,
|
|
6578
|
+
seos: Seo,
|
|
6579
|
+
configs: Config,
|
|
6580
|
+
message_templates: MessageTemplate,
|
|
6581
|
+
media: Media,
|
|
6582
|
+
pages: Page,
|
|
6583
|
+
product_categories: ProductCategory,
|
|
6584
|
+
collections: Collection,
|
|
6585
|
+
products: Product,
|
|
6586
|
+
attributes: Attribute,
|
|
6587
|
+
product_attributes: ProductAttribute,
|
|
6588
|
+
taxes: Tax,
|
|
6589
|
+
product_taxes: ProductTax,
|
|
6590
|
+
orders: Order,
|
|
6591
|
+
order_items: OrderItem,
|
|
6592
|
+
payments: Payment,
|
|
6593
|
+
brands: Brand,
|
|
6594
|
+
knowledge_base_documents: KnowledgeBaseDocument,
|
|
6595
|
+
knowledge_base_chunks: KnowledgeBaseChunk,
|
|
6596
|
+
chat_conversations: ChatConversation,
|
|
6597
|
+
chat_messages: ChatMessage,
|
|
6598
|
+
carts: Cart,
|
|
6599
|
+
cart_items: CartItem,
|
|
6600
|
+
wishlists: Wishlist,
|
|
6601
|
+
wishlist_items: WishlistItem,
|
|
6602
|
+
llm_agents: LlmAgent,
|
|
6603
|
+
llm_agent_knowledge_documents: LlmAgentKnowledgeDocument
|
|
6604
|
+
};
|
|
6605
|
+
|
|
3086
6606
|
// src/api/cms-api-handler.ts
|
|
6607
|
+
var KNOWLEDGE_SUFFIX = "knowledge";
|
|
6608
|
+
var CMS_API_LOG = "[cms-api]";
|
|
6609
|
+
function withLlmKnowledgeEntityFallbacks(base) {
|
|
6610
|
+
const keys = [
|
|
6611
|
+
"llm_agents",
|
|
6612
|
+
"llm_agent_knowledge_documents",
|
|
6613
|
+
"knowledge_base_documents",
|
|
6614
|
+
"knowledge_base_chunks"
|
|
6615
|
+
];
|
|
6616
|
+
const patch = {};
|
|
6617
|
+
for (const key of keys) {
|
|
6618
|
+
if (!(key in base) || base[key] == null) {
|
|
6619
|
+
const fallback = CMS_ENTITY_MAP[key];
|
|
6620
|
+
if (fallback) patch[key] = fallback;
|
|
6621
|
+
}
|
|
6622
|
+
}
|
|
6623
|
+
const merged = Object.keys(patch).length > 0 ? { ...base, ...patch } : base;
|
|
6624
|
+
if (!merged.llm_agents) {
|
|
6625
|
+
const agent = CMS_ENTITY_MAP.llm_agents ?? LlmAgent;
|
|
6626
|
+
return { ...merged, llm_agents: agent };
|
|
6627
|
+
}
|
|
6628
|
+
return merged;
|
|
6629
|
+
}
|
|
6630
|
+
function matchLlmAgentKnowledgeRoute(path) {
|
|
6631
|
+
const p = path[0] === "api" ? path.slice(1) : path;
|
|
6632
|
+
if (p[0] !== "llm_agents" || p.length < 2) return null;
|
|
6633
|
+
const seg1 = p[1];
|
|
6634
|
+
if (!seg1) return null;
|
|
6635
|
+
if (p[2] === KNOWLEDGE_SUFFIX) {
|
|
6636
|
+
return {
|
|
6637
|
+
slug: seg1,
|
|
6638
|
+
documentId: p.length >= 4 ? p[3] : void 0
|
|
6639
|
+
};
|
|
6640
|
+
}
|
|
6641
|
+
if (seg1.endsWith(KNOWLEDGE_SUFFIX) && seg1.length > KNOWLEDGE_SUFFIX.length) {
|
|
6642
|
+
const slug = seg1.slice(0, -KNOWLEDGE_SUFFIX.length);
|
|
6643
|
+
if (!slug) return null;
|
|
6644
|
+
if (p.length === 2) return { slug, documentId: void 0 };
|
|
6645
|
+
if (p.length === 3) return { slug, documentId: p[2] };
|
|
6646
|
+
}
|
|
6647
|
+
return null;
|
|
6648
|
+
}
|
|
3087
6649
|
var DEFAULT_EXCLUDE = /* @__PURE__ */ new Set([
|
|
3088
6650
|
"users",
|
|
3089
6651
|
"password_reset_tokens",
|
|
@@ -3096,14 +6658,15 @@ var DEFAULT_EXCLUDE = /* @__PURE__ */ new Set([
|
|
|
3096
6658
|
"cart_items",
|
|
3097
6659
|
"wishlists",
|
|
3098
6660
|
"wishlist_items",
|
|
3099
|
-
"message_templates"
|
|
6661
|
+
"message_templates",
|
|
6662
|
+
"llm_agent_knowledge_documents"
|
|
3100
6663
|
]);
|
|
3101
6664
|
function createCmsApiHandler(config) {
|
|
3102
6665
|
const {
|
|
3103
6666
|
dataSource,
|
|
3104
|
-
entityMap,
|
|
6667
|
+
entityMap: rawEntityMap,
|
|
3105
6668
|
pathToModel = (s) => s,
|
|
3106
|
-
crudResources
|
|
6669
|
+
crudResources: crudResourcesOverride,
|
|
3107
6670
|
getCms,
|
|
3108
6671
|
userAuth: userAuthConfig,
|
|
3109
6672
|
dashboard,
|
|
@@ -3120,9 +6683,13 @@ function createCmsApiHandler(config) {
|
|
|
3120
6683
|
userProfile,
|
|
3121
6684
|
settings: settingsConfig,
|
|
3122
6685
|
chat: chatConfig,
|
|
6686
|
+
llmAgentKnowledge: llmAgentKnowledgeConfig,
|
|
3123
6687
|
requireEntityPermission: userRequireEntityPermission,
|
|
3124
6688
|
getSessionUser
|
|
3125
6689
|
} = config;
|
|
6690
|
+
const entityMap = withLlmKnowledgeEntityFallbacks(rawEntityMap);
|
|
6691
|
+
const baseCrudResources = crudResourcesOverride ?? Object.keys(entityMap).filter((k) => !DEFAULT_EXCLUDE.has(k));
|
|
6692
|
+
const crudResources = entityMap.llm_agents && !baseCrudResources.includes("llm_agents") ? [...baseCrudResources, "llm_agents"] : baseCrudResources;
|
|
3126
6693
|
const requireEntityPermissionEffective = userRequireEntityPermission ?? (async (_req, entity, action) => config.json({ error: "Forbidden", reason: "entity_rbac_required", entity, action }, { status: 403 }));
|
|
3127
6694
|
const analytics = analyticsConfig ?? (getCms ? {
|
|
3128
6695
|
json: config.json,
|
|
@@ -3227,12 +6794,25 @@ function createCmsApiHandler(config) {
|
|
|
3227
6794
|
requireEntityPermission: requireEntityPermissionEffective
|
|
3228
6795
|
});
|
|
3229
6796
|
const chatHandlers = chatConfig ? createChatHandlers(chatConfig) : null;
|
|
6797
|
+
const llmAgentKnowledgeMerged = llmAgentKnowledgeConfig ?? (chatConfig ? {
|
|
6798
|
+
dataSource: chatConfig.dataSource,
|
|
6799
|
+
entityMap: withLlmKnowledgeEntityFallbacks(chatConfig.entityMap ?? rawEntityMap),
|
|
6800
|
+
getCms: chatConfig.getCms,
|
|
6801
|
+
json: chatConfig.json,
|
|
6802
|
+
requireAuth: chatConfig.requireAuth
|
|
6803
|
+
} : void 0);
|
|
6804
|
+
const llmAgentKnowledgeHandlers = llmAgentKnowledgeMerged ? createLlmAgentKnowledgeHandlers({
|
|
6805
|
+
...llmAgentKnowledgeMerged,
|
|
6806
|
+
requireEntityPermission: requireEntityPermissionEffective
|
|
6807
|
+
}) : null;
|
|
3230
6808
|
function resolveResource(segment) {
|
|
3231
6809
|
const model = pathToModel(segment);
|
|
3232
6810
|
return crudResources.includes(model) ? model : segment;
|
|
3233
6811
|
}
|
|
3234
6812
|
return {
|
|
3235
|
-
async handle(method,
|
|
6813
|
+
async handle(method, pathInput, req) {
|
|
6814
|
+
const m = typeof method === "string" ? method.toUpperCase() : "GET";
|
|
6815
|
+
const path = pathInput.length > 0 && pathInput[0] === "api" ? pathInput.slice(1) : pathInput;
|
|
3236
6816
|
async function analyticsGate() {
|
|
3237
6817
|
const a = await config.requireAuth(req);
|
|
3238
6818
|
if (a) return a;
|
|
@@ -3240,86 +6820,86 @@ function createCmsApiHandler(config) {
|
|
|
3240
6820
|
}
|
|
3241
6821
|
if (path[0] === "admin" && path[1] === "roles") {
|
|
3242
6822
|
if (!adminRoles) return config.json({ error: "Not found" }, { status: 404 });
|
|
3243
|
-
if (path.length === 2 &&
|
|
3244
|
-
if (path.length === 2 &&
|
|
3245
|
-
if (path.length === 3 &&
|
|
3246
|
-
if (path.length === 3 &&
|
|
3247
|
-
if (path.length === 4 && path[3] === "permissions" &&
|
|
6823
|
+
if (path.length === 2 && m === "GET") return adminRoles.list();
|
|
6824
|
+
if (path.length === 2 && m === "POST") return adminRoles.createGroup(req);
|
|
6825
|
+
if (path.length === 3 && m === "PATCH") return adminRoles.patchGroup(req, path[2]);
|
|
6826
|
+
if (path.length === 3 && m === "DELETE") return adminRoles.deleteGroup(path[2]);
|
|
6827
|
+
if (path.length === 4 && path[3] === "permissions" && m === "PUT") return adminRoles.putPermissions(req, path[2]);
|
|
3248
6828
|
return config.json({ error: "Not found" }, { status: 404 });
|
|
3249
6829
|
}
|
|
3250
|
-
if (path[0] === "dashboard" && path[1] === "stats" && path.length === 2 &&
|
|
6830
|
+
if (path[0] === "dashboard" && path[1] === "stats" && path.length === 2 && m === "GET" && dashboardGet) {
|
|
3251
6831
|
return dashboardGet(req);
|
|
3252
6832
|
}
|
|
3253
|
-
if (path[0] === "dashboard" && path[1] === "ecommerce" && path.length === 2 &&
|
|
6833
|
+
if (path[0] === "dashboard" && path[1] === "ecommerce" && path.length === 2 && m === "GET" && ecommerceAnalyticsGet) {
|
|
3254
6834
|
const g = await analyticsGate();
|
|
3255
6835
|
if (g) return g;
|
|
3256
6836
|
return ecommerceAnalyticsGet(req);
|
|
3257
6837
|
}
|
|
3258
6838
|
if (path[0] === "analytics" && analyticsHandlers) {
|
|
3259
|
-
if (path.length === 1 &&
|
|
6839
|
+
if (path.length === 1 && m === "GET") {
|
|
3260
6840
|
const g = await analyticsGate();
|
|
3261
6841
|
if (g) return g;
|
|
3262
6842
|
return analyticsHandlers.GET(req);
|
|
3263
6843
|
}
|
|
3264
|
-
if (path.length === 2 && path[1] === "property-id" &&
|
|
6844
|
+
if (path.length === 2 && path[1] === "property-id" && m === "GET") {
|
|
3265
6845
|
const g = await analyticsGate();
|
|
3266
6846
|
if (g) return g;
|
|
3267
6847
|
return analyticsHandlers.propertyId();
|
|
3268
6848
|
}
|
|
3269
|
-
if (path.length === 2 && path[1] === "permissions" &&
|
|
6849
|
+
if (path.length === 2 && path[1] === "permissions" && m === "GET") {
|
|
3270
6850
|
const g = await analyticsGate();
|
|
3271
6851
|
if (g) return g;
|
|
3272
6852
|
return analyticsHandlers.permissions();
|
|
3273
6853
|
}
|
|
3274
6854
|
}
|
|
3275
|
-
if (path[0] === "upload" && path.length === 1 &&
|
|
3276
|
-
if (path[0] === "media" && path[1] === "extract" && path.length === 3 &&
|
|
6855
|
+
if (path[0] === "upload" && path.length === 1 && m === "POST" && uploadPost) return uploadPost(req);
|
|
6856
|
+
if (path[0] === "media" && path[1] === "extract" && path.length === 3 && m === "POST" && zipExtractPost) {
|
|
3277
6857
|
return zipExtractPost(req, path[2]);
|
|
3278
6858
|
}
|
|
3279
|
-
if (path[0] === "blogs" && path[1] === "slug" && path.length === 3 &&
|
|
6859
|
+
if (path[0] === "blogs" && path[1] === "slug" && path.length === 3 && m === "GET" && blogBySlugGet) {
|
|
3280
6860
|
return blogBySlugGet(req, path[2]);
|
|
3281
6861
|
}
|
|
3282
|
-
if (path[0] === "forms" && path[1] === "slug" && path.length === 3 &&
|
|
6862
|
+
if (path[0] === "forms" && path[1] === "slug" && path.length === 3 && m === "GET" && formBySlugGet) {
|
|
3283
6863
|
return formBySlugGet(req, path[2]);
|
|
3284
6864
|
}
|
|
3285
6865
|
if (path[0] === "form-submissions") {
|
|
3286
6866
|
if (path.length === 1) {
|
|
3287
|
-
if (
|
|
3288
|
-
if (
|
|
6867
|
+
if (m === "GET" && formSubmissionList) return formSubmissionList(req);
|
|
6868
|
+
if (m === "POST" && formSubmissionPost) return formSubmissionPost(req);
|
|
3289
6869
|
}
|
|
3290
|
-
if (path.length === 2 &&
|
|
6870
|
+
if (path.length === 2 && m === "GET" && formSubmissionGetById) return formSubmissionGetById(req, path[1]);
|
|
3291
6871
|
}
|
|
3292
6872
|
if (path[0] === "forms" && formSaveHandlers) {
|
|
3293
|
-
if (path.length === 1 &&
|
|
6873
|
+
if (path.length === 1 && m === "POST") return formSaveHandlers.POST(req);
|
|
3294
6874
|
if (path.length === 2) {
|
|
3295
|
-
if (
|
|
3296
|
-
if (
|
|
6875
|
+
if (m === "GET") return formSaveHandlers.GET(req, path[1]);
|
|
6876
|
+
if (m === "PUT" || m === "PATCH") return formSaveHandlers.PUT(req, path[1]);
|
|
3297
6877
|
}
|
|
3298
6878
|
}
|
|
3299
6879
|
if (path[0] === "users" && usersHandlers) {
|
|
3300
6880
|
if (path.length === 1) {
|
|
3301
|
-
if (
|
|
3302
|
-
if (
|
|
6881
|
+
if (m === "GET") return usersHandlers.list(req);
|
|
6882
|
+
if (m === "POST") return usersHandlers.create(req);
|
|
3303
6883
|
}
|
|
3304
6884
|
if (path.length === 2) {
|
|
3305
|
-
if (path[1] === "avatar" &&
|
|
3306
|
-
if (path[1] === "profile" &&
|
|
6885
|
+
if (path[1] === "avatar" && m === "POST" && avatarPost) return avatarPost(req);
|
|
6886
|
+
if (path[1] === "profile" && m === "PUT" && profilePut) return profilePut(req);
|
|
3307
6887
|
const id = path[1];
|
|
3308
|
-
if (
|
|
3309
|
-
if (
|
|
3310
|
-
if (
|
|
6888
|
+
if (m === "GET") return usersHandlers.getById(req, id);
|
|
6889
|
+
if (m === "PUT" || m === "PATCH") return usersHandlers.update(req, id);
|
|
6890
|
+
if (m === "DELETE") return usersHandlers.delete(req, id);
|
|
3311
6891
|
}
|
|
3312
|
-
if (path.length === 3 && path[2] === "regenerate-invite" &&
|
|
6892
|
+
if (path.length === 3 && path[2] === "regenerate-invite" && m === "POST") {
|
|
3313
6893
|
return usersHandlers.regenerateInvite(req, path[1]);
|
|
3314
6894
|
}
|
|
3315
6895
|
}
|
|
3316
|
-
if (path[0] === "users" && path.length === 2 && userAuthRouter &&
|
|
6896
|
+
if (path[0] === "users" && path.length === 2 && userAuthRouter && m === "POST") {
|
|
3317
6897
|
return userAuthRouter.POST(req, path[1]);
|
|
3318
6898
|
}
|
|
3319
6899
|
if (path[0] === "settings" && path.length === 2 && settingsHandlers) {
|
|
3320
6900
|
const group = path[1];
|
|
3321
6901
|
const isPublic = settingsConfig?.publicGetGroups?.includes(group);
|
|
3322
|
-
if (
|
|
6902
|
+
if (m === "GET") {
|
|
3323
6903
|
if (!isPublic) {
|
|
3324
6904
|
const a = await config.requireAuth(req);
|
|
3325
6905
|
if (a) return a;
|
|
@@ -3328,22 +6908,70 @@ function createCmsApiHandler(config) {
|
|
|
3328
6908
|
}
|
|
3329
6909
|
return settingsHandlers.GET(req, group);
|
|
3330
6910
|
}
|
|
3331
|
-
if (
|
|
6911
|
+
if (m === "PUT") {
|
|
3332
6912
|
const pe = await requireEntityPermissionEffective(req, "settings", "update");
|
|
3333
6913
|
if (pe) return pe;
|
|
3334
6914
|
return settingsHandlers.PUT(req, group);
|
|
3335
6915
|
}
|
|
3336
6916
|
}
|
|
3337
6917
|
if (path[0] === "message-templates" && path[1] === "sms" && path.length === 2) {
|
|
3338
|
-
if (
|
|
3339
|
-
if (
|
|
6918
|
+
if (m === "GET") return smsMessageTemplateHandlers.GET(req);
|
|
6919
|
+
if (m === "PUT") return smsMessageTemplateHandlers.PUT(req);
|
|
6920
|
+
}
|
|
6921
|
+
if (path[0] === "llm_agents") {
|
|
6922
|
+
if (!entityMap.llm_agents) {
|
|
6923
|
+
console.error(CMS_API_LOG, "llm_agents route: entity missing after merge", {
|
|
6924
|
+
method: m,
|
|
6925
|
+
pathJoined: path.join("/"),
|
|
6926
|
+
entityMapKeyCount: Object.keys(entityMap).length
|
|
6927
|
+
});
|
|
6928
|
+
return config.json(
|
|
6929
|
+
{ error: "LlmAgent entity is not registered", hint: "Ensure migrations ran and entities include LlmAgent." },
|
|
6930
|
+
{ status: 503 }
|
|
6931
|
+
);
|
|
6932
|
+
}
|
|
6933
|
+
if (path.length === 1) {
|
|
6934
|
+
if (m === "GET") return crud.GET(req, "llm_agents");
|
|
6935
|
+
if (m === "POST") return crud.POST(req, "llm_agents");
|
|
6936
|
+
}
|
|
6937
|
+
if (path.length === 2 && !path[1]?.includes("knowledge")) {
|
|
6938
|
+
const id = path[1];
|
|
6939
|
+
if (m === "GET") return crudById.GET(req, "llm_agents", id);
|
|
6940
|
+
if (m === "PUT" || m === "PATCH") return crudById.PUT(req, "llm_agents", id);
|
|
6941
|
+
if (m === "DELETE") return crudById.DELETE(req, "llm_agents", id);
|
|
6942
|
+
}
|
|
6943
|
+
}
|
|
6944
|
+
{
|
|
6945
|
+
const kbMatch = matchLlmAgentKnowledgeRoute(path);
|
|
6946
|
+
if (kbMatch) {
|
|
6947
|
+
if (!llmAgentKnowledgeHandlers) {
|
|
6948
|
+
return config.json(
|
|
6949
|
+
{
|
|
6950
|
+
error: "LLM agent knowledge is not available",
|
|
6951
|
+
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."
|
|
6952
|
+
},
|
|
6953
|
+
{ status: 503 }
|
|
6954
|
+
);
|
|
6955
|
+
}
|
|
6956
|
+
const { slug, documentId } = kbMatch;
|
|
6957
|
+
if (m === "DELETE" && documentId != null && documentId !== "") {
|
|
6958
|
+
return llmAgentKnowledgeHandlers.unlink(req, slug, documentId);
|
|
6959
|
+
}
|
|
6960
|
+
if (m === "GET" && (documentId == null || documentId === "")) {
|
|
6961
|
+
return llmAgentKnowledgeHandlers.list(req, slug);
|
|
6962
|
+
}
|
|
6963
|
+
if (m === "POST" && (documentId == null || documentId === "")) {
|
|
6964
|
+
return llmAgentKnowledgeHandlers.post(req, slug);
|
|
6965
|
+
}
|
|
6966
|
+
}
|
|
3340
6967
|
}
|
|
3341
6968
|
if (path[0] === "chat" && chatHandlers) {
|
|
3342
|
-
if (path.length === 2 && path[1] === "
|
|
3343
|
-
if (path.length ===
|
|
3344
|
-
if (path.length ===
|
|
6969
|
+
if (path.length === 2 && path[1] === "config" && m === "GET") return chatHandlers.publicConfig(req);
|
|
6970
|
+
if (path.length === 2 && path[1] === "identify" && m === "POST") return chatHandlers.identify(req);
|
|
6971
|
+
if (path.length === 4 && path[1] === "conversations" && path[3] === "messages" && m === "GET") return chatHandlers.getMessages(req, path[2]);
|
|
6972
|
+
if (path.length === 2 && path[1] === "messages" && m === "POST") return chatHandlers.postMessage(req);
|
|
3345
6973
|
}
|
|
3346
|
-
if (path[0] === "orders" && path.length === 3 && path[2] === "invoice" &&
|
|
6974
|
+
if (path[0] === "orders" && path.length === 3 && path[2] === "invoice" && m === "GET" && getCms) {
|
|
3347
6975
|
const a = await config.requireAuth(req);
|
|
3348
6976
|
if (a) return a;
|
|
3349
6977
|
const pe = await requireEntityPermissionEffective(req, "orders", "read");
|
|
@@ -3357,17 +6985,17 @@ function createCmsApiHandler(config) {
|
|
|
3357
6985
|
if (path[0] === "orders" && path.length === 3 && path[2] === "repost-erp" && getCms) {
|
|
3358
6986
|
const a = await config.requireAuth(req);
|
|
3359
6987
|
if (a) return a;
|
|
3360
|
-
const pe = await requireEntityPermissionEffective(req, "orders",
|
|
6988
|
+
const pe = await requireEntityPermissionEffective(req, "orders", m === "GET" ? "read" : "update");
|
|
3361
6989
|
if (pe) return pe;
|
|
3362
6990
|
const oid = Number(path[1]);
|
|
3363
6991
|
if (!Number.isFinite(oid)) return config.json({ error: "Invalid id" }, { status: 400 });
|
|
3364
6992
|
const cms = await getCms();
|
|
3365
6993
|
const { isErpIntegrationEnabled: isErpIntegrationEnabled3 } = await Promise.resolve().then(() => (init_erp_config_enabled(), erp_config_enabled_exports));
|
|
3366
6994
|
const enabled = await isErpIntegrationEnabled3(cms, dataSource, entityMap);
|
|
3367
|
-
if (
|
|
6995
|
+
if (m === "GET") {
|
|
3368
6996
|
return config.json({ enabled });
|
|
3369
6997
|
}
|
|
3370
|
-
if (
|
|
6998
|
+
if (m === "POST") {
|
|
3371
6999
|
if (!enabled) return config.json({ error: "ERP integration is disabled" }, { status: 409 });
|
|
3372
7000
|
const { queueErpPaidOrderForOrderId: queueErpPaidOrderForOrderId2 } = await Promise.resolve().then(() => (init_paid_order_erp(), paid_order_erp_exports));
|
|
3373
7001
|
await queueErpPaidOrderForOrderId2(cms, dataSource, entityMap, oid);
|
|
@@ -3377,28 +7005,39 @@ function createCmsApiHandler(config) {
|
|
|
3377
7005
|
}
|
|
3378
7006
|
if (path.length === 0) return config.json({ error: "Not found" }, { status: 404 });
|
|
3379
7007
|
const resource = resolveResource(path[0]);
|
|
3380
|
-
if (!crudResources.includes(resource))
|
|
7008
|
+
if (!crudResources.includes(resource)) {
|
|
7009
|
+
console.warn(CMS_API_LOG, "generic CRUD gate: Invalid resource (not in crudResources)", {
|
|
7010
|
+
method: m,
|
|
7011
|
+
pathJoined: path.join("/"),
|
|
7012
|
+
pathSegments: path,
|
|
7013
|
+
resource,
|
|
7014
|
+
hasLlmAgentsEntity: Boolean(entityMap.llm_agents),
|
|
7015
|
+
crudResourcesHasResource: crudResources.includes(resource),
|
|
7016
|
+
crudResourcesLength: crudResources.length
|
|
7017
|
+
});
|
|
7018
|
+
return config.json({ error: "Invalid resource" }, { status: 400 });
|
|
7019
|
+
}
|
|
3381
7020
|
if (path.length === 2) {
|
|
3382
|
-
if (path[1] === "metadata" &&
|
|
7021
|
+
if (path[1] === "metadata" && m === "GET") {
|
|
3383
7022
|
return crud.GET_METADATA(req, resource);
|
|
3384
7023
|
}
|
|
3385
|
-
if (path[1] === "bulk" &&
|
|
7024
|
+
if (path[1] === "bulk" && m === "POST") {
|
|
3386
7025
|
return crud.BULK_POST(req, resource);
|
|
3387
7026
|
}
|
|
3388
|
-
if (path[1] === "export" &&
|
|
7027
|
+
if (path[1] === "export" && m === "GET") {
|
|
3389
7028
|
return crud.GET_EXPORT(req, resource);
|
|
3390
7029
|
}
|
|
3391
7030
|
}
|
|
3392
7031
|
if (path.length === 1) {
|
|
3393
|
-
if (
|
|
3394
|
-
if (
|
|
7032
|
+
if (m === "GET") return crud.GET(req, resource);
|
|
7033
|
+
if (m === "POST") return crud.POST(req, resource);
|
|
3395
7034
|
return config.json({ error: "Method not allowed" }, { status: 405 });
|
|
3396
7035
|
}
|
|
3397
7036
|
if (path.length === 2) {
|
|
3398
7037
|
const id = path[1];
|
|
3399
|
-
if (
|
|
3400
|
-
if (
|
|
3401
|
-
if (
|
|
7038
|
+
if (m === "GET") return crudById.GET(req, resource, id);
|
|
7039
|
+
if (m === "PUT" || m === "PATCH") return crudById.PUT(req, resource, id);
|
|
7040
|
+
if (m === "DELETE") return crudById.DELETE(req, resource, id);
|
|
3402
7041
|
return config.json({ error: "Method not allowed" }, { status: 405 });
|
|
3403
7042
|
}
|
|
3404
7043
|
return config.json({ error: "Not found" }, { status: 404 });
|
|
@@ -3407,7 +7046,7 @@ function createCmsApiHandler(config) {
|
|
|
3407
7046
|
}
|
|
3408
7047
|
|
|
3409
7048
|
// src/api/storefront-handlers.ts
|
|
3410
|
-
var
|
|
7049
|
+
var import_typeorm47 = require("typeorm");
|
|
3411
7050
|
|
|
3412
7051
|
// src/lib/is-valid-signup-email.ts
|
|
3413
7052
|
var MAX_EMAIL = 254;
|
|
@@ -3667,7 +7306,7 @@ async function queueSms(cms, payload) {
|
|
|
3667
7306
|
|
|
3668
7307
|
// src/lib/otp-challenge.ts
|
|
3669
7308
|
var import_crypto = require("crypto");
|
|
3670
|
-
var
|
|
7309
|
+
var import_typeorm46 = require("typeorm");
|
|
3671
7310
|
var OTP_TTL_MS = 10 * 60 * 1e3;
|
|
3672
7311
|
var MAX_SENDS_PER_HOUR = 5;
|
|
3673
7312
|
var MAX_VERIFY_ATTEMPTS = 8;
|
|
@@ -3701,7 +7340,7 @@ function normalizePhoneE164(raw, defaultCountryCode) {
|
|
|
3701
7340
|
async function countRecentOtpSends(dataSource, entityMap, purpose, identifier, since) {
|
|
3702
7341
|
const repo = dataSource.getRepository(entityMap.otp_challenges);
|
|
3703
7342
|
return repo.count({
|
|
3704
|
-
where: { purpose, identifier, createdAt: (0,
|
|
7343
|
+
where: { purpose, identifier, createdAt: (0, import_typeorm46.MoreThan)(since) }
|
|
3705
7344
|
});
|
|
3706
7345
|
}
|
|
3707
7346
|
async function createOtpChallenge(dataSource, entityMap, input) {
|
|
@@ -3715,7 +7354,7 @@ async function createOtpChallenge(dataSource, entityMap, input) {
|
|
|
3715
7354
|
await repo.delete({
|
|
3716
7355
|
purpose,
|
|
3717
7356
|
identifier,
|
|
3718
|
-
consumedAt: (0,
|
|
7357
|
+
consumedAt: (0, import_typeorm46.IsNull)()
|
|
3719
7358
|
});
|
|
3720
7359
|
const expiresAt = new Date(Date.now() + OTP_TTL_MS);
|
|
3721
7360
|
const codeHash = hashOtpCode(code, purpose, identifier, pepper);
|
|
@@ -3736,7 +7375,7 @@ async function verifyAndConsumeOtpChallenge(dataSource, entityMap, input) {
|
|
|
3736
7375
|
const { purpose, identifier, code, pepper } = input;
|
|
3737
7376
|
const repo = dataSource.getRepository(entityMap.otp_challenges);
|
|
3738
7377
|
const row = await repo.findOne({
|
|
3739
|
-
where: { purpose, identifier, consumedAt: (0,
|
|
7378
|
+
where: { purpose, identifier, consumedAt: (0, import_typeorm46.IsNull)() },
|
|
3740
7379
|
order: { id: "DESC" }
|
|
3741
7380
|
});
|
|
3742
7381
|
if (!row) {
|
|
@@ -3970,7 +7609,7 @@ function createStorefrontApiHandler(config) {
|
|
|
3970
7609
|
const u = await userRepo().findOne({ where: { id: userId } });
|
|
3971
7610
|
if (!u) return null;
|
|
3972
7611
|
const unclaimed = await contactRepo().findOne({
|
|
3973
|
-
where: { email: u.email, userId: (0,
|
|
7612
|
+
where: { email: u.email, userId: (0, import_typeorm47.IsNull)(), deleted: false }
|
|
3974
7613
|
});
|
|
3975
7614
|
if (unclaimed) {
|
|
3976
7615
|
await contactRepo().update(unclaimed.id, { userId });
|
|
@@ -5011,7 +8650,7 @@ function createStorefrontApiHandler(config) {
|
|
|
5011
8650
|
const previewByOrder = {};
|
|
5012
8651
|
if (orderIds.length) {
|
|
5013
8652
|
const oItems = await orderItemRepo().find({
|
|
5014
|
-
where: { orderId: (0,
|
|
8653
|
+
where: { orderId: (0, import_typeorm47.In)(orderIds) },
|
|
5015
8654
|
relations: ["product"],
|
|
5016
8655
|
order: { id: "ASC" }
|
|
5017
8656
|
});
|
|
@@ -5148,6 +8787,7 @@ function createStorefrontApiHandler(config) {
|
|
|
5148
8787
|
createForgotPasswordHandler,
|
|
5149
8788
|
createFormBySlugHandler,
|
|
5150
8789
|
createInviteAcceptHandler,
|
|
8790
|
+
createLlmAgentKnowledgeHandlers,
|
|
5151
8791
|
createMediaZipExtractHandler,
|
|
5152
8792
|
createSetPasswordHandler,
|
|
5153
8793
|
createSettingsApiHandlers,
|
|
@@ -5157,6 +8797,10 @@ function createStorefrontApiHandler(config) {
|
|
|
5157
8797
|
createUserAvatarHandler,
|
|
5158
8798
|
createUserProfileHandler,
|
|
5159
8799
|
createUsersApiHandlers,
|
|
5160
|
-
getPublicSettingsGroup
|
|
8800
|
+
getPublicSettingsGroup,
|
|
8801
|
+
mergeGuardrailsIntoSystemPrompt,
|
|
8802
|
+
parseLlmAgentValidationRules,
|
|
8803
|
+
validateUserMessageAgainstAgentRules,
|
|
8804
|
+
validateUserMessageAgainstStructuredRules
|
|
5161
8805
|
});
|
|
5162
8806
|
//# sourceMappingURL=api.cjs.map
|