gt 2.21.5 → 2.22.0
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 +32 -0
- package/dist/api/collectUserEditDiffs.js +1 -1
- package/dist/auth/callbackPage.d.ts +1 -0
- package/dist/auth/callbackPage.js +77 -0
- package/dist/auth/callbackPage.js.map +1 -0
- package/dist/auth/credentialStore.d.ts +15 -0
- package/dist/auth/credentialStore.js +107 -0
- package/dist/auth/credentialStore.js.map +1 -0
- package/dist/auth/errors.d.ts +7 -0
- package/dist/auth/errors.js +23 -0
- package/dist/auth/errors.js.map +1 -0
- package/dist/auth/loopback.d.ts +9 -0
- package/dist/auth/loopback.js +73 -0
- package/dist/auth/loopback.js.map +1 -0
- package/dist/auth/loopback.test.d.ts +1 -0
- package/dist/auth/oauth.d.ts +39 -0
- package/dist/auth/oauth.js +260 -0
- package/dist/auth/oauth.js.map +1 -0
- package/dist/bin/bin-entry.js +2 -10
- package/dist/bin/bin-entry.js.map +1 -1
- package/dist/cli/base.d.ts +4 -8
- package/dist/cli/base.js +119 -60
- package/dist/cli/base.js.map +1 -1
- package/dist/cli/commands/api.js +6 -2
- package/dist/cli/commands/api.js.map +1 -1
- package/dist/cli/commands/upload.js +2 -2
- package/dist/cli/commands/upload.js.map +1 -1
- package/dist/cli/commands/utils/validation.d.ts +7 -7
- package/dist/cli/commands/utils/validation.js +7 -20
- package/dist/cli/commands/utils/validation.js.map +1 -1
- package/dist/config/generateSettings.js +4 -9
- package/dist/config/generateSettings.js.map +1 -1
- package/dist/config/optionPresets.js +16 -6
- package/dist/config/optionPresets.js.map +1 -1
- package/dist/config/validateSettings.d.ts +4 -2
- package/dist/config/validateSettings.js +9 -0
- package/dist/config/validateSettings.js.map +1 -1
- package/dist/console/index.d.ts +0 -2
- package/dist/console/index.js +2 -4
- package/dist/console/index.js.map +1 -1
- package/dist/console/inkPrompts.js +8 -6
- package/dist/console/inkPrompts.js.map +1 -1
- package/dist/console/inkTypes.d.ts +3 -0
- package/dist/console/logger.d.ts +13 -0
- package/dist/console/logger.js +60 -20
- package/dist/console/logger.js.map +1 -1
- package/dist/console/logging.d.ts +5 -3
- package/dist/console/logging.js +8 -6
- package/dist/console/logging.js.map +1 -1
- package/dist/console/promptParsing.d.ts +4 -3
- package/dist/console/promptParsing.js +7 -7
- package/dist/console/promptParsing.js.map +1 -1
- package/dist/formats/files/aggregateFiles.js +4 -4
- package/dist/formats/files/aggregateFiles.js.map +1 -1
- package/dist/formats/files/localeContent.js +2 -2
- package/dist/formats/files/localeContent.js.map +1 -1
- package/dist/formats/files/transformFormat.d.ts +2 -0
- package/dist/formats/files/transformFormat.js +8 -2
- package/dist/formats/files/transformFormat.js.map +1 -1
- package/dist/formats/json/extractJson.js +3 -3
- package/dist/formats/json/extractJson.js.map +1 -1
- package/dist/formats/json/mergeJson.js +6 -6
- package/dist/formats/json/mergeJson.js.map +1 -1
- package/dist/formats/xcstrings/mergeXcstrings.js +2 -2
- package/dist/formats/xcstrings/mergeXcstrings.js.map +1 -1
- package/dist/generated/version.d.ts +1 -1
- package/dist/generated/version.js +1 -1
- package/dist/generated/version.js.map +1 -1
- package/dist/git/setupMergeDrivers.js +1 -1
- package/dist/git/setupMergeDrivers.js.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/main.js +2 -10
- package/dist/main.js.map +1 -1
- package/dist/react/jsx/utils/jsxParsing/addGTIdentifierToSyntaxTree.js +1 -1
- package/dist/react/jsx/utils/jsxParsing/parseJsx.js +1 -1
- package/dist/react/jsx/utils/parseString.js +1 -1
- package/dist/react/jsx/utils/stringParsing/derivation/index.js +1 -1
- package/dist/setup/developmentCredentials.d.ts +8 -0
- package/dist/setup/developmentCredentials.js +82 -0
- package/dist/setup/developmentCredentials.js.map +1 -0
- package/dist/setup/setupViteSPA.js +1 -1
- package/dist/setup/setupViteSPA.js.map +1 -1
- package/dist/setup/userInput.d.ts +1 -0
- package/dist/setup/userInput.js +7 -2
- package/dist/setup/userInput.js.map +1 -1
- package/dist/translation/extractInline.js +1 -1
- package/dist/translation/extractInline.js.map +1 -1
- package/dist/types/index.d.ts +4 -1
- package/dist/utils/api.d.ts +146 -67
- package/dist/utils/api.js +5 -94
- package/dist/utils/api.js.map +1 -1
- package/dist/utils/credentials.d.ts +37 -10
- package/dist/utils/credentials.js +267 -58
- package/dist/utils/credentials.js.map +1 -1
- package/dist/utils/loadEnv.d.ts +2 -0
- package/dist/utils/loadEnv.js +24 -0
- package/dist/utils/loadEnv.js.map +1 -0
- package/dist/utils/reactPackageCompatibility.js +1 -1
- package/dist/utils/reactPackageCompatibility.js.map +1 -1
- package/dist/workflows/steps/PollJobsStep.js +40 -53
- package/dist/workflows/steps/PollJobsStep.js.map +1 -1
- package/dist/workflows/utils/syncFonts.js +2 -2
- package/dist/workflows/utils/syncFonts.js.map +1 -1
- package/package.json +8 -7
- package/dist/next/config/parseNextConfig.d.ts +0 -10
- package/dist/next/config/parseNextConfig.js +0 -34
- package/dist/next/config/parseNextConfig.js.map +0 -1
- package/dist/utils/fetch.d.ts +0 -11
- package/dist/utils/fetch.js +0 -24
- package/dist/utils/fetch.js.map +0 -1
- package/dist/utils/gt.d.ts +0 -2
- package/dist/utils/gt.js +0 -7
- package/dist/utils/gt.js.map +0 -1
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { CustomMapping } from '@generaltranslation/format/types';
|
|
2
|
+
import type { UserTokenProvider } from 'generaltranslation/api';
|
|
3
|
+
import type { ModelProvider } from 'generaltranslation/internal';
|
|
2
4
|
import type { FileFormat } from 'generaltranslation/types';
|
|
3
5
|
import { SUPPORTED_FILE_EXTENSIONS } from '../formats/files/supportedFiles.js';
|
|
4
6
|
import { ParsingConfigOptions, GTParsingFlags, BaseParsingFlags, ParseFlagsByFileType } from './parsing.js';
|
|
@@ -179,6 +181,7 @@ export type Settings = {
|
|
|
179
181
|
baseUrl: string;
|
|
180
182
|
dashboardUrl: string;
|
|
181
183
|
apiKey?: string;
|
|
184
|
+
userTokenProvider?: UserTokenProvider;
|
|
182
185
|
projectId?: string;
|
|
183
186
|
defaultLocale: string;
|
|
184
187
|
locales: string[];
|
|
@@ -214,7 +217,7 @@ export type Settings = {
|
|
|
214
217
|
fonts?: FontsConfig;
|
|
215
218
|
framework?: SupportedFrameworks;
|
|
216
219
|
options?: AdditionalOptions;
|
|
217
|
-
modelProvider?:
|
|
220
|
+
modelProvider?: ModelProvider;
|
|
218
221
|
tag?: string;
|
|
219
222
|
tagMessage?: string;
|
|
220
223
|
parsingOptions: ParsingConfigOptions;
|
package/dist/utils/api.d.ts
CHANGED
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
import type { CustomMapping } from '@generaltranslation/format/types';
|
|
2
|
-
import {
|
|
2
|
+
import type { ApiClientConfig } from 'generaltranslation/api';
|
|
3
3
|
export declare function configureApiClient(config: ApiClientConfig & {
|
|
4
4
|
customMapping?: CustomMapping;
|
|
5
5
|
}): void;
|
|
6
6
|
export declare const api: {
|
|
7
|
-
|
|
8
|
-
branches: Array<import("@generaltranslation/api").Branch>;
|
|
9
|
-
defaultBranch: import("@generaltranslation/api").Branch & ({
|
|
10
|
-
[key: string]: unknown;
|
|
11
|
-
} | null);
|
|
12
|
-
}>;
|
|
13
|
-
checkJobStatus(jobIds: string[]): Promise<({
|
|
7
|
+
checkJobStatus(jobIds: string[], signal?: AbortSignal): Promise<({
|
|
14
8
|
status: "queued";
|
|
15
9
|
jobId: string;
|
|
16
10
|
} | {
|
|
@@ -37,22 +31,80 @@ export declare const api: {
|
|
|
37
31
|
currentLocales: Array<string>;
|
|
38
32
|
autoApprove: boolean;
|
|
39
33
|
}>;
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
34
|
+
resolveAliasLocale(locale: string): string;
|
|
35
|
+
resolveCanonicalLocale(locale: string): string;
|
|
36
|
+
translate: (source: import("generaltranslation/types").TranslateManyEntry, options: string | import("generaltranslation/types").TranslateOptions, timeoutMs?: number | false) => Promise<import("generaltranslation/types").TranslationResult>;
|
|
37
|
+
translateMany: {
|
|
38
|
+
(sources: import("generaltranslation/types").TranslateManyEntry[], options: string | import("generaltranslation/types").TranslateOptions, timeoutMs?: number | false): Promise<import("generaltranslation/types").TranslateManyResult>;
|
|
39
|
+
(sources: Record<string, import("generaltranslation/types").TranslateManyEntry>, options: string | import("generaltranslation/types").TranslateOptions, timeoutMs?: number | false): Promise<Record<string, import("generaltranslation/types").TranslationResult>>;
|
|
40
|
+
};
|
|
41
|
+
queryBranchData(body: import("@generaltranslation/api").GetBranchInfoData["body"]): Promise<{
|
|
42
|
+
branches: Array<import("@generaltranslation/api").Branch>;
|
|
43
|
+
defaultBranch: import("@generaltranslation/api").Branch & ({
|
|
44
|
+
[key: string]: unknown;
|
|
45
|
+
} | null);
|
|
46
|
+
}>;
|
|
47
|
+
createBranch(body: import("@generaltranslation/api").CreateBranchData["body"]): Promise<{
|
|
48
|
+
branch: import("@generaltranslation/api").Branch;
|
|
49
|
+
}>;
|
|
50
|
+
processFileMoves(moves: import("@generaltranslation/api").ProcessFileMovesData["body"]["moves"], options?: Pick<import("@generaltranslation/api").ProcessFileMovesData["body"], "branchId"> & {
|
|
51
|
+
timeout?: number;
|
|
52
|
+
}): Promise<{
|
|
53
|
+
results: {
|
|
54
|
+
oldFileId: string;
|
|
55
|
+
newFileId: string;
|
|
46
56
|
success: boolean;
|
|
57
|
+
newSourceFileId?: string;
|
|
58
|
+
clonedTranslationsCount?: number;
|
|
47
59
|
error?: string;
|
|
60
|
+
}[];
|
|
61
|
+
summary: {
|
|
62
|
+
total: number;
|
|
63
|
+
succeeded: number;
|
|
64
|
+
failed: number;
|
|
65
|
+
};
|
|
66
|
+
}>;
|
|
67
|
+
getOrphanedFiles(branchId: string, fileIds: string[], options?: {
|
|
68
|
+
timeout?: number;
|
|
69
|
+
}): Promise<{
|
|
70
|
+
orphanedFiles: Array<{
|
|
71
|
+
fileId: string;
|
|
72
|
+
versionId: string;
|
|
73
|
+
fileName: string;
|
|
48
74
|
}>;
|
|
49
75
|
}>;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
76
|
+
setupProject(files: import("@generaltranslation/api").GenerateProjectContextData["body"]["files"], options?: Omit<import("@generaltranslation/api").GenerateProjectContextData["body"], "files"> & {
|
|
77
|
+
timeoutMs?: number;
|
|
78
|
+
}): Promise<{
|
|
79
|
+
status: "completed";
|
|
80
|
+
} | {
|
|
81
|
+
setupJobId: string;
|
|
82
|
+
status: "queued";
|
|
83
|
+
}>;
|
|
84
|
+
awaitJobs(jobIds: readonly string[], options?: import("@generaltranslation/api").AwaitJobsOptions): Promise<{
|
|
85
|
+
jobs: {
|
|
86
|
+
jobId: string;
|
|
87
|
+
status: import("@generaltranslation/api").GetTranslationJobInfoResponse[number]["status"];
|
|
88
|
+
error?: {
|
|
89
|
+
message: string;
|
|
90
|
+
};
|
|
91
|
+
}[];
|
|
92
|
+
complete: boolean;
|
|
93
|
+
}>;
|
|
94
|
+
enqueueFiles(files: import("@generaltranslation/api").EnqueueFileTranslationsData["body"]["files"], options: {
|
|
95
|
+
sourceLocale?: string;
|
|
96
|
+
targetLocales: string[];
|
|
97
|
+
modelProvider?: string;
|
|
98
|
+
force?: boolean;
|
|
99
|
+
timeout?: number;
|
|
100
|
+
}): Promise<{
|
|
101
|
+
jobData: {
|
|
102
|
+
[k: string]: any;
|
|
103
|
+
};
|
|
104
|
+
locales: string[];
|
|
53
105
|
message: string;
|
|
54
|
-
}
|
|
55
|
-
createTag(body: CreateTagData["body"]): Promise<{
|
|
106
|
+
}>;
|
|
107
|
+
createTag(body: import("@generaltranslation/api").CreateTagData["body"]): Promise<{
|
|
56
108
|
tag: {
|
|
57
109
|
id: string;
|
|
58
110
|
tagId: string;
|
|
@@ -61,7 +113,24 @@ export declare const api: {
|
|
|
61
113
|
updatedAt: string;
|
|
62
114
|
};
|
|
63
115
|
}>;
|
|
64
|
-
|
|
116
|
+
publishFiles(files: import("@generaltranslation/api").PublishFilesData["body"]["files"]): Promise<{
|
|
117
|
+
results: Array<{
|
|
118
|
+
fileId: string;
|
|
119
|
+
versionId: string;
|
|
120
|
+
locale?: string;
|
|
121
|
+
branchId: string;
|
|
122
|
+
success: boolean;
|
|
123
|
+
error?: string;
|
|
124
|
+
}>;
|
|
125
|
+
}>;
|
|
126
|
+
submitUserEditDiffs(body: import("@generaltranslation/api").SubmitUserEditDiffsData["body"], options?: {
|
|
127
|
+
timeout?: number;
|
|
128
|
+
}): Promise<{
|
|
129
|
+
filesProcessed: number;
|
|
130
|
+
entriesReceived: number;
|
|
131
|
+
message: string;
|
|
132
|
+
}[]>;
|
|
133
|
+
createProject(orgId: import("@generaltranslation/api").CreateProjectData["path"]["orgId"], body: import("@generaltranslation/api").CreateProjectData["body"]): Promise<{
|
|
65
134
|
project: {
|
|
66
135
|
id: string;
|
|
67
136
|
name: string;
|
|
@@ -69,34 +138,26 @@ export declare const api: {
|
|
|
69
138
|
defaultLocale: string;
|
|
70
139
|
};
|
|
71
140
|
}>;
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
total: number;
|
|
90
|
-
succeeded: number;
|
|
91
|
-
failed: number;
|
|
141
|
+
listProjects(): Promise<{
|
|
142
|
+
id: string;
|
|
143
|
+
name: string;
|
|
144
|
+
orgId: string;
|
|
145
|
+
orgName: string;
|
|
146
|
+
}[]>;
|
|
147
|
+
listOrgs(): Promise<{
|
|
148
|
+
id: string;
|
|
149
|
+
name: string;
|
|
150
|
+
}[]>;
|
|
151
|
+
createProjectApiKey(projectId: import("@generaltranslation/api").CreateProjectApiKeyData["path"]["projectId"], body: import("@generaltranslation/api").CreateProjectApiKeyData["body"]): Promise<{
|
|
152
|
+
apiKey: {
|
|
153
|
+
id: string;
|
|
154
|
+
name: string;
|
|
155
|
+
key: string;
|
|
156
|
+
projectId: string;
|
|
157
|
+
type: "production";
|
|
92
158
|
};
|
|
93
159
|
}>;
|
|
94
|
-
|
|
95
|
-
resolveCanonicalLocale(locale: string): string;
|
|
96
|
-
createBranch(body: import("@generaltranslation/api").CreateBranchData["body"]): Promise<{
|
|
97
|
-
branch: import("@generaltranslation/api").Branch;
|
|
98
|
-
}>;
|
|
99
|
-
queryFileData(body: import("@generaltranslation/api").GetFileInfoData["body"]): Promise<{
|
|
160
|
+
queryFileData(body: import("@generaltranslation/api").GetFileInfoData["body"], timeoutMs?: number): Promise<{
|
|
100
161
|
translatedFiles: {
|
|
101
162
|
locale: string;
|
|
102
163
|
branchId: string;
|
|
@@ -124,38 +185,46 @@ export declare const api: {
|
|
|
124
185
|
publishedAt: string | null;
|
|
125
186
|
}[];
|
|
126
187
|
}>;
|
|
127
|
-
|
|
188
|
+
querySourceFile(path: import("@generaltranslation/api").GetTranslationStatusData["path"], query?: import("@generaltranslation/api").GetTranslationStatusData["query"], timeoutMs?: number): Promise<{
|
|
189
|
+
translations: {
|
|
190
|
+
locale: string;
|
|
191
|
+
completedAt: string | null;
|
|
192
|
+
approvedAt: string | null;
|
|
193
|
+
publishedAt: string | null;
|
|
194
|
+
createdAt: string | null;
|
|
195
|
+
updatedAt: string | null;
|
|
196
|
+
}[];
|
|
197
|
+
sourceFile: {
|
|
198
|
+
sourceLocale: string;
|
|
199
|
+
locales: string[];
|
|
200
|
+
id: string;
|
|
201
|
+
branchId: string;
|
|
202
|
+
fileId: string;
|
|
203
|
+
versionId: string;
|
|
204
|
+
fileName: string;
|
|
205
|
+
fileFormat: import("@generaltranslation/api").FileFormat;
|
|
206
|
+
dataFormat: string | null;
|
|
207
|
+
createdAt: string;
|
|
208
|
+
updatedAt: string;
|
|
209
|
+
};
|
|
210
|
+
}>;
|
|
211
|
+
downloadFileBatch(files: import("@generaltranslation/api").DownloadFilesData["body"], options?: {
|
|
212
|
+
timeout?: number;
|
|
213
|
+
}): Promise<{
|
|
128
214
|
files: import("generaltranslation/types").DownloadedFile[];
|
|
129
215
|
count: number;
|
|
130
216
|
pending: {
|
|
217
|
+
locale: string;
|
|
131
218
|
branchId: string;
|
|
132
219
|
fileId: string;
|
|
133
|
-
locale: string;
|
|
134
220
|
versionId: string;
|
|
135
221
|
}[];
|
|
136
222
|
}>;
|
|
137
|
-
setupProject(files: import("@generaltranslation/api").GenerateProjectContextData["body"]["files"], options?: Omit<import("@generaltranslation/api").GenerateProjectContextData["body"], "files">): Promise<{
|
|
138
|
-
status: "completed";
|
|
139
|
-
} | {
|
|
140
|
-
setupJobId: string;
|
|
141
|
-
status: "queued";
|
|
142
|
-
}>;
|
|
143
|
-
enqueueFiles(files: import("@generaltranslation/api").EnqueueFileTranslationsData["body"]["files"], options: {
|
|
144
|
-
sourceLocale?: string;
|
|
145
|
-
targetLocales: string[];
|
|
146
|
-
modelProvider?: string;
|
|
147
|
-
force?: boolean;
|
|
148
|
-
}): Promise<{
|
|
149
|
-
jobData: {
|
|
150
|
-
[k: string]: any;
|
|
151
|
-
};
|
|
152
|
-
locales: string[];
|
|
153
|
-
message: string;
|
|
154
|
-
}>;
|
|
155
223
|
uploadSourceFiles(files: Array<{
|
|
156
224
|
source: import("@generaltranslation/api").UploadSourceFilesData["body"]["data"][number]["source"];
|
|
157
225
|
}>, options: {
|
|
158
226
|
sourceLocale: string;
|
|
227
|
+
timeout?: number;
|
|
159
228
|
}): Promise<{
|
|
160
229
|
uploadedFiles: {
|
|
161
230
|
branchId: string;
|
|
@@ -167,9 +236,19 @@ export declare const api: {
|
|
|
167
236
|
locale?: string;
|
|
168
237
|
}[];
|
|
169
238
|
}>;
|
|
170
|
-
|
|
239
|
+
uploadFonts(fonts: import("@generaltranslation/api").UploadAssetsData["body"]["assets"], options?: {
|
|
240
|
+
timeout?: number;
|
|
241
|
+
}): Promise<{
|
|
242
|
+
assets: {
|
|
243
|
+
id: string;
|
|
244
|
+
assetKey: string;
|
|
245
|
+
fileName: string;
|
|
246
|
+
}[];
|
|
247
|
+
count: number;
|
|
248
|
+
}>;
|
|
171
249
|
uploadTranslations(files: import("@generaltranslation/api").UploadTranslationsData["body"]["data"], options: {
|
|
172
250
|
sourceLocale: string;
|
|
251
|
+
timeout?: number;
|
|
173
252
|
}): Promise<{
|
|
174
253
|
uploadedFiles: {
|
|
175
254
|
branchId: string;
|
package/dist/utils/api.js
CHANGED
|
@@ -1,105 +1,16 @@
|
|
|
1
|
-
import { createGtApiAdapter
|
|
2
|
-
import { createApiClient, createProject, createTag, getBranchInfo, getOrphanedFiles, getProjectInfo, getTranslationJobInfo, processBatches, processFileMoves, publishFiles, submitUserEditDiffs } from "generaltranslation/api";
|
|
1
|
+
import { createGtApiAdapter } from "generaltranslation/internal";
|
|
3
2
|
//#region src/utils/api.ts
|
|
4
|
-
const { configure: configureSharedApi, getClient,
|
|
3
|
+
const { configure: configureSharedApi, getClient: _getClient, loadJobStatuses, loadProjectInfo, ...sharedApi } = createGtApiAdapter();
|
|
5
4
|
function configureApiClient(config) {
|
|
6
5
|
configureSharedApi(config);
|
|
7
6
|
}
|
|
8
7
|
const api = {
|
|
9
8
|
...sharedApi,
|
|
10
|
-
async
|
|
11
|
-
return
|
|
12
|
-
body,
|
|
13
|
-
client: getClient()
|
|
14
|
-
}));
|
|
15
|
-
},
|
|
16
|
-
async checkJobStatus(jobIds) {
|
|
17
|
-
return unwrapApiResult(await getTranslationJobInfo({
|
|
18
|
-
body: { jobIds },
|
|
19
|
-
client: getClient()
|
|
20
|
-
}));
|
|
9
|
+
async checkJobStatus(jobIds, signal) {
|
|
10
|
+
return loadJobStatuses(jobIds, { signal });
|
|
21
11
|
},
|
|
22
12
|
async getProjectInfo(timeoutMs) {
|
|
23
|
-
|
|
24
|
-
if (!config.projectId) throw new Error("Project ID is required to fetch project information");
|
|
25
|
-
return unwrapApiResult(await getProjectInfo({
|
|
26
|
-
client: createApiClient({
|
|
27
|
-
...config,
|
|
28
|
-
timeoutMs
|
|
29
|
-
}),
|
|
30
|
-
path: { projectId: config.projectId }
|
|
31
|
-
}));
|
|
32
|
-
},
|
|
33
|
-
async publishFiles(files) {
|
|
34
|
-
return unwrapApiResult(await publishFiles({
|
|
35
|
-
body: { files },
|
|
36
|
-
client: getClient()
|
|
37
|
-
}));
|
|
38
|
-
},
|
|
39
|
-
async submitUserEditDiffs(body) {
|
|
40
|
-
return processBatches(body.diffs, async (diffs) => [unwrapApiResult(await submitUserEditDiffs({
|
|
41
|
-
body: {
|
|
42
|
-
projectId: body.projectId,
|
|
43
|
-
diffs: diffs.map((diff) => ({
|
|
44
|
-
...diff,
|
|
45
|
-
locale: sharedApi.resolveCanonicalLocale(diff.locale)
|
|
46
|
-
}))
|
|
47
|
-
},
|
|
48
|
-
client: getClient()
|
|
49
|
-
}))]);
|
|
50
|
-
},
|
|
51
|
-
async createTag(body) {
|
|
52
|
-
return unwrapApiResult(await createTag({
|
|
53
|
-
body,
|
|
54
|
-
client: getClient()
|
|
55
|
-
}));
|
|
56
|
-
},
|
|
57
|
-
async createProject(orgId, body) {
|
|
58
|
-
return unwrapApiResult(await createProject({
|
|
59
|
-
path: { orgId },
|
|
60
|
-
body: {
|
|
61
|
-
...body,
|
|
62
|
-
defaultLocale: sharedApi.resolveCanonicalLocale(body.defaultLocale)
|
|
63
|
-
},
|
|
64
|
-
client: getClient()
|
|
65
|
-
}));
|
|
66
|
-
},
|
|
67
|
-
async getOrphanedFiles(branchId, fileIds) {
|
|
68
|
-
const request = async (batch) => unwrapApiResult(await getOrphanedFiles({
|
|
69
|
-
body: {
|
|
70
|
-
branchId,
|
|
71
|
-
fileIds: batch
|
|
72
|
-
},
|
|
73
|
-
client: getClient()
|
|
74
|
-
}));
|
|
75
|
-
if (fileIds.length === 0) return request([]);
|
|
76
|
-
const results = await processBatches(fileIds, async (batch) => [await request(batch)]);
|
|
77
|
-
const orphanedFiles = new Map(results[0].orphanedFiles.map((file) => [file.fileId, file]));
|
|
78
|
-
for (const result of results.slice(1)) {
|
|
79
|
-
const batchFileIds = new Set(result.orphanedFiles.map((file) => file.fileId));
|
|
80
|
-
for (const fileId of orphanedFiles.keys()) if (!batchFileIds.has(fileId)) orphanedFiles.delete(fileId);
|
|
81
|
-
}
|
|
82
|
-
return { orphanedFiles: [...orphanedFiles.values()] };
|
|
83
|
-
},
|
|
84
|
-
async processFileMoves(moves, options) {
|
|
85
|
-
const result = await processBatches(moves, async (batch) => {
|
|
86
|
-
return unwrapApiResult(await processFileMoves({
|
|
87
|
-
body: {
|
|
88
|
-
branchId: options.branchId,
|
|
89
|
-
moves: batch
|
|
90
|
-
},
|
|
91
|
-
client: getClient()
|
|
92
|
-
})).results;
|
|
93
|
-
});
|
|
94
|
-
const succeeded = result.filter(({ success }) => success).length;
|
|
95
|
-
return {
|
|
96
|
-
results: result,
|
|
97
|
-
summary: {
|
|
98
|
-
total: moves.length,
|
|
99
|
-
succeeded,
|
|
100
|
-
failed: result.length - succeeded
|
|
101
|
-
}
|
|
102
|
-
};
|
|
13
|
+
return loadProjectInfo(void 0, timeoutMs);
|
|
103
14
|
}
|
|
104
15
|
};
|
|
105
16
|
//#endregion
|
package/dist/utils/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","names":[],"sources":["../../src/utils/api.ts"],"sourcesContent":["import type { CustomMapping } from '@generaltranslation/format/types';\nimport
|
|
1
|
+
{"version":3,"file":"api.js","names":[],"sources":["../../src/utils/api.ts"],"sourcesContent":["import type { CustomMapping } from '@generaltranslation/format/types';\nimport type { ApiClientConfig } from 'generaltranslation/api';\nimport { createGtApiAdapter } from 'generaltranslation/internal';\n\nconst {\n configure: configureSharedApi,\n getClient: _getClient,\n loadJobStatuses,\n loadProjectInfo,\n ...sharedApi\n} = createGtApiAdapter();\n\nexport function configureApiClient(\n config: ApiClientConfig & { customMapping?: CustomMapping }\n): void {\n configureSharedApi(config);\n}\n\n// CLI keeps the raw service views: unaliased project locales and nullable\n// job errors, plus per-request cancellation for polling.\nexport const api = {\n ...sharedApi,\n\n async checkJobStatus(jobIds: string[], signal?: AbortSignal) {\n return loadJobStatuses(jobIds, { signal });\n },\n\n async getProjectInfo(timeoutMs: number) {\n return loadProjectInfo(undefined, timeoutMs);\n },\n};\n\nexport type ApiClient = typeof api;\n"],"mappings":";;AAIA,MAAM,EACJ,WAAW,oBACX,WAAW,YACX,iBACA,iBACA,GAAG,cACD,oBAAoB;AAExB,SAAgB,mBACd,QACM;AACN,oBAAmB,OAAO;;AAK5B,MAAa,MAAM;CACjB,GAAG;CAEH,MAAM,eAAe,QAAkB,QAAsB;AAC3D,SAAO,gBAAgB,QAAQ,EAAE,QAAQ,CAAC;;CAG5C,MAAM,eAAe,WAAmB;AACtC,SAAO,gBAAgB,KAAA,GAAW,UAAU;;CAE/C"}
|
|
@@ -1,16 +1,43 @@
|
|
|
1
1
|
import { Settings, SupportedFrameworks } from '../types/index.js';
|
|
2
|
-
type Credentials = {
|
|
3
|
-
|
|
2
|
+
export type Credentials = {
|
|
3
|
+
apiKey: string;
|
|
4
4
|
projectId: string;
|
|
5
5
|
};
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
/** Names of the runtime variables init writes for this framework. */
|
|
7
|
+
export declare function getDevelopmentEnvNames(framework?: SupportedFrameworks): {
|
|
8
|
+
projectId: string;
|
|
9
|
+
devApiKey: string;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* Whether the project already has a runtime key: the framework's development
|
|
13
|
+
* key, or an explicit production key for server runtimes (gt-next, gt-node).
|
|
14
|
+
* Browser frameworks only read their prefixed key, so there `settings.apiKey`
|
|
15
|
+
* is tooling auth alone. `settings.projectId` already resolves every
|
|
16
|
+
* framework prefix. Login is checked separately.
|
|
17
|
+
*/
|
|
18
|
+
export declare function areCredentialsSet(settings: Pick<Settings, 'projectId' | 'apiKey'>, framework?: SupportedFrameworks): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Where .env.local content lives and its mode. Follows an existing symlink so
|
|
21
|
+
* its referent is replaced, never the link itself; anything but a regular
|
|
22
|
+
* file (dangling link, directory) fails before any write.
|
|
23
|
+
*/
|
|
24
|
+
declare function resolveEnvFile(envFile: string): Promise<{
|
|
25
|
+
target: string;
|
|
26
|
+
mode: number;
|
|
27
|
+
} | undefined>;
|
|
28
|
+
type GitExposure = 'no-repository' | 'tracked' | 'ignored' | 'unignored';
|
|
29
|
+
type CredentialsEnvFile = {
|
|
30
|
+
envFile: string;
|
|
31
|
+
existing: Awaited<ReturnType<typeof resolveEnvFile>>;
|
|
32
|
+
exposure: GitExposure;
|
|
9
33
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
34
|
+
/**
|
|
35
|
+
* Everything that must hold before credentials may be saved to .env.local,
|
|
36
|
+
* so callers can fail before minting a key: the path is a regular file (or a
|
|
37
|
+
* link to one) or absent, and neither it nor a link's referent is tracked by
|
|
38
|
+
* Git. A referent inside any worktree must already be ignored there; only
|
|
39
|
+
* .env.local itself gets an ignore rule added, by setCredentials.
|
|
40
|
+
*/
|
|
41
|
+
export declare function inspectCredentialsEnvFile(cwd?: string): Promise<CredentialsEnvFile>;
|
|
15
42
|
export declare function setCredentials(credentials: Credentials, framework?: SupportedFrameworks, cwd?: string): Promise<void>;
|
|
16
43
|
export {};
|