@distilled.cloud/porkbun 1.0.0-rc.13 → 1.0.0-rc.15
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/lib/credentials.d.ts +3 -3
- package/lib/credentials.d.ts.map +1 -1
- package/lib/credentials.js +4 -4
- package/lib/credentials.js.map +1 -1
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +1 -1
- package/lib/errors.js.map +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -2
- package/lib/index.js.map +1 -1
- package/lib/protocol.d.ts +3 -3
- package/lib/protocol.d.ts.map +1 -1
- package/lib/protocol.js +2 -6
- package/lib/protocol.js.map +1 -1
- package/lib/retry.d.ts +1 -1
- package/lib/retry.d.ts.map +1 -1
- package/lib/retry.js +1 -1
- package/lib/retry.js.map +1 -1
- package/lib/services/porkbun.d.ts +1134 -32
- package/lib/services/porkbun.d.ts.map +1 -1
- package/lib/services/porkbun.js +1225 -434
- package/lib/services/porkbun.js.map +1 -1
- package/package.json +12 -10
- package/src/credentials.ts +10 -12
- package/src/errors.ts +1 -1
- package/src/index.ts +2 -6
- package/src/protocol.ts +21 -30
- package/src/retry.ts +2 -8
- package/src/services/porkbun.ts +3044 -913
- package/lib/response-validation.test.d.ts +0 -4
- package/lib/response-validation.test.d.ts.map +0 -1
- package/lib/response-validation.test.js +0 -32
- package/lib/response-validation.test.js.map +0 -1
- package/src/response-validation.test.ts +0 -46
package/package.json
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@distilled.cloud/porkbun",
|
|
3
|
-
"version": "1.0.0-rc.
|
|
3
|
+
"version": "1.0.0-rc.15",
|
|
4
|
+
"license": "Apache-2.0",
|
|
4
5
|
"repository": {
|
|
5
6
|
"type": "git",
|
|
6
7
|
"url": "https://github.com/alchemy-run/distilled",
|
|
7
8
|
"directory": "packages/porkbun"
|
|
8
9
|
},
|
|
9
|
-
"license": "Apache-2.0",
|
|
10
|
-
"type": "module",
|
|
11
|
-
"sideEffects": false,
|
|
12
10
|
"files": [
|
|
13
11
|
"lib",
|
|
14
12
|
"src"
|
|
15
13
|
],
|
|
14
|
+
"type": "module",
|
|
15
|
+
"sideEffects": false,
|
|
16
16
|
"exports": {
|
|
17
17
|
".": {
|
|
18
18
|
"types": "./lib/index.d.ts",
|
|
@@ -64,20 +64,22 @@
|
|
|
64
64
|
}
|
|
65
65
|
},
|
|
66
66
|
"dependencies": {
|
|
67
|
-
"@distilled.cloud/core": "1.0.0-rc.
|
|
67
|
+
"@distilled.cloud/core": "1.0.0-rc.15"
|
|
68
68
|
},
|
|
69
69
|
"devDependencies": {
|
|
70
|
-
"@types/
|
|
71
|
-
"@types/node": "26.2.0",
|
|
72
|
-
"@effect/platform-bun": "^4.0.0"
|
|
70
|
+
"@types/node": "26.2.0"
|
|
73
71
|
},
|
|
74
72
|
"peerDependencies": {
|
|
75
73
|
"effect": "^4.0.0"
|
|
76
74
|
},
|
|
75
|
+
"distilled": {
|
|
76
|
+
"generatedAt": "2026-10-06",
|
|
77
|
+
"specUpdatedAt": "2026-10-06"
|
|
78
|
+
},
|
|
77
79
|
"scripts": {
|
|
78
80
|
"build": "tsc -b",
|
|
79
|
-
"convert": "bun scripts/convert.ts",
|
|
80
|
-
"generate": "bun scripts/convert.ts && bun scripts/generate.ts",
|
|
81
|
+
"convert": "node --conditions=bun scripts/convert.ts",
|
|
82
|
+
"generate": "node --conditions=bun scripts/convert.ts && node --conditions=bun scripts/generate.ts",
|
|
81
83
|
"typecheck": "tsc -p tsconfig.json",
|
|
82
84
|
"specs:fetch": "git submodule update --force --init --depth=1 specs/spec-mirror-porkbun",
|
|
83
85
|
"specs:update": "git submodule update --remote --force --depth=1 specs/spec-mirror-porkbun"
|
package/src/credentials.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ConfigError } from "@distilled.cloud/core/errors";
|
|
1
2
|
/**
|
|
2
3
|
* Porkbun credentials — hand-written.
|
|
3
4
|
*
|
|
@@ -11,7 +12,6 @@ import * as Context from "effect/Context";
|
|
|
11
12
|
import * as Effect from "effect/Effect";
|
|
12
13
|
import * as Layer from "effect/Layer";
|
|
13
14
|
import * as Redacted from "effect/Redacted";
|
|
14
|
-
import { ConfigError } from "@distilled.cloud/core/errors";
|
|
15
15
|
|
|
16
16
|
export const DEFAULT_API_BASE_URL = "https://api.porkbun.com/api/json/v3";
|
|
17
17
|
|
|
@@ -21,10 +21,9 @@ export interface Config {
|
|
|
21
21
|
readonly apiBaseUrl: string;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
export class Credentials extends Context.Service<
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
>()("PorkbunCredentials") {}
|
|
24
|
+
export class Credentials extends Context.Service<Credentials, Effect.Effect<Config>>()(
|
|
25
|
+
"PorkbunCredentials",
|
|
26
|
+
) {}
|
|
28
27
|
|
|
29
28
|
/** Auth headers for a resolved credentials config. */
|
|
30
29
|
export const formatHeaders = (config: Config): Record<string, string> => ({
|
|
@@ -32,17 +31,17 @@ export const formatHeaders = (config: Config): Record<string, string> => ({
|
|
|
32
31
|
"X-Secret-API-Key": Redacted.value(config.secretApiKey),
|
|
33
32
|
});
|
|
34
33
|
|
|
35
|
-
/** Layer from a
|
|
34
|
+
/** Layer from a redacted API key pair + optional base URL. */
|
|
36
35
|
export const fromApiKey = (config: {
|
|
37
|
-
readonly apiKey: string
|
|
38
|
-
readonly secretApiKey: string
|
|
36
|
+
readonly apiKey: Redacted.Redacted<string>;
|
|
37
|
+
readonly secretApiKey: Redacted.Redacted<string>;
|
|
39
38
|
readonly apiBaseUrl?: string;
|
|
40
39
|
}): Layer.Layer<Credentials> =>
|
|
41
40
|
Layer.succeed(
|
|
42
41
|
Credentials,
|
|
43
42
|
Effect.succeed({
|
|
44
|
-
apiKey:
|
|
45
|
-
secretApiKey:
|
|
43
|
+
apiKey: config.apiKey,
|
|
44
|
+
secretApiKey: config.secretApiKey,
|
|
46
45
|
apiBaseUrl: config.apiBaseUrl ?? DEFAULT_API_BASE_URL,
|
|
47
46
|
}),
|
|
48
47
|
);
|
|
@@ -59,8 +58,7 @@ export const CredentialsFromEnv: Layer.Layer<Credentials> = Layer.succeed(
|
|
|
59
58
|
|
|
60
59
|
if (!apiKey || !secretApiKey) {
|
|
61
60
|
return yield* new ConfigError({
|
|
62
|
-
message:
|
|
63
|
-
"PORKBUN_API_KEY and PORKBUN_SECRET_API_KEY environment variables are required",
|
|
61
|
+
message: "PORKBUN_API_KEY and PORKBUN_SECRET_API_KEY environment variables are required",
|
|
64
62
|
});
|
|
65
63
|
}
|
|
66
64
|
|
package/src/errors.ts
CHANGED
|
@@ -27,8 +27,8 @@ export {
|
|
|
27
27
|
} from "@distilled.cloud/core/errors";
|
|
28
28
|
export type { DefaultErrors } from "@distilled.cloud/core/errors";
|
|
29
29
|
|
|
30
|
-
import * as Schema from "effect/Schema";
|
|
31
30
|
import * as Category from "@distilled.cloud/core/category";
|
|
31
|
+
import * as Schema from "effect/Schema";
|
|
32
32
|
|
|
33
33
|
/** Unknown Porkbun error — returned when nothing else matches the failure. */
|
|
34
34
|
export class UnknownPorkbunError extends Schema.TaggedError<UnknownPorkbunError>()(
|
package/src/index.ts
CHANGED
|
@@ -15,11 +15,7 @@
|
|
|
15
15
|
export * from "./credentials.ts";
|
|
16
16
|
export * from "./errors.ts";
|
|
17
17
|
export * as T from "./traits.ts";
|
|
18
|
-
export {
|
|
19
|
-
PorkbunProtocol,
|
|
20
|
-
type PorkbunOpError,
|
|
21
|
-
type PorkbunOpContext,
|
|
22
|
-
} from "./protocol.ts";
|
|
18
|
+
export { PorkbunProtocol, type PorkbunOpError, type PorkbunOpContext } from "./protocol.ts";
|
|
23
19
|
export { paginateCursor } from "./pagination.ts";
|
|
24
20
|
export * as Retry from "./retry.ts";
|
|
25
21
|
export * as Services from "./services/index.ts";
|
|
@@ -28,4 +24,4 @@ export * as Services from "./services/index.ts";
|
|
|
28
24
|
// same-named shared ones from ./errors.ts — the ops actually raise the
|
|
29
25
|
// service-local classes.
|
|
30
26
|
export * from "./services/porkbun.ts";
|
|
31
|
-
export { BadRequest, Forbidden, NotFound } from "./services/porkbun.ts";
|
|
27
|
+
export { BadRequest, Conflict, Forbidden, NotFound } from "./services/porkbun.ts";
|
package/src/protocol.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import type * as API from "@distilled.cloud/core/api";
|
|
2
|
+
import type { API_ERRORS, ConfigError } from "@distilled.cloud/core/errors";
|
|
3
|
+
import { makeRestProtocol, type RestErrorEnvelope } from "@distilled.cloud/core/protocol-rest";
|
|
1
4
|
/**
|
|
2
5
|
* PorkbunProtocol — hand-written.
|
|
3
6
|
*
|
|
@@ -16,15 +19,9 @@
|
|
|
16
19
|
* {@link UnknownPorkbunError}.
|
|
17
20
|
*/
|
|
18
21
|
import * as Effect from "effect/Effect";
|
|
19
|
-
import type * as Layer from "effect/Layer";
|
|
20
22
|
import type * as HttpClient from "effect/http/HttpClient";
|
|
21
23
|
import type * as HttpClientError from "effect/http/HttpClientError";
|
|
22
|
-
import type * as
|
|
23
|
-
import {
|
|
24
|
-
makeRestProtocol,
|
|
25
|
-
type RestErrorEnvelope,
|
|
26
|
-
} from "@distilled.cloud/core/protocol-rest";
|
|
27
|
-
import type { API_ERRORS, ConfigError } from "@distilled.cloud/core/errors";
|
|
24
|
+
import type * as Layer from "effect/Layer";
|
|
28
25
|
import { Credentials, formatHeaders, type Config } from "./credentials.ts";
|
|
29
26
|
import { UnknownPorkbunError, PorkbunParseError } from "./errors.ts";
|
|
30
27
|
|
|
@@ -59,27 +56,21 @@ const errorEnvelope = (body: unknown): RestErrorEnvelope | undefined => {
|
|
|
59
56
|
};
|
|
60
57
|
};
|
|
61
58
|
|
|
62
|
-
export const PorkbunProtocol: Layer.Layer<API.Protocol> =
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
59
|
+
export const PorkbunProtocol: Layer.Layer<API.Protocol> = makeRestProtocol<Config>({
|
|
60
|
+
// The Credentials service holds an effect — resolving it here (per
|
|
61
|
+
// request, on the calling fiber) picks up context-provided credentials.
|
|
62
|
+
credentials: Effect.gen(function* () {
|
|
63
|
+
const resolve = yield* Credentials;
|
|
64
|
+
return yield* resolve;
|
|
65
|
+
}),
|
|
66
|
+
baseUrl: (creds) => creds.apiBaseUrl,
|
|
67
|
+
headers: (creds) => formatHeaders(creds),
|
|
68
|
+
errorEnvelope,
|
|
69
|
+
unknownError: ({ code, message, body }) =>
|
|
70
|
+
new UnknownPorkbunError({
|
|
71
|
+
code: typeof code === "string" ? code : code !== undefined ? String(code) : undefined,
|
|
72
|
+
message,
|
|
73
|
+
body,
|
|
69
74
|
}),
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
errorEnvelope,
|
|
73
|
-
unknownError: ({ code, message, body }) =>
|
|
74
|
-
new UnknownPorkbunError({
|
|
75
|
-
code:
|
|
76
|
-
typeof code === "string"
|
|
77
|
-
? code
|
|
78
|
-
: code !== undefined
|
|
79
|
-
? String(code)
|
|
80
|
-
: undefined,
|
|
81
|
-
message,
|
|
82
|
-
body,
|
|
83
|
-
}),
|
|
84
|
-
parseError: ({ body, cause }) => new PorkbunParseError({ body, cause }),
|
|
85
|
-
});
|
|
75
|
+
parseError: ({ body, cause }) => new PorkbunParseError({ body, cause }),
|
|
76
|
+
});
|
package/src/retry.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type Policy, throttlingFactory, transientFactory } from "@distilled.cloud/core/retry";
|
|
1
2
|
/**
|
|
2
3
|
* Porkbun retry configuration.
|
|
3
4
|
*
|
|
@@ -16,11 +17,6 @@
|
|
|
16
17
|
import * as Context from "effect/Context";
|
|
17
18
|
import * as Effect from "effect/Effect";
|
|
18
19
|
import * as Layer from "effect/Layer";
|
|
19
|
-
import {
|
|
20
|
-
type Policy,
|
|
21
|
-
throttlingFactory,
|
|
22
|
-
transientFactory,
|
|
23
|
-
} from "@distilled.cloud/core/retry";
|
|
24
20
|
|
|
25
21
|
export {
|
|
26
22
|
type Options,
|
|
@@ -43,9 +39,7 @@ export const policy = (optionsOrFactory: Policy) =>
|
|
|
43
39
|
Effect.provide(Layer.succeed(Retry, optionsOrFactory));
|
|
44
40
|
|
|
45
41
|
/** Disables all automatic retries. */
|
|
46
|
-
export const none = Effect.provide(
|
|
47
|
-
Layer.succeed(Retry, { while: () => false }),
|
|
48
|
-
);
|
|
42
|
+
export const none = Effect.provide(Layer.succeed(Retry, { while: () => false }));
|
|
49
43
|
|
|
50
44
|
/** Apply the throttling retry policy (retries throttling errors indefinitely). */
|
|
51
45
|
export const throttling = policy(throttlingFactory);
|