generaltranslation 8.1.6 → 8.1.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/CHANGELOG.md +6 -0
- package/README.md +14 -105
- package/dist/index.d.ts +17 -17
- package/dist/types-dir/api/enqueueFiles.d.ts +3 -1
- package/dist/types-dir/api/file.d.ts +2 -1
- package/dist/types.d.ts +58 -56
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# generaltranslation
|
|
2
2
|
|
|
3
|
+
## 8.1.7
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [#960](https://github.com/generaltranslation/gt/pull/960) [`eb07e8c`](https://github.com/generaltranslation/gt/commit/eb07e8ce1b610551437b40f96c72ac76d0af7b67) Thanks [@ErnestM1234](https://github.com/ErnestM1234)! - chore: upload shared id for static content
|
|
8
|
+
|
|
3
9
|
## 8.1.6
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -1,116 +1,25 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<a href="https://generaltranslation.com"
|
|
3
|
-
<
|
|
2
|
+
<a href="https://generaltranslation.com/docs">
|
|
3
|
+
<picture>
|
|
4
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://generaltranslation.com/gt-logo-dark.svg">
|
|
5
|
+
<source media="(prefers-color-scheme: light)" srcset="https://generaltranslation.com/gt-logo-light.svg">
|
|
6
|
+
<img alt="General Translation" src="https://generaltranslation.com/gt-logo-light.svg" width="100" height="100">
|
|
7
|
+
</picture>
|
|
4
8
|
</a>
|
|
5
9
|
</p>
|
|
6
10
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
See our [docs](https://generaltranslation.com/docs) for more information including guides, examples, and API references.
|
|
12
|
-
|
|
13
|
-
## Development
|
|
14
|
-
|
|
15
|
-
### Prerequisites
|
|
16
|
-
|
|
17
|
-
- Node.js (>= 16.0.0)
|
|
18
|
-
- npm or yarn
|
|
19
|
-
|
|
20
|
-
### Installation
|
|
21
|
-
|
|
22
|
-
```bash
|
|
23
|
-
npm install
|
|
24
|
-
```
|
|
25
|
-
|
|
26
|
-
## Testing
|
|
27
|
-
|
|
28
|
-
This project uses [Vitest](https://vitest.dev/) for testing with two types of tests:
|
|
29
|
-
|
|
30
|
-
### Test Types
|
|
31
|
-
|
|
32
|
-
- **Unit Tests** (`__tests__/`): Fast, isolated tests with mocking
|
|
33
|
-
|
|
34
|
-
### Running Tests
|
|
35
|
-
|
|
36
|
-
```bash
|
|
37
|
-
# Run all tests (unit + e2e)
|
|
38
|
-
npm test
|
|
39
|
-
|
|
40
|
-
# Run only unit tests
|
|
41
|
-
npm test -- __tests__
|
|
42
|
-
|
|
43
|
-
# Run tests in watch mode
|
|
44
|
-
npm run test:watch
|
|
45
|
-
|
|
46
|
-
# Run specific test file
|
|
47
|
-
npm test -- __tests__/logging/logger.test.ts
|
|
48
|
-
|
|
49
|
-
# Run tests matching a pattern
|
|
50
|
-
npm test -- -t "should handle translation"
|
|
51
|
-
```
|
|
52
|
-
|
|
53
|
-
### Environment Variables
|
|
54
|
-
|
|
55
|
-
#### Required for E2E Tests
|
|
56
|
-
|
|
57
|
-
Create a `.env` file in the project root with:
|
|
58
|
-
|
|
59
|
-
```bash
|
|
60
|
-
# GT API Configuration
|
|
61
|
-
VITE_GT_API_KEY="your-dev-api-key"
|
|
62
|
-
VITE_GT_PROJECT_ID="your-project-id"
|
|
63
|
-
VITE_GT_RUNTIME_URL="http://localhost:10000"
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
> **Note**: E2E tests require a running GT runtime server at the specified URL. Without proper configuration, e2e tests will skip gracefully.
|
|
67
|
-
|
|
68
|
-
#### Optional: Logger Configuration
|
|
69
|
-
|
|
70
|
-
```bash
|
|
71
|
-
# Set logging level for development/debugging
|
|
72
|
-
_GT_LOG_LEVEL=debug # Options: debug, info, warn, error (default: warn)
|
|
73
|
-
```
|
|
11
|
+
<p align="center">
|
|
12
|
+
<a href="https://generaltranslation.com/docs"><strong>Documentation</strong></a> · <a href="https://github.com/generaltranslation/gt/issues">Report Bug</a>
|
|
13
|
+
</p>
|
|
74
14
|
|
|
75
|
-
|
|
15
|
+
# generaltranslation
|
|
76
16
|
|
|
77
|
-
|
|
78
|
-
- **Timeout**: 15 seconds per test (suitable for network-dependent e2e tests)
|
|
79
|
-
- **Environment**: Node.js environment for testing
|
|
17
|
+
Core library for General Translation. Used internally by `gt-react` and `gt-next`.
|
|
80
18
|
|
|
81
|
-
|
|
19
|
+
## Installation
|
|
82
20
|
|
|
83
21
|
```bash
|
|
84
|
-
|
|
85
|
-
_GT_LOG_LEVEL=debug npm test --reporter=verbose
|
|
86
|
-
|
|
87
|
-
# Quick unit test validation
|
|
88
|
-
npm test -- __tests__
|
|
89
|
-
|
|
90
|
-
# Test specific functionality
|
|
91
|
-
npm test -- -t "logger" --reporter=verbose
|
|
92
|
-
|
|
93
|
-
# Watch mode for development
|
|
94
|
-
npm run test:watch -- __tests__/
|
|
22
|
+
npm install generaltranslation
|
|
95
23
|
```
|
|
96
24
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
```
|
|
100
|
-
__tests__/ # Unit tests with mocking
|
|
101
|
-
├── logging/ # Logger functionality tests
|
|
102
|
-
└── translate/ # Translation logic tests
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
## Contributing
|
|
106
|
-
|
|
107
|
-
We welcome any contributions to our libraries. Please submit a pull request!
|
|
108
|
-
|
|
109
|
-
### Development Workflow
|
|
110
|
-
|
|
111
|
-
1. Install dependencies: `npm install`
|
|
112
|
-
2. Set up environment variables (see Testing section)
|
|
113
|
-
3. Run tests: `npm test`
|
|
114
|
-
4. Make your changes
|
|
115
|
-
5. Run tests again to ensure everything works
|
|
116
|
-
6. Submit a pull request
|
|
25
|
+
See the [full documentation](https://generaltranslation.com/docs) for guides and API reference.
|
package/dist/index.d.ts
CHANGED
|
@@ -159,6 +159,23 @@ type FileQueryResult = {
|
|
|
159
159
|
}[];
|
|
160
160
|
};
|
|
161
161
|
|
|
162
|
+
type EnqueueFilesResult = {
|
|
163
|
+
jobData: {
|
|
164
|
+
[jobId: string]: {
|
|
165
|
+
sourceFileId: string;
|
|
166
|
+
fileId: string;
|
|
167
|
+
versionId: string;
|
|
168
|
+
branchId: string;
|
|
169
|
+
targetLocale: string;
|
|
170
|
+
projectId: string;
|
|
171
|
+
force: boolean;
|
|
172
|
+
modelProvider?: string;
|
|
173
|
+
};
|
|
174
|
+
};
|
|
175
|
+
locales: string[];
|
|
176
|
+
message: string;
|
|
177
|
+
};
|
|
178
|
+
|
|
162
179
|
type FileFormat = 'GTJSON' | 'JSON' | 'YAML' | 'MDX' | 'MD' | 'TS' | 'JS' | 'HTML' | 'TXT';
|
|
163
180
|
/**
|
|
164
181
|
* File object structure for referencing files
|
|
@@ -201,23 +218,6 @@ type DownloadFileBatchResult = {
|
|
|
201
218
|
count: number;
|
|
202
219
|
};
|
|
203
220
|
|
|
204
|
-
type EnqueueFilesResult = {
|
|
205
|
-
jobData: {
|
|
206
|
-
[jobId: string]: {
|
|
207
|
-
sourceFileId: string;
|
|
208
|
-
fileId: string;
|
|
209
|
-
versionId: string;
|
|
210
|
-
branchId: string;
|
|
211
|
-
targetLocale: string;
|
|
212
|
-
projectId: string;
|
|
213
|
-
force: boolean;
|
|
214
|
-
modelProvider?: string;
|
|
215
|
-
};
|
|
216
|
-
};
|
|
217
|
-
locales: string[];
|
|
218
|
-
message: string;
|
|
219
|
-
};
|
|
220
|
-
|
|
221
221
|
/**
|
|
222
222
|
* Metadata stored alongside GTJSON file entries.
|
|
223
223
|
* Keys correspond to the entry id/hash in the GTJSON body.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { DataFormat } from '../jsx/content';
|
|
2
|
+
import { Updates } from './enqueueFiles';
|
|
2
3
|
import { Entry } from './entry';
|
|
3
4
|
export type FileFormat = 'GTJSON' | 'JSON' | 'YAML' | 'MDX' | 'MD' | 'TS' | 'JS' | 'HTML' | 'TXT';
|
|
4
5
|
export type FileMetadata = {
|
|
@@ -23,7 +24,7 @@ export type File = {
|
|
|
23
24
|
*/
|
|
24
25
|
export type FileToUpload = {
|
|
25
26
|
content: string;
|
|
26
|
-
formatMetadata?: Record<string, any
|
|
27
|
+
formatMetadata?: Record<string, any> | Updates[number]['metadata'];
|
|
27
28
|
incomingBranchId?: string;
|
|
28
29
|
checkedOutBranchId?: string;
|
|
29
30
|
locale: string;
|
package/dist/types.d.ts
CHANGED
|
@@ -152,6 +152,63 @@ type CheckFileTranslationsOptions = {
|
|
|
152
152
|
timeout?: number;
|
|
153
153
|
};
|
|
154
154
|
|
|
155
|
+
type Updates = ({
|
|
156
|
+
metadata: Record<string, any> & {
|
|
157
|
+
staticId?: string;
|
|
158
|
+
};
|
|
159
|
+
} & ({
|
|
160
|
+
dataFormat: 'JSX';
|
|
161
|
+
source: JsxChildren;
|
|
162
|
+
} | {
|
|
163
|
+
dataFormat: 'ICU';
|
|
164
|
+
source: string;
|
|
165
|
+
} | {
|
|
166
|
+
dataFormat: 'I18NEXT';
|
|
167
|
+
source: string;
|
|
168
|
+
} | {
|
|
169
|
+
dataFormat: 'DATE_FNS';
|
|
170
|
+
source: string;
|
|
171
|
+
}))[];
|
|
172
|
+
/**
|
|
173
|
+
* Options for enqueueing files
|
|
174
|
+
* @param publish - Whether to publish the files
|
|
175
|
+
* @param requireApproval - Whether to require approval for the files
|
|
176
|
+
* @param description - Optional description for the project
|
|
177
|
+
* @param sourceLocale - The project's source locale
|
|
178
|
+
* @param targetLocales - The locales to translate the files to
|
|
179
|
+
* @param version - Optional custom version ID to specify
|
|
180
|
+
* @param timeout - Optional timeout for the request
|
|
181
|
+
* @param modelProvider - Optional model provider to use
|
|
182
|
+
*/
|
|
183
|
+
type EnqueueFilesOptions = {
|
|
184
|
+
publish?: boolean;
|
|
185
|
+
requireApproval?: boolean;
|
|
186
|
+
description?: string;
|
|
187
|
+
sourceLocale?: string;
|
|
188
|
+
targetLocales: string[];
|
|
189
|
+
version?: string;
|
|
190
|
+
_versionId?: string;
|
|
191
|
+
timeout?: number;
|
|
192
|
+
modelProvider?: string;
|
|
193
|
+
force?: boolean;
|
|
194
|
+
};
|
|
195
|
+
type EnqueueFilesResult = {
|
|
196
|
+
jobData: {
|
|
197
|
+
[jobId: string]: {
|
|
198
|
+
sourceFileId: string;
|
|
199
|
+
fileId: string;
|
|
200
|
+
versionId: string;
|
|
201
|
+
branchId: string;
|
|
202
|
+
targetLocale: string;
|
|
203
|
+
projectId: string;
|
|
204
|
+
force: boolean;
|
|
205
|
+
modelProvider?: string;
|
|
206
|
+
};
|
|
207
|
+
};
|
|
208
|
+
locales: string[];
|
|
209
|
+
message: string;
|
|
210
|
+
};
|
|
211
|
+
|
|
155
212
|
type FileFormat = 'GTJSON' | 'JSON' | 'YAML' | 'MDX' | 'MD' | 'TS' | 'JS' | 'HTML' | 'TXT';
|
|
156
213
|
/**
|
|
157
214
|
* File object structure for uploading files
|
|
@@ -163,7 +220,7 @@ type FileFormat = 'GTJSON' | 'JSON' | 'YAML' | 'MDX' | 'MD' | 'TS' | 'JS' | 'HTM
|
|
|
163
220
|
*/
|
|
164
221
|
type FileToUpload = {
|
|
165
222
|
content: string;
|
|
166
|
-
formatMetadata?: Record<string, any
|
|
223
|
+
formatMetadata?: Record<string, any> | Updates[number]['metadata'];
|
|
167
224
|
incomingBranchId?: string;
|
|
168
225
|
checkedOutBranchId?: string;
|
|
169
226
|
locale: string;
|
|
@@ -217,61 +274,6 @@ type FetchTranslationsResult = {
|
|
|
217
274
|
translations: RetrievedTranslations;
|
|
218
275
|
};
|
|
219
276
|
|
|
220
|
-
type Updates = ({
|
|
221
|
-
metadata: Record<string, any>;
|
|
222
|
-
} & ({
|
|
223
|
-
dataFormat: 'JSX';
|
|
224
|
-
source: JsxChildren;
|
|
225
|
-
} | {
|
|
226
|
-
dataFormat: 'ICU';
|
|
227
|
-
source: string;
|
|
228
|
-
} | {
|
|
229
|
-
dataFormat: 'I18NEXT';
|
|
230
|
-
source: string;
|
|
231
|
-
} | {
|
|
232
|
-
dataFormat: 'DATE_FNS';
|
|
233
|
-
source: string;
|
|
234
|
-
}))[];
|
|
235
|
-
/**
|
|
236
|
-
* Options for enqueueing files
|
|
237
|
-
* @param publish - Whether to publish the files
|
|
238
|
-
* @param requireApproval - Whether to require approval for the files
|
|
239
|
-
* @param description - Optional description for the project
|
|
240
|
-
* @param sourceLocale - The project's source locale
|
|
241
|
-
* @param targetLocales - The locales to translate the files to
|
|
242
|
-
* @param version - Optional custom version ID to specify
|
|
243
|
-
* @param timeout - Optional timeout for the request
|
|
244
|
-
* @param modelProvider - Optional model provider to use
|
|
245
|
-
*/
|
|
246
|
-
type EnqueueFilesOptions = {
|
|
247
|
-
publish?: boolean;
|
|
248
|
-
requireApproval?: boolean;
|
|
249
|
-
description?: string;
|
|
250
|
-
sourceLocale?: string;
|
|
251
|
-
targetLocales: string[];
|
|
252
|
-
version?: string;
|
|
253
|
-
_versionId?: string;
|
|
254
|
-
timeout?: number;
|
|
255
|
-
modelProvider?: string;
|
|
256
|
-
force?: boolean;
|
|
257
|
-
};
|
|
258
|
-
type EnqueueFilesResult = {
|
|
259
|
-
jobData: {
|
|
260
|
-
[jobId: string]: {
|
|
261
|
-
sourceFileId: string;
|
|
262
|
-
fileId: string;
|
|
263
|
-
versionId: string;
|
|
264
|
-
branchId: string;
|
|
265
|
-
targetLocale: string;
|
|
266
|
-
projectId: string;
|
|
267
|
-
force: boolean;
|
|
268
|
-
modelProvider?: string;
|
|
269
|
-
};
|
|
270
|
-
};
|
|
271
|
-
locales: string[];
|
|
272
|
-
message: string;
|
|
273
|
-
};
|
|
274
|
-
|
|
275
277
|
/**
|
|
276
278
|
* Metadata stored alongside GTJSON file entries.
|
|
277
279
|
* Keys correspond to the entry id/hash in the GTJSON body.
|