prisma-client-php 2.2.0 → 2.3.1
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/index.enc +1 -1
- package/dist/init.js +17 -9
- package/dist/prisma/seed.ts +29 -29
- package/dist/prisma.config.ts +10 -0
- package/dist/src/Lib/Prisma/Classes/PPHPUtility.php +64 -0
- package/package.json +2 -2
package/dist/init.js
CHANGED
|
@@ -72,9 +72,6 @@ function installNpmDependencies(isPrismaPHP) {
|
|
|
72
72
|
if (fs.existsSync(packageJsonPath)) {
|
|
73
73
|
const packageJsonContent = fs.readFileSync(packageJsonPath, "utf8");
|
|
74
74
|
packageJson = JSON.parse(packageJsonContent);
|
|
75
|
-
packageJson.prisma = {
|
|
76
|
-
seed: "tsx prisma/seed.ts",
|
|
77
|
-
};
|
|
78
75
|
if (!isPrismaPHP) {
|
|
79
76
|
packageJson.type = "module";
|
|
80
77
|
}
|
|
@@ -189,12 +186,12 @@ const readJsonFile = (filePath) => {
|
|
|
189
186
|
return JSON.parse(jsonData);
|
|
190
187
|
};
|
|
191
188
|
const npmPinnedVersions = {
|
|
192
|
-
prisma: "^6.
|
|
193
|
-
"@prisma/client": "^6.
|
|
194
|
-
"@prisma/internals": "^6.
|
|
195
|
-
tsx: "^4.
|
|
196
|
-
typescript: "^5.
|
|
197
|
-
"@types/node": "^
|
|
189
|
+
prisma: "^6.14.0",
|
|
190
|
+
"@prisma/client": "^6.14.0",
|
|
191
|
+
"@prisma/internals": "^6.14.0",
|
|
192
|
+
tsx: "^4.20.5",
|
|
193
|
+
typescript: "^5.9.2",
|
|
194
|
+
"@types/node": "^24.3.0",
|
|
198
195
|
};
|
|
199
196
|
function npmPkg(name) {
|
|
200
197
|
return npmPinnedVersions[name] ? `${name}@${npmPinnedVersions[name]}` : name;
|
|
@@ -224,6 +221,17 @@ async function main() {
|
|
|
224
221
|
isPrismaPHP
|
|
225
222
|
);
|
|
226
223
|
});
|
|
224
|
+
function copyFileVerbose(src, dest) {
|
|
225
|
+
if (!fs.existsSync(src)) {
|
|
226
|
+
console.warn(`File not found (skip): ${src}`);
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
fs.copyFileSync(src, dest);
|
|
230
|
+
console.log(`Copied file: ${path.basename(src)} -> ${dest}`);
|
|
231
|
+
}
|
|
232
|
+
const prismaConfigSrc = path.join(__dirname, "prisma.config.ts");
|
|
233
|
+
const prismaConfigDest = path.join(process.cwd(), "prisma.config.ts");
|
|
234
|
+
copyFileVerbose(prismaConfigSrc, prismaConfigDest);
|
|
227
235
|
console.log("Finished copying directories.");
|
|
228
236
|
}
|
|
229
237
|
// Run the main function
|
package/dist/prisma/seed.ts
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
|
|
1
|
+
import { PrismaClient } from "@prisma/client";
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
const prisma = new PrismaClient();
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
const userRoleData = [
|
|
6
|
+
{
|
|
7
|
+
id: 1,
|
|
8
|
+
name: "Admin",
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
id: 2,
|
|
12
|
+
name: "User",
|
|
13
|
+
},
|
|
14
|
+
];
|
|
14
15
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
// ];
|
|
16
|
+
const userData = [
|
|
17
|
+
{
|
|
18
|
+
name: "Juan",
|
|
19
|
+
email: "j@gmail.com",
|
|
20
|
+
password: "$2b$10$mgjotYzIXwrK1MCWmu4tgeUVnLcb.qzvqwxOq4FXEL8k2obwXivDi", // TODO: template password 1234 (bcrypt) testing only
|
|
21
|
+
roleId: 1,
|
|
22
|
+
},
|
|
23
|
+
];
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
async function main() {
|
|
26
26
|
// ========================================
|
|
27
27
|
// Code for PostgreSQL
|
|
28
28
|
// ----------------------------------------
|
|
@@ -63,12 +63,12 @@
|
|
|
63
63
|
// await prisma.user.deleteMany();
|
|
64
64
|
// await prisma.user.createMany({ data: userData });
|
|
65
65
|
// ========================================
|
|
66
|
-
|
|
66
|
+
}
|
|
67
67
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
68
|
+
main()
|
|
69
|
+
.catch((e) => {
|
|
70
|
+
throw e;
|
|
71
|
+
})
|
|
72
|
+
.finally(async () => {
|
|
73
|
+
await prisma.$disconnect();
|
|
74
|
+
});
|
|
@@ -1543,4 +1543,68 @@ final class PPHPUtility
|
|
|
1543
1543
|
|
|
1544
1544
|
return $clauses ? ' HAVING ' . implode(' AND ', $clauses) : '';
|
|
1545
1545
|
}
|
|
1546
|
+
|
|
1547
|
+
public static function normalizeRowTypes(array $row, array $fieldsByName): array
|
|
1548
|
+
{
|
|
1549
|
+
foreach ($fieldsByName as $name => $meta) {
|
|
1550
|
+
if (!array_key_exists($name, $row)) {
|
|
1551
|
+
continue;
|
|
1552
|
+
}
|
|
1553
|
+
if (($meta['kind'] ?? null) !== 'scalar') {
|
|
1554
|
+
continue;
|
|
1555
|
+
}
|
|
1556
|
+
|
|
1557
|
+
$type = $meta['type'] ?? null;
|
|
1558
|
+
$row[$name] = self::normalizeValueByType($row[$name], $type);
|
|
1559
|
+
}
|
|
1560
|
+
return $row;
|
|
1561
|
+
}
|
|
1562
|
+
|
|
1563
|
+
public static function normalizeListTypes(array $rows, array $fieldsByName): array
|
|
1564
|
+
{
|
|
1565
|
+
foreach ($rows as $i => $row) {
|
|
1566
|
+
if (is_array($row)) {
|
|
1567
|
+
$rows[$i] = self::normalizeRowTypes($row, $fieldsByName);
|
|
1568
|
+
} elseif (is_object($row)) {
|
|
1569
|
+
$rows[$i] = (object) self::normalizeRowTypes((array) $row, $fieldsByName);
|
|
1570
|
+
}
|
|
1571
|
+
}
|
|
1572
|
+
return $rows;
|
|
1573
|
+
}
|
|
1574
|
+
|
|
1575
|
+
private static function normalizeValueByType(mixed $value, ?string $type): mixed
|
|
1576
|
+
{
|
|
1577
|
+
if ($value === null) return null;
|
|
1578
|
+
|
|
1579
|
+
switch ($type) {
|
|
1580
|
+
case 'Boolean':
|
|
1581
|
+
return self::toBool($value);
|
|
1582
|
+
case 'Int':
|
|
1583
|
+
return (int) $value;
|
|
1584
|
+
case 'BigInt':
|
|
1585
|
+
return (string) $value;
|
|
1586
|
+
case 'Decimal':
|
|
1587
|
+
return (string) $value;
|
|
1588
|
+
case 'DateTime':
|
|
1589
|
+
return Validator::dateTime($value);
|
|
1590
|
+
default:
|
|
1591
|
+
return $value;
|
|
1592
|
+
}
|
|
1593
|
+
}
|
|
1594
|
+
|
|
1595
|
+
public static function toBool(mixed $v): bool
|
|
1596
|
+
{
|
|
1597
|
+
$b = Validator::boolean($v);
|
|
1598
|
+
if ($b !== null) return $b;
|
|
1599
|
+
|
|
1600
|
+
if (is_numeric($v)) return ((int) $v) === 1;
|
|
1601
|
+
|
|
1602
|
+
if (is_string($v)) {
|
|
1603
|
+
$s = strtolower(trim($v));
|
|
1604
|
+
if (in_array($s, ['t', 'y', 'yes'], true)) return true;
|
|
1605
|
+
if (in_array($s, ['f', 'n', 'no'], true)) return false;
|
|
1606
|
+
}
|
|
1607
|
+
|
|
1608
|
+
return (bool) $v;
|
|
1609
|
+
}
|
|
1546
1610
|
}
|
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": "2.
|
|
4
|
+
"version": "2.3.1",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"scripts": {
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"prisma-client-php"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"chalk": "^5.
|
|
28
|
+
"chalk": "^5.6.0",
|
|
29
29
|
"crypto-js": "^4.2.0"
|
|
30
30
|
}
|
|
31
31
|
}
|