@shivaedev/effect-react 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +10 -0
- package/README.md +20 -0
- package/dist/actionTrace.d.ts +3 -0
- package/dist/actionTrace.d.ts.map +1 -0
- package/dist/actionTrace.js +5 -0
- package/dist/actionTrace.js.map +1 -0
- package/dist/submission.d.ts +10 -10
- package/dist/submission.d.ts.map +1 -1
- package/dist/submission.js +4 -3
- package/dist/submission.js.map +1 -1
- package/package.json +5 -5
- package/src/actionTrace.ts +5 -0
- package/src/submission.ts +17 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.10.0 - 2026-10-19
|
|
4
|
+
|
|
5
|
+
### Added
|
|
6
|
+
|
|
7
|
+
- effect-react exports `actionTrace(effect, name?)` from `actionTrace.ts` to group an action's RPC Effects under a fresh trace. Editor saves and create submissions automatically group their save Effects in a `ui.submit` trace. Native HTTP RPC clients send W3C trace context through the host to SQL and job enqueueing; pg-boss worker attempts retain their separate, linked traces.
|
|
8
|
+
|
|
9
|
+
### Fixed
|
|
10
|
+
|
|
11
|
+
- Platform appHost preserves incoming W3C `traceparent` context for RPC handling even without an installed tracer or exporter. Request ids stay annotated on the RPC span.
|
|
12
|
+
|
|
3
13
|
## 0.9.0 - 2026-10-19
|
|
4
14
|
|
|
5
15
|
### Added
|
package/README.md
CHANGED
|
@@ -78,6 +78,26 @@ export function App({ session, recheck }: {
|
|
|
78
78
|
|
|
79
79
|
A query that fails with a tagged `Unauthorized` asks `recheck` to run and keeps its retained data. An action does the same once per failed result, retaining its last successful `data` and the typed failure in `cause`; rerendering that result does not repeat the recheck. The auth owner can retry the same session or remove it; the hook does not sign the user out. The boundary also handles React StrictMode's effect replay and preserves component state across hiding and revealing an `<Activity>` subtree, supplying a live registry when revealed.
|
|
80
80
|
|
|
81
|
+
### Trace an action across RPCs
|
|
82
|
+
|
|
83
|
+
Editor saves and create submissions automatically run their save Effect in a fresh `ui.submit` trace. For custom actions, wrap the Effect that performs the action with `actionTrace` before giving it to a native atom:
|
|
84
|
+
|
|
85
|
+
```ts
|
|
86
|
+
import { Effect } from "effect";
|
|
87
|
+
import { actionTrace } from "@shivaedev/effect-react/actionTrace.ts";
|
|
88
|
+
|
|
89
|
+
const save = OrdersClient.runtime.fn((input: OrderInput) =>
|
|
90
|
+
actionTrace(Effect.gen(function* () {
|
|
91
|
+
yield* api.validate.run(input);
|
|
92
|
+
return yield* api.save.run(input);
|
|
93
|
+
}), "ui.saveOrder"),
|
|
94
|
+
);
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
`OrdersClient`, `OrderInput` and `api` belong to the application. Dispatch `save` with `useAction(save)`. `actionTrace(effect, name?)` preserves the Effect's result, typed error and service requirements; its default span name is `ui.action`. Each execution starts a fresh trace, and RPCs run inside that Effect share it, including across asynchronous boundaries. Native atoms continue to own execution and cancellation. `useAction` also accepts ordinary native action atoms; wrap composite action Effects to group their RPCs.
|
|
98
|
+
|
|
99
|
+
Use native `RpcClient.layerProtocolHttp` with `FetchHttpClient.layer` for the browser RPC protocol. Effect sends the trace in the W3C `traceparent` HTTP header. Platform's appHost carries it into the RPC span and its SQL, and annotates the RPC span with `request.id`. Enqueued pg-boss jobs retain that span context; worker attempts start separate traces linked back to the sender.
|
|
100
|
+
|
|
81
101
|
### 2. Once per feature: native queries and actions
|
|
82
102
|
|
|
83
103
|
The hooks accept native atoms directly. This complete component module shows query and action state without RPC setup:
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actionTrace.d.ts","sourceRoot":"","sources":["../src/actionTrace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,wBAAgB,WAAW,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,SAAc,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAE/G"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"actionTrace.js","sourceRoot":"","sources":["../src/actionTrace.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,MAAM,UAAU,WAAW,CAAU,MAA8B,EAAE,IAAI,GAAG,WAAW;IACtF,OAAO,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;AACtD,CAAC"}
|
package/dist/submission.d.ts
CHANGED
|
@@ -3,17 +3,17 @@ import type * as Atom from "effect/reactivity/Atom";
|
|
|
3
3
|
import type { PersistedDraftConfig } from "@shivaedev/effect-form/persistence.ts";
|
|
4
4
|
import type { Decoded, Encoded, FieldFailure, Fields, Form, Services } from "@shivaedev/effect-form/shape.ts";
|
|
5
5
|
import { type AtomServices, type RejectField } from "./fieldRejection.ts";
|
|
6
|
-
export interface SubmissionConfig<
|
|
7
|
-
readonly fields: Schema.Struct<
|
|
8
|
-
readonly initialValues: Encoded<
|
|
6
|
+
export interface SubmissionConfig<TFields extends Fields, A, E, R, TRuntimeError> {
|
|
7
|
+
readonly fields: Schema.Struct<TFields>;
|
|
8
|
+
readonly initialValues: Encoded<TFields>;
|
|
9
9
|
readonly persistedDraft?: PersistedDraftConfig | undefined;
|
|
10
|
-
readonly rejectField: RejectField<
|
|
11
|
-
readonly runtime: Atom.AtomRuntime<Services<
|
|
12
|
-
readonly save: (values: Decoded<
|
|
10
|
+
readonly rejectField: RejectField<TFields, E> | undefined;
|
|
11
|
+
readonly runtime: Atom.AtomRuntime<Services<TFields, R>, TRuntimeError>;
|
|
12
|
+
readonly save: (values: Decoded<TFields>) => Effect.Effect<A, E, AtomServices<R>>;
|
|
13
13
|
}
|
|
14
|
-
export interface Submission<
|
|
15
|
-
readonly form: Form<
|
|
16
|
-
readonly submitted: () => Encoded<
|
|
14
|
+
export interface Submission<TFields extends Fields, A, E, TRuntimeError> {
|
|
15
|
+
readonly form: Form<TFields, A, E | FieldFailure, TRuntimeError>;
|
|
16
|
+
readonly submitted: () => Encoded<TFields> | undefined;
|
|
17
17
|
}
|
|
18
|
-
export declare
|
|
18
|
+
export declare function submission<TFields extends Fields, A, E, R, TRuntimeError>(config: SubmissionConfig<TFields, A, E, R, TRuntimeError>): Submission<TFields, A, E, TRuntimeError>;
|
|
19
19
|
//# sourceMappingURL=submission.d.ts.map
|
package/dist/submission.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"submission.d.ts","sourceRoot":"","sources":["../src/submission.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,KAAK,KAAK,IAAI,MAAM,wBAAwB,CAAC;AAEpD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAClF,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;
|
|
1
|
+
{"version":3,"file":"submission.d.ts","sourceRoot":"","sources":["../src/submission.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC7C,OAAO,KAAK,KAAK,IAAI,MAAM,wBAAwB,CAAC;AAEpD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAClF,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAE9G,OAAO,EAA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AE,CAAC,EAAE,aAAa,CAAC,CAc1C"}
|
package/dist/submission.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { make } from "@shivaedev/effect-form/form.ts";
|
|
2
|
+
import { actionTrace } from "#actionTrace.ts";
|
|
2
3
|
import { rejecting } from "./fieldRejection.js";
|
|
3
|
-
export
|
|
4
|
+
export function submission(config) {
|
|
4
5
|
const { fields, initialValues, runtime } = config;
|
|
5
6
|
const save = rejecting(fields, config.save, config.rejectField);
|
|
6
7
|
let submitted;
|
|
@@ -8,11 +9,11 @@ export const submission = (config) => {
|
|
|
8
9
|
initialValues,
|
|
9
10
|
onSubmit: (values, submitter, snapshot) => {
|
|
10
11
|
submitted = snapshot;
|
|
11
|
-
return save(values, submitter);
|
|
12
|
+
return actionTrace(save(values, submitter), "ui.submit");
|
|
12
13
|
},
|
|
13
14
|
persistedDraft: config.persistedDraft,
|
|
14
15
|
runtime,
|
|
15
16
|
});
|
|
16
17
|
return { form, submitted: () => submitted };
|
|
17
|
-
}
|
|
18
|
+
}
|
|
18
19
|
//# sourceMappingURL=submission.js.map
|
package/dist/submission.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"submission.js","sourceRoot":"","sources":["../src/submission.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,gCAAgC,CAAC;AAGtD,OAAO,EAAuC,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAgBrF,MAAM,
|
|
1
|
+
{"version":3,"file":"submission.js","sourceRoot":"","sources":["../src/submission.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAE,MAAM,gCAAgC,CAAC;AAGtD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAuC,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAgBrF,MAAM,UAAU,UAAU,CACzB,MAAyD;IAEzD,MAAM,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,GAAG,MAAM,CAAC;IAClD,MAAM,IAAI,GAAG,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC;IAChE,IAAI,SAAuC,CAAC;IAC5C,MAAM,IAAI,GAAsD,IAAI,CAAC,MAAM,EAAE;QAC5E,aAAa;QACb,QAAQ,EAAE,CAAC,MAAM,EAAE,SAAS,EAAE,QAAQ,EAAE,EAAE;YACzC,SAAS,GAAG,QAAQ,CAAC;YACrB,OAAO,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,CAAC,EAAE,WAAW,CAAC,CAAC;QAC1D,CAAC;QACD,cAAc,EAAE,MAAM,CAAC,cAAc;QACrC,OAAO;KACP,CAAC,CAAC;IACH,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC,SAAS,EAAE,CAAC;AAC7C,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shivaedev/effect-react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "React query, action, editor and session hooks for native Effect atoms",
|
|
5
5
|
"homepage": "https://github.com/ShivaeDev/platform/tree/main/packages/effect-react#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -53,12 +53,12 @@
|
|
|
53
53
|
"@effect/sql-sqlite-node": "4.0.4",
|
|
54
54
|
"@shivaedev/effect-pg-boss": "0.12.0",
|
|
55
55
|
"@shivaedev/effect-service": "0.4.0",
|
|
56
|
-
"@shivaedev/effect-sql": "0.
|
|
56
|
+
"@shivaedev/effect-sql": "0.8.0",
|
|
57
57
|
"@shivaedev/effect-test": "0.7.1",
|
|
58
|
-
"@shivaedev/effect-test-sql": "0.7.
|
|
58
|
+
"@shivaedev/effect-test-sql": "0.7.1",
|
|
59
59
|
"@shivaedev/local-postgres": "0.4.2",
|
|
60
|
-
"@shivaedev/platform": "0.20.
|
|
61
|
-
"@shivaedev/quality": "0.28.
|
|
60
|
+
"@shivaedev/platform": "0.20.1",
|
|
61
|
+
"@shivaedev/quality": "0.28.2",
|
|
62
62
|
"@shivaedev/test-story": "0.13.0",
|
|
63
63
|
"@tanstack/react-router": "1.170.42",
|
|
64
64
|
"@types/node": "24.19.2",
|
package/src/submission.ts
CHANGED
|
@@ -3,34 +3,37 @@ import type * as Atom from "effect/reactivity/Atom";
|
|
|
3
3
|
import { make } from "@shivaedev/effect-form/form.ts";
|
|
4
4
|
import type { PersistedDraftConfig } from "@shivaedev/effect-form/persistence.ts";
|
|
5
5
|
import type { Decoded, Encoded, FieldFailure, Fields, Form, Services } from "@shivaedev/effect-form/shape.ts";
|
|
6
|
+
import { actionTrace } from "#actionTrace.ts";
|
|
6
7
|
import { type AtomServices, type RejectField, rejecting } from "./fieldRejection.ts";
|
|
7
8
|
|
|
8
|
-
export interface SubmissionConfig<
|
|
9
|
-
readonly fields: Schema.Struct<
|
|
10
|
-
readonly initialValues: Encoded<
|
|
9
|
+
export interface SubmissionConfig<TFields extends Fields, A, E, R, TRuntimeError> {
|
|
10
|
+
readonly fields: Schema.Struct<TFields>;
|
|
11
|
+
readonly initialValues: Encoded<TFields>;
|
|
11
12
|
readonly persistedDraft?: PersistedDraftConfig | undefined;
|
|
12
|
-
readonly rejectField: RejectField<
|
|
13
|
-
readonly runtime: Atom.AtomRuntime<Services<
|
|
14
|
-
readonly save: (values: Decoded<
|
|
13
|
+
readonly rejectField: RejectField<TFields, E> | undefined;
|
|
14
|
+
readonly runtime: Atom.AtomRuntime<Services<TFields, R>, TRuntimeError>;
|
|
15
|
+
readonly save: (values: Decoded<TFields>) => Effect.Effect<A, E, AtomServices<R>>;
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
export interface Submission<
|
|
18
|
-
readonly form: Form<
|
|
19
|
-
readonly submitted: () => Encoded<
|
|
18
|
+
export interface Submission<TFields extends Fields, A, E, TRuntimeError> {
|
|
19
|
+
readonly form: Form<TFields, A, E | FieldFailure, TRuntimeError>;
|
|
20
|
+
readonly submitted: () => Encoded<TFields> | undefined;
|
|
20
21
|
}
|
|
21
22
|
|
|
22
|
-
export
|
|
23
|
+
export function submission<TFields extends Fields, A, E, R, TRuntimeError>(
|
|
24
|
+
config: SubmissionConfig<TFields, A, E, R, TRuntimeError>,
|
|
25
|
+
): Submission<TFields, A, E, TRuntimeError> {
|
|
23
26
|
const { fields, initialValues, runtime } = config;
|
|
24
27
|
const save = rejecting(fields, config.save, config.rejectField);
|
|
25
|
-
let submitted: Encoded<
|
|
26
|
-
const form: Form<
|
|
28
|
+
let submitted: Encoded<TFields> | undefined;
|
|
29
|
+
const form: Form<TFields, A, E | FieldFailure, TRuntimeError> = make(fields, {
|
|
27
30
|
initialValues,
|
|
28
31
|
onSubmit: (values, submitter, snapshot) => {
|
|
29
32
|
submitted = snapshot;
|
|
30
|
-
return save(values, submitter);
|
|
33
|
+
return actionTrace(save(values, submitter), "ui.submit");
|
|
31
34
|
},
|
|
32
35
|
persistedDraft: config.persistedDraft,
|
|
33
36
|
runtime,
|
|
34
37
|
});
|
|
35
38
|
return { form, submitted: () => submitted };
|
|
36
|
-
}
|
|
39
|
+
}
|