@localess/js-client 0.0.2

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 ADDED
@@ -0,0 +1,44 @@
1
+ <br/>
2
+ <br/>
3
+ <img src="https://github.com/Lessify/localess/wiki/img/logo-adaptive.svg" alt="logo">
4
+ <br/>
5
+ <br/>
6
+
7
+ ----
8
+
9
+ # Localess JavaScript / TypeScript Client SDK
10
+
11
+ This client SDK is designed to work with the Localess API. It provides a simple way to interact with the Localess API from your JavaScript or TypeScript application.
12
+
13
+ > **Important:**
14
+ > The Client is designed to be used on the server side only, as it requires your **Localess API Token** to be kept secret.
15
+ > Do not use this client in your frontend application, as it exposes your API Token to the public.
16
+
17
+ ## Installation
18
+
19
+ ### NPM
20
+ ````bash
21
+ npm install @localess/js-client@latest
22
+ ````
23
+
24
+ ### Yarn
25
+ ````bash
26
+ yarn add @localess/js-client@latest
27
+ ````
28
+
29
+ ## Usage
30
+
31
+ ````ts
32
+ import {localessClient} from "@localess/js-client";
33
+
34
+ const llClient = localessClient({
35
+ origin: 'https://my-localess.web.app', // A fully qualified domain name with protocol (http/https) and port.
36
+ spaceId: 'I1LoVe2LocaLess4Rever', // Localess space ID, cna be found in the Localess Space settings
37
+ token: 'Baz00KaT0KeN8S3CureLL' // Localess API token, can be found in the Localess Space settings
38
+ });
39
+
40
+ llClient.getLinks() // Fetch all Content Links
41
+ llClient.getContentBySlug('docs/overview') // Fetch content by SLUG
42
+ llClient.getContentById('FRnIT7CUABoRCdSVVGGs') // Fetch content by ID
43
+ llClient.getTranslations('en') // Fetch translations by locale
44
+ ````
@@ -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' | 'published';
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
+ }
package/dist/index.js ADDED
@@ -0,0 +1,114 @@
1
+ import { ProxyAgent } from 'proxy-agent';
2
+ import fetch from 'node-fetch';
3
+ import { FG_BLUE, proxyURIFromEnv, RESET } from "./utils";
4
+ export * from './models';
5
+ const LOG_GROUP = `${FG_BLUE}[Localess]${RESET}`;
6
+ export function localessClient(options) {
7
+ if (options.debug) {
8
+ console.log(LOG_GROUP, 'Client Options :', options);
9
+ }
10
+ const fetchOptions = {
11
+ redirect: 'follow',
12
+ };
13
+ if (proxyURIFromEnv()) {
14
+ fetchOptions.agent = new ProxyAgent();
15
+ }
16
+ return {
17
+ /**
18
+ * Get all links
19
+ * @returns {Promise<Links>}
20
+ */
21
+ async getLinks() {
22
+ if (options.debug) {
23
+ console.log(LOG_GROUP, 'getLinks()');
24
+ }
25
+ let url = `${options.origin}/api/v1/spaces/${options.spaceId}/links?token=${options.token}`;
26
+ if (options.debug) {
27
+ console.log(LOG_GROUP, 'getLinks url :', url);
28
+ }
29
+ const response = await fetch(url, fetchOptions);
30
+ if (options.debug) {
31
+ console.log(LOG_GROUP, 'getLinks status :', response.status);
32
+ }
33
+ const data = await response.json();
34
+ return data;
35
+ },
36
+ /**
37
+ * Get content by SLUG
38
+ * @param slug{string} - Content SLUG
39
+ * @param params{ContentFetchParams} - Fetch parameters
40
+ * @returns {Promise<Content>}
41
+ */
42
+ async getContentBySlug(slug, params) {
43
+ if (options.debug) {
44
+ console.log(LOG_GROUP, 'getContentBySlug() slug :', slug);
45
+ }
46
+ const version = params?.version == 'draft' ? `&version=${params.version}` : '';
47
+ const locale = params?.locale ? `&locale=${params.locale}` : '';
48
+ let url = `${options.origin}/api/v1/spaces/${options.spaceId}/contents/slugs/${slug}?token=${options.token}${version}${locale}`;
49
+ if (options.debug) {
50
+ console.log(LOG_GROUP, 'getContentBySlug url :', url);
51
+ }
52
+ const response = await fetch(url, fetchOptions);
53
+ if (options.debug) {
54
+ console.log(LOG_GROUP, 'getContentBySlug status :', response.status);
55
+ }
56
+ const data = await response.json();
57
+ return data;
58
+ },
59
+ /**
60
+ * Get content by ID
61
+ * @param id{string} - Content ID
62
+ * @param params{ContentFetchParams} - Fetch parameters
63
+ * @returns {Promise<Content>}
64
+ */
65
+ async getContentById(id, params) {
66
+ if (options.debug) {
67
+ console.log(LOG_GROUP, 'getContentById() id :', id);
68
+ }
69
+ const version = params?.version == 'draft' ? `&version=${params.version}` : '';
70
+ const locale = params?.locale ? `&locale=${params.locale}` : '';
71
+ let url = `${options.origin}/api/v1/spaces/${options.spaceId}/contents/${id}?token=${options.token}${version}${locale}`;
72
+ if (options.debug) {
73
+ console.log(LOG_GROUP, 'getContentById url :', url);
74
+ }
75
+ const response = await fetch(url, fetchOptions);
76
+ if (options.debug) {
77
+ console.log(LOG_GROUP, 'getContentById status :', response.status);
78
+ }
79
+ const data = await response.json();
80
+ return data;
81
+ },
82
+ /**
83
+ * Get translations for the given locale
84
+ * @param locale{string} - Locale identifier (ISO 639-1)
85
+ */
86
+ async getTranslations(locale) {
87
+ if (options.debug) {
88
+ console.log(LOG_GROUP, 'getTranslations()');
89
+ }
90
+ let url = `${options.origin}/api/v1/spaces/${options.spaceId}/translations/${locale}`;
91
+ if (options.debug) {
92
+ console.log(LOG_GROUP, 'getTranslations url :', url);
93
+ }
94
+ const response = await fetch(url, fetchOptions);
95
+ if (options.debug) {
96
+ console.log(LOG_GROUP, 'getTranslations status :', response.status);
97
+ }
98
+ const data = await response.json();
99
+ return data;
100
+ },
101
+ syncScriptUrl() {
102
+ return `${options.origin}/scripts/sync-v1.js`;
103
+ },
104
+ assetLink(asset) {
105
+ if (typeof asset === 'string') {
106
+ return `${options.origin}/api/v1/spaces/${options.spaceId}/assets/${asset}`;
107
+ }
108
+ else {
109
+ return `${options.origin}/api/v1/spaces/${options.spaceId}/assets/${asset.uri}`;
110
+ }
111
+ }
112
+ };
113
+ }
114
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,aAAa,CAAC;AACvC,OA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CAAC,CAAC;YACvD,CAAC;YACD,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,EAAE,YAAY,CAAC,CAAA;YAC/C,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;gBAClB,OAAO,CAAC,GAAG,CAAC,SAAS,EAAE,0BAA0B,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;YACtE,CAAC;YACD,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;YACnC,OAAO,IAAoB,CAAC;QAC9B,CAAC;QAED,aAAa;YACX,OAAO,GAAG,OAAO,CAAC,MAAM,qBAAqB,CAAA;QAC/C,CAAC;QAED,SAAS,CAAC,KAA4B;YACpC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;gBAC9B,OAAO,GAAG,OAAO,CAAC,MAAM,kBAAkB,OAAO,CAAC,OAAO,WAAW,KAAK,EAAE,CAAC;YAC9E,CAAC;iBAAM,CAAC;gBACN,OAAO,GAAG,OAAO,CAAC,MAAM,kBAAkB,OAAO,CAAC,OAAO,WAAW,KAAK,CAAC,GAAG,EAAE,CAAC;YAClF,CAAC;QACH,CAAC;KACF,CAAA;AACH,CAAC"}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Content Asset define reference to a Asset.
3
+ */
4
+ export interface ContentAsset {
5
+ /**
6
+ * Define the type of Asset
7
+ */
8
+ kind: 'ASSET';
9
+ /**
10
+ * Unique identifier for the asset.
11
+ */
12
+ uri: string;
13
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=content-asset.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-asset.js","sourceRoot":"","sources":["../../src/models/content-asset.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ /**
2
+ * ContentData defined Object to connect all possible root Schemas.
3
+ */
4
+ export type ContentData = unknown;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=content-data.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-data.js","sourceRoot":"","sources":["../../src/models/content-data.ts"],"names":[],"mappings":""}
@@ -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,2 @@
1
+ export {};
2
+ //# sourceMappingURL=content-metadata.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content-metadata.js","sourceRoot":"","sources":["../../src/models/content-metadata.ts"],"names":[],"mappings":""}
@@ -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,2 @@
1
+ export {};
2
+ //# sourceMappingURL=content.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"content.js","sourceRoot":"","sources":["../../src/models/content.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
1
+ export * from './content';
2
+ export * from './content-asset';
3
+ export * from './content-data';
4
+ export * from './content-metadata';
5
+ export * from './links';
6
+ export * from './translations';
@@ -0,0 +1,7 @@
1
+ export * from './content';
2
+ export * from './content-asset';
3
+ export * from './content-data';
4
+ export * from './content-metadata';
5
+ export * from './links';
6
+ export * from './translations';
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,SAAS,CAAC;AACxB,cAAc,gBAAgB,CAAC"}
@@ -0,0 +1,7 @@
1
+ import { ContentMetadata } from './content-metadata';
2
+ /**
3
+ * Key-Value Object. Where Key is Unique identifier for the Content object and Value is Content Metadata.
4
+ */
5
+ export interface Links {
6
+ [key: string]: ContentMetadata;
7
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=links.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"links.js","sourceRoot":"","sources":["../../src/models/links.ts"],"names":[],"mappings":""}
@@ -0,0 +1,6 @@
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
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=translations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"translations.js","sourceRoot":"","sources":["../../src/models/translations.ts"],"names":[],"mappings":""}
@@ -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/dist/utils.js ADDED
@@ -0,0 +1,47 @@
1
+ export function proxyURIFromEnv() {
2
+ return (process.env.HTTPS_PROXY ||
3
+ process.env.https_proxy ||
4
+ process.env.HTTP_PROXY ||
5
+ process.env.http_proxy ||
6
+ undefined);
7
+ }
8
+ export const RESET = "\x1b[0m";
9
+ export const BRIGHT = "\x1b[1m";
10
+ export const DIM = "\x1b[2m";
11
+ export const UNDERSCORE = "\x1b[4m";
12
+ export const BLINK = "\x1b[5m";
13
+ export const REVERSE = "\x1b[7m";
14
+ export const HIDDEN = "\x1b[8m";
15
+ export const FG_BLACK = "\x1b[30m";
16
+ export const FG_RED = "\x1b[31m";
17
+ export const FG_GREEN = "\x1b[32m";
18
+ export const FG_YELLOW = "\x1b[33m";
19
+ export const FG_BLUE = "\x1b[34m";
20
+ export const FG_MAGENTA = "\x1b[35m";
21
+ export const FG_CYAN = "\x1b[36m";
22
+ export const FG_WHITE = "\x1b[37m";
23
+ export const FG_GRAY = "\x1b[90m";
24
+ export const FG_BRIGHT_RED = "\x1b[91m";
25
+ export const FG_BRIGHT_GREEN = "\x1b[92m";
26
+ export const FG_BRIGHT_YELLOW = "\x1b[93m";
27
+ export const FG_BRIGHT_BLUE = "\x1b[94m";
28
+ export const FG_BRIGHT_MAGENTA = "\x1b[95m";
29
+ export const FG_BRIGHT_CYAN = "\x1b[96m";
30
+ export const FG_BRIGHT_WHITE = "\x1b[97m";
31
+ export const BG_BLACK = "\x1b[40m";
32
+ export const BG_RED = "\x1b[41m";
33
+ export const BG_GREEN = "\x1b[42m";
34
+ export const BG_YELLOW = "\x1b[43m";
35
+ export const BG_BLUE = "\x1b[44m";
36
+ export const BG_MAGENTA = "\x1b[45m";
37
+ export const BG_CYAN = "\x1b[46m";
38
+ export const BG_WHITE = "\x1b[47m";
39
+ export const BG_GRAY = "\x1b[100m";
40
+ export const BG_BRIGHT_RED = "\x1b[101m";
41
+ export const BG_BRIGHT_GREEN = "\x1b[102m";
42
+ export const BG_BRIGHT_YELLOW = "\x1b[103m";
43
+ export const BG_BRIGHT_BLUE = "\x1b[104m";
44
+ export const BG_BRIGHT_MAGENTA = "\x1b[105m";
45
+ export const BG_BRIGHT_CYAN = "\x1b[106m";
46
+ export const BG_BRIGHT_WHITE = "\x1b[107m";
47
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,eAAe;IAC7B,OAAO,CACL,OAAO,CAAC,GAAG,CAAC,WAAW;QACvB,OAAO,CAAC,GAAG,CAAC,WAAW;QACvB,OAAO,CAAC,GAAG,CAAC,UAAU;QACtB,OAAO,CAAC,GAAG,CAAC,UAAU;QACtB,SAAS,CACV,CAAC;AACJ,CAAC;AAGD,MAAM,CAAC,MAAM,KAAK,GAAG,SAAS,CAAA;AAC9B,MAAM,CAAC,MAAM,MAAM,GAAG,SAAS,CAAA;AAC/B,MAAM,CAAC,MAAM,GAAG,GAAG,SAAS,CAAA;AAC5B,MAAM,CAAC,MAAM,UAAU,GAAG,SAAS,CAAA;AACnC,MAAM,CAAC,MAAM,KAAK,GAAG,SAAS,CAAA;AAC9B,MAAM,CAAC,MAAM,OAAO,GAAG,SAAS,CAAA;AAChC,MAAM,CAAC,MAAM,MAAM,GAAG,SAAS,CAAA;AAE/B,MAAM,CAAC,MAAM,QAAQ,GAAG,UAAU,CAAA;AACl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MAAM,eAAe,GAAG,WAAW,CAAA;AAC1C,MAAM,CAAC,MAAM,gBAAgB,GAAG,WAAW,CAAA;AAC3C,MAAM,CAAC,MAAM,cAAc,GAAG,WAAW,CAAA;AACzC,MAAM,CAAC,MAAM,iBAAiB,GAAG,WAAW,CAAA;AAC5C,MAAM,CAAC,MAAM,cAAc,GAAG,WAAW,CAAA;AACzC,MAAM,CAAC,MAAM,eAAe,GAAG,WAAW,CAAA"}
package/package.json ADDED
@@ -0,0 +1,47 @@
1
+ {
2
+ "name": "@localess/js-client",
3
+ "version": "0.0.2",
4
+ "description": "Universal JavaScript/TypeScript SDK for Localess's API.",
5
+ "keywords": [
6
+ "localess",
7
+ "sdk",
8
+ "api",
9
+ "client",
10
+ "javascript",
11
+ "typescript"
12
+ ],
13
+ "author": "Lessify",
14
+ "homepage": "https://localess.org",
15
+ "sideEffects": false,
16
+ "main": "./dist/index.js",
17
+ "types": "./dist/index.d.ts",
18
+ "files": [
19
+ "dist"
20
+ ],
21
+ "exports": {
22
+ "import": "./dist/index.js",
23
+ "types": "./dist/index.d.ts"
24
+ },
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "git+https://github.com/Lessify/localess-js-client.git"
28
+ },
29
+ "bugs": {
30
+ "url": "https://github.com/Lessify/localess-js-client/issues"
31
+ },
32
+ "scripts": {
33
+ "build": "tsc -p tsconfig.json"
34
+ },
35
+ "license": "MIT",
36
+ "dependencies": {
37
+ "node-fetch": "^3.0.0",
38
+ "proxy-agent": "^6.0.0"
39
+ },
40
+ "devDependencies": {
41
+ "@types/node": "^20.12.12",
42
+ "typescript": "^5.0.0"
43
+ },
44
+ "engines": {
45
+ "node": ">= 18.0.0"
46
+ }
47
+ }