@aeriajs/types 0.0.72 → 0.0.74
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/collection.d.ts +3 -2
- package/dist/description.d.ts +4 -12
- package/dist/property.d.ts +2 -1
- package/dist/security.d.ts +14 -0
- package/package.json +1 -1
package/dist/collection.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import type { AccessCondition } from './accessControl.js';
|
|
2
|
-
import type { CollectionSecurityPolicy } from './security.js';
|
|
2
|
+
import type { CollectionSecurityPolicy, CollectionMiddleware } from './security.js';
|
|
3
3
|
import type { Context } from './context.js';
|
|
4
4
|
import type { Contract } from './contract.js';
|
|
5
5
|
import type { Description } from './description.js';
|
|
6
6
|
export type Collection<TCollection extends Collection = any> = {
|
|
7
7
|
description: Description;
|
|
8
8
|
item?: any;
|
|
9
|
-
security?: CollectionSecurityPolicy<TCollection>;
|
|
10
9
|
functions?: Record<string, (payload: any, context: Context<any>, ...args: any[]) => any>;
|
|
11
10
|
contracts?: Record<string, Contract>;
|
|
12
11
|
exposedFunctions?: Record<string, AccessCondition>;
|
|
12
|
+
security?: CollectionSecurityPolicy<TCollection>;
|
|
13
|
+
middlewares?: CollectionMiddleware | CollectionMiddleware[];
|
|
13
14
|
};
|
|
14
15
|
export type CollectionItem<TCollectionName extends keyof Collections> = Omit<Collections[TCollectionName]['item'], '_id'>;
|
|
15
16
|
export type CollectionItemWithId<TCollectionName extends keyof Collections> = Collections[TCollectionName]['item'];
|
package/dist/description.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type { PhosphorIcon } from '@phosphor-icons/core';
|
|
|
3
3
|
import type { Condition } from './condition.js';
|
|
4
4
|
import type { JsonSchema, PropertiesWithId } from './property.js';
|
|
5
5
|
import type { OwnershipMode } from './security.js';
|
|
6
|
-
export type
|
|
6
|
+
export type DescriptionPreset = 'crud' | 'duplicate' | 'remove' | 'removeAll' | 'owned' | 'timestamped' | 'view';
|
|
7
7
|
export type Icon = PhosphorIcon['name'];
|
|
8
8
|
export type CollectionActionRoute = {
|
|
9
9
|
route: {
|
|
@@ -61,16 +61,10 @@ export type FiltersPreset<TDescription extends Description> = {
|
|
|
61
61
|
badgeFunction?: string;
|
|
62
62
|
default?: boolean;
|
|
63
63
|
};
|
|
64
|
-
export type CollectionOptions<TDescription extends Description> = {
|
|
65
|
-
queryPreset?: {
|
|
66
|
-
filters?: Partial<Record<PropertiesWithId<TDescription> | `$${string}`, any>>;
|
|
67
|
-
sort?: Partial<Record<PropertiesWithId<TDescription>, any>>;
|
|
68
|
-
};
|
|
69
|
-
};
|
|
70
64
|
export type LayoutName = 'tabular' | 'grid' | 'list';
|
|
71
65
|
export type LayoutOptions<TDescription extends Description = any> = {
|
|
72
|
-
picture?: PropertiesWithId<TDescription>;
|
|
73
66
|
title?: PropertiesWithId<TDescription>;
|
|
67
|
+
picture?: PropertiesWithId<TDescription>;
|
|
74
68
|
badge?: PropertiesWithId<TDescription>;
|
|
75
69
|
information?: PropertiesWithId<TDescription>;
|
|
76
70
|
active?: PropertiesWithId<TDescription>;
|
|
@@ -88,11 +82,9 @@ export type RuntimeDescription<TDescription extends Description = any> = Pick<TD
|
|
|
88
82
|
export type Description<TDescription extends Description = any> = JsonSchema<TDescription> & {
|
|
89
83
|
title?: string;
|
|
90
84
|
categories?: readonly string[];
|
|
91
|
-
|
|
92
|
-
inline?: boolean;
|
|
85
|
+
hidden?: boolean;
|
|
93
86
|
preferred?: Record<string, RuntimeDescription<TDescription>>;
|
|
94
87
|
icon?: Icon;
|
|
95
|
-
options?: CollectionOptions<TDescription>;
|
|
96
88
|
indexes?: readonly PropertiesWithId<TDescription>[];
|
|
97
89
|
defaults?: Record<string, any>;
|
|
98
90
|
owned?: OwnershipMode;
|
|
@@ -103,7 +95,7 @@ export type Description<TDescription extends Description = any> = JsonSchema<TDe
|
|
|
103
95
|
timestamps?: false;
|
|
104
96
|
immutable?: boolean | readonly (keyof TDescription['properties'])[] | ((doc: WithId<any>) => boolean | Promise<boolean>);
|
|
105
97
|
route?: readonly string[];
|
|
106
|
-
presets?: readonly
|
|
98
|
+
presets?: readonly DescriptionPreset[];
|
|
107
99
|
table?: readonly PropertiesWithId<TDescription>[];
|
|
108
100
|
tableMeta?: readonly PropertiesWithId<TDescription>[];
|
|
109
101
|
filtersPresets?: Record<string, FiltersPreset<TDescription>>;
|
package/dist/property.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ import type { PhosphorIcon } from '@phosphor-icons/core';
|
|
|
2
2
|
import type { Condition } from './condition.js';
|
|
3
3
|
export type PropertyArrayElement = 'checkbox' | 'radio' | 'select';
|
|
4
4
|
export type PropertyInputType = 'text' | 'email' | 'password' | 'search' | 'time' | 'month';
|
|
5
|
+
export type PropertyInputElement = 'input' | 'textarea';
|
|
5
6
|
export type PropertyFormat = 'date' | 'date-time';
|
|
6
7
|
export type PropertiesWithId<TSchema extends JsonSchema> = keyof TSchema['properties'] | '_id';
|
|
7
8
|
export type RequiredProperties<TSchema extends JsonSchema> = readonly PropertiesWithId<TSchema>[] | Partial<Record<PropertiesWithId<TSchema>, Condition<TSchema> | boolean>>;
|
|
@@ -70,7 +71,7 @@ export type StringProperty = {
|
|
|
70
71
|
mask?: string | readonly string[];
|
|
71
72
|
maskedValue?: boolean;
|
|
72
73
|
placeholder?: string;
|
|
73
|
-
element?:
|
|
74
|
+
element?: PropertyInputElement;
|
|
74
75
|
inputType?: PropertyInputType;
|
|
75
76
|
};
|
|
76
77
|
export type NumberProperty = {
|
package/dist/security.d.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import type { Result } from './result.js';
|
|
2
|
+
import type { Context } from './context.js';
|
|
3
|
+
import type { ACError } from './accessControl.js';
|
|
1
4
|
export type OwnershipMode = boolean | 'always' | 'on-write';
|
|
2
5
|
export declare enum RateLimitingError {
|
|
3
6
|
Unauthenticated = "UNAUTHENTICATED",
|
|
@@ -29,3 +32,14 @@ export type CollectionSecurityPolicy<TCollection extends {
|
|
|
29
32
|
}> = {
|
|
30
33
|
functions?: Partial<Record<keyof TCollection['functions'], SecurityPolicy>>;
|
|
31
34
|
};
|
|
35
|
+
export type CollectionHookProps<TPayload = any> = {
|
|
36
|
+
propertyName?: string;
|
|
37
|
+
parentId?: string;
|
|
38
|
+
childId?: string;
|
|
39
|
+
payload: TPayload;
|
|
40
|
+
};
|
|
41
|
+
export type CollectionHook<TPayload = any> = (props: CollectionHookProps, context: Context) => Promise<Result.Either<ACError, TPayload>>;
|
|
42
|
+
export type CollectionMiddleware = {
|
|
43
|
+
beforeRead: CollectionHook;
|
|
44
|
+
beforeWrite: CollectionHook;
|
|
45
|
+
};
|