@distilled.cloud/forgejo 1.0.0-rc.12 → 1.0.0-rc.13

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/README.md CHANGED
@@ -52,7 +52,7 @@ DISTILLED_SPECS_LOCAL=1 pnpm generate forgejo
52
52
  import * as Forgejo from "@distilled.cloud/forgejo";
53
53
 
54
54
  const program = Effect.gen(function* () {
55
- const repo = yield* Forgejo.Services.repository.repoGet({
55
+ const repo = yield* Forgejo.repository.repoGet({
56
56
  owner: "acme",
57
57
  repo: "api",
58
58
  });
package/lib/index.d.ts CHANGED
@@ -13,7 +13,7 @@
13
13
  * ```ts
14
14
  * import * as Forgejo from "@distilled.cloud/forgejo";
15
15
  *
16
- * const repo = yield* Forgejo.Services.repository.repoGet({
16
+ * const repo = yield* Forgejo.repository.repoGet({
17
17
  * owner: "acme",
18
18
  * repo: "api",
19
19
  * });
@@ -24,5 +24,5 @@ export * from "./errors.ts";
24
24
  export * as T from "./traits.ts";
25
25
  export { ForgejoProtocol, type ForgejoOpError, type ForgejoOpContext, } from "./protocol.ts";
26
26
  export * as Retry from "./retry.ts";
27
- export * as Services from "./services/index.ts";
27
+ export * from "./services/index.ts";
28
28
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,OAAO,KAAK,CAAC,MAAM,aAAa,CAAC;AACjC,OAAO,EACL,eAAe,EACf,KAAK,cAAc,EACnB,KAAK,gBAAgB,GACtB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,OAAO,KAAK,CAAC,MAAM,aAAa,CAAC;AACjC,OAAO,EACL,eAAe,EACf,KAAK,cAAc,EACnB,KAAK,gBAAgB,GACtB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,cAAc,qBAAqB,CAAC"}
package/lib/index.js CHANGED
@@ -13,7 +13,7 @@
13
13
  * ```ts
14
14
  * import * as Forgejo from "@distilled.cloud/forgejo";
15
15
  *
16
- * const repo = yield* Forgejo.Services.repository.repoGet({
16
+ * const repo = yield* Forgejo.repository.repoGet({
17
17
  * owner: "acme",
18
18
  * repo: "api",
19
19
  * });
@@ -24,5 +24,5 @@ export * from "./errors.js";
24
24
  export * as T from "./traits.js";
25
25
  export { ForgejoProtocol, } from "./protocol.js";
26
26
  export * as Retry from "./retry.js";
27
- export * as Services from "./services/index.js";
27
+ export * from "./services/index.js";
28
28
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,OAAO,KAAK,CAAC,MAAM,aAAa,CAAC;AACjC,OAAO,EACL,eAAe,GAGhB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,KAAK,QAAQ,MAAM,qBAAqB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,OAAO,KAAK,CAAC,MAAM,aAAa,CAAC;AACjC,OAAO,EACL,eAAe,GAGhB,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,cAAc,qBAAqB,CAAC"}
package/lib/protocol.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type * as Layer from "effect/Layer";
2
- import type * as HttpClient from "effect/unstable/http/HttpClient";
3
- import type * as HttpClientError from "effect/unstable/http/HttpClientError";
2
+ import type * as HttpClient from "effect/http/HttpClient";
3
+ import type * as HttpClientError from "effect/http/HttpClientError";
4
4
  import type * as API from "@distilled.cloud/core/api";
5
5
  import type { ConfigError } from "@distilled.cloud/core/errors";
6
6
  import { Credentials } from "./credentials.ts";
@@ -1 +1 @@
1
- {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAC;AAE3C,OAAO,KAAK,KAAK,UAAU,MAAM,iCAAiC,CAAC;AACnE,OAAO,KAAK,KAAK,eAAe,MAAM,sCAAsC,CAAC;AAC7E,OAAO,KAAK,KAAK,GAAG,MAAM,2BAA2B,CAAC;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAKhE,OAAO,EAAE,WAAW,EAAe,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAuB,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAEtE;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GACtB,aAAa,GACb,WAAW,GACX,eAAe,CAAC,eAAe,CAAC;AAEpC,0EAA0E;AAC1E,MAAM,MAAM,gBAAgB,GAAG,WAAW,GAAG,UAAU,CAAC,UAAU,CAAC;AAenE,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CA0BlD,CAAC"}
1
+ {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,KAAK,KAAK,MAAM,cAAc,CAAC;AAE3C,OAAO,KAAK,KAAK,UAAU,MAAM,wBAAwB,CAAC;AAC1D,OAAO,KAAK,KAAK,eAAe,MAAM,6BAA6B,CAAC;AACpE,OAAO,KAAK,KAAK,GAAG,MAAM,2BAA2B,CAAC;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAKhE,OAAO,EAAE,WAAW,EAAe,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAEL,KAAK,aAAa,EAEnB,MAAM,aAAa,CAAC;AAErB;;;;;GAKG;AACH,MAAM,MAAM,cAAc,GACtB,aAAa,GACb,WAAW,GACX,eAAe,CAAC,eAAe,CAAC;AAEpC,0EAA0E;AAC1E,MAAM,MAAM,gBAAgB,GAAG,WAAW,GAAG,UAAU,CAAC,UAAU,CAAC;AAenE,eAAO,MAAM,eAAe,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CA2BlD,CAAC"}
package/lib/protocol.js CHANGED
@@ -20,7 +20,7 @@ import * as Effect from "effect/Effect";
20
20
  import * as Redacted from "effect/Redacted";
21
21
  import { makeRestProtocol, } from "@distilled.cloud/core/protocol-rest";
22
22
  import { Credentials } from "./credentials.js";
23
- import { UnknownForgejoError } from "./errors.js";
23
+ import { UnknownForgejoError, ForgejoParseError, } from "./errors.js";
24
24
  /**
25
25
  * Forgejo error bodies are `{ message, url }`. A response that arrives
26
26
  * without that envelope (a proxy 502, an HTML error page) falls through to
@@ -57,5 +57,6 @@ export const ForgejoProtocol = makeRestProtocol({
57
57
  message,
58
58
  body,
59
59
  }),
60
+ parseError: ({ body, cause }) => new ForgejoParseError({ body, cause }),
60
61
  });
61
62
  //# sourceMappingURL=protocol.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"protocol.js","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAA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AAE,EAAE,CAAC,CAAC;QACnB,aAAa,EAAE,SAAS,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;QACrD,MAAM,EAAE,kBAAkB;KAC3B,CAAC;IACF,aAAa;IACb,YAAY,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,CACxC,IAAI,mBAAmB,CAAC;QACtB,IAAI,EACF,OAAO,IAAI,KAAK,QAAQ;YACtB,CAAC,CAAC,IAAI;YACN,CAAC,CAAC,IAAI,KAAK,SAAS;gBAClB,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC;gBACd,CAAC,CAAC,SAAS;QACjB,OAAO;QACP,IAAI;KACL,CAAC;IACJ,UAAU,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,IAAI,iBAAiB,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;CACxE,CAAC,CAAC"}
@@ -0,0 +1,4 @@
1
+ import { ForgejoParseError } from "./errors.ts";
2
+ import type { ForgejoOpError } from "./protocol.ts";
3
+ export declare const parseErrorIsDeclared: [ForgejoParseError] extends [ForgejoOpError] ? true : false;
4
+ //# sourceMappingURL=response-validation.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response-validation.test.d.ts","sourceRoot":"","sources":["../src/response-validation.test.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGhD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAwCpD,eAAO,MAAM,oBAAoB,EAAE,CAAC,iBAAiB,CAAC,SAAS,CAAC,cAAc,CAAC,GAC3E,IAAI,GACJ,KAAY,CAAC"}
@@ -0,0 +1,34 @@
1
+ import { describe, expect, test } from "bun:test";
2
+ import { runValidationModes } from "@distilled.cloud/core/testing";
3
+ import * as Effect from "effect/Effect";
4
+ import { credentials } from "./credentials.js";
5
+ import { ForgejoParseError } from "./errors.js";
6
+ import * as Retry from "./retry.js";
7
+ import { getVersion } from "./services/miscellaneous.js";
8
+ // getVersion declares `{ version?: string }`; every member is optional, so the
9
+ // mismatch is a wrong primitive type.
10
+ const run = (body) => runValidationModes(getVersion({}).pipe(Retry.none, Effect.provide(credentials({ token: "test", baseUrl: "https://git.example.com" }))), { body });
11
+ describe("Forgejo response validation", () => {
12
+ test("a matching body succeeds unchanged in both modes", async () => {
13
+ const body = { version: "11.0.0" };
14
+ const { lenient, strict } = await run(JSON.stringify(body));
15
+ expect(lenient).toMatchObject({ _tag: "Success", success: body });
16
+ expect(strict).toMatchObject({ _tag: "Success", success: body });
17
+ });
18
+ test("a member with the wrong primitive type: lenient returns it, strict fails", async () => {
19
+ const body = { version: 11 };
20
+ const { lenient, strict } = await run(JSON.stringify(body));
21
+ expect(lenient).toMatchObject({ _tag: "Success", success: body });
22
+ expect(strict._tag).toBe("Failure");
23
+ expect(strict.failure).toBeInstanceOf(ForgejoParseError);
24
+ });
25
+ test("a non-JSON body: lenient returns the text, strict fails", async () => {
26
+ const { lenient, strict } = await run("not json");
27
+ expect(lenient).toMatchObject({ _tag: "Success", success: "not json" });
28
+ expect(strict._tag).toBe("Failure");
29
+ expect(strict.failure).toBeInstanceOf(ForgejoParseError);
30
+ });
31
+ });
32
+ // ForgejoParseError is part of every operation's declared error type.
33
+ export const parseErrorIsDeclared = true;
34
+ //# sourceMappingURL=response-validation.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"response-validation.test.js","sourceRoot":"","sources":["../src/response-validation.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,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,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;QAClE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACpC,MAAM,CAAE,MAAc,CAAC,OAAO,CAAC,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAC;IACpE,CAAC,CAAC,CAAC;IAEH,IAAI,CAAC,yDAAyD,EAAE,KAAK,IAAI,EAAE;QACzE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,GAAG,CAAC,UAAU,CAAC,CAAC;QAClD,MAAM,CAAC,OAAO,CAAC,CAAC,aAAa,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,CAAC,CAAC;QACxE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACpC,MAAM,CAAE,MAAc,CAAC,OAAO,CAAC,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAC;IACpE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,sEAAsE;AACtE,MAAM,CAAC,MAAM,oBAAoB,GAErB,IAAI,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@distilled.cloud/forgejo",
3
- "version": "1.0.0-rc.12",
3
+ "version": "1.0.0-rc.13",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/alchemy-run/distilled",
@@ -51,12 +51,6 @@
51
51
  "worker": "./src/traits.ts",
52
52
  "default": "./lib/traits.js"
53
53
  },
54
- "./Services": {
55
- "types": "./lib/services/index.d.ts",
56
- "bun": "./src/services/index.ts",
57
- "worker": "./src/services/index.ts",
58
- "default": "./lib/services/index.js"
59
- },
60
54
  "./*": {
61
55
  "types": "./lib/services/*.d.ts",
62
56
  "bun": "./src/services/*.ts",
@@ -65,15 +59,15 @@
65
59
  }
66
60
  },
67
61
  "dependencies": {
68
- "@distilled.cloud/core": "1.0.0-rc.12"
62
+ "@distilled.cloud/core": "1.0.0-rc.13"
69
63
  },
70
64
  "devDependencies": {
71
65
  "@types/bun": "1.3.14",
72
66
  "@types/node": "26.2.0",
73
- "@effect/platform-bun": ">=4.0.0-rc.115 || >=4.0.0"
67
+ "@effect/platform-bun": "^4.0.0"
74
68
  },
75
69
  "peerDependencies": {
76
- "effect": ">=4.0.0-rc.115 || >=4.0.0"
70
+ "effect": "^4.0.0"
77
71
  },
78
72
  "scripts": {
79
73
  "build": "tsc -b",
package/src/index.ts CHANGED
@@ -13,7 +13,7 @@
13
13
  * ```ts
14
14
  * import * as Forgejo from "@distilled.cloud/forgejo";
15
15
  *
16
- * const repo = yield* Forgejo.Services.repository.repoGet({
16
+ * const repo = yield* Forgejo.repository.repoGet({
17
17
  * owner: "acme",
18
18
  * repo: "api",
19
19
  * });
@@ -28,4 +28,4 @@ export {
28
28
  type ForgejoOpContext,
29
29
  } from "./protocol.ts";
30
30
  export * as Retry from "./retry.ts";
31
- export * as Services from "./services/index.ts";
31
+ export * from "./services/index.ts";
package/src/protocol.ts CHANGED
@@ -19,8 +19,8 @@
19
19
  import * as Effect from "effect/Effect";
20
20
  import type * as Layer from "effect/Layer";
21
21
  import * as Redacted from "effect/Redacted";
22
- import type * as HttpClient from "effect/unstable/http/HttpClient";
23
- import type * as HttpClientError from "effect/unstable/http/HttpClientError";
22
+ import type * as HttpClient from "effect/http/HttpClient";
23
+ import type * as HttpClientError from "effect/http/HttpClientError";
24
24
  import type * as API from "@distilled.cloud/core/api";
25
25
  import type { ConfigError } from "@distilled.cloud/core/errors";
26
26
  import {
@@ -28,7 +28,11 @@ import {
28
28
  type RestErrorEnvelope,
29
29
  } from "@distilled.cloud/core/protocol-rest";
30
30
  import { Credentials, type Config } from "./credentials.ts";
31
- import { UnknownForgejoError, type DefaultErrors } from "./errors.ts";
31
+ import {
32
+ UnknownForgejoError,
33
+ type DefaultErrors,
34
+ ForgejoParseError,
35
+ } from "./errors.ts";
32
36
 
33
37
  /**
34
38
  * Error channel shared by every generated Forgejo operation. Generated
@@ -83,4 +87,5 @@ export const ForgejoProtocol: Layer.Layer<API.Protocol> =
83
87
  message,
84
88
  body,
85
89
  }),
90
+ parseError: ({ body, cause }) => new ForgejoParseError({ body, cause }),
86
91
  });
@@ -0,0 +1,50 @@
1
+ import { describe, expect, test } from "bun:test";
2
+ import { runValidationModes } from "@distilled.cloud/core/testing";
3
+ import * as Effect from "effect/Effect";
4
+ import { credentials } from "./credentials.ts";
5
+ import { ForgejoParseError } from "./errors.ts";
6
+ import * as Retry from "./retry.ts";
7
+ import { getVersion } from "./services/miscellaneous.ts";
8
+ import type { ForgejoOpError } from "./protocol.ts";
9
+
10
+ // getVersion declares `{ version?: string }`; every member is optional, so the
11
+ // mismatch is a wrong primitive type.
12
+ const run = (body: string) =>
13
+ runValidationModes(
14
+ getVersion({}).pipe(
15
+ Retry.none,
16
+ Effect.provide(
17
+ credentials({ token: "test", baseUrl: "https://git.example.com" }),
18
+ ),
19
+ ),
20
+ { body },
21
+ );
22
+
23
+ describe("Forgejo response validation", () => {
24
+ test("a matching body succeeds unchanged in both modes", async () => {
25
+ const body = { version: "11.0.0" };
26
+ const { lenient, strict } = await run(JSON.stringify(body));
27
+ expect(lenient).toMatchObject({ _tag: "Success", success: body });
28
+ expect(strict).toMatchObject({ _tag: "Success", success: body });
29
+ });
30
+
31
+ test("a member with the wrong primitive type: lenient returns it, strict fails", async () => {
32
+ const body = { version: 11 };
33
+ const { lenient, strict } = await run(JSON.stringify(body));
34
+ expect(lenient).toMatchObject({ _tag: "Success", success: body });
35
+ expect(strict._tag).toBe("Failure");
36
+ expect((strict as any).failure).toBeInstanceOf(ForgejoParseError);
37
+ });
38
+
39
+ test("a non-JSON body: lenient returns the text, strict fails", async () => {
40
+ const { lenient, strict } = await run("not json");
41
+ expect(lenient).toMatchObject({ _tag: "Success", success: "not json" });
42
+ expect(strict._tag).toBe("Failure");
43
+ expect((strict as any).failure).toBeInstanceOf(ForgejoParseError);
44
+ });
45
+ });
46
+
47
+ // ForgejoParseError is part of every operation's declared error type.
48
+ export const parseErrorIsDeclared: [ForgejoParseError] extends [ForgejoOpError]
49
+ ? true
50
+ : false = true;