@voltro/plugin-gm 0.0.0-stage → 0.88.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.
- package/CHANGELOG.md +24492 -0
- package/LICENSE +61 -0
- package/README.md +46 -2
- package/SECURITY.md +56 -0
- package/THIRD-PARTY-NOTICES.md +5603 -0
- package/dist/action.js +3 -0
- package/dist/builtins.js +348 -0
- package/dist/contract.js +28 -0
- package/dist/entities.js +21 -0
- package/dist/errors.d.ts +15 -0
- package/dist/errors.js +18 -0
- package/dist/index.d.ts +498 -0
- package/dist/index.js +107 -0
- package/dist/inspect.js +21 -0
- package/dist/rpc.d.ts +103 -0
- package/dist/rpc.js +62 -0
- package/dist/service.js +257 -0
- package/dist/testing.d.ts +206 -0
- package/dist/testing.js +68 -0
- package/dist/web.d.ts +123 -0
- package/dist/web.js +6 -0
- package/package.json +81 -4
package/dist/testing.js
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { gmTables as e } from "./entities.js";
|
|
2
|
+
import { dataStoreGm as t, defaultGmApprovalWhen as n, defaultGmAuthorize as r, resolveGmOptions as i } from "./service.js";
|
|
3
|
+
import { defineGmAction as a } from "./action.js";
|
|
4
|
+
import { Effect as o, Schema as s } from "effect";
|
|
5
|
+
import { ensureTableRegistered as c } from "@voltro/database";
|
|
6
|
+
import { InMemoryDataStore as l } from "@voltro/runtime";
|
|
7
|
+
// src/testing.ts
|
|
8
|
+
var u = (e = "routine") => a({
|
|
9
|
+
id: "probe.note",
|
|
10
|
+
title: "Probe note",
|
|
11
|
+
risk: e,
|
|
12
|
+
input: s.Struct({ text: s.String }),
|
|
13
|
+
output: s.Struct({ echo: s.String }),
|
|
14
|
+
target: () => null,
|
|
15
|
+
execute: (e) => o.succeed({ echo: e.text })
|
|
16
|
+
}), d = (n) => {
|
|
17
|
+
e.forEach(c);
|
|
18
|
+
let r = new l();
|
|
19
|
+
return {
|
|
20
|
+
store: r,
|
|
21
|
+
gm: t(r, i({
|
|
22
|
+
now: () => Date.UTC(2026, 9, 18),
|
|
23
|
+
...n
|
|
24
|
+
}))
|
|
25
|
+
};
|
|
26
|
+
}, f = (e) => ({
|
|
27
|
+
type: "user",
|
|
28
|
+
id: "staff",
|
|
29
|
+
tenantId: "tenant",
|
|
30
|
+
scopes: [...e]
|
|
31
|
+
}), p = (e, t) => o.suspend(() => d(e).gm.api.actions(f(t))).pipe(o.map((e) => e.map((e) => e.id))), m = (e) => o.suspend(() => d(e).gm.api.execute(f(["gm:*"]), {
|
|
32
|
+
requestId: "slot",
|
|
33
|
+
actionId: "probe.note",
|
|
34
|
+
input: { text: "x" },
|
|
35
|
+
reason: "Probe"
|
|
36
|
+
})).pipe(o.map((e) => e.state)), h = {
|
|
37
|
+
kind: "slot",
|
|
38
|
+
defaultImplementation: r,
|
|
39
|
+
defaultProbe: {
|
|
40
|
+
run: () => p({ actions: [u()] }, ["gm:probe.*"]),
|
|
41
|
+
expected: ["probe.note"]
|
|
42
|
+
},
|
|
43
|
+
overrideProbe: {
|
|
44
|
+
run: () => p({
|
|
45
|
+
actions: [u()],
|
|
46
|
+
authorize: () => !1
|
|
47
|
+
}, ["gm:probe.*"]),
|
|
48
|
+
expected: []
|
|
49
|
+
}
|
|
50
|
+
}, g = {
|
|
51
|
+
kind: "slot",
|
|
52
|
+
defaultImplementation: n,
|
|
53
|
+
defaultProbe: {
|
|
54
|
+
run: () => m({
|
|
55
|
+
actions: [u("sensitive")],
|
|
56
|
+
approval: {}
|
|
57
|
+
}),
|
|
58
|
+
expected: "pending"
|
|
59
|
+
},
|
|
60
|
+
overrideProbe: {
|
|
61
|
+
run: () => m({
|
|
62
|
+
actions: [u("sensitive")],
|
|
63
|
+
approval: { when: () => !1 }
|
|
64
|
+
}),
|
|
65
|
+
expected: "executed"
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
export { g as gmApprovalSlotFixture, h as gmAuthorizeSlotFixture, d as gmFixture, u as gmProbeAction };
|
package/dist/web.d.ts
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { ActionState } from '@voltro/client';
|
|
2
|
+
import { Schema } from 'effect';
|
|
3
|
+
import { SubscriptionState } from '@voltro/client';
|
|
4
|
+
|
|
5
|
+
export declare type GmActionInfo = typeof GmActionInfoSchema.Type;
|
|
6
|
+
|
|
7
|
+
/** One action the caller may run; `input` is the JSON Schema of the encoded input a console renders its form from. */
|
|
8
|
+
declare const GmActionInfoSchema: Schema.Struct<{
|
|
9
|
+
readonly id: Schema.String;
|
|
10
|
+
readonly title: Schema.String;
|
|
11
|
+
readonly risk: Schema.Literals<readonly ["routine", "sensitive"]>;
|
|
12
|
+
readonly input: Schema.Unknown;
|
|
13
|
+
}>;
|
|
14
|
+
|
|
15
|
+
export declare interface GmExecuteInput {
|
|
16
|
+
readonly requestId: string;
|
|
17
|
+
readonly actionId: string;
|
|
18
|
+
readonly input: unknown;
|
|
19
|
+
readonly reason: string;
|
|
20
|
+
readonly ticket?: string | undefined;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export declare type GmRequest = typeof GmRequestSchema.Type;
|
|
24
|
+
|
|
25
|
+
declare const GmRequestSchema: Schema.Struct<{
|
|
26
|
+
readonly id: Schema.String;
|
|
27
|
+
readonly actionId: Schema.String;
|
|
28
|
+
readonly state: Schema.Literals<readonly ["pending", "approved", "executed", "rejected"]>;
|
|
29
|
+
readonly targetId: Schema.NullOr<Schema.String>;
|
|
30
|
+
readonly input: Schema.Unknown;
|
|
31
|
+
readonly output: Schema.NullOr<Schema.Unknown>;
|
|
32
|
+
readonly reason: Schema.String;
|
|
33
|
+
readonly ticket: Schema.NullOr<Schema.String>;
|
|
34
|
+
readonly requesterId: Schema.NullOr<Schema.String>;
|
|
35
|
+
readonly approverId: Schema.NullOr<Schema.String>;
|
|
36
|
+
readonly createdAt: Schema.Number;
|
|
37
|
+
readonly decidedAt: Schema.NullOr<Schema.Number>;
|
|
38
|
+
readonly executedAt: Schema.NullOr<Schema.Number>;
|
|
39
|
+
}>;
|
|
40
|
+
|
|
41
|
+
export declare type GmRequestState = typeof REQUEST_STATES[number];
|
|
42
|
+
|
|
43
|
+
/** pending: waits for a second person. approved: may run (retries re-run the idempotent action). executed and rejected are terminal. */
|
|
44
|
+
declare const REQUEST_STATES: readonly ["pending", "approved", "executed", "rejected"];
|
|
45
|
+
|
|
46
|
+
/** Actions the signed-in staff member may run, each with the JSON Schema of its input. */
|
|
47
|
+
export declare const useGmActions: (apiName?: string) => SubscriptionState<readonly {
|
|
48
|
+
readonly id: string;
|
|
49
|
+
readonly title: string;
|
|
50
|
+
readonly risk: "sensitive" | "routine";
|
|
51
|
+
readonly input: unknown;
|
|
52
|
+
}[]>;
|
|
53
|
+
|
|
54
|
+
export declare const useGmApprove: (apiName?: string) => ActionState<{
|
|
55
|
+
readonly id: string;
|
|
56
|
+
}, {
|
|
57
|
+
readonly id: string;
|
|
58
|
+
readonly actionId: string;
|
|
59
|
+
readonly state: "rejected" | "pending" | "approved" | "executed";
|
|
60
|
+
readonly targetId: string | null;
|
|
61
|
+
readonly input: unknown;
|
|
62
|
+
readonly output: unknown;
|
|
63
|
+
readonly reason: string;
|
|
64
|
+
readonly ticket: string | null;
|
|
65
|
+
readonly requesterId: string | null;
|
|
66
|
+
readonly approverId: string | null;
|
|
67
|
+
readonly createdAt: number;
|
|
68
|
+
readonly decidedAt: number | null;
|
|
69
|
+
readonly executedAt: number | null;
|
|
70
|
+
}>;
|
|
71
|
+
|
|
72
|
+
export declare const useGmExecute: (apiName?: string) => ActionState<GmExecuteInput, {
|
|
73
|
+
readonly id: string;
|
|
74
|
+
readonly actionId: string;
|
|
75
|
+
readonly state: "rejected" | "pending" | "approved" | "executed";
|
|
76
|
+
readonly targetId: string | null;
|
|
77
|
+
readonly input: unknown;
|
|
78
|
+
readonly output: unknown;
|
|
79
|
+
readonly reason: string;
|
|
80
|
+
readonly ticket: string | null;
|
|
81
|
+
readonly requesterId: string | null;
|
|
82
|
+
readonly approverId: string | null;
|
|
83
|
+
readonly createdAt: number;
|
|
84
|
+
readonly decidedAt: number | null;
|
|
85
|
+
readonly executedAt: number | null;
|
|
86
|
+
}>;
|
|
87
|
+
|
|
88
|
+
export declare const useGmReject: (apiName?: string) => ActionState<{
|
|
89
|
+
readonly id: string;
|
|
90
|
+
}, {
|
|
91
|
+
readonly id: string;
|
|
92
|
+
readonly actionId: string;
|
|
93
|
+
readonly state: "rejected" | "pending" | "approved" | "executed";
|
|
94
|
+
readonly targetId: string | null;
|
|
95
|
+
readonly input: unknown;
|
|
96
|
+
readonly output: unknown;
|
|
97
|
+
readonly reason: string;
|
|
98
|
+
readonly ticket: string | null;
|
|
99
|
+
readonly requesterId: string | null;
|
|
100
|
+
readonly approverId: string | null;
|
|
101
|
+
readonly createdAt: number;
|
|
102
|
+
readonly decidedAt: number | null;
|
|
103
|
+
readonly executedAt: number | null;
|
|
104
|
+
}>;
|
|
105
|
+
|
|
106
|
+
/** Live request history the caller may see; pass a state (`'pending'`) for an approval queue. */
|
|
107
|
+
export declare const useGmRequests: (state?: GmRequestState, apiName?: string) => SubscriptionState<readonly {
|
|
108
|
+
readonly id: string;
|
|
109
|
+
readonly actionId: string;
|
|
110
|
+
readonly state: "rejected" | "pending" | "approved" | "executed";
|
|
111
|
+
readonly targetId: string | null;
|
|
112
|
+
readonly input: unknown;
|
|
113
|
+
readonly output: unknown;
|
|
114
|
+
readonly reason: string;
|
|
115
|
+
readonly ticket: string | null;
|
|
116
|
+
readonly requesterId: string | null;
|
|
117
|
+
readonly approverId: string | null;
|
|
118
|
+
readonly createdAt: number;
|
|
119
|
+
readonly decidedAt: number | null;
|
|
120
|
+
readonly executedAt: number | null;
|
|
121
|
+
}[]>;
|
|
122
|
+
|
|
123
|
+
export { }
|
package/dist/web.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { BASE_NAME as e } from "./rpc.js";
|
|
2
|
+
import { pluginTag as t } from "@voltro/protocol";
|
|
3
|
+
import { useAction as n, useSubscription as r } from "@voltro/client";
|
|
4
|
+
// src/web.ts
|
|
5
|
+
var i = (n = "app") => r(n, t(e, "actions"), {}), a = (n, i = "app") => r(i, t(e, "requests"), n === void 0 ? {} : { state: n }), o = (r = "app") => n(r, t(e, "execute")), s = (r = "app") => n(r, t(e, "approve")), c = (r = "app") => n(r, t(e, "reject"));
|
|
6
|
+
export { i as useGmActions, s as useGmApprove, o as useGmExecute, c as useGmReject, a as useGmRequests };
|
package/package.json
CHANGED
|
@@ -1,6 +1,83 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@voltro/plugin-gm",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "0.88.0",
|
|
4
|
+
"description": "Configurable, audited game-master actions with reasons, idempotent requests and optional second-person approval",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"voltro",
|
|
7
|
+
"typescript",
|
|
8
|
+
"framework"
|
|
9
|
+
],
|
|
10
|
+
"license": "SEE LICENSE IN LICENSE",
|
|
11
|
+
"homepage": "https://voltro.dev",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"email": "support@voltro.dev"
|
|
14
|
+
},
|
|
15
|
+
"author": {
|
|
16
|
+
"name": "Voltro UG",
|
|
17
|
+
"url": "https://voltro.dev"
|
|
18
|
+
},
|
|
19
|
+
"type": "module",
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"import": "./dist/index.js",
|
|
24
|
+
"default": "./dist/index.js"
|
|
25
|
+
},
|
|
26
|
+
"./errors": {
|
|
27
|
+
"types": "./dist/errors.d.ts",
|
|
28
|
+
"import": "./dist/errors.js",
|
|
29
|
+
"default": "./dist/errors.js"
|
|
30
|
+
},
|
|
31
|
+
"./rpc": {
|
|
32
|
+
"types": "./dist/rpc.d.ts",
|
|
33
|
+
"import": "./dist/rpc.js",
|
|
34
|
+
"default": "./dist/rpc.js"
|
|
35
|
+
},
|
|
36
|
+
"./web": {
|
|
37
|
+
"types": "./dist/web.d.ts",
|
|
38
|
+
"import": "./dist/web.js",
|
|
39
|
+
"default": "./dist/web.js"
|
|
40
|
+
},
|
|
41
|
+
"./testing": {
|
|
42
|
+
"types": "./dist/testing.d.ts",
|
|
43
|
+
"import": "./dist/testing.js",
|
|
44
|
+
"default": "./dist/testing.js"
|
|
45
|
+
},
|
|
46
|
+
"./package.json": "./package.json"
|
|
47
|
+
},
|
|
48
|
+
"main": "./dist/index.js",
|
|
49
|
+
"module": "./dist/index.js",
|
|
50
|
+
"types": "./dist/index.d.ts",
|
|
51
|
+
"sideEffects": false,
|
|
52
|
+
"engines": {
|
|
53
|
+
"node": ">=24.0.0"
|
|
54
|
+
},
|
|
55
|
+
"dependencies": {
|
|
56
|
+
"@voltro/protocol": "0.88.0",
|
|
57
|
+
"@voltro/database": "0.88.0",
|
|
58
|
+
"@voltro/plugin-licensing": "0.88.0",
|
|
59
|
+
"@voltro/client": "0.88.0",
|
|
60
|
+
"@voltro/runtime": "0.88.0"
|
|
61
|
+
},
|
|
62
|
+
"peerDependencies": {
|
|
63
|
+
"effect": "4.1.0",
|
|
64
|
+
"@voltro/plugin-economy": "0.88.0",
|
|
65
|
+
"@voltro/plugin-sanctions": "0.88.0",
|
|
66
|
+
"@voltro/plugin-rooms": "0.88.0",
|
|
67
|
+
"react": "^19.0.0"
|
|
68
|
+
},
|
|
69
|
+
"peerDependenciesMeta": {
|
|
70
|
+
"@voltro/plugin-economy": {
|
|
71
|
+
"optional": true
|
|
72
|
+
},
|
|
73
|
+
"@voltro/plugin-sanctions": {
|
|
74
|
+
"optional": true
|
|
75
|
+
},
|
|
76
|
+
"@voltro/plugin-rooms": {
|
|
77
|
+
"optional": true
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
"publishConfig": {
|
|
81
|
+
"access": "public"
|
|
82
|
+
}
|
|
83
|
+
}
|