@marktiderman/genesis-cli 1.12.1 → 1.13.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.
- package/README.md +10 -4
- package/dist/cli.js +65 -29
- package/dist/cli.js.map +1 -1
- package/dist/doctor.js +5 -4
- package/dist/doctor.js.map +1 -1
- package/dist/genesis-catalog.json +48 -9
- package/dist/index.d.ts +11 -1
- package/dist/index.js +63 -28
- package/dist/index.js.map +1 -1
- package/dist/vite.js +5 -4
- package/dist/vite.js.map +1 -1
- package/package.json +2 -2
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
}
|
|
54
54
|
},
|
|
55
55
|
"@marktiderman/genesis-core": {
|
|
56
|
-
"version": "1.
|
|
56
|
+
"version": "1.13.0"
|
|
57
57
|
},
|
|
58
58
|
"@marktiderman/genesis-switchboard": {
|
|
59
59
|
"version": "2.1.0"
|
|
@@ -83,16 +83,16 @@
|
|
|
83
83
|
"version": "0.3.1"
|
|
84
84
|
},
|
|
85
85
|
"@marktiderman/genesis-forms-studio": {
|
|
86
|
-
"version": "0.
|
|
86
|
+
"version": "0.6.0"
|
|
87
87
|
},
|
|
88
88
|
"@marktiderman/genesis-forms-web": {
|
|
89
89
|
"version": "0.6.3"
|
|
90
90
|
},
|
|
91
91
|
"@marktiderman/genesis": {
|
|
92
|
-
"version": "0.9.
|
|
92
|
+
"version": "0.9.13"
|
|
93
93
|
},
|
|
94
94
|
"@marktiderman/genesis-cli": {
|
|
95
|
-
"version": "1.
|
|
95
|
+
"version": "1.13.0"
|
|
96
96
|
},
|
|
97
97
|
"@marktiderman/genesis-native": {
|
|
98
98
|
"version": "0.4.4",
|
|
@@ -373,13 +373,13 @@
|
|
|
373
373
|
}
|
|
374
374
|
},
|
|
375
375
|
"@marktiderman/genesis-studio": {
|
|
376
|
-
"version": "0.2.
|
|
376
|
+
"version": "0.2.1"
|
|
377
377
|
},
|
|
378
378
|
"@marktiderman/genesis-studio-server": {
|
|
379
379
|
"version": "0.3.1"
|
|
380
380
|
},
|
|
381
381
|
"@marktiderman/genesis-supabase": {
|
|
382
|
-
"version": "0.
|
|
382
|
+
"version": "0.7.0",
|
|
383
383
|
"blocks": {
|
|
384
384
|
"account": {
|
|
385
385
|
"feature": {
|
|
@@ -502,10 +502,49 @@
|
|
|
502
502
|
{
|
|
503
503
|
"file": "migrations/0008_genesis_feature_registry.sql",
|
|
504
504
|
"test": "migrations/tests/0008_genesis_feature_registry.test.sql"
|
|
505
|
+
},
|
|
506
|
+
{
|
|
507
|
+
"file": "migrations/0014_genesis_feature_registry_hardening.sql",
|
|
508
|
+
"test": "migrations/tests/0014_genesis_feature_registry_hardening.test.sql"
|
|
509
|
+
}
|
|
510
|
+
],
|
|
511
|
+
"steps": [
|
|
512
|
+
"Sync the registry on every deploy with the service key: syncFeatureRegistry(admin, features.json, { version: BUILD_TIME } (the build time, from a production deployment only)). Grant paid features by writing feature_entitlements from your billing webhook."
|
|
513
|
+
]
|
|
514
|
+
},
|
|
515
|
+
"owner-access": {
|
|
516
|
+
"feature": {
|
|
517
|
+
"name": "Owner access",
|
|
518
|
+
"summary": "The owner-access contract: fail-closed wrappers (genesis_owner_readable, genesis_owner_allows) over the app's two hooks, for every Genesis block whose rows belong to a person, a team or the tenant.",
|
|
519
|
+
"keywords": [
|
|
520
|
+
"access",
|
|
521
|
+
"owners",
|
|
522
|
+
"row level security",
|
|
523
|
+
"tenants",
|
|
524
|
+
"teams"
|
|
525
|
+
],
|
|
526
|
+
"audience": [
|
|
527
|
+
"developer"
|
|
528
|
+
]
|
|
529
|
+
},
|
|
530
|
+
"platforms": [
|
|
531
|
+
"web",
|
|
532
|
+
"native"
|
|
533
|
+
],
|
|
534
|
+
"requires": [
|
|
535
|
+
"tenant-features"
|
|
536
|
+
],
|
|
537
|
+
"migrations": [
|
|
538
|
+
{
|
|
539
|
+
"file": "migrations/0009_genesis_owner_access.sql",
|
|
540
|
+
"test": "migrations/tests/0009_genesis_owner_access.test.sql"
|
|
505
541
|
}
|
|
506
542
|
],
|
|
543
|
+
"install": [
|
|
544
|
+
"@supabase/supabase-js@^2.118.0"
|
|
545
|
+
],
|
|
507
546
|
"steps": [
|
|
508
|
-
"
|
|
547
|
+
"Define private.genesis_owner_can(tenant, viewer, person_id, team_id, organization_id, action) and private.genesis_readable_owners(viewer) in your own migration, as the header of 0009 shows. Without them the wrappers answer no."
|
|
509
548
|
]
|
|
510
549
|
}
|
|
511
550
|
}
|
|
@@ -701,10 +740,10 @@
|
|
|
701
740
|
}
|
|
702
741
|
},
|
|
703
742
|
"@marktiderman/genesis-ui": {
|
|
704
|
-
"version": "2.
|
|
743
|
+
"version": "2.18.0"
|
|
705
744
|
},
|
|
706
745
|
"@marktiderman/genesis-ui-native": {
|
|
707
|
-
"version": "2.
|
|
746
|
+
"version": "2.6.0"
|
|
708
747
|
}
|
|
709
748
|
}
|
|
710
749
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -38,12 +38,19 @@ interface FieldSettings {
|
|
|
38
38
|
label?: string;
|
|
39
39
|
description?: string;
|
|
40
40
|
widget?: string;
|
|
41
|
+
/** Server-owned: clients never write it. */
|
|
42
|
+
readonly?: boolean;
|
|
43
|
+
/** Left out of lists, exports and previews unless a screen asks. */
|
|
44
|
+
sensitive?: boolean;
|
|
41
45
|
}
|
|
42
46
|
/** What a table comment's `@genesis {...}` may set. */
|
|
43
47
|
interface TableSettings {
|
|
44
48
|
label?: string;
|
|
45
49
|
labelField?: string;
|
|
46
50
|
description?: string;
|
|
51
|
+
/** What one row is called ("brand"), and several when not `noun` + "s". */
|
|
52
|
+
noun?: string;
|
|
53
|
+
nounPlural?: string;
|
|
47
54
|
}
|
|
48
55
|
|
|
49
56
|
type Sql = postgres.Sql;
|
|
@@ -83,6 +90,9 @@ interface EmitOptions {
|
|
|
83
90
|
/** Where the contract came from, for the header. Never include a secret. */
|
|
84
91
|
source: string;
|
|
85
92
|
}
|
|
93
|
+
/** Thrown when the contract can't be emitted as asked (a name clash, a labelField that isn't a column). */
|
|
94
|
+
declare class EmitError extends Error {
|
|
95
|
+
}
|
|
86
96
|
declare function emitContracts(tables: readonly IntrospectedTable[], options: EmitOptions): string;
|
|
87
97
|
|
|
88
98
|
interface ParsedComment<S> {
|
|
@@ -140,4 +150,4 @@ interface InitPlan {
|
|
|
140
150
|
declare function detectHost(facts: ProjectFacts): StudioHost;
|
|
141
151
|
declare function planStudioInit(facts: ProjectFacts, options?: InitOptions): InitPlan;
|
|
142
152
|
|
|
143
|
-
export { CommentSettingsError, type EmitOptions, type FieldSettings, type InitOptions, type InitPlan, type IntrospectedColumn, type IntrospectedTable, type OpenApiDocument, type PlannedFile, type ProjectFacts, type StorageType, type StudioHost, type TableSettings, detectHost, emitContracts, introspectOpenApi, introspectPostgres, parseColumnComment, parseTableComment, planStudioInit };
|
|
153
|
+
export { CommentSettingsError, EmitError, type EmitOptions, type FieldSettings, type InitOptions, type InitPlan, type IntrospectedColumn, type IntrospectedTable, type OpenApiDocument, type PlannedFile, type ProjectFacts, type StorageType, type StudioHost, type TableSettings, detectHost, emitContracts, introspectOpenApi, introspectPostgres, parseColumnComment, parseTableComment, planStudioInit };
|
package/dist/index.js
CHANGED
|
@@ -325,8 +325,8 @@ This consumer was bootstrapped with \`@marktiderman/genesis-cli init ${consumer}
|
|
|
325
325
|
|
|
326
326
|
// src/introspect/comments.ts
|
|
327
327
|
var MARKER = "@genesis";
|
|
328
|
-
var TABLE_KEYS =
|
|
329
|
-
var FIELD_KEYS =
|
|
328
|
+
var TABLE_KEYS = { label: "string", labelField: "string", description: "string", noun: "string", nounPlural: "string" };
|
|
329
|
+
var FIELD_KEYS = { label: "string", description: "string", widget: "string", readonly: "boolean", sensitive: "boolean" };
|
|
330
330
|
var CommentSettingsError = class extends Error {
|
|
331
331
|
};
|
|
332
332
|
function parse(comment, keys, where) {
|
|
@@ -346,13 +346,17 @@ function parse(comment, keys, where) {
|
|
|
346
346
|
}
|
|
347
347
|
const settings = {};
|
|
348
348
|
for (const [key2, v] of Object.entries(value)) {
|
|
349
|
-
|
|
350
|
-
|
|
349
|
+
const kind = keys[key2];
|
|
350
|
+
if (!kind) {
|
|
351
|
+
throw new CommentSettingsError(`${where}: unknown ${MARKER} setting "${key2}". Allowed: ${Object.keys(keys).join(", ")}.`);
|
|
351
352
|
}
|
|
352
|
-
if (typeof v !==
|
|
353
|
+
if (typeof v !== kind) throw new CommentSettingsError(`${where}: ${MARKER} "${key2}" must be a ${kind}.`);
|
|
353
354
|
settings[key2] = v;
|
|
354
355
|
}
|
|
355
|
-
return {
|
|
356
|
+
return {
|
|
357
|
+
...description ? { description } : {},
|
|
358
|
+
...Object.keys(settings).length ? { settings } : {}
|
|
359
|
+
};
|
|
356
360
|
}
|
|
357
361
|
function parseTableComment(comment, table) {
|
|
358
362
|
return parse(comment, TABLE_KEYS, table);
|
|
@@ -526,12 +530,16 @@ function typeName(table) {
|
|
|
526
530
|
const pascal = `${table.schema}_${table.table}`.split(/[^A-Za-z0-9]+/).filter(Boolean).map((p) => p[0].toUpperCase() + p.slice(1)).join("");
|
|
527
531
|
return `${/^[0-9]/.test(pascal) ? "T" : ""}${pascal}Row`;
|
|
528
532
|
}
|
|
533
|
+
function constName(table) {
|
|
534
|
+
const row = typeName(table).replace(/Row$/, "");
|
|
535
|
+
return row[0].toLowerCase() + row.slice(1);
|
|
536
|
+
}
|
|
529
537
|
function tsType(column) {
|
|
530
538
|
const base = column.enumValues?.length ? column.enumValues.map(quote).join(" | ") : TS_TYPE[column.type];
|
|
531
539
|
const element = column.array ? base.includes("|") ? `(${base})[]` : `${base}[]` : base;
|
|
532
540
|
return column.nullable ? `${element} | null` : element;
|
|
533
541
|
}
|
|
534
|
-
function field(column) {
|
|
542
|
+
function field(column, indent) {
|
|
535
543
|
const parts = [`name: ${quote(column.name)}`, `type: ${quote(column.type)}`, `dbType: ${quote(column.dbType)}`];
|
|
536
544
|
if (column.array) parts.push("array: true");
|
|
537
545
|
if (column.nullable) parts.push("nullable: true");
|
|
@@ -547,10 +555,25 @@ function field(column) {
|
|
|
547
555
|
if (label) parts.push(`label: ${quote(label)}`);
|
|
548
556
|
if (description) parts.push(`description: ${quote(description)}`);
|
|
549
557
|
if (column.settings?.widget) parts.push(`widget: ${quote(column.settings.widget)}`);
|
|
550
|
-
|
|
558
|
+
if (column.settings?.readonly) parts.push("readOnly: true");
|
|
559
|
+
if (column.settings?.sensitive) parts.push("sensitive: true");
|
|
560
|
+
return `${indent}{ ${parts.join(", ")} },`;
|
|
551
561
|
}
|
|
562
|
+
var EmitError = class extends Error {
|
|
563
|
+
};
|
|
552
564
|
function emitContracts(tables, options) {
|
|
553
565
|
const sorted = [...tables].sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
|
|
566
|
+
const seen = /* @__PURE__ */ new Map();
|
|
567
|
+
for (const table of sorted) {
|
|
568
|
+
const id = typeName(table);
|
|
569
|
+
const other = seen.get(id);
|
|
570
|
+
if (other) throw new EmitError(`${other} and ${table.name} would both be named ${id}; rename one, or introspect them separately.`);
|
|
571
|
+
seen.set(id, table.name);
|
|
572
|
+
const labelField = table.settings?.labelField;
|
|
573
|
+
if (labelField && !table.columns.some((c) => c.name === labelField)) {
|
|
574
|
+
throw new EmitError(`${table.name}: @genesis labelField "${labelField}" isn't one of its columns.`);
|
|
575
|
+
}
|
|
576
|
+
}
|
|
554
577
|
const out = [
|
|
555
578
|
"// Generated by `genesis introspect` \u2014 do not edit by hand.",
|
|
556
579
|
`// Source: ${options.source}`,
|
|
@@ -559,31 +582,42 @@ function emitContracts(tables, options) {
|
|
|
559
582
|
"// Labels, widgets and descriptions come from `@genesis {...}` settings in",
|
|
560
583
|
"// table and column comments. Pass `contracts` to createStudioHandler: it",
|
|
561
584
|
"// wins over discovery for presentation, while types, keys and every",
|
|
562
|
-
"// permission still come from the live database.",
|
|
585
|
+
"// permission still come from the live database. Each contract goes through",
|
|
586
|
+
"// defineResource, so a bad @genesis setting fails to compile and views read the",
|
|
587
|
+
"// row type with RowOf<typeof contract>.",
|
|
563
588
|
"",
|
|
564
|
-
|
|
589
|
+
'import { defineResource } from "@marktiderman/genesis-core";',
|
|
590
|
+
""
|
|
565
591
|
];
|
|
566
592
|
for (const table of sorted) {
|
|
567
|
-
|
|
568
|
-
out.push(
|
|
569
|
-
out.push(`
|
|
570
|
-
|
|
571
|
-
|
|
593
|
+
const row = typeName(table);
|
|
594
|
+
out.push(`/** \`${table.name}\`. */`);
|
|
595
|
+
out.push(`export const ${constName(table)} = defineResource<${row}>()({`);
|
|
596
|
+
out.push(` name: ${quote(table.name)},`);
|
|
597
|
+
out.push(` key: ${table.key.length === 1 ? quote(table.key[0]) : `[${table.key.map(quote).join(", ")}]`},`);
|
|
598
|
+
if (table.settings?.label) out.push(` label: ${quote(table.settings.label)},`);
|
|
599
|
+
if (table.settings?.labelField) out.push(` labelField: ${quote(table.settings.labelField)},`);
|
|
600
|
+
if (table.settings?.noun) out.push(` noun: ${quote(table.settings.noun)},`);
|
|
601
|
+
if (table.settings?.nounPlural) out.push(` nounPlural: ${quote(table.settings.nounPlural)},`);
|
|
572
602
|
const description = table.settings?.description ?? table.description;
|
|
573
|
-
if (description) out.push(`
|
|
574
|
-
out.push("
|
|
575
|
-
for (const column of table.columns) out.push(field(column));
|
|
576
|
-
out.push("
|
|
577
|
-
out.push("
|
|
578
|
-
}
|
|
603
|
+
if (description) out.push(` description: ${quote(description)},`);
|
|
604
|
+
out.push(" fields: [");
|
|
605
|
+
for (const column of table.columns) out.push(field(column, " "));
|
|
606
|
+
out.push(" ],");
|
|
607
|
+
out.push("});", "");
|
|
608
|
+
}
|
|
609
|
+
out.push("export const contracts = {");
|
|
610
|
+
for (const table of sorted) out.push(` ${quote(table.name)}: ${constName(table)},`);
|
|
579
611
|
out.push("} as const;", "");
|
|
580
612
|
out.push("/** Every resource in this contract, `schema.table`. */");
|
|
581
613
|
out.push("export type GenesisResource = keyof typeof contracts;", "");
|
|
582
614
|
for (const table of sorted) {
|
|
583
615
|
out.push(`/** A row of \`${table.name}\`, as the studio handler returns it. */`);
|
|
584
|
-
out.push(`export
|
|
616
|
+
out.push(`export type ${typeName(table)} = {`);
|
|
585
617
|
for (const column of table.columns) out.push(` ${propKey(column.name)}: ${tsType(column)};`);
|
|
586
|
-
out.push("}", "");
|
|
618
|
+
out.push("};", "");
|
|
619
|
+
out.push(`/** The field names of \`${table.name}\`. */`);
|
|
620
|
+
out.push(`export type ${typeName(table).replace(/Row$/, "Field")} = keyof ${typeName(table)};`, "");
|
|
587
621
|
}
|
|
588
622
|
out.push("/** Row types by resource. */");
|
|
589
623
|
out.push("export interface GenesisRows {");
|
|
@@ -2518,7 +2552,7 @@ function namedImportsFrom(code, pkg) {
|
|
|
2518
2552
|
// src/doctor/native.ts
|
|
2519
2553
|
var SCRIPT_EXTS3 = /* @__PURE__ */ new Set([".ts", ".tsx", ".js", ".jsx", ".mts", ".cts", ".mjs", ".cjs"]);
|
|
2520
2554
|
var JSX_EXTS3 = /* @__PURE__ */ new Set([".tsx", ".jsx"]);
|
|
2521
|
-
var LAYOUT_NAME = /(?:Page|Screen|ScreenContainer)$/;
|
|
2555
|
+
var LAYOUT_NAME = /(?:Page|Screen|ScreenContainer)$|^NativeResourceView$/;
|
|
2522
2556
|
var NON_SCREEN_ROUTE = /(?:^|\/)(?:_layout|\+html|\+native-intent|\+middleware)\.[jt]sx?$|\+api\.[jt]sx?$/;
|
|
2523
2557
|
var PART_HEADER = /(?:Section|List|Card|Dialog|Table|Group|Column|Row|Cell|Accordion|Sheet|Drawer|Modal|Popover|Menu|Panel|Form)Header$/;
|
|
2524
2558
|
var HIDES_HEADER = /\bheaderShown\s*(?::|=\s*\{)\s*false\b/;
|
|
@@ -4357,8 +4391,9 @@ var CONTAINER = /(?:Card|CardContent|Dialog|DialogContent|Sheet|SheetContent|Dra
|
|
|
4357
4391
|
var SWITCHER = /<(TabsList|SubNavTabs)(?=[\s>/])/g;
|
|
4358
4392
|
var SHELL = /<AppShell(?=[\s>/])/;
|
|
4359
4393
|
var GENESIS_PACKAGE2 = /^@marktiderman\/genesis(?:-[\w-]+)?(?:\/|$)/;
|
|
4360
|
-
var PAGE_LAYOUT = /^(?!Breadcrumb)[A-Z]\w*(?:Page|PageShell)$/;
|
|
4361
|
-
var
|
|
4394
|
+
var PAGE_LAYOUT = /^(?:(?!Breadcrumb)[A-Z]\w*(?:Page|PageShell)|ResourceView)$/;
|
|
4395
|
+
var EMBEDDED_RESOURCE_VIEW = /<ResourceView\b[^>]*?\blayout\s*=\s*(?:(["'`]) {8}\1|\{\s*(["'`]) {8}\2\s*\})[^>]*>/g;
|
|
4396
|
+
var PACKAGE_SCREEN = /^(?:(?!Breadcrumb)[A-Z]\w*(?:Page|PageShell|Screen|Workspace)|ResourceView)$/;
|
|
4362
4397
|
var isNative = (ctx) => ctx.config.packs?.includes("native") ?? false;
|
|
4363
4398
|
var rendersRe = (names) => {
|
|
4364
4399
|
const list = [...names];
|
|
@@ -4472,7 +4507,7 @@ function checkPageLayouts(ctx) {
|
|
|
4472
4507
|
const rendersLayout = (code) => {
|
|
4473
4508
|
const names = new Set(layouts);
|
|
4474
4509
|
for (const n of namedImportsFrom(code, GENESIS_PACKAGE2)) if (PACKAGE_SCREEN.test(n)) names.add(n);
|
|
4475
|
-
return rendersRe(names)?.test(code) ?? false;
|
|
4510
|
+
return rendersRe(names)?.test(code.replace(EMBEDDED_RESOURCE_VIEW, "")) ?? false;
|
|
4476
4511
|
};
|
|
4477
4512
|
const cache2 = /* @__PURE__ */ new Map();
|
|
4478
4513
|
const provides = (r) => {
|
|
@@ -4630,6 +4665,6 @@ function formatReport(result) {
|
|
|
4630
4665
|
return lines.join("\n");
|
|
4631
4666
|
}
|
|
4632
4667
|
|
|
4633
|
-
export { CommentSettingsError, DoctorConfigError, GenesisConfigError, defineDoctorPlugin, detectHost, emitContracts, formatReport, introspectOpenApi, introspectPostgres, parseColumnComment, parseTableComment, planScaffold, planStudioInit, readGenesisConfig, runDoctor, runScaffold, validateConsumerName, validateLinks };
|
|
4668
|
+
export { CommentSettingsError, DoctorConfigError, EmitError, GenesisConfigError, defineDoctorPlugin, detectHost, emitContracts, formatReport, introspectOpenApi, introspectPostgres, parseColumnComment, parseTableComment, planScaffold, planStudioInit, readGenesisConfig, runDoctor, runScaffold, validateConsumerName, validateLinks };
|
|
4634
4669
|
//# sourceMappingURL=index.js.map
|
|
4635
4670
|
//# sourceMappingURL=index.js.map
|