@dosgato/templating 0.0.117 → 0.0.119
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/component.d.ts +5 -0
- package/dist/uitemplate.d.ts +64 -0
- package/package.json +1 -1
package/dist/component.d.ts
CHANGED
|
@@ -580,6 +580,11 @@ export declare abstract class Page<DataType extends PageData = any, FetchedType
|
|
|
580
580
|
* at any time during fetch, context, or render, to set an HTTP header on the response
|
|
581
581
|
*/
|
|
582
582
|
addHeader: (key: string, value: string | undefined) => void;
|
|
583
|
+
/**
|
|
584
|
+
* This method will be provided to page templates by the render server. You may call it to set
|
|
585
|
+
* the HTTP response status at any time during the fetch, context, or render.
|
|
586
|
+
*/
|
|
587
|
+
setStatus: (statusCode: number) => void;
|
|
583
588
|
/**
|
|
584
589
|
* URL for the currently rendering page
|
|
585
590
|
*
|
package/dist/uitemplate.d.ts
CHANGED
|
@@ -121,4 +121,68 @@ export interface DialogPageProp {
|
|
|
121
121
|
* API.
|
|
122
122
|
*/
|
|
123
123
|
export declare function dialogQuery<T = any>(query: string, variables?: any): Promise<T>;
|
|
124
|
+
/**
|
|
125
|
+
* A type for the config object that should be exported from a CMS instance's admin/local/index.js
|
|
126
|
+
* to configure how that instance should work.
|
|
127
|
+
*/
|
|
128
|
+
export interface UIConfig {
|
|
129
|
+
templates: UITemplate[];
|
|
130
|
+
login: {
|
|
131
|
+
/**
|
|
132
|
+
* What to do when we get a 401 from the API. Generally we'll want to redirect
|
|
133
|
+
* to our SSO login page. Since we use sveltekit we redirect by throwing:
|
|
134
|
+
* `throw redirect(302, 'my.sso.org/login')`
|
|
135
|
+
*/
|
|
136
|
+
handleUnauthorized: (environmentConfig: any) => void;
|
|
137
|
+
/**
|
|
138
|
+
* When our SSO finishes and redirects the user back to us, we need to extract the token so
|
|
139
|
+
* that we can save it in session storage.
|
|
140
|
+
*
|
|
141
|
+
* Many SSO services don't provide a token your API/render services can permanently accept. In that
|
|
142
|
+
* case you need to create a login endpoint on the API or render service that can generate a token
|
|
143
|
+
* your API and render service will accept and then redirect back to /.admin where this function can
|
|
144
|
+
* retrieve the token.
|
|
145
|
+
*
|
|
146
|
+
* If this function is left undefined, we'll assume that you want cookies instead and don't want
|
|
147
|
+
* to use sessionStorage. Note that BOTH the API and render services need to be sent the cookie,
|
|
148
|
+
* so you need to redirect through them both to get the cookie created before finally redirecting
|
|
149
|
+
* back to /.admin
|
|
150
|
+
*/
|
|
151
|
+
getToken?: (info: {
|
|
152
|
+
url: URL;
|
|
153
|
+
}) => string | undefined;
|
|
154
|
+
/**
|
|
155
|
+
* If your SSO requires a single return URL, you may need to do more work to return the user to
|
|
156
|
+
* where they were before they got a 401 that triggered a login. Maybe your SSO provides a passthrough
|
|
157
|
+
* parameter for you to use; otherwise you can set the return url in sessionStorage or a cookie.
|
|
158
|
+
*
|
|
159
|
+
* Whatever strategy you pick, it begins in handleUnauthorized. You'll save your current location in that
|
|
160
|
+
* function (by whatever means you choose), and then after the user has been redirected around a bit, you'll
|
|
161
|
+
* read what you saved in this function and return the URL. dosgato-admin will redirect for you.
|
|
162
|
+
*/
|
|
163
|
+
getRedirect?: (info: {
|
|
164
|
+
url: URL;
|
|
165
|
+
}) => string | undefined;
|
|
166
|
+
/**
|
|
167
|
+
* If you do not provide a logout function, we will simply destroy the token in sessionStorage and
|
|
168
|
+
* refresh the page, which should trigger a 401 from the API, which should in turn trigger a redirect
|
|
169
|
+
* to the login page.
|
|
170
|
+
*
|
|
171
|
+
* If you use cookies or if your SSO provider uses cookies and would immediately log the user back in,
|
|
172
|
+
* then you need to visit a logout endpoint instead of refreshing.
|
|
173
|
+
*
|
|
174
|
+
* Since we use sveltekit, you trigger navigation with `goto('my.sso.org/logout')`
|
|
175
|
+
*/
|
|
176
|
+
logout?: (environmentConfig: any, token: string) => void;
|
|
177
|
+
};
|
|
178
|
+
/**
|
|
179
|
+
* Optional CMS logo to be placed in the top left of the admin UI.
|
|
180
|
+
*/
|
|
181
|
+
logo?: IconOrSVG;
|
|
182
|
+
/**
|
|
183
|
+
* If you would like to collect more information about assets from editors, you may provide a dialog
|
|
184
|
+
* here. The data collected will be available when you retrieve assets.
|
|
185
|
+
*/
|
|
186
|
+
assetMetaDialog?: UITemplate['dialog'];
|
|
187
|
+
}
|
|
124
188
|
export {};
|