@opra/common 1.2.1 → 1.2.2
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/index.cjs +5 -5
- package/browser/index.mjs +5 -5
- package/cjs/document/api-document.js +2 -1
- package/cjs/document/common/api-base.js +2 -2
- package/cjs/document/common/value.js +2 -2
- package/cjs/document/data-type/api-field.js +2 -2
- package/cjs/document/data-type/complex-type.js +5 -5
- package/cjs/document/data-type/data-type.js +2 -2
- package/cjs/document/data-type/enum-type.js +4 -3
- package/cjs/document/data-type/mapped-type.js +4 -4
- package/cjs/document/data-type/mixin-type.js +2 -1
- package/cjs/document/data-type/simple-type.js +4 -3
- package/cjs/document/decorators/complex-type.decorator.js +2 -3
- package/cjs/document/decorators/http-controller.decorator.js +5 -7
- package/cjs/document/decorators/http-operation.decorator.js +1 -3
- package/cjs/document/decorators/rpc-controller.decorator.js +5 -7
- package/cjs/document/decorators/rpc-operation.decorator.js +2 -3
- package/cjs/document/decorators/simple-type.decorator.js +2 -4
- package/cjs/document/factory/http-api.factory.js +2 -1
- package/cjs/document/factory/rpc-api.factory.js +2 -1
- package/cjs/document/http/http-controller.js +2 -1
- package/cjs/document/http/http-media-type.js +2 -2
- package/cjs/document/http/http-multipart-field.js +2 -2
- package/cjs/document/http/http-operation-response.js +2 -2
- package/cjs/document/http/http-operation.js +2 -1
- package/cjs/document/http/http-parameter.js +2 -2
- package/cjs/document/http/http-request-body.js +2 -2
- package/cjs/document/rpc/rpc-controller.js +2 -1
- package/cjs/document/rpc/rpc-header.js +2 -2
- package/cjs/document/rpc/rpc-operation-response.js +2 -2
- package/cjs/document/rpc/rpc-operation.js +4 -4
- package/cjs/exception/opra-exception.js +4 -4
- package/cjs/filter/filter-rules.js +2 -1
- package/cjs/helpers/function-utils.js +2 -2
- package/cjs/helpers/object-utils.js +7 -48
- package/cjs/helpers/type-guards.js +0 -16
- package/esm/document/api-document.js +2 -1
- package/esm/document/common/api-base.js +1 -1
- package/esm/document/common/value.js +1 -1
- package/esm/document/data-type/api-field.js +1 -1
- package/esm/document/data-type/complex-type.js +1 -1
- package/esm/document/data-type/data-type.js +1 -1
- package/esm/document/data-type/enum-type.js +2 -1
- package/esm/document/data-type/mapped-type.js +1 -1
- package/esm/document/data-type/mixin-type.js +2 -1
- package/esm/document/data-type/simple-type.js +3 -2
- package/esm/document/decorators/complex-type.decorator.js +2 -2
- package/esm/document/decorators/http-controller.decorator.js +1 -2
- package/esm/document/decorators/http-operation.decorator.js +1 -2
- package/esm/document/decorators/rpc-controller.decorator.js +2 -3
- package/esm/document/decorators/rpc-operation.decorator.js +2 -2
- package/esm/document/decorators/simple-type.decorator.js +2 -3
- package/esm/document/factory/http-api.factory.js +2 -1
- package/esm/document/factory/rpc-api.factory.js +2 -1
- package/esm/document/http/http-controller.js +2 -1
- package/esm/document/http/http-media-type.js +1 -1
- package/esm/document/http/http-multipart-field.js +1 -1
- package/esm/document/http/http-operation-response.js +1 -1
- package/esm/document/http/http-operation.js +2 -1
- package/esm/document/http/http-parameter.js +1 -1
- package/esm/document/http/http-request-body.js +1 -1
- package/esm/document/rpc/rpc-controller.js +2 -1
- package/esm/document/rpc/rpc-header.js +1 -1
- package/esm/document/rpc/rpc-operation-response.js +1 -1
- package/esm/document/rpc/rpc-operation.js +1 -1
- package/esm/exception/opra-exception.js +1 -1
- package/esm/filter/filter-rules.js +2 -1
- package/esm/helpers/function-utils.js +1 -1
- package/esm/helpers/object-utils.js +4 -41
- package/esm/helpers/type-guards.js +0 -13
- package/package.json +2 -4
- package/types/helpers/object-utils.d.ts +0 -4
- package/types/helpers/type-guards.d.ts +0 -4
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.OpraException = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const objects_1 = require("@jsopen/objects");
|
|
5
|
+
const index_js_1 = require("../i18n/index.js");
|
|
6
6
|
/**
|
|
7
7
|
* Defines the base Opra exception, which is handled by the default Exceptions Handler.
|
|
8
8
|
*/
|
|
@@ -28,11 +28,11 @@ class OpraException extends Error {
|
|
|
28
28
|
this.message = this.message || this.constructor.name;
|
|
29
29
|
}
|
|
30
30
|
toString() {
|
|
31
|
-
return
|
|
31
|
+
return index_js_1.i18n.deep(this.message);
|
|
32
32
|
}
|
|
33
33
|
toJSON() {
|
|
34
34
|
const env = process.env.NODE_ENV;
|
|
35
|
-
return (0,
|
|
35
|
+
return (0, objects_1.omitUndefined)({
|
|
36
36
|
message: this.message,
|
|
37
37
|
severity: this.severity,
|
|
38
38
|
system: this.system,
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FilterRules = void 0;
|
|
4
4
|
require("../polifils/array-find-last.js");
|
|
5
|
+
const objects_1 = require("@jsopen/objects");
|
|
5
6
|
const valgen_1 = require("valgen");
|
|
6
7
|
const index_js_1 = require("../exception/index.js");
|
|
7
8
|
const index_js_2 = require("../helpers/index.js");
|
|
@@ -26,7 +27,7 @@ class FilterRules {
|
|
|
26
27
|
const operators = typeof options?.operators === 'string'
|
|
27
28
|
? options.operators.split(/\s*[,| ]\s*/)
|
|
28
29
|
: options?.operators;
|
|
29
|
-
this._rules.set(fieldName, (0,
|
|
30
|
+
this._rules.set(fieldName, (0, objects_1.omitUndefined)({
|
|
30
31
|
...options,
|
|
31
32
|
operators,
|
|
32
33
|
}));
|
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.resolveThunk = resolveThunk;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
+
const objects_1 = require("@jsopen/objects");
|
|
5
6
|
const putil_promisify_1 = tslib_1.__importDefault(require("putil-promisify"));
|
|
6
|
-
const type_guards_js_1 = require("./type-guards.js");
|
|
7
7
|
async function resolveThunk(thunk) {
|
|
8
8
|
thunk = putil_promisify_1.default.isPromise(thunk) ? await thunk : thunk;
|
|
9
9
|
if (typeof thunk === 'function') {
|
|
10
|
-
if ((0,
|
|
10
|
+
if ((0, objects_1.isConstructor)(thunk))
|
|
11
11
|
return thunk;
|
|
12
12
|
return await thunk();
|
|
13
13
|
}
|
|
@@ -1,57 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.cloneObject = cloneObject;
|
|
4
|
-
|
|
5
|
-
exports.omitNullish = omitNullish;
|
|
6
|
-
exports.isBuiltInObject = isBuiltInObject;
|
|
7
|
-
const tslib_1 = require("tslib");
|
|
8
|
-
const putil_isplainobject_1 = tslib_1.__importDefault(require("putil-isplainobject"));
|
|
9
|
-
const putil_merge_1 = tslib_1.__importDefault(require("putil-merge"));
|
|
4
|
+
const objects_1 = require("@jsopen/objects");
|
|
10
5
|
const constants_js_1 = require("../document/constants.js");
|
|
11
6
|
function cloneObject(obj, jsonOnly) {
|
|
12
|
-
return (0,
|
|
13
|
-
deep: v => (0,
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
return (0, objects_1.merge)({}, obj, {
|
|
8
|
+
deep: v => (0, objects_1.isPlainObject)(v) && !v[constants_js_1.DATATYPE_METADATA],
|
|
9
|
+
copyDescriptors: true,
|
|
10
|
+
ignoreUndefined: true,
|
|
11
|
+
filter(key, source) {
|
|
16
12
|
const v = source[key];
|
|
17
|
-
return !jsonOnly || (typeof v !== 'function' && (typeof v !== 'object' || (0,
|
|
13
|
+
return !jsonOnly || (typeof v !== 'function' && (typeof v !== 'object' || (0, objects_1.isPlainObject)(v) || Array.isArray(v)));
|
|
18
14
|
},
|
|
19
15
|
});
|
|
20
16
|
}
|
|
21
|
-
function omitUndefined(obj, recursive) {
|
|
22
|
-
if (!(obj && typeof obj === 'object'))
|
|
23
|
-
return obj;
|
|
24
|
-
for (const k of Object.keys(obj)) {
|
|
25
|
-
if (obj[k] === undefined)
|
|
26
|
-
delete obj[k];
|
|
27
|
-
else if (recursive && typeof obj[k] === 'object')
|
|
28
|
-
omitUndefined(obj[k]);
|
|
29
|
-
}
|
|
30
|
-
return obj;
|
|
31
|
-
}
|
|
32
|
-
function omitNullish(obj, recursive) {
|
|
33
|
-
if (!(obj && typeof obj === 'object'))
|
|
34
|
-
return obj;
|
|
35
|
-
for (const k of Object.keys(obj)) {
|
|
36
|
-
if (obj[k] == null)
|
|
37
|
-
delete obj[k];
|
|
38
|
-
else if (recursive && (0, putil_isplainobject_1.default)(obj[k]))
|
|
39
|
-
omitNullish(obj[k]);
|
|
40
|
-
}
|
|
41
|
-
return obj;
|
|
42
|
-
}
|
|
43
|
-
const TypedArray = Object.getPrototypeOf(Uint8Array);
|
|
44
|
-
function isBuiltInObject(v) {
|
|
45
|
-
return (Array.isArray(v) ||
|
|
46
|
-
(typeof v === 'object' &&
|
|
47
|
-
(v instanceof Date ||
|
|
48
|
-
v instanceof RegExp ||
|
|
49
|
-
v instanceof Map ||
|
|
50
|
-
v instanceof Set ||
|
|
51
|
-
v instanceof ArrayBuffer ||
|
|
52
|
-
v instanceof SharedArrayBuffer ||
|
|
53
|
-
v instanceof Promise ||
|
|
54
|
-
v instanceof Error ||
|
|
55
|
-
v instanceof TypedArray ||
|
|
56
|
-
Buffer.isBuffer(v))));
|
|
57
|
-
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isConstructor = isConstructor;
|
|
4
3
|
exports.isStream = isStream;
|
|
5
4
|
exports.isReadable = isReadable;
|
|
6
5
|
exports.isWritable = isWritable;
|
|
@@ -8,15 +7,6 @@ exports.isReadableStream = isReadableStream;
|
|
|
8
7
|
exports.isBlob = isBlob;
|
|
9
8
|
exports.isFormData = isFormData;
|
|
10
9
|
exports.isURL = isURL;
|
|
11
|
-
exports.isIterable = isIterable;
|
|
12
|
-
exports.isAsyncIterable = isAsyncIterable;
|
|
13
|
-
function isConstructor(fn) {
|
|
14
|
-
return (typeof fn === 'function' &&
|
|
15
|
-
fn.prototype &&
|
|
16
|
-
fn.prototype.constructor === fn &&
|
|
17
|
-
fn.prototype.constructor.name !== 'Function' &&
|
|
18
|
-
fn.prototype.constructor.name !== 'embedded');
|
|
19
|
-
}
|
|
20
10
|
function isStream(x) {
|
|
21
11
|
return x !== null && typeof x === 'object' && typeof x.pipe === 'function';
|
|
22
12
|
}
|
|
@@ -49,9 +39,3 @@ function isFormData(x) {
|
|
|
49
39
|
function isURL(x) {
|
|
50
40
|
return x !== null && typeof x == 'object' && typeof x.host === 'string' && typeof x.href === 'string';
|
|
51
41
|
}
|
|
52
|
-
function isIterable(x) {
|
|
53
|
-
return Symbol.iterator in x;
|
|
54
|
-
}
|
|
55
|
-
function isAsyncIterable(x) {
|
|
56
|
-
return Symbol.asyncIterator in x;
|
|
57
|
-
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
var _a;
|
|
2
|
+
import { omitUndefined } from '@jsopen/objects';
|
|
2
3
|
import { md5 } from 'super-fast-md5';
|
|
3
|
-
import { cloneObject,
|
|
4
|
+
import { cloneObject, ResponsiveMap } from '../helpers/index.js';
|
|
4
5
|
import { OpraSchema } from '../schema/index.js';
|
|
5
6
|
import { DataTypeMap } from './common/data-type-map.js';
|
|
6
7
|
import { DocumentElement } from './common/document-element.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { omitUndefined } from '@jsopen/objects';
|
|
1
2
|
import { asMutable } from 'ts-gems';
|
|
2
|
-
import { omitUndefined } from '../../helpers/index.js';
|
|
3
3
|
import { DocumentElement } from '../common/document-element.js';
|
|
4
4
|
import { DECORATOR } from '../constants.js';
|
|
5
5
|
import { ApiFieldDecorator } from '../decorators/api-field-decorator.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
|
+
import { omitUndefined } from '@jsopen/objects';
|
|
2
3
|
import { asMutable } from 'ts-gems';
|
|
3
|
-
import { omitUndefined } from '../../helpers/index.js';
|
|
4
4
|
import { OpraSchema } from '../../schema/index.js';
|
|
5
5
|
import { DocumentInitContext } from '../common/document-init-context.js';
|
|
6
6
|
import { DECORATOR } from '../constants.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { omitUndefined } from '@jsopen/objects';
|
|
1
2
|
import { asMutable } from 'ts-gems';
|
|
2
|
-
import { omitUndefined } from '../../helpers/index.js';
|
|
3
3
|
import { DocumentElement } from '../common/document-element.js';
|
|
4
4
|
import { CLASS_NAME_PATTERN } from '../constants.js';
|
|
5
5
|
import { colorFgMagenta, colorFgYellow, colorReset, nodeInspectCustom } from '../utils/inspect.util.js';
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
|
+
import { omitUndefined } from '@jsopen/objects';
|
|
2
3
|
import { asMutable } from 'ts-gems';
|
|
3
4
|
import { vg } from 'valgen';
|
|
4
|
-
import { cloneObject
|
|
5
|
+
import { cloneObject } from '../../helpers/index.js';
|
|
5
6
|
import { OpraSchema } from '../../schema/index.js';
|
|
6
7
|
import { DATATYPE_METADATA, DECORATOR } from '../constants.js';
|
|
7
8
|
import { DataType } from './data-type.js';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
|
+
import { omitUndefined } from '@jsopen/objects';
|
|
2
3
|
import { asMutable } from 'ts-gems';
|
|
3
|
-
import { omitUndefined } from '../../helpers/index.js';
|
|
4
4
|
import { OpraSchema } from '../../schema/index.js';
|
|
5
5
|
import { ApiField } from './api-field.js';
|
|
6
6
|
import { ComplexTypeBase } from './complex-type-base.js';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
|
+
import { omitUndefined } from '@jsopen/objects';
|
|
2
3
|
import { asMutable } from 'ts-gems';
|
|
3
|
-
import { inheritPropertyInitializers, mergePrototype
|
|
4
|
+
import { inheritPropertyInitializers, mergePrototype } from '../../helpers/index.js';
|
|
4
5
|
import { OpraSchema } from '../../schema/index.js';
|
|
5
6
|
import { DATATYPE_METADATA, DECORATOR } from '../constants.js';
|
|
6
7
|
import { ApiField } from './api-field.js';
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import 'reflect-metadata';
|
|
2
|
+
import { omitUndefined } from '@jsopen/objects';
|
|
2
3
|
import { asMutable } from 'ts-gems';
|
|
3
4
|
import { isAny } from 'valgen';
|
|
4
|
-
import { cloneObject
|
|
5
|
+
import { cloneObject } from '../../helpers/index.js';
|
|
5
6
|
import { OpraSchema } from '../../schema/index.js';
|
|
6
7
|
import { DECORATOR } from '../constants.js';
|
|
7
8
|
import { AttributeDecoratorFactory, SimpleTypeDecoratorFactory } from '../decorators/simple-type.decorator.js';
|
|
@@ -93,7 +94,7 @@ class SimpleTypeClass extends DataType {
|
|
|
93
94
|
});
|
|
94
95
|
if (Object.keys(this.ownNameMappings).length)
|
|
95
96
|
out.nameMappings = { ...this.ownNameMappings };
|
|
96
|
-
return out;
|
|
97
|
+
return omitUndefined(out, true);
|
|
97
98
|
}
|
|
98
99
|
}
|
|
99
100
|
SimpleType.prototype = SimpleTypeClass.prototype;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import omit from '
|
|
1
|
+
import { omit } from '@jsopen/objects';
|
|
2
2
|
import { OpraSchema } from '../../schema/index.js';
|
|
3
3
|
import { CLASS_NAME_PATTERN, DATATYPE_METADATA, EXTRACT_TYPENAME_PATTERN } from '../constants.js';
|
|
4
4
|
export function ComplexTypeDecorator(options) {
|
|
@@ -23,6 +23,6 @@ export function ComplexTypeDecorator(options) {
|
|
|
23
23
|
metadata.name = name;
|
|
24
24
|
// Merge options
|
|
25
25
|
if (options)
|
|
26
|
-
Object.assign(metadata, omit(options, ['
|
|
26
|
+
Object.assign(metadata, omit(options, ['name']));
|
|
27
27
|
};
|
|
28
28
|
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import omit from '
|
|
2
|
-
import merge from 'putil-merge';
|
|
1
|
+
import { merge, omit } from '@jsopen/objects';
|
|
3
2
|
import { OpraSchema } from '../../schema/index.js';
|
|
4
3
|
import { HTTP_CONTROLLER_METADATA } from '../constants.js';
|
|
5
4
|
const CLASS_NAME_PATTERN = /^(.*)(Controller)$/;
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import omit from 'lodash.omit';
|
|
2
1
|
import { MimeTypes } from '../../enums/index.js';
|
|
3
2
|
import { OpraSchema } from '../../schema/index.js';
|
|
4
3
|
import { HTTP_CONTROLLER_METADATA } from '../constants.js';
|
|
@@ -10,8 +9,8 @@ export function HttpOperationDecoratorFactory(decoratorChain, options) {
|
|
|
10
9
|
if (typeof propertyKey !== 'string')
|
|
11
10
|
throw new TypeError(`Symbol properties can not be decorated`);
|
|
12
11
|
const operationMetadata = {
|
|
12
|
+
...options,
|
|
13
13
|
kind: OpraSchema.HttpOperation.Kind,
|
|
14
|
-
...omit(options, ['kind']),
|
|
15
14
|
};
|
|
16
15
|
const controllerMetadata = (Reflect.getOwnMetadata(HTTP_CONTROLLER_METADATA, target.constructor) ||
|
|
17
16
|
{});
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import
|
|
2
|
-
import merge from 'putil-merge';
|
|
1
|
+
import { merge } from '@jsopen/objects';
|
|
3
2
|
import { OpraSchema } from '../../schema/index.js';
|
|
4
3
|
import { RPC_CONTROLLER_METADATA } from '../constants.js';
|
|
5
4
|
const CLASS_NAME_PATTERN = /^(.*)(Controller)$/;
|
|
@@ -21,10 +20,10 @@ export function RpcControllerDecoratorFactory(options) {
|
|
|
21
20
|
if (oldMetadata)
|
|
22
21
|
merge(metadata, oldMetadata, { deep: true });
|
|
23
22
|
merge(metadata, {
|
|
23
|
+
...options,
|
|
24
24
|
kind: OpraSchema.RpcController.Kind,
|
|
25
25
|
name,
|
|
26
26
|
path: name,
|
|
27
|
-
...omit(options, ['kind', 'name', 'instance', 'endpoints', 'key']),
|
|
28
27
|
}, { deep: true });
|
|
29
28
|
Reflect.defineMetadata(RPC_CONTROLLER_METADATA, metadata, target);
|
|
30
29
|
for (const fn of decoratorChain)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import omit from '
|
|
1
|
+
import { omit } from '@jsopen/objects';
|
|
2
2
|
import { OpraSchema } from '../../schema/index.js';
|
|
3
3
|
import { RPC_CONTROLLER_METADATA } from '../constants.js';
|
|
4
4
|
const augmentationRegistry = [];
|
|
@@ -13,8 +13,8 @@ export function RpcOperationDecoratorFactory(decoratorChain, payloadType, option
|
|
|
13
13
|
const operationMetadata = {
|
|
14
14
|
kind: OpraSchema.RpcOperation.Kind,
|
|
15
15
|
channel: propertyKey,
|
|
16
|
-
...omit(options, ['kind']),
|
|
17
16
|
payloadType,
|
|
17
|
+
...omit(options, ['kind', 'payloadType']),
|
|
18
18
|
};
|
|
19
19
|
const controllerMetadata = (Reflect.getOwnMetadata(RPC_CONTROLLER_METADATA, target.constructor) ||
|
|
20
20
|
{});
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import omit from 'lodash.omit';
|
|
2
1
|
import { OpraSchema } from '../../schema/index.js';
|
|
3
2
|
import { CLASS_NAME_PATTERN, DATATYPE_METADATA, EXTRACT_TYPENAME_PATTERN } from '../constants.js';
|
|
4
3
|
export function SimpleTypeDecoratorFactory(options) {
|
|
@@ -20,10 +19,10 @@ export function SimpleTypeDecoratorFactory(options) {
|
|
|
20
19
|
}
|
|
21
20
|
}
|
|
22
21
|
const metadata = Reflect.getOwnMetadata(DATATYPE_METADATA, target) || {};
|
|
22
|
+
if (options)
|
|
23
|
+
Object.assign(metadata, options);
|
|
23
24
|
metadata.kind = OpraSchema.SimpleType.Kind;
|
|
24
25
|
metadata.name = name;
|
|
25
|
-
if (options)
|
|
26
|
-
Object.assign(metadata, omit(options, ['kind', 'name']));
|
|
27
26
|
Reflect.defineMetadata(DATATYPE_METADATA, metadata, target);
|
|
28
27
|
};
|
|
29
28
|
decorator.Example = (value, description) => {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { isConstructor
|
|
1
|
+
import { isConstructor } from '@jsopen/objects';
|
|
2
|
+
import { resolveThunk } from '../../helpers/index.js';
|
|
2
3
|
import { HTTP_CONTROLLER_METADATA } from '../constants.js';
|
|
3
4
|
import { HttpApi } from '../http/http-api.js';
|
|
4
5
|
import { HttpController } from '../http/http-controller.js';
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { isConstructor
|
|
1
|
+
import { isConstructor } from '@jsopen/objects';
|
|
2
|
+
import { resolveThunk } from '../../helpers/index.js';
|
|
2
3
|
import { RPC_CONTROLLER_METADATA } from '../constants.js';
|
|
3
4
|
import { RpcApi } from '../rpc/rpc-api.js';
|
|
4
5
|
import { RpcController } from '../rpc/rpc-controller.js';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import nodePath from 'node:path';
|
|
2
|
+
import { omitUndefined } from '@jsopen/objects';
|
|
2
3
|
import { asMutable } from 'ts-gems';
|
|
3
|
-
import {
|
|
4
|
+
import { ResponsiveMap } from '../../helpers/index.js';
|
|
4
5
|
import { OpraSchema } from '../../schema/index.js';
|
|
5
6
|
import { DataTypeMap } from '../common/data-type-map.js';
|
|
6
7
|
import { DocumentElement } from '../common/document-element.js';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import typeIs from '@browsery/type-is';
|
|
2
|
+
import { omitUndefined } from '@jsopen/objects';
|
|
2
3
|
import { asMutable } from 'ts-gems';
|
|
3
4
|
import { isAny, vg } from 'valgen';
|
|
4
|
-
import { omitUndefined } from '../../helpers/index.js';
|
|
5
5
|
import { DocumentElement } from '../common/document-element.js';
|
|
6
6
|
import { DataType } from '../data-type/data-type.js';
|
|
7
7
|
export const HttpMediaType = function (owner, initArgs) {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import nodePath from 'node:path';
|
|
2
|
+
import { omitUndefined } from '@jsopen/objects';
|
|
2
3
|
import { asMutable } from 'ts-gems';
|
|
3
|
-
import { cloneObject
|
|
4
|
+
import { cloneObject } from '../../helpers/index.js';
|
|
4
5
|
import { OpraSchema } from '../../schema/index.js';
|
|
5
6
|
import { DataTypeMap } from '../common/data-type-map.js';
|
|
6
7
|
import { DocumentElement } from '../common/document-element.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { omitUndefined } from '@jsopen/objects';
|
|
1
2
|
import { asMutable } from 'ts-gems';
|
|
2
|
-
import { omitUndefined } from '../../helpers/index.js';
|
|
3
3
|
import { Value } from '../common/value.js';
|
|
4
4
|
import { parseRegExp } from '../utils/parse-regexp.util.js';
|
|
5
5
|
export const HttpParameter = function (owner, initArgs) {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { omitUndefined } from '@jsopen/objects';
|
|
1
2
|
import { asMutable } from 'ts-gems';
|
|
2
|
-
import {
|
|
3
|
+
import { ResponsiveMap } from '../../helpers/index.js';
|
|
3
4
|
import { OpraSchema } from '../../schema/index.js';
|
|
4
5
|
import { DataTypeMap } from '../common/data-type-map.js';
|
|
5
6
|
import { DocumentElement } from '../common/document-element.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { omitUndefined } from '@jsopen/objects';
|
|
1
2
|
import { asMutable } from 'ts-gems';
|
|
2
|
-
import { omitUndefined } from '../../helpers/index.js';
|
|
3
3
|
import { Value } from '../common/value.js';
|
|
4
4
|
import { parseRegExp } from '../utils/parse-regexp.util.js';
|
|
5
5
|
export const RpcHeader = function (owner, initArgs) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { omitUndefined } from '@jsopen/objects';
|
|
1
2
|
import { asMutable } from 'ts-gems';
|
|
2
|
-
import { omitUndefined } from '../../helpers/index.js';
|
|
3
3
|
import { OpraSchema } from '../../schema/index.js';
|
|
4
4
|
import { DataTypeMap } from '../common/data-type-map.js';
|
|
5
5
|
import { DocumentElement } from '../common/document-element.js';
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import '../polifils/array-find-last.js';
|
|
2
|
+
import { omitUndefined } from '@jsopen/objects';
|
|
2
3
|
import { isString } from 'valgen';
|
|
3
4
|
import { OpraException } from '../exception/index.js';
|
|
4
|
-
import {
|
|
5
|
+
import { ResponsiveMap } from '../helpers/index.js';
|
|
5
6
|
import { translate } from '../i18n/index.js';
|
|
6
7
|
import { ArithmeticExpression, ArrayExpression, ComparisonExpression, Literal, LogicalExpression, ParenthesizedExpression, QualifiedIdentifier, } from './ast/index.js';
|
|
7
8
|
import { parse } from './parse.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { isConstructor } from '@jsopen/objects';
|
|
1
2
|
import promisify from 'putil-promisify';
|
|
2
|
-
import { isConstructor } from './type-guards.js';
|
|
3
3
|
export async function resolveThunk(thunk) {
|
|
4
4
|
thunk = promisify.isPromise(thunk) ? await thunk : thunk;
|
|
5
5
|
if (typeof thunk === 'function') {
|
|
@@ -1,50 +1,13 @@
|
|
|
1
|
-
import isPlainObject from '
|
|
2
|
-
import merge from 'putil-merge';
|
|
1
|
+
import { isPlainObject, merge } from '@jsopen/objects';
|
|
3
2
|
import { DATATYPE_METADATA } from '../document/constants.js';
|
|
4
3
|
export function cloneObject(obj, jsonOnly) {
|
|
5
4
|
return merge({}, obj, {
|
|
6
5
|
deep: v => isPlainObject(v) && !v[DATATYPE_METADATA],
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
copyDescriptors: true,
|
|
7
|
+
ignoreUndefined: true,
|
|
8
|
+
filter(key, source) {
|
|
9
9
|
const v = source[key];
|
|
10
10
|
return !jsonOnly || (typeof v !== 'function' && (typeof v !== 'object' || isPlainObject(v) || Array.isArray(v)));
|
|
11
11
|
},
|
|
12
12
|
});
|
|
13
13
|
}
|
|
14
|
-
export function omitUndefined(obj, recursive) {
|
|
15
|
-
if (!(obj && typeof obj === 'object'))
|
|
16
|
-
return obj;
|
|
17
|
-
for (const k of Object.keys(obj)) {
|
|
18
|
-
if (obj[k] === undefined)
|
|
19
|
-
delete obj[k];
|
|
20
|
-
else if (recursive && typeof obj[k] === 'object')
|
|
21
|
-
omitUndefined(obj[k]);
|
|
22
|
-
}
|
|
23
|
-
return obj;
|
|
24
|
-
}
|
|
25
|
-
export function omitNullish(obj, recursive) {
|
|
26
|
-
if (!(obj && typeof obj === 'object'))
|
|
27
|
-
return obj;
|
|
28
|
-
for (const k of Object.keys(obj)) {
|
|
29
|
-
if (obj[k] == null)
|
|
30
|
-
delete obj[k];
|
|
31
|
-
else if (recursive && isPlainObject(obj[k]))
|
|
32
|
-
omitNullish(obj[k]);
|
|
33
|
-
}
|
|
34
|
-
return obj;
|
|
35
|
-
}
|
|
36
|
-
const TypedArray = Object.getPrototypeOf(Uint8Array);
|
|
37
|
-
export function isBuiltInObject(v) {
|
|
38
|
-
return (Array.isArray(v) ||
|
|
39
|
-
(typeof v === 'object' &&
|
|
40
|
-
(v instanceof Date ||
|
|
41
|
-
v instanceof RegExp ||
|
|
42
|
-
v instanceof Map ||
|
|
43
|
-
v instanceof Set ||
|
|
44
|
-
v instanceof ArrayBuffer ||
|
|
45
|
-
v instanceof SharedArrayBuffer ||
|
|
46
|
-
v instanceof Promise ||
|
|
47
|
-
v instanceof Error ||
|
|
48
|
-
v instanceof TypedArray ||
|
|
49
|
-
Buffer.isBuffer(v))));
|
|
50
|
-
}
|
|
@@ -1,10 +1,3 @@
|
|
|
1
|
-
export function isConstructor(fn) {
|
|
2
|
-
return (typeof fn === 'function' &&
|
|
3
|
-
fn.prototype &&
|
|
4
|
-
fn.prototype.constructor === fn &&
|
|
5
|
-
fn.prototype.constructor.name !== 'Function' &&
|
|
6
|
-
fn.prototype.constructor.name !== 'embedded');
|
|
7
|
-
}
|
|
8
1
|
export function isStream(x) {
|
|
9
2
|
return x !== null && typeof x === 'object' && typeof x.pipe === 'function';
|
|
10
3
|
}
|
|
@@ -37,9 +30,3 @@ export function isFormData(x) {
|
|
|
37
30
|
export function isURL(x) {
|
|
38
31
|
return x !== null && typeof x == 'object' && typeof x.host === 'string' && typeof x.href === 'string';
|
|
39
32
|
}
|
|
40
|
-
export function isIterable(x) {
|
|
41
|
-
return Symbol.iterator in x;
|
|
42
|
-
}
|
|
43
|
-
export function isAsyncIterable(x) {
|
|
44
|
-
return Symbol.asyncIterator in x;
|
|
45
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opra/common",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2",
|
|
4
4
|
"description": "Opra common package",
|
|
5
5
|
"author": "Panates",
|
|
6
6
|
"license": "MIT",
|
|
@@ -10,10 +10,8 @@
|
|
|
10
10
|
"@browsery/http-parser": "^0.5.9-r1",
|
|
11
11
|
"@browsery/i18next": "^23.12.3-r1",
|
|
12
12
|
"@browsery/type-is": "^1.6.18-r5",
|
|
13
|
+
"@jsopen/objects": "^1.4.2",
|
|
13
14
|
"fast-tokenizer": "^1.7.0",
|
|
14
|
-
"lodash.omit": "^4.5.0",
|
|
15
|
-
"putil-isplainobject": "^1.1.5",
|
|
16
|
-
"putil-merge": "^3.13.0",
|
|
17
15
|
"putil-promisify": "^1.10.1",
|
|
18
16
|
"putil-varhelpers": "^1.6.5",
|
|
19
17
|
"reflect-metadata": "^0.2.2",
|
|
@@ -1,5 +1 @@
|
|
|
1
|
-
import type { DeeperOmitTypes } from 'ts-gems';
|
|
2
1
|
export declare function cloneObject<T extends {}>(obj: T, jsonOnly?: boolean): T;
|
|
3
|
-
export declare function omitUndefined<T>(obj: T, recursive?: boolean): T;
|
|
4
|
-
export declare function omitNullish<T>(obj: T, recursive?: boolean): DeeperOmitTypes<T, null | undefined>;
|
|
5
|
-
export declare function isBuiltInObject(v: any): boolean;
|
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { Readable, Stream } from 'stream';
|
|
2
|
-
import type { Type } from 'ts-gems';
|
|
3
|
-
export declare function isConstructor(fn: any): fn is Type;
|
|
4
2
|
export declare function isStream(x: any): x is Stream;
|
|
5
3
|
export declare function isReadable(x: any): x is Readable;
|
|
6
4
|
export declare function isWritable(x: any): x is Readable;
|
|
@@ -8,5 +6,3 @@ export declare function isReadableStream(x: any): x is ReadableStream;
|
|
|
8
6
|
export declare function isBlob(x: any): x is Blob;
|
|
9
7
|
export declare function isFormData(x: any): x is FormData;
|
|
10
8
|
export declare function isURL(x: any): x is URL;
|
|
11
|
-
export declare function isIterable<T = unknown>(x: any): x is Iterable<T>;
|
|
12
|
-
export declare function isAsyncIterable<T = unknown>(x: any): x is AsyncIterableIterator<T>;
|