@distilled.cloud/gcp 0.2.0-alpha → 0.2.3

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,54 @@
1
+ # @distilled.cloud/gcp
2
+
3
+ Effect-native GCP SDK generated from [Google API Discovery Documents](https://developers.google.com/discovery/v1/getting_started) with exhaustive error typing. Covers Cloud Storage, Compute Engine, Cloud Run, and more.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @distilled.cloud/gcp effect
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ ```typescript
14
+ import { Effect, Layer } from "effect";
15
+ import * as FetchHttpClient from "effect/unstable/http/FetchHttpClient";
16
+ import * as Storage from "@distilled.cloud/gcp/storage";
17
+ import { Auth } from "@distilled.cloud/gcp";
18
+
19
+ const program = Storage.listBuckets({ project: "my-project" });
20
+
21
+ const GCPLive = Layer.mergeAll(FetchHttpClient.layer, Auth.fromADC());
22
+
23
+ program.pipe(Effect.provide(GCPLive), Effect.runPromise);
24
+ ```
25
+
26
+ ## Authentication
27
+
28
+ ```typescript
29
+ import { Auth } from "@distilled.cloud/gcp";
30
+
31
+ // Application Default Credentials (recommended for development)
32
+ Auth.fromADC()
33
+
34
+ // Service account JSON key file
35
+ Auth.fromServiceAccountFile("./service-account.json")
36
+
37
+ // Environment variable (GOOGLE_ACCESS_TOKEN)
38
+ Auth.fromEnv()
39
+ ```
40
+
41
+ ## Error Handling
42
+
43
+ ```typescript
44
+ Storage.getBucket({ bucket: "missing-bucket" }).pipe(
45
+ Effect.catchTags({
46
+ NotFound: () => Effect.succeed(null),
47
+ UnknownGCPError: (e) => Effect.fail(new Error(`Unknown: ${e.message}`)),
48
+ }),
49
+ );
50
+ ```
51
+
52
+ ## License
53
+
54
+ MIT
package/lib/client/api.js CHANGED
@@ -7,7 +7,7 @@
7
7
  */
8
8
  import * as Effect from "effect/Effect";
9
9
  import { makeAPI, } from "@distilled.cloud/core/client";
10
- import { HTTP_STATUS_MAP, GCPApiError, GCPParseError } from "../errors.js";
10
+ import { HTTP_STATUS_MAP, UnknownGCPError, GCPParseError } from "../errors.js";
11
11
  import { Credentials } from "../credentials.js";
12
12
  /**
13
13
  * Match a GCP API error response to the appropriate error class.
@@ -20,7 +20,7 @@ const matchError = (status, errorBody) => {
20
20
  if (ErrorClass) {
21
21
  return Effect.fail(new ErrorClass({ message }));
22
22
  }
23
- return Effect.fail(new GCPApiError({ code: status, message, body: errorBody }));
23
+ return Effect.fail(new UnknownGCPError({ code: status, message, body: errorBody }));
24
24
  };
25
25
  /**
26
26
  * GCP API client.
@@ -1 +1 @@
1
- {"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/client/api.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,EACL,OAAO,GAGR,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAIhD;;GAEG;AACH,MAAM,UAAU,GAAG,CACjB,MAAc,EACd,SAAkB,EACa,EAAE;IACjC,MAAM,UAAU,GAAI,eAAuB,CAAC,MAAM,CAAC,CAAC;IACpD,MAAM,OAAO,GACX,OAAO,SAAS,KAAK,QAAQ,IAAI,SAAS,KAAK,IAAI,IAAI,OAAO,IAAI,SAAS;QACzE,CAAC,CAAC,CAAE,SAAiB,CAAC,KAAK,EAAE,OAAO,IAAI,MAAM,CAAC,MAAM,CAAC,CAAC;QACvD,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAErB,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;IAClD,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CA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AAI,UAAU,EAAE,CAAC;QACf,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC;IAClD,CAAC;IACD,OAAO,MAAM,CAAC,IAAI,CAChB,IAAI,eAAe,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAChE,CAAC;AACJ,CAAC,CAAC;AAEF;;;;GAIG;AACH,MAAM,IAAI,GAAG,OAAO,CAAC;IACnB,WAAW,EAAE,WAAkB;IAC/B,UAAU,EAAE,CAAC,MAAW,EAAE,EAAE,CAAC,EAAE,EAAE,iCAAiC;IAClE,cAAc,EAAE,CAAC,KAAU,EAAE,EAAE,CAAC,CAAC;QAC/B,aAAa,EAAE,UAAU,KAAK,CAAC,WAAW,EAAE;KAC7C,CAAC;IACF,UAAU;IACV,UAAU,EAAE,aAAoB;CACjC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;AAC9B,MAAM,CAAC,MAAM,aAAa,GAAG,IAAI,CAAC,aAAa,CAAC"}
package/lib/errors.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  /**
2
2
  * GCP-specific error types.
3
3
  */
4
- export { BadRequest, Conflict, ConfigError, Forbidden, InternalServerError, NotFound, ServiceUnavailable, TooManyRequests, Unauthorized, UnprocessableEntity, HTTP_STATUS_MAP, DEFAULT_ERRORS, API_ERRORS, } from "@distilled.cloud/core/errors";
4
+ export { BadGateway, BadRequest, Conflict, ConfigError, Forbidden, GatewayTimeout, InternalServerError, NotFound, ServiceUnavailable, TooManyRequests, Unauthorized, UnprocessableEntity, HTTP_STATUS_MAP, DEFAULT_ERRORS, API_ERRORS, } from "@distilled.cloud/core/errors";
5
5
  export type { DefaultErrors } from "@distilled.cloud/core/errors";
6
6
  import * as Schema from "effect/Schema";
7
- declare const GCPApiError_base: Schema.ErrorClass<GCPApiError, Schema.TaggedStruct<"GCPApiError", {
7
+ declare const UnknownGCPError_base: Schema.ErrorClass<UnknownGCPError, Schema.TaggedStruct<"UnknownGCPError", {
8
8
  readonly code: Schema.optional<Schema.Number>;
9
9
  readonly message: Schema.optional<Schema.String>;
10
10
  readonly status: Schema.optional<Schema.String>;
@@ -14,7 +14,7 @@ declare const GCPApiError_base: Schema.ErrorClass<GCPApiError, Schema.TaggedStru
14
14
  ServerError: true;
15
15
  };
16
16
  });
17
- export declare class GCPApiError extends GCPApiError_base {
17
+ export declare class UnknownGCPError extends UnknownGCPError_base {
18
18
  }
19
19
  declare const GCPParseError_base: Schema.ErrorClass<GCPParseError, Schema.TaggedStruct<"GCPParseError", {
20
20
  readonly body: Schema.Unknown;
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EACL,UAAU,EACV,QAAQ,EACR,WAAW,EACX,SAAS,EACT,mBAAmB,EACnB,QAAQ,EACR,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,UAAU,GACX,MAAM,8BAA8B,CAAC;AACtC,YAAY,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAElE,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;;;;;;;;;;;AAIxC,qBAAa,WAAY,SAAQ,gBAQD;CAAG;;;;;;;;;AAGnC,qBAAa,aAAc,SAAQ,kBAMJ;CAAG"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EACL,UAAU,EACV,UAAU,EACV,QAAQ,EACR,WAAW,EACX,SAAS,EACT,cAAc,EACd,mBAAmB,EACnB,QAAQ,EACR,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,UAAU,GACX,MAAM,8BAA8B,CAAC;AACtC,YAAY,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAElE,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;;;;;;;;;;;AAIxC,qBAAa,eAAgB,SAAQ,oBAQL;CAAG;;;;;;;;;AAGnC,qBAAa,aAAc,SAAQ,kBAMJ;CAAG"}
package/lib/errors.js CHANGED
@@ -1,11 +1,11 @@
1
1
  /**
2
2
  * GCP-specific error types.
3
3
  */
4
- export { BadRequest, Conflict, ConfigError, Forbidden, InternalServerError, NotFound, ServiceUnavailable, TooManyRequests, Unauthorized, UnprocessableEntity, HTTP_STATUS_MAP, DEFAULT_ERRORS, API_ERRORS, } from "@distilled.cloud/core/errors";
4
+ export { BadGateway, BadRequest, Conflict, ConfigError, Forbidden, GatewayTimeout, InternalServerError, NotFound, ServiceUnavailable, TooManyRequests, Unauthorized, UnprocessableEntity, HTTP_STATUS_MAP, DEFAULT_ERRORS, API_ERRORS, } from "@distilled.cloud/core/errors";
5
5
  import * as Schema from "effect/Schema";
6
6
  import * as Category from "@distilled.cloud/core/category";
7
- // Generic GCP API Error
8
- export class GCPApiError extends Schema.TaggedErrorClass()("GCPApiError", {
7
+ // Unknown GCP error - returned when an error code is not recognized
8
+ export class UnknownGCPError extends Schema.TaggedErrorClass()("UnknownGCPError", {
9
9
  code: Schema.optional(Schema.Number),
10
10
  message: Schema.optional(Schema.String),
11
11
  status: Schema.optional(Schema.String),
package/lib/errors.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EACL,UAAU,EACV,QAAQ,EACR,WAAW,EACX,SAAS,EACT,mBAAmB,EACnB,QAAQ,EACR,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,UAAU,GACX,MAAM,8BAA8B,CAAC;AAGtC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACx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Q,CAAC,MAAM,CAAC,MAAM,CAAC;IACvC,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;IACtC,IAAI,EAAE,MAAM,CAAC,OAAO;CACrB,CACF,CAAC,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC;CAAG;AAEnC,6BAA6B;AAC7B,MAAM,OAAO,aAAc,SAAQ,MAAM,CAAC,gBAAgB,EAAiB,CACzE,eAAe,EACf;IACE,IAAI,EAAE,MAAM,CAAC,OAAO;IACpB,KAAK,EAAE,MAAM,CAAC,OAAO;CACtB,CACF,CAAC,IAAI,CAAC,QAAQ,CAAC,cAAc,CAAC;CAAG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@distilled.cloud/gcp",
3
- "version": "0.2.0-alpha",
3
+ "version": "0.2.3",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/alchemy-run/distilled",
@@ -57,14 +57,14 @@
57
57
  "specs:update": "git -C specs/distilled-spec-gcp fetch && git -C specs/distilled-spec-gcp checkout main && git -C specs/distilled-spec-gcp pull"
58
58
  },
59
59
  "dependencies": {
60
- "@distilled.cloud/core": "0.2.0",
61
- "effect": "4.0.0-beta.25"
60
+ "@distilled.cloud/core": "0.2.0-alpha",
61
+ "effect": "4.0.0-beta.30"
62
62
  },
63
63
  "devDependencies": {
64
64
  "@types/bun": "^1.3.0",
65
65
  "@types/node": "^25.3.5"
66
66
  },
67
67
  "peerDependencies": {
68
- "effect": "4.0.0-beta.25"
68
+ "effect": "4.0.0-beta.30"
69
69
  }
70
70
  }
package/src/client/api.ts CHANGED
@@ -11,7 +11,7 @@ import {
11
11
  type OperationMethod,
12
12
  type PaginatedOperationMethod,
13
13
  } from "@distilled.cloud/core/client";
14
- import { HTTP_STATUS_MAP, GCPApiError, GCPParseError } from "../errors.ts";
14
+ import { HTTP_STATUS_MAP, UnknownGCPError, GCPParseError } from "../errors.ts";
15
15
  import { Credentials } from "../credentials.ts";
16
16
 
17
17
  export type { OperationMethod, PaginatedOperationMethod };
@@ -33,7 +33,7 @@ const matchError = (
33
33
  return Effect.fail(new ErrorClass({ message }));
34
34
  }
35
35
  return Effect.fail(
36
- new GCPApiError({ code: status, message, body: errorBody }),
36
+ new UnknownGCPError({ code: status, message, body: errorBody }),
37
37
  );
38
38
  };
39
39
 
package/src/errors.ts CHANGED
@@ -2,10 +2,12 @@
2
2
  * GCP-specific error types.
3
3
  */
4
4
  export {
5
+ BadGateway,
5
6
  BadRequest,
6
7
  Conflict,
7
8
  ConfigError,
8
9
  Forbidden,
10
+ GatewayTimeout,
9
11
  InternalServerError,
10
12
  NotFound,
11
13
  ServiceUnavailable,
@@ -21,9 +23,9 @@ export type { DefaultErrors } from "@distilled.cloud/core/errors";
21
23
  import * as Schema from "effect/Schema";
22
24
  import * as Category from "@distilled.cloud/core/category";
23
25
 
24
- // Generic GCP API Error
25
- export class GCPApiError extends Schema.TaggedErrorClass<GCPApiError>()(
26
- "GCPApiError",
26
+ // Unknown GCP error - returned when an error code is not recognized
27
+ export class UnknownGCPError extends Schema.TaggedErrorClass<UnknownGCPError>()(
28
+ "UnknownGCPError",
27
29
  {
28
30
  code: Schema.optional(Schema.Number),
29
31
  message: Schema.optional(Schema.String),