@opra/common 0.33.12 → 0.33.13

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.
package/browser.js CHANGED
@@ -11209,13 +11209,16 @@ var CrudOperation = class extends Endpoint {
11209
11209
  this.kind = "operation";
11210
11210
  this.decodeInput = vg12.isAny();
11211
11211
  this.encodeReturning = vg12.isAny();
11212
- this.returnType = init.returnType instanceof DataType ? init.returnType : this.resource.document.getDataType(init.returnType || "any");
11213
- this.encodeReturning = this.returnType.generateCodec("encode", { operation: "read", partial: true });
11212
+ if (init.returnType)
11213
+ this.returnType = init.returnType instanceof DataType ? init.returnType : this.resource.document.getDataType(init.returnType);
11214
+ this.encodeReturning = this.returnType?.generateCodec("encode", { operation: "read", partial: true }) || vg12.isAny();
11214
11215
  this.inputOverwriteFields = init.options?.inputOverwriteFields;
11215
11216
  this.outputOverwriteFields = init.options?.outputOverwriteFields;
11216
11217
  }
11217
11218
  exportSchema(options) {
11218
11219
  const schema = super.exportSchema(options);
11220
+ if (this.returnType)
11221
+ schema.returnType = this.returnType.name && !this.returnType.isEmbedded ? this.returnType.name : this.returnType.exportSchema(options);
11219
11222
  if (this.inputOverwriteFields) {
11220
11223
  const trg = schema.options.inputOverwriteFields = {};
11221
11224
  Object.keys(this.inputOverwriteFields).forEach(([k, o]) => {
@@ -17,14 +17,18 @@ class CrudOperation extends endpoint_js_1.Endpoint {
17
17
  this.kind = 'operation';
18
18
  this.decodeInput = valgen_1.vg.isAny();
19
19
  this.encodeReturning = valgen_1.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', partial: true });
20
+ if (init.returnType)
21
+ this.returnType = init.returnType instanceof data_type_js_1.DataType
22
+ ? init.returnType : this.resource.document.getDataType(init.returnType);
23
+ this.encodeReturning = this.returnType?.generateCodec('encode', { operation: 'read', partial: true }) || valgen_1.vg.isAny();
23
24
  this.inputOverwriteFields = init.options?.inputOverwriteFields;
24
25
  this.outputOverwriteFields = init.options?.outputOverwriteFields;
25
26
  }
26
27
  exportSchema(options) {
27
28
  const schema = super.exportSchema(options);
29
+ if (this.returnType)
30
+ schema.returnType = this.returnType.name && !this.returnType.isEmbedded ?
31
+ this.returnType.name : this.returnType.exportSchema(options);
28
32
  if (this.inputOverwriteFields) {
29
33
  const trg = schema.options.inputOverwriteFields = {};
30
34
  Object.keys(this.inputOverwriteFields)
@@ -14,14 +14,18 @@ export class CrudOperation extends Endpoint {
14
14
  this.kind = 'operation';
15
15
  this.decodeInput = vg.isAny();
16
16
  this.encodeReturning = vg.isAny();
17
- this.returnType = init.returnType instanceof DataType
18
- ? init.returnType : this.resource.document.getDataType(init.returnType || 'any');
19
- this.encodeReturning = this.returnType.generateCodec('encode', { operation: 'read', partial: true });
17
+ if (init.returnType)
18
+ this.returnType = init.returnType instanceof DataType
19
+ ? init.returnType : this.resource.document.getDataType(init.returnType);
20
+ this.encodeReturning = this.returnType?.generateCodec('encode', { operation: 'read', partial: true }) || vg.isAny();
20
21
  this.inputOverwriteFields = init.options?.inputOverwriteFields;
21
22
  this.outputOverwriteFields = init.options?.outputOverwriteFields;
22
23
  }
23
24
  exportSchema(options) {
24
25
  const schema = super.exportSchema(options);
26
+ if (this.returnType)
27
+ schema.returnType = this.returnType.name && !this.returnType.isEmbedded ?
28
+ this.returnType.name : this.returnType.exportSchema(options);
25
29
  if (this.inputOverwriteFields) {
26
30
  const trg = schema.options.inputOverwriteFields = {};
27
31
  Object.keys(this.inputOverwriteFields)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opra/common",
3
- "version": "0.33.12",
3
+ "version": "0.33.13",
4
4
  "description": "Opra common package",
5
5
  "author": "Panates",
6
6
  "license": "MIT",
@@ -76,4 +76,4 @@
76
76
  "opra",
77
77
  "common"
78
78
  ]
79
- }
79
+ }
@@ -15,7 +15,7 @@ export declare class CrudOperation extends Endpoint {
15
15
  readonly name: string;
16
16
  readonly kind = "operation";
17
17
  decodeInput: Validator;
18
- returnType: DataType;
18
+ returnType?: DataType;
19
19
  encodeReturning: Validator;
20
20
  inputOverwriteFields?: Record<string, ApiField.InitArguments>;
21
21
  outputOverwriteFields?: Record<string, ApiField.InitArguments>;
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ResourceNotFoundError = void 0;
4
- const index_js_1 = require("../../http/index.js");
5
- const index_js_2 = require("../../i18n/index.js");
6
- const opra_exception_js_1 = require("../opra-exception.js");
7
- /**
8
- * The server cannot find the requested resource.
9
- * This can also mean that the endpoint is valid but the resource itself does not exist.
10
- */
11
- class ResourceNotFoundError extends opra_exception_js_1.OpraException {
12
- constructor(resource, keyValue, cause) {
13
- super({
14
- message: (0, index_js_2.translate)(`error:RESOURCE_NOT_AVAILABLE`, `Resource "${resource}${keyValue ? '/' + keyValue : ''}" is not available or you dont have access`),
15
- severity: 'error',
16
- code: 'RESOURCE_NOT_AVAILABLE',
17
- details: {
18
- resource,
19
- key: keyValue
20
- }
21
- }, cause, index_js_1.HttpStatusCodes.UNPROCESSABLE_ENTITY);
22
- }
23
- }
24
- exports.ResourceNotFoundError = ResourceNotFoundError;
@@ -1,24 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ResourceNotAvailable = void 0;
4
- const index_js_1 = require("../../http/index.js");
5
- const index_js_2 = require("../../i18n/index.js");
6
- const opra_exception_js_1 = require("../opra-exception.js");
7
- /**
8
- * The server cannot find the requested resource.
9
- * This can also mean that the endpoint is valid but the resource itself does not exist.
10
- */
11
- class ResourceNotAvailable extends opra_exception_js_1.OpraException {
12
- constructor(resource, keyValue, cause) {
13
- super({
14
- message: (0, index_js_2.translate)(`error:RESOURCE_NOT_AVAILABLE`, `Resource "${resource}${keyValue ? '/' + keyValue : ''}" is not available or you dont have access`),
15
- severity: 'error',
16
- code: 'RESOURCE_NOT_AVAILABLE',
17
- details: {
18
- resource,
19
- key: keyValue
20
- }
21
- }, cause, index_js_1.HttpStatusCodes.UNPROCESSABLE_ENTITY);
22
- }
23
- }
24
- exports.ResourceNotAvailable = ResourceNotAvailable;
@@ -1,20 +0,0 @@
1
- import { HttpStatusCodes } from '../../http/index.js';
2
- import { translate } from '../../i18n/index.js';
3
- import { OpraException } from '../opra-exception.js';
4
- /**
5
- * The server cannot find the requested resource.
6
- * This can also mean that the endpoint is valid but the resource itself does not exist.
7
- */
8
- export class ResourceNotFoundError extends OpraException {
9
- constructor(resource, keyValue, cause) {
10
- super({
11
- message: translate(`error:RESOURCE_NOT_AVAILABLE`, `Resource "${resource}${keyValue ? '/' + keyValue : ''}" is not available or you dont have access`),
12
- severity: 'error',
13
- code: 'RESOURCE_NOT_AVAILABLE',
14
- details: {
15
- resource,
16
- key: keyValue
17
- }
18
- }, cause, HttpStatusCodes.UNPROCESSABLE_ENTITY);
19
- }
20
- }
@@ -1,20 +0,0 @@
1
- import { HttpStatusCodes } from '../../http/index.js';
2
- import { translate } from '../../i18n/index.js';
3
- import { OpraException } from '../opra-exception.js';
4
- /**
5
- * The server cannot find the requested resource.
6
- * This can also mean that the endpoint is valid but the resource itself does not exist.
7
- */
8
- export class ResourceNotAvailable extends OpraException {
9
- constructor(resource, keyValue, cause) {
10
- super({
11
- message: translate(`error:RESOURCE_NOT_AVAILABLE`, `Resource "${resource}${keyValue ? '/' + keyValue : ''}" is not available or you dont have access`),
12
- severity: 'error',
13
- code: 'RESOURCE_NOT_AVAILABLE',
14
- details: {
15
- resource,
16
- key: keyValue
17
- }
18
- }, cause, HttpStatusCodes.UNPROCESSABLE_ENTITY);
19
- }
20
- }
@@ -1,8 +0,0 @@
1
- import { OpraException } from '../opra-exception.js';
2
- /**
3
- * The server cannot find the requested resource.
4
- * This can also mean that the endpoint is valid but the resource itself does not exist.
5
- */
6
- export declare class ResourceNotFoundError extends OpraException {
7
- constructor(resource: string, keyValue?: any, cause?: Error);
8
- }
@@ -1,8 +0,0 @@
1
- import { OpraException } from '../opra-exception.js';
2
- /**
3
- * The server cannot find the requested resource.
4
- * This can also mean that the endpoint is valid but the resource itself does not exist.
5
- */
6
- export declare class ResourceNotAvailable extends OpraException {
7
- constructor(resource: string, keyValue?: any, cause?: Error);
8
- }