express-file-cluster 0.9.3 → 0.10.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 (220) hide show
  1. package/dist/auth/index.cjs +6 -7
  2. package/dist/auth/index.cjs.map +1 -1
  3. package/dist/auth/index.d.cts +7 -2
  4. package/dist/auth/index.d.ts +7 -2
  5. package/dist/auth/index.js +5 -6
  6. package/dist/{chunk-QL6EWT4B.cjs → chunk-4DOHQU6I.cjs} +9 -7
  7. package/dist/chunk-4DOHQU6I.cjs.map +1 -0
  8. package/dist/chunk-73XJUT2S.js +366 -0
  9. package/dist/chunk-73XJUT2S.js.map +1 -0
  10. package/dist/{chunk-ATL4GYFU.js → chunk-7KC2H76D.js} +50 -8
  11. package/dist/chunk-7KC2H76D.js.map +1 -0
  12. package/dist/{chunk-TYR2GZZE.cjs → chunk-7KO4DJRJ.cjs} +19 -14
  13. package/dist/chunk-7KO4DJRJ.cjs.map +1 -0
  14. package/dist/{chunk-UBQYQPBU.js → chunk-ATVD2HGC.js} +4 -4
  15. package/dist/{chunk-R34R7QPD.cjs → chunk-DCJOWFVD.cjs} +3 -3
  16. package/dist/{chunk-R34R7QPD.cjs.map → chunk-DCJOWFVD.cjs.map} +1 -1
  17. package/dist/chunk-DUADUR6R.cjs +366 -0
  18. package/dist/chunk-DUADUR6R.cjs.map +1 -0
  19. package/dist/{chunk-BBSZLGZW.js → chunk-EGSSZUVO.js} +8 -6
  20. package/dist/chunk-EGSSZUVO.js.map +1 -0
  21. package/dist/{chunk-TI24L4XE.cjs → chunk-GBI77W5T.cjs} +6 -2
  22. package/dist/chunk-GBI77W5T.cjs.map +1 -0
  23. package/dist/{chunk-RTF7PHS2.cjs → chunk-HBCY7ILD.cjs} +306 -119
  24. package/dist/chunk-HBCY7ILD.cjs.map +1 -0
  25. package/dist/{chunk-ANUSWEAP.cjs → chunk-KFVFP2Q7.cjs} +59 -17
  26. package/dist/chunk-KFVFP2Q7.cjs.map +1 -0
  27. package/dist/{chunk-RS4MXCPW.js → chunk-NI2BNGGV.js} +2 -2
  28. package/dist/{chunk-X2US4RAM.cjs → chunk-NKLOE4AK.cjs} +11 -13
  29. package/dist/chunk-NKLOE4AK.cjs.map +1 -0
  30. package/dist/{chunk-RRQ2RK5M.js → chunk-PGJQK36V.js} +195 -8
  31. package/dist/chunk-PGJQK36V.js.map +1 -0
  32. package/dist/{chunk-QKQZF573.js → chunk-QDEDOHP7.js} +4 -6
  33. package/dist/chunk-QDEDOHP7.js.map +1 -0
  34. package/dist/{chunk-UTM4PEVG.js → chunk-R4XO4SVM.js} +10 -5
  35. package/dist/chunk-R4XO4SVM.js.map +1 -0
  36. package/dist/chunk-R52CUEGT.js +74 -0
  37. package/dist/chunk-R52CUEGT.js.map +1 -0
  38. package/dist/{chunk-HBYSKULC.js → chunk-RAB44UGX.js} +5 -1
  39. package/dist/chunk-RAB44UGX.js.map +1 -0
  40. package/dist/{chunk-7YEX4MQV.cjs → chunk-WBLUGOAG.cjs} +42 -6
  41. package/dist/chunk-WBLUGOAG.cjs.map +1 -0
  42. package/dist/{chunk-T4OHFU5T.cjs → chunk-YK4ZM3CA.cjs} +15 -15
  43. package/dist/{chunk-T4OHFU5T.cjs.map → chunk-YK4ZM3CA.cjs.map} +1 -1
  44. package/dist/cli/db-runner.cjs +2012 -120
  45. package/dist/cli/db-runner.cjs.map +1 -1
  46. package/dist/cli/db-runner.js +1989 -97
  47. package/dist/cli/db-runner.js.map +1 -1
  48. package/dist/cli/index.cjs +101 -43
  49. package/dist/cli/index.cjs.map +1 -1
  50. package/dist/cli/index.js +80 -22
  51. package/dist/cli/index.js.map +1 -1
  52. package/dist/docs/api-reference/auth.md +10 -8
  53. package/dist/docs/api-reference/collection.md +44 -1
  54. package/dist/docs/api-reference/ignite.md +22 -3
  55. package/dist/docs/api-reference/types.md +99 -0
  56. package/dist/docs/cli/add.md +1 -1
  57. package/dist/docs/cli/db.md +2 -2
  58. package/dist/docs/contributing/index.md +1 -1
  59. package/dist/docs/core-concepts/background-tasks.md +6 -3
  60. package/dist/docs/getting-started/index.md +3 -2
  61. package/dist/docs/guides/authentication.md +34 -24
  62. package/dist/docs/guides/caching.md +32 -1
  63. package/dist/docs/guides/database.md +14 -0
  64. package/dist/docs/guides/feature-matrix.md +58 -0
  65. package/dist/docs/guides/migrations.md +23 -2
  66. package/dist/docs/guides/oauth.md +15 -1
  67. package/dist/docs/guides/which-api.md +2 -2
  68. package/dist/docs/index.md +4 -1
  69. package/dist/docs/skills/SKILL.md +2 -2
  70. package/dist/docs/skills/api-surface.md +10 -4
  71. package/dist/docs/skills/auth-internals.md +3 -3
  72. package/dist/docs/skills/tasks-internals.md +4 -3
  73. package/dist/docs/skills/what-not-to-invent.md +4 -3
  74. package/dist/docs/versioning.md +42 -0
  75. package/dist/index.cjs +144 -51
  76. package/dist/index.cjs.map +1 -1
  77. package/dist/index.d.cts +204 -3
  78. package/dist/index.d.ts +204 -3
  79. package/dist/index.js +107 -14
  80. package/dist/index.js.map +1 -1
  81. package/dist/pgboss-backend-FW42SBSM.js +14 -0
  82. package/dist/pgboss-backend-RVHUBJTU.cjs +14 -0
  83. package/dist/{pgboss-backend-TCHI7CHM.cjs.map → pgboss-backend-RVHUBJTU.cjs.map} +1 -1
  84. package/dist/registry/index.json +34 -3
  85. package/dist/registry/js-mongo/account-security.json +1 -1
  86. package/dist/registry/js-mongo/admin-users.json +1 -1
  87. package/dist/registry/js-mongo/auth.json +1 -1
  88. package/dist/registry/js-mongo/auth@apple.json +1 -1
  89. package/dist/registry/js-mongo/auth@google.json +1 -1
  90. package/dist/registry/js-mongo/email-verification.json +1 -1
  91. package/dist/registry/js-mongo/forgot-password.json +1 -1
  92. package/dist/registry/js-mongo/user-profile.json +1 -1
  93. package/dist/registry/js-mongo-collection/_base.json +1 -0
  94. package/dist/registry/js-mongo-collection/account-security.json +1 -0
  95. package/dist/registry/js-mongo-collection/account-settings.json +1 -0
  96. package/dist/registry/js-mongo-collection/admin-admins.json +1 -0
  97. package/dist/registry/js-mongo-collection/admin-analytics.json +1 -0
  98. package/dist/registry/js-mongo-collection/admin-billing.json +1 -0
  99. package/dist/registry/js-mongo-collection/admin-content.json +1 -0
  100. package/dist/registry/js-mongo-collection/admin-logs.json +1 -0
  101. package/dist/registry/js-mongo-collection/admin-support.json +1 -0
  102. package/dist/registry/js-mongo-collection/admin-system.json +1 -0
  103. package/dist/registry/js-mongo-collection/admin-users.json +1 -0
  104. package/dist/registry/js-mongo-collection/admin.json +1 -0
  105. package/dist/registry/js-mongo-collection/auth.json +1 -0
  106. package/dist/registry/js-mongo-collection/auth@apple.json +1 -0
  107. package/dist/registry/js-mongo-collection/auth@google.json +1 -0
  108. package/dist/registry/js-mongo-collection/billing.json +1 -0
  109. package/dist/registry/js-mongo-collection/email-client.json +1 -0
  110. package/dist/registry/js-mongo-collection/email-verification.json +1 -0
  111. package/dist/registry/js-mongo-collection/files.json +1 -0
  112. package/dist/registry/js-mongo-collection/forgot-password.json +1 -0
  113. package/dist/registry/js-mongo-collection/notifications.json +1 -0
  114. package/dist/registry/js-mongo-collection/support.json +1 -0
  115. package/dist/registry/js-mongo-collection/user-profile.json +1 -0
  116. package/dist/registry/js-pg-model/account-security.json +1 -1
  117. package/dist/registry/js-pg-model/admin-users.json +1 -1
  118. package/dist/registry/js-pg-model/auth.json +1 -1
  119. package/dist/registry/js-pg-model/auth@apple.json +1 -1
  120. package/dist/registry/js-pg-model/auth@google.json +1 -1
  121. package/dist/registry/js-pg-model/email-verification.json +1 -1
  122. package/dist/registry/js-pg-model/forgot-password.json +1 -1
  123. package/dist/registry/js-pg-model/user-profile.json +1 -1
  124. package/dist/registry/js-pg-table/account-security.json +1 -1
  125. package/dist/registry/js-pg-table/admin-users.json +1 -1
  126. package/dist/registry/js-pg-table/auth.json +1 -1
  127. package/dist/registry/js-pg-table/auth@apple.json +1 -1
  128. package/dist/registry/js-pg-table/auth@google.json +1 -1
  129. package/dist/registry/js-pg-table/email-verification.json +1 -1
  130. package/dist/registry/js-pg-table/forgot-password.json +1 -1
  131. package/dist/registry/js-pg-table/user-profile.json +1 -1
  132. package/dist/registry/ts-mongo/account-security.json +1 -1
  133. package/dist/registry/ts-mongo/admin-users.json +1 -1
  134. package/dist/registry/ts-mongo/auth.json +1 -1
  135. package/dist/registry/ts-mongo/auth@apple.json +1 -1
  136. package/dist/registry/ts-mongo/auth@google.json +1 -1
  137. package/dist/registry/ts-mongo/email-verification.json +1 -1
  138. package/dist/registry/ts-mongo/forgot-password.json +1 -1
  139. package/dist/registry/ts-mongo/user-profile.json +1 -1
  140. package/dist/registry/ts-mongo-collection/_base.json +1 -0
  141. package/dist/registry/ts-mongo-collection/account-security.json +1 -0
  142. package/dist/registry/ts-mongo-collection/account-settings.json +1 -0
  143. package/dist/registry/ts-mongo-collection/admin-admins.json +1 -0
  144. package/dist/registry/ts-mongo-collection/admin-analytics.json +1 -0
  145. package/dist/registry/ts-mongo-collection/admin-billing.json +1 -0
  146. package/dist/registry/ts-mongo-collection/admin-content.json +1 -0
  147. package/dist/registry/ts-mongo-collection/admin-logs.json +1 -0
  148. package/dist/registry/ts-mongo-collection/admin-support.json +1 -0
  149. package/dist/registry/ts-mongo-collection/admin-system.json +1 -0
  150. package/dist/registry/ts-mongo-collection/admin-users.json +1 -0
  151. package/dist/registry/ts-mongo-collection/admin.json +1 -0
  152. package/dist/registry/ts-mongo-collection/auth.json +1 -0
  153. package/dist/registry/ts-mongo-collection/auth@apple.json +1 -0
  154. package/dist/registry/ts-mongo-collection/auth@google.json +1 -0
  155. package/dist/registry/ts-mongo-collection/billing.json +1 -0
  156. package/dist/registry/ts-mongo-collection/email-client.json +1 -0
  157. package/dist/registry/ts-mongo-collection/email-verification.json +1 -0
  158. package/dist/registry/ts-mongo-collection/files.json +1 -0
  159. package/dist/registry/ts-mongo-collection/forgot-password.json +1 -0
  160. package/dist/registry/ts-mongo-collection/notifications.json +1 -0
  161. package/dist/registry/ts-mongo-collection/support.json +1 -0
  162. package/dist/registry/ts-mongo-collection/user-profile.json +1 -0
  163. package/dist/registry/ts-pg-model/account-security.json +1 -1
  164. package/dist/registry/ts-pg-model/admin-users.json +1 -1
  165. package/dist/registry/ts-pg-model/auth.json +1 -1
  166. package/dist/registry/ts-pg-model/auth@apple.json +1 -1
  167. package/dist/registry/ts-pg-model/auth@google.json +1 -1
  168. package/dist/registry/ts-pg-model/email-verification.json +1 -1
  169. package/dist/registry/ts-pg-model/forgot-password.json +1 -1
  170. package/dist/registry/ts-pg-model/user-profile.json +1 -1
  171. package/dist/registry/ts-pg-table/account-security.json +1 -1
  172. package/dist/registry/ts-pg-table/admin-users.json +1 -1
  173. package/dist/registry/ts-pg-table/auth.json +1 -1
  174. package/dist/registry/ts-pg-table/auth@apple.json +1 -1
  175. package/dist/registry/ts-pg-table/auth@google.json +1 -1
  176. package/dist/registry/ts-pg-table/email-verification.json +1 -1
  177. package/dist/registry/ts-pg-table/forgot-password.json +1 -1
  178. package/dist/registry/ts-pg-table/user-profile.json +1 -1
  179. package/dist/tasks/index.cjs +4 -2
  180. package/dist/tasks/index.cjs.map +1 -1
  181. package/dist/tasks/index.d.cts +4 -2
  182. package/dist/tasks/index.d.ts +4 -2
  183. package/dist/tasks/index.js +3 -1
  184. package/dist/thread-runner.cjs +8 -0
  185. package/dist/thread-runner.cjs.map +1 -0
  186. package/dist/thread-runner.d.cts +3 -0
  187. package/dist/thread-runner.d.ts +3 -0
  188. package/dist/thread-runner.js +8 -0
  189. package/dist/thread-runner.js.map +1 -0
  190. package/dist/{types-BY-ObnZH.d.ts → types-Bnxvj3l0.d.cts} +14 -2
  191. package/dist/{types-BY-ObnZH.d.cts → types-Bnxvj3l0.d.ts} +14 -2
  192. package/package.json +1 -1
  193. package/dist/chunk-277BSYVH.js +0 -127
  194. package/dist/chunk-277BSYVH.js.map +0 -1
  195. package/dist/chunk-7YEX4MQV.cjs.map +0 -1
  196. package/dist/chunk-ANUSWEAP.cjs.map +0 -1
  197. package/dist/chunk-ATL4GYFU.js.map +0 -1
  198. package/dist/chunk-BBSZLGZW.js.map +0 -1
  199. package/dist/chunk-HBYSKULC.js.map +0 -1
  200. package/dist/chunk-HXV543HZ.js +0 -177
  201. package/dist/chunk-HXV543HZ.js.map +0 -1
  202. package/dist/chunk-LJNSJFOL.js +0 -38
  203. package/dist/chunk-LJNSJFOL.js.map +0 -1
  204. package/dist/chunk-QKQZF573.js.map +0 -1
  205. package/dist/chunk-QL6EWT4B.cjs.map +0 -1
  206. package/dist/chunk-RRQ2RK5M.js.map +0 -1
  207. package/dist/chunk-RTF7PHS2.cjs.map +0 -1
  208. package/dist/chunk-TI24L4XE.cjs.map +0 -1
  209. package/dist/chunk-TYR2GZZE.cjs.map +0 -1
  210. package/dist/chunk-UTM4PEVG.js.map +0 -1
  211. package/dist/chunk-VQSWSYK6.cjs +0 -177
  212. package/dist/chunk-VQSWSYK6.cjs.map +0 -1
  213. package/dist/chunk-X2US4RAM.cjs.map +0 -1
  214. package/dist/chunk-YL37D6KM.cjs +0 -127
  215. package/dist/chunk-YL37D6KM.cjs.map +0 -1
  216. package/dist/pgboss-backend-QKBXVJ6B.js +0 -14
  217. package/dist/pgboss-backend-TCHI7CHM.cjs +0 -14
  218. /package/dist/{chunk-UBQYQPBU.js.map → chunk-ATVD2HGC.js.map} +0 -0
  219. /package/dist/{chunk-RS4MXCPW.js.map → chunk-NI2BNGGV.js.map} +0 -0
  220. /package/dist/{pgboss-backend-QKBXVJ6B.js.map → pgboss-backend-FW42SBSM.js.map} +0 -0
package/dist/cli/index.js CHANGED
@@ -1,20 +1,19 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  scanDir
4
- } from "../chunk-RS4MXCPW.js";
4
+ } from "../chunk-NI2BNGGV.js";
5
5
  import {
6
6
  parseRedisUrl
7
- } from "../chunk-UBQYQPBU.js";
7
+ } from "../chunk-ATVD2HGC.js";
8
8
  import {
9
9
  writeModels
10
- } from "../chunk-BBSZLGZW.js";
10
+ } from "../chunk-EGSSZUVO.js";
11
11
  import {
12
12
  tableNameFor
13
- } from "../chunk-QKQZF573.js";
14
- import "../chunk-HXV543HZ.js";
15
- import "../chunk-LJNSJFOL.js";
16
- import "../chunk-HBYSKULC.js";
17
- import "../chunk-277BSYVH.js";
13
+ } from "../chunk-QDEDOHP7.js";
14
+ import "../chunk-R52CUEGT.js";
15
+ import "../chunk-RAB44UGX.js";
16
+ import "../chunk-73XJUT2S.js";
18
17
 
19
18
  // src/cli/index.ts
20
19
  import fs10 from "fs";
@@ -553,7 +552,7 @@ async function connect(opts) {
553
552
  if (backend === "bullmq") return bullmqAdmin(redisUrl ?? "redis://localhost:6379", opts.queue);
554
553
  if (backend === "pg-boss") {
555
554
  if (!databaseUrl) throw new Error("[EFC] pg-boss needs DATABASE_URL (or --database-url)");
556
- const { pgBossAdmin } = await import("../pgboss-backend-QKBXVJ6B.js");
555
+ const { pgBossAdmin } = await import("../pgboss-backend-FW42SBSM.js");
557
556
  return pgBossAdmin(databaseUrl, opts.queue);
558
557
  }
559
558
  throw new Error(`[EFC] Unknown task backend: ${backend}`);
@@ -819,8 +818,14 @@ function dbCommand() {
819
818
  (opts) => run2("sync", opts)
820
819
  );
821
820
  common(
822
- cmd.command("pull").description("Write defineTable models for the tables in the database (PostgreSQL)")
823
- ).option("--out <dir>", "where to write the models", "src/model").option("--force", "overwrite model files that already exist").action(
821
+ cmd.command("pull").description(
822
+ "Write models for the database: defineTable from PostgreSQL tables, defineCollection from sampled MongoDB documents"
823
+ )
824
+ ).option("--out <dir>", "where to write the models", "src/model").option("--force", "overwrite model files that already exist").option(
825
+ "--sample <n>",
826
+ "MongoDB: documents sampled per collection (default 1000)",
827
+ (v) => Number.parseInt(v, 10)
828
+ ).action(
824
829
  (opts) => run2("pull", opts)
825
830
  );
826
831
  common(cmd.command("status").description("List applied and pending migrations")).action(
@@ -831,7 +836,9 @@ function dbCommand() {
831
836
  ).action(
832
837
  (name, opts) => run2("seed", { ...opts, ...name !== void 0 && { seed: name } })
833
838
  );
834
- common(cmd.command("studio").description("Open a local, read-only database browser")).option("-p, --port <port>", "port to listen on (127.0.0.1 only)", "4983").action(
839
+ common(
840
+ cmd.command("studio").description("Open a local database browser (read-only; --write edits through your models)")
841
+ ).option("-p, --port <port>", "port to listen on (127.0.0.1 only)", "4983").option("--write", "allow inserting, editing and deleting rows (through src/model, validated)").action(
835
842
  (opts) => run2("studio", { ...opts, port: Number(opts.port) })
836
843
  );
837
844
  return cmd;
@@ -916,7 +923,8 @@ var Registry = class {
916
923
  };
917
924
  function variantOf(cfg) {
918
925
  const lang = cfg.language === "typescript" ? "ts" : "js";
919
- if (cfg.database === "mongodb") return `${lang}-mongo`;
926
+ if (cfg.database === "mongodb")
927
+ return cfg.modelApi === "defineCollection" ? `${lang}-mongo-collection` : `${lang}-mongo`;
920
928
  return `${lang}-pg-${cfg.modelApi === "defineTable" ? "table" : "model"}`;
921
929
  }
922
930
  function readJson(file) {
@@ -951,6 +959,10 @@ function detectProject(cwd, version2) {
951
959
  }
952
960
  let modelApi = database === "postgresql" ? "defineTable" : "defineModel";
953
961
  const modelDir = path7.join(cwd, "src", "model");
962
+ if (database === "mongodb" && fs7.existsSync(modelDir)) {
963
+ const sources = fs7.readdirSync(modelDir).filter((f) => /\.[jt]s$/.test(f)).map((f) => fs7.readFileSync(path7.join(modelDir, f), "utf8")).join("\n");
964
+ if (/\bdefineCollection\(/.test(sources)) modelApi = "defineCollection";
965
+ }
954
966
  if (database === "postgresql" && fs7.existsSync(modelDir)) {
955
967
  const sources = fs7.readdirSync(modelDir).filter((f) => /\.[jt]s$/.test(f)).map((f) => fs7.readFileSync(path7.join(modelDir, f), "utf8")).join("\n");
956
968
  if (/\bdefineModel\(/.test(sources) && !/\bdefineTable\(/.test(sources))
@@ -1043,7 +1055,7 @@ function planAdd(cwd, registry, names, opts = {}, cfg = readEfcJson(cwd) ?? dete
1043
1055
  const dup = plan.prompts.some(
1044
1056
  (q) => q.name === p.name && JSON.stringify(q.when) === JSON.stringify(p.when)
1045
1057
  );
1046
- if (!dup && sets(p)) plan.prompts.push(p);
1058
+ if (!dup && (p.config !== void 0 || sets(p))) plan.prompts.push(p);
1047
1059
  }
1048
1060
  }
1049
1061
  return plan;
@@ -1089,11 +1101,36 @@ function envFromAnswers(prompts, answers) {
1089
1101
  }
1090
1102
  return env;
1091
1103
  }
1104
+ function configFromAnswers(prompts, answers) {
1105
+ const config = {};
1106
+ for (const p of prompts) {
1107
+ if (p.config !== void 0 && p.name in answers && promptApplies(p, answers)) {
1108
+ config[p.config] = answers[p.name];
1109
+ }
1110
+ }
1111
+ return config;
1112
+ }
1113
+ function setConfigValues(cwd, values) {
1114
+ const entries = Object.entries(values);
1115
+ if (entries.length === 0) return [];
1116
+ const file = ["efc.config.ts", "efc.config.js", "efc.config.mjs"].map((f) => path7.join(cwd, f)).find((f) => fs7.existsSync(f));
1117
+ if (!file) return entries.map(([k, v]) => `efc.config: set \`${k}: '${v}'\``);
1118
+ let text = fs7.readFileSync(file, "utf8");
1119
+ const manual = [];
1120
+ for (const [key, value] of entries) {
1121
+ const re = new RegExp(`^(\\s*)${key}:\\s*(['"])[^'"\\n]*\\2`, "gm");
1122
+ const found = text.match(re)?.length ?? 0;
1123
+ if (found === 1) text = text.replace(re, `$1${key}: '${value}'`);
1124
+ else manual.push(`${path7.basename(file)}: set \`${key}: '${value}'\``);
1125
+ }
1126
+ fs7.writeFileSync(file, text);
1127
+ return manual;
1128
+ }
1092
1129
  function envLine(key, value) {
1093
1130
  if (!/[\s#"'`]/.test(value)) return `${key}=${value}`;
1094
1131
  return value.includes("'") ? `${key}="${value.replace(/"/g, '\\"')}"` : `${key}='${value}'`;
1095
1132
  }
1096
- function applyAdd(cwd, plan, registry, env = {}) {
1133
+ function applyAdd(cwd, plan, registry, env = {}, config = {}) {
1097
1134
  const result = {
1098
1135
  written: [],
1099
1136
  skipped: [],
@@ -1150,6 +1187,7 @@ function applyAdd(cwd, plan, registry, env = {}) {
1150
1187
  plan.env.filter((v) => !readEnvKeys(exampleFile).includes(v.key)).map((v) => `${v.key}=${v.example}`)
1151
1188
  );
1152
1189
  }
1190
+ result.manual.push(...setConfigValues(cwd, config));
1153
1191
  if (cfg.modelApi === "defineTable" && cfg.database === "postgresql" && newModels.length) {
1154
1192
  result.manual.push(...registerModels(cwd, cfg.language, newModels));
1155
1193
  }
@@ -1333,7 +1371,8 @@ import { ${pascal} } from '../../../model/${pascal}.js';
1333
1371
 
1334
1372
  export const POST = async ${typedArgs} => {
1335
1373
  const { name, email, password } = req.body;
1336
- if (!name || !email || !password) {
1374
+ // Strings only: an object such as {"$ne": null} would be read as a filter operator and match any account.
1375
+ if (typeof name !== 'string' || typeof email !== 'string' || typeof password !== 'string' || !name || !email || !password) {
1337
1376
  return res.status(400).json({ error: 'name, email and password are required' });
1338
1377
  }
1339
1378
  const existing = await ${db.findOne(pascal, "{ email }")};
@@ -1351,19 +1390,33 @@ function entityLoginContent(pascal, slug, cfg) {
1351
1390
  const typedArgs = ts ? "(req: Request, res: Response)" : "(req, res)";
1352
1391
  const typeImport = ts ? "import type { Request, Response } from 'express';\n" : "";
1353
1392
  return `${typeImport}import { issueToken, verifyPassword } from 'express-file-cluster/auth';
1393
+ import { rateLimit } from 'express-file-cluster';
1354
1394
  import { ${pascal} } from '../../../model/${pascal}.js';
1355
1395
 
1396
+ // 10 attempts per 15 minutes per address and account (see TRUST_PROXY behind a proxy).
1397
+ export const middlewares = [
1398
+ rateLimit({
1399
+ window: '15m',
1400
+ max: 10,
1401
+ key: (req) => \`\${req.ip}:\${String(req.body?.email ?? '').toLowerCase()}\`,
1402
+ }),
1403
+ ];
1404
+
1356
1405
  export const POST = async ${typedArgs} => {
1357
1406
  const { email, password } = req.body;
1358
- if (!email || !password) return res.status(400).json({ error: 'email and password are required' });
1407
+ // Strings only: an object such as {"$ne": null} would be read as a filter operator and match any account.
1408
+ if (typeof email !== 'string' || typeof password !== 'string' || !email || !password) {
1409
+ return res.status(400).json({ error: 'email and password are required' });
1410
+ }
1359
1411
 
1360
1412
  const record = await ${db.findOne(pascal, "{ email }")};
1361
1413
  if (!record) return res.status(401).json({ error: 'Invalid credentials' });
1362
1414
  const match = await verifyPassword(password, record.password);
1363
1415
  if (!match) return res.status(401).json({ error: 'Invalid credentials' });
1364
1416
  if (!record.isActive) return res.status(403).json({ error: 'Account suspended' });
1365
- await issueToken(res, { id: record.id, role: record.role, email: record.email });
1366
- res.json({ message: 'Logged in as ${slug}' });
1417
+ const token = await issueToken(res, { id: record.id, role: record.role, email: record.email });
1418
+ // bearer: the client stores the token itself; http-only: it's a cookie.
1419
+ res.json({ message: 'Logged in as ${slug}', ...(token ? { token } : {}) });
1367
1420
  };
1368
1421
  `;
1369
1422
  }
@@ -1734,6 +1787,7 @@ function addCommand() {
1734
1787
  if (!opts.yes && !tty) fail("Not a terminal \u2014 pass --yes to add without confirming.");
1735
1788
  const ask = opts.prompt && tty && plan.prompts.length > 0;
1736
1789
  let env = {};
1790
+ let config = {};
1737
1791
  if (!opts.yes || ask) {
1738
1792
  const term = openTerminal();
1739
1793
  try {
@@ -1742,15 +1796,19 @@ function addCommand() {
1742
1796
  return;
1743
1797
  }
1744
1798
  if (ask) {
1745
- console.log(pc8.bold("\n Configuration") + pc8.dim(" (saved to .env)\n"));
1746
- env = envFromAnswers(plan.prompts, await askPrompts(term, plan.prompts, cwd));
1799
+ const where = plan.prompts.some((p) => p.config !== void 0) ? ".env / efc.config" : ".env";
1800
+ console.log(pc8.bold("\n Configuration") + pc8.dim(` (saved to ${where})
1801
+ `));
1802
+ const answers = await askPrompts(term, plan.prompts, cwd);
1803
+ env = envFromAnswers(plan.prompts, answers);
1804
+ config = configFromAnswers(plan.prompts, answers);
1747
1805
  console.log();
1748
1806
  }
1749
1807
  } finally {
1750
1808
  term.close();
1751
1809
  }
1752
1810
  }
1753
- const result = applyAdd(cwd, plan, registry, env);
1811
+ const result = applyAdd(cwd, plan, registry, env, config);
1754
1812
  console.log(
1755
1813
  pc8.green(` \u2713 ${result.written.length} file(s) written`) + (result.conflicts.length ? pc8.yellow(`, ${result.conflicts.length} left alone`) : "")
1756
1814
  );