@gooddata/sdk-code-convertors 11.63.0-alpha.0 → 11.63.0-alpha.2

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.
Files changed (55) hide show
  1. package/esm/declarativePublisherTypesV2.d.ts +27 -0
  2. package/esm/declarativePublisherTypesV2.d.ts.map +1 -0
  3. package/esm/declarativePublisherTypesV2.js +2 -0
  4. package/esm/fillPublisherIdsV2.d.ts +16 -0
  5. package/esm/fillPublisherIdsV2.d.ts.map +1 -0
  6. package/esm/fillPublisherIdsV2.js +149 -0
  7. package/esm/from/declarativePublisherDocumentPageToYaml.d.ts +3 -10
  8. package/esm/from/declarativePublisherDocumentPageToYaml.d.ts.map +1 -1
  9. package/esm/from/declarativePublisherDocumentPageToYaml.js +12 -25
  10. package/esm/from/declarativePublisherDocumentToYaml.d.ts +5 -5
  11. package/esm/from/declarativePublisherDocumentToYaml.d.ts.map +1 -1
  12. package/esm/from/declarativePublisherDocumentToYaml.js +2 -1
  13. package/esm/from/declarativePublisherEntityToYamlV2.d.ts +52 -0
  14. package/esm/from/declarativePublisherEntityToYamlV2.d.ts.map +1 -0
  15. package/esm/from/declarativePublisherEntityToYamlV2.js +216 -0
  16. package/esm/index.d.ts +6 -1
  17. package/esm/index.d.ts.map +1 -1
  18. package/esm/index.js +4 -0
  19. package/esm/schemas/types.d.ts +17 -1
  20. package/esm/schemas/types.d.ts.map +1 -1
  21. package/esm/sdk-code-convertors.d.ts +187 -14
  22. package/esm/to/yamlPublisherDocumentPageToDeclarative.d.ts +4 -11
  23. package/esm/to/yamlPublisherDocumentPageToDeclarative.d.ts.map +1 -1
  24. package/esm/to/yamlPublisherDocumentPageToDeclarative.js +2 -17
  25. package/esm/to/yamlPublisherDocumentToDeclarative.d.ts +4 -4
  26. package/esm/to/yamlPublisherDocumentToDeclarative.d.ts.map +1 -1
  27. package/esm/to/yamlPublisherDocumentToDeclarative.js +2 -1
  28. package/esm/to/yamlPublisherEntityToDeclarativeV2.d.ts +34 -0
  29. package/esm/to/yamlPublisherEntityToDeclarativeV2.d.ts.map +1 -0
  30. package/esm/to/yamlPublisherEntityToDeclarativeV2.js +190 -0
  31. package/esm/utils/errors.d.ts +6 -1
  32. package/esm/utils/errors.d.ts.map +1 -1
  33. package/esm/utils/errors.js +15 -0
  34. package/esm/utils/keyCase.d.ts +24 -0
  35. package/esm/utils/keyCase.d.ts.map +1 -0
  36. package/esm/utils/keyCase.js +28 -0
  37. package/esm/utils/publisherContentV2.d.ts +25 -0
  38. package/esm/utils/publisherContentV2.d.ts.map +1 -0
  39. package/esm/utils/publisherContentV2.js +33 -0
  40. package/esm/utils/publisherFilters.d.ts +50 -0
  41. package/esm/utils/publisherFilters.d.ts.map +1 -0
  42. package/esm/utils/publisherFilters.js +122 -0
  43. package/esm/utils/publisherPeriodV2.d.ts +7 -0
  44. package/esm/utils/publisherPeriodV2.d.ts.map +1 -0
  45. package/esm/utils/publisherPeriodV2.js +34 -0
  46. package/esm/utils/publisherVersionV2.d.ts +9 -0
  47. package/esm/utils/publisherVersionV2.d.ts.map +1 -0
  48. package/esm/utils/publisherVersionV2.js +10 -0
  49. package/esm/utils/texts.d.ts +1 -0
  50. package/esm/utils/texts.d.ts.map +1 -1
  51. package/esm/utils/texts.js +5 -0
  52. package/esm/validateDeclarativePublisherEntityV2.d.ts +10 -0
  53. package/esm/validateDeclarativePublisherEntityV2.d.ts.map +1 -0
  54. package/esm/validateDeclarativePublisherEntityV2.js +34 -0
  55. package/package.json +6 -6
@@ -0,0 +1,27 @@
1
+ import { type IPublisherDocumentDefinitionV2, type IPublisherDocumentTemplateDefinitionV2, type IPublisherPageTemplateDefinitionV2 } from "@gooddata/sdk-model";
2
+ /**
3
+ * A document as the declarative API stores it: the model's definition named by a bare id.
4
+ *
5
+ * @alpha
6
+ */
7
+ export type DeclarativePublisherDocumentV2 = Omit<IPublisherDocumentDefinitionV2, "ref"> & {
8
+ id: string;
9
+ };
10
+ /**
11
+ * A document template as the declarative API stores it.
12
+ *
13
+ * @alpha
14
+ */
15
+ export type DeclarativePublisherDocumentTemplateV2 = Omit<IPublisherDocumentTemplateDefinitionV2, "ref"> & {
16
+ id: string;
17
+ };
18
+ /**
19
+ * A page template as the declarative API stores it. The backend's default page templates are not
20
+ * part of the declarative layout.
21
+ *
22
+ * @alpha
23
+ */
24
+ export type DeclarativePublisherPageTemplateV2 = Omit<IPublisherPageTemplateDefinitionV2, "ref"> & {
25
+ id: string;
26
+ };
27
+ //# sourceMappingURL=declarativePublisherTypesV2.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"declarativePublisherTypesV2.d.ts","sourceRoot":"","sources":["../src/declarativePublisherTypesV2.ts"],"names":[],"mappings":"AAKA,OAAO,EACH,KAAK,8BAA8B,EACnC,KAAK,sCAAsC,EAC3C,KAAK,kCAAkC,EAC1C,MAAM,qBAAqB,CAAC;AAE7B;;;;GAIG;AACH,MAAM,MAAM,8BAA8B,GAAG,IAAI,CAAC,8BAA8B,EAAE,KAAK,CAAC,GAAG;IAAE,EAAE,EAAE,MAAM,CAAA;CAAE,CAAC;AAE1G;;;;GAIG;AACH,MAAM,MAAM,sCAAsC,GAAG,IAAI,CAAC,sCAAsC,EAAE,KAAK,CAAC,GAAG;IACvG,EAAE,EAAE,MAAM,CAAC;CACd,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,kCAAkC,GAAG,IAAI,CAAC,kCAAkC,EAAE,KAAK,CAAC,GAAG;IAC/F,EAAE,EAAE,MAAM,CAAC;CACd,CAAC"}
@@ -0,0 +1,2 @@
1
+ // (C) 2026 GoodData Corporation
2
+ export {};
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Adds the section, page and widget ids a v2 document, document template or page template as code
3
+ * leaves out, so the YAML written by hand states the ids the stored entity keeps. An id counts as
4
+ * missing when it is absent, null or empty. Comments and the indent width survive, the line break of
5
+ * the first line is applied to the whole file, and the sequence style survives too, except that
6
+ * unindented sequences are kept only at a 2-space indent and the compact `- ` style is not kept.
7
+ * Block scalars take the indent width of the maps. Content that needs no id, or does not parse,
8
+ * comes back unchanged.
9
+ *
10
+ * @alpha
11
+ */
12
+ export declare function fillPublisherIdsV2(content: string): {
13
+ content: string;
14
+ changed: boolean;
15
+ };
16
+ //# sourceMappingURL=fillPublisherIdsV2.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fillPublisherIdsV2.d.ts","sourceRoot":"","sources":["../src/fillPublisherIdsV2.ts"],"names":[],"mappings":"AA+JA;;;;;;;;;;GAUG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,GAAG;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,CAezF"}
@@ -0,0 +1,149 @@
1
+ // (C) 2026 GoodData Corporation
2
+ import { LineCounter, Pair, Scalar, isMap, isScalar, isSeq, parseDocument, visit, } from "yaml";
3
+ import { newPublisherPageIdV2, newPublisherSectionIdV2, newPublisherWidgetIdV2 } from "@gooddata/sdk-model";
4
+ function isKey(pair, key) {
5
+ return isScalar(pair.key) ? pair.key.value === key : pair.key === key;
6
+ }
7
+ function isMissingId(node) {
8
+ const id = node.get("id");
9
+ return id === undefined || id === null || id === "";
10
+ }
11
+ function takenIds(nodes) {
12
+ return new Set(nodes.filter((node) => !isMissingId(node)).map((node) => String(node.get("id"))));
13
+ }
14
+ function drawId(generate, taken) {
15
+ let id = generate();
16
+ while (taken.has(id)) {
17
+ id = generate();
18
+ }
19
+ taken.add(id);
20
+ return id;
21
+ }
22
+ /** An `id` key already written keeps its place and its comment; a new one goes after `after`, or first. */
23
+ function placeId(node, id, after) {
24
+ const written = node.items.find((item) => isKey(item, "id"));
25
+ if (written !== undefined && isScalar(written.value)) {
26
+ written.value.value = id;
27
+ written.value.type = Scalar.PLAIN;
28
+ return;
29
+ }
30
+ if (written !== undefined) {
31
+ written.value = new Scalar(id);
32
+ return;
33
+ }
34
+ const position = after === undefined ? 0 : node.items.findIndex((item) => isKey(item, after)) + 1;
35
+ node.items.splice(position, 0, new Pair(new Scalar("id"), new Scalar(id)));
36
+ }
37
+ function maps(value) {
38
+ return isSeq(value) ? value.items.filter((item) => isMap(item)) : [];
39
+ }
40
+ function layoutNodes(node) {
41
+ if (!isMap(node)) {
42
+ return [];
43
+ }
44
+ const type = node.get("type");
45
+ return type === "row" || type === "column" ? maps(node.get("children")).flatMap(layoutNodes) : [node];
46
+ }
47
+ function fillMissing(nodes, { generate, taken, after }) {
48
+ const missing = nodes.filter(isMissingId);
49
+ for (const node of missing) {
50
+ placeId(node, drawId(generate, taken), after);
51
+ }
52
+ return missing.length > 0;
53
+ }
54
+ function fillWidgetIds(layout) {
55
+ const widgets = layoutNodes(layout);
56
+ return fillMissing(widgets, {
57
+ generate: newPublisherWidgetIdV2,
58
+ taken: takenIds(widgets),
59
+ after: "type",
60
+ });
61
+ }
62
+ function fillContentIds(type, content) {
63
+ if (!isMap(content)) {
64
+ return false;
65
+ }
66
+ if (type === "page_template") {
67
+ return fillWidgetIds(content.get("layout"));
68
+ }
69
+ if (type !== "document" && type !== "document_template") {
70
+ return false;
71
+ }
72
+ const sections = maps(content.get("sections"));
73
+ const pages = [
74
+ ...maps(content.get("pages")),
75
+ ...sections.flatMap((section) => maps(section.get("pages"))),
76
+ ];
77
+ const taken = takenIds([...sections, ...pages]);
78
+ const filledSections = fillMissing(sections, { generate: newPublisherSectionIdV2, taken });
79
+ const filledPages = fillMissing(pages, { generate: newPublisherPageIdV2, taken });
80
+ const filledWidgets = pages.map((page) => fillWidgetIds(page.get("layout"))).some(Boolean);
81
+ return filledSections || filledPages || filledWidgets;
82
+ }
83
+ /** The indent width the source uses: how far a block map's keys sit right of their parent key. */
84
+ function indentOf(document, lineCounter) {
85
+ let indent;
86
+ visit(document, {
87
+ Pair(_, pair) {
88
+ const [first] = isMap(pair.value) && !pair.value.flow ? pair.value.items : [];
89
+ if (indent === undefined &&
90
+ isScalar(pair.key) &&
91
+ pair.key.range &&
92
+ isScalar(first?.key) &&
93
+ first.key.range) {
94
+ indent =
95
+ lineCounter.linePos(first.key.range[0]).col - lineCounter.linePos(pair.key.range[0]).col;
96
+ }
97
+ },
98
+ });
99
+ return indent !== undefined && indent > 0 ? indent : 2;
100
+ }
101
+ /** True when block sequence items are written at their parent key's column (`key:` then `- item`). */
102
+ function hasUnindentedSequences(document, lineCounter) {
103
+ let unindented = false;
104
+ visit(document, {
105
+ Pair(_, pair) {
106
+ if (isScalar(pair.key) &&
107
+ isSeq(pair.value) &&
108
+ !pair.value.flow &&
109
+ pair.key.range &&
110
+ pair.value.range) {
111
+ const keyColumn = lineCounter.linePos(pair.key.range[0]).col;
112
+ unindented ||= keyColumn === lineCounter.linePos(pair.value.range[0]).col;
113
+ }
114
+ },
115
+ });
116
+ return unindented;
117
+ }
118
+ /** The first line break decides which one the whole output uses. */
119
+ function usesCrlf(content) {
120
+ const firstBreak = content.indexOf("\n");
121
+ return firstBreak > 0 && content[firstBreak - 1] === "\r";
122
+ }
123
+ /**
124
+ * Adds the section, page and widget ids a v2 document, document template or page template as code
125
+ * leaves out, so the YAML written by hand states the ids the stored entity keeps. An id counts as
126
+ * missing when it is absent, null or empty. Comments and the indent width survive, the line break of
127
+ * the first line is applied to the whole file, and the sequence style survives too, except that
128
+ * unindented sequences are kept only at a 2-space indent and the compact `- ` style is not kept.
129
+ * Block scalars take the indent width of the maps. Content that needs no id, or does not parse,
130
+ * comes back unchanged.
131
+ *
132
+ * @alpha
133
+ */
134
+ export function fillPublisherIdsV2(content) {
135
+ const lineCounter = new LineCounter();
136
+ const document = parseDocument(content, { lineCounter });
137
+ if (document.errors.length > 0 || !isMap(document.contents)) {
138
+ return { content, changed: false };
139
+ }
140
+ if (!fillContentIds(document.contents.get("type"), document.contents.get("content"))) {
141
+ return { content, changed: false };
142
+ }
143
+ const written = document.toString({
144
+ indent: indentOf(document, lineCounter),
145
+ indentSeq: !hasUnindentedSequences(document, lineCounter),
146
+ lineWidth: 0,
147
+ });
148
+ return { content: usesCrlf(content) ? written.replace(/\n/g, "\r\n") : written, changed: true };
149
+ }
@@ -1,12 +1,5 @@
1
1
  import { YAMLMap } from "yaml";
2
- import { type FilterContextItem, type IPublisherDocumentPage, type IPublisherPageBody } from "@gooddata/sdk-model";
3
- /**
4
- * A document holds its filters the way a dashboard's filter context does, so the same convertor writes
5
- * them; only the envelope it expects is put around them here.
6
- *
7
- * @internal
8
- */
9
- export declare function filtersToYaml(filters: FilterContextItem[] | undefined): YAMLMap | undefined;
2
+ import { type IPublisherDocumentPageV1, type IPublisherPageBodyV1 } from "@gooddata/sdk-model";
10
3
  /** @internal */
11
4
  export declare function mapOf(entries: Array<[string, unknown]>): YAMLMap;
12
5
  /**
@@ -19,7 +12,7 @@ export declare function mapOf(entries: Array<[string, unknown]>): YAMLMap;
19
12
  *
20
13
  * @internal
21
14
  */
22
- export declare function publisherPageBodyEntries(body: IPublisherPageBody): Array<[string, unknown]>;
15
+ export declare function publisherPageBodyEntries(body: IPublisherPageBodyV1): Array<[string, unknown]>;
23
16
  /** @internal */
24
- export declare function declarativePublisherDocumentPageToYaml(body: IPublisherDocumentPage): YAMLMap;
17
+ export declare function declarativePublisherDocumentPageToYaml(body: IPublisherDocumentPageV1): YAMLMap;
25
18
  //# sourceMappingURL=declarativePublisherDocumentPageToYaml.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"declarativePublisherDocumentPageToYaml.d.ts","sourceRoot":"","sources":["../../src/from/declarativePublisherDocumentPageToYaml.ts"],"names":[],"mappings":"AAEA,OAAO,EAAQ,OAAO,EAAW,MAAM,MAAM,CAAC;AAG9C,OAAO,EACH,KAAK,iBAAiB,EAEtB,KAAK,sBAAsB,EAE3B,KAAK,kBAAkB,EAe1B,MAAM,qBAAqB,CAAC;AAQ7B;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,iBAAiB,EAAE,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,CAQ3F;AAoBD,gBAAgB;AAChB,wBAAgB,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,OAAO,CAMhE;AAyOD;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,kBAAkB,GAAG,KAAK,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAmB3F;AAED,gBAAgB;AAChB,wBAAgB,sCAAsC,CAAC,IAAI,EAAE,sBAAsB,GAAG,OAAO,CAE5F"}
1
+ {"version":3,"file":"declarativePublisherDocumentPageToYaml.d.ts","sourceRoot":"","sources":["../../src/from/declarativePublisherDocumentPageToYaml.ts"],"names":[],"mappings":"AAEA,OAAO,EAAQ,OAAO,EAAW,MAAM,MAAM,CAAC;AAE9C,OAAO,EAEH,KAAK,wBAAwB,EAE7B,KAAK,oBAAoB,EAe5B,MAAM,qBAAqB,CAAC;AAyB7B,gBAAgB;AAChB,wBAAgB,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,GAAG,OAAO,CAMhE;AA8OD;;;;;;;;;GASG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,oBAAoB,GAAG,KAAK,CAAC,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAmB7F;AAED,gBAAgB;AAChB,wBAAgB,sCAAsC,CAAC,IAAI,EAAE,wBAAwB,GAAG,OAAO,CAE9F"}
@@ -1,25 +1,10 @@
1
1
  // (C) 2026 GoodData Corporation
2
2
  import { Pair, YAMLMap, YAMLSeq } from "yaml";
3
- import { dashboardFilterReferenceObjRef, isPublisherImageBackground, isPublisherImageSlot, isPublisherLayoutSection, isPublisherTextSlot, isPublisherVisualizationSlot, objRefToString, } from "@gooddata/sdk-model";
3
+ import { dashboardFilterReferenceObjRef, isPublisherImageBackgroundV1, isPublisherImageSlotV1, isPublisherLayoutSectionV1, isPublisherTextSlotV1, isPublisherVisualizationSlotV1, objRefToString, } from "@gooddata/sdk-model";
4
4
  import { CoreErrorCode, newError } from "../utils/errors.js";
5
5
  import { referencesAsWritten } from "../utils/publisherFilterRefs.js";
6
+ import { filtersToYaml } from "../utils/publisherFilters.js";
6
7
  import { getIdentifier } from "../utils/yamlUtils.js";
7
- import { declarativeFilterContextToYaml } from "./declarativeDashboardToYaml.js";
8
- /**
9
- * A document holds its filters the way a dashboard's filter context does, so the same convertor writes
10
- * them; only the envelope it expects is put around them here.
11
- *
12
- * @internal
13
- */
14
- export function filtersToYaml(filters) {
15
- if (!filters?.length) {
16
- return undefined;
17
- }
18
- const { filters: written } = declarativeFilterContextToYaml(undefined, {
19
- content: { filters: referencesAsWritten(filters), version: "2" },
20
- });
21
- return emptyToUndefined(written);
22
- }
23
8
  /**
24
9
  * Collapses a mapping that says only one thing down to that thing, the way a bucket with nothing
25
10
  * but a `using` is written as the field it uses.
@@ -110,7 +95,7 @@ function imageContentToYaml(slot) {
110
95
  return shorten(map, ["url"]) ?? map;
111
96
  }
112
97
  function placedSlotIds(node, into) {
113
- if (isPublisherLayoutSection(node)) {
98
+ if (isPublisherLayoutSectionV1(node)) {
114
99
  for (const child of node.children) {
115
100
  placedSlotIds(child, into);
116
101
  }
@@ -124,7 +109,7 @@ function backgroundToYaml(background, page) {
124
109
  if (background === undefined) {
125
110
  return undefined;
126
111
  }
127
- if (!isPublisherImageBackground(background)) {
112
+ if (!isPublisherImageBackgroundV1(background)) {
128
113
  return background.color;
129
114
  }
130
115
  const { slotId } = background;
@@ -137,7 +122,7 @@ function backgroundToYaml(background, page) {
137
122
  const slot = page.slotsById.get(slotId);
138
123
  // A backdrop naming a slot the page does not hold paints nothing, and is written as the bare
139
124
  // reference it is rather than invented content.
140
- if (slot === undefined || !isPublisherImageSlot(slot)) {
125
+ if (slot === undefined || !isPublisherImageSlotV1(slot)) {
141
126
  return mapOf([["image", mapOf([["ref", slotId]])]]);
142
127
  }
143
128
  const content = imageContentToYaml(slot);
@@ -196,7 +181,7 @@ function imageSlotToYaml(slot, weight) {
196
181
  ]);
197
182
  }
198
183
  function layoutNodeToYaml(node, page) {
199
- if (isPublisherLayoutSection(node)) {
184
+ if (isPublisherLayoutSectionV1(node)) {
200
185
  const children = new YAMLSeq();
201
186
  for (const child of node.children) {
202
187
  children.add(layoutNodeToYaml(child, page));
@@ -217,18 +202,20 @@ function layoutNodeToYaml(node, page) {
217
202
  ["visualization", null],
218
203
  ]);
219
204
  }
220
- if (isPublisherVisualizationSlot(slot)) {
205
+ if (isPublisherVisualizationSlotV1(slot)) {
221
206
  return visualizationSlotToYaml(slot, node.weight);
222
207
  }
223
- if (isPublisherTextSlot(slot)) {
208
+ if (isPublisherTextSlotV1(slot)) {
224
209
  return textSlotToYaml(slot, node.weight, page);
225
210
  }
226
- if (isPublisherImageSlot(slot)) {
211
+ if (isPublisherImageSlotV1(slot)) {
227
212
  return imageSlotToYaml(slot, node.weight);
228
213
  }
229
214
  // A slot of a kind this version does not know cannot be written without saying it is something
230
215
  // it is not, so the page is refused rather than quietly rewritten into a shape it never had.
231
- throw newError(CoreErrorCode.ItemNotSupported, [JSON.stringify({ slot: slot.type })]);
216
+ throw newError(CoreErrorCode.ItemNotSupported, [
217
+ JSON.stringify({ slot: slot.type }),
218
+ ]);
232
219
  }
233
220
  /**
234
221
  * Writes a page out as the single tree it is authored as: the geometry and the slots it places
@@ -1,6 +1,6 @@
1
1
  import { type DeclarativeReport, type DeclarativeReportPageLayout } from "@gooddata/api-client-tiger";
2
2
  import type { Report, ReportPageBody, ReportPageLayout, ReportTemplate } from "@gooddata/sdk-code-schemas/v1";
3
- import { type IPublisherDocumentDefinition, type IPublisherDocumentPage, type IPublisherDocumentTemplate, type IPublisherDocumentTemplateDefinition, type IPublisherPageLayout, type IPublisherPageLayoutDefinition } from "@gooddata/sdk-model";
3
+ import { type IPublisherDocumentDefinitionV1, type IPublisherDocumentPageV1, type IPublisherDocumentTemplateDefinitionV1, type IPublisherDocumentTemplateV1, type IPublisherPageTemplateDefinitionV1, type IPublisherPageTemplateV1 } from "@gooddata/sdk-model";
4
4
  /** @alpha */
5
5
  export declare function declarativePublisherDocumentToYaml(publisherDocument: DeclarativeReport): {
6
6
  content: string;
@@ -12,12 +12,12 @@ export declare function declarativePublisherDocumentToYaml(publisherDocument: De
12
12
  *
13
13
  * @alpha
14
14
  */
15
- export declare function publisherDocumentDefinitionToYaml(publisherDocument: IPublisherDocumentDefinition): {
15
+ export declare function publisherDocumentDefinitionToYaml(publisherDocument: IPublisherDocumentDefinitionV1): {
16
16
  content: string;
17
17
  json: Report;
18
18
  };
19
19
  /** @alpha */
20
- export declare function publisherDocumentTemplateDefinitionToYaml(template: IPublisherDocumentTemplate | IPublisherDocumentTemplateDefinition): {
20
+ export declare function publisherDocumentTemplateDefinitionToYaml(template: IPublisherDocumentTemplateV1 | IPublisherDocumentTemplateDefinitionV1): {
21
21
  content: string;
22
22
  json: ReportTemplate;
23
23
  };
@@ -27,7 +27,7 @@ export declare function publisherDocumentTemplateDefinitionToYaml(template: IPub
27
27
  *
28
28
  * @alpha
29
29
  */
30
- export declare function publisherPageLayoutDefinitionToYaml(layout: IPublisherPageLayout | IPublisherPageLayoutDefinition): {
30
+ export declare function publisherPageLayoutDefinitionToYaml(layout: IPublisherPageTemplateV1 | IPublisherPageTemplateDefinitionV1): {
31
31
  content: string;
32
32
  json: ReportPageLayout;
33
33
  };
@@ -41,5 +41,5 @@ export declare function declarativePublisherPageLayoutToYaml(layout: Declarative
41
41
  *
42
42
  * @internal
43
43
  */
44
- export declare function publisherDocumentPageToAacPage(page: IPublisherDocumentPage): ReportPageBody;
44
+ export declare function publisherDocumentPageToAacPage(page: IPublisherDocumentPageV1): ReportPageBody;
45
45
  //# sourceMappingURL=declarativePublisherDocumentToYaml.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"declarativePublisherDocumentToYaml.d.ts","sourceRoot":"","sources":["../../src/from/declarativePublisherDocumentToYaml.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,iBAAiB,EAAE,KAAK,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AACtG,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC9G,OAAO,EAEH,KAAK,4BAA4B,EACjC,KAAK,sBAAsB,EAC3B,KAAK,0BAA0B,EAC/B,KAAK,oCAAoC,EACzC,KAAK,oBAAoB,EAEzB,KAAK,8BAA8B,EAGtC,MAAM,qBAAqB,CAAC;AA2E7B,aAAa;AACb,wBAAgB,kCAAkC,CAAC,iBAAiB,EAAE,iBAAiB,GAAG;IACtF,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CAChB,CAsBA;AAED;;;;;GAKG;AACH,wBAAgB,iCAAiC,CAAC,iBAAiB,EAAE,4BAA4B,GAAG;IAChG,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CAChB,CAsBA;AAED,aAAa;AACb,wBAAgB,yCAAyC,CACrD,QAAQ,EAAE,0BAA0B,GAAG,oCAAoC,GAC5E;IACC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,cAAc,CAAC;CACxB,CAYA;AAED;;;;;GAKG;AACH,wBAAgB,mCAAmC,CAC/C,MAAM,EAAE,oBAAoB,GAAG,8BAA8B,GAC9D;IACC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,gBAAgB,CAAC;CAC1B,CAYA;AAED,aAAa;AACb,wBAAgB,oCAAoC,CAAC,MAAM,EAAE,2BAA2B,GAAG;IACvF,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,gBAAgB,CAAC;CAC1B,CAYA;AAED;;;;GAIG;AACH,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,sBAAsB,GAAG,cAAc,CAE3F"}
1
+ {"version":3,"file":"declarativePublisherDocumentToYaml.d.ts","sourceRoot":"","sources":["../../src/from/declarativePublisherDocumentToYaml.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,KAAK,iBAAiB,EAAE,KAAK,2BAA2B,EAAE,MAAM,4BAA4B,CAAC;AACtG,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC9G,OAAO,EAEH,KAAK,8BAA8B,EACnC,KAAK,wBAAwB,EAC7B,KAAK,sCAAsC,EAC3C,KAAK,4BAA4B,EAEjC,KAAK,kCAAkC,EACvC,KAAK,wBAAwB,EAGhC,MAAM,qBAAqB,CAAC;AA2E7B,aAAa;AACb,wBAAgB,kCAAkC,CAAC,iBAAiB,EAAE,iBAAiB,GAAG;IACtF,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CAChB,CAsBA;AAED;;;;;GAKG;AACH,wBAAgB,iCAAiC,CAAC,iBAAiB,EAAE,8BAA8B,GAAG;IAClG,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CAChB,CAsBA;AAED,aAAa;AACb,wBAAgB,yCAAyC,CACrD,QAAQ,EAAE,4BAA4B,GAAG,sCAAsC,GAChF;IACC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,cAAc,CAAC;CACxB,CAYA;AAED;;;;;GAKG;AACH,wBAAgB,mCAAmC,CAC/C,MAAM,EAAE,wBAAwB,GAAG,kCAAkC,GACtE;IACC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,gBAAgB,CAAC;CAC1B,CAYA;AAED,aAAa;AACb,wBAAgB,oCAAoC,CAAC,MAAM,EAAE,2BAA2B,GAAG;IACvF,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,gBAAgB,CAAC;CAC1B,CAYA;AAED;;;;GAIG;AACH,wBAAgB,8BAA8B,CAAC,IAAI,EAAE,wBAAwB,GAAG,cAAc,CAE7F"}
@@ -1,8 +1,9 @@
1
1
  // (C) 2026 GoodData Corporation
2
2
  import { Document, Scalar, YAMLSeq } from "yaml";
3
3
  import { objRefToString, } from "@gooddata/sdk-model";
4
+ import { filtersToYaml } from "../utils/publisherFilters.js";
4
5
  import { PUBLISHER_DOCUMENT_COMMENT, PUBLISHER_DOCUMENT_TEMPLATE_COMMENT, PUBLISHER_PAGE_LAYOUT_COMMENT, } from "../utils/texts.js";
5
- import { declarativePublisherDocumentPageToYaml, filtersToYaml, mapOf, publisherPageBodyEntries, } from "./declarativePublisherDocumentPageToYaml.js";
6
+ import { declarativePublisherDocumentPageToYaml, mapOf, publisherPageBodyEntries, } from "./declarativePublisherDocumentPageToYaml.js";
6
7
  /**
7
8
  * A date is quoted, so a reader whose YAML dialect knows timestamps hands back the string the
8
9
  * schema states rather than a date of its own making.
@@ -0,0 +1,52 @@
1
+ import { type IPublisherDocumentDefinitionV2, type IPublisherDocumentTemplateDefinitionV2, type IPublisherPageTemplateDefinitionV2 } from "@gooddata/sdk-model";
2
+ import { type DeclarativePublisherDocumentTemplateV2, type DeclarativePublisherDocumentV2, type DeclarativePublisherPageTemplateV2 } from "../declarativePublisherTypesV2.js";
3
+ import { type AacPublisherDocumentTemplateV2, type AacPublisherDocumentV2, type AacPublisherEntityWithOptionalIdV2, type AacPublisherPageTemplateV2 } from "../schemas/types.js";
4
+ import { type IErrorContext } from "../utils/errors.js";
5
+ /**
6
+ * Converts a stored v2 document to its as-code YAML.
7
+ *
8
+ * @alpha
9
+ */
10
+ export declare function declarativePublisherDocumentToYamlV2(document: DeclarativePublisherDocumentV2, errorContext?: IErrorContext): {
11
+ content: string;
12
+ json: AacPublisherDocumentV2;
13
+ };
14
+ /**
15
+ * Converts a stored v2 document template to its as-code YAML.
16
+ *
17
+ * @alpha
18
+ */
19
+ export declare function declarativePublisherDocumentTemplateToYamlV2(template: DeclarativePublisherDocumentTemplateV2, errorContext?: IErrorContext): {
20
+ content: string;
21
+ json: AacPublisherDocumentTemplateV2;
22
+ };
23
+ /**
24
+ * Converts a stored v2 page template to its as-code YAML.
25
+ *
26
+ * @alpha
27
+ */
28
+ export declare function declarativePublisherPageTemplateToYamlV2(template: DeclarativePublisherPageTemplateV2, errorContext?: IErrorContext): {
29
+ content: string;
30
+ json: AacPublisherPageTemplateV2;
31
+ };
32
+ /**
33
+ * Converts the v2 document the frontend holds to its as-code YAML. A document without a reference
34
+ * yet is written without an id.
35
+ *
36
+ * @alpha
37
+ */
38
+ export declare function publisherDocumentDefinitionToYamlV2(document: IPublisherDocumentDefinitionV2, errorContext?: IErrorContext): {
39
+ content: string;
40
+ json: AacPublisherEntityWithOptionalIdV2<AacPublisherDocumentV2>;
41
+ };
42
+ /** @alpha */
43
+ export declare function publisherDocumentTemplateDefinitionToYamlV2(template: IPublisherDocumentTemplateDefinitionV2, errorContext?: IErrorContext): {
44
+ content: string;
45
+ json: AacPublisherEntityWithOptionalIdV2<AacPublisherDocumentTemplateV2>;
46
+ };
47
+ /** @alpha */
48
+ export declare function publisherPageTemplateDefinitionToYamlV2(template: IPublisherPageTemplateDefinitionV2, errorContext?: IErrorContext): {
49
+ content: string;
50
+ json: AacPublisherEntityWithOptionalIdV2<AacPublisherPageTemplateV2>;
51
+ };
52
+ //# sourceMappingURL=declarativePublisherEntityToYamlV2.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"declarativePublisherEntityToYamlV2.d.ts","sourceRoot":"","sources":["../../src/from/declarativePublisherEntityToYamlV2.ts"],"names":[],"mappings":"AAYA,OAAO,EACH,KAAK,8BAA8B,EAEnC,KAAK,sCAAsC,EAE3C,KAAK,kCAAkC,EAO1C,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACH,KAAK,sCAAsC,EAC3C,KAAK,8BAA8B,EACnC,KAAK,kCAAkC,EAC1C,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACH,KAAK,8BAA8B,EACnC,KAAK,sBAAsB,EAC3B,KAAK,kCAAkC,EACvC,KAAK,0BAA0B,EAClC,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,aAAa,EAAsB,MAAM,oBAAoB,CAAC;AA+O5E;;;;GAIG;AACH,wBAAgB,oCAAoC,CAChD,QAAQ,EAAE,8BAA8B,EACxC,YAAY,CAAC,EAAE,aAAa,GAC7B;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,sBAAsB,CAAA;CAAE,CAGnD;AAED;;;;GAIG;AACH,wBAAgB,4CAA4C,CACxD,QAAQ,EAAE,sCAAsC,EAChD,YAAY,CAAC,EAAE,aAAa,GAC7B;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,8BAA8B,CAAA;CAAE,CAG3D;AAED;;;;GAIG;AACH,wBAAgB,wCAAwC,CACpD,QAAQ,EAAE,kCAAkC,EAC5C,YAAY,CAAC,EAAE,aAAa,GAC7B;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,0BAA0B,CAAA;CAAE,CAGvD;AAED;;;;;GAKG;AACH,wBAAgB,mCAAmC,CAC/C,QAAQ,EAAE,8BAA8B,EACxC,YAAY,CAAC,EAAE,aAAa,GAC7B;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,kCAAkC,CAAC,sBAAsB,CAAC,CAAA;CAAE,CAGvF;AAED,aAAa;AACb,wBAAgB,2CAA2C,CACvD,QAAQ,EAAE,sCAAsC,EAChD,YAAY,CAAC,EAAE,aAAa,GAC7B;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,kCAAkC,CAAC,8BAA8B,CAAC,CAAA;CAAE,CAM/F;AAED,aAAa;AACb,wBAAgB,uCAAuC,CACnD,QAAQ,EAAE,kCAAkC,EAC5C,YAAY,CAAC,EAAE,aAAa,GAC7B;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,kCAAkC,CAAC,0BAA0B,CAAC,CAAA;CAAE,CAM3F"}
@@ -0,0 +1,216 @@
1
+ // (C) 2026 GoodData Corporation
2
+ import { Document, Scalar, visit } from "yaml";
3
+ import { dashboardFilterReferenceObjRef, } from "@gooddata/sdk-model";
4
+ import { updateErrorContext } from "../utils/errors.js";
5
+ import { snakeKeys } from "../utils/keyCase.js";
6
+ import { pagesOrSectionsV2, unknownLayoutNodeV2 } from "../utils/publisherContentV2.js";
7
+ import { referencesAsWritten } from "../utils/publisherFilterRefs.js";
8
+ import { assertDocumentDateFiltersNameDataSet, filtersToYamlV2 } from "../utils/publisherFilters.js";
9
+ import { periodToYamlV2 } from "../utils/publisherPeriodV2.js";
10
+ import { assertPublisherContentVersionV2, publisherContentVersionV2 } from "../utils/publisherVersionV2.js";
11
+ import { PUBLISHER_DOCUMENT_COMMENT, PUBLISHER_DOCUMENT_TEMPLATE_COMMENT, PUBLISHER_PAGE_TEMPLATE_COMMENT_V2, } from "../utils/texts.js";
12
+ import { getIdentifier } from "../utils/yamlUtils.js";
13
+ function visualizationToYaml(widget, errorContext) {
14
+ const { visualization, dateDataSet, filters, ignoreDocumentFilters, ...rest } = widget;
15
+ return {
16
+ ...snakeKeys(rest),
17
+ ...(visualization === undefined ? {} : { visualization: visualization.identifier }),
18
+ ...(dateDataSet === undefined ? {} : { date: dateDataSet.identifier }),
19
+ ...(filters === undefined ? {} : { filters: filtersToYamlV2({ filters }, errorContext) }),
20
+ ...(ignoreDocumentFilters === undefined
21
+ ? {}
22
+ : {
23
+ ignored_filters: ignoreDocumentFilters.map((reference) => getIdentifier(referencesAsWritten(dashboardFilterReferenceObjRef(reference)), undefined, errorContext)),
24
+ }),
25
+ };
26
+ }
27
+ function layoutNodeToYaml(node, errorContext) {
28
+ switch (node.type) {
29
+ case "row":
30
+ case "column": {
31
+ const { children, ...container } = node;
32
+ return {
33
+ ...snakeKeys(container),
34
+ children: children.map((child) => layoutNodeToYaml(child, errorContext)),
35
+ };
36
+ }
37
+ case "visualization":
38
+ return visualizationToYaml(node, errorContext);
39
+ case "title":
40
+ case "heading":
41
+ case "text":
42
+ case "image":
43
+ case "takeaway":
44
+ return snakeKeys(node);
45
+ default:
46
+ throw unknownLayoutNodeV2(node, errorContext);
47
+ }
48
+ }
49
+ function pageBodyToYaml(body, errorContext) {
50
+ const { layout, filters, ...rest } = body;
51
+ return {
52
+ ...snakeKeys(rest),
53
+ layout: layoutNodeToYaml(layout, errorContext),
54
+ ...(filters === undefined ? {} : { filters: filtersToYamlV2({ filters }, errorContext) }),
55
+ };
56
+ }
57
+ function documentPageToYaml(page, errorContext) {
58
+ const { id, visible, ...body } = page;
59
+ return {
60
+ id,
61
+ ...(visible === undefined ? {} : { visible }),
62
+ ...pageBodyToYaml(body, updateErrorContext(errorContext, { path: [id] })),
63
+ };
64
+ }
65
+ function sectionToYaml(section, errorContext) {
66
+ const { pages, ...rest } = section;
67
+ const pagesContext = updateErrorContext(errorContext, { path: ["sections", section.id, "pages"] });
68
+ return { ...rest, pages: pages.map((page) => documentPageToYaml(page, pagesContext)) };
69
+ }
70
+ function defaultsToYaml({ period, ...rest }) {
71
+ return {
72
+ ...snakeKeys(rest),
73
+ ...(period === undefined ? {} : { period: periodToYamlV2(period) }),
74
+ };
75
+ }
76
+ function contentToYaml(content, errorContext) {
77
+ const { defaults, filters, attributeFilterConfigs, pages, sections, ...rest } = content;
78
+ const held = pagesOrSectionsV2({ pages, sections }, errorContext);
79
+ const filtersContext = updateErrorContext(errorContext, { path: ["filters"] });
80
+ if (filters !== undefined) {
81
+ assertDocumentDateFiltersNameDataSet(filters, filtersContext);
82
+ }
83
+ const base = {
84
+ ...(defaults === undefined
85
+ ? {}
86
+ : {
87
+ defaults: defaultsToYaml(defaults),
88
+ }),
89
+ ...(filters === undefined && !attributeFilterConfigs?.length
90
+ ? {}
91
+ : {
92
+ filters: filtersToYamlV2({ filters: filters ?? [], attributeFilterConfigs }, filtersContext),
93
+ }),
94
+ ...snakeKeys(rest),
95
+ };
96
+ if (held.sections !== undefined) {
97
+ return { ...base, sections: held.sections.map((section) => sectionToYaml(section, errorContext)) };
98
+ }
99
+ const pagesContext = updateErrorContext(errorContext, { path: ["pages"] });
100
+ return { ...base, pages: held.pages.map((page) => documentPageToYaml(page, pagesContext)) };
101
+ }
102
+ function entityFields(entity) {
103
+ return {
104
+ version: publisherContentVersionV2,
105
+ title: entity.title,
106
+ ...(entity.description === undefined ? {} : { description: entity.description }),
107
+ ...(entity.tags === undefined ? {} : { tags: entity.tags }),
108
+ };
109
+ }
110
+ function withId({ type, ...rest }, id) {
111
+ return { type, id, ...rest };
112
+ }
113
+ function withOptionalId(entity, id) {
114
+ return id === undefined ? entity : withId(entity, id);
115
+ }
116
+ // A 1.1 document leaves `0o17` plain, which a YAML 1.2 reader turns into a number. The merge tag
117
+ // writes `<<` plain whatever its quoting, so it goes; nothing written here is a merge key.
118
+ function yaml11Tags(tags) {
119
+ return [
120
+ ...tags.filter((tag) => typeof tag === "string" || tag.tag !== "tag:yaml.org,2002:merge"),
121
+ "intOct",
122
+ ];
123
+ }
124
+ /**
125
+ * Written for YAML 1.1, which PyYAML reads, so strings such as `no`, `on` or dates stay quoted strings.
126
+ */
127
+ function toYaml(json, comment) {
128
+ const document = new Document(json, { version: "1.1", customTags: yaml11Tags });
129
+ document.commentBefore = comment;
130
+ // PyYAML resolves a plain `=` or `<<` to its value or merge tag, and safe_load rejects both.
131
+ visit(document, {
132
+ Scalar(_, node) {
133
+ if (node.value === "=" || node.value === "<<") {
134
+ node.type = Scalar.QUOTE_DOUBLE;
135
+ }
136
+ },
137
+ });
138
+ return document.toString({ lineWidth: 0 });
139
+ }
140
+ function documentToYaml(document, errorContext) {
141
+ assertPublisherContentVersionV2(document, errorContext);
142
+ return {
143
+ type: "document",
144
+ ...entityFields(document),
145
+ period: periodToYamlV2(document.period),
146
+ content: contentToYaml(document.content, updateErrorContext(errorContext, { path: ["content"] })),
147
+ };
148
+ }
149
+ function documentTemplateToYaml(template, errorContext) {
150
+ assertPublisherContentVersionV2(template, errorContext);
151
+ return {
152
+ type: "document_template",
153
+ ...entityFields(template),
154
+ content: contentToYaml(template.content, updateErrorContext(errorContext, { path: ["content"] })),
155
+ };
156
+ }
157
+ function pageTemplateToYaml(template, errorContext) {
158
+ assertPublisherContentVersionV2(template, errorContext);
159
+ return {
160
+ type: "page_template",
161
+ ...entityFields(template),
162
+ content: pageBodyToYaml(template.content, updateErrorContext(errorContext, { path: ["content"] })),
163
+ };
164
+ }
165
+ function refToId(ref, errorContext) {
166
+ return ref === undefined
167
+ ? undefined
168
+ : getIdentifier(ref, true, updateErrorContext(errorContext, { path: ["ref"] }));
169
+ }
170
+ /**
171
+ * Converts a stored v2 document to its as-code YAML.
172
+ *
173
+ * @alpha
174
+ */
175
+ export function declarativePublisherDocumentToYamlV2(document, errorContext) {
176
+ const json = withId(documentToYaml(document, errorContext), document.id);
177
+ return { content: toYaml(json, PUBLISHER_DOCUMENT_COMMENT), json };
178
+ }
179
+ /**
180
+ * Converts a stored v2 document template to its as-code YAML.
181
+ *
182
+ * @alpha
183
+ */
184
+ export function declarativePublisherDocumentTemplateToYamlV2(template, errorContext) {
185
+ const json = withId(documentTemplateToYaml(template, errorContext), template.id);
186
+ return { content: toYaml(json, PUBLISHER_DOCUMENT_TEMPLATE_COMMENT), json };
187
+ }
188
+ /**
189
+ * Converts a stored v2 page template to its as-code YAML.
190
+ *
191
+ * @alpha
192
+ */
193
+ export function declarativePublisherPageTemplateToYamlV2(template, errorContext) {
194
+ const json = withId(pageTemplateToYaml(template, errorContext), template.id);
195
+ return { content: toYaml(json, PUBLISHER_PAGE_TEMPLATE_COMMENT_V2), json };
196
+ }
197
+ /**
198
+ * Converts the v2 document the frontend holds to its as-code YAML. A document without a reference
199
+ * yet is written without an id.
200
+ *
201
+ * @alpha
202
+ */
203
+ export function publisherDocumentDefinitionToYamlV2(document, errorContext) {
204
+ const json = withOptionalId(documentToYaml(document, errorContext), refToId(document.ref, errorContext));
205
+ return { content: toYaml(json, PUBLISHER_DOCUMENT_COMMENT), json };
206
+ }
207
+ /** @alpha */
208
+ export function publisherDocumentTemplateDefinitionToYamlV2(template, errorContext) {
209
+ const json = withOptionalId(documentTemplateToYaml(template, errorContext), refToId(template.ref, errorContext));
210
+ return { content: toYaml(json, PUBLISHER_DOCUMENT_TEMPLATE_COMMENT), json };
211
+ }
212
+ /** @alpha */
213
+ export function publisherPageTemplateDefinitionToYamlV2(template, errorContext) {
214
+ const json = withOptionalId(pageTemplateToYaml(template, errorContext), refToId(template.ref, errorContext));
215
+ return { content: toYaml(json, PUBLISHER_PAGE_TEMPLATE_COMMENT_V2), json };
216
+ }