arkos 2.0.0-next.29 → 2.0.0-next.30
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/esm/app.js +2 -0
- package/dist/esm/app.js.map +1 -1
- package/dist/esm/components/arkos-gateway/arkos-gateway.js +22 -5
- package/dist/esm/components/arkos-gateway/arkos-gateway.js.map +1 -1
- package/dist/esm/components/arkos-gateway/types.js.map +1 -1
- package/dist/esm/components/arkos-route-hook/index.js +9 -3
- package/dist/esm/components/arkos-route-hook/index.js.map +1 -1
- package/dist/esm/components/arkos-route-hook/reader.js.map +1 -1
- package/dist/esm/components/arkos-route-hook/types.js.map +1 -1
- package/dist/esm/exports/file-upload.js +2 -0
- package/dist/esm/exports/file-upload.js.map +1 -0
- package/dist/esm/exports/index.js.map +1 -1
- package/dist/esm/exports/websockets.js.map +1 -1
- package/dist/esm/generated.js.map +1 -1
- package/dist/esm/modules/auth/auth.controller.js +84 -141
- package/dist/esm/modules/auth/auth.controller.js.map +1 -1
- package/dist/esm/modules/auth/auth.router.js +1 -1
- package/dist/esm/modules/auth/auth.router.js.map +1 -1
- package/dist/esm/modules/auth/auth.service.js +93 -15
- package/dist/esm/modules/auth/auth.service.js.map +1 -1
- package/dist/esm/modules/auth/auth.types.js +2 -0
- package/dist/esm/modules/auth/auth.types.js.map +1 -0
- package/dist/esm/modules/auth/utils/helpers/auth.controller.helpers.js +1 -0
- package/dist/esm/modules/auth/utils/helpers/auth.controller.helpers.js.map +1 -1
- package/dist/esm/modules/auth/utils/token-extraction.js +57 -0
- package/dist/esm/modules/auth/utils/token-extraction.js.map +1 -0
- package/dist/esm/modules/base/base.controller.js +5 -0
- package/dist/esm/modules/base/base.controller.js.map +1 -1
- package/dist/esm/modules/base/base.middlewares.js +4 -4
- package/dist/esm/modules/base/base.middlewares.js.map +1 -1
- package/dist/esm/modules/base/utils/error-prettifier.js +64 -0
- package/dist/esm/modules/base/utils/error-prettifier.js.map +1 -1
- package/dist/esm/modules/error-handler/utils/error-handler.helpers.js +52 -8
- package/dist/esm/modules/error-handler/utils/error-handler.helpers.js.map +1 -1
- package/dist/esm/modules/error-handler/utils/get-handled-error.js +5 -0
- package/dist/esm/modules/error-handler/utils/get-handled-error.js.map +1 -1
- package/dist/esm/modules/file-upload/file-upload.controller.js +25 -7
- package/dist/esm/modules/file-upload/file-upload.controller.js.map +1 -1
- package/dist/esm/modules/file-upload/file-upload.router.js +21 -5
- package/dist/esm/modules/file-upload/file-upload.router.js.map +1 -1
- package/dist/esm/modules/file-upload/file-upload.service.js +28 -18
- package/dist/esm/modules/file-upload/file-upload.service.js.map +1 -1
- package/dist/esm/modules/file-upload/utils/file-upload-json-schema-generator.js +37 -12
- package/dist/esm/modules/file-upload/utils/file-upload-json-schema-generator.js.map +1 -1
- package/dist/esm/modules/file-upload/utils/helpers/file-upload.helpers.js +73 -35
- package/dist/esm/modules/file-upload/utils/helpers/file-upload.helpers.js.map +1 -1
- package/dist/esm/modules/file-upload/utils/helpers/serve-upload-dir.js +206 -0
- package/dist/esm/modules/file-upload/utils/helpers/serve-upload-dir.js.map +1 -0
- package/dist/esm/modules/file-upload/utils/helpers/upload-path.helper.js +103 -0
- package/dist/esm/modules/file-upload/utils/helpers/upload-path.helper.js.map +1 -0
- package/dist/esm/modules/file-upload/utils/helpers/upload-serving-validation.js +212 -0
- package/dist/esm/modules/file-upload/utils/helpers/upload-serving-validation.js.map +1 -0
- package/dist/esm/modules/file-upload/utils/helpers/upload-serving.registry.js +30 -0
- package/dist/esm/modules/file-upload/utils/helpers/upload-serving.registry.js.map +1 -0
- package/dist/esm/modules/swagger/utils/helpers/get-swagger-default-configs.js +1 -1
- package/dist/esm/modules/swagger/utils/helpers/get-swagger-default-configs.js.map +1 -1
- package/dist/esm/modules/swagger/utils/helpers/openapi-schema-converter.js +7 -8
- package/dist/esm/modules/swagger/utils/helpers/openapi-schema-converter.js.map +1 -1
- package/dist/esm/types/index.js.map +1 -1
- package/dist/esm/types/internal.js +2 -0
- package/dist/esm/types/internal.js.map +1 -0
- package/dist/esm/types/new-arkos-config.js.map +1 -1
- package/dist/esm/types/upload.js.map +1 -1
- package/dist/esm/types/validation/validation-manager.js +18 -10
- package/dist/esm/types/validation/validation-manager.js.map +1 -1
- package/dist/esm/types/validation/validator.js.map +1 -1
- package/dist/esm/utils/arkos-router/arkos-router-openapi-manager.js.map +1 -1
- package/dist/esm/utils/arkos-router/index.js +2 -11
- package/dist/esm/utils/arkos-router/index.js.map +1 -1
- package/dist/esm/utils/arkos-router/route-config-validator.js +11 -10
- package/dist/esm/utils/arkos-router/route-config-validator.js.map +1 -1
- package/dist/esm/utils/arkos-router/types/index.js.map +1 -1
- package/dist/esm/utils/arkos-router/types/upload-config.js.map +1 -1
- package/dist/esm/utils/arkos-router/utils/helpers/index.js +1 -0
- package/dist/esm/utils/arkos-router/utils/helpers/index.js.map +1 -1
- package/dist/esm/utils/arkos-router/utils/helpers/upload-manager.js +326 -37
- package/dist/esm/utils/arkos-router/utils/helpers/upload-manager.js.map +1 -1
- package/dist/esm/utils/cli/dev.js +15 -2
- package/dist/esm/utils/cli/dev.js.map +1 -1
- package/dist/esm/utils/cli/generate.js +8 -3
- package/dist/esm/utils/cli/generate.js.map +1 -1
- package/dist/esm/utils/cli/index.js +21 -20
- package/dist/esm/utils/cli/index.js.map +1 -1
- package/dist/esm/utils/cli/prisma-generate.js +24 -5
- package/dist/esm/utils/cli/prisma-generate.js.map +1 -1
- package/dist/esm/utils/cli/start.js +2 -0
- 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/dependency-version-check.js +39 -0
- package/dist/esm/utils/cli/utils/dependency-version-check.js.map +1 -0
- package/dist/esm/utils/cli/utils/template-generator/templates/router-template.js.map +1 -1
- package/dist/esm/utils/define-config.js +1 -0
- package/dist/esm/utils/define-config.js.map +1 -1
- package/dist/esm/utils/initialize-app.js +2 -0
- package/dist/esm/utils/initialize-app.js.map +1 -1
- package/dist/types/app.d.ts +5 -2
- package/dist/types/components/arkos-gateway/arkos-gateway.d.ts +19 -7
- package/dist/types/components/arkos-gateway/types.d.ts +19 -2
- package/dist/types/components/arkos-route-hook/index.d.ts +4 -3
- package/dist/types/components/arkos-route-hook/reader.d.ts +1 -1
- package/dist/types/components/arkos-route-hook/types.d.ts +4 -1
- package/dist/types/exports/file-upload.d.ts +1 -0
- package/dist/types/exports/index.d.ts +1 -2
- package/dist/types/exports/websockets.d.ts +1 -1
- package/dist/types/modules/auth/auth.controller.d.ts +10 -3
- package/dist/types/modules/auth/auth.service.d.ts +90 -0
- package/dist/types/modules/auth/auth.types.d.ts +72 -0
- package/dist/types/modules/auth/utils/helpers/auth.controller.helpers.d.ts +1 -0
- package/dist/types/modules/auth/utils/token-extraction.d.ts +53 -0
- package/dist/types/modules/base/base.controller.d.ts +1 -0
- package/dist/types/modules/base/utils/error-prettifier.d.ts +8 -0
- package/dist/types/modules/error-handler/utils/error-handler.helpers.d.ts +1 -0
- package/dist/types/modules/file-upload/file-upload.service.d.ts +2 -6
- package/dist/types/modules/file-upload/utils/helpers/file-upload.helpers.d.ts +21 -1
- package/dist/types/modules/file-upload/utils/helpers/serve-upload-dir.d.ts +43 -0
- package/dist/types/modules/file-upload/utils/helpers/upload-path.helper.d.ts +14 -0
- package/dist/types/modules/file-upload/utils/helpers/upload-serving-validation.d.ts +5 -0
- package/dist/types/modules/file-upload/utils/helpers/upload-serving.registry.d.ts +31 -0
- package/dist/types/modules/swagger/utils/helpers/openapi-schema-converter.d.ts +1 -1
- package/dist/types/types/index.d.ts +5 -0
- package/dist/types/types/internal.d.ts +25 -0
- package/dist/types/types/new-arkos-config.d.ts +24 -2
- package/dist/types/types/upload.d.ts +35 -0
- package/dist/types/types/validation/validation-manager.d.ts +6 -8
- package/dist/types/types/validation/validator.d.ts +2 -2
- package/dist/types/utils/arkos-router/types/index.d.ts +3 -2
- package/dist/types/utils/arkos-router/types/upload-config.d.ts +102 -11
- package/dist/types/utils/arkos-router/utils/helpers/upload-manager.d.ts +20 -0
- package/dist/types/utils/cli/utils/dependency-version-check.d.ts +15 -0
- package/dist/types/utils/define-config.d.ts +56 -2
- package/dist/types/utils/helpers/prisma.helpers.d.ts +1 -1
- package/package.json +15 -38
package/dist/esm/app.js
CHANGED
|
@@ -7,6 +7,7 @@ import runtimeCliCommander from './utils/cli/utils/runtime-cli-commander.js';
|
|
|
7
7
|
import { Server } from 'http';
|
|
8
8
|
import ExitError from './utils/helpers/exit-error.js';
|
|
9
9
|
import { applyArkosRouterProxy } from './utils/arkos-router/utils/helpers/apply-arkos-router-proxy.js';
|
|
10
|
+
import { serveUploadDir } from './modules/file-upload/utils/helpers/serve-upload-dir.js';
|
|
10
11
|
export const app = express();
|
|
11
12
|
let appServer;
|
|
12
13
|
export const docsLink = 'https://www.arkosjs.com/docs/core-concepts/routing/setup#setting-up-your-app';
|
|
@@ -66,6 +67,7 @@ export default function arkos() {
|
|
|
66
67
|
};
|
|
67
68
|
return app;
|
|
68
69
|
}
|
|
70
|
+
arkos.serveUploadDir = serveUploadDir;
|
|
69
71
|
export function getAppServer() {
|
|
70
72
|
return appServer;
|
|
71
73
|
}
|
package/dist/esm/app.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.js","sourceRoot":"","sources":["../../src/app.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,mBAAmB,GACpB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,OAAoB,MAAM,SAAS,CAAC;AAC3C,OAAO,QAAQ,MAAM,mBAAmB,CAAC;AAEzC,OAAO,aAAa,EAAE,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,mBAAmB,MAAM,yCAAyC,CAAC;AAC1E,OAAO,EAAmB,MAAM,EAAkB,MAAM,MAAM,CAAC;AAC/D,OAAO,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,KAAK,CAAC,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,UAAU;YAC9D,SAAS,GAAG,cAAc,CACxB,IAAI,EACJ,IAAI,EACJ,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAiB,CAAC,CAC/C,CAAC;aACC,IAAI,IAAI,CAAC,CAAC,CAAC,YAAY,MAAM,IAAI,OAAO,IAAI,CAAC,CAAC,CAAC,KAAK,QAAQ;YAC/D,SAAS,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CACxB,IAAI,EACJ,IAAI,EACJ,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAiB,CAAC,CAC/C,CAAC;QAEJ,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC;IAEF,OAAO,GAAG,CAAC;AACb,CAAC;AAED,MAAM,UAAU,YAAY;IAC1B,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import {\n isProduction,\n validateArkosConfig,\n} from './utils/helpers/arkos-config.helpers';\nimport express, { Express } from 'express';\nimport setupApp from './utils/setup-app';\nimport { Arkos } from './types/arkos';\nimport initializeApp, { addGlobalErrorHandler } from './utils/initialize-app';\nimport { logAppStartup } from './server';\nimport runtimeCliCommander from './utils/cli/utils/runtime-cli-commander';\nimport { IncomingMessage, Server, ServerResponse } from 'http';\nimport ExitError from './utils/helpers/exit-error';\nimport { applyArkosRouterProxy } from './utils/arkos-router/utils/helpers/apply-arkos-router-proxy';\nexport const app: express.Express = express();\n\nlet appServer: Server<typeof IncomingMessage, typeof ServerResponse>;\nexport const docsLink =\n 'https://www.arkosjs.com/docs/core-concepts/routing/setup#setting-up-your-app';\nlet instanciated = false;\ntype AppState = 'idle' | 'building' | 'built' | 'listening';\nexport let state: AppState = 'idle';\n\n/**\n * Creates and configures an Arkos application instance.\n *\n * Arkos extends Express with a small set of methods for registering routers,\n * loading route/service hooks, and booting the application. All Arkos-specific\n * setup (`app.build()`) must happen before the app starts\n * accepting requests.\n *\n * @example\n * ```ts\n * // Simple setup\n * import arkos from \"arkos\";\n *\n * const app = arkos();\n *\n * app.use(reportsRouter);\n *\n * app.listen();\n * ```\n *\n * @example\n * ```ts\n * // Custom HTTP server (e.g. for WebSockets)\n * import arkos from \"arkos\";\n * import http from \"http\";\n *\n * const app = arkos();\n *\n * app.use(reportsRouter);\n *\n * await app.build();\n *\n * const server = http.createServer(app);\n * app.listen(server)\n * ```\n *\n * @see {@link https://www.arkosjs.com/docs/core-concepts/routing/setup}\n */\nexport default function arkos(): Arkos {\n if (process.env.__ARKOS_CLI !== 'true')\n throw ExitError(\n `Arkos.js application must be started the built-in cli ${isProduction() ? \"'arkos start' in production\" : `'arkos dev' in development`} see https://www.arkosjs.com/docs/getting-started/installation#7-set-up-packagejson-scripts`,\n );\n\n if (instanciated)\n throw ExitError(`arkos() must be called only once, see ${docsLink}`);\n\n const app = applyArkosRouterProxy(express(), {}, 'app') as any as Arkos;\n setupApp(app);\n instanciated = true;\n\n function loadApp() {\n let _app = initializeApp(app);\n _app = addGlobalErrorHandler(_app);\n if (process.env.CLI_COMMAND) runtimeCliCommander.handle();\n return _app;\n }\n\n app.build = function () {\n if (state === 'built' || state === 'building')\n throw ExitError(`app.build() must only be called once, see ${docsLink}`);\n if (state === 'listening')\n throw ExitError(\n `app.build() must be called before app.listen(), see ${docsLink}`,\n );\n\n state = 'building';\n const _app = loadApp();\n state = 'built';\n return _app;\n };\n\n const originalListen = app.listen.bind(app) as any as Express['listen'];\n type UserCallback = (err?: Error) => void;\n\n const defaultCb = (\n port: number | string,\n host: string,\n cb?: UserCallback,\n ) => {\n logAppStartup(port, host);\n return cb || function () {};\n };\n\n app.listen = async function (...args: any[]): Promise<Server> {\n process.env.__ARKOS_SERVER_LISTENER = 'arkos';\n\n if (state === 'listening')\n throw ExitError(`app.listen() must only be called once, see ${docsLink}`);\n if (state === 'building')\n throw ExitError(\n `app.build() must be awaited before calling app.listen(), see ${docsLink}`,\n );\n\n if (state === 'idle') {\n state = 'listening';\n loadApp();\n }\n\n validateArkosConfig();\n\n const port = Number(process.env.__PORT || process.env.PORT || '8000');\n const host = process.env.__HOST! || process.env.HOST || '0.0.0.0';\n\n process.send?.({ started: true });\n if (process.env.__SKIP_LISTEN == 'true') return appServer;\n\n if ((args as any)?.length === 0 || typeof args[0] === 'function')\n appServer = originalListen(\n port,\n host,\n defaultCb(port, host, args[0] as UserCallback),\n );\n else if (args[0] instanceof Server || typeof args[0] === 'object')\n appServer = args[0].listen(\n port,\n host,\n defaultCb(port, host, args[1] as UserCallback),\n );\n\n return appServer;\n };\n\n return app;\n}\n\nexport function getAppServer() {\n return appServer;\n}\n\n"]}
|
|
1
|
+
{"version":3,"file":"app.js","sourceRoot":"","sources":["../../src/app.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,mBAAmB,GACpB,MAAM,sCAAsC,CAAC;AAC9C,OAAO,OAAoB,MAAM,SAAS,CAAC;AAC3C,OAAO,QAAQ,MAAM,mBAAmB,CAAC;AAEzC,OAAO,aAAa,EAAE,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAC9E,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,mBAAmB,MAAM,yCAAyC,CAAC;AAC1E,OAAO,EAAmB,MAAM,EAAkB,MAAM,MAAM,CAAC;AAC/D,OAAO,SAAS,MAAM,4BAA4B,CAAC;AACnD,OAAO,EAAE,qBAAqB,EAAE,MAAM,6DAA6D,CAAC;AACpG,OAAO,EAAE,cAAc,EAAE,MAAM,sDAAsD,CAAC;AACtF,MAAM,CAAC,MAAM,GAAG,GAAoB,OAAO,EAAE,CAAC;AAE9C,IAAI,SAAgE,CAAC;AACrE,MAAM,CAAC,MAAM,QAAQ,GACnB,8EAA8E,CAAC;AACjF,IAAI,YAAY,GAAG,KAAK,CAAC;AAEzB,MAAM,CAAC,IAAI,KAAK,GAAa,MAAM,CAAC;AAwCpC,MAAM,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IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,CACxB,IAAI,EACJ,IAAI,EACJ,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAiB,CAAC,CAC/C,CAAC;QAEJ,OAAO,SAAS,CAAC;IACnB,CAAC,CAAC;IAEF,OAAO,GAAG,CAAC;AACb,CAAC;AAED,KAAK,CAAC,cAAc,GAAG,cAAc,CAAC;AAEtC,MAAM,UAAU,YAAY;IAC1B,OAAO,SAAS,CAAC;AACnB,CAAC","sourcesContent":["import {\n isProduction,\n validateArkosConfig,\n} from './utils/helpers/arkos-config.helpers';\nimport express, { Express } from 'express';\nimport setupApp from './utils/setup-app';\nimport { Arkos } from './types/arkos';\nimport initializeApp, { addGlobalErrorHandler } from './utils/initialize-app';\nimport { logAppStartup } from './server';\nimport runtimeCliCommander from './utils/cli/utils/runtime-cli-commander';\nimport { IncomingMessage, Server, ServerResponse } from 'http';\nimport ExitError from './utils/helpers/exit-error';\nimport { applyArkosRouterProxy } from './utils/arkos-router/utils/helpers/apply-arkos-router-proxy';\nimport { serveUploadDir } from './modules/file-upload/utils/helpers/serve-upload-dir';\nexport const app: express.Express = express();\n\nlet appServer: Server<typeof IncomingMessage, typeof ServerResponse>;\nexport const docsLink =\n 'https://www.arkosjs.com/docs/core-concepts/routing/setup#setting-up-your-app';\nlet instanciated = false;\ntype AppState = 'idle' | 'building' | 'built' | 'listening';\nexport let state: AppState = 'idle';\n\n/**\n * Creates and configures an Arkos application instance.\n *\n * Arkos extends Express with a small set of methods for registering routers,\n * loading route/service hooks, and booting the application. All Arkos-specific\n * setup (`app.build()`) must happen before the app starts\n * accepting requests.\n *\n * @example\n * ```ts\n * // Simple setup\n * import arkos from \"arkos\";\n *\n * const app = arkos();\n *\n * app.use(reportsRouter);\n *\n * app.listen();\n * ```\n *\n * @example\n * ```ts\n * // Custom HTTP server (e.g. for WebSockets)\n * import arkos from \"arkos\";\n * import http from \"http\";\n *\n * const app = arkos();\n *\n * app.use(reportsRouter);\n *\n * await app.build();\n *\n * const server = http.createServer(app);\n * app.listen(server)\n * ```\n *\n * @see {@link https://www.arkosjs.com/docs/core-concepts/routing/setup}\n */\nexport default function arkos(): Arkos {\n if (process.env.__ARKOS_CLI !== 'true')\n throw ExitError(\n `Arkos.js application must be started the built-in cli ${isProduction() ? \"'arkos start' in production\" : `'arkos dev' in development`} see https://www.arkosjs.com/docs/getting-started/installation#7-set-up-packagejson-scripts`,\n );\n\n if (instanciated)\n throw ExitError(`arkos() must be called only once, see ${docsLink}`);\n\n const app = applyArkosRouterProxy(express(), {}, 'app') as any as Arkos;\n setupApp(app);\n instanciated = true;\n\n function loadApp() {\n let _app = initializeApp(app);\n _app = addGlobalErrorHandler(_app);\n if (process.env.CLI_COMMAND) runtimeCliCommander.handle();\n return _app;\n }\n\n app.build = function () {\n if (state === 'built' || state === 'building')\n throw ExitError(`app.build() must only be called once, see ${docsLink}`);\n if (state === 'listening')\n throw ExitError(\n `app.build() must be called before app.listen(), see ${docsLink}`,\n );\n\n state = 'building';\n const _app = loadApp();\n state = 'built';\n return _app;\n };\n\n const originalListen = app.listen.bind(app) as any as Express['listen'];\n type UserCallback = (err?: Error) => void;\n\n const defaultCb = (\n port: number | string,\n host: string,\n cb?: UserCallback,\n ) => {\n logAppStartup(port, host);\n return cb || function () {};\n };\n\n app.listen = async function (...args: any[]): Promise<Server> {\n process.env.__ARKOS_SERVER_LISTENER = 'arkos';\n\n if (state === 'listening')\n throw ExitError(`app.listen() must only be called once, see ${docsLink}`);\n if (state === 'building')\n throw ExitError(\n `app.build() must be awaited before calling app.listen(), see ${docsLink}`,\n );\n\n if (state === 'idle') {\n state = 'listening';\n loadApp();\n }\n\n validateArkosConfig();\n\n const port = Number(process.env.__PORT || process.env.PORT || '8000');\n const host = process.env.__HOST! || process.env.HOST || '0.0.0.0';\n\n process.send?.({ started: true });\n if (process.env.__SKIP_LISTEN == 'true') return appServer;\n\n if ((args as any)?.length === 0 || typeof args[0] === 'function')\n appServer = originalListen(\n port,\n host,\n defaultCb(port, host, args[0] as UserCallback),\n );\n else if (args[0] instanceof Server || typeof args[0] === 'object')\n appServer = args[0].listen(\n port,\n host,\n defaultCb(port, host, args[1] as UserCallback),\n );\n\n return appServer;\n };\n\n return app;\n}\n\narkos.serveUploadDir = serveUploadDir;\n\nexport function getAppServer() {\n return appServer;\n}\n\n"]}
|
|
@@ -8,15 +8,23 @@ import { loginRequiredError } from "../../modules/auth/utils/auth-error-objects.
|
|
|
8
8
|
import errorPrettifier from "../../modules/base/utils/error-prettifier.js";
|
|
9
9
|
import deepmerge from "../../utils/helpers/deepmerge.helper.js";
|
|
10
10
|
import { defaultGatewayStore } from "./utils/memory-gateway-store.js";
|
|
11
|
-
import { ArkosBroadcastOperatorImpl, mountArkosSocketExtensions } from "./socket-extensions.js";
|
|
11
|
+
import { ArkosBroadcastOperatorImpl, mountArkosSocketExtensions, } from "./socket-extensions.js";
|
|
12
12
|
import { isAuthenticationEnabled, isUsingAuthentication, } from "../../utils/helpers/arkos-config.helpers.js";
|
|
13
13
|
import ExitError from "../../utils/helpers/exit-error.js";
|
|
14
14
|
import { getUserFileExtension } from "../../utils/helpers/fs.helpers.js";
|
|
15
15
|
import { BadRequestError, TooManyRequestsError, } from "../../modules/error-handler/utils/errors.js";
|
|
16
|
+
import { parseCookieHeader } from "../../modules/auth/utils/token-extraction.js";
|
|
17
|
+
function parseHandshakeCookies(socket) {
|
|
18
|
+
if (!socket.handshake || socket.handshake.cookies)
|
|
19
|
+
return;
|
|
20
|
+
const rawCookie = socket.handshake.headers?.cookie ?? socket.request?.headers?.cookie;
|
|
21
|
+
socket.handshake.cookies = parseCookieHeader(rawCookie);
|
|
22
|
+
}
|
|
16
23
|
export class IArkosGateway {
|
|
17
24
|
config;
|
|
18
25
|
events = [];
|
|
19
26
|
pipes = [];
|
|
27
|
+
middlewares = [];
|
|
20
28
|
gateways = [];
|
|
21
29
|
hooks = [];
|
|
22
30
|
_nsp;
|
|
@@ -35,7 +43,7 @@ export class IArkosGateway {
|
|
|
35
43
|
this.gateways.push(item);
|
|
36
44
|
}
|
|
37
45
|
else if (typeof item === "function") {
|
|
38
|
-
this.
|
|
46
|
+
this.middlewares.push(item);
|
|
39
47
|
}
|
|
40
48
|
else {
|
|
41
49
|
throw new Error(`Invalid value for gateway.use() — expected an ArkosGateway instance or a middleware function but received "${typeof item}".`);
|
|
@@ -96,13 +104,16 @@ export class IArkosGateway {
|
|
|
96
104
|
this.hooks.push({ type, handler });
|
|
97
105
|
return this;
|
|
98
106
|
}
|
|
99
|
-
register(io,
|
|
107
|
+
register(io, optionsOrCallback = {}, callback) {
|
|
108
|
+
const options = typeof optionsOrCallback === "function" ? {} : optionsOrCallback;
|
|
109
|
+
const onRegistered = typeof optionsOrCallback === "function" ? optionsOrCallback : callback;
|
|
100
110
|
if (io._arkosGatewayRegistered)
|
|
101
111
|
throw new Error(`The method gateway.register() can only be called once per io server instance. Use gateway.use() to compose gateways, see https://www.arkosjs.com/docs/guides/web-sockets/setup.`);
|
|
102
112
|
io._arkosGatewayRegistered = true;
|
|
103
113
|
this._register(io, undefined, this.hooks || [], this.pipes || [], options);
|
|
114
|
+
onRegistered?.();
|
|
104
115
|
}
|
|
105
|
-
_register(io, parentConfig, inheritedHooks = [], inheritedPipes = [], options = {}) {
|
|
116
|
+
_register(io, parentConfig, inheritedHooks = [], inheritedPipes = [], options = {}, inheritedMiddlewares = []) {
|
|
106
117
|
options.store = options.store ?? defaultGatewayStore;
|
|
107
118
|
const { store } = options;
|
|
108
119
|
const parentName = parentConfig?.name;
|
|
@@ -121,6 +132,7 @@ export class IArkosGateway {
|
|
|
121
132
|
parentConfig?.authentication !== false;
|
|
122
133
|
const resolvedRateLimit = this.config.rateLimit ?? parentConfig?.rateLimit;
|
|
123
134
|
const resolvedHooks = [...inheritedHooks, ...this.hooks];
|
|
135
|
+
const resolvedMiddlewares = [...inheritedMiddlewares, ...this.middlewares];
|
|
124
136
|
const connectHandlers = resolvedHooks
|
|
125
137
|
.filter((h) => h.type === "connection")
|
|
126
138
|
.map((h) => h.handler);
|
|
@@ -130,9 +142,13 @@ export class IArkosGateway {
|
|
|
130
142
|
const errorHandlers = resolvedHooks
|
|
131
143
|
.filter((h) => h.type === "error")
|
|
132
144
|
.map((h) => h.handler);
|
|
145
|
+
for (const middleware of resolvedMiddlewares) {
|
|
146
|
+
ns.use((socket, next) => middleware(socket, next));
|
|
147
|
+
}
|
|
133
148
|
if (resolvedAuth && isAuthenticationEnabled()) {
|
|
134
149
|
ns.use(async (socket, next) => {
|
|
135
150
|
socket = socket;
|
|
151
|
+
parseHandshakeCookies(socket);
|
|
136
152
|
const startTime = new Date().getTime();
|
|
137
153
|
try {
|
|
138
154
|
await authHookManager.runAuthenticate({
|
|
@@ -166,6 +182,7 @@ export class IArkosGateway {
|
|
|
166
182
|
For further help see https://www.arkosjs.com/docs/core-concepts/authentication/setup.`);
|
|
167
183
|
ns.on("connection", async (s) => {
|
|
168
184
|
const socket = s;
|
|
185
|
+
parseHandshakeCookies(socket);
|
|
169
186
|
socket.locals = {};
|
|
170
187
|
socket._arkos = { store, gatewayConfig: localConfig };
|
|
171
188
|
mountArkosSocketExtensions(socket);
|
|
@@ -334,7 +351,7 @@ For further help see https://www.arkosjs.com/docs/core-concepts/authentication/s
|
|
|
334
351
|
name: namespaceName,
|
|
335
352
|
authentication: resolvedAuth,
|
|
336
353
|
rateLimit: resolvedRateLimit,
|
|
337
|
-
}, resolvedHooks, inheritedPipes, options);
|
|
354
|
+
}, resolvedHooks, inheritedPipes, options, resolvedMiddlewares);
|
|
338
355
|
}
|
|
339
356
|
}
|
|
340
357
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arkos-gateway.js","sourceRoot":"","sources":["../../../../src/components/arkos-gateway/arkos-gateway.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,EAAE,cAAc,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S,CACV,CAAC;wBAEF,IAAI,WAAW,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC,SAAS,EAAE,CAAC;4BACzC,GAAG,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;wBACzB,CAAC;oBACH,CAAC;oBAAC,OAAO,GAAQ,EAAE,CAAC;wBAClB,wBAAwB,CACtB,GAAG,EACH,MAAM,EACN,aAAa,EACb;4BACE,SAAS;4BACT,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI;4BAC3B,KAAK,EAAE,WAAW,CAAC,KAAK;yBACzB,EACD,GAAG,CACJ,CAAC;oBACJ,CAAC;gBACH,CAAC,CAAC,CAAC;YACL,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClC,KAAK,CAAC,SAAS,CACb,EAAE,EACF;gBACE,IAAI,EAAE,aAAa;gBACnB,cAAc,EAAE,YAAY;gBAC5B,SAAS,EAAE,iBAAiB;aAC7B,EACD,aAAa,EACb,cAAc,EACd,OAAO,CACR,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AA6BD,SAAS,YAAY,CAAC,MAA0B;IAC9C,OAAO,IAAI,aAAa,CAAC,MAAM,CAAC,CAAC;AACnC,CAAC;AAED,eAAe,YAAY,CAAC","sourcesContent":["import {\n ArkosGatewayConfig,\n ArkosGatewayErrorHandler,\n ArkosGatewayEventConfig,\n ArkosGatewayEventEntry,\n ArkosGatewayHandler,\n ArkosGatewayHookHandler,\n ArkosGatewayHookType,\n ArkosGatewayPipe,\n ArkosGatewayConnectionHandler,\n ArkosSocket,\n ArkosGatewayRegisterOptions,\n ArkosBroadcastOperator,\n ArkosEmitTarget,\n} from \"./types\";\nimport { Validator } from \"../../types/validation/validator\";\nimport { BroadcastOperator, Namespace, Server } from \"socket.io\";\nimport { authActionService, authService } from \"../../exports/services\";\nimport { checkRateLimit, clearRateLimitForSocket } from \"./utils/rate-limiter\";\nimport {\n handleArkosGatewayErrors,\n runArkosGatewayPipes,\n handleGatewayEventLog,\n handleGatewayLifecycleLog,\n} from \"./utils/helpers\";\nimport authHookManager from \"../../modules/auth/utils/auth-hooks-manager\";\nimport { getArkosConfig } from \"../../server\";\nimport validationManager from \"../../types/validation/validation-manager\";\nimport { loginRequiredError } from \"../../modules/auth/utils/auth-error-objects\";\nimport errorPrettifier from \"../../modules/base/utils/error-prettifier\";\nimport deepmerge from \"../../utils/helpers/deepmerge.helper\";\nimport { defaultGatewayStore } from \"./utils/memory-gateway-store\";\nimport { ArkosBroadcastOperatorImpl, mountArkosSocketExtensions } from \"./socket-extensions\";\nimport {\n isAuthenticationEnabled,\n isUsingAuthentication,\n} from \"../../utils/helpers/arkos-config.helpers\";\nimport ExitError from \"../../utils/helpers/exit-error\";\nimport { getUserFileExtension } from \"../../utils/helpers/fs.helpers\";\nimport {\n BadRequestError,\n TooManyRequestsError,\n} from \"../../modules/error-handler/utils/errors\";\n\nexport class IArkosGateway {\n private config: ArkosGatewayConfig;\n private events: ArkosGatewayEventEntry[] = [];\n private pipes: ArkosGatewayPipe[] = [];\n private gateways: IArkosGateway[] = [];\n private hooks: {\n type: ArkosGatewayHookType;\n handler: ArkosGatewayHookHandler;\n }[] = [];\n private _nsp!: Namespace\n\n constructor(config: ArkosGatewayConfig) {\n this.config = config;\n this.config.name = config.name ?? \"web-socket\";\n }\n\n get nsp(): Omit<Namespace, keyof ArkosEmitTarget | keyof BroadcastOperator<any, any>> & ArkosBroadcastOperator {\n if (!this._nsp) throw new Error(`gateway.nsp accessed before register()`);\n return new ArkosBroadcastOperatorImpl(this._nsp.sockets, this._nsp) as any;\n }\n\n /**\n * Register a Socket.io connection-level middleware — runs before a socket\n * is accepted into this gateway's namespace. Also accepts a child\n * `ArkosGateway` which will inherit this gateway's name as prefix along\n * with its auth, rateLimit, and pipes.\n *\n * @example\n * chatGateway.use((socket, next) => {\n * console.log(\"incoming connection\", socket.id)\n * })\n *\n * // nested gateway\n * chatGateway.use(notificationsGateway)\n */\n use(...middlewareOrGateway: Array<ArkosGatewayPipe | IArkosGateway>): this {\n for (const item of middlewareOrGateway) {\n if (item instanceof IArkosGateway) {\n this.gateways.push(item);\n } else if (typeof item === \"function\") {\n this.pipes.push(item as ArkosGatewayPipe);\n } else {\n throw new Error(\n `Invalid value for gateway.use() — expected an ArkosGateway instance or a middleware function but received \"${typeof item}\".`\n );\n }\n }\n return this;\n }\n\n /**\n * Register a pipe — middleware that runs before event handlers.\n *\n * When called with a function only, the pipe runs before every event\n * handler in this gateway and drills down to child gateways.\n *\n * When called with an event config object, the pipe runs only for that\n * specific event.\n *\n * @example\n * // runs before every event in this gateway\n * chatGateway.pipe((socket, data) => {\n * })\n *\n * // runs only before \"send_message\"\n * chatGateway.pipe({ event: \"send_message\" }, (socket, data) => {\n * })\n */\n pipe(fn: ArkosGatewayPipe): this;\n pipe<TSchema extends Validator = any>(\n eventConfig: { event: string },\n fn: ArkosGatewayPipe\n ): this;\n pipe<TSchema extends Validator = any>(\n fnOrConfig: ArkosGatewayPipe | ArkosGatewayEventConfig<TSchema>,\n fn?: ArkosGatewayPipe\n ): this {\n if (typeof fnOrConfig === \"function\") {\n this.pipes.push(fnOrConfig);\n } else if (fnOrConfig && typeof fnOrConfig === \"object\" && fn) {\n const entry = this.events.find(\n (e) => e.config.event === fnOrConfig.event\n );\n if (entry) {\n entry.pipes = entry.pipes ?? [];\n entry.pipes.push(fn);\n } else {\n this.events.push({\n config: { event: fnOrConfig.event, _pipeOnly: true } as any,\n handler: null as any,\n pipes: [fn],\n });\n }\n } else {\n throw new Error(\n `Invalid arguments for gateway.pipe() — pass a middleware function, or an event config object followed by a middleware function.`\n );\n }\n return this;\n }\n\n /**\n * Register an event handler.\n *\n * @example\n * chatGateway.on(\n * { event: \"send_message\", validation: MessageSchema, ack: true },\n * (socket, data, ack) => {\n * socket.to(data.room).emit(\"receive_message\", data)\n * ack?.({ status: \"ok\" })\n * }\n * )\n */\n on<TSchema extends Validator = any>(\n eventConfig: ArkosGatewayEventConfig<TSchema>,\n handler: ArkosGatewayHandler\n ): this {\n if (eventConfig.disabled) return this;\n\n if (eventConfig.authorization && this.config.authentication === false) {\n throw new Error(\n `Event \"${eventConfig.event}\" on \"${this.config.name}\" gateway defines authorization rules ` +\n `but the gateway has authentication: false. Enable authentication on the gateway to use per-event authentication.`\n );\n }\n\n const deferred = this.events.find(\n (e) => (e.config as any)._pipeOnly && e.config.event === eventConfig.event\n );\n\n const entry: ArkosGatewayEventEntry = {\n config: eventConfig,\n handler,\n pipes: [...this.pipes, ...(deferred?.pipes ?? [])],\n };\n\n if (deferred) {\n const idx = this.events.indexOf(deferred);\n this.events.splice(idx, 1, entry);\n } else {\n this.events.push(entry);\n }\n\n if (typeof eventConfig?.authorization == \"object\")\n // To reuse later on\n (eventConfig.authorization as any)._authAction = authActionService.add(\n eventConfig.authorization!.action,\n eventConfig.authorization!.resource,\n {\n [eventConfig.authorization!.action]: eventConfig.authorization?.rule,\n }\n );\n\n return this;\n }\n\n /**\n * Register a lifecycle hook.\n *\n * - `\"connection\"` — called after a socket successfully connects and passes authentication.\n * - `\"disconnect\"` — called when a socket disconnects.\n * - `\"error\"` — called when an error is thrown inside any event handler.\n * If not registered, Arkos emits a default `\"error\"` event to the socket.\n *\n * @example\n * chatGateway.hook(\"connection\", (socket) => {\n * console.log(\"connected\", socket.user.id)\n * })\n *\n * chatGateway.hook(\"error\", (err, socket) => {\n * socket.emit(\"error\", { message: err.message })\n * })\n */\n hook(type: \"connection\", handler: ArkosGatewayConnectionHandler): this;\n hook(type: \"disconnect\", handler: ArkosGatewayConnectionHandler): this;\n hook(type: \"error\", handler: ArkosGatewayErrorHandler): this;\n hook(\n type: ArkosGatewayHookType,\n handler: ArkosGatewayConnectionHandler | ArkosGatewayErrorHandler\n ): this {\n this.hooks.push({ type, handler });\n return this;\n }\n\n /**\n * Wire this gateway into a Socket.io `Server` instance.\n * Registers the namespace, auth middleware, rate limiting, pipes,\n * and all event handlers — then recurses into child gateways.\n *\n * @example\n * const io = new Server(server)\n * chatGateway.register(io)\n */\n register(io: Server, options: ArkosGatewayRegisterOptions = {}): void {\n if ((io as any)._arkosGatewayRegistered)\n throw new Error(\n `The method gateway.register() can only be called once per io server instance. Use gateway.use() to compose gateways, see https://www.arkosjs.com/docs/guides/web-sockets/setup.`\n );\n (io as any)._arkosGatewayRegistered = true;\n this._register(io, undefined, this.hooks || [], this.pipes || [], options);\n }\n\n private _register(\n io: Server,\n parentConfig?: ArkosGatewayConfig,\n inheritedHooks: {\n type: ArkosGatewayHookType;\n handler: ArkosGatewayHookHandler;\n }[] = [],\n inheritedPipes: ArkosGatewayPipe[] = [],\n options: ArkosGatewayRegisterOptions = {}\n ): void {\n options.store = options.store ?? defaultGatewayStore;\n const { store } = options;\n\n const parentName = parentConfig?.name;\n const ownName = this.config.name;\n this.config = deepmerge(parentConfig || {}, this.config, {\n arrayMerge: (_, sourceArray) => sourceArray,\n });\n this.config.name = ownName;\n const localConfig = this.config;\n\n const namespaceName = parentName\n ? `${parentName.replace(/\\/$/, \"\")}/${ownName.replace(/^\\//, \"\")}`\n : (ownName ?? \"\");\n\n const ns = io.of(namespaceName);\n this._nsp = ns;\n\n const resolvedAuth =\n this.config.authentication !== false &&\n parentConfig?.authentication !== false;\n\n const resolvedRateLimit = this.config.rateLimit ?? parentConfig?.rateLimit;\n const resolvedHooks = [...inheritedHooks, ...this.hooks];\n\n const connectHandlers = resolvedHooks\n .filter((h) => h.type === \"connection\")\n .map((h) => h.handler as ArkosGatewayConnectionHandler);\n\n const disconnectHandlers = resolvedHooks\n .filter((h) => h.type === \"disconnect\")\n .map((h) => h.handler as ArkosGatewayConnectionHandler);\n\n const errorHandlers = resolvedHooks\n .filter((h) => h.type === \"error\")\n .map((h) => h.handler as ArkosGatewayErrorHandler);\n\n if (resolvedAuth && isAuthenticationEnabled()) {\n ns.use(async (socket: any, next) => {\n socket = socket as ArkosSocket;\n const startTime = new Date().getTime();\n try {\n await authHookManager.runAuthenticate(\n {\n context: socket,\n done: (err?: any) => {\n if (err) throw err;\n next();\n },\n },\n async (socket) => {\n const user = await authService.getAuthenticatedUser(socket);\n if (!user) throw loginRequiredError;\n return user;\n },\n \"currentUser\"\n );\n } catch (err: any) {\n handleArkosGatewayErrors(err, socket, errorHandlers, {\n startTime,\n namespace: this.config.name,\n event: \"authentication\",\n });\n next(err);\n }\n });\n } else if (\n (this.config.authentication || parentConfig?.authentication) &&\n !isUsingAuthentication()\n )\n throw ExitError(\n `Trying to authenticate gateway ${this.config.name ? `${this.config.name}` : \"\"} without choosing an authentication mode under arkos.config.${getUserFileExtension()}.\n\nFor further help see https://www.arkosjs.com/docs/core-concepts/authentication/setup.`\n );\n\n ns.on(\"connection\", async (s) => {\n const socket = s as ArkosSocket;\n socket.locals = {};\n\n socket._arkos = { store, gatewayConfig: localConfig };\n mountArkosSocketExtensions(socket);\n\n handleGatewayLifecycleLog(this.config.name, \"connected\", socket.id);\n const connectionStartTime = new Date().getTime();\n\n if (socket.currentUser?.id)\n socket.join(`arkos::user:${socket.currentUser.id}`);\n\n try {\n for (const handler of connectHandlers) await handler(socket);\n } catch (err: any) {\n handleArkosGatewayErrors(err, socket, [], {\n startTime: connectionStartTime,\n namespace: this.config.name,\n event: \"connection\",\n });\n return;\n }\n\n socket.on(\"disconnect\", async () => {\n handleGatewayLifecycleLog(this.config.name, \"disconnected\", socket.id);\n\n await clearRateLimitForSocket(socket.id, store);\n try {\n for (const handler of disconnectHandlers) await handler(socket);\n } catch (err) {\n handleArkosGatewayErrors(err, socket, [], {\n startTime: connectionStartTime,\n namespace: this.config.name,\n event: \"disconnection\",\n });\n }\n });\n\n for (const entry of this.events) {\n if ((entry.config as any)._pipeOnly || !entry.handler) continue;\n\n const { config: eventConfig, handler, pipes: eventPipes = [] } = entry;\n\n if (\n (this.config.authentication || parentConfig?.authentication) &&\n !isUsingAuthentication()\n )\n throw ExitError(\n `Trying to use authorization gateway.on(\"${eventConfig.event}\") without choosing an authentication mode under arkos.config.${getUserFileExtension()}.\n\nFor further help see https://www.arkosjs.com/docs/core-concepts/authentication/setup.`\n );\n\n socket.on(eventConfig.event, async (...args: any[]) => {\n socket.locals = {};\n const startTime = new Date().getTime();\n let data = args[0];\n\n const ack =\n typeof args[args.length - 1] === \"function\"\n ? args[args.length - 1]\n : undefined;\n\n let ackCalled = false;\n const wrappedAck = ack\n ? (...response: any) => {\n ackCalled = true;\n ack(...response);\n }\n : undefined;\n\n function resolveDedup() {\n if (\n eventConfig.dedup === false ||\n localConfig.dedup === false ||\n parentConfig?.dedup === false\n )\n return null;\n\n return {\n enabled: true,\n ttl: 3600,\n ...parentConfig?.dedup,\n ...localConfig?.dedup,\n ...eventConfig?.dedup,\n };\n }\n\n const dedupOpt = resolveDedup();\n\n try {\n const meta = data?._meta || {};\n const resolvedMaxAge =\n eventConfig.maxAge ?? localConfig.maxAge ?? parentConfig?.maxAge;\n\n if (resolvedMaxAge && !meta.timestamp)\n throw new BadRequestError(\n \"Missing _meta.timestamp for maxAge deduplication\"\n );\n\n if (meta.timestamp !== undefined) {\n const timestamp = new Date(meta.timestamp);\n\n if (isNaN(timestamp.getTime())) {\n throw new BadRequestError(\n \"Invalid data._meta.timestamp\",\n \"InvalidTimestamp\"\n );\n }\n\n const age = Date.now() - timestamp.getTime();\n\n if (age + 1000 < 0)\n throw new BadRequestError(\n \"Timestamp is in the future\",\n \"FutureTimestamp\"\n );\n\n if (resolvedMaxAge && age > resolvedMaxAge) {\n throw new BadRequestError(\"Message is too old\", \"StaleMessage\");\n }\n }\n\n if (dedupOpt && dedupOpt?.enabled !== false) {\n if (!meta?.mid)\n throw new BadRequestError(\n \"Missing data._meta.mid in your payload for deduplication\",\n \"MissingDedupMessageId\",\n { data }\n );\n\n if (typeof meta.mid !== \"string\" || meta.mid.trim() === \"\")\n throw new BadRequestError(\n \"Invalid data._meta.mid, it must be a non-empty string\",\n \"InvalidMessageId\"\n );\n\n const key = `arkos::dedup:${eventConfig.event}:${meta.mid}`;\n const ttl = dedupOpt?.ttl ?? 3600;\n\n const acquired = await store.setIfNotExists(key, ttl);\n\n if (acquired === false)\n return wrappedAck?.({\n success: true,\n duplicate: true,\n });\n\n const { _meta, ...payload } = data;\n data = payload;\n\n socket.meta = meta;\n }\n\n const rateLimitOptions = eventConfig.rateLimit ?? resolvedRateLimit;\n if (rateLimitOptions !== false) {\n const { allowed, retryAfter } = await checkRateLimit(\n socket.id,\n eventConfig.event,\n rateLimitOptions || {},\n options.store!\n );\n if (!allowed) {\n throw new TooManyRequestsError(undefined, undefined, {\n retryAfter,\n });\n }\n }\n\n if (\n typeof eventConfig.authorization === \"object\" &&\n resolvedAuth &&\n isAuthenticationEnabled()\n ) {\n await authHookManager.runAuthorize(\n { context: socket, done: () => { } },\n (eventConfig?.authorization as any)?._authAction,\n \"currentUser\"\n );\n }\n\n if (eventConfig.validation) {\n const arkosConfig = getArkosConfig();\n const {\n validationFn,\n isValidValidator,\n validatorName,\n validatorNameType,\n } = validationManager;\n\n if (!isValidValidator(eventConfig.validation))\n throw new Error(\n `Your validation resolver is set to ${arkosConfig.validation!.resolver}, ` +\n `please provide a valid ${validatorName} in order to use { validation: ${validatorNameType} } ` +\n `under event handler \"${eventConfig.event}\" in \"${this.config.name}\" gateway.`\n );\n\n const shouldValidate = validationManager.shouldValidate(\n eventConfig.validation,\n data\n );\n\n if (shouldValidate === \"prohibit\")\n throw new BadRequestError(\n \"Event data is not allowed for this event.\",\n \"EventDataNotAllowed\",\n { data }\n );\n else if (shouldValidate === \"passthrough\") data = data;\n else {\n try {\n data = await (validationFn as any)(\n eventConfig.validation,\n data\n );\n } catch (err: any) {\n const { validationConfig } = validationManager;\n\n const resolver = validationConfig?.resolver;\n const isZod = validationConfig?.resolver === \"zod\";\n\n const prettifiedError = errorPrettifier.prettify(\n resolver as any,\n err\n );\n const error = prettifiedError[0];\n\n throw new BadRequestError(\n error.message,\n `InvalidData`,\n isZod ? err.format() : err\n );\n }\n }\n }\n\n socket.data = data;\n\n await runArkosGatewayPipes(\n [...inheritedPipes, ...eventPipes],\n socket,\n data\n );\n\n await handler(socket, data, wrappedAck);\n\n handleGatewayEventLog(\n this.config.name,\n eventConfig.event,\n 200,\n startTime\n );\n\n if (eventConfig.ack && ack && !ackCalled) {\n ack({ success: true });\n }\n } catch (err: any) {\n handleArkosGatewayErrors(\n err,\n socket,\n errorHandlers,\n {\n startTime,\n namespace: this.config.name,\n event: eventConfig.event,\n },\n ack\n );\n }\n });\n }\n });\n\n for (const child of this.gateways) {\n child._register(\n io,\n {\n name: namespaceName,\n authentication: resolvedAuth,\n rateLimit: resolvedRateLimit,\n },\n resolvedHooks,\n inheritedPipes,\n options\n );\n }\n }\n}\n\n/**\n * Creates an Arkos WebSocket Gateway backed by Socket.io.\n *\n * Handles authentication, validation, rate limiting, pipes,\n * error handling, and nested gateways — all declaratively.\n * Enhances every connected socket with `socket.user()`, `socket.peer()`,\n * `socket.retry()`, and automatic `_meta` injection on outgoing emits.\n *\n * @example\n * ```ts\n * const chatGateway = ArkosGateway({\n * name: \"chat\",\n * authentication: true,\n * rateLimit: { windowMs: 60_000, max: 200 },\n * })\n *\n * chatGateway.on(\n * { event: \"send_message\", validation: MessageSchema, ack: true },\n * (socket, data, ack) => {\n * socket.to(data.room).emit(\"receive_message\", data)\n * ack?.({ status: \"ok\" })\n * }\n * )\n * ```\n * @since 1.7.0-canary.18\n * @see {@link https://www.arkosjs.com/docs/core-concepts/components/gateways}\n */\nfunction ArkosGateway(config: ArkosGatewayConfig) {\n return new IArkosGateway(config);\n}\n\nexport default ArkosGateway;\n"]}
|
|
1
|
+
{"version":3,"file":"arkos-gateway.js","sourceRoot":"","sources":["../../../../src/components/arkos-gateway/arkos-gateway.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACxE,OAAO,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC/E,OAAO,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N,aAAa,EACb;4BACE,SAAS;4BACT,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,IAAI;4BAC3B,KAAK,EAAE,WAAW,CAAC,KAAK;yBACzB,EACD,GAAG,CACJ,CAAC;oBACJ,CAAC;gBACH,CAAC,CAAC,CAAC;YACL,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,QAAQ,EAAE,CAAC;YAClC,KAAK,CAAC,SAAS,CACb,EAAE,EACF;gBACE,IAAI,EAAE,aAAa;gBACnB,cAAc,EAAE,YAAY;gBAC5B,SAAS,EAAE,iBAAiB;aAC7B,EACD,aAAa,EACb,cAAc,EACd,OAAO,EACP,mBAAmB,CACpB,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AA6BD,SAAS,YAAY,CAAC,MAA0B;IAC9C,OAAO,IAAI,aAAa,CAAC,MAAM,CAAC,CAAC;AACnC,CAAC;AAED,eAAe,YAAY,CAAC","sourcesContent":["import {\n ArkosGatewayConfig,\n ArkosGatewayErrorHandler,\n ArkosGatewayEventConfig,\n ArkosGatewayEventEntry,\n ArkosGatewayHandler,\n ArkosGatewayHookHandler,\n ArkosGatewayHookType,\n ArkosGatewayPipe,\n ArkosGatewayMiddleware,\n ArkosGatewayConnectionHandler,\n ArkosSocket,\n ArkosGatewayRegisterOptions,\n ArkosBroadcastOperator,\n ArkosEmitTarget,\n} from \"./types\";\nimport { Validator } from \"../../types/validation/validator\";\nimport { BroadcastOperator, Namespace, Server } from \"socket.io\";\nimport { authActionService, authService } from \"../../exports/services\";\nimport { checkRateLimit, clearRateLimitForSocket } from \"./utils/rate-limiter\";\nimport {\n handleArkosGatewayErrors,\n runArkosGatewayPipes,\n handleGatewayEventLog,\n handleGatewayLifecycleLog,\n} from \"./utils/helpers\";\nimport authHookManager from \"../../modules/auth/utils/auth-hooks-manager\";\nimport { getArkosConfig } from \"../../server\";\nimport validationManager from \"../../types/validation/validation-manager\";\nimport { loginRequiredError } from \"../../modules/auth/utils/auth-error-objects\";\nimport errorPrettifier from \"../../modules/base/utils/error-prettifier\";\nimport deepmerge from \"../../utils/helpers/deepmerge.helper\";\nimport { defaultGatewayStore } from \"./utils/memory-gateway-store\";\nimport {\n ArkosBroadcastOperatorImpl,\n mountArkosSocketExtensions,\n} from \"./socket-extensions\";\nimport {\n isAuthenticationEnabled,\n isUsingAuthentication,\n} from \"../../utils/helpers/arkos-config.helpers\";\nimport ExitError from \"../../utils/helpers/exit-error\";\nimport { getUserFileExtension } from \"../../utils/helpers/fs.helpers\";\nimport {\n BadRequestError,\n TooManyRequestsError,\n} from \"../../modules/error-handler/utils/errors\";\nimport { parseCookieHeader } from \"../../modules/auth/utils/token-extraction\";\n\nfunction parseHandshakeCookies(socket: ArkosSocket): void {\n if (!socket.handshake || socket.handshake.cookies) return;\n\n const rawCookie =\n socket.handshake.headers?.cookie ?? socket.request?.headers?.cookie;\n\n socket.handshake.cookies = parseCookieHeader(rawCookie);\n}\n\nexport class IArkosGateway {\n private config: ArkosGatewayConfig;\n private events: ArkosGatewayEventEntry[] = [];\n private pipes: ArkosGatewayPipe[] = [];\n private middlewares: ArkosGatewayMiddleware[] = [];\n private gateways: IArkosGateway[] = [];\n private hooks: {\n type: ArkosGatewayHookType;\n handler: ArkosGatewayHookHandler;\n }[] = [];\n private _nsp!: Namespace;\n\n constructor(config: ArkosGatewayConfig) {\n this.config = config;\n this.config.name = config.name ?? \"web-socket\";\n }\n\n get nsp(): Omit<\n Namespace,\n keyof ArkosEmitTarget | keyof BroadcastOperator<any, any>\n > &\n ArkosBroadcastOperator {\n if (!this._nsp) throw new Error(`gateway.nsp accessed before register()`);\n return new ArkosBroadcastOperatorImpl(this._nsp.sockets, this._nsp) as any;\n }\n\n /**\n * Register a Socket.io connection-level middleware — runs before a socket\n * is accepted into this gateway's namespace, and before authentication.\n * Also accepts a child `ArkosGateway` which will inherit this gateway's\n * name as prefix along with its auth, rateLimit, and pipes.\n *\n * @example\n * chatGateway.use((socket, next) => {\n * console.log(\"incoming connection\", socket.id)\n * })\n *\n * // nested gateway\n * chatGateway.use(notificationsGateway)\n */\n use(\n ...middlewareOrGateway: Array<ArkosGatewayMiddleware | IArkosGateway>\n ): this {\n for (const item of middlewareOrGateway) {\n if (item instanceof IArkosGateway) {\n this.gateways.push(item);\n } else if (typeof item === \"function\") {\n this.middlewares.push(item as ArkosGatewayMiddleware);\n } else {\n throw new Error(\n `Invalid value for gateway.use() — expected an ArkosGateway instance or a middleware function but received \"${typeof item}\".`,\n );\n }\n }\n return this;\n }\n\n /**\n * Register a pipe — middleware that runs before event handlers.\n *\n * When called with a function only, the pipe runs before every event\n * handler in this gateway and drills down to child gateways.\n *\n * When called with an event config object, the pipe runs only for that\n * specific event.\n *\n * @example\n * // runs before every event in this gateway\n * chatGateway.pipe((socket, data) => {\n * })\n *\n * // runs only before \"send_message\"\n * chatGateway.pipe({ event: \"send_message\" }, (socket, data) => {\n * })\n */\n pipe(fn: ArkosGatewayPipe): this;\n pipe<TSchema extends Validator = any>(\n eventConfig: { event: string },\n fn: ArkosGatewayPipe,\n ): this;\n pipe<TSchema extends Validator = any>(\n fnOrConfig: ArkosGatewayPipe | ArkosGatewayEventConfig<TSchema>,\n fn?: ArkosGatewayPipe,\n ): this {\n if (typeof fnOrConfig === \"function\") {\n this.pipes.push(fnOrConfig);\n } else if (fnOrConfig && typeof fnOrConfig === \"object\" && fn) {\n const entry = this.events.find(\n (e) => e.config.event === fnOrConfig.event,\n );\n if (entry) {\n entry.pipes = entry.pipes ?? [];\n entry.pipes.push(fn);\n } else {\n this.events.push({\n config: { event: fnOrConfig.event, _pipeOnly: true } as any,\n handler: null as any,\n pipes: [fn],\n });\n }\n } else {\n throw new Error(\n `Invalid arguments for gateway.pipe() — pass a middleware function, or an event config object followed by a middleware function.`,\n );\n }\n return this;\n }\n\n /**\n * Register an event handler.\n *\n * @example\n * chatGateway.on(\n * { event: \"send_message\", validation: MessageSchema, ack: true },\n * (socket, data, ack) => {\n * socket.to(data.room).emit(\"receive_message\", data)\n * ack?.({ status: \"ok\" })\n * }\n * )\n */\n on<TSchema extends Validator = any>(\n eventConfig: ArkosGatewayEventConfig<TSchema>,\n handler: ArkosGatewayHandler<TSchema>,\n ): this {\n if (eventConfig.disabled) return this;\n\n if (eventConfig.authorization && this.config.authentication === false) {\n throw new Error(\n `Event \"${eventConfig.event}\" on \"${this.config.name}\" gateway defines authorization rules ` +\n `but the gateway has authentication: false. Enable authentication on the gateway to use per-event authentication.`,\n );\n }\n\n const deferred = this.events.find(\n (e) =>\n (e.config as any)._pipeOnly && e.config.event === eventConfig.event,\n );\n\n const entry: ArkosGatewayEventEntry = {\n config: eventConfig,\n handler,\n pipes: [...this.pipes, ...(deferred?.pipes ?? [])],\n };\n\n if (deferred) {\n const idx = this.events.indexOf(deferred);\n this.events.splice(idx, 1, entry);\n } else {\n this.events.push(entry);\n }\n\n if (typeof eventConfig?.authorization == \"object\")\n // To reuse later on\n (eventConfig.authorization as any)._authAction = authActionService.add(\n eventConfig.authorization!.action,\n eventConfig.authorization!.resource,\n {\n [eventConfig.authorization!.action]: eventConfig.authorization?.rule,\n },\n );\n\n return this;\n }\n\n /**\n * Register a lifecycle hook.\n *\n * - `\"connection\"` — called after a socket successfully connects and passes authentication.\n * - `\"disconnect\"` — called when a socket disconnects.\n * - `\"error\"` — called when an error is thrown inside any event handler.\n * If not registered, Arkos emits a default `\"error\"` event to the socket.\n *\n * @example\n * chatGateway.hook(\"connection\", (socket) => {\n * console.log(\"connected\", socket.user.id)\n * })\n *\n * chatGateway.hook(\"error\", (err, socket) => {\n * socket.emit(\"error\", { message: err.message })\n * })\n */\n hook(type: \"connection\", handler: ArkosGatewayConnectionHandler): this;\n hook(type: \"disconnect\", handler: ArkosGatewayConnectionHandler): this;\n hook(type: \"error\", handler: ArkosGatewayErrorHandler): this;\n hook(\n type: ArkosGatewayHookType,\n handler: ArkosGatewayConnectionHandler | ArkosGatewayErrorHandler,\n ): this {\n this.hooks.push({ type, handler });\n return this;\n }\n\n /**\n * Wire this gateway into a Socket.io `Server` instance.\n * Registers the namespace, auth middleware, rate limiting, pipes,\n * and all event handlers — then recurses into child gateways.\n *\n * @example\n * const io = new Server(server)\n * chatGateway.register(io)\n *\n * // with options\n * chatGateway.register(io, { store: redisStore })\n *\n * // run code once the gateway is mounted\n * chatGateway.register(io, { store: redisStore }, () => {\n * console.log(\"gateway mounted on\", chatGateway.nsp.name)\n * })\n *\n * The callback overload is available from 1.8.0-rc.\n */\n register(io: Server, callback?: () => void): void;\n register(\n io: Server,\n options: ArkosGatewayRegisterOptions,\n callback?: () => void,\n ): void;\n register(\n io: Server,\n optionsOrCallback: ArkosGatewayRegisterOptions | (() => void) = {},\n callback?: () => void,\n ): void {\n const options =\n typeof optionsOrCallback === \"function\" ? {} : optionsOrCallback;\n const onRegistered =\n typeof optionsOrCallback === \"function\" ? optionsOrCallback : callback;\n\n if ((io as any)._arkosGatewayRegistered)\n throw new Error(\n `The method gateway.register() can only be called once per io server instance. Use gateway.use() to compose gateways, see https://www.arkosjs.com/docs/guides/web-sockets/setup.`,\n );\n (io as any)._arkosGatewayRegistered = true;\n this._register(io, undefined, this.hooks || [], this.pipes || [], options);\n onRegistered?.();\n }\n\n private _register(\n io: Server,\n parentConfig?: ArkosGatewayConfig,\n inheritedHooks: {\n type: ArkosGatewayHookType;\n handler: ArkosGatewayHookHandler;\n }[] = [],\n inheritedPipes: ArkosGatewayPipe[] = [],\n options: ArkosGatewayRegisterOptions = {},\n inheritedMiddlewares: ArkosGatewayMiddleware[] = [],\n ): void {\n options.store = options.store ?? defaultGatewayStore;\n const { store } = options;\n\n const parentName = parentConfig?.name;\n const ownName = this.config.name;\n this.config = deepmerge(parentConfig || {}, this.config, {\n arrayMerge: (_, sourceArray) => sourceArray,\n });\n this.config.name = ownName;\n const localConfig = this.config;\n\n const namespaceName = parentName\n ? `${parentName.replace(/\\/$/, \"\")}/${ownName.replace(/^\\//, \"\")}`\n : (ownName ?? \"\");\n\n const ns = io.of(namespaceName);\n this._nsp = ns;\n\n const resolvedAuth =\n this.config.authentication !== false &&\n parentConfig?.authentication !== false;\n\n const resolvedRateLimit = this.config.rateLimit ?? parentConfig?.rateLimit;\n const resolvedHooks = [...inheritedHooks, ...this.hooks];\n const resolvedMiddlewares = [...inheritedMiddlewares, ...this.middlewares];\n\n const connectHandlers = resolvedHooks\n .filter((h) => h.type === \"connection\")\n .map((h) => h.handler as ArkosGatewayConnectionHandler);\n\n const disconnectHandlers = resolvedHooks\n .filter((h) => h.type === \"disconnect\")\n .map((h) => h.handler as ArkosGatewayConnectionHandler);\n\n const errorHandlers = resolvedHooks\n .filter((h) => h.type === \"error\")\n .map((h) => h.handler as ArkosGatewayErrorHandler);\n\n for (const middleware of resolvedMiddlewares) {\n ns.use((socket, next) => middleware(socket as ArkosSocket, next));\n }\n\n if (resolvedAuth && isAuthenticationEnabled()) {\n ns.use(async (socket: any, next) => {\n socket = socket as ArkosSocket;\n parseHandshakeCookies(socket);\n const startTime = new Date().getTime();\n try {\n await authHookManager.runAuthenticate(\n {\n context: socket,\n done: (err?: any) => {\n if (err) throw err;\n next();\n },\n },\n async (socket) => {\n const user = await authService.getAuthenticatedUser(socket);\n if (!user) throw loginRequiredError;\n return user;\n },\n \"currentUser\",\n );\n } catch (err: any) {\n handleArkosGatewayErrors(err, socket, errorHandlers, {\n startTime,\n namespace: this.config.name,\n event: \"authentication\",\n });\n next(err);\n }\n });\n } else if (\n (this.config.authentication || parentConfig?.authentication) &&\n !isUsingAuthentication()\n )\n throw ExitError(\n `Trying to authenticate gateway ${this.config.name ? `${this.config.name}` : \"\"} without choosing an authentication mode under arkos.config.${getUserFileExtension()}.\n\nFor further help see https://www.arkosjs.com/docs/core-concepts/authentication/setup.`,\n );\n\n ns.on(\"connection\", async (s) => {\n const socket = s as ArkosSocket;\n parseHandshakeCookies(socket);\n socket.locals = {};\n\n socket._arkos = { store, gatewayConfig: localConfig };\n mountArkosSocketExtensions(socket);\n\n handleGatewayLifecycleLog(this.config.name, \"connected\", socket.id);\n const connectionStartTime = new Date().getTime();\n\n if (socket.currentUser?.id)\n socket.join(`arkos::user:${socket.currentUser.id}`);\n\n try {\n for (const handler of connectHandlers) await handler(socket);\n } catch (err: any) {\n handleArkosGatewayErrors(err, socket, [], {\n startTime: connectionStartTime,\n namespace: this.config.name,\n event: \"connection\",\n });\n return;\n }\n\n socket.on(\"disconnect\", async () => {\n handleGatewayLifecycleLog(this.config.name, \"disconnected\", socket.id);\n\n await clearRateLimitForSocket(socket.id, store);\n try {\n for (const handler of disconnectHandlers) await handler(socket);\n } catch (err) {\n handleArkosGatewayErrors(err, socket, [], {\n startTime: connectionStartTime,\n namespace: this.config.name,\n event: \"disconnection\",\n });\n }\n });\n\n for (const entry of this.events) {\n if ((entry.config as any)._pipeOnly || !entry.handler) continue;\n\n const { config: eventConfig, handler, pipes: eventPipes = [] } = entry;\n\n if (\n (this.config.authentication || parentConfig?.authentication) &&\n !isUsingAuthentication()\n )\n throw ExitError(\n `Trying to use authorization gateway.on(\"${eventConfig.event}\") without choosing an authentication mode under arkos.config.${getUserFileExtension()}.\n\nFor further help see https://www.arkosjs.com/docs/core-concepts/authentication/setup.`,\n );\n\n socket.on(eventConfig.event, async (...args: any[]) => {\n socket.locals = {};\n const startTime = new Date().getTime();\n let data = args[0];\n\n const ack =\n typeof args[args.length - 1] === \"function\"\n ? args[args.length - 1]\n : undefined;\n\n let ackCalled = false;\n const wrappedAck = ack\n ? (...response: any) => {\n ackCalled = true;\n ack(...response);\n }\n : undefined;\n\n function resolveDedup() {\n if (\n eventConfig.dedup === false ||\n localConfig.dedup === false ||\n parentConfig?.dedup === false\n )\n return null;\n\n return {\n enabled: true,\n ttl: 3600,\n ...parentConfig?.dedup,\n ...localConfig?.dedup,\n ...eventConfig?.dedup,\n };\n }\n\n const dedupOpt = resolveDedup();\n\n try {\n const meta = data?._meta || {};\n const resolvedMaxAge =\n eventConfig.maxAge ?? localConfig.maxAge ?? parentConfig?.maxAge;\n\n if (resolvedMaxAge && !meta.timestamp)\n throw new BadRequestError(\n \"Missing _meta.timestamp for maxAge deduplication\",\n );\n\n if (meta.timestamp !== undefined) {\n const timestamp = new Date(meta.timestamp);\n\n if (isNaN(timestamp.getTime())) {\n throw new BadRequestError(\n \"Invalid data._meta.timestamp\",\n \"InvalidTimestamp\",\n );\n }\n\n const age = Date.now() - timestamp.getTime();\n\n if (age + 1000 < 0)\n throw new BadRequestError(\n \"Timestamp is in the future\",\n \"FutureTimestamp\",\n );\n\n if (resolvedMaxAge && age > resolvedMaxAge) {\n throw new BadRequestError(\"Message is too old\", \"StaleMessage\");\n }\n }\n\n if (dedupOpt && dedupOpt?.enabled !== false) {\n if (!meta?.mid)\n throw new BadRequestError(\n \"Missing data._meta.mid in your payload for deduplication\",\n \"MissingDedupMessageId\",\n { data },\n );\n\n if (typeof meta.mid !== \"string\" || meta.mid.trim() === \"\")\n throw new BadRequestError(\n \"Invalid data._meta.mid, it must be a non-empty string\",\n \"InvalidMessageId\",\n );\n\n const key = `arkos::dedup:${eventConfig.event}:${meta.mid}`;\n const ttl = dedupOpt?.ttl ?? 3600;\n\n const acquired = await store.setIfNotExists(key, ttl);\n\n if (acquired === false)\n return wrappedAck?.({\n success: true,\n duplicate: true,\n });\n\n const { _meta, ...payload } = data;\n data = payload;\n\n socket.meta = meta;\n }\n\n const rateLimitOptions = eventConfig.rateLimit ?? resolvedRateLimit;\n if (rateLimitOptions !== false) {\n const { allowed, retryAfter } = await checkRateLimit(\n socket.id,\n eventConfig.event,\n rateLimitOptions || {},\n options.store!,\n );\n if (!allowed) {\n throw new TooManyRequestsError(undefined, undefined, {\n retryAfter,\n });\n }\n }\n\n if (\n typeof eventConfig.authorization === \"object\" &&\n resolvedAuth &&\n isAuthenticationEnabled()\n ) {\n await authHookManager.runAuthorize(\n { context: socket, done: () => {} },\n (eventConfig?.authorization as any)?._authAction,\n \"currentUser\",\n );\n }\n\n if (eventConfig.validation) {\n const arkosConfig = getArkosConfig();\n const {\n validationFn,\n isValidValidator,\n validatorName,\n validatorNameType,\n } = validationManager;\n\n if (!isValidValidator(eventConfig.validation))\n throw new Error(\n `Your validation resolver is set to ${arkosConfig.validation!.resolver}, ` +\n `please provide a valid ${validatorName} in order to use { validation: ${validatorNameType} } ` +\n `under event handler \"${eventConfig.event}\" in \"${this.config.name}\" gateway.`,\n );\n\n const shouldValidate = validationManager.shouldValidate(\n eventConfig.validation,\n data,\n );\n\n if (shouldValidate === \"prohibit\")\n throw new BadRequestError(\n \"Event data is not allowed for this event.\",\n \"EventDataNotAllowed\",\n { data },\n );\n else if (shouldValidate === \"passthrough\") data = data;\n else {\n try {\n data = await (validationFn as any)(\n eventConfig.validation,\n data,\n );\n } catch (err: any) {\n const { validationConfig } = validationManager;\n\n const resolver = validationConfig?.resolver;\n const isZod = validationConfig?.resolver === \"zod\";\n\n const prettifiedError = errorPrettifier.prettify(\n resolver as any,\n err,\n );\n const error = prettifiedError[0];\n\n throw new BadRequestError(\n error.message,\n `InvalidData`,\n isZod ? err.format() : err,\n );\n }\n }\n }\n\n socket.data = data;\n\n await runArkosGatewayPipes(\n [...inheritedPipes, ...eventPipes],\n socket,\n data,\n );\n\n await handler(socket, data, wrappedAck);\n\n handleGatewayEventLog(\n this.config.name,\n eventConfig.event,\n 200,\n startTime,\n );\n\n if (eventConfig.ack && ack && !ackCalled) {\n ack({ success: true });\n }\n } catch (err: any) {\n handleArkosGatewayErrors(\n err,\n socket,\n errorHandlers,\n {\n startTime,\n namespace: this.config.name,\n event: eventConfig.event,\n },\n ack,\n );\n }\n });\n }\n });\n\n for (const child of this.gateways) {\n child._register(\n io,\n {\n name: namespaceName,\n authentication: resolvedAuth,\n rateLimit: resolvedRateLimit,\n },\n resolvedHooks,\n inheritedPipes,\n options,\n resolvedMiddlewares,\n );\n }\n }\n}\n\n/**\n * Creates an Arkos WebSocket Gateway backed by Socket.io.\n *\n * Handles authentication, validation, rate limiting, pipes,\n * error handling, and nested gateways — all declaratively.\n * Enhances every connected socket with `socket.user()`, `socket.peer()`,\n * `socket.retry()`, and automatic `_meta` injection on outgoing emits.\n *\n * @example\n * ```ts\n * const chatGateway = ArkosGateway({\n * name: \"chat\",\n * authentication: true,\n * rateLimit: { windowMs: 60_000, max: 200 },\n * })\n *\n * chatGateway.on(\n * { event: \"send_message\", validation: MessageSchema, ack: true },\n * (socket, data, ack) => {\n * socket.to(data.room).emit(\"receive_message\", data)\n * ack?.({ status: \"ok\" })\n * }\n * )\n * ```\n * @since 1.7.0-canary.18\n * @see {@link https://www.arkosjs.com/docs/core-concepts/components/gateways}\n */\nfunction ArkosGateway(config: ArkosGatewayConfig) {\n return new IArkosGateway(config);\n}\n\nexport default ArkosGateway;\n\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/components/arkos-gateway/types.ts"],"names":[],"mappings":"AA4jBA,MAAM,OAAO,sBAAsB;CAAI","sourcesContent":["import { BroadcastOperator, Socket } from \"socket.io\";\nimport { User } from \"../../types\";\nimport { DefaultEventsMap } from \"socket.io\";\nimport { Validator } from \"../../types/validation/validator\";\nimport { Options as RateLimitOptions } from \"express-rate-limit\";\nimport { DetailedAccessControlRule } from \"../../types/auth\";\n///@ts-ignore\nimport {\n AllButLast,\n DecorateAcknowledgements,\n DecorateAcknowledgementsWithMultipleResponses,\n EventNames,\n EventNamesWithAck,\n EventNamesWithError,\n EventParams,\n FirstNonErrorArg,\n Last,\n ///@ts-ignore\n} from \"socket.io/dist/typed-events\";\n\nexport interface EventsMap {\n [event: string]: any;\n}\n\nexport interface ArkosSocket<\n ListenEvents extends EventsMap = DefaultEventsMap,\n EmitEvents extends EventsMap = ListenEvents,\n ServerSideEvents extends EventsMap = DefaultEventsMap,\n SocketData extends Validator = any,\n SocketLocals extends Record<string, any> = Record<string, any>,\n> extends Socket<ListenEvents, EmitEvents, ServerSideEvents, SocketData> {\n /**\n * Populated by Arkos after successful authentication on connection.\n * Available in all event handlers when `authentication: true` on the gateway.\n */\n currentUser?: User;\n\n /**\n * Populated by Arkos after successful validation.\n * Typed to the event's validation schema when using TypeScript.\n */\n data: SocketData;\n\n /** User access token. */\n accessToken?: string;\n\n /**\n * Metadata from the incoming message, extracted from `_meta` by Arkos.\n *\n * - `mid`: Unique message ID used for deduplication.\n * - `timestamp`: When the message was sent by the client.\n */\n meta?: {\n mid?: string;\n timestamp?: string | number | Date;\n };\n\n /**\n * Per-event local storage, scoped to the current event pipeline.\n * Use to pass data between pipes and the event handler — like Express's `res.locals`.\n * Reset automatically on each event.\n *\n * @example\n * chatGateway.pipe((socket, data) => {\n * socket.locals.enriched = enrichUser(socket.currentUser)\n * })\n *\n * chatGateway.on({ event: \"send_message\" }, (socket, data) => {\n * console.log(socket.locals.enriched)\n * })\n */\n locals?: SocketLocals;\n\n /**\n * Internal Arkos context injected by the gateway at connection time.\n *\n * @internal\n */\n _arkos: {\n store: ArkosGatewayStore;\n gatewayConfig: ArkosGatewayConfig;\n };\n\n /**\n * Targets all active socket connections of a user by their user ID.\n * Uses the internal `arkos::user:{userId}` room convention.\n *\n * Supports emit, management, and exclusion operations across all of the\n * user's active connections.\n *\n * @example\n * socket.user(userId).emit(\"notification\", data)\n * socket.user(userId).except({ user: otherUserId }).emit(\"sync\", data)\n * const sockets = await socket.user(userId).fetchSockets()\n * const online = await socket.user(userId).isOnline()\n *\n * @since 1.7.0-canary.29\n */\n user(userId: string): ArkosUserTarget;\n\n /**\n * Wraps the next `emit` or `emitWithAck` with exponential backoff retry logic.\n * Chain `.timeout(ms)` before `.emitWithAck()` as usual.\n *\n * @example\n * socket.retry(3).emit(\"event\", data)\n * socket.retry(3).timeout(5000).emitWithAck(\"event\", data)\n *\n * @since 1.7.0-canary.29\n */\n retry(\n times: number,\n initialDelay?: number,\n multiplier?: number\n ): ArkosRetryTarget;\n\n /**\n * Emits an event to this client.\n * Arkos automatically injects `_meta` (`mid` + `timestamp`) into every outgoing payload\n * for client-side deduplication and freshness checks.\n *\n * @example\n * socket.emit(\"message\", { text: \"hello\" })\n * socket.emit(\"notification\", { title: \"New order\" })\n */\n emit<Ev extends EventNames<EmitEvents>>(\n ev: Ev,\n ...args: EventParams<EmitEvents, Ev>\n ): true;\n\n /**\n * Emits an event and waits for an acknowledgement from the client.\n * Arkos injects `_meta` automatically. Use `.timeout(ms)` to avoid hanging indefinitely.\n *\n * @example\n * const response = await socket.timeout(5000).emitWithAck(\"confirm\", data)\n */\n emitWithAck<Ev extends EventNamesWithAck<EmitEvents>>(\n ev: Ev,\n ...args: AllButLast<EventParams<EmitEvents, Ev>>\n ): Promise<FirstNonErrorArg<Last<EventParams<EmitEvents, Ev>>>>;\n\n /**\n * Targets a room when broadcasting — excludes the sender.\n * Returns an {@link ArkosBroadcastOperator} with enhanced `.except({ user })` support\n * and automatic `_meta` injection on every `.emit()`.\n *\n * @example\n * socket.to(\"room-101\").emit(\"message\", data)\n * socket.to(\"room-101\").except({ user: userId }).emit(\"message\", data)\n * socket.to(\"room-101\").volatile.emit(\"typing\", data)\n * await socket.to(\"room-101\").timeout(3000).emitWithAck(\"confirm\", data)\n *\n * @since 1.7.0-canary.29\n */\n to(\n room: string | string[]\n ): ArkosBroadcastOperator<\n DecorateAcknowledgementsWithMultipleResponses<EmitEvents>,\n SocketData\n > &\n BroadcastOperator<EmitEvents, SocketData>;\n /**\n * Broadcasts to all connected clients except the sender.\n * Returns an {@link ArkosBroadcastOperator} with enhanced `.except({ user })` support\n * and automatic `_meta` injection on every `.emit()`.\n *\n * @example\n * socket.broadcast.emit(\"announcement\", data)\n * socket.broadcast.except({ user: userId }).emit(\"announcement\", data)\n * socket.broadcast.volatile.emit(\"ping\", data)\n *\n * @since 1.7.0-canary.29\n */\n get broadcast(): ArkosBroadcastOperator<\n DecorateAcknowledgementsWithMultipleResponses<EmitEvents>,\n SocketData\n > &\n BroadcastOperator<EmitEvents, SocketData>;\n}\n\n/**\n * Enhanced broadcast/room target returned by `socket.to()` and `socket.broadcast`.\n * Extends the native `BroadcastOperator` with `{ user }` exclusion support\n * and automatic `_meta` injection on emit.\n *\n * @since 1.7.0-canary.29\n */\nexport interface ArkosBroadcastOperator<\n EmitEvents extends EventsMap = DefaultEventsMap,\n SocketData extends Validator = any,\n> extends BroadcastOperator<EmitEvents, SocketData> {\n /**\n * Exclude sockets from the broadcast.\n * Accepts a room name, socket ID, or `{ user: string | string[] }` to exclude\n * all sockets belonging to one or more users.\n *\n * @example\n * socket.to(\"room-101\").except(\"room-102\").emit(\"foo\", data)\n * socket.broadcast.except({ user: userId }).emit(\"foo\", data)\n * socket.broadcast.except({ user: [userId1, userId2] }).emit(\"foo\", data)\n */\n except(\n room: string | string[] | { user: string | string[] }\n ): ArkosBroadcastOperator<EmitEvents, SocketData>;\n\n /**\n * Emits to all clients,`_meta` is injected automatically.\n *\n * @example\n * // the “foo” event will be broadcast to all connected clients\n * io.emit(\"foo\", \"bar\");\n *\n * // the “foo” event will be broadcast to all connected clients in the “room-101” room\n * io.to(\"room-101\").emit(\"foo\", \"bar\");\n *\n * // with an acknowledgement expected from all connected clients\n * io.timeout(1000).emit(\"some-event\", (err, responses) => {\n * if (err) {\n * // some clients did not acknowledge the event in the given delay\n * } else {\n * console.log(responses); // one response per client\n * }\n * });\n *\n * @return Always true\n */\n emit<Ev extends EventNames<EmitEvents>>(\n ev: Ev,\n ...args: EventParams<EmitEvents, Ev>\n ): true;\n\n /** Chain volatile flag — event may be lost if client is not ready. */\n get volatile(): ArkosBroadcastOperator<EmitEvents, SocketData>;\n\n /** Chain compress flag. */\n compress(value: boolean): ArkosBroadcastOperator<EmitEvents, SocketData>;\n\n /** Chain timeout for `emitWithAck`. */\n timeout(\n ms: number\n ): ArkosBroadcastOperator<DecorateAcknowledgements<EmitEvents>, SocketData>;\n\n /**\n * Emits an event and waits for an acknowledgement from all clients.\n * `_meta` is injected automatically\n * @example\n * try {\n * const responses = await io.timeout(1000).emitWithAck(\"some-event\");\n * console.log(responses); // one response per client\n * } catch (e) {\n * // some clients did not acknowledge the event in the given delay\n * }\n *\n * @return a Promise that will be fulfilled when all clients have acknowledged the event\n */\n emitWithAck<Ev extends EventNamesWithError<EmitEvents>>(\n ev: Ev,\n ...args: AllButLast<EventParams<EmitEvents, Ev>>\n ): Promise<FirstNonErrorArg<Last<EventParams<EmitEvents, Ev>>>>;\n\n /**\n * Targets all active socket connections of a user by their user ID.\n * Uses the internal `arkos::user:{userId}` room convention.\n *\n * Supports emit, management, and exclusion operations across all of the\n * user's active connections.\n *\n * @example\n * socket.user(userId).emit(\"notification\", data)\n * socket.user(userId).except({ user: otherUserId }).emit(\"sync\", data)\n * const sockets = await socket.user(userId).fetchSockets()\n * const online = await socket.user(userId).isOnline()\n *\n * @since 1.7.0-canary.29\n */\n user(userId: string): ArkosUserTarget;\n /**\n * Returns all unique user IDs currently in the target room(s).\n *\n * @example\n * const users = await socket.to(\"room-123\").users()\n */\n users(): Promise<string[]>;\n}\n\n/**\n * Returned by `socket.retry(n)`. Wraps `emit` and `emitWithAck`\n * with exponential backoff. Chain `.timeout(ms)` before `.emitWithAck()` as usual.\n *\n * @since 1.7.0-canary.29\n */\nexport interface ArkosRetryTarget {\n /** Emit with ack and retry. `_meta` is injected automatically. */\n emitWithAck(event: string, data: any, ...rest: any[]): Promise<any>;\n\n /**\n * Chain a timeout before `emitWithAck`.\n *\n * @example\n * socket.retry(3).timeout(5000).emitWithAck(\"event\", data)\n */\n timeout(ms: number): ArkosRetryTarget;\n}\n\n/**\n * Returned by `socket.user(userId)`.\n * Targets all active socket connections of a user.\n *\n * @since 1.7.0-canary.29\n */\nexport interface ArkosUserTarget extends ArkosBroadcastOperator {\n /**\n * Returns all active rooms for this user.\n *\n * @example\n * const rooms = await socket.user(userId).activeRooms()\n * console.log(rooms.length) // number of active tabs/connections\n */\n activeRooms(): Promise<string[]>;\n}\n\nexport type ArkosGatewayPipe = (\n socket: ArkosSocket,\n data: any\n) => void | Promise<void>;\n\nexport type ArkosGatewayEventConfig<TSchema extends Validator = any> = {\n /** The Socket.io event name to listen for. */\n event: string;\n\n /** Zod schema or class-validator DTO to validate the incoming event payload. */\n validation?: TSchema;\n\n /** Per-event rate limiting. Overrides gateway-level `rateLimit` for this event. */\n rateLimit?: Partial<RateLimitOptions> | false;\n\n /**\n * Authorization configuration.\n *\n * @remarks Gateway `authentication` must NOT be `false` or this throws at registration time.\n */\n authorization?: {\n resource: string;\n action: string;\n rule?: DetailedAccessControlRule | string[] | \"*\";\n };\n\n /**\n * When `true`, Arkos automatically calls `ack({ success: true })` after the handler\n * finishes, unless the handler already called ack manually.\n */\n ack?: boolean;\n\n /** Disables this event handler without removing it. */\n disabled?: boolean;\n\n /**\n * Maximum age in milliseconds for incoming messages.\n * Requires `data._meta.timestamp`. Events older than this are rejected.\n */\n maxAge?: number;\n\n /** Per-event deduplication. Overrides gateway-level `dedup`. */\n dedup?:\n | {\n /** @default true */\n enabled?: boolean;\n /** Time-to-live in seconds for the dedup key. @default 3600 */\n ttl?: number;\n }\n | false;\n};\n\nexport type ArkosGatewayAckFn = (response: any) => void;\n\nexport type ArkosGatewayHandler<TData = any> = (\n socket: ArkosSocket,\n data: TData,\n ack?: ArkosGatewayAckFn\n) => void | Promise<void>;\n\nexport type ArkosGatewayEventEntry = {\n config: ArkosGatewayEventConfig;\n handler: ArkosGatewayHandler;\n pipes: ArkosGatewayPipe[];\n};\n\nexport type ArkosGatewayConnectionHandler = (\n socket: ArkosSocket\n) => void | Promise<void>;\n\nexport type ArkosGatewayHookHandler =\n | ArkosGatewayConnectionHandler\n | ArkosGatewayErrorHandler;\n\nexport type ArkosGatewayErrorHandler = (\n error: any,\n socket: ArkosSocket\n) => void | Promise<void>;\n\nexport type ArkosGatewayHookType = \"connection\" | \"disconnect\" | \"error\";\n\nexport type ArkosGatewayConfig = {\n /**\n * Socket.io namespace for this gateway.\n *\n * @example\n * name: \"/chat\"\n */\n name: string;\n\n /**\n * When `true`, Arkos runs auth middleware on connection and populates `socket.currentUser`.\n * Unauthenticated sockets are rejected.\n *\n * @default false\n */\n authentication?: boolean;\n\n /** Gateway-level rate limiting, applied per socket. Can be overridden per event. */\n rateLimit?: Partial<RateLimitOptions>;\n\n /**\n * Gateway-level deduplication. Drills down to child gateways and can be overridden\n * per child or per event listener.\n */\n dedup?:\n | {\n /** @default true */\n enabled?: boolean;\n /** @default 3600 */\n ttl?: number;\n }\n | false;\n\n /**\n * Maximum age in milliseconds for incoming messages.\n * Can be overridden per event via `maxAge` in `gateway.on()`.\n */\n maxAge?: number;\n};\n\n/**\n * Options for `gateway.register()`.\n * Passed once at the root — applies to all child gateways.\n */\nexport type ArkosGatewayRegisterOptions = {\n /**\n * Unified store for rate limiting and deduplication.\n * Defaults to an in-memory store — zero config for single-instance deployments.\n * For distributed deployments plug in a Redis-backed store.\n *\n * @example\n * store: new RedisArkosStore(redis)\n */\n store?: ArkosGatewayStore;\n};\n\n/**\n * Unified store interface for rate limiting and deduplication.\n * Implement this to plug in Redis, Valkey, or any distributed store.\n *\n * @example\n * class RedisArkosStore implements ArkosGatewayStore {\n * async increment(key, windowMs) { ... }\n * async clear(prefix) { ... }\n * async has(key) { ... }\n * async set(key, ttl) { ... }\n * async setIfNotExists(key, ttl) { ... }\n * }\n */\nexport interface ArkosGatewayStore {\n /** Increment a rate limit counter. Key format: `arkos::rl:{socketId}:{event}` */\n increment(\n key: string,\n windowMs: number\n ): Promise<{ count: number; resetAt: number }>;\n\n /** Clear all rate limit entries matching a prefix. Key format: `arkos::rl:{socketId}` */\n clear(prefix: string): Promise<void>;\n\n /** Check if a dedup key exists. */\n has(key: string): Promise<boolean>;\n\n /** Store a dedup key with TTL in seconds. */\n set(key: string, ttl: number): Promise<void>;\n\n /**\n * Atomically store a dedup key only if it does not already exist.\n * Returns `true` if created (process the message), `false` if duplicate (skip).\n */\n setIfNotExists(key: string, ttl: number): Promise<boolean>;\n}\n\n/**\n * Minimal broadcast/emit contract that {@link ArkosBroadcastOperatorImpl} wraps.\n * Deliberately narrower than socket.io's `BroadcastOperator` — only the methods\n * Arkos actually calls, so both a `BroadcastOperator` (from `socket.to()`) and a\n * raw `Namespace` (from `gateway.nsp`) satisfy it structurally.\n *\n * @since 1.7.1-canary.3\n */\nexport interface ArkosEmitTarget<EmitEvents extends EventsMap = DefaultEventsMap> {\n /**\n * Emits an event to the target. `_meta` (`mid` + `timestamp`) is injected automatically.\n *\n * @example\n * socket.to(\"room-101\").emit(\"message\", { text: \"hello\" })\n * socket.broadcast.emit(\"announcement\", data)\n */\n emit(event: string, ...args: any[]): boolean;\n\n /**\n * Emits an event and waits for an acknowledgement from all matched clients.\n * `_meta` is injected automatically.\n *\n * Optional — not every target supports ack collection directly (e.g. a raw\n * `Namespace` requires `.timeout(ms)` first). Throws at runtime if called on\n * a target that doesn't implement it natively.\n *\n * @example\n * const responses = await socket.to(\"room-101\").timeout(3000).emitWithAck(\"confirm\", data)\n */\n emitWithAck?(event: string, ...args: any[]): Promise<any>;\n\n /**\n * Excludes sockets from the broadcast.\n * Accepts a room name, socket ID, or array of rooms/IDs.\n * For `{ user }` exclusion, see {@link ArkosBroadcastOperatorImpl.except}.\n *\n * @example\n * socket.to(\"room-101\").except(\"room-102\").emit(\"foo\", data)\n */\n except(room: string | string[]): ArkosEmitTarget<EmitEvents>;\n\n /**\n * Sets the compress flag for the next emission.\n *\n * @example\n * socket.broadcast.compress(false).emit(\"ping\", data)\n */\n compress(value: boolean): ArkosEmitTarget<EmitEvents>;\n\n /**\n * Sets a timeout in milliseconds for `emitWithAck`.\n * Rejects the promise if no client acknowledges within the given delay.\n *\n * @example\n * socket.to(\"room-101\").timeout(3000).emitWithAck(\"confirm\", data)\n */\n timeout(ms: number): ArkosEmitTarget\n\n /**\n * Returns all sockets currently matched by this target.\n *\n * @example\n * const sockets = await socket.to(\"room-101\").fetchSockets()\n */\n fetchSockets(): Promise<any[]>;\n\n to(room: string | string[]): ArkosEmitTarget\n\n /**\n * Sets the volatile flag — the event may be dropped if the client is not ready.\n * Useful for high-frequency non-critical events like cursor positions or typing indicators.\n *\n * @example\n * socket.to(\"room-101\").volatile.emit(\"cursor\", position)\n */\n readonly volatile: ArkosEmitTarget<EmitEvents>;\n}\nexport class ArkosGatewayController { }\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/components/arkos-gateway/types.ts"],"names":[],"mappings":"AAmlBA,MAAM,OAAO,sBAAsB;CAAG","sourcesContent":["import { BroadcastOperator, Socket } from \"socket.io\";\nimport { User } from \"../../types\";\nimport { DefaultEventsMap } from \"socket.io\";\nimport { Validator } from \"../../types/validation/validator\";\nimport { Options as RateLimitOptions } from \"express-rate-limit\";\nimport { DetailedAccessControlRule } from \"../../types/auth\";\n///@ts-ignore\nimport {\n AllButLast,\n DecorateAcknowledgements,\n DecorateAcknowledgementsWithMultipleResponses,\n EventNames,\n EventNamesWithAck,\n EventNamesWithError,\n EventParams,\n FirstNonErrorArg,\n Last,\n ///@ts-ignore\n} from \"socket.io/dist/typed-events\";\nimport { InferValidationType } from \"../../utils/arkos-router/types\";\n\nexport interface EventsMap {\n [event: string]: any;\n}\n\nexport interface ArkosSocket<\n ListenEvents extends EventsMap = DefaultEventsMap,\n EmitEvents extends EventsMap = ListenEvents,\n ServerSideEvents extends EventsMap = DefaultEventsMap,\n SocketData extends Validator = any,\n SocketLocals extends Record<string, any> = Record<string, any>,\n> extends Socket<ListenEvents, EmitEvents, ServerSideEvents, SocketData> {\n /**\n * The engine.io handshake, enriched with the parsed `Cookie` header.\n *\n * Arkos parses the raw header once per connection, so handlers can read\n * cookies without installing `io.engine.use(cookieParser())` themselves.\n */\n handshake: Socket[\"handshake\"] & {\n cookies?: Record<string, string>;\n };\n\n /**\n * Populated by Arkos after successful authentication on connection.\n * Available in all event handlers when `authentication: true` on the gateway.\n */\n currentUser?: User;\n\n /**\n * Populated by Arkos after successful validation.\n * Typed to the event's validation schema when using TypeScript.\n */\n data: InferValidationType<SocketData, any>;\n\n /** User access token. */\n accessToken?: string;\n\n /**\n * Metadata from the incoming message, extracted from `_meta` by Arkos.\n *\n * - `mid`: Unique message ID used for deduplication.\n * - `timestamp`: When the message was sent by the client.\n */\n meta?: {\n mid?: string;\n timestamp?: string | number | Date;\n };\n\n /**\n * Per-event local storage, scoped to the current event pipeline.\n * Use to pass data between pipes and the event handler — like Express's `res.locals`.\n * Reset automatically on each event.\n *\n * @example\n * chatGateway.pipe((socket, data) => {\n * socket.locals.enriched = enrichUser(socket.currentUser)\n * })\n *\n * chatGateway.on({ event: \"send_message\" }, (socket, data) => {\n * console.log(socket.locals.enriched)\n * })\n */\n locals?: SocketLocals;\n\n /**\n * Internal Arkos context injected by the gateway at connection time.\n *\n * @internal\n */\n _arkos: {\n store: ArkosGatewayStore;\n gatewayConfig: ArkosGatewayConfig;\n };\n\n /**\n * Targets all active socket connections of a user by their user ID.\n * Uses the internal `arkos::user:{userId}` room convention.\n *\n * Supports emit, management, and exclusion operations across all of the\n * user's active connections.\n *\n * @example\n * socket.user(userId).emit(\"notification\", data)\n * socket.user(userId).except({ user: otherUserId }).emit(\"sync\", data)\n * const sockets = await socket.user(userId).fetchSockets()\n * const online = await socket.user(userId).isOnline()\n *\n * @since 1.7.0-canary.29\n */\n user(userId: string): ArkosUserTarget;\n\n /**\n * Wraps the next `emit` or `emitWithAck` with exponential backoff retry logic.\n * Chain `.timeout(ms)` before `.emitWithAck()` as usual.\n *\n * @example\n * socket.retry(3).emit(\"event\", data)\n * socket.retry(3).timeout(5000).emitWithAck(\"event\", data)\n *\n * @since 1.7.0-canary.29\n */\n retry(\n times: number,\n initialDelay?: number,\n multiplier?: number,\n ): ArkosRetryTarget;\n\n /**\n * Emits an event to this client.\n * Arkos automatically injects `_meta` (`mid` + `timestamp`) into every outgoing payload\n * for client-side deduplication and freshness checks.\n *\n * @example\n * socket.emit(\"message\", { text: \"hello\" })\n * socket.emit(\"notification\", { title: \"New order\" })\n */\n emit<Ev extends EventNames<EmitEvents>>(\n ev: Ev,\n ...args: EventParams<EmitEvents, Ev>\n ): true;\n\n /**\n * Emits an event and waits for an acknowledgement from the client.\n * Arkos injects `_meta` automatically. Use `.timeout(ms)` to avoid hanging indefinitely.\n *\n * @example\n * const response = await socket.timeout(5000).emitWithAck(\"confirm\", data)\n */\n emitWithAck<Ev extends EventNamesWithAck<EmitEvents>>(\n ev: Ev,\n ...args: AllButLast<EventParams<EmitEvents, Ev>>\n ): Promise<FirstNonErrorArg<Last<EventParams<EmitEvents, Ev>>>>;\n\n /**\n * Targets a room when broadcasting — excludes the sender.\n * Returns an {@link ArkosBroadcastOperator} with enhanced `.except({ user })` support\n * and automatic `_meta` injection on every `.emit()`.\n *\n * @example\n * socket.to(\"room-101\").emit(\"message\", data)\n * socket.to(\"room-101\").except({ user: userId }).emit(\"message\", data)\n * socket.to(\"room-101\").volatile.emit(\"typing\", data)\n * await socket.to(\"room-101\").timeout(3000).emitWithAck(\"confirm\", data)\n *\n * @since 1.7.0-canary.29\n */\n to(\n room: string | string[],\n ): ArkosBroadcastOperator<\n DecorateAcknowledgementsWithMultipleResponses<EmitEvents>,\n SocketData\n > &\n BroadcastOperator<EmitEvents, SocketData>;\n /**\n * Broadcasts to all connected clients except the sender.\n * Returns an {@link ArkosBroadcastOperator} with enhanced `.except({ user })` support\n * and automatic `_meta` injection on every `.emit()`.\n *\n * @example\n * socket.broadcast.emit(\"announcement\", data)\n * socket.broadcast.except({ user: userId }).emit(\"announcement\", data)\n * socket.broadcast.volatile.emit(\"ping\", data)\n *\n * @since 1.7.0-canary.29\n */\n get broadcast(): ArkosBroadcastOperator<\n DecorateAcknowledgementsWithMultipleResponses<EmitEvents>,\n SocketData\n > &\n BroadcastOperator<EmitEvents, SocketData>;\n}\n\n/**\n * Enhanced broadcast/room target returned by `socket.to()` and `socket.broadcast`.\n * Extends the native `BroadcastOperator` with `{ user }` exclusion support\n * and automatic `_meta` injection on emit.\n *\n * @since 1.7.0-canary.29\n */\nexport interface ArkosBroadcastOperator<\n EmitEvents extends EventsMap = DefaultEventsMap,\n SocketData extends Validator = any,\n> extends BroadcastOperator<EmitEvents, SocketData> {\n /**\n * Exclude sockets from the broadcast.\n * Accepts a room name, socket ID, or `{ user: string | string[] }` to exclude\n * all sockets belonging to one or more users.\n *\n * @example\n * socket.to(\"room-101\").except(\"room-102\").emit(\"foo\", data)\n * socket.broadcast.except({ user: userId }).emit(\"foo\", data)\n * socket.broadcast.except({ user: [userId1, userId2] }).emit(\"foo\", data)\n */\n except(\n room: string | string[] | { user: string | string[] },\n ): ArkosBroadcastOperator<EmitEvents, SocketData>;\n\n /**\n * Emits to all clients,`_meta` is injected automatically.\n *\n * @example\n * // the “foo” event will be broadcast to all connected clients\n * io.emit(\"foo\", \"bar\");\n *\n * // the “foo” event will be broadcast to all connected clients in the “room-101” room\n * io.to(\"room-101\").emit(\"foo\", \"bar\");\n *\n * // with an acknowledgement expected from all connected clients\n * io.timeout(1000).emit(\"some-event\", (err, responses) => {\n * if (err) {\n * // some clients did not acknowledge the event in the given delay\n * } else {\n * console.log(responses); // one response per client\n * }\n * });\n *\n * @return Always true\n */\n emit<Ev extends EventNames<EmitEvents>>(\n ev: Ev,\n ...args: EventParams<EmitEvents, Ev>\n ): true;\n\n /** Chain volatile flag — event may be lost if client is not ready. */\n get volatile(): ArkosBroadcastOperator<EmitEvents, SocketData>;\n\n /** Chain compress flag. */\n compress(value: boolean): ArkosBroadcastOperator<EmitEvents, SocketData>;\n\n /** Chain timeout for `emitWithAck`. */\n timeout(\n ms: number,\n ): ArkosBroadcastOperator<DecorateAcknowledgements<EmitEvents>, SocketData>;\n\n /**\n * Emits an event and waits for an acknowledgement from all clients.\n * `_meta` is injected automatically\n * @example\n * try {\n * const responses = await io.timeout(1000).emitWithAck(\"some-event\");\n * console.log(responses); // one response per client\n * } catch (e) {\n * // some clients did not acknowledge the event in the given delay\n * }\n *\n * @return a Promise that will be fulfilled when all clients have acknowledged the event\n */\n emitWithAck<Ev extends EventNamesWithError<EmitEvents>>(\n ev: Ev,\n ...args: AllButLast<EventParams<EmitEvents, Ev>>\n ): Promise<FirstNonErrorArg<Last<EventParams<EmitEvents, Ev>>>>;\n\n /**\n * Targets all active socket connections of a user by their user ID.\n * Uses the internal `arkos::user:{userId}` room convention.\n *\n * Supports emit, management, and exclusion operations across all of the\n * user's active connections.\n *\n * @example\n * socket.user(userId).emit(\"notification\", data)\n * socket.user(userId).except({ user: otherUserId }).emit(\"sync\", data)\n * const sockets = await socket.user(userId).fetchSockets()\n * const online = await socket.user(userId).isOnline()\n *\n * @since 1.7.0-canary.29\n */\n user(userId: string): ArkosUserTarget;\n /**\n * Returns all unique user IDs currently in the target room(s).\n *\n * @example\n * const users = await socket.to(\"room-123\").users()\n */\n users(): Promise<string[]>;\n}\n\n/**\n * Returned by `socket.retry(n)`. Wraps `emit` and `emitWithAck`\n * with exponential backoff. Chain `.timeout(ms)` before `.emitWithAck()` as usual.\n *\n * @since 1.7.0-canary.29\n */\nexport interface ArkosRetryTarget {\n /** Emit with ack and retry. `_meta` is injected automatically. */\n emitWithAck(event: string, data: any, ...rest: any[]): Promise<any>;\n\n /**\n * Chain a timeout before `emitWithAck`.\n *\n * @example\n * socket.retry(3).timeout(5000).emitWithAck(\"event\", data)\n */\n timeout(ms: number): ArkosRetryTarget;\n}\n\n/**\n * Returned by `socket.user(userId)`.\n * Targets all active socket connections of a user.\n *\n * @since 1.7.0-canary.29\n */\nexport interface ArkosUserTarget extends ArkosBroadcastOperator {\n /**\n * Returns all active rooms for this user.\n *\n * @example\n * const rooms = await socket.user(userId).activeRooms()\n * console.log(rooms.length) // number of active tabs/connections\n */\n activeRooms(): Promise<string[]>;\n}\n\nexport type ArkosGatewayPipe = (\n socket: ArkosSocket,\n data: any,\n) => void | Promise<void>;\n\n/**\n * Connection-level middleware registered with `gateway.use()`.\n * Same `(socket, next)` contract as Socket.io namespace middleware.\n * Runs before the namespace's authentication middleware and is inherited\n * by nested gateways.\n */\nexport type ArkosGatewayMiddleware = (\n socket: ArkosSocket,\n next: (err?: any) => void\n) => void | Promise<void>;\n\nexport type ArkosGatewayEventConfig<TSchema extends Validator = any> = {\n /** The Socket.io event name to listen for. */\n event: string;\n\n /** Zod schema or class-validator DTO to validate the incoming event payload. */\n validation?: TSchema;\n\n /** Per-event rate limiting. Overrides gateway-level `rateLimit` for this event. */\n rateLimit?: Partial<RateLimitOptions> | false;\n\n /**\n * Authorization configuration.\n *\n * @remarks Gateway `authentication` must NOT be `false` or this throws at registration time.\n */\n authorization?: {\n resource: string;\n action: string;\n rule?: DetailedAccessControlRule | string[] | \"*\";\n };\n\n /**\n * When `true`, Arkos automatically calls `ack({ success: true })` after the handler\n * finishes, unless the handler already called ack manually.\n */\n ack?: boolean;\n\n /** Disables this event handler without removing it. */\n disabled?: boolean;\n\n /**\n * Maximum age in milliseconds for incoming messages.\n * Requires `data._meta.timestamp`. Events older than this are rejected.\n */\n maxAge?: number;\n\n /** Per-event deduplication. Overrides gateway-level `dedup`. */\n dedup?:\n | {\n /** @default true */\n enabled?: boolean;\n /** Time-to-live in seconds for the dedup key. @default 3600 */\n ttl?: number;\n }\n | false;\n};\n\nexport type ArkosGatewayAckFn = (response: any) => void;\n\nexport type ArkosGatewayHandler<TData extends Validator = any> = (\n socket: ArkosSocket,\n data: InferValidationType<TData, any>,\n ack?: ArkosGatewayAckFn,\n) => void | Promise<void>;\n\nexport type ArkosGatewayEventEntry = {\n config: ArkosGatewayEventConfig;\n handler: ArkosGatewayHandler;\n pipes: ArkosGatewayPipe[];\n};\n\nexport type ArkosGatewayConnectionHandler = (\n socket: ArkosSocket,\n) => void | Promise<void>;\n\nexport type ArkosGatewayHookHandler =\n ArkosGatewayConnectionHandler | ArkosGatewayErrorHandler;\n\nexport type ArkosGatewayErrorHandler = (\n error: any,\n socket: ArkosSocket,\n) => void | Promise<void>;\n\nexport type ArkosGatewayHookType = \"connection\" | \"disconnect\" | \"error\";\n\nexport type ArkosGatewayConfig = {\n /**\n * Socket.io namespace for this gateway.\n *\n * @example\n * name: \"/chat\"\n */\n name: string;\n\n /**\n * When `true`, Arkos runs auth middleware on connection and populates `socket.currentUser`.\n * Unauthenticated sockets are rejected.\n *\n * @default false\n */\n authentication?: boolean;\n\n /** Gateway-level rate limiting, applied per socket. Can be overridden per event. */\n rateLimit?: Partial<RateLimitOptions>;\n\n /**\n * Gateway-level deduplication. Drills down to child gateways and can be overridden\n * per child or per event listener.\n */\n dedup?:\n | {\n /** @default true */\n enabled?: boolean;\n /** @default 3600 */\n ttl?: number;\n }\n | false;\n\n /**\n * Maximum age in milliseconds for incoming messages.\n * Can be overridden per event via `maxAge` in `gateway.on()`.\n */\n maxAge?: number;\n};\n\n/**\n * Options for `gateway.register()`.\n * Passed once at the root — applies to all child gateways.\n */\nexport type ArkosGatewayRegisterOptions = {\n /**\n * Unified store for rate limiting and deduplication.\n * Defaults to an in-memory store — zero config for single-instance deployments.\n * For distributed deployments plug in a Redis-backed store.\n *\n * @example\n * store: new RedisArkosStore(redis)\n */\n store?: ArkosGatewayStore;\n};\n\n/**\n * Unified store interface for rate limiting and deduplication.\n * Implement this to plug in Redis, Valkey, or any distributed store.\n *\n * @example\n * class RedisArkosStore implements ArkosGatewayStore {\n * async increment(key, windowMs) { ... }\n * async clear(prefix) { ... }\n * async has(key) { ... }\n * async set(key, ttl) { ... }\n * async setIfNotExists(key, ttl) { ... }\n * }\n */\nexport interface ArkosGatewayStore {\n /** Increment a rate limit counter. Key format: `arkos::rl:{socketId}:{event}` */\n increment(\n key: string,\n windowMs: number,\n ): Promise<{ count: number; resetAt: number }>;\n\n /** Clear all rate limit entries matching a prefix. Key format: `arkos::rl:{socketId}` */\n clear(prefix: string): Promise<void>;\n\n /** Check if a dedup key exists. */\n has(key: string): Promise<boolean>;\n\n /** Store a dedup key with TTL in seconds. */\n set(key: string, ttl: number): Promise<void>;\n\n /**\n * Atomically store a dedup key only if it does not already exist.\n * Returns `true` if created (process the message), `false` if duplicate (skip).\n */\n setIfNotExists(key: string, ttl: number): Promise<boolean>;\n}\n\n/**\n * Minimal broadcast/emit contract that {@link ArkosBroadcastOperatorImpl} wraps.\n * Deliberately narrower than socket.io's `BroadcastOperator` — only the methods\n * Arkos actually calls, so both a `BroadcastOperator` (from `socket.to()`) and a\n * raw `Namespace` (from `gateway.nsp`) satisfy it structurally.\n *\n * @since 1.7.1-canary.3\n */\nexport interface ArkosEmitTarget<\n EmitEvents extends EventsMap = DefaultEventsMap,\n> {\n /**\n * Emits an event to the target. `_meta` (`mid` + `timestamp`) is injected automatically.\n *\n * @example\n * socket.to(\"room-101\").emit(\"message\", { text: \"hello\" })\n * socket.broadcast.emit(\"announcement\", data)\n */\n emit(event: string, ...args: any[]): boolean;\n\n /**\n * Emits an event and waits for an acknowledgement from all matched clients.\n * `_meta` is injected automatically.\n *\n * Optional — not every target supports ack collection directly (e.g. a raw\n * `Namespace` requires `.timeout(ms)` first). Throws at runtime if called on\n * a target that doesn't implement it natively.\n *\n * @example\n * const responses = await socket.to(\"room-101\").timeout(3000).emitWithAck(\"confirm\", data)\n */\n emitWithAck?(event: string, ...args: any[]): Promise<any>;\n\n /**\n * Excludes sockets from the broadcast.\n * Accepts a room name, socket ID, or array of rooms/IDs.\n * For `{ user }` exclusion, see {@link ArkosBroadcastOperatorImpl.except}.\n *\n * @example\n * socket.to(\"room-101\").except(\"room-102\").emit(\"foo\", data)\n */\n except(room: string | string[]): ArkosEmitTarget<EmitEvents>;\n\n /**\n * Sets the compress flag for the next emission.\n *\n * @example\n * socket.broadcast.compress(false).emit(\"ping\", data)\n */\n compress(value: boolean): ArkosEmitTarget<EmitEvents>;\n\n /**\n * Sets a timeout in milliseconds for `emitWithAck`.\n * Rejects the promise if no client acknowledges within the given delay.\n *\n * @example\n * socket.to(\"room-101\").timeout(3000).emitWithAck(\"confirm\", data)\n */\n timeout(ms: number): ArkosEmitTarget;\n\n /**\n * Returns all sockets currently matched by this target.\n *\n * @example\n * const sockets = await socket.to(\"room-101\").fetchSockets()\n */\n fetchSockets(): Promise<any[]>;\n\n to(room: string | string[]): ArkosEmitTarget;\n\n /**\n * Sets the volatile flag — the event may be dropped if the client is not ready.\n * Useful for high-frequency non-critical events like cursor positions or typing indicators.\n *\n * @example\n * socket.to(\"room-101\").volatile.emit(\"cursor\", position)\n */\n readonly volatile: ArkosEmitTarget<EmitEvents>;\n}\nexport class ArkosGatewayController {}\n\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ArkosPrismaService } from '../../exports/services/index.js';
|
|
1
|
+
import { ArkosPrismaService, AuthService } from '../../exports/services/index.js';
|
|
2
2
|
import ExitError from '../../utils/helpers/exit-error.js';
|
|
3
3
|
export function ArkosRouteHook(moduleName, configs) {
|
|
4
4
|
const store = {};
|
|
@@ -6,8 +6,14 @@ export function ArkosRouteHook(moduleName, configs) {
|
|
|
6
6
|
store[name] = config;
|
|
7
7
|
return proxy;
|
|
8
8
|
};
|
|
9
|
-
if (configs?.service
|
|
10
|
-
|
|
9
|
+
if (configs?.service) {
|
|
10
|
+
if (moduleName === 'auth') {
|
|
11
|
+
if (!(configs.service instanceof AuthService))
|
|
12
|
+
throw ExitError(`Invalid service configured for "auth": expected an instance of AuthService, please make your service object extend the AuthService class.`);
|
|
13
|
+
}
|
|
14
|
+
else if (!(configs.service instanceof ArkosPrismaService))
|
|
15
|
+
throw ExitError(`Invalid service configured for model "${moduleName}": expected an instance of ArkosPrismaService, please make your service object extend the ArkosPrismaService class see https://www.arkosjs.com/docs/reference/base-service`);
|
|
16
|
+
}
|
|
11
17
|
const base = {
|
|
12
18
|
__type: 'ArkosRouteHook',
|
|
13
19
|
moduleName,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/arkos-route-hook/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/arkos-route-hook/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM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,OAAO,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;SAAM,CAAC;QACN,KAAK,MAAM,IAAI,IAAI;YACjB,WAAW;YACX,SAAS;YACT,UAAU;YACV,WAAW;YACX,WAAW;YACX,YAAY;YACZ,YAAY;YACZ,YAAY;SACb,EAAE,CAAC;YACF,OAAO,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC;QACnC,CAAC;IACH,CAAC;IAED,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;IAE3C,OAAO,KAA2C,CAAC;AACrD,CAAC","sourcesContent":["import { ArkosPrismaService, AuthService } from '../../exports/services';\nimport ExitError from '../../utils/helpers/exit-error';\nimport {\n ArkosModuleType,\n ArkosRouteHookReturn,\n ArkosRouteHookMethodConfig,\n} from './types';\n\ninterface InterceptorStore {\n [methodName: string]: ArkosRouteHookMethodConfig;\n}\n\n/**\n * Creates an interceptor for a built-in Arkos module or a generated model route.\n *\n * The returned instance exposes only the methods relevant to that module,\n * and is registered into the app via `app.load()`.\n *\n * @param moduleName - The module to intercept. Use `\"auth\"` or `\"file-upload\"`\n * for built-in modules, or any prisma model name string for generated CRUD routes.\n *\n * @example\n * ```ts\n * const userRouteHook = ArkosRouteHook(\"user\");\n *\n * userRouteHook.createOne({\n * validation: { body: CreateUserSchema },\n * before: [sanitize],\n * after: [notify]\n * });\n *\n * app.load(userRouteHook);\n * ```\n * @see {@link https://www.arkosjs.com/docs/core-concepts/components/route-hooks}\n */\nexport function ArkosRouteHook<T extends ArkosModuleType>(\n moduleName: T,\n configs?: {\n /**\n * `ArkosPrismaService` instance for such model, or an `AuthService`\n * subclass instance when `moduleName` is `\"auth\"`.\n */\n service?: T extends 'auth' ? AuthService : ArkosPrismaService<T>;\n },\n): ArkosRouteHookReturn<T> {\n const store: InterceptorStore = {};\n\n const makeMethod = (name: string) => (config: ArkosRouteHookMethodConfig) => {\n store[name] = config;\n return proxy;\n };\n\n if (configs?.service) {\n if (moduleName === 'auth') {\n if (!(configs.service instanceof AuthService))\n throw ExitError(\n `Invalid service configured for \"auth\": expected an instance of AuthService, please make your service object extend the AuthService class.`,\n );\n } else if (!(configs.service instanceof ArkosPrismaService))\n throw ExitError(\n `Invalid service configured for model \"${moduleName}\": expected an instance of ArkosPrismaService, please make your service object extend the ArkosPrismaService class see https://www.arkosjs.com/docs/reference/base-service`,\n );\n }\n\n const base = {\n __type: 'ArkosRouteHook' as const,\n moduleName,\n _store: store,\n _configs: configs || {},\n };\n\n const methods: Record<\n string,\n (config: ArkosRouteHookMethodConfig) => unknown\n > = {};\n\n if (moduleName === 'auth') {\n for (const name of [\n 'getMe',\n 'login',\n 'logout',\n 'signup',\n 'updateMe',\n 'updatePassword',\n ]) {\n methods[name] = makeMethod(name);\n }\n } else if (moduleName === 'file-upload' || moduleName === 'fileUpload') {\n for (const name of ['findFile', 'uploadFile', 'updateFile', 'deleteFile']) {\n methods[name] = makeMethod(name);\n }\n } else {\n for (const name of [\n 'createOne',\n 'findOne',\n 'findMany',\n 'updateOne',\n 'deleteOne',\n 'createMany',\n 'updateMany',\n 'deleteMany',\n ]) {\n methods[name] = makeMethod(name);\n }\n }\n\n const proxy = Object.assign(base, methods);\n\n return proxy as unknown as ArkosRouteHookReturn<T>;\n}\n\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reader.js","sourceRoot":"","sources":["../../../../src/components/arkos-route-hook/reader.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,MAAM,0CAA0C,CAAC;AAUxE,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"reader.js","sourceRoot":"","sources":["../../../../src/components/arkos-route-hook/reader.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,MAAM,0CAA0C,CAAC;AAUxE,OAAO,EAAE,SAAS,EAAE,MAA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C,QAAQ,CAAC,UAAU,CAAC,CAAC,SAAmB,CAAC,EAAE,UAAU,CAAC;IACpE,CAAC;IAKD,YAAY,CACV,UAAmB,EACnB,SAAqC;QAKrC,MAAM,EACJ,MAAM,GAAG,EAAE,EACX,KAAK,GAAG,EAAE,EACV,OAAO,GAAG,EAAE,GACb,GAAG,IAAI,CAAC,QAAQ,CAAC,UAAU,EAAE,SAAS,CAAC,IAAI,EAAE,CAAC;QAC/C,MAAM,UAAU,GAAG,IAAI,CAAC,aAAa,CAAC,UAAU,EAAE,SAAS,CAAC,CAAC;QAC7D,MAAM,WAAW,GAAG,IAAI,CAAC,cAAc,CAAC,UAAU,EAAE,SAAS,CAAC,IAAI,EAAE,CAAC;QACrE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,CAAC;IAC7D,CAAC;CACF;AAED,MAAM,CAAC,MAAM,eAAe,GAAG,IAAI,oBAAoB,EAAE,CAAC","sourcesContent":["import loadableRegistry from \"../../components/arkos-loadable-registry\";\nimport {\n ArkosModuleType,\n ArkosRouteHookHooks,\n ArkosRouteHookMethodConfig,\n ArkosRouteHookInstance,\n ArkosAuthRouteHookInstance,\n ArkosFileUploadRouteHookInstance,\n} from \"./types\";\nimport { ArkosRouteConfig } from \"../../exports\";\nimport { kebabCase } from \"../../exports/utils\";\n\ntype PrismaOperations = keyof Omit<\n ArkosRouteHookInstance<any>,\n \"__type\" | \"moduleName\" | \"_configs\"\n>;\n\nexport type OperationByModule<TModule extends ArkosModuleType> =\n TModule extends \"file-upload\"\n ? keyof Omit<ArkosFileUploadRouteHookInstance, \"__type\" | \"moduleName\" | \"service\">\n : TModule extends \"auth\"\n ? keyof Omit<\n ArkosAuthRouteHookInstance,\n \"__type\" | \"moduleName\" | \"_configs\" | \"service\"\n >\n : PrismaOperations;\n\n/**\n * Reader for `ArkosRouteHook` instances.\n * Reads config from the global loadable registry by module name.\n *\n * @example\n * ```ts\n * routeHookReader.getHooks(\"user\", \"findMany\") // { before, after, onError }\n * routeHookReader.getRouteConfig(\"user\", \"findMany\") // ArkosRouteConfig minus path and hooks\n * routeHookReader.getPrismaArgs(\"user\", \"findMany\") // prismaArgs for that operation\n * routeHookReader.getFullConfig(\"user\", \"findMany\") // full raw config object\n * routeHookReader.hasOperation(\"user\", \"findMany\") // true | false\n * routeHookReader.forOperation(\"user\", \"findMany\") // { before, after, onError, prismaArgs, routeConfig }\n * ```\n */\nclass ArkosRouteHookReader {\n private getRouteHook(moduleName: ArkosModuleType) {\n return loadableRegistry.getItem(\"ArkosRouteHook\", kebabCase(moduleName));\n }\n\n private getStore(\n moduleName: ArkosModuleType\n ): Record<string, ArkosRouteHookMethodConfig> {\n return (this.getRouteHook(moduleName) as any)?._store ?? {};\n }\n\n /**\n * Returns true if the routeHook has a config registered for the given operation.\n */\n hasOperation<TModule extends ArkosModuleType>(\n moduleName: TModule,\n operation: OperationByModule<TModule>\n ): boolean {\n return operation in this.getStore(moduleName);\n }\n\n /**\n * Returns the full raw config for the given operation, or `null` if not registered.\n */\n getFullConfig<TModule extends ArkosModuleType>(\n moduleName: TModule,\n operation: OperationByModule<TModule>\n ): ArkosRouteHookMethodConfig | null {\n return this.getStore(moduleName)[operation as string] ?? null;\n }\n\n /**\n * Returns only the lifecycle hooks (`before`, `after`, `onError`) for the given operation.\n */\n getHooks<TModule extends ArkosModuleType>(\n moduleName: TModule,\n operation: OperationByModule<TModule>\n ): ArkosRouteHookHooks | undefined {\n const config = this.getStore(moduleName)[operation as string];\n if (!config) return {};\n const { before, after, onError } = config;\n return { before, after, onError };\n }\n\n /**\n * Returns the `ArkosRouteConfig` portion of the config (excludes `path`, hooks, and `prismaArgs`)\n * for the given operation.\n */\n getRouteConfig<TModule extends ArkosModuleType>(\n moduleName: TModule,\n operation: OperationByModule<TModule>\n ): Omit<ArkosRouteConfig, \"path\"> | null {\n const config = this.getStore(moduleName)[operation as string];\n if (!config) return null;\n const { before, after, onError, prismaArgs, ...routeConfig } = config;\n return routeConfig;\n }\n\n /**\n * Returns the `prismaArgs` for the given operation, or `undefined` if not set.\n */\n getPrismaArgs<TModule extends ArkosModuleType>(\n moduleName: TModule,\n operation: OperationByModule<TModule>\n ): Record<string, any> | undefined {\n return this.getStore(moduleName)[operation as string]?.prismaArgs;\n }\n\n /**\n * Returns all extracted slices for a given operation in one call.\n */\n forOperation<TModule extends ArkosModuleType>(\n moduleName: TModule,\n operation: OperationByModule<TModule>\n ): ArkosRouteHookHooks & {\n prismaArgs?: Record<string, any>;\n routeConfig: Omit<ArkosRouteConfig, \"path\">;\n } {\n const {\n before = [],\n after = [],\n onError = [],\n } = this.getHooks(moduleName, operation) || {};\n const prismaArgs = this.getPrismaArgs(moduleName, operation);\n const routeConfig = this.getRouteConfig(moduleName, operation) ?? {};\n return { before, after, onError, prismaArgs, routeConfig };\n }\n}\n\nexport const routeHookReader = new ArkosRouteHookReader();\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/components/arkos-route-hook/types.ts"],"names":[],"mappings":"","sourcesContent":["import { ArkosRouteConfig } from \"../../exports\";\nimport { ArkosPrismaService } from \"../../exports/services\";\nimport { PrismaModels } from \"../../generated\";\nimport { ArkosErrorRequestHandler, ArkosRequestHandler } from \"../../types\";\n\nexport type Models = keyof PrismaModels<any>;\n\nexport interface ArkosRouteHookHooks {\n before?: ArkosRequestHandler[] | ArkosRequestHandler;\n after?: ArkosRequestHandler[] | ArkosRequestHandler;\n onError?: ArkosErrorRequestHandler[] | ArkosErrorRequestHandler;\n}\n\n/**\n * Extracts the correct Prisma args type for a given model and operation.\n * Falls back to `Record<string, any>` if the model or operation is not found.\n */\ntype PrismaQueryFor<\n TModel extends string,\n TOp extends string,\n> = TModel extends keyof PrismaModels<any>\n ? TOp extends keyof PrismaModels<any>[TModel]\n ? Partial<PrismaModels<any>[TModel][TOp]>\n : Record<string, any>\n : Record<string, any>;\n\n/**\n * Full config for an interceptor method — inherits all ArkosRouteConfig options\n * (validation, auth, rate limiting, etc.) minus `path`, plus lifecycle hooks,\n * plus `prismaArgs` typed to the specific model and operation's Prisma args.\n */\nexport type ArkosRouteHookMethodConfig<\n TModel extends string = string,\n TOp extends string = string,\n> = Omit<ArkosRouteConfig, \"path\"> &\n ArkosRouteHookHooks & {\n /**\n * Prisma options merged into this operation's query.\n * Typed against the model's actual Prisma args for this operation.\n */\n prismaArgs?: PrismaQueryFor<TModel, TOp>;\n };\n\n/**\n * Union of all valid module name types for ArkosRouteHook.\n * `string & {}` preserves autocomplete for \"auth\" and \"file-upload\"\n * while still accepting arbitrary model names.\n */\nexport type ArkosModuleType = \"auth\" | \"file-upload\" | Models;\n\n/**\n * Route hook instance for standard CRUD model routes.\n * Each method's `prismaQuery` is typed against the model's actual Prisma args.\n */\nexport interface ArkosRouteHookInstance<TModel extends Models> {\n readonly __type: \"ArkosRouteHook\";\n readonly moduleName: TModel;\n readonly _configs: {\n readonly service?: ArkosPrismaService;\n }\n\n createOne(config: ArkosRouteHookMethodConfig<TModel, \"CreateArgs\">): this;\n findOne(config: ArkosRouteHookMethodConfig<TModel, \"FindFirstArgs\">): this;\n findMany(config: ArkosRouteHookMethodConfig<TModel, \"FindManyArgs\">): this;\n updateOne(config: ArkosRouteHookMethodConfig<TModel, \"UpdateArgs\">): this;\n deleteOne(config: ArkosRouteHookMethodConfig<TModel, \"DeleteArgs\">): this;\n createMany(\n config: ArkosRouteHookMethodConfig<TModel, \"CreateManyArgs\">\n ): this;\n updateMany(\n config: ArkosRouteHookMethodConfig<TModel, \"UpdateManyArgs\">\n ): this;\n deleteMany(\n config: ArkosRouteHookMethodConfig<TModel, \"DeleteManyArgs\">\n ): this;\n}\n\n/**\n * Route hook instance for the built-in auth module.\n * Only exposes methods relevant to auth routes.\n */\nexport interface ArkosAuthRouteHookInstance {\n readonly __type: \"ArkosRouteHook\";\n readonly moduleName: \"auth\";\n\n getMe(config: ArkosRouteHookMethodConfig): this;\n login(config: ArkosRouteHookMethodConfig): this;\n logout(config: ArkosRouteHookMethodConfig): this;\n signup(config: ArkosRouteHookMethodConfig): this;\n updateMe(config: ArkosRouteHookMethodConfig): this;\n deleteMe(config: ArkosRouteHookMethodConfig): this;\n updatePassword(config: ArkosRouteHookMethodConfig): this;\n findOneAuthAction(config: ArkosRouteHookMethodConfig): this;\n findManyAuthAction(config: ArkosRouteHookMethodConfig): this;\n}\n\n/**\n * Route hook instance for the built-in file-upload module.\n * Only exposes methods relevant to file routes.\n */\nexport interface ArkosFileUploadRouteHookInstance {\n readonly __type: \"ArkosRouteHook\";\n readonly moduleName: \"file-upload\";\n\n findFile(config: Omit<ArkosRouteHookMethodConfig, \"after\">): this;\n uploadFile(config: ArkosRouteHookMethodConfig): this;\n updateFile(config: ArkosRouteHookMethodConfig): this;\n deleteFile(config: ArkosRouteHookMethodConfig): this;\n}\n\n/**\n * Maps the module type string to its corresponding interceptor instance type.\n * Enables ArkosRouteHook() to return a narrowed type based on the argument.\n */\nexport type ArkosRouteHookReturn<T extends ArkosModuleType> = T extends \"auth\"\n ? ArkosAuthRouteHookInstance\n : T extends \"file-upload\"\n ? ArkosFileUploadRouteHookInstance\n : ArkosRouteHookInstance<T>;\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/components/arkos-route-hook/types.ts"],"names":[],"mappings":"","sourcesContent":["import { ArkosRouteConfig } from \"../../exports\";\nimport { ArkosPrismaService, AuthService } from \"../../exports/services\";\nimport { PrismaModels } from \"../../generated\";\nimport { ArkosErrorRequestHandler, ArkosRequestHandler } from \"../../types\";\n\nexport type Models = keyof PrismaModels<any>;\n\nexport interface ArkosRouteHookHooks {\n before?: ArkosRequestHandler[] | ArkosRequestHandler;\n after?: ArkosRequestHandler[] | ArkosRequestHandler;\n onError?: ArkosErrorRequestHandler[] | ArkosErrorRequestHandler;\n}\n\n/**\n * Extracts the correct Prisma args type for a given model and operation.\n * Falls back to `Record<string, any>` if the model or operation is not found.\n */\ntype PrismaQueryFor<\n TModel extends string,\n TOp extends string,\n> = TModel extends keyof PrismaModels<any>\n ? TOp extends keyof PrismaModels<any>[TModel]\n ? Partial<PrismaModels<any>[TModel][TOp]>\n : Record<string, any>\n : Record<string, any>;\n\n/**\n * Full config for an interceptor method — inherits all ArkosRouteConfig options\n * (validation, auth, rate limiting, etc.) minus `path`, plus lifecycle hooks,\n * plus `prismaArgs` typed to the specific model and operation's Prisma args.\n */\nexport type ArkosRouteHookMethodConfig<\n TModel extends string = string,\n TOp extends string = string,\n> = Omit<ArkosRouteConfig, \"path\"> &\n ArkosRouteHookHooks & {\n /**\n * Prisma options merged into this operation's query.\n * Typed against the model's actual Prisma args for this operation.\n */\n prismaArgs?: PrismaQueryFor<TModel, TOp>;\n };\n\n/**\n * Union of all valid module name types for ArkosRouteHook.\n * `string & {}` preserves autocomplete for \"auth\" and \"file-upload\"\n * while still accepting arbitrary model names.\n */\nexport type ArkosModuleType = \"auth\" | \"file-upload\" | Models;\n\n/**\n * Route hook instance for standard CRUD model routes.\n * Each method's `prismaQuery` is typed against the model's actual Prisma args.\n */\nexport interface ArkosRouteHookInstance<TModel extends Models> {\n readonly __type: \"ArkosRouteHook\";\n readonly moduleName: TModel;\n readonly _configs: {\n readonly service?: ArkosPrismaService;\n }\n\n createOne(config: ArkosRouteHookMethodConfig<TModel, \"CreateArgs\">): this;\n findOne(config: ArkosRouteHookMethodConfig<TModel, \"FindFirstArgs\">): this;\n findMany(config: ArkosRouteHookMethodConfig<TModel, \"FindManyArgs\">): this;\n updateOne(config: ArkosRouteHookMethodConfig<TModel, \"UpdateArgs\">): this;\n deleteOne(config: ArkosRouteHookMethodConfig<TModel, \"DeleteArgs\">): this;\n createMany(\n config: ArkosRouteHookMethodConfig<TModel, \"CreateManyArgs\">\n ): this;\n updateMany(\n config: ArkosRouteHookMethodConfig<TModel, \"UpdateManyArgs\">\n ): this;\n deleteMany(\n config: ArkosRouteHookMethodConfig<TModel, \"DeleteManyArgs\">\n ): this;\n}\n\n/**\n * Route hook instance for the built-in auth module.\n * Only exposes methods relevant to auth routes.\n */\nexport interface ArkosAuthRouteHookInstance {\n readonly __type: \"ArkosRouteHook\";\n readonly moduleName: \"auth\";\n readonly _configs: {\n readonly service?: AuthService;\n };\n\n getMe(config: ArkosRouteHookMethodConfig): this;\n login(config: ArkosRouteHookMethodConfig): this;\n logout(config: ArkosRouteHookMethodConfig): this;\n signup(config: ArkosRouteHookMethodConfig): this;\n updateMe(config: ArkosRouteHookMethodConfig): this;\n deleteMe(config: ArkosRouteHookMethodConfig): this;\n updatePassword(config: ArkosRouteHookMethodConfig): this;\n findOneAuthAction(config: ArkosRouteHookMethodConfig): this;\n findManyAuthAction(config: ArkosRouteHookMethodConfig): this;\n}\n\n/**\n * Route hook instance for the built-in file-upload module.\n * Only exposes methods relevant to file routes.\n */\nexport interface ArkosFileUploadRouteHookInstance {\n readonly __type: \"ArkosRouteHook\";\n readonly moduleName: \"file-upload\";\n\n findFile(config: Omit<ArkosRouteHookMethodConfig, \"after\">): this;\n uploadFile(config: ArkosRouteHookMethodConfig): this;\n updateFile(config: ArkosRouteHookMethodConfig): this;\n deleteFile(config: ArkosRouteHookMethodConfig): this;\n}\n\n/**\n * Maps the module type string to its corresponding interceptor instance type.\n * Enables ArkosRouteHook() to return a narrowed type based on the argument.\n */\nexport type ArkosRouteHookReturn<T extends ArkosModuleType> = T extends \"auth\"\n ? ArkosAuthRouteHookInstance\n : T extends \"file-upload\"\n ? ArkosFileUploadRouteHookInstance\n : ArkosRouteHookInstance<T>;\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-upload.js","sourceRoot":"","sources":["../../../src/exports/file-upload.ts"],"names":[],"mappings":"","sourcesContent":["export type {\n ArkosFile,\n PrepareFileContext,\n UploadDirParams,\n UploadPrepare,\n UploadPrepareFile,\n UploadUrlPath,\n} from \"../types/upload\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/exports/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,WAAW,MAAM,uBAAuB,CAAC;AAUhD,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,KAAK,MAAM,QAAQ,CAAC;AAC3B,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAEhE,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAIzD,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAErE,OAAO,EAOL,cAAc,EAEd,wBAAwB,EACxB,cAAc,EACd,cAAc,EACd,WAAW,EAGX,WAAW,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/exports/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACnE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,WAAW,MAAM,uBAAuB,CAAC;AAUhD,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AACnE,OAAO,KAAK,MAAM,QAAQ,CAAC;AAC3B,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAEhE,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAIzD,OAAO,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAErE,OAAO,EAOL,cAAc,EAEd,wBAAwB,EACxB,cAAc,EACd,cAAc,EACd,WAAW,EAGX,WAAW,EAEX,YAAY,GACb,CAAC;AAEF,eAAe,KAAK,CAAC","sourcesContent":["import { BaseController } from \"./../modules/base/base.controller\";\nimport { getArkosConfig } from \"../server\";\nimport ArkosRouter from \"../utils/arkos-router\";\nimport { IArkosRouter } from \"../utils/arkos-router/types\";\nimport { ArkosRouteConfig } from \"../utils/arkos-router/types\";\nimport {\n ArkosRequest,\n ArkosResponse,\n ArkosNextFunction,\n ArkosRequestHandler,\n} from \"../types\";\nimport { ArkosConfig } from \"../types/new-arkos-config\";\nimport { loadEnvironmentVariables } from \"../utils/dotenv.helpers\";\nimport arkos from \"../app\";\nimport { ArkosRouteHook } from \"../components/arkos-route-hook\";\nimport { ArkosRouteHookInstance } from \"../components/arkos-route-hook/types\";\nimport { ArkosPolicy } from \"../components/arkos-policy\";\nimport { IArkosPolicy } from \"../components/arkos-policy/types\";\nimport type { ArkosLoadable } from \"../types/arkos\";\nimport { ArkosFile } from \"../types/upload\";\nimport { isProduction } from \"../utils/helpers/arkos-config.helpers\";\n\nexport {\n ArkosLoadable,\n ArkosRequest,\n ArkosResponse,\n ArkosNextFunction,\n ArkosRequestHandler,\n IArkosRouter,\n BaseController,\n ArkosConfig,\n loadEnvironmentVariables,\n getArkosConfig,\n ArkosRouteHook,\n ArkosRouter,\n ArkosRouteConfig,\n ArkosRouteHookInstance,\n ArkosPolicy,\n IArkosPolicy,\n isProduction,\n};\n\nexport default arkos;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"websockets.js","sourceRoot":"","sources":["../../../src/exports/websockets.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,2CAA2C,CAAC;AAErE,OAAO,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAC;AAC1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;
|
|
1
|
+
{"version":3,"file":"websockets.js","sourceRoot":"","sources":["../../../src/exports/websockets.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,2CAA2C,CAAC;AAErE,OAAO,EAAE,aAAa,EAAE,MAAM,2CAA2C,CAAC;AAC1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AAc3E,OAAO,EAAE,YAAY,EAAE,CAAC","sourcesContent":["import ArkosGateway from \"../components/arkos-gateway/arkos-gateway\";\n\nexport { IArkosGateway } from \"../components/arkos-gateway/arkos-gateway\";\nexport { ArkosGatewayController } from \"../components/arkos-gateway/types\";\nexport type {\n ArkosSocket,\n ArkosGatewayConfig,\n ArkosGatewayEventConfig,\n ArkosGatewayHandler,\n ArkosGatewayPipe,\n ArkosGatewayMiddleware,\n ArkosGatewayConnectionHandler,\n ArkosGatewayErrorHandler,\n ArkosGatewayAckFn,\n ArkosBroadcastOperator,\n} from \"../components/arkos-gateway/types\";\n\nexport { ArkosGateway };\n"]}
|