@localess/cli 3.0.5-dev.20260428203008 → 3.0.5-dev.20260501212257
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/SKILL.md +11 -6
- package/dist/cache.d.ts +29 -0
- package/dist/client.d.ts +142 -0
- package/dist/commands/login/index.d.ts +2 -0
- package/dist/commands/login/login.test.d.ts +1 -0
- package/dist/commands/logout/index.d.ts +2 -0
- package/dist/commands/translations/index.d.ts +2 -0
- package/dist/commands/translations/pull/index.d.ts +7 -0
- package/dist/commands/translations/push/index.d.ts +9 -0
- package/dist/commands/types/generate/generator.d.ts +3 -0
- package/dist/commands/types/generate/generator.test.d.ts +1 -0
- package/dist/commands/types/generate/index.d.ts +2 -0
- package/dist/commands/types/index.d.ts +2 -0
- package/dist/commands/types/types.test.d.ts +1 -0
- package/dist/file.d.ts +7 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.mjs +153 -146
- package/dist/models/content-asset.d.ts +13 -0
- package/dist/models/content-data.d.ts +27 -0
- package/dist/models/content-link.d.ts +21 -0
- package/dist/models/content-metadata.d.ts +41 -0
- package/dist/models/content-reference.d.ts +13 -0
- package/dist/models/content-rich-text.d.ts +13 -0
- package/dist/models/content.d.ts +21 -0
- package/dist/models/index.d.ts +13 -0
- package/dist/models/links.d.ts +7 -0
- package/dist/models/locale.d.ts +10 -0
- package/dist/models/references.d.ts +7 -0
- package/dist/models/schema.d.ts +142 -0
- package/dist/models/space.d.ts +21 -0
- package/dist/models/translation.zod.d.ts +13 -0
- package/dist/models/translations.d.ts +25 -0
- package/dist/program.d.ts +2 -0
- package/dist/session.d.ts +22 -0
- package/dist/utils.d.ts +45 -0
- package/dist/utils.test.d.ts +1 -0
- package/package.json +2 -3
package/SKILL.md
CHANGED
|
@@ -48,6 +48,7 @@ localess login \
|
|
|
48
48
|
2. Prompts interactively for any missing options
|
|
49
49
|
3. Validates credentials by calling the API
|
|
50
50
|
4. Saves credentials to `.localess/credentials.json` (mode `0o600`)
|
|
51
|
+
5. Automatically adds `.localess` to `.gitignore` (creates the file if absent; skips if the entry already exists)
|
|
51
52
|
|
|
52
53
|
### Logout
|
|
53
54
|
|
|
@@ -88,7 +89,7 @@ Recommended for **CI/CD pipelines** — no `localess login` step needed.
|
|
|
88
89
|
}
|
|
89
90
|
```
|
|
90
91
|
|
|
91
|
-
>
|
|
92
|
+
> `.localess` is automatically added to `.gitignore` by `localess login` to prevent credentials from being committed.
|
|
92
93
|
|
|
93
94
|
---
|
|
94
95
|
|
|
@@ -324,14 +325,18 @@ localess types generate
|
|
|
324
325
|
|
|
325
326
|
---
|
|
326
327
|
|
|
327
|
-
## .gitignore
|
|
328
|
+
## .gitignore
|
|
329
|
+
|
|
330
|
+
`localess login` automatically appends `.localess` to `.gitignore` in the current working directory (creating the file if it doesn't exist). No manual step is required.
|
|
331
|
+
|
|
332
|
+
If you want to commit generated types while still ignoring credentials, you can refine the entry manually after login:
|
|
328
333
|
|
|
329
334
|
```gitignore
|
|
330
|
-
# Localess credentials (contains API token)
|
|
335
|
+
# Localess credentials (contains API token) — added automatically by `localess login`
|
|
331
336
|
.localess/credentials.json
|
|
332
337
|
|
|
333
|
-
#
|
|
334
|
-
#
|
|
338
|
+
# Commit generated types so the whole team benefits from type safety;
|
|
339
|
+
# only exclude if types are regenerated in CI:
|
|
335
340
|
# .localess/localess.d.ts
|
|
336
341
|
```
|
|
337
342
|
|
|
@@ -358,6 +363,6 @@ localess types generate
|
|
|
358
363
|
|
|
359
364
|
5. **Use `add-missing` strategy (default)** for initial import of translations; switch to `update-existing` when syncing copy changes.
|
|
360
365
|
|
|
361
|
-
6. **Never commit `.localess/credentials.json`** —
|
|
366
|
+
6. **Never commit `.localess/credentials.json`** — `localess login` automatically adds `.localess` to `.gitignore`, so credentials are protected out of the box.
|
|
362
367
|
|
|
363
368
|
7. **Give the token minimum required permissions** — the `types generate` command needs "Development Tools" permission; other commands only need standard API access.
|
package/dist/cache.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { Content, ContentAsset, ContentData, Links, Space, Translations, TranslationUpdateResponse, TranslationUpdateType, Schemas } from './models';
|
|
2
|
+
import { OpenAPIObject } from 'openapi3-ts/oas30';
|
|
3
|
+
export type LocalessClientOptions = {
|
|
4
|
+
/**
|
|
5
|
+
* A fully qualified domain name with protocol (http/https) and port.
|
|
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' | string;
|
|
22
|
+
/**
|
|
23
|
+
* Enable debug mode
|
|
24
|
+
*/
|
|
25
|
+
debug?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Cache TTL (time to live) for API responses. Default is 5 minutes (300000 ms).
|
|
28
|
+
* Set to false to disable caching.
|
|
29
|
+
*/
|
|
30
|
+
cacheTTL?: number | false;
|
|
31
|
+
/**
|
|
32
|
+
* Number of times to retry failed fetch requests (network errors or 5xx). Default: 3
|
|
33
|
+
*/
|
|
34
|
+
retryCount?: number;
|
|
35
|
+
/**
|
|
36
|
+
* Delay in ms between retries. Default: 500ms
|
|
37
|
+
*/
|
|
38
|
+
retryDelay?: number;
|
|
39
|
+
};
|
|
40
|
+
export type LinksFetchParams = {
|
|
41
|
+
/**
|
|
42
|
+
* Content Kind. FOLDER or DOCUMENT. If not provided, it will return all.
|
|
43
|
+
* @example 'DOCUMENT'
|
|
44
|
+
*/
|
|
45
|
+
kind?: 'DOCUMENT' | 'FOLDER';
|
|
46
|
+
/**
|
|
47
|
+
* Content parent slug.
|
|
48
|
+
* @example 'legal/policy'
|
|
49
|
+
*/
|
|
50
|
+
parentSlug?: string;
|
|
51
|
+
/**
|
|
52
|
+
* If **true**, exclude all sub slugs, otherwise include all content under current selected **parent slug**.
|
|
53
|
+
* @example false
|
|
54
|
+
*/
|
|
55
|
+
excludeChildren?: boolean;
|
|
56
|
+
};
|
|
57
|
+
export type ContentFetchParams = {
|
|
58
|
+
/**
|
|
59
|
+
* Content version to fetch, leave empty for 'published' or 'draft' for the latest draft.
|
|
60
|
+
* Overrides the version set in the client options.
|
|
61
|
+
*/
|
|
62
|
+
version?: 'draft' | string;
|
|
63
|
+
/**
|
|
64
|
+
* Locale identifier (ISO 639-1) to fetch content in, leave empty for default locale.
|
|
65
|
+
*
|
|
66
|
+
* Example: en
|
|
67
|
+
*/
|
|
68
|
+
locale?: string;
|
|
69
|
+
/**
|
|
70
|
+
* Resolve references in the content data. Default is false.
|
|
71
|
+
*/
|
|
72
|
+
resolveReference?: boolean;
|
|
73
|
+
/**
|
|
74
|
+
* Resolve links in the content data. Default is false.
|
|
75
|
+
*/
|
|
76
|
+
resolveLink?: boolean;
|
|
77
|
+
};
|
|
78
|
+
export type TranslationFetchParams = {
|
|
79
|
+
/**
|
|
80
|
+
* Translation version to fetch, leave empty for 'published' or 'draft' for the latest draft.
|
|
81
|
+
* Overrides the version set in the client options.
|
|
82
|
+
*/
|
|
83
|
+
version?: 'draft' | string;
|
|
84
|
+
};
|
|
85
|
+
export interface LocalessClient {
|
|
86
|
+
/**
|
|
87
|
+
* Get space information
|
|
88
|
+
* @returns {Promise<Space>}
|
|
89
|
+
*/
|
|
90
|
+
getSpace(): Promise<Space>;
|
|
91
|
+
/**
|
|
92
|
+
* Get all links
|
|
93
|
+
* @param params{LinksFetchParams} - Fetch parameters
|
|
94
|
+
* @returns {Promise<Links>}
|
|
95
|
+
*/
|
|
96
|
+
getLinks(params?: LinksFetchParams): Promise<Links>;
|
|
97
|
+
/**
|
|
98
|
+
* Get content by SLUG
|
|
99
|
+
* @param slug{string} - Content SLUG
|
|
100
|
+
* @param params{ContentFetchParams} - Fetch parameters
|
|
101
|
+
* @returns {Promise<Content>}
|
|
102
|
+
*/
|
|
103
|
+
getContentBySlug<T extends ContentData = ContentData>(slug: string, params?: ContentFetchParams): Promise<Content<T>>;
|
|
104
|
+
/**
|
|
105
|
+
* Get content by ID
|
|
106
|
+
* @param id{string} - Content ID
|
|
107
|
+
* @param params{ContentFetchParams} - Fetch parameters
|
|
108
|
+
* @returns {Promise<Content>}
|
|
109
|
+
*/
|
|
110
|
+
getContentById<T extends ContentData = ContentData>(id: string, params?: ContentFetchParams): Promise<Content<T>>;
|
|
111
|
+
/**
|
|
112
|
+
* Get translations for the given locale
|
|
113
|
+
* @param locale{string} - Locale identifier (ISO 639-1)
|
|
114
|
+
* @param params{ContentFetchParams} - Fetch parameters
|
|
115
|
+
* @returns {Promise<Translations>}
|
|
116
|
+
*/
|
|
117
|
+
getTranslations(locale: string, params?: TranslationFetchParams): Promise<Translations>;
|
|
118
|
+
/**
|
|
119
|
+
* Update translations for the given locale
|
|
120
|
+
* @param locale - Locale identifier (ISO 639-1)
|
|
121
|
+
* @param type{TranslationUpdateType} - Type of update to perform (add-missing or update-existing)
|
|
122
|
+
* @param values - Key-Value Object. Where Key is Translation ID and Value is Translated Content
|
|
123
|
+
* @param dryRun - If true, the API will return the changes that would be made without actually applying them
|
|
124
|
+
* @returns {Promise<void>}
|
|
125
|
+
*/
|
|
126
|
+
updateTranslations(locale: string, type: TranslationUpdateType, values: Translations, dryRun?: boolean): Promise<TranslationUpdateResponse | undefined>;
|
|
127
|
+
/**
|
|
128
|
+
* Get OpenAPI specification
|
|
129
|
+
* Requires Token with Development Tools permission
|
|
130
|
+
*/
|
|
131
|
+
getOpenApi(): Promise<OpenAPIObject>;
|
|
132
|
+
/**
|
|
133
|
+
* Get Schemas Definition
|
|
134
|
+
*/
|
|
135
|
+
getSchemas(): Promise<Schemas>;
|
|
136
|
+
assetLink(asset: ContentAsset | string): string;
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Create a Localess API Client
|
|
140
|
+
* @param {LocalessClientOptions} options connection details
|
|
141
|
+
*/
|
|
142
|
+
export declare function localessClient(options: LocalessClientOptions): LocalessClient;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { TranslationFileFormat, TranslationUpdateType } from '../../../models';
|
|
3
|
+
export type TranslationsPushOptions = {
|
|
4
|
+
path: string;
|
|
5
|
+
format: TranslationFileFormat;
|
|
6
|
+
type: TranslationUpdateType;
|
|
7
|
+
dryRun?: boolean;
|
|
8
|
+
};
|
|
9
|
+
export declare const translationsPushCommand: Command;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/file.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare const DEFAULT_CONFIG_DIR = ".localess";
|
|
2
|
+
export declare function fileExists(path: string): Promise<boolean>;
|
|
3
|
+
export declare function writeFile(filePath: string, data: string, option?: {
|
|
4
|
+
mode?: number;
|
|
5
|
+
}): Promise<void>;
|
|
6
|
+
export declare function readFile(filePath: string): Promise<string>;
|
|
7
|
+
export declare function ensureGitignore(cwd: string, entry: string): Promise<void>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
export {};
|