@aeriajs/types 0.0.63 → 0.0.65

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.
@@ -11,5 +11,6 @@ export declare enum ACError {
11
11
  OwnershipError = "OWNERSHIP_ERROR",
12
12
  ResourceNotFound = "RESOURCE_NOT_FOUND",
13
13
  InsecureOperator = "INSECURE_OPERATOR",
14
- MalformedInput = "MALFORMED_INPUT"
14
+ MalformedInput = "MALFORMED_INPUT",
15
+ UnknownError = "UNKNOWN_INPUT"
15
16
  }
@@ -13,4 +13,5 @@ var ACError;
13
13
  ACError["ResourceNotFound"] = "RESOURCE_NOT_FOUND";
14
14
  ACError["InsecureOperator"] = "INSECURE_OPERATOR";
15
15
  ACError["MalformedInput"] = "MALFORMED_INPUT";
16
+ ACError["UnknownError"] = "UNKNOWN_INPUT";
16
17
  })(ACError || (exports.ACError = ACError = {}));
@@ -10,5 +10,6 @@ export var ACError = /* @__PURE__ */ ((ACError2) => {
10
10
  ACError2["ResourceNotFound"] = "RESOURCE_NOT_FOUND";
11
11
  ACError2["InsecureOperator"] = "INSECURE_OPERATOR";
12
12
  ACError2["MalformedInput"] = "MALFORMED_INPUT";
13
+ ACError2["UnknownError"] = "UNKNOWN_INPUT";
13
14
  return ACError2;
14
15
  })(ACError || {});
@@ -5,6 +5,7 @@ import type { Property } from './property.js';
5
5
  import type { UserRole } from './token.js';
6
6
  export type ContractBase = {
7
7
  builtin?: boolean;
8
+ streamed?: boolean;
8
9
  };
9
10
  export type ContractRoles = {
10
11
  roles?: readonly UserRole[] | boolean | 'unauthenticated' | 'unauthenticated-only';
@@ -15,8 +15,9 @@ export type Pagination = {
15
15
  offset: number;
16
16
  limit: number;
17
17
  };
18
+ type FilterProperty<T> = T extends ObjectId ? T | string : T;
18
19
  type DocumentFilter<TDocument> = PackReferences<TDocument> extends infer Document ? {
19
- [P in keyof Document]: null | (Document[P] extends ObjectId ? Document[P] | string : Document[P]);
20
+ [P in keyof Document]: null | (Document[P] extends (infer E)[] ? FilterProperty<E>[] : FilterProperty<Document[P]>);
20
21
  } : never;
21
22
  type RemoveAny<T> = {
22
23
  [P in keyof T as 0 extends (T[P] & 1) ? never : P]: T[P];
@@ -24,9 +25,9 @@ type RemoveAny<T> = {
24
25
  export type StrictFilter<TDocument> = RemoveAny<Filter<DocumentFilter<TDocument>>>;
25
26
  export type StrictFilterOperators<TDocument> = RemoveAny<FilterOperators<DocumentFilter<TDocument>>>;
26
27
  export type Filters<TDocument> = StrictFilter<TDocument> & Partial<{
27
- [P in keyof TDocument]: null | (TDocument[P] extends infer Field ? Field extends ObjectId ? Field | string : Field extends {
28
+ [P in keyof TDocument | `${Extract<keyof TDocument, string>}.${string}`]: (P extends keyof TDocument ? TDocument[P] extends infer Field ? Field extends ObjectId ? Field | string : Field extends {
28
29
  _id: infer Id;
29
- } ? Id | string : Field : never) extends infer Field ? Field | StrictFilterOperators<Field> | null : never;
30
+ } ? Id | string : Field : never : any) extends infer Field ? Field | StrictFilterOperators<Field> | null : never;
30
31
  }>;
31
32
  export type What<TDocument> = ({
32
33
  _id: ObjectId | string;
@@ -35,7 +36,7 @@ export type What<TDocument> = ({
35
36
  } & Omit<PackReferences<TDocument>, '_id'>) extends infer Document ? {
36
37
  [P in keyof Document]: Document[P] | null;
37
38
  } : never;
38
- export type Projection<TDocument> = keyof TDocument | '_id' extends infer DocumentProp ? TDocument extends string ? DocumentProp[] : string[] : never;
39
+ export type Projection<TDocument> = keyof TDocument | '_id' extends infer DocumentProp ? DocumentProp extends string ? DocumentProp[] : string[] : never;
39
40
  export type QuerySort<TDocument> = Partial<Record<keyof WithId<TDocument>, 1 | -1>>;
40
41
  export type CollectionDocument<TDocument> = TDocument;
41
42
  export type CountPayload<TDocument extends CollectionDocument<OptionalId<any>>> = {
package/dist/http.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import type { ServerResponse, IncomingMessage } from 'http';
3
2
  import type { MapSchemaUnion } from './schema.js';
4
3
  import type { ExtractError, ExtractResult, Result } from './result.js';
@@ -18,17 +17,18 @@ export declare enum HTTPStatus {
18
17
  }
19
18
  export type RouteUri = `/${string}`;
20
19
  export type RequestMethod = (typeof REQUEST_METHODS)[number];
21
- export type GenericRequest = {
22
- url: string;
23
- method: RequestMethod;
24
- headers: Record<string, string | string[] | undefined>;
25
- body?: string;
26
- query: Record<string, any>;
20
+ export type GenericRequest = Omit<IncomingMessage, 'url' | 'method'> & {
21
+ readonly url: string;
22
+ readonly method: RequestMethod;
23
+ readonly body?: string;
24
+ readonly fragments: string[];
27
25
  payload: Record<string, any>;
28
- fragments: string[];
29
- nodeRequest: IncomingMessage;
26
+ query: Record<string, any>;
27
+ };
28
+ export declare const STREAMED_RESPONSE: unique symbol;
29
+ export type GenericResponse = ServerResponse & {
30
+ [STREAMED_RESPONSE]?: boolean;
30
31
  };
31
- export type GenericResponse = ServerResponse;
32
32
  type ExtractCode<TRouteResponse> = TRouteResponse extends Result.Error<EndpointError<infer PCode>> ? PCode : never;
33
33
  type ExtractHTTPStatus<TRouteResponse> = TRouteResponse extends Result.Error<EndpointError<any, unknown, infer PHTTPStatus>> ? PHTTPStatus : never;
34
34
  export type WithACErrors<TRouteResponse> = Result.Either<ExtractError<TRouteResponse> | StrictEndpointError<ExtractCode<TRouteResponse> | ACError.AuthenticationError | ACError.AuthorizationError | RateLimitingError.LimitReached | RateLimitingError.Unauthenticated, unknown, ExtractHTTPStatus<TRouteResponse> | HTTPStatus.Unauthorized | HTTPStatus.TooManyRequests>, ExtractResult<TRouteResponse>>;
package/dist/http.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.HTTPStatus = exports.REQUEST_METHODS = void 0;
3
+ exports.STREAMED_RESPONSE = exports.HTTPStatus = exports.REQUEST_METHODS = void 0;
4
4
  exports.REQUEST_METHODS = [
5
5
  'GET',
6
6
  'HEAD',
@@ -23,3 +23,4 @@ var HTTPStatus;
23
23
  HTTPStatus[HTTPStatus["TooManyRequests"] = 429] = "TooManyRequests";
24
24
  HTTPStatus[HTTPStatus["InternalServerError"] = 500] = "InternalServerError";
25
25
  })(HTTPStatus || (exports.HTTPStatus = HTTPStatus = {}));
26
+ exports.STREAMED_RESPONSE = Symbol('StreamedResponse');
package/dist/http.mjs CHANGED
@@ -21,3 +21,4 @@ export var HTTPStatus = /* @__PURE__ */ ((HTTPStatus2) => {
21
21
  HTTPStatus2[HTTPStatus2["InternalServerError"] = 500] = "InternalServerError";
22
22
  return HTTPStatus2;
23
23
  })(HTTPStatus || {});
24
+ export const STREAMED_RESPONSE = Symbol("StreamedResponse");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aeriajs/types",
3
- "version": "0.0.63",
3
+ "version": "0.0.65",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",