@fibery/schema 12.0.1 → 13.0.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.
@@ -84,7 +84,6 @@ declare class FieldObject {
84
84
  private readonly raw;
85
85
  readonly holderType: TypeName;
86
86
  private readonly schema;
87
- /** Lazily filled; declared here so all instances share one hidden class. */
88
87
  private cache;
89
88
  constructor({ rawFieldObject, holderType, schema }: FieldObjectParams);
90
89
  toJSON(): string | RawFieldObject;
@@ -1,5 +1,4 @@
1
1
  import { NotFoundError } from "./errors.js";
2
- import { relaxable } from "./relaxable.js";
3
2
  import { parseType, toNonEnumTitle } from "./utils.js";
4
3
  import { isPlainObject } from "@fibery/helpers/src/_";
5
4
  //#region src/field-object.ts
@@ -10,8 +9,6 @@ var FieldObject = class {
10
9
  raw;
11
10
  holderType;
12
11
  schema;
13
- /** Lazily filled; declared here so all instances share one hidden class. */
14
- cache;
15
12
  constructor({ rawFieldObject, holderType, schema }) {
16
13
  if (!isPlainObject(rawFieldObject)) throw new Error("rawFieldObject arg must be plain object");
17
14
  if (typeof holderType !== "string") throw new Error("holderType arg must be string");
@@ -19,7 +16,12 @@ var FieldObject = class {
19
16
  this.raw = rawFieldObject;
20
17
  this.holderType = holderType;
21
18
  this.schema = schema;
22
- this.cache = void 0;
19
+ Object.defineProperty(this, "cache", {
20
+ value: void 0,
21
+ writable: true,
22
+ enumerable: false,
23
+ configurable: false
24
+ });
23
25
  }
24
26
  toJSON() {
25
27
  if (process.env.NODE_ENV === "test") return `<schema.typeObjectsByName["${this.holderType}"].fieldObjectsByName["${this.name}"]>`;
@@ -143,14 +145,11 @@ var FieldObject = class {
143
145
  }
144
146
  get typeObject() {
145
147
  const typeObject = this.resolveTypeObject();
146
- if (!typeObject) {
147
- if (relaxable()) return;
148
- throw new NotFoundError("type", {
149
- typeName: this.type,
150
- fieldId: this.id,
151
- fieldName: this.name
152
- });
153
- }
148
+ if (!typeObject) throw new NotFoundError("type", {
149
+ typeName: this.type,
150
+ fieldId: this.id,
151
+ fieldName: this.name
152
+ });
154
153
  return typeObject;
155
154
  }
156
155
  get holderTypeObject() {
@@ -158,14 +157,11 @@ var FieldObject = class {
158
157
  let value = cache.holderTypeObject;
159
158
  if (!value) {
160
159
  const holderTypeObject = this.schema.resolveTypeObject(this.holderType);
161
- if (!holderTypeObject) {
162
- if (relaxable()) return;
163
- throw new NotFoundError("type", {
164
- typeName: this.holderType,
165
- fieldId: this.id,
166
- fieldName: this.name
167
- });
168
- }
160
+ if (!holderTypeObject) throw new NotFoundError("type", {
161
+ typeName: this.holderType,
162
+ fieldId: this.id,
163
+ fieldName: this.name
164
+ });
169
165
  value = holderTypeObject;
170
166
  cache.holderTypeObject = value;
171
167
  }
package/lib/schema.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import { NotFoundError } from "./errors.js";
2
- import { relaxable } from "./relaxable.js";
3
2
  //#region src/schema.ts
4
3
  const EMPTY_FIELD_OBJECTS = Object.freeze([]);
5
4
  const typeComponentFieldObjects = /* @__PURE__ */ new WeakMap();
@@ -91,18 +90,12 @@ var Schema = class {
91
90
  }
92
91
  getTypeObjectByIdOrThrow(typeId) {
93
92
  const typeObject = this.getTypeObjectById(typeId);
94
- if (!typeObject) {
95
- if (relaxable()) return;
96
- throw new NotFoundError("type", { typeId });
97
- }
93
+ if (!typeObject) throw new NotFoundError("type", { typeId });
98
94
  return typeObject;
99
95
  }
100
96
  getTypeObjectByNameOrThrow(typeName) {
101
97
  const typeObject = this.getTypeObjectByName(typeName);
102
- if (!typeObject) {
103
- if (relaxable()) return;
104
- throw new NotFoundError("type", { typeName });
105
- }
98
+ if (!typeObject) throw new NotFoundError("type", { typeName });
106
99
  return typeObject;
107
100
  }
108
101
  };
@@ -54,7 +54,6 @@ declare class TypeObject {
54
54
  private readonly raw;
55
55
  private readonly schema;
56
56
  private readonly factory;
57
- /** Lazily filled; declared here so all instances share one hidden class. */
58
57
  private cache;
59
58
  constructor({ rawTypeObject, schema, factory }: TypeObjectParams);
60
59
  toJSON(): string | RawTypeObject;
@@ -1,5 +1,4 @@
1
1
  import { NotFoundError } from "./errors.js";
2
- import { relaxable } from "./relaxable.js";
3
2
  import { parseType, toTitle } from "./utils.js";
4
3
  import { isPlainObject, truthy } from "@fibery/helpers/src/_";
5
4
  import { pluralize } from "@fibery/pluralize";
@@ -10,15 +9,18 @@ var TypeObject = class {
10
9
  raw;
11
10
  schema;
12
11
  factory;
13
- /** Lazily filled; declared here so all instances share one hidden class. */
14
- cache;
15
12
  constructor({ rawTypeObject, schema, factory }) {
16
13
  if (!isPlainObject(rawTypeObject)) throw new Error("rawTypeObject arg must be plain object");
17
14
  if (!schema) throw new Error("schema arg must be provided");
18
15
  this.raw = rawTypeObject;
19
16
  this.schema = schema;
20
17
  this.factory = factory;
21
- this.cache = void 0;
18
+ Object.defineProperty(this, "cache", {
19
+ value: void 0,
20
+ writable: true,
21
+ enumerable: false,
22
+ configurable: false
23
+ });
22
24
  }
23
25
  toJSON() {
24
26
  if (process.env.NODE_ENV === "test") return `<schema.typeObjectsByName["${this.raw["fibery/name"]}"]>`;
@@ -32,26 +34,20 @@ var TypeObject = class {
32
34
  }
33
35
  getFieldObjectByIdOrThrow(fieldId) {
34
36
  const fieldObject = this.getFieldObjectById(fieldId);
35
- if (!fieldObject) {
36
- if (relaxable()) return;
37
- throw new NotFoundError("field", {
38
- typeId: this.id,
39
- typeName: this.name,
40
- fieldId
41
- });
42
- }
37
+ if (!fieldObject) throw new NotFoundError("field", {
38
+ typeId: this.id,
39
+ typeName: this.name,
40
+ fieldId
41
+ });
43
42
  return fieldObject;
44
43
  }
45
44
  getFieldObjectByNameOrThrow(fieldName) {
46
45
  const fieldObject = this.getFieldObjectByName(fieldName);
47
- if (!fieldObject) {
48
- if (relaxable()) return;
49
- throw new NotFoundError("field", {
50
- typeId: this.id,
51
- typeName: this.name,
52
- fieldName
53
- });
54
- }
46
+ if (!fieldObject) throw new NotFoundError("field", {
47
+ typeId: this.id,
48
+ typeName: this.name,
49
+ fieldName
50
+ });
55
51
  return fieldObject;
56
52
  }
57
53
  get rawMeta() {
package/lib/utils.js CHANGED
@@ -1,5 +1,4 @@
1
1
  import { NotDefinedGetError } from "./errors.js";
2
- import { relaxableRealm } from "./relaxable.js";
3
2
  import { printJsPath } from "./print-utils.js";
4
3
  import { traceError } from "@fibery/helpers/utils/trace";
5
4
  //#region src/utils.ts
@@ -101,9 +100,10 @@ const makeEnumTypeNamePart = ({ holderType, enumName }) => {
101
100
  const attachEnumNamespace = ({ enumNamespace, typeNamePart }) => {
102
101
  return `${enumNamespace}/${typeNamePart}`;
103
102
  };
103
+ const insideApplication = () => typeof window !== "undefined" && Boolean(window["x-ui-version"]);
104
104
  const reportedStrippedFields = /* @__PURE__ */ new Set();
105
105
  const reportStrippedField = (holderTypeName, rawFieldObject, isTypeSoftDeleted) => {
106
- if (!relaxableRealm()) return;
106
+ if (!insideApplication()) return;
107
107
  if (process.env.NODE_ENV === "production") return;
108
108
  const key = `${holderTypeName} ${rawFieldObject["fibery/name"]} ${rawFieldObject["fibery/type"]}`;
109
109
  if (reportedStrippedFields.has(key)) return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fibery/schema",
3
- "version": "12.0.1",
3
+ "version": "13.0.0",
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/helpers": "4.1.0",
25
+ "@fibery/helpers": "4.1.2",
26
26
  "@fibery/pluralize": "1.2.1"
27
27
  }
28
28
  }
@@ -1,7 +0,0 @@
1
- //#region src/relaxable.d.ts
2
- declare const relaxableRealm: () => boolean;
3
- declare let relaxable: () => boolean;
4
- /** Temporary application policy while strict lookups roll out. Standalone schema stays strict. */
5
- declare function setRelaxablePredicate(next: () => boolean): () => void;
6
- //#endregion
7
- export { relaxable, relaxableRealm, setRelaxablePredicate };
package/lib/relaxable.js DELETED
@@ -1,13 +0,0 @@
1
- //#region src/relaxable.ts
2
- const relaxableRealm = () => typeof window !== "undefined" && Boolean(window["x-ui-version"]);
3
- let relaxable = () => false;
4
- /** Temporary application policy while strict lookups roll out. Standalone schema stays strict. */
5
- function setRelaxablePredicate(next) {
6
- const previous = relaxable;
7
- relaxable = next;
8
- return () => {
9
- relaxable = previous;
10
- };
11
- }
12
- //#endregion
13
- export { relaxable, relaxableRealm, setRelaxablePredicate };