@nice-code/action 0.0.21 → 0.1.1
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/README.md +410 -0
- package/build/index.js +1148 -749
- package/build/react-query/index.js +170 -45
- package/build/types/ActionDomain/NiceActionDomain.d.ts +18 -46
- package/build/types/ActionDomain/NiceActionDomain.types.d.ts +9 -45
- package/build/types/ActionDomain/NiceActionDomainBase.d.ts +14 -0
- package/build/types/ActionDomain/RootDomain/NiceActionRootDomain.d.ts +22 -0
- package/build/types/ActionDomain/helpers/createRootActionDomain.d.ts +5 -0
- package/build/types/ActionRuntimeEnvironment/ActionConnect/ActionConnect.d.ts +24 -0
- package/build/types/ActionRuntimeEnvironment/ActionConnect/ActionConnect.types.d.ts +15 -0
- package/build/types/ActionRuntimeEnvironment/ActionConnect/ConnectionConfig/ConnectionConfig.d.ts +12 -0
- package/build/types/ActionRuntimeEnvironment/ActionConnect/ConnectionConfig/ConnectionConfig.types.d.ts +6 -0
- package/build/types/ActionRuntimeEnvironment/ActionConnect/Transport/Transport.d.ts +16 -0
- package/build/types/ActionRuntimeEnvironment/ActionConnect/Transport/Transport.types.d.ts +50 -0
- package/build/types/ActionRuntimeEnvironment/ActionConnect/Transport/TransportHttp.d.ts +9 -0
- package/build/types/ActionRuntimeEnvironment/ActionConnect/Transport/TransportWebSocket.d.ts +15 -0
- package/build/types/ActionRuntimeEnvironment/ActionConnect/Transport/err_nice_transport.d.ts +34 -0
- package/build/types/ActionRuntimeEnvironment/ActionConnect/Transport/err_nice_transport_ws.d.ts +18 -0
- package/build/types/ActionRuntimeEnvironment/ActionConnect/err_nice_connect.d.ts +5 -0
- package/build/types/ActionRuntimeEnvironment/ActionHandler/ActionHandler.d.ts +80 -0
- package/build/types/ActionRuntimeEnvironment/ActionHandler/ActionHandler.types.d.ts +68 -0
- package/build/types/ActionRuntimeEnvironment/ActionRuntimeEnvironment.d.ts +32 -0
- package/build/types/ActionRuntimeEnvironment/ActionRuntimeEnvironment.types.d.ts +15 -0
- package/build/types/ActionRuntimeEnvironment/utils/getAssumedRuntimeEnvironment.d.ts +2 -0
- package/build/types/ActionSchema/NiceActionSchema.d.ts +11 -7
- package/build/types/ActionSchema/NiceActionSchema.types.d.ts +1 -1
- package/build/types/NiceAction/MatchAction/MatchAction.d.ts +26 -0
- package/build/types/NiceAction/NiceAction.d.ts +19 -21
- package/build/types/NiceAction/NiceAction.enums.d.ts +5 -0
- package/build/types/NiceAction/NiceAction.types.d.ts +8 -11
- package/build/types/NiceAction/NiceActionCombined.types.d.ts +10 -0
- package/build/types/NiceAction/NiceActionPrimed.d.ts +19 -36
- package/build/types/NiceAction/NiceActionResponse.d.ts +15 -6
- package/build/types/NiceAction/utils/isNiceActionInstance.d.ts +3 -0
- package/build/types/errors/err_nice_action.d.ts +34 -12
- package/build/types/index.d.ts +22 -8
- package/build/types/react-query/index.d.ts +8 -10
- package/package.json +8 -6
- package/build/types/ActionDomain/createActionDomain.d.ts +0 -5
- package/build/types/ActionRequestResponse/ActionRequester/NiceActionRequester.d.ts +0 -31
- package/build/types/ActionRequestResponse/ActionResponder/NiceActionResponder.d.ts +0 -49
- package/build/types/ActionRequestResponse/ActionResponder/NiceActionResponder.types.d.ts +0 -7
- package/build/types/ActionRequestResponse/ActionResponder/NiceActionResponderEnvironment.d.ts +0 -42
- package/build/types/NiceAction/ActionSchema/NiceActionSchema.d.ts +0 -99
- package/build/types/NiceAction/ActionSchema/NiceActionSchema.types.d.ts +0 -31
- package/build/types/NiceAction/ActionSchema/NiceActionSchemaBuilder.d.ts +0 -1
- package/build/types/NiceAction/ActionSchema/action.d.ts +0 -2
- package/build/types/NiceAction/NiceActionPrimed.schema.d.ts +0 -8
- package/build/types/test/nice_action_test_schema.d.ts +0 -30
|
@@ -1086,7 +1086,7 @@ var require_jsx_runtime = __commonJS((exports, module) => {
|
|
|
1086
1086
|
}
|
|
1087
1087
|
});
|
|
1088
1088
|
|
|
1089
|
-
// ../../node_modules/.bun/@tanstack+query-core@5.
|
|
1089
|
+
// ../../node_modules/.bun/@tanstack+query-core@5.100.3/node_modules/@tanstack/query-core/build/modern/subscribable.js
|
|
1090
1090
|
var Subscribable = class {
|
|
1091
1091
|
constructor() {
|
|
1092
1092
|
this.listeners = /* @__PURE__ */ new Set;
|
|
@@ -1107,7 +1107,7 @@ var Subscribable = class {
|
|
|
1107
1107
|
onUnsubscribe() {}
|
|
1108
1108
|
};
|
|
1109
1109
|
|
|
1110
|
-
// ../../node_modules/.bun/@tanstack+query-core@5.
|
|
1110
|
+
// ../../node_modules/.bun/@tanstack+query-core@5.100.3/node_modules/@tanstack/query-core/build/modern/focusManager.js
|
|
1111
1111
|
var FocusManager = class extends Subscribable {
|
|
1112
1112
|
#focused;
|
|
1113
1113
|
#cleanup;
|
|
@@ -1169,7 +1169,7 @@ var FocusManager = class extends Subscribable {
|
|
|
1169
1169
|
};
|
|
1170
1170
|
var focusManager = new FocusManager;
|
|
1171
1171
|
|
|
1172
|
-
// ../../node_modules/.bun/@tanstack+query-core@5.
|
|
1172
|
+
// ../../node_modules/.bun/@tanstack+query-core@5.100.3/node_modules/@tanstack/query-core/build/modern/timeoutManager.js
|
|
1173
1173
|
var defaultTimeoutProvider = {
|
|
1174
1174
|
setTimeout: (callback, delay) => setTimeout(callback, delay),
|
|
1175
1175
|
clearTimeout: (timeoutId) => clearTimeout(timeoutId),
|
|
@@ -1214,7 +1214,7 @@ function systemSetTimeoutZero(callback) {
|
|
|
1214
1214
|
setTimeout(callback, 0);
|
|
1215
1215
|
}
|
|
1216
1216
|
|
|
1217
|
-
// ../../node_modules/.bun/@tanstack+query-core@5.
|
|
1217
|
+
// ../../node_modules/.bun/@tanstack+query-core@5.100.3/node_modules/@tanstack/query-core/build/modern/utils.js
|
|
1218
1218
|
var isServer = typeof window === "undefined" || "Deno" in globalThis;
|
|
1219
1219
|
function noop() {}
|
|
1220
1220
|
function isValidTimeout(value) {
|
|
@@ -1226,8 +1226,8 @@ function timeUntilStale(updatedAt, staleTime) {
|
|
|
1226
1226
|
function resolveStaleTime(staleTime, query) {
|
|
1227
1227
|
return typeof staleTime === "function" ? staleTime(query) : staleTime;
|
|
1228
1228
|
}
|
|
1229
|
-
function
|
|
1230
|
-
return typeof
|
|
1229
|
+
function resolveQueryBoolean(option, query) {
|
|
1230
|
+
return typeof option === "function" ? option(query) : option;
|
|
1231
1231
|
}
|
|
1232
1232
|
function hashKey(queryKey) {
|
|
1233
1233
|
return JSON.stringify(queryKey, (_, val) => isPlainObject(val) ? Object.keys(val).sort().reduce((result, key) => {
|
|
@@ -1330,6 +1330,14 @@ function replaceData(prevData, data, options) {
|
|
|
1330
1330
|
}
|
|
1331
1331
|
return data;
|
|
1332
1332
|
}
|
|
1333
|
+
function addToEnd(items, item, max = 0) {
|
|
1334
|
+
const newItems = [...items, item];
|
|
1335
|
+
return max && newItems.length > max ? newItems.slice(1) : newItems;
|
|
1336
|
+
}
|
|
1337
|
+
function addToStart(items, item, max = 0) {
|
|
1338
|
+
const newItems = [item, ...items];
|
|
1339
|
+
return max && newItems.length > max ? newItems.slice(0, -1) : newItems;
|
|
1340
|
+
}
|
|
1333
1341
|
var skipToken = /* @__PURE__ */ Symbol();
|
|
1334
1342
|
function ensureQueryFn(options, fetchOptions) {
|
|
1335
1343
|
if (true) {
|
|
@@ -1351,8 +1359,29 @@ function shouldThrowError(throwOnError, params) {
|
|
|
1351
1359
|
}
|
|
1352
1360
|
return !!throwOnError;
|
|
1353
1361
|
}
|
|
1362
|
+
function addConsumeAwareSignal(object, getSignal, onCancelled) {
|
|
1363
|
+
let consumed = false;
|
|
1364
|
+
let signal;
|
|
1365
|
+
Object.defineProperty(object, "signal", {
|
|
1366
|
+
enumerable: true,
|
|
1367
|
+
get: () => {
|
|
1368
|
+
signal ??= getSignal();
|
|
1369
|
+
if (consumed) {
|
|
1370
|
+
return signal;
|
|
1371
|
+
}
|
|
1372
|
+
consumed = true;
|
|
1373
|
+
if (signal.aborted) {
|
|
1374
|
+
onCancelled();
|
|
1375
|
+
} else {
|
|
1376
|
+
signal.addEventListener("abort", onCancelled, { once: true });
|
|
1377
|
+
}
|
|
1378
|
+
return signal;
|
|
1379
|
+
}
|
|
1380
|
+
});
|
|
1381
|
+
return object;
|
|
1382
|
+
}
|
|
1354
1383
|
|
|
1355
|
-
// ../../node_modules/.bun/@tanstack+query-core@5.
|
|
1384
|
+
// ../../node_modules/.bun/@tanstack+query-core@5.100.3/node_modules/@tanstack/query-core/build/modern/environmentManager.js
|
|
1356
1385
|
var environmentManager = /* @__PURE__ */ (() => {
|
|
1357
1386
|
let isServerFn = () => isServer;
|
|
1358
1387
|
return {
|
|
@@ -1365,7 +1394,7 @@ var environmentManager = /* @__PURE__ */ (() => {
|
|
|
1365
1394
|
};
|
|
1366
1395
|
})();
|
|
1367
1396
|
|
|
1368
|
-
// ../../node_modules/.bun/@tanstack+query-core@5.
|
|
1397
|
+
// ../../node_modules/.bun/@tanstack+query-core@5.100.3/node_modules/@tanstack/query-core/build/modern/thenable.js
|
|
1369
1398
|
function pendingThenable() {
|
|
1370
1399
|
let resolve;
|
|
1371
1400
|
let reject;
|
|
@@ -1397,7 +1426,7 @@ function pendingThenable() {
|
|
|
1397
1426
|
return thenable;
|
|
1398
1427
|
}
|
|
1399
1428
|
|
|
1400
|
-
// ../../node_modules/.bun/@tanstack+query-core@5.
|
|
1429
|
+
// ../../node_modules/.bun/@tanstack+query-core@5.100.3/node_modules/@tanstack/query-core/build/modern/notifyManager.js
|
|
1401
1430
|
var defaultScheduler = systemSetTimeoutZero;
|
|
1402
1431
|
function createNotifyManager() {
|
|
1403
1432
|
let queue = [];
|
|
@@ -1466,7 +1495,7 @@ function createNotifyManager() {
|
|
|
1466
1495
|
}
|
|
1467
1496
|
var notifyManager = createNotifyManager();
|
|
1468
1497
|
|
|
1469
|
-
// ../../node_modules/.bun/@tanstack+query-core@5.
|
|
1498
|
+
// ../../node_modules/.bun/@tanstack+query-core@5.100.3/node_modules/@tanstack/query-core/build/modern/onlineManager.js
|
|
1470
1499
|
var OnlineManager = class extends Subscribable {
|
|
1471
1500
|
#online = true;
|
|
1472
1501
|
#cleanup;
|
|
@@ -1518,7 +1547,7 @@ var OnlineManager = class extends Subscribable {
|
|
|
1518
1547
|
};
|
|
1519
1548
|
var onlineManager = new OnlineManager;
|
|
1520
1549
|
|
|
1521
|
-
// ../../node_modules/.bun/@tanstack+query-core@5.
|
|
1550
|
+
// ../../node_modules/.bun/@tanstack+query-core@5.100.3/node_modules/@tanstack/query-core/build/modern/retryer.js
|
|
1522
1551
|
function defaultRetryDelay(failureCount) {
|
|
1523
1552
|
return Math.min(1000 * 2 ** failureCount, 30000);
|
|
1524
1553
|
}
|
|
@@ -1638,7 +1667,7 @@ function createRetryer(config) {
|
|
|
1638
1667
|
};
|
|
1639
1668
|
}
|
|
1640
1669
|
|
|
1641
|
-
// ../../node_modules/.bun/@tanstack+query-core@5.
|
|
1670
|
+
// ../../node_modules/.bun/@tanstack+query-core@5.100.3/node_modules/@tanstack/query-core/build/modern/removable.js
|
|
1642
1671
|
var Removable = class {
|
|
1643
1672
|
#gcTimeout;
|
|
1644
1673
|
destroy() {
|
|
@@ -1663,8 +1692,97 @@ var Removable = class {
|
|
|
1663
1692
|
}
|
|
1664
1693
|
};
|
|
1665
1694
|
|
|
1666
|
-
// ../../node_modules/.bun/@tanstack+query-core@5.
|
|
1695
|
+
// ../../node_modules/.bun/@tanstack+query-core@5.100.3/node_modules/@tanstack/query-core/build/modern/infiniteQueryBehavior.js
|
|
1696
|
+
function infiniteQueryBehavior(pages) {
|
|
1697
|
+
return {
|
|
1698
|
+
onFetch: (context, query) => {
|
|
1699
|
+
const options = context.options;
|
|
1700
|
+
const direction = context.fetchOptions?.meta?.fetchMore?.direction;
|
|
1701
|
+
const oldPages = context.state.data?.pages || [];
|
|
1702
|
+
const oldPageParams = context.state.data?.pageParams || [];
|
|
1703
|
+
let result = { pages: [], pageParams: [] };
|
|
1704
|
+
let currentPage = 0;
|
|
1705
|
+
const fetchFn = async () => {
|
|
1706
|
+
let cancelled = false;
|
|
1707
|
+
const addSignalProperty = (object) => {
|
|
1708
|
+
addConsumeAwareSignal(object, () => context.signal, () => cancelled = true);
|
|
1709
|
+
};
|
|
1710
|
+
const queryFn = ensureQueryFn(context.options, context.fetchOptions);
|
|
1711
|
+
const fetchPage = async (data, param, previous) => {
|
|
1712
|
+
if (cancelled) {
|
|
1713
|
+
return Promise.reject();
|
|
1714
|
+
}
|
|
1715
|
+
if (param == null && data.pages.length) {
|
|
1716
|
+
return Promise.resolve(data);
|
|
1717
|
+
}
|
|
1718
|
+
const createQueryFnContext = () => {
|
|
1719
|
+
const queryFnContext2 = {
|
|
1720
|
+
client: context.client,
|
|
1721
|
+
queryKey: context.queryKey,
|
|
1722
|
+
pageParam: param,
|
|
1723
|
+
direction: previous ? "backward" : "forward",
|
|
1724
|
+
meta: context.options.meta
|
|
1725
|
+
};
|
|
1726
|
+
addSignalProperty(queryFnContext2);
|
|
1727
|
+
return queryFnContext2;
|
|
1728
|
+
};
|
|
1729
|
+
const queryFnContext = createQueryFnContext();
|
|
1730
|
+
const page = await queryFn(queryFnContext);
|
|
1731
|
+
const { maxPages } = context.options;
|
|
1732
|
+
const addTo = previous ? addToStart : addToEnd;
|
|
1733
|
+
return {
|
|
1734
|
+
pages: addTo(data.pages, page, maxPages),
|
|
1735
|
+
pageParams: addTo(data.pageParams, param, maxPages)
|
|
1736
|
+
};
|
|
1737
|
+
};
|
|
1738
|
+
if (direction && oldPages.length) {
|
|
1739
|
+
const previous = direction === "backward";
|
|
1740
|
+
const pageParamFn = previous ? getPreviousPageParam : getNextPageParam;
|
|
1741
|
+
const oldData = {
|
|
1742
|
+
pages: oldPages,
|
|
1743
|
+
pageParams: oldPageParams
|
|
1744
|
+
};
|
|
1745
|
+
const param = pageParamFn(options, oldData);
|
|
1746
|
+
result = await fetchPage(oldData, param, previous);
|
|
1747
|
+
} else {
|
|
1748
|
+
const remainingPages = pages ?? oldPages.length;
|
|
1749
|
+
do {
|
|
1750
|
+
const param = currentPage === 0 ? oldPageParams[0] ?? options.initialPageParam : getNextPageParam(options, result);
|
|
1751
|
+
if (currentPage > 0 && param == null) {
|
|
1752
|
+
break;
|
|
1753
|
+
}
|
|
1754
|
+
result = await fetchPage(result, param);
|
|
1755
|
+
currentPage++;
|
|
1756
|
+
} while (currentPage < remainingPages);
|
|
1757
|
+
}
|
|
1758
|
+
return result;
|
|
1759
|
+
};
|
|
1760
|
+
if (context.options.persister) {
|
|
1761
|
+
context.fetchFn = () => {
|
|
1762
|
+
return context.options.persister?.(fetchFn, {
|
|
1763
|
+
client: context.client,
|
|
1764
|
+
queryKey: context.queryKey,
|
|
1765
|
+
meta: context.options.meta,
|
|
1766
|
+
signal: context.signal
|
|
1767
|
+
}, query);
|
|
1768
|
+
};
|
|
1769
|
+
} else {
|
|
1770
|
+
context.fetchFn = fetchFn;
|
|
1771
|
+
}
|
|
1772
|
+
}
|
|
1773
|
+
};
|
|
1774
|
+
}
|
|
1775
|
+
function getNextPageParam(options, { pages, pageParams }) {
|
|
1776
|
+
const lastIndex = pages.length - 1;
|
|
1777
|
+
return pages.length > 0 ? options.getNextPageParam(pages[lastIndex], pages, pageParams[lastIndex], pageParams) : undefined;
|
|
1778
|
+
}
|
|
1779
|
+
function getPreviousPageParam(options, { pages, pageParams }) {
|
|
1780
|
+
return pages.length > 0 ? options.getPreviousPageParam?.(pages[0], pages, pageParams[0], pageParams) : undefined;
|
|
1781
|
+
}
|
|
1782
|
+
|
|
1783
|
+
// ../../node_modules/.bun/@tanstack+query-core@5.100.3/node_modules/@tanstack/query-core/build/modern/query.js
|
|
1667
1784
|
var Query = class extends Removable {
|
|
1785
|
+
#queryType;
|
|
1668
1786
|
#initialState;
|
|
1669
1787
|
#revertState;
|
|
1670
1788
|
#cache;
|
|
@@ -1689,11 +1807,17 @@ var Query = class extends Removable {
|
|
|
1689
1807
|
get meta() {
|
|
1690
1808
|
return this.options.meta;
|
|
1691
1809
|
}
|
|
1810
|
+
get queryType() {
|
|
1811
|
+
return this.#queryType;
|
|
1812
|
+
}
|
|
1692
1813
|
get promise() {
|
|
1693
1814
|
return this.#retryer?.promise;
|
|
1694
1815
|
}
|
|
1695
1816
|
setOptions(options) {
|
|
1696
1817
|
this.options = { ...this.#defaultOptions, ...options };
|
|
1818
|
+
if (options?._type) {
|
|
1819
|
+
this.#queryType = options._type;
|
|
1820
|
+
}
|
|
1697
1821
|
this.updateGcTime(this.options.gcTime);
|
|
1698
1822
|
if (this.state && this.state.data === undefined) {
|
|
1699
1823
|
const defaultState = getDefaultState(this.options);
|
|
@@ -1718,8 +1842,8 @@ var Query = class extends Removable {
|
|
|
1718
1842
|
});
|
|
1719
1843
|
return data;
|
|
1720
1844
|
}
|
|
1721
|
-
setState(state
|
|
1722
|
-
this.#dispatch({ type: "setState", state
|
|
1845
|
+
setState(state) {
|
|
1846
|
+
this.#dispatch({ type: "setState", state });
|
|
1723
1847
|
}
|
|
1724
1848
|
cancel(options) {
|
|
1725
1849
|
const promise = this.#retryer?.promise;
|
|
@@ -1738,7 +1862,7 @@ var Query = class extends Removable {
|
|
|
1738
1862
|
this.setState(this.resetState);
|
|
1739
1863
|
}
|
|
1740
1864
|
isActive() {
|
|
1741
|
-
return this.observers.some((observer) =>
|
|
1865
|
+
return this.observers.some((observer) => resolveQueryBoolean(observer.options.enabled, this) !== false);
|
|
1742
1866
|
}
|
|
1743
1867
|
isDisabled() {
|
|
1744
1868
|
if (this.getObserversCount() > 0) {
|
|
@@ -1881,7 +2005,8 @@ var Query = class extends Removable {
|
|
|
1881
2005
|
return context2;
|
|
1882
2006
|
};
|
|
1883
2007
|
const context = createFetchContext();
|
|
1884
|
-
this.options.
|
|
2008
|
+
const behavior = this.#queryType === "infinite" ? infiniteQueryBehavior(this.options.pages) : this.options.behavior;
|
|
2009
|
+
behavior?.onFetch(context, this);
|
|
1885
2010
|
this.#revertState = this.state;
|
|
1886
2011
|
if (this.state.fetchStatus === "idle" || this.state.fetchMeta !== context.fetchOptions?.meta) {
|
|
1887
2012
|
this.#dispatch({ type: "fetch", meta: context.fetchOptions?.meta });
|
|
@@ -2058,7 +2183,7 @@ function getDefaultState(options) {
|
|
|
2058
2183
|
};
|
|
2059
2184
|
}
|
|
2060
2185
|
|
|
2061
|
-
// ../../node_modules/.bun/@tanstack+query-core@5.
|
|
2186
|
+
// ../../node_modules/.bun/@tanstack+query-core@5.100.3/node_modules/@tanstack/query-core/build/modern/queryObserver.js
|
|
2062
2187
|
var QueryObserver = class extends Subscribable {
|
|
2063
2188
|
constructor(client, options) {
|
|
2064
2189
|
super();
|
|
@@ -2119,7 +2244,7 @@ var QueryObserver = class extends Subscribable {
|
|
|
2119
2244
|
const prevOptions = this.options;
|
|
2120
2245
|
const prevQuery = this.#currentQuery;
|
|
2121
2246
|
this.options = this.#client.defaultQueryOptions(options);
|
|
2122
|
-
if (this.options.enabled !== undefined && typeof this.options.enabled !== "boolean" && typeof this.options.enabled !== "function" && typeof
|
|
2247
|
+
if (this.options.enabled !== undefined && typeof this.options.enabled !== "boolean" && typeof this.options.enabled !== "function" && typeof resolveQueryBoolean(this.options.enabled, this.#currentQuery) !== "boolean") {
|
|
2123
2248
|
throw new Error("Expected enabled to be a boolean or a callback that returns a boolean");
|
|
2124
2249
|
}
|
|
2125
2250
|
this.#updateQuery();
|
|
@@ -2136,11 +2261,11 @@ var QueryObserver = class extends Subscribable {
|
|
|
2136
2261
|
this.#executeFetch();
|
|
2137
2262
|
}
|
|
2138
2263
|
this.updateResult();
|
|
2139
|
-
if (mounted && (this.#currentQuery !== prevQuery ||
|
|
2264
|
+
if (mounted && (this.#currentQuery !== prevQuery || resolveQueryBoolean(this.options.enabled, this.#currentQuery) !== resolveQueryBoolean(prevOptions.enabled, this.#currentQuery) || resolveStaleTime(this.options.staleTime, this.#currentQuery) !== resolveStaleTime(prevOptions.staleTime, this.#currentQuery))) {
|
|
2140
2265
|
this.#updateStaleTimeout();
|
|
2141
2266
|
}
|
|
2142
2267
|
const nextRefetchInterval = this.#computeRefetchInterval();
|
|
2143
|
-
if (mounted && (this.#currentQuery !== prevQuery ||
|
|
2268
|
+
if (mounted && (this.#currentQuery !== prevQuery || resolveQueryBoolean(this.options.enabled, this.#currentQuery) !== resolveQueryBoolean(prevOptions.enabled, this.#currentQuery) || nextRefetchInterval !== this.#currentRefetchInterval)) {
|
|
2144
2269
|
this.#updateRefetchInterval(nextRefetchInterval);
|
|
2145
2270
|
}
|
|
2146
2271
|
}
|
|
@@ -2225,7 +2350,7 @@ var QueryObserver = class extends Subscribable {
|
|
|
2225
2350
|
#updateRefetchInterval(nextInterval) {
|
|
2226
2351
|
this.#clearRefetchInterval();
|
|
2227
2352
|
this.#currentRefetchInterval = nextInterval;
|
|
2228
|
-
if (environmentManager.isServer() ||
|
|
2353
|
+
if (environmentManager.isServer() || resolveQueryBoolean(this.options.enabled, this.#currentQuery) === false || !isValidTimeout(this.#currentRefetchInterval) || this.#currentRefetchInterval === 0) {
|
|
2229
2354
|
return;
|
|
2230
2355
|
}
|
|
2231
2356
|
this.#refetchIntervalId = timeoutManager.setInterval(() => {
|
|
@@ -2345,7 +2470,7 @@ var QueryObserver = class extends Subscribable {
|
|
|
2345
2470
|
isStale: isStale(query, options),
|
|
2346
2471
|
refetch: this.refetch,
|
|
2347
2472
|
promise: this.#currentThenable,
|
|
2348
|
-
isEnabled:
|
|
2473
|
+
isEnabled: resolveQueryBoolean(options.enabled, query) !== false
|
|
2349
2474
|
};
|
|
2350
2475
|
const nextResult = result;
|
|
2351
2476
|
if (this.options.experimental_prefetchInRender) {
|
|
@@ -2450,23 +2575,23 @@ var QueryObserver = class extends Subscribable {
|
|
|
2450
2575
|
}
|
|
2451
2576
|
};
|
|
2452
2577
|
function shouldLoadOnMount(query, options) {
|
|
2453
|
-
return
|
|
2578
|
+
return resolveQueryBoolean(options.enabled, query) !== false && query.state.data === undefined && !(query.state.status === "error" && resolveQueryBoolean(options.retryOnMount, query) === false);
|
|
2454
2579
|
}
|
|
2455
2580
|
function shouldFetchOnMount(query, options) {
|
|
2456
2581
|
return shouldLoadOnMount(query, options) || query.state.data !== undefined && shouldFetchOn(query, options, options.refetchOnMount);
|
|
2457
2582
|
}
|
|
2458
2583
|
function shouldFetchOn(query, options, field) {
|
|
2459
|
-
if (
|
|
2584
|
+
if (resolveQueryBoolean(options.enabled, query) !== false && resolveStaleTime(options.staleTime, query) !== "static") {
|
|
2460
2585
|
const value = typeof field === "function" ? field(query) : field;
|
|
2461
2586
|
return value === "always" || value !== false && isStale(query, options);
|
|
2462
2587
|
}
|
|
2463
2588
|
return false;
|
|
2464
2589
|
}
|
|
2465
2590
|
function shouldFetchOptionally(query, prevQuery, options, prevOptions) {
|
|
2466
|
-
return (query !== prevQuery ||
|
|
2591
|
+
return (query !== prevQuery || resolveQueryBoolean(prevOptions.enabled, query) === false) && (!options.suspense || query.state.status !== "error") && isStale(query, options);
|
|
2467
2592
|
}
|
|
2468
2593
|
function isStale(query, options) {
|
|
2469
|
-
return
|
|
2594
|
+
return resolveQueryBoolean(options.enabled, query) !== false && query.isStaleByTime(resolveStaleTime(options.staleTime, query));
|
|
2470
2595
|
}
|
|
2471
2596
|
function shouldAssignObserverCurrentProperties(observer, optimisticResult) {
|
|
2472
2597
|
if (!shallowEqualObjects(observer.getCurrentResult(), optimisticResult)) {
|
|
@@ -2475,7 +2600,7 @@ function shouldAssignObserverCurrentProperties(observer, optimisticResult) {
|
|
|
2475
2600
|
return false;
|
|
2476
2601
|
}
|
|
2477
2602
|
|
|
2478
|
-
// ../../node_modules/.bun/@tanstack+query-core@5.
|
|
2603
|
+
// ../../node_modules/.bun/@tanstack+query-core@5.100.3/node_modules/@tanstack/query-core/build/modern/mutation.js
|
|
2479
2604
|
var Mutation = class extends Removable {
|
|
2480
2605
|
#client;
|
|
2481
2606
|
#observers;
|
|
@@ -2693,7 +2818,7 @@ function getDefaultState2() {
|
|
|
2693
2818
|
};
|
|
2694
2819
|
}
|
|
2695
2820
|
|
|
2696
|
-
// ../../node_modules/.bun/@tanstack+query-core@5.
|
|
2821
|
+
// ../../node_modules/.bun/@tanstack+query-core@5.100.3/node_modules/@tanstack/query-core/build/modern/mutationObserver.js
|
|
2697
2822
|
var MutationObserver = class extends Subscribable {
|
|
2698
2823
|
#client;
|
|
2699
2824
|
#currentResult = undefined;
|
|
@@ -2803,10 +2928,10 @@ var MutationObserver = class extends Subscribable {
|
|
|
2803
2928
|
});
|
|
2804
2929
|
}
|
|
2805
2930
|
};
|
|
2806
|
-
// ../../node_modules/.bun/@tanstack+react-query@5.
|
|
2931
|
+
// ../../node_modules/.bun/@tanstack+react-query@5.100.3+3f10a4be4e334a9b/node_modules/@tanstack/react-query/build/modern/useBaseQuery.js
|
|
2807
2932
|
var React5 = __toESM(require_react(), 1);
|
|
2808
2933
|
|
|
2809
|
-
// ../../node_modules/.bun/@tanstack+react-query@5.
|
|
2934
|
+
// ../../node_modules/.bun/@tanstack+react-query@5.100.3+3f10a4be4e334a9b/node_modules/@tanstack/react-query/build/modern/QueryClientProvider.js
|
|
2810
2935
|
var React = __toESM(require_react(), 1);
|
|
2811
2936
|
var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
|
|
2812
2937
|
"use client";
|
|
@@ -2822,7 +2947,7 @@ var useQueryClient = (queryClient) => {
|
|
|
2822
2947
|
return client;
|
|
2823
2948
|
};
|
|
2824
2949
|
|
|
2825
|
-
// ../../node_modules/.bun/@tanstack+react-query@5.
|
|
2950
|
+
// ../../node_modules/.bun/@tanstack+react-query@5.100.3+3f10a4be4e334a9b/node_modules/@tanstack/react-query/build/modern/QueryErrorResetBoundary.js
|
|
2826
2951
|
var React2 = __toESM(require_react(), 1);
|
|
2827
2952
|
var import_jsx_runtime2 = __toESM(require_jsx_runtime(), 1);
|
|
2828
2953
|
"use client";
|
|
@@ -2843,7 +2968,7 @@ function createValue() {
|
|
|
2843
2968
|
var QueryErrorResetBoundaryContext = React2.createContext(createValue());
|
|
2844
2969
|
var useQueryErrorResetBoundary = () => React2.useContext(QueryErrorResetBoundaryContext);
|
|
2845
2970
|
|
|
2846
|
-
// ../../node_modules/.bun/@tanstack+react-query@5.
|
|
2971
|
+
// ../../node_modules/.bun/@tanstack+react-query@5.100.3+3f10a4be4e334a9b/node_modules/@tanstack/react-query/build/modern/errorBoundaryUtils.js
|
|
2847
2972
|
var React3 = __toESM(require_react(), 1);
|
|
2848
2973
|
"use client";
|
|
2849
2974
|
var ensurePreventErrorBoundaryRetry = (options, errorResetBoundary, query) => {
|
|
@@ -2869,14 +2994,14 @@ var getHasError = ({
|
|
|
2869
2994
|
return result.isError && !errorResetBoundary.isReset() && !result.isFetching && query && (suspense && result.data === undefined || shouldThrowError(throwOnError, [result.error, query]));
|
|
2870
2995
|
};
|
|
2871
2996
|
|
|
2872
|
-
// ../../node_modules/.bun/@tanstack+react-query@5.
|
|
2997
|
+
// ../../node_modules/.bun/@tanstack+react-query@5.100.3+3f10a4be4e334a9b/node_modules/@tanstack/react-query/build/modern/IsRestoringProvider.js
|
|
2873
2998
|
var React4 = __toESM(require_react(), 1);
|
|
2874
2999
|
"use client";
|
|
2875
3000
|
var IsRestoringContext = React4.createContext(false);
|
|
2876
3001
|
var useIsRestoring = () => React4.useContext(IsRestoringContext);
|
|
2877
3002
|
var IsRestoringProvider = IsRestoringContext.Provider;
|
|
2878
3003
|
|
|
2879
|
-
// ../../node_modules/.bun/@tanstack+react-query@5.
|
|
3004
|
+
// ../../node_modules/.bun/@tanstack+react-query@5.100.3+3f10a4be4e334a9b/node_modules/@tanstack/react-query/build/modern/suspense.js
|
|
2880
3005
|
var ensureSuspenseTimers = (defaultedOptions) => {
|
|
2881
3006
|
if (defaultedOptions.suspense) {
|
|
2882
3007
|
const MIN_SUSPENSE_TIME_MS = 1000;
|
|
@@ -2894,7 +3019,7 @@ var fetchOptimistic = (defaultedOptions, observer, errorResetBoundary) => observ
|
|
|
2894
3019
|
errorResetBoundary.clearReset();
|
|
2895
3020
|
});
|
|
2896
3021
|
|
|
2897
|
-
// ../../node_modules/.bun/@tanstack+react-query@5.
|
|
3022
|
+
// ../../node_modules/.bun/@tanstack+react-query@5.100.3+3f10a4be4e334a9b/node_modules/@tanstack/react-query/build/modern/useBaseQuery.js
|
|
2898
3023
|
"use client";
|
|
2899
3024
|
function useBaseQuery(options, Observer, queryClient) {
|
|
2900
3025
|
if (true) {
|
|
@@ -2951,12 +3076,12 @@ function useBaseQuery(options, Observer, queryClient) {
|
|
|
2951
3076
|
return !defaultedOptions.notifyOnChangeProps ? observer.trackResult(result) : result;
|
|
2952
3077
|
}
|
|
2953
3078
|
|
|
2954
|
-
// ../../node_modules/.bun/@tanstack+react-query@5.
|
|
3079
|
+
// ../../node_modules/.bun/@tanstack+react-query@5.100.3+3f10a4be4e334a9b/node_modules/@tanstack/react-query/build/modern/useQuery.js
|
|
2955
3080
|
"use client";
|
|
2956
3081
|
function useQuery(options, queryClient) {
|
|
2957
3082
|
return useBaseQuery(options, QueryObserver, queryClient);
|
|
2958
3083
|
}
|
|
2959
|
-
// ../../node_modules/.bun/@tanstack+react-query@5.
|
|
3084
|
+
// ../../node_modules/.bun/@tanstack+react-query@5.100.3+3f10a4be4e334a9b/node_modules/@tanstack/react-query/build/modern/useMutation.js
|
|
2960
3085
|
var React6 = __toESM(require_react(), 1);
|
|
2961
3086
|
"use client";
|
|
2962
3087
|
function useMutation(options, queryClient) {
|
|
@@ -2975,25 +3100,25 @@ function useMutation(options, queryClient) {
|
|
|
2975
3100
|
return { ...result, mutate, mutateAsync: result.mutate };
|
|
2976
3101
|
}
|
|
2977
3102
|
// src/react-query/index.ts
|
|
2978
|
-
function niceActionQueryKey(action, input) {
|
|
3103
|
+
function niceActionQueryKey(action, input, meta) {
|
|
2979
3104
|
if (input === undefined) {
|
|
2980
3105
|
return ["nice-action", action.domain, action.allDomains, action.id];
|
|
2981
3106
|
}
|
|
2982
|
-
return ["nice-action", action.domain, action.allDomains, action.id, input];
|
|
3107
|
+
return ["nice-action", action.domain, action.allDomains, action.id, input, meta?.tag];
|
|
2983
3108
|
}
|
|
2984
3109
|
function useNiceQuery(action, input, options) {
|
|
2985
|
-
const {
|
|
3110
|
+
const { tag, meta, enabled, ...queryOptions2 } = options ?? {};
|
|
2986
3111
|
return useQuery({
|
|
2987
|
-
queryKey:
|
|
2988
|
-
queryFn: () => action.execute(input,
|
|
3112
|
+
queryKey: input != null ? niceActionQueryKey(action, input, { tag, meta }) : niceActionQueryKey(action),
|
|
3113
|
+
queryFn: () => action.execute(input, { tag, meta }),
|
|
2989
3114
|
enabled: input != null && (enabled ?? true),
|
|
2990
3115
|
...queryOptions2
|
|
2991
3116
|
});
|
|
2992
3117
|
}
|
|
2993
3118
|
function useNiceMutation(action, options) {
|
|
2994
|
-
const {
|
|
3119
|
+
const { tag, meta, ...mutationOptions2 } = options ?? {};
|
|
2995
3120
|
return useMutation({
|
|
2996
|
-
mutationFn: (input) => action.execute(input,
|
|
3121
|
+
mutationFn: (input) => action.execute(input, { tag, meta }),
|
|
2997
3122
|
...mutationOptions2
|
|
2998
3123
|
});
|
|
2999
3124
|
}
|
|
@@ -1,33 +1,27 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import type {
|
|
1
|
+
import type { IActionHandlerInputs } from "../ActionRuntimeEnvironment/ActionHandler/ActionHandler.types";
|
|
2
|
+
import type { IRuntimeEnvironmentMeta } from "../ActionRuntimeEnvironment/ActionRuntimeEnvironment.types";
|
|
3
3
|
import { NiceAction } from "../NiceAction/NiceAction";
|
|
4
|
-
import { type INiceAction_JsonObject, type INiceActionPrimed_JsonObject, type TNiceActionResponse_JsonObject } from "../NiceAction/NiceAction.types";
|
|
4
|
+
import { type INiceAction, type INiceAction_JsonObject, type INiceActionPrimed_JsonObject, type TNiceActionResponse_JsonObject } from "../NiceAction/NiceAction.types";
|
|
5
|
+
import type { TDistributedDomainActions } from "../NiceAction/NiceActionCombined.types";
|
|
5
6
|
import { NiceActionPrimed } from "../NiceAction/NiceActionPrimed";
|
|
6
7
|
import { NiceActionResponse } from "../NiceAction/NiceActionResponse";
|
|
7
|
-
import type { INiceActionDomain, INiceActionDomainChildOptions,
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
import type { INiceActionDomain, INiceActionDomainChildOptions, TInferInputFromSchema, TNiceActionDomainChildDef } from "./NiceActionDomain.types";
|
|
9
|
+
import { NiceActionDomainBase } from "./NiceActionDomainBase";
|
|
10
|
+
import { type NiceActionRootDomain } from "./RootDomain/NiceActionRootDomain";
|
|
11
|
+
export declare class NiceActionDomain<ACT_DOM extends INiceActionDomain = INiceActionDomain> extends NiceActionDomainBase<ACT_DOM> {
|
|
12
|
+
private _rootDomain;
|
|
13
|
+
constructor(definition: ACT_DOM, { rootDomain, }: {
|
|
14
|
+
rootDomain: NiceActionRootDomain;
|
|
15
|
+
});
|
|
16
|
+
get rootDomain(): NiceActionRootDomain<import("./NiceActionDomain.types").INiceActionRootDomain<string>>;
|
|
17
|
+
getEnvironmentMeta(): IRuntimeEnvironmentMeta;
|
|
16
18
|
createChildDomain<SUB_DOM extends INiceActionDomainChildOptions>(subDomainDef: SUB_DOM & {
|
|
17
19
|
[K in Exclude<keyof SUB_DOM, keyof INiceActionDomainChildOptions>]: never;
|
|
18
20
|
}): NiceActionDomain<TNiceActionDomainChildDef<ACT_DOM, SUB_DOM>>;
|
|
19
|
-
primeUnknown(actionId: ACT_DOM["
|
|
21
|
+
primeUnknown(actionId: keyof ACT_DOM["actions"] & string, input: unknown): NiceActionPrimed<ACT_DOM, string, ACT_DOM["actions"][string]>;
|
|
20
22
|
primeAction<ID extends keyof ACT_DOM["actions"] & string>(id: ID, input: TInferInputFromSchema<ACT_DOM["actions"][ID]>["Input"]): NiceActionPrimed<ACT_DOM, ID, ACT_DOM["actions"][ID]>;
|
|
21
23
|
action<ID extends keyof ACT_DOM["actions"] & string>(id: ID, hydrationData?: Pick<INiceAction_JsonObject<ACT_DOM, ID>, "cuid" | "timeCreated">): NiceAction<ACT_DOM, ID, ACT_DOM["actions"][ID]>;
|
|
22
|
-
|
|
23
|
-
matchAction<ID extends keyof ACT_DOM["actions"] & string>(action: unknown, id: ID): NiceActionPrimed<ACT_DOM, ID, ACT_DOM["actions"][ID]> | null;
|
|
24
|
-
/**
|
|
25
|
-
* Add an observer that is called after every action dispatched through this domain.
|
|
26
|
-
* Returns an unsubscribe function — call it to remove the listener.
|
|
27
|
-
*/
|
|
28
|
-
addActionListener(listener: TActionListener): () => void;
|
|
29
|
-
_dispatchAction<P extends NiceActionPrimed<ACT_DOM, string, ACT_DOM["actions"][string]>>(primed: P, envId?: string): Promise<unknown>;
|
|
30
|
-
private _withValidatedInput;
|
|
24
|
+
isDomainAction<ACT extends INiceAction<any>>(action: ACT | unknown | null | undefined): action is TDistributedDomainActions<ACT, ACT_DOM>;
|
|
31
25
|
/**
|
|
32
26
|
* Reconstruct a NiceActionPrimed from its serialized wire format.
|
|
33
27
|
* Runs the schema's deserializeInput if a custom serialization was defined.
|
|
@@ -40,29 +34,7 @@ export declare class NiceActionDomain<ACT_DOM extends INiceActionDomain = INiceA
|
|
|
40
34
|
*/
|
|
41
35
|
hydrateResponse<R extends TNiceActionResponse_JsonObject>(serialized: R): NiceActionResponse<ACT_DOM, keyof ACT_DOM["actions"] & string, ACT_DOM["actions"][R["id"] & keyof ACT_DOM["actions"]]>;
|
|
42
36
|
/**
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* Pass `options.envId` to register under a named environment — useful when multiple
|
|
46
|
-
* execution environments (e.g. worker, main thread) share the same domain definition.
|
|
47
|
-
* Named requesters are targeted by passing the same `envId` to `action.execute(input, envId)`.
|
|
48
|
-
*
|
|
49
|
-
* Omit `options` (or pass `undefined`) to register the default requester.
|
|
50
|
-
* Pass an existing `NiceActionRequester` as `handler` to reuse a shared instance.
|
|
51
|
-
* Throws `environment_already_registered` / `domain_action_requester_conflict` if already taken.
|
|
52
|
-
*/
|
|
53
|
-
setActionRequester(options?: {
|
|
54
|
-
envId?: string;
|
|
55
|
-
}, handler?: NiceActionRequester): NiceActionRequester;
|
|
56
|
-
/**
|
|
57
|
-
* Register a resolver as the fallback execution path for this domain.
|
|
58
|
-
*
|
|
59
|
-
* When no handler is set (or no envId-matching handler), the domain falls back to the
|
|
60
|
-
* resolver — calling `_resolvePrimed` directly, without re-serializing the input.
|
|
61
|
-
*
|
|
62
|
-
* Pass `options.envId` to register under a named environment.
|
|
63
|
-
* Throws `environment_already_registered` if the envId (or default) is already taken.
|
|
37
|
+
* Delegates dispatch to the root domain. All handler/environment routing lives there.
|
|
64
38
|
*/
|
|
65
|
-
|
|
66
|
-
envId?: string;
|
|
67
|
-
}): this;
|
|
39
|
+
_executeAction<P extends NiceActionPrimed<any, any, any>>(primed: P, { actionMeta, listeners, }: IActionHandlerInputs<P extends NiceActionPrimed<infer DOM, any, any> ? DOM : never>): Promise<unknown>;
|
|
68
40
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import type { NiceActionSchema } from "../ActionSchema/NiceActionSchema";
|
|
2
2
|
import type { INiceActionErrorDeclaration, TTransportedValue } from "../ActionSchema/NiceActionSchema.types";
|
|
3
|
-
import type { NiceActionPrimed } from "../NiceAction/NiceActionPrimed";
|
|
4
3
|
export type MaybePromise<T> = T | Promise<T>;
|
|
5
4
|
export type TPossibleDomainId = string;
|
|
6
5
|
export type TPossibleDomainIdList = [TPossibleDomainId, ...TPossibleDomainId[]];
|
|
@@ -10,17 +9,15 @@ export type TNiceActionDomainSchema = Record<string, NiceActionSchema<TTransport
|
|
|
10
9
|
* Does NOT include class methods.
|
|
11
10
|
*/
|
|
12
11
|
export interface INiceActionDomain<IDS extends TPossibleDomainIdList = TPossibleDomainIdList, SCH extends TNiceActionDomainSchema = TNiceActionDomainSchema> {
|
|
13
|
-
domain: IDS[0];
|
|
12
|
+
domain: IDS[0] & string;
|
|
14
13
|
allDomains: IDS;
|
|
15
14
|
actions: SCH;
|
|
16
15
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
* without re-serializing/deserializing. Errors from the fn propagate naturally.
|
|
23
|
-
*/
|
|
16
|
+
export interface INiceActionRootDomain<ID extends TPossibleDomainId = TPossibleDomainId> extends INiceActionDomain<[ID], {}> {
|
|
17
|
+
domain: ID;
|
|
18
|
+
allDomains: [ID];
|
|
19
|
+
actions: {};
|
|
20
|
+
}
|
|
24
21
|
export interface INiceActionDomainChildOptions<ERR_DOMAIN extends string = string, SCHEMA extends TNiceActionDomainSchema = TNiceActionDomainSchema> {
|
|
25
22
|
domain: ERR_DOMAIN;
|
|
26
23
|
actions: SCHEMA;
|
|
@@ -30,45 +27,12 @@ export type TNiceActionDomainChildDef<PARENT_DEF extends INiceActionDomain, SUB
|
|
|
30
27
|
allDomains: [SUB["domain"], ...PARENT_DEF["allDomains"]];
|
|
31
28
|
actions: SUB["actions"];
|
|
32
29
|
};
|
|
33
|
-
export type
|
|
30
|
+
export type TDomainActionId<DOM extends INiceActionDomain> = keyof DOM["actions"] & string;
|
|
31
|
+
export type TInferInputFromSchema<SCH extends NiceActionSchema<any, any, any>> = SCH extends NiceActionSchema<infer IN, any, any> ? {
|
|
34
32
|
Input: IN[0];
|
|
35
33
|
SerdeInput: IN[1];
|
|
36
34
|
} : never;
|
|
37
|
-
export type TInferOutputFromSchema<SCH
|
|
35
|
+
export type TInferOutputFromSchema<SCH extends NiceActionSchema<any, any, any>> = SCH extends NiceActionSchema<any, infer OUT, any> ? {
|
|
38
36
|
Output: OUT[0];
|
|
39
37
|
SerdeOutput: OUT[1];
|
|
40
38
|
} : never;
|
|
41
|
-
/**
|
|
42
|
-
* Handler registered via forDomain.
|
|
43
|
-
*
|
|
44
|
-
* `act.input` is typed as the union of input types for every action in `ACT_DOM`,
|
|
45
|
-
* and `act.coreAction` carries the matching schema — the same narrowing you get
|
|
46
|
-
* from `forActionIds` over all action IDs in the domain.
|
|
47
|
-
*/
|
|
48
|
-
export type TActionHandlerForDomain<ACT_DOM extends INiceActionDomain> = (action: NiceActionPrimed<ACT_DOM, keyof ACT_DOM["actions"] & string, ACT_DOM["actions"][keyof ACT_DOM["actions"] & string]>) => MaybePromise<unknown>;
|
|
49
|
-
/**
|
|
50
|
-
* Handler registered via forActionId — receives a specific action ID, with
|
|
51
|
-
* the primed action's input narrowed to that ID's schema.
|
|
52
|
-
*/
|
|
53
|
-
export type TActionIdHandlerForDomain<ACT_DOM extends INiceActionDomain, ID extends keyof ACT_DOM["actions"] & string> = (action: NiceActionPrimed<ACT_DOM, ID, ACT_DOM["actions"][ID]>) => MaybePromise<unknown>;
|
|
54
|
-
/**
|
|
55
|
-
* Observer called after each action is dispatched.
|
|
56
|
-
* Return value is ignored. Use for logging, metrics, tracing, etc.
|
|
57
|
-
*/
|
|
58
|
-
export type TActionListener = (action: NiceActionPrimed<any, any, any>) => MaybePromise<void>;
|
|
59
|
-
/**
|
|
60
|
-
* Broad handler signature used internally for storage and dispatch.
|
|
61
|
-
* Public-facing registration methods use narrower types (`TActionHandlerForDomain`,
|
|
62
|
-
* `TActionIdHandlerForDomain`); they are cast to this for storage.
|
|
63
|
-
*/
|
|
64
|
-
export type TBroadActionRequester<P extends NiceActionPrimed<any, any, any>> = (action: P) => MaybePromise<unknown>;
|
|
65
|
-
/**
|
|
66
|
-
* A single case in a `NiceActionRequester`.
|
|
67
|
-
*
|
|
68
|
-
* Construct via `forDomain` / `forActionId` / `forActionIds` — do not build directly.
|
|
69
|
-
*/
|
|
70
|
-
export interface IActionCase<P extends NiceActionPrimed<any, any, any> = NiceActionPrimed<any, any, any>> {
|
|
71
|
-
readonly _matcher: (action: P) => boolean;
|
|
72
|
-
readonly _requester: TBroadActionRequester<P>;
|
|
73
|
-
}
|
|
74
|
-
export type TDomainActionId<DOM extends INiceActionDomain> = keyof DOM["actions"] & string;
|