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,366 +0,0 @@
1
- import path from 'node:path';
2
- import { realpathSync, existsSync, writeFileSync, rmSync } from 'node:fs';
3
- import { tmpdir } from 'node:os';
4
- import { randomUUID } from 'node:crypto';
5
- import { EAS_CLI_VERSION } from './dependencies.js';
6
- import { readBoundedFile, MAX_PROJECT_JSON_BYTES } from './bounded-file.js';
7
- import { requiredProviders } from './provider-auth.js';
8
- import { planProviderProvisioning, provisionSelectedProviders } from './providers/provision.js';
9
- import { configuredRuntime, runtimeTargets, RUNTIME_KEYS } from './providers/runtime.js';
10
- import { CREDENTIALS } from './providers/api.js';
11
- import { atomicJson, defaultRunner } from './project-state.js';
12
- import { withLifecycleOperation } from './lifecycle.js';
13
- function artifactUrl(value) {
14
- if (typeof value !== 'string')
15
- return undefined;
16
- try {
17
- const url = new URL(value);
18
- if (url.protocol !== 'https:' || url.username || url.password)
19
- return undefined;
20
- return url.href;
21
- }
22
- catch {
23
- return undefined;
24
- }
25
- }
26
- function pendingBuild(root, commit, options, projectId) {
27
- const file = path.join(root, '.anhedral/mobile-build.pending.json');
28
- if (!existsSync(file))
29
- return undefined;
30
- let pending;
31
- try {
32
- pending = JSON.parse(readBoundedFile(file, MAX_PROJECT_JSON_BYTES).toString('utf8'));
33
- }
34
- catch {
35
- throw new Error('Invalid pending EAS build. Inspect the selected project before retrying.');
36
- }
37
- if (!pending ||
38
- typeof pending !== 'object' ||
39
- Array.isArray(pending) ||
40
- pending.schemaVersion !== 1 ||
41
- Object.keys(pending).some((key) => ![
42
- 'schemaVersion',
43
- 'status',
44
- 'commit',
45
- 'platform',
46
- 'profile',
47
- 'projectId',
48
- 'buildId',
49
- ].includes(key)) ||
50
- ![undefined, 'submitting', 'queued'].includes(pending.status) ||
51
- pending.commit !== commit ||
52
- pending.platform !== options.platform ||
53
- pending.profile !== options.profile ||
54
- pending.projectId !== projectId ||
55
- (pending.status === 'submitting'
56
- ? Object.hasOwn(pending, 'buildId')
57
- : typeof pending.buildId !== 'string' || !/^[a-zA-Z0-9-]{1,255}$/.test(pending.buildId)))
58
- throw new Error('Pending EAS build differs from the selected source or profile.');
59
- if (pending.status === 'submitting')
60
- throw new Error('EAS submission has an unknown outcome. Reconcile the selected project before retrying.');
61
- return pending;
62
- }
63
- /** EAS builds produce artifacts; store submission is a separate user action. */
64
- export async function buildMobileApplication(root, options, run = defaultRunner) {
65
- if (options.dryRun)
66
- return executeMobileBuild(root, options, run);
67
- // Validate local build configuration before creating an execution record.
68
- await executeMobileBuild(root, { ...options, dryRun: true }, run);
69
- return withLifecycleOperation(root, 'mobile', run, (session) => session.phase('mobile-build', () => executeMobileBuild(root, options, run)));
70
- }
71
- function mobileConfiguration(root, options) {
72
- root = realpathSync(root);
73
- if (!['ios', 'android'].includes(options.platform) ||
74
- !/^[a-z][a-z0-9-]{0,63}$/.test(options.profile))
75
- throw new Error('Select an explicit mobile platform and build profile.');
76
- if (!requiredProviders(root).some((provider) => provider.id === 'expo'))
77
- throw new Error('This project does not select Expo.');
78
- const directory = realpathSync(path.join(root, 'apps/mobile'));
79
- if (!directory.startsWith(root + path.sep))
80
- throw new Error('Mobile app escapes project directory.');
81
- let configuration;
82
- try {
83
- configuration = JSON.parse(readBoundedFile(path.join(directory, 'eas.json'), MAX_PROJECT_JSON_BYTES).toString('utf8'));
84
- }
85
- catch {
86
- throw new Error('A valid EAS build configuration is required.');
87
- }
88
- const profile = configuration?.build?.[options.profile];
89
- if (!profile || typeof profile !== 'object' || Array.isArray(profile))
90
- throw new Error('Requested EAS profile is not configured.');
91
- if (profile.extends)
92
- throw new Error('Resolve inherited EAS profiles before automatic delivery.');
93
- const selectedEnvironment = profile.environment ??
94
- (profile.developmentClient
95
- ? 'development'
96
- : profile.distribution === 'internal'
97
- ? 'preview'
98
- : 'production');
99
- if (!['development', 'preview', 'production'].includes(selectedEnvironment))
100
- throw new Error('Select an explicit supported EAS environment.');
101
- const args = [
102
- 'dlx',
103
- `eas-cli@${EAS_CLI_VERSION}`,
104
- 'build',
105
- '--platform',
106
- options.platform,
107
- '--profile',
108
- options.profile,
109
- '--non-interactive',
110
- '--json',
111
- '--no-wait',
112
- ];
113
- return { root, options, directory, profile, selectedEnvironment, args };
114
- }
115
- function readMobileApplication(directory) {
116
- const app = JSON.parse(readBoundedFile(path.join(directory, 'app.json'), MAX_PROJECT_JSON_BYTES).toString('utf8')).expo;
117
- if (['app.config.js', 'app.config.ts'].some((file) => existsSync(path.join(directory, file))))
118
- throw new Error('Automatic EAS setup requires a static app.json with explicit owner and slug.');
119
- if (typeof app?.owner !== 'string' ||
120
- !/^[a-zA-Z0-9_-]+$/.test(app.owner) ||
121
- typeof app.slug !== 'string' ||
122
- !/^[a-zA-Z0-9_-]+$/.test(app.slug))
123
- throw new Error('Set the intended Expo owner and slug in app.json before shipping.');
124
- return app;
125
- }
126
- function mobileEnvironment() {
127
- const environment = { ...process.env, CI: '1', NO_COLOR: '1' };
128
- // Expo keeps its own login credential; server/provider keys never reach native builds.
129
- for (const key of [...Object.values(CREDENTIALS), ...RUNTIME_KEYS])
130
- if (!key.startsWith('EXPO_PUBLIC_'))
131
- delete environment[key];
132
- return environment;
133
- }
134
- async function mobileSource(root, environment, run) {
135
- if (realpathSync((await run('git', ['rev-parse', '--show-toplevel'], root, environment)).trim()) !==
136
- root ||
137
- (await run('git', ['status', '--porcelain'], root, environment)).trim())
138
- throw new Error('Mobile delivery requires a clean application Git repository.');
139
- const commit = (await run('git', ['rev-parse', 'HEAD'], root, environment)).trim();
140
- if (!/^[a-f0-9]{40,64}$/.test(commit))
141
- throw new Error('Invalid mobile source commit.');
142
- return commit;
143
- }
144
- const easCli = ['dlx', `eas-cli@${EAS_CLI_VERSION}`];
145
- async function linkMobileProject({ configuration: { directory }, app, environment, run, }) {
146
- const cli = easCli;
147
- await run('pnpm', [...cli, 'project:init', '--non-interactive', '--force'], directory, environment);
148
- const linked = JSON.parse(readBoundedFile(path.join(directory, 'app.json'), MAX_PROJECT_JSON_BYTES).toString('utf8')).expo;
149
- if (linked?.owner !== app.owner ||
150
- linked.slug !== app.slug ||
151
- typeof linked.extra?.eas?.projectId !== 'string' ||
152
- !/^[a-f0-9-]{36}$/i.test(linked.extra.eas.projectId))
153
- throw new Error('EAS did not confirm a project link for the selected owner and slug. Inspect the account before retrying.');
154
- return {
155
- state: 'configuration-required',
156
- deployed: false,
157
- storeSubmission: false,
158
- nextAction: 'Review and commit the EAS project link written to app.json, then run ship again.',
159
- };
160
- }
161
- async function verifyMobileProject(session, projectId) {
162
- const { configuration: { directory }, app, environment, run, } = session;
163
- const cli = easCli;
164
- const remote = await run('pnpm', [...cli, 'project:info'], directory, environment);
165
- const remoteName = remote
166
- .split(/\r?\n/)
167
- .find((line) => /^fullName\s+/.test(line.trim()))
168
- ?.trim()
169
- .split(/\s+/)[1];
170
- const remoteId = remote
171
- .split(/\r?\n/)
172
- .find((line) => /^ID\s+/.test(line.trim()))
173
- ?.trim()
174
- .split(/\s+/)[1];
175
- if (remoteId !== projectId || remoteName !== `@${app.owner}/${app.slug}`)
176
- throw new Error('EAS project identity differs from the selected owner and project.');
177
- }
178
- async function configureMobileEnvironment(session, values) {
179
- const { configuration: { directory, selectedEnvironment }, environment, run, } = session;
180
- const cli = easCli;
181
- if (values && Object.keys(values).length) {
182
- const file = path.join(tmpdir(), `anhedral-expo-${randomUUID()}.env`);
183
- try {
184
- writeFileSync(file, Object.entries(values)
185
- .map(([key, value]) => `${key}=${JSON.stringify(value)}\n`)
186
- .join(''), { mode: 0o600, flag: 'wx' });
187
- await run('pnpm', [...cli, 'env:push', '--environment', selectedEnvironment, '--path', file, '--force'], directory, environment);
188
- }
189
- finally {
190
- rmSync(file, { force: true });
191
- }
192
- }
193
- }
194
- async function requestMobileBuild(session, selection) {
195
- const { configuration: { root, options, directory, args }, environment, run, } = session;
196
- const { commit, projectId, values } = selection;
197
- const cli = easCli;
198
- const source = () => mobileSource(root, environment, run);
199
- let builds;
200
- let expectedBuildId;
201
- const pendingFile = path.join(root, '.anhedral/mobile-build.pending.json');
202
- try {
203
- const pending = pendingBuild(root, commit, options, projectId);
204
- if (pending) {
205
- const buildId = pending.buildId;
206
- if (!buildId)
207
- throw new Error('Pending EAS build has no verified ID.');
208
- expectedBuildId = buildId;
209
- builds = [
210
- JSON.parse(await run('pnpm', [...cli, 'build:view', buildId, '--json'], directory, environment)),
211
- ];
212
- }
213
- else {
214
- if ((await source()) !== commit)
215
- throw new Error('Source changed before EAS build submission.');
216
- // Record intent before the remote queue mutation, including lost or invalid responses.
217
- atomicJson(pendingFile, {
218
- schemaVersion: 1,
219
- status: 'submitting',
220
- commit,
221
- platform: options.platform,
222
- profile: options.profile,
223
- projectId,
224
- });
225
- builds = JSON.parse(await run('pnpm', args, directory, { ...environment, ...values }));
226
- }
227
- }
228
- catch {
229
- throw new Error('EAS build did not return verified completion; inspect the selected Expo project before retrying.');
230
- }
231
- return { builds, expectedBuildId, pendingFile };
232
- }
233
- function validateMobileBuild(session, selection, builds, expectedBuildId) {
234
- const { configuration: { options, profile, selectedEnvironment }, app, } = session;
235
- const { commit, projectId } = selection;
236
- if (!Array.isArray(builds) || builds.length !== 1)
237
- throw new Error('EAS returned an unexpected build selection.');
238
- const build = builds[0];
239
- if (typeof build?.id !== 'string' || !/^[a-zA-Z0-9-]{1,255}$/.test(build.id))
240
- throw new Error('EAS did not return a valid build ID.');
241
- if (build.project?.id !== projectId ||
242
- build.project?.ownerAccount?.name !== app.owner ||
243
- build.project?.slug !== app.slug)
244
- throw new Error('EAS build belongs to a different project.');
245
- validateBuildProfile(build, options, profile, selectedEnvironment);
246
- if (build.gitCommitHash !== commit)
247
- throw new Error('EAS build source differs from the selected source commit.');
248
- if (expectedBuildId && build.id !== expectedBuildId)
249
- throw new Error('EAS returned a different build than the recorded selection.');
250
- return build;
251
- }
252
- function validateBuildProfile(build, options, profile, selectedEnvironment) {
253
- if (build.platform !== options.platform.toUpperCase() ||
254
- build.buildProfile !== options.profile ||
255
- (build.environment !== undefined && build.environment !== selectedEnvironment) ||
256
- (options.platform === 'ios' && build.isForIosSimulator !== (profile.ios?.simulator === true)))
257
- throw new Error('EAS build platform, profile or environment differs from the selected configuration.');
258
- }
259
- function mobileArtifact(options, profile) {
260
- if (options.platform === 'ios')
261
- return profile.ios?.simulator === true ? 'ios-simulator' : 'ipa';
262
- return profile.android?.buildType === 'apk' ||
263
- profile.distribution === 'internal' ||
264
- profile.developmentClient === true
265
- ? 'apk'
266
- : 'aab';
267
- }
268
- async function recordMobileBuild(session, selection, build, pendingFile) {
269
- const { configuration: { root, options, profile }, app, environment, run, } = session;
270
- const { commit, projectId } = selection;
271
- const source = () => mobileSource(root, environment, run);
272
- const downloadUrl = artifactUrl(build.artifacts?.applicationArchiveUrl ?? build.artifacts?.buildUrl);
273
- atomicJson(pendingFile, {
274
- schemaVersion: 1,
275
- status: 'queued',
276
- commit,
277
- platform: options.platform,
278
- profile: options.profile,
279
- projectId,
280
- buildId: build.id,
281
- });
282
- const buildPage = `https://expo.dev/accounts/${app.owner}/projects/${app.slug}/builds/${build.id}`;
283
- if (['NEW', 'IN_QUEUE', 'IN_PROGRESS', 'PENDING_CANCEL'].includes(build.status ?? ''))
284
- return {
285
- schemaVersion: 1,
286
- state: 'building',
287
- buildId: build.id,
288
- buildPageUrl: buildPage,
289
- commit,
290
- platform: options.platform,
291
- profile: options.profile,
292
- storeSubmission: false,
293
- nextAction: 'Run the same ship command again to inspect this build without creating another build.',
294
- };
295
- if (build.status !== 'FINISHED' || !downloadUrl)
296
- throw new Error('EAS has not confirmed a completed downloadable build. Inspect the recorded build before retrying.');
297
- if ((await source()) !== commit)
298
- throw new Error('Source changed during mobile build; do not treat this artifact as the current release.');
299
- const result = {
300
- schemaVersion: 1,
301
- projectId,
302
- owner: app.owner,
303
- slug: app.slug,
304
- recordedAt: new Date().toISOString(),
305
- // Identity validation already matched the provider owner/slug to the local app.
306
- buildPageUrl: buildPage,
307
- commit,
308
- platform: options.platform,
309
- profile: options.profile,
310
- buildId: build.id,
311
- downloadUrl,
312
- state: 'built',
313
- storeSubmission: false,
314
- artifact: mobileArtifact(options, profile),
315
- };
316
- atomicJson(path.join(root, '.anhedral/mobile-build.json'), result);
317
- rmSync(pendingFile, { force: true });
318
- return result;
319
- }
320
- async function executeMobileBuild(root, options, run) {
321
- const configuration = mobileConfiguration(root, options);
322
- root = configuration.root;
323
- if (options.dryRun)
324
- return {
325
- platform: options.platform,
326
- profile: options.profile,
327
- command: ['pnpm', ...configuration.args],
328
- mutation: false,
329
- storeSubmission: false,
330
- integrations: planProviderProvisioning(root),
331
- };
332
- const app = readMobileApplication(configuration.directory);
333
- const environment = mobileEnvironment();
334
- const session = { configuration, app, environment, run };
335
- const source = () => mobileSource(root, environment, run);
336
- const initialCommit = await source();
337
- // Unknown submissions must stop before checks, provisioning or remote configuration.
338
- pendingBuild(root, initialCommit, options, app.extra?.eas?.projectId);
339
- await run('pnpm', ['run', 'check'], root, environment);
340
- if ((await source()) !== initialCommit)
341
- throw new Error('Source changed during mobile checks.');
342
- const configured = await provisionSelectedProviders(root, false, run);
343
- if (!configured.ready)
344
- return {
345
- state: 'provider-configuration-required',
346
- deployed: false,
347
- integrations: configured,
348
- storeSubmission: false,
349
- };
350
- const runtime = configuredRuntime(root);
351
- const commit = await source();
352
- if (commit !== initialCommit)
353
- throw new Error('Source changed during provider configuration.');
354
- if (!app.extra?.eas?.projectId)
355
- return linkMobileProject(session);
356
- const projectId = app.extra.eas.projectId;
357
- if (typeof projectId !== 'string' || !/^[a-f0-9-]{36}$/i.test(projectId))
358
- throw new Error('Invalid EAS project ID.');
359
- await verifyMobileProject(session, projectId);
360
- const values = runtimeTargets(root, runtime)['apps/mobile/.env.local'];
361
- await configureMobileEnvironment(session, values);
362
- const selection = { commit, projectId, values };
363
- const { builds, expectedBuildId, pendingFile } = await requestMobileBuild(session, selection);
364
- const build = validateMobileBuild(session, selection, builds, expectedBuildId);
365
- return recordMobileBuild(session, selection, build, pendingFile);
366
- }
@@ -1,8 +0,0 @@
1
- import { neon } from '@neondatabase/serverless';
2
- import type { ApiRequest } from './providers/api.js';
3
- import { type IntegrationService } from './integration-service-readers.js';
4
- import type { ServiceData } from './service-model.js';
5
- export type NeonRead = (query: string, params?: unknown[]) => Promise<Record<string, unknown>[]>;
6
- export declare function neonReadConnection(service: IntegrationService, api: ApiRequest, env?: NodeJS.ProcessEnv, createClient?: typeof neon): Promise<NeonRead>;
7
- export declare function listNeonTables(read: NeonRead): Promise<string[]>;
8
- export declare function browseNeonData(read: NeonRead, table: string, offset?: number): Promise<ServiceData>;
@@ -1,117 +0,0 @@
1
- import { neon } from '@neondatabase/serverless';
2
- import { setting } from './providers/config.js';
3
- import { record } from './service-readers.js';
4
- import { inspectIntegrationResource, } from './integration-service-readers.js';
5
- const identifier = (value) => {
6
- if (!/^[a-zA-Z_][a-zA-Z0-9_]{0,127}$/.test(value))
7
- throw new Error('Unsupported database identifier.');
8
- return `"${value}"`;
9
- };
10
- const sensitive = /password|secret|token|email|phone|address|authorization|cookie|session|private|credential/i;
11
- export async function neonReadConnection(service, api, env = process.env, createClient = neon) {
12
- if (service.provider !== 'neon')
13
- throw new Error('Choose the selected Neon project.');
14
- const project = await inspectIntegrationResource(service, api);
15
- const connection = env[`ANHEDRAL_NEON_READONLY_URL_${String(project.id)
16
- .replace(/[^a-zA-Z0-9]/g, '_')
17
- .toUpperCase()}`] ?? env.ANHEDRAL_NEON_READONLY_URL;
18
- if (!connection)
19
- throw new Error('Provide ANHEDRAL_NEON_READONLY_URL for a restricted read-only role.');
20
- let url;
21
- try {
22
- url = new URL(connection);
23
- }
24
- catch {
25
- throw new Error('Invalid read-only database connection.');
26
- }
27
- if (!['postgres:', 'postgresql:'].includes(url.protocol) ||
28
- !url.hostname.endsWith('.neon.tech') ||
29
- !url.username ||
30
- !url.password ||
31
- (url.port && url.port !== '5432') ||
32
- decodeURIComponent(url.pathname.slice(1)) !== setting(service.settings, 'database'))
33
- throw new Error('Read-only database connection does not match selected configuration.');
34
- const endpoints = record(await api(`/api/v2/projects/${project.id}/endpoints`)).endpoints;
35
- if (!Array.isArray(endpoints) ||
36
- endpoints.length > 100 ||
37
- !endpoints.some((endpoint) => record(endpoint).host === url.hostname.replace(/-pooler\./, '.')))
38
- throw new Error('Database endpoint does not belong to the selected Neon project.');
39
- const sql = createClient(connection);
40
- return async (query, params = []) => {
41
- try {
42
- const result = await sql.transaction([
43
- sql.query("SELECT set_config('statement_timeout','5000',true)"),
44
- sql.query("SELECT current_setting('transaction_read_only') = 'on' AS read_only, (SELECT rolsuper OR rolcreatedb OR rolcreaterole FROM pg_roles WHERE rolname = current_user) AS privileged, EXISTS(SELECT 1 FROM pg_class c JOIN pg_namespace n ON n.oid=c.relnamespace WHERE n.nspname='public' AND c.relkind IN ('r','p') AND has_table_privilege(current_user,c.oid,'INSERT,UPDATE,DELETE,TRUNCATE')) AS writable"),
45
- sql.query(query, params),
46
- ], {
47
- readOnly: true,
48
- isolationLevel: 'RepeatableRead',
49
- fetchOptions: { signal: AbortSignal.timeout(10000), redirect: 'error' },
50
- });
51
- const role = result[1]?.[0];
52
- if (role?.read_only !== true || role.privileged !== false || role.writable !== false)
53
- throw new Error('Restricted read-only role required.');
54
- if (!Array.isArray(result[2]) || result[2].length > 1001)
55
- throw new Error('Database response exceeded limits.');
56
- return result[2].map(record);
57
- }
58
- catch {
59
- throw new Error('Neon read failed. Check the selected endpoint, restricted role, read permissions and query limits.');
60
- }
61
- };
62
- }
63
- export async function listNeonTables(read) {
64
- const rows = await read("SELECT table_name AS name FROM information_schema.tables WHERE table_schema='public' AND table_type='BASE TABLE' ORDER BY table_name LIMIT 1001");
65
- if (rows.length > 1000)
66
- throw new Error('Database schema exceeds its table limit.');
67
- return rows.map((row) => {
68
- if (typeof row.name !== 'string')
69
- throw new Error('Invalid database table.');
70
- identifier(row.name);
71
- return row.name;
72
- });
73
- }
74
- export async function browseNeonData(read, table, offset = 0) {
75
- identifier(table);
76
- if (!Number.isSafeInteger(offset) ||
77
- offset < 0 ||
78
- offset > 10000 ||
79
- !(await listNeonTables(read)).includes(table))
80
- throw new Error('Choose a bounded existing table page.');
81
- const fields = await read("SELECT column_name AS name FROM information_schema.columns WHERE table_schema='public' AND table_name=$1 ORDER BY ordinal_position LIMIT 51", [table]);
82
- if (fields.length > 50 || !fields.length)
83
- throw new Error('Table exceeds its supported column limit.');
84
- const columns = fields.map((row) => {
85
- if (typeof row.name !== 'string')
86
- throw new Error('Invalid database column.');
87
- identifier(row.name);
88
- return row.name;
89
- });
90
- const projection = columns
91
- .map((column) => sensitive.test(column)
92
- ? `'[masked]'::text AS ${identifier(column)}`
93
- : `left(${identifier(column)}::text,1000) AS ${identifier(column)}`)
94
- .join(', ');
95
- const rows = await read(`SELECT ${projection} FROM public.${identifier(table)} ORDER BY ${columns.map((_, index) => index + 1).join(', ')} LIMIT $1 OFFSET $2`, [26, offset]);
96
- let masked = columns.some((column) => sensitive.test(column));
97
- const outputRows = rows.slice(0, 25).map((row) => columns.map((column) => {
98
- const value = row[column];
99
- if (value === null)
100
- return null;
101
- if (typeof value !== 'string')
102
- throw new Error('Unsupported database value.');
103
- if (/^(?:sk[-_]|rk[-_]|whsec[-_]|Bearer )/i.test(value)) {
104
- masked = true;
105
- return '[masked]';
106
- }
107
- return value.slice(0, 1000);
108
- }));
109
- return {
110
- fetchedAt: new Date().toISOString(),
111
- columns,
112
- rows: outputRows,
113
- offset,
114
- hasMore: rows.length > 25,
115
- masked,
116
- };
117
- }
@@ -1,2 +0,0 @@
1
- import type { RecipeContext } from '../registry/types.js';
2
- export declare function scaffoldElectron({ root, options }: RecipeContext): Promise<void>;