@synap-core/workspace-templates 0.75.0 → 0.76.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 +17 -0
- package/dist/{define-gpV3Inzh.d.ts → define-BkLLS_UL.d.ts} +14 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1280 -113
- package/dist/index.js.map +1 -1
- package/dist/wire.d.ts +1 -1
- package/package.json +1 -1
- package/src/brand-library.yaml +4 -1
- package/src/content-os.piece-model.template.test.ts +52 -31
- package/src/content-os.space-contract.template.test.ts +158 -0
- package/src/content-os.template.test.ts +21 -8
- package/src/content-os.video-takes.template.test.ts +2 -2
- package/src/content-os.yaml +1624 -178
- package/src/crm.yaml +2 -1
- package/src/frame-host-modules.d.mts +1 -1
- package/src/frame-host-modules.mjs +5 -2
- package/src/lifecycle-declarations.test.ts +5 -0
- package/src/onboarding-intents.validate.test.ts +85 -0
- package/src/property-relation.validate.test.ts +218 -0
- package/src/social.yaml +5 -2
- package/src/templates.ts +1152 -112
- package/src/types.ts +14 -0
- package/src/validate.ts +181 -2
package/src/crm.yaml
CHANGED
|
@@ -2662,7 +2662,8 @@ playbooks:
|
|
|
2662
2662
|
documents.get, lens.page, sessions.get, playbook.process,
|
|
2663
2663
|
playbook.scorecard, project.pillars, views.get, views.execute,
|
|
2664
2664
|
profiles.get, propertyDefs.list, lifecycle.get, graph.of,
|
|
2665
|
-
automations.list, automations.runs, playbooks.list, surfaces.of
|
|
2665
|
+
automations.list, automations.runs, playbooks.list, surfaces.of,
|
|
2666
|
+
connections.list, capabilities.list) and only that
|
|
2666
2667
|
op's params; the host stamps the space, so never put a workspaceId, a token, a pod URL
|
|
2667
2668
|
or a fetch in the page. What the bridge reads stays live: query it in
|
|
2668
2669
|
the page, never
|
|
@@ -3,4 +3,4 @@ export declare const FRAME_HOST_MODULES: readonly string[];
|
|
|
3
3
|
export declare const FRAME_HOST_MODULE_RE: RegExp;
|
|
4
4
|
export declare function hostRequiresIn(code: string): string[];
|
|
5
5
|
export declare const FRAME_KIT_MODULE: string;
|
|
6
|
-
export declare function kitImportsIn(code: string): string[];
|
|
6
|
+
export declare function kitImportsIn(code: string, specifier?: string): string[];
|
|
@@ -24,10 +24,13 @@ export const FRAME_KIT_MODULE = '@synap/kit';
|
|
|
24
24
|
* Every name a bundle imports from the kit: `import{A as b,C}from"@synap/kit"`
|
|
25
25
|
* → `['A', 'C']`. A namespace or default import of the kit is returned as
|
|
26
26
|
* `*` / `default` so the build can refuse it (its names cannot be checked).
|
|
27
|
+
* `specifier`: another host module read the same way (a kit layer,
|
|
28
|
+
* `@synap/kit/editor`).
|
|
27
29
|
*/
|
|
28
|
-
export function kitImportsIn(code) {
|
|
30
|
+
export function kitImportsIn(code, specifier = FRAME_KIT_MODULE) {
|
|
29
31
|
const names = new Set();
|
|
30
|
-
|
|
32
|
+
const quoted = specifier.replace(/[/.\-]/g, '\\$&');
|
|
33
|
+
for (const m of code.matchAll(new RegExp(`import\\s*([^;'"]*?)\\s*from\\s*["']${quoted}["']`, 'g'))) {
|
|
31
34
|
const clause = m[1];
|
|
32
35
|
const braces = /\{([^}]*)\}/.exec(clause);
|
|
33
36
|
for (const part of braces ? braces[1].split(',') : []) {
|
|
@@ -303,6 +303,7 @@ describe("lifecycle declarations — coverage (derived from the playbooks)", ()
|
|
|
303
303
|
"brand-library:brand-asset.deprecated",
|
|
304
304
|
"brand-library:brand-voice-guide.approved",
|
|
305
305
|
"brand-library:brand-voice-guide.deprecated",
|
|
306
|
+
"brand-library:content-guideline.approved",
|
|
306
307
|
"brand-library:content-guideline.deprecated",
|
|
307
308
|
"builder-workspace:devplane_feature.cancelled",
|
|
308
309
|
"builder-workspace:devplane_story.dropped",
|
|
@@ -320,6 +321,8 @@ describe("lifecycle declarations — coverage (derived from the playbooks)", ()
|
|
|
320
321
|
"content-os:content-composition.approved",
|
|
321
322
|
"content-os:newsletter.Archived",
|
|
322
323
|
"content-os:post.Archived",
|
|
324
|
+
"content-os:post.Idea",
|
|
325
|
+
"content-os:post.Scheduled",
|
|
323
326
|
"crm:campaign.cancelled",
|
|
324
327
|
"crm:campaign.paused",
|
|
325
328
|
"crm:deal.lost",
|
|
@@ -340,6 +343,8 @@ describe("lifecycle declarations — coverage (derived from the playbooks)", ()
|
|
|
340
343
|
"operations:engagement.cancelled",
|
|
341
344
|
"operations:engagement.on-hold",
|
|
342
345
|
"social:post.Archived",
|
|
346
|
+
"social:post.Idea",
|
|
347
|
+
"social:post.Scheduled",
|
|
343
348
|
];
|
|
344
349
|
|
|
345
350
|
it("humanOnly sits on the kind's lifecycle, exactly the ledger", () => {
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The declared requests of a space (`onboarding.intents`, space contract L3,
|
|
3
|
+
* backend #1521) are checked at authoring time with the pod's own caps, because
|
|
4
|
+
* the pod CLIPS, DROPS or never MATCHES what breaks them, silently:
|
|
5
|
+
* - more than 8 phrases: the first 8 are kept;
|
|
6
|
+
* - a phrase over 80 characters: clipped;
|
|
7
|
+
* - a phrase of fewer than two meaningful words: routes nothing (the pod's
|
|
8
|
+
* matcher needs two shared words, or the whole phrase);
|
|
9
|
+
* - a locale that is not a BCP 47 language: dropped;
|
|
10
|
+
* - a repeat: dropped.
|
|
11
|
+
*
|
|
12
|
+
* Each rule has a failing fixture built by mutating ONE field of a clean one,
|
|
13
|
+
* and the clean one is asserted clean, so a fixture that fails for another
|
|
14
|
+
* reason cannot pass for the wrong one. Does NOT cover what `find` does with
|
|
15
|
+
* the phrases at run time (the pod's own tests).
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import { describe, expect, it } from "vitest";
|
|
19
|
+
import {
|
|
20
|
+
SPACE_INTENT_COUNT_CAP,
|
|
21
|
+
SPACE_INTENT_PHRASE_CAP,
|
|
22
|
+
intentMeaningfulWords,
|
|
23
|
+
validateTemplate,
|
|
24
|
+
} from "./validate.js";
|
|
25
|
+
import type { WorkspaceYaml } from "./types.js";
|
|
26
|
+
|
|
27
|
+
const tplWith = (intents: unknown): WorkspaceYaml =>
|
|
28
|
+
({
|
|
29
|
+
meta: {
|
|
30
|
+
slug: "intents-fixture",
|
|
31
|
+
name: "Intents fixture",
|
|
32
|
+
description: "Validation fixture",
|
|
33
|
+
icon: "circle",
|
|
34
|
+
color: "blue",
|
|
35
|
+
},
|
|
36
|
+
workspace: { name: "Intents fixture", description: "Validation fixture" },
|
|
37
|
+
profiles: [{ slug: "record", displayName: "Record", properties: [] }],
|
|
38
|
+
onboarding: { purpose: "Keep records.", intents },
|
|
39
|
+
}) as unknown as WorkspaceYaml;
|
|
40
|
+
|
|
41
|
+
const rulesOf = (intents: unknown) =>
|
|
42
|
+
validateTemplate(tplWith(intents), {})
|
|
43
|
+
.errors.filter((e) => e.rule.startsWith("onboarding-intent"))
|
|
44
|
+
.map((e) => e.rule);
|
|
45
|
+
|
|
46
|
+
const CLEAN = [
|
|
47
|
+
{ phrase: "write a LinkedIn post", locale: "en" },
|
|
48
|
+
{ phrase: "rédiger un post LinkedIn", locale: "fr" },
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
describe("onboarding.intents", () => {
|
|
52
|
+
it("mirrors the pod's caps (8 phrases of 80 characters)", () => {
|
|
53
|
+
expect(SPACE_INTENT_COUNT_CAP).toBe(8);
|
|
54
|
+
expect(SPACE_INTENT_PHRASE_CAP).toBe(80);
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it("a clean list is clean (so each fixture below fails for its own reason)", () => {
|
|
58
|
+
expect(rulesOf(CLEAN)).toEqual([]);
|
|
59
|
+
expect(rulesOf(undefined)).toEqual([]);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it("more than 8 phrases", () => {
|
|
63
|
+
const nine = Array.from({ length: 9 }, (_, i) => ({ phrase: `plan thing number${i}`, locale: "en" }));
|
|
64
|
+
expect(rulesOf(nine)).toEqual(["onboarding-intents-too-many"]);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it("a phrase over 80 characters", () => {
|
|
68
|
+
expect(rulesOf([{ phrase: `write ${"x".repeat(80)}` }])).toEqual(["onboarding-intent-too-long"]);
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("a phrase of one meaningful word, or only glue words, routes nothing", () => {
|
|
72
|
+
expect(rulesOf([{ phrase: "write" }])).toEqual(["onboarding-intent-words"]);
|
|
73
|
+
expect(rulesOf([{ phrase: "how do I" }])).toEqual(["onboarding-intent-words"]);
|
|
74
|
+
expect(rulesOf([{ phrase: "pour le de" }])).toEqual(["onboarding-intent-words"]);
|
|
75
|
+
expect(intentMeaningfulWords("rédiger un post LinkedIn")).toBe(3);
|
|
76
|
+
expect(intentMeaningfulWords("écrire l’histoire de notre marque")).toBe(3);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it("a locale that is not a language, a bare string, a repeat, a non-list", () => {
|
|
80
|
+
expect(rulesOf([{ phrase: "write a post", locale: "english" }])).toEqual(["onboarding-intent-locale"]);
|
|
81
|
+
expect(rulesOf(["write a post"])).toEqual(["onboarding-intent-invalid"]);
|
|
82
|
+
expect(rulesOf([{ phrase: "write a post" }, { phrase: "Write A Post" }])).toEqual(["onboarding-intent-duplicate"]);
|
|
83
|
+
expect(rulesOf("write a post")).toEqual(["onboarding-intents-invalid"]);
|
|
84
|
+
});
|
|
85
|
+
});
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A template property's `relation` is checked at authoring time
|
|
3
|
+
* (`checkPropertyRelations` in validate.ts) because the pod door
|
|
4
|
+
* (`resolvePropertyRelationDefs`, backend#1498) refuses the same four mistakes
|
|
5
|
+
* only as a report entry at apply time: the relation is then never set and no
|
|
6
|
+
* link is ever made.
|
|
7
|
+
*
|
|
8
|
+
* Each rule has a failing fixture built by mutating ONE field of a clean
|
|
9
|
+
* fixture, and the clean fixture is asserted clean, so a fixture that fails for
|
|
10
|
+
* an unrelated reason cannot pass for the wrong one.
|
|
11
|
+
*/
|
|
12
|
+
import { describe, expect, it } from "vitest";
|
|
13
|
+
import { validateTemplate } from "./validate.js";
|
|
14
|
+
import { getWorkspaceTemplate, WORKSPACE_TEMPLATES } from "./templates.js";
|
|
15
|
+
import type { WorkspaceYaml } from "./types.js";
|
|
16
|
+
|
|
17
|
+
const RULES = new Set([
|
|
18
|
+
"property-relation-invalid",
|
|
19
|
+
"property-relation-exposure",
|
|
20
|
+
"property-relation-not-entity-id",
|
|
21
|
+
"property-relation-unknown",
|
|
22
|
+
"property-relation-duplicate",
|
|
23
|
+
]);
|
|
24
|
+
|
|
25
|
+
const relErrors = (tpl: WorkspaceYaml, opts = {}) =>
|
|
26
|
+
validateTemplate(tpl, opts).errors.filter((e) => RULES.has(e.rule));
|
|
27
|
+
|
|
28
|
+
function fixture(
|
|
29
|
+
mutate: (
|
|
30
|
+
profiles: Record<string, any>[],
|
|
31
|
+
t: Record<string, any>
|
|
32
|
+
) => void = () => {}
|
|
33
|
+
): WorkspaceYaml {
|
|
34
|
+
const t: Record<string, any> = {
|
|
35
|
+
meta: {
|
|
36
|
+
slug: "rel",
|
|
37
|
+
name: "Rel",
|
|
38
|
+
description: "d",
|
|
39
|
+
icon: "x",
|
|
40
|
+
color: "gray",
|
|
41
|
+
},
|
|
42
|
+
workspace: { name: "Rel", description: "d" },
|
|
43
|
+
profiles: [
|
|
44
|
+
{
|
|
45
|
+
slug: "task",
|
|
46
|
+
displayName: "Task",
|
|
47
|
+
properties: [
|
|
48
|
+
{
|
|
49
|
+
slug: "task-project",
|
|
50
|
+
label: "Project",
|
|
51
|
+
valueType: "entity_id",
|
|
52
|
+
targetProfileSlug: "project",
|
|
53
|
+
inputType: "entity_select",
|
|
54
|
+
relation: "part_of_project",
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
slug: "task-owner",
|
|
58
|
+
label: "Owner",
|
|
59
|
+
valueType: "entity_id",
|
|
60
|
+
targetProfileSlug: "project",
|
|
61
|
+
inputType: "entity_select",
|
|
62
|
+
},
|
|
63
|
+
],
|
|
64
|
+
},
|
|
65
|
+
{ slug: "project", displayName: "Project", properties: [] },
|
|
66
|
+
],
|
|
67
|
+
entityLinks: [
|
|
68
|
+
{
|
|
69
|
+
sourceProfileSlug: "task",
|
|
70
|
+
targetProfileSlug: "project",
|
|
71
|
+
type: "part_of_project",
|
|
72
|
+
label: "Project",
|
|
73
|
+
},
|
|
74
|
+
],
|
|
75
|
+
relationDefs: [{ slug: "owned_by", displayName: "Owned by" }],
|
|
76
|
+
};
|
|
77
|
+
mutate(t.profiles, t);
|
|
78
|
+
return t as unknown as WorkspaceYaml;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
describe("property.relation validation", () => {
|
|
82
|
+
it("accepts a relation an entityLink defines, and one only relationDefs defines", () => {
|
|
83
|
+
expect(relErrors(fixture())).toEqual([]);
|
|
84
|
+
expect(
|
|
85
|
+
relErrors(
|
|
86
|
+
fixture((p) => {
|
|
87
|
+
p[0].properties[1].relation = "owned_by";
|
|
88
|
+
})
|
|
89
|
+
)
|
|
90
|
+
).toEqual([]);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it("rejects a relation no entityLinks / relationDefs defines", () => {
|
|
94
|
+
const errs = relErrors(
|
|
95
|
+
fixture((p) => {
|
|
96
|
+
p[0].properties[0].relation = "nope";
|
|
97
|
+
})
|
|
98
|
+
);
|
|
99
|
+
expect(errs.map((e) => e.rule)).toEqual(["property-relation-unknown"]);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it("rejects an exposure relation", () => {
|
|
103
|
+
const errs = relErrors(
|
|
104
|
+
fixture((p) => {
|
|
105
|
+
p[0].properties[0].relation = "visible_to";
|
|
106
|
+
})
|
|
107
|
+
);
|
|
108
|
+
expect(errs.map((e) => e.rule)).toEqual(["property-relation-exposure"]);
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
it("rejects a relation declared by two properties of one kind", () => {
|
|
112
|
+
const errs = relErrors(
|
|
113
|
+
fixture((p) => {
|
|
114
|
+
p[0].properties[1].relation = "part_of_project";
|
|
115
|
+
})
|
|
116
|
+
);
|
|
117
|
+
expect(errs.map((e) => e.rule)).toEqual(["property-relation-duplicate"]);
|
|
118
|
+
expect(errs[0].path).toBe("profiles.task.task-owner.relation");
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
it("accepts one relation declared by two properties of DIFFERENT kinds", () => {
|
|
122
|
+
// The sync is keyed on the source entity's profile: a task and a note
|
|
123
|
+
// pointing at a project through `part_of_project` write different rows.
|
|
124
|
+
expect(
|
|
125
|
+
relErrors(
|
|
126
|
+
fixture((p) => {
|
|
127
|
+
p[1].properties = [
|
|
128
|
+
{
|
|
129
|
+
slug: "project-parent",
|
|
130
|
+
label: "Parent",
|
|
131
|
+
valueType: "entity_id",
|
|
132
|
+
targetProfileSlug: "project",
|
|
133
|
+
inputType: "entity_select",
|
|
134
|
+
relation: "part_of_project",
|
|
135
|
+
},
|
|
136
|
+
];
|
|
137
|
+
})
|
|
138
|
+
)
|
|
139
|
+
).toEqual([]);
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
it("rejects a relation on a property that is not an entity_id", () => {
|
|
143
|
+
const errs = relErrors(
|
|
144
|
+
fixture((p) => {
|
|
145
|
+
p[0].properties[0].valueType = "string";
|
|
146
|
+
})
|
|
147
|
+
);
|
|
148
|
+
expect(errs.map((e) => e.rule)).toEqual([
|
|
149
|
+
"property-relation-not-entity-id",
|
|
150
|
+
]);
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
it("rejects an empty relation", () => {
|
|
154
|
+
const errs = relErrors(
|
|
155
|
+
fixture((p) => {
|
|
156
|
+
p[0].properties[0].relation = "";
|
|
157
|
+
})
|
|
158
|
+
);
|
|
159
|
+
expect(errs.map((e) => e.rule)).toEqual(["property-relation-invalid"]);
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
describe("Content OS: the post's references declare the relation they create", () => {
|
|
164
|
+
const tpl = getWorkspaceTemplate("content-os")!;
|
|
165
|
+
const rel = (slug: string) =>
|
|
166
|
+
tpl.profiles
|
|
167
|
+
.find((p) => p.slug === "post")
|
|
168
|
+
?.properties.find((d) => d.slug === slug);
|
|
169
|
+
|
|
170
|
+
it("post-campaign, post-pillar and post-series name the edge the template declares", () => {
|
|
171
|
+
expect(rel("post-campaign")?.relation).toBe("part_of_campaign");
|
|
172
|
+
expect(rel("post-pillar")?.relation).toBe("belongs_to_pillar");
|
|
173
|
+
expect(rel("post-series")?.relation).toBe("part_of_series");
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
it("an idea's pillar and campaign and a piece's campaign reuse the post's edges, one property per kind", () => {
|
|
177
|
+
const prop = (kind: string, slug: string) =>
|
|
178
|
+
tpl.profiles
|
|
179
|
+
.find((p) => p.slug === kind)
|
|
180
|
+
?.properties.find((d) => d.slug === slug);
|
|
181
|
+
expect(prop("idea", "idea-pillar")?.relation).toBe("belongs_to_pillar");
|
|
182
|
+
expect(prop("idea", "idea-campaign")?.relation).toBe("part_of_campaign");
|
|
183
|
+
expect(prop("content-composition", "composition-campaign")?.relation).toBe(
|
|
184
|
+
"part_of_campaign"
|
|
185
|
+
);
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
it("no kind declares one relation on two of its properties", () => {
|
|
189
|
+
for (const p of tpl.profiles) {
|
|
190
|
+
const rels = p.properties.flatMap((d) =>
|
|
191
|
+
d.relation ? [d.relation] : []
|
|
192
|
+
);
|
|
193
|
+
expect(new Set(rels).size, p.slug).toBe(rels.length);
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
it("every relation property is an entity_id whose entityLink goes to the property's target", () => {
|
|
198
|
+
for (const p of tpl.profiles)
|
|
199
|
+
for (const d of p.properties) {
|
|
200
|
+
if (!d.relation) continue;
|
|
201
|
+
expect(d.valueType).toBe("entity_id");
|
|
202
|
+
expect(
|
|
203
|
+
(tpl.entityLinks ?? []).some(
|
|
204
|
+
(l) =>
|
|
205
|
+
l.sourceProfileSlug === p.slug &&
|
|
206
|
+
l.type === d.relation &&
|
|
207
|
+
l.targetProfileSlug === d.targetProfileSlug
|
|
208
|
+
),
|
|
209
|
+
`${p.slug}.${d.slug}`
|
|
210
|
+
).toBe(true);
|
|
211
|
+
}
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
it("validates clean against the whole corpus", () => {
|
|
215
|
+
const corpus = Object.values(WORKSPACE_TEMPLATES) as WorkspaceYaml[];
|
|
216
|
+
expect(relErrors(tpl as WorkspaceYaml, { corpus })).toEqual([]);
|
|
217
|
+
});
|
|
218
|
+
});
|
package/src/social.yaml
CHANGED
|
@@ -162,13 +162,15 @@ profiles:
|
|
|
162
162
|
lifecycle:
|
|
163
163
|
property: post-status
|
|
164
164
|
options:
|
|
165
|
-
-
|
|
165
|
+
# Byte-identical to content-os's lifecycle (one declaration per kind).
|
|
166
|
+
- { key: Idea, category: open, humanOnly: true }
|
|
166
167
|
- { key: Briefed, category: active }
|
|
167
168
|
- { key: Scripted, category: active }
|
|
168
169
|
- { key: "In Draft", category: active }
|
|
169
170
|
- { key: Review, category: active }
|
|
170
|
-
- { key: Scheduled, category: active }
|
|
171
|
+
- { key: Scheduled, category: active, humanOnly: true }
|
|
171
172
|
- { key: Published, category: done }
|
|
173
|
+
- { key: Measured, category: done }
|
|
172
174
|
- { key: Archived, category: lost, humanOnly: true }
|
|
173
175
|
# How it renders (entity rendering, decision 8): @synap-core/types/presentation.
|
|
174
176
|
presentation:
|
|
@@ -187,6 +189,7 @@ profiles:
|
|
|
187
189
|
"Review",
|
|
188
190
|
"Scheduled",
|
|
189
191
|
"Published",
|
|
192
|
+
"Measured",
|
|
190
193
|
"Archived",
|
|
191
194
|
]
|
|
192
195
|
- slug: post-account
|