@systemfsoftware/effect-spec-runtime 0.0.0 → 0.1.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 CHANGED
@@ -1,5 +1,11 @@
1
1
  # @systemfsoftware/effect-spec-runtime
2
2
 
3
+ ## 0.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - `Suite`, `Register` and `TaskRef` functions that took their subject first can now also be called data-last. Existing calls keep working.
8
+
3
9
  ## 0.0.0
4
10
 
5
11
  ### Minor Changes
package/dist/index.d.ts CHANGED
@@ -12,9 +12,18 @@ type DescribeMode = 'describe' | 'skip' | 'only';
12
12
  * Keeps the caller's suite options verbatim when present; a suite declared
13
13
  * without options is registered through the two-argument collector call.
14
14
  */
15
- declare const invokeDescribe: (mode: DescribeMode, suiteName: string, suiteOpts: Options | undefined, fn: () => void) => void;
16
- declare const selectCaseRunner: (methodsIt: Vitest.Methods, mode: RegisterMode, useLiveClock: boolean) => Vitest.Test<Scope.Scope>;
17
- declare const selectLayeredRunner: <R>(scopedIt: Pick<Vitest.MethodsNonLive<R>, 'effect'>, mode: RegisterMode) => Vitest.Test<R | Scope.Scope>;
15
+ declare const invokeDescribe: {
16
+ (mode: DescribeMode, suiteName: string, suiteOpts: Options | undefined): (fn: () => void) => void;
17
+ (mode: DescribeMode, suiteName: string, suiteOpts: Options | undefined, fn: () => void): void;
18
+ };
19
+ declare const selectCaseRunner: {
20
+ (mode: RegisterMode, useLiveClock: boolean): (methodsIt: Vitest.Methods) => Vitest.Test<Scope.Scope>;
21
+ (methodsIt: Vitest.Methods, mode: RegisterMode, useLiveClock: boolean): Vitest.Test<Scope.Scope>;
22
+ };
23
+ declare const selectLayeredRunner: {
24
+ <R>(mode: RegisterMode): (scopedIt: Pick<Vitest.MethodsNonLive<R>, 'effect'>) => Vitest.Test<R | Scope.Scope>;
25
+ <R>(scopedIt: Pick<Vitest.MethodsNonLive<R>, 'effect'>, mode: RegisterMode): Vitest.Test<R | Scope.Scope>;
26
+ };
18
27
  declare namespace Suite_d_exports {
19
28
  export { Bindings, Config, DescribeMode, LayerOptions, Options, RegisterFn, RegisterMode, Shared, open, openCase, openShared, openSharedCase };
20
29
  }
@@ -38,10 +47,22 @@ interface Shared<R> {
38
47
  interface RegisterFn<B, E, R> {
39
48
  (name: string, body: Effect.Effect<B, E, R>, mode: RegisterMode): void;
40
49
  }
41
- declare const open: <B, E, C>(bindings: Bindings, config: Config, use: (register: RegisterFn<B, E, never>, propIt: Vitest.MethodsNonLive<never>) => C) => void;
42
- declare const openShared: <B, E, RShared, C>(bindings: Bindings, config: Config, shared: Shared<RShared>, use: (register: RegisterFn<B, E, RShared>, propIt: Vitest.MethodsNonLive<RShared>) => C) => void;
43
- declare const openCase: <B, E, RFresh, RFreshReq extends Scope.Scope, C>(bindings: Bindings, config: Config, caseLayer: Layer.Layer<RFresh, never, RFreshReq>, use: (register: RegisterFn<B, E, RFresh | RFreshReq>, propIt: Vitest.MethodsNonLive<never>) => C) => void;
44
- declare const openSharedCase: <B, E, RShared, RFresh, RFreshReq extends RShared | Scope.Scope, C>(bindings: Bindings, config: Config, shared: Shared<RShared>, caseLayer: Layer.Layer<RFresh, never, RFreshReq>, use: (register: RegisterFn<B, E, RShared | RFresh | RFreshReq>, propIt: Vitest.MethodsNonLive<RShared>) => C) => void;
50
+ declare const open: {
51
+ <B, E, C>(config: Config, use: (register: RegisterFn<B, E, never>, propIt: Vitest.MethodsNonLive<never>) => C): (bindings: Bindings) => void;
52
+ <B, E, C>(bindings: Bindings, config: Config, use: (register: RegisterFn<B, E, never>, propIt: Vitest.MethodsNonLive<never>) => C): void;
53
+ };
54
+ declare const openShared: {
55
+ <B, E, RShared, C>(config: Config, shared: Shared<RShared>, use: (register: RegisterFn<B, E, RShared>, propIt: Vitest.MethodsNonLive<RShared>) => C): (bindings: Bindings) => void;
56
+ <B, E, RShared, C>(bindings: Bindings, config: Config, shared: Shared<RShared>, use: (register: RegisterFn<B, E, RShared>, propIt: Vitest.MethodsNonLive<RShared>) => C): void;
57
+ };
58
+ declare const openCase: {
59
+ <B, E, RFresh, RFreshReq extends Scope.Scope, C>(config: Config, caseLayer: Layer.Layer<RFresh, never, RFreshReq>, use: (register: RegisterFn<B, E, RFresh | RFreshReq>, propIt: Vitest.MethodsNonLive<never>) => C): (bindings: Bindings) => void;
60
+ <B, E, RFresh, RFreshReq extends Scope.Scope, C>(bindings: Bindings, config: Config, caseLayer: Layer.Layer<RFresh, never, RFreshReq>, use: (register: RegisterFn<B, E, RFresh | RFreshReq>, propIt: Vitest.MethodsNonLive<never>) => C): void;
61
+ };
62
+ declare const openSharedCase: {
63
+ <B, E, RShared, RFresh, RFreshReq extends RShared | Scope.Scope, C>(config: Config, shared: Shared<RShared>, caseLayer: Layer.Layer<RFresh, never, RFreshReq>, use: (register: RegisterFn<B, E, RShared | RFresh | RFreshReq>, propIt: Vitest.MethodsNonLive<RShared>) => C): (bindings: Bindings) => void;
64
+ <B, E, RShared, RFresh, RFreshReq extends RShared | Scope.Scope, C>(bindings: Bindings, config: Config, shared: Shared<RShared>, caseLayer: Layer.Layer<RFresh, never, RFreshReq>, use: (register: RegisterFn<B, E, RShared | RFresh | RFreshReq>, propIt: Vitest.MethodsNonLive<RShared>) => C): void;
65
+ };
45
66
  declare namespace TaskRef_service_d_exports {
46
67
  export { RawVitestTaskRef, VitestTaskContext, VitestTaskRef, provideTaskRef };
47
68
  }
@@ -53,6 +74,9 @@ interface VitestTaskContext<Ann = unknown> {
53
74
  }
54
75
  declare const VitestTaskRef: Context.Reference<VitestTaskContext | null>;
55
76
  declare const RawVitestTaskRef: Context.Reference<VitestTaskContext | null>;
56
- declare const provideTaskRef: <A, E, R, Ctx>(effect: Effect.Effect<A, E, R>, ctx: Ctx) => Effect.Effect<A, E, R>;
77
+ declare const provideTaskRef: {
78
+ <Ctx>(ctx: Ctx): <A, E, R>(effect: Effect.Effect<A, E, R>) => Effect.Effect<A, E, R>;
79
+ <A, E, R, Ctx>(effect: Effect.Effect<A, E, R>, ctx: Ctx): Effect.Effect<A, E, R>;
80
+ };
57
81
  //#endregion
58
82
  export { Suite_d_exports as Suite, TaskRef_service_d_exports as TaskRef };
package/dist/index.mjs CHANGED
@@ -1,16 +1,13 @@
1
1
  import { t as __exportAll } from "./rolldown-runtime-D7D4PA-g.mjs";
2
2
  import { Context, Effect, Layer, Match, Option } from "effect";
3
+ import { dual } from "effect/Function";
3
4
  //#region src/Register.ts
4
5
  const selectDescribe = (mode) => ({
5
6
  skip: describe.skip,
6
7
  only: describe.only,
7
8
  describe
8
9
  })[mode];
9
- /**
10
- * Keeps the caller's suite options verbatim when present; a suite declared
11
- * without options is registered through the two-argument collector call.
12
- */
13
- const invokeDescribe = (mode, suiteName, suiteOpts, fn) => Option.match(Option.fromUndefinedOr(suiteOpts), {
10
+ const invokeDescribeImpl = (mode, suiteName, suiteOpts, fn) => Option.match(Option.fromUndefinedOr(suiteOpts), {
14
11
  onNone: () => {
15
12
  selectDescribe(mode)(suiteName, fn);
16
13
  },
@@ -18,6 +15,11 @@ const invokeDescribe = (mode, suiteName, suiteOpts, fn) => Option.match(Option.f
18
15
  selectDescribe(mode)(suiteName, options, fn);
19
16
  }
20
17
  });
18
+ /**
19
+ * Keeps the caller's suite options verbatim when present; a suite declared
20
+ * without options is registered through the two-argument collector call.
21
+ */
22
+ const invokeDescribe = dual(4, invokeDescribeImpl);
21
23
  const pickTester = (family, mode) => ({
22
24
  skip: family.skip,
23
25
  only: family.only,
@@ -28,8 +30,10 @@ const pickTester = (family, mode) => ({
28
30
  * shares the suite's controlled clock.
29
31
  */
30
32
  const caseClockFamily = (methodsIt, useLiveClock) => Match.value(useLiveClock).pipe(Match.when(true, () => methodsIt.live), Match.when(false, () => methodsIt.effect), Match.exhaustive);
31
- const selectCaseRunner = (methodsIt, mode, useLiveClock) => pickTester(caseClockFamily(methodsIt, useLiveClock), mode);
32
- const selectLayeredRunner = (scopedIt, mode) => pickTester(scopedIt.effect, mode);
33
+ const selectCaseRunnerImpl = (methodsIt, mode, useLiveClock) => pickTester(caseClockFamily(methodsIt, useLiveClock), mode);
34
+ const selectCaseRunner = dual(3, selectCaseRunnerImpl);
35
+ const selectLayeredRunnerImpl = (scopedIt, mode) => pickTester(scopedIt.effect, mode);
36
+ const selectLayeredRunner = dual(2, selectLayeredRunnerImpl);
33
37
  //#endregion
34
38
  //#region src/TaskRef.service.ts
35
39
  var TaskRef_service_exports = /* @__PURE__ */ __exportAll({
@@ -43,7 +47,8 @@ const isPlainTaskContext = (ctx) => typeof ctx === "object" && ctx !== null;
43
47
  const isTaskContext = (ctx) => typeof ctx === "object" ? ctx !== null : typeof ctx === "function";
44
48
  const readTaskContext = (ctx) => Option.getOrNull(Option.liftPredicate(ctx, isPlainTaskContext));
45
49
  const readRawTaskContext = (ctx) => Option.getOrNull(Option.liftPredicate(ctx, isTaskContext));
46
- const provideTaskRef = (effect, ctx) => effect.pipe(Effect.provideService(VitestTaskRef, readTaskContext(ctx)), Effect.provideService(RawVitestTaskRef, readRawTaskContext(ctx)));
50
+ const provideTaskRefImpl = (effect, ctx) => effect.pipe(Effect.provideService(VitestTaskRef, readTaskContext(ctx)), Effect.provideService(RawVitestTaskRef, readRawTaskContext(ctx)));
51
+ const provideTaskRef = dual(2, provideTaskRefImpl);
47
52
  //#endregion
48
53
  //#region src/Suite.ts
49
54
  var Suite_exports = /* @__PURE__ */ __exportAll({
@@ -59,29 +64,33 @@ const unlayeredRegister = (methodsIt, config, caseLayer) => (name, body, mode) =
59
64
  const layeredRegister = (scopedIt, caseLayer) => (name, body, mode) => {
60
65
  selectLayeredRunner(scopedIt, mode)(name, (ctx) => provideTaskRef(body.pipe(Effect.provide(Layer.fresh(caseLayer))), ctx));
61
66
  };
62
- const open = (bindings, config, use) => {
67
+ const openImpl = (bindings, config, use) => {
63
68
  invokeDescribe(config.describe, config.name, config.options, () => {
64
69
  use(unlayeredRegister(bindings.it, config, Layer.empty), bindings.it);
65
70
  });
66
71
  };
67
- const openShared = (bindings, config, shared, use) => {
72
+ const open = dual(3, openImpl);
73
+ const openSharedImpl = (bindings, config, shared, use) => {
68
74
  invokeDescribe(config.describe, config.name, config.options, () => {
69
75
  bindings.layer(shared.layer, layerSetupOptions(shared.excludeTestServices, config.liveClock))((scopedIt) => {
70
76
  use(layeredRegister(scopedIt, Layer.empty), scopedIt);
71
77
  });
72
78
  });
73
79
  };
74
- const openCase = (bindings, config, caseLayer, use) => {
80
+ const openShared = dual(4, openSharedImpl);
81
+ const openCaseImpl = (bindings, config, caseLayer, use) => {
75
82
  invokeDescribe(config.describe, config.name, config.options, () => {
76
83
  use(unlayeredRegister(bindings.it, config, caseLayer), bindings.it);
77
84
  });
78
85
  };
79
- const openSharedCase = (bindings, config, shared, caseLayer, use) => {
86
+ const openCase = dual(4, openCaseImpl);
87
+ const openSharedCaseImpl = (bindings, config, shared, caseLayer, use) => {
80
88
  invokeDescribe(config.describe, config.name, config.options, () => {
81
89
  bindings.layer(shared.layer, layerSetupOptions(shared.excludeTestServices, config.liveClock))((scopedIt) => {
82
90
  use(layeredRegister(scopedIt, caseLayer), scopedIt);
83
91
  });
84
92
  });
85
93
  };
94
+ const openSharedCase = dual(5, openSharedCaseImpl);
86
95
  //#endregion
87
96
  export { Suite_exports as Suite, TaskRef_service_exports as TaskRef };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@systemfsoftware/effect-spec-runtime",
3
3
  "license": "Apache-2.0",
4
- "version": "0.0.0",
4
+ "version": "0.1.0",
5
5
  "author": "Ryan Lee <drdgvhbh@gmail.com>",
6
6
  "repository": {
7
7
  "type": "git",
@@ -34,6 +34,10 @@
34
34
  "devDependencies": {
35
35
  "@effect/vitest": "4.0.0-rc.116",
36
36
  "@systemfsoftware/arethetypeswrong-cli": "^4.2.0",
37
+ "@systemfsoftware/oxlint-config-recommended": "^2.0.0",
38
+ "@systemfsoftware/tsconfig": "^2.0.0",
39
+ "@systemfsoftware/tsdown-config": "^0.1.0",
40
+ "@systemfsoftware/vitest-config": "^0.1.0",
37
41
  "@types/node": "^26",
38
42
  "effect": "4.0.0-rc.116",
39
43
  "fast-check": "^4",
@@ -41,11 +45,7 @@
41
45
  "rimraf": "^6.1.3",
42
46
  "tsdown": "^0.23.0",
43
47
  "tstyche": "^7.2.5",
44
- "vitest": "^5",
45
- "@systemfsoftware/tsconfig": "^1.3.6",
46
- "@systemfsoftware/vitest-config": "^0.1.0",
47
- "@systemfsoftware/oxlint-config-recommended": "^1.1.1",
48
- "@systemfsoftware/tsdown-config": "^0.1.0"
48
+ "vitest": "^5"
49
49
  },
50
50
  "peerDependencies": {
51
51
  "@effect/vitest": "4.0.0-rc.116",
@@ -58,7 +58,7 @@
58
58
  "scripts": {
59
59
  "clean": "rimraf dist",
60
60
  "build": "tsdown -l warn",
61
- "typecheck": "tsc --noEmit --incremental",
61
+ "typecheck": "tsc -b",
62
62
  "test": "vitest run",
63
63
  "test:types": "TSTYCHE_TYPESCRIPT_MODULE=tstyche-typescript tstyche",
64
64
  "lint": "f=${OXLINT_FORMAT:-${AGENT:+agent}}; oxlint . --format=${f:-default}",