@aeriajs/types 0.0.45 → 0.0.47

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/context.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { Collection as MongoCollection } from 'mongodb';
2
2
  import type { GenericRequest, GenericResponse } from './http.js';
3
- import type { Either, Description, PackReferences, SchemaWithId, FunctionPath, Token, ApiConfig, CollectionDocument, CollectionFunctions, RateLimitingParams, RateLimitingErrors, AcceptedRole } from '.';
3
+ import type { Either, EndpointError, Description, PackReferences, SchemaWithId, FunctionPath, Token, ApiConfig, CollectionDocument, CollectionFunctions, RateLimitingParams, RateLimitingErrors, AcceptedRole } from '.';
4
4
  export type CollectionModel<TDescription extends Description> = MongoCollection<Omit<PackReferences<SchemaWithId<TDescription>>, '_id'>>;
5
5
  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
6
  type RestParameters<TFunction> = TFunction extends (payload: any, context: Context, ...args: infer Rest) => any ? Rest : never;
@@ -33,6 +33,7 @@ export type RouteContext<TAcceptedRole extends AcceptedRole = null> = {
33
33
  request: GenericRequest;
34
34
  response: GenericResponse;
35
35
  log: (message: string, details?: any) => Promise<any>;
36
+ error: (error: EndpointError) => EndpointError;
36
37
  limitRate: (params: RateLimitingParams) => Promise<Either<RateLimitingErrors, {
37
38
  hits: number;
38
39
  points: number;
@@ -0,0 +1,6 @@
1
+ export type EndpointError = {
2
+ httpCode?: number;
3
+ code: string;
4
+ message: string;
5
+ details?: Record<string, any>;
6
+ };
package/dist/error.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/dist/error.mjs ADDED
@@ -0,0 +1 @@
1
+ "use strict";
package/dist/index.d.ts CHANGED
@@ -6,6 +6,7 @@ export * from './context.js';
6
6
  export * from './contract.js';
7
7
  export * from './description.js';
8
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
@@ -22,6 +22,7 @@ __exportStar(require("./context.js"), exports);
22
22
  __exportStar(require("./contract.js"), exports);
23
23
  __exportStar(require("./description.js"), exports);
24
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
@@ -7,6 +7,7 @@ export * from "./context.mjs";
7
7
  export * from "./contract.mjs";
8
8
  export * from "./description.mjs";
9
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
@@ -12,7 +12,7 @@ type CaseOwned<TSchema, TType> = TSchema extends {
12
12
  type CaseTimestamped<TSchema, TType> = TSchema extends {
13
13
  timestamps: false;
14
14
  } ? TType : TType & Timestamped;
15
- type TestType<T> = T & Record<string, any>;
15
+ type TestType<T> = T & Record<string, unknown>;
16
16
  export type InferProperty<T> = T extends TestType<{
17
17
  format: 'date' | 'date-time';
18
18
  }> ? Date : T extends TestType<{
@@ -24,7 +24,7 @@ export type InferProperty<T> = T extends TestType<{
24
24
  }> ? number : T extends TestType<{
25
25
  type: 'boolean';
26
26
  }> ? boolean : T extends TestType<{
27
- properties: any;
27
+ properties: unknown;
28
28
  }> ? Schema<T & {
29
29
  timestamps: false;
30
30
  }> : T extends TestType<{
@@ -36,7 +36,7 @@ export type InferProperty<T> = T extends TestType<{
36
36
  }> ? any : T extends TestType<{
37
37
  items: infer K;
38
38
  }> ? InferProperty<K>[] : T extends TestType<{
39
- getter: (doc: any) => infer K;
39
+ getter: (doc: unknown) => infer K;
40
40
  }> ? Awaited<K> : T extends TestType<{
41
41
  const: infer K;
42
42
  }> ? K : never;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aeriajs/types",
3
- "version": "0.0.45",
3
+ "version": "0.0.47",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",