@docaohuynh/ielts-api-utils 1.0.0 → 1.0.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.
@@ -0,0 +1,4 @@
1
+ export declare function encrypt(text: string, es: string): string;
2
+ export declare function encryptText(text: string, es: string): string;
3
+ export declare function decrypt(encryptedText: string, es: string): string;
4
+ export declare function decryptText(encryptedText: string, es: string): string;
@@ -0,0 +1 @@
1
+ export * from './encrypt';
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Decodes a signed payload, such as a JSON Web Token (JWT), into its original payload.
3
+ * @param signedPayload The signed payload to decode.
4
+ * @returns The original payload.
5
+ * @throws {Error} If the signed payload is invalid.
6
+ */
7
+ export declare function decodeSignedPayload(signedPayload: string): any;
@@ -0,0 +1 @@
1
+ export * from './decode-signed.util';
@@ -0,0 +1,8 @@
1
+ export * from './crypto';
2
+ export * from './strings';
3
+ export * from './decode';
4
+ export * from './language';
5
+ export * from './list';
6
+ export * from './strings';
7
+ export * from './time';
8
+ export * from './request';
@@ -0,0 +1 @@
1
+ export * from './language-translate.util';
@@ -0,0 +1,2 @@
1
+ export declare const formatTranslateListLanguage: (langs: string[]) => string[];
2
+ export declare const formatTranslateLanguage: (lang: string) => string;
@@ -0,0 +1 @@
1
+ export * from './list-string.util';
@@ -0,0 +1 @@
1
+ export declare const replaceWordInList: (words: string[], word: string, replaceWord: string) => string[];
@@ -0,0 +1,45 @@
1
+ /**
2
+ * HTTP request utility functions using Bun's fetch API
3
+ */
4
+ export interface RequestOptions {
5
+ headers?: Record<string, string>;
6
+ timeout?: number;
7
+ }
8
+ export interface ResponseData<T = any> {
9
+ data: T;
10
+ status: number;
11
+ statusText: string;
12
+ headers: Headers;
13
+ }
14
+ /**
15
+ * Send a GET request
16
+ * @param url - The URL to send the request to
17
+ * @param options - Request options including headers and timeout
18
+ * @returns Promise with response data
19
+ */
20
+ export declare function sendGet<T = any>(url: string, options?: RequestOptions): Promise<ResponseData<T>>;
21
+ /**
22
+ * Send a POST request
23
+ * @param url - The URL to send the request to
24
+ * @param body - The request body
25
+ * @param options - Request options including headers and timeout
26
+ * @returns Promise with response data
27
+ */
28
+ export declare function sendPost<T = any>(url: string, body: any, options?: RequestOptions): Promise<ResponseData<T>>;
29
+ /**
30
+ * Send a GET request with Bearer token authentication
31
+ * @param url - The URL to send the request to
32
+ * @param token - The Bearer token
33
+ * @param options - Request options including headers and timeout
34
+ * @returns Promise with response data
35
+ */
36
+ export declare function sendGetWithBearer<T = any>(url: string, token: string, options?: RequestOptions): Promise<ResponseData<T>>;
37
+ /**
38
+ * Send a POST request with Bearer token authentication
39
+ * @param url - The URL to send the request to
40
+ * @param body - The request body
41
+ * @param token - The Bearer token
42
+ * @param options - Request options including headers and timeout
43
+ * @returns Promise with response data
44
+ */
45
+ export declare function sendPostWithBearer<T = any>(url: string, body: any, token: string, options?: RequestOptions): Promise<ResponseData<T>>;
@@ -0,0 +1 @@
1
+ export * from './fetch';
@@ -0,0 +1,2 @@
1
+ export * from './split.util';
2
+ export * from './normalize.util';
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Normalizes text by removing diacritical marks and converting to lowercase
3
+ * Examples: 'ấ' -> 'a', 'ế' -> 'e', 'ồ' -> 'o', 'ứ' -> 'u'
4
+ */
5
+ export declare const normalizeText: (text: string) => string;
6
+ export declare const fullNameToUsername: (fullName: string) => string;
@@ -0,0 +1,2 @@
1
+ export declare const splitIntoSentences: (text: string) => string[];
2
+ export declare const splitIntoSentencesSimple: (text: string) => string[];
@@ -0,0 +1,2 @@
1
+ export * from './timeout.util';
2
+ export * from './timezone.util';
@@ -0,0 +1 @@
1
+ export declare function withTimeout<T>(promise: Promise<T>, ms: number, fallback: T): Promise<T>;
@@ -0,0 +1,4 @@
1
+ export declare const getCurrentDateInUserTimezone: (timezone: string, overrideDateISO?: string) => string | null;
2
+ export declare const getCurrentDateFullInUserTimezone: (timezone: string, overrideDateISO?: string) => string | null;
3
+ export declare const getCurrentDate: (overrideDateISO?: string) => Date;
4
+ export declare const getCurrentDateStr: (overrideDateISO?: string) => string | undefined;
package/package.json CHANGED
@@ -1,19 +1,22 @@
1
1
  {
2
2
  "name": "@docaohuynh/ielts-api-utils",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Utilities for IELTS API",
5
5
  "module": "index.ts",
6
- "main": "index.js",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
7
8
  "type": "module",
8
9
  "scripts": {
9
- "build": "bun build index.ts --outdir dist"
10
+ "build": "bun build index.ts --outdir dist --target node && tsc -p tsconfig.build.json"
10
11
  },
11
12
  "files": ["dist"],
12
13
  "devDependencies": {
13
- "@types/bun": "latest"
14
+ "@types/bun": "latest",
15
+ "mockdate": "^3.0.5",
16
+ "vitest": "^3.2.4"
14
17
  },
15
18
  "peerDependencies": {
16
- "typescript": "^5"
19
+ "typescript": "^5.9.2"
17
20
  },
18
21
  "dependencies": {
19
22
  "@types/luxon": "^3.7.1",