Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@embracesql/shared

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@embracesql/shared - npm Package Compare versions

Comparing version 0.0.13 to 0.0.14

4

package.json
{
"name": "@embracesql/shared",
"version": "0.0.13",
"version": "0.0.14",
"description": "EmbraceSQL shared types between browser and node.",

@@ -17,3 +17,3 @@ "type": "module",

},
"gitHead": "448c86eec2b97e67e555867f7c3ca08459993d24"
"gitHead": "4f59f194e44a54194d5f8d1344a1c0adadfd4958"
}

@@ -15,2 +15,7 @@ import {

/**
* Common name for pimary key.
*/
export const PRIMARY_KEY = "PrimaryKey";
/**
* Common name for return results.

@@ -51,3 +56,2 @@ *

Index,
IndexColumn,
Types,

@@ -72,2 +76,3 @@ CreateOperation,

Results,
Parameters,
}

@@ -125,3 +130,2 @@

[ASTKind.Index]: IndexNode;
[ASTKind.IndexColumn]: IndexColumnNode;
[ASTKind.Types]: TypesNode;

@@ -146,2 +150,3 @@ [ASTKind.CreateOperation]: CreateOperationNode;

[ASTKind.Results]: ResultsNode;
[ASTKind.Parameters]: ParametersNode;
};

@@ -545,3 +550,3 @@

const primaryKeyNames = this.primaryKey
? this.primaryKey.columns.map((c) => c.name)
? this.primaryKey.type.attributes.map((c) => c.name)
: [];

@@ -553,3 +558,3 @@ return this.allColumns.filter((a) => primaryKeyNames.includes(a.name));

const primaryKeyNames = this.primaryKey
? this.primaryKey.columns.map((c) => c.name)
? this.primaryKey.type.attributes.map((c) => c.name)
: [];

@@ -604,12 +609,9 @@ return this.allColumns.filter((a) => !primaryKeyNames.includes(a.name));

constructor(
public name: string,
public table: TableNode,
public name: string,
public unique: boolean,
public primaryKey: boolean,
attributes: NamedType[],
public type: CompositeTypeNode,
) {
super(name, ASTKind.Index, table);
attributes.forEach((a) => new IndexColumnNode(this, a.name, a.type));
// important that the operations go after the attributes
// so that we can have a well defined `typescriptName`
new ReadOperationNode(this);

@@ -619,38 +621,14 @@ new UpdateOperationNode(this);

}
get typescriptName() {
return `By${pascalCase(
this.columns.map((c) => c.typescriptName).join("_"),
)}`;
}
get columns(): IndexColumnNode[] {
return this.children.filter(
(n) => n.kind === ASTKind.IndexColumn,
) as IndexColumnNode[];
}
}
/**
* A single column on a single index in a schema in a database.
*/
export class IndexColumnNode extends ContainerNode implements NamedType {
constructor(
public index: IndexNode,
public name: string,
public type: TypeNode,
) {
super(name, ASTKind.IndexColumn, index);
}
}
// operations
export abstract class OperationNode extends ContainerNode {
/**
* Operations have parameters, inputs with a type.
*/
get parametersType() {
return this.children
.filter<CompositeTypeNode>(
(c): c is CompositeTypeNode => c.kind === ASTKind.CompositeType,
)
.find((c) => c.name === PARAMETERS);
return this.children.find<ParametersNode>(
(c): c is ParametersNode => c.kind === ASTKind.Parameters,
)?.type;
}

@@ -680,5 +658,5 @@ }

get resultsType() {
return this.children.filter<ResultsNode>(
return this.children.find<ResultsNode>(
(c): c is ResultsNode => c.kind === ASTKind.Results,
)[0].type;
)?.type;
}

@@ -843,3 +821,3 @@ }

id: string | number,
comment: string,
comment = "",
) {

@@ -854,21 +832,2 @@ super(name, ASTKind.CompositeType, parent, id, comment);

}
override typescriptTypeDefinition(
context: GenerationContext,
): string | undefined {
console.assert(context);
const attributes = this.children
.filter<AttributeNode>(
(c): c is AttributeNode => c.kind === ASTKind.Attribute,
)
.map((a) => {
if (a.type.kind === ASTKind.ArrayType) {
return `${a.typescriptPropertyName}: ${a.type.typescriptNamespacedName};`;
}
if (a.nullable) {
return `${a.typescriptPropertyName}: Nullable<${a.type.typescriptNamespacedName}>;`;
}
return `${a.typescriptPropertyName}: ${a.type.typescriptNamespacedName};`;
});
return ` { ${attributes.join("\n")} } `;
}

@@ -968,3 +927,3 @@ override typescriptTypeParser(context: GenerationContext) {

*/
export class ResultsNode extends ASTNode {
export class ResultsNode extends NamedASTNode {
constructor(

@@ -974,4 +933,16 @@ parent: ContainerNode,

) {
super(ASTKind.Results, parent);
super(RESULTS, ASTKind.Results, parent);
}
}
/**
* Parameters reference a type, but are not a type themselves.
*/
export class ParametersNode extends NamedASTNode {
constructor(
parent: ContainerNode,
public type: CompositeTypeNode,
) {
super(PARAMETERS, ASTKind.Parameters, parent);
}
}
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