@molecule/api-resource-user 1.8.0 → 1.8.1
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 +20 -44
- package/package.json +4 -4
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-
|
|
6
|
+
Generated: 2026-10-26T04:23:58.846Z
|
|
7
7
|
-->
|
|
8
8
|
|
|
9
9
|
# @molecule/api-resource-user
|
|
@@ -548,11 +548,7 @@ The map's `create` / `logIn` send HTTP responses. For a custom JSON envelope, co
|
|
|
548
548
|
their `{ statusCode, headers?, body }` result instead of reimplementing credential storage.
|
|
549
549
|
|
|
550
550
|
```typescript
|
|
551
|
-
function createRequestHandlerMap(
|
|
552
|
-
createRequestHandler: (
|
|
553
|
-
handler: Handler,
|
|
554
|
-
) => (req: MoleculeRequest, res: MoleculeResponse, next: MoleculeNextFunction) => Promise<void>,
|
|
555
|
-
): UserRequestHandlerMap
|
|
551
|
+
function createRequestHandlerMap(createRequestHandler: RequestHandlerCreator): UserRequestHandlerMap
|
|
556
552
|
```
|
|
557
553
|
|
|
558
554
|
- `createRequestHandler` — Factory from `@molecule/api-resource` that wraps handler configs into Express middleware.
|
|
@@ -573,10 +569,10 @@ two-factor responses. Read `handlers.create` / `handlers.logIn` for their comple
|
|
|
573
569
|
Retain each route's authorization and rate-limit middleware when adapting its envelope.
|
|
574
570
|
|
|
575
571
|
```typescript
|
|
576
|
-
function createResource
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
}): types.Resource
|
|
572
|
+
function createResource<
|
|
573
|
+
OAuthServers extends readonly [string, ...string[]] | undefined = undefined,
|
|
574
|
+
PlanKeys extends readonly [string, ...string[]] | undefined = undefined,
|
|
575
|
+
>(options?: { oauthServers?: OAuthServers; planKeys?: PlanKeys }): types.Resource
|
|
580
576
|
```
|
|
581
577
|
|
|
582
578
|
- `options` — Optional configuration.
|
|
@@ -592,7 +588,14 @@ Creates a full schema for user props.
|
|
|
592
588
|
OAuth servers and plan keys can be constrained by passing them as options.
|
|
593
589
|
|
|
594
590
|
```typescript
|
|
595
|
-
function createSchema
|
|
591
|
+
function createSchema<
|
|
592
|
+
OAuthServers extends readonly [string, ...string[]] | undefined = undefined,
|
|
593
|
+
PlanKeys extends readonly [string, ...string[]] | undefined = undefined,
|
|
594
|
+
>(options?: {
|
|
595
|
+
oauthServers?: OAuthServers
|
|
596
|
+
planKeys?: PlanKeys
|
|
597
|
+
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
|
598
|
+
}): z.ZodObject<
|
|
596
599
|
{
|
|
597
600
|
id: z.ZodString
|
|
598
601
|
createdAt: z.ZodString
|
|
@@ -652,7 +655,7 @@ const i18nRegistered: true
|
|
|
652
655
|
Default user resource definition.
|
|
653
656
|
|
|
654
657
|
```typescript
|
|
655
|
-
const resource: types.Resource
|
|
658
|
+
const resource: types.Resource
|
|
656
659
|
```
|
|
657
660
|
|
|
658
661
|
#### `routes`
|
|
@@ -791,14 +794,14 @@ Schema for creating a user via OAuth.
|
|
|
791
794
|
```typescript
|
|
792
795
|
const createOAuthPropsSchema: z.ZodObject<
|
|
793
796
|
{
|
|
794
|
-
oauthServer: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEnum<{}>>
|
|
795
|
-
oauthId: z.ZodOptional<z.ZodString>
|
|
796
797
|
username: z.ZodOptional<z.ZodString>
|
|
797
798
|
name: z.ZodOptional<z.ZodString>
|
|
798
799
|
email: z.ZodOptional<z.ZodNullable<z.ZodString>>
|
|
799
800
|
emailVerified: z.ZodOptional<z.ZodBoolean>
|
|
800
801
|
avatar: z.ZodOptional<z.ZodNullable<z.ZodString>>
|
|
801
802
|
bio: z.ZodOptional<z.ZodNullable<z.ZodString>>
|
|
803
|
+
oauthServer: z.ZodOptional<z.ZodString> | z.ZodOptional<z.ZodEnum<{}>>
|
|
804
|
+
oauthId: z.ZodOptional<z.ZodString>
|
|
802
805
|
oauthData: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>
|
|
803
806
|
},
|
|
804
807
|
z.core.$strip
|
|
@@ -1125,17 +1128,7 @@ user in (register, login, OAuth, password reset), as `handlers/logIn.ts` does: a
|
|
|
1125
1128
|
_(description truncated — read the full text in `node_modules/@molecule/api-resource-user/dist/authorization.d.ts`.)_
|
|
1126
1129
|
|
|
1127
1130
|
```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
|
|
1131
|
+
function set(_req: MoleculeRequest, res: MoleculeResponse, session: Session): string | null
|
|
1139
1132
|
```
|
|
1140
1133
|
|
|
1141
1134
|
- `_req` — The request object (unused; reserved for handler signature parity).
|
|
@@ -2318,24 +2311,7 @@ Get a user's current plan info.
|
|
|
2318
2311
|
Uses the bonded PlanService if available.
|
|
2319
2312
|
|
|
2320
2313
|
```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>
|
|
2314
|
+
function getPlan(user: types.Props): Promise<PlanInfo | Plan | null>
|
|
2339
2315
|
```
|
|
2340
2316
|
|
|
2341
2317
|
- `user` — The user props (needs `planKey`, `planExpiresAt`, `planAutoRenews`).
|
|
@@ -2453,7 +2429,7 @@ Returns a shallow copy of a user row with {@link SENSITIVE_USER_COLUMNS}
|
|
|
2453
2429
|
removed. The input row is not mutated.
|
|
2454
2430
|
|
|
2455
2431
|
```typescript
|
|
2456
|
-
function stripSensitiveUserColumns(user: T): T
|
|
2432
|
+
function stripSensitiveUserColumns<T extends Record<string, unknown>>(user: T): T
|
|
2457
2433
|
```
|
|
2458
2434
|
|
|
2459
2435
|
- `user` — The full user row (as loaded by `findById`).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@molecule/api-resource-user",
|
|
3
|
-
"version": "1.8.
|
|
3
|
+
"version": "1.8.1",
|
|
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.
|
|
37
|
-
"@molecule/api-config": "1.0.
|
|
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.
|
|
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",
|