@fibery/schema 10.2.15 → 10.2.17
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/lib/src/factory.d.ts +2 -2
- package/lib/src/field-object.d.ts +1 -1
- package/lib/src/field-object.js +8 -8
- package/lib/src/schema.d.ts +2 -2
- package/lib/src/schema.js +2 -5
- package/lib/src/type-object.d.ts +1 -1
- package/lib/src/type-object.js +10 -10
- package/lib/src/utils.d.ts +9 -6
- package/lib/src/utils.js +7 -7
- package/package.json +16 -60
package/lib/src/factory.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { FieldObject, FieldObjectParams } from "./field-object";
|
|
1
|
+
import { FieldObject, type FieldObjectParams } from "./field-object";
|
|
2
2
|
import { Schema } from "./schema";
|
|
3
|
-
import { TypeObject, TypeObjectParams } from "./type-object";
|
|
3
|
+
import { TypeObject, type TypeObjectParams } from "./type-object";
|
|
4
4
|
export type Factory = {
|
|
5
5
|
makeSchema: (rawSchema: Record<string, unknown>, options?: {
|
|
6
6
|
shouldRemoveDeletedTypesAndFields: boolean;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TypeObject } from "./type-object";
|
|
1
|
+
import type { TypeObject } from "./type-object";
|
|
2
2
|
export type Cardinality = ":cardinality/one-to-one" | ":cardinality/one-to-many" | ":cardinality/many-to-many" | ":cardinality/many-to-one";
|
|
3
3
|
export type RawFieldObject = {
|
|
4
4
|
"fibery/id": string;
|
package/lib/src/field-object.js
CHANGED
|
@@ -4,10 +4,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.FieldObject = void 0;
|
|
7
|
+
const _1 = require("@fibery/helpers/src/_");
|
|
7
8
|
const isFunction_1 = __importDefault(require("lodash/isFunction"));
|
|
8
9
|
const isPlainObject_1 = __importDefault(require("lodash/isPlainObject"));
|
|
9
10
|
const isString_1 = __importDefault(require("lodash/isString"));
|
|
10
|
-
const once_1 = __importDefault(require("lodash/once"));
|
|
11
11
|
const utils_1 = require("./utils");
|
|
12
12
|
class FieldObject {
|
|
13
13
|
name;
|
|
@@ -97,12 +97,12 @@ class FieldObject {
|
|
|
97
97
|
typeObject: {
|
|
98
98
|
configurable: false,
|
|
99
99
|
enumerable: true,
|
|
100
|
-
get: (0,
|
|
100
|
+
get: (0, _1.once)(() => resolveTypeObject(this.type)),
|
|
101
101
|
},
|
|
102
102
|
mixinTypeObject: {
|
|
103
103
|
configurable: false,
|
|
104
104
|
enumerable: true,
|
|
105
|
-
get: (0,
|
|
105
|
+
get: (0, _1.once)(() => {
|
|
106
106
|
return this.holderTypeObject.installedMixinTypeObjects.find((mixinTypeObject) => Object.hasOwn(mixinTypeObject.fieldObjectsByName, this.name) ||
|
|
107
107
|
(this.name === "workflow/state" && mixinTypeObject.name === "workflow/workflow"));
|
|
108
108
|
}),
|
|
@@ -110,19 +110,19 @@ class FieldObject {
|
|
|
110
110
|
holderTypeObject: {
|
|
111
111
|
configurable: false,
|
|
112
112
|
enumerable: true,
|
|
113
|
-
get: (0,
|
|
113
|
+
get: (0, _1.once)(() => {
|
|
114
114
|
return resolveTypeObject(holderType);
|
|
115
115
|
}),
|
|
116
116
|
},
|
|
117
117
|
nameParts: {
|
|
118
118
|
configurable: false,
|
|
119
119
|
enumerable: true,
|
|
120
|
-
get: (0,
|
|
120
|
+
get: (0, _1.once)(() => (0, utils_1.parseType)(rawFieldObject["fibery/name"])),
|
|
121
121
|
},
|
|
122
122
|
title: {
|
|
123
123
|
configurable: false,
|
|
124
124
|
enumerable: true,
|
|
125
|
-
get: (0,
|
|
125
|
+
get: (0, _1.once)(() => {
|
|
126
126
|
if (this.name === "fibery/role" && this.holderType === "fibery/user") {
|
|
127
127
|
return "User Role";
|
|
128
128
|
}
|
|
@@ -132,7 +132,7 @@ class FieldObject {
|
|
|
132
132
|
multiRelatedFieldObjects: {
|
|
133
133
|
configurable: false,
|
|
134
134
|
enumerable: true,
|
|
135
|
-
get: (0,
|
|
135
|
+
get: (0, _1.once)(() => {
|
|
136
136
|
const { multiRelation, typeObject } = this;
|
|
137
137
|
if (!multiRelation || !typeObject.isEntityRef) {
|
|
138
138
|
return [];
|
|
@@ -143,7 +143,7 @@ class FieldObject {
|
|
|
143
143
|
isMultiField: {
|
|
144
144
|
configurable: false,
|
|
145
145
|
enumerable: true,
|
|
146
|
-
get: (0,
|
|
146
|
+
get: (0, _1.once)(() => {
|
|
147
147
|
return this.typeObject.isEntityRef;
|
|
148
148
|
}),
|
|
149
149
|
},
|
package/lib/src/schema.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import type { Factory } from "./factory";
|
|
2
|
+
import type { RawTypeObject, TypeObject } from "./type-object";
|
|
3
3
|
export type RawSchema = {
|
|
4
4
|
"fibery/id": string;
|
|
5
5
|
"fibery/types": RawTypeObject[];
|
package/lib/src/schema.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
3
|
exports.Schema = void 0;
|
|
7
|
-
const
|
|
4
|
+
const _1 = require("@fibery/helpers/src/_");
|
|
8
5
|
class Schema {
|
|
9
6
|
typeObjects;
|
|
10
7
|
typeObjectsById;
|
|
@@ -21,7 +18,7 @@ class Schema {
|
|
|
21
18
|
enumerable: false,
|
|
22
19
|
},
|
|
23
20
|
});
|
|
24
|
-
const getTypeComponentTypeToFieldObject = (0,
|
|
21
|
+
const getTypeComponentTypeToFieldObject = (0, _1.once)(() => {
|
|
25
22
|
const typeComponentTypeToFieldObject = new Map();
|
|
26
23
|
this.typeObjects
|
|
27
24
|
.flatMap((typeObject) => typeObject.fieldObjects)
|
package/lib/src/type-object.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FieldObject, FieldObjectParams, RawFieldObject } from "./field-object";
|
|
2
1
|
import type { IdField, PublicIdField, RankField, TitleField } from "./field-keys";
|
|
2
|
+
import type { FieldObject, FieldObjectParams, RawFieldObject } from "./field-object";
|
|
3
3
|
export type SyncSource = {
|
|
4
4
|
appId: string;
|
|
5
5
|
appName: string;
|
package/lib/src/type-object.js
CHANGED
|
@@ -4,11 +4,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.TypeObject = void 0;
|
|
7
|
+
const _1 = require("@fibery/helpers/src/_");
|
|
8
|
+
const pluralize_1 = require("@fibery/pluralize");
|
|
7
9
|
const isFunction_1 = __importDefault(require("lodash/isFunction"));
|
|
8
10
|
const isPlainObject_1 = __importDefault(require("lodash/isPlainObject"));
|
|
9
|
-
const once_1 = __importDefault(require("lodash/once"));
|
|
10
11
|
const utils_1 = require("./utils");
|
|
11
|
-
const pluralize_1 = require("@fibery/pluralize");
|
|
12
12
|
class TypeObject {
|
|
13
13
|
name;
|
|
14
14
|
description;
|
|
@@ -66,13 +66,13 @@ class TypeObject {
|
|
|
66
66
|
this.syncSource = rawMeta["sync/source"] || null;
|
|
67
67
|
this.version = version;
|
|
68
68
|
this.isEntityRef = rawTypeObject["fibery/name"] === "fibery/entity-ref";
|
|
69
|
-
const fieldObjectsByNameOnceGetter = (0,
|
|
69
|
+
const fieldObjectsByNameOnceGetter = (0, _1.once)(() => {
|
|
70
70
|
return factory.makeFieldObjectsByName({
|
|
71
71
|
type: this.name,
|
|
72
72
|
fieldObjects: this.fieldObjects,
|
|
73
73
|
});
|
|
74
74
|
});
|
|
75
|
-
const fieldObjectsGetter = (0,
|
|
75
|
+
const fieldObjectsGetter = (0, _1.once)(() => rawTypeObject["fibery/fields"].map((rawFieldObject) => {
|
|
76
76
|
return factory.makeFieldObject({
|
|
77
77
|
rawFieldObject,
|
|
78
78
|
holderType: this.name,
|
|
@@ -106,7 +106,7 @@ class TypeObject {
|
|
|
106
106
|
fieldObjectsById: {
|
|
107
107
|
configurable: false,
|
|
108
108
|
enumerable: true,
|
|
109
|
-
get: (0,
|
|
109
|
+
get: (0, _1.once)(() => {
|
|
110
110
|
return factory.makeFieldObjectsById({
|
|
111
111
|
type: this.name,
|
|
112
112
|
fieldObjects: this.fieldObjects,
|
|
@@ -121,26 +121,26 @@ class TypeObject {
|
|
|
121
121
|
installedMixinTypeObjects: {
|
|
122
122
|
configurable: false,
|
|
123
123
|
enumerable: true,
|
|
124
|
-
get: (0,
|
|
124
|
+
get: (0, _1.once)(() => [...this.installedMixins].map(resolveTypeObject).filter((typeObject) => typeObject)),
|
|
125
125
|
},
|
|
126
126
|
title: {
|
|
127
127
|
configurable: false,
|
|
128
128
|
enumerable: true,
|
|
129
|
-
get: (0,
|
|
129
|
+
get: (0, _1.once)(() => (0, utils_1.toTitle)(this.name)),
|
|
130
130
|
},
|
|
131
131
|
pluralTitle: {
|
|
132
132
|
configurable: false,
|
|
133
133
|
enumerable: true,
|
|
134
|
-
get: (0,
|
|
134
|
+
get: (0, _1.once)(() => pluralize_1.pluralize.plural((0, utils_1.toTitle)(this.name))),
|
|
135
135
|
},
|
|
136
136
|
singularTitle: {
|
|
137
137
|
configurable: false,
|
|
138
138
|
enumerable: true,
|
|
139
|
-
get: (0,
|
|
139
|
+
get: (0, _1.once)(() => pluralize_1.pluralize.singular((0, utils_1.toTitle)(this.name))),
|
|
140
140
|
},
|
|
141
141
|
});
|
|
142
142
|
}
|
|
143
|
-
_getFieldObjectShortcuts = (0,
|
|
143
|
+
_getFieldObjectShortcuts = (0, _1.once)(() => {
|
|
144
144
|
const hasRank = this.installedMixins.has("fibery/rank-mixin");
|
|
145
145
|
return this.fieldObjects.reduce((result, fieldObject) => {
|
|
146
146
|
if (fieldObject.isId) {
|
package/lib/src/utils.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { RawSchema } from "./schema";
|
|
2
|
-
import { TypeObject } from "./type-object";
|
|
1
|
+
import type { RawSchema } from "./schema";
|
|
2
|
+
import type { TypeObject } from "./type-object";
|
|
3
3
|
export declare const withOnlyDefinedGets: (target: any, targetKind?: string) => any;
|
|
4
4
|
export declare const capitalizeFirstChar: (input: string) => string;
|
|
5
|
-
export declare const toTypeOrFieldNamePartTitle: (str: string) => string;
|
|
6
|
-
export declare const toTypeOrFieldTitle: (str: string) => string;
|
|
5
|
+
export declare const toTypeOrFieldNamePartTitle: (str: string | null | undefined) => string;
|
|
6
|
+
export declare const toTypeOrFieldTitle: (str: string | null | undefined) => string;
|
|
7
7
|
export declare const toPascalCase: (lispCasedString?: string) => string;
|
|
8
8
|
export declare const toNonEnumTitle: (strName: string) => string;
|
|
9
9
|
export declare const parseEnumType: (type: string) => {
|
|
@@ -13,10 +13,13 @@ export declare const parseEnumType: (type: string) => {
|
|
|
13
13
|
targetNamespace: string;
|
|
14
14
|
};
|
|
15
15
|
export declare const toTitle: (typeOrAttr: string) => string;
|
|
16
|
-
export declare const parseType: ((
|
|
16
|
+
export declare const parseType: ((arg: string) => {
|
|
17
17
|
namespace: string;
|
|
18
18
|
name: string;
|
|
19
|
-
}) & import("
|
|
19
|
+
}) & import("@fibery/helpers/src/_").MemoizedFunction<string, {
|
|
20
|
+
namespace: string;
|
|
21
|
+
name: string;
|
|
22
|
+
}>;
|
|
20
23
|
export declare const makeEnumTypeNamePart: ({ holderType, enumName }: {
|
|
21
24
|
holderType: string;
|
|
22
25
|
enumName: string;
|
package/lib/src/utils.js
CHANGED
|
@@ -4,14 +4,14 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.getTypeObjectTitle = exports.removeDeletedTypesAndFields = exports.attachEnumNamespace = exports.makeEnumTypeNamePart = exports.parseType = exports.toTitle = exports.parseEnumType = exports.toNonEnumTitle = exports.toPascalCase = exports.toTypeOrFieldTitle = exports.toTypeOrFieldNamePartTitle = exports.capitalizeFirstChar = exports.withOnlyDefinedGets = void 0;
|
|
7
|
+
const _1 = require("@fibery/helpers/src/_");
|
|
7
8
|
const trace_1 = require("@fibery/helpers/utils/trace");
|
|
8
9
|
const capitalize_1 = __importDefault(require("lodash/capitalize"));
|
|
9
10
|
const flow_1 = __importDefault(require("lodash/flow"));
|
|
10
11
|
const last_1 = __importDefault(require("lodash/last"));
|
|
11
|
-
const memoize_1 = __importDefault(require("lodash/memoize"));
|
|
12
12
|
const errors_1 = require("./errors");
|
|
13
13
|
const print_utils_1 = require("./print-utils");
|
|
14
|
-
const
|
|
14
|
+
const testRunnerKeys = new Set(["nodeType", "tagName", "hasAttribute"]);
|
|
15
15
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
16
16
|
const withOnlyDefinedGets = (target, targetKind = "object") => new Proxy(target, {
|
|
17
17
|
get(target, key) {
|
|
@@ -36,7 +36,7 @@ const withOnlyDefinedGets = (target, targetKind = "object") => new Proxy(target,
|
|
|
36
36
|
return undefined;
|
|
37
37
|
}
|
|
38
38
|
if (key === "inspect") {
|
|
39
|
-
// greetings from
|
|
39
|
+
// greetings from vitest/node console implementation
|
|
40
40
|
return undefined;
|
|
41
41
|
}
|
|
42
42
|
if (key === "@@toStringTag") {
|
|
@@ -48,8 +48,8 @@ const withOnlyDefinedGets = (target, targetKind = "object") => new Proxy(target,
|
|
|
48
48
|
return undefined;
|
|
49
49
|
}
|
|
50
50
|
if (process.env.NODE_ENV === "test") {
|
|
51
|
-
// greetings from
|
|
52
|
-
if (typeof key === "string" &&
|
|
51
|
+
// greetings from vitest serializer
|
|
52
|
+
if (typeof key === "string" && testRunnerKeys.has(key)) {
|
|
53
53
|
return undefined;
|
|
54
54
|
}
|
|
55
55
|
if (key === "@@__IMMUTABLE_ITERABLE__@@") {
|
|
@@ -62,7 +62,7 @@ const withOnlyDefinedGets = (target, targetKind = "object") => new Proxy(target,
|
|
|
62
62
|
return undefined;
|
|
63
63
|
}
|
|
64
64
|
if (key === "asymmetricMatch") {
|
|
65
|
-
// greetings from
|
|
65
|
+
// greetings from vitest expect().toEqual
|
|
66
66
|
return undefined;
|
|
67
67
|
}
|
|
68
68
|
if (key === "then") {
|
|
@@ -141,7 +141,7 @@ const splitKeyword = (keyword) => {
|
|
|
141
141
|
name,
|
|
142
142
|
};
|
|
143
143
|
};
|
|
144
|
-
exports.parseType = (0,
|
|
144
|
+
exports.parseType = (0, _1.memoize)((type) => {
|
|
145
145
|
if (!type.includes("/")) {
|
|
146
146
|
(0, trace_1.traceError)(`parseType invalid usage: passed type is '${type}'`);
|
|
147
147
|
}
|
package/package.json
CHANGED
|
@@ -1,87 +1,43 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fibery/schema",
|
|
3
|
-
"version": "10.2.
|
|
3
|
+
"version": "10.2.17",
|
|
4
|
+
"private": false,
|
|
4
5
|
"description": "Fibery schema utils",
|
|
5
|
-
"main": "./lib/index.js",
|
|
6
6
|
"files": [
|
|
7
7
|
"./lib"
|
|
8
8
|
],
|
|
9
|
+
"main": "./lib/index.js",
|
|
9
10
|
"exports": {
|
|
10
11
|
".": {
|
|
12
|
+
"@fibery/source": "./index.ts",
|
|
11
13
|
"types": "./lib/index.d.ts",
|
|
12
14
|
"default": "./lib/index.js"
|
|
13
15
|
}
|
|
14
16
|
},
|
|
15
|
-
"fiberyDevExports": {
|
|
16
|
-
".": "./index.ts"
|
|
17
|
-
},
|
|
18
|
-
"private": false,
|
|
19
17
|
"dependencies": {
|
|
20
18
|
"lodash": "4.17.21",
|
|
21
19
|
"memoize-one": "6.0.0",
|
|
22
|
-
"@fibery/
|
|
23
|
-
"@fibery/
|
|
20
|
+
"@fibery/pluralize": "1.1.2",
|
|
21
|
+
"@fibery/helpers": "3.0.0"
|
|
24
22
|
},
|
|
25
23
|
"devDependencies": {
|
|
26
24
|
"@babel/core": "7.28.5",
|
|
27
|
-
"@swc/jest": "0.2.39",
|
|
28
25
|
"@types/lodash": "4.14.172",
|
|
26
|
+
"@typescript/native-preview": "beta",
|
|
29
27
|
"babel-loader": "10.0.0",
|
|
30
|
-
"
|
|
31
|
-
"jest-junit": "16.0.0",
|
|
32
|
-
"typescript": "5.9.3",
|
|
28
|
+
"typescript": "6.0.1-rc",
|
|
33
29
|
"webpack": "5.87.0",
|
|
34
30
|
"webpack-cli": "6.0.1",
|
|
35
|
-
"@fibery/babel-preset": "7.4.2"
|
|
36
|
-
"@fibery/eslint-config": "9.0.1"
|
|
37
|
-
},
|
|
38
|
-
"jest": {
|
|
39
|
-
"testEnvironment": "node",
|
|
40
|
-
"coveragePathIgnorePatterns": [
|
|
41
|
-
"/node_modules/"
|
|
42
|
-
],
|
|
43
|
-
"collectCoverageFrom": [
|
|
44
|
-
"src/**/*.{js,jsx,ts,tsx}",
|
|
45
|
-
"!src/**/*.d.ts"
|
|
46
|
-
],
|
|
47
|
-
"coverageReporters": [
|
|
48
|
-
"text",
|
|
49
|
-
"cobertura"
|
|
50
|
-
],
|
|
51
|
-
"testPathIgnorePatterns": [
|
|
52
|
-
"<rootDir>[/\\\\](build|docs|node_modules|scripts)[/\\\\]"
|
|
53
|
-
],
|
|
54
|
-
"transform": {
|
|
55
|
-
"^.+\\.(js|jsx|ts|tsx)$": [
|
|
56
|
-
"@swc/jest",
|
|
57
|
-
{
|
|
58
|
-
"jsc": {
|
|
59
|
-
"parser": {
|
|
60
|
-
"syntax": "typescript",
|
|
61
|
-
"tsx": true,
|
|
62
|
-
"decorators": true,
|
|
63
|
-
"dynamicImport": true
|
|
64
|
-
},
|
|
65
|
-
"transform": {
|
|
66
|
-
"react": {
|
|
67
|
-
"runtime": "automatic"
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
]
|
|
73
|
-
},
|
|
74
|
-
"testEnvironmentOptions": {
|
|
75
|
-
"url": "http://localhost"
|
|
76
|
-
}
|
|
31
|
+
"@fibery/babel-preset": "7.4.2"
|
|
77
32
|
},
|
|
78
33
|
"scripts": {
|
|
79
|
-
"build": "rm -rf lib &&
|
|
80
|
-
"test": "
|
|
81
|
-
"test:ci": "
|
|
82
|
-
"test:coverage": "
|
|
83
|
-
"
|
|
84
|
-
"
|
|
34
|
+
"build": "rm -rf lib && tsc --project tsconfig.build.json",
|
|
35
|
+
"test": "../../scripts/test.sh",
|
|
36
|
+
"test:ci": "../../scripts/test.sh --ci",
|
|
37
|
+
"test:coverage": "../../scripts/test.sh --ci --coverage",
|
|
38
|
+
"check": "../../scripts/check.sh",
|
|
39
|
+
"lint": "../../scripts/lint.sh",
|
|
40
|
+
"typecheck": "../../scripts/typecheck.sh"
|
|
85
41
|
},
|
|
86
42
|
"types": "./lib/index.d.ts"
|
|
87
43
|
}
|