@aeriajs/types 0.0.67 → 0.0.69

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.
@@ -81,7 +81,7 @@ export type Description<TDescription extends Description = any> = JsonSchema<TDe
81
81
  preferred?: Record<string, RuntimeDescription<TDescription>>;
82
82
  icon?: Icon;
83
83
  options?: CollectionOptions<TDescription>;
84
- indexes?: readonly (keyof TDescription['properties'])[];
84
+ indexes?: readonly PropertiesWithId<TDescription>[];
85
85
  defaults?: Record<string, any>;
86
86
  owned?: OwnershipMode;
87
87
  temporary?: {
@@ -3,7 +3,7 @@ import type { Result } from './result.js';
3
3
  import type { EndpointError, StrictEndpointError } from './endpointError.js';
4
4
  import type { PackReferences } from './schema.js';
5
5
  import type { ACError } from './accessControl.js';
6
- import type { ValidationErrorCode } from './validation.js';
6
+ import type { ValidationErrorCode, TraverseError } from './validation.js';
7
7
  import type { HTTPStatus, WithACErrors } from './http.js';
8
8
  export type UploadAuxProps = {
9
9
  parentId: string;
@@ -70,7 +70,7 @@ export type RemoveFilePayload = UploadAuxProps & {
70
70
  _id: any;
71
71
  };
72
72
  };
73
- export type InsertReturnType<TDocument> = Result.Either<StrictEndpointError<ACError.InsecureOperator | ACError.OwnershipError | ACError.ResourceNotFound | ACError.TargetImmutable | ValidationErrorCode, unknown, HTTPStatus.NotFound | HTTPStatus.UnprocessableContent>, TDocument>;
73
+ export type InsertReturnType<TDocument> = Result.Either<StrictEndpointError<ACError.InsecureOperator | ACError.OwnershipError | ACError.ResourceNotFound | ACError.TargetImmutable | ValidationErrorCode | TraverseError.InvalidDocumentId | TraverseError.InvalidTempfile, unknown, HTTPStatus.NotFound | HTTPStatus.UnprocessableContent>, TDocument>;
74
74
  export type GetReturnType<TDocument> = Result.Either<StrictEndpointError<ACError.ResourceNotFound | ACError.MalformedInput, unknown, HTTPStatus.NotFound | HTTPStatus.BadRequest>, TDocument>;
75
75
  export type CountReturnType = Result.Either<EndpointError, number>;
76
76
  export type GetAllReturnType<TDocument> = Result.Either<EndpointError, TDocument[]>;
package/dist/http.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { ServerResponse, IncomingMessage } from 'http';
2
2
  import type { MapSchemaUnion } from './schema.js';
3
- import type { ExtractError, ExtractResult, Result } from './result.js';
3
+ import type { Result } from './result.js';
4
4
  import type { EndpointError, StrictEndpointError } from './endpointError.js';
5
5
  import type { ACError } from './accessControl.js';
6
6
  import type { RateLimitingError } from './security.js';
@@ -29,10 +29,12 @@ export declare const STREAMED_RESPONSE: unique symbol;
29
29
  export type GenericResponse = ServerResponse & {
30
30
  [STREAMED_RESPONSE]?: boolean;
31
31
  };
32
- type ExtractCode<TRouteResponse> = TRouteResponse extends Result.Error<EndpointError<infer PCode>> ? PCode : never;
33
- type ExtractHTTPStatus<TRouteResponse> = TRouteResponse extends Result.Error<EndpointError<any, unknown, infer PHTTPStatus>> ? PHTTPStatus : never;
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>>;
35
- export type EndpointFunction<TRouteMethod extends RequestMethod, TRouteResponse, TRoutePayload> = (TRoutePayload extends null ? (payload?: any) => Promise<WithACErrors<TRouteResponse>> : TRoutePayload extends undefined ? () => Promise<WithACErrors<TRouteResponse>> : (payload: TRoutePayload) => Promise<WithACErrors<TRouteResponse>>) extends infer Function ? Record<TRouteMethod, Function> : never;
32
+ type ExtractCode<TRouteResponse> = TRouteResponse extends EndpointError<infer PCode> ? PCode : never;
33
+ type ExtractHTTPStatus<TRouteResponse> = TRouteResponse extends EndpointError<any, unknown, infer PHTTPStatus> ? PHTTPStatus : never;
34
+ export type NativeError = ACError.AuthenticationError | ACError.AuthorizationError | RateLimitingError.LimitReached | RateLimitingError.Unauthenticated;
35
+ export type NativeHTTPErrorStatus = HTTPStatus.Unauthorized | HTTPStatus.TooManyRequests;
36
+ export type WithACErrors<TRouteResponse> = TRouteResponse extends Result.Either<infer InferredError, infer InferredResult> ? Result.Either<InferredError | StrictEndpointError<ExtractCode<InferredError> | NativeError, unknown, ExtractHTTPStatus<InferredError> | NativeHTTPErrorStatus>, InferredResult> : TRouteResponse | Result.Error<StrictEndpointError<NativeError, unknown, NativeHTTPErrorStatus>>;
37
+ export type EndpointFunction<TRouteMethod extends RequestMethod, TRouteResponse, TRoutePayload> = (TRoutePayload extends null ? <T = TRouteResponse>(payload?: any) => Promise<WithACErrors<T>> : TRoutePayload extends undefined ? <T = TRouteResponse>() => Promise<WithACErrors<T>> : <T = TRouteResponse>(payload: TRoutePayload) => Promise<WithACErrors<T>>) extends infer Function ? Record<TRouteMethod, Function> : never;
36
38
  export type MakeEndpoint<TRoute extends string, TRouteMethod extends RequestMethod, TRouteResponse = any, TRoutePayload = null> = TRoute extends `/${infer RouteTail}` ? MakeEndpoint<RouteTail, TRouteMethod, TRouteResponse, TRoutePayload> : TRoute extends `${infer Route}/${infer RouteTail}` ? Record<Route, MakeEndpoint<RouteTail, TRouteMethod, TRouteResponse, TRoutePayload>> : TRoute extends `(${string}` ? Record<string, EndpointFunction<TRouteMethod, TRouteResponse, TRoutePayload>> : Record<TRoute, EndpointFunction<TRouteMethod, TRouteResponse, TRoutePayload>>;
37
39
  type UnwrapResponse<TResponse> = TResponse extends readonly any[] ? TResponse : TResponse[];
38
40
  export type InferResponse<TResponse> = MapSchemaUnion<UnwrapResponse<TResponse>> extends infer InferredResponse ? InferredResponse | Promise<InferredResponse> : never;
@@ -10,6 +10,10 @@ export declare enum PropertyValidationErrorCode {
10
10
  ExtraneousElement = "EXTRANEOUS_ELEMENT",
11
11
  NumericConstraint = "NUMERIC_CONSTRAINT"
12
12
  }
13
+ export declare enum TraverseError {
14
+ InvalidDocumentId = "INVALID_DOCUMENT_ID",
15
+ InvalidTempfile = "INVALID_TEMPFILE"
16
+ }
13
17
  export type PropertyValidationError = {
14
18
  type: PropertyValidationErrorCode;
15
19
  index?: number;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PropertyValidationErrorCode = exports.ValidationErrorCode = void 0;
3
+ exports.TraverseError = exports.PropertyValidationErrorCode = exports.ValidationErrorCode = void 0;
4
4
  var ValidationErrorCode;
5
5
  (function (ValidationErrorCode) {
6
6
  ValidationErrorCode["InvalidProperties"] = "INVALID_PROPERTIES";
@@ -15,3 +15,8 @@ var PropertyValidationErrorCode;
15
15
  PropertyValidationErrorCode["ExtraneousElement"] = "EXTRANEOUS_ELEMENT";
16
16
  PropertyValidationErrorCode["NumericConstraint"] = "NUMERIC_CONSTRAINT";
17
17
  })(PropertyValidationErrorCode || (exports.PropertyValidationErrorCode = PropertyValidationErrorCode = {}));
18
+ var TraverseError;
19
+ (function (TraverseError) {
20
+ TraverseError["InvalidDocumentId"] = "INVALID_DOCUMENT_ID";
21
+ TraverseError["InvalidTempfile"] = "INVALID_TEMPFILE";
22
+ })(TraverseError || (exports.TraverseError = TraverseError = {}));
@@ -13,3 +13,8 @@ export var PropertyValidationErrorCode = /* @__PURE__ */ ((PropertyValidationErr
13
13
  PropertyValidationErrorCode2["NumericConstraint"] = "NUMERIC_CONSTRAINT";
14
14
  return PropertyValidationErrorCode2;
15
15
  })(PropertyValidationErrorCode || {});
16
+ export var TraverseError = /* @__PURE__ */ ((TraverseError2) => {
17
+ TraverseError2["InvalidDocumentId"] = "INVALID_DOCUMENT_ID";
18
+ TraverseError2["InvalidTempfile"] = "INVALID_TEMPFILE";
19
+ return TraverseError2;
20
+ })(TraverseError || {});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aeriajs/types",
3
- "version": "0.0.67",
3
+ "version": "0.0.69",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",