@seedtactics/insight-client 17.0.3 → 17.0.4

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.
@@ -1,4 +1,4 @@
1
- import { type Getter } from "jotai";
1
+ import { type Atom, type Getter } from "jotai";
2
2
  import type { ICurrentStatus } from "./api.js";
3
3
  type CurrentStatusSession = {
4
4
  readonly id: number;
@@ -17,6 +17,18 @@ export declare const currentStatusIsLiveRW: import("jotai").PrimitiveAtom<boolea
17
17
  export declare const errorLoadingStatusRW: import("jotai").PrimitiveAtom<string | null> & {
18
18
  init: string | null;
19
19
  };
20
+ export declare const errorLoadingCurrentStatus: Atom<string | null>;
21
+ export type CurrentStatusRequest = Readonly<{
22
+ session: number;
23
+ }>;
24
+ export declare const currentStatusRequest: Atom<Readonly<{
25
+ session: number;
26
+ }>>;
27
+ export declare const applyCurrentStatusResponse: import("jotai").WritableAtom<null, [request: Readonly<{
28
+ session: number;
29
+ }>, loaded: Readonly<ICurrentStatus>], boolean> & {
30
+ init: null;
31
+ };
20
32
  export declare function isCurrentSession(get: Getter, session: number): boolean;
21
33
  export declare const onLoadCurrentSt: import("jotai").WritableAtom<null, [status: Readonly<ICurrentStatus>], void> & {
22
34
  init: null;
@@ -41,6 +41,21 @@ export const currentStatusSessionAtom = atom({
41
41
  });
42
42
  export const currentStatusIsLiveRW = atom(false);
43
43
  export const errorLoadingStatusRW = atom(null);
44
+ export const errorLoadingCurrentStatus = errorLoadingStatusRW;
45
+ export const currentStatusRequest = atom((get) => ({
46
+ session: get(currentStatusSessionAtom).id,
47
+ }));
48
+ // Acknowledged action snapshots are authoritative, just like websocket snapshots. They may
49
+ // replace optimistic display edits. False means the response belongs to an earlier session;
50
+ // true means it was installed or a newer complete snapshot was already installed.
51
+ export const applyCurrentStatusResponse = atom(null, (get, set, request, loaded) => {
52
+ const current = get(currentStatusSessionAtom);
53
+ if (current.id !== request.session)
54
+ return false;
55
+ if (current.snapshot && loaded.revision <= current.snapshot.status.revision)
56
+ return true;
57
+ return set(acceptCurrentStatusSnapshot, request.session, loaded, "http");
58
+ });
44
59
  export function isCurrentSession(get, session) {
45
60
  return get(currentStatusSessionAtom).id === session;
46
61
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seedtactics/insight-client",
3
- "version": "17.0.3",
3
+ "version": "17.0.4",
4
4
  "license": "BSD-3-Clause",
5
5
  "repository": {
6
6
  "url": "https://github.com/SeedTactics/fms-insight"