@fibery/url-utils 2.3.1 → 2.3.3
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/lib/index.js +19 -6
- package/lib/parse-page-location.js +1 -1
- package/lib/routes.d.ts +2 -1
- package/lib/routes.js +3 -1
- package/lib/url-constants.d.ts +4 -1
- package/lib/url-constants.js +3 -1
- package/lib/workspaces.d.ts +3 -3
- package/package.json +1 -1
package/lib/index.js
CHANGED
|
@@ -15,13 +15,22 @@ const getFlagValue = (flag) => new URLSearchParams(window.location.search).get(f
|
|
|
15
15
|
const getSharingKey = () => {
|
|
16
16
|
return getFlagValue("sharing-key") || getFlagValue("sk");
|
|
17
17
|
};
|
|
18
|
+
const hasQueryParam = (url, key) => {
|
|
19
|
+
const queryStart = url.indexOf("?");
|
|
20
|
+
return queryStart !== -1 && new URLSearchParams(url.slice(queryStart + 1)).has(key);
|
|
21
|
+
};
|
|
18
22
|
const appendSharingKey = (url, sharingKey = getSharingKey()) => {
|
|
19
23
|
if (!url) return url || "";
|
|
24
|
+
const [location] = url.split("#");
|
|
25
|
+
if (hasQueryParam(location, "sharing-key")) return url;
|
|
20
26
|
return appendQueryParameter(url, sharingParamName, sharingKey);
|
|
21
27
|
};
|
|
22
28
|
const appendIsPublicParam = (url) => {
|
|
23
|
-
if (isPublicSpaceMode)
|
|
24
|
-
|
|
29
|
+
if (isPublicSpaceMode) {
|
|
30
|
+
const [location] = url.split("#");
|
|
31
|
+
if (hasQueryParam(location, "is-public")) return url;
|
|
32
|
+
return appendQueryParameter(url, publicParamName, "1");
|
|
33
|
+
} else return url;
|
|
25
34
|
};
|
|
26
35
|
const signedFileUrl = (url) => {
|
|
27
36
|
return url?.startsWith("/api/files/") && !url?.startsWith("/api/files/r/") ? url.replace("/api/files", "/api/files/r") : url;
|
|
@@ -71,11 +80,15 @@ const createPureFiberyEntityUrlMatcher = ({ ownHost }) => (originalUrl, matchUse
|
|
|
71
80
|
if (typeName === "fibery/user" && !matchUserAsWell) return null;
|
|
72
81
|
let publicId = null;
|
|
73
82
|
let context = void 0;
|
|
74
|
-
if (page === ":page/specific-object-view" && !params.viewLocator)
|
|
75
|
-
|
|
76
|
-
publicId = parseLocator(
|
|
83
|
+
if (page === ":page/specific-object-view" && !params.viewLocator) {
|
|
84
|
+
const objectOrViewLocator = String(params.objectLocator);
|
|
85
|
+
publicId = parseLocator(objectOrViewLocator).publicId;
|
|
86
|
+
} else if (params.viewLocator) {
|
|
87
|
+
const objectOrViewLocator = String(params.viewLocator);
|
|
88
|
+
publicId = parseLocator(objectOrViewLocator).publicId;
|
|
77
89
|
typeName = "fibery/view";
|
|
78
|
-
const
|
|
90
|
+
const objectLocator = String(params.objectLocator);
|
|
91
|
+
const contextEntityPublicId = parseLocator(objectLocator).publicId;
|
|
79
92
|
if (contextEntityPublicId && params.appNamespace && params.typeWithoutNamespace) context = {
|
|
80
93
|
contextEntityTypeName: `${params.appNamespace}/${params.typeWithoutNamespace}`,
|
|
81
94
|
contextEntityPublicId
|
|
@@ -23,7 +23,7 @@ function findPageMatch(maybeEncodedPath) {
|
|
|
23
23
|
const path = safeDecodeURIComponent(maybeEncodedPath);
|
|
24
24
|
const processedPath = decodeUnderscoresToSpaces(decodeDashesToSpaces(path));
|
|
25
25
|
return findTruthy(ORDERED_PAGE_ROUTES, ([page, route]) => {
|
|
26
|
-
const match = matchPath(processedPath, {
|
|
26
|
+
const match = matchPath(route === "/fibery/settings/:subsection(oauth-applications)/:applicationId" ? path : processedPath, {
|
|
27
27
|
path: route,
|
|
28
28
|
exact: true
|
|
29
29
|
});
|
package/lib/routes.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ declare const highlightTypePage = "/fibery/settings/:subsection(highlights)/:typ
|
|
|
20
20
|
declare const highlightTypeFieldEditPage = "/fibery/settings/:subsection(highlights)/:typeWithoutNamespace/fields/:fieldWithoutNamespace/edit";
|
|
21
21
|
declare const integrationSettingPage = "/fibery/settings/:subsection(integrations)/:templateId";
|
|
22
22
|
declare const personalIntegrationSettingPage = "/fibery/settings/:subsection(personal-integrations)/:integrationId";
|
|
23
|
+
declare const oauthApplicationSettingPage = "/fibery/settings/:subsection(oauth-applications)/:applicationId";
|
|
23
24
|
declare const typeAccessTemplateSettingPage = "/fibery/settings/:subsection(database-access-templates)/:templateId";
|
|
24
25
|
declare const isSettingsPage: (page?: string) => boolean;
|
|
25
26
|
declare const ORDERED_PAGE_ROUTES: Array<[string, string]>;
|
|
@@ -35,4 +36,4 @@ declare const ROUTES_WITH_PRESERVED_UNDERSCORES_PATTERNS_LOOKUP: {
|
|
|
35
36
|
[k: string]: boolean;
|
|
36
37
|
};
|
|
37
38
|
//#endregion
|
|
38
|
-
export { AUX_ROUTES, AUX_ROUTES_PATTERNS, ORDERED_AUX_ROUTES, ORDERED_COMMON_AUX_ROUTES, ORDERED_PAGE_ROUTES, PAGE_ROUTES, ROUTES_WITH_PRESERVED_UNDERSCORES_LOOKUP, ROUTES_WITH_PRESERVED_UNDERSCORES_PATTERNS_LOOKUP, appIndexViewLocator, appModePage, appTypeModeAccessTemplatePage, appTypeModeAutomationBasePage, appTypeModeAutomationSpecificPage, appTypeModeFieldEditPage, appTypeModeFormPage, appTypeModeGroupEditPage, appTypeModePage, appTypeModePageView, appTypeModeSubPage, deprecatedSpecificObjectEditorViewLocator, formsPublicPage, highlightTypeFieldEditPage, highlightTypePage, integrationSettingPage, isSettingsPage, personalIntegrationSettingPage, specificObjectEditorViewLocator, specificObjectUnknownObjectLocator, specificObjectViewsCatalogViewLocator, typeAccessTemplateSettingPage, userAccessViewLocator };
|
|
39
|
+
export { AUX_ROUTES, AUX_ROUTES_PATTERNS, ORDERED_AUX_ROUTES, ORDERED_COMMON_AUX_ROUTES, ORDERED_PAGE_ROUTES, PAGE_ROUTES, ROUTES_WITH_PRESERVED_UNDERSCORES_LOOKUP, ROUTES_WITH_PRESERVED_UNDERSCORES_PATTERNS_LOOKUP, appIndexViewLocator, appModePage, appTypeModeAccessTemplatePage, appTypeModeAutomationBasePage, appTypeModeAutomationSpecificPage, appTypeModeFieldEditPage, appTypeModeFormPage, appTypeModeGroupEditPage, appTypeModePage, appTypeModePageView, appTypeModeSubPage, deprecatedSpecificObjectEditorViewLocator, formsPublicPage, highlightTypeFieldEditPage, highlightTypePage, integrationSettingPage, isSettingsPage, oauthApplicationSettingPage, personalIntegrationSettingPage, specificObjectEditorViewLocator, specificObjectUnknownObjectLocator, specificObjectViewsCatalogViewLocator, typeAccessTemplateSettingPage, userAccessViewLocator };
|
package/lib/routes.js
CHANGED
|
@@ -37,6 +37,7 @@ const highlightTypePage = "/fibery/settings/:subsection(highlights)/:typeWithout
|
|
|
37
37
|
const highlightTypeFieldEditPage = `${highlightTypePage}/fields/:fieldWithoutNamespace/edit`;
|
|
38
38
|
const integrationSettingPage = "/fibery/settings/:subsection(integrations)/:templateId";
|
|
39
39
|
const personalIntegrationSettingPage = "/fibery/settings/:subsection(personal-integrations)/:integrationId";
|
|
40
|
+
const oauthApplicationSettingPage = "/fibery/settings/:subsection(oauth-applications)/:applicationId";
|
|
40
41
|
const typeAccessTemplateSettingPage = "/fibery/settings/:subsection(database-access-templates)/:templateId";
|
|
41
42
|
const settingsPage = ":page/settings";
|
|
42
43
|
const appPage = ":page/app";
|
|
@@ -74,6 +75,7 @@ const orderedRoutes = [
|
|
|
74
75
|
[settingsPage, integrationSettingPage],
|
|
75
76
|
[settingsPage, highlightTypeFieldEditPage],
|
|
76
77
|
[settingsPage, personalIntegrationSettingPage],
|
|
78
|
+
[settingsPage, oauthApplicationSettingPage],
|
|
77
79
|
[settingsPage, typeAccessTemplateSettingPage],
|
|
78
80
|
[settingsPage, "/fibery/settings/:subsection"],
|
|
79
81
|
[settingsPage, "/fibery/settings"],
|
|
@@ -152,4 +154,4 @@ const ROUTES_WITH_PRESERVED_UNDERSCORES_PATTERNS = ORDERED_AUX_ROUTES.filter(([r
|
|
|
152
154
|
const ROUTES_WITH_PRESERVED_UNDERSCORES_LOOKUP = Object.fromEntries(ROUTES_WITH_PRESERVED_UNDERSCORES.map((x) => [x, true]));
|
|
153
155
|
const ROUTES_WITH_PRESERVED_UNDERSCORES_PATTERNS_LOOKUP = Object.fromEntries(ROUTES_WITH_PRESERVED_UNDERSCORES_PATTERNS.map((x) => [x, true]));
|
|
154
156
|
//#endregion
|
|
155
|
-
export { AUX_ROUTES, AUX_ROUTES_PATTERNS, ORDERED_AUX_ROUTES, ORDERED_COMMON_AUX_ROUTES, ORDERED_PAGE_ROUTES, PAGE_ROUTES, ROUTES_WITH_PRESERVED_UNDERSCORES_LOOKUP, ROUTES_WITH_PRESERVED_UNDERSCORES_PATTERNS_LOOKUP, appIndexViewLocator, appModePage, appTypeModeAccessTemplatePage, appTypeModeAutomationBasePage, appTypeModeAutomationSpecificPage, appTypeModeFieldEditPage, appTypeModeFormPage, appTypeModeGroupEditPage, appTypeModePage, appTypeModePageView, appTypeModeSubPage, deprecatedSpecificObjectEditorViewLocator, formsPublicPage, highlightTypeFieldEditPage, highlightTypePage, integrationSettingPage, isSettingsPage, personalIntegrationSettingPage, specificObjectEditorViewLocator, specificObjectUnknownObjectLocator, specificObjectViewsCatalogViewLocator, typeAccessTemplateSettingPage, userAccessViewLocator };
|
|
157
|
+
export { AUX_ROUTES, AUX_ROUTES_PATTERNS, ORDERED_AUX_ROUTES, ORDERED_COMMON_AUX_ROUTES, ORDERED_PAGE_ROUTES, PAGE_ROUTES, ROUTES_WITH_PRESERVED_UNDERSCORES_LOOKUP, ROUTES_WITH_PRESERVED_UNDERSCORES_PATTERNS_LOOKUP, appIndexViewLocator, appModePage, appTypeModeAccessTemplatePage, appTypeModeAutomationBasePage, appTypeModeAutomationSpecificPage, appTypeModeFieldEditPage, appTypeModeFormPage, appTypeModeGroupEditPage, appTypeModePage, appTypeModePageView, appTypeModeSubPage, deprecatedSpecificObjectEditorViewLocator, formsPublicPage, highlightTypeFieldEditPage, highlightTypePage, integrationSettingPage, isSettingsPage, oauthApplicationSettingPage, personalIntegrationSettingPage, specificObjectEditorViewLocator, specificObjectUnknownObjectLocator, specificObjectViewsCatalogViewLocator, typeAccessTemplateSettingPage, userAccessViewLocator };
|
package/lib/url-constants.d.ts
CHANGED
|
@@ -5,5 +5,8 @@ declare const publicUrlPrefix = "/@public";
|
|
|
5
5
|
declare const formsUrlPrefix = "/@public/forms";
|
|
6
6
|
declare const formKeyParamName = "form-key";
|
|
7
7
|
declare const appsUrlPrefix = "/apps";
|
|
8
|
+
declare const publicAppsUrlPrefix = "/@public/apps";
|
|
9
|
+
declare const containerTypeParamName = "container-type";
|
|
10
|
+
type DocumentContainerType = "entity" | "comment" | "view" | "canvas-comment";
|
|
8
11
|
//#endregion
|
|
9
|
-
export { appsUrlPrefix, formKeyParamName, formsUrlPrefix, publicParamName, publicUrlPrefix, sharingParamName };
|
|
12
|
+
export { DocumentContainerType, appsUrlPrefix, containerTypeParamName, formKeyParamName, formsUrlPrefix, publicAppsUrlPrefix, publicParamName, publicUrlPrefix, sharingParamName };
|
package/lib/url-constants.js
CHANGED
|
@@ -5,5 +5,7 @@ const publicUrlPrefix = "/@public";
|
|
|
5
5
|
const formsUrlPrefix = "/@public/forms";
|
|
6
6
|
const formKeyParamName = "form-key";
|
|
7
7
|
const appsUrlPrefix = "/apps";
|
|
8
|
+
const publicAppsUrlPrefix = `${publicUrlPrefix}${appsUrlPrefix}`;
|
|
9
|
+
const containerTypeParamName = "container-type";
|
|
8
10
|
//#endregion
|
|
9
|
-
export { appsUrlPrefix, formKeyParamName, formsUrlPrefix, publicParamName, publicUrlPrefix, sharingParamName };
|
|
11
|
+
export { appsUrlPrefix, containerTypeParamName, formKeyParamName, formsUrlPrefix, publicAppsUrlPrefix, publicParamName, publicUrlPrefix, sharingParamName };
|
package/lib/workspaces.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
//#region src/workspaces.d.ts
|
|
2
2
|
type WorkspaceSettings = {
|
|
3
|
-
display_name
|
|
3
|
+
display_name?: string | null;
|
|
4
4
|
logo?: string | null;
|
|
5
5
|
publicSharing?: {
|
|
6
6
|
disabled: boolean;
|
|
@@ -9,9 +9,9 @@ type WorkspaceSettings = {
|
|
|
9
9
|
custom_domain?: string | null;
|
|
10
10
|
};
|
|
11
11
|
type Workspace = {
|
|
12
|
-
ui_settings: WorkspaceSettings
|
|
12
|
+
ui_settings: WorkspaceSettings;
|
|
13
13
|
name: string;
|
|
14
|
-
id?:
|
|
14
|
+
id?: number;
|
|
15
15
|
role?: string;
|
|
16
16
|
};
|
|
17
17
|
declare function getWorkspaceTitle(workspace: Workspace): string;
|