prisma-client-php 4.1.3 → 4.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/init.js CHANGED
@@ -1 +1 @@
1
- import fs from"fs";import path from"path";import{execSync}from"child_process";import{getFileMeta}from"./utils.js";import chalk from"chalk";const{__dirname}=getFileMeta();let projectSettings=null;function checkExcludeFiles(e){return projectSettings?.excludeFilePath?.includes(e.replace(/\\/g,"/"))??!1}function copyRecursiveSync(e,s,i=e,n=!1){if(!fs.existsSync(e))return void console.error(`Source folder does not exist: ${e}`);fs.existsSync(s)||fs.mkdirSync(s,{recursive:!0});const o=fs.readdirSync(e,{withFileTypes:!0});for(const r of o){const o=path.join(e,r.name),t=path.join(s,r.name),c=path.relative(i,o),p=path.join(path.basename(i),c);if(checkExcludeFiles(t))return;const a=path.relative(__dirname,o),l=path.normalize("src/Lib/Validator.php");n&&a===l?console.log(`Skipping file: ${p}`):r.isDirectory()?copyRecursiveSync(o,t,i,n):(fs.copyFileSync(o,t),console.log(`Copied file: ${p}`))}}const directoriesToCopy=[{srcFolder:path.join(__dirname,"src"),destFolder:path.join(process.cwd(),"src")},{srcFolder:path.join(__dirname,"settings"),destFolder:path.join(process.cwd(),"settings")},{srcFolder:path.join(__dirname,"prisma"),destFolder:path.join(process.cwd(),"prisma")}];function installNpmDependencies(e){const s=process.cwd(),i=path.join(s,"package.json");let n;if(!fs.existsSync(i))return void console.error("package.json does not exist.");{const s=fs.readFileSync(i,"utf8");n=JSON.parse(s),e||(n.type="module"),fs.writeFileSync(i,JSON.stringify(n,null,2))}let o=[npmPkg("prisma"),npmPkg("@prisma/client"),npmPkg("@prisma/internals"),npmPkg("better-sqlite3"),npmPkg("@prisma/adapter-better-sqlite3"),npmPkg("mariadb"),npmPkg("@prisma/adapter-mariadb"),npmPkg("pg"),npmPkg("@prisma/adapter-pg")];e||o.push(npmPkg("tsx"),npmPkg("typescript"),npmPkg("@types/node"));const r=o.join(" ");try{console.log(`Installing packages: ${r}`),execSync(`npm install --save-dev ${r}`,{stdio:"inherit",cwd:s}),e||execSync("npx tsc --init",{stdio:"inherit",cwd:s}),console.log("Packages installed successfully.")}catch(e){console.error("Error installing packages:",e)}}function initPrisma(){const e=process.cwd(),s=path.join(e,"prisma");if(fs.existsSync(s))console.warn("Prisma folder already exists. Skipping prisma init.");else try{console.log("Initializing Prisma..."),execSync("npx prisma init",{stdio:"inherit",cwd:e}),console.log("Prisma initialized successfully.")}catch(e){console.error("Error initializing Prisma:",e)}}async function installComposerDependencies(e){const s=process.cwd(),i=path.join(s,"composer.json");if(!fs.existsSync(i))return void console.error("composer.json does not exist.");let n=[composerPkg("calicastle/cuid")];if(e){const e=path.join(s,"prisma-php.json");if(fs.existsSync(e)){const i=readJsonFile(e);let n=[];i.excludeFiles?.map(e=>{const i=path.join(s,e);fs.existsSync(i)&&n.push(i.replace(/\\/g,"/"))}),projectSettings={...i,excludeFiles:i.excludeFiles??[],excludeFilePath:n??[]}}}else n.push(composerPkg("symfony/uid"),composerPkg("brick/math"),composerPkg("tsnc/prisma-php"));try{console.log("Installing Composer dependencies:"),n.forEach(e=>console.log(`- ${chalk.blue(e)}`));const e=`C:\\xampp\\php\\php.exe C:\\ProgramData\\ComposerSetup\\bin\\composer.phar require ${n.join(" ")}`;execSync(e,{stdio:"inherit",cwd:s})}catch(e){console.error("Error installing Composer dependencies:",e)}}const readJsonFile=e=>{const s=fs.readFileSync(e,"utf8");return JSON.parse(s)},npmPinnedVersions={prisma:"7.0.1","@prisma/client":"7.0.1","@prisma/internals":"7.0.1",tsx:"4.20.6",typescript:"5.9.3","@types/node":"24.10.1","better-sqlite3":"12.5.0","@prisma/adapter-better-sqlite3":"7.0.1",mariadb:"3.4.5","@prisma/adapter-mariadb":"7.0.1",pg:"8.16.3","@prisma/adapter-pg":"7.0.1"};function npmPkg(e){return npmPinnedVersions[e]?`${e}@${npmPinnedVersions[e]}`:e}const composerPinnedVersions={"calicastle/cuid":"2.0.0","symfony/uid":"7.3.1","brick/math":"0.14.1","tsnc/prisma-php":"1.0.0"};function composerPkg(e){return composerPinnedVersions[e]?`${e}:${composerPinnedVersions[e]}`:e}async function main(){const e=process.argv.includes("--prisma-php");installNpmDependencies(e),installComposerDependencies(e),initPrisma(),directoriesToCopy.forEach(s=>{copyRecursiveSync(s.srcFolder,s.destFolder,s.srcFolder,e)});const s=path.join(__dirname,"prisma.config.ts"),i=path.join(process.cwd(),"prisma.config.ts");var n,o;n=s,o=i,fs.existsSync(n)?(fs.copyFileSync(n,o),console.log(`Copied file: ${path.basename(n)}`)):console.warn(`File not found (skip): ${n}`),console.log("Finished copying directories.")}main().catch(e=>{console.error("Error during execution:",e)});
1
+ import fs from"fs";import path from"path";import{execSync}from"child_process";import{getFileMeta}from"./utils.js";import chalk from"chalk";const{__dirname}=getFileMeta();let projectSettings=null;function checkExcludeFiles(e){return projectSettings?.excludeFilePath?.includes(e.replace(/\\/g,"/"))??!1}function copyRecursiveSync(e,s,i=e,n=!1){if(!fs.existsSync(e))return void console.error(`Source folder does not exist: ${e}`);fs.existsSync(s)||fs.mkdirSync(s,{recursive:!0});const o=fs.readdirSync(e,{withFileTypes:!0});for(const r of o){const o=path.join(e,r.name),t=path.join(s,r.name),c=path.relative(i,o),p=path.join(path.basename(i),c);if(checkExcludeFiles(t))return;const a=path.relative(__dirname,o),l=path.normalize("src/Lib/Validator.php");n&&a===l?console.log(`Skipping file: ${p}`):r.isDirectory()?copyRecursiveSync(o,t,i,n):(fs.copyFileSync(o,t),console.log(`Copied file: ${p}`))}}const directoriesToCopy=[{srcFolder:path.join(__dirname,"src"),destFolder:path.join(process.cwd(),"src")},{srcFolder:path.join(__dirname,"settings"),destFolder:path.join(process.cwd(),"settings")},{srcFolder:path.join(__dirname,"prisma"),destFolder:path.join(process.cwd(),"prisma")}];function installNpmDependencies(e){const s=process.cwd(),i=path.join(s,"package.json");let n;if(!fs.existsSync(i))return void console.error("package.json does not exist.");{const s=fs.readFileSync(i,"utf8");n=JSON.parse(s),e||(n.type="module"),fs.writeFileSync(i,JSON.stringify(n,null,2))}let o=[npmPkg("prisma"),npmPkg("@prisma/client"),npmPkg("@prisma/internals"),npmPkg("better-sqlite3"),npmPkg("@prisma/adapter-better-sqlite3"),npmPkg("mariadb"),npmPkg("@prisma/adapter-mariadb"),npmPkg("pg"),npmPkg("@prisma/adapter-pg")];e||o.push(npmPkg("tsx"),npmPkg("typescript"),npmPkg("@types/node"));const r=o.join(" ");try{console.log(`Installing packages: ${r}`),execSync(`npm install --save-dev ${r}`,{stdio:"inherit",cwd:s}),e||execSync("npx tsc --init",{stdio:"inherit",cwd:s}),console.log("Packages installed successfully.")}catch(e){console.error("Error installing packages:",e)}}function initPrisma(){const e=process.cwd(),s=path.join(e,"prisma");if(fs.existsSync(s))console.warn("Prisma folder already exists. Skipping prisma init.");else try{console.log("Initializing Prisma..."),execSync("npx prisma init",{stdio:"inherit",cwd:e}),console.log("Prisma initialized successfully.")}catch(e){console.error("Error initializing Prisma:",e)}}async function installComposerDependencies(e){const s=process.cwd(),i=path.join(s,"composer.json");if(!fs.existsSync(i))return void console.error("composer.json does not exist.");let n=[composerPkg("calicastle/cuid")];if(e){const e=path.join(s,"prisma-php.json");if(fs.existsSync(e)){const i=readJsonFile(e);let n=[];i.excludeFiles?.map(e=>{const i=path.join(s,e);fs.existsSync(i)&&n.push(i.replace(/\\/g,"/"))}),projectSettings={...i,excludeFiles:i.excludeFiles??[],excludeFilePath:n??[]}}}else n.push(composerPkg("symfony/uid"),composerPkg("brick/math"),composerPkg("tsnc/prisma-php"));try{console.log("Installing Composer dependencies:"),n.forEach(e=>console.log(`- ${chalk.blue(e)}`));const e=`C:\\xampp\\php\\php.exe C:\\ProgramData\\ComposerSetup\\bin\\composer.phar require ${n.join(" ")}`;execSync(e,{stdio:"inherit",cwd:s})}catch(e){console.error("Error installing Composer dependencies:",e)}}const readJsonFile=e=>{const s=fs.readFileSync(e,"utf8");return JSON.parse(s)},npmPinnedVersions={prisma:"7.2.0","@prisma/client":"7.2.0","@prisma/internals":"7.2.0",tsx:"4.21.0",typescript:"5.9.3","@types/node":"25.0.3","better-sqlite3":"12.5.0","@prisma/adapter-better-sqlite3":"7.2.0",mariadb:"3.4.5","@prisma/adapter-mariadb":"7.2.0",pg:"8.16.3","@prisma/adapter-pg":"7.2.0"};function npmPkg(e){return npmPinnedVersions[e]?`${e}@${npmPinnedVersions[e]}`:e}const composerPinnedVersions={"calicastle/cuid":"2.0.0","symfony/uid":"7.3.1","brick/math":"0.14.1","tsnc/prisma-php":"1.0.0"};function composerPkg(e){return composerPinnedVersions[e]?`${e}:${composerPinnedVersions[e]}`:e}async function main(){const e=process.argv.includes("--prisma-php");installNpmDependencies(e),installComposerDependencies(e),initPrisma(),directoriesToCopy.forEach(s=>{copyRecursiveSync(s.srcFolder,s.destFolder,s.srcFolder,e)});const s=path.join(__dirname,"prisma.config.ts"),i=path.join(process.cwd(),"prisma.config.ts");var n,o;n=s,o=i,fs.existsSync(n)?(fs.copyFileSync(n,o),console.log(`Copied file: ${path.basename(n)}`)):console.warn(`File not found (skip): ${n}`),console.log("Finished copying directories.")}main().catch(e=>{console.error("Error during execution:",e)});
@@ -1430,6 +1430,15 @@ final class PPHPUtility
1430
1430
  if (!$requestOption) {
1431
1431
  return $relatedResult;
1432
1432
  }
1433
+
1434
+ if ($modelRelatedFieldIsList && $isExplicitOneToMany) {
1435
+ return [];
1436
+ }
1437
+
1438
+ if ($modelRelatedFieldIsList && empty($modelRelatedFromFields)) {
1439
+ return [];
1440
+ }
1441
+
1433
1442
  if (!$relatedResult) {
1434
1443
  throw new Exception("Failed to process related record for '{$relatedFieldName}'.");
1435
1444
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "prisma-client-php",
3
3
  "description": "Prisma Client PHP is an auto-generated query builder that enables type-safe database access in PHP.",
4
- "version": "4.1.3",
4
+ "version": "4.1.5",
5
5
  "main": "index.js",
6
6
  "type": "module",
7
7
  "scripts": {