@aeriajs/types 0.0.69 → 0.0.71

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,26 +1,38 @@
1
1
  import type { WithId } from 'mongodb';
2
- import type { IconStyle, PhosphorIcon } from '@phosphor-icons/core';
2
+ import type { PhosphorIcon } from '@phosphor-icons/core';
3
3
  import type { Condition } from './condition.js';
4
4
  import type { JsonSchema, PropertiesWithId } from './property.js';
5
5
  import type { OwnershipMode } from './security.js';
6
6
  export type CollectionPresets = 'crud' | 'duplicate' | 'remove' | 'removeAll' | 'owned' | 'timestamped' | 'view';
7
- export type Icon = PhosphorIcon['name'] | `${IconStyle}:${PhosphorIcon['name']}`;
8
- export type CollectionAction<TDescription extends Description> = {
7
+ export type Icon = PhosphorIcon['name'];
8
+ export type CollectionActionRoute = {
9
+ route: {
10
+ name: string;
11
+ setItem?: boolean;
12
+ fetchItem?: boolean;
13
+ clearItem?: boolean;
14
+ params?: Record<string, any>;
15
+ query?: Record<string, any>;
16
+ };
17
+ };
18
+ export type CollectionActionFunction = {
19
+ function?: string;
20
+ selection?: boolean;
21
+ effect?: string;
22
+ };
23
+ export type CollectionActionEvent = {
24
+ event?: string;
25
+ };
26
+ export type CollectionActionBase<TDescription extends Description> = {
9
27
  label: string;
10
28
  icon?: Icon;
11
29
  ask?: boolean;
12
- selection?: boolean;
13
- effect?: string;
14
30
  button?: boolean;
15
31
  translate?: boolean;
16
- setItem?: boolean;
17
- fetchItem?: boolean;
18
- clearItem?: boolean;
19
- params?: Record<string, any>;
20
- query?: Record<string, any>;
21
32
  roles?: readonly string[];
22
33
  requires?: readonly PropertiesWithId<TDescription>[];
23
34
  };
35
+ export type CollectionAction<TDescription extends Description> = CollectionActionBase<TDescription> & (CollectionActionRoute | CollectionActionFunction | CollectionActionEvent);
24
36
  export type CollectionActions<TDescription extends Description> = Record<string, null | CollectionAction<TDescription>>;
25
37
  export type FormLayout<TDescription extends Description> = {
26
38
  fields?: Partial<Record<PropertiesWithId<TDescription>, FormLayoutField<TDescription>>>;
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 { Result } from './result.js';
3
+ import type { Result, ExtractError, ExtractResult } 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';
@@ -33,7 +33,7 @@ type ExtractCode<TRouteResponse> = TRouteResponse extends EndpointError<infer PC
33
33
  type ExtractHTTPStatus<TRouteResponse> = TRouteResponse extends EndpointError<any, unknown, infer PHTTPStatus> ? PHTTPStatus : never;
34
34
  export type NativeError = ACError.AuthenticationError | ACError.AuthorizationError | RateLimitingError.LimitReached | RateLimitingError.Unauthenticated;
35
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>>;
36
+ export type WithACErrors<TRouteResponse> = TRouteResponse extends Result.Either<infer InferredError, unknown> ? Result.Either<ExtractError<TRouteResponse> | StrictEndpointError<ExtractCode<InferredError> | NativeError, unknown, ExtractHTTPStatus<InferredError> | NativeHTTPErrorStatus>, ExtractResult<TRouteResponse>> : TRouteResponse | Result.Error<StrictEndpointError<NativeError, unknown, NativeHTTPErrorStatus>>;
37
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;
38
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>>;
39
39
  type UnwrapResponse<TResponse> = TResponse extends readonly any[] ? TResponse : TResponse[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aeriajs/types",
3
- "version": "0.0.69",
3
+ "version": "0.0.71",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",