@fibery/schema 10.3.1 → 10.3.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/lib/field-object.d.ts +12 -3
- package/lib/field-object.js +4 -3
- package/lib/index.d.ts +2 -2
- package/lib/utils.d.ts +2 -5
- package/lib/utils.js +2 -3
- package/package.json +3 -3
package/lib/field-object.d.ts
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import { TypeObject } from "./type-object.js";
|
|
2
2
|
//#region src/field-object.d.ts
|
|
3
3
|
type Cardinality = ":cardinality/one-to-one" | ":cardinality/one-to-many" | ":cardinality/many-to-many" | ":cardinality/many-to-one";
|
|
4
|
+
type LinkRuleOperand = {
|
|
5
|
+
expression: unknown;
|
|
6
|
+
relationExpression: unknown;
|
|
7
|
+
operator: string;
|
|
8
|
+
};
|
|
9
|
+
type LinkRule = {
|
|
10
|
+
logicalOperator: string;
|
|
11
|
+
operands: Array<LinkRuleOperand>;
|
|
12
|
+
};
|
|
4
13
|
type RawFieldObject = {
|
|
5
14
|
"fibery/id": string;
|
|
6
15
|
"fibery/name": string;
|
|
@@ -19,7 +28,7 @@ type RawFieldObject = {
|
|
|
19
28
|
"formula/formula"?: unknown;
|
|
20
29
|
"formula/lookup?"?: boolean;
|
|
21
30
|
"link-rule/link-rule?"?: boolean;
|
|
22
|
-
"link-rule/link-rule"?:
|
|
31
|
+
"link-rule/link-rule"?: LinkRule;
|
|
23
32
|
"link-rule/disabled?"?: boolean;
|
|
24
33
|
"link-rule/disable-reason"?: string;
|
|
25
34
|
"fibery/relation"?: string;
|
|
@@ -58,7 +67,7 @@ declare class FieldObject {
|
|
|
58
67
|
formula: unknown | null;
|
|
59
68
|
isLookup: boolean;
|
|
60
69
|
hasLinkRule: boolean;
|
|
61
|
-
linkRule:
|
|
70
|
+
linkRule: LinkRule | null;
|
|
62
71
|
isLinkRuleDisabled: boolean;
|
|
63
72
|
linkRuleDisableReason: string | null;
|
|
64
73
|
relation: string | null;
|
|
@@ -89,4 +98,4 @@ declare class FieldObject {
|
|
|
89
98
|
get kind(): ":field/basic" | ":field/reference" | ":field/reference-collection";
|
|
90
99
|
}
|
|
91
100
|
//#endregion
|
|
92
|
-
export { Cardinality, FieldObject, FieldObjectParams, RawFieldObject };
|
|
101
|
+
export { Cardinality, FieldObject, FieldObjectParams, LinkRule, LinkRuleOperand, RawFieldObject };
|
package/lib/field-object.js
CHANGED
|
@@ -163,9 +163,10 @@ var FieldObject = class {
|
|
|
163
163
|
}
|
|
164
164
|
/** @deprecated use !typeObject.isPrimitive && cardinality === ... instead */
|
|
165
165
|
get kind() {
|
|
166
|
-
if (this.typeObject.isPrimitive)
|
|
167
|
-
|
|
168
|
-
|
|
166
|
+
if (this.typeObject.isPrimitive) {
|
|
167
|
+
if (this.isCollection) throw new Error("basic collection is not implemented");
|
|
168
|
+
else return ":field/basic";
|
|
169
|
+
} else if (this.isCollection) return ":field/reference-collection";
|
|
169
170
|
else return ":field/reference";
|
|
170
171
|
}
|
|
171
172
|
};
|
package/lib/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NotDefinedGetError } from "./errors.js";
|
|
2
2
|
import { RawTypeObject, SyncSource, TypeObject, TypeObjectParams } from "./type-object.js";
|
|
3
|
-
import { Cardinality, FieldObject, FieldObjectParams, RawFieldObject } from "./field-object.js";
|
|
3
|
+
import { Cardinality, FieldObject, FieldObjectParams, LinkRule, LinkRuleOperand, RawFieldObject } from "./field-object.js";
|
|
4
4
|
import { RawSchema, Schema } from "./schema.js";
|
|
5
5
|
import { Factory, factory, protectiveFactory } from "./factory.js";
|
|
6
6
|
import { attachEnumNamespace, capitalizeFirstChar, getTypeObjectTitle, makeEnumTypeNamePart, parseEnumType, parseType, removeDeletedTypesAndFields, toNonEnumTitle, toPascalCase, toTitle, toTypeOrFieldNamePartTitle, toTypeOrFieldTitle, withOnlyDefinedGets } from "./utils.js";
|
|
7
|
-
export { Cardinality, Factory, FieldObject, FieldObjectParams, NotDefinedGetError, RawFieldObject, RawSchema, RawTypeObject, Schema, SyncSource, TypeObject, TypeObjectParams, attachEnumNamespace, capitalizeFirstChar, factory, getTypeObjectTitle, makeEnumTypeNamePart, parseEnumType, parseType, protectiveFactory, removeDeletedTypesAndFields, toNonEnumTitle, toPascalCase, toTitle, toTypeOrFieldNamePartTitle, toTypeOrFieldTitle, withOnlyDefinedGets };
|
|
7
|
+
export { Cardinality, Factory, FieldObject, FieldObjectParams, LinkRule, LinkRuleOperand, NotDefinedGetError, RawFieldObject, RawSchema, RawTypeObject, Schema, SyncSource, TypeObject, TypeObjectParams, attachEnumNamespace, capitalizeFirstChar, factory, getTypeObjectTitle, makeEnumTypeNamePart, parseEnumType, parseType, protectiveFactory, removeDeletedTypesAndFields, toNonEnumTitle, toPascalCase, toTitle, toTypeOrFieldNamePartTitle, toTypeOrFieldTitle, withOnlyDefinedGets };
|
package/lib/utils.d.ts
CHANGED
|
@@ -15,13 +15,10 @@ declare const parseEnumType: (type: string) => {
|
|
|
15
15
|
targetNamespace: string;
|
|
16
16
|
};
|
|
17
17
|
declare const toTitle: (typeOrAttr: string) => string;
|
|
18
|
-
declare const parseType: (
|
|
18
|
+
declare const parseType: (type: string) => {
|
|
19
19
|
namespace: string;
|
|
20
20
|
name: string;
|
|
21
|
-
}
|
|
22
|
-
namespace: string;
|
|
23
|
-
name: string;
|
|
24
|
-
}>;
|
|
21
|
+
};
|
|
25
22
|
declare const makeEnumTypeNamePart: ({ holderType, enumName }: {
|
|
26
23
|
holderType: string;
|
|
27
24
|
enumName: string;
|
package/lib/utils.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { NotDefinedGetError } from "./errors.js";
|
|
2
2
|
import { printJsPath } from "./print-utils.js";
|
|
3
|
-
import { memoize } from "@fibery/helpers/src/_";
|
|
4
3
|
import { traceError } from "@fibery/helpers/utils/trace";
|
|
5
4
|
import capitalize from "lodash/capitalize.js";
|
|
6
5
|
import flow from "lodash/flow.js";
|
|
@@ -88,10 +87,10 @@ const splitKeyword = (keyword) => {
|
|
|
88
87
|
name: str.substring(index + 1)
|
|
89
88
|
};
|
|
90
89
|
};
|
|
91
|
-
const parseType =
|
|
90
|
+
const parseType = (type) => {
|
|
92
91
|
if (!type.includes("/")) traceError(`parseType invalid usage: passed type is '${type}'`);
|
|
93
92
|
return splitKeyword(type);
|
|
94
|
-
}
|
|
93
|
+
};
|
|
95
94
|
const makeEnumTypeNamePart = ({ holderType, enumName }) => {
|
|
96
95
|
const { namespace, name } = parseType(holderType);
|
|
97
96
|
return `${enumName}_${namespace}/${name}`;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fibery/schema",
|
|
3
|
-
"version": "10.3.
|
|
3
|
+
"version": "10.3.2",
|
|
4
4
|
"description": "Fibery schema utils",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"files": [
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"lodash": "4.17.21",
|
|
25
|
-
"@fibery/
|
|
26
|
-
"@fibery/
|
|
25
|
+
"@fibery/pluralize": "1.2.1",
|
|
26
|
+
"@fibery/helpers": "3.3.0"
|
|
27
27
|
}
|
|
28
28
|
}
|