@antelopejs/dms 0.18.1 → 0.19.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.
Files changed (73) hide show
  1. package/CHANGELOG.md +78 -0
  2. package/README.md +2 -2
  3. package/bin/control/backend.mjs +1 -1
  4. package/bin/control/base.mjs +24 -9
  5. package/bin/control/base.test.mjs +88 -0
  6. package/bin/control/browser-client.mjs +1 -1
  7. package/bin/control/commands-stack.mjs +3 -1
  8. package/bin/control/commands-verify.mjs +5 -23
  9. package/bin/control/consumer-install.test.mjs +73 -0
  10. package/bin/control/database.mjs +66 -0
  11. package/bin/control/doctor.mjs +7 -0
  12. package/bin/control/frontend-check.mjs +2 -1
  13. package/bin/control/frontend-mode.test.mjs +24 -0
  14. package/bin/control/identity.mjs +45 -16
  15. package/bin/control/journey.mjs +31 -3
  16. package/bin/control/journey.test.mjs +207 -2
  17. package/bin/control/launch.mjs +123 -0
  18. package/bin/control/module-root.mjs +40 -0
  19. package/bin/control/module-root.test.mjs +67 -0
  20. package/bin/control/mongo-server.test.mjs +91 -0
  21. package/bin/control/mongo.mjs +125 -12
  22. package/bin/control/options.mjs +1 -0
  23. package/bin/control/pid-reuse.test.mjs +278 -0
  24. package/bin/control/processes.mjs +91 -29
  25. package/bin/control/renderer.test.mjs +1 -1
  26. package/bin/control/run-copy.mjs +6 -1
  27. package/bin/control/run-state.mjs +4 -1
  28. package/bin/control/stack.mjs +78 -165
  29. package/bin/control/verify/behaviour.test.mjs +36 -23
  30. package/bin/control/verify/decode.mjs +1 -15
  31. package/bin/control/verify/decode.test.mjs +1 -14
  32. package/bin/control/verify/emit.mjs +11 -11
  33. package/bin/control/verify/formal.mjs +28 -14
  34. package/bin/control/verify/formal.test.mjs +15 -0
  35. package/bin/control/verify/types.mjs +1 -1
  36. package/bin/control/verify/verdict.mjs +9 -42
  37. package/bin/dms-control.mjs +4 -3
  38. package/dist/db/models/userNotifications.model.js +14 -8
  39. package/dist/db/models/userNotifications.model.js.map +1 -1
  40. package/dist/pages/public/auth/not-a-member.d.ts +9 -0
  41. package/dist/pages/public/auth/not-a-member.js +27 -0
  42. package/dist/pages/public/auth/not-a-member.js.map +1 -0
  43. package/dist/pages/public/index.d.ts +1 -0
  44. package/dist/pages/public/index.js +1 -0
  45. package/dist/pages/public/index.js.map +1 -1
  46. package/dist/routes/auth/oauth/identity-resolution.js +10 -0
  47. package/dist/routes/auth/oauth/identity-resolution.js.map +1 -1
  48. package/dist/routes/onboarding.js +1 -5
  49. package/dist/routes/onboarding.js.map +1 -1
  50. package/dist/utils/ensure-default-tenant.js +23 -3
  51. package/dist/utils/ensure-default-tenant.js.map +1 -1
  52. package/frontend-vue/layers/dms-auth/app/build/utils/noWorkspaceRoute.ts +19 -0
  53. package/frontend-vue/layers/dms-auth/app/custom-pages/auth/login.vue +4 -6
  54. package/frontend-vue/layers/dms-auth/app/custom-pages/auth/not-a-member.vue +21 -0
  55. package/frontend-vue/layers/dms-auth/app/custom-pages/auth/oauth-complete.vue +2 -4
  56. package/frontend-vue/layers/dms-auth/i18n/locales/auth-en-GB.json +6 -0
  57. package/frontend-vue/layers/dms-auth/i18n/locales/auth-fr-FR.json +6 -0
  58. package/frontend-vue/layers/dms-core/app/types/live.ts +2 -0
  59. package/frontend-vue/layers/dms-ui/app/build/components/containers/drawer/DynamicDrawer.vue +9 -3
  60. package/frontend-vue/layers/dms-ui/app/build/composables/live/currentPageLive.ts +7 -0
  61. package/frontend-vue/layers/dms-ui/app/build/composables/live/pageLiveController.ts +23 -3
  62. package/frontend-vue/layers/dms-ui/app/build/composables/live/usePageDataRefresh.ts +2 -1
  63. package/frontend-vue/layers/dms-ui/app/build/composables/table-view/tableViewRealtime.ts +21 -2
  64. package/frontend-vue/layers/dms-ui/app/build/composables/table-view/useTableLiveHold.ts +4 -3
  65. package/frontend-vue/layers/dms-ui/app/build/utils/accessibilityPreferences.ts +1 -21
  66. package/frontend-vue/layers/dms-ui/app/build/utils/blockPreview.ts +8 -4
  67. package/frontend-vue/layers/dms-ui/app/build/utils/link.ts +35 -7
  68. package/frontend-vue/layers/dms-ui/app/components/chart/ApexChartHost.vue +51 -8
  69. package/frontend-vue/layers/dms-ui/app/composables/chart/useApexChart.ts +1 -1
  70. package/frontend-vue/layers/dms-ui/app/utils/reducedMotion.ts +22 -0
  71. package/package.json +4 -4
  72. package/skills/dms-pages/REFERENCE.md +1 -1
  73. package/bin/control/verify/publish.mjs +0 -186
@@ -4,6 +4,7 @@ import {
4
4
  computed,
5
5
  defineAsyncComponent,
6
6
  markRaw,
7
+ onBeforeUnmount,
7
8
  onMounted,
8
9
  ref,
9
10
  shallowRef,
@@ -29,8 +30,14 @@ interface Emits {
29
30
 
30
31
  /** The ApexCharts instance the wrapper exposes as `chart`. */
31
32
  interface ApexCore {
32
- /** Apex's own (debounced) window resize handler: redraws at the container width. */
33
- windowResizeHandler: () => void;
33
+ /**
34
+ * Apex's (debounced) redraw at the container width, the one its parent
35
+ * resize observer starts. Unlike its window resize handler it does not
36
+ * read `chart.redrawOnWindowResize`, which only opts out of window resizes.
37
+ */
38
+ _windowResize: () => void;
39
+ /** Apex's state: `animationEnded` is false while the chart is animating. */
40
+ w: { globals: { animationEnded: boolean } };
34
41
  }
35
42
 
36
43
  interface ApexChartInstance {
@@ -57,12 +64,20 @@ const ApexChart = defineAsyncComponent<Component>(async () => {
57
64
  return mod.default ?? mod;
58
65
  });
59
66
 
67
+ const hostRef = ref<HTMLElement | null>(null);
68
+ const chartRef = ref<ApexChartInstance | null>(null);
69
+ let hostResizes: ResizeObserver | undefined;
70
+
60
71
  onMounted(() => {
61
72
  void ensureApexLocale(locale.value).catch(() => undefined);
73
+ if (!hostRef.value) return;
74
+ hostResizes = new ResizeObserver(redrawIfResizedWhileIdle);
75
+ hostResizes.observe(hostRef.value);
62
76
  });
63
77
 
64
- const hostRef = ref<HTMLElement | null>(null);
65
- const chartRef = ref<ApexChartInstance | null>(null);
78
+ onBeforeUnmount(() => {
79
+ hostResizes?.disconnect();
80
+ });
66
81
 
67
82
  /**
68
83
  * A plain, non-reactive copy of a value handed to Apex. Apex writes into the
@@ -96,7 +111,24 @@ function rawApexInput<T extends object>(value: T): T {
96
111
 
97
112
  const apexSeries = computed(() => rawApexInput(props.series ?? []));
98
113
 
99
- const pinnedOptions = shallowRef<Props["options"]>(rawApexInput(props.options));
114
+ /**
115
+ * The options handed to Apex, its parent resize observer off. That observer
116
+ * redraws on any change of the host's size, height included, and a circular
117
+ * chart changes the height itself: Apex draws it at its configured height,
118
+ * then fits its box to the ring and legend, and the redraw that resize starts
119
+ * draws it at the configured height again. The donut redraws every 150ms or
120
+ * so for as long as the page is open, and a screenshot taken mid-redraw
121
+ * shows the ring off centre. The host redraws on width changes instead.
122
+ */
123
+ function apexOptions(options: Props["options"]): Props["options"] {
124
+ const chart = isObject(options.chart) ? options.chart : {};
125
+ return rawApexInput({
126
+ ...options,
127
+ chart: { ...chart, redrawOnParentResize: false },
128
+ });
129
+ }
130
+
131
+ const pinnedOptions = shallowRef<Props["options"]>(apexOptions(props.options));
100
132
 
101
133
  function pushOptionsWithoutGroupBroadcast(
102
134
  instance: ApexChartInstance,
@@ -104,7 +136,7 @@ function pushOptionsWithoutGroupBroadcast(
104
136
  ): void {
105
137
  void instance
106
138
  .updateOptions(
107
- rawApexInput(next),
139
+ apexOptions(next),
108
140
  REDRAW_PATHS,
109
141
  ANIMATE,
110
142
  UPDATE_SYNCED_CHARTS,
@@ -131,7 +163,7 @@ watch(
131
163
  (next, previous) => {
132
164
  const instance = chartRef.value;
133
165
  if (!instance || axisTypeOf(next) !== axisTypeOf(previous)) {
134
- pinnedOptions.value = rawApexInput(next);
166
+ pinnedOptions.value = apexOptions(next);
135
167
  return;
136
168
  }
137
169
  pushOptionsWithoutGroupBroadcast(instance, next);
@@ -160,7 +192,18 @@ function redrawIfResizedWhileAnimating() {
160
192
  const host = hostRef.value;
161
193
  const chart = chartRef.value?.chart;
162
194
  if (!host || !chart || !isDrawnAtStaleWidth(host)) return;
163
- chart.windowResizeHandler();
195
+ chart._windowResize();
196
+ }
197
+
198
+ /**
199
+ * The host's own resize observer, in place of Apex's: a chart drawn at
200
+ * another width than its host redraws, and a change of height alone, such as
201
+ * the one a circular chart makes when it fits its box, redraws nothing. While
202
+ * an animation runs the redraw waits for its end.
203
+ */
204
+ function redrawIfResizedWhileIdle() {
205
+ if (chartRef.value?.chart?.w.globals.animationEnded !== true) return;
206
+ redrawIfResizedWhileAnimating();
164
207
  }
165
208
  </script>
166
209
 
@@ -33,7 +33,7 @@ import {
33
33
  toBucketSeries,
34
34
  type DatetimeBuckets,
35
35
  } from "./apexDatetimeBuckets";
36
- import { isReducedMotionActive } from "../../build/utils/accessibilityPreferences";
36
+ import { isReducedMotionActive } from "../../utils/reducedMotion";
37
37
  import {
38
38
  buildDataLabels,
39
39
  dataLabelOffset,
@@ -0,0 +1,22 @@
1
+ import { isFunction } from "../../../dms-core/app/utils/type-check";
2
+ import {
3
+ REDUCED_MOTION_QUERY,
4
+ reduceMotionFromClasses,
5
+ resolveReducedMotion,
6
+ } from "../build/utils/accessibilityPreferences";
7
+
8
+ /**
9
+ * Whether the page should skip JavaScript-driven motion right now: the
10
+ * `<html>` class when the user pinned a choice, the system otherwise. Always
11
+ * false on the server, which renders no animation.
12
+ */
13
+ export function isReducedMotionActive(): boolean {
14
+ const classList = globalThis.document?.documentElement?.classList;
15
+ if (!classList) return false;
16
+ const systemPrefersReduced =
17
+ isFunction(matchMedia) && matchMedia(REDUCED_MOTION_QUERY).matches;
18
+ return resolveReducedMotion(
19
+ reduceMotionFromClasses(classList),
20
+ systemPrefersReduced,
21
+ );
22
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@antelopejs/dms",
3
- "version": "0.18.1",
3
+ "version": "0.19.0",
4
4
  "description": "AntelopeJS DMS. Plug in your PostgreSQL, MongoDB or RethinkDB database and your coding agent builds a back office and analytics dashboard as typed TypeScript. Real-time updates on the data the DMS manages.",
5
5
  "keywords": [
6
6
  "antelopejs",
@@ -78,7 +78,7 @@
78
78
  "@antelopejs/interface-data-api": ">=0.6.0 <1.0.0",
79
79
  "@antelopejs/interface-database": ">=0.3.0 <1.0.0",
80
80
  "@antelopejs/interface-database-decorators": ">=0.2.0 <1.0.0",
81
- "@antelopejs/interface-dms": ">=0.12.0 <0.13.0",
81
+ "@antelopejs/interface-dms": ">=0.13.0 <0.14.0",
82
82
  "@antelopejs/interface-email": ">=0.0.6 <1.0.0",
83
83
  "@antelopejs/interface-file-storage": ">=0.1.4 <1.0.0",
84
84
  "archiver": "^7.0.1",
@@ -112,7 +112,6 @@
112
112
  "oxfmt": "^0.66.0",
113
113
  "oxlint": "1.81.0",
114
114
  "oxlint-tsgolint": "^7.0.2001",
115
- "playwright-core": "~1.56.1",
116
115
  "release-it": "^19.2.4",
117
116
  "release-it-changelogen": "^0.1.0",
118
117
  "rimraf": "^6.1.3",
@@ -140,7 +139,8 @@
140
139
  },
141
140
  "optionalDependencies": {
142
141
  "@antelopejs/interface-dms-automation": ">=0.6.0 <1.0.0",
143
- "@antelopejs/interface-redis": ">=0.0.9 <1.0.0"
142
+ "@antelopejs/interface-redis": ">=0.0.9 <1.0.0",
143
+ "playwright-core": "~1.56.1"
144
144
  },
145
145
  "peerDependencies": {
146
146
  "@antelopejs/core": ">=1.21.0 <2"
@@ -138,7 +138,7 @@ row's ⋯ button — `docs/04.components/08.tables/0.index.md#pinned-rows`.
138
138
  an editor reads the default children from the block type's `initialChildren`.
139
139
  A component may draw `<DmsPageToolbarBlock>` and `<DmsLiveToggleBlock>` itself, around controls
140
140
  of its own: neither needs a `componentId` or `pageId` there.
141
- - `liveHold: true` keeps a table's rows while paused, and in Direct while they are on screen (new
141
+ - `liveHold: true` keeps a table's rows while paused, and in Direct while they are on screen unless `whileOnScreen: false` (new
142
142
  rows wait behind a "N new · Show" pill over the rows, counting the rows the table's query matches now beyond those held, through its count route); `liveHold: { whileRowOpen, whileScrolled,
143
143
  whileSearching, whileSorted }` also holds the table alone; `liveHold.missedLabel` words its "N new".
144
144
  Paused, an event counts as its `payload.ids` rows or its `payload.count`, so a module may batch
@@ -1,186 +0,0 @@
1
- import { execFileSync, spawnSync } from "node:child_process";
2
- import { cpSync, mkdirSync, mkdtempSync, rmSync } from "node:fs";
3
- import { tmpdir } from "node:os";
4
- import { join } from "node:path";
5
- import { git } from "../git.mjs";
6
- import { decodeCommitStatuses } from "./decode.mjs";
7
- import { originRepository } from "./verdict.mjs";
8
-
9
- const EVIDENCE_BRANCH = "verify-evidence";
10
- const SCRATCH_BRANCH = "verify-evidence-scratch";
11
-
12
- /**
13
- * @param {string} repo The checkout
14
- * @returns {boolean} Whether origin holds the evidence branch
15
- */
16
- function remoteBranchExists(repo) {
17
- return git(["ls-remote", "--heads", "origin", EVIDENCE_BRANCH], repo) !== "";
18
- }
19
-
20
- /**
21
- * Commits the run's evidence under `pr-<n>/<sha>/` of the orphan
22
- * `verify-evidence` branch and pushes it, from a temporary worktree so the
23
- * checkout under review is never touched.
24
- *
25
- * @param {import("./skill.mjs").Skill} skill The skill
26
- * @param {import("../run-state.mjs").RunState} state The run
27
- * @param {{ pr: number, headSha: string, result: string }} verdict The verdict
28
- * @returns {string} The pushed evidence commit
29
- */
30
- export function pushEvidence(skill, state, verdict) {
31
- const repo = skill.repo;
32
- const worktree = mkdtempSync(join(tmpdir(), "verify-evidence-"));
33
- try {
34
- if (remoteBranchExists(repo)) {
35
- git(
36
- [
37
- "fetch",
38
- "--quiet",
39
- "origin",
40
- `${EVIDENCE_BRANCH}:refs/remotes/origin/${EVIDENCE_BRANCH}`,
41
- ],
42
- repo,
43
- );
44
- git(
45
- [
46
- "worktree",
47
- "add",
48
- "--quiet",
49
- "--detach",
50
- worktree,
51
- `origin/${EVIDENCE_BRANCH}`,
52
- ],
53
- repo,
54
- );
55
- } else {
56
- git(
57
- [
58
- "worktree",
59
- "add",
60
- "--quiet",
61
- "--orphan",
62
- "-B",
63
- SCRATCH_BRANCH,
64
- worktree,
65
- ],
66
- repo,
67
- );
68
- }
69
- const target = join(worktree, `pr-${verdict.pr}`, verdict.headSha);
70
- rmSync(target, { recursive: true, force: true });
71
- mkdirSync(target, { recursive: true });
72
- cpSync(state.evidence, target, { recursive: true });
73
- git(["add", "--all", "."], worktree);
74
- const message = `verify: evidence for #${verdict.pr} at ${verdict.headSha.slice(0, 7)} (${verdict.result})`;
75
- git(
76
- [
77
- "-c",
78
- "commit.gpgsign=false",
79
- "commit",
80
- "--quiet",
81
- "--allow-empty",
82
- "--no-verify",
83
- "-m",
84
- message,
85
- ],
86
- worktree,
87
- );
88
- git(
89
- [
90
- "push",
91
- "--quiet",
92
- "--no-verify",
93
- "origin",
94
- `HEAD:refs/heads/${EVIDENCE_BRANCH}`,
95
- ],
96
- worktree,
97
- );
98
- return git(["rev-parse", "HEAD"], worktree);
99
- } finally {
100
- git(["worktree", "remove", "--force", worktree], repo);
101
- if (git(["branch", "--list", SCRATCH_BRANCH], repo) !== "") {
102
- git(["branch", "--quiet", "-D", SCRATCH_BRANCH], repo);
103
- }
104
- }
105
- }
106
-
107
- /**
108
- * Posts the verdict as a PR comment.
109
- *
110
- * @param {import("./skill.mjs").Skill} skill The skill
111
- * @param {{ pr: number, markdown: string }} verdict The verdict
112
- * @returns {string} The comment URL gh prints
113
- */
114
- export function postComment(skill, verdict) {
115
- return execFileSync(
116
- "gh",
117
- [
118
- "pr",
119
- "comment",
120
- String(verdict.pr),
121
- "--repo",
122
- originRepository(skill.repo),
123
- "--body",
124
- verdict.markdown,
125
- ],
126
- { cwd: skill.repo, encoding: "utf8" },
127
- ).trim();
128
- }
129
-
130
- /**
131
- * Sets the `verify` commit status on the head SHA the verdict judged:
132
- * `success` for PASS and PASS+NOTES, `failure` for FAIL.
133
- *
134
- * @param {import("./skill.mjs").Skill} skill The skill
135
- * @param {{ headSha: string, result: string }} verdict The verdict
136
- * @param {string} targetUrl The comment URL
137
- * @returns {string | null} GitHub's error when the status could not be set
138
- */
139
- export function setStatus(skill, verdict, targetUrl) {
140
- const state = verdict.result === "FAIL" ? "failure" : "success";
141
- const result = spawnSync(
142
- "gh",
143
- [
144
- "api",
145
- "--silent",
146
- `repos/${originRepository(skill.repo)}/statuses/${verdict.headSha}`,
147
- "-f",
148
- `state=${state}`,
149
- "-f",
150
- "context=verify",
151
- "-f",
152
- `description=${skill.name}: ${verdict.result}`,
153
- "-f",
154
- `target_url=${targetUrl}`,
155
- ],
156
- { cwd: skill.repo, encoding: "utf8" },
157
- );
158
- return result.status === 0
159
- ? null
160
- : `${result.stderr}${result.stdout}`.trim() || `gh exited ${result.status}`;
161
- }
162
-
163
- /**
164
- * Reads back the `verify` status GitHub holds for a SHA, so the write is
165
- * checked through a second command.
166
- *
167
- * @param {import("./skill.mjs").Skill} skill The skill
168
- * @param {string} sha The commit
169
- * @returns {string} The status state, or `absent`
170
- */
171
- export function readStatus(skill, sha) {
172
- const answer = execFileSync(
173
- "gh",
174
- ["api", `repos/${originRepository(skill.repo)}/commits/${sha}/statuses`],
175
- {
176
- cwd: skill.repo,
177
- encoding: "utf8",
178
- },
179
- );
180
- /** @type {unknown} */
181
- const stored = JSON.parse(answer);
182
- const statuses = decodeCommitStatuses(stored, "gh api statuses");
183
- return (
184
- statuses.find((status) => status.context === "verify")?.state ?? "absent"
185
- );
186
- }