@voilabs/oilang 0.0.5 → 0.0.7
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/dist/adapters/PostgreSQL.d.ts +35 -61
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/oilang.d.ts +45 -33
- package/dist/stores/MemoryStore.d.ts +0 -10
- package/dist/stores/RedisStore.d.ts +1 -7
- package/dist/types.d.ts +12 -0
- package/package.json +1 -1
- package/dist/package.json +0 -36
|
@@ -1,4 +1,36 @@
|
|
|
1
1
|
import { Client, type ClientConfig } from "pg";
|
|
2
|
+
import { LocaleData, TranslationData } from "../types";
|
|
3
|
+
type ActionResponse<T> = {
|
|
4
|
+
success: true;
|
|
5
|
+
data: T;
|
|
6
|
+
} | {
|
|
7
|
+
success: false;
|
|
8
|
+
error: any;
|
|
9
|
+
};
|
|
10
|
+
declare class Locales {
|
|
11
|
+
private schema;
|
|
12
|
+
private client;
|
|
13
|
+
constructor(schema: string, client: Client);
|
|
14
|
+
list(): Promise<ActionResponse<LocaleData[]>>;
|
|
15
|
+
create(locale: string, nativeName: string, englishName: string): Promise<ActionResponse<LocaleData>>;
|
|
16
|
+
delete(locale: string): Promise<ActionResponse<{
|
|
17
|
+
code: string;
|
|
18
|
+
}>>;
|
|
19
|
+
update(locale: string, nativeName: string, englishName: string): Promise<ActionResponse<LocaleData>>;
|
|
20
|
+
}
|
|
21
|
+
declare class Translations {
|
|
22
|
+
private schema;
|
|
23
|
+
private client;
|
|
24
|
+
private localesSchema;
|
|
25
|
+
constructor(schema: string, client: Client, localesSchema: string);
|
|
26
|
+
list(): Promise<ActionResponse<TranslationData[]>>;
|
|
27
|
+
create(key: string, value: string, locale: string): Promise<ActionResponse<TranslationData>>;
|
|
28
|
+
delete(key: string, locale: string): Promise<ActionResponse<{
|
|
29
|
+
locale_id: string;
|
|
30
|
+
key: string;
|
|
31
|
+
}>>;
|
|
32
|
+
update(key: string, value: string, locale: string): Promise<ActionResponse<TranslationData>>;
|
|
33
|
+
}
|
|
2
34
|
export declare class PostgreSQL {
|
|
3
35
|
private config;
|
|
4
36
|
client: Client;
|
|
@@ -6,6 +38,8 @@ export declare class PostgreSQL {
|
|
|
6
38
|
keys: string;
|
|
7
39
|
locales: string;
|
|
8
40
|
};
|
|
41
|
+
locales: Locales;
|
|
42
|
+
translations: Translations;
|
|
9
43
|
constructor(config: string | ClientConfig | undefined, customizationConfig: {
|
|
10
44
|
schemaNames: {
|
|
11
45
|
keys: string;
|
|
@@ -17,65 +51,5 @@ export declare class PostgreSQL {
|
|
|
17
51
|
keys: string;
|
|
18
52
|
locales: string;
|
|
19
53
|
};
|
|
20
|
-
addLocale(locale: string, nativeName: string, englishName: string): Promise<{
|
|
21
|
-
success: true;
|
|
22
|
-
data: {
|
|
23
|
-
code: string;
|
|
24
|
-
native_name: string;
|
|
25
|
-
english_name: string;
|
|
26
|
-
created_at: string;
|
|
27
|
-
updated_at: string;
|
|
28
|
-
};
|
|
29
|
-
} | {
|
|
30
|
-
success: false;
|
|
31
|
-
error: any;
|
|
32
|
-
}>;
|
|
33
|
-
getAllLocales(): Promise<{
|
|
34
|
-
success: true;
|
|
35
|
-
data: Array<{
|
|
36
|
-
code: string;
|
|
37
|
-
native_name: string;
|
|
38
|
-
english_name: string;
|
|
39
|
-
created_at: string;
|
|
40
|
-
updated_at: string;
|
|
41
|
-
}>;
|
|
42
|
-
} | {
|
|
43
|
-
success: false;
|
|
44
|
-
error: any;
|
|
45
|
-
}>;
|
|
46
|
-
getAllTranslations(): Promise<{
|
|
47
|
-
success: true;
|
|
48
|
-
data: Array<{
|
|
49
|
-
locale_id: string;
|
|
50
|
-
key: string;
|
|
51
|
-
value: string;
|
|
52
|
-
}>;
|
|
53
|
-
} | {
|
|
54
|
-
success: false;
|
|
55
|
-
error: any;
|
|
56
|
-
}>;
|
|
57
|
-
deleteLocale(locale: string): Promise<{
|
|
58
|
-
success: boolean;
|
|
59
|
-
data: {
|
|
60
|
-
code: string;
|
|
61
|
-
};
|
|
62
|
-
error?: undefined;
|
|
63
|
-
} | {
|
|
64
|
-
success: boolean;
|
|
65
|
-
error: unknown;
|
|
66
|
-
data?: undefined;
|
|
67
|
-
}>;
|
|
68
|
-
addTranslation(locale: string, key: string, value: string): Promise<{
|
|
69
|
-
success: false;
|
|
70
|
-
error: Error & {
|
|
71
|
-
code: string;
|
|
72
|
-
};
|
|
73
|
-
} | {
|
|
74
|
-
success: true;
|
|
75
|
-
data: {
|
|
76
|
-
locale_id: string;
|
|
77
|
-
key: string;
|
|
78
|
-
value: string;
|
|
79
|
-
};
|
|
80
|
-
}>;
|
|
81
54
|
}
|
|
55
|
+
export {};
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
package/dist/oilang.d.ts
CHANGED
|
@@ -1,60 +1,72 @@
|
|
|
1
1
|
import type { MemoryStore } from "./stores/MemoryStore";
|
|
2
2
|
import type { PostgreSQL } from "./adapters/PostgreSQL";
|
|
3
3
|
import type { RedisStore } from "./stores/RedisStore";
|
|
4
|
+
import { LocaleData, TranslationData } from "./types";
|
|
4
5
|
type AdapterConfig = {
|
|
5
6
|
database: InstanceType<typeof PostgreSQL>;
|
|
6
7
|
store: InstanceType<typeof MemoryStore> | InstanceType<typeof RedisStore>;
|
|
8
|
+
fallbackLocale?: string;
|
|
7
9
|
};
|
|
8
|
-
|
|
9
|
-
|
|
10
|
+
type ActionResponse<T> = {
|
|
11
|
+
error: Error & {
|
|
12
|
+
code?: string;
|
|
13
|
+
};
|
|
14
|
+
data: null;
|
|
15
|
+
} | {
|
|
16
|
+
error: null;
|
|
17
|
+
data: T;
|
|
18
|
+
};
|
|
19
|
+
declare class Locale {
|
|
10
20
|
private database;
|
|
11
21
|
private store;
|
|
12
|
-
constructor(
|
|
13
|
-
|
|
14
|
-
createLocale(locale: string, nativeName: string, englishName: string): Promise<{
|
|
15
|
-
error: Error & {
|
|
16
|
-
code: string;
|
|
17
|
-
};
|
|
18
|
-
data: null;
|
|
19
|
-
} | {
|
|
22
|
+
constructor(database: AdapterConfig["database"], store: AdapterConfig["store"]);
|
|
23
|
+
list(): Promise<{
|
|
20
24
|
error: null;
|
|
21
|
-
data:
|
|
22
|
-
code: string;
|
|
23
|
-
native_name: string;
|
|
24
|
-
english_name: string;
|
|
25
|
-
created_at: string;
|
|
26
|
-
updated_at: string;
|
|
27
|
-
};
|
|
25
|
+
data: any[] | Record<string, string>;
|
|
28
26
|
}>;
|
|
29
|
-
|
|
27
|
+
create(locale: string, nativeName: string, englishName: string): Promise<ActionResponse<LocaleData>>;
|
|
28
|
+
delete(locale: string): Promise<{
|
|
30
29
|
error: null;
|
|
31
30
|
data: {
|
|
32
31
|
code: string;
|
|
33
|
-
}
|
|
32
|
+
};
|
|
34
33
|
} | {
|
|
35
|
-
error:
|
|
34
|
+
error: any;
|
|
36
35
|
data: null;
|
|
37
36
|
}>;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
37
|
+
update(locale: string, nativeName: string, englishName: string): Promise<ActionResponse<LocaleData>>;
|
|
38
|
+
}
|
|
39
|
+
declare class Translation {
|
|
40
|
+
private database;
|
|
41
|
+
private store;
|
|
42
|
+
private fallbackLocale?;
|
|
43
|
+
constructor(database: AdapterConfig["database"], store: AdapterConfig["store"], fallbackLocale?: string);
|
|
44
|
+
list(locale: string): Promise<any[] | Record<string, string>>;
|
|
45
|
+
create(locale: string, config: {
|
|
44
46
|
key: string;
|
|
45
47
|
value: string;
|
|
46
|
-
}): Promise<
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
};
|
|
50
|
-
data: null;
|
|
51
|
-
} | {
|
|
48
|
+
}): Promise<ActionResponse<TranslationData>>;
|
|
49
|
+
update(locale: string, key: string, newValue: string): Promise<ActionResponse<TranslationData>>;
|
|
50
|
+
delete(locale: string, key: string): Promise<{
|
|
52
51
|
error: null;
|
|
53
52
|
data: {
|
|
54
53
|
locale_id: string;
|
|
55
54
|
key: string;
|
|
56
|
-
value: string;
|
|
57
55
|
};
|
|
56
|
+
} | {
|
|
57
|
+
error: any;
|
|
58
|
+
data: null;
|
|
58
59
|
}>;
|
|
60
|
+
translate(locale: string, key: string, variables?: Record<string, string | number>): Promise<string>;
|
|
61
|
+
}
|
|
62
|
+
export declare class OILang {
|
|
63
|
+
private config;
|
|
64
|
+
private database;
|
|
65
|
+
private store;
|
|
66
|
+
private fallbackLocale;
|
|
67
|
+
locales: Locale;
|
|
68
|
+
translations: Translation;
|
|
69
|
+
constructor(config: AdapterConfig);
|
|
70
|
+
init(): Promise<void>;
|
|
59
71
|
}
|
|
60
72
|
export {};
|
|
@@ -5,8 +5,6 @@ export declare class MemoryStore {
|
|
|
5
5
|
code: string;
|
|
6
6
|
native_name: string;
|
|
7
7
|
english_name: string;
|
|
8
|
-
created_at: string;
|
|
9
|
-
updated_at: string;
|
|
10
8
|
}>, translations: Record<string, Record<string, string>>): Promise<void>;
|
|
11
9
|
set(config: {
|
|
12
10
|
seed: "translations";
|
|
@@ -19,8 +17,6 @@ export declare class MemoryStore {
|
|
|
19
17
|
code: string;
|
|
20
18
|
native_name: string;
|
|
21
19
|
english_name: string;
|
|
22
|
-
created_at: string;
|
|
23
|
-
updated_at: string;
|
|
24
20
|
};
|
|
25
21
|
}): Promise<void>;
|
|
26
22
|
get(config: {
|
|
@@ -34,8 +30,6 @@ export declare class MemoryStore {
|
|
|
34
30
|
code: string;
|
|
35
31
|
native_name: string;
|
|
36
32
|
english_name: string;
|
|
37
|
-
created_at: string;
|
|
38
|
-
updated_at: string;
|
|
39
33
|
} | undefined>;
|
|
40
34
|
getAll(config: {
|
|
41
35
|
seed: "locales";
|
|
@@ -46,8 +40,6 @@ export declare class MemoryStore {
|
|
|
46
40
|
code: string;
|
|
47
41
|
native_name: string;
|
|
48
42
|
english_name: string;
|
|
49
|
-
created_at: string;
|
|
50
|
-
updated_at: string;
|
|
51
43
|
}[]>;
|
|
52
44
|
remove(config: {
|
|
53
45
|
seed: "translations";
|
|
@@ -68,8 +60,6 @@ export declare class MemoryStore {
|
|
|
68
60
|
locale: {
|
|
69
61
|
native_name: string;
|
|
70
62
|
english_name: string;
|
|
71
|
-
created_at: string;
|
|
72
|
-
updated_at: string;
|
|
73
63
|
};
|
|
74
64
|
}): Promise<true | void>;
|
|
75
65
|
}
|
|
@@ -9,8 +9,6 @@ export declare class RedisStore {
|
|
|
9
9
|
code: string;
|
|
10
10
|
native_name: string;
|
|
11
11
|
english_name: string;
|
|
12
|
-
created_at: string;
|
|
13
|
-
updated_at: string;
|
|
14
12
|
}>, translations: Record<string, Record<string, string>>): Promise<void>;
|
|
15
13
|
set(config: {
|
|
16
14
|
seed: "translations";
|
|
@@ -23,8 +21,6 @@ export declare class RedisStore {
|
|
|
23
21
|
code: string;
|
|
24
22
|
native_name: string;
|
|
25
23
|
english_name: string;
|
|
26
|
-
created_at: string;
|
|
27
|
-
updated_at: string;
|
|
28
24
|
};
|
|
29
25
|
}): Promise<void>;
|
|
30
26
|
get(config: {
|
|
@@ -40,7 +36,7 @@ export declare class RedisStore {
|
|
|
40
36
|
} | {
|
|
41
37
|
seed: "translations";
|
|
42
38
|
locale: string;
|
|
43
|
-
}): Promise<any
|
|
39
|
+
}): Promise<any[] | Record<string, string>>;
|
|
44
40
|
remove(config: {
|
|
45
41
|
seed: "translations";
|
|
46
42
|
locale: string;
|
|
@@ -60,8 +56,6 @@ export declare class RedisStore {
|
|
|
60
56
|
locale: {
|
|
61
57
|
native_name: string;
|
|
62
58
|
english_name: string;
|
|
63
|
-
created_at: string;
|
|
64
|
-
updated_at: string;
|
|
65
59
|
};
|
|
66
60
|
}): Promise<true | void>;
|
|
67
61
|
}
|
package/dist/types.d.ts
ADDED
package/package.json
CHANGED
package/dist/package.json
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@voilabs/oilang",
|
|
3
|
-
"description": "A robust internationalization (i18n) handling library designed for performance and flexibility.",
|
|
4
|
-
"version": "0.0.3",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"build": "tsc",
|
|
9
|
-
"prepublishOnly": "npm run build"
|
|
10
|
-
},
|
|
11
|
-
"devDependencies": {
|
|
12
|
-
"@types/bun": "latest",
|
|
13
|
-
"@types/node": "^25.2.3",
|
|
14
|
-
"@types/pg": "^8.16.0"
|
|
15
|
-
},
|
|
16
|
-
"publishConfig": {
|
|
17
|
-
"access": "public"
|
|
18
|
-
},
|
|
19
|
-
"keywords": [
|
|
20
|
-
"i18n",
|
|
21
|
-
"full-stack",
|
|
22
|
-
"realtime"
|
|
23
|
-
],
|
|
24
|
-
"peerDependencies": {
|
|
25
|
-
"typescript": "^5.9.3"
|
|
26
|
-
},
|
|
27
|
-
"homepage": "https://oilang.com",
|
|
28
|
-
"repository": {
|
|
29
|
-
"type": "git",
|
|
30
|
-
"url": "git+https://github.com/voilabs/node-oilang.git"
|
|
31
|
-
},
|
|
32
|
-
"dependencies": {
|
|
33
|
-
"ioredis": "^5.9.3",
|
|
34
|
-
"pg": "^8.18.0"
|
|
35
|
-
}
|
|
36
|
-
}
|