@reventlessdev/trait-attachments 1.0.0-alpha.89 → 1.0.0-alpha.90

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": "@reventlessdev/trait-attachments",
3
- "version": "1.0.0-alpha.89",
3
+ "version": "1.0.0-alpha.90",
4
4
  "description": "Attachments domain trait: rules, host contract, conformance suite and emitter for an ordered set of stored files on an entity, with a primary and captions",
5
5
  "license": "Apache-2.0",
6
6
  "files": [
@@ -13,8 +13,8 @@
13
13
  "dependencies": {
14
14
  "sury": "11.1.0",
15
15
  "sury-ppx": "11.1.0",
16
- "@reventlessdev/reventless-gwt": "1.0.0-alpha.287",
17
- "@reventlessdev/reventless-spec": "3.0.0-alpha.200"
16
+ "@reventlessdev/reventless-gwt": "1.0.0-alpha.288",
17
+ "@reventlessdev/reventless-spec": "3.0.0-alpha.201"
18
18
  },
19
19
  "devDependencies": {
20
20
  "rescript": "12.3.1"
@@ -168,12 +168,15 @@ let evolve = (t, fact) =>
168
168
  }
169
169
  }
170
170
 
171
+ /** The one refusal the set owns: a primary or a caption on a ref it does not hold. */
172
+ type refusal = NotAttached
173
+
171
174
  // Shared by the two captioning ops, which differ only in how they arrive at a
172
175
  // ref. Spelled once so a named caption and the primary's caption cannot end up
173
176
  // with different ideas of what a repeat is.
174
- let setAltText = (t, ~ref, ~altText): result<array<fact>, [#NotAttached]> =>
177
+ let setAltText = (t, ~ref, ~altText): result<array<fact>, refusal> =>
175
178
  if !(t.attached->Array.includes(ref)) {
176
- Error(#NotAttached)
179
+ Error(NotAttached)
177
180
  } else if altTextOf(t, ref) == Some(altText) {
178
181
  Ok([])
179
182
  } else {
@@ -192,7 +195,7 @@ and an event log records both. Collapsing them into a single "replaced" fact
192
195
  would make a host declare an event that only bounded hosts have, which is one
193
196
  more way the two cardinalities' emitted surfaces could diverge.
194
197
  */
195
- let decideFacts = (t, ~cardinality: cardinality=Many, op): result<array<fact>, [#NotAttached]> =>
198
+ let decideFacts = (t, ~cardinality: cardinality=Many, op): result<array<fact>, refusal> =>
196
199
  switch op {
197
200
  | Attach({ref, altText}) =>
198
201
  if t.attached->Array.includes(ref) {
@@ -211,7 +214,7 @@ let decideFacts = (t, ~cardinality: cardinality=Many, op): result<array<fact>, [
211
214
  | Clear => Ok(t.attached->Array.map(r => Removed({ref: r})))
212
215
  | SetPrimary({ref}) =>
213
216
  if !(t.attached->Array.includes(ref)) {
214
- Error(#NotAttached)
217
+ Error(NotAttached)
215
218
  } else if effectivePrimary(t) == Some(ref) {
216
219
  Ok([])
217
220
  } else {
@@ -223,7 +226,7 @@ let decideFacts = (t, ~cardinality: cardinality=Many, op): result<array<fact>, [
223
226
  | SetPrimaryAltText({altText}) =>
224
227
  switch effectivePrimary(t) {
225
228
  | Some(ref) => setAltText(t, ~ref, ~altText)
226
- | None => Error(#NotAttached)
229
+ | None => Error(NotAttached)
227
230
  }
228
231
  }
229
232
 
@@ -238,7 +241,7 @@ be an arm that forgot — and the ops where it moves without anybody choosing (a
238
241
  first attachment, a removal that promotes the next) are exactly the ones where
239
242
  forgetting is easiest.
240
243
  */
241
- let decide = (t, ~cardinality: cardinality=Many, op): result<array<fact>, [#NotAttached]> =>
244
+ let decide = (t, ~cardinality: cardinality=Many, op): result<array<fact>, refusal> =>
242
245
  switch decideFacts(t, ~cardinality, op) {
243
246
  | Error(_) as e => e
244
247
  | Ok(facts) =>
@@ -537,7 +537,7 @@ let sliceDecision = (c: config): string => {
537
537
  single
538
538
  ? ` switch state.attachments->Attachments.decide(~cardinality=Single, op) {`
539
539
  : ` switch state.attachments->Attachments.decide(op) {`,
540
- ` | Error(#NotAttached) => Error(${n.notAttached})`,
540
+ ` | Error(Attachments.NotAttached) => Error(${n.notAttached})`,
541
541
  single
542
542
  ? ` | Ok(facts) => Ok(facts->Array.filterMap(toEvent(${c.entityId}, _)))`
543
543
  : ` | Ok(facts) => Ok(facts->Array.map(toEvent(${c.entityId}, _)))`,
@@ -370,7 +370,7 @@ function sliceDecision(c) {
370
370
  ` // is a complete graft, so leaving this is legitimate.`,
371
371
  ` let (` + c.entityId + `, op) = toOp(command)`,
372
372
  single ? ` switch state.attachments->Attachments.decide(~cardinality=Single, op) {` : ` switch state.attachments->Attachments.decide(op) {`,
373
- ` | Error(#NotAttached) => Error(` + n.notAttached + `)`,
373
+ ` | Error(Attachments.NotAttached) => Error(` + n.notAttached + `)`,
374
374
  single ? ` | Ok(facts) => Ok(facts->Array.filterMap(toEvent(` + c.entityId + `, _)))` : ` | Ok(facts) => Ok(facts->Array.map(toEvent(` + c.entityId + `, _)))`,
375
375
  ` }`,
376
376
  ` }`,