@blinkk/root-cms 1.3.12 → 2.0.0-rc.1

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/core.d.ts CHANGED
@@ -1,11 +1,86 @@
1
- import { L as LoadTranslationsOptions, T as TranslationsMap, a as LocaleTranslations } from './client-98Le1XxF.js';
2
- export { A as Action, p as ArrayObject, 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, R as Release, k as RootCMSClient, f as SaveDraftOptions, S as SetDocOptions, i as Translation, 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-98Le1XxF.js';
3
- import { RootConfig } from '@blinkk/root';
1
+ import { R as RootCMSClient, B as BatchRequest, L as LoadTranslationsOptions, T as TranslationsMap, a as LocaleTranslations } from './client-AKOLkEwt.js';
2
+ export { A as Action, v as ArrayObject, 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 Release, h as SaveDraftOptions, S as SetDocOptions, k as Translation, b as TranslationsDoc, 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-AKOLkEwt.js';
3
+ import { Request, Response, GetStaticPaths, GetStaticProps, RootConfig } from '@blinkk/root';
4
4
  import { Query } from 'firebase-admin/firestore';
5
5
  export { s as schema } from './schema-ix967Ud0.js';
6
6
  import 'firebase-admin/app';
7
7
  import 'preact';
8
8
 
9
+ type CMSRequest = Request & {
10
+ cmsClient: RootCMSClient;
11
+ };
12
+ interface CMSRouteContext {
13
+ /** HTTP request object. Only available in SSR mode. */
14
+ req?: CMSRequest;
15
+ slug: string;
16
+ mode: 'draft' | 'published';
17
+ cmsClient: RootCMSClient;
18
+ }
19
+ interface CMSRouteOptions {
20
+ /**
21
+ * Collection mapped to the route.
22
+ */
23
+ collection: string;
24
+ /**
25
+ * Route param name used for the slug. Used for dynamic routes, e.g.
26
+ * `[...slug].tsx`. Defaults to "slug".
27
+ */
28
+ slugParam?: string;
29
+ /**
30
+ * Slug to use for the route. Used for non-dynamic, single-document routes.
31
+ */
32
+ slug?: string;
33
+ /**
34
+ * Hook that allows callers to modify the Root CMS `BatchRequest` object. If a
35
+ * new `BatchRequest` is returned, it will replace the default one created by
36
+ * `cmsRoute()`.
37
+ */
38
+ preRequestHook?: (batchRequest: BatchRequest, context: CMSRouteContext) => void | BatchRequest;
39
+ /**
40
+ * Callback function that returns a map of Promises that contain fetched data.
41
+ * Once the promise is resolved, the values are injected into page's props
42
+ * for rendering.
43
+ */
44
+ fetchData?: (context: CMSRouteContext) => Record<string, Promise<any>>;
45
+ /**
46
+ * Hook for amending any props values before being passed to the page
47
+ * component.
48
+ */
49
+ preRenderHook?: (props: any, context: CMSRouteContext) => any | Promise<any>;
50
+ /**
51
+ * Hook for setting any response headers.
52
+ */
53
+ setResponseHeaders?: (req: Request, res: Response) => void;
54
+ /**
55
+ * Sets Cache-Control header to `private`.
56
+ */
57
+ disableCacheControl?: boolean;
58
+ /**
59
+ * Enables SSG mode for sites that serve on SCS or other static servers.
60
+ */
61
+ enableSSG?: boolean;
62
+ }
63
+ interface CMSDoc {
64
+ id: string;
65
+ slug: string;
66
+ sys?: {
67
+ locales?: string[];
68
+ };
69
+ }
70
+ /**
71
+ * Utility for generating SSR and SSG handlers in a Root route file.
72
+ */
73
+ declare function cmsRoute(options: CMSRouteOptions): {
74
+ getStaticPaths: GetStaticPaths | null;
75
+ getStaticProps: GetStaticProps | null;
76
+ handle: (req: CMSRequest, res: Response) => Promise<void>;
77
+ };
78
+ declare function resolvePromisesMap(promisesMap: Record<string, Promise<any>>): Promise<Record<string, any>>;
79
+ /**
80
+ * Issues an HTTP redirect, preserving any query params from the original req.
81
+ */
82
+ declare function redirectWithQuery(req: Request, res: Response, redirectCode: number, redirectPath: string): void;
83
+
9
84
  /** @deprecated Use client.ts instead. */
10
85
 
11
86
  /**
@@ -51,4 +126,4 @@ declare function loadTranslations(rootConfig: RootConfig, options?: LoadTranslat
51
126
  */
52
127
  declare function loadTranslationsForLocale(rootConfig: RootConfig, locale: string, options?: LoadTranslationsOptions): Promise<LocaleTranslations>;
53
128
 
54
- export { LoadTranslationsOptions, LocaleTranslations, TranslationsMap, getDoc, listDocs, loadTranslations, loadTranslationsForLocale, numDocs, publishScheduledDocs };
129
+ export { BatchRequest, type CMSDoc, type CMSRequest, type CMSRouteContext, type CMSRouteOptions, LoadTranslationsOptions, LocaleTranslations, RootCMSClient, TranslationsMap, cmsRoute, getDoc, listDocs, loadTranslations, loadTranslationsForLocale, numDocs, publishScheduledDocs, redirectWithQuery, resolvePromisesMap };