@distilled.cloud/vanta 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/vanta
2
+
3
+ Effect-native SDK for [vanta](https://www.npmjs.com/package/@distilled.cloud/vanta).
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @distilled.cloud/vanta 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 Vanta from "@distilled.cloud/vanta";
17
+
18
+ const program = Effect.gen(function* () {
19
+ const result = yield* Vanta.manageVanta.listComplianceFrameworks({});
20
+ return result;
21
+ });
22
+
23
+ const Live = Layer.mergeAll(
24
+ FetchHttpClient.layer,
25
+ Vanta.CredentialsFromEnv,
26
+ Vanta.VantaProtocol,
27
+ );
28
+
29
+ program.pipe(Effect.provide(Live), Effect.runPromise);
30
+ ```
31
+
32
+ ## Auth
33
+
34
+ Required: `VANTA_ACCESS_TOKEN`. Optional: `VANTA_API_BASE_URL`. Sent as `Authorization: Bearer`.
package/lib/index.d.ts CHANGED
@@ -9,7 +9,7 @@
9
9
  * ```ts
10
10
  * import * as Vanta from "@distilled.cloud/vanta";
11
11
  *
12
- * const frameworks = yield* Vanta.Services.manageVanta.listComplianceFrameworks({});
12
+ * const frameworks = yield* Vanta.manageVanta.listComplianceFrameworks({});
13
13
  * ```
14
14
  */
15
15
  export * from "./credentials.ts";
@@ -18,5 +18,5 @@ export * as T from "./traits.ts";
18
18
  export { VantaProtocol, type VantaOpError, type VantaOpContext, } from "./protocol.ts";
19
19
  export { paginateCursor } from "./pagination.ts";
20
20
  export * as Retry from "./retry.ts";
21
- export * as Services from "./services/index.ts";
21
+ export * from "./services/index.ts";
22
22
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,OAAO,KAAK,CAAC,MAAM,aAAa,CAAC;AACjC,OAAO,EACL,aAAa,EACb,KAAK,YAAY,EACjB,KAAK,cAAc,GACpB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,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;;;;;;;;;;;;;GAaG;AACH,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,OAAO,KAAK,CAAC,MAAM,aAAa,CAAC;AACjC,OAAO,EACL,aAAa,EACb,KAAK,YAAY,EACjB,KAAK,cAAc,GACpB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,cAAc,qBAAqB,CAAC"}
package/lib/index.js CHANGED
@@ -9,7 +9,7 @@
9
9
  * ```ts
10
10
  * import * as Vanta from "@distilled.cloud/vanta";
11
11
  *
12
- * const frameworks = yield* Vanta.Services.manageVanta.listComplianceFrameworks({});
12
+ * const frameworks = yield* Vanta.manageVanta.listComplianceFrameworks({});
13
13
  * ```
14
14
  */
15
15
  export * from "./credentials.js";
@@ -18,5 +18,5 @@ export * as T from "./traits.js";
18
18
  export { VantaProtocol, } from "./protocol.js";
19
19
  export { paginateCursor } from "./pagination.js";
20
20
  export * as Retry from "./retry.js";
21
- export * as Services from "./services/index.js";
21
+ export * from "./services/index.js";
22
22
  //# 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;;;;;;;;;;;;;GAaG;AACH,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,OAAO,KAAK,CAAC,MAAM,aAAa,CAAC;AACjC,OAAO,EACL,aAAa,GAGd,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,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;;;;;;;;;;;;;GAaG;AACH,cAAc,kBAAkB,CAAC;AACjC,cAAc,aAAa,CAAC;AAC5B,OAAO,KAAK,CAAC,MAAM,aAAa,CAAC;AACjC,OAAO,EACL,aAAa,GAGd,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,cAAc,qBAAqB,CAAC"}
package/lib/protocol.d.ts CHANGED
@@ -1,17 +1,17 @@
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 { UnknownVantaError } from "./errors.ts";
7
+ import { UnknownVantaError, VantaParseError } from "./errors.ts";
8
8
  /**
9
9
  * Error channel shared by every generated Vanta operation. Generated service
10
10
  * files annotate operations with `API.OperationMethod<I, O, VantaOpError,
11
11
  * VantaOpContext>` explicitly so the compiler never infers these back out of
12
12
  * the schema generics.
13
13
  */
14
- export type VantaOpError = InstanceType<(typeof API_ERRORS)[number]> | UnknownVantaError | ConfigError | HttpClientError.HttpClientError;
14
+ export type VantaOpError = InstanceType<(typeof API_ERRORS)[number]> | UnknownVantaError | ConfigError | HttpClientError.HttpClientError | VantaParseError;
15
15
  /** Context (requirements) shared by every generated Vanta operation. */
16
16
  export type VantaOpContext = Credentials | HttpClient.HttpClient;
17
17
  export declare const VantaProtocol: Layer.Layer<API.Protocol>;
@@ -1 +1 @@
1
- {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAgBA,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,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEhD;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GACpB,YAAY,CAAC,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,GACzC,iBAAiB,GACjB,WAAW,GACX,eAAe,CAAC,eAAe,CAAC;AAEpC,wEAAwE;AACxE,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG,UAAU,CAAC,UAAU,CAAC;AAEjE,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CAyBhD,CAAC"}
1
+ {"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../src/protocol.ts"],"names":[],"mappings":"AAgBA,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,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEjE;;;;;GAKG;AACH,MAAM,MAAM,YAAY,GACpB,YAAY,CAAC,CAAC,OAAO,UAAU,CAAC,CAAC,MAAM,CAAC,CAAC,GACzC,iBAAiB,GACjB,WAAW,GACX,eAAe,CAAC,eAAe,GAC/B,eAAe,CAAC;AAEpB,wEAAwE;AACxE,MAAM,MAAM,cAAc,GAAG,WAAW,GAAG,UAAU,CAAC,UAAU,CAAC;AAEjE,eAAO,MAAM,aAAa,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,QAAQ,CA0BhD,CAAC"}
package/lib/protocol.js CHANGED
@@ -17,7 +17,7 @@ import * as Effect from "effect/Effect";
17
17
  import * as Redacted from "effect/Redacted";
18
18
  import { makeRestProtocol } from "@distilled.cloud/core/protocol-rest";
19
19
  import { Credentials } from "./credentials.js";
20
- import { UnknownVantaError } from "./errors.js";
20
+ import { UnknownVantaError, VantaParseError } from "./errors.js";
21
21
  export const VantaProtocol = makeRestProtocol({
22
22
  // The Credentials service holds an effect — resolving it here (per
23
23
  // request, on the calling fiber) picks up context-provided credentials.
@@ -40,5 +40,6 @@ export const VantaProtocol = makeRestProtocol({
40
40
  message,
41
41
  body,
42
42
  }),
43
+ parseError: ({ body, cause }) => new VantaParseError({ 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;;;;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rorIsDeclared: [VantaParseError] extends [VantaOpError] ? 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,eAAe,EAAE,MAAM,aAAa,CAAC;AAG9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AA8ClD,eAAO,MAAM,oBAAoB,EAAE,CAAC,eAAe,CAAC,SAAS,CAAC,YAAY,CAAC,GACvE,IAAI,GACJ,KAAY,CAAC"}
@@ -0,0 +1,42 @@
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 { VantaParseError } from "./errors.js";
6
+ import * as Retry from "./retry.js";
7
+ import { listConnectedIntegrations } from "./services/manage_vanta.js";
8
+ // listConnectedIntegrations declares `{ results: { data: Integration[]; pageInfo: PageInfo } }`.
9
+ const run = (body) => runValidationModes(listConnectedIntegrations({}).pipe(Retry.none, Effect.provide(fromApiKey({ apiKey: "test" }))), { body });
10
+ describe("Vanta response validation", () => {
11
+ test("a matching body succeeds unchanged in both modes", async () => {
12
+ const body = {
13
+ results: {
14
+ data: [],
15
+ pageInfo: {
16
+ endCursor: null,
17
+ hasNextPage: false,
18
+ hasPreviousPage: false,
19
+ startCursor: null,
20
+ },
21
+ },
22
+ };
23
+ const { lenient, strict } = await run(JSON.stringify(body));
24
+ expect(lenient).toMatchObject({ _tag: "Success", success: body });
25
+ expect(strict).toMatchObject({ _tag: "Success", success: body });
26
+ });
27
+ test("a body missing required members: lenient returns it, strict fails", async () => {
28
+ const body = { results: { data: [] } };
29
+ const { lenient, strict } = await run(JSON.stringify(body));
30
+ expect(lenient).toMatchObject({ _tag: "Success", success: body });
31
+ expect(strict._tag).toBe("Failure");
32
+ expect(strict.failure).toBeInstanceOf(VantaParseError);
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.failure).toBeInstanceOf(VantaParseError);
38
+ });
39
+ });
40
+ // VantaParseError is part of every operation's declared error type.
41
+ export const parseErrorIsDeclared = true;
42
+ //# 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,eAAe,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,KAAK,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAC;AAGvE,iGAAiG;AACjG,MAAM,GAAG,GAAG,CAAC,IAAY,EAAE,EAAE,CAC3B,kBAAkB,CAChB,yBAAyB,CAAC,EAAE,CAAC,CAAC,IAAI,CAChC,KAAK,CAAC,IAAI,EACV,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,CAC/C,EACD,EAAE,IAAI,EAAE,CACT,CAAC;AAEJ,QAAQ,CAAC,2BAA2B,EAAE,GAAG,EAAE;IACzC,IAAI,CAAC,kDAAkD,EAAE,KAAK,IAAI,EAAE;QAClE,MAAM,IAAI,GAAG;YACX,OAAO,EAAE;gBACP,IAAI,EAAE,EAAE;gBACR,QAAQ,EAAE;oBACR,SAAS,EAAE,IAAI;oBACf,WAAW,EAAE,KAAK;oBAClB,eAAe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M,CAAE,MAAc,CAAC,OAAO,CAAC,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC;IAClE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,oEAAoE;AACpE,MAAM,CAAC,MAAM,oBAAoB,GAErB,IAAI,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@distilled.cloud/vanta",
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/index.ts CHANGED
@@ -9,7 +9,7 @@
9
9
  * ```ts
10
10
  * import * as Vanta from "@distilled.cloud/vanta";
11
11
  *
12
- * const frameworks = yield* Vanta.Services.manageVanta.listComplianceFrameworks({});
12
+ * const frameworks = yield* Vanta.manageVanta.listComplianceFrameworks({});
13
13
  * ```
14
14
  */
15
15
  export * from "./credentials.ts";
@@ -22,4 +22,4 @@ export {
22
22
  } from "./protocol.ts";
23
23
  export { paginateCursor } from "./pagination.ts";
24
24
  export * as Retry from "./retry.ts";
25
- export * as Services from "./services/index.ts";
25
+ export * from "./services/index.ts";
package/src/protocol.ts CHANGED
@@ -16,13 +16,13 @@
16
16
  import * as Effect from "effect/Effect";
17
17
  import type * as Layer from "effect/Layer";
18
18
  import * as Redacted from "effect/Redacted";
19
- import type * as HttpClient from "effect/unstable/http/HttpClient";
20
- import type * as HttpClientError from "effect/unstable/http/HttpClientError";
19
+ import type * as HttpClient from "effect/http/HttpClient";
20
+ import type * as HttpClientError from "effect/http/HttpClientError";
21
21
  import type * as API from "@distilled.cloud/core/api";
22
22
  import { makeRestProtocol } from "@distilled.cloud/core/protocol-rest";
23
23
  import type { API_ERRORS, ConfigError } from "@distilled.cloud/core/errors";
24
24
  import { Credentials, type Config } from "./credentials.ts";
25
- import { UnknownVantaError } from "./errors.ts";
25
+ import { UnknownVantaError, VantaParseError } from "./errors.ts";
26
26
 
27
27
  /**
28
28
  * Error channel shared by every generated Vanta operation. Generated service
@@ -34,7 +34,8 @@ export type VantaOpError =
34
34
  | InstanceType<(typeof API_ERRORS)[number]>
35
35
  | UnknownVantaError
36
36
  | ConfigError
37
- | HttpClientError.HttpClientError;
37
+ | HttpClientError.HttpClientError
38
+ | VantaParseError;
38
39
 
39
40
  /** Context (requirements) shared by every generated Vanta operation. */
40
41
  export type VantaOpContext = Credentials | HttpClient.HttpClient;
@@ -64,4 +65,5 @@ export const VantaProtocol: Layer.Layer<API.Protocol> =
64
65
  message,
65
66
  body,
66
67
  }),
68
+ parseError: ({ body, cause }) => new VantaParseError({ body, cause }),
67
69
  });
@@ -0,0 +1,56 @@
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 { VantaParseError } from "./errors.ts";
6
+ import * as Retry from "./retry.ts";
7
+ import { listConnectedIntegrations } from "./services/manage_vanta.ts";
8
+ import type { VantaOpError } from "./protocol.ts";
9
+
10
+ // listConnectedIntegrations declares `{ results: { data: Integration[]; pageInfo: PageInfo } }`.
11
+ const run = (body: string) =>
12
+ runValidationModes(
13
+ listConnectedIntegrations({}).pipe(
14
+ Retry.none,
15
+ Effect.provide(fromApiKey({ apiKey: "test" })),
16
+ ),
17
+ { body },
18
+ );
19
+
20
+ describe("Vanta response validation", () => {
21
+ test("a matching body succeeds unchanged in both modes", async () => {
22
+ const body = {
23
+ results: {
24
+ data: [],
25
+ pageInfo: {
26
+ endCursor: null,
27
+ hasNextPage: false,
28
+ hasPreviousPage: false,
29
+ startCursor: null,
30
+ },
31
+ },
32
+ };
33
+ const { lenient, strict } = await run(JSON.stringify(body));
34
+ expect(lenient).toMatchObject({ _tag: "Success", success: body });
35
+ expect(strict).toMatchObject({ _tag: "Success", success: body });
36
+ });
37
+
38
+ test("a body missing required members: lenient returns it, strict fails", async () => {
39
+ const body = { results: { data: [] } };
40
+ const { lenient, strict } = await run(JSON.stringify(body));
41
+ expect(lenient).toMatchObject({ _tag: "Success", success: body });
42
+ expect(strict._tag).toBe("Failure");
43
+ expect((strict as any).failure).toBeInstanceOf(VantaParseError);
44
+ });
45
+
46
+ test("a non-JSON body: lenient returns the text, strict fails", async () => {
47
+ const { lenient, strict } = await run("not json");
48
+ expect(lenient).toMatchObject({ _tag: "Success", success: "not json" });
49
+ expect((strict as any).failure).toBeInstanceOf(VantaParseError);
50
+ });
51
+ });
52
+
53
+ // VantaParseError is part of every operation's declared error type.
54
+ export const parseErrorIsDeclared: [VantaParseError] extends [VantaOpError]
55
+ ? true
56
+ : false = true;