@distilled.cloud/apache-superset 1.0.0-rc.11 → 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 ADDED
@@ -0,0 +1,34 @@
1
+ # @distilled.cloud/apache-superset
2
+
3
+ Effect-native SDK for [apache-superset](https://www.npmjs.com/package/@distilled.cloud/apache-superset).
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @distilled.cloud/apache-superset effect
9
+ ```
10
+
11
+ ## Quick start
12
+
13
+ ```ts
14
+ import { Effect, Layer } from "effect";
15
+ import * as FetchHttpClient from "effect/http/FetchHttpClient";
16
+ import * as ApacheSuperset from "@distilled.cloud/apache-superset";
17
+
18
+ const program = Effect.gen(function* () {
19
+ const result = yield* ApacheSuperset.getApiV1Dashboard({});
20
+ return result;
21
+ });
22
+
23
+ const Live = Layer.mergeAll(
24
+ FetchHttpClient.layer,
25
+ ApacheSuperset.CredentialsFromEnv,
26
+ ApacheSuperset.ApacheSupersetProtocol,
27
+ );
28
+
29
+ program.pipe(Effect.provide(Live), Effect.runPromise);
30
+ ```
31
+
32
+ ## Auth
33
+
34
+ Required: `SUPERSET_ACCESS_TOKEN`. Optional: `SUPERSET_URL`. Sent as `Authorization: Bearer`.
package/lib/protocol.d.ts CHANGED
@@ -1,10 +1,10 @@
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 { API_ERRORS, ConfigError } from "@distilled.cloud/core/errors";
6
6
  import { Credentials } from "./credentials.ts";
7
- import { UnknownApacheSupersetError } from "./errors.ts";
7
+ import { UnknownApacheSupersetError, ApacheSupersetParseError } from "./errors.ts";
8
8
  /**
9
9
  * Error channel shared by every generated Apache Superset operation.
10
10
  * Generated service files annotate operations with
@@ -12,7 +12,7 @@ import { UnknownApacheSupersetError } from "./errors.ts";
12
12
  * explicitly so the compiler never infers these back out of the schema
13
13
  * generics.
14
14
  */
15
- export type ApacheSupersetOpError = InstanceType<(typeof API_ERRORS)[number]> | UnknownApacheSupersetError | ConfigError | HttpClientError.HttpClientError;
15
+ export type ApacheSupersetOpError = InstanceType<(typeof API_ERRORS)[number]> | UnknownApacheSupersetError | ConfigError | HttpClientError.HttpClientError | ApacheSupersetParseError;
16
16
  /** Context (requirements) shared by every generated Apache Superset operation. */
17
17
  export type ApacheSupersetOpContext = Credentials | HttpClient.HttpClient;
18
18
  export declare const ApacheSupersetProtocol: Layer.Layer<API.Protocol>;
@@ -1 +1 @@
1
- {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAkBA,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;AAEtD,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAe,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAEzD;;;;;;GAMG;AACH,MAAM,MAAM,qBAAqB,GAC7B,YAAY,CAAC,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,GACzC,0BAA0B,GAC1B,WAAW,GACX,eAAe,CAAC,eAAe,CAAC;AAEpC,kFAAkF;AAClF,MAAM,MAAM,uBAAuB,GAAG,WAAW,GAAG,UAAU,CAAC,UAAU,CAAC;AAE1E,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAuBzD,CAAC"}
1
+ {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAkBA,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;AAEtD,OAAO,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC5E,OAAO,EAAE,WAAW,EAAe,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EACL,0BAA0B,EAC1B,wBAAwB,EACzB,MAAM,aAAa,CAAC;AAErB;;;;;;GAMG;AACH,MAAM,MAAM,qBAAqB,GAC7B,YAAY,CAAC,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,GACzC,0BAA0B,GAC1B,WAAW,GACX,eAAe,CAAC,eAAe,GAC/B,wBAAwB,CAAC;AAE7B,kFAAkF;AAClF,MAAM,MAAM,uBAAuB,GAAG,WAAW,GAAG,UAAU,CAAC,UAAU,CAAC;AAE1E,eAAO,MAAM,sBAAsB,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAyBzD,CAAC"}
package/lib/protocol.js CHANGED
@@ -19,7 +19,7 @@ import * as Effect from "effect/Effect";
19
19
  import * as Redacted from "effect/Redacted";
20
20
  import { makeRestProtocol } from "@distilled.cloud/core/protocol-rest";
21
21
  import { Credentials } from "./credentials.js";
22
- import { UnknownApacheSupersetError } from "./errors.js";
22
+ import { UnknownApacheSupersetError, ApacheSupersetParseError, } from "./errors.js";
23
23
  export const ApacheSupersetProtocol = makeRestProtocol({
24
24
  // The Credentials service holds an effect — resolving it here (per
25
25
  // request, on the calling fiber) picks up context-provided credentials.
@@ -40,5 +40,6 @@ export const ApacheSupersetProtocol = makeRestProtocol({
40
40
  message,
41
41
  body,
42
42
  }),
43
+ parseError: ({ body, cause }) => new ApacheSupersetParseError({ body, cause }),
43
44
  });
44
45
  //# sourceMappingURL=protocol.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"protocol.js","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAI5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AAEvE,OAAO,EAAE,WAAW,EAAe,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAkBzD,MAAM,CAAC,MAAM,sBAAsB,GACjC,gBAAgB,CAAS;IACvB,mEAAmE;IACnE,wEAAwE;IACxE,WAAW,EAAE,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;QAC/B,MAAM,OAAO,GAAG,KAAK,CAAC,CAAC,WAAW,CAAC;QACnC,OAAO,KAAK,CAAC,CAAC,OAAO,CAAC;IACxB,CAAC,CAAC;IACF,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU;IACpC,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;QACnB,aAAa,EAAE,UAAU,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE;KACxD,CAAC;IACF,YAAY,EAAE,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,EAAE,CACxC,IAAI,0BAA0B,CAAC;QAC7B,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,I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C9B,IAAI,wBAAwB,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;CAChD,CAAC,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { ApacheSupersetParseError } from "./errors.ts";
2
+ import type { ApacheSupersetOpError } from "./protocol.ts";
3
+ export declare const parseErrorIsDeclared: [ApacheSupersetParseError] extends [
4
+ ApacheSupersetOpError
5
+ ] ? true : false;
6
+ //# 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,wBAAwB,EAAE,MAAM,aAAa,CAAC;AAGvD,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAmC3D,eAAO,MAAM,oBAAoB,EAAE,CAAC,wBAAwB,CAAC,SAAS;IACpE,qBAAqB;CACtB,GACG,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 { fromApiKey } from "./credentials.js";
5
+ import { ApacheSupersetParseError } from "./errors.js";
6
+ import * as Retry from "./retry.js";
7
+ import { getMe } from "./services/superset.js";
8
+ // getMe declares `{ result?: UserResponseSchema }`; every member is optional,
9
+ // so the mismatch is a wrong primitive (`result.id` must be a number).
10
+ const run = (body) => runValidationModes(getMe({}).pipe(Retry.none, Effect.provide(fromApiKey({ apiKey: "test" }))), { body });
11
+ describe("Apache Superset response validation", () => {
12
+ test("a matching body succeeds unchanged in both modes", async () => {
13
+ const body = { result: { id: 1, username: "admin", is_active: true } };
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 body with a wrong primitive type: lenient returns it, strict fails", async () => {
19
+ const body = { result: { id: "one" } };
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(ApacheSupersetParseError);
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(ApacheSupersetParseError);
30
+ });
31
+ });
32
+ // ApacheSupersetParseError 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,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAC;AACvD,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAG/C,8EAA8E;AAC9E,uEAAuE;AACvE,MAAM,GAAG,GAAG,CAAC,IAAY,EAAE,EAAE,CAC3B,kBAAkB,CAChB,KAAK,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAC1E,EAAE,IAAI,EAAE,CACT,CAAC;AAEJ,QAAQ,CAAC,qCAAqC,EAAE,GAAG,EAAE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AAC;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,wBAAwB,CAAC,CAAC;IAC3E,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,6EAA6E;AAC7E,MAAM,CAAC,MAAM,oBAAoB,GAIrB,IAAI,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@distilled.cloud/apache-superset",
3
- "version": "1.0.0-rc.11",
3
+ "version": "1.0.0-rc.13",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/alchemy-run/distilled",
@@ -64,15 +64,15 @@
64
64
  }
65
65
  },
66
66
  "dependencies": {
67
- "@distilled.cloud/core": "1.0.0-rc.11"
67
+ "@distilled.cloud/core": "1.0.0-rc.13"
68
68
  },
69
69
  "devDependencies": {
70
70
  "@types/bun": "1.3.14",
71
71
  "@types/node": "26.2.0",
72
- "@effect/platform-bun": ">=4.0.0-rc.115 || >=4.0.0"
72
+ "@effect/platform-bun": "^4.0.0"
73
73
  },
74
74
  "peerDependencies": {
75
- "effect": ">=4.0.0-rc.115 || >=4.0.0"
75
+ "effect": "^4.0.0"
76
76
  },
77
77
  "scripts": {
78
78
  "build": "tsc -b",
package/src/protocol.ts CHANGED
@@ -18,13 +18,16 @@
18
18
  import * as Effect from "effect/Effect";
19
19
  import type * as Layer from "effect/Layer";
20
20
  import * as Redacted from "effect/Redacted";
21
- import type * as HttpClient from "effect/unstable/http/HttpClient";
22
- import type * as HttpClientError from "effect/unstable/http/HttpClientError";
21
+ import type * as HttpClient from "effect/http/HttpClient";
22
+ import type * as HttpClientError from "effect/http/HttpClientError";
23
23
  import type * as API from "@distilled.cloud/core/api";
24
24
  import { makeRestProtocol } from "@distilled.cloud/core/protocol-rest";
25
25
  import type { API_ERRORS, ConfigError } from "@distilled.cloud/core/errors";
26
26
  import { Credentials, type Config } from "./credentials.ts";
27
- import { UnknownApacheSupersetError } from "./errors.ts";
27
+ import {
28
+ UnknownApacheSupersetError,
29
+ ApacheSupersetParseError,
30
+ } from "./errors.ts";
28
31
 
29
32
  /**
30
33
  * Error channel shared by every generated Apache Superset operation.
@@ -37,7 +40,8 @@ export type ApacheSupersetOpError =
37
40
  | InstanceType<(typeof API_ERRORS)[number]>
38
41
  | UnknownApacheSupersetError
39
42
  | ConfigError
40
- | HttpClientError.HttpClientError;
43
+ | HttpClientError.HttpClientError
44
+ | ApacheSupersetParseError;
41
45
 
42
46
  /** Context (requirements) shared by every generated Apache Superset operation. */
43
47
  export type ApacheSupersetOpContext = Credentials | HttpClient.HttpClient;
@@ -65,4 +69,6 @@ export const ApacheSupersetProtocol: Layer.Layer<API.Protocol> =
65
69
  message,
66
70
  body,
67
71
  }),
72
+ parseError: ({ body, cause }) =>
73
+ new ApacheSupersetParseError({ body, cause }),
68
74
  });
@@ -0,0 +1,47 @@
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 { fromApiKey } from "./credentials.ts";
5
+ import { ApacheSupersetParseError } from "./errors.ts";
6
+ import * as Retry from "./retry.ts";
7
+ import { getMe } from "./services/superset.ts";
8
+ import type { ApacheSupersetOpError } from "./protocol.ts";
9
+
10
+ // getMe declares `{ result?: UserResponseSchema }`; every member is optional,
11
+ // so the mismatch is a wrong primitive (`result.id` must be a number).
12
+ const run = (body: string) =>
13
+ runValidationModes(
14
+ getMe({}).pipe(Retry.none, Effect.provide(fromApiKey({ apiKey: "test" }))),
15
+ { body },
16
+ );
17
+
18
+ describe("Apache Superset response validation", () => {
19
+ test("a matching body succeeds unchanged in both modes", async () => {
20
+ const body = { result: { id: 1, username: "admin", is_active: true } };
21
+ const { lenient, strict } = await run(JSON.stringify(body));
22
+ expect(lenient).toMatchObject({ _tag: "Success", success: body });
23
+ expect(strict).toMatchObject({ _tag: "Success", success: body });
24
+ });
25
+
26
+ test("a body with a wrong primitive type: lenient returns it, strict fails", async () => {
27
+ const body = { result: { id: "one" } };
28
+ const { lenient, strict } = await run(JSON.stringify(body));
29
+ expect(lenient).toMatchObject({ _tag: "Success", success: body });
30
+ expect(strict._tag).toBe("Failure");
31
+ expect((strict as any).failure).toBeInstanceOf(ApacheSupersetParseError);
32
+ });
33
+
34
+ test("a non-JSON body: lenient returns the text, strict fails", async () => {
35
+ const { lenient, strict } = await run("not json");
36
+ expect(lenient).toMatchObject({ _tag: "Success", success: "not json" });
37
+ expect(strict._tag).toBe("Failure");
38
+ expect((strict as any).failure).toBeInstanceOf(ApacheSupersetParseError);
39
+ });
40
+ });
41
+
42
+ // ApacheSupersetParseError is part of every operation's declared error type.
43
+ export const parseErrorIsDeclared: [ApacheSupersetParseError] extends [
44
+ ApacheSupersetOpError,
45
+ ]
46
+ ? true
47
+ : false = true;