@molecule/api-resource 1.0.4 → 1.0.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.
package/README.md CHANGED
@@ -3,15 +3,11 @@ AUTO-GENERATED — DO NOT EDIT THIS FILE.
3
3
  Generated by `mlcl sync-docs` from the package's src/index.ts JSDoc + mlcl/registry.json.
4
4
  Edits here are overwritten on the next commit (molecule's pre-commit hook regenerates).
5
5
  To change this document, edit the module-level JSDoc in src/index.ts.
6
- Generated: 2026-10-16T20:59:23.498Z
6
+ Generated: 2026-10-17T04:45:43.913Z
7
7
  -->
8
8
 
9
9
  # @molecule/api-resource
10
10
 
11
- > **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
12
- > It is written to be read by coding agents as much as by people, and is generated from this
13
- > package's source — edit `src/index.ts` JSDoc, not this file.
14
-
15
11
  Base resource patterns for molecule.dev.
16
12
 
17
13
  Provides CRUD operation factories and request handler utilities for
@@ -34,6 +30,10 @@ res.status(statusCode).send(body)
34
30
  Monkey-patching `res.json` (or `res.send`/`res.end`) to re-shape a handler's answer intercepts
35
31
  nothing the handler produces, so the request it was meant to answer is left unanswered and hangs.
36
32
 
33
+ > **Auto-generated, AI-first package reference** for the [molecule.dev](https://molecule.dev) ecosystem.
34
+ > It is written to be read by coding agents as much as by people, and is generated from this
35
+ > package's source — edit `src/index.ts` JSDoc, not this file.
36
+
37
37
  ## Quick Start
38
38
 
39
39
  ```typescript
@@ -120,10 +120,21 @@ Framework-agnostic HTTP request interface. Structurally compatible with Express'
120
120
  `Request` — Express objects satisfy this interface without adapters, but the type
121
121
  doesn't depend on Express, allowing use with Fastify, Hono, or Lambda.
122
122
 
123
+ `params` is `Record<string, any>` on purpose. Express 5 declares
124
+ `ParamsDictionary` as `{ [key: string]: string | string[] }` — a wildcard or a
125
+ repeated parameter yields an array — so `Record<string, string>` is NOT a
126
+ supertype of it, and every Express handler passing its own `Request` to a
127
+ function declared on this interface (`authorization.set(req, …)`) failed with
128
+ TS2345 and was told to cast. This is the same shape `body` and `query` already
129
+ use. A reader that needs one segment as a string checks it
130
+ (`typeof req.params.id === 'string'`) rather than trusting the annotation;
131
+ the packages that own the routes do exactly that where it matters (see
132
+ `@molecule/api-bonds-default-express`'s `getParamId`).
133
+
123
134
  ```typescript
124
135
  interface MoleculeRequest {
125
136
  body: any
126
- params: Record<string, string>
137
+ params: Record<string, any>
127
138
  query: Record<string, any>
128
139
  headers: Record<string, string | string[] | undefined>
129
140
  cookies?: Record<string, string>
@@ -11,10 +11,21 @@
11
11
  * Framework-agnostic HTTP request interface. Structurally compatible with Express's
12
12
  * `Request` — Express objects satisfy this interface without adapters, but the type
13
13
  * doesn't depend on Express, allowing use with Fastify, Hono, or Lambda.
14
+ *
15
+ * `params` is `Record<string, any>` on purpose. Express 5 declares
16
+ * `ParamsDictionary` as `{ [key: string]: string | string[] }` — a wildcard or a
17
+ * repeated parameter yields an array — so `Record<string, string>` is NOT a
18
+ * supertype of it, and every Express handler passing its own `Request` to a
19
+ * function declared on this interface (`authorization.set(req, …)`) failed with
20
+ * TS2345 and was told to cast. This is the same shape `body` and `query` already
21
+ * use. A reader that needs one segment as a string checks it
22
+ * (`typeof req.params.id === 'string'`) rather than trusting the annotation;
23
+ * the packages that own the routes do exactly that where it matters (see
24
+ * `@molecule/api-bonds-default-express`'s `getParamId`).
14
25
  */
15
26
  export interface MoleculeRequest {
16
27
  body: any;
17
- params: Record<string, string>;
28
+ params: Record<string, any>;
18
29
  query: Record<string, any>;
19
30
  headers: Record<string, string | string[] | undefined>;
20
31
  cookies?: Record<string, string>;
@@ -1 +1 @@
1
- {"version":3,"file":"http-types.d.ts","sourceRoot":"","sources":["../src/http-types.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,GAAG,CAAA;IACT,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,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,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAAA;IAC5E,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAA;IACtC,YAAY,CAAC,IAAI,IAAI,CAAA;IACrB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAA;CAC5B;AAED;;;;;GAKG;AACH,MAAM,MAAM,oBAAoB,GAAG,CAAC,GAAG,CAAC,EAAE,OAAO,KAAK,IAAI,CAAA;AAE1D;;;GAGG;AACH,MAAM,MAAM,sBAAsB,GAAG,CACnC,GAAG,EAAE,eAAe,EACpB,GAAG,EAAE,gBAAgB,EACrB,IAAI,EAAE,oBAAoB,KACvB,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molecule/api-resource",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "Resource CRUD operations and utilities for molecule.dev.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",