@synap-core/workspace-templates 0.2.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.
- package/dist/define.d.ts +97 -0
- package/dist/define.d.ts.map +1 -0
- package/dist/define.js +91 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/templates.d.ts +7 -0
- package/dist/templates.d.ts.map +1 -0
- package/dist/templates.js +23354 -0
- package/dist/types.d.ts +328 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +8 -0
- package/package.json +37 -0
- package/src/agent-fleet.yaml +1434 -0
- package/src/brand-library.yaml +627 -0
- package/src/builder.yaml +1355 -0
- package/src/content-os.yaml +1424 -0
- package/src/content-studio.yaml +312 -0
- package/src/crm.yaml +2606 -0
- package/src/define.ts +184 -0
- package/src/dev-dashboard.yaml +1309 -0
- package/src/foundation.yaml +343 -0
- package/src/index.ts +62 -0
- package/src/life-os.yaml +1443 -0
- package/src/marketing.yaml +244 -0
- package/src/personal.yaml +114 -0
- package/src/project-management.yaml +1119 -0
- package/src/radar.yaml +274 -0
- package/src/templates.ts +23363 -0
- package/src/types.ts +426 -0
package/src/define.ts
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
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
|
+
|
|
13
|
+
import type { WorkspaceYaml } from './types.js';
|
|
14
|
+
import { getWorkspaceTemplate } from './templates.js';
|
|
15
|
+
|
|
16
|
+
/** The flat definition object accepted by createFromDefinition. */
|
|
17
|
+
export interface WorkspaceDefinitionInput {
|
|
18
|
+
workspaceName: string;
|
|
19
|
+
description: string;
|
|
20
|
+
proposalId?: string;
|
|
21
|
+
profiles: WorkspaceYaml['profiles'];
|
|
22
|
+
views: NonNullable<WorkspaceYaml['views']>;
|
|
23
|
+
entityLinks: NonNullable<WorkspaceYaml['entityLinks']>;
|
|
24
|
+
seedEntities: NonNullable<WorkspaceYaml['seedEntities']>;
|
|
25
|
+
suggestedRelations?: WorkspaceYaml['suggestedRelations'];
|
|
26
|
+
displayTemplates?: WorkspaceYaml['displayTemplates'];
|
|
27
|
+
layoutConfig: WorkspaceYaml['layout'] | undefined;
|
|
28
|
+
bentoViewName?: string;
|
|
29
|
+
bentoViewBlocks?: NonNullable<WorkspaceYaml['bento']>['blocks'];
|
|
30
|
+
profileEntityBentoTemplates?: WorkspaceYaml['profileEntityBentoTemplates'];
|
|
31
|
+
// Workspace-level metadata (flattened from the `workspace` block)
|
|
32
|
+
workspaceSubtype?: string;
|
|
33
|
+
workspaceType?: NonNullable<WorkspaceYaml['workspace']>['workspaceType'];
|
|
34
|
+
workspaceVisibility?: string;
|
|
35
|
+
workspaceCapabilities?: string[];
|
|
36
|
+
sourceRoles?: NonNullable<WorkspaceYaml['workspace']>['sourceRoles'];
|
|
37
|
+
defaultSources?: NonNullable<WorkspaceYaml['workspace']>['defaultSources'];
|
|
38
|
+
/** Per-workspace onboarding context — written to settings.onboarding. */
|
|
39
|
+
onboarding?: WorkspaceYaml['onboarding'];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface ToDefinitionResult {
|
|
43
|
+
definition: WorkspaceDefinitionInput;
|
|
44
|
+
/** Stable idempotency key — the template's proposalId or slug. */
|
|
45
|
+
proposalId: string;
|
|
46
|
+
/** Display name for the new workspace. */
|
|
47
|
+
workspaceName: string;
|
|
48
|
+
/** Template id for telemetry / dedup. */
|
|
49
|
+
templateId: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Resolve a template (by slug or YAML object) into the createFromDefinition
|
|
54
|
+
* payload. Pass `nameOverride` to rename the workspace at creation time.
|
|
55
|
+
*/
|
|
56
|
+
export function toWorkspaceDefinition(
|
|
57
|
+
slugOrYaml: string | WorkspaceYaml,
|
|
58
|
+
nameOverride?: string,
|
|
59
|
+
): ToDefinitionResult {
|
|
60
|
+
const tpl: WorkspaceYaml | undefined =
|
|
61
|
+
typeof slugOrYaml === 'string' ? getWorkspaceTemplate(slugOrYaml) : slugOrYaml;
|
|
62
|
+
|
|
63
|
+
if (!tpl) {
|
|
64
|
+
throw new Error(`Workspace template not found: ${String(slugOrYaml)}`);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const ws = tpl.workspace;
|
|
68
|
+
const name = nameOverride ?? ws.name;
|
|
69
|
+
const proposalId = ws.proposalId ?? `${tpl.meta.slug}-v1`;
|
|
70
|
+
|
|
71
|
+
const definition: WorkspaceDefinitionInput = {
|
|
72
|
+
workspaceName: name,
|
|
73
|
+
description: ws.description,
|
|
74
|
+
proposalId,
|
|
75
|
+
profiles: tpl.profiles,
|
|
76
|
+
views: tpl.views ?? [],
|
|
77
|
+
entityLinks: tpl.entityLinks ?? [],
|
|
78
|
+
seedEntities: tpl.seedEntities ?? [],
|
|
79
|
+
suggestedRelations: tpl.suggestedRelations,
|
|
80
|
+
displayTemplates: tpl.displayTemplates,
|
|
81
|
+
layoutConfig: tpl.layout,
|
|
82
|
+
bentoViewName: tpl.bento?.viewName,
|
|
83
|
+
bentoViewBlocks: tpl.bento?.blocks,
|
|
84
|
+
profileEntityBentoTemplates: tpl.profileEntityBentoTemplates,
|
|
85
|
+
workspaceSubtype: ws.subtype,
|
|
86
|
+
workspaceType: ws.workspaceType,
|
|
87
|
+
workspaceVisibility: ws.visibility,
|
|
88
|
+
workspaceCapabilities: ws.capabilities,
|
|
89
|
+
sourceRoles: ws.sourceRoles,
|
|
90
|
+
defaultSources: ws.defaultSources,
|
|
91
|
+
onboarding: tpl.onboarding,
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
return { definition, proposalId, workspaceName: name, templateId: tpl.meta.slug };
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* The unified `PackageDefinition` shape consumed by `POST /api/hub/packages/apply`
|
|
99
|
+
* (CLI `synap launch`) and the CP package registry seeder. It composes the
|
|
100
|
+
* workspace definition with the capability/playbook/onboarding layers. Mirrors
|
|
101
|
+
* `PackageDefinition` in synap-backend `package-definition.ts`. Typed loosely on
|
|
102
|
+
* the layered fields to avoid a backend import; the wire validation lives in the
|
|
103
|
+
* apply endpoint.
|
|
104
|
+
*/
|
|
105
|
+
export interface PackageDefinitionOutput {
|
|
106
|
+
_meta: {
|
|
107
|
+
slug: string;
|
|
108
|
+
icon?: string;
|
|
109
|
+
color?: string;
|
|
110
|
+
tags?: string[];
|
|
111
|
+
isPublic?: boolean;
|
|
112
|
+
requiredTier?: string | null;
|
|
113
|
+
};
|
|
114
|
+
workspaceName: string;
|
|
115
|
+
description: string;
|
|
116
|
+
workspaceType?: WorkspaceYaml['workspace']['workspaceType'];
|
|
117
|
+
workspaceSubtype?: string;
|
|
118
|
+
workspaceVisibility?: string;
|
|
119
|
+
workspaceCapabilities?: string[];
|
|
120
|
+
sourceRoles?: WorkspaceYaml['workspace']['sourceRoles'];
|
|
121
|
+
defaultSources?: WorkspaceYaml['workspace']['defaultSources'];
|
|
122
|
+
profiles: WorkspaceYaml['profiles'];
|
|
123
|
+
views: NonNullable<WorkspaceYaml['views']>;
|
|
124
|
+
suggestedEntities: NonNullable<WorkspaceYaml['seedEntities']>;
|
|
125
|
+
suggestedRelations?: WorkspaceYaml['suggestedRelations'];
|
|
126
|
+
displayTemplates?: WorkspaceYaml['displayTemplates'];
|
|
127
|
+
entityLinks?: WorkspaceYaml['entityLinks'];
|
|
128
|
+
bentoLayout?: NonNullable<WorkspaceYaml['bento']>['blocks'];
|
|
129
|
+
bentoViewName?: string;
|
|
130
|
+
profileEntityBentoTemplates?: WorkspaceYaml['profileEntityBentoTemplates'];
|
|
131
|
+
layoutConfig?: WorkspaceYaml['layout'];
|
|
132
|
+
capabilities?: WorkspaceYaml['integrations'];
|
|
133
|
+
playbooks?: WorkspaceYaml['playbooks'];
|
|
134
|
+
onboarding?: WorkspaceYaml['onboarding'];
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Resolve a template (by slug or YAML object) into the full `PackageDefinition`
|
|
139
|
+
* accepted by `POST /api/hub/packages/apply` and the CP registry seeder. This is
|
|
140
|
+
* the single seam the CLI and control-plane use so they read from the canonical
|
|
141
|
+
* package instead of disk-stored JSON.
|
|
142
|
+
*/
|
|
143
|
+
export function toPackageDefinition(
|
|
144
|
+
slugOrYaml: string | WorkspaceYaml,
|
|
145
|
+
): PackageDefinitionOutput {
|
|
146
|
+
const tpl: WorkspaceYaml | undefined =
|
|
147
|
+
typeof slugOrYaml === 'string' ? getWorkspaceTemplate(slugOrYaml) : slugOrYaml;
|
|
148
|
+
|
|
149
|
+
if (!tpl) {
|
|
150
|
+
throw new Error(`Workspace template not found: ${String(slugOrYaml)}`);
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const ws = tpl.workspace;
|
|
154
|
+
return {
|
|
155
|
+
_meta: {
|
|
156
|
+
slug: tpl.meta.slug,
|
|
157
|
+
icon: tpl.meta.icon,
|
|
158
|
+
color: tpl.meta.color,
|
|
159
|
+
tags: tpl.meta.tags,
|
|
160
|
+
isPublic: tpl.meta.isPublic ?? true,
|
|
161
|
+
},
|
|
162
|
+
workspaceName: ws.name,
|
|
163
|
+
description: ws.description,
|
|
164
|
+
workspaceType: ws.workspaceType,
|
|
165
|
+
workspaceSubtype: ws.subtype,
|
|
166
|
+
workspaceVisibility: ws.visibility,
|
|
167
|
+
workspaceCapabilities: ws.capabilities,
|
|
168
|
+
sourceRoles: ws.sourceRoles,
|
|
169
|
+
defaultSources: ws.defaultSources,
|
|
170
|
+
profiles: tpl.profiles,
|
|
171
|
+
views: tpl.views ?? [],
|
|
172
|
+
suggestedEntities: tpl.seedEntities ?? [],
|
|
173
|
+
suggestedRelations: tpl.suggestedRelations,
|
|
174
|
+
displayTemplates: tpl.displayTemplates,
|
|
175
|
+
entityLinks: tpl.entityLinks,
|
|
176
|
+
bentoLayout: tpl.bento?.blocks,
|
|
177
|
+
bentoViewName: tpl.bento?.viewName,
|
|
178
|
+
profileEntityBentoTemplates: tpl.profileEntityBentoTemplates,
|
|
179
|
+
layoutConfig: tpl.layout,
|
|
180
|
+
capabilities: tpl.integrations,
|
|
181
|
+
playbooks: tpl.playbooks,
|
|
182
|
+
onboarding: tpl.onboarding,
|
|
183
|
+
};
|
|
184
|
+
}
|