@distilled.cloud/planetscale 0.2.5-alpha2 → 0.3.0-alpha

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
@@ -13,7 +13,8 @@ npm install @distilled.cloud/planetscale effect
13
13
  ```typescript
14
14
  import { Effect, Layer } from "effect";
15
15
  import * as FetchHttpClient from "effect/unstable/http/FetchHttpClient";
16
- import { listDatabases, CredentialsFromEnv, Credentials } from "@distilled.cloud/planetscale";
16
+ import { listDatabases } from "@distilled.cloud/planetscale/Operations";
17
+ import { CredentialsFromEnv, Credentials } from "@distilled.cloud/planetscale";
17
18
 
18
19
  const program = Effect.gen(function* () {
19
20
  const { organization } = yield* Credentials;
@@ -31,15 +32,16 @@ program.pipe(Effect.provide(PlanetScaleLive), Effect.runPromise);
31
32
  Set the following environment variables:
32
33
 
33
34
  ```bash
34
- # Format: SERVICE_TOKEN_ID:SERVICE_TOKEN
35
- PLANETSCALE_API_TOKEN=pscale_tkn_xxxxx:pscale_tok_xxxxx
35
+ PLANETSCALE_API_TOKEN=your-service-token
36
36
  PLANETSCALE_ORGANIZATION=my-org-name
37
37
  ```
38
38
 
39
+ Create a service token in the [PlanetScale dashboard](https://app.planetscale.com/) under **Settings > Service tokens**. Grant the token access to the databases and permissions it needs. `PLANETSCALE_ORGANIZATION` is your organization's URL slug.
40
+
39
41
  ## Error Handling
40
42
 
41
43
  ```typescript
42
- import { getDatabase } from "@distilled.cloud/planetscale";
44
+ import { getDatabase } from "@distilled.cloud/planetscale/Operations";
43
45
 
44
46
  getDatabase({ organization: "my-org", database: "missing" }).pipe(
45
47
  Effect.catchTags({
package/lib/client.d.ts CHANGED
@@ -1,10 +1,3 @@
1
- /**
2
- * PlanetScale API Client.
3
- *
4
- * Wraps the shared REST client from sdk-core with PlanetScale-specific
5
- * error matching and credential handling.
6
- */
7
- import * as Effect from "effect/Effect";
8
1
  import * as Schema from "effect/Schema";
9
2
  export { UnknownPlanetScaleError } from "./errors.ts";
10
3
  /**
@@ -12,6 +5,6 @@ export { UnknownPlanetScaleError } from "./errors.ts";
12
5
  */
13
6
  export declare const API: {
14
7
  make: <I extends Schema.Top, O extends Schema.Top, const E extends readonly import("@distilled.cloud/core/client").ApiErrorClass[] = readonly []>(configFn: () => import("@distilled.cloud/core/client").OperationConfig<I, O, E>) => any;
15
- makePaginated: <I extends Schema.Top, O extends Schema.Top, const E extends readonly import("@distilled.cloud/core/client").ApiErrorClass[] = readonly []>(configFn: () => import("@distilled.cloud/core/client").PaginatedOperationConfig<I, O, E>, paginateFn?: ((baseFn: (input: any) => Effect.Effect<any, any, any>, input: any, pagination: import("@distilled.cloud/core/pagination").PaginatedTrait) => import("effect/Stream").Stream<any, any, any>) | undefined) => any;
8
+ makePaginated: <I extends Schema.Top, O extends 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;
16
9
  };
17
10
  //# sourceMappingURL=client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AASxC,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAkCtD;;GAEG;AACH,eAAO,MAAM,GAAG;;;CAMd,CAAC"}
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AASxC,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AAkCtD;;GAEG;AACH,eAAO,MAAM,GAAG;;;CAQd,CAAC"}
package/lib/client.js CHANGED
@@ -5,6 +5,7 @@
5
5
  * error matching and credential handling.
6
6
  */
7
7
  import * as Effect from "effect/Effect";
8
+ import * as Redacted from "effect/Redacted";
8
9
  import * as Schema from "effect/Schema";
9
10
  import { makeAPI } from "@distilled.cloud/core/client";
10
11
  import { HTTP_STATUS_MAP, UnknownPlanetScaleError, PlanetScaleParseError, } from "./errors.js";
@@ -42,7 +43,9 @@ const matchError = (status, errorBody) => {
42
43
  export const API = makeAPI({
43
44
  credentials: Credentials,
44
45
  getBaseUrl: (creds) => creds.apiBaseUrl,
45
- getAuthHeaders: (creds) => ({ Authorization: creds.token }),
46
+ getAuthHeaders: (creds) => ({
47
+ Authorization: Redacted.value(creds.token),
48
+ }),
46
49
  matchError,
47
50
  ParseError: PlanetScaleParseError,
48
51
  });
package/lib/client.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AACvD,OAAO,EACL,eAAe,EACf,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,aAAa,CAAC;AAErB,2FAA2F;AAC3F,OAAO,EAAE,uBAAuB,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAE/C,4BAA4B;AAC5B,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC;IACrC,IAAI,EAAE,MAAM,CAAC,MAAM;IACnB,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;CACxC,CAAC,CAAC;AAEH;;GAEG;AACH,MAAM,UAAU,GAAG,CACjB,MAAc,EACd,SAAkB,EACa,EAAE;IACjC,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,MAAM,CAAC,iBAAiB,CAAC,gBAAg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AU,EAAE,EAAE,CAAC,CAAC;QAC/B,aAAa,EAAE,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC;KAC3C,CAAC;IACF,UAAU;IACV,UAAU,EAAE,qBAA4B;CACzC,CAAC,CAAC"}
@@ -1,9 +1,10 @@
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 declare const DEFAULT_API_BASE_URL = "https://api.planetscale.com/v1";
5
6
  export interface Config {
6
- readonly token: string;
7
+ readonly token: Redacted.Redacted<string>;
7
8
  readonly organization: string;
8
9
  readonly apiBaseUrl: string;
9
10
  }
@@ -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,eAAO,MAAM,oBAAoB,mCAAmC,CAAC;AAErE,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;;AAED,qBAAa,WAAY,SAAQ,gBAEhC;CAAG;AAEJ,eAAO,MAAM,kBAAkB,8CAoB9B,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,eAAO,MAAM,oBAAoB,mCAAmC,CAAC;AAErE,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC1C,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;CAC7B;;AAED,qBAAa,WAAY,SAAQ,gBAEhC;CAAG;AAEJ,eAAO,MAAM,kBAAkB,8CAwB9B,CAAC"}
@@ -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 const DEFAULT_API_BASE_URL = "https://api.planetscale.com/v1";
@@ -18,6 +19,10 @@ export const CredentialsFromEnv = Layer.effect(Credentials, Effect.gen(function*
18
19
  message: "PLANETSCALE_ORGANIZATION environment variable is required",
19
20
  });
20
21
  }
21
- return { token, organization, apiBaseUrl: DEFAULT_API_BASE_URL };
22
+ return {
23
+ token: Redacted.make(token),
24
+ organization,
25
+ apiBaseUrl: DEFAULT_API_BASE_URL,
26
+ };
22
27
  }));
23
28
  //# sourceMappingURL=credentials.js.map
@@ -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;AAE3D,MAAM,CAAC,MAAM,oBAAoB,GAAG,gCAAgC,CAAC;AAQrE,MAAM,OAAO,WAAY,SAAQ,UAAU,CAAC,OAAO,EAAuB,CACxE,wBAAwB,CACzB;CAAG;AAEJ,MAAM,CAAC,MAAM,kB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CAAC,GAAG,CAAC,wBAAwB,CAAC;IAE1D,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,OAAO,KAAK,CAAC,CAAC,IAAI,WAAW,CAAC;YAC5B,OAAO,EAAE,wDAAwD;SAClE,CAAC,CAAC;IACL,CAAC;IAED,IAAI,CAAC,YAAY,EAAE,CAAC;QAClB,OAAO,KAAK,CAAC,CAAC,IAAI,WAAW,CAAC;YAC5B,OAAO,EAAE,2DAA2D;SACrE,CAAC,CAAC;IACL,CAAC;IAED,OAAO;QACL,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC;QAC3B,YAAY;QACZ,UAAU,EAAE,oBAAoB;KACjC,CAAC;AACJ,CAAC,CAAC,CACH,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@distilled.cloud/planetscale",
3
- "version": "0.2.5-alpha2",
3
+ "version": "0.3.0-alpha",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/alchemy-run/distilled",
@@ -73,7 +73,7 @@
73
73
  "specs:update": "git -C specs/distilled-spec-planetscale fetch && git -C specs/distilled-spec-planetscale checkout main && git -C specs/distilled-spec-planetscale pull"
74
74
  },
75
75
  "dependencies": {
76
- "@distilled.cloud/core": "0.2.5-alpha2",
76
+ "@distilled.cloud/core": "0.3.0-alpha",
77
77
  "effect": "4.0.0-beta.30"
78
78
  },
79
79
  "devDependencies": {
package/src/client.ts CHANGED
@@ -5,6 +5,7 @@
5
5
  * error matching and credential handling.
6
6
  */
7
7
  import * as Effect from "effect/Effect";
8
+ import * as Redacted from "effect/Redacted";
8
9
  import * as Schema from "effect/Schema";
9
10
  import { makeAPI } from "@distilled.cloud/core/client";
10
11
  import {
@@ -54,7 +55,9 @@ const matchError = (
54
55
  export const API = makeAPI({
55
56
  credentials: Credentials as any,
56
57
  getBaseUrl: (creds: any) => creds.apiBaseUrl,
57
- getAuthHeaders: (creds: any) => ({ Authorization: creds.token }),
58
+ getAuthHeaders: (creds: any) => ({
59
+ Authorization: Redacted.value(creds.token),
60
+ }),
58
61
  matchError,
59
62
  ParseError: PlanetScaleParseError as any,
60
63
  });
@@ -1,12 +1,13 @@
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 const DEFAULT_API_BASE_URL = "https://api.planetscale.com/v1";
7
8
 
8
9
  export interface Config {
9
- readonly token: string;
10
+ readonly token: Redacted.Redacted<string>;
10
11
  readonly organization: string;
11
12
  readonly apiBaseUrl: string;
12
13
  }
@@ -33,6 +34,10 @@ export const CredentialsFromEnv = Layer.effect(
33
34
  });
34
35
  }
35
36
 
36
- return { token, organization, apiBaseUrl: DEFAULT_API_BASE_URL };
37
+ return {
38
+ token: Redacted.make(token),
39
+ organization,
40
+ apiBaseUrl: DEFAULT_API_BASE_URL,
41
+ };
37
42
  }),
38
43
  );