@cloudcrane/app-spec 0.7.0 → 0.7.1

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.
@@ -17,7 +17,10 @@ export function memoryProblems(spec) {
17
17
  if (spec.data.initial !== undefined && !validate(spec.data.initial))
18
18
  for (const e of validate.errors ?? [])
19
19
  problems.push({ at: `data.initial${e.instancePath.replace(/\//g, ".")}`, problem: `doesn't fit data.schema: ${e.message ?? "invalid"}` });
20
- // Every step from 1 to the current version, once each, so any older phone can come up to date.
20
+ // Every step from 1 to the current version, once each, so any older phone can come up to date. A page spec (an HTML
21
+ // app as a spec) moves its own data in its own code, as the page it is, so it has no migrations to check.
22
+ if (spec.page)
23
+ return [...problems, ...personalProblems(spec)];
21
24
  const steps = new Map();
22
25
  for (const m of spec.data.migrations)
23
26
  steps.set(m.from, (steps.get(m.from) ?? 0) + 1);
@@ -28,11 +31,11 @@ export function memoryProblems(spec) {
28
31
  if (n > 1)
29
32
  problems.push({ at: "data.migrations", problem: `${n} steps from version ${from}; there must be one` });
30
33
  }
31
- // Personal fields name something the saved data has.
32
- for (const pointer of spec.data.personal ?? [])
33
- if (!pointsInto(spec.data.schema, pointer))
34
- problems.push({ at: `data.personal ${pointer}`, problem: "the saved data has no such field (data.schema)" });
35
- return problems;
34
+ return [...problems, ...personalProblems(spec)];
35
+ }
36
+ /** Personal fields name something the saved data has. */
37
+ function personalProblems(spec) {
38
+ return (spec.data.personal ?? []).flatMap((pointer) => pointsInto(spec.data.schema, pointer) ? [] : [{ at: `data.personal ${pointer}`, problem: "the saved data has no such field (data.schema)" }]);
36
39
  }
37
40
  /** Whether a JSON Pointer names a field the schema describes (properties all the way down; arrays and maps by their items). */
38
41
  function pointsInto(schema, pointer) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloudcrane/app-spec",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "The CloudCrane app spec: its schema, the expression language its rules are written in, and the checks that keep partner code out of it.",
5
5
  "keywords": [
6
6
  "cloudcrane",