core-services-sdk 1.3.37 → 1.3.39
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/package.json +2 -2
- package/src/http/HttpError.js +1 -1
- package/tests/http/HttpError.unit.test.js +2 -2
- package/tsconfig.json +3 -1
- package/types/core/combine-unique-arrays.d.ts +1 -1
- package/types/core/index.d.ts +9 -9
- package/types/core/normalize-array-operators.d.ts +1 -1
- package/types/core/normalize-min-max.d.ts +16 -10
- package/types/core/normalize-phone-number.d.ts +30 -24
- package/types/core/normalize-premitives-types-or-default.d.ts +17 -4
- package/types/core/normalize-to-array.d.ts +1 -1
- package/types/core/otp-generators.d.ts +22 -18
- package/types/core/regex-utils.d.ts +1 -1
- package/types/core/sanitize-objects.d.ts +13 -4
- package/types/crypto/crypto.d.ts +31 -18
- package/types/crypto/encryption.d.ts +14 -6
- package/types/crypto/index.d.ts +2 -2
- package/types/fastify/error-handlers/with-error-handling.d.ts +26 -15
- package/types/fastify/index.d.ts +2 -2
- package/types/http/HttpError.d.ts +3 -4
- package/types/http/http-method.d.ts +6 -6
- package/types/http/http.d.ts +58 -34
- package/types/http/index.d.ts +4 -4
- package/types/http/responseType.d.ts +6 -6
- package/types/ids/generators.d.ts +28 -28
- package/types/ids/index.d.ts +2 -2
- package/types/ids/prefixes.d.ts +54 -54
- package/types/index.d.ts +11 -11
- package/types/logger/get-logger.d.ts +23 -21
- package/types/logger/index.d.ts +1 -1
- package/types/mailer/index.d.ts +2 -2
- package/types/mailer/mailer.service.d.ts +29 -19
- package/types/mailer/transport.factory.d.ts +43 -43
- package/types/mongodb/connect.d.ts +12 -7
- package/types/mongodb/dsl-to-mongo.d.ts +2 -1
- package/types/mongodb/index.d.ts +5 -5
- package/types/mongodb/initialize-mongodb.d.ts +18 -13
- package/types/mongodb/paginate.d.ts +23 -13
- package/types/mongodb/validate-mongo-uri.d.ts +1 -1
- package/types/rabbit-mq/index.d.ts +1 -1
- package/types/rabbit-mq/rabbit-mq.d.ts +62 -37
- package/types/templates/index.d.ts +1 -1
- package/types/templates/template-loader.d.ts +7 -3
- package/types/util/context.d.ts +53 -53
- package/types/util/index.d.ts +6 -6
- package/types/util/mask-sensitive.d.ts +14 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "core-services-sdk",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.39",
|
|
4
4
|
"main": "src/index.js",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"types": "types/index.d.ts",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"test": "vitest run --coverage",
|
|
11
11
|
"format": "prettier --write .",
|
|
12
12
|
"bump": "node ./scripts/bump-version.js",
|
|
13
|
-
"build:types": "tsc --
|
|
13
|
+
"build:types": "tsc --project tsconfig.json && prettier --write ."
|
|
14
14
|
},
|
|
15
15
|
"repository": {
|
|
16
16
|
"type": "git",
|
package/src/http/HttpError.js
CHANGED
|
@@ -35,7 +35,7 @@ export class HttpError extends Error {
|
|
|
35
35
|
constructor(error = {}) {
|
|
36
36
|
const { code, status, message, extendInfo } = error
|
|
37
37
|
|
|
38
|
-
super(message ||
|
|
38
|
+
super(message || code || httpStatus[status] || 'Unknown error')
|
|
39
39
|
|
|
40
40
|
this.code = code
|
|
41
41
|
this.status = status
|
|
@@ -21,11 +21,11 @@ describe('HttpError', () => {
|
|
|
21
21
|
|
|
22
22
|
it('should fallback to default message from status if message is missing', () => {
|
|
23
23
|
const error = new HttpError({
|
|
24
|
-
code: '
|
|
24
|
+
code: 'Missing parameter x',
|
|
25
25
|
status: httpStatus.BAD_REQUEST,
|
|
26
26
|
})
|
|
27
27
|
|
|
28
|
-
expect(error.message).toBe(
|
|
28
|
+
expect(error.message).toBe('Missing parameter x')
|
|
29
29
|
expect(error.extendInfo).toBeUndefined()
|
|
30
30
|
})
|
|
31
31
|
|
package/tsconfig.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export function combineUniqueArrays(...lists: Array<any>[]): Array<any
|
|
1
|
+
export function combineUniqueArrays(...lists: Array<any>[]): Array<any>
|
package/types/core/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
5
|
-
export * from
|
|
6
|
-
export * from
|
|
7
|
-
export * from
|
|
8
|
-
export * from
|
|
9
|
-
export * from
|
|
1
|
+
export * from './regex-utils.js'
|
|
2
|
+
export * from './otp-generators.js'
|
|
3
|
+
export * from './sanitize-objects.js'
|
|
4
|
+
export * from './normalize-min-max.js'
|
|
5
|
+
export * from './normalize-to-array.js'
|
|
6
|
+
export * from './combine-unique-arrays.js'
|
|
7
|
+
export * from './normalize-phone-number.js'
|
|
8
|
+
export * from './normalize-array-operators.js'
|
|
9
|
+
export * from './normalize-premitives-types-or-default.js'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export function normalizeOperators(obj: any): any
|
|
1
|
+
export function normalizeOperators(obj: any): any
|
|
@@ -1,10 +1,16 @@
|
|
|
1
|
-
export function normalizeMinMax(
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
}
|
|
1
|
+
export function normalizeMinMax(
|
|
2
|
+
defaultMinMax: {
|
|
3
|
+
min: number
|
|
4
|
+
max: number
|
|
5
|
+
},
|
|
6
|
+
valuesMinMax:
|
|
7
|
+
| {
|
|
8
|
+
min?: number
|
|
9
|
+
max?: number
|
|
10
|
+
}
|
|
11
|
+
| null
|
|
12
|
+
| undefined,
|
|
13
|
+
): {
|
|
14
|
+
min: number
|
|
15
|
+
max: number
|
|
16
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/** Resolve libphonenumber regardless of interop shape */
|
|
2
|
-
export function getLib(): any
|
|
3
|
-
export function phoneUtil(): any
|
|
2
|
+
export function getLib(): any
|
|
3
|
+
export function phoneUtil(): any
|
|
4
4
|
/**
|
|
5
5
|
* Parse & validate an international number (must start with '+').
|
|
6
6
|
* @param {string} input
|
|
@@ -8,12 +8,12 @@ export function phoneUtil(): any;
|
|
|
8
8
|
* @throws {Error} If the number is invalid
|
|
9
9
|
*/
|
|
10
10
|
export function normalizePhoneOrThrowIntl(input: string): {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
11
|
+
e164: string
|
|
12
|
+
national: string
|
|
13
|
+
international: string
|
|
14
|
+
regionCode: string | undefined
|
|
15
|
+
type: number
|
|
16
|
+
}
|
|
17
17
|
/**
|
|
18
18
|
* Parse & validate a national number using a region hint.
|
|
19
19
|
* @param {string} input
|
|
@@ -21,13 +21,16 @@ export function normalizePhoneOrThrowIntl(input: string): {
|
|
|
21
21
|
* @returns {{e164:string,national:string,international:string,regionCode:string|undefined,type:number}}
|
|
22
22
|
* @throws {Error} If the number is invalid
|
|
23
23
|
*/
|
|
24
|
-
export function normalizePhoneOrThrowWithRegion(
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
24
|
+
export function normalizePhoneOrThrowWithRegion(
|
|
25
|
+
input: string,
|
|
26
|
+
defaultRegion: string,
|
|
27
|
+
): {
|
|
28
|
+
e164: string
|
|
29
|
+
national: string
|
|
30
|
+
international: string
|
|
31
|
+
regionCode: string | undefined
|
|
32
|
+
type: number
|
|
33
|
+
}
|
|
31
34
|
/**
|
|
32
35
|
* Smart normalization:
|
|
33
36
|
* - If input starts with '+', parse as international.
|
|
@@ -37,12 +40,15 @@ export function normalizePhoneOrThrowWithRegion(input: string, defaultRegion: st
|
|
|
37
40
|
* @returns {{e164:string,national:string,international:string,regionCode:string|undefined,type:number}}
|
|
38
41
|
* @throws {Error} If invalid or defaultRegion is missing for non-international input
|
|
39
42
|
*/
|
|
40
|
-
export function normalizePhoneOrThrow(
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
43
|
+
export function normalizePhoneOrThrow(
|
|
44
|
+
input: string,
|
|
45
|
+
opts?: {
|
|
46
|
+
defaultRegion?: string
|
|
47
|
+
},
|
|
48
|
+
): {
|
|
49
|
+
e164: string
|
|
50
|
+
national: string
|
|
51
|
+
international: string
|
|
52
|
+
regionCode: string | undefined
|
|
53
|
+
type: number
|
|
54
|
+
}
|
|
@@ -53,7 +53,11 @@
|
|
|
53
53
|
* {}
|
|
54
54
|
* )
|
|
55
55
|
*/
|
|
56
|
-
export function normalizeOrDefault<T>(
|
|
56
|
+
export function normalizeOrDefault<T>(
|
|
57
|
+
value: any,
|
|
58
|
+
isValid: (v: any) => boolean,
|
|
59
|
+
defaultValue: T,
|
|
60
|
+
): T
|
|
57
61
|
/**
|
|
58
62
|
* Normalize a value to a non-empty, trimmed string; otherwise return a default (also trimmed).
|
|
59
63
|
*
|
|
@@ -93,7 +97,10 @@ export function normalizeOrDefault<T>(value: any, isValid: (v: any) => boolean,
|
|
|
93
97
|
* normalizeStringOrDefault(42, 'user-roles-management:edit')
|
|
94
98
|
* // → 'user-roles-management:edit'
|
|
95
99
|
*/
|
|
96
|
-
export function normalizeStringOrDefault(
|
|
100
|
+
export function normalizeStringOrDefault(
|
|
101
|
+
value: any,
|
|
102
|
+
defaultValue: string,
|
|
103
|
+
): string
|
|
97
104
|
/**
|
|
98
105
|
* Normalize a value to a valid number (with safe string coercion); otherwise return a default.
|
|
99
106
|
*
|
|
@@ -131,7 +138,10 @@ export function normalizeStringOrDefault(value: any, defaultValue: string): stri
|
|
|
131
138
|
* normalizeNumberOrDefault(NaN, 7) // → 7
|
|
132
139
|
* normalizeNumberOrDefault({}, 7) // → 7
|
|
133
140
|
*/
|
|
134
|
-
export function normalizeNumberOrDefault(
|
|
141
|
+
export function normalizeNumberOrDefault(
|
|
142
|
+
value: any,
|
|
143
|
+
defaultValue: number,
|
|
144
|
+
): number
|
|
135
145
|
/**
|
|
136
146
|
* Normalize a value to a boolean (with "true"/"false" string support); otherwise return a default.
|
|
137
147
|
*
|
|
@@ -169,4 +179,7 @@ export function normalizeNumberOrDefault(value: any, defaultValue: number): numb
|
|
|
169
179
|
* normalizeBooleanOrDefault('yes', false) // → false (rejected → default)
|
|
170
180
|
* normalizeBooleanOrDefault(1, true) // → true (rejected → default)
|
|
171
181
|
*/
|
|
172
|
-
export function normalizeBooleanOrDefault(
|
|
182
|
+
export function normalizeBooleanOrDefault(
|
|
183
|
+
value: any,
|
|
184
|
+
defaultValue: boolean,
|
|
185
|
+
): boolean
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export function normalizeToArray(value: any): string[]
|
|
1
|
+
export function normalizeToArray(value: any): string[]
|
|
@@ -11,46 +11,50 @@
|
|
|
11
11
|
* @throws {Error} If charset is provided and is not a non-empty string.
|
|
12
12
|
* @throws {Error} If the type is invalid and no valid charset is provided.
|
|
13
13
|
*/
|
|
14
|
-
export function generateCode({
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
14
|
+
export function generateCode({
|
|
15
|
+
length,
|
|
16
|
+
type,
|
|
17
|
+
charset,
|
|
18
|
+
}?: {
|
|
19
|
+
length?: number
|
|
20
|
+
type?: string
|
|
21
|
+
charset?: string
|
|
22
|
+
}): string
|
|
19
23
|
/**
|
|
20
24
|
* Generates an OTP code using alphabetic characters (both lowercase and uppercase).
|
|
21
25
|
*
|
|
22
26
|
* @param {number} [length=4] - The desired length of the code.
|
|
23
27
|
* @returns {string} The generated code.
|
|
24
28
|
*/
|
|
25
|
-
export function generateCodeAlpha(length?: number): string
|
|
29
|
+
export function generateCodeAlpha(length?: number): string
|
|
26
30
|
/**
|
|
27
31
|
* Generates an OTP code using only numeric digits (0-9).
|
|
28
32
|
*
|
|
29
33
|
* @param {number} [length=4] - The desired length of the code.
|
|
30
34
|
* @returns {string} The generated code.
|
|
31
35
|
*/
|
|
32
|
-
export function generateCodeDigits(length?: number): string
|
|
36
|
+
export function generateCodeDigits(length?: number): string
|
|
33
37
|
/**
|
|
34
38
|
* Generates an OTP code using alphabetic characters and digits.
|
|
35
39
|
*
|
|
36
40
|
* @param {number} [length=4] - The desired length of the code.
|
|
37
41
|
* @returns {string} The generated code.
|
|
38
42
|
*/
|
|
39
|
-
export function generateCodeAlphaNumeric(length?: number): string
|
|
43
|
+
export function generateCodeAlphaNumeric(length?: number): string
|
|
40
44
|
/**
|
|
41
45
|
* Generates an OTP code using alphabetic characters, digits, and symbols.
|
|
42
46
|
*
|
|
43
47
|
* @param {number} [length=4] - The desired length of the code.
|
|
44
48
|
* @returns {string} The generated code.
|
|
45
49
|
*/
|
|
46
|
-
export function generateCodeAlphaNumericSymbols(length?: number): string
|
|
50
|
+
export function generateCodeAlphaNumericSymbols(length?: number): string
|
|
47
51
|
export const OTP_GENERATOR_TYPES: Readonly<{
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
}
|
|
52
|
+
any: 'any'
|
|
53
|
+
alpha: 'alpha'
|
|
54
|
+
numeric: 'numeric'
|
|
55
|
+
symbols: 'symbols'
|
|
56
|
+
alphaLower: 'alphaLower'
|
|
57
|
+
alphaUpper: 'alphaUpper'
|
|
58
|
+
alphanumeric: 'alphanumeric'
|
|
59
|
+
alphanumericSymbols: 'alphanumericSymbols'
|
|
60
|
+
}>
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export function isValidRegex(pattern: string | RegExp): boolean
|
|
1
|
+
export function isValidRegex(pattern: string | RegExp): boolean
|
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
export function sanitizeObject(
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
export function sanitizeObject(
|
|
2
|
+
obj: any,
|
|
3
|
+
filter: (entry: [string, any]) => boolean,
|
|
4
|
+
): any
|
|
5
|
+
export function sanitizeUndefinedFields(obj: any): any
|
|
6
|
+
export function sanitizeObjectAllowProps(
|
|
7
|
+
obj: any,
|
|
8
|
+
allowedFields?: string[],
|
|
9
|
+
): any
|
|
10
|
+
export function sanitizeObjectDisallowProps(
|
|
11
|
+
obj: any,
|
|
12
|
+
disallowedFields?: string[],
|
|
13
|
+
): any
|
package/types/crypto/crypto.d.ts
CHANGED
|
@@ -1,18 +1,31 @@
|
|
|
1
|
-
export function getSalt(length: number): Buffer
|
|
2
|
-
export function getSaltHex(length: number): string
|
|
3
|
-
export function getEncryptedBuffer({
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
export function getSalt(length: number): Buffer
|
|
2
|
+
export function getSaltHex(length: number): string
|
|
3
|
+
export function getEncryptedBuffer({
|
|
4
|
+
salt,
|
|
5
|
+
expression,
|
|
6
|
+
length,
|
|
7
|
+
}: {
|
|
8
|
+
expression: string
|
|
9
|
+
salt: string
|
|
10
|
+
length?: number
|
|
11
|
+
}): Promise<Buffer>
|
|
12
|
+
export function encrypt({
|
|
13
|
+
salt,
|
|
14
|
+
expression,
|
|
15
|
+
passwordPrivateKey,
|
|
16
|
+
}: {
|
|
17
|
+
expression: string
|
|
18
|
+
salt: string
|
|
19
|
+
passwordPrivateKey?: string
|
|
20
|
+
}): Promise<string>
|
|
21
|
+
export function isPasswordMatch({
|
|
22
|
+
salt,
|
|
23
|
+
password,
|
|
24
|
+
encryptedPassword,
|
|
25
|
+
passwordPrivateKey,
|
|
26
|
+
}: {
|
|
27
|
+
salt: string
|
|
28
|
+
password: string
|
|
29
|
+
encryptedPassword: string
|
|
30
|
+
passwordPrivateKey?: string
|
|
31
|
+
}): Promise<boolean>
|
|
@@ -1,6 +1,14 @@
|
|
|
1
|
-
export function encryptPassword(
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
1
|
+
export function encryptPassword(
|
|
2
|
+
{
|
|
3
|
+
password,
|
|
4
|
+
}: {
|
|
5
|
+
password: string
|
|
6
|
+
},
|
|
7
|
+
{
|
|
8
|
+
saltLength,
|
|
9
|
+
passwordPrivateKey,
|
|
10
|
+
}: {
|
|
11
|
+
saltLength: number
|
|
12
|
+
passwordPrivateKey?: string
|
|
13
|
+
},
|
|
14
|
+
): Promise<any>
|
package/types/crypto/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
1
|
+
export * from './crypto.js'
|
|
2
|
+
export * from './encryption.js'
|
|
@@ -1,15 +1,26 @@
|
|
|
1
|
-
export function withErrorHandling(
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export
|
|
15
|
-
|
|
1
|
+
export function withErrorHandling(
|
|
2
|
+
log: object,
|
|
3
|
+
defaultError: HttpError,
|
|
4
|
+
): (funcToInvoke: () => Promise<any>) => Promise<any>
|
|
5
|
+
export function withErrorHandlingReply({
|
|
6
|
+
reply,
|
|
7
|
+
log,
|
|
8
|
+
defaultError,
|
|
9
|
+
}: {
|
|
10
|
+
reply: Reply
|
|
11
|
+
log: Logger
|
|
12
|
+
defaultError?: HttpError
|
|
13
|
+
}): (funcToInvoke: any) => Promise<any>
|
|
14
|
+
export function replyOnErrorOnly({
|
|
15
|
+
reply,
|
|
16
|
+
log,
|
|
17
|
+
defaultError,
|
|
18
|
+
}: {
|
|
19
|
+
reply: Reply
|
|
20
|
+
log: Logger
|
|
21
|
+
defaultError?: HttpError
|
|
22
|
+
}): (funcToInvoke: any) => Promise<any>
|
|
23
|
+
export type Reply = import('fastify').FastifyReply
|
|
24
|
+
export type Request = import('fastify').FastifyRequest
|
|
25
|
+
export type Logger = import('pino').Logger
|
|
26
|
+
import { HttpError } from '../../http/HttpError.js'
|
package/types/fastify/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { GENERAL_ERROR } from
|
|
2
|
-
export * from
|
|
1
|
+
export { GENERAL_ERROR } from './error-codes.js'
|
|
2
|
+
export * from './error-handlers/with-error-handling.js'
|
|
@@ -37,7 +37,6 @@ export class HttpError extends Error {
|
|
|
37
37
|
code?: string | number
|
|
38
38
|
message?: string
|
|
39
39
|
status?: number
|
|
40
|
-
|
|
41
40
|
extendInfo?: object
|
|
42
41
|
})
|
|
43
42
|
/**
|
|
@@ -49,10 +48,10 @@ export class HttpError extends Error {
|
|
|
49
48
|
* @type {number | undefined}
|
|
50
49
|
* HTTP status code associated with the error (e.g., 400, 500).
|
|
51
50
|
*/
|
|
52
|
-
|
|
51
|
+
status: number | undefined
|
|
53
52
|
/**
|
|
54
|
-
* @type {
|
|
55
|
-
*
|
|
53
|
+
* @type {object | undefined}
|
|
54
|
+
* Optional metadata for debugging/logging (e.g., request ID, user ID, retryAfter).
|
|
56
55
|
*/
|
|
57
56
|
extendInfo: object | undefined
|
|
58
57
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export const HTTP_METHODS: Readonly<{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
2
|
+
GET: 'GET'
|
|
3
|
+
POST: 'POST'
|
|
4
|
+
PUT: 'PUT'
|
|
5
|
+
PATCH: 'PATCH'
|
|
6
|
+
DELETE: 'DELETE'
|
|
7
|
+
}>
|
package/types/http/http.d.ts
CHANGED
|
@@ -1,36 +1,60 @@
|
|
|
1
|
-
export function get({
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
}
|
|
1
|
+
export function get({
|
|
2
|
+
url,
|
|
3
|
+
headers,
|
|
4
|
+
expectedType,
|
|
5
|
+
}: {
|
|
6
|
+
url: any
|
|
7
|
+
headers?: {}
|
|
8
|
+
expectedType?: 'json'
|
|
9
|
+
}): Promise<any>
|
|
10
|
+
export function post({
|
|
11
|
+
url,
|
|
12
|
+
body,
|
|
13
|
+
headers,
|
|
14
|
+
expectedType,
|
|
15
|
+
}: {
|
|
16
|
+
url: any
|
|
17
|
+
body: any
|
|
18
|
+
headers?: {}
|
|
19
|
+
expectedType?: 'json'
|
|
20
|
+
}): Promise<any>
|
|
21
|
+
export function put({
|
|
22
|
+
url,
|
|
23
|
+
body,
|
|
24
|
+
headers,
|
|
25
|
+
expectedType,
|
|
26
|
+
}: {
|
|
27
|
+
url: any
|
|
28
|
+
body: any
|
|
29
|
+
headers?: {}
|
|
30
|
+
expectedType?: 'json'
|
|
31
|
+
}): Promise<any>
|
|
32
|
+
export function patch({
|
|
33
|
+
url,
|
|
34
|
+
body,
|
|
35
|
+
headers,
|
|
36
|
+
expectedType,
|
|
37
|
+
}: {
|
|
38
|
+
url: any
|
|
39
|
+
body: any
|
|
40
|
+
headers?: {}
|
|
41
|
+
expectedType?: 'json'
|
|
42
|
+
}): Promise<any>
|
|
43
|
+
export function deleteApi({
|
|
44
|
+
url,
|
|
45
|
+
body,
|
|
46
|
+
headers,
|
|
47
|
+
expectedType,
|
|
48
|
+
}: {
|
|
49
|
+
url: any
|
|
50
|
+
body: any
|
|
51
|
+
headers?: {}
|
|
52
|
+
expectedType?: 'json'
|
|
53
|
+
}): Promise<any>
|
|
30
54
|
export namespace http {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
55
|
+
export { get }
|
|
56
|
+
export { put }
|
|
57
|
+
export { post }
|
|
58
|
+
export { patch }
|
|
59
|
+
export { deleteApi }
|
|
36
60
|
}
|
package/types/http/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
3
|
-
export * from
|
|
4
|
-
export * from
|
|
1
|
+
export * from './http.js'
|
|
2
|
+
export * from './HttpError.js'
|
|
3
|
+
export * from './http-method.js'
|
|
4
|
+
export * from './responseType.js'
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* *
|
|
3
3
|
*/
|
|
4
|
-
export type ResponseType = string
|
|
4
|
+
export type ResponseType = string
|
|
5
5
|
/**
|
|
6
6
|
* Enum representing supported response types for HTTP client parsing.
|
|
7
7
|
*
|
|
@@ -13,8 +13,8 @@ export type ResponseType = string;
|
|
|
13
13
|
* @property {string} file - Binary file or blob (not automatically parsed).
|
|
14
14
|
*/
|
|
15
15
|
export const ResponseType: Readonly<{
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
16
|
+
xml: 'xml'
|
|
17
|
+
json: 'json'
|
|
18
|
+
text: 'text'
|
|
19
|
+
file: 'file'
|
|
20
|
+
}>
|