@opra/common 0.23.2 → 0.24.1

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.
Files changed (102) hide show
  1. package/browser.js +319 -206
  2. package/cjs/document/constants.js +4 -2
  3. package/cjs/document/data-type/api-field.js +3 -3
  4. package/cjs/document/data-type/complex-type.js +2 -2
  5. package/cjs/document/data-type/enum-type.js +5 -5
  6. package/cjs/document/data-type/mapped-type.js +9 -9
  7. package/cjs/document/data-type/simple-type.js +2 -2
  8. package/cjs/document/data-type/union-type.js +2 -2
  9. package/cjs/document/factory/create-document.js +3 -3
  10. package/cjs/document/factory/factory.js +6 -6
  11. package/cjs/document/factory/import-resource-class.js +4 -4
  12. package/cjs/document/factory/import-type-class.js +4 -4
  13. package/cjs/document/factory/process-resources.js +12 -12
  14. package/cjs/document/index.js +3 -2
  15. package/cjs/document/resource/action.js +12 -0
  16. package/cjs/document/resource/collection-class.js +174 -0
  17. package/cjs/document/resource/collection-decorator.js +60 -0
  18. package/cjs/document/resource/collection.js +7 -212
  19. package/cjs/document/resource/resource-decorator.js +16 -0
  20. package/cjs/document/resource/resource.js +18 -2
  21. package/cjs/document/resource/singleton-class.js +53 -0
  22. package/cjs/document/resource/singleton-decorator.js +53 -0
  23. package/cjs/document/resource/singleton.js +7 -85
  24. package/cjs/document/resource/storage-class.js +24 -0
  25. package/cjs/document/resource/storage-decorator.js +51 -0
  26. package/cjs/document/resource/storage.js +7 -53
  27. package/cjs/document/utils/generate-codec.js +5 -5
  28. package/cjs/exception/resource-errors/resource-not-found.error.js +1 -1
  29. package/cjs/helpers/mixin-utils.js +2 -2
  30. package/cjs/schema/opra-schema.ns.js +0 -1
  31. package/cjs/schema/type-guards.js +5 -4
  32. package/esm/document/constants.js +3 -1
  33. package/esm/document/data-type/api-field.js +4 -4
  34. package/esm/document/data-type/complex-type.js +3 -3
  35. package/esm/document/data-type/enum-type.js +6 -6
  36. package/esm/document/data-type/mapped-type.js +10 -10
  37. package/esm/document/data-type/simple-type.js +3 -3
  38. package/esm/document/data-type/union-type.js +3 -3
  39. package/esm/document/factory/create-document.js +3 -3
  40. package/esm/document/factory/factory.js +7 -7
  41. package/esm/document/factory/import-resource-class.js +5 -5
  42. package/esm/document/factory/import-type-class.js +5 -5
  43. package/esm/document/factory/process-resources.js +9 -9
  44. package/esm/document/index.js +3 -2
  45. package/esm/document/resource/action.js +8 -0
  46. package/esm/document/resource/collection-class.js +169 -0
  47. package/esm/document/resource/collection-decorator.js +55 -0
  48. package/esm/document/resource/collection.js +6 -211
  49. package/esm/document/resource/resource-decorator.js +13 -0
  50. package/esm/document/resource/resource.js +18 -2
  51. package/esm/document/resource/singleton-class.js +49 -0
  52. package/esm/document/resource/singleton-decorator.js +48 -0
  53. package/esm/document/resource/singleton.js +6 -84
  54. package/esm/document/resource/storage-class.js +20 -0
  55. package/esm/document/resource/storage-decorator.js +46 -0
  56. package/esm/document/resource/storage.js +6 -52
  57. package/esm/document/utils/generate-codec.js +3 -3
  58. package/esm/exception/resource-errors/resource-not-found.error.js +1 -1
  59. package/esm/helpers/mixin-utils.js +2 -2
  60. package/esm/schema/opra-schema.ns.js +0 -1
  61. package/esm/schema/type-guards.js +3 -2
  62. package/package.json +1 -1
  63. package/types/document/api-document.d.ts +1 -1
  64. package/types/document/constants.d.ts +3 -1
  65. package/types/document/data-type/mapped-type.d.ts +2 -2
  66. package/types/document/factory/factory.d.ts +7 -7
  67. package/types/document/factory/process-resources.d.ts +2 -2
  68. package/types/document/index.d.ts +3 -2
  69. package/types/document/interfaces/{collection-resource.interface.d.ts → collection.interface.d.ts} +1 -1
  70. package/types/document/interfaces/{singleton-resource.interface.d.ts → singleton.interface.d.ts} +1 -1
  71. package/types/document/interfaces/{storage-resource.interface.d.ts → storage.interface.d.ts} +1 -1
  72. package/types/document/resource/action.d.ts +11 -0
  73. package/types/document/resource/collection-class.d.ts +24 -0
  74. package/types/document/resource/collection-decorator.d.ts +30 -0
  75. package/types/document/resource/collection.d.ts +12 -39
  76. package/types/document/resource/resource-decorator.d.ts +5 -0
  77. package/types/document/resource/resource.d.ts +7 -0
  78. package/types/document/resource/singleton-class.d.ts +20 -0
  79. package/types/document/resource/singleton-decorator.d.ts +25 -0
  80. package/types/document/resource/singleton.d.ts +10 -29
  81. package/types/document/resource/storage-class.d.ts +12 -0
  82. package/types/document/resource/storage-decorator.d.ts +22 -0
  83. package/types/document/resource/storage.d.ts +9 -20
  84. package/types/document/utils/generate-codec.d.ts +1 -1
  85. package/types/helpers/mixin-utils.d.ts +1 -1
  86. package/types/schema/document.interface.d.ts +1 -1
  87. package/types/schema/opra-schema.ns.d.ts +0 -1
  88. package/types/schema/resource/collection.interface.d.ts +18 -19
  89. package/types/schema/resource/container.interface.d.ts +4 -2
  90. package/types/schema/resource/resource.interface.d.ts +14 -0
  91. package/types/schema/resource/singleton.interface.d.ts +8 -8
  92. package/types/schema/resource/storage.interface.d.ts +7 -8
  93. package/types/schema/type-guards.d.ts +1 -1
  94. package/cjs/schema/resource/operation.interface.js +0 -2
  95. package/esm/schema/resource/operation.interface.js +0 -1
  96. package/types/schema/resource/operation.interface.d.ts +0 -3
  97. /package/cjs/document/interfaces/{collection-resource.interface.js → collection.interface.js} +0 -0
  98. /package/cjs/document/interfaces/{singleton-resource.interface.js → singleton.interface.js} +0 -0
  99. /package/cjs/document/interfaces/{storage-resource.interface.js → storage.interface.js} +0 -0
  100. /package/esm/document/interfaces/{collection-resource.interface.js → collection.interface.js} +0 -0
  101. /package/esm/document/interfaces/{singleton-resource.interface.js → singleton.interface.js} +0 -0
  102. /package/esm/document/interfaces/{storage-resource.interface.js → storage.interface.js} +0 -0
@@ -0,0 +1,20 @@
1
+ import { Type } from 'ts-gems';
2
+ import * as vg from 'valgen';
3
+ import { OpraSchema } from '../../schema/index.js';
4
+ import type { ApiDocument } from '../api-document.js';
5
+ import { ComplexType } from '../data-type/complex-type.js';
6
+ import { Resource } from './resource.js';
7
+ import type { Singleton } from './singleton.js';
8
+ export declare class SingletonClass extends Resource {
9
+ private _decoders;
10
+ private _encoders;
11
+ readonly type: ComplexType;
12
+ readonly kind = "Singleton";
13
+ readonly operations: OpraSchema.Singleton.Operations;
14
+ readonly controller?: object | Type;
15
+ constructor(document: ApiDocument, init: Singleton.InitArguments);
16
+ exportSchema(): OpraSchema.Singleton;
17
+ normalizeFieldPath(path: string | string[]): string[] | undefined;
18
+ getDecoder(endpoint: keyof OpraSchema.Singleton.Operations): vg.Validator<any, any>;
19
+ getEncoder(endpoint: keyof OpraSchema.Singleton.Operations): vg.Validator<any, any>;
20
+ }
@@ -0,0 +1,25 @@
1
+ import { StrictOmit } from 'ts-gems';
2
+ import { TypeThunkAsync } from '../../types.js';
3
+ import { Resource } from './resource.js';
4
+ import { ResourceDecorator } from './resource-decorator.js';
5
+ import type { Singleton } from './singleton.js';
6
+ type ErrorMessage<T, Error> = [T] extends [never] ? Error : T;
7
+ declare const operationProperties: readonly ["create", "delete", "get", "update"];
8
+ type OperationProperties = typeof operationProperties[number];
9
+ export interface SingletonDecorator extends StrictOmit<ResourceDecorator, 'Action'> {
10
+ (type: TypeThunkAsync | string, options?: Singleton.DecoratorOptions): ClassDecorator;
11
+ Action: (options?: Resource.ActionOptions) => (<T, K extends keyof T>(target: T, propertyKey: ErrorMessage<Exclude<K, OperationProperties>, `'${string & K}' property is reserved for operation endpoints and can not be used for actions`>) => void);
12
+ Create: (options?: Singleton.CreateEndpointOptions) => ((target: Object, propertyKey: 'create') => void);
13
+ Delete: (options?: Singleton.DeleteEndpointOptions) => ((target: Object, propertyKey: 'delete') => void);
14
+ Get: (options?: Singleton.GetEndpointOptions) => ((target: Object, propertyKey: 'get') => void);
15
+ Update: (options?: Singleton.UpdateEndpointOptions) => ((target: Object, propertyKey: 'update') => void);
16
+ }
17
+ export declare function SingletonDecorator(type: TypeThunkAsync | string, options?: Singleton.DecoratorOptions): ClassDecorator;
18
+ export declare namespace SingletonDecorator {
19
+ var Create: (options?: unknown) => (target: Object, propertyKey: string | symbol) => void;
20
+ var Get: (options?: unknown) => (target: Object, propertyKey: string | symbol) => void;
21
+ var Delete: (options?: unknown) => (target: Object, propertyKey: string | symbol) => void;
22
+ var Update: (options?: unknown) => (target: Object, propertyKey: string | symbol) => void;
23
+ var Action: (options: any) => PropertyDecorator;
24
+ }
25
+ export {};
@@ -1,18 +1,18 @@
1
- import { StrictOmit, Type } from 'ts-gems';
2
- import * as vg from 'valgen';
1
+ import { StrictOmit } from 'ts-gems';
3
2
  import { OpraSchema } from '../../schema/index.js';
4
3
  import type { TypeThunkAsync } from '../../types.js';
5
4
  import type { ApiDocument } from '../api-document.js';
6
5
  import { ComplexType } from '../data-type/complex-type.js';
7
- import { Resource } from './resource.js';
6
+ import type { Resource } from './resource.js';
7
+ import { SingletonClass } from './singleton-class.js';
8
+ import { SingletonDecorator } from './singleton-decorator.js';
8
9
  export declare namespace Singleton {
9
10
  interface InitArguments extends Resource.InitArguments, StrictOmit<OpraSchema.Singleton, 'kind' | 'type'> {
10
11
  type: ComplexType;
11
12
  }
12
13
  interface DecoratorOptions extends Resource.DecoratorOptions {
13
14
  }
14
- interface Metadata extends StrictOmit<OpraSchema.Singleton, 'type'> {
15
- name: string;
15
+ interface Metadata extends StrictOmit<Resource.Metadata, 'kind'>, StrictOmit<OpraSchema.Singleton, 'type'> {
16
16
  type: TypeThunkAsync | string;
17
17
  }
18
18
  namespace Create {
@@ -23,34 +23,15 @@ export declare namespace Singleton {
23
23
  }
24
24
  namespace Update {
25
25
  }
26
- type CreateOperationOptions = OpraSchema.Singleton.CreateOperation;
27
- type DeleteOperationOptions = OpraSchema.Singleton.DeleteOperation;
28
- type GetOperationOptions = OpraSchema.Singleton.GetOperation;
29
- type UpdateOperationOptions = OpraSchema.Singleton.UpdateOperation;
26
+ type CreateEndpointOptions = OpraSchema.Singleton.CreateEndpoint;
27
+ type DeleteEndpointOptions = OpraSchema.Singleton.DeleteEndpoint;
28
+ type GetEndpointOptions = OpraSchema.Singleton.GetEndpoint;
29
+ type UpdateEndpointOptions = OpraSchema.Singleton.UpdateEndpoint;
30
30
  }
31
- declare class SingletonClass extends Resource {
32
- private _decoders;
33
- private _encoders;
34
- readonly type: ComplexType;
35
- readonly kind = "Singleton";
36
- readonly operations: OpraSchema.Singleton.Operations;
37
- readonly controller?: object | Type;
38
- constructor(document: ApiDocument, init: Singleton.InitArguments);
39
- exportSchema(): OpraSchema.Singleton;
40
- normalizeFieldPath(this: Singleton, path: string | string[]): string[] | undefined;
41
- getDecoder(operation: keyof OpraSchema.Singleton.Operations): vg.Validator<any, any>;
42
- getEncoder(operation: keyof OpraSchema.Singleton.Operations): vg.Validator<any, any>;
43
- }
44
- export interface SingletonConstructor {
31
+ export interface SingletonConstructor extends SingletonDecorator {
45
32
  prototype: Singleton;
46
33
  new (document: ApiDocument, init: Singleton.InitArguments): Singleton;
47
- (type: TypeThunkAsync | string, options?: Singleton.DecoratorOptions): ClassDecorator;
48
- Create: (options?: Singleton.CreateOperationOptions) => ((target: Object, propertyKey: 'create') => void);
49
- Delete: (options?: Singleton.DeleteOperationOptions) => ((target: Object, propertyKey: 'delete') => void);
50
- Get: (options?: Singleton.GetOperationOptions) => ((target: Object, propertyKey: 'get') => void);
51
- Update: (options?: Singleton.UpdateOperationOptions) => ((target: Object, propertyKey: 'update') => void);
52
34
  }
53
35
  export interface Singleton extends SingletonClass {
54
36
  }
55
37
  export declare const Singleton: SingletonConstructor;
56
- export {};
@@ -0,0 +1,12 @@
1
+ import { Type } from 'ts-gems';
2
+ import { OpraSchema } from '../../schema/index.js';
3
+ import type { ApiDocument } from '../api-document.js';
4
+ import { Resource } from './resource.js';
5
+ import type { Storage } from './storage.js';
6
+ export declare class StorageClass extends Resource {
7
+ readonly kind = "Storage";
8
+ readonly operations: OpraSchema.Storage.Operations;
9
+ readonly controller?: object | Type;
10
+ constructor(document: ApiDocument, init: Storage.InitArguments);
11
+ exportSchema(): OpraSchema.Storage;
12
+ }
@@ -0,0 +1,22 @@
1
+ import { StrictOmit } from 'ts-gems';
2
+ import { Resource } from './resource.js';
3
+ import { ResourceDecorator } from './resource-decorator.js';
4
+ import type { Storage } from './storage.js';
5
+ type ErrorMessage<T, Error> = [T] extends [never] ? Error : T;
6
+ declare const operationProperties: readonly ["delete", "get", "post"];
7
+ type OperationProperties = typeof operationProperties[number];
8
+ export interface StorageDecorator extends StrictOmit<ResourceDecorator, 'Action'> {
9
+ (options?: Storage.DecoratorOptions): ClassDecorator;
10
+ Action: (options?: Resource.ActionOptions) => (<T, K extends keyof T>(target: T, propertyKey: ErrorMessage<Exclude<K, OperationProperties>, `'${string & K}' property is reserved for operation endpoints and can not be used for actions`>) => void);
11
+ Delete: (options?: Storage.DeleteEndpointOptions) => ((target: Object, propertyKey: 'delete') => void);
12
+ Get: (options?: Storage.GetEndpointOptions) => ((target: Object, propertyKey: 'get') => void);
13
+ Post: (options?: Storage.PostEndpointOptions) => ((target: Object, propertyKey: 'post') => void);
14
+ }
15
+ export declare function StorageDecorator(options?: Storage.DecoratorOptions): ClassDecorator;
16
+ export declare namespace StorageDecorator {
17
+ var Delete: (options?: unknown) => (target: Object, propertyKey: string | symbol) => void;
18
+ var Get: (options?: unknown) => (target: Object, propertyKey: string | symbol) => void;
19
+ var Post: (options?: unknown) => (target: Object, propertyKey: string | symbol) => void;
20
+ var Action: (options: any) => PropertyDecorator;
21
+ }
22
+ export {};
@@ -1,14 +1,15 @@
1
- import { StrictOmit, Type } from 'ts-gems';
1
+ import { StrictOmit } from 'ts-gems';
2
2
  import { OpraSchema } from '../../schema/index.js';
3
3
  import type { ApiDocument } from '../api-document.js';
4
- import { Resource } from './resource.js';
4
+ import type { Resource } from './resource.js';
5
+ import { StorageClass } from './storage-class.js';
6
+ import { StorageDecorator } from './storage-decorator.js';
5
7
  export declare namespace Storage {
6
8
  interface InitArguments extends Resource.InitArguments, StrictOmit<OpraSchema.Storage, 'kind'> {
7
9
  }
8
10
  interface DecoratorOptions extends Resource.DecoratorOptions {
9
11
  }
10
- interface Metadata extends OpraSchema.Storage {
11
- name: string;
12
+ interface Metadata extends StrictOmit<Resource.Metadata, 'kind'>, OpraSchema.Storage {
12
13
  }
13
14
  namespace Delete {
14
15
  }
@@ -16,26 +17,14 @@ export declare namespace Storage {
16
17
  }
17
18
  namespace Post {
18
19
  }
19
- type DeleteOperationOptions = OpraSchema.Storage.DeleteOperation;
20
- type GetOperationOptions = OpraSchema.Storage.GetOperation;
21
- type PostOperationOptions = OpraSchema.Storage.PostOperation;
20
+ type DeleteEndpointOptions = OpraSchema.Storage.DeleteEndpoint;
21
+ type GetEndpointOptions = OpraSchema.Storage.GetEndpoint;
22
+ type PostEndpointOptions = OpraSchema.Storage.PostEndpoint;
22
23
  }
23
- declare class StorageClass extends Resource {
24
- readonly kind = "Storage";
25
- readonly operations: OpraSchema.Storage.Operations;
26
- readonly controller?: object | Type;
27
- constructor(document: ApiDocument, init: Storage.InitArguments);
28
- exportSchema(): OpraSchema.Storage;
29
- }
30
- export interface StorageConstructor {
24
+ export interface StorageConstructor extends StorageDecorator {
31
25
  prototype: Storage;
32
26
  new (document: ApiDocument, init: Storage.InitArguments): Storage;
33
- (options?: Storage.DecoratorOptions): ClassDecorator;
34
- Delete: (options?: Storage.DeleteOperationOptions) => ((target: Object, propertyKey: 'delete') => void);
35
- Get: (options?: Storage.GetOperationOptions) => ((target: Object, propertyKey: 'get') => void);
36
- Post: (options?: Storage.PostOperationOptions) => ((target: Object, propertyKey: 'post') => void);
37
27
  }
38
28
  export interface Storage extends StorageClass {
39
29
  }
40
30
  export declare const Storage: StorageConstructor;
41
- export {};
@@ -7,4 +7,4 @@ export interface GenerateDecoderOptions {
7
7
  partial?: boolean;
8
8
  }
9
9
  export declare function generateCodec(type: ComplexType, codec: 'decode' | 'encode', options: GenerateDecoderOptions): vg.Validator<any, any>;
10
- export declare function _generateDecoder(type: ComplexType | MappedType | UnionType, codec: 'decode' | 'encode', options: GenerateDecoderOptions): vg.Validator<any, any>;
10
+ export declare function _generateCodec(type: ComplexType | MappedType | UnionType, codec: 'decode' | 'encode', options: GenerateDecoderOptions): vg.Validator<any, any>;
@@ -1,3 +1,3 @@
1
1
  import { Type } from 'ts-gems';
2
2
  export declare function mergePrototype(targetProto: any, baseProto: any, filter?: (k: string) => boolean): void;
3
- export declare function inheritPropertyInitializers(target: Record<string, any>, sourceClass: Type, isPropertyInherited?: (key: string) => boolean): void;
3
+ export declare function inheritPropertyInitializers(target: Record<string, any>, clazz: Type, isPropertyInherited?: (key: string) => boolean): void;
@@ -1,6 +1,6 @@
1
1
  import type { SpecVersion } from './constants.js';
2
2
  import type { DataType } from './data-type/data-type.interface.js';
3
- import type { Resource } from './resource/resource.interface.js';
3
+ import type { Resource } from './resource/resource.interface';
4
4
  export interface ApiDocument {
5
5
  version: SpecVersion;
6
6
  url?: string;
@@ -7,7 +7,6 @@ export * from './data-type/mapped-type.interface.js';
7
7
  export * from './data-type/union-type.interface.js';
8
8
  export * from './resource/collection.interface.js';
9
9
  export * from './resource/container.interface.js';
10
- export * from './resource/operation.interface.js';
11
10
  export * from './resource/resource.interface.js';
12
11
  export * from './resource/singleton.interface.js';
13
12
  export * from './resource/storage.interface.js';
@@ -1,8 +1,7 @@
1
1
  import type { OpraFilter } from '../../filter/index.js';
2
2
  import type { DataType } from '../data-type/data-type.interface.js';
3
3
  import type { Field } from '../data-type/field.interface';
4
- import type { Operation } from './operation.interface';
5
- import type { ResourceBase } from './resource.interface.js';
4
+ import type { Endpoint, ResourceBase } from './resource.interface.js';
6
5
  export interface Collection extends ResourceBase {
7
6
  kind: Collection.Kind;
8
7
  type: DataType.Name;
@@ -12,40 +11,40 @@ export interface Collection extends ResourceBase {
12
11
  export declare namespace Collection {
13
12
  const Kind = "Collection";
14
13
  type Kind = 'Collection';
15
- type CreateOperation = Operation & _OperationInput & _OperationResponse;
16
- type DeleteOperation = Operation;
17
- type DeleteManyOperation = Operation & _OperationFilter;
18
- type GetOperation = Operation & _OperationResponse;
19
- type FindManyOperation = Operation & _OperationFilter & _OperationResponse & {
14
+ type CreateEndpoint = Endpoint & _EndpointInput & _EndpointResponse;
15
+ type DeleteEndpoint = Endpoint;
16
+ type DeleteManyEndpoint = Endpoint & _EndpointFilter;
17
+ type GetEndpoint = Endpoint & _EndpointResponse;
18
+ type FindManyEndpoint = Endpoint & _EndpointFilter & _EndpointResponse & {
20
19
  sortFields?: string[];
21
20
  defaultSort?: string[];
22
21
  };
23
- type UpdateOperation = Operation & _OperationInput & _OperationResponse;
24
- type UpdateManyOperation = Operation & _OperationInput & _OperationFilter;
22
+ type UpdateEndpoint = Endpoint & _EndpointInput & _EndpointResponse;
23
+ type UpdateManyEndpoint = Endpoint & _EndpointInput & _EndpointFilter;
25
24
  interface Operations {
26
- create?: CreateOperation;
27
- delete?: DeleteOperation;
28
- get?: GetOperation;
29
- update?: UpdateOperation;
30
- deleteMany?: DeleteManyOperation;
31
- findMany?: FindManyOperation;
32
- updateMany?: UpdateManyOperation;
25
+ create?: CreateEndpoint;
26
+ delete?: DeleteEndpoint;
27
+ get?: GetEndpoint;
28
+ update?: UpdateEndpoint;
29
+ deleteMany?: DeleteManyEndpoint;
30
+ findMany?: FindManyEndpoint;
31
+ updateMany?: UpdateManyEndpoint;
33
32
  }
34
33
  }
35
- interface _OperationFilter {
34
+ interface _EndpointFilter {
36
35
  filters?: {
37
36
  field: Field.QualifiedName;
38
37
  operators?: OpraFilter.ComparisonOperator[];
39
38
  }[];
40
39
  }
41
- interface _OperationInput {
40
+ interface _EndpointInput {
42
41
  input?: {
43
42
  maxContentSize?: number | string;
44
43
  pick?: Field.QualifiedName[];
45
44
  omit?: Field.QualifiedName[];
46
45
  };
47
46
  }
48
- interface _OperationResponse {
47
+ interface _EndpointResponse {
49
48
  response?: {
50
49
  pick?: Field.QualifiedName[];
51
50
  omit?: Field.QualifiedName[];
@@ -1,7 +1,9 @@
1
- import type { Resource, ResourceBase } from './resource.interface.js';
1
+ import type { DataType } from '../data-type/data-type.interface.js';
2
+ import type { Resource, ResourceBase } from './resource.interface';
2
3
  export interface Container extends ResourceBase {
3
4
  kind: Container.Kind;
4
- resources: Resource[];
5
+ types?: Record<DataType.Name, DataType>;
6
+ resources?: Record<Resource.Name, Resource>;
5
7
  }
6
8
  export declare namespace Container {
7
9
  const Kind = "Container";
@@ -1,3 +1,4 @@
1
+ import type { Field } from '../data-type/field.interface.js';
1
2
  import type { Collection } from './collection.interface.js';
2
3
  import type { Container } from './container.interface.js';
3
4
  import type { Singleton } from './singleton.interface.js';
@@ -10,4 +11,17 @@ export declare namespace Resource {
10
11
  export interface ResourceBase {
11
12
  kind: string;
12
13
  description?: string;
14
+ actions?: Record<Action.Name, Action>;
15
+ }
16
+ export interface Endpoint {
17
+ description?: string;
18
+ }
19
+ export interface Action {
20
+ parameters?: Record<Action.ParameterName, Action.Parameter>;
21
+ }
22
+ export declare namespace Action {
23
+ type Name = string;
24
+ type ParameterName = string;
25
+ interface Parameter extends Pick<Field, 'type' | 'description' | 'isArray' | 'default' | 'required' | 'deprecated' | 'examples'> {
26
+ }
13
27
  }
@@ -9,14 +9,14 @@ export interface Singleton extends ResourceBase {
9
9
  export declare namespace Singleton {
10
10
  const Kind = "Singleton";
11
11
  type Kind = 'Singleton';
12
- type CreateOperation = Collection.CreateOperation;
13
- type DeleteOperation = Collection.DeleteOperation;
14
- type GetOperation = Collection.GetOperation;
15
- type UpdateOperation = Collection.UpdateOperation;
12
+ type CreateEndpoint = Collection.CreateEndpoint;
13
+ type DeleteEndpoint = Collection.DeleteEndpoint;
14
+ type GetEndpoint = Collection.GetEndpoint;
15
+ type UpdateEndpoint = Collection.UpdateEndpoint;
16
16
  interface Operations {
17
- create?: CreateOperation;
18
- delete?: DeleteOperation;
19
- get?: GetOperation;
20
- update?: UpdateOperation;
17
+ create?: CreateEndpoint;
18
+ delete?: DeleteEndpoint;
19
+ get?: GetEndpoint;
20
+ update?: UpdateEndpoint;
21
21
  }
22
22
  }
@@ -1,5 +1,4 @@
1
- import type { Operation } from './operation.interface';
2
- import type { ResourceBase } from './resource.interface.js';
1
+ import type { Endpoint, ResourceBase } from './resource.interface.js';
3
2
  export interface Storage extends ResourceBase {
4
3
  kind: Storage.Kind;
5
4
  operations: Storage.Operations;
@@ -7,9 +6,9 @@ export interface Storage extends ResourceBase {
7
6
  export declare namespace Storage {
8
7
  const Kind = "Storage";
9
8
  type Kind = 'Storage';
10
- type DeleteOperation = Operation;
11
- type GetOperation = Operation;
12
- type PostOperation = Operation & {
9
+ type DeleteEndpoint = Endpoint;
10
+ type GetEndpoint = Endpoint;
11
+ type PostEndpoint = Endpoint & {
13
12
  /**
14
13
  * the minium size of uploaded file
15
14
  *
@@ -48,8 +47,8 @@ export declare namespace Storage {
48
47
  maxFieldsSize?: number | undefined;
49
48
  };
50
49
  interface Operations {
51
- delete?: DeleteOperation;
52
- get?: GetOperation;
53
- post?: PostOperation;
50
+ delete?: DeleteEndpoint;
51
+ get?: GetEndpoint;
52
+ post?: PostEndpoint;
54
53
  }
55
54
  }
@@ -14,7 +14,7 @@ export declare function isSimpleType(obj: any): obj is SimpleType;
14
14
  export declare function isUnionType(obj: any): obj is UnionType;
15
15
  export declare function isMappedType(obj: any): obj is MappedType;
16
16
  export declare function isEnumType(obj: any): obj is EnumType;
17
- export declare function isResource(obj: any): obj is Resource;
17
+ export declare function isSource(obj: any): obj is Resource;
18
18
  export declare function isCollection(obj: any): obj is Collection;
19
19
  export declare function isSingleton(obj: any): obj is Singleton;
20
20
  export declare function isStorage(obj: any): obj is Singleton;
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1 +0,0 @@
1
- export {};
@@ -1,3 +0,0 @@
1
- export interface Operation {
2
- description?: string;
3
- }