@pattern-stack/codegen 0.12.0 → 0.12.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.
- package/CHANGELOG.md +66 -3
- package/dist/src/cli/index.js +101 -59
- package/dist/src/cli/index.js.map +1 -1
- package/dist/src/index.d.ts +25 -15
- package/dist/src/index.js +43 -35
- package/dist/src/index.js.map +1 -1
- package/package.json +1 -1
- package/templates/entity/new/clean-lite-ps/prompt-extension.js +2 -2
package/dist/src/index.d.ts
CHANGED
|
@@ -282,6 +282,8 @@ declare const EntityDefinitionSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<{
|
|
|
282
282
|
patterns: z.ZodOptional<z.ZodArray<z.ZodString, "many">>;
|
|
283
283
|
config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
284
284
|
scopeable: z.ZodOptional<z.ZodBoolean>;
|
|
285
|
+
surface: z.ZodOptional<z.ZodString>;
|
|
286
|
+
context: z.ZodOptional<z.ZodString>;
|
|
285
287
|
}, "strict", z.ZodTypeAny, {
|
|
286
288
|
name: string;
|
|
287
289
|
table: string;
|
|
@@ -294,6 +296,8 @@ declare const EntityDefinitionSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<{
|
|
|
294
296
|
pattern?: string | undefined;
|
|
295
297
|
patterns?: string[] | undefined;
|
|
296
298
|
scopeable?: boolean | undefined;
|
|
299
|
+
surface?: string | undefined;
|
|
300
|
+
context?: string | undefined;
|
|
297
301
|
}, {
|
|
298
302
|
name: string;
|
|
299
303
|
table: string;
|
|
@@ -306,6 +310,8 @@ declare const EntityDefinitionSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<{
|
|
|
306
310
|
pattern?: string | undefined;
|
|
307
311
|
patterns?: string[] | undefined;
|
|
308
312
|
scopeable?: boolean | undefined;
|
|
313
|
+
surface?: string | undefined;
|
|
314
|
+
context?: string | undefined;
|
|
309
315
|
}>, {
|
|
310
316
|
name: string;
|
|
311
317
|
table: string;
|
|
@@ -318,6 +324,8 @@ declare const EntityDefinitionSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<{
|
|
|
318
324
|
pattern?: string | undefined;
|
|
319
325
|
patterns?: string[] | undefined;
|
|
320
326
|
scopeable?: boolean | undefined;
|
|
327
|
+
surface?: string | undefined;
|
|
328
|
+
context?: string | undefined;
|
|
321
329
|
}, {
|
|
322
330
|
name: string;
|
|
323
331
|
table: string;
|
|
@@ -330,6 +338,8 @@ declare const EntityDefinitionSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<{
|
|
|
330
338
|
pattern?: string | undefined;
|
|
331
339
|
patterns?: string[] | undefined;
|
|
332
340
|
scopeable?: boolean | undefined;
|
|
341
|
+
surface?: string | undefined;
|
|
342
|
+
context?: string | undefined;
|
|
333
343
|
}>;
|
|
334
344
|
fields: z.ZodRecord<z.ZodString, z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodObject<{
|
|
335
345
|
type: z.ZodEnum<["string", "integer", "decimal", "boolean", "uuid", "date", "datetime", "json", "entity_ref", "string_array", "enum"]>;
|
|
@@ -1692,8 +1702,6 @@ declare const EntityDefinitionSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<{
|
|
|
1692
1702
|
value?: unknown;
|
|
1693
1703
|
}[] | undefined;
|
|
1694
1704
|
}>]>>>;
|
|
1695
|
-
surface: z.ZodOptional<z.ZodString>;
|
|
1696
|
-
context: z.ZodOptional<z.ZodString>;
|
|
1697
1705
|
events: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
1698
1706
|
name: z.ZodString;
|
|
1699
1707
|
queue: z.ZodString;
|
|
@@ -2024,6 +2032,8 @@ declare const EntityDefinitionSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<{
|
|
|
2024
2032
|
pattern?: string | undefined;
|
|
2025
2033
|
patterns?: string[] | undefined;
|
|
2026
2034
|
scopeable?: boolean | undefined;
|
|
2035
|
+
surface?: string | undefined;
|
|
2036
|
+
context?: string | undefined;
|
|
2027
2037
|
};
|
|
2028
2038
|
behaviors: (string | {
|
|
2029
2039
|
name: string;
|
|
@@ -2112,8 +2122,6 @@ declare const EntityDefinitionSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<{
|
|
|
2112
2122
|
value?: unknown;
|
|
2113
2123
|
}[];
|
|
2114
2124
|
}> | undefined;
|
|
2115
|
-
surface?: string | undefined;
|
|
2116
|
-
context?: string | undefined;
|
|
2117
2125
|
events?: {
|
|
2118
2126
|
name: string;
|
|
2119
2127
|
queue: string;
|
|
@@ -2228,6 +2236,8 @@ declare const EntityDefinitionSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<{
|
|
|
2228
2236
|
pattern?: string | undefined;
|
|
2229
2237
|
patterns?: string[] | undefined;
|
|
2230
2238
|
scopeable?: boolean | undefined;
|
|
2239
|
+
surface?: string | undefined;
|
|
2240
|
+
context?: string | undefined;
|
|
2231
2241
|
};
|
|
2232
2242
|
relationships?: Record<string, {
|
|
2233
2243
|
type: "belongs_to" | "has_many" | "has_one";
|
|
@@ -2316,8 +2326,6 @@ declare const EntityDefinitionSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<{
|
|
|
2316
2326
|
value?: unknown;
|
|
2317
2327
|
}[] | undefined;
|
|
2318
2328
|
}> | undefined;
|
|
2319
|
-
surface?: string | undefined;
|
|
2320
|
-
context?: string | undefined;
|
|
2321
2329
|
events?: {
|
|
2322
2330
|
name: string;
|
|
2323
2331
|
queue: string;
|
|
@@ -2432,6 +2440,8 @@ declare const EntityDefinitionSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<{
|
|
|
2432
2440
|
pattern?: string | undefined;
|
|
2433
2441
|
patterns?: string[] | undefined;
|
|
2434
2442
|
scopeable?: boolean | undefined;
|
|
2443
|
+
surface?: string | undefined;
|
|
2444
|
+
context?: string | undefined;
|
|
2435
2445
|
};
|
|
2436
2446
|
behaviors: (string | {
|
|
2437
2447
|
name: string;
|
|
@@ -2520,8 +2530,6 @@ declare const EntityDefinitionSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<{
|
|
|
2520
2530
|
value?: unknown;
|
|
2521
2531
|
}[];
|
|
2522
2532
|
}> | undefined;
|
|
2523
|
-
surface?: string | undefined;
|
|
2524
|
-
context?: string | undefined;
|
|
2525
2533
|
events?: {
|
|
2526
2534
|
name: string;
|
|
2527
2535
|
queue: string;
|
|
@@ -2636,6 +2644,8 @@ declare const EntityDefinitionSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<{
|
|
|
2636
2644
|
pattern?: string | undefined;
|
|
2637
2645
|
patterns?: string[] | undefined;
|
|
2638
2646
|
scopeable?: boolean | undefined;
|
|
2647
|
+
surface?: string | undefined;
|
|
2648
|
+
context?: string | undefined;
|
|
2639
2649
|
};
|
|
2640
2650
|
relationships?: Record<string, {
|
|
2641
2651
|
type: "belongs_to" | "has_many" | "has_one";
|
|
@@ -2724,8 +2734,6 @@ declare const EntityDefinitionSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<{
|
|
|
2724
2734
|
value?: unknown;
|
|
2725
2735
|
}[] | undefined;
|
|
2726
2736
|
}> | undefined;
|
|
2727
|
-
surface?: string | undefined;
|
|
2728
|
-
context?: string | undefined;
|
|
2729
2737
|
events?: {
|
|
2730
2738
|
name: string;
|
|
2731
2739
|
queue: string;
|
|
@@ -2840,6 +2848,8 @@ declare const EntityDefinitionSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<{
|
|
|
2840
2848
|
pattern?: string | undefined;
|
|
2841
2849
|
patterns?: string[] | undefined;
|
|
2842
2850
|
scopeable?: boolean | undefined;
|
|
2851
|
+
surface?: string | undefined;
|
|
2852
|
+
context?: string | undefined;
|
|
2843
2853
|
};
|
|
2844
2854
|
behaviors: (string | {
|
|
2845
2855
|
name: string;
|
|
@@ -2928,8 +2938,6 @@ declare const EntityDefinitionSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<{
|
|
|
2928
2938
|
value?: unknown;
|
|
2929
2939
|
}[];
|
|
2930
2940
|
}> | undefined;
|
|
2931
|
-
surface?: string | undefined;
|
|
2932
|
-
context?: string | undefined;
|
|
2933
2941
|
events?: {
|
|
2934
2942
|
name: string;
|
|
2935
2943
|
queue: string;
|
|
@@ -3044,6 +3052,8 @@ declare const EntityDefinitionSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<{
|
|
|
3044
3052
|
pattern?: string | undefined;
|
|
3045
3053
|
patterns?: string[] | undefined;
|
|
3046
3054
|
scopeable?: boolean | undefined;
|
|
3055
|
+
surface?: string | undefined;
|
|
3056
|
+
context?: string | undefined;
|
|
3047
3057
|
};
|
|
3048
3058
|
relationships?: Record<string, {
|
|
3049
3059
|
type: "belongs_to" | "has_many" | "has_one";
|
|
@@ -3132,8 +3142,6 @@ declare const EntityDefinitionSchema: z.ZodEffects<z.ZodEffects<z.ZodObject<{
|
|
|
3132
3142
|
value?: unknown;
|
|
3133
3143
|
}[] | undefined;
|
|
3134
3144
|
}> | undefined;
|
|
3135
|
-
surface?: string | undefined;
|
|
3136
|
-
context?: string | undefined;
|
|
3137
3145
|
events?: {
|
|
3138
3146
|
name: string;
|
|
3139
3147
|
queue: string;
|
|
@@ -3712,7 +3720,9 @@ interface LoadEntitiesResult {
|
|
|
3712
3720
|
/**
|
|
3713
3721
|
* Load all entity YAML files from a directory
|
|
3714
3722
|
*/
|
|
3715
|
-
declare function loadEntities(entitiesDir: string
|
|
3723
|
+
declare function loadEntities(entitiesDir: string, opts?: {
|
|
3724
|
+
excludeDirs?: string[];
|
|
3725
|
+
}): LoadEntitiesResult;
|
|
3716
3726
|
interface LoadRelationshipsResult {
|
|
3717
3727
|
relationships: ParsedRelationshipDefinition[];
|
|
3718
3728
|
issues: AnalysisIssue[];
|
package/dist/src/index.js
CHANGED
|
@@ -19,14 +19,17 @@ import { join, resolve } from "path";
|
|
|
19
19
|
function isYaml(name) {
|
|
20
20
|
return name.endsWith(".yaml") || name.endsWith(".yml");
|
|
21
21
|
}
|
|
22
|
-
function findYamlFiles(dir) {
|
|
22
|
+
function findYamlFiles(dir, opts) {
|
|
23
23
|
const root = resolve(dir);
|
|
24
24
|
const out = [];
|
|
25
|
+
const excluded = new Set((opts?.excludeDirs ?? []).map((d) => resolve(d)));
|
|
25
26
|
const walk = (current) => {
|
|
26
27
|
for (const entry of readdirSync(current, { withFileTypes: true })) {
|
|
27
28
|
if (entry.isDirectory()) {
|
|
28
29
|
if (entry.name.startsWith(".")) continue;
|
|
29
|
-
|
|
30
|
+
const child = join(current, entry.name);
|
|
31
|
+
if (excluded.has(resolve(child))) continue;
|
|
32
|
+
walk(child);
|
|
30
33
|
} else if (isYaml(entry.name)) {
|
|
31
34
|
out.push(join(current, entry.name));
|
|
32
35
|
}
|
|
@@ -1274,7 +1277,37 @@ var EntityConfigSchema = z3.object({
|
|
|
1274
1277
|
// JOB-7: marks this entity as a valid scope target for job scoping.
|
|
1275
1278
|
// Drives the generated ScopeEntityType union in
|
|
1276
1279
|
// runtime/subsystems/jobs/generated/scope-entity-type.ts.
|
|
1277
|
-
scopeable: z3.boolean().optional()
|
|
1280
|
+
scopeable: z3.boolean().optional(),
|
|
1281
|
+
// RFC-0001 §1/§8: the integration *surface* this entity belongs to
|
|
1282
|
+
// (e.g. 'calendar', 'mail', 'crm'). Surfaces span provider contexts
|
|
1283
|
+
// (ADR-0006) — one Google OAuth feeds calendar+mail+transcript. The union
|
|
1284
|
+
// of `surface:` values across all entity YAML is the closed set that a
|
|
1285
|
+
// provider's `surfaces:` must be a subset of (cross-checked in
|
|
1286
|
+
// src/parser/validate-providers.ts). Optional: entities without an
|
|
1287
|
+
// integration surface omit it. The surface-package *emission* convention
|
|
1288
|
+
// is Track C (#329); this field is only the declarative input both tracks
|
|
1289
|
+
// read. Lives inside the `entity:` block (next to `pattern:`/`name:`/`table:`).
|
|
1290
|
+
surface: z3.string().optional(),
|
|
1291
|
+
// Bounded-context declaration (ADR-0004) — "which bounded context this
|
|
1292
|
+
// entity belongs to". This is the DURABLE decision; it is a plain
|
|
1293
|
+
// bounded-context slug, NOT a folder knob. Different features consume it:
|
|
1294
|
+
//
|
|
1295
|
+
// - #403 (the FIRST consumer): drives the generated code's
|
|
1296
|
+
// module output folder. clean-lite-ps nests the entity's module under
|
|
1297
|
+
// `<modules>/<context>/<entity>/` so same-context entities group
|
|
1298
|
+
// together; untagged entities stay flat (`<modules>/<entity>/`).
|
|
1299
|
+
// - ADR-0004 (deferred): a later `naming: prefix | schema` knob reads
|
|
1300
|
+
// this SAME field to drive the Postgres physical layout —
|
|
1301
|
+
// `prefix` → `pgTable('<context>__<table>')`, then the flip to
|
|
1302
|
+
// `schema` → `pgSchema('<context>').table('<table>')`. NOT wired here.
|
|
1303
|
+
//
|
|
1304
|
+
// Sibling to `surface:` and orthogonal to it (ADR-0006): context = model
|
|
1305
|
+
// cohesion (which domain), surface = vendor composition (which integration).
|
|
1306
|
+
// Lives inside the `entity:` block (next to `pattern:`/`name:`/`table:`).
|
|
1307
|
+
context: z3.string().regex(
|
|
1308
|
+
/^[a-z][a-z0-9_]*$/,
|
|
1309
|
+
"context must be lowercase snake_case (e.g. 'integration')"
|
|
1310
|
+
).optional()
|
|
1278
1311
|
}).strict().refine((d) => !(d.pattern && d.patterns), {
|
|
1279
1312
|
message: "'pattern' and 'patterns' are mutually exclusive"
|
|
1280
1313
|
});
|
|
@@ -1427,36 +1460,11 @@ var EntityDefinitionSchema = z3.object({
|
|
|
1427
1460
|
// appear in `integration.providers` — see the superRefine on
|
|
1428
1461
|
// `EntityDefinitionSchema` below.
|
|
1429
1462
|
detection: z3.record(z3.string(), DetectionConfigSchema).optional(),
|
|
1430
|
-
//
|
|
1431
|
-
//
|
|
1432
|
-
//
|
|
1433
|
-
//
|
|
1434
|
-
//
|
|
1435
|
-
// src/parser/validate-providers.ts). Optional: entities without an
|
|
1436
|
-
// integration surface omit it. The surface-package *emission* convention
|
|
1437
|
-
// is Track C (#329); this field is only the declarative input both tracks
|
|
1438
|
-
// read.
|
|
1439
|
-
surface: z3.string().optional(),
|
|
1440
|
-
// Bounded-context declaration (ADR-0004) — "which bounded context this
|
|
1441
|
-
// entity belongs to". This is the DURABLE decision; it is a plain
|
|
1442
|
-
// bounded-context slug, NOT a folder knob. Different features consume it:
|
|
1443
|
-
//
|
|
1444
|
-
// - #403 (this PR, the FIRST consumer): drives the generated code's
|
|
1445
|
-
// module output folder. clean-lite-ps nests the entity's module under
|
|
1446
|
-
// `<modules>/<context>/<entity>/` so same-context entities group
|
|
1447
|
-
// together; untagged entities stay flat (`<modules>/<entity>/`).
|
|
1448
|
-
// - ADR-0004 (deferred): a later `naming: prefix | schema` knob reads
|
|
1449
|
-
// this SAME field to drive the Postgres physical layout —
|
|
1450
|
-
// `prefix` → `pgTable('<context>__<table>')`, then the flip to
|
|
1451
|
-
// `schema` → `pgSchema('<context>').table('<table>')`. NOT wired here;
|
|
1452
|
-
// #403 makes no table/column/schema changes.
|
|
1453
|
-
//
|
|
1454
|
-
// Sibling to `surface:` and orthogonal to it (ADR-0006): context = model
|
|
1455
|
-
// cohesion (which domain), surface = vendor composition (which integration).
|
|
1456
|
-
context: z3.string().regex(
|
|
1457
|
-
/^[a-z][a-z0-9_]*$/,
|
|
1458
|
-
"context must be lowercase snake_case (e.g. 'integration')"
|
|
1459
|
-
).optional(),
|
|
1463
|
+
// NOTE: `surface:` and `context:` moved INTO EntityConfigSchema (the
|
|
1464
|
+
// `entity:` block) in 0.12.2 — consumers write them next to
|
|
1465
|
+
// `pattern:`/`name:`/`table:`, which is the natural place. They are
|
|
1466
|
+
// read via `entity.surface` / `entity.context`. Clean break: no
|
|
1467
|
+
// root-level placement is accepted.
|
|
1460
1468
|
// v2: Domain event declarations (CODEGEN-EVOLUTION-PLAN Phase 2)
|
|
1461
1469
|
// Generates typed event classes, handlers, and queue registration
|
|
1462
1470
|
events: z3.array(EventDeclarationSchema).optional(),
|
|
@@ -2246,13 +2254,13 @@ function loadErrorToIssue(error) {
|
|
|
2246
2254
|
}
|
|
2247
2255
|
return issues;
|
|
2248
2256
|
}
|
|
2249
|
-
function loadEntities(entitiesDir) {
|
|
2257
|
+
function loadEntities(entitiesDir, opts) {
|
|
2250
2258
|
const entities = [];
|
|
2251
2259
|
const issues = [];
|
|
2252
2260
|
const resolvedDir = resolve2(entitiesDir);
|
|
2253
2261
|
let files;
|
|
2254
2262
|
try {
|
|
2255
|
-
files = findYamlFiles(resolvedDir);
|
|
2263
|
+
files = findYamlFiles(resolvedDir, { excludeDirs: opts?.excludeDirs });
|
|
2256
2264
|
} catch (err) {
|
|
2257
2265
|
issues.push({
|
|
2258
2266
|
severity: "error",
|