@aeriajs/types 0.0.39 → 0.0.40

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,4 +1,3 @@
1
- import type { Collection } from '.';
2
1
  export declare enum ACErrors {
3
2
  AssetNotFound = "ASSET_NOT_FOUND",
4
3
  AuthenticationError = "AUTHENTICATION_ERROR",
@@ -13,19 +12,3 @@ export declare enum ACErrors {
13
12
  ResourceNotFound = "RESOURCE_NOT_FOUND"
14
13
  }
15
14
  export declare const ACErrorMessages: Record<ACErrors, string>;
16
- export type Role<TCollection extends Collection = any, TAccessControl extends AccessControl<TCollection> = any> = {
17
- inherit?: readonly (keyof TAccessControl['roles'])[];
18
- grantEverything?: boolean;
19
- grant?: readonly (keyof TCollection['functions'])[];
20
- forbid?: readonly (keyof TCollection['functions'])[];
21
- };
22
- export type AccessControl<TCollection extends Collection = any, TAccessControl extends AccessControl<TCollection, TAccessControl> = any> = {
23
- roles?: Partial<Record<string, Role<TCollection, TAccessControl>>>;
24
- availableRoles?: keyof TAccessControl['roles'];
25
- parent?: TAccessControl['roles'];
26
- };
27
- export type NonCircularAccessControl<TCollection extends Collection = any, TAccessControl extends AccessControl<TCollection, TAccessControl> = any> = {
28
- roles?: Record<string, Role<TCollection, TAccessControl>>;
29
- availableRoles?: keyof TAccessControl['roles'];
30
- parent?: TAccessControl['roles'];
31
- };
package/dist/api.d.ts CHANGED
@@ -1,14 +1,13 @@
1
1
  import type { ObjectId } from 'mongodb';
2
- import type { Context, Contract, Description, CollectionSecurityPolicy, AccessControl, PackReferences, FunctionAttributes } from '.';
2
+ import type { Context, Contract, Description, CollectionSecurityPolicy, PackReferences, FunctionAttributes } from '.';
3
3
  export type AcceptedRole = UserRole | UserRole[] | null | unknown;
4
4
  export type Collection<TCollection extends Collection = any> = {
5
5
  description: Description;
6
6
  item?: any;
7
7
  security?: CollectionSecurityPolicy<TCollection>;
8
- accessControl?: AccessControl<TCollection>;
9
- functions?: Record<string, ((payload: any, context: Context, ...args: any[]) => any) & Partial<FunctionAttributes>>;
8
+ functions?: Record<string, ((payload: any, context: Context, ...args: any[]) => any) & FunctionAttributes>;
10
9
  functionContracts?: Record<string, Contract>;
11
- exposedFunctions?: string[];
10
+ exposedFunctions?: Record<string, readonly string[] | boolean>;
12
11
  };
13
12
  export type AssetType = keyof Collection;
14
13
  export type FunctionPath = `/${string}/${string}`;
package/dist/config.d.ts CHANGED
@@ -26,6 +26,7 @@ export type ApiConfig = {
26
26
  roles: string[];
27
27
  active: boolean;
28
28
  }>;
29
+ exposeFunctionsByDefault?: boolean;
29
30
  };
30
31
  tokenUserProperties?: string[];
31
32
  errorHandler?: <TError extends Error>(context: RouteContext, error: TError) => any | Promise<any>;
@@ -5,7 +5,7 @@ import type { OwnershipMode } from './security.js';
5
5
  export type CollectionPresets = 'crud' | 'duplicate' | 'remove' | 'removeAll' | 'owned' | 'timestamped' | 'view';
6
6
  export type Icon = PhosphorIcon['name'] | `${IconStyle}:${PhosphorIcon['name']}`;
7
7
  export type CollectionAction<TDescription extends Description> = {
8
- name: string;
8
+ label: string;
9
9
  icon?: Icon;
10
10
  ask?: boolean;
11
11
  selection?: boolean;
@@ -23,11 +23,13 @@ export type Filters<TDocument> = StrictFilter<any> & Partial<{
23
23
  _id: infer Id;
24
24
  } ? Id | string : Field : never) extends infer Field ? Field | StrictFilterOperators<Field> | null : never;
25
25
  }>;
26
- export type What<TDocument> = {
26
+ export type What<TDocument> = ({
27
27
  _id: ObjectId | string;
28
28
  } & Partial<Omit<PackReferences<TDocument>, '_id'>> & RemoveAny<StrictUpdateFilter<PackReferences<TDocument>>> | {
29
29
  _id?: null;
30
- } & Omit<PackReferences<TDocument>, '_id'>;
30
+ } & Omit<PackReferences<TDocument>, '_id'>) extends infer Document ? {
31
+ [P in keyof Document]: Document[P] | null;
32
+ } : never;
31
33
  export type Projection<TDocument> = keyof TDocument | '_id' extends infer DocumentProp ? TDocument extends string ? DocumentProp[] : string[] : never;
32
34
  export type QuerySort<TDocument> = Partial<Record<keyof WithId<TDocument>, 1 | -1>>;
33
35
  export type CollectionDocument<TDocument> = TDocument;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aeriajs/types",
3
- "version": "0.0.39",
3
+ "version": "0.0.40",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",