@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.
Files changed (108) hide show
  1. package/dist/browser.d.mts +6 -0
  2. package/dist/browser.mjs +28 -0
  3. package/dist/config.d.mts +64 -0
  4. package/dist/config.mjs +154 -0
  5. package/dist/config.test.d.mts +2 -0
  6. package/dist/config.test.mjs +18651 -0
  7. package/dist/constants/default-config.d.mts +7 -0
  8. package/dist/constants/default-config.mjs +25 -0
  9. package/dist/data/check-cache.d.mts +9 -0
  10. package/dist/data/check-cache.mjs +452 -0
  11. package/dist/data/clear-cache.d.mts +12 -0
  12. package/dist/data/clear-cache.mjs +379 -0
  13. package/dist/data/create-cache-dir.d.mts +3 -0
  14. package/dist/data/create-cache-dir.mjs +361 -0
  15. package/{src/data/create-cache-id.ts → dist/data/create-cache-id.d.mts} +3 -7
  16. package/dist/data/create-cache-id.mjs +10 -0
  17. package/dist/data/delete-cache-item.d.mts +9 -0
  18. package/dist/data/delete-cache-item.mjs +411 -0
  19. package/dist/data/get-cache.d.mts +13 -0
  20. package/dist/data/get-cache.mjs +374 -0
  21. package/dist/data/get-or-create-cache.d.mts +9 -0
  22. package/dist/data/get-or-create-cache.mjs +400 -0
  23. package/dist/data/save-cache.d.mts +19 -0
  24. package/dist/data/save-cache.mjs +374 -0
  25. package/dist/data/write-cache-to-disk.d.mts +9 -0
  26. package/dist/data/write-cache-to-disk.mjs +408 -0
  27. package/dist/flat-template-string.d.mts +14 -0
  28. package/dist/flat-template-string.mjs +16 -0
  29. package/dist/flat-template-string.test.d.mts +2 -0
  30. package/dist/flat-template-string.test.mjs +18479 -0
  31. package/dist/gringow.d.mts +9 -0
  32. package/dist/gringow.mjs +926 -0
  33. package/dist/index.d.mts +82 -0
  34. package/dist/index.mjs +948 -0
  35. package/dist/io/anthropic/ask.d.mts +11 -0
  36. package/dist/io/anthropic/ask.mjs +181 -0
  37. package/dist/io/anthropic/commit-response.d.mts +21 -0
  38. package/dist/io/anthropic/commit-response.mjs +10 -0
  39. package/dist/io/anthropic/index.d.mts +14 -0
  40. package/dist/io/anthropic/index.mjs +199 -0
  41. package/dist/io/anthropic/parse.d.mts +20 -0
  42. package/dist/io/anthropic/parse.mjs +10 -0
  43. package/dist/io/ask-llm.d.mts +19 -0
  44. package/dist/io/ask-llm.mjs +573 -0
  45. package/dist/io/gemini/ask.d.mts +11 -0
  46. package/dist/io/gemini/ask.mjs +206 -0
  47. package/dist/io/gemini/commit-response.d.mts +11 -0
  48. package/dist/io/gemini/commit-response.mjs +7 -0
  49. package/dist/io/gemini/index.d.mts +14 -0
  50. package/dist/io/gemini/index.mjs +222 -0
  51. package/dist/io/gemini/parse.d.mts +20 -0
  52. package/dist/io/gemini/parse.mjs +11 -0
  53. package/dist/io/huggingface/ask.d.mts +13 -0
  54. package/dist/io/huggingface/ask.mjs +397 -0
  55. package/dist/io/huggingface/commit-response.d.mts +39 -0
  56. package/dist/io/huggingface/commit-response.mjs +14 -0
  57. package/dist/io/huggingface/index.d.mts +13 -0
  58. package/dist/io/huggingface/index.mjs +418 -0
  59. package/dist/io/huggingface/languagesMap.d.mts +191 -0
  60. package/dist/io/huggingface/languagesMap.mjs +187 -0
  61. package/dist/io/huggingface/parse.d.mts +20 -0
  62. package/dist/io/huggingface/parse.mjs +9 -0
  63. package/dist/logger.d.mts +10 -0
  64. package/dist/logger.mjs +43 -0
  65. package/dist/logger.test.d.mts +2 -0
  66. package/dist/logger.test.mjs +18683 -0
  67. package/dist/schemas/config.shcema.d.mts +199 -0
  68. package/dist/schemas/config.shcema.mjs +52 -0
  69. package/dist/types/index.d.mts +28 -0
  70. package/dist/types/index.mjs +1 -0
  71. package/package.json +15 -10
  72. package/.nvmrc +0 -1
  73. package/gringow.json +0 -12
  74. package/src/browser.ts +0 -4
  75. package/src/config.ts +0 -93
  76. package/src/data/check-cache.ts +0 -15
  77. package/src/data/clear-cache.ts +0 -5
  78. package/src/data/create-cache-dir.ts +0 -7
  79. package/src/data/delete-cache-item.ts +0 -20
  80. package/src/data/get-cache.ts +0 -17
  81. package/src/data/get-or-create-cache.ts +0 -21
  82. package/src/data/save-cache.ts +0 -17
  83. package/src/data/write-cache-to-disk.ts +0 -20
  84. package/src/default-config.ts +0 -27
  85. package/src/flat-template-string.test.ts +0 -109
  86. package/src/flat-template-string.ts +0 -27
  87. package/src/gringow.ts +0 -49
  88. package/src/index.ts +0 -37
  89. package/src/io/anthropic/ask.ts +0 -31
  90. package/src/io/anthropic/commit-response.ts +0 -11
  91. package/src/io/anthropic/index.ts +0 -3
  92. package/src/io/anthropic/parse.ts +0 -11
  93. package/src/io/ask-llm.ts +0 -44
  94. package/src/io/gemini/ask.ts +0 -65
  95. package/src/io/gemini/commit-response.ts +0 -6
  96. package/src/io/gemini/index.ts +0 -3
  97. package/src/io/gemini/parse.ts +0 -12
  98. package/src/io/huggingface/ask.ts +0 -82
  99. package/src/io/huggingface/commit-response.ts +0 -16
  100. package/src/io/huggingface/index.ts +0 -16
  101. package/src/io/huggingface/languagesMap.ts +0 -189
  102. package/src/io/huggingface/parse.ts +0 -10
  103. package/src/logger.ts +0 -25
  104. package/src/schemas/config.shcema.ts +0 -58
  105. package/src/types/index.ts +0 -22
  106. package/tsconfig.json +0 -29
  107. package/tsup.config.ts +0 -21
  108. package/vitest.config.ts +0 -8
@@ -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 };