@aeriajs/types 0.0.51 → 0.0.52
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 +3 -5
- package/dist/accessControl.js +3 -16
- package/dist/accessControl.mjs +2 -15
- package/dist/collection.d.ts +1 -2
- package/dist/context.d.ts +9 -9
- package/dist/description.d.ts +2 -1
- package/dist/{monad.d.ts → either.d.ts} +0 -10
- package/dist/error.d.ts +20 -0
- package/dist/error.js +5 -0
- package/dist/error.mjs +3 -0
- package/dist/functions.d.ts +7 -4
- package/dist/http.d.ts +1 -0
- package/dist/http.js +1 -0
- package/dist/http.mjs +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.js +2 -1
- package/dist/index.mjs +2 -1
- package/dist/schema.d.ts +1 -1
- package/dist/security.d.ts +1 -1
- package/dist/security.js +6 -6
- package/dist/security.mjs +5 -5
- package/dist/token.d.ts +0 -2
- package/dist/validation.d.ts +13 -7
- package/dist/validation.js +15 -7
- package/dist/validation.mjs +14 -6
- package/package.json +1 -1
- /package/dist/{monad.js → either.js} +0 -0
- /package/dist/{monad.mjs → either.mjs} +0 -0
package/dist/accessControl.d.ts
CHANGED
|
@@ -6,11 +6,9 @@ export declare enum ACError {
|
|
|
6
6
|
AuthorizationError = "AUTHORIZATION_ERROR",
|
|
7
7
|
FunctionNotFound = "FUNCTION_NOT_FOUND",
|
|
8
8
|
FunctionNotExposed = "FUNCTION_NOT_EXPOSED",
|
|
9
|
-
|
|
10
|
-
ImmutabilityParentNotFound = "IMMUTABILITY_PARENT_NOT_FOUND",
|
|
11
|
-
ImmutabilityTargetImmutable = "IMMUTABILITY_TARGET_IMMUTABLE",
|
|
9
|
+
TargetImmutable = "TARGET_IMMUTABLE",
|
|
12
10
|
InvalidLimit = "INVALID_LIMIT",
|
|
13
11
|
OwnershipError = "OWNERSHIP_ERROR",
|
|
14
|
-
ResourceNotFound = "RESOURCE_NOT_FOUND"
|
|
12
|
+
ResourceNotFound = "RESOURCE_NOT_FOUND",
|
|
13
|
+
InsecureOperator = "INSECURE_OPERATOR"
|
|
15
14
|
}
|
|
16
|
-
export declare const ACErrorMessages: Record<ACError, string>;
|
package/dist/accessControl.js
CHANGED
|
@@ -1,28 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.ACError = void 0;
|
|
4
4
|
var ACError;
|
|
5
5
|
(function (ACError) {
|
|
6
6
|
ACError["AuthenticationError"] = "AUTHENTICATION_ERROR";
|
|
7
7
|
ACError["AuthorizationError"] = "AUTHORIZATION_ERROR";
|
|
8
8
|
ACError["FunctionNotFound"] = "FUNCTION_NOT_FOUND";
|
|
9
9
|
ACError["FunctionNotExposed"] = "FUNCTION_NOT_EXPOSED";
|
|
10
|
-
ACError["
|
|
11
|
-
ACError["ImmutabilityParentNotFound"] = "IMMUTABILITY_PARENT_NOT_FOUND";
|
|
12
|
-
ACError["ImmutabilityTargetImmutable"] = "IMMUTABILITY_TARGET_IMMUTABLE";
|
|
10
|
+
ACError["TargetImmutable"] = "TARGET_IMMUTABLE";
|
|
13
11
|
ACError["InvalidLimit"] = "INVALID_LIMIT";
|
|
14
12
|
ACError["OwnershipError"] = "OWNERSHIP_ERROR";
|
|
15
13
|
ACError["ResourceNotFound"] = "RESOURCE_NOT_FOUND";
|
|
14
|
+
ACError["InsecureOperator"] = "INSECURE_OPERATOR";
|
|
16
15
|
})(ACError || (exports.ACError = ACError = {}));
|
|
17
|
-
exports.ACErrorMessages = {
|
|
18
|
-
[ACError.AuthenticationError]: 'you have insufficient privileges',
|
|
19
|
-
[ACError.AuthorizationError]: 'you have insufficient privileges',
|
|
20
|
-
[ACError.FunctionNotFound]: 'function not found',
|
|
21
|
-
[ACError.FunctionNotExposed]: 'function not exposed',
|
|
22
|
-
[ACError.ImmutabilityIncorrectChild]: 'specified limit is invalid',
|
|
23
|
-
[ACError.ImmutabilityParentNotFound]: 'specified limit is invalid',
|
|
24
|
-
[ACError.ImmutabilityTargetImmutable]: 'specified limit is invalid',
|
|
25
|
-
[ACError.InvalidLimit]: 'specified limit is invalid',
|
|
26
|
-
[ACError.OwnershipError]: 'you have insufficient privileges',
|
|
27
|
-
[ACError.ResourceNotFound]: 'collection not found',
|
|
28
|
-
};
|
package/dist/accessControl.mjs
CHANGED
|
@@ -4,23 +4,10 @@ export var ACError = /* @__PURE__ */ ((ACError2) => {
|
|
|
4
4
|
ACError2["AuthorizationError"] = "AUTHORIZATION_ERROR";
|
|
5
5
|
ACError2["FunctionNotFound"] = "FUNCTION_NOT_FOUND";
|
|
6
6
|
ACError2["FunctionNotExposed"] = "FUNCTION_NOT_EXPOSED";
|
|
7
|
-
ACError2["
|
|
8
|
-
ACError2["ImmutabilityParentNotFound"] = "IMMUTABILITY_PARENT_NOT_FOUND";
|
|
9
|
-
ACError2["ImmutabilityTargetImmutable"] = "IMMUTABILITY_TARGET_IMMUTABLE";
|
|
7
|
+
ACError2["TargetImmutable"] = "TARGET_IMMUTABLE";
|
|
10
8
|
ACError2["InvalidLimit"] = "INVALID_LIMIT";
|
|
11
9
|
ACError2["OwnershipError"] = "OWNERSHIP_ERROR";
|
|
12
10
|
ACError2["ResourceNotFound"] = "RESOURCE_NOT_FOUND";
|
|
11
|
+
ACError2["InsecureOperator"] = "INSECURE_OPERATOR";
|
|
13
12
|
return ACError2;
|
|
14
13
|
})(ACError || {});
|
|
15
|
-
export const ACErrorMessages = {
|
|
16
|
-
["AUTHENTICATION_ERROR" /* AuthenticationError */]: "you have insufficient privileges",
|
|
17
|
-
["AUTHORIZATION_ERROR" /* AuthorizationError */]: "you have insufficient privileges",
|
|
18
|
-
["FUNCTION_NOT_FOUND" /* FunctionNotFound */]: "function not found",
|
|
19
|
-
["FUNCTION_NOT_EXPOSED" /* FunctionNotExposed */]: "function not exposed",
|
|
20
|
-
["IMMUTABILITY_INCORRECT_CHILD" /* ImmutabilityIncorrectChild */]: "specified limit is invalid",
|
|
21
|
-
["IMMUTABILITY_PARENT_NOT_FOUND" /* ImmutabilityParentNotFound */]: "specified limit is invalid",
|
|
22
|
-
["IMMUTABILITY_TARGET_IMMUTABLE" /* ImmutabilityTargetImmutable */]: "specified limit is invalid",
|
|
23
|
-
["INVALID_LIMIT" /* InvalidLimit */]: "specified limit is invalid",
|
|
24
|
-
["OWNERSHIP_ERROR" /* OwnershipError */]: "you have insufficient privileges",
|
|
25
|
-
["RESOURCE_NOT_FOUND" /* ResourceNotFound */]: "collection not found"
|
|
26
|
-
};
|
package/dist/collection.d.ts
CHANGED
|
@@ -7,11 +7,10 @@ export type Collection<TCollection extends Collection = any> = {
|
|
|
7
7
|
description: Description;
|
|
8
8
|
item?: any;
|
|
9
9
|
security?: CollectionSecurityPolicy<TCollection>;
|
|
10
|
-
functions?: Record<string, (payload: any, context: Context
|
|
10
|
+
functions?: Record<string, (payload: any, context: Context<any>, ...args: any[]) => any>;
|
|
11
11
|
contracts?: Record<string, Contract>;
|
|
12
12
|
exposedFunctions?: Record<string, AccessCondition>;
|
|
13
13
|
};
|
|
14
14
|
export type CollectionItem<TCollectionName extends keyof Collections> = Omit<Collections[TCollectionName]['item'], '_id'>;
|
|
15
15
|
export type CollectionItemWithId<TCollectionName extends keyof Collections> = Collections[TCollectionName]['item'];
|
|
16
16
|
export type AssetType = keyof Collection;
|
|
17
|
-
export type FunctionPath = `/${string}/${string}`;
|
package/dist/context.d.ts
CHANGED
|
@@ -3,15 +3,14 @@ import type { AcceptedRole } from './token.js';
|
|
|
3
3
|
import type { ApiConfig } from './config.js';
|
|
4
4
|
import type { CollectionDocument, CollectionFunctions } from './functions.js';
|
|
5
5
|
import type { Description } from './description.js';
|
|
6
|
-
import type {
|
|
7
|
-
import type { FunctionPath } from './collection.js';
|
|
6
|
+
import type { EndpointError, EndpointErrorContent } from './error.js';
|
|
8
7
|
import type { GenericRequest, GenericResponse, HTTPStatus } from './http.js';
|
|
9
8
|
import type { PackReferences, SchemaWithId } from './schema.js';
|
|
10
|
-
import type { RateLimitingParams,
|
|
9
|
+
import type { RateLimitingParams, RateLimitingError } from './security.js';
|
|
11
10
|
import type { Token } from './token.js';
|
|
12
11
|
export type CollectionModel<TDescription extends Description> = MongoCollection<Omit<PackReferences<SchemaWithId<TDescription>>, '_id'>>;
|
|
13
12
|
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;
|
|
14
|
-
type RestParameters<TFunction> = TFunction extends (payload: any, context: Context
|
|
13
|
+
type RestParameters<TFunction> = TFunction extends (payload: any, context: Context<any>, ...args: infer Rest) => any ? Rest : never;
|
|
15
14
|
type UnionFunctions<TFunctions, TSchema extends CollectionDocument<any>> = {
|
|
16
15
|
[P in keyof TFunctions]: (P extends keyof CollectionFunctions<any> ? CollectionFunctions<TSchema>[P] extends infer CollFunction ? CollFunction extends (...args: any[]) => any ? Extract<undefined, Parameters<CollFunction>[0]> extends never ? (payload: Parameters<CollFunction>[0], ...args: RestParameters<TFunctions[P]>) => ReturnType<CollFunction> : (payload?: Parameters<CollFunction>[0], ...args: RestParameters<TFunctions[P]>) => ReturnType<CollFunction> : never : never : OmitContextParameter<TFunctions[P]>) extends (...args: infer Args) => infer Return ? Return extends Promise<any> ? (...args: Args) => Return : (...args: Args) => Promise<Return> : never;
|
|
17
16
|
};
|
|
@@ -36,18 +35,19 @@ export type ContextOptions = {
|
|
|
36
35
|
};
|
|
37
36
|
export type RouteContext<TAcceptedRole extends AcceptedRole = null> = {
|
|
38
37
|
collections: IndepthCollections;
|
|
39
|
-
functionPath: FunctionPath;
|
|
40
38
|
token: Token<TAcceptedRole>;
|
|
41
39
|
request: GenericRequest;
|
|
42
40
|
response: GenericResponse;
|
|
43
41
|
log: (message: string, details?: any) => Promise<any>;
|
|
44
|
-
error: <TEndpointErrorContent extends
|
|
45
|
-
|
|
42
|
+
error: <const THTTPStatus extends HTTPStatus, const TEndpointErrorContent extends EndpointErrorContent>(httpStatus: THTTPStatus, error: TEndpointErrorContent) => EndpointError<TEndpointErrorContent & {
|
|
43
|
+
httpStatus: THTTPStatus;
|
|
44
|
+
}>;
|
|
45
|
+
limitRate: (params: RateLimitingParams) => Promise<EndpointError<EndpointErrorContent<RateLimitingError, HTTPStatus.TooManyRequests>> | {
|
|
46
46
|
hits: number;
|
|
47
47
|
points: number;
|
|
48
48
|
last_reach: Date;
|
|
49
49
|
last_maximum_reach: Date;
|
|
50
|
-
}
|
|
50
|
+
}>;
|
|
51
51
|
config: ApiConfig;
|
|
52
52
|
inherited: boolean;
|
|
53
53
|
calledFunction: string;
|
|
@@ -60,6 +60,6 @@ export type CollectionContext<TDescription extends Description = any, TFunctions
|
|
|
60
60
|
functions: TFunctions;
|
|
61
61
|
}> : IndepthCollection<any>;
|
|
62
62
|
};
|
|
63
|
-
export type Context<TDescription extends Description =
|
|
63
|
+
export type Context<TDescription extends Description = Description, TFunctions = any> = RouteContext & CollectionContext<TDescription, TFunctions>;
|
|
64
64
|
export type StrictContext<TAcceptedRole extends AcceptedRole = null, TDescription extends Description = any, TFunctions = any> = RouteContext<TAcceptedRole> & CollectionContext<TDescription, TFunctions>;
|
|
65
65
|
export {};
|
package/dist/description.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { WithId } from 'mongodb';
|
|
1
2
|
import type { IconStyle, PhosphorIcon } from '@phosphor-icons/core';
|
|
2
3
|
import type { Condition } from './condition.js';
|
|
3
4
|
import type { JsonSchema, PropertiesWithId } from './property.js';
|
|
@@ -87,7 +88,7 @@ export type Description<TDescription extends Description = any> = JsonSchema<TDe
|
|
|
87
88
|
expireAfterSeconds: number;
|
|
88
89
|
};
|
|
89
90
|
timestamps?: false;
|
|
90
|
-
immutable?: boolean | readonly
|
|
91
|
+
immutable?: boolean | readonly (keyof TDescription['properties'])[] | ((doc: WithId<any>) => boolean | Promise<boolean>);
|
|
91
92
|
route?: readonly string[];
|
|
92
93
|
presets?: readonly CollectionPresets[];
|
|
93
94
|
table?: readonly PropertiesWithId<TDescription>[];
|
|
@@ -6,16 +6,6 @@ export type Right<T> = {
|
|
|
6
6
|
readonly _tag: 'Right';
|
|
7
7
|
readonly value: T;
|
|
8
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
9
|
export type ExtractLeft<T> = T extends Left<infer L> ? L : never;
|
|
20
10
|
export type ExtractRight<T> = T extends Right<infer R> ? R : never;
|
|
21
11
|
export type Either<L, R> = Left<L> | Right<R>;
|
package/dist/error.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { HTTPStatus } from './http.js';
|
|
2
|
+
export declare const ERROR_SYMBOL_DESCRIPTION = "#__ERROR_SYMBOL__";
|
|
3
|
+
export declare const ERROR_SYMBOL: unique symbol;
|
|
4
|
+
export type EndpointErrorContent<TCode extends string = string, TDetails = unknown, THTTPStatus extends HTTPStatus = HTTPStatus, TMessage extends string = string> = {
|
|
5
|
+
code: TCode;
|
|
6
|
+
httpStatus?: THTTPStatus;
|
|
7
|
+
details?: TDetails;
|
|
8
|
+
message?: TMessage;
|
|
9
|
+
};
|
|
10
|
+
export type StrictEndpointErrorContent<TCode extends string = string, TDetails = unknown, THTTPStatus extends HTTPStatus | undefined = HTTPStatus, TMessage extends string | undefined = string> = {
|
|
11
|
+
code: TCode;
|
|
12
|
+
httpStatus: THTTPStatus;
|
|
13
|
+
details?: TDetails;
|
|
14
|
+
message?: TMessage;
|
|
15
|
+
};
|
|
16
|
+
export type EndpointError<TEndpointErrorContent extends EndpointErrorContent = EndpointErrorContent> = {
|
|
17
|
+
readonly _tag: 'Error';
|
|
18
|
+
readonly value: TEndpointErrorContent;
|
|
19
|
+
};
|
|
20
|
+
export type ExtractError<T> = T extends EndpointError ? T : never;
|
package/dist/error.js
ADDED
package/dist/error.mjs
ADDED
package/dist/functions.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { FilterOperators, StrictFilter as Filter, StrictUpdateFilter, WithId, OptionalId, ObjectId } from 'mongodb';
|
|
2
2
|
import type { ACError } from './accessControl.js';
|
|
3
|
-
import type {
|
|
3
|
+
import type { EndpointError, StrictEndpointErrorContent } from './error.js';
|
|
4
4
|
import type { PackReferences } from './schema.js';
|
|
5
|
-
import type {
|
|
5
|
+
import type { ValidationErrorCode } from './validation.js';
|
|
6
|
+
import type { HTTPStatus } from './http.js';
|
|
6
7
|
export type UploadAuxProps = {
|
|
7
8
|
parentId: string;
|
|
8
9
|
propertyName: string;
|
|
@@ -67,11 +68,13 @@ export type RemoveFilePayload = UploadAuxProps & {
|
|
|
67
68
|
_id: any;
|
|
68
69
|
};
|
|
69
70
|
};
|
|
71
|
+
export type InsertReturnType<TDocument> = TDocument | EndpointError<StrictEndpointErrorContent<ACError | ValidationErrorCode, unknown, HTTPStatus.NotFound | HTTPStatus.UnprocessableContent>>;
|
|
72
|
+
export type GetReturnType<TDocument> = TDocument | EndpointError<StrictEndpointErrorContent<ACError.ResourceNotFound, unknown, HTTPStatus.NotFound>>;
|
|
70
73
|
export type CollectionFunctions<TDocument extends CollectionDocument<OptionalId<any>>> = {
|
|
71
74
|
count: (payload: CountPayload<TDocument>) => Promise<number>;
|
|
72
|
-
get: (payload: GetPayload<TDocument>) => Promise<TDocument
|
|
75
|
+
get: (payload: GetPayload<TDocument>) => Promise<GetReturnType<TDocument>>;
|
|
73
76
|
getAll: (payload?: GetAllPayload<TDocument>) => Promise<TDocument[]>;
|
|
74
|
-
insert: (payload: InsertPayload<TDocument>) => Promise<
|
|
77
|
+
insert: (payload: InsertPayload<TDocument>) => Promise<InsertReturnType<TDocument>>;
|
|
75
78
|
remove: (payload: RemovePayload<TDocument>) => Promise<TDocument>;
|
|
76
79
|
removeAll: (payload: RemoveAllPayload) => Promise<any>;
|
|
77
80
|
removeFile: (payload: RemoveFilePayload) => Promise<any>;
|
package/dist/http.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import type { ServerResponse, IncomingMessage } from 'http';
|
|
|
3
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
5
|
export declare enum HTTPStatus {
|
|
6
|
+
Ok = 200,
|
|
6
7
|
BadRequest = 400,
|
|
7
8
|
Unauthorized = 401,
|
|
8
9
|
Forbidden = 403,
|
package/dist/http.js
CHANGED
|
@@ -14,6 +14,7 @@ exports.REQUEST_METHODS = [
|
|
|
14
14
|
];
|
|
15
15
|
var HTTPStatus;
|
|
16
16
|
(function (HTTPStatus) {
|
|
17
|
+
HTTPStatus[HTTPStatus["Ok"] = 200] = "Ok";
|
|
17
18
|
HTTPStatus[HTTPStatus["BadRequest"] = 400] = "BadRequest";
|
|
18
19
|
HTTPStatus[HTTPStatus["Unauthorized"] = 401] = "Unauthorized";
|
|
19
20
|
HTTPStatus[HTTPStatus["Forbidden"] = 403] = "Forbidden";
|
package/dist/http.mjs
CHANGED
|
@@ -11,6 +11,7 @@ export const REQUEST_METHODS = [
|
|
|
11
11
|
"SEARCH"
|
|
12
12
|
];
|
|
13
13
|
export var HTTPStatus = /* @__PURE__ */ ((HTTPStatus2) => {
|
|
14
|
+
HTTPStatus2[HTTPStatus2["Ok"] = 200] = "Ok";
|
|
14
15
|
HTTPStatus2[HTTPStatus2["BadRequest"] = 400] = "BadRequest";
|
|
15
16
|
HTTPStatus2[HTTPStatus2["Unauthorized"] = 401] = "Unauthorized";
|
|
16
17
|
HTTPStatus2[HTTPStatus2["Forbidden"] = 403] = "Forbidden";
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,8 @@ 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 './
|
|
8
|
+
export * from './either.js';
|
|
9
|
+
export * from './error.js';
|
|
9
10
|
export * from './functions.js';
|
|
10
11
|
export * from './http.js';
|
|
11
12
|
export * from './property.js';
|
package/dist/index.js
CHANGED
|
@@ -21,7 +21,8 @@ __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("./
|
|
24
|
+
__exportStar(require("./either.js"), exports);
|
|
25
|
+
__exportStar(require("./error.js"), exports);
|
|
25
26
|
__exportStar(require("./functions.js"), exports);
|
|
26
27
|
__exportStar(require("./http.js"), exports);
|
|
27
28
|
__exportStar(require("./property.js"), exports);
|
package/dist/index.mjs
CHANGED
|
@@ -6,7 +6,8 @@ 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 "./
|
|
9
|
+
export * from "./either.mjs";
|
|
10
|
+
export * from "./error.mjs";
|
|
10
11
|
export * from "./functions.mjs";
|
|
11
12
|
export * from "./http.mjs";
|
|
12
13
|
export * from "./property.mjs";
|
package/dist/schema.d.ts
CHANGED
|
@@ -41,7 +41,7 @@ export type InferProperty<T> = T extends TestType<{
|
|
|
41
41
|
const: infer K;
|
|
42
42
|
}> ? K : never;
|
|
43
43
|
export type InferSchema<TSchema> = MergeReferences<TSchema> extends infer MappedTypes ? TSchema extends {
|
|
44
|
-
|
|
44
|
+
Required: readonly [];
|
|
45
45
|
} ? Partial<MappedTypes> : TSchema extends {
|
|
46
46
|
required: infer RequiredPropNames;
|
|
47
47
|
} ? RequiredPropNames extends readonly (keyof MappedTypes)[] ? Pick<MappedTypes, RequiredPropNames[number]> extends infer RequiredProps ? RequiredProps & Partial<Exclude<MappedTypes, keyof RequiredProps>> : never : MappedTypes : MappedTypes : never;
|
package/dist/security.d.ts
CHANGED
package/dist/security.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
var
|
|
5
|
-
(function (
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
})(
|
|
3
|
+
exports.RateLimitingError = void 0;
|
|
4
|
+
var RateLimitingError;
|
|
5
|
+
(function (RateLimitingError) {
|
|
6
|
+
RateLimitingError["Unauthenticated"] = "UNAUTHENTICATED";
|
|
7
|
+
RateLimitingError["LimitReached"] = "LIMIT_REACHED";
|
|
8
|
+
})(RateLimitingError || (exports.RateLimitingError = RateLimitingError = {}));
|
package/dist/security.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
export var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
return
|
|
6
|
-
})(
|
|
2
|
+
export var RateLimitingError = /* @__PURE__ */ ((RateLimitingError2) => {
|
|
3
|
+
RateLimitingError2["Unauthenticated"] = "UNAUTHENTICATED";
|
|
4
|
+
RateLimitingError2["LimitReached"] = "LIMIT_REACHED";
|
|
5
|
+
return RateLimitingError2;
|
|
6
|
+
})(RateLimitingError || {});
|
package/dist/token.d.ts
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import type { ObjectId } from 'mongodb';
|
|
2
2
|
import type { PackReferences } from './schema.js';
|
|
3
|
-
import type { FunctionPath } from './collection.js';
|
|
4
3
|
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
4
|
export type AcceptedRole = UserRole | UserRole[] | null | unknown;
|
|
6
5
|
export type AuthenticatedToken<TAcceptedRole extends AcceptedRole = null> = {
|
|
7
6
|
authenticated: true;
|
|
8
7
|
sub: ObjectId;
|
|
9
8
|
roles: readonly (TAcceptedRole extends null ? string : TAcceptedRole)[];
|
|
10
|
-
allowed_functions?: readonly FunctionPath[];
|
|
11
9
|
userinfo: Omit<Collections['user']['item'], '_id' | 'roles'> extends infer UserItem ? UserItem | PackReferences<UserItem> : never;
|
|
12
10
|
};
|
|
13
11
|
export type UnauthenticatedToken = {
|
package/dist/validation.d.ts
CHANGED
|
@@ -1,29 +1,35 @@
|
|
|
1
|
-
export declare enum
|
|
1
|
+
export declare enum ValidationErrorCode {
|
|
2
2
|
InvalidProperties = "INVALID_PROPERTIES",
|
|
3
3
|
MissingProperties = "MISSING_PROPERTIES",
|
|
4
4
|
EmptyTarget = "EMPTY_TARGET"
|
|
5
5
|
}
|
|
6
|
-
export
|
|
6
|
+
export declare enum PropertyValidationErrorCode {
|
|
7
|
+
Missing = "MISSING_PROPERTY",
|
|
8
|
+
Extraneous = "EXTRANEOUS_PROPERTY",
|
|
9
|
+
Unmatching = "UNMATCHING_PROPERTIES",
|
|
10
|
+
ExtraneousElement = "EXTRANEOUS_ELEMENT",
|
|
11
|
+
NumericConstraint = "NUMERIC_CONSTRAINT"
|
|
12
|
+
}
|
|
7
13
|
export type PropertyValidationError = {
|
|
8
|
-
type:
|
|
14
|
+
type: PropertyValidationErrorCode;
|
|
9
15
|
index?: number;
|
|
10
16
|
details: {
|
|
11
17
|
expected: any;
|
|
12
|
-
got:
|
|
18
|
+
got: any;
|
|
13
19
|
};
|
|
14
20
|
};
|
|
15
21
|
export type ValidationErrorInvalidProperties = {
|
|
16
|
-
code:
|
|
22
|
+
code: ValidationErrorCode.InvalidProperties;
|
|
17
23
|
errors: Record<string, PropertyValidationError | ValidationError>;
|
|
18
24
|
};
|
|
19
25
|
export type ValidationErrorMissingProperties = {
|
|
20
|
-
code:
|
|
26
|
+
code: ValidationErrorCode.MissingProperties;
|
|
21
27
|
errors: Record<string, {
|
|
22
28
|
type: 'missing';
|
|
23
29
|
}>;
|
|
24
30
|
};
|
|
25
31
|
export type ValidationErrorEmptyTarget = {
|
|
26
|
-
code:
|
|
32
|
+
code: ValidationErrorCode.EmptyTarget;
|
|
27
33
|
errors: {};
|
|
28
34
|
};
|
|
29
35
|
export type ValidationError = ValidationErrorInvalidProperties | ValidationErrorMissingProperties | ValidationErrorEmptyTarget;
|
package/dist/validation.js
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
var
|
|
5
|
-
(function (
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
})(
|
|
3
|
+
exports.PropertyValidationErrorCode = exports.ValidationErrorCode = void 0;
|
|
4
|
+
var ValidationErrorCode;
|
|
5
|
+
(function (ValidationErrorCode) {
|
|
6
|
+
ValidationErrorCode["InvalidProperties"] = "INVALID_PROPERTIES";
|
|
7
|
+
ValidationErrorCode["MissingProperties"] = "MISSING_PROPERTIES";
|
|
8
|
+
ValidationErrorCode["EmptyTarget"] = "EMPTY_TARGET";
|
|
9
|
+
})(ValidationErrorCode || (exports.ValidationErrorCode = ValidationErrorCode = {}));
|
|
10
|
+
var PropertyValidationErrorCode;
|
|
11
|
+
(function (PropertyValidationErrorCode) {
|
|
12
|
+
PropertyValidationErrorCode["Missing"] = "MISSING_PROPERTY";
|
|
13
|
+
PropertyValidationErrorCode["Extraneous"] = "EXTRANEOUS_PROPERTY";
|
|
14
|
+
PropertyValidationErrorCode["Unmatching"] = "UNMATCHING_PROPERTIES";
|
|
15
|
+
PropertyValidationErrorCode["ExtraneousElement"] = "EXTRANEOUS_ELEMENT";
|
|
16
|
+
PropertyValidationErrorCode["NumericConstraint"] = "NUMERIC_CONSTRAINT";
|
|
17
|
+
})(PropertyValidationErrorCode || (exports.PropertyValidationErrorCode = PropertyValidationErrorCode = {}));
|
package/dist/validation.mjs
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
export var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
return
|
|
7
|
-
})(
|
|
2
|
+
export var ValidationErrorCode = /* @__PURE__ */ ((ValidationErrorCode2) => {
|
|
3
|
+
ValidationErrorCode2["InvalidProperties"] = "INVALID_PROPERTIES";
|
|
4
|
+
ValidationErrorCode2["MissingProperties"] = "MISSING_PROPERTIES";
|
|
5
|
+
ValidationErrorCode2["EmptyTarget"] = "EMPTY_TARGET";
|
|
6
|
+
return ValidationErrorCode2;
|
|
7
|
+
})(ValidationErrorCode || {});
|
|
8
|
+
export var PropertyValidationErrorCode = /* @__PURE__ */ ((PropertyValidationErrorCode2) => {
|
|
9
|
+
PropertyValidationErrorCode2["Missing"] = "MISSING_PROPERTY";
|
|
10
|
+
PropertyValidationErrorCode2["Extraneous"] = "EXTRANEOUS_PROPERTY";
|
|
11
|
+
PropertyValidationErrorCode2["Unmatching"] = "UNMATCHING_PROPERTIES";
|
|
12
|
+
PropertyValidationErrorCode2["ExtraneousElement"] = "EXTRANEOUS_ELEMENT";
|
|
13
|
+
PropertyValidationErrorCode2["NumericConstraint"] = "NUMERIC_CONSTRAINT";
|
|
14
|
+
return PropertyValidationErrorCode2;
|
|
15
|
+
})(PropertyValidationErrorCode || {});
|
package/package.json
CHANGED
|
File without changes
|
|
File without changes
|