@paljs/plugins
Advanced tools
Comparing version 1.1.1 to 1.1.3
@@ -1,2 +0,1 @@ | ||
import { SchemaObject } from '@paljs/types'; | ||
export interface onDeleteArgs { | ||
@@ -10,6 +9,5 @@ model: string; | ||
* @param prisma - optional arg you can send your clint class. | ||
* @param schema - your schema.prisma converted object . | ||
* @example | ||
* const prisma = new PrismaClient({log: ['query']}); | ||
* const prismaDelete = new PrismaDelete(prisma, schema); | ||
* const prismaDelete = new PrismaDelete(prisma); | ||
* | ||
@@ -28,4 +26,3 @@ * // or new PrismaDelete(); we will create new client and use | ||
private prisma; | ||
private schema; | ||
constructor(prisma: any, schema: SchemaObject); | ||
constructor(prisma?: any); | ||
private getModel; | ||
@@ -32,0 +29,0 @@ private getModelName; |
@@ -511,6 +511,5 @@ 'use strict'; | ||
* @param prisma - optional arg you can send your clint class. | ||
* @param schema - your schema.prisma converted object . | ||
* @example | ||
* const prisma = new PrismaClient({log: ['query']}); | ||
* const prismaDelete = new PrismaDelete(prisma, schema); | ||
* const prismaDelete = new PrismaDelete(prisma); | ||
* | ||
@@ -529,3 +528,3 @@ * // or new PrismaDelete(); we will create new client and use | ||
var PrismaDelete = /*#__PURE__*/function () { | ||
function PrismaDelete(prisma, schema) { | ||
function PrismaDelete(prisma) { | ||
if (prisma === void 0) { | ||
@@ -536,3 +535,2 @@ prisma = new client.PrismaClient(); | ||
this.prisma = prisma; | ||
this.schema = schema; | ||
} | ||
@@ -543,3 +541,3 @@ | ||
_proto.getModel = function getModel(modelName) { | ||
return this.schema.models.find(function (item) { | ||
return dataModel.models.find(function (item) { | ||
return item.name === modelName; | ||
@@ -590,6 +588,6 @@ }); | ||
return Promise.resolve(function () { | ||
if (modelId && fieldModelId && !field.required) { | ||
if (modelId && fieldModelId && !field.isRequired) { | ||
var _select, _ref, _extends2; | ||
var fieldSelect = field.list ? (_ref = {}, _ref[field.name] = { | ||
var fieldSelect = field.isList ? (_ref = {}, _ref[field.name] = { | ||
select: (_select = {}, _select[fieldModelId] = true, _select) | ||
@@ -609,3 +607,3 @@ }, _ref) : {}; | ||
data: (_data = {}, _data[field.name] = { | ||
disconnect: field.list ? result[field.name] : true | ||
disconnect: field.isList ? result[field.name] : true | ||
}, _data) | ||
@@ -612,0 +610,0 @@ })).then(function () {}); |
@@ -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=e(require("graphql-tag")),i=require("graphql"),o=require("fs");function u(){return(u=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 a(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}var l=t.dmmf.schema,c=t.dmmf.datamodel,s=function(){function e(t,n){void 0===n&&(n={}),this.info=t,this.availableArgs=["where","orderBy","skip","cursor","take"],this.isAggregate=!1;var r=this.info.returnType.toString().replace(/]/g,"").replace(/\[/g,"").replace(/!/g,"");this.isAggregate=r.includes("Aggregate"),this.value=e.mergeDeep(this.filterBy(r,this.getSelect(this.fields)),n)}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))};var t,r=e.prototype;return r.valueOf=function(t,n,r){void 0===r&&(r={});for(var i,o=t.split("."),u=this.getSelect(this.fields),l=function(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 a(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)?a(e,void 0):void 0}}(e))){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)}(o);!(i=l()).done;){var c=i.value;if(this.isAggregate&&u.hasOwnProperty(c))u=u[c];else{if(this.isAggregate||!u.hasOwnProperty("select")||!u.select.hasOwnProperty(c))return{};u=u.select[c]}}return n?e.mergeDeep(this.filterBy(n,u),r):u},r.filterBy=function(e,t){var n=this,r=c.models.find((function(t){return t.name===e}));if(r){var i=u({},t,{select:{}});return Object.keys(t.select).forEach((function(e){var o=r.fields.find((function(t){return t.name===e}));o&&(i.select[e]="object"!==o.kind||n.filterBy(o.type,t.select[e]))})),i}return t},r.getSelect=function(e){var t=this,n=this.isAggregate?{}:{select:{}};return Object.keys(e).forEach((function(r){0===Object.keys(e[r]).length?t.isAggregate?n[r]=!0:n.select[r]=!0:"__arguments"===r?e[r].forEach((function(e){Object.keys(e).forEach((function(r){t.availableArgs.includes(r)&&(n[r]=e[r].value)}))})):t.isAggregate?n[r]=t.getSelect(e[r]):n.select[r]=t.getSelect(e[r])})),n},(t=[{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}(),f=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{h(r,1,o(this.v))}catch(e){h(r,2,e)}return r}return this}return this.o=function(e){try{var i=e.v;1&e.s?h(r,1,t?t(i):i):n?h(r,1,n(i)):h(r,2,i)}catch(e){h(r,2,e)}},r},e}();function h(e,t,n){if(!e.s){if(n instanceof f){if(!n.s)return void(n.o=h.bind(null,e,t));1&t&&(t=n.s),n=n.v}if(n&&n.then)return void n.then(h.bind(null,e,t),h.bind(null,e,2));e.s=t,e.v=n;var r=e.o;r&&r(e)}}function d(e){return e instanceof f&&1&e.s}var v="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function p(e,t,n){if("function"==typeof e[v]){var r,i,o,u=e[v]();if(function e(a){try{for(;!((r=u.next()).done||n&&n());)if((a=t(r.value))&&a.then){if(!d(a))return void a.then(e,o||(o=h.bind(null,i=new f,2)));a=a.v}i?h(i,1,a):i=a}catch(e){h(i||(i=new f),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=[],c=0;c<e.length;c++)l.push(e[c]);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(!d(a))return void a.then(u,i||(i=h.bind(null,r=new f,2)));a=a.v}r?h(r,1,a):r=a}catch(e){h(r||(r=new f),2,e)}}(),r}(l,(function(e){return t(l[e])}),n)}"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var y=function(){function e(e,n){void 0===e&&(e=new t.PrismaClient),this.prisma=e,this.schema=n}var n=e.prototype;return n.getModel=function(e){return this.schema.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),a=r.getModelIdFieldName(t.type);return Promise.resolve(function(){if(o&&a&&!t.required){var e,l,c,s=t.list?((l={})[t.name]={select:(e={},e[a]=!0,e)},l):{};return Promise.resolve(r.prisma[i].findMany({where:n,select:u((c={},c[o]=!0,c),s)})).then((function(e){return p(e,(function(e){var n=function(){var n,u;if(!t.list||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.list||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 p(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=p(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=p(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}();function m(){var e,t,n=(e=["\n ","\n"],t||(t=e.slice(0)),e.raw=t,e);return m=function(){return n},n}function g(){var e="\n scalar DateTime\n \n type BatchPayload {\n count: Int!\n}\n";return l.enums.forEach((function(t){e+="enum "+t.name+" {",t.values.forEach((function(t){e+="\n "+t})),e+="}\n\n"})),l.inputTypes.forEach((function(t){e+="input "+t.name+" {\n ",t.fields.forEach((function(t){var n;e+=t.name+": "+((n=t.inputType.length>1&&"null"!==t.inputType[1].type&&"not"!==t.name?t.inputType[1]:t.inputType[0]).isList?"["+n.type+"!]":n.type)+(n.isRequired?"!":"")+"\n "})),e+="}\n \n"})),l.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.outputType.isRequired?"!":"")+"\n "})),e+="}\n \n"})),e}var b=r(m(),g());exports.PrismaDelete=y,exports.PrismaSelect=s,exports.generateGraphQlSDLFile=function(e,t){void 0===t&&(t="schema.graphql"),o.writeFileSync(t,i.printSchema(e))},exports.sdlInputs=b; | ||
"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(){return(u=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 a(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}var l=t.dmmf.schema,c=t.dmmf.datamodel,s=function(){function e(t,n){void 0===n&&(n={}),this.info=t,this.availableArgs=["where","orderBy","skip","cursor","take"],this.isAggregate=!1;var r=this.info.returnType.toString().replace(/]/g,"").replace(/\[/g,"").replace(/!/g,"");this.isAggregate=r.includes("Aggregate"),this.value=e.mergeDeep(this.filterBy(r,this.getSelect(this.fields)),n)}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))};var t,r=e.prototype;return r.valueOf=function(t,n,r){void 0===r&&(r={});for(var i,o=t.split("."),u=this.getSelect(this.fields),l=function(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 a(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)?a(e,void 0):void 0}}(e))){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)}(o);!(i=l()).done;){var c=i.value;if(this.isAggregate&&u.hasOwnProperty(c))u=u[c];else{if(this.isAggregate||!u.hasOwnProperty("select")||!u.select.hasOwnProperty(c))return{};u=u.select[c]}}return n?e.mergeDeep(this.filterBy(n,u),r):u},r.filterBy=function(e,t){var n=this,r=c.models.find((function(t){return t.name===e}));if(r){var i=u({},t,{select:{}});return Object.keys(t.select).forEach((function(e){var o=r.fields.find((function(t){return t.name===e}));o&&(i.select[e]="object"!==o.kind||n.filterBy(o.type,t.select[e]))})),i}return t},r.getSelect=function(e){var t=this,n=this.isAggregate?{}:{select:{}};return Object.keys(e).forEach((function(r){0===Object.keys(e[r]).length?t.isAggregate?n[r]=!0:n.select[r]=!0:"__arguments"===r?e[r].forEach((function(e){Object.keys(e).forEach((function(r){t.availableArgs.includes(r)&&(n[r]=e[r].value)}))})):t.isAggregate?n[r]=t.getSelect(e[r]):n.select[r]=t.getSelect(e[r])})),n},(t=[{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}(),f=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{d(r,1,o(this.v))}catch(e){d(r,2,e)}return r}return this}return this.o=function(e){try{var i=e.v;1&e.s?d(r,1,t?t(i):i):n?d(r,1,n(i)):d(r,2,i)}catch(e){d(r,2,e)}},r},e}();function d(e,t,n){if(!e.s){if(n instanceof f){if(!n.s)return void(n.o=d.bind(null,e,t));1&t&&(t=n.s),n=n.v}if(n&&n.then)return void n.then(d.bind(null,e,t),d.bind(null,e,2));e.s=t,e.v=n;var r=e.o;r&&r(e)}}function h(e){return e instanceof f&&1&e.s}var v="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function p(e,t,n){if("function"==typeof e[v]){var r,i,o,u=e[v]();if(function e(a){try{for(;!((r=u.next()).done||n&&n());)if((a=t(r.value))&&a.then){if(!h(a))return void a.then(e,o||(o=d.bind(null,i=new f,2)));a=a.v}i?d(i,1,a):i=a}catch(e){d(i||(i=new f),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=[],c=0;c<e.length;c++)l.push(e[c]);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(!h(a))return void a.then(u,i||(i=d.bind(null,r=new f,2)));a=a.v}r?d(r,1,a):r=a}catch(e){d(r||(r=new f),2,e)}}(),r}(l,(function(e){return t(l[e])}),n)}"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var y=function(){function e(e){void 0===e&&(e=new t.PrismaClient),this.prisma=e}var n=e.prototype;return n.getModel=function(e){return c.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),a=r.getModelIdFieldName(t.type);return Promise.resolve(function(){if(o&&a&&!t.isRequired){var e,l,c,s=t.isList?((l={})[t.name]={select:(e={},e[a]=!0,e)},l):{};return Promise.resolve(r.prisma[i].findMany({where:n,select:u((c={},c[o]=!0,c),s)})).then((function(e){return p(e,(function(e){var n=function(){var n,u;if(!t.list||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 p(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=p(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=p(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}();function m(){var e,t,n=(e=["\n ","\n"],t||(t=e.slice(0)),e.raw=t,e);return m=function(){return n},n}function g(){var e="\n scalar DateTime\n \n type BatchPayload {\n count: Int!\n}\n";return l.enums.forEach((function(t){e+="enum "+t.name+" {",t.values.forEach((function(t){e+="\n "+t})),e+="}\n\n"})),l.inputTypes.forEach((function(t){e+="input "+t.name+" {\n ",t.fields.forEach((function(t){var n;e+=t.name+": "+((n=t.inputType.length>1&&"null"!==t.inputType[1].type&&"not"!==t.name?t.inputType[1]:t.inputType[0]).isList?"["+n.type+"!]":n.type)+(n.isRequired?"!":"")+"\n "})),e+="}\n \n"})),l.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.outputType.isRequired?"!":"")+"\n "})),e+="}\n \n"})),e}var b=r(m(),g());exports.PrismaDelete=y,exports.PrismaSelect=s,exports.generateGraphQlSDLFile=function(e,t){void 0===t&&(t="schema.graphql"),o.writeFileSync(t,i.printSchema(e))},exports.sdlInputs=b; | ||
//# sourceMappingURL=plugins.cjs.production.min.js.map |
@@ -505,6 +505,5 @@ import { dmmf, PrismaClient } from '@prisma/client'; | ||
* @param prisma - optional arg you can send your clint class. | ||
* @param schema - your schema.prisma converted object . | ||
* @example | ||
* const prisma = new PrismaClient({log: ['query']}); | ||
* const prismaDelete = new PrismaDelete(prisma, schema); | ||
* const prismaDelete = new PrismaDelete(prisma); | ||
* | ||
@@ -523,3 +522,3 @@ * // or new PrismaDelete(); we will create new client and use | ||
var PrismaDelete = /*#__PURE__*/function () { | ||
function PrismaDelete(prisma, schema) { | ||
function PrismaDelete(prisma) { | ||
if (prisma === void 0) { | ||
@@ -530,3 +529,2 @@ prisma = new PrismaClient(); | ||
this.prisma = prisma; | ||
this.schema = schema; | ||
} | ||
@@ -537,3 +535,3 @@ | ||
_proto.getModel = function getModel(modelName) { | ||
return this.schema.models.find(function (item) { | ||
return dataModel.models.find(function (item) { | ||
return item.name === modelName; | ||
@@ -584,6 +582,6 @@ }); | ||
return Promise.resolve(function () { | ||
if (modelId && fieldModelId && !field.required) { | ||
if (modelId && fieldModelId && !field.isRequired) { | ||
var _select, _ref, _extends2; | ||
var fieldSelect = field.list ? (_ref = {}, _ref[field.name] = { | ||
var fieldSelect = field.isList ? (_ref = {}, _ref[field.name] = { | ||
select: (_select = {}, _select[fieldModelId] = true, _select) | ||
@@ -603,3 +601,3 @@ }, _ref) : {}; | ||
data: (_data = {}, _data[field.name] = { | ||
disconnect: field.list ? result[field.name] : true | ||
disconnect: field.isList ? result[field.name] : true | ||
}, _data) | ||
@@ -606,0 +604,0 @@ })).then(function () {}); |
{ | ||
"name": "@paljs/plugins", | ||
"version": "1.1.1", | ||
"version": "1.1.3", | ||
"main": "dist/index.js", | ||
@@ -38,3 +38,3 @@ "module": "dist/plugins.esm.js", | ||
], | ||
"gitHead": "528c1722cb0f315f04a8814f2de1dc122108d1f9" | ||
"gitHead": "b1278a6ec26dc20502e763e2c82be3437e62ebae" | ||
} |
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
205574
1471