@marktiderman/genesis-cli 1.26.1 → 1.27.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.
@@ -144,10 +144,10 @@
144
144
  "version": "0.10.24"
145
145
  },
146
146
  "@marktiderman/genesis-cli": {
147
- "version": "1.26.1"
147
+ "version": "1.27.0"
148
148
  },
149
149
  "@marktiderman/genesis-media": {
150
- "version": "0.2.0"
150
+ "version": "0.3.0"
151
151
  },
152
152
  "@marktiderman/genesis-native": {
153
153
  "version": "0.11.0",
@@ -423,7 +423,7 @@
423
423
  }
424
424
  },
425
425
  "@marktiderman/genesis-sites": {
426
- "version": "0.7.0",
426
+ "version": "0.7.2",
427
427
  "blocks": {
428
428
  "sites": {
429
429
  "feature": {
@@ -470,10 +470,10 @@
470
470
  "version": "0.4.2"
471
471
  },
472
472
  "@marktiderman/genesis-studio-server": {
473
- "version": "0.5.4"
473
+ "version": "0.6.0"
474
474
  },
475
475
  "@marktiderman/genesis-supabase": {
476
- "version": "0.15.0",
476
+ "version": "0.15.1",
477
477
  "blocks": {
478
478
  "account": {
479
479
  "feature": {
@@ -712,7 +712,7 @@
712
712
  }
713
713
  },
714
714
  "@marktiderman/genesis-support": {
715
- "version": "0.7.0",
715
+ "version": "0.8.1",
716
716
  "blocks": {
717
717
  "support-feedback": {
718
718
  "feature": {
package/dist/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  export { FileSystem, ScaffoldLogger, ScaffoldOptions, ScaffoldResult, planScaffold, runScaffold, validateConsumerName } from './scaffolder.js';
2
- import postgres from 'postgres';
3
2
  export { RunDoctorOptions, defineDoctorPlugin, formatReport, runDoctor } from './doctor.js';
4
3
  export { D as DoctorConfig, f as DoctorConfigError, g as DoctorContext, h as DoctorPlugin, i as DoctorResult, F as Finding, c as GenesisConfigError, j as GenesisConfigFile, b as GenesisLinks, k as GenesisSupabase, r as readGenesisConfig, v as validateLinks } from './config-ARs2YQ60.js';
5
4
  import '@marktiderman/genesis-features';
@@ -65,8 +64,15 @@ interface TableSettings {
65
64
  key?: string[];
66
65
  }
67
66
 
68
- type Sql = postgres.Sql;
69
- declare function introspectPostgres(sql: Sql, schemas: readonly string[], options?: {
67
+ /**
68
+ * A postgres.js pool, as far as introspection uses one: `postgres(url)` from
69
+ * postgres.js 3.4 or 4. Typed by the one method it calls, so either version's
70
+ * pool fits without a cast.
71
+ */
72
+ interface IntrospectSql {
73
+ unsafe(query: string, parameters?: readonly unknown[]): PromiseLike<readonly Record<string, unknown>[]>;
74
+ }
75
+ declare function introspectPostgres(sql: IntrospectSql, schemas: readonly string[], options?: {
70
76
  warn?: (message: string) => void;
71
77
  }): Promise<IntrospectedTable[]>;
72
78
 
@@ -279,4 +285,4 @@ declare function checkFigmaRoutes(options: CheckOptions): Promise<CoverageReport
279
285
  /** The report as text: a summary line, then one table per kind of finding. */
280
286
  declare function formatCoverage(r: CoverageReport): string;
281
287
 
282
- export { type AppRoute, CommentSettingsError, type CoverageReport, EmitError, type EmitOptions, type FieldSettings, type FigmaConfig, FigmaConfigError, type FigmaFacts, type InitOptions, type InitPlan, type IntrospectedColumn, type IntrospectedTable, type NavTarget, type OpenApiDocument, type PlannedFile, type ProjectFacts, type StorageType, type StudioHost, type TableSettings, appNavTargets, appRoutes, checkFigmaRoutes, compare as compareFigmaRoutes, detectHost, emitContracts, formatCoverage, introspectOpenApi, introspectPostgres, parseColumnComment, parseTableComment, planStudioInit, readFigma, readFigmaConfig, validateFigmaConfig };
288
+ export { type AppRoute, CommentSettingsError, type CoverageReport, EmitError, type EmitOptions, type FieldSettings, type FigmaConfig, FigmaConfigError, type FigmaFacts, type InitOptions, type InitPlan, type IntrospectSql, type IntrospectedColumn, type IntrospectedTable, type NavTarget, type OpenApiDocument, type PlannedFile, type ProjectFacts, type StorageType, type StudioHost, type TableSettings, appNavTargets, appRoutes, checkFigmaRoutes, compare as compareFigmaRoutes, detectHost, emitContracts, formatCoverage, introspectOpenApi, introspectPostgres, parseColumnComment, parseTableComment, planStudioInit, readFigma, readFigmaConfig, validateFigmaConfig };
package/dist/index.js CHANGED
@@ -285,8 +285,11 @@ var init_model = __esm({
285
285
  });
286
286
 
287
287
  // src/introspect/postgres.ts
288
- function where(sql, scope) {
289
- return "schemas" in scope ? sql`n.nspname = any(${scope.schemas})` : sql`c.oid = any(${scope.oids}::oid[])`;
288
+ function where(scope) {
289
+ return "schemas" in scope ? { condition: "n.nspname = any(array(select jsonb_array_elements_text($1::text::jsonb)))", param: JSON.stringify(scope.schemas) } : { condition: "c.oid = any(array(select jsonb_array_elements_text($1::text::jsonb)::oid))", param: JSON.stringify(scope.oids) };
290
+ }
291
+ async function read(sql, text, param) {
292
+ return [...await sql.unsafe(text, [param])];
290
293
  }
291
294
  function linkOf(columns, refColumns, refUnique = []) {
292
295
  if (columns.length === 1) return 0;
@@ -295,7 +298,8 @@ function linkOf(columns, refColumns, refUnique = []) {
295
298
  return own.length === 1 && refUnique[own[0]] === true ? own[0] : -1;
296
299
  }
297
300
  async function readRelations(sql, scope, into) {
298
- const columns = await sql`
301
+ const { condition, param } = where(scope);
302
+ const columns = await read(sql, `
299
303
  select c.oid::text as oid, c.relkind::text as relkind, n.nspname as schema, c.relname as table,
300
304
  obj_description(c.oid, 'pg_class') as table_comment,
301
305
  a.attnum::int as attnum,
@@ -314,17 +318,17 @@ async function readRelations(sql, scope, into) {
314
318
  join pg_attribute a on a.attrelid = c.oid and a.attnum > 0 and not a.attisdropped
315
319
  join pg_type t on t.oid = a.atttypid
316
320
  where c.relkind in ('r', 'p', 'v', 'm', 'f')
317
- and ${where(sql, scope)}
318
- order by n.nspname, c.relname, a.attnum`;
319
- const keys = await sql`
321
+ and ${condition}
322
+ order by n.nspname, c.relname, a.attnum`, param);
323
+ const keys = await read(sql, `
320
324
  select c.oid::text as oid, array_agg(k.attnum::int order by k.ord) as columns
321
325
  from pg_constraint con
322
326
  join pg_class c on c.oid = con.conrelid
323
327
  join pg_namespace n on n.oid = c.relnamespace
324
328
  cross join lateral unnest(con.conkey) with ordinality as k(attnum, ord)
325
- where con.contype = 'p' and ${where(sql, scope)}
326
- group by c.oid`;
327
- const links = await sql`
329
+ where con.contype = 'p' and ${condition}
330
+ group by c.oid`, param);
331
+ const links = await read(sql, `
328
332
  select c.oid::text as oid, con.conkey::int[] as attnums,
329
333
  array(select a.attname::text from unnest(con.conkey) with ordinality k(attnum, ord)
330
334
  join pg_attribute a on a.attrelid = c.oid and a.attnum = k.attnum order by k.ord) as columns,
@@ -341,9 +345,9 @@ async function readRelations(sql, scope, into) {
341
345
  join pg_class rc on rc.oid = con.confrelid
342
346
  join pg_namespace rn on rn.oid = rc.relnamespace
343
347
  where con.contype = 'f'
344
- and ${where(sql, scope)}
345
- order by con.conname`;
346
- const checks = await sql`
348
+ and ${condition}
349
+ order by con.conname`, param);
350
+ const checks = await read(sql, `
347
351
  select c.oid::text as oid, con.conkey[1]::int as attnum, a.attname as column,
348
352
  pg_get_constraintdef(con.oid) as definition
349
353
  from pg_constraint con
@@ -351,9 +355,9 @@ async function readRelations(sql, scope, into) {
351
355
  join pg_namespace n on n.oid = c.relnamespace
352
356
  join pg_attribute a on a.attrelid = c.oid and a.attnum = con.conkey[1]
353
357
  where con.contype = 'c' and array_length(con.conkey, 1) = 1
354
- and ${where(sql, scope)}
355
- order by con.conname`;
356
- const views = await sql`
358
+ and ${condition}
359
+ order by con.conname`, param);
360
+ const views = await read(sql, `
357
361
  select c.oid::text as oid, r.ev_action::text as ev_action
358
362
  from pg_class c
359
363
  join pg_namespace n on n.oid = c.relnamespace
@@ -361,7 +365,7 @@ async function readRelations(sql, scope, into) {
361
365
  where c.relkind = 'v'
362
366
  and (pg_relation_is_updatable(c.oid, false) & 20) = 20
363
367
  and not exists (select 1 from pg_rewrite o where o.ev_class = c.oid and o.rulename <> '_RETURN')
364
- and ${where(sql, scope)}`;
368
+ and ${condition}`, param);
365
369
  const added = [];
366
370
  for (const row of columns) {
367
371
  let relation = into.get(row.oid);
@@ -4506,7 +4510,7 @@ function createTrail(ctx) {
4506
4510
  declared = null;
4507
4511
  }
4508
4512
  const byPath = new Map(ctx.files.map((f) => [f.absolutePath, f]));
4509
- const read2 = (abs) => byPath.get(abs) ?? readSource(abs);
4513
+ const read3 = (abs) => byPath.get(abs) ?? readSource(abs);
4510
4514
  const importsCache = /* @__PURE__ */ new Map();
4511
4515
  const importsOf = (file) => {
4512
4516
  const hit = importsCache.get(file.absolutePath);
@@ -4583,7 +4587,7 @@ function createTrail(ctx) {
4583
4587
  cut.add(abs);
4584
4588
  continue;
4585
4589
  }
4586
- const target = read2(abs);
4590
+ const target = read3(abs);
4587
4591
  if (!target) {
4588
4592
  unknown = true;
4589
4593
  continue;
@@ -7244,7 +7248,7 @@ function sourceSchemas(source) {
7244
7248
  return schemas?.length ? schemas : null;
7245
7249
  }
7246
7250
  var lf = (text) => text.replace(/\r\n/g, "\n");
7247
- async function checkContracts(ctx, read2 = postgresContract) {
7251
+ async function checkContracts(ctx, read3 = postgresContract) {
7248
7252
  const settings = ctx.config.contracts;
7249
7253
  if (!settings) return;
7250
7254
  const out = settings.out ?? DEFAULT_CONTRACT_OUT;
@@ -7268,7 +7272,7 @@ async function checkContracts(ctx, read2 = postgresContract) {
7268
7272
  }
7269
7273
  let expected;
7270
7274
  try {
7271
- expected = lf((await read2(url, schemas)).content);
7275
+ expected = lf((await read3(url, schemas)).content);
7272
7276
  } catch (err) {
7273
7277
  const generation = err.name === "EmitError";
7274
7278
  const message = err.message.split("\n")[0];
@@ -7286,7 +7290,7 @@ async function checkContracts(ctx, read2 = postgresContract) {
7286
7290
  }
7287
7291
  }
7288
7292
  var GENESIS_DOCS = "https://github.com/marktiderman/genesis/blob/main/docs";
7289
- var read = (file) => existsSync(file) ? readFileSync(file, "utf8") : null;
7293
+ var read2 = (file) => existsSync(file) ? readFileSync(file, "utf8") : null;
7290
7294
  var CORE = [
7291
7295
  {
7292
7296
  need: "anything, before building it",
@@ -7416,7 +7420,7 @@ function packageGuides(root, packages) {
7416
7420
  const guides = [];
7417
7421
  for (const p of packages) {
7418
7422
  const stable = p.local ? path21.join(p.dir, "SKILL.md") : stableGuidePath(root, p);
7419
- const text = stable === null ? null : read(stable);
7423
+ const text = stable === null ? null : read2(stable);
7420
7424
  if (stable === null || text === null) continue;
7421
7425
  const description = skillDescription(text);
7422
7426
  const at = description.indexOf("Load before");
@@ -7515,8 +7519,8 @@ function claudeState(root) {
7515
7519
  function agentGuideState(root, packages, agentsFile = "AGENTS.md") {
7516
7520
  const rows = primitivesCatalog(packages);
7517
7521
  const guides = packageGuides(root, packages);
7518
- const skill = read(path21.join(root, SKILL_PATH))?.replace(/\r\n/g, "\n") ?? null;
7519
- const block = currentAgentsBlock(read(path21.join(root, agentsFile)));
7522
+ const skill = read2(path21.join(root, SKILL_PATH))?.replace(/\r\n/g, "\n") ?? null;
7523
+ const block = currentAgentsBlock(read2(path21.join(root, agentsFile)));
7520
7524
  return {
7521
7525
  skill: skill === null ? "missing" : skill === renderSkill(rows, guides) ? "ok" : "stale",
7522
7526
  agents: block === null || block === "broken" ? block ?? "missing" : block === renderAgentsBlock(rows, guides) ? "ok" : "stale",