@opra/common 0.28.1 → 0.29.0

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 (49) hide show
  1. package/browser.js +200 -100
  2. package/cjs/document/data-type/complex-type-class.js +36 -13
  3. package/cjs/document/factory/api-document-factory.js +26 -3
  4. package/cjs/document/factory/type-document-factory.js +6 -3
  5. package/cjs/document/index.js +1 -1
  6. package/cjs/document/resource/collection-class.js +31 -27
  7. package/cjs/document/resource/collection-decorator.js +61 -33
  8. package/cjs/document/resource/{operation-decorator.js → crud-operation-decorator.js} +3 -2
  9. package/cjs/document/resource/crud-operation.js +49 -0
  10. package/cjs/document/resource/crud-resource.js +2 -2
  11. package/cjs/document/resource/endpoint.js +11 -3
  12. package/cjs/document/resource/singleton-class.js +20 -15
  13. package/cjs/document/resource/storage-decorator.js +10 -10
  14. package/esm/document/data-type/complex-type-class.js +36 -13
  15. package/esm/document/factory/api-document-factory.js +26 -3
  16. package/esm/document/factory/type-document-factory.js +6 -3
  17. package/esm/document/index.js +1 -1
  18. package/esm/document/resource/collection-class.js +31 -27
  19. package/esm/document/resource/collection-decorator.js +54 -26
  20. package/esm/document/resource/{operation-decorator.js → crud-operation-decorator.js} +3 -2
  21. package/esm/document/resource/crud-operation.js +44 -0
  22. package/esm/document/resource/crud-resource.js +2 -2
  23. package/esm/document/resource/endpoint.js +11 -3
  24. package/esm/document/resource/singleton-class.js +20 -15
  25. package/esm/document/resource/storage-decorator.js +7 -7
  26. package/package.json +3 -2
  27. package/types/document/data-type/complex-type-class.d.ts +1 -1
  28. package/types/document/data-type/complex-type.d.ts +7 -3
  29. package/types/document/data-type/data-type.d.ts +3 -0
  30. package/types/document/data-type/field-class.d.ts +0 -2
  31. package/types/document/index.d.ts +1 -1
  32. package/types/document/resource/collection-class.d.ts +0 -9
  33. package/types/document/resource/collection-decorator.d.ts +12 -0
  34. package/types/document/resource/crud-operation-decorator.d.ts +6 -0
  35. package/types/document/resource/{operation.d.ts → crud-operation.d.ts} +12 -4
  36. package/types/document/resource/crud-resource.d.ts +3 -3
  37. package/types/document/resource/endpoint.d.ts +1 -1
  38. package/types/document/resource/resource-decorator.d.ts +3 -2
  39. package/types/document/resource/resource.d.ts +2 -2
  40. package/types/document/resource/singleton-class.d.ts +5 -5
  41. package/types/document/resource/singleton-decorator.d.ts +6 -0
  42. package/types/document/resource/storage-class.d.ts +4 -4
  43. package/types/schema/data-type/complex-type.interface.d.ts +1 -1
  44. package/types/schema/resource/collection.interface.d.ts +7 -7
  45. package/types/schema/resource/endpoint.interface.d.ts +2 -1
  46. package/types/schema/resource/singleton.interface.d.ts +0 -2
  47. package/cjs/document/resource/operation.js +0 -25
  48. package/esm/document/resource/operation.js +0 -20
  49. package/types/document/resource/operation-decorator.d.ts +0 -6
@@ -1,7 +1,8 @@
1
1
  import { Field } from '../data-type/field.interface.js';
2
- export interface Endpoint {
2
+ export interface Endpoint<TOptions extends Object = any> {
3
3
  description?: string;
4
4
  parameters?: Record<Endpoint.Parameter.Name, Endpoint.Parameter>;
5
+ options?: TOptions;
5
6
  }
6
7
  export declare namespace Endpoint {
7
8
  interface Parameter extends Pick<Field, 'type' | 'description' | 'isArray' | 'default' | 'required' | 'deprecated' | 'examples'> {
@@ -1,7 +1,6 @@
1
1
  import { StrictOmit } from 'ts-gems';
2
2
  import type { DataType } from '../data-type/data-type.interface.js';
3
3
  import type { Collection } from './collection.interface.js';
4
- import { Endpoint } from './endpoint.interface.js';
5
4
  import type { ResourceBase } from './resource.interface.js';
6
5
  export interface Singleton extends StrictOmit<ResourceBase, 'kind'> {
7
6
  kind: Singleton.Kind;
@@ -16,7 +15,6 @@ export declare namespace Singleton {
16
15
  delete?: Operations.Delete;
17
16
  get?: Operations.Get;
18
17
  update?: Operations.Update;
19
- [key: string]: Endpoint | undefined;
20
18
  }
21
19
  namespace Operations {
22
20
  type Create = Collection.Operations.Create;
@@ -1,25 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Operation = void 0;
4
- const tslib_1 = require("tslib");
5
- const vg = tslib_1.__importStar(require("valgen"));
6
- const data_type_js_1 = require("../data-type/data-type.js");
7
- const endpoint_js_1 = require("./endpoint.js");
8
- /**
9
- *
10
- * @class Operation
11
- */
12
- class Operation extends endpoint_js_1.Endpoint {
13
- constructor(resource, name, init) {
14
- super(resource, name, init);
15
- this.resource = resource;
16
- this.name = name;
17
- this.kind = 'operation';
18
- this.decodeInput = vg.isAny();
19
- this.encodeReturning = vg.isAny();
20
- this.returnType = init.returnType instanceof data_type_js_1.DataType
21
- ? init.returnType : this.resource.document.getDataType(init.returnType || 'any');
22
- this.encodeReturning = this.returnType.generateCodec('encode', { operation: 'read' });
23
- }
24
- }
25
- exports.Operation = Operation;
@@ -1,20 +0,0 @@
1
- import * as vg from 'valgen';
2
- import { DataType } from '../data-type/data-type.js';
3
- import { Endpoint } from './endpoint.js';
4
- /**
5
- *
6
- * @class Operation
7
- */
8
- export class Operation extends Endpoint {
9
- constructor(resource, name, init) {
10
- super(resource, name, init);
11
- this.resource = resource;
12
- this.name = name;
13
- this.kind = 'operation';
14
- this.decodeInput = vg.isAny();
15
- this.encodeReturning = vg.isAny();
16
- this.returnType = init.returnType instanceof DataType
17
- ? init.returnType : this.resource.document.getDataType(init.returnType || 'any');
18
- this.encodeReturning = this.returnType.generateCodec('encode', { operation: 'read' });
19
- }
20
- }
@@ -1,6 +0,0 @@
1
- import { Type } from 'ts-gems';
2
- import { ResourceDecorator } from './resource-decorator.js';
3
- export type OperationDecorator = ((target: Object, propertyKey: any) => void) & {
4
- Parameter: (name: string, optionsOrType?: ResourceDecorator.ParameterOptions | string | Type) => OperationDecorator;
5
- };
6
- export declare function createOperationDecorator<T extends OperationDecorator, M extends ResourceDecorator.OperationMetadata>(operation: string, options: any, list: ((operationMeta: M, target: Object, propertyKey: string) => void)[]): T;