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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (438) hide show
  1. package/README.md +404 -80
  2. package/assets/skill/skills/primitive-platform/SKILL.md +808 -0
  3. package/dist/bin/primitive.d.ts +2 -0
  4. package/dist/bin/primitive.js +294 -21
  5. package/dist/bin/primitive.js.map +1 -1
  6. package/dist/src/commands/admins.d.ts +2 -0
  7. package/dist/src/commands/admins.js +138 -19
  8. package/dist/src/commands/admins.js.map +1 -1
  9. package/dist/src/commands/analytics.d.ts +2 -0
  10. package/dist/src/commands/analytics.js +544 -55
  11. package/dist/src/commands/analytics.js.map +1 -1
  12. package/dist/src/commands/apps.d.ts +2 -0
  13. package/dist/src/commands/apps.js +51 -96
  14. package/dist/src/commands/apps.js.map +1 -1
  15. package/dist/src/commands/auth.d.ts +2 -0
  16. package/dist/src/commands/auth.js +177 -7
  17. package/dist/src/commands/auth.js.map +1 -1
  18. package/dist/src/commands/blob-buckets.d.ts +2 -0
  19. package/dist/src/commands/blob-buckets.js +330 -0
  20. package/dist/src/commands/blob-buckets.js.map +1 -0
  21. package/dist/src/commands/catalog.d.ts +2 -0
  22. package/dist/src/commands/catalog.js +37 -38
  23. package/dist/src/commands/catalog.js.map +1 -1
  24. package/dist/src/commands/collection-type-configs.d.ts +2 -0
  25. package/dist/src/commands/collection-type-configs.js +92 -0
  26. package/dist/src/commands/collection-type-configs.js.map +1 -0
  27. package/dist/src/commands/collections.d.ts +2 -0
  28. package/dist/src/commands/collections.js +565 -0
  29. package/dist/src/commands/collections.js.map +1 -0
  30. package/dist/src/commands/comparisons.d.ts +2 -0
  31. package/dist/src/commands/comparisons.js +6 -6
  32. package/dist/src/commands/comparisons.js.map +1 -1
  33. package/dist/src/commands/config.d.ts +46 -0
  34. package/dist/src/commands/config.js +479 -0
  35. package/dist/src/commands/config.js.map +1 -0
  36. package/dist/src/commands/connections.d.ts +2 -0
  37. package/dist/src/commands/connections.js +100 -0
  38. package/dist/src/commands/connections.js.map +1 -0
  39. package/dist/src/commands/cron-triggers.d.ts +2 -0
  40. package/dist/src/commands/cron-triggers.js +265 -0
  41. package/dist/src/commands/cron-triggers.js.map +1 -0
  42. package/dist/src/commands/database-type-configs.d.ts +2 -0
  43. package/dist/src/commands/database-type-configs.js +171 -0
  44. package/dist/src/commands/database-type-configs.js.map +1 -0
  45. package/dist/src/commands/database-types.d.ts +2 -0
  46. package/dist/src/commands/database-types.js +471 -0
  47. package/dist/src/commands/database-types.js.map +1 -0
  48. package/dist/src/commands/databases.d.ts +65 -0
  49. package/dist/src/commands/databases.js +2140 -112
  50. package/dist/src/commands/databases.js.map +1 -1
  51. package/dist/src/commands/documents.d.ts +2 -0
  52. package/dist/src/commands/documents.js +1357 -19
  53. package/dist/src/commands/documents.js.map +1 -1
  54. package/dist/src/commands/email-templates.d.ts +2 -0
  55. package/dist/src/commands/email-templates.js +174 -0
  56. package/dist/src/commands/email-templates.js.map +1 -0
  57. package/dist/src/commands/env.d.ts +23 -0
  58. package/dist/src/commands/env.js +333 -0
  59. package/dist/src/commands/env.js.map +1 -0
  60. package/dist/src/commands/feature-flags.d.ts +14 -0
  61. package/dist/src/commands/feature-flags.js +116 -0
  62. package/dist/src/commands/feature-flags.js.map +1 -0
  63. package/dist/src/commands/group-type-configs.d.ts +2 -0
  64. package/dist/src/commands/group-type-configs.js +86 -0
  65. package/dist/src/commands/group-type-configs.js.map +1 -0
  66. package/dist/src/commands/groups.d.ts +2 -0
  67. package/dist/src/commands/groups.js +38 -99
  68. package/dist/src/commands/groups.js.map +1 -1
  69. package/dist/src/commands/guides.d.ts +223 -0
  70. package/dist/src/commands/guides.js +617 -65
  71. package/dist/src/commands/guides.js.map +1 -1
  72. package/dist/src/commands/init.d.ts +25 -0
  73. package/dist/src/commands/init.js +1605 -208
  74. package/dist/src/commands/init.js.map +1 -1
  75. package/dist/src/commands/integrations.d.ts +2 -0
  76. package/dist/src/commands/integrations.js +380 -178
  77. package/dist/src/commands/integrations.js.map +1 -1
  78. package/dist/src/commands/llm.d.ts +2 -0
  79. package/dist/src/commands/llm.js +4 -2
  80. package/dist/src/commands/llm.js.map +1 -1
  81. package/dist/src/commands/locks.d.ts +8 -0
  82. package/dist/src/commands/locks.js +160 -0
  83. package/dist/src/commands/locks.js.map +1 -0
  84. package/dist/src/commands/metadata-category-configs.d.ts +12 -0
  85. package/dist/src/commands/metadata-category-configs.js +112 -0
  86. package/dist/src/commands/metadata-category-configs.js.map +1 -0
  87. package/dist/src/commands/metadata.d.ts +2 -0
  88. package/dist/src/commands/metadata.js +281 -0
  89. package/dist/src/commands/metadata.js.map +1 -0
  90. package/dist/src/commands/prompts.d.ts +2 -0
  91. package/dist/src/commands/prompts.js +225 -584
  92. package/dist/src/commands/prompts.js.map +1 -1
  93. package/dist/src/commands/rule-sets.d.ts +3 -0
  94. package/dist/src/commands/rule-sets.js +272 -0
  95. package/dist/src/commands/rule-sets.js.map +1 -0
  96. package/dist/src/commands/scripts.d.ts +20 -0
  97. package/dist/src/commands/scripts.js +554 -0
  98. package/dist/src/commands/scripts.js.map +1 -0
  99. package/dist/src/commands/secrets.d.ts +2 -0
  100. package/dist/src/commands/secrets.js +108 -0
  101. package/dist/src/commands/secrets.js.map +1 -0
  102. package/dist/src/commands/sessions.d.ts +2 -0
  103. package/dist/src/commands/sessions.js +75 -0
  104. package/dist/src/commands/sessions.js.map +1 -0
  105. package/dist/src/commands/skill.d.ts +2 -0
  106. package/dist/src/commands/skill.js +29 -0
  107. package/dist/src/commands/skill.js.map +1 -0
  108. package/dist/src/commands/sync-app-settings.d.ts +158 -0
  109. package/dist/src/commands/sync-app-settings.js +330 -0
  110. package/dist/src/commands/sync-app-settings.js.map +1 -0
  111. package/dist/src/commands/sync.d.ts +2323 -0
  112. package/dist/src/commands/sync.js +15065 -843
  113. package/dist/src/commands/sync.js.map +1 -1
  114. package/dist/src/commands/tokens.d.ts +2 -0
  115. package/dist/src/commands/tokens.js +130 -21
  116. package/dist/src/commands/tokens.js.map +1 -1
  117. package/dist/src/commands/users.d.ts +2 -0
  118. package/dist/src/commands/users.js +532 -23
  119. package/dist/src/commands/users.js.map +1 -1
  120. package/dist/src/commands/vars.d.ts +8 -0
  121. package/dist/src/commands/vars.js +96 -0
  122. package/dist/src/commands/vars.js.map +1 -0
  123. package/dist/src/commands/waitlist.d.ts +2 -0
  124. package/dist/src/commands/waitlist.js +10 -10
  125. package/dist/src/commands/waitlist.js.map +1 -1
  126. package/dist/src/commands/webhooks.d.ts +2 -0
  127. package/dist/src/commands/webhooks.js +562 -0
  128. package/dist/src/commands/webhooks.js.map +1 -0
  129. package/dist/src/commands/workflows.d.ts +116 -0
  130. package/dist/src/commands/workflows.js +1583 -681
  131. package/dist/src/commands/workflows.js.map +1 -1
  132. package/dist/src/lib/access-rule-display.d.ts +21 -0
  133. package/dist/src/lib/access-rule-display.js +34 -0
  134. package/dist/src/lib/access-rule-display.js.map +1 -0
  135. package/dist/src/lib/api-client.d.ts +1936 -0
  136. package/dist/src/lib/api-client.js +1826 -138
  137. package/dist/src/lib/api-client.js.map +1 -1
  138. package/dist/src/lib/app-settings-descriptor.d.ts +263 -0
  139. package/dist/src/lib/app-settings-descriptor.js +575 -0
  140. package/dist/src/lib/app-settings-descriptor.js.map +1 -0
  141. package/dist/src/lib/auth-flow.d.ts +8 -0
  142. package/dist/src/lib/batch.d.ts +26 -0
  143. package/dist/src/lib/batch.js +32 -0
  144. package/dist/src/lib/batch.js.map +1 -0
  145. package/dist/src/lib/block-layout.d.ts +160 -0
  146. package/dist/src/lib/block-layout.js +451 -0
  147. package/dist/src/lib/block-layout.js.map +1 -0
  148. package/dist/src/lib/canonical-json.d.ts +12 -0
  149. package/dist/src/lib/canonical-json.js +35 -0
  150. package/dist/src/lib/canonical-json.js.map +1 -0
  151. package/dist/src/lib/channel.d.ts +30 -0
  152. package/dist/src/lib/channel.js +68 -0
  153. package/dist/src/lib/channel.js.map +1 -0
  154. package/dist/src/lib/cli-manifest.d.ts +68 -0
  155. package/dist/src/lib/cli-manifest.js +71 -0
  156. package/dist/src/lib/cli-manifest.js.map +1 -0
  157. package/dist/src/lib/codegen-shared/generatedFiles.d.ts +101 -0
  158. package/dist/src/lib/codegen-shared/generatedFiles.js +191 -0
  159. package/dist/src/lib/codegen-shared/generatedFiles.js.map +1 -0
  160. package/dist/src/lib/codegen-shared/prettierStable.d.ts +262 -0
  161. package/dist/src/lib/codegen-shared/prettierStable.js +610 -0
  162. package/dist/src/lib/codegen-shared/prettierStable.js.map +1 -0
  163. package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.d.ts +68 -0
  164. package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.js +168 -0
  165. package/dist/src/lib/codegen-shared/resolveCodegenSourceDir.js.map +1 -0
  166. package/dist/src/lib/config-object-descriptor.d.ts +127 -0
  167. package/dist/src/lib/config-object-descriptor.js +658 -0
  168. package/dist/src/lib/config-object-descriptor.js.map +1 -0
  169. package/dist/src/lib/config-payload.d.ts +85 -0
  170. package/dist/src/lib/config-payload.js +116 -0
  171. package/dist/src/lib/config-payload.js.map +1 -0
  172. package/dist/src/lib/config-surface.d.ts +130 -0
  173. package/dist/src/lib/config-surface.js +300 -0
  174. package/dist/src/lib/config-surface.js.map +1 -0
  175. package/dist/src/lib/config-toml.d.ts +10 -0
  176. package/dist/src/lib/config-toml.js +42 -0
  177. package/dist/src/lib/config-toml.js.map +1 -0
  178. package/dist/src/lib/config.d.ts +53 -0
  179. package/dist/src/lib/config.js +92 -53
  180. package/dist/src/lib/config.js.map +1 -1
  181. package/dist/src/lib/confirm-prompt.d.ts +83 -0
  182. package/dist/src/lib/confirm-prompt.js +110 -0
  183. package/dist/src/lib/confirm-prompt.js.map +1 -0
  184. package/dist/src/lib/constants.d.ts +11 -0
  185. package/dist/src/lib/constants.js +12 -0
  186. package/dist/src/lib/constants.js.map +1 -0
  187. package/dist/src/lib/crash-handlers.d.ts +20 -0
  188. package/dist/src/lib/crash-handlers.js +49 -0
  189. package/dist/src/lib/crash-handlers.js.map +1 -0
  190. package/dist/src/lib/credentials-store.d.ts +89 -0
  191. package/dist/src/lib/credentials-store.js +330 -0
  192. package/dist/src/lib/credentials-store.js.map +1 -0
  193. package/dist/src/lib/csv.d.ts +47 -0
  194. package/dist/src/lib/csv.js +172 -0
  195. package/dist/src/lib/csv.js.map +1 -0
  196. package/dist/src/lib/data-input.d.ts +23 -0
  197. package/dist/src/lib/data-input.js +50 -0
  198. package/dist/src/lib/data-input.js.map +1 -0
  199. package/dist/src/lib/db-codegen/dbFingerprint.d.ts +10 -0
  200. package/dist/src/lib/db-codegen/dbFingerprint.js +17 -0
  201. package/dist/src/lib/db-codegen/dbFingerprint.js.map +1 -0
  202. package/dist/src/lib/db-codegen/dbGenerator.d.ts +67 -0
  203. package/dist/src/lib/db-codegen/dbGenerator.js +170 -0
  204. package/dist/src/lib/db-codegen/dbGenerator.js.map +1 -0
  205. package/dist/src/lib/db-codegen/dbNaming.d.ts +87 -0
  206. package/dist/src/lib/db-codegen/dbNaming.js +180 -0
  207. package/dist/src/lib/db-codegen/dbNaming.js.map +1 -0
  208. package/dist/src/lib/db-codegen/dbTemplates.d.ts +272 -0
  209. package/dist/src/lib/db-codegen/dbTemplates.js +480 -0
  210. package/dist/src/lib/db-codegen/dbTemplates.js.map +1 -0
  211. package/dist/src/lib/db-codegen/dbTsTypes.d.ts +73 -0
  212. package/dist/src/lib/db-codegen/dbTsTypes.js +139 -0
  213. package/dist/src/lib/db-codegen/dbTsTypes.js.map +1 -0
  214. package/dist/src/lib/db-codegen/dbTypeIR.d.ts +146 -0
  215. package/dist/src/lib/db-codegen/dbTypeIR.js +517 -0
  216. package/dist/src/lib/db-codegen/dbTypeIR.js.map +1 -0
  217. package/dist/src/lib/db-codegen/generated-operation-def-descriptor.d.ts +112 -0
  218. package/dist/src/lib/db-codegen/generated-operation-def-descriptor.js +211 -0
  219. package/dist/src/lib/db-codegen/generated-operation-def-descriptor.js.map +1 -0
  220. package/dist/src/lib/env-resolver-core.d.ts +147 -0
  221. package/dist/src/lib/env-resolver-core.js +265 -0
  222. package/dist/src/lib/env-resolver-core.js.map +1 -0
  223. package/dist/src/lib/env-resolver.d.ts +84 -0
  224. package/dist/src/lib/env-resolver.js +133 -0
  225. package/dist/src/lib/env-resolver.js.map +1 -0
  226. package/dist/src/lib/fetch.d.ts +5 -0
  227. package/dist/src/lib/generated-allowlist.d.ts +28 -0
  228. package/dist/src/lib/generated-allowlist.js +277 -0
  229. package/dist/src/lib/generated-allowlist.js.map +1 -0
  230. package/dist/src/lib/generated-config-surfaces.d.ts +682 -0
  231. package/dist/src/lib/generated-config-surfaces.js +4058 -0
  232. package/dist/src/lib/generated-config-surfaces.js.map +1 -0
  233. package/dist/src/lib/generated-template-lint.d.ts +212 -0
  234. package/dist/src/lib/generated-template-lint.js +624 -0
  235. package/dist/src/lib/generated-template-lint.js.map +1 -0
  236. package/dist/src/lib/init-adopt.d.ts +16 -0
  237. package/dist/src/lib/init-adopt.js +34 -0
  238. package/dist/src/lib/init-adopt.js.map +1 -0
  239. package/dist/src/lib/init-assets.d.ts +39 -0
  240. package/dist/src/lib/init-assets.js +97 -0
  241. package/dist/src/lib/init-assets.js.map +1 -0
  242. package/dist/src/lib/init-config.d.ts +98 -0
  243. package/dist/src/lib/init-config.js +186 -0
  244. package/dist/src/lib/init-config.js.map +1 -0
  245. package/dist/src/lib/init-ios-links.d.ts +50 -0
  246. package/dist/src/lib/init-ios-links.js +153 -0
  247. package/dist/src/lib/init-ios-links.js.map +1 -0
  248. package/dist/src/lib/init-plan.d.ts +80 -0
  249. package/dist/src/lib/init-plan.js +95 -0
  250. package/dist/src/lib/init-plan.js.map +1 -0
  251. package/dist/src/lib/init-production-env.d.ts +48 -0
  252. package/dist/src/lib/init-production-env.js +59 -0
  253. package/dist/src/lib/init-production-env.js.map +1 -0
  254. package/dist/src/lib/init-schema.d.ts +74 -0
  255. package/dist/src/lib/init-schema.js +358 -0
  256. package/dist/src/lib/init-schema.js.map +1 -0
  257. package/dist/src/lib/init-xcode.d.ts +33 -0
  258. package/dist/src/lib/init-xcode.js +114 -0
  259. package/dist/src/lib/init-xcode.js.map +1 -0
  260. package/dist/src/lib/integration-request-config.d.ts +30 -0
  261. package/dist/src/lib/integration-request-config.js +145 -0
  262. package/dist/src/lib/integration-request-config.js.map +1 -0
  263. package/dist/src/lib/local-state.d.ts +55 -0
  264. package/dist/src/lib/local-state.js +167 -0
  265. package/dist/src/lib/local-state.js.map +1 -0
  266. package/dist/src/lib/log-inspection.d.ts +568 -0
  267. package/dist/src/lib/log-inspection.js +639 -0
  268. package/dist/src/lib/log-inspection.js.map +1 -0
  269. package/dist/src/lib/migration-nag.d.ts +49 -0
  270. package/dist/src/lib/migration-nag.js +163 -0
  271. package/dist/src/lib/migration-nag.js.map +1 -0
  272. package/dist/src/lib/object-status-filter.d.ts +22 -0
  273. package/dist/src/lib/object-status-filter.js +45 -0
  274. package/dist/src/lib/object-status-filter.js.map +1 -0
  275. package/dist/src/lib/output.d.ts +109 -0
  276. package/dist/src/lib/output.js +191 -8
  277. package/dist/src/lib/output.js.map +1 -1
  278. package/dist/src/lib/package-manager.d.ts +140 -0
  279. package/dist/src/lib/package-manager.js +305 -0
  280. package/dist/src/lib/package-manager.js.map +1 -0
  281. package/dist/src/lib/paginate.d.ts +83 -0
  282. package/dist/src/lib/paginate.js +95 -0
  283. package/dist/src/lib/paginate.js.map +1 -0
  284. package/dist/src/lib/platform-owned.d.ts +63 -0
  285. package/dist/src/lib/platform-owned.js +85 -0
  286. package/dist/src/lib/platform-owned.js.map +1 -0
  287. package/dist/src/lib/project-config.d.ts +97 -0
  288. package/dist/src/lib/project-config.js +217 -0
  289. package/dist/src/lib/project-config.js.map +1 -0
  290. package/dist/src/lib/query-operators.d.ts +43 -0
  291. package/dist/src/lib/query-operators.js +80 -0
  292. package/dist/src/lib/query-operators.js.map +1 -0
  293. package/dist/src/lib/record-filter.d.ts +18 -0
  294. package/dist/src/lib/record-filter.js +55 -0
  295. package/dist/src/lib/record-filter.js.map +1 -0
  296. package/dist/src/lib/refresh-admin-credentials.d.ts +65 -0
  297. package/dist/src/lib/refresh-admin-credentials.js +103 -0
  298. package/dist/src/lib/refresh-admin-credentials.js.map +1 -0
  299. package/dist/src/lib/resolve-init-dev-port.d.ts +56 -0
  300. package/dist/src/lib/resolve-init-dev-port.js +55 -0
  301. package/dist/src/lib/resolve-init-dev-port.js.map +1 -0
  302. package/dist/src/lib/resolve-init-server.d.ts +64 -0
  303. package/dist/src/lib/resolve-init-server.js +77 -0
  304. package/dist/src/lib/resolve-init-server.js.map +1 -0
  305. package/dist/src/lib/resolve-platform.d.ts +74 -0
  306. package/dist/src/lib/resolve-platform.js +105 -0
  307. package/dist/src/lib/resolve-platform.js.map +1 -0
  308. package/dist/src/lib/run-status.d.ts +19 -0
  309. package/dist/src/lib/run-status.generated.d.ts +39 -0
  310. package/dist/src/lib/run-status.generated.js +66 -0
  311. package/dist/src/lib/run-status.generated.js.map +1 -0
  312. package/dist/src/lib/run-status.js +19 -0
  313. package/dist/src/lib/run-status.js.map +1 -0
  314. package/dist/src/lib/server-text-normalization.d.ts +51 -0
  315. package/dist/src/lib/server-text-normalization.js +90 -0
  316. package/dist/src/lib/server-text-normalization.js.map +1 -0
  317. package/dist/src/lib/server-url.d.ts +22 -0
  318. package/dist/src/lib/server-url.js +33 -0
  319. package/dist/src/lib/server-url.js.map +1 -0
  320. package/dist/src/lib/signing-secret-status.d.ts +81 -0
  321. package/dist/src/lib/signing-secret-status.js +116 -0
  322. package/dist/src/lib/signing-secret-status.js.map +1 -0
  323. package/dist/src/lib/skill-installer.d.ts +25 -0
  324. package/dist/src/lib/skill-installer.js +266 -0
  325. package/dist/src/lib/skill-installer.js.map +1 -0
  326. package/dist/src/lib/snapshots.d.ts +99 -0
  327. package/dist/src/lib/snapshots.js +357 -0
  328. package/dist/src/lib/snapshots.js.map +1 -0
  329. package/dist/src/lib/swift-codegen/dbGenerator.d.ts +113 -0
  330. package/dist/src/lib/swift-codegen/dbGenerator.js +914 -0
  331. package/dist/src/lib/swift-codegen/dbGenerator.js.map +1 -0
  332. package/dist/src/lib/swift-codegen/dbSwiftTypes.d.ts +42 -0
  333. package/dist/src/lib/swift-codegen/dbSwiftTypes.js +100 -0
  334. package/dist/src/lib/swift-codegen/dbSwiftTypes.js.map +1 -0
  335. package/dist/src/lib/swift-codegen/generator.d.ts +94 -0
  336. package/dist/src/lib/swift-codegen/generator.js +440 -0
  337. package/dist/src/lib/swift-codegen/generator.js.map +1 -0
  338. package/dist/src/lib/swift-codegen/schemaToSwift.d.ts +72 -0
  339. package/dist/src/lib/swift-codegen/schemaToSwift.js +644 -0
  340. package/dist/src/lib/swift-codegen/schemaToSwift.js.map +1 -0
  341. package/dist/src/lib/swift-codegen/siblingSymbols.d.ts +94 -0
  342. package/dist/src/lib/swift-codegen/siblingSymbols.js +155 -0
  343. package/dist/src/lib/swift-codegen/siblingSymbols.js.map +1 -0
  344. package/dist/src/lib/swift-codegen/swiftNaming.d.ts +85 -0
  345. package/dist/src/lib/swift-codegen/swiftNaming.js +198 -0
  346. package/dist/src/lib/swift-codegen/swiftNaming.js.map +1 -0
  347. package/dist/src/lib/sync-dir-selector.d.ts +21 -0
  348. package/dist/src/lib/sync-dir-selector.js +30 -0
  349. package/dist/src/lib/sync-dir-selector.js.map +1 -0
  350. package/dist/src/lib/sync-paths.d.ts +111 -0
  351. package/dist/src/lib/sync-paths.js +198 -0
  352. package/dist/src/lib/sync-paths.js.map +1 -0
  353. package/dist/src/lib/sync-resource-types.d.ts +544 -0
  354. package/dist/src/lib/sync-resource-types.js +975 -0
  355. package/dist/src/lib/sync-resource-types.js.map +1 -0
  356. package/dist/src/lib/sync-selectors.d.ts +95 -0
  357. package/dist/src/lib/sync-selectors.js +228 -0
  358. package/dist/src/lib/sync-selectors.js.map +1 -0
  359. package/dist/src/lib/template.d.ts +170 -0
  360. package/dist/src/lib/template.js +484 -68
  361. package/dist/src/lib/template.js.map +1 -1
  362. package/dist/src/lib/test-case-keys.d.ts +29 -0
  363. package/dist/src/lib/test-case-keys.js +55 -0
  364. package/dist/src/lib/test-case-keys.js.map +1 -0
  365. package/dist/src/lib/test-case-variables.d.ts +15 -0
  366. package/dist/src/lib/test-case-variables.js +29 -0
  367. package/dist/src/lib/test-case-variables.js.map +1 -0
  368. package/dist/src/lib/token-inject.d.ts +56 -0
  369. package/dist/src/lib/token-inject.js +204 -0
  370. package/dist/src/lib/token-inject.js.map +1 -0
  371. package/dist/src/lib/toml-database-config.d.ts +123 -0
  372. package/dist/src/lib/toml-database-config.js +527 -0
  373. package/dist/src/lib/toml-database-config.js.map +1 -0
  374. package/dist/src/lib/toml-metadata-config.d.ts +151 -0
  375. package/dist/src/lib/toml-metadata-config.js +476 -0
  376. package/dist/src/lib/toml-metadata-config.js.map +1 -0
  377. package/dist/src/lib/toml-native-form.d.ts +46 -0
  378. package/dist/src/lib/toml-native-form.js +78 -0
  379. package/dist/src/lib/toml-native-form.js.map +1 -0
  380. package/dist/src/lib/toml-params-validator.d.ts +129 -0
  381. package/dist/src/lib/toml-params-validator.js +298 -0
  382. package/dist/src/lib/toml-params-validator.js.map +1 -0
  383. package/dist/src/lib/toml-scalar-edit.d.ts +43 -0
  384. package/dist/src/lib/toml-scalar-edit.js +283 -0
  385. package/dist/src/lib/toml-scalar-edit.js.map +1 -0
  386. package/dist/src/lib/user-selector.d.ts +24 -0
  387. package/dist/src/lib/user-selector.js +33 -0
  388. package/dist/src/lib/user-selector.js.map +1 -0
  389. package/dist/src/lib/version-check.d.ts +35 -0
  390. package/dist/src/lib/version-check.js +241 -0
  391. package/dist/src/lib/version-check.js.map +1 -0
  392. package/dist/src/lib/watch.d.ts +121 -0
  393. package/dist/src/lib/watch.js +169 -0
  394. package/dist/src/lib/watch.js.map +1 -0
  395. package/dist/src/lib/workflow-apply.d.ts +110 -0
  396. package/dist/src/lib/workflow-apply.js +164 -0
  397. package/dist/src/lib/workflow-apply.js.map +1 -0
  398. package/dist/src/lib/workflow-codegen/generated-schema-descriptor.d.ts +129 -0
  399. package/dist/src/lib/workflow-codegen/generated-schema-descriptor.js +269 -0
  400. package/dist/src/lib/workflow-codegen/generated-schema-descriptor.js.map +1 -0
  401. package/dist/src/lib/workflow-codegen/generator.d.ts +96 -0
  402. package/dist/src/lib/workflow-codegen/generator.js +361 -0
  403. package/dist/src/lib/workflow-codegen/generator.js.map +1 -0
  404. package/dist/src/lib/workflow-codegen/invokerIR.d.ts +94 -0
  405. package/dist/src/lib/workflow-codegen/invokerIR.js +76 -0
  406. package/dist/src/lib/workflow-codegen/invokerIR.js.map +1 -0
  407. package/dist/src/lib/workflow-codegen/naming.d.ts +33 -0
  408. package/dist/src/lib/workflow-codegen/naming.js +81 -0
  409. package/dist/src/lib/workflow-codegen/naming.js.map +1 -0
  410. package/dist/src/lib/workflow-codegen/schemaToTs.d.ts +80 -0
  411. package/dist/src/lib/workflow-codegen/schemaToTs.js +303 -0
  412. package/dist/src/lib/workflow-codegen/schemaToTs.js.map +1 -0
  413. package/dist/src/lib/workflow-config-apply.d.ts +70 -0
  414. package/dist/src/lib/workflow-config-apply.js +137 -0
  415. package/dist/src/lib/workflow-config-apply.js.map +1 -0
  416. package/dist/src/lib/workflow-config-sidecar.d.ts +63 -0
  417. package/dist/src/lib/workflow-config-sidecar.js +96 -0
  418. package/dist/src/lib/workflow-config-sidecar.js.map +1 -0
  419. package/dist/src/lib/workflow-defaults.d.ts +29 -0
  420. package/dist/src/lib/workflow-defaults.js +41 -0
  421. package/dist/src/lib/workflow-defaults.js.map +1 -0
  422. package/dist/src/lib/workflow-fragments.d.ts +64 -0
  423. package/dist/src/lib/workflow-fragments.js +342 -0
  424. package/dist/src/lib/workflow-fragments.js.map +1 -0
  425. package/dist/src/lib/workflow-include-preserve.d.ts +76 -0
  426. package/dist/src/lib/workflow-include-preserve.js +286 -0
  427. package/dist/src/lib/workflow-include-preserve.js.map +1 -0
  428. package/dist/src/lib/workflow-payload.d.ts +98 -0
  429. package/dist/src/lib/workflow-payload.js +178 -0
  430. package/dist/src/lib/workflow-payload.js.map +1 -0
  431. package/dist/src/lib/workflow-toml-validator.d.ts +202 -0
  432. package/dist/src/lib/workflow-toml-validator.js +757 -0
  433. package/dist/src/lib/workflow-toml-validator.js.map +1 -0
  434. package/dist/src/types/index.d.ts +581 -0
  435. package/dist/src/validators.d.ts +65 -0
  436. package/dist/src/validators.js +64 -0
  437. package/dist/src/validators.js.map +1 -0
  438. package/package.json +32 -8
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Identifier-naming helpers for `workflows codegen` (issue #1442).
3
+ *
4
+ * Workflow keys resolve case-insensitively server-side and may contain
5
+ * characters that aren't valid TS identifiers (`.`, `-`). Only the emitted
6
+ * identifiers are sanitized — the runtime call always passes the ORIGINAL key
7
+ * string.
8
+ *
9
+ * Type names: `pascalCase(key) + "Input" | "Output"` (reuses `pascalCase` from
10
+ * the database codegen so the two commands share one PascalCase rule).
11
+ * Factory property: a camelCase form of the key.
12
+ */
13
+ import { pascalCase } from "../db-codegen/dbNaming.js";
14
+ /**
15
+ * Ensure an identifier is a valid TS identifier start. The server accepts
16
+ * workflow keys matching `^[a-z0-9][a-z0-9-_]{2,}$`, so a digit-leading key
17
+ * like `123-job` PascalCases to `123Job` — not a legal TS type name or
18
+ * unquoted object property, since identifiers can't start with a digit.
19
+ * Prefix an underscore in that case (`123Job` → `_123Job`). Only the emitted
20
+ * identifier changes; the runtime call still passes the ORIGINAL key string.
21
+ */
22
+ function ensureValidIdentifierStart(name) {
23
+ const first = name.charAt(0);
24
+ if (first >= "0" && first <= "9") {
25
+ return `_${name}`;
26
+ }
27
+ return name;
28
+ }
29
+ /**
30
+ * `create-checkout-session` / `createCheckoutSession` → `CreateCheckoutSession`.
31
+ * A digit-leading key (`123-job` → `_123Job`) is prefixed with `_` so the
32
+ * emitted type name is a valid TS identifier.
33
+ */
34
+ export function workflowTypeBaseName(key) {
35
+ return ensureValidIdentifierStart(pascalCase(key));
36
+ }
37
+ /** PascalCase base + `Input` (e.g. `CreateCheckoutSessionInput`). */
38
+ export function workflowInputTypeName(key) {
39
+ return `${workflowTypeBaseName(key)}Input`;
40
+ }
41
+ /** PascalCase base + `Output` (e.g. `CreateCheckoutSessionOutput`). */
42
+ export function workflowOutputTypeName(key) {
43
+ return `${workflowTypeBaseName(key)}Output`;
44
+ }
45
+ /**
46
+ * Reserved words that cannot be used as a bare `function <name>` declaration.
47
+ * The per-workflow factory is now a top-level exported function (not an
48
+ * object-literal property), so a key that camelCases to one of these must be
49
+ * escaped or `export function delete(client) {}` is a syntax error. Covers ES
50
+ * reserved words plus the strict-mode/future set — a workflow key resolves case
51
+ * -insensitively and matches `^[a-z0-9][a-z0-9-_]{2,}$`, so only the lowercase
52
+ * single-word forms can actually collide.
53
+ */
54
+ const RESERVED_WORDS = new Set([
55
+ "break", "case", "catch", "class", "const", "continue", "debugger",
56
+ "default", "delete", "do", "else", "enum", "export", "extends", "false",
57
+ "finally", "for", "function", "if", "import", "in", "instanceof", "new",
58
+ "null", "return", "super", "switch", "this", "throw", "true", "try",
59
+ "typeof", "var", "void", "while", "with", "yield", "let", "static",
60
+ "implements", "interface", "package", "private", "protected", "public",
61
+ "await",
62
+ ]);
63
+ /**
64
+ * camelCase factory function name for a workflow key: PascalCase, then lowercase
65
+ * the first character (`create-checkout-session` → `createCheckoutSession`,
66
+ * `refresh-sheet` → `refreshSheet`). Used as the top-level exported factory
67
+ * function name in the per-workflow generated file, so it must be a legal
68
+ * function identifier: a digit-leading key (`123-job` → `_123Job`) is
69
+ * underscore-prefixed, and a key that lands on a JS reserved word (`delete`,
70
+ * `new`, `import`) is underscore-suffixed (`delete_`). Only the emitted
71
+ * identifier changes; the runtime call still passes the ORIGINAL key string.
72
+ */
73
+ export function workflowFactoryName(key) {
74
+ const pascal = pascalCase(key);
75
+ if (pascal.length === 0)
76
+ return pascal;
77
+ const camel = pascal.charAt(0).toLowerCase() + pascal.slice(1);
78
+ const safeStart = ensureValidIdentifierStart(camel);
79
+ return RESERVED_WORDS.has(safeStart) ? `${safeStart}_` : safeStart;
80
+ }
81
+ //# sourceMappingURL=naming.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"naming.js","sourceRoot":"","sources":["../../../../src/lib/workflow-codegen/naming.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC;AAEvD;;;;;;;GAOG;AACH,SAAS,0BAA0B,CAAC,IAAY;IAC9C,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC7B,IAAI,KAAK,IAAI,GAAG,IAAI,KAAK,IAAI,GAAG,EAAE,CAAC;QACjC,OAAO,IAAI,IAAI,EAAE,CAAC;IACpB,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,GAAW;IAC9C,OAAO,0BAA0B,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC;AACrD,CAAC;AAED,qEAAqE;AACrE,MAAM,UAAU,qBAAqB,CAAC,GAAW;IAC/C,OAAO,GAAG,oBAAoB,CAAC,GAAG,CAAC,OAAO,CAAC;AAC7C,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,sBAAsB,CAAC,GAAW;IAChD,OAAO,GAAG,oBAAoB,CAAC,GAAG,CAAC,QAAQ,CAAC;AAC9C,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,cAAc,GAAG,IAAI,GAAG,CAAC;IAC7B,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU;IAClE,SAAS,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO;IACvE,SAAS,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,YAAY,EAAE,KAAK;IACvE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK;IACnE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,QAAQ;IAClE,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ;IACtE,OAAO;CACR,CAAC,CAAC;AAEH;;;;;;;;;GASG;AACH,MAAM,UAAU,mBAAmB,CAAC,GAAW;IAC7C,MAAM,MAAM,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;IAC/B,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,MAAM,CAAC;IACvC,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAC/D,MAAM,SAAS,GAAG,0BAA0B,CAAC,KAAK,CAAC,CAAC;IACpD,OAAO,cAAc,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,GAAG,SAAS,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC;AACrE,CAAC"}
@@ -0,0 +1,80 @@
1
+ /**
2
+ * JSON-Schema → TypeScript converter for `workflows codegen` (issue #1442).
3
+ *
4
+ * Workflow `inputSchema`/`outputSchema` are real JSON Schema. This converter
5
+ * types only the subset the server's validator descends into — and it reads
6
+ * that interpretation from the SAME descriptor the server validator consumes,
7
+ * vendored into the CLI as `generated-schema-descriptor.ts` (a byte copy of
8
+ * `src/workflows/schema-descriptor.ts`, kept fresh by
9
+ * `cli/scripts/gen-workflow-schema-descriptor.mjs` + its drift guard). So the
10
+ * generated type and the runtime validation can never disagree on:
11
+ *
12
+ * - `type` single scalar (`string`/`number`/`integer`/`boolean`/`null`) →
13
+ * the mapped TS scalar.
14
+ * - `type` array-union — only when every member is a scalar/`null` → a TS
15
+ * union. A union that contains `object` or `array` renders `unknown`,
16
+ * because the server only walks `properties`/`items` for the bare string
17
+ * `"object"`/`"array"` — a union is never descended, so a precise-looking
18
+ * type would over-promise.
19
+ * - `enum` → a scalar-literal union, intersected with the declared `type`
20
+ * first (the server gates on `type` before checking `enum`).
21
+ * - `type: "object"` with `properties` → a nested object type; `required[]`
22
+ * drives `name:` vs `name?:`. An OPEN object (no `additionalProperties:
23
+ * false`) also emits `[key: string]: unknown` so extra keys the runtime
24
+ * validator accepts don't hit TS excess-property errors; a CLOSED object
25
+ * (`additionalProperties: false`) omits the index signature.
26
+ * - `type: "array"` with `items` → `T[]`.
27
+ * - `oneOf` whose members are ALL `type: "object"` → a discriminated
28
+ * (tagged) union: the `|`-union of member object types, keyed by an
29
+ * auto-detected single-literal-`enum` discriminator (#1511). A defective
30
+ * all-object tagged union (no/ambiguous discriminator, <2 members) or an
31
+ * all-object `anyOf` (unsupported in v1) is a STRICT codegen error, not a
32
+ * silent `unknown` (Fork 3, resolved by the maintainer).
33
+ *
34
+ * Everything else the server ignores (`$ref`, `allOf`, `format`,
35
+ * `patternProperties`, numeric constraints, tuple `items`, and a `oneOf`/`anyOf`
36
+ * whose members are NOT all objects) renders `unknown`.
37
+ *
38
+ * Errors are NOT swallowed here — a malformed schema fails upstream at parse
39
+ * time, and a defective tagged union throws — this walker otherwise returns
40
+ * `unknown` for anything it does not recognize.
41
+ *
42
+ * FORMATTING CONTRACT (#1565): the types emitted here must be a fixed point of
43
+ * Prettier's DEFAULT config, since `workflows codegen --check` byte-compares
44
+ * the emission against disk. Long unions therefore render through
45
+ * `codegen-shared/prettierStable.ts` (which reproduces Prettier's width
46
+ * decision) instead of being joined with `" | "`. There is no Prettier
47
+ * dependency and no automated round-trip test, so verify any change to these
48
+ * shapes by hand — see that module's header.
49
+ */
50
+ import { type TypeNode } from "../codegen-shared/prettierStable.js";
51
+ /**
52
+ * Convert a parsed JSON Schema node to a TypeScript type expression. Object
53
+ * types render multi-line (2-space indent per level); everything else renders
54
+ * on a single line unless it is too wide for Prettier's default print width
55
+ * (#1565). `indent` is the current indentation depth.
56
+ */
57
+ export declare function schemaToTsType(schema: any, indent?: number): string;
58
+ /**
59
+ * `schemaToTsType` as a wrappable node — the emitters print it at the position
60
+ * it actually occupies so long unions/objects wrap exactly as Prettier would
61
+ * (#1565). See `codegen-shared/prettierStable.ts`.
62
+ */
63
+ export declare function schemaToTypeNode(schema: any): TypeNode;
64
+ /**
65
+ * True when the schema REJECTS an empty object `{}` — i.e. the client's
66
+ * `rootInput: options.input ?? {}` fallback would fail validation, so `input`
67
+ * must be a compile-time-required option (issue #1442, P4). Derived from the
68
+ * shared descriptor so it matches the server validator exactly:
69
+ *
70
+ * - a valid top-level discriminated-union (`oneOf`): the runtime always
71
+ * requires the discriminator present, so `{}` matches no case;
72
+ * - a declared top-level `type` that `{}` does not satisfy (anything but
73
+ * `object`, e.g. `string`/`array`, or a union with no `object` arm);
74
+ * - a top-level `enum` (a fresh `{}` is never an enum member);
75
+ * - `type: "object"` with a non-empty `required[]` (a missing required key).
76
+ *
77
+ * An all-optional object schema, or a schema with no top-level constraints,
78
+ * accepts `{}` → `input` is optional.
79
+ */
80
+ export declare function schemaRejectsEmptyObject(schema: any): boolean;
@@ -0,0 +1,303 @@
1
+ /**
2
+ * JSON-Schema → TypeScript converter for `workflows codegen` (issue #1442).
3
+ *
4
+ * Workflow `inputSchema`/`outputSchema` are real JSON Schema. This converter
5
+ * types only the subset the server's validator descends into — and it reads
6
+ * that interpretation from the SAME descriptor the server validator consumes,
7
+ * vendored into the CLI as `generated-schema-descriptor.ts` (a byte copy of
8
+ * `src/workflows/schema-descriptor.ts`, kept fresh by
9
+ * `cli/scripts/gen-workflow-schema-descriptor.mjs` + its drift guard). So the
10
+ * generated type and the runtime validation can never disagree on:
11
+ *
12
+ * - `type` single scalar (`string`/`number`/`integer`/`boolean`/`null`) →
13
+ * the mapped TS scalar.
14
+ * - `type` array-union — only when every member is a scalar/`null` → a TS
15
+ * union. A union that contains `object` or `array` renders `unknown`,
16
+ * because the server only walks `properties`/`items` for the bare string
17
+ * `"object"`/`"array"` — a union is never descended, so a precise-looking
18
+ * type would over-promise.
19
+ * - `enum` → a scalar-literal union, intersected with the declared `type`
20
+ * first (the server gates on `type` before checking `enum`).
21
+ * - `type: "object"` with `properties` → a nested object type; `required[]`
22
+ * drives `name:` vs `name?:`. An OPEN object (no `additionalProperties:
23
+ * false`) also emits `[key: string]: unknown` so extra keys the runtime
24
+ * validator accepts don't hit TS excess-property errors; a CLOSED object
25
+ * (`additionalProperties: false`) omits the index signature.
26
+ * - `type: "array"` with `items` → `T[]`.
27
+ * - `oneOf` whose members are ALL `type: "object"` → a discriminated
28
+ * (tagged) union: the `|`-union of member object types, keyed by an
29
+ * auto-detected single-literal-`enum` discriminator (#1511). A defective
30
+ * all-object tagged union (no/ambiguous discriminator, <2 members) or an
31
+ * all-object `anyOf` (unsupported in v1) is a STRICT codegen error, not a
32
+ * silent `unknown` (Fork 3, resolved by the maintainer).
33
+ *
34
+ * Everything else the server ignores (`$ref`, `allOf`, `format`,
35
+ * `patternProperties`, numeric constraints, tuple `items`, and a `oneOf`/`anyOf`
36
+ * whose members are NOT all objects) renders `unknown`.
37
+ *
38
+ * Errors are NOT swallowed here — a malformed schema fails upstream at parse
39
+ * time, and a defective tagged union throws — this walker otherwise returns
40
+ * `unknown` for anything it does not recognize.
41
+ *
42
+ * FORMATTING CONTRACT (#1565): the types emitted here must be a fixed point of
43
+ * Prettier's DEFAULT config, since `workflows codegen --check` byte-compares
44
+ * the emission against disk. Long unions therefore render through
45
+ * `codegen-shared/prettierStable.ts` (which reproduces Prettier's width
46
+ * decision) instead of being joined with `" | "`. There is no Prettier
47
+ * dependency and no automated round-trip test, so verify any change to these
48
+ * shapes by hand — see that module's header.
49
+ */
50
+ import { describeSchema, isType, } from "./generated-schema-descriptor.js";
51
+ import { arrayOf, atom, block, indent as pad2, printType, recordOf, renderMember, tsStringLiteral, union, } from "../codegen-shared/prettierStable.js";
52
+ /** Scalar JSON-schema types this converter maps to a concrete TS scalar. */
53
+ const SCALAR_TS = {
54
+ string: "string",
55
+ number: "number",
56
+ integer: "number",
57
+ boolean: "boolean",
58
+ null: "null",
59
+ };
60
+ /** A shared empty-object reference for the `{}`-rejection probe below. */
61
+ const EMPTY_OBJECT = Object.freeze({});
62
+ /**
63
+ * Render a scalar-literal union from an `enum` array. A string member is
64
+ * emitted via `tsStringLiteral` (Prettier's quote choice, #1565); a number,
65
+ * boolean, or `null` via `JSON.stringify`, which is already a Prettier fixed
66
+ * point for those. An object/array member has no TS literal form, so the whole
67
+ * enum falls back to `unknown` (returns `null` here).
68
+ */
69
+ function tsUnionFromScalarEnum(values) {
70
+ if (!Array.isArray(values) || values.length === 0)
71
+ return null;
72
+ const literals = [];
73
+ const seen = new Set();
74
+ for (const v of values) {
75
+ if (v !== null && (typeof v === "object" || Array.isArray(v))) {
76
+ // Objects/arrays are not representable as TS literals.
77
+ return null;
78
+ }
79
+ const literal = typeof v === "string" ? tsStringLiteral(v) : JSON.stringify(v);
80
+ if (literal === undefined)
81
+ return null; // e.g. `undefined` in the enum
82
+ if (!seen.has(literal)) {
83
+ seen.add(literal);
84
+ literals.push(literal);
85
+ }
86
+ }
87
+ return literals.length > 0 ? union(literals.map(atom)) : null;
88
+ }
89
+ /**
90
+ * Convert a parsed JSON Schema node to a TypeScript type expression. Object
91
+ * types render multi-line (2-space indent per level); everything else renders
92
+ * on a single line unless it is too wide for Prettier's default print width
93
+ * (#1565). `indent` is the current indentation depth.
94
+ */
95
+ export function schemaToTsType(schema, indent = 0) {
96
+ return printType(schemaToTypeNode(schema), indent * 2, indent);
97
+ }
98
+ /**
99
+ * `schemaToTsType` as a wrappable node — the emitters print it at the position
100
+ * it actually occupies so long unions/objects wrap exactly as Prettier would
101
+ * (#1565). See `codegen-shared/prettierStable.ts`.
102
+ */
103
+ export function schemaToTypeNode(schema) {
104
+ const d = describeSchema(schema);
105
+ // `enum` is the most specific constraint — the server checks it AFTER the
106
+ // type gate, so when both are present only the enum members that satisfy the
107
+ // declared type(s) are reachable. Emit just those (intersect with `type`
108
+ // via the shared `isType`). If the type filter leaves nothing representable,
109
+ // fall through to plain `type` rendering rather than over-promising.
110
+ if (d.enumValues) {
111
+ const allowedTypes = d.types;
112
+ const candidates = allowedTypes.length > 0
113
+ ? d.enumValues.filter((v) => allowedTypes.some((t) => isType(v, t)))
114
+ : d.enumValues;
115
+ if (candidates.length === 0) {
116
+ // No enum member satisfies the declared type gate (or the enum is empty),
117
+ // so the runtime rejects EVERY value: the type gate lets some values
118
+ // through, then `enum.includes(value)` fails them all. The reachable set
119
+ // is empty → an uninhabitable `never`. Widening to the declared type here
120
+ // (e.g. `{type:"string", enum:[1]}` → `string`) would let typed callers
121
+ // pass values the server always rejects.
122
+ return atom("never");
123
+ }
124
+ const enumUnion = tsUnionFromScalarEnum(candidates);
125
+ if (enumUnion !== null)
126
+ return enumUnion;
127
+ // Candidates survive the type gate but aren't representable as TS literals
128
+ // (object/array enum members). With no declared type there is nothing to
129
+ // fall back on → `unknown`; otherwise fall through to plain `type`.
130
+ if (allowedTypes.length === 0)
131
+ return atom("unknown");
132
+ }
133
+ // Array-union type (e.g. `["string", "null"]`). Only scalar/null members get
134
+ // a precise union — the server never descends `properties`/`items` for a
135
+ // union, so an object/array member forces `unknown`.
136
+ if (d.isUnion) {
137
+ const parts = [];
138
+ const seen = new Set();
139
+ for (const t of d.types) {
140
+ const mapped = SCALAR_TS[t];
141
+ // object/array/unknown member
142
+ if (mapped === undefined)
143
+ return atom("unknown");
144
+ if (!seen.has(mapped)) {
145
+ seen.add(mapped);
146
+ parts.push(mapped);
147
+ }
148
+ }
149
+ return parts.length > 0 ? union(parts.map(atom)) : atom("unknown");
150
+ }
151
+ // Discriminated-union (`oneOf`) rendering (#1511). A qualifying tagged union
152
+ // has no top-level `type`, so this runs ahead of the `singularType === null`
153
+ // fallback. Render each member via the existing object rendering and join
154
+ // with `|` — the natural TS discriminated union TS narrows on. A defective
155
+ // all-object tagged union (`kind: "invalid"`) is a strict codegen error
156
+ // (Fork 3, resolved by the maintainer), not a silent `unknown`.
157
+ if (d.oneOf) {
158
+ if (d.oneOf.kind === "invalid") {
159
+ throw new Error(`workflows codegen: ${d.oneOf.reason}`);
160
+ }
161
+ const { discriminant } = d.oneOf;
162
+ const members = d.oneOf.members.map((m) => {
163
+ const md = describeSchema(m.schema);
164
+ // Every member is `type: "object"` with `properties`, so `md.object` is
165
+ // non-null — reuse the shared object rendering rather than reimplement it.
166
+ if (!md.object)
167
+ return schemaToTypeNode(m.schema);
168
+ // The runtime validator always requires the discriminator present before
169
+ // it can select a branch — regardless of whether the member lists it in
170
+ // its own `required`. Force it required so the generated union can't
171
+ // compile a value that omits the tag (which the runtime rejects as
172
+ // "matches no case") (#1511).
173
+ const required = md.object.required.includes(discriminant)
174
+ ? md.object.required
175
+ : [...md.object.required, discriminant];
176
+ return objectNode({ ...md.object, required });
177
+ });
178
+ return union(members);
179
+ }
180
+ if (d.singularType === null) {
181
+ // No usable single type and no enum — the server enforces nothing.
182
+ return atom("unknown");
183
+ }
184
+ // Object: the server walks `properties`/`required` ONLY when the type is
185
+ // exactly `"object"`. `d.object` is non-null only in that case with declared
186
+ // properties; a typed object with no properties is open → Record.
187
+ if (d.singularType === "object") {
188
+ if (d.object)
189
+ return objectNode(d.object);
190
+ return recordOf("unknown");
191
+ }
192
+ // Array: the server walks `items` ONLY when the type is exactly `"array"`.
193
+ if (d.singularType === "array") {
194
+ const items = d.array ? d.array.items : undefined;
195
+ // Missing or tuple `items` (an array of schemas) is ignored → unknown[].
196
+ if (!items || typeof items !== "object" || Array.isArray(items)) {
197
+ return atom("unknown[]");
198
+ }
199
+ return arrayOf(schemaToTypeNode(items));
200
+ }
201
+ // Single scalar type.
202
+ const scalar = SCALAR_TS[d.singularType];
203
+ return scalar ? atom(scalar) : atom("unknown");
204
+ }
205
+ /** An object type as a node — always multi-line, so Prettier never collapses it. */
206
+ function objectNode(objectDesc) {
207
+ return block((level) => renderObjectType(objectDesc, level));
208
+ }
209
+ /**
210
+ * Render an object descriptor (`describeSchema(...).object`) as a TS object
211
+ * type. `required[]` drives optionality. An OPEN object (not
212
+ * `additionalProperties: false`) emits `[key: string]: unknown` so extra keys
213
+ * the runtime accepts don't trip TS excess-property checks; a CLOSED object
214
+ * omits it.
215
+ */
216
+ function renderObjectType(objectDesc, indent) {
217
+ const { properties, required, additionalPropertiesClosed } = objectDesc;
218
+ const propNames = Object.keys(properties);
219
+ const requiredSet = new Set(Array.isArray(required)
220
+ ? required.filter((k) => typeof k === "string")
221
+ : []);
222
+ const pad = pad2(indent + 1);
223
+ const closePad = pad2(indent);
224
+ const propNameSet = new Set(propNames);
225
+ const lines = [];
226
+ for (const name of propNames) {
227
+ lines.push(renderMember(indent + 1, quotePropIfNeeded(name), !requiredSet.has(name), schemaToTypeNode(properties[name])));
228
+ }
229
+ // A key listed in `required` but absent from `properties` has no declared
230
+ // child schema, yet the validator still rejects an object missing it. Emit it
231
+ // as a required `unknown` member so the generated type demands the key too —
232
+ // otherwise `{properties:{}, required:["id"]}` would accept `{}`, which the
233
+ // runtime rejects.
234
+ for (const name of requiredSet) {
235
+ if (!propNameSet.has(name)) {
236
+ lines.push(`${pad}${quotePropIfNeeded(name)}: unknown;`);
237
+ }
238
+ }
239
+ // Open objects accept extra keys at runtime; model that with an index
240
+ // signature so a call site passing an unlisted key still compiles.
241
+ if (!additionalPropertiesClosed) {
242
+ lines.push(`${pad}[key: string]: unknown;`);
243
+ }
244
+ // A closed object with no members at all renders `{}` — Prettier collapses an
245
+ // empty `{\n}` to `{}`, so emit it that way to stay byte-stable (#1565).
246
+ if (lines.length === 0)
247
+ return "{}";
248
+ return ["{", ...lines, `${closePad}}`].join("\n");
249
+ }
250
+ /**
251
+ * Quote an object-property name when it is not a plain identifier (so keys with
252
+ * hyphens, dots, or other characters render as valid TS). A quoted key uses
253
+ * Prettier's quote choice so it stays a fixed point (#1565).
254
+ */
255
+ function quotePropIfNeeded(name) {
256
+ if (/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(name))
257
+ return name;
258
+ return tsStringLiteral(name);
259
+ }
260
+ /**
261
+ * True when the schema REJECTS an empty object `{}` — i.e. the client's
262
+ * `rootInput: options.input ?? {}` fallback would fail validation, so `input`
263
+ * must be a compile-time-required option (issue #1442, P4). Derived from the
264
+ * shared descriptor so it matches the server validator exactly:
265
+ *
266
+ * - a valid top-level discriminated-union (`oneOf`): the runtime always
267
+ * requires the discriminator present, so `{}` matches no case;
268
+ * - a declared top-level `type` that `{}` does not satisfy (anything but
269
+ * `object`, e.g. `string`/`array`, or a union with no `object` arm);
270
+ * - a top-level `enum` (a fresh `{}` is never an enum member);
271
+ * - `type: "object"` with a non-empty `required[]` (a missing required key).
272
+ *
273
+ * An all-optional object schema, or a schema with no top-level constraints,
274
+ * accepts `{}` → `input` is optional.
275
+ */
276
+ export function schemaRejectsEmptyObject(schema) {
277
+ const d = describeSchema(schema);
278
+ // 0. A valid discriminated-union (`oneOf`) always requires the discriminator
279
+ // present before the runtime can select a branch, so a fresh `{}` (the
280
+ // client's `input ?? {}` fallback) matches no case and is rejected. The
281
+ // generated `input` must therefore be required, not optional (#1511).
282
+ if (d.oneOf && d.oneOf.kind === "valid") {
283
+ return true;
284
+ }
285
+ // 1. Type gate: `{}` must satisfy at least one declared type.
286
+ if (d.types.length && !d.types.some((t) => isType(EMPTY_OBJECT, t))) {
287
+ return true;
288
+ }
289
+ // 2. Enum gate: a JSON enum never contains a value reference-equal to `{}`,
290
+ // so any enum rejects it (mirrors `enum.includes(value)` at runtime).
291
+ if (d.enumValues && !d.enumValues.includes(EMPTY_OBJECT)) {
292
+ return true;
293
+ }
294
+ // 3. Object required: any required key is absent from `{}`.
295
+ if (d.object) {
296
+ for (const key of d.object.required) {
297
+ if (!(key in EMPTY_OBJECT))
298
+ return true;
299
+ }
300
+ }
301
+ return false;
302
+ }
303
+ //# sourceMappingURL=schemaToTs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemaToTs.js","sourceRoot":"","sources":["../../../../src/lib/workflow-codegen/schemaToTs.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AAEH,OAAO,EACL,cAAc,EACd,MAAM,GAEP,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EACL,OAAO,EACP,IAAI,EACJ,KAAK,EACL,MAAM,IAAI,IAAI,EAEd,SAAS,EACT,QAAQ,EACR,YAAY,EACZ,eAAe,EACf,KAAK,GAEN,MAAM,qCAAqC,CAAC;AAE7C,4EAA4E;AAC5E,MAAM,SAAS,GAA2B;IACxC,MAAM,EAAE,QAAQ;IAChB,MAAM,EAAE,QAAQ;IAChB,OAAO,EAAE,QAAQ;IACjB,OAAO,EAAE,SAAS;IAClB,IAAI,EAAE,MAAM;CACb,CAAC;AAEF,0EAA0E;AAC1E,MAAM,YAAY,GAA0B,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AAE9D;;;;;;GAMG;AACH,SAAS,qBAAqB,CAAC,MAAa;IAC1C,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,IAAI,CAAC;IAC/D,MAAM,QAAQ,GAAa,EAAE,CAAC;IAC9B,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,KAAK,MAAM,CAAC,IAAI,MAAM,EAAE,CAAC;QACvB,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAC9D,uDAAuD;YACvD,OAAO,IAAI,CAAC;QACd,CAAC;QACD,MAAM,OAAO,GAAG,OAAO,CAAC,KAAK,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CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * Apply a workflow's named config sidecars, and honor `activeConfigName`
3
+ * (issue #2645, spec §Contracts/Named configs).
4
+ *
5
+ * ── What this is for ─────────────────────────────────────────────────────
6
+ * Named configs used to be reachable only through `workflows configs
7
+ * create/update/duplicate/activate`. Those verbs are removed, so `config push`
8
+ * has to apply the bodies now — otherwise the capability would have been
9
+ * deleted rather than moved to TOML, which the spec's criterion 2 forbids.
10
+ *
11
+ * ── Division of labour with `applyWorkflowBody` ──────────────────────────
12
+ * The ACTIVE config's body stays where it already is: the `steps` at the top of
13
+ * `workflows/<key>.toml`, written through `applyWorkflowBody`'s
14
+ * ordering-sensitive sequence (metadata PATCH → steps → deferred `syncCallable`
15
+ * PATCH, #807). That path is deliberately untouched — a second single-object
16
+ * apply is what broke that ordering before. This module handles the OTHER named
17
+ * configs, each from its own sidecar, and then the activation.
18
+ *
19
+ * So each config body is declared exactly once: the live one at the top of the
20
+ * workflow file, every other one in `workflows/<key>.configs/<name>.toml`.
21
+ * After a pull that follows an `activeConfigName` change, the two swap roles.
22
+ *
23
+ * ── Ordering ─────────────────────────────────────────────────────────────
24
+ * Bodies first, activation last. Activating a config before writing its steps
25
+ * would put an empty or stale body into service for the width of one call.
26
+ */
27
+ import type { ApiClient } from "./api-client.js";
28
+ import type { WorkflowConfigSidecar } from "./workflow-config-sidecar.js";
29
+ export interface ApplyWorkflowConfigsOptions {
30
+ /** The workflow's configs as the server currently has them. */
31
+ serverConfigs: any[];
32
+ /** `[workflow].activeConfigName` from the TOML, when the author set one. */
33
+ activeConfigName?: string;
34
+ /** The config that is live right now, so a no-op activation is skipped. */
35
+ currentActiveConfigId?: string;
36
+ /**
37
+ * Let `activeConfigName` NAME the config that just received the workflow
38
+ * file's body, instead of requiring it to already exist.
39
+ *
40
+ * Create only. A workflow the server has just made carries one config it
41
+ * named itself ("default"), holding the body from `workflows/<key>.toml` —
42
+ * and pull never writes a sidecar for the active config, so on a fresh app
43
+ * there is nothing else `activeConfigName` could be referring to.
44
+ *
45
+ * Deliberately NOT set on update: there, an `activeConfigName` matching no
46
+ * config and no sidecar is far more likely a typo than a rename, and
47
+ * renaming the live config out from under that typo would be a silent
48
+ * mutation. Update keeps failing with the message that names the file to
49
+ * author.
50
+ */
51
+ adoptActiveConfigName?: boolean;
52
+ log?: (message: string) => void;
53
+ }
54
+ export interface ApplyWorkflowConfigsResult {
55
+ /** Config name → id, which the rest of push needs to resolve test cases. */
56
+ configIds: Map<string, string>;
57
+ /** Whether this call moved the live config. */
58
+ activated: boolean;
59
+ /** The config that is live once this call returns, when known. */
60
+ activeConfigId?: string;
61
+ }
62
+ /**
63
+ * Create or update each sidecar's config, then activate the named one.
64
+ *
65
+ * Reports whether it activated anything: activation writes the workflow
66
+ * DEFINITION (`activeConfigId`, and with it a fresh `modifiedAt`), so the
67
+ * caller's sync state is stale afterwards unless it re-reads — which is how a
68
+ * push that only switched the active config left the next one to conflict.
69
+ */
70
+ export declare function applyWorkflowConfigSidecars(client: ApiClient, appId: string, workflowId: string, sidecars: readonly WorkflowConfigSidecar[], options: ApplyWorkflowConfigsOptions): Promise<ApplyWorkflowConfigsResult>;