yarramate 1.25.1 → 1.25.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.
@@ -87,6 +87,19 @@ export interface SavedView {
87
87
  readonly presentation: ProjectionDefinition["presentation"];
88
88
  readonly path: string;
89
89
  }
90
+ /**
91
+ * The saved document for a view, from what the editor holds of it.
92
+ *
93
+ * An EMPTY title or description is written as no field at all (#509). The
94
+ * schema's `presentation.title` and `.description` are non-empty text, and
95
+ * the editor reads an undeclared description back as `""`; writing that
96
+ * string back made every membership edit to an undescribed view a document
97
+ * the schema refuses (YM201), so a subject added to five of the six
98
+ * ApertureX reference views could not be committed, since 1.0.0. The
99
+ * declared presentation is spread first and its own `title`/`description`
100
+ * set aside, so an emptied field is removed rather than kept from the
101
+ * declaration: the caller's value is the whole truth about those two.
102
+ */
90
103
  export declare const composeProjection: (input: {
91
104
  readonly id: string;
92
105
  readonly title: string;
@@ -106,17 +106,35 @@ export const duplicateView = (view, taken) => {
106
106
  }),
107
107
  };
108
108
  };
109
- export const composeProjection = (input) => ({
110
- format: "yarramate/projection/v1",
111
- id: input.id,
112
- version: "1.0",
113
- query: input.query,
114
- presentation: {
115
- ...(input.presentation ?? {}),
116
- title: input.title,
117
- description: input.description,
118
- },
119
- });
109
+ /**
110
+ * The saved document for a view, from what the editor holds of it.
111
+ *
112
+ * An EMPTY title or description is written as no field at all (#509). The
113
+ * schema's `presentation.title` and `.description` are non-empty text, and
114
+ * the editor reads an undeclared description back as `""`; writing that
115
+ * string back made every membership edit to an undescribed view a document
116
+ * the schema refuses (YM201), so a subject added to five of the six
117
+ * ApertureX reference views could not be committed, since 1.0.0. The
118
+ * declared presentation is spread first and its own `title`/`description`
119
+ * set aside, so an emptied field is removed rather than kept from the
120
+ * declaration: the caller's value is the whole truth about those two.
121
+ */
122
+ export const composeProjection = (input) => {
123
+ const { title: _title, description: _description, ...declared } = input.presentation ?? {};
124
+ return {
125
+ format: "yarramate/projection/v1",
126
+ id: input.id,
127
+ version: "1.0",
128
+ query: input.query,
129
+ presentation: {
130
+ ...declared,
131
+ ...(input.title.trim() === "" ? {} : { title: input.title }),
132
+ ...(input.description.trim() === ""
133
+ ? {}
134
+ : { description: input.description }),
135
+ },
136
+ };
137
+ };
120
138
  /**
121
139
  * Whether a view can be told which subjects it holds.
122
140
  *