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

@paljs/plugins

Package Overview
Dependencies
Maintainers
1
Versions
106
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@paljs/plugins - npm Package Compare versions

Comparing version 2.5.0 to 2.5.1

7

dist/delete.d.ts

@@ -0,1 +1,2 @@

import { DMMF } from './schema';
export interface onDeleteArgs {

@@ -25,3 +26,7 @@ model: string;

private prisma;
constructor(prisma?: any);
private options;
constructor(prisma: any, options: {
dmmf?: DMMF.Document;
});
get dataModel(): DMMF.Datamodel;
private getModel;

@@ -28,0 +33,0 @@ private getModelName;

30

dist/plugins.cjs.development.js

@@ -10,4 +10,2 @@ 'use strict';

var graphqlFields = _interopDefault(require('graphql-fields'));
var display = require('@paljs/display');
var chalk = _interopDefault(require('chalk'));
var gql = _interopDefault(require('graphql-tag'));

@@ -146,4 +144,2 @@ var graphql = require('graphql');

function PrismaSelect(info, options) {
var _this$options;
this.info = info;

@@ -153,6 +149,2 @@ this.options = options;

this.isAggregate = false;
if (this.options && (!this.options.defaultFields || !((_this$options = this.options) === null || _this$options === void 0 ? void 0 : _this$options.dmmf))) {
display.log.error("The second arg on " + chalk.blue('PrismaSelect') + " class changed in " + chalk.blue('v2.5.0') + " please look at release notes https://github.com/paljs/prisma-tools/releases/tag/v2.5.0");
}
}

@@ -365,5 +357,5 @@

get: function get() {
var _this$options2, _this$options2$dmmf;
var _this$options, _this$options$dmmf;
return ((_this$options2 = this.options) === null || _this$options2 === void 0 ? void 0 : (_this$options2$dmmf = _this$options2.dmmf) === null || _this$options2$dmmf === void 0 ? void 0 : _this$options2$dmmf.datamodel) || dataModel;
return ((_this$options = this.options) === null || _this$options === void 0 ? void 0 : (_this$options$dmmf = _this$options.dmmf) === null || _this$options$dmmf === void 0 ? void 0 : _this$options$dmmf.datamodel) || dataModel;
}

@@ -373,5 +365,5 @@ }, {

get: function get() {
var _this$options3;
var _this$options2;
return (_this$options3 = this.options) === null || _this$options3 === void 0 ? void 0 : _this$options3.defaultFields;
return (_this$options2 = this.options) === null || _this$options2 === void 0 ? void 0 : _this$options2.defaultFields;
}

@@ -601,3 +593,3 @@ }, {

var PrismaDelete = /*#__PURE__*/function () {
function PrismaDelete(prisma) {
function PrismaDelete(prisma, options) {
if (prisma === void 0) {

@@ -608,2 +600,3 @@ prisma = new client.PrismaClient();

this.prisma = prisma;
this.options = options;
}

@@ -614,3 +607,3 @@

_proto.getModel = function getModel(modelName) {
return dataModel.models.find(function (item) {
return this.dataModel.models.find(function (item) {
return item.name === modelName;

@@ -792,2 +785,11 @@ });

_createClass(PrismaDelete, [{
key: "dataModel",
get: function get() {
var _this$options, _this$options$dmmf;
return ((_this$options = this.options) === null || _this$options === void 0 ? void 0 : (_this$options$dmmf = _this$options.dmmf) === null || _this$options$dmmf === void 0 ? void 0 : _this$options$dmmf.datamodel) || dataModel;
}
}]);
return PrismaDelete;

@@ -794,0 +796,0 @@ }();

@@ -1,2 +0,2 @@

"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@prisma/client");require("@prisma/client/runtime");var n=e(require("graphql-fields")),r=require("@paljs/display"),i=e(require("chalk")),o=e(require("graphql-tag")),u=require("graphql"),a=require("fs");function l(){return(l=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function c(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return s(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?s(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}var f=t.dmmf.schema,d=t.dmmf.datamodel,h=function(){function e(e,t){var n;this.info=e,this.options=t,this.availableArgs=["where","orderBy","skip","cursor","take"],this.isAggregate=!1,!this.options||this.options.defaultFields&&(null===(n=this.options)||void 0===n?void 0:n.dmmf)||r.log.error("The second arg on "+i.blue("PrismaSelect")+" class changed in "+i.blue("v2.5.0")+" please look at release notes https://github.com/paljs/prisma-tools/releases/tag/v2.5.0")}e.getModelMap=function(e,t){var n=null==e?void 0:e.match(/@PrismaSelect.map\(\[(.*?)\]\)/);return!(!n||!t)&&n[1].replace(/ /g,"").split(",").filter((function(e){return e})).includes(t)};var t,o=e.prototype;return o.model=function(t){return this.dataModel.models.find((function(n){return n.name===t||e.getModelMap(n.documentation,t)}))},o.field=function(e,t){return null==t?void 0:t.fields.find((function(t){return t.name===e}))},e.isObject=function(e){return e&&"object"==typeof e&&!Array.isArray(e)},e.mergeDeep=function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];if(!r.length)return t;var o=r.shift();if(e.isObject(t)&&e.isObject(o))for(var u in o){var a,l;e.isObject(o[u])?(t[u]||Object.assign(t,((a={})[u]={},a)),e.mergeDeep(t[u],o[u])):Object.assign(t,((l={})[u]=o[u],l))}return e.mergeDeep.apply(e,[t].concat(r))},o.valueOf=function(t,n,r){void 0===r&&(r={});for(var i,o=t.split("."),u=this.getSelect(this.fields,n),a=c(o);!(i=a()).done;){var l=i.value;if(this.isAggregate&&u.hasOwnProperty(l))u=u[l];else{if(this.isAggregate||!u.hasOwnProperty("select")||!u.select.hasOwnProperty(l))return{};u=u.select[l]}}return n?e.mergeDeep(this.filterBy(n,u),r):u},o.valueWithFilter=function(e){return this.filterBy(e,this.getSelect(this.fields,e))},o.filterBy=function(e,t){var n=this,r=this.model(e);if(r){var i=l({},t,{select:{}});return Object.keys(t.select).forEach((function(e){var o=n.field(e,r);o&&(i.select[e]="object"!==o.kind||n.filterBy(o.type,t.select[e]))})),i}return t},o.getSelect=function(e,t){var n=this,r={};t&&this.defaultFields&&this.defaultFields[t]&&(r=this.defaultFields[t]);var i=this.model(t),o=this.isAggregate?{}:{select:l({},r)};return Object.keys(e).forEach((function(t){if(0===Object.keys(e[t]).length)n.isAggregate?o[t]=!0:o.select[t]=!0;else if("__arguments"===t)e[t].forEach((function(e){Object.keys(e).forEach((function(t){n.availableArgs.includes(t)&&(o[t]=e[t].value)}))}));else if(n.isAggregate)o[t]=n.getSelect(e[t]);else{var r=n.field(t,i);o.select[t]=n.getSelect(e[t],null==r?void 0:r.type)}})),o},(t=[{key:"value",get:function(){var e=this.info.returnType.toString().replace(/]/g,"").replace(/\[/g,"").replace(/!/g,"");return this.isAggregate=e.includes("Aggregate"),this.valueWithFilter(e)}},{key:"dataModel",get:function(){var e,t;return(null===(e=this.options)||void 0===e||null===(t=e.dmmf)||void 0===t?void 0:t.datamodel)||d}},{key:"defaultFields",get:function(){var e;return null===(e=this.options)||void 0===e?void 0:e.defaultFields}},{key:"fields",get:function(){return n(this.info,{},{excludedFields:["__typename"],processArguments:!0})}}])&&function(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}(e.prototype,t),e}(),p=function(){function e(){}return e.prototype.then=function(t,n){var r=new e,i=this.s;if(i){var o=1&i?t:n;if(o){try{v(r,1,o(this.v))}catch(e){v(r,2,e)}return r}return this}return this.o=function(e){try{var i=e.v;1&e.s?v(r,1,t?t(i):i):n?v(r,1,n(i)):v(r,2,i)}catch(e){v(r,2,e)}},r},e}();function v(e,t,n){if(!e.s){if(n instanceof p){if(!n.s)return void(n.o=v.bind(null,e,t));1&t&&(t=n.s),n=n.v}if(n&&n.then)return void n.then(v.bind(null,e,t),v.bind(null,e,2));e.s=t,e.v=n;var r=e.o;r&&r(e)}}function y(e){return e instanceof p&&1&e.s}var m="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function g(e,t,n){if("function"==typeof e[m]){var r,i,o,u=e[m]();if(function e(a){try{for(;!((r=u.next()).done||n&&n());)if((a=t(r.value))&&a.then){if(!y(a))return void a.then(e,o||(o=v.bind(null,i=new p,2)));a=a.v}i?v(i,1,a):i=a}catch(e){v(i||(i=new p),2,e)}}(),u.return){var a=function(e){try{r.done||u.return()}catch(e){}return e};if(i&&i.then)return i.then(a,(function(e){throw a(e)}));a()}return i}if(!("length"in e))throw new TypeError("Object is not iterable");for(var l=[],s=0;s<e.length;s++)l.push(e[s]);return function(e,t,n){var r,i,o=-1;return function u(a){try{for(;++o<e.length&&(!n||!n());)if((a=t(o))&&a.then){if(!y(a))return void a.then(u,i||(i=v.bind(null,r=new p,2)));a=a.v}r?v(r,1,a):r=a}catch(e){v(r||(r=new p),2,e)}}(),r}(l,(function(e){return t(l[e])}),n)}function b(){var e,t,n=(e=["\n ","\n"],t||(t=e.slice(0)),e.raw=t,e);return b=function(){return n},n}"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var S=[],j=function e(t){S.push(t);var n=f.inputTypes.find((function(e){return e.name===t}));if(n){if(0===n.fields.length)return!0;for(var r,i=c(n.fields);!(r=i()).done;){var o=w(r.value);if(o.type!==t&&"object"===o.kind&&!S.includes(o.type)&&e(o.type))return!0}}return!1},w=function(e){var t=0;return e.inputTypes.length>1&&"object"===e.inputTypes[1].kind&&(t=1),e.inputTypes[t]};exports.PrismaDelete=function(){function e(e){void 0===e&&(e=new t.PrismaClient),this.prisma=e}var n=e.prototype;return n.getModel=function(e){return d.models.find((function(t){return t.name===e}))},n.getModelName=function(e){return e.charAt(0).toLowerCase()+e.slice(1)},n.getFieldByType=function(e,t){var n;return null===(n=this.getModel(e))||void 0===n?void 0:n.fields.find((function(e){return e.type===t}))},n.getModelIdFieldName=function(e){var t,n;return null===(t=this.getModel(e))||void 0===t||null===(n=t.fields.find((function(e){return e.isId})))||void 0===n?void 0:n.name},n.getOnDeleteFields=function(e,t){var n;return null===(n=this.getModel(e))||void 0===n?void 0:n.fields.filter((function(e){var n,r;return(null===(n=e.documentation)||void 0===n?void 0:n.includes("@onDelete"))&&(null===(r=e.documentation)||void 0===r?void 0:r.includes(t))}))},n.setFieldNull=function(e,t,n){try{var r=this,i=r.getModelName(e),o=r.getModelIdFieldName(e),u=r.getModelIdFieldName(t.type);return Promise.resolve(function(){if(o&&u&&!t.isRequired){var e,a,s,c=t.isList?((a={})[t.name]={select:(e={},e[u]=!0,e)},a):{};return Promise.resolve(r.prisma[i].findMany({where:n,select:l((s={},s[o]=!0,s),c)})).then((function(e){return g(e,(function(e){var n=function(){var n,u;if(!t.isList||0!==e[t.name].length)return Promise.resolve(r.prisma[i].update({where:(n={},n[o]=e[o],n),data:(u={},u[t.name]={disconnect:!t.isList||e[t.name]},u)})).then((function(){}))}();if(n&&n.then)return n.then((function(){}))}))}))}}())}catch(e){return Promise.reject(e)}},n.getDeleteArray=function(e,t,n){void 0===n&&(n=!0);try{var r=function(){var n=i.getOnDeleteFields(e,"CASCADE"),r=function(){if(n)return g(n,(function(n){var r=i.getFieldByType(n.type,e),u=function(){if(r){var e,u=o.push;return Promise.resolve(i.getDeleteArray(n.type,(e={},e[r.name]=t,e))).then((function(e){u.call.apply(u,[o].concat(e))}))}}();if(u&&u.then)return u.then((function(){}))}))}();return r&&r.then?r.then((function(){return o})):o},i=this,o=n?[{name:i.getModelName(e),where:t}]:[],u=i.getOnDeleteFields(e,"SET_NULL"),a=function(){if(u){var n=g(u,(function(n){return Promise.resolve(i.setFieldNull(e,n,t)).then((function(){}))}));if(n&&n.then)return n.then((function(){}))}}();return Promise.resolve(a&&a.then?a.then(r):r())}catch(e){return Promise.reject(e)}},n.onDelete=function(e){var t=e.model,n=e.where,r=e.deleteParent;try{var i=this;return Promise.resolve(i.getDeleteArray(t,n,!!r)).then((function(e){var t=g(e.reverse(),(function(e){return Promise.resolve(i.prisma[e.name].deleteMany({where:e.where})).then((function(){}))}));if(t&&t.then)return t.then((function(){}))}))}catch(e){return Promise.reject(e)}},e}(),exports.PrismaSelect=h,exports.generateGraphQlSDLFile=function(e,t){void 0===t&&(t="schema.graphql"),a.writeFileSync(t,u.printSchema(e))},exports.getInputType=w,exports.hasEmptyTypeFields=j,exports.sdlInputs=function(){return o(b(),(e="\n scalar DateTime\n \n type BatchPayload {\n count: Int!\n}\n",f.enums.forEach((function(t){e+="enum "+t.name+" {",t.values.forEach((function(t){e+="\n "+t})),e+="}\n\n"})),f.inputTypes.forEach((function(t){t.fields.length>0&&(e+="input "+t.name+" {\n ",t.fields.forEach((function(t){var n=w(t);"object"===n.kind&&j(n.type)||(e+=t.name+": "+(n.isList?"["+n.type+"!]":n.type)+(t.isRequired?"!":"")+"\n ")})),e+="}\n \n")})),f.outputTypes.filter((function(e){return e.name.includes("Aggregate")})).forEach((function(t){e+="type "+t.name+" {\n ",t.fields.forEach((function(t){e+=t.name+": "+(t.outputType.isList?"["+t.outputType.type+"!]":t.outputType.type)+(t.isRequired?"!":"")+"\n "})),e+="}\n \n"})),e));var e};
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=require("@prisma/client");require("@prisma/client/runtime");var n=e(require("graphql-fields")),r=e(require("graphql-tag")),i=require("graphql"),o=require("fs");function u(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function a(e,t,n){return t&&u(e.prototype,t),n&&u(e,n),e}function l(){return(l=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e}).apply(this,arguments)}function s(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function c(e,t){var n;if("undefined"==typeof Symbol||null==e[Symbol.iterator]){if(Array.isArray(e)||(n=function(e,t){if(e){if("string"==typeof e)return s(e,void 0);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?s(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var r=0;return function(){return r>=e.length?{done:!0}:{done:!1,value:e[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=e[Symbol.iterator]()).next.bind(n)}var f=t.dmmf.schema,d=t.dmmf.datamodel,h=function(){function e(e,t){this.info=e,this.options=t,this.availableArgs=["where","orderBy","skip","cursor","take"],this.isAggregate=!1}e.getModelMap=function(e,t){var n=null==e?void 0:e.match(/@PrismaSelect.map\(\[(.*?)\]\)/);return!(!n||!t)&&n[1].replace(/ /g,"").split(",").filter((function(e){return e})).includes(t)};var t=e.prototype;return t.model=function(t){return this.dataModel.models.find((function(n){return n.name===t||e.getModelMap(n.documentation,t)}))},t.field=function(e,t){return null==t?void 0:t.fields.find((function(t){return t.name===e}))},e.isObject=function(e){return e&&"object"==typeof e&&!Array.isArray(e)},e.mergeDeep=function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),i=1;i<n;i++)r[i-1]=arguments[i];if(!r.length)return t;var o=r.shift();if(e.isObject(t)&&e.isObject(o))for(var u in o){var a,l;e.isObject(o[u])?(t[u]||Object.assign(t,((a={})[u]={},a)),e.mergeDeep(t[u],o[u])):Object.assign(t,((l={})[u]=o[u],l))}return e.mergeDeep.apply(e,[t].concat(r))},t.valueOf=function(t,n,r){void 0===r&&(r={});for(var i,o=t.split("."),u=this.getSelect(this.fields,n),a=c(o);!(i=a()).done;){var l=i.value;if(this.isAggregate&&u.hasOwnProperty(l))u=u[l];else{if(this.isAggregate||!u.hasOwnProperty("select")||!u.select.hasOwnProperty(l))return{};u=u.select[l]}}return n?e.mergeDeep(this.filterBy(n,u),r):u},t.valueWithFilter=function(e){return this.filterBy(e,this.getSelect(this.fields,e))},t.filterBy=function(e,t){var n=this,r=this.model(e);if(r){var i=l({},t,{select:{}});return Object.keys(t.select).forEach((function(e){var o=n.field(e,r);o&&(i.select[e]="object"!==o.kind||n.filterBy(o.type,t.select[e]))})),i}return t},t.getSelect=function(e,t){var n=this,r={};t&&this.defaultFields&&this.defaultFields[t]&&(r=this.defaultFields[t]);var i=this.model(t),o=this.isAggregate?{}:{select:l({},r)};return Object.keys(e).forEach((function(t){if(0===Object.keys(e[t]).length)n.isAggregate?o[t]=!0:o.select[t]=!0;else if("__arguments"===t)e[t].forEach((function(e){Object.keys(e).forEach((function(t){n.availableArgs.includes(t)&&(o[t]=e[t].value)}))}));else if(n.isAggregate)o[t]=n.getSelect(e[t]);else{var r=n.field(t,i);o.select[t]=n.getSelect(e[t],null==r?void 0:r.type)}})),o},a(e,[{key:"value",get:function(){var e=this.info.returnType.toString().replace(/]/g,"").replace(/\[/g,"").replace(/!/g,"");return this.isAggregate=e.includes("Aggregate"),this.valueWithFilter(e)}},{key:"dataModel",get:function(){var e,t;return(null===(e=this.options)||void 0===e||null===(t=e.dmmf)||void 0===t?void 0:t.datamodel)||d}},{key:"defaultFields",get:function(){var e;return null===(e=this.options)||void 0===e?void 0:e.defaultFields}},{key:"fields",get:function(){return n(this.info,{},{excludedFields:["__typename"],processArguments:!0})}}]),e}(),v=function(){function e(){}return e.prototype.then=function(t,n){var r=new e,i=this.s;if(i){var o=1&i?t:n;if(o){try{p(r,1,o(this.v))}catch(e){p(r,2,e)}return r}return this}return this.o=function(e){try{var i=e.v;1&e.s?p(r,1,t?t(i):i):n?p(r,1,n(i)):p(r,2,i)}catch(e){p(r,2,e)}},r},e}();function p(e,t,n){if(!e.s){if(n instanceof v){if(!n.s)return void(n.o=p.bind(null,e,t));1&t&&(t=n.s),n=n.v}if(n&&n.then)return void n.then(p.bind(null,e,t),p.bind(null,e,2));e.s=t,e.v=n;var r=e.o;r&&r(e)}}function y(e){return e instanceof v&&1&e.s}var m="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function g(e,t,n){if("function"==typeof e[m]){var r,i,o,u=e[m]();if(function e(a){try{for(;!((r=u.next()).done||n&&n());)if((a=t(r.value))&&a.then){if(!y(a))return void a.then(e,o||(o=p.bind(null,i=new v,2)));a=a.v}i?p(i,1,a):i=a}catch(e){p(i||(i=new v),2,e)}}(),u.return){var a=function(e){try{r.done||u.return()}catch(e){}return e};if(i&&i.then)return i.then(a,(function(e){throw a(e)}));a()}return i}if(!("length"in e))throw new TypeError("Object is not iterable");for(var l=[],s=0;s<e.length;s++)l.push(e[s]);return function(e,t,n){var r,i,o=-1;return function u(a){try{for(;++o<e.length&&(!n||!n());)if((a=t(o))&&a.then){if(!y(a))return void a.then(u,i||(i=p.bind(null,r=new v,2)));a=a.v}r?p(r,1,a):r=a}catch(e){p(r||(r=new v),2,e)}}(),r}(l,(function(e){return t(l[e])}),n)}function b(){var e,t,n=(e=["\n ","\n"],t||(t=e.slice(0)),e.raw=t,e);return b=function(){return n},n}"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var S=[],w=function e(t){S.push(t);var n=f.inputTypes.find((function(e){return e.name===t}));if(n){if(0===n.fields.length)return!0;for(var r,i=c(n.fields);!(r=i()).done;){var o=j(r.value);if(o.type!==t&&"object"===o.kind&&!S.includes(o.type)&&e(o.type))return!0}}return!1},j=function(e){var t=0;return e.inputTypes.length>1&&"object"===e.inputTypes[1].kind&&(t=1),e.inputTypes[t]};exports.PrismaDelete=function(){function e(e,n){void 0===e&&(e=new t.PrismaClient),this.prisma=e,this.options=n}var n=e.prototype;return n.getModel=function(e){return this.dataModel.models.find((function(t){return t.name===e}))},n.getModelName=function(e){return e.charAt(0).toLowerCase()+e.slice(1)},n.getFieldByType=function(e,t){var n;return null===(n=this.getModel(e))||void 0===n?void 0:n.fields.find((function(e){return e.type===t}))},n.getModelIdFieldName=function(e){var t,n;return null===(t=this.getModel(e))||void 0===t||null===(n=t.fields.find((function(e){return e.isId})))||void 0===n?void 0:n.name},n.getOnDeleteFields=function(e,t){var n;return null===(n=this.getModel(e))||void 0===n?void 0:n.fields.filter((function(e){var n,r;return(null===(n=e.documentation)||void 0===n?void 0:n.includes("@onDelete"))&&(null===(r=e.documentation)||void 0===r?void 0:r.includes(t))}))},n.setFieldNull=function(e,t,n){try{var r=this,i=r.getModelName(e),o=r.getModelIdFieldName(e),u=r.getModelIdFieldName(t.type);return Promise.resolve(function(){if(o&&u&&!t.isRequired){var e,a,s,c=t.isList?((a={})[t.name]={select:(e={},e[u]=!0,e)},a):{};return Promise.resolve(r.prisma[i].findMany({where:n,select:l((s={},s[o]=!0,s),c)})).then((function(e){return g(e,(function(e){var n=function(){var n,u;if(!t.isList||0!==e[t.name].length)return Promise.resolve(r.prisma[i].update({where:(n={},n[o]=e[o],n),data:(u={},u[t.name]={disconnect:!t.isList||e[t.name]},u)})).then((function(){}))}();if(n&&n.then)return n.then((function(){}))}))}))}}())}catch(e){return Promise.reject(e)}},n.getDeleteArray=function(e,t,n){void 0===n&&(n=!0);try{var r=function(){var n=i.getOnDeleteFields(e,"CASCADE"),r=function(){if(n)return g(n,(function(n){var r=i.getFieldByType(n.type,e),u=function(){if(r){var e,u=o.push;return Promise.resolve(i.getDeleteArray(n.type,(e={},e[r.name]=t,e))).then((function(e){u.call.apply(u,[o].concat(e))}))}}();if(u&&u.then)return u.then((function(){}))}))}();return r&&r.then?r.then((function(){return o})):o},i=this,o=n?[{name:i.getModelName(e),where:t}]:[],u=i.getOnDeleteFields(e,"SET_NULL"),a=function(){if(u){var n=g(u,(function(n){return Promise.resolve(i.setFieldNull(e,n,t)).then((function(){}))}));if(n&&n.then)return n.then((function(){}))}}();return Promise.resolve(a&&a.then?a.then(r):r())}catch(e){return Promise.reject(e)}},n.onDelete=function(e){var t=e.model,n=e.where,r=e.deleteParent;try{var i=this;return Promise.resolve(i.getDeleteArray(t,n,!!r)).then((function(e){var t=g(e.reverse(),(function(e){return Promise.resolve(i.prisma[e.name].deleteMany({where:e.where})).then((function(){}))}));if(t&&t.then)return t.then((function(){}))}))}catch(e){return Promise.reject(e)}},a(e,[{key:"dataModel",get:function(){var e,t;return(null===(e=this.options)||void 0===e||null===(t=e.dmmf)||void 0===t?void 0:t.datamodel)||d}}]),e}(),exports.PrismaSelect=h,exports.generateGraphQlSDLFile=function(e,t){void 0===t&&(t="schema.graphql"),o.writeFileSync(t,i.printSchema(e))},exports.getInputType=j,exports.hasEmptyTypeFields=w,exports.sdlInputs=function(){return r(b(),(e="\n scalar DateTime\n \n type BatchPayload {\n count: Int!\n}\n",f.enums.forEach((function(t){e+="enum "+t.name+" {",t.values.forEach((function(t){e+="\n "+t})),e+="}\n\n"})),f.inputTypes.forEach((function(t){t.fields.length>0&&(e+="input "+t.name+" {\n ",t.fields.forEach((function(t){var n=j(t);"object"===n.kind&&w(n.type)||(e+=t.name+": "+(n.isList?"["+n.type+"!]":n.type)+(t.isRequired?"!":"")+"\n ")})),e+="}\n \n")})),f.outputTypes.filter((function(e){return e.name.includes("Aggregate")})).forEach((function(t){e+="type "+t.name+" {\n ",t.fields.forEach((function(t){e+=t.name+": "+(t.outputType.isList?"["+t.outputType.type+"!]":t.outputType.type)+(t.isRequired?"!":"")+"\n "})),e+="}\n \n"})),e));var e};
//# sourceMappingURL=plugins.cjs.production.min.js.map
import { dmmf, PrismaClient } from '@prisma/client';
import '@prisma/client/runtime';
import graphqlFields from 'graphql-fields';
import { log } from '@paljs/display';
import chalk from 'chalk';
import gql from 'graphql-tag';

@@ -139,4 +137,2 @@ import { printSchema } from 'graphql';

function PrismaSelect(info, options) {
var _this$options;
this.info = info;

@@ -146,6 +142,2 @@ this.options = options;

this.isAggregate = false;
if (this.options && (!this.options.defaultFields || !((_this$options = this.options) === null || _this$options === void 0 ? void 0 : _this$options.dmmf))) {
log.error("The second arg on " + chalk.blue('PrismaSelect') + " class changed in " + chalk.blue('v2.5.0') + " please look at release notes https://github.com/paljs/prisma-tools/releases/tag/v2.5.0");
}
}

@@ -358,5 +350,5 @@

get: function get() {
var _this$options2, _this$options2$dmmf;
var _this$options, _this$options$dmmf;
return ((_this$options2 = this.options) === null || _this$options2 === void 0 ? void 0 : (_this$options2$dmmf = _this$options2.dmmf) === null || _this$options2$dmmf === void 0 ? void 0 : _this$options2$dmmf.datamodel) || dataModel;
return ((_this$options = this.options) === null || _this$options === void 0 ? void 0 : (_this$options$dmmf = _this$options.dmmf) === null || _this$options$dmmf === void 0 ? void 0 : _this$options$dmmf.datamodel) || dataModel;
}

@@ -366,5 +358,5 @@ }, {

get: function get() {
var _this$options3;
var _this$options2;
return (_this$options3 = this.options) === null || _this$options3 === void 0 ? void 0 : _this$options3.defaultFields;
return (_this$options2 = this.options) === null || _this$options2 === void 0 ? void 0 : _this$options2.defaultFields;
}

@@ -594,3 +586,3 @@ }, {

var PrismaDelete = /*#__PURE__*/function () {
function PrismaDelete(prisma) {
function PrismaDelete(prisma, options) {
if (prisma === void 0) {

@@ -601,2 +593,3 @@ prisma = new PrismaClient();

this.prisma = prisma;
this.options = options;
}

@@ -607,3 +600,3 @@

_proto.getModel = function getModel(modelName) {
return dataModel.models.find(function (item) {
return this.dataModel.models.find(function (item) {
return item.name === modelName;

@@ -785,2 +778,11 @@ });

_createClass(PrismaDelete, [{
key: "dataModel",
get: function get() {
var _this$options, _this$options$dmmf;
return ((_this$options = this.options) === null || _this$options === void 0 ? void 0 : (_this$options$dmmf = _this$options.dmmf) === null || _this$options$dmmf === void 0 ? void 0 : _this$options$dmmf.datamodel) || dataModel;
}
}]);
return PrismaDelete;

@@ -787,0 +789,0 @@ }();

{
"name": "@paljs/plugins",
"version": "2.5.0",
"version": "2.5.1",
"main": "dist/index.js",

@@ -39,3 +39,3 @@ "module": "dist/plugins.esm.js",

],
"gitHead": "487b16495ac55b121ee9d1e58fc84c07f13c3dea"
"gitHead": "e469c57ec9f502130031b1c2cc47df0df054ae11"
}

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