@aeriajs/core 0.0.85 → 0.0.86
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/assets.d.ts +2 -2
- package/dist/collection/define.d.ts +8 -8
- package/dist/endpoints.js +10 -10
- package/dist/endpoints.mjs +10 -10
- package/package.json +8 -8
package/dist/assets.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Context, Collection, Token } from '@aeriajs/types';
|
|
2
2
|
import { ACErrors } from '@aeriajs/types';
|
|
3
|
-
export declare const internalGetCollectionAsset: <TCollectionName extends string, TAssetName extends "item" | "description" | "security" | "functions" | "
|
|
4
|
-
export declare const getCollectionAsset: <TCollectionName extends string, TAssetName extends "item" | "description" | "security" | "functions" | "
|
|
3
|
+
export declare const internalGetCollectionAsset: <TCollectionName extends string, TAssetName extends "item" | "description" | "security" | "functions" | "contracts" | "exposedFunctions">(collectionName: TCollectionName, assetName: TAssetName) => Promise<import("@aeriajs/types").Left<ACErrors.ResourceNotFound> | import("@aeriajs/types").Left<ACErrors.AssetNotFound> | import("@aeriajs/types").Right<any>>;
|
|
4
|
+
export declare const getCollectionAsset: <TCollectionName extends string, TAssetName extends "item" | "description" | "security" | "functions" | "contracts" | "exposedFunctions">(collectionName: TCollectionName, assetName: TAssetName) => Promise<import("@aeriajs/types").Left<ACErrors.ResourceNotFound> | import("@aeriajs/types").Left<ACErrors.AssetNotFound> | import("@aeriajs/types").Right<NonNullable<Collection[TAssetName]>>>;
|
|
5
5
|
export declare const getFunction: <TCollectionName extends string, TFunctionName extends string>(collectionName: TCollectionName, functionName: TFunctionName, token?: Token, options?: {
|
|
6
6
|
exposedOnly: boolean;
|
|
7
7
|
}) => Promise<import("@aeriajs/types").Left<ACErrors.ResourceNotFound> | import("@aeriajs/types").Left<ACErrors.AssetNotFound> | import("@aeriajs/types").Left<ACErrors.FunctionNotFound> | import("@aeriajs/types").Left<ACErrors.FunctionNotExposed> | import("@aeriajs/types").Left<ACErrors.AuthorizationError> | import("@aeriajs/types").Right<(payload: unknown, context: Context) => Promise<any>>>;
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import type { SchemaWithId, Collection,
|
|
1
|
+
import type { SchemaWithId, Collection, StrictContext, Contract, ContractToFunction, Description, CollectionSecurityPolicy, AccessCondition, RoleFromAccessCondition } from '@aeriajs/types';
|
|
2
2
|
export type ExtendCollection<TLeftCollection extends Collection, TRightCollection> = Omit<TLeftCollection & TRightCollection, 'item'> & {
|
|
3
3
|
item: SchemaWithId<(TLeftCollection & TRightCollection)['description']>;
|
|
4
4
|
};
|
|
5
|
-
export declare const defineCollection: <TCollection extends Omit<Collection<TCollection extends Collection ? TCollection : never>, "item" | "description" | "security" | "functions" | "exposedFunctions">, const TDescription extends Description<TDescription>, const
|
|
5
|
+
export declare const defineCollection: <TCollection extends Omit<Collection<TCollection extends Collection ? TCollection : never>, "item" | "description" | "security" | "functions" | "exposedFunctions">, const TDescription extends Description<TDescription>, const TContracts extends { [P in keyof TFunctions]?: Contract | undefined; }, const TExposedFunctions extends Partial<Record<keyof TFunctions, AccessCondition>>, const TFunctions extends Record<string, (payload: any, context: StrictContext<any>) => any> & { [P_1 in keyof TContracts | keyof TExposedFunctions]: ContractToFunction<P_1 extends keyof TContracts ? NonNullable<TContracts[P_1]> : any, StrictContext<P_1 extends keyof TExposedFunctions ? RoleFromAccessCondition<TExposedFunctions[P_1]> : never, TDescription>>; }>(collection: TCollection & {
|
|
6
6
|
description: TDescription;
|
|
7
7
|
functions?: TFunctions;
|
|
8
|
-
|
|
9
|
-
exposedFunctions?:
|
|
8
|
+
contracts?: TContracts;
|
|
9
|
+
exposedFunctions?: TExposedFunctions;
|
|
10
10
|
security?: CollectionSecurityPolicy<{
|
|
11
11
|
description: NoInfer<TDescription>;
|
|
12
|
-
functions: TFunctions
|
|
12
|
+
functions: NoInfer<TFunctions>;
|
|
13
13
|
}>;
|
|
14
14
|
}) => TCollection & {
|
|
15
15
|
item: SchemaWithId<TDescription>;
|
|
16
16
|
description: TDescription;
|
|
17
17
|
functions: TFunctions;
|
|
18
|
-
|
|
18
|
+
contracts: TContracts;
|
|
19
19
|
};
|
|
20
20
|
export declare const extendCollection: <const TLeftCollection extends Collection, const TRightCollection extends {
|
|
21
21
|
description?: Partial<Description> | undefined;
|
|
22
22
|
item?: Partial<any> | undefined;
|
|
23
23
|
security?: Partial<CollectionSecurityPolicy<any> | undefined>;
|
|
24
|
-
functions?: Partial<Record<string, (payload: any, context: Context, ...args: any[]) => any> | undefined>;
|
|
25
|
-
|
|
24
|
+
functions?: Partial<Record<string, (payload: any, context: import("@aeriajs/types").Context, ...args: any[]) => any> | undefined>;
|
|
25
|
+
contracts?: Partial<Record<string, Contract> | undefined>;
|
|
26
26
|
exposedFunctions?: Partial<Record<string, AccessCondition> | undefined>;
|
|
27
27
|
}>(left: TLeftCollection, right: TRightCollection) => ExtendCollection<TLeftCollection, TRightCollection>;
|
package/dist/endpoints.js
CHANGED
|
@@ -37,7 +37,7 @@ const getEndpoints = async () => {
|
|
|
37
37
|
const collection = typeof candidate === 'function'
|
|
38
38
|
? candidate()
|
|
39
39
|
: candidate;
|
|
40
|
-
const { description, functions: collectionFunctions,
|
|
40
|
+
const { description, functions: collectionFunctions, contracts, exposedFunctions = {}, } = collection;
|
|
41
41
|
if (collectionFunctions) {
|
|
42
42
|
for (const fnName in collectionFunctions) {
|
|
43
43
|
const exposedStatus = await (0, accessControl_js_1.isFunctionExposed)(collection, fnName);
|
|
@@ -51,22 +51,22 @@ const getEndpoints = async () => {
|
|
|
51
51
|
: exposed
|
|
52
52
|
? await (0, entrypoint_1.getAvailableRoles)()
|
|
53
53
|
: [];
|
|
54
|
-
const
|
|
54
|
+
const endpointContracts = {
|
|
55
55
|
POST: null,
|
|
56
56
|
};
|
|
57
57
|
if (roles.length) {
|
|
58
|
-
|
|
59
|
-
|
|
58
|
+
endpointContracts.POST ??= {};
|
|
59
|
+
endpointContracts.POST.roles = roles;
|
|
60
60
|
}
|
|
61
|
-
if (
|
|
62
|
-
|
|
63
|
-
Object.assign(
|
|
61
|
+
if (contracts && fnName in contracts) {
|
|
62
|
+
endpointContracts.POST ??= {};
|
|
63
|
+
Object.assign(endpointContracts.POST, contracts[fnName]);
|
|
64
64
|
}
|
|
65
65
|
if (fnName in builtinFunctions) {
|
|
66
|
-
|
|
67
|
-
|
|
66
|
+
endpointContracts.POST ??= {};
|
|
67
|
+
endpointContracts.POST.builtin = true;
|
|
68
68
|
}
|
|
69
|
-
functions[endpoint] =
|
|
69
|
+
functions[endpoint] = endpointContracts;
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
}
|
package/dist/endpoints.mjs
CHANGED
|
@@ -13,7 +13,7 @@ export const getEndpoints = async () => {
|
|
|
13
13
|
const {
|
|
14
14
|
description,
|
|
15
15
|
functions: collectionFunctions,
|
|
16
|
-
|
|
16
|
+
contracts,
|
|
17
17
|
exposedFunctions = {}
|
|
18
18
|
} = collection;
|
|
19
19
|
if (collectionFunctions) {
|
|
@@ -25,22 +25,22 @@ export const getEndpoints = async () => {
|
|
|
25
25
|
const endpoint = `/${description.$id}/${fnName}`;
|
|
26
26
|
const exposed = exposedFunctions[fnName];
|
|
27
27
|
const roles = Array.isArray(exposed) ? exposed : exposed ? await getAvailableRoles() : [];
|
|
28
|
-
const
|
|
28
|
+
const endpointContracts = {
|
|
29
29
|
POST: null
|
|
30
30
|
};
|
|
31
31
|
if (roles.length) {
|
|
32
|
-
|
|
33
|
-
|
|
32
|
+
endpointContracts.POST ??= {};
|
|
33
|
+
endpointContracts.POST.roles = roles;
|
|
34
34
|
}
|
|
35
|
-
if (
|
|
36
|
-
|
|
37
|
-
Object.assign(
|
|
35
|
+
if (contracts && fnName in contracts) {
|
|
36
|
+
endpointContracts.POST ??= {};
|
|
37
|
+
Object.assign(endpointContracts.POST, contracts[fnName]);
|
|
38
38
|
}
|
|
39
39
|
if (fnName in builtinFunctions) {
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
endpointContracts.POST ??= {};
|
|
41
|
+
endpointContracts.POST.builtin = true;
|
|
42
42
|
}
|
|
43
|
-
functions[endpoint] =
|
|
43
|
+
functions[endpoint] = endpointContracts;
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aeriajs/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.86",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -41,13 +41,13 @@
|
|
|
41
41
|
"mongodb-memory-server": "^9.2.0"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"@aeriajs/builtins": "^0.0.
|
|
45
|
-
"@aeriajs/common": "^0.0.
|
|
46
|
-
"@aeriajs/entrypoint": "^0.0.
|
|
47
|
-
"@aeriajs/http": "^0.0.
|
|
48
|
-
"@aeriajs/security": "^0.0.
|
|
49
|
-
"@aeriajs/types": "^0.0.
|
|
50
|
-
"@aeriajs/validation": "^0.0.
|
|
44
|
+
"@aeriajs/builtins": "^0.0.86",
|
|
45
|
+
"@aeriajs/common": "^0.0.52",
|
|
46
|
+
"@aeriajs/entrypoint": "^0.0.52",
|
|
47
|
+
"@aeriajs/http": "^0.0.60",
|
|
48
|
+
"@aeriajs/security": "^0.0.86",
|
|
49
|
+
"@aeriajs/types": "^0.0.49",
|
|
50
|
+
"@aeriajs/validation": "^0.0.55"
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"mongodb": "^6.5.0",
|