anhedral 0.13.0 → 0.16.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 (360) hide show
  1. package/README.md +23 -229
  2. package/assets/patches/audit-deps.mjs +12 -2
  3. package/assets/stack/ai-schema.ts.txt +5 -0
  4. package/assets/stack/ai.ts.txt +30 -0
  5. package/assets/stack/api-index.ts.txt +15 -0
  6. package/assets/stack/auth-features.ts.txt +4 -0
  7. package/assets/stack/auth-journal.json.txt +13 -0
  8. package/assets/stack/auth-migration.sql.txt +53 -0
  9. package/assets/stack/auth-routes.ts.txt +11 -0
  10. package/assets/stack/auth-schema.ts.txt +64 -0
  11. package/assets/stack/auth-snapshot.json.txt +346 -0
  12. package/assets/stack/auth.ts.txt +32 -0
  13. package/assets/stack/billing-mode.ts.txt +8 -0
  14. package/assets/stack/billing-schema.ts.txt +11 -0
  15. package/assets/stack/desktop.rs.txt +21 -0
  16. package/assets/stack/entitlement-guard.ts.txt +32 -0
  17. package/assets/stack/entitlements.ts.txt +8 -0
  18. package/assets/stack/events-schema.ts.txt +12 -0
  19. package/assets/stack/events.ts.txt +59 -0
  20. package/assets/stack/mobile-auth.ts.txt +25 -0
  21. package/assets/stack/mobile-billing.tsx.txt +63 -0
  22. package/assets/stack/mobile-session.tsx.txt +83 -0
  23. package/assets/stack/native-button.tsx.txt +108 -0
  24. package/assets/stack/native-global.css.txt +4 -0
  25. package/assets/stack/native-lib-utils.ts.txt +5 -0
  26. package/assets/stack/native-metro.config.js.txt +6 -0
  27. package/assets/stack/native-nativewind-env.d.ts.txt +1 -0
  28. package/assets/stack/native-tailwind.config.js.txt +73 -0
  29. package/assets/stack/native-text.tsx.txt +89 -0
  30. package/assets/stack/purchases.ts.txt +65 -0
  31. package/assets/stack/revenuecat.ts.txt +88 -0
  32. package/assets/stack/rtc-schema.ts.txt +10 -0
  33. package/assets/stack/rtc.ts.txt +122 -0
  34. package/assets/stack/security.ts.txt +31 -0
  35. package/assets/stack/storage.ts.txt +36 -0
  36. package/assets/stack/stripe.ts.txt +126 -0
  37. package/assets/stack/web-sign-in.tsx.txt +51 -0
  38. package/assets/ui/LICENSE.react-native-reusables +21 -0
  39. package/assets/ui/LICENSE.shadcn +21 -0
  40. package/assets/ui/UPSTREAM.json +39 -0
  41. package/assets/ui/catalog.json +891 -0
  42. package/assets/ui/extensions/registry.json +6 -0
  43. package/assets/ui/native/_controls.tsx +521 -0
  44. package/assets/ui/native/_core.tsx +118 -0
  45. package/assets/ui/native/_data.tsx +200 -0
  46. package/assets/ui/native/_display.tsx +453 -0
  47. package/assets/ui/native/_feedback.tsx +242 -0
  48. package/assets/ui/native/_legacy-dialog.tsx +38 -0
  49. package/assets/ui/native/_motion.tsx +520 -0
  50. package/assets/ui/native/_overlay.tsx +402 -0
  51. package/assets/ui/native/_selection.tsx +366 -0
  52. package/assets/ui/native/accordion.tsx +1 -0
  53. package/assets/ui/native/alert-dialog.tsx +11 -0
  54. package/assets/ui/native/alert.tsx +1 -0
  55. package/assets/ui/native/aspect-ratio.tsx +1 -0
  56. package/assets/ui/native/attachment.tsx +8 -0
  57. package/assets/ui/native/avatar.tsx +8 -0
  58. package/assets/ui/native/badge.tsx +1 -0
  59. package/assets/ui/native/breadcrumb.tsx +9 -0
  60. package/assets/ui/native/bubble.tsx +1 -0
  61. package/assets/ui/native/button-group.tsx +1 -0
  62. package/assets/ui/native/button.tsx +86 -0
  63. package/assets/ui/native/calendar.tsx +170 -0
  64. package/assets/ui/native/card.tsx +44 -0
  65. package/assets/ui/native/carousel.tsx +1 -0
  66. package/assets/ui/native/chart.tsx +193 -0
  67. package/assets/ui/native/checkbox.tsx +1 -0
  68. package/assets/ui/native/code-block.tsx +137 -0
  69. package/assets/ui/native/collapsible.tsx +1 -0
  70. package/assets/ui/native/combobox.tsx +1 -0
  71. package/assets/ui/native/command.tsx +11 -0
  72. package/assets/ui/native/context-menu.tsx +16 -0
  73. package/assets/ui/native/data-table.tsx +1 -0
  74. package/assets/ui/native/date-picker.tsx +43 -0
  75. package/assets/ui/native/dialog.tsx +15 -0
  76. package/assets/ui/native/direction.tsx +1 -0
  77. package/assets/ui/native/drawer.tsx +10 -0
  78. package/assets/ui/native/dropdown-menu.tsx +16 -0
  79. package/assets/ui/native/empty.tsx +8 -0
  80. package/assets/ui/native/field.tsx +13 -0
  81. package/assets/ui/native/hover-card.tsx +1 -0
  82. package/assets/ui/native/input-group.tsx +8 -0
  83. package/assets/ui/native/input-otp.tsx +1 -0
  84. package/assets/ui/native/input.tsx +28 -0
  85. package/assets/ui/native/item.tsx +12 -0
  86. package/assets/ui/native/kbd.tsx +1 -0
  87. package/assets/ui/native/label.tsx +4 -0
  88. package/assets/ui/native/layout.tsx +26 -0
  89. package/assets/ui/native/marker.tsx +1 -0
  90. package/assets/ui/native/menubar.tsx +17 -0
  91. package/assets/ui/native/message-scroller.tsx +6 -0
  92. package/assets/ui/native/message.tsx +10 -0
  93. package/assets/ui/native/native-select.tsx +1 -0
  94. package/assets/ui/native/navigation-menu.tsx +10 -0
  95. package/assets/ui/native/pagination.tsx +9 -0
  96. package/assets/ui/native/popover.tsx +1 -0
  97. package/assets/ui/native/progress.tsx +1 -0
  98. package/assets/ui/native/questionnaire.tsx +130 -0
  99. package/assets/ui/native/radio-group.tsx +1 -0
  100. package/assets/ui/native/registry.json +1103 -0
  101. package/assets/ui/native/resizable.tsx +1 -0
  102. package/assets/ui/native/scroll-area.tsx +1 -0
  103. package/assets/ui/native/select.tsx +11 -0
  104. package/assets/ui/native/separator.tsx +1 -0
  105. package/assets/ui/native/sheet.tsx +10 -0
  106. package/assets/ui/native/sidebar.tsx +22 -0
  107. package/assets/ui/native/skeleton.tsx +1 -0
  108. package/assets/ui/native/slider.tsx +1 -0
  109. package/assets/ui/native/spinner.tsx +1 -0
  110. package/assets/ui/native/switch.tsx +1 -0
  111. package/assets/ui/native/table.tsx +10 -0
  112. package/assets/ui/native/tabs.tsx +1 -0
  113. package/assets/ui/native/text.tsx +20 -0
  114. package/assets/ui/native/textarea.tsx +1 -0
  115. package/assets/ui/native/theme-switcher.tsx +22 -0
  116. package/assets/ui/native/toast.tsx +11 -0
  117. package/assets/ui/native/toggle-group.tsx +1 -0
  118. package/assets/ui/native/toggle.tsx +1 -0
  119. package/assets/ui/native/tooltip.tsx +1 -0
  120. package/assets/ui/native/trace.tsx +20 -0
  121. package/assets/ui/native/typography.tsx +15 -0
  122. package/assets/ui/theme-storage.ts +25 -0
  123. package/assets/ui/theme.tsx +66 -0
  124. package/assets/ui/web/button.tsx +59 -0
  125. package/assets/ui/web/input.tsx +21 -0
  126. package/assets/ui/web/label.tsx +19 -0
  127. package/dist/bin.js +7 -12
  128. package/dist/capabilities.d.ts +4 -33
  129. package/dist/capabilities.js +2 -84
  130. package/dist/capability-catalog.d.ts +83 -0
  131. package/dist/capability-catalog.js +121 -0
  132. package/dist/capability-command.d.ts +3 -0
  133. package/dist/capability-command.js +188 -0
  134. package/dist/capability-editor.d.ts +17 -0
  135. package/dist/capability-editor.js +97 -0
  136. package/dist/capability-recipes.d.ts +4 -0
  137. package/dist/capability-recipes.js +520 -0
  138. package/dist/capability-references.d.ts +4 -0
  139. package/dist/capability-references.js +7 -0
  140. package/dist/cli-commands.d.ts +1 -2
  141. package/dist/cli-commands.js +10 -104
  142. package/dist/cli-output.d.ts +1 -2
  143. package/dist/cli-output.js +6 -251
  144. package/dist/command-schema.js +40 -374
  145. package/dist/dependencies.d.ts +34 -62
  146. package/dist/dependencies.js +112 -199
  147. package/dist/index.d.ts +1 -45
  148. package/dist/index.js +1 -30
  149. package/dist/platforms/mobile.js +29 -139
  150. package/dist/platforms/web.d.ts +3 -0
  151. package/dist/platforms/web.js +251 -0
  152. package/dist/project-config.d.ts +2 -13
  153. package/dist/project-config.js +10 -83
  154. package/dist/registry/context.js +0 -1
  155. package/dist/registry/options.js +6 -40
  156. package/dist/registry/resolve.d.ts +3 -4
  157. package/dist/registry/resolve.js +18 -108
  158. package/dist/registry/types.d.ts +1 -7
  159. package/dist/registry/usage.js +3 -9
  160. package/dist/runtime-policy.d.ts +0 -2
  161. package/dist/runtime-policy.js +0 -16
  162. package/dist/scaffold/backend.d.ts +0 -4
  163. package/dist/scaffold/backend.js +1 -189
  164. package/dist/scaffold/bootstrap.d.ts +2 -3
  165. package/dist/scaffold/bootstrap.js +37 -43
  166. package/dist/scaffold/compose.js +2 -14
  167. package/dist/scaffold/database.d.ts +1 -1
  168. package/dist/scaffold/database.js +19 -126
  169. package/dist/scaffold/documentation.d.ts +0 -1
  170. package/dist/scaffold/documentation.js +82 -84
  171. package/dist/scaffold/expo-runtime.d.ts +2 -2
  172. package/dist/scaffold/expo-runtime.js +9 -101
  173. package/dist/scaffold/native-ui.d.ts +2 -0
  174. package/dist/scaffold/native-ui.js +74 -0
  175. package/dist/scaffold/stack-documentation.d.ts +0 -1
  176. package/dist/scaffold/stack-documentation.js +3 -49
  177. package/dist/scaffold/storage.d.ts +2 -0
  178. package/dist/scaffold/storage.js +21 -0
  179. package/dist/scaffold/styling.d.ts +1 -1
  180. package/dist/scaffold/styling.js +20 -28
  181. package/dist/scaffold/workspace.js +63 -199
  182. package/dist/stack-registry.d.ts +2 -58
  183. package/dist/stack-registry.js +22 -446
  184. package/dist/standard.js +7 -24
  185. package/dist/ui-catalog.d.ts +26 -0
  186. package/dist/ui-catalog.js +31 -0
  187. package/dist/ui-command.d.ts +3 -0
  188. package/dist/ui-command.js +219 -0
  189. package/dist/ui-project.d.ts +22 -0
  190. package/dist/ui-project.js +110 -0
  191. package/dist/version.d.ts +1 -1
  192. package/dist/version.js +1 -1
  193. package/docs/anhedral-stack.md +4 -119
  194. package/docs/capabilities.md +110 -0
  195. package/docs/native-ui.md +102 -0
  196. package/docs/software-factory.md +16 -577
  197. package/docs/stack-standard.md +11 -307
  198. package/docs/ui.md +33 -0
  199. package/docs/verification.md +511 -0
  200. package/package.json +26 -27
  201. package/dist/access.d.ts +0 -10
  202. package/dist/access.js +0 -93
  203. package/dist/auth-schema-snapshot.d.ts +0 -346
  204. package/dist/auth-schema-snapshot.js +0 -347
  205. package/dist/auth-schema.d.ts +0 -1
  206. package/dist/auth-schema.js +0 -57
  207. package/dist/capability-contract.d.ts +0 -47
  208. package/dist/capability-contract.js +0 -168
  209. package/dist/catalog-model.d.ts +0 -24
  210. package/dist/catalog-model.js +0 -1
  211. package/dist/catalog-registration.d.ts +0 -16
  212. package/dist/catalog-registration.js +0 -22
  213. package/dist/catalog-snapshot.d.ts +0 -5
  214. package/dist/catalog-snapshot.js +0 -97
  215. package/dist/cli-delivery.d.ts +0 -3
  216. package/dist/cli-delivery.js +0 -172
  217. package/dist/cloudflare.d.ts +0 -25
  218. package/dist/cloudflare.js +0 -226
  219. package/dist/delivery-evidence.d.ts +0 -62
  220. package/dist/delivery-evidence.js +0 -186
  221. package/dist/delivery.d.ts +0 -88
  222. package/dist/delivery.js +0 -570
  223. package/dist/inspector-model.d.ts +0 -123
  224. package/dist/inspector-model.js +0 -1
  225. package/dist/integration-service-readers.d.ts +0 -13
  226. package/dist/integration-service-readers.js +0 -173
  227. package/dist/lifecycle-model.d.ts +0 -15
  228. package/dist/lifecycle-model.js +0 -20
  229. package/dist/lifecycle.d.ts +0 -11
  230. package/dist/lifecycle.js +0 -91
  231. package/dist/management.d.ts +0 -3
  232. package/dist/management.js +0 -47
  233. package/dist/mobile-delivery.d.ts +0 -77
  234. package/dist/mobile-delivery.js +0 -366
  235. package/dist/neon-service-data.d.ts +0 -8
  236. package/dist/neon-service-data.js +0 -117
  237. package/dist/platforms/desktop.d.ts +0 -2
  238. package/dist/platforms/desktop.js +0 -415
  239. package/dist/platforms/extension.d.ts +0 -2
  240. package/dist/platforms/extension.js +0 -328
  241. package/dist/project-catalog.d.ts +0 -41
  242. package/dist/project-catalog.js +0 -288
  243. package/dist/project-inspector.d.ts +0 -4
  244. package/dist/project-inspector.js +0 -702
  245. package/dist/project-lifecycle.d.ts +0 -25
  246. package/dist/project-lifecycle.js +0 -57
  247. package/dist/project-state.d.ts +0 -49
  248. package/dist/project-state.js +0 -563
  249. package/dist/provider-auth.d.ts +0 -41
  250. package/dist/provider-auth.js +0 -215
  251. package/dist/provider-readiness.d.ts +0 -30
  252. package/dist/provider-readiness.js +0 -104
  253. package/dist/providers/adapters.d.ts +0 -17
  254. package/dist/providers/adapters.js +0 -278
  255. package/dist/providers/api.d.ts +0 -29
  256. package/dist/providers/api.js +0 -253
  257. package/dist/providers/config.d.ts +0 -15
  258. package/dist/providers/config.js +0 -182
  259. package/dist/providers/definitions.d.ts +0 -318
  260. package/dist/providers/definitions.js +0 -127
  261. package/dist/providers/provision.d.ts +0 -24
  262. package/dist/providers/provision.js +0 -76
  263. package/dist/providers/receipts.d.ts +0 -20
  264. package/dist/providers/receipts.js +0 -66
  265. package/dist/providers/recovery-verification.d.ts +0 -7
  266. package/dist/providers/recovery-verification.js +0 -112
  267. package/dist/providers/recovery.d.ts +0 -30
  268. package/dist/providers/recovery.js +0 -34
  269. package/dist/providers/runtime.d.ts +0 -10
  270. package/dist/providers/runtime.js +0 -265
  271. package/dist/providers/schema.d.ts +0 -28
  272. package/dist/providers/schema.js +0 -49
  273. package/dist/providers/state.d.ts +0 -55
  274. package/dist/providers/state.js +0 -289
  275. package/dist/provision.d.ts +0 -55
  276. package/dist/provision.js +0 -284
  277. package/dist/r2-service-data.d.ts +0 -2
  278. package/dist/r2-service-data.js +0 -136
  279. package/dist/readiness.d.ts +0 -23
  280. package/dist/readiness.js +0 -122
  281. package/dist/registry/add.d.ts +0 -24
  282. package/dist/registry/add.js +0 -270
  283. package/dist/registry/bootstrap.d.ts +0 -2
  284. package/dist/registry/bootstrap.js +0 -14
  285. package/dist/registry/commands.d.ts +0 -3
  286. package/dist/registry/commands.js +0 -85
  287. package/dist/registry/presets.d.ts +0 -4
  288. package/dist/registry/presets.js +0 -41
  289. package/dist/registry/preview.d.ts +0 -11
  290. package/dist/registry/preview.js +0 -91
  291. package/dist/registry/receipt.d.ts +0 -3
  292. package/dist/registry/receipt.js +0 -68
  293. package/dist/repository.d.ts +0 -24
  294. package/dist/repository.js +0 -96
  295. package/dist/scaffold/auth.d.ts +0 -3
  296. package/dist/scaffold/auth.js +0 -151
  297. package/dist/scaffold/billing-config.d.ts +0 -1
  298. package/dist/scaffold/billing-config.js +0 -73
  299. package/dist/scaffold/billing-contracts.d.ts +0 -2
  300. package/dist/scaffold/billing-contracts.js +0 -48
  301. package/dist/scaffold/billing-providers.d.ts +0 -1
  302. package/dist/scaffold/billing-providers.js +0 -249
  303. package/dist/scaffold/billing-schema.d.ts +0 -1
  304. package/dist/scaffold/billing-schema.js +0 -34
  305. package/dist/scaffold/billing-security.d.ts +0 -1
  306. package/dist/scaffold/billing-security.js +0 -46
  307. package/dist/scaffold/billing-server.d.ts +0 -1
  308. package/dist/scaffold/billing-server.js +0 -139
  309. package/dist/scaffold/billing-store.d.ts +0 -1
  310. package/dist/scaffold/billing-store.js +0 -72
  311. package/dist/scaffold/billing.d.ts +0 -2
  312. package/dist/scaffold/billing.js +0 -216
  313. package/dist/scaffold/cloudflare-services.d.ts +0 -8
  314. package/dist/scaffold/cloudflare-services.js +0 -198
  315. package/dist/scaffold/expo-auth.d.ts +0 -3
  316. package/dist/scaffold/expo-auth.js +0 -192
  317. package/dist/scaffold/expo-billing.d.ts +0 -3
  318. package/dist/scaffold/expo-billing.js +0 -292
  319. package/dist/scaffold/integrations.d.ts +0 -4
  320. package/dist/scaffold/integrations.js +0 -12
  321. package/dist/scaffold/lint.d.ts +0 -4
  322. package/dist/scaffold/lint.js +0 -56
  323. package/dist/scaffold/neon-realtime.d.ts +0 -2
  324. package/dist/scaffold/neon-realtime.js +0 -97
  325. package/dist/scaffold/services.d.ts +0 -5
  326. package/dist/scaffold/services.js +0 -108
  327. package/dist/scaffold/stream.d.ts +0 -2
  328. package/dist/scaffold/stream.js +0 -114
  329. package/dist/scaffold/void.d.ts +0 -4
  330. package/dist/scaffold/void.js +0 -264
  331. package/dist/scaffold/web.d.ts +0 -2
  332. package/dist/scaffold/web.js +0 -130
  333. package/dist/service-deletion.d.ts +0 -29
  334. package/dist/service-deletion.js +0 -195
  335. package/dist/service-descriptor.d.ts +0 -10
  336. package/dist/service-descriptor.js +0 -78
  337. package/dist/service-model.d.ts +0 -49
  338. package/dist/service-model.js +0 -8
  339. package/dist/service-operations.d.ts +0 -29
  340. package/dist/service-operations.js +0 -78
  341. package/dist/service-readers.d.ts +0 -8
  342. package/dist/service-readers.js +0 -247
  343. package/dist/services-command.d.ts +0 -39
  344. package/dist/services-command.js +0 -102
  345. package/dist/ship.d.ts +0 -348
  346. package/dist/ship.js +0 -239
  347. package/dist/vercel-project.d.ts +0 -101
  348. package/dist/vercel-project.js +0 -305
  349. package/dist/vercel.d.ts +0 -67
  350. package/dist/vercel.js +0 -581
  351. package/dist/vinext.d.ts +0 -2
  352. package/dist/vinext.js +0 -86
  353. package/dist/void-execution.d.ts +0 -10
  354. package/dist/void-execution.js +0 -94
  355. package/dist/void-migrations.d.ts +0 -6
  356. package/dist/void-migrations.js +0 -110
  357. package/dist/void-state.d.ts +0 -16
  358. package/dist/void-state.js +0 -65
  359. package/dist/void.d.ts +0 -3
  360. package/dist/void.js +0 -5
@@ -1,22 +0,0 @@
1
- import { homedir } from 'node:os';
2
- import path from 'node:path';
3
- import { ProjectStore } from './project-catalog.js';
4
- export function catalogDirectory(env = process.env) {
5
- return (env.ANHEDRAL_PLUGIN_DATA ?? path.join(homedir(), '.local', 'share', 'anhedral', 'projects'));
6
- }
7
- /** Every successful CLI init records a local app unless explicitly disabled.
8
- * Registration failure never undoes generated source. */
9
- export function registerGeneratedProject(root, env = process.env) {
10
- const directory = catalogDirectory(env);
11
- if (env.ANHEDRAL_DISABLE_CATALOG === '1')
12
- return { state: 'not-enabled' };
13
- try {
14
- return { state: 'registered', id: new ProjectStore(directory).register(root) };
15
- }
16
- catch {
17
- return {
18
- state: 'pending',
19
- nextAction: 'Project generated. Catalog registration could not complete; refresh or register the source after restoring catalog access.',
20
- };
21
- }
22
- }
@@ -1,5 +0,0 @@
1
- import type { ProjectSummary } from './catalog-model.js';
2
- import type { ProjectEntry } from './project-catalog.js';
3
- /** List views read bounded package and project configuration; detailed evidence is opt-in by ID. */
4
- export declare function projectSnapshot(entry: ProjectEntry, detail?: boolean): ProjectSummary;
5
- export declare function readCatalogSourceIdentity(root: string): string | undefined;
@@ -1,97 +0,0 @@
1
- import { lstatSync, realpathSync } from 'node:fs';
2
- import path from 'node:path';
3
- import { readBoundedFile } from './bounded-file.js';
4
- import { readProjectConfig, projectConfigPath } from './project-config.js';
5
- import { inspectApplication } from './project-inspector.js';
6
- import { STANDARD_PRODUCTS } from './stack-registry.js';
7
- import { z } from 'zod';
8
- /** List views read bounded package and project configuration; detailed evidence is opt-in by ID. */
9
- export function projectSnapshot(entry, detail = false) {
10
- const summary = {
11
- id: entry.id,
12
- name: entry.name,
13
- sourceName: '',
14
- updatedAt: entry.updatedAt,
15
- products: [],
16
- status: 'source',
17
- };
18
- try {
19
- if (realpathSync(entry.root) !== entry.root)
20
- throw new Error();
21
- const configuration = catalogConfiguration(entry.root);
22
- if (entry.sourceIdentity !== sourceIdentity(configuration))
23
- return {
24
- ...summary,
25
- status: 'unavailable',
26
- message: 'This directory contains a different app. Select its new catalog entry or restore the registered source.',
27
- };
28
- if (realpathSync(entry.root) !== entry.root)
29
- throw new Error();
30
- const read = (relative) => {
31
- const file = path.join(entry.root, relative);
32
- if (!realpathSync(file).startsWith(entry.root + path.sep))
33
- throw new Error();
34
- return JSON.parse(readBoundedFile(file, 256 * 1024).toString('utf8'));
35
- };
36
- const manifest = read('package.json');
37
- if (typeof manifest.name !== 'string' ||
38
- !/^(@[a-z0-9._-]+\/)?[a-z0-9._-]+$/i.test(manifest.name) ||
39
- manifest.name.length > 214)
40
- throw new Error();
41
- summary.sourceName = manifest.name;
42
- const rawSetup = configuration?.setup;
43
- if (rawSetup !== undefined) {
44
- if (!rawSetup || typeof rawSetup !== 'object' || Array.isArray(rawSetup))
45
- throw new Error();
46
- if (Buffer.byteLength(JSON.stringify(rawSetup)) > 256 * 1024)
47
- throw new Error();
48
- const setup = rawSetup;
49
- summary.products = Array.isArray(setup.products)
50
- ? setup.products
51
- .filter((p) => typeof p === 'string' &&
52
- STANDARD_PRODUCTS.includes(p))
53
- .slice(0, 100)
54
- : [];
55
- }
56
- }
57
- catch {
58
- summary.status = 'unavailable';
59
- summary.message =
60
- 'Source summary is unavailable. Restore or inspect the registered source, then refresh.';
61
- }
62
- if (detail) {
63
- try {
64
- if (realpathSync(entry.root) !== entry.root)
65
- throw new Error();
66
- summary.inspection = inspectApplication(entry.root);
67
- summary.status =
68
- summary.status !== 'unavailable' &&
69
- summary.inspection.targets.data.some((target) => target.latestAttempt || target.lastSuccessful)
70
- ? 'recorded'
71
- : summary.status;
72
- }
73
- catch {
74
- summary.status = 'unavailable';
75
- summary.message = 'Registered source is unavailable. Restore the directory, then refresh.';
76
- }
77
- }
78
- return summary;
79
- }
80
- function catalogConfiguration(root) {
81
- return lstatSync(projectConfigPath(root), { throwIfNoEntry: false })
82
- ? readProjectConfig(root)
83
- : null;
84
- }
85
- function sourceIdentity(configuration) {
86
- if (configuration?.identity === undefined)
87
- return undefined;
88
- if (Buffer.byteLength(JSON.stringify(configuration.identity)) > 4096)
89
- throw new Error('Project identity exceeds its size limit.');
90
- return z
91
- .object({ schemaVersion: z.literal(1), id: z.string().uuid() })
92
- .strict()
93
- .parse(configuration.identity).id;
94
- }
95
- export function readCatalogSourceIdentity(root) {
96
- return sourceIdentity(catalogConfiguration(root));
97
- }
@@ -1,3 +0,0 @@
1
- import { type OutputOptions } from './cli-output.js';
2
- export declare const DELIVERY_COMMANDS: readonly ["register", "connect", "provision", "ship", "status", "manage", "verify", "rollback", "adopt", "recover"];
3
- export declare function runDelivery(command: string, args: string[], output: OutputOptions): Promise<void>;
@@ -1,172 +0,0 @@
1
- import path from 'node:path';
2
- import { commandArguments, commandArgumentError } from './cli-arguments.js';
3
- import { printResult } from './cli-output.js';
4
- import { hasProjectSection, readProjectSection } from './project-config.js';
5
- import { recoverDeliveryLock } from './project-state.js';
6
- import { readLifecycleOperation } from './lifecycle.js';
7
- import { buildMobileApplication } from './mobile-delivery.js';
8
- import { shipCloudflareApplication, shipSelectedVercelApplication, shipSelectedStack, } from './ship.js';
9
- import { planProvisioning, provisionApplication } from './provision.js';
10
- import { writeManagementOverview } from './management.js';
11
- import { registerApplication, connectApplication, applicationStatus, verifyApplication, rollbackApplication, recoverApplication, } from './delivery.js';
12
- import { registerVercelApplication, connectVercelApplication, vercelApplicationStatus, verifyVercelApplication, rollbackVercelApplication, adoptVercelApplication, recoverVercelApplication, writeVercelOverview, } from './vercel.js';
13
- export const DELIVERY_COMMANDS = [
14
- 'register',
15
- 'connect',
16
- 'provision',
17
- 'ship',
18
- 'status',
19
- 'manage',
20
- 'verify',
21
- 'rollback',
22
- 'adopt',
23
- 'recover',
24
- ];
25
- function deliveryOptions(command, args) {
26
- const options = commandArguments(command, args);
27
- const error = (message) => commandArgumentError(command, message);
28
- if (options.positional.length > 1)
29
- throw error('Specify at most one application directory.');
30
- function choice(flag, choices, message) {
31
- const value = options.value(flag);
32
- if (value === undefined)
33
- return undefined;
34
- if (!choices.includes(value))
35
- throw error(message);
36
- return value;
37
- }
38
- return {
39
- root: path.resolve(options.positional[0] ?? process.cwd()),
40
- account: options.value('--account'),
41
- audience: choice('--audience', ['public', 'private'], 'Specify --audience public or private.'),
42
- emails: options.values('--allow-email'),
43
- provider: choice('--provider', ['vercel', 'cloudflare'], 'Specify one provider: vercel or cloudflare.'),
44
- scope: options.value('--scope'),
45
- use: choice('--use', ['personal', 'commercial'], 'Specify --use personal or commercial.'),
46
- create: options.has('--create'),
47
- git: options.has('--git'),
48
- platform: choice('--platform', ['ios', 'android'], 'Select one mobile platform.'),
49
- profile: options.value('--profile'),
50
- releaseId: options.value('--release'),
51
- dryRun: options.has('--dry-run'),
52
- refresh: options.has('--refresh'),
53
- local: options.has('--local'),
54
- lock: options.has('--lock'),
55
- dataCompatible: options.has('--data-compatible'),
56
- };
57
- }
58
- function isVercel(command, { root, provider }) {
59
- if (provider)
60
- return provider === 'vercel';
61
- if (hasProjectSection(root, 'vercel'))
62
- return true;
63
- return (command === 'register' &&
64
- hasProjectSection(root, 'setup') &&
65
- readProjectSection(root, 'setup').hosting === 'vercel');
66
- }
67
- function releaseId(command, options) {
68
- if (!options.releaseId)
69
- throw commandArgumentError(command, 'Rollback requires --release <recorded-id>.');
70
- return options.releaseId;
71
- }
72
- async function vercelCommand(command, options) {
73
- const { root, account, emails, audience, use, scope, create, git, dryRun, refresh, local } = options;
74
- if (account || emails.length)
75
- throw commandArgumentError(command, 'Cloudflare account/member flags require --provider cloudflare.');
76
- switch (command) {
77
- case 'register':
78
- return registerVercelApplication(root);
79
- case 'connect':
80
- if (!audience || !use)
81
- throw commandArgumentError(command, 'Vercel connect requires --audience public|private and --use personal|commercial.');
82
- return connectVercelApplication(root, { scope, audience, use, create, git });
83
- case 'ship':
84
- return shipSelectedVercelApplication(root, dryRun);
85
- case 'adopt':
86
- return adoptVercelApplication(root);
87
- case 'recover':
88
- return recoverVercelApplication(root);
89
- case 'verify':
90
- return verifyVercelApplication(root);
91
- case 'rollback':
92
- return rollbackVercelApplication(root, releaseId(command, options), options.dataCompatible);
93
- case 'status':
94
- return vercelApplicationStatus(root, refresh);
95
- case 'manage': {
96
- const snapshot = await vercelApplicationStatus(root, !local);
97
- return { file: writeVercelOverview(root, snapshot), evidence: snapshot.evidence };
98
- }
99
- default:
100
- throw commandArgumentError(command, 'Vercel project creation is handled by connect --create; Cloudflare resource provisioning requires --provider cloudflare.');
101
- }
102
- }
103
- async function cloudflareCommand(command, options) {
104
- const { root, account, audience, emails, scope, use, create, git, dryRun, refresh, local } = options;
105
- if (scope || use || create || git)
106
- throw commandArgumentError(command, 'Vercel connect options require a Vercel web manifest or --provider vercel.');
107
- switch (command) {
108
- case 'register':
109
- return registerApplication(root);
110
- case 'connect':
111
- return connectApplication(root, account, audience, undefined, emails);
112
- case 'provision':
113
- return dryRun ? planProvisioning(root) : provisionApplication(root);
114
- case 'ship':
115
- return shipCloudflareApplication(root, dryRun);
116
- case 'adopt':
117
- throw commandArgumentError(command, 'Git deployment adoption requires --provider vercel.');
118
- case 'recover':
119
- return recoverApplication(root);
120
- case 'verify':
121
- return verifyApplication(root);
122
- case 'rollback':
123
- return rollbackApplication(root, releaseId(command, options), options.dataCompatible);
124
- case 'manage': {
125
- const snapshot = await applicationStatus(root, !local);
126
- return { file: writeManagementOverview(root, snapshot), evidence: snapshot.evidence };
127
- }
128
- default:
129
- return applicationStatus(root, refresh);
130
- }
131
- }
132
- async function executeDelivery(command, options) {
133
- const { root, provider, platform, profile, dryRun, lock, refresh } = options;
134
- if (command === 'recover' && lock) {
135
- if (provider || refresh)
136
- throw commandArgumentError(command, 'Local lock recovery cannot be combined with provider recovery or --refresh.');
137
- return { result: recoverDeliveryLock(root), blockedStates: [] };
138
- }
139
- if (platform || profile) {
140
- if (!platform || !profile || provider)
141
- throw commandArgumentError(command, 'Mobile shipping requires --platform and --profile, without --provider.');
142
- return {
143
- result: await buildMobileApplication(root, { platform, profile, dryRun }),
144
- blockedStates: ['configuration-required', 'provider-configuration-required'],
145
- };
146
- }
147
- // Resolve hosting before the mixed-stack path, retaining its configuration preflight.
148
- const web = isVercel(command, options);
149
- if (command === 'ship' && !provider)
150
- return {
151
- result: await shipSelectedStack(root, dryRun),
152
- blockedStates: ['configuration-required', 'provider-configuration-required', 'partial'],
153
- };
154
- let result = await (web ? vercelCommand : cloudflareCommand)(command, options);
155
- if (command === 'status')
156
- result = { ...result, operation: readLifecycleOperation(root) };
157
- return {
158
- result,
159
- blockedStates: web
160
- ? ['provider-configuration-required']
161
- : ['configuration-required', 'provider-configuration-required'],
162
- };
163
- }
164
- export async function runDelivery(command, args, output) {
165
- const { result, blockedStates } = await executeDelivery(command, deliveryOptions(command, args));
166
- printResult(command, result, output);
167
- if (result &&
168
- typeof result === 'object' &&
169
- 'state' in result &&
170
- blockedStates.includes(String(result.state)))
171
- process.exitCode = 1;
172
- }
@@ -1,25 +0,0 @@
1
- import type { ApplicationProject, DeliveryRunner } from './project-state.js';
2
- export interface CloudflareResponse {
3
- result: unknown;
4
- result_info?: {
5
- page?: number;
6
- total_pages?: number;
7
- count?: number;
8
- per_page?: number;
9
- cursor?: string;
10
- };
11
- }
12
- export type CloudflareRequest = (method: 'GET' | 'POST' | 'DELETE', endpoint: string, body?: unknown) => Promise<CloudflareResponse>;
13
- export interface CloudflareRequestOptions {
14
- send?: typeof fetch;
15
- timeoutMs?: number;
16
- analytics?: boolean;
17
- }
18
- export declare class CloudflareRequestError extends Error {
19
- readonly status: number;
20
- constructor(message: string, status: number);
21
- }
22
- /** Credentials stay in this closure. Fixed account paths, bounded response reads and
23
- * a whole-request deadline apply to reads and mutations; mutations never retry. */
24
- export declare function cloudflareRequest(project: ApplicationProject, directory: string, run: DeliveryRunner, env: NodeJS.ProcessEnv, options?: CloudflareRequestOptions): Promise<CloudflareRequest>;
25
- export declare function listCloudflare(request: CloudflareRequest, endpoint: string): Promise<Record<string, unknown>[]>;
@@ -1,226 +0,0 @@
1
- const ORIGIN = 'https://api.cloudflare.com';
2
- const MAX_RESPONSE_BYTES = 2 * 1024 * 1024;
3
- export class CloudflareRequestError extends Error {
4
- status;
5
- constructor(message, status) {
6
- super(message);
7
- this.status = status;
8
- }
9
- }
10
- function object(value) {
11
- return Boolean(value) && typeof value === 'object' && !Array.isArray(value);
12
- }
13
- function cancelBody(response) {
14
- try {
15
- void response.body?.cancel().catch(() => undefined);
16
- }
17
- catch {
18
- /* Best effort cancellation never exposes provider diagnostics. */
19
- }
20
- }
21
- async function boundedJson(response, signal) {
22
- if (signal.aborted) {
23
- cancelBody(response);
24
- throw new Error();
25
- }
26
- const reader = response.body?.getReader();
27
- if (!reader)
28
- throw new Error();
29
- const cancel = () => {
30
- void reader.cancel().catch(() => undefined);
31
- };
32
- signal.addEventListener('abort', cancel, { once: true });
33
- const chunks = [];
34
- let bytes = 0;
35
- try {
36
- for (;;) {
37
- const chunk = await reader.read();
38
- if (chunk.done)
39
- break;
40
- bytes += chunk.value.length;
41
- if (bytes > MAX_RESPONSE_BYTES || signal.aborted)
42
- throw new Error();
43
- chunks.push(chunk.value);
44
- }
45
- return JSON.parse(Buffer.concat(chunks).toString('utf8'));
46
- }
47
- catch {
48
- cancel();
49
- throw new Error();
50
- }
51
- finally {
52
- signal.removeEventListener('abort', cancel);
53
- reader.releaseLock();
54
- }
55
- }
56
- function responseInfo(value) {
57
- if (value === undefined || value === null)
58
- return undefined;
59
- if (!object(value))
60
- throw new Error('Cloudflare returned unsupported pagination.');
61
- const info = {};
62
- if (value.cursor !== undefined) {
63
- if (typeof value.cursor !== 'string' ||
64
- value.cursor.length > 4096 ||
65
- /[\x00-\x1f\x7f]/.test(value.cursor))
66
- throw new Error('Cloudflare returned an invalid pagination cursor.');
67
- info.cursor = value.cursor;
68
- }
69
- for (const field of ['page', 'total_pages', 'count', 'per_page']) {
70
- const entry = value[field];
71
- if (entry !== undefined) {
72
- if (typeof entry !== 'number' || !Number.isSafeInteger(entry) || entry < 0)
73
- throw new Error('Cloudflare returned unsupported pagination.');
74
- info[field] = entry;
75
- }
76
- }
77
- return info;
78
- }
79
- /** Credentials stay in this closure. Fixed account paths, bounded response reads and
80
- * a whole-request deadline apply to reads and mutations; mutations never retry. */
81
- export async function cloudflareRequest(project, directory, run, env, options = {}) {
82
- const account = project.accountId;
83
- if (typeof account !== 'string' || !/^[a-f0-9]{32}$/.test(account))
84
- throw new Error('Select a valid Cloudflare account before provider requests.');
85
- const timeoutMs = options.timeoutMs ?? 30_000;
86
- if (!Number.isInteger(timeoutMs) || timeoutMs < 1 || timeoutMs > 30_000)
87
- throw new Error('Invalid bounded Cloudflare request deadline.');
88
- const send = options.send ?? fetch;
89
- let credentials;
90
- try {
91
- const raw = await run('pnpm', ['exec', 'wrangler', 'auth', 'token', '--json'], directory, env);
92
- if (Buffer.byteLength(raw) > 64 * 1024)
93
- throw new Error();
94
- credentials = JSON.parse(raw);
95
- }
96
- catch {
97
- throw new Error('Cannot retrieve structured Wrangler credentials; update Wrangler and check authentication.');
98
- }
99
- if (!object(credentials) ||
100
- typeof credentials.type !== 'string' ||
101
- !['oauth', 'api_token'].includes(credentials.type) ||
102
- typeof credentials.token !== 'string' ||
103
- !/^[\x21-\x7e]{1,16384}$/.test(credentials.token))
104
- throw new Error('Cloudflare operations require scoped API-token or Wrangler OAuth access.');
105
- const token = credentials.token;
106
- const prefix = `/client/v4/accounts/${account}`;
107
- return async (method, endpoint, body) => {
108
- let url;
109
- try {
110
- if (typeof endpoint !== 'string')
111
- throw new Error();
112
- const decodedPath = decodeURIComponent(endpoint.split('?')[0]);
113
- if (!['GET', 'POST', 'DELETE'].includes(method) ||
114
- endpoint.length > 4096 ||
115
- !endpoint.startsWith('/') ||
116
- endpoint.startsWith('//') ||
117
- /[\x00-\x20\x7f#\\]/.test(endpoint) ||
118
- decodedPath.includes('..') ||
119
- /[\x00-\x20\x7f#\\%]/.test(decodedPath))
120
- throw new Error();
121
- if (options.analytics) {
122
- if (endpoint !== '/graphql' ||
123
- method !== 'POST' ||
124
- !object(body) ||
125
- !object(body.variables) ||
126
- body.variables.accountTag !== account)
127
- throw new Error();
128
- url = new URL('/client/v4/graphql', ORIGIN);
129
- }
130
- else {
131
- url = new URL(`${prefix}${endpoint}`, ORIGIN);
132
- if (url.origin !== ORIGIN || !url.pathname.startsWith(`${prefix}/`))
133
- throw new Error();
134
- }
135
- }
136
- catch {
137
- throw new Error('Invalid account-scoped provider request.');
138
- }
139
- const controller = new AbortController();
140
- let timer;
141
- const timeout = new Promise((_resolve, reject) => {
142
- timer = setTimeout(() => {
143
- controller.abort();
144
- reject(new Error('Cloudflare request deadline exceeded; inspect remote status before retrying.'));
145
- }, timeoutMs);
146
- });
147
- try {
148
- return await Promise.race([
149
- (async () => {
150
- let response;
151
- try {
152
- response = await send(url.href, {
153
- method,
154
- headers: { Authorization: `Bearer ${token}`, 'Content-Type': 'application/json' },
155
- body: body === undefined ? undefined : JSON.stringify(body),
156
- redirect: 'error',
157
- signal: controller.signal,
158
- });
159
- }
160
- catch {
161
- throw new Error('Cloudflare request failed; check connectivity and account permissions.');
162
- }
163
- let data;
164
- try {
165
- data = await boundedJson(response, controller.signal);
166
- }
167
- catch {
168
- throw new Error(`Cloudflare returned unsupported output (HTTP ${response.status}).`);
169
- }
170
- if (!object(data))
171
- throw new Error(`Cloudflare returned unsupported output (HTTP ${response.status}).`);
172
- if (!response.ok ||
173
- (options.analytics
174
- ? data.errors != null && (!Array.isArray(data.errors) || data.errors.length > 0)
175
- : data.success !== true)) {
176
- const codes = Array.isArray(data.errors)
177
- ? data.errors
178
- .slice(0, 20)
179
- .filter(object)
180
- .map((item) => item.code)
181
- .filter((code) => typeof code === 'number' &&
182
- Number.isSafeInteger(code) &&
183
- code >= 0 &&
184
- code <= 1_000_000)
185
- .join(',')
186
- : '';
187
- throw new CloudflareRequestError(`Cloudflare operation failed (HTTP ${response.status}${codes ? `; codes ${codes}` : ''}). Check scoped permissions and service eligibility; no paid plan is activated automatically.`, response.status);
188
- }
189
- if (options.analytics)
190
- return { result: data.data };
191
- if (!Object.hasOwn(data, 'result'))
192
- throw new Error('Cloudflare returned no operation result.');
193
- return { result: data.result, result_info: responseInfo(data.result_info) };
194
- })(),
195
- timeout,
196
- ]);
197
- }
198
- finally {
199
- clearTimeout(timer);
200
- }
201
- };
202
- }
203
- export async function listCloudflare(request, endpoint) {
204
- const result = [];
205
- let bytes = 0;
206
- for (let page = 1; page <= 1000; page++) {
207
- const response = await request('GET', `${endpoint}${endpoint.includes('?') ? '&' : '?'}page=${page}&per_page=100`);
208
- if (!Array.isArray(response.result) ||
209
- response.result.length > 100 ||
210
- response.result.some((item) => !object(item)))
211
- throw new Error('Unsupported provider resource list.');
212
- try {
213
- bytes += Buffer.byteLength(JSON.stringify(response.result));
214
- }
215
- catch {
216
- throw new Error('Unsupported provider resource list.');
217
- }
218
- if (result.length + response.result.length > 10_000 || bytes > 10 * 1024 * 1024)
219
- throw new Error('Provider resource listing exceeded its collection limit.');
220
- result.push(...response.result);
221
- const info = responseInfo(response.result_info);
222
- if (info?.total_pages !== undefined ? page >= info.total_pages : response.result.length < 100)
223
- return result;
224
- }
225
- throw new Error('Provider resource listing exceeded pagination limit.');
226
- }
@@ -1,62 +0,0 @@
1
- import { type CloudflareRequest } from './cloudflare.js';
2
- import { defaultRunner, type ApplicationProject, type DeploymentTarget } from './project-state.js';
3
- export interface TargetRelease {
4
- target: string;
5
- versionId: string;
6
- urls: string[];
7
- providerConfirmed: boolean;
8
- }
9
- export interface Release {
10
- id: string;
11
- commit: string;
12
- startedAt: string;
13
- finishedAt?: string;
14
- state: 'running' | 'checked' | 'deployed' | 'configuration-required' | 'failed';
15
- targets: TargetRelease[];
16
- failure?: string;
17
- configurationChanges?: string[];
18
- operation?: 'ship' | 'rollback';
19
- restoredReleaseId?: string;
20
- verification?: {
21
- state: 'passed' | 'failed';
22
- checkedAt: string;
23
- command: 'pnpm run test:live';
24
- };
25
- }
26
- export interface ReleaseHistory {
27
- schemaVersion: 1;
28
- projectId: string;
29
- releases: Release[];
30
- }
31
- export declare function history(root: string, project: ApplicationProject): ReleaseHistory;
32
- export declare function checkTargets(root: string, project: ApplicationProject, allowResourcePlaceholders?: boolean): void;
33
- export declare function configurationFingerprint(root: string, project: ApplicationProject): string;
34
- export declare function planDelivery(root: string, allowResourcePlaceholders?: boolean): {
35
- project: ApplicationProject;
36
- checks: string[][];
37
- deployments: {
38
- target: string;
39
- directory: string;
40
- command: string[];
41
- }[];
42
- resourcesProvisioned: boolean;
43
- audience: "unconfigured" | "public" | "private";
44
- };
45
- export declare function parseDeploymentOutput(source: string, target: DeploymentTarget): TargetRelease;
46
- export interface ActiveVersion {
47
- versionId: string;
48
- percentage: number;
49
- }
50
- export declare function activeVersions(value: unknown): ActiveVersion[];
51
- export declare function providerStatus(root: string, project: ApplicationProject, target: DeploymentTarget, run: typeof defaultRunner, request?: CloudflareRequest): Promise<unknown>;
52
- export declare function fullyActive(versions: ActiveVersion[], versionId: string): boolean;
53
- export declare function describeArchitecture(root: string, project: ApplicationProject): {
54
- target: string;
55
- workerName: string;
56
- directory: string;
57
- bindings: {
58
- kind: string;
59
- binding: string;
60
- }[];
61
- scheduled: string[];
62
- }[];