@distilled.cloud/fly-io 1.0.0-rc.14 → 1.0.0-rc.16

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.
Files changed (61) hide show
  1. package/lib/credentials.d.ts +3 -3
  2. package/lib/credentials.d.ts.map +1 -1
  3. package/lib/credentials.js +43 -38
  4. package/lib/credentials.js.map +1 -1
  5. package/lib/errors.d.ts +24 -24
  6. package/lib/errors.d.ts.map +1 -1
  7. package/lib/errors.js +37 -37
  8. package/lib/errors.js.map +1 -1
  9. package/lib/index.d.ts +2 -2
  10. package/lib/index.js +31 -31
  11. package/lib/pagination.d.ts +1 -1
  12. package/lib/pagination.js +3 -3
  13. package/lib/protocol.d.ts +2 -2
  14. package/lib/protocol.d.ts.map +1 -1
  15. package/lib/protocol.js +89 -66
  16. package/lib/protocol.js.map +1 -1
  17. package/lib/retry.d.ts +1 -1
  18. package/lib/retry.d.ts.map +1 -1
  19. package/lib/retry.js +26 -25
  20. package/lib/retry.js.map +1 -1
  21. package/lib/services/addons.d.ts +0 -65
  22. package/lib/services/addons.d.ts.map +1 -1
  23. package/lib/services/addons.js +54 -561
  24. package/lib/services/machines.d.ts +25 -444
  25. package/lib/services/machines.d.ts.map +1 -1
  26. package/lib/services/machines.js +317 -2726
  27. package/lib/services/mpg.d.ts +1 -67
  28. package/lib/services/mpg.d.ts.map +1 -1
  29. package/lib/services/mpg.js +75 -448
  30. package/lib/services/sprites.d.ts +1 -125
  31. package/lib/services/sprites.d.ts.map +1 -1
  32. package/lib/services/sprites.js +146 -884
  33. package/lib/traits.d.ts.map +1 -1
  34. package/lib/traits.js +14 -14
  35. package/lib/traits.js.map +1 -1
  36. package/package.json +13 -9
  37. package/src/credentials.ts +18 -15
  38. package/src/errors.ts +26 -28
  39. package/src/index.ts +2 -2
  40. package/src/pagination.ts +1 -1
  41. package/src/protocol.ts +67 -36
  42. package/src/retry.ts +6 -4
  43. package/src/services/addons.ts +593 -692
  44. package/src/services/machines.ts +3332 -3364
  45. package/src/services/mpg.ts +582 -519
  46. package/src/services/sprites.ts +1008 -948
  47. package/src/traits.ts +8 -4
  48. package/lib/protocol.test.d.ts +0 -2
  49. package/lib/protocol.test.d.ts.map +0 -1
  50. package/lib/protocol.test.js +0 -126
  51. package/lib/protocol.test.js.map +0 -1
  52. package/lib/services/addons.js.map +0 -1
  53. package/lib/services/machines.js.map +0 -1
  54. package/lib/services/mpg.js.map +0 -1
  55. package/lib/services/sprites.js.map +0 -1
  56. package/lib/sprites-mint.test.d.ts +0 -2
  57. package/lib/sprites-mint.test.d.ts.map +0 -1
  58. package/lib/sprites-mint.test.js +0 -169
  59. package/lib/sprites-mint.test.js.map +0 -1
  60. package/src/protocol.test.ts +0 -214
  61. package/src/sprites-mint.test.ts +0 -228
@@ -1 +1 @@
1
- {"version":3,"file":"traits.d.ts","sourceRoot":"","sources":["../src/traits.ts"],"names":[],"mappings":"AAUA,OAAO,EACL,IAAI,EACJ,MAAM,EACN,KAAK,EACL,KAAK,EACL,IAAI,EACJ,YAAY,EACZ,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,UAAU,EACV,kBAAkB,EAClB,gBAAgB,EAChB,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,UAAU,EACV,YAAY,EACZ,WAAW,EACX,WAAW,EACX,UAAU,EACV,kBAAkB,EAClB,cAAc,EACd,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EACL,WAAW,EACX,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,qCAAqC,CAAC;AAE7C;;;GAGG;AACH,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,IAAI,EAAE,OAAO,GAAG,UAAU,CAAC;CACrC;AA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A6C,CAAC;AAEvF,eAAO,MAAM,wBAAwB,eAEpC,CAAC;AAEF,oEAAoE;AACpE,eAAO,MAAM,kBAAkB,wDAAuD,CAAC"}
package/lib/traits.js CHANGED
@@ -1,21 +1,21 @@
1
- /**
2
- * Fly.io SDK trait surface — hand-written.
3
- *
4
- * Re-exports the generic protocol traits from core so generated operations
5
- * import everything from one place. REST services use the bare-payload and
6
- * sensitive-value traits; GraphQL add-ons add the operation/response-path
7
- * envelope traits.
8
- */
1
+
2
+
3
+
4
+
5
+
6
+
7
+
8
+
9
9
  import { makeAnnotation } from "@distilled.cloud/core/trait";
10
10
  export { Body, Header, Query, Label, Http, ResponseCode, HttpBody, FormDataFile, KeyDictionary, UnionCases, applyErrorMatchers, getErrorMatchers, bodySymbol, headerSymbol, querySymbol, labelSymbol, httpSymbol, responseCodeSymbol, httpBodySymbol, formDataFileSymbol, keyDictionarySymbol, unionCasesSymbol, errorMatchersSymbol, } from "@distilled.cloud/core/trait";
11
11
  export { RawResponse, RawResponseRoot, SensitiveValue, rawResponseSymbol, rawResponseRootSymbol, sensitiveValueSymbol, } from "@distilled.cloud/core/protocol-rest";
12
- export const graphqlOpSymbol = Symbol.for("@distilled.cloud/fly-io/graphql-op");
13
- /** Marks an operation input with its GraphQL document (`com.flyio.graphql#operation`). */
12
+ export const graphqlOpSymbol = /*@__PURE__*/ Symbol.for("@distilled.cloud/fly-io/graphql-op");
13
+
14
14
  export const GraphQLOp = (op) => makeAnnotation(graphqlOpSymbol, op);
15
- export const responsePathSymbol = Symbol.for("@distilled.cloud/fly-io/graphql-response-path");
16
- /** Dotted path under GraphQL `data` (`com.flyio.graphql#responsePath`). */
15
+ export const responsePathSymbol = /*@__PURE__*/ Symbol.for("@distilled.cloud/fly-io/graphql-response-path");
16
+
17
17
  export const ResponsePath = (path) => makeAnnotation(responsePathSymbol, path);
18
- export const graphqlPayloadRootSymbol = Symbol.for("@distilled.cloud/fly-io/graphql-payload-root");
19
- /** Marks a response whose entire value is `data.<responsePath>`. */
18
+ export const graphqlPayloadRootSymbol = /*@__PURE__*/ Symbol.for("@distilled.cloud/fly-io/graphql-payload-root");
19
+
20
20
  export const GraphQLPayloadRoot = () => makeAnnotation(graphqlPayloadRootSymbol, true);
21
21
  //# sourceMappingURL=traits.js.map
package/lib/traits.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"traits.js","sourceRoot":"","sources":["../src/traits.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE7D,OAAO,EACL,IAAI,EACJ,MAAM,EACN,KAAK,EACL,KAAK,EACL,IAAI,EACJ,YAAY,EACZ,QAAQ,EACR,YAAY,EACZ,aAAa,EACb,UAAU,EACV,kBAAkB,EAClB,gBAAgB,EAGhB,UAAU,EACV,YAAY,EACZ,WAAW,EACX,WAAW,EACX,UAAU,EACV,kBAAkB,EAClB,cAAc,EACd,kBAAkB,EAClB,mBAAmB,EACnB,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,6BAA6B,CAAC;AAErC,OAAO,EACL,WAAW,EACX,eAAe,EACf,cAAc,EACd,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,GACrB,MAAM,qCAAqC,CAAC;AAY7C,MAAM,CAAC,MAAM,eAAe,GAAG,MAAM,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC;AAEhF,0FAA0F;AAC1F,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,EAAkB,EAAE,EAAE,CAAC,cAAc,CAAC,eAAe,EAAE,EAAE,CAAC,CAAC;AAErF,MAAM,CAAC,MAAM,kBAAkB,GAAG,MAAM,CAAC,GAAG,CAAC,+CAA+C,CAAC,CAAC;AAE9F,2EAA2E;AAC3E,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,cAAc,CAAC,kBAAkB,EAAE,IAAI,CAAC,CAAC;AAEvF,MAAM,CAAC,MAAM,wBAAwB,GA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,CAAC,GAAG,CAC9D,8CAA8C,CAC/C,CAAC;AAEF,oEAAoE;AACpE,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,EAAE,CAAC,cAAc,CAAC,wBAAwB,EAAE,IAAI,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@distilled.cloud/fly-io",
3
- "version": "1.0.0-rc.14",
3
+ "version": "1.0.0-rc.16",
4
4
  "license": "Apache-2.0",
5
5
  "repository": {
6
6
  "type": "git",
@@ -19,7 +19,9 @@
19
19
  "types": "./lib/index.d.ts",
20
20
  "bun": "./src/index.ts",
21
21
  "worker": "./src/index.ts",
22
- "default": "./lib/index.js"
22
+ "module": "./lib/index.full.js",
23
+ "module-sync": "./lib/index.js",
24
+ "default": "./lib/index.full.js"
23
25
  },
24
26
  "./Credentials": {
25
27
  "types": "./lib/credentials.d.ts",
@@ -85,27 +87,29 @@
85
87
  "types": "./lib/services/*.d.ts",
86
88
  "bun": "./src/services/*.ts",
87
89
  "worker": "./src/services/*.ts",
88
- "default": "./lib/services/*.js"
90
+ "module": "./lib/services.full/*.js",
91
+ "module-sync": "./lib/services/*.js",
92
+ "default": "./lib/services.full/*.js"
89
93
  }
90
94
  },
91
95
  "dependencies": {
92
- "@distilled.cloud/core": "1.0.0-rc.14"
96
+ "@distilled.cloud/core": "1.0.0-rc.16"
93
97
  },
94
98
  "devDependencies": {
95
- "@types/node": "26.2.0"
99
+ "@types/node": "26.6.5"
96
100
  },
97
101
  "peerDependencies": {
98
- "effect": "^4.0.0"
102
+ "effect": "^4.0.5"
99
103
  },
100
104
  "distilled": {
101
- "generatedAt": "2026-10-09",
105
+ "generatedAt": "2026-10-21",
102
106
  "specUpdatedAt": "2026-10-08"
103
107
  },
104
108
  "scripts": {
105
109
  "convert": "node --conditions=bun scripts/convert.ts",
106
110
  "generate": "node --conditions=bun scripts/generate.ts",
107
- "typecheck": "tsc -p tsconfig.json",
108
- "build": "tsc -b",
111
+ "typecheck": "tsrs -p tsconfig.json",
112
+ "build": "tsrs -b",
109
113
  "specs:fetch": "git submodule update --force --init --depth=1 specs/spec-mirror-fly-io",
110
114
  "specs:update": "git submodule update --remote --force --depth=1 specs/spec-mirror-fly-io"
111
115
  }
@@ -1,5 +1,6 @@
1
+ import * as EffectConfig from "@distilled.cloud/core/config";
1
2
  /**
2
- * Fly.io credentials — hand-written.
3
+ * Fly.io credentials -- hand-written.
3
4
  *
4
5
  * The `Credentials` service holds an *effect* that resolves the current
5
6
  * credentials on every request. The protocol layer resolves it per request
@@ -14,7 +15,6 @@
14
15
  * mints a Sprites bearer from `FLY_API_TOKEN` (see `SpritesProtocol`).
15
16
  */
16
17
  import { ConfigError } from "@distilled.cloud/core/errors";
17
- import * as EffectConfig from "effect/Config";
18
18
  import * as Context from "effect/Context";
19
19
  import * as Effect from "effect/Effect";
20
20
  import * as Layer from "effect/Layer";
@@ -30,13 +30,13 @@ export const DEFAULT_API_BASE_URL = "https://api.machines.dev";
30
30
  /** UI-EX REST + GraphQL host (MPG, Tigris, Redis). Not overridable via an invented env var. */
31
31
  export const DEFAULT_FLY_API_BASE_URL = "https://api.fly.io";
32
32
 
33
- /** Sprites REST root. Auth is a bearer minted from `FLY_API_TOKEN` — never `SPRITES_TOKEN`. */
33
+ /** Sprites REST root. Auth is a bearer minted from `FLY_API_TOKEN` -- never `SPRITES_TOKEN`. */
34
34
  export const DEFAULT_SPRITES_API_BASE_URL = "https://api.sprites.dev/v1";
35
35
 
36
36
  /**
37
37
  * Normalize a Fly API hostname into the Machines API base URL.
38
38
  *
39
- * - unset / empty → `https://api.machines.dev`
39
+ * - unset / empty -> `https://api.machines.dev`
40
40
  * - trailing slashes stripped
41
41
  * - a trailing `/v1` is dropped: `flyctl` and older consumers set
42
42
  * `FLY_API_HOSTNAME` to the `/v1` root, and the routes already carry it
@@ -53,27 +53,30 @@ export interface Config {
53
53
  readonly apiBaseUrl: string;
54
54
  }
55
55
 
56
- export class Credentials extends Context.Service<Credentials, Effect.Effect<Config>>()(
57
- "Fly-ioCredentials",
58
- ) {}
56
+ export class Credentials
57
+ extends /*@__PURE__*/ Context.Service<Credentials, Effect.Effect<Config>>()(
58
+ "Fly-ioCredentials",
59
+ ) {}
59
60
 
60
- const envConfig = EffectConfig.all({
61
- apiKey: EffectConfig.String("FLY_API_TOKEN").pipe(
62
- EffectConfig.orElse(() => EffectConfig.String("FLY_IO_API_KEY")),
61
+ const envConfig = /*@__PURE__*/ EffectConfig.all({
62
+ apiKey: /*@__PURE__*/ EffectConfig.String("FLY_API_TOKEN").pipe(
63
+ /*@__PURE__*/ EffectConfig.orElse(() => EffectConfig.String("FLY_IO_API_KEY")),
64
+ ),
65
+ apiBaseUrl: /*@__PURE__*/ EffectConfig.String("FLY_API_HOSTNAME").pipe(
66
+ /*@__PURE__*/ EffectConfig.withDefault(""),
63
67
  ),
64
- apiBaseUrl: EffectConfig.String("FLY_API_HOSTNAME").pipe(EffectConfig.withDefault("")),
65
68
  });
66
69
 
67
- export const CredentialsFromEnv = Layer.succeed(
70
+ export const CredentialsFromEnv = /*@__PURE__*/ Layer.succeed(
68
71
  Credentials,
69
- envConfig.pipe(
70
- Effect.mapError(
72
+ /*@__PURE__*/ envConfig.pipe(
73
+ /*@__PURE__*/ Effect.mapError(
71
74
  () =>
72
75
  new ConfigError({
73
76
  message: "FLY_API_TOKEN (or FLY_IO_API_KEY) environment variable is required",
74
77
  }),
75
78
  ),
76
- Effect.map(({ apiKey, apiBaseUrl }) => ({
79
+ /*@__PURE__*/ Effect.map(({ apiKey, apiBaseUrl }) => ({
77
80
  apiKey: Redacted.make(apiKey),
78
81
  apiBaseUrl: normalizeApiBaseUrl(apiBaseUrl || undefined),
79
82
  })),
package/src/errors.ts CHANGED
@@ -27,42 +27,39 @@ export {
27
27
  } from "@distilled.cloud/core/errors";
28
28
  import * as Category from "@distilled.cloud/core/category";
29
29
  import type { DefaultErrors as CoreDefaultErrors } from "@distilled.cloud/core/errors";
30
+ import * as Schema from "@distilled.cloud/core/schema-lite-typed";
30
31
  import { applyErrorMatchers } from "@distilled.cloud/core/trait";
31
- import * as Schema from "effect/Schema";
32
32
 
33
33
  /**
34
- * Unknown Fly.io error — returned when a failure matches no status-mapped
34
+ * Unknown Fly.io error -- returned when a failure matches no status-mapped
35
35
  * error class. Carries the raw body for later cataloging.
36
36
  */
37
- export class UnknownFlyIoError extends Schema.TaggedError<UnknownFlyIoError>()(
38
- "UnknownFlyIoError",
39
- {
40
- code: Schema.optional(Schema.String),
41
- message: Schema.optional(Schema.String),
37
+ export class UnknownFlyIoError
38
+ extends /*@__PURE__*/ Schema.TaggedError<UnknownFlyIoError>()("UnknownFlyIoError", {
39
+ code: /*@__PURE__*/ Schema.optional(Schema.String),
40
+ message: /*@__PURE__*/ Schema.optional(Schema.String),
42
41
  body: Schema.Unknown,
43
- },
44
- ).pipe(Category.withServerError) {}
42
+ }).pipe(Category.withServerError) {}
45
43
 
46
44
  /** Schema parse error wrapper. */
47
- export class FlyIoParseError extends Schema.TaggedError<FlyIoParseError>()("FlyIoParseError", {
48
- body: Schema.Unknown,
49
- cause: Schema.Unknown,
50
- }).pipe(Category.withParseError) {}
45
+ export class FlyIoParseError
46
+ extends /*@__PURE__*/ Schema.TaggedError<FlyIoParseError>()("FlyIoParseError", {
47
+ body: Schema.Unknown,
48
+ cause: Schema.Unknown,
49
+ }).pipe(Category.withParseError) {}
51
50
 
52
51
  /**
53
52
  * Sprites is not enabled for the Fly organization that owns `FLY_API_TOKEN`.
54
53
  *
55
54
  * Returned by `POST /v1/organizations/{org}/tokens` as HTTP 401 with a
56
55
  * message matching `sprites not enabled`. Sprite CRUD never sees a
57
- * `SPRITES_TOKEN` — this is the mint-time entitlement signal.
56
+ * `SPRITES_TOKEN` -- this is the mint-time entitlement signal.
58
57
  */
59
- export class SpritesNotEnabled extends Schema.TaggedError<SpritesNotEnabled>()(
60
- "SpritesNotEnabled",
61
- {
62
- code: Schema.optional(Schema.Int),
63
- message: Schema.optional(Schema.String),
64
- },
65
- ).pipe(Category.withAuthError) {}
58
+ export class SpritesNotEnabled
59
+ extends /*@__PURE__*/ Schema.TaggedError<SpritesNotEnabled>()("SpritesNotEnabled", {
60
+ code: /*@__PURE__*/ Schema.optional(Schema.Int),
61
+ message: /*@__PURE__*/ Schema.optional(Schema.String),
62
+ }).pipe(Category.withAuthError) {}
66
63
  applyErrorMatchers(SpritesNotEnabled, [
67
64
  { status: 401, message: { matches: "[Ss]prites not enabled" } },
68
65
  ]);
@@ -72,13 +69,14 @@ applyErrorMatchers(SpritesNotEnabled, [
72
69
  * (`createExtensionTosAgreement`). GraphQL returns this as a 200
73
70
  * with `Not authorized to access this createextensiontosagreement`.
74
71
  */
75
- export class CreateExtensionTosAgreementNotAuthorized extends Schema.TaggedError<CreateExtensionTosAgreementNotAuthorized>()(
76
- "CreateExtensionTosAgreementNotAuthorized",
77
- {
78
- code: Schema.optional(Schema.Int),
79
- message: Schema.optional(Schema.String),
80
- },
81
- ).pipe(Category.withAuthError) {}
72
+ export class CreateExtensionTosAgreementNotAuthorized
73
+ extends /*@__PURE__*/ Schema.TaggedError<CreateExtensionTosAgreementNotAuthorized>()(
74
+ "CreateExtensionTosAgreementNotAuthorized",
75
+ {
76
+ code: /*@__PURE__*/ Schema.optional(Schema.Int),
77
+ message: /*@__PURE__*/ Schema.optional(Schema.String),
78
+ },
79
+ ).pipe(Category.withAuthError) {}
82
80
  applyErrorMatchers(CreateExtensionTosAgreementNotAuthorized, [
83
81
  {
84
82
  message: {
package/src/index.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  /**
2
- * @distilled.cloud/fly-io — Fly.io SDK for Effect.
2
+ * @distilled.cloud/fly-io -- Fly.io SDK for Effect.
3
3
  *
4
4
  * `./services` is generated by `scripts/generate.ts` from the Smithy model
5
- * written by `scripts/convert.ts` (OpenAPI → Smithy via the shared core
5
+ * written by `scripts/convert.ts` (OpenAPI -> Smithy via the shared core
6
6
  * converter). Everything else in this folder is hand-written.
7
7
  *
8
8
  * The generated barrel is re-exported at the package root, same as every
package/src/pagination.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Fly.io pagination — cursor (Sprites list) and Relay (GraphQL add-ons).
2
+ * Fly.io pagination -- cursor (Sprites list) and Relay (GraphQL add-ons).
3
3
  */
4
4
  export {
5
5
  paginateCursor,
package/src/protocol.ts CHANGED
@@ -11,14 +11,19 @@ import {
11
11
  matchTypedError,
12
12
  } from "@distilled.cloud/core/protocol-http";
13
13
  import {
14
+ hasSensitiveMember,
14
15
  makeRestProtocol,
15
16
  unwrapRedactedDeep,
16
17
  wrapSensitive,
17
18
  } from "@distilled.cloud/core/protocol-rest";
18
- import { failIfStrict, validateResponse } from "@distilled.cloud/core/response-validation";
19
+ import {
20
+ failUnlessLenient,
21
+ validateResponse,
22
+ withholdActual,
23
+ } from "@distilled.cloud/core/response-validation";
19
24
  import { parseRetryAfterForStatus } from "@distilled.cloud/core/retry-after";
20
25
  /**
21
- * Fly.io protocols — Machines REST, UI-EX REST (MPG), GraphQL add-ons, and
26
+ * Fly.io protocols -- Machines REST, UI-EX REST (MPG), GraphQL add-ons, and
22
27
  * Sprites REST.
23
28
  *
24
29
  * Machines (`FlyIoProtocol`) is a plain bearer-token JSON API at
@@ -116,7 +121,7 @@ const spritesErrorEnvelope = (body: unknown) => {
116
121
  return { message, code };
117
122
  };
118
123
 
119
- const resolveFlyCreds = Effect.gen(function* () {
124
+ const resolveFlyCreds = /*@__PURE__*/ Effect.gen(function* () {
120
125
  const resolve = yield* Credentials;
121
126
  return yield* resolve;
122
127
  });
@@ -127,11 +132,10 @@ const resolveFlyCreds = Effect.gen(function* () {
127
132
  * GetSecret in the same process; this service only changes headers:
128
133
  * omit `Authorization`, send `Connection: close`.
129
134
  */
130
- export class MachineIdentity extends Context.Service<MachineIdentity, true>()(
131
- "FlyIoMachineIdentity",
132
- ) {}
135
+ export class MachineIdentity
136
+ extends /*@__PURE__*/ Context.Service<MachineIdentity, true>()("FlyIoMachineIdentity") {}
133
137
 
134
- const FlyIoProtocolRest: Layer.Layer<API.Protocol> = makeRestProtocol<Config>({
138
+ const FlyIoProtocolRest: Layer.Layer<API.Protocol> = /*@__PURE__*/ makeRestProtocol<Config>({
135
139
  credentials: resolveFlyCreds,
136
140
  baseUrl: (creds) => creds.apiBaseUrl,
137
141
  headers: (creds) => ({
@@ -142,9 +146,9 @@ const FlyIoProtocolRest: Layer.Layer<API.Protocol> = makeRestProtocol<Config>({
142
146
  parseError: ({ body, cause }) => new FlyIoParseError({ body, cause }),
143
147
  });
144
148
 
145
- export const FlyIoProtocol: Layer.Layer<API.Protocol> = Layer.effect(
149
+ export const FlyIoProtocol: Layer.Layer<API.Protocol> = /*@__PURE__*/ Layer.effect(
146
150
  API.Protocol,
147
- Effect.gen(function* () {
151
+ /*@__PURE__*/ Effect.gen(function* () {
148
152
  const rest = yield* API.Protocol;
149
153
  return API.Protocol.of({
150
154
  encode: (args) =>
@@ -160,10 +164,10 @@ export const FlyIoProtocol: Layer.Layer<API.Protocol> = Layer.effect(
160
164
  decode: rest.decode,
161
165
  });
162
166
  }),
163
- ).pipe(Layer.provide(FlyIoProtocolRest));
167
+ ).pipe(/*@__PURE__*/ Layer.provide(FlyIoProtocolRest));
164
168
 
165
169
  /** MPG UI-EX REST at `https://api.fly.io` with the Machines bearer token. */
166
- export const FlyApiProtocol: Layer.Layer<API.Protocol> = makeRestProtocol<Config>({
170
+ export const FlyApiProtocol: Layer.Layer<API.Protocol> = /*@__PURE__*/ makeRestProtocol<Config>({
167
171
  credentials: resolveFlyCreds,
168
172
  baseUrl: () => DEFAULT_FLY_API_BASE_URL,
169
173
  headers: (creds) => ({
@@ -404,7 +408,7 @@ const mintOnce = (fly: Config) =>
404
408
  if (typeof token !== "string" || token.length === 0) {
405
409
  return yield* fail(
406
410
  new FlyIoParseError({
407
- body: json ?? text,
411
+ body: "[REDACTED]",
408
412
  cause: "mint response missing token",
409
413
  }),
410
414
  );
@@ -413,8 +417,11 @@ const mintOnce = (fly: Config) =>
413
417
  });
414
418
 
415
419
  // Keyed by the Fly token itself: `Redacted` hashes and compares by value.
416
- const mintedTokens = MutableHashMap.empty<Redacted.Redacted<string>, Redacted.Redacted<string>>();
417
- const mintInFlight = MutableHashMap.empty<
420
+ const mintedTokens = /*@__PURE__*/ MutableHashMap.empty<
421
+ Redacted.Redacted<string>,
422
+ Redacted.Redacted<string>
423
+ >();
424
+ const mintInFlight = /*@__PURE__*/ MutableHashMap.empty<
418
425
  Redacted.Redacted<string>,
419
426
  Deferred.Deferred<Redacted.Redacted<string>, Effect.Error<ReturnType<typeof mintOnce>>>
420
427
  >();
@@ -554,24 +561,32 @@ const decodeSpritesResponse = ({
554
561
  }
555
562
 
556
563
  // Strict mode checks the mapped body (or parsed exec frames) against the
557
- // output schema.
564
+ // output schema. For an output with sensitive members, a non-JSON body
565
+ // fails in every mode and parse errors withhold the body.
566
+ const sensitive = hasSensitiveMember(outputAst);
567
+ const reported = sensitive ? "[REDACTED]" : (execFrames ?? (nonJson ? text : json));
568
+ if (nonJson && sensitive) {
569
+ return yield* fail(
570
+ new FlyIoParseError({
571
+ body: "[REDACTED]",
572
+ cause: "Invalid JSON response",
573
+ }),
574
+ );
575
+ }
558
576
  const body: unknown = execFrames ?? parseMaybeNdjson(nonJson ? text : (json ?? {}));
559
577
  const mapped = yield* validateResponse(
560
578
  outputAst,
561
579
  mapKeys(outputAst, body, "decode"),
562
580
  (cause) =>
563
- new FlyIoParseError({
564
- body: execFrames ?? (nonJson ? text : json),
565
- cause,
566
- }),
581
+ new FlyIoParseError({ body: reported, cause: sensitive ? withholdActual(cause) : cause }),
567
582
  ).pipe(Effect.catch(fail));
568
583
  return wrapSensitive(outputAst, mapped);
569
584
  });
570
585
 
571
586
  /** Sprites REST at `https://api.sprites.dev/v1`, minted from `FLY_API_TOKEN`. */
572
- export const SpritesProtocol: Layer.Layer<API.Protocol> = Layer.succeed(
587
+ export const SpritesProtocol: Layer.Layer<API.Protocol> = /*@__PURE__*/ Layer.succeed(
573
588
  API.Protocol,
574
- API.Protocol.of({
589
+ /*@__PURE__*/ API.Protocol.of({
575
590
  encode: (args) =>
576
591
  encodeSpritesRequest(args) as Effect.Effect<HttpClientRequest.HttpClientRequest>,
577
592
  decode: (args) => decodeSpritesResponse(args) as Effect.Effect<unknown>,
@@ -579,25 +594,25 @@ export const SpritesProtocol: Layer.Layer<API.Protocol> = Layer.succeed(
579
594
  );
580
595
 
581
596
  // =============================================================================
582
- // GraphQL add-ons (Tigris, Redis) — POST https://api.fly.io/graphql
597
+ // GraphQL add-ons (Tigris, Redis) -- POST https://api.fly.io/graphql
583
598
  // =============================================================================
584
599
 
585
- const GraphQLError = Schema.Struct({
600
+ const GraphQLError = /*@__PURE__*/ Schema.Struct({
586
601
  message: Schema.String,
587
- path: Schema.optional(Schema.Array(Schema.Unknown)),
588
- extensions: Schema.optional(
589
- Schema.Struct({
590
- code: Schema.optional(Schema.String),
602
+ path: /*@__PURE__*/ Schema.optional(/*@__PURE__*/ Schema.Array(Schema.Unknown)),
603
+ extensions: /*@__PURE__*/ Schema.optional(
604
+ /*@__PURE__*/ Schema.Struct({
605
+ code: /*@__PURE__*/ Schema.optional(Schema.String),
591
606
  }),
592
607
  ),
593
608
  });
594
609
 
595
- const GraphQLEnvelope = Schema.Struct({
596
- data: Schema.optional(Schema.NullOr(Schema.Unknown)),
597
- errors: Schema.optional(Schema.Array(GraphQLError)),
610
+ const GraphQLEnvelope = /*@__PURE__*/ Schema.Struct({
611
+ data: /*@__PURE__*/ Schema.optional(/*@__PURE__*/ Schema.NullOr(Schema.Unknown)),
612
+ errors: /*@__PURE__*/ Schema.optional(/*@__PURE__*/ Schema.Array(GraphQLError)),
598
613
  });
599
614
 
600
- const decodeEnvelope = Schema.decodeUnknownOption(GraphQLEnvelope);
615
+ const decodeEnvelope = /*@__PURE__*/ Schema.decodeUnknownOption(GraphQLEnvelope);
601
616
 
602
617
  const matchGraphqlError = (
603
618
  status: number,
@@ -715,12 +730,23 @@ const graphqlDecode = ({
715
730
  }
716
731
  }
717
732
 
733
+ // For an output with sensitive members, a non-JSON body fails in every
734
+ // mode and parse errors withhold the body.
735
+ const sensitive = hasSensitiveMember(outputAst);
718
736
  if (!parsed) {
719
737
  if (status >= 400) {
720
738
  return yield* matchGraphqlError(status, text, headers, errors);
721
739
  }
740
+ if (sensitive) {
741
+ return yield* fail(
742
+ new FlyIoParseError({
743
+ body: "[REDACTED]",
744
+ cause: "response body is not valid JSON",
745
+ }),
746
+ );
747
+ }
722
748
  // Lenient mode returns the body as read.
723
- return yield* failIfStrict(
749
+ return yield* failUnlessLenient(
724
750
  new FlyIoParseError({
725
751
  body: text,
726
752
  cause: "response body is not valid JSON",
@@ -752,16 +778,21 @@ const graphqlDecode = ({
752
778
  }
753
779
  // Strict mode checks the payload at the response path against the
754
780
  // output schema.
755
- return yield* validateResponse(
781
+ const validated = yield* validateResponse(
756
782
  outputAst,
757
783
  payload === undefined ? null : payload,
758
- (cause) => new FlyIoParseError({ body: json, cause }),
784
+ (cause) =>
785
+ new FlyIoParseError({
786
+ body: sensitive ? "[REDACTED]" : json,
787
+ cause: sensitive ? withholdActual(cause) : cause,
788
+ }),
759
789
  ).pipe(Effect.catch(fail));
790
+ return wrapSensitive(outputAst, validated);
760
791
  });
761
792
 
762
- export const FlyGraphqlProtocol: Layer.Layer<API.Protocol> = Layer.succeed(
793
+ export const FlyGraphqlProtocol: Layer.Layer<API.Protocol> = /*@__PURE__*/ Layer.succeed(
763
794
  API.Protocol,
764
- API.Protocol.of({
795
+ /*@__PURE__*/ API.Protocol.of({
765
796
  encode: (args) => graphqlEncode(args) as Effect.Effect<HttpClientRequest.HttpClientRequest>,
766
797
  decode: graphqlDecode,
767
798
  }),
package/src/retry.ts CHANGED
@@ -33,17 +33,19 @@ export {
33
33
  } from "@distilled.cloud/core/retry";
34
34
 
35
35
  /** Context tag for configuring retry behavior of FlyIo API calls. */
36
- export class Retry extends Context.Service<Retry, Policy>()("FlyIoRetry") {}
36
+ export class Retry extends /*@__PURE__*/ Context.Service<Retry, Policy>()("FlyIoRetry") {}
37
37
 
38
38
  /** Provides a custom retry policy to every FlyIo API call below it. */
39
39
  export const policy = (optionsOrFactory: Policy) =>
40
40
  Effect.provide(Layer.succeed(Retry, optionsOrFactory));
41
41
 
42
42
  /** Disables all automatic retries. */
43
- export const none = Effect.provide(Layer.succeed(Retry, { while: () => false }));
43
+ export const none = /*@__PURE__*/ Effect.provide(
44
+ /*@__PURE__*/ Layer.succeed(Retry, { while: () => false }),
45
+ );
44
46
 
45
47
  /** Apply the throttling retry policy (retries throttling errors indefinitely). */
46
- export const throttling = policy(throttlingFactory);
48
+ export const throttling = /*@__PURE__*/ policy(throttlingFactory);
47
49
 
48
50
  /** Apply the transient retry policy (retries all transient errors indefinitely). */
49
- export const transient = policy(transientFactory);
51
+ export const transient = /*@__PURE__*/ policy(transientFactory);