@opra/common 0.12.0 → 0.14.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.
- package/cjs/schema/implementation/data-type/data-type.js +4 -0
- package/cjs/schema/implementation/resource/collection-resource-info.js +8 -0
- package/cjs/schema/implementation/resource/singleton-resource-info.js +8 -0
- package/esm/schema/implementation/data-type/data-type.d.ts +1 -0
- package/esm/schema/implementation/data-type/data-type.js +4 -0
- package/esm/schema/implementation/resource/collection-resource-info.d.ts +1 -0
- package/esm/schema/implementation/resource/collection-resource-info.js +8 -0
- package/esm/schema/implementation/resource/singleton-resource-info.d.ts +1 -0
- package/esm/schema/implementation/resource/singleton-resource-info.js +8 -0
- package/package.json +2 -2
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DataType = void 0;
|
|
4
4
|
const clone_object_util_js_1 = require("../../utils/clone-object.util.js");
|
|
5
|
+
const builtin_data_types_js_1 = require("./builtin-data-types.js");
|
|
5
6
|
class DataType {
|
|
6
7
|
constructor(document, name, metadata) {
|
|
7
8
|
this._document = document;
|
|
@@ -23,6 +24,9 @@ class DataType {
|
|
|
23
24
|
get ctor() {
|
|
24
25
|
return this._metadata.ctor;
|
|
25
26
|
}
|
|
27
|
+
get isBuiltin() {
|
|
28
|
+
return builtin_data_types_js_1.builtInTypes.has(this._name);
|
|
29
|
+
}
|
|
26
30
|
parse(value) {
|
|
27
31
|
return this._metadata.parse ? this._metadata.parse(value) : value;
|
|
28
32
|
}
|
|
@@ -46,6 +46,14 @@ class CollectionResourceInfo extends resource_info_js_1.ResourceInfo {
|
|
|
46
46
|
get search() {
|
|
47
47
|
return this.metadata.search;
|
|
48
48
|
}
|
|
49
|
+
getHandlerNames() {
|
|
50
|
+
const out = [];
|
|
51
|
+
constants_js_1.collectionMethods.forEach(m => {
|
|
52
|
+
if (this.metadata[m])
|
|
53
|
+
out.push(m);
|
|
54
|
+
});
|
|
55
|
+
return out;
|
|
56
|
+
}
|
|
49
57
|
getHandler(method) {
|
|
50
58
|
const r = this.metadata[method];
|
|
51
59
|
return r && r.handler;
|
|
@@ -24,6 +24,14 @@ class SingletonResourceInfo extends resource_info_js_1.ResourceInfo {
|
|
|
24
24
|
get update() {
|
|
25
25
|
return this.metadata.update;
|
|
26
26
|
}
|
|
27
|
+
getHandlerNames() {
|
|
28
|
+
const out = [];
|
|
29
|
+
constants_js_1.singletonMethods.forEach(m => {
|
|
30
|
+
if (this.metadata[m])
|
|
31
|
+
out.push(m);
|
|
32
|
+
});
|
|
33
|
+
return out;
|
|
34
|
+
}
|
|
27
35
|
getSchema(jsonOnly) {
|
|
28
36
|
const out = super.getSchema(jsonOnly);
|
|
29
37
|
for (const k of constants_js_1.singletonMethods) {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { cloneObject } from '../../utils/clone-object.util.js';
|
|
2
|
+
import { builtInTypes } from './builtin-data-types.js';
|
|
2
3
|
export class DataType {
|
|
3
4
|
constructor(document, name, metadata) {
|
|
4
5
|
this._document = document;
|
|
@@ -20,6 +21,9 @@ export class DataType {
|
|
|
20
21
|
get ctor() {
|
|
21
22
|
return this._metadata.ctor;
|
|
22
23
|
}
|
|
24
|
+
get isBuiltin() {
|
|
25
|
+
return builtInTypes.has(this._name);
|
|
26
|
+
}
|
|
23
27
|
parse(value) {
|
|
24
28
|
return this._metadata.parse ? this._metadata.parse(value) : value;
|
|
25
29
|
}
|
|
@@ -16,6 +16,7 @@ export declare class CollectionResourceInfo extends ResourceInfo {
|
|
|
16
16
|
get update(): OpraSchema.UpdateMethodResolver | undefined;
|
|
17
17
|
get updateMany(): OpraSchema.UpdateManyMethodResolver | undefined;
|
|
18
18
|
get search(): OpraSchema.SearchMethodResolver | undefined;
|
|
19
|
+
getHandlerNames(): string[];
|
|
19
20
|
getHandler(method: string): Function;
|
|
20
21
|
getSchema(jsonOnly?: boolean): OpraSchema.CollectionResource;
|
|
21
22
|
}
|
|
@@ -43,6 +43,14 @@ export class CollectionResourceInfo extends ResourceInfo {
|
|
|
43
43
|
get search() {
|
|
44
44
|
return this.metadata.search;
|
|
45
45
|
}
|
|
46
|
+
getHandlerNames() {
|
|
47
|
+
const out = [];
|
|
48
|
+
collectionMethods.forEach(m => {
|
|
49
|
+
if (this.metadata[m])
|
|
50
|
+
out.push(m);
|
|
51
|
+
});
|
|
52
|
+
return out;
|
|
53
|
+
}
|
|
46
54
|
getHandler(method) {
|
|
47
55
|
const r = this.metadata[method];
|
|
48
56
|
return r && r.handler;
|
|
@@ -10,5 +10,6 @@ export declare class SingletonResourceInfo extends ResourceInfo {
|
|
|
10
10
|
get delete(): OpraSchema.MethodResolver | undefined;
|
|
11
11
|
get get(): OpraSchema.GetMethodResolver | undefined;
|
|
12
12
|
get update(): OpraSchema.UpdateMethodResolver | undefined;
|
|
13
|
+
getHandlerNames(): string[];
|
|
13
14
|
getSchema(jsonOnly?: boolean): OpraSchema.SingletonResource;
|
|
14
15
|
}
|
|
@@ -21,6 +21,14 @@ export class SingletonResourceInfo extends ResourceInfo {
|
|
|
21
21
|
get update() {
|
|
22
22
|
return this.metadata.update;
|
|
23
23
|
}
|
|
24
|
+
getHandlerNames() {
|
|
25
|
+
const out = [];
|
|
26
|
+
singletonMethods.forEach(m => {
|
|
27
|
+
if (this.metadata[m])
|
|
28
|
+
out.push(m);
|
|
29
|
+
});
|
|
30
|
+
return out;
|
|
31
|
+
}
|
|
24
32
|
getSchema(jsonOnly) {
|
|
25
33
|
const out = super.getSchema(jsonOnly);
|
|
26
34
|
for (const k of singletonMethods) {
|
package/package.json
CHANGED