@marktiderman/genesis-features 0.6.1 → 0.7.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 CHANGED
@@ -221,32 +221,50 @@ Blocks shipped so far: `createUpdates(…)` (`app-updates`, in `@marktiderman/ge
221
221
 
222
222
  ## Content packs
223
223
 
224
- A content pack is versioned data that fills installed blocks: session types and their agendas, metric
225
- templates, custom field definitions (genesis-forms fields on a work table), forms, roadmap templates and
226
- labels. Packs are code: the publishing package exports them, and an installer copies them into a tenant's
227
- editable rows, keeping each row's source (pack, version, key) so an update can tell what someone changed.
224
+ A content pack is versioned data that fills installed blocks: whatever those blocks hold (meeting types,
225
+ templates, checklists, forms) plus labels. Packs are code: the publishing package exports them, and an
226
+ installer copies them into a tenant's editable rows, keeping each row's source (pack, version, key) so an
227
+ update can tell what someone changed.
228
+
229
+ A pack's `sections` are keyed by the block that owns them. Genesis checks what every pack shares; what an
230
+ item holds is the block's business, checked by the validator it registers as `contributes.contentSection`:
228
231
 
229
232
  ```ts
230
- import { contentPackProblems, defineContentPack } from "@marktiderman/genesis-features/blocks";
231
-
232
- export const weeklyTeamRhythm = defineContentPack({
233
- id: "weekly-team-rhythm",
234
- name: "Weekly team rhythm",
235
- version: "1.0.0",
236
- publisher: "@marktiderman/genesis-content",
237
- requires: ["sessions", "metrics"],
238
- labels: { "pursuit.quarter": "Rocks" },
239
- sessionTypes: [{ key: "weekly", kind: "team", name: "Weekly meeting", agenda: [{ key: "check-in", title: "Check in", minutes: 5 }] }],
240
- metricTemplates: [{ key: "revenue", name: "Revenue", unitType: "currency", cadence: "weekly", goalDirection: "up" }],
233
+ import { contentPackProblems, defineBlock, defineContentPack } from "@marktiderman/genesis-features/blocks";
234
+
235
+ export const meetingsBlock = defineBlock({
236
+ id: "meetings",
237
+ contributes: {
238
+ // Returns every problem with this block's items in a pack.
239
+ contentSection: (items) =>
240
+ (items as { key: string; minutes?: number }[]).filter((m) => !((m.minutes ?? 0) > 0)).map((m) => `${m.key}: minutes must be more than 0`),
241
+ },
241
242
  });
242
243
 
243
- contentPackProblems(weeklyTeamRhythm, installedBlockIds); // [] when it can be installed
244
+ export const weeklyTeamRhythm = defineContentPack(
245
+ {
246
+ id: "weekly-team-rhythm",
247
+ name: "Weekly team rhythm",
248
+ version: "1.0.0",
249
+ publisher: "@acme/content",
250
+ requires: ["meetings"],
251
+ labels: { "project.phase": "Stage" },
252
+ sections: { meetings: [{ key: "weekly", name: "Weekly meeting", minutes: 60 }] },
253
+ },
254
+ { blocks: [meetingsBlock] },
255
+ );
256
+
257
+ contentPackProblems(weeklyTeamRhythm, { installed: installedBlockIds, blocks: [meetingsBlock] }); // [] when it can be installed
244
258
  ```
245
259
 
246
- `defineContentPack` lists every problem at once: ids, semver versions, keys (unique per section, stable
247
- across versions), references between roadmap items, field targets, and any section whose block
248
- `requires` doesn't list (`sessionTypes` → sessions, `metricTemplates` → metrics, `fieldDefinitions` →
249
- its target's block, `forms` → forms, `roadmapTemplates` → roadmap).
260
+ `defineContentPack` lists every problem at once: ids, semver versions, publisher, label keys, item keys
261
+ (unique per section, stable across versions), every block validator's problems, and any section whose
262
+ block `requires` doesn't list. `contentPackProblems(pack, installedBlockIds)` still takes the installed
263
+ blocks alone; `{ validators: { meetings: fn } }` gives validators by block id instead of blocks.
264
+
265
+ The typed sections packs had before (`sessionTypes`, `metricTemplates`, `fieldDefinitions`, `forms`,
266
+ `roadmapTemplates`) still work and are checked as before, but are deprecated: put that data in `sections`
267
+ under the block that owns it.
250
268
 
251
269
  ## The page
252
270
 
package/dist/blocks.d.ts CHANGED
@@ -1,6 +1,228 @@
1
1
  import { F as FeaturePlatform } from './platforms-NR0liM8L.js';
2
2
  export { a as FEATURE_PLATFORMS } from './platforms-NR0liM8L.js';
3
3
 
4
+ /**
5
+ * The typed sections content packs had before `sections`: session types,
6
+ * metric templates, custom fields, forms and roadmap templates, each tied to a
7
+ * block an app owns. Kept, and still checked as before, so packs written
8
+ * against them keep working. New packs put their data in `sections`, keyed by
9
+ * block id, and the block checks it.
10
+ *
11
+ * Everything here is deprecated and goes in the next major.
12
+ */
13
+
14
+ /**
15
+ * A content pack's settings for one session type, with its agenda.
16
+ * @deprecated Put session types in `sections` under the block that owns them, checked by that block's validator.
17
+ * @stability Beta
18
+ */
19
+ interface ContentPackSessionType {
20
+ key: string;
21
+ kind: string;
22
+ name: string;
23
+ description?: string;
24
+ defaultMinutes?: number;
25
+ agenda: readonly {
26
+ key: string;
27
+ title: string;
28
+ minutes: number;
29
+ }[];
30
+ }
31
+ /**
32
+ * A metric to start from.
33
+ * @deprecated Put metric templates in `sections` under the block that owns them, checked by that block's validator.
34
+ * @stability Beta
35
+ */
36
+ interface ContentPackMetricTemplate {
37
+ key: string;
38
+ name: string;
39
+ unitType: string;
40
+ unit?: string;
41
+ cadence: string;
42
+ goalDirection: string;
43
+ goalValue?: number;
44
+ goalMax?: number;
45
+ measureKind?: string;
46
+ rollup?: string;
47
+ }
48
+ /**
49
+ * Where a custom field lives, and the block that owns that table.
50
+ * @deprecated Custom fields belong in `sections` under the block that owns their table.
51
+ * @stability Beta
52
+ */
53
+ declare const CONTENT_PACK_FIELD_TARGETS: {
54
+ readonly pursuits: "pursuits";
55
+ readonly work_items: "pursuits";
56
+ readonly metrics: "metrics";
57
+ readonly sessions: "sessions";
58
+ };
59
+ /**
60
+ * @deprecated See {@link CONTENT_PACK_FIELD_TARGETS}.
61
+ * @stability Beta
62
+ */
63
+ type ContentPackFieldTarget = keyof typeof CONTENT_PACK_FIELD_TARGETS;
64
+ /**
65
+ * A custom field: a genesis-forms serializable field, on one of the work tables.
66
+ * @deprecated Put field definitions in `sections` under the block that owns their table.
67
+ * @stability Beta
68
+ */
69
+ interface ContentPackFieldDefinition {
70
+ key: string;
71
+ target: ContentPackFieldTarget;
72
+ label: string;
73
+ /** A genesis-forms serializable field: type, options, validation. */
74
+ field: {
75
+ readonly type: string;
76
+ readonly [key: string]: unknown;
77
+ };
78
+ required?: boolean;
79
+ visibility: "tenant" | "app" | "private";
80
+ }
81
+ /**
82
+ * A worksheet, assessment or form: a genesis-forms definition.
83
+ * @deprecated Put forms in `sections` under the block that owns them.
84
+ * @stability Beta
85
+ */
86
+ interface ContentPackForm {
87
+ key: string;
88
+ kind: "worksheet" | "assessment" | "form";
89
+ title: string;
90
+ definition: {
91
+ readonly [key: string]: unknown;
92
+ };
93
+ scoring?: unknown;
94
+ }
95
+ /**
96
+ * A roadmap to start from: items that release by a rule, linked to each other by key.
97
+ * @deprecated Put roadmap templates in `sections` under the block that owns them, checked by that block's validator.
98
+ * @stability Beta
99
+ */
100
+ interface ContentPackRoadmapTemplate {
101
+ key: string;
102
+ name: string;
103
+ items: readonly {
104
+ key: string;
105
+ kind: string;
106
+ title: string;
107
+ /** Another item's key in this template. */
108
+ ref?: string;
109
+ release: {
110
+ rule: string;
111
+ afterDays?: number;
112
+ anchor?: string;
113
+ };
114
+ }[];
115
+ }
116
+ /** The deprecated typed sections, as optional fields of a pack. */
117
+ interface LegacyContentPackSections {
118
+ /** @deprecated Use `sections`. */
119
+ sessionTypes?: readonly ContentPackSessionType[];
120
+ /** @deprecated Use `sections`. */
121
+ metricTemplates?: readonly ContentPackMetricTemplate[];
122
+ /** @deprecated Use `sections`. */
123
+ fieldDefinitions?: readonly ContentPackFieldDefinition[];
124
+ /** @deprecated Use `sections`. */
125
+ forms?: readonly ContentPackForm[];
126
+ /** @deprecated Use `sections`. */
127
+ roadmapTemplates?: readonly ContentPackRoadmapTemplate[];
128
+ }
129
+
130
+ /**
131
+ * Content packs: versioned data that fills installed blocks. A pack is code,
132
+ * reviewed like any other: the publishing package exports it, and an installer
133
+ * copies it into a tenant's editable rows, keeping each row's source (pack,
134
+ * version, key) so an update can tell what a person changed.
135
+ *
136
+ * A pack's `sections` are keyed by the block that owns them, and each holds
137
+ * that block's items. Genesis checks what every pack shares (id, version,
138
+ * publisher, requires, labels, and a unique `key` on every item); what an item
139
+ * holds is the block's business, checked by the validator the block registers
140
+ * (`contributes.contentSection` on `defineBlock`, or a `validators` map).
141
+ *
142
+ * `defineContentPack` checks a pack's shape; `contentPackProblems` with the
143
+ * installed blocks also checks that every block it fills is there. Keys, not
144
+ * ids, link things together, and stay the same across versions.
145
+ *
146
+ * No zod here: packs ship to phones with `/blocks`.
147
+ */
148
+
149
+ /**
150
+ * Checks one section's items for the block that owns it, and returns every
151
+ * problem (an empty list when they're fine). Messages are relative to the
152
+ * section ("weekly: minutes must be more than 0"): the checker puts the pack
153
+ * and section in front. A validator that throws is reported as a problem.
154
+ *
155
+ * @stability Beta
156
+ */
157
+ type ContentPackSectionValidator = (items: readonly unknown[]) => readonly string[];
158
+ /** A pack's sections: block id → that block's items. @stability Beta */
159
+ type ContentPackSections = Readonly<Record<string, readonly unknown[]>>;
160
+ /** One content pack, as its publisher defines it. @stability Beta */
161
+ interface ContentPackDef extends LegacyContentPackSections {
162
+ /** Kebab-case, unique per publisher. */
163
+ id: string;
164
+ name: string;
165
+ description?: string;
166
+ /** Semver. Updates are additive. */
167
+ version: string;
168
+ /** The package that publishes it. */
169
+ publisher: string;
170
+ /** The block ids it fills; installing is refused unless every one is installed. */
171
+ requires: readonly string[];
172
+ /** Taxonomy: label key → display text, e.g. `"project.phase": "Stage"`. */
173
+ labels?: Readonly<Record<string, string>>;
174
+ /**
175
+ * The data it fills, by block id. Every item has a `key`, unique in its
176
+ * section and the same across versions; the rest is checked by the block's
177
+ * validator.
178
+ */
179
+ sections?: ContentPackSections;
180
+ }
181
+ /** @stability Beta */
182
+ interface ContentPackCheckOptions {
183
+ /** The installed blocks: every block the pack requires must be one. */
184
+ installed?: EnabledBlocks;
185
+ /** Blocks whose `contributes.contentSection` checks their section's items. */
186
+ blocks?: readonly BlockDef<string, unknown>[];
187
+ /** Section validators by block id; these win over a block's own. */
188
+ validators?: Readonly<Record<string, ContentPackSectionValidator>>;
189
+ }
190
+ /** Thrown by {@link defineContentPack}; lists every problem at once. @stability Beta */
191
+ declare class ContentPackError extends Error {
192
+ readonly problems: string[];
193
+ constructor(problems: string[]);
194
+ }
195
+ /** The block ids a pack's sections need, whatever it declares. @stability Beta */
196
+ declare function contentPackBlocks(pack: ContentPackDef): string[];
197
+ /**
198
+ * Every problem with a pack: its shape, each section's items (through the
199
+ * validator its block registers, when given) and, given the installed blocks,
200
+ * any block it fills that isn't installed. An empty list means it can be
201
+ * installed. The second argument is the installed blocks, or options.
202
+ *
203
+ * @stability Beta
204
+ */
205
+ declare function contentPackProblems(pack: ContentPackDef, installedOrOptions?: EnabledBlocks | ContentPackCheckOptions): string[];
206
+ /**
207
+ * Declare a content pack: returns it unchanged, typed, after checking its
208
+ * shape (throws a {@link ContentPackError} listing every problem). Give the
209
+ * blocks it fills, or validators by block id, to check each section's items
210
+ * too. Whether its blocks are installed is checked at install time with
211
+ * {@link contentPackProblems}.
212
+ *
213
+ * ```ts
214
+ * export const weeklyTeamRhythm = defineContentPack({
215
+ * id: "weekly-team-rhythm", name: "Weekly team rhythm", version: "1.0.0",
216
+ * publisher: "@acme/content", requires: ["meetings"],
217
+ * labels: { "project.phase": "Stage" },
218
+ * sections: { meetings: [{ key: "weekly", name: "Weekly meeting", minutes: 60 }] },
219
+ * }, { blocks: [meetingsBlock] });
220
+ * ```
221
+ *
222
+ * @stability Beta
223
+ */
224
+ declare function defineContentPack<const T extends ContentPackDef>(pack: T, options?: Omit<ContentPackCheckOptions, "installed">): T;
225
+
4
226
  /**
5
227
  * A navigation entry a block offers. The app's nav tree places it (by the
6
228
  * block's FeatureId and this id); a block never decides where it goes.
@@ -112,6 +334,12 @@ interface BlockContributions<S = unknown> {
112
334
  /** Agent skills that come with it: repo or package paths to a `SKILL.md`. */
113
335
  skills?: readonly string[];
114
336
  privacy?: BlockPrivacy;
337
+ /**
338
+ * Checks this block's section of a content pack (`sections[<block id>]`):
339
+ * returns every problem with its items. `defineContentPack` and
340
+ * `contentPackProblems` run it when given the block.
341
+ */
342
+ contentSection?: ContentPackSectionValidator;
115
343
  }
116
344
  /**
117
345
  * One block. `id` is the block's FeatureId: the same id as its entry in the
@@ -232,147 +460,4 @@ type SlotOf<B> = B extends BlockDef<string, infer S> ? S : never;
232
460
  */
233
461
  declare function resolveBlocks<B extends BlockDef<string, unknown>>(blocks: readonly B[], enabled?: EnabledBlocks, options?: ResolveBlocksOptions): ResolvedBlocks<B>;
234
462
 
235
- /**
236
- * Content packs: versioned data that fills installed blocks (session types and
237
- * agendas, metric templates, custom field definitions, forms, roadmap templates,
238
- * labels). A pack is code, reviewed like any other: the publishing package
239
- * exports it, and an installer copies it into a tenant's editable rows, keeping
240
- * each row's source (pack, version, key) so an update can tell what a person
241
- * changed.
242
- *
243
- * `defineContentPack` checks a pack's shape; `contentPackProblems` with the
244
- * installed blocks also checks that every block it fills is there. Keys, not
245
- * ids, link things together, and stay the same across versions.
246
- *
247
- * No zod here: packs ship to phones with `/blocks`.
248
- */
249
-
250
- /** A content pack's settings for one session type, with its agenda. @stability Beta */
251
- interface ContentPackSessionType {
252
- key: string;
253
- kind: string;
254
- name: string;
255
- description?: string;
256
- defaultMinutes?: number;
257
- agenda: readonly {
258
- key: string;
259
- title: string;
260
- minutes: number;
261
- }[];
262
- }
263
- /** A metric to start from. @stability Beta */
264
- interface ContentPackMetricTemplate {
265
- key: string;
266
- name: string;
267
- unitType: string;
268
- unit?: string;
269
- cadence: string;
270
- goalDirection: string;
271
- goalValue?: number;
272
- goalMax?: number;
273
- measureKind?: string;
274
- rollup?: string;
275
- }
276
- /** Where a custom field lives, and the block that owns that table. @stability Beta */
277
- declare const CONTENT_PACK_FIELD_TARGETS: {
278
- readonly pursuits: "pursuits";
279
- readonly work_items: "pursuits";
280
- readonly metrics: "metrics";
281
- readonly sessions: "sessions";
282
- };
283
- /** @stability Beta */
284
- type ContentPackFieldTarget = keyof typeof CONTENT_PACK_FIELD_TARGETS;
285
- /** A custom field: a genesis-forms serializable field, on one of the work tables. @stability Beta */
286
- interface ContentPackFieldDefinition {
287
- key: string;
288
- target: ContentPackFieldTarget;
289
- label: string;
290
- /** A genesis-forms serializable field: type, options, validation. */
291
- field: {
292
- readonly type: string;
293
- readonly [key: string]: unknown;
294
- };
295
- required?: boolean;
296
- visibility: "tenant" | "app" | "private";
297
- }
298
- /** A worksheet, assessment or form: a genesis-forms definition. @stability Beta */
299
- interface ContentPackForm {
300
- key: string;
301
- kind: "worksheet" | "assessment" | "form";
302
- title: string;
303
- definition: {
304
- readonly [key: string]: unknown;
305
- };
306
- scoring?: unknown;
307
- }
308
- /** A roadmap to start from: items that release by a rule, linked to each other by key. @stability Beta */
309
- interface ContentPackRoadmapTemplate {
310
- key: string;
311
- name: string;
312
- items: readonly {
313
- key: string;
314
- kind: string;
315
- title: string;
316
- /** Another item's key in this template. */
317
- ref?: string;
318
- release: {
319
- rule: string;
320
- afterDays?: number;
321
- anchor?: string;
322
- };
323
- }[];
324
- }
325
- /** One content pack, as its publisher defines it. @stability Beta */
326
- interface ContentPackDef {
327
- /** Kebab-case, unique per publisher. */
328
- id: string;
329
- name: string;
330
- description?: string;
331
- /** Semver. Updates are additive. */
332
- version: string;
333
- /** The package that publishes it. */
334
- publisher: string;
335
- /** The block ids it fills; installing is refused unless every one is installed. */
336
- requires: readonly string[];
337
- /** Taxonomy: label key → display text, e.g. `"pursuit.quarter": "Rocks"`. */
338
- labels?: Readonly<Record<string, string>>;
339
- sessionTypes?: readonly ContentPackSessionType[];
340
- metricTemplates?: readonly ContentPackMetricTemplate[];
341
- fieldDefinitions?: readonly ContentPackFieldDefinition[];
342
- forms?: readonly ContentPackForm[];
343
- roadmapTemplates?: readonly ContentPackRoadmapTemplate[];
344
- }
345
- /** Thrown by {@link defineContentPack}; lists every problem at once. @stability Beta */
346
- declare class ContentPackError extends Error {
347
- readonly problems: string[];
348
- constructor(problems: string[]);
349
- }
350
- /** The block ids a pack's sections need, whatever it declares. @stability Beta */
351
- declare function contentPackBlocks(pack: ContentPackDef): string[];
352
- /**
353
- * Every problem with a pack: its shape and, given the installed blocks, any
354
- * block it fills that isn't installed. An empty list means it can be installed.
355
- *
356
- * @stability Beta
357
- */
358
- declare function contentPackProblems(pack: ContentPackDef, installed?: EnabledBlocks): string[];
359
- /**
360
- * Declare a content pack: returns it unchanged, typed, after checking its
361
- * shape (throws a {@link ContentPackError} listing every problem). Whether its
362
- * blocks are installed is checked at install time with
363
- * {@link contentPackProblems}.
364
- *
365
- * ```ts
366
- * export const weeklyTeamRhythm = defineContentPack({
367
- * id: "weekly-team-rhythm", name: "Weekly team rhythm", version: "1.0.0",
368
- * publisher: "@marktiderman/genesis-content", requires: ["sessions", "metrics"],
369
- * labels: { "pursuit.quarter": "Rocks" },
370
- * sessionTypes: [{ key: "weekly", kind: "team", name: "Weekly meeting", agenda: [{ key: "check-in", title: "Check in", minutes: 5 }] }],
371
- * });
372
- * ```
373
- *
374
- * @stability Beta
375
- */
376
- declare function defineContentPack<const T extends ContentPackDef>(pack: T): T;
377
-
378
- export { type BlockContributions, type BlockDataUse, type BlockDef, BlockError, type BlockMigration, type BlockNavItem, type BlockPrivacy, type BlockRoute, type BlockSettingsRow, CONTENT_PACK_FIELD_TARGETS, type ContentPackDef, ContentPackError, type ContentPackFieldDefinition, type ContentPackFieldTarget, type ContentPackForm, type ContentPackMetricTemplate, type ContentPackRoadmapTemplate, type ContentPackSessionType, type Contributed, type EnabledBlocks, FeaturePlatform, type ResolveBlocksOptions, type ResolvedBlocks, contentPackBlocks, contentPackProblems, defineBlock, defineContentPack, resolveBlocks };
463
+ export { type BlockContributions, type BlockDataUse, type BlockDef, BlockError, type BlockMigration, type BlockNavItem, type BlockPrivacy, type BlockRoute, type BlockSettingsRow, CONTENT_PACK_FIELD_TARGETS, type ContentPackCheckOptions, type ContentPackDef, ContentPackError, type ContentPackFieldDefinition, type ContentPackFieldTarget, type ContentPackForm, type ContentPackMetricTemplate, type ContentPackRoadmapTemplate, type ContentPackSectionValidator, type ContentPackSections, type ContentPackSessionType, type Contributed, type EnabledBlocks, FeaturePlatform, type ResolveBlocksOptions, type ResolvedBlocks, contentPackBlocks, contentPackProblems, defineBlock, defineContentPack, resolveBlocks };
package/dist/blocks.js CHANGED
@@ -1,4 +1,4 @@
1
- export { BlockError, CONTENT_PACK_FIELD_TARGETS, ContentPackError, contentPackBlocks, contentPackProblems, defineBlock, defineContentPack, resolveBlocks } from './chunk-OBVR6AZR.js';
1
+ export { BlockError, CONTENT_PACK_FIELD_TARGETS, ContentPackError, contentPackBlocks, contentPackProblems, defineBlock, defineContentPack, resolveBlocks } from './chunk-O6KDWT3B.js';
2
2
  import './chunk-VYUX7VAX.js';
3
3
  export { FEATURE_PLATFORMS } from './chunk-B6WRD3WF.js';
4
4
  //# sourceMappingURL=blocks.js.map
@@ -12,7 +12,7 @@ ${problems.map((p) => ` - ${p}`).join("\n")}`);
12
12
  problems;
13
13
  };
14
14
  var ID = /^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$/;
15
- var CONTRIBUTION_KEYS = ["nav", "settings", "routes", "slots", "migrations", "skills", "privacy"];
15
+ var CONTRIBUTION_KEYS = ["nav", "settings", "routes", "slots", "migrations", "skills", "privacy", "contentSection"];
16
16
  function duplicates(values) {
17
17
  const seen = /* @__PURE__ */ new Set();
18
18
  const dup = /* @__PURE__ */ new Set();
@@ -151,13 +151,58 @@ function resolveBlocks(blocks, enabled, options = {}) {
151
151
  });
152
152
  }
153
153
 
154
- // src/content-packs.ts
154
+ // src/content-packs-legacy.ts
155
155
  var CONTENT_PACK_FIELD_TARGETS = {
156
156
  pursuits: "pursuits",
157
157
  work_items: "pursuits",
158
158
  metrics: "metrics",
159
159
  sessions: "sessions"
160
160
  };
161
+ var SECTION_BLOCK = { sessionTypes: "sessions", metricTemplates: "metrics", forms: "forms", roadmapTemplates: "roadmap" };
162
+ function legacyContentPackBlocks(pack) {
163
+ const needed = [];
164
+ for (const [section, block] of Object.entries(SECTION_BLOCK)) {
165
+ const items = pack[section];
166
+ if (items && items.length) needed.push(block);
167
+ }
168
+ for (const f of pack.fieldDefinitions ?? []) {
169
+ const block = CONTENT_PACK_FIELD_TARGETS[f.target];
170
+ if (block) needed.push(block);
171
+ }
172
+ return needed;
173
+ }
174
+ function legacyContentPackProblems(pack, at, keyProblems2) {
175
+ const problems = [
176
+ ...keyProblems2(`${at}.sessionTypes`, pack.sessionTypes),
177
+ ...keyProblems2(`${at}.metricTemplates`, pack.metricTemplates),
178
+ ...keyProblems2(`${at}.fieldDefinitions`, pack.fieldDefinitions),
179
+ ...keyProblems2(`${at}.forms`, pack.forms),
180
+ ...keyProblems2(`${at}.roadmapTemplates`, pack.roadmapTemplates)
181
+ ];
182
+ for (const s of pack.sessionTypes ?? []) {
183
+ problems.push(...keyProblems2(`${at}.sessionTypes.${s.key}.agenda`, s.agenda));
184
+ for (const item of s.agenda ?? []) {
185
+ if (!(typeof item.minutes === "number" && item.minutes > 0)) problems.push(`${at}.sessionTypes.${s.key}.agenda.${item.key}: minutes must be more than 0`);
186
+ }
187
+ }
188
+ for (const f of pack.fieldDefinitions ?? []) {
189
+ if (!Object.hasOwn(CONTENT_PACK_FIELD_TARGETS, f.target)) problems.push(`${at}.fieldDefinitions.${f.key}: target "${String(f.target)}" isn't one of ${Object.keys(CONTENT_PACK_FIELD_TARGETS).join(", ")}`);
190
+ if (typeof f.field?.type !== "string") problems.push(`${at}.fieldDefinitions.${f.key}: field needs a genesis-forms type`);
191
+ if (!["tenant", "app", "private"].includes(f.visibility)) problems.push(`${at}.fieldDefinitions.${f.key}: visibility must be tenant, app or private`);
192
+ }
193
+ for (const r of pack.roadmapTemplates ?? []) {
194
+ problems.push(...keyProblems2(`${at}.roadmapTemplates.${r.key}.items`, r.items));
195
+ const keys = new Set((r.items ?? []).map((i) => i.key));
196
+ for (const item of r.items ?? []) {
197
+ if (item.ref !== void 0 && (!keys.has(item.ref) || item.ref === item.key)) {
198
+ problems.push(`${at}.roadmapTemplates.${r.key}.items.${item.key}: ref "${item.ref}" isn't another item in this template`);
199
+ }
200
+ }
201
+ }
202
+ return problems;
203
+ }
204
+
205
+ // src/content-packs.ts
161
206
  var ContentPackError = class extends Error {
162
207
  constructor(problems) {
163
208
  super(`Invalid content pack:
@@ -170,26 +215,23 @@ ${problems.map((p) => ` - ${p}`).join("\n")}`);
170
215
  var KEBAB = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;
171
216
  var KEY = /^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$/;
172
217
  var SEMVER = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-[0-9A-Za-z.-]+)?(?:\+[0-9A-Za-z.-]+)?$/;
173
- var SECTION_BLOCK = { sessionTypes: "sessions", metricTemplates: "metrics", forms: "forms", roadmapTemplates: "roadmap" };
174
218
  function keyProblems(where, items) {
175
219
  const problems = [];
176
220
  const seen = /* @__PURE__ */ new Set();
177
221
  for (const [i, item] of (items ?? []).entries()) {
178
- if (typeof item?.key !== "string" || !KEY.test(item.key)) problems.push(`${where}[${i}].key: "${String(item?.key)}" is not a key (lowercase, dots, dashes or underscores)`);
179
- else if (seen.has(item.key)) problems.push(`${where}: the key "${item.key}" is used twice`);
180
- else seen.add(item.key);
222
+ const key = item?.key;
223
+ if (typeof key !== "string" || !KEY.test(key)) problems.push(`${where}[${i}].key: "${String(key)}" is not a key (lowercase, dots, dashes or underscores)`);
224
+ else if (seen.has(key)) problems.push(`${where}: the key "${key}" is used twice`);
225
+ else seen.add(key);
181
226
  }
182
227
  return problems;
183
228
  }
184
229
  function contentPackBlocks(pack) {
185
- const needed = /* @__PURE__ */ new Set();
186
- for (const [section, block] of Object.entries(SECTION_BLOCK)) {
187
- const items = pack[section];
188
- if (items && items.length) needed.add(block);
189
- }
190
- for (const f of pack.fieldDefinitions ?? []) {
191
- const block = CONTENT_PACK_FIELD_TARGETS[f.target];
192
- if (block) needed.add(block);
230
+ const needed = new Set(legacyContentPackBlocks(pack));
231
+ const sections = pack.sections;
232
+ const entries = sections && typeof sections === "object" && !Array.isArray(sections) ? Object.entries(sections) : [];
233
+ for (const [block, items] of entries) {
234
+ if (Array.isArray(items) && items.length) needed.add(block);
193
235
  }
194
236
  return [...needed].sort();
195
237
  }
@@ -198,7 +240,17 @@ function test(blocks) {
198
240
  const set = new Set(blocks);
199
241
  return (id) => set.has(id);
200
242
  }
201
- function contentPackProblems(pack, installed) {
243
+ function checkOptions(value) {
244
+ if (value === void 0) return {};
245
+ if (typeof value === "function") return { installed: value };
246
+ if (typeof value === "object" && value !== null) {
247
+ if (Symbol.iterator in value) return { installed: value };
248
+ return value;
249
+ }
250
+ throw new TypeError(`contentPackProblems: the second argument is the installed block ids (a list or a predicate) or options, not ${value === null ? "null" : typeof value}`);
251
+ }
252
+ function contentPackProblems(pack, installedOrOptions) {
253
+ const options = checkOptions(installedOrOptions);
202
254
  const at = `content pack ${typeof pack?.id === "string" ? pack.id : "?"}`;
203
255
  const problems = [];
204
256
  if (typeof pack?.id !== "string" || !KEBAB.test(pack.id)) problems.push(`${at}: id must be kebab-case`);
@@ -213,49 +265,51 @@ function contentPackProblems(pack, installed) {
213
265
  if (!KEY.test(label)) problems.push(`${at}: label key "${label}" is not a key`);
214
266
  if (typeof text !== "string" || !text.trim()) problems.push(`${at}: label "${label}" needs display text`);
215
267
  }
216
- problems.push(
217
- ...keyProblems(`${at}.sessionTypes`, pack.sessionTypes),
218
- ...keyProblems(`${at}.metricTemplates`, pack.metricTemplates),
219
- ...keyProblems(`${at}.fieldDefinitions`, pack.fieldDefinitions),
220
- ...keyProblems(`${at}.forms`, pack.forms),
221
- ...keyProblems(`${at}.roadmapTemplates`, pack.roadmapTemplates)
222
- );
223
- for (const s of pack.sessionTypes ?? []) {
224
- problems.push(...keyProblems(`${at}.sessionTypes.${s.key}.agenda`, s.agenda));
225
- for (const item of s.agenda ?? []) {
226
- if (!(typeof item.minutes === "number" && item.minutes > 0)) problems.push(`${at}.sessionTypes.${s.key}.agenda.${item.key}: minutes must be more than 0`);
227
- }
228
- }
229
- for (const f of pack.fieldDefinitions ?? []) {
230
- if (!Object.hasOwn(CONTENT_PACK_FIELD_TARGETS, f.target)) problems.push(`${at}.fieldDefinitions.${f.key}: target "${String(f.target)}" isn't one of ${Object.keys(CONTENT_PACK_FIELD_TARGETS).join(", ")}`);
231
- if (typeof f.field?.type !== "string") problems.push(`${at}.fieldDefinitions.${f.key}: field needs a genesis-forms type`);
232
- if (!["tenant", "app", "private"].includes(f.visibility)) problems.push(`${at}.fieldDefinitions.${f.key}: visibility must be tenant, app or private`);
268
+ const validators = /* @__PURE__ */ Object.create(null);
269
+ for (const block of options.blocks ?? []) {
270
+ const validate = block.contributes?.contentSection;
271
+ if (typeof validate === "function") validators[block.id] = validate;
233
272
  }
234
- for (const r of pack.roadmapTemplates ?? []) {
235
- problems.push(...keyProblems(`${at}.roadmapTemplates.${r.key}.items`, r.items));
236
- const keys = new Set((r.items ?? []).map((i) => i.key));
237
- for (const item of r.items ?? []) {
238
- if (item.ref !== void 0 && (!keys.has(item.ref) || item.ref === item.key)) {
239
- problems.push(`${at}.roadmapTemplates.${r.key}.items.${item.key}: ref "${item.ref}" isn't another item in this template`);
240
- }
273
+ for (const [block, validate] of Object.entries(options.validators ?? {})) if (typeof validate === "function") validators[block] = validate;
274
+ const sections = pack.sections;
275
+ const sectionsOk = sections === void 0 || typeof sections === "object" && sections !== null && !Array.isArray(sections);
276
+ if (!sectionsOk) problems.push(`${at}: sections must be an object keyed by block id`);
277
+ for (const [block, items] of sectionsOk ? Object.entries(sections ?? {}) : []) {
278
+ const where = `${at}.sections.${block}`;
279
+ if (!KEY.test(block)) problems.push(`${where}: "${block}" is not a block id`);
280
+ if (!Array.isArray(items)) {
281
+ problems.push(`${where}: must be a list of items`);
282
+ continue;
283
+ }
284
+ problems.push(...keyProblems(where, items));
285
+ const validate = validators[block];
286
+ if (!validate) continue;
287
+ let found;
288
+ try {
289
+ found = validate(items);
290
+ } catch (error) {
291
+ problems.push(`${where}: the block's validator failed: ${error instanceof Error ? error.message : String(error)}`);
292
+ continue;
241
293
  }
294
+ for (const problem of Array.isArray(found) ? found : []) problems.push(`${where}: ${problem}`);
242
295
  }
296
+ problems.push(...legacyContentPackProblems(pack, at, keyProblems));
243
297
  const declared = new Set(pack.requires);
244
298
  for (const block of contentPackBlocks(pack)) {
245
299
  if (!declared.has(block)) problems.push(`${at}: fills the ${block} block but doesn't list it in requires`);
246
300
  }
247
- if (installed !== void 0) {
248
- const has = test(installed);
301
+ if (options.installed !== void 0) {
302
+ const has = test(options.installed);
249
303
  for (const block of pack.requires) if (!has(block)) problems.push(`${at}: needs the ${block} block, which isn't installed`);
250
304
  }
251
305
  return problems;
252
306
  }
253
- function defineContentPack(pack) {
254
- const problems = contentPackProblems(pack);
307
+ function defineContentPack(pack, options) {
308
+ const problems = contentPackProblems(pack, { blocks: options?.blocks, validators: options?.validators });
255
309
  if (problems.length) throw new ContentPackError(problems);
256
310
  return pack;
257
311
  }
258
312
 
259
313
  export { BlockError, CONTENT_PACK_FIELD_TARGETS, ContentPackError, contentPackBlocks, contentPackProblems, defineBlock, defineContentPack, resolveBlocks };
260
- //# sourceMappingURL=chunk-OBVR6AZR.js.map
261
- //# sourceMappingURL=chunk-OBVR6AZR.js.map
314
+ //# sourceMappingURL=chunk-O6KDWT3B.js.map
315
+ //# sourceMappingURL=chunk-O6KDWT3B.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/blocks.ts","../src/content-packs-legacy.ts","../src/content-packs.ts"],"names":["keyProblems"],"mappings":";;;;AA+JO,IAAM,UAAA,GAAN,cAAyB,KAAA,CAAM;AAAA,EACpC,YAAqB,QAAA,EAAoB;AACvC,IAAA,KAAA,CAAM,CAAA;AAAA,EAAoB,QAAA,CAAS,GAAA,CAAI,CAAC,CAAA,KAAM,CAAA,IAAA,EAAO,CAAC,CAAA,CAAE,CAAA,CAAE,IAAA,CAAK,IAAI,CAAC,CAAA,CAAE,CAAA;AADnD,IAAA,IAAA,CAAA,QAAA,GAAA,QAAA;AAEnB,IAAA,IAAA,CAAK,IAAA,GAA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vG,EAAA,IAAI,QAAA,CAAS,MAAA,EAAQ,MAAM,IAAI,iBAAiB,QAAQ,CAAA;AACxD,EAAA,OAAO,IAAA;AACT","file":"chunk-O6KDWT3B.js","sourcesContent":["/**\n * Blocks: a feature an app adds whole (account, push, observability, support,\n * updates), declared once with what it needs and what it contributes. The app\n * shell, the navigation tree and Settings consume contributions by FeatureId;\n * the app still owns where they go.\n *\n * Platform-neutral and free of zod, so it ships to phones:\n * `@marktiderman/genesis-features/blocks` (also re-exported from the root).\n */\nimport { cycleProblems, dependencyOrder, requirementProblem } from \"./graph\";\nimport { FEATURE_PLATFORMS, type FeaturePlatform } from \"./platforms\";\nimport type { ContentPackSectionValidator } from \"./content-packs\";\n\n/**\n * A navigation entry a block offers. The app's nav tree places it (by the\n * block's FeatureId and this id); a block never decides where it goes.\n * `id`, `label` and `path` match genesis-core's `NavigationNode`.\n *\n * @stability Beta\n */\nexport interface BlockNavItem {\n /** Unique across every enabled block. */\n id: string;\n label: string;\n path: string;\n /** An icon name the app's icon set knows. */\n icon?: string;\n /** Lower first. Default 0. */\n order?: number;\n}\n\n/**\n * A Settings row a block offers, placed in the section with id `section`\n * (`\"account\"`, `\"about\"`, or one of the app's own; an unknown id becomes a\n * new section at the end).\n *\n * @stability Beta\n */\nexport interface BlockSettingsRow {\n /** Unique across every enabled block. */\n id: string;\n section: string;\n title: string;\n subtitle?: string;\n /**\n * A hook giving a subtitle that changes (a version, a count). It is called\n * on every render of the Settings screen, in block order, so the set of\n * blocks must not change while the app runs (shells read them once).\n */\n useSubtitle?: () => string | null | undefined;\n /** Where tapping the row goes, as a path. */\n href?: string;\n /** Lower first within its section. Default 0. */\n order?: number;\n testID?: string;\n}\n\n/**\n * A screen a block's feature needs the app to route to. On file-based\n * routers the app owns the route file; this is the declaration a check (or\n * a deep-link allowlist) reads.\n *\n * @stability Beta\n */\nexport interface BlockRoute {\n path: string;\n /** What the screen is for, in a few words. */\n description?: string;\n /** `true` when only a signed-in person can open it. */\n signedIn?: boolean;\n}\n\n/**\n * A SQL migration a block needs, shipped in a package: copy it into the\n * app's `supabase/migrations/` under a timestamped name.\n *\n * @stability Beta\n */\nexport interface BlockMigration {\n /** The npm package that ships it, e.g. `@marktiderman/genesis-supabase`. */\n package: string;\n /** Its path in the package, e.g. `migrations/0002_genesis_app_release_policy.sql`. */\n file: string;\n /** Its pgTAP test in the package, if any. */\n test?: string;\n}\n\n/**\n * One kind of data a block collects, for the App Store privacy label and the\n * Play data safety form.\n *\n * @stability Beta\n */\nexport interface BlockDataUse {\n /** What, in the stores' words: `\"email address\"`, `\"user id\"`, `\"crash data\"`. */\n type: string;\n /** Why: `\"app functionality\"`, `\"analytics\"`, … */\n purposes: readonly string[];\n /** Tied to the person's identity. */\n linked: boolean;\n /** Used to track the person across other companies' apps. */\n tracking: boolean;\n}\n\n/** What a block means for privacy. @stability Beta */\nexport interface BlockPrivacy {\n collects?: readonly BlockDataUse[];\n /** Anything a reviewer or a privacy policy should say, one sentence each. */\n notes?: readonly string[];\n}\n\n/**\n * What a block adds to an app. Every key is optional. `S` is what a slot is\n * filled with on the consuming platform (a React component on native and web).\n *\n * @stability Beta\n */\nexport interface BlockContributions<S = unknown> {\n nav?: readonly BlockNavItem[];\n settings?: readonly BlockSettingsRow[];\n routes?: readonly BlockRoute[];\n /**\n * Fills for the host shell's slots, by slot name (e.g. `fatal` on\n * `GenesisNativeApp`). The app's own `slots` always win over a block's.\n */\n slots?: Readonly<Record<string, S>>;\n migrations?: readonly BlockMigration[];\n /** Agent skills that come with it: repo or package paths to a `SKILL.md`. */\n skills?: readonly string[];\n privacy?: BlockPrivacy;\n /**\n * Checks this block's section of a content pack (`sections[<block id>]`):\n * returns every problem with its items. `defineContentPack` and\n * `contentPackProblems` run it when given the block.\n */\n contentSection?: ContentPackSectionValidator;\n}\n\n/**\n * One block. `id` is the block's FeatureId: the same id as its entry in the\n * feature registry.\n *\n * @stability Beta\n */\nexport interface BlockDef<Id extends string = string, S = unknown> {\n readonly id: Id;\n /**\n * What must be on with it: other blocks' ids, or features the app owns that\n * aren't blocks. A requirement that is a block must be enabled (and on this\n * platform); one that isn't a block must be listed in `enabled`. A\n * requirement that is neither is an error, so a forgotten block is loud.\n */\n readonly requires?: readonly string[];\n readonly contributes?: BlockContributions<S>;\n /** Where it runs. Default every platform. */\n readonly platforms?: readonly FeaturePlatform[];\n}\n\n/** Thrown by {@link defineBlock} and {@link resolveBlocks}; lists every problem at once. @stability Beta */\nexport class BlockError extends Error {\n constructor(readonly problems: string[]) {\n super(`Invalid blocks:\\n${problems.map((p) => ` - ${p}`).join(\"\\n\")}`);\n this.name = \"BlockError\";\n }\n}\n\n// The feature registry's id rule (model.ts), repeated so this file stays free of zod.\nconst ID = /^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$/;\n\nconst CONTRIBUTION_KEYS = [\"nav\", \"settings\", \"routes\", \"slots\", \"migrations\", \"skills\", \"privacy\", \"contentSection\"] as const;\n\nfunction duplicates(values: readonly string[]): string[] {\n const seen = new Set<string>();\n const dup = new Set<string>();\n for (const v of values) (seen.has(v) ? dup : seen).add(v);\n return [...dup];\n}\n\nfunction blockProblems(block: BlockDef<string, unknown>): string[] {\n const { id } = block;\n const problems: string[] = [];\n if (typeof id !== \"string\" || !ID.test(id)) problems.push(`${String(id)}: a block id is a feature id: lowercase letters and digits, joined by -, _ or .`);\n for (const req of block.requires ?? []) {\n if (req === id) problems.push(`${id}.requires: a block can't require itself`);\n else if (!ID.test(req)) problems.push(`${id}.requires: \"${req}\" is not a feature id`);\n }\n for (const p of block.platforms ?? []) {\n if (!(FEATURE_PLATFORMS as readonly string[]).includes(p)) problems.push(`${id}.platforms: \"${p}\" is not one of ${FEATURE_PLATFORMS.join(\", \")}`);\n }\n if (block.platforms && block.platforms.length === 0) problems.push(`${id}.platforms: an empty list runs nowhere; leave it out for every platform`);\n const c = block.contributes ?? {};\n for (const key of Object.keys(c)) {\n if (!(CONTRIBUTION_KEYS as readonly string[]).includes(key)) problems.push(`${id}.contributes.${key}: not a contribution (${CONTRIBUTION_KEYS.join(\", \")})`);\n }\n for (const d of duplicates((c.nav ?? []).map((n) => n.id))) problems.push(`${id}.contributes.nav: \"${d}\" appears twice`);\n for (const d of duplicates((c.settings ?? []).map((r) => r.id))) problems.push(`${id}.contributes.settings: \"${d}\" appears twice`);\n for (const d of duplicates((c.routes ?? []).map((r) => r.path))) problems.push(`${id}.contributes.routes: \"${d}\" appears twice`);\n for (const n of c.nav ?? []) if (!n.id || !n.label || !n.path) problems.push(`${id}.contributes.nav: every entry needs an id, a label and a path`);\n for (const r of c.settings ?? []) if (!r.id || !r.section || !r.title) problems.push(`${id}.contributes.settings: every row needs an id, a section and a title`);\n for (const m of c.migrations ?? []) if (!m.package || !m.file) problems.push(`${id}.contributes.migrations: every migration needs a package and a file`);\n return problems;\n}\n\n/**\n * Declare a block. Validates it (id, requirements, platforms, contribution\n * keys and duplicate ids within the block) and returns it frozen, so a\n * typo fails where the block is written rather than where it is used:\n *\n * ```ts\n * export const supportBlock = defineBlock({\n * id: \"support\",\n * requires: [\"account\"],\n * platforms: [\"web\", \"native\"],\n * contributes: {\n * settings: [{ id: \"contact-support\", section: \"about\", title: \"Contact support\", href: \"/support\" }],\n * routes: [{ path: \"/support\", signedIn: true }],\n * migrations: [{ package: \"@acme/support\", file: \"migrations/0001_support.sql\" }],\n * },\n * });\n * ```\n *\n * To check `id` against the app's registry at compile time, give the\n * FeatureId: `defineBlock<FeatureId>({ … })`. `S` is what slots are filled\n * with, inferred from `contributes.slots` (a component on native and web).\n *\n * @stability Beta\n */\nexport function defineBlock<const Id extends string, S = never>(block: BlockDef<Id, S>): BlockDef<Id, S> {\n const problems = blockProblems(block as BlockDef<string, unknown>);\n if (problems.length) throw new BlockError(problems);\n return Object.freeze(block);\n}\n\n/** Which blocks are on: ids, a predicate, or (left out) every block given. @stability Beta */\nexport type EnabledBlocks = Iterable<string> | ((id: string) => boolean);\n\n/** @stability Beta */\nexport interface ResolveBlocksOptions {\n /** Keep only blocks that run here. A required block that doesn't is a missing requirement. */\n platform?: FeaturePlatform;\n /**\n * The app's feature registry (`features` from `defineFeatures`): every block\n * id and requirement must be one of its ids.\n */\n features?: Readonly<Record<string, unknown>>;\n /**\n * A block whose requirement is off: `throw` (default: a set-up mistake, found\n * at launch) or `drop` it, and every block needing it, listing each in\n * `dropped` (for switches that change at run time, such as a tenant turning\n * a feature off).\n */\n missing?: \"throw\" | \"drop\";\n /**\n * The host's slot names (e.g. `GenesisNativeApp`'s). A block filling any\n * other slot is an error, so a typo doesn't fill nothing silently.\n */\n slots?: readonly string[];\n}\n\n/** A contribution with the FeatureId of the block it came from. @stability Beta */\nexport type Contributed<T, Id extends string = string> = T & { readonly feature: Id };\n\n/** @stability Beta */\nexport interface ResolvedBlocks<B extends BlockDef<string, unknown> = BlockDef> {\n /** The enabled blocks, in dependency order (a block after what it requires). */\n readonly blocks: readonly B[];\n readonly ids: ReadonlySet<B[\"id\"]>;\n has(id: string): boolean;\n /** One block's contributions, or `undefined` when it isn't on. */\n contributionsOf(id: B[\"id\"]): NonNullable<B[\"contributes\"]> | undefined;\n /** Nav entries by `order`, then block order. Place them in the app's tree by `feature` and `id`. */\n readonly nav: readonly Contributed<BlockNavItem, B[\"id\"]>[];\n /** Settings rows by `order`, then block order. */\n readonly settings: readonly Contributed<BlockSettingsRow, B[\"id\"]>[];\n readonly routes: readonly Contributed<BlockRoute, B[\"id\"]>[];\n /** Slot fills by slot name. Two blocks filling one slot is an error. */\n readonly slots: Readonly<Record<string, SlotOf<B>>>;\n readonly migrations: readonly Contributed<BlockMigration, B[\"id\"]>[];\n readonly skills: readonly Contributed<{ path: string }, B[\"id\"]>[];\n readonly privacy: readonly Contributed<BlockPrivacy, B[\"id\"]>[];\n /** With `missing: \"drop\"`: blocks left out, and the requirements that were off. */\n readonly dropped: readonly { id: B[\"id\"]; missing: readonly string[] }[];\n}\n\ntype SlotOf<B> = B extends BlockDef<string, infer S> ? S : never;\n\nfunction enabledPredicate(enabled: EnabledBlocks | undefined): ((id: string) => boolean) | undefined {\n if (enabled === undefined) return undefined;\n if (typeof enabled === \"function\") return enabled;\n const set = new Set(enabled);\n return (id) => set.has(id);\n}\n\nconst byOrder = <T extends { order?: number }>(items: { item: T; at: number }[]) =>\n items.sort((a, b) => (a.item.order ?? 0) - (b.item.order ?? 0) || a.at - b.at).map((x) => x.item);\n\n/**\n * The blocks that are on, checked and merged:\n *\n * - every block is valid ({@link defineBlock}'s checks, for blocks built by hand) and its id is unique;\n * - `requires` has no cycles, and with `features`, names real features;\n * - every enabled block's requirements are on (see {@link ResolveBlocksOptions.missing});\n * - no two enabled blocks contribute the same nav id, settings row id, route path or slot.\n *\n * `enabled` left out means every block given is on (and no app feature that\n * isn't a block). Throws a {@link BlockError} listing every problem at once.\n *\n * @stability Beta\n */\nexport function resolveBlocks<B extends BlockDef<string, unknown>>(\n blocks: readonly B[],\n enabled?: EnabledBlocks,\n options: ResolveBlocksOptions = {},\n): ResolvedBlocks<B> {\n const { platform, features, missing = \"throw\", slots: slotNames } = options;\n const problems: string[] = [];\n const byId = new Map<string, B>();\n for (const block of blocks) {\n problems.push(...blockProblems(block));\n if (byId.has(block.id)) problems.push(`${block.id}: two blocks have this id`);\n else byId.set(block.id, block);\n }\n const isFeature = features ? (id: string) => Object.hasOwn(features, id) : undefined;\n if (isFeature) for (const id of byId.keys()) if (!isFeature(id)) problems.push(`${id}: not a feature in the registry`);\n const graph = Object.fromEntries([...byId].map(([id, b]) => [id, { requires: b.requires }]));\n // Self-requirements are already reported by blockProblems; here, unknown ids and cycles.\n const known = { noun: \"block\", isKnown: (req: string) => byId.has(req) || !isFeature || isFeature(req) };\n for (const [id, node] of Object.entries(graph)) {\n for (const req of node.requires ?? []) {\n if (req !== id && requirementProblem(graph, id, req, known)) problems.push(`${id}.requires: \"${req}\" is neither a block nor a feature in the registry`);\n }\n }\n problems.push(...cycleProblems(graph));\n if (problems.length) throw new BlockError(problems);\n\n const isOn = enabledPredicate(enabled);\n const runsHere = (b: B) => !platform || !b.platforms || b.platforms.includes(platform);\n const active = new Set<string>();\n for (const [id, b] of byId) if ((!isOn || isOn(id)) && runsHere(b)) active.add(id);\n\n // In dependency order, so dropping a block also drops what needs it.\n const order = dependencyOrder(graph);\n const dropped: { id: B[\"id\"]; missing: string[] }[] = [];\n for (const id of order) {\n if (!active.has(id)) continue;\n const off = (byId.get(id)!.requires ?? []).filter((req) => {\n if (byId.has(req)) return !active.has(req);\n return !isOn || !isOn(req);\n });\n if (!off.length) continue;\n if (missing === \"drop\") {\n active.delete(id);\n dropped.push({ id, missing: off });\n continue;\n }\n for (const req of off) {\n const why = !byId.has(req)\n ? isOn\n ? \"is not enabled\"\n : \"is not one of the blocks given (pass it, or list the app feature in enabled)\"\n : !runsHere(byId.get(req)!)\n ? `doesn't run on ${platform}`\n : \"is off\";\n problems.push(`${id}.requires: \"${req}\" ${why}; turn it on or turn ${id} off`);\n }\n }\n if (problems.length) throw new BlockError(problems);\n\n const on = order.filter((id) => active.has(id)).map((id) => byId.get(id)!);\n const nav: { item: Contributed<BlockNavItem, B[\"id\"]>; at: number }[] = [];\n const settings: { item: Contributed<BlockSettingsRow, B[\"id\"]>; at: number }[] = [];\n const routes: Contributed<BlockRoute, B[\"id\"]>[] = [];\n const migrations: Contributed<BlockMigration, B[\"id\"]>[] = [];\n const skills: Contributed<{ path: string }, B[\"id\"]>[] = [];\n const privacy: Contributed<BlockPrivacy, B[\"id\"]>[] = [];\n const slots: Record<string, SlotOf<B>> = {};\n const owner = { nav: new Map<string, string>(), settings: new Map<string, string>(), routes: new Map<string, string>(), slots: new Map<string, string>() };\n const claim = (kind: keyof typeof owner, key: string, id: string, what: string) => {\n const first = owner[kind].get(key);\n if (first !== undefined) problems.push(`${id}.contributes.${kind}: ${what} \"${key}\" is already contributed by ${first}`);\n else owner[kind].set(key, id);\n return first === undefined;\n };\n on.forEach((block, at) => {\n const feature = block.id;\n const c = block.contributes ?? {};\n for (const n of c.nav ?? []) if (claim(\"nav\", n.id, feature, \"the nav entry\")) nav.push({ item: { ...n, feature }, at });\n for (const r of c.settings ?? []) if (claim(\"settings\", r.id, feature, \"the settings row\")) settings.push({ item: { ...r, feature }, at });\n for (const r of c.routes ?? []) if (claim(\"routes\", r.path, feature, \"the route\")) routes.push({ ...r, feature });\n for (const [name, fill] of Object.entries(c.slots ?? {})) {\n if (slotNames && !slotNames.includes(name)) {\n problems.push(`${feature}.contributes.slots: \"${name}\" is not a slot here (${slotNames.join(\", \")})`);\n continue;\n }\n if (claim(\"slots\", name, feature, \"the slot\")) slots[name] = fill as SlotOf<B>;\n }\n for (const m of c.migrations ?? []) migrations.push({ ...m, feature });\n for (const path of c.skills ?? []) skills.push({ path, feature });\n if (c.privacy) privacy.push({ ...c.privacy, feature });\n });\n if (problems.length) throw new BlockError(problems);\n\n const ids = new Set(on.map((b) => b.id)) as ReadonlySet<B[\"id\"]>;\n return Object.freeze({\n blocks: Object.freeze(on),\n ids,\n has: (id: string) => ids.has(id as B[\"id\"]),\n contributionsOf: (id: B[\"id\"]) => (ids.has(id) ? ((byId.get(id)!.contributes ?? {}) as NonNullable<B[\"contributes\"]>) : undefined),\n nav: Object.freeze(byOrder(nav)),\n settings: Object.freeze(byOrder(settings)),\n routes: Object.freeze(routes),\n slots: Object.freeze(slots),\n migrations: Object.freeze(migrations),\n skills: Object.freeze(skills),\n privacy: Object.freeze(privacy),\n dropped: Object.freeze(dropped),\n });\n}\n","/**\n * The typed sections content packs had before `sections`: session types,\n * metric templates, custom fields, forms and roadmap templates, each tied to a\n * block an app owns. Kept, and still checked as before, so packs written\n * against them keep working. New packs put their data in `sections`, keyed by\n * block id, and the block checks it.\n *\n * Everything here is deprecated and goes in the next major.\n */\nimport type { ContentPackDef } from \"./content-packs\";\n\n/**\n * A content pack's settings for one session type, with its agenda.\n * @deprecated Put session types in `sections` under the block that owns them, checked by that block's validator.\n * @stability Beta\n */\nexport interface ContentPackSessionType {\n key: string;\n kind: string;\n name: string;\n description?: string;\n defaultMinutes?: number;\n agenda: readonly { key: string; title: string; minutes: number }[];\n}\n\n/**\n * A metric to start from.\n * @deprecated Put metric templates in `sections` under the block that owns them, checked by that block's validator.\n * @stability Beta\n */\nexport interface ContentPackMetricTemplate {\n key: string;\n name: string;\n unitType: string;\n unit?: string;\n cadence: string;\n goalDirection: string;\n goalValue?: number;\n goalMax?: number;\n measureKind?: string;\n rollup?: string;\n}\n\n/**\n * Where a custom field lives, and the block that owns that table.\n * @deprecated Custom fields belong in `sections` under the block that owns their table.\n * @stability Beta\n */\nexport const CONTENT_PACK_FIELD_TARGETS = {\n pursuits: \"pursuits\",\n work_items: \"pursuits\",\n metrics: \"metrics\",\n sessions: \"sessions\",\n} as const;\n\n/**\n * @deprecated See {@link CONTENT_PACK_FIELD_TARGETS}.\n * @stability Beta\n */\nexport type ContentPackFieldTarget = keyof typeof CONTENT_PACK_FIELD_TARGETS;\n\n/**\n * A custom field: a genesis-forms serializable field, on one of the work tables.\n * @deprecated Put field definitions in `sections` under the block that owns their table.\n * @stability Beta\n */\nexport interface ContentPackFieldDefinition {\n key: string;\n target: ContentPackFieldTarget;\n label: string;\n /** A genesis-forms serializable field: type, options, validation. */\n field: { readonly type: string; readonly [key: string]: unknown };\n required?: boolean;\n visibility: \"tenant\" | \"app\" | \"private\";\n}\n\n/**\n * A worksheet, assessment or form: a genesis-forms definition.\n * @deprecated Put forms in `sections` under the block that owns them.\n * @stability Beta\n */\nexport interface ContentPackForm {\n key: string;\n kind: \"worksheet\" | \"assessment\" | \"form\";\n title: string;\n definition: { readonly [key: string]: unknown };\n scoring?: unknown;\n}\n\n/**\n * A roadmap to start from: items that release by a rule, linked to each other by key.\n * @deprecated Put roadmap templates in `sections` under the block that owns them, checked by that block's validator.\n * @stability Beta\n */\nexport interface ContentPackRoadmapTemplate {\n key: string;\n name: string;\n items: readonly {\n key: string;\n kind: string;\n title: string;\n /** Another item's key in this template. */\n ref?: string;\n release: { rule: string; afterDays?: number; anchor?: string };\n }[];\n}\n\n/** The deprecated typed sections, as optional fields of a pack. */\nexport interface LegacyContentPackSections {\n /** @deprecated Use `sections`. */\n sessionTypes?: readonly ContentPackSessionType[];\n /** @deprecated Use `sections`. */\n metricTemplates?: readonly ContentPackMetricTemplate[];\n /** @deprecated Use `sections`. */\n fieldDefinitions?: readonly ContentPackFieldDefinition[];\n /** @deprecated Use `sections`. */\n forms?: readonly ContentPackForm[];\n /** @deprecated Use `sections`. */\n roadmapTemplates?: readonly ContentPackRoadmapTemplate[];\n}\n\n/** The block each typed section fills. */\nconst SECTION_BLOCK = { sessionTypes: \"sessions\", metricTemplates: \"metrics\", forms: \"forms\", roadmapTemplates: \"roadmap\" } as const;\n\n/** The blocks a pack's typed sections need. */\nexport function legacyContentPackBlocks(pack: ContentPackDef): string[] {\n const needed: string[] = [];\n for (const [section, block] of Object.entries(SECTION_BLOCK)) {\n const items = pack[section as keyof typeof SECTION_BLOCK];\n if (items && items.length) needed.push(block);\n }\n for (const f of pack.fieldDefinitions ?? []) {\n const block = CONTENT_PACK_FIELD_TARGETS[f.target];\n if (block) needed.push(block);\n }\n return needed;\n}\n\n/** Every problem with a pack's typed sections, the checks they always had. */\nexport function legacyContentPackProblems(\n pack: ContentPackDef,\n at: string,\n keyProblems: (where: string, items: readonly unknown[] | undefined) => string[],\n): string[] {\n const problems: string[] = [\n ...keyProblems(`${at}.sessionTypes`, pack.sessionTypes),\n ...keyProblems(`${at}.metricTemplates`, pack.metricTemplates),\n ...keyProblems(`${at}.fieldDefinitions`, pack.fieldDefinitions),\n ...keyProblems(`${at}.forms`, pack.forms),\n ...keyProblems(`${at}.roadmapTemplates`, pack.roadmapTemplates),\n ];\n for (const s of pack.sessionTypes ?? []) {\n problems.push(...keyProblems(`${at}.sessionTypes.${s.key}.agenda`, s.agenda));\n for (const item of s.agenda ?? []) {\n if (!(typeof item.minutes === \"number\" && item.minutes > 0)) problems.push(`${at}.sessionTypes.${s.key}.agenda.${item.key}: minutes must be more than 0`);\n }\n }\n for (const f of pack.fieldDefinitions ?? []) {\n if (!Object.hasOwn(CONTENT_PACK_FIELD_TARGETS, f.target)) problems.push(`${at}.fieldDefinitions.${f.key}: target \"${String(f.target)}\" isn't one of ${Object.keys(CONTENT_PACK_FIELD_TARGETS).join(\", \")}`);\n if (typeof f.field?.type !== \"string\") problems.push(`${at}.fieldDefinitions.${f.key}: field needs a genesis-forms type`);\n if (![\"tenant\", \"app\", \"private\"].includes(f.visibility)) problems.push(`${at}.fieldDefinitions.${f.key}: visibility must be tenant, app or private`);\n }\n for (const r of pack.roadmapTemplates ?? []) {\n problems.push(...keyProblems(`${at}.roadmapTemplates.${r.key}.items`, r.items));\n const keys = new Set((r.items ?? []).map((i) => i.key));\n for (const item of r.items ?? []) {\n if (item.ref !== undefined && (!keys.has(item.ref) || item.ref === item.key)) {\n problems.push(`${at}.roadmapTemplates.${r.key}.items.${item.key}: ref \"${item.ref}\" isn't another item in this template`);\n }\n }\n }\n return problems;\n}\n","/**\n * Content packs: versioned data that fills installed blocks. A pack is code,\n * reviewed like any other: the publishing package exports it, and an installer\n * copies it into a tenant's editable rows, keeping each row's source (pack,\n * version, key) so an update can tell what a person changed.\n *\n * A pack's `sections` are keyed by the block that owns them, and each holds\n * that block's items. Genesis checks what every pack shares (id, version,\n * publisher, requires, labels, and a unique `key` on every item); what an item\n * holds is the block's business, checked by the validator the block registers\n * (`contributes.contentSection` on `defineBlock`, or a `validators` map).\n *\n * `defineContentPack` checks a pack's shape; `contentPackProblems` with the\n * installed blocks also checks that every block it fills is there. Keys, not\n * ids, link things together, and stay the same across versions.\n *\n * No zod here: packs ship to phones with `/blocks`.\n */\nimport type { BlockDef, EnabledBlocks } from \"./blocks\";\nimport {\n legacyContentPackBlocks,\n legacyContentPackProblems,\n type LegacyContentPackSections,\n} from \"./content-packs-legacy\";\n\nexport {\n CONTENT_PACK_FIELD_TARGETS,\n type ContentPackFieldDefinition,\n type ContentPackFieldTarget,\n type ContentPackForm,\n type ContentPackMetricTemplate,\n type ContentPackRoadmapTemplate,\n type ContentPackSessionType,\n} from \"./content-packs-legacy\";\n\n/**\n * Checks one section's items for the block that owns it, and returns every\n * problem (an empty list when they're fine). Messages are relative to the\n * section (\"weekly: minutes must be more than 0\"): the checker puts the pack\n * and section in front. A validator that throws is reported as a problem.\n *\n * @stability Beta\n */\nexport type ContentPackSectionValidator = (items: readonly unknown[]) => readonly string[];\n\n/** A pack's sections: block id → that block's items. @stability Beta */\nexport type ContentPackSections = Readonly<Record<string, readonly unknown[]>>;\n\n/** One content pack, as its publisher defines it. @stability Beta */\nexport interface ContentPackDef extends LegacyContentPackSections {\n /** Kebab-case, unique per publisher. */\n id: string;\n name: string;\n description?: string;\n /** Semver. Updates are additive. */\n version: string;\n /** The package that publishes it. */\n publisher: string;\n /** The block ids it fills; installing is refused unless every one is installed. */\n requires: readonly string[];\n /** Taxonomy: label key → display text, e.g. `\"project.phase\": \"Stage\"`. */\n labels?: Readonly<Record<string, string>>;\n /**\n * The data it fills, by block id. Every item has a `key`, unique in its\n * section and the same across versions; the rest is checked by the block's\n * validator.\n */\n sections?: ContentPackSections;\n}\n\n/** @stability Beta */\nexport interface ContentPackCheckOptions {\n /** The installed blocks: every block the pack requires must be one. */\n installed?: EnabledBlocks;\n /** Blocks whose `contributes.contentSection` checks their section's items. */\n blocks?: readonly BlockDef<string, unknown>[];\n /** Section validators by block id; these win over a block's own. */\n validators?: Readonly<Record<string, ContentPackSectionValidator>>;\n}\n/** Thrown by {@link defineContentPack}; lists every problem at once. @stability Beta */\nexport class ContentPackError extends Error {\n constructor(readonly problems: string[]) {\n super(`Invalid content pack:\\n${problems.map((p) => ` - ${p}`).join(\"\\n\")}`);\n this.name = \"ContentPackError\";\n }\n}\n\nconst KEBAB = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;\nconst KEY = /^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$/;\nconst SEMVER = /^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-[0-9A-Za-z.-]+)?(?:\\+[0-9A-Za-z.-]+)?$/;\n\nfunction keyProblems(where: string, items: readonly unknown[] | undefined): string[] {\n const problems: string[] = [];\n const seen = new Set<string>();\n for (const [i, item] of (items ?? []).entries()) {\n const key = (item as { key?: unknown } | null | undefined)?.key;\n if (typeof key !== \"string\" || !KEY.test(key)) problems.push(`${where}[${i}].key: \"${String(key)}\" is not a key (lowercase, dots, dashes or underscores)`);\n else if (seen.has(key)) problems.push(`${where}: the key \"${key}\" is used twice`);\n else seen.add(key);\n }\n return problems;\n}\n\n/** The block ids a pack's sections need, whatever it declares. @stability Beta */\nexport function contentPackBlocks(pack: ContentPackDef): string[] {\n const needed = new Set<string>(legacyContentPackBlocks(pack));\n const sections = pack.sections;\n const entries = sections && typeof sections === \"object\" && !Array.isArray(sections) ? Object.entries(sections) : [];\n for (const [block, items] of entries) {\n if (Array.isArray(items) && items.length) needed.add(block);\n }\n return [...needed].sort();\n}\n\nfunction test(blocks: EnabledBlocks): (id: string) => boolean {\n if (typeof blocks === \"function\") return blocks;\n const set = new Set(blocks);\n return (id) => set.has(id);\n}\n\n/** The second argument: the installed blocks (ids or a predicate), or options. Anything else is a caller's mistake. */\nfunction checkOptions(value: unknown): ContentPackCheckOptions {\n if (value === undefined) return {};\n if (typeof value === \"function\") return { installed: value as EnabledBlocks };\n if (typeof value === \"object\" && value !== null) {\n if (Symbol.iterator in value) return { installed: value as EnabledBlocks };\n return value as ContentPackCheckOptions;\n }\n throw new TypeError(`contentPackProblems: the second argument is the installed block ids (a list or a predicate) or options, not ${value === null ? \"null\" : typeof value}`);\n}\n\n/**\n * Every problem with a pack: its shape, each section's items (through the\n * validator its block registers, when given) and, given the installed blocks,\n * any block it fills that isn't installed. An empty list means it can be\n * installed. The second argument is the installed blocks, or options.\n *\n * @stability Beta\n */\nexport function contentPackProblems(pack: ContentPackDef, installedOrOptions?: EnabledBlocks | ContentPackCheckOptions): string[] {\n const options = checkOptions(installedOrOptions);\n const at = `content pack ${typeof pack?.id === \"string\" ? pack.id : \"?\"}`;\n const problems: string[] = [];\n if (typeof pack?.id !== \"string\" || !KEBAB.test(pack.id)) problems.push(`${at}: id must be kebab-case`);\n if (typeof pack?.name !== \"string\" || !pack.name.trim()) problems.push(`${at}: needs a name`);\n if (typeof pack?.version !== \"string\" || !SEMVER.test(pack.version)) problems.push(`${at}: version \"${String(pack?.version)}\" isn't semver`);\n if (typeof pack?.publisher !== \"string\" || !pack.publisher.trim()) problems.push(`${at}: needs a publisher (its package name)`);\n if (!Array.isArray(pack?.requires)) {\n problems.push(`${at}: requires must list the blocks it fills`);\n return problems;\n }\n for (const [label, text] of Object.entries(pack.labels ?? {})) {\n if (!KEY.test(label)) problems.push(`${at}: label key \"${label}\" is not a key`);\n if (typeof text !== \"string\" || !text.trim()) problems.push(`${at}: label \"${label}\" needs display text`);\n }\n // A null-prototype map: section keys come from the pack, so `constructor` must not find Object.\n const validators: Record<string, ContentPackSectionValidator> = Object.create(null);\n for (const block of options.blocks ?? []) {\n const validate = block.contributes?.contentSection;\n if (typeof validate === \"function\") validators[block.id] = validate;\n }\n for (const [block, validate] of Object.entries(options.validators ?? {})) if (typeof validate === \"function\") validators[block] = validate;\n const sections = pack.sections;\n const sectionsOk = sections === undefined || (typeof sections === \"object\" && sections !== null && !Array.isArray(sections));\n if (!sectionsOk) problems.push(`${at}: sections must be an object keyed by block id`);\n for (const [block, items] of sectionsOk ? Object.entries(sections ?? {}) : []) {\n const where = `${at}.sections.${block}`;\n if (!KEY.test(block)) problems.push(`${where}: \"${block}\" is not a block id`);\n if (!Array.isArray(items)) {\n problems.push(`${where}: must be a list of items`);\n continue;\n }\n problems.push(...keyProblems(where, items));\n const validate = validators[block];\n if (!validate) continue;\n let found: readonly string[] | undefined;\n try {\n found = validate(items);\n } catch (error) {\n problems.push(`${where}: the block's validator failed: ${error instanceof Error ? error.message : String(error)}`);\n continue;\n }\n for (const problem of Array.isArray(found) ? found : []) problems.push(`${where}: ${problem}`);\n }\n problems.push(...legacyContentPackProblems(pack, at, keyProblems));\n // Every block a section fills must be declared, and (when known) installed.\n const declared = new Set(pack.requires);\n for (const block of contentPackBlocks(pack)) {\n if (!declared.has(block)) problems.push(`${at}: fills the ${block} block but doesn't list it in requires`);\n }\n if (options.installed !== undefined) {\n const has = test(options.installed);\n for (const block of pack.requires) if (!has(block)) problems.push(`${at}: needs the ${block} block, which isn't installed`);\n }\n return problems;\n}\n\n/**\n * Declare a content pack: returns it unchanged, typed, after checking its\n * shape (throws a {@link ContentPackError} listing every problem). Give the\n * blocks it fills, or validators by block id, to check each section's items\n * too. Whether its blocks are installed is checked at install time with\n * {@link contentPackProblems}.\n *\n * ```ts\n * export const weeklyTeamRhythm = defineContentPack({\n * id: \"weekly-team-rhythm\", name: \"Weekly team rhythm\", version: \"1.0.0\",\n * publisher: \"@acme/content\", requires: [\"meetings\"],\n * labels: { \"project.phase\": \"Stage\" },\n * sections: { meetings: [{ key: \"weekly\", name: \"Weekly meeting\", minutes: 60 }] },\n * }, { blocks: [meetingsBlock] });\n * ```\n *\n * @stability Beta\n */\nexport function defineContentPack<const T extends ContentPackDef>(pack: T, options?: Omit<ContentPackCheckOptions, \"installed\">): T {\n const problems = contentPackProblems(pack, { blocks: options?.blocks, validators: options?.validators });\n if (problems.length) throw new ContentPackError(problems);\n return pack;\n}\n"]}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { F as Features, b as FeatureRecord, a as Flags } from './model-8dMGbgtM.js';
2
2
  export { c as FEATURE_HORIZONS, d as FEATURE_LAYERS, e as FeatureDef, f as FeatureHorizon, g as FeatureIdOf, h as FeatureLayer, i as FeatureLinks, j as FeatureMedia, k as FeatureRegistryError, l as FeatureVisibility, m as FindOptions, n as FlagDef, o as defineFeatures, p as defineFlags, q as expiredFlags, r as featureSchema, s as findFeatures, t as flagSchema, u as flagsForFeature, v as toRecords } from './model-8dMGbgtM.js';
3
- export { BlockContributions, BlockDataUse, BlockDef, BlockError, BlockMigration, BlockNavItem, BlockPrivacy, BlockRoute, BlockSettingsRow, CONTENT_PACK_FIELD_TARGETS, ContentPackDef, ContentPackError, ContentPackFieldDefinition, ContentPackFieldTarget, ContentPackForm, ContentPackMetricTemplate, ContentPackRoadmapTemplate, ContentPackSessionType, Contributed, EnabledBlocks, ResolveBlocksOptions, ResolvedBlocks, contentPackBlocks, contentPackProblems, defineBlock, defineContentPack, resolveBlocks } from './blocks.js';
3
+ export { BlockContributions, BlockDataUse, BlockDef, BlockError, BlockMigration, BlockNavItem, BlockPrivacy, BlockRoute, BlockSettingsRow, CONTENT_PACK_FIELD_TARGETS, ContentPackCheckOptions, ContentPackDef, ContentPackError, ContentPackFieldDefinition, ContentPackFieldTarget, ContentPackForm, ContentPackMetricTemplate, ContentPackRoadmapTemplate, ContentPackSectionValidator, ContentPackSections, ContentPackSessionType, Contributed, EnabledBlocks, ResolveBlocksOptions, ResolvedBlocks, contentPackBlocks, contentPackProblems, defineBlock, defineContentPack, resolveBlocks } from './blocks.js';
4
4
  export { F as FeatureOff, G as GateAnswer, b as GateContext, c as GateFeature, d as GateFlag, e as GateReason, f as GateRegistry, a as GateSnapshot, g as GateSnapshotOptions, I as IdSet, S as SHIPPED_STATUSES, h as featureOn, i as fromSnapshot, j as gateSnapshot, k as isSnapshotStale, r as requireFeature } from './gate-oYFzQKyb.js';
5
5
  export { a as FEATURE_PLATFORMS, F as FeaturePlatform } from './platforms-NR0liM8L.js';
6
6
  export { d as FEATURE_STATUSES, e as FLAG_KINDS, b as FeatureAccess, a as FeatureStatus, c as FlagKind, F as FlagValue } from './types-Bd766VxF.js';
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- export { BlockError, CONTENT_PACK_FIELD_TARGETS, ContentPackError, contentPackBlocks, contentPackProblems, defineBlock, defineContentPack, resolveBlocks } from './chunk-OBVR6AZR.js';
1
+ export { BlockError, CONTENT_PACK_FIELD_TARGETS, ContentPackError, contentPackBlocks, contentPackProblems, defineBlock, defineContentPack, resolveBlocks } from './chunk-O6KDWT3B.js';
2
2
  export { FeatureOff, SHIPPED_STATUSES, featureOn, fromSnapshot, gateSnapshot, isSnapshotStale, requireFeature } from './chunk-YTPGUU5F.js';
3
3
  export { AGENTS_BLOCK_END, AGENTS_BLOCK_START, BrokenBlockError, FEATURE_HORIZONS, FEATURE_LAYERS, FEATURE_STATUSES, FLAG_KINDS, FeatureRegistryError, MARKETING_BLOCK_END, MARKETING_BLOCK_START, OPENFEATURE_MANIFEST_SCHEMA, defineFeatures, defineFlags, expiredFlags, featureSchema, findFeatures, flagSchema, flagsForFeature, marketingRecords, readAgentsBlock, replaceAgentsBlock, toAgentsMarkdown, toJson, toMarketingMarkdown, toOpenFeatureManifest, toRecords, toSkillMarkdown } from './chunk-JMXJZT6O.js';
4
4
  export { cycleProblems, dependencyOrder, requirementProblem, requiresProblems } from './chunk-VYUX7VAX.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marktiderman/genesis-features",
3
- "version": "0.6.1",
3
+ "version": "0.7.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -69,9 +69,9 @@
69
69
  }
70
70
  },
71
71
  "devDependencies": {
72
- "@marktiderman/genesis-core": "^1.16.1",
73
- "@marktiderman/genesis-design-system": "^1.5.0",
74
- "@marktiderman/genesis-ui": "^2.20.0",
72
+ "@marktiderman/genesis-core": "^2.1.0",
73
+ "@marktiderman/genesis-design-system": "^1.5.1",
74
+ "@marktiderman/genesis-ui": "^2.23.0",
75
75
  "@testing-library/react": "^16.3.2",
76
76
  "@types/node": "^22.9.0",
77
77
  "@types/react": "^19.2.14",
@@ -86,6 +86,24 @@
86
86
  "vitest": "^4.1.12",
87
87
  "zod": "^4.4.3"
88
88
  },
89
+ "genesis": {
90
+ "doctor": {
91
+ "prefer": [
92
+ {
93
+ "id": "no-env-feature-switches",
94
+ "need": "turning a feature on or off",
95
+ "level": "warn",
96
+ "forbid": {
97
+ "pattern": "\\b(?:import\\.meta\\.env|process\\.env)\\.(?:VITE_|NEXT_PUBLIC_|EXPO_PUBLIC_)?(?:FEATURE|FF|ENABLE|FLAG)_[A-Z0-9_]+"
98
+ },
99
+ "use": "a feature in features.ts read with featureOn / useFeature, or a flag",
100
+ "import": "@marktiderman/genesis-features",
101
+ "docs": "https://github.com/marktiderman/genesis/blob/main/packages/features/README.md",
102
+ "why": "An environment switch needs a redeploy to change and isn't in the feature registry."
103
+ }
104
+ ]
105
+ }
106
+ },
89
107
  "scripts": {
90
108
  "build": "tsup && node ../../scripts/check-exports-resolve.mjs",
91
109
  "clean": "rm -rf dist",
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/blocks.ts","../src/content-packs.ts"],"names":[],"mappings":";;;;AAwJO,IAAM,UAAA,GAAN,cAAyB,KAAA,CAAM;AAAA,EACpC,YAAqB,QAAA,EAAoB;AACvC,IAAA,KAAA,CAAM,CAAA;AAAA,EAAoB,QAAA,CAAS,GAAA,CAAI,CAAC,CAAA,KAAM,CAAA,IAAA,EAAO,CAAC,CAAA,CAAE,CAAA,CAAE,IAAA,CAAK,IAAI,CAAC,CAAA,CAAE,CAAA;AADnD,IAAA,IAAA,CAAA,QAAA,GAAA,QAAA;AAEnB,IAAA,IAAA,CAAK,IAAA,GAAO,YAAA;AAAA,EACd;AAAA,EAHqB,QAAA;AAIvB;AAGA,IAAM,EAAA,GAAK,qCAAA;AAEX,IAAM,iBAAA,GAAoB,CAAC,KAAA,EAAO,UAAA,EAAY,UAAU,OAAA,EAAS,YAAA,EAAc,UAAU,SAAS,CAAA;AAElG,SAAS,WAAW,MAAA,EAAqC;AACvD,EAAA,MAAM,IAAA,uBAAW,GAAA,EAAY;AAC7B,EAAA,MAAM,GAAA,uBAAU,GAAA,EAAY;AAC5B,EAAA,KAAA,MAAW,CAAA,IAAK,MAAA,EAAQ,CAAC,IAAA,CAAK,GAAA,CAAI,CAAC,CAAA,GAAI,GAAA,GAAM,IAAA,EAAM,GAAA,CAAI,CAAC,CAA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feature an app adds whole (account, push, observability, support,\n * updates), declared once with what it needs and what it contributes. The app\n * shell, the navigation tree and Settings consume contributions by FeatureId;\n * the app still owns where they go.\n *\n * Platform-neutral and free of zod, so it ships to phones:\n * `@marktiderman/genesis-features/blocks` (also re-exported from the root).\n */\nimport { cycleProblems, dependencyOrder, requirementProblem } from \"./graph\";\nimport { FEATURE_PLATFORMS, type FeaturePlatform } from \"./platforms\";\n\n/**\n * A navigation entry a block offers. The app's nav tree places it (by the\n * block's FeatureId and this id); a block never decides where it goes.\n * `id`, `label` and `path` match genesis-core's `NavigationNode`.\n *\n * @stability Beta\n */\nexport interface BlockNavItem {\n /** Unique across every enabled block. */\n id: string;\n label: string;\n path: string;\n /** An icon name the app's icon set knows. */\n icon?: string;\n /** Lower first. Default 0. */\n order?: number;\n}\n\n/**\n * A Settings row a block offers, placed in the section with id `section`\n * (`\"account\"`, `\"about\"`, or one of the app's own; an unknown id becomes a\n * new section at the end).\n *\n * @stability Beta\n */\nexport interface BlockSettingsRow {\n /** Unique across every enabled block. */\n id: string;\n section: string;\n title: string;\n subtitle?: string;\n /**\n * A hook giving a subtitle that changes (a version, a count). It is called\n * on every render of the Settings screen, in block order, so the set of\n * blocks must not change while the app runs (shells read them once).\n */\n useSubtitle?: () => string | null | undefined;\n /** Where tapping the row goes, as a path. */\n href?: string;\n /** Lower first within its section. Default 0. */\n order?: number;\n testID?: string;\n}\n\n/**\n * A screen a block's feature needs the app to route to. On file-based\n * routers the app owns the route file; this is the declaration a check (or\n * a deep-link allowlist) reads.\n *\n * @stability Beta\n */\nexport interface BlockRoute {\n path: string;\n /** What the screen is for, in a few words. */\n description?: string;\n /** `true` when only a signed-in person can open it. */\n signedIn?: boolean;\n}\n\n/**\n * A SQL migration a block needs, shipped in a package: copy it into the\n * app's `supabase/migrations/` under a timestamped name.\n *\n * @stability Beta\n */\nexport interface BlockMigration {\n /** The npm package that ships it, e.g. `@marktiderman/genesis-supabase`. */\n package: string;\n /** Its path in the package, e.g. `migrations/0002_genesis_app_release_policy.sql`. */\n file: string;\n /** Its pgTAP test in the package, if any. */\n test?: string;\n}\n\n/**\n * One kind of data a block collects, for the App Store privacy label and the\n * Play data safety form.\n *\n * @stability Beta\n */\nexport interface BlockDataUse {\n /** What, in the stores' words: `\"email address\"`, `\"user id\"`, `\"crash data\"`. */\n type: string;\n /** Why: `\"app functionality\"`, `\"analytics\"`, … */\n purposes: readonly string[];\n /** Tied to the person's identity. */\n linked: boolean;\n /** Used to track the person across other companies' apps. */\n tracking: boolean;\n}\n\n/** What a block means for privacy. @stability Beta */\nexport interface BlockPrivacy {\n collects?: readonly BlockDataUse[];\n /** Anything a reviewer or a privacy policy should say, one sentence each. */\n notes?: readonly string[];\n}\n\n/**\n * What a block adds to an app. Every key is optional. `S` is what a slot is\n * filled with on the consuming platform (a React component on native and web).\n *\n * @stability Beta\n */\nexport interface BlockContributions<S = unknown> {\n nav?: readonly BlockNavItem[];\n settings?: readonly BlockSettingsRow[];\n routes?: readonly BlockRoute[];\n /**\n * Fills for the host shell's slots, by slot name (e.g. `fatal` on\n * `GenesisNativeApp`). The app's own `slots` always win over a block's.\n */\n slots?: Readonly<Record<string, S>>;\n migrations?: readonly BlockMigration[];\n /** Agent skills that come with it: repo or package paths to a `SKILL.md`. */\n skills?: readonly string[];\n privacy?: BlockPrivacy;\n}\n\n/**\n * One block. `id` is the block's FeatureId: the same id as its entry in the\n * feature registry.\n *\n * @stability Beta\n */\nexport interface BlockDef<Id extends string = string, S = unknown> {\n readonly id: Id;\n /**\n * What must be on with it: other blocks' ids, or features the app owns that\n * aren't blocks. A requirement that is a block must be enabled (and on this\n * platform); one that isn't a block must be listed in `enabled`. A\n * requirement that is neither is an error, so a forgotten block is loud.\n */\n readonly requires?: readonly string[];\n readonly contributes?: BlockContributions<S>;\n /** Where it runs. Default every platform. */\n readonly platforms?: readonly FeaturePlatform[];\n}\n\n/** Thrown by {@link defineBlock} and {@link resolveBlocks}; lists every problem at once. @stability Beta */\nexport class BlockError extends Error {\n constructor(readonly problems: string[]) {\n super(`Invalid blocks:\\n${problems.map((p) => ` - ${p}`).join(\"\\n\")}`);\n this.name = \"BlockError\";\n }\n}\n\n// The feature registry's id rule (model.ts), repeated so this file stays free of zod.\nconst ID = /^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$/;\n\nconst CONTRIBUTION_KEYS = [\"nav\", \"settings\", \"routes\", \"slots\", \"migrations\", \"skills\", \"privacy\"] as const;\n\nfunction duplicates(values: readonly string[]): string[] {\n const seen = new Set<string>();\n const dup = new Set<string>();\n for (const v of values) (seen.has(v) ? dup : seen).add(v);\n return [...dup];\n}\n\nfunction blockProblems(block: BlockDef<string, unknown>): string[] {\n const { id } = block;\n const problems: string[] = [];\n if (typeof id !== \"string\" || !ID.test(id)) problems.push(`${String(id)}: a block id is a feature id: lowercase letters and digits, joined by -, _ or .`);\n for (const req of block.requires ?? []) {\n if (req === id) problems.push(`${id}.requires: a block can't require itself`);\n else if (!ID.test(req)) problems.push(`${id}.requires: \"${req}\" is not a feature id`);\n }\n for (const p of block.platforms ?? []) {\n if (!(FEATURE_PLATFORMS as readonly string[]).includes(p)) problems.push(`${id}.platforms: \"${p}\" is not one of ${FEATURE_PLATFORMS.join(\", \")}`);\n }\n if (block.platforms && block.platforms.length === 0) problems.push(`${id}.platforms: an empty list runs nowhere; leave it out for every platform`);\n const c = block.contributes ?? {};\n for (const key of Object.keys(c)) {\n if (!(CONTRIBUTION_KEYS as readonly string[]).includes(key)) problems.push(`${id}.contributes.${key}: not a contribution (${CONTRIBUTION_KEYS.join(\", \")})`);\n }\n for (const d of duplicates((c.nav ?? []).map((n) => n.id))) problems.push(`${id}.contributes.nav: \"${d}\" appears twice`);\n for (const d of duplicates((c.settings ?? []).map((r) => r.id))) problems.push(`${id}.contributes.settings: \"${d}\" appears twice`);\n for (const d of duplicates((c.routes ?? []).map((r) => r.path))) problems.push(`${id}.contributes.routes: \"${d}\" appears twice`);\n for (const n of c.nav ?? []) if (!n.id || !n.label || !n.path) problems.push(`${id}.contributes.nav: every entry needs an id, a label and a path`);\n for (const r of c.settings ?? []) if (!r.id || !r.section || !r.title) problems.push(`${id}.contributes.settings: every row needs an id, a section and a title`);\n for (const m of c.migrations ?? []) if (!m.package || !m.file) problems.push(`${id}.contributes.migrations: every migration needs a package and a file`);\n return problems;\n}\n\n/**\n * Declare a block. Validates it (id, requirements, platforms, contribution\n * keys and duplicate ids within the block) and returns it frozen, so a\n * typo fails where the block is written rather than where it is used:\n *\n * ```ts\n * export const supportBlock = defineBlock({\n * id: \"support\",\n * requires: [\"account\"],\n * platforms: [\"web\", \"native\"],\n * contributes: {\n * settings: [{ id: \"contact-support\", section: \"about\", title: \"Contact support\", href: \"/support\" }],\n * routes: [{ path: \"/support\", signedIn: true }],\n * migrations: [{ package: \"@acme/support\", file: \"migrations/0001_support.sql\" }],\n * },\n * });\n * ```\n *\n * To check `id` against the app's registry at compile time, give the\n * FeatureId: `defineBlock<FeatureId>({ … })`. `S` is what slots are filled\n * with, inferred from `contributes.slots` (a component on native and web).\n *\n * @stability Beta\n */\nexport function defineBlock<const Id extends string, S = never>(block: BlockDef<Id, S>): BlockDef<Id, S> {\n const problems = blockProblems(block as BlockDef<string, unknown>);\n if (problems.length) throw new BlockError(problems);\n return Object.freeze(block);\n}\n\n/** Which blocks are on: ids, a predicate, or (left out) every block given. @stability Beta */\nexport type EnabledBlocks = Iterable<string> | ((id: string) => boolean);\n\n/** @stability Beta */\nexport interface ResolveBlocksOptions {\n /** Keep only blocks that run here. A required block that doesn't is a missing requirement. */\n platform?: FeaturePlatform;\n /**\n * The app's feature registry (`features` from `defineFeatures`): every block\n * id and requirement must be one of its ids.\n */\n features?: Readonly<Record<string, unknown>>;\n /**\n * A block whose requirement is off: `throw` (default: a set-up mistake, found\n * at launch) or `drop` it, and every block needing it, listing each in\n * `dropped` (for switches that change at run time, such as a tenant turning\n * a feature off).\n */\n missing?: \"throw\" | \"drop\";\n /**\n * The host's slot names (e.g. `GenesisNativeApp`'s). A block filling any\n * other slot is an error, so a typo doesn't fill nothing silently.\n */\n slots?: readonly string[];\n}\n\n/** A contribution with the FeatureId of the block it came from. @stability Beta */\nexport type Contributed<T, Id extends string = string> = T & { readonly feature: Id };\n\n/** @stability Beta */\nexport interface ResolvedBlocks<B extends BlockDef<string, unknown> = BlockDef> {\n /** The enabled blocks, in dependency order (a block after what it requires). */\n readonly blocks: readonly B[];\n readonly ids: ReadonlySet<B[\"id\"]>;\n has(id: string): boolean;\n /** One block's contributions, or `undefined` when it isn't on. */\n contributionsOf(id: B[\"id\"]): NonNullable<B[\"contributes\"]> | undefined;\n /** Nav entries by `order`, then block order. Place them in the app's tree by `feature` and `id`. */\n readonly nav: readonly Contributed<BlockNavItem, B[\"id\"]>[];\n /** Settings rows by `order`, then block order. */\n readonly settings: readonly Contributed<BlockSettingsRow, B[\"id\"]>[];\n readonly routes: readonly Contributed<BlockRoute, B[\"id\"]>[];\n /** Slot fills by slot name. Two blocks filling one slot is an error. */\n readonly slots: Readonly<Record<string, SlotOf<B>>>;\n readonly migrations: readonly Contributed<BlockMigration, B[\"id\"]>[];\n readonly skills: readonly Contributed<{ path: string }, B[\"id\"]>[];\n readonly privacy: readonly Contributed<BlockPrivacy, B[\"id\"]>[];\n /** With `missing: \"drop\"`: blocks left out, and the requirements that were off. */\n readonly dropped: readonly { id: B[\"id\"]; missing: readonly string[] }[];\n}\n\ntype SlotOf<B> = B extends BlockDef<string, infer S> ? S : never;\n\nfunction enabledPredicate(enabled: EnabledBlocks | undefined): ((id: string) => boolean) | undefined {\n if (enabled === undefined) return undefined;\n if (typeof enabled === \"function\") return enabled;\n const set = new Set(enabled);\n return (id) => set.has(id);\n}\n\nconst byOrder = <T extends { order?: number }>(items: { item: T; at: number }[]) =>\n items.sort((a, b) => (a.item.order ?? 0) - (b.item.order ?? 0) || a.at - b.at).map((x) => x.item);\n\n/**\n * The blocks that are on, checked and merged:\n *\n * - every block is valid ({@link defineBlock}'s checks, for blocks built by hand) and its id is unique;\n * - `requires` has no cycles, and with `features`, names real features;\n * - every enabled block's requirements are on (see {@link ResolveBlocksOptions.missing});\n * - no two enabled blocks contribute the same nav id, settings row id, route path or slot.\n *\n * `enabled` left out means every block given is on (and no app feature that\n * isn't a block). Throws a {@link BlockError} listing every problem at once.\n *\n * @stability Beta\n */\nexport function resolveBlocks<B extends BlockDef<string, unknown>>(\n blocks: readonly B[],\n enabled?: EnabledBlocks,\n options: ResolveBlocksOptions = {},\n): ResolvedBlocks<B> {\n const { platform, features, missing = \"throw\", slots: slotNames } = options;\n const problems: string[] = [];\n const byId = new Map<string, B>();\n for (const block of blocks) {\n problems.push(...blockProblems(block));\n if (byId.has(block.id)) problems.push(`${block.id}: two blocks have this id`);\n else byId.set(block.id, block);\n }\n const isFeature = features ? (id: string) => Object.hasOwn(features, id) : undefined;\n if (isFeature) for (const id of byId.keys()) if (!isFeature(id)) problems.push(`${id}: not a feature in the registry`);\n const graph = Object.fromEntries([...byId].map(([id, b]) => [id, { requires: b.requires }]));\n // Self-requirements are already reported by blockProblems; here, unknown ids and cycles.\n const known = { noun: \"block\", isKnown: (req: string) => byId.has(req) || !isFeature || isFeature(req) };\n for (const [id, node] of Object.entries(graph)) {\n for (const req of node.requires ?? []) {\n if (req !== id && requirementProblem(graph, id, req, known)) problems.push(`${id}.requires: \"${req}\" is neither a block nor a feature in the registry`);\n }\n }\n problems.push(...cycleProblems(graph));\n if (problems.length) throw new BlockError(problems);\n\n const isOn = enabledPredicate(enabled);\n const runsHere = (b: B) => !platform || !b.platforms || b.platforms.includes(platform);\n const active = new Set<string>();\n for (const [id, b] of byId) if ((!isOn || isOn(id)) && runsHere(b)) active.add(id);\n\n // In dependency order, so dropping a block also drops what needs it.\n const order = dependencyOrder(graph);\n const dropped: { id: B[\"id\"]; missing: string[] }[] = [];\n for (const id of order) {\n if (!active.has(id)) continue;\n const off = (byId.get(id)!.requires ?? []).filter((req) => {\n if (byId.has(req)) return !active.has(req);\n return !isOn || !isOn(req);\n });\n if (!off.length) continue;\n if (missing === \"drop\") {\n active.delete(id);\n dropped.push({ id, missing: off });\n continue;\n }\n for (const req of off) {\n const why = !byId.has(req)\n ? isOn\n ? \"is not enabled\"\n : \"is not one of the blocks given (pass it, or list the app feature in enabled)\"\n : !runsHere(byId.get(req)!)\n ? `doesn't run on ${platform}`\n : \"is off\";\n problems.push(`${id}.requires: \"${req}\" ${why}; turn it on or turn ${id} off`);\n }\n }\n if (problems.length) throw new BlockError(problems);\n\n const on = order.filter((id) => active.has(id)).map((id) => byId.get(id)!);\n const nav: { item: Contributed<BlockNavItem, B[\"id\"]>; at: number }[] = [];\n const settings: { item: Contributed<BlockSettingsRow, B[\"id\"]>; at: number }[] = [];\n const routes: Contributed<BlockRoute, B[\"id\"]>[] = [];\n const migrations: Contributed<BlockMigration, B[\"id\"]>[] = [];\n const skills: Contributed<{ path: string }, B[\"id\"]>[] = [];\n const privacy: Contributed<BlockPrivacy, B[\"id\"]>[] = [];\n const slots: Record<string, SlotOf<B>> = {};\n const owner = { nav: new Map<string, string>(), settings: new Map<string, string>(), routes: new Map<string, string>(), slots: new Map<string, string>() };\n const claim = (kind: keyof typeof owner, key: string, id: string, what: string) => {\n const first = owner[kind].get(key);\n if (first !== undefined) problems.push(`${id}.contributes.${kind}: ${what} \"${key}\" is already contributed by ${first}`);\n else owner[kind].set(key, id);\n return first === undefined;\n };\n on.forEach((block, at) => {\n const feature = block.id;\n const c = block.contributes ?? {};\n for (const n of c.nav ?? []) if (claim(\"nav\", n.id, feature, \"the nav entry\")) nav.push({ item: { ...n, feature }, at });\n for (const r of c.settings ?? []) if (claim(\"settings\", r.id, feature, \"the settings row\")) settings.push({ item: { ...r, feature }, at });\n for (const r of c.routes ?? []) if (claim(\"routes\", r.path, feature, \"the route\")) routes.push({ ...r, feature });\n for (const [name, fill] of Object.entries(c.slots ?? {})) {\n if (slotNames && !slotNames.includes(name)) {\n problems.push(`${feature}.contributes.slots: \"${name}\" is not a slot here (${slotNames.join(\", \")})`);\n continue;\n }\n if (claim(\"slots\", name, feature, \"the slot\")) slots[name] = fill as SlotOf<B>;\n }\n for (const m of c.migrations ?? []) migrations.push({ ...m, feature });\n for (const path of c.skills ?? []) skills.push({ path, feature });\n if (c.privacy) privacy.push({ ...c.privacy, feature });\n });\n if (problems.length) throw new BlockError(problems);\n\n const ids = new Set(on.map((b) => b.id)) as ReadonlySet<B[\"id\"]>;\n return Object.freeze({\n blocks: Object.freeze(on),\n ids,\n has: (id: string) => ids.has(id as B[\"id\"]),\n contributionsOf: (id: B[\"id\"]) => (ids.has(id) ? ((byId.get(id)!.contributes ?? {}) as NonNullable<B[\"contributes\"]>) : undefined),\n nav: Object.freeze(byOrder(nav)),\n settings: Object.freeze(byOrder(settings)),\n routes: Object.freeze(routes),\n slots: Object.freeze(slots),\n migrations: Object.freeze(migrations),\n skills: Object.freeze(skills),\n privacy: Object.freeze(privacy),\n dropped: Object.freeze(dropped),\n });\n}\n","/**\n * Content packs: versioned data that fills installed blocks (session types and\n * agendas, metric templates, custom field definitions, forms, roadmap templates,\n * labels). A pack is code, reviewed like any other: the publishing package\n * exports it, and an installer copies it into a tenant's editable rows, keeping\n * each row's source (pack, version, key) so an update can tell what a person\n * changed.\n *\n * `defineContentPack` checks a pack's shape; `contentPackProblems` with the\n * installed blocks also checks that every block it fills is there. Keys, not\n * ids, link things together, and stay the same across versions.\n *\n * No zod here: packs ship to phones with `/blocks`.\n */\nimport type { EnabledBlocks } from \"./blocks\";\n\n/** A content pack's settings for one session type, with its agenda. @stability Beta */\nexport interface ContentPackSessionType {\n key: string;\n kind: string;\n name: string;\n description?: string;\n defaultMinutes?: number;\n agenda: readonly { key: string; title: string; minutes: number }[];\n}\n\n/** A metric to start from. @stability Beta */\nexport interface ContentPackMetricTemplate {\n key: string;\n name: string;\n unitType: string;\n unit?: string;\n cadence: string;\n goalDirection: string;\n goalValue?: number;\n goalMax?: number;\n measureKind?: string;\n rollup?: string;\n}\n\n/** Where a custom field lives, and the block that owns that table. @stability Beta */\nexport const CONTENT_PACK_FIELD_TARGETS = {\n pursuits: \"pursuits\",\n work_items: \"pursuits\",\n metrics: \"metrics\",\n sessions: \"sessions\",\n} as const;\n\n/** @stability Beta */\nexport type ContentPackFieldTarget = keyof typeof CONTENT_PACK_FIELD_TARGETS;\n\n/** A custom field: a genesis-forms serializable field, on one of the work tables. @stability Beta */\nexport interface ContentPackFieldDefinition {\n key: string;\n target: ContentPackFieldTarget;\n label: string;\n /** A genesis-forms serializable field: type, options, validation. */\n field: { readonly type: string; readonly [key: string]: unknown };\n required?: boolean;\n visibility: \"tenant\" | \"app\" | \"private\";\n}\n\n/** A worksheet, assessment or form: a genesis-forms definition. @stability Beta */\nexport interface ContentPackForm {\n key: string;\n kind: \"worksheet\" | \"assessment\" | \"form\";\n title: string;\n definition: { readonly [key: string]: unknown };\n scoring?: unknown;\n}\n\n/** A roadmap to start from: items that release by a rule, linked to each other by key. @stability Beta */\nexport interface ContentPackRoadmapTemplate {\n key: string;\n name: string;\n items: readonly {\n key: string;\n kind: string;\n title: string;\n /** Another item's key in this template. */\n ref?: string;\n release: { rule: string; afterDays?: number; anchor?: string };\n }[];\n}\n\n/** One content pack, as its publisher defines it. @stability Beta */\nexport interface ContentPackDef {\n /** Kebab-case, unique per publisher. */\n id: string;\n name: string;\n description?: string;\n /** Semver. Updates are additive. */\n version: string;\n /** The package that publishes it. */\n publisher: string;\n /** The block ids it fills; installing is refused unless every one is installed. */\n requires: readonly string[];\n /** Taxonomy: label key → display text, e.g. `\"pursuit.quarter\": \"Rocks\"`. */\n labels?: Readonly<Record<string, string>>;\n sessionTypes?: readonly ContentPackSessionType[];\n metricTemplates?: readonly ContentPackMetricTemplate[];\n fieldDefinitions?: readonly ContentPackFieldDefinition[];\n forms?: readonly ContentPackForm[];\n roadmapTemplates?: readonly ContentPackRoadmapTemplate[];\n}\n\n/** Thrown by {@link defineContentPack}; lists every problem at once. @stability Beta */\nexport class ContentPackError extends Error {\n constructor(readonly problems: string[]) {\n super(`Invalid content pack:\\n${problems.map((p) => ` - ${p}`).join(\"\\n\")}`);\n this.name = \"ContentPackError\";\n }\n}\n\nconst KEBAB = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/;\nconst KEY = /^[a-z][a-z0-9]*(?:[-_.][a-z0-9]+)*$/;\nconst SEMVER = /^(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)(?:-[0-9A-Za-z.-]+)?(?:\\+[0-9A-Za-z.-]+)?$/;\n\n/** The block each section fills. */\nconst SECTION_BLOCK = { sessionTypes: \"sessions\", metricTemplates: \"metrics\", forms: \"forms\", roadmapTemplates: \"roadmap\" } as const;\n\nfunction keyProblems(where: string, items: readonly { key: string }[] | undefined): string[] {\n const problems: string[] = [];\n const seen = new Set<string>();\n for (const [i, item] of (items ?? []).entries()) {\n if (typeof item?.key !== \"string\" || !KEY.test(item.key)) problems.push(`${where}[${i}].key: \"${String(item?.key)}\" is not a key (lowercase, dots, dashes or underscores)`);\n else if (seen.has(item.key)) problems.push(`${where}: the key \"${item.key}\" is used twice`);\n else seen.add(item.key);\n }\n return problems;\n}\n\n/** The block ids a pack's sections need, whatever it declares. @stability Beta */\nexport function contentPackBlocks(pack: ContentPackDef): string[] {\n const needed = new Set<string>();\n for (const [section, block] of Object.entries(SECTION_BLOCK)) {\n const items = pack[section as keyof typeof SECTION_BLOCK];\n if (items && items.length) needed.add(block);\n }\n for (const f of pack.fieldDefinitions ?? []) {\n const block = CONTENT_PACK_FIELD_TARGETS[f.target];\n if (block) needed.add(block);\n }\n return [...needed].sort();\n}\n\nfunction test(blocks: EnabledBlocks): (id: string) => boolean {\n if (typeof blocks === \"function\") return blocks;\n const set = new Set(blocks);\n return (id) => set.has(id);\n}\n\n/**\n * Every problem with a pack: its shape and, given the installed blocks, any\n * block it fills that isn't installed. An empty list means it can be installed.\n *\n * @stability Beta\n */\nexport function contentPackProblems(pack: ContentPackDef, installed?: EnabledBlocks): string[] {\n const at = `content pack ${typeof pack?.id === \"string\" ? pack.id : \"?\"}`;\n const problems: string[] = [];\n if (typeof pack?.id !== \"string\" || !KEBAB.test(pack.id)) problems.push(`${at}: id must be kebab-case`);\n if (typeof pack?.name !== \"string\" || !pack.name.trim()) problems.push(`${at}: needs a name`);\n if (typeof pack?.version !== \"string\" || !SEMVER.test(pack.version)) problems.push(`${at}: version \"${String(pack?.version)}\" isn't semver`);\n if (typeof pack?.publisher !== \"string\" || !pack.publisher.trim()) problems.push(`${at}: needs a publisher (its package name)`);\n if (!Array.isArray(pack?.requires)) {\n problems.push(`${at}: requires must list the blocks it fills`);\n return problems;\n }\n for (const [label, text] of Object.entries(pack.labels ?? {})) {\n if (!KEY.test(label)) problems.push(`${at}: label key \"${label}\" is not a key`);\n if (typeof text !== \"string\" || !text.trim()) problems.push(`${at}: label \"${label}\" needs display text`);\n }\n problems.push(\n ...keyProblems(`${at}.sessionTypes`, pack.sessionTypes),\n ...keyProblems(`${at}.metricTemplates`, pack.metricTemplates),\n ...keyProblems(`${at}.fieldDefinitions`, pack.fieldDefinitions),\n ...keyProblems(`${at}.forms`, pack.forms),\n ...keyProblems(`${at}.roadmapTemplates`, pack.roadmapTemplates),\n );\n for (const s of pack.sessionTypes ?? []) {\n problems.push(...keyProblems(`${at}.sessionTypes.${s.key}.agenda`, s.agenda));\n for (const item of s.agenda ?? []) {\n if (!(typeof item.minutes === \"number\" && item.minutes > 0)) problems.push(`${at}.sessionTypes.${s.key}.agenda.${item.key}: minutes must be more than 0`);\n }\n }\n for (const f of pack.fieldDefinitions ?? []) {\n if (!Object.hasOwn(CONTENT_PACK_FIELD_TARGETS, f.target)) problems.push(`${at}.fieldDefinitions.${f.key}: target \"${String(f.target)}\" isn't one of ${Object.keys(CONTENT_PACK_FIELD_TARGETS).join(\", \")}`);\n if (typeof f.field?.type !== \"string\") problems.push(`${at}.fieldDefinitions.${f.key}: field needs a genesis-forms type`);\n if (![\"tenant\", \"app\", \"private\"].includes(f.visibility)) problems.push(`${at}.fieldDefinitions.${f.key}: visibility must be tenant, app or private`);\n }\n for (const r of pack.roadmapTemplates ?? []) {\n problems.push(...keyProblems(`${at}.roadmapTemplates.${r.key}.items`, r.items));\n const keys = new Set((r.items ?? []).map((i) => i.key));\n for (const item of r.items ?? []) {\n if (item.ref !== undefined && (!keys.has(item.ref) || item.ref === item.key)) {\n problems.push(`${at}.roadmapTemplates.${r.key}.items.${item.key}: ref \"${item.ref}\" isn't another item in this template`);\n }\n }\n }\n // Every block a section fills must be declared, and (when known) installed.\n const declared = new Set(pack.requires);\n for (const block of contentPackBlocks(pack)) {\n if (!declared.has(block)) problems.push(`${at}: fills the ${block} block but doesn't list it in requires`);\n }\n if (installed !== undefined) {\n const has = test(installed);\n for (const block of pack.requires) if (!has(block)) problems.push(`${at}: needs the ${block} block, which isn't installed`);\n }\n return problems;\n}\n\n/**\n * Declare a content pack: returns it unchanged, typed, after checking its\n * shape (throws a {@link ContentPackError} listing every problem). Whether its\n * blocks are installed is checked at install time with\n * {@link contentPackProblems}.\n *\n * ```ts\n * export const weeklyTeamRhythm = defineContentPack({\n * id: \"weekly-team-rhythm\", name: \"Weekly team rhythm\", version: \"1.0.0\",\n * publisher: \"@marktiderman/genesis-content\", requires: [\"sessions\", \"metrics\"],\n * labels: { \"pursuit.quarter\": \"Rocks\" },\n * sessionTypes: [{ key: \"weekly\", kind: \"team\", name: \"Weekly meeting\", agenda: [{ key: \"check-in\", title: \"Check in\", minutes: 5 }] }],\n * });\n * ```\n *\n * @stability Beta\n */\nexport function defineContentPack<const T extends ContentPackDef>(pack: T): T {\n const problems = contentPackProblems(pack);\n if (problems.length) throw new ContentPackError(problems);\n return pack;\n}\n"]}