@opra/common 0.24.2 → 0.25.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 (100) hide show
  1. package/browser.js +368 -314
  2. package/cjs/document/data-type/complex-type-class.js +151 -0
  3. package/cjs/document/data-type/complex-type.js +13 -168
  4. package/cjs/document/data-type/data-type.js +4 -0
  5. package/cjs/document/data-type/enum-type-class.js +32 -0
  6. package/cjs/document/data-type/enum-type.js +24 -49
  7. package/cjs/document/data-type/field-class.js +34 -0
  8. package/cjs/document/data-type/field-decorator.js +45 -0
  9. package/cjs/document/data-type/field.js +25 -0
  10. package/cjs/document/data-type/mapped-type-class.js +48 -0
  11. package/cjs/document/data-type/mapped-type.js +18 -58
  12. package/cjs/document/data-type/simple-type-class.js +29 -0
  13. package/cjs/document/data-type/simple-type.js +12 -43
  14. package/cjs/document/data-type/union-type-class.js +36 -0
  15. package/cjs/document/data-type/union-type.js +3 -31
  16. package/cjs/document/{resource → decorators}/collection-decorator.js +2 -24
  17. package/cjs/document/decorators/complex-type.decorator.js +23 -0
  18. package/cjs/document/decorators/resource.decorator.js +38 -0
  19. package/cjs/document/decorators/simple-type.decorator.js +20 -0
  20. package/cjs/document/{resource/singleton-decorator.js → decorators/singleton.decorator.js} +2 -19
  21. package/cjs/document/{resource/storage-decorator.js → decorators/storage.decorator.js} +2 -18
  22. package/cjs/document/index.js +1 -1
  23. package/cjs/document/resource/collection.js +4 -3
  24. package/cjs/document/resource/endpoint.js +44 -0
  25. package/cjs/document/resource/resource.js +9 -10
  26. package/cjs/document/resource/singleton.js +5 -1
  27. package/cjs/document/resource/storage.js +5 -1
  28. package/cjs/schema/opra-schema.ns.js +1 -0
  29. package/cjs/schema/resource/endpoint.interface.js +2 -0
  30. package/esm/document/data-type/complex-type-class.js +147 -0
  31. package/esm/document/data-type/complex-type.js +13 -168
  32. package/esm/document/data-type/data-type.js +4 -0
  33. package/esm/document/data-type/enum-type-class.js +27 -0
  34. package/esm/document/data-type/enum-type.js +22 -47
  35. package/esm/document/data-type/field-class.js +30 -0
  36. package/esm/document/data-type/field-decorator.js +41 -0
  37. package/esm/document/data-type/field.js +21 -0
  38. package/esm/document/data-type/mapped-type-class.js +43 -0
  39. package/esm/document/data-type/mapped-type.js +13 -53
  40. package/esm/document/data-type/simple-type-class.js +24 -0
  41. package/esm/document/data-type/simple-type.js +12 -43
  42. package/esm/document/data-type/union-type-class.js +32 -0
  43. package/esm/document/data-type/union-type.js +2 -30
  44. package/esm/document/{resource → decorators}/collection-decorator.js +2 -23
  45. package/esm/document/decorators/complex-type.decorator.js +18 -0
  46. package/esm/document/decorators/resource.decorator.js +33 -0
  47. package/esm/document/decorators/simple-type.decorator.js +15 -0
  48. package/esm/document/{resource/singleton-decorator.js → decorators/singleton.decorator.js} +2 -18
  49. package/esm/document/{resource/storage-decorator.js → decorators/storage.decorator.js} +2 -17
  50. package/esm/document/index.js +1 -1
  51. package/esm/document/resource/collection.js +4 -3
  52. package/esm/document/resource/endpoint.js +40 -0
  53. package/esm/document/resource/resource.js +9 -10
  54. package/esm/document/resource/singleton.js +5 -1
  55. package/esm/document/resource/storage.js +5 -1
  56. package/esm/schema/opra-schema.ns.js +1 -0
  57. package/esm/schema/resource/endpoint.interface.js +1 -0
  58. package/package.json +3 -11
  59. package/types/document/data-type/complex-type-class.d.ts +33 -0
  60. package/types/document/data-type/complex-type.d.ts +18 -43
  61. package/types/document/data-type/data-type.d.ts +17 -13
  62. package/types/document/data-type/enum-type-class.d.ts +17 -0
  63. package/types/document/data-type/enum-type.d.ts +11 -24
  64. package/types/document/data-type/field-class.d.ts +20 -0
  65. package/types/document/data-type/field-decorator.d.ts +5 -0
  66. package/types/document/data-type/{api-field.d.ts → field.d.ts} +20 -20
  67. package/types/document/data-type/mapped-type-class.d.ts +21 -0
  68. package/types/document/data-type/mapped-type.d.ts +24 -39
  69. package/types/document/data-type/simple-type-class.d.ts +17 -0
  70. package/types/document/data-type/simple-type.d.ts +21 -31
  71. package/types/document/data-type/union-type-class.d.ts +18 -0
  72. package/types/document/data-type/union-type.d.ts +15 -27
  73. package/types/document/{resource → decorators}/collection-decorator.d.ts +14 -14
  74. package/types/document/decorators/complex-type.decorator.d.ts +2 -0
  75. package/types/document/decorators/resource.decorator.d.ts +9 -0
  76. package/types/document/decorators/simple-type.decorator.d.ts +2 -0
  77. package/types/document/{resource/singleton-decorator.d.ts → decorators/singleton.decorator.d.ts} +11 -11
  78. package/types/document/{resource/storage-decorator.d.ts → decorators/storage.decorator.d.ts} +10 -10
  79. package/types/document/factory/import-type-class.d.ts +1 -1
  80. package/types/document/index.d.ts +1 -1
  81. package/types/document/resource/collection.d.ts +16 -12
  82. package/types/document/resource/endpoint.d.ts +29 -0
  83. package/types/document/resource/resource.d.ts +15 -14
  84. package/types/document/resource/singleton.d.ts +15 -8
  85. package/types/document/resource/storage-class.d.ts +0 -2
  86. package/types/document/resource/storage.d.ts +12 -8
  87. package/types/filter/ast/terms/qualified-identifier.d.ts +1 -1
  88. package/types/schema/opra-schema.ns.d.ts +1 -0
  89. package/types/schema/resource/collection.interface.d.ts +2 -1
  90. package/types/schema/resource/endpoint.interface.d.ts +12 -0
  91. package/types/schema/resource/resource.interface.d.ts +3 -15
  92. package/types/schema/resource/storage.interface.d.ts +2 -1
  93. package/cjs/document/data-type/api-field.js +0 -83
  94. package/cjs/document/resource/action.js +0 -12
  95. package/cjs/document/resource/resource-decorator.js +0 -16
  96. package/esm/document/data-type/api-field.js +0 -80
  97. package/esm/document/resource/action.js +0 -8
  98. package/esm/document/resource/resource-decorator.js +0 -13
  99. package/types/document/resource/action.d.ts +0 -11
  100. package/types/document/resource/resource-decorator.d.ts +0 -5
@@ -0,0 +1,17 @@
1
+ import * as vg from 'valgen';
2
+ import { OpraSchema } from '../../schema/index.js';
3
+ import type { ApiDocument } from '../api-document.js';
4
+ import { DataType } from './data-type.js';
5
+ import type { EnumType } from './enum-type.js';
6
+ export declare class EnumTypeClass extends DataType {
7
+ readonly kind = "EnumType";
8
+ readonly base?: EnumType;
9
+ readonly values: Record<string, string | number>;
10
+ readonly meanings: Record<string, string>;
11
+ readonly ownValues: Record<string, string | number>;
12
+ readonly ownMeanings: Record<string, string>;
13
+ readonly decode: vg.Validator<any, any>;
14
+ readonly encode: vg.Validator<any, any>;
15
+ constructor(document: ApiDocument, init: EnumType.InitArguments);
16
+ exportSchema(): OpraSchema.EnumType;
17
+ }
@@ -1,8 +1,18 @@
1
1
  import 'reflect-metadata';
2
- import * as vg from 'valgen';
3
2
  import { OpraSchema } from '../../schema/index.js';
4
3
  import type { ApiDocument } from '../api-document.js';
5
4
  import { DataType } from './data-type.js';
5
+ import { EnumTypeClass } from './enum-type-class.js';
6
+ export interface EnumTypeConstructor {
7
+ new (document: ApiDocument, init?: EnumType.InitArguments): EnumType;
8
+ <T extends OpraSchema.EnumObject | readonly (string | number)[]>(target: T, options?: EnumType.Options<T>): T;
9
+ }
10
+ export interface EnumType extends EnumTypeClass {
11
+ }
12
+ /**
13
+ * @class EnumType
14
+ */
15
+ export declare const EnumType: EnumTypeConstructor;
6
16
  export declare namespace EnumType {
7
17
  interface InitArguments extends DataType.InitArguments, Pick<OpraSchema.EnumType, 'base' | 'values' | 'meanings'> {
8
18
  base?: EnumType;
@@ -16,26 +26,3 @@ export declare namespace EnumType {
16
26
  name: string;
17
27
  }
18
28
  }
19
- declare class EnumTypeClass extends DataType {
20
- readonly kind = "EnumType";
21
- readonly base?: EnumType;
22
- readonly values: Record<string, string | number>;
23
- readonly meanings: Record<string, string>;
24
- readonly ownValues: Record<string, string | number>;
25
- readonly ownMeanings: Record<string, string>;
26
- readonly decode: vg.Validator<any, any>;
27
- readonly encode: vg.Validator<any, any>;
28
- constructor(document: ApiDocument, init: EnumType.InitArguments);
29
- exportSchema(): OpraSchema.EnumType;
30
- }
31
- export interface EnumTypeConstructor {
32
- new (document: ApiDocument, init?: EnumType.InitArguments): EnumType;
33
- <T extends OpraSchema.EnumObject | readonly (string | number)[]>(target: T, options?: EnumType.Options<T>): T;
34
- }
35
- export interface EnumType extends EnumTypeClass {
36
- }
37
- /**
38
- * @class EnumType
39
- */
40
- export declare const EnumType: EnumTypeConstructor;
41
- export {};
@@ -0,0 +1,20 @@
1
+ import type { OpraSchema } from '../../schema/index.js';
2
+ import type { ComplexType } from './complex-type.js';
3
+ import type { DataType } from './data-type.js';
4
+ import type { ApiField } from './field.js';
5
+ export declare class FieldClass {
6
+ readonly owner: ComplexType;
7
+ readonly origin?: ComplexType;
8
+ readonly type: DataType;
9
+ readonly name: string;
10
+ description?: string;
11
+ isArray?: boolean;
12
+ default?: any;
13
+ fixed?: string | number;
14
+ required?: boolean;
15
+ exclusive?: boolean;
16
+ deprecated?: boolean | string;
17
+ examples?: any[] | Record<string, any>;
18
+ constructor(owner: ComplexType, init: ApiField.InitArguments);
19
+ exportSchema(): OpraSchema.Field;
20
+ }
@@ -0,0 +1,5 @@
1
+ import type { ApiField } from './field.js';
2
+ export interface FieldDecorator {
3
+ (options?: ApiField.DecoratorOptions): PropertyDecorator;
4
+ }
5
+ export declare function FieldDecorator(options?: ApiField.DecoratorOptions): PropertyDecorator;
@@ -3,6 +3,26 @@ import { OpraSchema } from '../../schema/index.js';
3
3
  import { TypeThunkAsync } from '../../types.js';
4
4
  import type { ComplexType } from './complex-type.js';
5
5
  import { DataType } from './data-type.js';
6
+ import { FieldClass } from './field-class.js';
7
+ import { FieldDecorator } from './field-decorator.js';
8
+ /**
9
+ * Type definition of ComplexType constructor type
10
+ * @type FieldConstructor
11
+ */
12
+ export interface FieldConstructor extends FieldDecorator {
13
+ prototype: FieldClass;
14
+ new (owner: ComplexType, init: ApiField.InitArguments): FieldClass;
15
+ }
16
+ export interface ApiField extends FieldClass {
17
+ }
18
+ /**
19
+ * @class ApiField
20
+ * @decorator ApiField
21
+ */
22
+ export declare const ApiField: FieldConstructor;
23
+ /**
24
+ * @namespace ApiField
25
+ */
6
26
  export declare namespace ApiField {
7
27
  interface InitArguments extends StrictOmit<OpraSchema.Field, 'type'> {
8
28
  name: string;
@@ -19,23 +39,3 @@ export declare namespace ApiField {
19
39
  designType?: Type;
20
40
  }
21
41
  }
22
- export interface ApiField extends StrictOmit<OpraSchema.Field, 'type'> {
23
- readonly owner: ComplexType;
24
- readonly origin?: ComplexType;
25
- readonly type: DataType;
26
- readonly name: string;
27
- exportSchema(): OpraSchema.Field;
28
- }
29
- /**
30
- * Type definition of ComplexType constructor type
31
- * @type ApiFieldConstructor
32
- */
33
- export interface ApiFieldConstructor {
34
- new (owner: ComplexType, init: ApiField.InitArguments): ApiField;
35
- (options?: ApiField.DecoratorOptions): PropertyDecorator;
36
- prototype: ApiField;
37
- }
38
- /**
39
- * @class ComplexType
40
- */
41
- export declare const ApiField: ApiFieldConstructor;
@@ -0,0 +1,21 @@
1
+ import * as vg from 'valgen';
2
+ import { ResponsiveMap } from '../../helpers/index.js';
3
+ import type { Field } from '../../schema/data-type/field.interface.js';
4
+ import { OpraSchema } from '../../schema/index.js';
5
+ import type { ApiDocument } from '../api-document.js';
6
+ import type { ComplexType } from './complex-type.js';
7
+ import { DataType } from './data-type.js';
8
+ import type { ApiField } from './field.js';
9
+ import type { MappedType } from './mapped-type.js';
10
+ export declare class MappedTypeClass extends DataType {
11
+ readonly kind = "MappedType";
12
+ readonly own: MappedType.OwnProperties;
13
+ readonly type: ComplexType;
14
+ readonly additionalFields?: boolean | vg.Validator | 'error';
15
+ readonly fields: ResponsiveMap<ApiField>;
16
+ readonly omit?: Field.Name[];
17
+ readonly pick?: Field.Name[];
18
+ constructor(document: ApiDocument, init: MappedType.InitArguments);
19
+ exportSchema(): OpraSchema.MappedType;
20
+ }
21
+ export declare function getIsInheritedPredicateFn(pick?: Field.Name[], omit?: Field.Name[]): (propertyName: string) => boolean;
@@ -1,47 +1,18 @@
1
1
  import 'reflect-metadata';
2
2
  import { Class, StrictOmit, Type } from 'ts-gems';
3
- import * as vg from 'valgen';
4
- import { ResponsiveMap } from '../../helpers/index.js';
5
- import { Field } from '../../schema/data-type/field.interface.js';
6
3
  import { OpraSchema } from '../../schema/index.js';
7
4
  import type { ApiDocument } from '../api-document.js';
8
- import { ApiField } from './api-field.js';
9
5
  import { ComplexType } from './complex-type.js';
10
6
  import { DataType } from './data-type.js';
7
+ import { MappedTypeClass } from './mapped-type-class.js';
11
8
  /**
12
- * @namespace MappedType
9
+ *
13
10
  */
14
- export declare namespace MappedType {
15
- interface InitArguments extends DataType.InitArguments, Pick<OpraSchema.MappedType, 'pick' | 'omit'> {
16
- type: ComplexType;
17
- }
18
- interface OwnProperties extends DataType.OwnProperties, Pick<OpraSchema.MappedType, 'pick' | 'omit'> {
19
- }
20
- interface Options<T, K = keyof T> {
21
- pick?: readonly K[];
22
- omit?: readonly K[];
23
- }
24
- interface Metadata extends StrictOmit<OpraSchema.MappedType, 'type'> {
25
- type: Type;
26
- }
27
- }
28
- declare class MappedTypeClass extends DataType {
29
- readonly kind = "MappedType";
30
- readonly own: MappedType.OwnProperties;
31
- readonly type: ComplexType;
32
- readonly additionalFields?: boolean | vg.Validator | 'error';
33
- readonly fields: ResponsiveMap<ApiField>;
34
- readonly omit?: Field.Name[];
35
- readonly pick?: Field.Name[];
36
- constructor(document: ApiDocument, init: MappedType.InitArguments);
37
- exportSchema(): OpraSchema.MappedType;
38
- }
11
+ export declare function PickType<T extends any[], I1, S1, K extends keyof I1>(classRef: Class<T, I1, S1>, keys: readonly K[]): Class<T, Pick<I1, K>> & Omit<Pick<S1, keyof typeof classRef>, 'prototype' | 'constructor'>;
39
12
  /**
40
- * Type definition of MappedType prototype
41
- * @type MappedType
13
+ *
42
14
  */
43
- export interface MappedType extends MappedTypeClass {
44
- }
15
+ export declare function OmitType<T extends any[], I1, S1, K extends keyof I1>(classRef: Class<T, I1, S1>, keys: readonly K[]): Class<T, Omit<I1, K>> & Omit<Pick<S1, keyof typeof classRef>, 'prototype' | 'constructor'>;
45
16
  /**
46
17
  * Type definition of MappedType constructor type
47
18
  * @type MappedTypeConstructor
@@ -62,11 +33,25 @@ export interface MappedTypeConstructor {
62
33
  */
63
34
  export declare const MappedType: MappedTypeConstructor;
64
35
  /**
65
- *
36
+ * Type definition of MappedType prototype
37
+ * @type MappedType
66
38
  */
67
- export declare function PickType<T extends any[], I1, S1, K extends keyof I1>(classRef: Class<T, I1, S1>, keys: readonly K[]): Class<T, Pick<I1, K>> & Omit<Pick<S1, keyof typeof classRef>, 'prototype' | 'constructor'>;
39
+ export interface MappedType extends MappedTypeClass {
40
+ }
68
41
  /**
69
- *
42
+ * @namespace MappedType
70
43
  */
71
- export declare function OmitType<T extends any[], I1, S1, K extends keyof I1>(classRef: Class<T, I1, S1>, keys: readonly K[]): Class<T, Omit<I1, K>> & Omit<Pick<S1, keyof typeof classRef>, 'prototype' | 'constructor'>;
72
- export {};
44
+ export declare namespace MappedType {
45
+ interface InitArguments extends DataType.InitArguments, Pick<OpraSchema.MappedType, 'pick' | 'omit'> {
46
+ type: ComplexType;
47
+ }
48
+ interface OwnProperties extends DataType.OwnProperties, Pick<OpraSchema.MappedType, 'pick' | 'omit'> {
49
+ }
50
+ interface Options<T, K = keyof T> {
51
+ pick?: readonly K[];
52
+ omit?: readonly K[];
53
+ }
54
+ interface Metadata extends StrictOmit<OpraSchema.MappedType, 'type'> {
55
+ type: Type;
56
+ }
57
+ }
@@ -0,0 +1,17 @@
1
+ import * as vg from 'valgen';
2
+ import { OpraSchema } from '../../schema/index.js';
3
+ import type { ApiDocument } from '../api-document.js';
4
+ import { DataType } from './data-type.js';
5
+ import type { SimpleType } from './simple-type.js';
6
+ /**
7
+ * @class SimpleType
8
+ */
9
+ export declare class SimpleTypeClass extends DataType {
10
+ readonly kind = "SimpleType";
11
+ readonly base?: SimpleType;
12
+ readonly own: SimpleType.OwnProperties;
13
+ readonly decode: vg.Validator<any, any>;
14
+ readonly encode: vg.Validator<any, any>;
15
+ constructor(document: ApiDocument, init: SimpleType.InitArguments);
16
+ exportSchema(): OpraSchema.SimpleType;
17
+ }
@@ -1,37 +1,8 @@
1
1
  import 'reflect-metadata';
2
2
  import * as vg from 'valgen';
3
- import { OpraSchema } from '../../schema/index.js';
4
3
  import type { ApiDocument } from '../api-document.js';
5
4
  import { DataType } from './data-type.js';
6
- export declare namespace SimpleType {
7
- interface InitArguments extends DataType.InitArguments {
8
- base?: SimpleType;
9
- decoder?: vg.Validator<any, any>;
10
- encoder?: vg.Validator<any, any>;
11
- }
12
- interface DecoratorOptions extends DataType.DecoratorOptions {
13
- decoder?: vg.Validator<any, any>;
14
- encoder?: vg.Validator<any, any>;
15
- }
16
- interface Metadata extends DataType.Metadata {
17
- decoder?: vg.Validator<any, any>;
18
- encoder?: vg.Validator<any, any>;
19
- }
20
- interface OwnProperties extends DataType.OwnProperties {
21
- }
22
- }
23
- /**
24
- * @class SimpleType
25
- */
26
- declare class SimpleTypeClass extends DataType {
27
- readonly kind = "SimpleType";
28
- readonly base?: SimpleType;
29
- readonly own: SimpleType.OwnProperties;
30
- readonly decode: vg.Validator<any, any>;
31
- readonly encode: vg.Validator<any, any>;
32
- constructor(document: ApiDocument, init: SimpleType.InitArguments);
33
- exportSchema(): OpraSchema.SimpleType;
34
- }
5
+ import { SimpleTypeClass } from './simple-type-class.js';
35
6
  export interface SimpleTypeConstructor {
36
7
  new (document: ApiDocument, init: SimpleType.InitArguments): SimpleType;
37
8
  (options?: SimpleType.DecoratorOptions): (target: any) => any;
@@ -43,4 +14,23 @@ export interface SimpleType extends SimpleTypeClass {
43
14
  * @class SimpleType
44
15
  */
45
16
  export declare const SimpleType: SimpleTypeConstructor;
46
- export {};
17
+ /**
18
+ * @namespace SimpleType
19
+ */
20
+ export declare namespace SimpleType {
21
+ interface InitArguments extends DataType.InitArguments {
22
+ base?: SimpleType;
23
+ decoder?: vg.Validator;
24
+ encoder?: vg.Validator;
25
+ }
26
+ interface DecoratorOptions extends DataType.DecoratorOptions {
27
+ decoder?: vg.Validator;
28
+ encoder?: vg.Validator;
29
+ }
30
+ interface Metadata extends DataType.Metadata {
31
+ decoder?: vg.Validator;
32
+ encoder?: vg.Validator;
33
+ }
34
+ interface OwnProperties extends DataType.OwnProperties {
35
+ }
36
+ }
@@ -0,0 +1,18 @@
1
+ import * as vg from 'valgen';
2
+ import { ResponsiveMap } from '../../helpers/index.js';
3
+ import { OpraSchema } from '../../schema/index.js';
4
+ import type { ApiDocument } from '../api-document.js';
5
+ import { ComplexType } from './complex-type.js';
6
+ import { DataType } from './data-type.js';
7
+ import type { ApiField } from './field.js';
8
+ import { MappedType } from './mapped-type.js';
9
+ import type { UnionType } from './union-type.js';
10
+ export declare class UnionTypeClass extends DataType {
11
+ readonly kind = "UnionType";
12
+ readonly own: UnionType.OwnProperties;
13
+ readonly types: (ComplexType | UnionType | MappedType)[];
14
+ readonly additionalFields?: boolean | vg.Validator | 'error';
15
+ readonly fields: ResponsiveMap<ApiField>;
16
+ constructor(document: ApiDocument, init: UnionType.InitArguments);
17
+ exportSchema(): OpraSchema.UnionType;
18
+ }
@@ -1,36 +1,11 @@
1
1
  import 'reflect-metadata';
2
2
  import { Class, StrictOmit, Type } from 'ts-gems';
3
- import * as vg from 'valgen';
4
- import { ResponsiveMap } from '../../helpers/index.js';
5
3
  import { OpraSchema } from '../../schema/index.js';
6
4
  import type { ApiDocument } from '../api-document.js';
7
- import { ApiField } from './api-field.js';
8
5
  import { ComplexType } from './complex-type.js';
9
6
  import { DataType } from './data-type.js';
10
7
  import { MappedType } from './mapped-type.js';
11
- /**
12
- * @namespace UnionType
13
- */
14
- export declare namespace UnionType {
15
- interface InitArguments extends DataType.InitArguments {
16
- types: (ComplexType | UnionType | MappedType)[];
17
- }
18
- interface OwnProperties extends DataType.OwnProperties {
19
- types: (ComplexType | UnionType | MappedType)[];
20
- }
21
- interface Metadata extends StrictOmit<OpraSchema.UnionType, 'types'> {
22
- types: Type[];
23
- }
24
- }
25
- declare class UnionTypeClass extends DataType {
26
- readonly kind = "UnionType";
27
- readonly own: UnionType.OwnProperties;
28
- readonly types: (ComplexType | UnionType | MappedType)[];
29
- readonly additionalFields?: boolean | vg.Validator | 'error';
30
- readonly fields: ResponsiveMap<ApiField>;
31
- constructor(document: ApiDocument, init: UnionType.InitArguments);
32
- exportSchema(): OpraSchema.UnionType;
33
- }
8
+ import { UnionTypeClass } from './union-type-class.js';
34
9
  /**
35
10
  * Type definition of UnionType constructor type
36
11
  * @type UnionTypeConstructor
@@ -51,4 +26,17 @@ export interface UnionType extends UnionTypeClass {
51
26
  * @class UnionType
52
27
  */
53
28
  export declare const UnionType: UnionTypeConstructor;
54
- export {};
29
+ /**
30
+ * @namespace UnionType
31
+ */
32
+ export declare namespace UnionType {
33
+ interface InitArguments extends DataType.InitArguments {
34
+ types: (ComplexType | UnionType | MappedType)[];
35
+ }
36
+ interface OwnProperties extends DataType.OwnProperties {
37
+ types: (ComplexType | UnionType | MappedType)[];
38
+ }
39
+ interface Metadata extends StrictOmit<OpraSchema.UnionType, 'types'> {
40
+ types: Type[];
41
+ }
42
+ }
@@ -1,21 +1,10 @@
1
1
  import { StrictOmit, Type } from 'ts-gems';
2
- import type { Collection } from './collection.js';
3
- import { Resource } from './resource.js';
4
- import { ResourceDecorator } from './resource-decorator.js';
2
+ import type { Collection } from '../resource/collection';
3
+ import { Resource } from '../resource/resource.js';
4
+ import { ResourceDecorator } from './resource.decorator.js';
5
5
  type ErrorMessage<T, Error> = [T] extends [never] ? Error : T;
6
6
  declare const operationProperties: readonly ["create", "delete", "deleteMany", "get", "findMany", "update", "updateMany"];
7
7
  type OperationProperties = typeof operationProperties[number];
8
- export interface CollectionDecorator extends StrictOmit<ResourceDecorator, 'Action'> {
9
- <T>(type: Type<T> | string, options?: Collection.DecoratorOptions<T>): 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
- Create: (options?: Collection.CreateEndpointOptions) => ((target: Object, propertyKey: 'create') => void);
12
- Delete: (options?: Collection.DeleteEndpointOptions) => ((target: Object, propertyKey: 'delete') => void);
13
- DeleteMany: (options?: Collection.DeleteManyEndpointOptions) => ((target: Object, propertyKey: 'deleteMany') => void);
14
- Get: (options?: Collection.GetEndpointOptions) => ((target: Object, propertyKey: 'get') => void);
15
- FindMany: (options?: Collection.FindManyEndpointOptions) => ((target: Object, propertyKey: 'findMany') => void);
16
- Update: (options?: Collection.UpdateEndpointOptions) => ((target: Object, propertyKey: 'update') => void);
17
- UpdateMany: (options?: Collection.UpdateManyEndpointOptions) => ((target: Object, propertyKey: 'updateMany') => void);
18
- }
19
8
  export declare function CollectionDecorator(type: Type | string, options?: Collection.DecoratorOptions): ClassDecorator;
20
9
  export declare namespace CollectionDecorator {
21
10
  var Create: (options?: unknown) => (target: Object, propertyKey: string | symbol) => void;
@@ -27,4 +16,15 @@ export declare namespace CollectionDecorator {
27
16
  var UpdateMany: (options?: unknown) => (target: Object, propertyKey: string | symbol) => void;
28
17
  var Action: (options: any) => PropertyDecorator;
29
18
  }
19
+ export interface CollectionDecorator extends StrictOmit<ResourceDecorator, 'Action'> {
20
+ <T>(type: Type<T> | string, options?: Collection.DecoratorOptions<T>): ClassDecorator;
21
+ 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);
22
+ Create: (options?: Collection.CreateEndpointOptions) => ((target: Object, propertyKey: 'create') => void);
23
+ Delete: (options?: Collection.DeleteEndpointOptions) => ((target: Object, propertyKey: 'delete') => void);
24
+ DeleteMany: (options?: Collection.DeleteManyEndpointOptions) => ((target: Object, propertyKey: 'deleteMany') => void);
25
+ Get: (options?: Collection.GetEndpointOptions) => ((target: Object, propertyKey: 'get') => void);
26
+ FindMany: (options?: Collection.FindManyEndpointOptions) => ((target: Object, propertyKey: 'findMany') => void);
27
+ Update: (options?: Collection.UpdateEndpointOptions) => ((target: Object, propertyKey: 'update') => void);
28
+ UpdateMany: (options?: Collection.UpdateManyEndpointOptions) => ((target: Object, propertyKey: 'updateMany') => void);
29
+ }
30
30
  export {};
@@ -0,0 +1,2 @@
1
+ import type { ComplexType } from '../data-type/complex-type.js';
2
+ export declare function ComplexTypeDecorator(options?: ComplexType.DecoratorOptions): (target: Function) => void;
@@ -0,0 +1,9 @@
1
+ import { OpraSchema } from '../../schema/index.js';
2
+ import type { Resource } from '../resource/resource';
3
+ export interface ResourceDecorator {
4
+ Action: (options?: Resource.ActionOptions) => PropertyDecorator;
5
+ }
6
+ export declare function ResourceDecorator<O extends Resource.DecoratorOptions>(kind: OpraSchema.Resource.Kind, options?: O): ClassDecorator;
7
+ export declare namespace ResourceDecorator {
8
+ var Action: (options: any) => PropertyDecorator;
9
+ }
@@ -0,0 +1,2 @@
1
+ import type { SimpleType } from '../data-type/simple-type';
2
+ export declare function SimpleTypeDecorator(options?: SimpleType.DecoratorOptions): (target: Function) => void;
@@ -1,19 +1,11 @@
1
1
  import { StrictOmit } from 'ts-gems';
2
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';
3
+ import { Resource } from '../resource/resource.js';
4
+ import type { Singleton } from '../resource/singleton.js';
5
+ import { ResourceDecorator } from './resource.decorator.js';
6
6
  type ErrorMessage<T, Error> = [T] extends [never] ? Error : T;
7
7
  declare const operationProperties: readonly ["create", "delete", "get", "update"];
8
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
9
  export declare function SingletonDecorator(type: TypeThunkAsync | string, options?: Singleton.DecoratorOptions): ClassDecorator;
18
10
  export declare namespace SingletonDecorator {
19
11
  var Create: (options?: unknown) => (target: Object, propertyKey: string | symbol) => void;
@@ -22,4 +14,12 @@ export declare namespace SingletonDecorator {
22
14
  var Update: (options?: unknown) => (target: Object, propertyKey: string | symbol) => void;
23
15
  var Action: (options: any) => PropertyDecorator;
24
16
  }
17
+ export interface SingletonDecorator extends StrictOmit<ResourceDecorator, 'Action'> {
18
+ (type: TypeThunkAsync | string, options?: Singleton.DecoratorOptions): ClassDecorator;
19
+ 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);
20
+ Create: (options?: Singleton.CreateEndpointOptions) => ((target: Object, propertyKey: 'create') => void);
21
+ Delete: (options?: Singleton.DeleteEndpointOptions) => ((target: Object, propertyKey: 'delete') => void);
22
+ Get: (options?: Singleton.GetEndpointOptions) => ((target: Object, propertyKey: 'get') => void);
23
+ Update: (options?: Singleton.UpdateEndpointOptions) => ((target: Object, propertyKey: 'update') => void);
24
+ }
25
25
  export {};
@@ -1,17 +1,10 @@
1
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';
2
+ import { Resource } from '../resource/resource.js';
3
+ import type { Storage } from '../resource/storage.js';
4
+ import { ResourceDecorator } from './resource.decorator.js';
5
5
  type ErrorMessage<T, Error> = [T] extends [never] ? Error : T;
6
6
  declare const operationProperties: readonly ["delete", "get", "post"];
7
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
8
  export declare function StorageDecorator(options?: Storage.DecoratorOptions): ClassDecorator;
16
9
  export declare namespace StorageDecorator {
17
10
  var Delete: (options?: unknown) => (target: Object, propertyKey: string | symbol) => void;
@@ -19,4 +12,11 @@ export declare namespace StorageDecorator {
19
12
  var Post: (options?: unknown) => (target: Object, propertyKey: string | symbol) => void;
20
13
  var Action: (options: any) => PropertyDecorator;
21
14
  }
15
+ export interface StorageDecorator extends StrictOmit<ResourceDecorator, 'Action'> {
16
+ (options?: Storage.DecoratorOptions): ClassDecorator;
17
+ 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);
18
+ Delete: (options?: Storage.DeleteEndpointOptions) => ((target: Object, propertyKey: 'delete') => void);
19
+ Get: (options?: Storage.GetEndpointOptions) => ((target: Object, propertyKey: 'get') => void);
20
+ Post: (options?: Storage.PostEndpointOptions) => ((target: Object, propertyKey: 'post') => void);
21
+ }
22
22
  export {};
@@ -1,9 +1,9 @@
1
1
  import { Type } from 'ts-gems';
2
2
  import { OpraSchema } from '../../schema/index.js';
3
3
  import type { ThunkAsync } from '../../types.js';
4
- import type { ApiField } from '../data-type/api-field.js';
5
4
  import type { ComplexType } from '../data-type/complex-type.js';
6
5
  import type { EnumType } from '../data-type/enum-type.js';
6
+ import type { ApiField } from '../data-type/field.js';
7
7
  import type { MappedType } from '../data-type/mapped-type.js';
8
8
  import type { SimpleType } from '../data-type/simple-type.js';
9
9
  import type { UnionType } from '../data-type/union-type.js';
@@ -4,7 +4,7 @@ export * from './api-document.js';
4
4
  export * from './factory/index.js';
5
5
  export * from './data-type/data-type.js';
6
6
  export * from './data-type/complex-type.js';
7
- export * from './data-type/api-field.js';
7
+ export * from './data-type/field.js';
8
8
  export * from './data-type/enum-type.js';
9
9
  export * from './data-type/mapped-type.js';
10
10
  export * from './data-type/simple-type.js';
@@ -3,9 +3,23 @@ import { OpraSchema } from '../../schema/index.js';
3
3
  import type { TypeThunkAsync } from '../../types.js';
4
4
  import type { ApiDocument } from '../api-document.js';
5
5
  import { ComplexType } from '../data-type/complex-type.js';
6
+ import { CollectionDecorator } from '../decorators/collection-decorator.js';
6
7
  import { CollectionClass } from './collection-class.js';
7
- import { CollectionDecorator } from './collection-decorator.js';
8
- import { Resource } from './resource.js';
8
+ import type { Resource } from './resource.js';
9
+ export interface CollectionConstructor extends CollectionDecorator {
10
+ prototype: CollectionClass;
11
+ new (document: ApiDocument, init: Collection.InitArguments): CollectionClass;
12
+ }
13
+ export interface Collection extends CollectionClass {
14
+ }
15
+ /**
16
+ * @class Collection
17
+ * @decorator Collection
18
+ */
19
+ export declare const Collection: CollectionConstructor;
20
+ /**
21
+ * @namespace Collection
22
+ */
9
23
  export declare namespace Collection {
10
24
  interface InitArguments extends Resource.InitArguments, StrictOmit<OpraSchema.Collection, 'kind' | 'type'> {
11
25
  type: ComplexType;
@@ -38,13 +52,3 @@ export declare namespace Collection {
38
52
  type UpdateEndpointOptions = OpraSchema.Collection.UpdateEndpoint;
39
53
  type UpdateManyEndpointOptions = OpraSchema.Collection.UpdateManyEndpoint;
40
54
  }
41
- export interface CollectionConstructor extends CollectionDecorator {
42
- prototype: Collection;
43
- new (document: ApiDocument, init: Collection.InitArguments): Collection;
44
- }
45
- export interface Collection extends CollectionClass {
46
- }
47
- /**
48
- *
49
- */
50
- export declare const Collection: CollectionConstructor;
@@ -0,0 +1,29 @@
1
+ import { StrictOmit } from 'ts-gems';
2
+ import { ResponsiveMap } from '../../helpers/index.js';
3
+ import { OpraSchema } from '../../schema/index.js';
4
+ import { DataType } from '../data-type/data-type.js';
5
+ export declare class Endpoint {
6
+ readonly name: string;
7
+ description?: string;
8
+ parameters: ResponsiveMap<Endpoint.Parameter>;
9
+ constructor(init: Endpoint.InitArguments);
10
+ exportSchema(): OpraSchema.Endpoint;
11
+ }
12
+ export declare namespace Endpoint {
13
+ interface InitArguments extends OpraSchema.Endpoint {
14
+ name: string;
15
+ }
16
+ class Parameter implements StrictOmit<OpraSchema.Endpoint.Parameter, 'type'> {
17
+ readonly name: string;
18
+ readonly type: string | DataType;
19
+ description?: string;
20
+ isArray?: boolean;
21
+ default?: any;
22
+ required?: boolean;
23
+ deprecated?: boolean | string;
24
+ constructor(init: OpraSchema.Endpoint.Parameter);
25
+ exportSchema(): OpraSchema.Endpoint.Parameter;
26
+ }
27
+ namespace Parameter {
28
+ }
29
+ }