@dyrected/core 2.13.0 → 2.13.3
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/LICENSE.md +50 -0
- package/dist/{app-D_ODsBWA.d.ts → app-De-3eNn1.d.cts} +6 -0
- package/dist/{app-D_ODsBWA.d.cts → app-De-3eNn1.d.ts} +6 -0
- package/dist/index.cjs +17 -0
- package/dist/index.d.cts +14 -3
- package/dist/index.d.ts +14 -3
- package/dist/index.js +5867 -368
- package/dist/server.cjs +37 -7
- package/dist/server.d.cts +2 -2
- package/dist/server.d.ts +2 -2
- package/dist/server.js +8487 -1033
- package/package.json +9 -9
- package/dist/access-P6Z2XAFS.js +0 -10
- package/dist/ai-X3M2SE5A.js +0 -17
- package/dist/ai-tools-UPKJY3TX.js +0 -14
- package/dist/chunk-254THFDS.js +0 -202
- package/dist/chunk-27YRIGK5.js +0 -1758
- package/dist/chunk-4RAQJVJM.js +0 -18
- package/dist/chunk-DZMBVIMN.js +0 -3910
- package/dist/chunk-HRRJ3RYT.js +0 -70
- package/dist/chunk-JSBRDJBE.js +0 -30
- package/dist/chunk-W7GKJM2X.js +0 -1136
- package/dist/chunk-ZYYDTHF3.js +0 -635
- package/dist/rag.service-YDGEYTXS.js +0 -11
- package/dist/where-sanitizer-CAAIYSSK.js +0 -76
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dyrected/core",
|
|
3
|
-
"version": "2.13.
|
|
3
|
+
"version": "2.13.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -20,12 +20,6 @@
|
|
|
20
20
|
"files": [
|
|
21
21
|
"dist"
|
|
22
22
|
],
|
|
23
|
-
"scripts": {
|
|
24
|
-
"build": "NODE_OPTIONS=--max-old-space-size=4096 tsup src/index.ts src/server.ts --format cjs,esm --dts",
|
|
25
|
-
"dev": "NODE_OPTIONS=--max-old-space-size=4096 tsup src/index.ts src/server.ts --format cjs,esm --watch --dts",
|
|
26
|
-
"lint": "eslint src/**/*.ts",
|
|
27
|
-
"test": "vitest"
|
|
28
|
-
},
|
|
29
23
|
"dependencies": {
|
|
30
24
|
"@ai-sdk/google": "^4.0.49",
|
|
31
25
|
"@ai-sdk/openai": "^4.0.50",
|
|
@@ -65,5 +59,11 @@
|
|
|
65
59
|
"publishConfig": {
|
|
66
60
|
"access": "public"
|
|
67
61
|
},
|
|
68
|
-
"description": "Core engine and schema handling for Dyrected CMS"
|
|
69
|
-
|
|
62
|
+
"description": "Core engine and schema handling for Dyrected CMS",
|
|
63
|
+
"scripts": {
|
|
64
|
+
"build": "NODE_OPTIONS=--max-old-space-size=4096 tsup src/index.ts src/server.ts --format cjs,esm --dts",
|
|
65
|
+
"dev": "NODE_OPTIONS=--max-old-space-size=4096 tsup src/index.ts src/server.ts --format cjs,esm --watch --dts",
|
|
66
|
+
"lint": "eslint src/**/*.ts",
|
|
67
|
+
"test": "vitest"
|
|
68
|
+
}
|
|
69
|
+
}
|
package/dist/access-P6Z2XAFS.js
DELETED
package/dist/ai-X3M2SE5A.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AI_ACTIONS_COLLECTION,
|
|
3
|
-
AI_AUDIT_COLLECTION,
|
|
4
|
-
AI_CHUNKS_COLLECTION,
|
|
5
|
-
AI_MESSAGES_COLLECTION,
|
|
6
|
-
AI_THREADS_COLLECTION,
|
|
7
|
-
isAICollection
|
|
8
|
-
} from "./chunk-4RAQJVJM.js";
|
|
9
|
-
import "./chunk-JSBRDJBE.js";
|
|
10
|
-
export {
|
|
11
|
-
AI_ACTIONS_COLLECTION,
|
|
12
|
-
AI_AUDIT_COLLECTION,
|
|
13
|
-
AI_CHUNKS_COLLECTION,
|
|
14
|
-
AI_MESSAGES_COLLECTION,
|
|
15
|
-
AI_THREADS_COLLECTION,
|
|
16
|
-
isAICollection
|
|
17
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createDyrectedAITools,
|
|
3
|
-
validatePayloadAgainstFields
|
|
4
|
-
} from "./chunk-W7GKJM2X.js";
|
|
5
|
-
import "./chunk-ZYYDTHF3.js";
|
|
6
|
-
import "./chunk-254THFDS.js";
|
|
7
|
-
import "./chunk-4RAQJVJM.js";
|
|
8
|
-
import "./chunk-HRRJ3RYT.js";
|
|
9
|
-
import "./chunk-27YRIGK5.js";
|
|
10
|
-
import "./chunk-JSBRDJBE.js";
|
|
11
|
-
export {
|
|
12
|
-
createDyrectedAITools,
|
|
13
|
-
validatePayloadAgainstFields
|
|
14
|
-
};
|
package/dist/chunk-254THFDS.js
DELETED
|
@@ -1,202 +0,0 @@
|
|
|
1
|
-
// src/utils/ai-pii.ts
|
|
2
|
-
var NON_NEGOTIABLE_CREDENTIAL_FIELDS = /* @__PURE__ */ new Set([
|
|
3
|
-
"password",
|
|
4
|
-
"salt",
|
|
5
|
-
"hash",
|
|
6
|
-
"resetPasswordToken",
|
|
7
|
-
"apiKey",
|
|
8
|
-
"token",
|
|
9
|
-
"secret",
|
|
10
|
-
"accessToken",
|
|
11
|
-
"refreshToken",
|
|
12
|
-
"privateKey",
|
|
13
|
-
"private_key",
|
|
14
|
-
"webhookSecret",
|
|
15
|
-
"webhook_secret",
|
|
16
|
-
"authSecret",
|
|
17
|
-
"auth_secret",
|
|
18
|
-
"cvv",
|
|
19
|
-
"cvc",
|
|
20
|
-
"pin"
|
|
21
|
-
]);
|
|
22
|
-
function maskEmail(email, strategy = "mask") {
|
|
23
|
-
if (!email || typeof email !== "string") return email;
|
|
24
|
-
if (strategy === "token") return "[REDACTED_EMAIL]";
|
|
25
|
-
const atIdx = email.indexOf("@");
|
|
26
|
-
if (atIdx <= 1) {
|
|
27
|
-
return "***@" + (email.slice(atIdx + 1) || "example.com");
|
|
28
|
-
}
|
|
29
|
-
const prefix = email[0];
|
|
30
|
-
const domain = email.slice(atIdx);
|
|
31
|
-
return `${prefix}***${domain}`;
|
|
32
|
-
}
|
|
33
|
-
function maskPhone(phone, strategy = "mask") {
|
|
34
|
-
if (!phone || typeof phone !== "string") return phone;
|
|
35
|
-
if (strategy === "token") return "[REDACTED_PHONE]";
|
|
36
|
-
const digits = phone.replace(/\D/g, "");
|
|
37
|
-
if (digits.length < 4) return "***-***-****";
|
|
38
|
-
const lastFour = digits.slice(-4);
|
|
39
|
-
return `***-***-${lastFour}`;
|
|
40
|
-
}
|
|
41
|
-
var PII_REGEX_PATTERNS = {
|
|
42
|
-
email: /[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g,
|
|
43
|
-
phone_number: /(?:\+?\d{1,3}[-\s]?)?\(?\d{3}\)?[-.\s]?\d{3}[-\s]?\d{4}\b/g,
|
|
44
|
-
phoneNumber: /(?:\+?\d{1,3}[-\s]?)?\(?\d{3}\)?[-.\s]?\d{3}[-\s]?\d{4}\b/g,
|
|
45
|
-
phone: /(?:\+?\d{1,3}[-\s]?)?\(?\d{3}\)?[-.\s]?\d{3}[-\s]?\d{4}\b/g,
|
|
46
|
-
credit_card: /\b(?:\d{4}[-\s]?){3}\d{4}\b/g,
|
|
47
|
-
ssn: /\b\d{3}-\d{2}-\d{4}\b/g,
|
|
48
|
-
ipv4: /\b(?:\d{1,3}\.){3}\d{1,3}\b/g,
|
|
49
|
-
ipv6: /(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|(?:[0-9a-fA-F]{1,4}:){1,7}:|(?:[0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}/g,
|
|
50
|
-
iban: /\b[A-Z]{2}\d{2}[A-Z0-9]{4}\d{7}([A-Z0-9]?){0,16}\b/g,
|
|
51
|
-
api_key: /\b(?:sk_(?:live|test)_[0-9a-zA-Z_]{16,}|ghp_[0-9a-zA-Z_]{20,}|AKIA[0-9A-Z]{16})\b/g,
|
|
52
|
-
jwt: /\beyJ[a-zA-Z0-9_-]+\.eyJ[a-zA-Z0-9_-]+\.[a-zA-Z0-9_-]+\b/g,
|
|
53
|
-
passport: /\b[A-Z]{1,2}[0-9]{6,9}\b/g
|
|
54
|
-
};
|
|
55
|
-
var PII_PATTERN_PRIORITY = {
|
|
56
|
-
api_key: 1,
|
|
57
|
-
jwt: 2,
|
|
58
|
-
iban: 3,
|
|
59
|
-
credit_card: 4,
|
|
60
|
-
ipv6: 5,
|
|
61
|
-
ipv4: 6,
|
|
62
|
-
email: 7,
|
|
63
|
-
passport: 8,
|
|
64
|
-
ssn: 9,
|
|
65
|
-
phone: 10,
|
|
66
|
-
phone_number: 10,
|
|
67
|
-
phoneNumber: 10
|
|
68
|
-
};
|
|
69
|
-
function maskTextPII(text, piiConfig) {
|
|
70
|
-
if (!text || typeof text !== "string") return text;
|
|
71
|
-
if (!piiConfig || piiConfig.enabled === false) return text;
|
|
72
|
-
let result = text;
|
|
73
|
-
const strategy = piiConfig.strategy || "mask";
|
|
74
|
-
const rawPatterns = piiConfig.patterns || [
|
|
75
|
-
"email",
|
|
76
|
-
"phone",
|
|
77
|
-
"phone_number",
|
|
78
|
-
"phoneNumber",
|
|
79
|
-
"ssn",
|
|
80
|
-
"credit_card",
|
|
81
|
-
"ipv4"
|
|
82
|
-
];
|
|
83
|
-
const patterns = [...rawPatterns].sort(
|
|
84
|
-
(a, b) => (PII_PATTERN_PRIORITY[a] ?? 99) - (PII_PATTERN_PRIORITY[b] ?? 99)
|
|
85
|
-
);
|
|
86
|
-
for (const patternName of patterns) {
|
|
87
|
-
const regex = PII_REGEX_PATTERNS[patternName];
|
|
88
|
-
if (!regex) continue;
|
|
89
|
-
result = result.replace(regex, (match) => {
|
|
90
|
-
switch (patternName) {
|
|
91
|
-
case "email":
|
|
92
|
-
return maskEmail(match, strategy);
|
|
93
|
-
case "phone":
|
|
94
|
-
case "phone_number":
|
|
95
|
-
case "phoneNumber":
|
|
96
|
-
return maskPhone(match, strategy);
|
|
97
|
-
case "credit_card":
|
|
98
|
-
return strategy === "token" ? "[REDACTED_CREDIT_CARD]" : "****-****-****-" + match.replace(/\D/g, "").slice(-4);
|
|
99
|
-
case "ssn":
|
|
100
|
-
return strategy === "token" ? "[REDACTED_SSN]" : "***-**-" + match.replace(/\D/g, "").slice(-4);
|
|
101
|
-
case "ipv4":
|
|
102
|
-
return "[REDACTED_IP]";
|
|
103
|
-
case "ipv6":
|
|
104
|
-
return "[REDACTED_IPV6]";
|
|
105
|
-
case "iban":
|
|
106
|
-
return strategy === "token" ? "[REDACTED_IBAN]" : "****-****-" + match.replace(/\s/g, "").slice(-4);
|
|
107
|
-
case "api_key":
|
|
108
|
-
return "[REDACTED_API_KEY]";
|
|
109
|
-
case "jwt":
|
|
110
|
-
return "[REDACTED_JWT]";
|
|
111
|
-
case "passport":
|
|
112
|
-
return strategy === "token" ? "[REDACTED_PASSPORT]" : "***" + match.slice(-3);
|
|
113
|
-
default:
|
|
114
|
-
return "[REDACTED]";
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
}
|
|
118
|
-
if (typeof piiConfig.customScrubber === "function") {
|
|
119
|
-
result = piiConfig.customScrubber(result);
|
|
120
|
-
}
|
|
121
|
-
return result;
|
|
122
|
-
}
|
|
123
|
-
function sanitizeDocForAI(options) {
|
|
124
|
-
const { doc, collectionConfig, globalAIConfig } = options;
|
|
125
|
-
if (!doc || typeof doc !== "object") return doc;
|
|
126
|
-
const copy = { ...doc };
|
|
127
|
-
for (const cred of NON_NEGOTIABLE_CREDENTIAL_FIELDS) {
|
|
128
|
-
delete copy[cred];
|
|
129
|
-
}
|
|
130
|
-
if (collectionConfig?.ai?.excludeFields) {
|
|
131
|
-
for (const field of collectionConfig.ai.excludeFields) {
|
|
132
|
-
delete copy[field];
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
const fields = collectionConfig?.fields || [];
|
|
136
|
-
for (const field of fields) {
|
|
137
|
-
const fieldName = field.name;
|
|
138
|
-
if (!fieldName || copy[fieldName] === void 0) continue;
|
|
139
|
-
if (field.ai?.exclude === true) {
|
|
140
|
-
delete copy[fieldName];
|
|
141
|
-
continue;
|
|
142
|
-
}
|
|
143
|
-
const val = copy[fieldName];
|
|
144
|
-
const normalizedName = fieldName.toLowerCase().replace(/[_\s-]/g, "");
|
|
145
|
-
const isEmail = field.type === "email" || normalizedName.includes("email");
|
|
146
|
-
const isPhone = field.type === "phone" || normalizedName.includes("phone") || normalizedName === "tel" || normalizedName === "telephone" || normalizedName === "mobile" || normalizedName === "cell";
|
|
147
|
-
if (isEmail) {
|
|
148
|
-
if (globalAIConfig?.pii?.enabled !== false && field.ai?.allowRaw !== true && typeof val === "string") {
|
|
149
|
-
copy[fieldName] = maskEmail(val, globalAIConfig?.pii?.strategy);
|
|
150
|
-
}
|
|
151
|
-
continue;
|
|
152
|
-
}
|
|
153
|
-
if (isPhone) {
|
|
154
|
-
if (globalAIConfig?.pii?.enabled !== false && field.ai?.allowRaw !== true && typeof val === "string") {
|
|
155
|
-
copy[fieldName] = maskPhone(val, globalAIConfig?.pii?.strategy);
|
|
156
|
-
}
|
|
157
|
-
continue;
|
|
158
|
-
}
|
|
159
|
-
if (field.ai?.redact === true || field.ai?.redact === "mask") {
|
|
160
|
-
if (typeof val === "string") {
|
|
161
|
-
copy[fieldName] = "[REDACTED]";
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
if (collectionConfig?.ai?.redactFields) {
|
|
166
|
-
for (const field of collectionConfig.ai.redactFields) {
|
|
167
|
-
if (copy[field] !== void 0) {
|
|
168
|
-
const val = copy[field];
|
|
169
|
-
if (typeof val === "string") {
|
|
170
|
-
if (field.toLowerCase().includes("email")) {
|
|
171
|
-
copy[field] = maskEmail(val, globalAIConfig?.pii?.strategy);
|
|
172
|
-
} else if (field.toLowerCase().includes("phone")) {
|
|
173
|
-
copy[field] = maskPhone(val, globalAIConfig?.pii?.strategy);
|
|
174
|
-
} else {
|
|
175
|
-
copy[field] = "[REDACTED]";
|
|
176
|
-
}
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
let result = copy;
|
|
182
|
-
if (typeof collectionConfig?.ai?.sanitizeDoc === "function") {
|
|
183
|
-
result = collectionConfig.ai.sanitizeDoc(copy);
|
|
184
|
-
}
|
|
185
|
-
if (globalAIConfig?.pii?.enabled === true) {
|
|
186
|
-
for (const [k, v] of Object.entries(result)) {
|
|
187
|
-
if (typeof v === "string") {
|
|
188
|
-
result[k] = maskTextPII(v, globalAIConfig.pii);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
return result;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
export {
|
|
196
|
-
NON_NEGOTIABLE_CREDENTIAL_FIELDS,
|
|
197
|
-
maskEmail,
|
|
198
|
-
maskPhone,
|
|
199
|
-
PII_REGEX_PATTERNS,
|
|
200
|
-
maskTextPII,
|
|
201
|
-
sanitizeDocForAI
|
|
202
|
-
};
|