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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"setup-app.js","sourceRoot":"","sources":["../../../src/utils/setup-app.ts"],"names":[],"mappings":"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","sourcesContent":["import compression from \"compression\";\nimport { Arkos } from \"../types/arkos\";\nimport { getArkosConfig } from \"./helpers/arkos-config.helpers\";\nimport rateLimit from \"express-rate-limit\";\nimport deepmerge from \"./helpers/deepmerge.helper\";\nimport cors from \"cors\";\nimport express from \"express\";\nimport cookieParser from \"cookie-parser\";\nimport { queryParser } from \"./helpers/query-parser.helpers\";\nimport { handleRequestLogs } from \"../modules/base/base.middlewares\";\nimport debuggerService from \"../modules/debugger/debugger.service\";\n\nexport default function setupApp(app: Arkos) {\n const config = getArkosConfig();\n\n const middlewaresConfig = config?.middlewares;\n\n if (middlewaresConfig?.compression !== false) {\n if (typeof middlewaresConfig?.compression === \"function\") {\n app.use(middlewaresConfig.compression);\n } else {\n app.use(compression(middlewaresConfig?.compression || {}));\n }\n }\n\n if (middlewaresConfig?.rateLimit !== false) {\n if (typeof middlewaresConfig?.rateLimit === \"function\") {\n app.use(middlewaresConfig.rateLimit);\n } else {\n app.use(\n rateLimit(\n deepmerge(\n {\n windowMs: 60 * 1000,\n limit: 300,\n standardHeaders: \"draft-7\",\n legacyHeaders: false,\n handler: (_, res) => {\n res.status(429).json({\n message: \"Too many requests, please try again later\",\n });\n },\n },\n middlewaresConfig?.rateLimit || {}\n )\n )\n );\n }\n }\n\n if (middlewaresConfig?.cors !== false) {\n if (typeof middlewaresConfig?.cors === \"function\") {\n app.use(middlewaresConfig.cors);\n } else {\n app.use(\n cors(\n middlewaresConfig?.cors?.customHandler\n ? middlewaresConfig.cors.customHandler\n : deepmerge(\n {\n origin: (\n origin: string,\n cb: (err: Error | null, allow?: boolean) => void\n ) => {\n const allowed = (middlewaresConfig?.cors as any)\n ?.allowedOrigins;\n\n if (allowed === \"*\") cb(null, true);\n else if (Array.isArray(allowed))\n cb(null, !origin || allowed?.includes?.(origin));\n else if (typeof allowed === \"string\")\n cb(null, !origin || allowed === origin);\n else cb(null, false);\n },\n\n methods: [\"GET\", \"POST\", \"PUT\", \"DELETE\", \"PATCH\", \"OPTIONS\"],\n allowedHeaders: [\n \"Content-Type\",\n \"Authorization\",\n \"Connection\",\n ],\n credentials: true,\n },\n middlewaresConfig?.cors?.options || {}\n )\n )\n );\n }\n }\n\n if (middlewaresConfig?.expressJson !== false) {\n if (typeof middlewaresConfig?.expressJson === \"function\") {\n app.use(middlewaresConfig.expressJson);\n } else {\n app.use(express.json(middlewaresConfig?.expressJson || {}));\n }\n }\n\n if (middlewaresConfig?.cookieParser !== false) {\n if (typeof middlewaresConfig?.cookieParser === \"function\") {\n app.use(middlewaresConfig.cookieParser);\n } else {\n const params = Array.isArray(middlewaresConfig?.cookieParser)\n ? middlewaresConfig.cookieParser\n : [];\n app.use(cookieParser(...(params as any))); // FIXME: check types correctly\n }\n }\n\n if (middlewaresConfig?.queryParser !== false) {\n if (typeof middlewaresConfig?.queryParser === \"function\") {\n app.use(middlewaresConfig.queryParser);\n } else {\n app.use(\n queryParser(\n deepmerge(\n {\n parseNull: true,\n parseUndefined: true,\n parseBoolean: true,\n parseNumber: true,\n },\n middlewaresConfig?.queryParser || {}\n )\n )\n );\n }\n }\n\n if (middlewaresConfig?.requestLogger !== false) {\n if (typeof middlewaresConfig?.requestLogger === \"function\") {\n app.use(middlewaresConfig.requestLogger);\n } else {\n app.use(handleRequestLogs);\n }\n }\n\n app.use(debuggerService.logRequestInfo);\n\n return app;\n}\n"]}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { IArkosPolicy } from "./types";
|
|
2
|
+
/**
|
|
3
|
+
* Creates a typed policy for a Prisma model resource.
|
|
4
|
+
*
|
|
5
|
+
* Each `.rule()` call registers an action and returns the policy
|
|
6
|
+
* with a typed `can{Action}` permission checker and a typed `{Action}`
|
|
7
|
+
* entry — both passable to the `authentication` field on `ArkosRouteHook`
|
|
8
|
+
* and `ArkosRouter`, and callable for fine-grained permission checks.
|
|
9
|
+
*
|
|
10
|
+
* @param resource - The resource name in kebab-case (e.g. `"user"`, `"blog-post"`)
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* const userPolicy = ArkosPolicy("user")
|
|
15
|
+
* .rule("Create", ["Admin", "Editor"])
|
|
16
|
+
* .rule("View", "*")
|
|
17
|
+
* .rule("Delete", ["Admin"]);
|
|
18
|
+
*
|
|
19
|
+
* // Pass to authentication field
|
|
20
|
+
* userRouter.post({ path: "/users", authentication: userPolicy.Create });
|
|
21
|
+
* userRouteHook.deleteOne({ authentication: userPolicy.Delete });
|
|
22
|
+
*
|
|
23
|
+
* // Fine-grained check
|
|
24
|
+
* if (userPolicy.canCreate(req.user)) { ... }
|
|
25
|
+
*
|
|
26
|
+
* export default userPolicy;
|
|
27
|
+
* ```
|
|
28
|
+
*
|
|
29
|
+
* @see {@link https://www.arkosjs.com/docs/api-referency/arkos-policy}
|
|
30
|
+
*/
|
|
31
|
+
export declare function ArkosPolicy<TResource extends string>(resource: TResource): IArkosPolicy<TResource, never>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { User } from "../../types";
|
|
2
|
+
import { DetailedAccessControlRule } from "../../types/auth";
|
|
3
|
+
export type ArkosPolicyRule = string[] | DetailedAccessControlRule | "*";
|
|
4
|
+
export type PolicyAuthEntry<TResource extends string, TAction extends string> = {
|
|
5
|
+
readonly resource: TResource;
|
|
6
|
+
readonly action: TAction;
|
|
7
|
+
readonly rule: ArkosPolicyRule;
|
|
8
|
+
};
|
|
9
|
+
export type PolicyChecker = (user?: User) => Promise<boolean>;
|
|
10
|
+
type CanKey<TAction extends string> = `can${Capitalize<TAction>}`;
|
|
11
|
+
export type PolicyWithActions<TResource extends string, TActions extends string> = IArkosPolicy<TResource, TActions> & {
|
|
12
|
+
[K in TActions]: PolicyAuthEntry<TResource, K>;
|
|
13
|
+
} & {
|
|
14
|
+
[K in CanKey<TActions>]: PolicyChecker;
|
|
15
|
+
};
|
|
16
|
+
export interface IArkosPolicy<TResource extends string, TActions extends string = never> {
|
|
17
|
+
readonly __type: "ArkosPolicy";
|
|
18
|
+
readonly resource: TResource;
|
|
19
|
+
rule<TAction extends string>(action: TAction, config?: ArkosPolicyRule): PolicyWithActions<TResource, TActions | TAction>;
|
|
20
|
+
}
|
|
21
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function getOpenApiLoginHtml(): string;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { ArkosRequest } from "..";
|
|
2
|
+
/**
|
|
3
|
+
* Context object passed to `before` and `after` auth hooks.
|
|
4
|
+
*/
|
|
5
|
+
export interface AuthHookContext {
|
|
6
|
+
req: ArkosRequest;
|
|
7
|
+
/**
|
|
8
|
+
* Continue to the next hook or core logic.
|
|
9
|
+
* Call with an error to abort and forward to the global error handler.
|
|
10
|
+
*/
|
|
11
|
+
next: (err?: unknown) => void;
|
|
12
|
+
/**
|
|
13
|
+
* Only available in `before` hooks.
|
|
14
|
+
* Bypasses core logic and jumps directly to `after` hooks.
|
|
15
|
+
*/
|
|
16
|
+
skip: () => void;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Context object passed to `onError` auth hooks.
|
|
20
|
+
*/
|
|
21
|
+
export interface AuthErrorHookContext {
|
|
22
|
+
req: ArkosRequest;
|
|
23
|
+
error: unknown;
|
|
24
|
+
/**
|
|
25
|
+
* Forward the original or a new error to the global error handler.
|
|
26
|
+
*/
|
|
27
|
+
next: (err?: unknown) => void;
|
|
28
|
+
/**
|
|
29
|
+
* Suppress the error and jump to `after` hooks.
|
|
30
|
+
*/
|
|
31
|
+
skip: () => void;
|
|
32
|
+
}
|
|
33
|
+
export type AuthHookHandler = (ctx: AuthHookContext) => void | Promise<void>;
|
|
34
|
+
export type AuthAfterHookHandler = (ctx: Omit<AuthHookContext, "skip">) => void | Promise<void>;
|
|
35
|
+
export type AuthErrorHookHandler = (ctx: AuthErrorHookContext) => void | Promise<void>;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Express } from "express";
|
|
2
|
+
import { IncomingMessage, Server, ServerResponse } from "http";
|
|
3
|
+
import { IArkosRouter } from "../exports";
|
|
4
|
+
type ArkosRouterMethods = "get" | "post" | "put" | "patch" | "delete" | "options" | "head" | "all" | "use" | "trace" | "route";
|
|
5
|
+
export interface Arkos extends Omit<Express, "listen" | ArkosRouterMethods>, Pick<IArkosRouter, ArkosRouterMethods> {
|
|
6
|
+
(req: IncomingMessage, res: ServerResponse): void;
|
|
7
|
+
/**
|
|
8
|
+
* Applies all loaded items to the app by adding them as middleware,
|
|
9
|
+
* routers, or handlers at the end of the stack.
|
|
10
|
+
*
|
|
11
|
+
* This ensures that Arkos internals always run after user middleware/routes.
|
|
12
|
+
* Automatically called before listen() if not called manually.
|
|
13
|
+
*/
|
|
14
|
+
build(): Promise<this>;
|
|
15
|
+
/**
|
|
16
|
+
* Starts the server using Arkos-managed port and host configuration.
|
|
17
|
+
* Automatically calls build() if not called manually.
|
|
18
|
+
*
|
|
19
|
+
* @param callback Optional callback invoked once server starts
|
|
20
|
+
*/
|
|
21
|
+
listen(callback?: (error?: Error) => void): Promise<Server>;
|
|
22
|
+
/**
|
|
23
|
+
* Starts the server using Arkos-managed port and host configuration.
|
|
24
|
+
* app.build() must be called before this.
|
|
25
|
+
*
|
|
26
|
+
* @param server {Server} - Optional callback invoked once server starts
|
|
27
|
+
* @param callback Optional callback invoked once server starts
|
|
28
|
+
*/
|
|
29
|
+
listen(server: Server, callback?: (error?: Error) => void): Promise<Server>;
|
|
30
|
+
}
|
|
31
|
+
export {};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { NextFunction, Request, Response } from "express";
|
|
2
2
|
export type PrismaOperations = "findMany";
|
|
3
3
|
/**
|
|
4
4
|
* Type definition for authentication-related Prisma query operations
|
|
@@ -273,8 +273,6 @@ export interface ArkosResponse<ResBody = any, Locals extends Record<string, any>
|
|
|
273
273
|
}
|
|
274
274
|
export interface ArkosNextFunction extends NextFunction {
|
|
275
275
|
}
|
|
276
|
-
export
|
|
277
|
-
|
|
278
|
-
export interface ArkosErrorRequestHandler<P extends Record<string, any> = any, ResBody = any, ReqBody = any, ReqQuery = qs.ParsedQs, Locals extends Record<string, any> = Record<string, any>> extends ErrorRequestHandler<P, ResBody, ReqBody, ReqQuery, Locals> {
|
|
279
|
-
}
|
|
276
|
+
export type ArkosRequestHandler<P extends Record<string, any> = any, ResBody = any, ReqBody = any, ReqQuery extends Record<string, any> = any, Locals extends Record<string, any> = Record<string, any>> = (req: ArkosRequest<P, ResBody, ReqBody, ReqQuery>, res: ArkosResponse<ResBody, Locals>, next: ArkosNextFunction) => void | Promise<void>;
|
|
277
|
+
export type ArkosErrorRequestHandler<P extends Record<string, any> = any, ResBody = any, ReqBody = any, ReqQuery extends Record<string, any> = any, Locals extends Record<string, any> = Record<string, any>> = (err: any, req: ArkosRequest<P, ResBody, ReqBody, ReqQuery>, res: ArkosResponse<ResBody, Locals>, next: ArkosNextFunction) => void | Promise<void>;
|
|
280
278
|
export {};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { IRoute, IRouter } from "express";
|
|
2
|
-
import { ZodSchema } from "zod";
|
|
1
|
+
import { IRoute, IRouter, Locals } from "express";
|
|
2
|
+
import { z, ZodSchema } from "zod";
|
|
3
3
|
import { Options as RateLimitOptions } from "express-rate-limit";
|
|
4
4
|
import { Options as QueryParserOptions } from "../../../utils/helpers/query-parser.helpers";
|
|
5
5
|
import { DetailedAccessControlRule } from "../../../types/auth";
|
|
@@ -8,6 +8,7 @@ import compression from "compression";
|
|
|
8
8
|
import { OpenApiConfig } from "./openapi-config";
|
|
9
9
|
import { UploadConfig } from "./upload-config";
|
|
10
10
|
import { BodyParserConfig } from "./body-parser-config";
|
|
11
|
+
type InferValidationType<T, Fallback> = T extends ZodSchema ? z.infer<T> : T extends new (...args: any[]) => infer I ? I : Fallback;
|
|
11
12
|
export type PathParams = string | RegExp | Array<string | RegExp>;
|
|
12
13
|
export type ArkosAnyRequestHandler = ArkosRequestHandler | ArkosErrorRequestHandler | Array<ArkosRequestHandler | ArkosErrorRequestHandler>;
|
|
13
14
|
/**
|
|
@@ -17,9 +18,17 @@ export type ArkosAnyRequestHandler = ArkosRequestHandler | ArkosErrorRequestHand
|
|
|
17
18
|
* @param {...(ArkosRequestHandler | ArkosErrorRequestHandler)[]} handlers - Request and error handlers for the route.
|
|
18
19
|
* @returns {IRouter} The Express router instance.
|
|
19
20
|
*/
|
|
20
|
-
type RouterMethodHandler<T> =
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
type RouterMethodHandler<T> = {
|
|
22
|
+
(config: PathParams, ...handlers: Array<ArkosAnyRequestHandler>): T;
|
|
23
|
+
<TQuery extends ZodSchema | (new (...args: any[]) => object) | false | undefined = any, TBody extends ZodSchema | (new (...args: any[]) => object) | false | undefined = any, TParams extends ZodSchema | (new (...args: any[]) => object) | false | undefined = any>(config: ArkosRouteConfig<TQuery, TBody, TParams> | PathParams, ...handlers: Array<ArkosRequestHandler<InferValidationType<TParams, Record<string, string>>, any, InferValidationType<TBody, any>, InferValidationType<TQuery, qs.ParsedQs>, any> | Array<ArkosRequestHandler<InferValidationType<TParams, Record<string, string>>, any, InferValidationType<TBody, any>, InferValidationType<TQuery, qs.ParsedQs>, any>>>): T;
|
|
24
|
+
<TQuery extends ZodSchema | (new (...args: any[]) => object) | false | undefined = any, TBody extends ZodSchema | (new (...args: any[]) => object) | false | undefined = any, TParams extends ZodSchema | (new (...args: any[]) => object) | false | undefined = any>(config: ArkosRouteConfig<TQuery, TBody, TParams> | PathParams, ...handlers: Array<ArkosErrorRequestHandler<InferValidationType<TParams, Record<string, string>>, any, InferValidationType<TBody, any>, InferValidationType<TQuery, qs.ParsedQs>, any> | Array<ArkosErrorRequestHandler<InferValidationType<TParams, Record<string, string>>, any, InferValidationType<TBody, any>, InferValidationType<TQuery, qs.ParsedQs>, any>>>): T;
|
|
25
|
+
};
|
|
26
|
+
export type ArkosRouteMethodHandler<T> = {
|
|
27
|
+
(config: ArkosAnyRequestHandler | Omit<ArkosRouteConfig, "path">, ...handlers: Array<ArkosRequestHandler | ArkosErrorRequestHandler | Array<ArkosRequestHandler | ArkosErrorRequestHandler>>): T;
|
|
28
|
+
<TQuery extends ZodSchema | (new (...args: any[]) => object) | false | undefined = any, TBody extends ZodSchema | (new (...args: any[]) => object) | false | undefined = any, TParams extends ZodSchema | (new (...args: any[]) => object) | false | undefined = any>(config: Omit<ArkosRouteConfig<TQuery, TBody, TParams>, "path">, ...handlers: Array<ArkosRequestHandler<InferValidationType<TParams, Record<string, string>>, any, InferValidationType<TBody, any>, InferValidationType<TQuery, qs.ParsedQs>, Locals> | Array<ArkosRequestHandler<InferValidationType<TParams, Record<string, string>>, any, InferValidationType<TBody, any>, InferValidationType<TQuery, qs.ParsedQs>, Locals>>>): T;
|
|
29
|
+
<TQuery extends ZodSchema | (new (...args: any[]) => object) | false | undefined = any, TBody extends ZodSchema | (new (...args: any[]) => object) | false | undefined = any, TParams extends ZodSchema | (new (...args: any[]) => object) | false | undefined = any>(config: Omit<ArkosRouteConfig<TQuery, TBody, TParams>, "path">, ...handlers: Array<ArkosErrorRequestHandler<InferValidationType<TParams, Record<string, string>>, any, InferValidationType<TBody, any>, InferValidationType<TQuery, qs.ParsedQs>, Locals> | Array<ArkosErrorRequestHandler<InferValidationType<TParams, Record<string, string>>, any, InferValidationType<TBody, any>, InferValidationType<TQuery, qs.ParsedQs>, Locals>>>): T;
|
|
30
|
+
};
|
|
31
|
+
export interface IArkosRoute extends IRoute {
|
|
23
32
|
/** GET method handler with route configuration support */
|
|
24
33
|
get: ArkosRouteMethodHandler<this>;
|
|
25
34
|
/** POST method handler with route configuration support */
|
|
@@ -80,13 +89,13 @@ export interface IArkosRouter extends IRouter {
|
|
|
80
89
|
trace: RouterMethodHandler<this>;
|
|
81
90
|
/** ALL methods handler with route configuration support */
|
|
82
91
|
all: RouterMethodHandler<this>;
|
|
83
|
-
route<T extends string>(prefix: T):
|
|
84
|
-
route(prefix: PathParams):
|
|
92
|
+
route<T extends string>(prefix: T): IArkosRoute;
|
|
93
|
+
route(prefix: PathParams): IArkosRoute;
|
|
85
94
|
}
|
|
86
95
|
/**
|
|
87
96
|
* Configuration object for defining routes in Arkos.js.
|
|
88
97
|
*/
|
|
89
|
-
export type ArkosRouteConfig = {
|
|
98
|
+
export type ArkosRouteConfig<TQuery extends ZodSchema | (new (...args: any[]) => object) | false | undefined = any, TBody extends ZodSchema | (new (...args: any[]) => object) | false | undefined = any, TParams extends ZodSchema | (new (...args: any[]) => object) | false | undefined = any> = {
|
|
90
99
|
/**
|
|
91
100
|
* Disables the route by not mounting it internally.
|
|
92
101
|
*/
|
|
@@ -119,9 +128,9 @@ export type ArkosRouteConfig = {
|
|
|
119
128
|
* - Each property accepts a Zod schema, a class constructor, or `false` to disable validation for that part.
|
|
120
129
|
*/
|
|
121
130
|
validation?: false | {
|
|
122
|
-
query?:
|
|
123
|
-
body?:
|
|
124
|
-
params?:
|
|
131
|
+
query?: TQuery;
|
|
132
|
+
body?: TBody;
|
|
133
|
+
params?: TParams;
|
|
125
134
|
};
|
|
126
135
|
/**
|
|
127
136
|
* Rate limiting configuration for this route.
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RouterOptions } from "express";
|
|
2
|
+
export declare function applyArkosRouterProxy<T extends object>(target: T, options?: RouterOptions & {
|
|
3
|
+
prefix?: string | RegExp | Array<string | RegExp>;
|
|
4
|
+
openapi?: {
|
|
5
|
+
tags?: string[];
|
|
6
|
+
};
|
|
7
|
+
}, name?: "app" | "ArkosRouter()"): T;
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options for configuring a bundle run.
|
|
3
|
+
*/
|
|
4
|
+
interface BundlerOptions {
|
|
5
|
+
/** Output file extension: ".js" | ".cjs" | ".mjs" */
|
|
6
|
+
ext: string;
|
|
7
|
+
/** Directory containing the compiled output files to process */
|
|
8
|
+
outDir: string;
|
|
9
|
+
/** Source root directory used to resolve tsconfig paths. Defaults to process.cwd() */
|
|
10
|
+
rootDir?: string;
|
|
11
|
+
/** Explicit path to tsconfig.json or jsconfig.json. Auto-detected from rootDir if omitted */
|
|
12
|
+
configPath?: string;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Post-compilation import rewriter and alias resolver.
|
|
16
|
+
*
|
|
17
|
+
* Recursively processes all `.js`, `.cjs`, and `.mjs` files in the output
|
|
18
|
+
* directory, rewriting:
|
|
19
|
+
* - Relative imports to include the correct file extension
|
|
20
|
+
* - Directory imports to use `/index.ext`
|
|
21
|
+
* - Path aliases defined in tsconfig/jsconfig `paths` to relative paths
|
|
22
|
+
*
|
|
23
|
+
* Bare node_modules specifiers (e.g. `"express"`, `"@prisma/client"`) are
|
|
24
|
+
* left untouched.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```ts
|
|
28
|
+
* const bundler = new Bundler();
|
|
29
|
+
*
|
|
30
|
+
* bundler.bundle({
|
|
31
|
+
* ext: ".js",
|
|
32
|
+
* outDir: "./dist",
|
|
33
|
+
* rootDir: "./",
|
|
34
|
+
* configPath: "./tsconfig.json",
|
|
35
|
+
* });
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
38
|
+
export declare class Bundler {
|
|
39
|
+
/**
|
|
40
|
+
* Regexes for matching all import/export/require statement forms.
|
|
41
|
+
* Defined as static to avoid recreation per file processed.
|
|
42
|
+
*/
|
|
43
|
+
private static readonly IMPORT_REGEXES;
|
|
44
|
+
/**
|
|
45
|
+
* Pre-compiles path alias patterns into a lookup-friendly structure
|
|
46
|
+
* so alias matching during processing is O(n) over aliases rather than
|
|
47
|
+
* re-parsing patterns per import.
|
|
48
|
+
*/
|
|
49
|
+
private compileAliases;
|
|
50
|
+
/**
|
|
51
|
+
* Loads and parses the tsconfig/jsconfig file, resolving any `extends` chain.
|
|
52
|
+
* Falls back to `{ baseUrl: rootDir, paths: {} }` if no config is found.
|
|
53
|
+
*
|
|
54
|
+
* @param rootDir - Absolute root directory
|
|
55
|
+
* @param configPath - Explicit config path, or undefined to auto-detect
|
|
56
|
+
*/
|
|
57
|
+
private loadConfig;
|
|
58
|
+
/**
|
|
59
|
+
* Searches for a tsconfig.json or jsconfig.json in the given directory.
|
|
60
|
+
* Prefers tsconfig.json over jsconfig.json.
|
|
61
|
+
*
|
|
62
|
+
* @param dir - Directory to search in
|
|
63
|
+
* @returns Absolute path to the config file, or null if not found
|
|
64
|
+
*/
|
|
65
|
+
private findConfig;
|
|
66
|
+
/**
|
|
67
|
+
* Recursively parses a tsconfig/jsconfig file, following `extends` chains
|
|
68
|
+
* and merging `paths` with child config taking precedence over parent.
|
|
69
|
+
*
|
|
70
|
+
* @param configPath - Absolute path to the config file to parse
|
|
71
|
+
* @param rootDir - Absolute root directory used as fallback baseUrl
|
|
72
|
+
*/
|
|
73
|
+
private parseConfig;
|
|
74
|
+
/**
|
|
75
|
+
* Resolves a tsconfig `extends` value that points to a node_modules package,
|
|
76
|
+
* e.g. `"@tsconfig/node18/tsconfig.json"`.
|
|
77
|
+
*
|
|
78
|
+
* @param extendsValue - The raw extends string from tsconfig
|
|
79
|
+
* @param rootDir - Root directory to resolve from
|
|
80
|
+
* @returns Absolute path to the resolved config file, or null if not found
|
|
81
|
+
*/
|
|
82
|
+
private resolveNodeModulesConfig;
|
|
83
|
+
/**
|
|
84
|
+
* Reads a JSON file that may contain comments and trailing commas
|
|
85
|
+
* (as tsconfig/jsconfig files allow) and returns the parsed object.
|
|
86
|
+
*
|
|
87
|
+
* @param filePath - Absolute path to the JSON file
|
|
88
|
+
* @returns Parsed object, or empty object if parsing fails
|
|
89
|
+
*/
|
|
90
|
+
private readJsonWithComments;
|
|
91
|
+
/**
|
|
92
|
+
* Resolves a single import path to its final rewritten form.
|
|
93
|
+
*
|
|
94
|
+
* Resolution order:
|
|
95
|
+
* 1. Relative imports (`./`, `../`) — extension is added via `addExtension`
|
|
96
|
+
* 2. Aliased imports — matched against compiled aliases and converted to relative paths
|
|
97
|
+
* 3. Bare specifiers (`express`, `@prisma/client`) — returned untouched
|
|
98
|
+
*
|
|
99
|
+
* @param importPath - The raw import string from source code
|
|
100
|
+
* @param fileDir - Absolute directory of the file containing the import
|
|
101
|
+
* @param ext - The output file extension
|
|
102
|
+
* @param resolvedPaths - Resolved baseUrl and paths from tsconfig
|
|
103
|
+
* @param compiledAliases - Pre-compiled alias entries
|
|
104
|
+
*/
|
|
105
|
+
private resolveImport;
|
|
106
|
+
private getFileDirInSource;
|
|
107
|
+
/**
|
|
108
|
+
* Appends the configured extension to an import path if not already present.
|
|
109
|
+
* If the path resolves to a directory containing an `index` file, appends
|
|
110
|
+
* `/index.ext` instead.
|
|
111
|
+
*
|
|
112
|
+
* @param importPath - The relative import path to fix
|
|
113
|
+
* @param fileDir - Absolute directory of the file containing the import
|
|
114
|
+
* @param ext - The output file extension
|
|
115
|
+
*/
|
|
116
|
+
private addExtension;
|
|
117
|
+
/**
|
|
118
|
+
* Converts an absolute path to a relative path from a given directory,
|
|
119
|
+
* ensuring the result always starts with `./` or `../`.
|
|
120
|
+
*
|
|
121
|
+
* @param fromDir - The directory to compute the relative path from
|
|
122
|
+
* @param toPath - The absolute target path
|
|
123
|
+
* @returns A POSIX-style relative path
|
|
124
|
+
*/
|
|
125
|
+
private toRelative;
|
|
126
|
+
/**
|
|
127
|
+
* Rewrites all import/export/require statements in a string of JS source code.
|
|
128
|
+
* Each regex is reset before use since they are stateful with the `/g` flag.
|
|
129
|
+
*
|
|
130
|
+
* @param content - Raw file content to process
|
|
131
|
+
* @param fileDir - Absolute directory of the file being processed
|
|
132
|
+
* @param ext - The output file extension
|
|
133
|
+
* @param resolvedPaths - Resolved baseUrl and paths from tsconfig
|
|
134
|
+
* @param compiledAliases - Pre-compiled alias entries
|
|
135
|
+
*/
|
|
136
|
+
private rewriteImports;
|
|
137
|
+
/**
|
|
138
|
+
* Recursively processes all `.js`, `.cjs`, and `.mjs` files in the output
|
|
139
|
+
* directory, rewriting imports in-place. Files whose content is unchanged
|
|
140
|
+
* are not written back to disk.
|
|
141
|
+
*
|
|
142
|
+
* @param options - Configuration options for this bundle run
|
|
143
|
+
*/
|
|
144
|
+
bundle(options: BundlerOptions): void;
|
|
145
|
+
/**
|
|
146
|
+
* Internal recursive directory walker, separated so that `bundle()` only
|
|
147
|
+
* resolves config once at the top level rather than on every recursion.
|
|
148
|
+
*/
|
|
149
|
+
private _bundleDir;
|
|
150
|
+
}
|
|
151
|
+
export declare const bundler: Bundler;
|
|
152
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function ExitError(message: any, code?: number): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AuthConfigs } from "../../types/auth";
|
|
2
|
-
import { AuthRouterEndpoint, RouterConfig, RouterEndpoint } from "../../types/router-config";
|
|
2
|
+
import { AuthRouterEndpoint, FileUploadRouterEndpoint, RouterConfig, RouterEndpoint } from "../../types/router-config";
|
|
3
3
|
import { ArkosRouteConfig } from "../arkos-router/types";
|
|
4
4
|
import { ArkosConfig } from "../../exports";
|
|
5
5
|
export declare const safeCatchAsync: (middleware: any, options?: {
|
|
@@ -8,7 +8,7 @@ export declare const safeCatchAsync: (middleware: any, options?: {
|
|
|
8
8
|
export declare const processMiddleware: (middleware: any, options?: {
|
|
9
9
|
type: "error" | "normal";
|
|
10
10
|
}) => any[];
|
|
11
|
-
export declare function getAuthenticationConfig(endpoint: RouterEndpoint | AuthRouterEndpoint, modelName: string, authConfigs?: AuthConfigs): boolean | {
|
|
11
|
+
export declare function getAuthenticationConfig(endpoint: RouterEndpoint | AuthRouterEndpoint | FileUploadRouterEndpoint, modelName: string, authConfigs?: AuthConfigs): boolean | {
|
|
12
12
|
resource: string;
|
|
13
13
|
action: string;
|
|
14
14
|
rule: string[] | import("../../types/auth").DetailedAccessControlRule | undefined;
|
|
@@ -24,4 +24,4 @@ export declare function getAuthenticationConfig(endpoint: RouterEndpoint | AuthR
|
|
|
24
24
|
* @param validationSchema - Optional validation schema for the endpoint
|
|
25
25
|
* @returns Route configuration object
|
|
26
26
|
*/
|
|
27
|
-
export declare function createRouteConfig(arkosConfig: ArkosConfig, endpoint: RouterEndpoint | AuthRouterEndpoint, routeName: string, path: string, routerConfig: RouterConfig<any>, modelNameInKebab: string, authConfigs: any, validationSchema?: any): ArkosRouteConfig;
|
|
27
|
+
export declare function createRouteConfig(arkosConfig: ArkosConfig, endpoint: RouterEndpoint | AuthRouterEndpoint | FileUploadRouterEndpoint, routeName: string, path: string, routerConfig: RouterConfig<any>, modelNameInKebab: string, authConfigs: any, validationSchema?: any): ArkosRouteConfig;
|
package/package.json
CHANGED
|
@@ -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"]}
|