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

@loancrate/prisma-schema-parser

Package Overview
Dependencies
Maintainers
3
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@loancrate/prisma-schema-parser - npm Package Compare versions

Comparing version 1.0.0 to 2.0.0

5

dist/ast.d.ts

@@ -106,4 +106,3 @@ export interface PrismaSchema {

}
export declare type SchemaExpression = ConstantExpression | FunctionCall;
export declare type ConstantExpression = ScalarLiteral | PathExpression | ArrayExpression;
export declare type SchemaExpression = ScalarLiteral | PathExpression | ArrayExpression | FunctionCall;
export interface ScalarLiteral<T = string | number | boolean> {

@@ -120,3 +119,3 @@ kind: "literal";

kind: "array";
items: ConstantExpression[];
items: SchemaExpression[];
}

@@ -123,0 +122,0 @@ export interface FunctionCall {

19

dist/attributes.d.ts

@@ -13,8 +13,12 @@ import "error-cause/auto";

export declare function findIdFieldAttribute(decl: FieldDeclaration): IdFieldAttribute | undefined;
export interface IndexField {
name: string;
length?: number;
sort?: SortOrder;
ops?: string;
}
export interface IdBlockAttribute {
fields: string[];
fields: IndexField[];
name?: string;
map?: string;
length?: number;
sort?: SortOrder;
clustered?: boolean;

@@ -36,7 +40,5 @@ }

export interface UniqueBlockAttribute {
fields: string[];
fields: IndexField[];
name?: string;
map?: string;
length?: number;
sort?: SortOrder;
clustered?: boolean;

@@ -46,10 +48,7 @@ }

export interface IndexBlockAttribute {
fields: string[];
fields: IndexField[];
name?: string;
map?: string;
length?: number;
sort?: SortOrder;
clustered?: boolean;
type?: string;
ops?: string;
}

@@ -56,0 +55,0 @@ export declare function findIndexBlockAttributes(decl: ModelDeclaration): IndexBlockAttribute[];

@@ -27,6 +27,28 @@ "use strict";

length: applyOptional((0, access_1.findArgument)(attr.args, "length"), access_1.readNumberArgument),
sort: applyOptional(applyOptional((0, access_1.findArgument)(attr.args, "sort"), access_1.readStringArgument), asSortOrder),
sort: applyOptional(applyOptional((0, access_1.findArgument)(attr.args, "sort"), access_1.readFieldReferenceArgument), asSortOrder),
clustered: applyOptional((0, access_1.findArgument)(attr.args, "clustered"), access_1.readBooleanArgument),
};
}
function readFieldArgument(arg) {
const expr = (0, access_1.getArgumentExpression)(arg);
if (expr.kind === "path") {
return { name: (0, format_1.joinPath)(expr.value) };
}
if (expr.kind === "functionCall") {
return {
name: (0, format_1.joinPath)(expr.path.value),
length: applyOptional((0, access_1.findArgument)(expr.args, "length"), access_1.readNumberArgument),
sort: applyOptional(applyOptional((0, access_1.findArgument)(expr.args, "sort"), access_1.readFieldReferenceArgument), asSortOrder),
ops: applyOptional((0, access_1.findArgument)(expr.args, "ops"), readOpsArgument),
};
}
throw (0, access_1.getArgumentTypeError)(arg, "Field reference or function call");
}
function readFieldsArgument(arg) {
const expr = (0, access_1.getArgumentExpression)(arg);
if (expr.kind === "array") {
return expr.items.map(readFieldArgument);
}
return [readFieldArgument(arg)];
}
function findIdBlockAttribute(decl) {

@@ -38,5 +60,6 @@ return parseUniqueAttributeWith(decl, "id", parseIdBlockAttribute);

return {
fields: (0, access_1.readFieldReferencesArgument)((0, access_1.getArgument)(attr.args, "fields", 0)),
fields: readFieldsArgument((0, access_1.getArgument)(attr.args, "fields", 0)),
name: applyOptional((0, access_1.findArgument)(attr.args, "name"), access_1.readStringArgument),
...parseIdFieldAttribute(attr),
map: applyOptional((0, access_1.findArgument)(attr.args, "map"), access_1.readStringArgument),
clustered: applyOptional((0, access_1.findArgument)(attr.args, "clustered"), access_1.readBooleanArgument),
};

@@ -62,4 +85,3 @@ }

...parseIdBlockAttribute(attr),
type: applyOptional((0, access_1.findArgument)(attr.args, "type"), access_1.readStringArgument),
ops: applyOptional((0, access_1.findArgument)(attr.args, "ops"), readOpsArgument),
type: applyOptional((0, access_1.findArgument)(attr.args, "type"), access_1.readFieldReferenceArgument),
}));

@@ -70,9 +92,9 @@ }

const expr = (0, access_1.getArgumentExpression)(arg);
if (expr.kind === "path") {
return (0, format_1.joinPath)(expr.value);
}
if (expr.kind === "functionCall") {
return (0, format_1.formatAst)(expr);
}
if (expr.kind === "literal" && typeof expr.value === "string") {
return expr.value;
}
throw (0, access_1.getArgumentTypeError)(arg, "String literal or function call");
throw (0, access_1.getArgumentTypeError)(arg, "Identifier or function call");
}

@@ -79,0 +101,0 @@ exports.readOpsArgument = readOpsArgument;

{
"name": "@loancrate/prisma-schema-parser",
"version": "1.0.0",
"version": "2.0.0",
"description": "Prisma Schema Parser",

@@ -5,0 +5,0 @@ "keywords": [

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is too big to display

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