@hypequery/serve 0.15.3 → 0.15.5
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api-builder.d.ts","sourceRoot":"","sources":["../../src/server/api-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,YAAY,
|
|
1
|
+
{"version":3,"file":"api-builder.d.ts","sourceRoot":"","sources":["../../src/server/api-builder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,YAAY,EAIZ,gBAAgB,EAChB,eAAe,EACf,eAAe,EACf,YAAY,EACZ,oBAAoB,EAErB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,qBAAqB,CAAC;AACtE,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,wBAAwB,CAAC;AAC7E,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAMtD,eAAO,MAAM,gBAAgB,GAC3B,QAAQ,SAAS,eAAe,CAAC,QAAQ,EAAE,KAAK,CAAC,EACjD,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACxC,KAAK,SAAS,WAAW,EAEzB,cAAc,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,CAAC,EACzD,aAAa,gBAAgB,EAC7B,QAAQ,WAAW,EACnB,gBAAgB,YAAY,CAAC,KAAK,CAAC,EAAE,EACrC,mBAAmB,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,KAAK,CAAC,EAAE,EAC/D,cAAc,oBAAoB,CAChC,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,CAAC,EAC3C,QAAQ,EACR,KAAK,CACN,EACD,SAAS,YAAY,EACrB,UAAU,MAAM,EAChB,oBAAoB,kBAAkB,EACtC,yBAAyB,CACvB,OAAO,CAAC,EAAE,8BAA8B,KACrC,0BAA0B,EAC/B,oBAAoB,SAAS,MAAM,EAAE,KACpC,YAAY,CAAC,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,EAAE,KAAK,CAAC,EAAE,QAAQ,EAAE,KAAK,CAsH3E,CAAC"}
|
|
@@ -3,6 +3,18 @@ import { applyBasePath, normalizeRoutePath } from "../router.js";
|
|
|
3
3
|
import { mapEndpointToToolkit } from "./mapper.js";
|
|
4
4
|
import { attachDeploymentBuildSource } from "./deployment-build-source.js";
|
|
5
5
|
export const createAPImethods = (queryEntries, queryLogger, router, authStrategies, globalMiddlewares, executeQuery, handler, basePath, cacheObservability, buildDeploymentContract, runtimeEntrypoints) => {
|
|
6
|
+
/**
|
|
7
|
+
* Routes registered through `api.route()`, keyed by endpoint identity.
|
|
8
|
+
*
|
|
9
|
+
* `route()` adds a route to the router but leaves `queryEntries` holding the
|
|
10
|
+
* auto-registered `/queries/<key>` convention endpoint. Both routes stay live,
|
|
11
|
+
* but the manifest can only name one, and clients should be pointed at the one
|
|
12
|
+
* the author declared explicitly. First registration wins, so calling `route()`
|
|
13
|
+
* twice for the same endpoint keeps the manifest stable. Object identity is
|
|
14
|
+
* required because entries such as `orders` and `dataset:orders` may have the
|
|
15
|
+
* same `endpoint.key` while representing different operations.
|
|
16
|
+
*/
|
|
17
|
+
const explicitRoutes = new WeakMap();
|
|
6
18
|
const api = {
|
|
7
19
|
queries: queryEntries,
|
|
8
20
|
queryLogger,
|
|
@@ -11,7 +23,7 @@ export const createAPImethods = (queryEntries, queryLogger, router, authStrategi
|
|
|
11
23
|
manifest: () => {
|
|
12
24
|
const manifest = {};
|
|
13
25
|
for (const [key, endpoint] of Object.entries(queryEntries)) {
|
|
14
|
-
manifest[key] = {
|
|
26
|
+
manifest[key] = explicitRoutes.get(endpoint) ?? {
|
|
15
27
|
method: endpoint.method,
|
|
16
28
|
// queryEntries store the pre-basePath route; re-apply so the manifest
|
|
17
29
|
// carries the full request path clients should call.
|
|
@@ -52,6 +64,12 @@ export const createAPImethods = (queryEntries, queryLogger, router, authStrategi
|
|
|
52
64
|
middlewares,
|
|
53
65
|
};
|
|
54
66
|
router.register(registeredEndpoint);
|
|
67
|
+
if (!explicitRoutes.has(endpoint)) {
|
|
68
|
+
explicitRoutes.set(endpoint, {
|
|
69
|
+
method,
|
|
70
|
+
path: applyBasePath(basePath, normalizedPath),
|
|
71
|
+
});
|
|
72
|
+
}
|
|
55
73
|
return api;
|
|
56
74
|
},
|
|
57
75
|
use: (middleware) => {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hypequery/serve",
|
|
3
|
-
"version": "0.15.
|
|
3
|
+
"version": "0.15.5",
|
|
4
4
|
"description": "Code-first TypeScript runtime for validated ClickHouse analytics APIs, OpenAPI, auth, and tenancy",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"clickhouse",
|
|
@@ -39,14 +39,18 @@
|
|
|
39
39
|
"openapi-typescript": "^7.13.0",
|
|
40
40
|
"zod": "^3.23.8",
|
|
41
41
|
"zod-to-json-schema": "^3.23.5",
|
|
42
|
-
"@hypequery/datasets": "^0.13.
|
|
42
|
+
"@hypequery/datasets": "^0.13.5"
|
|
43
43
|
},
|
|
44
44
|
"peerDependencies": {
|
|
45
|
-
"tsx": "^4.0.0"
|
|
45
|
+
"tsx": "^4.0.0",
|
|
46
|
+
"zod": "^3.23.8"
|
|
46
47
|
},
|
|
47
48
|
"peerDependenciesMeta": {
|
|
48
49
|
"tsx": {
|
|
49
50
|
"optional": true
|
|
51
|
+
},
|
|
52
|
+
"zod": {
|
|
53
|
+
"optional": true
|
|
50
54
|
}
|
|
51
55
|
},
|
|
52
56
|
"devDependencies": {
|