@venizia/ignis-kernel 0.4.1 → 0.4.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/base/applications/cors.d.ts +13 -0
- package/dist/cjs/base/applications/cors.d.ts.map +1 -0
- package/dist/cjs/base/applications/cors.js +43 -0
- package/dist/cjs/base/applications/cors.js.map +1 -0
- package/dist/cjs/base/applications/deprecations.d.ts +10 -0
- package/dist/cjs/base/applications/deprecations.d.ts.map +1 -0
- package/dist/cjs/base/applications/deprecations.js +23 -0
- package/dist/cjs/base/applications/deprecations.js.map +1 -0
- package/dist/cjs/base/applications/rest.d.ts.map +1 -1
- package/dist/cjs/base/applications/rest.js +6 -0
- package/dist/cjs/base/applications/rest.js.map +1 -1
- package/dist/cjs/base/controllers/factory/authorize-guard.d.ts +19 -0
- package/dist/cjs/base/controllers/factory/authorize-guard.d.ts.map +1 -0
- package/dist/cjs/base/controllers/factory/authorize-guard.js +60 -0
- package/dist/cjs/base/controllers/factory/authorize-guard.js.map +1 -0
- package/dist/cjs/base/controllers/factory/controller.d.ts.map +1 -1
- package/dist/cjs/base/controllers/factory/controller.js +8 -0
- package/dist/cjs/base/controllers/factory/controller.js.map +1 -1
- package/dist/cjs/base/metadata/model-settings.d.ts +21 -0
- package/dist/cjs/base/metadata/model-settings.d.ts.map +1 -0
- package/dist/cjs/base/metadata/model-settings.js +77 -0
- package/dist/cjs/base/metadata/model-settings.js.map +1 -0
- package/dist/cjs/base/metadata/persistents.d.ts +1 -1
- package/dist/cjs/base/metadata/persistents.d.ts.map +1 -1
- package/dist/cjs/base/metadata/persistents.js +20 -8
- package/dist/cjs/base/metadata/persistents.js.map +1 -1
- package/dist/cjs/base/repositories/common/constants.d.ts +18 -1
- package/dist/cjs/base/repositories/common/constants.d.ts.map +1 -1
- package/dist/cjs/base/repositories/common/constants.js +22 -2
- package/dist/cjs/base/repositories/common/constants.js.map +1 -1
- package/dist/cjs/base/repositories/core/abstract.d.ts +1 -1
- package/dist/cjs/base/repositories/core/abstract.d.ts.map +1 -1
- package/dist/cjs/base/repositories/core/abstract.js +4 -4
- package/dist/cjs/base/repositories/core/abstract.js.map +1 -1
- package/dist/cjs/helpers/inversion/common/types/model.d.ts +94 -22
- package/dist/cjs/helpers/inversion/common/types/model.d.ts.map +1 -1
- package/dist/cjs/helpers/inversion/common/types/model.js.map +1 -1
- package/dist/esm/base/applications/cors.d.ts +13 -0
- package/dist/esm/base/applications/cors.d.ts.map +1 -0
- package/dist/esm/base/applications/cors.js +39 -0
- package/dist/esm/base/applications/cors.js.map +1 -0
- package/dist/esm/base/applications/deprecations.d.ts +10 -0
- package/dist/esm/base/applications/deprecations.d.ts.map +1 -0
- package/dist/esm/base/applications/deprecations.js +19 -0
- package/dist/esm/base/applications/deprecations.js.map +1 -0
- package/dist/esm/base/applications/rest.d.ts.map +1 -1
- package/dist/esm/base/applications/rest.js +6 -0
- package/dist/esm/base/applications/rest.js.map +1 -1
- package/dist/esm/base/controllers/factory/authorize-guard.d.ts +19 -0
- package/dist/esm/base/controllers/factory/authorize-guard.d.ts.map +1 -0
- package/dist/esm/base/controllers/factory/authorize-guard.js +56 -0
- package/dist/esm/base/controllers/factory/authorize-guard.js.map +1 -0
- package/dist/esm/base/controllers/factory/controller.d.ts.map +1 -1
- package/dist/esm/base/controllers/factory/controller.js +8 -0
- package/dist/esm/base/controllers/factory/controller.js.map +1 -1
- package/dist/esm/base/metadata/model-settings.d.ts +21 -0
- package/dist/esm/base/metadata/model-settings.d.ts.map +1 -0
- package/dist/esm/base/metadata/model-settings.js +73 -0
- package/dist/esm/base/metadata/model-settings.js.map +1 -0
- package/dist/esm/base/metadata/persistents.d.ts +1 -1
- package/dist/esm/base/metadata/persistents.d.ts.map +1 -1
- package/dist/esm/base/metadata/persistents.js +20 -8
- package/dist/esm/base/metadata/persistents.js.map +1 -1
- package/dist/esm/base/repositories/common/constants.d.ts +18 -1
- package/dist/esm/base/repositories/common/constants.d.ts.map +1 -1
- package/dist/esm/base/repositories/common/constants.js +20 -1
- package/dist/esm/base/repositories/common/constants.js.map +1 -1
- package/dist/esm/base/repositories/core/abstract.d.ts +1 -1
- package/dist/esm/base/repositories/core/abstract.d.ts.map +1 -1
- package/dist/esm/base/repositories/core/abstract.js +4 -4
- package/dist/esm/base/repositories/core/abstract.js.map +1 -1
- package/dist/esm/helpers/inversion/common/types/model.d.ts +94 -22
- package/dist/esm/helpers/inversion/common/types/model.d.ts.map +1 -1
- package/dist/esm/helpers/inversion/common/types/model.js.map +1 -1
- package/package.json +5 -5
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { AbstractEntity } from '../../../../base/models/index.js';
|
|
2
|
-
import type { ScopeFilters, TFilter, TScopeFilterMissingBehavior, TWhere } from '../../../../base/repositories/index.js';
|
|
2
|
+
import type { ScopeFilters, TFilter, TScopeFilterMissingBehavior, TScopeWriteGuard, TWhere } from '../../../../base/repositories/index.js';
|
|
3
3
|
import type { TClass, TNullable, TValueOrResolver } from '@venizia/ignis-helpers/common';
|
|
4
4
|
import type { IArtifactRegistrationOptions } from './artifact.js';
|
|
5
5
|
export interface IModelAuthorizeSettings {
|
|
@@ -8,12 +8,38 @@ export interface IModelAuthorizeSettings {
|
|
|
8
8
|
/** Extensible - consumers can add any extra authorization metadata. */
|
|
9
9
|
[extra: string | symbol]: any;
|
|
10
10
|
}
|
|
11
|
+
/** What a restricted caller may write to the scope columns (`@model` settings.access.write). */
|
|
12
|
+
export interface IModelAccessWriteSettings {
|
|
13
|
+
/**
|
|
14
|
+
* What a create, createAll or an update payload that names a scope column does when its value
|
|
15
|
+
* disagrees with the resolved scope. `reject` (default) refuses the write and writes nothing - for
|
|
16
|
+
* `createAll` not even the valid rows. `assign` also fills a scope column that is ABSENT from a
|
|
17
|
+
* created row, when the scope is a single equality; a value that is present and disagrees is
|
|
18
|
+
* still refused.
|
|
19
|
+
*
|
|
20
|
+
* The scope's columns and allowed values are read from the resolved `where` (equality, `eq`, `inq`
|
|
21
|
+
* and arrays, `and`, and an `or` over one column). Any other shape cannot be checked, and the write
|
|
22
|
+
* is refused with its own message - never skipped. `ScopeFilters.UNRESTRICTED` bypasses the guard
|
|
23
|
+
* too, which is the deliberate way to write across scopes (system scope, an admin role).
|
|
24
|
+
*
|
|
25
|
+
* Not checked: an update that does not name the scope column (the row was already selected through
|
|
26
|
+
* the scoped `where`), and raw statements that bypass the repository.
|
|
27
|
+
*/
|
|
28
|
+
mode?: TScopeWriteGuard;
|
|
29
|
+
/**
|
|
30
|
+
* `true` lets a restricted caller write `null` to a scope column, or leave it out on create: the
|
|
31
|
+
* row has no owner and is shared. Default `false`, so `null` is refused like any other value
|
|
32
|
+
* outside the scope, even when the resolved scope has a `null` branch (that branch lets the caller
|
|
33
|
+
* READ shared rows, a separate permission). Reads are scoped as before.
|
|
34
|
+
*/
|
|
35
|
+
sharedRows?: boolean;
|
|
36
|
+
}
|
|
11
37
|
/**
|
|
12
|
-
* Row
|
|
13
|
-
*
|
|
14
|
-
*
|
|
38
|
+
* Row access for `@model` settings.access - resolved per query, so it can depend on the current
|
|
39
|
+
* request (tenant, org, membership). Framework-internal escape hatches aside, nothing short of
|
|
40
|
+
* removing this setting from the model turns scoping off.
|
|
15
41
|
*/
|
|
16
|
-
export interface
|
|
42
|
+
export interface IModelAccessSettings {
|
|
17
43
|
/**
|
|
18
44
|
* Returns the scope `where`; `ScopeFilters.UNRESTRICTED` to apply no scope for THIS call (an
|
|
19
45
|
* internal operator, a caller the application has decided sees everything); or null/undefined
|
|
@@ -27,41 +53,87 @@ export interface IScopeFilterSettings {
|
|
|
27
53
|
* per MODEL - it cannot express a per-USER bypass; use `ScopeFilters.UNRESTRICTED` for that.
|
|
28
54
|
*/
|
|
29
55
|
onMissing?: TScopeFilterMissingBehavior;
|
|
56
|
+
/**
|
|
57
|
+
* The property names the write guard checks. Optional: with none declared the guard checks every
|
|
58
|
+
* column the resolved scope constrains. When declared, each name must exist on the model (checked
|
|
59
|
+
* at boot), and a resolved scope that constrains any other column is refused as unverifiable.
|
|
60
|
+
*/
|
|
61
|
+
columns?: string[];
|
|
62
|
+
/** What a restricted caller may write to the scope columns. See {@link IModelAccessWriteSettings}. */
|
|
63
|
+
write?: IModelAccessWriteSettings;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* The old, flat shape of {@link IModelAccessSettings}.
|
|
67
|
+
*
|
|
68
|
+
* @deprecated Use `settings.access` (`writeGuard` is `access.write.mode`, `sharedRows` is
|
|
69
|
+
* `access.write.sharedRows`). Removed in 0.4.3.
|
|
70
|
+
*/
|
|
71
|
+
export interface IScopeFilterSettings {
|
|
72
|
+
resolve: () => TNullable<TWhere> | typeof ScopeFilters.UNRESTRICTED;
|
|
73
|
+
onMissing?: TScopeFilterMissingBehavior;
|
|
74
|
+
writeGuard?: TScopeWriteGuard;
|
|
75
|
+
sharedRows?: boolean;
|
|
76
|
+
columns?: string[];
|
|
77
|
+
}
|
|
78
|
+
/** What a query runs with when it names nothing (`@model` settings.query). */
|
|
79
|
+
export interface IModelQuerySettings {
|
|
80
|
+
/** Default filter auto-applied to all repository operations. Bypassable via shouldSkipDefaultFilter. */
|
|
81
|
+
filter?: TFilter;
|
|
82
|
+
limit?: {
|
|
83
|
+
/** Default row limit when a query omits `limit`. Must be a positive integer. Falls back to DEFAULT_LIMIT (10). */
|
|
84
|
+
default?: number;
|
|
85
|
+
/**
|
|
86
|
+
* Largest `limit` a CALLER may ask for. Must be a positive integer. Falls back to
|
|
87
|
+
* DEFAULT_MAX_LIMIT (1000).
|
|
88
|
+
*
|
|
89
|
+
* Policy, not capacity - the engine's own ceiling sits far above it. The number is chosen so
|
|
90
|
+
* that reaching it means the caller is doing something unusual, and raising it is how a model
|
|
91
|
+
* says so deliberately.
|
|
92
|
+
*/
|
|
93
|
+
max?: number;
|
|
94
|
+
};
|
|
30
95
|
}
|
|
31
96
|
export interface IModelSettings {
|
|
32
97
|
/** Properties excluded from all query results at SQL level. */
|
|
33
98
|
hiddenProperties?: string[];
|
|
34
|
-
/** Default filter
|
|
35
|
-
|
|
99
|
+
/** Default filter and limits of a query: `filter`, `limit.default`, `limit.max`. */
|
|
100
|
+
query?: IModelQuerySettings;
|
|
36
101
|
/**
|
|
37
|
-
* Row
|
|
38
|
-
* NOT removable by `shouldSkipDefaultFilter
|
|
39
|
-
*
|
|
40
|
-
*
|
|
102
|
+
* Row access: the scope ANDed into every read and write whose scope is expressible as a filter
|
|
103
|
+
* clause, NOT removable by `shouldSkipDefaultFilter`, and the guard that holds writes to it.
|
|
104
|
+
* Ownership resolved per row or through a polymorphic reference is NOT expressible here - that
|
|
105
|
+
* check is still the application's to perform.
|
|
41
106
|
*
|
|
42
107
|
* Relational repositories only - a search-backed model (Typesense, Meilisearch) never reads
|
|
43
108
|
* this setting, so mirroring a scoped entity into a search index needs its own query-time scope.
|
|
44
109
|
*/
|
|
110
|
+
access?: IModelAccessSettings;
|
|
111
|
+
/** Authorization settings for this model (principal name, etc.). */
|
|
112
|
+
authorize?: IModelAuthorizeSettings;
|
|
113
|
+
/** @deprecated Use `query.filter`. Removed in 0.4.3. */
|
|
114
|
+
defaultFilter?: TFilter;
|
|
115
|
+
/** @deprecated Use `access`. Removed in 0.4.3. */
|
|
45
116
|
scopeFilter?: IScopeFilterSettings;
|
|
46
|
-
/**
|
|
117
|
+
/** @deprecated Use `query.limit.default`. Removed in 0.4.3. */
|
|
47
118
|
defaultLimit?: number;
|
|
48
|
-
/**
|
|
49
|
-
* Largest `limit` a CALLER may ask for. Must be a positive integer. Falls back to
|
|
50
|
-
* DEFAULT_MAX_LIMIT (1000).
|
|
51
|
-
*
|
|
52
|
-
* Policy, not capacity - the engine's own ceiling sits far above it. The number is chosen so
|
|
53
|
-
* that reaching it means the caller is doing something unusual, and raising it is how a model
|
|
54
|
-
* says so deliberately.
|
|
55
|
-
*/
|
|
119
|
+
/** @deprecated Use `query.limit.max`. Removed in 0.4.3. */
|
|
56
120
|
maxLimit?: number;
|
|
57
|
-
|
|
58
|
-
|
|
121
|
+
}
|
|
122
|
+
/** One deprecated settings key a model still uses, and the key that replaces it. */
|
|
123
|
+
export interface IDeprecatedModelSetting {
|
|
124
|
+
/** The old key, written as the model wrote it: `defaultFilter`, `scopeFilter.writeGuard`. */
|
|
125
|
+
key: string;
|
|
126
|
+
/** The key that replaces it: `query.filter`, `access.write.mode`. */
|
|
127
|
+
use: string;
|
|
59
128
|
}
|
|
60
129
|
export interface IModelMetadata extends IArtifactRegistrationOptions {
|
|
61
130
|
type: 'entity' | 'view';
|
|
62
131
|
tableName?: string;
|
|
63
132
|
skipMigrate?: boolean;
|
|
133
|
+
/** As the `@model` decorator stores it: normalised to the new keys; the deprecated keys are gone. */
|
|
64
134
|
settings?: IModelSettings;
|
|
135
|
+
/** Set by the decorator, read by the boot warning; not for application code. */
|
|
136
|
+
deprecatedSettings?: IDeprecatedModelSetting[];
|
|
65
137
|
}
|
|
66
138
|
export interface IEntityStatics {
|
|
67
139
|
schema?: unknown;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../../../../src/helpers/inversion/common/types/model.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,KAAK,EACV,YAAY,EACZ,OAAO,EACP,2BAA2B,EAC3B,MAAM,EACP,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,+BAA+B,CAAC;AACzF,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,YAAY,CAAC;AAE/D,MAAM,WAAW,uBAAuB;IACtC,0EAA0E;IAC1E,SAAS,EAAE,MAAM,CAAC;IAClB,uEAAuE;IACvE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,GAAG,CAAC;CAC/B;AAED;;;;GAIG;AACH,MAAM,WAAW,oBAAoB;IACnC;;;;OAIG;IACH,OAAO,EAAE,MAAM,SAAS,CAAC,MAAM,CAAC,GAAG,OAAO,YAAY,CAAC,YAAY,CAAC;IAEpE;;;;;OAKG;IACH,SAAS,CAAC,EAAE,2BAA2B,CAAC;
|
|
1
|
+
{"version":3,"file":"model.d.ts","sourceRoot":"","sources":["../../../../../../src/helpers/inversion/common/types/model.ts"],"names":[],"mappings":"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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../../../../../src/helpers/inversion/common/types/model.ts"],"names":[],"mappings":"","sourcesContent":["import type { AbstractEntity } from '@/base/models';\nimport type {\n ScopeFilters,\n TFilter,\n TScopeFilterMissingBehavior,\n TWhere,\n} from '@/base/repositories';\nimport type { TClass, TNullable, TValueOrResolver } from '@venizia/ignis-helpers/common';\nimport type { IArtifactRegistrationOptions } from './artifact';\n\nexport interface IModelAuthorizeSettings {\n /** The authorization principal name (resource/subject) for this model. */\n principal: string;\n /** Extensible - consumers can add any extra authorization metadata. */\n [extra: string | symbol]: any;\n}\n\n/**\n *
|
|
1
|
+
{"version":3,"file":"model.js","sourceRoot":"","sources":["../../../../../../src/helpers/inversion/common/types/model.ts"],"names":[],"mappings":"","sourcesContent":["import type { AbstractEntity } from '@/base/models';\nimport type {\n ScopeFilters,\n TFilter,\n TScopeFilterMissingBehavior,\n TScopeWriteGuard,\n TWhere,\n} from '@/base/repositories';\nimport type { TClass, TNullable, TValueOrResolver } from '@venizia/ignis-helpers/common';\nimport type { IArtifactRegistrationOptions } from './artifact';\n\nexport interface IModelAuthorizeSettings {\n /** The authorization principal name (resource/subject) for this model. */\n principal: string;\n /** Extensible - consumers can add any extra authorization metadata. */\n [extra: string | symbol]: any;\n}\n\n/** What a restricted caller may write to the scope columns (`@model` settings.access.write). */\nexport interface IModelAccessWriteSettings {\n /**\n * What a create, createAll or an update payload that names a scope column does when its value\n * disagrees with the resolved scope. `reject` (default) refuses the write and writes nothing - for\n * `createAll` not even the valid rows. `assign` also fills a scope column that is ABSENT from a\n * created row, when the scope is a single equality; a value that is present and disagrees is\n * still refused.\n *\n * The scope's columns and allowed values are read from the resolved `where` (equality, `eq`, `inq`\n * and arrays, `and`, and an `or` over one column). Any other shape cannot be checked, and the write\n * is refused with its own message - never skipped. `ScopeFilters.UNRESTRICTED` bypasses the guard\n * too, which is the deliberate way to write across scopes (system scope, an admin role).\n *\n * Not checked: an update that does not name the scope column (the row was already selected through\n * the scoped `where`), and raw statements that bypass the repository.\n */\n mode?: TScopeWriteGuard;\n\n /**\n * `true` lets a restricted caller write `null` to a scope column, or leave it out on create: the\n * row has no owner and is shared. Default `false`, so `null` is refused like any other value\n * outside the scope, even when the resolved scope has a `null` branch (that branch lets the caller\n * READ shared rows, a separate permission). Reads are scoped as before.\n */\n sharedRows?: boolean;\n}\n\n/**\n * Row access for `@model` settings.access - resolved per query, so it can depend on the current\n * request (tenant, org, membership). Framework-internal escape hatches aside, nothing short of\n * removing this setting from the model turns scoping off.\n */\nexport interface IModelAccessSettings {\n /**\n * Returns the scope `where`; `ScopeFilters.UNRESTRICTED` to apply no scope for THIS call (an\n * internal operator, a caller the application has decided sees everything); or null/undefined\n * when this caller's scope cannot be determined at all.\n */\n resolve: () => TNullable<TWhere> | typeof ScopeFilters.UNRESTRICTED;\n\n /**\n * What `applyScopeFilter` does when `resolve()` returns null/undefined - no request context, no\n * tenant, a background job. Defaults to `deny`: an unresolved scope matches zero rows, never\n * every row. `allow` is an explicit, reviewed opt-out for migrations and background jobs, declared\n * per MODEL - it cannot express a per-USER bypass; use `ScopeFilters.UNRESTRICTED` for that.\n */\n onMissing?: TScopeFilterMissingBehavior;\n\n /**\n * The property names the write guard checks. Optional: with none declared the guard checks every\n * column the resolved scope constrains. When declared, each name must exist on the model (checked\n * at boot), and a resolved scope that constrains any other column is refused as unverifiable.\n */\n columns?: string[];\n\n /** What a restricted caller may write to the scope columns. See {@link IModelAccessWriteSettings}. */\n write?: IModelAccessWriteSettings;\n}\n\n/**\n * The old, flat shape of {@link IModelAccessSettings}.\n *\n * @deprecated Use `settings.access` (`writeGuard` is `access.write.mode`, `sharedRows` is\n * `access.write.sharedRows`). Removed in 0.4.3.\n */\nexport interface IScopeFilterSettings {\n resolve: () => TNullable<TWhere> | typeof ScopeFilters.UNRESTRICTED;\n onMissing?: TScopeFilterMissingBehavior;\n writeGuard?: TScopeWriteGuard;\n sharedRows?: boolean;\n columns?: string[];\n}\n\n/** What a query runs with when it names nothing (`@model` settings.query). */\nexport interface IModelQuerySettings {\n /** Default filter auto-applied to all repository operations. Bypassable via shouldSkipDefaultFilter. */\n filter?: TFilter;\n\n limit?: {\n /** Default row limit when a query omits `limit`. Must be a positive integer. Falls back to DEFAULT_LIMIT (10). */\n default?: number;\n\n /**\n * Largest `limit` a CALLER may ask for. Must be a positive integer. Falls back to\n * DEFAULT_MAX_LIMIT (1000).\n *\n * Policy, not capacity - the engine's own ceiling sits far above it. The number is chosen so\n * that reaching it means the caller is doing something unusual, and raising it is how a model\n * says so deliberately.\n */\n max?: number;\n };\n}\n\nexport interface IModelSettings {\n /** Properties excluded from all query results at SQL level. */\n hiddenProperties?: string[];\n\n /** Default filter and limits of a query: `filter`, `limit.default`, `limit.max`. */\n query?: IModelQuerySettings;\n\n /**\n * Row access: the scope ANDed into every read and write whose scope is expressible as a filter\n * clause, NOT removable by `shouldSkipDefaultFilter`, and the guard that holds writes to it.\n * Ownership resolved per row or through a polymorphic reference is NOT expressible here - that\n * check is still the application's to perform.\n *\n * Relational repositories only - a search-backed model (Typesense, Meilisearch) never reads\n * this setting, so mirroring a scoped entity into a search index needs its own query-time scope.\n */\n access?: IModelAccessSettings;\n\n /** Authorization settings for this model (principal name, etc.). */\n authorize?: IModelAuthorizeSettings;\n\n /** @deprecated Use `query.filter`. Removed in 0.4.3. */\n defaultFilter?: TFilter;\n\n /** @deprecated Use `access`. Removed in 0.4.3. */\n scopeFilter?: IScopeFilterSettings;\n\n /** @deprecated Use `query.limit.default`. Removed in 0.4.3. */\n defaultLimit?: number;\n\n /** @deprecated Use `query.limit.max`. Removed in 0.4.3. */\n maxLimit?: number;\n}\n\n/** One deprecated settings key a model still uses, and the key that replaces it. */\nexport interface IDeprecatedModelSetting {\n /** The old key, written as the model wrote it: `defaultFilter`, `scopeFilter.writeGuard`. */\n key: string;\n /** The key that replaces it: `query.filter`, `access.write.mode`. */\n use: string;\n}\n\nexport interface IModelMetadata extends IArtifactRegistrationOptions {\n type: 'entity' | 'view';\n tableName?: string;\n skipMigrate?: boolean;\n\n /** As the `@model` decorator stores it: normalised to the new keys; the deprecated keys are gone. */\n settings?: IModelSettings;\n\n /** Set by the decorator, read by the boot warning; not for application code. */\n deprecatedSettings?: IDeprecatedModelSetting[];\n}\n\nexport interface IEntityStatics {\n schema?: unknown;\n relations?: TValueOrResolver<Array<unknown>>;\n}\n\nexport type TModelClass<Model extends AbstractEntity = AbstractEntity> = TClass<Model> &\n IEntityStatics;\n\n/** Decorator target for model classes (supports both strongly typed and ClassDecorator patterns). */\nexport type TDecoratorModelTarget<Model extends AbstractEntity = AbstractEntity> =\n | TModelClass<Model>\n | (Function & IEntityStatics);\n\nexport interface IModelRegistryEntry<Model extends AbstractEntity = AbstractEntity> {\n target: TValueOrResolver<TClass<Model>>;\n metadata: IModelMetadata;\n schema: unknown;\n\n /** Lazy resolver to avoid circular deps. Resolved when DataSource builds schema. */\n relationsResolver?: TValueOrResolver<Array<unknown>>;\n\n /** Cache populated on first buildSchema() call. */\n _builtRelations?: unknown;\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@venizia/ignis-kernel",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "Browser-pure kernel of the IGNIS framework: dependency injection, lifecycle, REST controllers, repository and datasource abstractions, and the authentication and authorization seams. No node builtin and no server-only peer, so the same kernel serves a Bun server and a browser Worker.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"authentication",
|
|
@@ -79,14 +79,14 @@
|
|
|
79
79
|
"prepublishOnly": "make rebuild"
|
|
80
80
|
},
|
|
81
81
|
"dependencies": {
|
|
82
|
-
"@venizia/ignis-filter": "0.4.
|
|
83
|
-
"@venizia/ignis-helpers": "0.4.
|
|
84
|
-
"@venizia/ignis-inversion": "0.4.
|
|
82
|
+
"@venizia/ignis-filter": "0.4.2",
|
|
83
|
+
"@venizia/ignis-helpers": "0.4.2",
|
|
84
|
+
"@venizia/ignis-inversion": "0.4.2",
|
|
85
85
|
"reflect-metadata": "^0.2.2"
|
|
86
86
|
},
|
|
87
87
|
"devDependencies": {
|
|
88
88
|
"@types/bun": "^1.4.3",
|
|
89
|
-
"@venizia/dev-configs": "0.4.
|
|
89
|
+
"@venizia/dev-configs": "0.4.2",
|
|
90
90
|
"casbin": "^5.51.1",
|
|
91
91
|
"eslint": "^10.13.0",
|
|
92
92
|
"oxlint": "1.89.0",
|