@tulipes/cli 0.2.0 → 0.3.0-rc.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.
Files changed (110) hide show
  1. package/dist/config-check.js +1 -1
  2. package/dist/env-check.d.ts +5 -3
  3. package/dist/env-check.js +26 -19
  4. package/dist/env-check.js.map +1 -1
  5. package/dist/main.js +83 -19
  6. package/dist/main.js.map +1 -1
  7. package/dist/migrate-0.12-env.d.ts +36 -0
  8. package/dist/migrate-0.12-env.js +250 -0
  9. package/dist/migrate-0.12-env.js.map +1 -0
  10. package/dist/migrate-0.12-scaffold.d.ts +1 -0
  11. package/dist/migrate-0.12-scaffold.js +197 -0
  12. package/dist/migrate-0.12-scaffold.js.map +1 -0
  13. package/dist/migrate-0.12.d.ts +47 -0
  14. package/dist/migrate-0.12.js +210 -0
  15. package/dist/migrate-0.12.js.map +1 -0
  16. package/dist/migrate.d.ts +3 -1
  17. package/dist/migrate.js +11 -5
  18. package/dist/migrate.js.map +1 -1
  19. package/dist/new-module.d.ts +7 -0
  20. package/dist/new-module.js +35 -16
  21. package/dist/new-module.js.map +1 -1
  22. package/dist/roles.d.ts +15 -0
  23. package/dist/roles.js +54 -0
  24. package/dist/roles.js.map +1 -0
  25. package/dist/routes.d.ts +7 -2
  26. package/dist/routes.js +19 -10
  27. package/dist/routes.js.map +1 -1
  28. package/dist/spec.d.ts +2 -0
  29. package/dist/spec.js +13 -11
  30. package/dist/spec.js.map +1 -1
  31. package/dist/sync.js +66 -53
  32. package/dist/sync.js.map +1 -1
  33. package/package.json +4 -4
  34. package/templates/AGENTS.md +35 -23
  35. package/templates/app/.envs/.env.development +2 -1
  36. package/templates/app/.envs/.env.production +2 -2
  37. package/templates/app/.envs/.env.staging +2 -2
  38. package/templates/app/README.md +44 -29
  39. package/templates/app/config/app.config.ts +60 -7
  40. package/templates/app/docs/agent-manifest.json +8 -681
  41. package/templates/app/modules/agent/controllers/{agent.controllers.ts → web.agent.controllers.ts} +1 -1
  42. package/templates/app/modules/agent/routes/{agent.routes.ts → web.agent.routes.ts} +4 -4
  43. package/templates/app/modules/auth/bootstrap/credentials.bootstrap.ts +20 -12
  44. package/templates/app/modules/auth/bootstrap/seed-admin.bootstrap.ts +4 -2
  45. package/templates/app/modules/auth/controllers/{auth.controllers.ts → web.auth.controllers.ts} +1 -1
  46. package/templates/app/modules/auth/helpers/passport.ts +1 -1
  47. package/templates/app/modules/auth/helpers/session-cache.ts +3 -3
  48. package/templates/app/modules/auth/helpers/tokens.ts +3 -5
  49. package/templates/app/modules/auth/module.acl.ts +31 -9
  50. package/templates/app/modules/auth/module.config.ts +5 -3
  51. package/templates/app/modules/auth/package.json +10 -10
  52. package/templates/app/modules/auth/routes/{auth.routes.ts → web.auth.routes.ts} +15 -10
  53. package/templates/app/modules/auth/tests/auth.test.ts +1 -1
  54. package/templates/app/modules/config/controllers/{config.controllers.ts → bo.config.controllers.ts} +3 -2
  55. package/templates/app/modules/config/helpers/audit.ts +1 -1
  56. package/templates/app/modules/config/helpers/describe.ts +35 -26
  57. package/templates/app/modules/config/module.acl.ts +1 -1
  58. package/templates/app/modules/config/routes/{config.routes.ts → bo.config.routes.ts} +5 -5
  59. package/templates/app/modules/config/tests/config.test.ts +14 -6
  60. package/templates/app/modules/core/helpers/cache/index.ts +8 -7
  61. package/templates/app/modules/core/helpers/lazy.ts +3 -3
  62. package/templates/app/modules/core/helpers/logger/index.ts +24 -16
  63. package/templates/app/modules/core/module.config.ts +5 -3
  64. package/templates/app/modules/core/package.json +46 -19
  65. package/templates/app/modules/core/routes/core.routes.ts +4 -4
  66. package/templates/app/modules/hello/agent/hello.agent.ts +2 -2
  67. package/templates/app/modules/hello/controllers/{hello.controllers.ts → web/hello.controllers.ts} +1 -1
  68. package/templates/app/modules/hello/controllers/{greetings.controllers.ts → web/hello.greetings.controllers.ts} +2 -2
  69. package/templates/app/modules/hello/module.acl.ts +12 -7
  70. package/templates/app/modules/hello/queues/hello.queues.ts +1 -1
  71. package/templates/app/modules/hello/routes/{greetings.routes.ts → web/hello.greetings.routes.ts} +4 -4
  72. package/templates/app/modules/hello/routes/{hello.routes.ts → web/hello.routes.ts} +14 -8
  73. package/templates/app/modules/security/helpers/rate-limit.ts +3 -2
  74. package/templates/app/modules/security/routes/security.routes.ts +4 -4
  75. package/templates/app/modules/settings/bootstrap/log-streams.bootstrap.ts +2 -2
  76. package/templates/app/modules/settings/controllers/{settings.controllers.ts → bo.settings.controllers.ts} +7 -6
  77. package/templates/app/modules/settings/helpers/log-stream.ts +6 -5
  78. package/templates/app/modules/settings/routes/{settings.routes.ts → bo.settings.routes.ts} +3 -3
  79. package/templates/app/modules/settings/tests/settings.test.ts +21 -25
  80. package/templates/app/modules/users/controllers/{users.controllers.ts → bo.users.controllers.ts} +5 -55
  81. package/templates/{overlays/no-queues/modules/users/controllers/users.controllers.ts → app/modules/users/controllers/web.users.controllers.ts} +4 -42
  82. package/templates/app/modules/users/module.acl.ts +4 -4
  83. package/templates/app/modules/users/queues/users.queues.ts +1 -1
  84. package/templates/app/modules/users/routes/bo.users.routes.ts +39 -0
  85. package/templates/app/modules/users/routes/web.users.routes.ts +45 -0
  86. package/templates/app/nginx/production.conf +1 -1
  87. package/templates/app/scripts/deploy-nginx.ts +3 -2
  88. package/templates/app/tests/support.ts +4 -3
  89. package/templates/claude/skills/tulipes-agent-tool/SKILL.md +6 -4
  90. package/templates/claude/skills/tulipes-boot-errors/SKILL.md +13 -7
  91. package/templates/claude/skills/tulipes-config/SKILL.md +6 -4
  92. package/templates/claude/skills/tulipes-endpoint/SKILL.md +34 -15
  93. package/templates/claude/skills/tulipes-env-variable/SKILL.md +62 -37
  94. package/templates/claude/skills/tulipes-i18n/SKILL.md +20 -1
  95. package/templates/claude/skills/tulipes-module/SKILL.md +10 -5
  96. package/templates/claude/skills/tulipes-permissions/SKILL.md +123 -35
  97. package/templates/claude/skills/tulipes-queue/SKILL.md +3 -2
  98. package/templates/claude/skills/tulipes-settings/SKILL.md +9 -8
  99. package/templates/claude/skills/tulipes-spec/SKILL.md +12 -2
  100. package/templates/minimal/config/app.config.ts +13 -3
  101. package/templates/minimal/modules/agent/routes/{agent.routes.ts → web.agent.routes.ts} +2 -2
  102. package/templates/minimal/modules/core/module.acl.ts +7 -1
  103. package/templates/minimal/modules/core/package.json +4 -4
  104. package/templates/minimal/modules/hello/module.acl.ts +1 -1
  105. package/templates/minimal/modules/hello/routes/{health.routes.ts → web.hello.health.routes.ts} +1 -1
  106. package/templates/minimal/modules/hello/routes/{hello.routes.ts → web.hello.routes.ts} +1 -1
  107. package/templates/overlays/no-queues/modules/hello/controllers/{greetings.controllers.ts → web/hello.greetings.controllers.ts} +1 -1
  108. package/templates/overlays/no-queues/modules/users/controllers/bo.users.controllers.ts +57 -0
  109. package/templates/versions.json +8 -8
  110. package/templates/app/modules/users/routes/users.routes.ts +0 -60
@@ -3,24 +3,35 @@ import type { AppConfigFn } from "@tulipes/core/boot";
3
3
  /**
4
4
  * ── The app-wide config seed ──────────────────────────────────────────
5
5
  *
6
- * Runs FIRST in boot phase 6, before any module.config.ts factory, and
6
+ * Runs FIRST in boot phase 4, before any module's settings are loaded, and
7
7
  * whatever it returns becomes the base of the global config. Modules read
8
8
  * it through `ctx.config.<key>`.
9
9
  *
10
+ * It receives `env`: every module's environment values, resolved from the
11
+ * container, `.envs/.env.<APP_ENV>` and the defaults each module declares
12
+ * in its package.json `tulipes.env` — `env.core.port`, `env.auth.adminEmail`
13
+ * — typed by `pnpm sync`. This is the one place the environment is wired
14
+ * to what the framework and the providers read: `server.port` for core,
15
+ * `mongoose.*` for @tulipes/mongoose, `bullmq.redisUrl` for @tulipes/bullmq.
16
+ * Modules never need this wiring: each reads its own values as
17
+ * `ctx.config.<module>.<name>`, beside its settings.
18
+ *
10
19
  * Add a key here when two or more modules share a value. Config belonging
11
20
  * to ONE feature goes in that module's `module.config.ts` instead, where
12
21
  * `pnpm sync` types it for you — that is where `users.maxSessions` and
13
22
  * `users.signupMode` live. A value that differs per deployment belongs in
14
- * neither: declare it in a module's `meta.variables.json` and read it with
15
- * `Environment.get`, the way MONGO_URI, CORS_ORIGINS and BODY_LIMIT do.
23
+ * neither: declare it under `tulipes.env` in a module's package.json and
24
+ * read it as `ctx.config.<module>.<name>`, the way MONGO_URI and REDIS_URL
25
+ * are declared by the core module.
16
26
  *
17
- * The framework reads exactly one field of this object: `app.name`, which
18
- * titles the startup banner. Everything else is yours.
27
+ * Under inspection (`tulipes routes`, `tulipes spec`) a value that is
28
+ * missing or invalid is `undefined` rather than an error, so this file
29
+ * only wires values and never requires one.
19
30
  */
20
31
 
21
32
  // `satisfies` (not a type annotation) so TypeScript keeps the exact shape
22
33
  // of this object for the augmentation at the bottom of the file.
23
- const appConfig = (() => ({
34
+ const appConfig = ((env) => ({
24
35
  app: {
25
36
  name: "tulipes-example",
26
37
  },
@@ -34,6 +45,31 @@ const appConfig = (() => ({
34
45
  prefix: "/api/v1",
35
46
  },
36
47
 
48
+ /** What core listens on. */
49
+ server: {
50
+ port: env.core.port,
51
+ },
52
+
53
+ /**
54
+ * How @tulipes/mongoose reaches MongoDB. A full MONGO_URI wins — it is the
55
+ * only way to name a replica set, an Atlas cluster or driver options;
56
+ * otherwise the host, credentials and database name are handed to the
57
+ * driver separately, so nothing is URL-encoded by hand.
58
+ */
59
+ mongoose: env.core.mongodbUri
60
+ ? { uri: env.core.mongodbUri }
61
+ : {
62
+ uri: env.core.mongodbHost,
63
+ user: env.core.mongodbUsername,
64
+ pass: env.core.mongodbPassword,
65
+ dbName: env.core.mongodbDbName,
66
+ },
67
+
68
+ /** How @tulipes/bullmq reaches Redis. */
69
+ bullmq: {
70
+ redisUrl: env.core.redisUrl,
71
+ },
72
+
37
73
  /**
38
74
  * The languages this app speaks. Every module owns its own strings in
39
75
  * `modules/<name>/i18n/<locale>.json` — the module is the namespace —
@@ -50,6 +86,21 @@ const appConfig = (() => ({
50
86
  supportedLocales: ["en", "fr"],
51
87
  },
52
88
 
89
+ /**
90
+ * How instants are read. Dates are stored and returned as UTC; a zone is
91
+ * what "today", "02:00" and a timestamp in an email mean. A request picks
92
+ * its own with `?tz=Europe/Paris` or an X-Timezone header (narrowed to
93
+ * `supported` when you list it), and handlers read it as `req.timezone`
94
+ * with helpers on `req.time`; code with no request uses `ctx.time`.
95
+ *
96
+ * `default` is also the zone of cron patterns given to `ctx.queues`, and
97
+ * — unless `applyToProcess: false` — the process zone, so log times,
98
+ * daily log rotation and `Date#getHours()` agree with it.
99
+ */
100
+ timezone: {
101
+ default: "UTC",
102
+ },
103
+
53
104
  /**
54
105
  * List-endpoint defaults, so every module paginates identically and no
55
106
  * caller can ask for ten thousand rows. → modules/users/routes
@@ -67,7 +118,9 @@ export default appConfig;
67
118
  * number, not `unknown`. `pnpm sync` does this automatically for
68
119
  * module.config.ts factories; the app-level seed types itself here.
69
120
  * Partial because the config object is empty until this factory runs.
121
+ * `server`, `mongoose` and `bullmq` are left out: core and the providers
122
+ * already type the keys they read.
70
123
  */
71
124
  declare module "@tulipes/core/config" {
72
- interface GlobalConfig extends Partial<ReturnType<typeof appConfig>> {}
125
+ interface GlobalConfig extends Partial<Omit<ReturnType<typeof appConfig>, "server" | "mongoose" | "bullmq">> {}
73
126
  }