@aeriajs/types 0.0.48 → 0.0.50
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 +4 -4
- package/dist/accessControl.js +26 -26
- package/dist/accessControl.mjs +14 -14
- package/dist/collection.d.ts +17 -0
- package/dist/config.d.ts +3 -1
- package/dist/context.d.ts +11 -6
- package/dist/contract.d.ts +5 -1
- package/dist/description.d.ts +1 -1
- package/dist/functions.d.ts +5 -2
- package/dist/http.d.ts +10 -1
- package/dist/http.js +11 -1
- package/dist/http.mjs +10 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.js +3 -3
- package/dist/index.mjs +3 -3
- package/dist/monad.d.ts +21 -0
- package/dist/property.d.ts +1 -1
- package/dist/security.d.ts +3 -2
- package/dist/token.d.ts +21 -0
- package/package.json +1 -1
- package/dist/api.d.ts +0 -30
- package/dist/either.d.ts +0 -9
- package/dist/error.d.ts +0 -6
- /package/dist/{api.js → collection.js} +0 -0
- /package/dist/{api.mjs → collection.mjs} +0 -0
- /package/dist/{either.js → monad.js} +0 -0
- /package/dist/{either.mjs → monad.mjs} +0 -0
- /package/dist/{error.js → token.js} +0 -0
- /package/dist/{error.mjs → token.mjs} +0 -0
package/dist/accessControl.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import type { UserRole } from './token.js';
|
|
2
2
|
export type AccessCondition = readonly UserRole[] | boolean | 'unauthenticated' | 'unauthenticated-only';
|
|
3
|
-
export type
|
|
4
|
-
export declare enum
|
|
3
|
+
export type RoleFromAccessCondition<TAccessCondition extends AccessCondition | undefined> = undefined extends TAccessCondition ? null : TAccessCondition extends readonly (infer Role)[] ? Role : TAccessCondition extends true ? Exclude<UserRole, 'unauthenticated'> : TAccessCondition extends false ? never : TAccessCondition extends 'unauthenticated-only' ? 'unauthenticated' : TAccessCondition extends 'unauthenticated' ? UserRole : never;
|
|
4
|
+
export declare enum ACError {
|
|
5
5
|
AssetNotFound = "ASSET_NOT_FOUND",
|
|
6
6
|
AuthenticationError = "AUTHENTICATION_ERROR",
|
|
7
7
|
AuthorizationError = "AUTHORIZATION_ERROR",
|
|
@@ -14,4 +14,4 @@ export declare enum ACErrors {
|
|
|
14
14
|
OwnershipError = "OWNERSHIP_ERROR",
|
|
15
15
|
ResourceNotFound = "RESOURCE_NOT_FOUND"
|
|
16
16
|
}
|
|
17
|
-
export declare const ACErrorMessages: Record<
|
|
17
|
+
export declare const ACErrorMessages: Record<ACError, string>;
|
package/dist/accessControl.js
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ACErrorMessages = exports.
|
|
4
|
-
var
|
|
5
|
-
(function (
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
})(
|
|
3
|
+
exports.ACErrorMessages = exports.ACError = void 0;
|
|
4
|
+
var ACError;
|
|
5
|
+
(function (ACError) {
|
|
6
|
+
ACError["AssetNotFound"] = "ASSET_NOT_FOUND";
|
|
7
|
+
ACError["AuthenticationError"] = "AUTHENTICATION_ERROR";
|
|
8
|
+
ACError["AuthorizationError"] = "AUTHORIZATION_ERROR";
|
|
9
|
+
ACError["FunctionNotFound"] = "FUNCTION_NOT_FOUND";
|
|
10
|
+
ACError["FunctionNotExposed"] = "FUNCTION_NOT_EXPOSED";
|
|
11
|
+
ACError["ImmutabilityIncorrectChild"] = "IMMUTABILITY_INCORRECT_CHILD";
|
|
12
|
+
ACError["ImmutabilityParentNotFound"] = "IMMUTABILITY_PARENT_NOT_FOUND";
|
|
13
|
+
ACError["ImmutabilityTargetImmutable"] = "IMMUTABILITY_TARGET_IMMUTABLE";
|
|
14
|
+
ACError["InvalidLimit"] = "INVALID_LIMIT";
|
|
15
|
+
ACError["OwnershipError"] = "OWNERSHIP_ERROR";
|
|
16
|
+
ACError["ResourceNotFound"] = "RESOURCE_NOT_FOUND";
|
|
17
|
+
})(ACError || (exports.ACError = ACError = {}));
|
|
18
18
|
exports.ACErrorMessages = {
|
|
19
|
-
[
|
|
20
|
-
[
|
|
21
|
-
[
|
|
22
|
-
[
|
|
23
|
-
[
|
|
24
|
-
[
|
|
25
|
-
[
|
|
26
|
-
[
|
|
27
|
-
[
|
|
28
|
-
[
|
|
29
|
-
[
|
|
19
|
+
[ACError.AssetNotFound]: 'collection has no registered functions',
|
|
20
|
+
[ACError.AuthenticationError]: 'you have insufficient privileges',
|
|
21
|
+
[ACError.AuthorizationError]: 'you have insufficient privileges',
|
|
22
|
+
[ACError.FunctionNotFound]: 'function not found',
|
|
23
|
+
[ACError.FunctionNotExposed]: 'function not exposed',
|
|
24
|
+
[ACError.ImmutabilityIncorrectChild]: 'specified limit is invalid',
|
|
25
|
+
[ACError.ImmutabilityParentNotFound]: 'specified limit is invalid',
|
|
26
|
+
[ACError.ImmutabilityTargetImmutable]: 'specified limit is invalid',
|
|
27
|
+
[ACError.InvalidLimit]: 'specified limit is invalid',
|
|
28
|
+
[ACError.OwnershipError]: 'you have insufficient privileges',
|
|
29
|
+
[ACError.ResourceNotFound]: 'collection not found',
|
|
30
30
|
};
|
package/dist/accessControl.mjs
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
export var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return
|
|
15
|
-
})(
|
|
2
|
+
export var ACError = /* @__PURE__ */ ((ACError2) => {
|
|
3
|
+
ACError2["AssetNotFound"] = "ASSET_NOT_FOUND";
|
|
4
|
+
ACError2["AuthenticationError"] = "AUTHENTICATION_ERROR";
|
|
5
|
+
ACError2["AuthorizationError"] = "AUTHORIZATION_ERROR";
|
|
6
|
+
ACError2["FunctionNotFound"] = "FUNCTION_NOT_FOUND";
|
|
7
|
+
ACError2["FunctionNotExposed"] = "FUNCTION_NOT_EXPOSED";
|
|
8
|
+
ACError2["ImmutabilityIncorrectChild"] = "IMMUTABILITY_INCORRECT_CHILD";
|
|
9
|
+
ACError2["ImmutabilityParentNotFound"] = "IMMUTABILITY_PARENT_NOT_FOUND";
|
|
10
|
+
ACError2["ImmutabilityTargetImmutable"] = "IMMUTABILITY_TARGET_IMMUTABLE";
|
|
11
|
+
ACError2["InvalidLimit"] = "INVALID_LIMIT";
|
|
12
|
+
ACError2["OwnershipError"] = "OWNERSHIP_ERROR";
|
|
13
|
+
ACError2["ResourceNotFound"] = "RESOURCE_NOT_FOUND";
|
|
14
|
+
return ACError2;
|
|
15
|
+
})(ACError || {});
|
|
16
16
|
export const ACErrorMessages = {
|
|
17
17
|
["ASSET_NOT_FOUND" /* AssetNotFound */]: "collection has no registered functions",
|
|
18
18
|
["AUTHENTICATION_ERROR" /* AuthenticationError */]: "you have insufficient privileges",
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { AccessCondition } from './accessControl.js';
|
|
2
|
+
import type { CollectionSecurityPolicy } from './security.js';
|
|
3
|
+
import type { Context } from './context.js';
|
|
4
|
+
import type { Contract } from './contract.js';
|
|
5
|
+
import type { Description } from './description.js';
|
|
6
|
+
export type Collection<TCollection extends Collection = any> = {
|
|
7
|
+
description: Description;
|
|
8
|
+
item?: any;
|
|
9
|
+
security?: CollectionSecurityPolicy<TCollection>;
|
|
10
|
+
functions?: Record<string, (payload: any, context: Context, ...args: any[]) => any>;
|
|
11
|
+
contracts?: Record<string, Contract>;
|
|
12
|
+
exposedFunctions?: Record<string, AccessCondition>;
|
|
13
|
+
};
|
|
14
|
+
export type CollectionItem<TCollectionName extends keyof Collections> = Omit<Collections[TCollectionName]['item'], '_id'>;
|
|
15
|
+
export type CollectionItemWithId<TCollectionName extends keyof Collections> = Collections[TCollectionName]['item'];
|
|
16
|
+
export type AssetType = keyof Collection;
|
|
17
|
+
export type FunctionPath = `/${string}/${string}`;
|
package/dist/config.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import type { RouteContext
|
|
1
|
+
import type { RouteContext } from './context.js';
|
|
2
|
+
import type { RouteUri } from './http.js';
|
|
3
|
+
import type { RateLimitingParams } from './security.js';
|
|
2
4
|
export type ApiConfig = {
|
|
3
5
|
secret?: string;
|
|
4
6
|
baseUrl?: RouteUri;
|
package/dist/context.d.ts
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
import type { Collection as MongoCollection } from 'mongodb';
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
2
|
+
import type { AcceptedRole } from './token.js';
|
|
3
|
+
import type { ApiConfig } from './config.js';
|
|
4
|
+
import type { CollectionDocument, CollectionFunctions } from './functions.js';
|
|
5
|
+
import type { Description } from './description.js';
|
|
6
|
+
import type { Either, EndpointError, EndpointErrorContent } from './monad.js';
|
|
7
|
+
import type { FunctionPath } from './collection.js';
|
|
8
|
+
import type { GenericRequest, GenericResponse, HTTPStatus } from './http.js';
|
|
9
|
+
import type { PackReferences, SchemaWithId } from './schema.js';
|
|
10
|
+
import type { RateLimitingParams, RateLimitingErrors } from './security.js';
|
|
11
|
+
import type { Token } from './token.js';
|
|
4
12
|
export type CollectionModel<TDescription extends Description> = MongoCollection<Omit<PackReferences<SchemaWithId<TDescription>>, '_id'>>;
|
|
5
13
|
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
14
|
type RestParameters<TFunction> = TFunction extends (payload: any, context: Context, ...args: infer Rest) => any ? Rest : never;
|
|
@@ -33,10 +41,7 @@ export type RouteContext<TAcceptedRole extends AcceptedRole = null> = {
|
|
|
33
41
|
request: GenericRequest;
|
|
34
42
|
response: GenericResponse;
|
|
35
43
|
log: (message: string, details?: any) => Promise<any>;
|
|
36
|
-
error: (error:
|
|
37
|
-
$isError: true;
|
|
38
|
-
error: EndpointError;
|
|
39
|
-
};
|
|
44
|
+
error: <TEndpointErrorContent extends Omit<EndpointErrorContent, 'httpStatus'>>(httpStatus: HTTPStatus, error: TEndpointErrorContent) => EndpointError<TEndpointErrorContent>;
|
|
40
45
|
limitRate: (params: RateLimitingParams) => Promise<Either<RateLimitingErrors, {
|
|
41
46
|
hits: number;
|
|
42
47
|
points: number;
|
package/dist/contract.d.ts
CHANGED
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { Context } from './context.js';
|
|
2
|
+
import type { InferProperty } from './schema.js';
|
|
3
|
+
import type { InferResponse } from './http.js';
|
|
4
|
+
import type { Property } from './property.js';
|
|
5
|
+
import type { UserRole } from './token.js';
|
|
2
6
|
export type ContractBase = {
|
|
3
7
|
builtin?: boolean;
|
|
4
8
|
};
|
package/dist/description.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { IconStyle, PhosphorIcon } from '@phosphor-icons/core';
|
|
2
|
-
import type { JsonSchema, PropertiesWithId } from './property.js';
|
|
3
2
|
import type { Condition } from './condition.js';
|
|
3
|
+
import type { JsonSchema, PropertiesWithId } from './property.js';
|
|
4
4
|
import type { OwnershipMode } from './security.js';
|
|
5
5
|
export type CollectionPresets = 'crud' | 'duplicate' | 'remove' | 'removeAll' | 'owned' | 'timestamped' | 'view';
|
|
6
6
|
export type Icon = PhosphorIcon['name'] | `${IconStyle}:${PhosphorIcon['name']}`;
|
package/dist/functions.d.ts
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
import type { FilterOperators, StrictFilter as Filter, StrictUpdateFilter, WithId, OptionalId, ObjectId } from 'mongodb';
|
|
2
|
-
import type {
|
|
2
|
+
import type { ACError } from './accessControl.js';
|
|
3
|
+
import type { Either } from './monad.js';
|
|
4
|
+
import type { PackReferences } from './schema.js';
|
|
5
|
+
import type { ValidationError } from './validation.js';
|
|
3
6
|
export type UploadAuxProps = {
|
|
4
7
|
parentId: string;
|
|
5
8
|
propertyName: string;
|
|
@@ -68,7 +71,7 @@ export type CollectionFunctions<TDocument extends CollectionDocument<OptionalId<
|
|
|
68
71
|
count: (payload: CountPayload<TDocument>) => Promise<number>;
|
|
69
72
|
get: (payload: GetPayload<TDocument>) => Promise<TDocument | null>;
|
|
70
73
|
getAll: (payload?: GetAllPayload<TDocument>) => Promise<TDocument[]>;
|
|
71
|
-
insert: (payload: InsertPayload<TDocument>) => Promise<Either<ValidationError |
|
|
74
|
+
insert: (payload: InsertPayload<TDocument>) => Promise<Either<ValidationError | ACError, TDocument>>;
|
|
72
75
|
remove: (payload: RemovePayload<TDocument>) => Promise<TDocument>;
|
|
73
76
|
removeAll: (payload: RemoveAllPayload) => Promise<any>;
|
|
74
77
|
removeFile: (payload: RemoveFilePayload) => Promise<any>;
|
package/dist/http.d.ts
CHANGED
|
@@ -1,7 +1,16 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
2
|
import type { ServerResponse, IncomingMessage } from 'http';
|
|
3
|
-
import type { MapSchemaUnion } from '.';
|
|
3
|
+
import type { MapSchemaUnion } from './schema.js';
|
|
4
4
|
export declare const REQUEST_METHODS: readonly ["GET", "HEAD", "POST", "PUT", "DELETE", "OPTIONS", "PATCH", "TRACE", "SEARCH"];
|
|
5
|
+
export declare enum HTTPStatus {
|
|
6
|
+
BadRequest = 400,
|
|
7
|
+
Unauthorized = 401,
|
|
8
|
+
Forbidden = 403,
|
|
9
|
+
NotFound = 404,
|
|
10
|
+
UnprocessableContent = 422,
|
|
11
|
+
TooManyRequests = 429,
|
|
12
|
+
InternalServerError = 500
|
|
13
|
+
}
|
|
5
14
|
export type RouteUri = `/${string}`;
|
|
6
15
|
export type RequestMethod = (typeof REQUEST_METHODS)[number];
|
|
7
16
|
export type GenericRequest = {
|
package/dist/http.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.REQUEST_METHODS = void 0;
|
|
3
|
+
exports.HTTPStatus = exports.REQUEST_METHODS = void 0;
|
|
4
4
|
exports.REQUEST_METHODS = [
|
|
5
5
|
'GET',
|
|
6
6
|
'HEAD',
|
|
@@ -12,3 +12,13 @@ exports.REQUEST_METHODS = [
|
|
|
12
12
|
'TRACE',
|
|
13
13
|
'SEARCH',
|
|
14
14
|
];
|
|
15
|
+
var HTTPStatus;
|
|
16
|
+
(function (HTTPStatus) {
|
|
17
|
+
HTTPStatus[HTTPStatus["BadRequest"] = 400] = "BadRequest";
|
|
18
|
+
HTTPStatus[HTTPStatus["Unauthorized"] = 401] = "Unauthorized";
|
|
19
|
+
HTTPStatus[HTTPStatus["Forbidden"] = 403] = "Forbidden";
|
|
20
|
+
HTTPStatus[HTTPStatus["NotFound"] = 404] = "NotFound";
|
|
21
|
+
HTTPStatus[HTTPStatus["UnprocessableContent"] = 422] = "UnprocessableContent";
|
|
22
|
+
HTTPStatus[HTTPStatus["TooManyRequests"] = 429] = "TooManyRequests";
|
|
23
|
+
HTTPStatus[HTTPStatus["InternalServerError"] = 500] = "InternalServerError";
|
|
24
|
+
})(HTTPStatus || (exports.HTTPStatus = HTTPStatus = {}));
|
package/dist/http.mjs
CHANGED
|
@@ -10,3 +10,13 @@ export const REQUEST_METHODS = [
|
|
|
10
10
|
"TRACE",
|
|
11
11
|
"SEARCH"
|
|
12
12
|
];
|
|
13
|
+
export var HTTPStatus = /* @__PURE__ */ ((HTTPStatus2) => {
|
|
14
|
+
HTTPStatus2[HTTPStatus2["BadRequest"] = 400] = "BadRequest";
|
|
15
|
+
HTTPStatus2[HTTPStatus2["Unauthorized"] = 401] = "Unauthorized";
|
|
16
|
+
HTTPStatus2[HTTPStatus2["Forbidden"] = 403] = "Forbidden";
|
|
17
|
+
HTTPStatus2[HTTPStatus2["NotFound"] = 404] = "NotFound";
|
|
18
|
+
HTTPStatus2[HTTPStatus2["UnprocessableContent"] = 422] = "UnprocessableContent";
|
|
19
|
+
HTTPStatus2[HTTPStatus2["TooManyRequests"] = 429] = "TooManyRequests";
|
|
20
|
+
HTTPStatus2[HTTPStatus2["InternalServerError"] = 500] = "InternalServerError";
|
|
21
|
+
return HTTPStatus2;
|
|
22
|
+
})(HTTPStatus || {});
|
package/dist/index.d.ts
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
export * from './accessControl.js';
|
|
2
|
-
export * from './
|
|
2
|
+
export * from './collection.js';
|
|
3
3
|
export * from './condition.js';
|
|
4
4
|
export * from './config.js';
|
|
5
5
|
export * from './context.js';
|
|
6
6
|
export * from './contract.js';
|
|
7
7
|
export * from './description.js';
|
|
8
|
-
export * from './
|
|
9
|
-
export * from './error.js';
|
|
8
|
+
export * from './monad.js';
|
|
10
9
|
export * from './functions.js';
|
|
11
10
|
export * from './http.js';
|
|
12
11
|
export * from './property.js';
|
|
13
12
|
export * from './schema.js';
|
|
14
13
|
export * from './security.js';
|
|
14
|
+
export * from './token.js';
|
|
15
15
|
export * from './validation.js';
|
|
16
16
|
export type { WithId, OptionalId, } from 'mongodb';
|
package/dist/index.js
CHANGED
|
@@ -15,17 +15,17 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
__exportStar(require("./accessControl.js"), exports);
|
|
18
|
-
__exportStar(require("./
|
|
18
|
+
__exportStar(require("./collection.js"), exports);
|
|
19
19
|
__exportStar(require("./condition.js"), exports);
|
|
20
20
|
__exportStar(require("./config.js"), exports);
|
|
21
21
|
__exportStar(require("./context.js"), exports);
|
|
22
22
|
__exportStar(require("./contract.js"), exports);
|
|
23
23
|
__exportStar(require("./description.js"), exports);
|
|
24
|
-
__exportStar(require("./
|
|
25
|
-
__exportStar(require("./error.js"), exports);
|
|
24
|
+
__exportStar(require("./monad.js"), exports);
|
|
26
25
|
__exportStar(require("./functions.js"), exports);
|
|
27
26
|
__exportStar(require("./http.js"), exports);
|
|
28
27
|
__exportStar(require("./property.js"), exports);
|
|
29
28
|
__exportStar(require("./schema.js"), exports);
|
|
30
29
|
__exportStar(require("./security.js"), exports);
|
|
30
|
+
__exportStar(require("./token.js"), exports);
|
|
31
31
|
__exportStar(require("./validation.js"), exports);
|
package/dist/index.mjs
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
export * from "./accessControl.mjs";
|
|
3
|
-
export * from "./
|
|
3
|
+
export * from "./collection.mjs";
|
|
4
4
|
export * from "./condition.mjs";
|
|
5
5
|
export * from "./config.mjs";
|
|
6
6
|
export * from "./context.mjs";
|
|
7
7
|
export * from "./contract.mjs";
|
|
8
8
|
export * from "./description.mjs";
|
|
9
|
-
export * from "./
|
|
10
|
-
export * from "./error.mjs";
|
|
9
|
+
export * from "./monad.mjs";
|
|
11
10
|
export * from "./functions.mjs";
|
|
12
11
|
export * from "./http.mjs";
|
|
13
12
|
export * from "./property.mjs";
|
|
14
13
|
export * from "./schema.mjs";
|
|
15
14
|
export * from "./security.mjs";
|
|
15
|
+
export * from "./token.mjs";
|
|
16
16
|
export * from "./validation.mjs";
|
package/dist/monad.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export type Left<T> = {
|
|
2
|
+
readonly _tag: 'Left';
|
|
3
|
+
readonly value: T;
|
|
4
|
+
};
|
|
5
|
+
export type Right<T> = {
|
|
6
|
+
readonly _tag: 'Right';
|
|
7
|
+
readonly value: T;
|
|
8
|
+
};
|
|
9
|
+
export type EndpointErrorContent = {
|
|
10
|
+
httpStatus?: number;
|
|
11
|
+
code: string;
|
|
12
|
+
message: string;
|
|
13
|
+
details?: Record<string, any>;
|
|
14
|
+
};
|
|
15
|
+
export type EndpointError<T extends EndpointErrorContent> = {
|
|
16
|
+
readonly _tag: 'Error';
|
|
17
|
+
readonly error: T;
|
|
18
|
+
};
|
|
19
|
+
export type ExtractLeft<T> = T extends Left<infer L> ? L : never;
|
|
20
|
+
export type ExtractRight<T> = T extends Right<infer R> ? R : never;
|
|
21
|
+
export type Either<L, R> = Left<L> | Right<R>;
|
package/dist/property.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { PhosphorIcon } from '@phosphor-icons/core';
|
|
2
|
-
import type { Condition } from '.';
|
|
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
5
|
export type PropertyFormat = 'date' | 'date-time';
|
package/dist/security.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { Collection } from './api.js';
|
|
2
1
|
export type OwnershipMode = boolean | 'always' | 'on-write';
|
|
3
2
|
export declare enum RateLimitingErrors {
|
|
4
3
|
Unauthenticated = "UNAUTHENTICATED",
|
|
@@ -25,6 +24,8 @@ export type SecurityPolicy = {
|
|
|
25
24
|
rateLimiting?: RateLimitingParams;
|
|
26
25
|
logging?: LoggingParams;
|
|
27
26
|
};
|
|
28
|
-
export type CollectionSecurityPolicy<TCollection extends
|
|
27
|
+
export type CollectionSecurityPolicy<TCollection extends {
|
|
28
|
+
functions?: Record<string, (...args: any[]) => unknown>;
|
|
29
|
+
}> = {
|
|
29
30
|
functions?: Partial<Record<keyof TCollection['functions'], SecurityPolicy>>;
|
|
30
31
|
};
|
package/dist/token.d.ts
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ObjectId } from 'mongodb';
|
|
2
|
+
import type { PackReferences } from './schema.js';
|
|
3
|
+
import type { FunctionPath } from './collection.js';
|
|
4
|
+
export type UserRole = (Collections['user']['item']['roles'][number] extends infer UserDefinedRole ? UserDefinedRole extends string ? `${UserDefinedRole}${UserDefinedRole}` extends UserDefinedRole ? 'root' : UserDefinedRole : never : never) | 'root' | 'unauthenticated';
|
|
5
|
+
export type AcceptedRole = UserRole | UserRole[] | null | unknown;
|
|
6
|
+
export type AuthenticatedToken<TAcceptedRole extends AcceptedRole = null> = {
|
|
7
|
+
authenticated: true;
|
|
8
|
+
sub: ObjectId;
|
|
9
|
+
roles: readonly (TAcceptedRole extends null ? string : TAcceptedRole)[];
|
|
10
|
+
allowed_functions?: readonly FunctionPath[];
|
|
11
|
+
userinfo: Omit<Collections['user']['item'], '_id' | 'roles'> extends infer UserItem ? UserItem | PackReferences<UserItem> : never;
|
|
12
|
+
};
|
|
13
|
+
export type UnauthenticatedToken = {
|
|
14
|
+
authenticated: false;
|
|
15
|
+
sub: null;
|
|
16
|
+
};
|
|
17
|
+
export type TokenRecipient = {
|
|
18
|
+
type: 'bearer';
|
|
19
|
+
content: string;
|
|
20
|
+
};
|
|
21
|
+
export type Token<TAcceptedRole extends AcceptedRole = null> = (null extends TAcceptedRole ? true : 'unauthenticated' extends TAcceptedRole ? true : false) extends true ? AuthenticatedToken | UnauthenticatedToken : AuthenticatedToken<TAcceptedRole>;
|
package/package.json
CHANGED
package/dist/api.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import type { ObjectId } from 'mongodb';
|
|
2
|
-
import type { Context, Contract, Description, CollectionSecurityPolicy, PackReferences, AcceptedRole, AccessCondition } from '.';
|
|
3
|
-
export type Collection<TCollection extends Collection = any> = {
|
|
4
|
-
description: Description;
|
|
5
|
-
item?: any;
|
|
6
|
-
security?: CollectionSecurityPolicy<TCollection>;
|
|
7
|
-
functions?: Record<string, (payload: any, context: Context, ...args: any[]) => any>;
|
|
8
|
-
functionContracts?: Record<string, Contract>;
|
|
9
|
-
exposedFunctions?: Record<string, AccessCondition>;
|
|
10
|
-
};
|
|
11
|
-
export type CollectionItem<TCollectionName extends keyof Collections> = Omit<Collections[TCollectionName]['item'], '_id'>;
|
|
12
|
-
export type CollectionItemWithId<TCollectionName extends keyof Collections> = Collections[TCollectionName]['item'];
|
|
13
|
-
export type AssetType = keyof Collection;
|
|
14
|
-
export type FunctionPath = `/${string}/${string}`;
|
|
15
|
-
export type AuthenticatedToken<TAcceptedRole extends AcceptedRole = null> = {
|
|
16
|
-
authenticated: true;
|
|
17
|
-
sub: ObjectId;
|
|
18
|
-
roles: readonly (TAcceptedRole extends null ? string : TAcceptedRole)[];
|
|
19
|
-
allowed_functions?: readonly FunctionPath[];
|
|
20
|
-
userinfo: Collections['user']['item'] | PackReferences<Collections['user']['item']>;
|
|
21
|
-
};
|
|
22
|
-
export type UnauthenticatedToken = {
|
|
23
|
-
authenticated: false;
|
|
24
|
-
sub: null;
|
|
25
|
-
};
|
|
26
|
-
export type TokenRecipient = {
|
|
27
|
-
type: 'bearer';
|
|
28
|
-
content: string;
|
|
29
|
-
};
|
|
30
|
-
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/either.d.ts
DELETED
package/dist/error.d.ts
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|