@opencloudcms/client 0.0.0-stage → 0.1.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/LICENSE +21 -0
- package/README.md +337 -2
- package/dist/cjs/actions/runner.js +434 -0
- package/dist/cjs/core/account.js +22 -0
- package/dist/cjs/core/actions.js +56 -0
- package/dist/cjs/core/auth.js +73 -0
- package/dist/cjs/core/client.js +160 -0
- package/dist/cjs/core/content.js +89 -0
- package/dist/cjs/core/default-client.js +27 -0
- package/dist/cjs/core/errors.js +53 -0
- package/dist/cjs/core/typed.js +22 -0
- package/dist/cjs/core/types.js +2 -0
- package/dist/cjs/core/utils.js +64 -0
- package/dist/cjs/index.js +37 -0
- package/dist/cjs/next/loopback.js +12 -0
- package/dist/cjs/next/server.js +99 -0
- package/dist/cjs/next/stubs.js +10 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/react/provider.js +162 -0
- package/dist/cjs/react/stubs.js +13 -0
- package/dist/cjs/server.js +38 -0
- package/dist/esm/actions/runner.d.ts +92 -0
- package/dist/esm/actions/runner.js +428 -0
- package/dist/esm/core/account.d.ts +20 -0
- package/dist/esm/core/account.js +19 -0
- package/dist/esm/core/actions.d.ts +81 -0
- package/dist/esm/core/actions.js +51 -0
- package/dist/esm/core/auth.d.ts +61 -0
- package/dist/esm/core/auth.js +69 -0
- package/dist/esm/core/client.d.ts +2 -0
- package/dist/esm/core/client.js +157 -0
- package/dist/esm/core/content.d.ts +5 -0
- package/dist/esm/core/content.js +85 -0
- package/dist/esm/core/default-client.d.ts +9 -0
- package/dist/esm/core/default-client.js +23 -0
- package/dist/esm/core/errors.d.ts +13 -0
- package/dist/esm/core/errors.js +47 -0
- package/dist/esm/core/typed.d.ts +31 -0
- package/dist/esm/core/typed.js +19 -0
- package/dist/esm/core/types.d.ts +90 -0
- package/dist/esm/core/types.js +1 -0
- package/dist/esm/core/utils.d.ts +27 -0
- package/dist/esm/core/utils.js +56 -0
- package/dist/esm/index.d.ts +20 -0
- package/dist/esm/index.js +12 -0
- package/dist/esm/next/loopback.d.ts +6 -0
- package/dist/esm/next/loopback.js +9 -0
- package/dist/esm/next/server.d.ts +19 -0
- package/dist/esm/next/server.js +60 -0
- package/dist/esm/next/stubs.d.ts +5 -0
- package/dist/esm/next/stubs.js +7 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/react/provider.d.ts +38 -0
- package/dist/esm/react/provider.js +153 -0
- package/dist/esm/react/stubs.d.ts +6 -0
- package/dist/esm/react/stubs.js +10 -0
- package/dist/esm/server.d.ts +21 -0
- package/dist/esm/server.js +13 -0
- package/package.json +61 -3
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
'use client';
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.OpenCloudCmsProvider = OpenCloudCmsProvider;
|
|
5
|
+
exports.useClient = useClient;
|
|
6
|
+
exports.useCustomer = useCustomer;
|
|
7
|
+
exports.useSignIn = useSignIn;
|
|
8
|
+
exports.useSignOut = useSignOut;
|
|
9
|
+
exports.useActionRunner = useActionRunner;
|
|
10
|
+
exports.useAction = useAction;
|
|
11
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
12
|
+
const react_1 = require("react");
|
|
13
|
+
const runner_js_1 = require("../actions/runner.js");
|
|
14
|
+
const client_js_1 = require("../core/client.js");
|
|
15
|
+
const StableContext = (0, react_1.createContext)(null);
|
|
16
|
+
const CustomerContext = (0, react_1.createContext)(null);
|
|
17
|
+
function OpenCloudCmsProvider(props) {
|
|
18
|
+
const { children, initialCustomer } = props;
|
|
19
|
+
const clientRef = (0, react_1.useRef)(null);
|
|
20
|
+
const client = props.client ?? (clientRef.current ??= (0, client_js_1.createClient)());
|
|
21
|
+
const hasInitial = initialCustomer !== undefined;
|
|
22
|
+
const [customer, setCustomer] = (0, react_1.useState)(hasInitial ? initialCustomer : null);
|
|
23
|
+
const [loading, setLoading] = (0, react_1.useState)(!hasInitial);
|
|
24
|
+
const started = (0, react_1.useRef)(false);
|
|
25
|
+
const live = (0, react_1.useRef)(true);
|
|
26
|
+
const seq = (0, react_1.useRef)(0);
|
|
27
|
+
// For the action runner's auth gate: the last known customer, and the me() in flight.
|
|
28
|
+
const known = (0, react_1.useRef)({ loaded: hasInitial, customer: initialCustomer ?? null });
|
|
29
|
+
const inflight = (0, react_1.useRef)(null);
|
|
30
|
+
const refresh = (0, react_1.useCallback)(async () => {
|
|
31
|
+
const mine = ++seq.current;
|
|
32
|
+
const p = (async () => {
|
|
33
|
+
const next = await client.auth.me();
|
|
34
|
+
if (mine === seq.current)
|
|
35
|
+
known.current = { loaded: true, customer: next };
|
|
36
|
+
if (live.current && mine === seq.current) {
|
|
37
|
+
setCustomer(next);
|
|
38
|
+
setLoading(false);
|
|
39
|
+
}
|
|
40
|
+
})();
|
|
41
|
+
inflight.current = p;
|
|
42
|
+
return p;
|
|
43
|
+
}, [client]);
|
|
44
|
+
(0, react_1.useEffect)(() => {
|
|
45
|
+
live.current = true;
|
|
46
|
+
if (!hasInitial && !started.current) {
|
|
47
|
+
started.current = true; // one me() per provider mount, shared by every consumer
|
|
48
|
+
refresh().catch(() => {
|
|
49
|
+
if (live.current)
|
|
50
|
+
setLoading(false);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
return () => {
|
|
54
|
+
live.current = false;
|
|
55
|
+
};
|
|
56
|
+
}, [hasInitial, refresh]);
|
|
57
|
+
// Latest props, read lazily by the runner: inline `actions` / `ui` don't rebuild it or change the context.
|
|
58
|
+
const actionsRef = (0, react_1.useRef)(props.actions ?? []);
|
|
59
|
+
actionsRef.current = props.actions ?? [];
|
|
60
|
+
const uiRef = (0, react_1.useRef)(props.ui ?? {});
|
|
61
|
+
uiRef.current = props.ui ?? {};
|
|
62
|
+
const signInPath = props.signInPath ?? '/account/login';
|
|
63
|
+
const stable = (0, react_1.useMemo)(() => {
|
|
64
|
+
const runner = new runner_js_1.ActionRunner({
|
|
65
|
+
client,
|
|
66
|
+
get actions() {
|
|
67
|
+
return actionsRef.current;
|
|
68
|
+
},
|
|
69
|
+
signInPath,
|
|
70
|
+
get ui() {
|
|
71
|
+
return uiRef.current;
|
|
72
|
+
},
|
|
73
|
+
// Same state as useCustomer: waits for the mount-time me() (or starts one); throws when it is unknown.
|
|
74
|
+
async getCustomer() {
|
|
75
|
+
if (!known.current.loaded)
|
|
76
|
+
await (inflight.current ?? refresh());
|
|
77
|
+
if (!known.current.loaded)
|
|
78
|
+
throw new Error('customer unknown');
|
|
79
|
+
return known.current.customer;
|
|
80
|
+
},
|
|
81
|
+
onAuthChange: () => refresh(),
|
|
82
|
+
});
|
|
83
|
+
return { client, signInPath, runner };
|
|
84
|
+
}, [client, signInPath, refresh]);
|
|
85
|
+
const cust = (0, react_1.useMemo)(() => ({ customer, loading, refresh }), [customer, loading, refresh]);
|
|
86
|
+
return ((0, jsx_runtime_1.jsx)(StableContext.Provider, { value: stable, children: (0, jsx_runtime_1.jsx)(CustomerContext.Provider, { value: cust, children: children }) }));
|
|
87
|
+
}
|
|
88
|
+
const MISSING = 'OpenCloudCmsProvider is missing: wrap your app in <OpenCloudCmsProvider>';
|
|
89
|
+
function useStable() {
|
|
90
|
+
const ctx = (0, react_1.useContext)(StableContext);
|
|
91
|
+
if (!ctx)
|
|
92
|
+
throw new Error(MISSING);
|
|
93
|
+
return ctx;
|
|
94
|
+
}
|
|
95
|
+
function useCustomerCtx() {
|
|
96
|
+
const ctx = (0, react_1.useContext)(CustomerContext);
|
|
97
|
+
if (!ctx)
|
|
98
|
+
throw new Error(MISSING);
|
|
99
|
+
return ctx;
|
|
100
|
+
}
|
|
101
|
+
function useClient() {
|
|
102
|
+
return useStable().client;
|
|
103
|
+
}
|
|
104
|
+
function useCustomer() {
|
|
105
|
+
return useCustomerCtx();
|
|
106
|
+
}
|
|
107
|
+
function useSignIn() {
|
|
108
|
+
const { client } = useStable();
|
|
109
|
+
return (0, react_1.useCallback)((returnTo) => client.auth.signIn(returnTo), [client]);
|
|
110
|
+
}
|
|
111
|
+
function useSignOut() {
|
|
112
|
+
const { client } = useStable();
|
|
113
|
+
const { refresh } = useCustomerCtx();
|
|
114
|
+
return (0, react_1.useCallback)(async () => {
|
|
115
|
+
const out = await client.auth.signOut({ navigate: false });
|
|
116
|
+
try {
|
|
117
|
+
await refresh();
|
|
118
|
+
}
|
|
119
|
+
finally {
|
|
120
|
+
client.auth.followRedirect(out);
|
|
121
|
+
}
|
|
122
|
+
}, [client, refresh]);
|
|
123
|
+
}
|
|
124
|
+
/** The provider's action runner (used by `core/blocks` triggers). */
|
|
125
|
+
function useActionRunner() {
|
|
126
|
+
return useStable().runner;
|
|
127
|
+
}
|
|
128
|
+
/** Runs action `name` from your own components: same lifecycle, client hooks and events as page triggers. */
|
|
129
|
+
function useAction(name) {
|
|
130
|
+
const runner = useActionRunner();
|
|
131
|
+
const [state, setState] = (0, react_1.useState)({ pending: false, error: null, result: undefined });
|
|
132
|
+
const live = (0, react_1.useRef)(true);
|
|
133
|
+
// One run at a time per hook instance: a second run() while pending gets the same promise (one POST).
|
|
134
|
+
const inflight = (0, react_1.useRef)(null);
|
|
135
|
+
(0, react_1.useEffect)(() => {
|
|
136
|
+
live.current = true;
|
|
137
|
+
return () => {
|
|
138
|
+
live.current = false;
|
|
139
|
+
};
|
|
140
|
+
}, []);
|
|
141
|
+
const run = (0, react_1.useCallback)((req = {}) => {
|
|
142
|
+
if (inflight.current)
|
|
143
|
+
return inflight.current;
|
|
144
|
+
setState((s) => ({ ...s, pending: true }));
|
|
145
|
+
const p = (async () => {
|
|
146
|
+
let out = { ok: false };
|
|
147
|
+
try {
|
|
148
|
+
out = await runner.run(null, { id: req.id, name, params: req.params ?? {}, input: req.input, page: req.page });
|
|
149
|
+
}
|
|
150
|
+
finally {
|
|
151
|
+
inflight.current = null;
|
|
152
|
+
if (live.current) {
|
|
153
|
+
setState((s) => ({ pending: false, error: out.ok ? null : out.error ?? null, result: out.ok ? out.result : s.result }));
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return out;
|
|
157
|
+
})();
|
|
158
|
+
inflight.current = p;
|
|
159
|
+
return p;
|
|
160
|
+
}, [runner, name]);
|
|
161
|
+
return { run, pending: state.pending, error: state.error, result: state.result };
|
|
162
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useActionRunner = exports.useAction = exports.useSignOut = exports.useSignIn = exports.useClient = exports.useCustomer = void 0;
|
|
4
|
+
// react-server build: hooks cannot run in a server component. Importing them is fine; calling one throws.
|
|
5
|
+
const notHere = (name) => (..._args) => {
|
|
6
|
+
throw new Error(`${name} is not available in a server component`);
|
|
7
|
+
};
|
|
8
|
+
exports.useCustomer = notHere('useCustomer');
|
|
9
|
+
exports.useClient = notHere('useClient');
|
|
10
|
+
exports.useSignIn = notHere('useSignIn');
|
|
11
|
+
exports.useSignOut = notHere('useSignOut');
|
|
12
|
+
exports.useAction = notHere('useAction');
|
|
13
|
+
exports.useActionRunner = notHere('useActionRunner');
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OpenCloudCmsProvider = exports.useActionRunner = exports.useAction = exports.useSignOut = exports.useSignIn = exports.useClient = exports.useCustomer = exports.defineActionClient = exports.ACTION_EVENT = exports.ActionRunner = exports.requireCustomer = exports.getCustomer = exports.publicClient = exports.serverClient = exports.loopbackUrl = exports.utils = exports.errorMessage = exports.isApiError = exports.ApiError = exports.setDefaultClientFactory = exports.createContentApi = exports.createClient = void 0;
|
|
4
|
+
// `react-server` build: no React context or hooks evaluated here. Real Next server helpers; hooks are stubs that
|
|
5
|
+
// throw when called. The Provider is re-exported from its 'use client' file (a client reference in RSC).
|
|
6
|
+
var client_js_1 = require("./core/client.js");
|
|
7
|
+
Object.defineProperty(exports, "createClient", { enumerable: true, get: function () { return client_js_1.createClient; } });
|
|
8
|
+
var typed_js_1 = require("./core/typed.js");
|
|
9
|
+
Object.defineProperty(exports, "createContentApi", { enumerable: true, get: function () { return typed_js_1.createContentApi; } });
|
|
10
|
+
var default_client_js_1 = require("./core/default-client.js");
|
|
11
|
+
Object.defineProperty(exports, "setDefaultClientFactory", { enumerable: true, get: function () { return default_client_js_1.setDefaultClientFactory; } });
|
|
12
|
+
var errors_js_1 = require("./core/errors.js");
|
|
13
|
+
Object.defineProperty(exports, "ApiError", { enumerable: true, get: function () { return errors_js_1.ApiError; } });
|
|
14
|
+
Object.defineProperty(exports, "isApiError", { enumerable: true, get: function () { return errors_js_1.isApiError; } });
|
|
15
|
+
Object.defineProperty(exports, "errorMessage", { enumerable: true, get: function () { return errors_js_1.errorMessage; } });
|
|
16
|
+
var utils_js_1 = require("./core/utils.js");
|
|
17
|
+
Object.defineProperty(exports, "utils", { enumerable: true, get: function () { return utils_js_1.utils; } });
|
|
18
|
+
var loopback_js_1 = require("./next/loopback.js");
|
|
19
|
+
Object.defineProperty(exports, "loopbackUrl", { enumerable: true, get: function () { return loopback_js_1.loopbackUrl; } });
|
|
20
|
+
var server_js_1 = require("./next/server.js");
|
|
21
|
+
Object.defineProperty(exports, "serverClient", { enumerable: true, get: function () { return server_js_1.serverClient; } });
|
|
22
|
+
Object.defineProperty(exports, "publicClient", { enumerable: true, get: function () { return server_js_1.publicClient; } });
|
|
23
|
+
Object.defineProperty(exports, "getCustomer", { enumerable: true, get: function () { return server_js_1.getCustomer; } });
|
|
24
|
+
Object.defineProperty(exports, "requireCustomer", { enumerable: true, get: function () { return server_js_1.requireCustomer; } });
|
|
25
|
+
var runner_js_1 = require("./actions/runner.js");
|
|
26
|
+
Object.defineProperty(exports, "ActionRunner", { enumerable: true, get: function () { return runner_js_1.ActionRunner; } });
|
|
27
|
+
Object.defineProperty(exports, "ACTION_EVENT", { enumerable: true, get: function () { return runner_js_1.ACTION_EVENT; } });
|
|
28
|
+
var actions_js_1 = require("./core/actions.js");
|
|
29
|
+
Object.defineProperty(exports, "defineActionClient", { enumerable: true, get: function () { return actions_js_1.defineActionClient; } });
|
|
30
|
+
var stubs_js_1 = require("./react/stubs.js");
|
|
31
|
+
Object.defineProperty(exports, "useCustomer", { enumerable: true, get: function () { return stubs_js_1.useCustomer; } });
|
|
32
|
+
Object.defineProperty(exports, "useClient", { enumerable: true, get: function () { return stubs_js_1.useClient; } });
|
|
33
|
+
Object.defineProperty(exports, "useSignIn", { enumerable: true, get: function () { return stubs_js_1.useSignIn; } });
|
|
34
|
+
Object.defineProperty(exports, "useSignOut", { enumerable: true, get: function () { return stubs_js_1.useSignOut; } });
|
|
35
|
+
Object.defineProperty(exports, "useAction", { enumerable: true, get: function () { return stubs_js_1.useAction; } });
|
|
36
|
+
Object.defineProperty(exports, "useActionRunner", { enumerable: true, get: function () { return stubs_js_1.useActionRunner; } });
|
|
37
|
+
var provider_js_1 = require("./react/provider.js");
|
|
38
|
+
Object.defineProperty(exports, "OpenCloudCmsProvider", { enumerable: true, get: function () { return provider_js_1.OpenCloudCmsProvider; } });
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { type Customer } from '../core/auth.js';
|
|
2
|
+
import { ApiError } from '../core/errors.js';
|
|
3
|
+
import { type ActionClientDefinition, type ActionRequest } from '../core/actions.js';
|
|
4
|
+
import type { ApiIssue, Client } from '../core/types.js';
|
|
5
|
+
/** DOM event dispatched (bubbling) on the trigger for every phase; on `document` for runs without a trigger. */
|
|
6
|
+
export declare const ACTION_EVENT = "opencloudcms:action";
|
|
7
|
+
export type ActionPhase = 'trigger' | 'pending' | 'success' | 'error' | 'settled';
|
|
8
|
+
export interface ActionEventDetail {
|
|
9
|
+
name: string;
|
|
10
|
+
phase: ActionPhase;
|
|
11
|
+
ok?: boolean;
|
|
12
|
+
code?: string;
|
|
13
|
+
}
|
|
14
|
+
/** Page-level UI the runner uses. Every member is optional: a minimal default is used for each missing one. */
|
|
15
|
+
export interface UiAdapter {
|
|
16
|
+
/** Default: a DOM toast (`.ocms-toasts > .ocms-toast[data-tone]`), themeable with CSS. */
|
|
17
|
+
toast?(message: string, tone?: 'success' | 'error' | 'info'): void;
|
|
18
|
+
/** Default: `window.confirm`. */
|
|
19
|
+
confirm?(message: string): boolean | Promise<boolean>;
|
|
20
|
+
/** Default: no-op (`core/blocks` registers its overlay store with `runner.setUi`). */
|
|
21
|
+
openOverlay?(name: string): void;
|
|
22
|
+
closeOverlay?(name?: string): void;
|
|
23
|
+
/** Receives an already-sanitized same-site target. Default: `location.assign`. */
|
|
24
|
+
navigate?(path: string): void;
|
|
25
|
+
/** Default: `location.reload()`. */
|
|
26
|
+
refresh?(): void;
|
|
27
|
+
}
|
|
28
|
+
/** `actions` and `ui` are read on every run (the provider passes getters over refs, so new props apply at once). */
|
|
29
|
+
export interface ActionRunnerOptions {
|
|
30
|
+
client: Client;
|
|
31
|
+
actions: ActionClientDefinition[];
|
|
32
|
+
/** Storefront sign-in page; signed-out customers go to `<signInPath>?returnTo=<current path>`. */
|
|
33
|
+
signInPath: string;
|
|
34
|
+
ui: UiAdapter;
|
|
35
|
+
/** The signed-in customer, `null` when signed out. A throw means "unknown": the server decides (it answers 401). */
|
|
36
|
+
getCustomer(): Promise<Customer | null>;
|
|
37
|
+
/** Called after the built-in `sign-out` ends the session (the provider refreshes its customer). */
|
|
38
|
+
onAuthChange(): void | Promise<void>;
|
|
39
|
+
}
|
|
40
|
+
export type ActionRunInput = Omit<ActionRequest, 'id'> & {
|
|
41
|
+
id?: string;
|
|
42
|
+
form?: HTMLFormElement;
|
|
43
|
+
/**
|
|
44
|
+
* Draft preview (page-actions goal 11): only actions whose manifest entry sets `previewSafe` (and the client-only
|
|
45
|
+
* built-ins `sign-in`, `navigate-back`) run; any other shows a toast and sends nothing. Never sent to the server.
|
|
46
|
+
*/
|
|
47
|
+
preview?: boolean;
|
|
48
|
+
};
|
|
49
|
+
export interface ActionRunResult {
|
|
50
|
+
ok: boolean;
|
|
51
|
+
result?: unknown;
|
|
52
|
+
error?: ApiError;
|
|
53
|
+
}
|
|
54
|
+
export declare const BUILTIN_ACTIONS: readonly string[];
|
|
55
|
+
export declare class ActionRunner {
|
|
56
|
+
private readonly o;
|
|
57
|
+
private overrides;
|
|
58
|
+
/** Holders of runner-level draft preview (`setPreview`): preview is on while any holds it. */
|
|
59
|
+
private readonly previewHolders;
|
|
60
|
+
constructor(o: ActionRunnerOptions);
|
|
61
|
+
/** Hooks of `name` from the current `actions` (the last definition wins). */
|
|
62
|
+
private hooksOf;
|
|
63
|
+
/** Layer UI handlers over the constructor's adapter (e.g. the page's overlay store). Returns an undo. */
|
|
64
|
+
setUi(ui: Partial<UiAdapter>): () => void;
|
|
65
|
+
/**
|
|
66
|
+
* Runner-level draft preview (page-actions goal 11): while on, every run is a preview run, also `useAction` in custom
|
|
67
|
+
* code that never passes `preview`. Held per `key` (default: the runner): on while any key holds it, idempotent per
|
|
68
|
+
* key. Returns an undo that releases `key`. `core/blocks`' `ActionScope` holds it on a draft preview page.
|
|
69
|
+
*/
|
|
70
|
+
setPreview(on: boolean, key?: object): () => void;
|
|
71
|
+
isPreview(): boolean;
|
|
72
|
+
/** Runs the whole lifecycle (goal 8). Never throws; `{ ok: false }` without `error` means ignored or cancelled. */
|
|
73
|
+
run(trigger: HTMLElement | null, input: ActionRunInput): Promise<ActionRunResult>;
|
|
74
|
+
private execute;
|
|
75
|
+
/** Draft preview: whether `name` may run for real. An unreadable manifest blocks it (fail closed). */
|
|
76
|
+
private previewSafe;
|
|
77
|
+
/** True only when the manifest says `requireCustomer` and the customer is known to be signed out. */
|
|
78
|
+
private signedOutButRequired;
|
|
79
|
+
/**
|
|
80
|
+
* The page's `sign-in` overlay when it has one (and an overlay handler), else `<path>?returnTo=<current path>` where
|
|
81
|
+
* `path` is the server's `signIn` (its configured loginPath, from a 401) when it is a safe local path, else `signInPath`.
|
|
82
|
+
*/
|
|
83
|
+
private toSignIn;
|
|
84
|
+
/** The UiAdapter's `navigate`, else `location.assign`. `to` must already be safe. */
|
|
85
|
+
private go;
|
|
86
|
+
private adapter;
|
|
87
|
+
private makeUi;
|
|
88
|
+
}
|
|
89
|
+
/** Undoes `setFieldErrors` (only what the runner set: an author's own `aria-invalid` is left alone). */
|
|
90
|
+
export declare function clearFieldErrors(form: HTMLFormElement): void;
|
|
91
|
+
/** `['input', <name>, ...]` issues → `aria-invalid` on the controls named `<name>` and the first message in `[data-ocms-error-for]`. */
|
|
92
|
+
export declare function setFieldErrors(form: HTMLFormElement, issues: ApiIssue[]): void;
|