@localess/js-client 0.0.3-20240526-114112.0 → 0.0.3-next.20240526-181814.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/dist/index.d.ts +21 -3
- package/dist/index.js +8 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,30 @@
|
|
|
1
1
|
import { Content, ContentAsset, Links, Translations } from "./models";
|
|
2
2
|
export * from './models';
|
|
3
3
|
export type LocalessClientOptions = {
|
|
4
|
-
|
|
4
|
+
/**
|
|
5
|
+
* A fully qualified domain name with protocol (http/https) and port.
|
|
6
|
+
*
|
|
7
|
+
* Example: https://localess-prod.web.app
|
|
8
|
+
*/
|
|
9
|
+
origin: string;
|
|
10
|
+
/**
|
|
11
|
+
* Content version to fetch, leave empty for 'published' or 'draft' for the latest draft
|
|
12
|
+
*/
|
|
5
13
|
version?: 'draft';
|
|
6
|
-
|
|
14
|
+
/**
|
|
15
|
+
* Locale to fetch content in, leave empty for default locale
|
|
16
|
+
*
|
|
17
|
+
* Example: en
|
|
18
|
+
*/
|
|
19
|
+
locale?: string;
|
|
20
|
+
/**
|
|
21
|
+
* Localess space ID, cna be found in the Localess Space settings
|
|
22
|
+
*/
|
|
7
23
|
spaceId: string;
|
|
24
|
+
/**
|
|
25
|
+
* Localess API token, can be found in the Localess Space settings
|
|
26
|
+
*/
|
|
8
27
|
token: string;
|
|
9
|
-
secure?: boolean;
|
|
10
28
|
};
|
|
11
29
|
export declare function localessClient(options: LocalessClientOptions): {
|
|
12
30
|
getLinks(): Promise<Links>;
|
package/dist/index.js
CHANGED
|
@@ -9,39 +9,38 @@ export function localessClient(options) {
|
|
|
9
9
|
if (proxyURIFromEnv()) {
|
|
10
10
|
fetchOptions.agent = new ProxyAgent();
|
|
11
11
|
}
|
|
12
|
-
const host = `${options.secure ? 'https' : 'http'}://${options.domain}`;
|
|
13
12
|
const version = options.version ? `&version=${options.version}` : '';
|
|
14
|
-
const locale = options.
|
|
13
|
+
const locale = options.locale ? `&locale=${options.locale}` : '';
|
|
15
14
|
return {
|
|
16
15
|
async getLinks() {
|
|
17
|
-
const response = await fetch(`${
|
|
16
|
+
const response = await fetch(`${origin}/api/v1/spaces/${options.spaceId}/links?token=${options.token}`, fetchOptions);
|
|
18
17
|
const data = await response.json();
|
|
19
18
|
return data;
|
|
20
19
|
},
|
|
21
20
|
async getContentBySlug(slug) {
|
|
22
|
-
const response = await fetch(`${
|
|
21
|
+
const response = await fetch(`${origin}/api/v1/spaces/${options.spaceId}/contents/slugs/${slug}?token=${options.token}${version}${locale}`, fetchOptions);
|
|
23
22
|
const data = await response.json();
|
|
24
23
|
return data;
|
|
25
24
|
},
|
|
26
25
|
async getContentById(id) {
|
|
27
|
-
const response = await fetch(`${
|
|
26
|
+
const response = await fetch(`${origin}/api/v1/spaces/${options.spaceId}/contents/${id}?token=${options.token}${version}${locale}`, fetchOptions);
|
|
28
27
|
const data = await response.json();
|
|
29
28
|
return data;
|
|
30
29
|
},
|
|
31
30
|
async getTranslations() {
|
|
32
|
-
const response = await fetch(`${
|
|
31
|
+
const response = await fetch(`${origin}/api/v1/spaces/${options.spaceId}/translations/${locale || 'en'}`, fetchOptions);
|
|
33
32
|
const data = await response.json();
|
|
34
33
|
return data;
|
|
35
34
|
},
|
|
36
35
|
syncScriptUrl() {
|
|
37
|
-
return `${
|
|
36
|
+
return `${origin}/scripts/sync-v1.js`;
|
|
38
37
|
},
|
|
39
38
|
assetLink(asset) {
|
|
40
39
|
if (typeof asset === 'string') {
|
|
41
|
-
return `${
|
|
40
|
+
return `${origin}/api/v1/spaces/${options.spaceId}/assets/${asset}`;
|
|
42
41
|
}
|
|
43
42
|
else {
|
|
44
|
-
return `${
|
|
43
|
+
return `${origin}/api/v1/spaces/${options.spaceId}/assets/${asset.uri}`;
|
|
45
44
|
}
|
|
46
45
|
}
|
|
47
46
|
};
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAC;AACvC,OAAO,KAAoB,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAC,eAAe,EAAC,MAAM,SAAS,CAAC;AAGxC,cAAc,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAC;AACvC,OAAO,KAAoB,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAC,eAAe,EAAC,MAAM,SAAS,CAAC;AAGxC,cAAc,UAAU,CAAC;AA6BzB,MAAM,UAAU,cAAc,CAAC,OAA8B;IAC3D,MAAM,YAAY,GAAgB;QAChC,QAAQ,EAAE,QAAQ;KACnB,CAAC;IACF,IAAI,eAAe,EAAE,EAAE,CAAC;QACtB,YAAY,CAAC,KAAK,GAAG,IAAI,UAAU,EAAE,CAAC;IACxC,CAAC;IACD,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,YAAY,OAAO,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACrE,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;IACjE,OAAO;QAEL,KAAK,CAAC,QAAQ;YACZ,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,MAAM,kBAAkB,OAAO,CAAC,OAAO,gBAAgB,OAAO,CAAC,KAAK,EAAE,EAAE,YAAY,CAAC,CAAA;YACrH,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YACnC,OAAO,IAAa,CAAC;QACvB,CAAC;QAED,KAAK,CAAC,gBAAgB,CAAC,IAAY;YACjC,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