@infracraft/pulumi 1.24.0 → 1.26.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.
Files changed (198) hide show
  1. package/README.md +9 -0
  2. package/dist/errors/api-not-found-error.cjs +28 -0
  3. package/dist/errors/api-not-found-error.cjs.map +1 -0
  4. package/dist/errors/api-not-found-error.d.cts +25 -0
  5. package/dist/errors/api-not-found-error.d.cts.map +1 -0
  6. package/dist/errors/api-not-found-error.d.mts +25 -0
  7. package/dist/errors/api-not-found-error.d.mts.map +1 -0
  8. package/dist/errors/api-not-found-error.mjs +27 -0
  9. package/dist/errors/api-not-found-error.mjs.map +1 -0
  10. package/dist/fly/app.cjs +8 -2
  11. package/dist/fly/app.cjs.map +1 -1
  12. package/dist/fly/app.d.cts +32 -1
  13. package/dist/fly/app.d.cts.map +1 -1
  14. package/dist/fly/app.d.mts +32 -1
  15. package/dist/fly/app.d.mts.map +1 -1
  16. package/dist/fly/app.mjs +8 -3
  17. package/dist/fly/app.mjs.map +1 -1
  18. package/dist/fly/certificate.cjs +16 -3
  19. package/dist/fly/certificate.cjs.map +1 -1
  20. package/dist/fly/certificate.d.cts.map +1 -1
  21. package/dist/fly/certificate.d.mts.map +1 -1
  22. package/dist/fly/certificate.mjs +16 -3
  23. package/dist/fly/certificate.mjs.map +1 -1
  24. package/dist/fly/client.cjs +13 -11
  25. package/dist/fly/client.cjs.map +1 -1
  26. package/dist/fly/client.d.cts +2 -1
  27. package/dist/fly/client.d.cts.map +1 -1
  28. package/dist/fly/client.d.mts +2 -1
  29. package/dist/fly/client.d.mts.map +1 -1
  30. package/dist/fly/client.mjs +13 -11
  31. package/dist/fly/client.mjs.map +1 -1
  32. package/dist/fly/ip.cjs +13 -2
  33. package/dist/fly/ip.cjs.map +1 -1
  34. package/dist/fly/ip.d.cts.map +1 -1
  35. package/dist/fly/ip.d.mts.map +1 -1
  36. package/dist/fly/ip.mjs +13 -2
  37. package/dist/fly/ip.mjs.map +1 -1
  38. package/dist/fly/secret.cjs +14 -2
  39. package/dist/fly/secret.cjs.map +1 -1
  40. package/dist/fly/secret.d.cts.map +1 -1
  41. package/dist/fly/secret.d.mts.map +1 -1
  42. package/dist/fly/secret.mjs +14 -2
  43. package/dist/fly/secret.mjs.map +1 -1
  44. package/dist/fly/volume.cjs +19 -3
  45. package/dist/fly/volume.cjs.map +1 -1
  46. package/dist/fly/volume.d.cts +34 -1
  47. package/dist/fly/volume.d.cts.map +1 -1
  48. package/dist/fly/volume.d.mts +34 -1
  49. package/dist/fly/volume.d.mts.map +1 -1
  50. package/dist/fly/volume.mjs +19 -4
  51. package/dist/fly/volume.mjs.map +1 -1
  52. package/dist/http/resilient-fetch.cjs +72 -0
  53. package/dist/http/resilient-fetch.cjs.map +1 -0
  54. package/dist/http/resilient-fetch.d.cts +32 -0
  55. package/dist/http/resilient-fetch.d.cts.map +1 -0
  56. package/dist/http/resilient-fetch.d.mts +32 -0
  57. package/dist/http/resilient-fetch.d.mts.map +1 -0
  58. package/dist/http/resilient-fetch.mjs +71 -0
  59. package/dist/http/resilient-fetch.mjs.map +1 -0
  60. package/dist/neon/branch.cjs +19 -9
  61. package/dist/neon/branch.cjs.map +1 -1
  62. package/dist/neon/branch.d.cts.map +1 -1
  63. package/dist/neon/branch.d.mts.map +1 -1
  64. package/dist/neon/branch.mjs +19 -9
  65. package/dist/neon/branch.mjs.map +1 -1
  66. package/dist/neon/client.cjs +12 -5
  67. package/dist/neon/client.cjs.map +1 -1
  68. package/dist/neon/client.d.cts +8 -4
  69. package/dist/neon/client.d.cts.map +1 -1
  70. package/dist/neon/client.d.mts +8 -4
  71. package/dist/neon/client.d.mts.map +1 -1
  72. package/dist/neon/client.mjs +12 -5
  73. package/dist/neon/client.mjs.map +1 -1
  74. package/dist/neon/database.cjs +19 -9
  75. package/dist/neon/database.cjs.map +1 -1
  76. package/dist/neon/database.d.cts.map +1 -1
  77. package/dist/neon/database.d.mts.map +1 -1
  78. package/dist/neon/database.mjs +19 -9
  79. package/dist/neon/database.mjs.map +1 -1
  80. package/dist/neon/endpoint.cjs +22 -12
  81. package/dist/neon/endpoint.cjs.map +1 -1
  82. package/dist/neon/endpoint.d.cts.map +1 -1
  83. package/dist/neon/endpoint.d.mts.map +1 -1
  84. package/dist/neon/endpoint.mjs +22 -12
  85. package/dist/neon/endpoint.mjs.map +1 -1
  86. package/dist/neon/project.cjs +20 -10
  87. package/dist/neon/project.cjs.map +1 -1
  88. package/dist/neon/project.d.cts.map +1 -1
  89. package/dist/neon/project.d.mts.map +1 -1
  90. package/dist/neon/project.mjs +20 -10
  91. package/dist/neon/project.mjs.map +1 -1
  92. package/dist/neon/role.cjs +16 -9
  93. package/dist/neon/role.cjs.map +1 -1
  94. package/dist/neon/role.d.cts.map +1 -1
  95. package/dist/neon/role.d.mts.map +1 -1
  96. package/dist/neon/role.mjs +16 -9
  97. package/dist/neon/role.mjs.map +1 -1
  98. package/dist/railway/client.cjs +4 -3
  99. package/dist/railway/client.cjs.map +1 -1
  100. package/dist/railway/client.d.cts +2 -2
  101. package/dist/railway/client.d.cts.map +1 -1
  102. package/dist/railway/client.d.mts +2 -2
  103. package/dist/railway/client.d.mts.map +1 -1
  104. package/dist/railway/client.mjs +4 -3
  105. package/dist/railway/client.mjs.map +1 -1
  106. package/dist/railway/domain.cjs +6 -3
  107. package/dist/railway/domain.cjs.map +1 -1
  108. package/dist/railway/domain.d.cts.map +1 -1
  109. package/dist/railway/domain.d.mts.map +1 -1
  110. package/dist/railway/domain.mjs +6 -3
  111. package/dist/railway/domain.mjs.map +1 -1
  112. package/dist/railway/environment.cjs +5 -2
  113. package/dist/railway/environment.cjs.map +1 -1
  114. package/dist/railway/environment.d.cts.map +1 -1
  115. package/dist/railway/environment.d.mts.map +1 -1
  116. package/dist/railway/environment.mjs +5 -2
  117. package/dist/railway/environment.mjs.map +1 -1
  118. package/dist/railway/project-token.cjs +26 -10
  119. package/dist/railway/project-token.cjs.map +1 -1
  120. package/dist/railway/project-token.d.cts +17 -0
  121. package/dist/railway/project-token.d.cts.map +1 -1
  122. package/dist/railway/project-token.d.mts +17 -0
  123. package/dist/railway/project-token.d.mts.map +1 -1
  124. package/dist/railway/project-token.mjs +26 -10
  125. package/dist/railway/project-token.mjs.map +1 -1
  126. package/dist/railway/project.cjs +4 -1
  127. package/dist/railway/project.cjs.map +1 -1
  128. package/dist/railway/project.d.cts.map +1 -1
  129. package/dist/railway/project.d.mts.map +1 -1
  130. package/dist/railway/project.mjs +4 -1
  131. package/dist/railway/project.mjs.map +1 -1
  132. package/dist/railway/service.cjs +5 -2
  133. package/dist/railway/service.cjs.map +1 -1
  134. package/dist/railway/service.d.cts.map +1 -1
  135. package/dist/railway/service.d.mts.map +1 -1
  136. package/dist/railway/service.mjs +5 -2
  137. package/dist/railway/service.mjs.map +1 -1
  138. package/dist/railway/variable.cjs +4 -1
  139. package/dist/railway/variable.cjs.map +1 -1
  140. package/dist/railway/variable.d.cts.map +1 -1
  141. package/dist/railway/variable.d.mts.map +1 -1
  142. package/dist/railway/variable.mjs +4 -1
  143. package/dist/railway/variable.mjs.map +1 -1
  144. package/dist/railway/volume.cjs +4 -1
  145. package/dist/railway/volume.cjs.map +1 -1
  146. package/dist/railway/volume.d.cts.map +1 -1
  147. package/dist/railway/volume.d.mts.map +1 -1
  148. package/dist/railway/volume.mjs +4 -1
  149. package/dist/railway/volume.mjs.map +1 -1
  150. package/dist/vercel/client.cjs +115 -0
  151. package/dist/vercel/client.cjs.map +1 -0
  152. package/dist/vercel/client.d.cts +77 -0
  153. package/dist/vercel/client.d.cts.map +1 -0
  154. package/dist/vercel/client.d.mts +77 -0
  155. package/dist/vercel/client.d.mts.map +1 -0
  156. package/dist/vercel/client.mjs +114 -0
  157. package/dist/vercel/client.mjs.map +1 -0
  158. package/dist/vercel/domain.cjs +28 -35
  159. package/dist/vercel/domain.cjs.map +1 -1
  160. package/dist/vercel/domain.d.cts.map +1 -1
  161. package/dist/vercel/domain.d.mts.map +1 -1
  162. package/dist/vercel/domain.mjs +28 -35
  163. package/dist/vercel/domain.mjs.map +1 -1
  164. package/dist/vercel/index.cjs +2 -0
  165. package/dist/vercel/index.d.cts +2 -1
  166. package/dist/vercel/index.d.mts +2 -1
  167. package/dist/vercel/index.mjs +2 -1
  168. package/dist/vercel/integration.cjs +6 -5
  169. package/dist/vercel/integration.cjs.map +1 -1
  170. package/dist/vercel/integration.d.cts.map +1 -1
  171. package/dist/vercel/integration.d.mts.map +1 -1
  172. package/dist/vercel/integration.mjs +6 -5
  173. package/dist/vercel/integration.mjs.map +1 -1
  174. package/dist/vercel/marketplace-resource.cjs +6 -12
  175. package/dist/vercel/marketplace-resource.cjs.map +1 -1
  176. package/dist/vercel/marketplace-resource.d.cts.map +1 -1
  177. package/dist/vercel/marketplace-resource.d.mts.map +1 -1
  178. package/dist/vercel/marketplace-resource.mjs +6 -12
  179. package/dist/vercel/marketplace-resource.mjs.map +1 -1
  180. package/dist/vercel/project.cjs +19 -42
  181. package/dist/vercel/project.cjs.map +1 -1
  182. package/dist/vercel/project.d.cts.map +1 -1
  183. package/dist/vercel/project.d.mts.map +1 -1
  184. package/dist/vercel/project.mjs +19 -42
  185. package/dist/vercel/project.mjs.map +1 -1
  186. package/dist/vercel/resource-connection.cjs +14 -19
  187. package/dist/vercel/resource-connection.cjs.map +1 -1
  188. package/dist/vercel/resource-connection.d.cts.map +1 -1
  189. package/dist/vercel/resource-connection.d.mts.map +1 -1
  190. package/dist/vercel/resource-connection.mjs +14 -19
  191. package/dist/vercel/resource-connection.mjs.map +1 -1
  192. package/dist/vercel/variable.cjs +40 -48
  193. package/dist/vercel/variable.cjs.map +1 -1
  194. package/dist/vercel/variable.d.cts.map +1 -1
  195. package/dist/vercel/variable.d.mts.map +1 -1
  196. package/dist/vercel/variable.mjs +40 -48
  197. package/dist/vercel/variable.mjs.map +1 -1
  198. package/package.json +1 -1
package/README.md CHANGED
@@ -14,6 +14,15 @@
14
14
 
15
15
  Native Pulumi providers with adopt-or-create semantics and deploy orchestration. No Terraform bridge.
16
16
 
17
+ ## Design principles
18
+
19
+ - **Resources model single API objects.** Each resource wraps exactly one platform API object, and argument names mirror the platform API's field names.
20
+ - **Adopt-or-create IS the import principle.** `pulumi import` is unimplemented for dynamic providers, so `create()` looks the object up by name and adopts it before creating a new one.
21
+ - **Reads reconcile drift.** A resource deleted out of band returns blank on `pulumi refresh` and gets recreated on the next `up`. Write-once secrets and env-var batches are deliberate pass-throughs — their stored state is the source of truth.
22
+ - **Deletes are conservative — and idempotent.** Shared containers (projects, project-level services) are never deleted by Pulumi; volumes retain; deleting an already-gone resource succeeds instead of stranding state.
23
+ - **One resilient transport.** All HTTP goes through a single fetch wrapper with a per-attempt timeout, bounded retries on transient failures (network errors, 5xx, 429), and `Retry-After` support.
24
+ - **Secrets stay secret.** Provider credentials and minted values are marked secret in Pulumi state, and deploy tokens travel via stdin — never in command text.
25
+
17
26
  ## Providers
18
27
 
19
28
  | | Provider | Import | What it does |
@@ -0,0 +1,28 @@
1
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_chunk = require('../chunk-BVYJZCqc.cjs');
3
+
4
+ //#region src/errors/api-not-found-error.ts
5
+ /**
6
+ * Thrown when a provider API responds 404 for a resource path.
7
+ *
8
+ * Clients throw this instead of a generic error so callers can distinguish
9
+ * "gone" from "failed" via `instanceof`: adopt-or-create lookups turn it into
10
+ * `null`, and `read()` implementations turn it into a blank `ReadResult` so
11
+ * `pulumi refresh` reconciles out-of-band deletions.
12
+ */
13
+ var ApiNotFoundError = class extends Error {
14
+ /**
15
+ * @param provider Provider whose API returned the 404
16
+ * @param path API path (or URL) that was not found
17
+ */
18
+ constructor(provider, path) {
19
+ super(`${provider} API returned 404 for ${path}`);
20
+ this.name = "ApiNotFoundError";
21
+ this.provider = provider;
22
+ this.path = path;
23
+ }
24
+ };
25
+
26
+ //#endregion
27
+ exports.ApiNotFoundError = ApiNotFoundError;
28
+ //# sourceMappingURL=api-not-found-error.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-not-found-error.cjs","names":[],"sources":["../../src/errors/api-not-found-error.ts"],"sourcesContent":["/**\n * Thrown when a provider API responds 404 for a resource path.\n *\n * Clients throw this instead of a generic error so callers can distinguish\n * \"gone\" from \"failed\" via `instanceof`: adopt-or-create lookups turn it into\n * `null`, and `read()` implementations turn it into a blank `ReadResult` so\n * `pulumi refresh` reconciles out-of-band deletions.\n */\nexport class ApiNotFoundError extends Error {\n\t/** Provider whose API returned the 404 (e.g. `\"neon\"`, `\"vercel\"`, `\"fly\"`). */\n\treadonly provider: string;\n\n\t/** API path (or URL) that was not found. */\n\treadonly path: string;\n\n\t/**\n\t * @param provider Provider whose API returned the 404\n\t * @param path API path (or URL) that was not found\n\t */\n\tconstructor(provider: string, path: string) {\n\t\tsuper(`${provider} API returned 404 for ${path}`);\n\n\t\tthis.name = \"ApiNotFoundError\";\n\t\tthis.provider = provider;\n\t\tthis.path = path;\n\t}\n}\n"],"mappings":";;;;;;;;;;;;AAQA,IAAa,mBAAb,cAAsC,MAAM;;;;;CAW3C,YAAY,UAAkB,MAAc;EAC3C,MAAM,GAAG,SAAS,wBAAwB,MAAM;EAEhD,KAAK,OAAO;EACZ,KAAK,WAAW;EAChB,KAAK,OAAO;CACb;AACD"}
@@ -0,0 +1,25 @@
1
+ import { t as __name } from "../chunk-OPjESj5l.cjs";
2
+
3
+ //#region src/errors/api-not-found-error.d.ts
4
+ /**
5
+ * Thrown when a provider API responds 404 for a resource path.
6
+ *
7
+ * Clients throw this instead of a generic error so callers can distinguish
8
+ * "gone" from "failed" via `instanceof`: adopt-or-create lookups turn it into
9
+ * `null`, and `read()` implementations turn it into a blank `ReadResult` so
10
+ * `pulumi refresh` reconciles out-of-band deletions.
11
+ */
12
+ declare class ApiNotFoundError extends Error {
13
+ /** Provider whose API returned the 404 (e.g. `"neon"`, `"vercel"`, `"fly"`). */
14
+ readonly provider: string;
15
+ /** API path (or URL) that was not found. */
16
+ readonly path: string;
17
+ /**
18
+ * @param provider Provider whose API returned the 404
19
+ * @param path API path (or URL) that was not found
20
+ */
21
+ constructor(provider: string, path: string);
22
+ }
23
+ //#endregion
24
+ export { ApiNotFoundError };
25
+ //# sourceMappingURL=api-not-found-error.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-not-found-error.d.cts","names":[],"sources":["../../src/errors/api-not-found-error.ts"],"mappings":";;;;;;AAQA;;;;;cAAa,gBAAA,SAAyB,KAAK;EAKjC;EAAA,SAHA,QAAA;EASG;EAAA,SANH,IAAA;EAMiC;AAAA;;;cAA9B,QAAA,UAAkB,IAAA;AAAA"}
@@ -0,0 +1,25 @@
1
+ import { t as __name } from "../chunk-OPjESj5l.mjs";
2
+
3
+ //#region src/errors/api-not-found-error.d.ts
4
+ /**
5
+ * Thrown when a provider API responds 404 for a resource path.
6
+ *
7
+ * Clients throw this instead of a generic error so callers can distinguish
8
+ * "gone" from "failed" via `instanceof`: adopt-or-create lookups turn it into
9
+ * `null`, and `read()` implementations turn it into a blank `ReadResult` so
10
+ * `pulumi refresh` reconciles out-of-band deletions.
11
+ */
12
+ declare class ApiNotFoundError extends Error {
13
+ /** Provider whose API returned the 404 (e.g. `"neon"`, `"vercel"`, `"fly"`). */
14
+ readonly provider: string;
15
+ /** API path (or URL) that was not found. */
16
+ readonly path: string;
17
+ /**
18
+ * @param provider Provider whose API returned the 404
19
+ * @param path API path (or URL) that was not found
20
+ */
21
+ constructor(provider: string, path: string);
22
+ }
23
+ //#endregion
24
+ export { ApiNotFoundError };
25
+ //# sourceMappingURL=api-not-found-error.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-not-found-error.d.mts","names":[],"sources":["../../src/errors/api-not-found-error.ts"],"mappings":";;;;;;AAQA;;;;;cAAa,gBAAA,SAAyB,KAAK;EAKjC;EAAA,SAHA,QAAA;EASG;EAAA,SANH,IAAA;EAMiC;AAAA;;;cAA9B,QAAA,UAAkB,IAAA;AAAA"}
@@ -0,0 +1,27 @@
1
+ import { t as __name } from "../chunk-OPjESj5l.mjs";
2
+
3
+ //#region src/errors/api-not-found-error.ts
4
+ /**
5
+ * Thrown when a provider API responds 404 for a resource path.
6
+ *
7
+ * Clients throw this instead of a generic error so callers can distinguish
8
+ * "gone" from "failed" via `instanceof`: adopt-or-create lookups turn it into
9
+ * `null`, and `read()` implementations turn it into a blank `ReadResult` so
10
+ * `pulumi refresh` reconciles out-of-band deletions.
11
+ */
12
+ var ApiNotFoundError = class extends Error {
13
+ /**
14
+ * @param provider Provider whose API returned the 404
15
+ * @param path API path (or URL) that was not found
16
+ */
17
+ constructor(provider, path) {
18
+ super(`${provider} API returned 404 for ${path}`);
19
+ this.name = "ApiNotFoundError";
20
+ this.provider = provider;
21
+ this.path = path;
22
+ }
23
+ };
24
+
25
+ //#endregion
26
+ export { ApiNotFoundError };
27
+ //# sourceMappingURL=api-not-found-error.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"api-not-found-error.mjs","names":[],"sources":["../../src/errors/api-not-found-error.ts"],"sourcesContent":["/**\n * Thrown when a provider API responds 404 for a resource path.\n *\n * Clients throw this instead of a generic error so callers can distinguish\n * \"gone\" from \"failed\" via `instanceof`: adopt-or-create lookups turn it into\n * `null`, and `read()` implementations turn it into a blank `ReadResult` so\n * `pulumi refresh` reconciles out-of-band deletions.\n */\nexport class ApiNotFoundError extends Error {\n\t/** Provider whose API returned the 404 (e.g. `\"neon\"`, `\"vercel\"`, `\"fly\"`). */\n\treadonly provider: string;\n\n\t/** API path (or URL) that was not found. */\n\treadonly path: string;\n\n\t/**\n\t * @param provider Provider whose API returned the 404\n\t * @param path API path (or URL) that was not found\n\t */\n\tconstructor(provider: string, path: string) {\n\t\tsuper(`${provider} API returned 404 for ${path}`);\n\n\t\tthis.name = \"ApiNotFoundError\";\n\t\tthis.provider = provider;\n\t\tthis.path = path;\n\t}\n}\n"],"mappings":";;;;;;;;;;;AAQA,IAAa,mBAAb,cAAsC,MAAM;;;;;CAW3C,YAAY,UAAkB,MAAc;EAC3C,MAAM,GAAG,SAAS,wBAAwB,MAAM;EAEhD,KAAK,OAAO;EACZ,KAAK,WAAW;EAChB,KAAK,OAAO;CACb;AACD"}
package/dist/fly/app.cjs CHANGED
@@ -12,6 +12,8 @@ _pulumi_pulumi = require_chunk.__toESM(_pulumi_pulumi, 1);
12
12
  * `POST /v1/apps`. `delete()` is a no-op — deleting a Fly app destroys
13
13
  * everything in it, so (like Railway/Neon/Vercel top-level resources) Pulumi
14
14
  * does not delete apps.
15
+ *
16
+ * @internal Exported only for unit testing; not part of the public API surface.
15
17
  */
16
18
  var FlyAppResourceProvider = class {
17
19
  async create(inputs) {
@@ -36,7 +38,7 @@ var FlyAppResourceProvider = class {
36
38
  }
37
39
  async read(id, props) {
38
40
  const app = await new require_fly_client.FlyClient(props.token).tryGet(`/v1/apps/${id}`);
39
- if (!app) throw new Error(`Fly app "${id}" not found during refresh`);
41
+ if (!app) return {};
40
42
  return {
41
43
  id,
42
44
  props: {
@@ -72,7 +74,10 @@ var FlyAppResource = class extends _pulumi_pulumi.dynamic.Resource {
72
74
  super(new FlyAppResourceProvider(), name, {
73
75
  ...args,
74
76
  appId: void 0
75
- }, opts);
77
+ }, {
78
+ ...opts,
79
+ additionalSecretOutputs: ["token"]
80
+ });
76
81
  }
77
82
  };
78
83
  /**
@@ -99,4 +104,5 @@ var FlyApp = class extends _pulumi_pulumi.ComponentResource {
99
104
 
100
105
  //#endregion
101
106
  exports.FlyApp = FlyApp;
107
+ exports.FlyAppResourceProvider = FlyAppResourceProvider;
102
108
  //# sourceMappingURL=app.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"app.cjs","names":["FlyClient","pulumi"],"sources":["../../src/fly/app.ts"],"sourcesContent":["import * as pulumi from \"@pulumi/pulumi\";\n\nimport { FlyClient } from \"./client\";\nimport type { FlyProvider } from \"./provider\";\n\n/** Resolved inputs for the Fly app dynamic provider. */\ninterface FlyAppInputs {\n\t/** Fly API token. */\n\ttoken: string;\n\n\t/** App name (globally unique). Used as the resource identifier. */\n\tname: string;\n\n\t/** Org slug used only when creating a new app. */\n\torganization?: string;\n}\n\n/** Persisted state for the Fly app. */\ninterface FlyAppOutputs extends FlyAppInputs {\n\t/** App identifier — equals the app name (all child paths key off the name). */\n\tappId: string;\n}\n\n/** Get-app response (only the fields we read). */\ninterface FlyAppResponse {\n\tid: string;\n\tname: string;\n}\n\n/**\n * Dynamic provider implementing adopt-or-create for Fly apps.\n *\n * `create()` does `GET /v1/apps/{name}`; if found it adopts, otherwise it\n * `POST /v1/apps`. `delete()` is a no-op — deleting a Fly app destroys\n * everything in it, so (like Railway/Neon/Vercel top-level resources) Pulumi\n * does not delete apps.\n */\nclass FlyAppResourceProvider implements pulumi.dynamic.ResourceProvider {\n\tasync create(inputs: FlyAppInputs): Promise<pulumi.dynamic.CreateResult> {\n\t\tconst client = new FlyClient(inputs.token);\n\n\t\tconst existing = await client.tryGet<FlyAppResponse>(\n\t\t\t`/v1/apps/${inputs.name}`,\n\t\t);\n\n\t\tif (existing) {\n\t\t\tpulumi.log.info(`Adopting existing Fly app \"${inputs.name}\"`);\n\t\t} else {\n\t\t\tif (!inputs.organization) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`FlyApp \"${inputs.name}\": an organization is required to create a new app — set it on FlyProvider or FlyApp args`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tpulumi.log.info(`Fly app \"${inputs.name}\" not found — creating...`);\n\n\t\t\tawait client.post(\"/v1/apps\", {\n\t\t\t\tapp_name: inputs.name,\n\t\t\t\torg_slug: inputs.organization,\n\t\t\t});\n\t\t}\n\n\t\tconst outs: FlyAppOutputs = { ...inputs, appId: inputs.name };\n\n\t\treturn { id: inputs.name, outs };\n\t}\n\n\tasync read(\n\t\tid: string,\n\t\tprops: FlyAppOutputs,\n\t): Promise<pulumi.dynamic.ReadResult> {\n\t\tconst client = new FlyClient(props.token);\n\t\tconst app = await client.tryGet<FlyAppResponse>(`/v1/apps/${id}`);\n\n\t\tif (!app) {\n\t\t\tthrow new Error(`Fly app \"${id}\" not found during refresh`);\n\t\t}\n\n\t\treturn { id, props: { ...props, name: app.name, appId: app.name } };\n\t}\n\n\tasync update(\n\t\tid: string,\n\t\t_olds: FlyAppOutputs,\n\t\tnews: FlyAppInputs,\n\t): Promise<pulumi.dynamic.UpdateResult> {\n\t\treturn { outs: { ...news, appId: id } };\n\t}\n\n\tasync delete(): Promise<void> {\n\t\tpulumi.log.warn(\n\t\t\t\"Fly app deletion skipped — apps are not deleted by Pulumi (would destroy all contained resources)\",\n\t\t);\n\t}\n\n\tasync diff(\n\t\t_id: string,\n\t\tolds: FlyAppOutputs,\n\t\tnews: FlyAppInputs,\n\t): Promise<pulumi.dynamic.DiffResult> {\n\t\tconst replaces: string[] = [];\n\n\t\tif (olds.name !== news.name) {\n\t\t\treplaces.push(\"name\");\n\t\t}\n\n\t\tif (olds.organization !== news.organization) {\n\t\t\treplaces.push(\"organization\");\n\t\t}\n\n\t\treturn {\n\t\t\tchanges: replaces.length > 0,\n\t\t\treplaces,\n\t\t\tdeleteBeforeReplace: true,\n\t\t};\n\t}\n}\n\n/** Internal dynamic resource — not part of the public API. */\nclass FlyAppResource extends pulumi.dynamic.Resource {\n\tpublic declare readonly appId: pulumi.Output<string>;\n\n\tconstructor(\n\t\tname: string,\n\t\targs: {\n\t\t\ttoken: pulumi.Input<string>;\n\t\t\tname: pulumi.Input<string>;\n\t\t\torganization?: pulumi.Input<string | undefined>;\n\t\t},\n\t\topts?: pulumi.CustomResourceOptions,\n\t) {\n\t\tsuper(\n\t\t\tnew FlyAppResourceProvider(),\n\t\t\tname,\n\t\t\t{ ...args, appId: undefined },\n\t\t\topts,\n\t\t);\n\t}\n}\n\n/** Options type for FlyApp — replaces Pulumi's native `provider` field. */\ntype FlyAppOptions = Omit<pulumi.ComponentResourceOptions, \"provider\"> & {\n\t/** Fly authentication context. */\n\tprovider: FlyProvider;\n};\n\n/** Args for FlyApp. */\nexport interface FlyAppArgs {\n\t/** App name (globally unique). Used for adoption lookup and as `.id`. */\n\tname: pulumi.Input<string>;\n\n\t/**\n\t * Org slug for app creation. Overrides `FlyProvider.organization`.\n\t * Ignored when the app already exists (adoption).\n\t */\n\torganization?: pulumi.Input<string>;\n}\n\n/**\n * Manages a Fly app with adopt-or-create semantics.\n *\n * @example\n * ```typescript\n * const app = new FlyApp(\"api\", { name: \"rby-api\" }, { provider });\n * ```\n */\nexport class FlyApp extends pulumi.ComponentResource {\n\t/** App identifier (equals the app name). */\n\tpublic readonly id: pulumi.Output<string>;\n\n\tconstructor(name: string, args: FlyAppArgs, opts: FlyAppOptions) {\n\t\tconst { provider, ...pulumiOpts } = opts;\n\n\t\tsuper(\"infracraft:fly:App\", name, {}, pulumiOpts);\n\n\t\tconst resource = new FlyAppResource(\n\t\t\t`${name}-resource`,\n\t\t\t{\n\t\t\t\ttoken: provider.token,\n\t\t\t\tname: args.name,\n\t\t\t\torganization: args.organization ?? provider.organization,\n\t\t\t},\n\t\t\t{ parent: this },\n\t\t);\n\n\t\tthis.id = resource.appId;\n\n\t\tthis.registerOutputs({ id: this.id });\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;AAqCA,IAAM,yBAAN,MAAwE;CACvE,MAAM,OAAO,QAA4D;EACxE,MAAM,SAAS,IAAIA,6BAAU,OAAO,KAAK;EAMzC,IAAI,MAJmB,OAAO,OAC7B,YAAY,OAAO,MACpB,GAGC,eAAO,IAAI,KAAK,8BAA8B,OAAO,KAAK,EAAE;OACtD;GACN,IAAI,CAAC,OAAO,cACX,MAAM,IAAI,MACT,WAAW,OAAO,KAAK,0FACxB;GAGD,eAAO,IAAI,KAAK,YAAY,OAAO,KAAK,0BAA0B;GAElE,MAAM,OAAO,KAAK,YAAY;IAC7B,UAAU,OAAO;IACjB,UAAU,OAAO;GAClB,CAAC;EACF;EAEA,MAAM,OAAsB;GAAE,GAAG;GAAQ,OAAO,OAAO;EAAK;EAE5D,OAAO;GAAE,IAAI,OAAO;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AAC;CACrC;AACD"}
1
+ {"version":3,"file":"app.cjs","names":["FlyClient","pulumi"],"sources":["../../src/fly/app.ts"],"sourcesContent":["import * as pulumi from \"@pulumi/pulumi\";\n\nimport { FlyClient } from \"./client\";\nimport type { FlyProvider } from \"./provider\";\n\n/** Resolved inputs for the Fly app dynamic provider. */\ninterface FlyAppInputs {\n\t/** Fly API token. */\n\ttoken: string;\n\n\t/** App name (globally unique). Used as the resource identifier. */\n\tname: string;\n\n\t/** Org slug used only when creating a new app. */\n\torganization?: string;\n}\n\n/** Persisted state for the Fly app. */\ninterface FlyAppOutputs extends FlyAppInputs {\n\t/** App identifier — equals the app name (all child paths key off the name). */\n\tappId: string;\n}\n\n/** Get-app response (only the fields we read). */\ninterface FlyAppResponse {\n\tid: string;\n\tname: string;\n}\n\n/**\n * Dynamic provider implementing adopt-or-create for Fly apps.\n *\n * `create()` does `GET /v1/apps/{name}`; if found it adopts, otherwise it\n * `POST /v1/apps`. `delete()` is a no-op — deleting a Fly app destroys\n * everything in it, so (like Railway/Neon/Vercel top-level resources) Pulumi\n * does not delete apps.\n *\n * @internal Exported only for unit testing; not part of the public API surface.\n */\nexport class FlyAppResourceProvider implements pulumi.dynamic.ResourceProvider {\n\tasync create(inputs: FlyAppInputs): Promise<pulumi.dynamic.CreateResult> {\n\t\tconst client = new FlyClient(inputs.token);\n\n\t\tconst existing = await client.tryGet<FlyAppResponse>(\n\t\t\t`/v1/apps/${inputs.name}`,\n\t\t);\n\n\t\tif (existing) {\n\t\t\tpulumi.log.info(`Adopting existing Fly app \"${inputs.name}\"`);\n\t\t} else {\n\t\t\tif (!inputs.organization) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`FlyApp \"${inputs.name}\": an organization is required to create a new app — set it on FlyProvider or FlyApp args`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tpulumi.log.info(`Fly app \"${inputs.name}\" not found — creating...`);\n\n\t\t\tawait client.post(\"/v1/apps\", {\n\t\t\t\tapp_name: inputs.name,\n\t\t\t\torg_slug: inputs.organization,\n\t\t\t});\n\t\t}\n\n\t\tconst outs: FlyAppOutputs = { ...inputs, appId: inputs.name };\n\n\t\treturn { id: inputs.name, outs };\n\t}\n\n\tasync read(\n\t\tid: string,\n\t\tprops: FlyAppOutputs,\n\t): Promise<pulumi.dynamic.ReadResult> {\n\t\tconst client = new FlyClient(props.token);\n\t\tconst app = await client.tryGet<FlyAppResponse>(`/v1/apps/${id}`);\n\n\t\tif (!app) {\n\t\t\t// Resource gone blank id lets refresh reconcile the deletion.\n\t\t\treturn {};\n\t\t}\n\n\t\treturn { id, props: { ...props, name: app.name, appId: app.name } };\n\t}\n\n\tasync update(\n\t\tid: string,\n\t\t_olds: FlyAppOutputs,\n\t\tnews: FlyAppInputs,\n\t): Promise<pulumi.dynamic.UpdateResult> {\n\t\treturn { outs: { ...news, appId: id } };\n\t}\n\n\tasync delete(): Promise<void> {\n\t\tpulumi.log.warn(\n\t\t\t\"Fly app deletion skipped — apps are not deleted by Pulumi (would destroy all contained resources)\",\n\t\t);\n\t}\n\n\tasync diff(\n\t\t_id: string,\n\t\tolds: FlyAppOutputs,\n\t\tnews: FlyAppInputs,\n\t): Promise<pulumi.dynamic.DiffResult> {\n\t\tconst replaces: string[] = [];\n\n\t\tif (olds.name !== news.name) {\n\t\t\treplaces.push(\"name\");\n\t\t}\n\n\t\tif (olds.organization !== news.organization) {\n\t\t\treplaces.push(\"organization\");\n\t\t}\n\n\t\treturn {\n\t\t\tchanges: replaces.length > 0,\n\t\t\treplaces,\n\t\t\tdeleteBeforeReplace: true,\n\t\t};\n\t}\n}\n\n/** Internal dynamic resource — not part of the public API. */\nclass FlyAppResource extends pulumi.dynamic.Resource {\n\tpublic declare readonly appId: pulumi.Output<string>;\n\n\tconstructor(\n\t\tname: string,\n\t\targs: {\n\t\t\ttoken: pulumi.Input<string>;\n\t\t\tname: pulumi.Input<string>;\n\t\t\torganization?: pulumi.Input<string | undefined>;\n\t\t},\n\t\topts?: pulumi.CustomResourceOptions,\n\t) {\n\t\tsuper(\n\t\t\tnew FlyAppResourceProvider(),\n\t\t\tname,\n\t\t\t{ ...args, appId: undefined },\n\t\t\t// The API token flows into dynamic-provider state with the outputs — mark it secret there.\n\t\t\t{ ...opts, additionalSecretOutputs: [\"token\"] },\n\t\t);\n\t}\n}\n\n/** Options type for FlyApp — replaces Pulumi's native `provider` field. */\ntype FlyAppOptions = Omit<pulumi.ComponentResourceOptions, \"provider\"> & {\n\t/** Fly authentication context. */\n\tprovider: FlyProvider;\n};\n\n/** Args for FlyApp. */\nexport interface FlyAppArgs {\n\t/** App name (globally unique). Used for adoption lookup and as `.id`. */\n\tname: pulumi.Input<string>;\n\n\t/**\n\t * Org slug for app creation. Overrides `FlyProvider.organization`.\n\t * Ignored when the app already exists (adoption).\n\t */\n\torganization?: pulumi.Input<string>;\n}\n\n/**\n * Manages a Fly app with adopt-or-create semantics.\n *\n * @example\n * ```typescript\n * const app = new FlyApp(\"api\", { name: \"rby-api\" }, { provider });\n * ```\n */\nexport class FlyApp extends pulumi.ComponentResource {\n\t/** App identifier (equals the app name). */\n\tpublic readonly id: pulumi.Output<string>;\n\n\tconstructor(name: string, args: FlyAppArgs, opts: FlyAppOptions) {\n\t\tconst { provider, ...pulumiOpts } = opts;\n\n\t\tsuper(\"infracraft:fly:App\", name, {}, pulumiOpts);\n\n\t\tconst resource = new FlyAppResource(\n\t\t\t`${name}-resource`,\n\t\t\t{\n\t\t\t\ttoken: provider.token,\n\t\t\t\tname: args.name,\n\t\t\t\torganization: args.organization ?? provider.organization,\n\t\t\t},\n\t\t\t{ parent: this },\n\t\t);\n\n\t\tthis.id = resource.appId;\n\n\t\tthis.registerOutputs({ id: this.id });\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAuCA,IAAa,yBAAb,MAA+E;CAC9E,MAAM,OAAO,QAA4D;EACxE,MAAM,SAAS,IAAIA,6BAAU,OAAO,KAAK;EAMzC,IAAI,MAJmB,OAAO,OAC7B,YAAY,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;AA4BA,IAAa,SAAb,cAA4BA,eAAO,kBAAkB;CAIpD,YAAY,MAAc,MAAkB,MAAqB;EAChE,MAAM,EAAE,UAAU,GAAG,eAAe;EAEpC,MAAM,sBAAsB,MAAM,CAAC,GAAG,UAAU;EAEhD,MAAM,WAAW,IAAI,eACpB,GAAG,KAAK,YACR;GACC,OAAO,SAAS;GAChB,MAAM,KAAK;GACX,cAAc,KAAK,gBAAgB,SAAS;EAC7C,GACA,EAAE,QAAQ,KAAK,CAChB;EAEA,KAAK,KAAK,SAAS;EAEnB,KAAK,gBAAgB,EAAE,IAAI,KAAK,GAAG,CAAC;CACrC;AACD"}
@@ -3,6 +3,37 @@ import { FlyProvider } from "./provider.cjs";
3
3
  import * as pulumi from "@pulumi/pulumi";
4
4
 
5
5
  //#region src/fly/app.d.ts
6
+ /** Resolved inputs for the Fly app dynamic provider. */
7
+ interface FlyAppInputs {
8
+ /** Fly API token. */
9
+ token: string;
10
+ /** App name (globally unique). Used as the resource identifier. */
11
+ name: string;
12
+ /** Org slug used only when creating a new app. */
13
+ organization?: string;
14
+ }
15
+ /** Persisted state for the Fly app. */
16
+ interface FlyAppOutputs extends FlyAppInputs {
17
+ /** App identifier — equals the app name (all child paths key off the name). */
18
+ appId: string;
19
+ }
20
+ /**
21
+ * Dynamic provider implementing adopt-or-create for Fly apps.
22
+ *
23
+ * `create()` does `GET /v1/apps/{name}`; if found it adopts, otherwise it
24
+ * `POST /v1/apps`. `delete()` is a no-op — deleting a Fly app destroys
25
+ * everything in it, so (like Railway/Neon/Vercel top-level resources) Pulumi
26
+ * does not delete apps.
27
+ *
28
+ * @internal Exported only for unit testing; not part of the public API surface.
29
+ */
30
+ declare class FlyAppResourceProvider implements pulumi.dynamic.ResourceProvider {
31
+ create(inputs: FlyAppInputs): Promise<pulumi.dynamic.CreateResult>;
32
+ read(id: string, props: FlyAppOutputs): Promise<pulumi.dynamic.ReadResult>;
33
+ update(id: string, _olds: FlyAppOutputs, news: FlyAppInputs): Promise<pulumi.dynamic.UpdateResult>;
34
+ delete(): Promise<void>;
35
+ diff(_id: string, olds: FlyAppOutputs, news: FlyAppInputs): Promise<pulumi.dynamic.DiffResult>;
36
+ }
6
37
  /** Options type for FlyApp — replaces Pulumi's native `provider` field. */
7
38
  type FlyAppOptions = Omit<pulumi.ComponentResourceOptions, "provider"> & {
8
39
  /** Fly authentication context. */provider: FlyProvider;
@@ -31,5 +62,5 @@ declare class FlyApp extends pulumi.ComponentResource {
31
62
  constructor(name: string, args: FlyAppArgs, opts: FlyAppOptions);
32
63
  }
33
64
  //#endregion
34
- export { FlyApp, FlyAppArgs };
65
+ export { FlyApp, FlyAppArgs, FlyAppResourceProvider };
35
66
  //# sourceMappingURL=app.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"app.d.cts","names":[],"sources":["../../src/fly/app.ts"],"mappings":";;;;;;KA6IK,aAAA,GAAgB,IAAA,CAAK,MAAA,CAAO,wBAAA;oCAEhC,QAAA,EAAU,WAAA;AAAA;;UAIM,UAAA;EANI;EAQpB,IAAA,EAAM,MAAA,CAAO,KAAA;EANQ;;;;EAYrB,YAAA,GAAe,MAAA,CAAO,KAAK;AAAA;;;AAZN;AAItB;;;;;cAmBa,MAAA,SAAe,MAAA,CAAO,iBAAA;EAjBrB;EAAA,SAmBG,EAAA,EAAI,MAAA,CAAO,MAAA;cAEf,IAAA,UAAc,IAAA,EAAM,UAAA,EAAY,IAAA,EAAM,aAAA;AAAA"}
1
+ {"version":3,"file":"app.d.cts","names":[],"sources":["../../src/fly/app.ts"],"mappings":";;;;;;UAMU,YAAA;;EAET,KAAA;EAFqB;EAKrB,IAAA;EALqB;EAQrB,YAAA;AAAA;;UAIS,aAAA,SAAsB,YAAY;EAJ/B;EAMZ,KAAK;AAAA;;;AAAA;AAmBN;;;;;;;cAAa,sBAAA,YAAkC,MAAA,CAAO,OAAA,CAAQ,gBAAA;EACvD,MAAA,CAAO,MAAA,EAAQ,YAAA,GAAe,OAAA,CAAQ,MAAA,CAAO,OAAA,CAAQ,YAAA;EA6BrD,IAAA,CACL,EAAA,UACA,KAAA,EAAO,aAAA,GACL,OAAA,CAAQ,MAAA,CAAO,OAAA,CAAQ,UAAA;EAYpB,MAAA,CACL,EAAA,UACA,KAAA,EAAO,aAAA,EACP,IAAA,EAAM,YAAA,GACJ,OAAA,CAAQ,MAAA,CAAO,OAAA,CAAQ,YAAA;EAIpB,MAAA,CAAA,GAAU,OAAA;EAMV,IAAA,CACL,GAAA,UACA,IAAA,EAAM,aAAA,EACN,IAAA,EAAM,YAAA,GACJ,OAAA,CAAQ,MAAA,CAAO,OAAA,CAAQ,UAAA;AAAA;;KA2CtB,aAAA,GAAgB,IAAA,CAAK,MAAA,CAAO,wBAAA;EA3CrB,kCA6CX,QAAA,EAAU,WAAA;AAAA;;UAIM,UAAA;EAhH8B;EAkH9C,IAAA,EAAM,MAAA,CAAO,KAAA;EAlHgD;;;;EAwH7D,YAAA,GAAe,MAAA,CAAO,KAAK;AAAA;;;;;;;;;cAWf,MAAA,SAAe,MAAA,CAAO,iBAAA;EAlGR;EAAA,SAoGV,EAAA,EAAI,MAAA,CAAO,MAAA;cAEf,IAAA,UAAc,IAAA,EAAM,UAAA,EAAY,IAAA,EAAM,aAAA;AAAA"}
@@ -3,6 +3,37 @@ import { FlyProvider } from "./provider.mjs";
3
3
  import * as pulumi from "@pulumi/pulumi";
4
4
 
5
5
  //#region src/fly/app.d.ts
6
+ /** Resolved inputs for the Fly app dynamic provider. */
7
+ interface FlyAppInputs {
8
+ /** Fly API token. */
9
+ token: string;
10
+ /** App name (globally unique). Used as the resource identifier. */
11
+ name: string;
12
+ /** Org slug used only when creating a new app. */
13
+ organization?: string;
14
+ }
15
+ /** Persisted state for the Fly app. */
16
+ interface FlyAppOutputs extends FlyAppInputs {
17
+ /** App identifier — equals the app name (all child paths key off the name). */
18
+ appId: string;
19
+ }
20
+ /**
21
+ * Dynamic provider implementing adopt-or-create for Fly apps.
22
+ *
23
+ * `create()` does `GET /v1/apps/{name}`; if found it adopts, otherwise it
24
+ * `POST /v1/apps`. `delete()` is a no-op — deleting a Fly app destroys
25
+ * everything in it, so (like Railway/Neon/Vercel top-level resources) Pulumi
26
+ * does not delete apps.
27
+ *
28
+ * @internal Exported only for unit testing; not part of the public API surface.
29
+ */
30
+ declare class FlyAppResourceProvider implements pulumi.dynamic.ResourceProvider {
31
+ create(inputs: FlyAppInputs): Promise<pulumi.dynamic.CreateResult>;
32
+ read(id: string, props: FlyAppOutputs): Promise<pulumi.dynamic.ReadResult>;
33
+ update(id: string, _olds: FlyAppOutputs, news: FlyAppInputs): Promise<pulumi.dynamic.UpdateResult>;
34
+ delete(): Promise<void>;
35
+ diff(_id: string, olds: FlyAppOutputs, news: FlyAppInputs): Promise<pulumi.dynamic.DiffResult>;
36
+ }
6
37
  /** Options type for FlyApp — replaces Pulumi's native `provider` field. */
7
38
  type FlyAppOptions = Omit<pulumi.ComponentResourceOptions, "provider"> & {
8
39
  /** Fly authentication context. */provider: FlyProvider;
@@ -31,5 +62,5 @@ declare class FlyApp extends pulumi.ComponentResource {
31
62
  constructor(name: string, args: FlyAppArgs, opts: FlyAppOptions);
32
63
  }
33
64
  //#endregion
34
- export { FlyApp, FlyAppArgs };
65
+ export { FlyApp, FlyAppArgs, FlyAppResourceProvider };
35
66
  //# sourceMappingURL=app.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"app.d.mts","names":[],"sources":["../../src/fly/app.ts"],"mappings":";;;;;;KA6IK,aAAA,GAAgB,IAAA,CAAK,MAAA,CAAO,wBAAA;oCAEhC,QAAA,EAAU,WAAA;AAAA;;UAIM,UAAA;EANI;EAQpB,IAAA,EAAM,MAAA,CAAO,KAAA;EANQ;;;;EAYrB,YAAA,GAAe,MAAA,CAAO,KAAK;AAAA;;;AAZN;AAItB;;;;;cAmBa,MAAA,SAAe,MAAA,CAAO,iBAAA;EAjBrB;EAAA,SAmBG,EAAA,EAAI,MAAA,CAAO,MAAA;cAEf,IAAA,UAAc,IA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v1/apps`. `delete()` is a no-op — deleting a Fly app destroys
11
11
  * everything in it, so (like Railway/Neon/Vercel top-level resources) Pulumi
12
12
  * does not delete apps.
13
+ *
14
+ * @internal Exported only for unit testing; not part of the public API surface.
13
15
  */
14
16
  var FlyAppResourceProvider = class {
15
17
  async create(inputs) {
@@ -34,7 +36,7 @@ var FlyAppResourceProvider = class {
34
36
  }
35
37
  async read(id, props) {
36
38
  const app = await new FlyClient(props.token).tryGet(`/v1/apps/${id}`);
37
- if (!app) throw new Error(`Fly app "${id}" not found during refresh`);
39
+ if (!app) return {};
38
40
  return {
39
41
  id,
40
42
  props: {
@@ -70,7 +72,10 @@ var FlyAppResource = class extends pulumi.dynamic.Resource {
70
72
  super(new FlyAppResourceProvider(), name, {
71
73
  ...args,
72
74
  appId: void 0
73
- }, opts);
75
+ }, {
76
+ ...opts,
77
+ additionalSecretOutputs: ["token"]
78
+ });
74
79
  }
75
80
  };
76
81
  /**
@@ -96,5 +101,5 @@ var FlyApp = class extends pulumi.ComponentResource {
96
101
  };
97
102
 
98
103
  //#endregion
99
- export { FlyApp };
104
+ export { FlyApp, FlyAppResourceProvider };
100
105
  //# sourceMappingURL=app.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"app.mjs","names":[],"sources":["../../src/fly/app.ts"],"sourcesContent":["import * as pulumi from \"@pulumi/pulumi\";\n\nimport { FlyClient } from \"./client\";\nimport type { FlyProvider } from \"./provider\";\n\n/** Resolved inputs for the Fly app dynamic provider. */\ninterface FlyAppInputs {\n\t/** Fly API token. */\n\ttoken: string;\n\n\t/** App name (globally unique). Used as the resource identifier. */\n\tname: string;\n\n\t/** Org slug used only when creating a new app. */\n\torganization?: string;\n}\n\n/** Persisted state for the Fly app. */\ninterface FlyAppOutputs extends FlyAppInputs {\n\t/** App identifier — equals the app name (all child paths key off the name). */\n\tappId: string;\n}\n\n/** Get-app response (only the fields we read). */\ninterface FlyAppResponse {\n\tid: string;\n\tname: string;\n}\n\n/**\n * Dynamic provider implementing adopt-or-create for Fly apps.\n *\n * `create()` does `GET /v1/apps/{name}`; if found it adopts, otherwise it\n * `POST /v1/apps`. `delete()` is a no-op — deleting a Fly app destroys\n * everything in it, so (like Railway/Neon/Vercel top-level resources) Pulumi\n * does not delete apps.\n */\nclass FlyAppResourceProvider implements pulumi.dynamic.ResourceProvider {\n\tasync create(inputs: FlyAppInputs): Promise<pulumi.dynamic.CreateResult> {\n\t\tconst client = new FlyClient(inputs.token);\n\n\t\tconst existing = await client.tryGet<FlyAppResponse>(\n\t\t\t`/v1/apps/${inputs.name}`,\n\t\t);\n\n\t\tif (existing) {\n\t\t\tpulumi.log.info(`Adopting existing Fly app \"${inputs.name}\"`);\n\t\t} else {\n\t\t\tif (!inputs.organization) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`FlyApp \"${inputs.name}\": an organization is required to create a new app — set it on FlyProvider or FlyApp args`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tpulumi.log.info(`Fly app \"${inputs.name}\" not found — creating...`);\n\n\t\t\tawait client.post(\"/v1/apps\", {\n\t\t\t\tapp_name: inputs.name,\n\t\t\t\torg_slug: inputs.organization,\n\t\t\t});\n\t\t}\n\n\t\tconst outs: FlyAppOutputs = { ...inputs, appId: inputs.name };\n\n\t\treturn { id: inputs.name, outs };\n\t}\n\n\tasync read(\n\t\tid: string,\n\t\tprops: FlyAppOutputs,\n\t): Promise<pulumi.dynamic.ReadResult> {\n\t\tconst client = new FlyClient(props.token);\n\t\tconst app = await client.tryGet<FlyAppResponse>(`/v1/apps/${id}`);\n\n\t\tif (!app) {\n\t\t\tthrow new Error(`Fly app \"${id}\" not found during refresh`);\n\t\t}\n\n\t\treturn { id, props: { ...props, name: app.name, appId: app.name } };\n\t}\n\n\tasync update(\n\t\tid: string,\n\t\t_olds: FlyAppOutputs,\n\t\tnews: FlyAppInputs,\n\t): Promise<pulumi.dynamic.UpdateResult> {\n\t\treturn { outs: { ...news, appId: id } };\n\t}\n\n\tasync delete(): Promise<void> {\n\t\tpulumi.log.warn(\n\t\t\t\"Fly app deletion skipped — apps are not deleted by Pulumi (would destroy all contained resources)\",\n\t\t);\n\t}\n\n\tasync diff(\n\t\t_id: string,\n\t\tolds: FlyAppOutputs,\n\t\tnews: FlyAppInputs,\n\t): Promise<pulumi.dynamic.DiffResult> {\n\t\tconst replaces: string[] = [];\n\n\t\tif (olds.name !== news.name) {\n\t\t\treplaces.push(\"name\");\n\t\t}\n\n\t\tif (olds.organization !== news.organization) {\n\t\t\treplaces.push(\"organization\");\n\t\t}\n\n\t\treturn {\n\t\t\tchanges: replaces.length > 0,\n\t\t\treplaces,\n\t\t\tdeleteBeforeReplace: true,\n\t\t};\n\t}\n}\n\n/** Internal dynamic resource — not part of the public API. */\nclass FlyAppResource extends pulumi.dynamic.Resource {\n\tpublic declare readonly appId: pulumi.Output<string>;\n\n\tconstructor(\n\t\tname: string,\n\t\targs: {\n\t\t\ttoken: pulumi.Input<string>;\n\t\t\tname: pulumi.Input<string>;\n\t\t\torganization?: pulumi.Input<string | undefined>;\n\t\t},\n\t\topts?: pulumi.CustomResourceOptions,\n\t) {\n\t\tsuper(\n\t\t\tnew FlyAppResourceProvider(),\n\t\t\tname,\n\t\t\t{ ...args, appId: undefined },\n\t\t\topts,\n\t\t);\n\t}\n}\n\n/** Options type for FlyApp — replaces Pulumi's native `provider` field. */\ntype FlyAppOptions = Omit<pulumi.ComponentResourceOptions, \"provider\"> & {\n\t/** Fly authentication context. */\n\tprovider: FlyProvider;\n};\n\n/** Args for FlyApp. */\nexport interface FlyAppArgs {\n\t/** App name (globally unique). Used for adoption lookup and as `.id`. */\n\tname: pulumi.Input<string>;\n\n\t/**\n\t * Org slug for app creation. Overrides `FlyProvider.organization`.\n\t * Ignored when the app already exists (adoption).\n\t */\n\torganization?: pulumi.Input<string>;\n}\n\n/**\n * Manages a Fly app with adopt-or-create semantics.\n *\n * @example\n * ```typescript\n * const app = new FlyApp(\"api\", { name: \"rby-api\" }, { provider });\n * ```\n */\nexport class FlyApp extends pulumi.ComponentResource {\n\t/** App identifier (equals the app name). */\n\tpublic readonly id: pulumi.Output<string>;\n\n\tconstructor(name: string, args: FlyAppArgs, opts: FlyAppOptions) {\n\t\tconst { provider, ...pulumiOpts } = opts;\n\n\t\tsuper(\"infracraft:fly:App\", name, {}, pulumiOpts);\n\n\t\tconst resource = new FlyAppResource(\n\t\t\t`${name}-resource`,\n\t\t\t{\n\t\t\t\ttoken: provider.token,\n\t\t\t\tname: args.name,\n\t\t\t\torganization: args.organization ?? provider.organization,\n\t\t\t},\n\t\t\t{ parent: this },\n\t\t);\n\n\t\tthis.id = resource.appId;\n\n\t\tthis.registerOutputs({ id: this.id });\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;AAqCA,IAAM,yBAAN,MAAwE;CACvE,MAAM,OAAO,QAA4D;EACxE,MAAM,SAAS,IAAI,UAAU,OAAO,KAAK;EAMzC,IAAI,MAJmB,OAAO,OAC7B,YAAY,OAAO,MACpB,GAGC,OAAO,IAAI,KAAK,8BAA8B,OAAO,KAAK,EAAE;OACtD;GACN,IAAI,CAAC,OAAO,cACX,MAAM,IAAI,MACT,WAAW,OAAO,KAAK,0FACxB;GAGD,OAAO,IAAI,KAAK,YAAY,OAAO,KAAK,0BAA0B;GAElE,MAAM,OAAO,KAAK,YAAY;IAC7B,UAAU,OAAO;IACjB,UAAU,OAAO;GAClB,CAAC;EACF;EAEA,MAAM,OAAsB;GAAE,GAAG;GAAQ,OAAO,OAAO;EAAK;EAE5D,OAAO;GAAE,IAAI,OAAO;GAAM;EAAK;CAChC;CAEA,MAAM,KACL,IACA,OACqC;EAErC,MAAM,MAAM,MAAM,IADC,UAAU,MAAM,KACZ,EAAE,OAAuB,YAAY,IAAI;EAEhE,IAAI,CAAC,KACJ,MAAM,IAAI,MAAM,YAAY,GAAG,2BAA2B;EAG3D,OAAO;GAAE;GAAI,OAAO;IAAE,GAAG;IAAO,MAAM,IAAI;IAAM,OAAO,IAAI;GAAK;EAAE;CACnE;CAEA,MAAM,OACL,IACA,OACA,MACuC;EACvC,OAAO,EAAE,MAAM;GAAE,GAAG;GAAM,OAAO;EAAG,EAAE;CACvC;CAEA,MAAM,SAAwB;EAC7B,OAAO,IAAI,KACV,mGACD;CACD;CAEA,MAAM,KACL,KACA,MACA,MACqC;EACrC,MAAM,WAAqB,CAAC;EAE5B,IAAI,KAAK,SAAS,KAAK,MACtB,SAAS,KAAK,MAAM;EAGrB,IAAI,KAAK,iBAAiB,KAAK,cAC9B,SAAS,KAAK,cAAc;EAG7B,OAAO;GACN,SAAS,SAAS,SAAS;GAC3B;GACA,qBAAqB;EACtB;CACD;AACD;;AAGA,IAAM,iBAAN,cAA6B,OAAO,QAAQ,SAAS;CAGpD,YACC,MACA,MAKA,MACC;EACD,MACC,IAAI,uBAAuB,GAC3B,MACA;GAAE,GAAG;GAAM,OAAO;EAAU,GAC5B,IACD;CACD;AACD;;;;;;;;;AA4BA,IAAa,SAAb,cAA4B,OAAO,kBAAkB;CAIpD,YAAY,MAAc,MAAkB,MAAqB;EAChE,MAAM,EAAE,UAAU,GAAG,eAAe;EAEpC,MAAM,sBAAsB,MAAM,CAAC,GAAG,UAAU;EAEhD,MAAM,WAAW,IAAI,eACpB,GAAG,KAAK,YACR;GACC,OAAO,SAAS;GAChB,MAAM,KAAK;GACX,cAAc,KAAK,gBAAgB,SAAS;EAC7C,GACA,EAAE,QAAQ,KAAK,CAChB;EAEA,KAAK,KAAK,SAAS;EAEnB,KAAK,gBAAgB,EAAE,IAAI,KAAK,GAAG,CAAC;CACrC;AACD"}
1
+ {"version":3,"file":"app.mjs","names":[],"sources":["../../src/fly/app.ts"],"sourcesContent":["import * as pulumi from \"@pulumi/pulumi\";\n\nimport { FlyClient } from \"./client\";\nimport type { FlyProvider } from \"./provider\";\n\n/** Resolved inputs for the Fly app dynamic provider. */\ninterface FlyAppInputs {\n\t/** Fly API token. */\n\ttoken: string;\n\n\t/** App name (globally unique). Used as the resource identifier. */\n\tname: string;\n\n\t/** Org slug used only when creating a new app. */\n\torganization?: string;\n}\n\n/** Persisted state for the Fly app. */\ninterface FlyAppOutputs extends FlyAppInputs {\n\t/** App identifier — equals the app name (all child paths key off the name). */\n\tappId: string;\n}\n\n/** Get-app response (only the fields we read). */\ninterface FlyAppResponse {\n\tid: string;\n\tname: string;\n}\n\n/**\n * Dynamic provider implementing adopt-or-create for Fly apps.\n *\n * `create()` does `GET /v1/apps/{name}`; if found it adopts, otherwise it\n * `POST /v1/apps`. `delete()` is a no-op — deleting a Fly app destroys\n * everything in it, so (like Railway/Neon/Vercel top-level resources) Pulumi\n * does not delete apps.\n *\n * @internal Exported only for unit testing; not part of the public API surface.\n */\nexport class FlyAppResourceProvider implements pulumi.dynamic.ResourceProvider {\n\tasync create(inputs: FlyAppInputs): Promise<pulumi.dynamic.CreateResult> {\n\t\tconst client = new FlyClient(inputs.token);\n\n\t\tconst existing = await client.tryGet<FlyAppResponse>(\n\t\t\t`/v1/apps/${inputs.name}`,\n\t\t);\n\n\t\tif (existing) {\n\t\t\tpulumi.log.info(`Adopting existing Fly app \"${inputs.name}\"`);\n\t\t} else {\n\t\t\tif (!inputs.organization) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`FlyApp \"${inputs.name}\": an organization is required to create a new app — set it on FlyProvider or FlyApp args`,\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tpulumi.log.info(`Fly app \"${inputs.name}\" not found — creating...`);\n\n\t\t\tawait client.post(\"/v1/apps\", {\n\t\t\t\tapp_name: inputs.name,\n\t\t\t\torg_slug: inputs.organization,\n\t\t\t});\n\t\t}\n\n\t\tconst outs: FlyAppOutputs = { ...inputs, appId: inputs.name };\n\n\t\treturn { id: inputs.name, outs };\n\t}\n\n\tasync read(\n\t\tid: string,\n\t\tprops: FlyAppOutputs,\n\t): Promise<pulumi.dynamic.ReadResult> {\n\t\tconst client = new FlyClient(props.token);\n\t\tconst app = await client.tryGet<FlyAppResponse>(`/v1/apps/${id}`);\n\n\t\tif (!app) {\n\t\t\t// Resource gone blank id lets refresh reconcile the deletion.\n\t\t\treturn {};\n\t\t}\n\n\t\treturn { id, props: { ...props, name: app.name, appId: app.name } };\n\t}\n\n\tasync update(\n\t\tid: string,\n\t\t_olds: FlyAppOutputs,\n\t\tnews: FlyAppInputs,\n\t): Promise<pulumi.dynamic.UpdateResult> {\n\t\treturn { outs: { ...news, appId: id } };\n\t}\n\n\tasync delete(): Promise<void> {\n\t\tpulumi.log.warn(\n\t\t\t\"Fly app deletion skipped — apps are not deleted by Pulumi (would destroy all contained resources)\",\n\t\t);\n\t}\n\n\tasync diff(\n\t\t_id: string,\n\t\tolds: FlyAppOutputs,\n\t\tnews: FlyAppInputs,\n\t): Promise<pulumi.dynamic.DiffResult> {\n\t\tconst replaces: string[] = [];\n\n\t\tif (olds.name !== news.name) {\n\t\t\treplaces.push(\"name\");\n\t\t}\n\n\t\tif (olds.organization !== news.organization) {\n\t\t\treplaces.push(\"organization\");\n\t\t}\n\n\t\treturn {\n\t\t\tchanges: replaces.length > 0,\n\t\t\treplaces,\n\t\t\tdeleteBeforeReplace: true,\n\t\t};\n\t}\n}\n\n/** Internal dynamic resource — not part of the public API. */\nclass FlyAppResource extends pulumi.dynamic.Resource {\n\tpublic declare readonly appId: pulumi.Output<string>;\n\n\tconstructor(\n\t\tname: string,\n\t\targs: {\n\t\t\ttoken: pulumi.Input<string>;\n\t\t\tname: pulumi.Input<string>;\n\t\t\torganization?: pulumi.Input<string | undefined>;\n\t\t},\n\t\topts?: pulumi.CustomResourceOptions,\n\t) {\n\t\tsuper(\n\t\t\tnew FlyAppResourceProvider(),\n\t\t\tname,\n\t\t\t{ ...args, appId: undefined },\n\t\t\t// The API token flows into dynamic-provider state with the outputs — mark it secret there.\n\t\t\t{ ...opts, additionalSecretOutputs: [\"token\"] },\n\t\t);\n\t}\n}\n\n/** Options type for FlyApp — replaces Pulumi's native `provider` field. */\ntype FlyAppOptions = Omit<pulumi.ComponentResourceOptions, \"provider\"> & {\n\t/** Fly authentication context. */\n\tprovider: FlyProvider;\n};\n\n/** Args for FlyApp. */\nexport interface FlyAppArgs {\n\t/** App name (globally unique). Used for adoption lookup and as `.id`. */\n\tname: pulumi.Input<string>;\n\n\t/**\n\t * Org slug for app creation. Overrides `FlyProvider.organization`.\n\t * Ignored when the app already exists (adoption).\n\t */\n\torganization?: pulumi.Input<string>;\n}\n\n/**\n * Manages a Fly app with adopt-or-create semantics.\n *\n * @example\n * ```typescript\n * const app = new FlyApp(\"api\", { name: \"rby-api\" }, { provider });\n * ```\n */\nexport class FlyApp extends pulumi.ComponentResource {\n\t/** App identifier (equals the app name). */\n\tpublic readonly id: pulumi.Output<string>;\n\n\tconstructor(name: string, args: FlyAppArgs, opts: FlyAppOptions) {\n\t\tconst { provider, ...pulumiOpts } = opts;\n\n\t\tsuper(\"infracraft:fly:App\", name, {}, pulumiOpts);\n\n\t\tconst resource = new FlyAppResource(\n\t\t\t`${name}-resource`,\n\t\t\t{\n\t\t\t\ttoken: provider.token,\n\t\t\t\tname: args.name,\n\t\t\t\torganization: args.organization ?? provider.organization,\n\t\t\t},\n\t\t\t{ parent: this },\n\t\t);\n\n\t\tthis.id = resource.appId;\n\n\t\tthis.registerOutputs({ id: this.id });\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;AAuCA,IAAa,yBAAb,MAA+E;CAC9E,MAAM,OAAO,QAA4D;EACxE,MAAM,SAAS,IAAI,UAAU,OAAO,KAAK;EAMzC,IAAI,MAJmB,OAAO,OAC7B,YAAY,OAAO,MACpB,GAGC,OAAO,IAAI,KAAK,8BAA8B,OAAO,KAAK,EAAE;OACtD;GACN,IAAI,CAAC,OAAO,cACX,MAAM,IAAI,MACT,WAAW,OAAO,KAAK,0FACxB;GAGD,OAAO,IAAI,KAAK,YAAY,OAAO,KAAK,0BAA0B;GAElE,MAAM,OAAO,KAAK,YAAY;IAC7B,UAAU,OAAO;IACjB,UAAU,OAAO;GAClB,CAAC;EACF;EAEA,MAAM,OAAsB;GAAE,GAA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ChB;EAEA,KAAK,KAAK,SAAS;EAEnB,KAAK,gBAAgB,EAAE,IAAI,KAAK,GAAG,CAAC;CACrC;AACD"}
@@ -1,5 +1,6 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
2
  const require_chunk = require('../chunk-BVYJZCqc.cjs');
3
+ const require_errors_api_not_found_error = require('../errors/api-not-found-error.cjs');
3
4
  const require_fly_client = require('./client.cjs');
4
5
  let _pulumi_pulumi = require("@pulumi/pulumi");
5
6
  _pulumi_pulumi = require_chunk.__toESM(_pulumi_pulumi, 1);
@@ -30,7 +31,7 @@ var FlyCertificateResourceProvider = class {
30
31
  }
31
32
  async read(id, props) {
32
33
  const cert = await new require_fly_client.FlyClient(props.token).tryGet(`/v1/apps/${props.appName}/certificates/${encodeURIComponent(id)}`);
33
- if (!cert) throw new Error(`Fly certificate "${id}" not found during refresh`);
34
+ if (!cert) return {};
34
35
  return {
35
36
  id,
36
37
  props: {
@@ -48,7 +49,16 @@ var FlyCertificateResourceProvider = class {
48
49
  } };
49
50
  }
50
51
  async delete(id, props) {
51
- await new require_fly_client.FlyClient(props.token).delete(`/v1/apps/${props.appName}/certificates/${encodeURIComponent(id)}`);
52
+ const client = new require_fly_client.FlyClient(props.token);
53
+ try {
54
+ await client.delete(`/v1/apps/${props.appName}/certificates/${encodeURIComponent(id)}`);
55
+ } catch (error) {
56
+ if (error instanceof require_errors_api_not_found_error.ApiNotFoundError) {
57
+ _pulumi_pulumi.log.warn(`Fly certificate "${id}" already deleted`);
58
+ return;
59
+ }
60
+ throw error;
61
+ }
52
62
  }
53
63
  async diff(_id, olds, news) {
54
64
  const replaces = [];
@@ -68,7 +78,10 @@ var FlyCertificateResource = class extends _pulumi_pulumi.dynamic.Resource {
68
78
  ...args,
69
79
  configured: void 0,
70
80
  dnsRequirements: void 0
71
- }, opts);
81
+ }, {
82
+ ...opts,
83
+ additionalSecretOutputs: ["token"]
84
+ });
72
85
  }
73
86
  };
74
87
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"certificate.cjs","names":["FlyClient","pulumi"],"sources":["../../src/fly/certificate.ts"],"sourcesContent":["import * as pulumi from \"@pulumi/pulumi\";\n\nimport type { FlyApp } from \"./app\";\nimport { FlyClient } from \"./client\";\nimport type { FlyProvider } from \"./provider\";\n\n/** DNS records the consumer must create for certificate validation. */\nexport interface FlyDnsRequirements {\n\t/** ACME challenge CNAME record. */\n\tacme_challenge?: { name: string; target: string };\n\n\t/** `_fly-ownership` TXT record. */\n\townership?: { name: string; app_value: string };\n\n\t/** CNAME target for the hostname itself. */\n\tcname?: string;\n}\n\n/** Resolved inputs for the Fly certificate dynamic provider. */\ninterface FlyCertificateInputs {\n\t/** Fly API token. */\n\ttoken: string;\n\n\t/** App name the certificate belongs to. */\n\tappName: string;\n\n\t/** Hostname to issue an ACME certificate for. Used as the resource key. */\n\thostname: string;\n}\n\n/** Persisted state for the Fly certificate. */\ninterface FlyCertificateOutputs extends FlyCertificateInputs {\n\t/** Whether the certificate is fully provisioned (DNS correct). */\n\tconfigured: boolean;\n\n\t/** DNS records required for validation. */\n\tdnsRequirements: FlyDnsRequirements;\n}\n\n/** Certificate response (only the fields we read). */\ninterface FlyCertificateResponse {\n\thostname: string;\n\tconfigured: boolean;\n\tdns_requirements?: FlyDnsRequirements;\n}\n\n/**\n * Dynamic provider for Fly ACME (Let's Encrypt) certificates. `create()` checks\n * for an existing cert by hostname and adopts it, otherwise it requests one via\n * `POST /v1/apps/{app}/certificates/acme`. The Machines API returns no `id` —\n * the hostname is the resource key.\n */\nclass FlyCertificateResourceProvider\n\timplements pulumi.dynamic.ResourceProvider\n{\n\tasync create(\n\t\tinputs: FlyCertificateInputs,\n\t): Promise<pulumi.dynamic.CreateResult> {\n\t\tconst client = new FlyClient(inputs.token);\n\t\tconst path = `/v1/apps/${inputs.appName}/certificates/${encodeURIComponent(inputs.hostname)}`;\n\n\t\tlet cert = await client.tryGet<FlyCertificateResponse>(path);\n\n\t\tif (cert) {\n\t\t\tpulumi.log.info(`Adopting existing Fly certificate \"${inputs.hostname}\"`);\n\t\t} else {\n\t\t\tcert = await client.post<FlyCertificateResponse>(\n\t\t\t\t`/v1/apps/${inputs.appName}/certificates/acme`,\n\t\t\t\t{ hostname: inputs.hostname },\n\t\t\t);\n\t\t}\n\n\t\tconst outs: FlyCertificateOutputs = {\n\t\t\t...inputs,\n\t\t\tconfigured: cert.configured ?? false,\n\t\t\tdnsRequirements: cert.dns_requirements ?? {},\n\t\t};\n\n\t\treturn { id: inputs.hostname, outs };\n\t}\n\n\tasync read(\n\t\tid: string,\n\t\tprops: FlyCertificateOutputs,\n\t): Promise<pulumi.dynamic.ReadResult> {\n\t\tconst client = new FlyClient(props.token);\n\n\t\tconst cert = await client.tryGet<FlyCertificateResponse>(\n\t\t\t`/v1/apps/${props.appName}/certificates/${encodeURIComponent(id)}`,\n\t\t);\n\n\t\tif (!cert) {\n\t\t\tthrow new Error(`Fly certificate \"${id}\" not found during refresh`);\n\t\t}\n\n\t\treturn {\n\t\t\tid,\n\t\t\tprops: {\n\t\t\t\t...props,\n\t\t\t\tconfigured: cert.configured ?? false,\n\t\t\t\tdnsRequirements: cert.dns_requirements ?? {},\n\t\t\t},\n\t\t};\n\t}\n\n\tasync update(\n\t\t_id: string,\n\t\t_olds: FlyCertificateOutputs,\n\t\tnews: FlyCertificateInputs,\n\t): Promise<pulumi.dynamic.UpdateResult> {\n\t\t// Hostname/app changes force replacement (see diff); nothing else is updatable.\n\t\treturn {\n\t\t\touts: { ...news, configured: false, dnsRequirements: {} },\n\t\t};\n\t}\n\n\tasync delete(id: string, props: FlyCertificateOutputs): Promise<void> {\n\t\tconst client = new FlyClient(props.token);\n\n\t\tawait client.delete(\n\t\t\t`/v1/apps/${props.appName}/certificates/${encodeURIComponent(id)}`,\n\t\t);\n\t}\n\n\tasync diff(\n\t\t_id: string,\n\t\tolds: FlyCertificateOutputs,\n\t\tnews: FlyCertificateInputs,\n\t): Promise<pulumi.dynamic.DiffResult> {\n\t\tconst replaces: string[] = [];\n\n\t\tif (olds.appName !== news.appName) {\n\t\t\treplaces.push(\"appName\");\n\t\t}\n\n\t\tif (olds.hostname !== news.hostname) {\n\t\t\treplaces.push(\"hostname\");\n\t\t}\n\n\t\treturn {\n\t\t\tchanges: replaces.length > 0,\n\t\t\treplaces,\n\t\t\tdeleteBeforeReplace: true,\n\t\t};\n\t}\n}\n\n/** Internal dynamic resource — not part of the public API. */\nclass FlyCertificateResource extends pulumi.dynamic.Resource {\n\tpublic declare readonly configured: pulumi.Output<boolean>;\n\tpublic declare readonly dnsRequirements: pulumi.Output<FlyDnsRequirements>;\n\n\tconstructor(\n\t\tname: string,\n\t\targs: {\n\t\t\ttoken: pulumi.Input<string>;\n\t\t\tappName: pulumi.Input<string>;\n\t\t\thostname: pulumi.Input<string>;\n\t\t},\n\t\topts?: pulumi.CustomResourceOptions,\n\t) {\n\t\tsuper(\n\t\t\tnew FlyCertificateResourceProvider(),\n\t\t\tname,\n\t\t\t{ ...args, configured: undefined, dnsRequirements: undefined },\n\t\t\topts,\n\t\t);\n\t}\n}\n\n/** Options type for FlyCertificate. */\ntype FlyCertificateOptions = Omit<\n\tpulumi.ComponentResourceOptions,\n\t\"provider\"\n> & {\n\t/** Fly authentication context. */\n\tprovider: FlyProvider;\n\n\t/** App the certificate belongs to. */\n\tapp: FlyApp;\n};\n\n/** Args for FlyCertificate. */\nexport interface FlyCertificateArgs {\n\t/** Hostname to issue an ACME certificate for (e.g. `\"api.example.com\"`). */\n\thostname: pulumi.Input<string>;\n}\n\n/**\n * Manages a Fly ACME certificate for a custom hostname.\n *\n * Exposes `.configured` and `.dnsRequirements` so the consumer can wire up the\n * required DNS records.\n *\n * @example\n * ```typescript\n * const cert = new FlyCertificate(\"api-cert\", {\n * hostname: \"api.example.com\",\n * }, { provider, app });\n * ```\n */\nexport class FlyCertificate extends pulumi.ComponentResource {\n\t/** Certificate identifier (equals the hostname). */\n\tpublic readonly id: pulumi.Output<string>;\n\n\t/** Whether the certificate is fully provisioned. */\n\tpublic readonly configured: pulumi.Output<boolean>;\n\n\t/** DNS records required for validation. */\n\tpublic readonly dnsRequirements: pulumi.Output<FlyDnsRequirements>;\n\n\tconstructor(\n\t\tname: string,\n\t\targs: FlyCertificateArgs,\n\t\topts: FlyCertificateOptions,\n\t) {\n\t\tconst { provider, app, ...pulumiOpts } = opts;\n\n\t\tsuper(\"infracraft:fly:Certificate\", name, {}, pulumiOpts);\n\n\t\tconst resource = new FlyCertificateResource(\n\t\t\t`${name}-resource`,\n\t\t\t{\n\t\t\t\ttoken: provider.token,\n\t\t\t\tappName: app.id,\n\t\t\t\thostname: args.hostname,\n\t\t\t},\n\t\t\t{ parent: this },\n\t\t);\n\n\t\tthis.id = pulumi.output(args.hostname);\n\t\tthis.configured = resource.configured;\n\t\tthis.dnsRequirements = resource.dnsRequirements;\n\n\t\tthis.registerOutputs({\n\t\t\tid: this.id,\n\t\t\tconfigured: this.configured,\n\t\t\tdnsRequirements: this.dnsRequirements,\n\t\t});\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;AAoDA,IAAM,iCAAN,MAEA;CACC,MAAM,OACL,QACuC;EACvC,MAAM,SAAS,IAAIA,6BAAU,OAAO,KAAK;EACzC,MAAM,OAAO,YAAY,OAAO,QAAQ,gBAAgB,mBAAmB,OAAO,QAAQ;EAE1F,IAAI,OAAO,MAAM,OAAO,OAA+B,IAAI;EAE3D,IAAI,MACH,eAAO,IAAI,KAAK,sCAAsC,OAAO,SAAS,EAAE;OAExE,OAAO,MAAM,OAAO,KACnB,YAAY,OAAO,QAAQ,qBAC3B,EAAE,UAAU,OAAO,SAAS,CAC7B;EAGD,MAAM,OAA8B;GACnC,GAAG;GACH,YAAY,KAAK,cAAc;GAC/B,iBAAiB,KAAK,oBAAoB,CAAC;EAC5C;EAEA,OAAO;GAAE,IAAI,OAAO;GAAU;EAAK;CACpC;CAEA,MAAM,KACL,IACA,OACqC;EAGrC,MAAM,OAAO,MAAM,IAFAA,6BAAU,MA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AEA,KAAK,KAAKA,eAAO,OAAO,KAAK,QAAQ;EACrC,KAAK,aAAa,SAAS;EAC3B,KAAK,kBAAkB,SAAS;EAEhC,KAAK,gBAAgB;GACpB,IAAI,KAAK;GACT,YAAY,KAAK;GACjB,iBAAiB,KAAK;EACvB,CAAC;CACF;AACD"}
1
+ {"version":3,"file":"certificate.cjs","names":["FlyClient","ApiNotFoundError","pulumi"],"sources":["../../src/fly/certificate.ts"],"sourcesContent":["import * as pulumi from \"@pulumi/pulumi\";\n\nimport { ApiNotFoundError } from \"../errors/api-not-found-error\";\nimport type { FlyApp } from \"./app\";\nimport { FlyClient } from \"./client\";\nimport type { FlyProvider } from \"./provider\";\n\n/** DNS records the consumer must create for certificate validation. */\nexport interface FlyDnsRequirements {\n\t/** ACME challenge CNAME record. */\n\tacme_challenge?: { name: string; target: string };\n\n\t/** `_fly-ownership` TXT record. */\n\townership?: { name: string; app_value: string };\n\n\t/** CNAME target for the hostname itself. */\n\tcname?: string;\n}\n\n/** Resolved inputs for the Fly certificate dynamic provider. */\ninterface FlyCertificateInputs {\n\t/** Fly API token. */\n\ttoken: string;\n\n\t/** App name the certificate belongs to. */\n\tappName: string;\n\n\t/** Hostname to issue an ACME certificate for. Used as the resource key. */\n\thostname: string;\n}\n\n/** Persisted state for the Fly certificate. */\ninterface FlyCertificateOutputs extends FlyCertificateInputs {\n\t/** Whether the certificate is fully provisioned (DNS correct). */\n\tconfigured: boolean;\n\n\t/** DNS records required for validation. */\n\tdnsRequirements: FlyDnsRequirements;\n}\n\n/** Certificate response (only the fields we read). */\ninterface FlyCertificateResponse {\n\thostname: string;\n\tconfigured: boolean;\n\tdns_requirements?: FlyDnsRequirements;\n}\n\n/**\n * Dynamic provider for Fly ACME (Let's Encrypt) certificates. `create()` checks\n * for an existing cert by hostname and adopts it, otherwise it requests one via\n * `POST /v1/apps/{app}/certificates/acme`. The Machines API returns no `id` —\n * the hostname is the resource key.\n */\nclass FlyCertificateResourceProvider\n\timplements pulumi.dynamic.ResourceProvider\n{\n\tasync create(\n\t\tinputs: FlyCertificateInputs,\n\t): Promise<pulumi.dynamic.CreateResult> {\n\t\tconst client = new FlyClient(inputs.token);\n\t\tconst path = `/v1/apps/${inputs.appName}/certificates/${encodeURIComponent(inputs.hostname)}`;\n\n\t\tlet cert = await client.tryGet<FlyCertificateResponse>(path);\n\n\t\tif (cert) {\n\t\t\tpulumi.log.info(`Adopting existing Fly certificate \"${inputs.hostname}\"`);\n\t\t} else {\n\t\t\tcert = await client.post<FlyCertificateResponse>(\n\t\t\t\t`/v1/apps/${inputs.appName}/certificates/acme`,\n\t\t\t\t{ hostname: inputs.hostname },\n\t\t\t);\n\t\t}\n\n\t\tconst outs: FlyCertificateOutputs = {\n\t\t\t...inputs,\n\t\t\tconfigured: cert.configured ?? false,\n\t\t\tdnsRequirements: cert.dns_requirements ?? {},\n\t\t};\n\n\t\treturn { id: inputs.hostname, outs };\n\t}\n\n\tasync read(\n\t\tid: string,\n\t\tprops: FlyCertificateOutputs,\n\t): Promise<pulumi.dynamic.ReadResult> {\n\t\tconst client = new FlyClient(props.token);\n\n\t\tconst cert = await client.tryGet<FlyCertificateResponse>(\n\t\t\t`/v1/apps/${props.appName}/certificates/${encodeURIComponent(id)}`,\n\t\t);\n\n\t\tif (!cert) {\n\t\t\t// Resource gone blank id lets refresh reconcile the deletion.\n\t\t\treturn {};\n\t\t}\n\n\t\treturn {\n\t\t\tid,\n\t\t\tprops: {\n\t\t\t\t...props,\n\t\t\t\tconfigured: cert.configured ?? false,\n\t\t\t\tdnsRequirements: cert.dns_requirements ?? {},\n\t\t\t},\n\t\t};\n\t}\n\n\tasync update(\n\t\t_id: string,\n\t\t_olds: FlyCertificateOutputs,\n\t\tnews: FlyCertificateInputs,\n\t): Promise<pulumi.dynamic.UpdateResult> {\n\t\t// Hostname/app changes force replacement (see diff); nothing else is updatable.\n\t\treturn {\n\t\t\touts: { ...news, configured: false, dnsRequirements: {} },\n\t\t};\n\t}\n\n\tasync delete(id: string, props: FlyCertificateOutputs): Promise<void> {\n\t\tconst client = new FlyClient(props.token);\n\n\t\ttry {\n\t\t\tawait client.delete(\n\t\t\t\t`/v1/apps/${props.appName}/certificates/${encodeURIComponent(id)}`,\n\t\t\t);\n\t\t} catch (error) {\n\t\t\t// Already gone — deletion is idempotent.\n\t\t\tif (error instanceof ApiNotFoundError) {\n\t\t\t\tpulumi.log.warn(`Fly certificate \"${id}\" already deleted`);\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tasync diff(\n\t\t_id: string,\n\t\tolds: FlyCertificateOutputs,\n\t\tnews: FlyCertificateInputs,\n\t): Promise<pulumi.dynamic.DiffResult> {\n\t\tconst replaces: string[] = [];\n\n\t\tif (olds.appName !== news.appName) {\n\t\t\treplaces.push(\"appName\");\n\t\t}\n\n\t\tif (olds.hostname !== news.hostname) {\n\t\t\treplaces.push(\"hostname\");\n\t\t}\n\n\t\treturn {\n\t\t\tchanges: replaces.length > 0,\n\t\t\treplaces,\n\t\t\tdeleteBeforeReplace: true,\n\t\t};\n\t}\n}\n\n/** Internal dynamic resource — not part of the public API. */\nclass FlyCertificateResource extends pulumi.dynamic.Resource {\n\tpublic declare readonly configured: pulumi.Output<boolean>;\n\tpublic declare readonly dnsRequirements: pulumi.Output<FlyDnsRequirements>;\n\n\tconstructor(\n\t\tname: string,\n\t\targs: {\n\t\t\ttoken: pulumi.Input<string>;\n\t\t\tappName: pulumi.Input<string>;\n\t\t\thostname: pulumi.Input<string>;\n\t\t},\n\t\topts?: pulumi.CustomResourceOptions,\n\t) {\n\t\tsuper(\n\t\t\tnew FlyCertificateResourceProvider(),\n\t\t\tname,\n\t\t\t{ ...args, configured: undefined, dnsRequirements: undefined },\n\t\t\t// The API token flows into dynamic-provider state with the outputs — mark it secret there.\n\t\t\t{ ...opts, additionalSecretOutputs: [\"token\"] },\n\t\t);\n\t}\n}\n\n/** Options type for FlyCertificate. */\ntype FlyCertificateOptions = Omit<\n\tpulumi.ComponentResourceOptions,\n\t\"provider\"\n> & {\n\t/** Fly authentication context. */\n\tprovider: FlyProvider;\n\n\t/** App the certificate belongs to. */\n\tapp: FlyApp;\n};\n\n/** Args for FlyCertificate. */\nexport interface FlyCertificateArgs {\n\t/** Hostname to issue an ACME certificate for (e.g. `\"api.example.com\"`). */\n\thostname: pulumi.Input<string>;\n}\n\n/**\n * Manages a Fly ACME certificate for a custom hostname.\n *\n * Exposes `.configured` and `.dnsRequirements` so the consumer can wire up the\n * required DNS records.\n *\n * @example\n * ```typescript\n * const cert = new FlyCertificate(\"api-cert\", {\n * hostname: \"api.example.com\",\n * }, { provider, app });\n * ```\n */\nexport class FlyCertificate extends pulumi.ComponentResource {\n\t/** Certificate identifier (equals the hostname). */\n\tpublic readonly id: pulumi.Output<string>;\n\n\t/** Whether the certificate is fully provisioned. */\n\tpublic readonly configured: pulumi.Output<boolean>;\n\n\t/** DNS records required for validation. */\n\tpublic readonly dnsRequirements: pulumi.Output<FlyDnsRequirements>;\n\n\tconstructor(\n\t\tname: string,\n\t\targs: FlyCertificateArgs,\n\t\topts: FlyCertificateOptions,\n\t) {\n\t\tconst { provider, app, ...pulumiOpts } = opts;\n\n\t\tsuper(\"infracraft:fly:Certificate\", name, {}, pulumiOpts);\n\n\t\tconst resource = new FlyCertificateResource(\n\t\t\t`${name}-resource`,\n\t\t\t{\n\t\t\t\ttoken: provider.token,\n\t\t\t\tappName: app.id,\n\t\t\t\thostname: args.hostname,\n\t\t\t},\n\t\t\t{ parent: this },\n\t\t);\n\n\t\tthis.id = pulumi.output(args.hostname);\n\t\tthis.configured = resource.configured;\n\t\tthis.dnsRequirements = resource.dnsRequirements;\n\n\t\tthis.registerOutputs({\n\t\t\tid: this.id,\n\t\t\tconfigured: this.configured,\n\t\t\tdnsRequirements: this.dnsRequirements,\n\t\t});\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;AAqDA,IAAM,iCAAN,MAEA;CACC,MAAM,OACL,QACuC;EACvC,M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A;;UAIW,kBAAA;EAJL;EAMX,QAAA,EAAU,MAAA,CAAO,KAAK;AAAA;;;;;;;AANX;AAIZ;;;;;;cAkBa,cAAA,SAAuB,MAAA,CAAO,iBAAA;EAhBpB;EAAA,SAkBN,EAAA,EAAI,MAAA,CAAO,MAAA;EAFf;EAAA,SAKI,UAAA,EAAY,MAAA,CAAO,MAAA;;WAGnB,eAAA,EAAiB,MAAA,CAAO,MAAA,CAAO,kBAAA;cAG9C,IAAA,UACA,IAAA,EAAM,kBAAA,EACN,IAAA,EAAM,qBAAA;AAAA"}
1
+ {"version":3,"file":"certificate.d.cts","names":[],"sources":["../../src/fly/certificate.ts"],"mappings":";;;;;;;UAQiB,kBAAA;;EAEhB,cAAA;IAAmB,IAAA;IAAc,MAAA;EAAA;EAAjC;EAGA,SAAA;IAAc,IAAA;IAAc,SAAA;EAAA;EAAA;EAG5B,KAAA;AAAA;AAAK;AAAA,KAyKD,qBAAA,GAAwB,IAAA,CAC5B,MAAA,CAAO,wBAAA;EADkB,kCAKzB,QAAA,EAAU,WAAA,EAJV;EAOA,GAAA,EAAK,MAAA;AAAA;;UAIW,kBAAA;EAJL;EAMX,QAAA,EAAU,MAAA,CAAO,KAAK;AAAA;;;;;;;AANX;AAIZ;;;;;;cAkBa,cAAA,SAAuB,MAAA,CAAO,iBAAA;EAhBpB;EAAA,SAkBN,EAAA,EAAI,MAAA,CAAO,MAAA;EAFf;EAAA,SAKI,UAAA,EAAY,MAAA,CAAO,MAAA;;WAGnB,eAAA,EAAiB,MAAA,CAAO,MAAA,CAAO,kBAAA;cAG9C,IAAA,UACA,IAAA,EAAM,kBAAA,EACN,IAAA,EAAM,qBAAA;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"certificate.d.mts","names":[],"sources":["../../src/fly/certificate.ts"],"mappings":";;;;;;;UAOiB,kBAAA;;EAEhB,cAAA;IAAmB,IAAA;IAAc,MAAA;EAAA;EAAjC;EAGA,SAAA;IAAc,IAAA;IAAc,SAAA;E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{ t as __name } from "../chunk-OPjESj5l.mjs";
2
+ import { ApiNotFoundError } from "../errors/api-not-found-error.mjs";
2
3
  import { FlyClient } from "./client.mjs";
3
4
  import * as pulumi from "@pulumi/pulumi";
4
5
 
@@ -28,7 +29,7 @@ var FlyCertificateResourceProvider = class {
28
29
  }
29
30
  async read(id, props) {
30
31
  const cert = await new FlyClient(props.token).tryGet(`/v1/apps/${props.appName}/certificates/${encodeURIComponent(id)}`);
31
- if (!cert) throw new Error(`Fly certificate "${id}" not found during refresh`);
32
+ if (!cert) return {};
32
33
  return {
33
34
  id,
34
35
  props: {
@@ -46,7 +47,16 @@ var FlyCertificateResourceProvider = class {
46
47
  } };
47
48
  }
48
49
  async delete(id, props) {
49
- await new FlyClient(props.token).delete(`/v1/apps/${props.appName}/certificates/${encodeURIComponent(id)}`);
50
+ const client = new FlyClient(props.token);
51
+ try {
52
+ await client.delete(`/v1/apps/${props.appName}/certificates/${encodeURIComponent(id)}`);
53
+ } catch (error) {
54
+ if (error instanceof ApiNotFoundError) {
55
+ pulumi.log.warn(`Fly certificate "${id}" already deleted`);
56
+ return;
57
+ }
58
+ throw error;
59
+ }
50
60
  }
51
61
  async diff(_id, olds, news) {
52
62
  const replaces = [];
@@ -66,7 +76,10 @@ var FlyCertificateResource = class extends pulumi.dynamic.Resource {
66
76
  ...args,
67
77
  configured: void 0,
68
78
  dnsRequirements: void 0
69
- }, opts);
79
+ }, {
80
+ ...opts,
81
+ additionalSecretOutputs: ["token"]
82
+ });
70
83
  }
71
84
  };
72
85
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"certificate.mjs","names":[],"sources":["../../src/fly/certificate.ts"],"sourcesContent":["import * as pulumi from \"@pulumi/pulumi\";\n\nimport type { FlyApp } from \"./app\";\nimport { FlyClient } from \"./client\";\nimport type { FlyProvider } from \"./provider\";\n\n/** DNS records the consumer must create for certificate validation. */\nexport interface FlyDnsRequirements {\n\t/** ACME challenge CNAME record. */\n\tacme_challenge?: { name: string; target: string };\n\n\t/** `_fly-ownership` TXT record. */\n\townership?: { name: string; app_value: string };\n\n\t/** CNAME target for the hostname itself. */\n\tcname?: string;\n}\n\n/** Resolved inputs for the Fly certificate dynamic provider. */\ninterface FlyCertificateInputs {\n\t/** Fly API token. */\n\ttoken: string;\n\n\t/** App name the certificate belongs to. */\n\tappName: string;\n\n\t/** Hostname to issue an ACME certificate for. Used as the resource key. */\n\thostname: string;\n}\n\n/** Persisted state for the Fly certificate. */\ninterface FlyCertificateOutputs extends FlyCertificateInputs {\n\t/** Whether the certificate is fully provisioned (DNS correct). */\n\tconfigured: boolean;\n\n\t/** DNS records required for validation. */\n\tdnsRequirements: FlyDnsRequirements;\n}\n\n/** Certificate response (only the fields we read). */\ninterface FlyCertificateResponse {\n\thostname: string;\n\tconfigured: boolean;\n\tdns_requirements?: FlyDnsRequirements;\n}\n\n/**\n * Dynamic provider for Fly ACME (Let's Encrypt) certificates. `create()` checks\n * for an existing cert by hostname and adopts it, otherwise it requests one via\n * `POST /v1/apps/{app}/certificates/acme`. The Machines API returns no `id` —\n * the hostname is the resource key.\n */\nclass FlyCertificateResourceProvider\n\timplements pulumi.dynamic.ResourceProvider\n{\n\tasync create(\n\t\tinputs: FlyCertificateInputs,\n\t): Promise<pulumi.dynamic.CreateResult> {\n\t\tconst client = new FlyClient(inputs.token);\n\t\tconst path = `/v1/apps/${inputs.appName}/certificates/${encodeURIComponent(inputs.hostname)}`;\n\n\t\tlet cert = await client.tryGet<FlyCertificateResponse>(path);\n\n\t\tif (cert) {\n\t\t\tpulumi.log.info(`Adopting existing Fly certificate \"${inputs.hostname}\"`);\n\t\t} else {\n\t\t\tcert = await client.post<FlyCertificateResponse>(\n\t\t\t\t`/v1/apps/${inputs.appName}/certificates/acme`,\n\t\t\t\t{ hostname: inputs.hostname },\n\t\t\t);\n\t\t}\n\n\t\tconst outs: FlyCertificateOutputs = {\n\t\t\t...inputs,\n\t\t\tconfigured: cert.configured ?? false,\n\t\t\tdnsRequirements: cert.dns_requirements ?? {},\n\t\t};\n\n\t\treturn { id: inputs.hostname, outs };\n\t}\n\n\tasync read(\n\t\tid: string,\n\t\tprops: FlyCertificateOutputs,\n\t): Promise<pulumi.dynamic.ReadResult> {\n\t\tconst client = new FlyClient(props.token);\n\n\t\tconst cert = await client.tryGet<FlyCertificateResponse>(\n\t\t\t`/v1/apps/${props.appName}/certificates/${encodeURIComponent(id)}`,\n\t\t);\n\n\t\tif (!cert) {\n\t\t\tthrow new Error(`Fly certificate \"${id}\" not found during refresh`);\n\t\t}\n\n\t\treturn {\n\t\t\tid,\n\t\t\tprops: {\n\t\t\t\t...props,\n\t\t\t\tconfigured: cert.configured ?? false,\n\t\t\t\tdnsRequirements: cert.dns_requirements ?? {},\n\t\t\t},\n\t\t};\n\t}\n\n\tasync update(\n\t\t_id: string,\n\t\t_olds: FlyCertificateOutputs,\n\t\tnews: FlyCertificateInputs,\n\t): Promise<pulumi.dynamic.UpdateResult> {\n\t\t// Hostname/app changes force replacement (see diff); nothing else is updatable.\n\t\treturn {\n\t\t\touts: { ...news, configured: false, dnsRequirements: {} },\n\t\t};\n\t}\n\n\tasync delete(id: string, props: FlyCertificateOutputs): Promise<void> {\n\t\tconst client = new FlyClient(props.token);\n\n\t\tawait client.delete(\n\t\t\t`/v1/apps/${props.appName}/certificates/${encodeURIComponent(id)}`,\n\t\t);\n\t}\n\n\tasync diff(\n\t\t_id: string,\n\t\tolds: FlyCertificateOutputs,\n\t\tnews: FlyCertificateInputs,\n\t): Promise<pulumi.dynamic.DiffResult> {\n\t\tconst replaces: string[] = [];\n\n\t\tif (olds.appName !== news.appName) {\n\t\t\treplaces.push(\"appName\");\n\t\t}\n\n\t\tif (olds.hostname !== news.hostname) {\n\t\t\treplaces.push(\"hostname\");\n\t\t}\n\n\t\treturn {\n\t\t\tchanges: replaces.length > 0,\n\t\t\treplaces,\n\t\t\tdeleteBeforeReplace: true,\n\t\t};\n\t}\n}\n\n/** Internal dynamic resource — not part of the public API. */\nclass FlyCertificateResource extends pulumi.dynamic.Resource {\n\tpublic declare readonly configured: pulumi.Output<boolean>;\n\tpublic declare readonly dnsRequirements: pulumi.Output<FlyDnsRequirements>;\n\n\tconstructor(\n\t\tname: string,\n\t\targs: {\n\t\t\ttoken: pulumi.Input<string>;\n\t\t\tappName: pulumi.Input<string>;\n\t\t\thostname: pulumi.Input<string>;\n\t\t},\n\t\topts?: pulumi.CustomResourceOptions,\n\t) {\n\t\tsuper(\n\t\t\tnew FlyCertificateResourceProvider(),\n\t\t\tname,\n\t\t\t{ ...args, configured: undefined, dnsRequirements: undefined },\n\t\t\topts,\n\t\t);\n\t}\n}\n\n/** Options type for FlyCertificate. */\ntype FlyCertificateOptions = Omit<\n\tpulumi.ComponentResourceOptions,\n\t\"provider\"\n> & {\n\t/** Fly authentication context. */\n\tprovider: FlyProvider;\n\n\t/** App the certificate belongs to. */\n\tapp: FlyApp;\n};\n\n/** Args for FlyCertificate. */\nexport interface FlyCertificateArgs {\n\t/** Hostname to issue an ACME certificate for (e.g. `\"api.example.com\"`). */\n\thostname: pulumi.Input<string>;\n}\n\n/**\n * Manages a Fly ACME certificate for a custom hostname.\n *\n * Exposes `.configured` and `.dnsRequirements` so the consumer can wire up the\n * required DNS records.\n *\n * @example\n * ```typescript\n * const cert = new FlyCertificate(\"api-cert\", {\n * hostname: \"api.example.com\",\n * }, { provider, app });\n * ```\n */\nexport class FlyCertificate extends pulumi.ComponentResource {\n\t/** Certificate identifier (equals the hostname). */\n\tpublic readonly id: pulumi.Output<string>;\n\n\t/** Whether the certificate is fully provisioned. */\n\tpublic readonly configured: pulumi.Output<boolean>;\n\n\t/** DNS records required for validation. */\n\tpublic readonly dnsRequirements: pulumi.Output<FlyDnsRequirements>;\n\n\tconstructor(\n\t\tname: string,\n\t\targs: FlyCertificateArgs,\n\t\topts: FlyCertificateOptions,\n\t) {\n\t\tconst { provider, app, ...pulumiOpts } = opts;\n\n\t\tsuper(\"infracraft:fly:Certificate\", name, {}, pulumiOpts);\n\n\t\tconst resource = new FlyCertificateResource(\n\t\t\t`${name}-resource`,\n\t\t\t{\n\t\t\t\ttoken: provider.token,\n\t\t\t\tappName: app.id,\n\t\t\t\thostname: args.hostname,\n\t\t\t},\n\t\t\t{ parent: this },\n\t\t);\n\n\t\tthis.id = pulumi.output(args.hostname);\n\t\tthis.configured = resource.configured;\n\t\tthis.dnsRequirements = resource.dnsRequirements;\n\n\t\tthis.registerOutputs({\n\t\t\tid: this.id,\n\t\t\tconfigured: this.configured,\n\t\t\tdnsRequirements: this.dnsRequirements,\n\t\t});\n\t}\n}\n"],"mappings":";;;;;;;;;;;AAoDA,IAAM,iCAAN,MAEA;CACC,MAAM,OACL,QACuC;EACvC,MAAM,SAAS,IAAI,UAAU,OAAO,KAAK;EACzC,MAAM,OAAO,YAAY,OAAO,QAAQ,gBAAgB,mBAAmB,OAAO,QAAQ;EAE1F,IAAI,OAAO,MAAM,OAAO,OAA+B,IAAI;EAE3D,IAAI,MACH,OAAO,IAAI,KAAK,sCAAsC,OAAO,SAAS,EAAE;OAExE,OAAO,MAAM,OAAO,KACnB,YAAY,OAAO,QAAQ,qBAC3B,EAAE,UAAU,OAAO,SAAS,CAC7B;EAGD,MAAM,OAA8B;GACnC,GAAG;GACH,YAAY,KAAK,cAAc;GAC/B,iBAAiB,KAAK,oBAAoB,CAAC;EAC5C;EAEA,OAAO;GAAE,IAAI,OAAO;GAAU;EAAK;CACpC;CAEA,MAAM,KACL,IACA,OACqC;EAGrC,MAAM,OAAO,MAAM,IAFA,UAAU,MAAM,KAEX,EAAE,OACzB,YAAY,MAAM,QAAQ,gBAAgB,mBAAmB,EAAE,GAChE;EAEA,IAAI,CAAC,MACJ,MAAM,IAAI,MAAM,oBAAoB,GAAG,2BAA2B;EAGnE,OAAO;GACN;GACA,OAAO;IACN,GAAG;IACH,YAAY,KAAK,cAAc;IAC/B,iBAAiB,KAAK,oBAAoB,CAAC;GAC5C;EACD;CACD;CAEA,MAAM,OACL,KACA,OACA,MACuC;EAEvC,OAAO,EACN,MAAM;GAAE,GAAG;GAAM,YAAY;GAAO,iBAAiB,CAAC;EAAE,EACzD;CACD;CAEA,MAAM,OAAO,IAAY,OAA6C;EAGrE,MAAM,IAFa,UAAU,MAAM,KAExB,EAAE,OACZ,YAAY,MAAM,QAAQ,gBAAgB,mBAAmB,EAAE,GAChE;CACD;CAEA,MAAM,KACL,KACA,MACA,MACqC;EACrC,MAAM,WAAqB,CAAC;EAE5B,IAAI,KAAK,YAAY,KAAK,SACzB,SAAS,KAAK,SAAS;EAGxB,IAAI,KAAK,aAAa,KAAK,UAC1B,SAAS,KAAK,UAAU;EAGzB,OAAO;GACN,SAAS,SAAS,SAAS;GAC3B;GACA,qBAAqB;EACtB;CACD;AACD;;AAGA,IAAM,yBAAN,cAAqC,OAAO,QAAQ,SAAS;CAI5D,YACC,MACA,MAKA,MACC;EACD,MACC,IAAI,+BAA+B,GACnC,MACA;GAAE,GAAG;GAAM,YAAY;GAAW,iBAAiB;EAAU,GAC7D,IACD;CACD;AACD;;;;;;;;;;;;;;AAiCA,IAAa,iBAAb,cAAoC,OAAO,kBAAkB;CAU5D,YACC,MACA,MACA,MACC;EACD,MAAM,EAAE,UAAU,KAAK,GAAG,eAAe;EAEzC,MAAM,8BAA8B,MAAM,CAAC,GAAG,UAAU;EAExD,MAAM,WAAW,IAAI,uBACpB,GAAG,KAAK,YACR;GACC,OAAO,SAAS;GAChB,SAAS,IAAI;GACb,UAAU,KAAK;EAChB,GACA,EAAE,QAAQ,KAAK,CAChB;EAEA,KAAK,KAAK,OAAO,OAAO,KAAK,QAAQ;EACrC,KAAK,aAAa,SAAS;EAC3B,KAAK,kBAAkB,SAAS;EAEhC,KAAK,gBAAgB;GACpB,IAAI,KAAK;GACT,YAAY,KAAK;GACjB,iBAAiB,KAAK;EACvB,CAAC;CACF;AACD"}
1
+ {"version":3,"file":"certificate.mjs","names":[],"sources":["../../src/fly/certificate.ts"],"sourcesContent":["import * as pulumi from \"@pulumi/pulumi\";\n\nimport { ApiNotFoundError } from \"../errors/api-not-found-error\";\nimport type { FlyApp } from \"./app\";\nimport { FlyClient } from \"./client\";\nimport type { FlyProvider } from \"./provider\";\n\n/** DNS records the consumer must create for certificate validation. */\nexport interface FlyDnsRequirements {\n\t/** ACME challenge CNAME record. */\n\tacme_challenge?: { name: string; target: string };\n\n\t/** `_fly-ownership` TXT record. */\n\townership?: { name: string; app_value: string };\n\n\t/** CNAME target for the hostname itself. */\n\tcname?: string;\n}\n\n/** Resolved inputs for the Fly certificate dynamic provider. */\ninterface FlyCertificateInputs {\n\t/** Fly API token. */\n\ttoken: string;\n\n\t/** App name the certificate belongs to. */\n\tappName: string;\n\n\t/** Hostname to issue an ACME certificate for. Used as the resource key. */\n\thostname: string;\n}\n\n/** Persisted state for the Fly certificate. */\ninterface FlyCertificateOutputs extends FlyCertificateInputs {\n\t/** Whether the certificate is fully provisioned (DNS correct). */\n\tconfigured: boolean;\n\n\t/** DNS records required for validation. */\n\tdnsRequirements: FlyDnsRequirements;\n}\n\n/** Certificate response (only the fields we read). */\ninterface FlyCertificateResponse {\n\thostname: string;\n\tconfigured: boolean;\n\tdns_requirements?: FlyDnsRequirements;\n}\n\n/**\n * Dynamic provider for Fly ACME (Let's Encrypt) certificates. `create()` checks\n * for an existing cert by hostname and adopts it, otherwise it requests one via\n * `POST /v1/apps/{app}/certificates/acme`. The Machines API returns no `id` —\n * the hostname is the resource key.\n */\nclass FlyCertificateResourceProvider\n\timplements pulumi.dynamic.ResourceProvider\n{\n\tasync create(\n\t\tinputs: FlyCertificateInputs,\n\t): Promise<pulumi.dynamic.CreateResult> {\n\t\tconst client = new FlyClient(inputs.token);\n\t\tconst path = `/v1/apps/${inputs.appName}/certificates/${encodeURIComponent(inputs.hostname)}`;\n\n\t\tlet cert = await client.tryGet<FlyCertificateResponse>(path);\n\n\t\tif (cert) {\n\t\t\tpulumi.log.info(`Adopting existing Fly certificate \"${inputs.hostname}\"`);\n\t\t} else {\n\t\t\tcert = await client.post<FlyCertificateResponse>(\n\t\t\t\t`/v1/apps/${inputs.appName}/certificates/acme`,\n\t\t\t\t{ hostname: inputs.hostname },\n\t\t\t);\n\t\t}\n\n\t\tconst outs: FlyCertificateOutputs = {\n\t\t\t...inputs,\n\t\t\tconfigured: cert.configured ?? false,\n\t\t\tdnsRequirements: cert.dns_requirements ?? {},\n\t\t};\n\n\t\treturn { id: inputs.hostname, outs };\n\t}\n\n\tasync read(\n\t\tid: string,\n\t\tprops: FlyCertificateOutputs,\n\t): Promise<pulumi.dynamic.ReadResult> {\n\t\tconst client = new FlyClient(props.token);\n\n\t\tconst cert = await client.tryGet<FlyCertificateResponse>(\n\t\t\t`/v1/apps/${props.appName}/certificates/${encodeURIComponent(id)}`,\n\t\t);\n\n\t\tif (!cert) {\n\t\t\t// Resource gone blank id lets refresh reconcile the deletion.\n\t\t\treturn {};\n\t\t}\n\n\t\treturn {\n\t\t\tid,\n\t\t\tprops: {\n\t\t\t\t...props,\n\t\t\t\tconfigured: cert.configured ?? false,\n\t\t\t\tdnsRequirements: cert.dns_requirements ?? {},\n\t\t\t},\n\t\t};\n\t}\n\n\tasync update(\n\t\t_id: string,\n\t\t_olds: FlyCertificateOutputs,\n\t\tnews: FlyCertificateInputs,\n\t): Promise<pulumi.dynamic.UpdateResult> {\n\t\t// Hostname/app changes force replacement (see diff); nothing else is updatable.\n\t\treturn {\n\t\t\touts: { ...news, configured: false, dnsRequirements: {} },\n\t\t};\n\t}\n\n\tasync delete(id: string, props: FlyCertificateOutputs): Promise<void> {\n\t\tconst client = new FlyClient(props.token);\n\n\t\ttry {\n\t\t\tawait client.delete(\n\t\t\t\t`/v1/apps/${props.appName}/certificates/${encodeURIComponent(id)}`,\n\t\t\t);\n\t\t} catch (error) {\n\t\t\t// Already gone — deletion is idempotent.\n\t\t\tif (error instanceof ApiNotFoundError) {\n\t\t\t\tpulumi.log.warn(`Fly certificate \"${id}\" already deleted`);\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tthrow error;\n\t\t}\n\t}\n\n\tasync diff(\n\t\t_id: string,\n\t\tolds: FlyCertificateOutputs,\n\t\tnews: FlyCertificateInputs,\n\t): Promise<pulumi.dynamic.DiffResult> {\n\t\tconst replaces: string[] = [];\n\n\t\tif (olds.appName !== news.appName) {\n\t\t\treplaces.push(\"appName\");\n\t\t}\n\n\t\tif (olds.hostname !== news.hostname) {\n\t\t\treplaces.push(\"hostname\");\n\t\t}\n\n\t\treturn {\n\t\t\tchanges: replaces.length > 0,\n\t\t\treplaces,\n\t\t\tdeleteBeforeReplace: true,\n\t\t};\n\t}\n}\n\n/** Internal dynamic resource — not part of the public API. */\nclass FlyCertificateResource extends pulumi.dynamic.Resource {\n\tpublic declare readonly configured: pulumi.Output<boolean>;\n\tpublic declare readonly dnsRequirements: pulumi.Output<FlyDnsRequirements>;\n\n\tconstructor(\n\t\tname: string,\n\t\targs: {\n\t\t\ttoken: pulumi.Input<string>;\n\t\t\tappName: pulumi.Input<string>;\n\t\t\thostname: pulumi.Input<string>;\n\t\t},\n\t\topts?: pulumi.CustomResourceOptions,\n\t) {\n\t\tsuper(\n\t\t\tnew FlyCertificateResourceProvider(),\n\t\t\tname,\n\t\t\t{ ...args, configured: undefined, dnsRequirements: undefined },\n\t\t\t// The API token flows into dynamic-provider state with the outputs — mark it secret there.\n\t\t\t{ ...opts, additionalSecretOutputs: [\"token\"] },\n\t\t);\n\t}\n}\n\n/** Options type for FlyCertificate. */\ntype FlyCertificateOptions = Omit<\n\tpulumi.ComponentResourceOptions,\n\t\"provider\"\n> & {\n\t/** Fly authentication context. */\n\tprovider: FlyProvider;\n\n\t/** App the certificate belongs to. */\n\tapp: FlyApp;\n};\n\n/** Args for FlyCertificate. */\nexport interface FlyCertificateArgs {\n\t/** Hostname to issue an ACME certificate for (e.g. `\"api.example.com\"`). */\n\thostname: pulumi.Input<string>;\n}\n\n/**\n * Manages a Fly ACME certificate for a custom hostname.\n *\n * Exposes `.configured` and `.dnsRequirements` so the consumer can wire up the\n * required DNS records.\n *\n * @example\n * ```typescript\n * const cert = new FlyCertificate(\"api-cert\", {\n * hostname: \"api.example.com\",\n * }, { provider, app });\n * ```\n */\nexport class FlyCertificate extends pulumi.ComponentResource {\n\t/** Certificate identifier (equals the hostname). */\n\tpublic readonly id: pulumi.Output<string>;\n\n\t/** Whether the certificate is fully provisioned. */\n\tpublic readonly configured: pulumi.Output<boolean>;\n\n\t/** DNS records required for validation. */\n\tpublic readonly dnsRequirements: pulumi.Output<FlyDnsRequirements>;\n\n\tconstructor(\n\t\tname: string,\n\t\targs: FlyCertificateArgs,\n\t\topts: FlyCertificateOptions,\n\t) {\n\t\tconst { provider, app, ...pulumiOpts } = opts;\n\n\t\tsuper(\"infracraft:fly:Certificate\", name, {}, pulumiOpts);\n\n\t\tconst resource = new FlyCertificateResource(\n\t\t\t`${name}-resource`,\n\t\t\t{\n\t\t\t\ttoken: provider.token,\n\t\t\t\tappName: app.id,\n\t\t\t\thostname: args.hostname,\n\t\t\t},\n\t\t\t{ parent: this },\n\t\t);\n\n\t\tthis.id = pulumi.output(args.hostname);\n\t\tthis.configured = resource.configured;\n\t\tthis.dnsRequirements = resource.dnsRequirements;\n\n\t\tthis.registerOutputs({\n\t\t\tid: this.id,\n\t\t\tconfigured: this.configured,\n\t\t\tdnsRequirements: this.dnsRequirements,\n\t\t});\n\t}\n}\n"],"mappings":";;;;;;;;;;;;AAqDA,IAAM,iCAAN,MAEA;CACC,MAAM,OACL,QACuC;EACvC,MAAM,SAAS,IAAI,UAAU,OAAO,KAAK;EACzC,MAAM,OAAO,YAAY,OAAO,QAAQ,gBAAgB,mBAAmB,OAAO,QAAQ;EAE1F,IAAI,OAAO,MAAM,OAAO,OAA+B,IAAI;EAE3D,IAAI,MACH,OAAO,IAAI,KAAK,sCAAsC,OAAO,SAAS,EAAE;OAExE,OAAO,MAAM,OAAO,KACnB,YAAY,OAAO,QAAQ,qBAC3B,EAAE,UAAU,OAAO,SAAS,CAC7B;EAGD,MAAM,OAA8B;GACnC,GAA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