@synap-core/workspace-templates 0.77.0 → 0.78.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synap-core/workspace-templates",
3
- "version": "0.77.0",
3
+ "version": "0.78.0",
4
4
  "type": "module",
5
5
  "description": "Canonical workspace definitions — YAML source + typed exports for browser, backend, CLI, and marketplace",
6
6
  "license": "PolyForm-Noncommercial-1.0.0",
@@ -342,6 +342,8 @@ describe("lifecycle declarations — coverage (derived from the playbooks)", ()
342
342
  "operations:deliverable.cancelled",
343
343
  "operations:engagement.cancelled",
344
344
  "operations:engagement.on-hold",
345
+ "operations:estimate.accepted",
346
+ "operations:estimate.declined",
345
347
  "social:post.Archived",
346
348
  "social:post.Idea",
347
349
  "social:post.Scheduled",
@@ -0,0 +1,125 @@
1
+ /**
2
+ * Operations: the `estimate` kind (decision e480340b) and the rule that makes
3
+ * its references reach a kind on the pod. Read from the YAML SOURCE.
4
+ *
5
+ * Why the reference rule is its own test: `synap catalog validate` accepts a
6
+ * target from a DEPENDENCY's vocabulary, but the pod does not. Both provisioning
7
+ * doors resolve a kind this template does not declare with
8
+ * `getBySlugForWorkspace(slug, workspaceId)` and no user, which admits only a
9
+ * system kind, a kind homed in this space, or a shared kind granted to it; the
10
+ * grant is written by declaring the shared kind here (backend
11
+ * `resolve-property-target-profiles.ts`, `kindVisibleWhere`). An unresolved
12
+ * target leaves the picker unconstrained and an unresolved link is skipped,
13
+ * both silently. So every target here must be a system kind or a kind this
14
+ * template declares. Not covered: whether the PICKER lists entities homed in
15
+ * another space (a runtime read, not the template).
16
+ */
17
+ import { describe, expect, it } from "vitest";
18
+ import { readFileSync } from "node:fs";
19
+ import { dirname, join } from "node:path";
20
+ import { fileURLToPath } from "node:url";
21
+ import { load } from "js-yaml";
22
+ import type { WorkspaceYaml } from "./types.js";
23
+ import { SYSTEM_PROFILES } from "./validate.js";
24
+
25
+ const dir = dirname(fileURLToPath(import.meta.url));
26
+ const read = (f: string) =>
27
+ load(readFileSync(join(dir, `${f}.yaml`), "utf8")) as WorkspaceYaml;
28
+ const ops = read("operations");
29
+ const declared = new Set(ops.profiles.map((p) => p.slug));
30
+ const reachable = (slug: string) =>
31
+ SYSTEM_PROFILES.has(slug) || declared.has(slug);
32
+ const estimate = ops.profiles.find((p) => p.slug === "estimate");
33
+
34
+ describe("Operations: every kind a reference names resolves from this space", () => {
35
+ const targets = [
36
+ ...ops.profiles.flatMap((p) =>
37
+ p.properties
38
+ .filter((pr) => pr.valueType === "entity_id" && pr.targetProfileSlug)
39
+ .map((pr) => ({
40
+ at: `${p.slug}.${pr.slug}`,
41
+ slug: pr.targetProfileSlug!,
42
+ }))
43
+ ),
44
+ ...(ops.entityLinks ?? []).flatMap((l) => [
45
+ { at: `entityLinks ${l.type} source`, slug: l.sourceProfileSlug },
46
+ { at: `entityLinks ${l.type} target`, slug: l.targetProfileSlug },
47
+ ]),
48
+ ];
49
+
50
+ it("finds the references it guards (non-vacuity)", () => {
51
+ expect(targets.length).toBeGreaterThanOrEqual(15);
52
+ expect(targets.map((t) => t.at)).toContain("estimate.estimate-template");
53
+ // The rule can still see a miss: Finance's invoice is neither system nor declared here.
54
+ expect(reachable("invoice")).toBe(false);
55
+ });
56
+
57
+ it("each is a system kind or a kind this template declares", () => {
58
+ expect(targets.filter((t) => !reachable(t.slug))).toEqual([]);
59
+ });
60
+
61
+ it("a shared kind restated with no body is required from a template that holds the body", () => {
62
+ const refs = ops.profiles.filter(
63
+ (p) =>
64
+ (p.scope ?? "").toLowerCase() === "shared" && p.properties.length === 0
65
+ );
66
+ expect(refs.map((p) => p.slug).sort()).toEqual([
67
+ "brand-template",
68
+ "client",
69
+ ]);
70
+ const required = (ops.dependencies ?? [])
71
+ .filter((d) => d.kind === "workspace" && d.relation === "require")
72
+ .map((d) => read(d.slug));
73
+ for (const ref of refs)
74
+ expect(
75
+ required.some((t) =>
76
+ t.profiles.some((p) => p.slug === ref.slug && p.properties.length > 0)
77
+ ),
78
+ ref.slug
79
+ ).toBe(true);
80
+ });
81
+ });
82
+
83
+ describe("Operations: the estimate kind", () => {
84
+ it("declares its lifecycle once, accepting and declining by a person only", () => {
85
+ expect(estimate?.lifecycle?.property).toBe("estimate-status");
86
+ expect(
87
+ estimate?.lifecycle?.options.map((o) => [
88
+ o.key,
89
+ o.category,
90
+ o.humanOnly === true,
91
+ ])
92
+ ).toEqual([
93
+ ["draft", "open", false],
94
+ ["sent", "active", false],
95
+ ["accepted", "done", true],
96
+ ["declined", "lost", true],
97
+ ["expired", "lost", false],
98
+ ["superseded", "lost", false],
99
+ ]);
100
+ });
101
+
102
+ it("links its deal through the estimate-deal property, and declares its other edges", () => {
103
+ const deal = estimate?.properties.find((p) => p.slug === "estimate-deal");
104
+ expect(deal?.relation).toBe("estimate_for_deal");
105
+ const links = new Set(
106
+ (ops.entityLinks ?? []).map(
107
+ (l) => `${l.sourceProfileSlug}>${l.targetProfileSlug}:${l.type}`
108
+ )
109
+ );
110
+ for (const at of [
111
+ "estimate>deal:estimate_for_deal",
112
+ "estimate>contract:estimate_becomes_contract",
113
+ "estimate>estimate:revises",
114
+ ])
115
+ expect(links.has(at), at).toBe(true);
116
+ });
117
+
118
+ it("stores its lines as a list, amounts in minor units", () => {
119
+ const lines = estimate?.properties.find((p) => p.slug === "estimate-lines");
120
+ expect(lines?.valueType).toBe("array");
121
+ expect(
122
+ (lines as { description?: string } | undefined)?.description
123
+ ).toMatch(/minor units/);
124
+ });
125
+ });
@@ -78,6 +78,19 @@ dependencies:
78
78
  kind: workspace
79
79
  relation: require
80
80
  reason: "Provides the pod-wide `client` role this space onboards and serves (Clients board, Onboard a client) and its automations query."
81
+ # An estimate names the brand-template it is generated from
82
+ # (`estimate-template`). `brand-template` is Brand Library's `scope: shared`
83
+ # kind, home Content OS on a live pod: a template property resolves a kind it
84
+ # does not declare only when the kind is system, homed here, or shared AND
85
+ # granted to this space (`resolve-property-target-profiles.ts`). Operations
86
+ # re-declares it below to get that grant, as content-os does; requiring
87
+ # brand-library installs its FULL body first, so the reference never takes
88
+ # the pod-wide seat with an empty one (lead decision, estimate session
89
+ # f4d1244f, 4 Dec 2026).
90
+ - slug: brand-library
91
+ kind: workspace
92
+ relation: require
93
+ reason: "Provides the shared brand-template kind an estimate is generated from."
81
94
 
82
95
  profiles:
83
96
  # The pod-wide `client` role, REFERENCED (foundation's SSOT body; crm.yaml
@@ -252,6 +265,103 @@ profiles:
252
265
  valueType: string
253
266
  inputType: textarea
254
267
 
268
+ # A priced quote for a client, made before any contract (decision e480340b:
269
+ # its own kind, not a contract type or child; it links deal, contract and
270
+ # invoice). One deal has several estimates; a change after `sent` is a new
271
+ # estimate (version 2) that `revises` the old one, which becomes
272
+ # `superseded`. Amounts are integers in MINOR units (cents), the first kind
273
+ # to do so: moving an estimate to a contract needs a conversion. Synap never
274
+ # issues the invoice (decision 0b40ddbd): an estimate links its invoices with
275
+ # the pod-wide `relates_to` for now (see entityLinks below).
276
+ - slug: estimate
277
+ displayName: Estimate
278
+ icon: calculator
279
+ description: "A priced quote for a client, sent before any contract — its lines, currency, VAT, version and the date it is valid until."
280
+ # The ONE lifecycle (work model L1). Accepting and declining are the
281
+ # client's answer, recorded by a person; `expired` will be set by an
282
+ # automation and `superseded` when the next version is made (later slices).
283
+ lifecycle:
284
+ property: estimate-status
285
+ options:
286
+ - { key: draft, category: open }
287
+ - { key: sent, category: active }
288
+ - { key: accepted, category: done, humanOnly: true }
289
+ - { key: declined, category: lost, humanOnly: true }
290
+ - { key: expired, category: lost }
291
+ - { key: superseded, category: lost }
292
+ properties:
293
+ - slug: estimate-status
294
+ label: Status
295
+ valueType: string
296
+ inputType: select
297
+ enumValues: [draft, sent, accepted, declined, expired, superseded]
298
+ constraints: { defaultValue: draft }
299
+ # Written by hand: nothing numbers estimates yet.
300
+ - slug: estimate-number
301
+ label: Number
302
+ valueType: string
303
+ inputType: text
304
+ - slug: estimate-version
305
+ label: Version
306
+ valueType: number
307
+ inputType: number
308
+ constraints: { defaultValue: 1 }
309
+ - slug: issued-date
310
+ label: Issued
311
+ valueType: date
312
+ inputType: date
313
+ - slug: valid-until
314
+ label: Valid until
315
+ valueType: date
316
+ inputType: date
317
+ # ISO 4217 code.
318
+ - slug: estimate-currency
319
+ label: Currency
320
+ valueType: string
321
+ inputType: text
322
+ constraints: { defaultValue: EUR }
323
+ # Basis points: 2000 = 20 %.
324
+ - slug: estimate-vat-bp
325
+ label: VAT (basis points)
326
+ valueType: number
327
+ inputType: number
328
+ constraints: { defaultValue: 2000 }
329
+ - slug: estimate-lines
330
+ label: Lines
331
+ description: "The priced lines: a list of { label, quantity, unit_price }, unit_price an integer in minor units (cents)."
332
+ valueType: array
333
+ inputType: json
334
+ # Whoever wears the `client` role, a company or a person (the
335
+ # engagement-client precedent).
336
+ - slug: estimate-client
337
+ label: Client
338
+ valueType: entity_id
339
+ targetProfileSlug: client
340
+ inputType: entity_select
341
+ # Many estimates to at most one deal. `deal` is a system kind, so it
342
+ # resolves from this space.
343
+ - slug: estimate-deal
344
+ label: Deal
345
+ valueType: entity_id
346
+ targetProfileSlug: deal
347
+ relation: estimate_for_deal
348
+ inputType: entity_select
349
+ # The pinned template the estimate's body is generated from.
350
+ - slug: estimate-template
351
+ label: Template
352
+ valueType: entity_id
353
+ targetProfileSlug: brand-template
354
+ inputType: entity_select
355
+
356
+ # Brand Library's shared kind, REFERENCED (not owned, not twinned): this
357
+ # declaration writes Operations' grant so `estimate-template` resolves. No
358
+ # properties and no lifecycle are restated: brand-library (required above)
359
+ # holds the body.
360
+ - slug: brand-template
361
+ displayName: Brand Template
362
+ scope: shared
363
+ properties: []
364
+
255
365
  # The durable OUTPUT of the daily briefing automation. A recap that only ever
256
366
  # exists as a chat message is not knowledge — it cannot be queried, ranked, or
257
367
  # linked. This kind is what turns the digest into structure: one dated row per
@@ -326,6 +436,25 @@ entityLinks:
326
436
  targetProfileSlug: engagement
327
437
  type: contract_for_engagement
328
438
  label: Engagement
439
+ # The estimate's edges (decision e480340b). `estimate_for_deal` is written by
440
+ # the `estimate-deal` property. Cardinalities are the intent, not enforced:
441
+ # an estimate becomes at most one contract; version 2 `revises` version 1.
442
+ # The typed `invoice_for_estimate` is DEFERRED: `invoice` is Finance's
443
+ # workspace-scoped kind and resolves from no other space (declaring it here
444
+ # would promote it to shared), so an estimate links its invoices with the
445
+ # pod-wide `relates_to` until the invoice and its Pennylane or Qonto link land.
446
+ - sourceProfileSlug: estimate
447
+ targetProfileSlug: deal
448
+ type: estimate_for_deal
449
+ label: Deal
450
+ - sourceProfileSlug: estimate
451
+ targetProfileSlug: contract
452
+ type: estimate_becomes_contract
453
+ label: Contract
454
+ - sourceProfileSlug: estimate
455
+ targetProfileSlug: estimate
456
+ type: revises
457
+ label: Revises
329
458
 
330
459
  # CURATED views — the delivery motion, not one per profile
331
460
  views:
@@ -364,6 +493,11 @@ views:
364
493
  description: "Contracts by status — the flow board of Get a contract signed."
365
494
  config:
366
495
  groupByField: contract-status
496
+ - name: Estimates
497
+ slug: estimates
498
+ type: table
499
+ scopeProfileSlug: estimate
500
+ description: "Estimates with their status, client, deal and validity."
367
501
  - name: Client Briefings
368
502
  slug: client-briefings
369
503
  type: list
@@ -425,6 +559,10 @@ layout:
425
559
  viewName: Contracts
426
560
  label: Contracts
427
561
  icon: file-signature
562
+ - kind: view
563
+ viewName: Estimates
564
+ label: Estimates
565
+ icon: calculator
428
566
 
429
567
  # Bento dashboard
430
568
  bento:
package/src/templates.ts CHANGED
@@ -32640,6 +32640,12 @@ const DATA = {
32640
32640
  "kind": "workspace",
32641
32641
  "relation": "require",
32642
32642
  "reason": "Provides the pod-wide `client` role this space onboards and serves (Clients board, Onboard a client) and its automations query."
32643
+ },
32644
+ {
32645
+ "slug": "brand-library",
32646
+ "kind": "workspace",
32647
+ "relation": "require",
32648
+ "reason": "Provides the shared brand-template kind an estimate is generated from."
32643
32649
  }
32644
32650
  ],
32645
32651
  "profiles": [
@@ -32940,6 +32946,142 @@ const DATA = {
32940
32946
  }
32941
32947
  ]
32942
32948
  },
32949
+ {
32950
+ "slug": "estimate",
32951
+ "displayName": "Estimate",
32952
+ "icon": "calculator",
32953
+ "description": "A priced quote for a client, sent before any contract — its lines, currency, VAT, version and the date it is valid until.",
32954
+ "lifecycle": {
32955
+ "property": "estimate-status",
32956
+ "options": [
32957
+ {
32958
+ "key": "draft",
32959
+ "category": "open"
32960
+ },
32961
+ {
32962
+ "key": "sent",
32963
+ "category": "active"
32964
+ },
32965
+ {
32966
+ "key": "accepted",
32967
+ "category": "done",
32968
+ "humanOnly": true
32969
+ },
32970
+ {
32971
+ "key": "declined",
32972
+ "category": "lost",
32973
+ "humanOnly": true
32974
+ },
32975
+ {
32976
+ "key": "expired",
32977
+ "category": "lost"
32978
+ },
32979
+ {
32980
+ "key": "superseded",
32981
+ "category": "lost"
32982
+ }
32983
+ ]
32984
+ },
32985
+ "properties": [
32986
+ {
32987
+ "slug": "estimate-status",
32988
+ "label": "Status",
32989
+ "valueType": "string",
32990
+ "inputType": "select",
32991
+ "enumValues": [
32992
+ "draft",
32993
+ "sent",
32994
+ "accepted",
32995
+ "declined",
32996
+ "expired",
32997
+ "superseded"
32998
+ ],
32999
+ "constraints": {
33000
+ "defaultValue": "draft"
33001
+ }
33002
+ },
33003
+ {
33004
+ "slug": "estimate-number",
33005
+ "label": "Number",
33006
+ "valueType": "string",
33007
+ "inputType": "text"
33008
+ },
33009
+ {
33010
+ "slug": "estimate-version",
33011
+ "label": "Version",
33012
+ "valueType": "number",
33013
+ "inputType": "number",
33014
+ "constraints": {
33015
+ "defaultValue": 1
33016
+ }
33017
+ },
33018
+ {
33019
+ "slug": "issued-date",
33020
+ "label": "Issued",
33021
+ "valueType": "date",
33022
+ "inputType": "date"
33023
+ },
33024
+ {
33025
+ "slug": "valid-until",
33026
+ "label": "Valid until",
33027
+ "valueType": "date",
33028
+ "inputType": "date"
33029
+ },
33030
+ {
33031
+ "slug": "estimate-currency",
33032
+ "label": "Currency",
33033
+ "valueType": "string",
33034
+ "inputType": "text",
33035
+ "constraints": {
33036
+ "defaultValue": "EUR"
33037
+ }
33038
+ },
33039
+ {
33040
+ "slug": "estimate-vat-bp",
33041
+ "label": "VAT (basis points)",
33042
+ "valueType": "number",
33043
+ "inputType": "number",
33044
+ "constraints": {
33045
+ "defaultValue": 2000
33046
+ }
33047
+ },
33048
+ {
33049
+ "slug": "estimate-lines",
33050
+ "label": "Lines",
33051
+ "description": "The priced lines: a list of { label, quantity, unit_price }, unit_price an integer in minor units (cents).",
33052
+ "valueType": "array",
33053
+ "inputType": "json"
33054
+ },
33055
+ {
33056
+ "slug": "estimate-client",
33057
+ "label": "Client",
33058
+ "valueType": "entity_id",
33059
+ "targetProfileSlug": "client",
33060
+ "inputType": "entity_select"
33061
+ },
33062
+ {
33063
+ "slug": "estimate-deal",
33064
+ "label": "Deal",
33065
+ "valueType": "entity_id",
33066
+ "targetProfileSlug": "deal",
33067
+ "relation": "estimate_for_deal",
33068
+ "inputType": "entity_select"
33069
+ },
33070
+ {
33071
+ "slug": "estimate-template",
33072
+ "label": "Template",
33073
+ "valueType": "entity_id",
33074
+ "targetProfileSlug": "brand-template",
33075
+ "inputType": "entity_select"
33076
+ }
33077
+ ]
33078
+ },
33079
+ {
33080
+ "slug": "brand-template",
33081
+ "displayName": "Brand Template",
33082
+ "scope": "shared",
33083
+ "properties": []
33084
+ },
32943
33085
  {
32944
33086
  "slug": "client-briefing",
32945
33087
  "displayName": "Client Briefing",
@@ -33023,6 +33165,24 @@ const DATA = {
33023
33165
  "targetProfileSlug": "engagement",
33024
33166
  "type": "contract_for_engagement",
33025
33167
  "label": "Engagement"
33168
+ },
33169
+ {
33170
+ "sourceProfileSlug": "estimate",
33171
+ "targetProfileSlug": "deal",
33172
+ "type": "estimate_for_deal",
33173
+ "label": "Deal"
33174
+ },
33175
+ {
33176
+ "sourceProfileSlug": "estimate",
33177
+ "targetProfileSlug": "contract",
33178
+ "type": "estimate_becomes_contract",
33179
+ "label": "Contract"
33180
+ },
33181
+ {
33182
+ "sourceProfileSlug": "estimate",
33183
+ "targetProfileSlug": "estimate",
33184
+ "type": "revises",
33185
+ "label": "Revises"
33026
33186
  }
33027
33187
  ],
33028
33188
  "views": [
@@ -33073,6 +33233,13 @@ const DATA = {
33073
33233
  "groupByField": "contract-status"
33074
33234
  }
33075
33235
  },
33236
+ {
33237
+ "name": "Estimates",
33238
+ "slug": "estimates",
33239
+ "type": "table",
33240
+ "scopeProfileSlug": "estimate",
33241
+ "description": "Estimates with their status, client, deal and validity."
33242
+ },
33076
33243
  {
33077
33244
  "name": "Client Briefings",
33078
33245
  "slug": "client-briefings",
@@ -33149,6 +33316,12 @@ const DATA = {
33149
33316
  "viewName": "Contracts",
33150
33317
  "label": "Contracts",
33151
33318
  "icon": "file-signature"
33319
+ },
33320
+ {
33321
+ "kind": "view",
33322
+ "viewName": "Estimates",
33323
+ "label": "Estimates",
33324
+ "icon": "calculator"
33152
33325
  }
33153
33326
  ]
33154
33327
  },