@gringow/gringow 0.0.6 → 0.0.8
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/browser.d.mts +6 -0
- package/dist/browser.mjs +28 -0
- package/dist/config.d.mts +64 -0
- package/dist/config.mjs +154 -0
- package/dist/config.test.d.mts +2 -0
- package/dist/config.test.mjs +18651 -0
- package/dist/constants/default-config.d.mts +7 -0
- package/dist/constants/default-config.mjs +25 -0
- package/dist/data/check-cache.d.mts +9 -0
- package/dist/data/check-cache.mjs +452 -0
- package/dist/data/clear-cache.d.mts +12 -0
- package/dist/data/clear-cache.mjs +379 -0
- package/dist/data/create-cache-dir.d.mts +3 -0
- package/dist/data/create-cache-dir.mjs +361 -0
- package/{src/data/create-cache-id.ts → dist/data/create-cache-id.d.mts} +3 -7
- package/dist/data/create-cache-id.mjs +10 -0
- package/dist/data/delete-cache-item.d.mts +9 -0
- package/dist/data/delete-cache-item.mjs +411 -0
- package/dist/data/get-cache.d.mts +13 -0
- package/dist/data/get-cache.mjs +374 -0
- package/dist/data/get-or-create-cache.d.mts +9 -0
- package/dist/data/get-or-create-cache.mjs +400 -0
- package/dist/data/save-cache.d.mts +19 -0
- package/dist/data/save-cache.mjs +374 -0
- package/dist/data/write-cache-to-disk.d.mts +9 -0
- package/dist/data/write-cache-to-disk.mjs +408 -0
- package/dist/flat-template-string.d.mts +14 -0
- package/dist/flat-template-string.mjs +16 -0
- package/dist/flat-template-string.test.d.mts +2 -0
- package/dist/flat-template-string.test.mjs +18479 -0
- package/dist/gringow.d.mts +9 -0
- package/dist/gringow.mjs +926 -0
- package/dist/index.d.mts +82 -0
- package/dist/index.mjs +948 -0
- package/dist/io/anthropic/ask.d.mts +11 -0
- package/dist/io/anthropic/ask.mjs +181 -0
- package/dist/io/anthropic/commit-response.d.mts +21 -0
- package/dist/io/anthropic/commit-response.mjs +10 -0
- package/dist/io/anthropic/index.d.mts +14 -0
- package/dist/io/anthropic/index.mjs +199 -0
- package/dist/io/anthropic/parse.d.mts +20 -0
- package/dist/io/anthropic/parse.mjs +10 -0
- package/dist/io/ask-llm.d.mts +19 -0
- package/dist/io/ask-llm.mjs +573 -0
- package/dist/io/gemini/ask.d.mts +11 -0
- package/dist/io/gemini/ask.mjs +206 -0
- package/dist/io/gemini/commit-response.d.mts +11 -0
- package/dist/io/gemini/commit-response.mjs +7 -0
- package/dist/io/gemini/index.d.mts +14 -0
- package/dist/io/gemini/index.mjs +222 -0
- package/dist/io/gemini/parse.d.mts +20 -0
- package/dist/io/gemini/parse.mjs +11 -0
- package/dist/io/huggingface/ask.d.mts +13 -0
- package/dist/io/huggingface/ask.mjs +397 -0
- package/dist/io/huggingface/commit-response.d.mts +39 -0
- package/dist/io/huggingface/commit-response.mjs +14 -0
- package/dist/io/huggingface/index.d.mts +13 -0
- package/dist/io/huggingface/index.mjs +418 -0
- package/dist/io/huggingface/languagesMap.d.mts +191 -0
- package/dist/io/huggingface/languagesMap.mjs +187 -0
- package/dist/io/huggingface/parse.d.mts +20 -0
- package/dist/io/huggingface/parse.mjs +9 -0
- package/dist/logger.d.mts +10 -0
- package/dist/logger.mjs +43 -0
- package/dist/logger.test.d.mts +2 -0
- package/dist/logger.test.mjs +18683 -0
- package/dist/schemas/config.shcema.d.mts +199 -0
- package/dist/schemas/config.shcema.mjs +52 -0
- package/dist/types/index.d.mts +28 -0
- package/dist/types/index.mjs +1 -0
- package/package.json +15 -10
- package/.nvmrc +0 -1
- package/gringow.json +0 -12
- package/src/browser.ts +0 -4
- package/src/config.ts +0 -93
- package/src/data/check-cache.ts +0 -15
- package/src/data/clear-cache.ts +0 -5
- package/src/data/create-cache-dir.ts +0 -7
- package/src/data/delete-cache-item.ts +0 -20
- package/src/data/get-cache.ts +0 -17
- package/src/data/get-or-create-cache.ts +0 -21
- package/src/data/save-cache.ts +0 -17
- package/src/data/write-cache-to-disk.ts +0 -20
- package/src/default-config.ts +0 -27
- package/src/flat-template-string.test.ts +0 -109
- package/src/flat-template-string.ts +0 -27
- package/src/gringow.ts +0 -49
- package/src/index.ts +0 -37
- package/src/io/anthropic/ask.ts +0 -31
- package/src/io/anthropic/commit-response.ts +0 -11
- package/src/io/anthropic/index.ts +0 -3
- package/src/io/anthropic/parse.ts +0 -11
- package/src/io/ask-llm.ts +0 -44
- package/src/io/gemini/ask.ts +0 -65
- package/src/io/gemini/commit-response.ts +0 -6
- package/src/io/gemini/index.ts +0 -3
- package/src/io/gemini/parse.ts +0 -12
- package/src/io/huggingface/ask.ts +0 -82
- package/src/io/huggingface/commit-response.ts +0 -16
- package/src/io/huggingface/index.ts +0 -16
- package/src/io/huggingface/languagesMap.ts +0 -189
- package/src/io/huggingface/parse.ts +0 -10
- package/src/logger.ts +0 -25
- package/src/schemas/config.shcema.ts +0 -58
- package/src/types/index.ts +0 -22
- package/tsconfig.json +0 -29
- package/tsup.config.ts +0 -21
- package/vitest.config.ts +0 -8
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
export { awaitedConfig, getConfigSource, isLocalConfigFound } from './config.mjs';
|
|
2
|
+
export { clearCache } from './data/clear-cache.mjs';
|
|
3
|
+
export { createCacheId } from './data/create-cache-id.mjs';
|
|
4
|
+
export { getCache } from './data/get-cache.mjs';
|
|
5
|
+
export { flatTemplateString } from './flat-template-string.mjs';
|
|
6
|
+
export { GringowConfig } from './constants/default-config.mjs';
|
|
7
|
+
import 'zod';
|
|
8
|
+
import './schemas/config.shcema.mjs';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Checks if a cache item exists for the given ID
|
|
12
|
+
*
|
|
13
|
+
* @param cacheId - The cache ID to check
|
|
14
|
+
* @returns Promise that resolves to the cached item if found, or undefined otherwise
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* const item = await checkCache("gid_123abc")
|
|
18
|
+
* if (item) {
|
|
19
|
+
* console.log("Found in cache:", item.translation)
|
|
20
|
+
* }
|
|
21
|
+
*/
|
|
22
|
+
declare function checkCache(cacheId: string): Promise<GringowCacheItem | undefined>;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Deletes a cache item.
|
|
26
|
+
*
|
|
27
|
+
* @param cacheId - The cache ID.
|
|
28
|
+
* @returns The cache ID.
|
|
29
|
+
*/
|
|
30
|
+
declare function deleteCacheItem(cacheId: string): Promise<GringowCache>;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Gets the existing cache or creates a new empty one if it doesn't exist
|
|
34
|
+
*
|
|
35
|
+
* @returns Promise that resolves to the cache object
|
|
36
|
+
* @throws {GringowError} If there is an error reading/writing the cache file
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* const cache = await getOrCreateCache()
|
|
40
|
+
* // Returns existing cache or creates new empty cache: {}
|
|
41
|
+
*/
|
|
42
|
+
declare function getOrCreateCache(): Promise<GringowCache>;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Writes the cache to disk.
|
|
46
|
+
*
|
|
47
|
+
* @param cacheId - The cache ID.
|
|
48
|
+
* @param cached - The cached item.
|
|
49
|
+
* @returns The cached item.
|
|
50
|
+
*/
|
|
51
|
+
declare function writeCacheToDisk(cacheId: string, cached: GringowCacheItem): Promise<GringowCacheItem>;
|
|
52
|
+
|
|
53
|
+
type GringowTranslation = {
|
|
54
|
+
[key: string]: string;
|
|
55
|
+
};
|
|
56
|
+
type GringowCacheItem = {
|
|
57
|
+
original: string;
|
|
58
|
+
translation: GringowTranslation;
|
|
59
|
+
};
|
|
60
|
+
type GringowCache = {
|
|
61
|
+
[key: string]: GringowCacheItem;
|
|
62
|
+
};
|
|
63
|
+
type GringowResponse = {
|
|
64
|
+
cacheId: string;
|
|
65
|
+
translation: GringowCacheItem;
|
|
66
|
+
};
|
|
67
|
+
type GringowError = Error & {
|
|
68
|
+
code?: string;
|
|
69
|
+
cause?: Error;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Gringow is a function that translates a string or a template string into a
|
|
74
|
+
* translated string.
|
|
75
|
+
*
|
|
76
|
+
* @param strings - The string or template string to translate.
|
|
77
|
+
* @param values - The values to interpolate into the string.
|
|
78
|
+
* @returns The translated string.
|
|
79
|
+
*/
|
|
80
|
+
declare function Gringow(strings: TemplateStringsArray | string, ...values: Array<unknown>): Promise<GringowResponse>;
|
|
81
|
+
|
|
82
|
+
export { type GringowCache, type GringowCacheItem, type GringowError, type GringowResponse, type GringowTranslation, checkCache, Gringow as default, deleteCacheItem, getOrCreateCache, writeCacheToDisk };
|