@synap-core/workspace-templates 0.5.0 → 0.6.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/src/types.ts CHANGED
@@ -53,6 +53,10 @@ export interface TemplateProfile {
53
53
  scope?: string;
54
54
  /** Semantic slug for system profiles. */
55
55
  semanticSlug?: string;
56
+ /** Kind vs role profile. Omit for default ('kind'). */
57
+ profileKind?: "kind" | "role";
58
+ /** For profileKind='role': which base-kind profile slugs this role can attach to. */
59
+ applicableKinds?: string[];
56
60
  properties: TemplateProperty[];
57
61
  }
58
62
 
@@ -329,6 +333,49 @@ export interface TemplateExtendsRef {
329
333
  };
330
334
  }
331
335
 
336
+ // ============================================================================
337
+ // Dependencies — the template composition graph (base + overlay)
338
+ // ============================================================================
339
+
340
+ /**
341
+ * A dependency this template declares on ANOTHER template/package. The install
342
+ * resolver (backend `POST /api/hub/packages/apply`) reads these to build the
343
+ * pod's template graph: every dependency is ensured present before this
344
+ * template is applied — missing ones install first (topologically) — and a
345
+ * `compose` dependency LAYERS this template's schema additively onto the
346
+ * dependency's workspace instead of creating a second workspace.
347
+ *
348
+ * This is the general composition primitive: a BASE template carries the
349
+ * agnostic data model; an OVERLAY template `compose`s onto it and adds the
350
+ * use-case-specific data (e.g. `blockchain-ecosystem` → `ecosystem`,
351
+ * `grants` → `operations`). Distinct from `extends` (which imports from a live
352
+ * workspace, tRPC-only) — `dependencies` is template→template.
353
+ */
354
+ export interface TemplateDependency {
355
+ /** Slug of the template/package this one depends on. */
356
+ slug: string;
357
+ /**
358
+ * What the dependency is. Default `'workspace'`. Only `'workspace'`
359
+ * dependencies can be `compose`d; `'capability'`/`'automation'` are always
360
+ * `require`d present without merging.
361
+ */
362
+ kind?: 'workspace' | 'capability' | 'automation';
363
+ /**
364
+ * How this template relates to the dependency:
365
+ * - `'compose'`: this template is an OVERLAY on the dependency's workspace.
366
+ * The base is installed first if absent, then this template's profiles /
367
+ * roles / relations / views are applied ADDITIVELY onto the base workspace
368
+ * — no separate workspace is created for this template.
369
+ * - `'require'` (default): the dependency must be present on the pod as its
370
+ * own artifact, but this template does not merge into it.
371
+ */
372
+ relation?: 'compose' | 'require';
373
+ /**
374
+ * Short human reason shown in the install-time "this also installs…" prompt.
375
+ */
376
+ reason?: string;
377
+ }
378
+
332
379
  // ============================================================================
333
380
  // Top-level template definition (YAML shape)
334
381
  // ============================================================================
@@ -429,6 +476,14 @@ export interface WorkspaceYaml {
429
476
 
430
477
  /** Inherit profiles/views from other workspaces */
431
478
  extends?: TemplateExtendsRef[];
479
+
480
+ /**
481
+ * Template-composition dependencies — other templates this one needs. The
482
+ * install resolver installs missing dependencies first and, for a `compose`
483
+ * dependency, layers this template additively onto the dependency's
484
+ * workspace. See {@link TemplateDependency}.
485
+ */
486
+ dependencies?: TemplateDependency[];
432
487
  }
433
488
 
434
489
  // ============================================================================
package/dist/define.d.ts DELETED
@@ -1,97 +0,0 @@
1
- /**
2
- * @synap-core/workspace-templates — Definition adapter
3
- *
4
- * Converts a YAML template (WorkspaceYaml) into the flat payload shape that
5
- * the backend `workspaces.createFromDefinition` mutation + Hub REST
6
- * `/workspaces/from-definition` endpoint expect.
7
- *
8
- * This is the single canonical seam: every consumer (browser app, onboarding,
9
- * CLI, marketplace) provisions a workspace through this function so the wire
10
- * shape never drifts per call-site.
11
- */
12
- import type { WorkspaceYaml } from './types.js';
13
- /** The flat definition object accepted by createFromDefinition. */
14
- export interface WorkspaceDefinitionInput {
15
- workspaceName: string;
16
- description: string;
17
- proposalId?: string;
18
- profiles: WorkspaceYaml['profiles'];
19
- views: NonNullable<WorkspaceYaml['views']>;
20
- entityLinks: NonNullable<WorkspaceYaml['entityLinks']>;
21
- seedEntities: NonNullable<WorkspaceYaml['seedEntities']>;
22
- suggestedRelations?: WorkspaceYaml['suggestedRelations'];
23
- displayTemplates?: WorkspaceYaml['displayTemplates'];
24
- layoutConfig: WorkspaceYaml['layout'] | undefined;
25
- bentoViewName?: string;
26
- bentoViewBlocks?: NonNullable<WorkspaceYaml['bento']>['blocks'];
27
- profileEntityBentoTemplates?: WorkspaceYaml['profileEntityBentoTemplates'];
28
- workspaceSubtype?: string;
29
- workspaceType?: NonNullable<WorkspaceYaml['workspace']>['workspaceType'];
30
- workspaceVisibility?: string;
31
- workspaceCapabilities?: string[];
32
- sourceRoles?: NonNullable<WorkspaceYaml['workspace']>['sourceRoles'];
33
- defaultSources?: NonNullable<WorkspaceYaml['workspace']>['defaultSources'];
34
- /** Per-workspace onboarding context — written to settings.onboarding. */
35
- onboarding?: WorkspaceYaml['onboarding'];
36
- }
37
- export interface ToDefinitionResult {
38
- definition: WorkspaceDefinitionInput;
39
- /** Stable idempotency key — the template's proposalId or slug. */
40
- proposalId: string;
41
- /** Display name for the new workspace. */
42
- workspaceName: string;
43
- /** Template id for telemetry / dedup. */
44
- templateId: string;
45
- }
46
- /**
47
- * Resolve a template (by slug or YAML object) into the createFromDefinition
48
- * payload. Pass `nameOverride` to rename the workspace at creation time.
49
- */
50
- export declare function toWorkspaceDefinition(slugOrYaml: string | WorkspaceYaml, nameOverride?: string): ToDefinitionResult;
51
- /**
52
- * The unified `PackageDefinition` shape consumed by `POST /api/hub/packages/apply`
53
- * (CLI `synap launch`) and the CP package registry seeder. It composes the
54
- * workspace definition with the capability/playbook/onboarding layers. Mirrors
55
- * `PackageDefinition` in synap-backend `package-definition.ts`. Typed loosely on
56
- * the layered fields to avoid a backend import; the wire validation lives in the
57
- * apply endpoint.
58
- */
59
- export interface PackageDefinitionOutput {
60
- _meta: {
61
- slug: string;
62
- icon?: string;
63
- color?: string;
64
- tags?: string[];
65
- isPublic?: boolean;
66
- requiredTier?: string | null;
67
- };
68
- workspaceName: string;
69
- description: string;
70
- workspaceType?: WorkspaceYaml['workspace']['workspaceType'];
71
- workspaceSubtype?: string;
72
- workspaceVisibility?: string;
73
- workspaceCapabilities?: string[];
74
- sourceRoles?: WorkspaceYaml['workspace']['sourceRoles'];
75
- defaultSources?: WorkspaceYaml['workspace']['defaultSources'];
76
- profiles: WorkspaceYaml['profiles'];
77
- views: NonNullable<WorkspaceYaml['views']>;
78
- suggestedEntities: NonNullable<WorkspaceYaml['seedEntities']>;
79
- suggestedRelations?: WorkspaceYaml['suggestedRelations'];
80
- displayTemplates?: WorkspaceYaml['displayTemplates'];
81
- entityLinks?: WorkspaceYaml['entityLinks'];
82
- bentoLayout?: NonNullable<WorkspaceYaml['bento']>['blocks'];
83
- bentoViewName?: string;
84
- profileEntityBentoTemplates?: WorkspaceYaml['profileEntityBentoTemplates'];
85
- layoutConfig?: WorkspaceYaml['layout'];
86
- capabilities?: WorkspaceYaml['integrations'];
87
- playbooks?: WorkspaceYaml['playbooks'];
88
- onboarding?: WorkspaceYaml['onboarding'];
89
- }
90
- /**
91
- * Resolve a template (by slug or YAML object) into the full `PackageDefinition`
92
- * accepted by `POST /api/hub/packages/apply` and the CP registry seeder. This is
93
- * the single seam the CLI and control-plane use so they read from the canonical
94
- * package instead of disk-stored JSON.
95
- */
96
- export declare function toPackageDefinition(slugOrYaml: string | WorkspaceYaml): PackageDefinitionOutput;
97
- //# sourceMappingURL=define.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"define.d.ts","sourceRoot":"","sources":["../src/define.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGhD,mEAAmE;AACnE,MAAM,WAAW,wBAAwB;IACvC,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;IACpC,KAAK,EAAE,WAAW,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC;IAC3C,WAAW,EAAE,WAAW,CAAC,aAAa,CAAC,aAAa,CAAC,CAAC,CAAC;IACvD,YAAY,EAAE,WAAW,CAAC,aAAa,CAAC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,aAAa,CAAC,QAAQ,CAAC,CAAC;IACvC,YAAY,CAAC,EAAE,aAAa,CAAC,cAAc,CAAC,CAAC;IAC7C,SAAS,CAAC,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;IACvC,UAAU,CAAC,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC;CAC1C;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,UAAU,EAAE,MAAM,GAAG,aAAa,GACjC,uBAAuB,CAuCzB"}
package/dist/define.js DELETED
@@ -1,91 +0,0 @@
1
- /**
2
- * @synap-core/workspace-templates — Definition adapter
3
- *
4
- * Converts a YAML template (WorkspaceYaml) into the flat payload shape that
5
- * the backend `workspaces.createFromDefinition` mutation + Hub REST
6
- * `/workspaces/from-definition` endpoint expect.
7
- *
8
- * This is the single canonical seam: every consumer (browser app, onboarding,
9
- * CLI, marketplace) provisions a workspace through this function so the wire
10
- * shape never drifts per call-site.
11
- */
12
- import { getWorkspaceTemplate } from './templates.js';
13
- /**
14
- * Resolve a template (by slug or YAML object) into the createFromDefinition
15
- * payload. Pass `nameOverride` to rename the workspace at creation time.
16
- */
17
- export function toWorkspaceDefinition(slugOrYaml, nameOverride) {
18
- const tpl = typeof slugOrYaml === 'string' ? getWorkspaceTemplate(slugOrYaml) : slugOrYaml;
19
- if (!tpl) {
20
- throw new Error(`Workspace template not found: ${String(slugOrYaml)}`);
21
- }
22
- const ws = tpl.workspace;
23
- const name = nameOverride ?? ws.name;
24
- const proposalId = ws.proposalId ?? `${tpl.meta.slug}-v1`;
25
- const definition = {
26
- workspaceName: name,
27
- description: ws.description,
28
- proposalId,
29
- profiles: tpl.profiles,
30
- views: tpl.views ?? [],
31
- entityLinks: tpl.entityLinks ?? [],
32
- seedEntities: tpl.seedEntities ?? [],
33
- suggestedRelations: tpl.suggestedRelations,
34
- displayTemplates: tpl.displayTemplates,
35
- layoutConfig: tpl.layout,
36
- bentoViewName: tpl.bento?.viewName,
37
- bentoViewBlocks: tpl.bento?.blocks,
38
- profileEntityBentoTemplates: tpl.profileEntityBentoTemplates,
39
- workspaceSubtype: ws.subtype,
40
- workspaceType: ws.workspaceType,
41
- workspaceVisibility: ws.visibility,
42
- workspaceCapabilities: ws.capabilities,
43
- sourceRoles: ws.sourceRoles,
44
- defaultSources: ws.defaultSources,
45
- onboarding: tpl.onboarding,
46
- };
47
- return { definition, proposalId, workspaceName: name, templateId: tpl.meta.slug };
48
- }
49
- /**
50
- * Resolve a template (by slug or YAML object) into the full `PackageDefinition`
51
- * accepted by `POST /api/hub/packages/apply` and the CP registry seeder. This is
52
- * the single seam the CLI and control-plane use so they read from the canonical
53
- * package instead of disk-stored JSON.
54
- */
55
- export function toPackageDefinition(slugOrYaml) {
56
- const tpl = typeof slugOrYaml === 'string' ? getWorkspaceTemplate(slugOrYaml) : slugOrYaml;
57
- if (!tpl) {
58
- throw new Error(`Workspace template not found: ${String(slugOrYaml)}`);
59
- }
60
- const ws = tpl.workspace;
61
- return {
62
- _meta: {
63
- slug: tpl.meta.slug,
64
- icon: tpl.meta.icon,
65
- color: tpl.meta.color,
66
- tags: tpl.meta.tags,
67
- isPublic: tpl.meta.isPublic ?? true,
68
- },
69
- workspaceName: ws.name,
70
- description: ws.description,
71
- workspaceType: ws.workspaceType,
72
- workspaceSubtype: ws.subtype,
73
- workspaceVisibility: ws.visibility,
74
- workspaceCapabilities: ws.capabilities,
75
- sourceRoles: ws.sourceRoles,
76
- defaultSources: ws.defaultSources,
77
- profiles: tpl.profiles,
78
- views: tpl.views ?? [],
79
- suggestedEntities: tpl.seedEntities ?? [],
80
- suggestedRelations: tpl.suggestedRelations,
81
- displayTemplates: tpl.displayTemplates,
82
- entityLinks: tpl.entityLinks,
83
- bentoLayout: tpl.bento?.blocks,
84
- bentoViewName: tpl.bento?.viewName,
85
- profileEntityBentoTemplates: tpl.profileEntityBentoTemplates,
86
- layoutConfig: tpl.layout,
87
- capabilities: tpl.integrations,
88
- playbooks: tpl.playbooks,
89
- onboarding: tpl.onboarding,
90
- };
91
- }
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,YAAY,EACV,aAAa,EACb,YAAY,EACZ,cAAc,EACd,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,mBAAmB,EACnB,sBAAsB,EACtB,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,yBAAyB,EACzB,uBAAuB,EACvB,mBAAmB,EACnB,kBAAkB,EAClB,kBAAkB,EAClB,mCAAmC,EACnC,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,+BAA+B,EAC/B,gBAAgB,EAChB,qBAAqB,GACtB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,mBAAmB,EACnB,oBAAoB,EACpB,sBAAsB,EACtB,mBAAmB,GACpB,MAAM,gBAAgB,CAAC;AAExB,YAAY,EAAE,qBAAqB,EAAE,MAAM,gBAAgB,CAAC;AAE5D,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACzE,YAAY,EACV,wBAAwB,EACxB,kBAAkB,EAClB,uBAAuB,GACxB,MAAM,aAAa,CAAC"}
@@ -1,7 +0,0 @@
1
- import type { WorkspaceYaml } from './types.js';
2
- export declare const WORKSPACE_TEMPLATES: Record<string, WorkspaceYaml>;
3
- export type WorkspaceTemplateSlug = keyof typeof WORKSPACE_TEMPLATES;
4
- export declare function getWorkspaceTemplate(slug: string): WorkspaceYaml | undefined;
5
- export declare function listWorkspaceTemplates(): WorkspaceYaml[];
6
- export declare function listPublicTemplates(): WorkspaceYaml[];
7
- //# sourceMappingURL=templates.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../src/templates.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAkqvBhD,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAQ,CAAC;AAEvE,MAAM,MAAM,qBAAqB,GAAG,MAAM,OAAO,mBAAmB,CAAC;AAErE,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa,GAAG,SAAS,CAE5E;AAED,wBAAgB,sBAAsB,IAAI,aAAa,EAAE,CAExD;AAED,wBAAgB,mBAAmB,IAAI,aAAa,EAAE,CAErD"}