@blinkk/root-cms 1.3.12 → 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-98Le1XxF.d.ts → client-dBGLkauA.d.ts} +137 -6
- package/dist/client.d.ts +1 -1
- package/dist/client.js +413 -45
- package/dist/core.d.ts +79 -4
- package/dist/core.js +609 -45
- package/dist/functions.js +413 -53
- package/dist/plugin.d.ts +1 -1
- package/dist/plugin.js +461 -34
- 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';
|
|
@@ -294,6 +312,15 @@ declare class RootCMSClient {
|
|
|
294
312
|
* what you are doing.
|
|
295
313
|
*/
|
|
296
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>;
|
|
297
324
|
/**
|
|
298
325
|
* Saves draft data to a doc.
|
|
299
326
|
*
|
|
@@ -331,20 +358,24 @@ declare class RootCMSClient {
|
|
|
331
358
|
* Publishes docs in scheduled releases.
|
|
332
359
|
*/
|
|
333
360
|
publishScheduledReleases(): Promise<void>;
|
|
361
|
+
publishTranslationsDoc(translationsId: string, options?: {
|
|
362
|
+
batch?: WriteBatch;
|
|
363
|
+
publishedBy?: string;
|
|
364
|
+
}): Promise<void>;
|
|
334
365
|
/**
|
|
335
366
|
* Checks if a doc is currently "locked" for publishing.
|
|
336
367
|
*/
|
|
337
368
|
testPublishingLocked(doc: Doc): boolean;
|
|
338
369
|
/**
|
|
339
|
-
* Loads
|
|
340
|
-
* filtered by tag.
|
|
370
|
+
* Loads all published strings in the db.
|
|
341
371
|
*
|
|
342
|
-
* Returns a map like:
|
|
343
372
|
* ```
|
|
344
373
|
* {
|
|
345
374
|
* "<hash>": {"source": "Hello", "es": "Hola", "fr": "Bonjour"},
|
|
346
375
|
* }
|
|
347
376
|
* ```
|
|
377
|
+
*
|
|
378
|
+
* @deprecated Use `createBatchRequest()` to fetch draft/published translations.
|
|
348
379
|
*/
|
|
349
380
|
loadTranslations(options?: LoadTranslationsOptions): Promise<TranslationsMap>;
|
|
350
381
|
/**
|
|
@@ -354,12 +385,22 @@ declare class RootCMSClient {
|
|
|
354
385
|
* "Hello": {"es": "Hola", "fr": "Bonjour"},
|
|
355
386
|
* });
|
|
356
387
|
* ```
|
|
388
|
+
*
|
|
389
|
+
* @deprecated Use `saveDraftTranslations()` and `publishTranslations()`
|
|
390
|
+
* instead.
|
|
357
391
|
*/
|
|
358
392
|
saveTranslations(translations: {
|
|
359
393
|
[source: string]: {
|
|
360
394
|
[locale: string]: string;
|
|
361
395
|
};
|
|
362
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>;
|
|
363
404
|
/**
|
|
364
405
|
* Returns the "key" used for a translation as stored in the db. Translations
|
|
365
406
|
* are stored under `Projects/<project id>/Translations/<sha1 hash>`.
|
|
@@ -403,6 +444,18 @@ declare class RootCMSClient {
|
|
|
403
444
|
getFromDataSource<T = any>(dataSourceId: string, options?: {
|
|
404
445
|
mode?: 'draft' | 'published';
|
|
405
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>;
|
|
406
459
|
/**
|
|
407
460
|
* Gets the user's role from the project's ACL.
|
|
408
461
|
*/
|
|
@@ -415,12 +468,90 @@ declare class RootCMSClient {
|
|
|
415
468
|
by?: string;
|
|
416
469
|
metadata?: any;
|
|
417
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;
|
|
418
550
|
}
|
|
419
551
|
/**
|
|
420
552
|
* Returns true if the `data` is a rich text data object.
|
|
421
553
|
*/
|
|
422
554
|
declare function isRichTextData(data: any): boolean;
|
|
423
|
-
declare function getCmsPlugin(rootConfig: RootConfig): CMSPlugin;
|
|
424
555
|
/**
|
|
425
556
|
* Walks the data tree and converts any array of objects into "array objects"
|
|
426
557
|
* for storage in firestore.
|
|
@@ -476,7 +607,7 @@ declare function unmarshalArray(arrObject: ArrayObject): any[];
|
|
|
476
607
|
* }
|
|
477
608
|
* ```
|
|
478
609
|
*/
|
|
479
|
-
declare function translationsForLocale(translationsMap: TranslationsMap, locale: string): LocaleTranslations;
|
|
610
|
+
declare function translationsForLocale(translationsMap: TranslationsMap, locale: string | string[]): LocaleTranslations;
|
|
480
611
|
/**
|
|
481
612
|
* Parses a docId (e.g. `Pages/foo`) and returns the `collection` and `slug`.
|
|
482
613
|
*/
|
|
@@ -485,4 +616,4 @@ declare function parseDocId(docId: string): {
|
|
|
485
616
|
slug: string;
|
|
486
617
|
};
|
|
487
618
|
|
|
488
|
-
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';
|