@contentstorage/core 3.2.0 → 3.2.1
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/commands/cli.js +4 -0
- package/dist/commands/pull.js +4 -0
- package/dist/commands/push.js +4 -0
- package/dist/commands/stats.js +4 -0
- package/dist/commands/translate.js +10 -3
- package/dist/core/api-client.d.ts +2 -1
- package/dist/core/api-client.js +4 -3
- package/dist/core/config-loader.js +1 -0
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
package/dist/commands/cli.js
CHANGED
|
@@ -15,6 +15,7 @@ const COMMANDS = {
|
|
|
15
15
|
' --content-key <key> Content key (read-only access)',
|
|
16
16
|
' --api-key <key> API key (read + write access)',
|
|
17
17
|
' --project-id <id> Project ID (required with --api-key)',
|
|
18
|
+
' --api-url <url> API base URL (default: production)',
|
|
18
19
|
' --content-dir <dir> Directory to save content files',
|
|
19
20
|
' --lang <code> Language code (e.g., EN, FR)',
|
|
20
21
|
' --pending-changes Fetch pending/draft content',
|
|
@@ -28,6 +29,7 @@ const COMMANDS = {
|
|
|
28
29
|
options: [
|
|
29
30
|
' --api-key <key> API key for authentication (required)',
|
|
30
31
|
' --project-id <id> Project ID (required)',
|
|
32
|
+
' --api-url <url> API base URL (default: production)',
|
|
31
33
|
' --content-dir <dir> Directory with content files',
|
|
32
34
|
' --lang <code> Language code to push (e.g., EN)',
|
|
33
35
|
' --dry-run Preview changes without applying',
|
|
@@ -52,6 +54,7 @@ const COMMANDS = {
|
|
|
52
54
|
' --content-key <key> Content key (read-only access)',
|
|
53
55
|
' --api-key <key> API key (read + write access)',
|
|
54
56
|
' --project-id <id> Project ID (required with --api-key)',
|
|
57
|
+
' --api-url <url> API base URL (default: production)',
|
|
55
58
|
' --content-dir <dir> Directory with content files',
|
|
56
59
|
' --pending-changes Analyze pending/draft content',
|
|
57
60
|
],
|
|
@@ -72,6 +75,7 @@ const COMMANDS = {
|
|
|
72
75
|
options: [
|
|
73
76
|
' --api-key <key> API key for authentication',
|
|
74
77
|
' --project-id <id> Project ID',
|
|
78
|
+
' --api-url <url> API base URL (default: production)',
|
|
75
79
|
' --content-dir <dir> Directory with content files',
|
|
76
80
|
' --lang <code> Source language code (e.g., EN)',
|
|
77
81
|
' --dry-run Preview changes without pushing',
|
package/dist/commands/pull.js
CHANGED
|
@@ -38,6 +38,9 @@ export async function pullContent() {
|
|
|
38
38
|
else if (key === 'project-id') {
|
|
39
39
|
cliConfig.projectId = value;
|
|
40
40
|
}
|
|
41
|
+
else if (key === 'api-url') {
|
|
42
|
+
cliConfig.apiUrl = value;
|
|
43
|
+
}
|
|
41
44
|
// Skip the value in the next iteration
|
|
42
45
|
i++;
|
|
43
46
|
}
|
|
@@ -78,6 +81,7 @@ export async function pullContent() {
|
|
|
78
81
|
? createApiClient({
|
|
79
82
|
apiKey: config.apiKey,
|
|
80
83
|
projectId: config.projectId,
|
|
84
|
+
apiUrl: config.apiUrl,
|
|
81
85
|
})
|
|
82
86
|
: null;
|
|
83
87
|
// If using API client and no languages specified, fetch from project info
|
package/dist/commands/push.js
CHANGED
|
@@ -30,6 +30,9 @@ export async function pushContent() {
|
|
|
30
30
|
else if (key === 'content-dir') {
|
|
31
31
|
cliConfig.contentDir = value;
|
|
32
32
|
}
|
|
33
|
+
else if (key === 'api-url') {
|
|
34
|
+
cliConfig.apiUrl = value;
|
|
35
|
+
}
|
|
33
36
|
i++; // Skip the value in next iteration
|
|
34
37
|
}
|
|
35
38
|
}
|
|
@@ -69,6 +72,7 @@ export async function pushContent() {
|
|
|
69
72
|
const apiClient = createApiClient({
|
|
70
73
|
apiKey: config.apiKey,
|
|
71
74
|
projectId: config.projectId,
|
|
75
|
+
apiUrl: config.apiUrl,
|
|
72
76
|
});
|
|
73
77
|
if (!apiClient) {
|
|
74
78
|
console.error(chalk.red('Failed to create API client'));
|
package/dist/commands/stats.js
CHANGED
|
@@ -267,6 +267,9 @@ export async function showStats() {
|
|
|
267
267
|
else if (key === 'project-id') {
|
|
268
268
|
cliConfig.projectId = value;
|
|
269
269
|
}
|
|
270
|
+
else if (key === 'api-url') {
|
|
271
|
+
cliConfig.apiUrl = value;
|
|
272
|
+
}
|
|
270
273
|
i++; // Skip the value in next iteration
|
|
271
274
|
}
|
|
272
275
|
}
|
|
@@ -296,6 +299,7 @@ export async function showStats() {
|
|
|
296
299
|
const apiClient = createApiClient({
|
|
297
300
|
apiKey: config.apiKey,
|
|
298
301
|
projectId: config.projectId,
|
|
302
|
+
apiUrl: config.apiUrl,
|
|
299
303
|
});
|
|
300
304
|
if (!apiClient) {
|
|
301
305
|
console.error(chalk.red('Failed to create API client'));
|
|
@@ -77,6 +77,9 @@ export async function translateContent() {
|
|
|
77
77
|
else if (key === 'content-dir') {
|
|
78
78
|
cliConfig.contentDir = value;
|
|
79
79
|
}
|
|
80
|
+
else if (key === 'api-url') {
|
|
81
|
+
cliConfig.apiUrl = value;
|
|
82
|
+
}
|
|
80
83
|
i++;
|
|
81
84
|
}
|
|
82
85
|
}
|
|
@@ -117,6 +120,7 @@ export async function translateContent() {
|
|
|
117
120
|
const apiClient = createApiClient({
|
|
118
121
|
apiKey: config.apiKey,
|
|
119
122
|
projectId: config.projectId,
|
|
123
|
+
apiUrl: config.apiUrl,
|
|
120
124
|
});
|
|
121
125
|
if (!apiClient) {
|
|
122
126
|
console.error(chalk.red('Failed to create API client'));
|
|
@@ -230,11 +234,14 @@ export async function translateContent() {
|
|
|
230
234
|
const pushed = result.keysAdded + result.keysUpdated;
|
|
231
235
|
console.log(chalk.green(`\n✓ ${pushed} keys pushed (${result.keysAdded} new, ${result.keysUpdated} modified)`) +
|
|
232
236
|
(response.session ? chalk.dim(` [session: ${response.session.id}]`) : ''));
|
|
233
|
-
// Step 7:
|
|
237
|
+
// Step 7: Show session URL and ask before opening browser
|
|
234
238
|
if (response.session) {
|
|
235
|
-
console.log(chalk.bold('\n→
|
|
239
|
+
console.log(chalk.bold('\n→ Translate session created:'));
|
|
236
240
|
console.log(chalk.cyan(` ${response.session.url}`));
|
|
237
|
-
|
|
241
|
+
const openAnswer = await prompt('Open in browser? (Y/n) ');
|
|
242
|
+
if (openAnswer.toLowerCase() !== 'n') {
|
|
243
|
+
openInBrowser(response.session.url);
|
|
244
|
+
}
|
|
238
245
|
}
|
|
239
246
|
}
|
|
240
247
|
catch (error) {
|
|
@@ -77,7 +77,7 @@ export interface ApiError {
|
|
|
77
77
|
export declare class ApiClient {
|
|
78
78
|
private client;
|
|
79
79
|
private projectId;
|
|
80
|
-
constructor(apiKey: string, projectId: string);
|
|
80
|
+
constructor(apiKey: string, projectId: string, apiUrl?: string);
|
|
81
81
|
/**
|
|
82
82
|
* Handle API errors consistently
|
|
83
83
|
*/
|
|
@@ -119,4 +119,5 @@ export declare class ApiClient {
|
|
|
119
119
|
export declare function createApiClient(config: {
|
|
120
120
|
apiKey?: string;
|
|
121
121
|
projectId?: string;
|
|
122
|
+
apiUrl?: string;
|
|
122
123
|
}): ApiClient | null;
|
package/dist/core/api-client.js
CHANGED
|
@@ -5,10 +5,11 @@
|
|
|
5
5
|
import axios from 'axios';
|
|
6
6
|
import { CONTENTSTORAGE_CONFIG } from '../utils/constants.js';
|
|
7
7
|
export class ApiClient {
|
|
8
|
-
constructor(apiKey, projectId) {
|
|
8
|
+
constructor(apiKey, projectId, apiUrl) {
|
|
9
9
|
this.projectId = projectId;
|
|
10
|
+
const baseApiUrl = apiUrl || CONTENTSTORAGE_CONFIG.API_URL;
|
|
10
11
|
this.client = axios.create({
|
|
11
|
-
baseURL: `${
|
|
12
|
+
baseURL: `${baseApiUrl}/api/v1/cli`,
|
|
12
13
|
headers: {
|
|
13
14
|
Authorization: `Bearer ${apiKey}`,
|
|
14
15
|
'Content-Type': 'application/json',
|
|
@@ -114,5 +115,5 @@ export function createApiClient(config) {
|
|
|
114
115
|
if (!config.apiKey || !config.projectId) {
|
|
115
116
|
return null;
|
|
116
117
|
}
|
|
117
|
-
return new ApiClient(config.apiKey, config.projectId);
|
|
118
|
+
return new ApiClient(config.apiKey, config.projectId, config.apiUrl);
|
|
118
119
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export type AppConfig = {
|
|
|
7
7
|
flatten?: boolean;
|
|
8
8
|
apiKey?: string;
|
|
9
9
|
projectId?: string;
|
|
10
|
+
apiUrl?: string;
|
|
10
11
|
};
|
|
11
12
|
export type LanguageCode = 'SQ' | 'BE' | 'BS' | 'BG' | 'HR' | 'CS' | 'DA' | 'NL' | 'EN' | 'ET' | 'FI' | 'FR' | 'DE' | 'EL' | 'HU' | 'GA' | 'IT' | 'LV' | 'LT' | 'MK' | 'NO' | 'PL' | 'PT' | 'RO' | 'RU' | 'SR' | 'SK' | 'SL' | 'ES' | 'SV' | 'TR' | 'UK';
|
|
12
13
|
/**
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@contentstorage/core",
|
|
3
3
|
"author": "Kaido Hussar <kaido@contentstorage.app>",
|
|
4
4
|
"homepage": "https://contentstorage.app",
|
|
5
|
-
"version": "3.2.
|
|
5
|
+
"version": "3.2.1",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"description": "Contentstorage CLI for managing translations and generating TypeScript types",
|
|
8
8
|
"license": "MIT",
|