effect 4.0.0-beta.60 → 4.0.0-beta.63

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 (35) hide show
  1. package/dist/Effect.d.ts +82 -0
  2. package/dist/Effect.d.ts.map +1 -1
  3. package/dist/Effect.js +82 -0
  4. package/dist/Effect.js.map +1 -1
  5. package/dist/index.d.ts +1 -1
  6. package/dist/index.js +1 -1
  7. package/dist/internal/effect.js +17 -1
  8. package/dist/internal/effect.js.map +1 -1
  9. package/dist/unstable/cluster/K8sHttpClient.d.ts +1 -1
  10. package/dist/unstable/cluster/K8sHttpClient.js +1 -1
  11. package/dist/unstable/cluster/K8sHttpClient.js.map +1 -1
  12. package/dist/unstable/httpapi/HttpApiBuilder.d.ts +1 -1
  13. package/dist/unstable/httpapi/HttpApiBuilder.d.ts.map +1 -1
  14. package/dist/unstable/httpapi/HttpApiBuilder.js +27 -17
  15. package/dist/unstable/httpapi/HttpApiBuilder.js.map +1 -1
  16. package/dist/unstable/httpapi/HttpApiClient.d.ts.map +1 -1
  17. package/dist/unstable/httpapi/HttpApiClient.js +2 -1
  18. package/dist/unstable/httpapi/HttpApiClient.js.map +1 -1
  19. package/dist/unstable/httpapi/HttpApiTest.d.ts +20 -0
  20. package/dist/unstable/httpapi/HttpApiTest.d.ts.map +1 -0
  21. package/dist/unstable/httpapi/HttpApiTest.js +54 -0
  22. package/dist/unstable/httpapi/HttpApiTest.js.map +1 -0
  23. package/dist/unstable/httpapi/index.d.ts +4 -0
  24. package/dist/unstable/httpapi/index.d.ts.map +1 -1
  25. package/dist/unstable/httpapi/index.js +4 -0
  26. package/dist/unstable/httpapi/index.js.map +1 -1
  27. package/package.json +1 -1
  28. package/src/Effect.ts +88 -0
  29. package/src/index.ts +1 -1
  30. package/src/internal/effect.ts +28 -1
  31. package/src/unstable/cluster/K8sHttpClient.ts +3 -3
  32. package/src/unstable/httpapi/HttpApiBuilder.ts +38 -22
  33. package/src/unstable/httpapi/HttpApiClient.ts +4 -3
  34. package/src/unstable/httpapi/HttpApiTest.ts +95 -0
  35. package/src/unstable/httpapi/index.ts +5 -0
package/dist/Effect.d.ts CHANGED
@@ -7143,6 +7143,50 @@ export declare const orElseSucceed: {
7143
7143
  */
7144
7144
  <A, E, R, A2>(self: Effect<A, E, R>, evaluate: LazyArg<A2>): Effect<A | A2, never, R>;
7145
7145
  };
7146
+ /**
7147
+ * Runs a sequence of effects and returns the result of the first successful
7148
+ * one.
7149
+ *
7150
+ * **Details**
7151
+ *
7152
+ * This function executes the provided effects in sequence, stopping at the
7153
+ * first success. If an effect succeeds, its result is returned immediately and
7154
+ * no further effects in the sequence are executed.
7155
+ *
7156
+ * If all effects fail, the returned effect fails with the error from the last
7157
+ * effect. If the collection is empty, the returned effect defects with an
7158
+ * `Error` whose message is `"Received an empty collection of effects"`.
7159
+ *
7160
+ * **When to Use**
7161
+ *
7162
+ * Use `firstSuccessOf` when you have prioritized fallback strategies, such as
7163
+ * attempting multiple APIs, reading configuration from several sources, or
7164
+ * trying alternative resource locations in order.
7165
+ *
7166
+ * @example
7167
+ * ```ts
7168
+ * import { Effect } from "effect"
7169
+ *
7170
+ * const primary = Effect.fail("primary unavailable")
7171
+ * const secondary = Effect.succeed("secondary result")
7172
+ * const tertiary = Effect.sync(() => {
7173
+ * throw new Error("not evaluated")
7174
+ * })
7175
+ *
7176
+ * const program = Effect.firstSuccessOf([
7177
+ * primary,
7178
+ * secondary,
7179
+ * tertiary
7180
+ * ])
7181
+ *
7182
+ * console.log(Effect.runSync(program))
7183
+ * // Output: "secondary result"
7184
+ * ```
7185
+ *
7186
+ * @since 2.0.0
7187
+ * @category Fallback
7188
+ */
7189
+ export declare const firstSuccessOf: <Eff extends Effect<any, any, any>>(effects: Iterable<Eff>) => Effect<Success<Eff>, Error<Eff>, Services<Eff>>;
7146
7190
  /**
7147
7191
  * Adds a time limit to an effect, triggering a timeout if the effect exceeds
7148
7192
  * the duration.
@@ -11100,6 +11144,44 @@ export declare const scopedWith: <A, E, R>(f: (scope: Scope) => Effect<A, E, R>)
11100
11144
  export declare const acquireRelease: <A, E, R, R2>(acquire: Effect<A, E, R>, release: (a: A, exit: Exit.Exit<unknown, unknown>) => Effect<unknown, never, R2>, options?: {
11101
11145
  readonly interruptible?: boolean;
11102
11146
  }) => Effect<A, E, R | R2 | Scope>;
11147
+ /**
11148
+ * This function constructs a scoped resource from an Effect that acquires a
11149
+ * disposable value.
11150
+ *
11151
+ * The resource is automatically disposed when the surrounding
11152
+ * {@link Scope} is closed, using {@link Symbol.dispose} for
11153
+ * synchronous disposables or {@link Symbol.asyncDispose} for asynchronous
11154
+ * disposables.
11155
+ *
11156
+ * This is similar to {@link acquireRelease}, but uses the standard
11157
+ * JavaScript disposal protocal instead of requiring an explicit release
11158
+ * function.
11159
+ *
11160
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/using}
11161
+ *
11162
+ * @example
11163
+ * ```ts
11164
+ * import sqlite from "node:sqlite";
11165
+ * import { Effect } from "effect";
11166
+ *
11167
+ * const program = Effect.scoped(
11168
+ * Effect.gen(function* () {
11169
+ * // acquire database connection
11170
+ * // database will be closed when the scope is closed
11171
+ * const db = yield* Effect.acquireDisposable(
11172
+ * Effect.sync(() => new sqlite.DatabaseSync(":memory:"))
11173
+ * )
11174
+ *
11175
+ * const row = db.prepare("SELECT 1 AS value").get()
11176
+ * yield* Effect.log(row) // { value: 1 }
11177
+ * })
11178
+ * )
11179
+ * ```
11180
+ *
11181
+ * @since 4.0.0
11182
+ * @category Resource Management & Finalization
11183
+ */
11184
+ export declare const acquireDisposable: <A extends AsyncDisposable | Disposable, E, R>(acquire: Effect<A, E, R>) => Effect<A, E, R | Scope>;
11103
11185
  /**
11104
11186
  * This function is used to ensure that an `Effect` value that represents the
11105
11187
  * acquisition of a resource (for example, opening a file, launching a thread,