primitive-admin 1.1.0-alpha.6 → 1.1.0-alpha.61

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 (387) hide show
  1. package/README.md +389 -71
  2. package/assets/skill/skills/primitive-platform/SKILL.md +670 -0
  3. package/dist/bin/primitive.d.ts +2 -0
  4. package/dist/bin/primitive.js +287 -17
  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 +554 -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 +27 -80
  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 +526 -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 +35 -0
  34. package/dist/src/commands/config.js +437 -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 +204 -0
  41. package/dist/src/commands/cron-triggers.js.map +1 -0
  42. package/dist/src/commands/database-types.d.ts +2 -0
  43. package/dist/src/commands/database-types.js +171 -0
  44. package/dist/src/commands/database-types.js.map +1 -0
  45. package/dist/src/commands/databases.d.ts +65 -0
  46. package/dist/src/commands/databases.js +2153 -96
  47. package/dist/src/commands/databases.js.map +1 -1
  48. package/dist/src/commands/documents.d.ts +2 -0
  49. package/dist/src/commands/documents.js +1230 -19
  50. package/dist/src/commands/documents.js.map +1 -1
  51. package/dist/src/commands/email-templates.d.ts +2 -0
  52. package/dist/src/commands/email-templates.js +174 -0
  53. package/dist/src/commands/email-templates.js.map +1 -0
  54. package/dist/src/commands/env.d.ts +12 -0
  55. package/dist/src/commands/env.js +260 -0
  56. package/dist/src/commands/env.js.map +1 -0
  57. package/dist/src/commands/group-type-configs.d.ts +2 -0
  58. package/dist/src/commands/group-type-configs.js +86 -0
  59. package/dist/src/commands/group-type-configs.js.map +1 -0
  60. package/dist/src/commands/groups.d.ts +2 -0
  61. package/dist/src/commands/groups.js +38 -99
  62. package/dist/src/commands/groups.js.map +1 -1
  63. package/dist/src/commands/guides.d.ts +223 -0
  64. package/dist/src/commands/guides.js +617 -65
  65. package/dist/src/commands/guides.js.map +1 -1
  66. package/dist/src/commands/init.d.ts +17 -0
  67. package/dist/src/commands/init.js +964 -202
  68. package/dist/src/commands/init.js.map +1 -1
  69. package/dist/src/commands/integrations.d.ts +2 -0
  70. package/dist/src/commands/integrations.js +484 -205
  71. package/dist/src/commands/integrations.js.map +1 -1
  72. package/dist/src/commands/llm.d.ts +2 -0
  73. package/dist/src/commands/llm.js +13 -8
  74. package/dist/src/commands/llm.js.map +1 -1
  75. package/dist/src/commands/locks.d.ts +8 -0
  76. package/dist/src/commands/locks.js +160 -0
  77. package/dist/src/commands/locks.js.map +1 -0
  78. package/dist/src/commands/metadata.d.ts +2 -0
  79. package/dist/src/commands/metadata.js +406 -0
  80. package/dist/src/commands/metadata.js.map +1 -0
  81. package/dist/src/commands/prompts.d.ts +2 -0
  82. package/dist/src/commands/prompts.js +135 -355
  83. package/dist/src/commands/prompts.js.map +1 -1
  84. package/dist/src/commands/rule-sets.d.ts +3 -0
  85. package/dist/src/commands/rule-sets.js +271 -0
  86. package/dist/src/commands/rule-sets.js.map +1 -0
  87. package/dist/src/commands/scripts.d.ts +20 -0
  88. package/dist/src/commands/scripts.js +739 -0
  89. package/dist/src/commands/scripts.js.map +1 -0
  90. package/dist/src/commands/secrets.d.ts +2 -0
  91. package/dist/src/commands/secrets.js +108 -0
  92. package/dist/src/commands/secrets.js.map +1 -0
  93. package/dist/src/commands/sessions.d.ts +2 -0
  94. package/dist/src/commands/sessions.js +75 -0
  95. package/dist/src/commands/sessions.js.map +1 -0
  96. package/dist/src/commands/settings.d.ts +18 -0
  97. package/dist/src/commands/settings.js +54 -0
  98. package/dist/src/commands/settings.js.map +1 -0
  99. package/dist/src/commands/skill.d.ts +2 -0
  100. package/dist/src/commands/skill.js +29 -0
  101. package/dist/src/commands/skill.js.map +1 -0
  102. package/dist/src/commands/sync-app-settings.d.ts +125 -0
  103. package/dist/src/commands/sync-app-settings.js +380 -0
  104. package/dist/src/commands/sync-app-settings.js.map +1 -0
  105. package/dist/src/commands/sync.d.ts +958 -0
  106. package/dist/src/commands/sync.js +8954 -812
  107. package/dist/src/commands/sync.js.map +1 -1
  108. package/dist/src/commands/tokens.d.ts +2 -0
  109. package/dist/src/commands/tokens.js +130 -21
  110. package/dist/src/commands/tokens.js.map +1 -1
  111. package/dist/src/commands/users.d.ts +2 -0
  112. package/dist/src/commands/users.js +440 -22
  113. package/dist/src/commands/users.js.map +1 -1
  114. package/dist/src/commands/vars.d.ts +8 -0
  115. package/dist/src/commands/vars.js +96 -0
  116. package/dist/src/commands/vars.js.map +1 -0
  117. package/dist/src/commands/waitlist.d.ts +2 -0
  118. package/dist/src/commands/waitlist.js +10 -10
  119. package/dist/src/commands/waitlist.js.map +1 -1
  120. package/dist/src/commands/webhooks.d.ts +2 -0
  121. package/dist/src/commands/webhooks.js +442 -0
  122. package/dist/src/commands/webhooks.js.map +1 -0
  123. package/dist/src/commands/workflows.d.ts +94 -0
  124. package/dist/src/commands/workflows.js +1581 -448
  125. package/dist/src/commands/workflows.js.map +1 -1
  126. package/dist/src/lib/api-client.d.ts +1814 -0
  127. package/dist/src/lib/api-client.js +1655 -103
  128. package/dist/src/lib/api-client.js.map +1 -1
  129. package/dist/src/lib/app-settings-descriptor.d.ts +130 -0
  130. package/dist/src/lib/app-settings-descriptor.js +262 -0
  131. package/dist/src/lib/app-settings-descriptor.js.map +1 -0
  132. package/dist/src/lib/auth-flow.d.ts +8 -0
  133. package/dist/src/lib/batch.d.ts +26 -0
  134. package/dist/src/lib/batch.js +32 -0
  135. package/dist/src/lib/batch.js.map +1 -0
  136. package/dist/src/lib/block-layout.d.ts +160 -0
  137. package/dist/src/lib/block-layout.js +451 -0
  138. package/dist/src/lib/block-layout.js.map +1 -0
  139. package/dist/src/lib/canonical-json.d.ts +12 -0
  140. package/dist/src/lib/canonical-json.js +35 -0
  141. package/dist/src/lib/canonical-json.js.map +1 -0
  142. package/dist/src/lib/channel.d.ts +30 -0
  143. package/dist/src/lib/channel.js +68 -0
  144. package/dist/src/lib/channel.js.map +1 -0
  145. package/dist/src/lib/cli-manifest.d.ts +68 -0
  146. package/dist/src/lib/cli-manifest.js +71 -0
  147. package/dist/src/lib/cli-manifest.js.map +1 -0
  148. package/dist/src/lib/codegen-shared/generatedFiles.d.ts +97 -0
  149. package/dist/src/lib/codegen-shared/generatedFiles.js +184 -0
  150. package/dist/src/lib/codegen-shared/generatedFiles.js.map +1 -0
  151. package/dist/src/lib/codegen-shared/prettierStable.d.ts +262 -0
  152. package/dist/src/lib/codegen-shared/prettierStable.js +610 -0
  153. package/dist/src/lib/codegen-shared/prettierStable.js.map +1 -0
  154. package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.d.ts +68 -0
  155. package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.js +168 -0
  156. package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.js.map +1 -0
  157. package/dist/src/lib/config-object-descriptor.d.ts +108 -0
  158. package/dist/src/lib/config-object-descriptor.js +607 -0
  159. package/dist/src/lib/config-object-descriptor.js.map +1 -0
  160. package/dist/src/lib/config-payload.d.ts +85 -0
  161. package/dist/src/lib/config-payload.js +105 -0
  162. package/dist/src/lib/config-payload.js.map +1 -0
  163. package/dist/src/lib/config-surface.d.ts +93 -0
  164. package/dist/src/lib/config-surface.js +178 -0
  165. package/dist/src/lib/config-surface.js.map +1 -0
  166. package/dist/src/lib/config-toml.d.ts +10 -0
  167. package/dist/src/lib/config-toml.js +42 -0
  168. package/dist/src/lib/config-toml.js.map +1 -0
  169. package/dist/src/lib/config.d.ts +53 -0
  170. package/dist/src/lib/config.js +92 -53
  171. package/dist/src/lib/config.js.map +1 -1
  172. package/dist/src/lib/confirm-prompt.d.ts +83 -0
  173. package/dist/src/lib/confirm-prompt.js +110 -0
  174. package/dist/src/lib/confirm-prompt.js.map +1 -0
  175. package/dist/src/lib/constants.d.ts +11 -0
  176. package/dist/src/lib/constants.js +12 -0
  177. package/dist/src/lib/constants.js.map +1 -0
  178. package/dist/src/lib/crash-handlers.d.ts +20 -0
  179. package/dist/src/lib/crash-handlers.js +49 -0
  180. package/dist/src/lib/crash-handlers.js.map +1 -0
  181. package/dist/src/lib/credentials-store.d.ts +89 -0
  182. package/dist/src/lib/credentials-store.js +330 -0
  183. package/dist/src/lib/credentials-store.js.map +1 -0
  184. package/dist/src/lib/csv.d.ts +47 -0
  185. package/dist/src/lib/csv.js +172 -0
  186. package/dist/src/lib/csv.js.map +1 -0
  187. package/dist/src/lib/data-input.d.ts +23 -0
  188. package/dist/src/lib/data-input.js +50 -0
  189. package/dist/src/lib/data-input.js.map +1 -0
  190. package/dist/src/lib/db-codegen/dbFingerprint.d.ts +10 -0
  191. package/dist/src/lib/db-codegen/dbFingerprint.js +17 -0
  192. package/dist/src/lib/db-codegen/dbFingerprint.js.map +1 -0
  193. package/dist/src/lib/db-codegen/dbGenerator.d.ts +67 -0
  194. package/dist/src/lib/db-codegen/dbGenerator.js +170 -0
  195. package/dist/src/lib/db-codegen/dbGenerator.js.map +1 -0
  196. package/dist/src/lib/db-codegen/dbNaming.d.ts +87 -0
  197. package/dist/src/lib/db-codegen/dbNaming.js +180 -0
  198. package/dist/src/lib/db-codegen/dbNaming.js.map +1 -0
  199. package/dist/src/lib/db-codegen/dbTemplates.d.ts +272 -0
  200. package/dist/src/lib/db-codegen/dbTemplates.js +480 -0
  201. package/dist/src/lib/db-codegen/dbTemplates.js.map +1 -0
  202. package/dist/src/lib/db-codegen/dbTsTypes.d.ts +73 -0
  203. package/dist/src/lib/db-codegen/dbTsTypes.js +139 -0
  204. package/dist/src/lib/db-codegen/dbTsTypes.js.map +1 -0
  205. package/dist/src/lib/db-codegen/dbTypeIR.d.ts +146 -0
  206. package/dist/src/lib/db-codegen/dbTypeIR.js +517 -0
  207. package/dist/src/lib/db-codegen/dbTypeIR.js.map +1 -0
  208. package/dist/src/lib/db-codegen/generated-operation-def-descriptor.d.ts +112 -0
  209. package/dist/src/lib/db-codegen/generated-operation-def-descriptor.js +211 -0
  210. package/dist/src/lib/db-codegen/generated-operation-def-descriptor.js.map +1 -0
  211. package/dist/src/lib/env-resolver.d.ts +62 -0
  212. package/dist/src/lib/env-resolver.js +121 -0
  213. package/dist/src/lib/env-resolver.js.map +1 -0
  214. package/dist/src/lib/fetch.d.ts +5 -0
  215. package/dist/src/lib/generated-allowlist.d.ts +28 -0
  216. package/dist/src/lib/generated-allowlist.js +266 -0
  217. package/dist/src/lib/generated-allowlist.js.map +1 -0
  218. package/dist/src/lib/generated-config-surfaces.d.ts +578 -0
  219. package/dist/src/lib/generated-config-surfaces.js +3630 -0
  220. package/dist/src/lib/generated-config-surfaces.js.map +1 -0
  221. package/dist/src/lib/generated-template-lint.d.ts +206 -0
  222. package/dist/src/lib/generated-template-lint.js +589 -0
  223. package/dist/src/lib/generated-template-lint.js.map +1 -0
  224. package/dist/src/lib/generated-workflow-model-fields.d.ts +20 -0
  225. package/dist/src/lib/generated-workflow-model-fields.js +53 -0
  226. package/dist/src/lib/generated-workflow-model-fields.js.map +1 -0
  227. package/dist/src/lib/google-client-secret-status.d.ts +35 -0
  228. package/dist/src/lib/google-client-secret-status.js +56 -0
  229. package/dist/src/lib/google-client-secret-status.js.map +1 -0
  230. package/dist/src/lib/init-config.d.ts +81 -0
  231. package/dist/src/lib/init-config.js +149 -0
  232. package/dist/src/lib/init-config.js.map +1 -0
  233. package/dist/src/lib/log-inspection.d.ts +568 -0
  234. package/dist/src/lib/log-inspection.js +639 -0
  235. package/dist/src/lib/log-inspection.js.map +1 -0
  236. package/dist/src/lib/migration-nag.d.ts +49 -0
  237. package/dist/src/lib/migration-nag.js +163 -0
  238. package/dist/src/lib/migration-nag.js.map +1 -0
  239. package/dist/src/lib/output.d.ts +109 -0
  240. package/dist/src/lib/output.js +191 -8
  241. package/dist/src/lib/output.js.map +1 -1
  242. package/dist/src/lib/package-manager.d.ts +140 -0
  243. package/dist/src/lib/package-manager.js +305 -0
  244. package/dist/src/lib/package-manager.js.map +1 -0
  245. package/dist/src/lib/paginate.d.ts +83 -0
  246. package/dist/src/lib/paginate.js +95 -0
  247. package/dist/src/lib/paginate.js.map +1 -0
  248. package/dist/src/lib/platform-owned.d.ts +51 -0
  249. package/dist/src/lib/platform-owned.js +64 -0
  250. package/dist/src/lib/platform-owned.js.map +1 -0
  251. package/dist/src/lib/project-config.d.ts +97 -0
  252. package/dist/src/lib/project-config.js +219 -0
  253. package/dist/src/lib/project-config.js.map +1 -0
  254. package/dist/src/lib/query-operators.d.ts +43 -0
  255. package/dist/src/lib/query-operators.js +80 -0
  256. package/dist/src/lib/query-operators.js.map +1 -0
  257. package/dist/src/lib/record-filter.d.ts +18 -0
  258. package/dist/src/lib/record-filter.js +55 -0
  259. package/dist/src/lib/record-filter.js.map +1 -0
  260. package/dist/src/lib/refresh-admin-credentials.d.ts +65 -0
  261. package/dist/src/lib/refresh-admin-credentials.js +103 -0
  262. package/dist/src/lib/refresh-admin-credentials.js.map +1 -0
  263. package/dist/src/lib/resolve-init-dev-port.d.ts +56 -0
  264. package/dist/src/lib/resolve-init-dev-port.js +55 -0
  265. package/dist/src/lib/resolve-init-dev-port.js.map +1 -0
  266. package/dist/src/lib/resolve-init-server.d.ts +71 -0
  267. package/dist/src/lib/resolve-init-server.js +94 -0
  268. package/dist/src/lib/resolve-init-server.js.map +1 -0
  269. package/dist/src/lib/resolve-platform.d.ts +45 -0
  270. package/dist/src/lib/resolve-platform.js +43 -0
  271. package/dist/src/lib/resolve-platform.js.map +1 -0
  272. package/dist/src/lib/run-status.d.ts +19 -0
  273. package/dist/src/lib/run-status.generated.d.ts +39 -0
  274. package/dist/src/lib/run-status.generated.js +66 -0
  275. package/dist/src/lib/run-status.generated.js.map +1 -0
  276. package/dist/src/lib/run-status.js +19 -0
  277. package/dist/src/lib/run-status.js.map +1 -0
  278. package/dist/src/lib/signing-secret-status.d.ts +81 -0
  279. package/dist/src/lib/signing-secret-status.js +116 -0
  280. package/dist/src/lib/signing-secret-status.js.map +1 -0
  281. package/dist/src/lib/skill-installer.d.ts +25 -0
  282. package/dist/src/lib/skill-installer.js +266 -0
  283. package/dist/src/lib/skill-installer.js.map +1 -0
  284. package/dist/src/lib/snapshots.d.ts +99 -0
  285. package/dist/src/lib/snapshots.js +357 -0
  286. package/dist/src/lib/snapshots.js.map +1 -0
  287. package/dist/src/lib/swift-codegen/dbGenerator.d.ts +100 -0
  288. package/dist/src/lib/swift-codegen/dbGenerator.js +682 -0
  289. package/dist/src/lib/swift-codegen/dbGenerator.js.map +1 -0
  290. package/dist/src/lib/swift-codegen/dbSwiftTypes.d.ts +42 -0
  291. package/dist/src/lib/swift-codegen/dbSwiftTypes.js +100 -0
  292. package/dist/src/lib/swift-codegen/dbSwiftTypes.js.map +1 -0
  293. package/dist/src/lib/swift-codegen/generator.d.ts +85 -0
  294. package/dist/src/lib/swift-codegen/generator.js +266 -0
  295. package/dist/src/lib/swift-codegen/generator.js.map +1 -0
  296. package/dist/src/lib/swift-codegen/schemaToSwift.d.ts +72 -0
  297. package/dist/src/lib/swift-codegen/schemaToSwift.js +644 -0
  298. package/dist/src/lib/swift-codegen/schemaToSwift.js.map +1 -0
  299. package/dist/src/lib/swift-codegen/siblingSymbols.d.ts +90 -0
  300. package/dist/src/lib/swift-codegen/siblingSymbols.js +152 -0
  301. package/dist/src/lib/swift-codegen/siblingSymbols.js.map +1 -0
  302. package/dist/src/lib/swift-codegen/swiftNaming.d.ts +85 -0
  303. package/dist/src/lib/swift-codegen/swiftNaming.js +198 -0
  304. package/dist/src/lib/swift-codegen/swiftNaming.js.map +1 -0
  305. package/dist/src/lib/sync-paths.d.ts +72 -0
  306. package/dist/src/lib/sync-paths.js +130 -0
  307. package/dist/src/lib/sync-paths.js.map +1 -0
  308. package/dist/src/lib/sync-resource-types.d.ts +445 -0
  309. package/dist/src/lib/sync-resource-types.js +812 -0
  310. package/dist/src/lib/sync-resource-types.js.map +1 -0
  311. package/dist/src/lib/sync-selectors.d.ts +95 -0
  312. package/dist/src/lib/sync-selectors.js +228 -0
  313. package/dist/src/lib/sync-selectors.js.map +1 -0
  314. package/dist/src/lib/template.d.ts +121 -0
  315. package/dist/src/lib/template.js +447 -67
  316. package/dist/src/lib/template.js.map +1 -1
  317. package/dist/src/lib/token-inject.d.ts +56 -0
  318. package/dist/src/lib/token-inject.js +204 -0
  319. package/dist/src/lib/token-inject.js.map +1 -0
  320. package/dist/src/lib/toml-database-config.d.ts +123 -0
  321. package/dist/src/lib/toml-database-config.js +527 -0
  322. package/dist/src/lib/toml-database-config.js.map +1 -0
  323. package/dist/src/lib/toml-metadata-config.d.ts +151 -0
  324. package/dist/src/lib/toml-metadata-config.js +476 -0
  325. package/dist/src/lib/toml-metadata-config.js.map +1 -0
  326. package/dist/src/lib/toml-native-form.d.ts +46 -0
  327. package/dist/src/lib/toml-native-form.js +78 -0
  328. package/dist/src/lib/toml-native-form.js.map +1 -0
  329. package/dist/src/lib/toml-params-validator.d.ts +129 -0
  330. package/dist/src/lib/toml-params-validator.js +298 -0
  331. package/dist/src/lib/toml-params-validator.js.map +1 -0
  332. package/dist/src/lib/toml-scalar-edit.d.ts +43 -0
  333. package/dist/src/lib/toml-scalar-edit.js +283 -0
  334. package/dist/src/lib/toml-scalar-edit.js.map +1 -0
  335. package/dist/src/lib/user-selector.d.ts +24 -0
  336. package/dist/src/lib/user-selector.js +33 -0
  337. package/dist/src/lib/user-selector.js.map +1 -0
  338. package/dist/src/lib/version-check.d.ts +35 -0
  339. package/dist/src/lib/version-check.js +241 -0
  340. package/dist/src/lib/version-check.js.map +1 -0
  341. package/dist/src/lib/watch.d.ts +121 -0
  342. package/dist/src/lib/watch.js +169 -0
  343. package/dist/src/lib/watch.js.map +1 -0
  344. package/dist/src/lib/workflow-apply.d.ts +51 -0
  345. package/dist/src/lib/workflow-apply.js +89 -0
  346. package/dist/src/lib/workflow-apply.js.map +1 -0
  347. package/dist/src/lib/workflow-codegen/generated-schema-descriptor.d.ts +129 -0
  348. package/dist/src/lib/workflow-codegen/generated-schema-descriptor.js +269 -0
  349. package/dist/src/lib/workflow-codegen/generated-schema-descriptor.js.map +1 -0
  350. package/dist/src/lib/workflow-codegen/generator.d.ts +96 -0
  351. package/dist/src/lib/workflow-codegen/generator.js +361 -0
  352. package/dist/src/lib/workflow-codegen/generator.js.map +1 -0
  353. package/dist/src/lib/workflow-codegen/invokerIR.d.ts +83 -0
  354. package/dist/src/lib/workflow-codegen/invokerIR.js +71 -0
  355. package/dist/src/lib/workflow-codegen/invokerIR.js.map +1 -0
  356. package/dist/src/lib/workflow-codegen/naming.d.ts +33 -0
  357. package/dist/src/lib/workflow-codegen/naming.js +81 -0
  358. package/dist/src/lib/workflow-codegen/naming.js.map +1 -0
  359. package/dist/src/lib/workflow-codegen/schemaToTs.d.ts +80 -0
  360. package/dist/src/lib/workflow-codegen/schemaToTs.js +303 -0
  361. package/dist/src/lib/workflow-codegen/schemaToTs.js.map +1 -0
  362. package/dist/src/lib/workflow-config-apply.d.ts +70 -0
  363. package/dist/src/lib/workflow-config-apply.js +137 -0
  364. package/dist/src/lib/workflow-config-apply.js.map +1 -0
  365. package/dist/src/lib/workflow-config-sidecar.d.ts +63 -0
  366. package/dist/src/lib/workflow-config-sidecar.js +96 -0
  367. package/dist/src/lib/workflow-config-sidecar.js.map +1 -0
  368. package/dist/src/lib/workflow-field-descriptor.d.ts +91 -0
  369. package/dist/src/lib/workflow-field-descriptor.js +153 -0
  370. package/dist/src/lib/workflow-field-descriptor.js.map +1 -0
  371. package/dist/src/lib/workflow-fragments.d.ts +64 -0
  372. package/dist/src/lib/workflow-fragments.js +342 -0
  373. package/dist/src/lib/workflow-fragments.js.map +1 -0
  374. package/dist/src/lib/workflow-include-preserve.d.ts +71 -0
  375. package/dist/src/lib/workflow-include-preserve.js +153 -0
  376. package/dist/src/lib/workflow-include-preserve.js.map +1 -0
  377. package/dist/src/lib/workflow-payload.d.ts +86 -0
  378. package/dist/src/lib/workflow-payload.js +168 -0
  379. package/dist/src/lib/workflow-payload.js.map +1 -0
  380. package/dist/src/lib/workflow-toml-validator.d.ts +199 -0
  381. package/dist/src/lib/workflow-toml-validator.js +754 -0
  382. package/dist/src/lib/workflow-toml-validator.js.map +1 -0
  383. package/dist/src/types/index.d.ts +533 -0
  384. package/dist/src/validators.d.ts +65 -0
  385. package/dist/src/validators.js +64 -0
  386. package/dist/src/validators.js.map +1 -0
  387. package/package.json +32 -6
@@ -0,0 +1,739 @@
1
+ import { ApiClient } from "../lib/api-client.js";
2
+ import { resolveAppId } from "../lib/config.js";
3
+ import chalk from "chalk";
4
+ import { success, error, info, keyValue, result as printResult, formatTable, formatId, formatDate, formatDuration, json, divider, } from "../lib/output.js";
5
+ import { confirmPrompt } from "../lib/confirm-prompt.js";
6
+ /**
7
+ * Resolve a user-supplied script reference (either a `scriptId` or the
8
+ * script's `name`) to its `scriptId`. Scripts are named handles, so the CLI
9
+ * accepts a name for convenience the way `sync` refers to them by name; the
10
+ * block-testing API keys on `scriptId` (the block id). If a raw id matches an
11
+ * existing script it is used directly; otherwise we list the app's scripts and
12
+ * match on name (case-sensitive, then case-insensitive as a fallback).
13
+ *
14
+ * The server enforces name uniqueness by EXACT match, so `foo` and `FOO` can
15
+ * both exist. Input `Foo` then matches neither exactly and falls through to the
16
+ * case-insensitive step with two candidates — where picking one is arbitrary.
17
+ * That is a silent wrong-target write for `update`/`configs activate` and an
18
+ * unrecoverable one for `delete`, so an ambiguous fallback is an error naming
19
+ * the candidates. A single case-insensitive match still resolves, keeping the
20
+ * convenience behavior every command already relies on.
21
+ */
22
+ export async function resolveScriptId(client, appId, ref) {
23
+ const { items } = await client.listScripts(appId);
24
+ const byId = items.find((s) => s.scriptId === ref);
25
+ if (byId)
26
+ return byId.scriptId;
27
+ const byName = items.find((s) => s.name === ref);
28
+ if (byName)
29
+ return byName.scriptId;
30
+ const byNameCi = items.filter((s) => String(s.name).toLowerCase() === ref.toLowerCase());
31
+ if (byNameCi.length === 1)
32
+ return byNameCi[0].scriptId;
33
+ if (byNameCi.length > 1) {
34
+ const candidates = byNameCi
35
+ .map((s) => String(s.name))
36
+ .sort()
37
+ .join(", ");
38
+ throw new Error(`Script name is ambiguous: ${ref}. Did you mean: ${candidates}? ` +
39
+ `Names differing only in case must be given exactly, or by scriptId.`);
40
+ }
41
+ throw new Error(`Script not found: ${ref}`);
42
+ }
43
+ export function registerScriptsCommands(program) {
44
+ const scripts = program
45
+ .command("scripts")
46
+ .description("Inspect Rhai scripts (transforms), their versions, and tests")
47
+ .addHelpText("after", `
48
+ Examples:
49
+ $ primitive scripts list
50
+ $ primitive scripts get my-transform
51
+ # Deleting: remove transforms/my-transform.rhai and run 'primitive sync push --prune'.
52
+ $ primitive scripts configs list my-transform
53
+ $ primitive scripts tests list my-transform
54
+ $ primitive scripts tests create my-transform --name "Basic" --vars '{"x":1}'
55
+ $ primitive scripts tests run my-transform <test-case-id>
56
+ $ primitive scripts tests run-all my-transform
57
+
58
+ Scripts (transforms) are authored via 'sync' from transforms/<name>.rhai
59
+ files. Test cases live under transforms/<name>.tests/*.toml and round-trip
60
+ through 'sync pull' / 'sync push'. Both the script reference and the test
61
+ commands accept either a script id or a script name.
62
+ `);
63
+ // Server-side configuration is authored in TOML and applied with `sync push`
64
+ // (issue #2645) — this group no longer carries config-setting flags.
65
+ scripts.addHelpText("after", `
66
+ Configuration lives in transforms/<name>.rhai:
67
+ $ primitive config fields transform # the file's keys, types and defaults
68
+ $ primitive config new transform <key> # scaffold one locally
69
+ $ primitive config set transform/<key> <path>=<value>
70
+ $ primitive sync push --only transform/<key>
71
+ `);
72
+ // List scripts
73
+ scripts
74
+ .command("list")
75
+ .description("List scripts (transforms) for an app")
76
+ .argument("[app-id]", "App ID (uses current app if not specified)")
77
+ .option("--app <app-id>", "App ID (uses current app if not specified)")
78
+ .option("--json", "Output as JSON")
79
+ .action(async (appId, options) => {
80
+ const resolvedAppId = resolveAppId(appId, options);
81
+ const client = new ApiClient();
82
+ try {
83
+ const { items } = await client.listScripts(resolvedAppId);
84
+ if (options.json) {
85
+ json(items);
86
+ return;
87
+ }
88
+ if (!items || items.length === 0) {
89
+ info("No scripts found.");
90
+ return;
91
+ }
92
+ console.log(formatTable(items, [
93
+ { header: "ID", key: "scriptId", format: formatId },
94
+ { header: "NAME", key: "name" },
95
+ {
96
+ header: "ACTIVE CONFIG",
97
+ key: "activeConfigId",
98
+ format: (v) => (v ? formatId(v) : "-"),
99
+ },
100
+ { header: "MODIFIED", key: "modifiedAt", format: formatDate },
101
+ ]));
102
+ }
103
+ catch (err) {
104
+ error(err.message);
105
+ process.exit(1);
106
+ }
107
+ });
108
+ // Get a script
109
+ scripts
110
+ .command("get")
111
+ .description("Get a script's details and versions")
112
+ .argument("<script>", "Script ID or name")
113
+ .option("--app <app-id>", "App ID (uses current app if not specified)")
114
+ .option("--json", "Output as JSON")
115
+ .action(async (script, options) => {
116
+ const resolvedAppId = resolveAppId(undefined, options);
117
+ const client = new ApiClient();
118
+ try {
119
+ const scriptId = await resolveScriptId(client, resolvedAppId, script);
120
+ const result = await client.getScript(resolvedAppId, scriptId);
121
+ if (options.json) {
122
+ json(result);
123
+ return;
124
+ }
125
+ printResult("Script ID", result.scriptId);
126
+ printResult("Name", result.name);
127
+ printResult("Description", result.description || "-");
128
+ printResult("Active Config", result.activeConfigId || "-");
129
+ printResult("Created", formatDate(result.createdAt));
130
+ const configs = Array.isArray(result.configs) ? result.configs : [];
131
+ if (configs.length > 0) {
132
+ divider();
133
+ info("Versions:");
134
+ console.log(formatTable(configs, [
135
+ { header: "CONFIG ID", key: "configId", format: formatId },
136
+ { header: "NAME", key: "configName" },
137
+ { header: "STATUS", key: "status" },
138
+ {
139
+ header: "ACTIVE",
140
+ key: "configId",
141
+ format: (v) => v === result.activeConfigId ? chalk.green("Yes") : "-",
142
+ },
143
+ { header: "CONTENT HASH", key: "contentHash", format: formatId },
144
+ ]));
145
+ }
146
+ }
147
+ catch (err) {
148
+ error(err.message);
149
+ process.exit(1);
150
+ }
151
+ });
152
+ // ============================================
153
+ // CONFIGS (VERSIONS) SUBCOMMAND
154
+ // ============================================
155
+ const configs = scripts
156
+ .command("configs")
157
+ .description("Inspect a script's versioned configs");
158
+ configs
159
+ .command("list")
160
+ .description("List a script's versions (configs)")
161
+ .argument("<script>", "Script ID or name")
162
+ .option("--app <app-id>", "App ID (uses current app if not specified)")
163
+ .option("--json", "Output as JSON")
164
+ .action(async (script, options) => {
165
+ const resolvedAppId = resolveAppId(undefined, options);
166
+ const client = new ApiClient();
167
+ try {
168
+ const scriptId = await resolveScriptId(client, resolvedAppId, script);
169
+ const header = await client.getScript(resolvedAppId, scriptId);
170
+ const { items } = await client.listScriptConfigs(resolvedAppId, scriptId);
171
+ if (options.json) {
172
+ json(items);
173
+ return;
174
+ }
175
+ if (!items || items.length === 0) {
176
+ info("No versions found.");
177
+ return;
178
+ }
179
+ console.log(formatTable(items, [
180
+ { header: "CONFIG ID", key: "configId", format: formatId },
181
+ { header: "NAME", key: "configName" },
182
+ { header: "STATUS", key: "status" },
183
+ {
184
+ header: "ACTIVE",
185
+ key: "configId",
186
+ format: (v) => v === header.activeConfigId ? chalk.green("Yes") : "-",
187
+ },
188
+ { header: "CONTENT HASH", key: "contentHash", format: formatId },
189
+ { header: "CREATED", key: "createdAt", format: formatDate },
190
+ ]));
191
+ }
192
+ catch (err) {
193
+ error(err.message);
194
+ process.exit(1);
195
+ }
196
+ });
197
+ // Get one version. `list` says which versions exist; this says what one of
198
+ // them holds — the body the server would run. A transform is authored as
199
+ // `transforms/<name>.rhai` and applied by `sync push`, so this is the read
200
+ // that answers "is what is running what I committed?" for a single version.
201
+ configs
202
+ .command("get")
203
+ .description("Show one version (config) of a script as the server has it")
204
+ .argument("<script>", "Script ID or name")
205
+ .argument("<config>", "Config ID or name")
206
+ .option("--app <app-id>", "App ID (uses current app if not specified)")
207
+ .option("--json", "Output as JSON")
208
+ .action(async (script, config, options) => {
209
+ const resolvedAppId = resolveAppId(undefined, options);
210
+ const client = new ApiClient();
211
+ try {
212
+ const scriptId = await resolveScriptId(client, resolvedAppId, script);
213
+ const header = await client.getScript(resolvedAppId, scriptId);
214
+ const { items } = await client.listScriptConfigs(resolvedAppId, scriptId);
215
+ const found = (items ?? []).find((c) => c.configId === config || c.configName === config);
216
+ if (!found) {
217
+ error(`Script '${script}' has no version '${config}'. Run 'primitive scripts configs list ${script}' to see them.`);
218
+ process.exit(1);
219
+ }
220
+ if (options.json) {
221
+ json(found);
222
+ return;
223
+ }
224
+ keyValue("Config ID", found.configId);
225
+ keyValue("Name", found.configName);
226
+ keyValue("Status", found.status);
227
+ keyValue("Active", found.configId === header.activeConfigId ? "Yes" : "No");
228
+ if (found.contentHash)
229
+ keyValue("Content Hash", found.contentHash);
230
+ if (found.createdAt)
231
+ keyValue("Created", formatDate(found.createdAt));
232
+ if (typeof found.body === "string") {
233
+ divider();
234
+ info("Body:");
235
+ console.log(found.body);
236
+ }
237
+ }
238
+ catch (err) {
239
+ error(err.message);
240
+ process.exit(1);
241
+ }
242
+ });
243
+ // ============================================
244
+ // TESTS SUBCOMMAND — script block testing (blockType "script")
245
+ // ============================================
246
+ const tests = scripts
247
+ .command("tests")
248
+ .description("Manage and run script test cases")
249
+ .addHelpText("after", `
250
+ Test modes:
251
+ Active version — omit --config; runs against the script's active config.
252
+ Pinned version — pass --config <config-id> to run a specific version.
253
+
254
+ Examples:
255
+ $ primitive scripts tests list my-transform
256
+ $ primitive scripts tests create my-transform --name "Basic" --vars '{"x":1}'
257
+ $ primitive scripts tests run my-transform <test-case-id>
258
+ $ primitive scripts tests run my-transform <test-case-id> --config <config-id>
259
+ $ primitive scripts tests run-all my-transform
260
+ $ primitive scripts tests runs my-transform
261
+ `);
262
+ // List test cases
263
+ tests
264
+ .command("list")
265
+ .description("List test cases for a script")
266
+ .argument("<script>", "Script ID or name")
267
+ .option("--app <app-id>", "App ID (uses current app if not specified)")
268
+ .option("--json", "Output as JSON")
269
+ .action(async (script, options) => {
270
+ const resolvedAppId = resolveAppId(undefined, options);
271
+ const client = new ApiClient();
272
+ try {
273
+ const scriptId = await resolveScriptId(client, resolvedAppId, script);
274
+ const { items } = await client.listTestCases(resolvedAppId, "script", scriptId);
275
+ if (options.json) {
276
+ json(items);
277
+ return;
278
+ }
279
+ if (!items || items.length === 0) {
280
+ info("No test cases found.");
281
+ return;
282
+ }
283
+ console.log(formatTable(items, [
284
+ { header: "ID", key: "testCaseId", format: formatId },
285
+ { header: "NAME", key: "name" },
286
+ {
287
+ header: "CONFIG",
288
+ key: "configId",
289
+ format: (v) => (v ? formatId(v) : "-"),
290
+ },
291
+ { header: "CREATED", key: "createdAt", format: formatDate },
292
+ ]));
293
+ }
294
+ catch (err) {
295
+ error(err.message);
296
+ process.exit(1);
297
+ }
298
+ });
299
+ // Create test case
300
+ tests
301
+ .command("create")
302
+ .description("Create a test case for a script")
303
+ .argument("<script>", "Script ID or name")
304
+ .option("--app <app-id>", "App ID (uses current app if not specified)")
305
+ .option("--name <name>", "Test case name (required)")
306
+ .option("--vars <json>", "Input variables as JSON (required)")
307
+ .option("--pattern <regex>", "Expected output pattern (regex)")
308
+ .option("--contains <json>", "Expected strings to contain (JSON array)")
309
+ .option("--json-subset <json>", "Expected JSON subset to match")
310
+ .option("--config <config-id>", "Config ID to pin this test to a version")
311
+ .option("--json", "Output as JSON")
312
+ .action(async (script, options) => {
313
+ const resolvedAppId = resolveAppId(undefined, options);
314
+ if (!options.name || !options.vars) {
315
+ error("Required: --name and --vars");
316
+ process.exit(1);
317
+ }
318
+ let inputVariables;
319
+ try {
320
+ inputVariables = JSON.parse(options.vars);
321
+ }
322
+ catch {
323
+ error("Invalid JSON in --vars");
324
+ process.exit(1);
325
+ }
326
+ let expectedOutputContains;
327
+ if (options.contains) {
328
+ try {
329
+ expectedOutputContains = JSON.parse(options.contains);
330
+ }
331
+ catch {
332
+ error("Invalid JSON in --contains");
333
+ process.exit(1);
334
+ }
335
+ }
336
+ let expectedJsonSubset;
337
+ if (options.jsonSubset) {
338
+ try {
339
+ expectedJsonSubset = JSON.parse(options.jsonSubset);
340
+ }
341
+ catch {
342
+ error("Invalid JSON in --json-subset");
343
+ process.exit(1);
344
+ }
345
+ }
346
+ const client = new ApiClient();
347
+ try {
348
+ const scriptId = await resolveScriptId(client, resolvedAppId, script);
349
+ const result = await client.createTestCase(resolvedAppId, "script", scriptId, {
350
+ name: options.name,
351
+ inputVariables,
352
+ expectedOutputPattern: options.pattern,
353
+ expectedOutputContains,
354
+ expectedJsonSubset,
355
+ configId: options.config,
356
+ });
357
+ if (options.json) {
358
+ json(result);
359
+ return;
360
+ }
361
+ success(`Test case created: ${result.name}`);
362
+ keyValue("Test Case ID", result.testCaseId);
363
+ }
364
+ catch (err) {
365
+ error(err.message);
366
+ process.exit(1);
367
+ }
368
+ });
369
+ // Get test case
370
+ tests
371
+ .command("get")
372
+ .description("Get test case details")
373
+ .argument("<script>", "Script ID or name")
374
+ .argument("<test-case-id>", "Test Case ID")
375
+ .option("--app <app-id>", "App ID (uses current app if not specified)")
376
+ .option("--json", "Output as JSON")
377
+ .action(async (script, testCaseId, options) => {
378
+ const resolvedAppId = resolveAppId(undefined, options);
379
+ const client = new ApiClient();
380
+ try {
381
+ const scriptId = await resolveScriptId(client, resolvedAppId, script);
382
+ const result = await client.getTestCase(resolvedAppId, "script", scriptId, testCaseId);
383
+ if (options.json) {
384
+ json(result);
385
+ return;
386
+ }
387
+ printResult("Test Case ID", result.testCaseId);
388
+ printResult("Name", result.name);
389
+ printResult("Config ID", result.configId || "-");
390
+ printResult("Created", formatDate(result.createdAt));
391
+ divider();
392
+ info("Input Variables:");
393
+ try {
394
+ console.log(JSON.stringify(JSON.parse(result.inputVariables || "{}"), null, 2));
395
+ }
396
+ catch {
397
+ console.log(result.inputVariables || "{}");
398
+ }
399
+ if (result.expectedOutputPattern) {
400
+ divider();
401
+ printResult("Expected Pattern", result.expectedOutputPattern);
402
+ }
403
+ if (result.expectedOutputContains) {
404
+ divider();
405
+ info("Expected Contains:");
406
+ try {
407
+ console.log(JSON.stringify(JSON.parse(result.expectedOutputContains), null, 2));
408
+ }
409
+ catch {
410
+ console.log(result.expectedOutputContains);
411
+ }
412
+ }
413
+ if (result.expectedJsonSubset) {
414
+ divider();
415
+ info("Expected JSON Subset:");
416
+ try {
417
+ console.log(JSON.stringify(JSON.parse(result.expectedJsonSubset), null, 2));
418
+ }
419
+ catch {
420
+ console.log(result.expectedJsonSubset);
421
+ }
422
+ }
423
+ }
424
+ catch (err) {
425
+ error(err.message);
426
+ process.exit(1);
427
+ }
428
+ });
429
+ // Update test case
430
+ tests
431
+ .command("update")
432
+ .description("Update a test case")
433
+ .argument("<script>", "Script ID or name")
434
+ .argument("<test-case-id>", "Test Case ID")
435
+ .option("--app <app-id>", "App ID (uses current app if not specified)")
436
+ .option("--name <name>", "Test case name")
437
+ .option("--vars <json>", "Input variables as JSON")
438
+ .option("--pattern <regex>", "Expected output pattern (regex)")
439
+ .option("--contains <json>", "Expected strings to contain (JSON array)")
440
+ .option("--json-subset <json>", "Expected JSON subset to match")
441
+ .option("--config <config-id>", "Config ID to pin this test to a version")
442
+ .option("--clear-pattern", "Clear expected pattern")
443
+ .option("--clear-contains", "Clear expected contains")
444
+ .option("--clear-json-subset", "Clear expected JSON subset")
445
+ .option("--json", "Output as JSON")
446
+ .action(async (script, testCaseId, options) => {
447
+ const resolvedAppId = resolveAppId(undefined, options);
448
+ const payload = {};
449
+ if (options.name)
450
+ payload.name = options.name;
451
+ if (options.vars) {
452
+ try {
453
+ payload.inputVariables = JSON.parse(options.vars);
454
+ }
455
+ catch {
456
+ error("Invalid JSON in --vars");
457
+ process.exit(1);
458
+ }
459
+ }
460
+ if (options.clearPattern) {
461
+ payload.expectedOutputPattern = null;
462
+ }
463
+ else if (options.pattern) {
464
+ payload.expectedOutputPattern = options.pattern;
465
+ }
466
+ if (options.clearContains) {
467
+ payload.expectedOutputContains = null;
468
+ }
469
+ else if (options.contains) {
470
+ try {
471
+ payload.expectedOutputContains = JSON.parse(options.contains);
472
+ }
473
+ catch {
474
+ error("Invalid JSON in --contains");
475
+ process.exit(1);
476
+ }
477
+ }
478
+ if (options.clearJsonSubset) {
479
+ payload.expectedJsonSubset = null;
480
+ }
481
+ else if (options.jsonSubset) {
482
+ try {
483
+ payload.expectedJsonSubset = JSON.parse(options.jsonSubset);
484
+ }
485
+ catch {
486
+ error("Invalid JSON in --json-subset");
487
+ process.exit(1);
488
+ }
489
+ }
490
+ if (options.config)
491
+ payload.configId = options.config;
492
+ if (Object.keys(payload).length === 0) {
493
+ error("No update options specified.");
494
+ process.exit(1);
495
+ }
496
+ const client = new ApiClient();
497
+ try {
498
+ const scriptId = await resolveScriptId(client, resolvedAppId, script);
499
+ const result = await client.updateTestCase(resolvedAppId, "script", scriptId, testCaseId, payload);
500
+ if (options.json) {
501
+ json(result);
502
+ return;
503
+ }
504
+ success("Test case updated.");
505
+ }
506
+ catch (err) {
507
+ error(err.message);
508
+ process.exit(1);
509
+ }
510
+ });
511
+ // Delete test case
512
+ tests
513
+ .command("delete")
514
+ .description("Delete a test case")
515
+ .argument("<script>", "Script ID or name")
516
+ .argument("<test-case-id>", "Test Case ID")
517
+ .option("--app <app-id>", "App ID (uses current app if not specified)")
518
+ .option("-y, --yes", "Skip confirmation prompt")
519
+ .action(async (script, testCaseId, options) => {
520
+ const resolvedAppId = resolveAppId(undefined, options);
521
+ if (!options.yes) {
522
+ let confirm;
523
+ try {
524
+ confirm = await confirmPrompt(`Are you sure you want to delete test case ${testCaseId}?`);
525
+ }
526
+ catch (err) {
527
+ error(err.message);
528
+ process.exit(1);
529
+ }
530
+ if (!confirm) {
531
+ info("Cancelled.");
532
+ return;
533
+ }
534
+ }
535
+ const client = new ApiClient();
536
+ try {
537
+ const scriptId = await resolveScriptId(client, resolvedAppId, script);
538
+ await client.deleteTestCase(resolvedAppId, "script", scriptId, testCaseId);
539
+ success("Test case deleted.");
540
+ }
541
+ catch (err) {
542
+ error(err.message);
543
+ process.exit(1);
544
+ }
545
+ });
546
+ // Run a single test case
547
+ tests
548
+ .command("run")
549
+ .description("Run a single test case")
550
+ .argument("<script>", "Script ID or name")
551
+ .argument("<test-case-id>", "Test Case ID")
552
+ .option("--app <app-id>", "App ID (uses current app if not specified)")
553
+ .option("--config <config-id>", "Pin to a specific version (defaults to the test case's config, else the active version)")
554
+ .option("--json", "Output as JSON")
555
+ .action(async (script, testCaseId, options) => {
556
+ const resolvedAppId = resolveAppId(undefined, options);
557
+ const client = new ApiClient();
558
+ try {
559
+ const scriptId = await resolveScriptId(client, resolvedAppId, script);
560
+ const testCase = await client.getTestCase(resolvedAppId, "script", scriptId, testCaseId);
561
+ let variables = {};
562
+ try {
563
+ variables = JSON.parse(testCase.inputVariables || "{}");
564
+ }
565
+ catch {
566
+ // Use empty object if parsing fails
567
+ }
568
+ const result = await client.executeBlockTest(resolvedAppId, "script", scriptId, {
569
+ variables,
570
+ testCaseId,
571
+ configId: options.config || testCase.configId,
572
+ });
573
+ if (options.json) {
574
+ json(result);
575
+ return;
576
+ }
577
+ const passed = result.verification?.passed;
578
+ if (passed) {
579
+ success("Test PASSED");
580
+ }
581
+ else {
582
+ error("Test FAILED");
583
+ }
584
+ keyValue("Duration", formatDuration(result.metrics?.durationMs));
585
+ if (result.verification) {
586
+ divider();
587
+ info("Verification:");
588
+ const v = result.verification;
589
+ keyValue(" Passed", v.passed ? chalk.green("Yes") : chalk.red("No"));
590
+ if (v.summary) {
591
+ keyValue(" Checks", `${v.summary?.passed || 0}/${v.summary?.total || 0} passed`);
592
+ }
593
+ if (v.checks && v.checks.length > 0) {
594
+ console.log();
595
+ for (const check of v.checks) {
596
+ const icon = check.passed ? chalk.green("✓") : chalk.red("✗");
597
+ console.log(` ${icon} ${check.name}`);
598
+ if (!check.passed && check.message) {
599
+ console.log(` ${chalk.dim(check.message)}`);
600
+ }
601
+ }
602
+ }
603
+ }
604
+ if (result.output) {
605
+ divider();
606
+ info("Output:");
607
+ console.log(result.output);
608
+ }
609
+ if (result.error) {
610
+ divider();
611
+ error(`Error: ${result.error}`);
612
+ }
613
+ }
614
+ catch (err) {
615
+ error(err.message);
616
+ process.exit(1);
617
+ }
618
+ });
619
+ // Run all test cases
620
+ tests
621
+ .command("run-all")
622
+ .description("Run all test cases for a script, or a specific subset")
623
+ .argument("<script>", "Script ID or name")
624
+ .option("--app <app-id>", "App ID (uses current app if not specified)")
625
+ .option("--config <config-id>", "Override config ID for all tests (pin to a version)")
626
+ .option("--test-cases <ids>", "Comma-separated list of test case IDs to run (runs only these)")
627
+ .option("--json", "Output as JSON")
628
+ .action(async (script, options) => {
629
+ const resolvedAppId = resolveAppId(undefined, options);
630
+ const client = new ApiClient();
631
+ try {
632
+ let testCaseIds;
633
+ if (options.testCases) {
634
+ testCaseIds = options.testCases
635
+ .split(",")
636
+ .map((id) => id.trim())
637
+ .filter(Boolean);
638
+ if (testCaseIds.length === 0) {
639
+ error("No valid test case IDs provided in --test-cases");
640
+ process.exit(1);
641
+ }
642
+ }
643
+ const scriptId = await resolveScriptId(client, resolvedAppId, script);
644
+ if (!options.json) {
645
+ if (testCaseIds) {
646
+ info(`Running ${testCaseIds.length} selected test case(s)...`);
647
+ }
648
+ else {
649
+ info("Running all test cases...");
650
+ }
651
+ }
652
+ const result = await client.runAllTestCases(resolvedAppId, "script", scriptId, {
653
+ overrideConfigId: options.config,
654
+ testCaseIds,
655
+ });
656
+ if (options.json) {
657
+ json(result);
658
+ return;
659
+ }
660
+ const { summary, runs, comparisonGroup } = result;
661
+ divider();
662
+ keyValue("Comparison Group", comparisonGroup);
663
+ keyValue("Total Tests", summary.total);
664
+ keyValue("Passed", chalk.green(summary.passed));
665
+ keyValue("Failed", summary.failed > 0 ? chalk.red(summary.failed) : "0");
666
+ divider();
667
+ if (runs && runs.length > 0) {
668
+ for (const r of runs) {
669
+ const passed = r.verification?.passed;
670
+ const icon = passed ? chalk.green("✓") : chalk.red("✗");
671
+ const status = passed ? "PASSED" : "FAILED";
672
+ console.log(`${icon} ${r.testCaseName} - ${status}`);
673
+ if (!passed && r.verification?.details?.reason) {
674
+ console.log(` ${chalk.dim(r.verification.details.reason)}`);
675
+ }
676
+ }
677
+ }
678
+ if (summary.failed > 0) {
679
+ process.exit(1);
680
+ }
681
+ }
682
+ catch (err) {
683
+ error(err.message);
684
+ process.exit(1);
685
+ }
686
+ });
687
+ // List test runs
688
+ tests
689
+ .command("runs")
690
+ .description("List recent test runs for a script")
691
+ .argument("<script>", "Script ID or name")
692
+ .option("--app <app-id>", "App ID (uses current app if not specified)")
693
+ .option("--limit <n>", "Maximum number of runs to show", "20")
694
+ .option("--group <group>", "Filter by comparison group")
695
+ .option("--json", "Output as JSON")
696
+ .action(async (script, options) => {
697
+ const resolvedAppId = resolveAppId(undefined, options);
698
+ const client = new ApiClient();
699
+ try {
700
+ const scriptId = await resolveScriptId(client, resolvedAppId, script);
701
+ const { items } = await client.listTestRuns(resolvedAppId, "script", scriptId, {
702
+ limit: parseInt(options.limit),
703
+ comparisonGroup: options.group,
704
+ });
705
+ if (options.json) {
706
+ json(items);
707
+ return;
708
+ }
709
+ if (!items || items.length === 0) {
710
+ info("No test runs found.");
711
+ return;
712
+ }
713
+ console.log(formatTable(items, [
714
+ { header: "RUN ID", key: "runId", format: formatId },
715
+ {
716
+ header: "TEST CASE ID",
717
+ key: "testCaseId",
718
+ format: (v) => (v ? formatId(v) : "-"),
719
+ },
720
+ {
721
+ header: "PASSED",
722
+ key: "verificationPassed",
723
+ format: (v) => v === true
724
+ ? chalk.green("Yes")
725
+ : v === false
726
+ ? chalk.red("No")
727
+ : "-",
728
+ },
729
+ { header: "DURATION", key: "durationMs", format: formatDuration },
730
+ { header: "STARTED", key: "startedAt", format: formatDate },
731
+ ]));
732
+ }
733
+ catch (err) {
734
+ error(err.message);
735
+ process.exit(1);
736
+ }
737
+ });
738
+ }
739
+ //# sourceMappingURL=scripts.js.map