@workglow/ai 0.2.0 → 0.2.2
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/browser.js +20 -22
- package/dist/browser.js.map +3 -3
- package/dist/bun.js +20 -22
- package/dist/bun.js.map +3 -3
- package/dist/model/ModelRepository.d.ts +16 -2
- package/dist/model/ModelRepository.d.ts.map +1 -1
- package/dist/node.js +20 -22
- package/dist/node.js.map +3 -3
- package/package.json +11 -11
package/dist/bun.js
CHANGED
|
@@ -486,31 +486,29 @@ var ModelRecordSchema = {
|
|
|
486
486
|
var ModelPrimaryKeyNames = ["model_id"];
|
|
487
487
|
|
|
488
488
|
// src/model/ModelRepository.ts
|
|
489
|
-
var compiledModelRecordSchema;
|
|
490
|
-
function getModelRecordSchemaNode() {
|
|
491
|
-
if (!compiledModelRecordSchema) {
|
|
492
|
-
compiledModelRecordSchema = compileSchema(ModelRecordSchema);
|
|
493
|
-
}
|
|
494
|
-
return compiledModelRecordSchema;
|
|
495
|
-
}
|
|
496
|
-
function validateModelRecord(model) {
|
|
497
|
-
const schemaNode = getModelRecordSchemaNode();
|
|
498
|
-
const result = schemaNode.validate(model);
|
|
499
|
-
if (!result.valid) {
|
|
500
|
-
const errorMessages = result.errors.map((e) => {
|
|
501
|
-
const path = e.data?.pointer || "";
|
|
502
|
-
return `${e.message}${path ? ` (${path})` : ""}`;
|
|
503
|
-
});
|
|
504
|
-
throw new Error(`Invalid model record: ${errorMessages.join(", ")}`);
|
|
505
|
-
}
|
|
506
|
-
}
|
|
507
|
-
|
|
508
489
|
class ModelRepository {
|
|
509
490
|
modelTabularRepository;
|
|
510
491
|
constructor(modelTabularRepository) {
|
|
511
492
|
this.modelTabularRepository = modelTabularRepository;
|
|
512
493
|
}
|
|
513
494
|
events = new EventEmitter;
|
|
495
|
+
compiledValidationSchema;
|
|
496
|
+
getValidationSchema() {
|
|
497
|
+
return ModelRecordSchema;
|
|
498
|
+
}
|
|
499
|
+
validateModelRecord(model) {
|
|
500
|
+
if (!this.compiledValidationSchema) {
|
|
501
|
+
this.compiledValidationSchema = compileSchema(this.getValidationSchema());
|
|
502
|
+
}
|
|
503
|
+
const result = this.compiledValidationSchema.validate(model);
|
|
504
|
+
if (!result.valid) {
|
|
505
|
+
const errorMessages = result.errors.map((e) => {
|
|
506
|
+
const path = e.data?.pointer || "";
|
|
507
|
+
return `${e.message}${path ? ` (${path})` : ""}`;
|
|
508
|
+
});
|
|
509
|
+
throw new Error(`Invalid model record: ${errorMessages.join(", ")}`);
|
|
510
|
+
}
|
|
511
|
+
}
|
|
514
512
|
async setupDatabase() {
|
|
515
513
|
await this.modelTabularRepository.setupDatabase?.();
|
|
516
514
|
}
|
|
@@ -527,7 +525,7 @@ class ModelRepository {
|
|
|
527
525
|
return this.events.waitOn(name);
|
|
528
526
|
}
|
|
529
527
|
async addModel(model) {
|
|
530
|
-
validateModelRecord(model);
|
|
528
|
+
this.validateModelRecord(model);
|
|
531
529
|
const existing = await this.modelTabularRepository.get({ model_id: model.model_id });
|
|
532
530
|
if (existing) {
|
|
533
531
|
throw new Error(`Model with id "${model.model_id}" already exists`);
|
|
@@ -537,7 +535,7 @@ class ModelRepository {
|
|
|
537
535
|
return model;
|
|
538
536
|
}
|
|
539
537
|
async updateModel(model) {
|
|
540
|
-
validateModelRecord(model);
|
|
538
|
+
this.validateModelRecord(model);
|
|
541
539
|
const existing = await this.modelTabularRepository.get({ model_id: model.model_id });
|
|
542
540
|
if (!existing) {
|
|
543
541
|
throw new Error(`Model with id "${model.model_id}" not found`);
|
|
@@ -7580,4 +7578,4 @@ export {
|
|
|
7580
7578
|
AgentInputSchema
|
|
7581
7579
|
};
|
|
7582
7580
|
|
|
7583
|
-
//# debugId=
|
|
7581
|
+
//# debugId=3B27AB4CF952BD5A64756E2164756E21
|