strapi-plugin-hubspot 0.4.2 → 0.6.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/CHANGELOG.md +48 -0
- package/README.md +116 -4
- package/dist/_chunks/Forms-BF4_zA-m.js +1007 -0
- package/dist/_chunks/Forms-CW1KFO9U.mjs +989 -0
- package/dist/_chunks/{HubspotObjectInput-DutelVp6.mjs → HubspotObjectInput-CpxeM2J0.mjs} +4 -16
- package/dist/_chunks/{HubspotObjectInput-Br2jTFkG.js → HubspotObjectInput-hjAYWtaU.js} +4 -16
- package/dist/_chunks/HubspotPropertyInput-C-52Lu24.mjs +227 -0
- package/dist/_chunks/HubspotPropertyInput-OSeIBaRC.js +245 -0
- package/dist/_chunks/Settings-2V7TH5CX.mjs +321 -0
- package/dist/_chunks/Settings-DcA9M5Tw.js +339 -0
- package/dist/_chunks/en-CJ9wYHgN.mjs +197 -0
- package/dist/_chunks/en-C_-N8cjv.js +197 -0
- package/dist/_chunks/fr-BHObPoUp.js +197 -0
- package/dist/_chunks/fr-DttDn-2Y.mjs +197 -0
- package/dist/_chunks/{Settings-CQsB0B2T.mjs → index-C1UJXE_o.mjs} +576 -317
- package/dist/_chunks/{index-BUlB1rK9.js → index-CMzg-x5i.js} +12 -4
- package/dist/_chunks/{Settings-CvbKVl-t.js → index-Dgbid2LK.js} +580 -322
- package/dist/_chunks/{index-CKoBcX1T.mjs → index-DkGOTp8p.mjs} +12 -4
- package/dist/_chunks/{objectLabels-dM4o67Fz.mjs → objectLabels-D9UEuOGr.mjs} +1 -1
- package/dist/_chunks/{objectLabels-B76t8qqg.js → objectLabels-Th7aYW-B.js} +1 -1
- package/dist/_chunks/useHubspotSchema-Bgrgg8Mt.js +75 -0
- package/dist/_chunks/useHubspotSchema-DQkQcA_V.mjs +58 -0
- package/dist/admin/index.js +2 -1
- package/dist/admin/index.mjs +2 -1
- package/dist/admin/src/builder/ConditionEditor.d.ts +17 -0
- package/dist/admin/src/builder/FieldPanel.d.ts +16 -0
- package/dist/admin/src/builder/types.d.ts +90 -0
- package/dist/admin/src/index.d.ts +1 -0
- package/dist/admin/src/pages/FormEditor.d.ts +9 -0
- package/dist/admin/src/pages/Forms.d.ts +4 -0
- package/dist/admin/src/pages/FormsList.d.ts +8 -0
- package/dist/admin/src/useHubspotSchema.d.ts +28 -0
- package/dist/server/index.js +880 -5
- package/dist/server/index.mjs +880 -5
- package/dist/server/src/__tests__/conditions.test.d.ts +1 -0
- package/dist/server/src/__tests__/forms.test.d.ts +1 -0
- package/dist/server/src/__tests__/formsSubmit.test.d.ts +1 -0
- package/dist/server/src/__tests__/importLegacy.test.d.ts +1 -0
- package/dist/server/src/conditions.d.ts +88 -0
- package/dist/server/src/content-types.d.ts +161 -9
- package/dist/server/src/forms.d.ts +81 -0
- package/dist/server/src/formsAdmin.d.ts +39 -0
- package/dist/server/src/importLegacy.d.ts +25 -0
- package/dist/server/src/index.d.ts +214 -16
- package/dist/shared/types.d.ts +103 -0
- package/dist/shared/types.js +2 -0
- package/dist/shared/types.mjs +2 -0
- package/package.json +23 -6
- package/dist/_chunks/HubspotPropertyInput-CK6Yj9rC.mjs +0 -177
- package/dist/_chunks/HubspotPropertyInput-DIPDPRXJ.js +0 -195
- package/dist/_chunks/en-D4ueeUcJ.mjs +0 -82
- package/dist/_chunks/en-PBG7-vMR.js +0 -82
- package/dist/_chunks/fr-DL4wdV8I.js +0 -82
- package/dist/_chunks/fr-DYnxVmIO.mjs +0 -82
|
@@ -1,9 +1,4 @@
|
|
|
1
|
-
import { jsxs, jsx } from "react/jsx-runtime";
|
|
2
1
|
import * as React from "react";
|
|
3
|
-
import { u as useIntl, o as objectLabel } from "./objectLabels-dM4o67Fz.mjs";
|
|
4
|
-
import { Flex, Divider, Typography, Button, Box, Link as Link$1, Badge, Loader, Field } from "@strapi/design-system";
|
|
5
|
-
import { useFetchClient } from "@strapi/strapi/admin";
|
|
6
|
-
import { g as getTranslation, P as PLUGIN_ID } from "./index-CKoBcX1T.mjs";
|
|
7
2
|
import "react-dom";
|
|
8
3
|
/**
|
|
9
4
|
* @remix-run/router v1.23.3
|
|
@@ -80,6 +75,166 @@ var ResultType;
|
|
|
80
75
|
ResultType2["redirect"] = "redirect";
|
|
81
76
|
ResultType2["error"] = "error";
|
|
82
77
|
})(ResultType || (ResultType = {}));
|
|
78
|
+
function matchRoutes(routes, locationArg, basename) {
|
|
79
|
+
if (basename === void 0) {
|
|
80
|
+
basename = "/";
|
|
81
|
+
}
|
|
82
|
+
return matchRoutesImpl(routes, locationArg, basename);
|
|
83
|
+
}
|
|
84
|
+
function matchRoutesImpl(routes, locationArg, basename, allowPartial) {
|
|
85
|
+
let location = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
|
|
86
|
+
let pathname = stripBasename(location.pathname || "/", basename);
|
|
87
|
+
if (pathname == null) {
|
|
88
|
+
return null;
|
|
89
|
+
}
|
|
90
|
+
let branches = flattenRoutes(routes);
|
|
91
|
+
rankRouteBranches(branches);
|
|
92
|
+
let matches = null;
|
|
93
|
+
let decoded = decodePath(pathname);
|
|
94
|
+
for (let i = 0; matches == null && i < branches.length; ++i) {
|
|
95
|
+
matches = matchRouteBranch(branches[i], decoded);
|
|
96
|
+
}
|
|
97
|
+
return matches;
|
|
98
|
+
}
|
|
99
|
+
function flattenRoutes(routes, branches, parentsMeta, parentPath) {
|
|
100
|
+
if (branches === void 0) {
|
|
101
|
+
branches = [];
|
|
102
|
+
}
|
|
103
|
+
if (parentsMeta === void 0) {
|
|
104
|
+
parentsMeta = [];
|
|
105
|
+
}
|
|
106
|
+
if (parentPath === void 0) {
|
|
107
|
+
parentPath = "";
|
|
108
|
+
}
|
|
109
|
+
let flattenRoute = (route, index, relativePath) => {
|
|
110
|
+
let meta = {
|
|
111
|
+
relativePath: relativePath === void 0 ? route.path || "" : relativePath,
|
|
112
|
+
caseSensitive: route.caseSensitive === true,
|
|
113
|
+
childrenIndex: index,
|
|
114
|
+
route
|
|
115
|
+
};
|
|
116
|
+
if (meta.relativePath.startsWith("/")) {
|
|
117
|
+
invariant(meta.relativePath.startsWith(parentPath), 'Absolute route path "' + meta.relativePath + '" nested under path ' + ('"' + parentPath + '" is not valid. An absolute child route path ') + "must start with the combined path of all its parent routes.");
|
|
118
|
+
meta.relativePath = meta.relativePath.slice(parentPath.length);
|
|
119
|
+
}
|
|
120
|
+
let path = joinPaths([parentPath, meta.relativePath]);
|
|
121
|
+
let routesMeta = parentsMeta.concat(meta);
|
|
122
|
+
if (route.children && route.children.length > 0) {
|
|
123
|
+
invariant(
|
|
124
|
+
// Our types know better, but runtime JS may not!
|
|
125
|
+
// @ts-expect-error
|
|
126
|
+
route.index !== true,
|
|
127
|
+
"Index routes must not have child routes. Please remove " + ('all child routes from route path "' + path + '".')
|
|
128
|
+
);
|
|
129
|
+
flattenRoutes(route.children, branches, routesMeta, path);
|
|
130
|
+
}
|
|
131
|
+
if (route.path == null && !route.index) {
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
branches.push({
|
|
135
|
+
path,
|
|
136
|
+
score: computeScore(path, route.index),
|
|
137
|
+
routesMeta
|
|
138
|
+
});
|
|
139
|
+
};
|
|
140
|
+
routes.forEach((route, index) => {
|
|
141
|
+
var _route$path;
|
|
142
|
+
if (route.path === "" || !((_route$path = route.path) != null && _route$path.includes("?"))) {
|
|
143
|
+
flattenRoute(route, index);
|
|
144
|
+
} else {
|
|
145
|
+
for (let exploded of explodeOptionalSegments(route.path)) {
|
|
146
|
+
flattenRoute(route, index, exploded);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
return branches;
|
|
151
|
+
}
|
|
152
|
+
function explodeOptionalSegments(path) {
|
|
153
|
+
let segments = path.split("/");
|
|
154
|
+
if (segments.length === 0) return [];
|
|
155
|
+
let [first, ...rest] = segments;
|
|
156
|
+
let isOptional = first.endsWith("?");
|
|
157
|
+
let required = first.replace(/\?$/, "");
|
|
158
|
+
if (rest.length === 0) {
|
|
159
|
+
return isOptional ? [required, ""] : [required];
|
|
160
|
+
}
|
|
161
|
+
let restExploded = explodeOptionalSegments(rest.join("/"));
|
|
162
|
+
let result = [];
|
|
163
|
+
result.push(...restExploded.map((subpath) => subpath === "" ? required : [required, subpath].join("/")));
|
|
164
|
+
if (isOptional) {
|
|
165
|
+
result.push(...restExploded);
|
|
166
|
+
}
|
|
167
|
+
return result.map((exploded) => path.startsWith("/") && exploded === "" ? "/" : exploded);
|
|
168
|
+
}
|
|
169
|
+
function rankRouteBranches(branches) {
|
|
170
|
+
branches.sort((a, b) => a.score !== b.score ? b.score - a.score : compareIndexes(a.routesMeta.map((meta) => meta.childrenIndex), b.routesMeta.map((meta) => meta.childrenIndex)));
|
|
171
|
+
}
|
|
172
|
+
const paramRe = /^:[\w-]+$/;
|
|
173
|
+
const dynamicSegmentValue = 3;
|
|
174
|
+
const indexRouteValue = 2;
|
|
175
|
+
const emptySegmentValue = 1;
|
|
176
|
+
const staticSegmentValue = 10;
|
|
177
|
+
const splatPenalty = -2;
|
|
178
|
+
const isSplat = (s) => s === "*";
|
|
179
|
+
function computeScore(path, index) {
|
|
180
|
+
let segments = path.split("/");
|
|
181
|
+
let initialScore = segments.length;
|
|
182
|
+
if (segments.some(isSplat)) {
|
|
183
|
+
initialScore += splatPenalty;
|
|
184
|
+
}
|
|
185
|
+
if (index) {
|
|
186
|
+
initialScore += indexRouteValue;
|
|
187
|
+
}
|
|
188
|
+
return segments.filter((s) => !isSplat(s)).reduce((score, segment) => score + (paramRe.test(segment) ? dynamicSegmentValue : segment === "" ? emptySegmentValue : staticSegmentValue), initialScore);
|
|
189
|
+
}
|
|
190
|
+
function compareIndexes(a, b) {
|
|
191
|
+
let siblings = a.length === b.length && a.slice(0, -1).every((n, i) => n === b[i]);
|
|
192
|
+
return siblings ? (
|
|
193
|
+
// If two routes are siblings, we should try to match the earlier sibling
|
|
194
|
+
// first. This allows people to have fine-grained control over the matching
|
|
195
|
+
// behavior by simply putting routes with identical paths in the order they
|
|
196
|
+
// want them tried.
|
|
197
|
+
a[a.length - 1] - b[b.length - 1]
|
|
198
|
+
) : (
|
|
199
|
+
// Otherwise, it doesn't really make sense to rank non-siblings by index,
|
|
200
|
+
// so they sort equally.
|
|
201
|
+
0
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
function matchRouteBranch(branch, pathname, allowPartial) {
|
|
205
|
+
let {
|
|
206
|
+
routesMeta
|
|
207
|
+
} = branch;
|
|
208
|
+
let matchedParams = {};
|
|
209
|
+
let matchedPathname = "/";
|
|
210
|
+
let matches = [];
|
|
211
|
+
for (let i = 0; i < routesMeta.length; ++i) {
|
|
212
|
+
let meta = routesMeta[i];
|
|
213
|
+
let end = i === routesMeta.length - 1;
|
|
214
|
+
let remainingPathname = matchedPathname === "/" ? pathname : pathname.slice(matchedPathname.length) || "/";
|
|
215
|
+
let match = matchPath({
|
|
216
|
+
path: meta.relativePath,
|
|
217
|
+
caseSensitive: meta.caseSensitive,
|
|
218
|
+
end
|
|
219
|
+
}, remainingPathname);
|
|
220
|
+
let route = meta.route;
|
|
221
|
+
if (!match) {
|
|
222
|
+
return null;
|
|
223
|
+
}
|
|
224
|
+
Object.assign(matchedParams, match.params);
|
|
225
|
+
matches.push({
|
|
226
|
+
// TODO: Can this as be avoided?
|
|
227
|
+
params: matchedParams,
|
|
228
|
+
pathname: joinPaths([matchedPathname, match.pathname]),
|
|
229
|
+
pathnameBase: normalizePathname(joinPaths([matchedPathname, match.pathnameBase])),
|
|
230
|
+
route
|
|
231
|
+
});
|
|
232
|
+
if (match.pathnameBase !== "/") {
|
|
233
|
+
matchedPathname = joinPaths([matchedPathname, match.pathnameBase]);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
return matches;
|
|
237
|
+
}
|
|
83
238
|
function matchPath(pattern, pathname) {
|
|
84
239
|
if (typeof pattern === "string") {
|
|
85
240
|
pattern = {
|
|
@@ -147,6 +302,14 @@ function compilePath(path, caseSensitive, end) {
|
|
|
147
302
|
let matcher = new RegExp(regexpSource, caseSensitive ? void 0 : "i");
|
|
148
303
|
return [matcher, params];
|
|
149
304
|
}
|
|
305
|
+
function decodePath(value) {
|
|
306
|
+
try {
|
|
307
|
+
return value.split("/").map((v) => decodeURIComponent(v).replace(/\//g, "%2F")).join("/");
|
|
308
|
+
} catch (error) {
|
|
309
|
+
warning(false, 'The URL path "' + value + '" could not be decoded because it is is a malformed URL segment. This is probably due to a bad percent ' + ("encoding (" + error + ")."));
|
|
310
|
+
return value;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
150
313
|
function stripBasename(pathname, basename) {
|
|
151
314
|
if (basename === "/") return pathname;
|
|
152
315
|
if (!pathname.toLowerCase().startsWith(basename.toLowerCase())) {
|
|
@@ -260,8 +423,12 @@ function resolveTo(toArg, routePathnames, locationPathname, isPathRelative) {
|
|
|
260
423
|
}
|
|
261
424
|
const removeDoubleSlashes = (path) => path.replace(/\/\/+/g, "/");
|
|
262
425
|
const joinPaths = (paths) => removeDoubleSlashes(paths.join("/"));
|
|
426
|
+
const normalizePathname = (pathname) => pathname.replace(/\/+$/, "").replace(/^\/*/, "/");
|
|
263
427
|
const normalizeSearch = (search) => !search || search === "?" ? "" : search.startsWith("?") ? search : "?" + search;
|
|
264
428
|
const normalizeHash = (hash) => !hash || hash === "#" ? "" : hash.startsWith("#") ? hash : "#" + hash;
|
|
429
|
+
function isRouteErrorResponse(error) {
|
|
430
|
+
return error != null && typeof error.status === "number" && typeof error.statusText === "string" && typeof error.internal === "boolean" && "data" in error;
|
|
431
|
+
}
|
|
265
432
|
const validMutationMethodsArr = ["post", "put", "patch", "delete"];
|
|
266
433
|
new Set(validMutationMethodsArr);
|
|
267
434
|
const validRequestMethodsArr = ["get", ...validMutationMethodsArr];
|
|
@@ -415,6 +582,13 @@ function useNavigateUnstable() {
|
|
|
415
582
|
}, [basename, navigator, routePathnamesJson, locationPathname, dataRouterContext]);
|
|
416
583
|
return navigate;
|
|
417
584
|
}
|
|
585
|
+
function useParams() {
|
|
586
|
+
let {
|
|
587
|
+
matches
|
|
588
|
+
} = React.useContext(RouteContext);
|
|
589
|
+
let routeMatch = matches[matches.length - 1];
|
|
590
|
+
return routeMatch ? routeMatch.params : {};
|
|
591
|
+
}
|
|
418
592
|
function useResolvedPath(to, _temp2) {
|
|
419
593
|
let {
|
|
420
594
|
relative
|
|
@@ -431,6 +605,285 @@ function useResolvedPath(to, _temp2) {
|
|
|
431
605
|
let routePathnamesJson = JSON.stringify(getResolveToMatches(matches, future.v7_relativeSplatPath));
|
|
432
606
|
return React.useMemo(() => resolveTo(to, JSON.parse(routePathnamesJson), locationPathname, relative === "path"), [to, routePathnamesJson, locationPathname, relative]);
|
|
433
607
|
}
|
|
608
|
+
function useRoutes(routes, locationArg) {
|
|
609
|
+
return useRoutesImpl(routes, locationArg);
|
|
610
|
+
}
|
|
611
|
+
function useRoutesImpl(routes, locationArg, dataRouterState, future) {
|
|
612
|
+
!useInRouterContext() ? process.env.NODE_ENV !== "production" ? invariant(
|
|
613
|
+
false,
|
|
614
|
+
// TODO: This error is probably because they somehow have 2 versions of the
|
|
615
|
+
// router loaded. We can help them understand how to avoid that.
|
|
616
|
+
"useRoutes() may be used only in the context of a <Router> component."
|
|
617
|
+
) : invariant(false) : void 0;
|
|
618
|
+
let {
|
|
619
|
+
navigator
|
|
620
|
+
} = React.useContext(NavigationContext);
|
|
621
|
+
let {
|
|
622
|
+
matches: parentMatches
|
|
623
|
+
} = React.useContext(RouteContext);
|
|
624
|
+
let routeMatch = parentMatches[parentMatches.length - 1];
|
|
625
|
+
let parentParams = routeMatch ? routeMatch.params : {};
|
|
626
|
+
let parentPathname = routeMatch ? routeMatch.pathname : "/";
|
|
627
|
+
let parentPathnameBase = routeMatch ? routeMatch.pathnameBase : "/";
|
|
628
|
+
let parentRoute = routeMatch && routeMatch.route;
|
|
629
|
+
if (process.env.NODE_ENV !== "production") {
|
|
630
|
+
let parentPath = parentRoute && parentRoute.path || "";
|
|
631
|
+
warningOnce(parentPathname, !parentRoute || parentPath.endsWith("*"), "You rendered descendant <Routes> (or called `useRoutes()`) at " + ('"' + parentPathname + '" (under <Route path="' + parentPath + '">) but the ') + `parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render.
|
|
632
|
+
|
|
633
|
+
` + ('Please change the parent <Route path="' + parentPath + '"> to <Route ') + ('path="' + (parentPath === "/" ? "*" : parentPath + "/*") + '">.'));
|
|
634
|
+
}
|
|
635
|
+
let locationFromContext = useLocation();
|
|
636
|
+
let location;
|
|
637
|
+
if (locationArg) {
|
|
638
|
+
var _parsedLocationArg$pa;
|
|
639
|
+
let parsedLocationArg = typeof locationArg === "string" ? parsePath(locationArg) : locationArg;
|
|
640
|
+
!(parentPathnameBase === "/" || ((_parsedLocationArg$pa = parsedLocationArg.pathname) == null ? void 0 : _parsedLocationArg$pa.startsWith(parentPathnameBase))) ? process.env.NODE_ENV !== "production" ? invariant(false, "When overriding the location using `<Routes location>` or `useRoutes(routes, location)`, the location pathname must begin with the portion of the URL pathname that was " + ('matched by all parent routes. The current pathname base is "' + parentPathnameBase + '" ') + ('but pathname "' + parsedLocationArg.pathname + '" was given in the `location` prop.')) : invariant(false) : void 0;
|
|
641
|
+
location = parsedLocationArg;
|
|
642
|
+
} else {
|
|
643
|
+
location = locationFromContext;
|
|
644
|
+
}
|
|
645
|
+
let pathname = location.pathname || "/";
|
|
646
|
+
let remainingPathname = pathname;
|
|
647
|
+
if (parentPathnameBase !== "/") {
|
|
648
|
+
let parentSegments = parentPathnameBase.replace(/^\//, "").split("/");
|
|
649
|
+
let segments = pathname.replace(/^\//, "").split("/");
|
|
650
|
+
remainingPathname = "/" + segments.slice(parentSegments.length).join("/");
|
|
651
|
+
}
|
|
652
|
+
let matches = matchRoutes(routes, {
|
|
653
|
+
pathname: remainingPathname
|
|
654
|
+
});
|
|
655
|
+
if (process.env.NODE_ENV !== "production") {
|
|
656
|
+
process.env.NODE_ENV !== "production" ? warning(parentRoute || matches != null, 'No routes matched location "' + location.pathname + location.search + location.hash + '" ') : void 0;
|
|
657
|
+
process.env.NODE_ENV !== "production" ? warning(matches == null || matches[matches.length - 1].route.element !== void 0 || matches[matches.length - 1].route.Component !== void 0 || matches[matches.length - 1].route.lazy !== void 0, 'Matched leaf route at location "' + location.pathname + location.search + location.hash + '" does not have an element or Component. This means it will render an <Outlet /> with a null value by default resulting in an "empty" page.') : void 0;
|
|
658
|
+
}
|
|
659
|
+
let renderedMatches = _renderMatches(matches && matches.map((match) => Object.assign({}, match, {
|
|
660
|
+
params: Object.assign({}, parentParams, match.params),
|
|
661
|
+
pathname: joinPaths([
|
|
662
|
+
parentPathnameBase,
|
|
663
|
+
// Re-encode pathnames that were decoded inside matchRoutes
|
|
664
|
+
navigator.encodeLocation ? navigator.encodeLocation(match.pathname).pathname : match.pathname
|
|
665
|
+
]),
|
|
666
|
+
pathnameBase: match.pathnameBase === "/" ? parentPathnameBase : joinPaths([
|
|
667
|
+
parentPathnameBase,
|
|
668
|
+
// Re-encode pathnames that were decoded inside matchRoutes
|
|
669
|
+
navigator.encodeLocation ? navigator.encodeLocation(match.pathnameBase).pathname : match.pathnameBase
|
|
670
|
+
])
|
|
671
|
+
})), parentMatches, dataRouterState, future);
|
|
672
|
+
if (locationArg && renderedMatches) {
|
|
673
|
+
return /* @__PURE__ */ React.createElement(LocationContext.Provider, {
|
|
674
|
+
value: {
|
|
675
|
+
location: _extends$1({
|
|
676
|
+
pathname: "/",
|
|
677
|
+
search: "",
|
|
678
|
+
hash: "",
|
|
679
|
+
state: null,
|
|
680
|
+
key: "default"
|
|
681
|
+
}, location),
|
|
682
|
+
navigationType: Action.Pop
|
|
683
|
+
}
|
|
684
|
+
}, renderedMatches);
|
|
685
|
+
}
|
|
686
|
+
return renderedMatches;
|
|
687
|
+
}
|
|
688
|
+
function DefaultErrorComponent() {
|
|
689
|
+
let error = useRouteError();
|
|
690
|
+
let message = isRouteErrorResponse(error) ? error.status + " " + error.statusText : error instanceof Error ? error.message : JSON.stringify(error);
|
|
691
|
+
let stack = error instanceof Error ? error.stack : null;
|
|
692
|
+
let lightgrey = "rgba(200,200,200, 0.5)";
|
|
693
|
+
let preStyles = {
|
|
694
|
+
padding: "0.5rem",
|
|
695
|
+
backgroundColor: lightgrey
|
|
696
|
+
};
|
|
697
|
+
let codeStyles = {
|
|
698
|
+
padding: "2px 4px",
|
|
699
|
+
backgroundColor: lightgrey
|
|
700
|
+
};
|
|
701
|
+
let devInfo = null;
|
|
702
|
+
if (process.env.NODE_ENV !== "production") {
|
|
703
|
+
console.error("Error handled by React Router default ErrorBoundary:", error);
|
|
704
|
+
devInfo = /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("p", null, "💿 Hey developer 👋"), /* @__PURE__ */ React.createElement("p", null, "You can provide a way better UX than this when your app throws errors by providing your own ", /* @__PURE__ */ React.createElement("code", {
|
|
705
|
+
style: codeStyles
|
|
706
|
+
}, "ErrorBoundary"), " or", " ", /* @__PURE__ */ React.createElement("code", {
|
|
707
|
+
style: codeStyles
|
|
708
|
+
}, "errorElement"), " prop on your route."));
|
|
709
|
+
}
|
|
710
|
+
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("h2", null, "Unexpected Application Error!"), /* @__PURE__ */ React.createElement("h3", {
|
|
711
|
+
style: {
|
|
712
|
+
fontStyle: "italic"
|
|
713
|
+
}
|
|
714
|
+
}, message), stack ? /* @__PURE__ */ React.createElement("pre", {
|
|
715
|
+
style: preStyles
|
|
716
|
+
}, stack) : null, devInfo);
|
|
717
|
+
}
|
|
718
|
+
const defaultErrorElement = /* @__PURE__ */ React.createElement(DefaultErrorComponent, null);
|
|
719
|
+
class RenderErrorBoundary extends React.Component {
|
|
720
|
+
constructor(props) {
|
|
721
|
+
super(props);
|
|
722
|
+
this.state = {
|
|
723
|
+
location: props.location,
|
|
724
|
+
revalidation: props.revalidation,
|
|
725
|
+
error: props.error
|
|
726
|
+
};
|
|
727
|
+
}
|
|
728
|
+
static getDerivedStateFromError(error) {
|
|
729
|
+
return {
|
|
730
|
+
error
|
|
731
|
+
};
|
|
732
|
+
}
|
|
733
|
+
static getDerivedStateFromProps(props, state) {
|
|
734
|
+
if (state.location !== props.location || state.revalidation !== "idle" && props.revalidation === "idle") {
|
|
735
|
+
return {
|
|
736
|
+
error: props.error,
|
|
737
|
+
location: props.location,
|
|
738
|
+
revalidation: props.revalidation
|
|
739
|
+
};
|
|
740
|
+
}
|
|
741
|
+
return {
|
|
742
|
+
error: props.error !== void 0 ? props.error : state.error,
|
|
743
|
+
location: state.location,
|
|
744
|
+
revalidation: props.revalidation || state.revalidation
|
|
745
|
+
};
|
|
746
|
+
}
|
|
747
|
+
componentDidCatch(error, errorInfo) {
|
|
748
|
+
console.error("React Router caught the following error during render", error, errorInfo);
|
|
749
|
+
}
|
|
750
|
+
render() {
|
|
751
|
+
return this.state.error !== void 0 ? /* @__PURE__ */ React.createElement(RouteContext.Provider, {
|
|
752
|
+
value: this.props.routeContext
|
|
753
|
+
}, /* @__PURE__ */ React.createElement(RouteErrorContext.Provider, {
|
|
754
|
+
value: this.state.error,
|
|
755
|
+
children: this.props.component
|
|
756
|
+
})) : this.props.children;
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
function RenderedRoute(_ref) {
|
|
760
|
+
let {
|
|
761
|
+
routeContext,
|
|
762
|
+
match,
|
|
763
|
+
children
|
|
764
|
+
} = _ref;
|
|
765
|
+
let dataRouterContext = React.useContext(DataRouterContext);
|
|
766
|
+
if (dataRouterContext && dataRouterContext.static && dataRouterContext.staticContext && (match.route.errorElement || match.route.ErrorBoundary)) {
|
|
767
|
+
dataRouterContext.staticContext._deepestRenderedBoundaryId = match.route.id;
|
|
768
|
+
}
|
|
769
|
+
return /* @__PURE__ */ React.createElement(RouteContext.Provider, {
|
|
770
|
+
value: routeContext
|
|
771
|
+
}, children);
|
|
772
|
+
}
|
|
773
|
+
function _renderMatches(matches, parentMatches, dataRouterState, future) {
|
|
774
|
+
var _dataRouterState;
|
|
775
|
+
if (parentMatches === void 0) {
|
|
776
|
+
parentMatches = [];
|
|
777
|
+
}
|
|
778
|
+
if (dataRouterState === void 0) {
|
|
779
|
+
dataRouterState = null;
|
|
780
|
+
}
|
|
781
|
+
if (future === void 0) {
|
|
782
|
+
future = null;
|
|
783
|
+
}
|
|
784
|
+
if (matches == null) {
|
|
785
|
+
var _future;
|
|
786
|
+
if (!dataRouterState) {
|
|
787
|
+
return null;
|
|
788
|
+
}
|
|
789
|
+
if (dataRouterState.errors) {
|
|
790
|
+
matches = dataRouterState.matches;
|
|
791
|
+
} else if ((_future = future) != null && _future.v7_partialHydration && parentMatches.length === 0 && !dataRouterState.initialized && dataRouterState.matches.length > 0) {
|
|
792
|
+
matches = dataRouterState.matches;
|
|
793
|
+
} else {
|
|
794
|
+
return null;
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
let renderedMatches = matches;
|
|
798
|
+
let errors = (_dataRouterState = dataRouterState) == null ? void 0 : _dataRouterState.errors;
|
|
799
|
+
if (errors != null) {
|
|
800
|
+
let errorIndex = renderedMatches.findIndex((m) => m.route.id && (errors == null ? void 0 : errors[m.route.id]) !== void 0);
|
|
801
|
+
!(errorIndex >= 0) ? process.env.NODE_ENV !== "production" ? invariant(false, "Could not find a matching route for errors on route IDs: " + Object.keys(errors).join(",")) : invariant(false) : void 0;
|
|
802
|
+
renderedMatches = renderedMatches.slice(0, Math.min(renderedMatches.length, errorIndex + 1));
|
|
803
|
+
}
|
|
804
|
+
let renderFallback = false;
|
|
805
|
+
let fallbackIndex = -1;
|
|
806
|
+
if (dataRouterState && future && future.v7_partialHydration) {
|
|
807
|
+
for (let i = 0; i < renderedMatches.length; i++) {
|
|
808
|
+
let match = renderedMatches[i];
|
|
809
|
+
if (match.route.HydrateFallback || match.route.hydrateFallbackElement) {
|
|
810
|
+
fallbackIndex = i;
|
|
811
|
+
}
|
|
812
|
+
if (match.route.id) {
|
|
813
|
+
let {
|
|
814
|
+
loaderData,
|
|
815
|
+
errors: errors2
|
|
816
|
+
} = dataRouterState;
|
|
817
|
+
let needsToRunLoader = match.route.loader && loaderData[match.route.id] === void 0 && (!errors2 || errors2[match.route.id] === void 0);
|
|
818
|
+
if (match.route.lazy || needsToRunLoader) {
|
|
819
|
+
renderFallback = true;
|
|
820
|
+
if (fallbackIndex >= 0) {
|
|
821
|
+
renderedMatches = renderedMatches.slice(0, fallbackIndex + 1);
|
|
822
|
+
} else {
|
|
823
|
+
renderedMatches = [renderedMatches[0]];
|
|
824
|
+
}
|
|
825
|
+
break;
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
return renderedMatches.reduceRight((outlet, match, index) => {
|
|
831
|
+
let error;
|
|
832
|
+
let shouldRenderHydrateFallback = false;
|
|
833
|
+
let errorElement = null;
|
|
834
|
+
let hydrateFallbackElement = null;
|
|
835
|
+
if (dataRouterState) {
|
|
836
|
+
error = errors && match.route.id ? errors[match.route.id] : void 0;
|
|
837
|
+
errorElement = match.route.errorElement || defaultErrorElement;
|
|
838
|
+
if (renderFallback) {
|
|
839
|
+
if (fallbackIndex < 0 && index === 0) {
|
|
840
|
+
warningOnce("route-fallback", false, "No `HydrateFallback` element provided to render during initial hydration");
|
|
841
|
+
shouldRenderHydrateFallback = true;
|
|
842
|
+
hydrateFallbackElement = null;
|
|
843
|
+
} else if (fallbackIndex === index) {
|
|
844
|
+
shouldRenderHydrateFallback = true;
|
|
845
|
+
hydrateFallbackElement = match.route.hydrateFallbackElement || null;
|
|
846
|
+
}
|
|
847
|
+
}
|
|
848
|
+
}
|
|
849
|
+
let matches2 = parentMatches.concat(renderedMatches.slice(0, index + 1));
|
|
850
|
+
let getChildren = () => {
|
|
851
|
+
let children;
|
|
852
|
+
if (error) {
|
|
853
|
+
children = errorElement;
|
|
854
|
+
} else if (shouldRenderHydrateFallback) {
|
|
855
|
+
children = hydrateFallbackElement;
|
|
856
|
+
} else if (match.route.Component) {
|
|
857
|
+
children = /* @__PURE__ */ React.createElement(match.route.Component, null);
|
|
858
|
+
} else if (match.route.element) {
|
|
859
|
+
children = match.route.element;
|
|
860
|
+
} else {
|
|
861
|
+
children = outlet;
|
|
862
|
+
}
|
|
863
|
+
return /* @__PURE__ */ React.createElement(RenderedRoute, {
|
|
864
|
+
match,
|
|
865
|
+
routeContext: {
|
|
866
|
+
outlet,
|
|
867
|
+
matches: matches2,
|
|
868
|
+
isDataRoute: dataRouterState != null
|
|
869
|
+
},
|
|
870
|
+
children
|
|
871
|
+
});
|
|
872
|
+
};
|
|
873
|
+
return dataRouterState && (match.route.ErrorBoundary || match.route.errorElement || index === 0) ? /* @__PURE__ */ React.createElement(RenderErrorBoundary, {
|
|
874
|
+
location: dataRouterState.location,
|
|
875
|
+
revalidation: dataRouterState.revalidation,
|
|
876
|
+
component: errorElement,
|
|
877
|
+
error,
|
|
878
|
+
children: getChildren(),
|
|
879
|
+
routeContext: {
|
|
880
|
+
outlet: null,
|
|
881
|
+
matches: matches2,
|
|
882
|
+
isDataRoute: true
|
|
883
|
+
}
|
|
884
|
+
}) : getChildren();
|
|
885
|
+
}, null);
|
|
886
|
+
}
|
|
434
887
|
var DataRouterHook$1 = /* @__PURE__ */ function(DataRouterHook2) {
|
|
435
888
|
DataRouterHook2["UseBlocker"] = "useBlocker";
|
|
436
889
|
DataRouterHook2["UseRevalidator"] = "useRevalidator";
|
|
@@ -458,6 +911,11 @@ function useDataRouterContext$1(hookName) {
|
|
|
458
911
|
!ctx ? process.env.NODE_ENV !== "production" ? invariant(false, getDataRouterConsoleError$1(hookName)) : invariant(false) : void 0;
|
|
459
912
|
return ctx;
|
|
460
913
|
}
|
|
914
|
+
function useDataRouterState(hookName) {
|
|
915
|
+
let state = React.useContext(DataRouterStateContext);
|
|
916
|
+
!state ? process.env.NODE_ENV !== "production" ? invariant(false, getDataRouterConsoleError$1(hookName)) : invariant(false) : void 0;
|
|
917
|
+
return state;
|
|
918
|
+
}
|
|
461
919
|
function useRouteContext(hookName) {
|
|
462
920
|
let route = React.useContext(RouteContext);
|
|
463
921
|
!route ? process.env.NODE_ENV !== "production" ? invariant(false, getDataRouterConsoleError$1(hookName)) : invariant(false) : void 0;
|
|
@@ -472,6 +930,16 @@ function useCurrentRouteId(hookName) {
|
|
|
472
930
|
function useRouteId() {
|
|
473
931
|
return useCurrentRouteId(DataRouterStateHook$1.UseRouteId);
|
|
474
932
|
}
|
|
933
|
+
function useRouteError() {
|
|
934
|
+
var _state$errors;
|
|
935
|
+
let error = React.useContext(RouteErrorContext);
|
|
936
|
+
let state = useDataRouterState(DataRouterStateHook$1.UseRouteError);
|
|
937
|
+
let routeId = useCurrentRouteId(DataRouterStateHook$1.UseRouteError);
|
|
938
|
+
if (error !== void 0) {
|
|
939
|
+
return error;
|
|
940
|
+
}
|
|
941
|
+
return (_state$errors = state.errors) == null ? void 0 : _state$errors[routeId];
|
|
942
|
+
}
|
|
475
943
|
function useNavigateStable() {
|
|
476
944
|
let {
|
|
477
945
|
router
|
|
@@ -497,8 +965,64 @@ function useNavigateStable() {
|
|
|
497
965
|
}, [router, id]);
|
|
498
966
|
return navigate;
|
|
499
967
|
}
|
|
968
|
+
const alreadyWarned$1 = {};
|
|
969
|
+
function warningOnce(key, cond, message) {
|
|
970
|
+
if (!cond && !alreadyWarned$1[key]) {
|
|
971
|
+
alreadyWarned$1[key] = true;
|
|
972
|
+
process.env.NODE_ENV !== "production" ? warning(false, message) : void 0;
|
|
973
|
+
}
|
|
974
|
+
}
|
|
975
|
+
function Route(_props) {
|
|
976
|
+
process.env.NODE_ENV !== "production" ? invariant(false, "A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your <Route> in a <Routes>.") : invariant(false);
|
|
977
|
+
}
|
|
978
|
+
function Routes(_ref6) {
|
|
979
|
+
let {
|
|
980
|
+
children,
|
|
981
|
+
location
|
|
982
|
+
} = _ref6;
|
|
983
|
+
return useRoutes(createRoutesFromChildren(children), location);
|
|
984
|
+
}
|
|
500
985
|
new Promise(() => {
|
|
501
986
|
});
|
|
987
|
+
function createRoutesFromChildren(children, parentPath) {
|
|
988
|
+
if (parentPath === void 0) {
|
|
989
|
+
parentPath = [];
|
|
990
|
+
}
|
|
991
|
+
let routes = [];
|
|
992
|
+
React.Children.forEach(children, (element, index) => {
|
|
993
|
+
if (!/* @__PURE__ */ React.isValidElement(element)) {
|
|
994
|
+
return;
|
|
995
|
+
}
|
|
996
|
+
let treePath = [...parentPath, index];
|
|
997
|
+
if (element.type === React.Fragment) {
|
|
998
|
+
routes.push.apply(routes, createRoutesFromChildren(element.props.children, treePath));
|
|
999
|
+
return;
|
|
1000
|
+
}
|
|
1001
|
+
!(element.type === Route) ? process.env.NODE_ENV !== "production" ? invariant(false, "[" + (typeof element.type === "string" ? element.type : element.type.name) + "] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>") : invariant(false) : void 0;
|
|
1002
|
+
!(!element.props.index || !element.props.children) ? process.env.NODE_ENV !== "production" ? invariant(false, "An index route cannot have child routes.") : invariant(false) : void 0;
|
|
1003
|
+
let route = {
|
|
1004
|
+
id: element.props.id || treePath.join("-"),
|
|
1005
|
+
caseSensitive: element.props.caseSensitive,
|
|
1006
|
+
element: element.props.element,
|
|
1007
|
+
Component: element.props.Component,
|
|
1008
|
+
index: element.props.index,
|
|
1009
|
+
path: element.props.path,
|
|
1010
|
+
loader: element.props.loader,
|
|
1011
|
+
action: element.props.action,
|
|
1012
|
+
errorElement: element.props.errorElement,
|
|
1013
|
+
ErrorBoundary: element.props.ErrorBoundary,
|
|
1014
|
+
hasErrorBoundary: element.props.ErrorBoundary != null || element.props.errorElement != null,
|
|
1015
|
+
shouldRevalidate: element.props.shouldRevalidate,
|
|
1016
|
+
handle: element.props.handle,
|
|
1017
|
+
lazy: element.props.lazy
|
|
1018
|
+
};
|
|
1019
|
+
if (element.props.children) {
|
|
1020
|
+
route.children = createRoutesFromChildren(element.props.children, treePath);
|
|
1021
|
+
}
|
|
1022
|
+
routes.push(route);
|
|
1023
|
+
});
|
|
1024
|
+
return routes;
|
|
1025
|
+
}
|
|
502
1026
|
/**
|
|
503
1027
|
* React Router DOM v6.30.4
|
|
504
1028
|
*
|
|
@@ -549,6 +1073,28 @@ function shouldProcessLinkClick(event, target) {
|
|
|
549
1073
|
(!target || target === "_self") && // Let browser handle "target=_blank" etc.
|
|
550
1074
|
!isModifiedEvent(event);
|
|
551
1075
|
}
|
|
1076
|
+
function createSearchParams(init) {
|
|
1077
|
+
if (init === void 0) {
|
|
1078
|
+
init = "";
|
|
1079
|
+
}
|
|
1080
|
+
return new URLSearchParams(typeof init === "string" || Array.isArray(init) || init instanceof URLSearchParams ? init : Object.keys(init).reduce((memo, key) => {
|
|
1081
|
+
let value = init[key];
|
|
1082
|
+
return memo.concat(Array.isArray(value) ? value.map((v) => [key, v]) : [[key, value]]);
|
|
1083
|
+
}, []));
|
|
1084
|
+
}
|
|
1085
|
+
function getSearchParamsForLocation(locationSearch, defaultSearchParams) {
|
|
1086
|
+
let searchParams = createSearchParams(locationSearch);
|
|
1087
|
+
if (defaultSearchParams) {
|
|
1088
|
+
defaultSearchParams.forEach((_, key) => {
|
|
1089
|
+
if (!searchParams.has(key)) {
|
|
1090
|
+
defaultSearchParams.getAll(key).forEach((value) => {
|
|
1091
|
+
searchParams.append(key, value);
|
|
1092
|
+
});
|
|
1093
|
+
}
|
|
1094
|
+
});
|
|
1095
|
+
}
|
|
1096
|
+
return searchParams;
|
|
1097
|
+
}
|
|
552
1098
|
let _formDataSupportsSubmitter = null;
|
|
553
1099
|
function isFormDataSubmitterSupported() {
|
|
554
1100
|
if (_formDataSupportsSubmitter === null) {
|
|
@@ -871,6 +1417,25 @@ function useLinkClickHandler(to, _temp) {
|
|
|
871
1417
|
}
|
|
872
1418
|
}, [location, navigate, path, replaceProp, state, target, to, preventScrollReset, relative, viewTransition]);
|
|
873
1419
|
}
|
|
1420
|
+
function useSearchParams(defaultInit) {
|
|
1421
|
+
process.env.NODE_ENV !== "production" ? warning(typeof URLSearchParams !== "undefined", "You cannot use the `useSearchParams` hook in a browser that does not support the URLSearchParams API. If you need to support Internet Explorer 11, we recommend you load a polyfill such as https://github.com/ungap/url-search-params.") : void 0;
|
|
1422
|
+
let defaultSearchParamsRef = React.useRef(createSearchParams(defaultInit));
|
|
1423
|
+
let hasSetSearchParamsRef = React.useRef(false);
|
|
1424
|
+
let location = useLocation();
|
|
1425
|
+
let searchParams = React.useMemo(() => (
|
|
1426
|
+
// Only merge in the defaults if we haven't yet called setSearchParams.
|
|
1427
|
+
// Once we call that we want those to take precedence, otherwise you can't
|
|
1428
|
+
// remove a param with setSearchParams({}) if it has an initial value
|
|
1429
|
+
getSearchParamsForLocation(location.search, hasSetSearchParamsRef.current ? null : defaultSearchParamsRef.current)
|
|
1430
|
+
), [location.search]);
|
|
1431
|
+
let navigate = useNavigate();
|
|
1432
|
+
let setSearchParams = React.useCallback((nextInit, navigateOptions) => {
|
|
1433
|
+
const newSearchParams = createSearchParams(typeof nextInit === "function" ? nextInit(searchParams) : nextInit);
|
|
1434
|
+
hasSetSearchParamsRef.current = true;
|
|
1435
|
+
navigate("?" + newSearchParams, navigateOptions);
|
|
1436
|
+
}, [navigate, searchParams]);
|
|
1437
|
+
return [searchParams, setSearchParams];
|
|
1438
|
+
}
|
|
874
1439
|
function validateClientSideSubmission() {
|
|
875
1440
|
if (typeof document === "undefined") {
|
|
876
1441
|
throw new Error("You are calling submit during the server render. Try calling submit within a `useEffect` or callback instead.");
|
|
@@ -977,317 +1542,11 @@ function useViewTransitionState(to, opts) {
|
|
|
977
1542
|
let nextPath = stripBasename(vtContext.nextLocation.pathname, basename) || vtContext.nextLocation.pathname;
|
|
978
1543
|
return matchPath(path.pathname, nextPath) != null || matchPath(path.pathname, currentPath) != null;
|
|
979
1544
|
}
|
|
980
|
-
const AuditSection = ({ configured }) => {
|
|
981
|
-
const intl = useIntl();
|
|
982
|
-
const { formatMessage } = intl;
|
|
983
|
-
const { get } = useFetchClient();
|
|
984
|
-
const [busy, setBusy] = React.useState(false);
|
|
985
|
-
const [error, setError] = React.useState(false);
|
|
986
|
-
const [result, setResult] = React.useState(null);
|
|
987
|
-
const t = (id, defaultMessage, values) => formatMessage({ id: getTranslation(id), defaultMessage }, values);
|
|
988
|
-
const problemText = (p) => {
|
|
989
|
-
switch (p.code) {
|
|
990
|
-
case "unknown":
|
|
991
|
-
return t("problem.unknown", "“{property}” does not exist on {object} in this portal", {
|
|
992
|
-
property: p.property,
|
|
993
|
-
object: objectLabel(intl, p.object)
|
|
994
|
-
});
|
|
995
|
-
case "wrong-object":
|
|
996
|
-
return t("problem.wrong-object", "“{property}” exists on {actual}, not on {object}", {
|
|
997
|
-
property: p.property,
|
|
998
|
-
object: objectLabel(intl, p.object),
|
|
999
|
-
actual: objectLabel(intl, p.actualObject)
|
|
1000
|
-
});
|
|
1001
|
-
case "whitespace":
|
|
1002
|
-
return t("problem.whitespace", "“{property}” has surrounding whitespace", {
|
|
1003
|
-
property: p.property
|
|
1004
|
-
});
|
|
1005
|
-
case "bad-option":
|
|
1006
|
-
return t("problem.bad-option", "“{property}” does not accept {values}", {
|
|
1007
|
-
property: p.property,
|
|
1008
|
-
values: p.values.join(", ")
|
|
1009
|
-
});
|
|
1010
|
-
}
|
|
1011
|
-
};
|
|
1012
|
-
const run = async () => {
|
|
1013
|
-
setBusy(true);
|
|
1014
|
-
setError(false);
|
|
1015
|
-
setResult(null);
|
|
1016
|
-
try {
|
|
1017
|
-
const { data } = await get(`/${PLUGIN_ID}/audit`);
|
|
1018
|
-
setResult(data);
|
|
1019
|
-
} catch {
|
|
1020
|
-
setError(true);
|
|
1021
|
-
} finally {
|
|
1022
|
-
setBusy(false);
|
|
1023
|
-
}
|
|
1024
|
-
};
|
|
1025
|
-
const entryLink = (uid, entry) => `/content-manager/collection-types/${uid}/${entry.documentId}` + (entry.locale ? `?plugins[i18n][locale]=${entry.locale}` : "");
|
|
1026
|
-
const totalInvalid = result?.targets.reduce((n, r) => n + r.invalid.length, 0) ?? 0;
|
|
1027
|
-
return /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 4, children: [
|
|
1028
|
-
/* @__PURE__ */ jsx(Divider, {}),
|
|
1029
|
-
/* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "flex-start", gap: 2, children: [
|
|
1030
|
-
/* @__PURE__ */ jsx(Typography, { variant: "beta", children: t("audit.title", "Mapping audit") }),
|
|
1031
|
-
/* @__PURE__ */ jsx(Typography, { variant: "epsilon", textColor: "neutral600", children: t(
|
|
1032
|
-
"audit.subtitle",
|
|
1033
|
-
"Scans every entry of the validated content types and lists the mappings the portal would reject today — including properties deleted in HubSpot since they were saved."
|
|
1034
|
-
) })
|
|
1035
|
-
] }),
|
|
1036
|
-
/* @__PURE__ */ jsx(Flex, { gap: 2, children: /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: run, loading: busy, disabled: !configured, children: t("audit.run", "Run the audit") }) }),
|
|
1037
|
-
error ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "danger600", children: t("audit.error", "Audit failed — HubSpot unreachable?") }) : null,
|
|
1038
|
-
result && !result.targets.length ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: t(
|
|
1039
|
-
"audit.no-targets",
|
|
1040
|
-
"No content type to audit — declare them under `validate` in the plugin config."
|
|
1041
|
-
) }) : null,
|
|
1042
|
-
result && result.targets.length ? /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 4, children: [
|
|
1043
|
-
totalInvalid === 0 && result.targets.every((r) => !r.error) ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "success600", children: t("audit.clean", "Nothing to report — every mapping is valid.") }) : null,
|
|
1044
|
-
result.targets.map((report) => /* @__PURE__ */ jsxs(Box, { children: [
|
|
1045
|
-
/* @__PURE__ */ jsxs(Flex, { gap: 2, alignItems: "center", paddingBottom: 2, children: [
|
|
1046
|
-
/* @__PURE__ */ jsx(Typography, { variant: "delta", children: report.uid }),
|
|
1047
|
-
/* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: t("audit.summary", "{entries} entries · {mappings} mappings", {
|
|
1048
|
-
entries: report.entries,
|
|
1049
|
-
mappings: report.mappings
|
|
1050
|
-
}) })
|
|
1051
|
-
] }),
|
|
1052
|
-
report.error ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "danger600", children: t("audit.target-error", "Could not scan: {error}", { error: report.error }) }) : null,
|
|
1053
|
-
/* @__PURE__ */ jsx(Flex, { direction: "column", alignItems: "stretch", gap: 2, children: report.invalid.map((entry) => /* @__PURE__ */ jsxs(
|
|
1054
|
-
Box,
|
|
1055
|
-
{
|
|
1056
|
-
padding: 3,
|
|
1057
|
-
background: "neutral100",
|
|
1058
|
-
hasRadius: true,
|
|
1059
|
-
children: [
|
|
1060
|
-
/* @__PURE__ */ jsxs(Flex, { gap: 2, alignItems: "center", children: [
|
|
1061
|
-
/* @__PURE__ */ jsx(Link$1, { tag: Link, to: entryLink(report.uid, entry), children: entry.label }),
|
|
1062
|
-
entry.locale ? /* @__PURE__ */ jsx(Badge, { children: entry.locale }) : null
|
|
1063
|
-
] }),
|
|
1064
|
-
/* @__PURE__ */ jsx(Box, { paddingTop: 1, children: entry.problems.map((p, i) => /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "danger600", tag: "p", children: problemText(p) }, i)) })
|
|
1065
|
-
]
|
|
1066
|
-
},
|
|
1067
|
-
`${entry.documentId}-${entry.locale ?? ""}`
|
|
1068
|
-
)) })
|
|
1069
|
-
] }, report.uid))
|
|
1070
|
-
] }) : null
|
|
1071
|
-
] });
|
|
1072
|
-
};
|
|
1073
|
-
const FailuresSection = ({ configured }) => {
|
|
1074
|
-
const { formatMessage } = useIntl();
|
|
1075
|
-
const { get, post } = useFetchClient();
|
|
1076
|
-
const [total, setTotal] = React.useState(null);
|
|
1077
|
-
const [busy, setBusy] = React.useState(false);
|
|
1078
|
-
const [feedback, setFeedback] = React.useState(
|
|
1079
|
-
null
|
|
1080
|
-
);
|
|
1081
|
-
const t = (id, defaultMessage, values) => formatMessage({ id: getTranslation(id), defaultMessage }, values);
|
|
1082
|
-
const load = React.useCallback(async () => {
|
|
1083
|
-
try {
|
|
1084
|
-
const { data } = await get(`/${PLUGIN_ID}/failures`);
|
|
1085
|
-
setTotal(data.total);
|
|
1086
|
-
} catch {
|
|
1087
|
-
setTotal(null);
|
|
1088
|
-
}
|
|
1089
|
-
}, [get]);
|
|
1090
|
-
React.useEffect(() => {
|
|
1091
|
-
load();
|
|
1092
|
-
}, [load]);
|
|
1093
|
-
const retry = async () => {
|
|
1094
|
-
setBusy(true);
|
|
1095
|
-
setFeedback(null);
|
|
1096
|
-
try {
|
|
1097
|
-
const { data } = await post(
|
|
1098
|
-
`/${PLUGIN_ID}/failures/retry`
|
|
1099
|
-
);
|
|
1100
|
-
setFeedback({
|
|
1101
|
-
tone: data.failed ? "danger" : "success",
|
|
1102
|
-
text: t("failures.retried", "{succeeded} replayed, {failed} still failing.", {
|
|
1103
|
-
succeeded: data.succeeded,
|
|
1104
|
-
failed: data.failed
|
|
1105
|
-
})
|
|
1106
|
-
});
|
|
1107
|
-
await load();
|
|
1108
|
-
} catch {
|
|
1109
|
-
setFeedback({ tone: "danger", text: t("failures.error", "Replay failed.") });
|
|
1110
|
-
} finally {
|
|
1111
|
-
setBusy(false);
|
|
1112
|
-
}
|
|
1113
|
-
};
|
|
1114
|
-
return /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 4, children: [
|
|
1115
|
-
/* @__PURE__ */ jsx(Divider, {}),
|
|
1116
|
-
/* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "flex-start", gap: 2, children: [
|
|
1117
|
-
/* @__PURE__ */ jsx(Typography, { variant: "beta", children: t("failures.title", "Failed submissions") }),
|
|
1118
|
-
/* @__PURE__ */ jsx(Typography, { variant: "epsilon", textColor: "neutral600", children: t(
|
|
1119
|
-
"failures.subtitle",
|
|
1120
|
-
"Submissions HubSpot couldn't take after the automatic retries. They can be inspected under Content Manager → HubSpot failed submissions."
|
|
1121
|
-
) })
|
|
1122
|
-
] }),
|
|
1123
|
-
/* @__PURE__ */ jsxs(Flex, { gap: 2, alignItems: "center", children: [
|
|
1124
|
-
/* @__PURE__ */ jsx(Badge, { active: Boolean(total), children: t("failures.count", "{count} queued", { count: total ?? 0 }) }),
|
|
1125
|
-
/* @__PURE__ */ jsx(
|
|
1126
|
-
Button,
|
|
1127
|
-
{
|
|
1128
|
-
variant: "secondary",
|
|
1129
|
-
onClick: retry,
|
|
1130
|
-
loading: busy,
|
|
1131
|
-
disabled: !configured || !total,
|
|
1132
|
-
children: t("failures.retry", "Replay now")
|
|
1133
|
-
}
|
|
1134
|
-
)
|
|
1135
|
-
] }),
|
|
1136
|
-
feedback ? /* @__PURE__ */ jsx(
|
|
1137
|
-
Typography,
|
|
1138
|
-
{
|
|
1139
|
-
variant: "pi",
|
|
1140
|
-
textColor: feedback.tone === "success" ? "success600" : "danger600",
|
|
1141
|
-
children: feedback.text
|
|
1142
|
-
}
|
|
1143
|
-
) : null
|
|
1144
|
-
] });
|
|
1145
|
-
};
|
|
1146
|
-
const HubspotSettings = () => {
|
|
1147
|
-
const { formatMessage } = useIntl();
|
|
1148
|
-
const { get, put, del } = useFetchClient();
|
|
1149
|
-
const [settings, setSettings] = React.useState(null);
|
|
1150
|
-
const [apiKey, setApiKey] = React.useState("");
|
|
1151
|
-
const [busy, setBusy] = React.useState(false);
|
|
1152
|
-
const [feedback, setFeedback] = React.useState(
|
|
1153
|
-
null
|
|
1154
|
-
);
|
|
1155
|
-
const t = (id, defaultMessage, values) => formatMessage({ id: getTranslation(id), defaultMessage }, values);
|
|
1156
|
-
const load = React.useCallback(async () => {
|
|
1157
|
-
const { data } = await get(`/${PLUGIN_ID}/settings`);
|
|
1158
|
-
setSettings(data);
|
|
1159
|
-
}, [get]);
|
|
1160
|
-
React.useEffect(() => {
|
|
1161
|
-
load().catch(
|
|
1162
|
-
() => setFeedback({ tone: "danger", text: t("settings.load-error", "Could not load settings.") })
|
|
1163
|
-
);
|
|
1164
|
-
}, [load]);
|
|
1165
|
-
const save = async () => {
|
|
1166
|
-
setBusy(true);
|
|
1167
|
-
setFeedback(null);
|
|
1168
|
-
try {
|
|
1169
|
-
const { data } = await put(`/${PLUGIN_ID}/settings`, { apiKey });
|
|
1170
|
-
setSettings(data);
|
|
1171
|
-
setApiKey("");
|
|
1172
|
-
setFeedback({ tone: "success", text: t("settings.saved", "Key saved.") });
|
|
1173
|
-
} catch {
|
|
1174
|
-
setFeedback({ tone: "danger", text: t("settings.save-error", "Could not save the key.") });
|
|
1175
|
-
} finally {
|
|
1176
|
-
setBusy(false);
|
|
1177
|
-
}
|
|
1178
|
-
};
|
|
1179
|
-
const remove = async () => {
|
|
1180
|
-
setBusy(true);
|
|
1181
|
-
setFeedback(null);
|
|
1182
|
-
try {
|
|
1183
|
-
const { data } = await del(`/${PLUGIN_ID}/settings`);
|
|
1184
|
-
setSettings(data);
|
|
1185
|
-
setApiKey("");
|
|
1186
|
-
setFeedback({ tone: "success", text: t("settings.removed", "Key removed.") });
|
|
1187
|
-
} catch {
|
|
1188
|
-
setFeedback({ tone: "danger", text: t("settings.remove-error", "Could not remove the key.") });
|
|
1189
|
-
} finally {
|
|
1190
|
-
setBusy(false);
|
|
1191
|
-
}
|
|
1192
|
-
};
|
|
1193
|
-
const test = async () => {
|
|
1194
|
-
setBusy(true);
|
|
1195
|
-
setFeedback(null);
|
|
1196
|
-
try {
|
|
1197
|
-
const { data } = await get(
|
|
1198
|
-
`/${PLUGIN_ID}/properties?refresh=1`
|
|
1199
|
-
);
|
|
1200
|
-
setFeedback(
|
|
1201
|
-
data.configured ? {
|
|
1202
|
-
tone: "success",
|
|
1203
|
-
text: t("settings.test-ok", "Connection established — {count} readable properties.", {
|
|
1204
|
-
count: data.properties.length
|
|
1205
|
-
})
|
|
1206
|
-
} : { tone: "danger", text: t("settings.test-no-key", "No key configured.") }
|
|
1207
|
-
);
|
|
1208
|
-
} catch {
|
|
1209
|
-
setFeedback({
|
|
1210
|
-
tone: "danger",
|
|
1211
|
-
text: t("settings.test-error", "HubSpot unreachable — invalid or revoked key?")
|
|
1212
|
-
});
|
|
1213
|
-
} finally {
|
|
1214
|
-
setBusy(false);
|
|
1215
|
-
}
|
|
1216
|
-
};
|
|
1217
|
-
if (!settings) {
|
|
1218
|
-
return /* @__PURE__ */ jsx(Box, { padding: 8, children: /* @__PURE__ */ jsx(Loader, { small: true, children: t("settings.loading", "Loading…") }) });
|
|
1219
|
-
}
|
|
1220
|
-
const sourceLabel = {
|
|
1221
|
-
settings: t("settings.source.settings", "set here"),
|
|
1222
|
-
config: t("settings.source.config", "config/plugins.ts"),
|
|
1223
|
-
env: t("settings.source.env", "environment variable")
|
|
1224
|
-
};
|
|
1225
|
-
return /* @__PURE__ */ jsx(Box, { padding: 8, children: /* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "stretch", gap: 6, children: [
|
|
1226
|
-
/* @__PURE__ */ jsxs(Flex, { direction: "column", alignItems: "flex-start", gap: 2, children: [
|
|
1227
|
-
/* @__PURE__ */ jsx(Typography, { variant: "alpha", children: "HubSpot" }),
|
|
1228
|
-
/* @__PURE__ */ jsx(Typography, { variant: "epsilon", textColor: "neutral600", children: t(
|
|
1229
|
-
"settings.subtitle",
|
|
1230
|
-
"The private app token used to read the portal's properties and validate form mappings."
|
|
1231
|
-
) })
|
|
1232
|
-
] }),
|
|
1233
|
-
/* @__PURE__ */ jsxs(Flex, { gap: 2, alignItems: "center", children: [
|
|
1234
|
-
/* @__PURE__ */ jsx(Badge, { active: settings.configured, children: settings.configured ? t("settings.configured", "Configured {hint}", { hint: settings.hint }) : t("settings.not-configured", "Not configured") }),
|
|
1235
|
-
settings.keySource ? /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: t("settings.source", "source: {source}", { source: sourceLabel[settings.keySource] }) }) : null
|
|
1236
|
-
] }),
|
|
1237
|
-
/* @__PURE__ */ jsx(Box, { maxWidth: "32rem", children: /* @__PURE__ */ jsxs(
|
|
1238
|
-
Field.Root,
|
|
1239
|
-
{
|
|
1240
|
-
name: "apiKey",
|
|
1241
|
-
hint: t(
|
|
1242
|
-
"settings.key.hint",
|
|
1243
|
-
"A key entered here overrides the ones from config/plugins.ts and HUBSPOT_API_KEY."
|
|
1244
|
-
),
|
|
1245
|
-
children: [
|
|
1246
|
-
/* @__PURE__ */ jsx(Field.Label, { children: t("settings.key.label", "Private app token") }),
|
|
1247
|
-
/* @__PURE__ */ jsx(
|
|
1248
|
-
Field.Input,
|
|
1249
|
-
{
|
|
1250
|
-
type: "password",
|
|
1251
|
-
value: apiKey,
|
|
1252
|
-
autoComplete: "off",
|
|
1253
|
-
placeholder: settings.configured ? t("settings.key.placeholder.set", "•••••••• (leave empty to keep)") : t("settings.key.placeholder.empty", "pat-eu1-…"),
|
|
1254
|
-
onChange: (e) => setApiKey(e.target.value)
|
|
1255
|
-
}
|
|
1256
|
-
),
|
|
1257
|
-
/* @__PURE__ */ jsx(Field.Hint, {})
|
|
1258
|
-
]
|
|
1259
|
-
}
|
|
1260
|
-
) }),
|
|
1261
|
-
/* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
|
|
1262
|
-
/* @__PURE__ */ jsx(Button, { onClick: save, loading: busy, disabled: !apiKey.trim(), children: t("settings.save", "Save") }),
|
|
1263
|
-
/* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: test, loading: busy, disabled: !settings.configured, children: t("settings.test", "Test connection") }),
|
|
1264
|
-
/* @__PURE__ */ jsx(
|
|
1265
|
-
Button,
|
|
1266
|
-
{
|
|
1267
|
-
variant: "danger-light",
|
|
1268
|
-
onClick: remove,
|
|
1269
|
-
loading: busy,
|
|
1270
|
-
disabled: settings.keySource !== "settings",
|
|
1271
|
-
children: t("settings.remove", "Remove")
|
|
1272
|
-
}
|
|
1273
|
-
)
|
|
1274
|
-
] }),
|
|
1275
|
-
feedback ? /* @__PURE__ */ jsx(
|
|
1276
|
-
Typography,
|
|
1277
|
-
{
|
|
1278
|
-
variant: "pi",
|
|
1279
|
-
textColor: feedback.tone === "success" ? "success600" : "danger600",
|
|
1280
|
-
children: feedback.text
|
|
1281
|
-
}
|
|
1282
|
-
) : null,
|
|
1283
|
-
/* @__PURE__ */ jsx(Box, { paddingTop: 4, children: /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: t(
|
|
1284
|
-
"settings.scopes",
|
|
1285
|
-
"The token needs the crm.schemas.contacts.read and crm.schemas.companies.read scopes to list properties. It is never returned to the browser: only its existence, its source and its last four characters are."
|
|
1286
|
-
) }) }),
|
|
1287
|
-
/* @__PURE__ */ jsx(AuditSection, { configured: settings.configured }),
|
|
1288
|
-
/* @__PURE__ */ jsx(FailuresSection, { configured: settings.configured })
|
|
1289
|
-
] }) });
|
|
1290
|
-
};
|
|
1291
1545
|
export {
|
|
1292
|
-
|
|
1546
|
+
Link as L,
|
|
1547
|
+
Routes as R,
|
|
1548
|
+
useSearchParams as a,
|
|
1549
|
+
useNavigate as b,
|
|
1550
|
+
Route as c,
|
|
1551
|
+
useParams as u
|
|
1293
1552
|
};
|