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 2.7.0 to 2.8.0

68

dist/plugins.cjs.development.js

@@ -824,3 +824,5 @@ 'use strict';

testedTypes.push(type);
var inputType = schema$1 === null || schema$1 === void 0 ? void 0 : schema$1.inputTypes.find(function (item) {
var inputObjectTypes = schema$1 ? [].concat(schema$1 === null || schema$1 === void 0 ? void 0 : schema$1.inputObjectTypes.prisma) : [];
if (schema$1 === null || schema$1 === void 0 ? void 0 : schema$1.inputObjectTypes.model) inputObjectTypes.push.apply(inputObjectTypes, schema$1.inputObjectTypes.model);
var inputType = inputObjectTypes.find(function (item) {
return item.name === type;

@@ -836,3 +838,3 @@ });

if (fieldType.type !== type && fieldType.kind === 'object' && !testedTypes.includes(fieldType.type)) {
if (fieldType.type !== type && fieldType.location === 'inputObjectTypes' && !testedTypes.includes(fieldType.type)) {
var state = hasEmptyTypeFields(fieldType.type);

@@ -853,3 +855,3 @@ if (state) return true;

if (field.inputTypes.length > 1 && field.inputTypes[1].kind === 'object') {
if (field.inputTypes.length > 1 && field.inputTypes[1].location !== 'scalar') {
index = 1;

@@ -866,32 +868,40 @@ }

var fileContent = "\n scalar DateTime\n \n type BatchPayload {\n count: Int!\n}\n";
schema$1 === null || schema$1 === void 0 ? void 0 : schema$1.enums.forEach(function (item) {
fileContent += "enum " + item.name + " {";
item.values.forEach(function (item2) {
fileContent += "\n " + item2;
if (schema$1) {
var enums = [].concat(schema$1.enumTypes.prisma);
if (schema$1.enumTypes.model) enums.push.apply(enums, schema$1.enumTypes.model);
enums.forEach(function (item) {
fileContent += "enum " + item.name + " {";
item.values.forEach(function (item2) {
fileContent += "\n " + item2;
});
fileContent += "}\n \n ";
});
fileContent += "}\n\n";
});
schema$1 === null || schema$1 === void 0 ? void 0 : schema$1.inputTypes.forEach(function (model) {
if (model.fields.length > 0) {
fileContent += "input " + model.name + " {\n ";
model.fields.forEach(function (field) {
var inputType = getInputType(field, options);
var hasEmptyType = inputType.kind === 'object' && hasEmptyTypeFields(inputType.type);
var inputObjectTypes = [].concat(schema$1.inputObjectTypes.prisma);
if (schema$1.inputObjectTypes.model) inputObjectTypes.push.apply(inputObjectTypes, schema$1.inputObjectTypes.model);
inputObjectTypes.forEach(function (model) {
if (model.fields.length > 0) {
fileContent += "input " + model.name + " {\n ";
model.fields.forEach(function (field) {
var inputType = getInputType(field, options);
var hasEmptyType = inputType.location === 'inputObjectTypes' && hasEmptyTypeFields(inputType.type);
if (!hasEmptyType) {
fileContent += field.name + ": " + (inputType.isList ? "[" + inputType.type + "!]" : inputType.type) + (field.isRequired ? '!' : '') + "\n ";
}
if (!hasEmptyType) {
fileContent += field.name + ": " + (inputType.isList ? "[" + inputType.type + "!]" : inputType.type) + (field.isRequired ? '!' : '') + "\n ";
}
});
fileContent += "}\n \n ";
}
});
schema$1 === null || schema$1 === void 0 ? void 0 : schema$1.outputObjectTypes.prisma.filter(function (type) {
return type.name.includes('Aggregate');
}).forEach(function (type) {
fileContent += "type " + type.name + " {\n ";
type.fields.forEach(function (field) {
fileContent += field.name + ": " + (field.outputType.isList ? "[" + field.outputType.type + "!]" : field.outputType.type) + (field.isRequired ? '!' : '') + "\n ";
});
fileContent += "}\n \n";
}
});
schema$1 === null || schema$1 === void 0 ? void 0 : schema$1.outputTypes.filter(function (type) {
return type.name.includes('Aggregate');
}).forEach(function (type) {
fileContent += "type " + type.name + " {\n ";
type.fields.forEach(function (field) {
fileContent += field.name + ": " + (field.outputType.isList ? "[" + field.outputType.type + "!]" : field.outputType.type) + (field.isRequired ? '!' : '') + "\n ";
fileContent += "}\n \n ";
});
fileContent += "}\n \n";
});
}
return fileContent;

@@ -898,0 +908,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=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 l(e,t,n){return t&&u(e.prototype,t),n&&u(e,n),e}function a(){return(a=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=null==t.dmmf?void 0:t.dmmf.schema,d=null==t.dmmf?void 0:t.dmmf.datamodel,v=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){var n;return null===(n=this.dataModel)||void 0===n?void 0:n.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 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))},t.valueOf=function(t,n,r){void 0===r&&(r={});for(var i,o=t.split("."),u=this.getSelect(this.fields),l=c(o);!(i=l()).done;){var a=i.value;if(this.isAggregate&&u.hasOwnProperty(a))u=u[a];else{if(this.isAggregate||!u.hasOwnProperty("select")||!u.select.hasOwnProperty(a))return{};u=u.select[a]}}return n?e.mergeDeep(this.filterBy(n,u),r):u},t.valueWithFilter=function(e){return this.filterBy(e,this.getSelect(this.fields))},t.filterBy=function(e,t){var n=this,r=this.model(e);if(r){var i={};this.defaultFields&&this.defaultFields[e]&&(i=this.defaultFields[e]);var o=a({},t,{select:a({},i)});return Object.keys(t.select).forEach((function(e){var i=n.field(e,r);if(i)if("object"!==i.kind)o.select[e]=!0;else{var u=n.filterBy(i.type,t.select[e]);Object.keys(u.select).length>0&&(o.select[e]=u)}})),o}return t},t.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},l(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}(),h=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 h){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 h&&1&e.s}function m(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(!y(l))return void l.then(u,i||(i=p.bind(null,r=new h,2)));l=l.v}r?p(r,1,l):r=l}catch(e){p(r||(r=new h),2,e)}}(),r}var g="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function b(e,t,n){if("function"==typeof e[g]){var r,i,o,u=e[g]();if(function e(l){try{for(;!((r=u.next()).done||n&&n());)if((l=t(r.value))&&l.then){if(!y(l))return void l.then(e,o||(o=p.bind(null,i=new h,2)));l=l.v}i?p(i,1,l):i=l}catch(e){p(i||(i=new h),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=[],s=0;s<e.length;s++)a.push(e[s]);return m(a,(function(e){return t(a[e])}),n)}function w(){var e,t,n=(e=["\n ","\n"],t||(t=e.slice(0)),e.raw=t,e);return w=function(){return n},n}"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var S=[],j=function e(t,n){var r,i=(null==n||null===(r=n.dmmf)||void 0===r?void 0:r.schema)||f;S.push(t);var o=null==i?void 0:i.inputTypes.find((function(e){return e.name===t}));if(o){if(0===o.fields.length)return!0;for(var u,l=c(o.fields);!(u=l()).done;){var a=O(u.value,n);if(a.type!==t&&"object"===a.kind&&!S.includes(a.type)&&e(a.type))return!0}}return!1},O=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&&"object"===e.inputTypes[1].kind&&(n=1),e.inputTypes[n]};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){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)},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(t,n,r){try{var i=this,o=e.getModelName(t),u=i.getModelIdFieldName(t),l=i.getModelIdFieldName(n.type);return Promise.resolve(function(){if(u&&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[o].findMany({where:r,select:a((s={},s[u]=!0,s),c)})).then((function(e){return b(e,(function(e){var t=function(){var t,r;if(!n.isList||0!==e[n.name].length)return Promise.resolve(i.prisma[o].update({where:(t={},t[u]=e[u],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)}},n.getDeleteArray=function(t,n,r){void 0===r&&(r=!0);try{var i=function(){var e=o.getOnDeleteFields(t,"CASCADE"),r=function(){if(e)return b(e,(function(e){var r=o.getFieldByType(e.type,t),i=function(){if(r){var t,i=u.push;return Promise.resolve(o.getDeleteArray(e.type,(t={},t[r.name]=n,t))).then((function(e){i.call.apply(i,[u].concat(e))}))}}();if(i&&i.then)return i.then((function(){}))}))}();return r&&r.then?r.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=b(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)}},n.onDelete=function(e){var t=e.model,n=e.where,r=e.deleteParent,i=e.returnFields;try{var o=this;return Promise.resolve(o.getDeleteArray(t,n,!!r)).then((function(e){var t=!1,n=e.reverse();return m(n,(function(e){return e+1===n.length&&r?(t=!0,Promise.resolve(o.prisma[n[e].name].deleteMany({where:n[e].where,select:i}))):Promise.resolve(o.prisma[n[e].name].deleteMany({where:n[e].where})).then((function(){}))}),(function(){return t}))}))}catch(e){return Promise.reject(e)}},l(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=v,exports.generateGraphQlSDLFile=function(e,t){void 0===t&&(t="schema.graphql"),o.writeFileSync(t,i.printSchema(e))},exports.getInputType=O,exports.hasEmptyTypeFields=j,exports.sdlInputs=function(e){return r(w(),function(e){var t,n=(null==e||null===(t=e.dmmf)||void 0===t?void 0:t.schema)||f,r="\n scalar DateTime\n \n type BatchPayload {\n count: Int!\n}\n";return null==n||n.enums.forEach((function(e){r+="enum "+e.name+" {",e.values.forEach((function(e){r+="\n "+e})),r+="}\n\n"})),null==n||n.inputTypes.forEach((function(t){t.fields.length>0&&(r+="input "+t.name+" {\n ",t.fields.forEach((function(t){var n=O(t,e);"object"===n.kind&&j(n.type)||(r+=t.name+": "+(n.isList?"["+n.type+"!]":n.type)+(t.isRequired?"!":"")+"\n ")})),r+="}\n \n")})),null==n||n.outputTypes.filter((function(e){return e.name.includes("Aggregate")})).forEach((function(e){r+="type "+e.name+" {\n ",e.fields.forEach((function(e){r+=e.name+": "+(e.outputType.isList?"["+e.outputType.type+"!]":e.outputType.type)+(e.isRequired?"!":"")+"\n "})),r+="}\n \n"})),r}(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 l(e,t,n){return t&&u(e.prototype,t),n&&u(e,n),e}function a(){return(a=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=null==t.dmmf?void 0:t.dmmf.schema,d=null==t.dmmf?void 0:t.dmmf.datamodel,p=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){var n;return null===(n=this.dataModel)||void 0===n?void 0:n.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 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))},t.valueOf=function(t,n,r){void 0===r&&(r={});for(var i,o=t.split("."),u=this.getSelect(this.fields),l=c(o);!(i=l()).done;){var a=i.value;if(this.isAggregate&&u.hasOwnProperty(a))u=u[a];else{if(this.isAggregate||!u.hasOwnProperty("select")||!u.select.hasOwnProperty(a))return{};u=u.select[a]}}return n?e.mergeDeep(this.filterBy(n,u),r):u},t.valueWithFilter=function(e){return this.filterBy(e,this.getSelect(this.fields))},t.filterBy=function(e,t){var n=this,r=this.model(e);if(r){var i={};this.defaultFields&&this.defaultFields[e]&&(i=this.defaultFields[e]);var o=a({},t,{select:a({},i)});return Object.keys(t.select).forEach((function(e){var i=n.field(e,r);if(i)if("object"!==i.kind)o.select[e]=!0;else{var u=n.filterBy(i.type,t.select[e]);Object.keys(u.select).length>0&&(o.select[e]=u)}})),o}return t},t.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},l(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{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 v){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 y(e){return e instanceof v&&1&e.s}function m(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(!y(l))return void l.then(u,i||(i=h.bind(null,r=new v,2)));l=l.v}r?h(r,1,l):r=l}catch(e){h(r||(r=new v),2,e)}}(),r}var g="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function b(e,t,n){if("function"==typeof e[g]){var r,i,o,u=e[g]();if(function e(l){try{for(;!((r=u.next()).done||n&&n());)if((l=t(r.value))&&l.then){if(!y(l))return void l.then(e,o||(o=h.bind(null,i=new v,2)));l=l.v}i?h(i,1,l):i=l}catch(e){h(i||(i=new v),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=[],s=0;s<e.length;s++)a.push(e[s]);return m(a,(function(e){return t(a[e])}),n)}function O(){var e,t,n=(e=["\n ","\n"],t||(t=e.slice(0)),e.raw=t,e);return O=function(){return n},n}"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var j=[],w=function e(t,n){var r,i=(null==n||null===(r=n.dmmf)||void 0===r?void 0:r.schema)||f;j.push(t);var o=i?[].concat(null==i?void 0:i.inputObjectTypes.prisma):[];(null==i?void 0:i.inputObjectTypes.model)&&o.push.apply(o,i.inputObjectTypes.model);var u=o.find((function(e){return e.name===t}));if(u){if(0===u.fields.length)return!0;for(var l,a=c(u.fields);!(l=a()).done;){var s=S(l.value,n);if(s.type!==t&&"inputObjectTypes"===s.location&&!j.includes(s.type)&&e(s.type))return!0}}return!1},S=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&&"scalar"!==e.inputTypes[1].location&&(n=1),e.inputTypes[n]};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){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)},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(t,n,r){try{var i=this,o=e.getModelName(t),u=i.getModelIdFieldName(t),l=i.getModelIdFieldName(n.type);return Promise.resolve(function(){if(u&&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[o].findMany({where:r,select:a((s={},s[u]=!0,s),c)})).then((function(e){return b(e,(function(e){var t=function(){var t,r;if(!n.isList||0!==e[n.name].length)return Promise.resolve(i.prisma[o].update({where:(t={},t[u]=e[u],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)}},n.getDeleteArray=function(t,n,r){void 0===r&&(r=!0);try{var i=function(){var e=o.getOnDeleteFields(t,"CASCADE"),r=function(){if(e)return b(e,(function(e){var r=o.getFieldByType(e.type,t),i=function(){if(r){var t,i=u.push;return Promise.resolve(o.getDeleteArray(e.type,(t={},t[r.name]=n,t))).then((function(e){i.call.apply(i,[u].concat(e))}))}}();if(i&&i.then)return i.then((function(){}))}))}();return r&&r.then?r.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=b(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)}},n.onDelete=function(e){var t=e.model,n=e.where,r=e.deleteParent,i=e.returnFields;try{var o=this;return Promise.resolve(o.getDeleteArray(t,n,!!r)).then((function(e){var t=!1,n=e.reverse();return m(n,(function(e){return e+1===n.length&&r?(t=!0,Promise.resolve(o.prisma[n[e].name].deleteMany({where:n[e].where,select:i}))):Promise.resolve(o.prisma[n[e].name].deleteMany({where:n[e].where})).then((function(){}))}),(function(){return t}))}))}catch(e){return Promise.reject(e)}},l(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=p,exports.generateGraphQlSDLFile=function(e,t){void 0===t&&(t="schema.graphql"),o.writeFileSync(t,i.printSchema(e))},exports.getInputType=S,exports.hasEmptyTypeFields=w,exports.sdlInputs=function(e){return r(O(),function(e){var t,n=(null==e||null===(t=e.dmmf)||void 0===t?void 0:t.schema)||f,r="\n scalar DateTime\n \n type BatchPayload {\n count: Int!\n}\n";if(n){var i=[].concat(n.enumTypes.prisma);n.enumTypes.model&&i.push.apply(i,n.enumTypes.model),i.forEach((function(e){r+="enum "+e.name+" {",e.values.forEach((function(e){r+="\n "+e})),r+="}\n \n "}));var o=[].concat(n.inputObjectTypes.prisma);n.inputObjectTypes.model&&o.push.apply(o,n.inputObjectTypes.model),o.forEach((function(t){t.fields.length>0&&(r+="input "+t.name+" {\n ",t.fields.forEach((function(t){var n=S(t,e);"inputObjectTypes"===n.location&&w(n.type)||(r+=t.name+": "+(n.isList?"["+n.type+"!]":n.type)+(t.isRequired?"!":"")+"\n ")})),r+="}\n \n ")})),null==n||n.outputObjectTypes.prisma.filter((function(e){return e.name.includes("Aggregate")})).forEach((function(e){r+="type "+e.name+" {\n ",e.fields.forEach((function(e){r+=e.name+": "+(e.outputType.isList?"["+e.outputType.type+"!]":e.outputType.type)+(e.isRequired?"!":"")+"\n "})),r+="}\n \n "}))}return r}(e))};
//# sourceMappingURL=plugins.cjs.production.min.js.map

@@ -818,3 +818,5 @@ import { dmmf, PrismaClient } from '@prisma/client';

testedTypes.push(type);
var inputType = schema$1 === null || schema$1 === void 0 ? void 0 : schema$1.inputTypes.find(function (item) {
var inputObjectTypes = schema$1 ? [].concat(schema$1 === null || schema$1 === void 0 ? void 0 : schema$1.inputObjectTypes.prisma) : [];
if (schema$1 === null || schema$1 === void 0 ? void 0 : schema$1.inputObjectTypes.model) inputObjectTypes.push.apply(inputObjectTypes, schema$1.inputObjectTypes.model);
var inputType = inputObjectTypes.find(function (item) {
return item.name === type;

@@ -830,3 +832,3 @@ });

if (fieldType.type !== type && fieldType.kind === 'object' && !testedTypes.includes(fieldType.type)) {
if (fieldType.type !== type && fieldType.location === 'inputObjectTypes' && !testedTypes.includes(fieldType.type)) {
var state = hasEmptyTypeFields(fieldType.type);

@@ -847,3 +849,3 @@ if (state) return true;

if (field.inputTypes.length > 1 && field.inputTypes[1].kind === 'object') {
if (field.inputTypes.length > 1 && field.inputTypes[1].location !== 'scalar') {
index = 1;

@@ -860,32 +862,40 @@ }

var fileContent = "\n scalar DateTime\n \n type BatchPayload {\n count: Int!\n}\n";
schema$1 === null || schema$1 === void 0 ? void 0 : schema$1.enums.forEach(function (item) {
fileContent += "enum " + item.name + " {";
item.values.forEach(function (item2) {
fileContent += "\n " + item2;
if (schema$1) {
var enums = [].concat(schema$1.enumTypes.prisma);
if (schema$1.enumTypes.model) enums.push.apply(enums, schema$1.enumTypes.model);
enums.forEach(function (item) {
fileContent += "enum " + item.name + " {";
item.values.forEach(function (item2) {
fileContent += "\n " + item2;
});
fileContent += "}\n \n ";
});
fileContent += "}\n\n";
});
schema$1 === null || schema$1 === void 0 ? void 0 : schema$1.inputTypes.forEach(function (model) {
if (model.fields.length > 0) {
fileContent += "input " + model.name + " {\n ";
model.fields.forEach(function (field) {
var inputType = getInputType(field, options);
var hasEmptyType = inputType.kind === 'object' && hasEmptyTypeFields(inputType.type);
var inputObjectTypes = [].concat(schema$1.inputObjectTypes.prisma);
if (schema$1.inputObjectTypes.model) inputObjectTypes.push.apply(inputObjectTypes, schema$1.inputObjectTypes.model);
inputObjectTypes.forEach(function (model) {
if (model.fields.length > 0) {
fileContent += "input " + model.name + " {\n ";
model.fields.forEach(function (field) {
var inputType = getInputType(field, options);
var hasEmptyType = inputType.location === 'inputObjectTypes' && hasEmptyTypeFields(inputType.type);
if (!hasEmptyType) {
fileContent += field.name + ": " + (inputType.isList ? "[" + inputType.type + "!]" : inputType.type) + (field.isRequired ? '!' : '') + "\n ";
}
if (!hasEmptyType) {
fileContent += field.name + ": " + (inputType.isList ? "[" + inputType.type + "!]" : inputType.type) + (field.isRequired ? '!' : '') + "\n ";
}
});
fileContent += "}\n \n ";
}
});
schema$1 === null || schema$1 === void 0 ? void 0 : schema$1.outputObjectTypes.prisma.filter(function (type) {
return type.name.includes('Aggregate');
}).forEach(function (type) {
fileContent += "type " + type.name + " {\n ";
type.fields.forEach(function (field) {
fileContent += field.name + ": " + (field.outputType.isList ? "[" + field.outputType.type + "!]" : field.outputType.type) + (field.isRequired ? '!' : '') + "\n ";
});
fileContent += "}\n \n";
}
});
schema$1 === null || schema$1 === void 0 ? void 0 : schema$1.outputTypes.filter(function (type) {
return type.name.includes('Aggregate');
}).forEach(function (type) {
fileContent += "type " + type.name + " {\n ";
type.fields.forEach(function (field) {
fileContent += field.name + ": " + (field.outputType.isList ? "[" + field.outputType.type + "!]" : field.outputType.type) + (field.isRequired ? '!' : '') + "\n ";
fileContent += "}\n \n ";
});
fileContent += "}\n \n";
});
}
return fileContent;

@@ -892,0 +902,0 @@ }

{
"name": "@paljs/plugins",
"version": "2.7.0",
"version": "2.8.0",
"main": "dist/index.js",

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

"dependencies": {
"@paljs/types": "^2.5.4",
"@paljs/types": "^2.8.0",
"graphql-fields": "2.0.3",

@@ -33,3 +33,3 @@ "graphql-tag": "2.11.0"

"devDependencies": {
"@prisma/client": "2.11.0",
"@prisma/client": "2.12.0",
"graphql": "^15.4.0",

@@ -41,3 +41,3 @@ "typescript": "4.0.5"

],
"gitHead": "4a0d689f6122d542a5725088cbff5b7b9781b642"
"gitHead": "21446d04af4316b4624558f3c2f49f2e2ff6d4b2"
}

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