@aeriajs/types 0.0.17 → 0.0.19

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.
@@ -1,16 +1,17 @@
1
1
  import type { Collection } from '.';
2
2
  export declare enum ACErrors {
3
- AuthorizationError = "AUTHORIZATION_ERROR",
3
+ AssetNotFound = "ASSET_NOT_FOUND",
4
4
  AuthenticationError = "AUTHENTICATION_ERROR",
5
+ AuthorizationError = "AUTHORIZATION_ERROR",
6
+ FunctionNotFound = "FUNCTION_NOT_FOUND",
5
7
  ImmutabilityIncorrectChild = "IMMUTABILITY_INCORRECT_CHILD",
6
8
  ImmutabilityParentNotFound = "IMMUTABILITY_PARENT_NOT_FOUND",
7
9
  ImmutabilityTargetImmutable = "IMMUTABILITY_TARGET_IMMUTABLE",
10
+ InvalidLimit = "INVALID_LIMIT",
8
11
  OwnershipError = "OWNERSHIP_ERROR",
9
- ResourceNotFound = "RESOURCE_NOT_FOUND",
10
- AssetNotFound = "ASSET_NOT_FOUND",
11
- FunctionNotFound = "FUNCTION_NOT_FOUND",
12
- InvalidLimit = "INVALID_LIMIT"
12
+ ResourceNotFound = "RESOURCE_NOT_FOUND"
13
13
  }
14
+ export declare const ACErrorMessages: Record<ACErrors, string>;
14
15
  export type Role<TCollection extends Collection = any, TAccessControl extends AccessControl<TCollection> = any> = {
15
16
  inherit?: readonly (keyof TAccessControl['roles'])[];
16
17
  grantEverything?: boolean;
@@ -1,16 +1,28 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ACErrors = void 0;
3
+ exports.ACErrorMessages = exports.ACErrors = void 0;
4
4
  var ACErrors;
5
5
  (function (ACErrors) {
6
- ACErrors["AuthorizationError"] = "AUTHORIZATION_ERROR";
6
+ ACErrors["AssetNotFound"] = "ASSET_NOT_FOUND";
7
7
  ACErrors["AuthenticationError"] = "AUTHENTICATION_ERROR";
8
+ ACErrors["AuthorizationError"] = "AUTHORIZATION_ERROR";
9
+ ACErrors["FunctionNotFound"] = "FUNCTION_NOT_FOUND";
8
10
  ACErrors["ImmutabilityIncorrectChild"] = "IMMUTABILITY_INCORRECT_CHILD";
9
11
  ACErrors["ImmutabilityParentNotFound"] = "IMMUTABILITY_PARENT_NOT_FOUND";
10
12
  ACErrors["ImmutabilityTargetImmutable"] = "IMMUTABILITY_TARGET_IMMUTABLE";
13
+ ACErrors["InvalidLimit"] = "INVALID_LIMIT";
11
14
  ACErrors["OwnershipError"] = "OWNERSHIP_ERROR";
12
15
  ACErrors["ResourceNotFound"] = "RESOURCE_NOT_FOUND";
13
- ACErrors["AssetNotFound"] = "ASSET_NOT_FOUND";
14
- ACErrors["FunctionNotFound"] = "FUNCTION_NOT_FOUND";
15
- ACErrors["InvalidLimit"] = "INVALID_LIMIT";
16
16
  })(ACErrors || (exports.ACErrors = ACErrors = {}));
17
+ exports.ACErrorMessages = {
18
+ [ACErrors.AssetNotFound]: 'collection has no registered functions',
19
+ [ACErrors.AuthenticationError]: 'you have insufficient privileges',
20
+ [ACErrors.AuthorizationError]: 'you have insufficient privileges',
21
+ [ACErrors.FunctionNotFound]: 'function not found',
22
+ [ACErrors.ImmutabilityIncorrectChild]: 'specified limit is invalid',
23
+ [ACErrors.ImmutabilityParentNotFound]: 'specified limit is invalid',
24
+ [ACErrors.ImmutabilityTargetImmutable]: 'specified limit is invalid',
25
+ [ACErrors.InvalidLimit]: 'specified limit is invalid',
26
+ [ACErrors.OwnershipError]: 'you have insufficient privileges',
27
+ [ACErrors.ResourceNotFound]: 'collection not found',
28
+ };
@@ -1,13 +1,28 @@
1
+ function _define_property(obj, key, value) {
2
+ if (key in obj) {
3
+ Object.defineProperty(obj, key, {
4
+ value: value,
5
+ enumerable: true,
6
+ configurable: true,
7
+ writable: true
8
+ });
9
+ } else {
10
+ obj[key] = value;
11
+ }
12
+ return obj;
13
+ }
1
14
  export var ACErrors;
2
15
  (function(ACErrors) {
3
- ACErrors["AuthorizationError"] = "AUTHORIZATION_ERROR";
16
+ ACErrors["AssetNotFound"] = "ASSET_NOT_FOUND";
4
17
  ACErrors["AuthenticationError"] = "AUTHENTICATION_ERROR";
18
+ ACErrors["AuthorizationError"] = "AUTHORIZATION_ERROR";
19
+ ACErrors["FunctionNotFound"] = "FUNCTION_NOT_FOUND";
5
20
  ACErrors["ImmutabilityIncorrectChild"] = "IMMUTABILITY_INCORRECT_CHILD";
6
21
  ACErrors["ImmutabilityParentNotFound"] = "IMMUTABILITY_PARENT_NOT_FOUND";
7
22
  ACErrors["ImmutabilityTargetImmutable"] = "IMMUTABILITY_TARGET_IMMUTABLE";
23
+ ACErrors["InvalidLimit"] = "INVALID_LIMIT";
8
24
  ACErrors["OwnershipError"] = "OWNERSHIP_ERROR";
9
25
  ACErrors["ResourceNotFound"] = "RESOURCE_NOT_FOUND";
10
- ACErrors["AssetNotFound"] = "ASSET_NOT_FOUND";
11
- ACErrors["FunctionNotFound"] = "FUNCTION_NOT_FOUND";
12
- ACErrors["InvalidLimit"] = "INVALID_LIMIT";
13
26
  })(ACErrors || (ACErrors = {}));
27
+ var _obj;
28
+ export var ACErrorMessages = (_obj = {}, _define_property(_obj, "ASSET_NOT_FOUND", "collection has no registered functions"), _define_property(_obj, "AUTHENTICATION_ERROR", "you have insufficient privileges"), _define_property(_obj, "AUTHORIZATION_ERROR", "you have insufficient privileges"), _define_property(_obj, "FUNCTION_NOT_FOUND", "function not found"), _define_property(_obj, "IMMUTABILITY_INCORRECT_CHILD", "specified limit is invalid"), _define_property(_obj, "IMMUTABILITY_PARENT_NOT_FOUND", "specified limit is invalid"), _define_property(_obj, "IMMUTABILITY_TARGET_IMMUTABLE", "specified limit is invalid"), _define_property(_obj, "INVALID_LIMIT", "specified limit is invalid"), _define_property(_obj, "OWNERSHIP_ERROR", "you have insufficient privileges"), _define_property(_obj, "RESOURCE_NOT_FOUND", "collection not found"), _obj);
package/dist/context.d.ts CHANGED
@@ -2,7 +2,7 @@ import type { Collection as MongoCollection } from 'mongodb';
2
2
  import type { GenericRequest, GenericResponse } from './http';
3
3
  import type { Description, PackReferences, SchemaWithId, FunctionPath, DecodedToken, ApiConfig, CollectionDocument, CollectionFunctions } from '.';
4
4
  export type CollectionModel<TDescription extends Description> = MongoCollection<Omit<PackReferences<SchemaWithId<TDescription>>, '_id'>>;
5
- type OmitContextParameter<TFunction> = TFunction extends (payload: infer Payload, context: Context, ...args: infer Rest) => infer Return ? (payload: Payload, ...args: Rest) => Return : never;
5
+ type OmitContextParameter<TFunction> = TFunction extends () => any ? TFunction : 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;
7
7
  type UnionFunctions<TFunctions, TSchema extends CollectionDocument<any>> = {
8
8
  [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;
package/dist/http.d.ts CHANGED
@@ -6,7 +6,7 @@ export type RequestMethod = (typeof REQUEST_METHODS)[number];
6
6
  export type GenericRequest = {
7
7
  url: string;
8
8
  method: RequestMethod;
9
- headers: Record<string, string>;
9
+ headers: Record<string, string | string[] | undefined>;
10
10
  body?: string;
11
11
  query: Record<string, any>;
12
12
  payload: Record<string, any>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aeriajs/types",
3
- "version": "0.0.17",
3
+ "version": "0.0.19",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",