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