@nice-code/action 0.2.11 → 0.2.13
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/build/devtools/browser/index.js +2067 -0
- package/build/devtools/server/index.js +235 -0
- package/build/index.js +51 -21
- package/build/types/ActionDefinition/Action/Payload/ActionPayload_Request.d.ts +1 -0
- package/build/types/ActionDefinition/Action/RunningAction.d.ts +2 -0
- package/build/types/ActionDefinition/Action/RunningAction.types.d.ts +2 -0
- package/build/types/ActionRuntime/ActionRuntime.d.ts +4 -2
- package/build/types/ActionRuntime/HandlerCallStack.d.ts +3 -0
- package/build/types/ActionRuntime/RuntimeCoordinate.d.ts +9 -7
- package/build/types/devtools/browser/NiceActionDevtools.d.ts +8 -0
- package/build/types/devtools/browser/components/ActionDetailPanel.d.ts +7 -0
- package/build/types/devtools/browser/components/ActionEntryRow.d.ts +11 -0
- package/build/types/devtools/browser/components/CallStackSection.d.ts +8 -0
- package/build/types/devtools/browser/components/ChildDispatchChips.d.ts +4 -0
- package/build/types/devtools/browser/components/Chip.d.ts +11 -0
- package/build/types/devtools/browser/components/DetailSection.d.ts +5 -0
- package/build/types/devtools/browser/components/DomainChip.d.ts +14 -0
- package/build/types/devtools/browser/components/HandlerChips.d.ts +10 -0
- package/build/types/devtools/browser/components/MetaSection.d.ts +4 -0
- package/build/types/devtools/browser/components/PanelChrome.d.ts +14 -0
- package/build/types/devtools/browser/components/RoutingSection.d.ts +5 -0
- package/build/types/devtools/browser/components/RunningTimer.d.ts +7 -0
- package/build/types/devtools/browser/components/SectionLabel.d.ts +4 -0
- package/build/types/devtools/browser/components/StackTraceSection.d.ts +5 -0
- package/build/types/devtools/browser/components/utils.d.ts +7 -0
- package/build/types/devtools/browser/index.d.ts +3 -0
- package/build/types/devtools/core/ActionDevtools.types.d.ts +50 -0
- package/build/types/devtools/core/ActionDevtoolsCore.d.ts +14 -0
- package/build/types/devtools/server/NiceActionServerDevtools.d.ts +30 -0
- package/build/types/devtools/server/index.d.ts +3 -0
- package/build/types/index.d.ts +1 -1
- package/package.json +17 -3
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
// src/ActionDefinition/Action/RunningAction.types.ts
|
|
2
|
+
var ERunningActionState;
|
|
3
|
+
((ERunningActionState2) => {
|
|
4
|
+
ERunningActionState2["running"] = "running";
|
|
5
|
+
ERunningActionState2["completed"] = "completed";
|
|
6
|
+
})(ERunningActionState ||= {});
|
|
7
|
+
var ERunningActionUpdateType;
|
|
8
|
+
((ERunningActionUpdateType2) => {
|
|
9
|
+
ERunningActionUpdateType2["started"] = "started";
|
|
10
|
+
ERunningActionUpdateType2["progress"] = "progress";
|
|
11
|
+
ERunningActionUpdateType2["finished"] = "finished";
|
|
12
|
+
})(ERunningActionUpdateType ||= {});
|
|
13
|
+
var ERunningActionFinishedType;
|
|
14
|
+
((ERunningActionFinishedType2) => {
|
|
15
|
+
ERunningActionFinishedType2["aborted"] = "aborted";
|
|
16
|
+
ERunningActionFinishedType2["failed"] = "failed";
|
|
17
|
+
ERunningActionFinishedType2["success"] = "success";
|
|
18
|
+
})(ERunningActionFinishedType ||= {});
|
|
19
|
+
|
|
20
|
+
// src/devtools/server/NiceActionServerDevtools.ts
|
|
21
|
+
class ActionServerDevtools {
|
|
22
|
+
_options;
|
|
23
|
+
_inFlight = new Map;
|
|
24
|
+
constructor(options = {}) {
|
|
25
|
+
const defaultEnabled = typeof process !== "undefined" ? true : true;
|
|
26
|
+
this._options = {
|
|
27
|
+
logger: options.logger ?? defaultConsoleLogger,
|
|
28
|
+
format: options.format ?? "pretty",
|
|
29
|
+
logPayloads: options.logPayloads ?? true,
|
|
30
|
+
enabled: options.enabled ?? defaultEnabled
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
attachToDomain(domain) {
|
|
34
|
+
if (!this._options.enabled) {
|
|
35
|
+
return () => {};
|
|
36
|
+
}
|
|
37
|
+
return domain.addActionListener((update) => {
|
|
38
|
+
const { runningAction, type, time } = update;
|
|
39
|
+
const actionPath = [...runningAction.allDomains, runningAction.id].join(".");
|
|
40
|
+
if (type === "started" /* started */) {
|
|
41
|
+
this._inFlight.set(runningAction.cuid, { startTime: time });
|
|
42
|
+
this._log("started", actionPath, runningAction.cuid, {
|
|
43
|
+
...this._options.logPayloads ? { input: runningAction.state?.request?.input } : {}
|
|
44
|
+
});
|
|
45
|
+
} else if (type === "progress" /* progress */) {
|
|
46
|
+
this._log("progress", actionPath, runningAction.cuid, { progress: update.progress });
|
|
47
|
+
} else if (type === "finished" /* finished */) {
|
|
48
|
+
const timing = this._inFlight.get(runningAction.cuid);
|
|
49
|
+
const duration = timing != null ? time - timing.startTime : undefined;
|
|
50
|
+
this._inFlight.delete(runningAction.cuid);
|
|
51
|
+
const finishType = update.finishType;
|
|
52
|
+
if (finishType === "success" /* success */) {
|
|
53
|
+
this._log("success", actionPath, runningAction.cuid, {
|
|
54
|
+
...duration != null ? { duration: `${duration}ms` } : {},
|
|
55
|
+
...this._options.logPayloads ? { output: update.response?.result?.output } : {}
|
|
56
|
+
});
|
|
57
|
+
} else if (finishType === "failed" /* failed */) {
|
|
58
|
+
this._log("failed", actionPath, runningAction.cuid, {
|
|
59
|
+
...duration != null ? { duration: `${duration}ms` } : {},
|
|
60
|
+
error: serializeError(update.error)
|
|
61
|
+
});
|
|
62
|
+
} else {
|
|
63
|
+
this._log("aborted", actionPath, runningAction.cuid, {
|
|
64
|
+
...duration != null ? { duration: `${duration}ms` } : {},
|
|
65
|
+
...update.reason != null ? { reason: String(update.reason) } : {}
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
_log(event, actionPath, cuid, data) {
|
|
72
|
+
const { logger, format } = this._options;
|
|
73
|
+
if (format === "json") {
|
|
74
|
+
logger(JSON.stringify({ time: new Date().toISOString(), event, action: actionPath, cuid, ...data }));
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
const prefix = PRETTY_PREFIX[event] ?? `[${event}]`;
|
|
78
|
+
const suffix = Object.keys(data).length > 0 ? ` ${formatPrettyData(data)}` : "";
|
|
79
|
+
logger(`${prefix} ${actionPath} cuid=${cuid}${suffix}`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
var PRETTY_PREFIX = {
|
|
83
|
+
started: "[nice-action] ►",
|
|
84
|
+
progress: "[nice-action] ",
|
|
85
|
+
success: "[nice-action] ✓",
|
|
86
|
+
failed: "[nice-action] ✗",
|
|
87
|
+
aborted: "[nice-action] ○"
|
|
88
|
+
};
|
|
89
|
+
function formatPrettyData(data) {
|
|
90
|
+
return Object.entries(data).map(([k, v]) => `${k}=${safeStringify(v)}`).join(" ");
|
|
91
|
+
}
|
|
92
|
+
function safeStringify(value) {
|
|
93
|
+
if (value === undefined)
|
|
94
|
+
return "undefined";
|
|
95
|
+
if (value === null)
|
|
96
|
+
return "null";
|
|
97
|
+
if (typeof value === "string")
|
|
98
|
+
return `"${value}"`;
|
|
99
|
+
try {
|
|
100
|
+
return JSON.stringify(value);
|
|
101
|
+
} catch {
|
|
102
|
+
return String(value);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
function serializeError(err) {
|
|
106
|
+
if (err == null)
|
|
107
|
+
return err;
|
|
108
|
+
if (err instanceof Error)
|
|
109
|
+
return { message: err.message, name: err.name, stack: err.stack };
|
|
110
|
+
if (typeof err === "object") {
|
|
111
|
+
try {
|
|
112
|
+
return JSON.parse(JSON.stringify(err));
|
|
113
|
+
} catch {
|
|
114
|
+
return String(err);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return err;
|
|
118
|
+
}
|
|
119
|
+
function defaultConsoleLogger(message) {
|
|
120
|
+
console.log(message);
|
|
121
|
+
}
|
|
122
|
+
// src/devtools/core/ActionDevtoolsCore.ts
|
|
123
|
+
function extractRouting(context) {
|
|
124
|
+
return (context?.routing ?? []).map((item) => {
|
|
125
|
+
const handler = item.handler;
|
|
126
|
+
const isExternal = handler?.type === "external";
|
|
127
|
+
return {
|
|
128
|
+
runtime: {
|
|
129
|
+
envId: item.runtime?.envId ?? "unknown",
|
|
130
|
+
perId: item.runtime?.perId,
|
|
131
|
+
insId: item.runtime?.insId
|
|
132
|
+
},
|
|
133
|
+
handlerType: isExternal ? "external" : "local",
|
|
134
|
+
handlerClient: isExternal && handler.client != null ? {
|
|
135
|
+
envId: handler.client.envId ?? "unknown",
|
|
136
|
+
perId: handler.client.perId,
|
|
137
|
+
insId: handler.client.insId
|
|
138
|
+
} : undefined,
|
|
139
|
+
transport: isExternal ? handler.transType : undefined,
|
|
140
|
+
time: item.time
|
|
141
|
+
};
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
function extractMeta(context) {
|
|
145
|
+
return {
|
|
146
|
+
timeCreated: context?.timeCreated ?? Date.now(),
|
|
147
|
+
originClient: {
|
|
148
|
+
envId: context?.originClient?.envId ?? "unknown",
|
|
149
|
+
perId: context?.originClient?.perId,
|
|
150
|
+
insId: context?.originClient?.insId
|
|
151
|
+
},
|
|
152
|
+
routing: extractRouting(context)
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
class ActionDevtoolsCore {
|
|
157
|
+
_entries = [];
|
|
158
|
+
_listeners = new Set;
|
|
159
|
+
constructor(_options = {}) {}
|
|
160
|
+
attachToDomain(domain) {
|
|
161
|
+
return domain.addActionListener((update) => {
|
|
162
|
+
const { runningAction, type, time } = update;
|
|
163
|
+
if (type === "started" /* started */) {
|
|
164
|
+
const entry = {
|
|
165
|
+
cuid: runningAction.cuid,
|
|
166
|
+
actionId: runningAction.id,
|
|
167
|
+
domain: runningAction.domain,
|
|
168
|
+
allDomains: [...runningAction.allDomains],
|
|
169
|
+
status: "running",
|
|
170
|
+
startTime: time,
|
|
171
|
+
input: runningAction.state?.request?.input,
|
|
172
|
+
progressUpdates: [],
|
|
173
|
+
meta: extractMeta(runningAction.context),
|
|
174
|
+
parentCuid: runningAction.parentCuid,
|
|
175
|
+
callSite: runningAction.callSite
|
|
176
|
+
};
|
|
177
|
+
this._entries = [entry, ...this._entries];
|
|
178
|
+
this._notify();
|
|
179
|
+
} else if (type === "progress" /* progress */) {
|
|
180
|
+
this._updateEntry(runningAction.cuid, (e) => ({
|
|
181
|
+
...e,
|
|
182
|
+
progressUpdates: [...e.progressUpdates, update.progress]
|
|
183
|
+
}));
|
|
184
|
+
} else if (type === "finished" /* finished */) {
|
|
185
|
+
this._updateEntry(runningAction.cuid, (e) => {
|
|
186
|
+
const finishedRoutingContext = update.response?.context ?? runningAction.context;
|
|
187
|
+
const base = {
|
|
188
|
+
...e,
|
|
189
|
+
endTime: time,
|
|
190
|
+
meta: { ...e.meta, routing: extractRouting(finishedRoutingContext) }
|
|
191
|
+
};
|
|
192
|
+
const finishType = update.finishType;
|
|
193
|
+
if (finishType === "success" /* success */) {
|
|
194
|
+
return { ...base, status: "success", output: update.response?.result?.output };
|
|
195
|
+
}
|
|
196
|
+
if (finishType === "failed" /* failed */) {
|
|
197
|
+
const rawError = update.error;
|
|
198
|
+
const errorStack2 = rawError instanceof Error ? rawError.stack : undefined;
|
|
199
|
+
return { ...base, status: "failed", error: rawError, errorStack: errorStack2 };
|
|
200
|
+
}
|
|
201
|
+
const abortReason = update.reason;
|
|
202
|
+
const errorStack = abortReason instanceof Error ? abortReason.stack : undefined;
|
|
203
|
+
return { ...base, status: "aborted", abortReason, errorStack };
|
|
204
|
+
});
|
|
205
|
+
}
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
getEntries() {
|
|
209
|
+
return this._entries;
|
|
210
|
+
}
|
|
211
|
+
subscribe(listener) {
|
|
212
|
+
this._listeners.add(listener);
|
|
213
|
+
listener(this._entries);
|
|
214
|
+
return () => {
|
|
215
|
+
this._listeners.delete(listener);
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
clear() {
|
|
219
|
+
this._entries = [];
|
|
220
|
+
this._notify();
|
|
221
|
+
}
|
|
222
|
+
_updateEntry(cuid, updater) {
|
|
223
|
+
this._entries = this._entries.map((e) => e.cuid === cuid ? updater(e) : e);
|
|
224
|
+
this._notify();
|
|
225
|
+
}
|
|
226
|
+
_notify() {
|
|
227
|
+
const snapshot = this._entries;
|
|
228
|
+
for (const listener of this._listeners)
|
|
229
|
+
listener(snapshot);
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
export {
|
|
233
|
+
ActionServerDevtools,
|
|
234
|
+
ActionDevtoolsCore
|
|
235
|
+
};
|
package/build/index.js
CHANGED
|
@@ -37,19 +37,19 @@ class RuntimeCoordinate {
|
|
|
37
37
|
this.perId = perId;
|
|
38
38
|
this.insId = insId;
|
|
39
39
|
}
|
|
40
|
-
specify(
|
|
40
|
+
specify(specifics) {
|
|
41
41
|
return new RuntimeCoordinate({
|
|
42
42
|
envId: this.envId,
|
|
43
43
|
perId: this.perId,
|
|
44
44
|
insId: this.insId,
|
|
45
|
-
...
|
|
45
|
+
...specifics
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
|
-
specifyIfUnset(
|
|
48
|
+
specifyIfUnset(specifics) {
|
|
49
49
|
return new RuntimeCoordinate({
|
|
50
50
|
envId: this.envId,
|
|
51
|
-
perId: this.perId ??
|
|
52
|
-
insId: this.insId ??
|
|
51
|
+
perId: this.perId ?? specifics.perId,
|
|
52
|
+
insId: this.insId ?? specifics.insId
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
55
|
toJsonObject() {
|
|
@@ -271,6 +271,7 @@ class ActionPayload_Result extends ActionPayload {
|
|
|
271
271
|
// src/ActionDefinition/Action/Payload/ActionPayload_Request.ts
|
|
272
272
|
class ActionPayload_Request extends ActionPayload {
|
|
273
273
|
input;
|
|
274
|
+
_callSite;
|
|
274
275
|
constructor(params, input, data) {
|
|
275
276
|
super(params.context, "request" /* request */, data);
|
|
276
277
|
this.input = input;
|
|
@@ -310,6 +311,7 @@ class ActionPayload_Request extends ActionPayload {
|
|
|
310
311
|
return value.waitForResultPayload();
|
|
311
312
|
}
|
|
312
313
|
async run(options) {
|
|
314
|
+
this._callSite = new Error().stack;
|
|
313
315
|
return this._domain.runAction(this, options);
|
|
314
316
|
}
|
|
315
317
|
}
|
|
@@ -396,6 +398,8 @@ class RunningAction {
|
|
|
396
398
|
_domain;
|
|
397
399
|
domain;
|
|
398
400
|
allDomains;
|
|
401
|
+
parentCuid;
|
|
402
|
+
callSite;
|
|
399
403
|
_resultPayloadPromise;
|
|
400
404
|
_resolveResult;
|
|
401
405
|
_rejectResult;
|
|
@@ -409,6 +413,8 @@ class RunningAction {
|
|
|
409
413
|
this.domain = initialState.context.domain;
|
|
410
414
|
this.allDomains = initialState.context.allDomains;
|
|
411
415
|
this._domain = initialState.context._domain;
|
|
416
|
+
this.parentCuid = initialState.parentCuid;
|
|
417
|
+
this.callSite = initialState.callSite;
|
|
412
418
|
this._resultPayloadPromise = new Promise((resolve, reject) => {
|
|
413
419
|
this._resolveResult = resolve;
|
|
414
420
|
this._rejectResult = reject;
|
|
@@ -864,13 +870,13 @@ class ActionRuntime {
|
|
|
864
870
|
get coordinate() {
|
|
865
871
|
return this._coordinate;
|
|
866
872
|
}
|
|
867
|
-
|
|
868
|
-
if (this._coordinate.envId !==
|
|
873
|
+
specifyRuntimeCoordinate(specifics) {
|
|
874
|
+
if (specifics.envId != null && this._coordinate.envId !== specifics.envId) {
|
|
869
875
|
throw err_nice_action.fromId("not_implemented" /* not_implemented */, {
|
|
870
|
-
label: `updating RuntimeCoordinate with a different "envId" ("${this._coordinate.envId}" → "${
|
|
876
|
+
label: `updating RuntimeCoordinate with a different "envId" ("${this._coordinate.envId}" → "${specifics.envId}")`
|
|
871
877
|
});
|
|
872
878
|
}
|
|
873
|
-
this._coordinate =
|
|
879
|
+
this._coordinate = this._coordinate.specify(specifics);
|
|
874
880
|
this.apply();
|
|
875
881
|
}
|
|
876
882
|
registerRunningAction(ra) {
|
|
@@ -1044,6 +1050,18 @@ function getDefaultActionRuntime() {
|
|
|
1044
1050
|
return runtimeState.defaultLocalRuntime;
|
|
1045
1051
|
}
|
|
1046
1052
|
|
|
1053
|
+
// src/ActionRuntime/HandlerCallStack.ts
|
|
1054
|
+
var _stack = [];
|
|
1055
|
+
function pushHandlerCuid(cuid) {
|
|
1056
|
+
_stack.push(cuid);
|
|
1057
|
+
}
|
|
1058
|
+
function popHandlerCuid() {
|
|
1059
|
+
_stack.pop();
|
|
1060
|
+
}
|
|
1061
|
+
function peekHandlerCuid() {
|
|
1062
|
+
return _stack[_stack.length - 1];
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1047
1065
|
// src/ActionRuntime/Handler/ActionHandler.ts
|
|
1048
1066
|
import { nanoid as nanoid3 } from "nanoid";
|
|
1049
1067
|
|
|
@@ -1093,7 +1111,12 @@ class ActionLocalHandler extends ActionHandler {
|
|
|
1093
1111
|
handler: this.toHandlerRouteItem(),
|
|
1094
1112
|
time: Date.now()
|
|
1095
1113
|
});
|
|
1096
|
-
const runningAction = new RunningAction({
|
|
1114
|
+
const runningAction = new RunningAction({
|
|
1115
|
+
context: action.context,
|
|
1116
|
+
request: action,
|
|
1117
|
+
parentCuid: peekHandlerCuid(),
|
|
1118
|
+
callSite: action._callSite ?? new Error().stack
|
|
1119
|
+
});
|
|
1097
1120
|
this._handleRunningAction(handler, runningAction).catch((err2) => runningAction._abort(err2));
|
|
1098
1121
|
return runningAction;
|
|
1099
1122
|
}
|
|
@@ -1102,17 +1125,22 @@ class ActionLocalHandler extends ActionHandler {
|
|
|
1102
1125
|
if (state.result != null) {
|
|
1103
1126
|
return;
|
|
1104
1127
|
}
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
result
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1128
|
+
pushHandlerCuid(runningAction.cuid);
|
|
1129
|
+
try {
|
|
1130
|
+
const rawResult = await handler(state.request);
|
|
1131
|
+
let result;
|
|
1132
|
+
if (rawResult instanceof ActionPayload_Result) {
|
|
1133
|
+
result = rawResult;
|
|
1134
|
+
} else if (rawResult != null && isActionPayload_Result_JsonObject(rawResult)) {
|
|
1135
|
+
const domain = this.actionRouter.domainManager.getActionDomainOrThrow(state.request);
|
|
1136
|
+
result = domain.hydrateResultPayload(rawResult);
|
|
1137
|
+
} else {
|
|
1138
|
+
result = state.request.successResult(rawResult);
|
|
1139
|
+
}
|
|
1140
|
+
runningAction._completeWithResult(result);
|
|
1141
|
+
} finally {
|
|
1142
|
+
popHandlerCuid();
|
|
1114
1143
|
}
|
|
1115
|
-
runningAction._completeWithResult(result);
|
|
1116
1144
|
}
|
|
1117
1145
|
async handlePayloadWireOrThrow(wire, config) {
|
|
1118
1146
|
const hydratedAction = this.actionRouter.domainManager.hydrateActionPayload(wire);
|
|
@@ -2179,6 +2207,8 @@ class ActionExternalClientHandler extends ActionHandler {
|
|
|
2179
2207
|
const localRuntime = config?.targetLocalRuntime ?? ActionRuntime.getDefault();
|
|
2180
2208
|
const localClient = localRuntime.coordinate;
|
|
2181
2209
|
const incomingTimeout = config?.timeout ?? this._defaultTimeout;
|
|
2210
|
+
const parentCuid = peekHandlerCuid();
|
|
2211
|
+
const callSite = action._callSite ?? new Error().stack;
|
|
2182
2212
|
const { methods, transport } = await this.transportManager.getReadyTransport({
|
|
2183
2213
|
action,
|
|
2184
2214
|
localClient,
|
|
@@ -2189,7 +2219,7 @@ class ActionExternalClientHandler extends ActionHandler {
|
|
|
2189
2219
|
handler: this.toHandlerRouteItem(transport),
|
|
2190
2220
|
time: Date.now()
|
|
2191
2221
|
});
|
|
2192
|
-
const runningAction = new RunningAction({ context: action.context, request: action });
|
|
2222
|
+
const runningAction = new RunningAction({ context: action.context, request: action, parentCuid, callSite });
|
|
2193
2223
|
localRuntime.registerRunningAction(runningAction);
|
|
2194
2224
|
const routeActionParams = {
|
|
2195
2225
|
action,
|
|
@@ -10,6 +10,7 @@ import { ActionPayload_Progress } from "./ActionPayload_Progress";
|
|
|
10
10
|
import { ActionPayload_Result } from "./ActionPayload_Result";
|
|
11
11
|
export declare class ActionPayload_Request<DOM extends IActionDomain, ID extends keyof DOM["actionSchema"] & string = keyof DOM["actionSchema"] & string> extends ActionPayload<EActionPayloadType.request, DOM, ID> {
|
|
12
12
|
readonly input: TInferInputFromSchema<DOM["actionSchema"][ID]>["Input"];
|
|
13
|
+
_callSite?: string;
|
|
13
14
|
constructor(params: {
|
|
14
15
|
context: ActionContext<DOM, ID>;
|
|
15
16
|
}, input: TInferInputFromSchema<DOM["actionSchema"][ID]>["Input"], data: IActionPayload_Data_Base);
|
|
@@ -13,6 +13,8 @@ export declare class RunningAction<DOM extends IActionDomain, ID extends keyof D
|
|
|
13
13
|
readonly _domain: ActionDomain<DOM>;
|
|
14
14
|
readonly domain: DOM["domain"];
|
|
15
15
|
readonly allDomains: DOM["allDomains"];
|
|
16
|
+
readonly parentCuid?: string;
|
|
17
|
+
readonly callSite?: string;
|
|
16
18
|
private readonly _resultPayloadPromise;
|
|
17
19
|
private _resolveResult;
|
|
18
20
|
private _rejectResult;
|
|
@@ -20,6 +20,8 @@ export interface IRunningActionState_ConstructorParams<DOM extends IActionDomain
|
|
|
20
20
|
request: ActionPayload_Request<DOM, ID>;
|
|
21
21
|
progress?: ActionPayload_Progress<DOM, ID>[];
|
|
22
22
|
result?: ActionPayload_Result<DOM, ID>;
|
|
23
|
+
parentCuid?: string;
|
|
24
|
+
callSite?: string;
|
|
23
25
|
}
|
|
24
26
|
export declare enum ERunningActionUpdateType {
|
|
25
27
|
started = "started",
|
|
@@ -5,7 +5,7 @@ import type { IActionDomain } from "../ActionDefinition/Domain/ActionDomain.type
|
|
|
5
5
|
import type { IRuntimeMeta, TActionRuntimeHandler } from "./ActionRuntime.types";
|
|
6
6
|
import { type IHandleActionOptions, type TActionHandler } from "./Handler/ActionHandler.types";
|
|
7
7
|
import type { ActionExternalClientHandler } from "./Handler/ExternalClient/ActionExternalClientHandler";
|
|
8
|
-
import { RuntimeCoordinate } from "./RuntimeCoordinate";
|
|
8
|
+
import { type IRuntimeCoordinateSpecifics, RuntimeCoordinate } from "./RuntimeCoordinate";
|
|
9
9
|
export declare class ActionRuntime {
|
|
10
10
|
private _coordinate;
|
|
11
11
|
readonly timeCreated: number;
|
|
@@ -17,7 +17,9 @@ export declare class ActionRuntime {
|
|
|
17
17
|
static getDefault(): ActionRuntime;
|
|
18
18
|
constructor(coordinate: RuntimeCoordinate);
|
|
19
19
|
get coordinate(): RuntimeCoordinate;
|
|
20
|
-
|
|
20
|
+
specifyRuntimeCoordinate(specifics: IRuntimeCoordinateSpecifics & {
|
|
21
|
+
envId?: string;
|
|
22
|
+
}): void;
|
|
21
23
|
registerRunningAction(ra: RunningAction<any, any>): void;
|
|
22
24
|
resolveIncomingActionPayload(json: TActionPayload_Any_JsonObject<any, any>): void;
|
|
23
25
|
/**
|
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
export interface
|
|
2
|
-
/**
|
|
3
|
-
* A static runtime environment identifier (e.g. "web_app_v1", "backend_analytics")
|
|
4
|
-
*/
|
|
5
|
-
envId: string;
|
|
1
|
+
export interface IRuntimeCoordinateSpecifics {
|
|
6
2
|
/**
|
|
7
3
|
* A unique and persistent client ID (should stay the same between runtime instance reloads)
|
|
8
4
|
*/
|
|
@@ -13,6 +9,12 @@ export interface IRuntimeCoordinate {
|
|
|
13
9
|
*/
|
|
14
10
|
insId?: string;
|
|
15
11
|
}
|
|
12
|
+
export interface IRuntimeCoordinate extends IRuntimeCoordinateSpecifics {
|
|
13
|
+
/**
|
|
14
|
+
* A static runtime environment identifier (e.g. "web_app_v1", "backend_analytics")
|
|
15
|
+
*/
|
|
16
|
+
envId: string;
|
|
17
|
+
}
|
|
16
18
|
export type TRuntimeCoordinateEnvId = `envId[${string}]`;
|
|
17
19
|
export type TRuntimeCoordinateStringId = `${TRuntimeCoordinateEnvId}perId[${string | "_"}]:insId[${string | "_"}]`;
|
|
18
20
|
export interface IRuntimeFullCoordinates extends Required<IRuntimeCoordinate> {
|
|
@@ -25,8 +27,8 @@ export declare class RuntimeCoordinate implements IRuntimeCoordinate {
|
|
|
25
27
|
static env(envId: string): RuntimeCoordinate;
|
|
26
28
|
withPersistentId(perId: string): RuntimeCoordinate;
|
|
27
29
|
constructor({ envId, perId, insId }: IRuntimeCoordinate);
|
|
28
|
-
specify(
|
|
29
|
-
specifyIfUnset(
|
|
30
|
+
specify(specifics: IRuntimeCoordinateSpecifics): RuntimeCoordinate;
|
|
31
|
+
specifyIfUnset(specifics: IRuntimeCoordinateSpecifics): RuntimeCoordinate;
|
|
30
32
|
toJsonObject(): IRuntimeCoordinate;
|
|
31
33
|
isExactlySame(other: IRuntimeCoordinate): boolean;
|
|
32
34
|
isSameFor(other: IRuntimeCoordinate): {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { TDevtoolsPosition } from "../core/ActionDevtools.types";
|
|
2
|
+
import type { ActionDevtoolsCore } from "../core/ActionDevtoolsCore";
|
|
3
|
+
export interface INiceActionDevtoolsProps {
|
|
4
|
+
core: ActionDevtoolsCore;
|
|
5
|
+
position?: TDevtoolsPosition;
|
|
6
|
+
initialOpen?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function NiceActionDevtools(props: INiceActionDevtoolsProps): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { IDevtoolsActionEntry } from "../../core/ActionDevtools.types";
|
|
2
|
+
export declare function ActionDetailPanel({ entry, parent, childEntries, onSelectEntry, }: {
|
|
3
|
+
entry: IDevtoolsActionEntry;
|
|
4
|
+
parent: IDevtoolsActionEntry | null;
|
|
5
|
+
childEntries: IDevtoolsActionEntry[];
|
|
6
|
+
onSelectEntry: (cuid: string) => void;
|
|
7
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { IDevtoolsActionEntry } from "../../core/ActionDevtools.types";
|
|
2
|
+
export declare function ActionEntryRow({ entry, isSelected, onClick, groupCount, isSubEntry, isLatest, latestTime, childExternalLabels, }: {
|
|
3
|
+
entry: IDevtoolsActionEntry;
|
|
4
|
+
isSelected: boolean;
|
|
5
|
+
onClick: () => void;
|
|
6
|
+
groupCount?: number;
|
|
7
|
+
isSubEntry?: boolean;
|
|
8
|
+
isLatest?: boolean;
|
|
9
|
+
latestTime?: number;
|
|
10
|
+
childExternalLabels?: string[];
|
|
11
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { IDevtoolsActionEntry } from "../../core/ActionDevtools.types";
|
|
2
|
+
export declare function CallStackSection({ parent, childEntries, focusedChildCuid, onFocusChild, onSelectParent, }: {
|
|
3
|
+
parent: IDevtoolsActionEntry | null;
|
|
4
|
+
childEntries: IDevtoolsActionEntry[];
|
|
5
|
+
focusedChildCuid: string | null;
|
|
6
|
+
onFocusChild: (cuid: string) => void;
|
|
7
|
+
onSelectParent: (cuid: string) => void;
|
|
8
|
+
}): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { CSSProperties, ReactNode } from "react";
|
|
2
|
+
interface IChipProps {
|
|
3
|
+
color: string;
|
|
4
|
+
borderColor: string;
|
|
5
|
+
fontSize?: string;
|
|
6
|
+
padding?: string;
|
|
7
|
+
children: ReactNode;
|
|
8
|
+
style?: CSSProperties;
|
|
9
|
+
}
|
|
10
|
+
export declare function Chip({ color, borderColor, fontSize, padding, children, style, }: IChipProps): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface IDomainTooltipCtx {
|
|
2
|
+
show: (rect: DOMRect, allDomains: string[]) => void;
|
|
3
|
+
hide: () => void;
|
|
4
|
+
}
|
|
5
|
+
export declare const DomainTooltipCtx: import("react").Context<IDomainTooltipCtx | null>;
|
|
6
|
+
export declare function DomainHierarchyTooltip({ allDomains, anchor, }: {
|
|
7
|
+
allDomains: string[];
|
|
8
|
+
anchor: DOMRect;
|
|
9
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare function DomainChip({ domain, allDomains, size, }: {
|
|
11
|
+
domain: string;
|
|
12
|
+
allDomains?: string[];
|
|
13
|
+
size: "sm" | "md";
|
|
14
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { IDevtoolsActionEntry, IDevtoolsRouteItem } from "../../core/ActionDevtools.types";
|
|
2
|
+
export declare function getExternalLabel(hop: IDevtoolsRouteItem): string | null;
|
|
3
|
+
interface IHandlerChipsProps {
|
|
4
|
+
entry: IDevtoolsActionEntry;
|
|
5
|
+
size: "sm" | "md";
|
|
6
|
+
/** Show the local runtime chip even when an external chip is also present */
|
|
7
|
+
alwaysShowLocal?: boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function HandlerChips({ entry, size, alwaysShowLocal }: IHandlerChipsProps): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { TDevtoolsPosition } from "../../core/ActionDevtools.types";
|
|
2
|
+
export type TDockSide = "top" | "bottom" | "left" | "right";
|
|
3
|
+
export declare function getDockSide(pos: TDevtoolsPosition): TDockSide | null;
|
|
4
|
+
export declare function PanelHeader({ position, onPositionChange, onClose, onClear, }: {
|
|
5
|
+
position: TDevtoolsPosition;
|
|
6
|
+
onPositionChange: (p: TDevtoolsPosition) => void;
|
|
7
|
+
onClose: () => void;
|
|
8
|
+
onClear?: () => void;
|
|
9
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
10
|
+
export declare function ResizeHandle({ dockSide, dockedSize, onChange, }: {
|
|
11
|
+
dockSide: TDockSide;
|
|
12
|
+
dockedSize: number;
|
|
13
|
+
onChange: (size: number) => void;
|
|
14
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { IDevtoolsActionEntry } from "../../core/ActionDevtools.types";
|
|
2
|
+
export declare function RunningTimer({ startTime }: {
|
|
3
|
+
startTime: number;
|
|
4
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
5
|
+
export declare function DurationDisplay({ entry }: {
|
|
6
|
+
entry: IDevtoolsActionEntry;
|
|
7
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { IDevtoolsActionEntry, TDevtoolsActionStatus } from "../../core/ActionDevtools.types";
|
|
2
|
+
export declare const STATUS_COLOR: Record<TDevtoolsActionStatus, string>;
|
|
3
|
+
export declare const STATUS_SYMBOL: Record<TDevtoolsActionStatus, string>;
|
|
4
|
+
export declare function safeStringify(value: unknown, indent?: number): string;
|
|
5
|
+
export declare function formatRelativeAge(ms: number): string;
|
|
6
|
+
export declare function formatDuration(entry: IDevtoolsActionEntry): string | null;
|
|
7
|
+
export declare function formatTimestamp(startTime: number): string;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export type { IDevtoolsActionEntry, IDevtoolsObservableDomain, TDevtoolsActionStatus, TDevtoolsListener, } from "../core/ActionDevtools.types";
|
|
2
|
+
export { ActionDevtoolsCore, type IActionDevtoolsCoreOptions } from "../core/ActionDevtoolsCore";
|
|
3
|
+
export { type INiceActionDevtoolsProps, NiceActionDevtools } from "./NiceActionDevtools";
|