@distilled.cloud/gcp 0.2.6 → 0.4.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/README.md +15 -13
- package/lib/client/api.d.ts +1 -9
- package/lib/client/api.d.ts.map +1 -1
- package/lib/client/api.js +2 -1
- package/lib/client/api.js.map +1 -1
- package/lib/credentials.d.ts +2 -1
- package/lib/credentials.d.ts.map +1 -1
- package/lib/credentials.js +2 -1
- package/lib/credentials.js.map +1 -1
- package/lib/sensitive.d.ts +5 -0
- package/lib/sensitive.d.ts.map +1 -0
- package/lib/sensitive.js +5 -0
- package/lib/sensitive.js.map +1 -0
- package/package.json +2 -2
- package/src/client/api.ts +2 -1
- package/src/credentials.ts +3 -2
- package/src/sensitive.ts +4 -0
package/README.md
CHANGED
|
@@ -13,35 +13,37 @@ npm install @distilled.cloud/gcp effect
|
|
|
13
13
|
```typescript
|
|
14
14
|
import { Effect, Layer } from "effect";
|
|
15
15
|
import * as FetchHttpClient from "effect/unstable/http/FetchHttpClient";
|
|
16
|
-
import * as Storage from "@distilled.cloud/gcp/storage";
|
|
17
|
-
import {
|
|
16
|
+
import * as Storage from "@distilled.cloud/gcp/storage-v1";
|
|
17
|
+
import { CredentialsFromEnv } from "@distilled.cloud/gcp";
|
|
18
18
|
|
|
19
19
|
const program = Storage.listBuckets({ project: "my-project" });
|
|
20
20
|
|
|
21
|
-
const GCPLive = Layer.mergeAll(FetchHttpClient.layer,
|
|
21
|
+
const GCPLive = Layer.mergeAll(FetchHttpClient.layer, CredentialsFromEnv);
|
|
22
22
|
|
|
23
23
|
program.pipe(Effect.provide(GCPLive), Effect.runPromise);
|
|
24
24
|
```
|
|
25
25
|
|
|
26
|
-
##
|
|
26
|
+
## Configuration
|
|
27
27
|
|
|
28
|
-
|
|
29
|
-
import { Auth } from "@distilled.cloud/gcp";
|
|
28
|
+
Set the following environment variables:
|
|
30
29
|
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
```bash
|
|
31
|
+
GOOGLE_ACCESS_TOKEN=your-access-token
|
|
32
|
+
GOOGLE_PROJECT_ID=my-project # optional, used by operations that require a project
|
|
33
|
+
```
|
|
33
34
|
|
|
34
|
-
|
|
35
|
-
Auth.fromServiceAccountFile("./service-account.json")
|
|
35
|
+
Generate an access token using the `gcloud` CLI:
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
```bash
|
|
38
|
+
gcloud auth print-access-token
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
+
For service accounts, use workload identity or a service account key to obtain an OAuth2 access token. Access tokens are short-lived (typically 1 hour) — refresh as needed.
|
|
42
|
+
|
|
41
43
|
## Error Handling
|
|
42
44
|
|
|
43
45
|
```typescript
|
|
44
|
-
Storage.
|
|
46
|
+
Storage.getBuckets({ bucket: "missing-bucket" }).pipe(
|
|
45
47
|
Effect.catchTags({
|
|
46
48
|
NotFound: () => Effect.succeed(null),
|
|
47
49
|
UnknownGCPError: (e) => Effect.fail(new Error(`Unknown: ${e.message}`)),
|
package/lib/client/api.d.ts
CHANGED
|
@@ -1,13 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* GCP API operations factory.
|
|
3
|
-
*
|
|
4
|
-
* This module is imported as `import * as API from "../client/api.ts"` by
|
|
5
|
-
* generated service files so that `API.make()`, `API.OperationMethod`, etc.
|
|
6
|
-
* are all accessible as namespace members.
|
|
7
|
-
*/
|
|
8
|
-
import * as Effect from "effect/Effect";
|
|
9
1
|
import { type OperationMethod, type PaginatedOperationMethod } from "@distilled.cloud/core/client";
|
|
10
2
|
export type { OperationMethod, PaginatedOperationMethod };
|
|
11
3
|
export declare const make: <I extends import("effect/Schema").Top, O extends import("effect/Schema").Top, const E extends readonly import("@distilled.cloud/core/client").ApiErrorClass[] = readonly []>(configFn: () => import("@distilled.cloud/core/client").OperationConfig<I, O, E>) => any;
|
|
12
|
-
export declare const makePaginated: <I extends import("effect/Schema").Top, O extends import("effect/Schema").Top, const E extends readonly import("@distilled.cloud/core/client").ApiErrorClass[] = readonly []>(configFn: () => import("@distilled.cloud/core/client").PaginatedOperationConfig<I, O, E>, paginateFn?:
|
|
4
|
+
export declare const makePaginated: <I extends import("effect/Schema").Top, O extends import("effect/Schema").Top, const E extends readonly import("@distilled.cloud/core/client").ApiErrorClass[] = readonly []>(configFn: () => import("@distilled.cloud/core/client").PaginatedOperationConfig<I, O, E>, paginateFn?: import("@distilled.cloud/core/pagination").PaginationStrategy | undefined) => any;
|
|
13
5
|
//# sourceMappingURL=api.d.ts.map
|
package/lib/client/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/client/api.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/client/api.ts"],"names":[],"mappings":"AASA,OAAO,EAEL,KAAK,eAAe,EACpB,KAAK,wBAAwB,EAC9B,MAAM,8BAA8B,CAAC;AAItC,YAAY,EAAE,eAAe,EAAE,wBAAwB,EAAE,CAAC;AAsC1D,eAAO,MAAM,IAAI,uQAAY,CAAC;AAC9B,eAAO,MAAM,aAAa,wWAAqB,CAAC"}
|
package/lib/client/api.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* are all accessible as namespace members.
|
|
7
7
|
*/
|
|
8
8
|
import * as Effect from "effect/Effect";
|
|
9
|
+
import * as Redacted from "effect/Redacted";
|
|
9
10
|
import { makeAPI, } from "@distilled.cloud/core/client";
|
|
10
11
|
import { HTTP_STATUS_MAP, UnknownGCPError, GCPParseError } from "../errors.js";
|
|
11
12
|
import { Credentials } from "../credentials.js";
|
|
@@ -31,7 +32,7 @@ const _API = makeAPI({
|
|
|
31
32
|
credentials: Credentials,
|
|
32
33
|
getBaseUrl: (_creds) => "", // Set per-service via Http trait
|
|
33
34
|
getAuthHeaders: (creds) => ({
|
|
34
|
-
Authorization: `Bearer ${creds.accessToken}`,
|
|
35
|
+
Authorization: `Bearer ${Redacted.value(creds.accessToken)}`,
|
|
35
36
|
}),
|
|
36
37
|
matchError,
|
|
37
38
|
ParseError: GCPParseError,
|
package/lib/client/api.js.map
CHANGED
|
@@ -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,eAAe,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC/E,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,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,EA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AAE,CAAC,EAAE,EAAE,iCAAiC;IAClE,cAAc,EAAE,CAAC,KAAU,EAAE,EAAE,CAAC,CAAC;QAC/B,aAAa,EAAE,UAAU,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,WAAW,CAAC,EAAE;KAC7D,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/credentials.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as Layer from "effect/Layer";
|
|
2
|
+
import * as Redacted from "effect/Redacted";
|
|
2
3
|
import * as ServiceMap from "effect/ServiceMap";
|
|
3
4
|
import { ConfigError } from "@distilled.cloud/core/errors";
|
|
4
5
|
export interface Config {
|
|
5
|
-
readonly accessToken: string
|
|
6
|
+
readonly accessToken: Redacted.Redacted<string>;
|
|
6
7
|
readonly project?: string;
|
|
7
8
|
}
|
|
8
9
|
declare const Credentials_base: ServiceMap.ServiceClass<Credentials, "GCPCredentials", Config>;
|
package/lib/credentials.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../src/credentials.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE3D,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../src/credentials.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAE3D,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,WAAW,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAChD,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC;CAC3B;;AAED,qBAAa,WAAY,SAAQ,gBAEhC;CAAG;AAEJ,eAAO,MAAM,kBAAkB,8CAgB9B,CAAC"}
|
package/lib/credentials.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as Effect from "effect/Effect";
|
|
2
2
|
import * as Layer from "effect/Layer";
|
|
3
|
+
import * as Redacted from "effect/Redacted";
|
|
3
4
|
import * as ServiceMap from "effect/ServiceMap";
|
|
4
5
|
import { ConfigError } from "@distilled.cloud/core/errors";
|
|
5
6
|
export class Credentials extends ServiceMap.Service()("GCPCredentials") {
|
|
@@ -12,7 +13,7 @@ export const CredentialsFromEnv = Layer.effect(Credentials, Effect.gen(function*
|
|
|
12
13
|
});
|
|
13
14
|
}
|
|
14
15
|
return {
|
|
15
|
-
accessToken,
|
|
16
|
+
accessToken: Redacted.make(accessToken),
|
|
16
17
|
project: process.env.GOOGLE_PROJECT_ID,
|
|
17
18
|
};
|
|
18
19
|
}));
|
package/lib/credentials.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credentials.js","sourceRoot":"","sources":["../src/credentials.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAO3D,MAAM,OAAO,WAAY,SAAQ,UAAU,CAAC,OAAO,EAAuB,CACxE,gBAAgB,CACjB;CAAG;AAEJ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{"version":3,"file":"sensitive.d.ts","sourceRoot":"","sources":["../src/sensitive.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,iCAAiC,CAAC"}
|
package/lib/sensitive.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sensitive.js","sourceRoot":"","sources":["../src/sensitive.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,cAAc,iCAAiC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@distilled.cloud/gcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/alchemy-run/distilled",
|
|
@@ -57,7 +57,7 @@
|
|
|
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.
|
|
60
|
+
"@distilled.cloud/core": "0.4.0",
|
|
61
61
|
"effect": "4.0.0-beta.30"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
package/src/client/api.ts
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* are all accessible as namespace members.
|
|
7
7
|
*/
|
|
8
8
|
import * as Effect from "effect/Effect";
|
|
9
|
+
import * as Redacted from "effect/Redacted";
|
|
9
10
|
import {
|
|
10
11
|
makeAPI,
|
|
11
12
|
type OperationMethod,
|
|
@@ -46,7 +47,7 @@ const _API = makeAPI({
|
|
|
46
47
|
credentials: Credentials as any,
|
|
47
48
|
getBaseUrl: (_creds: any) => "", // Set per-service via Http trait
|
|
48
49
|
getAuthHeaders: (creds: any) => ({
|
|
49
|
-
Authorization: `Bearer ${creds.accessToken}`,
|
|
50
|
+
Authorization: `Bearer ${Redacted.value(creds.accessToken)}`,
|
|
50
51
|
}),
|
|
51
52
|
matchError,
|
|
52
53
|
ParseError: GCPParseError as any,
|
package/src/credentials.ts
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import * as Effect from "effect/Effect";
|
|
2
2
|
import * as Layer from "effect/Layer";
|
|
3
|
+
import * as Redacted from "effect/Redacted";
|
|
3
4
|
import * as ServiceMap from "effect/ServiceMap";
|
|
4
5
|
import { ConfigError } from "@distilled.cloud/core/errors";
|
|
5
6
|
|
|
6
7
|
export interface Config {
|
|
7
|
-
readonly accessToken: string
|
|
8
|
+
readonly accessToken: Redacted.Redacted<string>;
|
|
8
9
|
readonly project?: string;
|
|
9
10
|
}
|
|
10
11
|
|
|
@@ -24,7 +25,7 @@ export const CredentialsFromEnv = Layer.effect(
|
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
return {
|
|
27
|
-
accessToken,
|
|
28
|
+
accessToken: Redacted.make(accessToken),
|
|
28
29
|
project: process.env.GOOGLE_PROJECT_ID,
|
|
29
30
|
};
|
|
30
31
|
}),
|
package/src/sensitive.ts
ADDED