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

prisma-client-lib

Package Overview
Dependencies
Maintainers
1
Versions
498
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

prisma-client-lib - npm Package Compare versions

Comparing version 0.2.58 to 0.2.59

dist/codegen/typescript-definitions.d.ts

4

dist/Client.js

@@ -192,2 +192,3 @@ "use strict";

inactivityTimeout: 60000,
lazy: true,
}, WS);

@@ -304,3 +305,4 @@ }

var fieldType = _this.getDeepType(field.type);
return fieldType instanceof graphql_1.GraphQLScalarType;
return (fieldType instanceof graphql_1.GraphQLScalarType ||
fieldType instanceof graphql_1.GraphQLEnumType);
})

@@ -307,0 +309,0 @@ .map(function (_a) {

@@ -15,3 +15,3 @@ import { TypescriptGenerator } from './typescript-client';

renderClientConstructor(): string;
format(code: string, options?: prettier.Options): any;
format(code: string, options?: prettier.Options): string;
renderAtLeastOne(): string;

@@ -18,0 +18,0 @@ renderGraphQL(): string;

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

var prettier = require("prettier");
var version = require('../../package.json').version;
var codeComment_1 = require("../utils/codeComment");
var FlowGenerator = /** @class */ (function (_super) {

@@ -48,3 +48,3 @@ __extends(FlowGenerator, _super);

FlowGenerator.prototype.renderImports = function () {
return "/**\n * @flow\n */\n\n// Code generated by Prisma CLI (https://github.com/prisma/prisma) and prisma-client-lib@" + version + ". DO NOT EDIT.\n\nimport type { GraphQLSchema } from 'graphql'\nimport type { IResolvers } from 'graphql-tools/dist/Interfaces'\nimport type { BasePrismaOptions as BPOType, Options } from 'prisma-client-lib'\nimport { makePrismaClientClass } from 'prisma-client-lib'\nimport { typeDefs } from './prisma-schema'";
return "/**\n * @flow\n */\n\n" + codeComment_1.codeComment + "\n\nimport type { GraphQLSchema } from 'graphql'\nimport type { IResolvers } from 'graphql-tools/dist/Interfaces'\nimport type { BasePrismaOptions as BPOType, Options } from 'prisma-client-lib'\nimport { makePrismaClientClass } from 'prisma-client-lib'\nimport { typeDefs } from './prisma-schema'";
};

@@ -51,0 +51,0 @@ FlowGenerator.prototype.renderClientConstructor = function () {

@@ -19,2 +19,3 @@ "use strict";

var getTypeNames_1 = require("../utils/getTypeNames");
var codeComment_1 = require("../utils/codeComment");
var goCase = function (s) {

@@ -229,3 +230,3 @@ var cased = upperCamelCase(s);

GoGenerator.prototype.renderLib = function (options) {
return "\n// Code generated by Prisma CLI (https://github.com/prisma/prisma). DO NOT EDIT.\npackage prisma\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"html/template\"\n\t\"reflect\"\n)\n\n// GraphQLField docs\ntype GraphQLField struct {\n Name string\n TypeName string\n TypeFields []string\n}\n\n// GraphQLArg docs\ntype GraphQLArg struct {\n Name string\n Key string\n TypeName string\n Value interface{}\n}\n\n// Instruction docs\ntype Instruction struct {\n Name string\n Field GraphQLField\n Operation string\n\tArgs []GraphQLArg\n}\n\nfunc isZeroOfUnderlyingType(x interface{}) bool {\n\treturn reflect.DeepEqual(x, reflect.Zero(reflect.TypeOf(x)).Interface())\n}\n\nfunc isArray(i interface{}) bool {\n v := reflect.ValueOf(i)\n switch v.Kind() {\n case reflect.Array:\n return true\n case reflect.Slice:\n return true\n default:\n return false\n }\n}\n\ntype PrismaOptions struct {\n\tEndpoint string\n\tDebug bool\n}\n\nfunc New(options *PrismaOptions) Client {\n if options == nil {\n return Client{}\n }\n\treturn Client{\n\t\tEndpoint: options.Endpoint,\n\t\tDebug: options.Debug,\n\t\tExists: Exists{\n\t\t\tEndpoint: options.Endpoint,\n\t\t\tDebug: options.Debug,\n\t\t},\n\t}\n}\n\ntype Client struct {\n Endpoint string\n Debug bool\n Exists Exists\n}\n\n// Exists docs\ntype Exists struct {\n\tEndpoint string\n\tDebug bool\n}\n\n// ProcessInstructions docs\nfunc (client *Client) ProcessInstructions(stack []Instruction) string {\n\tquery := make(map[string]interface{})\n\targsByInstruction := make(map[string][]GraphQLArg)\n\tvar allArgs []GraphQLArg\n\tfirstInstruction := stack[0]\n\tfor i := len(stack) - 1; i >= 0; i-- {\n\t\tinstruction := stack[i]\n\t\tif client.Debug {\n\t\t\tfmt.Println(\"Instruction: \", instruction)\n\t\t}\n\t\tif len(query) == 0 {\n\t\t\tquery[instruction.Name] = instruction.Field.TypeFields\n argsByInstruction[instruction.Name] = instruction.Args\n for _, arg := range instruction.Args {\n\t\t\t\tallArgs = append(allArgs, arg)\n\t\t\t}\n\t\t} else {\n\t\t\tpreviousInstruction := stack[i+1]\n\t\t\tquery[instruction.Name] = map[string]interface{}{\n\t\t\t\tpreviousInstruction.Name: query[previousInstruction.Name],\n\t\t\t}\n argsByInstruction[instruction.Name] = instruction.Args\n for _, arg := range instruction.Args {\n\t\t\t\tallArgs = append(allArgs, arg)\n\t\t\t}\n\t\t\tdelete(query, previousInstruction.Name)\n\t\t}\n\t}\n\n\tif client.Debug {\n\t\tfmt.Println(\"Final Query:\", query)\n\t\tfmt.Println(\"Final Args By Instruction:\", argsByInstruction)\n\t\tfmt.Println(\"Final All Args:\", allArgs)\n\t}\n\n\t// TODO: Make this recursive - current depth = 3\n\tqueryTemplateString := `\n {{ $.operation }} {{ $.operationName }} \n \t{{- if eq (len $.allArgs) 0 }} {{ else }} ( {{ end }}\n \t{{- range $_, $arg := $.allArgs }}\n\t\t\t${{ $arg.Name }}: {{ $arg.TypeName }}, \n\t\t{{- end }}\n\t{{- if eq (len $.allArgs) 0 }} {{ else }} ) {{ end }}\n {\n {{- range $k, $v := $.query }}\n {{- if isArray $v }}\n\t {{- $k }}\n\t {{- range $argKey, $argValue := $.argsByInstruction }}\n\t {{- if eq $argKey $k }}\n\t \t{{- if eq (len $argValue) 0 }} {{ else }} ( {{ end }}\n\t\t\t\t{{- range $k, $arg := $argValue}}\n\t\t\t\t\t{{ $arg.Key }}: ${{ $arg.Name }},\n\t\t\t\t{{- end }}\n\t\t{{- if eq (len $argValue) 0 }} {{ else }} ) {{ end }}\n\t\t\t{{- end }}\n\t\t{{- end }}\n\t {\n {{- range $k1, $v1 := $v }}\n {{ $v1 }}\n {{end}}\n }\n {{- else }}\n\t {{ $k }} \n\t {{- range $argKey, $argValue := $.argsByInstruction }}\n\t \t{{- if eq $argKey $k }}\n\t \t\t{{- if eq (len $argValue) 0 }} {{ else }} ( {{ end }}\n {{- range $k, $arg := $argValue}}\n {{ $arg.Key }}: ${{ $arg.Name }},\n {{- end }}\n\t\t\t{{- if eq (len $argValue) 0 }} {{ else }} ) {{ end }}\n {{- end }}\n {{- end }}\n\t\t{\n {{- range $k, $v := $v }}\n {{- if isArray $v }}\n\t\t {{ $k }} \n\t\t {{- range $argKey, $argValue := $.argsByInstruction }}\n\t\t {{- if eq $argKey $k }}\n\t\t\t{{- if eq (len $argValue) 0 }} {{ else }} ( {{ end }}\n {{- range $k, $arg := $argValue}}\n {{ $arg.Key }}: ${{ $arg.Name }},\n {{- end }}\n\t\t\t\t{{- if eq (len $argValue) 0 }} {{ else }} ) {{ end }} \n {{- end }}\n {{- end }}\n\t\t\t{ \n {{- range $k1, $v1 := $v }}\n {{ $v1 }}\n {{end}}\n }\n {{- else }}\n\t\t {{ $k }} \n\t\t {{- range $argKey, $argValue := $.argsByInstruction }}\n\t\t {{- if eq $argKey $k }}\n\t\t \t{{- if eq (len $argValue) 0 }} {{ else }} ( {{ end }}\n {{- range $k, $arg := $argValue}}\n {{ $arg.Key }}: ${{ $arg.Name }},\n {{- end }}\n\t\t\t\t{{- if eq (len $argValue) 0 }} {{ else }} ) {{ end }} \n {{- end }}\n {{- end }}\n\t\t\t{\n {{- range $k, $v := $v }}\n {{- if isArray $v }}\n {{ $k }} { \n {{- range $k1, $v1 := $v }}\n {{ $v1 }}\n {{end}}\n }\n {{- else }}\n\t\t\t\t{{ $k }} \n\t\t\t\t{{- range $argKey, $argValue := $.argsByInstruction }}\n\t\t\t\t{{- if eq $argKey $k }}\n\t\t\t\t\t{{- if eq (len $argValue) 0 }} {{ else }} ( {{ end }}\n {{- range $k, $arg := $argValue}}\n {{ $arg.Key }}: ${{ $arg.Name }},\n {{- end }}\n\t\t\t\t\t {{- if eq (len $argValue) 0 }} {{ else }} ) {{ end }} \n {{- end }}\n {{- end }}\n\t\t\t\t {\n id\n }\n {{- end }}\n {{- end }}\n }\n {{- end }}\n {{- end }}\n }\n {{- end }}\n {{- end }}\n }\n `\n\n\ttemplateFunctions := template.FuncMap{\n\t\t\"isArray\": isArray,\n\t}\n\n\tqueryTemplate, err := template.New(\"query\").Funcs(templateFunctions).Parse(queryTemplateString)\n\tvar queryBytes bytes.Buffer\n\tvar data = make(map[string]interface{})\n\tdata = map[string]interface{}{\n\t\t\"query\": query,\n\t\t\"argsByInstruction\": argsByInstruction,\n\t\t\"allArgs\": allArgs,\n\t\t\"operation\": firstInstruction.Operation,\n\t\t\"operationName\": firstInstruction.Name,\n\t}\n\tqueryTemplate.Execute(&queryBytes, data)\n\n\tif client.Debug {\n\t\tfmt.Println(\"Query String: \", queryBytes.String())\n\t}\n\tif err == nil {\n\t\treturn queryBytes.String()\n\t}\n\treturn \"Failed to generate query\"\n}\n ";
return "\n" + codeComment_1.codeComment + "\npackage prisma\n\nimport (\n\t\"bytes\"\n\t\"fmt\"\n\t\"html/template\"\n\t\"reflect\"\n)\n\n// GraphQLField docs\ntype GraphQLField struct {\n Name string\n TypeName string\n TypeFields []string\n}\n\n// GraphQLArg docs\ntype GraphQLArg struct {\n Name string\n Key string\n TypeName string\n Value interface{}\n}\n\n// Instruction docs\ntype Instruction struct {\n Name string\n Field GraphQLField\n Operation string\n\tArgs []GraphQLArg\n}\n\nfunc isZeroOfUnderlyingType(x interface{}) bool {\n\treturn reflect.DeepEqual(x, reflect.Zero(reflect.TypeOf(x)).Interface())\n}\n\nfunc isArray(i interface{}) bool {\n v := reflect.ValueOf(i)\n switch v.Kind() {\n case reflect.Array:\n return true\n case reflect.Slice:\n return true\n default:\n return false\n }\n}\n\ntype PrismaOptions struct {\n\tEndpoint string\n\tDebug bool\n}\n\nfunc New(options *PrismaOptions) Client {\n if options == nil {\n return Client{}\n }\n\treturn Client{\n\t\tEndpoint: options.Endpoint,\n\t\tDebug: options.Debug,\n\t\tExists: Exists{\n\t\t\tEndpoint: options.Endpoint,\n\t\t\tDebug: options.Debug,\n\t\t},\n\t}\n}\n\ntype Client struct {\n Endpoint string\n Debug bool\n Exists Exists\n}\n\n// Exists docs\ntype Exists struct {\n\tEndpoint string\n\tDebug bool\n}\n\n// ProcessInstructions docs\nfunc (client *Client) ProcessInstructions(stack []Instruction) string {\n\tquery := make(map[string]interface{})\n\targsByInstruction := make(map[string][]GraphQLArg)\n\tvar allArgs []GraphQLArg\n\tfirstInstruction := stack[0]\n\tfor i := len(stack) - 1; i >= 0; i-- {\n\t\tinstruction := stack[i]\n\t\tif client.Debug {\n\t\t\tfmt.Println(\"Instruction: \", instruction)\n\t\t}\n\t\tif len(query) == 0 {\n\t\t\tquery[instruction.Name] = instruction.Field.TypeFields\n argsByInstruction[instruction.Name] = instruction.Args\n for _, arg := range instruction.Args {\n\t\t\t\tallArgs = append(allArgs, arg)\n\t\t\t}\n\t\t} else {\n\t\t\tpreviousInstruction := stack[i+1]\n\t\t\tquery[instruction.Name] = map[string]interface{}{\n\t\t\t\tpreviousInstruction.Name: query[previousInstruction.Name],\n\t\t\t}\n argsByInstruction[instruction.Name] = instruction.Args\n for _, arg := range instruction.Args {\n\t\t\t\tallArgs = append(allArgs, arg)\n\t\t\t}\n\t\t\tdelete(query, previousInstruction.Name)\n\t\t}\n\t}\n\n\tif client.Debug {\n\t\tfmt.Println(\"Final Query:\", query)\n\t\tfmt.Println(\"Final Args By Instruction:\", argsByInstruction)\n\t\tfmt.Println(\"Final All Args:\", allArgs)\n\t}\n\n\t// TODO: Make this recursive - current depth = 3\n\tqueryTemplateString := `\n {{ $.operation }} {{ $.operationName }} \n \t{{- if eq (len $.allArgs) 0 }} {{ else }} ( {{ end }}\n \t{{- range $_, $arg := $.allArgs }}\n\t\t\t${{ $arg.Name }}: {{ $arg.TypeName }}, \n\t\t{{- end }}\n\t{{- if eq (len $.allArgs) 0 }} {{ else }} ) {{ end }}\n {\n {{- range $k, $v := $.query }}\n {{- if isArray $v }}\n\t {{- $k }}\n\t {{- range $argKey, $argValue := $.argsByInstruction }}\n\t {{- if eq $argKey $k }}\n\t \t{{- if eq (len $argValue) 0 }} {{ else }} ( {{ end }}\n\t\t\t\t{{- range $k, $arg := $argValue}}\n\t\t\t\t\t{{ $arg.Key }}: ${{ $arg.Name }},\n\t\t\t\t{{- end }}\n\t\t{{- if eq (len $argValue) 0 }} {{ else }} ) {{ end }}\n\t\t\t{{- end }}\n\t\t{{- end }}\n\t {\n {{- range $k1, $v1 := $v }}\n {{ $v1 }}\n {{end}}\n }\n {{- else }}\n\t {{ $k }} \n\t {{- range $argKey, $argValue := $.argsByInstruction }}\n\t \t{{- if eq $argKey $k }}\n\t \t\t{{- if eq (len $argValue) 0 }} {{ else }} ( {{ end }}\n {{- range $k, $arg := $argValue}}\n {{ $arg.Key }}: ${{ $arg.Name }},\n {{- end }}\n\t\t\t{{- if eq (len $argValue) 0 }} {{ else }} ) {{ end }}\n {{- end }}\n {{- end }}\n\t\t{\n {{- range $k, $v := $v }}\n {{- if isArray $v }}\n\t\t {{ $k }} \n\t\t {{- range $argKey, $argValue := $.argsByInstruction }}\n\t\t {{- if eq $argKey $k }}\n\t\t\t{{- if eq (len $argValue) 0 }} {{ else }} ( {{ end }}\n {{- range $k, $arg := $argValue}}\n {{ $arg.Key }}: ${{ $arg.Name }},\n {{- end }}\n\t\t\t\t{{- if eq (len $argValue) 0 }} {{ else }} ) {{ end }} \n {{- end }}\n {{- end }}\n\t\t\t{ \n {{- range $k1, $v1 := $v }}\n {{ $v1 }}\n {{end}}\n }\n {{- else }}\n\t\t {{ $k }} \n\t\t {{- range $argKey, $argValue := $.argsByInstruction }}\n\t\t {{- if eq $argKey $k }}\n\t\t \t{{- if eq (len $argValue) 0 }} {{ else }} ( {{ end }}\n {{- range $k, $arg := $argValue}}\n {{ $arg.Key }}: ${{ $arg.Name }},\n {{- end }}\n\t\t\t\t{{- if eq (len $argValue) 0 }} {{ else }} ) {{ end }} \n {{- end }}\n {{- end }}\n\t\t\t{\n {{- range $k, $v := $v }}\n {{- if isArray $v }}\n {{ $k }} { \n {{- range $k1, $v1 := $v }}\n {{ $v1 }}\n {{end}}\n }\n {{- else }}\n\t\t\t\t{{ $k }} \n\t\t\t\t{{- range $argKey, $argValue := $.argsByInstruction }}\n\t\t\t\t{{- if eq $argKey $k }}\n\t\t\t\t\t{{- if eq (len $argValue) 0 }} {{ else }} ( {{ end }}\n {{- range $k, $arg := $argValue}}\n {{ $arg.Key }}: ${{ $arg.Name }},\n {{- end }}\n\t\t\t\t\t {{- if eq (len $argValue) 0 }} {{ else }} ) {{ end }} \n {{- end }}\n {{- end }}\n\t\t\t\t {\n id\n }\n {{- end }}\n {{- end }}\n }\n {{- end }}\n {{- end }}\n }\n {{- end }}\n {{- end }}\n }\n `\n\n\ttemplateFunctions := template.FuncMap{\n\t\t\"isArray\": isArray,\n\t}\n\n\tqueryTemplate, err := template.New(\"query\").Funcs(templateFunctions).Parse(queryTemplateString)\n\tvar queryBytes bytes.Buffer\n\tvar data = make(map[string]interface{})\n\tdata = map[string]interface{}{\n\t\t\"query\": query,\n\t\t\"argsByInstruction\": argsByInstruction,\n\t\t\"allArgs\": allArgs,\n\t\t\"operation\": firstInstruction.Operation,\n\t\t\"operationName\": firstInstruction.Name,\n\t}\n\tqueryTemplate.Execute(&queryBytes, data)\n\n\tif client.Debug {\n\t\tfmt.Println(\"Query String: \", queryBytes.String())\n\t}\n\tif err == nil {\n\t\treturn queryBytes.String()\n\t}\n\treturn \"Failed to generate query\"\n}\n ";
};

@@ -232,0 +233,0 @@ GoGenerator.prototype.render = function (options) {

@@ -5,4 +5,4 @@ import { TypescriptGenerator, RenderOptions } from './typescript-client';

constructor(options: any);
format(code: string, options?: prettier.Options): any;
renderJavascript(options?: RenderOptions): any;
format(code: string, options?: prettier.Options): string;
renderJavascript(options?: RenderOptions): string;
}

@@ -36,5 +36,5 @@ import { GraphQLObjectType, GraphQLSchema, GraphQLUnionType, GraphQLInterfaceType, GraphQLInputObjectType, GraphQLInputField, GraphQLField, GraphQLInputType, GraphQLOutputType, GraphQLScalarType, GraphQLEnumType, GraphQLFieldMap, GraphQLObjectType as GraphQLObjectTypeRef } from 'graphql';

});
format(code: string, options?: prettier.Options): any;
format(code: string, options?: prettier.Options): string;
renderAtLeastOne(): string;
render(options?: RenderOptions): any;
render(options?: RenderOptions): string;
renderClientConstructor(): string;

@@ -59,3 +59,3 @@ renderImports(): string;

renderFieldName(field: GraphQLInputField | GraphQLField<any, any>, node: boolean): string;
wrapType(type: any, subscription?: boolean): string;
wrapType(type: any, subscription?: boolean, isArray?: boolean): string;
renderFieldType({ field, node, input, partial, renderFunction, isMutation, isSubscription, }: {

@@ -62,0 +62,0 @@ field: any;

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

var prettier = require("prettier");
var version = require('../../package.json').version;
var codeComment_1 = require("../utils/codeComment");
var TypescriptGenerator = /** @class */ (function (_super) {

@@ -102,2 +102,5 @@ __extends(TypescriptGenerator, _super);

GraphQLEnumType: function (type) {
if (type.name === 'PrismaDatabase') {
return "";
}
return _this.renderDescription(type.description) + "export type " + type.name + " = " + type

@@ -119,3 +122,3 @@ .getValues()

TypescriptGenerator.prototype.render = function (options) {
return this.format(this.compile(templateObject_1 || (templateObject_1 = __makeTemplateObject(["", "\n\n", "\n\nexport interface Exists {\n", "\n}\n\nexport interface Node {}\n\nexport interface Fragmentable {\n $fragment<T>(fragment: string | Object): T\n}\n\n", " interface ", " {\n $exists: Exists;\n $graphql: <T ", " any>(query: string, variables?: {[key: string]: any}) => Promise<T>;\n $getAbstractResolvers(filterSchema?: GraphQLSchema | string): IResolvers;\n\n /**\n * Queries\n */\n\n", ";\n\n /**\n * Mutations\n */\n\n", ";\n\n\n /**\n * Subscriptions\n */\n\n $subscribe: Subscription\n\n}\n\nexport interface Subscription {\n", ";\n}\n\n", "\n\n/**\n * Types\n*/\n\n", "\n\n/**\n * Type Defs\n*/\n\n", "\n"], ["\\\n", "\n\n", "\n\nexport interface Exists {\\n", "\\n}\n\nexport interface Node {}\n\nexport interface Fragmentable {\n $fragment<T>(fragment: string | Object): T\n}\n\n", " interface ", " {\n $exists: Exists;\n $graphql: <T ",
return this.format(this.compile(templateObject_1 || (templateObject_1 = __makeTemplateObject(["", "\n\n", "\n\nexport interface Exists {\n", "\n}\n\nexport interface Node {}\n\nexport type FragmentableArray<T> = Promise<Array<T>> & Fragmentable\n\nexport interface Fragmentable {\n $fragment<T>(fragment: string | DocumentNode): Promise<T>\n}\n\n", " interface ", " {\n $exists: Exists;\n $graphql: <T ", " any>(query: string, variables?: {[key: string]: any}) => Promise<T>;\n $getAbstractResolvers(filterSchema?: GraphQLSchema | string): IResolvers;\n\n /**\n * Queries\n */\n\n", ";\n\n /**\n * Mutations\n */\n\n", ";\n\n\n /**\n * Subscriptions\n */\n\n $subscribe: Subscription\n\n}\n\nexport interface Subscription {\n", ";\n}\n\n", "\n\n/**\n * Types\n*/\n\n", "\n\n/**\n * Type Defs\n*/\n\n", "\n"], ["\\\n", "\n\n", "\n\nexport interface Exists {\\n", "\\n}\n\nexport interface Node {}\n\nexport type FragmentableArray<T> = Promise<Array<T>> & Fragmentable\n\nexport interface Fragmentable {\n $fragment<T>(fragment: string | DocumentNode): Promise<T>\n}\n\n", " interface ", " {\n $exists: Exists;\n $graphql: <T ",
" any>(query: string, variables?: {[key: string]: any}) => Promise<T>;\n $getAbstractResolvers(filterSchema?: GraphQLSchema | string): IResolvers;\n\n /**\n * Queries\n */\n\n", ";\n\n /**\n * Mutations\n */\n\n", ";\n\n\n /**\n * Subscriptions\n */\n\n $subscribe: Subscription\n\n}\n\nexport interface Subscription {\n", ";\n}\n\n", "\n\n/**\n * Types\n*/\n\n", "\n\n/**\n * Type Defs\n*/\n\n", "\n"])), this.renderImports(), this.renderAtLeastOne(), this.renderExists(), this.exportPrisma ? 'export' : '', this.prismaInterface, this.genericsDelimiter, this.renderQueries(), this.renderMutations(), this.renderSubscriptions(), this.renderClientConstructor, this.renderTypes(), this.renderExports(options)));

@@ -127,3 +130,3 @@ };

TypescriptGenerator.prototype.renderImports = function () {
return "// Code generated by Prisma CLI (https://github.com/prisma/prisma) and prisma-client-lib@" + version + ". DO NOT EDIT.\n\nimport { GraphQLSchema } from 'graphql'\nimport { IResolvers } from 'graphql-tools/dist/Interfaces'\nimport { makePrismaClientClass, BaseClientOptions } from 'prisma-client-lib'\nimport { typeDefs } from './prisma-schema'";
return codeComment_1.codeComment + "\n\nimport { DocumentNode, GraphQLSchema } from 'graphql'\nimport { IResolvers } from 'graphql-tools/dist/Interfaces'\nimport { makePrismaClientClass, BaseClientOptions } from 'prisma-client-lib'\nimport { typeDefs } from './prisma-schema'";
};

@@ -275,2 +278,6 @@ TypescriptGenerator.prototype.renderPrismaClassArgs = function (options) {

return Object.keys(fields)
.filter(function (f) {
var field = fields[f];
return !(field.name === 'executeRaw' && isMutation);
})
.map(function (f) {

@@ -342,7 +349,11 @@ var field = fields[f];

};
TypescriptGenerator.prototype.wrapType = function (type, subscription) {
TypescriptGenerator.prototype.wrapType = function (type, subscription, isArray) {
if (subscription === void 0) { subscription = false; }
if (isArray === void 0) { isArray = false; }
if (subscription) {
return "Promise<AsyncIterator<" + type + ">>";
}
if (isArray) {
return "FragmentableArray<" + type + ">";
}
return "Promise<" + type + ">";

@@ -397,3 +408,3 @@ };

if (renderFunction) {
return "<T " + this.genericsDelimiter + " " + this.wrapType("Array<" + typeString, isSubscription) + ">> (" + (field.args && field.args.length > 0
return "<T " + this.genericsDelimiter + " " + this.wrapType("" + typeString, isSubscription, true) + "> (" + (field.args && field.args.length > 0
? this.renderArgs(field, isMutation, false)

@@ -403,3 +414,3 @@ : '') + ") => T";

else {
return this.wrapType("Array<" + typeString + ">", isSubscription);
return this.wrapType(typeString, isSubscription, true);
}

@@ -463,4 +474,6 @@ }

: interfaces;
return "" + this.renderDescription(typeDescription) + (typeName.includes('WhereUniqueInput')
? "export type " + typeName + " = AtLeastOne<{\n " + fieldDefinition + "\n }>"
return "" + this.renderDescription(typeDescription) + (
// TODO: Find a better solution than the hacky replace to remove ? from inside AtLeastOne
typeName.includes('WhereUniqueInput')
? "export type " + typeName + " = AtLeastOne<{\n " + fieldDefinition.replace('?:', ':') + "\n }>"
: "export interface " + typeName + (subscription ? 'Subscription' : '') + (actualInterfaces.length > 0

@@ -467,0 +480,0 @@ ? " extends " + actualInterfaces.map(function (i) { return i.name; }).join(', ')

export { Client } from './Client';
export { ClientOptions, BaseClientOptions } from './types';
export { forwardTo } from './utils';
export { Generator } from './codegen/Generator';
export { JavascriptGenerator } from './codegen/javascript-client';
export { TypescriptGenerator } from './codegen/typescript-client';
export { TypescriptDefinitionsGenerator } from './codegen/typescript-definitions';
export { GoGenerator } from './codegen/go-client';
export { FlowGenerator } from './codegen/flow-client';
export { makePrismaClientClass } from './makePrismaClientClass';

@@ -5,4 +5,2 @@ "use strict";

exports.Client = Client_1.Client;
var utils_1 = require("./utils");
exports.forwardTo = utils_1.forwardTo;
var Generator_1 = require("./codegen/Generator");

@@ -14,2 +12,4 @@ exports.Generator = Generator_1.Generator;

exports.TypescriptGenerator = typescript_client_1.TypescriptGenerator;
var typescript_definitions_1 = require("./codegen/typescript-definitions");
exports.TypescriptDefinitionsGenerator = typescript_definitions_1.TypescriptDefinitionsGenerator;
var go_client_1 = require("./codegen/go-client");

@@ -16,0 +16,0 @@ exports.GoGenerator = go_client_1.GoGenerator;

@@ -5,3 +5,2 @@ import { GraphQLObjectType, GraphQLSchema, GraphQLResolveInfo, GraphQLOutputType } from 'graphql';

export declare function getTypeForRootFieldName(rootFieldName: string, operation: Operation, schema: GraphQLSchema): GraphQLOutputType;
export declare function forwardTo(bindingName: string): <PARENT, ARGS, CONTEXT>(parent: PARENT, args: ARGS, context: CONTEXT, info: GraphQLResolveInfo) => any;
export declare function printDocumentFromInfo(info: GraphQLResolveInfo): string;

@@ -8,0 +7,0 @@ export declare function getExistsTypes(queryType: GraphQLObjectType): string;

@@ -43,20 +43,2 @@ "use strict";

exports.getTypeForRootFieldName = getTypeForRootFieldName;
function forwardTo(bindingName) {
return function (parent, args, context, info) {
var message = "Forward to '" + bindingName + "." + info.parentType.name.toLowerCase() + "." + info.fieldName + "' failed. ";
if (context[bindingName]) {
if (context[bindingName][info.parentType.name.toLowerCase()][info.fieldName]) {
return context[bindingName][info.parentType.name.toLowerCase()][info.fieldName](args, info);
}
else {
message += "Field '" + info.parentType.name.toLowerCase() + "." + info.fieldName + "' not found on binding '" + bindingName + "'.";
}
}
else {
message += "Client '" + bindingName + "' not found.";
}
throw new Error(message);
};
}
exports.forwardTo = forwardTo;
function printDocumentFromInfo(info) {

@@ -63,0 +45,0 @@ var fragments = Object.keys(info.fragments).map(function (fragment) { return info.fragments[fragment]; });

{
"name": "prisma-client-lib",
"version": "0.2.58",
"version": "0.2.59",
"author": "Tim Suchanek <suchanek@prisma.io>",

@@ -17,2 +17,3 @@ "license": "Apache-2.0",

"test-ts-generator-only": "npm run build && ava dist/codegen/typescript-client.test.js",
"test-ts-definitions-generator-only": "npm run build && ava dist/codegen/typescript-definitions.test.js",
"test-go-generator-only": "npm run build && ava dist/codegen/go-client.test.js",

@@ -23,23 +24,23 @@ "test-flow-generator-only": "npm run build && ava dist/codegen/flow-client.test.js",

"dependencies": {
"@types/node": "^10.9.4",
"debug": "^4.0.1",
"graphql-tag": "^2.9.2",
"@types/node": "^10.12.0",
"@types/prettier": "^1.13.2",
"debug": "^4.1.0",
"graphql-tag": "^2.10.0",
"http-link-dataloader": "^0.1.4",
"jsonwebtoken": "^8.3.0",
"lodash.flatten": "^4.4.0",
"prettier": "^1.14.2",
"subscriptions-transport-ws": "^0.9.14",
"prettier": "^1.14.3",
"subscriptions-transport-ws": "^0.9.15",
"uppercamelcase": "^3.0.0",
"ws": "^6.0.0",
"zen-observable": "^0.8.9"
"ws": "^6.1.0",
"zen-observable": "^0.8.10"
},
"devDependencies": {
"@types/graphql": "0.13",
"@types/node": "10.0.2",
"@types/graphql": "14.0.3",
"ava": "^0.25.0",
"graphql": "^14.0.2",
"semantic-release": "^15.9.15",
"semantic-release": "^15.10.4",
"tslint": "5.11.0",
"tslint-config-standard": "8.0.1",
"typescript": "3.0.3"
"typescript": "3.1.3"
},

@@ -46,0 +47,0 @@ "peerDependencies": {

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