@conloca/cloud-astro 0.2.2 → 0.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (241) hide show
  1. package/README.md +378 -207
  2. package/dist/.build-inputs.json +69 -0
  3. package/dist/src/component-manifest.d.ts +5 -3
  4. package/dist/src/component-manifest.d.ts.map +1 -1
  5. package/dist/src/component-manifest.js +7 -7
  6. package/dist/src/component-manifest.js.map +1 -1
  7. package/dist/src/constants.d.ts +14 -13
  8. package/dist/src/constants.d.ts.map +1 -1
  9. package/dist/src/constants.js +14 -13
  10. package/dist/src/constants.js.map +1 -1
  11. package/dist/src/d3-build.d.ts +70 -0
  12. package/dist/src/d3-build.d.ts.map +1 -0
  13. package/dist/src/d3-build.js +272 -0
  14. package/dist/src/d3-build.js.map +1 -0
  15. package/dist/src/descriptors.d.ts +2 -2
  16. package/dist/src/descriptors.d.ts.map +1 -1
  17. package/dist/src/descriptors.js +4 -2
  18. package/dist/src/descriptors.js.map +1 -1
  19. package/dist/src/doctor/checks-address.d.ts +18 -0
  20. package/dist/src/doctor/checks-address.d.ts.map +1 -0
  21. package/dist/src/doctor/checks-address.js +163 -0
  22. package/dist/src/doctor/checks-address.js.map +1 -0
  23. package/dist/src/doctor/checks-live.d.ts +8 -5
  24. package/dist/src/doctor/checks-live.d.ts.map +1 -1
  25. package/dist/src/doctor/checks-live.js +226 -188
  26. package/dist/src/doctor/checks-live.js.map +1 -1
  27. package/dist/src/doctor/checks-offline.d.ts +6 -25
  28. package/dist/src/doctor/checks-offline.d.ts.map +1 -1
  29. package/dist/src/doctor/checks-offline.js +30 -259
  30. package/dist/src/doctor/checks-offline.js.map +1 -1
  31. package/dist/src/doctor/checks-preview-limits.d.ts +11 -0
  32. package/dist/src/doctor/checks-preview-limits.d.ts.map +1 -0
  33. package/dist/src/doctor/checks-preview-limits.js +133 -0
  34. package/dist/src/doctor/checks-preview-limits.js.map +1 -0
  35. package/dist/src/doctor/checks-preview-live.d.ts +14 -0
  36. package/dist/src/doctor/checks-preview-live.d.ts.map +1 -0
  37. package/dist/src/doctor/checks-preview-live.js +72 -0
  38. package/dist/src/doctor/checks-preview-live.js.map +1 -0
  39. package/dist/src/doctor/checks-preview.d.ts +7 -0
  40. package/dist/src/doctor/checks-preview.d.ts.map +1 -0
  41. package/dist/src/doctor/checks-preview.js +287 -0
  42. package/dist/src/doctor/checks-preview.js.map +1 -0
  43. package/dist/src/doctor/config-scan.d.ts +12 -3
  44. package/dist/src/doctor/config-scan.d.ts.map +1 -1
  45. package/dist/src/doctor/config-scan.js +38 -11
  46. package/dist/src/doctor/config-scan.js.map +1 -1
  47. package/dist/src/doctor/run.d.ts.map +1 -1
  48. package/dist/src/doctor/run.js +16 -10
  49. package/dist/src/doctor/run.js.map +1 -1
  50. package/dist/src/doctor/types.d.ts +17 -7
  51. package/dist/src/doctor/types.d.ts.map +1 -1
  52. package/dist/src/doctor/types.js +17 -7
  53. package/dist/src/doctor/types.js.map +1 -1
  54. package/dist/src/editor-page/bundle.d.ts +90 -0
  55. package/dist/src/editor-page/bundle.d.ts.map +1 -0
  56. package/dist/src/editor-page/bundle.js +373 -0
  57. package/dist/src/editor-page/bundle.js.map +1 -0
  58. package/dist/src/editor-page/data-schemas.d.ts +16 -0
  59. package/dist/src/editor-page/data-schemas.d.ts.map +1 -0
  60. package/dist/src/editor-page/data-schemas.js +39 -0
  61. package/dist/src/editor-page/data-schemas.js.map +1 -0
  62. package/dist/src/editor-page/emit.d.ts +69 -0
  63. package/dist/src/editor-page/emit.d.ts.map +1 -0
  64. package/dist/src/editor-page/emit.js +254 -0
  65. package/dist/src/editor-page/emit.js.map +1 -0
  66. package/dist/src/editor-page/framing.d.ts +23 -0
  67. package/dist/src/editor-page/framing.d.ts.map +1 -0
  68. package/dist/src/editor-page/framing.js +39 -0
  69. package/dist/src/editor-page/framing.js.map +1 -0
  70. package/dist/src/editor-page/page.d.ts +9 -0
  71. package/dist/src/editor-page/page.d.ts.map +1 -0
  72. package/dist/src/editor-page/page.js +31 -0
  73. package/dist/src/editor-page/page.js.map +1 -0
  74. package/dist/src/editor-page/site-base.d.ts +4 -0
  75. package/dist/src/editor-page/site-base.d.ts.map +1 -0
  76. package/dist/src/editor-page/site-base.js +13 -0
  77. package/dist/src/editor-page/site-base.js.map +1 -0
  78. package/dist/src/git.d.ts +11 -8
  79. package/dist/src/git.d.ts.map +1 -1
  80. package/dist/src/git.js +25 -8
  81. package/dist/src/git.js.map +1 -1
  82. package/dist/src/index.d.ts +4 -1
  83. package/dist/src/index.d.ts.map +1 -1
  84. package/dist/src/index.js +11 -6
  85. package/dist/src/index.js.map +1 -1
  86. package/dist/src/integration.d.ts +1 -1
  87. package/dist/src/integration.d.ts.map +1 -1
  88. package/dist/src/integration.js +377 -416
  89. package/dist/src/integration.js.map +1 -1
  90. package/dist/src/node.d.ts +3 -1
  91. package/dist/src/node.d.ts.map +1 -1
  92. package/dist/src/node.js +7 -2
  93. package/dist/src/node.js.map +1 -1
  94. package/dist/src/preview/_dispatch.d.ts +12 -0
  95. package/dist/src/preview/_dispatch.d.ts.map +1 -1
  96. package/dist/src/preview/_dispatch.js +31 -0
  97. package/dist/src/preview/_dispatch.js.map +1 -1
  98. package/dist/src/preview/_resolve-opts.d.ts +19 -10
  99. package/dist/src/preview/_resolve-opts.d.ts.map +1 -1
  100. package/dist/src/preview/_resolve-opts.js +24 -11
  101. package/dist/src/preview/_resolve-opts.js.map +1 -1
  102. package/dist/src/preview/banner.d.ts +12 -9
  103. package/dist/src/preview/banner.d.ts.map +1 -1
  104. package/dist/src/preview/banner.js +46 -43
  105. package/dist/src/preview/banner.js.map +1 -1
  106. package/dist/src/preview/cloudflare-adapter.d.ts +35 -0
  107. package/dist/src/preview/cloudflare-adapter.d.ts.map +1 -0
  108. package/dist/src/preview/cloudflare-adapter.js +92 -0
  109. package/dist/src/preview/cloudflare-adapter.js.map +1 -0
  110. package/dist/src/preview/cookie.d.ts +13 -14
  111. package/dist/src/preview/cookie.d.ts.map +1 -1
  112. package/dist/src/preview/cookie.js +19 -26
  113. package/dist/src/preview/cookie.js.map +1 -1
  114. package/dist/src/preview/dispatcher.d.ts +73 -0
  115. package/dist/src/preview/dispatcher.d.ts.map +1 -0
  116. package/dist/src/preview/dispatcher.js +329 -0
  117. package/dist/src/preview/dispatcher.js.map +1 -0
  118. package/dist/src/preview/entry-code.d.ts +33 -0
  119. package/dist/src/preview/entry-code.d.ts.map +1 -0
  120. package/dist/src/preview/entry-code.js +33 -0
  121. package/dist/src/preview/entry-code.js.map +1 -0
  122. package/dist/src/preview/headers.d.ts +24 -4
  123. package/dist/src/preview/headers.d.ts.map +1 -1
  124. package/dist/src/preview/headers.js +35 -7
  125. package/dist/src/preview/headers.js.map +1 -1
  126. package/dist/src/preview/label.d.ts +8 -0
  127. package/dist/src/preview/label.d.ts.map +1 -0
  128. package/dist/src/preview/label.js +14 -0
  129. package/dist/src/preview/label.js.map +1 -0
  130. package/dist/src/preview/landing.d.ts +23 -2
  131. package/dist/src/preview/landing.d.ts.map +1 -1
  132. package/dist/src/preview/landing.js +105 -37
  133. package/dist/src/preview/landing.js.map +1 -1
  134. package/dist/src/preview/middleware.d.ts +49 -22
  135. package/dist/src/preview/middleware.d.ts.map +1 -1
  136. package/dist/src/preview/middleware.js +259 -100
  137. package/dist/src/preview/middleware.js.map +1 -1
  138. package/dist/src/preview/preview-path.d.ts +47 -5
  139. package/dist/src/preview/preview-path.d.ts.map +1 -1
  140. package/dist/src/preview/preview-path.js +65 -8
  141. package/dist/src/preview/preview-path.js.map +1 -1
  142. package/dist/src/preview/redeem-url.d.ts +7 -0
  143. package/dist/src/preview/redeem-url.d.ts.map +1 -0
  144. package/dist/src/preview/redeem-url.js +14 -0
  145. package/dist/src/preview/redeem-url.js.map +1 -0
  146. package/dist/src/preview/site-middleware.d.ts +5 -5
  147. package/dist/src/preview/site-middleware.d.ts.map +1 -1
  148. package/dist/src/preview/site-middleware.js +53 -26
  149. package/dist/src/preview/site-middleware.js.map +1 -1
  150. package/dist/src/preview-build.d.ts +29 -15
  151. package/dist/src/preview-build.d.ts.map +1 -1
  152. package/dist/src/preview-build.js +66 -25
  153. package/dist/src/preview-build.js.map +1 -1
  154. package/dist/src/preview.d.ts +1 -1
  155. package/dist/src/preview.d.ts.map +1 -1
  156. package/dist/src/preview.js +1 -1
  157. package/dist/src/preview.js.map +1 -1
  158. package/dist/src/repository.d.ts +1 -1
  159. package/dist/src/repository.js +1 -1
  160. package/dist/src/resolve-options.d.ts +17 -0
  161. package/dist/src/resolve-options.d.ts.map +1 -0
  162. package/dist/src/resolve-options.js +21 -0
  163. package/dist/src/resolve-options.js.map +1 -0
  164. package/dist/src/site-id.d.ts +0 -2
  165. package/dist/src/site-id.d.ts.map +1 -1
  166. package/dist/src/site-id.js +2 -3
  167. package/dist/src/site-id.js.map +1 -1
  168. package/dist/src/skill.d.ts +11 -0
  169. package/dist/src/skill.d.ts.map +1 -1
  170. package/dist/src/skill.js +32 -9
  171. package/dist/src/skill.js.map +1 -1
  172. package/dist/src/types.d.ts +33 -78
  173. package/dist/src/types.d.ts.map +1 -1
  174. package/package.json +63 -13
  175. package/src/component-manifest.ts +11 -8
  176. package/src/constants.ts +15 -13
  177. package/src/d3-build.ts +315 -0
  178. package/src/descriptors.ts +6 -4
  179. package/src/doctor/checks-address.ts +190 -0
  180. package/src/doctor/checks-live.ts +262 -268
  181. package/src/doctor/checks-offline.ts +32 -279
  182. package/src/doctor/checks-preview-limits.ts +137 -0
  183. package/src/doctor/checks-preview-live.ts +77 -0
  184. package/src/doctor/checks-preview.ts +302 -0
  185. package/src/doctor/config-scan.ts +35 -9
  186. package/src/doctor/run.ts +18 -16
  187. package/src/doctor/types.ts +17 -7
  188. package/src/editor-page/bundle.ts +487 -0
  189. package/src/editor-page/data-schemas.ts +47 -0
  190. package/src/editor-page/emit.ts +362 -0
  191. package/src/editor-page/framing.ts +62 -0
  192. package/src/editor-page/page.ts +37 -0
  193. package/src/editor-page/site-base.ts +11 -0
  194. package/src/git.ts +29 -10
  195. package/src/index.ts +22 -6
  196. package/src/integration.ts +399 -469
  197. package/src/node.ts +18 -2
  198. package/src/preview/_dispatch.ts +36 -1
  199. package/src/preview/_resolve-opts.ts +35 -12
  200. package/src/preview/banner.ts +61 -43
  201. package/src/preview/cloudflare-adapter.ts +103 -0
  202. package/src/preview/cookie.ts +18 -24
  203. package/src/preview/dispatcher.ts +407 -0
  204. package/src/preview/entry-code.ts +51 -0
  205. package/src/preview/headers.ts +35 -7
  206. package/src/preview/label.ts +12 -0
  207. package/src/preview/landing.ts +117 -39
  208. package/src/preview/middleware.ts +302 -115
  209. package/src/preview/preview-path.ts +83 -8
  210. package/src/preview/redeem-url.ts +14 -0
  211. package/src/preview/site-middleware.ts +60 -30
  212. package/src/preview-build.ts +85 -26
  213. package/src/preview-handler.astro +12 -9
  214. package/src/preview.ts +0 -1
  215. package/src/repository.ts +1 -1
  216. package/src/resolve-options.ts +37 -0
  217. package/src/site-id.ts +2 -4
  218. package/src/skill/SKILL.md +63 -55
  219. package/src/skill.ts +36 -8
  220. package/src/types.ts +33 -79
  221. package/src/virtual-modules.d.ts +4 -1
  222. package/dist/src/build-commit.d.ts +0 -19
  223. package/dist/src/build-commit.d.ts.map +0 -1
  224. package/dist/src/build-commit.js +0 -6
  225. package/dist/src/build-commit.js.map +0 -1
  226. package/dist/src/bundle.d.ts +0 -181
  227. package/dist/src/bundle.d.ts.map +0 -1
  228. package/dist/src/bundle.js +0 -413
  229. package/dist/src/bundle.js.map +0 -1
  230. package/dist/src/discovery.d.ts +0 -58
  231. package/dist/src/discovery.d.ts.map +0 -1
  232. package/dist/src/discovery.js +0 -133
  233. package/dist/src/discovery.js.map +0 -1
  234. package/dist/src/register.d.ts +0 -98
  235. package/dist/src/register.d.ts.map +0 -1
  236. package/dist/src/register.js +0 -103
  237. package/dist/src/register.js.map +0 -1
  238. package/src/build-commit.ts +0 -22
  239. package/src/bundle.ts +0 -570
  240. package/src/discovery.ts +0 -183
  241. package/src/register.ts +0 -180
@@ -1,98 +0,0 @@
1
- /**
2
- * Registration request (`POST {endpoint}/api/v1/registrations`). Auth is the
3
- * build token (`cbt_<id>.<secret>`) the endpoint issued; the body carries build
4
- * metadata only.
5
- */
6
- export interface RegistrationInput {
7
- /** Editor endpoint, e.g. 'https://cms.example.com'. */
8
- endpoint: string;
9
- /** Build token sent as `Authorization: Bearer <token>`. */
10
- buildToken: string;
11
- /** Auto-detected `owner/repo` identity of the build checkout. */
12
- repoUri: string;
13
- gitSha: string;
14
- branch: string;
15
- /** Deployable-site id (top-level siteId in the content root's
16
- * sites.json, or the implicit 'default' for a zero-config repo). Resolved at
17
- * build via resolveBuildSiteId — registration attaches, never defines. */
18
- siteId: string;
19
- /** Absolute URL the editor fetches the bundle from. */
20
- editorBundleUrl: string;
21
- /** Full sha-256 hex of the bundle bytes; the editor refuses non-matching bytes. */
22
- bundleHash: string;
23
- /** Absolute URL of the companion canvas stylesheet; absent when the config graph has no styles. */
24
- stylesheetUrl?: string;
25
- /** Full sha-256 hex of the stylesheet bytes; the editor skips non-matching bytes (fail-soft). */
26
- stylesheetHash?: string;
27
- /**
28
- * Discovered content-wrapper shape of the fragmentPreviewRoute — inline
29
- * because it is well under 1 KB; a URL+hash would add a
30
- * fetch and a verification for nothing.
31
- */
32
- hostWrappers?: {
33
- content: {
34
- tagName: string;
35
- className: string;
36
- } | null;
37
- codeBlock: unknown;
38
- };
39
- /** Absolute URL of the discovery route's collected CSS; same artifact pattern as stylesheetUrl. */
40
- routeCssUrl?: string;
41
- /** Full sha-256 hex of the route-CSS bytes; the editor skips non-matching bytes (fail-soft). */
42
- routeCssHash?: string;
43
- /** Absolute URL of the build's component manifest; same artifact pattern as stylesheetUrl. */
44
- componentManifestUrl?: string;
45
- /** Full sha-256 hex of the manifest bytes; a reader refuses non-matching bytes. */
46
- componentManifestHash?: string;
47
- deploymentUrl?: string;
48
- deploymentProvider?: string;
49
- /**
50
- * The commit the artifact was actually built from; differs from gitSha only when CI hands over the branch's
51
- * latest commit.
52
- */
53
- buildId?: string;
54
- /**
55
- * The `@conloca/cloud-astro` version that produced this build, so the endpoint and the doctor can say which
56
- * package version built the editor bundle.
57
- */
58
- clientVersion?: string;
59
- }
60
- export interface RegistrationResult {
61
- /** Per-branch preview secret consumed by the recursive preview build. */
62
- previewSecret: string;
63
- }
64
- /**
65
- * The minimal fetch surface this module relies on. A narrow seam (matching
66
- * `PreviewBuildSpawn` in preview-build.ts) lets tests pass a tiny fake
67
- * without reconstructing the full `fetch` typing.
68
- */
69
- export type RegistrationFetch = (url: string, init: {
70
- method: 'POST';
71
- headers: Record<string, string>;
72
- body: string;
73
- }) => Promise<Response>;
74
- /**
75
- * Backoff before each retry; length + 1 = total attempts. Starts at 1 s,
76
- * doubles to a 30 s ceiling and stops before the waits alone exceed the
77
- * budget: an endpoint that has just been set up can answer 503 for a while,
78
- * and a budget of about a second gives up long before it settles.
79
- */
80
- export declare function _registrationRetryDelays(): number[];
81
- /**
82
- * POSTs the registration to the endpoint and returns the per-branch preview
83
- * secret. Network errors and 5xx responses are retried with exponential
84
- * backoff (1 s doubling to 30 s, ten attempts within a three-minute wait
85
- * budget); 4xx responses throw immediately with the response body so
86
- * the caller can surface the exact rejection reason (e.g. an invalid token).
87
- */
88
- export declare function postRegistration(input: RegistrationInput): Promise<RegistrationResult>;
89
- /**
90
- * Internal seam that takes the fetch function (and retry backoff) as
91
- * parameters so tests can substitute fakes. Public callers should use
92
- * {@link postRegistration}.
93
- *
94
- * Exported with a leading underscore to signal that this is an internal API
95
- * and not part of the package's public surface.
96
- */
97
- export declare function _postRegistrationWith(fetchFn: RegistrationFetch, input: RegistrationInput, retryDelaysMs?: readonly number[]): Promise<RegistrationResult>;
98
- //# sourceMappingURL=register.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"register.d.ts","sourceRoot":"","sources":["../../src/register.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,WAAW,iBAAiB;IAChC,uD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MAAM,CAAC,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,KACpE,OAAO,CAAC,QAAQ,CAAC,CAAC;AAMvB;;;;;GAKG;AACH,wBAAgB,wBAAwB,IAAI,MAAM,EAAE,CAUnD;AAID;;;;;;GAMG;AACH,wBAAsB,gBAAgB,CAAC,KAAK,EAAE,iBAAiB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CAE5F;AAED;;;;;;;GAOG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,iBAAiB,EAC1B,KAAK,EAAE,iBAAiB,EACxB,aAAa,GAAE,SAAS,MAAM,EAA4B,GACzD,OAAO,CAAC,kBAAkB,CAAC,CA6D7B"}
@@ -1,103 +0,0 @@
1
- import { PACKAGE_NAME } from './constants.js';
2
- const INITIAL_RETRY_MS = 1_000;
3
- const MAX_RETRY_MS = 30_000;
4
- const RETRY_BUDGET_MS = 180_000;
5
- /**
6
- * Backoff before each retry; length + 1 = total attempts. Starts at 1 s,
7
- * doubles to a 30 s ceiling and stops before the waits alone exceed the
8
- * budget: an endpoint that has just been set up can answer 503 for a while,
9
- * and a budget of about a second gives up long before it settles.
10
- */
11
- export function _registrationRetryDelays() {
12
- const delays = [];
13
- let next = INITIAL_RETRY_MS;
14
- let total = 0;
15
- while (total + next <= RETRY_BUDGET_MS) {
16
- delays.push(next);
17
- total += next;
18
- next = Math.min(next * 2, MAX_RETRY_MS);
19
- }
20
- return delays;
21
- }
22
- const DEFAULT_RETRY_DELAYS_MS = _registrationRetryDelays();
23
- /**
24
- * POSTs the registration to the endpoint and returns the per-branch preview
25
- * secret. Network errors and 5xx responses are retried with exponential
26
- * backoff (1 s doubling to 30 s, ten attempts within a three-minute wait
27
- * budget); 4xx responses throw immediately with the response body so
28
- * the caller can surface the exact rejection reason (e.g. an invalid token).
29
- */
30
- export async function postRegistration(input) {
31
- return _postRegistrationWith((url, init) => fetch(url, init), input);
32
- }
33
- /**
34
- * Internal seam that takes the fetch function (and retry backoff) as
35
- * parameters so tests can substitute fakes. Public callers should use
36
- * {@link postRegistration}.
37
- *
38
- * Exported with a leading underscore to signal that this is an internal API
39
- * and not part of the package's public surface.
40
- */
41
- export async function _postRegistrationWith(fetchFn, input, retryDelaysMs = DEFAULT_RETRY_DELAYS_MS) {
42
- const url = `${input.endpoint}/api/v1/registrations`;
43
- const init = {
44
- method: 'POST',
45
- headers: {
46
- 'content-type': 'application/json',
47
- authorization: `Bearer ${input.buildToken}`,
48
- },
49
- // JSON.stringify drops undefined optional fields, matching the endpoint's
50
- // "optional means absent" reading of the body.
51
- body: JSON.stringify({
52
- repoUri: input.repoUri,
53
- gitSha: input.gitSha,
54
- branch: input.branch,
55
- siteId: input.siteId,
56
- editorBundleUrl: input.editorBundleUrl,
57
- bundleHash: input.bundleHash,
58
- stylesheetUrl: input.stylesheetUrl,
59
- stylesheetHash: input.stylesheetHash,
60
- hostWrappers: input.hostWrappers,
61
- routeCssUrl: input.routeCssUrl,
62
- routeCssHash: input.routeCssHash,
63
- componentManifestUrl: input.componentManifestUrl,
64
- componentManifestHash: input.componentManifestHash,
65
- deploymentUrl: input.deploymentUrl,
66
- deploymentProvider: input.deploymentProvider,
67
- buildId: input.buildId,
68
- clientVersion: input.clientVersion,
69
- }),
70
- };
71
- const attempts = retryDelaysMs.length + 1;
72
- let lastFailure = '';
73
- for (let attempt = 0; attempt < attempts; attempt++) {
74
- if (attempt > 0 && retryDelaysMs[attempt - 1] > 0) {
75
- await new Promise((resolve) => setTimeout(resolve, retryDelaysMs[attempt - 1]));
76
- }
77
- let response;
78
- try {
79
- response = await fetchFn(url, init);
80
- }
81
- catch (error) {
82
- // Network-level failure (endpoint unreachable, DNS, reset) — retry.
83
- lastFailure = error instanceof Error ? error.message : String(error);
84
- continue;
85
- }
86
- if (response.ok) {
87
- const payload = (await response.json().catch(() => null));
88
- if (typeof payload?.previewSecret !== 'string' || payload.previewSecret === '') {
89
- throw new Error(`${PACKAGE_NAME}: registration response is missing previewSecret`);
90
- }
91
- return { previewSecret: payload.previewSecret };
92
- }
93
- const text = await response.text().catch(() => '');
94
- if (response.status < 500) {
95
- // 4xx is deterministic (bad token, repo not covered, malformed body) —
96
- // retrying cannot help, and the body carries the exact reason.
97
- throw new Error(`${PACKAGE_NAME}: registration rejected: HTTP ${response.status} ${text}`);
98
- }
99
- lastFailure = `HTTP ${response.status} ${text}`;
100
- }
101
- throw new Error(`${PACKAGE_NAME}: registration failed after ${attempts} attempts: ${lastFailure}`);
102
- }
103
- //# sourceMappingURL=register.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"register.js","sourceRoot":"","sources":["../../src/register.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAuE9C,MAAM,gBAAgB,GAAG,KAAK,CAAC;AAC/B,MAAM,YAAY,GAAG,MAAM,CAAC;AAC5B,MAAM,eAAe,GAAG,OAAO,CAAC;AAEhC;;;;;GAKG;AACH,MAAM,UAAU,wBAAwB;IACtC,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,IAAI,IAAI,GAAG,gBAAgB,CAAC;IAC5B,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,OAAO,KAAK,GAAG,IAAI,IAAI,eAAe,EAAE,CAAC;QACvC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAClB,KAAK,IAAI,IAAI,CAAC;QACd,IAAI,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,EAAE,YAAY,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,uBAAuB,GAAsB,wBAAwB,EAAE,CAAC;AAE9E;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CAAC,KAAwB;IAC7D,OAAO,qBAAqB,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,KAAK,CAAC,CAAC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Q,CAAC,MAAM,IAAI,IAAI,EAAE,CAAC,CAAC;QAC7F,CAAC;QACD,WAAW,GAAG,QAAQ,QAAQ,CAAC,MAAM,IAAI,IAAI,EAAE,CAAC;IAClD,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,GAAG,YAAY,+BAA+B,QAAQ,cAAc,WAAW,EAAE,CAAC,CAAC;AACrG,CAAC"}
@@ -1,22 +0,0 @@
1
- /**
2
- * The commit a registration names and the commit the artifact was built from.
3
- * They differ only when CI hands over the branch's latest commit
4
- * (`CF_PAGES_COMMIT_SHA`) while building another commit — a pull request's
5
- * merge commit — because the endpoint can only serve a commit the branch
6
- * actually carries.
7
- */
8
- export interface RegistrationCommits {
9
- gitSha: string | undefined;
10
- buildId: string | undefined;
11
- }
12
-
13
- /** Resolves which commit the registration names and which commit produced the bundle. */
14
- export function registrationCommits(input: {
15
- /** The branch's latest commit, as CI hands it over through CF_PAGES_COMMIT_SHA. */
16
- eventCommitSha: string | undefined;
17
- /** git rev-parse HEAD in the build checkout. */
18
- checkoutCommitSha: string | undefined;
19
- }): RegistrationCommits {
20
- const gitSha = input.eventCommitSha ?? input.checkoutCommitSha;
21
- return { gitSha, buildId: input.checkoutCommitSha ?? gitSha };
22
- }