Skip to content

Commit 39d15a1

Browse files
authored
Merge pull request #81 from Exabyte-io/hotfix/executable
fix: json schema validation
2 parents db8af00 + fa1d501 commit 39d15a1

24 files changed

+266
-27
lines changed

.mocharc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"extension": ["ts", "js"],
33
"spec": "tests/**/*.ts",
4-
"require": ["ts-node/register"]
4+
"require": ["ts-node/register"],
5+
"file": ["tests/js/setup.ts"]
56
}

dist/js/applicationMixin.d.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity";
33
import type { DefaultableInMemoryEntity } from "@mat3ra/code/dist/js/entity/mixins/DefaultableMixin";
44
import type { NamedInMemoryEntity } from "@mat3ra/code/dist/js/entity/mixins/NamedEntityMixin";
55
import type { Constructor } from "@mat3ra/code/dist/js/utils/types";
6+
import type { ApplicationSchemaBase } from "@mat3ra/esse/dist/js/types";
67
import Executable from "./executable";
78
type Base = InMemoryEntity & NamedInMemoryEntity & DefaultableInMemoryEntity;
89
export type BaseConstructor = Constructor<Base> & {
@@ -27,7 +28,8 @@ export type ApplicationStaticMixin = {
2728
summary: string;
2829
build: string;
2930
};
31+
jsonSchema: ApplicationSchemaBase;
3032
};
31-
export declare function applicationMixin(item: Base): Base;
32-
export declare function applicationStaticMixin<T extends BaseConstructor>(Application: T): ApplicationStaticMixin;
33+
export declare function applicationMixin(item: Base): void;
34+
export declare function applicationStaticMixin<T extends BaseConstructor>(Application: T): void;
3335
export {};

dist/js/applicationMixin.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
"use strict";
2+
var __importDefault = (this && this.__importDefault) || function (mod) {
3+
return (mod && mod.__esModule) ? mod : { "default": mod };
4+
};
25
Object.defineProperty(exports, "__esModule", { value: true });
36
exports.applicationMixin = applicationMixin;
47
exports.applicationStaticMixin = applicationStaticMixin;
8+
const JSONSchemasInterface_1 = __importDefault(require("@mat3ra/esse/dist/js/esse/JSONSchemasInterface"));
59
function applicationMixin(item) {
610
// @ts-expect-error
711
const properties = {
@@ -29,7 +33,6 @@ function applicationMixin(item) {
2933
},
3034
};
3135
Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties));
32-
return item;
3336
}
3437
function applicationStaticMixin(Application) {
3538
const properties = {
@@ -42,7 +45,9 @@ function applicationStaticMixin(Application) {
4245
build: "Default",
4346
};
4447
},
48+
get jsonSchema() {
49+
return JSONSchemasInterface_1.default.getSchemaById("software/application");
50+
},
4551
};
4652
Object.defineProperties(Application, Object.getOwnPropertyDescriptors(properties));
47-
return properties;
4853
}

dist/js/executable.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { NamedDefaultableInMemoryEntity } from "@mat3ra/code/dist/js/entity";
22
import type { Constructor } from "@mat3ra/code/dist/js/utils/types";
33
import { type ExecutableMixin } from "./executableMixin";
4-
type Base = typeof NamedDefaultableInMemoryEntity & Constructor<ExecutableMixin>;
4+
type Base = Constructor<ExecutableMixin> & typeof NamedDefaultableInMemoryEntity;
55
declare const Executable_base: Base;
66
export default class Executable extends Executable_base {
77
}

dist/js/executable.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ exports.default = Executable;
99
// Apply mixins
1010
(0, RuntimeItemsMixin_1.runtimeItemsMixin)(Executable.prototype);
1111
(0, executableMixin_1.executableMixin)(Executable.prototype);
12+
(0, executableMixin_1.executableStaticMixin)(Executable);

dist/js/executableMixin.d.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,21 @@ import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity";
22
import type { DefaultableInMemoryEntity } from "@mat3ra/code/dist/js/entity/mixins/DefaultableMixin";
33
import type { NamedInMemoryEntity } from "@mat3ra/code/dist/js/entity/mixins/NamedEntityMixin";
44
import type { Constructor } from "@mat3ra/code/dist/js/utils/types";
5+
import type { AnyObject } from "@mat3ra/esse/dist/js/esse/types";
6+
import type { ExecutableSchema } from "@mat3ra/esse/dist/js/types";
57
import type { FlavorMixin } from "./flavorMixin";
68
type BaseFlavor = FlavorMixin & NamedInMemoryEntity & InMemoryEntity;
79
type Base = InMemoryEntity & NamedInMemoryEntity & DefaultableInMemoryEntity;
8-
export declare function executableMixin(item: Base): Base;
10+
export declare function executableMixin(item: Base): void;
11+
export declare function executableStaticMixin(Executable: Constructor<Base>): void;
912
export type BaseConstructor = Constructor<Base> & {
1013
constructCustomFlavor?: (config: object) => BaseFlavor;
1114
};
1215
export type ExecutableMixin = {
1316
applicationId: string[];
17+
toJSON: () => ExecutableSchema & AnyObject;
18+
};
19+
export type ExecutableStaticMixin = {
20+
jsonSchema: ExecutableSchema;
1421
};
1522
export {};

dist/js/executableMixin.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
"use strict";
2+
var __importDefault = (this && this.__importDefault) || function (mod) {
3+
return (mod && mod.__esModule) ? mod : { "default": mod };
4+
};
25
Object.defineProperty(exports, "__esModule", { value: true });
36
exports.executableMixin = executableMixin;
7+
exports.executableStaticMixin = executableStaticMixin;
8+
const JSONSchemasInterface_1 = __importDefault(require("@mat3ra/esse/dist/js/esse/JSONSchemasInterface"));
49
function executableMixin(item) {
510
// @ts-expect-error
611
const properties = {
@@ -12,5 +17,12 @@ function executableMixin(item) {
1217
},
1318
};
1419
Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties));
15-
return item;
20+
}
21+
function executableStaticMixin(Executable) {
22+
const properties = {
23+
get jsonSchema() {
24+
return JSONSchemasInterface_1.default.getSchemaById("software/executable");
25+
},
26+
};
27+
Object.defineProperties(Executable, Object.getOwnPropertyDescriptors(properties));
1628
}

dist/js/flavor.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ exports.default = Flavor;
99
// Apply mixins
1010
(0, flavorMixin_1.flavorMixin)(Flavor.prototype);
1111
(0, RuntimeItemsMixin_1.runtimeItemsMixin)(Flavor.prototype);
12+
(0, flavorMixin_1.flavorStaticMixin)(Flavor);

dist/js/flavorMixin.d.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type { InMemoryEntity } from "@mat3ra/code/dist/js/entity";
22
import type { NamedInMemoryEntity } from "@mat3ra/code/dist/js/entity/mixins/NamedEntityMixin";
3+
import type { Constructor } from "@mat3ra/code/dist/js/utils/types";
34
import type { FlavorSchema } from "@mat3ra/esse/dist/js/types";
45
type Base = InMemoryEntity & NamedInMemoryEntity;
56
type Input = Required<FlavorSchema>["input"];
@@ -13,4 +14,8 @@ export type FlavorMixin = {
1314
getInputAsRenderedTemplates: (context: Record<string, unknown>) => Record<string, unknown>[];
1415
};
1516
export declare function flavorMixin(item: Base): FlavorMixin & InMemoryEntity & NamedInMemoryEntity;
17+
export declare function flavorStaticMixin(Flavor: Constructor<Base>): void;
18+
export type FlavorStaticMixin = {
19+
jsonSchema: FlavorSchema;
20+
};
1621
export {};

dist/js/flavorMixin.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
"use strict";
2+
var __importDefault = (this && this.__importDefault) || function (mod) {
3+
return (mod && mod.__esModule) ? mod : { "default": mod };
4+
};
25
Object.defineProperty(exports, "__esModule", { value: true });
36
exports.flavorMixin = flavorMixin;
7+
exports.flavorStaticMixin = flavorStaticMixin;
8+
const JSONSchemasInterface_1 = __importDefault(require("@mat3ra/esse/dist/js/esse/JSONSchemasInterface"));
49
// TODO: should we add fields from esse schema (executableId, executableName, applicationName)?
510
function flavorMixin(item) {
611
// @ts-expect-error
@@ -27,3 +32,11 @@ function flavorMixin(item) {
2732
Object.defineProperties(item, Object.getOwnPropertyDescriptors(properties));
2833
return properties;
2934
}
35+
function flavorStaticMixin(Flavor) {
36+
const properties = {
37+
get jsonSchema() {
38+
return JSONSchemasInterface_1.default.getSchemaById("software/flavor");
39+
},
40+
};
41+
Object.defineProperties(Flavor, Object.getOwnPropertyDescriptors(properties));
42+
}

0 commit comments

Comments
 (0)