@gen3/toolsff 0.12.42 → 0.12.43

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.
@@ -37,7 +37,7 @@ function normalizeRoute(route) {
37
37
  if (r.length > 1) r = r.replace(/\/$/, '');
38
38
  return r;
39
39
  }
40
- // ✅ Convert Next.js pages-style dynamic segments to middleware matcher syntax
40
+ // ✅ Convert Next.js pages-style dynamic segments to proxy matcher syntax
41
41
  function routeToMiddlewareMatcher(route) {
42
42
  // route examples:
43
43
  // "/Explorer/[configId]" -> "/Explorer/:configId"
@@ -94,47 +94,47 @@ function getMatcherFromAuthConfig(authConfig) {
94
94
  const excluded = new Set(DEFAULT_EXCLUDED_ROUTES.map(normalizeRoute));
95
95
  return normalizedRoutes.filter((r)=>!excluded.has(r));
96
96
  }
97
- // ✅ Generates the actual Next middleware entry file with literal matcher
97
+ // ✅ Generates the actual Next proxy entry file with literal matcher
98
98
  function writeGeneratedMiddlewareEntryTs(matcher, opts = {}) {
99
- const outputFile = path.resolve(opts.outputFile || './src/middleware.ts');
100
- const body = `// @generated by tools/scanSitePaths.ts\n` + `// Do not edit manually. Edit src/middleware-impl.ts instead.\n` + `export { middleware } from './middleware-impl';\n\n` + `export const config = {\n` + ` matcher: ${JSON.stringify(matcher, null, 2)},\n` + `};\n`;
101
- console.log(`Writing generated middleware entry to ${outputFile}`);
99
+ const outputFile = path.resolve(opts.outputFile || './src/proxy.ts');
100
+ const body = `// @generated by tools/scanSitePaths.ts\n` + `// Do not edit manually. Edit src/proxy-impl.ts instead.\n` + `export { proxy } from './proxy-impl';\n\n` + `export const config = {\n` + ` matcher: ${JSON.stringify(matcher, null, 2)},\n` + `};\n`;
101
+ console.log(`Writing generated proxy entry to ${outputFile}`);
102
102
  fs.mkdirSync(path.dirname(outputFile), {
103
103
  recursive: true
104
104
  });
105
105
  fs.writeFileSync(outputFile, body);
106
106
  }
107
107
  /**
108
- * Configures and generates middleware route matchers based on authentication and routing requirements.
108
+ * Configures and generates proxy route matchers based on authentication and routing requirements.
109
109
  *
110
- * The function determines the set of middleware routes based on the authentication configuration and
111
- * whether all pages require login. It generates appropriate route matchers for middleware processing
110
+ * The function determines the set of proxy routes based on the authentication configuration and
111
+ * whether all pages require login. It generates appropriate route matchers for proxy processing
112
112
  * and writes the resulting matchers to a TypeScript file for use in the application.
113
113
  *
114
114
  * @param {boolean} [useScanAllPaths=false] - A flag to determine whether to include all application routes
115
- * in the middleware path matcher. If true, all application routes
115
+ * in the proxy path matcher. If true, all application routes
116
116
  * are scanned and included; otherwise, specific routes from the
117
117
  * authentication configuration are considered.
118
- * @param forceMatchAll - set to true to force all routes to be matched by the middleware.
118
+ * @param forceMatchAll - set to true to force all routes to be matched by the proxy.
119
119
  */ const createMiddlewareRoutes = (useScanAllPaths = false, forceMatchAll = false)=>{
120
120
  const authConfig = loadAuthConfig();
121
121
  const allPagesRequireLogin = authConfig?.routes?.['*']?.loginRequired;
122
122
  let routes;
123
123
  if (allPagesRequireLogin || forceMatchAll) {
124
- console.log('All pages require login. Adding all routes to middleware path matcher.');
124
+ console.log('All pages require login. Adding all routes to proxy path matcher.');
125
125
  routes = useScanAllPaths ? getPagesRoutes() : []; // setting to [] will cause the matcher to be set below
126
126
  } else {
127
- console.log('Some pages require login. Adding authz routes to middleware path matcher.');
127
+ console.log('Some pages require login. Adding authz routes to proxy path matcher.');
128
128
  routes = getMatcherFromAuthConfig(authConfig);
129
129
  }
130
- // ✅ Convert to valid middleware matcher patterns
130
+ // ✅ Convert to valid proxy matcher patterns
131
131
  let matcher = (routes || []).map(routeToMiddlewareMatcher);
132
132
  if (matcher.length === 0) {
133
133
  matcher = [
134
134
  '/((?!_next/static|_next/image|_next/data|Login|api|403|404|no-workspace-access|favicon.ico|.*\\.ico$|.*\\.png$|.*\\.jpg$|.*\\.svg$|.*\\.json$).*)'
135
135
  ];
136
136
  }
137
- console.log(`middleware matcher entries:\n${matcher.join('\n')}`);
137
+ console.log(`proxy matcher entries:\n${matcher.join('\n')}`);
138
138
  writeGeneratedMiddlewareEntryTs(matcher);
139
139
  };
140
140
  function main() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gen3/toolsff",
3
- "version": "0.12.42",
3
+ "version": "0.12.43",
4
4
  "description": "tools for processing Gen3 commons content: color theme, icons, sharedFilters",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -48,5 +48,5 @@
48
48
  "axios": "^1.8.2"
49
49
  }
50
50
  },
51
- "gitHead": "99bb82f01ddae8d8df7b9e2b7950e4748d1c600c"
51
+ "gitHead": "8948283d154e2a56a7dbc0b4218cc187c293485e"
52
52
  }