New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@teambit/semantics.entities.semantic-schema

Package Overview
Dependencies
Maintainers
17
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@teambit/semantics.entities.semantic-schema - npm Package Compare versions

Comparing version 0.0.7 to 0.0.8

api-schema.ts

4

dist/index.d.ts

@@ -1,4 +0,4 @@

export { SemanticSchema } from './semantic-schema';
export { APISchema } from './api-schema';
export type { SchemaNode } from './schema-node';
export { Export, Module, StaticProperties, FunctionSchema, TypeRefSchema } from './schemas';
export { Export, Module, StaticProperties, FunctionSchema, Parameter, TypeRefSchema, VariableSchema, ClassSchema, ConstructorSchema, TypeSchema, TypeIntersectionSchema, TypeUnionSchema, TypeLiteralSchema, IndexSignatureSchema, InterfaceSchema, GetAccessorSchema, SetAccessorSchema, } from './schemas';
export type { JSONSchema, JSONSchemaObject } from './json-schema';
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TypeRefSchema = exports.FunctionSchema = exports.Module = exports.Export = exports.SemanticSchema = void 0;
var semantic_schema_1 = require("./semantic-schema");
Object.defineProperty(exports, "SemanticSchema", { enumerable: true, get: function () { return semantic_schema_1.SemanticSchema; } });
exports.SetAccessorSchema = exports.GetAccessorSchema = exports.InterfaceSchema = exports.IndexSignatureSchema = exports.TypeLiteralSchema = exports.TypeUnionSchema = exports.TypeIntersectionSchema = exports.TypeSchema = exports.ConstructorSchema = exports.ClassSchema = exports.VariableSchema = exports.TypeRefSchema = exports.FunctionSchema = exports.Module = exports.Export = exports.APISchema = void 0;
var api_schema_1 = require("./api-schema");
Object.defineProperty(exports, "APISchema", { enumerable: true, get: function () { return api_schema_1.APISchema; } });
var schemas_1 = require("./schemas");

@@ -11,2 +11,13 @@ Object.defineProperty(exports, "Export", { enumerable: true, get: function () { return schemas_1.Export; } });

Object.defineProperty(exports, "TypeRefSchema", { enumerable: true, get: function () { return schemas_1.TypeRefSchema; } });
Object.defineProperty(exports, "VariableSchema", { enumerable: true, get: function () { return schemas_1.VariableSchema; } });
Object.defineProperty(exports, "ClassSchema", { enumerable: true, get: function () { return schemas_1.ClassSchema; } });
Object.defineProperty(exports, "ConstructorSchema", { enumerable: true, get: function () { return schemas_1.ConstructorSchema; } });
Object.defineProperty(exports, "TypeSchema", { enumerable: true, get: function () { return schemas_1.TypeSchema; } });
Object.defineProperty(exports, "TypeIntersectionSchema", { enumerable: true, get: function () { return schemas_1.TypeIntersectionSchema; } });
Object.defineProperty(exports, "TypeUnionSchema", { enumerable: true, get: function () { return schemas_1.TypeUnionSchema; } });
Object.defineProperty(exports, "TypeLiteralSchema", { enumerable: true, get: function () { return schemas_1.TypeLiteralSchema; } });
Object.defineProperty(exports, "IndexSignatureSchema", { enumerable: true, get: function () { return schemas_1.IndexSignatureSchema; } });
Object.defineProperty(exports, "InterfaceSchema", { enumerable: true, get: function () { return schemas_1.InterfaceSchema; } });
Object.defineProperty(exports, "GetAccessorSchema", { enumerable: true, get: function () { return schemas_1.GetAccessorSchema; } });
Object.defineProperty(exports, "SetAccessorSchema", { enumerable: true, get: function () { return schemas_1.SetAccessorSchema; } });
//# sourceMappingURL=index.js.map
/**
* an interface for implmenting a new schema node.
* an interface for implementing a new schema node.
*/
export interface SchemaNode {
getSignature?(): string;
toString(): string;
/**
* TODO: this should be made mandatory. this is the main serialization method.
*/
toObject?(): string;
toObject(): Record<string, any> & {
constructorName: string;
};
}

@@ -0,1 +1,26 @@

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ClassSchema = void 0;
const chalk_1 = __importDefault(require("chalk"));
class ClassSchema {
constructor(className, members) {
this.className = className;
this.members = members;
}
toObject() {
return {
constructorName: this.constructor.name,
name: this.className,
members: this.members.map((member) => member.toObject()),
};
}
toString() {
const membersStr = this.members.map((m) => `* ${m.toString()}`).join('\n');
return `${chalk_1.default.bold.underline(this.className)}\n${membersStr}`;
}
}
exports.ClassSchema = ClassSchema;
//# sourceMappingURL=class.js.map
import { SchemaNode } from '../schema-node';
declare type Primitive = string | number | boolean | null | undefined;
export declare type StaticProperties = Map<string, Primitive>;
export declare class Export {
export declare class Export implements SchemaNode {
/**

@@ -12,3 +12,3 @@ * named export identifier of the module export.

*/
readonly node?: SchemaNode;
readonly nodes?: SchemaNode[];
/**

@@ -30,3 +30,3 @@ * static properties attached to this export

*/
node?: SchemaNode,
nodes?: SchemaNode[],
/**

@@ -40,3 +40,7 @@ * static properties attached to this export

staticProperties?: StaticProperties);
toObject(): {
constructorName: string;
identifier: string;
};
}
export {};

@@ -13,3 +13,3 @@ "use strict";

*/
node,
nodes,
/**

@@ -24,7 +24,13 @@ * static properties attached to this export

this.identifier = identifier;
this.node = node;
this.nodes = nodes;
this.staticProperties = staticProperties;
}
toObject() {
return {
constructorName: this.constructor.name,
identifier: this.identifier,
};
}
}
exports.Export = Export;
//# sourceMappingURL=export.js.map
import { SchemaNode } from '../schema-node';
import { TypeRefSchema } from './type-ref';
export declare type Argument = {
export declare type Parameter = {
name: string;
type: TypeRefSchema;
defaultValue?: any;
description: any;
type: string;
description?: string;
};
export declare class FunctionSchema implements SchemaNode {
readonly name: string;
readonly args: Argument[];
readonly params: Parameter[];
readonly returnType: TypeRefSchema;
constructor(name: string, args: Argument[], returnType: TypeRefSchema);
private signature;
constructor(name: string, params: Parameter[], returnType: TypeRefSchema, signature: string);
serialize(): void;
toJsonSchema(): void;
getSignature(): string;
toObject(): {
constructorName: string;
name: string;
params: Parameter[];
returnType: {
constructorName: string;
name: string;
componentId: import("@teambit/component").ComponentID;
packageName: string;
};
signature: string;
};
toString(): string;
}
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.FunctionSchema = void 0;
const chalk_1 = __importDefault(require("chalk"));
class FunctionSchema {
constructor(name,
// readonly doc: any,
args, returnType) {
params, returnType, signature) {
this.name = name;
this.args = args;
this.params = params;
this.returnType = returnType;
this.signature = signature;
}
serialize() { }
toJsonSchema() { }
getSignature() {
return this.signature;
}
toObject() {
return {
constructorName: this.constructor.name,
name: this.name,
params: this.params,
returnType: this.returnType.toObject(),
signature: this.signature,
};
}
toString() {
const paramsStr = this.params.map((arg) => `${arg.name}: ${arg.type.toString()}`).join(', ');
return `${chalk_1.default.bold(this.name)}(${paramsStr}): ${this.returnType.toString()}`;
}
}
exports.FunctionSchema = FunctionSchema;
//# sourceMappingURL=function.js.map
export { Module } from './module';
export { Export, StaticProperties } from './export';
export { FunctionSchema } from './function';
export { FunctionSchema, Parameter } from './function';
export { TypeRefSchema } from './type-ref';
export { VariableSchema } from './variable';
export { ClassSchema } from './class';
export { ConstructorSchema } from './constructor';
export { TypeSchema } from './type';
export { TypeIntersectionSchema } from './type-intersection';
export { TypeUnionSchema } from './type-union';
export { TypeLiteralSchema } from './type-literal';
export { IndexSignatureSchema } from './index-signature';
export { InterfaceSchema } from './interface';
export { GetAccessorSchema } from './get-accessor';
export { SetAccessorSchema } from './set-accessor';
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TypeRefSchema = exports.FunctionSchema = exports.Export = exports.Module = void 0;
exports.SetAccessorSchema = exports.GetAccessorSchema = exports.InterfaceSchema = exports.IndexSignatureSchema = exports.TypeLiteralSchema = exports.TypeUnionSchema = exports.TypeIntersectionSchema = exports.TypeSchema = exports.ConstructorSchema = exports.ClassSchema = exports.VariableSchema = exports.TypeRefSchema = exports.FunctionSchema = exports.Export = exports.Module = void 0;
var module_1 = require("./module");

@@ -12,2 +12,24 @@ Object.defineProperty(exports, "Module", { enumerable: true, get: function () { return module_1.Module; } });

Object.defineProperty(exports, "TypeRefSchema", { enumerable: true, get: function () { return type_ref_1.TypeRefSchema; } });
var variable_1 = require("./variable");
Object.defineProperty(exports, "VariableSchema", { enumerable: true, get: function () { return variable_1.VariableSchema; } });
var class_1 = require("./class");
Object.defineProperty(exports, "ClassSchema", { enumerable: true, get: function () { return class_1.ClassSchema; } });
var constructor_1 = require("./constructor");
Object.defineProperty(exports, "ConstructorSchema", { enumerable: true, get: function () { return constructor_1.ConstructorSchema; } });
var type_1 = require("./type");
Object.defineProperty(exports, "TypeSchema", { enumerable: true, get: function () { return type_1.TypeSchema; } });
var type_intersection_1 = require("./type-intersection");
Object.defineProperty(exports, "TypeIntersectionSchema", { enumerable: true, get: function () { return type_intersection_1.TypeIntersectionSchema; } });
var type_union_1 = require("./type-union");
Object.defineProperty(exports, "TypeUnionSchema", { enumerable: true, get: function () { return type_union_1.TypeUnionSchema; } });
var type_literal_1 = require("./type-literal");
Object.defineProperty(exports, "TypeLiteralSchema", { enumerable: true, get: function () { return type_literal_1.TypeLiteralSchema; } });
var index_signature_1 = require("./index-signature");
Object.defineProperty(exports, "IndexSignatureSchema", { enumerable: true, get: function () { return index_signature_1.IndexSignatureSchema; } });
var interface_1 = require("./interface");
Object.defineProperty(exports, "InterfaceSchema", { enumerable: true, get: function () { return interface_1.InterfaceSchema; } });
var get_accessor_1 = require("./get-accessor");
Object.defineProperty(exports, "GetAccessorSchema", { enumerable: true, get: function () { return get_accessor_1.GetAccessorSchema; } });
var set_accessor_1 = require("./set-accessor");
Object.defineProperty(exports, "SetAccessorSchema", { enumerable: true, get: function () { return set_accessor_1.SetAccessorSchema; } });
//# sourceMappingURL=index.js.map

@@ -1,13 +0,17 @@

import { Export } from './export';
import { SchemaNode } from '../schema-node';
import { Export } from '../schemas';
export declare class Module implements SchemaNode {
/**
* all module exports.
*/
readonly exports: Export[];
constructor(
/**
* all module exports.
*/
exports: Export[]);
exports: SchemaNode[];
namespace?: string;
constructor(exports: SchemaNode[]);
getExportSchemas(): Export[];
toObject(): {
constructorName: string;
namespace: string;
exports: (Record<string, any> & {
constructorName: string;
})[];
};
flatExportsRecursively(): void;
toString(): string;
}
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Module = void 0;
const chalk_1 = __importDefault(require("chalk"));
const schemas_1 = require("../schemas");
class Module {
constructor(
/**
* all module exports.
*/
exports) {
constructor(exports) {
this.exports = exports;
}
getExportSchemas() {
return this.exports.filter((e) => e instanceof schemas_1.Export);
}
toObject() {
return {
constructorName: this.constructor.name,
namespace: this.namespace,
exports: this.exports.map((exp) => exp.toObject()),
};
}
flatExportsRecursively() {
this.exports = this.exports.reduce((acc, exp) => {
if (exp instanceof Module) {
exp.flatExportsRecursively();
if (exp.namespace)
return [...acc, exp];
return [...acc, ...exp.exports];
}
return [...acc, exp];
}, []);
}
toString() {
if (!this.namespace)
throw new Error('toString() should not be called on a module without namespace, make sure this.flatExportsRecursively() is called');
const exportsStr = this.exports.map((m) => `* ${m.toString()}`).join('\n');
return `${chalk_1.default.bold.underline(this.namespace)}\n${exportsStr}`;
}
}
exports.Module = Module;
//# sourceMappingURL=module.js.map

@@ -36,3 +36,10 @@ import { ComponentID } from '@teambit/component';

packageName?: string, node?: SchemaNode);
toObject(): {
constructorName: string;
name: string;
componentId: ComponentID;
packageName: string;
};
toString(): string;
static from(plainSchema: PlainTypeRefSchema): TypeRefSchema;
}
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.TypeRefSchema = void 0;
const component_1 = require("@teambit/component");
const chalk_1 = __importDefault(require("chalk"));
class TypeRefSchema {

@@ -24,2 +28,19 @@ constructor(

}
toObject() {
return {
constructorName: this.constructor.name,
name: this.name,
componentId: this.componentId,
packageName: this.packageName,
};
}
toString() {
if (this.componentId) {
return `${this.componentId}/${this.name}`;
}
if (this.packageName) {
return `${chalk_1.default.dim(this.packageName)}/${this.name}`;
}
return this.name;
}
static from(plainSchema) {

@@ -26,0 +47,0 @@ return new TypeRefSchema(plainSchema.name, plainSchema.componentId ? component_1.ComponentID.fromString(plainSchema.componentId) : undefined, plainSchema.packageName, plainSchema.node);

@@ -0,1 +1,27 @@

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.TypeSchema = void 0;
const chalk_1 = __importDefault(require("chalk"));
class TypeSchema {
constructor(name, type, signature) {
this.name = name;
this.type = type;
this.signature = signature;
}
toObject() {
return {
constructorName: this.constructor.name,
name: this.name,
type: this.type.toObject(),
signature: this.signature,
};
}
toString() {
return `${chalk_1.default.bold(this.name)}: ${this.type.toString()}`;
}
}
exports.TypeSchema = TypeSchema;
//# sourceMappingURL=type.js.map

@@ -1,4 +0,22 @@

export { SemanticSchema } from './semantic-schema';
export { APISchema } from './api-schema';
export type { SchemaNode } from './schema-node';
export { Export, Module, StaticProperties, FunctionSchema, TypeRefSchema } from './schemas';
export {
Export,
Module,
StaticProperties,
FunctionSchema,
Parameter,
TypeRefSchema,
VariableSchema,
ClassSchema,
ConstructorSchema,
TypeSchema,
TypeIntersectionSchema,
TypeUnionSchema,
TypeLiteralSchema,
IndexSignatureSchema,
InterfaceSchema,
GetAccessorSchema,
SetAccessorSchema,
} from './schemas';
export type { JSONSchema, JSONSchemaObject } from './json-schema';
{
"name": "@teambit/semantics.entities.semantic-schema",
"version": "0.0.7",
"version": "0.0.8",
"homepage": "https://bit.dev/teambit/semantics/entities/semantic-schema",

@@ -9,5 +9,6 @@ "main": "dist/index.js",

"name": "entities/semantic-schema",
"version": "0.0.7"
"version": "0.0.8"
},
"dependencies": {
"chalk": "4.1.2",
"json-schema": "0.4.0"

@@ -14,0 +15,0 @@ },

/**
* an interface for implmenting a new schema node.
* an interface for implementing a new schema node.
*/
export interface SchemaNode {
getSignature?(): string;
toString(): string;
/**
* TODO: this should be made mandatory. this is the main serialization method.
*/
toObject?(): string;
toObject(): Record<string, any> & { constructorName: string };
}

@@ -6,3 +6,3 @@ import { SchemaNode } from '../schema-node';

export class Export {
export class Export implements SchemaNode {
constructor(

@@ -17,3 +17,3 @@ /**

*/
readonly node?: SchemaNode,
readonly nodes?: SchemaNode[],

@@ -29,2 +29,9 @@ /**

) {}
toObject() {
return {
constructorName: this.constructor.name,
identifier: this.identifier,
};
}
}

@@ -0,9 +1,10 @@

import chalk from 'chalk';
import { SchemaNode } from '../schema-node';
import { TypeRefSchema } from './type-ref';
export type Argument = {
export type Parameter = {
name: string;
type: TypeRefSchema;
defaultValue?: any;
description: any;
type: string;
description?: string;
};

@@ -15,5 +16,6 @@

// readonly doc: any,
readonly args: Argument[],
readonly params: Parameter[],
readonly returnType: TypeRefSchema
readonly returnType: TypeRefSchema,
private signature: string
) {}

@@ -24,2 +26,21 @@

toJsonSchema() {}
getSignature() {
return this.signature;
}
toObject() {
return {
constructorName: this.constructor.name,
name: this.name,
params: this.params,
returnType: this.returnType.toObject(),
signature: this.signature,
};
}
toString() {
const paramsStr = this.params.map((arg) => `${arg.name}: ${arg.type.toString()}`).join(', ');
return `${chalk.bold(this.name)}(${paramsStr}): ${this.returnType.toString()}`;
}
}
export { Module } from './module';
export { Export, StaticProperties } from './export';
export { FunctionSchema } from './function';
export { FunctionSchema, Parameter } from './function';
export { TypeRefSchema } from './type-ref';
export { VariableSchema } from './variable';
export { ClassSchema } from './class';
export { ConstructorSchema } from './constructor';
export { TypeSchema } from './type';
export { TypeIntersectionSchema } from './type-intersection';
export { TypeUnionSchema } from './type-union';
export { TypeLiteralSchema } from './type-literal';
export { IndexSignatureSchema } from './index-signature';
export { InterfaceSchema } from './interface';
export { GetAccessorSchema } from './get-accessor';
export { SetAccessorSchema } from './set-accessor';

@@ -1,11 +0,40 @@

import { Export } from './export';
import chalk from 'chalk';
import { SchemaNode } from '../schema-node';
import { Export } from '../schemas';
export class Module implements SchemaNode {
constructor(
/**
* all module exports.
*/
readonly exports: Export[]
) {}
namespace?: string;
constructor(public exports: SchemaNode[]) {}
getExportSchemas(): Export[] {
return this.exports.filter((e) => e instanceof Export) as Export[];
}
toObject() {
return {
constructorName: this.constructor.name,
namespace: this.namespace,
exports: this.exports.map((exp) => exp.toObject()),
};
}
flatExportsRecursively() {
this.exports = this.exports.reduce((acc, exp) => {
if (exp instanceof Module) {
exp.flatExportsRecursively();
if (exp.namespace) return [...acc, exp];
return [...acc, ...exp.exports];
}
return [...acc, exp];
}, [] as SchemaNode[]);
}
toString() {
if (!this.namespace)
throw new Error(
'toString() should not be called on a module without namespace, make sure this.flatExportsRecursively() is called'
);
const exportsStr = this.exports.map((m) => `* ${m.toString()}`).join('\n');
return `${chalk.bold.underline(this.namespace)}\n${exportsStr}`;
}
}
import { ComponentID } from '@teambit/component';
import chalk from 'chalk';
import { SchemaNode } from '../schema-node';

@@ -31,2 +32,21 @@

toObject() {
return {
constructorName: this.constructor.name,
name: this.name,
componentId: this.componentId,
packageName: this.packageName,
};
}
toString() {
if (this.componentId) {
return `${this.componentId}/${this.name}`;
}
if (this.packageName) {
return `${chalk.dim(this.packageName)}/${this.name}`;
}
return this.name;
}
static from(plainSchema: PlainTypeRefSchema) {

@@ -33,0 +53,0 @@ return new TypeRefSchema(

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc