arkos 1.4.9-beta → 1.4.10-beta
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/cjs/app.js +14 -14
- package/dist/cjs/components/arkos-policy/index.js +38 -0
- package/dist/cjs/components/arkos-policy/index.js.map +1 -0
- package/dist/cjs/{types/arkos-prisma-input.bak.js → components/arkos-policy/types.js} +1 -1
- package/dist/cjs/components/arkos-policy/types.js.map +1 -0
- package/dist/cjs/exports/auth/index.js +1 -1
- package/dist/cjs/exports/config.js +6 -0
- package/dist/cjs/exports/config.js.map +1 -0
- package/dist/cjs/exports/controllers/index.js +2 -2
- package/dist/cjs/exports/error-handler/index.js +2 -2
- package/dist/cjs/exports/index.js +4 -4
- package/dist/cjs/exports/middlewares/index.js +1 -1
- package/dist/cjs/exports/prisma/index.js +1 -1
- package/dist/cjs/exports/services/index.js +5 -5
- package/dist/cjs/exports/utils/index.js +2 -2
- package/dist/cjs/exports/validation/index.js +2 -2
- package/dist/cjs/modules/auth/auth.controller.js +7 -7
- package/dist/cjs/modules/auth/auth.router.js +10 -10
- package/dist/cjs/modules/auth/auth.service.js +12 -12
- package/dist/cjs/modules/auth/utils/auth-error-objects.js +1 -1
- package/dist/cjs/modules/auth/utils/helpers/auth.controller.helpers.js +2 -2
- package/dist/cjs/modules/auth/utils/services/auth-action.service.js +3 -3
- package/dist/cjs/modules/base/base.controller.js +9 -9
- package/dist/cjs/modules/base/base.middlewares.js +9 -9
- package/dist/cjs/modules/base/base.router.js +4 -4
- package/dist/cjs/modules/base/base.service.js +8 -8
- package/dist/cjs/modules/base/utils/error-prettifier.js +1 -1
- package/dist/cjs/modules/base/utils/helpers/base.controller.helpers.js +1 -1
- package/dist/cjs/modules/base/utils/helpers/base.middlewares.helpers.js +1 -1
- package/dist/cjs/modules/base/utils/helpers/base.router.helpers.js +9 -9
- package/dist/cjs/modules/base/utils/helpers/base.service.helpers.js +2 -2
- package/dist/cjs/modules/debugger/debugger.service.js +4 -4
- package/dist/cjs/modules/debugger/utils/loaded-components-logger.js +2 -2
- package/dist/cjs/modules/email/email.service.js +2 -2
- package/dist/cjs/modules/error-handler/error-handler.controller.js +2 -2
- package/dist/cjs/modules/error-handler/utils/error-handler.helpers.js +1 -1
- package/dist/cjs/modules/file-upload/file-upload.controller.js +9 -9
- package/dist/cjs/modules/file-upload/file-upload.controller.js.map +1 -1
- package/dist/cjs/modules/file-upload/file-upload.router.js +22 -22
- package/dist/cjs/modules/file-upload/file-upload.router.js.map +1 -1
- package/dist/cjs/modules/file-upload/file-upload.service.js +6 -6
- package/dist/cjs/modules/file-upload/utils/helpers/file-upload.helpers.js +3 -3
- package/dist/cjs/modules/swagger/swagger.router.js +8 -8
- package/dist/cjs/modules/swagger/utils/get-open-api-login-html.js +276 -0
- package/dist/cjs/modules/swagger/utils/get-open-api-login-html.js.map +1 -0
- package/dist/cjs/modules/swagger/utils/helpers/get-authentication-json-schema-paths.js +3 -3
- package/dist/cjs/modules/swagger/utils/helpers/get-file-upload-json-schema-paths.js +4 -4
- package/dist/cjs/modules/swagger/utils/helpers/get-swagger-default-configs.js +1 -1
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-class-validator-json-schemas.js +4 -4
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-prisma-json-schemas.js +2 -2
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/generate-zod-json-schemas.js +3 -3
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-main-routes-paths.js +5 -5
- package/dist/cjs/modules/swagger/utils/helpers/json-schema-generators/prisma-models/generate-prisma-model-parent-routes-paths.js +3 -3
- package/dist/cjs/modules/swagger/utils/helpers/missing-json-schemas-generator.js +2 -2
- package/dist/cjs/modules/swagger/utils/helpers/openapi-schema-converter.js +3 -3
- package/dist/cjs/modules/swagger/utils/helpers/swagger.router.helpers.js +12 -12
- package/dist/cjs/server.js +5 -5
- package/dist/cjs/types/arkos-config/utils.js +3 -0
- package/dist/cjs/types/arkos-config/utils.js.map +1 -0
- package/dist/cjs/types/arkos.js +3 -0
- package/dist/cjs/types/arkos.js.map +1 -0
- package/dist/cjs/types/index.js.map +1 -1
- package/dist/cjs/utils/arkos-router/arkos-router-openapi-manager.js +1 -1
- package/dist/cjs/utils/arkos-router/index.js +9 -9
- package/dist/cjs/utils/arkos-router/index.js.map +1 -1
- package/dist/cjs/utils/arkos-router/route-config-validator.js +2 -2
- package/dist/cjs/utils/arkos-router/types/index.js.map +1 -1
- package/dist/cjs/utils/arkos-router/utils/helpers/apply-arkos-router-proxy.js +152 -0
- package/dist/cjs/utils/arkos-router/utils/helpers/apply-arkos-router-proxy.js.map +1 -0
- package/dist/cjs/utils/arkos-router/utils/helpers/index.js +6 -6
- package/dist/cjs/utils/arkos-router/utils/helpers/upload-manager.js +8 -8
- package/dist/cjs/utils/bundler.js +163 -0
- package/dist/cjs/utils/bundler.js.map +1 -0
- package/dist/cjs/utils/cli/build.js +21 -33
- package/dist/cjs/utils/cli/build.js.map +1 -1
- package/dist/cjs/utils/cli/dev.js +6 -5
- package/dist/cjs/utils/cli/dev.js.map +1 -1
- package/dist/cjs/utils/cli/export-auth-action.js +4 -3
- package/dist/cjs/utils/cli/export-auth-action.js.map +1 -1
- package/dist/cjs/utils/cli/generate.js +8 -8
- package/dist/cjs/utils/cli/index.js +7 -7
- package/dist/cjs/utils/cli/prisma-generate.js +3 -3
- package/dist/cjs/utils/cli/remove-dir-cli.js +1 -1
- package/dist/cjs/utils/cli/start.js +5 -5
- package/dist/cjs/utils/cli/start.js.map +1 -1
- package/dist/cjs/utils/cli/utils/cli.helpers.js +3 -3
- package/dist/cjs/utils/cli/utils/runtime-cli-commander.js +5 -5
- package/dist/cjs/utils/cli/utils/template-generator/templates/auth-configs-template.js +2 -2
- package/dist/cjs/utils/cli/utils/template-generator/templates/class-validator/create-dto-template.js +2 -2
- package/dist/cjs/utils/cli/utils/template-generator/templates/class-validator/update-dto-template.js +2 -2
- package/dist/cjs/utils/cli/utils/template-generator/templates/class-validator-dto-generator.js +2 -2
- package/dist/cjs/utils/cli/utils/template-generator/templates/generate-multiple-components.js +3 -3
- package/dist/cjs/utils/cli/utils/template-generator/templates/hooks-template.js +1 -1
- package/dist/cjs/utils/cli/utils/template-generator/templates/policy-template.js +53 -0
- package/dist/cjs/utils/cli/utils/template-generator/templates/policy-template.js.map +1 -0
- package/dist/cjs/utils/cli/utils/template-generator/templates/query-options-template.js +1 -1
- package/dist/cjs/utils/cli/utils/template-generator/templates/router-template.js +1 -1
- package/dist/cjs/utils/cli/utils/template-generator/templates/service-template.js +1 -1
- package/dist/cjs/utils/cli/utils/template-generator/templates/zod/create-schema-template.js +2 -2
- package/dist/cjs/utils/cli/utils/template-generator/templates/zod/update-schema-template.js +2 -2
- package/dist/cjs/utils/cli/utils/template-generator/templates/zod-schema-generator.js +2 -2
- package/dist/cjs/utils/cli/utils/template-generators.js +11 -11
- package/dist/cjs/utils/cli/utils/watermark-stamper.js +3 -3
- package/dist/cjs/utils/dotenv.helpers.js +2 -2
- package/dist/cjs/utils/dynamic-loader.js +8 -8
- package/dist/cjs/utils/features/api.features.js +5 -5
- package/dist/cjs/utils/features/change-case.features.js +1 -1
- package/dist/cjs/utils/features/port-and-host-allocator.js +1 -1
- package/dist/cjs/utils/helpers/api.features.helpers.js +2 -2
- package/dist/cjs/utils/helpers/arkos-config.helpers.js +3 -3
- package/dist/cjs/utils/helpers/exit-error.js +12 -0
- package/dist/cjs/utils/helpers/exit-error.js.map +1 -0
- package/dist/cjs/utils/helpers/fs.helpers.js +1 -1
- package/dist/cjs/utils/helpers/fs.helpers.js.map +1 -1
- package/dist/cjs/utils/helpers/prisma.helpers.js +6 -6
- package/dist/cjs/utils/helpers/query-parser.helpers.js +1 -1
- package/dist/cjs/utils/helpers/routers.helpers.js +4 -4
- package/dist/cjs/utils/helpers/routers.helpers.js.map +1 -1
- package/dist/cjs/utils/initialize-app.js +56 -0
- package/dist/cjs/utils/initialize-app.js.map +1 -0
- package/dist/cjs/utils/prisma/prisma-json-schema-generator.js +4 -4
- package/dist/cjs/utils/prisma/prisma-schema-parser.js +2 -2
- package/dist/cjs/utils/setup-app.js +119 -0
- package/dist/cjs/utils/setup-app.js.map +1 -0
- package/dist/esm/components/arkos-policy/index.js +32 -0
- package/dist/esm/components/arkos-policy/index.js.map +1 -0
- package/dist/esm/components/arkos-policy/types.js +2 -0
- package/dist/esm/components/arkos-policy/types.js.map +1 -0
- package/dist/esm/exports/config.js +3 -0
- package/dist/esm/exports/config.js.map +1 -0
- package/dist/esm/modules/file-upload/file-upload.controller.js +2 -2
- package/dist/esm/modules/file-upload/file-upload.controller.js.map +1 -1
- package/dist/esm/modules/file-upload/file-upload.router.js +12 -12
- package/dist/esm/modules/file-upload/file-upload.router.js.map +1 -1
- package/dist/esm/modules/swagger/utils/get-open-api-login-html.js +273 -0
- package/dist/esm/modules/swagger/utils/get-open-api-login-html.js.map +1 -0
- package/dist/esm/types/arkos-config/utils.js +2 -0
- package/dist/esm/types/arkos-config/utils.js.map +1 -0
- package/dist/esm/types/arkos.js +2 -0
- package/dist/esm/types/arkos.js.map +1 -0
- package/dist/esm/types/index.js.map +1 -1
- package/dist/esm/utils/arkos-router/index.js.map +1 -1
- package/dist/esm/utils/arkos-router/types/index.js.map +1 -1
- package/dist/esm/utils/arkos-router/utils/helpers/apply-arkos-router-proxy.js +146 -0
- package/dist/esm/utils/arkos-router/utils/helpers/apply-arkos-router-proxy.js.map +1 -0
- package/dist/esm/utils/bundler.js +156 -0
- package/dist/esm/utils/bundler.js.map +1 -0
- package/dist/esm/utils/cli/build.js +15 -27
- package/dist/esm/utils/cli/build.js.map +1 -1
- package/dist/esm/utils/cli/dev.js +1 -0
- package/dist/esm/utils/cli/dev.js.map +1 -1
- package/dist/esm/utils/cli/export-auth-action.js +1 -0
- package/dist/esm/utils/cli/export-auth-action.js.map +1 -1
- package/dist/esm/utils/cli/start.js +1 -1
- package/dist/esm/utils/cli/start.js.map +1 -1
- package/dist/esm/utils/cli/utils/cli.helpers.js +1 -1
- package/dist/esm/utils/cli/utils/template-generator/templates/policy-template.js +47 -0
- package/dist/esm/utils/cli/utils/template-generator/templates/policy-template.js.map +1 -0
- package/dist/esm/utils/helpers/exit-error.js +6 -0
- package/dist/esm/utils/helpers/exit-error.js.map +1 -0
- package/dist/esm/utils/helpers/fs.helpers.js +1 -1
- package/dist/esm/utils/helpers/fs.helpers.js.map +1 -1
- package/dist/esm/utils/helpers/routers.helpers.js.map +1 -1
- package/dist/esm/utils/initialize-app.js +50 -0
- package/dist/esm/utils/initialize-app.js.map +1 -0
- package/dist/esm/utils/setup-app.js +113 -0
- package/dist/esm/utils/setup-app.js.map +1 -0
- package/dist/types/components/arkos-policy/index.d.ts +31 -0
- package/dist/types/components/arkos-policy/types.d.ts +21 -0
- package/dist/types/exports/config.d.ts +2 -0
- package/dist/types/modules/file-upload/file-upload.router.d.ts +1 -2
- package/dist/types/modules/swagger/utils/get-open-api-login-html.d.ts +1 -0
- package/dist/types/types/arkos-config/utils.d.ts +35 -0
- package/dist/types/types/arkos.d.ts +31 -0
- package/dist/types/types/index.d.ts +3 -5
- package/dist/types/utils/arkos-router/types/index.d.ts +20 -11
- package/dist/types/utils/arkos-router/utils/helpers/apply-arkos-router-proxy.d.ts +7 -0
- package/dist/types/utils/bundler.d.ts +152 -0
- package/dist/types/utils/cli/utils/template-generator/templates/policy-template.d.ts +2 -0
- package/dist/types/utils/helpers/exit-error.d.ts +1 -0
- package/dist/types/utils/helpers/routers.helpers.d.ts +3 -3
- package/dist/types/utils/initialize-app.d.ts +2 -0
- package/dist/types/utils/setup-app.d.ts +2 -0
- package/package.json +1 -1
- package/dist/cjs/types/arkos-prisma-input.bak.js.map +0 -1
- package/dist/cjs/utils/cli/utils/static-types-generator.js +0 -558
- package/dist/cjs/utils/cli/utils/static-types-generator.js.map +0 -1
- package/dist/esm/types/arkos-prisma-input.bak.js +0 -2
- package/dist/esm/types/arkos-prisma-input.bak.js.map +0 -1
- package/dist/esm/utils/cli/utils/static-types-generator.js +0 -553
- package/dist/esm/utils/cli/utils/static-types-generator.js.map +0 -1
- package/dist/types/types/arkos-prisma-input.bak.d.ts +0 -237
- package/dist/types/utils/cli/utils/static-types-generator.d.ts +0 -36
|
@@ -1,558 +0,0 @@
|
|
|
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
|
-
const promises_1 = __importDefault(require("fs/promises"));
|
|
7
|
-
const child_process_1 = require("child_process");
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const sheu_1 = __importDefault(require("../../sheu"));
|
|
10
|
-
const change_case_helpers_1 = require("../../helpers/change-case.helpers");
|
|
11
|
-
const prisma_schema_parser_1 = __importDefault(require("../../prisma/prisma-schema-parser"));
|
|
12
|
-
class StaticTypesGenerator {
|
|
13
|
-
constructor() {
|
|
14
|
-
this.packageName = "@arkosjs/types";
|
|
15
|
-
this.outputDir = path_1.default.resolve(process.cwd(), `node_modules/${this.packageName}`);
|
|
16
|
-
}
|
|
17
|
-
async generate() {
|
|
18
|
-
try {
|
|
19
|
-
await this.generatePrismaClient();
|
|
20
|
-
await this.ensureOutputDirectory();
|
|
21
|
-
await this.generateTypeDeclarations();
|
|
22
|
-
await this.generatePackageJson();
|
|
23
|
-
sheu_1.default.done("Types for @prisma/client and base service generated successfully!");
|
|
24
|
-
}
|
|
25
|
-
catch (error) {
|
|
26
|
-
sheu_1.default.error("Failed to generate static types:");
|
|
27
|
-
console.log(error);
|
|
28
|
-
throw error;
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
async generatePrismaClient() {
|
|
32
|
-
return new Promise((resolve, reject) => {
|
|
33
|
-
try {
|
|
34
|
-
(0, child_process_1.execSync)("npx prisma generate", { stdio: "inherit" });
|
|
35
|
-
resolve();
|
|
36
|
-
}
|
|
37
|
-
catch (error) {
|
|
38
|
-
reject(new Error(`Prisma generation failed: ${error}`));
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
async ensureOutputDirectory() {
|
|
43
|
-
await promises_1.default.mkdir(this.outputDir, { recursive: true });
|
|
44
|
-
}
|
|
45
|
-
generateDeclarationContent() {
|
|
46
|
-
return `import { ServiceBaseContext } from "arkos/services";
|
|
47
|
-
import { Prisma, PrismaClient } from "@prisma/client"
|
|
48
|
-
|
|
49
|
-
export interface PrismaField {
|
|
50
|
-
name: string;
|
|
51
|
-
type: string;
|
|
52
|
-
isOptional: boolean;
|
|
53
|
-
isArray: boolean;
|
|
54
|
-
foreignKeyField?: string;
|
|
55
|
-
foreignReferenceField?: string;
|
|
56
|
-
isRelation: boolean;
|
|
57
|
-
defaultValue?: any;
|
|
58
|
-
isId?: boolean;
|
|
59
|
-
isUnique?: boolean;
|
|
60
|
-
attributes: string[];
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
export declare type ModelsGetPayload<T extends Record<string, any>> = {
|
|
65
|
-
${prisma_schema_parser_1.default.models
|
|
66
|
-
.map((model) => ` "${(0, change_case_helpers_1.kebabCase)(model.name)}": {
|
|
67
|
-
Delegate: Prisma.${model.name}Delegate,
|
|
68
|
-
GetPayload: Prisma.${model.name}GetPayload<T>,
|
|
69
|
-
FindManyArgs: Prisma.${model.name}FindManyArgs,
|
|
70
|
-
FindFirstArgs: Prisma.${model.name}FindFirstArgs,
|
|
71
|
-
CreateArgs: Prisma.${model.name}CreateArgs,
|
|
72
|
-
CreateManyArgs: Prisma.${model.name}CreateManyArgs,
|
|
73
|
-
UpdateArgs: Prisma.${model.name}UpdateArgs,
|
|
74
|
-
UpdateManyArgs: Prisma.${model.name}UpdateManyArgs,
|
|
75
|
-
DeleteArgs: Prisma.${model.name}DeleteArgs,
|
|
76
|
-
DeleteManyArgs: Prisma.${model.name}DeleteManyArgs,
|
|
77
|
-
CountArgs: Prisma.${model.name}CountArgs
|
|
78
|
-
}`)
|
|
79
|
-
.join(",\n")}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
export type ExtractFilters<T> = T extends { where?: infer W; [x: string]: any } ? W : any;
|
|
83
|
-
export type ExtractQueryOptions<T, K extends keyof T = never> = Omit<T, K>;
|
|
84
|
-
export type ExtractData<T> = T extends { data: infer D; [x: string]: any } ? D : any;
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Base service class for handling CRUD operations on a specific model.
|
|
89
|
-
* This class provides standard implementation of data operations that can be extended
|
|
90
|
-
*
|
|
91
|
-
* by model-specific service classes.
|
|
92
|
-
*
|
|
93
|
-
* @class BaseService
|
|
94
|
-
*
|
|
95
|
-
* @usage
|
|
96
|
-
*
|
|
97
|
-
* **Example:** creating a simple service
|
|
98
|
-
*
|
|
99
|
-
* \`\`\`ts
|
|
100
|
-
* import { BaseService } from "arkos/services"
|
|
101
|
-
*
|
|
102
|
-
* export class UserService extends BaseService<"user"> {}
|
|
103
|
-
*
|
|
104
|
-
* const userService = new UserService("user")
|
|
105
|
-
* \`\`\`
|
|
106
|
-
*
|
|
107
|
-
* **Example:** accessing request context in hooks
|
|
108
|
-
*
|
|
109
|
-
* \`\`\`
|
|
110
|
-
*
|
|
111
|
-
* @see {@link https://www.arkosjs.com/docs/api-reference/the-base-service-class}
|
|
112
|
-
* @see {@link https://www.arkosjs.com/docs/guide/accessing-request-context-in-services}
|
|
113
|
-
*
|
|
114
|
-
*/
|
|
115
|
-
export declare class BaseService<
|
|
116
|
-
TModelName extends keyof ModelsGetPayload<any>
|
|
117
|
-
> {
|
|
118
|
-
modelName: TModelName;
|
|
119
|
-
relationFields: {
|
|
120
|
-
singular: PrismaField[] | undefined;
|
|
121
|
-
list: PrismaField[] | undefined;
|
|
122
|
-
};
|
|
123
|
-
prisma: PrismaClient;
|
|
124
|
-
|
|
125
|
-
constructor(modelName: TModelName);
|
|
126
|
-
|
|
127
|
-
/**
|
|
128
|
-
* Creates a single record in the database.
|
|
129
|
-
*
|
|
130
|
-
* @template TOptions - The query options type extending query options excluding 'data'
|
|
131
|
-
* @param {ExtractData} data - The data for creating the record
|
|
132
|
-
* @param {TOptions} [queryOptions] - Optional Prisma query options (select, include, etc.)
|
|
133
|
-
* @param {ServiceBaseContext} [context] - Optional service execution context
|
|
134
|
-
* @returns {Promise<ModelsGetPayload>} The created record
|
|
135
|
-
*
|
|
136
|
-
* @example
|
|
137
|
-
* \`\`\`ts
|
|
138
|
-
* const user = await userService.createOne({
|
|
139
|
-
* name: "John Doe",
|
|
140
|
-
* email: "john@example.com"
|
|
141
|
-
* });
|
|
142
|
-
* \`\`\`
|
|
143
|
-
*
|
|
144
|
-
* @example
|
|
145
|
-
* \`\`\`ts
|
|
146
|
-
* // With query options
|
|
147
|
-
* const user = await userService.createOne(
|
|
148
|
-
* { name: "John Doe", email: "john@example.com" },
|
|
149
|
-
* { include: { posts: true } }
|
|
150
|
-
* );
|
|
151
|
-
* \`\`\`
|
|
152
|
-
*/
|
|
153
|
-
createOne<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['CreateArgs'], 'data'>>(
|
|
154
|
-
data: ExtractData<ModelsGetPayload<any>[TModelName]['CreateArgs']>,
|
|
155
|
-
queryOptions?: TOptions,
|
|
156
|
-
context?: ServiceBaseContext
|
|
157
|
-
): Promise<ModelsGetPayload<TOptions>[TModelName]['GetPayload']>;
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Creates multiple records in the database.
|
|
161
|
-
*
|
|
162
|
-
* @template TOptions - The query options type extending query options excluding 'data'
|
|
163
|
-
* @param {ExtractData} data - Array of data objects or object with data array
|
|
164
|
-
* @param {TOptions} [queryOptions] - Optional Prisma query options
|
|
165
|
-
* @param {ServiceBaseContext} [context] - Optional service execution context
|
|
166
|
-
* @returns {Promise<Array>} Array of created records
|
|
167
|
-
*
|
|
168
|
-
* @example
|
|
169
|
-
* \`\`\`ts
|
|
170
|
-
* const users = await userService.createMany([
|
|
171
|
-
* { name: "John Doe", email: "john@example.com" },
|
|
172
|
-
* { name: "Jane Smith", email: "jane@example.com" }
|
|
173
|
-
* ]);
|
|
174
|
-
* \`\`\`
|
|
175
|
-
*/
|
|
176
|
-
createMany<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['CreateManyArgs'], 'data'>>(
|
|
177
|
-
data: ExtractData<ModelsGetPayload<any>[TModelName]['CreateManyArgs']>,
|
|
178
|
-
queryOptions?: TOptions,
|
|
179
|
-
context?: ServiceBaseContext
|
|
180
|
-
): Promise<ModelsGetPayload<TOptions>[TModelName]['GetPayload'][]>;
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* Counts records matching the specified filters.
|
|
184
|
-
*
|
|
185
|
-
* @template TOptions - The query options type extending query options excluding 'where'
|
|
186
|
-
* @param {ExtractFilters} [filters] - Optional where conditions to filter records
|
|
187
|
-
* @param {TOptions} [queryOptions] - Optional Prisma query options
|
|
188
|
-
* @param {ServiceBaseContext} [context] - Optional service execution context
|
|
189
|
-
* @returns {Promise<number>} The count of matching records
|
|
190
|
-
*
|
|
191
|
-
* @example
|
|
192
|
-
* \`\`\`ts
|
|
193
|
-
* const totalUsers = await userService.count();
|
|
194
|
-
* \`\`\`
|
|
195
|
-
*
|
|
196
|
-
* @example
|
|
197
|
-
* \`\`\`ts
|
|
198
|
-
* const activeUsers = await userService.count({
|
|
199
|
-
* status: "active"
|
|
200
|
-
* });
|
|
201
|
-
* \`\`\`
|
|
202
|
-
*/
|
|
203
|
-
count<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['CountArgs'], 'where'>>(
|
|
204
|
-
filters?: ExtractFilters<ModelsGetPayload<any>[TModelName]['CountArgs']>,
|
|
205
|
-
queryOptions?: TOptions,
|
|
206
|
-
context?: ServiceBaseContext
|
|
207
|
-
): Promise<number>;
|
|
208
|
-
|
|
209
|
-
/**
|
|
210
|
-
* Finds multiple records matching the specified filters.
|
|
211
|
-
*
|
|
212
|
-
* @template TOptions - The query options type extending query options excluding 'where'
|
|
213
|
-
* @param {ExtractFilters} [filters] - Optional where conditions to filter records
|
|
214
|
-
* @param {TOptions} [queryOptions] - Optional Prisma query options (select, include, orderBy, skip, take, etc.)
|
|
215
|
-
* @param {ServiceBaseContext} [context] - Optional service execution context
|
|
216
|
-
* @returns {Promise<Array>} Array of matching records
|
|
217
|
-
*
|
|
218
|
-
* @example
|
|
219
|
-
* \`\`\`ts
|
|
220
|
-
* const users = await userService.findMany({
|
|
221
|
-
* status: "active"
|
|
222
|
-
* });
|
|
223
|
-
* \`\`\`
|
|
224
|
-
*
|
|
225
|
-
* @example
|
|
226
|
-
* \`\`\`ts
|
|
227
|
-
* // With pagination and ordering
|
|
228
|
-
* const users = await userService.findMany(
|
|
229
|
-
* { status: "active" },
|
|
230
|
-
* { orderBy: { createdAt: "desc" }, take: 10, skip: 0 }
|
|
231
|
-
* );
|
|
232
|
-
* \`\`\`
|
|
233
|
-
*/
|
|
234
|
-
findMany<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['FindManyArgs'], 'where'>>(
|
|
235
|
-
filters?: ExtractFilters<ModelsGetPayload<any>[TModelName]['FindManyArgs']>,
|
|
236
|
-
queryOptions?: TOptions,
|
|
237
|
-
context?: ServiceBaseContext
|
|
238
|
-
): Promise<ModelsGetPayload<TOptions>[TModelName]['GetPayload'][]>;
|
|
239
|
-
|
|
240
|
-
/**
|
|
241
|
-
* Finds a single record by its ID.
|
|
242
|
-
*
|
|
243
|
-
* @template TOptions - The query options type extending query options excluding 'where'
|
|
244
|
-
* @param {string | number} id - The unique identifier of the record
|
|
245
|
-
* @param {TOptions} [queryOptions] - Optional Prisma query options (select, include, etc.)
|
|
246
|
-
* @param {ServiceBaseContext} [context] - Optional service execution context
|
|
247
|
-
* @returns {Promise<ModelsGetPayload | null>} The matching record or null if not found
|
|
248
|
-
*
|
|
249
|
-
* @example
|
|
250
|
-
* \`\`\`ts
|
|
251
|
-
* const user = await userService.findById("user-123");
|
|
252
|
-
* \`\`\`
|
|
253
|
-
*
|
|
254
|
-
* @example
|
|
255
|
-
* \`\`\`ts
|
|
256
|
-
* // With relations
|
|
257
|
-
* const user = await userService.findById(
|
|
258
|
-
* "user-123",
|
|
259
|
-
* { include: { posts: true, profile: true } }
|
|
260
|
-
* );
|
|
261
|
-
* \`\`\`
|
|
262
|
-
*/
|
|
263
|
-
findById<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['FindFirstArgs'], 'where'>>(
|
|
264
|
-
id: string | number,
|
|
265
|
-
queryOptions?: TOptions,
|
|
266
|
-
context?: ServiceBaseContext
|
|
267
|
-
): Promise<ModelsGetPayload<TOptions>[TModelName]['GetPayload'] | null>;
|
|
268
|
-
|
|
269
|
-
/**
|
|
270
|
-
* Updates a single record matching the specified id.
|
|
271
|
-
*
|
|
272
|
-
* @template TOptions - The query options type extending query options excluding 'where' and 'data'
|
|
273
|
-
* @param {string | number} id - The unique identifier of the record
|
|
274
|
-
* @param {ExtractData} data - The data to update
|
|
275
|
-
* @param {TOptions} [queryOptions] - Optional Prisma query options (select, include, etc.)
|
|
276
|
-
* @param {ServiceBaseContext} [context] - Optional service execution context
|
|
277
|
-
* @returns {Promise<ModelsGetPayload>} The updated record
|
|
278
|
-
*
|
|
279
|
-
* @example
|
|
280
|
-
* \`\`\`ts
|
|
281
|
-
* const updatedUser = await userService.updateById(
|
|
282
|
-
* "user-123",
|
|
283
|
-
* { name: "John Updated" }
|
|
284
|
-
* );
|
|
285
|
-
* \`\`\`
|
|
286
|
-
*
|
|
287
|
-
* @example
|
|
288
|
-
* \`\`\`ts
|
|
289
|
-
* // With relations
|
|
290
|
-
* const updatedUser = await userService.updateById(
|
|
291
|
-
* "user-123",
|
|
292
|
-
* { name: "John Updated" },
|
|
293
|
-
* { include: { posts: true } }
|
|
294
|
-
* );
|
|
295
|
-
* \`\`\`
|
|
296
|
-
*/
|
|
297
|
-
updateById<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['UpdateArgs'], 'where' | 'data'>>(
|
|
298
|
-
id: string | number,
|
|
299
|
-
data: ExtractData<ModelsGetPayload<any>[TModelName]['UpdateArgs']>,
|
|
300
|
-
queryOptions?: TOptions,
|
|
301
|
-
context?: ServiceBaseContext
|
|
302
|
-
): Promise<ModelsGetPayload<TOptions>[TModelName]['GetPayload']>;
|
|
303
|
-
|
|
304
|
-
/**
|
|
305
|
-
* Deletes a single record matching the specified id.
|
|
306
|
-
*
|
|
307
|
-
* @param {string | number} id - The unique identifier of the record
|
|
308
|
-
* @param {ServiceBaseContext} [context] - Optional service execution context
|
|
309
|
-
* @returns {Promise<ModelsGetPayload>} The deleted record
|
|
310
|
-
*
|
|
311
|
-
* @example
|
|
312
|
-
* \`\`\`ts
|
|
313
|
-
* const deletedUser = await userService.deleteById("user-123");
|
|
314
|
-
* \`\`\`
|
|
315
|
-
*/
|
|
316
|
-
deleteById(
|
|
317
|
-
id: string | number,
|
|
318
|
-
context?: ServiceBaseContext
|
|
319
|
-
): Promise<ModelsGetPayload<any>[TModelName]['GetPayload']>;
|
|
320
|
-
|
|
321
|
-
/**
|
|
322
|
-
* Finds the first record matching the specified filters.
|
|
323
|
-
*
|
|
324
|
-
* @template TOptions - The query options type extending query options excluding 'where'
|
|
325
|
-
* @param {ExtractFilters} filters - Where conditions to filter records
|
|
326
|
-
* @param {TOptions} [queryOptions] - Optional Prisma query options (select, include, orderBy, etc.)
|
|
327
|
-
* @param {ServiceBaseContext} [context] - Optional service execution context
|
|
328
|
-
* @returns {Promise<ModelsGetPayload | null>} The first matching record or null if not found
|
|
329
|
-
*
|
|
330
|
-
* @example
|
|
331
|
-
* \`\`\`ts
|
|
332
|
-
* const user = await userService.findOne({
|
|
333
|
-
* email: "john@example.com"
|
|
334
|
-
* });
|
|
335
|
-
* \`\`\`
|
|
336
|
-
*
|
|
337
|
-
* @example
|
|
338
|
-
* \`\`\`ts
|
|
339
|
-
* // With relations and ordering
|
|
340
|
-
* const latestPost = await postService.findOne(
|
|
341
|
-
* { published: true },
|
|
342
|
-
* { include: { author: true }, orderBy: { createdAt: "desc" } }
|
|
343
|
-
* );
|
|
344
|
-
* \`\`\`
|
|
345
|
-
*/
|
|
346
|
-
findOne<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['FindFirstArgs'], 'where'>>(
|
|
347
|
-
filters: ExtractFilters<ModelsGetPayload<any>[TModelName]['FindManyArgs']>,
|
|
348
|
-
queryOptions?: TOptions,
|
|
349
|
-
context?: ServiceBaseContext
|
|
350
|
-
): Promise<ModelsGetPayload<TOptions>[TModelName]['GetPayload'] | null>;
|
|
351
|
-
|
|
352
|
-
/**
|
|
353
|
-
* Updates a single record matching the specified filters.
|
|
354
|
-
*
|
|
355
|
-
* @template TOptions - The query options type extending query options excluding 'where' and 'data'
|
|
356
|
-
* @param {ExtractFilters} filters - Where conditions to identify the record to update
|
|
357
|
-
* @param {ExtractData} data - The data to update
|
|
358
|
-
* @param {TOptions} [queryOptions] - Optional Prisma query options (select, include, etc.)
|
|
359
|
-
* @param {ServiceBaseContext} [context] - Optional service execution context
|
|
360
|
-
* @returns {Promise<ModelsGetPayload>} The updated record
|
|
361
|
-
*
|
|
362
|
-
* @example
|
|
363
|
-
* \`\`\`ts
|
|
364
|
-
* const updatedUser = await userService.updateOne(
|
|
365
|
-
* { id: "user-123" },
|
|
366
|
-
* { name: "John Updated" }
|
|
367
|
-
* );
|
|
368
|
-
* \`\`\`
|
|
369
|
-
*
|
|
370
|
-
* @example
|
|
371
|
-
* \`\`\`ts
|
|
372
|
-
* // With relations
|
|
373
|
-
* const updatedUser = await userService.updateOne(
|
|
374
|
-
* { id: "user-123" },
|
|
375
|
-
* { name: "John Updated" },
|
|
376
|
-
* { include: { posts: true } }
|
|
377
|
-
* );
|
|
378
|
-
* \`\`\`
|
|
379
|
-
*/
|
|
380
|
-
updateOne<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['UpdateArgs'], 'where' | 'data'>>(
|
|
381
|
-
filters: ExtractFilters<ModelsGetPayload<any>[TModelName]['UpdateArgs']>,
|
|
382
|
-
data: ExtractData<ModelsGetPayload<any>[TModelName]['UpdateArgs']>,
|
|
383
|
-
queryOptions?: TOptions,
|
|
384
|
-
context?: ServiceBaseContext
|
|
385
|
-
): Promise<ModelsGetPayload<TOptions>[TModelName]['GetPayload']>;
|
|
386
|
-
|
|
387
|
-
/**
|
|
388
|
-
* Updates multiple records matching the specified filters.
|
|
389
|
-
*
|
|
390
|
-
* @template TOptions - The query options type extending query options excluding 'where' and 'data'
|
|
391
|
-
* @param {ExtractFilters} filters - Where conditions to identify records to update
|
|
392
|
-
* @param {ExtractData} data - The data to update
|
|
393
|
-
* @param {TOptions} [queryOptions] - Optional Prisma query options
|
|
394
|
-
* @param {ServiceBaseContext} [context] - Optional service execution context
|
|
395
|
-
* @returns {Promise<{ count: number }>} Object containing count of updated records
|
|
396
|
-
*
|
|
397
|
-
* @example
|
|
398
|
-
* \`\`\`ts
|
|
399
|
-
* const result = await userService.updateMany(
|
|
400
|
-
* { status: "pending" },
|
|
401
|
-
* { status: "active" }
|
|
402
|
-
* );
|
|
403
|
-
* console.log(result.count); // Number of updated records
|
|
404
|
-
* \`\`\`
|
|
405
|
-
*/
|
|
406
|
-
updateMany<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['UpdateManyArgs'], 'where' | 'data'>>(
|
|
407
|
-
filters: ExtractFilters<ModelsGetPayload<any>[TModelName]['UpdateManyArgs']>,
|
|
408
|
-
data: ExtractData<ModelsGetPayload<any>[TModelName]['UpdateManyArgs']>,
|
|
409
|
-
queryOptions?: TOptions,
|
|
410
|
-
context?: ServiceBaseContext
|
|
411
|
-
): Promise<{ count: number }>;
|
|
412
|
-
|
|
413
|
-
/**
|
|
414
|
-
* Deletes a single record matching the specified filters.
|
|
415
|
-
*
|
|
416
|
-
* @template TOptions - The query options type extending query options excluding 'where'
|
|
417
|
-
* @param {ExtractFilters} filters - Where conditions to identify the record to delete
|
|
418
|
-
* @param {TOptions} [queryOptions] - Optional Prisma query options
|
|
419
|
-
* @param {ServiceBaseContext} [context] - Optional service execution context
|
|
420
|
-
* @returns {Promise<ModelsGetPayload>} The deleted record
|
|
421
|
-
*
|
|
422
|
-
* @example
|
|
423
|
-
* \`\`\`ts
|
|
424
|
-
* const deletedUser = await userService.deleteOne({
|
|
425
|
-
* id: "user-123"
|
|
426
|
-
* });
|
|
427
|
-
* \`\`\`
|
|
428
|
-
*/
|
|
429
|
-
deleteOne<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['DeleteArgs'], 'where'>>(
|
|
430
|
-
filters: ExtractFilters<ModelsGetPayload<any>[TModelName]['DeleteArgs']>,
|
|
431
|
-
queryOptions?: TOptions,
|
|
432
|
-
context?: ServiceBaseContext
|
|
433
|
-
): Promise<ModelsGetPayload<TOptions>[TModelName]['GetPayload']>;
|
|
434
|
-
|
|
435
|
-
/**
|
|
436
|
-
* Deletes multiple records matching the specified filters.
|
|
437
|
-
*
|
|
438
|
-
* @template TOptions - The query options type extending query options excluding 'where'
|
|
439
|
-
* @param {ExtractFilters} filters - Where conditions to identify records to delete
|
|
440
|
-
* @param {TOptions} [queryOptions] - Optional Prisma query options
|
|
441
|
-
* @param {ServiceBaseContext} [context] - Optional service execution context
|
|
442
|
-
* @returns {Promise<{ count: number }>} Object containing count of deleted records
|
|
443
|
-
*
|
|
444
|
-
* @example
|
|
445
|
-
* \`\`\`ts
|
|
446
|
-
* const result = await userService.deleteMany({
|
|
447
|
-
* status: "inactive"
|
|
448
|
-
* });
|
|
449
|
-
* console.log(result.count); // Number of deleted records
|
|
450
|
-
* \`\`\`
|
|
451
|
-
*/
|
|
452
|
-
deleteMany<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['DeleteManyArgs'], 'where'>>(
|
|
453
|
-
filters: ExtractFilters<ModelsGetPayload<any>[TModelName]['DeleteManyArgs']>,
|
|
454
|
-
queryOptions?: TOptions,
|
|
455
|
-
context?: ServiceBaseContext
|
|
456
|
-
): Promise<{ count: number }>;
|
|
457
|
-
|
|
458
|
-
/**
|
|
459
|
-
* Performs multiple update operations in a single transaction.
|
|
460
|
-
* Each item in the data array must contain filter criteria to identify the record to update.
|
|
461
|
-
*
|
|
462
|
-
* @template TOptions - The query options type extending query options excluding 'where' and 'data'
|
|
463
|
-
* @param {Array<UpdateOneData>} dataArray - Array of update objects, each containing filter criteria and data
|
|
464
|
-
* @param {TOptions} [queryOptions] - Optional Prisma query options applied to all updates
|
|
465
|
-
* @param {ServiceBaseContext} [context] - Optional service execution context
|
|
466
|
-
* @returns {Promise<Array<ModelsGetPayload>>} Array of updated records
|
|
467
|
-
*
|
|
468
|
-
* @example
|
|
469
|
-
* \`\`\`ts
|
|
470
|
-
* const results = await userService.batchUpdate([
|
|
471
|
-
* { where: { id: "user-1" }, data: { status: "active" } },
|
|
472
|
-
* { where: { id: "user-2" }, data: { status: "inactive" } }
|
|
473
|
-
* ]);
|
|
474
|
-
* \`\`\`
|
|
475
|
-
*
|
|
476
|
-
* @example
|
|
477
|
-
* \`\`\`ts
|
|
478
|
-
* // With query options for all updates
|
|
479
|
-
* const results = await userService.batchUpdate(
|
|
480
|
-
* [
|
|
481
|
-
* { where: { id: "user-1" }, data: { status: "active" } },
|
|
482
|
-
* { where: { id: "user-2" }, data: { status: "inactive" } }
|
|
483
|
-
* ],
|
|
484
|
-
* { include: { posts: true } }
|
|
485
|
-
* );
|
|
486
|
-
* \`\`\`
|
|
487
|
-
*/
|
|
488
|
-
batchUpdate<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['UpdateArgs'], 'where' | 'data'>>(
|
|
489
|
-
dataArray: Array<{
|
|
490
|
-
where: ExtractFilters<ModelsGetPayload<any>[TModelName]['UpdateArgs']>,
|
|
491
|
-
data: ExtractData<ModelsGetPayload<any>[TModelName]['UpdateArgs']>
|
|
492
|
-
}>,
|
|
493
|
-
queryOptions?: TOptions,
|
|
494
|
-
context?: ServiceBaseContext
|
|
495
|
-
): Promise<Array<ModelsGetPayload<TOptions>[TModelName]['GetPayload']>>;
|
|
496
|
-
|
|
497
|
-
/**
|
|
498
|
-
* Performs multiple delete operations in a single transaction.
|
|
499
|
-
*
|
|
500
|
-
* @template TOptions - The query options type extending query options excluding 'where'
|
|
501
|
-
* @param {Array<ExtractFilters>} batchFilters - Array of where conditions, each identifying a record to delete
|
|
502
|
-
* @param {TOptions} [queryOptions] - Optional Prisma query options applied to all deletes
|
|
503
|
-
* @param {ServiceBaseContext} [context] - Optional service execution context
|
|
504
|
-
* @returns {Promise<Array<ModelsGetPayload>>} Array of deleted records
|
|
505
|
-
*
|
|
506
|
-
* @example
|
|
507
|
-
* \`\`\`ts
|
|
508
|
-
* const deletedUsers = await userService.batchDelete([
|
|
509
|
-
* { id: "user-1" },
|
|
510
|
-
* { id: "user-2" },
|
|
511
|
-
* { id: "user-3" }
|
|
512
|
-
* ]);
|
|
513
|
-
* \`\`\`
|
|
514
|
-
*
|
|
515
|
-
* @example
|
|
516
|
-
* \`\`\`ts
|
|
517
|
-
* // With query options
|
|
518
|
-
* const deletedUsers = await userService.batchDelete(
|
|
519
|
-
* [
|
|
520
|
-
* { id: "user-1" },
|
|
521
|
-
* { id: "user-2" }
|
|
522
|
-
* ],
|
|
523
|
-
* { include: { posts: true } }
|
|
524
|
-
* );
|
|
525
|
-
* \`\`\`
|
|
526
|
-
*/
|
|
527
|
-
batchDelete<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['DeleteArgs'], 'where'>>(
|
|
528
|
-
batchFilters: Array<ExtractFilters<ModelsGetPayload<any>[TModelName]['DeleteArgs']>>,
|
|
529
|
-
queryOptions?: TOptions,
|
|
530
|
-
context?: ServiceBaseContext
|
|
531
|
-
): Promise<Array<ModelsGetPayload<TOptions>[TModelName]['GetPayload']>>;
|
|
532
|
-
}
|
|
533
|
-
`;
|
|
534
|
-
}
|
|
535
|
-
async generateTypeDeclarations() {
|
|
536
|
-
const content = this.generateDeclarationContent();
|
|
537
|
-
const filePath = path_1.default.join(this.outputDir, "base.service.d.ts");
|
|
538
|
-
await promises_1.default.writeFile(filePath, content, { encoding: "utf8" });
|
|
539
|
-
}
|
|
540
|
-
generatePackageJsonContent() {
|
|
541
|
-
return JSON.stringify({
|
|
542
|
-
name: this.packageName,
|
|
543
|
-
version: "1.0.0",
|
|
544
|
-
types: "./base.service.d.ts",
|
|
545
|
-
exports: {
|
|
546
|
-
"./base.service": "./base.service.d.ts",
|
|
547
|
-
},
|
|
548
|
-
}, null, 2);
|
|
549
|
-
}
|
|
550
|
-
async generatePackageJson() {
|
|
551
|
-
const content = this.generatePackageJsonContent();
|
|
552
|
-
const pkgPath = path_1.default.join(this.outputDir, "package.json");
|
|
553
|
-
await promises_1.default.writeFile(pkgPath, content, { encoding: "utf8" });
|
|
554
|
-
}
|
|
555
|
-
}
|
|
556
|
-
const staticTypesGenerator = new StaticTypesGenerator();
|
|
557
|
-
exports.default = staticTypesGenerator;
|
|
558
|
-
//# sourceMappingURL=static-types-generator.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"static-types-generator.js","sourceRoot":"","sources":["../../../../../src/utils/cli/utils/static-types-generator.ts"],"names":[],"mappings":";;;;;AAAA,2DAA6B;AAC7B,iDAAyC;AACzC,gDAAwB;AACxB,sDAA8B;AAC9B,2EAA8D;AAC9D,6FAAmE;AAEnE,MAAM,oBAAoB;IAIxB;QAFiB,gBAAW,GAAG,gBAAgB,CAAC;QAG9C,IAAI,CAAC,SAAS,GAAG,cAAI,CAAC,OAAO,CAC3B,OAAO,CAAC,GAAG,EAAE,EACb,gBAAgB,IAAI,CAAC,WAAW,EAAE,CACnC,CAAC;IACJ,CAAC;IAMD,KAAK,CAAC,QAAQ;QACZ,IAAI,CAAC;YAEH,MAAM,IAAI,CAAC,oBAAoB,EAAE,CAAC;YAGlC,MAAM,IAAI,CAAC,qBAAqB,EAAE,CAAC;YAGnC,MAAM,IAAI,CAAC,wBAAwB,EAAE,CAAC;YAGtC,MAAM,IAAI,CAAC,mBAAmB,EAAE,CAAC;YAEjC,cAAI,CAAC,IAAI,CACP,mEAAmE,CACpE,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,cAAI,CAAC,KAAK,CAAC,kCAAkC,CAAC,CAAC;YAC/C,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YACnB,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;IAKO,KAAK,CAAC,oBAAoB;QAChC,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,IAAI,CAAC;gBACH,IAAA,wBAAQ,EAAC,qBAAqB,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;gBACtD,OAAO,EAAE,CAAC;YACZ,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBACf,MAAM,CAAC,IAAI,KAAK,CAAC,6BAA6B,KAAK,EAAE,CAAC,CAAC,CAAC;YAC1D,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC;IAKO,KAAK,CAAC,qBAAqB;QACjC,MAAM,kBAAE,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;IACtD,CAAC;IAKO,0BAA0B;QAChC,OAAO;;;;;;;;;;;;;;;;;;;EAmBT,8BAAkB,CAAC,MAAM;aACxB,GAAG,CACF,CAAC,KAAK,EAAE,EAAE,CACR,MAAM,IAAA,+BAAS,EAAC,KAAK,CAAC,IAAI,CAAC;yBACR,KAAK,CAAC,IAAI;2BACR,KAAK,CAAC,IAAI;6BACR,KAAK,CAAC,IAAI;8BACT,KAAK,CAAC,IAAI;2BACb,KAAK,CAAC,IAAI;+BACN,KAAK,CAAC,IAAI;2BACd,KAAK,CAAC,IAAI;+BACN,KAAK,CAAC,IAAI;2BACd,KAAK,CAAC,IAAI;+BACN,KAAK,CAAC,IAAI;0BACf,KAAK,CAAC,IAAI;IAChC,CACD;aACA,IAAI,CAAC,KAAK,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAscb,CAAC;IACA,CAAC;IAKO,KAAK,CAAC,wBAAwB;QACpC,MAAM,OAAO,GAAG,IAAI,CAAC,0BAA0B,EAAE,CAAC;QAClD,MAAM,QAAQ,GAAG,cAAI,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,mBAAmB,CAAC,CAAC;QAChE,MAAM,kBAAE,CAAC,SAAS,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;IAC9D,CAAC;IAKO,0BAA0B;QAChC,OAAO,IAAI,CAAC,SAAS,CACnB;YACE,IAAI,EAAE,IAAI,CAAC,WAAW;YACtB,OAAO,EAAE,OAAO;YAChB,KAAK,EAAE,qBAAqB;YAC5B,OAAO,EAAE;gBACP,gBAAgB,EAAE,qBAAqB;aACxC;SACF,EACD,IAAI,EACJ,CAAC,CACF,CAAC;IACJ,CAAC;IAKO,KAAK,CAAC,mBAAmB;QAC/B,MAAM,OAAO,GAAG,IAAI,CAAC,0BAA0B,EAAE,CAAC;QAClD,MAAM,OAAO,GAAG,cAAI,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;QAC1D,MAAM,kBAAE,CAAC,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;IAC7D,CAAC;CACF;AAED,MAAM,oBAAoB,GAAG,IAAI,oBAAoB,EAAE,CAAC;AACxD,kBAAe,oBAAoB,CAAC","sourcesContent":["import fs from \"fs/promises\";\nimport { execSync } from \"child_process\";\nimport path from \"path\";\nimport sheu from \"../../sheu\";\nimport { kebabCase } from \"../../helpers/change-case.helpers\";\nimport prismaSchemaParser from \"../../prisma/prisma-schema-parser\";\n\nclass StaticTypesGenerator {\n private readonly outputDir: string;\n private readonly packageName = \"@arkosjs/types\";\n\n constructor() {\n this.outputDir = path.resolve(\n process.cwd(),\n `node_modules/${this.packageName}`\n );\n }\n\n /**\n * Generates all static types including Prisma types and package metadata\n * @returns Promise<void>\n */\n async generate(): Promise<void> {\n try {\n // Step 1: Generate Prisma client types\n await this.generatePrismaClient();\n\n // Step 2: Ensure output directory exists\n await this.ensureOutputDirectory();\n\n // Step 3: Generate TypeScript declaration file\n await this.generateTypeDeclarations();\n\n // Step 4: Generate package.json\n await this.generatePackageJson();\n\n sheu.done(\n \"Types for @prisma/client and base service generated successfully!\"\n );\n } catch (error) {\n sheu.error(\"Failed to generate static types:\");\n console.log(error);\n throw error;\n }\n }\n\n /**\n * Executes Prisma client generation\n */\n private async generatePrismaClient(): Promise<void> {\n return new Promise((resolve, reject) => {\n try {\n execSync(\"npx prisma generate\", { stdio: \"inherit\" });\n resolve();\n } catch (error) {\n reject(new Error(`Prisma generation failed: ${error}`));\n }\n });\n }\n\n /**\n * Ensures the output directory exists\n */\n private async ensureOutputDirectory(): Promise<void> {\n await fs.mkdir(this.outputDir, { recursive: true });\n }\n\n /**\n * Generates the TypeScript declaration file content\n */\n private generateDeclarationContent(): string {\n return `import { ServiceBaseContext } from \"arkos/services\";\nimport { Prisma, PrismaClient } from \"@prisma/client\"\n\nexport interface PrismaField {\n name: string;\n type: string;\n isOptional: boolean;\n isArray: boolean;\n foreignKeyField?: string;\n foreignReferenceField?: string;\n isRelation: boolean;\n defaultValue?: any;\n isId?: boolean;\n isUnique?: boolean;\n attributes: string[];\n}\n\n\nexport declare type ModelsGetPayload<T extends Record<string, any>> = {\n${prismaSchemaParser.models\n .map(\n (model) =>\n ` \"${kebabCase(model.name)}\": {\n Delegate: Prisma.${model.name}Delegate,\n GetPayload: Prisma.${model.name}GetPayload<T>,\n FindManyArgs: Prisma.${model.name}FindManyArgs,\n FindFirstArgs: Prisma.${model.name}FindFirstArgs,\n CreateArgs: Prisma.${model.name}CreateArgs,\n CreateManyArgs: Prisma.${model.name}CreateManyArgs,\n UpdateArgs: Prisma.${model.name}UpdateArgs,\n UpdateManyArgs: Prisma.${model.name}UpdateManyArgs,\n DeleteArgs: Prisma.${model.name}DeleteArgs,\n DeleteManyArgs: Prisma.${model.name}DeleteManyArgs,\n CountArgs: Prisma.${model.name}CountArgs\n }`\n )\n .join(\",\\n\")}\n}\n\nexport type ExtractFilters<T> = T extends { where?: infer W; [x: string]: any } ? W : any;\nexport type ExtractQueryOptions<T, K extends keyof T = never> = Omit<T, K>;\nexport type ExtractData<T> = T extends { data: infer D; [x: string]: any } ? D : any;\n\n\n/**\n * Base service class for handling CRUD operations on a specific model.\n * This class provides standard implementation of data operations that can be extended\n *\n * by model-specific service classes.\n *\n * @class BaseService\n *\n * @usage\n *\n * **Example:** creating a simple service\n *\n * \\`\\`\\`ts\n * import { BaseService } from \"arkos/services\"\n *\n * export class UserService extends BaseService<\"user\"> {}\n *\n * const userService = new UserService(\"user\")\n * \\`\\`\\`\n *\n * **Example:** accessing request context in hooks\n *\n * \\`\\`\\`\n *\n * @see {@link https://www.arkosjs.com/docs/api-reference/the-base-service-class}\n * @see {@link https://www.arkosjs.com/docs/guide/accessing-request-context-in-services}\n *\n */\nexport declare class BaseService<\n TModelName extends keyof ModelsGetPayload<any>\n> {\n modelName: TModelName;\n relationFields: {\n singular: PrismaField[] | undefined;\n list: PrismaField[] | undefined;\n };\n prisma: PrismaClient;\n \n constructor(modelName: TModelName);\n \n /**\n * Creates a single record in the database.\n *\n * @template TOptions - The query options type extending query options excluding 'data'\n * @param {ExtractData} data - The data for creating the record\n * @param {TOptions} [queryOptions] - Optional Prisma query options (select, include, etc.)\n * @param {ServiceBaseContext} [context] - Optional service execution context\n * @returns {Promise<ModelsGetPayload>} The created record\n *\n * @example\n * \\`\\`\\`ts\n * const user = await userService.createOne({\n * name: \"John Doe\",\n * email: \"john@example.com\"\n * });\n * \\`\\`\\`\n *\n * @example\n * \\`\\`\\`ts\n * // With query options\n * const user = await userService.createOne(\n * { name: \"John Doe\", email: \"john@example.com\" },\n * { include: { posts: true } }\n * );\n * \\`\\`\\`\n */\n createOne<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['CreateArgs'], 'data'>>(\n data: ExtractData<ModelsGetPayload<any>[TModelName]['CreateArgs']>, \n queryOptions?: TOptions, \n context?: ServiceBaseContext\n ): Promise<ModelsGetPayload<TOptions>[TModelName]['GetPayload']>;\n\n /**\n * Creates multiple records in the database.\n *\n * @template TOptions - The query options type extending query options excluding 'data'\n * @param {ExtractData} data - Array of data objects or object with data array\n * @param {TOptions} [queryOptions] - Optional Prisma query options\n * @param {ServiceBaseContext} [context] - Optional service execution context\n * @returns {Promise<Array>} Array of created records\n *\n * @example\n * \\`\\`\\`ts\n * const users = await userService.createMany([\n * { name: \"John Doe\", email: \"john@example.com\" },\n * { name: \"Jane Smith\", email: \"jane@example.com\" }\n * ]);\n * \\`\\`\\`\n */\n createMany<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['CreateManyArgs'], 'data'>>(\n data: ExtractData<ModelsGetPayload<any>[TModelName]['CreateManyArgs']>, \n queryOptions?: TOptions, \n context?: ServiceBaseContext\n ): Promise<ModelsGetPayload<TOptions>[TModelName]['GetPayload'][]>;\n\n /**\n * Counts records matching the specified filters.\n *\n * @template TOptions - The query options type extending query options excluding 'where'\n * @param {ExtractFilters} [filters] - Optional where conditions to filter records\n * @param {TOptions} [queryOptions] - Optional Prisma query options\n * @param {ServiceBaseContext} [context] - Optional service execution context\n * @returns {Promise<number>} The count of matching records\n *\n * @example\n * \\`\\`\\`ts\n * const totalUsers = await userService.count();\n * \\`\\`\\`\n *\n * @example\n * \\`\\`\\`ts\n * const activeUsers = await userService.count({\n * status: \"active\"\n * });\n * \\`\\`\\`\n */ \n count<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['CountArgs'], 'where'>>(\n filters?: ExtractFilters<ModelsGetPayload<any>[TModelName]['CountArgs']>, \n queryOptions?: TOptions,\n context?: ServiceBaseContext\n ): Promise<number>;\n\n /**\n * Finds multiple records matching the specified filters.\n *\n * @template TOptions - The query options type extending query options excluding 'where'\n * @param {ExtractFilters} [filters] - Optional where conditions to filter records\n * @param {TOptions} [queryOptions] - Optional Prisma query options (select, include, orderBy, skip, take, etc.)\n * @param {ServiceBaseContext} [context] - Optional service execution context\n * @returns {Promise<Array>} Array of matching records\n *\n * @example\n * \\`\\`\\`ts\n * const users = await userService.findMany({\n * status: \"active\"\n * });\n * \\`\\`\\`\n *\n * @example\n * \\`\\`\\`ts\n * // With pagination and ordering\n * const users = await userService.findMany(\n * { status: \"active\" },\n * { orderBy: { createdAt: \"desc\" }, take: 10, skip: 0 }\n * );\n * \\`\\`\\`\n */\n findMany<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['FindManyArgs'], 'where'>>(\n filters?: ExtractFilters<ModelsGetPayload<any>[TModelName]['FindManyArgs']>, \n queryOptions?: TOptions, \n context?: ServiceBaseContext\n ): Promise<ModelsGetPayload<TOptions>[TModelName]['GetPayload'][]>;\n\n /**\n * Finds a single record by its ID.\n *\n * @template TOptions - The query options type extending query options excluding 'where'\n * @param {string | number} id - The unique identifier of the record\n * @param {TOptions} [queryOptions] - Optional Prisma query options (select, include, etc.)\n * @param {ServiceBaseContext} [context] - Optional service execution context\n * @returns {Promise<ModelsGetPayload | null>} The matching record or null if not found\n *\n * @example\n * \\`\\`\\`ts\n * const user = await userService.findById(\"user-123\");\n * \\`\\`\\`\n *\n * @example\n * \\`\\`\\`ts\n * // With relations\n * const user = await userService.findById(\n * \"user-123\",\n * { include: { posts: true, profile: true } }\n * );\n * \\`\\`\\`\n */\n findById<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['FindFirstArgs'], 'where'>>(\n id: string | number, \n queryOptions?: TOptions, \n context?: ServiceBaseContext\n ): Promise<ModelsGetPayload<TOptions>[TModelName]['GetPayload'] | null>;\n\n /**\n * Updates a single record matching the specified id.\n *\n * @template TOptions - The query options type extending query options excluding 'where' and 'data'\n * @param {string | number} id - The unique identifier of the record\n * @param {ExtractData} data - The data to update\n * @param {TOptions} [queryOptions] - Optional Prisma query options (select, include, etc.)\n * @param {ServiceBaseContext} [context] - Optional service execution context\n * @returns {Promise<ModelsGetPayload>} The updated record\n *\n * @example\n * \\`\\`\\`ts\n * const updatedUser = await userService.updateById(\n * \"user-123\",\n * { name: \"John Updated\" }\n * );\n * \\`\\`\\`\n *\n * @example\n * \\`\\`\\`ts\n * // With relations\n * const updatedUser = await userService.updateById(\n * \"user-123\",\n * { name: \"John Updated\" },\n * { include: { posts: true } }\n * );\n * \\`\\`\\`\n */\n updateById<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['UpdateArgs'], 'where' | 'data'>>(\n id: string | number,\n data: ExtractData<ModelsGetPayload<any>[TModelName]['UpdateArgs']>, \n queryOptions?: TOptions, \n context?: ServiceBaseContext\n ): Promise<ModelsGetPayload<TOptions>[TModelName]['GetPayload']>;\n\n /**\n * Deletes a single record matching the specified id.\n *\n * @param {string | number} id - The unique identifier of the record\n * @param {ServiceBaseContext} [context] - Optional service execution context\n * @returns {Promise<ModelsGetPayload>} The deleted record\n *\n * @example\n * \\`\\`\\`ts\n * const deletedUser = await userService.deleteById(\"user-123\");\n * \\`\\`\\`\n */\n deleteById(\n id: string | number,\n context?: ServiceBaseContext\n ): Promise<ModelsGetPayload<any>[TModelName]['GetPayload']>;\n\n /**\n * Finds the first record matching the specified filters.\n *\n * @template TOptions - The query options type extending query options excluding 'where'\n * @param {ExtractFilters} filters - Where conditions to filter records\n * @param {TOptions} [queryOptions] - Optional Prisma query options (select, include, orderBy, etc.)\n * @param {ServiceBaseContext} [context] - Optional service execution context\n * @returns {Promise<ModelsGetPayload | null>} The first matching record or null if not found\n *\n * @example\n * \\`\\`\\`ts\n * const user = await userService.findOne({\n * email: \"john@example.com\"\n * });\n * \\`\\`\\`\n *\n * @example\n * \\`\\`\\`ts\n * // With relations and ordering\n * const latestPost = await postService.findOne(\n * { published: true },\n * { include: { author: true }, orderBy: { createdAt: \"desc\" } }\n * );\n * \\`\\`\\`\n */\n findOne<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['FindFirstArgs'], 'where'>>(\n filters: ExtractFilters<ModelsGetPayload<any>[TModelName]['FindManyArgs']>, \n queryOptions?: TOptions, \n context?: ServiceBaseContext\n ): Promise<ModelsGetPayload<TOptions>[TModelName]['GetPayload'] | null>;\n\n /**\n * Updates a single record matching the specified filters.\n *\n * @template TOptions - The query options type extending query options excluding 'where' and 'data'\n * @param {ExtractFilters} filters - Where conditions to identify the record to update\n * @param {ExtractData} data - The data to update\n * @param {TOptions} [queryOptions] - Optional Prisma query options (select, include, etc.)\n * @param {ServiceBaseContext} [context] - Optional service execution context\n * @returns {Promise<ModelsGetPayload>} The updated record\n *\n * @example\n * \\`\\`\\`ts\n * const updatedUser = await userService.updateOne(\n * { id: \"user-123\" },\n * { name: \"John Updated\" }\n * );\n * \\`\\`\\`\n *\n * @example\n * \\`\\`\\`ts\n * // With relations\n * const updatedUser = await userService.updateOne(\n * { id: \"user-123\" },\n * { name: \"John Updated\" },\n * { include: { posts: true } }\n * );\n * \\`\\`\\`\n */\n updateOne<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['UpdateArgs'], 'where' | 'data'>>(\n filters: ExtractFilters<ModelsGetPayload<any>[TModelName]['UpdateArgs']>, \n data: ExtractData<ModelsGetPayload<any>[TModelName]['UpdateArgs']>, \n queryOptions?: TOptions, \n context?: ServiceBaseContext\n ): Promise<ModelsGetPayload<TOptions>[TModelName]['GetPayload']>;\n\n /**\n * Updates multiple records matching the specified filters.\n *\n * @template TOptions - The query options type extending query options excluding 'where' and 'data'\n * @param {ExtractFilters} filters - Where conditions to identify records to update\n * @param {ExtractData} data - The data to update\n * @param {TOptions} [queryOptions] - Optional Prisma query options\n * @param {ServiceBaseContext} [context] - Optional service execution context\n * @returns {Promise<{ count: number }>} Object containing count of updated records\n *\n * @example\n * \\`\\`\\`ts\n * const result = await userService.updateMany(\n * { status: \"pending\" },\n * { status: \"active\" }\n * );\n * console.log(result.count); // Number of updated records\n * \\`\\`\\`\n */\n updateMany<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['UpdateManyArgs'], 'where' | 'data'>>(\n filters: ExtractFilters<ModelsGetPayload<any>[TModelName]['UpdateManyArgs']>, \n data: ExtractData<ModelsGetPayload<any>[TModelName]['UpdateManyArgs']>, \n queryOptions?: TOptions, \n context?: ServiceBaseContext\n ): Promise<{ count: number }>;\n\n /**\n * Deletes a single record matching the specified filters.\n *\n * @template TOptions - The query options type extending query options excluding 'where'\n * @param {ExtractFilters} filters - Where conditions to identify the record to delete\n * @param {TOptions} [queryOptions] - Optional Prisma query options\n * @param {ServiceBaseContext} [context] - Optional service execution context\n * @returns {Promise<ModelsGetPayload>} The deleted record\n *\n * @example\n * \\`\\`\\`ts\n * const deletedUser = await userService.deleteOne({\n * id: \"user-123\"\n * });\n * \\`\\`\\`\n */\n deleteOne<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['DeleteArgs'], 'where'>>(\n filters: ExtractFilters<ModelsGetPayload<any>[TModelName]['DeleteArgs']>, \n queryOptions?: TOptions,\n context?: ServiceBaseContext\n ): Promise<ModelsGetPayload<TOptions>[TModelName]['GetPayload']>;\n\n /**\n * Deletes multiple records matching the specified filters.\n *\n * @template TOptions - The query options type extending query options excluding 'where'\n * @param {ExtractFilters} filters - Where conditions to identify records to delete\n * @param {TOptions} [queryOptions] - Optional Prisma query options\n * @param {ServiceBaseContext} [context] - Optional service execution context\n * @returns {Promise<{ count: number }>} Object containing count of deleted records\n *\n * @example\n * \\`\\`\\`ts\n * const result = await userService.deleteMany({\n * status: \"inactive\"\n * });\n * console.log(result.count); // Number of deleted records\n * \\`\\`\\`\n */\n deleteMany<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['DeleteManyArgs'], 'where'>>(\n filters: ExtractFilters<ModelsGetPayload<any>[TModelName]['DeleteManyArgs']>, \n queryOptions?: TOptions,\n context?: ServiceBaseContext\n ): Promise<{ count: number }>;\n\n /**\n * Performs multiple update operations in a single transaction.\n * Each item in the data array must contain filter criteria to identify the record to update.\n *\n * @template TOptions - The query options type extending query options excluding 'where' and 'data'\n * @param {Array<UpdateOneData>} dataArray - Array of update objects, each containing filter criteria and data\n * @param {TOptions} [queryOptions] - Optional Prisma query options applied to all updates\n * @param {ServiceBaseContext} [context] - Optional service execution context\n * @returns {Promise<Array<ModelsGetPayload>>} Array of updated records\n *\n * @example\n * \\`\\`\\`ts\n * const results = await userService.batchUpdate([\n * { where: { id: \"user-1\" }, data: { status: \"active\" } },\n * { where: { id: \"user-2\" }, data: { status: \"inactive\" } }\n * ]);\n * \\`\\`\\`\n *\n * @example\n * \\`\\`\\`ts\n * // With query options for all updates\n * const results = await userService.batchUpdate(\n * [\n * { where: { id: \"user-1\" }, data: { status: \"active\" } },\n * { where: { id: \"user-2\" }, data: { status: \"inactive\" } }\n * ],\n * { include: { posts: true } }\n * );\n * \\`\\`\\`\n */\n batchUpdate<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['UpdateArgs'], 'where' | 'data'>>(\n dataArray: Array<{\n where: ExtractFilters<ModelsGetPayload<any>[TModelName]['UpdateArgs']>,\n data: ExtractData<ModelsGetPayload<any>[TModelName]['UpdateArgs']>\n }>,\n queryOptions?: TOptions,\n context?: ServiceBaseContext\n ): Promise<Array<ModelsGetPayload<TOptions>[TModelName]['GetPayload']>>;\n\n /**\n * Performs multiple delete operations in a single transaction.\n *\n * @template TOptions - The query options type extending query options excluding 'where'\n * @param {Array<ExtractFilters>} batchFilters - Array of where conditions, each identifying a record to delete\n * @param {TOptions} [queryOptions] - Optional Prisma query options applied to all deletes\n * @param {ServiceBaseContext} [context] - Optional service execution context\n * @returns {Promise<Array<ModelsGetPayload>>} Array of deleted records\n *\n * @example\n * \\`\\`\\`ts\n * const deletedUsers = await userService.batchDelete([\n * { id: \"user-1\" },\n * { id: \"user-2\" },\n * { id: \"user-3\" }\n * ]);\n * \\`\\`\\`\n *\n * @example\n * \\`\\`\\`ts\n * // With query options\n * const deletedUsers = await userService.batchDelete(\n * [\n * { id: \"user-1\" },\n * { id: \"user-2\" }\n * ],\n * { include: { posts: true } }\n * );\n * \\`\\`\\`\n */\n batchDelete<TOptions extends ExtractQueryOptions<ModelsGetPayload<any>[TModelName]['DeleteArgs'], 'where'>>(\n batchFilters: Array<ExtractFilters<ModelsGetPayload<any>[TModelName]['DeleteArgs']>>,\n queryOptions?: TOptions,\n context?: ServiceBaseContext\n ): Promise<Array<ModelsGetPayload<TOptions>[TModelName]['GetPayload']>>;\n}\n`;\n }\n\n /**\n * Writes the TypeScript declaration file\n */\n private async generateTypeDeclarations(): Promise<void> {\n const content = this.generateDeclarationContent();\n const filePath = path.join(this.outputDir, \"base.service.d.ts\");\n await fs.writeFile(filePath, content, { encoding: \"utf8\" });\n }\n\n /**\n * Generates the package.json content\n */\n private generatePackageJsonContent(): string {\n return JSON.stringify(\n {\n name: this.packageName,\n version: \"1.0.0\",\n types: \"./base.service.d.ts\",\n exports: {\n \"./base.service\": \"./base.service.d.ts\",\n },\n },\n null,\n 2\n );\n }\n\n /**\n * Writes the package.json file\n */\n private async generatePackageJson(): Promise<void> {\n const content = this.generatePackageJsonContent();\n const pkgPath = path.join(this.outputDir, \"package.json\");\n await fs.writeFile(pkgPath, content, { encoding: \"utf8\" });\n }\n}\n\nconst staticTypesGenerator = new StaticTypesGenerator();\nexport default staticTypesGenerator;\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"arkos-prisma-input.bak.js","sourceRoot":"","sources":["../../../src/types/arkos-prisma-input.bak.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Helper type to exclude properties from T that exist in U\n * Used internally by XOR to create mutually exclusive types\n */\ntype Without<T, U> = {\n [P in Exclude<keyof T, keyof U>]?: never;\n};\n/**\n * XOR (Exclusive OR) type for mutually exclusive union types\n * Ensures that properties from T and U cannot be mixed together\n * @see https://stackoverflow.com/questions/42123407/does-typescript-support-mutually-exclusive-types\n */\ntype XOR<T, U> = T extends object\n ? U extends object\n ? (Without<T, U> & U) | (Without<U, T> & T)\n : U\n : T;\n/**\n * Extract type from Prisma's Enumerable wrapper\n * Currently acts as identity but can be extended to handle array unwrapping\n */\n// type Unpack<T> = T extends Array<infer U> ? U : T extends (infer U)[] ? U : T;\ntype Unpack<T> = T;\n/**\n * Checks if a field is a Prisma relation field\n * A field is considered a relation if it has any of: create, connect, connectOrCreate, update, delete, disconnect\n * Handles optional fields by excluding undefined before checking\n * @template T - The type to check\n * @returns true if T is a relation field, false otherwise\n */\nexport type IsRelationField<T> =\n Exclude<T, undefined> extends\n | {\n create?: { id?: any } | { id?: any }[];\n }\n | {\n connect?: { id?: any } | { id?: any }[];\n }\n | {\n update?: { where?: { id?: any }; data?: any };\n }\n | {\n delete?: { where?: { id?: any } };\n }\n | {\n disconnect?: { where?: { id?: any } };\n }\n ? true\n : false;\n\n/**\n * Checks if a Prisma relation field is an array/many relation\n * Detects relations that support multiple records (one-to-many or many-to-many)\n * @template T - The relation field type\n * @returns true if it's an array relation, false otherwise\n */\nexport type IsArrayRelation<T> =\n Exclude<T, undefined> extends { createMany?: any }\n ? true\n : Exclude<T, undefined> extends { deleteMany?: any }\n ? true\n : false;\n\n/**\n * Extracts the create data type from a Prisma relation field\n * @template T - The relation field type\n * @returns The type used in the create operation, or never if not present\n */\nexport type ExtractCreateType<T> =\n Exclude<T, undefined> extends { create?: infer C }\n ? C extends Array<infer U>\n ? (U & {\n apiAction?: \"create\";\n })[]\n : C & {\n apiAction?: \"create\";\n }\n : never;\n\ntype ExtractConnectType<\n T,\n action extends \"connect\" | \"delete\" | \"udpate\" | \"disconnect\" | \"deleteMany\",\n> =\n Exclude<T, undefined> extends { [k in action]?: infer C }\n ? C extends Array<infer U>\n ? (U & {\n apiAction?: action;\n })[]\n : C & {\n apiAction?: action;\n }\n : never;\n/**\n * Extracts and merges the update data type from a Prisma relation field\n * Combines the 'where' clause and 'data' fields into a single type\n * @template T - The relation field type\n * @returns Merged type of where & data fields, or never if not present\n */\ntype ExtractUpdateType<T> = T extends {\n update?: infer U;\n}\n ? U extends Array<infer Item>\n ? Item extends {\n where: infer W;\n data: infer D;\n }\n ? ((W & D) & { apiAction?: \"update\" })[]\n : never\n : U extends {\n where: infer W;\n data: infer D;\n }\n ? (W & D) & { apiAction?: \"update\" }\n : never\n : never;\n\n/**\n * Creates a flattened union type for a single relation field\n * Combines all possible Prisma operations (create, connect, update, delete, etc.) into a discriminated union\n * Each variant includes an optional apiAction field for explicit operation specification\n * @template T - The Prisma relation field type\n */\ntype FlattenRelationField<T> =\n /**\n * Create Operation - Creates a new related entity\n * Extracts the 'create' data type and recursively flattens nested relations\n * @example { name: \"New Item\", apiAction?: \"create\" }\n */\n | (ExtractCreateType<T> extends never\n ? never\n : FlattenRelations<ExtractCreateType<T>>)\n /**\n * Connect Operation - Links to an existing entity using unique fields\n * Extracts the 'connect' data type (typically unique identifiers like id, email, etc.)\n * @example { id: 123, apiAction?: \"connect\" } or { email: \"user@example.com\", apiAction?: \"connect\" }\n */\n | (ExtractConnectType<T, \"connect\"> extends never\n ? never\n : FlattenRelations<ExtractConnectType<T, \"connect\">>)\n /**\n * Update Operation - Modifies an existing related entity\n * Combines the 'where' clause and 'data' fields into a single flat object\n * @example { id: 123, name: \"Updated Name\", apiAction?: \"update\" }\n */\n | (ExtractUpdateType<T> extends never\n ? never\n : FlattenRelations<ExtractUpdateType<T>> & {\n apiAction?: \"update\";\n })\n /**\n * Delete Operation - Removes a related entity from the database\n * Requires unique identifier(s) and explicit apiAction: \"delete\"\n * For arrays, automatically uses deleteMany; for singular relations uses delete\n * @example { id: 123, apiAction: \"delete\" }\n */\n | (T extends {\n delete?: any;\n }\n ? {\n apiAction: \"delete\";\n } & ExtractConnectType<T, \"delete\">\n : never)\n /**\n * Disconnect Operation - Breaks the relationship without deleting the entity\n * Requires unique identifier(s) and explicit apiAction: \"disconnect\"\n * Only available for optional relations\n * @example { id: 123, apiAction: \"disconnect\" }\n */\n | (T extends {\n disconnect?: any;\n }\n ? {\n apiAction: \"disconnect\";\n } & ExtractConnectType<T, \"disconnect\">\n : never)\n /**\n * Set Operation - Replaces all related entities with a new set\n * Typically used for many-to-many relations to completely replace the relation set\n * @example { id: 456, apiAction?: \"set\" }\n */\n | (T extends {\n set?: infer S;\n }\n ? Unpack<S> & {\n apiAction?: \"set\";\n }\n : never)\n /**\n * Delete Many Operation - Removes multiple related entities matching criteria\n * Requires unique identifier(s) and explicit apiAction: \"deleteMany\"\n * Used for bulk deletion of related records\n * @example { id: 123, apiAction: \"deleteMany\" }\n */\n | (T extends {\n deleteMany?: any;\n }\n ? {\n apiAction: \"deleteMany\";\n } & ExtractConnectType<T, \"deleteMany\">\n : never);\n\n/**\n * Ensures array relations only accept arrays, not single objects\n * For array relations (one-to-many, many-to-many), forces array type\n * For singular relations (one-to-one, many-to-one), keeps XOR behavior\n * @template T - The original Prisma field type\n * @template Flattened - The flattened relation field type\n */\ntype EnforceArrayRelation<T, Flattened> =\n IsArrayRelation<T> extends true\n ? // Array relation: Extract only array types from the union\n Flattened extends Array<any>\n ? Flattened\n : never\n : // Singular relation: Keep XOR behavior (can be object OR array)\n Exclude<XOR<Flattened, T>, \"AND\">;\n\ntype FlattenRelations<T> = {\n [K in keyof T]: IsRelationField<T[K]> extends true\n ? EnforceArrayRelation<T[K], FlattenRelationField<T[K]>>\n : T[K] extends object\n ? T[K] extends Date | null | undefined\n ? T[K]\n : FlattenRelations<T[K]>\n : T[K];\n};\n/**\n * Flattens Prisma relation inputs into a simpler, developer-friendly format\n *\n * Transforms Prisma's nested relation format:\n * ```typescript\n * { posts: { create: [...], connect: [...], update: [...] } }\n * ```\n *\n * Into a flattened format with optional apiAction discriminators:\n * ```typescript\n * { posts: [\n * { title: \"New Post\" }, // auto-detected as create\n * { id: 1 }, // auto-detected as connect\n * { id: 2, title: \"Updated\", apiAction: \"update\" }\n * ]}\n * ```\n *\n * Features:\n * - Preserves non-relation fields as-is\n * - Automatically detects operation type based on field presence\n * - Supports explicit apiAction for disambiguation\n * - Works recursively for deeply nested relations\n * - Enforces array-only types for array relations (one-to-many, many-to-many)\n * - Enforces mutual exclusivity between flattened and Prisma formats for singular relations\n *\n * @see {@link https://wwww.arkosjs.com/docs/api-reference/arkos-prisma-input}\n * @template T - The Prisma input type (e.g., Prisma.UserCreateInput)\n * @returns A flattened version of the input type with simplified relation handling\n *\n * @example\n * ```typescript\n * import { Prisma } from \"@prisma/client\";\n *\n * type FlatUserInput = ArkosPrismaInput<Prisma.UserCreateInput>;\n *\n * const user: FlatUserInput = {\n * name: \"John\",\n * email: \"john@example.com\",\n * posts: [\n * { title: \"My First Post\" }, // creates new post\n * { id: 1 }, // connects to existing post\n * { id: 2, title: \"Updated\" }, // updates existing post\n * { id: 3, apiAction: \"delete\" } // deletes post\n * ],\n * profile: { bio: \"Software developer\" } // singular relation (can be object or array)\n * };\n * ```\n */\nexport type ArkosPrismaInput<T> = FlattenRelations<T>;\n"]}
|