@aeriajs/common 0.0.88 → 0.0.90

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.
@@ -11,6 +11,7 @@ exports.endpointError = endpointError;
11
11
  const isEndpointError = (object) => {
12
12
  return object
13
13
  && object.error
14
+ && typeof object.error === 'object'
14
15
  && (types_1.ERROR_SYMBOL in object.error || types_1.ERROR_SYMBOL_DESCRIPTION in object.error);
15
16
  };
16
17
  exports.isEndpointError = isEndpointError;
@@ -6,5 +6,5 @@ export const endpointError = (value) => {
6
6
  }, value));
7
7
  };
8
8
  export const isEndpointError = (object) => {
9
- return object && object.error && (ERROR_SYMBOL in object.error || ERROR_SYMBOL_DESCRIPTION in object.error);
9
+ return object && object.error && typeof object.error === "object" && (ERROR_SYMBOL in object.error || ERROR_SYMBOL_DESCRIPTION in object.error);
10
10
  };
package/dist/index.d.ts CHANGED
@@ -14,7 +14,6 @@ export * from './getMissingProperties.js';
14
14
  export * from './getReferenceProperty.js';
15
15
  export * from './getValueFromPath.js';
16
16
  export * from './http.js';
17
- export * from './isEmptyObject.js';
18
17
  export * from './isGranted.js';
19
18
  export * from './isObjectId.js';
20
19
  export * from './isReference.js';
package/dist/index.js CHANGED
@@ -30,7 +30,6 @@ __exportStar(require("./getMissingProperties.js"), exports);
30
30
  __exportStar(require("./getReferenceProperty.js"), exports);
31
31
  __exportStar(require("./getValueFromPath.js"), exports);
32
32
  __exportStar(require("./http.js"), exports);
33
- __exportStar(require("./isEmptyObject.js"), exports);
34
33
  __exportStar(require("./isGranted.js"), exports);
35
34
  __exportStar(require("./isObjectId.js"), exports);
36
35
  __exportStar(require("./isReference.js"), exports);
package/dist/index.mjs CHANGED
@@ -15,7 +15,6 @@ export * from "./getMissingProperties.mjs";
15
15
  export * from "./getReferenceProperty.mjs";
16
16
  export * from "./getValueFromPath.mjs";
17
17
  export * from "./http.mjs";
18
- export * from "./isEmptyObject.mjs";
19
18
  export * from "./isGranted.mjs";
20
19
  export * from "./isObjectId.mjs";
21
20
  export * from "./isReference.mjs";
package/dist/schema.d.ts CHANGED
@@ -1,5 +1,4 @@
1
- import type { Property, ObjectToSchema, HTTPStatus } from '@aeriajs/types';
2
- export declare const fromLiteral: <const TObject, TRequired extends (keyof TObject & string)[]>(object: TObject, required?: TRequired) => ObjectToSchema<TObject, TRequired>;
1
+ import type { Property, HTTPStatus } from '@aeriajs/types';
3
2
  export declare const errorSchema: <const TObject extends Property>(object: TObject) => {
4
3
  readonly type: "object";
5
4
  readonly properties: {
package/dist/schema.js CHANGED
@@ -1,53 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.genericEndpointErrorSchema = exports.endpointErrorSchema = exports.resultSchema = exports.errorSchema = exports.fromLiteral = void 0;
4
- const mapValueToProperty = (value) => {
5
- if (value.constructor === Object) {
6
- return Object.assign({
7
- type: 'object',
8
- }, (0, exports.fromLiteral)(value));
9
- }
10
- if (value === Date) {
11
- return {
12
- type: 'string',
13
- format: 'date-time',
14
- };
15
- }
16
- if (Array.isArray(value)) {
17
- return {
18
- type: 'array',
19
- items: mapValueToProperty(value[0]),
20
- };
21
- }
22
- if (value && typeof value === 'string') {
23
- return {
24
- $ref: value,
25
- };
26
- }
27
- return {
28
- type: typeof value,
29
- };
30
- };
31
- const fromLiteral = (object, required) => {
32
- const entries = [];
33
- for (const propName in object) {
34
- const value = object[propName];
35
- if (value === null || value === undefined) {
36
- continue;
37
- }
38
- entries.push([
39
- propName,
40
- mapValueToProperty(value),
41
- ]);
42
- }
43
- const properties = Object.fromEntries(entries);
44
- return {
45
- type: 'object',
46
- required,
47
- properties,
48
- };
49
- };
50
- exports.fromLiteral = fromLiteral;
3
+ exports.genericEndpointErrorSchema = exports.endpointErrorSchema = exports.resultSchema = exports.errorSchema = void 0;
51
4
  const errorSchema = (object) => {
52
5
  return {
53
6
  type: 'object',
package/dist/schema.mjs CHANGED
@@ -1,50 +1,4 @@
1
1
  "use strict";
2
- const mapValueToProperty = (value) => {
3
- if (value.constructor === Object) {
4
- return Object.assign({
5
- type: "object"
6
- }, fromLiteral(value));
7
- }
8
- if (value === Date) {
9
- return {
10
- type: "string",
11
- format: "date-time"
12
- };
13
- }
14
- if (Array.isArray(value)) {
15
- return {
16
- type: "array",
17
- items: mapValueToProperty(value[0])
18
- };
19
- }
20
- if (value && typeof value === "string") {
21
- return {
22
- $ref: value
23
- };
24
- }
25
- return {
26
- type: typeof value
27
- };
28
- };
29
- export const fromLiteral = (object, required) => {
30
- const entries = [];
31
- for (const propName in object) {
32
- const value = object[propName];
33
- if (value === null || value === void 0) {
34
- continue;
35
- }
36
- entries.push([
37
- propName,
38
- mapValueToProperty(value)
39
- ]);
40
- }
41
- const properties = Object.fromEntries(entries);
42
- return {
43
- type: "object",
44
- required,
45
- properties
46
- };
47
- };
48
2
  export const errorSchema = (object) => {
49
3
  return {
50
4
  type: "object",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aeriajs/common",
3
- "version": "0.0.88",
3
+ "version": "0.0.90",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -31,7 +31,7 @@
31
31
  "bson": "^6.5.0"
32
32
  },
33
33
  "peerDependencies": {
34
- "@aeriajs/types": "^0.0.76",
34
+ "@aeriajs/types": "^0.0.78",
35
35
  "bson": "^6.5.0"
36
36
  },
37
37
  "scripts": {
@@ -1 +0,0 @@
1
- export declare const isEmptyObject: (object: any) => any;
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isEmptyObject = void 0;
4
- const isEmptyObject = (object) => {
5
- return object && Object.keys(object).length === 0 && object.constructor === Object;
6
- };
7
- exports.isEmptyObject = isEmptyObject;
@@ -1,4 +0,0 @@
1
- "use strict";
2
- export const isEmptyObject = (object) => {
3
- return object && Object.keys(object).length === 0 && object.constructor === Object;
4
- };