@localess/js-client 0.0.4-next.20240527-214345.0 → 0.0.4
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/cjs/index.d.ts +78 -0
- package/dist/cjs/models/content-asset.d.ts +13 -0
- package/dist/cjs/models/content-data.d.ts +4 -0
- package/dist/cjs/models/content-metadata.d.ts +41 -0
- package/dist/cjs/models/content.d.ts +47 -0
- package/dist/cjs/models/index.d.ts +6 -0
- package/dist/cjs/models/links.d.ts +7 -0
- package/dist/cjs/models/translations.d.ts +6 -0
- package/dist/cjs/utils.d.ts +40 -0
- package/package.json +4 -1
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { Content, ContentAsset, Links, Translations } from "./models";
|
|
2
|
+
export * from './models';
|
|
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, cna 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
|
+
* Enable debug mode
|
|
20
|
+
*/
|
|
21
|
+
debug?: boolean;
|
|
22
|
+
};
|
|
23
|
+
export type ContentFetchParams = {
|
|
24
|
+
/**
|
|
25
|
+
* Content version to fetch, leave empty for 'published' or 'draft' for the latest draft
|
|
26
|
+
*/
|
|
27
|
+
version?: 'draft' | string;
|
|
28
|
+
/**
|
|
29
|
+
* Locale identifier (ISO 639-1) to fetch content in, leave empty for default locale.
|
|
30
|
+
*
|
|
31
|
+
* Example: en
|
|
32
|
+
*/
|
|
33
|
+
locale?: string;
|
|
34
|
+
};
|
|
35
|
+
export declare function localessClient(options: LocalessClientOptions): {
|
|
36
|
+
/**
|
|
37
|
+
* Get all links
|
|
38
|
+
* @returns {Promise<Links>}
|
|
39
|
+
*/
|
|
40
|
+
getLinks(): Promise<Links>;
|
|
41
|
+
/**
|
|
42
|
+
* Get content by SLUG
|
|
43
|
+
* @param slug{string} - Content SLUG
|
|
44
|
+
* @param params{ContentFetchParams} - Fetch parameters
|
|
45
|
+
* @returns {Promise<Content>}
|
|
46
|
+
*/
|
|
47
|
+
getContentBySlug(slug: string, params?: ContentFetchParams): Promise<Content>;
|
|
48
|
+
/**
|
|
49
|
+
* Get content by ID
|
|
50
|
+
* @param id{string} - Content ID
|
|
51
|
+
* @param params{ContentFetchParams} - Fetch parameters
|
|
52
|
+
* @returns {Promise<Content>}
|
|
53
|
+
*/
|
|
54
|
+
getContentById(id: string, params?: ContentFetchParams): Promise<Content>;
|
|
55
|
+
/**
|
|
56
|
+
* Get translations for the given locale
|
|
57
|
+
* @param locale{string} - Locale identifier (ISO 639-1)
|
|
58
|
+
*/
|
|
59
|
+
getTranslations(locale: string): Promise<Translations>;
|
|
60
|
+
syncScriptUrl(): string;
|
|
61
|
+
assetLink(asset: ContentAsset | string): string;
|
|
62
|
+
};
|
|
63
|
+
declare global {
|
|
64
|
+
type EventType = 'input' | 'save' | 'publish' | 'change';
|
|
65
|
+
type EventCallback = (event: EventToApp) => void;
|
|
66
|
+
type EventToApp = {
|
|
67
|
+
type: 'save' | 'publish';
|
|
68
|
+
} | {
|
|
69
|
+
type: 'input' | 'change';
|
|
70
|
+
data: any;
|
|
71
|
+
};
|
|
72
|
+
interface LocalessSync {
|
|
73
|
+
on: (event: EventType | EventType[], callback: EventCallback) => void;
|
|
74
|
+
}
|
|
75
|
+
interface Window {
|
|
76
|
+
localess?: LocalessSync;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content Metadata define 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
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { ContentData } from './content-data';
|
|
2
|
+
/**
|
|
3
|
+
* Content define shared object for all possible Content Types.
|
|
4
|
+
*/
|
|
5
|
+
export interface Content {
|
|
6
|
+
/**
|
|
7
|
+
* Date and Time at which the Content was created.
|
|
8
|
+
*/
|
|
9
|
+
createdAt: string;
|
|
10
|
+
data?: ContentData;
|
|
11
|
+
/**
|
|
12
|
+
* Combination of SLUG and Parent SLUG of the Content
|
|
13
|
+
*/
|
|
14
|
+
fullSlug: string;
|
|
15
|
+
/**
|
|
16
|
+
* Unique identifier for the object.
|
|
17
|
+
*/
|
|
18
|
+
id: string;
|
|
19
|
+
/**
|
|
20
|
+
* Define the type of Content, whether it is a FOLDER or DOCUMENT.
|
|
21
|
+
*/
|
|
22
|
+
kind: 'FOLDER' | 'DOCUMENT';
|
|
23
|
+
/**
|
|
24
|
+
* Locale unique identifier (ISO 639-1).
|
|
25
|
+
*/
|
|
26
|
+
locale?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Name of the Content
|
|
29
|
+
*/
|
|
30
|
+
name: string;
|
|
31
|
+
/**
|
|
32
|
+
* Parent SLUG of the Content
|
|
33
|
+
*/
|
|
34
|
+
parentSlug: string;
|
|
35
|
+
/**
|
|
36
|
+
* Date and Time at which the Content was published.
|
|
37
|
+
*/
|
|
38
|
+
publishedAt?: string;
|
|
39
|
+
/**
|
|
40
|
+
* SLUG of the Content
|
|
41
|
+
*/
|
|
42
|
+
slug: string;
|
|
43
|
+
/**
|
|
44
|
+
* Date and Time at which the Content was updated.
|
|
45
|
+
*/
|
|
46
|
+
updatedAt: string;
|
|
47
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export declare function proxyURIFromEnv(): string | undefined;
|
|
2
|
+
export declare const RESET = "\u001B[0m";
|
|
3
|
+
export declare const BRIGHT = "\u001B[1m";
|
|
4
|
+
export declare const DIM = "\u001B[2m";
|
|
5
|
+
export declare const UNDERSCORE = "\u001B[4m";
|
|
6
|
+
export declare const BLINK = "\u001B[5m";
|
|
7
|
+
export declare const REVERSE = "\u001B[7m";
|
|
8
|
+
export declare const HIDDEN = "\u001B[8m";
|
|
9
|
+
export declare const FG_BLACK = "\u001B[30m";
|
|
10
|
+
export declare const FG_RED = "\u001B[31m";
|
|
11
|
+
export declare const FG_GREEN = "\u001B[32m";
|
|
12
|
+
export declare const FG_YELLOW = "\u001B[33m";
|
|
13
|
+
export declare const FG_BLUE = "\u001B[34m";
|
|
14
|
+
export declare const FG_MAGENTA = "\u001B[35m";
|
|
15
|
+
export declare const FG_CYAN = "\u001B[36m";
|
|
16
|
+
export declare const FG_WHITE = "\u001B[37m";
|
|
17
|
+
export declare const FG_GRAY = "\u001B[90m";
|
|
18
|
+
export declare const FG_BRIGHT_RED = "\u001B[91m";
|
|
19
|
+
export declare const FG_BRIGHT_GREEN = "\u001B[92m";
|
|
20
|
+
export declare const FG_BRIGHT_YELLOW = "\u001B[93m";
|
|
21
|
+
export declare const FG_BRIGHT_BLUE = "\u001B[94m";
|
|
22
|
+
export declare const FG_BRIGHT_MAGENTA = "\u001B[95m";
|
|
23
|
+
export declare const FG_BRIGHT_CYAN = "\u001B[96m";
|
|
24
|
+
export declare const FG_BRIGHT_WHITE = "\u001B[97m";
|
|
25
|
+
export declare const BG_BLACK = "\u001B[40m";
|
|
26
|
+
export declare const BG_RED = "\u001B[41m";
|
|
27
|
+
export declare const BG_GREEN = "\u001B[42m";
|
|
28
|
+
export declare const BG_YELLOW = "\u001B[43m";
|
|
29
|
+
export declare const BG_BLUE = "\u001B[44m";
|
|
30
|
+
export declare const BG_MAGENTA = "\u001B[45m";
|
|
31
|
+
export declare const BG_CYAN = "\u001B[46m";
|
|
32
|
+
export declare const BG_WHITE = "\u001B[47m";
|
|
33
|
+
export declare const BG_GRAY = "\u001B[100m";
|
|
34
|
+
export declare const BG_BRIGHT_RED = "\u001B[101m";
|
|
35
|
+
export declare const BG_BRIGHT_GREEN = "\u001B[102m";
|
|
36
|
+
export declare const BG_BRIGHT_YELLOW = "\u001B[103m";
|
|
37
|
+
export declare const BG_BRIGHT_BLUE = "\u001B[104m";
|
|
38
|
+
export declare const BG_BRIGHT_MAGENTA = "\u001B[105m";
|
|
39
|
+
export declare const BG_BRIGHT_CYAN = "\u001B[106m";
|
|
40
|
+
export declare const BG_BRIGHT_WHITE = "\u001B[107m";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@localess/js-client",
|
|
3
|
-
"version": "0.0.4
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"description": "Universal JavaScript/TypeScript SDK for Localess's API.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"localess",
|
|
@@ -16,6 +16,9 @@
|
|
|
16
16
|
"files": [
|
|
17
17
|
"dist"
|
|
18
18
|
],
|
|
19
|
+
"main": "dist/cjs/index.js",
|
|
20
|
+
"module": "dist/index.js",
|
|
21
|
+
"types": "dist/index.d.ts",
|
|
19
22
|
"exports": {
|
|
20
23
|
".": {
|
|
21
24
|
"import": "./dist/index.js",
|