jcc-express-mvc 1.9.5 → 1.9.6
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/lib/Application/ApplicationBuilder.d.ts.map +1 -1
- package/lib/Application/ApplicationBuilder.js +2 -0
- package/lib/Auth/index.js +3 -3
- package/lib/Auth/type.d.ts +1 -1
- package/lib/Command-Line/MakeCommand.d.ts +1 -0
- package/lib/Command-Line/MakeCommand.d.ts.map +1 -1
- package/lib/Command-Line/MakeCommand.js +62 -0
- package/lib/Command-Line/NodeArtisanCommand.d.ts +2 -0
- package/lib/Command-Line/NodeArtisanCommand.d.ts.map +1 -1
- package/lib/Command-Line/NodeArtisanCommand.js +19 -0
- package/lib/Command-Line/PrismaCommand.d.ts +9 -0
- package/lib/Command-Line/PrismaCommand.d.ts.map +1 -0
- package/lib/Command-Line/PrismaCommand.js +46 -0
- package/lib/Command-Line/files/Resource.d.ts +8 -0
- package/lib/Command-Line/files/Resource.d.ts.map +1 -0
- package/lib/Command-Line/files/Resource.js +25 -0
- package/lib/Database/Database.d.ts +1 -6
- package/lib/Database/Database.d.ts.map +1 -1
- package/lib/Database/Database.js +22 -9
- package/lib/Database/DatabaseServiceProvider.d.ts.map +1 -1
- package/lib/Database/DatabaseServiceProvider.js +4 -0
- package/lib/Database/Drivers/Prisma/adapter.d.ts +14 -0
- package/lib/Database/Drivers/Prisma/adapter.d.ts.map +1 -0
- package/lib/Database/Drivers/Prisma/adapter.js +50 -0
- package/lib/Database/Drivers/Prisma/adapters/mariadb.d.ts +6 -0
- package/lib/Database/Drivers/Prisma/adapters/mariadb.d.ts.map +1 -0
- package/lib/Database/Drivers/Prisma/adapters/mariadb.js +28 -0
- package/lib/Database/Drivers/Prisma/adapters/postgres.d.ts +4 -0
- package/lib/Database/Drivers/Prisma/adapters/postgres.d.ts.map +1 -0
- package/lib/Database/Drivers/Prisma/adapters/postgres.js +30 -0
- package/lib/Database/Drivers/Prisma/adapters/sqlite.d.ts +6 -0
- package/lib/Database/Drivers/Prisma/adapters/sqlite.d.ts.map +1 -0
- package/lib/Database/Drivers/Prisma/adapters/sqlite.js +60 -0
- package/lib/Database/Drivers/Prisma/connection.d.ts +5 -0
- package/lib/Database/Drivers/Prisma/connection.d.ts.map +1 -0
- package/lib/Database/Drivers/Prisma/connection.js +14 -0
- package/lib/Database/Drivers/Prisma/readConnectionEnv.d.ts +3 -0
- package/lib/Database/Drivers/Prisma/readConnectionEnv.d.ts.map +1 -0
- package/lib/Database/Drivers/Prisma/readConnectionEnv.js +15 -0
- package/lib/Database/Drivers/Prisma/register.d.ts +7 -0
- package/lib/Database/Drivers/Prisma/register.d.ts.map +1 -0
- package/lib/Database/Drivers/Prisma/register.js +43 -0
- package/lib/Database/Drivers/Prisma/types.d.ts +18 -0
- package/lib/Database/Drivers/Prisma/types.d.ts.map +1 -0
- package/lib/Database/Drivers/Prisma/types.js +2 -0
- package/lib/Database/Drivers/PrismaDriver.d.ts +24 -0
- package/lib/Database/Drivers/PrismaDriver.d.ts.map +1 -0
- package/lib/Database/Drivers/PrismaDriver.js +41 -0
- package/lib/Database/Prisma/connection.d.ts +6 -0
- package/lib/Database/Prisma/connection.d.ts.map +1 -0
- package/lib/Database/Prisma/connection.js +19 -0
- package/lib/Database/PrismaServiceProvider.d.ts +12 -0
- package/lib/Database/PrismaServiceProvider.d.ts.map +1 -0
- package/lib/Database/PrismaServiceProvider.js +45 -0
- package/lib/Database/index.d.ts +4 -0
- package/lib/Database/index.d.ts.map +1 -1
- package/lib/Database/index.js +13 -1
- package/lib/Database/interface.d.ts +1 -1
- package/lib/Database/isPrismaOrm.d.ts +3 -0
- package/lib/Database/isPrismaOrm.d.ts.map +1 -0
- package/lib/Database/isPrismaOrm.js +7 -0
- package/lib/Database/type.d.ts +1 -1
- package/lib/Database/type.d.ts.map +1 -1
- package/lib/Global/helpers.d.ts.map +1 -1
- package/lib/Global/helpers.js +3 -0
- package/lib/Resources/JsonResources.d.ts +27 -0
- package/lib/Resources/JsonResources.d.ts.map +1 -0
- package/lib/Resources/JsonResources.js +137 -0
- package/lib/Resources/ResourceCollection.d.ts +15 -0
- package/lib/Resources/ResourceCollection.d.ts.map +1 -0
- package/lib/Resources/ResourceCollection.js +32 -0
- package/lib/Resources/helpers.d.ts +8 -0
- package/lib/Resources/helpers.d.ts.map +1 -0
- package/lib/Resources/helpers.js +38 -0
- package/lib/Resources/index.d.ts +5 -0
- package/lib/Resources/index.d.ts.map +1 -0
- package/lib/Resources/index.js +9 -0
- package/lib/Resources/types.d.ts +10 -0
- package/lib/Resources/types.d.ts.map +1 -0
- package/lib/Resources/types.js +5 -0
- package/lib/util/index.d.ts +1 -0
- package/lib/util/index.d.ts.map +1 -1
- package/lib/util/index.js +5 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApplicationBuilder.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Application/ApplicationBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"ApplicationBuilder.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Application/ApplicationBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAI/D,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAU3C,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAEzC,qBAAa,kBAAkB;IACtB,GAAG,EAAE,WAAW,CAAC;gBAEZ,GAAG,EAAE,WAAW;IAIrB,UAAU,CAAC,MAAM,EAAE,GAAG;IAKtB,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;IAMtC,WAAW,CAAC,WAAW,EAAE,WAAW,EAAE;IAOtC,aAAa,CAClB,SAAS,EAAE,KAAK,CAAC,KAAK,GAAG,EAAE,WAAW,KAAK,eAAe,CAAC;IA4B7D,OAAO,CAAC,UAAU;IAMlB,OAAO,CAAC,gBAAgB;IAIjB,WAAW;IAKX,cAAc,CAAC,oBAAoB,GAAE,cAAc,EAAO;IAY1D,MAAM;CAKd"}
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ApplicationBuilder = void 0;
|
|
4
4
|
const DatabaseServiceProvider_1 = require("../Database/DatabaseServiceProvider");
|
|
5
|
+
const PrismaServiceProvider_1 = require("../Database/PrismaServiceProvider");
|
|
5
6
|
const Middleware_1 = require("../Middleware");
|
|
6
7
|
const NodeArtisanCommand_1 = require("../Command-Line/NodeArtisanCommand");
|
|
7
8
|
const helpers_1 = require("../Global/helpers");
|
|
@@ -40,6 +41,7 @@ class ApplicationBuilder {
|
|
|
40
41
|
const chain = [
|
|
41
42
|
LogServiceProvider_1.LogServiceProvider,
|
|
42
43
|
DatabaseServiceProvider_1.DatabaseServiceProvider,
|
|
44
|
+
PrismaServiceProvider_1.PrismaServiceProvider,
|
|
43
45
|
SessionServiceProvider_1.SessionServiceProvider,
|
|
44
46
|
CacheServiceProvider_1.CacheServiceProvider,
|
|
45
47
|
...ordered,
|
package/lib/Auth/index.js
CHANGED
|
@@ -86,10 +86,10 @@ class Authentication {
|
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
static async apiAttempt(data) {
|
|
89
|
-
data = data || { field: "email",
|
|
89
|
+
data = data || { field: "email", model: "User" };
|
|
90
90
|
const input = request().input(data.field || "");
|
|
91
91
|
const password = request().input("password");
|
|
92
|
-
const { [data.
|
|
92
|
+
const { [data.model]: Model } = (0, util_1.getModel)(data.model);
|
|
93
93
|
let user = await (0, util_1.findUserForAuth)(Model, { [data.field]: input });
|
|
94
94
|
if (!user) {
|
|
95
95
|
return (0, util_1.authResponseMessages)(false, "Invalid credentials", null, null);
|
|
@@ -97,7 +97,7 @@ class Authentication {
|
|
|
97
97
|
if (!(await (0, util_1.verifyHash)(password, user?.password || ""))) {
|
|
98
98
|
return (0, util_1.authResponseMessages)(false, "Invalid credentials", null, null);
|
|
99
99
|
}
|
|
100
|
-
return (0, util_1.authResponseMessages)(true, "Login successful", user?.toJSON(), user.createToken(
|
|
100
|
+
return (0, util_1.authResponseMessages)(true, "Login successful", user?.toJSON(), user.createToken());
|
|
101
101
|
}
|
|
102
102
|
/**
|
|
103
103
|
* After the user is resolved (e.g. OAuth via Socialite), issue JWT cookies
|
package/lib/Auth/type.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export declare class MakeCommand {
|
|
|
3
3
|
createController(controllerName: string, modelName?: boolean): any;
|
|
4
4
|
createApiController(controllerName: string, modelName?: boolean): any;
|
|
5
5
|
createModel(modelName: string): any;
|
|
6
|
+
createResource(name: string): void;
|
|
6
7
|
createRequest(requestName: string): any;
|
|
7
8
|
createMigration(migrationName: string, optionalTable: string): any;
|
|
8
9
|
createSeeder(name: string): any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MakeCommand.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Command-Line/MakeCommand.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"MakeCommand.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Command-Line/MakeCommand.ts"],"names":[],"mappings":"AAoCA,qBAAa,WAAW;IACtB,OAAO,CAAC,aAAa,CAA0C;IAE/D,gBAAgB,CAAC,cAAc,EAAE,MAAM,EAAE,SAAS,UAAQ,GAAG,GAAG;IAsChE,mBAAmB,CAAC,cAAc,EAAE,MAAM,EAAE,SAAS,UAAQ,GAAG,GAAG;IAkDnE,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,GAAG;IAuBnC,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAuClC,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,GAAG;IA4BvC,eAAe,CAAC,aAAa,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,GAAG;IA4BlE,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG;IA2B/B,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,GAAG;IA8B/B,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG;IA8B3B,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,GAAG;IAmC1D,gBAAgB;IA+BhB,kBAAkB;IAyBlB,cAAc,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,GAAG;IAiCjD,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,GAAG;IAmC/C,aAAa,CAAC,IAAI,EAAE,MAAM,EAAE,eAAe,CAAC,EAAE,MAAM,GAAG,GAAG;IAmC1D,aAAa,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IA+BjC,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI;IA+BpD,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IAiC7B,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI;IA8BhC,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG;CAkCrC"}
|
|
@@ -1,4 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
2
35
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
37
|
};
|
|
@@ -28,6 +61,7 @@ const Service_1 = __importDefault(require("./files/Service"));
|
|
|
28
61
|
const Repository_1 = __importDefault(require("./files/Repository"));
|
|
29
62
|
const Dto_1 = __importDefault(require("./files/Dto"));
|
|
30
63
|
const Action_1 = __importDefault(require("./files/Action"));
|
|
64
|
+
const Resource_1 = __importStar(require("./files/Resource"));
|
|
31
65
|
const Config_1 = require("../Config/Config");
|
|
32
66
|
const rootPath = app_root_path_1.default.path;
|
|
33
67
|
/** Convert PascalCase to kebab-case (e.g. SendEmails -> send:emails) */
|
|
@@ -115,6 +149,34 @@ class MakeCommand {
|
|
|
115
149
|
return console.log(colors_1.default.red(`${modelName} model not added`)); // Log error if model addition fails
|
|
116
150
|
}
|
|
117
151
|
}
|
|
152
|
+
createResource(name) {
|
|
153
|
+
try {
|
|
154
|
+
if (!name) {
|
|
155
|
+
console.log(colors_1.default.red("Please give a name for your resource"));
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
const { className, filePath } = (0, Resource_1.parseResourceName)(name);
|
|
159
|
+
const resourcePath = path_1.default.resolve(`${rootPath}/app/Http/Resources`);
|
|
160
|
+
if (!fs_1.default.existsSync(resourcePath)) {
|
|
161
|
+
fs_1.default.mkdirSync(resourcePath, { recursive: true });
|
|
162
|
+
}
|
|
163
|
+
const targetDir = path_1.default.dirname(path_1.default.resolve(resourcePath, filePath));
|
|
164
|
+
if (!fs_1.default.existsSync(targetDir)) {
|
|
165
|
+
fs_1.default.mkdirSync(targetDir, { recursive: true });
|
|
166
|
+
}
|
|
167
|
+
const resourceFile = path_1.default.resolve(resourcePath, `${filePath}.${this.fileExtension}`);
|
|
168
|
+
if (fs_1.default.existsSync(resourceFile)) {
|
|
169
|
+
console.log(colors_1.default.yellow(`${className} already exists`));
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
fs_1.default.writeFileSync(resourceFile, (0, Resource_1.default)(className));
|
|
173
|
+
console.log(colors_1.default.green(`${className} created successfully [${resourceFile}]`));
|
|
174
|
+
}
|
|
175
|
+
catch (err) {
|
|
176
|
+
console.log(colors_1.default.red(`${name} resource not created`));
|
|
177
|
+
console.log(err.message);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
118
180
|
createRequest(requestName) {
|
|
119
181
|
try {
|
|
120
182
|
if (!requestName) {
|
|
@@ -12,6 +12,7 @@ export declare class ConsoleKernel {
|
|
|
12
12
|
private _watch;
|
|
13
13
|
private _app;
|
|
14
14
|
private _cache;
|
|
15
|
+
private _prisma;
|
|
15
16
|
private get migrate();
|
|
16
17
|
private get db();
|
|
17
18
|
private get make();
|
|
@@ -19,6 +20,7 @@ export declare class ConsoleKernel {
|
|
|
19
20
|
private get schedule();
|
|
20
21
|
private get watch();
|
|
21
22
|
private get cache();
|
|
23
|
+
private get prisma();
|
|
22
24
|
private app;
|
|
23
25
|
constructor();
|
|
24
26
|
/** Load user commands from app/Console/Command (guarded, non-blocking for missing dir) */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NodeArtisanCommand.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Command-Line/NodeArtisanCommand.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"NodeArtisanCommand.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Command-Line/NodeArtisanCommand.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AA6CpC,qBAAa,aAAa;IACxB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAiB;IACzC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAK1B;IACF,OAAO,CAAC,cAAc,CAA0B;IAChD,OAAO,CAAC,QAAQ,CAAwB;IACxC,OAAO,CAAC,GAAG,CAA0B;IACrC,OAAO,CAAC,KAAK,CAA4B;IACzC,OAAO,CAAC,MAAM,CAA6B;IAC3C,OAAO,CAAC,SAAS,CAAgC;IACjD,OAAO,CAAC,MAAM,CAA6B;IAC3C,OAAO,CAAC,IAAI,CAAc;IAC1B,OAAO,CAAC,MAAM,CAA6B;IAC3C,OAAO,CAAC,OAAO,CAA8B;IAE7C,OAAO,KAAK,OAAO,GAElB;IAED,OAAO,KAAK,EAAE,GAEb;IAED,OAAO,KAAK,IAAI,GAEf;IAED,OAAO,KAAK,KAAK,GAEhB;IAED,OAAO,KAAK,QAAQ,GAEnB;IAED,OAAO,KAAK,KAAK,GAEhB;IAED,OAAO,KAAK,KAAK,GAEhB;IAED,OAAO,KAAK,MAAM,GAEjB;IAED,OAAO,CAAC,GAAG;;IAWX,0FAA0F;IAC1F,OAAO,CAAC,kBAAkB;IA0B1B,OAAO,CAAC,aAAa;IAQrB,wFAAwF;IACxF,kFAAkF;YACpE,mBAAmB;IAQjC,OAAO,CAAC,sBAAsB;IAK9B,OAAO,CAAC,gBAAgB;YAWV,gBAAgB;IAW9B,OAAO,CAAC,SAAS;IAkDjB,OAAO,CAAC,aAAa;IAsRrB,OAAO,CAAC,QAAQ;IAgLhB,KAAK,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,UAAU,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;CA4BpD"}
|
|
@@ -27,6 +27,7 @@ const Monitor_1 = require("../Monitor");
|
|
|
27
27
|
const MonitorManager_1 = require("../Monitor/MonitorManager");
|
|
28
28
|
const CacheCommand_1 = require("./CacheCommand");
|
|
29
29
|
const PublishCommand_1 = require("./PublishCommand");
|
|
30
|
+
const PrismaCommand_1 = require("./PrismaCommand");
|
|
30
31
|
/** Parse key=value from secondArg (e.g. steps=2, class=UserSeeder) */
|
|
31
32
|
const parseOption = (secondArg, key) => {
|
|
32
33
|
if (!secondArg?.includes("="))
|
|
@@ -56,6 +57,9 @@ class ConsoleKernel {
|
|
|
56
57
|
get cache() {
|
|
57
58
|
return (this._cache ??= new CacheCommand_1.CacheCommand(this._app));
|
|
58
59
|
}
|
|
60
|
+
get prisma() {
|
|
61
|
+
return (this._prisma ??= new PrismaCommand_1.PrismaCommand());
|
|
62
|
+
}
|
|
59
63
|
app() {
|
|
60
64
|
const bootstrap = require(`${app_root_path_1.default.path}/bootstrap/app`);
|
|
61
65
|
const app = bootstrap.app;
|
|
@@ -72,6 +76,7 @@ class ConsoleKernel {
|
|
|
72
76
|
this._schedule = null;
|
|
73
77
|
this._watch = null;
|
|
74
78
|
this._cache = null;
|
|
79
|
+
this._prisma = null;
|
|
75
80
|
this._app = this.app();
|
|
76
81
|
this.loadCustomCommands();
|
|
77
82
|
}
|
|
@@ -190,6 +195,7 @@ class ConsoleKernel {
|
|
|
190
195
|
}
|
|
191
196
|
}));
|
|
192
197
|
this.defineCommand("make:request").action(this.runAction((name) => this.make.createRequest(name)));
|
|
198
|
+
this.defineCommand("make:resource").action(this.runAction((name) => this.make.createResource(name)));
|
|
193
199
|
this.defineCommand("make:seeder").action(this.runAction((name) => this.make.createSeeder(name)));
|
|
194
200
|
this.defineCommand("make:migration").action(this.runAction((name, secondArg) => {
|
|
195
201
|
const table = parseOption(secondArg, "table");
|
|
@@ -246,6 +252,12 @@ class ConsoleKernel {
|
|
|
246
252
|
: await this.db.seed();
|
|
247
253
|
}));
|
|
248
254
|
this.defineCommand("db:wipe").action(this.runAction(() => this.db.wipe()));
|
|
255
|
+
// ─── prisma ─────────────────────────────────────────────────────────
|
|
256
|
+
this.defineCommand("prisma:generate").action(this.runAction(() => this.prisma.generate()));
|
|
257
|
+
this.defineCommand("prisma:migrate").action(this.runAction((name) => this.prisma.migrate(name)));
|
|
258
|
+
this.defineCommand("prisma:deploy").action(this.runAction(() => this.prisma.deploy()));
|
|
259
|
+
this.defineCommand("prisma:push").action(this.runAction(() => this.prisma.push()));
|
|
260
|
+
this.defineCommand("prisma:studio").action(this.runAction(() => this.prisma.studio()));
|
|
249
261
|
// ─── route / queue / tinker / inertia ─────────────────────────────────
|
|
250
262
|
this.defineCommand("queue:work").action(this.runAction(async (queueName, secondArg) => {
|
|
251
263
|
const rawConcurrency = Number(parseOption(secondArg, "concurrency") ?? 1);
|
|
@@ -339,6 +351,7 @@ class ConsoleKernel {
|
|
|
339
351
|
console.log(line("make:migration <name> [table=]", "Create a new database migration file"));
|
|
340
352
|
console.log(line("make:seeder <name>", "Create a new database seeder class"));
|
|
341
353
|
console.log(line("make:request <name>", "Create a new form request validation class"));
|
|
354
|
+
console.log(line("make:resource <name>", "Create a new API resource class in app/Http/Resources"));
|
|
342
355
|
console.log(line("make:event <name>", "Create a new event class"));
|
|
343
356
|
console.log(line("make:listener <name> [event=]", "Create a new event listener class"));
|
|
344
357
|
console.log(line("make:job <name>", "Create a new queue job class"));
|
|
@@ -359,6 +372,12 @@ class ConsoleKernel {
|
|
|
359
372
|
console.log(line("migrate:rollback [steps=]", "Rollback last batch (or specified steps)"));
|
|
360
373
|
console.log(line("db:seed [class=]", "Run database seeders (or a specific seeder class)"));
|
|
361
374
|
console.log(line("db:wipe", "Drop all database tables\n"));
|
|
375
|
+
console.log(section("🧬 Prisma Commands:"));
|
|
376
|
+
console.log(line("prisma:generate", "Generate the Prisma client"));
|
|
377
|
+
console.log(line("prisma:migrate [name]", "Create and apply a Prisma migration (dev)"));
|
|
378
|
+
console.log(line("prisma:deploy", "Apply pending Prisma migrations (production)"));
|
|
379
|
+
console.log(line("prisma:push", "Push schema changes without migrations"));
|
|
380
|
+
console.log(line("prisma:studio", "Open Prisma Studio\n"));
|
|
362
381
|
console.log(section("🔄 Queue Commands:"));
|
|
363
382
|
console.log(line("queue:work", "Start processing queued jobs\n"));
|
|
364
383
|
console.log(section("🛣️ Route Commands:"));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PrismaCommand.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Command-Line/PrismaCommand.ts"],"names":[],"mappings":"AAIA,qBAAa,aAAa;IACxB,OAAO,CAAC,GAAG;IAYX,QAAQ,IAAI,IAAI;IAKhB,OAAO,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,IAAI;IAS5B,MAAM,IAAI,IAAI;IAKd,IAAI,IAAI,IAAI;IAKZ,MAAM,IAAI,IAAI;CAIf"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.PrismaCommand = void 0;
|
|
7
|
+
const node_child_process_1 = require("node:child_process");
|
|
8
|
+
const app_root_path_1 = __importDefault(require("app-root-path"));
|
|
9
|
+
const colors_1 = __importDefault(require("colors"));
|
|
10
|
+
class PrismaCommand {
|
|
11
|
+
run(args) {
|
|
12
|
+
const result = (0, node_child_process_1.spawnSync)("bun", ["--bun", "x", "prisma", ...args], {
|
|
13
|
+
cwd: app_root_path_1.default.path,
|
|
14
|
+
stdio: "inherit",
|
|
15
|
+
env: process.env,
|
|
16
|
+
});
|
|
17
|
+
if (result.status !== 0) {
|
|
18
|
+
process.exit(result.status ?? 1);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
generate() {
|
|
22
|
+
console.log(colors_1.default.cyan("Running prisma generate..."));
|
|
23
|
+
this.run(["generate"]);
|
|
24
|
+
}
|
|
25
|
+
migrate(name) {
|
|
26
|
+
const args = ["migrate", "dev"];
|
|
27
|
+
if (name) {
|
|
28
|
+
args.push("--name", name);
|
|
29
|
+
}
|
|
30
|
+
console.log(colors_1.default.cyan("Running prisma migrate dev..."));
|
|
31
|
+
this.run(args);
|
|
32
|
+
}
|
|
33
|
+
deploy() {
|
|
34
|
+
console.log(colors_1.default.cyan("Running prisma migrate deploy..."));
|
|
35
|
+
this.run(["migrate", "deploy"]);
|
|
36
|
+
}
|
|
37
|
+
push() {
|
|
38
|
+
console.log(colors_1.default.cyan("Running prisma db push..."));
|
|
39
|
+
this.run(["db", "push"]);
|
|
40
|
+
}
|
|
41
|
+
studio() {
|
|
42
|
+
console.log(colors_1.default.cyan("Starting Prisma Studio..."));
|
|
43
|
+
this.run(["studio"]);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
exports.PrismaCommand = PrismaCommand;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Resource.d.ts","sourceRoot":"","sources":["../../../../jcc-express-mvc/lib/Command-Line/files/Resource.ts"],"names":[],"mappings":"AAAA,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG;IAChD,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB,CASA;AAED,QAAA,MAAM,cAAc,GAAI,WAAW,MAAM,KAAG,MAW3C,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.parseResourceName = parseResourceName;
|
|
4
|
+
function parseResourceName(input) {
|
|
5
|
+
const normalized = input.replace(/\\/g, "/");
|
|
6
|
+
const parts = normalized.split("/");
|
|
7
|
+
const base = parts.pop().replace(/Resources?$/, "");
|
|
8
|
+
const className = `${base}Resources`;
|
|
9
|
+
const dir = parts.join("/");
|
|
10
|
+
const filePath = dir ? `${dir}/${className}` : className;
|
|
11
|
+
return { className, filePath, modelBase: base };
|
|
12
|
+
}
|
|
13
|
+
const createResource = (className) => `import { JsonResources } from "@framework/lib/Resources";
|
|
14
|
+
|
|
15
|
+
export class ${className} extends JsonResources {
|
|
16
|
+
declare id: number;
|
|
17
|
+
|
|
18
|
+
toArray(): Record<string, unknown> {
|
|
19
|
+
return {
|
|
20
|
+
id: this.id,
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
`;
|
|
25
|
+
exports.default = createResource;
|
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import { DatabaseConfig } from "./type";
|
|
2
2
|
/**
|
|
3
3
|
* Database manager that resolves the appropriate driver based on config.
|
|
4
|
-
* Drivers: knex (Jcc-eloquent), sequelize, mongoose
|
|
5
|
-
*
|
|
6
|
-
* Usage:
|
|
7
|
-
* const db = new Database(config);
|
|
8
|
-
* await db.connect();
|
|
9
|
-
* const client = db.getConnection(); // Knex | Sequelize | Mongoose
|
|
4
|
+
* Drivers: knex (Jcc-eloquent), sequelize, mongoose, prisma
|
|
10
5
|
*/
|
|
11
6
|
export declare class Database {
|
|
12
7
|
private readonly app?;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Database.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Database/Database.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"Database.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Database/Database.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,QAAQ,CAAC;AASxC;;;GAGG;AACH,qBAAa,QAAQ;IAKjB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC;IAJvB,OAAO,CAAC,MAAM,CAAiB;gBAG7B,QAAQ,CAAC,EAAE,OAAO,CAAC,cAAc,CAAC,EACjB,GAAG,CAAC,EAAE,GAAG,YAAA;IAM5B,OAAO,CAAC,iBAAiB;IAoBzB,OAAO,CAAC,aAAa;IAsBf,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAI9B,aAAa,IAAI,OAAO;IAIlB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;CAGlC"}
|
package/lib/Database/Database.js
CHANGED
|
@@ -4,15 +4,11 @@ exports.Database = void 0;
|
|
|
4
4
|
const KnexDriver_1 = require("./Drivers/KnexDriver");
|
|
5
5
|
const SequelizeDriver_1 = require("./Drivers/SequelizeDriver");
|
|
6
6
|
const MongooseDriver_1 = require("./Drivers/MongooseDriver");
|
|
7
|
+
const PrismaDriver_1 = require("./Drivers/PrismaDriver");
|
|
7
8
|
const Config_1 = require("../Config/Config");
|
|
8
9
|
/**
|
|
9
10
|
* Database manager that resolves the appropriate driver based on config.
|
|
10
|
-
* Drivers: knex (Jcc-eloquent), sequelize, mongoose
|
|
11
|
-
*
|
|
12
|
-
* Usage:
|
|
13
|
-
* const db = new Database(config);
|
|
14
|
-
* await db.connect();
|
|
15
|
-
* const client = db.getConnection(); // Knex | Sequelize | Mongoose
|
|
11
|
+
* Drivers: knex (Jcc-eloquent), sequelize, mongoose, prisma
|
|
16
12
|
*/
|
|
17
13
|
class Database {
|
|
18
14
|
constructor(dbConfig, app) {
|
|
@@ -21,18 +17,35 @@ class Database {
|
|
|
21
17
|
this.driver = this.resolveDriver(driverName, app);
|
|
22
18
|
}
|
|
23
19
|
resolveDriverName(dbConfig) {
|
|
24
|
-
if (dbConfig?.driver)
|
|
25
|
-
|
|
20
|
+
if (dbConfig?.driver) {
|
|
21
|
+
const driver = dbConfig.driver.toLowerCase();
|
|
22
|
+
if (driver === "prisma")
|
|
23
|
+
return "prisma";
|
|
24
|
+
if (driver === "mongoose" || driver === "mongodb")
|
|
25
|
+
return "mongoose";
|
|
26
|
+
if (driver === "sequelize")
|
|
27
|
+
return "sequelize";
|
|
28
|
+
return "knex";
|
|
29
|
+
}
|
|
26
30
|
const connection = Config_1.config.get("DB_CONNECTION", "mysql2").toLowerCase();
|
|
27
31
|
const orm = Config_1.config.get("DB_ORM", "jcc").toLowerCase();
|
|
32
|
+
if (orm === "prisma")
|
|
33
|
+
return "prisma";
|
|
28
34
|
if (connection === "mongodb" || orm === "mongoose")
|
|
29
35
|
return "mongoose";
|
|
30
36
|
if (connection === "sequelize" || orm === "sequelize")
|
|
31
37
|
return "sequelize";
|
|
32
|
-
return "knex";
|
|
38
|
+
return "knex";
|
|
33
39
|
}
|
|
34
40
|
resolveDriver(driverName, app) {
|
|
35
41
|
switch (driverName) {
|
|
42
|
+
case "prisma": {
|
|
43
|
+
const ServiceClass = app?.config?.database?.prisma?.service;
|
|
44
|
+
if (!ServiceClass || !app) {
|
|
45
|
+
throw new Error("Prisma driver requires the application instance and database.prisma.service in app config.");
|
|
46
|
+
}
|
|
47
|
+
return PrismaDriver_1.PrismaDriver.fromApp(app, ServiceClass);
|
|
48
|
+
}
|
|
36
49
|
case "sequelize":
|
|
37
50
|
return new SequelizeDriver_1.SequelizeDriver(app?.config?.database?.sequelize);
|
|
38
51
|
case "mongoose":
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatabaseServiceProvider.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Database/DatabaseServiceProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE9D,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"DatabaseServiceProvider.d.ts","sourceRoot":"","sources":["../../../jcc-express-mvc/lib/Database/DatabaseServiceProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAE9D,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAI/D;;;GAGG;AACH,qBAAa,uBAAwB,SAAQ,eAAe;gBAC9C,GAAG,EAAE,WAAW;IAI5B;;OAEG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAc/B;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAE3B;;OAEG;IACH,oBAAoB,IAAI,OAAO;CAehC"}
|
|
@@ -4,6 +4,7 @@ exports.DatabaseServiceProvider = void 0;
|
|
|
4
4
|
const Database_1 = require("./Database");
|
|
5
5
|
const ServiceProvider_1 = require("../Providers/ServiceProvider");
|
|
6
6
|
const Config_1 = require("../Config/Config");
|
|
7
|
+
const isPrismaOrm_1 = require("./isPrismaOrm");
|
|
7
8
|
/**
|
|
8
9
|
* Database service provider.
|
|
9
10
|
* Registers the database connection and loads models for Sequelize/Mongoose.
|
|
@@ -36,6 +37,9 @@ class DatabaseServiceProvider extends ServiceProvider_1.ServiceProvider {
|
|
|
36
37
|
* True when using Sequelize or Mongoose instead of Jcc-eloquent (Knex)
|
|
37
38
|
*/
|
|
38
39
|
externalSupportedORM() {
|
|
40
|
+
if ((0, isPrismaOrm_1.isPrismaOrm)()) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
39
43
|
const dbConnection = Config_1.config.get("DB_CONNECTION");
|
|
40
44
|
const dbOrm = Config_1.config.get("DB_ORM");
|
|
41
45
|
const supportedConnections = [
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Application } from "../../../Application/Application";
|
|
2
|
+
import type { SqlDriverAdapterFactory } from "@prisma/client/runtime/client";
|
|
3
|
+
export type PrismaAdapterName = "mariadb" | "mysql" | "mysql2" | "postgres" | "postgresql" | "pg" | "sqlite" | "better-sqlite3" | "libsql";
|
|
4
|
+
export declare function createPrismaAdapter(adapter: PrismaAdapterName): SqlDriverAdapterFactory;
|
|
5
|
+
/**
|
|
6
|
+
* Resolve a Prisma driver adapter only when explicitly configured.
|
|
7
|
+
* Returns `undefined` when the app should supply its own adapter (e.g. in `PrismaService`).
|
|
8
|
+
*
|
|
9
|
+
* Precedence:
|
|
10
|
+
* 1. `database.prisma.adapter` in app config (factory or instance)
|
|
11
|
+
* 2. `PRISMA_ADAPTER` env → built-in factory for that driver
|
|
12
|
+
*/
|
|
13
|
+
export declare function resolvePrismaAdapter(app: Application): SqlDriverAdapterFactory | undefined;
|
|
14
|
+
//# sourceMappingURL=adapter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"adapter.d.ts","sourceRoot":"","sources":["../../../../../jcc-express-mvc/lib/Database/Drivers/Prisma/adapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAC;AAEpE,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAM7E,MAAM,MAAM,iBAAiB,GACzB,SAAS,GACT,OAAO,GACP,QAAQ,GACR,UAAU,GACV,YAAY,GACZ,IAAI,GACJ,QAAQ,GACR,gBAAgB,GAChB,QAAQ,CAAC;AAEb,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,iBAAiB,GACzB,uBAAuB,CAwBzB;AAED;;;;;;;GAOG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,WAAW,GACf,uBAAuB,GAAG,SAAS,CAqBrC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createPrismaAdapter = createPrismaAdapter;
|
|
4
|
+
exports.resolvePrismaAdapter = resolvePrismaAdapter;
|
|
5
|
+
const Config_1 = require("../../../Config/Config");
|
|
6
|
+
const sqlite_1 = require("./adapters/sqlite");
|
|
7
|
+
const mariadb_1 = require("./adapters/mariadb");
|
|
8
|
+
const postgres_1 = require("./adapters/postgres");
|
|
9
|
+
function createPrismaAdapter(adapter) {
|
|
10
|
+
switch (adapter) {
|
|
11
|
+
case "mariadb":
|
|
12
|
+
case "mysql":
|
|
13
|
+
case "mysql2":
|
|
14
|
+
return (0, mariadb_1.createMariaDbAdapter)();
|
|
15
|
+
case "postgres":
|
|
16
|
+
case "postgresql":
|
|
17
|
+
case "pg":
|
|
18
|
+
return (0, postgres_1.createPostgresAdapter)();
|
|
19
|
+
case "sqlite":
|
|
20
|
+
case "better-sqlite3":
|
|
21
|
+
return (0, sqlite_1.createSqliteAdapter)();
|
|
22
|
+
case "libsql":
|
|
23
|
+
return (0, sqlite_1.createLibSqlAdapter)();
|
|
24
|
+
default:
|
|
25
|
+
throw new Error(`Unsupported PRISMA_ADAPTER "${adapter}". Use mariadb, postgres, sqlite, or libsql — or set database.prisma.adapter in app config.`);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Resolve a Prisma driver adapter only when explicitly configured.
|
|
30
|
+
* Returns `undefined` when the app should supply its own adapter (e.g. in `PrismaService`).
|
|
31
|
+
*
|
|
32
|
+
* Precedence:
|
|
33
|
+
* 1. `database.prisma.adapter` in app config (factory or instance)
|
|
34
|
+
* 2. `PRISMA_ADAPTER` env → built-in factory for that driver
|
|
35
|
+
*/
|
|
36
|
+
function resolvePrismaAdapter(app) {
|
|
37
|
+
const prismaConfig = app.config?.database?.prisma;
|
|
38
|
+
const custom = prismaConfig?.adapter;
|
|
39
|
+
if (typeof custom === "function") {
|
|
40
|
+
return custom();
|
|
41
|
+
}
|
|
42
|
+
if (custom !== undefined && custom !== null) {
|
|
43
|
+
return custom;
|
|
44
|
+
}
|
|
45
|
+
const explicit = Config_1.config.get("PRISMA_ADAPTER", "").toLowerCase();
|
|
46
|
+
if (explicit) {
|
|
47
|
+
return createPrismaAdapter(explicit);
|
|
48
|
+
}
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { SqlDriverAdapterFactory } from "@prisma/client/runtime/client";
|
|
2
|
+
/** Prisma driver adapter for MariaDB / MySQL. */
|
|
3
|
+
export declare function createMariaDbAdapter(): SqlDriverAdapterFactory;
|
|
4
|
+
/** @deprecated Use `createMariaDbAdapter()` */
|
|
5
|
+
export declare const prismaMariaDbAdapterFromEnv: typeof createMariaDbAdapter;
|
|
6
|
+
//# sourceMappingURL=mariadb.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mariadb.d.ts","sourceRoot":"","sources":["../../../../../../jcc-express-mvc/lib/Database/Drivers/Prisma/adapters/mariadb.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAiB7E,iDAAiD;AACjD,wBAAgB,oBAAoB,IAAI,uBAAuB,CAY9D;AAED,+CAA+C;AAC/C,eAAO,MAAM,2BAA2B,6BAAuB,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.prismaMariaDbAdapterFromEnv = void 0;
|
|
4
|
+
exports.createMariaDbAdapter = createMariaDbAdapter;
|
|
5
|
+
const readConnectionEnv_1 = require("../readConnectionEnv");
|
|
6
|
+
function loadMariaDbAdapter() {
|
|
7
|
+
try {
|
|
8
|
+
return require("@prisma/adapter-mariadb");
|
|
9
|
+
}
|
|
10
|
+
catch {
|
|
11
|
+
throw new Error("Install @prisma/adapter-mariadb to use the MariaDB/MySQL Prisma adapter.");
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/** Prisma driver adapter for MariaDB / MySQL. */
|
|
15
|
+
function createMariaDbAdapter() {
|
|
16
|
+
const { PrismaMariaDb } = loadMariaDbAdapter();
|
|
17
|
+
const connection = (0, readConnectionEnv_1.readPrismaConnectionEnv)();
|
|
18
|
+
return new PrismaMariaDb({
|
|
19
|
+
host: connection.host,
|
|
20
|
+
port: connection.port,
|
|
21
|
+
user: connection.user,
|
|
22
|
+
password: connection.password,
|
|
23
|
+
database: connection.database,
|
|
24
|
+
connectionLimit: connection.connectionLimit,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
/** @deprecated Use `createMariaDbAdapter()` */
|
|
28
|
+
exports.prismaMariaDbAdapterFromEnv = createMariaDbAdapter;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres.d.ts","sourceRoot":"","sources":["../../../../../../jcc-express-mvc/lib/Database/Drivers/Prisma/adapters/postgres.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAkB7E,4CAA4C;AAC5C,wBAAgB,qBAAqB,IAAI,uBAAuB,CAe/D"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createPostgresAdapter = createPostgresAdapter;
|
|
4
|
+
const readConnectionEnv_1 = require("../readConnectionEnv");
|
|
5
|
+
function loadPgAdapter() {
|
|
6
|
+
try {
|
|
7
|
+
return {
|
|
8
|
+
PrismaPg: require("@prisma/adapter-pg").PrismaPg,
|
|
9
|
+
Pool: require("pg").Pool,
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
throw new Error("Install @prisma/adapter-pg and pg to use the PostgreSQL Prisma adapter.");
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
/** Prisma driver adapter for PostgreSQL. */
|
|
17
|
+
function createPostgresAdapter() {
|
|
18
|
+
const { PrismaPg, Pool } = loadPgAdapter();
|
|
19
|
+
const connection = (0, readConnectionEnv_1.readPrismaConnectionEnv)();
|
|
20
|
+
const pool = new Pool({
|
|
21
|
+
connectionString: connection.url || undefined,
|
|
22
|
+
host: connection.url ? undefined : connection.host,
|
|
23
|
+
port: connection.url ? undefined : connection.port,
|
|
24
|
+
user: connection.url ? undefined : connection.user,
|
|
25
|
+
password: connection.url ? undefined : connection.password,
|
|
26
|
+
database: connection.url ? undefined : connection.database,
|
|
27
|
+
max: connection.connectionLimit,
|
|
28
|
+
});
|
|
29
|
+
return new PrismaPg(pool);
|
|
30
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { SqlDriverAdapterFactory } from "@prisma/client/runtime/client";
|
|
2
|
+
/** Prisma driver adapter for SQLite (better-sqlite3). */
|
|
3
|
+
export declare function createSqliteAdapter(): SqlDriverAdapterFactory;
|
|
4
|
+
/** Prisma driver adapter for LibSQL / Turso. */
|
|
5
|
+
export declare function createLibSqlAdapter(): SqlDriverAdapterFactory;
|
|
6
|
+
//# sourceMappingURL=sqlite.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sqlite.d.ts","sourceRoot":"","sources":["../../../../../../jcc-express-mvc/lib/Database/Drivers/Prisma/adapters/sqlite.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,+BAA+B,CAAC;AAkC7E,yDAAyD;AACzD,wBAAgB,mBAAmB,IAAI,uBAAuB,CAK7D;AAED,gDAAgD;AAChD,wBAAgB,mBAAmB,IAAI,uBAAuB,CA8B7D"}
|