@opra/common 0.31.0 → 0.31.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.
package/browser.js CHANGED
@@ -10416,8 +10416,11 @@ var CrudResource = class extends Resource {
10416
10416
  }
10417
10417
  }
10418
10418
  }
10419
- getOperation(name) {
10420
- return this.operations.get(name);
10419
+ getOperation(operation) {
10420
+ const op = this.operations.get(operation);
10421
+ if (!op)
10422
+ throw new Error(`${this.name} resource does not support "${operation}" operations`);
10423
+ return op;
10421
10424
  }
10422
10425
  exportSchema(options) {
10423
10426
  const schema = super.exportSchema(options);
@@ -10513,6 +10516,7 @@ var CollectionClass = class extends CrudResource {
10513
10516
  endpoint.defineParameter("omit", { type: "string", isArray: true, isBuiltin: true });
10514
10517
  endpoint.defineParameter("include", { type: "string", isArray: true, isBuiltin: true });
10515
10518
  endpoint.decodeInput = this.type.generateCodec("decode", {
10519
+ partial: true,
10516
10520
  pick: endpoint.options.inputPickFields,
10517
10521
  omit: endpoint.options.inputOmitFields,
10518
10522
  operation: "write",
@@ -100,6 +100,7 @@ class CollectionClass extends crud_resource_js_1.CrudResource {
100
100
  endpoint.defineParameter('omit', { type: 'string', isArray: true, isBuiltin: true });
101
101
  endpoint.defineParameter('include', { type: 'string', isArray: true, isBuiltin: true });
102
102
  endpoint.decodeInput = this.type.generateCodec('decode', {
103
+ partial: true,
103
104
  pick: endpoint.options.inputPickFields,
104
105
  omit: endpoint.options.inputOmitFields,
105
106
  operation: 'write',
@@ -14,8 +14,11 @@ class CrudResource extends resource_js_1.Resource {
14
14
  }
15
15
  }
16
16
  }
17
- getOperation(name) {
18
- return this.operations.get(name);
17
+ getOperation(operation) {
18
+ const op = this.operations.get(operation);
19
+ if (!op)
20
+ throw new Error(`${this.name} resource does not support "${operation}" operations`);
21
+ return op;
19
22
  }
20
23
  exportSchema(options) {
21
24
  const schema = super.exportSchema(options);
@@ -96,6 +96,7 @@ export class CollectionClass extends CrudResource {
96
96
  endpoint.defineParameter('omit', { type: 'string', isArray: true, isBuiltin: true });
97
97
  endpoint.defineParameter('include', { type: 'string', isArray: true, isBuiltin: true });
98
98
  endpoint.decodeInput = this.type.generateCodec('decode', {
99
+ partial: true,
99
100
  pick: endpoint.options.inputPickFields,
100
101
  omit: endpoint.options.inputOmitFields,
101
102
  operation: 'write',
@@ -11,8 +11,11 @@ export class CrudResource extends Resource {
11
11
  }
12
12
  }
13
13
  }
14
- getOperation(name) {
15
- return this.operations.get(name);
14
+ getOperation(operation) {
15
+ const op = this.operations.get(operation);
16
+ if (!op)
17
+ throw new Error(`${this.name} resource does not support "${operation}" operations`);
18
+ return op;
16
19
  }
17
20
  exportSchema(options) {
18
21
  const schema = super.exportSchema(options);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opra/common",
3
- "version": "0.31.0",
3
+ "version": "0.31.1",
4
4
  "description": "Opra common package",
5
5
  "author": "Panates",
6
6
  "license": "MIT",
@@ -7,7 +7,7 @@ import { Resource } from './resource.js';
7
7
  export declare abstract class CrudResource extends Resource {
8
8
  operations: ResponsiveMap<CrudOperation>;
9
9
  protected constructor(parent: ApiDocument | Container, init: Resource.InitArguments);
10
- getOperation(name: string): CrudOperation | undefined;
10
+ getOperation(operation: string): CrudOperation | undefined;
11
11
  exportSchema(options?: {
12
12
  webSafe?: boolean;
13
13
  }): OpraSchema.ResourceBase & {