arkos 2.0.0-next.26 → 2.0.0-next.28
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/cli.js +1 -8
- package/dist/esm/components/arkos-gateway/arkos-gateway.js +9 -2
- package/dist/esm/components/arkos-gateway/arkos-gateway.js.map +1 -1
- package/dist/esm/components/arkos-gateway/socket-extensions.js +26 -18
- package/dist/esm/components/arkos-gateway/socket-extensions.js.map +1 -1
- package/dist/esm/components/arkos-gateway/types.js.map +1 -1
- package/dist/esm/modules/email/email.service.js +4 -2
- package/dist/esm/modules/email/email.service.js.map +1 -1
- package/dist/esm/utils/cli/build.js +2 -3
- package/dist/esm/utils/cli/build.js.map +1 -1
- package/dist/esm/utils/cli/dev.js +2 -4
- package/dist/esm/utils/cli/dev.js.map +1 -1
- package/dist/esm/utils/cli/export-auth-action.js +2 -3
- package/dist/esm/utils/cli/export-auth-action.js.map +1 -1
- package/dist/esm/utils/cli/index.js +13 -0
- package/dist/esm/utils/cli/index.js.map +1 -1
- package/dist/esm/utils/cli/prisma-generate.js +43 -2
- package/dist/esm/utils/cli/prisma-generate.js.map +1 -1
- package/dist/esm/utils/cli/start.js +2 -4
- 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/watermark-stamper.js +1 -1
- package/dist/esm/utils/cli/utils/watermark-stamper.js.map +1 -1
- package/dist/esm/utils/dotenv.helpers.js +3 -1
- package/dist/esm/utils/dotenv.helpers.js.map +1 -1
- package/dist/esm/utils/helpers/arkos-config.helpers.js +3 -2
- package/dist/esm/utils/helpers/arkos-config.helpers.js.map +1 -1
- package/dist/esm/utils/helpers/prisma.helpers.js +2 -2
- package/dist/esm/utils/helpers/prisma.helpers.js.map +1 -1
- package/dist/types/components/arkos-gateway/arkos-gateway.d.ts +4 -2
- package/dist/types/components/arkos-gateway/socket-extensions.d.ts +5 -4
- package/dist/types/components/arkos-gateway/types.d.ts +86 -0
- package/dist/types/modules/email/email.service.d.ts +2 -0
- package/dist/types/utils/dotenv.helpers.d.ts +1 -0
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"arkos-config.helpers.js","sourceRoot":"","sources":["../../../../src/utils/helpers/arkos-config.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAmB,MAAM,kBAAkB,CAAC;AACjE,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,KAAK,SAAS,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,CAAC,wCAAwC,CAAC,CAAC;AAE3C,IAAI,kBAAkB,GAAQ,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"arkos-config.helpers.js","sourceRoot":"","sources":["../../../../src/utils/helpers/arkos-config.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAmB,MAAM,kBAAkB,CAAC;AACjE,OAAO,IAAI,MAAM,SAAS,CAAC;AAC3B,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,KAAK,SAAS,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,CAAC,wCAAwC,CAAC,CAAC;AAE3C,IAAI,kBAAkB,GAAQ,EAAE,CAAC;AACjC,MAAM,cAAc,GAAG,gBAAgB,SAAS,CAAC,oBAAoB,EAAE,EAAE,CAAC;AAE1E,IAAI,CAAC;IACH,kBAAkB,GAAG,0BAA0B,CAAC;AAClD,CAAC;AAAC,OAAO,GAAQ,EAAE,CAAC;IAClB,IAAI,GAAG,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,GAAG,cAAc,GAAG,CAAC;QAC1D,IAAI,CAAC,IAAI,CACP,kCAAkC,cAAc,gBAAgB,EAChE;Y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B,MAAM,SAAS,CACb,gHAAgH,CACjH,CAAC;IAEJ,IACE,qBAAqB;QACrB,YAAY,EAAE;QACd,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU;QACvB,CAAC,MAAM,CAAC,cAAc,EAAE,GAAG,EAAE,MAAM;QAEnC,MAAM,SAAS,CACb,qHAAqH,CACtH,CAAC;IAEJ,IAAI,qBAAqB,IAAI,CAAC,iBAAiB,EAAE;QAC/C,MAAM,SAAS,CACb,2LAA2L,CAC5L,CAAC;AACN,CAAC","sourcesContent":["import { defineConfig, UserArkosConfig } from \"../define-config\";\nimport sheu from \"../sheu\";\nimport ExitError from \"./exit-error\";\nimport * as fsHelpers from \"./fs.helpers\";\nimport { getPrismaInstance } from \"./prisma.helpers\";\n(\"ReplaceWithNeededImportsForArkosConfig\"); // This will be filled by post build script\n\nlet definedArkosConfig: any = {};\nconst configFilename = `arkos.config.${fsHelpers.getUserFileExtension()}`;\n\ntry {\n definedArkosConfig = \"ReplaceWithDynamicImport\"; // This will be filled by post build script\n} catch (err: any) {\n if (err.message.toLowerCase().includes(`${configFilename}'`))\n sheu.warn(\n `Using default configs, because ${configFilename} was not found`,\n {\n timestamp: true,\n }\n );\n else throw err;\n}\n\nexport function isUsingAuthentication() {\n const { authentication } = getArkosConfig();\n return authentication?.mode;\n}\n\nexport function isAuthenticationEnabled() {\n const { authentication } = getArkosConfig();\n return authentication?.mode && authentication?.enabled !== false;\n}\n\n/**\n * Gives access to the underlying current configurations being used by **Arkos** by default and also loaded through `arkos.config.{ts|js}`\n *\n * @returns {ArkosConfig}\n */\nexport function getArkosConfig(): UserArkosConfig {\n const config =\n typeof definedArkosConfig === \"string\"\n ? { __loader: \"defineConfig\" }\n : (definedArkosConfig as any)?.default || { __loader: \"defineConfig\" };\n const configFile = `arkos.config.${fsHelpers.getUserFileExtension()}`;\n\n if (\n (config as any).__loader !== \"defineConfig\" &&\n //@ts-ignore\n typeof jest == \"undefined\" &&\n typeof definedArkosConfig === \"object\"\n ) {\n sheu.error(\n `From v1.6 config under ${configFile} must be wrapped in \\`defineConfig()\\` function from \\`arkos/config\\`. You can do the following under your ${configFile}:\n\nimport { defineConfig } from \"arkos/config\"\n\nconst config = defineConfig({ ... })\n\nexport default config\n`\n );\n process.exit(1);\n }\n\n return defineConfig(config) as any;\n}\n\n/**\n * Returns true if application is being run through `arkos start` after `arkos build`\n *\n * @since 1.5.16-beta\n */\nexport function isProduction() {\n return process.env.ARKOS_BUILD === \"true\";\n}\n\nexport function validateArkosConfig() {\n const config = getArkosConfig();\n const authenticationEnabled = isAuthenticationEnabled();\n\n if (!config?.source?.entryPoint)\n throw ExitError(\n `Invalid value for 'arkosConfig.source.entryPoint', please pass a valid path from the current working directory`\n );\n\n if (\n authenticationEnabled &&\n isProduction() &&\n !process.env.JWT_SECRET &&\n !config.authentication?.jwt?.secret\n )\n throw ExitError(\n `Missing jwt secret in production, see https://www.arkosjs.com/docs/core-concepts/authentication/setup#configuration`\n );\n\n if (authenticationEnabled && !getPrismaInstance())\n throw ExitError(\n `Arkos' authentication system relies on prisma instance, please disabled your authentication or see https://www.arkosjs.com/docs/core-concepts/prisma-orm/setup to setup a prisma instance`\n );\n}\n"]}
|
|
@@ -9,9 +9,9 @@ export function loadPrismaModule() {
|
|
|
9
9
|
return instance;
|
|
10
10
|
}
|
|
11
11
|
export function handlePrismaGet(target, prop, receiver) {
|
|
12
|
-
const originalProperty = (Reflect.get(target, prop, receiver)
|
|
12
|
+
const originalProperty = (Reflect.get(target, prop, receiver));
|
|
13
13
|
const isModel = typeof originalProperty === "object"
|
|
14
|
-
? "findMany" in originalProperty
|
|
14
|
+
? "findMany" in (originalProperty || {})
|
|
15
15
|
: false;
|
|
16
16
|
if (isModel && originalProperty) {
|
|
17
17
|
return new Proxy(originalProperty, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prisma.helpers.js","sourceRoot":"","sources":["../../../../src/utils/helpers/prisma.helpers.ts"],"names":[],"mappings":"AAAA,OAAO,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,CAAC,CAAC;gBACJ,CAAC;gBAED,OAAO,cAAc,CAAC;YACxB,CAAC;SACF,CAAC,CAAC;IACL,CAAC;IAED,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAED,MAAM,UAAU,iBAAiB;IAC/B,OAAO,IAAI,KAAK,CAAC,cAAc,EAAE,EAAE,MAAM,EAAE,QAAQ,IAAI,EAAE,EAAE;QACzD,GAAG,EAAE,eAAe;KACrB,CAAC,CAAC;AACL,CAAC","sourcesContent":["import { getArkosConfig } from \"./arkos-config.helpers\";\nimport sheu from \"../sheu\";\nimport { getUserFileExtension } from \"./fs.helpers\";\n\nexport let prismaInstance: any = null;\n\nexport function loadPrismaModule() {\n const instance = getArkosConfig()?.prisma?.instance;\n if (!instance)\n sheu.warn(\n `Prisma client instance not passed to arkos.config.${getUserFileExtension()}, see https://www.arkosjs.com/docs/core-concepts/prisma-orm/setup`,\n { timestamp: true }\n );\n return instance;\n}\n\nexport function handlePrismaGet(target: any, prop: string, receiver: any) {\n const originalProperty = (Reflect.get(target, prop, receiver)) as any;\n\n const isModel =\n typeof originalProperty === \"object\"\n ? \"findMany\" in (originalProperty || {})\n : false;\n\n if (isModel && originalProperty) {\n return new Proxy(originalProperty, {\n get(modelTarget, methodName, modelReceiver) {\n const originalMethod = Reflect.get(\n modelTarget,\n methodName,\n modelReceiver\n );\n\n if (typeof originalMethod === \"function\") {\n return function(...args: any[]) {\n const config = getArkosConfig();\n const debugLevel = config.debugging?.requests?.level || 0;\n\n if (debugLevel >= 3) {\n const queryArgs = args[0];\n\n if (queryArgs && Object.keys(queryArgs).length > 0) {\n sheu.debug(\n `Final Prisma Args\\n${JSON.stringify(queryArgs, null, 2)}`,\n { timestamp: true }\n );\n } else {\n sheu.debug(`Final Prisma Args - Empty`, { timestamp: true });\n }\n }\n\n return originalMethod.apply(modelTarget, args);\n };\n }\n\n return originalMethod;\n },\n });\n }\n\n return originalProperty;\n}\n\nexport function getPrismaInstance() {\n return new Proxy(getArkosConfig()?.prisma?.instance || {}, {\n get: handlePrismaGet,\n });\n}\n"]}
|
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import { ArkosGatewayConfig, ArkosGatewayErrorHandler, ArkosGatewayEventConfig, ArkosGatewayHandler, ArkosGatewayPipe, ArkosGatewayConnectionHandler, ArkosGatewayRegisterOptions } from "./types";
|
|
1
|
+
import { ArkosGatewayConfig, ArkosGatewayErrorHandler, ArkosGatewayEventConfig, ArkosGatewayHandler, ArkosGatewayPipe, ArkosGatewayConnectionHandler, ArkosGatewayRegisterOptions, ArkosBroadcastOperator, ArkosEmitTarget } from "./types";
|
|
2
2
|
import { Validator } from "../../types/validation/validator";
|
|
3
|
-
import { Server } from "socket.io";
|
|
3
|
+
import { BroadcastOperator, Namespace, Server } from "socket.io";
|
|
4
4
|
export declare class IArkosGateway {
|
|
5
5
|
private config;
|
|
6
6
|
private events;
|
|
7
7
|
private pipes;
|
|
8
8
|
private gateways;
|
|
9
9
|
private hooks;
|
|
10
|
+
private _nsp;
|
|
10
11
|
constructor(config: ArkosGatewayConfig);
|
|
12
|
+
get nsp(): Omit<Namespace, keyof ArkosEmitTarget | keyof BroadcastOperator<any, any>> & ArkosBroadcastOperator;
|
|
11
13
|
/**
|
|
12
14
|
* Register a Socket.io connection-level middleware — runs before a socket
|
|
13
15
|
* is accepted into this gateway's namespace. Also accepts a child
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import { ArkosSocket } from "./types";
|
|
2
|
-
import {
|
|
1
|
+
import { ArkosEmitTarget, ArkosSocket, ArkosUserTarget } from "./types";
|
|
2
|
+
import { Socket } from "socket.io";
|
|
3
3
|
export declare class ArkosBroadcastOperatorImpl {
|
|
4
|
-
private readonly
|
|
4
|
+
private readonly sockets;
|
|
5
5
|
private readonly operator;
|
|
6
|
-
constructor(
|
|
6
|
+
constructor(sockets: Map<string, Socket>, operator: ArkosEmitTarget);
|
|
7
|
+
user(userId: string): ArkosUserTarget;
|
|
7
8
|
/**
|
|
8
9
|
* Returns all unique user IDs currently in the target room(s).
|
|
9
10
|
* Uses the internal `arkos::user:` room convention to map sockets to users.
|
|
@@ -191,6 +191,22 @@ export interface ArkosBroadcastOperator<EmitEvents extends EventsMap = DefaultEv
|
|
|
191
191
|
* @return a Promise that will be fulfilled when all clients have acknowledged the event
|
|
192
192
|
*/
|
|
193
193
|
emitWithAck<Ev extends EventNamesWithError<EmitEvents>>(ev: Ev, ...args: AllButLast<EventParams<EmitEvents, Ev>>): Promise<FirstNonErrorArg<Last<EventParams<EmitEvents, Ev>>>>;
|
|
194
|
+
/**
|
|
195
|
+
* Targets all active socket connections of a user by their user ID.
|
|
196
|
+
* Uses the internal `arkos::user:{userId}` room convention.
|
|
197
|
+
*
|
|
198
|
+
* Supports emit, management, and exclusion operations across all of the
|
|
199
|
+
* user's active connections.
|
|
200
|
+
*
|
|
201
|
+
* @example
|
|
202
|
+
* socket.user(userId).emit("notification", data)
|
|
203
|
+
* socket.user(userId).except({ user: otherUserId }).emit("sync", data)
|
|
204
|
+
* const sockets = await socket.user(userId).fetchSockets()
|
|
205
|
+
* const online = await socket.user(userId).isOnline()
|
|
206
|
+
*
|
|
207
|
+
* @since 1.7.0-canary.29
|
|
208
|
+
*/
|
|
209
|
+
user(userId: string): ArkosUserTarget;
|
|
194
210
|
/**
|
|
195
211
|
* Returns all unique user IDs currently in the target room(s).
|
|
196
212
|
*
|
|
@@ -360,5 +376,75 @@ export interface ArkosGatewayStore {
|
|
|
360
376
|
*/
|
|
361
377
|
setIfNotExists(key: string, ttl: number): Promise<boolean>;
|
|
362
378
|
}
|
|
379
|
+
/**
|
|
380
|
+
* Minimal broadcast/emit contract that {@link ArkosBroadcastOperatorImpl} wraps.
|
|
381
|
+
* Deliberately narrower than socket.io's `BroadcastOperator` — only the methods
|
|
382
|
+
* Arkos actually calls, so both a `BroadcastOperator` (from `socket.to()`) and a
|
|
383
|
+
* raw `Namespace` (from `gateway.nsp`) satisfy it structurally.
|
|
384
|
+
*
|
|
385
|
+
* @since 1.7.1-canary.3
|
|
386
|
+
*/
|
|
387
|
+
export interface ArkosEmitTarget<EmitEvents extends EventsMap = DefaultEventsMap> {
|
|
388
|
+
/**
|
|
389
|
+
* Emits an event to the target. `_meta` (`mid` + `timestamp`) is injected automatically.
|
|
390
|
+
*
|
|
391
|
+
* @example
|
|
392
|
+
* socket.to("room-101").emit("message", { text: "hello" })
|
|
393
|
+
* socket.broadcast.emit("announcement", data)
|
|
394
|
+
*/
|
|
395
|
+
emit(event: string, ...args: any[]): boolean;
|
|
396
|
+
/**
|
|
397
|
+
* Emits an event and waits for an acknowledgement from all matched clients.
|
|
398
|
+
* `_meta` is injected automatically.
|
|
399
|
+
*
|
|
400
|
+
* Optional — not every target supports ack collection directly (e.g. a raw
|
|
401
|
+
* `Namespace` requires `.timeout(ms)` first). Throws at runtime if called on
|
|
402
|
+
* a target that doesn't implement it natively.
|
|
403
|
+
*
|
|
404
|
+
* @example
|
|
405
|
+
* const responses = await socket.to("room-101").timeout(3000).emitWithAck("confirm", data)
|
|
406
|
+
*/
|
|
407
|
+
emitWithAck?(event: string, ...args: any[]): Promise<any>;
|
|
408
|
+
/**
|
|
409
|
+
* Excludes sockets from the broadcast.
|
|
410
|
+
* Accepts a room name, socket ID, or array of rooms/IDs.
|
|
411
|
+
* For `{ user }` exclusion, see {@link ArkosBroadcastOperatorImpl.except}.
|
|
412
|
+
*
|
|
413
|
+
* @example
|
|
414
|
+
* socket.to("room-101").except("room-102").emit("foo", data)
|
|
415
|
+
*/
|
|
416
|
+
except(room: string | string[]): ArkosEmitTarget<EmitEvents>;
|
|
417
|
+
/**
|
|
418
|
+
* Sets the compress flag for the next emission.
|
|
419
|
+
*
|
|
420
|
+
* @example
|
|
421
|
+
* socket.broadcast.compress(false).emit("ping", data)
|
|
422
|
+
*/
|
|
423
|
+
compress(value: boolean): ArkosEmitTarget<EmitEvents>;
|
|
424
|
+
/**
|
|
425
|
+
* Sets a timeout in milliseconds for `emitWithAck`.
|
|
426
|
+
* Rejects the promise if no client acknowledges within the given delay.
|
|
427
|
+
*
|
|
428
|
+
* @example
|
|
429
|
+
* socket.to("room-101").timeout(3000).emitWithAck("confirm", data)
|
|
430
|
+
*/
|
|
431
|
+
timeout(ms: number): ArkosEmitTarget;
|
|
432
|
+
/**
|
|
433
|
+
* Returns all sockets currently matched by this target.
|
|
434
|
+
*
|
|
435
|
+
* @example
|
|
436
|
+
* const sockets = await socket.to("room-101").fetchSockets()
|
|
437
|
+
*/
|
|
438
|
+
fetchSockets(): Promise<any[]>;
|
|
439
|
+
to(room: string | string[]): ArkosEmitTarget;
|
|
440
|
+
/**
|
|
441
|
+
* Sets the volatile flag — the event may be dropped if the client is not ready.
|
|
442
|
+
* Useful for high-frequency non-critical events like cursor positions or typing indicators.
|
|
443
|
+
*
|
|
444
|
+
* @example
|
|
445
|
+
* socket.to("room-101").volatile.emit("cursor", position)
|
|
446
|
+
*/
|
|
447
|
+
readonly volatile: ArkosEmitTarget<EmitEvents>;
|
|
448
|
+
}
|
|
363
449
|
export declare class ArkosGatewayController {
|
|
364
450
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "arkos",
|
|
3
|
-
"version": "2.0.0-next.
|
|
3
|
+
"version": "2.0.0-next.28",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "The Express & Prisma RESTful Framework",
|
|
6
6
|
"main": "dist/esm/exports/index.js",
|
|
@@ -207,7 +207,7 @@
|
|
|
207
207
|
"uuidv7": "^1.2.1"
|
|
208
208
|
},
|
|
209
209
|
"peerDependencies": {
|
|
210
|
-
"@prisma/client": "7.9.
|
|
210
|
+
"@prisma/client": "7.9.1",
|
|
211
211
|
"@scalar/api-reference": "1.63.0",
|
|
212
212
|
"@scalar/express-api-reference": "0.10.11",
|
|
213
213
|
"bcryptjs": "3.0.3",
|