primitive-admin 1.2.0-alpha.8 → 1.3.0-alpha.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 (563) hide show
  1. package/README.md +258 -186
  2. package/assets/skill/skills/primitive-platform/SKILL.md +103 -29
  3. package/dist/bin/primitive.js +15 -89
  4. package/dist/bin/primitive.js.map +1 -1
  5. package/dist/src/commands/admins.js +80 -17
  6. package/dist/src/commands/admins.js.map +1 -1
  7. package/dist/src/commands/agent-sessions.d.ts +129 -0
  8. package/dist/src/commands/agent-sessions.js +532 -20
  9. package/dist/src/commands/agent-sessions.js.map +1 -1
  10. package/dist/src/commands/analytics.js +207 -155
  11. package/dist/src/commands/analytics.js.map +1 -1
  12. package/dist/src/commands/apps-children.d.ts +1 -1
  13. package/dist/src/commands/apps-children.js +56 -145
  14. package/dist/src/commands/apps-children.js.map +1 -1
  15. package/dist/src/commands/apps-transitions.d.ts +39 -0
  16. package/dist/src/commands/apps-transitions.js +198 -0
  17. package/dist/src/commands/apps-transitions.js.map +1 -0
  18. package/dist/src/commands/apps.d.ts +17 -0
  19. package/dist/src/commands/apps.js +108 -3
  20. package/dist/src/commands/apps.js.map +1 -1
  21. package/dist/src/commands/auth-sessions.js +2 -0
  22. package/dist/src/commands/auth-sessions.js.map +1 -1
  23. package/dist/src/commands/auth.js +138 -44
  24. package/dist/src/commands/auth.js.map +1 -1
  25. package/dist/src/commands/blob-buckets.js +2 -0
  26. package/dist/src/commands/blob-buckets.js.map +1 -1
  27. package/dist/src/commands/collections.js +318 -256
  28. package/dist/src/commands/collections.js.map +1 -1
  29. package/dist/src/commands/comparisons.js +2 -0
  30. package/dist/src/commands/comparisons.js.map +1 -1
  31. package/dist/src/commands/config.d.ts +2 -2
  32. package/dist/src/commands/config.js +59 -33
  33. package/dist/src/commands/config.js.map +1 -1
  34. package/dist/src/commands/connections.js +2 -0
  35. package/dist/src/commands/connections.js.map +1 -1
  36. package/dist/src/commands/database-type-configs.js +5 -3
  37. package/dist/src/commands/database-type-configs.js.map +1 -1
  38. package/dist/src/commands/database-types.js +13 -313
  39. package/dist/src/commands/database-types.js.map +1 -1
  40. package/dist/src/commands/databases.js +6 -4
  41. package/dist/src/commands/databases.js.map +1 -1
  42. package/dist/src/commands/db3-types.d.ts +15 -0
  43. package/dist/src/commands/db3-types.js +159 -0
  44. package/dist/src/commands/db3-types.js.map +1 -0
  45. package/dist/src/commands/db3.d.ts +24 -0
  46. package/dist/src/commands/db3.js +1444 -0
  47. package/dist/src/commands/db3.js.map +1 -0
  48. package/dist/src/commands/documents.d.ts +110 -10
  49. package/dist/src/commands/documents.js +1012 -748
  50. package/dist/src/commands/documents.js.map +1 -1
  51. package/dist/src/commands/email-templates.js +74 -0
  52. package/dist/src/commands/email-templates.js.map +1 -1
  53. package/dist/src/commands/env.js +8 -4
  54. package/dist/src/commands/env.js.map +1 -1
  55. package/dist/src/commands/function-trigger-commands.d.ts +28 -0
  56. package/dist/src/commands/function-trigger-commands.js +341 -0
  57. package/dist/src/commands/function-trigger-commands.js.map +1 -0
  58. package/dist/src/commands/functions.js +376 -30
  59. package/dist/src/commands/functions.js.map +1 -1
  60. package/dist/src/commands/groups.js +168 -50
  61. package/dist/src/commands/groups.js.map +1 -1
  62. package/dist/src/commands/guides.js +7 -5
  63. package/dist/src/commands/guides.js.map +1 -1
  64. package/dist/src/commands/hosting.d.ts +8 -0
  65. package/dist/src/commands/hosting.js +346 -0
  66. package/dist/src/commands/hosting.js.map +1 -0
  67. package/dist/src/commands/init.js +129 -38
  68. package/dist/src/commands/init.js.map +1 -1
  69. package/dist/src/commands/integrations.js +82 -53
  70. package/dist/src/commands/integrations.js.map +1 -1
  71. package/dist/src/commands/llm.js +9 -6
  72. package/dist/src/commands/llm.js.map +1 -1
  73. package/dist/src/commands/locks.d.ts +5 -3
  74. package/dist/src/commands/locks.js +19 -61
  75. package/dist/src/commands/locks.js.map +1 -1
  76. package/dist/src/commands/metadata-category-configs.d.ts +2 -2
  77. package/dist/src/commands/metadata-category-configs.js +4 -2
  78. package/dist/src/commands/metadata-category-configs.js.map +1 -1
  79. package/dist/src/commands/metadata.js +41 -0
  80. package/dist/src/commands/metadata.js.map +1 -1
  81. package/dist/src/commands/prompts.js +75 -52
  82. package/dist/src/commands/prompts.js.map +1 -1
  83. package/dist/src/commands/rate-counters.d.ts +19 -0
  84. package/dist/src/commands/rate-counters.js +104 -0
  85. package/dist/src/commands/rate-counters.js.map +1 -0
  86. package/dist/src/commands/rule-sets.d.ts +1 -1
  87. package/dist/src/commands/rule-sets.js +2 -1
  88. package/dist/src/commands/rule-sets.js.map +1 -1
  89. package/dist/src/commands/schemas.d.ts +15 -0
  90. package/dist/src/commands/schemas.js +122 -0
  91. package/dist/src/commands/schemas.js.map +1 -0
  92. package/dist/src/commands/scripts.d.ts +9 -17
  93. package/dist/src/commands/scripts.js +24 -479
  94. package/dist/src/commands/scripts.js.map +1 -1
  95. package/dist/src/commands/secrets.js +47 -3
  96. package/dist/src/commands/secrets.js.map +1 -1
  97. package/dist/src/commands/sessions.js +2 -0
  98. package/dist/src/commands/sessions.js.map +1 -1
  99. package/dist/src/commands/settings.d.ts +12 -9
  100. package/dist/src/commands/settings.js +31 -79
  101. package/dist/src/commands/settings.js.map +1 -1
  102. package/dist/src/commands/skill.js +2 -0
  103. package/dist/src/commands/skill.js.map +1 -1
  104. package/dist/src/commands/sync-schemas.d.ts +202 -0
  105. package/dist/src/commands/sync-schemas.js +629 -0
  106. package/dist/src/commands/sync-schemas.js.map +1 -0
  107. package/dist/src/commands/sync-user-properties.d.ts +118 -0
  108. package/dist/src/commands/sync-user-properties.js +276 -0
  109. package/dist/src/commands/sync-user-properties.js.map +1 -0
  110. package/dist/src/commands/sync.d.ts +519 -554
  111. package/dist/src/commands/sync.js +3010 -4909
  112. package/dist/src/commands/sync.js.map +1 -1
  113. package/dist/src/commands/tokens.js +5 -3
  114. package/dist/src/commands/tokens.js.map +1 -1
  115. package/dist/src/commands/transitions.d.ts +54 -0
  116. package/dist/src/commands/transitions.js +418 -0
  117. package/dist/src/commands/transitions.js.map +1 -0
  118. package/dist/src/commands/usage.d.ts +18 -0
  119. package/dist/src/commands/usage.js +343 -0
  120. package/dist/src/commands/usage.js.map +1 -0
  121. package/dist/src/commands/user-properties.d.ts +14 -0
  122. package/dist/src/commands/user-properties.js +79 -0
  123. package/dist/src/commands/user-properties.js.map +1 -0
  124. package/dist/src/commands/users.js +911 -18
  125. package/dist/src/commands/users.js.map +1 -1
  126. package/dist/src/commands/vars.js +2 -0
  127. package/dist/src/commands/vars.js.map +1 -1
  128. package/dist/src/commands/waitlist.js +39 -4
  129. package/dist/src/commands/waitlist.js.map +1 -1
  130. package/dist/src/commands/workflows.d.ts +5 -83
  131. package/dist/src/commands/workflows.js +57 -2282
  132. package/dist/src/commands/workflows.js.map +1 -1
  133. package/dist/src/lib/analytics-query.d.ts +58 -0
  134. package/dist/src/lib/analytics-query.js +134 -0
  135. package/dist/src/lib/analytics-query.js.map +1 -0
  136. package/dist/src/lib/api-client.d.ts +1830 -429
  137. package/dist/src/lib/api-client.js +1025 -546
  138. package/dist/src/lib/api-client.js.map +1 -1
  139. package/dist/src/lib/app-settings-descriptor.d.ts +1 -1
  140. package/dist/src/lib/app-settings-descriptor.js +6 -0
  141. package/dist/src/lib/app-settings-descriptor.js.map +1 -1
  142. package/dist/src/lib/auth-fixtures.d.ts +44 -0
  143. package/dist/src/lib/auth-fixtures.js +61 -0
  144. package/dist/src/lib/auth-fixtures.js.map +1 -0
  145. package/dist/src/lib/auth-flow.d.ts +34 -1
  146. package/dist/src/lib/auth-flow.js +429 -13
  147. package/dist/src/lib/auth-flow.js.map +1 -1
  148. package/dist/src/lib/block-layout.d.ts +12 -23
  149. package/dist/src/lib/block-layout.js +26 -92
  150. package/dist/src/lib/block-layout.js.map +1 -1
  151. package/dist/src/lib/block-selector.d.ts +8 -14
  152. package/dist/src/lib/block-selector.js +8 -19
  153. package/dist/src/lib/block-selector.js.map +1 -1
  154. package/dist/src/lib/child-apps-local.d.ts +3 -47
  155. package/dist/src/lib/child-apps-local.js +11 -73
  156. package/dist/src/lib/child-apps-local.js.map +1 -1
  157. package/dist/src/lib/cli-manifest.d.ts +9 -0
  158. package/dist/src/lib/cli-manifest.js +10 -1
  159. package/dist/src/lib/cli-manifest.js.map +1 -1
  160. package/dist/src/lib/cli-version.d.ts +14 -0
  161. package/dist/src/lib/cli-version.js +38 -0
  162. package/dist/src/lib/cli-version.js.map +1 -0
  163. package/dist/src/lib/codegen-shared/prettierStable.d.ts +41 -0
  164. package/dist/src/lib/codegen-shared/prettierStable.js +146 -24
  165. package/dist/src/lib/codegen-shared/prettierStable.js.map +1 -1
  166. package/dist/src/lib/collection-export.d.ts +76 -15
  167. package/dist/src/lib/collection-export.js +116 -23
  168. package/dist/src/lib/collection-export.js.map +1 -1
  169. package/dist/src/lib/collection-principal.d.ts +22 -0
  170. package/dist/src/lib/collection-principal.js +35 -0
  171. package/dist/src/lib/collection-principal.js.map +1 -0
  172. package/dist/src/lib/command-groups.d.ts +30 -0
  173. package/dist/src/lib/command-groups.js +109 -0
  174. package/dist/src/lib/command-groups.js.map +1 -0
  175. package/dist/src/lib/command-status.d.ts +147 -0
  176. package/dist/src/lib/command-status.js +266 -0
  177. package/dist/src/lib/command-status.js.map +1 -0
  178. package/dist/src/lib/config-object-descriptor.d.ts +9 -22
  179. package/dist/src/lib/config-object-descriptor.js +107 -276
  180. package/dist/src/lib/config-object-descriptor.js.map +1 -1
  181. package/dist/src/lib/config-surface.d.ts +3 -7
  182. package/dist/src/lib/config-surface.js +9 -13
  183. package/dist/src/lib/config-surface.js.map +1 -1
  184. package/dist/src/lib/config-toml.d.ts +11 -2
  185. package/dist/src/lib/config-toml.js +25 -2
  186. package/dist/src/lib/config-toml.js.map +1 -1
  187. package/dist/src/lib/credentials-home.d.ts +7 -0
  188. package/dist/src/lib/credentials-home.js +45 -10
  189. package/dist/src/lib/credentials-home.js.map +1 -1
  190. package/dist/src/lib/credentials-lock.d.ts +14 -6
  191. package/dist/src/lib/credentials-lock.js +90 -10
  192. package/dist/src/lib/credentials-lock.js.map +1 -1
  193. package/dist/src/lib/credentials-store.d.ts +123 -70
  194. package/dist/src/lib/credentials-store.js +358 -113
  195. package/dist/src/lib/credentials-store.js.map +1 -1
  196. package/dist/src/lib/custodian.d.ts +8 -0
  197. package/dist/src/lib/custodian.js +18 -0
  198. package/dist/src/lib/custodian.js.map +1 -0
  199. package/dist/src/lib/data-input.d.ts +1 -1
  200. package/dist/src/lib/data-input.js +1 -1
  201. package/dist/src/lib/db-codegen/dbTsTypes.d.ts +1 -1
  202. package/dist/src/lib/db-codegen/dbTsTypes.js +3 -0
  203. package/dist/src/lib/db-codegen/dbTsTypes.js.map +1 -1
  204. package/dist/src/lib/db-codegen/dbTypeIR.d.ts +38 -1
  205. package/dist/src/lib/db-codegen/dbTypeIR.js +29 -7
  206. package/dist/src/lib/db-codegen/dbTypeIR.js.map +1 -1
  207. package/dist/src/lib/db-type-records.d.ts +106 -0
  208. package/dist/src/lib/db-type-records.js +224 -0
  209. package/dist/src/lib/db-type-records.js.map +1 -0
  210. package/dist/src/lib/db3-export.d.ts +287 -0
  211. package/dist/src/lib/db3-export.js +647 -0
  212. package/dist/src/lib/db3-export.js.map +1 -0
  213. package/dist/src/lib/db3-index-output.d.ts +116 -0
  214. package/dist/src/lib/db3-index-output.js +223 -0
  215. package/dist/src/lib/db3-index-output.js.map +1 -0
  216. package/dist/src/lib/db3-type-models.d.ts +134 -0
  217. package/dist/src/lib/db3-type-models.js +452 -0
  218. package/dist/src/lib/db3-type-models.js.map +1 -0
  219. package/dist/src/lib/deprecation.d.ts +2 -2
  220. package/dist/src/lib/deprecation.js +2 -2
  221. package/dist/src/lib/document-ingest-artifact.d.ts +13 -0
  222. package/dist/src/lib/document-ingest-artifact.js +36 -6
  223. package/dist/src/lib/document-ingest-artifact.js.map +1 -1
  224. package/dist/src/lib/document-ingest-format2.d.ts +36 -0
  225. package/dist/src/lib/document-ingest-format2.js +78 -0
  226. package/dist/src/lib/document-ingest-format2.js.map +1 -0
  227. package/dist/src/lib/document-ingest-input.d.ts +9 -0
  228. package/dist/src/lib/document-ingest-input.js +28 -1
  229. package/dist/src/lib/document-ingest-input.js.map +1 -1
  230. package/dist/src/lib/document-ingest.d.ts +11 -1
  231. package/dist/src/lib/document-ingest.js +16 -0
  232. package/dist/src/lib/document-ingest.js.map +1 -1
  233. package/dist/src/lib/document-schema-rows.d.ts +42 -0
  234. package/dist/src/lib/document-schema-rows.js +53 -0
  235. package/dist/src/lib/document-schema-rows.js.map +1 -0
  236. package/dist/src/lib/experimental-apis.d.ts +36 -0
  237. package/dist/src/lib/experimental-apis.js +46 -0
  238. package/dist/src/lib/experimental-apis.js.map +1 -0
  239. package/dist/src/lib/file-attachment.d.ts +24 -0
  240. package/dist/src/lib/file-attachment.js +31 -0
  241. package/dist/src/lib/file-attachment.js.map +1 -0
  242. package/dist/src/lib/function-authorize-check.d.ts +142 -0
  243. package/dist/src/lib/function-authorize-check.js +311 -0
  244. package/dist/src/lib/function-authorize-check.js.map +1 -0
  245. package/dist/src/lib/function-authorize-view.d.ts +27 -0
  246. package/dist/src/lib/function-authorize-view.js +88 -0
  247. package/dist/src/lib/function-authorize-view.js.map +1 -0
  248. package/dist/src/lib/function-bundle.d.ts +27 -5
  249. package/dist/src/lib/function-bundle.js +142 -7
  250. package/dist/src/lib/function-bundle.js.map +1 -1
  251. package/dist/src/lib/function-collect.d.ts +90 -12
  252. package/dist/src/lib/function-collect.js +482 -12
  253. package/dist/src/lib/function-collect.js.map +1 -1
  254. package/dist/src/lib/function-db-types.d.ts +65 -11
  255. package/dist/src/lib/function-db-types.js +297 -157
  256. package/dist/src/lib/function-db-types.js.map +1 -1
  257. package/dist/src/lib/function-document-types.d.ts +19 -7
  258. package/dist/src/lib/function-document-types.js +24 -12
  259. package/dist/src/lib/function-document-types.js.map +1 -1
  260. package/dist/src/lib/function-lint.d.ts +57 -0
  261. package/dist/src/lib/function-lint.js +234 -0
  262. package/dist/src/lib/function-lint.js.map +1 -0
  263. package/dist/src/lib/function-log-row.js +21 -2
  264. package/dist/src/lib/function-log-row.js.map +1 -1
  265. package/dist/src/lib/function-run.d.ts +13 -21
  266. package/dist/src/lib/function-run.js +14 -27
  267. package/dist/src/lib/function-run.js.map +1 -1
  268. package/dist/src/lib/function-schema-codegen.d.ts +86 -22
  269. package/dist/src/lib/function-schema-codegen.js +194 -88
  270. package/dist/src/lib/function-schema-codegen.js.map +1 -1
  271. package/dist/src/lib/function-schema-refs.d.ts +98 -0
  272. package/dist/src/lib/function-schema-refs.js +177 -0
  273. package/dist/src/lib/function-schema-refs.js.map +1 -0
  274. package/dist/src/lib/function-sync.d.ts +109 -6
  275. package/dist/src/lib/function-sync.js +179 -26
  276. package/dist/src/lib/function-sync.js.map +1 -1
  277. package/dist/src/lib/function-trigger-listing.d.ts +11 -6
  278. package/dist/src/lib/function-trigger-listing.js +32 -11
  279. package/dist/src/lib/function-trigger-listing.js.map +1 -1
  280. package/dist/src/lib/function-triggers.d.ts +15 -3
  281. package/dist/src/lib/function-triggers.js +72 -10
  282. package/dist/src/lib/function-triggers.js.map +1 -1
  283. package/dist/src/lib/function-typecheck.d.ts +52 -0
  284. package/dist/src/lib/function-typecheck.js +174 -54
  285. package/dist/src/lib/function-typecheck.js.map +1 -1
  286. package/dist/src/lib/function-versions.d.ts +2 -0
  287. package/dist/src/lib/function-versions.js +1 -0
  288. package/dist/src/lib/function-versions.js.map +1 -1
  289. package/dist/src/lib/generated-build-flags.d.ts +13 -0
  290. package/dist/src/lib/generated-build-flags.js +14 -0
  291. package/dist/src/lib/generated-build-flags.js.map +1 -0
  292. package/dist/src/lib/generated-command-status.d.ts +6 -0
  293. package/dist/src/lib/generated-command-status.js +469 -0
  294. package/dist/src/lib/generated-command-status.js.map +1 -0
  295. package/dist/src/lib/generated-config-surfaces.d.ts +586 -152
  296. package/dist/src/lib/generated-config-surfaces.js +1919 -1883
  297. package/dist/src/lib/generated-config-surfaces.js.map +1 -1
  298. package/dist/src/lib/generated-sdk-types.d.ts +1 -1
  299. package/dist/src/lib/generated-sdk-types.js +1 -1
  300. package/dist/src/lib/generated-sdk-types.js.map +1 -1
  301. package/dist/src/lib/generated-workflow-model-fields.d.ts +20 -0
  302. package/dist/src/lib/generated-workflow-model-fields.js +53 -0
  303. package/dist/src/lib/generated-workflow-model-fields.js.map +1 -0
  304. package/dist/src/lib/hosting-build.d.ts +97 -0
  305. package/dist/src/lib/hosting-build.js +204 -0
  306. package/dist/src/lib/hosting-build.js.map +1 -0
  307. package/dist/src/lib/hosting-client.d.ts +167 -0
  308. package/dist/src/lib/hosting-client.js +340 -0
  309. package/dist/src/lib/hosting-client.js.map +1 -0
  310. package/dist/src/lib/hosting-environments.d.ts +32 -0
  311. package/dist/src/lib/hosting-environments.js +74 -0
  312. package/dist/src/lib/hosting-environments.js.map +1 -0
  313. package/dist/src/lib/hosting-errors.d.ts +30 -0
  314. package/dist/src/lib/hosting-errors.js +43 -0
  315. package/dist/src/lib/hosting-errors.js.map +1 -0
  316. package/dist/src/lib/hosting-token.d.ts +46 -0
  317. package/dist/src/lib/hosting-token.js +60 -0
  318. package/dist/src/lib/hosting-token.js.map +1 -0
  319. package/dist/src/lib/hosting-wait.d.ts +42 -0
  320. package/dist/src/lib/hosting-wait.js +84 -0
  321. package/dist/src/lib/hosting-wait.js.map +1 -0
  322. package/dist/src/lib/hosting-wfp-upload.d.ts +86 -0
  323. package/dist/src/lib/hosting-wfp-upload.js +149 -0
  324. package/dist/src/lib/hosting-wfp-upload.js.map +1 -0
  325. package/dist/src/lib/init-assets.d.ts +2 -6
  326. package/dist/src/lib/init-assets.js +11 -27
  327. package/dist/src/lib/init-assets.js.map +1 -1
  328. package/dist/src/lib/init-ios-links.d.ts +11 -7
  329. package/dist/src/lib/init-ios-links.js +28 -22
  330. package/dist/src/lib/init-ios-links.js.map +1 -1
  331. package/dist/src/lib/init-login-note.d.ts +13 -0
  332. package/dist/src/lib/init-login-note.js +22 -0
  333. package/dist/src/lib/init-login-note.js.map +1 -0
  334. package/dist/src/lib/init-schema.d.ts +15 -0
  335. package/dist/src/lib/init-schema.js +54 -0
  336. package/dist/src/lib/init-schema.js.map +1 -1
  337. package/dist/src/lib/integration-test-request.d.ts +54 -0
  338. package/dist/src/lib/integration-test-request.js +207 -0
  339. package/dist/src/lib/integration-test-request.js.map +1 -0
  340. package/dist/src/lib/invoker-shared-enums.d.ts +35 -0
  341. package/dist/src/lib/invoker-shared-enums.js +98 -0
  342. package/dist/src/lib/invoker-shared-enums.js.map +1 -0
  343. package/dist/src/lib/json-value.d.ts +6 -0
  344. package/dist/src/lib/json-value.js +13 -0
  345. package/dist/src/lib/json-value.js.map +1 -0
  346. package/dist/src/lib/load-routes.d.ts +33 -0
  347. package/dist/src/lib/load-routes.js +35 -0
  348. package/dist/src/lib/load-routes.js.map +1 -0
  349. package/dist/src/lib/log-inspection.d.ts +23 -4
  350. package/dist/src/lib/log-inspection.js +14 -5
  351. package/dist/src/lib/log-inspection.js.map +1 -1
  352. package/dist/src/lib/login-exchange-check.d.ts +18 -0
  353. package/dist/src/lib/login-exchange-check.js +27 -0
  354. package/dist/src/lib/login-exchange-check.js.map +1 -0
  355. package/dist/src/lib/login-scope-lines.d.ts +17 -7
  356. package/dist/src/lib/login-scope-lines.js +33 -10
  357. package/dist/src/lib/login-scope-lines.js.map +1 -1
  358. package/dist/src/lib/metadata-report.d.ts +85 -0
  359. package/dist/src/lib/metadata-report.js +81 -0
  360. package/dist/src/lib/metadata-report.js.map +1 -0
  361. package/dist/src/lib/object-status-filter.d.ts +9 -1
  362. package/dist/src/lib/object-status-filter.js +9 -1
  363. package/dist/src/lib/object-status-filter.js.map +1 -1
  364. package/dist/src/lib/output.d.ts +1 -1
  365. package/dist/src/lib/output.js +3 -1
  366. package/dist/src/lib/output.js.map +1 -1
  367. package/dist/src/lib/pin-refusal-hint.d.ts +12 -0
  368. package/dist/src/lib/pin-refusal-hint.js +35 -0
  369. package/dist/src/lib/pin-refusal-hint.js.map +1 -0
  370. package/dist/src/lib/platform-owned.js +5 -0
  371. package/dist/src/lib/platform-owned.js.map +1 -1
  372. package/dist/src/lib/primitive-declaration-names.d.ts +21 -0
  373. package/dist/src/lib/primitive-declaration-names.js +22 -0
  374. package/dist/src/lib/primitive-declaration-names.js.map +1 -0
  375. package/dist/src/lib/primitive-declaration.d.ts +174 -0
  376. package/dist/src/lib/primitive-declaration.js +792 -0
  377. package/dist/src/lib/primitive-declaration.js.map +1 -0
  378. package/dist/src/lib/primitive-env-plugin.d.ts +99 -0
  379. package/dist/src/lib/primitive-env-plugin.js +408 -0
  380. package/dist/src/lib/primitive-env-plugin.js.map +1 -0
  381. package/dist/src/lib/project-login-apps.d.ts +8 -0
  382. package/dist/src/lib/project-login-apps.js +27 -0
  383. package/dist/src/lib/project-login-apps.js.map +1 -0
  384. package/dist/src/lib/prompt-schema-codegen.d.ts +46 -15
  385. package/dist/src/lib/prompt-schema-codegen.js +142 -108
  386. package/dist/src/lib/prompt-schema-codegen.js.map +1 -1
  387. package/dist/src/lib/prompt-schema-document.d.ts +35 -0
  388. package/dist/src/lib/prompt-schema-document.js +92 -0
  389. package/dist/src/lib/prompt-schema-document.js.map +1 -0
  390. package/dist/src/lib/prompt-schema-refs.d.ts +173 -0
  391. package/dist/src/lib/prompt-schema-refs.js +478 -0
  392. package/dist/src/lib/prompt-schema-refs.js.map +1 -0
  393. package/dist/src/lib/records-verbs.d.ts +79 -0
  394. package/dist/src/lib/records-verbs.js +45 -0
  395. package/dist/src/lib/records-verbs.js.map +1 -0
  396. package/dist/src/lib/register-commands.d.ts +36 -0
  397. package/dist/src/lib/register-commands.js +37 -0
  398. package/dist/src/lib/register-commands.js.map +1 -0
  399. package/dist/src/lib/retired-imports.d.ts +53 -0
  400. package/dist/src/lib/retired-imports.js +120 -0
  401. package/dist/src/lib/retired-imports.js.map +1 -0
  402. package/dist/src/lib/run-status.d.ts +1 -1
  403. package/dist/src/lib/run-status.generated.d.ts +2 -2
  404. package/dist/src/lib/run-status.generated.js +3 -1
  405. package/dist/src/lib/run-status.generated.js.map +1 -1
  406. package/dist/src/lib/run-status.js +1 -1
  407. package/dist/src/lib/schema-codegen/compiledSpace.d.ts +62 -0
  408. package/dist/src/lib/schema-codegen/compiledSpace.js +103 -0
  409. package/dist/src/lib/schema-codegen/compiledSpace.js.map +1 -0
  410. package/dist/src/lib/schema-codegen/generated-db3-bridge.d.ts +86 -0
  411. package/dist/src/lib/schema-codegen/generated-db3-bridge.js +227 -0
  412. package/dist/src/lib/schema-codegen/generated-db3-bridge.js.map +1 -0
  413. package/dist/src/lib/schema-codegen/generated-db3-query-capabilities.d.ts +85 -0
  414. package/dist/src/lib/schema-codegen/generated-db3-query-capabilities.js +86 -0
  415. package/dist/src/lib/schema-codegen/generated-db3-query-capabilities.js.map +1 -0
  416. package/dist/src/lib/schema-codegen/generated-field-grammar.d.ts +218 -0
  417. package/dist/src/lib/schema-codegen/generated-field-grammar.js +397 -0
  418. package/dist/src/lib/schema-codegen/generated-field-grammar.js.map +1 -0
  419. package/dist/src/lib/schema-codegen/generated-field-table.d.ts +80 -0
  420. package/dist/src/lib/schema-codegen/generated-field-table.js +542 -0
  421. package/dist/src/lib/schema-codegen/generated-field-table.js.map +1 -0
  422. package/dist/src/lib/schema-codegen/generated-prompt-schemas.d.ts +195 -0
  423. package/dist/src/lib/schema-codegen/generated-prompt-schemas.js +503 -0
  424. package/dist/src/lib/schema-codegen/generated-prompt-schemas.js.map +1 -0
  425. package/dist/src/lib/schema-codegen/generated-schema-descriptor.d.ts +258 -0
  426. package/dist/src/lib/schema-codegen/generated-schema-descriptor.js +422 -0
  427. package/dist/src/lib/schema-codegen/generated-schema-descriptor.js.map +1 -0
  428. package/dist/src/lib/schema-codegen/generated-schema-file.d.ts +129 -0
  429. package/dist/src/lib/schema-codegen/generated-schema-file.js +475 -0
  430. package/dist/src/lib/schema-codegen/generated-schema-file.js.map +1 -0
  431. package/dist/src/lib/schema-codegen/generated-schema-provenance.d.ts +115 -0
  432. package/dist/src/lib/schema-codegen/generated-schema-provenance.js +274 -0
  433. package/dist/src/lib/schema-codegen/generated-schema-provenance.js.map +1 -0
  434. package/dist/src/lib/schema-codegen/generated-schema-refs.d.ts +366 -0
  435. package/dist/src/lib/schema-codegen/generated-schema-refs.js +1789 -0
  436. package/dist/src/lib/schema-codegen/generated-schema-refs.js.map +1 -0
  437. package/dist/src/lib/schema-codegen/generated-schema-shape.d.ts +27 -0
  438. package/dist/src/lib/schema-codegen/generated-schema-shape.js +126 -0
  439. package/dist/src/lib/schema-codegen/generated-schema-shape.js.map +1 -0
  440. package/dist/src/lib/schema-codegen/namedRefs.d.ts +56 -0
  441. package/dist/src/lib/schema-codegen/namedRefs.js +143 -0
  442. package/dist/src/lib/schema-codegen/namedRefs.js.map +1 -0
  443. package/dist/src/lib/schema-codegen/naming.d.ts +35 -0
  444. package/dist/src/lib/schema-codegen/naming.js +83 -0
  445. package/dist/src/lib/schema-codegen/naming.js.map +1 -0
  446. package/dist/src/lib/schema-codegen/schemaChanges.d.ts +74 -0
  447. package/dist/src/lib/schema-codegen/schemaChanges.js +277 -0
  448. package/dist/src/lib/schema-codegen/schemaChanges.js.map +1 -0
  449. package/dist/src/lib/schema-codegen/schemaDocs.d.ts +69 -0
  450. package/dist/src/lib/schema-codegen/schemaDocs.js +219 -0
  451. package/dist/src/lib/schema-codegen/schemaDocs.js.map +1 -0
  452. package/dist/src/lib/schema-codegen/schemaIR.d.ts +158 -0
  453. package/dist/src/lib/schema-codegen/schemaIR.js +279 -0
  454. package/dist/src/lib/schema-codegen/schemaIR.js.map +1 -0
  455. package/dist/src/lib/schema-codegen/schemaToTs.d.ts +109 -0
  456. package/dist/src/lib/schema-codegen/schemaToTs.js +269 -0
  457. package/dist/src/lib/schema-codegen/schemaToTs.js.map +1 -0
  458. package/dist/src/lib/schema-codegen/valuesLists.d.ts +48 -0
  459. package/dist/src/lib/schema-codegen/valuesLists.js +144 -0
  460. package/dist/src/lib/schema-codegen/valuesLists.js.map +1 -0
  461. package/dist/src/lib/schema-family-index.d.ts +228 -0
  462. package/dist/src/lib/schema-family-index.js +813 -0
  463. package/dist/src/lib/schema-family-index.js.map +1 -0
  464. package/dist/src/lib/schema-pins.d.ts +82 -0
  465. package/dist/src/lib/schema-pins.js +198 -0
  466. package/dist/src/lib/schema-pins.js.map +1 -0
  467. package/dist/src/lib/schema-preview.d.ts +244 -0
  468. package/dist/src/lib/schema-preview.js +498 -0
  469. package/dist/src/lib/schema-preview.js.map +1 -0
  470. package/dist/src/lib/scope-request.d.ts +23 -11
  471. package/dist/src/lib/scope-request.js +69 -31
  472. package/dist/src/lib/scope-request.js.map +1 -1
  473. package/dist/src/lib/session-scope.d.ts +26 -0
  474. package/dist/src/lib/session-scope.js +58 -0
  475. package/dist/src/lib/session-scope.js.map +1 -0
  476. package/dist/src/lib/skill-installer.d.ts +2 -2
  477. package/dist/src/lib/skill-installer.js +2 -21
  478. package/dist/src/lib/skill-installer.js.map +1 -1
  479. package/dist/src/lib/step-run-table.d.ts +1 -2
  480. package/dist/src/lib/step-run-table.js +1 -2
  481. package/dist/src/lib/step-run-table.js.map +1 -1
  482. package/dist/src/lib/swift-codegen/agentGenerator.d.ts +8 -3
  483. package/dist/src/lib/swift-codegen/agentGenerator.js +76 -22
  484. package/dist/src/lib/swift-codegen/agentGenerator.js.map +1 -1
  485. package/dist/src/lib/swift-codegen/banners.d.ts +12 -0
  486. package/dist/src/lib/swift-codegen/banners.js +12 -0
  487. package/dist/src/lib/swift-codegen/banners.js.map +1 -1
  488. package/dist/src/lib/swift-codegen/functionGenerator.d.ts +36 -1
  489. package/dist/src/lib/swift-codegen/functionGenerator.js +169 -51
  490. package/dist/src/lib/swift-codegen/functionGenerator.js.map +1 -1
  491. package/dist/src/lib/swift-codegen/schemaToSwift.d.ts +33 -9
  492. package/dist/src/lib/swift-codegen/schemaToSwift.js +215 -179
  493. package/dist/src/lib/swift-codegen/schemaToSwift.js.map +1 -1
  494. package/dist/src/lib/swift-codegen/sharedGenerator.d.ts +45 -0
  495. package/dist/src/lib/swift-codegen/sharedGenerator.js +165 -0
  496. package/dist/src/lib/swift-codegen/sharedGenerator.js.map +1 -0
  497. package/dist/src/lib/swift-codegen/swiftKeys.d.ts +19 -0
  498. package/dist/src/lib/swift-codegen/swiftKeys.js +31 -0
  499. package/dist/src/lib/swift-codegen/swiftKeys.js.map +1 -0
  500. package/dist/src/lib/swift-codegen/userPropertiesGenerator.d.ts +30 -0
  501. package/dist/src/lib/swift-codegen/userPropertiesGenerator.js +69 -0
  502. package/dist/src/lib/swift-codegen/userPropertiesGenerator.js.map +1 -0
  503. package/dist/src/lib/sync-resource-types.d.ts +117 -31
  504. package/dist/src/lib/sync-resource-types.js +197 -189
  505. package/dist/src/lib/sync-resource-types.js.map +1 -1
  506. package/dist/src/lib/sync-selectors.d.ts +7 -0
  507. package/dist/src/lib/sync-selectors.js +22 -2
  508. package/dist/src/lib/sync-selectors.js.map +1 -1
  509. package/dist/src/lib/template.d.ts +39 -3
  510. package/dist/src/lib/template.js +103 -14
  511. package/dist/src/lib/template.js.map +1 -1
  512. package/dist/src/lib/test-case-file-names.d.ts +3 -5
  513. package/dist/src/lib/test-case-file-names.js +3 -5
  514. package/dist/src/lib/test-case-file-names.js.map +1 -1
  515. package/dist/src/lib/test-runs.d.ts +45 -0
  516. package/dist/src/lib/test-runs.js +150 -0
  517. package/dist/src/lib/test-runs.js.map +1 -0
  518. package/dist/src/lib/test-users.d.ts +25 -0
  519. package/dist/src/lib/test-users.js +36 -0
  520. package/dist/src/lib/test-users.js.map +1 -0
  521. package/dist/src/lib/toml-database-config.d.ts +4 -2
  522. package/dist/src/lib/toml-database-config.js +11 -6
  523. package/dist/src/lib/toml-database-config.js.map +1 -1
  524. package/dist/src/lib/toml-scalar-edit.js +6 -4
  525. package/dist/src/lib/toml-scalar-edit.js.map +1 -1
  526. package/dist/src/lib/transition-warnings.d.ts +21 -0
  527. package/dist/src/lib/transition-warnings.js +49 -0
  528. package/dist/src/lib/transition-warnings.js.map +1 -0
  529. package/dist/src/lib/user-index.d.ts +80 -0
  530. package/dist/src/lib/user-index.js +166 -0
  531. package/dist/src/lib/user-index.js.map +1 -0
  532. package/dist/src/lib/user-properties/generated-properties-schema.d.ts +159 -0
  533. package/dist/src/lib/user-properties/generated-properties-schema.js +471 -0
  534. package/dist/src/lib/user-properties/generated-properties-schema.js.map +1 -0
  535. package/dist/src/lib/user-properties/user-properties-codegen.d.ts +55 -0
  536. package/dist/src/lib/user-properties/user-properties-codegen.js +129 -0
  537. package/dist/src/lib/user-properties/user-properties-codegen.js.map +1 -0
  538. package/dist/src/lib/user-walk.d.ts +31 -0
  539. package/dist/src/lib/user-walk.js +102 -0
  540. package/dist/src/lib/user-walk.js.map +1 -0
  541. package/dist/src/lib/webhook-capture.d.ts +43 -0
  542. package/dist/src/lib/webhook-capture.js +91 -0
  543. package/dist/src/lib/webhook-capture.js.map +1 -0
  544. package/dist/src/lib/webhook-deliver.d.ts +18 -20
  545. package/dist/src/lib/webhook-deliver.js +34 -89
  546. package/dist/src/lib/webhook-deliver.js.map +1 -1
  547. package/dist/src/lib/webhook-test-run.d.ts +32 -0
  548. package/dist/src/lib/webhook-test-run.js +108 -0
  549. package/dist/src/lib/webhook-test-run.js.map +1 -0
  550. package/dist/src/lib/worker-perf-format.d.ts +22 -0
  551. package/dist/src/lib/worker-perf-format.js +27 -0
  552. package/dist/src/lib/worker-perf-format.js.map +1 -0
  553. package/dist/src/lib/workflow-field-descriptor.d.ts +91 -0
  554. package/dist/src/lib/workflow-field-descriptor.js +153 -0
  555. package/dist/src/lib/workflow-field-descriptor.js.map +1 -0
  556. package/dist/src/types/index.d.ts +20 -65
  557. package/dist/src/validators.d.ts +7 -55
  558. package/dist/src/validators.js +7 -53
  559. package/dist/src/validators.js.map +1 -1
  560. package/dist/src/vite.d.ts +17 -0
  561. package/dist/src/vite.js +18 -0
  562. package/dist/src/vite.js.map +1 -0
  563. package/package.json +20 -9
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hosting-token.js","sourceRoot":"","sources":["../../../src/lib/hosting-token.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,uEAAuE;AACvE,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,GAAG,MAAM,CAAC;AAqB7C,qDAAqD;AACrD,MAAM,OAAO,oBAAoB;IAOF;IANrB,OAAO,GAAwB,IAAI,CAAC;IACpC,OAAO,GAAiC,IAAI,CAAC;IAC7C,IAAI,GAAgB,OAAO,CAAC;IACnB,GAAG,CAAe;IAEnC,wEAAwE;IACxE,YAA6B,OAA6B;QAA7B,YAAO,GAAP,OAAO,CAAsB;QACxD,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC;IACrC,CAAC;IAED,yEAAyE;IACzE,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;IACjD,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,KAAK;QACT,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO;YAAE,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC;QACtD,IAAI,IAAI,CAAC,OAAO,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,OAAO,EAAE,GAAG,IAAI,CAAC,GAAG,EAAE,IAAI,kBAAkB,EAAE,CAAC;YAClG,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC;QAClC,CAAC;QACD,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC;YAClB,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;YACvB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO;iBACxB,MAAM,CAAC,IAAI,CAAC;iBACZ,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE;gBAChB,IAAI,IAAI,CAAC,IAAI,KAAK,IAAI;oBAAE,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;gBAC/C,OAAO,OAAO,CAAC;YACjB,CAAC,CAAC;iBACD,OAAO,CAAC,GAAG,EAAE;gBACZ,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;YACtB,CAAC,CAAC,CAAC;QACP,CAAC;QACD,OAAO,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC;IAC1C,CAAC;IAED,8EAA8E;IAC9E,SAAS;QACP,IAAI,CAAC,IAAI,GAAG,SAAS,CAAC;QACtB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;QACpB,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC;IACtB,CAAC;CACF"}
@@ -0,0 +1,42 @@
1
+ /** The header every answer produced from an active deployment carries. */
2
+ export declare const DEPLOY_HEADER = "x-primitive-hosting-deploy";
3
+ /** How long a command waits for the origin to serve a deployment. */
4
+ export declare const SERVE_TIMEOUT_MS = 120000;
5
+ /** Time between two probes of the origin. */
6
+ export declare const SERVE_INTERVAL_MS = 1000;
7
+ /** One probe's answer: its status and the deployment id it carried, if any. */
8
+ export interface ProbeAnswer {
9
+ status: number;
10
+ deployId: string | null;
11
+ }
12
+ /** What {@link waitUntilServed} needs. */
13
+ export interface WaitOptions {
14
+ /** The origin being probed, for the timeout's message. */
15
+ origin: string;
16
+ /** The deployment the origin must serve. */
17
+ deployId: string;
18
+ /**
19
+ * One `HEAD <origin>/`; a thrown error counts as no answer. The signal is
20
+ * aborted when the wait's deadline passes while the probe is in flight.
21
+ */
22
+ probe: (signal: AbortSignal) => Promise<ProbeAnswer>;
23
+ /** How long to wait in all; 120 s by default. */
24
+ timeoutMs?: number;
25
+ /** Time between probes; 1 s by default. */
26
+ intervalMs?: number;
27
+ /** The clock; `Date.now` by default. */
28
+ now?: () => number;
29
+ /** Waits `ms`; a timer by default. */
30
+ sleep?: (ms: number) => Promise<void>;
31
+ }
32
+ /**
33
+ * Polls until the origin serves `deployId`. Each probe is bounded by the
34
+ * time left before `timeoutMs`, and an answer that arrives after the
35
+ * deadline is not accepted, so the wait never succeeds or runs past it.
36
+ *
37
+ * @param options The origin, the deployment, the probe and the clock.
38
+ * @returns The answer that showed the deployment served.
39
+ * @throws HostingError `activation_timeout` once `timeoutMs` have passed,
40
+ * carrying the last answer in `details`.
41
+ */
42
+ export declare function waitUntilServed(options: WaitOptions): Promise<ProbeAnswer>;
@@ -0,0 +1,84 @@
1
+ /**
2
+ * How `primitive hosting deploy` and `activate` know the origin serves a
3
+ * deployment: they poll `HEAD <origin>/` until an answer carries the
4
+ * deployment's id in `x-primitive-hosting-deploy` with a status below 500.
5
+ * A 5xx carrying the id (the dispatcher's storage-unavailable 503) is not
6
+ * served.
7
+ */
8
+ import { HostingError } from "./hosting-errors.js";
9
+ /** The header every answer produced from an active deployment carries. */
10
+ export const DEPLOY_HEADER = "x-primitive-hosting-deploy";
11
+ /** How long a command waits for the origin to serve a deployment. */
12
+ export const SERVE_TIMEOUT_MS = 120_000;
13
+ /** Time between two probes of the origin. */
14
+ export const SERVE_INTERVAL_MS = 1_000;
15
+ function seconds(ms) {
16
+ return `${Math.round(ms / 100) / 10} s`;
17
+ }
18
+ /** A probe cut off by the wait's deadline: not an answer, so the last real answer stands. */
19
+ class DeadlinePassed extends Error {
20
+ }
21
+ /**
22
+ * Runs one probe, bounded by what is left of the wait: when `remainingMs`
23
+ * pass first, the probe's signal is aborted and the probe counts as no answer.
24
+ */
25
+ async function boundedProbe(probe, remainingMs) {
26
+ const controller = new AbortController();
27
+ let timer;
28
+ const expired = new Promise((_, reject) => {
29
+ timer = setTimeout(() => {
30
+ controller.abort();
31
+ reject(new DeadlinePassed("no answer before the wait's deadline"));
32
+ }, Math.max(0, remainingMs));
33
+ });
34
+ const probing = probe(controller.signal);
35
+ // A probe that settles after the deadline won must not surface as an unhandled rejection.
36
+ probing.catch(() => undefined);
37
+ try {
38
+ return await Promise.race([probing, expired]);
39
+ }
40
+ finally {
41
+ clearTimeout(timer);
42
+ }
43
+ }
44
+ /**
45
+ * Polls until the origin serves `deployId`. Each probe is bounded by the
46
+ * time left before `timeoutMs`, and an answer that arrives after the
47
+ * deadline is not accepted, so the wait never succeeds or runs past it.
48
+ *
49
+ * @param options The origin, the deployment, the probe and the clock.
50
+ * @returns The answer that showed the deployment served.
51
+ * @throws HostingError `activation_timeout` once `timeoutMs` have passed,
52
+ * carrying the last answer in `details`.
53
+ */
54
+ export async function waitUntilServed(options) {
55
+ const { origin, deployId, probe, timeoutMs = SERVE_TIMEOUT_MS, intervalMs = SERVE_INTERVAL_MS, now = Date.now, sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms)), } = options;
56
+ const started = now();
57
+ let last = null;
58
+ let lastError = null;
59
+ for (;;) {
60
+ try {
61
+ const answer = await boundedProbe(probe, timeoutMs - (now() - started));
62
+ last = answer;
63
+ lastError = null;
64
+ const servedInTime = now() - started <= timeoutMs;
65
+ if (servedInTime && answer.deployId === deployId && answer.status < 500)
66
+ return answer;
67
+ }
68
+ catch (err) {
69
+ if (!(err instanceof DeadlinePassed && (last || lastError))) {
70
+ last = null;
71
+ lastError = err instanceof Error ? err.message : String(err);
72
+ }
73
+ }
74
+ const elapsed = now() - started;
75
+ if (elapsed >= timeoutMs)
76
+ break;
77
+ await sleep(Math.min(intervalMs, timeoutMs - elapsed));
78
+ }
79
+ const lastAnswer = last
80
+ ? `${last.status} ${last.deployId ? `from deployment ${last.deployId}` : "with no deployment id"}`
81
+ : `no answer (${lastError ?? "unknown error"})`;
82
+ throw new HostingError("activation_timeout", `Deployment ${deployId} is active in the registry, but ${origin} did not serve it within ${seconds(timeoutMs)}; it last answered ${lastAnswer}. Check it with 'primitive hosting get'.`, undefined, { deployId, origin, lastStatus: last?.status ?? null, lastDeployId: last?.deployId ?? null });
83
+ }
84
+ //# sourceMappingURL=hosting-wait.js.map
@@ -0,0 +1 @@
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AM,CAAC,GAAG,CAAC,CAAC;YAC/D,CAAC;QACH,CAAC;QACD,MAAM,OAAO,GAAG,GAAG,EAAE,GAAG,OAAO,CAAC;QAChC,IAAI,OAAO,IAAI,SAAS;YAAE,MAAM;QAChC,MAAM,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,SAAS,GAAG,OAAO,CAAC,CAAC,CAAC;IACzD,CAAC;IACD,MAAM,UAAU,GAAG,IAAI;QACrB,CAAC,CAAC,GAAG,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,mBAAmB,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,uBAAuB,EAAE;QAClG,CAAC,CAAC,cAAc,SAAS,IAAI,eAAe,GAAG,CAAC;IAClD,MAAM,IAAI,YAAY,CACpB,oBAAoB,EACpB,cAAc,QAAQ,mCAAmC,MAAM,4BAA4B,OAAO,CAAC,SAAS,CAAC,sBAAsB,UAAU,0CAA0C,EACvL,SAAS,EACT,EAAE,QAAQ,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,IAAI,IAAI,EAAE,YAAY,EAAE,IAAI,EAAE,QAAQ,IAAI,IAAI,EAAE,CAC7F,CAAC;AACJ,CAAC"}
@@ -0,0 +1,86 @@
1
+ import type { BuildFile } from "./hosting-build.js";
2
+ /** A file the hosting service uploads beside the build's (its version marker). */
3
+ export interface PlatformFile {
4
+ /** The file's 32-hex hash, as the buckets name it. */
5
+ hash: string;
6
+ contentType: string;
7
+ /** The file's bytes, base64. */
8
+ base64: string;
9
+ }
10
+ /** A create's `upload` answer on `wfp`. */
11
+ export interface UploadSession {
12
+ url: string;
13
+ token: string;
14
+ /** Groups of 32-hex hashes, each uploaded in one request. */
15
+ buckets: string[][];
16
+ platformFiles: PlatformFile[];
17
+ }
18
+ /** Buckets uploaded at once. */
19
+ export declare const BUCKET_CONCURRENCY = 3;
20
+ /** Retries of one bucket after a network failure or a 5xx. */
21
+ export declare const BUCKET_RETRIES = 3;
22
+ /**
23
+ * Refuses an upload URL that is not Cloudflare's API, before any byte or the
24
+ * session token is sent.
25
+ *
26
+ * @param url The create answer's `upload.url`.
27
+ * @throws HostingError `upload_target_invalid`.
28
+ */
29
+ export declare function checkUploadTarget(url: string): void;
30
+ /**
31
+ * Whether a failed bucket upload is tried again: after a network failure or
32
+ * a 5xx, never after a 4xx.
33
+ *
34
+ * @param failure The answer's status, or that there was none.
35
+ * @returns True to retry.
36
+ */
37
+ export declare function shouldRetryUpload(failure: {
38
+ status: number;
39
+ } | {
40
+ network: true;
41
+ }): boolean;
42
+ /** One field of a bucket: a build file read from disk, or a platform file's bytes. */
43
+ export type BucketPart = {
44
+ name: string;
45
+ contentType: string;
46
+ file: BuildFile;
47
+ } | {
48
+ name: string;
49
+ contentType: string;
50
+ base64: string;
51
+ };
52
+ /**
53
+ * The fields of one bucket, one per hash: the build file holding it, else
54
+ * the platform file the session listed. The same bytes at two paths are one
55
+ * field.
56
+ *
57
+ * @param bucket The bucket's 32-hex hashes.
58
+ * @param files The build's files.
59
+ * @param platformFiles The session's platform files.
60
+ * @returns The bucket's fields, in the bucket's order.
61
+ * @throws HostingError `hosting_error` when a hash matches neither.
62
+ */
63
+ export declare function bucketParts(bucket: readonly string[], files: readonly BuildFile[], platformFiles: readonly PlatformFile[]): BucketPart[];
64
+ /**
65
+ * One bucket as Cloudflare's upload takes it: a field per hash, named by
66
+ * the hash, holding the file's base64 with its content type.
67
+ *
68
+ * @param parts The bucket's fields ({@link bucketParts}).
69
+ * @returns The multipart form.
70
+ */
71
+ export declare function bucketForm(parts: readonly BucketPart[]): Promise<FormData>;
72
+ /**
73
+ * Uploads every bucket of the session, {@link BUCKET_CONCURRENCY} at a time.
74
+ * Every bucket is checked against the build before the first is sent.
75
+ *
76
+ * @param session The create's `upload` answer; its URL is not checked here ({@link checkUploadTarget}).
77
+ * @param files The build's files.
78
+ * @param options `sleep` replaces the pause between retries.
79
+ * @returns How many files were uploaded.
80
+ * @throws HostingError `upload_session_expired`, `upload_refused`, `upload_failed` or `hosting_error`.
81
+ */
82
+ export declare function uploadBuckets(session: UploadSession, files: readonly BuildFile[], options?: {
83
+ sleep?: (ms: number) => Promise<void>;
84
+ }): Promise<{
85
+ uploaded: number;
86
+ }>;
@@ -0,0 +1,149 @@
1
+ /**
2
+ * How `primitive hosting deploy` uploads a build on the `wfp` backend: the
3
+ * create answers an `upload` session (Cloudflare's upload URL, a session
4
+ * token valid one hour, and the buckets of files the app's user Worker
5
+ * lacks), and the CLI sends each bucket straight to Cloudflare as base64
6
+ * multipart, three buckets at a time. The session token is sent only to
7
+ * `https://api.cloudflare.com` and never printed.
8
+ */
9
+ import { readFile } from "fs/promises";
10
+ import { hostingFetch } from "./hosting-client.js";
11
+ import { HostingError } from "./hosting-errors.js";
12
+ /** Buckets uploaded at once. */
13
+ export const BUCKET_CONCURRENCY = 3;
14
+ /** Retries of one bucket after a network failure or a 5xx. */
15
+ export const BUCKET_RETRIES = 3;
16
+ /** How long one bucket upload may take. */
17
+ const BUCKET_TIMEOUT_MS = 120_000;
18
+ /**
19
+ * Refuses an upload URL that is not Cloudflare's API, before any byte or the
20
+ * session token is sent.
21
+ *
22
+ * @param url The create answer's `upload.url`.
23
+ * @throws HostingError `upload_target_invalid`.
24
+ */
25
+ export function checkUploadTarget(url) {
26
+ let target;
27
+ try {
28
+ target = new URL(url);
29
+ }
30
+ catch {
31
+ target = null;
32
+ }
33
+ const ok = target !== null && target.protocol === "https:" && target.host === "api.cloudflare.com" && !target.username && !target.password;
34
+ if (!ok) {
35
+ throw new HostingError("upload_target_invalid", "The hosting service named an upload target that is not https://api.cloudflare.com, so nothing was uploaded. Check that PRIMITIVE_HOSTING_URL points at a Primitive hosting service.");
36
+ }
37
+ }
38
+ /**
39
+ * Whether a failed bucket upload is tried again: after a network failure or
40
+ * a 5xx, never after a 4xx.
41
+ *
42
+ * @param failure The answer's status, or that there was none.
43
+ * @returns True to retry.
44
+ */
45
+ export function shouldRetryUpload(failure) {
46
+ return "network" in failure || failure.status >= 500;
47
+ }
48
+ /**
49
+ * The fields of one bucket, one per hash: the build file holding it, else
50
+ * the platform file the session listed. The same bytes at two paths are one
51
+ * field.
52
+ *
53
+ * @param bucket The bucket's 32-hex hashes.
54
+ * @param files The build's files.
55
+ * @param platformFiles The session's platform files.
56
+ * @returns The bucket's fields, in the bucket's order.
57
+ * @throws HostingError `hosting_error` when a hash matches neither.
58
+ */
59
+ export function bucketParts(bucket, files, platformFiles) {
60
+ const byHash = new Map();
61
+ for (const file of files)
62
+ if (!byHash.has(file.sha256.slice(0, 32)))
63
+ byHash.set(file.sha256.slice(0, 32), file);
64
+ return bucket.map((hash) => {
65
+ const file = byHash.get(hash);
66
+ if (file)
67
+ return { name: hash, contentType: file.contentType, file };
68
+ const platform = platformFiles.find((p) => p.hash === hash);
69
+ if (platform)
70
+ return { name: hash, contentType: platform.contentType, base64: platform.base64 };
71
+ throw new HostingError("hosting_error", `The hosting service asked for a file the build does not hold (${hash}).`);
72
+ });
73
+ }
74
+ /**
75
+ * One bucket as Cloudflare's upload takes it: a field per hash, named by
76
+ * the hash, holding the file's base64 with its content type.
77
+ *
78
+ * @param parts The bucket's fields ({@link bucketParts}).
79
+ * @returns The multipart form.
80
+ */
81
+ export async function bucketForm(parts) {
82
+ const form = new FormData();
83
+ for (const part of parts) {
84
+ const base64 = "file" in part ? (await readFile(part.file.absolutePath)).toString("base64") : part.base64;
85
+ form.append(part.name, new Blob([base64], { type: part.contentType }), part.name);
86
+ }
87
+ return form;
88
+ }
89
+ /** Waits `ms`. */
90
+ const pause = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
91
+ /** Uploads one bucket, retried as {@link shouldRetryUpload} says. */
92
+ async function uploadBucket(session, parts, sleep) {
93
+ const form = await bucketForm(parts);
94
+ const encoded = new Response(form);
95
+ const contentType = encoded.headers.get("content-type");
96
+ const body = Buffer.from(await encoded.arrayBuffer());
97
+ let last = "";
98
+ let attempts = 0;
99
+ for (let attempt = 0; attempt <= BUCKET_RETRIES; attempt++) {
100
+ if (attempt > 0)
101
+ await sleep(250 * attempt);
102
+ attempts++;
103
+ let status;
104
+ try {
105
+ status = (await hostingFetch(session.url, {
106
+ method: "POST",
107
+ headers: { Authorization: `Bearer ${session.token}`, "Content-Type": contentType },
108
+ body,
109
+ timeoutMs: BUCKET_TIMEOUT_MS,
110
+ })).status;
111
+ }
112
+ catch (err) {
113
+ last = `a network error (${err instanceof Error ? err.message : String(err)})`;
114
+ continue;
115
+ }
116
+ if (status >= 200 && status < 300)
117
+ return;
118
+ if (status === 401 || status === 403) {
119
+ throw new HostingError("upload_session_expired", "The upload session expired or was not accepted. Run the deploy again: it opens a new session and uploads what is still missing.", status);
120
+ }
121
+ if (!shouldRetryUpload({ status })) {
122
+ throw new HostingError("upload_refused", `The hosting backend refused an upload with ${status}. Nothing was activated; run the deploy again.`, status);
123
+ }
124
+ last = `${status}`;
125
+ }
126
+ throw new HostingError("upload_failed", `Could not upload ${parts.length} file(s) after ${BUCKET_RETRIES} retries: the last attempt ended with ${last}. Nothing was activated; run the deploy again to upload what is still missing.`, undefined, { attempts });
127
+ }
128
+ /**
129
+ * Uploads every bucket of the session, {@link BUCKET_CONCURRENCY} at a time.
130
+ * Every bucket is checked against the build before the first is sent.
131
+ *
132
+ * @param session The create's `upload` answer; its URL is not checked here ({@link checkUploadTarget}).
133
+ * @param files The build's files.
134
+ * @param options `sleep` replaces the pause between retries.
135
+ * @returns How many files were uploaded.
136
+ * @throws HostingError `upload_session_expired`, `upload_refused`, `upload_failed` or `hosting_error`.
137
+ */
138
+ export async function uploadBuckets(session, files, options = {}) {
139
+ const queue = session.buckets.map((bucket) => bucketParts(bucket, files, session.platformFiles ?? []));
140
+ const sleep = options.sleep ?? pause;
141
+ let next = 0;
142
+ const worker = async () => {
143
+ while (next < queue.length)
144
+ await uploadBucket(session, queue[next++], sleep);
145
+ };
146
+ await Promise.all(Array.from({ length: Math.min(BUCKET_CONCURRENCY, queue.length) }, worker));
147
+ return { uploaded: queue.reduce((n, parts) => n + parts.length, 0) };
148
+ }
149
+ //# sourceMappingURL=hosting-wfp-upload.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hosting-wfp-upload.js","sourceRoot":"","sources":["../../../src/lib/hosting-wfp-upload.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAoBnD,gCAAgC;AAChC,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,CAAC;AAEpC,8DAA8D;AAC9D,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC;AAEhC,2CAA2C;AAC3C,MAAM,iBAAiB,GAAG,OAAO,CAAC;AAElC;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,GAAW;IAC3C,IAAI,MAAkB,CAAC;IACvB,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;IACxB,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,GAAG,IAAI,CAAC;IAChB,CAAC;IACD,MAAM,EAAE,GAAG,MAAM,KAAK,IAAI,IAAI,MAAM,CAAC,QAAQ,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,KAAK,oBAAoB,IAAI,CAAC,MAAM,CAAC,QAAQ,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;IAC3I,IAAI,CAAC,EAAE,EAAE,CAAC;QACR,MAAM,IAAI,YAAY,CACpB,uBAAuB,EACvB,qLAAqL,CACtL,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,OAA+C;IAC/E,OAAO,SAAS,IAAI,OAAO,IAAI,OAAO,CAAC,MAAM,IAAI,GAAG,CAAC;AACvD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CAAC,MAAM,EAAE,EAAE,CAAC,WAAW,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,aAAa,IAAI,EAAE,CAAC,CAAC,CAAC;IACvG,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,KAAK,CAAC;IACrC,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,MAAM,MAAM,GAAG,KAAK,IAAI,EAAE;QACxB,OAAO,IAAI,GAAG,KAAK,CAAC,MAAM;YAAE,MAAM,YAAY,CAAC,OAAO,EAAE,KAAK,CAAC,IAAI,EAAE,CAAC,EAAE,KAAK,CAAC,CAAC;IAChF,CAAC,CAAC;IACF,MAAM,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,kBAAkB,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC;IAC9F,OAAO,EAAE,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,EAAE,CAAC;AACvE,CAAC"}
@@ -18,12 +18,6 @@ export declare function platformLabel(platform: Platform): string;
18
18
  * file is the cheapest place for a reader to find that rule.
19
19
  */
20
20
  export declare const CANONICAL_SCHEMA_HEADER = "# The model schema for this app \u2014 ONE copy, shared by every client.\n#\n# The TOML keys here are the wire field names, so a second copy that drifts\n# orphans the other one's records. Every client reads THIS file:\n# - the web client's codegen input points at it, and its generated barrel\n# imports it directly\n# - the Swift client names it in `bao-codegen.json` beside its sources\n# Add or change a model here, then re-run each client's codegen.\n";
21
- /**
22
- * A starter schema for the rare composition that has no template starter to
23
- * adopt. The scaffolded clients normally supply their own, which is what a
24
- * composed repo promotes to the root.
25
- */
26
- export declare const FALLBACK_STARTER_SCHEMA = "[models.user_prefs.fields.id]\ntype = \"id\"\nauto_assign = true\nindexed = true\nrequired = true\n\n[models.user_prefs.fields.key]\ntype = \"string\"\nindexed = true\nunique = true\n\n[models.user_prefs.fields.value]\ntype = \"string\"\n";
27
21
  /**
28
22
  * The app-wide `AGENTS.md` for a repository with several clients.
29
23
  *
@@ -36,4 +30,6 @@ export declare function rootAgentsMarkdown(input: {
36
30
  platform: Platform;
37
31
  dir: string;
38
32
  }>;
33
+ /** Whether the repository has `models/models.toml`; the layout names it only then. */
34
+ schema?: boolean;
39
35
  }): string;
@@ -18,25 +18,6 @@ export const CANONICAL_SCHEMA_HEADER = `# The model schema for this app — ONE
18
18
  # - the Swift client names it in \`bao-codegen.json\` beside its sources
19
19
  # Add or change a model here, then re-run each client's codegen.
20
20
  `;
21
- /**
22
- * A starter schema for the rare composition that has no template starter to
23
- * adopt. The scaffolded clients normally supply their own, which is what a
24
- * composed repo promotes to the root.
25
- */
26
- export const FALLBACK_STARTER_SCHEMA = `[models.user_prefs.fields.id]
27
- type = "id"
28
- auto_assign = true
29
- indexed = true
30
- required = true
31
-
32
- [models.user_prefs.fields.key]
33
- type = "string"
34
- indexed = true
35
- unique = true
36
-
37
- [models.user_prefs.fields.value]
38
- type = "string"
39
- `;
40
21
  /**
41
22
  * The app-wide `AGENTS.md` for a repository with several clients.
42
23
  *
@@ -44,13 +25,20 @@ type = "string"
44
25
  * own file is never replaced by init.
45
26
  */
46
27
  export function rootAgentsMarkdown(input) {
28
+ const schema = input.schema ?? true;
47
29
  const rows = input.clients
48
30
  .map((client) => `- \`${client.dir}/\` — ${platformLabel(client.platform)} client`)
49
31
  .join("\n");
32
+ const schemaRow = schema
33
+ ? `- \`models/models.toml\` — the model schema. ONE copy: its keys are the wire
34
+ field names, so a second copy that drifts orphans the other's records. Each
35
+ client's codegen reads this file in place; never copy it into a client.
36
+ `
37
+ : "";
50
38
  return `# ${input.appName}
51
39
 
52
40
  One Primitive app, several clients. The app is the shared thing: one app ID,
53
- one set of environments, one exported server config, one model schema. Each
41
+ one set of environments, one exported server config${schema ? ", one model schema" : ""}. Each
54
42
  client is an independent project in its own directory — there is no workspace
55
43
  file and no root \`package.json\`.
56
44
 
@@ -61,10 +49,7 @@ file and no root \`package.json\`.
61
49
  - \`primitive/<env>/\` — the exported server config (workflows,
62
50
  database type configs, app settings) that \`primitive config diff\` and
63
51
  \`primitive config push\` read and write.
64
- - \`models/models.toml\` — the model schema. ONE copy: its keys are the wire
65
- field names, so a second copy that drifts orphans the other's records. Each
66
- client's codegen reads this file in place; never copy it into a client.
67
- ${rows}
52
+ ${schemaRow}${rows}
68
53
 
69
54
  ## Per app vs per client
70
55
 
@@ -72,8 +57,7 @@ ${rows}
72
57
  | --- | --- |
73
58
  | Environments and app ID | Generated code |
74
59
  | Exported server config | Dependencies and build config |
75
- | Model schema | Runtime connection settings |
76
- | Secrets | Deploy configuration |
60
+ ${schema ? "| Model schema | Runtime connection settings |\n| Secrets | Deploy configuration |" : "| Secrets | Runtime connection settings |\n| — | Deploy configuration |"}
77
61
  | — | Its own \`AGENTS.md\` |
78
62
 
79
63
  ## Running commands
@@ -90,7 +74,7 @@ primitive init <dir> --platform <web|ios>
90
74
  \`\`\`
91
75
 
92
76
  Run from inside this repository, that adds a client to THIS app: it reuses this
93
- config, wires the new client to \`models/models.toml\`, and creates no second
77
+ config, ${schema ? "wires the new client to \`models/models.toml\`, " : ""}and creates no second
94
78
  \`.primitive/\` and no second git repository.
95
79
  `;
96
80
  }
@@ -1 +1 @@
1
- {"version":3,"file":"init-assets.js","sourceRoot":"","sources":["../../../src/lib/init-assets.ts"],"names":[],"mappings":"AAWA,yEAAyE;AACzE,MAAM,UAAU,aAAa,CAAC,QAAkB;IAC9C,OAAO,QAAQ,KAAK,KAAK,CAAC,CAAC,CAAC,eAAe,CAAC,CAAC,CAAC,WAAW,CAAC;AAC5D,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG;;;;;;;;CAQtC,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAu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;;;;;;;;;;;EAWrF,SAAS,GAAG,IAAI;;;;;;;;EAQhB,MAAM,CAAC,CAAC,CAAC,oFAAoF,CAAC,CAAC,CAAC,yEAAyE;;;;;;;;;;;;;;;;;UAiBjK,MAAM,CAAC,CAAC,CAAC,kDAAkD,CAAC,CAAC,CAAC,EAAE;;CAEzE,CAAC;AACF,CAAC"}
@@ -1,10 +1,8 @@
1
1
  /**
2
- * The `CFBundleURLName` the library and the template agree on. Changing it
3
- * breaks the manager's scheme resolution, so it is pinned by a test that reads
4
- * both files.
2
+ * The `CFBundleURLName` of the template's URL type: the entry init stamps.
5
3
  */
6
4
  export declare const PRIMITIVE_AUTH_URL_TYPE_NAME = "PrimitiveAuth";
7
- /** The library's fallback scheme — reserved, never a derived result. */
5
+ /** The template's shipped scheme — reserved, never a derived result. */
8
6
  export declare const FALLBACK_CALLBACK_SCHEME = "primitiveapp";
9
7
  /**
10
8
  * The custom URL scheme for one scaffolded client: a readable prefix from the
@@ -14,8 +12,13 @@ export declare const FALLBACK_CALLBACK_SCHEME = "primitiveapp";
14
12
  * share a scheme, whatever they are called.
15
13
  */
16
14
  export declare function deriveCallbackScheme(appName: string, appId: string, clientDirName?: string): string;
17
- /** The redirect target the emailed sign-in link uses, for one scheme. */
18
- export declare function iosMagicLinkRedirectUri(scheme: string): string;
15
+ /**
16
+ * The scheme callback an emailed sign-in link lands on, for one scheme: the
17
+ * value of the `PrimitiveOAuthRedirectURI` key, and the allow-list entry.
18
+ */
19
+ export declare function iosSchemeCallbackUri(scheme: string): string;
20
+ /** The Info.plist key the template reads its `oauthRedirectUri` from. */
21
+ export declare const OAUTH_REDIRECT_URI_PLIST_KEY = "PrimitiveOAuthRedirectURI";
19
22
  export interface StampResult {
20
23
  /** `not-found` when the plist predates the `PrimitiveAuth` URL type. */
21
24
  outcome: "stamped" | "already" | "not-found";
@@ -46,7 +49,8 @@ export declare function stampCallbackScheme(clientDir: string, scheme: string):
46
49
  export declare function setWebUrlInstruction(origin: string, indent?: string): string[];
47
50
  /**
48
51
  * What init prints about email sign-in on the iOS path: it already works, and
49
- * this is the one opt-in that adds the link.
52
+ * this is the opt-in that adds a scheme link — an allow-list entry and one
53
+ * Info.plist key, no source edit.
50
54
  *
51
55
  * The allow-list step is phrased as a MERGE into the existing array — `app.toml`
52
56
  * is the whole app-settings truth on push (#2880), so a replacement array would
@@ -1,34 +1,33 @@
1
1
  /**
2
2
  * The iOS app's own URL scheme, and the documented opt-in that turns the
3
- * sign-in email's LINK on (#2969).
3
+ * sign-in email's LINK on (#2969, #4930).
4
4
  *
5
5
  * The Swift template registers one custom URL scheme, under the
6
- * `PrimitiveAuth` URL-type name that `PrimitiveAuthManager` reads its callback
7
- * scheme from. Shipped, that scheme is `primitiveapp` — which every app
8
- * scaffolded from the template would otherwise share, making iOS link routing
9
- * between two of them on one device ambiguous. So init stamps an app-unique
10
- * scheme in its place.
6
+ * `PrimitiveAuth` URL-type name. Shipped, that scheme is `primitiveapp` —
7
+ * which every app scaffolded from the template would otherwise share, making
8
+ * iOS link routing between two of them on one device ambiguous. So init
9
+ * stamps an app-unique scheme in its place.
11
10
  *
12
11
  * The suffix is the WHOLE app ID, not a tail or a hash of it: app IDs are
13
12
  * 26-character ULIDs, and any fixed-width squeeze of them is many-to-one — two
14
13
  * distinct apps could still be handed the same scheme, which is the failure
15
14
  * this stamping exists to prevent.
16
15
  *
17
- * Init writes no app settings here. Email sign-in works out of the box because
18
- * the manager sends NO redirect target by default, so the email carries the
19
- * code alone and the allow-list is not consulted at all. Sending the link is
20
- * the developer's opt-in — one allow-list entry plus one flag — and init only
21
- * prints what those are.
16
+ * Init writes no app settings here. Email sign-in works out of the box: with
17
+ * no web origin and no `oauthRedirectUri`, the client sends NO redirect target,
18
+ * so the email carries the code alone and the allow-list is not consulted at
19
+ * all. Sending a scheme link is the developer's opt-in — one allow-list entry
20
+ * plus the `PrimitiveOAuthRedirectURI` key in `Info-Partial.plist`, which the
21
+ * template forwards as the client's `oauthRedirectUri` — and init only prints
22
+ * what those are.
22
23
  */
23
24
  import { existsSync, readFileSync, writeFileSync } from "fs";
24
25
  import { join } from "path";
25
26
  /**
26
- * The `CFBundleURLName` the library and the template agree on. Changing it
27
- * breaks the manager's scheme resolution, so it is pinned by a test that reads
28
- * both files.
27
+ * The `CFBundleURLName` of the template's URL type: the entry init stamps.
29
28
  */
30
29
  export const PRIMITIVE_AUTH_URL_TYPE_NAME = "PrimitiveAuth";
31
- /** The library's fallback scheme — reserved, never a derived result. */
30
+ /** The template's shipped scheme — reserved, never a derived result. */
32
31
  export const FALLBACK_CALLBACK_SCHEME = "primitiveapp";
33
32
  /** How much of the app name survives into the readable prefix. */
34
33
  const PREFIX_MAX_LENGTH = 20;
@@ -63,10 +62,15 @@ export function deriveCallbackScheme(appName, appId, clientDirName) {
63
62
  // what a derived one must never collide with.
64
63
  return scheme === FALLBACK_CALLBACK_SCHEME ? `${scheme}-app` : scheme;
65
64
  }
66
- /** The redirect target the emailed sign-in link uses, for one scheme. */
67
- export function iosMagicLinkRedirectUri(scheme) {
68
- return `${scheme}://auth/magic-link`;
65
+ /**
66
+ * The scheme callback an emailed sign-in link lands on, for one scheme: the
67
+ * value of the `PrimitiveOAuthRedirectURI` key, and the allow-list entry.
68
+ */
69
+ export function iosSchemeCallbackUri(scheme) {
70
+ return `${scheme}://oauth/callback`;
69
71
  }
72
+ /** The Info.plist key the template reads its `oauthRedirectUri` from. */
73
+ export const OAUTH_REDIRECT_URI_PLIST_KEY = "PrimitiveOAuthRedirectURI";
70
74
  /**
71
75
  * Replaces the scheme registered under the `PrimitiveAuth` URL type in a
72
76
  * scaffolded client's `Info-Partial.plist`.
@@ -132,7 +136,8 @@ export function setWebUrlInstruction(origin, indent = " ") {
132
136
  }
133
137
  /**
134
138
  * What init prints about email sign-in on the iOS path: it already works, and
135
- * this is the one opt-in that adds the link.
139
+ * this is the opt-in that adds a scheme link — an allow-list entry and one
140
+ * Info.plist key, no source edit.
136
141
  *
137
142
  * The allow-list step is phrased as a MERGE into the existing array — `app.toml`
138
143
  * is the whole app-settings truth on push (#2880), so a replacement array would
@@ -146,7 +151,7 @@ export function setWebUrlInstruction(origin, indent = " ") {
146
151
  */
147
152
  export function linkOptInGuidance(scheme, options = {}) {
148
153
  const registered = options.registered !== false;
149
- const redirectUri = iosMagicLinkRedirectUri(scheme);
154
+ const redirectUri = iosSchemeCallbackUri(scheme);
150
155
  return [
151
156
  "Email sign-in works now: the email carries a 6-digit code and needs no app settings.",
152
157
  "When this app gets a web client, prefer the https link: set the environment's `webUrl` —",
@@ -155,8 +160,9 @@ export function linkOptInGuidance(scheme, options = {}) {
155
160
  " app where it is installed and signs in through the browser anywhere else.",
156
161
  `Until then, to ALSO send a sign-in link that opens this app, add "${redirectUri}" to the existing`,
157
162
  " [auth].emailRedirectUris array in config/app.toml (merge it in — run",
158
- " `primitive config pull --only app` first if that file is not there yet), then run",
159
- " `primitive config push --only app` and set `authManager.sendsEmailSignInLink = true`.",
163
+ " `primitive config pull --only app` first if that file is not there yet), run",
164
+ ` \`primitive config push --only app\`, and add the ${OAUTH_REDIRECT_URI_PLIST_KEY} key to`,
165
+ ` Info-Partial.plist with the value "${redirectUri}".`,
160
166
  registered
161
167
  ? "The scheme registration and the link routing are already in this client."
162
168
  : `The scheme "${scheme}" is NOT registered in this client yet — register it first (see`