@flowmarkdev/node 0.0.0-stage → 0.1.0-alpha.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.
Files changed (43) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +173 -2
  3. package/dist/adapters/next.d.ts +17 -0
  4. package/dist/adapters/next.js +38 -0
  5. package/dist/adapters/proxy.d.ts +25 -0
  6. package/dist/adapters/proxy.js +94 -0
  7. package/dist/browser/index.d.ts +52 -0
  8. package/dist/browser/index.js +115 -0
  9. package/dist/client/create-client.d.ts +21 -0
  10. package/dist/client/create-client.js +136 -0
  11. package/dist/client/runtime.d.ts +5 -0
  12. package/dist/client/runtime.js +72 -0
  13. package/dist/config/api-origin.d.ts +2 -0
  14. package/dist/config/api-origin.js +12 -0
  15. package/dist/config/define-config.d.ts +11 -0
  16. package/dist/config/define-config.js +12 -0
  17. package/dist/config/settings.d.ts +11 -0
  18. package/dist/config/settings.js +31 -0
  19. package/dist/errors/index.d.ts +49 -0
  20. package/dist/errors/index.js +21 -0
  21. package/dist/features/delivery/adapters/http-transport.d.ts +8 -0
  22. package/dist/features/delivery/adapters/http-transport.js +31 -0
  23. package/dist/features/delivery/adapters/http.d.ts +4 -0
  24. package/dist/features/delivery/adapters/http.js +11 -0
  25. package/dist/features/delivery/adapters/memory-transport.d.ts +10 -0
  26. package/dist/features/delivery/adapters/memory-transport.js +12 -0
  27. package/dist/features/delivery/delivery-queue.d.ts +15 -0
  28. package/dist/features/delivery/delivery-queue.js +56 -0
  29. package/dist/features/delivery/ports/workflow-transport.d.ts +9 -0
  30. package/dist/features/delivery/ports/workflow-transport.js +3 -0
  31. package/dist/features/workflows/workflow-engine.d.ts +27 -0
  32. package/dist/features/workflows/workflow-engine.js +232 -0
  33. package/dist/index.d.ts +7 -0
  34. package/dist/index.js +5 -0
  35. package/dist/types/index.d.ts +167 -0
  36. package/dist/types/index.js +1 -0
  37. package/dist/utils/failure-from-unknown.d.ts +3 -0
  38. package/dist/utils/failure-from-unknown.js +36 -0
  39. package/dist/utils/operation-args.d.ts +5 -0
  40. package/dist/utils/operation-args.js +3 -0
  41. package/dist/utils/operation-callback.d.ts +2 -0
  42. package/dist/utils/operation-callback.js +18 -0
  43. package/package.json +75 -3
@@ -0,0 +1,232 @@
1
+ import { Clock, Context, Effect, Layer, Ref } from "effect";
2
+ import { DeliveryQueue } from "../delivery/delivery-queue.js";
3
+ export class WorkflowEngine extends Context.Tag("@flowmarkdev/node/WorkflowEngine")() {
4
+ static layer = Layer.effect(WorkflowEngine, Effect.gen(function* () {
5
+ const delivery = yield* DeliveryQueue;
6
+ const start = Effect.fn("Flowmark.WorkflowEngine.start")(function* (workflow, options) {
7
+ const runId = options.id ??
8
+ (yield* Effect.sync(() => globalThis.crypto.randomUUID()));
9
+ const ordering = yield* Effect.makeSemaphore(1);
10
+ const finished = yield* Ref.make(false);
11
+ const completionRequested = yield* Ref.make(false);
12
+ const pendingCompletion = yield* Ref.make(undefined);
13
+ const activeOperations = yield* Ref.make(new Set());
14
+ const record = Effect.fn("Flowmark.WorkflowEngine.record")(function* (createEvent) {
15
+ const now = yield* Clock.currentTimeMillis;
16
+ yield* delivery.enqueue(createEvent(new Date(now).toISOString()), ordering);
17
+ });
18
+ yield* record((timestamp) => ({
19
+ type: "started",
20
+ workflow,
21
+ runId,
22
+ timestamp,
23
+ ...(options.properties === undefined
24
+ ? {}
25
+ : { properties: options.properties }),
26
+ ...(options.environment === undefined
27
+ ? {}
28
+ : { environment: options.environment }),
29
+ ...(options.release === undefined
30
+ ? {}
31
+ : { release: options.release }),
32
+ ...(options.correlationId === undefined
33
+ ? {}
34
+ : { correlationId: options.correlationId }),
35
+ ...(options.parentRunId === undefined
36
+ ? {}
37
+ : { parentRunId: options.parentRunId }),
38
+ }));
39
+ const step = Effect.fn("Flowmark.WorkflowEngine.step")(function* (name, stepOptions) {
40
+ if ((yield* Ref.get(finished)) ||
41
+ (yield* Ref.get(completionRequested))) {
42
+ return;
43
+ }
44
+ yield* record((timestamp) => ({
45
+ type: "step",
46
+ workflow,
47
+ runId,
48
+ timestamp,
49
+ step: name,
50
+ ...(stepOptions?.properties === undefined
51
+ ? {}
52
+ : { properties: stepOptions.properties }),
53
+ }));
54
+ });
55
+ const complete = Effect.fn("Flowmark.WorkflowEngine.complete")(function* (doneOptions) {
56
+ if (yield* Ref.getAndSet(finished, true)) {
57
+ return;
58
+ }
59
+ yield* record((timestamp) => ({
60
+ type: "completed",
61
+ workflow,
62
+ runId,
63
+ timestamp,
64
+ ...(doneOptions?.result === undefined
65
+ ? {}
66
+ : { result: doneOptions.result }),
67
+ }));
68
+ });
69
+ const done = Effect.fn("Flowmark.WorkflowEngine.done")(function* (doneOptions) {
70
+ if ((yield* Ref.get(finished)) ||
71
+ (yield* Ref.get(completionRequested))) {
72
+ return;
73
+ }
74
+ yield* Ref.set(completionRequested, true);
75
+ yield* Ref.set(pendingCompletion, doneOptions);
76
+ if ((yield* Ref.get(activeOperations)).size > 0) {
77
+ return;
78
+ }
79
+ yield* complete(doneOptions);
80
+ });
81
+ const fail = Effect.fn("Flowmark.WorkflowEngine.fail")(function* (options) {
82
+ if (yield* Ref.getAndSet(finished, true)) {
83
+ return;
84
+ }
85
+ yield* Ref.set(completionRequested, false);
86
+ yield* Ref.set(pendingCompletion, undefined);
87
+ yield* Ref.set(activeOperations, new Set());
88
+ const { result, ...failure } = options;
89
+ yield* record((timestamp) => ({
90
+ type: "failed",
91
+ workflow,
92
+ runId,
93
+ timestamp,
94
+ failure,
95
+ ...(result === undefined ? {} : { result }),
96
+ }));
97
+ });
98
+ const error = Effect.fn("Flowmark.WorkflowEngine.error")(function* (failure) {
99
+ if ((yield* Ref.get(finished)) ||
100
+ (yield* Ref.get(completionRequested))) {
101
+ return;
102
+ }
103
+ yield* record((timestamp) => ({
104
+ type: "error",
105
+ workflow,
106
+ runId,
107
+ timestamp,
108
+ error: failure,
109
+ }));
110
+ });
111
+ const setProperties = Effect.fn("Flowmark.WorkflowEngine.setProperties")(function* (properties) {
112
+ if (yield* Ref.get(finished) || (yield* Ref.get(completionRequested))) {
113
+ return;
114
+ }
115
+ yield* record((timestamp) => ({
116
+ type: "properties",
117
+ workflow,
118
+ runId,
119
+ timestamp,
120
+ properties,
121
+ }));
122
+ });
123
+ const progress = Effect.fn("Flowmark.WorkflowEngine.progress")(function* (progress) {
124
+ if ((yield* Ref.get(finished)) ||
125
+ (yield* Ref.get(completionRequested))) {
126
+ return;
127
+ }
128
+ yield* record((timestamp) => ({
129
+ type: "progress",
130
+ workflow,
131
+ runId,
132
+ timestamp,
133
+ ...progress,
134
+ }));
135
+ });
136
+ const operation = Effect.fn("Flowmark.WorkflowEngine.operation")(function* (operationName, operationOptions) {
137
+ const operationId = yield* Effect.sync(() => globalThis.crypto.randomUUID());
138
+ const startedAt = yield* Effect.sync(() => performance.now());
139
+ const operationFinished = yield* Ref.make(false);
140
+ const canStart = !(yield* Ref.get(finished)) &&
141
+ !(yield* Ref.get(completionRequested));
142
+ if (canStart) {
143
+ yield* Ref.update(activeOperations, (active) => new Set(active).add(operationId));
144
+ yield* record((timestamp) => ({
145
+ type: "operation_started",
146
+ workflow,
147
+ runId,
148
+ timestamp,
149
+ operationId,
150
+ operationName,
151
+ ...(operationOptions?.properties === undefined
152
+ ? {}
153
+ : { properties: operationOptions.properties }),
154
+ }));
155
+ }
156
+ const duration = Effect.sync(() => Math.max(0, performance.now() - startedAt));
157
+ const done = Effect.gen(function* () {
158
+ if (yield* Ref.getAndSet(operationFinished, true)) {
159
+ return;
160
+ }
161
+ if ((yield* Ref.get(finished)) || !canStart) {
162
+ return;
163
+ }
164
+ if (canStart) {
165
+ yield* Ref.update(activeOperations, (active) => {
166
+ const next = new Set(active);
167
+ next.delete(operationId);
168
+ return next;
169
+ });
170
+ }
171
+ const durationMs = yield* duration;
172
+ yield* record((timestamp) => ({
173
+ type: "operation_completed",
174
+ workflow,
175
+ runId,
176
+ timestamp,
177
+ operationId,
178
+ operationName,
179
+ durationMs,
180
+ }));
181
+ const active = yield* Ref.get(activeOperations);
182
+ if (active.size === 0 && (yield* Ref.get(completionRequested))) {
183
+ yield* complete(yield* Ref.get(pendingCompletion));
184
+ }
185
+ });
186
+ const fail = Effect.fn("Flowmark.WorkflowEngine.operation.fail")(function* (failure) {
187
+ if (yield* Ref.getAndSet(operationFinished, true)) {
188
+ return;
189
+ }
190
+ if ((yield* Ref.get(finished)) || !canStart) {
191
+ return;
192
+ }
193
+ if (canStart) {
194
+ yield* Ref.update(activeOperations, (active) => {
195
+ const next = new Set(active);
196
+ next.delete(operationId);
197
+ return next;
198
+ });
199
+ }
200
+ const durationMs = yield* duration;
201
+ yield* record((timestamp) => ({
202
+ type: "operation_failed",
203
+ workflow,
204
+ runId,
205
+ timestamp,
206
+ operationId,
207
+ operationName,
208
+ durationMs,
209
+ failure,
210
+ }));
211
+ const active = yield* Ref.get(activeOperations);
212
+ if (active.size === 0 &&
213
+ (yield* Ref.get(completionRequested))) {
214
+ yield* complete(yield* Ref.get(pendingCompletion));
215
+ }
216
+ });
217
+ return { operationId, done, fail };
218
+ });
219
+ return {
220
+ runId,
221
+ step,
222
+ done,
223
+ fail,
224
+ error,
225
+ setProperties,
226
+ operation,
227
+ progress,
228
+ };
229
+ });
230
+ return WorkflowEngine.of({ start });
231
+ }));
232
+ }
@@ -0,0 +1,7 @@
1
+ export { createFlowmark, workflow } from "./client/create-client.js";
2
+ export { defineConfig } from "./config/define-config.js";
3
+ export { FlowmarkConfigError, FlowmarkDeliveryError, FlowmarkHttpError, FlowmarkQueueError, WorkflowTransportError, } from "./errors/index.js";
4
+ export { WorkflowTransport } from "./features/delivery/ports/workflow-transport.js";
5
+ export { MemoryTransport } from "./features/delivery/adapters/memory-transport.js";
6
+ export type { Flow, FlowmarkClient, FlowmarkConfig, InstrumentationErrorHandler, WorkflowOptions, WorkflowRunOptions, WorkflowDoneOptions, WorkflowFailOptions, WorkflowStepOptions, WorkflowOperation, WorkflowOperationOptions, } from "./types/index.js";
7
+ export type { JsonValue, WorkflowRunId, WorkflowError, WorkflowCorrelationId, WorkflowEvent, WorkflowFailure, WorkflowProperties, WorkflowProgress, WorkflowOperationFailure, WorkflowResult, } from "@flowmarkdev/core";
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export { createFlowmark, workflow } from "./client/create-client.js";
2
+ export { defineConfig } from "./config/define-config.js";
3
+ export { FlowmarkConfigError, FlowmarkDeliveryError, FlowmarkHttpError, FlowmarkQueueError, WorkflowTransportError, } from "./errors/index.js";
4
+ export { WorkflowTransport } from "./features/delivery/ports/workflow-transport.js";
5
+ export { MemoryTransport } from "./features/delivery/adapters/memory-transport.js";
@@ -0,0 +1,167 @@
1
+ import type { WorkflowEvent, WorkflowName, WorkflowCorrelationId, WorkflowError, WorkflowFailure, WorkflowProperties, WorkflowProgress, WorkflowResult, WorkflowRunId, WorkflowStepName } from "@flowmarkdev/core";
2
+ import type { DeliveryFailure } from "../errors/index.js";
3
+ import type { WorkflowTransport } from "../features/delivery/ports/workflow-transport.js";
4
+ /**
5
+ * Receives delivery/validation failures without throwing them into application code.
6
+ * Throwing from this callback is logged and contained by the SDK.
7
+ */
8
+ export type InstrumentationErrorHandler = (error: DeliveryFailure, event: WorkflowEvent) => void;
9
+ /** Server-only client options. Omit values to read FLOWMARK_* environment variables. */
10
+ export interface FlowmarkConfig {
11
+ /**
12
+ * Secret project write key. Defaults to FLOWMARK_API_KEY.
13
+ * Server only — never NEXT_PUBLIC_* or a browser bundle.
14
+ */
15
+ readonly apiKey?: string;
16
+ /**
17
+ * Flowmark API origin, not an ingestion path.
18
+ * Defaults to FLOWMARK_API_URL or http://localhost:3003 outside production.
19
+ * Production requires an explicit origin. HTTPS is required except on localhost.
20
+ */
21
+ readonly apiUrl?: string;
22
+ /** Optional deployment environment added to each started event. */
23
+ readonly environment?: string;
24
+ /** Optional release/version added to each started event. */
25
+ readonly release?: string;
26
+ /** Receives typed failures. If omitted, the SDK logs delivery warnings. */
27
+ readonly onInstrumentationError?: InstrumentationErrorHandler;
28
+ }
29
+ /** Optional metadata for one execution of a workflow. */
30
+ export interface WorkflowRunOptions {
31
+ /**
32
+ * ID for this execution. A UUID is generated if omitted.
33
+ * Same name + same id on a later request continues this run (second started is ignored).
34
+ * Do not call done() until that whole process ends.
35
+ * Do not reuse a durable entity id that outlives one execution; put those in properties.
36
+ */
37
+ readonly id?: WorkflowRunId;
38
+ /** Bounded JSON-safe context sent with the start event. Never include secrets or unnecessary personal data. */
39
+ readonly properties?: WorkflowProperties;
40
+ /** Optional deployment environment; overrides the client default. */
41
+ readonly environment?: string;
42
+ /** Optional release/version; overrides the client default. */
43
+ readonly release?: string;
44
+ /**
45
+ * Explicit identifier grouping related runs. Keep it bounded and non-sensitive;
46
+ * it is not an automatic trace ID or proof of a causal relationship.
47
+ */
48
+ readonly correlationId?: WorkflowCorrelationId;
49
+ /**
50
+ * Parent run's external SDK run ID, explicitly propagated by application code.
51
+ * It is not the dashboard's internal UUID. Browser-supplied values are
52
+ * untrusted and must not be treated as identity.
53
+ */
54
+ readonly parentRunId?: WorkflowRunId;
55
+ }
56
+ /** Optional context attached to a semantic step without executing business logic. */
57
+ export interface WorkflowStepOptions {
58
+ readonly properties?: WorkflowProperties;
59
+ }
60
+ /** Optional JSON-safe result recorded when the workflow completes. */
61
+ export interface WorkflowDoneOptions {
62
+ readonly result?: WorkflowResult;
63
+ }
64
+ /**
65
+ * Structured terminal failure. `code` is required; `result` is the same kind of
66
+ * bounded business summary accepted by done().
67
+ */
68
+ export interface WorkflowFailOptions extends WorkflowFailure {
69
+ readonly result?: WorkflowResult;
70
+ }
71
+ /** Optional context attached when an operation starts. */
72
+ export interface WorkflowOperationOptions {
73
+ readonly properties?: WorkflowProperties;
74
+ }
75
+ /** Explicit lifecycle handle for a single independently identified operation. */
76
+ export interface WorkflowOperation {
77
+ /** Unique UUID identifying this operation event family. */
78
+ readonly operationId: string;
79
+ /** Marks the operation successful and records its monotonic duration. */
80
+ done(): void;
81
+ /** Marks the operation failed and records its monotonic duration. */
82
+ fail(failure: WorkflowFailure): void;
83
+ }
84
+ /** Advanced custom-transport options. Normal consumers should use createFlowmark(). */
85
+ export interface WorkflowOptions extends WorkflowRunOptions {
86
+ /** Required, unique execution ID for the low-level workflow() API. */
87
+ readonly id: WorkflowRunId;
88
+ /** Effect-based event destination; not required by configured clients. */
89
+ readonly transport: WorkflowTransport;
90
+ /** Receives typed failures without interrupting the host application. */
91
+ readonly onInstrumentationError?: InstrumentationErrorHandler;
92
+ }
93
+ /**
94
+ * Markers for one workflow run. Delivery happens asynchronously in the background.
95
+ * Properties/results must be JSON-safe objects within the shared @flowmarkdev/core
96
+ * limits: 5 nested levels, 128 keys, 128-character keys, 2,048-character
97
+ * strings, and 16 KiB encoded per object.
98
+ */
99
+ export interface Flow {
100
+ /** This run's SDK identifier (options.id, or a generated UUID). */
101
+ readonly runId: WorkflowRunId;
102
+ /**
103
+ * Records a meaningful checkpoint. Does not execute the step's business logic.
104
+ * Calls after done() or fail() are ignored.
105
+ * @param name A stable semantic name, such as "payment-created".
106
+ * @param options Optional step-local bounded JSON properties.
107
+ */
108
+ step(name: WorkflowStepName, options?: WorkflowStepOptions): void;
109
+ /**
110
+ * Ends the run as successful. Call only when the whole process is finished —
111
+ * not in the first handler of a multi-request flow.
112
+ * If operations are open, completion waits until they close. First terminal wins.
113
+ */
114
+ done(options?: WorkflowDoneOptions): void;
115
+ /**
116
+ * Ends the run as failed without throwing. Call only when the whole process
117
+ * is finished. `code` is required. Can supersede a pending done().
118
+ */
119
+ fail(options: WorkflowFailOptions): void;
120
+ /**
121
+ * Records an error without terminating the run.
122
+ * `handled` describes application handling; only fail() makes the run failed.
123
+ */
124
+ error(error: WorkflowError): void;
125
+ /**
126
+ * Appends a shallow context amendment; previous event history is never rewritten.
127
+ * When keys repeat, the newest value applies to the run's current context.
128
+ */
129
+ setProperties(properties: WorkflowProperties): void;
130
+ /**
131
+ * Starts an independently identified operation.
132
+ * Operations may overlap; each returned handle must be closed by its caller.
133
+ * An operation callback reports its own success/failure and preserves the
134
+ * callback's result or original rejection; it never fails the workflow.
135
+ */
136
+ operation(name: WorkflowStepName, options?: WorkflowOperationOptions): WorkflowOperation;
137
+ operation<T>(name: WorkflowStepName, callback: () => PromiseLike<T>, options?: WorkflowOperationOptions): Promise<T>;
138
+ /** Records an absolute progress snapshot; invalid values are rejected by validation. */
139
+ progress(progress: WorkflowProgress): void;
140
+ }
141
+ /** Ordinary TypeScript client; Effect execution is managed internally. */
142
+ export interface FlowmarkClient {
143
+ /**
144
+ * Starts a run, or continues one when `options.id` matches an existing run
145
+ * of the same workflow name. Omit `id` for a new execution.
146
+ * Persist `flow.runId` if a later request should append to this run.
147
+ * @param name Stable process name, such as "checkout.order" or "expedition.run".
148
+ * @throws FlowmarkConfigError If configuration/context is invalid or the client was shut down.
149
+ * @example
150
+ * const flow = flowmark.workflow("checkout.order", { properties: { orderId } })
151
+ * flow.step("payment-captured")
152
+ * flow.done({ result: { shipmentId } })
153
+ */
154
+ workflow(name: WorkflowName, options?: WorkflowRunOptions): Flow;
155
+ /**
156
+ * Waits for pending deliveries without closing the client.
157
+ * Rejects with FlowmarkDeliveryError if delivery failed or the queue overflowed.
158
+ * Browser clients can use this before full-page navigation; it does not guarantee offline delivery.
159
+ */
160
+ flush(): Promise<void>;
161
+ /**
162
+ * Stops accepting workflows, drains pending deliveries, and releases SDK resources.
163
+ * Call before a Node.js process/job exits. The Next.js adapter handles this automatically.
164
+ * Rejects with FlowmarkDeliveryError when draining reports delivery failures.
165
+ */
166
+ shutdown(): Promise<void>;
167
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { WorkflowFailure } from "@flowmarkdev/core";
2
+ /** Maps a thrown callback value to a structured operation failure. */
3
+ export declare const failureFromUnknown: (cause: unknown) => WorkflowFailure;
@@ -0,0 +1,36 @@
1
+ const codeLimit = 128;
2
+ const messageLimit = 2048;
3
+ const isRecord = (value) => typeof value === "object" && value !== null;
4
+ const boundedCode = (value) => typeof value === "string" &&
5
+ value.length > 0 &&
6
+ value.length <= codeLimit &&
7
+ value.trim().length > 0
8
+ ? value
9
+ : undefined;
10
+ const boundedMessage = (value) => typeof value === "string" && value.length > 0
11
+ ? value.slice(0, messageLimit)
12
+ : undefined;
13
+ /** Maps a thrown callback value to a structured operation failure. */
14
+ export const failureFromUnknown = (cause) => {
15
+ if (isRecord(cause)) {
16
+ const code = boundedCode(cause.code);
17
+ if (code !== undefined) {
18
+ return {
19
+ code,
20
+ ...(boundedMessage(cause.message) === undefined
21
+ ? {}
22
+ : { message: boundedMessage(cause.message) }),
23
+ ...(typeof cause.retryable === "boolean"
24
+ ? { retryable: cause.retryable }
25
+ : {}),
26
+ };
27
+ }
28
+ }
29
+ if (cause instanceof Error) {
30
+ const message = boundedMessage(cause.message);
31
+ return message === undefined
32
+ ? { code: "operation_failed" }
33
+ : { code: "operation_failed", message };
34
+ }
35
+ return { code: "operation_failed" };
36
+ };
@@ -0,0 +1,5 @@
1
+ import type { WorkflowOperationOptions } from "../types/index.js";
2
+ export declare const splitOperationArgs: <T>(callbackOrOptions?: (() => PromiseLike<T>) | WorkflowOperationOptions, options?: WorkflowOperationOptions) => {
3
+ readonly callback?: () => PromiseLike<T>;
4
+ readonly options?: WorkflowOperationOptions;
5
+ };
@@ -0,0 +1,3 @@
1
+ export const splitOperationArgs = (callbackOrOptions, options) => typeof callbackOrOptions === "function"
2
+ ? { callback: callbackOrOptions, options }
3
+ : { options: callbackOrOptions };
@@ -0,0 +1,2 @@
1
+ import type { WorkflowOperation } from "../types/index.js";
2
+ export declare function withOperationCallback<T>(operation: WorkflowOperation, callback: () => PromiseLike<T>): Promise<T>;
@@ -0,0 +1,18 @@
1
+ import { failureFromUnknown } from "./failure-from-unknown.js";
2
+ export function withOperationCallback(operation, callback) {
3
+ let result;
4
+ try {
5
+ result = callback();
6
+ }
7
+ catch (cause) {
8
+ operation.fail(failureFromUnknown(cause));
9
+ return Promise.reject(cause);
10
+ }
11
+ return Promise.resolve(result).then((value) => {
12
+ operation.done();
13
+ return value;
14
+ }, (cause) => {
15
+ operation.fail(failureFromUnknown(cause));
16
+ throw cause;
17
+ });
18
+ }
package/package.json CHANGED
@@ -1,6 +1,78 @@
1
1
  {
2
2
  "name": "@flowmarkdev/node",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0-alpha.1",
4
+ "description": "Workflow observability for Node.js application code",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js"
13
+ },
14
+ "./next": {
15
+ "types": "./dist/adapters/next.d.ts",
16
+ "import": "./dist/adapters/next.js"
17
+ },
18
+ "./browser": {
19
+ "types": "./dist/browser/index.d.ts",
20
+ "import": "./dist/browser/index.js"
21
+ },
22
+ "./next/proxy": {
23
+ "types": "./dist/adapters/proxy.d.ts",
24
+ "import": "./dist/adapters/proxy.js"
25
+ },
26
+ "./proxy": {
27
+ "types": "./dist/adapters/proxy.d.ts",
28
+ "import": "./dist/adapters/proxy.js"
29
+ },
30
+ "./package.json": "./package.json"
31
+ },
32
+ "files": [
33
+ "dist",
34
+ "README.md",
35
+ "LICENSE"
36
+ ],
37
+ "publishConfig": {
38
+ "access": "public"
39
+ },
40
+ "repository": {
41
+ "type": "git",
42
+ "url": "git+https://github.com/Mumma6/flowmark.git",
43
+ "directory": "packages/sdk"
44
+ },
45
+ "homepage": "https://docs.flowmark.dev",
46
+ "bugs": {
47
+ "url": "https://github.com/Mumma6/flowmark/issues"
48
+ },
49
+ "engines": {
50
+ "node": ">=20.19"
51
+ },
52
+ "dependencies": {
53
+ "@effect/platform": "^0.97.2",
54
+ "effect": "^3.22.4",
55
+ "@flowmarkdev/core": "0.1.0-alpha.1"
56
+ },
57
+ "peerDependencies": {
58
+ "next": ">=16"
59
+ },
60
+ "peerDependenciesMeta": {
61
+ "next": {
62
+ "optional": true
63
+ }
64
+ },
65
+ "devDependencies": {
66
+ "next": "^16.4.2",
67
+ "@types/node": "^22.18.6",
68
+ "typescript": "^5.9.2",
69
+ "vitest": "^3.2.4"
70
+ },
71
+ "scripts": {
72
+ "dev": "tsc -p tsconfig.build.json --watch --preserveWatchOutput",
73
+ "build": "tsc -p tsconfig.build.json",
74
+ "lint": "eslint src test",
75
+ "test": "vitest run",
76
+ "typecheck": "tsc -p tsconfig.json --noEmit"
77
+ }
6
78
  }