@fibery/schema 10.2.11 → 10.2.13

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.
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.protectiveFactory = exports.factory = void 0;
7
- const lodash_1 = __importDefault(require("lodash"));
7
+ const keyBy_1 = __importDefault(require("lodash/keyBy"));
8
8
  const field_object_1 = require("./field-object");
9
9
  const schema_1 = require("./schema");
10
10
  const type_object_1 = require("./type-object");
@@ -17,11 +17,11 @@ exports.factory = {
17
17
  factory: exports.factory,
18
18
  }),
19
19
  makeTypeObject: (args) => new type_object_1.TypeObject({ ...args, factory: exports.factory }),
20
- makeTypeObjectsById: (typeObjects) => lodash_1.default.keyBy(typeObjects, (x) => x.id),
21
- makeTypeObjectsByName: (typeObjects) => lodash_1.default.keyBy(typeObjects, (x) => x.name),
20
+ makeTypeObjectsById: (typeObjects) => (0, keyBy_1.default)(typeObjects, (x) => x.id),
21
+ makeTypeObjectsByName: (typeObjects) => (0, keyBy_1.default)(typeObjects, (x) => x.name),
22
22
  makeFieldObject: (args) => new field_object_1.FieldObject(args),
23
- makeFieldObjectsById: ({ fieldObjects }) => lodash_1.default.keyBy(fieldObjects, (x) => x.id),
24
- makeFieldObjectsByName: ({ fieldObjects }) => lodash_1.default.keyBy(fieldObjects, (x) => x.name),
23
+ makeFieldObjectsById: ({ fieldObjects }) => (0, keyBy_1.default)(fieldObjects, (x) => x.id),
24
+ makeFieldObjectsByName: ({ fieldObjects }) => (0, keyBy_1.default)(fieldObjects, (x) => x.name),
25
25
  };
26
26
  exports.protectiveFactory = {
27
27
  makeSchema: (rawSchema, options = { shouldRemoveDeletedTypesAndFields: true }) => (0, utils_1.withOnlyDefinedGets)(new schema_1.Schema({
@@ -34,12 +34,12 @@ exports.protectiveFactory = {
34
34
  const typeObject = new type_object_1.TypeObject({ ...args, factory: exports.protectiveFactory });
35
35
  return (0, utils_1.withOnlyDefinedGets)(typeObject, `schema.typeObjectsByName["${typeObject.name}"]`);
36
36
  },
37
- makeTypeObjectsById: (typeObjects) => (0, utils_1.withOnlyDefinedGets)(lodash_1.default.keyBy(typeObjects, (x) => x.id), "schema.typeObjectsById"),
38
- makeTypeObjectsByName: (typeObjects) => (0, utils_1.withOnlyDefinedGets)(lodash_1.default.keyBy(typeObjects, (x) => x.name), "schema.typeObjectsByName"),
37
+ makeTypeObjectsById: (typeObjects) => (0, utils_1.withOnlyDefinedGets)((0, keyBy_1.default)(typeObjects, (x) => x.id), "schema.typeObjectsById"),
38
+ makeTypeObjectsByName: (typeObjects) => (0, utils_1.withOnlyDefinedGets)((0, keyBy_1.default)(typeObjects, (x) => x.name), "schema.typeObjectsByName"),
39
39
  makeFieldObject: (args) => {
40
40
  const fieldObject = new field_object_1.FieldObject(args);
41
41
  return (0, utils_1.withOnlyDefinedGets)(fieldObject, `schema.typeObjectsByName["${fieldObject.holderType}"].fieldObjectsByName["${fieldObject.name}"]`);
42
42
  },
43
- makeFieldObjectsById: ({ type, fieldObjects }) => (0, utils_1.withOnlyDefinedGets)(lodash_1.default.keyBy(fieldObjects, (x) => x.id), `schema.typeObjectsByName["${type}"].fieldObjectsById`),
44
- makeFieldObjectsByName: ({ type, fieldObjects }) => (0, utils_1.withOnlyDefinedGets)(lodash_1.default.keyBy(fieldObjects, (x) => x.name), `schema.typeObjectsByName["${type}"].fieldObjectsByName`),
43
+ makeFieldObjectsById: ({ type, fieldObjects }) => (0, utils_1.withOnlyDefinedGets)((0, keyBy_1.default)(fieldObjects, (x) => x.id), `schema.typeObjectsByName["${type}"].fieldObjectsById`),
44
+ makeFieldObjectsByName: ({ type, fieldObjects }) => (0, utils_1.withOnlyDefinedGets)((0, keyBy_1.default)(fieldObjects, (x) => x.name), `schema.typeObjectsByName["${type}"].fieldObjectsByName`),
45
45
  };
@@ -0,0 +1,4 @@
1
+ export type IdField = "fibery/id";
2
+ export type PublicIdField = "fibery/public-id";
3
+ export type RankField = "fibery/rank";
4
+ export type TitleField = "__NOTHING_INTERESTING__TitleField__";
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -4,8 +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
- /* eslint-disable no-use-before-define */
8
- const lodash_1 = __importDefault(require("lodash"));
7
+ const isFunction_1 = __importDefault(require("lodash/isFunction"));
8
+ const isPlainObject_1 = __importDefault(require("lodash/isPlainObject"));
9
+ const isString_1 = __importDefault(require("lodash/isString"));
10
+ const once_1 = __importDefault(require("lodash/once"));
9
11
  const utils_1 = require("./utils");
10
12
  class FieldObject {
11
13
  name;
@@ -47,16 +49,16 @@ class FieldObject {
47
49
  isDependency;
48
50
  isDependencyStart;
49
51
  constructor({ rawFieldObject, holderType, resolveTypeObject, version, resolveMultiRelatedFieldObjects, }) {
50
- if (!lodash_1.default.isPlainObject(rawFieldObject)) {
52
+ if (!(0, isPlainObject_1.default)(rawFieldObject)) {
51
53
  throw new Error("rawFieldObject arg must be plain object");
52
54
  }
53
- if (!lodash_1.default.isString(holderType)) {
55
+ if (!(0, isString_1.default)(holderType)) {
54
56
  throw new Error("holderType arg must be string");
55
57
  }
56
- if (!lodash_1.default.isFunction(resolveTypeObject)) {
58
+ if (!(0, isFunction_1.default)(resolveTypeObject)) {
57
59
  throw new Error("resolveTypeObject arg must be function");
58
60
  }
59
- if (!lodash_1.default.isFunction(resolveMultiRelatedFieldObjects)) {
61
+ if (!(0, isFunction_1.default)(resolveMultiRelatedFieldObjects)) {
60
62
  throw new Error("resolveMultiRelationFieldObjects arg must be function");
61
63
  }
62
64
  this.name = rawFieldObject["fibery/name"];
@@ -95,12 +97,12 @@ class FieldObject {
95
97
  typeObject: {
96
98
  configurable: false,
97
99
  enumerable: true,
98
- get: lodash_1.default.once(() => resolveTypeObject(this.type)),
100
+ get: (0, once_1.default)(() => resolveTypeObject(this.type)),
99
101
  },
100
102
  mixinTypeObject: {
101
103
  configurable: false,
102
104
  enumerable: true,
103
- get: lodash_1.default.once(() => {
105
+ get: (0, once_1.default)(() => {
104
106
  return this.holderTypeObject.installedMixinTypeObjects.find((mixinTypeObject) => Object.hasOwn(mixinTypeObject.fieldObjectsByName, this.name) ||
105
107
  (this.name === "workflow/state" && mixinTypeObject.name === "workflow/workflow"));
106
108
  }),
@@ -108,19 +110,19 @@ class FieldObject {
108
110
  holderTypeObject: {
109
111
  configurable: false,
110
112
  enumerable: true,
111
- get: lodash_1.default.once(() => {
113
+ get: (0, once_1.default)(() => {
112
114
  return resolveTypeObject(holderType);
113
115
  }),
114
116
  },
115
117
  nameParts: {
116
118
  configurable: false,
117
119
  enumerable: true,
118
- get: lodash_1.default.once(() => (0, utils_1.parseType)(rawFieldObject["fibery/name"])),
120
+ get: (0, once_1.default)(() => (0, utils_1.parseType)(rawFieldObject["fibery/name"])),
119
121
  },
120
122
  title: {
121
123
  configurable: false,
122
124
  enumerable: true,
123
- get: lodash_1.default.once(() => {
125
+ get: (0, once_1.default)(() => {
124
126
  if (this.name === "fibery/role" && this.holderType === "fibery/user") {
125
127
  return "User Role";
126
128
  }
@@ -130,7 +132,7 @@ class FieldObject {
130
132
  multiRelatedFieldObjects: {
131
133
  configurable: false,
132
134
  enumerable: true,
133
- get: lodash_1.default.once(() => {
135
+ get: (0, once_1.default)(() => {
134
136
  const { multiRelation, typeObject } = this;
135
137
  if (!multiRelation || !typeObject.isEntityRef) {
136
138
  return [];
@@ -141,7 +143,7 @@ class FieldObject {
141
143
  isMultiField: {
142
144
  configurable: false,
143
145
  enumerable: true,
144
- get: lodash_1.default.once(() => {
146
+ get: (0, once_1.default)(() => {
145
147
  return this.typeObject.isEntityRef;
146
148
  }),
147
149
  },
package/lib/src/schema.js CHANGED
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.Schema = void 0;
7
- const lodash_1 = __importDefault(require("lodash"));
7
+ const once_1 = __importDefault(require("lodash/once"));
8
8
  class Schema {
9
9
  typeObjects;
10
10
  typeObjectsById;
@@ -21,7 +21,7 @@ class Schema {
21
21
  enumerable: false,
22
22
  },
23
23
  });
24
- const getTypeComponentTypeToFieldObject = lodash_1.default.once(() => {
24
+ const getTypeComponentTypeToFieldObject = (0, once_1.default)(() => {
25
25
  const typeComponentTypeToFieldObject = new Map();
26
26
  this.typeObjects
27
27
  .flatMap((typeObject) => typeObject.fieldObjects)
@@ -1,4 +1,5 @@
1
1
  import { FieldObject, FieldObjectParams, RawFieldObject } from "./field-object";
2
+ import type { IdField, PublicIdField, RankField, TitleField } from "./field-keys";
2
3
  export type SyncSource = {
3
4
  appId: string;
4
5
  appName: string;
@@ -80,21 +81,21 @@ export declare class TypeObject {
80
81
  isEntityRef: boolean;
81
82
  constructor({ rawTypeObject, resolveTypeObject, getTypeComponentTypeToFieldObject, version, factory, resolveMultiRelatedFieldObjects, }: TypeObjectParams);
82
83
  _getFieldObjectShortcuts: () => {
83
- idField: string;
84
+ idField: IdField;
84
85
  idFieldObject: FieldObject;
85
- publicIdField: string;
86
+ publicIdField: PublicIdField;
86
87
  publicIdFieldObject: FieldObject;
87
- titleField: string;
88
+ titleField: TitleField;
88
89
  titleFieldObject: FieldObject;
89
- rankField: null | string;
90
- rankFieldObject: null | FieldObject;
90
+ rankField: RankField | null;
91
+ rankFieldObject: FieldObject | null;
91
92
  };
92
- get idField(): string;
93
+ get idField(): IdField;
93
94
  get idFieldObject(): FieldObject;
94
- get publicIdField(): string;
95
+ get publicIdField(): PublicIdField;
95
96
  get publicIdFieldObject(): FieldObject;
96
- get titleField(): string;
97
+ get titleField(): TitleField;
97
98
  get titleFieldObject(): FieldObject;
98
- get rankField(): string | null;
99
+ get rankField(): RankField | null;
99
100
  get rankFieldObject(): FieldObject | null;
100
101
  }
@@ -4,8 +4,9 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.TypeObject = void 0;
7
- /* eslint-disable no-use-before-define */
8
- const lodash_1 = __importDefault(require("lodash"));
7
+ const isFunction_1 = __importDefault(require("lodash/isFunction"));
8
+ const isPlainObject_1 = __importDefault(require("lodash/isPlainObject"));
9
+ const once_1 = __importDefault(require("lodash/once"));
9
10
  const utils_1 = require("./utils");
10
11
  const pluralize_1 = require("@fibery/pluralize");
11
12
  class TypeObject {
@@ -38,10 +39,10 @@ class TypeObject {
38
39
  isDeleted;
39
40
  isEntityRef;
40
41
  constructor({ rawTypeObject, resolveTypeObject, getTypeComponentTypeToFieldObject, version, factory, resolveMultiRelatedFieldObjects, }) {
41
- if (!lodash_1.default.isPlainObject(rawTypeObject)) {
42
+ if (!(0, isPlainObject_1.default)(rawTypeObject)) {
42
43
  throw new Error("rawTypeObject arg must be plain object");
43
44
  }
44
- if (!lodash_1.default.isFunction(resolveTypeObject)) {
45
+ if (!(0, isFunction_1.default)(resolveTypeObject)) {
45
46
  throw new Error("resolveTypeObject arg must be function");
46
47
  }
47
48
  this.name = rawTypeObject["fibery/name"];
@@ -65,13 +66,13 @@ class TypeObject {
65
66
  this.syncSource = rawMeta["sync/source"] || null;
66
67
  this.version = version;
67
68
  this.isEntityRef = rawTypeObject["fibery/name"] === "fibery/entity-ref";
68
- const fieldObjectsByNameOnceGetter = lodash_1.default.once(() => {
69
+ const fieldObjectsByNameOnceGetter = (0, once_1.default)(() => {
69
70
  return factory.makeFieldObjectsByName({
70
71
  type: this.name,
71
72
  fieldObjects: this.fieldObjects,
72
73
  });
73
74
  });
74
- const fieldObjectsGetter = lodash_1.default.once(() => rawTypeObject["fibery/fields"].map((rawFieldObject) => {
75
+ const fieldObjectsGetter = (0, once_1.default)(() => rawTypeObject["fibery/fields"].map((rawFieldObject) => {
75
76
  return factory.makeFieldObject({
76
77
  rawFieldObject,
77
78
  holderType: this.name,
@@ -105,7 +106,7 @@ class TypeObject {
105
106
  fieldObjectsById: {
106
107
  configurable: false,
107
108
  enumerable: true,
108
- get: lodash_1.default.once(() => {
109
+ get: (0, once_1.default)(() => {
109
110
  return factory.makeFieldObjectsById({
110
111
  type: this.name,
111
112
  fieldObjects: this.fieldObjects,
@@ -120,26 +121,26 @@ class TypeObject {
120
121
  installedMixinTypeObjects: {
121
122
  configurable: false,
122
123
  enumerable: true,
123
- get: lodash_1.default.once(() => [...this.installedMixins].map(resolveTypeObject).filter((typeObject) => typeObject)),
124
+ get: (0, once_1.default)(() => [...this.installedMixins].map(resolveTypeObject).filter((typeObject) => typeObject)),
124
125
  },
125
126
  title: {
126
127
  configurable: false,
127
128
  enumerable: true,
128
- get: lodash_1.default.once(() => (0, utils_1.toTitle)(this.name)),
129
+ get: (0, once_1.default)(() => (0, utils_1.toTitle)(this.name)),
129
130
  },
130
131
  pluralTitle: {
131
132
  configurable: false,
132
133
  enumerable: true,
133
- get: lodash_1.default.once(() => pluralize_1.pluralize.plural((0, utils_1.toTitle)(this.name))),
134
+ get: (0, once_1.default)(() => pluralize_1.pluralize.plural((0, utils_1.toTitle)(this.name))),
134
135
  },
135
136
  singularTitle: {
136
137
  configurable: false,
137
138
  enumerable: true,
138
- get: lodash_1.default.once(() => pluralize_1.pluralize.singular((0, utils_1.toTitle)(this.name))),
139
+ get: (0, once_1.default)(() => pluralize_1.pluralize.singular((0, utils_1.toTitle)(this.name))),
139
140
  },
140
141
  });
141
142
  }
142
- _getFieldObjectShortcuts = lodash_1.default.once(() => {
143
+ _getFieldObjectShortcuts = (0, once_1.default)(() => {
143
144
  const hasRank = this.installedMixins.has("fibery/rank-mixin");
144
145
  return this.fieldObjects.reduce((result, fieldObject) => {
145
146
  if (fieldObject.isId) {
@@ -1,4 +1,3 @@
1
- import _ from "lodash";
2
1
  import { RawSchema } from "./schema";
3
2
  import { TypeObject } from "./type-object";
4
3
  export declare const withOnlyDefinedGets: (target: any, targetKind?: string) => any;
@@ -17,7 +16,7 @@ export declare const toTitle: (typeOrAttr: string) => string;
17
16
  export declare const parseType: ((type: any) => {
18
17
  namespace: string;
19
18
  name: string;
20
- }) & _.MemoizedFunction;
19
+ }) & import("lodash").MemoizedFunction;
21
20
  export declare const makeEnumTypeNamePart: ({ holderType, enumName }: {
22
21
  holderType: string;
23
22
  enumName: string;
package/lib/src/utils.js CHANGED
@@ -5,7 +5,10 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
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
7
  const trace_1 = require("@fibery/helpers/utils/trace");
8
- const lodash_1 = __importDefault(require("lodash"));
8
+ const capitalize_1 = __importDefault(require("lodash/capitalize"));
9
+ const flow_1 = __importDefault(require("lodash/flow"));
10
+ const last_1 = __importDefault(require("lodash/last"));
11
+ const memoize_1 = __importDefault(require("lodash/memoize"));
9
12
  const errors_1 = require("./errors");
10
13
  const print_utils_1 = require("./print-utils");
11
14
  const jestKey = new Set(["nodeType", "tagName", "hasAttribute"]);
@@ -87,9 +90,9 @@ const capitalizeFirstChar = (input) => {
87
90
  };
88
91
  exports.capitalizeFirstChar = capitalizeFirstChar;
89
92
  const replaceTildes = (str) => (str || "").split("~").join(" ");
90
- exports.toTypeOrFieldNamePartTitle = lodash_1.default.flow([exports.capitalizeFirstChar, replaceTildes]);
91
- exports.toTypeOrFieldTitle = lodash_1.default.flow([getNamePart, exports.toTypeOrFieldNamePartTitle]);
92
- const toPascalCase = (lispCasedString = "") => lispCasedString && (lodash_1.default.last(lispCasedString.split("/")) || "").split("-").map(lodash_1.default.capitalize).join(" ");
93
+ exports.toTypeOrFieldNamePartTitle = (0, flow_1.default)([exports.capitalizeFirstChar, replaceTildes]);
94
+ exports.toTypeOrFieldTitle = (0, flow_1.default)([getNamePart, exports.toTypeOrFieldNamePartTitle]);
95
+ const toPascalCase = (lispCasedString = "") => lispCasedString && ((0, last_1.default)(lispCasedString.split("/")) || "").split("-").map(capitalize_1.default).join(" ");
93
96
  exports.toPascalCase = toPascalCase;
94
97
  const isObsoleteTitle = (str) => {
95
98
  const { name } = splitKeyword(str);
@@ -138,7 +141,7 @@ const splitKeyword = (keyword) => {
138
141
  name,
139
142
  };
140
143
  };
141
- exports.parseType = lodash_1.default.memoize((type) => {
144
+ exports.parseType = (0, memoize_1.default)((type) => {
142
145
  if (!type.includes("/")) {
143
146
  (0, trace_1.traceError)(`parseType invalid usage: passed type is '${type}'`);
144
147
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fibery/schema",
3
- "version": "10.2.11",
3
+ "version": "10.2.13",
4
4
  "description": "Fibery schema utils",
5
5
  "main": "./lib/index.js",
6
6
  "files": [
@@ -19,22 +19,21 @@
19
19
  "dependencies": {
20
20
  "lodash": "4.17.21",
21
21
  "memoize-one": "6.0.0",
22
- "@fibery/helpers": "1.3.4",
23
- "@fibery/pluralize": "1.0.2"
22
+ "@fibery/pluralize": "1.1.0",
23
+ "@fibery/helpers": "1.4.0"
24
24
  },
25
25
  "devDependencies": {
26
26
  "@babel/core": "7.28.5",
27
27
  "@swc/jest": "0.2.39",
28
28
  "@types/lodash": "4.14.172",
29
- "@types/node": "24.10.1",
30
29
  "babel-loader": "10.0.0",
31
30
  "jest": "30.2.0",
32
31
  "jest-junit": "16.0.0",
33
32
  "typescript": "5.9.3",
34
33
  "webpack": "5.87.0",
35
- "webpack-cli": "4.10.0",
36
- "@fibery/eslint-config": "8.6.2",
37
- "@fibery/babel-preset": "7.4.1"
34
+ "webpack-cli": "6.0.1",
35
+ "@fibery/babel-preset": "7.4.1",
36
+ "@fibery/eslint-config": "9.0.0"
38
37
  },
39
38
  "jest": {
40
39
  "testEnvironment": "node",
@@ -81,7 +80,8 @@
81
80
  "test": "jest",
82
81
  "test:ci": "pnpm run test --reporters=default --reporters=jest-junit",
83
82
  "test:coverage": "pnpm run test --coverage --coverageDirectory=${JEST_COVERAGE_RESULT_DIR:-$(pwd)}/coverage/schema --reporters=default --reporters=jest-junit",
84
- "lint": "eslint ."
83
+ "lint": "eslint .",
84
+ "typecheck": "tsc --noEmit"
85
85
  },
86
86
  "types": "./lib/index.d.ts"
87
87
  }