@opra/common 1.2.0 → 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.
Files changed (75) hide show
  1. package/browser/index.cjs +5 -5
  2. package/browser/index.mjs +5 -5
  3. package/cjs/document/api-document.js +2 -1
  4. package/cjs/document/common/api-base.js +2 -2
  5. package/cjs/document/common/value.js +2 -2
  6. package/cjs/document/data-type/api-field.js +4 -4
  7. package/cjs/document/data-type/complex-type.js +5 -5
  8. package/cjs/document/data-type/data-type.js +2 -2
  9. package/cjs/document/data-type/enum-type.js +4 -3
  10. package/cjs/document/data-type/mapped-type.js +4 -4
  11. package/cjs/document/data-type/mixin-type.js +2 -1
  12. package/cjs/document/data-type/simple-type.js +4 -3
  13. package/cjs/document/decorators/complex-type.decorator.js +2 -3
  14. package/cjs/document/decorators/http-controller.decorator.js +5 -7
  15. package/cjs/document/decorators/http-operation.decorator.js +1 -3
  16. package/cjs/document/decorators/rpc-controller.decorator.js +5 -7
  17. package/cjs/document/decorators/rpc-operation.decorator.js +2 -3
  18. package/cjs/document/decorators/simple-type.decorator.js +2 -4
  19. package/cjs/document/factory/http-api.factory.js +2 -1
  20. package/cjs/document/factory/rpc-api.factory.js +2 -1
  21. package/cjs/document/http/http-controller.js +2 -1
  22. package/cjs/document/http/http-media-type.js +2 -2
  23. package/cjs/document/http/http-multipart-field.js +2 -2
  24. package/cjs/document/http/http-operation-response.js +2 -2
  25. package/cjs/document/http/http-operation.js +2 -1
  26. package/cjs/document/http/http-parameter.js +2 -2
  27. package/cjs/document/http/http-request-body.js +2 -2
  28. package/cjs/document/rpc/rpc-controller.js +2 -1
  29. package/cjs/document/rpc/rpc-header.js +2 -2
  30. package/cjs/document/rpc/rpc-operation-response.js +2 -2
  31. package/cjs/document/rpc/rpc-operation.js +4 -4
  32. package/cjs/exception/opra-exception.js +4 -4
  33. package/cjs/filter/filter-rules.js +2 -1
  34. package/cjs/helpers/function-utils.js +2 -2
  35. package/cjs/helpers/object-utils.js +7 -48
  36. package/cjs/helpers/type-guards.js +0 -16
  37. package/esm/document/api-document.js +2 -1
  38. package/esm/document/common/api-base.js +1 -1
  39. package/esm/document/common/value.js +1 -1
  40. package/esm/document/data-type/api-field.js +3 -3
  41. package/esm/document/data-type/complex-type.js +1 -1
  42. package/esm/document/data-type/data-type.js +1 -1
  43. package/esm/document/data-type/enum-type.js +2 -1
  44. package/esm/document/data-type/mapped-type.js +1 -1
  45. package/esm/document/data-type/mixin-type.js +2 -1
  46. package/esm/document/data-type/simple-type.js +3 -2
  47. package/esm/document/decorators/complex-type.decorator.js +2 -2
  48. package/esm/document/decorators/http-controller.decorator.js +1 -2
  49. package/esm/document/decorators/http-operation.decorator.js +1 -2
  50. package/esm/document/decorators/rpc-controller.decorator.js +2 -3
  51. package/esm/document/decorators/rpc-operation.decorator.js +2 -2
  52. package/esm/document/decorators/simple-type.decorator.js +2 -3
  53. package/esm/document/factory/http-api.factory.js +2 -1
  54. package/esm/document/factory/rpc-api.factory.js +2 -1
  55. package/esm/document/http/http-controller.js +2 -1
  56. package/esm/document/http/http-media-type.js +1 -1
  57. package/esm/document/http/http-multipart-field.js +1 -1
  58. package/esm/document/http/http-operation-response.js +1 -1
  59. package/esm/document/http/http-operation.js +2 -1
  60. package/esm/document/http/http-parameter.js +1 -1
  61. package/esm/document/http/http-request-body.js +1 -1
  62. package/esm/document/rpc/rpc-controller.js +2 -1
  63. package/esm/document/rpc/rpc-header.js +1 -1
  64. package/esm/document/rpc/rpc-operation-response.js +1 -1
  65. package/esm/document/rpc/rpc-operation.js +1 -1
  66. package/esm/exception/opra-exception.js +1 -1
  67. package/esm/filter/filter-rules.js +2 -1
  68. package/esm/helpers/function-utils.js +1 -1
  69. package/esm/helpers/object-utils.js +4 -41
  70. package/esm/helpers/type-guards.js +0 -13
  71. package/package.json +2 -4
  72. package/types/document/data-type/api-field.d.ts +1 -1
  73. package/types/helpers/object-utils.d.ts +0 -4
  74. package/types/helpers/type-guards.d.ts +0 -4
  75. package/types/schema/data-type/field.interface.d.ts +2 -2
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RpcOperation = void 0;
4
+ const objects_1 = require("@jsopen/objects");
4
5
  const ts_gems_1 = require("ts-gems");
5
- const index_js_1 = require("../../helpers/index.js");
6
- const index_js_2 = require("../../schema/index.js");
6
+ const index_js_1 = require("../../schema/index.js");
7
7
  const data_type_map_js_1 = require("../common/data-type-map.js");
8
8
  const document_element_js_1 = require("../common/document-element.js");
9
9
  const constants_js_1 = require("../constants.js");
@@ -59,8 +59,8 @@ class RpcOperationClass extends document_element_js_1.DocumentElement {
59
59
  }
60
60
  }
61
61
  toJSON() {
62
- const out = (0, index_js_1.omitUndefined)({
63
- kind: index_js_2.OpraSchema.RpcOperation.Kind,
62
+ const out = (0, objects_1.omitUndefined)({
63
+ kind: index_js_1.OpraSchema.RpcOperation.Kind,
64
64
  description: this.description,
65
65
  channel: this.channel,
66
66
  payloadType: this.payloadType.name ? this.payloadType.name : this.payloadType.toJSON(),
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.OpraException = void 0;
4
- const index_js_1 = require("../helpers/index.js");
5
- const index_js_2 = require("../i18n/index.js");
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 index_js_2.i18n.deep(this.message);
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, index_js_1.omitUndefined)({
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, index_js_2.omitUndefined)({
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, type_guards_js_1.isConstructor)(thunk))
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
- exports.omitUndefined = omitUndefined;
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, putil_merge_1.default)({}, obj, {
13
- deep: v => (0, putil_isplainobject_1.default)(v) && !v[constants_js_1.DATATYPE_METADATA],
14
- descriptor: true,
15
- filter: (source, key) => {
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, putil_isplainobject_1.default)(v) || Array.isArray(v)));
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, omitUndefined, ResponsiveMap } from '../helpers/index.js';
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,4 +1,4 @@
1
- import { omitUndefined } from '../../helpers/index.js';
1
+ import { omitUndefined } from '@jsopen/objects';
2
2
  import { CLASS_NAME_PATTERN } from '../constants.js';
3
3
  import { DocumentElement } from './document-element.js';
4
4
  export class ApiBase extends DocumentElement {
@@ -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 './document-element.js';
4
4
  export const Value = function (owner, initArgs) {
5
5
  if (!this)
@@ -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';
@@ -32,7 +32,7 @@ export const ApiField = function (...args) {
32
32
  _this.fixed = initArgs.fixed;
33
33
  _this.required = initArgs.required;
34
34
  _this.exclusive = initArgs.exclusive;
35
- _this.localisation = initArgs.localisation;
35
+ _this.localization = initArgs.localization;
36
36
  _this.keyField = initArgs.keyField;
37
37
  _this.deprecated = initArgs.deprecated;
38
38
  _this.readonly = initArgs.readonly;
@@ -55,7 +55,7 @@ class ApiFieldClass extends DocumentElement {
55
55
  fixed: this.fixed,
56
56
  required: this.required || undefined,
57
57
  exclusive: this.exclusive || undefined,
58
- localisation: this.localisation || undefined,
58
+ localization: this.localization || undefined,
59
59
  keyField: this.keyField || undefined,
60
60
  deprecated: this.deprecated || undefined,
61
61
  readonly: this.readonly || undefined,
@@ -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, omitUndefined } from '../../helpers/index.js';
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, omitUndefined } from '../../helpers/index.js';
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, omitUndefined } from '../../helpers/index.js';
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 'lodash.omit';
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, ['kind', 'name', 'base', 'fields']));
26
+ Object.assign(metadata, omit(options, ['name']));
27
27
  };
28
28
  }
@@ -1,5 +1,4 @@
1
- import omit from 'lodash.omit';
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 omit from 'lodash.omit';
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 'lodash.omit';
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, resolveThunk } from '../../helpers/index.js';
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, resolveThunk } from '../../helpers/index.js';
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 { omitUndefined, ResponsiveMap } from '../../helpers/index.js';
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,4 +1,4 @@
1
- import { omitUndefined } from '../../helpers/index.js';
1
+ import { omitUndefined } from '@jsopen/objects';
2
2
  import { parseRegExp } from '../utils/parse-regexp.util.js';
3
3
  import { HttpMediaType } from './http-media-type.js';
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { omitUndefined } from '../../helpers/index.js';
1
+ import { omitUndefined } from '@jsopen/objects';
2
2
  import { HttpMediaType } from './http-media-type.js';
3
3
  import { HttpStatusRange } from './http-status-range.js';
4
4
  /**
@@ -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, omitUndefined } from '../../helpers/index.js';
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,4 +1,4 @@
1
- import { omitUndefined } from '../../helpers/index.js';
1
+ import { omitUndefined } from '@jsopen/objects';
2
2
  import { DocumentElement } from '../common/document-element.js';
3
3
  /**
4
4
  * @class HttpRequestBody
@@ -1,5 +1,6 @@
1
+ import { omitUndefined } from '@jsopen/objects';
1
2
  import { asMutable } from 'ts-gems';
2
- import { omitUndefined, ResponsiveMap } from '../../helpers/index.js';
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,4 +1,4 @@
1
- import { omitUndefined } from '../../helpers/index.js';
1
+ import { omitUndefined } from '@jsopen/objects';
2
2
  import { DocumentElement } from '../common/document-element.js';
3
3
  import { DataType } from '../data-type/data-type.js';
4
4
  /**
@@ -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,4 +1,4 @@
1
- import { omitUndefined } from '../helpers/index.js';
1
+ import { omitUndefined } from '@jsopen/objects';
2
2
  import { i18n } from '../i18n/index.js';
3
3
  /**
4
4
  * Defines the base Opra exception, which is handled by the default Exceptions Handler.
@@ -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 { omitUndefined, ResponsiveMap } from '../helpers/index.js';
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 'putil-isplainobject';
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
- descriptor: true,
8
- filter: (source, key) => {
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.0",
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",
@@ -62,7 +62,7 @@ declare class ApiFieldClass extends DocumentElement {
62
62
  readonly fixed?: any;
63
63
  readonly required?: boolean;
64
64
  readonly exclusive?: boolean;
65
- readonly localisation?: boolean;
65
+ readonly localization?: boolean;
66
66
  readonly keyField?: string;
67
67
  readonly deprecated?: boolean | string;
68
68
  readonly readonly?: boolean;