@blinkk/root-cms 1.3.11 → 2.0.0-rc.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/cli.js +116 -62
- package/dist/{client-AoUqU1KV.d.ts → client-dBGLkauA.d.ts} +142 -6
- package/dist/client.d.ts +1 -1
- package/dist/client.js +420 -47
- package/dist/core.d.ts +79 -4
- package/dist/core.js +616 -47
- package/dist/functions.js +420 -55
- package/dist/plugin.d.ts +1 -1
- package/dist/plugin.js +468 -36
- package/dist/ui/ui.css +2 -2
- package/dist/ui/ui.js +71 -72
- package/package.json +3 -3
|
@@ -127,6 +127,7 @@ type CMSPlugin = Plugin & {
|
|
|
127
127
|
getFirestore: () => Firestore;
|
|
128
128
|
};
|
|
129
129
|
declare function cmsPlugin(options: CMSPluginOptions): CMSPlugin;
|
|
130
|
+
declare function getCmsPlugin(rootConfig: RootConfig): CMSPlugin;
|
|
130
131
|
|
|
131
132
|
interface Doc<Fields = any> {
|
|
132
133
|
/** The id of the doc, e.g. "Pages/foo-bar". */
|
|
@@ -154,6 +155,23 @@ interface Doc<Fields = any> {
|
|
|
154
155
|
};
|
|
155
156
|
fields: Fields;
|
|
156
157
|
}
|
|
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
|
+
}
|
|
157
175
|
type DocMode = 'draft' | 'published';
|
|
158
176
|
type UserRole = 'ADMIN' | 'EDITOR' | 'VIEWER';
|
|
159
177
|
type HttpMethod = 'GET' | 'POST';
|
|
@@ -212,6 +230,11 @@ interface ListDocsOptions {
|
|
|
212
230
|
orderBy?: string;
|
|
213
231
|
orderByDirection?: 'asc' | 'desc';
|
|
214
232
|
query?: (query: Query) => Query;
|
|
233
|
+
/**
|
|
234
|
+
* Whether to fetch the "raw" version of the doc (for use in conjunction with
|
|
235
|
+
* `setRawDoc()`).
|
|
236
|
+
*/
|
|
237
|
+
raw?: boolean;
|
|
215
238
|
}
|
|
216
239
|
interface GetCountOptions {
|
|
217
240
|
mode: DocMode;
|
|
@@ -289,6 +312,15 @@ declare class RootCMSClient {
|
|
|
289
312
|
* what you are doing.
|
|
290
313
|
*/
|
|
291
314
|
getRawDoc(collectionId: string, slug: string, options: GetDocOptions): Promise<any | null>;
|
|
315
|
+
dbCollectionDocsPath(collectionId: string, options: {
|
|
316
|
+
mode: 'draft' | 'published';
|
|
317
|
+
}): string;
|
|
318
|
+
dbDocPath(collectionId: string, slug: string, options: {
|
|
319
|
+
mode: 'draft' | 'published';
|
|
320
|
+
}): string;
|
|
321
|
+
dbDocRef(collectionId: string, slug: string, options: {
|
|
322
|
+
mode: 'draft' | 'published';
|
|
323
|
+
}): FirebaseFirestore.DocumentReference<FirebaseFirestore.DocumentData>;
|
|
292
324
|
/**
|
|
293
325
|
* Saves draft data to a doc.
|
|
294
326
|
*
|
|
@@ -326,20 +358,24 @@ declare class RootCMSClient {
|
|
|
326
358
|
* Publishes docs in scheduled releases.
|
|
327
359
|
*/
|
|
328
360
|
publishScheduledReleases(): Promise<void>;
|
|
361
|
+
publishTranslationsDoc(translationsId: string, options?: {
|
|
362
|
+
batch?: WriteBatch;
|
|
363
|
+
publishedBy?: string;
|
|
364
|
+
}): Promise<void>;
|
|
329
365
|
/**
|
|
330
366
|
* Checks if a doc is currently "locked" for publishing.
|
|
331
367
|
*/
|
|
332
368
|
testPublishingLocked(doc: Doc): boolean;
|
|
333
369
|
/**
|
|
334
|
-
* Loads
|
|
335
|
-
* filtered by tag.
|
|
370
|
+
* Loads all published strings in the db.
|
|
336
371
|
*
|
|
337
|
-
* Returns a map like:
|
|
338
372
|
* ```
|
|
339
373
|
* {
|
|
340
374
|
* "<hash>": {"source": "Hello", "es": "Hola", "fr": "Bonjour"},
|
|
341
375
|
* }
|
|
342
376
|
* ```
|
|
377
|
+
*
|
|
378
|
+
* @deprecated Use `createBatchRequest()` to fetch draft/published translations.
|
|
343
379
|
*/
|
|
344
380
|
loadTranslations(options?: LoadTranslationsOptions): Promise<TranslationsMap>;
|
|
345
381
|
/**
|
|
@@ -349,12 +385,22 @@ declare class RootCMSClient {
|
|
|
349
385
|
* "Hello": {"es": "Hola", "fr": "Bonjour"},
|
|
350
386
|
* });
|
|
351
387
|
* ```
|
|
388
|
+
*
|
|
389
|
+
* @deprecated Use `saveDraftTranslations()` and `publishTranslations()`
|
|
390
|
+
* instead.
|
|
352
391
|
*/
|
|
353
392
|
saveTranslations(translations: {
|
|
354
393
|
[source: string]: {
|
|
355
394
|
[locale: string]: string;
|
|
356
395
|
};
|
|
357
396
|
}, 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>;
|
|
358
404
|
/**
|
|
359
405
|
* Returns the "key" used for a translation as stored in the db. Translations
|
|
360
406
|
* are stored under `Projects/<project id>/Translations/<sha1 hash>`.
|
|
@@ -398,6 +444,18 @@ declare class RootCMSClient {
|
|
|
398
444
|
getFromDataSource<T = any>(dataSourceId: string, options?: {
|
|
399
445
|
mode?: 'draft' | 'published';
|
|
400
446
|
}): Promise<DataSourceData<T> | null>;
|
|
447
|
+
dbDataSourceDataPath(dataSourceId: string, options: {
|
|
448
|
+
mode: 'draft' | 'published';
|
|
449
|
+
}): string;
|
|
450
|
+
dbDataSourceDataRef(dataSourceId: string, options: {
|
|
451
|
+
mode: 'draft' | 'published';
|
|
452
|
+
}): 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>;
|
|
401
459
|
/**
|
|
402
460
|
* Gets the user's role from the project's ACL.
|
|
403
461
|
*/
|
|
@@ -410,12 +468,90 @@ declare class RootCMSClient {
|
|
|
410
468
|
by?: string;
|
|
411
469
|
metadata?: any;
|
|
412
470
|
}): Promise<void>;
|
|
471
|
+
createBatchRequest(options: BatchRequestOptions): BatchRequest;
|
|
472
|
+
}
|
|
473
|
+
interface BatchRequestOptions {
|
|
474
|
+
mode: 'draft' | 'published';
|
|
475
|
+
/**
|
|
476
|
+
* Whether to automatically fetch translations for the docs retrieved in the
|
|
477
|
+
* request.
|
|
478
|
+
*/
|
|
479
|
+
translate?: boolean;
|
|
480
|
+
}
|
|
481
|
+
interface BatchRequestQuery {
|
|
482
|
+
queryId: string;
|
|
483
|
+
collectionId: string;
|
|
484
|
+
queryOptions?: BatchRequestQueryOptions;
|
|
485
|
+
}
|
|
486
|
+
interface BatchRequestQueryOptions {
|
|
487
|
+
offset?: number;
|
|
488
|
+
limit?: number;
|
|
489
|
+
orderBy?: string;
|
|
490
|
+
orderByDirection?: 'asc' | 'desc';
|
|
491
|
+
query?: (query: Query) => Query;
|
|
492
|
+
}
|
|
493
|
+
declare class BatchRequest {
|
|
494
|
+
cmsClient: RootCMSClient;
|
|
495
|
+
private options;
|
|
496
|
+
private db;
|
|
497
|
+
private docIds;
|
|
498
|
+
private dataSourceIds;
|
|
499
|
+
private queries;
|
|
500
|
+
private translationsIds;
|
|
501
|
+
constructor(cmsClient: RootCMSClient, options: BatchRequestOptions);
|
|
502
|
+
/**
|
|
503
|
+
* Adds a doc to the batch request.
|
|
504
|
+
*/
|
|
505
|
+
addDoc(docId: string): void;
|
|
506
|
+
/**
|
|
507
|
+
* Adds a data source to the batch request.
|
|
508
|
+
*/
|
|
509
|
+
addDataSource(dataSourceId: string): void;
|
|
510
|
+
/**
|
|
511
|
+
* Adds a collection-based query to the batch request.
|
|
512
|
+
*/
|
|
513
|
+
addQuery(queryId: string, collectionId: string, queryOptions?: BatchRequestQueryOptions): void;
|
|
514
|
+
/**
|
|
515
|
+
* Adds a translation file to the request.
|
|
516
|
+
*/
|
|
517
|
+
addTranslations(translationsId: string): void;
|
|
518
|
+
/**
|
|
519
|
+
* Fetches data from the DB.
|
|
520
|
+
*/
|
|
521
|
+
fetch(): Promise<BatchResponse>;
|
|
522
|
+
private fetchDocs;
|
|
523
|
+
private fetchQueries;
|
|
524
|
+
private fetchDataSources;
|
|
525
|
+
private fetchTranslations;
|
|
526
|
+
}
|
|
527
|
+
declare class BatchResponse {
|
|
528
|
+
docs: Record<string, Doc>;
|
|
529
|
+
queries: Record<string, Doc[]>;
|
|
530
|
+
dataSources: Record<string, DataSourceData>;
|
|
531
|
+
translations: Record<string, TranslationsDoc>;
|
|
532
|
+
/**
|
|
533
|
+
* Returns a map of translations for a given locale or locale fallbacks.
|
|
534
|
+
*
|
|
535
|
+
* The input is either a single locale (e.g. "de") or an array of locales
|
|
536
|
+
* representing the fallback tree, e.g. ["en-CA", "en-GB", "en"].
|
|
537
|
+
*
|
|
538
|
+
* The returned value is a flat map of source string to translated string,
|
|
539
|
+
* e.g.:
|
|
540
|
+
* {"<source>": "<translation>"}
|
|
541
|
+
*/
|
|
542
|
+
getTranslations(locale: string | string[]): LocaleTranslations;
|
|
543
|
+
/**
|
|
544
|
+
* Merges the strings from all translations files retrieved in the request.
|
|
545
|
+
* The returned value is a map of string to translations, e.g.:
|
|
546
|
+
*
|
|
547
|
+
* {"<hash>": {"source": "<source>", "<locale>": "<translation>"}}
|
|
548
|
+
*/
|
|
549
|
+
private getTranslationsMap;
|
|
413
550
|
}
|
|
414
551
|
/**
|
|
415
552
|
* Returns true if the `data` is a rich text data object.
|
|
416
553
|
*/
|
|
417
554
|
declare function isRichTextData(data: any): boolean;
|
|
418
|
-
declare function getCmsPlugin(rootConfig: RootConfig): CMSPlugin;
|
|
419
555
|
/**
|
|
420
556
|
* Walks the data tree and converts any array of objects into "array objects"
|
|
421
557
|
* for storage in firestore.
|
|
@@ -471,7 +607,7 @@ declare function unmarshalArray(arrObject: ArrayObject): any[];
|
|
|
471
607
|
* }
|
|
472
608
|
* ```
|
|
473
609
|
*/
|
|
474
|
-
declare function translationsForLocale(translationsMap: TranslationsMap, locale: string): LocaleTranslations;
|
|
610
|
+
declare function translationsForLocale(translationsMap: TranslationsMap, locale: string | string[]): LocaleTranslations;
|
|
475
611
|
/**
|
|
476
612
|
* Parses a docId (e.g. `Pages/foo`) and returns the `collection` and `slug`.
|
|
477
613
|
*/
|
|
@@ -480,4 +616,4 @@ declare function parseDocId(docId: string): {
|
|
|
480
616
|
slug: string;
|
|
481
617
|
};
|
|
482
618
|
|
|
483
|
-
export { type Action as A,
|
|
619
|
+
export { type Action as A, BatchRequest as B, parseDocId as C, type Doc as D, type CMSUser as E, type CMSAIConfig as F, type GetDocOptions as G, type HttpMethod as H, type CMSSidebarTool as I, type CMSPluginOptions as J, type CMSPlugin as K, type LoadTranslationsOptions as L, cmsPlugin as M, RootCMSClient as R, type SetDocOptions as S, type TranslationsMap as T, type UserRole as U, type LocaleTranslations as a, type TranslationsDoc as b, type DocMode as c, type DataSource as d, type DataSourceData as e, type DataSourceMode as f, getCmsPlugin as g, type SaveDraftOptions as h, type ListDocsOptions as i, type GetCountOptions as j, type Translation as k, type Release as l, type ListActionsOptions as m, type BatchRequestOptions as n, type BatchRequestQuery as o, type BatchRequestQueryOptions as p, BatchResponse as q, isRichTextData as r, marshalData as s, normalizeData as t, unmarshalData as u, type ArrayObject as v, toArrayObject as w, marshalArray as x, unmarshalArray as y, translationsForLocale 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, v as ArrayObject, B as BatchRequest, n as BatchRequestOptions, o as BatchRequestQuery, p as BatchRequestQueryOptions, q as BatchResponse, d as DataSource, e as DataSourceData, f as DataSourceMode, D as Doc, c as DocMode, j as GetCountOptions, G as GetDocOptions, H as HttpMethod, m as ListActionsOptions, i as ListDocsOptions, L as LoadTranslationsOptions, a as LocaleTranslations, l as Release, R as RootCMSClient, h as SaveDraftOptions, S as SetDocOptions, k as Translation, b as TranslationsDoc, T as TranslationsMap, U as UserRole, g as getCmsPlugin, r as isRichTextData, x as marshalArray, s as marshalData, t as normalizeData, C as parseDocId, w as toArrayObject, z as translationsForLocale, y as unmarshalArray, u as unmarshalData } from './client-dBGLkauA.js';
|