@@ -6,119 +6,152 @@ type RedirectRule = {
66 from : string | string [ ] ;
77} ;
88
9- export const redirects : RedirectRule [ ] = [
10- // Operations API
11- { from : '/developers/operations-api/utilities' , to : '/developers/operations-api/system-operations' } ,
9+ // Function to generate redirects with the appropriate base path
10+ export function generateRedirects ( basePath : string ) : RedirectRule [ ] {
11+ // Helper to add base path to a route
12+ const withBase = ( path : string ) => `${ basePath } ${ path } ` ;
1213
13- // Installation paths
14- { from : '/install-harperdb' , to : '/deployments/install-harper/' } ,
15- { from : '/install-harperdb/linux' , to : '/deployments/install-harper/linux' } ,
16- { from : '/install-harperdb/other' , to : '/deployments/install-harper/' } ,
17- { from : '/install-harperdb/docker' , to : '/deployments/install-harper/' } ,
18- { from : '/install-harperdb/mac' , to : '/deployments/install-harper/' } ,
19- { from : '/install-harperdb/windows' , to : '/deployments/install-harper/' } ,
20- { from : '/install-harperdb/linux-quickstart' , to : '/deployments/install-harper/linux' } ,
21- { from : '/install-harperdb/offline' , to : '/deployments/install-harper/' } ,
22- { from : '/install-harperdb/node-ver-requirement' , to : '/deployments/install-harper/' } ,
23- { from : '/deployments/install-harperdb' , to : '/deployments/install-harper/' } ,
24- { from : '/deployments/install-harperdb/linux' , to : '/deployments/install-harper/linux' } ,
25-
26- // Harper Studio (old HarperDB Studio paths)
27- { from : '/harperdb-studio' , to : '/administration/harper-studio/' } ,
28- { from : '/harperdb-studio/create-account' , to : '/administration/harper-studio/create-account' } ,
29- { from : '/harperdb-studio/login-password-reset' , to : '/administration/harper-studio/login-password-reset' } ,
30- { from : [ '/harperdb-studio/resources' , '/administration/harper-studio/resources' ] , to : '/administration/harper-studio/' } ,
31- { from : '/harperdb-studio/organizations' , to : '/administration/harper-studio/organizations' } ,
32- { from : '/harperdb-studio/instances' , to : '/administration/harper-studio/instances' } ,
33- { from : '/harperdb-studio/query-instance-data' , to : '/administration/harper-studio/query-instance-data' } ,
34- { from : '/harperdb-studio/manage-schemas-browse-data' , to : '/administration/harper-studio/manage-databases-browse-data' } ,
35- { from : [ '/harperdb-studio/manage-charts' , '/administration/harper-studio/manage-charts' ] , to : '/administration/harper-studio/query-instance-data' } ,
36- { from : '/harperdb-studio/manage-clustering' , to : '/administration/harper-studio/manage-replication' } ,
37- { from : '/harperdb-studio/manage-instance-users' , to : '/administration/harper-studio/manage-instance-users' } ,
38- { from : '/harperdb-studio/manage-instance-roles' , to : '/administration/harper-studio/manage-instance-users' } ,
39- { from : '/harperdb-studio/manage-functions' , to : '/administration/harper-studio/manage-applications' } ,
40- { from : '/harperdb-studio/instance-metrics' , to : '/administration/harper-studio/instance-metrics' } ,
41- { from : '/harperdb-studio/instance-configuration' , to : '/administration/harper-studio/instance-configuration' } ,
42- { from : '/harperdb-studio/enable-mixed-content' , to : '/administration/harper-studio/enable-mixed-content' } ,
43-
44- // Harper Cloud (old HarperDB Cloud paths)
45- { from : '/harperdb-cloud' , to : '/deployments/harper-cloud/' } ,
46-
47- // Security
48- { from : '/security' , to : '/developers/security/' } ,
49- { from : '/security/jwt-auth' , to : '/developers/security/jwt-auth' } ,
50- { from : '/security/basic-auth' , to : '/developers/security/basic-auth' } ,
51- { from : '/security/configuration' , to : '/developers/security/configuration' } ,
52- { from : '/security/users-and-roles' , to : '/developers/security/users-and-roles' } ,
53-
54- // Custom Functions → Applications
55- { from : '/custom-functions' , to : '/developers/applications/' } ,
56- { from : '/custom-functions/define-routes' , to : '/developers/applications/define-routes' } ,
57- { from : [ '/custom-functions/using-npm-git' , '/developers/custom-functions/create-project' ] , to : '/developers/applications/' } ,
58- { from : '/custom-functions/custom-functions-operations' , to : '/developers/operations-api/' } ,
59- { from : '/custom-functions/debugging-custom-function' , to : '/developers/applications/debugging' } ,
60- { from : '/custom-functions/example-projects' , to : '/developers/applications/example-projects' } ,
61-
62- // Add-ons and SDKs
63- { from : '/add-ons-and-sdks' , to : '/developers/applications/' } ,
64- { from : '/add-ons-and-sdks/google-data-studio' , to : '/developers/miscellaneous/google-data-studio' } ,
65-
66- // SQL Guide
67- { from : '/sql-guide' , to : '/developers/sql-guide/' } ,
68-
69- // CLI
70- { from : '/harperdb-cli' , to : '/deployments/harper-cli' } ,
71- { from : '/deployments/harperdb-cli' , to : '/deployments/harper-cli' } ,
72-
73- // Top-level paths
74- { from : '/configuration' , to : '/deployments/configuration' } ,
75- { from : '/logging' , to : '/administration/logging/standard-logging' } ,
76- { from : '/transaction-logging' , to : '/administration/logging/transaction-logging' } ,
77- { from : '/audit-logging' , to : '/administration/logging/audit-logging' } ,
78- { from : '/jobs' , to : '/administration/jobs' } ,
79- { from : '/upgrade-hdb-instance' , to : '/deployments/upgrade-hdb-instance' } ,
80- { from : '/reference' , to : '/technical-details/reference/' } ,
81- { from : '/operations-api' , to : '/developers/operations-api/' } ,
82- { from : '/rest' , to : '/developers/rest' } ,
83- { from : '/api' , to : '/developers/operations-api/' } ,
84-
85- // File rename redirect
86- { from : '/administration/logging/logging' , to : '/administration/logging/standard-logging' } ,
87- ] ;
14+ return [
15+ // Operations API
16+ { from : withBase ( '/developers/operations-api/utilities' ) , to : withBase ( '/developers/operations-api/system-operations' ) } ,
17+
18+ // Installation paths
19+ { from : withBase ( '/install-harperdb' ) , to : withBase ( '/deployments/install-harper/' ) } ,
20+ { from : withBase ( '/install-harperdb/linux' ) , to : withBase ( '/deployments/install-harper/linux' ) } ,
21+ { from : withBase ( '/install-harperdb/other' ) , to : withBase ( '/deployments/install-harper/' ) } ,
22+ { from : withBase ( '/install-harperdb/docker' ) , to : withBase ( '/deployments/install-harper/' ) } ,
23+ { from : withBase ( '/install-harperdb/mac' ) , to : withBase ( '/deployments/install-harper/' ) } ,
24+ { from : withBase ( '/install-harperdb/windows' ) , to : withBase ( '/deployments/install-harper/' ) } ,
25+ { from : withBase ( '/install-harperdb/linux-quickstart' ) , to : withBase ( '/deployments/install-harper/linux' ) } ,
26+ { from : withBase ( '/install-harperdb/offline' ) , to : withBase ( '/deployments/install-harper/' ) } ,
27+ { from : withBase ( '/install-harperdb/node-ver-requirement' ) , to : withBase ( '/deployments/install-harper/' ) } ,
28+ { from : withBase ( '/deployments/install-harperdb' ) , to : withBase ( '/deployments/install-harper/' ) } ,
29+ { from : withBase ( '/deployments/install-harperdb/linux' ) , to : withBase ( '/deployments/install-harper/linux' ) } ,
30+
31+ // Harper Studio (old HarperDB Studio paths)
32+ { from : withBase ( '/harperdb-studio' ) , to : withBase ( '/administration/harper-studio/' ) } ,
33+ { from : withBase ( '/harperdb-studio/create-account' ) , to : withBase ( '/administration/harper-studio/create-account' ) } ,
34+ { from : withBase ( '/harperdb-studio/login-password-reset' ) , to : withBase ( '/administration/harper-studio/login-password-reset' ) } ,
35+ { from : [ withBase ( '/harperdb-studio/resources' ) , withBase ( '/administration/harper-studio/resources' ) ] , to : withBase ( '/administration/harper-studio/' ) } ,
36+ { from : withBase ( '/harperdb-studio/organizations' ) , to : withBase ( '/administration/harper-studio/organizations' ) } ,
37+ { from : withBase ( '/harperdb-studio/instances' ) , to : withBase ( '/administration/harper-studio/instances' ) } ,
38+ { from : withBase ( '/harperdb-studio/query-instance-data' ) , to : withBase ( '/administration/harper-studio/query-instance-data' ) } ,
39+ { from : withBase ( '/harperdb-studio/manage-schemas-browse-data' ) , to : withBase ( '/administration/harper-studio/manage-databases-browse-data' ) } ,
40+ { from : [ withBase ( '/harperdb-studio/manage-charts' ) , withBase ( '/administration/harper-studio/manage-charts' ) ] , to : withBase ( '/administration/harper-studio/query-instance-data' ) } ,
41+ { from : withBase ( '/harperdb-studio/manage-clustering' ) , to : withBase ( '/administration/harper-studio/manage-replication' ) } ,
42+ { from : withBase ( '/harperdb-studio/manage-instance-users' ) , to : withBase ( '/administration/harper-studio/manage-instance-users' ) } ,
43+ { from : withBase ( '/harperdb-studio/manage-instance-roles' ) , to : withBase ( '/administration/harper-studio/manage-instance-users' ) } ,
44+ { from : withBase ( '/harperdb-studio/manage-functions' ) , to : withBase ( '/administration/harper-studio/manage-applications' ) } ,
45+ { from : withBase ( '/harperdb-studio/instance-metrics' ) , to : withBase ( '/administration/harper-studio/instance-metrics' ) } ,
46+ { from : withBase ( '/harperdb-studio/instance-configuration' ) , to : withBase ( '/administration/harper-studio/instance-configuration' ) } ,
47+ { from : withBase ( '/harperdb-studio/enable-mixed-content' ) , to : withBase ( '/administration/harper-studio/enable-mixed-content' ) } ,
48+
49+ // Harper Cloud (old HarperDB Cloud paths)
50+ { from : withBase ( '/harperdb-cloud' ) , to : withBase ( '/deployments/harper-cloud/' ) } ,
51+
52+ // Security
53+ { from : withBase ( '/security' ) , to : withBase ( '/developers/security/' ) } ,
54+ { from : withBase ( '/security/jwt-auth' ) , to : withBase ( '/developers/security/jwt-auth' ) } ,
55+ { from : withBase ( '/security/basic-auth' ) , to : withBase ( '/developers/security/basic-auth' ) } ,
56+ { from : withBase ( '/security/configuration' ) , to : withBase ( '/developers/security/configuration' ) } ,
57+ { from : withBase ( '/security/users-and-roles' ) , to : withBase ( '/developers/security/users-and-roles' ) } ,
58+
59+ // Custom Functions → Applications
60+ { from : withBase ( '/custom-functions' ) , to : withBase ( '/developers/applications/' ) } ,
61+ { from : withBase ( '/custom-functions/define-routes' ) , to : withBase ( '/developers/applications/define-routes' ) } ,
62+ { from : [ withBase ( '/custom-functions/using-npm-git' ) , withBase ( '/developers/custom-functions/create-project' ) ] , to : withBase ( '/developers/applications/' ) } ,
63+ { from : withBase ( '/custom-functions/custom-functions-operations' ) , to : withBase ( '/developers/operations-api/' ) } ,
64+ { from : withBase ( '/custom-functions/debugging-custom-function' ) , to : withBase ( '/developers/applications/debugging' ) } ,
65+ { from : withBase ( '/custom-functions/example-projects' ) , to : withBase ( '/developers/applications/example-projects' ) } ,
66+
67+ // Add-ons and SDKs
68+ { from : withBase ( '/add-ons-and-sdks' ) , to : withBase ( '/developers/applications/' ) } ,
69+ { from : withBase ( '/add-ons-and-sdks/google-data-studio' ) , to : withBase ( '/developers/miscellaneous/google-data-studio' ) } ,
70+
71+ // SQL Guide
72+ { from : withBase ( '/sql-guide' ) , to : withBase ( '/developers/sql-guide/' ) } ,
73+
74+ // CLI
75+ { from : withBase ( '/harperdb-cli' ) , to : withBase ( '/deployments/harper-cli' ) } ,
76+ { from : withBase ( '/deployments/harperdb-cli' ) , to : withBase ( '/deployments/harper-cli' ) } ,
77+
78+ // Top-level paths
79+ { from : withBase ( '/configuration' ) , to : withBase ( '/deployments/configuration' ) } ,
80+ { from : withBase ( '/logging' ) , to : withBase ( '/administration/logging/standard-logging' ) } ,
81+ { from : withBase ( '/transaction-logging' ) , to : withBase ( '/administration/logging/transaction-logging' ) } ,
82+ { from : withBase ( '/audit-logging' ) , to : withBase ( '/administration/logging/audit-logging' ) } ,
83+ { from : withBase ( '/jobs' ) , to : withBase ( '/administration/jobs' ) } ,
84+ { from : withBase ( '/upgrade-hdb-instance' ) , to : withBase ( '/deployments/upgrade-hdb-instance' ) } ,
85+ { from : withBase ( '/reference' ) , to : withBase ( '/technical-details/reference/' ) } ,
86+ { from : withBase ( '/operations-api' ) , to : withBase ( '/developers/operations-api/' ) } ,
87+ { from : withBase ( '/rest' ) , to : withBase ( '/developers/rest' ) } ,
88+ { from : withBase ( '/api' ) , to : withBase ( '/developers/operations-api/' ) } ,
89+
90+ // File rename redirect
91+ { from : withBase ( '/administration/logging/logging' ) , to : withBase ( '/administration/logging/standard-logging' ) } ,
92+ ] ;
93+ }
94+
95+ // For backward compatibility, export a default set with empty base path
96+ export const redirects = generateRedirects ( '' ) ;
8897
8998// Function to create wildcard redirects for moved sections
90- export function createRedirects ( existingPath : string ) : string [ ] | undefined {
99+ // This handles dynamic redirects for paths not explicitly defined in the main redirect list
100+ export function createRedirects ( existingPath : string , basePath : string = '' ) : string [ ] | undefined {
91101 const redirects : string [ ] = [ ] ;
92102
93- // Handle wildcard redirects for paths with subpaths
94- if ( existingPath . startsWith ( '/administration/harper-studio/' ) ) {
95- const subpath = existingPath . replace ( '/administration/harper-studio/' , '' ) ;
96- if ( subpath ) { // Only add redirect if there's an actual subpath
97- redirects . push ( `/administration/harperdb-studio/${ subpath } ` ) ;
103+ // Only create wildcard redirects for paths that aren't already explicitly defined
104+ // Check if this is a path we handle with wildcard redirects
105+
106+ // Harper Studio - only for subpaths not already defined
107+ if ( existingPath . startsWith ( `${ basePath } /administration/harper-studio/` ) ) {
108+ const subpath = existingPath . replace ( `${ basePath } /administration/harper-studio/` , '' ) ;
109+ // Skip paths that are already explicitly redirected
110+ const explicitStudioPaths = [
111+ 'create-account' , 'login-password-reset' , 'organizations' , 'instances' ,
112+ 'query-instance-data' , 'manage-databases-browse-data' , 'manage-replication' ,
113+ 'manage-instance-users' , 'manage-applications' , 'instance-metrics' ,
114+ 'instance-configuration' , 'enable-mixed-content'
115+ ] ;
116+ if ( subpath && ! explicitStudioPaths . includes ( subpath ) ) {
117+ redirects . push ( `${ basePath } /administration/harperdb-studio/${ subpath } ` ) ;
98118 }
99119 }
100120
101- if ( existingPath . startsWith ( '/deployments/harper-cloud/' ) ) {
102- const subpath = existingPath . replace ( '/deployments/harper-cloud/' , '' ) ;
103- if ( subpath ) { // Only add redirect if there's an actual subpath
104- redirects . push ( `/harperdb-cloud/${ subpath } ` ) ;
105- redirects . push ( `/deployments/harperdb-cloud/${ subpath } ` ) ;
121+ // Harper Cloud - only for subpaths not already defined
122+ if ( existingPath . startsWith ( `${ basePath } /deployments/harper-cloud/` ) ) {
123+ const subpath = existingPath . replace ( `${ basePath } /deployments/harper-cloud/` , '' ) ;
124+ // The main harper-cloud redirect is explicit, only handle other subpaths
125+ if ( subpath ) {
126+ redirects . push ( `${ basePath } /deployments/harperdb-cloud/${ subpath } ` ) ;
106127 }
107128 }
108129
109- if ( existingPath . startsWith ( '/developers/clustering/' ) ) {
110- const subpath = existingPath . replace ( '/developers/clustering/' , '' ) ;
111- if ( subpath ) { // Only add redirect if there's an actual subpath
112- redirects . push ( `/clustering/${ subpath } ` ) ;
130+ // Install Harper - only for subpaths not already defined
131+ if ( existingPath . startsWith ( `${ basePath } /deployments/install-harper/` ) ) {
132+ const subpath = existingPath . replace ( `${ basePath } /deployments/install-harper/` , '' ) ;
133+ // Skip 'linux' as it's explicitly defined
134+ if ( subpath && subpath !== 'linux' ) {
135+ redirects . push ( `${ basePath } /deployments/install-harperdb/${ subpath } ` ) ;
113136 }
114137 }
115138
116- if ( existingPath . startsWith ( '/developers/sql-guide/' ) ) {
117- const subpath = existingPath . replace ( '/developers/sql-guide/' , '' ) ;
118- if ( subpath ) { // Only add redirect if there's an actual subpath
119- redirects . push ( `/sql-guide/${ subpath } ` ) ;
139+ // Custom Functions - handle subpaths
140+ if ( existingPath . startsWith ( `${ basePath } /developers/custom-functions/` ) ) {
141+ const subpath = existingPath . replace ( `${ basePath } /developers/custom-functions/` , '' ) ;
142+ // Skip paths that are explicitly defined
143+ const explicitCustomPaths = [ 'define-routes' , 'debugging-custom-function' , 'example-projects' ] ;
144+ if ( subpath && ! explicitCustomPaths . includes ( subpath ) ) {
145+ redirects . push ( `${ basePath } /custom-functions/${ subpath } ` ) ;
120146 }
121147 }
122148
149+ // Don't create wildcard redirects for these as they're all explicitly defined:
150+ // - /developers/security/* (all subpaths are explicit)
151+ // - /deployments/harper-cli (explicit)
152+ // - /developers/sql-guide/* (has explicit redirect)
153+ // - /developers/operations-api/* (has explicit redirects)
154+ // - /technical-details/reference/* (has explicit redirect)
155+
123156 return redirects . length > 0 ? redirects : undefined ;
124157}
0 commit comments