@fibery/url-utils 2.2.7 → 2.3.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/lib/routes.js CHANGED
@@ -1,14 +1,9 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.ROUTES_WITH_PRESERVED_UNDERSCORES_PATTERNS_LOOKUP = exports.ROUTES_WITH_PRESERVED_UNDERSCORES_LOOKUP = exports.AUX_ROUTES_PATTERNS = exports.AUX_ROUTES = exports.ORDERED_AUX_ROUTES = exports.ORDERED_COMMON_AUX_ROUTES = exports.PAGE_ROUTES = exports.ORDERED_PAGE_ROUTES = exports.isSettingsPage = exports.typeAccessTemplateSettingPage = exports.personalIntegrationSettingPage = exports.integrationSettingPage = exports.highlightTypeFieldEditPage = exports.highlightTypePage = exports.formsPublicPage = exports.appTypeModePageView = exports.appModePage = exports.appTypeModeGroupEditPage = exports.appTypeModeFieldEditPage = exports.appTypeModeAutomationSpecificPage = exports.appTypeModeAccessTemplatePage = exports.appTypeModeAutomationBasePage = exports.appTypeModeSubPage = exports.appTypeModePage = exports.specificObjectEditorViewLocator = exports.specificObjectUnknownObjectLocator = exports.deprecatedSpecificObjectEditorViewLocator = exports.specificObjectViewsCatalogViewLocator = exports.userAccessViewLocator = exports.appIndexViewLocator = void 0;
7
- const fromPairs_1 = __importDefault(require("lodash/fromPairs"));
8
- const locator_utils_1 = require("./locator-utils");
9
- const url_constants_1 = require("./url-constants");
1
+ import { escapeRegExpChar } from "./locator-utils.js";
2
+ import { formsUrlPrefix, publicUrlPrefix } from "./url-constants.js";
3
+ import fromPairs from "lodash/fromPairs.js";
4
+ //#region src/routes.ts
10
5
  const titleWithPublicIdLocatorPattern = `[^/=]+?-\\d+`;
11
- const transientIdPattern = "...".split("").map(locator_utils_1.escapeRegExpChar).join("");
6
+ const transientIdPattern = "...".split("").map(escapeRegExpChar).join("");
12
7
  const titleWithTransientIdLocatorPattern = `[^/]+?-${transientIdPattern}`;
13
8
  const transientIdLocatorPattern = transientIdPattern;
14
9
  const idLocatorPattern = `\\w{8}-\\w{4}-\\w{4}-\\w{4}-\\w{12}`;
@@ -20,166 +15,141 @@ const commentLocatorPattern = `comment=${publicIdLocatorPattern}`;
20
15
  const extendedCommentLocatorPattern = `parentComment=${publicIdLocatorPattern}&comment=${publicIdLocatorPattern}`;
21
16
  const anchorLocatorPattern = `anchor=${idLocatorPattern}`;
22
17
  const anchorWithTitleLocatorPattern = `anchor=${titleWithGuidLocatorPattern}`;
23
- const anchorWB = `anchor=wb-[^/]+`;
24
- const fieldLocatorPattern = `field=${idLocatorPattern}`;
25
- const scrollLocatorPattern = `${extendedCommentLocatorPattern}|${commentLocatorPattern}|${fieldLocatorPattern}|${anchorLocatorPattern}|${anchorWithTitleLocatorPattern}|${anchorWB}`;
26
- exports.appIndexViewLocator = "views";
27
- exports.userAccessViewLocator = "access";
28
- exports.specificObjectViewsCatalogViewLocator = "views";
29
- exports.deprecatedSpecificObjectEditorViewLocator = "edit";
30
- exports.specificObjectUnknownObjectLocator = "any";
31
- exports.specificObjectEditorViewLocator = null;
32
- exports.appTypeModePage = `/fibery/space/:appNamespace/:mode/:typeWithoutNamespace`;
33
- exports.appTypeModeSubPage = `/fibery/space/:appNamespace/:mode/:typeWithoutNamespace/:subPage`;
34
- exports.appTypeModeAutomationBasePage = `${exports.appTypeModeSubPage}/:automationType/:automationItemId`;
35
- exports.appTypeModeAccessTemplatePage = `${exports.appTypeModeSubPage}/access-templates/:accessTemplateId`;
36
- exports.appTypeModeAutomationSpecificPage = `${exports.appTypeModeAutomationBasePage}/:automationMode`;
37
- exports.appTypeModeFieldEditPage = `${exports.appTypeModeSubPage}/:fieldTitle/edit`;
38
- exports.appTypeModeGroupEditPage = `${exports.appTypeModeSubPage}/:typeId/members`;
39
- exports.appModePage = `/fibery/space/:appNamespace/:mode`;
40
- exports.appTypeModePageView = `${exports.appTypeModePage}/${exports.appIndexViewLocator}/:viewLocator(${viewLocatorPattern})`;
41
- exports.formsPublicPage = `${url_constants_1.formsUrlPrefix}/:formKey`;
42
- exports.highlightTypePage = "/fibery/settings/:subsection(highlights)/:typeWithoutNamespace";
43
- exports.highlightTypeFieldEditPage = `${exports.highlightTypePage}/fields/:fieldWithoutNamespace/edit`;
44
- exports.integrationSettingPage = "/fibery/settings/:subsection(integrations)/:templateId";
45
- exports.personalIntegrationSettingPage = "/fibery/settings/:subsection(personal-integrations)/:integrationId";
46
- exports.typeAccessTemplateSettingPage = "/fibery/settings/:subsection(database-access-templates)/:templateId";
18
+ const scrollLocatorPattern = `${extendedCommentLocatorPattern}|${commentLocatorPattern}|${`field=${idLocatorPattern}`}|${anchorLocatorPattern}|${anchorWithTitleLocatorPattern}|anchor=wb-[^/]+`;
19
+ const appIndexViewLocator = "views";
20
+ const userAccessViewLocator = "access";
21
+ const specificObjectViewsCatalogViewLocator = "views";
22
+ const deprecatedSpecificObjectEditorViewLocator = "edit";
23
+ const specificObjectUnknownObjectLocator = "any";
24
+ const specificObjectEditorViewLocator = null;
25
+ const appTypeModePage = `/fibery/space/:appNamespace/:mode/:typeWithoutNamespace`;
26
+ const appTypeModeSubPage = `/fibery/space/:appNamespace/:mode/:typeWithoutNamespace/:subPage`;
27
+ const appTypeModeAutomationBasePage = `${appTypeModeSubPage}/:automationType/:automationItemId`;
28
+ const appTypeModeAccessTemplatePage = `${appTypeModeSubPage}/access-templates/:accessTemplateId`;
29
+ const appTypeModeFormPage = `${appTypeModeSubPage}/form/:formId`;
30
+ const appTypeModeAutomationSpecificPage = `${appTypeModeAutomationBasePage}/:automationMode`;
31
+ const appTypeModeFieldEditPage = `${appTypeModeSubPage}/:fieldTitle/edit`;
32
+ const appTypeModeGroupEditPage = `${appTypeModeSubPage}/:typeId/members`;
33
+ const appModePage = `/fibery/space/:appNamespace/:mode`;
34
+ const appTypeModePageView = `${appTypeModePage}/${appIndexViewLocator}/:viewLocator(${viewLocatorPattern})`;
35
+ const formsPublicPage = `${formsUrlPrefix}/:formKey`;
36
+ const highlightTypePage = "/fibery/settings/:subsection(highlights)/:typeWithoutNamespace";
37
+ const highlightTypeFieldEditPage = `${highlightTypePage}/fields/:fieldWithoutNamespace/edit`;
38
+ const integrationSettingPage = "/fibery/settings/:subsection(integrations)/:templateId";
39
+ const personalIntegrationSettingPage = "/fibery/settings/:subsection(personal-integrations)/:integrationId";
40
+ const typeAccessTemplateSettingPage = "/fibery/settings/:subsection(database-access-templates)/:templateId";
47
41
  const settingsPage = ":page/settings";
48
42
  const appPage = ":page/app";
49
43
  const typePage = ":page/type";
50
- const settingsPages = new Set([settingsPage, appPage, typePage]);
44
+ const settingsPages = /* @__PURE__ */ new Set([
45
+ settingsPage,
46
+ appPage,
47
+ typePage
48
+ ]);
51
49
  const isSettingsPage = (page) => {
52
- if (!page) {
53
- return false;
54
- }
55
- return settingsPages.has(page);
50
+ if (!page) return false;
51
+ return settingsPages.has(page);
56
52
  };
57
- exports.isSettingsPage = isSettingsPage;
58
53
  const orderedRoutes = [
59
- [":page/apps-gallery", `/fibery/apps-gallery/:appCategory`],
60
- [":page/app", `/fibery/space/:appNamespace`],
61
- [":page/app-access", `/fibery/space/:appNamespace/access`],
62
- [":page/app-import", `/fibery/space/:appNamespace/import/:connectorId?/:mode?`],
63
- [":page/app-sync", `/fibery/space/:appNamespace/sync/:connectorId?/:mode?`],
64
- [":page/database-import", `/fibery/space/:appNamespace/database/:databaseName/import/:connectorId?`],
65
- [typePage, exports.appModePage],
66
- [":page/type-view", exports.appTypeModePageView],
67
- [typePage, exports.appTypeModeFieldEditPage],
68
- [typePage, exports.appTypeModeGroupEditPage],
69
- [typePage, exports.appTypeModeAutomationSpecificPage],
70
- [typePage, exports.appTypeModeAccessTemplatePage],
71
- [typePage, exports.appTypeModeAutomationBasePage],
72
- [typePage, exports.appTypeModeSubPage],
73
- [typePage, exports.appTypeModePage],
74
- [":page/schema", `/:appNamespace(fibery)/settings/domain`],
75
- [":page/schema", `/workspace-map`],
76
- [":page/me", `/:appNamespace(fibery)/me`],
77
- [settingsPage, exports.highlightTypePage],
78
- [settingsPage, exports.integrationSettingPage],
79
- [settingsPage, exports.highlightTypeFieldEditPage],
80
- [settingsPage, exports.personalIntegrationSettingPage],
81
- [settingsPage, exports.typeAccessTemplateSettingPage],
82
- [settingsPage, "/fibery/settings/:subsection"],
83
- [settingsPage, "/fibery/settings"],
84
- [
85
- ":page/app-view",
86
- `/:appNamespace/:viewLocator(${exports.appIndexViewLocator}|${viewLocatorPattern})/:scrollLocator(${scrollLocatorPattern})?`,
87
- ],
88
- [":page/favorite", `/favorites/:parts+`],
89
- [":page/audit-log", "/audit-log"],
90
- [":page/home", "/home"],
91
- [":page/activity-log", "/activity-log"],
92
- [":page/audit-soft-deleted-fields", "/audit-soft-deleted-fields"],
93
- [":page/global-search", "/search"],
94
- [":page/global-notifications", "/inbox"],
95
- [":page/desktop-app-redirect", "/desktop"],
96
- [":page/search", "/search/:id"],
97
- [":page/watchlist", "/watchlist"],
98
- [":page/ai-assistant", "/ai-assistant/:agentId"],
99
- [":page/shared-with-me", "/shared-with-me"],
100
- [":page/trash", "/trash"],
101
- [":page/trash-bin", "/trash-bin"],
102
- [":page/not-found", "/not-found"],
103
- [
104
- ":page/specific-object-view",
105
- [
106
- `/:appNamespace/:typeWithoutNamespace`,
107
- `:objectLocator(${exports.specificObjectUnknownObjectLocator}|${titleWithPublicIdLocatorPattern}|${publicIdLocatorPattern})`,
108
- `:viewLocator(${exports.specificObjectViewsCatalogViewLocator}|${exports.deprecatedSpecificObjectEditorViewLocator}|${viewLocatorPattern})?`,
109
- `:scrollLocator(${scrollLocatorPattern})?`,
110
- ].join("/"),
111
- ],
112
- [":page/public-form", `/forms/:formKey`],
113
- [":page/app-root", `/:appNamespace`],
114
- [":page/root", `/`],
115
- ];
116
- exports.ORDERED_PAGE_ROUTES = orderedRoutes
117
- .map(([page, route]) => [page, `${url_constants_1.publicUrlPrefix}${route === "/" ? "" : route}`])
118
- .concat(orderedRoutes);
119
- exports.PAGE_ROUTES = (0, fromPairs_1.default)(exports.ORDERED_PAGE_ROUTES);
120
- exports.ORDERED_COMMON_AUX_ROUTES = [
121
- [":aux/no-panel-support", `no-panel/:type`],
122
- [":aux/notifications", `notifications`],
123
- [":aux/not-found", "not-found"],
124
- [":aux/tutorial", `tutorial/:auxLocator(${auxLocatorPattern})/view`],
125
- [":aux/ai-assistant-history", `ai-assistant-history`],
126
- [":aux/ai-assistant", `ai-assistant/:agentId/:conversationId`],
127
- [":aux/ai-assistant", `ai-assistant/:agentId`],
128
- [":aux/user-access", `user-access/:userPublicId`],
129
- [":aux/user-group-access", `user-group-access/:auxTypeNamespace/:auxTypeName/:publicId`],
130
- [":aux/type-access-templates", `database-access-templates/:templateId`],
131
- [":aux/type-access-templates", `database-access-templates`],
132
- [":aux/type-access", `:auxTypeNamespace/:auxTypeName/type-access`],
133
- [":aux/type-object-editor", `:auxTypeNamespace/:auxTypeName/edit`],
134
- [":aux/type-object-editor-implicit-namespace", `:auxTypeName/edit`],
135
- [":aux/type-object-editor-for-composite-type", `:nsA/:nameA\\_:nsB/:nameB/edit`],
136
- [
137
- ":aux/app-view-with-context",
138
- `:appNamespace/views/:viewType/:viewLocator(${viewLocatorPattern})/context/:auxTypeNamespace/:auxTypeName/:auxLocator(${auxLocatorPattern})/:scrollLocator(${scrollLocatorPattern})?`,
139
- ],
140
- [
141
- ":aux/app-view",
142
- `:appNamespace/views/:viewType/:viewLocator(${viewLocatorPattern})/:scrollLocator(${scrollLocatorPattern})?`,
143
- ],
144
- [
145
- ":aux/object-editor",
146
- `:auxTypeNamespace/:auxTypeName/:auxLocator(${auxLocatorPattern})/:scrollLocator(${scrollLocatorPattern})?`,
147
- ],
148
- [
149
- ":aux/object-editor-implicit-namespace",
150
- `:auxTypeName/:auxLocator(${auxLocatorPattern})/:scrollLocator(${scrollLocatorPattern})?`,
151
- ],
152
- [
153
- ":aux/object-editor-for-composite-type",
154
- `:nsA/:nameA\\_:nsB/:nameB/:auxLocator(${auxLocatorPattern})/:scrollLocator(${scrollLocatorPattern})?`,
155
- ],
156
- [":aux/gallery-app", `gallery/:auxAppNamespace`],
157
- [":aux/search", `search/:id`],
158
- [":aux/shared-with-me", `shared-with-me`],
159
- [":aux/import", `import`],
160
- [":aux/app-export", `app-export/:auxAppNamespace/share`],
161
- [":aux/install-integration-app", `app-sync/:auxAppNamespace`],
162
- [":aux/users-invite", `invite-users`],
163
- [":aux/share-workspace", "share-workspace"],
164
- [":aux/ai-create-space", "ai-create-space"],
165
- [":aux/ai-create-view", "ai-create-view/:appNamespace"],
166
- [":aux/ai-update-view-filter", `ai-update-view-filter-:viewId(${idLocatorPattern})`],
167
- [":aux/book-demo", `book-demo`],
168
- [":aux/create-entity", `create-entity`],
54
+ [":page/apps-gallery", `/fibery/apps-gallery/:appCategory`],
55
+ [":page/app", `/fibery/space/:appNamespace`],
56
+ [":page/app-access", `/fibery/space/:appNamespace/access`],
57
+ [":page/app-import", `/fibery/space/:appNamespace/import/:connectorId?/:mode?`],
58
+ [":page/app-sync", `/fibery/space/:appNamespace/sync/:connectorId?/:mode?`],
59
+ [":page/database-import", `/fibery/space/:appNamespace/database/:databaseName/import/:connectorId?`],
60
+ [typePage, appModePage],
61
+ [":page/type-view", appTypeModePageView],
62
+ [typePage, appTypeModeFieldEditPage],
63
+ [typePage, appTypeModeGroupEditPage],
64
+ [typePage, appTypeModeAutomationSpecificPage],
65
+ [typePage, appTypeModeAccessTemplatePage],
66
+ [typePage, appTypeModeFormPage],
67
+ [typePage, appTypeModeAutomationBasePage],
68
+ [typePage, appTypeModeSubPage],
69
+ [typePage, appTypeModePage],
70
+ [":page/schema", `/:appNamespace(fibery)/settings/domain`],
71
+ [":page/schema", `/workspace-map`],
72
+ [":page/me", `/:appNamespace(fibery)/me`],
73
+ [settingsPage, highlightTypePage],
74
+ [settingsPage, integrationSettingPage],
75
+ [settingsPage, highlightTypeFieldEditPage],
76
+ [settingsPage, personalIntegrationSettingPage],
77
+ [settingsPage, typeAccessTemplateSettingPage],
78
+ [settingsPage, "/fibery/settings/:subsection"],
79
+ [settingsPage, "/fibery/settings"],
80
+ [":page/app-view", `/:appNamespace/:viewLocator(${appIndexViewLocator}|${viewLocatorPattern})/:scrollLocator(${scrollLocatorPattern})?`],
81
+ [":page/favorite", `/favorites/:parts+`],
82
+ [":page/audit-log", "/audit-log"],
83
+ [":page/home", "/home"],
84
+ [":page/activity", "/activity"],
85
+ [":page/activity-log", "/activity-log"],
86
+ [":page/audit-soft-deleted-fields", "/audit-soft-deleted-fields"],
87
+ [":page/global-search", "/search"],
88
+ [":page/global-notifications", "/inbox"],
89
+ [":page/desktop-app-redirect", "/desktop"],
90
+ [":page/search", "/search/:id"],
91
+ [":page/watchlist", "/watchlist"],
92
+ [":page/ai-assistant", "/ai-assistant/:agentId"],
93
+ [":page/shared-with-me", "/shared-with-me"],
94
+ [":page/trash", "/trash"],
95
+ [":page/trash-bin", "/trash-bin"],
96
+ [":page/not-found", "/not-found"],
97
+ [":page/specific-object-view", [
98
+ `/:appNamespace/:typeWithoutNamespace`,
99
+ `:objectLocator(any|${titleWithPublicIdLocatorPattern}|${publicIdLocatorPattern})`,
100
+ `:viewLocator(${specificObjectViewsCatalogViewLocator}|${deprecatedSpecificObjectEditorViewLocator}|${viewLocatorPattern})?`,
101
+ `:scrollLocator(${scrollLocatorPattern})?`
102
+ ].join("/")],
103
+ [":page/public-form", `/forms/:formKey`],
104
+ [":page/app-root", `/:appNamespace`],
105
+ [":page/root", `/`]
169
106
  ];
170
- exports.ORDERED_AUX_ROUTES = [
171
- ...exports.ORDERED_COMMON_AUX_ROUTES,
172
- [":aux/view-config-raw", "config/raw"],
107
+ const ORDERED_PAGE_ROUTES = orderedRoutes.map(([page, route]) => [page, `${publicUrlPrefix}${route === "/" ? "" : route}`]).concat(orderedRoutes);
108
+ const PAGE_ROUTES = fromPairs(ORDERED_PAGE_ROUTES);
109
+ const ORDERED_COMMON_AUX_ROUTES = [
110
+ [":aux/no-panel-support", `no-panel/:type`],
111
+ [":aux/notifications", `notifications`],
112
+ [":aux/not-found", "not-found"],
113
+ [":aux/tutorial", `tutorial/:auxLocator(${auxLocatorPattern})/view`],
114
+ [":aux/ai-assistant-history", `ai-assistant-history`],
115
+ [":aux/ai-assistant", `ai-assistant/:agentId/:conversationId`],
116
+ [":aux/ai-assistant", `ai-assistant/:agentId`],
117
+ [":aux/user-access", `user-access/:userPublicId`],
118
+ [":aux/user-group-access", `user-group-access/:auxTypeNamespace/:auxTypeName/:publicId`],
119
+ [":aux/type-access-templates", `database-access-templates/:templateId`],
120
+ [":aux/type-access-templates", `database-access-templates`],
121
+ [":aux/type-access", `:auxTypeNamespace/:auxTypeName/type-access`],
122
+ [":aux/type-object-editor", `:auxTypeNamespace/:auxTypeName/edit`],
123
+ [":aux/type-object-editor-implicit-namespace", `:auxTypeName/edit`],
124
+ [":aux/type-object-editor-for-composite-type", `:nsA/:nameA\\_:nsB/:nameB/edit`],
125
+ [":aux/app-view-with-context", `:appNamespace/views/:viewType/:viewLocator(${viewLocatorPattern})/context/:auxTypeNamespace/:auxTypeName/:auxLocator(${auxLocatorPattern})/:scrollLocator(${scrollLocatorPattern})?`],
126
+ [":aux/app-view", `:appNamespace/views/:viewType/:viewLocator(${viewLocatorPattern})/:scrollLocator(${scrollLocatorPattern})?`],
127
+ [":aux/object-editor", `:auxTypeNamespace/:auxTypeName/:auxLocator(${auxLocatorPattern})/:scrollLocator(${scrollLocatorPattern})?`],
128
+ [":aux/object-editor-implicit-namespace", `:auxTypeName/:auxLocator(${auxLocatorPattern})/:scrollLocator(${scrollLocatorPattern})?`],
129
+ [":aux/object-editor-for-composite-type", `:nsA/:nameA\\_:nsB/:nameB/:auxLocator(${auxLocatorPattern})/:scrollLocator(${scrollLocatorPattern})?`],
130
+ [":aux/gallery-app", `gallery/:auxAppNamespace`],
131
+ [":aux/search", `search/:id`],
132
+ [":aux/shared-with-me", `shared-with-me`],
133
+ [":aux/import", `import`],
134
+ [":aux/app-export", `app-export/:auxAppNamespace/share`],
135
+ [":aux/install-integration-app", `app-sync/:auxAppNamespace`],
136
+ [":aux/users-invite", `invite-users`],
137
+ [":aux/share-workspace", "share-workspace"],
138
+ [":aux/ai-create-view", "ai-create-view/:appNamespace"],
139
+ [":aux/ai-update-view-filter", `ai-update-view-filter-:viewId(${idLocatorPattern})`],
140
+ [":aux/book-demo", `book-demo`],
141
+ [":aux/create-entity", `create-entity`]
173
142
  ];
174
- exports.AUX_ROUTES = (0, fromPairs_1.default)(exports.ORDERED_AUX_ROUTES);
175
- exports.AUX_ROUTES_PATTERNS = exports.ORDERED_AUX_ROUTES.map(([, pattern]) => pattern);
143
+ const ORDERED_AUX_ROUTES = [...ORDERED_COMMON_AUX_ROUTES, [":aux/view-config-raw", "config/raw"]];
144
+ const AUX_ROUTES = fromPairs(ORDERED_AUX_ROUTES);
145
+ const AUX_ROUTES_PATTERNS = ORDERED_AUX_ROUTES.map(([, pattern]) => pattern);
176
146
  const ROUTES_WITH_PRESERVED_UNDERSCORES = [
177
- // enums
178
- ":aux/type-object-editor-for-composite-type",
179
- ":aux/object-editor-for-composite-type",
180
- // other
181
- ":aux/upgrade-to-plan",
147
+ ":aux/type-object-editor-for-composite-type",
148
+ ":aux/object-editor-for-composite-type",
149
+ ":aux/upgrade-to-plan"
182
150
  ];
183
- const ROUTES_WITH_PRESERVED_UNDERSCORES_PATTERNS = exports.ORDERED_AUX_ROUTES.filter(([route]) => ROUTES_WITH_PRESERVED_UNDERSCORES.includes(route)).map(([, pattern]) => pattern);
184
- exports.ROUTES_WITH_PRESERVED_UNDERSCORES_LOOKUP = Object.fromEntries(ROUTES_WITH_PRESERVED_UNDERSCORES.map((x) => [x, true]));
185
- exports.ROUTES_WITH_PRESERVED_UNDERSCORES_PATTERNS_LOOKUP = Object.fromEntries(ROUTES_WITH_PRESERVED_UNDERSCORES_PATTERNS.map((x) => [x, true]));
151
+ const ROUTES_WITH_PRESERVED_UNDERSCORES_PATTERNS = ORDERED_AUX_ROUTES.filter(([route]) => ROUTES_WITH_PRESERVED_UNDERSCORES.includes(route)).map(([, pattern]) => pattern);
152
+ const ROUTES_WITH_PRESERVED_UNDERSCORES_LOOKUP = Object.fromEntries(ROUTES_WITH_PRESERVED_UNDERSCORES.map((x) => [x, true]));
153
+ const ROUTES_WITH_PRESERVED_UNDERSCORES_PATTERNS_LOOKUP = Object.fromEntries(ROUTES_WITH_PRESERVED_UNDERSCORES_PATTERNS.map((x) => [x, true]));
154
+ //#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 };
@@ -1,5 +1,9 @@
1
- export declare const sharingParamName = "sharing-key";
2
- export declare const publicParamName = "is-public";
3
- export declare const publicUrlPrefix = "/@public";
4
- export declare const formsUrlPrefix = "/@public/forms";
5
- export declare const formKeyParamName = "form-key";
1
+ //#region src/url-constants.d.ts
2
+ declare const sharingParamName = "sharing-key";
3
+ declare const publicParamName = "is-public";
4
+ declare const publicUrlPrefix = "/@public";
5
+ declare const formsUrlPrefix = "/@public/forms";
6
+ declare const formKeyParamName = "form-key";
7
+ declare const appsUrlPrefix = "/apps";
8
+ //#endregion
9
+ export { appsUrlPrefix, formKeyParamName, formsUrlPrefix, publicParamName, publicUrlPrefix, sharingParamName };
@@ -1,8 +1,9 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.formKeyParamName = exports.formsUrlPrefix = exports.publicUrlPrefix = exports.publicParamName = exports.sharingParamName = void 0;
4
- exports.sharingParamName = "sharing-key";
5
- exports.publicParamName = "is-public";
6
- exports.publicUrlPrefix = "/@public";
7
- exports.formsUrlPrefix = "/@public/forms";
8
- exports.formKeyParamName = "form-key";
1
+ //#region src/url-constants.ts
2
+ const sharingParamName = "sharing-key";
3
+ const publicParamName = "is-public";
4
+ const publicUrlPrefix = "/@public";
5
+ const formsUrlPrefix = "/@public/forms";
6
+ const formKeyParamName = "form-key";
7
+ const appsUrlPrefix = "/apps";
8
+ //#endregion
9
+ export { appsUrlPrefix, formKeyParamName, formsUrlPrefix, publicParamName, publicUrlPrefix, sharingParamName };
@@ -1,17 +1,22 @@
1
+ //#region src/workspaces.d.ts
1
2
  type WorkspaceSettings = {
2
- display_name: string | null;
3
- logo?: string | null;
4
- publicSharing?: {
5
- disabled: boolean;
6
- } | null;
7
- documentsDisabled?: boolean;
8
- custom_domain?: string | null;
3
+ display_name: string | null;
4
+ logo?: string | null;
5
+ publicSharing?: {
6
+ disabled: boolean;
7
+ } | null;
8
+ documentsDisabled?: boolean;
9
+ custom_domain?: string | null;
9
10
  };
10
- export type Workspace = {
11
- ui_settings: WorkspaceSettings | null;
12
- name: string;
11
+ type Workspace = {
12
+ ui_settings: WorkspaceSettings | null;
13
+ name: string;
14
+ id?: string;
15
+ role?: string;
13
16
  };
14
- export declare function getWorkspaceTitle(workspace: Workspace): string;
15
- export declare function isCurrentWorkspace(workspace: Workspace, hostname: string): boolean;
16
- export declare function getCurrentWorkspaceTitle(workspace: Workspace | null, hostname: string): string;
17
- export {};
17
+ declare function getWorkspaceTitle(workspace: Workspace): string;
18
+ declare function hostnameFromWorkspace(workspace: Workspace): string;
19
+ declare function isCurrentWorkspace(workspace: Workspace, hostname: string): boolean;
20
+ declare function getCurrentWorkspaceTitle(workspace: Workspace | null, hostname: string): string;
21
+ //#endregion
22
+ export { Workspace, getCurrentWorkspaceTitle, getWorkspaceTitle, hostnameFromWorkspace, isCurrentWorkspace };
package/lib/workspaces.js CHANGED
@@ -1,25 +1,24 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getWorkspaceTitle = getWorkspaceTitle;
4
- exports.isCurrentWorkspace = isCurrentWorkspace;
5
- exports.getCurrentWorkspaceTitle = getCurrentWorkspaceTitle;
1
+ //#region src/workspaces.ts
6
2
  const capitalizeFirstChar = (input) => {
7
- const str = input || "";
8
- return str ? str.charAt(0).toUpperCase() + str.slice(1) : str;
3
+ const str = input || "";
4
+ return str ? str.charAt(0).toUpperCase() + str.slice(1) : str;
9
5
  };
6
+ function withRolePostfix(title, role) {
7
+ return role ? `${title} (${role})` : title;
8
+ }
10
9
  function getWorkspaceTitle(workspace) {
11
- if (workspace.ui_settings?.display_name) {
12
- return workspace.ui_settings.display_name;
13
- }
14
- const titleMatches = workspace.name.match(/(.+?)\.fibery\..+/);
15
- const name = titleMatches ? titleMatches[1] : workspace.name;
16
- return name.split(`-`).map(capitalizeFirstChar).join(" ");
10
+ if (workspace.ui_settings?.display_name) return withRolePostfix(workspace.ui_settings.display_name, workspace.role);
11
+ const titleMatches = workspace.name.match(/(.+?)\.fibery\..+/);
12
+ return withRolePostfix((titleMatches ? titleMatches[1] : workspace.name).split(`-`).map(capitalizeFirstChar).join(" "), workspace.role);
13
+ }
14
+ function hostnameFromWorkspace(workspace) {
15
+ return workspace.name;
17
16
  }
18
17
  function isCurrentWorkspace(workspace, hostname) {
19
- return workspace.name === hostname || workspace.ui_settings?.custom_domain === hostname;
18
+ return hostnameFromWorkspace(workspace) === hostname || workspace.ui_settings?.custom_domain === hostname;
20
19
  }
21
20
  function getCurrentWorkspaceTitle(workspace, hostname) {
22
- return workspace
23
- ? getWorkspaceTitle(workspace)
24
- : hostname.split(".")[0].split("-").map(capitalizeFirstChar).join(" ");
21
+ return workspace ? getWorkspaceTitle(workspace) : hostname.split(".")[0].split("-").map(capitalizeFirstChar).join(" ");
25
22
  }
23
+ //#endregion
24
+ export { getCurrentWorkspaceTitle, getWorkspaceTitle, hostnameFromWorkspace, isCurrentWorkspace };
package/package.json CHANGED
@@ -1,48 +1,31 @@
1
1
  {
2
2
  "name": "@fibery/url-utils",
3
- "version": "2.2.7",
4
- "main": "lib/index.js",
5
- "browser": "index.ts",
3
+ "version": "2.3.1",
4
+ "license": "UNLICENSED",
6
5
  "files": [
7
- "/lib"
6
+ "lib"
8
7
  ],
8
+ "type": "module",
9
+ "sideEffects": false,
10
+ "main": "./lib/index.js",
11
+ "types": "./lib/index.d.ts",
9
12
  "exports": {
10
- ".": "./lib/index.js",
11
- "./*": "./lib/*.js"
12
- },
13
- "fiberyDevExports": {
14
- ".": "./index.ts",
15
- "./*": "./*.ts"
13
+ ".": {
14
+ "types": "./lib/index.d.ts",
15
+ "default": "./lib/index.js"
16
+ },
17
+ "./*": {
18
+ "types": "./lib/*.d.ts",
19
+ "default": "./lib/*.js"
20
+ }
16
21
  },
17
22
  "dependencies": {
18
- "path-to-regexp": "3.0.0"
19
- },
20
- "devDependencies": {
21
- "@types/jest": "30.0.0",
22
- "@types/lodash": "4.14.172",
23
- "@types/react-router-dom": "5.3.2",
24
- "@typescript-eslint/eslint-plugin": "8.54.0",
25
- "@typescript-eslint/parser": "8.54.0",
26
- "eslint": "9.39.2",
27
- "eslint-plugin-unicorn": "62.0.0",
28
- "jest": "30.2.0",
29
- "jest-circus": "30.2.0",
30
- "jest-junit": "16.0.0",
31
23
  "lodash": "4.17.21",
32
- "react": "18.3.1",
33
- "react-router-dom": "5.3.0",
34
- "typescript": "5.9.3",
35
- "@fibery/babel-preset": "7.4.2",
36
- "@fibery/eslint-config": "9.0.1"
24
+ "path-to-regexp": "3.0.0",
25
+ "react-router-dom": "5.3.4"
37
26
  },
38
27
  "peerDependencies": {
39
28
  "lodash": "4.17.21",
40
29
  "react-router-dom": "^5.3.0"
41
- },
42
- "scripts": {
43
- "test": "jest",
44
- "build": "rm -rf lib && tsc --project ./tsconfig.build.json",
45
- "test:ci": "jest --reporters=default --reporters=jest-junit",
46
- "lint": "eslint ."
47
30
  }
48
31
  }