Huge News!Announcing our $40M Series B led by Abstract Ventures.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 3.0.11 to 3.2.0

21

dist/plugins.cjs.development.js

@@ -139,2 +139,3 @@ 'use strict';

this.availableArgs = ['where', 'orderBy', 'skip', 'cursor', 'take'];
this.allowedProps = ['_count'];
this.isAggregate = false;

@@ -288,12 +289,16 @@ }

Object.keys(selectObject.select).forEach(function (key) {
var field = _this.field(key, model);
if (_this.allowedProps.includes(key)) {
filteredObject.select[key] = selectObject.select[key];
} else {
var field = _this.field(key, model);
if (field) {
if (field.kind !== 'object') {
filteredObject.select[key] = true;
} else {
var subModelFilter = _this.filterBy(field.type, selectObject.select[key]);
if (field) {
if (field.kind !== 'object') {
filteredObject.select[key] = true;
} else {
var subModelFilter = _this.filterBy(field.type, selectObject.select[key]);
if (Object.keys(subModelFilter.select).length > 0) {
filteredObject.select[key] = subModelFilter;
if (Object.keys(subModelFilter.select).length > 0) {
filteredObject.select[key] = subModelFilter;
}
}

@@ -300,0 +305,0 @@ }

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=(e=require("graphql-fields"))&&"object"==typeof e&&"default"in e?e.default:e,n=require("fs");function r(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 i(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}function o(){return(o=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 u(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 a(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 u(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)?u(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 l=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 n=e.prototype;return n.model=function(t){return this.dataModel.find((function(n){return n.name===t||e.getModelMap(n.documentation,t)}))},n.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))},n.valueOf=function(t,n,r){void 0===r&&(r={});for(var i,o=t.split("."),u=this.getSelect(this.fields),l=a(o);!(i=l()).done;){var s=i.value;if(this.isAggregate&&u.hasOwnProperty(s))u=u[s];else{if(this.isAggregate||!u.hasOwnProperty("select")||!u.select.hasOwnProperty(s))return{};u=u.select[s]}}return n?e.mergeDeep(this.filterBy(n,u),r):u},n.valueWithFilter=function(e){return this.filterBy(e,this.getSelect(this.fields))},n.filterBy=function(e,t){var n=this,r=this.model(e);if(r&&"object"==typeof t){var i={};if(this.defaultFields&&this.defaultFields[e]){var u=this.defaultFields[e];i="function"==typeof u?u(t.select):u}var a=o({},t,{select:o({},i)});return Object.keys(t.select).forEach((function(e){var i=n.field(e,r);if(i)if("object"!==i.kind)a.select[e]=!0;else{var o=n.filterBy(i.type,t.select[e]);Object.keys(o.select).length>0&&(a.select[e]=o)}})),a}return t},n.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},i(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=[];if(null===(e=this.options)||void 0===e?void 0:e.dmmf){var n;null===(n=this.options)||void 0===n||n.dmmf.forEach((function(e){t.push.apply(t,e.datamodel.models)}))}else{var r=require("@prisma/client").Prisma;r.dmmf&&r.dmmf.datamodel&&t.push.apply(t,r.dmmf.datamodel.models)}return t}},{key:"defaultFields",get:function(){var e;return null===(e=this.options)||void 0===e?void 0:e.defaultFields}},{key:"fields",get:function(){return t(this.info,{},{excludedFields:["__typename"],processArguments:!0})}}]),e}(),s=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{c(r,1,o(this.v))}catch(e){c(r,2,e)}return r}return this}return this.o=function(e){try{var i=e.v;1&e.s?c(r,1,t?t(i):i):n?c(r,1,n(i)):c(r,2,i)}catch(e){c(r,2,e)}},r},e}();function c(e,t,n){if(!e.s){if(n instanceof s){if(!n.s)return void(n.o=c.bind(null,e,t));1&t&&(t=n.s),n=n.v}if(n&&n.then)return void n.then(c.bind(null,e,t),c.bind(null,e,2));e.s=t,e.v=n;var r=e.o;r&&r(e)}}function f(e){return e instanceof s&&1&e.s}function d(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(!f(a))return void a.then(u,i||(i=c.bind(null,r=new s,2)));a=a.v}r?c(r,1,a):r=a}catch(e){c(r||(r=new s),2,e)}}(),r}var p="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function v(e,t,n){if("function"==typeof e[p]){var r,i,o,u=e[p]();if(function e(a){try{for(;!((r=u.next()).done||n&&n());)if((a=t(r.value))&&a.then){if(!f(a))return void a.then(e,o||(o=c.bind(null,i=new s,2)));a=a.v}i?c(i,1,a):i=a}catch(e){c(i||(i=new s),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=[],v=0;v<e.length;v++)l.push(e[v]);return d(l,(function(e){return t(l[e])}),n)}function h(){var e,t,n=(e=["\n ","\n "],t||(t=e.slice(0)),e.raw=t,e);return h=function(){return n},n}"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var m=[],y=function e(t,n){var r,i,o,u,l=null==n||null===(r=n.dmmf)||void 0===r?void 0:r.schema;l||(l=null===(u=require("@prisma/client").Prisma.dmmf)||void 0===u?void 0:u.schema),m.push(t);var s=l?[].concat(null===(i=l)||void 0===i?void 0:i.inputObjectTypes.prisma):[];(null===(o=l)||void 0===o?void 0:o.inputObjectTypes.model)&&s.push.apply(s,l.inputObjectTypes.model);var c=s.find((function(e){return e.name===t}));if(c){if(0===c.fields.length)return!0;for(var f,d=a(c.fields);!(f=d()).done;){var p=g(f.value,n);if(p.type!==t&&"inputObjectTypes"===p.location&&!m.includes(p.type)&&e(p.type,n))return!0}}return!1},g=function(e,t){var n=0;return(null==t?void 0:t.doNotUseFieldUpdateOperationsInput)&&e.inputTypes.length>1&&e.inputTypes[1].type.endsWith("FieldUpdateOperationsInput")||e.inputTypes.length>1&&("inputObjectTypes"===e.inputTypes[1].location||e.inputTypes[1].isList)&&(n=1),e.inputTypes[n]};exports.PrismaDelete=function(){function e(e,t){this.prisma=e,this.options=t}var t=e.prototype;return t.getModel=function(e){var t;return null===(t=this.dataModel)||void 0===t?void 0:t.models.find((function(t){return t.name===e}))},e.getModelName=function(e){return e.charAt(0).toLowerCase()+e.slice(1)},t.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&&!e.isList}))},t.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},t.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))}))},t.setFieldNull=function(t,n,r){try{var i=this,u=e.getModelName(t),a=i.getModelIdFieldName(t),l=i.getModelIdFieldName(n.type);return Promise.resolve(function(){if(a&&l&&!n.isRequired){var e,t,s,c=n.isList?((t={})[n.name]={select:(e={},e[l]=!0,e)},t):{};return Promise.resolve(i.prisma[u].findMany({where:r,select:o((s={},s[a]=!0,s),c)})).then((function(e){return v(e,(function(e){var t=function(){var t,r;if(!n.isList||0!==e[n.name].length)return Promise.resolve(i.prisma[u].update({where:(t={},t[a]=e[a],t),data:(r={},r[n.name]={disconnect:!n.isList||e[n.name]},r)})).then((function(){}))}();if(t&&t.then)return t.then((function(){}))}))}))}}())}catch(e){return Promise.reject(e)}},t.getDeleteArray=function(t,n,r){void 0===r&&(r=!0);try{var i=function(){var r=o.getOnDeleteFields(t,"CASCADE"),i=function(){if(r)return v(r,(function(r){var i=o.getFieldByType(r.type,t),a=function(){if(i){var a=function(){if(r.type!==t){var a,l=u.push;return Promise.resolve(o.getDeleteArray(r.type,(a={},a[i.name]=n,a))).then((function(e){l.call.apply(l,[u].concat(e))}))}var s;u.push({name:e.getModelName(t),where:(s={},s[i.name]=n,s)})}();if(a&&a.then)return a.then((function(){}))}}();if(a&&a.then)return a.then((function(){}))}))}();return i&&i.then?i.then((function(){return u})):u},o=this,u=r?[{name:e.getModelName(t),where:n}]:[],a=o.getOnDeleteFields(t,"SET_NULL"),l=function(){if(a){var e=v(a,(function(e){return Promise.resolve(o.setFieldNull(t,e,n)).then((function(){}))}));if(e&&e.then)return e.then((function(){}))}}();return Promise.resolve(l&&l.then?l.then(i):i())}catch(e){return Promise.reject(e)}},t.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=!1,n=e.reverse();return d(n,(function(e){return e+1===n.length&&r?(t=!0,Promise.resolve(i.prisma[n[e].name].deleteMany({where:n[e].where}))):Promise.resolve(i.prisma[n[e].name].deleteMany({where:n[e].where})).then((function(){}))}),(function(){return t}))}))}catch(e){return Promise.reject(e)}},i(e,[{key:"getDMMF",get:function(){return require("@prisma/client").Prisma.dmmf}},{key:"dataModel",get:function(){var e,t,n,r;return(null===(e=this.options)||void 0===e?void 0:e.dmmf)?null===(t=this.options)||void 0===t||null===(n=t.dmmf)||void 0===n?void 0:n.datamodel:null===(r=this.getDMMF)||void 0===r?void 0:r.datamodel}}]),e}(),exports.PrismaSelect=l,exports.generateGraphQlSDLFile=function(e,t){void 0===t&&(t="schema.graphql");var r=require("graphql");n.writeFileSync(t,(0,r.printSchema)(e))},exports.getInputType=g,exports.hasEmptyTypeFields=y,exports.sdlInputs=function(e){return require("graphql-tag")(h(),function(e){var t,n,r=null==e||null===(t=e.dmmf)||void 0===t?void 0:t.schema;r||(r=null===(n=require("@prisma/client").Prisma.dmmf)||void 0===n?void 0:n.schema);var i="\n scalar DateTime\n \n type BatchPayload {\n count: Int!\n}\n";if(r){var o,u=[].concat(r.enumTypes.prisma);r.enumTypes.model&&u.push.apply(u,r.enumTypes.model),u.forEach((function(e){i+="enum "+e.name+" {",e.values.forEach((function(e){i+="\n "+e})),i+="}\n \n "}));var a=[].concat(r.inputObjectTypes.prisma);r.inputObjectTypes.model&&a.push.apply(a,r.inputObjectTypes.model),a.forEach((function(t){t.fields.length>0&&(i+="input "+t.name+" {\n ",t.fields.forEach((function(t){var n=g(t,e);"inputObjectTypes"===n.location&&y(n.type,e)||(i+=t.name+": "+(n.isList?"["+n.type+"!]":n.type)+(t.isRequired?"!":"")+"\n ")})),i+="}\n \n ")})),null===(o=r)||void 0===o||o.outputObjectTypes.prisma.filter((function(e){return e.name.includes("Aggregate")})).forEach((function(e){i+="type "+e.name+" {\n ",e.fields.forEach((function(e){i+=e.name+": "+(e.outputType.isList?"["+e.outputType.type+"!]":e.outputType.type)+(e.isNullable?"":"!")+"\n "})),i+="}\n \n "}))}return i}(e))};
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=(e=require("graphql-fields"))&&"object"==typeof e&&"default"in e?e.default:e,n=require("fs");function r(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 i(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e}function o(){return(o=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 u(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 l(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 u(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)?u(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 a=function(){function e(e,t){this.info=e,this.options=t,this.availableArgs=["where","orderBy","skip","cursor","take"],this.allowedProps=["_count"],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 n=e.prototype;return n.model=function(t){return this.dataModel.find((function(n){return n.name===t||e.getModelMap(n.documentation,t)}))},n.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 l,a;e.isObject(o[u])?(t[u]||Object.assign(t,((l={})[u]={},l)),e.mergeDeep(t[u],o[u])):Object.assign(t,((a={})[u]=o[u],a))}return e.mergeDeep.apply(e,[t].concat(r))},n.valueOf=function(t,n,r){void 0===r&&(r={});for(var i,o=t.split("."),u=this.getSelect(this.fields),a=l(o);!(i=a()).done;){var s=i.value;if(this.isAggregate&&u.hasOwnProperty(s))u=u[s];else{if(this.isAggregate||!u.hasOwnProperty("select")||!u.select.hasOwnProperty(s))return{};u=u.select[s]}}return n?e.mergeDeep(this.filterBy(n,u),r):u},n.valueWithFilter=function(e){return this.filterBy(e,this.getSelect(this.fields))},n.filterBy=function(e,t){var n=this,r=this.model(e);if(r&&"object"==typeof t){var i={};if(this.defaultFields&&this.defaultFields[e]){var u=this.defaultFields[e];i="function"==typeof u?u(t.select):u}var l=o({},t,{select:o({},i)});return Object.keys(t.select).forEach((function(e){if(n.allowedProps.includes(e))l.select[e]=t.select[e];else{var i=n.field(e,r);if(i)if("object"!==i.kind)l.select[e]=!0;else{var o=n.filterBy(i.type,t.select[e]);Object.keys(o.select).length>0&&(l.select[e]=o)}}})),l}return t},n.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},i(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=[];if(null===(e=this.options)||void 0===e?void 0:e.dmmf){var n;null===(n=this.options)||void 0===n||n.dmmf.forEach((function(e){t.push.apply(t,e.datamodel.models)}))}else{var r=require("@prisma/client").Prisma;r.dmmf&&r.dmmf.datamodel&&t.push.apply(t,r.dmmf.datamodel.models)}return t}},{key:"defaultFields",get:function(){var e;return null===(e=this.options)||void 0===e?void 0:e.defaultFields}},{key:"fields",get:function(){return t(this.info,{},{excludedFields:["__typename"],processArguments:!0})}}]),e}(),s=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{c(r,1,o(this.v))}catch(e){c(r,2,e)}return r}return this}return this.o=function(e){try{var i=e.v;1&e.s?c(r,1,t?t(i):i):n?c(r,1,n(i)):c(r,2,i)}catch(e){c(r,2,e)}},r},e}();function c(e,t,n){if(!e.s){if(n instanceof s){if(!n.s)return void(n.o=c.bind(null,e,t));1&t&&(t=n.s),n=n.v}if(n&&n.then)return void n.then(c.bind(null,e,t),c.bind(null,e,2));e.s=t,e.v=n;var r=e.o;r&&r(e)}}function f(e){return e instanceof s&&1&e.s}function d(e,t,n){var r,i,o=-1;return function u(l){try{for(;++o<e.length&&(!n||!n());)if((l=t(o))&&l.then){if(!f(l))return void l.then(u,i||(i=c.bind(null,r=new s,2)));l=l.v}r?c(r,1,l):r=l}catch(e){c(r||(r=new s),2,e)}}(),r}var p="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function v(e,t,n){if("function"==typeof e[p]){var r,i,o,u=e[p]();if(function e(l){try{for(;!((r=u.next()).done||n&&n());)if((l=t(r.value))&&l.then){if(!f(l))return void l.then(e,o||(o=c.bind(null,i=new s,2)));l=l.v}i?c(i,1,l):i=l}catch(e){c(i||(i=new s),2,e)}}(),u.return){var l=function(e){try{r.done||u.return()}catch(e){}return e};if(i&&i.then)return i.then(l,(function(e){throw l(e)}));l()}return i}if(!("length"in e))throw new TypeError("Object is not iterable");for(var a=[],v=0;v<e.length;v++)a.push(e[v]);return d(a,(function(e){return t(a[e])}),n)}function h(){var e,t,n=(e=["\n ","\n "],t||(t=e.slice(0)),e.raw=t,e);return h=function(){return n},n}"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var m=[],y=function e(t,n){var r,i,o,u,a=null==n||null===(r=n.dmmf)||void 0===r?void 0:r.schema;a||(a=null===(u=require("@prisma/client").Prisma.dmmf)||void 0===u?void 0:u.schema),m.push(t);var s=a?[].concat(null===(i=a)||void 0===i?void 0:i.inputObjectTypes.prisma):[];(null===(o=a)||void 0===o?void 0:o.inputObjectTypes.model)&&s.push.apply(s,a.inputObjectTypes.model);var c=s.find((function(e){return e.name===t}));if(c){if(0===c.fields.length)return!0;for(var f,d=l(c.fields);!(f=d()).done;){var p=g(f.value,n);if(p.type!==t&&"inputObjectTypes"===p.location&&!m.includes(p.type)&&e(p.type,n))return!0}}return!1},g=function(e,t){var n=0;return(null==t?void 0:t.doNotUseFieldUpdateOperationsInput)&&e.inputTypes.length>1&&e.inputTypes[1].type.endsWith("FieldUpdateOperationsInput")||e.inputTypes.length>1&&("inputObjectTypes"===e.inputTypes[1].location||e.inputTypes[1].isList)&&(n=1),e.inputTypes[n]};exports.PrismaDelete=function(){function e(e,t){this.prisma=e,this.options=t}var t=e.prototype;return t.getModel=function(e){var t;return null===(t=this.dataModel)||void 0===t?void 0:t.models.find((function(t){return t.name===e}))},e.getModelName=function(e){return e.charAt(0).toLowerCase()+e.slice(1)},t.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&&!e.isList}))},t.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},t.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))}))},t.setFieldNull=function(t,n,r){try{var i=this,u=e.getModelName(t),l=i.getModelIdFieldName(t),a=i.getModelIdFieldName(n.type);return Promise.resolve(function(){if(l&&a&&!n.isRequired){var e,t,s,c=n.isList?((t={})[n.name]={select:(e={},e[a]=!0,e)},t):{};return Promise.resolve(i.prisma[u].findMany({where:r,select:o((s={},s[l]=!0,s),c)})).then((function(e){return v(e,(function(e){var t=function(){var t,r;if(!n.isList||0!==e[n.name].length)return Promise.resolve(i.prisma[u].update({where:(t={},t[l]=e[l],t),data:(r={},r[n.name]={disconnect:!n.isList||e[n.name]},r)})).then((function(){}))}();if(t&&t.then)return t.then((function(){}))}))}))}}())}catch(e){return Promise.reject(e)}},t.getDeleteArray=function(t,n,r){void 0===r&&(r=!0);try{var i=function(){var r=o.getOnDeleteFields(t,"CASCADE"),i=function(){if(r)return v(r,(function(r){var i=o.getFieldByType(r.type,t),l=function(){if(i){var l=function(){if(r.type!==t){var l,a=u.push;return Promise.resolve(o.getDeleteArray(r.type,(l={},l[i.name]=n,l))).then((function(e){a.call.apply(a,[u].concat(e))}))}var s;u.push({name:e.getModelName(t),where:(s={},s[i.name]=n,s)})}();if(l&&l.then)return l.then((function(){}))}}();if(l&&l.then)return l.then((function(){}))}))}();return i&&i.then?i.then((function(){return u})):u},o=this,u=r?[{name:e.getModelName(t),where:n}]:[],l=o.getOnDeleteFields(t,"SET_NULL"),a=function(){if(l){var e=v(l,(function(e){return Promise.resolve(o.setFieldNull(t,e,n)).then((function(){}))}));if(e&&e.then)return e.then((function(){}))}}();return Promise.resolve(a&&a.then?a.then(i):i())}catch(e){return Promise.reject(e)}},t.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=!1,n=e.reverse();return d(n,(function(e){return e+1===n.length&&r?(t=!0,Promise.resolve(i.prisma[n[e].name].deleteMany({where:n[e].where}))):Promise.resolve(i.prisma[n[e].name].deleteMany({where:n[e].where})).then((function(){}))}),(function(){return t}))}))}catch(e){return Promise.reject(e)}},i(e,[{key:"getDMMF",get:function(){return require("@prisma/client").Prisma.dmmf}},{key:"dataModel",get:function(){var e,t,n,r;return(null===(e=this.options)||void 0===e?void 0:e.dmmf)?null===(t=this.options)||void 0===t||null===(n=t.dmmf)||void 0===n?void 0:n.datamodel:null===(r=this.getDMMF)||void 0===r?void 0:r.datamodel}}]),e}(),exports.PrismaSelect=a,exports.generateGraphQlSDLFile=function(e,t){void 0===t&&(t="schema.graphql");var r=require("graphql");n.writeFileSync(t,(0,r.printSchema)(e))},exports.getInputType=g,exports.hasEmptyTypeFields=y,exports.sdlInputs=function(e){return require("graphql-tag")(h(),function(e){var t,n,r=null==e||null===(t=e.dmmf)||void 0===t?void 0:t.schema;r||(r=null===(n=require("@prisma/client").Prisma.dmmf)||void 0===n?void 0:n.schema);var i="\n scalar DateTime\n \n type BatchPayload {\n count: Int!\n}\n";if(r){var o,u=[].concat(r.enumTypes.prisma);r.enumTypes.model&&u.push.apply(u,r.enumTypes.model),u.forEach((function(e){i+="enum "+e.name+" {",e.values.forEach((function(e){i+="\n "+e})),i+="}\n \n "}));var l=[].concat(r.inputObjectTypes.prisma);r.inputObjectTypes.model&&l.push.apply(l,r.inputObjectTypes.model),l.forEach((function(t){t.fields.length>0&&(i+="input "+t.name+" {\n ",t.fields.forEach((function(t){var n=g(t,e);"inputObjectTypes"===n.location&&y(n.type,e)||(i+=t.name+": "+(n.isList?"["+n.type+"!]":n.type)+(t.isRequired?"!":"")+"\n ")})),i+="}\n \n ")})),null===(o=r)||void 0===o||o.outputObjectTypes.prisma.filter((function(e){return e.name.includes("Aggregate")})).forEach((function(e){i+="type "+e.name+" {\n ",e.fields.forEach((function(e){i+=e.name+": "+(e.outputType.isList?"["+e.outputType.type+"!]":e.outputType.type)+(e.isNullable?"":"!")+"\n "})),i+="}\n \n "}))}return i}(e))};
//# sourceMappingURL=plugins.cjs.production.min.js.map

@@ -133,2 +133,3 @@ import graphqlFields from 'graphql-fields';

this.availableArgs = ['where', 'orderBy', 'skip', 'cursor', 'take'];
this.allowedProps = ['_count'];
this.isAggregate = false;

@@ -282,12 +283,16 @@ }

Object.keys(selectObject.select).forEach(function (key) {
var field = _this.field(key, model);
if (_this.allowedProps.includes(key)) {
filteredObject.select[key] = selectObject.select[key];
} else {
var field = _this.field(key, model);
if (field) {
if (field.kind !== 'object') {
filteredObject.select[key] = true;
} else {
var subModelFilter = _this.filterBy(field.type, selectObject.select[key]);
if (field) {
if (field.kind !== 'object') {
filteredObject.select[key] = true;
} else {
var subModelFilter = _this.filterBy(field.type, selectObject.select[key]);
if (Object.keys(subModelFilter.select).length > 0) {
filteredObject.select[key] = subModelFilter;
if (Object.keys(subModelFilter.select).length > 0) {
filteredObject.select[key] = subModelFilter;
}
}

@@ -294,0 +299,0 @@ }

@@ -45,2 +45,3 @@ import { GraphQLResolveInfo } from 'graphql';

private availableArgs;
private allowedProps;
private isAggregate;

@@ -47,0 +48,0 @@ constructor(info: GraphQLResolveInfo, options?: {

{
"name": "@paljs/plugins",
"version": "3.0.11",
"version": "3.2.0",
"main": "dist/index.js",

@@ -24,5 +24,5 @@ "module": "dist/plugins.esm.js",

"dependencies": {
"@paljs/types": "^3.0.1",
"@paljs/types": "^3.2.0",
"graphql-fields": "2.0.3",
"graphql-tag": "2.11.0"
"graphql-tag": "2.12.4"
},

@@ -33,5 +33,5 @@ "publishConfig": {

"devDependencies": {
"@prisma/client": "^2.20.1",
"@prisma/client": "^2.22.1",
"graphql": "^15.5.0",
"typescript": "4.2.3"
"typescript": "4.2.4"
},

@@ -41,3 +41,3 @@ "files": [

],
"gitHead": "ab6296bb5a087c4b4786255b7cbbe4eb22bce507"
"gitHead": "80ca20ec4c35f407b7a1ca474847dbf84e51c1d1"
}

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