@distilled.cloud/neon 0.2.0-alpha → 0.2.4
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 +52 -0
- package/lib/client.d.ts +1 -1
- package/lib/client.d.ts.map +1 -1
- package/lib/client.js +5 -5
- package/lib/client.js.map +1 -1
- package/lib/errors.d.ts +3 -3
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +3 -3
- package/lib/errors.js.map +1 -1
- package/package.json +4 -4
- package/src/client.ts +5 -5
- package/src/errors.ts +5 -3
package/README.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# @distilled.cloud/neon
|
|
2
|
+
|
|
3
|
+
Effect-native Neon SDK generated from the [Neon OpenAPI specification](https://api-docs.neon.tech). Manage serverless Postgres projects, branches, endpoints, databases, and roles with exhaustive error typing.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @distilled.cloud/neon 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 { listProjects } from "@distilled.cloud/neon";
|
|
17
|
+
import { CredentialsFromEnv } from "@distilled.cloud/neon";
|
|
18
|
+
|
|
19
|
+
const program = Effect.gen(function* () {
|
|
20
|
+
const projects = yield* listProjects({});
|
|
21
|
+
return projects.projects;
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const NeonLive = Layer.mergeAll(FetchHttpClient.layer, CredentialsFromEnv);
|
|
25
|
+
|
|
26
|
+
program.pipe(Effect.provide(NeonLive), Effect.runPromise);
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Configuration
|
|
30
|
+
|
|
31
|
+
Set the following environment variable:
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
NEON_API_KEY=your-api-key
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Error Handling
|
|
38
|
+
|
|
39
|
+
```typescript
|
|
40
|
+
import { getProject } from "@distilled.cloud/neon";
|
|
41
|
+
|
|
42
|
+
getProject({ project_id: "missing" }).pipe(
|
|
43
|
+
Effect.catchTags({
|
|
44
|
+
NotFound: () => Effect.succeed(null),
|
|
45
|
+
UnknownNeonError: (e) => Effect.fail(new Error(`Unknown: ${e.message}`)),
|
|
46
|
+
}),
|
|
47
|
+
);
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## License
|
|
51
|
+
|
|
52
|
+
MIT
|
package/lib/client.d.ts
CHANGED
package/lib/client.d.ts.map
CHANGED
|
@@ -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;AAKxC,OAAO,EAAE,
|
|
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;AAKxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAkC/C;;GAEG;AACH,eAAO,MAAM,GAAG;;;CAQd,CAAC"}
|
package/lib/client.js
CHANGED
|
@@ -7,9 +7,9 @@
|
|
|
7
7
|
import * as Effect from "effect/Effect";
|
|
8
8
|
import * as Schema from "effect/Schema";
|
|
9
9
|
import { makeAPI } from "@distilled.cloud/core/client";
|
|
10
|
-
import { HTTP_STATUS_MAP,
|
|
11
|
-
// Re-export for backwards compatibility (tests import
|
|
12
|
-
export {
|
|
10
|
+
import { HTTP_STATUS_MAP, UnknownNeonError, NeonParseError } from "./errors.js";
|
|
11
|
+
// Re-export for backwards compatibility (tests import UnknownNeonError from client)
|
|
12
|
+
export { UnknownNeonError } from "./errors.js";
|
|
13
13
|
import { Credentials } from "./credentials.js";
|
|
14
14
|
// API Error Response Schema
|
|
15
15
|
const ApiErrorResponse = Schema.Struct({
|
|
@@ -26,14 +26,14 @@ const matchError = (status, errorBody) => {
|
|
|
26
26
|
if (ErrorClass) {
|
|
27
27
|
return Effect.fail(new ErrorClass({ message: parsed.message ?? "" }));
|
|
28
28
|
}
|
|
29
|
-
return Effect.fail(new
|
|
29
|
+
return Effect.fail(new UnknownNeonError({
|
|
30
30
|
code: parsed.code,
|
|
31
31
|
message: parsed.message,
|
|
32
32
|
body: errorBody,
|
|
33
33
|
}));
|
|
34
34
|
}
|
|
35
35
|
catch {
|
|
36
|
-
return Effect.fail(new
|
|
36
|
+
return Effect.fail(new UnknownNeonError({ body: errorBody }));
|
|
37
37
|
}
|
|
38
38
|
};
|
|
39
39
|
/**
|
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,EAAE,eAAe,EAAE,
|
|
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,EAAE,eAAe,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAEhF,oFAAoF;AACpF,OAAO,EAAE,gBAAgB,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U,KAAK,CAAC,MAAM,EAAE;KACxC,CAAC;IACF,UAAU;IACV,UAAU,EAAE,cAAqB;CAClC,CAAC,CAAC"}
|
package/lib/errors.d.ts
CHANGED
|
@@ -4,10 +4,10 @@
|
|
|
4
4
|
* Re-exports common HTTP errors from sdk-core and adds Neon-specific
|
|
5
5
|
* error matching and API error types.
|
|
6
6
|
*/
|
|
7
|
-
export { BadRequest, Conflict, ConfigError, Forbidden, InternalServerError, Locked, NotFound, ServiceUnavailable, TooManyRequests, Unauthorized, UnprocessableEntity, HTTP_STATUS_MAP, DEFAULT_ERRORS, API_ERRORS, } from "@distilled.cloud/core/errors";
|
|
7
|
+
export { BadGateway, BadRequest, Conflict, ConfigError, Forbidden, GatewayTimeout, InternalServerError, Locked, NotFound, ServiceUnavailable, TooManyRequests, Unauthorized, UnprocessableEntity, HTTP_STATUS_MAP, DEFAULT_ERRORS, API_ERRORS, } from "@distilled.cloud/core/errors";
|
|
8
8
|
export type { DefaultErrors } from "@distilled.cloud/core/errors";
|
|
9
9
|
import * as Schema from "effect/Schema";
|
|
10
|
-
declare const
|
|
10
|
+
declare const UnknownNeonError_base: Schema.ErrorClass<UnknownNeonError, Schema.TaggedStruct<"UnknownNeonError", {
|
|
11
11
|
readonly code: Schema.optional<Schema.String>;
|
|
12
12
|
readonly message: Schema.optional<Schema.String>;
|
|
13
13
|
readonly body: Schema.Unknown;
|
|
@@ -16,7 +16,7 @@ declare const NeonApiError_base: Schema.ErrorClass<NeonApiError, Schema.TaggedSt
|
|
|
16
16
|
ServerError: true;
|
|
17
17
|
};
|
|
18
18
|
});
|
|
19
|
-
export declare class
|
|
19
|
+
export declare class UnknownNeonError extends UnknownNeonError_base {
|
|
20
20
|
}
|
|
21
21
|
declare const NeonParseError_base: Schema.ErrorClass<NeonParseError, Schema.TaggedStruct<"NeonParseError", {
|
|
22
22
|
readonly body: Schema.Unknown;
|
package/lib/errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACL,UAAU,EACV,QAAQ,EACR,WAAW,EACX,SAAS,EACT,mBAAmB,EACnB,MAAM,EACN,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,
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACL,UAAU,EACV,UAAU,EACV,QAAQ,EACR,WAAW,EACX,SAAS,EACT,cAAc,EACd,mBAAmB,EACnB,MAAM,EACN,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,gBAAiB,SAAQ,qBAON;CAAG;;;;;;;;;AAGnC,qBAAa,cAAe,SAAQ,mBAML;CAAG"}
|
package/lib/errors.js
CHANGED
|
@@ -4,11 +4,11 @@
|
|
|
4
4
|
* Re-exports common HTTP errors from sdk-core and adds Neon-specific
|
|
5
5
|
* error matching and API error types.
|
|
6
6
|
*/
|
|
7
|
-
export { BadRequest, Conflict, ConfigError, Forbidden, InternalServerError, Locked, NotFound, ServiceUnavailable, TooManyRequests, Unauthorized, UnprocessableEntity, HTTP_STATUS_MAP, DEFAULT_ERRORS, API_ERRORS, } from "@distilled.cloud/core/errors";
|
|
7
|
+
export { BadGateway, BadRequest, Conflict, ConfigError, Forbidden, GatewayTimeout, InternalServerError, Locked, NotFound, ServiceUnavailable, TooManyRequests, Unauthorized, UnprocessableEntity, HTTP_STATUS_MAP, DEFAULT_ERRORS, API_ERRORS, } from "@distilled.cloud/core/errors";
|
|
8
8
|
import * as Schema from "effect/Schema";
|
|
9
9
|
import * as Category from "@distilled.cloud/core/category";
|
|
10
|
-
//
|
|
11
|
-
export class
|
|
10
|
+
// Unknown Neon error - returned when an error code is not recognized
|
|
11
|
+
export class UnknownNeonError extends Schema.TaggedErrorClass()("UnknownNeonError", {
|
|
12
12
|
code: Schema.optional(Schema.String),
|
|
13
13
|
message: Schema.optional(Schema.String),
|
|
14
14
|
body: Schema.Unknown,
|
package/lib/errors.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACL,UAAU,EACV,QAAQ,EACR,WAAW,EACX,SAAS,EACT,mBAAmB,EACnB,MAAM,EACN,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;AACxC,OAAO,KAAK,QAAQ,MAAM,gCAAgC,CAAC;AAE3D,
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EACL,UAAU,EACV,UAAU,EACV,QAAQ,EACR,WAAW,EACX,SAAS,EACT,cAAc,EACd,mBAAmB,EACnB,MAAM,EACN,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;AACxC,OAAO,KAAK,QAAQ,MAAM,gCAAgC,CAAC;AAE3D,qEAAqE;AACrE,MAAM,OAAO,gBAAiB,SAAQ,MAAM,CAAC,gBAAgB,EAAoB,CAC/E,kBAAkB,EAClB;IACE,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;IACpC,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;IACvC,IAAI,EAAE,MAAM,CAAC,OAAO;CACrB,CACF,CAAC,IAAI,CAAC,QAAQ,CAAC,eAAe,CAAC;CAAG;AAEnC,6BAA6B;AAC7B,MAAM,OAAO,cAAe,SAAQ,MAAM,CAAC,gBAAgB,EAAkB,CAC3E,gBAAgB,EAChB;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/neon",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/alchemy-run/distilled",
|
|
@@ -73,8 +73,8 @@
|
|
|
73
73
|
"specs:update": "git -C specs/distilled-spec-neon fetch && git -C specs/distilled-spec-neon checkout main && git -C specs/distilled-spec-neon pull"
|
|
74
74
|
},
|
|
75
75
|
"dependencies": {
|
|
76
|
-
"@distilled.cloud/core": "0.2.0",
|
|
77
|
-
"effect": "4.0.0-beta.
|
|
76
|
+
"@distilled.cloud/core": "0.2.0-alpha",
|
|
77
|
+
"effect": "4.0.0-beta.30"
|
|
78
78
|
},
|
|
79
79
|
"devDependencies": {
|
|
80
80
|
"@types/bun": "^1.3.0",
|
|
@@ -83,6 +83,6 @@
|
|
|
83
83
|
"vitest": "^3.2.3"
|
|
84
84
|
},
|
|
85
85
|
"peerDependencies": {
|
|
86
|
-
"effect": "4.0.0-beta.
|
|
86
|
+
"effect": "4.0.0-beta.30"
|
|
87
87
|
}
|
|
88
88
|
}
|
package/src/client.ts
CHANGED
|
@@ -7,10 +7,10 @@
|
|
|
7
7
|
import * as Effect from "effect/Effect";
|
|
8
8
|
import * as Schema from "effect/Schema";
|
|
9
9
|
import { makeAPI } from "@distilled.cloud/core/client";
|
|
10
|
-
import { HTTP_STATUS_MAP,
|
|
10
|
+
import { HTTP_STATUS_MAP, UnknownNeonError, NeonParseError } from "./errors.ts";
|
|
11
11
|
|
|
12
|
-
// Re-export for backwards compatibility (tests import
|
|
13
|
-
export {
|
|
12
|
+
// Re-export for backwards compatibility (tests import UnknownNeonError from client)
|
|
13
|
+
export { UnknownNeonError } from "./errors.ts";
|
|
14
14
|
import { Credentials } from "./credentials.ts";
|
|
15
15
|
|
|
16
16
|
// API Error Response Schema
|
|
@@ -33,14 +33,14 @@ const matchError = (
|
|
|
33
33
|
return Effect.fail(new ErrorClass({ message: parsed.message ?? "" }));
|
|
34
34
|
}
|
|
35
35
|
return Effect.fail(
|
|
36
|
-
new
|
|
36
|
+
new UnknownNeonError({
|
|
37
37
|
code: parsed.code,
|
|
38
38
|
message: parsed.message,
|
|
39
39
|
body: errorBody,
|
|
40
40
|
}),
|
|
41
41
|
);
|
|
42
42
|
} catch {
|
|
43
|
-
return Effect.fail(new
|
|
43
|
+
return Effect.fail(new UnknownNeonError({ body: errorBody }));
|
|
44
44
|
}
|
|
45
45
|
};
|
|
46
46
|
|
package/src/errors.ts
CHANGED
|
@@ -5,10 +5,12 @@
|
|
|
5
5
|
* error matching and API error types.
|
|
6
6
|
*/
|
|
7
7
|
export {
|
|
8
|
+
BadGateway,
|
|
8
9
|
BadRequest,
|
|
9
10
|
Conflict,
|
|
10
11
|
ConfigError,
|
|
11
12
|
Forbidden,
|
|
13
|
+
GatewayTimeout,
|
|
12
14
|
InternalServerError,
|
|
13
15
|
Locked,
|
|
14
16
|
NotFound,
|
|
@@ -25,9 +27,9 @@ export type { DefaultErrors } from "@distilled.cloud/core/errors";
|
|
|
25
27
|
import * as Schema from "effect/Schema";
|
|
26
28
|
import * as Category from "@distilled.cloud/core/category";
|
|
27
29
|
|
|
28
|
-
//
|
|
29
|
-
export class
|
|
30
|
-
"
|
|
30
|
+
// Unknown Neon error - returned when an error code is not recognized
|
|
31
|
+
export class UnknownNeonError extends Schema.TaggedErrorClass<UnknownNeonError>()(
|
|
32
|
+
"UnknownNeonError",
|
|
31
33
|
{
|
|
32
34
|
code: Schema.optional(Schema.String),
|
|
33
35
|
message: Schema.optional(Schema.String),
|