create-questpie 2.0.4 → 2.1.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 (152) hide show
  1. package/dist/index.mjs +362 -119
  2. package/package.json +2 -3
  3. package/templates/elysia/AGENTS.md +56 -0
  4. package/templates/elysia/CLAUDE.md +39 -0
  5. package/templates/elysia/Dockerfile +24 -0
  6. package/templates/elysia/README.md +148 -0
  7. package/templates/elysia/docker/init-extensions.sql +11 -0
  8. package/templates/elysia/docker-compose.yml +21 -0
  9. package/templates/elysia/env.example +16 -0
  10. package/templates/elysia/gitignore +6 -0
  11. package/templates/elysia/package.json +47 -0
  12. package/templates/elysia/questpie.config.ts +12 -0
  13. package/templates/elysia/src/index.ts +21 -0
  14. package/templates/elysia/src/lib/auth-client.ts +32 -0
  15. package/templates/elysia/src/lib/client.ts +13 -0
  16. package/templates/elysia/src/lib/env.ts +24 -0
  17. package/templates/elysia/src/lib/query-client.ts +18 -0
  18. package/templates/elysia/src/lib/query.ts +18 -0
  19. package/templates/elysia/src/questpie/server/.generated/context.gen.ts +200 -0
  20. package/templates/elysia/src/questpie/server/.generated/entities.gen.ts +84 -0
  21. package/templates/elysia/src/questpie/server/.generated/factories.ts +65 -0
  22. package/templates/elysia/src/questpie/server/.generated/index.ts +131 -0
  23. package/templates/elysia/src/questpie/server/.generated/names.gen.ts +25 -0
  24. package/templates/elysia/src/questpie/server/app.ts +10 -0
  25. package/templates/elysia/src/questpie/server/collections/index.ts +1 -0
  26. package/templates/elysia/src/questpie/server/collections/posts.collection.ts +10 -0
  27. package/templates/elysia/src/questpie/server/config/auth.ts +8 -0
  28. package/templates/elysia/src/questpie/server/config/openapi.ts +10 -0
  29. package/templates/elysia/src/questpie/server/globals/index.ts +1 -0
  30. package/templates/elysia/src/questpie/server/globals/site-settings.global.ts +10 -0
  31. package/templates/elysia/src/questpie/server/modules.ts +8 -0
  32. package/templates/elysia/src/questpie/server/questpie.config.ts +21 -0
  33. package/templates/elysia/tsconfig.json +28 -0
  34. package/templates/hono/AGENTS.md +56 -0
  35. package/templates/hono/CLAUDE.md +39 -0
  36. package/templates/hono/Dockerfile +24 -0
  37. package/templates/hono/README.md +148 -0
  38. package/templates/hono/docker/init-extensions.sql +11 -0
  39. package/templates/hono/docker-compose.yml +21 -0
  40. package/templates/hono/env.example +16 -0
  41. package/templates/hono/gitignore +6 -0
  42. package/templates/hono/package.json +47 -0
  43. package/templates/hono/questpie.config.ts +12 -0
  44. package/templates/hono/src/index.ts +30 -0
  45. package/templates/hono/src/lib/auth-client.ts +32 -0
  46. package/templates/hono/src/lib/client.ts +13 -0
  47. package/templates/hono/src/lib/env.ts +24 -0
  48. package/templates/hono/src/lib/query-client.ts +18 -0
  49. package/templates/hono/src/lib/query.ts +18 -0
  50. package/templates/hono/src/questpie/server/.generated/context.gen.ts +200 -0
  51. package/templates/hono/src/questpie/server/.generated/entities.gen.ts +84 -0
  52. package/templates/hono/src/questpie/server/.generated/factories.ts +65 -0
  53. package/templates/hono/src/questpie/server/.generated/index.ts +131 -0
  54. package/templates/hono/src/questpie/server/.generated/names.gen.ts +25 -0
  55. package/templates/hono/src/questpie/server/app.ts +10 -0
  56. package/templates/hono/src/questpie/server/collections/index.ts +1 -0
  57. package/templates/hono/src/questpie/server/collections/posts.collection.ts +10 -0
  58. package/templates/hono/src/questpie/server/config/auth.ts +8 -0
  59. package/templates/hono/src/questpie/server/config/openapi.ts +10 -0
  60. package/templates/hono/src/questpie/server/globals/index.ts +1 -0
  61. package/templates/hono/src/questpie/server/globals/site-settings.global.ts +10 -0
  62. package/templates/hono/src/questpie/server/modules.ts +8 -0
  63. package/templates/hono/src/questpie/server/questpie.config.ts +21 -0
  64. package/templates/hono/tsconfig.json +28 -0
  65. package/templates/next/AGENTS.md +55 -0
  66. package/templates/next/CLAUDE.md +39 -0
  67. package/templates/next/Dockerfile +25 -0
  68. package/templates/next/README.md +148 -0
  69. package/templates/next/components.json +22 -0
  70. package/templates/next/docker/init-extensions.sql +11 -0
  71. package/templates/next/docker-compose.yml +21 -0
  72. package/templates/next/env.example +16 -0
  73. package/templates/next/gitignore +10 -0
  74. package/templates/next/next-env.d.ts +5 -0
  75. package/templates/next/next.config.ts +20 -0
  76. package/templates/next/package.json +54 -0
  77. package/templates/next/postcss.config.mjs +8 -0
  78. package/templates/next/public/.gitkeep +0 -0
  79. package/templates/next/questpie.config.ts +12 -0
  80. package/templates/next/src/app/admin/[[...all]]/page.tsx +34 -0
  81. package/templates/next/src/app/admin/admin.css +4 -0
  82. package/templates/next/src/app/admin/layout.tsx +63 -0
  83. package/templates/next/src/app/api/[...all]/route.ts +24 -0
  84. package/templates/next/src/app/layout.tsx +24 -0
  85. package/templates/next/src/app/not-found.tsx +18 -0
  86. package/templates/next/src/app/page.tsx +74 -0
  87. package/templates/next/src/app/providers.tsx +11 -0
  88. package/templates/next/src/lib/auth-client.ts +12 -0
  89. package/templates/next/src/lib/client.ts +13 -0
  90. package/templates/next/src/lib/env.ts +24 -0
  91. package/templates/next/src/lib/query-client.ts +18 -0
  92. package/templates/next/src/lib/query.ts +18 -0
  93. package/templates/next/src/questpie/admin/.generated/client.ts +13 -0
  94. package/templates/next/src/questpie/admin/admin.ts +9 -0
  95. package/templates/next/src/questpie/admin/modules.ts +3 -0
  96. package/templates/next/src/questpie/server/.generated/context.gen.ts +204 -0
  97. package/templates/next/src/questpie/server/.generated/entities.gen.ts +100 -0
  98. package/templates/next/src/questpie/server/.generated/factories.ts +204 -0
  99. package/templates/next/src/questpie/server/.generated/index.ts +139 -0
  100. package/templates/next/src/questpie/server/.generated/names.gen.ts +31 -0
  101. package/templates/next/src/questpie/server/app.ts +10 -0
  102. package/templates/next/src/questpie/server/collections/index.ts +1 -0
  103. package/templates/next/src/questpie/server/collections/posts.collection.ts +58 -0
  104. package/templates/next/src/questpie/server/config/admin.ts +80 -0
  105. package/templates/next/src/questpie/server/config/auth.ts +8 -0
  106. package/templates/next/src/questpie/server/config/openapi.ts +10 -0
  107. package/templates/next/src/questpie/server/globals/index.ts +1 -0
  108. package/templates/next/src/questpie/server/globals/site-settings.global.ts +19 -0
  109. package/templates/next/src/questpie/server/modules.ts +9 -0
  110. package/templates/next/src/questpie/server/questpie.config.ts +21 -0
  111. package/templates/next/src/styles.css +125 -0
  112. package/templates/next/tsconfig.json +37 -0
  113. package/templates/tanstack-start/AGENTS.md +35 -607
  114. package/templates/tanstack-start/CLAUDE.md +26 -134
  115. package/templates/tanstack-start/README.md +13 -1
  116. package/templates/tanstack-start/docker/init-extensions.sql +11 -0
  117. package/templates/tanstack-start/docker-compose.yml +1 -0
  118. package/templates/tanstack-start/src/lib/auth-client.ts +1 -1
  119. package/templates/tanstack-start/src/lib/client.ts +1 -1
  120. package/templates/tanstack-start/src/lib/query.ts +18 -0
  121. package/templates/tanstack-start/src/questpie/server/collections/index.ts +1 -1
  122. package/templates/tanstack-start/src/questpie/server/globals/index.ts +1 -1
  123. package/templates/tanstack-start/src/questpie/server/questpie.config.ts +1 -1
  124. package/templates/tanstack-start/src/routes/__root.tsx +31 -1
  125. package/templates/tanstack-start/src/routes/api/$.ts +1 -1
  126. package/templates/tanstack-start/src/routes/index.tsx +97 -0
  127. package/skills/questpie/AGENTS.md +0 -2871
  128. package/skills/questpie/SKILL.md +0 -293
  129. package/skills/questpie/coverage.json +0 -213
  130. package/skills/questpie/references/auth.md +0 -236
  131. package/skills/questpie/references/business-logic.md +0 -620
  132. package/skills/questpie/references/codegen-plugin-api.md +0 -382
  133. package/skills/questpie/references/crud-api.md +0 -580
  134. package/skills/questpie/references/data-modeling.md +0 -509
  135. package/skills/questpie/references/extend.md +0 -584
  136. package/skills/questpie/references/field-types.md +0 -398
  137. package/skills/questpie/references/infrastructure-adapters.md +0 -720
  138. package/skills/questpie/references/mcp.md +0 -147
  139. package/skills/questpie/references/multi-tenancy.md +0 -363
  140. package/skills/questpie/references/production.md +0 -640
  141. package/skills/questpie/references/query-operators.md +0 -125
  142. package/skills/questpie/references/quickstart.md +0 -562
  143. package/skills/questpie/references/rules.md +0 -454
  144. package/skills/questpie/references/sandbox.md +0 -110
  145. package/skills/questpie/references/tanstack-query.md +0 -543
  146. package/skills/questpie/references/type-inference.md +0 -167
  147. package/skills/questpie/references/workflows.md +0 -155
  148. package/skills/questpie-admin/AGENTS.md +0 -1515
  149. package/skills/questpie-admin/SKILL.md +0 -443
  150. package/skills/questpie-admin/references/blocks.md +0 -331
  151. package/skills/questpie-admin/references/custom-ui.md +0 -305
  152. package/skills/questpie-admin/references/views.md +0 -449
@@ -0,0 +1,200 @@
1
+ /* oxlint-disable */
2
+ // AUTO-GENERATED by questpie codegen — DO NOT EDIT
3
+ // Regenerate with: questpie generate
4
+
5
+ // ── Runtime ────────────────────────────────────────────────
6
+ import _runtime from "../questpie.config";
7
+
8
+ // ── Modules ────────────────────────────────────────────────
9
+ import _modules from "../modules";
10
+
11
+ // ── Collections ────────────────────────────────────────────
12
+ import { posts as _coll_posts } from "../collections/posts.collection";
13
+
14
+ // ── Globals ────────────────────────────────────────────────
15
+ import { siteSettings as _glob_siteSettings } from "../globals/site-settings.global";
16
+
17
+ // ── Core Singles ───────────────────────────────────────────
18
+ import _authConfig from "../config/auth";
19
+
20
+ // ── Plugin Singles ─────────────────────────────────────────
21
+ import _openapi from "../config/openapi";
22
+
23
+ import type { AppCollections, AppGlobals, AppJobs, _ModuleCollections, _AppDefaultServices, _AppServicesSeam, _AppTopLevelServices, _AppCustomServiceNamespaces, _Registry_Collections, _Registry_Globals, _Registry_Jobs, _Registry_Routes, _Registry_Services, _Registry_Emails, _Registry_FieldTypes, _AllModuleFields } from "./entities.gen";
24
+ import type { AnyCollectionOrBuilder, AnyGlobalOrBuilder, CollectionAPI, DrizzleClientFromQuestpieConfig, InferContextExtensionsFromAppConfig, InferSessionFromAuthConfig, MailerService, Questpie, QuestpieConfig, QueueClient, QueueJobType, ServiceInstancesInNamespace, TablesFromConfig, z } from "questpie/types";
25
+
26
+ type _MPConfigSub<A extends readonly any[], K extends string> = A extends readonly [infer H, ...infer T extends readonly any[]] ? (H extends { config: infer C } ? (C extends Record<K, infer V> ? V : {}) : {}) & _MPConfigSub<T, K> : {};
27
+ type _AppAppConfig = {};
28
+ type _AppContextExtensions = Partial<InferContextExtensionsFromAppConfig<_AppAppConfig>>;
29
+ type _AppAuthConfig = _MPConfigSub<typeof _modules, "auth"> & typeof _authConfig;
30
+ type _AppSessionAuthConfig = _AppAuthConfig;
31
+ type _AppSession = NonNullable<InferSessionFromAuthConfig<_AppSessionAuthConfig>> | null;
32
+
33
+ type _CollectionsAPI = { [K in keyof AppCollections]: CollectionAPI<AppCollections[K], AppCollections> };
34
+ type _JobHandlerCollections = _ModuleCollections & {
35
+ posts: typeof _coll_posts;
36
+ };
37
+ type _JobHandlerCollectionsAPI = {
38
+ posts: CollectionAPI<typeof _coll_posts, _JobHandlerCollections>;
39
+ };
40
+ type _ExecutionContextJob<T> = T extends { name: infer TName extends string; schema: z.ZodSchema<infer TPayload> } ? QueueJobType<TPayload, TName> : never;
41
+ type _ExecutionContextJobs = {};
42
+ type _ExecutionContextServiceDefinitions = {};
43
+ type _ExecutionContextDefaultServices = ServiceInstancesInNamespace<_ExecutionContextServiceDefinitions, "services">;
44
+ type _AppCollectionDefinitions = AppCollections & Record<string, AnyCollectionOrBuilder>;
45
+ type _AppGlobalDefinitions = AppGlobals & Record<string, AnyGlobalOrBuilder>;
46
+ type _AppQuestpieConfig = Omit<QuestpieConfig, "app" | "db" | "collections" | "globals" | "auth" | "~contextExtensions"> & {
47
+ app: (typeof _runtime)["app"];
48
+ db: (typeof _runtime)["db"];
49
+ collections: _AppCollectionDefinitions;
50
+ globals: _AppGlobalDefinitions;
51
+ auth: _AppAuthConfig;
52
+ storage: (typeof _runtime)["storage"];
53
+ "~contextExtensions": _AppContextExtensions;
54
+ };
55
+ type _AppQuestpieBase = Questpie<_AppQuestpieConfig>;
56
+ type _AppDb = DrizzleClientFromQuestpieConfig<_AppQuestpieConfig>;
57
+ type _AppGlobalsAPI = _AppQuestpieBase["globals"];
58
+ type _AppStorage = _AppQuestpieBase["storage"];
59
+ type _AppTables = TablesFromConfig<_AppQuestpieConfig>;
60
+ export type _AppQuestpie = Omit<_AppQuestpieBase, "collections" | "globals"> & {
61
+ collections: _CollectionsAPI;
62
+ globals: _AppGlobalsAPI;
63
+ };
64
+
65
+ // ── AppContext augmentation — auto-types ALL handlers ──────
66
+ type _AppInfraRecord = {
67
+ // Infrastructure
68
+ app: _AppQuestpie;
69
+ db: _AppDb;
70
+ email: _AppQuestpie["email"];
71
+ queue: QueueClient<AppJobs>;
72
+ storage: _AppStorage;
73
+ kv: _AppQuestpie["kv"];
74
+ logger: _AppQuestpie["logger"];
75
+ search: _AppQuestpie["search"];
76
+ realtime: _AppQuestpie["realtime"];
77
+
78
+ // Entity APIs
79
+ collections: _CollectionsAPI;
80
+ globals: _AppGlobalsAPI;
81
+ tables: _AppTables;
82
+
83
+ // Request-scoped
84
+ session: _AppSession;
85
+ t: (key: string, params?: Record<string, unknown>, locale?: string) => string;
86
+
87
+ // User services
88
+ services: _AppDefaultServices;
89
+ };
90
+ type _AppInfraContext = _AppInfraRecord & _AppCustomServiceNamespaces;
91
+ type _AppCoreContext = _AppContextExtensions & _AppInfraContext;
92
+ type _ServiceCreateInfra = Omit<_AppInfraRecord, "services"> & { services: Questpie.Services };
93
+
94
+ declare global {
95
+ namespace Questpie {
96
+ interface AppContext extends _AppCoreContext, _AppTopLevelServices {}
97
+
98
+ interface JobHandlerContext {
99
+ // Infrastructure
100
+ db: _AppDb;
101
+ email: _AppQuestpie["email"];
102
+ queue: QueueClient<_ExecutionContextJobs>;
103
+ storage: _AppStorage;
104
+ kv: _AppQuestpie["kv"];
105
+ logger: _AppQuestpie["logger"];
106
+ search: _AppQuestpie["search"];
107
+ realtime: _AppQuestpie["realtime"];
108
+
109
+ // Entity APIs
110
+ collections: _JobHandlerCollectionsAPI;
111
+ globals: _AppGlobalsAPI;
112
+ tables: _AppTables;
113
+
114
+ // Request-scoped
115
+ session: _AppSession;
116
+ t: (key: string, params?: Record<string, unknown>, locale?: string) => string;
117
+
118
+ // Top-level services (namespace: null)
119
+ workflows?: _AppTopLevelServices extends { workflows: infer W } ? W : never;
120
+
121
+ // User services
122
+ services: _ExecutionContextDefaultServices;
123
+ }
124
+
125
+ interface WorkflowContext {
126
+ // Infrastructure
127
+ db: _AppDb;
128
+ email: _AppQuestpie["email"];
129
+ queue: QueueClient<_ExecutionContextJobs>;
130
+ storage: _AppStorage;
131
+ kv: _AppQuestpie["kv"];
132
+ logger: _AppQuestpie["logger"];
133
+ search: _AppQuestpie["search"];
134
+ realtime: _AppQuestpie["realtime"];
135
+
136
+ // Entity APIs
137
+ collections: _JobHandlerCollectionsAPI;
138
+ globals: _AppGlobalsAPI;
139
+ tables: _AppTables;
140
+
141
+ // Request-scoped
142
+ session: _AppSession;
143
+ t: (key: string, params?: Record<string, unknown>, locale?: string) => string;
144
+
145
+ // Top-level services (namespace: null)
146
+ workflows?: _AppTopLevelServices extends { workflows: infer W } ? W : never;
147
+
148
+ // User services
149
+ services: _ExecutionContextDefaultServices;
150
+ }
151
+
152
+ interface Services extends _AppServicesSeam {}
153
+ interface ServiceCreateContext extends _AppContextExtensions, _ServiceCreateInfra {}
154
+ // Names-only marker — the `ServiceCreateContext` fallback conditional
155
+ // probes THIS interface's keys instead of the real one (whose base
156
+ // resolves through module service definitions and would cycle).
157
+ interface ServiceCreateContextGenerated { generated: unknown }
158
+
159
+ // Typed service surface for appConfig({ context }) resolvers.
160
+ // Excludes _AppContextExtensions — the resolver produces them.
161
+ interface ContextResolverContext {
162
+ collections: _CollectionsAPI;
163
+ globals: _AppGlobalsAPI;
164
+ logger: _AppQuestpie["logger"];
165
+ kv: _AppQuestpie["kv"];
166
+ queue: QueueClient<AppJobs>;
167
+ t: (key: string, params?: Record<string, unknown>, locale?: string) => string;
168
+ services: _AppDefaultServices;
169
+ }
170
+
171
+ // App-level hook / default-access ctx infra seams (CL-05).
172
+ // Filled with the real infra MINUS _AppContextExtensions, so the
173
+ // app-level hooks/access predicates get precise db/session/
174
+ // collections/globals/queue WITHOUT re-entering the extensions cycle.
175
+ interface AppHookContext extends _AppInfraContext {}
176
+ interface AppDefaultAccessContext extends _AppInfraContext {}
177
+
178
+ // appConfig({ context }) resolver session/db — off the cyclic edge.
179
+ interface ContextResolverBase {
180
+ session: _AppSession;
181
+ db: _AppDb;
182
+ }
183
+
184
+ interface Registry {
185
+ collections: _Registry_Collections;
186
+ globals: _Registry_Globals;
187
+ jobs: _Registry_Jobs;
188
+ routes: _Registry_Routes;
189
+ services: _Registry_Services;
190
+ emails: _Registry_Emails;
191
+ "~fieldTypes": _Registry_FieldTypes & _AllModuleFields;
192
+ }
193
+ }
194
+ }
195
+
196
+ /** Resolved auth session for this app (`{ user, session } | null`). */
197
+ export type AppSession = _AppSession;
198
+
199
+ /** Authenticated user shape from the app session. */
200
+ export type AppSessionUser = NonNullable<_AppSession>["user"];
@@ -0,0 +1,84 @@
1
+ /* oxlint-disable */
2
+ // AUTO-GENERATED by questpie codegen — DO NOT EDIT
3
+ // Regenerate with: questpie generate
4
+
5
+ import "./names.gen";
6
+ // ── Runtime ────────────────────────────────────────────────
7
+ import _runtime from "../questpie.config";
8
+
9
+ // ── Modules ────────────────────────────────────────────────
10
+ import _modules from "../modules";
11
+
12
+ // ── Collections ────────────────────────────────────────────
13
+ import { posts as _coll_posts } from "../collections/posts.collection";
14
+
15
+ // ── Globals ────────────────────────────────────────────────
16
+ import { siteSettings as _glob_siteSettings } from "../globals/site-settings.global";
17
+
18
+ // ── Core Singles ───────────────────────────────────────────
19
+ import _authConfig from "../config/auth";
20
+
21
+ // ── Plugin Singles ─────────────────────────────────────────
22
+ import _openapi from "../config/openapi";
23
+
24
+ import type { RouteParamsFromKey, RouteWithParams } from "questpie/types";
25
+
26
+ // ════════════════════════════════════════════════════════════
27
+ // TYPES — composed from typeof references (zero inference cost)
28
+ // ════════════════════════════════════════════════════════════
29
+
30
+ import type { ExtractModulePropArr, ExtractModulePropArrOverride, ServiceCustomNamespaceInstances, ServiceInstanceOf, ServiceInstancesInNamespace, ServiceTopLevelInstances } from "questpie/types";
31
+ type _RouteDefinitionWithoutHandler<T> = T extends { mode: "raw" } ? Omit<T, "handler"> & { handler: (args: unknown) => Response | Promise<Response> } : Omit<T, "handler"> & { handler: (args: unknown) => unknown | Promise<unknown> };
32
+ export type _ModuleCollections = ExtractModulePropArrOverride<typeof _modules, "collections">;
33
+ export type _ModuleGlobals = ExtractModulePropArr<typeof _modules, "globals">;
34
+ export type _ModuleJobs = ExtractModulePropArr<typeof _modules, "jobs">;
35
+ export type _ModuleRoutes = ExtractModulePropArr<typeof _modules, "routes">;
36
+ export type _ModuleServices = {};
37
+ export type _ModuleFieldTypes = ExtractModulePropArr<typeof _modules, "fieldTypes">;
38
+ // Registry category extraction from modules
39
+ export type _Registry_Collections = ExtractModulePropArrOverride<typeof _modules, "collections">;
40
+ export type _Registry_Globals = ExtractModulePropArr<typeof _modules, "globals">;
41
+ export type _Registry_Jobs = ExtractModulePropArr<typeof _modules, "jobs">;
42
+ export type _Registry_Routes = ExtractModulePropArr<typeof _modules, "routes">;
43
+ export type _Registry_Services = {};
44
+ export type _Registry_Emails = ExtractModulePropArr<typeof _modules, "emails">;
45
+ export type _Registry_FieldTypes = ExtractModulePropArr<typeof _modules, "fieldTypes">;
46
+
47
+ // Recursive module property extraction (for fields contributed at each level)
48
+ import type { ExtractModuleProp } from "questpie/types";
49
+
50
+ export type _AllModuleFields = ExtractModuleProp<{ modules: typeof _modules }, "fields">;
51
+
52
+ /** All collections in the app (modules + user, user overrides) */
53
+ export type AppCollections = _ModuleCollections & {
54
+ posts: typeof _coll_posts;
55
+ };
56
+
57
+ /** All globals in the app (modules + user, user overrides) */
58
+ export type AppGlobals = _ModuleGlobals & {
59
+ siteSettings: typeof _glob_siteSettings;
60
+ };
61
+
62
+ /** All jobs in the app (modules + user, user overrides) */
63
+ export type AppJobs = _ModuleJobs;
64
+
65
+ /** All routes in the app (modules + user, user overrides) */
66
+ export type AppRoutes = _ModuleRoutes;
67
+
68
+ /** All service definitions in the app (modules + user, user overrides). */
69
+ type _AppServiceDefinitions = _ModuleServices;
70
+
71
+ /** All services in the app as resolved service instances. */
72
+ export type AppServices = {
73
+ [K in keyof _AppServiceDefinitions]: ServiceInstanceOf<_AppServiceDefinitions[K]>;
74
+ };
75
+ export type _AppDefaultServices = ServiceInstancesInNamespace<_AppServiceDefinitions, "services">;
76
+ export type _AppServicesSeam = { [K in keyof _AppServiceDefinitions]: ServiceInstanceOf<_AppServiceDefinitions[K]> };
77
+ export type _AppTopLevelServices = ServiceTopLevelInstances<_AppServiceDefinitions>;
78
+ export type _AppCustomServiceNamespaces = ServiceCustomNamespaceInstances<_AppServiceDefinitions>;
79
+
80
+ /** All email templates in the app — use with email.sendTemplate() */
81
+ export type AppEmailTemplates = Record<string, never>;
82
+
83
+ /** All fieldtypes in the app (modules + user, user overrides) */
84
+ export type AppFieldTypes = _ModuleFieldTypes;
@@ -0,0 +1,65 @@
1
+ /* oxlint-disable */
2
+ // AUTO-GENERATED by questpie codegen — DO NOT EDIT
3
+ // Typed factory functions with plugin extensions. Regenerate with: questpie generate
4
+
5
+ // ── Core Imports ───────────────────────────────────────────
6
+ import { CollectionBuilder, GlobalBuilder, builtinFields, type EmptyCollectionState, type EmptyGlobalState, type BuiltinFields } from "questpie/builders";
7
+
8
+ // Merged field factories — builtins + module-contributed (e.g. richText, blocks) + user fields
9
+ const _rawFieldDefs = { ...builtinFields } as const;
10
+
11
+ const _allFieldDefs = _rawFieldDefs;
12
+
13
+ // ── Entity key registry (names only — acyclic by construction) ─────
14
+ declare global {
15
+ namespace Questpie {
16
+ interface CollectionKeys { posts: unknown }
17
+ interface GlobalKeys { siteSettings: unknown }
18
+ }
19
+ }
20
+
21
+ // ── Plugin Imports ─────────────────────────────────────────
22
+ import { type AppConfigInput, type AuthConfig } from "questpie/types";
23
+ import { type OpenApiModuleConfig } from "@questpie/openapi";
24
+
25
+ // Field types — populated by module codegen via Questpie.FieldTypesMap
26
+ type _AllFieldTypes = Questpie.FieldTypesMap;
27
+
28
+ // ════════════════════════════════════════════════════════════
29
+ // Factory functions
30
+ // ════════════════════════════════════════════════════════════
31
+
32
+ /**
33
+ * Create a typed collection builder with plugin extensions.
34
+ *
35
+ * @example
36
+ * ```ts
37
+ * import { collection } from "#questpie/factories";
38
+ *
39
+ * export default collection("posts")
40
+ * .fields(({ f }) => ({ title: f.text(255).required() }))
41
+ * ```
42
+ */
43
+ export function collection<TName extends string>(name: TName): CollectionBuilder<EmptyCollectionState<TName, undefined, _AllFieldTypes>> {
44
+ return CollectionBuilder.create<TName, _AllFieldTypes>(name, _allFieldDefs);
45
+ }
46
+
47
+ /**
48
+ * Create a typed global builder with plugin extensions.
49
+ */
50
+ export function global<TName extends string>(name: TName): GlobalBuilder<EmptyGlobalState<TName, undefined, _AllFieldTypes>> {
51
+ return GlobalBuilder.create<TName, _AllFieldTypes>(name, _allFieldDefs);
52
+ }
53
+
54
+ // ════════════════════════════════════════════════════════════
55
+ // Singleton factory functions
56
+ // ════════════════════════════════════════════════════════════
57
+
58
+ /** Typed factory for appConfig config. */
59
+ export function appConfig<T extends AppConfigInput>(config: T): T { return config; }
60
+
61
+ /** Typed factory for authConfig config. */
62
+ export function authConfig<T extends AuthConfig>(config: T): T { return config; }
63
+
64
+ /** Typed factory for openapi config. */
65
+ export function openapi<T extends OpenApiModuleConfig>(config: T): T { return config; }
@@ -0,0 +1,131 @@
1
+ /* oxlint-disable */
2
+ // AUTO-GENERATED by questpie codegen — DO NOT EDIT
3
+ // Regenerate with: questpie generate
4
+
5
+ import { createApp, createContextFactory } from "questpie/app";
6
+ import "./names.gen";
7
+ import type { AccessContext, AppDefinition, CollectionSelect, GlobalSelect, HookContext } from "questpie/types";
8
+ import type { AppCollections, AppGlobals, AppRoutes } from "./entities.gen";
9
+ import type { _AppQuestpie, AppSession, AppSessionUser } from "./context.gen";
10
+
11
+ // ── Runtime ────────────────────────────────────────────────
12
+ import _runtime from "../questpie.config";
13
+
14
+ // ── Modules ────────────────────────────────────────────────
15
+ import _modules from "../modules";
16
+
17
+ // ── Collections ────────────────────────────────────────────
18
+ import { posts as _coll_posts } from "../collections/posts.collection";
19
+
20
+ // ── Globals ────────────────────────────────────────────────
21
+ import { siteSettings as _glob_siteSettings } from "../globals/site-settings.global";
22
+
23
+ // ── Core Singles ───────────────────────────────────────────
24
+ import _authConfig from "../config/auth";
25
+
26
+ // ── Plugin Singles ─────────────────────────────────────────
27
+ import _openapi from "../config/openapi";
28
+
29
+ export type * from "./entities.gen";
30
+ export type * from "./context.gen";
31
+
32
+ /**
33
+ * Select/document type for a collection key — prefer over `Record<string, any>` for docs.
34
+ */
35
+ export type CollectionDoc<K extends keyof AppCollections> = CollectionSelect<AppCollections[K]>;
36
+
37
+ /**
38
+ * Select/document type for a global key.
39
+ */
40
+ export type GlobalDoc<K extends keyof AppGlobals> = GlobalSelect<AppGlobals[K]>;
41
+
42
+ /**
43
+ * Access-rule ctx for shared helpers. `K` narrows `data` to that collection's row.
44
+ *
45
+ * CYCLE RULE: import these only from files NOT imported by a collection
46
+ * (routes, services, jobs, scripts). Helpers imported by collections take
47
+ * the package-level `AccessContext` from "questpie" instead — see the
48
+ * type-inference reference.
49
+ *
50
+ * @example
51
+ * ```ts
52
+ * export async function isOwner(ctx: AccessRuleContext<"posts">) {
53
+ * return ctx.data?.authorId === ctx.session?.user.id; // ctx.collections typed
54
+ * }
55
+ * ```
56
+ */
57
+ export type AccessRuleContext<K extends keyof AppCollections | unknown = unknown> =
58
+ AccessContext<K extends keyof AppCollections ? CollectionDoc<K> : unknown>;
59
+
60
+ /**
61
+ * Hook ctx for shared helpers. `K` narrows `data` to that collection's row.
62
+ * Same cycle rule as `AccessRuleContext`.
63
+ */
64
+ export type HookRuleContext<K extends keyof AppCollections | unknown = unknown> =
65
+ HookContext<K extends keyof AppCollections ? CollectionDoc<K> : unknown>;
66
+
67
+ /**
68
+ * Flat config type for client APIs.
69
+ * Use with `createClient<AppConfig>()` and `createAdminAuthClient<AppConfig>()`.
70
+ * For handler context, use `AppContext` (auto-typed via module augmentation).
71
+ */
72
+ export type AppConfig = {
73
+ collections: AppCollections;
74
+ globals: AppGlobals;
75
+ routes: AppRoutes;
76
+ storage: (typeof _runtime)["storage"];
77
+ auth: typeof _authConfig;
78
+ };
79
+
80
+ // ════════════════════════════════════════════════════════════
81
+ // RUNTIME — create the app instance
82
+ // ════════════════════════════════════════════════════════════
83
+
84
+ var _appPromise: Promise<unknown> | undefined;
85
+
86
+ _appPromise = createApp(
87
+ ({
88
+ modules: _modules,
89
+ collections: {
90
+ posts: _coll_posts,
91
+ },
92
+ globals: {
93
+ siteSettings: _glob_siteSettings,
94
+ },
95
+ config: {
96
+ auth: _authConfig,
97
+ openapi: _openapi,
98
+ },
99
+ }) satisfies AppDefinition,
100
+ _runtime,
101
+ );
102
+
103
+ export const app = (await _appPromise) as unknown as _AppQuestpie;
104
+
105
+ /** Fully typed QUESTPIE app instance. */
106
+ export type App = typeof app;
107
+
108
+ // ── createContext — typed context for scripts ──────────────
109
+ /**
110
+ * Create a typed AppContext for use in scripts, tests, or standalone code.
111
+ * Resolves all services and provides flat access to infrastructure.
112
+ *
113
+ * @example
114
+ * ```ts
115
+ * import { createContext } from "#questpie";
116
+ *
117
+ * const ctx = await createContext();
118
+ * const posts = await ctx.collections.posts.find({});
119
+ * ```
120
+ */
121
+ export async function createContext(
122
+ options?: Parameters<ReturnType<typeof createContextFactory>>[0],
123
+ ) {
124
+ while (!_appPromise) {
125
+ await new Promise((resolve) => setTimeout(resolve, 0));
126
+ }
127
+
128
+ return createContextFactory((await _appPromise) as _AppQuestpie)(options);
129
+ }
130
+
131
+ // Factories: import { collection, global, ... } from '#questpie/factories';
@@ -0,0 +1,25 @@
1
+ /* oxlint-disable */
2
+ // AUTO-GENERATED by questpie codegen — DO NOT EDIT
3
+ // Regenerate with: questpie generate
4
+
5
+ // ── Modules ────────────────────────────────────────────────
6
+ import _modules from "../modules";
7
+
8
+ // ── Module entity-name key sets (distributive `keyof`) ─────
9
+ type _ModuleCollectionsKeyNames = (typeof _modules)[number] extends infer M ? M extends { collections: infer C } ? keyof C & string : never : never;
10
+ type _ModuleGlobalsKeyNames = (typeof _modules)[number] extends infer M ? M extends { globals: infer C } ? keyof C & string : never : never;
11
+ type _ModuleJobsKeyNames = (typeof _modules)[number] extends infer M ? M extends { jobs: infer C } ? keyof C & string : never : never;
12
+ type _ModuleRoutesKeyNames = (typeof _modules)[number] extends infer M ? M extends { routes: infer C } ? keyof C & string : never : never;
13
+ type _ModuleServicesKeyNames = (typeof _modules)[number] extends infer M ? M extends { services: infer C } ? keyof C & string : never : never;
14
+ type _ModuleFieldTypesKeyNames = (typeof _modules)[number] extends infer M ? M extends { fieldTypes: infer C } ? keyof C & string : never : never;
15
+
16
+ declare global {
17
+ namespace Questpie {
18
+ interface CollectionKeys extends Record<_ModuleCollectionsKeyNames, unknown> {}
19
+ interface GlobalKeys extends Record<_ModuleGlobalsKeyNames, unknown> {}
20
+ interface JobKeys extends Record<_ModuleJobsKeyNames, unknown> {}
21
+ interface RouteKeys extends Record<_ModuleRoutesKeyNames, unknown> {}
22
+ interface ServiceKeys extends Record<_ModuleServicesKeyNames, unknown> {}
23
+ interface FieldTypeKeys extends Record<_ModuleFieldTypesKeyNames, unknown> {}
24
+ }
25
+ }
@@ -0,0 +1,10 @@
1
+ /**
2
+ * App Instance
3
+ *
4
+ * Re-exports the app from the generated entrypoint.
5
+ * Run `questpie generate` to regenerate .generated/index.ts.
6
+ *
7
+ * If .generated/ does not exist yet, run: bun questpie generate
8
+ */
9
+
10
+ export { type App, type AppConfig, app } from "./.generated/index";
@@ -0,0 +1 @@
1
+ export { posts } from "./posts.collection";
@@ -0,0 +1,10 @@
1
+ import { collection } from "#questpie/factories";
2
+
3
+ export const posts = collection("posts")
4
+ .fields(({ f }) => ({
5
+ title: f.text(255).label("Title").required(),
6
+ slug: f.text(255).label("Slug").required(),
7
+ content: f.textarea().label("Content"),
8
+ published: f.boolean().label("Published").default(false).required(),
9
+ }))
10
+ .title(({ f }) => f.title);
@@ -0,0 +1,8 @@
1
+ import { authConfig } from "questpie/app";
2
+
3
+ export default authConfig({
4
+ emailAndPassword: {
5
+ enabled: true,
6
+ requireEmailVerification: false,
7
+ },
8
+ });
@@ -0,0 +1,10 @@
1
+ import { openApiConfig } from "@questpie/openapi";
2
+
3
+ export default openApiConfig({
4
+ info: {
5
+ title: "{{projectName}} API",
6
+ version: "1.0.0",
7
+ description: "QUESTPIE API",
8
+ },
9
+ scalar: { theme: "purple" },
10
+ });
@@ -0,0 +1 @@
1
+ export { siteSettings } from "./site-settings.global";
@@ -0,0 +1,10 @@
1
+ import { global } from "#questpie/factories";
2
+
3
+ export const siteSettings = global("siteSettings")
4
+ .fields(({ f }) => ({
5
+ siteName: f.text().label("Site Name").required().default("{{projectName}}"),
6
+ description: f
7
+ .textarea()
8
+ .label("Site Description")
9
+ .default("A QUESTPIE powered site"),
10
+ }));
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Modules — static module dependencies for this project.
3
+ */
4
+ import { openApiModule } from "@questpie/openapi";
5
+
6
+ const modules = [openApiModule] as const;
7
+
8
+ export default modules;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * QUESTPIE Runtime Configuration
3
+ *
4
+ * Runtime-only configuration: database, adapters, secrets.
5
+ * Entity definitions (collections, globals, etc.) are codegen-generated.
6
+ * Admin sidebar, dashboard, and branding live in config/admin.ts.
7
+ */
8
+
9
+ import { runtimeConfig } from "questpie/app";
10
+ import { ConsoleAdapter } from "questpie/adapters/console";
11
+
12
+ import { env } from "@/lib/env";
13
+
14
+ export default runtimeConfig({
15
+ app: { url: env.APP_URL },
16
+ db: { url: env.DATABASE_URL },
17
+ storage: { basePath: "/api" },
18
+ email: {
19
+ adapter: new ConsoleAdapter({ logHtml: false }),
20
+ },
21
+ });
@@ -0,0 +1,28 @@
1
+ {
2
+ "include": ["src/**/*.ts", "*.config.ts"],
3
+ "exclude": ["node_modules", "dist", "**/*.test.ts"],
4
+ "compilerOptions": {
5
+ "target": "ES2022",
6
+ "module": "ESNext",
7
+ "lib": ["ES2022", "DOM", "DOM.Iterable"],
8
+ "types": ["bun-types"],
9
+ "moduleResolution": "bundler",
10
+ "resolveJsonModule": true,
11
+ "allowImportingTsExtensions": true,
12
+ "verbatimModuleSyntax": false,
13
+ "noEmit": true,
14
+ "skipLibCheck": true,
15
+ "strict": true,
16
+ "noUnusedLocals": false,
17
+ "noUnusedParameters": false,
18
+ "noFallthroughCasesInSwitch": true,
19
+ "noUncheckedSideEffectImports": true,
20
+ "baseUrl": ".",
21
+ "paths": {
22
+ "@/*": ["./src/*"],
23
+ "~/*": ["./src/*"],
24
+ "#questpie": ["./src/questpie/server/.generated/index.ts"],
25
+ "#questpie/*": ["./src/questpie/server/.generated/*"]
26
+ }
27
+ }
28
+ }