@radio-garden/ditojs-server 2.91.0-0.1b51d4b4e → 2.91.0-2.566eca6ca
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/package.json +6 -6
- package/types/index.d.ts +68 -30
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@radio-garden/ditojs-server",
|
|
3
|
-
"version": "2.91.0-
|
|
3
|
+
"version": "2.91.0-2.566eca6ca",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Dito.js Server – Dito.js is a declarative and modern web framework, based on Objection.js, Koa.js and Vue.js",
|
|
6
6
|
"repository": "https://github.com/ditojs/dito/tree/main/packages/server",
|
|
@@ -61,10 +61,10 @@
|
|
|
61
61
|
"repl": "^0.1.3",
|
|
62
62
|
"type-fest": "^5.4.4",
|
|
63
63
|
"uuid": "^13.0.0",
|
|
64
|
-
"@ditojs/
|
|
65
|
-
"@ditojs/
|
|
66
|
-
"@ditojs/
|
|
67
|
-
"@ditojs/router": "npm:@radio-garden/ditojs-router@^2.91.0-
|
|
64
|
+
"@ditojs/admin": "npm:@radio-garden/ditojs-admin@^2.91.0-2.566eca6ca",
|
|
65
|
+
"@ditojs/build": "npm:@radio-garden/ditojs-build@^2.91.0-2.566eca6ca",
|
|
66
|
+
"@ditojs/utils": "npm:@radio-garden/ditojs-utils@^2.91.0-2.566eca6ca",
|
|
67
|
+
"@ditojs/router": "npm:@radio-garden/ditojs-router@^2.91.0-2.566eca6ca"
|
|
68
68
|
},
|
|
69
69
|
"peerDependencies": {
|
|
70
70
|
"@aws-sdk/client-s3": "^3.0.0",
|
|
@@ -87,7 +87,7 @@
|
|
|
87
87
|
"objection": "^3.1.5",
|
|
88
88
|
"typescript": "^5.9.3"
|
|
89
89
|
},
|
|
90
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "566eca6ca",
|
|
91
91
|
"gitBranch": "feature/asset-signatures",
|
|
92
92
|
"scripts": {
|
|
93
93
|
"types": "tsc --noEmit --esModuleInterop ./types/index.d.ts"
|
package/types/index.d.ts
CHANGED
|
@@ -694,6 +694,7 @@ export interface Application
|
|
|
694
694
|
|
|
695
695
|
export type SchemaType = LiteralUnion<
|
|
696
696
|
| 'string'
|
|
697
|
+
| 'text'
|
|
697
698
|
| 'number'
|
|
698
699
|
| 'integer'
|
|
699
700
|
| 'boolean'
|
|
@@ -936,7 +937,7 @@ export type ModelProperty<T = any> = Schema<T> & {
|
|
|
936
937
|
*/
|
|
937
938
|
computed?: boolean
|
|
938
939
|
/**
|
|
939
|
-
* Marks the property
|
|
940
|
+
* Marks the property as hidden, so that it does not show up in data
|
|
940
941
|
* converted to JSON.
|
|
941
942
|
*
|
|
942
943
|
* This can be used for sensitive data.
|
|
@@ -1722,11 +1723,31 @@ export type ModelProperties<$Model extends Model = Model> = [
|
|
|
1722
1723
|
}
|
|
1723
1724
|
|
|
1724
1725
|
/**
|
|
1725
|
-
* A controller action definition.
|
|
1726
|
-
*
|
|
1727
|
-
*
|
|
1728
|
-
*
|
|
1729
|
-
*
|
|
1726
|
+
* A controller action definition. The HTTP method and route
|
|
1727
|
+
* path are derived from the action name key (e.g.
|
|
1728
|
+
* `'post import'` → `POST /import`, `'get'` → `GET /`).
|
|
1729
|
+
*
|
|
1730
|
+
* @example
|
|
1731
|
+
* // Bare handler function:
|
|
1732
|
+
* collection = {
|
|
1733
|
+
* allow: ['get'],
|
|
1734
|
+
* 'post import'(ctx) {
|
|
1735
|
+
* return this.importData(ctx.request.body)
|
|
1736
|
+
* }
|
|
1737
|
+
* }
|
|
1738
|
+
*
|
|
1739
|
+
* @example
|
|
1740
|
+
* // Options object with handler, authorize, etc.:
|
|
1741
|
+
* collection = {
|
|
1742
|
+
* allow: ['get'],
|
|
1743
|
+
* 'post import': {
|
|
1744
|
+
* handler(ctx) {
|
|
1745
|
+
* return this.importData(ctx.request.body)
|
|
1746
|
+
* },
|
|
1747
|
+
* authorize: 'admin',
|
|
1748
|
+
* transacted: true
|
|
1749
|
+
* }
|
|
1750
|
+
* }
|
|
1730
1751
|
*/
|
|
1731
1752
|
export type ControllerAction<$Controller extends Controller = Controller> =
|
|
1732
1753
|
| ControllerActionOptions<$Controller>
|
|
@@ -1773,9 +1794,12 @@ export class Controller {
|
|
|
1773
1794
|
logRoutes: boolean
|
|
1774
1795
|
|
|
1775
1796
|
/**
|
|
1776
|
-
*
|
|
1777
|
-
*
|
|
1778
|
-
*
|
|
1797
|
+
* Which inherited actions to enable, e.g.
|
|
1798
|
+
* `['get', 'post', 'get stats']`. Actions defined
|
|
1799
|
+
* directly on the same object are always enabled.
|
|
1800
|
+
* When set, it replaces any parent controller's
|
|
1801
|
+
* `allow` list. When omitted, the parent's `allow`
|
|
1802
|
+
* list is inherited.
|
|
1779
1803
|
*/
|
|
1780
1804
|
allow?: OrReadOnly<ControllerActionName[]>
|
|
1781
1805
|
|
|
@@ -1938,14 +1962,14 @@ type ModelDataProperties<$Model extends Model = Model> = {
|
|
|
1938
1962
|
* - Any other `string`: Checked as a role via
|
|
1939
1963
|
* `UserModel.$hasRole()`.
|
|
1940
1964
|
* - `function`: Dynamically resolves to any of the above.
|
|
1941
|
-
* - `Record<HTTPMethod, string | string[]
|
|
1965
|
+
* - `Partial<Record<HTTPMethod, string | string[]>>`: Per-method
|
|
1942
1966
|
* role authorization.
|
|
1943
1967
|
*/
|
|
1944
1968
|
export type Authorize =
|
|
1945
1969
|
| boolean
|
|
1946
1970
|
| OrArrayOf<LiteralUnion<'$self' | '$owner'>>
|
|
1947
1971
|
| ((ctx: KoaContext) => OrPromiseOf<Authorize>)
|
|
1948
|
-
| Record<HTTPMethod, string | string[]
|
|
1972
|
+
| Partial<Record<HTTPMethod, string | string[]>>
|
|
1949
1973
|
|
|
1950
1974
|
export type BaseControllerActionOptions = {
|
|
1951
1975
|
/**
|
|
@@ -2051,8 +2075,8 @@ export type ModelControllerAction<
|
|
|
2051
2075
|
|
|
2052
2076
|
/**
|
|
2053
2077
|
* Map of action names to action definitions for a model
|
|
2054
|
-
* controller's collection-level actions (e.g. `
|
|
2055
|
-
* `
|
|
2078
|
+
* controller's collection-level actions (e.g. `'get'`,
|
|
2079
|
+
* `'post'`, `'post login'`).
|
|
2056
2080
|
*/
|
|
2057
2081
|
export type ModelControllerActions<
|
|
2058
2082
|
$ModelController extends ModelController = ModelController
|
|
@@ -2089,16 +2113,19 @@ export type ModelControllerMemberActions<
|
|
|
2089
2113
|
}
|
|
2090
2114
|
|
|
2091
2115
|
/**
|
|
2092
|
-
* Action name
|
|
2093
|
-
*
|
|
2094
|
-
* `'
|
|
2116
|
+
* Action name: an HTTP method, optionally followed by a
|
|
2117
|
+
* space and a name (e.g. `'get'`, `'post login'`,
|
|
2118
|
+
* `'get session'`). The method and name are split on the
|
|
2119
|
+
* first space to determine the HTTP method and route path.
|
|
2120
|
+
* Bare names without an HTTP method prefix (e.g. `'login'`)
|
|
2121
|
+
* are not supported and will throw at runtime.
|
|
2095
2122
|
*/
|
|
2096
2123
|
export type ControllerActionName = `${HTTPMethod}${string}`
|
|
2097
2124
|
|
|
2098
2125
|
/**
|
|
2099
2126
|
* Map of action names to action definitions for a
|
|
2100
|
-
* controller.
|
|
2101
|
-
*
|
|
2127
|
+
* controller. Use `allow` to whitelist specific actions
|
|
2128
|
+
* and `authorize` for group-level authorization.
|
|
2102
2129
|
*/
|
|
2103
2130
|
export type ControllerActions<$Controller extends Controller = Controller> = {
|
|
2104
2131
|
[name: ControllerActionName]: ControllerAction<$Controller>
|
|
@@ -3416,11 +3443,25 @@ export function addRelationSchemas(
|
|
|
3416
3443
|
properties: Record<string, ModelProperty>
|
|
3417
3444
|
): void
|
|
3418
3445
|
|
|
3419
|
-
export type Keyword =
|
|
3446
|
+
export type Keyword = (
|
|
3420
3447
|
| SetOptional<Ajv.MacroKeywordDefinition, 'keyword'>
|
|
3421
3448
|
| SetOptional<Ajv.CodeKeywordDefinition, 'keyword'>
|
|
3422
3449
|
| SetOptional<Ajv.FuncKeywordDefinition, 'keyword'>
|
|
3423
|
-
|
|
3450
|
+
) & {
|
|
3451
|
+
/** Custom error message shown when validation fails. */
|
|
3452
|
+
message?: string
|
|
3453
|
+
/** When true, validation errors for this keyword are suppressed. */
|
|
3454
|
+
silent?: boolean
|
|
3455
|
+
}
|
|
3456
|
+
export type Format = (
|
|
3457
|
+
| Ajv.ValidateFunction
|
|
3458
|
+
| Ajv.FormatDefinition<string>
|
|
3459
|
+
) & {
|
|
3460
|
+
/** Custom error message shown when validation fails. */
|
|
3461
|
+
message?: string
|
|
3462
|
+
/** When true, validation errors for this format are suppressed. */
|
|
3463
|
+
silent?: boolean
|
|
3464
|
+
}
|
|
3424
3465
|
|
|
3425
3466
|
/** Built-in AJV keyword definitions. */
|
|
3426
3467
|
export const keywords: {
|
|
@@ -3459,24 +3500,21 @@ export type Id = string | number
|
|
|
3459
3500
|
* ```ts
|
|
3460
3501
|
* declare module '@ditojs/server' {
|
|
3461
3502
|
* interface KoaContextState {
|
|
3462
|
-
*
|
|
3503
|
+
* foo: string
|
|
3463
3504
|
* }
|
|
3464
3505
|
* }
|
|
3465
3506
|
* ```
|
|
3466
3507
|
*/
|
|
3467
|
-
export interface KoaContextState {
|
|
3468
|
-
|
|
3469
|
-
|
|
3470
|
-
|
|
3471
|
-
: KoaContextState
|
|
3508
|
+
export interface KoaContextState {
|
|
3509
|
+
user: InstanceType<typeof UserModel>
|
|
3510
|
+
[key: string]: unknown
|
|
3511
|
+
}
|
|
3472
3512
|
|
|
3473
|
-
export type KoaContext<$State =
|
|
3513
|
+
export type KoaContext<$State = KoaContextState> = Koa.ParameterizedContext<
|
|
3474
3514
|
$State,
|
|
3475
3515
|
{
|
|
3476
3516
|
transaction: objection.Transaction
|
|
3477
|
-
session: koaSession.ContextSession
|
|
3478
|
-
state: { user: any }
|
|
3479
|
-
}
|
|
3517
|
+
session: koaSession.ContextSession
|
|
3480
3518
|
logger: PinoLogger
|
|
3481
3519
|
}
|
|
3482
3520
|
>
|