@blinkk/root-cms 2.0.0-rc.0 → 2.0.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/app.js +226 -20
- package/dist/cli.js +217 -164
- package/dist/{client-dBGLkauA.d.ts → client-fqtWzfpQ.d.ts} +349 -113
- package/dist/client.d.ts +1 -1
- package/dist/client.js +699 -316
- package/dist/core.d.ts +5 -80
- package/dist/core.js +705 -515
- package/dist/functions.js +695 -306
- package/dist/plugin.d.ts +1 -1
- package/dist/plugin.js +961 -524
- package/dist/project.d.ts +1 -1
- package/dist/project.js +2 -2
- package/dist/richtext.js +0 -1
- package/dist/{schema-ix967Ud0.d.ts → schema-KpQGOA1Z.d.ts} +65 -8
- package/dist/ui/signin.css +0 -1
- package/dist/ui/signin.js +0 -1
- package/dist/ui/ui.css +1 -2
- package/dist/ui/ui.js +142 -103
- package/package.json +20 -16
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { Request, Plugin, RootConfig } from '@blinkk/root';
|
|
2
2
|
import { App } from 'firebase-admin/app';
|
|
3
|
-
import { Firestore, Timestamp, Query
|
|
3
|
+
import { Firestore, WriteBatch, Timestamp, Query } from 'firebase-admin/firestore';
|
|
4
|
+
|
|
5
|
+
/** Supported Root AI models. Defaults to 'vertexai/gemini-2.5-flash'. */
|
|
6
|
+
type RootAiModel = 'vertexai/gemini-2.5-flash' | 'vertexai/gemini-2.0-pro' | 'vertexai/gemini-1.5-flash' | 'vertexai/gemini-1.5-pro';
|
|
4
7
|
|
|
5
8
|
interface CMSUser {
|
|
6
9
|
email: string;
|
|
@@ -8,8 +11,8 @@ interface CMSUser {
|
|
|
8
11
|
interface CMSAIConfig {
|
|
9
12
|
/** Custom API endpoint for chat prompts. */
|
|
10
13
|
endpoint?: string;
|
|
11
|
-
/** Gen AI model to use.
|
|
12
|
-
model?:
|
|
14
|
+
/** Gen AI model to use. */
|
|
15
|
+
model?: RootAiModel;
|
|
13
16
|
}
|
|
14
17
|
interface CMSSidebarTool {
|
|
15
18
|
/** URL for the sidebar icon image. */
|
|
@@ -100,6 +103,10 @@ type CMSPluginOptions = {
|
|
|
100
103
|
*/
|
|
101
104
|
tools?: Record<string, CMSSidebarTool>;
|
|
102
105
|
};
|
|
106
|
+
/**
|
|
107
|
+
* URL for a custom favicon used by the CMS UI.
|
|
108
|
+
*/
|
|
109
|
+
favicon?: string;
|
|
103
110
|
/**
|
|
104
111
|
* Callback when an action occurs.
|
|
105
112
|
*/
|
|
@@ -108,7 +115,14 @@ type CMSPluginOptions = {
|
|
|
108
115
|
* Experimental config options. Note: these are subject to change at any time.
|
|
109
116
|
*/
|
|
110
117
|
experiments?: {
|
|
118
|
+
/**
|
|
119
|
+
* Enables the Root CMS AI page.
|
|
120
|
+
*/
|
|
111
121
|
ai?: boolean | CMSAIConfig;
|
|
122
|
+
/**
|
|
123
|
+
* Enables the v2 `TranslationsManager`.
|
|
124
|
+
*/
|
|
125
|
+
v2TranslationsManager?: boolean;
|
|
112
126
|
};
|
|
113
127
|
/**
|
|
114
128
|
* Adjust console output verbosity. Default is `'info'`.
|
|
@@ -127,7 +141,191 @@ type CMSPlugin = Plugin & {
|
|
|
127
141
|
getFirestore: () => Firestore;
|
|
128
142
|
};
|
|
129
143
|
declare function cmsPlugin(options: CMSPluginOptions): CMSPlugin;
|
|
130
|
-
|
|
144
|
+
|
|
145
|
+
type Locale = string;
|
|
146
|
+
type SourceString = string;
|
|
147
|
+
type TranslatedString = string;
|
|
148
|
+
type TranslationsDocMode = 'draft' | 'published';
|
|
149
|
+
interface TranslationsLocaleDocHashMap {
|
|
150
|
+
/**
|
|
151
|
+
* A hash map of a source string's hash fingerprint to the source string and
|
|
152
|
+
* translated string.
|
|
153
|
+
*/
|
|
154
|
+
[hash: string]: TranslationsLocaleDocEntry;
|
|
155
|
+
}
|
|
156
|
+
interface TranslationsLocaleDocEntry {
|
|
157
|
+
source: SourceString;
|
|
158
|
+
translation: TranslatedString;
|
|
159
|
+
}
|
|
160
|
+
interface TranslationsDbPathOptions {
|
|
161
|
+
project: string;
|
|
162
|
+
mode: TranslationsDocMode;
|
|
163
|
+
}
|
|
164
|
+
type TranslationsLocaleDocDbPathOptions = TranslationsDbPathOptions & {
|
|
165
|
+
id: string;
|
|
166
|
+
locale: string;
|
|
167
|
+
};
|
|
168
|
+
/**
|
|
169
|
+
* A translations map containing translations for multiple locales.
|
|
170
|
+
*
|
|
171
|
+
* Example:
|
|
172
|
+
* ```
|
|
173
|
+
* {
|
|
174
|
+
* "one": {"es": "uno", "fr": "un"},
|
|
175
|
+
* "two": {"es": "dos", "fr": "deux"}
|
|
176
|
+
* }
|
|
177
|
+
* ```
|
|
178
|
+
*/
|
|
179
|
+
interface MultiLocaleTranslationsMap {
|
|
180
|
+
[source: SourceString]: {
|
|
181
|
+
[locale: Locale]: TranslatedString;
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* A translations map containing translations for a single locale.
|
|
186
|
+
*
|
|
187
|
+
* Example:
|
|
188
|
+
* ```
|
|
189
|
+
* {
|
|
190
|
+
* "one": "uno",
|
|
191
|
+
* "two": "dos"
|
|
192
|
+
* }
|
|
193
|
+
* ```
|
|
194
|
+
*/
|
|
195
|
+
interface SingleLocaleTranslationsMap {
|
|
196
|
+
[source: SourceString]: TranslatedString;
|
|
197
|
+
}
|
|
198
|
+
declare class TranslationsManager {
|
|
199
|
+
cmsClient: RootCMSClient;
|
|
200
|
+
constructor(cmsClient: RootCMSClient);
|
|
201
|
+
/**
|
|
202
|
+
* Saves draft translations for a translations doc id.
|
|
203
|
+
*
|
|
204
|
+
* Example:
|
|
205
|
+
* ```
|
|
206
|
+
* const strings = {
|
|
207
|
+
* 'one': {es: 'uno', fr: 'un'},
|
|
208
|
+
* 'two': {es: 'dos', fr: 'deux'},
|
|
209
|
+
* };
|
|
210
|
+
* await tm.saveTranslations('Pages/index', strings);
|
|
211
|
+
* ```
|
|
212
|
+
*/
|
|
213
|
+
saveTranslations(id: string, strings: MultiLocaleTranslationsMap, options?: {
|
|
214
|
+
tags?: string[];
|
|
215
|
+
modifiedBy?: string;
|
|
216
|
+
}): Promise<void>;
|
|
217
|
+
/**
|
|
218
|
+
* Publishes a translations doc.
|
|
219
|
+
*/
|
|
220
|
+
publishTranslations(id: string, options?: {
|
|
221
|
+
batch?: WriteBatch;
|
|
222
|
+
publishedBy?: string;
|
|
223
|
+
}): Promise<void>;
|
|
224
|
+
/**
|
|
225
|
+
* Fetches translations from one or more translations docs in the translations
|
|
226
|
+
* manager.
|
|
227
|
+
*
|
|
228
|
+
* Example:
|
|
229
|
+
* ```
|
|
230
|
+
* await tm.loadTranslations();
|
|
231
|
+
* // =>
|
|
232
|
+
* // {
|
|
233
|
+
* // "one": {"es": "uno", "fr": "un"},
|
|
234
|
+
* // "two": {"es": "dos", "fr": "deux"}
|
|
235
|
+
* // }
|
|
236
|
+
* ```
|
|
237
|
+
*
|
|
238
|
+
* To load a specific set of translations docs by id:
|
|
239
|
+
* ```
|
|
240
|
+
* const translationsToLoad = ['Global/strings', 'Global/header', 'Global/footer', 'Pages/index'];
|
|
241
|
+
* await tm.loadTranslations({ids: translationsToLoad});
|
|
242
|
+
* // =>
|
|
243
|
+
* // {
|
|
244
|
+
* // "one": {"es": "uno", "fr": "un"},
|
|
245
|
+
* // "two": {"es": "dos", "fr": "deux"}
|
|
246
|
+
* // }
|
|
247
|
+
* ```
|
|
248
|
+
*
|
|
249
|
+
* To load a subset of locales (more performant):
|
|
250
|
+
* ```
|
|
251
|
+
* await tm.loadTranslations({locales: ['es']});
|
|
252
|
+
* // =>
|
|
253
|
+
* // {
|
|
254
|
+
* // "one": {"es": "uno"},
|
|
255
|
+
* // "two": {"es": "dos"}
|
|
256
|
+
* // }
|
|
257
|
+
* ```
|
|
258
|
+
*/
|
|
259
|
+
loadTranslations(options?: {
|
|
260
|
+
ids?: string[];
|
|
261
|
+
tags?: string[];
|
|
262
|
+
locales?: Locale[];
|
|
263
|
+
mode?: TranslationsDocMode;
|
|
264
|
+
}): Promise<MultiLocaleTranslationsMap>;
|
|
265
|
+
/**
|
|
266
|
+
* Fetches translations for a given locale, with optional fallbacks.
|
|
267
|
+
* The return value is a map of source string to translated string.
|
|
268
|
+
*
|
|
269
|
+
* Example:
|
|
270
|
+
* ```
|
|
271
|
+
* await translationsDoc.loadTranslationsForLocale('es');
|
|
272
|
+
* // =>
|
|
273
|
+
* // {
|
|
274
|
+
* // "one": "uno",
|
|
275
|
+
* // "two": "dos",
|
|
276
|
+
* // }
|
|
277
|
+
* ```
|
|
278
|
+
*/
|
|
279
|
+
loadTranslationsForLocale(locale: Locale, options?: {
|
|
280
|
+
mode?: TranslationsDocMode;
|
|
281
|
+
fallbackLocales?: Locale[];
|
|
282
|
+
}): Promise<SingleLocaleTranslationsMap>;
|
|
283
|
+
/**
|
|
284
|
+
* Converts a multi-locale translations map to a flat single-locale map,
|
|
285
|
+
* with optional support for fallback locales.
|
|
286
|
+
*
|
|
287
|
+
* ```
|
|
288
|
+
* const multiLocaleStrings = {
|
|
289
|
+
* 'one': {es: 'uno', fr: 'un'},
|
|
290
|
+
* 'two': {es: 'dos', fr: 'deux'}
|
|
291
|
+
* };
|
|
292
|
+
* translationsDoc.toSingleLocaleMap(multiLocaleStrings, ['es']);
|
|
293
|
+
* // =>
|
|
294
|
+
* // {
|
|
295
|
+
* // "one": "uno",
|
|
296
|
+
* // "two": "dos",
|
|
297
|
+
* // }
|
|
298
|
+
* ```
|
|
299
|
+
*/
|
|
300
|
+
private toSingleLocaleMap;
|
|
301
|
+
/**
|
|
302
|
+
* Converts a multi-locale translations map to a single-locale hashed version,
|
|
303
|
+
* used for storage in in the DB.
|
|
304
|
+
*
|
|
305
|
+
* ```
|
|
306
|
+
* const multiLocaleStrings = {
|
|
307
|
+
* 'one': {es: 'uno', fr: 'un'},
|
|
308
|
+
* 'two': {es: 'dos', fr: 'deux'}
|
|
309
|
+
* };
|
|
310
|
+
* translationsDoc.toLocaleDocHashMap(multiLocaleStrings, 'es');
|
|
311
|
+
* // =>
|
|
312
|
+
* // {
|
|
313
|
+
* // "<hash1>": {"source": "one", "translation": "uno"},
|
|
314
|
+
* // "<hash2>": {"source": "two", "translation": "dos"},
|
|
315
|
+
* // }
|
|
316
|
+
* ```
|
|
317
|
+
*
|
|
318
|
+
* One reason for using hashes is because the DB has limits on the number of
|
|
319
|
+
* chars that can be used as the "key" in a object map.
|
|
320
|
+
*/
|
|
321
|
+
private toLocaleDocHashMap;
|
|
322
|
+
/**
|
|
323
|
+
* Import translations from the v1 system to the TranslationsManager.
|
|
324
|
+
*/
|
|
325
|
+
importTranslationsFromV1(): Promise<void>;
|
|
326
|
+
}
|
|
327
|
+
declare function buildTranslationsDbPath(options: TranslationsDbPathOptions): string;
|
|
328
|
+
declare function buildTranslationsLocaleDocDbPath(options: TranslationsLocaleDocDbPathOptions): string;
|
|
131
329
|
|
|
132
330
|
interface Doc<Fields = any> {
|
|
133
331
|
/** The id of the doc, e.g. "Pages/foo-bar". */
|
|
@@ -155,23 +353,6 @@ interface Doc<Fields = any> {
|
|
|
155
353
|
};
|
|
156
354
|
fields: Fields;
|
|
157
355
|
}
|
|
158
|
-
interface TranslationsDoc {
|
|
159
|
-
id: string;
|
|
160
|
-
sys: {
|
|
161
|
-
modifiedAt: Timestamp;
|
|
162
|
-
modifiedBy: string;
|
|
163
|
-
publishedAt?: Timestamp;
|
|
164
|
-
publishedBy?: string;
|
|
165
|
-
linkedSheet?: {
|
|
166
|
-
spreadsheetId: string;
|
|
167
|
-
gid: number;
|
|
168
|
-
linkedAt: Timestamp;
|
|
169
|
-
linkedBy: string;
|
|
170
|
-
};
|
|
171
|
-
tags?: string[];
|
|
172
|
-
};
|
|
173
|
-
strings: TranslationsMap;
|
|
174
|
-
}
|
|
175
356
|
type DocMode = 'draft' | 'published';
|
|
176
357
|
type UserRole = 'ADMIN' | 'EDITOR' | 'VIEWER';
|
|
177
358
|
type HttpMethod = 'GET' | 'POST';
|
|
@@ -203,6 +384,8 @@ interface DataSource {
|
|
|
203
384
|
interface DataSourceData<T = any> {
|
|
204
385
|
dataSource: DataSource;
|
|
205
386
|
data: T;
|
|
387
|
+
/** Optional list of column headers (for gsheet sources). */
|
|
388
|
+
headers?: string[];
|
|
206
389
|
}
|
|
207
390
|
type DataSourceMode = 'draft' | 'published';
|
|
208
391
|
interface GetDocOptions {
|
|
@@ -257,6 +440,7 @@ interface Release {
|
|
|
257
440
|
id: string;
|
|
258
441
|
description?: string;
|
|
259
442
|
docIds?: string[];
|
|
443
|
+
dataSourceIds?: string[];
|
|
260
444
|
createdAt?: Timestamp;
|
|
261
445
|
createdBy?: string;
|
|
262
446
|
scheduledAt?: Timestamp;
|
|
@@ -312,12 +496,21 @@ declare class RootCMSClient {
|
|
|
312
496
|
* what you are doing.
|
|
313
497
|
*/
|
|
314
498
|
getRawDoc(collectionId: string, slug: string, options: GetDocOptions): Promise<any | null>;
|
|
499
|
+
/**
|
|
500
|
+
* Firestore path for a collection.
|
|
501
|
+
*/
|
|
315
502
|
dbCollectionDocsPath(collectionId: string, options: {
|
|
316
503
|
mode: 'draft' | 'published';
|
|
317
504
|
}): string;
|
|
505
|
+
/**
|
|
506
|
+
* Firestore path for a content doc.
|
|
507
|
+
*/
|
|
318
508
|
dbDocPath(collectionId: string, slug: string, options: {
|
|
319
509
|
mode: 'draft' | 'published';
|
|
320
510
|
}): string;
|
|
511
|
+
/**
|
|
512
|
+
* Firestore doc ref for a content doc.
|
|
513
|
+
*/
|
|
321
514
|
dbDocRef(collectionId: string, slug: string, options: {
|
|
322
515
|
mode: 'draft' | 'published';
|
|
323
516
|
}): FirebaseFirestore.DocumentReference<FirebaseFirestore.DocumentData>;
|
|
@@ -349,6 +542,7 @@ declare class RootCMSClient {
|
|
|
349
542
|
publishDocs(docIds: string[], options?: {
|
|
350
543
|
publishedBy: string;
|
|
351
544
|
batch?: WriteBatch;
|
|
545
|
+
releaseId?: string;
|
|
352
546
|
}): Promise<any[]>;
|
|
353
547
|
/**
|
|
354
548
|
* Publishes scheduled docs.
|
|
@@ -358,24 +552,35 @@ declare class RootCMSClient {
|
|
|
358
552
|
* Publishes docs in scheduled releases.
|
|
359
553
|
*/
|
|
360
554
|
publishScheduledReleases(): Promise<void>;
|
|
361
|
-
publishTranslationsDoc(translationsId: string, options?: {
|
|
362
|
-
batch?: WriteBatch;
|
|
363
|
-
publishedBy?: string;
|
|
364
|
-
}): Promise<void>;
|
|
365
555
|
/**
|
|
366
556
|
* Checks if a doc is currently "locked" for publishing.
|
|
367
557
|
*/
|
|
368
558
|
testPublishingLocked(doc: Doc): boolean;
|
|
369
559
|
/**
|
|
370
|
-
*
|
|
560
|
+
* Returns a `TranslationsManager` object for managing translations.
|
|
561
|
+
*
|
|
562
|
+
* To get translations:
|
|
563
|
+
* ```
|
|
564
|
+
* await tm.loadTranslations({
|
|
565
|
+
* ids: ['Global/strings', 'Pages/index'],
|
|
566
|
+
* locales: ['es'],
|
|
567
|
+
* });
|
|
568
|
+
* ```
|
|
371
569
|
*
|
|
570
|
+
* NOTE: The `TranslationsManager` is a v2 feature that will eventually
|
|
571
|
+
* replace the v1 translations system.
|
|
572
|
+
*/
|
|
573
|
+
getTranslationsManager(): TranslationsManager;
|
|
574
|
+
/**
|
|
575
|
+
* Loads translations saved in the translations collection, optionally
|
|
576
|
+
* filtered by tag.
|
|
577
|
+
*
|
|
578
|
+
* Returns a map like:
|
|
372
579
|
* ```
|
|
373
580
|
* {
|
|
374
581
|
* "<hash>": {"source": "Hello", "es": "Hola", "fr": "Bonjour"},
|
|
375
582
|
* }
|
|
376
583
|
* ```
|
|
377
|
-
*
|
|
378
|
-
* @deprecated Use `createBatchRequest()` to fetch draft/published translations.
|
|
379
584
|
*/
|
|
380
585
|
loadTranslations(options?: LoadTranslationsOptions): Promise<TranslationsMap>;
|
|
381
586
|
/**
|
|
@@ -385,22 +590,12 @@ declare class RootCMSClient {
|
|
|
385
590
|
* "Hello": {"es": "Hola", "fr": "Bonjour"},
|
|
386
591
|
* });
|
|
387
592
|
* ```
|
|
388
|
-
*
|
|
389
|
-
* @deprecated Use `saveDraftTranslations()` and `publishTranslations()`
|
|
390
|
-
* instead.
|
|
391
593
|
*/
|
|
392
594
|
saveTranslations(translations: {
|
|
393
595
|
[source: string]: {
|
|
394
596
|
[locale: string]: string;
|
|
395
597
|
};
|
|
396
598
|
}, tags?: string[]): Promise<void>;
|
|
397
|
-
saveDraftTranslations(translationsId: string, translations: {
|
|
398
|
-
[source: string]: {
|
|
399
|
-
[locale: string]: string;
|
|
400
|
-
};
|
|
401
|
-
}, options?: {
|
|
402
|
-
modifiedby?: string;
|
|
403
|
-
}): Promise<void>;
|
|
404
599
|
/**
|
|
405
600
|
* Returns the "key" used for a translation as stored in the db. Translations
|
|
406
601
|
* are stored under `Projects/<project id>/Translations/<sha1 hash>`.
|
|
@@ -423,6 +618,18 @@ declare class RootCMSClient {
|
|
|
423
618
|
* ```
|
|
424
619
|
*/
|
|
425
620
|
loadTranslationsForLocale(locale: string, options?: LoadTranslationsOptions): Promise<LocaleTranslations>;
|
|
621
|
+
/**
|
|
622
|
+
* Firestore path for a translations file.
|
|
623
|
+
*/
|
|
624
|
+
dbTranslationsPath(translationsId: string, options: {
|
|
625
|
+
mode: 'draft' | 'published';
|
|
626
|
+
}): string;
|
|
627
|
+
/**
|
|
628
|
+
* Firestore doc ref for a translations file.
|
|
629
|
+
*/
|
|
630
|
+
dbTranslationsRef(translationsId: string, options: {
|
|
631
|
+
mode: 'draft' | 'published';
|
|
632
|
+
}): FirebaseFirestore.DocumentReference<FirebaseFirestore.DocumentData>;
|
|
426
633
|
/**
|
|
427
634
|
* Returns a data source configuration object.
|
|
428
635
|
*/
|
|
@@ -436,6 +643,11 @@ declare class RootCMSClient {
|
|
|
436
643
|
publishDataSource(dataSourceId: string, options?: {
|
|
437
644
|
publishedBy?: string;
|
|
438
645
|
}): Promise<void>;
|
|
646
|
+
publishDataSources(dataSourceIds: string[], options?: {
|
|
647
|
+
publishedBy: string;
|
|
648
|
+
batch?: WriteBatch;
|
|
649
|
+
commitBatch?: boolean;
|
|
650
|
+
}): Promise<void>;
|
|
439
651
|
private fetchData;
|
|
440
652
|
private fetchHttpData;
|
|
441
653
|
/**
|
|
@@ -444,18 +656,18 @@ declare class RootCMSClient {
|
|
|
444
656
|
getFromDataSource<T = any>(dataSourceId: string, options?: {
|
|
445
657
|
mode?: 'draft' | 'published';
|
|
446
658
|
}): Promise<DataSourceData<T> | null>;
|
|
659
|
+
/**
|
|
660
|
+
* Firestore path for a datasource data.
|
|
661
|
+
*/
|
|
447
662
|
dbDataSourceDataPath(dataSourceId: string, options: {
|
|
448
663
|
mode: 'draft' | 'published';
|
|
449
664
|
}): string;
|
|
665
|
+
/**
|
|
666
|
+
* Firestore doc ref for a datasource data.
|
|
667
|
+
*/
|
|
450
668
|
dbDataSourceDataRef(dataSourceId: string, options: {
|
|
451
669
|
mode: 'draft' | 'published';
|
|
452
670
|
}): FirebaseFirestore.DocumentReference<FirebaseFirestore.DocumentData>;
|
|
453
|
-
dbTranslationsPath(translationsId: string, options: {
|
|
454
|
-
mode: 'draft' | 'published';
|
|
455
|
-
}): string;
|
|
456
|
-
dbTranslationsRef(translationsId: string, options: {
|
|
457
|
-
mode: 'draft' | 'published';
|
|
458
|
-
}): FirebaseFirestore.DocumentReference<FirebaseFirestore.DocumentData>;
|
|
459
671
|
/**
|
|
460
672
|
* Gets the user's role from the project's ACL.
|
|
461
673
|
*/
|
|
@@ -468,8 +680,80 @@ declare class RootCMSClient {
|
|
|
468
680
|
by?: string;
|
|
469
681
|
metadata?: any;
|
|
470
682
|
}): Promise<void>;
|
|
683
|
+
/**
|
|
684
|
+
* Creates a batch request that is capable of fetching one or more docs,
|
|
685
|
+
* corresponding translations, and dataSources.
|
|
686
|
+
*/
|
|
471
687
|
createBatchRequest(options: BatchRequestOptions): BatchRequest;
|
|
472
688
|
}
|
|
689
|
+
/**
|
|
690
|
+
* Returns true if the `data` is a rich text data object.
|
|
691
|
+
*/
|
|
692
|
+
declare function isRichTextData(data: any): boolean;
|
|
693
|
+
declare function getCmsPlugin(rootConfig: RootConfig): CMSPlugin;
|
|
694
|
+
/**
|
|
695
|
+
* Walks the data tree and converts any array of objects into "array objects"
|
|
696
|
+
* for storage in firestore.
|
|
697
|
+
*/
|
|
698
|
+
declare function marshalData(data: any): any;
|
|
699
|
+
/**
|
|
700
|
+
* Walks the data tree and converts any Timestamp objects to millis and any
|
|
701
|
+
* _array maps to normal arrays.
|
|
702
|
+
*
|
|
703
|
+
* E.g.:
|
|
704
|
+
*
|
|
705
|
+
* normalizeData({
|
|
706
|
+
* sys: {modifiedAt: Timestamp(123)},
|
|
707
|
+
* fields: {
|
|
708
|
+
* _array: ['asdf'],
|
|
709
|
+
* asdf: {title: 'hello'}
|
|
710
|
+
* }
|
|
711
|
+
* })
|
|
712
|
+
* // => {sys: {modifiedAt: 123}, fields: {foo: [{title: 'hello'}]}}
|
|
713
|
+
*/
|
|
714
|
+
declare function unmarshalData(data: any): any;
|
|
715
|
+
/** @deprecated Use `unmarshalData()` instead. */
|
|
716
|
+
declare function normalizeData(data: any): any;
|
|
717
|
+
interface ArrayObject {
|
|
718
|
+
[key: string]: any;
|
|
719
|
+
_array: string[];
|
|
720
|
+
}
|
|
721
|
+
/**
|
|
722
|
+
* Serializes an array into an `ArrayObject`, e.g.:
|
|
723
|
+
*
|
|
724
|
+
* ```
|
|
725
|
+
* marshalArray([1, 2, 3])
|
|
726
|
+
* // => {a: 1, b: 2, c: 3, _array: ['a', 'b', 'c']}
|
|
727
|
+
* ```
|
|
728
|
+
*
|
|
729
|
+
* This database storage method makes it easier to update a single field in a
|
|
730
|
+
* deeply nested array object.
|
|
731
|
+
*/
|
|
732
|
+
declare function toArrayObject(arr: any[]): ArrayObject;
|
|
733
|
+
declare const marshalArray: typeof toArrayObject;
|
|
734
|
+
/**
|
|
735
|
+
* Converts an `ArrayObject` to a normal array.
|
|
736
|
+
*/
|
|
737
|
+
declare function unmarshalArray(arrObject: ArrayObject): any[];
|
|
738
|
+
/**
|
|
739
|
+
* Converts a translations map from `loadTranslations()` to a map of source to
|
|
740
|
+
* translated string for a particular locale.
|
|
741
|
+
*
|
|
742
|
+
* Returns a map like:
|
|
743
|
+
* ```
|
|
744
|
+
* {
|
|
745
|
+
* "Hello": "Bonjour",
|
|
746
|
+
* }
|
|
747
|
+
* ```
|
|
748
|
+
*/
|
|
749
|
+
declare function translationsForLocale(translationsMap: TranslationsMap, locale: string): LocaleTranslations;
|
|
750
|
+
/**
|
|
751
|
+
* Parses a docId (e.g. `Pages/foo`) and returns the `collection` and `slug`.
|
|
752
|
+
*/
|
|
753
|
+
declare function parseDocId(docId: string): {
|
|
754
|
+
collection: string;
|
|
755
|
+
slug: string;
|
|
756
|
+
};
|
|
473
757
|
interface BatchRequestOptions {
|
|
474
758
|
mode: 'draft' | 'published';
|
|
475
759
|
/**
|
|
@@ -490,6 +774,23 @@ interface BatchRequestQueryOptions {
|
|
|
490
774
|
orderByDirection?: 'asc' | 'desc';
|
|
491
775
|
query?: (query: Query) => Query;
|
|
492
776
|
}
|
|
777
|
+
interface TranslationsDoc {
|
|
778
|
+
id: string;
|
|
779
|
+
sys: {
|
|
780
|
+
modifiedAt: Timestamp;
|
|
781
|
+
modifiedBy: string;
|
|
782
|
+
publishedAt?: Timestamp;
|
|
783
|
+
publishedBy?: string;
|
|
784
|
+
linkedSheet?: {
|
|
785
|
+
spreadsheetId: string;
|
|
786
|
+
gid: number;
|
|
787
|
+
linkedAt: Timestamp;
|
|
788
|
+
linkedBy: string;
|
|
789
|
+
};
|
|
790
|
+
tags?: string[];
|
|
791
|
+
};
|
|
792
|
+
strings: TranslationsMap;
|
|
793
|
+
}
|
|
493
794
|
declare class BatchRequest {
|
|
494
795
|
cmsClient: RootCMSClient;
|
|
495
796
|
private options;
|
|
@@ -535,11 +836,13 @@ declare class BatchResponse {
|
|
|
535
836
|
* The input is either a single locale (e.g. "de") or an array of locales
|
|
536
837
|
* representing the fallback tree, e.g. ["en-CA", "en-GB", "en"].
|
|
537
838
|
*
|
|
839
|
+
* TODO(stevenle): support the locale fallback tree.
|
|
840
|
+
*
|
|
538
841
|
* The returned value is a flat map of source string to translated string,
|
|
539
842
|
* e.g.:
|
|
540
843
|
* {"<source>": "<translation>"}
|
|
541
844
|
*/
|
|
542
|
-
getTranslations(locale: string
|
|
845
|
+
getTranslations(locale: string): LocaleTranslations;
|
|
543
846
|
/**
|
|
544
847
|
* Merges the strings from all translations files retrieved in the request.
|
|
545
848
|
* The returned value is a map of string to translations, e.g.:
|
|
@@ -548,72 +851,5 @@ declare class BatchResponse {
|
|
|
548
851
|
*/
|
|
549
852
|
private getTranslationsMap;
|
|
550
853
|
}
|
|
551
|
-
/**
|
|
552
|
-
* Returns true if the `data` is a rich text data object.
|
|
553
|
-
*/
|
|
554
|
-
declare function isRichTextData(data: any): boolean;
|
|
555
|
-
/**
|
|
556
|
-
* Walks the data tree and converts any array of objects into "array objects"
|
|
557
|
-
* for storage in firestore.
|
|
558
|
-
*/
|
|
559
|
-
declare function marshalData(data: any): any;
|
|
560
|
-
/**
|
|
561
|
-
* Walks the data tree and converts any Timestamp objects to millis and any
|
|
562
|
-
* _array maps to normal arrays.
|
|
563
|
-
*
|
|
564
|
-
* E.g.:
|
|
565
|
-
*
|
|
566
|
-
* normalizeData({
|
|
567
|
-
* sys: {modifiedAt: Timestamp(123)},
|
|
568
|
-
* fields: {
|
|
569
|
-
* _array: ['asdf'],
|
|
570
|
-
* asdf: {title: 'hello'}
|
|
571
|
-
* }
|
|
572
|
-
* })
|
|
573
|
-
* // => {sys: {modifiedAt: 123}, fields: {foo: [{title: 'hello'}]}}
|
|
574
|
-
*/
|
|
575
|
-
declare function unmarshalData(data: any): any;
|
|
576
|
-
/** @deprecated Use `unmarshalData()` instead. */
|
|
577
|
-
declare function normalizeData(data: any): any;
|
|
578
|
-
interface ArrayObject {
|
|
579
|
-
[key: string]: any;
|
|
580
|
-
_array: string[];
|
|
581
|
-
}
|
|
582
|
-
/**
|
|
583
|
-
* Serializes an array into an `ArrayObject`, e.g.:
|
|
584
|
-
*
|
|
585
|
-
* ```
|
|
586
|
-
* marshalArray([1, 2, 3])
|
|
587
|
-
* // => {a: 1, b: 2, c: 3, _array: ['a', 'b', 'c']}
|
|
588
|
-
* ```
|
|
589
|
-
*
|
|
590
|
-
* This database storage method makes it easier to update a single field in a
|
|
591
|
-
* deeply nested array object.
|
|
592
|
-
*/
|
|
593
|
-
declare function toArrayObject(arr: any[]): ArrayObject;
|
|
594
|
-
declare const marshalArray: typeof toArrayObject;
|
|
595
|
-
/**
|
|
596
|
-
* Converts an `ArrayObject` to a normal array.
|
|
597
|
-
*/
|
|
598
|
-
declare function unmarshalArray(arrObject: ArrayObject): any[];
|
|
599
|
-
/**
|
|
600
|
-
* Converts a translations map from `loadTranslations()` to a map of source to
|
|
601
|
-
* translated string for a particular locale.
|
|
602
|
-
*
|
|
603
|
-
* Returns a map like:
|
|
604
|
-
* ```
|
|
605
|
-
* {
|
|
606
|
-
* "Hello": "Bonjour",
|
|
607
|
-
* }
|
|
608
|
-
* ```
|
|
609
|
-
*/
|
|
610
|
-
declare function translationsForLocale(translationsMap: TranslationsMap, locale: string | string[]): LocaleTranslations;
|
|
611
|
-
/**
|
|
612
|
-
* Parses a docId (e.g. `Pages/foo`) and returns the `collection` and `slug`.
|
|
613
|
-
*/
|
|
614
|
-
declare function parseDocId(docId: string): {
|
|
615
|
-
collection: string;
|
|
616
|
-
slug: string;
|
|
617
|
-
};
|
|
618
854
|
|
|
619
|
-
export { type Action as A,
|
|
855
|
+
export { cmsPlugin as $, type Action as A, type BatchRequestOptions as B, BatchResponse as C, type Doc as D, type Locale as E, type SourceString as F, type GetDocOptions as G, type HttpMethod as H, type TranslatedString as I, type TranslationsDocMode as J, type TranslationsLocaleDocHashMap as K, type LoadTranslationsOptions as L, type TranslationsLocaleDocEntry as M, type MultiLocaleTranslationsMap as N, type SingleLocaleTranslationsMap as O, TranslationsManager as P, buildTranslationsDbPath as Q, type Release as R, type SetDocOptions as S, type TranslationsMap as T, type UserRole as U, buildTranslationsLocaleDocDbPath as V, type CMSUser as W, type CMSAIConfig as X, type CMSSidebarTool as Y, type CMSPluginOptions as Z, type CMSPlugin as _, type LocaleTranslations as a, type DocMode as b, type DataSource as c, type DataSourceData as d, type DataSourceMode as e, type SaveDraftOptions as f, type ListDocsOptions as g, type GetCountOptions as h, type Translation as i, type ListActionsOptions as j, RootCMSClient as k, isRichTextData as l, getCmsPlugin as m, marshalData as n, normalizeData as o, type ArrayObject as p, marshalArray as q, unmarshalArray as r, translationsForLocale as s, toArrayObject as t, unmarshalData as u, parseDocId as v, type BatchRequestQuery as w, type BatchRequestQueryOptions as x, type TranslationsDoc as y, BatchRequest as z };
|
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import '@blinkk/root';
|
|
2
2
|
import 'firebase-admin/app';
|
|
3
3
|
import 'firebase-admin/firestore';
|
|
4
|
-
export { A as Action,
|
|
4
|
+
export { A as Action, p as ArrayObject, z as BatchRequest, B as BatchRequestOptions, w as BatchRequestQuery, x as BatchRequestQueryOptions, C as BatchResponse, c as DataSource, d as DataSourceData, e as DataSourceMode, D as Doc, b as DocMode, h as GetCountOptions, G as GetDocOptions, H as HttpMethod, j as ListActionsOptions, g as ListDocsOptions, L as LoadTranslationsOptions, a as LocaleTranslations, R as Release, k as RootCMSClient, f as SaveDraftOptions, S as SetDocOptions, i as Translation, y as TranslationsDoc, T as TranslationsMap, U as UserRole, m as getCmsPlugin, l as isRichTextData, q as marshalArray, n as marshalData, o as normalizeData, v as parseDocId, t as toArrayObject, s as translationsForLocale, r as unmarshalArray, u as unmarshalData } from './client-fqtWzfpQ.js';
|