@aeriajs/common 0.0.90 → 0.0.92

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.
@@ -1,2 +1,2 @@
1
1
  import type { Property } from '@aeriajs/types';
2
- export declare const checkForUndefined: (property: Property, propertyName: string, what: Record<string, any>) => boolean;
2
+ export declare const checkForUndefined: (property: Property, propName: string, what: Record<string, unknown>) => boolean;
@@ -1,12 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.checkForUndefined = void 0;
4
- const checkForUndefined = (property, propertyName, what) => {
4
+ const checkForUndefined = (property, propName, what) => {
5
5
  if (property.readOnly || property.isTimestamp) {
6
6
  return false;
7
7
  }
8
- return what[propertyName] === null
9
- || what[propertyName] === undefined
10
- || what[propertyName] === '';
8
+ return what[propName] === null
9
+ || what[propName] === undefined
10
+ || what[propName] === '';
11
11
  };
12
12
  exports.checkForUndefined = checkForUndefined;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
- export const checkForUndefined = (property, propertyName, what) => {
2
+ export const checkForUndefined = (property, propName, what) => {
3
3
  if (property.readOnly || property.isTimestamp) {
4
4
  return false;
5
5
  }
6
- return what[propertyName] === null || what[propertyName] === void 0 || what[propertyName] === "";
6
+ return what[propName] === null || what[propName] === void 0 || what[propName] === "";
7
7
  };
@@ -1,2 +1,2 @@
1
1
  import type { Condition } from '@aeriajs/types';
2
- export declare const convertConditionToQuery: (condition: Condition, subject?: Record<string, any>) => Record<string, any>;
2
+ export declare const convertConditionToQuery: (condition: Condition, subject?: Record<string, unknown>) => Record<string, unknown>;
@@ -1,5 +1,5 @@
1
1
  export type MergeOptions = {
2
2
  arrays?: false;
3
- callback?: (key: string, leftVal: any, rightVal: any) => any;
3
+ callback?: (key: string, leftVal: unknown, rightVal: unknown) => unknown;
4
4
  };
5
- export declare const deepMerge: <const TLeft extends Record<string, any>, const TRight extends Record<string, any>>(left: TLeft, right: TRight, options?: MergeOptions) => TLeft & TRight;
5
+ export declare const deepMerge: <const TLeft, const TRight>(left: TLeft, right: TRight, options?: MergeOptions) => TLeft & TRight;
@@ -1,2 +1,2 @@
1
1
  import type { Description } from '@aeriajs/types';
2
- export declare const freshItem: (description: Pick<Description, "properties" | "freshItem">) => Record<string, any>;
2
+ export declare const freshItem: (description: Pick<Description, "properties" | "freshItem">) => Record<string, unknown>;
@@ -1,2 +1,2 @@
1
1
  import type { JsonSchema } from '@aeriajs/types';
2
- export declare const getMissingProperties: (what: Record<string, any>, schema: Omit<JsonSchema, "$id">, required: JsonSchema["required"]) => string[];
2
+ export declare const getMissingProperties: (what: Record<string, unknown>, schema: Omit<JsonSchema, "$id">, required: JsonSchema["required"]) => string[];
package/dist/http.d.ts CHANGED
@@ -1,20 +1,23 @@
1
- import type { RequestMethod } from '@aeriajs/types';
2
1
  export type RequestParams = Omit<RequestInit, 'headers'> & {
3
- method: RequestMethod;
4
- headers?: Partial<Record<string, string>>;
2
+ headers?: Record<string, string>;
5
3
  };
6
- export type RequestConfig<ResponseType = any> = {
4
+ export type RequestConfig = {
7
5
  params?: RequestParams;
8
- requestTransformer?: (...args: Parameters<typeof defaultRequestTransformer>) => Promise<ResponseType>;
6
+ requestTransformer?: (...args: Parameters<typeof defaultRequestTransformer>) => Promise<{
7
+ url: string;
8
+ params: RequestParams;
9
+ }>;
9
10
  responseTransformer?: typeof defaultResponseTransformer;
10
11
  };
11
- export declare const defaultRequestTransformer: (url: string, payload: any, params: RequestParams) => Promise<{
12
+ export declare const defaultRequestTransformer: (url: string, payload: unknown, params: RequestParams) => Promise<{
12
13
  url: string;
13
14
  params: RequestParams;
14
15
  }>;
15
16
  export declare const defaultResponseTransformer: (response: Awaited<ReturnType<typeof fetch>>) => Promise<Response & {
16
17
  data: unknown;
17
18
  }>;
18
- export declare const request: <ResponseType = any>(url: string, payload?: any, config?: RequestConfig<ResponseType>) => Promise<Omit<any, "data"> & {
19
- data: ResponseType;
19
+ export declare const request: <TResponseType = unknown>(url: string, payload?: unknown, config?: RequestConfig) => Promise<Response & {
20
+ data: unknown;
21
+ } & {
22
+ data: TResponseType;
20
23
  }>;
package/dist/http.js CHANGED
@@ -6,7 +6,7 @@ const defaultRequestTransformer = async (url, payload, params) => {
6
6
  url,
7
7
  params,
8
8
  };
9
- if (payload) {
9
+ if (typeof payload === 'string') {
10
10
  if (params.method === 'GET' || params.method === 'HEAD') {
11
11
  request.url += `?${new URLSearchParams(payload)}`;
12
12
  }
@@ -23,12 +23,12 @@ const defaultResponseTransformer = async (response) => {
23
23
  const result = response;
24
24
  result.data = await response.text();
25
25
  if (response.headers.get('content-type')?.startsWith('application/json')) {
26
- result.data = JSON.parse(result.data);
26
+ result.data = JSON.parse(String(result.data));
27
27
  }
28
28
  return result;
29
29
  };
30
30
  exports.defaultResponseTransformer = defaultResponseTransformer;
31
- const request = async (url, payload, config) => {
31
+ const request = async (url, payload, config = {}) => {
32
32
  const { requestTransformer = exports.defaultRequestTransformer, responseTransformer = exports.defaultResponseTransformer, params = {
33
33
  method: payload
34
34
  ? 'POST'
@@ -38,7 +38,7 @@ const request = async (url, payload, config) => {
38
38
  'content-type': 'application/json',
39
39
  }
40
40
  : {},
41
- }, } = config || {};
41
+ }, } = config;
42
42
  const transformedRequest = await requestTransformer(url, payload, params);
43
43
  const response = await fetch(transformedRequest.url, transformedRequest.params);
44
44
  const transformedResponse = await responseTransformer(response);
package/dist/http.mjs CHANGED
@@ -4,7 +4,7 @@ export const defaultRequestTransformer = async (url, payload, params) => {
4
4
  url,
5
5
  params
6
6
  };
7
- if (payload) {
7
+ if (typeof payload === "string") {
8
8
  if (params.method === "GET" || params.method === "HEAD") {
9
9
  request2.url += `?${new URLSearchParams(payload)}`;
10
10
  } else {
@@ -17,11 +17,11 @@ export const defaultResponseTransformer = async (response) => {
17
17
  const result = response;
18
18
  result.data = await response.text();
19
19
  if (response.headers.get("content-type")?.startsWith("application/json")) {
20
- result.data = JSON.parse(result.data);
20
+ result.data = JSON.parse(String(result.data));
21
21
  }
22
22
  return result;
23
23
  };
24
- export const request = async (url, payload, config) => {
24
+ export const request = async (url, payload, config = {}) => {
25
25
  const {
26
26
  requestTransformer = defaultRequestTransformer,
27
27
  responseTransformer = defaultResponseTransformer,
@@ -31,7 +31,7 @@ export const request = async (url, payload, config) => {
31
31
  "content-type": "application/json"
32
32
  } : {}
33
33
  }
34
- } = config || {};
34
+ } = config;
35
35
  const transformedRequest = await requestTransformer(url, payload, params);
36
36
  const response = await fetch(transformedRequest.url, transformedRequest.params);
37
37
  const transformedResponse = await responseTransformer(response);
package/dist/pipe.d.ts CHANGED
@@ -1,4 +1,4 @@
1
1
  export type PipeOptions = {
2
- returnFirst?: boolean | ((value: any) => any);
2
+ returnFirst?: boolean | ((value: unknown) => unknown);
3
3
  };
4
- export declare const pipe: <TFunction extends (...args: any) => any>(functions: TFunction[], options?: PipeOptions) => (value: Parameters<TFunction>[0], ...args: Parameters<TFunction> extends [unknown, ...infer Tail] ? Tail : []) => Promise<any>;
4
+ export declare const pipe: <TFunction extends (...args: any) => any>(functions: TFunction[], options?: PipeOptions) => (value: Parameters<TFunction>[0], ...args: Parameters<TFunction> extends [unknown, ...infer Tail] ? Tail : []) => Promise<{} | ReturnType<TFunction> | null>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aeriajs/common",
3
- "version": "0.0.90",
3
+ "version": "0.0.92",
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.78",
34
+ "@aeriajs/types": "^0.0.79",
35
35
  "bson": "^6.5.0"
36
36
  },
37
37
  "scripts": {