@aeriajs/types 0.0.30 → 0.0.32
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/accessControl.d.ts +1 -4
- package/dist/api.d.ts +6 -5
- package/dist/condition.d.ts +1 -1
- package/dist/context.d.ts +7 -5
- package/dist/contract.d.ts +1 -1
- package/dist/description.d.ts +15 -14
- package/dist/security.d.ts +4 -1
- package/package.json +1 -1
package/dist/accessControl.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Collection } from '.';
|
|
2
2
|
export declare enum ACErrors {
|
|
3
3
|
AssetNotFound = "ASSET_NOT_FOUND",
|
|
4
4
|
AuthenticationError = "AUTHENTICATION_ERROR",
|
|
@@ -28,6 +28,3 @@ export type NonCircularAccessControl<TCollection extends Collection = any, TAcce
|
|
|
28
28
|
availableRoles?: keyof TAccessControl['roles'];
|
|
29
29
|
parent?: TAccessControl['roles'];
|
|
30
30
|
};
|
|
31
|
-
export type ExpectToken<TToken extends Token, TRole extends UserRole | UserRole[]> = (TRole extends any[] ? TRole[number] : TRole) extends infer NormalizedRole ? TToken extends AuthenticatedToken ? NormalizedRole extends TToken['roles'][number] ? TToken : Omit<TToken, 'roles'> & {
|
|
32
|
-
roles: readonly NormalizedRole[];
|
|
33
|
-
} : TToken : never;
|
package/dist/api.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ObjectId } from 'mongodb';
|
|
2
2
|
import type { Context, Contract, Description, CollectionSecurityPolicy, AccessControl, PackReferences } from '.';
|
|
3
|
+
export type AcceptedRole = UserRole | UserRole[] | null | unknown;
|
|
3
4
|
export type Collection<TCollection extends Collection = any> = {
|
|
4
5
|
description: Description;
|
|
5
6
|
item?: any;
|
|
@@ -9,12 +10,12 @@ export type Collection<TCollection extends Collection = any> = {
|
|
|
9
10
|
functionContracts?: Record<string, Contract>;
|
|
10
11
|
};
|
|
11
12
|
export type AssetType = keyof Collection;
|
|
12
|
-
export type FunctionPath =
|
|
13
|
-
export type UserRole = Collections['user']['item']['roles'][number];
|
|
14
|
-
export type AuthenticatedToken<TAcceptedRole =
|
|
13
|
+
export type FunctionPath = `/${string}/${string}`;
|
|
14
|
+
export type UserRole = Collections['user']['item']['roles'][number] | 'root' | 'guest';
|
|
15
|
+
export type AuthenticatedToken<TAcceptedRole extends AcceptedRole = null> = {
|
|
15
16
|
authenticated: true;
|
|
16
17
|
sub: ObjectId;
|
|
17
|
-
roles: readonly TAcceptedRole[];
|
|
18
|
+
roles: readonly (TAcceptedRole extends null ? string : TAcceptedRole)[];
|
|
18
19
|
allowed_functions?: readonly FunctionPath[];
|
|
19
20
|
userinfo: PackReferences<Collections['user']['item']>;
|
|
20
21
|
};
|
|
@@ -22,4 +23,4 @@ export type UnauthenticatedToken = {
|
|
|
22
23
|
authenticated: false;
|
|
23
24
|
sub: null;
|
|
24
25
|
};
|
|
25
|
-
export type Token<TAcceptedRole =
|
|
26
|
+
export type Token<TAcceptedRole extends AcceptedRole = null> = (TAcceptedRole extends any[] ? TAcceptedRole[number] : TAcceptedRole) extends infer NormalizedRole ? NormalizedRole extends null | 'guest' ? AuthenticatedToken | UnauthenticatedToken : AuthenticatedToken<NormalizedRole> : never;
|
package/dist/condition.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { JsonSchema, PropertiesWithId } from './property';
|
|
1
|
+
import type { JsonSchema, PropertiesWithId } from './property.js';
|
|
2
2
|
export type FinalOperator = 'equal' | 'in' | 'gt' | 'lt' | 'gte' | 'lte';
|
|
3
3
|
export type FinalCondition<TSchema extends JsonSchema = any> = {
|
|
4
4
|
operator: FinalOperator;
|
package/dist/context.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Collection as MongoCollection } from 'mongodb';
|
|
2
|
-
import type { GenericRequest, GenericResponse } from './http';
|
|
3
|
-
import type { Either, Description, PackReferences, SchemaWithId, FunctionPath, Token, ApiConfig, CollectionDocument, CollectionFunctions, RateLimitingParams, RateLimitingErrors } from '.';
|
|
2
|
+
import type { GenericRequest, GenericResponse } from './http.js';
|
|
3
|
+
import type { Either, Description, PackReferences, SchemaWithId, FunctionPath, Token, ApiConfig, CollectionDocument, CollectionFunctions, RateLimitingParams, RateLimitingErrors, AcceptedRole } from '.';
|
|
4
4
|
export type CollectionModel<TDescription extends Description> = MongoCollection<Omit<PackReferences<SchemaWithId<TDescription>>, '_id'>>;
|
|
5
5
|
type OmitContextParameter<TFunction> = TFunction extends () => any ? TFunction : TFunction extends (payload: undefined, ...args: any[]) => infer Return ? () => Return : TFunction extends (payload: infer Payload, context: Context, ...args: infer Rest) => infer Return ? (payload: Payload, ...args: Rest) => Return : never;
|
|
6
6
|
type RestParameters<TFunction> = TFunction extends (payload: any, context: Context, ...args: infer Rest) => any ? Rest : never;
|
|
@@ -26,7 +26,7 @@ export type ContextOptions = {
|
|
|
26
26
|
inherited?: boolean;
|
|
27
27
|
calledFunction?: string;
|
|
28
28
|
};
|
|
29
|
-
export type RouteContext<TAcceptedRole =
|
|
29
|
+
export type RouteContext<TAcceptedRole extends AcceptedRole = null> = {
|
|
30
30
|
collections: IndepthCollections;
|
|
31
31
|
functionPath: FunctionPath;
|
|
32
32
|
token: Token<TAcceptedRole>;
|
|
@@ -43,12 +43,14 @@ export type RouteContext<TAcceptedRole = string> = {
|
|
|
43
43
|
inherited: boolean;
|
|
44
44
|
calledFunction: string;
|
|
45
45
|
};
|
|
46
|
-
export type
|
|
46
|
+
export type CollectionContext<TDescription extends Description = any, TFunctions = any> = {
|
|
47
47
|
description: TDescription;
|
|
48
48
|
collectionName?: (keyof Collections & string) | string;
|
|
49
49
|
collection: TDescription['$id'] extends keyof Collections ? IndepthCollection<{
|
|
50
50
|
description: TDescription;
|
|
51
51
|
functions: TFunctions;
|
|
52
|
-
}> :
|
|
52
|
+
}> : IndepthCollection<any>;
|
|
53
53
|
};
|
|
54
|
+
export type Context<TDescription extends Description = any, TFunctions = any> = RouteContext & CollectionContext<TDescription, TFunctions>;
|
|
55
|
+
export type StrictContext<TAcceptedRole extends AcceptedRole = null, TDescription extends Description = any, TFunctions = any> = RouteContext<TAcceptedRole> & CollectionContext<TDescription, TFunctions>;
|
|
54
56
|
export {};
|
package/dist/contract.d.ts
CHANGED
package/dist/description.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { IconStyle, PhosphorIcon } from '@phosphor-icons/core';
|
|
2
|
-
import type { JsonSchema, PropertiesWithId } from './property';
|
|
3
|
-
import type { Condition } from './condition';
|
|
2
|
+
import type { JsonSchema, PropertiesWithId } from './property.js';
|
|
3
|
+
import type { Condition } from './condition.js';
|
|
4
|
+
import type { OwnershipMode } from './security.js';
|
|
4
5
|
export type CollectionPresets = 'crud' | 'duplicate' | 'remove' | 'removeAll' | 'owned' | 'timestamped' | 'view';
|
|
5
6
|
export type Icon = PhosphorIcon['name'] | `${IconStyle}:${PhosphorIcon['name']}`;
|
|
6
7
|
export type CollectionAction<TDescription extends Description> = Readonly<{
|
|
@@ -71,33 +72,33 @@ export type SearchOptions<TDescription extends Description> = {
|
|
|
71
72
|
};
|
|
72
73
|
export type Description<TDescription extends Description = any> = JsonSchema<TDescription> & {
|
|
73
74
|
title?: string;
|
|
74
|
-
categories?: string[];
|
|
75
|
+
categories?: readonly string[];
|
|
75
76
|
system?: boolean;
|
|
76
77
|
inline?: boolean;
|
|
77
78
|
preferred?: Record<string, Partial<TDescription | Description>>;
|
|
78
79
|
icon?: Icon;
|
|
79
80
|
options?: CollectionOptions<TDescription>;
|
|
80
|
-
indexes?:
|
|
81
|
+
indexes?: readonly (keyof TDescription['properties'])[];
|
|
81
82
|
defaults?: Record<string, any>;
|
|
82
|
-
owned?:
|
|
83
|
+
owned?: OwnershipMode;
|
|
83
84
|
temporary?: {
|
|
84
85
|
index: keyof TDescription['properties'];
|
|
85
86
|
expireAfterSeconds: number;
|
|
86
87
|
};
|
|
87
88
|
timestamps?: false;
|
|
88
|
-
immutable?: boolean |
|
|
89
|
-
route?:
|
|
90
|
-
presets?:
|
|
91
|
-
table?:
|
|
92
|
-
tableMeta?:
|
|
89
|
+
immutable?: boolean | readonly string[];
|
|
90
|
+
route?: readonly string[];
|
|
91
|
+
presets?: readonly CollectionPresets[];
|
|
92
|
+
table?: readonly PropertiesWithId<TDescription>[];
|
|
93
|
+
tableMeta?: readonly PropertiesWithId<TDescription>[];
|
|
93
94
|
filtersPresets?: Record<string, FiltersPreset<TDescription>>;
|
|
94
95
|
freshItem?: Partial<Record<PropertiesWithId<TDescription>, any>>;
|
|
95
|
-
form?:
|
|
96
|
-
writable?:
|
|
97
|
-
filters?:
|
|
96
|
+
form?: readonly PropertiesWithId<TDescription>[] | Record<PropertiesWithId<TDescription>, string[]>;
|
|
97
|
+
writable?: readonly PropertiesWithId<TDescription>[];
|
|
98
|
+
filters?: readonly (PropertiesWithId<TDescription> | {
|
|
98
99
|
property: PropertiesWithId<TDescription>;
|
|
99
100
|
default: string;
|
|
100
|
-
}
|
|
101
|
+
})[];
|
|
101
102
|
layout?: Layout<TDescription>;
|
|
102
103
|
formLayout?: Partial<FormLayout<TDescription>>;
|
|
103
104
|
tableLayout?: Partial<TableLayout<TDescription>>;
|
package/dist/security.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Collection } from './api.js';
|
|
2
|
+
export type OwnershipMode = boolean | 'always' | 'on-write';
|
|
2
3
|
export declare enum RateLimitingErrors {
|
|
3
4
|
Unauthenticated = "UNAUTHENTICATED",
|
|
4
5
|
LimitReached = "LIMIT_REACHED"
|
|
@@ -24,4 +25,6 @@ export type SecurityPolicy = {
|
|
|
24
25
|
rateLimiting?: RateLimitingParams;
|
|
25
26
|
logging?: LoggingParams;
|
|
26
27
|
};
|
|
27
|
-
export type CollectionSecurityPolicy<TCollection extends Collection = any> =
|
|
28
|
+
export type CollectionSecurityPolicy<TCollection extends Collection = any> = {
|
|
29
|
+
functions?: Partial<Record<keyof TCollection['functions'], SecurityPolicy>>;
|
|
30
|
+
};
|