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,34 @@
1
+ /**
2
+ * Reading the app identity out of the project a run is adopting (#2890).
3
+ *
4
+ * `getCurrentEnvironment()` resolves from the process's working directory,
5
+ * which is not necessarily inside the project being adopted — `primitive init
6
+ * ../ios` resolves against the TARGET, not the cwd. This resolves the same
7
+ * precedence order (`--env` -> `PRIMITIVE_ENV` -> this machine's selection ->
8
+ * the committed default -> the sole environment) against an explicit root.
9
+ */
10
+ import { join } from "path";
11
+ import { readLocalSelection, selectEnvironmentName } from "./env-resolver-core.js";
12
+ import { PROJECT_CONFIG_DIR, PROJECT_CONFIG_FILENAME, loadProjectConfigFromPath, } from "./project-config.js";
13
+ /**
14
+ * Resolves the environment `init` adopts from the project rooted at `root`.
15
+ * Throws whatever the loader or the selector throws — a broken or ambiguous
16
+ * project config must stop the run, not be guessed around.
17
+ */
18
+ export function resolveAdoptedEnvironment(root, options = {}) {
19
+ const projectConfigPath = join(root, PROJECT_CONFIG_DIR, PROJECT_CONFIG_FILENAME);
20
+ const projectConfig = loadProjectConfigFromPath(projectConfigPath);
21
+ const { name } = selectEnvironmentName(projectConfig, {
22
+ explicitEnvName: options.explicitEnvName ?? null,
23
+ envVarName: options.envVarName ?? null,
24
+ localSelection: readLocalSelection(projectConfigPath),
25
+ configPath: projectConfigPath,
26
+ });
27
+ return {
28
+ name,
29
+ config: projectConfig.environments[name],
30
+ projectConfig,
31
+ projectConfigPath,
32
+ };
33
+ }
34
+ //# sourceMappingURL=init-adopt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init-adopt.js","sourceRoot":"","sources":["../../../src/lib/init-adopt.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AACnF,OAAO,EACL,kBAAkB,EAClB,uBAAuB,EACvB,yBAAyB,GAG1B,MAAM,qBAAqB,CAAC;AAS7B;;;;GAIG;AACH,MAAM,UAAU,yBAAyB,CACvC,IAAY,EACZ,UAA2E,EAAE;IAE7E,MAAM,iBAAiB,GAAG,IAAI,CAAC,IAAI,EAAE,kBAAkB,EAAE,uBAAuB,CAAC,CAAC;IAClF,MAAM,aAAa,GAAG,yBAAyB,CAAC,iBAAiB,CAAC,CAAC;IACnE,MAAM,EAAE,IAAI,EAAE,GAAG,qBAAqB,CAAC,aAAoB,EAAE;QAC3D,eAAe,EAAE,OAAO,CAAC,eAAe,IAAI,IAAI;QAChD,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,IAAI;QACtC,cAAc,EAAE,kBAAkB,CAAC,iBAAiB,CAAC;QACrD,UAAU,EAAE,iBAAiB;KAC9B,CAAC,CAAC;IACH,OAAO;QACL,IAAI;QACJ,MAAM,EAAE,aAAa,CAAC,YAAY,CAAC,IAAI,CAAC;QACxC,aAAa;QACb,iBAAiB;KAClB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * The files `primitive init` writes at the ROOT of a repository that holds
3
+ * several clients of one Primitive app (#2890).
4
+ *
5
+ * These are app-wide, not client-wide: each client's own `AGENTS.md`,
6
+ * `package.json`, runtime config and dependencies ship with its template. What
7
+ * belongs here is only what the clients share — which is exactly the part a
8
+ * team otherwise has to reverse-engineer.
9
+ */
10
+ import type { Platform } from "./resolve-platform.js";
11
+ /** Human label for a platform, used in generated prose and summaries. */
12
+ export declare function platformLabel(platform: Platform): string;
13
+ /**
14
+ * The header prepended to the canonical `models/models.toml`.
15
+ *
16
+ * The schema is not client state: its TOML keys are the wire field names, so a
17
+ * second copy that drifts orphans the first one's records. Saying so in the
18
+ * file is the cheapest place for a reader to find that rule.
19
+ */
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
+ /**
28
+ * The app-wide `AGENTS.md` for a repository with several clients.
29
+ *
30
+ * Written only when there is no `AGENTS.md` at the root already — a client's
31
+ * own file is never replaced by init.
32
+ */
33
+ export declare function rootAgentsMarkdown(input: {
34
+ appName: string;
35
+ clients: Array<{
36
+ platform: Platform;
37
+ dir: string;
38
+ }>;
39
+ }): string;
@@ -0,0 +1,97 @@
1
+ /** Human label for a platform, used in generated prose and summaries. */
2
+ export function platformLabel(platform) {
3
+ return platform === "ios" ? "iOS (SwiftUI)" : "Web (Vue)";
4
+ }
5
+ /**
6
+ * The header prepended to the canonical `models/models.toml`.
7
+ *
8
+ * The schema is not client state: its TOML keys are the wire field names, so a
9
+ * second copy that drifts orphans the first one's records. Saying so in the
10
+ * file is the cheapest place for a reader to find that rule.
11
+ */
12
+ export const CANONICAL_SCHEMA_HEADER = `# The model schema for this app — ONE copy, shared by every client.
13
+ #
14
+ # The TOML keys here are the wire field names, so a second copy that drifts
15
+ # orphans the other one's records. Every client reads THIS file:
16
+ # - the web client's codegen input points at it, and its generated barrel
17
+ # imports it directly
18
+ # - the Swift client names it in \`bao-codegen.json\` beside its sources
19
+ # Add or change a model here, then re-run each client's codegen.
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
+ /**
41
+ * The app-wide `AGENTS.md` for a repository with several clients.
42
+ *
43
+ * Written only when there is no `AGENTS.md` at the root already — a client's
44
+ * own file is never replaced by init.
45
+ */
46
+ export function rootAgentsMarkdown(input) {
47
+ const rows = input.clients
48
+ .map((client) => `- \`${client.dir}/\` — ${platformLabel(client.platform)} client`)
49
+ .join("\n");
50
+ return `# ${input.appName}
51
+
52
+ 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
54
+ client is an independent project in its own directory — there is no workspace
55
+ file and no root \`package.json\`.
56
+
57
+ ## Layout
58
+
59
+ - \`.primitive/config.json\` — the Primitive environments (backend URL + app ID
60
+ per environment). The single source of truth, for every client.
61
+ - \`.primitive/sync/<env>/<appId>/\` — the exported server config (workflows,
62
+ database type configs, app settings) that \`primitive config diff\` and
63
+ \`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}
68
+
69
+ ## Per app vs per client
70
+
71
+ | Per app (here, at the root) | Per client (in its directory) |
72
+ | --- | --- |
73
+ | Environments and app ID | Generated code |
74
+ | Exported server config | Dependencies and build config |
75
+ | Model schema | Runtime connection settings |
76
+ | Secrets | Deploy configuration |
77
+ | — | Its own \`AGENTS.md\` |
78
+
79
+ ## Running commands
80
+
81
+ Every \`primitive\` command walks up to this directory's \`.primitive/config.json\`,
82
+ so it resolves the same app from any client directory and needs no path flag.
83
+ \`primitive env use <name>\` selects the environment every command in this
84
+ repository targets — it is an app-wide selection, not a per-client one.
85
+
86
+ ## Adding another client
87
+
88
+ \`\`\`sh
89
+ primitive init <dir> --platform <web|ios>
90
+ \`\`\`
91
+
92
+ 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
94
+ \`.primitive/\` and no second git repository.
95
+ `;
96
+ }
97
+ //# sourceMappingURL=init-assets.js.map
@@ -0,0 +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,uBAAuB,GAAG;;;;;;;;;;;;;CAatC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,KAGlC;IACC,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO;SACvB,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,OAAO,MAAM,CAAC,GAAG,SAAS,aAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,SAAS,CAAC;SAClF,IAAI,CAAC,IAAI,CAAC,CAAC;IAEd,OAAO,KAAK,KAAK,CAAC,OAAO;;;;;;;;;;;;;;;;;EAiBzB,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BL,CAAC;AACF,CAAC"}
@@ -0,0 +1,98 @@
1
+ export declare const INIT_CONFIG_FILENAME = ".primitive-init.toml";
2
+ export interface InitConfig {
3
+ /**
4
+ * What this run does with the app:
5
+ * - `create` — make a new app (needs `app_name`)
6
+ * - `use-existing` — scaffold against an app that already exists (needs `app_id`)
7
+ * - `add-client` — add another client to the Primitive app the surrounding
8
+ * project already targets (#2890). The app comes from the selected
9
+ * environment of the nearest ancestor `.primitive/config.json`, so this
10
+ * action names no app of its own.
11
+ */
12
+ action: "create" | "use-existing" | "add-client";
13
+ /** App name (required for action = "create") */
14
+ app_name?: string;
15
+ /** Existing app ID (required for action = "use-existing") */
16
+ app_id?: string;
17
+ /** Project directory name */
18
+ dir?: string;
19
+ /** Access mode for the app */
20
+ access_mode?: "public" | "domain" | "invite-only";
21
+ /** Port for local dev server */
22
+ dev_port?: number;
23
+ /** Whether to skip npm install */
24
+ skip_install?: boolean;
25
+ /**
26
+ * Custom server URL. Behaves like the `-s/--server` flag: the app is created
27
+ * on this server and the scaffolded project config records it. The flag wins
28
+ * when both are given. (#2376)
29
+ */
30
+ server?: string;
31
+ /** Email addresses to invite (for invite-only mode) */
32
+ invite_emails?: string[];
33
+ /** Allowed email domains (for domain mode) */
34
+ allowed_domains?: string[];
35
+ /** Whether to overwrite a non-empty target directory (default: false) */
36
+ overwrite?: boolean;
37
+ /**
38
+ * Target platform(s) for the scaffolded client(s): `"web"`, `"ios"`, a
39
+ * comma-separated string, or a TOML array (`platform = ["web", "ios"]`).
40
+ */
41
+ platform?: string | string[];
42
+ /**
43
+ * Non-interactive consent to move an existing single-client repo's model
44
+ * schema to `<project root>/models/models.toml` so both clients read one copy
45
+ * (#2890). Valid only with `action = "add-client"`.
46
+ */
47
+ promote_schema?: boolean;
48
+ }
49
+ export interface ValidationResult {
50
+ valid: boolean;
51
+ errors: string[];
52
+ }
53
+ /**
54
+ * Resolves the "use an existing app" app id from the two places it can be
55
+ * specified: the `--use-existing-app-id` CLI flag (highest precedence) or an
56
+ * init-config TOML with `action = "use-existing"` + `app_id`.
57
+ *
58
+ * Before this existed, `init` only read the flag, so a `use-existing` TOML fell
59
+ * through to the create-app branch and interactively prompted for an app name —
60
+ * hanging non-interactive (`--config`) runs. (See js-bao-wss #1217.)
61
+ *
62
+ * Returns `undefined` when neither source selects an existing app (i.e. the run
63
+ * should create a new app).
64
+ */
65
+ export declare function resolveUseExistingAppId(flag: string | undefined, initConfig: InitConfig | null): string | undefined;
66
+ /** Where the resolved "skip dependency install" decision came from. */
67
+ export type SkipInstallSource = "flag" | "config" | "default";
68
+ export interface ResolvedSkipInstall {
69
+ skipInstall: boolean;
70
+ source: SkipInstallSource;
71
+ }
72
+ /**
73
+ * Resolves whether `primitive init` skips the dependency install, from the two
74
+ * places it can be requested: the `--skip-install` flag (highest precedence)
75
+ * or `skip_install = true` in the init-config TOML.
76
+ *
77
+ * `init` used to read only the flag, so a config's `skip_install` was silently
78
+ * ignored and CI runs installed anyway (#2720). Precedence matches #2376's
79
+ * `server` fix: the flag wins. Because `--skip-install` is a boolean flag it
80
+ * can only ever request a skip, so an explicit `skip_install = false` in the
81
+ * config cannot un-skip a run that passed the flag.
82
+ */
83
+ export declare function resolveSkipInstall(flag: boolean | undefined, initConfig: InitConfig | null): ResolvedSkipInstall;
84
+ /**
85
+ * Parses a TOML string into an InitConfig object.
86
+ * Throws if the string contains invalid TOML.
87
+ */
88
+ export declare function parseInitConfigToml(content: string): InitConfig;
89
+ /**
90
+ * Loads and parses a .primitive-init.toml file from the given directory.
91
+ * Returns null if the file does not exist.
92
+ * Throws if the file exists but contains invalid TOML.
93
+ */
94
+ export declare function loadInitConfig(dir: string): InitConfig | null;
95
+ /**
96
+ * Validates an InitConfig object. Returns a ValidationResult with any errors.
97
+ */
98
+ export declare function validateInitConfig(config: InitConfig): ValidationResult;
@@ -0,0 +1,186 @@
1
+ import { existsSync, readFileSync } from "fs";
2
+ import { join } from "path";
3
+ import { parseConfigToml } from "./config-toml.js";
4
+ import { PROJECT_CONFIG_DISPLAY_NAME } from "./project-config.js";
5
+ import { parsePlatformList } from "./resolve-platform.js";
6
+ import { validateServerUrl } from "./server-url.js";
7
+ export const INIT_CONFIG_FILENAME = ".primitive-init.toml";
8
+ /**
9
+ * Resolves the "use an existing app" app id from the two places it can be
10
+ * specified: the `--use-existing-app-id` CLI flag (highest precedence) or an
11
+ * init-config TOML with `action = "use-existing"` + `app_id`.
12
+ *
13
+ * Before this existed, `init` only read the flag, so a `use-existing` TOML fell
14
+ * through to the create-app branch and interactively prompted for an app name —
15
+ * hanging non-interactive (`--config`) runs. (See js-bao-wss #1217.)
16
+ *
17
+ * Returns `undefined` when neither source selects an existing app (i.e. the run
18
+ * should create a new app).
19
+ */
20
+ export function resolveUseExistingAppId(flag, initConfig) {
21
+ if (flag)
22
+ return flag;
23
+ if (initConfig?.action === "use-existing")
24
+ return initConfig.app_id;
25
+ return undefined;
26
+ }
27
+ /**
28
+ * Resolves whether `primitive init` skips the dependency install, from the two
29
+ * places it can be requested: the `--skip-install` flag (highest precedence)
30
+ * or `skip_install = true` in the init-config TOML.
31
+ *
32
+ * `init` used to read only the flag, so a config's `skip_install` was silently
33
+ * ignored and CI runs installed anyway (#2720). Precedence matches #2376's
34
+ * `server` fix: the flag wins. Because `--skip-install` is a boolean flag it
35
+ * can only ever request a skip, so an explicit `skip_install = false` in the
36
+ * config cannot un-skip a run that passed the flag.
37
+ */
38
+ export function resolveSkipInstall(flag, initConfig) {
39
+ if (flag)
40
+ return { skipInstall: true, source: "flag" };
41
+ // Strict `=== true`: a non-boolean that slipped past validation must not
42
+ // skip the install by truthiness (`skip_install = "false"` reads as a skip).
43
+ if (initConfig?.skip_install === true) {
44
+ return { skipInstall: true, source: "config" };
45
+ }
46
+ return { skipInstall: false, source: "default" };
47
+ }
48
+ /**
49
+ * Parses a TOML string into an InitConfig object.
50
+ * Throws if the string contains invalid TOML.
51
+ */
52
+ export function parseInitConfigToml(content) {
53
+ const parsed = parseConfigToml(content);
54
+ // The cast is safe because validateInitConfig() is always called after parsing
55
+ return parsed;
56
+ }
57
+ /**
58
+ * Loads and parses a .primitive-init.toml file from the given directory.
59
+ * Returns null if the file does not exist.
60
+ * Throws if the file exists but contains invalid TOML.
61
+ */
62
+ export function loadInitConfig(dir) {
63
+ const configPath = join(dir, INIT_CONFIG_FILENAME);
64
+ if (!existsSync(configPath)) {
65
+ return null;
66
+ }
67
+ const content = readFileSync(configPath, "utf-8");
68
+ return parseInitConfigToml(content);
69
+ }
70
+ /**
71
+ * Validates an InitConfig object. Returns a ValidationResult with any errors.
72
+ */
73
+ export function validateInitConfig(config) {
74
+ const errors = [];
75
+ // action is required
76
+ const ACTIONS = ["create", "use-existing", "add-client"];
77
+ if (!config.action) {
78
+ errors.push(`Missing required field: "action" (must be ${ACTIONS.map((a) => `"${a}"`).join(", ")})`);
79
+ }
80
+ else if (!ACTIONS.includes(config.action)) {
81
+ errors.push(`"action" must be ${ACTIONS.map((a) => `"${a}"`).join(", ")}`);
82
+ }
83
+ else {
84
+ // Validate action-specific required fields
85
+ if (config.action === "create" && !config.app_name) {
86
+ errors.push('"app_name" is required when action is "create"');
87
+ }
88
+ if (config.action === "use-existing" && !config.app_id) {
89
+ errors.push('"app_id" is required when action is "use-existing"');
90
+ }
91
+ // `add-client` takes its app — and therefore its access mode and its
92
+ // invitations — from the environment it adopts. Naming any of them here
93
+ // would describe a second app this run is not allowed to touch.
94
+ if (config.action === "add-client") {
95
+ for (const key of [
96
+ "app_name",
97
+ "app_id",
98
+ "access_mode",
99
+ "invite_emails",
100
+ "allowed_domains",
101
+ ]) {
102
+ const value = config[key];
103
+ const present = Array.isArray(value) ? value.length > 0 : value !== undefined;
104
+ if (present) {
105
+ errors.push(`"${key}" is not allowed with action = "add-client": the app comes from the selected environment of the existing ${PROJECT_CONFIG_DISPLAY_NAME}.`);
106
+ }
107
+ }
108
+ }
109
+ }
110
+ // Validate access_mode if provided
111
+ if (config.access_mode) {
112
+ const validModes = ["public", "domain", "invite-only"];
113
+ if (!validModes.includes(config.access_mode)) {
114
+ errors.push('"access_mode" must be "public", "domain", or "invite-only"');
115
+ }
116
+ else if (config.access_mode === "domain" && (!config.allowed_domains || config.allowed_domains.length === 0)) {
117
+ errors.push('"allowed_domains" is required when access_mode is "domain"');
118
+ }
119
+ }
120
+ // Validate platform if provided. A string or an array of strings; only "web"
121
+ // and "ios" are supported (`macos` is intentionally rejected until the macOS
122
+ // template is ready), and each may be named once (#2890).
123
+ if (config.platform !== undefined) {
124
+ if (typeof config.platform !== "string" && !Array.isArray(config.platform)) {
125
+ errors.push('"platform" must be a string or an array of strings');
126
+ }
127
+ else {
128
+ const parsed = parsePlatformList(config.platform);
129
+ if (!parsed.ok)
130
+ errors.push(`"platform": ${parsed.error}`);
131
+ }
132
+ }
133
+ // `promote_schema` is consent for a move that only the add-client path can
134
+ // make; anywhere else it would silently do nothing.
135
+ if (config.promote_schema !== undefined) {
136
+ if (typeof config.promote_schema !== "boolean") {
137
+ errors.push('"promote_schema" must be a boolean (true or false)');
138
+ }
139
+ else if (config.action !== "add-client") {
140
+ errors.push('"promote_schema" is only valid with action = "add-client"');
141
+ }
142
+ }
143
+ // Validate server if provided. An unusable value must fail here rather than
144
+ // fall through to the current server, which is how #2376 went unnoticed.
145
+ if (config.server !== undefined) {
146
+ const serverValidation = validateServerUrl(config.server);
147
+ if (serverValidation !== true) {
148
+ errors.push(`"server" must be a valid URL (e.g., https://primitiveapi.com): ${serverValidation}`);
149
+ }
150
+ }
151
+ // Validate skip_install if provided. The TOML is cast to InitConfig without
152
+ // runtime narrowing, so a non-boolean has to be rejected here rather than
153
+ // reach the resolver, where anything truthy would skip the install.
154
+ if (config.skip_install !== undefined && typeof config.skip_install !== "boolean") {
155
+ errors.push('"skip_install" must be a boolean (true or false)');
156
+ }
157
+ // Validate dev_port if provided
158
+ if (config.dev_port !== undefined) {
159
+ if (typeof config.dev_port !== "number" || !Number.isInteger(config.dev_port) || config.dev_port < 1 || config.dev_port > 65535) {
160
+ errors.push('"dev_port" must be an integer between 1 and 65535');
161
+ }
162
+ }
163
+ // Validate invite_emails format if provided
164
+ if (config.invite_emails && Array.isArray(config.invite_emails)) {
165
+ for (const email of config.invite_emails) {
166
+ if (!email.includes("@")) {
167
+ errors.push(`Invalid email in invite_emails: "${email}"`);
168
+ }
169
+ }
170
+ }
171
+ // Warn about fields ignored for use-existing action
172
+ if (config.action === "use-existing") {
173
+ const ignoredFields = [];
174
+ if (config.access_mode)
175
+ ignoredFields.push("access_mode");
176
+ if (config.invite_emails && config.invite_emails.length > 0)
177
+ ignoredFields.push("invite_emails");
178
+ if (config.allowed_domains && config.allowed_domains.length > 0)
179
+ ignoredFields.push("allowed_domains");
180
+ if (ignoredFields.length > 0) {
181
+ errors.push(`The following fields are ignored when action is "use-existing": ${ignoredFields.join(", ")}. Remove them to avoid confusion.`);
182
+ }
183
+ }
184
+ return { valid: errors.length === 0, errors };
185
+ }
186
+ //# sourceMappingURL=init-config.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"init-config.js","sourceRoot":"","sources":["../../../src/lib/init-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,IAAI,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACnD,OAAO,EAAE,2BAA2B,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpD,MAAM,CAAC,MAAM,oBAAoB,GAAG,sBAAsB,CAAC;AAuD3D;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,uBAAuB,CACrC,IAAwB,EACxB,UAA6B;IAE7B,IAAI,IAAI;QAAE,OAAO,IAAI,CAAC;IACtB,IAA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,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC;gBACzB,MAAM,CAAC,IAAI,CAAC,oCAAoC,KAAK,GAAG,CAAC,CAAC;YAC5D,CAAC;QACH,CAAC;IACH,CAAC;IAED,oDAAoD;IACpD,IAAI,MAAM,CAAC,MAAM,KAAK,cAAc,EAAE,CAAC;QACrC,MAAM,aAAa,GAAa,EAAE,CAAC;QACnC,IAAI,MAAM,CAAC,WAAW;YAAE,aAAa,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;QAC1D,IAAI,MAAM,CAAC,aAAa,IAAI,MAAM,CAAC,aAAa,CAAC,MAAM,GAAG,CAAC;YAAE,aAAa,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QACjG,IAAI,MAAM,CAAC,eAAe,IAAI,MAAM,CAAC,eAAe,CAAC,MAAM,GAAG,CAAC;YAAE,aAAa,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;QACvG,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YAC7B,MAAM,CAAC,IAAI,CAAC,mEAAmE,aAAa,CAAC,IAAI,CAAC,IAAI,CAAC,mCAAmC,CAAC,CAAC;QAC9I,CAAC;IACH,CAAC;IAED,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;AAChD,CAAC"}
@@ -0,0 +1,50 @@
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.
5
+ */
6
+ export declare const PRIMITIVE_AUTH_URL_TYPE_NAME = "PrimitiveAuth";
7
+ /** The library's fallback scheme — reserved, never a derived result. */
8
+ export declare const FALLBACK_CALLBACK_SCHEME = "primitiveapp";
9
+ /**
10
+ * The custom URL scheme for one scaffolded client: a readable prefix from the
11
+ * app name, then the full lowercased app ID.
12
+ *
13
+ * Deterministic and injective over server-generated app IDs — two apps never
14
+ * share a scheme, whatever they are called.
15
+ */
16
+ 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;
19
+ export interface StampResult {
20
+ /** `not-found` when the plist predates the `PrimitiveAuth` URL type. */
21
+ outcome: "stamped" | "already" | "not-found";
22
+ }
23
+ /**
24
+ * Replaces the scheme registered under the `PrimitiveAuth` URL type in a
25
+ * scaffolded client's `Info-Partial.plist`.
26
+ *
27
+ * A targeted text substitution, not a plist rewrite: the file's comments are
28
+ * the checklist a developer reads when their emailed link does nothing, and a
29
+ * serializer would drop them.
30
+ */
31
+ export declare function stampCallbackScheme(clientDir: string, scheme: string): StampResult;
32
+ /**
33
+ * What init prints about email sign-in on the iOS path: it already works, and
34
+ * this is the one opt-in that adds the link.
35
+ *
36
+ * The allow-list step is phrased as a MERGE into the existing array — `app.toml`
37
+ * is the whole app-settings truth on push (#2880), so a replacement array would
38
+ * silently drop the web callback the app was seeded with.
39
+ *
40
+ * `registered` is false when the scheme could not be stamped (an older template
41
+ * with no `PrimitiveAuth` URL type). The allow-list entry and the flag are the
42
+ * same either way, but the closing line must not claim a registration that is
43
+ * not there: a developer who did only the two steps would be left with a dead
44
+ * tap and nothing naming the missing piece.
45
+ */
46
+ export declare function linkOptInGuidance(scheme: string, options?: {
47
+ registered?: boolean;
48
+ }): string[];
49
+ /** What init says when the template predates the `PrimitiveAuth` URL type. */
50
+ export declare function missingUrlTypeGuidance(scheme: string): string[];