@fibery/schema 13.1.4 → 13.1.5
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/brands.d.ts +1 -3
- package/lib/errors.d.ts +1 -3
- package/lib/errors.js +1 -2
- package/lib/factory.d.ts +3 -5
- package/lib/factory.js +2 -3
- package/lib/field-keys.d.ts +1 -3
- package/lib/field-object.d.ts +2 -4
- package/lib/field-object.js +1 -2
- package/lib/index.d.ts +4 -4
- package/lib/index.js +4 -4
- package/lib/print-utils.d.ts +1 -3
- package/lib/print-utils.js +1 -2
- package/lib/query-expression.d.ts +1 -3
- package/lib/schema.d.ts +2 -4
- package/lib/schema.js +1 -2
- package/lib/type-object.d.ts +2 -4
- package/lib/type-object.js +1 -2
- package/lib/utils.d.ts +2 -4
- package/lib/utils.js +1 -2
- package/package.json +2 -2
package/lib/brands.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { Holder, Kind } from "@fibery/helpers/utils/types";
|
|
2
|
-
//#region src/brands.d.ts
|
|
3
2
|
export type Id = string & Kind<"id">;
|
|
4
3
|
export type PublicId = string & Kind<"publicId">;
|
|
5
4
|
export type Name = string & Kind<"name">;
|
|
@@ -21,5 +20,4 @@ export type SpaceName = string & Kind<"name"> & Holder<"space">;
|
|
|
21
20
|
* `String.prototype` optional, and the getters index a lookup map with the
|
|
22
21
|
* parameter.
|
|
23
22
|
*/
|
|
24
|
-
export type Permissive<B extends string> = string & Partial<B>;
|
|
25
|
-
//#endregion
|
|
23
|
+
export type Permissive<B extends string> = string & Partial<B>;
|
package/lib/errors.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/errors.d.ts
|
|
2
1
|
export declare class NotDefinedGetError extends Error {}
|
|
3
2
|
export type NotFoundNames = {
|
|
4
3
|
typeId?: string;
|
|
@@ -21,5 +20,4 @@ export declare class NotFoundError extends Error {
|
|
|
21
20
|
readonly fieldId: string | undefined;
|
|
22
21
|
readonly fieldName: string | undefined;
|
|
23
22
|
constructor(what: "type" | "field", { typeId, typeName, fieldId, fieldName }: NotFoundNames);
|
|
24
|
-
}
|
|
25
|
-
//#endregion
|
|
23
|
+
}
|
package/lib/errors.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/errors.ts
|
|
2
2
|
var NotDefinedGetError = class extends Error {};
|
|
3
3
|
/**
|
|
4
4
|
* `message` says only what kind of thing was missing, so it is a safe Sentry title and a
|
|
@@ -24,5 +24,4 @@ var NotFoundError = class extends Error {
|
|
|
24
24
|
this.fieldName = fieldName;
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
|
-
//#endregion
|
|
28
27
|
export { NotDefinedGetError, NotFoundError };
|
package/lib/factory.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { EntityId, FieldId, SpaceId, TypeId } from "./brands.js";
|
|
2
|
-
import { TypeObject, TypeObjectParams } from "./type-object.js";
|
|
3
|
-
import { Schema } from "./schema.js";
|
|
4
2
|
import { FieldObject, FieldObjectParams } from "./field-object.js";
|
|
5
|
-
|
|
3
|
+
import { Schema } from "./schema.js";
|
|
4
|
+
import { TypeObject, TypeObjectParams } from "./type-object.js";
|
|
6
5
|
export type Factory = {
|
|
7
6
|
makeSchema: (rawSchema: Record<string, unknown>, options?: {
|
|
8
7
|
shouldRemoveDeletedTypesAndFields: boolean;
|
|
@@ -34,5 +33,4 @@ export declare const mintUuidV7Everywhere: () => void;
|
|
|
34
33
|
export declare const makeEntityId: (version?: LegacyUuidVersion) => EntityId;
|
|
35
34
|
export declare const makeTypeId: (version?: LegacyUuidVersion) => TypeId;
|
|
36
35
|
export declare const makeFieldId: (version?: LegacyUuidVersion) => FieldId;
|
|
37
|
-
export declare const makeSpaceId: (version?: LegacyUuidVersion) => SpaceId;
|
|
38
|
-
//#endregion
|
|
36
|
+
export declare const makeSpaceId: (version?: LegacyUuidVersion) => SpaceId;
|
package/lib/factory.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { removeDeletedTypesAndFields } from "./utils.js";
|
|
2
1
|
import { FieldObject } from "./field-object.js";
|
|
3
2
|
import { Schema } from "./schema.js";
|
|
4
3
|
import { TypeObject } from "./type-object.js";
|
|
4
|
+
import { removeDeletedTypesAndFields } from "./utils.js";
|
|
5
5
|
import keyBy from "lodash/keyBy.js";
|
|
6
6
|
import { v1, v4, v7 } from "uuid";
|
|
7
|
-
|
|
7
|
+
// src/factory.ts
|
|
8
8
|
const makeSchema = (rawSchema, options = { shouldRemoveDeletedTypesAndFields: true }) => new Schema({
|
|
9
9
|
rawSchema: options.shouldRemoveDeletedTypesAndFields ? removeDeletedTypesAndFields(rawSchema) : rawSchema,
|
|
10
10
|
factory
|
|
@@ -36,5 +36,4 @@ const makeEntityId = (version) => mint(version);
|
|
|
36
36
|
const makeTypeId = (version) => mint(version);
|
|
37
37
|
const makeFieldId = (version) => mint(version);
|
|
38
38
|
const makeSpaceId = (version) => mint(version);
|
|
39
|
-
//#endregion
|
|
40
39
|
export { factory, makeEntityId, makeFieldId, makeFieldObject, makeFieldObjectsById, makeFieldObjectsByName, makeSchema, makeSpaceId, makeTypeId, makeTypeObject, makeTypeObjectsById, makeTypeObjectsByName, mintUuidV7Everywhere };
|
package/lib/field-keys.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
//#region src/field-keys.d.ts
|
|
2
1
|
export type IdField = "fibery/id";
|
|
3
2
|
export type PublicIdField = "fibery/public-id";
|
|
4
3
|
export type RankField = "fibery/rank";
|
|
5
|
-
export type TitleField = "__NOTHING_INTERESTING__TitleField__";
|
|
6
|
-
//#endregion
|
|
4
|
+
export type TitleField = "__NOTHING_INTERESTING__TitleField__";
|
package/lib/field-object.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { FieldId, FieldName, SpaceName, TypeName } from "./brands.js";
|
|
2
2
|
import { Expression, SubQuery } from "./query-expression.js";
|
|
3
|
-
import { TypeObject } from "./type-object.js";
|
|
4
3
|
import { SchemaRef } from "./schema.js";
|
|
5
|
-
|
|
4
|
+
import { TypeObject } from "./type-object.js";
|
|
6
5
|
export type Cardinality = ":cardinality/one-to-one" | ":cardinality/one-to-many" | ":cardinality/many-to-many" | ":cardinality/many-to-one";
|
|
7
6
|
export type LinkRuleOperand = {
|
|
8
7
|
expression: unknown;
|
|
@@ -140,5 +139,4 @@ export declare class FieldObject {
|
|
|
140
139
|
get cardinality(): Cardinality;
|
|
141
140
|
/** @deprecated use !typeObject.isPrimitive && cardinality === ... instead */
|
|
142
141
|
get kind(): ":field/basic" | ":field/reference" | ":field/reference-collection";
|
|
143
|
-
}
|
|
144
|
-
//#endregion
|
|
142
|
+
}
|
package/lib/field-object.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NotFoundError } from "./errors.js";
|
|
2
2
|
import { parseType, toNonEnumTitle } from "./utils.js";
|
|
3
3
|
import { isPlainObject } from "@fibery/helpers/src/object";
|
|
4
|
-
|
|
4
|
+
// src/field-object.ts
|
|
5
5
|
const EMPTY_META = Object.freeze({});
|
|
6
6
|
const EMPTY_FIELD_OBJECTS = Object.freeze([]);
|
|
7
7
|
const nameParts = /* @__PURE__ */ new WeakMap();
|
|
@@ -239,5 +239,4 @@ var FieldObject = class {
|
|
|
239
239
|
else return ":field/reference";
|
|
240
240
|
}
|
|
241
241
|
};
|
|
242
|
-
//#endregion
|
|
243
242
|
export { FieldObject };
|
package/lib/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { EntityId, FieldId, FieldName, Id, Name, Permissive, PublicId, SpaceId, SpaceName, TypeId, TypeName } from "./brands.js";
|
|
2
|
-
import {
|
|
3
|
-
import { Expression, ExpressionArgument, FieldExpression, FromRootExpression, FunctionCallExpression, MultiFieldAccess, OrderBy, Query, QueryLimit, Select, SubQuery } from "./query-expression.js";
|
|
4
|
-
import { RawTypeObject, SyncSource, TypeObject, TypeObjectFactory, TypeObjectParams } from "./type-object.js";
|
|
2
|
+
import { Factory, LegacyUuidVersion, factory, makeEntityId, makeFieldId, makeFieldObject, makeFieldObjectsById, makeFieldObjectsByName, makeSchema, makeSpaceId, makeTypeId, makeTypeObject, makeTypeObjectsById, makeTypeObjectsByName, mintUuidV7Everywhere } from "./factory.js";
|
|
5
3
|
import { RawSchema, Schema, SchemaRef } from "./schema.js";
|
|
4
|
+
import { RawTypeObject, SyncSource, TypeObject, TypeObjectFactory, TypeObjectParams } from "./type-object.js";
|
|
6
5
|
import { Cardinality, FieldObject, FieldObjectParams, LinkRule, LinkRuleOperand, RawFieldFormula, RawFieldObject, SyncField, SyncRelation } from "./field-object.js";
|
|
7
|
-
import { Factory, LegacyUuidVersion, factory, makeEntityId, makeFieldId, makeFieldObject, makeFieldObjectsById, makeFieldObjectsByName, makeSchema, makeSpaceId, makeTypeId, makeTypeObject, makeTypeObjectsById, makeTypeObjectsByName, mintUuidV7Everywhere } from "./factory.js";
|
|
8
6
|
import { attachEnumNamespace, capitalizeFirstChar, getTypeObjectTitle, isOneOf, makeEnumTypeNamePart, parseEnumType, parseType, removeDeletedTypesAndFields, toNonEnumTitle, toPascalCase, toTitle, toTypeOrFieldNamePartTitle, toTypeOrFieldTitle, withOnlyDefinedGets } from "./utils.js";
|
|
7
|
+
import { NotDefinedGetError, NotFoundError, NotFoundNames } from "./errors.js";
|
|
8
|
+
import { Expression, ExpressionArgument, FieldExpression, FromRootExpression, FunctionCallExpression, MultiFieldAccess, OrderBy, Query, QueryLimit, Select, SubQuery } from "./query-expression.js";
|
|
9
9
|
export { Cardinality, EntityId, type Expression, type ExpressionArgument, Factory, type FieldExpression, FieldId, FieldName, FieldObject, FieldObjectParams, type FromRootExpression, type FunctionCallExpression, Id, LegacyUuidVersion, LinkRule, LinkRuleOperand, type MultiFieldAccess, Name, NotDefinedGetError, NotFoundError, NotFoundNames, type OrderBy, Permissive, PublicId, type Query, type QueryLimit, RawFieldFormula, RawFieldObject, RawSchema, RawTypeObject, Schema, SchemaRef, type Select, SpaceId, SpaceName, type SubQuery, SyncField, SyncRelation, SyncSource, TypeId, TypeName, TypeObject, TypeObjectFactory, TypeObjectParams, attachEnumNamespace, capitalizeFirstChar, factory, getTypeObjectTitle, isOneOf, makeEntityId, makeEnumTypeNamePart, makeFieldId, makeFieldObject, makeFieldObjectsById, makeFieldObjectsByName, makeSchema, makeSpaceId, makeTypeId, makeTypeObject, makeTypeObjectsById, makeTypeObjectsByName, mintUuidV7Everywhere, parseEnumType, parseType, removeDeletedTypesAndFields, toNonEnumTitle, toPascalCase, toTitle, toTypeOrFieldNamePartTitle, toTypeOrFieldTitle, withOnlyDefinedGets };
|
package/lib/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { attachEnumNamespace, capitalizeFirstChar, getTypeObjectTitle, isOneOf, makeEnumTypeNamePart, parseEnumType, parseType, removeDeletedTypesAndFields, toNonEnumTitle, toPascalCase, toTitle, toTypeOrFieldNamePartTitle, toTypeOrFieldTitle, withOnlyDefinedGets } from "./utils.js";
|
|
3
|
-
import { FieldObject } from "./field-object.js";
|
|
1
|
+
import { factory, makeEntityId, makeFieldId, makeFieldObject, makeFieldObjectsById, makeFieldObjectsByName, makeSchema, makeSpaceId, makeTypeId, makeTypeObject, makeTypeObjectsById, makeTypeObjectsByName, mintUuidV7Everywhere } from "./factory.js";
|
|
4
2
|
import { Schema } from "./schema.js";
|
|
5
3
|
import { TypeObject } from "./type-object.js";
|
|
6
|
-
import {
|
|
4
|
+
import { FieldObject } from "./field-object.js";
|
|
5
|
+
import { attachEnumNamespace, capitalizeFirstChar, getTypeObjectTitle, isOneOf, makeEnumTypeNamePart, parseEnumType, parseType, removeDeletedTypesAndFields, toNonEnumTitle, toPascalCase, toTitle, toTypeOrFieldNamePartTitle, toTypeOrFieldTitle, withOnlyDefinedGets } from "./utils.js";
|
|
6
|
+
import { NotDefinedGetError, NotFoundError } from "./errors.js";
|
|
7
7
|
export { FieldObject, NotDefinedGetError, NotFoundError, Schema, TypeObject, attachEnumNamespace, capitalizeFirstChar, factory, getTypeObjectTitle, isOneOf, makeEntityId, makeEnumTypeNamePart, makeFieldId, makeFieldObject, makeFieldObjectsById, makeFieldObjectsByName, makeSchema, makeSpaceId, makeTypeId, makeTypeObject, makeTypeObjectsById, makeTypeObjectsByName, mintUuidV7Everywhere, parseEnumType, parseType, removeDeletedTypesAndFields, toNonEnumTitle, toPascalCase, toTitle, toTypeOrFieldNamePartTitle, toTypeOrFieldTitle, withOnlyDefinedGets };
|
package/lib/print-utils.d.ts
CHANGED
package/lib/print-utils.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
// src/print-utils.ts
|
|
2
2
|
const validIdentifierRegExp = /^[a-zA-Z_$][0-9a-zA-Z_$]*$/;
|
|
3
3
|
const isValidIdentifier = (x) => validIdentifierRegExp.test(x);
|
|
4
4
|
const printJsPath = (keys) => keys.map((key) => isValidIdentifier(key) ? "." + key : `["${key}"]`).join("");
|
|
5
|
-
//#endregion
|
|
6
5
|
export { isValidIdentifier, printJsPath };
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/query-expression.d.ts
|
|
2
1
|
export type MultiFieldAccess = [string, string];
|
|
3
2
|
export type FieldExpression = Array<string | MultiFieldAccess>;
|
|
4
3
|
export type ExpressionArgument = Expression | SubQuery | number;
|
|
@@ -34,5 +33,4 @@ export type SubQuery = {
|
|
|
34
33
|
"q/order-by"?: OrderBy;
|
|
35
34
|
"q/limit"?: QueryLimit;
|
|
36
35
|
"q/where"?: Expression;
|
|
37
|
-
};
|
|
38
|
-
//#endregion
|
|
36
|
+
};
|
package/lib/schema.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Permissive, TypeId, TypeName } from "./brands.js";
|
|
2
|
-
import { RawTypeObject, TypeObject } from "./type-object.js";
|
|
3
2
|
import { FieldObject } from "./field-object.js";
|
|
3
|
+
import { RawTypeObject, TypeObject } from "./type-object.js";
|
|
4
4
|
import { Factory } from "@fibery/schema/src/factory";
|
|
5
|
-
//#region src/schema.d.ts
|
|
6
5
|
export type RawSchema = {
|
|
7
6
|
"fibery/id": string;
|
|
8
7
|
"fibery/types": RawTypeObject[];
|
|
@@ -45,5 +44,4 @@ export declare class Schema implements SchemaRef {
|
|
|
45
44
|
getTypeObjectByName(typeName: Permissive<TypeName>): TypeObject | null;
|
|
46
45
|
getTypeObjectByIdOrThrow(typeId: Permissive<TypeId>): TypeObject;
|
|
47
46
|
getTypeObjectByNameOrThrow(typeName: Permissive<TypeName>): TypeObject;
|
|
48
|
-
}
|
|
49
|
-
//#endregion
|
|
47
|
+
}
|
package/lib/schema.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NotFoundError } from "./errors.js";
|
|
2
|
-
|
|
2
|
+
// src/schema.ts
|
|
3
3
|
const EMPTY_FIELD_OBJECTS = Object.freeze([]);
|
|
4
4
|
const typeComponentFieldObjects = /* @__PURE__ */ new WeakMap();
|
|
5
5
|
const multiRelatedFieldObjects = /* @__PURE__ */ new WeakMap();
|
|
@@ -99,5 +99,4 @@ var Schema = class {
|
|
|
99
99
|
return typeObject;
|
|
100
100
|
}
|
|
101
101
|
};
|
|
102
|
-
//#endregion
|
|
103
102
|
export { Schema };
|
package/lib/type-object.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { FieldId, FieldName, Permissive, SpaceName, TypeId, TypeName } from "./brands.js";
|
|
2
|
-
import { SchemaRef } from "./schema.js";
|
|
3
2
|
import { FieldObject, FieldObjectParams, RawFieldObject } from "./field-object.js";
|
|
4
|
-
|
|
3
|
+
import { SchemaRef } from "./schema.js";
|
|
5
4
|
export type SyncSource = {
|
|
6
5
|
appId: string;
|
|
7
6
|
appName: string;
|
|
@@ -101,5 +100,4 @@ export declare class TypeObject {
|
|
|
101
100
|
get titleFieldObject(): FieldObject;
|
|
102
101
|
get rankField(): "fibery/rank" | null;
|
|
103
102
|
get rankFieldObject(): FieldObject | null;
|
|
104
|
-
}
|
|
105
|
-
//#endregion
|
|
103
|
+
}
|
package/lib/type-object.js
CHANGED
|
@@ -3,7 +3,7 @@ import { parseType, toTitle } from "./utils.js";
|
|
|
3
3
|
import { isPlainObject } from "@fibery/helpers/src/object";
|
|
4
4
|
import { truthy } from "@fibery/helpers/src/_";
|
|
5
5
|
import { pluralize } from "@fibery/pluralize";
|
|
6
|
-
|
|
6
|
+
// src/type-object.ts
|
|
7
7
|
const EMPTY_META = Object.freeze({});
|
|
8
8
|
const DEFAULT_COLOR = "#4978D4";
|
|
9
9
|
var TypeObject = class {
|
|
@@ -255,5 +255,4 @@ var TypeObject = class {
|
|
|
255
255
|
return this.known.rankFieldObject;
|
|
256
256
|
}
|
|
257
257
|
};
|
|
258
|
-
//#endregion
|
|
259
258
|
export { TypeObject };
|
package/lib/utils.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { SpaceName, TypeName } from "./brands.js";
|
|
2
|
-
import { RawTypeObject, TypeObject } from "./type-object.js";
|
|
3
2
|
import { RawSchema } from "./schema.js";
|
|
4
|
-
|
|
3
|
+
import { RawTypeObject, TypeObject } from "./type-object.js";
|
|
5
4
|
export declare const withOnlyDefinedGets: (target: any, targetKind?: string) => any;
|
|
6
5
|
export declare const capitalizeFirstChar: (input: string) => string;
|
|
7
6
|
export declare const toTypeOrFieldNamePartTitle: (str: string | null | undefined) => string;
|
|
@@ -34,5 +33,4 @@ export declare const removeDeletedTypesAndFields: (rawSchema: RawSchema) => {
|
|
|
34
33
|
};
|
|
35
34
|
export declare const getTypeObjectTitle: (typeObject: TypeObject, form?: "singular" | "plural") => string;
|
|
36
35
|
/** `===` does not narrow a branded string (`TypeName`, `FieldName`) to a literal; this does. */
|
|
37
|
-
export declare const isOneOf: <const L extends readonly string[]>(value: string, literals: L) => value is L[number];
|
|
38
|
-
//#endregion
|
|
36
|
+
export declare const isOneOf: <const L extends readonly string[]>(value: string, literals: L) => value is L[number];
|
package/lib/utils.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NotDefinedGetError } from "./errors.js";
|
|
2
2
|
import { printJsPath } from "./print-utils.js";
|
|
3
3
|
import { traceError } from "@fibery/helpers/utils/trace";
|
|
4
|
-
|
|
4
|
+
// src/utils.ts
|
|
5
5
|
const testRunnerKeys = /* @__PURE__ */ new Set([
|
|
6
6
|
"nodeType",
|
|
7
7
|
"tagName",
|
|
@@ -139,5 +139,4 @@ const removeDeletedTypesAndFields = (rawSchema) => {
|
|
|
139
139
|
const getTypeObjectTitle = (typeObject, form) => form ? form === "singular" ? typeObject.singularTitle : typeObject.pluralTitle : typeObject.title;
|
|
140
140
|
/** `===` does not narrow a branded string (`TypeName`, `FieldName`) to a literal; this does. */
|
|
141
141
|
const isOneOf = (value, literals) => literals.includes(value);
|
|
142
|
-
//#endregion
|
|
143
142
|
export { attachEnumNamespace, capitalizeFirstChar, getTypeObjectTitle, isOneOf, makeEnumTypeNamePart, parseEnumType, parseType, removeDeletedTypesAndFields, toNonEnumTitle, toPascalCase, toTitle, toTypeOrFieldNamePartTitle, toTypeOrFieldTitle, withOnlyDefinedGets };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fibery/schema",
|
|
3
|
-
"version": "13.1.
|
|
3
|
+
"version": "13.1.5",
|
|
4
4
|
"description": "Fibery schema utils",
|
|
5
5
|
"license": "UNLICENSED",
|
|
6
6
|
"files": [
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
}
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@fibery/helpers": "
|
|
24
|
+
"@fibery/helpers": "7.0.0",
|
|
25
25
|
"@fibery/pluralize": "1.2.1",
|
|
26
26
|
"lodash": "4.18.1",
|
|
27
27
|
"uuid": "11.1.0"
|