@nice-code/action 0.8.0 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. package/build/ActionDevtoolsCore-B4s6aGvI.d.ts +79 -0
  2. package/build/ActionDevtoolsCore-BLeY_N-3.js +159 -0
  3. package/build/ActionDevtoolsCore-BLeY_N-3.js.map +1 -0
  4. package/build/ActionDevtoolsCore-Pg7ERO3L.d.ts +79 -0
  5. package/build/ActionDevtoolsCore-yfJ9tkvl.js +154 -0
  6. package/build/ActionDevtoolsCore-yfJ9tkvl.js.map +1 -0
  7. package/build/ActionPayload.types-BN-rXFBK.d.ts +2328 -0
  8. package/build/ActionPayload.types-D28ELKXC.d.ts +2328 -0
  9. package/build/RunningAction.types-C176rqHG.js +22 -0
  10. package/build/RunningAction.types-C176rqHG.js.map +1 -0
  11. package/build/RunningAction.types-DjCX1xp5.js +39 -0
  12. package/build/RunningAction.types-DjCX1xp5.js.map +1 -0
  13. package/build/devtools/browser/index.d.ts +17 -0
  14. package/build/devtools/browser/index.js +3762 -5145
  15. package/build/devtools/browser/index.js.map +1 -0
  16. package/build/devtools/server/index.d.ts +35 -0
  17. package/build/devtools/server/index.js +97 -261
  18. package/build/devtools/server/index.js.map +1 -0
  19. package/build/index.d.ts +2 -0
  20. package/build/index.js +3872 -3870
  21. package/build/index.js.map +1 -0
  22. package/build/react-query/index.d.ts +17 -0
  23. package/build/react-query/index.js +60 -60
  24. package/build/react-query/index.js.map +1 -0
  25. package/package.json +11 -10
  26. package/build/types/ActionDefinition/Action/Action.combined.types.d.ts +0 -37
  27. package/build/types/ActionDefinition/Action/ActionBase.d.ts +0 -14
  28. package/build/types/ActionDefinition/Action/ActionBase.types.d.ts +0 -24
  29. package/build/types/ActionDefinition/Action/Context/ActionContext.d.ts +0 -25
  30. package/build/types/ActionDefinition/Action/Context/ActionContext.types.d.ts +0 -35
  31. package/build/types/ActionDefinition/Action/Core/ActionCore.d.ts +0 -19
  32. package/build/types/ActionDefinition/Action/Core/ActionCore.types.d.ts +0 -10
  33. package/build/types/ActionDefinition/Action/Payload/ActionPayload.d.ts +0 -14
  34. package/build/types/ActionDefinition/Action/Payload/ActionPayload.types.d.ts +0 -110
  35. package/build/types/ActionDefinition/Action/Payload/ActionPayload_Progress.d.ts +0 -15
  36. package/build/types/ActionDefinition/Action/Payload/ActionPayload_Request.d.ts +0 -26
  37. package/build/types/ActionDefinition/Action/Payload/ActionPayload_Result.d.ts +0 -19
  38. package/build/types/ActionDefinition/Action/RunningAction.d.ts +0 -36
  39. package/build/types/ActionDefinition/Action/RunningAction.types.d.ts +0 -73
  40. package/build/types/ActionDefinition/Domain/ActionDomain.d.ts +0 -42
  41. package/build/types/ActionDefinition/Domain/ActionDomain.types.d.ts +0 -43
  42. package/build/types/ActionDefinition/Domain/ActionDomainBase.d.ts +0 -14
  43. package/build/types/ActionDefinition/Domain/ActionRootDomain.d.ts +0 -24
  44. package/build/types/ActionDefinition/Domain/helpers/createRootActionDomain.d.ts +0 -5
  45. package/build/types/ActionDefinition/Schema/ActionSchema.d.ts +0 -68
  46. package/build/types/ActionDefinition/Schema/ActionSchema.types.d.ts +0 -28
  47. package/build/types/ActionRuntime/ActionDomainManager.d.ts +0 -13
  48. package/build/types/ActionRuntime/ActionRuntime.d.ts +0 -78
  49. package/build/types/ActionRuntime/ActionRuntime.types.d.ts +0 -22
  50. package/build/types/ActionRuntime/ActionRuntimeManager.d.ts +0 -20
  51. package/build/types/ActionRuntime/Handler/ActionHandler.d.ts +0 -16
  52. package/build/types/ActionRuntime/Handler/ActionHandler.types.d.ts +0 -65
  53. package/build/types/ActionRuntime/Handler/ExternalClient/ActionExternalClientHandler.d.ts +0 -45
  54. package/build/types/ActionRuntime/Handler/ExternalClient/ActionExternalClientHandler.types.d.ts +0 -7
  55. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/ConnectionTransportManager.d.ts +0 -16
  56. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/Custom/CustomConnection.d.ts +0 -7
  57. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/Custom/CustomTransport.d.ts +0 -43
  58. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/Custom/TransportCustom.types.d.ts +0 -11
  59. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/Http/HttpConnection.d.ts +0 -8
  60. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/Http/HttpTransport.d.ts +0 -26
  61. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/Http/TransportHttp.types.d.ts +0 -16
  62. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/Transport.d.ts +0 -27
  63. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/Transport.types.d.ts +0 -131
  64. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/TransportConnection.d.ts +0 -27
  65. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/TransportWebSocket.types.d.ts +0 -41
  66. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/WebSocketConnection.d.ts +0 -34
  67. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/WebSocketTransport.d.ts +0 -60
  68. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/actionFrameCrypto.d.ts +0 -31
  69. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/actionWireCodec.d.ts +0 -41
  70. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/actionWsHandshake.d.ts +0 -187
  71. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/createBinaryWsAdapter.d.ts +0 -20
  72. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/createBinaryWsSessionFactory.d.ts +0 -31
  73. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/secureWsChannel.d.ts +0 -63
  74. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/WebSocket/ws_util.d.ts +0 -11
  75. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/err_nice_transport.d.ts +0 -36
  76. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/err_nice_transport_ws.d.ts +0 -18
  77. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/helpers/addTransportStatusMetadata.d.ts +0 -2
  78. package/build/types/ActionRuntime/Handler/ExternalClient/Transport/helpers/createUnsetTransportResolvers.d.ts +0 -2
  79. package/build/types/ActionRuntime/Handler/ExternalClient/err_nice_external_client.d.ts +0 -5
  80. package/build/types/ActionRuntime/Handler/Local/ActionLocalHandler.d.ts +0 -55
  81. package/build/types/ActionRuntime/Handler/Local/ActionLocalHandler.types.d.ts +0 -7
  82. package/build/types/ActionRuntime/Handler/Server/ActionServerHandler.d.ts +0 -254
  83. package/build/types/ActionRuntime/Handler/Server/WsConnectionStateStore.d.ts +0 -61
  84. package/build/types/ActionRuntime/Handler/Server/createActionFetchHandler.d.ts +0 -40
  85. package/build/types/ActionRuntime/Handler/Server/createSecureActionServer.d.ts +0 -71
  86. package/build/types/ActionRuntime/HandlerCallStack.d.ts +0 -3
  87. package/build/types/ActionRuntime/Routing/ActionRouter.d.ts +0 -55
  88. package/build/types/ActionRuntime/Routing/ActionRouter.types.d.ts +0 -20
  89. package/build/types/ActionRuntime/RuntimeCoordinate.d.ts +0 -58
  90. package/build/types/ActionRuntime/test/helpers/new_action_test_data.d.ts +0 -207
  91. package/build/types/ActionRuntime/utils/runtimeCoordinateToStringIds.d.ts +0 -2
  92. package/build/types/devtools/browser/NiceActionDevtools.d.ts +0 -14
  93. package/build/types/devtools/browser/components/ActionErrorDisplay.d.ts +0 -5
  94. package/build/types/devtools/browser/components/CallStackSection.d.ts +0 -8
  95. package/build/types/devtools/browser/components/ChildDispatchChips.d.ts +0 -6
  96. package/build/types/devtools/browser/components/Chip.d.ts +0 -22
  97. package/build/types/devtools/browser/components/DetailSection.d.ts +0 -5
  98. package/build/types/devtools/browser/components/DomainChip.d.ts +0 -8
  99. package/build/types/devtools/browser/components/HandlerChips.d.ts +0 -21
  100. package/build/types/devtools/browser/components/Icon.d.ts +0 -16
  101. package/build/types/devtools/browser/components/MetaSection.d.ts +0 -4
  102. package/build/types/devtools/browser/components/NiceErrorDisplay.d.ts +0 -19
  103. package/build/types/devtools/browser/components/OriginChip.d.ts +0 -15
  104. package/build/types/devtools/browser/components/RoutingSection.d.ts +0 -5
  105. package/build/types/devtools/browser/components/RunningTimer.d.ts +0 -7
  106. package/build/types/devtools/browser/components/SectionLabel.d.ts +0 -1
  107. package/build/types/devtools/browser/components/StackTraceSection.d.ts +0 -9
  108. package/build/types/devtools/browser/components/Tooltip.d.ts +0 -1
  109. package/build/types/devtools/browser/components/action_detail/ActionDetailPanel.d.ts +0 -7
  110. package/build/types/devtools/browser/components/action_list/ActionEntryRow.d.ts +0 -14
  111. package/build/types/devtools/browser/components/action_list/ActionInputAndOutputChip.d.ts +0 -11
  112. package/build/types/devtools/browser/components/action_list/ActionList.d.ts +0 -10
  113. package/build/types/devtools/browser/components/action_list/IoTooltipContent.d.ts +0 -3
  114. package/build/types/devtools/browser/components/action_list/action_list.types.d.ts +0 -4
  115. package/build/types/devtools/browser/components/sourceMapResolver.d.ts +0 -6
  116. package/build/types/devtools/browser/components/utils.d.ts +0 -20
  117. package/build/types/devtools/browser/devtools_storage.d.ts +0 -6
  118. package/build/types/devtools/browser/index.d.ts +0 -3
  119. package/build/types/devtools/browser/ui_util/size.d.ts +0 -6
  120. package/build/types/devtools/core/ActionDevtools.types.d.ts +0 -55
  121. package/build/types/devtools/core/ActionDevtoolsCore.d.ts +0 -17
  122. package/build/types/devtools/core/devtools_colors.d.ts +0 -38
  123. package/build/types/devtools/server/NiceActionServerDevtools.d.ts +0 -30
  124. package/build/types/devtools/server/index.d.ts +0 -3
  125. package/build/types/errors/err_nice_action.d.ts +0 -96
  126. package/build/types/index.d.ts +0 -43
  127. package/build/types/nice_action.static.d.ts +0 -3
  128. package/build/types/react-query/hooks/useActionMutation.d.ts +0 -10
  129. package/build/types/react-query/hooks/useActionQuery.d.ts +0 -17
  130. package/build/types/react-query/index.d.ts +0 -2
  131. package/build/types/utils/assertIsActionJson.d.ts +0 -2
  132. package/build/types/utils/decodeActionFrame.d.ts +0 -17
  133. package/build/types/utils/getAssumedRuntimeEnvironment.d.ts +0 -2
  134. package/build/types/utils/hashPayloadData.d.ts +0 -5
  135. package/build/types/utils/isActionPayload_Any_JsonObject.d.ts +0 -2
  136. package/build/types/utils/isActionPayload_Progress_JsonObject.d.ts +0 -2
  137. package/build/types/utils/isActionPayload_Request_JsonObject.d.ts +0 -2
  138. package/build/types/utils/isActionPayload_Result_JsonObject.d.ts +0 -2
  139. package/build/types/utils/isAction_Any_Instance.d.ts +0 -3
  140. package/build/types/utils/isAction_Any_JsonObject.d.ts +0 -2
  141. package/build/types/utils/isAction_Base_JsonObject.d.ts +0 -2
  142. package/build/types/utils/isAction_Context_JsonObject.d.ts +0 -2
  143. package/build/types/utils/isAction_Core_JsonObject.d.ts +0 -2
  144. package/build/types/utils/typescript/MaybePromise.d.ts +0 -1
  145. package/build/types/utils/wait.utils.d.ts +0 -13
@@ -0,0 +1,17 @@
1
+ import { $n as TInferOutputFromSchema, Kn as IActionDomain, Pt as ActionCore, Qn as TInferInputFromSchema, nr as ActionSchema, rr as TInferActionError } from "../ActionPayload.types-BN-rXFBK.js";
2
+ import { QueryKey, UseMutationOptions, UseMutationResult, UseQueryOptions, UseQueryResult } from "@tanstack/react-query";
3
+
4
+ //#region src/react-query/hooks/useActionMutation.d.ts
5
+ /** When an action has no input schema (Input = never), use void so mutate() needs no arguments. */
6
+ type TActionMutationVars<SCH extends ActionSchema<any, any, any>> = [TInferInputFromSchema<SCH>["Input"]] extends [never] ? void : TInferInputFromSchema<SCH>["Input"];
7
+ type TUseNiceMutationOptions<DOM extends IActionDomain, ID extends keyof DOM["actionSchema"] & string, SCH extends DOM["actionSchema"][ID] = DOM["actionSchema"][ID], TContext = unknown> = Omit<UseMutationOptions<TInferOutputFromSchema<SCH>["Output"], TInferActionError<SCH>, TActionMutationVars<SCH>, TContext>, "mutationFn">;
8
+ declare function useActionMutation<DOM extends IActionDomain, ID extends keyof DOM["actionSchema"] & string, SCH extends DOM["actionSchema"][ID], TContext = unknown>(action: ActionCore<DOM, ID>, options?: TUseNiceMutationOptions<DOM, ID, SCH, TContext>): UseMutationResult<TInferOutputFromSchema<SCH>["Output"], TInferActionError<SCH>, TActionMutationVars<SCH>, TContext>;
9
+ //#endregion
10
+ //#region src/react-query/hooks/useActionQuery.d.ts
11
+ declare function actionQueryKey<DOM extends IActionDomain, ID extends keyof DOM["actionSchema"] & string>(action: ActionCore<DOM, ID>): readonly ["nice-action", DOM["domain"], DOM["allDomains"], ID];
12
+ declare function actionQueryKey<DOM extends IActionDomain, ID extends keyof DOM["actionSchema"] & string>(action: ActionCore<DOM, ID>, input: TInferInputFromSchema<DOM["actionSchema"][ID]>["Input"]): readonly ["nice-action", DOM["domain"], DOM["allDomains"], ID, TInferInputFromSchema<DOM["actionSchema"][ID]>["Input"]];
13
+ type TUseActionQueryOptions<DOM extends IActionDomain, ID extends keyof DOM["actionSchema"] & string, SCH extends DOM["actionSchema"][ID] = DOM["actionSchema"][ID], TSelect = TInferOutputFromSchema<SCH>["Output"]> = Omit<UseQueryOptions<TInferOutputFromSchema<SCH>["Output"], TInferActionError<SCH>, TSelect, QueryKey>, "queryKey" | "queryFn">;
14
+ declare function useActionQuery<DOM extends IActionDomain, ID extends keyof DOM["actionSchema"] & string, SCH extends DOM["actionSchema"][ID], TSelect = TInferOutputFromSchema<SCH>["Output"]>(action: ActionCore<DOM, ID>, ...args: [TInferInputFromSchema<SCH>["Input"]] extends [never] ? [options?: TUseActionQueryOptions<DOM, ID, SCH, TSelect>] : [input: TInferInputFromSchema<SCH>["Input"] | null | undefined, options?: TUseActionQueryOptions<DOM, ID, SCH, TSelect>]): UseQueryResult<TSelect, TInferActionError<SCH>>;
15
+ //#endregion
16
+ export { TActionMutationVars, TUseActionQueryOptions, TUseNiceMutationOptions, actionQueryKey, useActionMutation, useActionQuery };
17
+ //# sourceMappingURL=index.d.ts.map
@@ -1,67 +1,67 @@
1
- // src/react-query/hooks/useActionMutation.ts
2
- import {
3
- useMutation
4
- } from "@tanstack/react-query";
1
+ import { useMutation, useQuery } from "@tanstack/react-query";
5
2
  import { useRef } from "react";
3
+ //#region src/react-query/hooks/useActionMutation.ts
6
4
  function useActionMutation(action, options) {
7
- const mutationOptions = options ?? {};
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
- },
16
- ...mutationOptions
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
- };
5
+ const mutationOptions = options ?? {};
6
+ const callSiteRef = useRef(void 0);
7
+ const result = useMutation({
8
+ mutationFn: (input) => {
9
+ const req = action.request(input);
10
+ req._callSite = callSiteRef.current;
11
+ callSiteRef.current = void 0;
12
+ return req.runToOutput();
13
+ },
14
+ ...mutationOptions
15
+ });
16
+ return {
17
+ ...result,
18
+ mutate: (...args) => {
19
+ callSiteRef.current = (/* @__PURE__ */ new Error()).stack;
20
+ return result.mutate(...args);
21
+ },
22
+ mutateAsync: (...args) => {
23
+ callSiteRef.current = (/* @__PURE__ */ new Error()).stack;
24
+ return result.mutateAsync(...args);
25
+ }
26
+ };
29
27
  }
30
- // src/react-query/hooks/useActionQuery.ts
31
- import {
32
- useQuery
33
- } from "@tanstack/react-query";
34
- import { useRef as useRef2 } from "react";
28
+ //#endregion
29
+ //#region src/react-query/hooks/useActionQuery.ts
35
30
  function actionQueryKey(action, input) {
36
- if (input === undefined) {
37
- return ["nice-action", action.domain, action.allDomains, action.id];
38
- }
39
- return ["nice-action", action.domain, action.allDomains, action.id, input];
31
+ if (input === void 0) return [
32
+ "nice-action",
33
+ action.domain,
34
+ action.allDomains,
35
+ action.id
36
+ ];
37
+ return [
38
+ "nice-action",
39
+ action.domain,
40
+ action.allDomains,
41
+ action.id,
42
+ input
43
+ ];
40
44
  }
41
45
  function useActionQuery(action, ...args) {
42
- const hasInputSchema = action.schema.inputSchema != null;
43
- let input;
44
- let options;
45
- if (hasInputSchema) {
46
- [input, options] = args;
47
- } else {
48
- [options] = args;
49
- }
50
- const { enabled, ...queryOptions } = options ?? {};
51
- const callSiteRef = useRef2(new Error().stack);
52
- return useQuery({
53
- queryKey: input != null ? actionQueryKey(action, input) : actionQueryKey(action),
54
- queryFn: () => {
55
- const req = action.request(input);
56
- req._callSite = callSiteRef.current;
57
- return req.runToOutput();
58
- },
59
- enabled: hasInputSchema ? input != null && (enabled ?? true) : enabled ?? true,
60
- ...queryOptions
61
- });
46
+ const hasInputSchema = action.schema.inputSchema != null;
47
+ let input;
48
+ let options;
49
+ if (hasInputSchema) [input, options] = args;
50
+ else [options] = args;
51
+ const { enabled, ...queryOptions } = options ?? {};
52
+ const callSiteRef = useRef((/* @__PURE__ */ new Error()).stack);
53
+ return useQuery({
54
+ queryKey: input != null ? actionQueryKey(action, input) : actionQueryKey(action),
55
+ queryFn: () => {
56
+ const req = action.request(input);
57
+ req._callSite = callSiteRef.current;
58
+ return req.runToOutput();
59
+ },
60
+ enabled: hasInputSchema ? input != null && (enabled ?? true) : enabled ?? true,
61
+ ...queryOptions
62
+ });
62
63
  }
63
- export {
64
- useActionQuery,
65
- useActionMutation,
66
- actionQueryKey
67
- };
64
+ //#endregion
65
+ export { actionQueryKey, useActionMutation, useActionQuery };
66
+
67
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/react-query/hooks/useActionMutation.ts","../../src/react-query/hooks/useActionQuery.ts"],"sourcesContent":["import {\r\n type UseMutationOptions,\r\n type UseMutationResult,\r\n useMutation,\r\n} from \"@tanstack/react-query\";\r\nimport { useRef } from \"react\";\r\nimport type { ActionCore } from \"../../ActionDefinition/Action/Core/ActionCore\";\r\nimport type {\r\n IActionDomain,\r\n TInferInputFromSchema,\r\n TInferOutputFromSchema,\r\n} from \"../../ActionDefinition/Domain/ActionDomain.types\";\r\nimport type { ActionSchema, TInferActionError } from \"../../ActionDefinition/Schema/ActionSchema\";\r\n\r\n/** When an action has no input schema (Input = never), use void so mutate() needs no arguments. */\r\nexport type TActionMutationVars<SCH extends ActionSchema<any, any, any>> = [\r\n TInferInputFromSchema<SCH>[\"Input\"],\r\n] extends [never]\r\n ? void\r\n : TInferInputFromSchema<SCH>[\"Input\"];\r\n\r\nexport type TUseNiceMutationOptions<\r\n DOM extends IActionDomain,\r\n ID extends keyof DOM[\"actionSchema\"] & string,\r\n SCH extends DOM[\"actionSchema\"][ID] = DOM[\"actionSchema\"][ID],\r\n TContext = unknown,\r\n> = Omit<\r\n UseMutationOptions<\r\n TInferOutputFromSchema<SCH>[\"Output\"],\r\n TInferActionError<SCH>,\r\n TActionMutationVars<SCH>,\r\n TContext\r\n >,\r\n \"mutationFn\"\r\n>;\r\n\r\nexport function useActionMutation<\r\n DOM extends IActionDomain,\r\n ID extends keyof DOM[\"actionSchema\"] & string,\r\n SCH extends DOM[\"actionSchema\"][ID],\r\n TContext = unknown,\r\n>(\r\n action: ActionCore<DOM, ID>,\r\n options?: TUseNiceMutationOptions<DOM, ID, SCH, TContext>,\r\n): UseMutationResult<\r\n TInferOutputFromSchema<SCH>[\"Output\"],\r\n TInferActionError<SCH>,\r\n TActionMutationVars<SCH>,\r\n TContext\r\n> {\r\n const mutationOptions = options ?? {};\r\n\r\n // Side-channel for the call site: mutate() writes it synchronously, mutationFn reads it.\r\n // React Query calls mutationFn synchronously within mutate(), so the ref is always fresh.\r\n const callSiteRef = useRef<string | undefined>(undefined);\r\n\r\n const result = useMutation({\r\n mutationFn: (input: TActionMutationVars<SCH>) => {\r\n const req = action.request(input as unknown as TInferInputFromSchema<SCH>[\"Input\"]);\r\n req._callSite = callSiteRef.current;\r\n callSiteRef.current = undefined;\r\n return req.runToOutput();\r\n },\r\n ...mutationOptions,\r\n });\r\n\r\n // Wrap mutate/mutateAsync so the call site is captured at the user's invocation point.\r\n // By the time mutationFn runs inside React Query's scheduler the user's frames are gone.\r\n return {\r\n ...result,\r\n mutate: (...args: Parameters<typeof result.mutate>) => {\r\n callSiteRef.current = new Error().stack;\r\n return result.mutate(...args);\r\n },\r\n mutateAsync: (...args: Parameters<typeof result.mutateAsync>) => {\r\n callSiteRef.current = new Error().stack;\r\n return result.mutateAsync(...args);\r\n },\r\n };\r\n}\r\n","import {\n type QueryKey,\n type UseQueryOptions,\n type UseQueryResult,\n useQuery,\n} from \"@tanstack/react-query\";\nimport { useRef } from \"react\";\nimport type { ActionCore } from \"../../ActionDefinition/Action/Core/ActionCore\";\nimport type {\n IActionDomain,\n TInferInputFromSchema,\n TInferOutputFromSchema,\n} from \"../../ActionDefinition/Domain/ActionDomain.types\";\nimport type { TInferActionError } from \"../../ActionDefinition/Schema/ActionSchema\";\n\nexport function actionQueryKey<\n DOM extends IActionDomain,\n ID extends keyof DOM[\"actionSchema\"] & string,\n>(action: ActionCore<DOM, ID>): readonly [\"nice-action\", DOM[\"domain\"], DOM[\"allDomains\"], ID];\n\nexport function actionQueryKey<\n DOM extends IActionDomain,\n ID extends keyof DOM[\"actionSchema\"] & string,\n>(\n action: ActionCore<DOM, ID>,\n input: TInferInputFromSchema<DOM[\"actionSchema\"][ID]>[\"Input\"],\n): readonly [\n \"nice-action\",\n DOM[\"domain\"],\n DOM[\"allDomains\"],\n ID,\n TInferInputFromSchema<DOM[\"actionSchema\"][ID]>[\"Input\"],\n];\n\nexport function actionQueryKey(action: ActionCore<any, any>, input?: unknown): QueryKey {\n if (input === undefined) {\n return [\"nice-action\", action.domain, action.allDomains, action.id] as const;\n }\n\n return [\"nice-action\", action.domain, action.allDomains, action.id, input] as const;\n}\n\nexport type TUseActionQueryOptions<\n DOM extends IActionDomain,\n ID extends keyof DOM[\"actionSchema\"] & string,\n SCH extends DOM[\"actionSchema\"][ID] = DOM[\"actionSchema\"][ID],\n TSelect = TInferOutputFromSchema<SCH>[\"Output\"],\n> = Omit<\n UseQueryOptions<TInferOutputFromSchema<SCH>[\"Output\"], TInferActionError<SCH>, TSelect, QueryKey>,\n \"queryKey\" | \"queryFn\"\n>;\n\nexport function useActionQuery<\n DOM extends IActionDomain,\n ID extends keyof DOM[\"actionSchema\"] & string,\n SCH extends DOM[\"actionSchema\"][ID],\n TSelect = TInferOutputFromSchema<SCH>[\"Output\"],\n>(\n action: ActionCore<DOM, ID>,\n ...args: [TInferInputFromSchema<SCH>[\"Input\"]] extends [never]\n ? [options?: TUseActionQueryOptions<DOM, ID, SCH, TSelect>]\n : [\n input: TInferInputFromSchema<SCH>[\"Input\"] | null | undefined,\n options?: TUseActionQueryOptions<DOM, ID, SCH, TSelect>,\n ]\n): UseQueryResult<TSelect, TInferActionError<SCH>> {\n const hasInputSchema = action.schema.inputSchema != null;\n\n let input: TInferInputFromSchema<SCH>[\"Input\"] | null | undefined;\n let options: TUseActionQueryOptions<DOM, ID, SCH, TSelect> | undefined;\n\n if (hasInputSchema) {\n [input, options] = args as [\n TInferInputFromSchema<SCH>[\"Input\"] | null | undefined,\n TUseActionQueryOptions<DOM, ID, SCH, TSelect>?,\n ];\n } else {\n [options] = args as [TUseActionQueryOptions<DOM, ID, SCH, TSelect>?];\n }\n\n const { enabled, ...queryOptions } = options ?? {};\n\n // Capture the call site synchronously here — the user's component frame is on the\n // stack now. By the time queryFn runs inside React Query's scheduler it's gone.\n const callSiteRef = useRef(new Error().stack);\n\n return useQuery({\n queryKey: input != null ? actionQueryKey(action, input) : actionQueryKey(action),\n queryFn: () => {\n const req = (action.request as (input: any) => any)(input);\n req._callSite = callSiteRef.current;\n return req.runToOutput();\n },\n enabled: hasInputSchema ? input != null && (enabled ?? true) : (enabled ?? true),\n ...queryOptions,\n } as UseQueryOptions<TInferOutputFromSchema<SCH>[\"Output\"], TInferActionError<SCH>, TSelect>);\n}\n"],"mappings":";;;AAoCA,SAAgB,kBAMd,QACA,SAMA;CACA,MAAM,kBAAkB,WAAW,CAAC;CAIpC,MAAM,cAAc,OAA2B,KAAA,CAAS;CAExD,MAAM,SAAS,YAAY;EACzB,aAAa,UAAoC;GAC/C,MAAM,MAAM,OAAO,QAAQ,KAAuD;GAClF,IAAI,YAAY,YAAY;GAC5B,YAAY,UAAU,KAAA;GACtB,OAAO,IAAI,YAAY;EACzB;EACA,GAAG;CACL,CAAC;CAID,OAAO;EACL,GAAG;EACH,SAAS,GAAG,SAA2C;GACrD,YAAY,2BAAU,IAAI,MAAM,EAAA,CAAE;GAClC,OAAO,OAAO,OAAO,GAAG,IAAI;EAC9B;EACA,cAAc,GAAG,SAAgD;GAC/D,YAAY,2BAAU,IAAI,MAAM,EAAA,CAAE;GAClC,OAAO,OAAO,YAAY,GAAG,IAAI;EACnC;CACF;AACF;;;AC7CA,SAAgB,eAAe,QAA8B,OAA2B;CACtF,IAAI,UAAU,KAAA,GACZ,OAAO;EAAC;EAAe,OAAO;EAAQ,OAAO;EAAY,OAAO;CAAE;CAGpE,OAAO;EAAC;EAAe,OAAO;EAAQ,OAAO;EAAY,OAAO;EAAI;CAAK;AAC3E;AAYA,SAAgB,eAMd,QACA,GAAG,MAM8C;CACjD,MAAM,iBAAiB,OAAO,OAAO,eAAe;CAEpD,IAAI;CACJ,IAAI;CAEJ,IAAI,gBACF,CAAC,OAAO,WAAW;MAKnB,CAAC,WAAW;CAGd,MAAM,EAAE,SAAS,GAAG,iBAAiB,WAAW,CAAC;CAIjD,MAAM,cAAc,wBAAO,IAAI,MAAM,EAAA,CAAE,KAAK;CAE5C,OAAO,SAAS;EACd,UAAU,SAAS,OAAO,eAAe,QAAQ,KAAK,IAAI,eAAe,MAAM;EAC/E,eAAe;GACb,MAAM,MAAO,OAAO,QAAgC,KAAK;GACzD,IAAI,YAAY,YAAY;GAC5B,OAAO,IAAI,YAAY;EACzB;EACA,SAAS,iBAAiB,SAAS,SAAS,WAAW,QAAS,WAAW;EAC3E,GAAG;CACL,CAA4F;AAC9F"}
package/package.json CHANGED
@@ -1,26 +1,26 @@
1
1
  {
2
2
  "name": "@nice-code/action",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "exports": {
5
5
  ".": {
6
6
  "source": "./src/index.ts",
7
7
  "import": "./build/index.js",
8
- "types": "./build/types/index.d.ts"
8
+ "types": "./build/index.d.ts"
9
9
  },
10
10
  "./devtools/browser": {
11
11
  "source": "./src/devtools/browser/index.ts",
12
12
  "import": "./build/devtools/browser/index.js",
13
- "types": "./build/types/devtools/browser/index.d.ts"
13
+ "types": "./build/devtools/browser/index.d.ts"
14
14
  },
15
15
  "./devtools/server": {
16
16
  "source": "./src/devtools/server/index.ts",
17
17
  "import": "./build/devtools/server/index.js",
18
- "types": "./build/types/devtools/server/index.d.ts"
18
+ "types": "./build/devtools/server/index.d.ts"
19
19
  },
20
20
  "./react-query": {
21
21
  "source": "./src/react-query/index.ts",
22
22
  "import": "./build/react-query/index.js",
23
- "types": "./build/types/react-query/index.d.ts"
23
+ "types": "./build/react-query/index.d.ts"
24
24
  }
25
25
  },
26
26
  "files": [
@@ -39,7 +39,8 @@
39
39
  "access": "public"
40
40
  },
41
41
  "scripts": {
42
- "build": "bun run clean-build && bun run build.ts && bun run build-types",
42
+ "build-bun": "bun run clean-build && bun run build.ts && bun run build-types",
43
+ "build": "bun run clean-build && tsdown",
43
44
  "build-types": "tsc --project tsconfig.build.json",
44
45
  "build-watch": "bun run clean-build && bun run build.ts --watch && bun run build-types --watch",
45
46
  "clean-build": "bunx rimraf build",
@@ -50,16 +51,16 @@
50
51
  },
51
52
  "type": "module",
52
53
  "dependencies": {
53
- "@nice-code/common-errors": "0.8.0",
54
- "@nice-code/error": "0.8.0",
55
- "@nice-code/util": "0.8.0",
54
+ "@nice-code/common-errors": "0.9.0",
55
+ "@nice-code/error": "0.9.0",
56
+ "@nice-code/util": "0.9.0",
56
57
  "@standard-schema/spec": "^1.1.0",
57
58
  "@tanstack/react-virtual": "^3.13.26",
58
59
  "http-status-codes": "^2.3.0",
59
60
  "lucide-react": "1.17.0",
60
61
  "msgpackr": "2.0.4",
61
62
  "nanoid": "^5.1.9",
62
- "nice-devtools-shared": "0.8.0",
63
+ "nice-devtools-shared": "0.9.0",
63
64
  "source-map-js": "^1.2.1",
64
65
  "std-env": "^4.1.0"
65
66
  },
@@ -1,37 +0,0 @@
1
- import type { IActionDomain } from "../Domain/ActionDomain.types";
2
- import type { IActionBase } from "./ActionBase.types";
3
- import type { ActionContext } from "./Context/ActionContext";
4
- import type { IActionContext_JsonObject } from "./Context/ActionContext.types";
5
- import type { ActionCore } from "./Core/ActionCore";
6
- import type { IActionCore_JsonObject } from "./Core/ActionCore.types";
7
- import type { IActionPayload_Progress_JsonObject, IActionPayload_Request_JsonObject, IActionPayload_Result_JsonObject, TActionPayload_Any_Instance, TActionPayload_Any_JsonObject } from "./Payload/ActionPayload.types";
8
- import type { ActionPayload_Progress } from "./Payload/ActionPayload_Progress";
9
- import type { ActionPayload_Request } from "./Payload/ActionPayload_Request";
10
- import type { ActionPayload_Result } from "./Payload/ActionPayload_Result";
11
- /**
12
- * Distributes a union ID into a proper discriminated union of ActionPayload_Request instances,
13
- * so that narrowing on `.id` also narrows `.input`.
14
- */
15
- export type TDistributeActionPayload_Request<DOM extends IActionDomain, ID extends keyof DOM["actionSchema"] & string> = ID extends keyof DOM["actionSchema"] & string ? ActionPayload_Request<DOM, ID> : never;
16
- /**
17
- * Distributes a union ID into a proper discriminated union of ActionPayload_Result instances,
18
- * so that narrowing on `.id` also narrows `.result`.
19
- */
20
- export type TDistributeActionPayload_Result<DOM extends IActionDomain, ID extends keyof DOM["actionSchema"] & string> = ID extends keyof DOM["actionSchema"] & string ? ActionPayload_Result<DOM, ID> : never;
21
- export type TAction_Any_Instance<DOM extends IActionDomain, ID extends keyof DOM["actionSchema"] & string = keyof DOM["actionSchema"] & string> = ActionCore<DOM, ID> | TActionPayload_Any_Instance<DOM, ID> | ActionContext<DOM, ID>;
22
- /**
23
- *
24
- * COMBINED JSON TYPES
25
- *
26
- */
27
- export type TAction_Any_JsonObject<DOM extends IActionDomain = IActionDomain, ID extends keyof DOM["actionSchema"] & string = keyof DOM["actionSchema"] & string> = IActionCore_JsonObject<DOM, ID> | TActionPayload_Any_JsonObject<DOM, ID> | IActionContext_JsonObject<DOM, ID>;
28
- /**
29
- *
30
- * UTILITY TYPES
31
- *
32
- */
33
- export type TDistributedDomainActions<DOM extends IActionDomain, ACT extends IActionBase<any, DOM, any>> = {
34
- [ID in keyof DOM["actionSchema"] & string]: TNarrowActionType<DOM, ACT, ID>;
35
- }[keyof DOM["actionSchema"] & string];
36
- export type TNarrowActionType<DOM extends IActionDomain, ACT extends IActionBase<any, DOM, any>, ID extends keyof DOM["actionSchema"] & string = keyof DOM["actionSchema"] & string> = ACT extends ActionPayload_Result<any> ? ActionPayload_Result<DOM, ID> : ACT extends ActionPayload_Request<any> ? ActionPayload_Request<DOM, ID> : ACT extends ActionPayload_Progress<any> ? ActionPayload_Progress<DOM, ID> : ACT extends ActionCore<any> ? ActionCore<DOM, ID> : never;
37
- export type TNarrowActionJsonTypeToActionInstanceType<DOM extends IActionDomain, ACT extends TAction_Any_JsonObject<DOM>, ID extends keyof DOM["actionSchema"] & string = keyof DOM["actionSchema"] & string> = ACT extends IActionPayload_Request_JsonObject<any> ? ActionPayload_Request<DOM, ID> : ACT extends IActionPayload_Result_JsonObject<any> ? ActionPayload_Result<DOM, ID> : ACT extends IActionPayload_Progress_JsonObject<any> ? ActionPayload_Progress<DOM, ID> : ACT extends IActionCore_JsonObject<any> ? ActionCore<DOM, ID> : never;
@@ -1,14 +0,0 @@
1
- import type { ActionDomain } from "../Domain/ActionDomain";
2
- import type { IActionDomain } from "../Domain/ActionDomain.types";
3
- import type { EActionForm, IActionBase, IActionBase_JsonObject } from "./ActionBase.types";
4
- export declare abstract class ActionBase<FORM extends EActionForm, DOM extends IActionDomain, ID extends keyof DOM["actionSchema"] & string = keyof DOM["actionSchema"] & string> implements IActionBase<FORM, DOM, ID> {
5
- readonly form: FORM;
6
- readonly _domain: ActionDomain<DOM>;
7
- readonly id: ID;
8
- readonly domain: DOM["domain"];
9
- readonly allDomains: DOM["allDomains"];
10
- readonly schema: DOM["actionSchema"][ID];
11
- constructor(form: FORM, _domain: ActionDomain<DOM>, id: ID);
12
- protected toJsonObject(): IActionBase_JsonObject<FORM, DOM, ID>;
13
- protected toJsonString(): string;
14
- }
@@ -1,24 +0,0 @@
1
- import type { ActionDomain } from "../Domain/ActionDomain";
2
- import type { IActionDomain } from "../Domain/ActionDomain.types";
3
- export declare enum EActionForm {
4
- core = "core",
5
- context = "context",
6
- data = "data"
7
- }
8
- export interface INiceActionIdAndDomain<DOM extends IActionDomain = IActionDomain> {
9
- domain: DOM["domain"];
10
- id: keyof DOM["actionSchema"] & string;
11
- }
12
- export interface IActionBase<FORM extends EActionForm, DOM extends IActionDomain, ID extends keyof DOM["actionSchema"] & string = keyof DOM["actionSchema"] & string> extends INiceActionIdAndDomain<DOM> {
13
- id: ID;
14
- form: FORM;
15
- _domain: ActionDomain<DOM>;
16
- allDomains: DOM["allDomains"];
17
- schema: DOM["actionSchema"][ID];
18
- }
19
- export interface IActionBase_JsonObject<FORM extends EActionForm = EActionForm, DOM extends IActionDomain = IActionDomain, ID extends keyof DOM["actionSchema"] & string = keyof DOM["actionSchema"] & string> {
20
- form: FORM;
21
- domain: DOM["domain"];
22
- allDomains: DOM["allDomains"];
23
- id: ID;
24
- }
@@ -1,25 +0,0 @@
1
- import { RuntimeCoordinate } from "../../../ActionRuntime/RuntimeCoordinate";
2
- import type { ActionDomain } from "../../Domain/ActionDomain";
3
- import type { IActionDomain, TInferInputFromSchema, TInferOutputFromSchema } from "../../Domain/ActionDomain.types";
4
- import { ActionBase } from "../ActionBase";
5
- import { EActionForm } from "../ActionBase.types";
6
- import type { IActionContext, IActionContext_Data, IActionContext_Data_JsonObject, IActionContext_JsonObject, IActionRouteItem } from "./ActionContext.types";
7
- export declare class ActionContext<DOM extends IActionDomain, ID extends keyof DOM["actionSchema"] & string = keyof DOM["actionSchema"] & string> extends ActionBase<EActionForm.context, DOM, ID> implements IActionContext<DOM, ID> {
8
- readonly _domain: ActionDomain<DOM>;
9
- readonly form = EActionForm.context;
10
- readonly _routing: IActionRouteItem[];
11
- readonly timeCreated: number;
12
- readonly cuid: string;
13
- originClient: RuntimeCoordinate;
14
- constructor(_domain: ActionDomain<DOM>, id: ID, hydrationData: IActionContext_Data);
15
- _setOriginClient(client: RuntimeCoordinate): void;
16
- toJsonString(): string;
17
- toContextDataJsonObject(): IActionContext_Data_JsonObject;
18
- toJsonObject(): IActionContext_JsonObject<DOM, ID>;
19
- get routing(): IActionRouteItem[];
20
- addRouteItem(item: IActionRouteItem): void;
21
- deserializeInput(serialized: TInferInputFromSchema<DOM["actionSchema"][ID]>["SerdeInput"]): TInferInputFromSchema<DOM["actionSchema"][ID]>["Input"];
22
- serializeInput(raw: TInferInputFromSchema<DOM["actionSchema"][ID]>["Input"]): TInferInputFromSchema<DOM["actionSchema"][ID]>["SerdeInput"];
23
- validateInput(input: unknown): TInferInputFromSchema<DOM["actionSchema"][ID]>["Input"];
24
- validateOutput(output: unknown): TInferOutputFromSchema<DOM["actionSchema"][ID]>["Output"];
25
- }
@@ -1,35 +0,0 @@
1
- import type { IRuntimeCoordinate, RuntimeCoordinate } from "../../../ActionRuntime/RuntimeCoordinate";
2
- import type { IActionDomain } from "../../Domain/ActionDomain.types";
3
- import type { EActionForm, IActionBase, IActionBase_JsonObject } from "../ActionBase.types";
4
- import type { IActionRouteItemHandler } from "../Payload/ActionPayload.types";
5
- export interface IActionRouteItem {
6
- runtime: RuntimeCoordinate;
7
- handler: IActionRouteItemHandler;
8
- time: number;
9
- }
10
- export interface IActionContext_Data {
11
- cuid: string;
12
- timeCreated: number;
13
- routing: IActionRouteItem[];
14
- originClient: RuntimeCoordinate;
15
- }
16
- export interface IActionContext<DOM extends IActionDomain, ID extends keyof DOM["actionSchema"] & string = keyof DOM["actionSchema"] & string> extends IActionBase<EActionForm.context, DOM, ID>, IActionContext_Data {
17
- }
18
- /**
19
- *
20
- * JSON TYPES
21
- *
22
- */
23
- export interface IActionRouteItem_JsonObject {
24
- runtime: IRuntimeCoordinate;
25
- handler: IActionRouteItemHandler;
26
- time: number;
27
- }
28
- export interface IActionContext_Data_JsonObject {
29
- cuid: string;
30
- timeCreated: number;
31
- routing: IActionRouteItem_JsonObject[];
32
- originClient: IRuntimeCoordinate;
33
- }
34
- export interface IActionContext_JsonObject<DOM extends IActionDomain = IActionDomain, ID extends keyof DOM["actionSchema"] & string = keyof DOM["actionSchema"] & string> extends IActionBase_JsonObject<EActionForm.context, DOM, ID>, IActionContext_Data_JsonObject {
35
- }
@@ -1,19 +0,0 @@
1
- import type { ActionDomain } from "../../Domain/ActionDomain";
2
- import type { IActionDomain, TInferInputFromSchema, TInferOutputFromSchema } from "../../Domain/ActionDomain.types";
3
- import type { TNarrowActionType } from "../Action.combined.types";
4
- import { ActionBase } from "../ActionBase";
5
- import { EActionForm, type IActionBase, type IActionBase_JsonObject } from "../ActionBase.types";
6
- import { ActionPayload_Request } from "../Payload/ActionPayload_Request";
7
- import type { IActionCore } from "./ActionCore.types";
8
- export declare class ActionCore<DOM extends IActionDomain, ID extends keyof DOM["actionSchema"] & string = keyof DOM["actionSchema"] & string> extends ActionBase<EActionForm.core, DOM, ID> implements IActionCore<DOM, ID> {
9
- readonly _domain: ActionDomain<DOM>;
10
- readonly form = EActionForm.core;
11
- constructor(_domain: ActionDomain<DOM>, id: ID);
12
- is<ACT extends IActionBase<any, any, any>>(action: ACT | unknown | null | undefined): action is TNarrowActionType<DOM, ACT, ID>;
13
- toJsonObject(): IActionBase_JsonObject<EActionForm.core, DOM, ID>;
14
- request(...args: [TInferInputFromSchema<DOM["actionSchema"][ID]>["Input"]] extends [never] ? [input?: never] : [input: TInferInputFromSchema<DOM["actionSchema"][ID]>["Input"]]): ActionPayload_Request<DOM, ID>;
15
- deserializeInput(serialized: TInferInputFromSchema<DOM["actionSchema"][ID]>["SerdeInput"]): TInferInputFromSchema<DOM["actionSchema"][ID]>["Input"];
16
- serializeInput(raw: TInferInputFromSchema<DOM["actionSchema"][ID]>["Input"]): TInferInputFromSchema<DOM["actionSchema"][ID]>["SerdeInput"];
17
- validateInput(input: unknown): TInferInputFromSchema<DOM["actionSchema"][ID]>["Input"];
18
- validateOutput(output: unknown): TInferOutputFromSchema<DOM["actionSchema"][ID]>["Output"];
19
- }
@@ -1,10 +0,0 @@
1
- import type { IActionDomain } from "../../Domain/ActionDomain.types";
2
- import type { EActionForm, IActionBase } from "../ActionBase.types";
3
- export interface IActionCore<DOM extends IActionDomain, ID extends keyof DOM["actionSchema"] & string = keyof DOM["actionSchema"] & string> extends IActionBase<EActionForm.core, DOM, ID> {
4
- }
5
- export type IActionCore_JsonObject<DOM extends IActionDomain = IActionDomain, ID extends keyof DOM["actionSchema"] & string = keyof DOM["actionSchema"] & string> = {
6
- form: EActionForm.core;
7
- domain: DOM["domain"];
8
- allDomains: DOM["allDomains"];
9
- id: ID;
10
- };
@@ -1,14 +0,0 @@
1
- import type { IActionDomain } from "../../Domain/ActionDomain.types";
2
- import { ActionBase } from "../ActionBase";
3
- import { EActionForm } from "../ActionBase.types";
4
- import type { ActionContext } from "../Context/ActionContext";
5
- import type { EActionPayloadType, IActionPayload_Base, IActionPayload_Base_JsonObject, IActionPayload_Data_Base } from "./ActionPayload.types";
6
- export declare abstract class ActionPayload<DT extends EActionPayloadType, DOM extends IActionDomain, ID extends keyof DOM["actionSchema"] & string = keyof DOM["actionSchema"] & string> extends ActionBase<EActionForm.data, DOM, ID> implements IActionPayload_Base<DT, DOM, ID> {
7
- readonly form: EActionForm.data;
8
- readonly type: DT;
9
- readonly context: ActionContext<DOM, ID>;
10
- readonly time: number;
11
- protected constructor(context: ActionContext<DOM, ID>, type: DT, data: IActionPayload_Data_Base);
12
- protected toBaseJsonObject(): IActionPayload_Base_JsonObject<DT, DOM, ID>;
13
- abstract toJsonObject(): IActionPayload_Base_JsonObject<DT, DOM, ID>;
14
- }
@@ -1,110 +0,0 @@
1
- import type { TInferActionError } from "../../..";
2
- import type { IActionHandler_ExternalClient_Json, IActionHandler_Local_Json } from "../../../ActionRuntime/Handler/ActionHandler.types";
3
- import type { ETransportType, ITransportRouteInfo } from "../../../ActionRuntime/Handler/ExternalClient/Transport/Transport.types";
4
- import type { IActionDomain, TInferInputFromSchema, TInferOutputFromSchema } from "../../Domain/ActionDomain.types";
5
- import type { EActionForm, IActionBase, IActionBase_JsonObject } from "../ActionBase.types";
6
- import type { ActionContext } from "../Context/ActionContext";
7
- import type { IActionContext_Data_JsonObject } from "../Context/ActionContext.types";
8
- import type { ActionPayload_Progress } from "./ActionPayload_Progress";
9
- import type { ActionPayload_Request } from "./ActionPayload_Request";
10
- import type { ActionPayload_Result } from "./ActionPayload_Result";
11
- export declare enum EActionPayloadType {
12
- request = "request",
13
- progress = "progress",
14
- result = "result",
15
- stream = "stream",
16
- push = "push"
17
- }
18
- export interface IActionPayload_Data_Base {
19
- time: number;
20
- }
21
- export interface IActionPayload_Base<DT extends EActionPayloadType, DOM extends IActionDomain, ID extends keyof DOM["actionSchema"] & string> extends IActionBase<EActionForm.data, DOM, ID>, IActionPayload_Data_Base {
22
- readonly type: DT;
23
- readonly context: ActionContext<DOM, ID>;
24
- }
25
- export type IActionRouteItemHandler = IActionHandler_Local_Json | (IActionHandler_ExternalClient_Json & {
26
- transType: ETransportType;
27
- transOrd: number;
28
- transInfo?: ITransportRouteInfo;
29
- });
30
- /**
31
- * [ ]
32
- * [ ACTION PAYLOAD TYPES ]
33
- * [ ]
34
- */
35
- /**
36
- *
37
- * [ RESULT ]
38
- *
39
- */
40
- export type TActionResultOutcome<OUT, ERR> = {
41
- ok: true;
42
- output: OUT;
43
- } | {
44
- ok: false;
45
- error: ERR;
46
- };
47
- export interface IActionPayload_Result<DOM extends IActionDomain, ID extends keyof DOM["actionSchema"] & string> extends IActionPayload_Base<EActionPayloadType.result, DOM, ID> {
48
- readonly result: TActionResultOutcome<TInferOutputFromSchema<DOM["actionSchema"][ID]>["Output"], TInferActionError<DOM["actionSchema"][ID]>>;
49
- }
50
- /**
51
- *
52
- * [ PROGRESS ]
53
- *
54
- */
55
- export declare enum EActionProgressType {
56
- none = "none",
57
- percentage = "percentage",
58
- custom = "custom"
59
- }
60
- export interface IActionProgress_None {
61
- type: EActionProgressType.none;
62
- }
63
- export interface IActionProgress_Percentage {
64
- type: EActionProgressType.percentage;
65
- progress: number;
66
- message?: string;
67
- }
68
- export interface IActionProgress_Custom {
69
- type: EActionProgressType.custom;
70
- data: any;
71
- }
72
- export type TActionProgress = IActionProgress_None | IActionProgress_Percentage | IActionProgress_Custom;
73
- export interface IActionPayload_Progress<DOM extends IActionDomain, ID extends keyof DOM["actionSchema"] & string> extends IActionPayload_Base<EActionPayloadType.progress, DOM, ID> {
74
- readonly progress: TActionProgress;
75
- }
76
- /**
77
- *
78
- * [ ]
79
- * [ Wire JSON types ]
80
- * [ ]
81
- *
82
- */
83
- export interface IActionPayload_Base_JsonObject<DT extends EActionPayloadType, DOM extends IActionDomain = IActionDomain, ID extends keyof DOM["actionSchema"] & string = keyof DOM["actionSchema"] & string> extends IActionBase_JsonObject<EActionForm.data, DOM, ID> {
84
- type: DT;
85
- context: IActionContext_Data_JsonObject;
86
- time: number;
87
- }
88
- 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> {
89
- type: EActionPayloadType.request;
90
- input: TInferInputFromSchema<DOM["actionSchema"][ID]>["SerdeInput"];
91
- inputHash: string;
92
- }
93
- 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> {
94
- type: EActionPayloadType.progress;
95
- progress: TActionProgress;
96
- }
97
- 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> {
98
- type: EActionPayloadType.result;
99
- result: TActionResultOutcome<TInferOutputFromSchema<DOM["actionSchema"][ID]>["SerdeOutput"], TInferActionError<DOM["actionSchema"][ID]>>;
100
- outputHash: string;
101
- }
102
- /**
103
- *
104
- * [ ]
105
- * [ COMBINED TYPES ]
106
- * [ ]
107
- *
108
- */
109
- export type TActionPayload_Any_Instance<DOM extends IActionDomain = IActionDomain, ID extends keyof DOM["actionSchema"] & string = keyof DOM["actionSchema"] & string> = ActionPayload_Request<DOM, ID> | ActionPayload_Result<DOM, ID> | ActionPayload_Progress<DOM, ID>;
110
- export type TActionPayload_Any_JsonObject<DOM extends IActionDomain = IActionDomain, ID extends keyof DOM["actionSchema"] & string = keyof DOM["actionSchema"] & string> = IActionPayload_Request_JsonObject<DOM, ID> | IActionPayload_Progress_JsonObject<DOM, ID> | IActionPayload_Result_JsonObject<DOM, ID>;
@@ -1,15 +0,0 @@
1
- import type { IActionDomain } from "../../Domain/ActionDomain.types";
2
- import type { ActionContext } from "../Context/ActionContext";
3
- import { ActionPayload } from "./ActionPayload";
4
- import type { IActionPayload_Data_Base, IActionPayload_Progress, IActionPayload_Progress_JsonObject, TActionProgress } from "./ActionPayload.types";
5
- import { EActionPayloadType } from "./ActionPayload.types";
6
- import { ActionPayload_Request } from "./ActionPayload_Request";
7
- export declare class ActionPayload_Progress<DOM extends IActionDomain, ID extends keyof DOM["actionSchema"] & string = keyof DOM["actionSchema"] & string> extends ActionPayload<EActionPayloadType.progress, DOM, ID> implements IActionPayload_Progress<DOM, ID> {
8
- readonly progress: TActionProgress;
9
- constructor(params: {
10
- context: ActionContext<DOM, ID>;
11
- } | ActionPayload_Request<DOM, ID>, progress: TActionProgress, data: IActionPayload_Data_Base);
12
- toJsonObject(): IActionPayload_Progress_JsonObject<DOM, ID>;
13
- toJsonString(): string;
14
- toHttpResponse(): Response;
15
- }
@@ -1,26 +0,0 @@
1
- import type { IExecuteActionOptions } from "../../../ActionRuntime/Handler/ActionHandler.types";
2
- import type { IActionDomain, TInferInputFromSchema, TInferOutputFromSchema } from "../../Domain/ActionDomain.types";
3
- import type { TInferActionError } from "../../Schema/ActionSchema";
4
- import type { ActionContext } from "../Context/ActionContext";
5
- import type { RunningAction } from "../RunningAction";
6
- import { ActionPayload } from "./ActionPayload";
7
- import type { IActionPayload_Data_Base, TActionProgress } from "./ActionPayload.types";
8
- import { EActionPayloadType, type IActionPayload_Request_JsonObject } from "./ActionPayload.types";
9
- import { ActionPayload_Progress } from "./ActionPayload_Progress";
10
- import { ActionPayload_Result } from "./ActionPayload_Result";
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
- readonly input: TInferInputFromSchema<DOM["actionSchema"][ID]>["Input"];
13
- readonly inputHash: string;
14
- _callSite?: string;
15
- constructor(params: {
16
- context: ActionContext<DOM, ID>;
17
- }, input: TInferInputFromSchema<DOM["actionSchema"][ID]>["Input"], data: IActionPayload_Data_Base);
18
- successResult(...args: [TInferOutputFromSchema<DOM["actionSchema"][ID]>["Output"]] extends [never] ? [] | [output: TInferOutputFromSchema<DOM["actionSchema"][ID]>["Output"]] : [output: TInferOutputFromSchema<DOM["actionSchema"][ID]>["Output"]]): ActionPayload_Result<DOM, ID>;
19
- errorResult(err: TInferActionError<DOM["actionSchema"][ID]>): ActionPayload_Result<DOM, ID>;
20
- progress(progress: TActionProgress): ActionPayload_Progress<DOM, ID>;
21
- toJsonObject(): IActionPayload_Request_JsonObject<DOM, ID>;
22
- toJsonString(): string;
23
- runToOutput(options?: IExecuteActionOptions<DOM, ID>): Promise<TInferOutputFromSchema<DOM["actionSchema"][ID]>["Output"]>;
24
- runToResultPayload(options?: IExecuteActionOptions<DOM, ID>): Promise<ActionPayload_Result<DOM, ID>>;
25
- run(options?: IExecuteActionOptions<DOM, ID>): Promise<RunningAction<DOM, ID>>;
26
- }
@@ -1,19 +0,0 @@
1
- import type { IActionDomain, TInferOutputFromSchema } from "../../Domain/ActionDomain.types";
2
- import type { TInferActionError } from "../../Schema/ActionSchema";
3
- import type { ActionContext } from "../Context/ActionContext";
4
- import { ActionPayload } from "./ActionPayload";
5
- import type { IActionPayload_Data_Base, TActionResultOutcome } from "./ActionPayload.types";
6
- import { EActionPayloadType, type IActionPayload_Result_JsonObject } from "./ActionPayload.types";
7
- import { ActionPayload_Request } from "./ActionPayload_Request";
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
- readonly result: TActionResultOutcome<TInferOutputFromSchema<DOM["actionSchema"][ID]>["Output"], TInferActionError<DOM["actionSchema"][ID]>>;
10
- readonly outputHash: string;
11
- constructor(params: {
12
- context: ActionContext<DOM, ID>;
13
- } | ActionPayload_Request<DOM, ID>, result: TActionResultOutcome<TInferOutputFromSchema<DOM["actionSchema"][ID]>["Output"], TInferActionError<DOM["actionSchema"][ID]>>, data: IActionPayload_Data_Base);
14
- toJsonObject(): IActionPayload_Result_JsonObject<DOM, ID>;
15
- toJsonString(): string;
16
- toHttpResponse({ useErrorStatus }?: {
17
- useErrorStatus?: boolean;
18
- }): Response;
19
- }