@localess/cli 3.2.4-dev.20260611135516 → 3.2.4-dev.20260611210209
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/README.md +9 -5
- package/SKILL.md +2 -2
- package/dist/index.mjs +142 -240
- package/dist/src/client.d.ts +17 -143
- package/dist/src/models/index.d.ts +2 -12
- package/dist/src/models/space.d.ts +1 -1
- package/dist/src/models/translations.d.ts +1 -7
- package/dist/src/utils.d.ts +0 -3
- package/package.json +2 -1
- package/dist/src/cache.d.ts +0 -29
- package/dist/src/models/asset-metadata.d.ts +0 -29
- package/dist/src/models/assets.d.ts +0 -7
- package/dist/src/models/content-asset.d.ts +0 -13
- package/dist/src/models/content-data.d.ts +0 -27
- package/dist/src/models/content-link.d.ts +0 -21
- package/dist/src/models/content-metadata.d.ts +0 -41
- package/dist/src/models/content-reference.d.ts +0 -13
- package/dist/src/models/content-rich-text.d.ts +0 -13
- package/dist/src/models/content.d.ts +0 -26
- package/dist/src/models/links.d.ts +0 -7
- package/dist/src/models/locale.d.ts +0 -10
- package/dist/src/models/references.d.ts +0 -7
package/README.md
CHANGED
|
@@ -12,7 +12,7 @@ The `@localess/cli` package is the official command-line interface for the [Loca
|
|
|
12
12
|
|
|
13
13
|
## Requirements
|
|
14
14
|
|
|
15
|
-
- Node.js >=
|
|
15
|
+
- Node.js >= 24.0.0
|
|
16
16
|
|
|
17
17
|
## Installation
|
|
18
18
|
|
|
@@ -184,10 +184,11 @@ localess translations pull <locale> --path <file> [options]
|
|
|
184
184
|
|
|
185
185
|
**Options:**
|
|
186
186
|
|
|
187
|
-
| Flag | Default | Description
|
|
188
|
-
|
|
189
|
-
| `-p, --path <path>` | *(required)* | Output file path
|
|
190
|
-
| `-f, --format <format>` | `flat` | File format: `flat` or `nested`
|
|
187
|
+
| Flag | Default | Description |
|
|
188
|
+
|-------------------------|--------------|--------------------------------------|
|
|
189
|
+
| `-p, --path <path>` | *(required)* | Output file path |
|
|
190
|
+
| `-f, --format <format>` | `flat` | File format: `flat` or `nested` |
|
|
191
|
+
| `--draft` | `false` | Pull the draft (unpublished) version |
|
|
191
192
|
|
|
192
193
|
**Examples:**
|
|
193
194
|
|
|
@@ -197,6 +198,9 @@ localess translations pull en --path ./locales/en.json
|
|
|
197
198
|
|
|
198
199
|
# Pull German translations as nested JSON
|
|
199
200
|
localess translations pull de --path ./locales/de.json --format nested
|
|
201
|
+
|
|
202
|
+
# Pull draft (unpublished) translations
|
|
203
|
+
localess translations pull en --path ./locales/en.json --draft
|
|
200
204
|
```
|
|
201
205
|
|
|
202
206
|
---
|
package/SKILL.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
- Pushing and pulling translations (flat and nested JSON formats supported for both push and pull)
|
|
9
9
|
- Generating TypeScript type definitions from the OpenAPI schema
|
|
10
10
|
|
|
11
|
-
**Status:** Early development (v3.
|
|
11
|
+
**Status:** Early development (v3.2.4). Requires Node.js >= 24.0.0.
|
|
12
12
|
|
|
13
13
|
---
|
|
14
14
|
|
|
@@ -289,7 +289,7 @@ jobs:
|
|
|
289
289
|
- uses: actions/checkout@v4
|
|
290
290
|
- uses: actions/setup-node@v4
|
|
291
291
|
with:
|
|
292
|
-
node-version: '
|
|
292
|
+
node-version: '24'
|
|
293
293
|
- run: npm install -g @localess/cli
|
|
294
294
|
- run: localess translations push en --path ./locales/en.json
|
|
295
295
|
env:
|
package/dist/index.mjs
CHANGED
|
@@ -1,45 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { Command as e } from "commander";
|
|
3
3
|
import { input as t, password as n } from "@inquirer/prompts";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { localessClient as r } from "@localess/client";
|
|
5
|
+
import { access as i, appendFile as a, mkdir as o, readFile as s, writeFile as c } from "node:fs/promises";
|
|
6
|
+
import { join as l, parse as ee } from "node:path";
|
|
6
7
|
import * as u from "node:process";
|
|
7
|
-
import
|
|
8
|
+
import te from "node:process";
|
|
8
9
|
import { z as d } from "zod";
|
|
9
10
|
import f from "chalk";
|
|
10
11
|
//#region package.json
|
|
11
|
-
var p = "3.2.4-dev.
|
|
12
|
-
set(e, t) {}
|
|
13
|
-
get(e) {}
|
|
14
|
-
has(e) {
|
|
15
|
-
return !1;
|
|
16
|
-
}
|
|
17
|
-
}, m = class {
|
|
18
|
-
ttlMs;
|
|
19
|
-
cache = /* @__PURE__ */ new Map();
|
|
20
|
-
constructor(e = 3e5) {
|
|
21
|
-
this.ttlMs = e;
|
|
22
|
-
}
|
|
23
|
-
set(e, t) {
|
|
24
|
-
this.cache.set(e, {
|
|
25
|
-
value: t,
|
|
26
|
-
expiresAt: Date.now() + this.ttlMs
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
get(e) {
|
|
30
|
-
let t = this.cache.get(e);
|
|
31
|
-
if (t) {
|
|
32
|
-
if (Date.now() > t.expiresAt) {
|
|
33
|
-
this.cache.delete(e);
|
|
34
|
-
return;
|
|
35
|
-
}
|
|
36
|
-
return t.value;
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
has(e) {
|
|
40
|
-
return this.get(e) !== void 0;
|
|
41
|
-
}
|
|
42
|
-
}, ne = "\x1B[0m", re = "\x1B[34m";
|
|
12
|
+
var p = "3.2.4-dev.20260611210209", m = "\x1B[0m", ne = "\x1B[34m";
|
|
43
13
|
function h(e) {
|
|
44
14
|
return Object.keys(e).sort().reduce((t, n) => {
|
|
45
15
|
let r = e[n];
|
|
@@ -54,7 +24,7 @@ function g(e, t = "") {
|
|
|
54
24
|
}
|
|
55
25
|
return n;
|
|
56
26
|
}
|
|
57
|
-
function
|
|
27
|
+
function re(e) {
|
|
58
28
|
let t = {};
|
|
59
29
|
for (let [n, r] of Object.entries(e)) {
|
|
60
30
|
let e = n.split("."), i = t;
|
|
@@ -64,24 +34,24 @@ function _(e) {
|
|
|
64
34
|
}
|
|
65
35
|
//#endregion
|
|
66
36
|
//#region src/client.ts
|
|
67
|
-
var
|
|
68
|
-
async function
|
|
37
|
+
var _ = `${ne}[Localess:Client]${m}`;
|
|
38
|
+
async function v(e, t, n = 3, r = 500, i) {
|
|
69
39
|
let a = 0, o;
|
|
70
40
|
for (; a <= n;) {
|
|
71
41
|
try {
|
|
72
42
|
let n = await fetch(e, t);
|
|
73
|
-
if (!n.ok && n.status >= 500) i && console.log(
|
|
43
|
+
if (!n.ok && n.status >= 500) i && console.log(_, `fetchWithRetry: HTTP ${n.status} on attempt ${a + 1}`), o = /* @__PURE__ */ Error(`HTTP ${n.status}`);
|
|
74
44
|
else return n;
|
|
75
45
|
} catch (e) {
|
|
76
|
-
i && console.log(
|
|
46
|
+
i && console.log(_, `fetchWithRetry: network error on attempt ${a + 1}`, e), o = e;
|
|
77
47
|
}
|
|
78
48
|
a++, a <= n && await new Promise((e) => setTimeout(e, r));
|
|
79
49
|
}
|
|
80
50
|
throw o;
|
|
81
51
|
}
|
|
82
|
-
function
|
|
83
|
-
e.debug && console.log(
|
|
84
|
-
let t = e.origin.replace(/\/+$/, ""),
|
|
52
|
+
function y(e) {
|
|
53
|
+
e.debug && console.log(_, "Client Options : ", e);
|
|
54
|
+
let t = r(e), n = e.origin.replace(/\/+$/, ""), i = {
|
|
85
55
|
redirect: "follow",
|
|
86
56
|
headers: {
|
|
87
57
|
"Content-Type": "application/json",
|
|
@@ -89,178 +59,110 @@ function b(e) {
|
|
|
89
59
|
"X-Localess-Agent": "Localess-CLI-Client",
|
|
90
60
|
"X-Localess-Agent-Version": "0.9.0"
|
|
91
61
|
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
let
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
},
|
|
126
|
-
async getContentBySlug(r, a) {
|
|
127
|
-
e.debug && (console.log(v, "getContentBySlug() slug : ", r), console.log(v, "getContentBySlug() params : ", JSON.stringify(a)));
|
|
128
|
-
let o = "";
|
|
129
|
-
e?.version && e.version == "draft" && (o = `&version=${e.version}`), a?.version && a.version == "draft" && (o = `&version=${a.version}`);
|
|
130
|
-
let s = a?.locale ? `&locale=${a.locale}` : "", c = a?.resolveReference ? `&resolveReference=${a.resolveReference}` : "", l = a?.resolveLink ? `&resolveLink=${a.resolveLink}` : "", u = `${t}/api/v1/spaces/${e.spaceId}/contents/slugs/${r}?token=${e.token}${o}${s}${c}${l}`;
|
|
131
|
-
if (e.debug && console.log(v, "getContentBySlug fetch url : ", u), i.has(u)) return e.debug && console.log(v, "getContentBySlug cache hit"), i.get(u);
|
|
132
|
-
try {
|
|
133
|
-
let t = await y(u, n, e.retryCount, e.retryDelay, e.debug);
|
|
134
|
-
e.debug && console.log(v, "getContentBySlug status : ", t.status);
|
|
135
|
-
let r = await t.json();
|
|
136
|
-
return i.set(u, r), r;
|
|
137
|
-
} catch (e) {
|
|
138
|
-
return console.error(v, "getContentBySlug error : ", e), {};
|
|
139
|
-
}
|
|
140
|
-
},
|
|
141
|
-
async getContentById(r, a) {
|
|
142
|
-
e.debug && (console.log(v, "getContentById() id : ", r), console.log(v, "getContentById() params : ", JSON.stringify(a)));
|
|
143
|
-
let o = "";
|
|
144
|
-
e?.version && e.version == "draft" && (o = `&version=${e.version}`), a?.version && a.version == "draft" && (o = `&version=${a.version}`);
|
|
145
|
-
let s = a?.locale ? `&locale=${a.locale}` : "", c = a?.resolveReference ? `&resolveReference=${a.resolveReference}` : "", l = a?.resolveLink ? `&resolveLink=${a.resolveLink}` : "", u = `${t}/api/v1/spaces/${e.spaceId}/contents/${r}?token=${e.token}${o}${s}${c}${l}`;
|
|
146
|
-
if (e.debug && console.log(v, "getContentById fetch url : ", u), i.has(u)) return e.debug && console.log(v, "getContentById cache hit"), i.get(u);
|
|
147
|
-
try {
|
|
148
|
-
let t = await y(u, n, e.retryCount, e.retryDelay, e.debug);
|
|
149
|
-
e.debug && console.log(v, "getContentById status : ", t.status);
|
|
150
|
-
let r = await t.json();
|
|
151
|
-
return i.set(u, r), r;
|
|
152
|
-
} catch (e) {
|
|
153
|
-
return console.error(v, "getContentById error : ", e), {};
|
|
154
|
-
}
|
|
155
|
-
},
|
|
156
|
-
async getTranslations(r, a) {
|
|
157
|
-
e.debug && (console.log(v, "getTranslations() locale : ", r), console.log(v, "getTranslations() params : ", JSON.stringify(a)));
|
|
158
|
-
let o = "";
|
|
159
|
-
e?.version && e.version == "draft" && (o = `&version=${e.version}`), a?.version && a.version == "draft" && (o = `&version=${a.version}`);
|
|
160
|
-
let s = `${t}/api/v1/spaces/${e.spaceId}/translations/${r}?token=${e.token}${o}`;
|
|
161
|
-
if (e.debug && console.log(v, "getTranslations fetch url : ", s), i.has(s)) return e.debug && console.log(v, "getTranslations cache hit"), i.get(s);
|
|
162
|
-
try {
|
|
163
|
-
let t = await y(s, n, e.retryCount, e.retryDelay, e.debug);
|
|
164
|
-
e.debug && console.log(v, "getTranslations status : ", t.status);
|
|
165
|
-
let r = await t.json();
|
|
166
|
-
return i.set(s, r), r;
|
|
167
|
-
} catch (e) {
|
|
168
|
-
return console.error(v, "getTranslations error : ", e), {};
|
|
169
|
-
}
|
|
170
|
-
},
|
|
171
|
-
async updateTranslations(r, i, a, o) {
|
|
172
|
-
e.debug && (console.log(v, "updateTranslations() locale : ", r), console.log(v, "updateTranslations() type : ", i), console.log(v, "updateTranslations() values : ", JSON.stringify(a)));
|
|
173
|
-
let s = `${t}/api/v1/spaces/${e.spaceId}/translations/${r}`;
|
|
174
|
-
e.debug && console.log(v, "updateTranslations fetch url : ", s);
|
|
175
|
-
let c = {
|
|
176
|
-
type: i,
|
|
177
|
-
values: a,
|
|
178
|
-
dryRun: o
|
|
179
|
-
};
|
|
180
|
-
try {
|
|
181
|
-
let t = await y(s, {
|
|
182
|
-
method: "POST",
|
|
183
|
-
headers: {
|
|
184
|
-
"X-API-KEY": e.token,
|
|
185
|
-
...n.headers
|
|
186
|
-
},
|
|
187
|
-
body: JSON.stringify(c)
|
|
188
|
-
}, e.retryCount, e.retryDelay, e.debug);
|
|
189
|
-
return e.debug && console.log(v, "updateTranslations status : ", t.status), t.json();
|
|
190
|
-
} catch (e) {
|
|
191
|
-
console.error(v, "updateTranslations error : ", e);
|
|
192
|
-
}
|
|
193
|
-
},
|
|
194
|
-
async getOpenApi() {
|
|
195
|
-
e.debug && console.log(v, "getOpenApi()");
|
|
196
|
-
let r = `${t}/api/v1/spaces/${e.spaceId}/open-api?token=${e.token}`;
|
|
197
|
-
if (e.debug && console.log(v, "getOpenApi fetch url : ", r), i.has(r)) return e.debug && console.log(v, "getOpenApi cache hit"), i.get(r);
|
|
198
|
-
try {
|
|
199
|
-
let t = await y(r, n, e.retryCount, e.retryDelay, e.debug);
|
|
200
|
-
e.debug && console.log(v, "getOpenApi status : ", t.status);
|
|
201
|
-
let a = await t.json();
|
|
202
|
-
return i.set(r, a), a;
|
|
203
|
-
} catch (e) {
|
|
204
|
-
return console.error(v, "getOpenApi error : ", e), {};
|
|
205
|
-
}
|
|
206
|
-
},
|
|
207
|
-
async getSchemas() {
|
|
208
|
-
e.debug && console.log(v, "getSchemas()");
|
|
209
|
-
let r = `${t}/api/v1/spaces/${e.spaceId}/schemas?token=${e.token}`;
|
|
210
|
-
if (e.debug && console.log(v, "getSchemas fetch url : ", r), i.has(r)) return e.debug && console.log(v, "getSchemas cache hit"), i.get(r);
|
|
211
|
-
try {
|
|
212
|
-
let t = await y(r, n, e.retryCount, e.retryDelay, e.debug);
|
|
213
|
-
e.debug && console.log(v, "getSchemas status : ", t.status);
|
|
214
|
-
let a = await t.json();
|
|
215
|
-
return i.set(r, a), a;
|
|
216
|
-
} catch (e) {
|
|
217
|
-
return console.error(v, "getSchemas error : ", e), {};
|
|
218
|
-
}
|
|
219
|
-
},
|
|
220
|
-
assetLink(n) {
|
|
221
|
-
return typeof n == "string" ? `${t}/api/v1/spaces/${e.spaceId}/assets/${n}` : `${t}/api/v1/spaces/${e.spaceId}/assets/${n.uri}`;
|
|
62
|
+
};
|
|
63
|
+
async function a() {
|
|
64
|
+
e.debug && console.log(_, "getSpace()");
|
|
65
|
+
let t = `${n}/api/v1/spaces/${e.spaceId}?token=${e.token}`;
|
|
66
|
+
e.debug && console.log(_, "getSpace fetch url : ", t);
|
|
67
|
+
try {
|
|
68
|
+
let n = await v(t, i, e.retryCount, e.retryDelay, e.debug);
|
|
69
|
+
return e.debug && console.log(_, "getSpace status : ", n.status), n.json();
|
|
70
|
+
} catch (e) {
|
|
71
|
+
return console.error(_, "getSpace error : ", e), {};
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
async function o() {
|
|
75
|
+
e.debug && console.log(_, "getSchemas()");
|
|
76
|
+
let t = `${n}/api/v1/spaces/${e.spaceId}/schemas?token=${e.token}`;
|
|
77
|
+
e.debug && console.log(_, "getSchemas fetch url : ", t);
|
|
78
|
+
try {
|
|
79
|
+
let n = await v(t, i, e.retryCount, e.retryDelay, e.debug);
|
|
80
|
+
return e.debug && console.log(_, "getSchemas status : ", n.status), n.json();
|
|
81
|
+
} catch (e) {
|
|
82
|
+
return console.error(_, "getSchemas error : ", e), {};
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
async function s() {
|
|
86
|
+
e.debug && console.log(_, "getOpenApi()");
|
|
87
|
+
let t = `${n}/api/v1/spaces/${e.spaceId}/open-api?token=${e.token}`;
|
|
88
|
+
e.debug && console.log(_, "getOpenApi fetch url : ", t);
|
|
89
|
+
try {
|
|
90
|
+
let n = await v(t, i, e.retryCount, e.retryDelay, e.debug);
|
|
91
|
+
return e.debug && console.log(_, "getOpenApi status : ", n.status), n.json();
|
|
92
|
+
} catch (e) {
|
|
93
|
+
return console.error(_, "getOpenApi error : ", e), {};
|
|
222
94
|
}
|
|
95
|
+
}
|
|
96
|
+
async function c(t, r, a, o) {
|
|
97
|
+
e.debug && (console.log(_, "updateTranslations() locale : ", t), console.log(_, "updateTranslations() type : ", r), console.log(_, "updateTranslations() values : ", JSON.stringify(a)));
|
|
98
|
+
let s = `${n}/api/v1/spaces/${e.spaceId}/translations/${t}`;
|
|
99
|
+
e.debug && console.log(_, "updateTranslations fetch url : ", s);
|
|
100
|
+
let c = {
|
|
101
|
+
type: r,
|
|
102
|
+
values: a,
|
|
103
|
+
dryRun: o
|
|
104
|
+
};
|
|
105
|
+
try {
|
|
106
|
+
let t = await v(s, {
|
|
107
|
+
method: "POST",
|
|
108
|
+
headers: {
|
|
109
|
+
"X-API-KEY": e.token,
|
|
110
|
+
...i.headers
|
|
111
|
+
},
|
|
112
|
+
body: JSON.stringify(c)
|
|
113
|
+
}, e.retryCount, e.retryDelay, e.debug);
|
|
114
|
+
return e.debug && console.log(_, "updateTranslations status : ", t.status), t.json();
|
|
115
|
+
} catch (e) {
|
|
116
|
+
console.error(_, "updateTranslations error : ", e);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return {
|
|
120
|
+
...t,
|
|
121
|
+
getSpace: a,
|
|
122
|
+
getSchemas: o,
|
|
123
|
+
getOpenApi: s,
|
|
124
|
+
updateTranslations: c
|
|
223
125
|
};
|
|
224
126
|
}
|
|
225
127
|
//#endregion
|
|
226
128
|
//#region src/file.ts
|
|
227
|
-
var
|
|
228
|
-
async function
|
|
229
|
-
let r =
|
|
129
|
+
var b = ".localess";
|
|
130
|
+
async function x(e, t, n) {
|
|
131
|
+
let r = ee(e).dir;
|
|
230
132
|
try {
|
|
231
|
-
await
|
|
133
|
+
await o(r, { recursive: !0 });
|
|
232
134
|
} catch {
|
|
233
135
|
return;
|
|
234
136
|
}
|
|
235
137
|
try {
|
|
236
|
-
await
|
|
138
|
+
await c(e, t, n);
|
|
237
139
|
} catch {}
|
|
238
140
|
}
|
|
239
|
-
async function
|
|
240
|
-
return
|
|
141
|
+
async function ie(e) {
|
|
142
|
+
return s(e, "utf-8");
|
|
241
143
|
}
|
|
242
|
-
async function
|
|
243
|
-
let n =
|
|
144
|
+
async function ae(e, t) {
|
|
145
|
+
let n = l(e, ".gitignore"), r = "";
|
|
244
146
|
try {
|
|
245
|
-
r = await
|
|
147
|
+
r = await s(n, "utf-8");
|
|
246
148
|
} catch {}
|
|
247
|
-
r.split("\n").map((e) => e.trim()).includes(t) || await
|
|
149
|
+
r.split("\n").map((e) => e.trim()).includes(t) || await a(n, `${r.length > 0 && !r.endsWith("\n") ? "\n" : ""}${t}\n`, "utf-8");
|
|
248
150
|
}
|
|
249
151
|
//#endregion
|
|
250
152
|
//#region src/session.ts
|
|
251
|
-
var
|
|
252
|
-
async function
|
|
253
|
-
let e = { isLoggedIn: !1 }, t = u.env.LOCALESS_TOKEN, n = u.env.LOCALESS_SPACE,
|
|
254
|
-
if (t && n &&
|
|
153
|
+
var S = l(u.cwd(), b, "credentials.json");
|
|
154
|
+
async function C() {
|
|
155
|
+
let e = { isLoggedIn: !1 }, t = u.env.LOCALESS_TOKEN, n = u.env.LOCALESS_SPACE, r = u.env.LOCALESS_ORIGIN;
|
|
156
|
+
if (t && n && r) return console.debug("Login in using environment variables."), {
|
|
255
157
|
isLoggedIn: !0,
|
|
256
158
|
space: n,
|
|
257
|
-
origin:
|
|
159
|
+
origin: r,
|
|
258
160
|
token: t,
|
|
259
161
|
method: "env"
|
|
260
162
|
};
|
|
261
163
|
try {
|
|
262
|
-
await
|
|
263
|
-
let t = await
|
|
164
|
+
await i(S);
|
|
165
|
+
let t = await s(S, "utf8"), n = JSON.parse(t);
|
|
264
166
|
if (Object.keys(n).length === 0) return e;
|
|
265
167
|
if (n.origin && n.token && n.space) return console.debug("Login in using credentials file."), {
|
|
266
168
|
isLoggedIn: !0,
|
|
@@ -272,21 +174,21 @@ async function E() {
|
|
|
272
174
|
} catch {}
|
|
273
175
|
return e;
|
|
274
176
|
}
|
|
275
|
-
async function
|
|
276
|
-
if (e.origin && e.token && e.space) await S
|
|
177
|
+
async function w(e) {
|
|
178
|
+
if (e.origin && e.token && e.space) await x(S, JSON.stringify(e, null, 2), { mode: 384 }), console.log("Session credentials saved to file system."), await ae(u.cwd(), b), console.log(`Added '${b}' to .gitignore to prevent credentials from being committed.`);
|
|
277
179
|
else throw Error("Cannot persist session: missing required fields.");
|
|
278
180
|
}
|
|
279
|
-
async function
|
|
181
|
+
async function T() {
|
|
280
182
|
try {
|
|
281
|
-
await
|
|
183
|
+
await i(S), await x(S, "{}", { mode: 384 });
|
|
282
184
|
} catch {
|
|
283
185
|
throw Error("Failed to clear session credentials.");
|
|
284
186
|
}
|
|
285
187
|
}
|
|
286
188
|
//#endregion
|
|
287
189
|
//#region src/commands/login/index.ts
|
|
288
|
-
var
|
|
289
|
-
if ((await
|
|
190
|
+
var E = new e("login").description("Login to Localess CLI").option("-o, --origin <origin>", "Origin of the Localess instance").option("-s, --space <space>", "Space ID to login to").option("-t, --token <token>", "Token to login to Localess CLI").action(async (e) => {
|
|
191
|
+
if ((await C()).isLoggedIn) {
|
|
290
192
|
console.log("Already logged in."), console.log("If you want to log in with different credentials, please log out first using \"localess logout\" command.");
|
|
291
193
|
return;
|
|
292
194
|
}
|
|
@@ -299,14 +201,14 @@ var ae = new e("login").description("Login to Localess CLI").option("-o, --origi
|
|
|
299
201
|
}), a = e.token ?? await n({
|
|
300
202
|
message: "Token:",
|
|
301
203
|
mask: !0
|
|
302
|
-
}), o =
|
|
204
|
+
}), o = y({
|
|
303
205
|
origin: r,
|
|
304
206
|
spaceId: i,
|
|
305
207
|
token: a
|
|
306
208
|
});
|
|
307
209
|
try {
|
|
308
210
|
let e = await o.getSpace();
|
|
309
|
-
console.log(`Successfully logged in to space: ${e.name} (${e.id})`), await
|
|
211
|
+
console.log(`Successfully logged in to space: ${e.name} (${e.id})`), await w({
|
|
310
212
|
origin: r,
|
|
311
213
|
space: i,
|
|
312
214
|
token: a
|
|
@@ -314,9 +216,9 @@ var ae = new e("login").description("Login to Localess CLI").option("-o, --origi
|
|
|
314
216
|
} catch {
|
|
315
217
|
console.error("Login failed");
|
|
316
218
|
}
|
|
317
|
-
}),
|
|
219
|
+
}), D = new e("logout").description("Logout from Localess CLI").action(async () => {
|
|
318
220
|
console.log("Logging out...");
|
|
319
|
-
let e = await
|
|
221
|
+
let e = await C();
|
|
320
222
|
if (!e.isLoggedIn) {
|
|
321
223
|
console.log("Not currently logged in.");
|
|
322
224
|
return;
|
|
@@ -326,7 +228,7 @@ var ae = new e("login").description("Login to Localess CLI").option("-o, --origi
|
|
|
326
228
|
return;
|
|
327
229
|
}
|
|
328
230
|
try {
|
|
329
|
-
await
|
|
231
|
+
await T(), console.log("Successfully logged out.");
|
|
330
232
|
} catch (e) {
|
|
331
233
|
console.error("Failed to log out:", e);
|
|
332
234
|
}
|
|
@@ -334,63 +236,63 @@ var ae = new e("login").description("Login to Localess CLI").option("-o, --origi
|
|
|
334
236
|
return e.ROOT = "ROOT", e.NODE = "NODE", e.ENUM = "ENUM", e;
|
|
335
237
|
}({}), k = /* @__PURE__ */ function(e) {
|
|
336
238
|
return e.TEXT = "TEXT", e.TEXTAREA = "TEXTAREA", e.RICH_TEXT = "RICH_TEXT", e.MARKDOWN = "MARKDOWN", e.NUMBER = "NUMBER", e.COLOR = "COLOR", e.DATE = "DATE", e.DATETIME = "DATETIME", e.BOOLEAN = "BOOLEAN", e.OPTION = "OPTION", e.OPTIONS = "OPTIONS", e.LINK = "LINK", e.REFERENCE = "REFERENCE", e.REFERENCES = "REFERENCES", e.ASSET = "ASSET", e.ASSETS = "ASSETS", e.SCHEMA = "SCHEMA", e.SCHEMAS = "SCHEMAS", e;
|
|
337
|
-
}({}), A =
|
|
239
|
+
}({}), A = d.record(d.string(), d.string()), j = d.enum([
|
|
240
|
+
"add-missing",
|
|
241
|
+
"update-existing",
|
|
242
|
+
"delete-missing"
|
|
243
|
+
]);
|
|
244
|
+
d.object({
|
|
245
|
+
type: j,
|
|
246
|
+
values: A
|
|
247
|
+
});
|
|
248
|
+
//#endregion
|
|
249
|
+
//#region src/models/translations.ts
|
|
250
|
+
var M = /* @__PURE__ */ function(e) {
|
|
338
251
|
return e.ADD_MISSING = "add-missing", e.UPDATE_EXISTING = "update-existing", e.DELETE_MISSING = "delete-missing", e;
|
|
339
|
-
}({}),
|
|
252
|
+
}({}), N = /* @__PURE__ */ function(e) {
|
|
340
253
|
return e.FLAT = "flat", e.NESTED = "nested", e;
|
|
341
|
-
}({}),
|
|
342
|
-
if (console.log("Pulling translations with arguments:", e), console.log("Pulling translations with options:", t), !Object.values(
|
|
343
|
-
console.error("Invalid format provided. Possible values are :", Object.values(
|
|
254
|
+
}({}), P = new e("pull").argument("<locale>", "Locale to pull").description("Pull locale translations from Localess").requiredOption("-p, --path <path>", "Path where the translations file will be saved").option("-f, --format <format>", `File format. Possible values are : ${Object.values(N)}`, N.FLAT).option("--draft", "Pull the draft version of translations").action(async (e, t) => {
|
|
255
|
+
if (console.log("Pulling translations with arguments:", e), console.log("Pulling translations with options:", t), !Object.values(N).includes(t.format)) {
|
|
256
|
+
console.error("Invalid format provided. Possible values are :", Object.values(N));
|
|
344
257
|
return;
|
|
345
258
|
}
|
|
346
|
-
let n = await
|
|
259
|
+
let n = await C();
|
|
347
260
|
if (!n.isLoggedIn) {
|
|
348
261
|
console.error("Not logged in"), console.error("Please log in first using \"localess login\" command");
|
|
349
262
|
return;
|
|
350
263
|
}
|
|
351
|
-
let r =
|
|
264
|
+
let r = y({
|
|
352
265
|
origin: n.origin,
|
|
353
266
|
spaceId: n.space,
|
|
354
267
|
token: n.token
|
|
355
268
|
});
|
|
356
269
|
console.log("Pulling translations from Localess for locale:", e);
|
|
357
270
|
let i = await r.getTranslations(e, { version: t.draft ? "draft" : void 0 });
|
|
358
|
-
if (console.log("Saving translations in file:", t.path), t.format ===
|
|
359
|
-
else if (t.format ===
|
|
360
|
-
let e = h(
|
|
361
|
-
await
|
|
271
|
+
if (console.log("Saving translations in file:", t.path), t.format === N.FLAT) await x(t.path, JSON.stringify(h(i), null, 2));
|
|
272
|
+
else if (t.format === N.NESTED) {
|
|
273
|
+
let e = h(re(i));
|
|
274
|
+
await x(t.path, JSON.stringify(e, null, 2));
|
|
362
275
|
}
|
|
363
276
|
console.log("Successfully saved translations from Localess");
|
|
364
|
-
}),
|
|
365
|
-
"
|
|
366
|
-
|
|
367
|
-
"delete-missing"
|
|
368
|
-
]);
|
|
369
|
-
d.object({
|
|
370
|
-
type: P,
|
|
371
|
-
values: N
|
|
372
|
-
});
|
|
373
|
-
//#endregion
|
|
374
|
-
//#region src/commands/translations/push/index.ts
|
|
375
|
-
var F = new e("push").argument("<locale>", "Locale to push").description("Push locale translations to Localess").requiredOption("-p, --path <path>", "Path to the translations file to push").option("-f, --format <format>", `File format. Possible values are : ${Object.values(j)}`, j.FLAT).option("-t, --type <type>", `Push type. Possible values are : ${Object.values(A)}`, A.ADD_MISSING).option("--dry-run", "Preview changes without applying them to Localess").action(async (e, t) => {
|
|
376
|
-
if (console.log("Pushing translations with arguments:", e), console.log("Pushing translations with options:", t), !P.safeParse(t.type).success) {
|
|
377
|
-
console.error("Invalid type provided. Possible values are :", Object.values(A));
|
|
277
|
+
}), F = new e("push").argument("<locale>", "Locale to push").description("Push locale translations to Localess").requiredOption("-p, --path <path>", "Path to the translations file to push").option("-f, --format <format>", `File format. Possible values are : ${Object.values(N)}`, N.FLAT).option("-t, --type <type>", `Push type. Possible values are : ${Object.values(M)}`, M.ADD_MISSING).option("--dry-run", "Preview changes without applying them to Localess").action(async (e, t) => {
|
|
278
|
+
if (console.log("Pushing translations with arguments:", e), console.log("Pushing translations with options:", t), !j.safeParse(t.type).success) {
|
|
279
|
+
console.error("Invalid type provided. Possible values are :", Object.values(M));
|
|
378
280
|
return;
|
|
379
281
|
}
|
|
380
|
-
let n = await
|
|
282
|
+
let n = await C();
|
|
381
283
|
if (!n.isLoggedIn) {
|
|
382
284
|
console.error("Not logged in"), console.error("Please log in first using \"localess login\" command");
|
|
383
285
|
return;
|
|
384
286
|
}
|
|
385
|
-
let r =
|
|
287
|
+
let r = y({
|
|
386
288
|
origin: n.origin,
|
|
387
289
|
spaceId: n.space,
|
|
388
290
|
token: n.token
|
|
389
291
|
});
|
|
390
292
|
t.dryRun && console.warn("Dry run mode enabled: No changes will be made."), console.log("Reading translations file from:", t.path);
|
|
391
|
-
let i = await
|
|
392
|
-
o = t.format ===
|
|
393
|
-
let s =
|
|
293
|
+
let i = await ie(t.path), a = JSON.parse(i), o;
|
|
294
|
+
o = t.format === N.NESTED ? g(a) : a;
|
|
295
|
+
let s = A.safeParse(o);
|
|
394
296
|
if (!s.success) {
|
|
395
297
|
console.error("Invalid translations file format:", s.error);
|
|
396
298
|
return;
|
|
@@ -398,7 +300,7 @@ var F = new e("push").argument("<locale>", "Locale to push").description("Push l
|
|
|
398
300
|
console.log("Pushing translations to Localess with locale:", e, "and type:", t.type);
|
|
399
301
|
let c = await r.updateTranslations(e, t.type, o, t.dryRun);
|
|
400
302
|
c ? (c.dryRun && console.log("Dry run results:"), console.log("Successfully pushed translations to Localess"), console.log("Summary:", c.message), c.ids && console.log("Updated translation IDs:", c.ids)) : console.log("Something went wrong while pushing translations to Localess");
|
|
401
|
-
}), I = new e("translations").description("Manage translations").addCommand(F).addCommand(
|
|
303
|
+
}), I = new e("translations").description("Manage translations").addCommand(F).addCommand(P);
|
|
402
304
|
//#endregion
|
|
403
305
|
//#region src/commands/types/generate/generator.ts
|
|
404
306
|
function L(e) {
|
|
@@ -521,14 +423,14 @@ function V(e, t = "") {
|
|
|
521
423
|
}
|
|
522
424
|
//#endregion
|
|
523
425
|
//#region src/commands/types/generate/index.ts
|
|
524
|
-
var H =
|
|
426
|
+
var H = l(te.cwd(), b, "localess.ts"), U = new e("generate").description("Generate types for your schemas").option("-p, --path <path>", "Path to the file where to save the generated types. Default is .localess/localess.ts", H).option("--prefix <prefix>", "Prefix to prepend to all generated type names", "").action(async (e) => {
|
|
525
427
|
console.log("Types in with options:", e);
|
|
526
|
-
let t = await
|
|
428
|
+
let t = await C();
|
|
527
429
|
if (!t.isLoggedIn) {
|
|
528
430
|
console.error("Not logged in"), console.error("Please log in first using \"localess login\" command");
|
|
529
431
|
return;
|
|
530
432
|
}
|
|
531
|
-
let n =
|
|
433
|
+
let n = y({
|
|
532
434
|
origin: t.origin,
|
|
533
435
|
spaceId: t.space,
|
|
534
436
|
token: t.token
|
|
@@ -537,7 +439,7 @@ var H = c(ee.cwd(), x, "localess.ts"), U = new e("generate").description("Genera
|
|
|
537
439
|
let r = await n.getSchemas();
|
|
538
440
|
console.log("Generating types...");
|
|
539
441
|
let i = V(r, e.prefix);
|
|
540
|
-
await
|
|
442
|
+
await x(e.path, i), console.log(`Types written to ${e.path}`);
|
|
541
443
|
}), W = new e("types").description("Generate types for your schemas").addCommand(U), G = "@localess/cli", K = `https://registry.npmjs.org/${G}`;
|
|
542
444
|
function q(e) {
|
|
543
445
|
let [t, n = null] = e.split("-"), r = t.split(".").map(Number);
|
|
@@ -574,7 +476,7 @@ function Z(e, t, n) {
|
|
|
574
476
|
""
|
|
575
477
|
].join("\n");
|
|
576
478
|
}
|
|
577
|
-
async function
|
|
479
|
+
async function oe(e) {
|
|
578
480
|
try {
|
|
579
481
|
let t = new AbortController(), n = setTimeout(() => t.abort(), 3e3), r = q(e).preRelease !== null, [i, a] = await Promise.all([Y("latest", t.signal), r ? Y("dev", t.signal) : Promise.resolve(null)]);
|
|
580
482
|
if (clearTimeout(n), i && J(i, e)) return Z(e, i, "latest");
|
|
@@ -588,11 +490,11 @@ var Q = new e();
|
|
|
588
490
|
Q.name("Localess CLI").description("CLI tool for Localess platform management").version(p);
|
|
589
491
|
var $;
|
|
590
492
|
Q.hook("preAction", () => {
|
|
591
|
-
$ =
|
|
493
|
+
$ = oe(p);
|
|
592
494
|
}), Q.hook("postAction", async () => {
|
|
593
495
|
let e = await $;
|
|
594
496
|
e && console.log(e);
|
|
595
|
-
}), Q.addCommand(
|
|
497
|
+
}), Q.addCommand(E), Q.addCommand(D), Q.addCommand(I), Q.addCommand(W);
|
|
596
498
|
//#endregion
|
|
597
499
|
//#region src/index.ts
|
|
598
500
|
try {
|
package/dist/src/client.d.ts
CHANGED
|
@@ -1,38 +1,9 @@
|
|
|
1
1
|
import { OpenAPIObject } from 'openapi3-ts/oas30';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* Example: https://my-localess.web.app
|
|
8
|
-
*/
|
|
9
|
-
origin: string;
|
|
10
|
-
/**
|
|
11
|
-
* Localess space ID can be found in the Localess Space settings
|
|
12
|
-
*/
|
|
13
|
-
spaceId: string;
|
|
14
|
-
/**
|
|
15
|
-
* Localess API token can be found in the Localess Space settings
|
|
16
|
-
*/
|
|
17
|
-
token: string;
|
|
18
|
-
/**
|
|
19
|
-
* Content version to fetch, leave empty for 'published' or 'draft' for the latest draft
|
|
20
|
-
*/
|
|
21
|
-
version?: 'draft';
|
|
22
|
-
/**
|
|
23
|
-
* Enable debug mode
|
|
24
|
-
*/
|
|
25
|
-
debug?: boolean;
|
|
26
|
-
/**
|
|
27
|
-
* Cache TTL (time to live) in **seconds** for API responses.
|
|
28
|
-
*
|
|
29
|
-
* - `undefined` — use default in-memory TTL cache with 5 minutes TTL (default)
|
|
30
|
-
* - `number` — use in-memory TTL cache with the given TTL in seconds
|
|
31
|
-
* - `false` — disable caching entirely (always fetches fresh data)
|
|
32
|
-
*
|
|
33
|
-
* @default 300 (5 minutes)
|
|
34
|
-
*/
|
|
35
|
-
cacheTTL?: number | false;
|
|
2
|
+
import { LocalessClientOptions, Translations } from '@localess/client';
|
|
3
|
+
import { Space } from './models/space';
|
|
4
|
+
import { Schemas } from './models/schema';
|
|
5
|
+
import { TranslationUpdateResponse, TranslationUpdateType } from './models/translations';
|
|
6
|
+
export type LocalessCliClientOptions = LocalessClientOptions & {
|
|
36
7
|
/**
|
|
37
8
|
* Number of times to retry failed fetch requests (network errors or 5xx). Default: 3
|
|
38
9
|
*/
|
|
@@ -42,113 +13,16 @@ export type LocalessClientOptions = {
|
|
|
42
13
|
*/
|
|
43
14
|
retryDelay?: number;
|
|
44
15
|
};
|
|
45
|
-
export
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* If **true**, exclude all sub slugs, otherwise include all content under current selected **parent slug**.
|
|
58
|
-
* @example false
|
|
59
|
-
*/
|
|
60
|
-
excludeChildren?: boolean;
|
|
61
|
-
};
|
|
62
|
-
export type ContentFetchParams = {
|
|
63
|
-
/**
|
|
64
|
-
* Content version to fetch, leave empty for 'published' or 'draft' for the latest draft.
|
|
65
|
-
* Overrides the version set in the client options.
|
|
66
|
-
*/
|
|
67
|
-
version?: 'draft';
|
|
68
|
-
/**
|
|
69
|
-
* Locale identifier (ISO 639-1) to fetch content in, leave empty for default locale.
|
|
70
|
-
*
|
|
71
|
-
* Example: en
|
|
72
|
-
*/
|
|
73
|
-
locale?: string;
|
|
74
|
-
/**
|
|
75
|
-
* Resolve references in the content data.
|
|
76
|
-
* @default false
|
|
77
|
-
*/
|
|
78
|
-
resolveReference?: boolean;
|
|
79
|
-
/**
|
|
80
|
-
* Resolve links in the content data.
|
|
81
|
-
* @default false
|
|
82
|
-
*/
|
|
83
|
-
resolveLink?: boolean;
|
|
84
|
-
/**
|
|
85
|
-
* Resolve all assets.
|
|
86
|
-
* @default false
|
|
87
|
-
*/
|
|
88
|
-
resolveAsset?: boolean;
|
|
89
|
-
};
|
|
90
|
-
export type TranslationFetchParams = {
|
|
91
|
-
/**
|
|
92
|
-
* Translation version to fetch, leave empty for 'published' or 'draft' for the latest draft.
|
|
93
|
-
* Overrides the version set in the client options.
|
|
94
|
-
*/
|
|
95
|
-
version?: 'draft';
|
|
16
|
+
export declare function localessCliClient(options: LocalessCliClientOptions): {
|
|
17
|
+
getSpace: () => Promise<Space>;
|
|
18
|
+
getSchemas: () => Promise<Schemas>;
|
|
19
|
+
getOpenApi: () => Promise<OpenAPIObject>;
|
|
20
|
+
updateTranslations: (locale: string, type: TranslationUpdateType, values: Translations, dryRun?: boolean) => Promise<TranslationUpdateResponse | undefined>;
|
|
21
|
+
getLinks(params?: import('@localess/client').LinksFetchParams): Promise<import('@localess/client').Links>;
|
|
22
|
+
getContentBySlug<T extends import('@localess/client').ContentData = import('@localess/client').ContentData>(slug: string, params?: import('@localess/client').ContentFetchParams): Promise<import('@localess/client').Content<T>>;
|
|
23
|
+
getContentById<T extends import('@localess/client').ContentData = import('@localess/client').ContentData>(id: string, params?: import('@localess/client').ContentFetchParams): Promise<import('@localess/client').Content<T>>;
|
|
24
|
+
getTranslations(locale: string, params?: import('@localess/client').TranslationFetchParams): Promise<Translations>;
|
|
25
|
+
syncScriptUrl(): string;
|
|
26
|
+
assetLink(asset: import('@localess/client').ContentAsset | string, params?: import('@localess/client').AssetTransformParams): string;
|
|
96
27
|
};
|
|
97
|
-
export
|
|
98
|
-
/**
|
|
99
|
-
* Get space information
|
|
100
|
-
* @returns {Promise<Space>}
|
|
101
|
-
*/
|
|
102
|
-
getSpace(): Promise<Space>;
|
|
103
|
-
/**
|
|
104
|
-
* Get all links
|
|
105
|
-
* @param params{LinksFetchParams} - Fetch parameters
|
|
106
|
-
* @returns {Promise<Links>}
|
|
107
|
-
*/
|
|
108
|
-
getLinks(params?: LinksFetchParams): Promise<Links>;
|
|
109
|
-
/**
|
|
110
|
-
* Get content by SLUG
|
|
111
|
-
* @param slug{string} - Content SLUG
|
|
112
|
-
* @param params{ContentFetchParams} - Fetch parameters
|
|
113
|
-
* @returns {Promise<Content>}
|
|
114
|
-
*/
|
|
115
|
-
getContentBySlug<T extends ContentData = ContentData>(slug: string, params?: ContentFetchParams): Promise<Content<T>>;
|
|
116
|
-
/**
|
|
117
|
-
* Get content by ID
|
|
118
|
-
* @param id{string} - Content ID
|
|
119
|
-
* @param params{ContentFetchParams} - Fetch parameters
|
|
120
|
-
* @returns {Promise<Content>}
|
|
121
|
-
*/
|
|
122
|
-
getContentById<T extends ContentData = ContentData>(id: string, params?: ContentFetchParams): Promise<Content<T>>;
|
|
123
|
-
/**
|
|
124
|
-
* Get translations for the given locale
|
|
125
|
-
* @param locale{string} - Locale identifier (ISO 639-1)
|
|
126
|
-
* @param params{ContentFetchParams} - Fetch parameters
|
|
127
|
-
* @returns {Promise<Translations>}
|
|
128
|
-
*/
|
|
129
|
-
getTranslations(locale: string, params?: TranslationFetchParams): Promise<Translations>;
|
|
130
|
-
/**
|
|
131
|
-
* Update translations for the given locale
|
|
132
|
-
* @param locale - Locale identifier (ISO 639-1)
|
|
133
|
-
* @param type{TranslationUpdateType} - Type of update to perform (add-missing or update-existing)
|
|
134
|
-
* @param values - Key-Value Object. Where Key is Translation ID and Value is Translated Content
|
|
135
|
-
* @param dryRun - If true, the API will return the changes that would be made without actually applying them
|
|
136
|
-
* @returns {Promise<void>}
|
|
137
|
-
*/
|
|
138
|
-
updateTranslations(locale: string, type: TranslationUpdateType, values: Translations, dryRun?: boolean): Promise<TranslationUpdateResponse | undefined>;
|
|
139
|
-
/**
|
|
140
|
-
* Get OpenAPI specification
|
|
141
|
-
* Requires Token with Development Tools permission
|
|
142
|
-
*/
|
|
143
|
-
getOpenApi(): Promise<OpenAPIObject>;
|
|
144
|
-
/**
|
|
145
|
-
* Get Schemas Definition
|
|
146
|
-
*/
|
|
147
|
-
getSchemas(): Promise<Schemas>;
|
|
148
|
-
assetLink(asset: ContentAsset | string): string;
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Create a Localess API Client
|
|
152
|
-
* @param {LocalessClientOptions} options connection details
|
|
153
|
-
*/
|
|
154
|
-
export declare function localessClient(options: LocalessClientOptions): LocalessClient;
|
|
28
|
+
export type LocalessCliClient = ReturnType<typeof localessCliClient>;
|
|
@@ -1,15 +1,5 @@
|
|
|
1
|
-
export * from '
|
|
2
|
-
export * from './assets';
|
|
3
|
-
export * from './content';
|
|
4
|
-
export * from './content-asset';
|
|
5
|
-
export * from './content-data';
|
|
6
|
-
export * from './content-link';
|
|
7
|
-
export * from './content-metadata';
|
|
8
|
-
export * from './content-reference';
|
|
9
|
-
export * from './content-rich-text';
|
|
10
|
-
export * from './links';
|
|
11
|
-
export * from './locale';
|
|
12
|
-
export * from './references';
|
|
1
|
+
export * from '@localess/client';
|
|
13
2
|
export * from './schema';
|
|
14
3
|
export * from './space';
|
|
4
|
+
export * from './translation.zod';
|
|
15
5
|
export * from './translations';
|
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Key-Value Object. Where Key is Translation ID and Value is Translated Content
|
|
3
|
-
*/
|
|
4
|
-
export interface Translations {
|
|
5
|
-
[key: string]: string;
|
|
6
|
-
}
|
|
7
1
|
export type TranslationUpdate = {
|
|
8
2
|
dryRun?: boolean;
|
|
9
3
|
type: TranslationUpdateType;
|
|
10
|
-
values:
|
|
4
|
+
values: Record<string, string>;
|
|
11
5
|
};
|
|
12
6
|
export declare enum TranslationUpdateType {
|
|
13
7
|
ADD_MISSING = "add-missing",
|
package/dist/src/utils.d.ts
CHANGED
|
@@ -37,9 +37,6 @@ export declare const BG_BRIGHT_BLUE = "\u001B[104m";
|
|
|
37
37
|
export declare const BG_BRIGHT_MAGENTA = "\u001B[105m";
|
|
38
38
|
export declare const BG_BRIGHT_CYAN = "\u001B[106m";
|
|
39
39
|
export declare const BG_BRIGHT_WHITE = "\u001B[107m";
|
|
40
|
-
export declare const isBrowser: () => boolean;
|
|
41
|
-
export declare const isServer: () => boolean;
|
|
42
|
-
export declare const isIframe: () => boolean;
|
|
43
40
|
export declare function sortObjectKeys<T extends Record<string, unknown>>(input: T): T;
|
|
44
41
|
export declare function nestedObjectToFlat(input: Record<string, unknown>, prefix?: string): Record<string, string>;
|
|
45
42
|
export declare function dotToNestedObject(input: Record<string, string>): Record<string, unknown>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@localess/cli",
|
|
3
|
-
"version": "3.2.4-dev.
|
|
3
|
+
"version": "3.2.4-dev.20260611210209",
|
|
4
4
|
"description": "Localess Command Line.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
"license": "MIT",
|
|
47
47
|
"dependencies": {
|
|
48
48
|
"@inquirer/prompts": "^8.5.2",
|
|
49
|
+
"@localess/client": "3.2.4-dev.20260611210209",
|
|
49
50
|
"chalk": "^5.6.2",
|
|
50
51
|
"commander": "^15.0.0",
|
|
51
52
|
"zod": "^4.4.3"
|
package/dist/src/cache.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export interface ICache<V> {
|
|
2
|
-
set(key: string, value: V): void;
|
|
3
|
-
get(key: string): V | undefined;
|
|
4
|
-
has(key: string): boolean;
|
|
5
|
-
}
|
|
6
|
-
export declare class Cache<V> implements ICache<V> {
|
|
7
|
-
private cache;
|
|
8
|
-
set(key: string, value: V): void;
|
|
9
|
-
get(key: string): V | undefined;
|
|
10
|
-
has(key: string): boolean;
|
|
11
|
-
}
|
|
12
|
-
export declare class NoCache<V> implements ICache<V> {
|
|
13
|
-
set(key: string, value: V): void;
|
|
14
|
-
get(key: string): V | undefined;
|
|
15
|
-
has(key: string): boolean;
|
|
16
|
-
}
|
|
17
|
-
export declare class TTLCache<V> {
|
|
18
|
-
private ttlMs;
|
|
19
|
-
private cache;
|
|
20
|
-
/**
|
|
21
|
-
* Creates a TTLCache with a specified time-to-live (TTL) for each entry.
|
|
22
|
-
* default is 5 minutes (300000 ms).
|
|
23
|
-
* @param ttlMs
|
|
24
|
-
*/
|
|
25
|
-
constructor(ttlMs?: number);
|
|
26
|
-
set(key: string, value: V): void;
|
|
27
|
-
get(key: string): V | undefined;
|
|
28
|
-
has(key: string): boolean;
|
|
29
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Resolved Asset metadata returned when resolveAsset=true.
|
|
3
|
-
*/
|
|
4
|
-
export interface AssetMetadata {
|
|
5
|
-
/**
|
|
6
|
-
* Unique identifier for the Asset.
|
|
7
|
-
*/
|
|
8
|
-
id: string;
|
|
9
|
-
/**
|
|
10
|
-
* Name of the Asset.
|
|
11
|
-
* @example hero-image
|
|
12
|
-
*/
|
|
13
|
-
name: string;
|
|
14
|
-
/**
|
|
15
|
-
* File extension of the Asset.
|
|
16
|
-
* @example .jpg
|
|
17
|
-
*/
|
|
18
|
-
extension: string;
|
|
19
|
-
/**
|
|
20
|
-
* MIME type of the Asset.
|
|
21
|
-
* @example image/jpeg
|
|
22
|
-
*/
|
|
23
|
-
type: string;
|
|
24
|
-
/**
|
|
25
|
-
* Alternative text for the Asset.
|
|
26
|
-
* @example A hero image
|
|
27
|
-
*/
|
|
28
|
-
alt?: string;
|
|
29
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { ContentAsset } from './content-asset';
|
|
2
|
-
import { ContentLink } from './content-link';
|
|
3
|
-
import { ContentReference } from './content-reference';
|
|
4
|
-
import { ContentRichText } from './content-rich-text';
|
|
5
|
-
export type ContentDataField = any | string | string[] | number | boolean | ContentLink | ContentRichText | ContentData | ContentData[] | ContentAsset | ContentAsset[] | ContentReference | ContentReference[];
|
|
6
|
-
/**
|
|
7
|
-
* Content Data Schema related information.
|
|
8
|
-
*/
|
|
9
|
-
export interface ContentDataSchema {
|
|
10
|
-
/**
|
|
11
|
-
* Unique identifier of a component in a content.
|
|
12
|
-
*/
|
|
13
|
-
_id: string;
|
|
14
|
-
/**
|
|
15
|
-
* Unique identifier for the Schema object.
|
|
16
|
-
*/
|
|
17
|
-
_schema: string;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* ContentData defined Object to connect all possible root Schemas.
|
|
21
|
-
*/
|
|
22
|
-
export interface ContentData extends ContentDataSchema {
|
|
23
|
-
/**
|
|
24
|
-
* Other Schema-specific fields
|
|
25
|
-
*/
|
|
26
|
-
[field: string]: ContentDataField | undefined;
|
|
27
|
-
}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Content Link define reference to a Link.
|
|
3
|
-
*/
|
|
4
|
-
export interface ContentLink {
|
|
5
|
-
/**
|
|
6
|
-
* Define the type of Link
|
|
7
|
-
*/
|
|
8
|
-
kind: 'LINK';
|
|
9
|
-
/**
|
|
10
|
-
* Define the target of the link. _blank for the new tab and _self for the same tab.
|
|
11
|
-
*/
|
|
12
|
-
target: '_blank' | '_self';
|
|
13
|
-
/**
|
|
14
|
-
* Define the type of Link. URL for external links and Content for internal links.
|
|
15
|
-
*/
|
|
16
|
-
type: 'url' | 'content';
|
|
17
|
-
/**
|
|
18
|
-
* If the type is content, then it will be Content ID. Otherwise, it will be URL.
|
|
19
|
-
*/
|
|
20
|
-
uri: string;
|
|
21
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Content Metadata defines short information about a Content for navigation reason.
|
|
3
|
-
*/
|
|
4
|
-
export interface ContentMetadata {
|
|
5
|
-
/**
|
|
6
|
-
* Date and Time at which the Content was created.
|
|
7
|
-
*/
|
|
8
|
-
createdAt: string;
|
|
9
|
-
/**
|
|
10
|
-
* Combination of SLUG and Parent SLUG of the Content
|
|
11
|
-
*/
|
|
12
|
-
fullSlug: string;
|
|
13
|
-
/**
|
|
14
|
-
* Unique identifier for the object.
|
|
15
|
-
*/
|
|
16
|
-
id: string;
|
|
17
|
-
/**
|
|
18
|
-
* Define the type of Content, whether it is a FOLDER or DOCUMENT.
|
|
19
|
-
*/
|
|
20
|
-
kind: 'FOLDER' | 'DOCUMENT';
|
|
21
|
-
/**
|
|
22
|
-
* Name of the Content
|
|
23
|
-
*/
|
|
24
|
-
name: string;
|
|
25
|
-
/**
|
|
26
|
-
* Parent SLUG of the Content
|
|
27
|
-
*/
|
|
28
|
-
parentSlug: string;
|
|
29
|
-
/**
|
|
30
|
-
* Date and Time at which the Content was published.
|
|
31
|
-
*/
|
|
32
|
-
publishedAt?: string;
|
|
33
|
-
/**
|
|
34
|
-
* SLUG of the Content
|
|
35
|
-
*/
|
|
36
|
-
slug: string;
|
|
37
|
-
/**
|
|
38
|
-
* Date and Time at which the Content was updated.
|
|
39
|
-
*/
|
|
40
|
-
updatedAt: string;
|
|
41
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { Assets } from './assets';
|
|
2
|
-
import { ContentData } from './content-data';
|
|
3
|
-
import { ContentMetadata } from './content-metadata';
|
|
4
|
-
import { Links } from './links';
|
|
5
|
-
import { References } from './references';
|
|
6
|
-
/**
|
|
7
|
-
* Content defines a shared object for all possible Content Types.
|
|
8
|
-
*/
|
|
9
|
-
export interface Content<T extends ContentData = ContentData> extends ContentMetadata {
|
|
10
|
-
/**
|
|
11
|
-
* Content Data
|
|
12
|
-
*/
|
|
13
|
-
data?: T;
|
|
14
|
-
/**
|
|
15
|
-
* All links used in the content.
|
|
16
|
-
*/
|
|
17
|
-
links?: Links;
|
|
18
|
-
/**
|
|
19
|
-
* All references used in the content.
|
|
20
|
-
*/
|
|
21
|
-
references?: References;
|
|
22
|
-
/**
|
|
23
|
-
* All assets used in the content.
|
|
24
|
-
*/
|
|
25
|
-
assets?: Assets;
|
|
26
|
-
}
|