@molecule/api-resource-user 1.5.7 → 1.7.0

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.
Files changed (68) hide show
  1. package/README.md +291 -57
  2. package/dist/authorization.d.ts +64 -6
  3. package/dist/authorization.d.ts.map +1 -1
  4. package/dist/authorization.js +129 -17
  5. package/dist/authorization.js.map +1 -1
  6. package/dist/handlers/create.d.ts +19 -5
  7. package/dist/handlers/create.d.ts.map +1 -1
  8. package/dist/handlers/create.js +20 -5
  9. package/dist/handlers/create.js.map +1 -1
  10. package/dist/handlers/del.d.ts +2 -2
  11. package/dist/handlers/del.d.ts.map +1 -1
  12. package/dist/handlers/del.js +1 -1
  13. package/dist/handlers/del.js.map +1 -1
  14. package/dist/handlers/forgotPassword.d.ts +2 -2
  15. package/dist/handlers/forgotPassword.d.ts.map +1 -1
  16. package/dist/handlers/forgotPassword.js +2 -2
  17. package/dist/handlers/forgotPassword.js.map +1 -1
  18. package/dist/handlers/logIn.d.ts +13 -6
  19. package/dist/handlers/logIn.d.ts.map +1 -1
  20. package/dist/handlers/logIn.js +13 -6
  21. package/dist/handlers/logIn.js.map +1 -1
  22. package/dist/handlers/logInOAuth.d.ts +8 -4
  23. package/dist/handlers/logInOAuth.d.ts.map +1 -1
  24. package/dist/handlers/logInOAuth.js +9 -5
  25. package/dist/handlers/logInOAuth.js.map +1 -1
  26. package/dist/handlers/payments/handlePaymentNotification.d.ts +2 -2
  27. package/dist/handlers/payments/handlePaymentNotification.d.ts.map +1 -1
  28. package/dist/handlers/payments/handlePaymentNotification.js +2 -2
  29. package/dist/handlers/payments/handlePaymentNotification.js.map +1 -1
  30. package/dist/handlers/payments/verifyPayment.d.ts +2 -2
  31. package/dist/handlers/payments/verifyPayment.d.ts.map +1 -1
  32. package/dist/handlers/payments/verifyPayment.js +1 -1
  33. package/dist/handlers/payments/verifyPayment.js.map +1 -1
  34. package/dist/handlers/read.d.ts +2 -2
  35. package/dist/handlers/read.d.ts.map +1 -1
  36. package/dist/handlers/read.js +1 -1
  37. package/dist/handlers/read.js.map +1 -1
  38. package/dist/handlers/readSelf.d.ts +10 -3
  39. package/dist/handlers/readSelf.d.ts.map +1 -1
  40. package/dist/handlers/readSelf.js +16 -2
  41. package/dist/handlers/readSelf.js.map +1 -1
  42. package/dist/handlers/resetPassword.d.ts +2 -1
  43. package/dist/handlers/resetPassword.d.ts.map +1 -1
  44. package/dist/handlers/resetPassword.js +2 -1
  45. package/dist/handlers/resetPassword.js.map +1 -1
  46. package/dist/handlers/update.d.ts +10 -4
  47. package/dist/handlers/update.d.ts.map +1 -1
  48. package/dist/handlers/update.js +10 -4
  49. package/dist/handlers/update.js.map +1 -1
  50. package/dist/handlers/updatePassword.d.ts +12 -3
  51. package/dist/handlers/updatePassword.d.ts.map +1 -1
  52. package/dist/handlers/updatePassword.js +25 -7
  53. package/dist/handlers/updatePassword.js.map +1 -1
  54. package/dist/handlers/updatePlan.d.ts +2 -2
  55. package/dist/handlers/updatePlan.d.ts.map +1 -1
  56. package/dist/handlers/updatePlan.js +1 -1
  57. package/dist/handlers/updatePlan.js.map +1 -1
  58. package/dist/handlers/verifyTwoFactor.d.ts +2 -2
  59. package/dist/handlers/verifyTwoFactor.d.ts.map +1 -1
  60. package/dist/handlers/verifyTwoFactor.js +2 -2
  61. package/dist/handlers/verifyTwoFactor.js.map +1 -1
  62. package/dist/index.d.ts +95 -14
  63. package/dist/index.d.ts.map +1 -1
  64. package/dist/index.js +95 -14
  65. package/dist/index.js.map +1 -1
  66. package/dist/types.d.ts +38 -0
  67. package/dist/types.d.ts.map +1 -1
  68. package/package.json +1 -1
package/dist/types.d.ts CHANGED
@@ -11,4 +11,42 @@ export type { CreateOAuthProps, CreateProps, CreateSecretProps, Props, SecretPro
11
11
  * An object describing the `user` resource.
12
12
  */
13
13
  export type Resource<T = unknown> = resourceTypes.Resource<T>;
14
+ /**
15
+ * Configuration accepted by every user handler factory (`handlers.create`,
16
+ * `handlers.logIn`, `handlers.update`, …).
17
+ *
18
+ * `name` and `tableName` are the caller's to supply, because an app may mount the
19
+ * user resource on its own table. `schema` is OPTIONAL — no factory requires you
20
+ * to invent one:
21
+ *
22
+ * - `handlers.create` and `handlers.logInOAuth` validate the props they write and
23
+ * default to this package's {@link propsSchema} when `schema` is omitted.
24
+ * - `handlers.update` validates with the package's `updatePropsSchema` and ignores
25
+ * a supplied `schema`.
26
+ * - The remaining handlers read/write rows directly and never look at `schema`.
27
+ *
28
+ * Omission is NOT "no validation": the handlers that validate use
29
+ * {@link propsSchema}. Pass `createResource({ oauthServers, planKeys })` (or the
30
+ * `resource` export) when the app constrains `oauthServer` / `planKey`, and pass
31
+ * your own extended Zod object only when you add fields.
32
+ *
33
+ * @example
34
+ * ```ts
35
+ * handlers.create({ name: 'User', tableName: 'users' }) // validates with propsSchema
36
+ * handlers.create(createResource({ oauthServers: ['google'] as const }))
37
+ * ```
38
+ */
39
+ export interface HandlerResource {
40
+ /** The resource name used in error messages (e.g. `'User'`). */
41
+ name: string;
42
+ /** The database table name for users. */
43
+ tableName: string;
44
+ /**
45
+ * Optional Zod schema validated by `handlers.create` / `handlers.logInOAuth`.
46
+ * Defaults to {@link propsSchema}. Must expose `safeParse`; a stub object is not
47
+ * a schema and the first request answers 400 `resource.error.unknownError` with
48
+ * `TypeError: schema.safeParse is not a function`.
49
+ */
50
+ schema?: unknown;
51
+ }
14
52
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,KAAK,aAAa,MAAM,8BAA8B,CAAA;AAGlE,YAAY,EACV,gBAAgB,EAChB,WAAW,EACX,iBAAiB,EACjB,KAAK,EACL,WAAW,EACX,OAAO,EACP,yBAAyB,EACzB,eAAe,EACf,WAAW,EACX,oBAAoB,EACpB,0BAA0B,GAC3B,MAAM,aAAa,CAAA;AAEpB;;GAEG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,GAAG,OAAO,IAAI,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAA"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,KAAK,aAAa,MAAM,8BAA8B,CAAA;AAGlE,YAAY,EACV,gBAAgB,EAChB,WAAW,EACX,iBAAiB,EACjB,KAAK,EACL,WAAW,EACX,OAAO,EACP,yBAAyB,EACzB,eAAe,EACf,WAAW,EACX,oBAAoB,EACpB,0BAA0B,GAC3B,MAAM,aAAa,CAAA;AAEpB;;GAEG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,GAAG,OAAO,IAAI,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAA;AAE7D;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,WAAW,eAAe;IAC9B,gEAAgE;IAChE,IAAI,EAAE,MAAM,CAAA;IACZ,yCAAyC;IACzC,SAAS,EAAE,MAAM,CAAA;IACjB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;CACjB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@molecule/api-resource-user",
3
- "version": "1.5.7",
3
+ "version": "1.7.0",
4
4
  "description": "User resource types and schema for molecule.dev.",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",