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

nexus-prisma

Package Overview
Dependencies
Maintainers
1
Versions
225
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nexus-prisma - npm Package Compare versions

Comparing version 0.0.1-beta.2 to 0.0.1-beta.3

dist/nexus-prisma/scalars.d.ts

1

dist/index.js

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

const writeFileAsync = util_1.promisify(fs.writeFile);
const copyFileAsync = util_1.promisify(fs.copyFile);
function getNexusPrismaRuntime(photonOutput) {

@@ -28,0 +27,0 @@ const dmmf = require(photonOutput).dmmf;

export interface NexusPrismaParams {
photon: (ctx: any) => any;
}
export declare function nexusPrismaMethod(params: NexusPrismaParams): (import("@prisma/nexus/dist/dynamicMethod").DynamicOutputMethodDef<"crud"> | import("@prisma/nexus/dist/dynamicMethod").DynamicOutputMethodDef<"model">)[];
export declare function nexusPrismaMethod(params: NexusPrismaParams): any[];
import { core } from '@prisma/nexus';
import { NexusPrismaParams } from '.';
import { ExternalDMMF as DMMF } from '../dmmf/dmmf-types';
import { DMMFClass } from '../dmmf/DMMFClass';
import { NexusPrismaParams } from '.';
import { INamingStrategy } from './StrategyNaming';

@@ -24,3 +24,4 @@ interface NexusPrismaMethodParams {

constructor(params: NexusPrismaParams);
getNexusPrismaMethod(): (core.DynamicOutputMethodDef<"crud"> | core.DynamicOutputMethodDef<"model">)[];
getPrismaScalars(): any[];
getNexusPrismaMethod(): any[];
protected getCRUDDynamicOutputMethod(): core.DynamicOutputMethodDef<"crud">;

@@ -27,0 +28,0 @@ protected getModelDynamicOutputMethod(): core.DynamicOutputMethodDef<"model">;

@@ -6,5 +6,6 @@ "use strict";

const DMMFClass_1 = require("../dmmf/DMMFClass");
const utils_1 = require("../utils");
const scalars_1 = require("./scalars");
const StrategyNaming_1 = require("./StrategyNaming");
const supported_ops_1 = require("./supported-ops");
const utils_1 = require("../utils");
class NexusPrismaBuilder {

@@ -30,7 +31,19 @@ constructor(params) {

}
getPrismaScalars() {
const allScalarNames = utils_1.flatMap(this.dmmf.schema.outputTypes, o => o.fields)
.filter(f => f.outputType.kind === 'scalar' &&
!scalars_1.GQL_SCALARS_NAMES.includes(f.outputType.type))
.map(f => f.outputType.type);
const dedupScalarNames = [...new Set(allScalarNames)];
const scalars = [];
if (dedupScalarNames.includes('DateTime')) {
scalars.push(scalars_1.dateTimeScalar);
}
return scalars;
}
getNexusPrismaMethod() {
return [
this.getCRUDDynamicOutputMethod(),
this.getModelDynamicOutputMethod()
//this.getModelsDynamicOutputMethod()
this.getModelDynamicOutputMethod(),
...this.getPrismaScalars()
];

@@ -104,3 +117,3 @@ }

name: 'models',
typeDefinition: `: NexusPrisma<TypeName, 'models', 'models'>`,
typeDefinition: `: NexusPrisma<TypeName, 'models'>`,
factory: ({ typeDef: t }) => {

@@ -107,0 +120,0 @@ const allModels = this.dmmf.datamodel.models.reduce((acc, model) => {

export declare const keyBy: <T>(collection: T[], iteratee: (value: T) => string) => Record<string, T>;
export declare const upperFirst: (s: string) => string;
export declare function flatMap<T, U>(array: T[], callbackfn: (value: T, index: number, array: T[]) => U[]): U[];
export declare function nexusOpts(param: {

@@ -4,0 +5,0 @@ type: string;

@@ -13,2 +13,6 @@ "use strict";

};
function flatMap(array, callbackfn) {
return Array.prototype.concat(...array.map(callbackfn));
}
exports.flatMap = flatMap;
function nexusOpts(param) {

@@ -15,0 +19,0 @@ return {

@@ -36,3 +36,3 @@ module.exports =

/******/ // Load entry module and return exports
/******/ return __webpack_require__(714);
/******/ return __webpack_require__(826);
/******/ };

@@ -46,3 +46,3 @@ /******/

/***/ 8:
/***/ 43:
/***/ (function(__unusedmodule, exports, __webpack_require__) {

@@ -53,3 +53,3 @@

Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = __webpack_require__(212);
const utils_1 = __webpack_require__(163);
class DMMFClass {

@@ -139,90 +139,3 @@ constructor({ datamodel, schema, mappings }) {

/***/ 212:
/***/ (function(__unusedmodule, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const path_1 = __webpack_require__(622);
exports.keyBy = (collection, iteratee) => {
return collection.reduce((acc, curr) => {
acc[iteratee(curr)] = curr;
return acc;
}, {});
};
exports.upperFirst = (s) => {
return s.replace(/^\w/, c => c.toUpperCase());
};
function nexusOpts(param) {
return {
type: param.type,
list: param.isList ? true : undefined,
nullable: !param.isRequired
};
}
exports.nexusOpts = nexusOpts;
function assertPhotonInContext(photon) {
if (!photon) {
throw new Error('Could not find photon in context');
}
}
exports.assertPhotonInContext = assertPhotonInContext;
function trimIfInNodeModules(path) {
if (path.includes('node_modules')) {
return path.substring(path.lastIndexOf('node_modules') + 'node_modules'.length + 1);
}
return path;
}
exports.trimIfInNodeModules = trimIfInNodeModules;
function getImportPathRelativeToOutput(from, to) {
if (to.includes('node_modules')) {
return trimIfInNodeModules(to);
}
let relativePath = path_1.relative(from, to);
if (!relativePath.startsWith('.')) {
relativePath = './' + relativePath;
}
// remove .ts or .js file extension
relativePath = relativePath.replace(/\.(ts|js)$/, '');
// remove /index
relativePath = relativePath.replace(/\/index$/, '');
// replace \ with /
relativePath = relativePath.replace(/\\/g, '/');
return relativePath;
}
exports.getImportPathRelativeToOutput = getImportPathRelativeToOutput;
/***/ }),
/***/ 453:
/***/ (function(__unusedmodule, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = __webpack_require__(212);
exports.defaultNamingStrategy = {
whereInput(typeName, fieldName) {
return `${utils_1.upperFirst(typeName)}${utils_1.upperFirst(fieldName)}WhereInput`;
},
orderByInput(typeName, fieldName) {
return `${utils_1.upperFirst(typeName)}${utils_1.upperFirst(fieldName)}OrderByInput`;
},
relationFilterInput(typeName, fieldName) {
return `${utils_1.upperFirst(typeName)}${utils_1.upperFirst(fieldName)}Filter`;
}
};
/***/ }),
/***/ 548:
/***/ (function(module) {
module.exports = require("@prisma/nexus");
/***/ }),
/***/ 563:
/***/ 154:
/***/ (function(__unusedmodule, exports) {

@@ -310,11 +223,66 @@

/***/ 622:
/***/ (function(module) {
/***/ 163:
/***/ (function(__unusedmodule, exports, __webpack_require__) {
module.exports = require("path");
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const path_1 = __webpack_require__(622);
exports.keyBy = (collection, iteratee) => {
return collection.reduce((acc, curr) => {
acc[iteratee(curr)] = curr;
return acc;
}, {});
};
exports.upperFirst = (s) => {
return s.replace(/^\w/, c => c.toUpperCase());
};
function flatMap(array, callbackfn) {
return Array.prototype.concat(...array.map(callbackfn));
}
exports.flatMap = flatMap;
function nexusOpts(param) {
return {
type: param.type,
list: param.isList ? true : undefined,
nullable: !param.isRequired
};
}
exports.nexusOpts = nexusOpts;
function assertPhotonInContext(photon) {
if (!photon) {
throw new Error('Could not find photon in context');
}
}
exports.assertPhotonInContext = assertPhotonInContext;
function trimIfInNodeModules(path) {
if (path.includes('node_modules')) {
return path.substring(path.lastIndexOf('node_modules') + 'node_modules'.length + 1);
}
return path;
}
exports.trimIfInNodeModules = trimIfInNodeModules;
function getImportPathRelativeToOutput(from, to) {
if (to.includes('node_modules')) {
return trimIfInNodeModules(to);
}
let relativePath = path_1.relative(from, to);
if (!relativePath.startsWith('.')) {
relativePath = './' + relativePath;
}
// remove .ts or .js file extension
relativePath = relativePath.replace(/\.(ts|js)$/, '');
// remove /index
relativePath = relativePath.replace(/\/index$/, '');
// replace \ with /
relativePath = relativePath.replace(/\\/g, '/');
return relativePath;
}
exports.getImportPathRelativeToOutput = getImportPathRelativeToOutput;
/***/ }),
/***/ 667:
/***/ (function(__unusedmodule, exports) {
/***/ 166:
/***/ (function(__unusedmodule, exports, __webpack_require__) {

@@ -324,17 +292,14 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
function getSupportedQueries(mapping) {
return [mapping.findOne, mapping.findMany].filter(Boolean);
}
exports.getSupportedQueries = getSupportedQueries;
function getSupportedMutations(mapping) {
return [
mapping.create,
mapping.update,
mapping.updateMany,
mapping.delete,
mapping.deleteMany,
mapping.upsert
].filter(Boolean);
}
exports.getSupportedMutations = getSupportedMutations;
const utils_1 = __webpack_require__(163);
exports.defaultNamingStrategy = {
whereInput(typeName, fieldName) {
return `${utils_1.upperFirst(typeName)}${utils_1.upperFirst(fieldName)}WhereInput`;
},
orderByInput(typeName, fieldName) {
return `${utils_1.upperFirst(typeName)}${utils_1.upperFirst(fieldName)}OrderByInput`;
},
relationFilterInput(typeName, fieldName) {
return `${utils_1.upperFirst(typeName)}${utils_1.upperFirst(fieldName)}Filter`;
}
};

@@ -344,3 +309,17 @@

/***/ 714:
/***/ 548:
/***/ (function(module) {
module.exports = require("@prisma/nexus");
/***/ }),
/***/ 622:
/***/ (function(module) {
module.exports = require("path");
/***/ }),
/***/ 644:
/***/ (function(__unusedmodule, exports, __webpack_require__) {

@@ -351,8 +330,17 @@

Object.defineProperty(exports, "__esModule", { value: true });
const NexusPrismaBuilder_1 = __webpack_require__(893);
function nexusPrismaMethod(params) {
const builder = new NexusPrismaBuilder_1.NexusPrismaBuilder(params);
return builder.getNexusPrismaMethod();
}
exports.nexusPrismaMethod = nexusPrismaMethod;
const nexus_1 = __webpack_require__(548);
exports.GQL_SCALARS_NAMES = ['Int', 'Float', 'String', 'ID', 'Boolean'];
exports.dateTimeScalar = nexus_1.scalarType({
name: 'DateTime',
description: 'DateTime',
parseLiteral(value) {
return value;
},
serialize(value) {
return value;
},
parseValue(value) {
return value;
}
});

@@ -362,3 +350,3 @@

/***/ 893:
/***/ 656:
/***/ (function(__unusedmodule, exports, __webpack_require__) {

@@ -370,7 +358,8 @@

const nexus_1 = __webpack_require__(548);
const dmmf_transformer_1 = __webpack_require__(563);
const DMMFClass_1 = __webpack_require__(8);
const StrategyNaming_1 = __webpack_require__(453);
const supported_ops_1 = __webpack_require__(667);
const utils_1 = __webpack_require__(212);
const dmmf_transformer_1 = __webpack_require__(154);
const DMMFClass_1 = __webpack_require__(43);
const utils_1 = __webpack_require__(163);
const scalars_1 = __webpack_require__(644);
const StrategyNaming_1 = __webpack_require__(166);
const supported_ops_1 = __webpack_require__(954);
class NexusPrismaBuilder {

@@ -396,7 +385,19 @@ constructor(params) {

}
getPrismaScalars() {
const allScalarNames = utils_1.flatMap(this.dmmf.schema.outputTypes, o => o.fields)
.filter(f => f.outputType.kind === 'scalar' &&
!scalars_1.GQL_SCALARS_NAMES.includes(f.outputType.type))
.map(f => f.outputType.type);
const dedupScalarNames = [...new Set(allScalarNames)];
const scalars = [];
if (dedupScalarNames.includes('DateTime')) {
scalars.push(scalars_1.dateTimeScalar);
}
return scalars;
}
getNexusPrismaMethod() {
return [
this.getCRUDDynamicOutputMethod(),
this.getModelDynamicOutputMethod()
//this.getModelsDynamicOutputMethod()
this.getModelDynamicOutputMethod(),
...this.getPrismaScalars()
];

@@ -470,3 +471,3 @@ }

name: 'models',
typeDefinition: `: NexusPrisma<TypeName, 'models', 'models'>`,
typeDefinition: `: NexusPrisma<TypeName, 'models'>`,
factory: ({ typeDef: t }) => {

@@ -697,4 +698,45 @@ const allModels = this.dmmf.datamodel.models.reduce((acc, model) => {

/***/ }),
/***/ 826:
/***/ (function(__unusedmodule, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const NexusPrismaBuilder_1 = __webpack_require__(656);
function nexusPrismaMethod(params) {
const builder = new NexusPrismaBuilder_1.NexusPrismaBuilder(params);
return builder.getNexusPrismaMethod();
}
exports.nexusPrismaMethod = nexusPrismaMethod;
/***/ }),
/***/ 954:
/***/ (function(__unusedmodule, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function getSupportedQueries(mapping) {
return [mapping.findOne, mapping.findMany].filter(Boolean);
}
exports.getSupportedQueries = getSupportedQueries;
function getSupportedMutations(mapping) {
return [
mapping.create,
mapping.update,
mapping.updateMany,
mapping.delete,
mapping.deleteMany,
mapping.upsert
].filter(Boolean);
}
exports.getSupportedMutations = getSupportedMutations;
/***/ })
/******/ });
export interface NexusPrismaParams {
photon: (ctx: any) => any;
}
export declare function nexusPrismaMethod(params: NexusPrismaParams): (import("@prisma/nexus/dist/dynamicMethod").DynamicOutputMethodDef<"crud"> | import("@prisma/nexus/dist/dynamicMethod").DynamicOutputMethodDef<"model">)[];
export declare function nexusPrismaMethod(params: NexusPrismaParams): any[];
import { core } from '@prisma/nexus';
import { NexusPrismaParams } from '.';
import { ExternalDMMF as DMMF } from '../dmmf/dmmf-types';
import { DMMFClass } from '../dmmf/DMMFClass';
import { NexusPrismaParams } from '.';
import { INamingStrategy } from './StrategyNaming';

@@ -24,3 +24,4 @@ interface NexusPrismaMethodParams {

constructor(params: NexusPrismaParams);
getNexusPrismaMethod(): (core.DynamicOutputMethodDef<"crud"> | core.DynamicOutputMethodDef<"model">)[];
getPrismaScalars(): any[];
getNexusPrismaMethod(): any[];
protected getCRUDDynamicOutputMethod(): core.DynamicOutputMethodDef<"crud">;

@@ -27,0 +28,0 @@ protected getModelDynamicOutputMethod(): core.DynamicOutputMethodDef<"model">;

export declare const keyBy: <T>(collection: T[], iteratee: (value: T) => string) => Record<string, T>;
export declare const upperFirst: (s: string) => string;
export declare function flatMap<T, U>(array: T[], callbackfn: (value: T, index: number, array: T[]) => U[]): U[];
export declare function nexusOpts(param: {

@@ -4,0 +5,0 @@ type: string;

{
"name": "nexus-prisma",
"version": "0.0.1-beta.2",
"version": "0.0.1-beta.3",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"license": "MIT",
"author": "Flavian DESVERNE <desverne@prisma.io>",
"author": "Flavian Desverne <desverne@prisma.io>",
"files": [

@@ -12,5 +12,2 @@ "dist",

],
"bin": {
"photogen": "dist/index.js"
},
"scripts": {

@@ -22,9 +19,9 @@ "build": "rm -rf dist && rm -rf nexus_prisma_ncc_build && tsc && ncc build -e @prisma/nexus src/nexus-prisma/index.ts -o nexus_prisma_ncc_build",

"dependencies": {
"@prisma/nexus": "^0.0.1",
"pkg-up": "^3.1.0"
"@prisma/nexus": "^0.0.1"
},
"devDependencies": {
"@prisma/cli": "^0.0.17",
"@types/node": "^12.0.8",
"@zeit/ncc": "^0.19.1",
"@prisma/cli": "^0.0.19",
"@types/graphql": "^14.2.1",
"@types/node": "^12.0.10",
"@zeit/ncc": "^0.20.1",
"prettier": "^1.17.1",

@@ -31,0 +28,0 @@ "ts-node": "^8.3.0",

@@ -10,3 +10,3 @@ # nexus-prisma

```
git clone https://github.com/Weakky/photogen.git
git clone https://github.com/prisma/nexus-prisma.git
cd example

@@ -13,0 +13,0 @@ ```

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