@mayhem93/nexxus-core-lib 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-cjs/common/BuiltinSchemas.js +24 -5
- package/dist-cjs/common/BuiltinSchemas.js.map +1 -1
- package/dist-cjs/common/FilterQuery.js +4 -15
- package/dist-cjs/common/FilterQuery.js.map +1 -1
- package/dist-cjs/common/InferModel.js +3 -0
- package/dist-cjs/common/InferModel.js.map +1 -0
- package/dist-cjs/common/JsonPatch.js +42 -225
- package/dist-cjs/common/JsonPatch.js.map +1 -1
- package/dist-cjs/common/SchemaValidator.js +100 -29
- package/dist-cjs/common/SchemaValidator.js.map +1 -1
- package/dist-cjs/index.js +3 -0
- package/dist-cjs/index.js.map +1 -1
- package/dist-cjs/lib/BaseService.js +6 -6
- package/dist-cjs/lib/BaseService.js.map +1 -1
- package/dist-cjs/lib/ConfigManager.js +18 -21
- package/dist-cjs/lib/ConfigManager.js.map +1 -1
- package/dist-cjs/lib/Exceptions.js +8 -1
- package/dist-cjs/lib/Exceptions.js.map +1 -1
- package/dist-cjs/lib/Logger.js +138 -65
- package/dist-cjs/lib/Logger.js.map +1 -1
- package/dist-cjs/models/AppModel.js +17 -3
- package/dist-cjs/models/AppModel.js.map +1 -1
- package/dist-cjs/models/Application.js +51 -12
- package/dist-cjs/models/Application.js.map +1 -1
- package/dist-cjs/models/BaseModel.js.map +1 -1
- package/dist-cjs/models/BuiltinModel.js +8 -0
- package/dist-cjs/models/BuiltinModel.js.map +1 -0
- package/dist-cjs/models/User.js +12 -3
- package/dist-cjs/models/User.js.map +1 -1
- package/dist-esm/common/BuiltinSchemas.js +23 -4
- package/dist-esm/common/BuiltinSchemas.js.map +1 -1
- package/dist-esm/common/FilterQuery.js +5 -16
- package/dist-esm/common/FilterQuery.js.map +1 -1
- package/dist-esm/common/InferModel.js +2 -0
- package/dist-esm/common/InferModel.js.map +1 -0
- package/dist-esm/common/JsonPatch.js +44 -227
- package/dist-esm/common/JsonPatch.js.map +1 -1
- package/dist-esm/common/SchemaValidator.js +100 -29
- package/dist-esm/common/SchemaValidator.js.map +1 -1
- package/dist-esm/index.js +3 -0
- package/dist-esm/index.js.map +1 -1
- package/dist-esm/lib/BaseService.js +8 -8
- package/dist-esm/lib/BaseService.js.map +1 -1
- package/dist-esm/lib/ConfigManager.js +18 -21
- package/dist-esm/lib/ConfigManager.js.map +1 -1
- package/dist-esm/lib/Exceptions.js +6 -0
- package/dist-esm/lib/Exceptions.js.map +1 -1
- package/dist-esm/lib/Logger.js +139 -66
- package/dist-esm/lib/Logger.js.map +1 -1
- package/dist-esm/models/AppModel.js +17 -3
- package/dist-esm/models/AppModel.js.map +1 -1
- package/dist-esm/models/Application.js +52 -13
- package/dist-esm/models/Application.js.map +1 -1
- package/dist-esm/models/BaseModel.js.map +1 -1
- package/dist-esm/models/BuiltinModel.js +4 -0
- package/dist-esm/models/BuiltinModel.js.map +1 -0
- package/dist-esm/models/User.js +11 -2
- package/dist-esm/models/User.js.map +1 -1
- package/dist-types/common/BuiltinSchemas.d.ts +59 -5
- package/dist-types/common/FilterQuery.d.ts +3 -11
- package/dist-types/common/InferModel.d.ts +29 -0
- package/dist-types/common/JsonPatch.d.ts +4 -45
- package/dist-types/common/ModelTypes.d.ts +1 -0
- package/dist-types/common/QueuePayloads.d.ts +48 -26
- package/dist-types/common/SchemaValidator.d.ts +42 -2
- package/dist-types/index.d.ts +3 -0
- package/dist-types/lib/BaseService.d.ts +8 -1
- package/dist-types/lib/ConfigManager.d.ts +6 -12
- package/dist-types/lib/Exceptions.d.ts +4 -0
- package/dist-types/lib/Logger.d.ts +84 -14
- package/dist-types/models/AppModel.d.ts +31 -5
- package/dist-types/models/Application.d.ts +36 -8
- package/dist-types/models/BaseModel.d.ts +14 -12
- package/dist-types/models/BuiltinModel.d.ts +3 -0
- package/dist-types/models/User.d.ts +15 -13
- package/package.json +4 -4
- package/src/schemas/winston-logger.schema.json +51 -6
|
@@ -1,9 +1,35 @@
|
|
|
1
|
+
import { NexxusApplicationSchema } from "./Application";
|
|
1
2
|
import { NexxusBaseModel, INexxusBaseModel } from "./BaseModel";
|
|
2
|
-
export
|
|
3
|
+
export interface INexxusAppModel extends INexxusBaseModel {
|
|
3
4
|
appId: string;
|
|
4
5
|
userId?: string;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Monotonically-increasing per-document version counter, assigned by the
|
|
8
|
+
* database adapter on every write. Used for client-side gap detection and
|
|
9
|
+
* dedup when applying real-time update events. App models flow through the
|
|
10
|
+
* async Writer → Transport Manager → client pipeline; built-in models
|
|
11
|
+
* (Application, User) do not and therefore do not carry a version.
|
|
12
|
+
* Never set by user input — the validator rejects user-supplied values.
|
|
13
|
+
*/
|
|
14
|
+
version?: number;
|
|
15
|
+
[key: string]: unknown;
|
|
16
|
+
}
|
|
17
|
+
export declare class NexxusAppModel extends NexxusBaseModel<INexxusAppModel> {
|
|
18
|
+
/**
|
|
19
|
+
* Construct an AppModel from user-supplied or pre-validated data.
|
|
20
|
+
*
|
|
21
|
+
* Pass the application's schema as the second argument to validate + normalize
|
|
22
|
+
* the input (e.g. date strings → integer timestamps). Pass `null` to skip
|
|
23
|
+
* validation — only do that when the data is already trusted (e.g. coming
|
|
24
|
+
* back from storage). The `fromStorage` static factory below is the preferred
|
|
25
|
+
* way to express that intent.
|
|
26
|
+
*/
|
|
27
|
+
constructor(props: INexxusAppModel, appSchema: NexxusApplicationSchema | null);
|
|
28
|
+
/**
|
|
29
|
+
* Hydrate an AppModel from already-validated storage. Use when reading back
|
|
30
|
+
* from the database — the data was validated when it was written, so we don't
|
|
31
|
+
* re-validate (saves work and avoids false-positives on legacy/edge-case docs
|
|
32
|
+
* that pre-date a later schema change).
|
|
33
|
+
*/
|
|
34
|
+
static fromStorage(props: INexxusAppModel): NexxusAppModel;
|
|
9
35
|
}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { INexxusBaseModel } from "./BaseModel";
|
|
2
|
+
import { NexxusBuiltinModel } from "./BuiltinModel";
|
|
2
3
|
import { NexxusModelDef } from "../common/ModelTypes";
|
|
4
|
+
import { InferModel } from "../common/InferModel";
|
|
5
|
+
import { NEXXUS_BUILTIN_MODEL_SCHEMAS } from "../common/BuiltinSchemas";
|
|
3
6
|
import { NexxusUserDetailSchema } from "./User";
|
|
4
7
|
export interface NexxusApplicationSchema {
|
|
5
8
|
[modelName: string]: NexxusModelDef;
|
|
@@ -7,23 +10,48 @@ export interface NexxusApplicationSchema {
|
|
|
7
10
|
export interface NexxusUserTypeConfig {
|
|
8
11
|
private?: boolean;
|
|
9
12
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
+
/**
|
|
14
|
+
* Per-application auth configuration. Lives on the Application document so
|
|
15
|
+
* that each tenant carries its own JWT secret and per-strategy settings.
|
|
16
|
+
*
|
|
17
|
+
* `strategies` is a map keyed by strategy name (must be a subset of the
|
|
18
|
+
* deployment's `api.auth.availableStrategies`). Each value's shape is
|
|
19
|
+
* whatever the strategy's own JSON Schema defines — validated by the
|
|
20
|
+
* corresponding `NexxusAuthStrategy` subclass at instantiation time.
|
|
21
|
+
*/
|
|
22
|
+
export interface NexxusApplicationAuthConfig {
|
|
23
|
+
jwtSecret: string;
|
|
24
|
+
jwtExpiresIn?: string;
|
|
25
|
+
strategies: Record<string, unknown>;
|
|
26
|
+
}
|
|
27
|
+
export type INexxusApplication = INexxusBaseModel<'application'> & InferModel<typeof NEXXUS_BUILTIN_MODEL_SCHEMAS.application> & {
|
|
13
28
|
schema: NexxusApplicationSchema;
|
|
14
|
-
authEnabled: boolean;
|
|
15
|
-
allowMultipleLogin: boolean | null;
|
|
16
29
|
userTypes?: {
|
|
17
30
|
[userType: string]: NexxusUserTypeConfig;
|
|
18
31
|
};
|
|
19
32
|
userDetailSchema?: {
|
|
20
33
|
[userType: string]: NexxusUserDetailSchema;
|
|
21
34
|
};
|
|
35
|
+
auth?: NexxusApplicationAuthConfig;
|
|
36
|
+
defaultLimit?: number;
|
|
37
|
+
maxLimit?: number;
|
|
22
38
|
};
|
|
23
|
-
export declare class NexxusApplication extends
|
|
24
|
-
constructor(data:
|
|
39
|
+
export declare class NexxusApplication extends NexxusBuiltinModel<INexxusApplication> {
|
|
40
|
+
constructor(data: INexxusApplication);
|
|
25
41
|
getSchema(): NexxusApplicationSchema;
|
|
26
42
|
getUserDetailSchema(userType?: string): NexxusUserDetailSchema | null;
|
|
43
|
+
hasAuthEnabled(): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Runtime field schema for one of the developer-declared models in this
|
|
46
|
+
* application's `schema` field. Built-in models (user, application) have
|
|
47
|
+
* their own static `getModelSchema` and are not resolved here.
|
|
48
|
+
*/
|
|
49
|
+
getAppModelSchema(modelType: string): NexxusModelDef;
|
|
50
|
+
/**
|
|
51
|
+
* Runtime field schema for Application records. Static because the schema
|
|
52
|
+
* is global — not per-app.
|
|
53
|
+
*/
|
|
54
|
+
static getModelSchema(): NexxusModelDef;
|
|
27
55
|
getAppModelFieldType(modelType: string, fieldPath: string): string | undefined;
|
|
28
56
|
getModelFilterableFields(modelType: string): Set<string>;
|
|
29
57
|
}
|
|
@@ -1,23 +1,25 @@
|
|
|
1
|
-
import { NexxusApplication,
|
|
2
|
-
import {
|
|
3
|
-
import { NexxusAppModel,
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import type { NexxusApplication, INexxusApplication } from "./Application";
|
|
2
|
+
import type { NexxusUser, INexxusUser } from "./User";
|
|
3
|
+
import type { NexxusAppModel, INexxusAppModel } from "./AppModel";
|
|
4
|
+
export declare const MODEL_REGISTRY: {
|
|
5
|
+
readonly application: "application";
|
|
6
|
+
readonly user: "user";
|
|
7
|
+
};
|
|
8
|
+
export type NexxusBuiltinTypeName = typeof MODEL_REGISTRY[keyof typeof MODEL_REGISTRY];
|
|
9
|
+
export type NexxusModelTypeName = NexxusBuiltinTypeName | (string & {});
|
|
10
|
+
export interface INexxusBaseModel<TType extends NexxusModelTypeName = NexxusModelTypeName> {
|
|
7
11
|
id?: string;
|
|
8
12
|
createdAt?: number;
|
|
9
13
|
updatedAt?: number;
|
|
10
14
|
type: TType;
|
|
11
15
|
}
|
|
12
|
-
export declare const MODEL_REGISTRY: {
|
|
13
|
-
readonly application: "application";
|
|
14
|
-
readonly user: "user";
|
|
15
|
-
};
|
|
16
|
-
export type NexxusBuiltinModelTypeName = typeof MODEL_REGISTRY[keyof typeof MODEL_REGISTRY];
|
|
17
|
-
export type NexxusModelTypeName = NexxusBuiltinModelTypeName | string;
|
|
18
16
|
export declare abstract class NexxusBaseModel<T extends INexxusBaseModel = INexxusBaseModel> {
|
|
19
17
|
protected data: T;
|
|
20
18
|
static readonly modelType: string | undefined;
|
|
21
19
|
constructor(data: T);
|
|
22
20
|
getData(): T;
|
|
23
21
|
}
|
|
22
|
+
export type AnyNexxusBuiltinModel = NexxusApplication | NexxusUser;
|
|
23
|
+
export type AnyNexxusBuiltinModelData = INexxusApplication | INexxusUser;
|
|
24
|
+
export type AnyNexxusModel = AnyNexxusBuiltinModel | NexxusAppModel;
|
|
25
|
+
export type AnyNexxusModelData = AnyNexxusBuiltinModelData | INexxusAppModel;
|
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
username: string;
|
|
7
|
-
password: string | null;
|
|
8
|
-
authProviders: Array<string>;
|
|
9
|
-
devices: Array<string>;
|
|
10
|
-
details?: Record<string, any>;
|
|
11
|
-
};
|
|
1
|
+
import { INexxusBaseModel } from "./BaseModel";
|
|
2
|
+
import { NexxusBuiltinModel } from "./BuiltinModel";
|
|
3
|
+
import { NexxusFieldDef, NexxusModelDef } from "../common/ModelTypes";
|
|
4
|
+
import { InferModel } from "../common/InferModel";
|
|
5
|
+
import { NEXXUS_BUILTIN_MODEL_SCHEMAS } from "../common/BuiltinSchemas";
|
|
12
6
|
export interface NexxusUserDetailSchema {
|
|
13
7
|
[field: string]: NexxusFieldDef;
|
|
14
8
|
}
|
|
15
|
-
export
|
|
16
|
-
|
|
9
|
+
export type INexxusUser = INexxusBaseModel<'user'> & InferModel<typeof NEXXUS_BUILTIN_MODEL_SCHEMAS.user> & {
|
|
10
|
+
details?: Record<string, any>;
|
|
11
|
+
};
|
|
12
|
+
export declare class NexxusUser extends NexxusBuiltinModel<INexxusUser> {
|
|
13
|
+
/**
|
|
14
|
+
* Runtime field schema for User records. Optionally overlays a per-userType
|
|
15
|
+
* detail schema (resolved from the owning application) into `details.properties`.
|
|
16
|
+
*/
|
|
17
|
+
static getModelSchema(userDetails?: NexxusUserDetailSchema | null): NexxusModelDef;
|
|
18
|
+
constructor(data: INexxusUser);
|
|
17
19
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mayhem93/nexxus-core-lib",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.2",
|
|
4
4
|
"description": "Core types and structures used by other Nexxus packages",
|
|
5
5
|
"main": "dist-cjs/index.js",
|
|
6
6
|
"module": "dist-esm/index.js",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"dist-*/**",
|
|
18
18
|
"src/schemas/**/*.json"
|
|
19
19
|
],
|
|
20
|
-
"homepage": "https://github.com/Mayhem93/nexxus-
|
|
20
|
+
"homepage": "https://github.com/Mayhem93/nexxus-lib/tree/main/src/core",
|
|
21
21
|
"keywords": ["realtime", "sync", "synchronization", "notifications", "backend", "baas"],
|
|
22
22
|
"author": "Răzvan Botea <contact@razvanbotea.me>",
|
|
23
23
|
"license": "MPL-2.0",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"@tsconfig/node24": "^24.0.1",
|
|
26
26
|
"@types/node": "^24.9.1",
|
|
27
27
|
"concurrently": "^9.2.1",
|
|
28
|
-
"typescript": "
|
|
28
|
+
"typescript": "^6.0.0"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@types/argparse": "^2.0.17",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
},
|
|
41
41
|
"repository": {
|
|
42
42
|
"type": "git",
|
|
43
|
-
"url": "https://github.com/Mayhem93/nexxus-
|
|
43
|
+
"url": "https://github.com/Mayhem93/nexxus-lib.git",
|
|
44
44
|
"directory": "src/core"
|
|
45
45
|
}
|
|
46
46
|
}
|
|
@@ -1,24 +1,69 @@
|
|
|
1
1
|
{
|
|
2
|
-
"$
|
|
2
|
+
"$id": "nexxus-winston-logger",
|
|
3
3
|
"type": "object",
|
|
4
4
|
"properties": {
|
|
5
5
|
"level": {
|
|
6
6
|
"type": "string",
|
|
7
|
-
"enum": ["debug", "info", "warn", "error", "critical", "alert", "emerg"]
|
|
7
|
+
"enum": ["debug", "info", "warn", "error", "critical", "alert", "emerg"],
|
|
8
|
+
"default": "info"
|
|
8
9
|
},
|
|
9
10
|
"logType": {
|
|
10
11
|
"type": "string",
|
|
11
|
-
"enum": ["text", "json"]
|
|
12
|
+
"enum": ["text", "json"],
|
|
13
|
+
"default": "text"
|
|
12
14
|
},
|
|
13
15
|
"timestamps": {
|
|
14
|
-
"type": "boolean"
|
|
16
|
+
"type": "boolean",
|
|
17
|
+
"default": true
|
|
15
18
|
},
|
|
16
19
|
"colors": {
|
|
17
|
-
"type": "boolean"
|
|
20
|
+
"type": "boolean",
|
|
21
|
+
"default": false
|
|
22
|
+
},
|
|
23
|
+
"transports": {
|
|
24
|
+
"type": "array",
|
|
25
|
+
"items": {
|
|
26
|
+
"oneOf": [
|
|
27
|
+
{ "$ref": "#/definitions/StdoutTransport" },
|
|
28
|
+
{ "$ref": "#/definitions/FileTransport" },
|
|
29
|
+
{ "$ref": "#/definitions/CustomTransport" }
|
|
30
|
+
]
|
|
31
|
+
}
|
|
18
32
|
}
|
|
19
33
|
},
|
|
20
34
|
"required": [
|
|
21
35
|
"level",
|
|
22
36
|
"logType"
|
|
23
|
-
]
|
|
37
|
+
],
|
|
38
|
+
"definitions": {
|
|
39
|
+
"StdoutTransport": {
|
|
40
|
+
"type": "object",
|
|
41
|
+
"properties": {
|
|
42
|
+
"type": { "const": "stdout" }
|
|
43
|
+
},
|
|
44
|
+
"required": ["type"],
|
|
45
|
+
"additionalProperties": false
|
|
46
|
+
},
|
|
47
|
+
"FileTransport": {
|
|
48
|
+
"type": "object",
|
|
49
|
+
"properties": {
|
|
50
|
+
"type": { "const": "file" },
|
|
51
|
+
"filename": { "type": "string" },
|
|
52
|
+
"maxSize": { "type": "number" },
|
|
53
|
+
"maxFiles": { "type": "number" }
|
|
54
|
+
},
|
|
55
|
+
"required": ["type", "filename"],
|
|
56
|
+
"additionalProperties": false
|
|
57
|
+
},
|
|
58
|
+
"CustomTransport": {
|
|
59
|
+
"type": "object",
|
|
60
|
+
"properties": {
|
|
61
|
+
"type": { "type": "string", "not": { "enum": ["stdout", "file"] } },
|
|
62
|
+
"export": { "type": "string" },
|
|
63
|
+
"options": { "type": "object" }
|
|
64
|
+
},
|
|
65
|
+
"required": ["type"],
|
|
66
|
+
"additionalProperties": false
|
|
67
|
+
}
|
|
68
|
+
}
|
|
24
69
|
}
|