@nice-code/action 0.2.15 → 0.2.17
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 +4086 -1494
- package/build/devtools/server/index.js +35 -7
- package/build/index.js +112 -22
- package/build/react-query/index.js +22 -4
- package/build/types/ActionDefinition/Action/Payload/ActionPayload.types.d.ts +3 -1
- package/build/types/ActionDefinition/Action/Payload/ActionPayload_Request.d.ts +1 -0
- package/build/types/ActionDefinition/Action/Payload/ActionPayload_Result.d.ts +1 -0
- package/build/types/ActionDefinition/Action/RunningAction.d.ts +1 -0
- package/build/types/ActionDefinition/Domain/ActionDomain.d.ts +2 -1
- package/build/types/ActionDefinition/Domain/ActionRootDomain.d.ts +1 -1
- package/build/types/ActionDefinition/Schema/ActionSchema.d.ts +0 -18
- package/build/types/devtools/browser/components/ActionErrorDisplay.d.ts +4 -0
- package/build/types/devtools/browser/components/ChildDispatchChips.d.ts +5 -3
- package/build/types/devtools/browser/components/Chip.d.ts +17 -5
- package/build/types/devtools/browser/components/DomainChip.d.ts +3 -11
- package/build/types/devtools/browser/components/HandlerChips.d.ts +2 -1
- package/build/types/devtools/browser/components/Icon.d.ts +15 -0
- package/build/types/devtools/browser/components/NiceErrorDisplay.d.ts +19 -0
- package/build/types/devtools/browser/components/StackTraceSection.d.ts +3 -1
- package/build/types/devtools/browser/components/Tooltip.d.ts +14 -0
- package/build/types/devtools/browser/components/{ActionDetailPanel.d.ts → action_detail/ActionDetailPanel.d.ts} +1 -1
- package/build/types/devtools/browser/components/action_list/ActionEntryRow.d.ts +13 -0
- package/build/types/devtools/browser/components/utils.d.ts +4 -0
- package/build/types/devtools/browser/ui_util/size.d.ts +6 -0
- package/build/types/devtools/core/ActionDevtools.types.d.ts +4 -1
- package/build/types/devtools/core/devtools_colors.d.ts +57 -0
- package/build/types/utils/hashPayloadData.d.ts +5 -0
- package/package.json +4 -3
- package/build/types/devtools/browser/components/ActionEntryRow.d.ts +0 -11
|
@@ -50,10 +50,18 @@ class ActionServerDevtools {
|
|
|
50
50
|
this._inFlight.delete(runningAction.cuid);
|
|
51
51
|
const finishType = update.finishType;
|
|
52
52
|
if (finishType === "success" /* success */) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
const result = update.response?.result;
|
|
54
|
+
if (result != null && !result.ok) {
|
|
55
|
+
this._log("action-error", actionPath, runningAction.cuid, {
|
|
56
|
+
...duration != null ? { duration: `${duration}ms` } : {},
|
|
57
|
+
error: serializeError(result.error)
|
|
58
|
+
});
|
|
59
|
+
} else {
|
|
60
|
+
this._log("success", actionPath, runningAction.cuid, {
|
|
61
|
+
...duration != null ? { duration: `${duration}ms` } : {},
|
|
62
|
+
...this._options.logPayloads ? { output: result?.output } : {}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
57
65
|
} else if (finishType === "failed" /* failed */) {
|
|
58
66
|
this._log("failed", actionPath, runningAction.cuid, {
|
|
59
67
|
...duration != null ? { duration: `${duration}ms` } : {},
|
|
@@ -120,6 +128,12 @@ function defaultConsoleLogger(message) {
|
|
|
120
128
|
console.log(message);
|
|
121
129
|
}
|
|
122
130
|
// src/devtools/core/ActionDevtoolsCore.ts
|
|
131
|
+
function serializeErrorForDisplay(error) {
|
|
132
|
+
if (error != null && typeof error === "object" && error.name === "NiceError" && typeof error.toJsonObject === "function") {
|
|
133
|
+
return error.toJsonObject();
|
|
134
|
+
}
|
|
135
|
+
return error;
|
|
136
|
+
}
|
|
123
137
|
function extractRouting(context) {
|
|
124
138
|
return (context?.routing ?? []).map((item) => {
|
|
125
139
|
const handler = item.handler;
|
|
@@ -169,6 +183,7 @@ class ActionDevtoolsCore {
|
|
|
169
183
|
status: "running",
|
|
170
184
|
startTime: time,
|
|
171
185
|
input: runningAction.state?.request?.input,
|
|
186
|
+
inputHash: runningAction.state?.request?.inputHash,
|
|
172
187
|
progressUpdates: [],
|
|
173
188
|
meta: extractMeta(runningAction.context),
|
|
174
189
|
parentCuid: runningAction.parentCuid,
|
|
@@ -191,16 +206,29 @@ class ActionDevtoolsCore {
|
|
|
191
206
|
};
|
|
192
207
|
const finishType = update.finishType;
|
|
193
208
|
if (finishType === "success" /* success */) {
|
|
194
|
-
|
|
209
|
+
const result = update.response?.result;
|
|
210
|
+
const outputHash = update.response?.outputHash;
|
|
211
|
+
if (result != null && !result.ok) {
|
|
212
|
+
const rawError = result.error;
|
|
213
|
+
const errorStack2 = rawError instanceof Error ? rawError.stack : undefined;
|
|
214
|
+
return {
|
|
215
|
+
...base,
|
|
216
|
+
status: "action-error",
|
|
217
|
+
outputHash,
|
|
218
|
+
error: serializeErrorForDisplay(rawError),
|
|
219
|
+
errorStack: errorStack2
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
return { ...base, status: "success", output: result?.output, outputHash };
|
|
195
223
|
}
|
|
196
224
|
if (finishType === "failed" /* failed */) {
|
|
197
225
|
const rawError = update.error;
|
|
198
226
|
const errorStack2 = rawError instanceof Error ? rawError.stack : undefined;
|
|
199
|
-
return { ...base, status: "failed", error: rawError, errorStack: errorStack2 };
|
|
227
|
+
return { ...base, status: "failed", error: serializeErrorForDisplay(rawError), errorStack: errorStack2 };
|
|
200
228
|
}
|
|
201
229
|
const abortReason = update.reason;
|
|
202
230
|
const errorStack = abortReason instanceof Error ? abortReason.stack : undefined;
|
|
203
|
-
return { ...base, status: "aborted", abortReason, errorStack };
|
|
231
|
+
return { ...base, status: "aborted", abortReason: serializeErrorForDisplay(abortReason), errorStack };
|
|
204
232
|
});
|
|
205
233
|
}
|
|
206
234
|
});
|
package/build/index.js
CHANGED
|
@@ -204,6 +204,28 @@ class ActionPayload extends ActionBase {
|
|
|
204
204
|
}
|
|
205
205
|
}
|
|
206
206
|
|
|
207
|
+
// src/utils/hashPayloadData.ts
|
|
208
|
+
function stableStringify(value) {
|
|
209
|
+
if (value === null || value === undefined)
|
|
210
|
+
return String(value);
|
|
211
|
+
if (typeof value !== "object")
|
|
212
|
+
return JSON.stringify(value) ?? "undefined";
|
|
213
|
+
if (Array.isArray(value))
|
|
214
|
+
return `[${value.map(stableStringify).join(",")}]`;
|
|
215
|
+
const keys = Object.keys(value).sort();
|
|
216
|
+
return "{" + keys.map((k) => `${JSON.stringify(k)}:${stableStringify(value[k])}`).join(",") + "}";
|
|
217
|
+
}
|
|
218
|
+
function fnv1a32(str) {
|
|
219
|
+
let hash = 2166136261;
|
|
220
|
+
for (let i = 0;i < str.length; i++) {
|
|
221
|
+
hash = (hash ^ str.charCodeAt(i)) * 16777619 >>> 0;
|
|
222
|
+
}
|
|
223
|
+
return hash.toString(16).padStart(8, "0");
|
|
224
|
+
}
|
|
225
|
+
function hashPayloadData(data) {
|
|
226
|
+
return fnv1a32(stableStringify(data));
|
|
227
|
+
}
|
|
228
|
+
|
|
207
229
|
// src/ActionDefinition/Action/Payload/ActionPayload.types.ts
|
|
208
230
|
var EActionPayloadType;
|
|
209
231
|
((EActionPayloadType2) => {
|
|
@@ -247,14 +269,18 @@ class ActionPayload_Progress extends ActionPayload {
|
|
|
247
269
|
// src/ActionDefinition/Action/Payload/ActionPayload_Result.ts
|
|
248
270
|
class ActionPayload_Result extends ActionPayload {
|
|
249
271
|
result;
|
|
272
|
+
outputHash;
|
|
250
273
|
constructor(params, result, data) {
|
|
251
274
|
super(params.context, "result" /* result */, data);
|
|
252
275
|
this.result = result;
|
|
276
|
+
this.outputHash = result.ok ? hashPayloadData(this.context.schema.serializeOutput(result.output)) : hashPayloadData(result.error.message);
|
|
253
277
|
}
|
|
254
278
|
toJsonObject() {
|
|
279
|
+
const wireResult = this.result.ok ? { ok: true, output: this.context.schema.serializeOutput(this.result.output) } : this.result;
|
|
255
280
|
return {
|
|
256
281
|
...this.toBaseJsonObject(),
|
|
257
|
-
result:
|
|
282
|
+
result: wireResult,
|
|
283
|
+
outputHash: this.outputHash
|
|
258
284
|
};
|
|
259
285
|
}
|
|
260
286
|
toJsonString() {
|
|
@@ -271,10 +297,12 @@ class ActionPayload_Result extends ActionPayload {
|
|
|
271
297
|
// src/ActionDefinition/Action/Payload/ActionPayload_Request.ts
|
|
272
298
|
class ActionPayload_Request extends ActionPayload {
|
|
273
299
|
input;
|
|
300
|
+
inputHash;
|
|
274
301
|
_callSite;
|
|
275
302
|
constructor(params, input, data) {
|
|
276
303
|
super(params.context, "request" /* request */, data);
|
|
277
304
|
this.input = input;
|
|
305
|
+
this.inputHash = hashPayloadData(this.context.schema.serializeInput(input));
|
|
278
306
|
}
|
|
279
307
|
successResult(...args) {
|
|
280
308
|
const output = args[0];
|
|
@@ -293,7 +321,8 @@ class ActionPayload_Request extends ActionPayload {
|
|
|
293
321
|
toJsonObject() {
|
|
294
322
|
return {
|
|
295
323
|
...super.toBaseJsonObject(),
|
|
296
|
-
input: this.context.schema.serializeInput(this.input)
|
|
324
|
+
input: this.context.schema.serializeInput(this.input),
|
|
325
|
+
inputHash: this.inputHash
|
|
297
326
|
};
|
|
298
327
|
}
|
|
299
328
|
toJsonString() {
|
|
@@ -421,6 +450,7 @@ class RunningAction {
|
|
|
421
450
|
this._resolveResult = resolve;
|
|
422
451
|
this._rejectResult = reject;
|
|
423
452
|
});
|
|
453
|
+
this._resultPayloadPromise.catch(() => {});
|
|
424
454
|
this._state = {
|
|
425
455
|
request: initialState.request,
|
|
426
456
|
progress: initialState.progress ?? [],
|
|
@@ -519,6 +549,20 @@ class RunningAction {
|
|
|
519
549
|
});
|
|
520
550
|
return true;
|
|
521
551
|
}
|
|
552
|
+
_failWithError(error) {
|
|
553
|
+
if (this._state.result != null || this._isAborted)
|
|
554
|
+
return false;
|
|
555
|
+
this._isAborted = true;
|
|
556
|
+
this._rejectResult(error);
|
|
557
|
+
this._sendUpdate({
|
|
558
|
+
type: "finished" /* finished */,
|
|
559
|
+
finishType: "failed" /* failed */,
|
|
560
|
+
runningAction: this,
|
|
561
|
+
time: Date.now(),
|
|
562
|
+
error
|
|
563
|
+
});
|
|
564
|
+
return true;
|
|
565
|
+
}
|
|
522
566
|
_updateProgress(progress) {
|
|
523
567
|
if (this._state.result != null || this._isAborted)
|
|
524
568
|
return;
|
|
@@ -540,6 +584,9 @@ class RunningAction {
|
|
|
540
584
|
return this._completeWithResult(result);
|
|
541
585
|
}
|
|
542
586
|
}
|
|
587
|
+
// src/ActionRuntime/Handler/Local/ActionLocalHandler.ts
|
|
588
|
+
import { castNiceError as castNiceError2, isNiceErrorObject, NiceError } from "@nice-code/error";
|
|
589
|
+
|
|
543
590
|
// src/errors/err_nice_action.ts
|
|
544
591
|
import { err, err_nice } from "@nice-code/error";
|
|
545
592
|
var EErrId_NiceAction;
|
|
@@ -637,6 +684,7 @@ var isActionPayload_Result_JsonObject = (obj) => {
|
|
|
637
684
|
};
|
|
638
685
|
|
|
639
686
|
// src/ActionRuntime/ActionRuntime.ts
|
|
687
|
+
import { castNiceError } from "@nice-code/error";
|
|
640
688
|
import { nanoid as nanoid2 } from "nanoid";
|
|
641
689
|
|
|
642
690
|
// src/utils/getAssumedRuntimeEnvironment.ts
|
|
@@ -912,8 +960,18 @@ class ActionRuntime {
|
|
|
912
960
|
return this.handleActionPayload(action);
|
|
913
961
|
}
|
|
914
962
|
async handleActionPayload(action, options) {
|
|
915
|
-
const handlerForAction = this.getHandlerForActionOrThrow(action, options);
|
|
916
963
|
if (action.type === "request" /* request */) {
|
|
964
|
+
let handlerForAction;
|
|
965
|
+
try {
|
|
966
|
+
handlerForAction = this.getHandlerForActionOrThrow(action, options);
|
|
967
|
+
} catch (err2) {
|
|
968
|
+
const runningAction2 = new RunningAction({
|
|
969
|
+
context: action.context,
|
|
970
|
+
request: action
|
|
971
|
+
});
|
|
972
|
+
runningAction2._completeWithResult(action.errorResult(castNiceError(err2)));
|
|
973
|
+
return runningAction2;
|
|
974
|
+
}
|
|
917
975
|
const runningAction = await handlerForAction.handleActionRequest(action, {
|
|
918
976
|
...options,
|
|
919
977
|
targetLocalRuntime: this
|
|
@@ -1119,7 +1177,15 @@ class ActionLocalHandler extends ActionHandler {
|
|
|
1119
1177
|
parentCuid: peekHandlerCuid(),
|
|
1120
1178
|
callSite: action._callSite ?? new Error().stack
|
|
1121
1179
|
});
|
|
1122
|
-
this._handleRunningAction(handler, runningAction).catch((err2) =>
|
|
1180
|
+
this._handleRunningAction(handler, runningAction).catch((err2) => {
|
|
1181
|
+
if (err2 instanceof NiceError) {
|
|
1182
|
+
runningAction._completeWithResult(action.errorResult(err2));
|
|
1183
|
+
} else if (isNiceErrorObject(err2)) {
|
|
1184
|
+
runningAction._completeWithResult(action.errorResult(castNiceError2(err2)));
|
|
1185
|
+
} else {
|
|
1186
|
+
runningAction._abort(err2);
|
|
1187
|
+
}
|
|
1188
|
+
});
|
|
1123
1189
|
return runningAction;
|
|
1124
1190
|
}
|
|
1125
1191
|
async _handleRunningAction(handler, runningAction) {
|
|
@@ -1263,6 +1329,17 @@ class ActionDomain extends ActionDomainBase {
|
|
|
1263
1329
|
}
|
|
1264
1330
|
return new ActionCore(this, id);
|
|
1265
1331
|
}
|
|
1332
|
+
wrapAsPartialLocalHandler(wrappedActionExecutor) {
|
|
1333
|
+
const _handler = new ActionLocalHandler;
|
|
1334
|
+
const executor = wrappedActionExecutor;
|
|
1335
|
+
for (const actionKey in wrappedActionExecutor) {
|
|
1336
|
+
if (!this.actionSchema[actionKey]) {
|
|
1337
|
+
continue;
|
|
1338
|
+
}
|
|
1339
|
+
_handler.forAction(this.actionForId(actionKey), (request) => executor[request.id](request.input));
|
|
1340
|
+
}
|
|
1341
|
+
return _handler;
|
|
1342
|
+
}
|
|
1266
1343
|
wrapAsLocalHandler(wrappedActionExecutor) {
|
|
1267
1344
|
const _handler = new ActionLocalHandler;
|
|
1268
1345
|
const executor = wrappedActionExecutor;
|
|
@@ -1331,7 +1408,11 @@ class ActionDomain extends ActionDomainBase {
|
|
|
1331
1408
|
});
|
|
1332
1409
|
}
|
|
1333
1410
|
const contextAction = this.hydrateContext(id, serialized.context);
|
|
1334
|
-
|
|
1411
|
+
const result = serialized.result.ok ? {
|
|
1412
|
+
ok: true,
|
|
1413
|
+
output: contextAction.schema.deserializeOutput(serialized.result.output)
|
|
1414
|
+
} : serialized.result;
|
|
1415
|
+
return new ActionPayload_Result({ context: contextAction }, result, {
|
|
1335
1416
|
time: serialized.time
|
|
1336
1417
|
});
|
|
1337
1418
|
}
|
|
@@ -1508,9 +1589,22 @@ class ActionRootDomain extends ActionDomainBase {
|
|
|
1508
1589
|
return this._actionRuntimeManager.getBestRuntimeForSpecifier(clientSpecifier);
|
|
1509
1590
|
}
|
|
1510
1591
|
async _runAction(actionPayload, options) {
|
|
1511
|
-
const { handler, runtime: runtime2 } = this._actionRuntimeManager.getRuntimeAndHandlerForActionOrThrow(actionPayload, options);
|
|
1512
|
-
actionPayload.context._setOriginClient(runtime2.coordinate);
|
|
1513
1592
|
const allListeners = [...this._listeners, ...options?.listeners ?? []];
|
|
1593
|
+
let handlerAndRuntime;
|
|
1594
|
+
try {
|
|
1595
|
+
handlerAndRuntime = this._actionRuntimeManager.getRuntimeAndHandlerForActionOrThrow(actionPayload, options);
|
|
1596
|
+
} catch (err2) {
|
|
1597
|
+
const runningAction2 = new RunningAction({
|
|
1598
|
+
context: actionPayload.context,
|
|
1599
|
+
request: actionPayload,
|
|
1600
|
+
callSite: actionPayload._callSite
|
|
1601
|
+
});
|
|
1602
|
+
runningAction2.addUpdateListeners(allListeners);
|
|
1603
|
+
runningAction2._failWithError(err2);
|
|
1604
|
+
throw err2;
|
|
1605
|
+
}
|
|
1606
|
+
const { handler, runtime: runtime2 } = handlerAndRuntime;
|
|
1607
|
+
actionPayload.context._setOriginClient(runtime2.coordinate);
|
|
1514
1608
|
const runningAction = await handler.handleActionRequest(actionPayload, {
|
|
1515
1609
|
targetLocalRuntime: runtime2
|
|
1516
1610
|
});
|
|
@@ -1534,20 +1628,12 @@ class ActionSchema {
|
|
|
1534
1628
|
get outputSchema() {
|
|
1535
1629
|
return this.outputOptions?.schema;
|
|
1536
1630
|
}
|
|
1537
|
-
input(options
|
|
1538
|
-
|
|
1539
|
-
this.inputOptions = { ...options, serialization: { serialize, deserialize } };
|
|
1540
|
-
} else {
|
|
1541
|
-
this.inputOptions = options;
|
|
1542
|
-
}
|
|
1631
|
+
input(options) {
|
|
1632
|
+
this.inputOptions = options;
|
|
1543
1633
|
return this;
|
|
1544
1634
|
}
|
|
1545
|
-
output(options
|
|
1546
|
-
|
|
1547
|
-
this.outputOptions = { ...options, serialization: { serialize, deserialize } };
|
|
1548
|
-
} else {
|
|
1549
|
-
this.outputOptions = options;
|
|
1550
|
-
}
|
|
1635
|
+
output(options) {
|
|
1636
|
+
this.outputOptions = options;
|
|
1551
1637
|
return this;
|
|
1552
1638
|
}
|
|
1553
1639
|
throws(domain, ids) {
|
|
@@ -1877,7 +1963,7 @@ class TransportCustom extends Transport {
|
|
|
1877
1963
|
}
|
|
1878
1964
|
|
|
1879
1965
|
// src/ActionRuntime/Handler/ExternalClient/Transport/Http/TransportHttp.ts
|
|
1880
|
-
import { castNiceError, NiceError } from "@nice-code/error";
|
|
1966
|
+
import { castNiceError as castNiceError3, isNiceErrorObject as isNiceErrorObject2, NiceError as NiceError2 } from "@nice-code/error";
|
|
1881
1967
|
class TransportHttp extends Transport {
|
|
1882
1968
|
constructor(def) {
|
|
1883
1969
|
super({
|
|
@@ -1929,8 +2015,12 @@ class TransportHttp extends Transport {
|
|
|
1929
2015
|
const jsonData = await res.json();
|
|
1930
2016
|
if (isActionPayload_Result_JsonObject(jsonData)) {
|
|
1931
2017
|
runningAction._completeWithResult(action._domain.hydrateResultPayload(jsonData));
|
|
2018
|
+
} else if (isNiceErrorObject2(jsonData)) {
|
|
2019
|
+
runningAction._completeWithResult(action.errorResult(castNiceError3(jsonData)));
|
|
1932
2020
|
} else {
|
|
1933
|
-
runningAction._completeWithResult(action.errorResult(
|
|
2021
|
+
runningAction._completeWithResult(action.errorResult(err_nice_transport.fromId("invalid_action_response" /* invalid_action_response */, {
|
|
2022
|
+
actionId: action.id
|
|
2023
|
+
})));
|
|
1934
2024
|
}
|
|
1935
2025
|
} catch (e) {
|
|
1936
2026
|
throw err_nice_transport.fromId("send_failed" /* send_failed */, {
|
|
@@ -1969,7 +2059,7 @@ class TransportHttp extends Transport {
|
|
|
1969
2059
|
if (timedOut) {
|
|
1970
2060
|
throw err_nice_transport.fromId("timeout" /* timeout */, { timeout });
|
|
1971
2061
|
}
|
|
1972
|
-
if (err3 instanceof
|
|
2062
|
+
if (err3 instanceof NiceError2) {
|
|
1973
2063
|
throw err3;
|
|
1974
2064
|
}
|
|
1975
2065
|
throw err_nice_transport.fromId("send_failed" /* send_failed */, {
|
|
@@ -2,18 +2,36 @@
|
|
|
2
2
|
import {
|
|
3
3
|
useMutation
|
|
4
4
|
} from "@tanstack/react-query";
|
|
5
|
+
import { useRef } from "react";
|
|
5
6
|
function useActionMutation(action, options) {
|
|
6
7
|
const mutationOptions = options ?? {};
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
const callSiteRef = useRef(undefined);
|
|
9
|
+
const result = useMutation({
|
|
10
|
+
mutationFn: (input) => {
|
|
11
|
+
const req = action.request(input);
|
|
12
|
+
req._callSite = callSiteRef.current;
|
|
13
|
+
callSiteRef.current = undefined;
|
|
14
|
+
return req.runToOutput();
|
|
15
|
+
},
|
|
9
16
|
...mutationOptions
|
|
10
17
|
});
|
|
18
|
+
return {
|
|
19
|
+
...result,
|
|
20
|
+
mutate: (...args) => {
|
|
21
|
+
callSiteRef.current = new Error().stack;
|
|
22
|
+
return result.mutate(...args);
|
|
23
|
+
},
|
|
24
|
+
mutateAsync: (...args) => {
|
|
25
|
+
callSiteRef.current = new Error().stack;
|
|
26
|
+
return result.mutateAsync(...args);
|
|
27
|
+
}
|
|
28
|
+
};
|
|
11
29
|
}
|
|
12
30
|
// src/react-query/hooks/useActionQuery.ts
|
|
13
31
|
import {
|
|
14
32
|
useQuery
|
|
15
33
|
} from "@tanstack/react-query";
|
|
16
|
-
import { useRef } from "react";
|
|
34
|
+
import { useRef as useRef2 } from "react";
|
|
17
35
|
function actionQueryKey(action, input) {
|
|
18
36
|
if (input === undefined) {
|
|
19
37
|
return ["nice-action", action.domain, action.allDomains, action.id];
|
|
@@ -30,7 +48,7 @@ function useActionQuery(action, ...args) {
|
|
|
30
48
|
[options] = args;
|
|
31
49
|
}
|
|
32
50
|
const { enabled, ...queryOptions } = options ?? {};
|
|
33
|
-
const callSiteRef =
|
|
51
|
+
const callSiteRef = useRef2(new Error().stack);
|
|
34
52
|
return useQuery({
|
|
35
53
|
queryKey: input != null ? actionQueryKey(action, input) : actionQueryKey(action),
|
|
36
54
|
queryFn: () => {
|
|
@@ -87,6 +87,7 @@ export interface IActionPayload_Base_JsonObject<DT extends EActionPayloadType, D
|
|
|
87
87
|
export interface IActionPayload_Request_JsonObject<DOM extends IActionDomain = IActionDomain, ID extends keyof DOM["actionSchema"] & string = keyof DOM["actionSchema"] & string> extends IActionPayload_Base_JsonObject<EActionPayloadType.request, DOM, ID> {
|
|
88
88
|
type: EActionPayloadType.request;
|
|
89
89
|
input: TInferInputFromSchema<DOM["actionSchema"][ID]>["SerdeInput"];
|
|
90
|
+
inputHash: string;
|
|
90
91
|
}
|
|
91
92
|
export interface IActionPayload_Progress_JsonObject<DOM extends IActionDomain = IActionDomain, ID extends keyof DOM["actionSchema"] & string = keyof DOM["actionSchema"] & string> extends IActionPayload_Base_JsonObject<EActionPayloadType.progress, DOM, ID> {
|
|
92
93
|
type: EActionPayloadType.progress;
|
|
@@ -94,7 +95,8 @@ export interface IActionPayload_Progress_JsonObject<DOM extends IActionDomain =
|
|
|
94
95
|
}
|
|
95
96
|
export interface IActionPayload_Result_JsonObject<DOM extends IActionDomain = IActionDomain, ID extends keyof DOM["actionSchema"] & string = keyof DOM["actionSchema"] & string> extends IActionPayload_Base_JsonObject<EActionPayloadType.result, DOM, ID> {
|
|
96
97
|
type: EActionPayloadType.result;
|
|
97
|
-
result: TActionResultOutcome<TInferOutputFromSchema<DOM["actionSchema"][ID]>["
|
|
98
|
+
result: TActionResultOutcome<TInferOutputFromSchema<DOM["actionSchema"][ID]>["SerdeOutput"], TInferActionError<DOM["actionSchema"][ID]>>;
|
|
99
|
+
outputHash: string;
|
|
98
100
|
}
|
|
99
101
|
/**
|
|
100
102
|
*
|
|
@@ -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
|
+
readonly inputHash: string;
|
|
13
14
|
_callSite?: string;
|
|
14
15
|
constructor(params: {
|
|
15
16
|
context: ActionContext<DOM, ID>;
|
|
@@ -7,6 +7,7 @@ import { EActionPayloadType, type IActionPayload_Result_JsonObject } from "./Act
|
|
|
7
7
|
import { ActionPayload_Request } from "./ActionPayload_Request";
|
|
8
8
|
export declare class ActionPayload_Result<DOM extends IActionDomain, ID extends keyof DOM["actionSchema"] & string = keyof DOM["actionSchema"] & string> extends ActionPayload<EActionPayloadType.result, DOM, ID> {
|
|
9
9
|
readonly result: TActionResultOutcome<TInferOutputFromSchema<DOM["actionSchema"][ID]>["Output"], TInferActionError<DOM["actionSchema"][ID]>>;
|
|
10
|
+
readonly outputHash: string;
|
|
10
11
|
constructor(params: {
|
|
11
12
|
context: ActionContext<DOM, ID>;
|
|
12
13
|
} | ActionPayload_Request<DOM, ID>, result: TActionResultOutcome<TInferOutputFromSchema<DOM["actionSchema"][ID]>["Output"], TInferActionError<DOM["actionSchema"][ID]>>, data: IActionPayload_Data_Base);
|
|
@@ -29,6 +29,7 @@ export declare class RunningAction<DOM extends IActionDomain, ID extends keyof D
|
|
|
29
29
|
_sendUpdate(update: TRunningActionUpdate<DOM, ID>): void;
|
|
30
30
|
_completeWithResult(result: ActionPayload_Result<DOM, ID>): boolean;
|
|
31
31
|
_abort(reason?: unknown): boolean;
|
|
32
|
+
_failWithError(error: unknown): boolean;
|
|
32
33
|
_updateProgress(progress: ActionPayload_Progress<DOM, ID>): void;
|
|
33
34
|
waitForResultPayload(): Promise<ActionPayload_Result<DOM, ID>>;
|
|
34
35
|
_resolveFromJson(resultJson: IActionPayload_Result_JsonObject<DOM, ID>): boolean;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
import type { ActionRuntime } from "../../ActionRuntime/ActionRuntime";
|
|
1
2
|
import type { IExecuteActionOptions } from "../../ActionRuntime/Handler/ActionHandler.types";
|
|
2
3
|
import { ActionLocalHandler } from "../../ActionRuntime/Handler/Local/ActionLocalHandler";
|
|
3
|
-
import type { ActionRuntime } from "../../ActionRuntime/ActionRuntime";
|
|
4
4
|
import type { TAction_Any_JsonObject, TDistributeActionPayload_Request, TDistributeActionPayload_Result, TDistributedDomainActions, TNarrowActionJsonTypeToActionInstanceType } from "../Action/Action.combined.types";
|
|
5
5
|
import { type IActionBase } from "../Action/ActionBase.types";
|
|
6
6
|
import { ActionContext } from "../Action/Context/ActionContext";
|
|
@@ -29,6 +29,7 @@ export declare class ActionDomain<ACT_DOM extends IActionDomain = IActionDomain>
|
|
|
29
29
|
get action(): TActionMap<ACT_DOM>;
|
|
30
30
|
actionsMap(): TActionMap<ACT_DOM>;
|
|
31
31
|
actionForId<ID extends keyof ACT_DOM["actionSchema"] & string>(id: ID): ActionCore<ACT_DOM, ID>;
|
|
32
|
+
wrapAsPartialLocalHandler(wrappedActionExecutor: Partial<TWrappableDomainActionHandler<ACT_DOM>>): ActionLocalHandler;
|
|
32
33
|
wrapAsLocalHandler(wrappedActionExecutor: TWrappableDomainActionHandler<ACT_DOM>): ActionLocalHandler;
|
|
33
34
|
hydrateContext<ID extends keyof ACT_DOM["actionSchema"] & string>(id: ID, contextData: IActionContext_Data_JsonObject): ActionContext<ACT_DOM, ID>;
|
|
34
35
|
isDomainAction<ACT extends IActionBase<any, ACT_DOM, any>>(action: ACT | unknown | null | undefined): action is TDistributedDomainActions<ACT_DOM, ACT>;
|
|
@@ -2,7 +2,7 @@ import type { ActionRuntime } from "../../ActionRuntime/ActionRuntime";
|
|
|
2
2
|
import type { IExecuteActionOptions } from "../../ActionRuntime/Handler/ActionHandler.types";
|
|
3
3
|
import type { IRuntimeCoordinate } from "../../ActionRuntime/RuntimeCoordinate";
|
|
4
4
|
import type { ActionPayload_Request } from "../Action/Payload/ActionPayload_Request";
|
|
5
|
-
import
|
|
5
|
+
import { RunningAction } from "../Action/RunningAction";
|
|
6
6
|
import { ActionDomain } from "./ActionDomain";
|
|
7
7
|
import type { IActionDomain, IActionDomainChildOptions, IActionRootDomain, TActionDomainChildDef } from "./ActionDomain.types";
|
|
8
8
|
import { ActionDomainBase } from "./ActionDomainBase";
|
|
@@ -13,30 +13,12 @@ export declare class ActionSchema<INPUT extends TTransportedValue<any, any> = ne
|
|
|
13
13
|
* needing explicit type parameters.
|
|
14
14
|
*/
|
|
15
15
|
input<VS extends StandardSchemaV1 = StandardSchemaV1, SERDE_IN = any>(options: TActionSchemaOptions<VS, SERDE_IN>): ActionSchema<TTransportedValue<StandardSchemaV1.InferInput<VS>, SERDE_IN>, OUTPUT, ERRORS>;
|
|
16
|
-
/**
|
|
17
|
-
* Declare the input schema with serialization via sequential parameters.
|
|
18
|
-
* TypeScript infers SERDE_IN from `serialize`'s return type (left-to-right),
|
|
19
|
-
* then provides it as the contextual type for `deserialize`'s parameter —
|
|
20
|
-
* no explicit type parameters or casts needed.
|
|
21
|
-
*/
|
|
22
|
-
input<VS extends StandardSchemaV1, SERDE_IN = any>(options: {
|
|
23
|
-
schema: VS;
|
|
24
|
-
}, serialize: (raw: StandardSchemaV1.InferInput<VS>) => SERDE_IN, deserialize: (serde: SERDE_IN) => StandardSchemaV1.InferInput<VS>): ActionSchema<TTransportedValue<StandardSchemaV1.InferInput<VS>, SERDE_IN>, OUTPUT, ERRORS>;
|
|
25
16
|
/**
|
|
26
17
|
* Declare the output schema (JSON-native or with explicit SERDE type param).
|
|
27
18
|
* For non-JSON-native outputs, prefer the 3-argument form below to avoid
|
|
28
19
|
* needing explicit type parameters.
|
|
29
20
|
*/
|
|
30
21
|
output<VS extends StandardSchemaV1 = StandardSchemaV1, SERDE_OUT = any>(options: TActionSchemaOptions<VS, SERDE_OUT>): ActionSchema<INPUT, TTransportedValue<StandardSchemaV1.InferInput<VS>, SERDE_OUT>, ERRORS>;
|
|
31
|
-
/**
|
|
32
|
-
* Declare the output schema with serialization via sequential parameters.
|
|
33
|
-
* TypeScript infers SERDE_OUT from `serialize`'s return type (left-to-right),
|
|
34
|
-
* then provides it as the contextual type for `deserialize`'s parameter —
|
|
35
|
-
* no explicit type parameters or casts needed.
|
|
36
|
-
*/
|
|
37
|
-
output<VS extends StandardSchemaV1, SERDE_OUT = any>(options: {
|
|
38
|
-
schema: VS;
|
|
39
|
-
}, serialize: (raw: StandardSchemaV1.InferInput<VS>) => SERDE_OUT, deserialize: (serde: SERDE_OUT) => StandardSchemaV1.InferInput<VS>): ActionSchema<INPUT, TTransportedValue<StandardSchemaV1.InferInput<VS>, SERDE_OUT>, ERRORS>;
|
|
40
22
|
/**
|
|
41
23
|
* Declare that this action may throw any error from `domain`.
|
|
42
24
|
* `TInferActionError` will include `NiceError<DEF, keyof schema>` in its union.
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import type { IDevtoolsRouteItem } from "../../core/ActionDevtools.types";
|
|
2
|
+
import { ESize } from "../ui_util/size";
|
|
3
|
+
export declare function ChildDispatchChips({ childRouteItems, size, }: {
|
|
4
|
+
childRouteItems?: IDevtoolsRouteItem[];
|
|
5
|
+
size?: ESize;
|
|
4
6
|
}): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -1,11 +1,23 @@
|
|
|
1
|
-
import type
|
|
2
|
-
|
|
1
|
+
import { type CSSProperties, type ReactNode } from "react";
|
|
2
|
+
import { type ESemanticThing } from "../../core/devtools_colors";
|
|
3
|
+
import { ESize } from "../ui_util/size";
|
|
4
|
+
import { type ITooltipConfig } from "./Tooltip";
|
|
5
|
+
export interface IChipColorEntry {
|
|
3
6
|
color: string;
|
|
4
7
|
borderColor: string;
|
|
5
|
-
|
|
6
|
-
|
|
8
|
+
subtle?: {
|
|
9
|
+
color?: string;
|
|
10
|
+
borderColor?: string;
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
interface IChipProps {
|
|
14
|
+
color: ESemanticThing;
|
|
15
|
+
subtle?: boolean;
|
|
16
|
+
size?: ESize;
|
|
17
|
+
rounded?: boolean;
|
|
18
|
+
tooltip?: ITooltipConfig;
|
|
7
19
|
children: ReactNode;
|
|
8
20
|
style?: CSSProperties;
|
|
9
21
|
}
|
|
10
|
-
export declare function Chip({ color,
|
|
22
|
+
export declare function Chip({ color, subtle, size, rounded, tooltip, children, style, }: IChipProps): import("react/jsx-runtime").JSX.Element;
|
|
11
23
|
export {};
|
|
@@ -1,15 +1,7 @@
|
|
|
1
|
-
|
|
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;
|
|
1
|
+
import { ESize } from "../ui_util/size";
|
|
10
2
|
export declare function DomainChip({ subtle, domain, allDomains, size, }: {
|
|
11
3
|
subtle?: boolean;
|
|
12
4
|
domain: string;
|
|
13
|
-
allDomains
|
|
14
|
-
size
|
|
5
|
+
allDomains: string[];
|
|
6
|
+
size?: ESize;
|
|
15
7
|
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { IDevtoolsActionEntry, IDevtoolsRouteItem } from "../../core/ActionDevtools.types";
|
|
2
|
+
import { ESize } from "../ui_util/size";
|
|
2
3
|
export declare function getExternalLabel(hop: IDevtoolsRouteItem): string | null;
|
|
3
4
|
interface IHandlerChipsProps {
|
|
4
5
|
entry: IDevtoolsActionEntry;
|
|
5
|
-
size:
|
|
6
|
+
size: ESize;
|
|
6
7
|
}
|
|
7
8
|
export declare function HandlerChips({ entry, size }: IHandlerChipsProps): import("react/jsx-runtime").JSX.Element;
|
|
8
9
|
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { LucideIcon } from "lucide-react";
|
|
2
|
+
import type { CSSProperties } from "react";
|
|
3
|
+
import { type ESemanticThing } from "../../core/devtools_colors";
|
|
4
|
+
import { ESize } from "../ui_util/size";
|
|
5
|
+
import { type ITooltipConfig } from "./Tooltip";
|
|
6
|
+
interface IIconProps {
|
|
7
|
+
icon: LucideIcon;
|
|
8
|
+
color: ESemanticThing;
|
|
9
|
+
size?: ESize;
|
|
10
|
+
subtle?: boolean;
|
|
11
|
+
tooltip?: ITooltipConfig;
|
|
12
|
+
style?: CSSProperties;
|
|
13
|
+
}
|
|
14
|
+
export declare function Icon({ icon: IconComponent, color, size, subtle, tooltip, style, }: IIconProps): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type TNiceErrorJson = {
|
|
2
|
+
name: "NiceError";
|
|
3
|
+
message: string;
|
|
4
|
+
ids: string[];
|
|
5
|
+
httpStatusCode: number;
|
|
6
|
+
def: {
|
|
7
|
+
domain: string;
|
|
8
|
+
allDomains: string[];
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
export declare function isNiceErrorJson(value: unknown): value is TNiceErrorJson;
|
|
12
|
+
export declare function NiceErrorBody({ error }: {
|
|
13
|
+
error: TNiceErrorJson;
|
|
14
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
15
|
+
export declare function NiceErrorDisplay({ error, label, color, }: {
|
|
16
|
+
error: TNiceErrorJson;
|
|
17
|
+
label: string;
|
|
18
|
+
color: string;
|
|
19
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
export declare function
|
|
1
|
+
export declare function countUserFrames(stack: string | undefined): number;
|
|
2
|
+
export declare function StackTraceSection({ label, stack, color, minFrameCount, }: {
|
|
2
3
|
label: string;
|
|
3
4
|
stack: string | undefined;
|
|
4
5
|
color?: string;
|
|
6
|
+
minFrameCount?: number;
|
|
5
7
|
}): import("react/jsx-runtime").JSX.Element | null;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export interface ITooltipConfig {
|
|
3
|
+
content: ReactNode;
|
|
4
|
+
title?: ReactNode;
|
|
5
|
+
/** "center" centers the tooltip above/below the anchor (default).
|
|
6
|
+
* "edge" aligns the nearer horizontal edge with the anchor edge. */
|
|
7
|
+
align?: "center" | "edge";
|
|
8
|
+
maxWidth?: number;
|
|
9
|
+
}
|
|
10
|
+
export declare function Tooltip({ anchor, config, children, }: {
|
|
11
|
+
anchor: DOMRect;
|
|
12
|
+
config: ITooltipConfig;
|
|
13
|
+
children?: ReactNode;
|
|
14
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { IDevtoolsActionEntry } from "
|
|
1
|
+
import type { IDevtoolsActionEntry } from "../../../core/ActionDevtools.types";
|
|
2
2
|
export declare function ActionDetailPanel({ entry, parent, childEntries, onSelectEntry, }: {
|
|
3
3
|
entry: IDevtoolsActionEntry;
|
|
4
4
|
parent: IDevtoolsActionEntry | null;
|