create-questpie 2.0.0 → 2.0.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 (45) hide show
  1. package/README.md +10 -6
  2. package/dist/index.mjs +140 -25
  3. package/package.json +5 -3
  4. package/skills/questpie/AGENTS.md +2664 -0
  5. package/skills/questpie/SKILL.md +181 -0
  6. package/skills/questpie/references/auth.md +121 -0
  7. package/skills/questpie/references/business-logic.md +550 -0
  8. package/skills/questpie/references/codegen-plugin-api.md +382 -0
  9. package/skills/questpie/references/crud-api.md +378 -0
  10. package/skills/questpie/references/data-modeling.md +489 -0
  11. package/skills/questpie/references/extend.md +493 -0
  12. package/skills/questpie/references/field-types.md +386 -0
  13. package/skills/questpie/references/infrastructure-adapters.md +545 -0
  14. package/skills/questpie/references/multi-tenancy.md +364 -0
  15. package/skills/questpie/references/production.md +475 -0
  16. package/skills/questpie/references/query-operators.md +125 -0
  17. package/skills/questpie/references/quickstart.md +549 -0
  18. package/skills/questpie/references/rules.md +327 -0
  19. package/skills/questpie/references/tanstack-query.md +520 -0
  20. package/skills/questpie-admin/AGENTS.md +1442 -0
  21. package/skills/questpie-admin/SKILL.md +410 -0
  22. package/skills/questpie-admin/references/blocks.md +307 -0
  23. package/skills/questpie-admin/references/custom-ui.md +305 -0
  24. package/skills/questpie-admin/references/views.md +433 -0
  25. package/templates/tanstack-start/AGENTS.md +71 -62
  26. package/templates/tanstack-start/CLAUDE.md +26 -23
  27. package/templates/tanstack-start/README.md +32 -20
  28. package/templates/tanstack-start/env.example +1 -1
  29. package/templates/tanstack-start/package.json +20 -6
  30. package/templates/tanstack-start/src/lib/client.ts +2 -2
  31. package/templates/tanstack-start/src/lib/env.ts +1 -1
  32. package/templates/tanstack-start/src/questpie/admin/.generated/client.ts +13 -0
  33. package/templates/tanstack-start/src/questpie/admin/modules.ts +1 -0
  34. package/templates/tanstack-start/src/questpie/server/.generated/factories.ts +117 -241
  35. package/templates/tanstack-start/src/questpie/server/.generated/index.ts +129 -81
  36. package/templates/tanstack-start/src/questpie/server/app.ts +1 -1
  37. package/templates/tanstack-start/src/questpie/server/config/admin.ts +27 -30
  38. package/templates/tanstack-start/src/questpie/server/globals/site-settings.global.ts +1 -1
  39. package/templates/tanstack-start/src/questpie/server/questpie.config.ts +1 -1
  40. package/templates/tanstack-start/src/routeTree.gen.ts +138 -0
  41. package/templates/tanstack-start/src/routes/__root.tsx +0 -2
  42. package/templates/tanstack-start/src/routes/admin.tsx +8 -1
  43. package/templates/tanstack-start/src/tanstack-start.d.ts +1 -0
  44. package/templates/tanstack-start/src/vite-env.d.ts +1 -0
  45. package/templates/tanstack-start/vite.config.ts +1 -3
@@ -3,63 +3,51 @@
3
3
  // Typed factory functions with plugin extensions. Regenerate with: questpie generate
4
4
 
5
5
  // ── Core Imports ───────────────────────────────────────────
6
- import {
7
- type CollectionAccess,
8
- CollectionBuilder,
9
- type ContextResolver,
10
- createFieldNameProxy,
11
- type EmptyCollectionState,
12
- type EmptyGlobalState,
13
- GlobalBuilder,
14
- type GlobalHooksInput,
15
- type LocaleConfig,
16
- wrapBuilderWithExtensions,
17
- } from "questpie";
18
- import type { RegistryProp } from "questpie";
6
+ import { CollectionBuilder, GlobalBuilder, wrapBuilderWithExtensions, builtinFields, type EmptyCollectionState, type EmptyGlobalState, type BuiltinFields, Field } from "questpie";
7
+
8
+ // ── Runtime Field Imports ──────────────────────────────────
9
+ import { adminFields } from "@questpie/admin/server";
10
+
11
+ const _fieldExt: Record<string, { stateKey: string; resolve: (v: any) => any }> = {
12
+ admin: { stateKey: "admin", resolve: (v: any) => v },
13
+ form: {
14
+ stateKey: "form",
15
+ resolve(configOrFn: any) {
16
+ if (typeof configOrFn === 'function') return configOrFn({ f: createFieldNameProxy() });
17
+ return configOrFn;
18
+ },
19
+ },
20
+ };
21
+
22
+ // Merged field factories — builtins + module-contributed (e.g. richText, blocks) + user fields
23
+ const _rawFieldDefs = { ...builtinFields, ...adminFields } as const;
24
+
25
+ // Wrap field factories so returned Field instances have extension methods
26
+ function _wrapFieldFactory(fn: (...args: any[]) => any): (...args: any[]) => any {
27
+ return (...args: any[]) => wrapBuilderWithExtensions(fn(...args), _fieldExt, Field);
28
+ }
29
+
30
+ const _allFieldDefs = Object.fromEntries(
31
+ Object.entries(_rawFieldDefs).map(([k, v]) => [k, _wrapFieldFactory(v as any)])
32
+ ) as unknown as typeof _rawFieldDefs;
19
33
 
20
34
  // ── Plugin Imports ─────────────────────────────────────────
21
- import {
22
- type ActionsConfigContext,
23
- type AdminCollectionConfig,
24
- type AdminConfigContext,
25
- type AdminGlobalConfig,
26
- type AdminLocaleConfig,
27
- createActionCallbackProxy,
28
- createComponentCallbackProxy,
29
- createViewCallbackProxy,
30
- type DashboardContribution,
31
- type FilterViewsByKind,
32
- type FormViewConfig,
33
- type FormViewConfigContext,
34
- type ListViewConfig,
35
- type ListViewConfigContext,
36
- type PreviewConfig,
37
- type ServerActionsConfig,
38
- type ServerBrandingConfig,
39
- type SidebarContribution,
40
- } from "@questpie/admin/server";
35
+ import { type AdminCollectionConfig, type AdminConfigContext, type ListViewConfig, type ListViewConfigContext, type FilterViewsByKind, type FormViewConfig, type FormViewConfigContext, type PreviewConfig, type ServerActionsConfig, type ActionsConfigContext, type AdminGlobalConfig, type AdminConfigInput, createViewCallbackProxy, createComponentCallbackProxy, createActionCallbackProxy } from "@questpie/admin/server";
36
+ import { type AppConfigInput, type AuthConfig, createFieldNameProxy } from "questpie";
37
+ import { type OpenApiModuleConfig } from "@questpie/openapi";
38
+
41
39
  // ════════════════════════════════════════════════════════════
42
- // Type extraction from Registry — driven by CategoryDeclaration
40
+ // Type extraction — driven by CategoryDeclaration
43
41
  // ════════════════════════════════════════════════════════════
44
42
 
45
- // ── Module import (for type extraction) ──
46
- import type _modulesArr from "../modules";
47
-
48
- type _ViewsNames = (keyof RegistryProp<"views"> & string) | (string & {});
49
- type _ViewsRecord = RegistryProp<"views">;
50
- type _ComponentsNames =
51
- | (keyof RegistryProp<"components"> & string)
52
- | (string & {});
53
- type _ComponentsNames_Strict = keyof RegistryProp<"components"> & string;
54
- type _ComponentsRecord = RegistryProp<"components">;
43
+ type _ViewsNames = (keyof Questpie.ViewsRegistry & string) | (string & {});
44
+ type _ViewsRecord = Questpie.ViewsRegistry;
45
+ type _ComponentsNames = (keyof Questpie.ComponentsRegistry & string) | (string & {});
46
+ type _ComponentsNames_Strict = keyof Questpie.ComponentsRegistry & string;
47
+ type _ComponentsRecord = Questpie.ComponentsRegistry;
55
48
 
56
- // Field types — extracted from modules
57
- import type { ExtractModuleProp } from "questpie";
58
-
59
- type _AllFieldTypes = ExtractModuleProp<
60
- { modules: typeof _modulesArr },
61
- "fields"
62
- >;
49
+ // Field types — populated by module codegen via Questpie.FieldTypesMap
50
+ type _AllFieldTypes = Questpie.FieldTypesMap;
63
51
 
64
52
  // ════════════════════════════════════════════════════════════
65
53
  // Type augmentations — generated from plugin registries
@@ -67,67 +55,25 @@ type _AllFieldTypes = ExtractModuleProp<
67
55
 
68
56
  declare module "questpie" {
69
57
  interface CollectionBuilder<TState> {
70
- admin(
71
- configFn:
72
- | AdminCollectionConfig
73
- | ((
74
- ctx: AdminConfigContext<_ComponentsRecord>,
75
- ) => AdminCollectionConfig),
76
- ): CollectionBuilder<TState>;
77
- list(
78
- configFn: (
79
- ctx: ListViewConfigContext<
80
- TState extends {
81
- fieldDefinitions: infer F extends Record<string, any>;
82
- }
83
- ? F
84
- : Record<string, any>,
85
- FilterViewsByKind<_ViewsRecord, "list">
86
- >,
87
- ) => ListViewConfig,
88
- ): CollectionBuilder<TState>;
89
- form(
90
- configFn: (
91
- ctx: FormViewConfigContext<
92
- TState extends {
93
- fieldDefinitions: infer F extends Record<string, any>;
94
- }
95
- ? F
96
- : Record<string, any>,
97
- FilterViewsByKind<_ViewsRecord, "form">
98
- >,
99
- ) => FormViewConfig,
100
- ): CollectionBuilder<TState>;
58
+ admin(configFn: AdminCollectionConfig | ((ctx: AdminConfigContext<_ComponentsRecord>) => AdminCollectionConfig)): CollectionBuilder<TState>;
59
+ list(configFn: (ctx: ListViewConfigContext<TState extends { fieldDefinitions: infer F extends Record<string, any> } ? F : Record<string, any>, FilterViewsByKind<_ViewsRecord, "list">>) => ListViewConfig): CollectionBuilder<TState>;
60
+ form(configFn: (ctx: FormViewConfigContext<TState extends { fieldDefinitions: infer F extends Record<string, any> } ? F : Record<string, any>, FilterViewsByKind<_ViewsRecord, "form">>) => FormViewConfig): CollectionBuilder<TState>;
101
61
  preview(config: PreviewConfig): CollectionBuilder<TState>;
102
- actions(
103
- configFn: (
104
- ctx: ActionsConfigContext<Record<string, unknown>, _ComponentsRecord>,
105
- ) => ServerActionsConfig,
106
- ): CollectionBuilder<TState>;
62
+ actions(configFn: (ctx: ActionsConfigContext<Record<string, unknown>, _ComponentsRecord>) => ServerActionsConfig): CollectionBuilder<TState>;
107
63
  }
108
64
  interface GlobalBuilder<TState> {
109
- admin(
110
- configFn:
111
- | AdminGlobalConfig
112
- | ((ctx: AdminConfigContext<_ComponentsRecord>) => AdminGlobalConfig),
113
- ): GlobalBuilder<TState>;
114
- form(
115
- configFn: (
116
- ctx: FormViewConfigContext<
117
- TState extends {
118
- fieldDefinitions: infer F extends Record<string, any>;
119
- }
120
- ? F
121
- : Record<string, any>,
122
- FilterViewsByKind<_ViewsRecord, "form">
123
- >,
124
- ) => FormViewConfig,
125
- ): GlobalBuilder<TState>;
65
+ admin(configFn: AdminGlobalConfig | ((ctx: AdminConfigContext<_ComponentsRecord>) => AdminGlobalConfig)): GlobalBuilder<TState>;
66
+ form(configFn: (ctx: FormViewConfigContext<TState extends { fieldDefinitions: infer F extends Record<string, any> } ? F : Record<string, any>, FilterViewsByKind<_ViewsRecord, "form">>) => FormViewConfig): GlobalBuilder<TState>;
67
+ }
68
+ interface Field<TState> {
69
+ admin(config: unknown): Field<TState>;
70
+ form(configFn: (ctx: { f: Record<string, string> }) => { fields: import('@questpie/admin/server').FieldLayoutItem[] }): Field<TState>;
126
71
  }
127
72
  }
128
73
 
129
74
  declare global {
130
75
  namespace Questpie {
76
+ interface FieldTypesMap extends BuiltinFields {}
131
77
  interface FieldTypeRegistry extends Record<keyof _AllFieldTypes, {}> {}
132
78
  }
133
79
  }
@@ -140,90 +86,54 @@ declare module "@questpie/admin/server" {
140
86
  // Extension registries
141
87
  // ════════════════════════════════════════════════════════════
142
88
 
143
- const _collExt: Record<string, { stateKey: string; resolve: (v: any) => any }> =
144
- {
145
- admin: {
146
- stateKey: "admin",
147
- resolve(configOrFn: any) {
148
- if (typeof configOrFn === "function")
149
- return configOrFn({ c: createComponentCallbackProxy() });
150
- return configOrFn;
151
- },
89
+ const _collExt: Record<string, { stateKey: string; resolve: (v: any) => any }> = {
90
+ admin: {
91
+ stateKey: "admin",
92
+ resolve(configOrFn: any) {
93
+ if (typeof configOrFn === 'function') return configOrFn({ c: createComponentCallbackProxy() });
94
+ return configOrFn;
152
95
  },
153
- list: {
154
- stateKey: "adminList",
155
- resolve(configOrFn: any) {
156
- const resolved =
157
- typeof configOrFn === "function"
158
- ? configOrFn({
159
- v: createViewCallbackProxy(),
160
- f: createFieldNameProxy(),
161
- a: createActionCallbackProxy(),
162
- })
163
- : configOrFn;
164
- return {
165
- ...{
166
- view: "collection-table",
167
- showSearch: true,
168
- showFilters: true,
169
- showToolbar: true,
170
- },
171
- ...resolved,
172
- };
173
- },
96
+ },
97
+ list: {
98
+ stateKey: "adminList",
99
+ resolve(configOrFn: any) {
100
+ const resolved = typeof configOrFn === 'function' ? configOrFn({ v: createViewCallbackProxy(), f: createFieldNameProxy(), a: createActionCallbackProxy() }) : configOrFn;
101
+ return { ...{"view":"collection-table","showSearch":true,"showFilters":true,"showToolbar":true}, ...resolved };
174
102
  },
175
- form: {
176
- stateKey: "adminForm",
177
- resolve(configOrFn: any) {
178
- const resolved =
179
- typeof configOrFn === "function"
180
- ? configOrFn({
181
- v: createViewCallbackProxy(),
182
- f: createFieldNameProxy(),
183
- })
184
- : configOrFn;
185
- return { ...{ view: "collection-form", showMeta: true }, ...resolved };
186
- },
103
+ },
104
+ form: {
105
+ stateKey: "adminForm",
106
+ resolve(configOrFn: any) {
107
+ const resolved = typeof configOrFn === 'function' ? configOrFn({ v: createViewCallbackProxy(), f: createFieldNameProxy() }) : configOrFn;
108
+ return { ...{"view":"collection-form","showMeta":true}, ...resolved };
187
109
  },
188
- preview: { stateKey: "adminPreview", resolve: (v: any) => v },
189
- actions: {
190
- stateKey: "adminActions",
191
- resolve(configOrFn: any) {
192
- if (typeof configOrFn === "function")
193
- return configOrFn({
194
- a: createActionCallbackProxy(),
195
- c: createComponentCallbackProxy(),
196
- f: createFieldNameProxy(),
197
- });
198
- return configOrFn;
199
- },
110
+ },
111
+ preview: { stateKey: "adminPreview", resolve: (v: any) => v },
112
+ actions: {
113
+ stateKey: "adminActions",
114
+ resolve(configOrFn: any) {
115
+ if (typeof configOrFn === 'function') return configOrFn({ a: createActionCallbackProxy(), c: createComponentCallbackProxy(), f: createFieldNameProxy() });
116
+ return configOrFn;
200
117
  },
201
- };
202
-
203
- const _globExt: Record<string, { stateKey: string; resolve: (v: any) => any }> =
204
- {
205
- admin: {
206
- stateKey: "admin",
207
- resolve(configOrFn: any) {
208
- if (typeof configOrFn === "function")
209
- return configOrFn({ c: createComponentCallbackProxy() });
210
- return configOrFn;
211
- },
118
+ },
119
+ };
120
+
121
+ const _globExt: Record<string, { stateKey: string; resolve: (v: any) => any }> = {
122
+ admin: {
123
+ stateKey: "admin",
124
+ resolve(configOrFn: any) {
125
+ if (typeof configOrFn === 'function') return configOrFn({ c: createComponentCallbackProxy() });
126
+ return configOrFn;
212
127
  },
213
- form: {
214
- stateKey: "adminForm",
215
- resolve(configOrFn: any) {
216
- const resolved =
217
- typeof configOrFn === "function"
218
- ? configOrFn({
219
- v: createViewCallbackProxy(),
220
- f: createFieldNameProxy(),
221
- })
222
- : configOrFn;
223
- return { ...{ view: "global-form", showMeta: true }, ...resolved };
224
- },
128
+ },
129
+ form: {
130
+ stateKey: "adminForm",
131
+ resolve(configOrFn: any) {
132
+ const resolved = typeof configOrFn === 'function' ? configOrFn({ v: createViewCallbackProxy(), f: createFieldNameProxy() }) : configOrFn;
133
+ return { ...{"view":"global-form","showMeta":true}, ...resolved };
225
134
  },
226
- };
135
+ },
136
+ };
227
137
 
228
138
  // ════════════════════════════════════════════════════════════
229
139
  // Factory functions
@@ -237,82 +147,48 @@ const _globExt: Record<string, { stateKey: string; resolve: (v: any) => any }> =
237
147
  * import { collection } from "#questpie/factories";
238
148
  *
239
149
  * export default collection("posts")
240
- * .fields(({ f }) => ({ title: f.text({ required: true }) }))
150
+ * .fields(({ f }) => ({ title: f.text(255).required() }))
241
151
  * .admin(({ c }) => ({ icon: c.icon("ph:article") }))
242
152
  * .list(({ v, f }) => v.collectionTable({ columns: [f.title] }))
243
153
  * ```
244
154
  */
245
- export function collection<TName extends string>(
246
- name: TName,
247
- ): CollectionBuilder<EmptyCollectionState<TName, undefined, _AllFieldTypes>> {
248
- return wrapBuilderWithExtensions(
249
- CollectionBuilder.create<TName, _AllFieldTypes>(name),
250
- _collExt,
251
- CollectionBuilder,
252
- ) as any;
155
+ export function collection<TName extends string>(name: TName): CollectionBuilder<EmptyCollectionState<TName, undefined, _AllFieldTypes>> {
156
+ return wrapBuilderWithExtensions(CollectionBuilder.create<TName, _AllFieldTypes>(name, _allFieldDefs), _collExt, CollectionBuilder) as any;
253
157
  }
254
158
 
255
159
  /**
256
160
  * Create a typed global builder with plugin extensions.
257
161
  */
258
- export function global<TName extends string>(
259
- name: TName,
260
- ): GlobalBuilder<EmptyGlobalState<TName, undefined, _AllFieldTypes>> {
261
- return wrapBuilderWithExtensions(
262
- GlobalBuilder.create<TName, _AllFieldTypes>(name),
263
- _globExt,
264
- GlobalBuilder,
265
- ) as any;
162
+ export function global<TName extends string>(name: TName): GlobalBuilder<EmptyGlobalState<TName, undefined, _AllFieldTypes>> {
163
+ return wrapBuilderWithExtensions(GlobalBuilder.create<TName, _AllFieldTypes>(name, _allFieldDefs), _globExt, GlobalBuilder) as any;
266
164
  }
267
165
 
268
166
  // ════════════════════════════════════════════════════════════
269
- // Singleton factory functions
167
+ // Builder factory functions (plugin-contributed)
270
168
  // ════════════════════════════════════════════════════════════
271
169
 
272
- /** Typed factory for locale config. */
273
- export function locale<T extends LocaleConfig>(config: T): T {
274
- return config;
275
- }
276
-
277
- /** Typed factory for hooks config. */
278
- export function hooks<T extends GlobalHooksInput>(config: T): T {
279
- return config;
280
- }
281
-
282
- /** Typed factory for access config. */
283
- export function access<T extends CollectionAccess>(config: T): T {
284
- return config;
170
+ import { BlockBuilder } from "@questpie/admin/server";
171
+ /**
172
+ * Create a typed block builder with wrapped field defs.
173
+ */
174
+ export function block<TName extends string>(name: TName): import('@questpie/admin/server').BlockBuilder<{ name: TName }> {
175
+ return BlockBuilder.create(name, _allFieldDefs) as any;
285
176
  }
286
177
 
287
- /** Typed factory for context config. */
288
- export function context<T extends ContextResolver>(config: T): T {
289
- return config;
290
- }
178
+ // ════════════════════════════════════════════════════════════
179
+ // Singleton factory functions
180
+ // ════════════════════════════════════════════════════════════
291
181
 
292
- /** Typed factory for branding config. */
293
- export function branding<T extends ServerBrandingConfig>(config: T): T {
294
- return config;
295
- }
182
+ /** Typed factory for appConfig config. */
183
+ export function appConfig<T extends AppConfigInput>(config: T): T { return config; }
296
184
 
297
- /** Typed factory for adminLocale config. */
298
- export function adminLocale<T extends AdminLocaleConfig>(config: T): T {
299
- return config;
300
- }
185
+ /** Typed factory for authConfig config. */
186
+ export function authConfig<T extends AuthConfig>(config: T): T { return config; }
301
187
 
302
- /** Typed factory for sidebar config. Accepts plain config or callback. */
303
- export function sidebar<T extends SidebarContribution>(config: T): T;
304
- export function sidebar<T extends (...args: any[]) => SidebarContribution>(
305
- cb: T,
306
- ): T;
307
- export function sidebar(v: any): any {
308
- return v;
309
- }
188
+ /** Typed factory for adminConfig config. Accepts plain config or callback. */
189
+ export function adminConfig<T extends AdminConfigInput>(config: T): T;
190
+ export function adminConfig<T extends (...args: any[]) => AdminConfigInput>(cb: T): T;
191
+ export function adminConfig(v: any): any { return v; }
310
192
 
311
- /** Typed factory for dashboard config. Accepts plain config or callback. */
312
- export function dashboard<T extends DashboardContribution>(config: T): T;
313
- export function dashboard<T extends (...args: any[]) => DashboardContribution>(
314
- cb: T,
315
- ): T;
316
- export function dashboard(v: any): any {
317
- return v;
318
- }
193
+ /** Typed factory for openapi config. */
194
+ export function openapi<T extends OpenApiModuleConfig>(config: T): T { return config; }