@teambit/semantics.entities.semantic-schema 0.0.87 → 0.0.89

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.
@@ -11,6 +11,14 @@ function _lodash() {
11
11
  };
12
12
  return data;
13
13
  }
14
+ function _pluralize() {
15
+ const data = _interopRequireDefault(require("pluralize"));
16
+ _pluralize = function () {
17
+ return data;
18
+ };
19
+ return data;
20
+ }
21
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
22
  /**
15
23
  * a convenient abstract class for all schema to extend.
16
24
  * the reason for having it as an abstract class and not an interface, for now, is mostly for the `__schema` prop.
@@ -18,7 +26,7 @@ function _lodash() {
18
26
  */
19
27
  class SchemaNode {
20
28
  __schema = this.constructor.name;
21
- displaySchemaName = this.constructor.name.replace(/Schema$/, '').replace(/([A-Z])/g, ' $1').trim().replace(/s$/, 'ses').replace(/([^s]s)$/, '$1es').replace(/([^s])$/, '$1s');
29
+ displaySchemaName = (0, _pluralize().default)(this.constructor.name.replace(/Schema$/, '').replace(/([A-Z])/g, ' $1').trim());
22
30
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
23
31
  static fromObject(obj) {
24
32
  throw new Error(`Method 'fromObject' not implemented in subclass.`);
@@ -1 +1 @@
1
- {"version":3,"names":["_lodash","data","require","SchemaNode","__schema","constructor","name","displaySchemaName","replace","trim","fromObject","obj","Error","toObject","pickBy","location","doc","undefined","signature","v","getNodes","getAllNodesRecursively","visitedNodes","Set","has","add","nodes","flatMap","node","findNode","predicate","child","foundNode","exports"],"sources":["schema-node.ts"],"sourcesContent":["import { pickBy } from 'lodash';\nimport { DocSchema } from './schemas';\n\nexport interface ISchemaNode {\n __schema: string;\n location: SchemaLocation;\n doc?: DocSchema;\n signature?: string;\n name?: string;\n toObject(): Record<string, any>;\n toString(options?: { color?: boolean }): string;\n toFullSignature(options?: { showDocs?: boolean }): string;\n getNodes(): SchemaNode[];\n findNode(predicate: (node: SchemaNode) => boolean, visitedNodes?: Set<SchemaNode>): SchemaNode | undefined;\n getAllNodesRecursively(visitedNodes?: Set<SchemaNode>): SchemaNode[];\n displaySchemaName: string;\n}\n\n/**\n * a convenient abstract class for all schema to extend.\n * the reason for having it as an abstract class and not an interface, for now, is mostly for the `__schema` prop.\n * this way it won't need to be implemented in each one of the subclasses.\n */\nexport abstract class SchemaNode implements ISchemaNode {\n readonly __schema = this.constructor.name;\n readonly displaySchemaName = this.constructor.name\n .replace(/Schema$/, '')\n .replace(/([A-Z])/g, ' $1')\n .trim()\n .replace(/s$/, 'ses')\n .replace(/([^s]s)$/, '$1es')\n .replace(/([^s])$/, '$1s');\n\n abstract readonly location: SchemaLocation;\n readonly doc?: DocSchema;\n readonly signature?: string;\n readonly name?: string;\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n static fromObject(obj: Record<string, any>): SchemaNode {\n throw new Error(`Method 'fromObject' not implemented in subclass.`);\n }\n\n toObject(): Record<string, any> {\n return pickBy(\n {\n __schema: this.__schema,\n location: this.location,\n doc: this.doc ? this.doc.toObject() : undefined,\n signature: this.signature,\n name: this.name,\n },\n (v) => v !== undefined\n );\n }\n\n abstract toString(options?: { color?: boolean }): string;\n abstract toFullSignature(options?: { showDocs?: boolean }): string;\n\n getNodes(): SchemaNode[] {\n return [this];\n }\n\n getAllNodesRecursively(visitedNodes = new Set<SchemaNode>()): SchemaNode[] {\n if (visitedNodes.has(this)) {\n return [];\n }\n\n visitedNodes.add(this);\n\n const nodes = this.getNodes();\n return [this, ...nodes.flatMap((node) => node.getAllNodesRecursively(visitedNodes))];\n }\n\n findNode(predicate: (node: SchemaNode) => boolean, visitedNodes = new Set<SchemaNode>()): SchemaNode | undefined {\n if (predicate(this)) return this;\n if (visitedNodes.has(this)) return undefined;\n\n visitedNodes.add(this);\n\n for (const child of this.getNodes()) {\n const foundNode = child.findNode(predicate, visitedNodes);\n if (foundNode) return foundNode;\n }\n\n return undefined;\n }\n}\n\nexport type SchemaLocation = {\n /**\n * file-path relative to the component root-dir. normalized to Linux.\n */\n filePath: string;\n line: number;\n character: number;\n};\n"],"mappings":";;;;;;AAAA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,OAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAkBA;AACA;AACA;AACA;AACA;AACO,MAAeE,UAAU,CAAwB;EAC7CC,QAAQ,GAAG,IAAI,CAACC,WAAW,CAACC,IAAI;EAChCC,iBAAiB,GAAG,IAAI,CAACF,WAAW,CAACC,IAAI,CAC/CE,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CACtBA,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC,CAC1BC,IAAI,CAAC,CAAC,CACND,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CACpBA,OAAO,CAAC,UAAU,EAAE,MAAM,CAAC,CAC3BA,OAAO,CAAC,SAAS,EAAE,KAAK,CAAC;EAM5B;EACA,OAAOE,UAAUA,CAACC,GAAwB,EAAc;IACtD,MAAM,IAAIC,KAAK,CAAC,kDAAkD,CAAC;EACrE;EAEAC,QAAQA,CAAA,EAAwB;IAC9B,OAAO,IAAAC,gBAAM,EACX;MACEV,QAAQ,EAAE,IAAI,CAACA,QAAQ;MACvBW,QAAQ,EAAE,IAAI,CAACA,QAAQ;MACvBC,GAAG,EAAE,IAAI,CAACA,GAAG,GAAG,IAAI,CAACA,GAAG,CAACH,QAAQ,CAAC,CAAC,GAAGI,SAAS;MAC/CC,SAAS,EAAE,IAAI,CAACA,SAAS;MACzBZ,IAAI,EAAE,IAAI,CAACA;IACb,CAAC,EACAa,CAAC,IAAKA,CAAC,KAAKF,SACf,CAAC;EACH;EAKAG,QAAQA,CAAA,EAAiB;IACvB,OAAO,CAAC,IAAI,CAAC;EACf;EAEAC,sBAAsBA,CAACC,YAAY,GAAG,IAAIC,GAAG,CAAa,CAAC,EAAgB;IACzE,IAAID,YAAY,CAACE,GAAG,CAAC,IAAI,CAAC,EAAE;MAC1B,OAAO,EAAE;IACX;IAEAF,YAAY,CAACG,GAAG,CAAC,IAAI,CAAC;IAEtB,MAAMC,KAAK,GAAG,IAAI,CAACN,QAAQ,CAAC,CAAC;IAC7B,OAAO,CAAC,IAAI,EAAE,GAAGM,KAAK,CAACC,OAAO,CAAEC,IAAI,IAAKA,IAAI,CAACP,sBAAsB,CAACC,YAAY,CAAC,CAAC,CAAC;EACtF;EAEAO,QAAQA,CAACC,SAAwC,EAAER,YAAY,GAAG,IAAIC,GAAG,CAAa,CAAC,EAA0B;IAC/G,IAAIO,SAAS,CAAC,IAAI,CAAC,EAAE,OAAO,IAAI;IAChC,IAAIR,YAAY,CAACE,GAAG,CAAC,IAAI,CAAC,EAAE,OAAOP,SAAS;IAE5CK,YAAY,CAACG,GAAG,CAAC,IAAI,CAAC;IAEtB,KAAK,MAAMM,KAAK,IAAI,IAAI,CAACX,QAAQ,CAAC,CAAC,EAAE;MACnC,MAAMY,SAAS,GAAGD,KAAK,CAACF,QAAQ,CAACC,SAAS,EAAER,YAAY,CAAC;MACzD,IAAIU,SAAS,EAAE,OAAOA,SAAS;IACjC;IAEA,OAAOf,SAAS;EAClB;AACF;AAACgB,OAAA,CAAA9B,UAAA,GAAAA,UAAA","ignoreList":[]}
1
+ {"version":3,"names":["_lodash","data","require","_pluralize","_interopRequireDefault","e","__esModule","default","SchemaNode","__schema","constructor","name","displaySchemaName","pluralize","replace","trim","fromObject","obj","Error","toObject","pickBy","location","doc","undefined","signature","v","getNodes","getAllNodesRecursively","visitedNodes","Set","has","add","nodes","flatMap","node","findNode","predicate","child","foundNode","exports"],"sources":["schema-node.ts"],"sourcesContent":["import { pickBy } from 'lodash';\nimport pluralize from 'pluralize';\nimport { DocSchema } from './schemas';\n\nexport interface ISchemaNode {\n __schema: string;\n location: SchemaLocation;\n doc?: DocSchema;\n signature?: string;\n name?: string;\n toObject(): Record<string, any>;\n toString(options?: { color?: boolean }): string;\n toFullSignature(options?: { showDocs?: boolean }): string;\n getNodes(): SchemaNode[];\n findNode(predicate: (node: SchemaNode) => boolean, visitedNodes?: Set<SchemaNode>): SchemaNode | undefined;\n getAllNodesRecursively(visitedNodes?: Set<SchemaNode>): SchemaNode[];\n displaySchemaName: string;\n}\n\n/**\n * a convenient abstract class for all schema to extend.\n * the reason for having it as an abstract class and not an interface, for now, is mostly for the `__schema` prop.\n * this way it won't need to be implemented in each one of the subclasses.\n */\nexport abstract class SchemaNode implements ISchemaNode {\n readonly __schema = this.constructor.name;\n readonly displaySchemaName = pluralize(\n this.constructor.name\n .replace(/Schema$/, '')\n .replace(/([A-Z])/g, ' $1')\n .trim()\n );\n\n abstract readonly location: SchemaLocation;\n readonly doc?: DocSchema;\n readonly signature?: string;\n readonly name?: string;\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n static fromObject(obj: Record<string, any>): SchemaNode {\n throw new Error(`Method 'fromObject' not implemented in subclass.`);\n }\n\n toObject(): Record<string, any> {\n return pickBy(\n {\n __schema: this.__schema,\n location: this.location,\n doc: this.doc ? this.doc.toObject() : undefined,\n signature: this.signature,\n name: this.name,\n },\n (v) => v !== undefined\n );\n }\n\n abstract toString(options?: { color?: boolean }): string;\n abstract toFullSignature(options?: { showDocs?: boolean }): string;\n\n getNodes(): SchemaNode[] {\n return [this];\n }\n\n getAllNodesRecursively(visitedNodes = new Set<SchemaNode>()): SchemaNode[] {\n if (visitedNodes.has(this)) {\n return [];\n }\n\n visitedNodes.add(this);\n\n const nodes = this.getNodes();\n return [this, ...nodes.flatMap((node) => node.getAllNodesRecursively(visitedNodes))];\n }\n\n findNode(predicate: (node: SchemaNode) => boolean, visitedNodes = new Set<SchemaNode>()): SchemaNode | undefined {\n if (predicate(this)) return this;\n if (visitedNodes.has(this)) return undefined;\n\n visitedNodes.add(this);\n\n for (const child of this.getNodes()) {\n const foundNode = child.findNode(predicate, visitedNodes);\n if (foundNode) return foundNode;\n }\n\n return undefined;\n }\n}\n\nexport type SchemaLocation = {\n /**\n * file-path relative to the component root-dir. normalized to Linux.\n */\n filePath: string;\n line: number;\n character: number;\n};\n"],"mappings":";;;;;;AAAA,SAAAA,QAAA;EAAA,MAAAC,IAAA,GAAAC,OAAA;EAAAF,OAAA,YAAAA,CAAA;IAAA,OAAAC,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AACA,SAAAE,WAAA;EAAA,MAAAF,IAAA,GAAAG,sBAAA,CAAAF,OAAA;EAAAC,UAAA,YAAAA,CAAA;IAAA,OAAAF,IAAA;EAAA;EAAA,OAAAA,IAAA;AAAA;AAAkC,SAAAG,uBAAAC,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAkBlC;AACA;AACA;AACA;AACA;AACO,MAAeG,UAAU,CAAwB;EAC7CC,QAAQ,GAAG,IAAI,CAACC,WAAW,CAACC,IAAI;EAChCC,iBAAiB,GAAG,IAAAC,oBAAS,EACpC,IAAI,CAACH,WAAW,CAACC,IAAI,CAClBG,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CACtBA,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC,CAC1BC,IAAI,CAAC,CACV,CAAC;EAMD;EACA,OAAOC,UAAUA,CAACC,GAAwB,EAAc;IACtD,MAAM,IAAIC,KAAK,CAAC,kDAAkD,CAAC;EACrE;EAEAC,QAAQA,CAAA,EAAwB;IAC9B,OAAO,IAAAC,gBAAM,EACX;MACEX,QAAQ,EAAE,IAAI,CAACA,QAAQ;MACvBY,QAAQ,EAAE,IAAI,CAACA,QAAQ;MACvBC,GAAG,EAAE,IAAI,CAACA,GAAG,GAAG,IAAI,CAACA,GAAG,CAACH,QAAQ,CAAC,CAAC,GAAGI,SAAS;MAC/CC,SAAS,EAAE,IAAI,CAACA,SAAS;MACzBb,IAAI,EAAE,IAAI,CAACA;IACb,CAAC,EACAc,CAAC,IAAKA,CAAC,KAAKF,SACf,CAAC;EACH;EAKAG,QAAQA,CAAA,EAAiB;IACvB,OAAO,CAAC,IAAI,CAAC;EACf;EAEAC,sBAAsBA,CAACC,YAAY,GAAG,IAAIC,GAAG,CAAa,CAAC,EAAgB;IACzE,IAAID,YAAY,CAACE,GAAG,CAAC,IAAI,CAAC,EAAE;MAC1B,OAAO,EAAE;IACX;IAEAF,YAAY,CAACG,GAAG,CAAC,IAAI,CAAC;IAEtB,MAAMC,KAAK,GAAG,IAAI,CAACN,QAAQ,CAAC,CAAC;IAC7B,OAAO,CAAC,IAAI,EAAE,GAAGM,KAAK,CAACC,OAAO,CAAEC,IAAI,IAAKA,IAAI,CAACP,sBAAsB,CAACC,YAAY,CAAC,CAAC,CAAC;EACtF;EAEAO,QAAQA,CAACC,SAAwC,EAAER,YAAY,GAAG,IAAIC,GAAG,CAAa,CAAC,EAA0B;IAC/G,IAAIO,SAAS,CAAC,IAAI,CAAC,EAAE,OAAO,IAAI;IAChC,IAAIR,YAAY,CAACE,GAAG,CAAC,IAAI,CAAC,EAAE,OAAOP,SAAS;IAE5CK,YAAY,CAACG,GAAG,CAAC,IAAI,CAAC;IAEtB,KAAK,MAAMM,KAAK,IAAI,IAAI,CAACX,QAAQ,CAAC,CAAC,EAAE;MACnC,MAAMY,SAAS,GAAGD,KAAK,CAACF,QAAQ,CAACC,SAAS,EAAER,YAAY,CAAC;MACzD,IAAIU,SAAS,EAAE,OAAOA,SAAS;IACjC;IAEA,OAAOf,SAAS;EAClB;AACF;AAACgB,OAAA,CAAA/B,UAAA,GAAAA,UAAA","ignoreList":[]}
package/package.json CHANGED
@@ -1,23 +1,25 @@
1
1
  {
2
2
  "name": "@teambit/semantics.entities.semantic-schema",
3
- "version": "0.0.87",
3
+ "version": "0.0.89",
4
4
  "homepage": "https://bit.cloud/teambit/semantics/entities/semantic-schema",
5
5
  "main": "dist/index.js",
6
6
  "componentId": {
7
7
  "scope": "teambit.semantics",
8
8
  "name": "entities/semantic-schema",
9
- "version": "0.0.87"
9
+ "version": "0.0.89"
10
10
  },
11
11
  "dependencies": {
12
12
  "chalk": "4.1.2",
13
13
  "lodash": "4.17.21",
14
+ "pluralize": "8.0.0",
14
15
  "@teambit/component-id": "1.2.4"
15
16
  },
16
17
  "devDependencies": {
17
18
  "@types/lodash": "4.14.165",
19
+ "@types/pluralize": "0.0.29",
18
20
  "@types/mocha": "9.1.0",
19
21
  "chai": "4.3.0",
20
- "@teambit/node.envs.node-babel-mocha": "0.1.5"
22
+ "@teambit/node.envs.node-babel-mocha": "0.1.18"
21
23
  },
22
24
  "peerDependencies": {},
23
25
  "license": "Apache-2.0",
package/schema-node.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { pickBy } from 'lodash';
2
+ import pluralize from 'pluralize';
2
3
  import { DocSchema } from './schemas';
3
4
 
4
5
  export interface ISchemaNode {
@@ -23,13 +24,12 @@ export interface ISchemaNode {
23
24
  */
24
25
  export abstract class SchemaNode implements ISchemaNode {
25
26
  readonly __schema = this.constructor.name;
26
- readonly displaySchemaName = this.constructor.name
27
- .replace(/Schema$/, '')
28
- .replace(/([A-Z])/g, ' $1')
29
- .trim()
30
- .replace(/s$/, 'ses')
31
- .replace(/([^s]s)$/, '$1es')
32
- .replace(/([^s])$/, '$1s');
27
+ readonly displaySchemaName = pluralize(
28
+ this.constructor.name
29
+ .replace(/Schema$/, '')
30
+ .replace(/([A-Z])/g, ' $1')
31
+ .trim()
32
+ );
33
33
 
34
34
  abstract readonly location: SchemaLocation;
35
35
  readonly doc?: DocSchema;