@hypermode/models-as
Advanced tools
Comparing version 0.1.3 to 0.1.4
19
index.ts
@@ -16,11 +16,8 @@ import { JSON } from "json-as"; | ||
export abstract class Model< | ||
TInput extends object = object, | ||
TOutput extends object = object, | ||
> { | ||
protected constructor( | ||
public readonly info: ModelInfo, | ||
protected invoker: ModelInvoker, | ||
) {} | ||
export abstract class Model<TInput = unknown, TOutput = unknown> { | ||
static invoker: ModelInvoker | null = null; | ||
protected constructor(public info: ModelInfo) {} | ||
foo: string = "bar"; | ||
debug: boolean = false; | ||
@@ -34,2 +31,6 @@ | ||
invoke(input: TInput): TOutput { | ||
if (!Model.invoker) { | ||
throw new Error("Model invoker is not set."); | ||
} | ||
const modelName = this.info.name; | ||
@@ -41,3 +42,3 @@ const inputJson = JSON.stringify(input); | ||
const outputJson = this.invoker(modelName, inputJson); | ||
const outputJson = Model.invoker(modelName, inputJson); | ||
if (!outputJson) { | ||
@@ -44,0 +45,0 @@ throw new Error(`Failed to invoke ${modelName} model.`); |
{ | ||
"name": "@hypermode/models-as", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "Hypermode Model Interface Library for AssemblyScript", | ||
@@ -20,3 +20,3 @@ "author": "Hypermode, Inc.", | ||
"devDependencies": { | ||
"@types/node": "^20.14.4", | ||
"@types/node": "^20.14.5", | ||
"@typescript-eslint/eslint-plugin": "^7.13.1", | ||
@@ -23,0 +23,0 @@ "@typescript-eslint/parser": "^7.13.1", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11984
361