@molecule/api-resource-user 1.8.0 → 1.8.2

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,7 +3,7 @@ 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-25T22:46:46.920Z
6
+ Generated: 2026-11-01T07:02:43.984Z
7
7
  -->
8
8
 
9
9
  # @molecule/api-resource-user
@@ -50,6 +50,8 @@ store). Set `AUTH_SCHEME=Token` (or `verifyMiddleware({ scheme: 'Token' })`): ev
50
50
  accepts it, `logIn`/`create` return `accessToken`, `GET /users/me` echoes it, and a password
51
51
  change revokes every OTHER device but keeps the caller's own session.
52
52
 
53
+ **Generated full-stack apps:** mlcl derives the app-auth composition root from this API contract; keep that bond and use its shared HTTP client.
54
+
53
55
  **`handlers.*` return `{ statusCode, headers?, body }` and never write to `res`** — not through
54
56
  `res.json`, not through `res.send`, not through `res.end`. The mounted routes apply that object
55
57
  for you (`createRequestHandler` does `res.set(headers)`, `res.status(statusCode)`,
@@ -548,11 +550,7 @@ The map's `create` / `logIn` send HTTP responses. For a custom JSON envelope, co
548
550
  their `{ statusCode, headers?, body }` result instead of reimplementing credential storage.
549
551
 
550
552
  ```typescript
551
- function createRequestHandlerMap(
552
- createRequestHandler: (
553
- handler: Handler,
554
- ) => (req: MoleculeRequest, res: MoleculeResponse, next: MoleculeNextFunction) => Promise<void>,
555
- ): UserRequestHandlerMap
553
+ function createRequestHandlerMap(createRequestHandler: RequestHandlerCreator): UserRequestHandlerMap
556
554
  ```
557
555
 
558
556
  - `createRequestHandler` — Factory from `@molecule/api-resource` that wraps handler configs into Express middleware.
@@ -573,10 +571,10 @@ two-factor responses. Read `handlers.create` / `handlers.logIn` for their comple
573
571
  Retain each route's authorization and rate-limit middleware when adapting its envelope.
574
572
 
575
573
  ```typescript
576
- function createResource(options?: {
577
- oauthServers?: OAuthServers
578
- planKeys?: PlanKeys
579
- }): types.Resource<unknown>
574
+ function createResource<
575
+ OAuthServers extends readonly [string, ...string[]] | undefined = undefined,
576
+ PlanKeys extends readonly [string, ...string[]] | undefined = undefined,
577
+ >(options?: { oauthServers?: OAuthServers; planKeys?: PlanKeys }): types.Resource
580
578
  ```
581
579
 
582
580
  - `options` — Optional configuration.
@@ -592,7 +590,14 @@ Creates a full schema for user props.
592
590
  OAuth servers and plan keys can be constrained by passing them as options.
593
591
 
594
592
  ```typescript
595
- function createSchema(options?: { oauthServers?: OAuthServers; planKeys?: PlanKeys }): z.ZodObject<
593
+ function createSchema<
594
+ OAuthServers extends readonly [string, ...string[]] | undefined = undefined,
595
+ PlanKeys extends readonly [string, ...string[]] | undefined = undefined,
596
+ >(options?: {
597
+ oauthServers?: OAuthServers
598
+ planKeys?: PlanKeys
599
+ // eslint-disable-next-line @typescript-eslint/explicit-function-return-type
600
+ }): z.ZodObject<
596
601
  {
597
602
  id: z.ZodString
598
603
  createdAt: z.ZodString
@@ -652,7 +657,7 @@ const i18nRegistered: true
652
657
  Default user resource definition.
653
658
 
654
659
  ```typescript
655
- const resource: types.Resource<unknown>
660
+ const resource: types.Resource
656
661
  ```
657
662
 
658
663
  #### `routes`
@@ -791,14 +796,14 @@ Schema for creating a user via OAuth.
791
796
  ```typescript
792
797
  const createOAuthPropsSchema: z.ZodObject<
793
798
  {
794
- oauthServer: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEnum<{}>>
795
- oauthId: z.ZodOptional<z.ZodString>
796
799
  username: z.ZodOptional<z.ZodString>
797
800
  name: z.ZodOptional<z.ZodString>
798
801
  email: z.ZodOptional<z.ZodNullable<z.ZodString>>
799
802
  emailVerified: z.ZodOptional<z.ZodBoolean>
800
803
  avatar: z.ZodOptional<z.ZodNullable<z.ZodString>>
801
804
  bio: z.ZodOptional<z.ZodNullable<z.ZodString>>
805
+ oauthServer: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEnum<{}>>
806
+ oauthId: z.ZodOptional<z.ZodString>
802
807
  oauthData: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>
803
808
  },
804
809
  z.core.$strip
@@ -1125,17 +1130,7 @@ user in (register, login, OAuth, password reset), as `handlers/logIn.ts` does: a
1125
1130
  _(description truncated — read the full text in `node_modules/@molecule/api-resource-user/dist/authorization.d.ts`.)_
1126
1131
 
1127
1132
  ```typescript
1128
- function set(
1129
- _req: MoleculeRequest,
1130
- res: MoleculeResponse,
1131
- session: {
1132
- userId: string
1133
- deviceId: string
1134
- id?: string | undefined
1135
- oauthServer?: string | undefined
1136
- oauthId?: string | undefined
1137
- },
1138
- ): string | null
1133
+ function set(_req: MoleculeRequest, res: MoleculeResponse, session: Session): string | null
1139
1134
  ```
1140
1135
 
1141
1136
  - `_req` — The request object (unused; reserved for handler signature parity).
@@ -2318,24 +2313,7 @@ Get a user's current plan info.
2318
2313
  Uses the bonded PlanService if available.
2319
2314
 
2320
2315
  ```typescript
2321
- function getPlan(user: {
2322
- id: string
2323
- createdAt: string
2324
- updatedAt: string
2325
- username?: string | undefined
2326
- name?: string | undefined
2327
- email?: string | null | undefined
2328
- emailVerified?: boolean | undefined
2329
- avatar?: string | null | undefined
2330
- bio?: string | null | undefined
2331
- twoFactorEnabled?: boolean | undefined
2332
- oauthServer?: string | undefined
2333
- oauthId?: string | undefined
2334
- oauthData?: Record<string, unknown> | undefined
2335
- planKey?: string | undefined
2336
- planExpiresAt?: string | undefined
2337
- planAutoRenews?: boolean | undefined
2338
- }): Promise<Plan | PlanInfo | null>
2316
+ function getPlan(user: types.Props): Promise<PlanInfo | Plan | null>
2339
2317
  ```
2340
2318
 
2341
2319
  - `user` — The user props (needs `planKey`, `planExpiresAt`, `planAutoRenews`).
@@ -2453,7 +2431,7 @@ Returns a shallow copy of a user row with {@link SENSITIVE_USER_COLUMNS}
2453
2431
  removed. The input row is not mutated.
2454
2432
 
2455
2433
  ```typescript
2456
- function stripSensitiveUserColumns(user: T): T
2434
+ function stripSensitiveUserColumns<T extends Record<string, unknown>>(user: T): T
2457
2435
  ```
2458
2436
 
2459
2437
  - `user` — The full user row (as loaded by `findById`).
package/dist/index.d.ts CHANGED
@@ -40,6 +40,8 @@
40
40
  * accepts it, `logIn`/`create` return `accessToken`, `GET /users/me` echoes it, and a password
41
41
  * change revokes every OTHER device but keeps the caller's own session.
42
42
  *
43
+ * **Generated full-stack apps:** mlcl derives the app-auth composition root from this API contract; keep that bond and use its shared HTTP client.
44
+ *
43
45
  * **`handlers.*` return `{ statusCode, headers?, body }` and never write to `res`** — not through
44
46
  * `res.json`, not through `res.send`, not through `res.end`. The mounted routes apply that object
45
47
  * for you (`createRequestHandler` does `res.set(headers)`, `res.status(statusCode)`,
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqSG;AAEH,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAA;AACnD,OAAO,KAAK,WAAW,MAAM,wBAAwB,CAAA;AACrD,cAAc,oBAAoB,CAAA;AAClC,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAA;AAC/C,cAAc,WAAW,CAAA;AACzB,cAAc,mBAAmB,CAAA;AACjC,cAAc,wBAAwB,CAAA;AACtC,cAAc,eAAe,CAAA;AAC7B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuSG;AAEH,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAA;AACnD,OAAO,KAAK,WAAW,MAAM,wBAAwB,CAAA;AACrD,cAAc,oBAAoB,CAAA;AAClC,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAA;AAC/C,cAAc,WAAW,CAAA;AACzB,cAAc,mBAAmB,CAAA;AACjC,cAAc,wBAAwB,CAAA;AACtC,cAAc,eAAe,CAAA;AAC7B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAA"}
package/dist/index.js CHANGED
@@ -40,6 +40,8 @@
40
40
  * accepts it, `logIn`/`create` return `accessToken`, `GET /users/me` echoes it, and a password
41
41
  * change revokes every OTHER device but keeps the caller's own session.
42
42
  *
43
+ * **Generated full-stack apps:** mlcl derives the app-auth composition root from this API contract; keep that bond and use its shared HTTP client.
44
+ *
43
45
  * **`handlers.*` return `{ statusCode, headers?, body }` and never write to `res`** — not through
44
46
  * `res.json`, not through `res.send`, not through `res.end`. The mounted routes apply that object
45
47
  * for you (`createRequestHandler` does `res.set(headers)`, `res.status(statusCode)`,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqSG;AAEH,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAA;AACnD,OAAO,KAAK,WAAW,MAAM,wBAAwB,CAAA;AACrD,cAAc,oBAAoB,CAAA;AAClC,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAA;AAC/C,cAAc,WAAW,CAAA;AACzB,cAAc,mBAAmB,CAAA;AACjC,cAAc,wBAAwB,CAAA;AACtC,cAAc,eAAe,CAAA;AAC7B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuSG;AAEH,OAAO,KAAK,aAAa,MAAM,oBAAoB,CAAA;AACnD,OAAO,KAAK,WAAW,MAAM,wBAAwB,CAAA;AACrD,cAAc,oBAAoB,CAAA;AAClC,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAA;AAC/C,cAAc,WAAW,CAAA;AACzB,cAAc,mBAAmB,CAAA;AACjC,cAAc,wBAAwB,CAAA;AACtC,cAAc,eAAe,CAAA;AAC7B,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,OAAO,KAAK,KAAK,MAAM,YAAY,CAAA;AACnC,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molecule/api-resource-user",
3
- "version": "1.8.0",
3
+ "version": "1.8.2",
4
4
  "description": "User resource types and schema for molecule.dev.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -33,11 +33,11 @@
33
33
  "zod": "4.6.7"
34
34
  },
35
35
  "devDependencies": {
36
- "@molecule/api-bond": "1.0.3",
37
- "@molecule/api-config": "1.0.3",
36
+ "@molecule/api-bond": "1.0.4",
37
+ "@molecule/api-config": "1.0.4",
38
38
  "@molecule/api-locales-user": "1.1.0",
39
39
  "@molecule/api-locales-user-payments": "1.0.3",
40
- "@molecule/api-payments": "1.2.2",
40
+ "@molecule/api-payments": "1.2.3",
41
41
  "@molecule/api-push-notifications": "1.0.3",
42
42
  "@molecule/api-rate-limit": "1.0.4",
43
43
  "@molecule/api-two-factor": "1.0.2",