@localess/client 3.0.1-dev.20260410071322 → 3.0.1-dev.20260412201733

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@localess/client",
3
- "version": "3.0.1-dev.20260410071322",
3
+ "version": "3.0.1-dev.20260412201733",
4
4
  "description": "Universal JavaScript/TypeScript SDK for Localess's API.",
5
5
  "keywords": [
6
6
  "localess",
@@ -36,14 +36,14 @@
36
36
  "url": "https://github.com/Lessify/localess-js/issues"
37
37
  },
38
38
  "scripts": {
39
- "build": "tsup src/index.ts --format cjs,esm --dts"
39
+ "build": "vite build"
40
40
  },
41
41
  "license": "MIT",
42
- "dependencies": {},
43
42
  "devDependencies": {
44
43
  "@types/node": "^20",
45
- "tsup": "^8.5.1",
46
- "typescript": "^5.0.0"
44
+ "typescript": "^5.0.0",
45
+ "vite": "^8.0.8",
46
+ "vite-plugin-dts": "^4.5.4"
47
47
  },
48
48
  "engines": {
49
49
  "node": ">= 20.0.0"
package/dist/index.d.mts DELETED
@@ -1,336 +0,0 @@
1
- /**
2
- * Content Asset defines reference to an Asset.
3
- */
4
- 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
- }
14
-
15
- /**
16
- * Content Link define reference to a Link.
17
- */
18
- interface ContentLink {
19
- /**
20
- * Define the type of Link
21
- */
22
- kind: 'LINK';
23
- /**
24
- * Define the target of the link. _blank for the new tab and _self for the same tab.
25
- */
26
- target: '_blank' | '_self';
27
- /**
28
- * Define the type of Link. URL for external links and Content for internal links.
29
- */
30
- type: 'url' | 'content';
31
- /**
32
- * If the type is content, then it will be Content ID. Otherwise, it will be URL.
33
- */
34
- uri: string;
35
- }
36
-
37
- /**
38
- * Content RichText define content as JSON Object.
39
- */
40
- interface ContentRichText {
41
- /**
42
- * Define the type of Content Node
43
- */
44
- type?: string;
45
- /**
46
- * List of Content Nodes
47
- */
48
- content?: ContentRichText[];
49
- }
50
-
51
- /**
52
- * Content Reference defines reference to a Content.
53
- */
54
- interface ContentReference {
55
- /**
56
- * Define the type of REFERENCE
57
- */
58
- kind: 'REFERENCE';
59
- /**
60
- * Unique identifier for the Content Document.
61
- */
62
- uri: string;
63
- }
64
-
65
- type ContentDataField = any | string | string[] | number | boolean | ContentLink | ContentRichText | ContentData | ContentData[] | ContentAsset | ContentAsset[] | ContentReference | ContentReference[];
66
- /**
67
- * Content Data Schema related information.
68
- */
69
- interface ContentDataSchema {
70
- /**
71
- * Unique identifier of a component in a content.
72
- */
73
- _id: string;
74
- /**
75
- * Unique identifier for the Schema object.
76
- */
77
- _schema: string;
78
- }
79
- /**
80
- * ContentData defined Object to connect all possible root Schemas.
81
- */
82
- interface ContentData extends ContentDataSchema {
83
- /**
84
- * Other Schema-specific fields
85
- */
86
- [field: string]: ContentDataField | undefined;
87
- }
88
-
89
- /**
90
- * Content Metadata defines short information about a Content for navigation reason.
91
- */
92
- interface ContentMetadata {
93
- /**
94
- * Date and Time at which the Content was created.
95
- */
96
- createdAt: string;
97
- /**
98
- * Combination of SLUG and Parent SLUG of the Content
99
- */
100
- fullSlug: string;
101
- /**
102
- * Unique identifier for the object.
103
- */
104
- id: string;
105
- /**
106
- * Define the type of Content, whether it is a FOLDER or DOCUMENT.
107
- */
108
- kind: 'FOLDER' | 'DOCUMENT';
109
- /**
110
- * Name of the Content
111
- */
112
- name: string;
113
- /**
114
- * Parent SLUG of the Content
115
- */
116
- parentSlug: string;
117
- /**
118
- * Date and Time at which the Content was published.
119
- */
120
- publishedAt?: string;
121
- /**
122
- * SLUG of the Content
123
- */
124
- slug: string;
125
- /**
126
- * Date and Time at which the Content was updated.
127
- */
128
- updatedAt: string;
129
- }
130
-
131
- /**
132
- * Key-Value Object. Where Key is a Unique identifier for the Content object and Value is Content Metadata.
133
- */
134
- interface Links {
135
- [key: string]: ContentMetadata;
136
- }
137
-
138
- /**
139
- * Key-Value Object. Where Key is a Unique identifier for the Content object and Value is Content.
140
- */
141
- interface References {
142
- [key: string]: Content;
143
- }
144
-
145
- /**
146
- * Content defines a shared object for all possible Content Types.
147
- */
148
- interface Content<T extends ContentData = ContentData> extends ContentMetadata {
149
- /**
150
- * Content Data
151
- */
152
- data?: T;
153
- /**
154
- * All links used in the content.
155
- */
156
- links?: Links;
157
- /**
158
- * All references used in the content.
159
- */
160
- references?: References;
161
- }
162
-
163
- interface Locale {
164
- /**
165
- * Unique identifier for the Locale.
166
- */
167
- id: string;
168
- /**
169
- * Name of the Locale.
170
- */
171
- name: string;
172
- }
173
-
174
- /**
175
- * Key-Value Object. Where Key is Translation ID and Value is Translated Content
176
- */
177
- interface Translations {
178
- [key: string]: string;
179
- }
180
-
181
- type LocalessClientOptions = {
182
- /**
183
- * A fully qualified domain name with protocol (http/https) and port.
184
- *
185
- * Example: https://my-localess.web.app
186
- */
187
- origin: string;
188
- /**
189
- * Localess space ID can be found in the Localess Space settings
190
- */
191
- spaceId: string;
192
- /**
193
- * Localess API token can be found in the Localess Space settings
194
- */
195
- token: string;
196
- /**
197
- * Content version to fetch, leave empty for 'published' or 'draft' for the latest draft
198
- */
199
- version?: 'draft' | string;
200
- /**
201
- * Enable debug mode
202
- */
203
- debug?: boolean;
204
- /**
205
- * Cache TTL (time to live) for API responses. Default is 5 minutes (300000 ms).
206
- * Set to false to disable caching.
207
- */
208
- cacheTTL?: number | false;
209
- };
210
- type LinksFetchParams = {
211
- /**
212
- * Content Kind. FOLDER or DOCUMENT. If not provided, it will return all.
213
- * @example 'DOCUMENT'
214
- */
215
- kind?: 'DOCUMENT' | 'FOLDER';
216
- /**
217
- * Content parent slug.
218
- * @example 'legal/policy'
219
- */
220
- parentSlug?: string;
221
- /**
222
- * If **true**, exclude all sub slugs, otherwise include all content under current selected **parent slug**.
223
- * @example false
224
- */
225
- excludeChildren?: boolean;
226
- };
227
- type ContentFetchParams = {
228
- /**
229
- * Content version to fetch, leave empty for 'published' or 'draft' for the latest draft.
230
- * Overrides the version set in the client options.
231
- */
232
- version?: 'draft';
233
- /**
234
- * Locale identifier (ISO 639-1) to fetch content in, leave empty for default locale.
235
- *
236
- * Example: en
237
- */
238
- locale?: string;
239
- /**
240
- * Resolve references in the content data. Default is false.
241
- */
242
- resolveReference?: boolean;
243
- /**
244
- * Resolve links in the content data. Default is false.
245
- */
246
- resolveLink?: boolean;
247
- };
248
- interface LocalessClient {
249
- /**
250
- * Get all links
251
- * @param params{LinksFetchParams} - Fetch parameters
252
- * @returns {Promise<Links>}
253
- */
254
- getLinks(params?: LinksFetchParams): Promise<Links>;
255
- /**
256
- * Get content by SLUG
257
- * @param slug{string} - Content SLUG
258
- * @param params{ContentFetchParams} - Fetch parameters
259
- * @returns {Promise<Content>}
260
- */
261
- getContentBySlug<T extends ContentData = ContentData>(slug: string, params?: ContentFetchParams): Promise<Content<T>>;
262
- /**
263
- * Get content by ID
264
- * @param id{string} - Content ID
265
- * @param params{ContentFetchParams} - Fetch parameters
266
- * @returns {Promise<Content>}
267
- */
268
- getContentById<T extends ContentData = ContentData>(id: string, params?: ContentFetchParams): Promise<Content<T>>;
269
- /**
270
- * Get translations for the given locale
271
- * @param locale{string} - Locale identifier (ISO 639-1)
272
- */
273
- getTranslations(locale: string): Promise<Translations>;
274
- syncScriptUrl(): string;
275
- assetLink(asset: ContentAsset | string): string;
276
- }
277
- /**
278
- * Create a Localess API Client
279
- * @param {LocalessClientOptions} options connection details
280
- */
281
- declare function localessClient(options: LocalessClientOptions): LocalessClient;
282
-
283
- /**
284
- * Adds Localess editable attributes to a content item.
285
- * @param content
286
- * @returns An object containing data-ll-id and data-ll-schema attributes.
287
- */
288
- declare function localessEditable(content: ContentDataSchema): {
289
- 'data-ll-id': string;
290
- 'data-ll-schema': string;
291
- };
292
- /**
293
- * Adds Localess editable field attribute to a specific field.
294
- * Added type safety to ensure fieldName is a valid key of the content data excluding base schema fields.
295
- * @param fieldName
296
- * @returns An object containing data-ll-field attribute.
297
- */
298
- declare function localessEditableField<T extends ContentData = ContentData>(fieldName: Exclude<keyof T, keyof ContentDataSchema>): {
299
- 'data-ll-field': Exclude<keyof T, keyof ContentDataSchema>;
300
- };
301
-
302
- /**
303
- * Inject Localess Sync Script in Header
304
- * @param {string} origin A fully qualified domain name with protocol (http/https) and port.
305
- * @param {boolean} force Force Script Injection even if the application is not in Visual Editor.
306
- */
307
- declare function loadLocalessSync(origin: string, force?: boolean): void;
308
-
309
- declare const isBrowser: () => boolean;
310
- declare const isServer: () => boolean;
311
- declare const isIframe: () => boolean;
312
-
313
- type EventToAppType = 'save' | 'publish' | 'pong' | 'input' | 'change' | 'enterSchema' | 'hoverSchema';
314
- type EventCallback = (event: EventToApp) => void;
315
- type EventToApp = {
316
- type: 'save' | 'publish' | 'pong';
317
- } | {
318
- type: 'input' | 'change';
319
- data: any;
320
- } | {
321
- type: 'enterSchema' | 'hoverSchema';
322
- id: string;
323
- schema: string;
324
- field?: string;
325
- };
326
- interface LocalessSync {
327
- onChange: (callback: EventCallback) => void;
328
- on: (event: EventToAppType | EventToAppType[], callback: EventCallback) => void;
329
- }
330
- declare global {
331
- interface Window {
332
- localess?: LocalessSync;
333
- }
334
- }
335
-
336
- export { type Content, type ContentAsset, type ContentData, type ContentDataField, type ContentDataSchema, type ContentFetchParams, type ContentLink, type ContentMetadata, type ContentReference, type ContentRichText, type EventCallback, type EventToApp, type EventToAppType, type Links, type LinksFetchParams, type Locale, type LocalessClient, type LocalessClientOptions, type LocalessSync, type References, type Translations, isBrowser, isIframe, isServer, loadLocalessSync, localessClient, localessEditable, localessEditableField };