@fibery/schema 10.0.1 → 10.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.
@@ -71,6 +71,7 @@ export declare class TypeObject {
71
71
  installedMixinTypeObjects: TypeObject[];
72
72
  title: string;
73
73
  pluralTitle: string;
74
+ singularTitle: string;
74
75
  fieldObjects: Array<FieldObject>;
75
76
  fieldObjectsById: Record<string, FieldObject>;
76
77
  fieldObjectsByName: Record<string, FieldObject>;
@@ -30,6 +30,7 @@ class TypeObject {
30
30
  installedMixinTypeObjects;
31
31
  title;
32
32
  pluralTitle;
33
+ singularTitle;
33
34
  fieldObjects;
34
35
  fieldObjectsById;
35
36
  fieldObjectsByName;
@@ -131,6 +132,11 @@ class TypeObject {
131
132
  enumerable: true,
132
133
  get: lodash_1.default.once(() => (0, utils_1.toTitle)(pluralize_1.default.plural(this.name))),
133
134
  },
135
+ singularTitle: {
136
+ configurable: false,
137
+ enumerable: true,
138
+ get: lodash_1.default.once(() => (0, utils_1.toTitle)(pluralize_1.default.singular(this.name))),
139
+ },
134
140
  });
135
141
  }
136
142
  _getFieldObjectShortcuts = lodash_1.default.once(() => {
@@ -1,5 +1,6 @@
1
1
  import _ from "lodash";
2
2
  import { RawSchema } from "./schema";
3
+ import { TypeObject } from "./type-object";
3
4
  export declare const withOnlyDefinedGets: (target: any, targetKind?: string) => any;
4
5
  export declare const capitalizeFirstChar: (input: string) => string;
5
6
  export declare const toTypeOrFieldNamePartTitle: (str: string) => string;
@@ -57,3 +58,4 @@ export declare const removeDeletedTypesAndFields: (rawSchema: RawSchema) => {
57
58
  "fibery/id": string;
58
59
  "fibery/version": string;
59
60
  };
61
+ export declare const getTypeObjectTitle: (typeObject: TypeObject, form?: "singular" | "plural") => string;
package/lib/src/utils.js CHANGED
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- 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;
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
8
  const lodash_1 = __importDefault(require("lodash"));
9
9
  const errors_1 = require("./errors");
@@ -160,3 +160,5 @@ const removeDeletedTypesAndFields = (rawSchema) => {
160
160
  return { ...schemaRest, "fibery/types": filteredRawTypeObjects };
161
161
  };
162
162
  exports.removeDeletedTypesAndFields = removeDeletedTypesAndFields;
163
+ const getTypeObjectTitle = (typeObject, form) => form ? (form === "singular" ? typeObject.singularTitle : typeObject.pluralTitle) : typeObject.title;
164
+ exports.getTypeObjectTitle = getTypeObjectTitle;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fibery/schema",
3
- "version": "10.0.1",
3
+ "version": "10.1.0",
4
4
  "description": "Fibery schema utils",
5
5
  "main": "./lib/index.js",
6
6
  "files": [