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
@@ -1,20 +1,19 @@
1
1
  #!/usr/bin/env node
2
2
  "use strict"; function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
3
3
 
4
- var _chunkR34R7QPDcjs = require('../chunk-R34R7QPD.cjs');
4
+ var _chunkDCJOWFVDcjs = require('../chunk-DCJOWFVD.cjs');
5
5
 
6
6
 
7
- var _chunkT4OHFU5Tcjs = require('../chunk-T4OHFU5T.cjs');
7
+ var _chunkYK4ZM3CAcjs = require('../chunk-YK4ZM3CA.cjs');
8
8
 
9
9
 
10
- var _chunkQL6EWT4Bcjs = require('../chunk-QL6EWT4B.cjs');
10
+ var _chunk4DOHQU6Icjs = require('../chunk-4DOHQU6I.cjs');
11
11
 
12
12
 
13
- var _chunkX2US4RAMcjs = require('../chunk-X2US4RAM.cjs');
14
- require('../chunk-VQSWSYK6.cjs');
15
- require('../chunk-7YEX4MQV.cjs');
16
- require('../chunk-TI24L4XE.cjs');
17
- require('../chunk-YL37D6KM.cjs');
13
+ var _chunkNKLOE4AKcjs = require('../chunk-NKLOE4AK.cjs');
14
+ require('../chunk-WBLUGOAG.cjs');
15
+ require('../chunk-GBI77W5T.cjs');
16
+ require('../chunk-DUADUR6R.cjs');
18
17
 
19
18
  // src/cli/index.ts
20
19
  var _fs = require('fs'); var _fs2 = _interopRequireDefault(_fs);
@@ -502,7 +501,7 @@ async function bullmqAdmin(redisUrl, queueName = "efc") {
502
501
  } catch (e2) {
503
502
  throw new Error("[EFC] bullmq is not installed. Run: npm install bullmq");
504
503
  }
505
- const queue = new bullmq.Queue(queueName, { connection: _chunkT4OHFU5Tcjs.parseRedisUrl.call(void 0, redisUrl) });
504
+ const queue = new bullmq.Queue(queueName, { connection: _chunkYK4ZM3CAcjs.parseRedisUrl.call(void 0, redisUrl) });
506
505
  const failedJobs = async (ids2) => {
507
506
  if (ids2.length === 0) return queue.getFailed(0, -1);
508
507
  const jobs = await Promise.all(ids2.map((id) => queue.getJob(id)));
@@ -553,7 +552,7 @@ async function connect(opts) {
553
552
  if (backend === "bullmq") return bullmqAdmin(_nullishCoalesce(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 Promise.resolve().then(() => _interopRequireWildcard(require("../pgboss-backend-TCHI7CHM.cjs")));
555
+ const { pgBossAdmin } = await Promise.resolve().then(() => _interopRequireWildcard(require("../pgboss-backend-RVHUBJTU.cjs")));
557
556
  return pgBossAdmin(databaseUrl, opts.queue);
558
557
  }
559
558
  throw new Error(`[EFC] Unknown task backend: ${backend}`);
@@ -647,7 +646,7 @@ function routesCommand() {
647
646
  console.error(_picocolors2.default.red("[EFC] Could not find apiDir (expected src/api)"));
648
647
  process.exit(1);
649
648
  }
650
- const routes = _chunkR34R7QPDcjs.scanDir.call(void 0, apiDir);
649
+ const routes = _chunkDCJOWFVDcjs.scanDir.call(void 0, apiDir);
651
650
  if (routes.length === 0) {
652
651
  console.log(_picocolors2.default.yellow("No routes found."));
653
652
  return;
@@ -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 = _path2.default.join(cwd, "src", "model");
962
+ if (database === "mongodb" && _fs2.default.existsSync(modelDir)) {
963
+ const sources = _fs2.default.readdirSync(modelDir).filter((f) => /\.[jt]s$/.test(f)).map((f) => _fs2.default.readFileSync(_path2.default.join(modelDir, f), "utf8")).join("\n");
964
+ if (/\bdefineCollection\(/.test(sources)) modelApi = "defineCollection";
965
+ }
954
966
  if (database === "postgresql" && _fs2.default.existsSync(modelDir)) {
955
967
  const sources = _fs2.default.readdirSync(modelDir).filter((f) => /\.[jt]s$/.test(f)).map((f) => _fs2.default.readFileSync(_path2.default.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 = _nullishCoalesce(readEfc
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) => _path2.default.join(cwd, f)).find((f) => _fs2.default.existsSync(f));
1117
+ if (!file) return entries.map(([k, v]) => `efc.config: set \`${k}: '${v}'\``);
1118
+ let text = _fs2.default.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 = _nullishCoalesce(_optionalChain([text, 'access', _32 => _32.match, 'call', _33 => _33(re), 'optionalAccess', _34 => _34.length]), () => ( 0));
1123
+ if (found === 1) text = text.replace(re, `$1${key}: '${value}'`);
1124
+ else manual.push(`${_path2.default.basename(file)}: set \`${key}: '${value}'\``);
1125
+ }
1126
+ _fs2.default.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: [],
@@ -1116,7 +1153,7 @@ function applyAdd(cwd, plan, registry, env = {}) {
1116
1153
  _fs2.default.mkdirSync(_path2.default.dirname(abs), { recursive: true });
1117
1154
  _fs2.default.writeFileSync(abs, f.content);
1118
1155
  result.written.push(f.path);
1119
- const model = _optionalChain([/^src\/model\/([A-Za-z0-9_]+)\.[jt]s$/, 'access', _32 => _32.exec, 'call', _33 => _33(f.path), 'optionalAccess', _34 => _34[1]]);
1156
+ const model = _optionalChain([/^src\/model\/([A-Za-z0-9_]+)\.[jt]s$/, 'access', _35 => _35.exec, 'call', _36 => _36(f.path), 'optionalAccess', _37 => _37[1]]);
1120
1157
  if (model && model !== "index" && !existed) newModels.push(model);
1121
1158
  }
1122
1159
  cfg.files[f.path] = sha256(f.content);
@@ -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
  }
@@ -1426,19 +1479,19 @@ function generateEntityAuth(cwd, entityName, cfg, options) {
1426
1479
  for (const f of files) {
1427
1480
  const abs = _path2.default.join(cwd, f.rel);
1428
1481
  const exists = _fs2.default.existsSync(abs);
1429
- if (exists && !_optionalChain([options, 'optionalAccess', _35 => _35.overwrite])) {
1482
+ if (exists && !_optionalChain([options, 'optionalAccess', _38 => _38.overwrite])) {
1430
1483
  result.conflicts.push(f.rel);
1431
1484
  result.manual.push(`${f.rel} already exists \u2014 skipped (pass --overwrite to replace)`);
1432
1485
  continue;
1433
1486
  }
1434
1487
  result.written.push(f.rel);
1435
- if (!_optionalChain([options, 'optionalAccess', _36 => _36.dryRun])) {
1488
+ if (!_optionalChain([options, 'optionalAccess', _39 => _39.dryRun])) {
1436
1489
  _fs2.default.mkdirSync(_path2.default.dirname(abs), { recursive: true });
1437
1490
  _fs2.default.writeFileSync(abs, f.content);
1438
1491
  cfg.files[f.rel] = sha256(f.content);
1439
1492
  }
1440
1493
  }
1441
- if (entityUsesTables(cfg) && !_optionalChain([options, 'optionalAccess', _37 => _37.dryRun])) {
1494
+ if (entityUsesTables(cfg) && !_optionalChain([options, 'optionalAccess', _40 => _40.dryRun])) {
1442
1495
  result.manual.push(...registerModels(cwd, cfg.language, [pascal]));
1443
1496
  }
1444
1497
  const envFile = _path2.default.join(cwd, ".env");
@@ -1446,7 +1499,7 @@ function generateEntityAuth(cwd, entityName, cfg, options) {
1446
1499
  const envKeys = readEnvKeys(envFile);
1447
1500
  if (!envKeys.includes("JWT_SECRET")) {
1448
1501
  const secret = _crypto2.default.randomBytes(64).toString("hex");
1449
- if (!_optionalChain([options, 'optionalAccess', _38 => _38.dryRun])) {
1502
+ if (!_optionalChain([options, 'optionalAccess', _41 => _41.dryRun])) {
1450
1503
  appendEnv(envFile, [`JWT_SECRET=${secret}`]);
1451
1504
  const exampleFile = _path2.default.join(cwd, ".env.example");
1452
1505
  if (_fs2.default.existsSync(exampleFile) && !readEnvKeys(exampleFile).includes("JWT_SECRET")) {
@@ -1458,7 +1511,7 @@ function generateEntityAuth(cwd, entityName, cfg, options) {
1458
1511
  }
1459
1512
  const itemName = `auth:${slug}`;
1460
1513
  if (!cfg.items.includes(itemName)) cfg.items.push(itemName);
1461
- if (!_optionalChain([options, 'optionalAccess', _39 => _39.dryRun])) {
1514
+ if (!_optionalChain([options, 'optionalAccess', _42 => _42.dryRun])) {
1462
1515
  writeEfcJson(cwd, cfg);
1463
1516
  }
1464
1517
  return result;
@@ -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(_picocolors2.default.bold("\n Configuration") + _picocolors2.default.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(_picocolors2.default.bold("\n Configuration") + _picocolors2.default.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
  _picocolors2.default.green(` \u2713 ${result.written.length} file(s) written`) + (result.conflicts.length ? _picocolors2.default.yellow(`, ${result.conflicts.length} left alone`) : "")
1756
1814
  );
@@ -1798,7 +1856,7 @@ function listCommand() {
1798
1856
  try {
1799
1857
  const cwd = process.cwd();
1800
1858
  const registry = new Registry();
1801
- const installed = new Set(_nullishCoalesce(_optionalChain([readEfcJson, 'call', _40 => _40(cwd), 'optionalAccess', _41 => _41.items]), () => ( [])));
1859
+ const installed = new Set(_nullishCoalesce(_optionalChain([readEfcJson, 'call', _43 => _43(cwd), 'optionalAccess', _44 => _44.items]), () => ( [])));
1802
1860
  const groups = [...new Set(registry.index.items.map((i) => i.group))];
1803
1861
  for (const group of groups) {
1804
1862
  console.log(_picocolors2.default.bold(`
@@ -1809,7 +1867,7 @@ function listCommand() {
1809
1867
  console.log(` ${mark} ${_picocolors2.default.cyan(item.name.padEnd(20))} ${item.description}${deps}`);
1810
1868
  }
1811
1869
  }
1812
- const entities = (_nullishCoalesce(_optionalChain([readEfcJson, 'call', _42 => _42(cwd), 'optionalAccess', _43 => _43.items]), () => ( []))).filter((i) => i.startsWith("auth:")).map((i) => i.slice(5));
1870
+ const entities = (_nullishCoalesce(_optionalChain([readEfcJson, 'call', _45 => _45(cwd), 'optionalAccess', _46 => _46.items]), () => ( []))).filter((i) => i.startsWith("auth:")).map((i) => i.slice(5));
1813
1871
  if (entities.length > 0) {
1814
1872
  console.log(_picocolors2.default.bold("\n custom auth entities"));
1815
1873
  for (const e of entities) {
@@ -1967,15 +2025,15 @@ function parseAttrs(s) {
1967
2025
  return out;
1968
2026
  }
1969
2027
  function arg(a, name) {
1970
- if (!_optionalChain([a, 'optionalAccess', _44 => _44.args])) return void 0;
2028
+ if (!_optionalChain([a, 'optionalAccess', _47 => _47.args])) return void 0;
1971
2029
  const parts = splitTop(a.args, ",");
1972
2030
  if (name) {
1973
2031
  const p = parts.find((x) => x.startsWith(`${name}:`));
1974
- return _optionalChain([p, 'optionalAccess', _45 => _45.slice, 'call', _46 => _46(name.length + 1), 'access', _47 => _47.trim, 'call', _48 => _48()]);
2032
+ return _optionalChain([p, 'optionalAccess', _48 => _48.slice, 'call', _49 => _49(name.length + 1), 'access', _50 => _50.trim, 'call', _51 => _51()]);
1975
2033
  }
1976
2034
  return parts.find((x) => !/^\w+\s*:/.test(x));
1977
2035
  }
1978
- var unquote = (s) => _optionalChain([s, 'optionalAccess', _49 => _49.replace, 'call', _50 => _50(/^"(.*)"$/, "$1")]);
2036
+ var unquote = (s) => _optionalChain([s, 'optionalAccess', _52 => _52.replace, 'call', _53 => _53(/^"(.*)"$/, "$1")]);
1979
2037
  var list = (s) => s ? splitTop(s.replace(/^\[|\]$/g, ""), ",").map((x) => x.trim()).filter(Boolean) : [];
1980
2038
  function parsePrisma(source) {
1981
2039
  const text = source.replace(/\/\/.*$/gm, "");
@@ -1988,7 +2046,7 @@ function parsePrisma(source) {
1988
2046
  const [, kind, name, body] = block;
1989
2047
  const lines = body.split("\n").map((l) => l.trim()).filter(Boolean);
1990
2048
  if (kind === "datasource") {
1991
- provider = unquote(_optionalChain([/provider\s*=\s*("[^"]*")/, 'access', _51 => _51.exec, 'call', _52 => _52(body), 'optionalAccess', _53 => _53[1]]));
2049
+ provider = unquote(_optionalChain([/provider\s*=\s*("[^"]*")/, 'access', _54 => _54.exec, 'call', _55 => _55(body), 'optionalAccess', _56 => _56[1]]));
1992
2050
  } else if (kind === "enum") {
1993
2051
  const values = [];
1994
2052
  const names = [];
@@ -2050,7 +2108,7 @@ function importPrisma(source) {
2050
2108
  const def = _nullishCoalesce(arg(attr(_nullishCoalesce(id, () => ( { attrs: [] })), "@default")), () => ( ""));
2051
2109
  idKind.set(
2052
2110
  m.name,
2053
- _optionalChain([id, 'optionalAccess', _54 => _54.type]) === "Int" && /autoincrement/.test(def) ? "serial" : _optionalChain([id, 'optionalAccess', _55 => _55.type]) === "BigInt" && /autoincrement/.test(def) ? "bigserial" : "uuid"
2111
+ _optionalChain([id, 'optionalAccess', _57 => _57.type]) === "Int" && /autoincrement/.test(def) ? "serial" : _optionalChain([id, 'optionalAccess', _58 => _58.type]) === "BigInt" && /autoincrement/.test(def) ? "bigserial" : "uuid"
2054
2112
  );
2055
2113
  }
2056
2114
  const rels = [];
@@ -2080,7 +2138,7 @@ function importPrisma(source) {
2080
2138
  const fields = [];
2081
2139
  const relations = {};
2082
2140
  const table = _nullishCoalesce(unquote(arg(blocks(m, "@@map")[0])), () => ( m.name));
2083
- if (table !== _chunkX2US4RAMcjs.tableNameFor.call(void 0, m.name)) options["collection"] = table;
2141
+ if (table !== _chunkNKLOE4AKcjs.tableNameFor.call(void 0, m.name)) options["collection"] = table;
2084
2142
  const kind = idKind.get(m.name);
2085
2143
  if (kind !== "uuid") options["id"] = kind;
2086
2144
  if (blocks(m, "@@id").length) {
@@ -2136,7 +2194,7 @@ function importPrisma(source) {
2136
2194
  continue;
2137
2195
  }
2138
2196
  const other = partner(r);
2139
- if (r.list && _optionalChain([other, 'optionalAccess', _56 => _56.list])) {
2197
+ if (r.list && _optionalChain([other, 'optionalAccess', _59 => _59.list])) {
2140
2198
  if (m.name < r.target || m.name === r.target && f.name < other.field) {
2141
2199
  fields.push([
2142
2200
  f.name,
@@ -2206,7 +2264,7 @@ function importPrisma(source) {
2206
2264
  }
2207
2265
  function scalarDef(f, enums, notes) {
2208
2266
  const db = f.attrs.find((a) => a.name.startsWith("@db."));
2209
- const dbType = _optionalChain([db, 'optionalAccess', _57 => _57.name, 'access', _58 => _58.slice, 'call', _59 => _59(4)]);
2267
+ const dbType = _optionalChain([db, 'optionalAccess', _60 => _60.name, 'access', _61 => _61.slice, 'call', _62 => _62(4)]);
2210
2268
  let def;
2211
2269
  const e = enums.get(f.type);
2212
2270
  if (e) def = { type: "string", enum: e.values, nativeEnum: true };
@@ -2214,7 +2272,7 @@ function scalarDef(f, enums, notes) {
2214
2272
  switch (f.type) {
2215
2273
  case "String":
2216
2274
  if (dbType === "Uuid") def = { type: "uuid" };
2217
- else if (dbType === "VarChar" && _optionalChain([db, 'optionalAccess', _60 => _60.args]))
2275
+ else if (dbType === "VarChar" && _optionalChain([db, 'optionalAccess', _63 => _63.args]))
2218
2276
  def = { type: "string", maxLength: Number(db.args) };
2219
2277
  else def = { type: "string" };
2220
2278
  break;
@@ -2228,7 +2286,7 @@ function scalarDef(f, enums, notes) {
2228
2286
  def = { type: "number" };
2229
2287
  break;
2230
2288
  case "Decimal": {
2231
- const [p, s] = (_nullishCoalesce(_optionalChain([db, 'optionalAccess', _61 => _61.args]), () => ( ""))).split(",").map((x) => Number(x.trim()));
2289
+ const [p, s] = (_nullishCoalesce(_optionalChain([db, 'optionalAccess', _64 => _64.args]), () => ( ""))).split(",").map((x) => Number(x.trim()));
2232
2290
  def = p ? { type: "decimal", precision: p, scale: _nullishCoalesce(s, () => ( 0)) } : { type: "decimal" };
2233
2291
  break;
2234
2292
  }
@@ -2267,7 +2325,7 @@ function importPrismaCommand() {
2267
2325
  const { models, warnings } = importPrisma(_fs2.default.readFileSync(file, "utf8"));
2268
2326
  const typescript = _fs2.default.existsSync(_path2.default.join(process.cwd(), "tsconfig.json"));
2269
2327
  const dir = _path2.default.resolve(opts.out);
2270
- const { written, skipped } = _chunkQL6EWT4Bcjs.writeModels.call(void 0, dir, models, {
2328
+ const { written, skipped } = _chunk4DOHQU6Icjs.writeModels.call(void 0, dir, models, {
2271
2329
  typescript,
2272
2330
  ...opts.force && { force: true }
2273
2331
  });