@webpieces/http-routing 0.4.731 → 0.4.732
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webpieces/http-routing",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.732",
|
|
4
4
|
"description": "Decorator-based routing with auto-wiring for WebPieces",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -22,9 +22,9 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@inversifyjs/binding-decorators": "1.1.5",
|
|
25
|
-
"@webpieces/core-context": "0.4.
|
|
26
|
-
"@webpieces/core-util": "0.4.
|
|
27
|
-
"@webpieces/gcp-identity": "0.4.
|
|
25
|
+
"@webpieces/core-context": "0.4.732",
|
|
26
|
+
"@webpieces/core-util": "0.4.732",
|
|
27
|
+
"@webpieces/gcp-identity": "0.4.732",
|
|
28
28
|
"inversify": "7.10.4",
|
|
29
29
|
"jsonwebtoken": "9.0.2",
|
|
30
30
|
"minimatch": "10.0.1"
|
package/src/FilterMatcher.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.FilterMatcher = void 0;
|
|
4
|
-
|
|
4
|
+
// Interop-resolved (issue #747) — NEVER `import { minimatch } from 'minimatch'` here; that named
|
|
5
|
+
// export does not exist on minimatch v3, which is what a hoisted-linker consumer can resolve to.
|
|
6
|
+
const MinimatchInterop_1 = require("./MinimatchInterop");
|
|
5
7
|
/**
|
|
6
8
|
* FilterMatcher - Matches filters to routes based on filepath patterns.
|
|
7
9
|
* Similar to Java SharedMatchUtil.findMatchingFilters().
|
|
@@ -43,7 +45,7 @@ class FilterMatcher {
|
|
|
43
45
|
// Normalize filepath for consistent matching
|
|
44
46
|
const normalizedPath = FilterMatcher.normalizeFilepath(controllerFilepath);
|
|
45
47
|
// Match using minimatch
|
|
46
|
-
if ((0,
|
|
48
|
+
if ((0, MinimatchInterop_1.minimatch)(normalizedPath, pattern)) {
|
|
47
49
|
matchingFilters.push({ filter, priority: definition.priority });
|
|
48
50
|
}
|
|
49
51
|
}
|
package/src/FilterMatcher.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FilterMatcher.js","sourceRoot":"","sources":["../../../../../packages/http/http-routing/src/FilterMatcher.ts"],"names":[],"mappings":";;;AAIA,
|
|
1
|
+
{"version":3,"file":"FilterMatcher.js","sourceRoot":"","sources":["../../../../../packages/http/http-routing/src/FilterMatcher.ts"],"names":[],"mappings":";;;AAIA,iGAAiG;AACjG,iGAAiG;AACjG,yDAA+C;AAO/C;;;;;;;;;;;;GAYG;AACH,MAAa,aAAa;IACtB;;;;;;OAMG;IACH,MAAM,CAAC,mBAAmB,CACtB,kBAAsC,EACtC,UAAmC;QAEnC,MAAM,eAAe,GAAoD,EAAE,CAAC;QAE5E,KAAK,MAAM,UAAU,IAAI,UAAU,EAAE,CAAC;YAClC,MAAM,OAAO,GAAG,UAAU,CAAC,eAAe,CAAC;YAC3C,MAAM,MAAM,GAAG,UAAU,CAAC,MAAoB,CAAC;YAE/C,4DAA4D;YAC5D,IAAI,OAAO,KAAK,GAAG,EAAE,CAAC;gBAClB,eAAe,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAC;gBAChE,SAAS;YACb,CAAC;YAED,yDAAyD;YACzD,IAAI,CAAC,kBAAkB,EAAE,CAAC;gBACtB,IAAI,OAAO,KAAK,MAAM,EAAE,CAAC;oBACrB,eAAe,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAC;gBACpE,CAAC;gBACD,SAAS;YACb,CAAC;YAED,6CAA6C;YAC7C,MAAM,cAAc,GAAG,aAAa,CAAC,iBAAiB,CAAC,kBAAkB,CAAC,CAAC;YAE3E,wBAAwB;YACxB,IAAI,IAAA,4BAAS,EAAC,cAAc,EAAE,OAAO,CAAC,EAAE,CAAC;gBACrC,eAAe,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,CAAC,QAAQ,EAAE,CAAC,CAAC;YACpE,CAAC;QACL,CAAC;QAED,mCAAmC;QACnC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,GAAG,CAAC,CAAC,QAAQ,CAAC,CAAC;QAExD,OAAO,eAAe,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACtD,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CAAC,iBAAiB,CAAC,QAAgB;QACrC,OAAO,QAAQ;aACV,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,yCAAyC;aAC7D,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC,sBAAsB;IACrD,CAAC;CACJ;AA5DD,sCA4DC","sourcesContent":["import { Filter } from '@webpieces/core-util';\nimport { WpResponse } from './WpResponse';\nimport { MethodMeta } from './MethodMeta';\nimport { FilterDefinition } from './WebAppMeta';\n// Interop-resolved (issue #747) — NEVER `import { minimatch } from 'minimatch'` here; that named\n// export does not exist on minimatch v3, which is what a hoisted-linker consumer can resolve to.\nimport { minimatch } from './MinimatchInterop';\n\n/**\n * Type alias for HTTP filters that work with MethodMeta and ResponseWrapper.\n */\nexport type HttpFilter = Filter<MethodMeta, WpResponse<unknown>>;\n\n/**\n * FilterMatcher - Matches filters to routes based on filepath patterns.\n * Similar to Java SharedMatchUtil.findMatchingFilters().\n *\n * Responsibilities:\n * 1. Filter based on filepath glob pattern matching\n * 2. Sort matching filters by priority (higher first)\n *\n * Differences from Java:\n * - Uses glob patterns instead of regex\n * - Only matches filepaths (no URL path or HTTPS filtering yet)\n * - Simpler API focused on one responsibility\n */\nexport class FilterMatcher {\n /**\n * Find filters that match the given controller filepath.\n *\n * @param controllerFilepath - The filepath of the controller source file\n * @param allFilters - All registered filters with their definitions\n * @returns Array of matching filters, sorted by priority (highest first)\n */\n static findMatchingFilters(\n controllerFilepath: string | undefined,\n allFilters: Array<FilterDefinition>,\n ): HttpFilter[] {\n const matchingFilters: Array<{ filter: HttpFilter; priority: number }> = [];\n\n for (const definition of allFilters) {\n const pattern = definition.filepathPattern;\n const filter = definition.filter as HttpFilter;\n\n // Special case: '*' matches all controllers (global filter)\n if (pattern === '*') {\n matchingFilters.push({ filter, priority: definition.priority });\n continue;\n }\n\n // If no filepath available, only match wildcard patterns\n if (!controllerFilepath) {\n if (pattern === '**/*') {\n matchingFilters.push({ filter, priority: definition.priority });\n }\n continue;\n }\n\n // Normalize filepath for consistent matching\n const normalizedPath = FilterMatcher.normalizeFilepath(controllerFilepath);\n\n // Match using minimatch\n if (minimatch(normalizedPath, pattern)) {\n matchingFilters.push({ filter, priority: definition.priority });\n }\n }\n\n // Sort by priority (highest first)\n matchingFilters.sort((a, b) => b.priority - a.priority);\n\n return matchingFilters.map((item) => item.filter);\n }\n\n /**\n * Normalize a controller filepath for consistent matching.\n * - Converts backslashes to forward slashes (Windows compatibility)\n * - Removes leading './'\n *\n * @param filepath - Raw filepath\n * @returns Normalized filepath\n */\n static normalizeFilepath(filepath: string): string {\n return filepath\n .replace(/\\\\/g, '/') // Windows backslashes to forward slashes\n .replace(/^\\.\\//, ''); // Remove leading './'\n }\n}\n"]}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { minimatch as MinimatchNamed } from 'minimatch';
|
|
2
|
+
/**
|
|
3
|
+
* The `(path, pattern, options?) => boolean` callable that EVERY minimatch major has exposed —
|
|
4
|
+
* only the wrapper around it changed between versions.
|
|
5
|
+
*/
|
|
6
|
+
export type MinimatchFn = typeof MinimatchNamed;
|
|
7
|
+
/**
|
|
8
|
+
* The two export shapes minimatch has shipped:
|
|
9
|
+
* - v5+ : `exports.minimatch = minimatch` — a MODULE carrying a named `minimatch` export.
|
|
10
|
+
* - v3/v4: `module.exports = minimatch` — the module IS the function, with NO named export.
|
|
11
|
+
*/
|
|
12
|
+
type MinimatchExport = MinimatchFn & {
|
|
13
|
+
minimatch?: MinimatchFn;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Resolves whichever minimatch actually got linked into the callable both shapes provide.
|
|
17
|
+
*
|
|
18
|
+
* WHY THIS EXISTS (issue #747). `import { minimatch } from 'minimatch'` compiles to
|
|
19
|
+
* `minimatch_1.minimatch`, which is `undefined` against minimatch v3 — and v3 is what a consumer
|
|
20
|
+
* gets whenever pnpm's `node-linker=hoisted` puts an older minimatch at the root and this package
|
|
21
|
+
* receives no nested copy. `@webpieces/rules-config` crashed that way; `FilterMatcher` had the
|
|
22
|
+
* identical call and was surviving only by luck of nesting.
|
|
23
|
+
*
|
|
24
|
+
* THIS IS NOT A WEBPIECES COMPATIBILITY SHIM. It keeps no old spelling of any webpieces surface
|
|
25
|
+
* alive — there is exactly one exported `minimatch` binding here, and no caller can choose a
|
|
26
|
+
* second one. It reconciles an EXTERNAL library's two export shapes, which webpieces neither owns
|
|
27
|
+
* nor can delete, at the one boundary where that library enters this package.
|
|
28
|
+
*/
|
|
29
|
+
export declare class MinimatchInterop {
|
|
30
|
+
/**
|
|
31
|
+
* @param loaded whatever `require('minimatch')` produced in the consumer's tree
|
|
32
|
+
* @returns the matcher function, from the named export when present, else the module itself
|
|
33
|
+
*/
|
|
34
|
+
resolve(loaded: MinimatchExport): MinimatchFn;
|
|
35
|
+
}
|
|
36
|
+
/** The interop-resolved matcher. Import THIS, never `{ minimatch } from 'minimatch'`. */
|
|
37
|
+
export declare const minimatch: MinimatchFn;
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.minimatch = exports.MinimatchInterop = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Resolves whichever minimatch actually got linked into the callable both shapes provide.
|
|
6
|
+
*
|
|
7
|
+
* WHY THIS EXISTS (issue #747). `import { minimatch } from 'minimatch'` compiles to
|
|
8
|
+
* `minimatch_1.minimatch`, which is `undefined` against minimatch v3 — and v3 is what a consumer
|
|
9
|
+
* gets whenever pnpm's `node-linker=hoisted` puts an older minimatch at the root and this package
|
|
10
|
+
* receives no nested copy. `@webpieces/rules-config` crashed that way; `FilterMatcher` had the
|
|
11
|
+
* identical call and was surviving only by luck of nesting.
|
|
12
|
+
*
|
|
13
|
+
* THIS IS NOT A WEBPIECES COMPATIBILITY SHIM. It keeps no old spelling of any webpieces surface
|
|
14
|
+
* alive — there is exactly one exported `minimatch` binding here, and no caller can choose a
|
|
15
|
+
* second one. It reconciles an EXTERNAL library's two export shapes, which webpieces neither owns
|
|
16
|
+
* nor can delete, at the one boundary where that library enters this package.
|
|
17
|
+
*/
|
|
18
|
+
class MinimatchInterop {
|
|
19
|
+
/**
|
|
20
|
+
* @param loaded whatever `require('minimatch')` produced in the consumer's tree
|
|
21
|
+
* @returns the matcher function, from the named export when present, else the module itself
|
|
22
|
+
*/
|
|
23
|
+
resolve(loaded) {
|
|
24
|
+
return loaded.minimatch ?? loaded;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
exports.MinimatchInterop = MinimatchInterop;
|
|
28
|
+
/** The interop-resolved matcher. Import THIS, never `{ minimatch } from 'minimatch'`. */
|
|
29
|
+
exports.minimatch = new MinimatchInterop().resolve(require('minimatch'));
|
|
30
|
+
//# sourceMappingURL=MinimatchInterop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MinimatchInterop.js","sourceRoot":"","sources":["../../../../../packages/http/http-routing/src/MinimatchInterop.ts"],"names":[],"mappings":";;;AAeA;;;;;;;;;;;;;GAaG;AACH,MAAa,gBAAgB;IACzB;;;OAGG;IACH,OAAO,CAAC,MAAuB;QAC3B,OAAO,MAAM,CAAC,SAAS,IAAI,MAAM,CAAC;IACtC,CAAC;CACJ;AARD,4CAQC;AAED,yFAAyF;AAC5E,QAAA,SAAS,GAAgB,IAAI,gBAAgB,EAAE,CAAC,OAAO,CAChE,OAAO,CAAC,WAAW,CAAoB,CAC1C,CAAC","sourcesContent":["import type { minimatch as MinimatchNamed } from 'minimatch';\n\n/**\n * The `(path, pattern, options?) => boolean` callable that EVERY minimatch major has exposed —\n * only the wrapper around it changed between versions.\n */\nexport type MinimatchFn = typeof MinimatchNamed;\n\n/**\n * The two export shapes minimatch has shipped:\n * - v5+ : `exports.minimatch = minimatch` — a MODULE carrying a named `minimatch` export.\n * - v3/v4: `module.exports = minimatch` — the module IS the function, with NO named export.\n */\ntype MinimatchExport = MinimatchFn & { minimatch?: MinimatchFn };\n\n/**\n * Resolves whichever minimatch actually got linked into the callable both shapes provide.\n *\n * WHY THIS EXISTS (issue #747). `import { minimatch } from 'minimatch'` compiles to\n * `minimatch_1.minimatch`, which is `undefined` against minimatch v3 — and v3 is what a consumer\n * gets whenever pnpm's `node-linker=hoisted` puts an older minimatch at the root and this package\n * receives no nested copy. `@webpieces/rules-config` crashed that way; `FilterMatcher` had the\n * identical call and was surviving only by luck of nesting.\n *\n * THIS IS NOT A WEBPIECES COMPATIBILITY SHIM. It keeps no old spelling of any webpieces surface\n * alive — there is exactly one exported `minimatch` binding here, and no caller can choose a\n * second one. It reconciles an EXTERNAL library's two export shapes, which webpieces neither owns\n * nor can delete, at the one boundary where that library enters this package.\n */\nexport class MinimatchInterop {\n /**\n * @param loaded whatever `require('minimatch')` produced in the consumer's tree\n * @returns the matcher function, from the named export when present, else the module itself\n */\n resolve(loaded: MinimatchExport): MinimatchFn {\n return loaded.minimatch ?? loaded;\n }\n}\n\n/** The interop-resolved matcher. Import THIS, never `{ minimatch } from 'minimatch'`. */\nexport const minimatch: MinimatchFn = new MinimatchInterop().resolve(\n require('minimatch') as MinimatchExport,\n);\n"]}
|