primitive-admin 1.1.0-alpha.9 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (591) hide show
  1. package/README.md +523 -109
  2. package/assets/skill/skills/primitive-platform/SKILL.md +289 -0
  3. package/dist/bin/primitive.d.ts +2 -0
  4. package/dist/bin/primitive.js +372 -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 +136 -30
  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 +713 -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 +65 -100
  14. package/dist/src/commands/apps.js.map +1 -1
  15. package/dist/src/commands/auth-sessions.d.ts +7 -0
  16. package/dist/src/commands/auth-sessions.js +144 -0
  17. package/dist/src/commands/auth-sessions.js.map +1 -0
  18. package/dist/src/commands/auth.d.ts +2 -0
  19. package/dist/src/commands/auth.js +238 -108
  20. package/dist/src/commands/auth.js.map +1 -1
  21. package/dist/src/commands/blob-buckets.d.ts +2 -0
  22. package/dist/src/commands/blob-buckets.js +331 -0
  23. package/dist/src/commands/blob-buckets.js.map +1 -0
  24. package/dist/src/commands/catalog.d.ts +2 -0
  25. package/dist/src/commands/catalog.js +63 -48
  26. package/dist/src/commands/catalog.js.map +1 -1
  27. package/dist/src/commands/collection-type-configs.d.ts +2 -0
  28. package/dist/src/commands/collection-type-configs.js +85 -0
  29. package/dist/src/commands/collection-type-configs.js.map +1 -0
  30. package/dist/src/commands/collections.d.ts +2 -0
  31. package/dist/src/commands/collections.js +1282 -0
  32. package/dist/src/commands/collections.js.map +1 -0
  33. package/dist/src/commands/comparisons.d.ts +2 -0
  34. package/dist/src/commands/comparisons.js +6 -6
  35. package/dist/src/commands/comparisons.js.map +1 -1
  36. package/dist/src/commands/config.d.ts +46 -0
  37. package/dist/src/commands/config.js +465 -0
  38. package/dist/src/commands/config.js.map +1 -0
  39. package/dist/src/commands/connections.d.ts +2 -0
  40. package/dist/src/commands/connections.js +99 -0
  41. package/dist/src/commands/connections.js.map +1 -0
  42. package/dist/src/commands/cron-triggers.d.ts +2 -0
  43. package/dist/src/commands/cron-triggers.js +266 -0
  44. package/dist/src/commands/cron-triggers.js.map +1 -0
  45. package/dist/src/commands/database-type-configs.d.ts +2 -0
  46. package/dist/src/commands/database-type-configs.js +164 -0
  47. package/dist/src/commands/database-type-configs.js.map +1 -0
  48. package/dist/src/commands/database-types.d.ts +2 -0
  49. package/dist/src/commands/database-types.js +471 -0
  50. package/dist/src/commands/database-types.js.map +1 -0
  51. package/dist/src/commands/databases.d.ts +65 -0
  52. package/dist/src/commands/databases.js +1887 -243
  53. package/dist/src/commands/databases.js.map +1 -1
  54. package/dist/src/commands/documents.d.ts +60 -0
  55. package/dist/src/commands/documents.js +2888 -22
  56. package/dist/src/commands/documents.js.map +1 -1
  57. package/dist/src/commands/email-templates.d.ts +2 -0
  58. package/dist/src/commands/email-templates.js +175 -0
  59. package/dist/src/commands/email-templates.js.map +1 -0
  60. package/dist/src/commands/env.d.ts +23 -0
  61. package/dist/src/commands/env.js +395 -0
  62. package/dist/src/commands/env.js.map +1 -0
  63. package/dist/src/commands/feature-flags.d.ts +14 -0
  64. package/dist/src/commands/feature-flags.js +117 -0
  65. package/dist/src/commands/feature-flags.js.map +1 -0
  66. package/dist/src/commands/functions.d.ts +20 -0
  67. package/dist/src/commands/functions.js +1630 -0
  68. package/dist/src/commands/functions.js.map +1 -0
  69. package/dist/src/commands/group-type-configs.d.ts +2 -0
  70. package/dist/src/commands/group-type-configs.js +87 -0
  71. package/dist/src/commands/group-type-configs.js.map +1 -0
  72. package/dist/src/commands/groups.d.ts +2 -0
  73. package/dist/src/commands/groups.js +65 -113
  74. package/dist/src/commands/groups.js.map +1 -1
  75. package/dist/src/commands/guides.d.ts +223 -0
  76. package/dist/src/commands/guides.js +627 -69
  77. package/dist/src/commands/guides.js.map +1 -1
  78. package/dist/src/commands/init.d.ts +37 -0
  79. package/dist/src/commands/init.js +1693 -208
  80. package/dist/src/commands/init.js.map +1 -1
  81. package/dist/src/commands/integrations.d.ts +2 -0
  82. package/dist/src/commands/integrations.js +428 -187
  83. package/dist/src/commands/integrations.js.map +1 -1
  84. package/dist/src/commands/llm.d.ts +2 -0
  85. package/dist/src/commands/llm.js +4 -2
  86. package/dist/src/commands/llm.js.map +1 -1
  87. package/dist/src/commands/locks.d.ts +8 -0
  88. package/dist/src/commands/locks.js +175 -0
  89. package/dist/src/commands/locks.js.map +1 -0
  90. package/dist/src/commands/metadata-category-configs.d.ts +12 -0
  91. package/dist/src/commands/metadata-category-configs.js +113 -0
  92. package/dist/src/commands/metadata-category-configs.js.map +1 -0
  93. package/dist/src/commands/metadata.d.ts +2 -0
  94. package/dist/src/commands/metadata.js +288 -0
  95. package/dist/src/commands/metadata.js.map +1 -0
  96. package/dist/src/commands/prompts.d.ts +2 -0
  97. package/dist/src/commands/prompts.js +322 -634
  98. package/dist/src/commands/prompts.js.map +1 -1
  99. package/dist/src/commands/rule-sets.d.ts +3 -0
  100. package/dist/src/commands/rule-sets.js +139 -148
  101. package/dist/src/commands/rule-sets.js.map +1 -1
  102. package/dist/src/commands/scripts.d.ts +30 -0
  103. package/dist/src/commands/scripts.js +688 -0
  104. package/dist/src/commands/scripts.js.map +1 -0
  105. package/dist/src/commands/secrets.d.ts +2 -0
  106. package/dist/src/commands/secrets.js +109 -0
  107. package/dist/src/commands/secrets.js.map +1 -0
  108. package/dist/src/commands/sessions.d.ts +2 -0
  109. package/dist/src/commands/sessions.js +76 -0
  110. package/dist/src/commands/sessions.js.map +1 -0
  111. package/dist/src/commands/skill.d.ts +2 -0
  112. package/dist/src/commands/skill.js +29 -0
  113. package/dist/src/commands/skill.js.map +1 -0
  114. package/dist/src/commands/sync-app-settings.d.ts +158 -0
  115. package/dist/src/commands/sync-app-settings.js +328 -0
  116. package/dist/src/commands/sync-app-settings.js.map +1 -0
  117. package/dist/src/commands/sync.d.ts +2670 -0
  118. package/dist/src/commands/sync.js +17144 -834
  119. package/dist/src/commands/sync.js.map +1 -1
  120. package/dist/src/commands/tokens.d.ts +2 -0
  121. package/dist/src/commands/tokens.js +132 -22
  122. package/dist/src/commands/tokens.js.map +1 -1
  123. package/dist/src/commands/users.d.ts +2 -0
  124. package/dist/src/commands/users.js +542 -24
  125. package/dist/src/commands/users.js.map +1 -1
  126. package/dist/src/commands/vars.d.ts +8 -0
  127. package/dist/src/commands/vars.js +97 -0
  128. package/dist/src/commands/vars.js.map +1 -0
  129. package/dist/src/commands/waitlist.d.ts +2 -0
  130. package/dist/src/commands/waitlist.js +12 -11
  131. package/dist/src/commands/waitlist.js.map +1 -1
  132. package/dist/src/commands/webhooks.d.ts +31 -0
  133. package/dist/src/commands/webhooks.js +633 -0
  134. package/dist/src/commands/webhooks.js.map +1 -0
  135. package/dist/src/commands/workflows.d.ts +88 -0
  136. package/dist/src/commands/workflows.js +1568 -742
  137. package/dist/src/commands/workflows.js.map +1 -1
  138. package/dist/src/lib/access-rule-display.d.ts +21 -0
  139. package/dist/src/lib/access-rule-display.js +34 -0
  140. package/dist/src/lib/access-rule-display.js.map +1 -0
  141. package/dist/src/lib/api-client.d.ts +2550 -0
  142. package/dist/src/lib/api-client.js +2503 -160
  143. package/dist/src/lib/api-client.js.map +1 -1
  144. package/dist/src/lib/app-settings-descriptor.d.ts +263 -0
  145. package/dist/src/lib/app-settings-descriptor.js +583 -0
  146. package/dist/src/lib/app-settings-descriptor.js.map +1 -0
  147. package/dist/src/lib/auth-flow.d.ts +8 -0
  148. package/dist/src/lib/batch.d.ts +26 -0
  149. package/dist/src/lib/batch.js +32 -0
  150. package/dist/src/lib/batch.js.map +1 -0
  151. package/dist/src/lib/block-layout.d.ts +160 -0
  152. package/dist/src/lib/block-layout.js +451 -0
  153. package/dist/src/lib/block-layout.js.map +1 -0
  154. package/dist/src/lib/block-selector.d.ts +58 -0
  155. package/dist/src/lib/block-selector.js +92 -0
  156. package/dist/src/lib/block-selector.js.map +1 -0
  157. package/dist/src/lib/canonical-json.d.ts +12 -0
  158. package/dist/src/lib/canonical-json.js +35 -0
  159. package/dist/src/lib/canonical-json.js.map +1 -0
  160. package/dist/src/lib/channel.d.ts +30 -0
  161. package/dist/src/lib/channel.js +68 -0
  162. package/dist/src/lib/channel.js.map +1 -0
  163. package/dist/src/lib/cli-manifest.d.ts +68 -0
  164. package/dist/src/lib/cli-manifest.js +71 -0
  165. package/dist/src/lib/cli-manifest.js.map +1 -0
  166. package/dist/src/lib/codegen-shared/generatedFiles.d.ts +101 -0
  167. package/dist/src/lib/codegen-shared/generatedFiles.js +191 -0
  168. package/dist/src/lib/codegen-shared/generatedFiles.js.map +1 -0
  169. package/dist/src/lib/codegen-shared/prettierStable.d.ts +262 -0
  170. package/dist/src/lib/codegen-shared/prettierStable.js +610 -0
  171. package/dist/src/lib/codegen-shared/prettierStable.js.map +1 -0
  172. package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.d.ts +38 -0
  173. package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.js +46 -0
  174. package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.js.map +1 -0
  175. package/dist/src/lib/collection-export.d.ts +184 -0
  176. package/dist/src/lib/collection-export.js +252 -0
  177. package/dist/src/lib/collection-export.js.map +1 -0
  178. package/dist/src/lib/config-json-field.d.ts +28 -0
  179. package/dist/src/lib/config-json-field.js +56 -0
  180. package/dist/src/lib/config-json-field.js.map +1 -0
  181. package/dist/src/lib/config-object-descriptor.d.ts +127 -0
  182. package/dist/src/lib/config-object-descriptor.js +740 -0
  183. package/dist/src/lib/config-object-descriptor.js.map +1 -0
  184. package/dist/src/lib/config-payload.d.ts +92 -0
  185. package/dist/src/lib/config-payload.js +161 -0
  186. package/dist/src/lib/config-payload.js.map +1 -0
  187. package/dist/src/lib/config-surface.d.ts +141 -0
  188. package/dist/src/lib/config-surface.js +368 -0
  189. package/dist/src/lib/config-surface.js.map +1 -0
  190. package/dist/src/lib/config-toml.d.ts +10 -0
  191. package/dist/src/lib/config-toml.js +42 -0
  192. package/dist/src/lib/config-toml.js.map +1 -0
  193. package/dist/src/lib/config.d.ts +71 -0
  194. package/dist/src/lib/config.js +71 -68
  195. package/dist/src/lib/config.js.map +1 -1
  196. package/dist/src/lib/confirm-prompt.d.ts +83 -0
  197. package/dist/src/lib/confirm-prompt.js +110 -0
  198. package/dist/src/lib/confirm-prompt.js.map +1 -0
  199. package/dist/src/lib/constants.d.ts +11 -0
  200. package/dist/src/lib/constants.js +12 -0
  201. package/dist/src/lib/constants.js.map +1 -0
  202. package/dist/src/lib/crash-handlers.d.ts +20 -0
  203. package/dist/src/lib/crash-handlers.js +49 -0
  204. package/dist/src/lib/crash-handlers.js.map +1 -0
  205. package/dist/src/lib/credentials-store.d.ts +104 -0
  206. package/dist/src/lib/credentials-store.js +336 -0
  207. package/dist/src/lib/credentials-store.js.map +1 -0
  208. package/dist/src/lib/csv.d.ts +47 -0
  209. package/dist/src/lib/csv.js +172 -0
  210. package/dist/src/lib/csv.js.map +1 -0
  211. package/dist/src/lib/data-input.d.ts +23 -0
  212. package/dist/src/lib/data-input.js +50 -0
  213. package/dist/src/lib/data-input.js.map +1 -0
  214. package/dist/src/lib/db-codegen/dbFingerprint.d.ts +10 -0
  215. package/dist/src/lib/db-codegen/dbFingerprint.js +17 -0
  216. package/dist/src/lib/db-codegen/dbFingerprint.js.map +1 -0
  217. package/dist/src/lib/db-codegen/dbGenerator.d.ts +67 -0
  218. package/dist/src/lib/db-codegen/dbGenerator.js +170 -0
  219. package/dist/src/lib/db-codegen/dbGenerator.js.map +1 -0
  220. package/dist/src/lib/db-codegen/dbNaming.d.ts +87 -0
  221. package/dist/src/lib/db-codegen/dbNaming.js +180 -0
  222. package/dist/src/lib/db-codegen/dbNaming.js.map +1 -0
  223. package/dist/src/lib/db-codegen/dbTemplates.d.ts +272 -0
  224. package/dist/src/lib/db-codegen/dbTemplates.js +480 -0
  225. package/dist/src/lib/db-codegen/dbTemplates.js.map +1 -0
  226. package/dist/src/lib/db-codegen/dbTsTypes.d.ts +73 -0
  227. package/dist/src/lib/db-codegen/dbTsTypes.js +139 -0
  228. package/dist/src/lib/db-codegen/dbTsTypes.js.map +1 -0
  229. package/dist/src/lib/db-codegen/dbTypeIR.d.ts +146 -0
  230. package/dist/src/lib/db-codegen/dbTypeIR.js +525 -0
  231. package/dist/src/lib/db-codegen/dbTypeIR.js.map +1 -0
  232. package/dist/src/lib/db-codegen/generated-operation-def-descriptor.d.ts +112 -0
  233. package/dist/src/lib/db-codegen/generated-operation-def-descriptor.js +211 -0
  234. package/dist/src/lib/db-codegen/generated-operation-def-descriptor.js.map +1 -0
  235. package/dist/src/lib/deprecation.d.ts +22 -0
  236. package/dist/src/lib/deprecation.js +43 -0
  237. package/dist/src/lib/deprecation.js.map +1 -0
  238. package/dist/src/lib/document-export-permissions.d.ts +30 -0
  239. package/dist/src/lib/document-export-permissions.js +54 -0
  240. package/dist/src/lib/document-export-permissions.js.map +1 -0
  241. package/dist/src/lib/document-ingest-artifact.d.ts +120 -0
  242. package/dist/src/lib/document-ingest-artifact.js +505 -0
  243. package/dist/src/lib/document-ingest-artifact.js.map +1 -0
  244. package/dist/src/lib/document-ingest-input.d.ts +51 -0
  245. package/dist/src/lib/document-ingest-input.js +132 -0
  246. package/dist/src/lib/document-ingest-input.js.map +1 -0
  247. package/dist/src/lib/document-ingest-rows.d.ts +137 -0
  248. package/dist/src/lib/document-ingest-rows.js +181 -0
  249. package/dist/src/lib/document-ingest-rows.js.map +1 -0
  250. package/dist/src/lib/document-ingest.d.ts +101 -0
  251. package/dist/src/lib/document-ingest.js +384 -0
  252. package/dist/src/lib/document-ingest.js.map +1 -0
  253. package/dist/src/lib/env-resolver-core.d.ts +258 -0
  254. package/dist/src/lib/env-resolver-core.js +447 -0
  255. package/dist/src/lib/env-resolver-core.js.map +1 -0
  256. package/dist/src/lib/env-resolver.d.ts +99 -0
  257. package/dist/src/lib/env-resolver.js +153 -0
  258. package/dist/src/lib/env-resolver.js.map +1 -0
  259. package/dist/src/lib/fetch.d.ts +5 -0
  260. package/dist/src/lib/function-bundle.d.ts +147 -0
  261. package/dist/src/lib/function-bundle.js +341 -0
  262. package/dist/src/lib/function-bundle.js.map +1 -0
  263. package/dist/src/lib/function-collect.d.ts +123 -0
  264. package/dist/src/lib/function-collect.js +610 -0
  265. package/dist/src/lib/function-collect.js.map +1 -0
  266. package/dist/src/lib/function-db-types.d.ts +202 -0
  267. package/dist/src/lib/function-db-types.js +870 -0
  268. package/dist/src/lib/function-db-types.js.map +1 -0
  269. package/dist/src/lib/function-document-types.d.ts +144 -0
  270. package/dist/src/lib/function-document-types.js +370 -0
  271. package/dist/src/lib/function-document-types.js.map +1 -0
  272. package/dist/src/lib/function-grants-preflight.d.ts +64 -0
  273. package/dist/src/lib/function-grants-preflight.js +105 -0
  274. package/dist/src/lib/function-grants-preflight.js.map +1 -0
  275. package/dist/src/lib/function-log-lines.d.ts +76 -0
  276. package/dist/src/lib/function-log-lines.js +160 -0
  277. package/dist/src/lib/function-log-lines.js.map +1 -0
  278. package/dist/src/lib/function-log-row.d.ts +29 -0
  279. package/dist/src/lib/function-log-row.js +73 -0
  280. package/dist/src/lib/function-log-row.js.map +1 -0
  281. package/dist/src/lib/function-log-tail.d.ts +132 -0
  282. package/dist/src/lib/function-log-tail.js +262 -0
  283. package/dist/src/lib/function-log-tail.js.map +1 -0
  284. package/dist/src/lib/function-run.d.ts +289 -0
  285. package/dist/src/lib/function-run.js +389 -0
  286. package/dist/src/lib/function-run.js.map +1 -0
  287. package/dist/src/lib/function-schema-codegen.d.ts +143 -0
  288. package/dist/src/lib/function-schema-codegen.js +420 -0
  289. package/dist/src/lib/function-schema-codegen.js.map +1 -0
  290. package/dist/src/lib/function-sync.d.ts +459 -0
  291. package/dist/src/lib/function-sync.js +1258 -0
  292. package/dist/src/lib/function-sync.js.map +1 -0
  293. package/dist/src/lib/function-trigger-listing.d.ts +27 -0
  294. package/dist/src/lib/function-trigger-listing.js +70 -0
  295. package/dist/src/lib/function-trigger-listing.js.map +1 -0
  296. package/dist/src/lib/function-typecheck.d.ts +86 -0
  297. package/dist/src/lib/function-typecheck.js +370 -0
  298. package/dist/src/lib/function-typecheck.js.map +1 -0
  299. package/dist/src/lib/function-versions.d.ts +122 -0
  300. package/dist/src/lib/function-versions.js +182 -0
  301. package/dist/src/lib/function-versions.js.map +1 -0
  302. package/dist/src/lib/generated-allowlist.d.ts +28 -0
  303. package/dist/src/lib/generated-allowlist.js +281 -0
  304. package/dist/src/lib/generated-allowlist.js.map +1 -0
  305. package/dist/src/lib/generated-config-surfaces.d.ts +2936 -0
  306. package/dist/src/lib/generated-config-surfaces.js +10569 -0
  307. package/dist/src/lib/generated-config-surfaces.js.map +1 -0
  308. package/dist/src/lib/generated-sdk-types.d.ts +12 -0
  309. package/dist/src/lib/generated-sdk-types.js +13 -0
  310. package/dist/src/lib/generated-sdk-types.js.map +1 -0
  311. package/dist/src/lib/generated-template-lint.d.ts +212 -0
  312. package/dist/src/lib/generated-template-lint.js +624 -0
  313. package/dist/src/lib/generated-template-lint.js.map +1 -0
  314. package/dist/src/lib/init-adopt.d.ts +16 -0
  315. package/dist/src/lib/init-adopt.js +34 -0
  316. package/dist/src/lib/init-adopt.js.map +1 -0
  317. package/dist/src/lib/init-assets.d.ts +39 -0
  318. package/dist/src/lib/init-assets.js +97 -0
  319. package/dist/src/lib/init-assets.js.map +1 -0
  320. package/dist/src/lib/init-client-platforms.d.ts +14 -0
  321. package/dist/src/lib/init-client-platforms.js +71 -0
  322. package/dist/src/lib/init-client-platforms.js.map +1 -0
  323. package/dist/src/lib/init-config.d.ts +98 -0
  324. package/dist/src/lib/init-config.js +186 -0
  325. package/dist/src/lib/init-config.js.map +1 -0
  326. package/dist/src/lib/init-email-redirect-uris.d.ts +37 -0
  327. package/dist/src/lib/init-email-redirect-uris.js +46 -0
  328. package/dist/src/lib/init-email-redirect-uris.js.map +1 -0
  329. package/dist/src/lib/init-ios-links.d.ts +91 -0
  330. package/dist/src/lib/init-ios-links.js +219 -0
  331. package/dist/src/lib/init-ios-links.js.map +1 -0
  332. package/dist/src/lib/init-plan.d.ts +80 -0
  333. package/dist/src/lib/init-plan.js +95 -0
  334. package/dist/src/lib/init-plan.js.map +1 -0
  335. package/dist/src/lib/init-production-env.d.ts +48 -0
  336. package/dist/src/lib/init-production-env.js +59 -0
  337. package/dist/src/lib/init-production-env.js.map +1 -0
  338. package/dist/src/lib/init-schema.d.ts +74 -0
  339. package/dist/src/lib/init-schema.js +358 -0
  340. package/dist/src/lib/init-schema.js.map +1 -0
  341. package/dist/src/lib/init-xcode.d.ts +34 -0
  342. package/dist/src/lib/init-xcode.js +138 -0
  343. package/dist/src/lib/init-xcode.js.map +1 -0
  344. package/dist/src/lib/integration-request-config.d.ts +30 -0
  345. package/dist/src/lib/integration-request-config.js +145 -0
  346. package/dist/src/lib/integration-request-config.js.map +1 -0
  347. package/dist/src/lib/integration-selector.d.ts +42 -0
  348. package/dist/src/lib/integration-selector.js +46 -0
  349. package/dist/src/lib/integration-selector.js.map +1 -0
  350. package/dist/src/lib/ios-app-id.d.ts +34 -0
  351. package/dist/src/lib/ios-app-id.js +69 -0
  352. package/dist/src/lib/ios-app-id.js.map +1 -0
  353. package/dist/src/lib/list-options.d.ts +68 -0
  354. package/dist/src/lib/list-options.js +89 -0
  355. package/dist/src/lib/list-options.js.map +1 -0
  356. package/dist/src/lib/local-state.d.ts +55 -0
  357. package/dist/src/lib/local-state.js +167 -0
  358. package/dist/src/lib/local-state.js.map +1 -0
  359. package/dist/src/lib/local-test-cases.d.ts +63 -0
  360. package/dist/src/lib/local-test-cases.js +136 -0
  361. package/dist/src/lib/local-test-cases.js.map +1 -0
  362. package/dist/src/lib/log-inspection.d.ts +715 -0
  363. package/dist/src/lib/log-inspection.js +816 -0
  364. package/dist/src/lib/log-inspection.js.map +1 -0
  365. package/dist/src/lib/logout-admin-session.d.ts +33 -0
  366. package/dist/src/lib/logout-admin-session.js +70 -0
  367. package/dist/src/lib/logout-admin-session.js.map +1 -0
  368. package/dist/src/lib/migration-nag.d.ts +49 -0
  369. package/dist/src/lib/migration-nag.js +163 -0
  370. package/dist/src/lib/migration-nag.js.map +1 -0
  371. package/dist/src/lib/object-status-filter.d.ts +22 -0
  372. package/dist/src/lib/object-status-filter.js +45 -0
  373. package/dist/src/lib/object-status-filter.js.map +1 -0
  374. package/dist/src/lib/output.d.ts +124 -0
  375. package/dist/src/lib/output.js +219 -8
  376. package/dist/src/lib/output.js.map +1 -1
  377. package/dist/src/lib/package-manager.d.ts +140 -0
  378. package/dist/src/lib/package-manager.js +305 -0
  379. package/dist/src/lib/package-manager.js.map +1 -0
  380. package/dist/src/lib/paginate.d.ts +98 -0
  381. package/dist/src/lib/paginate.js +112 -0
  382. package/dist/src/lib/paginate.js.map +1 -0
  383. package/dist/src/lib/platform-owned.d.ts +63 -0
  384. package/dist/src/lib/platform-owned.js +85 -0
  385. package/dist/src/lib/platform-owned.js.map +1 -0
  386. package/dist/src/lib/project-config.d.ts +122 -0
  387. package/dist/src/lib/project-config.js +244 -0
  388. package/dist/src/lib/project-config.js.map +1 -0
  389. package/dist/src/lib/prompt-cost-format.d.ts +11 -0
  390. package/dist/src/lib/prompt-cost-format.js +41 -0
  391. package/dist/src/lib/prompt-cost-format.js.map +1 -0
  392. package/dist/src/lib/prompt-schema-codegen.d.ts +147 -0
  393. package/dist/src/lib/prompt-schema-codegen.js +462 -0
  394. package/dist/src/lib/prompt-schema-codegen.js.map +1 -0
  395. package/dist/src/lib/query-operators.d.ts +43 -0
  396. package/dist/src/lib/query-operators.js +80 -0
  397. package/dist/src/lib/query-operators.js.map +1 -0
  398. package/dist/src/lib/record-filter.d.ts +18 -0
  399. package/dist/src/lib/record-filter.js +55 -0
  400. package/dist/src/lib/record-filter.js.map +1 -0
  401. package/dist/src/lib/refresh-admin-credentials.d.ts +73 -0
  402. package/dist/src/lib/refresh-admin-credentials.js +123 -0
  403. package/dist/src/lib/refresh-admin-credentials.js.map +1 -0
  404. package/dist/src/lib/resolve-init-dev-port.d.ts +56 -0
  405. package/dist/src/lib/resolve-init-dev-port.js +55 -0
  406. package/dist/src/lib/resolve-init-dev-port.js.map +1 -0
  407. package/dist/src/lib/resolve-init-server.d.ts +64 -0
  408. package/dist/src/lib/resolve-init-server.js +77 -0
  409. package/dist/src/lib/resolve-init-server.js.map +1 -0
  410. package/dist/src/lib/resolve-owner.d.ts +19 -0
  411. package/dist/src/lib/resolve-owner.js +20 -0
  412. package/dist/src/lib/resolve-owner.js.map +1 -0
  413. package/dist/src/lib/resolve-platform.d.ts +74 -0
  414. package/dist/src/lib/resolve-platform.js +105 -0
  415. package/dist/src/lib/resolve-platform.js.map +1 -0
  416. package/dist/src/lib/run-status.d.ts +19 -0
  417. package/dist/src/lib/run-status.generated.d.ts +39 -0
  418. package/dist/src/lib/run-status.generated.js +66 -0
  419. package/dist/src/lib/run-status.generated.js.map +1 -0
  420. package/dist/src/lib/run-status.js +19 -0
  421. package/dist/src/lib/run-status.js.map +1 -0
  422. package/dist/src/lib/server-text-normalization.d.ts +51 -0
  423. package/dist/src/lib/server-text-normalization.js +90 -0
  424. package/dist/src/lib/server-text-normalization.js.map +1 -0
  425. package/dist/src/lib/server-url.d.ts +22 -0
  426. package/dist/src/lib/server-url.js +33 -0
  427. package/dist/src/lib/server-url.js.map +1 -0
  428. package/dist/src/lib/signing-secret-status.d.ts +81 -0
  429. package/dist/src/lib/signing-secret-status.js +116 -0
  430. package/dist/src/lib/signing-secret-status.js.map +1 -0
  431. package/dist/src/lib/skill-installer.d.ts +71 -0
  432. package/dist/src/lib/skill-installer.js +441 -0
  433. package/dist/src/lib/skill-installer.js.map +1 -0
  434. package/dist/src/lib/snapshot-audit-source.d.ts +45 -0
  435. package/dist/src/lib/snapshot-audit-source.js +58 -0
  436. package/dist/src/lib/snapshot-audit-source.js.map +1 -0
  437. package/dist/src/lib/snapshot-audit-store.d.ts +52 -0
  438. package/dist/src/lib/snapshot-audit-store.js +196 -0
  439. package/dist/src/lib/snapshot-audit-store.js.map +1 -0
  440. package/dist/src/lib/snapshot-audit.d.ts +207 -0
  441. package/dist/src/lib/snapshot-audit.js +431 -0
  442. package/dist/src/lib/snapshot-audit.js.map +1 -0
  443. package/dist/src/lib/snapshot-build-rows.d.ts +60 -0
  444. package/dist/src/lib/snapshot-build-rows.js +87 -0
  445. package/dist/src/lib/snapshot-build-rows.js.map +1 -0
  446. package/dist/src/lib/snapshot-build.d.ts +50 -0
  447. package/dist/src/lib/snapshot-build.js +111 -0
  448. package/dist/src/lib/snapshot-build.js.map +1 -0
  449. package/dist/src/lib/snapshot-manifest-layout.d.ts +61 -0
  450. package/dist/src/lib/snapshot-manifest-layout.js +70 -0
  451. package/dist/src/lib/snapshot-manifest-layout.js.map +1 -0
  452. package/dist/src/lib/snapshots.d.ts +98 -0
  453. package/dist/src/lib/snapshots.js +294 -0
  454. package/dist/src/lib/snapshots.js.map +1 -0
  455. package/dist/src/lib/step-run-table.d.ts +43 -0
  456. package/dist/src/lib/step-run-table.js +129 -0
  457. package/dist/src/lib/step-run-table.js.map +1 -0
  458. package/dist/src/lib/storage-pending-retry.d.ts +26 -0
  459. package/dist/src/lib/storage-pending-retry.js +42 -0
  460. package/dist/src/lib/storage-pending-retry.js.map +1 -0
  461. package/dist/src/lib/swift-codegen/agentGenerator.d.ts +42 -0
  462. package/dist/src/lib/swift-codegen/agentGenerator.js +118 -0
  463. package/dist/src/lib/swift-codegen/agentGenerator.js.map +1 -0
  464. package/dist/src/lib/swift-codegen/banners.d.ts +24 -0
  465. package/dist/src/lib/swift-codegen/banners.js +25 -0
  466. package/dist/src/lib/swift-codegen/banners.js.map +1 -0
  467. package/dist/src/lib/swift-codegen/dbGenerator.d.ts +113 -0
  468. package/dist/src/lib/swift-codegen/dbGenerator.js +926 -0
  469. package/dist/src/lib/swift-codegen/dbGenerator.js.map +1 -0
  470. package/dist/src/lib/swift-codegen/dbSwiftTypes.d.ts +42 -0
  471. package/dist/src/lib/swift-codegen/dbSwiftTypes.js +100 -0
  472. package/dist/src/lib/swift-codegen/dbSwiftTypes.js.map +1 -0
  473. package/dist/src/lib/swift-codegen/functionGenerator.d.ts +139 -0
  474. package/dist/src/lib/swift-codegen/functionGenerator.js +462 -0
  475. package/dist/src/lib/swift-codegen/functionGenerator.js.map +1 -0
  476. package/dist/src/lib/swift-codegen/generator.d.ts +100 -0
  477. package/dist/src/lib/swift-codegen/generator.js +457 -0
  478. package/dist/src/lib/swift-codegen/generator.js.map +1 -0
  479. package/dist/src/lib/swift-codegen/schemaToSwift.d.ts +87 -0
  480. package/dist/src/lib/swift-codegen/schemaToSwift.js +661 -0
  481. package/dist/src/lib/swift-codegen/schemaToSwift.js.map +1 -0
  482. package/dist/src/lib/swift-codegen/siblingSymbols.d.ts +94 -0
  483. package/dist/src/lib/swift-codegen/siblingSymbols.js +155 -0
  484. package/dist/src/lib/swift-codegen/siblingSymbols.js.map +1 -0
  485. package/dist/src/lib/swift-codegen/swiftNaming.d.ts +85 -0
  486. package/dist/src/lib/swift-codegen/swiftNaming.js +198 -0
  487. package/dist/src/lib/swift-codegen/swiftNaming.js.map +1 -0
  488. package/dist/src/lib/sync-dir-selector.d.ts +21 -0
  489. package/dist/src/lib/sync-dir-selector.js +30 -0
  490. package/dist/src/lib/sync-dir-selector.js.map +1 -0
  491. package/dist/src/lib/sync-paths.d.ts +128 -0
  492. package/dist/src/lib/sync-paths.js +195 -0
  493. package/dist/src/lib/sync-paths.js.map +1 -0
  494. package/dist/src/lib/sync-resource-types.d.ts +563 -0
  495. package/dist/src/lib/sync-resource-types.js +1073 -0
  496. package/dist/src/lib/sync-resource-types.js.map +1 -0
  497. package/dist/src/lib/sync-selectors.d.ts +138 -0
  498. package/dist/src/lib/sync-selectors.js +289 -0
  499. package/dist/src/lib/sync-selectors.js.map +1 -0
  500. package/dist/src/lib/template.d.ts +170 -0
  501. package/dist/src/lib/template.js +484 -68
  502. package/dist/src/lib/template.js.map +1 -1
  503. package/dist/src/lib/test-case-file-names.d.ts +40 -0
  504. package/dist/src/lib/test-case-file-names.js +91 -0
  505. package/dist/src/lib/test-case-file-names.js.map +1 -0
  506. package/dist/src/lib/test-case-keys.d.ts +29 -0
  507. package/dist/src/lib/test-case-keys.js +55 -0
  508. package/dist/src/lib/test-case-keys.js.map +1 -0
  509. package/dist/src/lib/test-case-variables.d.ts +29 -0
  510. package/dist/src/lib/test-case-variables.js +71 -0
  511. package/dist/src/lib/test-case-variables.js.map +1 -0
  512. package/dist/src/lib/token-inject.d.ts +56 -0
  513. package/dist/src/lib/token-inject.js +204 -0
  514. package/dist/src/lib/token-inject.js.map +1 -0
  515. package/dist/src/lib/toml-database-config.d.ts +123 -0
  516. package/dist/src/lib/toml-database-config.js +544 -0
  517. package/dist/src/lib/toml-database-config.js.map +1 -0
  518. package/dist/src/lib/toml-metadata-config.d.ts +151 -0
  519. package/dist/src/lib/toml-metadata-config.js +476 -0
  520. package/dist/src/lib/toml-metadata-config.js.map +1 -0
  521. package/dist/src/lib/toml-native-form.d.ts +46 -0
  522. package/dist/src/lib/toml-native-form.js +78 -0
  523. package/dist/src/lib/toml-native-form.js.map +1 -0
  524. package/dist/src/lib/toml-params-validator.d.ts +129 -0
  525. package/dist/src/lib/toml-params-validator.js +298 -0
  526. package/dist/src/lib/toml-params-validator.js.map +1 -0
  527. package/dist/src/lib/toml-scalar-edit.d.ts +43 -0
  528. package/dist/src/lib/toml-scalar-edit.js +283 -0
  529. package/dist/src/lib/toml-scalar-edit.js.map +1 -0
  530. package/dist/src/lib/user-selector.d.ts +24 -0
  531. package/dist/src/lib/user-selector.js +33 -0
  532. package/dist/src/lib/user-selector.js.map +1 -0
  533. package/dist/src/lib/version-check.d.ts +35 -0
  534. package/dist/src/lib/version-check.js +241 -0
  535. package/dist/src/lib/version-check.js.map +1 -0
  536. package/dist/src/lib/watch.d.ts +121 -0
  537. package/dist/src/lib/watch.js +169 -0
  538. package/dist/src/lib/watch.js.map +1 -0
  539. package/dist/src/lib/web-url.d.ts +40 -0
  540. package/dist/src/lib/web-url.js +76 -0
  541. package/dist/src/lib/web-url.js.map +1 -0
  542. package/dist/src/lib/webhook-deliver.d.ts +209 -0
  543. package/dist/src/lib/webhook-deliver.js +519 -0
  544. package/dist/src/lib/webhook-deliver.js.map +1 -0
  545. package/dist/src/lib/workflow-apply.d.ts +110 -0
  546. package/dist/src/lib/workflow-apply.js +164 -0
  547. package/dist/src/lib/workflow-apply.js.map +1 -0
  548. package/dist/src/lib/workflow-codegen/generated-schema-descriptor.d.ts +129 -0
  549. package/dist/src/lib/workflow-codegen/generated-schema-descriptor.js +269 -0
  550. package/dist/src/lib/workflow-codegen/generated-schema-descriptor.js.map +1 -0
  551. package/dist/src/lib/workflow-codegen/generator.d.ts +96 -0
  552. package/dist/src/lib/workflow-codegen/generator.js +361 -0
  553. package/dist/src/lib/workflow-codegen/generator.js.map +1 -0
  554. package/dist/src/lib/workflow-codegen/invokerIR.d.ts +94 -0
  555. package/dist/src/lib/workflow-codegen/invokerIR.js +76 -0
  556. package/dist/src/lib/workflow-codegen/invokerIR.js.map +1 -0
  557. package/dist/src/lib/workflow-codegen/naming.d.ts +33 -0
  558. package/dist/src/lib/workflow-codegen/naming.js +81 -0
  559. package/dist/src/lib/workflow-codegen/naming.js.map +1 -0
  560. package/dist/src/lib/workflow-codegen/schemaToTs.d.ts +80 -0
  561. package/dist/src/lib/workflow-codegen/schemaToTs.js +303 -0
  562. package/dist/src/lib/workflow-codegen/schemaToTs.js.map +1 -0
  563. package/dist/src/lib/workflow-config-apply.d.ts +70 -0
  564. package/dist/src/lib/workflow-config-apply.js +137 -0
  565. package/dist/src/lib/workflow-config-apply.js.map +1 -0
  566. package/dist/src/lib/workflow-config-sidecar.d.ts +63 -0
  567. package/dist/src/lib/workflow-config-sidecar.js +96 -0
  568. package/dist/src/lib/workflow-config-sidecar.js.map +1 -0
  569. package/dist/src/lib/workflow-defaults.d.ts +29 -0
  570. package/dist/src/lib/workflow-defaults.js +41 -0
  571. package/dist/src/lib/workflow-defaults.js.map +1 -0
  572. package/dist/src/lib/workflow-fragments.d.ts +64 -0
  573. package/dist/src/lib/workflow-fragments.js +342 -0
  574. package/dist/src/lib/workflow-fragments.js.map +1 -0
  575. package/dist/src/lib/workflow-include-preserve.d.ts +76 -0
  576. package/dist/src/lib/workflow-include-preserve.js +286 -0
  577. package/dist/src/lib/workflow-include-preserve.js.map +1 -0
  578. package/dist/src/lib/workflow-payload.d.ts +98 -0
  579. package/dist/src/lib/workflow-payload.js +178 -0
  580. package/dist/src/lib/workflow-payload.js.map +1 -0
  581. package/dist/src/lib/workflow-toml-validator.d.ts +211 -0
  582. package/dist/src/lib/workflow-toml-validator.js +770 -0
  583. package/dist/src/lib/workflow-toml-validator.js.map +1 -0
  584. package/dist/src/lib/workflow-usage.d.ts +196 -0
  585. package/dist/src/lib/workflow-usage.js +310 -0
  586. package/dist/src/lib/workflow-usage.js.map +1 -0
  587. package/dist/src/types/index.d.ts +591 -0
  588. package/dist/src/validators.d.ts +65 -0
  589. package/dist/src/validators.js +64 -0
  590. package/dist/src/validators.js.map +1 -0
  591. package/package.json +34 -9
@@ -1,46 +1,28 @@
1
- import { existsSync, mkdirSync, readFileSync, writeFileSync, chmodSync } from "fs";
2
- import { homedir } from "os";
3
- import { join } from "path";
4
- // Allow override via environment variable for testing
5
- const CONFIG_DIR = process.env.PRIMITIVE_CONFIG_DIR || join(homedir(), ".primitive");
6
- const CREDENTIALS_FILE = join(CONFIG_DIR, "credentials.json");
7
- function ensureConfigDir() {
8
- if (!existsSync(CONFIG_DIR)) {
9
- mkdirSync(CONFIG_DIR, { recursive: true, mode: 0o700 });
10
- }
11
- }
1
+ /**
2
+ * Thin compatibility shim over the new project-scoped config system.
3
+ *
4
+ * Historically the CLI had one global credentials file at
5
+ * ~/.primitive/credentials.json and a handful of helpers here. After the
6
+ * project-config overhaul (issue #373) credentials live per-environment
7
+ * inside `<projectRoot>/.primitive/credentials.json` when a
8
+ * primitive/config.json is in scope, and fall back to the legacy global
9
+ * file otherwise.
10
+ *
11
+ * The rest of the CLI continues to import from this module, so we keep
12
+ * the original public API (loadCredentials, saveCredentials, etc.) and
13
+ * just delegate to the new stores.
14
+ */
15
+ import { clearCredentialsStore, loadCredentialsStore, saveCredentialsStore, } from "./credentials-store.js";
16
+ import { getCurrentEnvironment, requireCurrentEnvironment, } from "./env-resolver.js";
17
+ import { DEFAULT_SERVER_URL } from "./constants.js";
12
18
  export function loadCredentials() {
13
- try {
14
- if (!existsSync(CREDENTIALS_FILE)) {
15
- return null;
16
- }
17
- const data = readFileSync(CREDENTIALS_FILE, "utf-8");
18
- return JSON.parse(data);
19
- }
20
- catch {
21
- return null;
22
- }
19
+ return loadCredentialsStore();
23
20
  }
24
21
  export function saveCredentials(credentials) {
25
- ensureConfigDir();
26
- writeFileSync(CREDENTIALS_FILE, JSON.stringify(credentials, null, 2), {
27
- mode: 0o600,
28
- });
29
- // Ensure file permissions are secure
30
- chmodSync(CREDENTIALS_FILE, 0o600);
22
+ saveCredentialsStore(credentials);
31
23
  }
32
24
  export function clearCredentials() {
33
- try {
34
- if (existsSync(CREDENTIALS_FILE)) {
35
- writeFileSync(CREDENTIALS_FILE, "", { mode: 0o600 });
36
- // Actually remove the file
37
- const { unlinkSync } = require("fs");
38
- unlinkSync(CREDENTIALS_FILE);
39
- }
40
- }
41
- catch {
42
- // Ignore errors
43
- }
25
+ clearCredentialsStore();
44
26
  }
45
27
  export function isTokenExpired(credentials) {
46
28
  if (!credentials.expiresAt)
@@ -58,41 +40,62 @@ export function isTokenExpiringSoon(credentials) {
58
40
  // Consider expiring soon if less than 5 minutes remaining
59
41
  return expiresAt - now < 5 * 60 * 1000;
60
42
  }
61
- export function setCurrentApp(appId, appName) {
62
- const credentials = loadCredentials();
63
- if (!credentials) {
64
- throw new Error("Not logged in. Run 'primitive login' first.");
65
- }
66
- credentials.currentAppId = appId;
67
- credentials.currentAppName = appName;
68
- saveCredentials(credentials);
69
- }
70
- export function clearCurrentApp() {
71
- const credentials = loadCredentials();
72
- if (!credentials) {
73
- return;
74
- }
75
- delete credentials.currentAppId;
76
- delete credentials.currentAppName;
77
- saveCredentials(credentials);
43
+ /**
44
+ * The app this invocation runs against: the resolved environment's, and only
45
+ * ever that (#3152).
46
+ *
47
+ * It never answers "none" (#3154). Outside a project there is no environment,
48
+ * and therefore no app — but there is also no configuration tree, no server
49
+ * and no credentials, so "which app?" is not a question with a quieter answer
50
+ * than the others. `requireCurrentEnvironment()` gives the one refusal, which
51
+ * is what retired the "No app specified" branch and its five local copies.
52
+ */
53
+ export function getCurrentApp() {
54
+ const env = requireCurrentEnvironment(); // may throw on an unresolvable env
55
+ return { appId: env.config.appId, appName: env.config.appName };
78
56
  }
79
57
  export function getCurrentAppId() {
80
- const credentials = loadCredentials();
81
- return credentials?.currentAppId;
58
+ return getCurrentApp().appId;
82
59
  }
60
+ /**
61
+ * The app a command acts on: an explicit one where the command still takes
62
+ * one (`users`, `apps`, `admins`, the database data verbs), otherwise the
63
+ * environment's.
64
+ *
65
+ * The explicit forms are checked FIRST and short-circuit, so a cross-app read
66
+ * still works with no environment able to name that app — that is the whole
67
+ * reason `--app` survives on those commands (intent §Decisions).
68
+ */
83
69
  export function resolveAppId(appId, options) {
84
- const resolved = appId || options.app || getCurrentAppId();
85
- if (!resolved) {
86
- console.error("No app specified. Use <app-id>, --app, or 'primitive use <app-id>' to set context.");
87
- process.exit(1);
88
- }
89
- return resolved;
70
+ return appId || options.app || getCurrentAppId();
90
71
  }
72
+ /**
73
+ * The API base URL for the active environment.
74
+ *
75
+ * The credentials-file fallback is gone (#3154): a `serverUrl` left in
76
+ * `~/.primitive/credentials.json` by whatever the last `login` targeted was a
77
+ * second source for the one thing an environment exists to say.
78
+ */
91
79
  export function getServerUrl() {
92
- const credentials = loadCredentials();
93
- if (!credentials?.serverUrl) {
94
- throw new Error("Not logged in. Run 'primitive login' first.");
95
- }
96
- return credentials.serverUrl;
80
+ return requireCurrentEnvironment().config.apiUrl;
81
+ }
82
+ /**
83
+ * Resolves the API base URL to authenticate against, used by `primitive login`
84
+ * (issue #1343).
85
+ *
86
+ * Unlike getServerUrl(), this must work *before* any credentials exist (first
87
+ * login), so it never falls back to the stored credentials' serverUrl:
88
+ *
89
+ * - Project mode → the active environment's `apiUrl` (canonical). Lets
90
+ * getCurrentEnvironment() throw on an unresolvable env (ambiguous/unknown
91
+ * --env) so the caller can fail loudly instead of silently targeting prod.
92
+ * - Legacy mode (no primitive/config.json) → DEFAULT_SERVER_URL, which
93
+ * honors the PRIMITIVE_SERVER_URL escape hatch (constants.ts).
94
+ *
95
+ * The trailing slash is stripped so callers can build `${url}/admin/api/...`.
96
+ */
97
+ export function getConfiguredServerUrl() {
98
+ const env = getCurrentEnvironment(); // may throw on an unresolvable env
99
+ return (env ? env.config.apiUrl : DEFAULT_SERVER_URL).replace(/\/$/, "");
97
100
  }
98
101
  //# sourceMappingURL=config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/lib/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,IAAI,CAAC;AACnF,OAAO,EAAE,OAAO,EAAE,MAAM,IAAI,CAAC;AAC7B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAG5B,sDAAsD;AACtD,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,oBAAoB,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,YAAY,CAAC,CAAC;AACrF,MAAM,gBAAgB,GAAG,IAAI,CAAC,UAAU,EAAE,kBAAkB,CAAC,CAAC;AAE9D,SAAS,eAAe;IACtB,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC5B,SAAS,CAAC,UAAU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AM,CAAC,CAAC,CAAC,kBAAkB,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;AAC3E,CAAC"}
@@ -0,0 +1,83 @@
1
+ /**
2
+ * Shared interactive-confirmation helper for destructive CLI commands.
3
+ *
4
+ * Background (issue #972): every destructive command used the legacy
5
+ * `inquirer.default.prompt([{ type: "confirm", ... }])` pattern directly. When
6
+ * stdin is not a usable TTY (closed/piped/EOF/Ctrl-D), inquirer v9.3.8 throws
7
+ * `ERR_USE_AFTER_CLOSE: readline was closed` from inside a Node event-emitter
8
+ * callback (`PromptUI.onForceClose` -> `process.emit`). Because that throw
9
+ * originates in event-dispatch, it escapes both the command's own `try/catch`
10
+ * AND the top-level `.catch` in `cli/bin/primitive.ts` — and with no
11
+ * `uncaughtException` handler, Node printed only the bare `Node.js vX` banner
12
+ * and died before the API call. `cron-triggers delete` / `workflows delete`
13
+ * crashed without deleting anything.
14
+ *
15
+ * Migration (issue #999): the helper's internals are now built on the modern
16
+ * `@inquirer/prompts` `confirm()` API instead of legacy `inquirer.default.prompt`.
17
+ * The modern API rejects its promise with a *catchable* `ExitPromptError`
18
+ * (Ctrl-C / SIGINT / force-close) / `AbortPromptError` / `CancelPromptError`
19
+ * rather than crashing via `process.emit`, so the root-cause crash class is
20
+ * removed. Crucially, `@inquirer/prompts` `confirm()` has **no built-in non-TTY
21
+ * guard** — so the #972 guard below MUST stay, or the crash class regresses into
22
+ * a hang/opaque-reject on piped/closed stdin. The migration changes only the
23
+ * default prompt fn's internals; the guard, the `ConfirmPromptError` contract,
24
+ * and the public `confirmPrompt()` signature are preserved.
25
+ *
26
+ * `confirmPrompt()` fixes the cause:
27
+ * 1. Non-TTY guard — if stdin is not a TTY, it never touches the prompt.
28
+ * Instead it throws a catchable `ConfirmPromptError` with an actionable
29
+ * message ("re-run with --yes ..."). Per the maintainer decision on #972
30
+ * this is a hard error, never a silent mutate or silent abort.
31
+ * 2. Local try/catch — in a real TTY the prompt is awaited inside a try/catch
32
+ * so an abort/EOF (`ExitPromptError` / `AbortPromptError` /
33
+ * `CancelPromptError`, or legacy `ERR_USE_AFTER_CLOSE`) surfaces as a clean
34
+ * `ConfirmPromptError`, not a stack trace or crash.
35
+ *
36
+ * Commands should call this instead of inquirer directly, e.g.:
37
+ *
38
+ * if (!options.yes) {
39
+ * try {
40
+ * const ok = await confirmPrompt(`Delete cron trigger ${id}?`);
41
+ * if (!ok) { info("Cancelled."); return; }
42
+ * } catch (err) {
43
+ * error(err.message);
44
+ * process.exit(1);
45
+ * }
46
+ * }
47
+ */
48
+ /** Error thrown when a confirmation can't be obtained interactively. */
49
+ export declare class ConfirmPromptError extends Error {
50
+ constructor(message: string);
51
+ }
52
+ /**
53
+ * Shape of the `@inquirer/prompts` `confirm()` function. Injectable for testing.
54
+ *
55
+ * Note (#999): this shifted from the legacy inquirer questions-array →
56
+ * `{ confirm: boolean }` shape to the modern bare `{ message, default }` →
57
+ * `Promise<boolean>` shape.
58
+ */
59
+ export type PromptFn = (config: {
60
+ message: string;
61
+ default?: boolean;
62
+ }) => Promise<boolean>;
63
+ export interface ConfirmPromptOptions {
64
+ /** Default answer when the user just presses enter. Defaults to false. */
65
+ defaultValue?: boolean;
66
+ /**
67
+ * Override the underlying prompt function (for tests). Defaults to lazily
68
+ * importing `@inquirer/prompts` `confirm`.
69
+ */
70
+ promptFn?: PromptFn;
71
+ /**
72
+ * Override TTY detection (for tests). Defaults to `process.stdin.isTTY`.
73
+ */
74
+ isTTY?: boolean;
75
+ }
76
+ /**
77
+ * Ask the user a yes/no confirmation question.
78
+ *
79
+ * @returns `true` if the user confirms, `false` if they decline.
80
+ * @throws {ConfirmPromptError} when stdin is not an interactive TTY (so the
81
+ * prompt can't be shown), or when the underlying prompt aborts/crashes.
82
+ */
83
+ export declare function confirmPrompt(message: string, options?: ConfirmPromptOptions): Promise<boolean>;
@@ -0,0 +1,110 @@
1
+ /**
2
+ * Shared interactive-confirmation helper for destructive CLI commands.
3
+ *
4
+ * Background (issue #972): every destructive command used the legacy
5
+ * `inquirer.default.prompt([{ type: "confirm", ... }])` pattern directly. When
6
+ * stdin is not a usable TTY (closed/piped/EOF/Ctrl-D), inquirer v9.3.8 throws
7
+ * `ERR_USE_AFTER_CLOSE: readline was closed` from inside a Node event-emitter
8
+ * callback (`PromptUI.onForceClose` -> `process.emit`). Because that throw
9
+ * originates in event-dispatch, it escapes both the command's own `try/catch`
10
+ * AND the top-level `.catch` in `cli/bin/primitive.ts` — and with no
11
+ * `uncaughtException` handler, Node printed only the bare `Node.js vX` banner
12
+ * and died before the API call. `cron-triggers delete` / `workflows delete`
13
+ * crashed without deleting anything.
14
+ *
15
+ * Migration (issue #999): the helper's internals are now built on the modern
16
+ * `@inquirer/prompts` `confirm()` API instead of legacy `inquirer.default.prompt`.
17
+ * The modern API rejects its promise with a *catchable* `ExitPromptError`
18
+ * (Ctrl-C / SIGINT / force-close) / `AbortPromptError` / `CancelPromptError`
19
+ * rather than crashing via `process.emit`, so the root-cause crash class is
20
+ * removed. Crucially, `@inquirer/prompts` `confirm()` has **no built-in non-TTY
21
+ * guard** — so the #972 guard below MUST stay, or the crash class regresses into
22
+ * a hang/opaque-reject on piped/closed stdin. The migration changes only the
23
+ * default prompt fn's internals; the guard, the `ConfirmPromptError` contract,
24
+ * and the public `confirmPrompt()` signature are preserved.
25
+ *
26
+ * `confirmPrompt()` fixes the cause:
27
+ * 1. Non-TTY guard — if stdin is not a TTY, it never touches the prompt.
28
+ * Instead it throws a catchable `ConfirmPromptError` with an actionable
29
+ * message ("re-run with --yes ..."). Per the maintainer decision on #972
30
+ * this is a hard error, never a silent mutate or silent abort.
31
+ * 2. Local try/catch — in a real TTY the prompt is awaited inside a try/catch
32
+ * so an abort/EOF (`ExitPromptError` / `AbortPromptError` /
33
+ * `CancelPromptError`, or legacy `ERR_USE_AFTER_CLOSE`) surfaces as a clean
34
+ * `ConfirmPromptError`, not a stack trace or crash.
35
+ *
36
+ * Commands should call this instead of inquirer directly, e.g.:
37
+ *
38
+ * if (!options.yes) {
39
+ * try {
40
+ * const ok = await confirmPrompt(`Delete cron trigger ${id}?`);
41
+ * if (!ok) { info("Cancelled."); return; }
42
+ * } catch (err) {
43
+ * error(err.message);
44
+ * process.exit(1);
45
+ * }
46
+ * }
47
+ */
48
+ /** Error thrown when a confirmation can't be obtained interactively. */
49
+ export class ConfirmPromptError extends Error {
50
+ constructor(message) {
51
+ super(message);
52
+ this.name = "ConfirmPromptError";
53
+ }
54
+ }
55
+ async function defaultPromptFn(config) {
56
+ const { confirm } = await import("@inquirer/prompts");
57
+ return confirm(config);
58
+ }
59
+ /**
60
+ * Names of the catchable abort errors thrown by `@inquirer/prompts` when the
61
+ * user interrupts a prompt (Ctrl-C / SIGINT / force-close / abort signal /
62
+ * cancel). We match on `name` (not just `instanceof`) so detection is robust to
63
+ * the error class being duplicated across module realms.
64
+ */
65
+ const ABORT_ERROR_NAMES = new Set([
66
+ "ExitPromptError",
67
+ "AbortPromptError",
68
+ "CancelPromptError",
69
+ ]);
70
+ /**
71
+ * Ask the user a yes/no confirmation question.
72
+ *
73
+ * @returns `true` if the user confirms, `false` if they decline.
74
+ * @throws {ConfirmPromptError} when stdin is not an interactive TTY (so the
75
+ * prompt can't be shown), or when the underlying prompt aborts/crashes.
76
+ */
77
+ export async function confirmPrompt(message, options = {}) {
78
+ const isTTY = options.isTTY ?? Boolean(process.stdin.isTTY);
79
+ if (!isTTY) {
80
+ throw new ConfirmPromptError("No interactive terminal available to confirm this action. " +
81
+ "Re-run with --yes (-y) to skip the confirmation prompt in " +
82
+ "non-interactive contexts (CI, pipes, agents).");
83
+ }
84
+ const promptFn = options.promptFn ?? defaultPromptFn;
85
+ try {
86
+ const confirmed = await promptFn({
87
+ message,
88
+ default: options.defaultValue ?? false,
89
+ });
90
+ return Boolean(confirmed);
91
+ }
92
+ catch (err) {
93
+ // A deliberate abort/EOF/Ctrl-C/Ctrl-D — either the modern
94
+ // `@inquirer/prompts` `ExitPromptError`/`AbortPromptError`/`CancelPromptError`
95
+ // (matched by name to survive cross-realm `instanceof` mismatches), or the
96
+ // legacy inquirer `ERR_USE_AFTER_CLOSE`. Surface as a clean, actionable
97
+ // error so the caller exits 1 with no stack trace / bare `Node.js vX` banner.
98
+ if (ABORT_ERROR_NAMES.has(err?.name) ||
99
+ err?.code === "ERR_USE_AFTER_CLOSE") {
100
+ throw new ConfirmPromptError("Confirmation cancelled (no interactive input). " +
101
+ "Re-run with --yes (-y) to skip confirmation.");
102
+ }
103
+ // Any other prompt failure: still surface it as a clean, catchable error
104
+ // rather than letting it escape as an uncaught crash.
105
+ throw new ConfirmPromptError(err?.message
106
+ ? `Confirmation prompt failed: ${err.message}`
107
+ : "Confirmation prompt failed.");
108
+ }
109
+ }
110
+ //# sourceMappingURL=confirm-prompt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"confirm-prompt.js","sourceRoot":"","sources":["../../../src/lib/confirm-prompt.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AAEH,wEAAwE;AACxE,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAC3C,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AA4BD,KAAK,UAAU,eAAe,CAAC,MAG9B;IACC,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,MAAM,CAAC,mBAAmB,CAAC,CAAC;IACtD,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC;AACzB,CAAC;AAED;;;;;GAKG;AACH,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC;IAChC,iBAAiB;IACjB,kBAAkB;IAClB,mBAAmB;CACpB,CAAC,CAAC;AAEH;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,OAAe,EACf,UAAgC,EAAE;IAElC,MAAM,KAAK,GAAG,OAAO,CAAC,KAAK,IAAI,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAE5D,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,kBAAkB,CAC1B,4DAA4D;YAC1D,4DAA4D;YAC5D,+CAA+C,CAClD,CAAC;IACJ,CAAC;IAED,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,IAAI,eAAe,CAAC;IAErD,IAAI,CAAC;QACH,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC;YAC/B,OAAO;YACP,OAAO,EAAE,OAAO,CAAC,YAAY,IAAI,KAAK;SACvC,CAAC,CAAC;QACH,OAAO,OAAO,CAAC,SAAS,CAAC,CAAC;IAC5B,CAAC;IAAC,OAAO,GAAQ,EAAE,CAAC;QAClB,2DAA2D;QAC3D,+EAA+E;QAC/E,2EAA2E;QAC3E,wEAAwE;QACxE,8EAA8E;QAC9E,IACE,iBAAiB,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC;YAChC,GAAG,EAAE,IAAI,KAAK,qBAAqB,EACnC,CAAC;YACD,MAAM,IAAI,kBAAkB,CAC1B,iDAAiD;gBAC/C,8CAA8C,CACjD,CAAC;QACJ,CAAC;QACD,yEAAyE;QACzE,sDAAsD;QACtD,MAAM,IAAI,kBAAkB,CAC1B,GAAG,EAAE,OAAO;YACV,CAAC,CAAC,+BAA+B,GAAG,CAAC,OAAO,EAAE;YAC9C,CAAC,CAAC,6BAA6B,CAClC,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,11 @@
1
+ export declare const PRODUCTION_SERVER_URL = "https://primitiveapi.com";
2
+ export declare const DEFAULT_SERVER_URL: string;
3
+ /**
4
+ * The alpha deployment's canonical server URL. Mirrors
5
+ * `wrangler.toml [env.alpha] WORKER_URL` — keep the two in sync; if the alpha
6
+ * URL ever changes, update both. Used only by `primitive guides` to detect the
7
+ * alpha target and fetch guides from the `primitive-docs` `next` branch instead
8
+ * of `main` (issue #1463). This is an internal-only convenience;
9
+ * security-through-obscurity is acceptable.
10
+ */
11
+ export declare const ALPHA_SERVER_URL = "https://js-bao-wss-alpha.primitive-labs-dev.workers.dev";
@@ -0,0 +1,12 @@
1
+ export const PRODUCTION_SERVER_URL = "https://primitiveapi.com";
2
+ export const DEFAULT_SERVER_URL = process.env.PRIMITIVE_SERVER_URL || PRODUCTION_SERVER_URL;
3
+ /**
4
+ * The alpha deployment's canonical server URL. Mirrors
5
+ * `wrangler.toml [env.alpha] WORKER_URL` — keep the two in sync; if the alpha
6
+ * URL ever changes, update both. Used only by `primitive guides` to detect the
7
+ * alpha target and fetch guides from the `primitive-docs` `next` branch instead
8
+ * of `main` (issue #1463). This is an internal-only convenience;
9
+ * security-through-obscurity is acceptable.
10
+ */
11
+ export const ALPHA_SERVER_URL = "https://js-bao-wss-alpha.primitive-labs-dev.workers.dev";
12
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/lib/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,qBAAqB,GAAG,0BAA0B,CAAC;AAEhE,MAAM,CAAC,MAAM,kBAAkB,GAC7B,OAAO,CAAC,GAAG,CAAC,oBAAoB,IAAI,qBAAqB,CAAC;AAE5D;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAC3B,yDAAyD,CAAC"}
@@ -0,0 +1,20 @@
1
+ /**
2
+ * Global crash handlers for the CLI entrypoint (issue #972, Option A).
3
+ *
4
+ * The CLI previously registered no `uncaughtException` / `unhandledRejection`
5
+ * handlers. When an error escaped the top-level `.catch` in
6
+ * `cli/bin/primitive.ts` — e.g. the `ERR_USE_AFTER_CLOSE` thrown from inside an
7
+ * inquirer event-emitter callback when stdin isn't a usable TTY — Node printed
8
+ * only its bare `Node.js vX` version banner and died. That was the exact
9
+ * symptom in #972: a delete command crashed with no error message.
10
+ *
11
+ * These handlers are a narrow safety net: print a clean `✗ <message>` to stderr
12
+ * (matching `error()` in output.ts) and exit non-zero, so NO command can ever
13
+ * bare-crash again. They intentionally do not try to recover — they only make
14
+ * an already-fatal error legible.
15
+ */
16
+ /**
17
+ * Register process-level handlers that convert otherwise-fatal escaped errors
18
+ * into a clean stderr message + non-zero exit. Idempotent.
19
+ */
20
+ export declare function installGlobalCrashHandlers(): void;
@@ -0,0 +1,49 @@
1
+ /**
2
+ * Global crash handlers for the CLI entrypoint (issue #972, Option A).
3
+ *
4
+ * The CLI previously registered no `uncaughtException` / `unhandledRejection`
5
+ * handlers. When an error escaped the top-level `.catch` in
6
+ * `cli/bin/primitive.ts` — e.g. the `ERR_USE_AFTER_CLOSE` thrown from inside an
7
+ * inquirer event-emitter callback when stdin isn't a usable TTY — Node printed
8
+ * only its bare `Node.js vX` version banner and died. That was the exact
9
+ * symptom in #972: a delete command crashed with no error message.
10
+ *
11
+ * These handlers are a narrow safety net: print a clean `✗ <message>` to stderr
12
+ * (matching `error()` in output.ts) and exit non-zero, so NO command can ever
13
+ * bare-crash again. They intentionally do not try to recover — they only make
14
+ * an already-fatal error legible.
15
+ */
16
+ import { error } from "./output.js";
17
+ function describe(err) {
18
+ if (err && typeof err === "object") {
19
+ const e = err;
20
+ // The signature crash from a non-TTY confirm prompt — give actionable help.
21
+ if (e.code === "ERR_USE_AFTER_CLOSE") {
22
+ return ("No interactive terminal available to confirm this action. " +
23
+ "Re-run with --yes (-y) to skip the confirmation prompt in " +
24
+ "non-interactive contexts (CI, pipes, agents).");
25
+ }
26
+ if (e.message)
27
+ return e.message;
28
+ }
29
+ return "An unexpected error occurred.";
30
+ }
31
+ let installed = false;
32
+ /**
33
+ * Register process-level handlers that convert otherwise-fatal escaped errors
34
+ * into a clean stderr message + non-zero exit. Idempotent.
35
+ */
36
+ export function installGlobalCrashHandlers() {
37
+ if (installed)
38
+ return;
39
+ installed = true;
40
+ process.on("uncaughtException", (err) => {
41
+ error(describe(err));
42
+ process.exit(1);
43
+ });
44
+ process.on("unhandledRejection", (reason) => {
45
+ error(describe(reason));
46
+ process.exit(1);
47
+ });
48
+ }
49
+ //# sourceMappingURL=crash-handlers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crash-handlers.js","sourceRoot":"","sources":["../../../src/lib/crash-handlers.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAEpC,SAAS,QAAQ,CAAC,GAAY;IAC5B,IAAI,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QACnC,MAAM,CAAC,GAAG,GAA0C,CAAC;QACrD,4EAA4E;QAC5E,IAAI,CAAC,CAAC,IAAI,KAAK,qBAAqB,EAAE,CAAC;YACrC,OAAO,CACL,4DAA4D;gBAC5D,4DAA4D;gBAC5D,+CAA+C,CAChD,CAAC;QACJ,CAAC;QACD,IAAI,CAAC,CAAC,OAAO;YAAE,OAAO,CAAC,CAAC,OAAO,CAAC;IAClC,CAAC;IACD,OAAO,+BAA+B,CAAC;AACzC,CAAC;AAED,IAAI,SAAS,GAAG,KAAK,CAAC;AAEtB;;;GAGG;AACH,MAAM,UAAU,0BAA0B;IACxC,IAAI,SAAS;QAAE,OAAO;IACtB,SAAS,GAAG,IAAI,CAAC;IAEjB,OAAO,CAAC,EAAE,CAAC,mBAAmB,EAAE,CAAC,GAAG,EAAE,EAAE;QACtC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;QACrB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;IAEH,OAAO,CAAC,EAAE,CAAC,oBAAoB,EAAE,CAAC,MAAM,EAAE,EAAE;QAC1C,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;QACxB,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,104 @@
1
+ /**
2
+ * Credentials storage with dual-mode support.
3
+ *
4
+ * Credentials are tokens and who they belong to, and nothing else: the app an
5
+ * invocation runs against is the resolved environment's `appId` (#3152), never
6
+ * a slot in this file.
7
+ *
8
+ * Mode A (project mode): credentials live at
9
+ * <projectRoot>/.primitive/credentials.json
10
+ * with per-environment slots:
11
+ * {
12
+ * "environments": {
13
+ * "dev": { "accessToken": "...", "refreshToken": "...", ... },
14
+ * "prod": { ... }
15
+ * }
16
+ * }
17
+ *
18
+ * Mode B (global mode): no primitive/config.json in scope, so we fall back to
19
+ * ~/.primitive/credentials.json
20
+ * with the flat Credentials shape the CLI has always used.
21
+ *
22
+ * Mode B is NOT a default any more (#3154, intent criterion 5). It used to be
23
+ * the silent answer for every command run outside a project, which is how an
24
+ * app-scoped command could quietly operate against whatever server the last
25
+ * `login` happened to target. Now a command has to say out loud that it may
26
+ * work outside a project, by calling `allowGlobalCredentials()` in its own
27
+ * action; every other command gets `missing-config` here instead of a file.
28
+ *
29
+ * Exactly four commands say it: `login`, which creates the file; `logout`,
30
+ * which is the only way to clear what login wrote; `init`, which must call the
31
+ * API before a project can exist; and `bootstrap`, which creates the first
32
+ * super-admin on an empty no-OAuth database and therefore cannot be inside a
33
+ * project either. The last two are the divergence from the intent's "login and
34
+ * init and nothing else", adjudicated on #3154 as finding F1.
35
+ *
36
+ * The opt-in is per ACTION, not per argv: `primitive --env prod login` and
37
+ * `primitive login` reach the same line, so there is no flag shape for a
38
+ * pre-parse to miss. And it only PERMITS the global file — inside a project
39
+ * all four still use the per-environment slots.
40
+ */
41
+ import type { Credentials } from "../types/index.js";
42
+ export declare const PROJECT_LOCAL_DIR = ".primitive";
43
+ export declare const PROJECT_CREDENTIALS_FILENAME = "credentials.json";
44
+ /** Returns true when a primitive/config.json is in scope (project mode active). */
45
+ export declare function isProjectMode(): boolean;
46
+ /**
47
+ * Returns the path to the credentials file that will be used, based on
48
+ * whether we're in project mode or legacy mode.
49
+ */
50
+ export declare function getCredentialsFilePath(): string;
51
+ /**
52
+ * Declare that THIS command may fall back to `~/.primitive/credentials.json`
53
+ * when no project is in scope. Called at the top of `login`, `logout`, `init`
54
+ * and `bootstrap`, and nowhere else.
55
+ */
56
+ export declare function allowGlobalCredentials(): void;
57
+ /**
58
+ * Drop the declaration again. One invocation runs one command, so nothing in
59
+ * the CLI calls this — it exists so a test file can exercise both sides of the
60
+ * boundary in one process, the way `resetEnvResolver()` does for the resolver.
61
+ */
62
+ export declare function resetGlobalCredentialsAllowance(): void;
63
+ /**
64
+ * Reads credentials for the current environment (project mode) or the
65
+ * legacy global file. Returns the standard Credentials shape so existing
66
+ * callers don't need to change.
67
+ *
68
+ * In project mode, we blend the per-env stored creds with the serverUrl
69
+ * and appId from primitive/config.json to produce the Credentials the rest of
70
+ * the CLI expects.
71
+ */
72
+ export declare function loadCredentialsStore(): Credentials | null;
73
+ /**
74
+ * Saves credentials. In project mode, writes to the per-env slot in the
75
+ * project credentials file. In legacy mode, writes the global file.
76
+ *
77
+ * The serverUrl on the incoming Credentials is used as-is for legacy
78
+ * mode, and ignored in project mode (the env's apiUrl is canonical).
79
+ */
80
+ export declare function saveCredentialsStore(credentials: Credentials): void;
81
+ /**
82
+ * Clears credentials for the current environment (project mode) or
83
+ * deletes the legacy file (legacy mode).
84
+ */
85
+ export declare function clearCredentialsStore(): void;
86
+ /**
87
+ * Removes the credentials slot for the named environment in a specific
88
+ * project's credentials file. Used by `env remove` so stale tokens from a
89
+ * previously-removed environment can never be silently re-used if the same
90
+ * name is later added back. Never throws.
91
+ */
92
+ export declare function clearCredentialsForEnvInProject(projectRoot: string, envName: string): void;
93
+ /**
94
+ * Writes the credentials slot for the named environment in a specific
95
+ * project's credentials file. Used by `primitive init` to carry the session
96
+ * it just authenticated into the freshly scaffolded project, so the first
97
+ * in-project CLI command works without a second `primitive login`.
98
+ */
99
+ export declare function seedCredentialsForEnvInProject(projectRoot: string, envName: string, credentials: Credentials): void;
100
+ /**
101
+ * Lists all environments that have stored credentials in project mode.
102
+ * Returns an empty array in legacy mode.
103
+ */
104
+ export declare function listAuthenticatedEnvironments(): string[];