@digilogiclabs/platform-core 1.2.0 → 1.3.0
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/README.md +583 -545
- package/dist/index.d.mts +608 -32
- package/dist/index.d.ts +608 -32
- package/dist/index.js +5063 -252
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +5043 -252
- package/dist/index.mjs.map +1 -1
- package/dist/migrate.js +88 -31
- package/dist/migrate.js.map +1 -1
- package/dist/migrations/index.js +33 -13
- package/dist/migrations/index.js.map +1 -1
- package/dist/migrations/index.mjs +33 -13
- package/dist/migrations/index.mjs.map +1 -1
- package/dist/testing.js +99 -23
- package/dist/testing.js.map +1 -1
- package/dist/testing.mjs +99 -23
- package/dist/testing.mjs.map +1 -1
- package/package.json +6 -1
package/dist/testing.mjs
CHANGED
|
@@ -1126,7 +1126,11 @@ var MemoryQueryBuilder = class {
|
|
|
1126
1126
|
const updated = [];
|
|
1127
1127
|
const newTable = table.map((item) => {
|
|
1128
1128
|
if (this.matchesWhere(item)) {
|
|
1129
|
-
const updatedItem = {
|
|
1129
|
+
const updatedItem = {
|
|
1130
|
+
...item,
|
|
1131
|
+
...this._updateData,
|
|
1132
|
+
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
1133
|
+
};
|
|
1130
1134
|
updated.push(updatedItem);
|
|
1131
1135
|
return updatedItem;
|
|
1132
1136
|
}
|
|
@@ -1141,8 +1145,10 @@ var MemoryQueryBuilder = class {
|
|
|
1141
1145
|
result.sort((a, b) => {
|
|
1142
1146
|
const aVal = a[column];
|
|
1143
1147
|
const bVal = b[column];
|
|
1144
|
-
if (aVal === null || aVal === void 0)
|
|
1145
|
-
|
|
1148
|
+
if (aVal === null || aVal === void 0)
|
|
1149
|
+
return direction === "asc" ? 1 : -1;
|
|
1150
|
+
if (bVal === null || bVal === void 0)
|
|
1151
|
+
return direction === "asc" ? -1 : 1;
|
|
1146
1152
|
const cmp = aVal < bVal ? -1 : aVal > bVal ? 1 : 0;
|
|
1147
1153
|
return direction === "asc" ? cmp : -cmp;
|
|
1148
1154
|
});
|
|
@@ -1223,7 +1229,9 @@ var MemoryCache = class {
|
|
|
1223
1229
|
return Promise.all(keys.map((key) => this.get(key)));
|
|
1224
1230
|
}
|
|
1225
1231
|
async mset(entries) {
|
|
1226
|
-
await Promise.all(
|
|
1232
|
+
await Promise.all(
|
|
1233
|
+
entries.map(({ key, value, ttl }) => this.set(key, value, ttl))
|
|
1234
|
+
);
|
|
1227
1235
|
}
|
|
1228
1236
|
async incr(key, by = 1) {
|
|
1229
1237
|
const current = await this.get(key) || 0;
|
|
@@ -1272,7 +1280,10 @@ var MemoryCache = class {
|
|
|
1272
1280
|
var MemoryStorage = class {
|
|
1273
1281
|
files = /* @__PURE__ */ new Map();
|
|
1274
1282
|
async upload(key, data, options) {
|
|
1275
|
-
this.files.set(key, {
|
|
1283
|
+
this.files.set(key, {
|
|
1284
|
+
data: Buffer.from("mock"),
|
|
1285
|
+
contentType: options?.contentType
|
|
1286
|
+
});
|
|
1276
1287
|
return { url: "memory://" + key };
|
|
1277
1288
|
}
|
|
1278
1289
|
async download(key) {
|
|
@@ -1982,7 +1993,9 @@ var ConsoleEmail = class {
|
|
|
1982
1993
|
console.log("=".repeat(60));
|
|
1983
1994
|
console.log(`ID: ${id}`);
|
|
1984
1995
|
console.log(`To: ${this.formatAddresses(message.to)}`);
|
|
1985
|
-
console.log(
|
|
1996
|
+
console.log(
|
|
1997
|
+
`From: ${message.from ? this.formatAddress(message.from) : "(default)"}`
|
|
1998
|
+
);
|
|
1986
1999
|
console.log(`Subject: ${message.subject}`);
|
|
1987
2000
|
if (message.replyTo) {
|
|
1988
2001
|
console.log(`Reply-To: ${this.formatAddress(message.replyTo)}`);
|
|
@@ -1991,15 +2004,21 @@ var ConsoleEmail = class {
|
|
|
1991
2004
|
console.log(`Tags: ${message.tags.join(", ")}`);
|
|
1992
2005
|
}
|
|
1993
2006
|
if (message.attachments && message.attachments.length > 0) {
|
|
1994
|
-
console.log(
|
|
2007
|
+
console.log(
|
|
2008
|
+
`Attachments: ${message.attachments.map((a) => a.filename).join(", ")}`
|
|
2009
|
+
);
|
|
1995
2010
|
}
|
|
1996
2011
|
console.log("-".repeat(60));
|
|
1997
2012
|
if (message.text) {
|
|
1998
2013
|
console.log("TEXT BODY:");
|
|
1999
|
-
console.log(
|
|
2014
|
+
console.log(
|
|
2015
|
+
message.text.slice(0, 500) + (message.text.length > 500 ? "\n...(truncated)" : "")
|
|
2016
|
+
);
|
|
2000
2017
|
}
|
|
2001
2018
|
if (message.html) {
|
|
2002
|
-
console.log(
|
|
2019
|
+
console.log(
|
|
2020
|
+
"HTML BODY: [HTML content - " + message.html.length + " chars]"
|
|
2021
|
+
);
|
|
2003
2022
|
}
|
|
2004
2023
|
console.log("=".repeat(60) + "\n");
|
|
2005
2024
|
this.sentEmails.push(message);
|
|
@@ -2267,14 +2286,34 @@ var MemorySecrets = class {
|
|
|
2267
2286
|
|
|
2268
2287
|
// src/config.ts
|
|
2269
2288
|
import { z } from "zod";
|
|
2270
|
-
var DatabaseProviderSchema = z.enum([
|
|
2289
|
+
var DatabaseProviderSchema = z.enum([
|
|
2290
|
+
"memory",
|
|
2291
|
+
"postgres",
|
|
2292
|
+
"supabase"
|
|
2293
|
+
]);
|
|
2271
2294
|
var CacheProviderSchema = z.enum(["memory", "redis", "upstash"]);
|
|
2272
|
-
var StorageProviderSchema = z.enum([
|
|
2273
|
-
|
|
2295
|
+
var StorageProviderSchema = z.enum([
|
|
2296
|
+
"memory",
|
|
2297
|
+
"s3",
|
|
2298
|
+
"minio",
|
|
2299
|
+
"r2",
|
|
2300
|
+
"supabase"
|
|
2301
|
+
]);
|
|
2302
|
+
var EmailProviderSchema = z.enum([
|
|
2303
|
+
"memory",
|
|
2304
|
+
"console",
|
|
2305
|
+
"smtp",
|
|
2306
|
+
"resend"
|
|
2307
|
+
]);
|
|
2274
2308
|
var QueueProviderSchema = z.enum(["memory", "bullmq"]);
|
|
2275
2309
|
var TracingProviderSchema = z.enum(["noop", "memory", "otlp"]);
|
|
2276
2310
|
var LogLevelSchema = z.enum(["debug", "info", "warn", "error"]);
|
|
2277
|
-
var AIProviderSchema = z.enum([
|
|
2311
|
+
var AIProviderSchema = z.enum([
|
|
2312
|
+
"memory",
|
|
2313
|
+
"openai",
|
|
2314
|
+
"anthropic",
|
|
2315
|
+
"google"
|
|
2316
|
+
]);
|
|
2278
2317
|
var RAGProviderSchema = z.enum(["memory", "pinecone", "weaviate"]);
|
|
2279
2318
|
var DatabaseConfigSchema = z.object({
|
|
2280
2319
|
provider: DatabaseProviderSchema.default("memory"),
|
|
@@ -2285,7 +2324,10 @@ var DatabaseConfigSchema = z.object({
|
|
|
2285
2324
|
supabaseServiceRoleKey: z.string().optional().describe("Supabase service role key"),
|
|
2286
2325
|
poolSize: z.number().int().min(1).max(100).default(10).describe("Connection pool size"),
|
|
2287
2326
|
connectionTimeout: z.number().int().min(1e3).max(6e4).default(5e3).describe("Connection timeout in ms"),
|
|
2288
|
-
ssl: z.union([
|
|
2327
|
+
ssl: z.union([
|
|
2328
|
+
z.boolean(),
|
|
2329
|
+
z.object({ rejectUnauthorized: z.boolean().optional() })
|
|
2330
|
+
]).optional().describe("SSL configuration")
|
|
2289
2331
|
}).refine(
|
|
2290
2332
|
(data) => {
|
|
2291
2333
|
if (data.provider === "supabase") {
|
|
@@ -2416,7 +2458,9 @@ var RAGConfigSchema = z.object({
|
|
|
2416
2458
|
indexName: z.string().optional().describe("Pinecone index name or Weaviate class"),
|
|
2417
2459
|
namespace: z.string().optional().describe("Default namespace"),
|
|
2418
2460
|
host: z.string().url().optional().describe("Weaviate host URL"),
|
|
2419
|
-
embeddingProvider: AIProviderSchema.default("memory").describe(
|
|
2461
|
+
embeddingProvider: AIProviderSchema.default("memory").describe(
|
|
2462
|
+
"Provider for generating embeddings"
|
|
2463
|
+
),
|
|
2420
2464
|
embeddingApiKey: z.string().optional().describe("API key for embedding provider"),
|
|
2421
2465
|
embeddingModel: z.string().optional().describe("Model for generating embeddings")
|
|
2422
2466
|
}).refine(
|
|
@@ -3202,7 +3246,18 @@ function createPlatform(config) {
|
|
|
3202
3246
|
const tracing = finalConfig.observability.tracing.provider === "memory" ? new MemoryTracing() : new NoopTracing();
|
|
3203
3247
|
const ai = finalConfig.ai.enabled ? new MemoryAI() : null;
|
|
3204
3248
|
const rag = finalConfig.rag.enabled ? new MemoryRAG() : null;
|
|
3205
|
-
return createPlatformFromAdapters(
|
|
3249
|
+
return createPlatformFromAdapters(
|
|
3250
|
+
db,
|
|
3251
|
+
cache,
|
|
3252
|
+
storage,
|
|
3253
|
+
email,
|
|
3254
|
+
queue,
|
|
3255
|
+
logger,
|
|
3256
|
+
metrics,
|
|
3257
|
+
tracing,
|
|
3258
|
+
ai,
|
|
3259
|
+
rag
|
|
3260
|
+
);
|
|
3206
3261
|
}
|
|
3207
3262
|
function createPlatformFromAdapters(db, cache, storage, email, queue, logger, metrics, tracing, ai, rag) {
|
|
3208
3263
|
const platform = {
|
|
@@ -3215,7 +3270,14 @@ function createPlatformFromAdapters(db, cache, storage, email, queue, logger, me
|
|
|
3215
3270
|
metrics,
|
|
3216
3271
|
tracing,
|
|
3217
3272
|
async healthCheck() {
|
|
3218
|
-
const [
|
|
3273
|
+
const [
|
|
3274
|
+
dbHealth,
|
|
3275
|
+
cacheHealth,
|
|
3276
|
+
storageHealth,
|
|
3277
|
+
emailHealth,
|
|
3278
|
+
queueHealth,
|
|
3279
|
+
tracingHealth
|
|
3280
|
+
] = await Promise.all([
|
|
3219
3281
|
db.healthCheck(),
|
|
3220
3282
|
cache.healthCheck(),
|
|
3221
3283
|
storage.healthCheck(),
|
|
@@ -3237,7 +3299,12 @@ function createPlatformFromAdapters(db, cache, storage, email, queue, logger, me
|
|
|
3237
3299
|
};
|
|
3238
3300
|
},
|
|
3239
3301
|
async close() {
|
|
3240
|
-
await Promise.all([
|
|
3302
|
+
await Promise.all([
|
|
3303
|
+
db.close(),
|
|
3304
|
+
cache.close(),
|
|
3305
|
+
queue.close(),
|
|
3306
|
+
tracing.close()
|
|
3307
|
+
]);
|
|
3241
3308
|
}
|
|
3242
3309
|
};
|
|
3243
3310
|
if (ai) {
|
|
@@ -3304,7 +3371,11 @@ function createTestPlatformWithInternals() {
|
|
|
3304
3371
|
};
|
|
3305
3372
|
},
|
|
3306
3373
|
async close() {
|
|
3307
|
-
await Promise.all([
|
|
3374
|
+
await Promise.all([
|
|
3375
|
+
memoryDb.close(),
|
|
3376
|
+
memoryCache.close(),
|
|
3377
|
+
memoryQueue.close()
|
|
3378
|
+
]);
|
|
3308
3379
|
}
|
|
3309
3380
|
};
|
|
3310
3381
|
return {
|
|
@@ -3344,15 +3415,20 @@ function assertEmailSent(memoryEmail, expected) {
|
|
|
3344
3415
|
const matchesTo = (emailTo, expectedTo) => {
|
|
3345
3416
|
if (!emailTo) return false;
|
|
3346
3417
|
if (Array.isArray(emailTo)) {
|
|
3347
|
-
return emailTo.some(
|
|
3418
|
+
return emailTo.some(
|
|
3419
|
+
(addr) => addr === expectedTo || typeof addr === "object" && addr.email === expectedTo
|
|
3420
|
+
);
|
|
3348
3421
|
}
|
|
3349
3422
|
return emailTo === expectedTo || typeof emailTo === "object" && emailTo.email === expectedTo;
|
|
3350
3423
|
};
|
|
3351
3424
|
const found = emails.find((email) => {
|
|
3352
|
-
if (expected.to && !matchesTo(email.to, expected.to))
|
|
3425
|
+
if (expected.to && !matchesTo(email.to, expected.to))
|
|
3426
|
+
return false;
|
|
3353
3427
|
if (expected.subject) {
|
|
3354
|
-
if (typeof expected.subject === "string" && email.subject !== expected.subject)
|
|
3355
|
-
|
|
3428
|
+
if (typeof expected.subject === "string" && email.subject !== expected.subject)
|
|
3429
|
+
return false;
|
|
3430
|
+
if (expected.subject instanceof RegExp && !expected.subject.test(email.subject))
|
|
3431
|
+
return false;
|
|
3356
3432
|
}
|
|
3357
3433
|
if (expected.bodyContains) {
|
|
3358
3434
|
const body = email.html || email.text || "";
|