primitive-admin 1.1.0-alpha.7 → 1.1.0-alpha.71

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 (438) hide show
  1. package/README.md +404 -80
  2. package/assets/skill/skills/primitive-platform/SKILL.md +808 -0
  3. package/dist/bin/primitive.d.ts +2 -0
  4. package/dist/bin/primitive.js +294 -21
  5. package/dist/bin/primitive.js.map +1 -1
  6. package/dist/src/commands/admins.d.ts +2 -0
  7. package/dist/src/commands/admins.js +138 -19
  8. package/dist/src/commands/admins.js.map +1 -1
  9. package/dist/src/commands/analytics.d.ts +2 -0
  10. package/dist/src/commands/analytics.js +544 -55
  11. package/dist/src/commands/analytics.js.map +1 -1
  12. package/dist/src/commands/apps.d.ts +2 -0
  13. package/dist/src/commands/apps.js +51 -96
  14. package/dist/src/commands/apps.js.map +1 -1
  15. package/dist/src/commands/auth.d.ts +2 -0
  16. package/dist/src/commands/auth.js +177 -7
  17. package/dist/src/commands/auth.js.map +1 -1
  18. package/dist/src/commands/blob-buckets.d.ts +2 -0
  19. package/dist/src/commands/blob-buckets.js +330 -0
  20. package/dist/src/commands/blob-buckets.js.map +1 -0
  21. package/dist/src/commands/catalog.d.ts +2 -0
  22. package/dist/src/commands/catalog.js +37 -38
  23. package/dist/src/commands/catalog.js.map +1 -1
  24. package/dist/src/commands/collection-type-configs.d.ts +2 -0
  25. package/dist/src/commands/collection-type-configs.js +92 -0
  26. package/dist/src/commands/collection-type-configs.js.map +1 -0
  27. package/dist/src/commands/collections.d.ts +2 -0
  28. package/dist/src/commands/collections.js +565 -0
  29. package/dist/src/commands/collections.js.map +1 -0
  30. package/dist/src/commands/comparisons.d.ts +2 -0
  31. package/dist/src/commands/comparisons.js +6 -6
  32. package/dist/src/commands/comparisons.js.map +1 -1
  33. package/dist/src/commands/config.d.ts +46 -0
  34. package/dist/src/commands/config.js +479 -0
  35. package/dist/src/commands/config.js.map +1 -0
  36. package/dist/src/commands/connections.d.ts +2 -0
  37. package/dist/src/commands/connections.js +100 -0
  38. package/dist/src/commands/connections.js.map +1 -0
  39. package/dist/src/commands/cron-triggers.d.ts +2 -0
  40. package/dist/src/commands/cron-triggers.js +265 -0
  41. package/dist/src/commands/cron-triggers.js.map +1 -0
  42. package/dist/src/commands/database-type-configs.d.ts +2 -0
  43. package/dist/src/commands/database-type-configs.js +171 -0
  44. package/dist/src/commands/database-type-configs.js.map +1 -0
  45. package/dist/src/commands/database-types.d.ts +2 -0
  46. package/dist/src/commands/database-types.js +471 -0
  47. package/dist/src/commands/database-types.js.map +1 -0
  48. package/dist/src/commands/databases.d.ts +65 -0
  49. package/dist/src/commands/databases.js +2140 -112
  50. package/dist/src/commands/databases.js.map +1 -1
  51. package/dist/src/commands/documents.d.ts +2 -0
  52. package/dist/src/commands/documents.js +1357 -19
  53. package/dist/src/commands/documents.js.map +1 -1
  54. package/dist/src/commands/email-templates.d.ts +2 -0
  55. package/dist/src/commands/email-templates.js +174 -0
  56. package/dist/src/commands/email-templates.js.map +1 -0
  57. package/dist/src/commands/env.d.ts +23 -0
  58. package/dist/src/commands/env.js +333 -0
  59. package/dist/src/commands/env.js.map +1 -0
  60. package/dist/src/commands/feature-flags.d.ts +14 -0
  61. package/dist/src/commands/feature-flags.js +116 -0
  62. package/dist/src/commands/feature-flags.js.map +1 -0
  63. package/dist/src/commands/group-type-configs.d.ts +2 -0
  64. package/dist/src/commands/group-type-configs.js +86 -0
  65. package/dist/src/commands/group-type-configs.js.map +1 -0
  66. package/dist/src/commands/groups.d.ts +2 -0
  67. package/dist/src/commands/groups.js +38 -99
  68. package/dist/src/commands/groups.js.map +1 -1
  69. package/dist/src/commands/guides.d.ts +223 -0
  70. package/dist/src/commands/guides.js +617 -65
  71. package/dist/src/commands/guides.js.map +1 -1
  72. package/dist/src/commands/init.d.ts +25 -0
  73. package/dist/src/commands/init.js +1605 -208
  74. package/dist/src/commands/init.js.map +1 -1
  75. package/dist/src/commands/integrations.d.ts +2 -0
  76. package/dist/src/commands/integrations.js +380 -178
  77. package/dist/src/commands/integrations.js.map +1 -1
  78. package/dist/src/commands/llm.d.ts +2 -0
  79. package/dist/src/commands/llm.js +4 -2
  80. package/dist/src/commands/llm.js.map +1 -1
  81. package/dist/src/commands/locks.d.ts +8 -0
  82. package/dist/src/commands/locks.js +160 -0
  83. package/dist/src/commands/locks.js.map +1 -0
  84. package/dist/src/commands/metadata-category-configs.d.ts +12 -0
  85. package/dist/src/commands/metadata-category-configs.js +112 -0
  86. package/dist/src/commands/metadata-category-configs.js.map +1 -0
  87. package/dist/src/commands/metadata.d.ts +2 -0
  88. package/dist/src/commands/metadata.js +281 -0
  89. package/dist/src/commands/metadata.js.map +1 -0
  90. package/dist/src/commands/prompts.d.ts +2 -0
  91. package/dist/src/commands/prompts.js +225 -584
  92. package/dist/src/commands/prompts.js.map +1 -1
  93. package/dist/src/commands/rule-sets.d.ts +3 -0
  94. package/dist/src/commands/rule-sets.js +272 -0
  95. package/dist/src/commands/rule-sets.js.map +1 -0
  96. package/dist/src/commands/scripts.d.ts +20 -0
  97. package/dist/src/commands/scripts.js +554 -0
  98. package/dist/src/commands/scripts.js.map +1 -0
  99. package/dist/src/commands/secrets.d.ts +2 -0
  100. package/dist/src/commands/secrets.js +108 -0
  101. package/dist/src/commands/secrets.js.map +1 -0
  102. package/dist/src/commands/sessions.d.ts +2 -0
  103. package/dist/src/commands/sessions.js +75 -0
  104. package/dist/src/commands/sessions.js.map +1 -0
  105. package/dist/src/commands/skill.d.ts +2 -0
  106. package/dist/src/commands/skill.js +29 -0
  107. package/dist/src/commands/skill.js.map +1 -0
  108. package/dist/src/commands/sync-app-settings.d.ts +158 -0
  109. package/dist/src/commands/sync-app-settings.js +330 -0
  110. package/dist/src/commands/sync-app-settings.js.map +1 -0
  111. package/dist/src/commands/sync.d.ts +2323 -0
  112. package/dist/src/commands/sync.js +15065 -843
  113. package/dist/src/commands/sync.js.map +1 -1
  114. package/dist/src/commands/tokens.d.ts +2 -0
  115. package/dist/src/commands/tokens.js +130 -21
  116. package/dist/src/commands/tokens.js.map +1 -1
  117. package/dist/src/commands/users.d.ts +2 -0
  118. package/dist/src/commands/users.js +532 -23
  119. package/dist/src/commands/users.js.map +1 -1
  120. package/dist/src/commands/vars.d.ts +8 -0
  121. package/dist/src/commands/vars.js +96 -0
  122. package/dist/src/commands/vars.js.map +1 -0
  123. package/dist/src/commands/waitlist.d.ts +2 -0
  124. package/dist/src/commands/waitlist.js +10 -10
  125. package/dist/src/commands/waitlist.js.map +1 -1
  126. package/dist/src/commands/webhooks.d.ts +2 -0
  127. package/dist/src/commands/webhooks.js +562 -0
  128. package/dist/src/commands/webhooks.js.map +1 -0
  129. package/dist/src/commands/workflows.d.ts +116 -0
  130. package/dist/src/commands/workflows.js +1583 -681
  131. package/dist/src/commands/workflows.js.map +1 -1
  132. package/dist/src/lib/access-rule-display.d.ts +21 -0
  133. package/dist/src/lib/access-rule-display.js +34 -0
  134. package/dist/src/lib/access-rule-display.js.map +1 -0
  135. package/dist/src/lib/api-client.d.ts +1936 -0
  136. package/dist/src/lib/api-client.js +1826 -138
  137. package/dist/src/lib/api-client.js.map +1 -1
  138. package/dist/src/lib/app-settings-descriptor.d.ts +263 -0
  139. package/dist/src/lib/app-settings-descriptor.js +575 -0
  140. package/dist/src/lib/app-settings-descriptor.js.map +1 -0
  141. package/dist/src/lib/auth-flow.d.ts +8 -0
  142. package/dist/src/lib/batch.d.ts +26 -0
  143. package/dist/src/lib/batch.js +32 -0
  144. package/dist/src/lib/batch.js.map +1 -0
  145. package/dist/src/lib/block-layout.d.ts +160 -0
  146. package/dist/src/lib/block-layout.js +451 -0
  147. package/dist/src/lib/block-layout.js.map +1 -0
  148. package/dist/src/lib/canonical-json.d.ts +12 -0
  149. package/dist/src/lib/canonical-json.js +35 -0
  150. package/dist/src/lib/canonical-json.js.map +1 -0
  151. package/dist/src/lib/channel.d.ts +30 -0
  152. package/dist/src/lib/channel.js +68 -0
  153. package/dist/src/lib/channel.js.map +1 -0
  154. package/dist/src/lib/cli-manifest.d.ts +68 -0
  155. package/dist/src/lib/cli-manifest.js +71 -0
  156. package/dist/src/lib/cli-manifest.js.map +1 -0
  157. package/dist/src/lib/codegen-shared/generatedFiles.d.ts +101 -0
  158. package/dist/src/lib/codegen-shared/generatedFiles.js +191 -0
  159. package/dist/src/lib/codegen-shared/generatedFiles.js.map +1 -0
  160. package/dist/src/lib/codegen-shared/prettierStable.d.ts +262 -0
  161. package/dist/src/lib/codegen-shared/prettierStable.js +610 -0
  162. package/dist/src/lib/codegen-shared/prettierStable.js.map +1 -0
  163. package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.d.ts +68 -0
  164. package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.js +168 -0
  165. package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.js.map +1 -0
  166. package/dist/src/lib/config-object-descriptor.d.ts +127 -0
  167. package/dist/src/lib/config-object-descriptor.js +658 -0
  168. package/dist/src/lib/config-object-descriptor.js.map +1 -0
  169. package/dist/src/lib/config-payload.d.ts +85 -0
  170. package/dist/src/lib/config-payload.js +116 -0
  171. package/dist/src/lib/config-payload.js.map +1 -0
  172. package/dist/src/lib/config-surface.d.ts +130 -0
  173. package/dist/src/lib/config-surface.js +300 -0
  174. package/dist/src/lib/config-surface.js.map +1 -0
  175. package/dist/src/lib/config-toml.d.ts +10 -0
  176. package/dist/src/lib/config-toml.js +42 -0
  177. package/dist/src/lib/config-toml.js.map +1 -0
  178. package/dist/src/lib/config.d.ts +53 -0
  179. package/dist/src/lib/config.js +92 -53
  180. package/dist/src/lib/config.js.map +1 -1
  181. package/dist/src/lib/confirm-prompt.d.ts +83 -0
  182. package/dist/src/lib/confirm-prompt.js +110 -0
  183. package/dist/src/lib/confirm-prompt.js.map +1 -0
  184. package/dist/src/lib/constants.d.ts +11 -0
  185. package/dist/src/lib/constants.js +12 -0
  186. package/dist/src/lib/constants.js.map +1 -0
  187. package/dist/src/lib/crash-handlers.d.ts +20 -0
  188. package/dist/src/lib/crash-handlers.js +49 -0
  189. package/dist/src/lib/crash-handlers.js.map +1 -0
  190. package/dist/src/lib/credentials-store.d.ts +89 -0
  191. package/dist/src/lib/credentials-store.js +330 -0
  192. package/dist/src/lib/credentials-store.js.map +1 -0
  193. package/dist/src/lib/csv.d.ts +47 -0
  194. package/dist/src/lib/csv.js +172 -0
  195. package/dist/src/lib/csv.js.map +1 -0
  196. package/dist/src/lib/data-input.d.ts +23 -0
  197. package/dist/src/lib/data-input.js +50 -0
  198. package/dist/src/lib/data-input.js.map +1 -0
  199. package/dist/src/lib/db-codegen/dbFingerprint.d.ts +10 -0
  200. package/dist/src/lib/db-codegen/dbFingerprint.js +17 -0
  201. package/dist/src/lib/db-codegen/dbFingerprint.js.map +1 -0
  202. package/dist/src/lib/db-codegen/dbGenerator.d.ts +67 -0
  203. package/dist/src/lib/db-codegen/dbGenerator.js +170 -0
  204. package/dist/src/lib/db-codegen/dbGenerator.js.map +1 -0
  205. package/dist/src/lib/db-codegen/dbNaming.d.ts +87 -0
  206. package/dist/src/lib/db-codegen/dbNaming.js +180 -0
  207. package/dist/src/lib/db-codegen/dbNaming.js.map +1 -0
  208. package/dist/src/lib/db-codegen/dbTemplates.d.ts +272 -0
  209. package/dist/src/lib/db-codegen/dbTemplates.js +480 -0
  210. package/dist/src/lib/db-codegen/dbTemplates.js.map +1 -0
  211. package/dist/src/lib/db-codegen/dbTsTypes.d.ts +73 -0
  212. package/dist/src/lib/db-codegen/dbTsTypes.js +139 -0
  213. package/dist/src/lib/db-codegen/dbTsTypes.js.map +1 -0
  214. package/dist/src/lib/db-codegen/dbTypeIR.d.ts +146 -0
  215. package/dist/src/lib/db-codegen/dbTypeIR.js +517 -0
  216. package/dist/src/lib/db-codegen/dbTypeIR.js.map +1 -0
  217. package/dist/src/lib/db-codegen/generated-operation-def-descriptor.d.ts +112 -0
  218. package/dist/src/lib/db-codegen/generated-operation-def-descriptor.js +211 -0
  219. package/dist/src/lib/db-codegen/generated-operation-def-descriptor.js.map +1 -0
  220. package/dist/src/lib/env-resolver-core.d.ts +147 -0
  221. package/dist/src/lib/env-resolver-core.js +265 -0
  222. package/dist/src/lib/env-resolver-core.js.map +1 -0
  223. package/dist/src/lib/env-resolver.d.ts +84 -0
  224. package/dist/src/lib/env-resolver.js +133 -0
  225. package/dist/src/lib/env-resolver.js.map +1 -0
  226. package/dist/src/lib/fetch.d.ts +5 -0
  227. package/dist/src/lib/generated-allowlist.d.ts +28 -0
  228. package/dist/src/lib/generated-allowlist.js +277 -0
  229. package/dist/src/lib/generated-allowlist.js.map +1 -0
  230. package/dist/src/lib/generated-config-surfaces.d.ts +682 -0
  231. package/dist/src/lib/generated-config-surfaces.js +4058 -0
  232. package/dist/src/lib/generated-config-surfaces.js.map +1 -0
  233. package/dist/src/lib/generated-template-lint.d.ts +212 -0
  234. package/dist/src/lib/generated-template-lint.js +624 -0
  235. package/dist/src/lib/generated-template-lint.js.map +1 -0
  236. package/dist/src/lib/init-adopt.d.ts +16 -0
  237. package/dist/src/lib/init-adopt.js +34 -0
  238. package/dist/src/lib/init-adopt.js.map +1 -0
  239. package/dist/src/lib/init-assets.d.ts +39 -0
  240. package/dist/src/lib/init-assets.js +97 -0
  241. package/dist/src/lib/init-assets.js.map +1 -0
  242. package/dist/src/lib/init-config.d.ts +98 -0
  243. package/dist/src/lib/init-config.js +186 -0
  244. package/dist/src/lib/init-config.js.map +1 -0
  245. package/dist/src/lib/init-ios-links.d.ts +50 -0
  246. package/dist/src/lib/init-ios-links.js +153 -0
  247. package/dist/src/lib/init-ios-links.js.map +1 -0
  248. package/dist/src/lib/init-plan.d.ts +80 -0
  249. package/dist/src/lib/init-plan.js +95 -0
  250. package/dist/src/lib/init-plan.js.map +1 -0
  251. package/dist/src/lib/init-production-env.d.ts +48 -0
  252. package/dist/src/lib/init-production-env.js +59 -0
  253. package/dist/src/lib/init-production-env.js.map +1 -0
  254. package/dist/src/lib/init-schema.d.ts +74 -0
  255. package/dist/src/lib/init-schema.js +358 -0
  256. package/dist/src/lib/init-schema.js.map +1 -0
  257. package/dist/src/lib/init-xcode.d.ts +33 -0
  258. package/dist/src/lib/init-xcode.js +114 -0
  259. package/dist/src/lib/init-xcode.js.map +1 -0
  260. package/dist/src/lib/integration-request-config.d.ts +30 -0
  261. package/dist/src/lib/integration-request-config.js +145 -0
  262. package/dist/src/lib/integration-request-config.js.map +1 -0
  263. package/dist/src/lib/local-state.d.ts +55 -0
  264. package/dist/src/lib/local-state.js +167 -0
  265. package/dist/src/lib/local-state.js.map +1 -0
  266. package/dist/src/lib/log-inspection.d.ts +568 -0
  267. package/dist/src/lib/log-inspection.js +639 -0
  268. package/dist/src/lib/log-inspection.js.map +1 -0
  269. package/dist/src/lib/migration-nag.d.ts +49 -0
  270. package/dist/src/lib/migration-nag.js +163 -0
  271. package/dist/src/lib/migration-nag.js.map +1 -0
  272. package/dist/src/lib/object-status-filter.d.ts +22 -0
  273. package/dist/src/lib/object-status-filter.js +45 -0
  274. package/dist/src/lib/object-status-filter.js.map +1 -0
  275. package/dist/src/lib/output.d.ts +109 -0
  276. package/dist/src/lib/output.js +191 -8
  277. package/dist/src/lib/output.js.map +1 -1
  278. package/dist/src/lib/package-manager.d.ts +140 -0
  279. package/dist/src/lib/package-manager.js +305 -0
  280. package/dist/src/lib/package-manager.js.map +1 -0
  281. package/dist/src/lib/paginate.d.ts +83 -0
  282. package/dist/src/lib/paginate.js +95 -0
  283. package/dist/src/lib/paginate.js.map +1 -0
  284. package/dist/src/lib/platform-owned.d.ts +63 -0
  285. package/dist/src/lib/platform-owned.js +85 -0
  286. package/dist/src/lib/platform-owned.js.map +1 -0
  287. package/dist/src/lib/project-config.d.ts +97 -0
  288. package/dist/src/lib/project-config.js +217 -0
  289. package/dist/src/lib/project-config.js.map +1 -0
  290. package/dist/src/lib/query-operators.d.ts +43 -0
  291. package/dist/src/lib/query-operators.js +80 -0
  292. package/dist/src/lib/query-operators.js.map +1 -0
  293. package/dist/src/lib/record-filter.d.ts +18 -0
  294. package/dist/src/lib/record-filter.js +55 -0
  295. package/dist/src/lib/record-filter.js.map +1 -0
  296. package/dist/src/lib/refresh-admin-credentials.d.ts +65 -0
  297. package/dist/src/lib/refresh-admin-credentials.js +103 -0
  298. package/dist/src/lib/refresh-admin-credentials.js.map +1 -0
  299. package/dist/src/lib/resolve-init-dev-port.d.ts +56 -0
  300. package/dist/src/lib/resolve-init-dev-port.js +55 -0
  301. package/dist/src/lib/resolve-init-dev-port.js.map +1 -0
  302. package/dist/src/lib/resolve-init-server.d.ts +64 -0
  303. package/dist/src/lib/resolve-init-server.js +77 -0
  304. package/dist/src/lib/resolve-init-server.js.map +1 -0
  305. package/dist/src/lib/resolve-platform.d.ts +74 -0
  306. package/dist/src/lib/resolve-platform.js +105 -0
  307. package/dist/src/lib/resolve-platform.js.map +1 -0
  308. package/dist/src/lib/run-status.d.ts +19 -0
  309. package/dist/src/lib/run-status.generated.d.ts +39 -0
  310. package/dist/src/lib/run-status.generated.js +66 -0
  311. package/dist/src/lib/run-status.generated.js.map +1 -0
  312. package/dist/src/lib/run-status.js +19 -0
  313. package/dist/src/lib/run-status.js.map +1 -0
  314. package/dist/src/lib/server-text-normalization.d.ts +51 -0
  315. package/dist/src/lib/server-text-normalization.js +90 -0
  316. package/dist/src/lib/server-text-normalization.js.map +1 -0
  317. package/dist/src/lib/server-url.d.ts +22 -0
  318. package/dist/src/lib/server-url.js +33 -0
  319. package/dist/src/lib/server-url.js.map +1 -0
  320. package/dist/src/lib/signing-secret-status.d.ts +81 -0
  321. package/dist/src/lib/signing-secret-status.js +116 -0
  322. package/dist/src/lib/signing-secret-status.js.map +1 -0
  323. package/dist/src/lib/skill-installer.d.ts +25 -0
  324. package/dist/src/lib/skill-installer.js +266 -0
  325. package/dist/src/lib/skill-installer.js.map +1 -0
  326. package/dist/src/lib/snapshots.d.ts +99 -0
  327. package/dist/src/lib/snapshots.js +357 -0
  328. package/dist/src/lib/snapshots.js.map +1 -0
  329. package/dist/src/lib/swift-codegen/dbGenerator.d.ts +113 -0
  330. package/dist/src/lib/swift-codegen/dbGenerator.js +914 -0
  331. package/dist/src/lib/swift-codegen/dbGenerator.js.map +1 -0
  332. package/dist/src/lib/swift-codegen/dbSwiftTypes.d.ts +42 -0
  333. package/dist/src/lib/swift-codegen/dbSwiftTypes.js +100 -0
  334. package/dist/src/lib/swift-codegen/dbSwiftTypes.js.map +1 -0
  335. package/dist/src/lib/swift-codegen/generator.d.ts +94 -0
  336. package/dist/src/lib/swift-codegen/generator.js +440 -0
  337. package/dist/src/lib/swift-codegen/generator.js.map +1 -0
  338. package/dist/src/lib/swift-codegen/schemaToSwift.d.ts +72 -0
  339. package/dist/src/lib/swift-codegen/schemaToSwift.js +644 -0
  340. package/dist/src/lib/swift-codegen/schemaToSwift.js.map +1 -0
  341. package/dist/src/lib/swift-codegen/siblingSymbols.d.ts +94 -0
  342. package/dist/src/lib/swift-codegen/siblingSymbols.js +155 -0
  343. package/dist/src/lib/swift-codegen/siblingSymbols.js.map +1 -0
  344. package/dist/src/lib/swift-codegen/swiftNaming.d.ts +85 -0
  345. package/dist/src/lib/swift-codegen/swiftNaming.js +198 -0
  346. package/dist/src/lib/swift-codegen/swiftNaming.js.map +1 -0
  347. package/dist/src/lib/sync-dir-selector.d.ts +21 -0
  348. package/dist/src/lib/sync-dir-selector.js +30 -0
  349. package/dist/src/lib/sync-dir-selector.js.map +1 -0
  350. package/dist/src/lib/sync-paths.d.ts +111 -0
  351. package/dist/src/lib/sync-paths.js +198 -0
  352. package/dist/src/lib/sync-paths.js.map +1 -0
  353. package/dist/src/lib/sync-resource-types.d.ts +544 -0
  354. package/dist/src/lib/sync-resource-types.js +975 -0
  355. package/dist/src/lib/sync-resource-types.js.map +1 -0
  356. package/dist/src/lib/sync-selectors.d.ts +95 -0
  357. package/dist/src/lib/sync-selectors.js +228 -0
  358. package/dist/src/lib/sync-selectors.js.map +1 -0
  359. package/dist/src/lib/template.d.ts +170 -0
  360. package/dist/src/lib/template.js +484 -68
  361. package/dist/src/lib/template.js.map +1 -1
  362. package/dist/src/lib/test-case-keys.d.ts +29 -0
  363. package/dist/src/lib/test-case-keys.js +55 -0
  364. package/dist/src/lib/test-case-keys.js.map +1 -0
  365. package/dist/src/lib/test-case-variables.d.ts +15 -0
  366. package/dist/src/lib/test-case-variables.js +29 -0
  367. package/dist/src/lib/test-case-variables.js.map +1 -0
  368. package/dist/src/lib/token-inject.d.ts +56 -0
  369. package/dist/src/lib/token-inject.js +204 -0
  370. package/dist/src/lib/token-inject.js.map +1 -0
  371. package/dist/src/lib/toml-database-config.d.ts +123 -0
  372. package/dist/src/lib/toml-database-config.js +527 -0
  373. package/dist/src/lib/toml-database-config.js.map +1 -0
  374. package/dist/src/lib/toml-metadata-config.d.ts +151 -0
  375. package/dist/src/lib/toml-metadata-config.js +476 -0
  376. package/dist/src/lib/toml-metadata-config.js.map +1 -0
  377. package/dist/src/lib/toml-native-form.d.ts +46 -0
  378. package/dist/src/lib/toml-native-form.js +78 -0
  379. package/dist/src/lib/toml-native-form.js.map +1 -0
  380. package/dist/src/lib/toml-params-validator.d.ts +129 -0
  381. package/dist/src/lib/toml-params-validator.js +298 -0
  382. package/dist/src/lib/toml-params-validator.js.map +1 -0
  383. package/dist/src/lib/toml-scalar-edit.d.ts +43 -0
  384. package/dist/src/lib/toml-scalar-edit.js +283 -0
  385. package/dist/src/lib/toml-scalar-edit.js.map +1 -0
  386. package/dist/src/lib/user-selector.d.ts +24 -0
  387. package/dist/src/lib/user-selector.js +33 -0
  388. package/dist/src/lib/user-selector.js.map +1 -0
  389. package/dist/src/lib/version-check.d.ts +35 -0
  390. package/dist/src/lib/version-check.js +241 -0
  391. package/dist/src/lib/version-check.js.map +1 -0
  392. package/dist/src/lib/watch.d.ts +121 -0
  393. package/dist/src/lib/watch.js +169 -0
  394. package/dist/src/lib/watch.js.map +1 -0
  395. package/dist/src/lib/workflow-apply.d.ts +110 -0
  396. package/dist/src/lib/workflow-apply.js +164 -0
  397. package/dist/src/lib/workflow-apply.js.map +1 -0
  398. package/dist/src/lib/workflow-codegen/generated-schema-descriptor.d.ts +129 -0
  399. package/dist/src/lib/workflow-codegen/generated-schema-descriptor.js +269 -0
  400. package/dist/src/lib/workflow-codegen/generated-schema-descriptor.js.map +1 -0
  401. package/dist/src/lib/workflow-codegen/generator.d.ts +96 -0
  402. package/dist/src/lib/workflow-codegen/generator.js +361 -0
  403. package/dist/src/lib/workflow-codegen/generator.js.map +1 -0
  404. package/dist/src/lib/workflow-codegen/invokerIR.d.ts +94 -0
  405. package/dist/src/lib/workflow-codegen/invokerIR.js +76 -0
  406. package/dist/src/lib/workflow-codegen/invokerIR.js.map +1 -0
  407. package/dist/src/lib/workflow-codegen/naming.d.ts +33 -0
  408. package/dist/src/lib/workflow-codegen/naming.js +81 -0
  409. package/dist/src/lib/workflow-codegen/naming.js.map +1 -0
  410. package/dist/src/lib/workflow-codegen/schemaToTs.d.ts +80 -0
  411. package/dist/src/lib/workflow-codegen/schemaToTs.js +303 -0
  412. package/dist/src/lib/workflow-codegen/schemaToTs.js.map +1 -0
  413. package/dist/src/lib/workflow-config-apply.d.ts +70 -0
  414. package/dist/src/lib/workflow-config-apply.js +137 -0
  415. package/dist/src/lib/workflow-config-apply.js.map +1 -0
  416. package/dist/src/lib/workflow-config-sidecar.d.ts +63 -0
  417. package/dist/src/lib/workflow-config-sidecar.js +96 -0
  418. package/dist/src/lib/workflow-config-sidecar.js.map +1 -0
  419. package/dist/src/lib/workflow-defaults.d.ts +29 -0
  420. package/dist/src/lib/workflow-defaults.js +41 -0
  421. package/dist/src/lib/workflow-defaults.js.map +1 -0
  422. package/dist/src/lib/workflow-fragments.d.ts +64 -0
  423. package/dist/src/lib/workflow-fragments.js +342 -0
  424. package/dist/src/lib/workflow-fragments.js.map +1 -0
  425. package/dist/src/lib/workflow-include-preserve.d.ts +76 -0
  426. package/dist/src/lib/workflow-include-preserve.js +286 -0
  427. package/dist/src/lib/workflow-include-preserve.js.map +1 -0
  428. package/dist/src/lib/workflow-payload.d.ts +98 -0
  429. package/dist/src/lib/workflow-payload.js +178 -0
  430. package/dist/src/lib/workflow-payload.js.map +1 -0
  431. package/dist/src/lib/workflow-toml-validator.d.ts +202 -0
  432. package/dist/src/lib/workflow-toml-validator.js +757 -0
  433. package/dist/src/lib/workflow-toml-validator.js.map +1 -0
  434. package/dist/src/types/index.d.ts +581 -0
  435. package/dist/src/validators.d.ts +65 -0
  436. package/dist/src/validators.js +64 -0
  437. package/dist/src/validators.js.map +1 -0
  438. package/package.json +32 -8
@@ -0,0 +1,153 @@
1
+ /**
2
+ * The iOS app's own URL scheme, and the documented opt-in that turns the
3
+ * sign-in email's LINK on (#2969).
4
+ *
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.
11
+ *
12
+ * The suffix is the WHOLE app ID, not a tail or a hash of it: app IDs are
13
+ * 26-character ULIDs, and any fixed-width squeeze of them is many-to-one — two
14
+ * distinct apps could still be handed the same scheme, which is the failure
15
+ * this stamping exists to prevent.
16
+ *
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.
22
+ */
23
+ import { existsSync, readFileSync, writeFileSync } from "fs";
24
+ import { join } from "path";
25
+ /**
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.
29
+ */
30
+ export const PRIMITIVE_AUTH_URL_TYPE_NAME = "PrimitiveAuth";
31
+ /** The library's fallback scheme — reserved, never a derived result. */
32
+ export const FALLBACK_CALLBACK_SCHEME = "primitiveapp";
33
+ /** How much of the app name survives into the readable prefix. */
34
+ const PREFIX_MAX_LENGTH = 20;
35
+ /** The app-name placeholder init carries when it never asked for one. */
36
+ const APP_NAME_PLACEHOLDER = "(existing app)";
37
+ /**
38
+ * A URL-scheme-safe, letter-first fragment of `value`, or `""` when nothing
39
+ * usable survives (an empty name, an emoji-only one, digits alone).
40
+ */
41
+ function schemeFragment(value, maxLength) {
42
+ const sanitized = (value ?? "").toLowerCase().replace(/[^a-z0-9]/g, "");
43
+ // RFC 3986 schemes start with a letter, and the prefix is what leads.
44
+ const letterFirst = sanitized.replace(/^[0-9]+/, "");
45
+ return letterFirst.slice(0, maxLength);
46
+ }
47
+ /**
48
+ * The custom URL scheme for one scaffolded client: a readable prefix from the
49
+ * app name, then the full lowercased app ID.
50
+ *
51
+ * Deterministic and injective over server-generated app IDs — two apps never
52
+ * share a scheme, whatever they are called.
53
+ */
54
+ export function deriveCallbackScheme(appName, appId, clientDirName) {
55
+ const named = appName === APP_NAME_PLACEHOLDER ? "" : appName;
56
+ const prefix = schemeFragment(named, PREFIX_MAX_LENGTH) ||
57
+ schemeFragment(clientDirName, PREFIX_MAX_LENGTH) ||
58
+ "app";
59
+ // No truncation: the whole ID is what makes the scheme unique.
60
+ const suffix = (appId ?? "").toLowerCase().replace(/[^a-z0-9]/g, "");
61
+ const scheme = suffix ? `${prefix}-${suffix}` : prefix;
62
+ // Only reachable with no app ID at all, but the reserved scheme is exactly
63
+ // what a derived one must never collide with.
64
+ return scheme === FALLBACK_CALLBACK_SCHEME ? `${scheme}-app` : scheme;
65
+ }
66
+ /** The redirect target the emailed sign-in link uses, for one scheme. */
67
+ export function iosMagicLinkRedirectUri(scheme) {
68
+ return `${scheme}://auth/magic-link`;
69
+ }
70
+ /**
71
+ * Replaces the scheme registered under the `PrimitiveAuth` URL type in a
72
+ * scaffolded client's `Info-Partial.plist`.
73
+ *
74
+ * A targeted text substitution, not a plist rewrite: the file's comments are
75
+ * the checklist a developer reads when their emailed link does nothing, and a
76
+ * serializer would drop them.
77
+ */
78
+ export function stampCallbackScheme(clientDir, scheme) {
79
+ const plistPath = join(clientDir, "Info-Partial.plist");
80
+ if (!existsSync(plistPath))
81
+ return { outcome: "not-found" };
82
+ let text;
83
+ try {
84
+ text = readFileSync(plistPath, "utf-8");
85
+ }
86
+ catch {
87
+ return { outcome: "not-found" };
88
+ }
89
+ const marker = `<string>${PRIMITIVE_AUTH_URL_TYPE_NAME}</string>`;
90
+ const markerIndex = text.indexOf(marker);
91
+ if (markerIndex === -1)
92
+ return { outcome: "not-found" };
93
+ // Stay inside the URL-type dict the marker names: an app may register other
94
+ // schemes (a Google reversed client ID, say) and those are not ours to move.
95
+ const dictStart = text.lastIndexOf("<dict>", markerIndex);
96
+ const dictEnd = text.indexOf("</dict>", markerIndex);
97
+ if (dictStart === -1 || dictEnd === -1)
98
+ return { outcome: "not-found" };
99
+ const block = text.slice(dictStart, dictEnd);
100
+ if (!block.includes("<key>CFBundleURLName</key>"))
101
+ return { outcome: "not-found" };
102
+ const schemesPattern = /(<key>CFBundleURLSchemes<\/key>\s*<array>\s*<string>)([^<]*)(<\/string>)/;
103
+ const match = schemesPattern.exec(block);
104
+ if (!match)
105
+ return { outcome: "not-found" };
106
+ if (match[2] === scheme)
107
+ return { outcome: "already" };
108
+ const rewritten = block.replace(schemesPattern, `$1${scheme}$3`);
109
+ writeFileSync(plistPath, text.slice(0, dictStart) + rewritten + text.slice(dictEnd));
110
+ return { outcome: "stamped" };
111
+ }
112
+ /**
113
+ * What init prints about email sign-in on the iOS path: it already works, and
114
+ * this is the one opt-in that adds the link.
115
+ *
116
+ * The allow-list step is phrased as a MERGE into the existing array — `app.toml`
117
+ * is the whole app-settings truth on push (#2880), so a replacement array would
118
+ * silently drop the web callback the app was seeded with.
119
+ *
120
+ * `registered` is false when the scheme could not be stamped (an older template
121
+ * with no `PrimitiveAuth` URL type). The allow-list entry and the flag are the
122
+ * same either way, but the closing line must not claim a registration that is
123
+ * not there: a developer who did only the two steps would be left with a dead
124
+ * tap and nothing naming the missing piece.
125
+ */
126
+ export function linkOptInGuidance(scheme, options = {}) {
127
+ const registered = options.registered !== false;
128
+ const redirectUri = iosMagicLinkRedirectUri(scheme);
129
+ return [
130
+ "Email sign-in works now: the email carries a 6-digit code and needs no app settings.",
131
+ `To ALSO send a sign-in link that opens this app, add "${redirectUri}" to the existing`,
132
+ " [auth].emailRedirectUris array in config/app.toml (merge it in — run",
133
+ " `primitive config pull --only app` first if that file is not there yet), then run",
134
+ " `primitive config push --only app` and set `authManager.sendsEmailSignInLink = true`.",
135
+ registered
136
+ ? "The scheme registration and the link routing are already in this client."
137
+ : `The scheme "${scheme}" is NOT registered in this client yet — register it first (see`
138
+ + ` the ${PRIMITIVE_AUTH_URL_TYPE_NAME} warning above), or the link stays a dead tap.`,
139
+ " Full checklist: `primitive guides get authentication --language swift`, or the",
140
+ " authentication.md docs page — 'Make the emailed sign-in link open your app'.",
141
+ ];
142
+ }
143
+ /** What init says when the template predates the `PrimitiveAuth` URL type. */
144
+ export function missingUrlTypeGuidance(scheme) {
145
+ return [
146
+ `This template's Info-Partial.plist registers no ${PRIMITIVE_AUTH_URL_TYPE_NAME} URL type, so the`,
147
+ ` scheme "${scheme}" was not stamped and an emailed sign-in link cannot open this app.`,
148
+ ` Add a CFBundleURLTypes entry named ${PRIMITIVE_AUTH_URL_TYPE_NAME} with that scheme, then follow`,
149
+ " the authentication.md docs page — 'Make the emailed sign-in link open your app'",
150
+ " (or `primitive guides get authentication --language swift`).",
151
+ ];
152
+ }
153
+ //# sourceMappingURL=init-ios-links.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init-ios-links.js","sourceRoot":"","sources":["../../../src/lib/init-ios-links.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,IAAI,CAAC;AAC7D,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAA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ACnF,gEAAgE;KACjE,CAAC;AACJ,CAAC"}
@@ -0,0 +1,80 @@
1
+ import type { Platform } from "./resolve-platform.js";
2
+ export type InitMode = "standalone" | "multi-client" | "add-client";
3
+ export interface ClientPlan {
4
+ platform: Platform;
5
+ /** Absolute directory this client's template is installed into. */
6
+ dir: string;
7
+ }
8
+ export interface InitPlan {
9
+ mode: InitMode;
10
+ /** Every client this run scaffolds, in processing order (web first). */
11
+ clients: ClientPlan[];
12
+ /** The directory holding the ONE `.primitive/` for this app. */
13
+ projectRoot: string;
14
+ /**
15
+ * Whether this run writes `.primitive/config.json` and seeds the
16
+ * environment's credential slot. False when adopting: the config is already
17
+ * there and is not this run's to rewrite.
18
+ */
19
+ writesProjectConfig: boolean;
20
+ /**
21
+ * Whether this run may create the app and point the CLI's global "current
22
+ * app" at it. False when adopting — the app already exists and belongs to the
23
+ * project config.
24
+ */
25
+ ownsApp: boolean;
26
+ /**
27
+ * Whether this run creates the git repository and its initial commit. False
28
+ * when adopting: the surrounding repository owns the history, and the new
29
+ * files are left for the user to review and commit.
30
+ */
31
+ initsGit: boolean;
32
+ /**
33
+ * The one schema both clients read, or `null` in standalone mode where the
34
+ * client keeps the template's own copy (spec decision 1: single-client output
35
+ * is unchanged).
36
+ */
37
+ canonicalSchemaPath: string | null;
38
+ /**
39
+ * Whether this run may write an app-wide `AGENTS.md` at the project root.
40
+ * Never over an existing file — client `AGENTS.md` files ship with their
41
+ * templates and an adopted repo's root file is the user's.
42
+ */
43
+ writesRootAgents: boolean;
44
+ }
45
+ export interface PlanInitInput {
46
+ /** The resolved platforms, in canonical order. */
47
+ platforms: Platform[];
48
+ /** Absolute directory the command was pointed at. */
49
+ targetDir: string;
50
+ /**
51
+ * The nearest ancestor project root, passed ONLY when it differs from
52
+ * `targetDir` — `primitive init .` at an existing project root keeps its
53
+ * merge behavior rather than adopting itself.
54
+ */
55
+ ancestorProjectRoot?: string | null;
56
+ }
57
+ /** Resolve the layout for this run. */
58
+ export declare function planInit(input: PlanInitInput): InitPlan;
59
+ export interface InitGuardInput {
60
+ /** The init config's `action`, when a non-interactive config is in effect. */
61
+ action?: "create" | "use-existing" | "add-client";
62
+ /** Whether an init config is in effect at all. */
63
+ hasConfig: boolean;
64
+ /** The nearest ancestor project root, or null/undefined outside a project. */
65
+ ancestorProjectRoot?: string | null;
66
+ /** `app_id` from a `use-existing` init config. */
67
+ configAppId?: string;
68
+ /** `--use-existing-app-id`. */
69
+ flagAppId?: string;
70
+ /** The adopted environment's `appId`, when adopting. */
71
+ environmentAppId?: string;
72
+ /** The adopted environment's name, for the error messages. */
73
+ environmentName?: string;
74
+ }
75
+ /**
76
+ * Everything a run must be refused for, checked before any download, any API
77
+ * call and any write. Returns the user-facing message, or `null` when the run
78
+ * may proceed.
79
+ */
80
+ export declare function checkInitGuards(input: InitGuardInput): string | null;
@@ -0,0 +1,95 @@
1
+ /**
2
+ * What shape does this `primitive init` run produce? (#2890)
3
+ *
4
+ * One Primitive app can have several clients — a web client and a native
5
+ * client — and they are one app: one appId, one project config, one exported
6
+ * server-config tree, one model schema. `init` therefore composes one of three
7
+ * layouts, and the choice decides everything downstream:
8
+ *
9
+ * standalone — one client, no surrounding project. Today's flat scaffold,
10
+ * unchanged: the client IS the project root.
11
+ * multi-client — several clients, no surrounding project. Each client gets a
12
+ * platform-named subdirectory; the project config, the git
13
+ * repository and the canonical schema live at the root.
14
+ * add-client — an ancestor `.primitive/config.json` already exists. The run
15
+ * ADOPTS it: no nested project config, no nested git
16
+ * repository, no app creation, no commit. This is the path the
17
+ * issue opens with — running init in a subdirectory used to
18
+ * scaffold a second project that had to be partly undone.
19
+ *
20
+ * Pure on purpose: the layout and the guards are the part that is expensive to
21
+ * get wrong and impossible to assert from a half-written scaffold.
22
+ */
23
+ import { join } from "path";
24
+ import { PROJECT_CONFIG_DISPLAY_NAME } from "./project-config.js";
25
+ /** Resolve the layout for this run. */
26
+ export function planInit(input) {
27
+ const adopting = Boolean(input.ancestorProjectRoot);
28
+ const projectRoot = adopting ? input.ancestorProjectRoot : input.targetDir;
29
+ const composed = adopting || input.platforms.length > 1;
30
+ // One client in an adopt run lands exactly where the user pointed the
31
+ // command; anything else gets a platform-named subdirectory, which is what
32
+ // makes `web/` and `ios/` siblings under one root.
33
+ const useSubdirectories = input.platforms.length > 1;
34
+ const clients = input.platforms.map((platform) => ({
35
+ platform,
36
+ dir: useSubdirectories ? join(input.targetDir, platform) : input.targetDir,
37
+ }));
38
+ const mode = adopting
39
+ ? "add-client"
40
+ : input.platforms.length > 1
41
+ ? "multi-client"
42
+ : "standalone";
43
+ return {
44
+ mode,
45
+ clients,
46
+ projectRoot,
47
+ writesProjectConfig: !adopting,
48
+ ownsApp: !adopting,
49
+ initsGit: !adopting,
50
+ canonicalSchemaPath: composed
51
+ ? join(projectRoot, "models", "models.toml")
52
+ : null,
53
+ writesRootAgents: composed,
54
+ };
55
+ }
56
+ /**
57
+ * Everything a run must be refused for, checked before any download, any API
58
+ * call and any write. Returns the user-facing message, or `null` when the run
59
+ * may proceed.
60
+ */
61
+ export function checkInitGuards(input) {
62
+ const root = input.ancestorProjectRoot;
63
+ if (!root) {
64
+ // `add-client` describes adopting a project that is not there.
65
+ if (input.action === "add-client") {
66
+ return (`action = "add-client" adds a client to an existing Primitive app, but there is no ` +
67
+ `${PROJECT_CONFIG_DISPLAY_NAME} in this directory or any parent. ` +
68
+ `Run init from inside the app's repository, or use action = "create" to start a new app.`);
69
+ }
70
+ return null;
71
+ }
72
+ const envName = input.environmentName ?? "the selected environment";
73
+ // Creating a SECOND app inside a repository that already has one is the
74
+ // nesting this change removes.
75
+ if (input.action === "create") {
76
+ return (`action = "create" would create a second Primitive app inside the existing project at ${root}. ` +
77
+ `Use action = "add-client" to add this client to the app that project already targets.`);
78
+ }
79
+ if (!input.environmentAppId) {
80
+ return (`The "${envName}" environment in ${root}/${PROJECT_CONFIG_DISPLAY_NAME} has no appId, so there is no app to add this client to. ` +
81
+ `Set one with \`primitive env add <name> --api-url <url> --app-id <appId>\`, or select an environment that has one with \`primitive env use <name>\`.`);
82
+ }
83
+ // Naming an app explicitly is allowed only when it is the SAME app: a
84
+ // different one would wire this client to a backend the rest of the repo does
85
+ // not target.
86
+ const named = input.flagAppId ?? (input.action === "use-existing" ? input.configAppId : undefined);
87
+ if (named && named !== input.environmentAppId) {
88
+ const source = input.flagAppId ? "--use-existing-app-id" : '`app_id` (action = "use-existing")';
89
+ return (`${source} names app ${named}, but the "${envName}" environment of the project at ${root} targets app ${input.environmentAppId}. ` +
90
+ `A client added to this repository belongs to that app — drop the app id and use action = "add-client", ` +
91
+ `or run init outside this project to scaffold a separate app.`);
92
+ }
93
+ return null;
94
+ }
95
+ //# sourceMappingURL=init-plan.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init-plan.js","sourceRoot":"","sources":["../../../src/lib/init-plan.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AA8DlE,uCAAuC;AACvC,MAAM,UAAU,QAAQ,CAAC,KAAoB;IAC3C,MAAM,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC;IACpD,MAAM,WAAW,GAAG,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,mBAAoB,CAAC,CAAC,CAAC,KAAK,CAAC,SAAS,CAAC;IAC5E,MAAM,QAAQ,GAAG,QAAQ,IAAI,KAAK,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;IAExD,sEAAsE;IACtE,2EAA2E;IAC3E,mDAAmD;IACnD,MAAM,iBAAiB,GAAG,KAAK,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC;IACrD,MAAM,OAAO,GAAiB,KAAK,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC;QAC/D,QAAQ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CAAC,gBAAgB,EAAE,CAAC;QAC5B,OAAO,CACL,QAAQ,OAAO,oBAAoB,IAAI,IAAI,2BAA2B,2DAA2D;YACjI,sJAAsJ,CACvJ,CAAC;IACJ,CAAC;IAED,sEAAsE;IACtE,8EAA8E;IAC9E,cAAc;IACd,MAAM,KAAK,GAAG,KAAK,CAAC,SAAS,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,cAAc,CAAC,CAAC,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IACnG,IAAI,KAAK,IAAI,KAAK,KAAK,KAAK,CAAC,gBAAgB,EAAE,CAAC;QAC9C,MAAM,MAAM,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,oCAAoC,CAAC;QAChG,OAAO,CACL,GAAG,MAAM,cAAc,KAAK,cAAc,OAAO,mCAAmC,IAAI,gBAAgB,KAAK,CAAC,gBAAgB,IAAI;YAClI,yGAAyG;YACzG,8DAA8D,CAC/D,CAAC;IACJ,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Which backend a scaffolded client's PRODUCTION build talks to (#2890).
3
+ *
4
+ * `init` used to write the hosted production URL into `.env.production`
5
+ * unconditionally, alongside the app ID of the app it had just created. On the
6
+ * hosted server those agree. On any other one — a self-hosted server, a staging
7
+ * server, an alpha channel — they do not: the production build points at a
8
+ * backend the app ID does not exist on, and the mismatch only shows up after a
9
+ * deploy.
10
+ *
11
+ * So a composed run derives the pair from the project's own environments
12
+ * instead, and only falls back to the old behavior where it was right anyway:
13
+ *
14
+ * 1. a `prod` environment, then a `production` one — the team already said
15
+ * which backend/app pair production means
16
+ * 2. otherwise, when this run targets the hosted production server, the
17
+ * hosted production URL with this app (today's output)
18
+ * 3. otherwise the selected environment's own server and app — one backend,
19
+ * one app, consistently
20
+ *
21
+ * Standalone runs keep calling the old path verbatim, so a single-client
22
+ * scaffold's output is unchanged (spec decision 1).
23
+ */
24
+ export interface ProductionRuntime {
25
+ serverUrl: string;
26
+ appId: string;
27
+ appName?: string;
28
+ /** Which rule chose it, for the message init prints. */
29
+ source: "environment" | "hosted-production" | "selected";
30
+ /** The environment name, when one was used. */
31
+ environmentName?: string;
32
+ }
33
+ export interface ResolveProductionRuntimeInput {
34
+ /** The project's environments, keyed by name. */
35
+ environments?: Record<string, {
36
+ apiUrl?: string;
37
+ appId?: string;
38
+ appName?: string;
39
+ } | undefined>;
40
+ /** The server this run targets. */
41
+ selectedServerUrl: string;
42
+ /** The app this run scaffolds against. */
43
+ selectedAppId: string;
44
+ selectedAppName?: string;
45
+ /** The hosted production server URL. */
46
+ productionServerUrl: string;
47
+ }
48
+ export declare function resolveProductionRuntime(input: ResolveProductionRuntimeInput): ProductionRuntime;
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Which backend a scaffolded client's PRODUCTION build talks to (#2890).
3
+ *
4
+ * `init` used to write the hosted production URL into `.env.production`
5
+ * unconditionally, alongside the app ID of the app it had just created. On the
6
+ * hosted server those agree. On any other one — a self-hosted server, a staging
7
+ * server, an alpha channel — they do not: the production build points at a
8
+ * backend the app ID does not exist on, and the mismatch only shows up after a
9
+ * deploy.
10
+ *
11
+ * So a composed run derives the pair from the project's own environments
12
+ * instead, and only falls back to the old behavior where it was right anyway:
13
+ *
14
+ * 1. a `prod` environment, then a `production` one — the team already said
15
+ * which backend/app pair production means
16
+ * 2. otherwise, when this run targets the hosted production server, the
17
+ * hosted production URL with this app (today's output)
18
+ * 3. otherwise the selected environment's own server and app — one backend,
19
+ * one app, consistently
20
+ *
21
+ * Standalone runs keep calling the old path verbatim, so a single-client
22
+ * scaffold's output is unchanged (spec decision 1).
23
+ */
24
+ /** Trailing-slash-insensitive comparison, as elsewhere in init. */
25
+ function sameServer(a, b) {
26
+ return a.replace(/\/+$/, "") === b.replace(/\/+$/, "");
27
+ }
28
+ export function resolveProductionRuntime(input) {
29
+ const environments = input.environments ?? {};
30
+ // `prod` first, deliberately: a repo with both names has one of them as the
31
+ // real one, and `prod` is what `primitive init` and the templates use.
32
+ for (const name of ["prod", "production"]) {
33
+ const env = environments[name];
34
+ if (env?.apiUrl && env?.appId) {
35
+ return {
36
+ serverUrl: env.apiUrl,
37
+ appId: env.appId,
38
+ appName: env.appName ?? input.selectedAppName,
39
+ source: "environment",
40
+ environmentName: name,
41
+ };
42
+ }
43
+ }
44
+ if (sameServer(input.selectedServerUrl, input.productionServerUrl)) {
45
+ return {
46
+ serverUrl: input.productionServerUrl,
47
+ appId: input.selectedAppId,
48
+ appName: input.selectedAppName,
49
+ source: "hosted-production",
50
+ };
51
+ }
52
+ return {
53
+ serverUrl: input.selectedServerUrl,
54
+ appId: input.selectedAppId,
55
+ appName: input.selectedAppName,
56
+ source: "selected",
57
+ };
58
+ }
59
+ //# sourceMappingURL=init-production-env.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init-production-env.js","sourceRoot":"","sources":["../../../src/lib/init-production-env.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AA2BH,mEAAmE;AACnE,SAAS,UAAU,CAAC,CAAS,EAAE,CAAS;IACtC,OAAO,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AACzD,CAAC;AAED,MAAM,UAAU,wBAAwB,CACtC,KAAoC;IAEpC,MAAM,YAAY,GAAG,KAAK,CAAC,YAAY,IAAI,EAAE,CAAC;IAC9C,4EAA4E;IAC5E,uEAAuE;IACvE,KAAK,MAAM,IAAI,IAAI,CAAC,MAAM,EAAE,YAAY,CAAC,EAAE,CAAC;QAC1C,MAAM,GAAG,GAAG,YAAY,CAAC,IAAI,CAAC,CAAC;QAC/B,IAAI,GAAG,EAAE,MAAM,IAAI,GAAG,EAAE,KAAK,EAAE,CAAC;YAC9B,OAAO;gBACL,SAAS,EAAE,GAAG,CAAC,MAAM;gBACrB,KAAK,EAAE,GAAG,CAAC,KAAK;gBAChB,OAAO,EAAE,GAAG,CAAC,OAAO,IAAI,KAAK,CAAC,eAAe;gBAC7C,MAAM,EAAE,aAAa;gBACrB,eAAe,EAAE,IAAI;aACtB,CAAC;QACJ,CAAC;IACH,CAAC;IAED,IAAI,UAAU,CAAC,KAAK,CAAC,iBAAiB,EAAE,KAAK,CAAC,mBAAmB,CAAC,EAAE,CAAC;QACnE,OAAO;YACL,SAAS,EAAE,KAAK,CAAC,mBAAmB;YACpC,KAAK,EAAE,KAAK,CAAC,aAAa;YAC1B,OAAO,EAAE,KAAK,CAAC,eAAe;YAC9B,MAAM,EAAE,mBAAmB;SAC5B,CAAC;IACJ,CAAC;IAED,OAAO;QACL,SAAS,EAAE,KAAK,CAAC,iBAAiB;QAClC,KAAK,EAAE,KAAK,CAAC,aAAa;QAC1B,OAAO,EAAE,KAAK,CAAC,eAAe;QAC9B,MAAM,EAAE,UAAU;KACnB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,74 @@
1
+ import type { Platform } from "./resolve-platform.js";
2
+ /** The canonical schema's path, relative to the project root. */
3
+ export declare const CANONICAL_SCHEMA_RELATIVE: string;
4
+ /**
5
+ * A POSIX-style relative specifier from `fromDir` to `toFile`, always prefixed
6
+ * with `./` or `../` — what both an import specifier and a `-i` argument need.
7
+ */
8
+ export declare function relativeSchemaPath(fromDir: string, toFile: string): string;
9
+ /**
10
+ * The schema a freshly installed client template ships, or null when it has
11
+ * none (the Swift starter is comment-only but the file is still there).
12
+ */
13
+ export declare function findClientSchema(clientDir: string, platform: Platform): string | null;
14
+ /** The Swift target's source directory (`Sources/<AppName>`), if there is one. */
15
+ export declare function findSwiftTargetDir(clientDir: string): string | null;
16
+ /**
17
+ * The models a schema declares, in the order it declares them.
18
+ *
19
+ * `[models.<name>]`, `[models.<name>.fields.<field>]` and the array form all
20
+ * name the same model; the loader treats the first path segment after `models`
21
+ * as the model name, and so does this.
22
+ */
23
+ export declare function declaredModelNames(toml: string): string[];
24
+ /**
25
+ * The app's one schema has to declare every model its clients read.
26
+ *
27
+ * A client's template ships both a starter schema and code generated from it —
28
+ * the web template's store reads `UserPref`, and the model generator refuses a
29
+ * schema with no models at all. So composing the shared schema is not "pick a
30
+ * starter": it is the base schema (an existing client's, when one is being
31
+ * promoted) PLUS every model a client being added declares and the base does
32
+ * not. Nothing is ever overwritten — a model the base already declares is the
33
+ * app's definition of it, and stays exactly as it is.
34
+ */
35
+ export declare function composeSchemaContent(input: {
36
+ /** The schema the app already has, or the one being promoted to the root. */
37
+ base: string;
38
+ /** The starter schemas of the clients this run is adding. */
39
+ starters: string[];
40
+ }): {
41
+ content: string;
42
+ added: string[];
43
+ };
44
+ /** What `wireClientToSchema` actually rewrote, for the caller to report. */
45
+ export interface SchemaWiringResult {
46
+ /** Files rewritten or created so this client reads the shared schema. */
47
+ rewired: string[];
48
+ /** The client-local schema copy that was removed, if any. */
49
+ removed?: string;
50
+ /** Set when the client's shape was not recognized and nothing was rewired. */
51
+ error?: string;
52
+ }
53
+ /**
54
+ * Points one client at the shared schema and drops its own copy.
55
+ *
56
+ * Writes the new wiring BEFORE removing the client-local schema, so a failure
57
+ * leaves a client that still has a schema rather than one with neither.
58
+ */
59
+ export declare function wireClientToSchema(clientDir: string, platform: Platform, schemaPath: string): SchemaWiringResult;
60
+ /**
61
+ * Why this client cannot be pointed at the shared schema, or null when it can.
62
+ *
63
+ * Separate from the wiring itself because the answer decides whether the run
64
+ * happens at all: a client that keeps its own schema while the app has another
65
+ * is the two-copies layout the shared schema exists to prevent, so a caller
66
+ * asks this BEFORE it writes the shared file — before the download, when the
67
+ * client already exists.
68
+ */
69
+ export declare function checkClientWiring(clientDir: string, platform: Platform, schemaPath: string): string | null;
70
+ /**
71
+ * Writes the canonical schema, creating `models/` if needed. Never overwrites:
72
+ * an existing shared schema is the app's, not this run's.
73
+ */
74
+ export declare function writeCanonicalSchema(schemaPath: string, content: string): boolean;