Repository navigation
Expand file tree
/
Copy pathmetaobjects.config.ts
More file actions
59 lines (57 loc) · 2.59 KB
/
Copy pathmetaobjects.config.ts
File metadata and controls
59 lines (57 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import { defineConfig } from "@metaobjectsdev/cli";
// ADR-0034 scaffold-and-own: this example OWNS its four core generators, as local copies
// under codegen/generators/ — what `meta eject entity queries routes barrel` writes. That
// is the customization path. Importing the same four from
// `@metaobjectsdev/codegen-ts/generators` runs them as shipped and works too (removed at
// 1.0, restored in 1.1 — ADR-0034 Amendment 5).
import { entityFile } from "./codegen/generators/entity";
import { queriesFile } from "./codegen/generators/queries";
import { routesFile } from "./codegen/generators/routes";
import { barrel } from "./codegen/generators/barrel";
// React form codegen (PATTERN 2 — entity views: the generated form dispatches
// per view.* control, incl. <ImageUpload> for view.image).
import { formFile } from "@metaobjectsdev/codegen-ts-react";
// Template/payload codegen (PATTERN 4 — LLM/document payloads).
import {
promptRender,
outputParser,
extractor,
outputPrompt,
renderHelper,
} from "@metaobjectsdev/codegen-ts/generators";
import { TYPE_SOURCE, type MetaObject } from "@metaobjectsdev/metadata";
// `entityFile`/`queriesFile`/`routesFile` derive DB participation from a
// declared/inherited `source.*` child (the #248 persistability contract), so
// the sourceless shapes here need no filter for them: `entityFile` renders a
// sourceless shape as SHAPE-ONLY output (interface + Zod, no Drizzle table —
// see ProgramDescriptionPayload.ts in src/generated/), while `queriesFile`/
// `routesFile` skip it outright. The sourceless shapes: the pure
// `object.value`s (SyllabusSection / InstructorProfile — a value can never
// declare a source, loader-enforced) and the SOURCELESS `object.projection`
// payload (ProgramDescriptionPayload, #210 — assembly origins live on
// projections; a template payloadRef may target a sourceless projection).
// `formFile` is the one generator that does NOT yet make that distinction —
// it assumes every passing entity is form-submittable — so it alone needs the
// config-level `filter` (the option exists for exactly this): only a PERSISTED
// object is form-submitted in this domain.
const isPersisted = (e: MetaObject): boolean =>
e.children().some((c) => c.type === TYPE_SOURCE);
export default defineConfig({
outDir: "src/generated",
extStyle: "none",
dbImport: "../db",
dialect: "postgres",
apiPrefix: "/api",
generators: [
entityFile(),
queriesFile(),
routesFile(),
formFile({ filter: isPersisted }),
promptRender(),
outputParser(),
extractor(),
outputPrompt(),
renderHelper(),
barrel(),
],
});