1import { WS_METHODS } from "@t3tools/contracts";
2import {
3 createEnvironmentRpcCommand,
4 createEnvironmentRpcQueryAtomFamily,
5 createEnvironmentRpcSubscriptionAtomFamily,
6} from "@t3tools/client-runtime/state/runtime";
7import { connectionAtomRuntime } from "../connection/runtime";
8
9export const jjEnvironment = {
10 stack: createEnvironmentRpcSubscriptionAtomFamily(connectionAtomRuntime, {
11 label: "jj:stack",
12 tag: WS_METHODS.jjSubscribeStack,
13 }),
14 // A range of commit ids never changes, so a cached diff stays valid.
15 diff: createEnvironmentRpcQueryAtomFamily(connectionAtomRuntime, {
16 label: "jj:diff",
17 tag: WS_METHODS.jjDiff,
18 staleTimeMs: 60 * 60_000,
19 }),
20 snapshot: createEnvironmentRpcCommand(connectionAtomRuntime, {
21 label: "jj:snapshot",
22 tag: WS_METHODS.jjSnapshot,
23 }),
24 describe: createEnvironmentRpcCommand(connectionAtomRuntime, {
25 label: "jj:describe",
26 tag: WS_METHODS.jjDescribe,
27 }),
28 squash: createEnvironmentRpcCommand(connectionAtomRuntime, {
29 label: "jj:squash",
30 tag: WS_METHODS.jjSquash,
31 }),
32 push: createEnvironmentRpcCommand(connectionAtomRuntime, {
33 label: "jj:push",
34 tag: WS_METHODS.jjPush,
35 }),
36};