@antelopejs/dms 0.18.2 → 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 (69) hide show
  1. package/CHANGELOG.md +60 -0
  2. package/README.md +1 -1
  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/consumer-install.test.mjs +73 -0
  9. package/bin/control/database.mjs +66 -0
  10. package/bin/control/doctor.mjs +7 -0
  11. package/bin/control/frontend-check.mjs +2 -1
  12. package/bin/control/frontend-mode.test.mjs +24 -0
  13. package/bin/control/identity.mjs +45 -16
  14. package/bin/control/journey.mjs +31 -3
  15. package/bin/control/journey.test.mjs +207 -2
  16. package/bin/control/launch.mjs +123 -0
  17. package/bin/control/module-root.mjs +40 -0
  18. package/bin/control/module-root.test.mjs +67 -0
  19. package/bin/control/mongo-server.test.mjs +91 -0
  20. package/bin/control/mongo.mjs +125 -12
  21. package/bin/control/options.mjs +1 -0
  22. package/bin/control/pid-reuse.test.mjs +278 -0
  23. package/bin/control/processes.mjs +91 -29
  24. package/bin/control/renderer.test.mjs +1 -1
  25. package/bin/control/run-copy.mjs +6 -1
  26. package/bin/control/run-state.mjs +4 -1
  27. package/bin/control/stack.mjs +78 -165
  28. package/bin/control/verify/behaviour.test.mjs +36 -23
  29. package/bin/control/verify/decode.mjs +1 -0
  30. package/bin/control/verify/emit.mjs +11 -11
  31. package/bin/control/verify/formal.mjs +28 -14
  32. package/bin/control/verify/formal.test.mjs +15 -0
  33. package/bin/control/verify/types.mjs +1 -1
  34. package/bin/dms-control.mjs +4 -2
  35. package/dist/db/models/userNotifications.model.js +14 -8
  36. package/dist/db/models/userNotifications.model.js.map +1 -1
  37. package/dist/pages/public/auth/not-a-member.d.ts +9 -0
  38. package/dist/pages/public/auth/not-a-member.js +27 -0
  39. package/dist/pages/public/auth/not-a-member.js.map +1 -0
  40. package/dist/pages/public/index.d.ts +1 -0
  41. package/dist/pages/public/index.js +1 -0
  42. package/dist/pages/public/index.js.map +1 -1
  43. package/dist/routes/auth/oauth/identity-resolution.js +10 -0
  44. package/dist/routes/auth/oauth/identity-resolution.js.map +1 -1
  45. package/dist/routes/onboarding.js +1 -5
  46. package/dist/routes/onboarding.js.map +1 -1
  47. package/dist/utils/ensure-default-tenant.js +23 -3
  48. package/dist/utils/ensure-default-tenant.js.map +1 -1
  49. package/frontend-vue/layers/dms-auth/app/build/utils/noWorkspaceRoute.ts +19 -0
  50. package/frontend-vue/layers/dms-auth/app/custom-pages/auth/login.vue +4 -6
  51. package/frontend-vue/layers/dms-auth/app/custom-pages/auth/not-a-member.vue +21 -0
  52. package/frontend-vue/layers/dms-auth/app/custom-pages/auth/oauth-complete.vue +2 -4
  53. package/frontend-vue/layers/dms-auth/i18n/locales/auth-en-GB.json +6 -0
  54. package/frontend-vue/layers/dms-auth/i18n/locales/auth-fr-FR.json +6 -0
  55. package/frontend-vue/layers/dms-core/app/types/live.ts +2 -0
  56. package/frontend-vue/layers/dms-ui/app/build/components/containers/drawer/DynamicDrawer.vue +9 -3
  57. package/frontend-vue/layers/dms-ui/app/build/composables/live/currentPageLive.ts +7 -0
  58. package/frontend-vue/layers/dms-ui/app/build/composables/live/pageLiveController.ts +23 -3
  59. package/frontend-vue/layers/dms-ui/app/build/composables/live/usePageDataRefresh.ts +2 -1
  60. package/frontend-vue/layers/dms-ui/app/build/composables/table-view/tableViewRealtime.ts +21 -2
  61. package/frontend-vue/layers/dms-ui/app/build/composables/table-view/useTableLiveHold.ts +4 -3
  62. package/frontend-vue/layers/dms-ui/app/build/utils/accessibilityPreferences.ts +1 -21
  63. package/frontend-vue/layers/dms-ui/app/build/utils/blockPreview.ts +8 -4
  64. package/frontend-vue/layers/dms-ui/app/build/utils/link.ts +35 -7
  65. package/frontend-vue/layers/dms-ui/app/components/chart/ApexChartHost.vue +51 -8
  66. package/frontend-vue/layers/dms-ui/app/composables/chart/useApexChart.ts +1 -1
  67. package/frontend-vue/layers/dms-ui/app/utils/reducedMotion.ts +22 -0
  68. package/package.json +4 -4
  69. package/skills/dms-pages/REFERENCE.md +1 -1
@@ -1,5 +1,8 @@
1
1
  import { usePageLive } from "../../../composables/live/usePageLive";
2
- import type { RealtimeTopicHandler } from "#dms-core/app/composables/realtime/useUserRealtime";
2
+ import {
3
+ useUserRealtime,
4
+ type RealtimeTopicHandler,
5
+ } from "#dms-core/app/composables/realtime/useUserRealtime";
3
6
  import type { RealtimePresenceMap } from "./tableViewTypes";
4
7
  import type { TableViewScope } from "./tableViewScope";
5
8
 
@@ -51,13 +54,19 @@ export function useTableViewRowRealtime<T extends Data>(
51
54
  data.value = { ...data.value, results: next };
52
55
  };
53
56
 
57
+ let rowReadCount = 0;
58
+ const appliedRowReads = new Map<string, number>();
59
+
54
60
  const patchRowLocal = async (id: string) => {
55
61
  if (!data.value?.results) return;
56
62
  const idx = data.value.results.findIndex((row) => getRowId(row) === id);
57
63
  if (idx === -1) return;
64
+ rowReadCount += 1;
65
+ const read = rowReadCount;
58
66
  try {
59
67
  const fresh = await tableRows.getRow(id);
60
- if (!fresh) return;
68
+ if (!fresh || read < (appliedRowReads.get(id) ?? 0)) return;
69
+ appliedRowReads.set(id, read);
61
70
  const next = [...data.value.results];
62
71
  next[idx] = fresh;
63
72
  data.value = { ...data.value, results: next };
@@ -81,6 +90,7 @@ export function useTableViewRowEvents<T extends Data>(
81
90
  scope: Pick<
82
91
  TableViewScope<T>,
83
92
  | "configuration"
93
+ | "listState"
84
94
  | "rowRealtime"
85
95
  | "rowCommands"
86
96
  | "refresh"
@@ -89,6 +99,7 @@ export function useTableViewRowEvents<T extends Data>(
89
99
  >,
90
100
  ) {
91
101
  const { REALTIME_EVENT_TYPE } = scope.configuration;
102
+ const { isListLoading } = scope.listState;
92
103
  const { removeRowsLocal, patchRowLocal, realtimeRowTopic } =
93
104
  scope.rowRealtime;
94
105
  const { deselectRows } = scope.rowCommands;
@@ -115,6 +126,10 @@ export function useTableViewRowEvents<T extends Data>(
115
126
  ]);
116
127
  return;
117
128
  }
129
+ if (isListLoading.value) {
130
+ await refreshAll();
131
+ return;
132
+ }
118
133
  await Promise.all([
119
134
  ...ids.map((id) => patchRowLocal(id)),
120
135
  refreshCounts(),
@@ -148,5 +163,9 @@ export function useTableViewRowEvents<T extends Data>(
148
163
  }
149
164
  void handler(ids);
150
165
  });
166
+
167
+ watch(useUserRealtime().pageTopics, (topics) => {
168
+ if (realtimeRowTopic.value && topics.length > 0) liveGate.owe();
169
+ });
151
170
  return {};
152
171
  }
@@ -124,14 +124,15 @@ function useLocalHold(
124
124
  const target = tableElement();
125
125
  return target instanceof HTMLElement ? target : null;
126
126
  };
127
+ const holdsOnScreen = !!holdOptions && holdOptions.whileOnScreen !== false;
127
128
  const isScrolled = useScrolledPastTop(element, !!holdOptions?.whileScrolled);
128
- const isReached = useTableReached(element, !!holdOptions);
129
+ const isReached = useTableReached(element, holdsOnScreen);
129
130
  const reasons: Array<[LocalHoldReason, boolean, () => boolean]> = [
130
131
  ["rowOpen", !!holdOptions?.whileRowOpen, signals.isRowOpen ?? NEVER],
131
132
  ["searching", !!holdOptions?.whileSearching, signals.isSearching ?? NEVER],
132
133
  ["sorted", !!holdOptions?.whileSorted, signals.isSorted ?? NEVER],
133
134
  ["scrolled", !!holdOptions?.whileScrolled, () => isScrolled.value],
134
- ["reading", !!holdOptions, () => isReached.value],
135
+ ["reading", holdsOnScreen, () => isReached.value],
135
136
  ];
136
137
  return computed(
137
138
  () =>
@@ -143,7 +144,7 @@ function useLocalHold(
143
144
  /**
144
145
  * The `liveHold` of a table view: while its live page is paused, while its
145
146
  * rows are on screen or scrolled past (rows landing at the top would move
146
- * them) — or, with `whileRowOpen` / `whileSearching` / `whileSorted` /
147
+ * them; not with `whileOnScreen: false`) — or, with `whileRowOpen` / `whileSearching` / `whileSorted` /
147
148
  * `whileScrolled`, saying so, while the user reads a row, searches, sorts or
148
149
  * scrolled down — the table keeps its rows: the gate requests nothing on its events and counts them, and a
149
150
  * source route is told the moment they were frozen, so the user's own
@@ -3,11 +3,7 @@
3
3
  * `auto` follows the operating system's `prefers-reduced-motion`; `on` and
4
4
  * `off` pin the choice whatever the system says.
5
5
  */
6
- import {
7
- isObject,
8
- isString,
9
- isFunction,
10
- } from "../../../../dms-core/app/utils/type-check";
6
+ import { isObject, isString } from "../../../../dms-core/app/utils/type-check";
11
7
  export type ReduceMotionPreference = "auto" | "on" | "off";
12
8
 
13
9
  export interface AccessibilityPreferences {
@@ -124,19 +120,3 @@ export function reduceMotionFromClasses(
124
120
  if (classList.contains(ACCESSIBILITY_HTML_CLASSES.fullMotion)) return "off";
125
121
  return "auto";
126
122
  }
127
-
128
- /**
129
- * Whether the page should skip JavaScript-driven motion right now: the
130
- * `<html>` class when the user pinned a choice, the system otherwise. Always
131
- * false on the server, which renders no animation.
132
- */
133
- export function isReducedMotionActive(): boolean {
134
- const classList = globalThis.document?.documentElement?.classList;
135
- if (!classList) return false;
136
- const systemPrefersReduced =
137
- isFunction(matchMedia) && matchMedia(REDUCED_MOTION_QUERY).matches;
138
- return resolveReducedMotion(
139
- reduceMotionFromClasses(classList),
140
- systemPrefersReduced,
141
- );
142
- }
@@ -369,14 +369,18 @@ function readsRouteSource(options: Record<string, unknown>): boolean {
369
369
  return isRecord(source) && isString(source.fetchUrl);
370
370
  }
371
371
 
372
- /** Serialized resource fields may read the preview's immutable demo record. */
373
- function readsFixtureForm(
372
+ /**
373
+ * Whether a resource form was serialized with its fields and the URL of the
374
+ * record it reads, and saves nowhere: drawn like a `Form`, its `fetchUrl`
375
+ * checked by {@link OPTION_RULES} like any other block's URL.
376
+ */
377
+ function readsSerializedForm(
374
378
  blockType: PreviewBlockType,
375
379
  options: Record<string, unknown>,
376
380
  ): boolean {
377
381
  return (
378
382
  blockType.componentName === "dms-form" &&
379
- options.fetchUrl === "/api/block-preview/fixtures/workspace" &&
383
+ isString(options.fetchUrl) &&
380
384
  Array.isArray(options.fields) &&
381
385
  !options.submitUrl
382
386
  );
@@ -396,7 +400,7 @@ function issueFor(
396
400
  if (
397
401
  match.blockType.needsController &&
398
402
  !readsRouteSource(options) &&
399
- !readsFixtureForm(match.blockType, options)
403
+ !readsSerializedForm(match.blockType, options)
400
404
  ) {
401
405
  return { key: "needs_backend", name: match.name };
402
406
  }
@@ -16,17 +16,45 @@ export const EXTERNAL_LINK_ATTRIBUTES = {
16
16
  rel: "noopener noreferrer",
17
17
  } as const;
18
18
 
19
+ function pathOnThisSite(to: string): string {
20
+ const url = new URL(to, window.location.href);
21
+ return `${url.pathname}${url.search}${url.hash}`;
22
+ }
23
+
24
+ function isPlainClick(event: MouseEvent): boolean {
25
+ return !(
26
+ event.defaultPrevented ||
27
+ event.button !== 0 ||
28
+ event.altKey ||
29
+ event.ctrlKey ||
30
+ event.metaKey ||
31
+ event.shiftKey
32
+ );
33
+ }
34
+
19
35
  /**
20
36
  * Props for a `UButton` (or `ULink`) following `to`, its page tokens
21
37
  * (`{{params.X}}`, `{{query.X}}`) filled: an external target opens in a new
22
- * tab, the others navigate in place.
38
+ * tab, the others navigate in place. A DMS route keeps its `href` for a new
39
+ * tab, but a plain click goes through `navigateDms`, read against the page
40
+ * on screen, so a link that changes only the query (`?status=pending` or a
41
+ * full path) stays in the browser: Nuxt UI's Inertia link, which
42
+ * `external` turns off, would ask the server for the page.
23
43
  */
24
- export function buttonLinkProps(
25
- declared: string | undefined,
26
- ): Record<string, string> {
44
+ export function buttonLinkProps(declared: string | undefined) {
27
45
  const to = pageLink(declared);
28
46
  if (!to) return {};
29
- return linkKind(to) === "external"
30
- ? { to, ...EXTERNAL_LINK_ATTRIBUTES }
31
- : { to };
47
+ const kind = linkKind(to);
48
+ if (kind === "external") return { to, ...EXTERNAL_LINK_ATTRIBUTES };
49
+ if (kind === "anchor") return { to };
50
+ return {
51
+ to,
52
+ external: true,
53
+ noRel: true,
54
+ onClick: (event: MouseEvent) => {
55
+ if (!isPlainClick(event)) return;
56
+ event.preventDefault();
57
+ void navigateDms(pathOnThisSite(to));
58
+ },
59
+ };
32
60
  }
@@ -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.2",
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