@cmssy/types 0.38.0 → 0.39.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.
@@ -27,11 +27,17 @@ export interface CmssyBlockWorkspace {
27
27
  * Enough for a block to ask the delivery API about its own surroundings ("the
28
28
  * pages under mine", "posts other than me"), and deliberately not more: a block
29
29
  * handed the whole tree starts carrying routing logic and stops being portable.
30
+ *
31
+ * A page block always gets `id`: the renderer fetched the page. A layout block
32
+ * gets the routed page as the layout slot knows it - `slug` and `path` - and
33
+ * `id`/`pageType` only when the caller had the page fetched already.
30
34
  */
31
35
  export interface CmssyBlockPage {
32
- id: string;
36
+ id?: string;
33
37
  /** Full path from the site root, e.g. `/docs/blocks/define`. */
34
38
  slug: string;
39
+ /** `slug` split into segments, without a locale prefix: `["docs", "blocks", "define"]`. */
40
+ path: string[];
35
41
  pageType?: string | null;
36
42
  }
37
43
  export interface CmssyBlockContext {
@@ -40,11 +46,15 @@ export interface CmssyBlockContext {
40
46
  forms?: Record<string, CmssyFormDefinition>;
41
47
  auth?: CmssyBlockAuthContext;
42
48
  workspace?: CmssyBlockWorkspace;
43
- /** Absent for layout blocks, which belong to a layout rather than a page. */
49
+ /**
50
+ * The routed page. Set for page blocks and for layout blocks alike - a
51
+ * layout block sees the page its layout is resolved for. Absent only when
52
+ * the renderer was given no page at all.
53
+ */
44
54
  page?: CmssyBlockPage;
45
55
  /**
46
56
  * Whatever the app handed the renderer - a signed-in member, a feature flag,
47
- * the active path, an A/B bucket. The SDK passes it through untouched: it
57
+ * an A/B bucket. (The routed path is not app state: it is `page.path`.) The SDK passes it through untouched: it
48
58
  * neither reads nor validates it, and never adds keys of its own.
49
59
  *
50
60
  * This is the extension point. A block that needs something cmssy does not
@@ -60,10 +70,11 @@ export interface BuildBlockContextExtra {
60
70
  auth?: CmssyBlockAuthContext;
61
71
  workspace?: CmssyBlockWorkspace;
62
72
  /**
63
- * The fetched page, as the renderer already holds it. `buildBlockContext`
64
- * keeps the identity and drops the rest, so nothing has to map it first.
73
+ * The fetched page, as the renderer already holds it, or just its slug when
74
+ * only the route is known. `buildBlockContext` keeps the identity, derives
75
+ * `path` from the slug and drops the rest, so nothing has to map it first.
65
76
  */
66
- page?: CmssyPageData;
77
+ page?: Partial<CmssyPageData>;
67
78
  app?: Record<string, unknown>;
68
79
  }
69
80
  //# sourceMappingURL=block-context.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"block-context.d.ts","sourceRoot":"","sources":["../src/block-context.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAElD,MAAM,WAAW,kBAAkB;IACjC,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,qBAAqB;IACpC,eAAe,EAAE,OAAO,CAAC;IACzB,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAAC;CACjC;AAED,MAAM,WAAW,mBAAmB;IAClC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;;GAMG;AACH,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,gEAAgE;IAChE,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,kBAAkB,CAAC;IAC3B,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;IAC5C,IAAI,CAAC,EAAE,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AC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC1B;AAED,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,kBAAkB,CAAC;IAC3B,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,mBAAmB,CAAC,CAAC;IAC5C,IAAI,CAAC,EAAE,qBAAqB,CAAC;IAC7B,SAAS,CAAC,EAAE,mBAAmB,CAAC;IAChC;;;;OAIG;IACH,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB;;;;;;;;;;;OAWG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B;AAED,MAAM,WAAW,sBAAsB;IACrC,IAAI,CAAC,EAAE,qBAAqB,CAAC;IAC7B,SAAS,CAAC,EAAE,mBAAmB,CAAC;IAChC;;;;OAIG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC,aAAa,CAAC,CAAC;IAC9B,GAAG,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC/B"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cmssy/types",
3
- "version": "0.38.0",
3
+ "version": "0.39.0",
4
4
  "description": "Shared type definitions for Cmssy platform",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",