@protoyard/blueprint 0.0.0-stage → 1.1.1

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.
Files changed (168) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +1145 -2
  3. package/dist/aggregate.d.ts +83 -0
  4. package/dist/aggregate.js +268 -0
  5. package/dist/app-model.d.ts +76 -0
  6. package/dist/app-model.js +287 -0
  7. package/dist/archetypes/index.d.ts +1 -0
  8. package/dist/archetypes/index.js +1 -0
  9. package/dist/archetypes/schema.d.ts +126 -0
  10. package/dist/archetypes/schema.js +77 -0
  11. package/dist/audit.d.ts +52 -0
  12. package/dist/audit.js +149 -0
  13. package/dist/authoring/deck-lint.d.ts +32 -0
  14. package/dist/authoring/deck-lint.js +567 -0
  15. package/dist/authoring/index.d.ts +1 -0
  16. package/dist/authoring/index.js +1 -0
  17. package/dist/authoring/select-deck-layouts.d.ts +50 -0
  18. package/dist/authoring/select-deck-layouts.js +213 -0
  19. package/dist/authoring-apis.d.ts +13 -0
  20. package/dist/authoring-apis.js +13 -0
  21. package/dist/authoring-validation.d.ts +65 -0
  22. package/dist/authoring-validation.js +267 -0
  23. package/dist/avatar.d.ts +25 -0
  24. package/dist/avatar.js +30 -0
  25. package/dist/brand.d.ts +70 -0
  26. package/dist/brand.js +294 -0
  27. package/dist/brief/archetypes.d.ts +28 -0
  28. package/dist/brief/archetypes.js +798 -0
  29. package/dist/brief/content-synthesize.d.ts +31 -0
  30. package/dist/brief/content-synthesize.js +210 -0
  31. package/dist/brief/deck-outlines.d.ts +96 -0
  32. package/dist/brief/deck-outlines.js +561 -0
  33. package/dist/brief/draft-bodies.d.ts +29 -0
  34. package/dist/brief/draft-bodies.js +224 -0
  35. package/dist/brief/fields.d.ts +19 -0
  36. package/dist/brief/fields.js +229 -0
  37. package/dist/brief/index.d.ts +8 -0
  38. package/dist/brief/index.js +8 -0
  39. package/dist/brief/kind-detection.d.ts +69 -0
  40. package/dist/brief/kind-detection.js +353 -0
  41. package/dist/brief/limits.d.ts +117 -0
  42. package/dist/brief/limits.js +217 -0
  43. package/dist/brief/page-doc-outlines.d.ts +80 -0
  44. package/dist/brief/page-doc-outlines.js +485 -0
  45. package/dist/brief/synthesize.d.ts +59 -0
  46. package/dist/brief/synthesize.js +511 -0
  47. package/dist/brief/text.d.ts +13 -0
  48. package/dist/brief/text.js +59 -0
  49. package/dist/canvas-screen.d.ts +31 -0
  50. package/dist/canvas-screen.js +33 -0
  51. package/dist/canvas-seed.d.ts +58 -0
  52. package/dist/canvas-seed.js +82 -0
  53. package/dist/computed/evaluate.d.ts +11 -0
  54. package/dist/computed/evaluate.js +101 -0
  55. package/dist/computed/index.d.ts +4 -0
  56. package/dist/computed/index.js +3 -0
  57. package/dist/computed/public.d.ts +14 -0
  58. package/dist/computed/public.js +19 -0
  59. package/dist/computed/schema.d.ts +10 -0
  60. package/dist/computed/schema.js +140 -0
  61. package/dist/computed/types.d.ts +70 -0
  62. package/dist/computed/types.js +1 -0
  63. package/dist/computed/validate.d.ts +6 -0
  64. package/dist/computed/validate.js +146 -0
  65. package/dist/csv-guard.d.ts +15 -0
  66. package/dist/csv-guard.js +29 -0
  67. package/dist/csv.d.ts +85 -0
  68. package/dist/csv.js +288 -0
  69. package/dist/files.d.ts +35 -0
  70. package/dist/files.js +246 -0
  71. package/dist/form-schema.d.ts +124 -0
  72. package/dist/form-schema.js +300 -0
  73. package/dist/generator-version.d.ts +11 -0
  74. package/dist/generator-version.js +51 -0
  75. package/dist/generator.d.ts +34 -0
  76. package/dist/generator.js +445 -0
  77. package/dist/identity.d.ts +34 -0
  78. package/dist/identity.js +91 -0
  79. package/dist/import/csv-shape.d.ts +40 -0
  80. package/dist/import/csv-shape.js +265 -0
  81. package/dist/import/json-shape.d.ts +55 -0
  82. package/dist/import/json-shape.js +491 -0
  83. package/dist/import/limits.d.ts +13 -0
  84. package/dist/import/limits.js +14 -0
  85. package/dist/import/sqlite-schema.d.ts +36 -0
  86. package/dist/import/sqlite-schema.js +729 -0
  87. package/dist/index.d.ts +60 -0
  88. package/dist/index.js +58 -0
  89. package/dist/kinds/anchors.d.ts +18 -0
  90. package/dist/kinds/anchors.js +46 -0
  91. package/dist/kinds/bodies.d.ts +6 -0
  92. package/dist/kinds/bodies.js +32 -0
  93. package/dist/kinds/brand-runtime.d.ts +19 -0
  94. package/dist/kinds/brand-runtime.js +35 -0
  95. package/dist/kinds/deck.d.ts +8 -0
  96. package/dist/kinds/deck.js +34 -0
  97. package/dist/kinds/doc.d.ts +19 -0
  98. package/dist/kinds/doc.js +41 -0
  99. package/dist/kinds/embed/index.d.ts +39 -0
  100. package/dist/kinds/embed/index.js +91 -0
  101. package/dist/kinds/envelope.d.ts +159 -0
  102. package/dist/kinds/envelope.js +78 -0
  103. package/dist/kinds/index.d.ts +11 -0
  104. package/dist/kinds/index.js +11 -0
  105. package/dist/kinds/kind.d.ts +36 -0
  106. package/dist/kinds/kind.js +55 -0
  107. package/dist/kinds/limits.d.ts +64 -0
  108. package/dist/kinds/limits.js +190 -0
  109. package/dist/kinds/page-doc-runtime.d.ts +37 -0
  110. package/dist/kinds/page-doc-runtime.js +55 -0
  111. package/dist/kinds/page.d.ts +16 -0
  112. package/dist/kinds/page.js +67 -0
  113. package/dist/kinds/parse.d.ts +18 -0
  114. package/dist/kinds/parse.js +27 -0
  115. package/dist/kinds/runtime.d.ts +128 -0
  116. package/dist/kinds/runtime.js +206 -0
  117. package/dist/kinds/services.d.ts +49 -0
  118. package/dist/kinds/services.js +249 -0
  119. package/dist/kinds/testing.d.ts +9 -0
  120. package/dist/kinds/testing.js +16 -0
  121. package/dist/migrations.d.ts +97 -0
  122. package/dist/migrations.js +351 -0
  123. package/dist/motion.d.ts +50 -0
  124. package/dist/motion.js +52 -0
  125. package/dist/notifications.d.ts +19 -0
  126. package/dist/notifications.js +177 -0
  127. package/dist/patch.d.ts +122 -0
  128. package/dist/patch.js +322 -0
  129. package/dist/policy.d.ts +23 -0
  130. package/dist/policy.js +105 -0
  131. package/dist/runtime-definition.d.ts +39 -0
  132. package/dist/runtime-definition.js +74 -0
  133. package/dist/scenarios.d.ts +9 -0
  134. package/dist/scenarios.js +49 -0
  135. package/dist/schema/blueprint.schema.json +10191 -0
  136. package/dist/schema-json.d.ts +6 -0
  137. package/dist/schema-json.js +36 -0
  138. package/dist/schema.d.ts +6348 -0
  139. package/dist/schema.js +1269 -0
  140. package/dist/search.d.ts +16 -0
  141. package/dist/search.js +96 -0
  142. package/dist/services.d.ts +89 -0
  143. package/dist/services.js +898 -0
  144. package/dist/share.d.ts +78 -0
  145. package/dist/share.js +234 -0
  146. package/dist/sheet-screen.d.ts +49 -0
  147. package/dist/sheet-screen.js +91 -0
  148. package/dist/storage.d.ts +43 -0
  149. package/dist/storage.js +179 -0
  150. package/dist/stream.d.ts +26 -0
  151. package/dist/stream.js +173 -0
  152. package/dist/untrusted.d.ts +63 -0
  153. package/dist/untrusted.js +502 -0
  154. package/dist/validation-tasks.d.ts +178 -0
  155. package/dist/validation-tasks.js +199 -0
  156. package/dist/validation.d.ts +35 -0
  157. package/dist/validation.js +312 -0
  158. package/dist/variants.d.ts +112 -0
  159. package/dist/variants.js +283 -0
  160. package/dist/workflows/index.d.ts +3 -0
  161. package/dist/workflows/index.js +3 -0
  162. package/dist/workflows/schema.d.ts +50 -0
  163. package/dist/workflows/schema.js +34 -0
  164. package/dist/workflows/transition.d.ts +15 -0
  165. package/dist/workflows/transition.js +25 -0
  166. package/dist/workflows/validate.d.ts +17 -0
  167. package/dist/workflows/validate.js +140 -0
  168. package/package.json +120 -3
@@ -0,0 +1,74 @@
1
+ import { definePrototype, parseManifest, } from '@protoyard/core';
2
+ import { deriveAppModel } from "./app-model.js";
3
+ import { brandLibraryThemeId, resolveBlueprintBrand } from "./brand.js";
4
+ import { blueprintGeneratorVersion } from "./generator-version.js";
5
+ import { deriveDatabaseVersions, latestSchemaVersion } from "./migrations.js";
6
+ import { derivePolicy } from "./policy.js";
7
+ import { blueprintScenarios } from "./scenarios.js";
8
+ import { deriveIntegrity } from "./storage.js";
9
+ /** Scenario a blueprint prototype opens in (one of `blueprintScenarios`). */
10
+ export const BLUEPRINT_DEFAULT_SCENARIO = 'active';
11
+ /**
12
+ * The theme id a blueprint opens in: its library theme, the id of the theme
13
+ * its brand builds, or null without a brand. `protoyard generate` writes it to
14
+ * `protoyard.json` and the player uses it as `defaultTheme`. Throws
15
+ * `BrandThemeError` for an unknown library theme or a brand that fails AA.
16
+ */
17
+ export function brandDefaultThemeId(blueprint) {
18
+ if (!blueprint.brand)
19
+ return null;
20
+ const libraryTheme = brandLibraryThemeId(blueprint.brand);
21
+ if (libraryTheme)
22
+ return libraryTheme;
23
+ return resolveBlueprintBrand(blueprint.brand, { blueprintName: blueprint.name }).id;
24
+ }
25
+ /** The theme a blueprint's brand builds, or null for no brand or a library brand (shipped by id). */
26
+ export function blueprintBrandTheme(blueprint) {
27
+ if (!blueprint.brand || brandLibraryThemeId(blueprint.brand))
28
+ return null;
29
+ return resolveBlueprintBrand(blueprint.brand, { blueprintName: blueprint.name });
30
+ }
31
+ /**
32
+ * Builds a `definePrototype`-valid definition from a parsed blueprint, plus
33
+ * its app model. The world generator loads lazily (`@protoyard/blueprint/generator`
34
+ * stays out of the caller's initial chunk until a scenario seeds).
35
+ */
36
+ export function definePrototypeFromBlueprint(blueprint, options) {
37
+ const slug = options.slug ?? options.namespace;
38
+ const scenarios = blueprintScenarios(blueprint);
39
+ const appModel = deriveAppModel(blueprint);
40
+ const theme = blueprintBrandTheme(blueprint);
41
+ const manifest = parseManifest({
42
+ id: `local.${slug}`,
43
+ slug,
44
+ kind: 'prototype',
45
+ name: blueprint.name,
46
+ description: blueprint.description ?? '',
47
+ version: options.version ?? '0.1.0',
48
+ category: blueprint.category ?? blueprint.catalog?.category ?? 'general',
49
+ tags: blueprint.tags,
50
+ ...(blueprint.icon ? { icon: blueprint.icon } : {}),
51
+ defaultScenario: BLUEPRINT_DEFAULT_SCENARIO,
52
+ defaultTheme: brandDefaultThemeId(blueprint) ?? 'violet',
53
+ preview: {
54
+ viewport: 'desktop',
55
+ layout: { id: appModel.layout.id },
56
+ },
57
+ storage: { namespace: options.namespace, schemaVersion: latestSchemaVersion(blueprint) },
58
+ scenarios: scenarios.map((scenario) => scenario.id),
59
+ });
60
+ const definition = definePrototype({
61
+ manifest,
62
+ database: { versions: deriveDatabaseVersions(blueprint) },
63
+ scenarios,
64
+ policy: derivePolicy(blueprint),
65
+ integrity: deriveIntegrity(blueprint),
66
+ ...(theme ? { themes: [theme] } : {}),
67
+ async generate(ctx) {
68
+ const { createBlueprintGenerator } = await import("./generator.js");
69
+ return createBlueprintGenerator(blueprint).generate(ctx);
70
+ },
71
+ generatorVersion: blueprintGeneratorVersion(blueprint),
72
+ });
73
+ return { definition, appModel };
74
+ }
@@ -0,0 +1,9 @@
1
+ import type { ScenarioDefinition } from '@protoyard/core';
2
+ import type { Blueprint } from './schema.ts';
3
+ /**
4
+ * Default scenarios for a blueprint-backed prototype. These are deliberately
5
+ * product-generic; the blueprint parameter keeps scenario selection at the
6
+ * validated blueprint boundary and leaves room for future data-only scenario
7
+ * options without requiring each player or template to duplicate defaults.
8
+ */
9
+ export declare function blueprintScenarios(_blueprint: Blueprint): ScenarioDefinition[];
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Default scenarios for a blueprint-backed prototype. These are deliberately
3
+ * product-generic; the blueprint parameter keeps scenario selection at the
4
+ * validated blueprint boundary and leaves room for future data-only scenario
5
+ * options without requiring each player or template to duplicate defaults.
6
+ */
7
+ export function blueprintScenarios(_blueprint) {
8
+ return [
9
+ {
10
+ id: 'empty',
11
+ name: 'Empty',
12
+ description: 'Team only — no records yet.',
13
+ seed: 123_001,
14
+ referenceTime: '2026-06-01T09:00:00.000Z',
15
+ density: 'empty',
16
+ organization: { size: 4, ageDays: 30, subscription: 'pro' },
17
+ },
18
+ {
19
+ id: 'active',
20
+ extends: 'workspace-owner',
21
+ name: 'Active',
22
+ description: 'A normal density workspace for day-to-day demos.',
23
+ seed: 123_002,
24
+ referenceTime: '2026-06-01T14:00:00.000Z',
25
+ density: 'normal',
26
+ organization: { size: 6, ageDays: 120, subscription: 'pro' },
27
+ },
28
+ {
29
+ id: 'viewer',
30
+ extends: 'read-only-viewer',
31
+ name: 'Viewer',
32
+ description: 'Read-only stroll through seeded work.',
33
+ seed: 123_003,
34
+ referenceTime: '2026-06-01T11:00:00.000Z',
35
+ density: 'sparse',
36
+ organization: { size: 5, ageDays: 60, subscription: 'pro' },
37
+ },
38
+ {
39
+ id: 'massive',
40
+ extends: 'workspace-owner',
41
+ name: 'Massive',
42
+ description: 'Dense seed for list virtualization and budget checks.',
43
+ seed: 123_004,
44
+ referenceTime: '2026-06-01T16:00:00.000Z',
45
+ density: 'massive',
46
+ organization: { size: 12, ageDays: 365, subscription: 'enterprise' },
47
+ },
48
+ ];
49
+ }