Skip to content

Commit b0e9c25

Browse files
committed
update: merge latest main
2 parents d588277 + fb130ad commit b0e9c25

25 files changed

+795
-249
lines changed

package-lock.json

Lines changed: 22 additions & 20 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"@babel/preset-react": "7.16.7",
5757
"@babel/register": "^7.16.0",
5858
"@babel/runtime-corejs3": "7.16.8",
59-
"@exabyte-io/esse.js": "git+https://github.com/Exabyte-io/esse.git#update/SOF-6668",
59+
"@exabyte-io/esse.js": "2023.8.31-0",
6060
"@types/chai": "^4.3.5",
6161
"@types/crypto-js": "^4.1.1",
6262
"@types/js-yaml": "^4.0.5",
@@ -77,6 +77,7 @@
7777
"mixwith": "^0.1.1",
7878
"nunjucks": "^3.2.4",
7979
"react-jsonschema-form": "^1.8.1",
80+
"semver": "^7.5.3",
8081
"ts-node": "^10.9.1",
8182
"typescript": "^4.5.5",
8283
"underscore": "^1.13.3",

src/JSONSchemasInterface.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export class JSONSchemasInterface {
7878

7979
/**
8080
*
81-
* @param {Object} - external schema
81+
* @param globalSchema
8282
*/
8383
static registerGlobalSchema(globalSchema: JSONSchema) {
8484
if (JSONSchemasInterface._schema === globalSchema) {
@@ -159,4 +159,14 @@ export class JSONSchemasInterface {
159159
}
160160
return ajv.compile(schema);
161161
}
162+
163+
/**
164+
* Register global schema only if none has been registered yet.
165+
* @param globalSchema
166+
*/
167+
static registerGlobalSchemaIfEmpty(globalSchema: JSONSchema) {
168+
if (!JSONSchemasInterface._schema) {
169+
JSONSchemasInterface.registerGlobalSchema(globalSchema);
170+
}
171+
}
162172
}

src/context/registry.js

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,27 @@ export class ContextProviderRegistryContainer {
4646
* };
4747
*
4848
*/
49-
export const extendAndPatchRegistry = (registryContainer, classConfigMap, classesToPatch = {}) => {
49+
export const extendAndPatchRegistry = (
50+
registryContainer,
51+
classConfigMap,
52+
classesToPatch = {},
53+
defaultSettings = {},
54+
) => {
5055
Object.entries(classConfigMap).forEach(([name, { providerCls, config }]) => {
5156
Object.entries(classesToPatch).forEach(([clsName, cls]) => {
5257
if (providerCls[clsName]) {
5358
providerCls[clsName] = cls;
5459
}
60+
const providerDefaultSettings = defaultSettings[providerCls.name];
61+
if (providerDefaultSettings) {
62+
Object.entries(providerDefaultSettings).forEach(([key, value]) => {
63+
if (providerCls[key]) {
64+
providerCls[key] = value;
65+
}
66+
});
67+
}
5568
});
69+
5670
registryContainer.addProvider({
5771
instance: providerCls.getConstructorConfig(config),
5872
name,
@@ -66,7 +80,16 @@ export const extendAndPatchRegistry = (registryContainer, classConfigMap, classe
6680
* @param {Object} classConfigMap
6781
* @param {{Material: SpecificMockMaterial}} classesToPatch
6882
*/
69-
export const createAndPatchRegistry = (classConfigMap, classesToPatch = {}) => {
83+
export const createAndPatchRegistry = (
84+
classConfigMap,
85+
classesToPatch = {},
86+
defaultSettings = {},
87+
) => {
7088
const registryContainer = new ContextProviderRegistryContainer();
71-
return extendAndPatchRegistry(registryContainer, classConfigMap, classesToPatch);
89+
return extendAndPatchRegistry(
90+
registryContainer,
91+
classConfigMap,
92+
classesToPatch,
93+
defaultSettings,
94+
);
7295
};

src/entity/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
DefaultableMixin,
88
HasDescriptionMixin,
99
HasMetadataMixin,
10+
HasScopeTrackMixin,
1011
NamedEntityMixin,
1112
TaggableMixin,
1213
} from "./mixins/props";
@@ -43,6 +44,7 @@ export {
4344
HasDescriptionMixin,
4445
HasMetadataMixin,
4546
TaggableMixin,
47+
HasScopeTrackMixin,
4648
NamedEntityMixin,
4749
RuntimeItemsMixin,
4850
RuntimeContextFieldMixin,

src/entity/mixins/props.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,6 @@ export function DefaultableMixin<T extends InMemoryEntityConstructor>(superclass
1111

1212
declare static readonly defaultConfig: object | null;
1313

14-
// Define in superclass
15-
// static get defaultConfig() {
16-
// }
17-
1814
static createDefault() {
1915
return new this.prototype.constructor(this.defaultConfig);
2016
}
@@ -38,6 +34,18 @@ export function TaggableMixin<T extends InMemoryEntityConstructor>(superclass: T
3834
};
3935
}
4036

37+
export function HasScopeTrackMixin<T extends InMemoryEntityConstructor>(superclass: T) {
38+
return class extends superclass {
39+
get scopeTrack() {
40+
return this.prop("scopeTrack", []);
41+
}
42+
43+
set scopeTrack(array: unknown[]) {
44+
this.setProp("scopeTrack", array);
45+
}
46+
};
47+
}
48+
4149
export function HasMetadataMixin<T extends InMemoryEntityConstructor>(superclass: T) {
4250
return class extends superclass {
4351
get metadata(): object {

src/utils/filter.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ interface PathObject {
66
}
77

88
// Filter conditions
9-
interface FilterObject {
9+
export interface FilterObject {
1010
path?: string;
1111
regex?: RegExp;
1212
}
@@ -57,6 +57,7 @@ export function filterEntityList({
5757
filterObjects = [],
5858
multiPathSeparator = "",
5959
}: FilterEntityListProps) {
60+
if (!filterObjects || !filterObjects.length) return [];
6061
const filterObjects_ = filterObjects.map((o) => (o.regex ? { regex: new RegExp(o.regex) } : o));
6162

6263
let filtered;

src/utils/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,11 @@ import {
2727
sortKeysDeepForObject,
2828
stringifyObject,
2929
} from "./object";
30-
import { getSchemaWithDependencies } from "./schemas";
30+
import { getSchemaWithDependencies, buildNamedEntitySchema } from "./schemas";
3131
import { getSearchQuerySelector } from "./selector";
3232
import {
3333
convertArabicToRoman,
34+
findPreviousVersion,
3435
randomAlphanumeric,
3536
removeCommentsFromSourceCode,
3637
removeEmptyLinesFromString,
@@ -89,4 +90,6 @@ export {
8990
getFilesInDirectory,
9091
getDirectories,
9192
createObjectPathFromFilePath,
93+
buildNamedEntitySchema,
94+
findPreviousVersion,
9295
};

src/utils/object.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import omit from "lodash/omit";
1010

1111
import { AnyObject } from "../entity/in_memory";
1212
import { NameResultSchema } from "../types";
13+
import { safeMakeArray } from "./array";
1314
import { deepClone } from "./clone";
1415

1516
/**
@@ -248,6 +249,7 @@ function isTreeObject<T>(value: unknown): value is Tree<T> {
248249
* mergeTerminalNodes(tree); // ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l']
249250
*/
250251
export function mergeTerminalNodes<T = string>(tree: Tree<T>, unique = false): T[] {
252+
if (!isTreeObject<T>(tree)) return safeMakeArray(tree);
251253
const terminalValues = Object.values(tree).reduce((accumulator: T[], value) => {
252254
if (isTreeObject<T>(value)) {
253255
return accumulator.concat(mergeTerminalNodes(value));

0 commit comments

Comments
 (0)