@fibery/schema 13.0.2 → 13.1.0

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 CHANGED
@@ -1,15 +1,15 @@
1
1
  import { Holder, Kind } from "@fibery/helpers/utils/types";
2
2
  //#region src/brands.d.ts
3
- type Id = string & Kind<"id">;
4
- type PublicId = string & Kind<"publicId">;
5
- type Name = string & Kind<"name">;
6
- type TypeId = string & Kind<"id"> & Holder<"type">;
7
- type FieldId = string & Kind<"id"> & Holder<"field">;
8
- type EntityId = string & Kind<"id"> & Holder<"entity">;
9
- type SpaceId = string & Kind<"id"> & Holder<"space">;
10
- type TypeName = string & Kind<"name"> & Holder<"type">;
11
- type FieldName = string & Kind<"name"> & Holder<"field">;
12
- type SpaceName = string & Kind<"name"> & Holder<"space">;
3
+ export type Id = string & Kind<"id">;
4
+ export type PublicId = string & Kind<"publicId">;
5
+ export type Name = string & Kind<"name">;
6
+ export type TypeId = string & Kind<"id"> & Holder<"type">;
7
+ export type FieldId = string & Kind<"id"> & Holder<"field">;
8
+ export type EntityId = string & Kind<"id"> & Holder<"entity">;
9
+ export type SpaceId = string & Kind<"id"> & Holder<"space">;
10
+ export type TypeName = string & Kind<"name"> & Holder<"type">;
11
+ export type FieldName = string & Kind<"name"> & Holder<"field">;
12
+ export type SpaceName = string & Kind<"name"> & Holder<"space">;
13
13
  /**
14
14
  * A brand with its tags made optional, for lookup parameters.
15
15
  *
@@ -21,6 +21,5 @@ type SpaceName = string & Kind<"name"> & Holder<"space">;
21
21
  * `String.prototype` optional, and the getters index a lookup map with the
22
22
  * parameter.
23
23
  */
24
- type Permissive<B extends string> = string & Partial<B>;
25
- //#endregion
26
- export { EntityId, FieldId, FieldName, Id, Name, Permissive, PublicId, SpaceId, SpaceName, TypeId, TypeName };
24
+ export type Permissive<B extends string> = string & Partial<B>;
25
+ //#endregion
package/lib/errors.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  //#region src/errors.d.ts
2
- declare class NotDefinedGetError extends Error {}
3
- type NotFoundNames = {
2
+ export declare class NotDefinedGetError extends Error {}
3
+ export type NotFoundNames = {
4
4
  typeId?: string;
5
5
  typeName?: string;
6
6
  fieldId?: string;
@@ -14,7 +14,7 @@ type NotFoundNames = {
14
14
  * Throw sites fill in both the id and the name wherever they can resolve one: a bare uuid is
15
15
  * unactionable in an issue, and a name alone will not survive a rename.
16
16
  */
17
- declare class NotFoundError extends Error {
17
+ export declare class NotFoundError extends Error {
18
18
  readonly what: "type" | "field";
19
19
  readonly typeId: string | undefined;
20
20
  readonly typeName: string | undefined;
@@ -22,5 +22,4 @@ declare class NotFoundError extends Error {
22
22
  readonly fieldName: string | undefined;
23
23
  constructor(what: "type" | "field", { typeId, typeName, fieldId, fieldName }: NotFoundNames);
24
24
  }
25
- //#endregion
26
- export { NotDefinedGetError, NotFoundError, NotFoundNames };
25
+ //#endregion
package/lib/factory.d.ts CHANGED
@@ -1,8 +1,9 @@
1
+ import { EntityId, FieldId, SpaceId, TypeId } from "./brands.js";
1
2
  import { TypeObject, TypeObjectParams } from "./type-object.js";
2
3
  import { Schema } from "./schema.js";
3
4
  import { FieldObject, FieldObjectParams } from "./field-object.js";
4
5
  //#region src/factory.d.ts
5
- type Factory = {
6
+ export type Factory = {
6
7
  makeSchema: (rawSchema: Record<string, unknown>, options?: {
7
8
  shouldRemoveDeletedTypesAndFields: boolean;
8
9
  }) => Schema;
@@ -19,7 +20,19 @@ type Factory = {
19
20
  fieldObjects: ReadonlyArray<FieldObject>;
20
21
  }) => Readonly<Record<string, FieldObject>>;
21
22
  };
22
- declare const factory: Factory;
23
- declare const protectiveFactory: Factory;
24
- //#endregion
25
- export { Factory, factory, protectiveFactory };
23
+ export declare const makeSchema: Factory["makeSchema"];
24
+ export declare const makeTypeObject: Factory["makeTypeObject"];
25
+ export declare const makeTypeObjectsById: Factory["makeTypeObjectsById"];
26
+ export declare const makeTypeObjectsByName: Factory["makeTypeObjectsByName"];
27
+ export declare const makeFieldObject: Factory["makeFieldObject"];
28
+ export declare const makeFieldObjectsById: Factory["makeFieldObjectsById"];
29
+ export declare const makeFieldObjectsByName: Factory["makeFieldObjectsByName"];
30
+ export declare const factory: Factory;
31
+ /** Existing callers pin the version they persisted with; new ids are v7 until those migrate. */
32
+ export type LegacyUuidVersion = 1 | 4;
33
+ export declare const mintUuidV7Everywhere: () => void;
34
+ export declare const makeEntityId: (version?: LegacyUuidVersion) => EntityId;
35
+ export declare const makeTypeId: (version?: LegacyUuidVersion) => TypeId;
36
+ export declare const makeFieldId: (version?: LegacyUuidVersion) => FieldId;
37
+ export declare const makeSpaceId: (version?: LegacyUuidVersion) => SpaceId;
38
+ //#endregion
package/lib/factory.js CHANGED
@@ -1,44 +1,40 @@
1
- import { removeDeletedTypesAndFields, withOnlyDefinedGets } from "./utils.js";
1
+ import { removeDeletedTypesAndFields } from "./utils.js";
2
2
  import { FieldObject } from "./field-object.js";
3
3
  import { Schema } from "./schema.js";
4
4
  import { TypeObject } from "./type-object.js";
5
5
  import keyBy from "lodash/keyBy.js";
6
+ import { v1, v4, v7 } from "uuid";
6
7
  //#region src/factory.ts
8
+ const makeSchema = (rawSchema, options = { shouldRemoveDeletedTypesAndFields: true }) => new Schema({
9
+ rawSchema: options.shouldRemoveDeletedTypesAndFields ? removeDeletedTypesAndFields(rawSchema) : rawSchema,
10
+ factory
11
+ });
12
+ const makeTypeObject = (args) => new TypeObject({
13
+ ...args,
14
+ factory
15
+ });
16
+ const makeTypeObjectsById = (typeObjects) => keyBy(typeObjects, (x) => x.id);
17
+ const makeTypeObjectsByName = (typeObjects) => keyBy(typeObjects, (x) => x.name);
18
+ const makeFieldObject = (args) => new FieldObject(args);
19
+ const makeFieldObjectsById = ({ fieldObjects }) => keyBy(fieldObjects, (x) => x.id);
20
+ const makeFieldObjectsByName = ({ fieldObjects }) => keyBy(fieldObjects, (x) => x.name);
7
21
  const factory = {
8
- makeSchema: (rawSchema, options = { shouldRemoveDeletedTypesAndFields: true }) => new Schema({
9
- rawSchema: options.shouldRemoveDeletedTypesAndFields ? removeDeletedTypesAndFields(rawSchema) : rawSchema,
10
- factory
11
- }),
12
- makeTypeObject: (args) => new TypeObject({
13
- ...args,
14
- factory
15
- }),
16
- makeTypeObjectsById: (typeObjects) => keyBy(typeObjects, (x) => x.id),
17
- makeTypeObjectsByName: (typeObjects) => keyBy(typeObjects, (x) => x.name),
18
- makeFieldObject: (args) => new FieldObject(args),
19
- makeFieldObjectsById: ({ fieldObjects }) => keyBy(fieldObjects, (x) => x.id),
20
- makeFieldObjectsByName: ({ fieldObjects }) => keyBy(fieldObjects, (x) => x.name)
22
+ makeSchema,
23
+ makeTypeObject,
24
+ makeTypeObjectsById,
25
+ makeTypeObjectsByName,
26
+ makeFieldObject,
27
+ makeFieldObjectsById,
28
+ makeFieldObjectsByName
21
29
  };
22
- const protectiveFactory = {
23
- makeSchema: (rawSchema, options = { shouldRemoveDeletedTypesAndFields: true }) => withOnlyDefinedGets(new Schema({
24
- rawSchema: options.shouldRemoveDeletedTypesAndFields ? removeDeletedTypesAndFields(rawSchema) : rawSchema,
25
- factory: protectiveFactory
26
- }), `schema`),
27
- makeTypeObject: (args) => {
28
- const typeObject = new TypeObject({
29
- ...args,
30
- factory: protectiveFactory
31
- });
32
- return withOnlyDefinedGets(typeObject, `schema.typeObjectsByName["${typeObject.name}"]`);
33
- },
34
- makeTypeObjectsById: (typeObjects) => withOnlyDefinedGets(keyBy(typeObjects, (x) => x.id), "schema.typeObjectsById"),
35
- makeTypeObjectsByName: (typeObjects) => withOnlyDefinedGets(keyBy(typeObjects, (x) => x.name), "schema.typeObjectsByName"),
36
- makeFieldObject: (args) => {
37
- const fieldObject = new FieldObject(args);
38
- return withOnlyDefinedGets(fieldObject, `schema.typeObjectsByName["${fieldObject.holderType}"].fieldObjectsByName["${fieldObject.name}"]`);
39
- },
40
- makeFieldObjectsById: ({ type, fieldObjects }) => withOnlyDefinedGets(keyBy(fieldObjects, (x) => x.id), `schema.typeObjectsByName["${type}"].fieldObjectsById`),
41
- makeFieldObjectsByName: ({ type, fieldObjects }) => withOnlyDefinedGets(keyBy(fieldObjects, (x) => x.name), `schema.typeObjectsByName["${type}"].fieldObjectsByName`)
30
+ let v7Everywhere = false;
31
+ const mintUuidV7Everywhere = () => {
32
+ v7Everywhere = true;
42
33
  };
34
+ const mint = (version) => v7Everywhere || version === void 0 ? v7() : version === 1 ? v1() : v4();
35
+ const makeEntityId = (version) => mint(version);
36
+ const makeTypeId = (version) => mint(version);
37
+ const makeFieldId = (version) => mint(version);
38
+ const makeSpaceId = (version) => mint(version);
43
39
  //#endregion
44
- export { factory, protectiveFactory };
40
+ export { factory, makeEntityId, makeFieldId, makeFieldObject, makeFieldObjectsById, makeFieldObjectsByName, makeSchema, makeSpaceId, makeTypeId, makeTypeObject, makeTypeObjectsById, makeTypeObjectsByName, mintUuidV7Everywhere };
@@ -1,7 +1,6 @@
1
1
  //#region src/field-keys.d.ts
2
- type IdField = "fibery/id";
3
- type PublicIdField = "fibery/public-id";
4
- type RankField = "fibery/rank";
5
- type TitleField = "__NOTHING_INTERESTING__TitleField__";
6
- //#endregion
7
- export { IdField, PublicIdField, RankField, TitleField };
2
+ export type IdField = "fibery/id";
3
+ export type PublicIdField = "fibery/public-id";
4
+ export type RankField = "fibery/rank";
5
+ export type TitleField = "__NOTHING_INTERESTING__TitleField__";
6
+ //#endregion
@@ -1,22 +1,23 @@
1
1
  import { FieldId, FieldName, SpaceName, TypeName } from "./brands.js";
2
+ import { Expression, SubQuery } from "./query-expression.js";
2
3
  import { TypeObject } from "./type-object.js";
3
4
  import { SchemaRef } from "./schema.js";
4
5
  //#region src/field-object.d.ts
5
- type Cardinality = ":cardinality/one-to-one" | ":cardinality/one-to-many" | ":cardinality/many-to-many" | ":cardinality/many-to-one";
6
- type LinkRuleOperand = {
6
+ export type Cardinality = ":cardinality/one-to-one" | ":cardinality/one-to-many" | ":cardinality/many-to-many" | ":cardinality/many-to-one";
7
+ export type LinkRuleOperand = {
7
8
  expression: unknown;
8
9
  relationExpression: unknown;
9
10
  operator: string;
10
11
  };
11
- type LinkRule = {
12
+ export type LinkRule = {
12
13
  logicalOperator: string;
13
14
  operands: Array<LinkRuleOperand>;
14
15
  };
15
- type SyncField = {
16
+ export type SyncField = {
16
17
  id: string;
17
18
  type: string;
18
19
  };
19
- type SyncRelation = {
20
+ export type SyncRelation = {
20
21
  id: string;
21
22
  name: string;
22
23
  type: string;
@@ -24,7 +25,11 @@ type SyncRelation = {
24
25
  targetName: string;
25
26
  targetFieldId: FieldId;
26
27
  };
27
- type RawFieldObject = {
28
+ export type RawFieldFormula = {
29
+ expression?: Expression | SubQuery | null;
30
+ params?: Record<string, unknown>;
31
+ };
32
+ export type RawFieldObject = {
28
33
  "fibery/id": FieldId;
29
34
  "fibery/name": FieldName;
30
35
  "fibery/type": TypeName;
@@ -39,7 +44,7 @@ type RawFieldObject = {
39
44
  "formula/formula?"?: boolean;
40
45
  "formula/disabled?"?: boolean;
41
46
  "formula/disable-reason"?: string;
42
- "formula/formula"?: unknown;
47
+ "formula/formula"?: RawFieldFormula | null;
43
48
  "formula/lookup?"?: boolean;
44
49
  "link-rule/link-rule?"?: boolean;
45
50
  "link-rule/link-rule"?: LinkRule;
@@ -75,12 +80,12 @@ type RawFieldObject = {
75
80
  "ui/type"?: string;
76
81
  };
77
82
  };
78
- type FieldObjectParams = {
83
+ export type FieldObjectParams = {
79
84
  rawFieldObject: RawFieldObject;
80
85
  holderType: TypeName;
81
86
  schema: SchemaRef;
82
87
  };
83
- declare class FieldObject {
88
+ export declare class FieldObject {
84
89
  private readonly raw;
85
90
  readonly holderType: TypeName;
86
91
  private readonly schema;
@@ -102,7 +107,7 @@ declare class FieldObject {
102
107
  get isFormula(): boolean;
103
108
  get isFormulaDisabled(): boolean;
104
109
  get formulaDisableReason(): string | null;
105
- get formula(): {} | null;
110
+ get formula(): RawFieldFormula | null;
106
111
  get isLookup(): boolean;
107
112
  get hasLinkRule(): boolean;
108
113
  get linkRule(): LinkRule | null;
@@ -136,5 +141,4 @@ declare class FieldObject {
136
141
  /** @deprecated use !typeObject.isPrimitive && cardinality === ... instead */
137
142
  get kind(): ":field/basic" | ":field/reference" | ":field/reference-collection";
138
143
  }
139
- //#endregion
140
- export { Cardinality, FieldObject, FieldObjectParams, LinkRule, LinkRuleOperand, RawFieldObject, SyncField, SyncRelation };
144
+ //#endregion
package/lib/index.d.ts CHANGED
@@ -1,8 +1,9 @@
1
1
  import { EntityId, FieldId, FieldName, Id, Name, Permissive, PublicId, SpaceId, SpaceName, TypeId, TypeName } from "./brands.js";
2
2
  import { NotDefinedGetError, NotFoundError, NotFoundNames } from "./errors.js";
3
+ import { Expression, ExpressionArgument, FieldExpression, FromRootExpression, FunctionCallExpression, MultiFieldAccess, OrderBy, Query, QueryLimit, Select, SubQuery } from "./query-expression.js";
3
4
  import { RawTypeObject, SyncSource, TypeObject, TypeObjectFactory, TypeObjectParams } from "./type-object.js";
4
5
  import { RawSchema, Schema, SchemaRef } from "./schema.js";
5
- import { Cardinality, FieldObject, FieldObjectParams, LinkRule, LinkRuleOperand, RawFieldObject, SyncField, SyncRelation } from "./field-object.js";
6
- import { Factory, factory, protectiveFactory } from "./factory.js";
6
+ 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";
7
8
  import { attachEnumNamespace, capitalizeFirstChar, getTypeObjectTitle, isOneOf, makeEnumTypeNamePart, parseEnumType, parseType, removeDeletedTypesAndFields, toNonEnumTitle, toPascalCase, toTitle, toTypeOrFieldNamePartTitle, toTypeOrFieldTitle, withOnlyDefinedGets } from "./utils.js";
8
- export { Cardinality, EntityId, Factory, FieldId, FieldName, FieldObject, FieldObjectParams, Id, LinkRule, LinkRuleOperand, Name, NotDefinedGetError, NotFoundError, NotFoundNames, Permissive, PublicId, RawFieldObject, RawSchema, RawTypeObject, Schema, SchemaRef, SpaceId, SpaceName, SyncField, SyncRelation, SyncSource, TypeId, TypeName, TypeObject, TypeObjectFactory, TypeObjectParams, attachEnumNamespace, capitalizeFirstChar, factory, getTypeObjectTitle, isOneOf, makeEnumTypeNamePart, parseEnumType, parseType, protectiveFactory, removeDeletedTypesAndFields, toNonEnumTitle, toPascalCase, toTitle, toTypeOrFieldNamePartTitle, toTypeOrFieldTitle, withOnlyDefinedGets };
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
@@ -3,5 +3,5 @@ import { attachEnumNamespace, capitalizeFirstChar, getTypeObjectTitle, isOneOf,
3
3
  import { FieldObject } from "./field-object.js";
4
4
  import { Schema } from "./schema.js";
5
5
  import { TypeObject } from "./type-object.js";
6
- import { factory, protectiveFactory } from "./factory.js";
7
- export { FieldObject, NotDefinedGetError, NotFoundError, Schema, TypeObject, attachEnumNamespace, capitalizeFirstChar, factory, getTypeObjectTitle, isOneOf, makeEnumTypeNamePart, parseEnumType, parseType, protectiveFactory, removeDeletedTypesAndFields, toNonEnumTitle, toPascalCase, toTitle, toTypeOrFieldNamePartTitle, toTypeOrFieldTitle, withOnlyDefinedGets };
6
+ import { factory, makeEntityId, makeFieldId, makeFieldObject, makeFieldObjectsById, makeFieldObjectsByName, makeSchema, makeSpaceId, makeTypeId, makeTypeObject, makeTypeObjectsById, makeTypeObjectsByName, mintUuidV7Everywhere } from "./factory.js";
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 };
@@ -1,5 +1,4 @@
1
1
  //#region src/print-utils.d.ts
2
- declare const isValidIdentifier: (x: string) => boolean;
3
- declare const printJsPath: (keys: string[]) => string;
4
- //#endregion
5
- export { isValidIdentifier, printJsPath };
2
+ export declare const isValidIdentifier: (x: string) => boolean;
3
+ export declare const printJsPath: (keys: string[]) => string;
4
+ //#endregion
@@ -0,0 +1,38 @@
1
+ //#region src/query-expression.d.ts
2
+ export type MultiFieldAccess = [string, string];
3
+ export type FieldExpression = Array<string | MultiFieldAccess>;
4
+ export type ExpressionArgument = Expression | SubQuery | number;
5
+ export type FunctionCallExpression = [string, ...ExpressionArgument[]];
6
+ export type FromRootExpression = ["q/from-root", ...FieldExpression[]];
7
+ /**
8
+ * The full union of all expression forms.
9
+ *
10
+ * Use type guards (isFieldExpression, isFunctionCallExpression, etc.) to narrow.
11
+ *
12
+ * Note: FieldExpression, FunctionCallExpression, FromRootExpression are all subtypes
13
+ * of expression arrays and listed explicitly for readability. SubQuery can occur
14
+ * inside an expression array; a standalone query has its own type.
15
+ */
16
+ export type Expression = string | ExpressionArgument[] | FieldExpression | FunctionCallExpression | FromRootExpression;
17
+ export type OrderBy = Array<[Expression, string] | [Expression, string, string]>;
18
+ export type QueryLimit = number | "q/no-limit";
19
+ export type Select = {
20
+ [field: string]: Expression | SubQuery | Select;
21
+ };
22
+ export type Query<From extends string = string> = {
23
+ "q/from": From;
24
+ "q/select"?: Expression | Select;
25
+ "q/offset"?: number;
26
+ "q/order-by"?: OrderBy;
27
+ "q/limit"?: QueryLimit;
28
+ "q/where"?: Expression;
29
+ };
30
+ export type SubQuery = {
31
+ "q/from": FieldExpression;
32
+ "q/select"?: Expression | Select;
33
+ "q/offset"?: number;
34
+ "q/order-by"?: OrderBy;
35
+ "q/limit"?: QueryLimit;
36
+ "q/where"?: Expression;
37
+ };
38
+ //#endregion
File without changes
package/lib/schema.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  import { Permissive, TypeId, TypeName } from "./brands.js";
2
2
  import { RawTypeObject, TypeObject } from "./type-object.js";
3
3
  import { FieldObject } from "./field-object.js";
4
- import { Factory } from "./factory.js";
4
+ import { Factory } from "@fibery/schema/src/factory";
5
5
  //#region src/schema.d.ts
6
- type RawSchema = {
6
+ export type RawSchema = {
7
7
  "fibery/id": string;
8
8
  "fibery/types": RawTypeObject[];
9
9
  "fibery/version": string;
@@ -12,13 +12,13 @@ type RawSchema = {
12
12
  * @internal the wiring TypeObject/FieldObject need from their owning schema. A structural
13
13
  * type rather than `Schema` so standalone type objects can supply a stub.
14
14
  */
15
- type SchemaRef = {
15
+ export type SchemaRef = {
16
16
  readonly version: string;
17
17
  resolveTypeObject: (type: Permissive<TypeName>) => TypeObject | null;
18
18
  resolveTypeComponentFieldObject: (type: string) => FieldObject | null;
19
19
  resolveMultiRelatedFieldObjects: (multiRelation: string) => ReadonlyArray<FieldObject>;
20
20
  };
21
- declare class Schema implements SchemaRef {
21
+ export declare class Schema implements SchemaRef {
22
22
  readonly typeObjects: ReadonlyArray<TypeObject>;
23
23
  private readonly typeObjectsById;
24
24
  private readonly typeObjectsByName;
@@ -46,5 +46,4 @@ declare class Schema implements SchemaRef {
46
46
  getTypeObjectByIdOrThrow(typeId: Permissive<TypeId>): TypeObject;
47
47
  getTypeObjectByNameOrThrow(typeName: Permissive<TypeName>): TypeObject;
48
48
  }
49
- //#endregion
50
- export { RawSchema, Schema, SchemaRef };
49
+ //#endregion
@@ -2,14 +2,14 @@ import { FieldId, FieldName, Permissive, SpaceName, TypeId, TypeName } from "./b
2
2
  import { SchemaRef } from "./schema.js";
3
3
  import { FieldObject, FieldObjectParams, RawFieldObject } from "./field-object.js";
4
4
  //#region src/type-object.d.ts
5
- type SyncSource = {
5
+ export type SyncSource = {
6
6
  appId: string;
7
7
  appName: string;
8
8
  id: string;
9
9
  state: string;
10
10
  type: string;
11
11
  };
12
- type RawTypeObject = {
12
+ export type RawTypeObject = {
13
13
  "fibery/id": TypeId;
14
14
  "fibery/name": TypeName;
15
15
  "fibery/description"?: string | null;
@@ -34,7 +34,7 @@ type RawTypeObject = {
34
34
  "semantic-index/enabled"?: boolean;
35
35
  };
36
36
  };
37
- type TypeObjectFactory = {
37
+ export type TypeObjectFactory = {
38
38
  makeFieldObjectsByName: (params: {
39
39
  type: string;
40
40
  fieldObjects: ReadonlyArray<FieldObject>;
@@ -45,12 +45,12 @@ type TypeObjectFactory = {
45
45
  }) => Readonly<Record<string, FieldObject>>;
46
46
  makeFieldObject: (params: FieldObjectParams) => FieldObject;
47
47
  };
48
- type TypeObjectParams = {
48
+ export type TypeObjectParams = {
49
49
  rawTypeObject: RawTypeObject;
50
50
  schema: SchemaRef;
51
51
  factory: TypeObjectFactory;
52
52
  };
53
- declare class TypeObject {
53
+ export declare class TypeObject {
54
54
  private readonly raw;
55
55
  private readonly schema;
56
56
  private readonly factory;
@@ -102,5 +102,4 @@ declare class TypeObject {
102
102
  get rankField(): "fibery/rank" | null;
103
103
  get rankFieldObject(): FieldObject | null;
104
104
  }
105
- //#endregion
106
- export { RawTypeObject, SyncSource, TypeObject, TypeObjectFactory, TypeObjectParams };
105
+ //#endregion
package/lib/utils.d.ts CHANGED
@@ -2,38 +2,37 @@ import { SpaceName, TypeName } from "./brands.js";
2
2
  import { RawTypeObject, TypeObject } from "./type-object.js";
3
3
  import { RawSchema } from "./schema.js";
4
4
  //#region src/utils.d.ts
5
- declare const withOnlyDefinedGets: (target: any, targetKind?: string) => any;
6
- declare const capitalizeFirstChar: (input: string) => string;
7
- declare const toTypeOrFieldNamePartTitle: (str: string | null | undefined) => string;
8
- declare const toTypeOrFieldTitle: (str: string | null | undefined) => string;
9
- declare const toPascalCase: (lispCasedString?: string) => string;
10
- declare const toNonEnumTitle: (strName: string) => string;
11
- declare const parseEnumType: (type: string) => {
5
+ export declare const withOnlyDefinedGets: (target: any, targetKind?: string) => any;
6
+ export declare const capitalizeFirstChar: (input: string) => string;
7
+ export declare const toTypeOrFieldNamePartTitle: (str: string | null | undefined) => string;
8
+ export declare const toTypeOrFieldTitle: (str: string | null | undefined) => string;
9
+ export declare const toPascalCase: (lispCasedString?: string) => string;
10
+ export declare const toNonEnumTitle: (strName: string) => string;
11
+ export declare const parseEnumType: (type: string) => {
12
12
  templateName: string;
13
13
  templateNamespace: SpaceName;
14
14
  targetName: string;
15
15
  targetNamespace: SpaceName;
16
16
  };
17
- declare const toTitle: (typeOrAttr: string) => string;
18
- declare const parseType: (type: string) => {
17
+ export declare const toTitle: (typeOrAttr: string) => string;
18
+ export declare const parseType: (type: string) => {
19
19
  namespace: SpaceName;
20
20
  name: string;
21
21
  };
22
- declare const makeEnumTypeNamePart: ({ holderType, enumName }: {
22
+ export declare const makeEnumTypeNamePart: ({ holderType, enumName }: {
23
23
  holderType: string;
24
24
  enumName: string;
25
25
  }) => string;
26
- declare const attachEnumNamespace: ({ enumNamespace, typeNamePart }: {
26
+ export declare const attachEnumNamespace: ({ enumNamespace, typeNamePart }: {
27
27
  enumNamespace: string;
28
28
  typeNamePart: string;
29
29
  }) => TypeName;
30
- declare const removeDeletedTypesAndFields: (rawSchema: RawSchema) => {
30
+ export declare const removeDeletedTypesAndFields: (rawSchema: RawSchema) => {
31
31
  "fibery/types": RawTypeObject[];
32
32
  "fibery/id": string;
33
33
  "fibery/version": string;
34
34
  };
35
- declare const getTypeObjectTitle: (typeObject: TypeObject, form?: "singular" | "plural") => string;
35
+ export declare const getTypeObjectTitle: (typeObject: TypeObject, form?: "singular" | "plural") => string;
36
36
  /** `===` does not narrow a branded string (`TypeName`, `FieldName`) to a literal; this does. */
37
- declare const isOneOf: <const L extends readonly string[]>(value: string, literals: L) => value is L[number];
38
- //#endregion
39
- export { attachEnumNamespace, capitalizeFirstChar, getTypeObjectTitle, isOneOf, makeEnumTypeNamePart, parseEnumType, parseType, removeDeletedTypesAndFields, toNonEnumTitle, toPascalCase, toTitle, toTypeOrFieldNamePartTitle, toTypeOrFieldTitle, withOnlyDefinedGets };
37
+ export declare const isOneOf: <const L extends readonly string[]>(value: string, literals: L) => value is L[number];
38
+ //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fibery/schema",
3
- "version": "13.0.2",
3
+ "version": "13.1.0",
4
4
  "description": "Fibery schema utils",
5
5
  "license": "UNLICENSED",
6
6
  "files": [
@@ -21,8 +21,9 @@
21
21
  }
22
22
  },
23
23
  "dependencies": {
24
- "lodash": "4.17.21",
25
- "@fibery/helpers": "4.2.1",
26
- "@fibery/pluralize": "1.2.1"
24
+ "@fibery/helpers": "5.0.0",
25
+ "@fibery/pluralize": "1.2.1",
26
+ "lodash": "4.18.1",
27
+ "uuid": "11.1.0"
27
28
  }
28
29
  }