@halonicjs/testing 0.0.0 → 0.1.1

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/LICENSE +202 -0
  2. package/NOTICE +5 -0
  3. package/README.md +41 -1
  4. package/dist/adapters/http-kit/src/address-checking.d.ts +19 -0
  5. package/dist/adapters/http-kit/src/address-checking.js +1 -0
  6. package/dist/adapters/http-kit/src/address-class.d.ts +34 -0
  7. package/dist/adapters/http-kit/src/address-class.js +109 -0
  8. package/dist/adapters/http-kit/src/index.d.ts +3 -0
  9. package/dist/adapters/http-kit/src/index.js +2 -0
  10. package/dist/adapters/http-kit/src/ip-address.d.ts +23 -0
  11. package/dist/adapters/http-kit/src/ip-address.js +89 -0
  12. package/dist/adapters/integration-kit/src/auth-placement.d.ts +40 -0
  13. package/dist/adapters/integration-kit/src/auth-placement.js +102 -0
  14. package/dist/adapters/integration-kit/src/current-secret-forms.d.ts +28 -0
  15. package/dist/adapters/integration-kit/src/current-secret-forms.js +60 -0
  16. package/dist/adapters/integration-kit/src/declaration.d.ts +15 -0
  17. package/dist/adapters/integration-kit/src/declaration.js +78 -0
  18. package/dist/adapters/integration-kit/src/host.d.ts +34 -0
  19. package/dist/adapters/integration-kit/src/host.js +31 -0
  20. package/dist/adapters/integration-kit/src/index.d.ts +16 -0
  21. package/dist/adapters/integration-kit/src/index.js +22 -0
  22. package/dist/adapters/integration-kit/src/leak-attempt.d.ts +16 -0
  23. package/dist/adapters/integration-kit/src/leak-attempt.js +19 -0
  24. package/dist/adapters/integration-kit/src/limited-http.d.ts +55 -0
  25. package/dist/adapters/integration-kit/src/limited-http.js +225 -0
  26. package/dist/adapters/integration-kit/src/load-problem.d.ts +20 -0
  27. package/dist/adapters/integration-kit/src/load-problem.js +1 -0
  28. package/dist/adapters/integration-kit/src/loader.d.ts +131 -0
  29. package/dist/adapters/integration-kit/src/loader.js +251 -0
  30. package/dist/adapters/integration-kit/src/local-address.d.ts +15 -0
  31. package/dist/adapters/integration-kit/src/local-address.js +25 -0
  32. package/dist/adapters/integration-kit/src/own-request.d.ts +33 -0
  33. package/dist/adapters/integration-kit/src/own-request.js +36 -0
  34. package/dist/adapters/integration-kit/src/plugin-load.d.ts +14 -0
  35. package/dist/adapters/integration-kit/src/plugin-load.js +58 -0
  36. package/dist/adapters/integration-kit/src/policy.d.ts +83 -0
  37. package/dist/adapters/integration-kit/src/policy.js +37 -0
  38. package/dist/adapters/integration-kit/src/request-body.d.ts +38 -0
  39. package/dist/adapters/integration-kit/src/request-body.js +68 -0
  40. package/dist/adapters/integration-kit/src/request-log.d.ts +25 -0
  41. package/dist/adapters/integration-kit/src/request-log.js +17 -0
  42. package/dist/adapters/integration-kit/src/response-body.d.ts +27 -0
  43. package/dist/adapters/integration-kit/src/response-body.js +117 -0
  44. package/dist/adapters/integration-kit/src/scoped-tokens.d.ts +14 -0
  45. package/dist/adapters/integration-kit/src/scoped-tokens.js +27 -0
  46. package/dist/adapters/integration-kit/src/secret-filter.d.ts +84 -0
  47. package/dist/adapters/integration-kit/src/secret-filter.js +220 -0
  48. package/dist/adapters/integration-kit/src/secret-in-request.d.ts +62 -0
  49. package/dist/adapters/integration-kit/src/secret-in-request.js +139 -0
  50. package/dist/adapters/integration-kit/src/secret-placement.d.ts +46 -0
  51. package/dist/adapters/integration-kit/src/secret-placement.js +160 -0
  52. package/dist/adapters/integration-kit/src/sign-in-placement.d.ts +29 -0
  53. package/dist/adapters/integration-kit/src/sign-in-placement.js +92 -0
  54. package/dist/adapters/integration-kit/src/wait.d.ts +16 -0
  55. package/dist/adapters/integration-kit/src/wait.js +35 -0
  56. package/dist/core/events/src/add-usage.d.ts +10 -0
  57. package/dist/core/events/src/add-usage.js +27 -0
  58. package/dist/core/events/src/agent-resume.d.ts +24 -0
  59. package/dist/core/events/src/agent-resume.js +1 -0
  60. package/dist/core/events/src/blocked-sites.d.ts +57 -0
  61. package/dist/core/events/src/blocked-sites.js +89 -0
  62. package/dist/core/events/src/home-path.d.ts +13 -0
  63. package/dist/core/events/src/home-path.js +26 -0
  64. package/dist/core/events/src/index.d.ts +17 -0
  65. package/dist/core/events/src/index.js +10 -0
  66. package/dist/core/events/src/run-basics.d.ts +228 -0
  67. package/dist/core/events/src/run-basics.js +1 -0
  68. package/dist/core/events/src/run-event.d.ts +478 -0
  69. package/dist/core/events/src/run-event.js +1 -0
  70. package/dist/core/events/src/run-reads.d.ts +25 -0
  71. package/dist/core/events/src/run-reads.js +44 -0
  72. package/dist/core/events/src/run-sends.d.ts +47 -0
  73. package/dist/core/events/src/run-sends.js +68 -0
  74. package/dist/core/events/src/run-summary.d.ts +108 -0
  75. package/dist/core/events/src/run-summary.js +1 -0
  76. package/dist/core/events/src/sandbox-blocked.d.ts +42 -0
  77. package/dist/core/events/src/sandbox-blocked.js +26 -0
  78. package/dist/core/events/src/sandbox-opened-read.d.ts +17 -0
  79. package/dist/core/events/src/sandbox-opened-read.js +63 -0
  80. package/dist/core/events/src/sandbox-opened.d.ts +94 -0
  81. package/dist/core/events/src/sandbox-opened.js +52 -0
  82. package/dist/core/events/src/summarize.d.ts +14 -0
  83. package/dist/core/events/src/summarize.js +192 -0
  84. package/dist/core/events/src/timeline-entry.d.ts +21 -0
  85. package/dist/core/events/src/timeline-entry.js +106 -0
  86. package/dist/core/events/src/upgrade.d.ts +23 -0
  87. package/dist/core/events/src/upgrade.js +49 -0
  88. package/dist/core/format/src/compact.d.ts +30 -0
  89. package/dist/core/format/src/compact.js +72 -0
  90. package/dist/core/format/src/index.d.ts +39 -0
  91. package/dist/core/format/src/index.js +25 -0
  92. package/dist/core/format/src/integration/index.d.ts +7 -0
  93. package/dist/core/format/src/integration/index.js +10 -0
  94. package/dist/core/format/src/json-schema.d.ts +26 -0
  95. package/dist/core/format/src/json-schema.js +48 -0
  96. package/dist/core/format/src/kind.d.ts +65 -0
  97. package/dist/core/format/src/kind.js +1 -0
  98. package/dist/core/format/src/kinds/agent/kind.d.ts +4 -0
  99. package/dist/core/format/src/kinds/agent/kind.js +10 -0
  100. package/dist/core/format/src/kinds/agent/sandbox-fields.d.ts +99 -0
  101. package/dist/core/format/src/kinds/agent/sandbox-fields.js +216 -0
  102. package/dist/core/format/src/kinds/agent/schema.d.ts +147 -0
  103. package/dist/core/format/src/kinds/agent/schema.js +107 -0
  104. package/dist/core/format/src/kinds/agent/working-folder-start.d.ts +74 -0
  105. package/dist/core/format/src/kinds/agent/working-folder-start.js +312 -0
  106. package/dist/core/format/src/kinds/collection/kind.d.ts +8 -0
  107. package/dist/core/format/src/kinds/collection/kind.js +14 -0
  108. package/dist/core/format/src/kinds/collection/schema.d.ts +89 -0
  109. package/dist/core/format/src/kinds/collection/schema.js +90 -0
  110. package/dist/core/format/src/kinds/connector/is-local.d.ts +10 -0
  111. package/dist/core/format/src/kinds/connector/is-local.js +43 -0
  112. package/dist/core/format/src/kinds/connector/kind.d.ts +4 -0
  113. package/dist/core/format/src/kinds/connector/kind.js +218 -0
  114. package/dist/core/format/src/kinds/connector/schema.d.ts +74 -0
  115. package/dist/core/format/src/kinds/connector/schema.js +143 -0
  116. package/dist/core/format/src/kinds/deployments/kind.d.ts +4 -0
  117. package/dist/core/format/src/kinds/deployments/kind.js +49 -0
  118. package/dist/core/format/src/kinds/deployments/schema.d.ts +77 -0
  119. package/dist/core/format/src/kinds/deployments/schema.js +94 -0
  120. package/dist/core/format/src/kinds/hub/kind.d.ts +4 -0
  121. package/dist/core/format/src/kinds/hub/kind.js +10 -0
  122. package/dist/core/format/src/kinds/hub/schema.d.ts +54 -0
  123. package/dist/core/format/src/kinds/hub/schema.js +34 -0
  124. package/dist/core/format/src/kinds/integration/approved-sign-ins.d.ts +62 -0
  125. package/dist/core/format/src/kinds/integration/approved-sign-ins.js +125 -0
  126. package/dist/core/format/src/kinds/integration/host-key.d.ts +7 -0
  127. package/dist/core/format/src/kinds/integration/host-key.js +8 -0
  128. package/dist/core/format/src/kinds/integration/kind.d.ts +18 -0
  129. package/dist/core/format/src/kinds/integration/kind.js +175 -0
  130. package/dist/core/format/src/kinds/integration/parse-sheet.d.ts +19 -0
  131. package/dist/core/format/src/kinds/integration/parse-sheet.js +24 -0
  132. package/dist/core/format/src/kinds/integration/policy.d.ts +112 -0
  133. package/dist/core/format/src/kinds/integration/policy.js +327 -0
  134. package/dist/core/format/src/kinds/integration/schema.d.ts +410 -0
  135. package/dist/core/format/src/kinds/integration/schema.js +359 -0
  136. package/dist/core/format/src/kinds/integration/sign-in-checks.d.ts +13 -0
  137. package/dist/core/format/src/kinds/integration/sign-in-checks.js +120 -0
  138. package/dist/core/format/src/kinds/integration/sign-in-urls.d.ts +19 -0
  139. package/dist/core/format/src/kinds/integration/sign-in-urls.js +47 -0
  140. package/dist/core/format/src/kinds/knowledge/kind.d.ts +4 -0
  141. package/dist/core/format/src/kinds/knowledge/kind.js +13 -0
  142. package/dist/core/format/src/kinds/knowledge/schema.d.ts +18 -0
  143. package/dist/core/format/src/kinds/knowledge/schema.js +25 -0
  144. package/dist/core/format/src/kinds/models/kind.d.ts +4 -0
  145. package/dist/core/format/src/kinds/models/kind.js +10 -0
  146. package/dist/core/format/src/kinds/models/schema.d.ts +92 -0
  147. package/dist/core/format/src/kinds/models/schema.js +38 -0
  148. package/dist/core/format/src/kinds/plugin/backend.d.ts +22 -0
  149. package/dist/core/format/src/kinds/plugin/backend.js +31 -0
  150. package/dist/core/format/src/kinds/plugin/checks.d.ts +13 -0
  151. package/dist/core/format/src/kinds/plugin/checks.js +137 -0
  152. package/dist/core/format/src/kinds/plugin/kind.d.ts +8 -0
  153. package/dist/core/format/src/kinds/plugin/kind.js +16 -0
  154. package/dist/core/format/src/kinds/plugin/problems.d.ts +24 -0
  155. package/dist/core/format/src/kinds/plugin/problems.js +65 -0
  156. package/dist/core/format/src/kinds/plugin/schema.d.ts +672 -0
  157. package/dist/core/format/src/kinds/plugin/schema.js +261 -0
  158. package/dist/core/format/src/kinds/plugin/setting-values.d.ts +17 -0
  159. package/dist/core/format/src/kinds/plugin/setting-values.js +38 -0
  160. package/dist/core/format/src/kinds/plugin/ui-checks.d.ts +8 -0
  161. package/dist/core/format/src/kinds/plugin/ui-checks.js +85 -0
  162. package/dist/core/format/src/kinds/provider/kind.d.ts +4 -0
  163. package/dist/core/format/src/kinds/provider/kind.js +24 -0
  164. package/dist/core/format/src/kinds/provider/schema.d.ts +17 -0
  165. package/dist/core/format/src/kinds/provider/schema.js +22 -0
  166. package/dist/core/format/src/kinds/routine/kind.d.ts +8 -0
  167. package/dist/core/format/src/kinds/routine/kind.js +62 -0
  168. package/dist/core/format/src/kinds/routine/schema.d.ts +94 -0
  169. package/dist/core/format/src/kinds/routine/schema.js +115 -0
  170. package/dist/core/format/src/kinds/routine/webhook-headers.d.ts +9 -0
  171. package/dist/core/format/src/kinds/routine/webhook-headers.js +26 -0
  172. package/dist/core/format/src/kinds/runtime/kind.d.ts +4 -0
  173. package/dist/core/format/src/kinds/runtime/kind.js +13 -0
  174. package/dist/core/format/src/kinds/runtime/schema.d.ts +10 -0
  175. package/dist/core/format/src/kinds/runtime/schema.js +12 -0
  176. package/dist/core/format/src/kinds/skill/kind.d.ts +4 -0
  177. package/dist/core/format/src/kinds/skill/kind.js +10 -0
  178. package/dist/core/format/src/kinds/skill/schema.d.ts +17 -0
  179. package/dist/core/format/src/kinds/skill/schema.js +17 -0
  180. package/dist/core/format/src/kinds/skill/scripts-folder.d.ts +27 -0
  181. package/dist/core/format/src/kinds/skill/scripts-folder.js +37 -0
  182. package/dist/core/format/src/kinds/workflow/kind.d.ts +8 -0
  183. package/dist/core/format/src/kinds/workflow/kind.js +14 -0
  184. package/dist/core/format/src/kinds/workflow/schema.d.ts +162 -0
  185. package/dist/core/format/src/kinds/workflow/schema.js +106 -0
  186. package/dist/core/format/src/kinds/workflow-test/kind.d.ts +4 -0
  187. package/dist/core/format/src/kinds/workflow-test/kind.js +14 -0
  188. package/dist/core/format/src/kinds/workflow-test/schema.d.ts +67 -0
  189. package/dist/core/format/src/kinds/workflow-test/schema.js +59 -0
  190. package/dist/core/format/src/kinds/workspace/kind.d.ts +4 -0
  191. package/dist/core/format/src/kinds/workspace/kind.js +10 -0
  192. package/dist/core/format/src/kinds/workspace/schema.d.ts +72 -0
  193. package/dist/core/format/src/kinds/workspace/schema.js +66 -0
  194. package/dist/core/format/src/parse-file.d.ts +69 -0
  195. package/dist/core/format/src/parse-file.js +105 -0
  196. package/dist/core/format/src/recording/format.d.ts +81 -0
  197. package/dist/core/format/src/recording/format.js +102 -0
  198. package/dist/core/format/src/recording/index.d.ts +1 -0
  199. package/dist/core/format/src/recording/index.js +3 -0
  200. package/dist/core/format/src/registry.d.ts +64 -0
  201. package/dist/core/format/src/registry.js +61 -0
  202. package/dist/core/format/src/reserved.d.ts +20 -0
  203. package/dist/core/format/src/reserved.js +30 -0
  204. package/dist/core/format/src/shared/fields.d.ts +34 -0
  205. package/dist/core/format/src/shared/fields.js +74 -0
  206. package/dist/core/format/src/shared/guard.d.ts +32 -0
  207. package/dist/core/format/src/shared/guard.js +16 -0
  208. package/dist/core/format/src/shared/key-in-value.d.ts +28 -0
  209. package/dist/core/format/src/shared/key-in-value.js +82 -0
  210. package/dist/core/format/src/shared/legacy-keys.d.ts +8 -0
  211. package/dist/core/format/src/shared/legacy-keys.js +17 -0
  212. package/dist/core/format/src/shared/program-start.d.ts +60 -0
  213. package/dist/core/format/src/shared/program-start.js +99 -0
  214. package/dist/core/format/src/shared/relative-path.d.ts +29 -0
  215. package/dist/core/format/src/shared/relative-path.js +50 -0
  216. package/dist/core/format/src/shared/secret-name.d.ts +24 -0
  217. package/dist/core/format/src/shared/secret-name.js +107 -0
  218. package/dist/core/format/src/source.d.ts +16 -0
  219. package/dist/core/format/src/source.js +73 -0
  220. package/dist/core/ports/src/agent-placement-store.d.ts +74 -0
  221. package/dist/core/ports/src/agent-placement-store.js +27 -0
  222. package/dist/core/ports/src/agent-runs-not-available.d.ts +21 -0
  223. package/dist/core/ports/src/agent-runs-not-available.js +25 -0
  224. package/dist/core/ports/src/blob-store.d.ts +45 -0
  225. package/dist/core/ports/src/blob-store.js +24 -0
  226. package/dist/core/ports/src/cant-try-error.d.ts +35 -0
  227. package/dist/core/ports/src/cant-try-error.js +44 -0
  228. package/dist/core/ports/src/chat.d.ts +127 -0
  229. package/dist/core/ports/src/chat.js +1 -0
  230. package/dist/core/ports/src/clock.d.ts +7 -0
  231. package/dist/core/ports/src/clock.js +2 -0
  232. package/dist/core/ports/src/connection-settings-store.d.ts +57 -0
  233. package/dist/core/ports/src/connection-settings-store.js +2 -0
  234. package/dist/core/ports/src/connector-client.d.ts +303 -0
  235. package/dist/core/ports/src/connector-client.js +19 -0
  236. package/dist/core/ports/src/coordination.d.ts +84 -0
  237. package/dist/core/ports/src/coordination.js +2 -0
  238. package/dist/core/ports/src/definition-store.d.ts +229 -0
  239. package/dist/core/ports/src/definition-store.js +122 -0
  240. package/dist/core/ports/src/digest.d.ts +14 -0
  241. package/dist/core/ports/src/digest.js +2 -0
  242. package/dist/core/ports/src/folder-reader.d.ts +89 -0
  243. package/dist/core/ports/src/folder-reader.js +2 -0
  244. package/dist/core/ports/src/harness-bridge-server.d.ts +198 -0
  245. package/dist/core/ports/src/harness-bridge-server.js +37 -0
  246. package/dist/core/ports/src/harness-sign-in-command.d.ts +27 -0
  247. package/dist/core/ports/src/harness-sign-in-command.js +31 -0
  248. package/dist/core/ports/src/harness.d.ts +283 -0
  249. package/dist/core/ports/src/harness.js +45 -0
  250. package/dist/core/ports/src/host-settings-store.d.ts +116 -0
  251. package/dist/core/ports/src/host-settings-store.js +106 -0
  252. package/dist/core/ports/src/http-client.d.ts +27 -0
  253. package/dist/core/ports/src/http-client.js +2 -0
  254. package/dist/core/ports/src/id-generator.d.ts +14 -0
  255. package/dist/core/ports/src/id-generator.js +2 -0
  256. package/dist/core/ports/src/index.d.ts +45 -0
  257. package/dist/core/ports/src/index.js +44 -0
  258. package/dist/core/ports/src/instruction-trust-store.d.ts +81 -0
  259. package/dist/core/ports/src/instruction-trust-store.js +43 -0
  260. package/dist/core/ports/src/integration.d.ts +242 -0
  261. package/dist/core/ports/src/integration.js +31 -0
  262. package/dist/core/ports/src/knowledge-provider.d.ts +65 -0
  263. package/dist/core/ports/src/knowledge-provider.js +2 -0
  264. package/dist/core/ports/src/llm-cache.d.ts +13 -0
  265. package/dist/core/ports/src/llm-cache.js +2 -0
  266. package/dist/core/ports/src/llm-provider.d.ts +186 -0
  267. package/dist/core/ports/src/llm-provider.js +139 -0
  268. package/dist/core/ports/src/model-price.d.ts +34 -0
  269. package/dist/core/ports/src/model-price.js +25 -0
  270. package/dist/core/ports/src/password-hasher.d.ts +63 -0
  271. package/dist/core/ports/src/password-hasher.js +2 -0
  272. package/dist/core/ports/src/plugin-folder-writer.d.ts +104 -0
  273. package/dist/core/ports/src/plugin-folder-writer.js +95 -0
  274. package/dist/core/ports/src/port-versions.d.ts +47 -0
  275. package/dist/core/ports/src/port-versions.js +80 -0
  276. package/dist/core/ports/src/program-probe.d.ts +69 -0
  277. package/dist/core/ports/src/program-probe.js +2 -0
  278. package/dist/core/ports/src/provider-default-base-url.d.ts +10 -0
  279. package/dist/core/ports/src/provider-default-base-url.js +18 -0
  280. package/dist/core/ports/src/record-store.d.ts +79 -0
  281. package/dist/core/ports/src/record-store.js +108 -0
  282. package/dist/core/ports/src/resource-probe.d.ts +59 -0
  283. package/dist/core/ports/src/resource-probe.js +2 -0
  284. package/dist/core/ports/src/run-executor.d.ts +303 -0
  285. package/dist/core/ports/src/run-executor.js +2 -0
  286. package/dist/core/ports/src/run-failure-error.d.ts +49 -0
  287. package/dist/core/ports/src/run-failure-error.js +47 -0
  288. package/dist/core/ports/src/run-store.d.ts +194 -0
  289. package/dist/core/ports/src/run-store.js +131 -0
  290. package/dist/core/ports/src/run-target-not-found.d.ts +34 -0
  291. package/dist/core/ports/src/run-target-not-found.js +41 -0
  292. package/dist/core/ports/src/sandbox-setting-store.d.ts +68 -0
  293. package/dist/core/ports/src/sandbox-setting-store.js +33 -0
  294. package/dist/core/ports/src/sandbox.d.ts +364 -0
  295. package/dist/core/ports/src/sandbox.js +70 -0
  296. package/dist/core/ports/src/scheduler.d.ts +85 -0
  297. package/dist/core/ports/src/scheduler.js +2 -0
  298. package/dist/core/ports/src/secrets.d.ts +201 -0
  299. package/dist/core/ports/src/secrets.js +200 -0
  300. package/dist/core/ports/src/token-store.d.ts +19 -0
  301. package/dist/core/ports/src/token-store.js +2 -0
  302. package/dist/core/ports/src/tool-approval-store.d.ts +253 -0
  303. package/dist/core/ports/src/tool-approval-store.js +116 -0
  304. package/dist/core/ports/src/trust-store.d.ts +72 -0
  305. package/dist/core/ports/src/trust-store.js +2 -0
  306. package/dist/core/ports/src/unfenced-run-consent-store.d.ts +43 -0
  307. package/dist/core/ports/src/unfenced-run-consent-store.js +2 -0
  308. package/dist/core/ports/src/vcs-status.d.ts +8 -0
  309. package/dist/core/ports/src/vcs-status.js +90 -0
  310. package/dist/core/ports/src/vcs.d.ts +394 -0
  311. package/dist/core/ports/src/vcs.js +48 -0
  312. package/dist/core/schema-kit/src/builders.d.ts +50 -0
  313. package/dist/core/schema-kit/src/builders.js +72 -0
  314. package/dist/core/schema-kit/src/depth.d.ts +15 -0
  315. package/dist/core/schema-kit/src/depth.js +37 -0
  316. package/dist/core/schema-kit/src/index.d.ts +6 -0
  317. package/dist/core/schema-kit/src/index.js +6 -0
  318. package/dist/core/schema-kit/src/issue.d.ts +22 -0
  319. package/dist/core/schema-kit/src/issue.js +23 -0
  320. package/dist/core/schema-kit/src/json-schema.d.ts +23 -0
  321. package/dist/core/schema-kit/src/json-schema.js +22 -0
  322. package/dist/core/schema-kit/src/parse.d.ts +17 -0
  323. package/dist/core/schema-kit/src/parse.js +25 -0
  324. package/dist/core/schema-kit/src/schema.d.ts +12 -0
  325. package/dist/core/schema-kit/src/schema.js +1 -0
  326. package/dist/core/std/src/amount.d.ts +13 -0
  327. package/dist/core/std/src/amount.js +22 -0
  328. package/dist/core/std/src/ascii-host.d.ts +18 -0
  329. package/dist/core/std/src/ascii-host.js +110 -0
  330. package/dist/core/std/src/assert.d.ts +39 -0
  331. package/dist/core/std/src/assert.js +59 -0
  332. package/dist/core/std/src/base64url.d.ts +23 -0
  333. package/dist/core/std/src/base64url.js +65 -0
  334. package/dist/core/std/src/canonical-json.d.ts +18 -0
  335. package/dist/core/std/src/canonical-json.js +56 -0
  336. package/dist/core/std/src/clock.d.ts +27 -0
  337. package/dist/core/std/src/clock.js +33 -0
  338. package/dist/core/std/src/constant-time.d.ts +16 -0
  339. package/dist/core/std/src/constant-time.js +26 -0
  340. package/dist/core/std/src/content-digest.d.ts +24 -0
  341. package/dist/core/std/src/content-digest.js +28 -0
  342. package/dist/core/std/src/deep-clone.d.ts +15 -0
  343. package/dist/core/std/src/deep-clone.js +59 -0
  344. package/dist/core/std/src/deep-equal.d.ts +23 -0
  345. package/dist/core/std/src/deep-equal.js +64 -0
  346. package/dist/core/std/src/emitter.d.ts +42 -0
  347. package/dist/core/std/src/emitter.js +74 -0
  348. package/dist/core/std/src/error-kind.d.ts +88 -0
  349. package/dist/core/std/src/error-kind.js +98 -0
  350. package/dist/core/std/src/hex.d.ts +10 -0
  351. package/dist/core/std/src/hex.js +16 -0
  352. package/dist/core/std/src/hidden-characters.d.ts +19 -0
  353. package/dist/core/std/src/hidden-characters.js +54 -0
  354. package/dist/core/std/src/ids.d.ts +45 -0
  355. package/dist/core/std/src/ids.js +49 -0
  356. package/dist/core/std/src/index.d.ts +30 -0
  357. package/dist/core/std/src/index.js +31 -0
  358. package/dist/core/std/src/keyed-queue.d.ts +18 -0
  359. package/dist/core/std/src/keyed-queue.js +32 -0
  360. package/dist/core/std/src/line-diff.d.ts +83 -0
  361. package/dist/core/std/src/line-diff.js +179 -0
  362. package/dist/core/std/src/line-merge.d.ts +63 -0
  363. package/dist/core/std/src/line-merge.js +138 -0
  364. package/dist/core/std/src/plain-data.d.ts +32 -0
  365. package/dist/core/std/src/plain-data.js +57 -0
  366. package/dist/core/std/src/posix-path.d.ts +61 -0
  367. package/dist/core/std/src/posix-path.js +121 -0
  368. package/dist/core/std/src/public-suffixes.generated.d.ts +9 -0
  369. package/dist/core/std/src/public-suffixes.generated.js +10429 -0
  370. package/dist/core/std/src/registrable-domain.d.ts +10 -0
  371. package/dist/core/std/src/registrable-domain.js +62 -0
  372. package/dist/core/std/src/result.d.ts +55 -0
  373. package/dist/core/std/src/result.js +52 -0
  374. package/dist/core/std/src/secret-scrubber.d.ts +54 -0
  375. package/dist/core/std/src/secret-scrubber.js +124 -0
  376. package/dist/core/std/src/secret-shape.d.ts +20 -0
  377. package/dist/core/std/src/secret-shape.js +53 -0
  378. package/dist/core/std/src/secret-variable-name.d.ts +12 -0
  379. package/dist/core/std/src/secret-variable-name.js +34 -0
  380. package/dist/core/std/src/site-name.d.ts +35 -0
  381. package/dist/core/std/src/site-name.js +111 -0
  382. package/dist/core/std/src/stop-signal.d.ts +44 -0
  383. package/dist/core/std/src/stop-signal.js +77 -0
  384. package/dist/core/std/src/text.d.ts +28 -0
  385. package/dist/core/std/src/text.js +54 -0
  386. package/dist/core/std/src/url-host.d.ts +35 -0
  387. package/dist/core/std/src/url-host.js +170 -0
  388. package/dist/core/std/src/utf8.d.ts +23 -0
  389. package/dist/core/std/src/utf8.js +110 -0
  390. package/dist/core/std/src/version.d.ts +48 -0
  391. package/dist/core/std/src/version.js +103 -0
  392. package/dist/core/yaml/src/depth.d.ts +14 -0
  393. package/dist/core/yaml/src/depth.js +140 -0
  394. package/dist/core/yaml/src/edit-data.d.ts +47 -0
  395. package/dist/core/yaml/src/edit-data.js +286 -0
  396. package/dist/core/yaml/src/edit-text.d.ts +92 -0
  397. package/dist/core/yaml/src/edit-text.js +267 -0
  398. package/dist/core/yaml/src/edit.d.ts +47 -0
  399. package/dist/core/yaml/src/edit.js +198 -0
  400. package/dist/core/yaml/src/index.d.ts +5 -0
  401. package/dist/core/yaml/src/index.js +4 -0
  402. package/dist/core/yaml/src/problem.d.ts +20 -0
  403. package/dist/core/yaml/src/problem.js +1 -0
  404. package/dist/core/yaml/src/read.d.ts +47 -0
  405. package/dist/core/yaml/src/read.js +130 -0
  406. package/dist/core/yaml/src/splice-node.d.ts +47 -0
  407. package/dist/core/yaml/src/splice-node.js +333 -0
  408. package/dist/core/yaml/src/splice.d.ts +13 -0
  409. package/dist/core/yaml/src/splice.js +174 -0
  410. package/dist/core/yaml/src/unsupported.d.ts +26 -0
  411. package/dist/core/yaml/src/unsupported.js +70 -0
  412. package/dist/core/yaml/src/write.d.ts +35 -0
  413. package/dist/core/yaml/src/write.js +44 -0
  414. package/dist/testing/integration/src/canaries.d.ts +14 -0
  415. package/dist/testing/integration/src/canaries.js +17 -0
  416. package/dist/testing/integration/src/checks.d.ts +37 -0
  417. package/dist/testing/integration/src/checks.js +195 -0
  418. package/dist/testing/integration/src/describe.d.ts +35 -0
  419. package/dist/testing/integration/src/describe.js +74 -0
  420. package/dist/testing/integration/src/failure.d.ts +6 -0
  421. package/dist/testing/integration/src/failure.js +8 -0
  422. package/dist/testing/integration/src/fake-wait.d.ts +18 -0
  423. package/dist/testing/integration/src/fake-wait.js +21 -0
  424. package/dist/testing/integration/src/index.d.ts +10 -0
  425. package/dist/testing/integration/src/index.js +11 -0
  426. package/dist/testing/integration/src/load.d.ts +14 -0
  427. package/dist/testing/integration/src/load.js +47 -0
  428. package/dist/testing/integration/src/plugin-folder.d.ts +23 -0
  429. package/dist/testing/integration/src/plugin-folder.js +59 -0
  430. package/dist/testing/integration/src/plugin.d.ts +32 -0
  431. package/dist/testing/integration/src/plugin.js +57 -0
  432. package/dist/testing/integration/src/recording.d.ts +84 -0
  433. package/dist/testing/integration/src/recording.js +164 -0
  434. package/dist/testing/integration/src/run.d.ts +60 -0
  435. package/dist/testing/integration/src/run.js +81 -0
  436. package/dist/testing/integration/src/source-scan.d.ts +16 -0
  437. package/dist/testing/integration/src/source-scan.js +40 -0
  438. package/package.json +34 -3
@@ -0,0 +1,140 @@
1
+ import { CST, Lexer } from "yaml";
2
+ /** Token types that carry no structure: they never open or close a level. */
3
+ const quietTypes = new Set([
4
+ "space",
5
+ "newline",
6
+ "comment",
7
+ "byte-order-mark",
8
+ ]);
9
+ /**
10
+ * Finds where lists and maps first nest deeper than `maxDepth`, by reading
11
+ * the text as tokens, without building any tree. The `yaml` library builds
12
+ * the whole tree before we can look at it, so a hostile file such as five
13
+ * million `[` would use up memory first. This pass needs memory for the
14
+ * open levels only, and stops at the first one past the limit.
15
+ *
16
+ * Block levels are counted from indentation. The count can be a little
17
+ * higher than the real depth in odd layouts; `findUnsupported` still checks
18
+ * the exact tree afterwards.
19
+ *
20
+ * @returns the offset of the first list or map past the limit, or `undefined`
21
+ */
22
+ export function findDepthOffset(text, maxDepth) {
23
+ const scan = new DepthScan();
24
+ let offset = 0;
25
+ for (const token of new Lexer().lex(text)) {
26
+ // The lexer marks documents, scalars and errors with control characters
27
+ // that are not in the text, so they take no space.
28
+ const inText = !isMarker(token);
29
+ const type = inText ? CST.tokenType(token) : null;
30
+ const lineStart = scan.lineStart;
31
+ if (inText) {
32
+ scan.noteText(token, offset);
33
+ }
34
+ const reached = inText && !quietTypes.has(type) ? scan.take(type, offset, offset - lineStart) : 0;
35
+ if (reached > maxDepth) {
36
+ return scan.reportAt;
37
+ }
38
+ offset += inText ? token.length : 0;
39
+ }
40
+ return undefined;
41
+ }
42
+ /** True for the control-character tokens the lexer adds that are not in the text. */
43
+ function isMarker(token) {
44
+ return token === CST.DOCUMENT || token === CST.FLOW_END || token === CST.SCALAR;
45
+ }
46
+ /** The open lists and maps while the tokens of a text go by. */
47
+ class DepthScan {
48
+ /** Offset of the start of the current line. */
49
+ lineStart = 0;
50
+ /** Where to report the level that was just opened. */
51
+ reportAt = 0;
52
+ blocks = [];
53
+ flowDepth = 0;
54
+ atLineStart = true;
55
+ /** Where the key of the current entry starts, so a `:` knows its map's column. */
56
+ entry;
57
+ /** Keeps track of line breaks, including those inside multi-line scalars. */
58
+ noteText(token, offset) {
59
+ const lastBreak = token.lastIndexOf("\n");
60
+ if (lastBreak !== -1) {
61
+ this.lineStart = offset + lastBreak + 1;
62
+ this.atLineStart = true;
63
+ this.entry = undefined;
64
+ }
65
+ }
66
+ /**
67
+ * Takes one token that has structure.
68
+ *
69
+ * @returns how many lists and maps are open now
70
+ */
71
+ take(type, offset, col) {
72
+ this.reportAt = offset;
73
+ if (type === "doc-start" || type === "doc-end") {
74
+ this.blocks.length = 0;
75
+ this.flowDepth = 0;
76
+ }
77
+ else if (this.flowDepth > 0 || type === "flow-map-start" || type === "flow-seq-start") {
78
+ this.takeFlow(type, offset, col);
79
+ }
80
+ else {
81
+ this.takeBlock(type, offset, col);
82
+ }
83
+ return this.blocks.length + this.flowDepth;
84
+ }
85
+ takeFlow(type, offset, col) {
86
+ this.claimEntry(col, offset);
87
+ if (type === "flow-map-start" || type === "flow-seq-start") {
88
+ if (this.flowDepth === 0 && this.atLineStart) {
89
+ this.closeBlocksDeeperThan(col);
90
+ }
91
+ this.flowDepth++;
92
+ }
93
+ else if (type === "flow-map-end" || type === "flow-seq-end") {
94
+ this.flowDepth--;
95
+ }
96
+ this.atLineStart = false;
97
+ }
98
+ takeBlock(type, offset, col) {
99
+ if (this.atLineStart) {
100
+ this.closeBlocksDeeperThan(col);
101
+ this.atLineStart = false;
102
+ }
103
+ if (type === "seq-item-ind" || type === "explicit-key-ind") {
104
+ this.enter(type === "seq-item-ind" ? "list" : "map", col);
105
+ this.entry = undefined;
106
+ }
107
+ else if (type === "map-value-ind") {
108
+ // A map is reported where its first key starts, not at the colon.
109
+ this.reportAt = this.entry?.offset ?? offset;
110
+ this.enter("map", this.entry?.col ?? col);
111
+ this.entry = undefined;
112
+ }
113
+ else {
114
+ this.claimEntry(col, offset);
115
+ }
116
+ }
117
+ claimEntry(col, offset) {
118
+ this.entry ??= { col, offset };
119
+ }
120
+ /** Opens a block level at `col`, or reuses it, closing every level inside it. */
121
+ enter(kind, col) {
122
+ this.closeBlocksDeeperThan(col);
123
+ for (let index = this.blocks.length - 1; index >= 0; index--) {
124
+ const level = this.blocks[index];
125
+ if (level.col !== col) {
126
+ break;
127
+ }
128
+ if (level.kind === kind) {
129
+ this.blocks.length = index + 1;
130
+ return;
131
+ }
132
+ }
133
+ this.blocks.push({ kind, col });
134
+ }
135
+ closeBlocksDeeperThan(col) {
136
+ while ((this.blocks.at(-1)?.col ?? -1) > col) {
137
+ this.blocks.pop();
138
+ }
139
+ }
140
+ }
@@ -0,0 +1,47 @@
1
+ import { type Result } from "../../std/src/index.js";
2
+ import type { YamlPath } from "./read.js";
3
+ /**
4
+ * One change to a YAML text, at a path of keys and list indexes:
5
+ * - `set`: puts `value` at `path`, creating missing maps on the way. On a
6
+ * list, the index must point at an item that exists. `path` `[]` replaces
7
+ * the whole document.
8
+ * - `delete`: removes the key or list item at `path`. Nothing happens when
9
+ * nothing is there.
10
+ * - `insert`: adds `value` to a list before the item at the index that ends
11
+ * `path`; the list's length adds it at the end.
12
+ *
13
+ * A `set` that adds a new key to a map puts it at the end of that map, or
14
+ * right after the key `after` names; `after: null` puts it first. This is
15
+ * where the key goes in the text, and in the data, so a block put back from
16
+ * another version of the file lands where it was in every layout and in a
17
+ * flow map. `after` does nothing when the key is already there, and a key
18
+ * `after` names that isn't there means the end.
19
+ */
20
+ export type YamlEdit = {
21
+ readonly kind: "set";
22
+ readonly path: YamlPath;
23
+ readonly value: unknown;
24
+ readonly after?: string | null;
25
+ } | {
26
+ readonly kind: "delete";
27
+ readonly path: YamlPath;
28
+ } | {
29
+ readonly kind: "insert";
30
+ readonly path: YamlPath;
31
+ readonly value: unknown;
32
+ };
33
+ /**
34
+ * Applies an edit to plain data, the way `editYaml` must change what the
35
+ * text reads as. The read-back after each edit compares against this.
36
+ *
37
+ * @returns the new data (the input is not changed), or why the edit doesn't fit
38
+ */
39
+ export declare function applyEditToData(data: unknown, edit: YamlEdit): Result<unknown, string>;
40
+ /**
41
+ * Says why a value has no YAML form that reads back equal, or `undefined`
42
+ * when it has one: plain objects, arrays, text, numbers, booleans and `null`,
43
+ * nested no deeper than `maxDepth`.
44
+ */
45
+ export declare function checkValue(value: unknown, maxDepth: number): string | undefined;
46
+ /** A path as people read it: `steps.0.id`, or "the top of the file" for `[]`. */
47
+ export declare function describePath(path: YamlPath): string;
@@ -0,0 +1,286 @@
1
+ import { deepClone, err, ok } from "../../std/src/index.js";
2
+ /**
3
+ * Applies an edit to plain data, the way `editYaml` must change what the
4
+ * text reads as. The read-back after each edit compares against this.
5
+ *
6
+ * @returns the new data (the input is not changed), or why the edit doesn't fit
7
+ */
8
+ export function applyEditToData(data, edit) {
9
+ const pathProblem = checkPath(edit.path);
10
+ if (pathProblem !== undefined) {
11
+ return err(pathProblem);
12
+ }
13
+ switch (edit.kind) {
14
+ case "set":
15
+ return setData(data, edit.path, edit.value, edit.after);
16
+ case "delete":
17
+ return deleteData(data, edit.path);
18
+ case "insert":
19
+ return insertData(data, edit.path, edit.value);
20
+ }
21
+ }
22
+ /**
23
+ * Says why a value has no YAML form that reads back equal, or `undefined`
24
+ * when it has one: plain objects, arrays, text, numbers, booleans and `null`,
25
+ * nested no deeper than `maxDepth`.
26
+ */
27
+ export function checkValue(value, maxDepth) {
28
+ return checkValueAt(value, [], new Set(), maxDepth);
29
+ }
30
+ /** A path as people read it: `steps.0.id`, or "the top of the file" for `[]`. */
31
+ export function describePath(path) {
32
+ return path.length === 0 ? "the top of the file" : `"${path.join(".")}"`;
33
+ }
34
+ function setData(data, path, value, after) {
35
+ if (path.length === 0) {
36
+ return ok(deepClone(value));
37
+ }
38
+ const root = isMissing(data) ? missingParent(path, 0) : ok(deepClone(data));
39
+ if (!root.ok) {
40
+ return root;
41
+ }
42
+ let parent = root.value;
43
+ for (let depth = 0; depth < path.length - 1; depth++) {
44
+ const step = childForSet(parent, path, depth);
45
+ if (!step.ok) {
46
+ return step;
47
+ }
48
+ parent = step.value;
49
+ }
50
+ const placed = placeValue(parent, path, deepClone(value), after);
51
+ return placed === undefined ? ok(root.value) : err(placed);
52
+ }
53
+ /** The child at `path[depth]`, created as an empty map when it is missing. */
54
+ function childForSet(parent, path, depth) {
55
+ const container = asContainer(parent, path, depth);
56
+ if (!container.ok) {
57
+ return container;
58
+ }
59
+ const child = readChild(container.value, path, depth);
60
+ if (!child.ok) {
61
+ return child;
62
+ }
63
+ if (!isMissing(child.value)) {
64
+ return child;
65
+ }
66
+ const created = missingParent(path, depth + 1);
67
+ if (created.ok) {
68
+ setKey(container.value, path[depth], created.value);
69
+ }
70
+ return created;
71
+ }
72
+ /** A new empty map for a missing parent; `set` never creates lists. */
73
+ function missingParent(path, depth) {
74
+ if (typeof path[depth] === "number") {
75
+ return err(`There is no list at ${describePath(path.slice(0, depth))}; set creates only maps. Set the list first.`);
76
+ }
77
+ return ok({});
78
+ }
79
+ function placeValue(parent, path, value, after) {
80
+ const container = asContainer(parent, path, path.length - 1);
81
+ if (!container.ok) {
82
+ return container.error;
83
+ }
84
+ const key = path[path.length - 1];
85
+ if (Array.isArray(container.value)) {
86
+ const index = key;
87
+ if (index === container.value.length) {
88
+ return `${describePath(path)} is one past the end of the list; use insert to add an item.`;
89
+ }
90
+ if (index > container.value.length) {
91
+ return noItem(path, path.length - 1, container.value.length);
92
+ }
93
+ container.value[index] = value;
94
+ return undefined;
95
+ }
96
+ if (after !== undefined && !Object.hasOwn(container.value, key)) {
97
+ addKeyAfter(container.value, key, value, after);
98
+ return undefined;
99
+ }
100
+ setKey(container.value, key, value);
101
+ return undefined;
102
+ }
103
+ /**
104
+ * Adds a key the map doesn't have right after the key `after` names, or first
105
+ * for `null`, or at the end when `after` isn't there. A plain object keeps
106
+ * its keys in the order they were added, so every key is added again in the
107
+ * new order. (A key that reads as a whole number, such as "2", still comes
108
+ * first: JavaScript orders those itself.)
109
+ */
110
+ function addKeyAfter(record, key, value, after) {
111
+ const entries = Object.entries(record);
112
+ const previous = after === null ? -1 : entries.findIndex(([name]) => name === after);
113
+ const at = after !== null && previous === -1 ? entries.length : previous + 1;
114
+ entries.splice(at, 0, [key, value]);
115
+ for (const [name] of entries) {
116
+ delete record[name];
117
+ }
118
+ for (const [name, entryValue] of entries) {
119
+ setKey(record, name, entryValue);
120
+ }
121
+ }
122
+ function deleteData(data, path) {
123
+ if (path.length === 0) {
124
+ return err("delete needs a path; to empty the file, set [] to {}.");
125
+ }
126
+ const copy = deepClone(data);
127
+ let parent = copy;
128
+ for (let depth = 0; depth < path.length - 1; depth++) {
129
+ if (isMissing(parent)) {
130
+ return ok(copy);
131
+ }
132
+ const container = asContainer(parent, path, depth);
133
+ if (!container.ok) {
134
+ return container;
135
+ }
136
+ const child = readChild(container.value, path, depth);
137
+ // An item past the end of a list is nothing to delete.
138
+ parent = child.ok ? child.value : undefined;
139
+ }
140
+ if (isMissing(parent)) {
141
+ return ok(copy);
142
+ }
143
+ const container = asContainer(parent, path, path.length - 1);
144
+ if (!container.ok) {
145
+ return container;
146
+ }
147
+ const key = path[path.length - 1];
148
+ if (Array.isArray(container.value)) {
149
+ container.value.splice(key, 1);
150
+ }
151
+ else if (Object.hasOwn(container.value, key)) {
152
+ delete container.value[key];
153
+ }
154
+ return ok(copy);
155
+ }
156
+ function insertData(data, path, value) {
157
+ const index = path[path.length - 1];
158
+ if (typeof index !== "number") {
159
+ return err("insert needs a path that ends in a list index.");
160
+ }
161
+ const copy = deepClone(data);
162
+ let list = copy;
163
+ for (let depth = 0; depth < path.length - 1; depth++) {
164
+ const container = asContainer(list, path, depth);
165
+ if (!container.ok) {
166
+ return container;
167
+ }
168
+ const child = readChild(container.value, path, depth);
169
+ if (!child.ok) {
170
+ return child;
171
+ }
172
+ list = child.value;
173
+ }
174
+ if (!Array.isArray(list)) {
175
+ return err(`There is no list at ${describePath(path.slice(0, -1))} to insert into.`);
176
+ }
177
+ if (index > list.length) {
178
+ return err(noItem(path, path.length - 1, list.length));
179
+ }
180
+ list.splice(index, 0, deepClone(value));
181
+ return ok(copy);
182
+ }
183
+ /** The value at `path[depth]` inside a container; an index past the end is a problem. */
184
+ function readChild(container, path, depth) {
185
+ const key = path[depth];
186
+ if (Array.isArray(container)) {
187
+ const index = key;
188
+ return index < container.length
189
+ ? ok(container[index])
190
+ : err(noItem(path, depth, container.length));
191
+ }
192
+ return ok(Object.hasOwn(container, key) ? container[key] : undefined);
193
+ }
194
+ /** Checks that `value` (at `path[0..depth)`) can hold the key `path[depth]`. */
195
+ function asContainer(value, path, depth) {
196
+ const at = describePath(path.slice(0, depth));
197
+ const key = path[depth];
198
+ if (Array.isArray(value)) {
199
+ return typeof key === "number"
200
+ ? ok(value)
201
+ : err(`${at} is a list; use a number, not "${String(key)}", to reach an item.`);
202
+ }
203
+ if (typeof value === "object" && value !== null) {
204
+ return typeof key === "string"
205
+ ? ok(value)
206
+ : err(`${at} is a map; use a text key, not ${String(key)}.`);
207
+ }
208
+ return err(`${at} holds ${describeKind(value)}, not a map or a list.`);
209
+ }
210
+ function noItem(path, depth, length) {
211
+ return `There is no item ${String(path[depth])} in ${describePath(path.slice(0, depth))}; the list has ${length}.`;
212
+ }
213
+ function checkPath(path) {
214
+ for (const key of path) {
215
+ if (typeof key === "number" && !(Number.isInteger(key) && key >= 0)) {
216
+ return `A list index must be a whole number of 0 or more, not ${key}.`;
217
+ }
218
+ if (typeof key !== "number" && typeof key !== "string") {
219
+ return `A path holds only text keys and list indexes, not ${typeof key}.`;
220
+ }
221
+ }
222
+ return undefined;
223
+ }
224
+ /**
225
+ * Sets an own key, also one named `__proto__`, which plain assignment would
226
+ * turn into a prototype change. YAML files can hold such a key.
227
+ */
228
+ function setKey(record, key, value) {
229
+ Object.defineProperty(record, key, {
230
+ value,
231
+ writable: true,
232
+ enumerable: true,
233
+ configurable: true,
234
+ });
235
+ }
236
+ /** `null` and absent values: `set` creates a map in their place. */
237
+ function isMissing(value) {
238
+ return value === undefined || value === null;
239
+ }
240
+ function checkValueAt(value, path, open, maxDepth) {
241
+ const at = path.length === 0 ? "The value" : `The value at ${describePath(path)}`;
242
+ if (value === null || ["string", "number", "boolean"].includes(typeof value)) {
243
+ return undefined;
244
+ }
245
+ if (typeof value !== "object") {
246
+ return `${at} is ${describeKind(value)}, which YAML can't hold.`;
247
+ }
248
+ if (open.has(value)) {
249
+ return `${at} contains itself, which YAML can't hold.`;
250
+ }
251
+ if (!Array.isArray(value) && !isPlainRecord(value)) {
252
+ return `${at} is ${describeKind(value)}; YAML holds only plain objects and arrays.`;
253
+ }
254
+ if (path.length >= maxDepth) {
255
+ return `${at} nests deeper than the limit of ${maxDepth} levels.`;
256
+ }
257
+ open.add(value);
258
+ const entries = Array.isArray(value)
259
+ ? Array.from(value.keys(), (index) => [index, index in value ? value[index] : undefined])
260
+ : Object.entries(value);
261
+ for (const [key, child] of entries) {
262
+ const problem = checkValueAt(child, [...path, key], open, maxDepth);
263
+ if (problem !== undefined) {
264
+ return problem;
265
+ }
266
+ }
267
+ open.delete(value);
268
+ return undefined;
269
+ }
270
+ function isPlainRecord(value) {
271
+ const prototype = Object.getPrototypeOf(value);
272
+ return prototype === Object.prototype || prototype === null;
273
+ }
274
+ function describeKind(value) {
275
+ if (value === undefined)
276
+ return "undefined";
277
+ if (value === null)
278
+ return "null";
279
+ if (typeof value === "object") {
280
+ const name = value.constructor?.name;
281
+ return name === undefined ? "an object" : `a ${name}`;
282
+ }
283
+ if (typeof value === "string")
284
+ return "text";
285
+ return `a ${typeof value}`;
286
+ }
@@ -0,0 +1,92 @@
1
+ import { Scalar } from "yaml";
2
+ /**
3
+ * How the file indents its blocks, so new lines match it: the spaces per
4
+ * level, and whether a list under a key is indented (`indentSeq`) or starts
5
+ * at the key's column. These are the yaml library's own options.
6
+ */
7
+ export interface IndentStyle {
8
+ readonly indent: number;
9
+ readonly indentSeq: boolean;
10
+ }
11
+ /** The library's defaults, which `writeYamlFile` writes with. */
12
+ export declare const defaultIndentStyle: IndentStyle;
13
+ /**
14
+ * The text's line ending: `\r\n` when every line break is one, `\n` when every
15
+ * one is that or there are none, `undefined` when the text mixes them.
16
+ */
17
+ export declare function lineEndingOf(text: string): "\n" | "\r\n" | undefined;
18
+ /** Where the line holding `offset` starts. A byte order mark isn't part of the first line. */
19
+ export declare function lineStart(text: string, offset: number): number;
20
+ /** The column of `offset`, counting from 0. */
21
+ export declare function columnOf(text: string, offset: number): number;
22
+ /** True when only spaces come before `offset` on its line. */
23
+ export declare function startsItsLine(text: string, offset: number): boolean;
24
+ /**
25
+ * Where the entry whose value ends at `valueEnd` ends: after its line break,
26
+ * so a trailing `# comment` goes with it. Block collections already end after
27
+ * a line break.
28
+ */
29
+ export declare function entryEnd(text: string, valueEnd: number): number;
30
+ /** Moves `offset` (a line start) up over the comment lines right above it. */
31
+ export declare function aboveComments(text: string, offset: number): number;
32
+ /**
33
+ * True when every comment line of `before`, outside `before[from, to)`, is
34
+ * still a line of `after`.
35
+ */
36
+ export declare function keepsComments(before: string, from: number, to: number, after: string): boolean;
37
+ /**
38
+ * Removes the lines from `from` to `to` (both line starts). When blank lines
39
+ * sat on both sides, one of them goes too, so two sections stay one blank
40
+ * line apart instead of two. At the start or the end of the file, the blank
41
+ * lines next to the removed ones go too, so none is left there.
42
+ */
43
+ export declare function removeLines(text: string, from: number, to: number): string;
44
+ /**
45
+ * Moves the comment lines from `at` (a line start) down to the next entry to
46
+ * that entry's indent, when it starts at `column`. These are comments left
47
+ * indented under a block that is deleted above them; less indented ones stay.
48
+ */
49
+ export declare function alignComments(text: string, at: number, column: number): string;
50
+ /** Inserts whole lines at a line start; at the end of a text without a final line break, adds one first. */
51
+ export declare function insertLines(text: string, at: number, lines: string): string;
52
+ /**
53
+ * Replaces `text[from, to)` with `rendered`, keeping a line break at the end
54
+ * only when the replaced text had one.
55
+ */
56
+ export declare function replaceRange(text: string, from: number, to: number, rendered: string): string;
57
+ /**
58
+ * Moves a comment on the line where `text[from, to)` starts onto the first line of
59
+ * `rendered`, when only blanks, the `:` or `-` and a block text header come before it:
60
+ * `a: # about a` over a block value, or with no value. Comment lines inside the
61
+ * old value go with it.
62
+ *
63
+ * @returns where the replaced text ends (past the comment) and what replaces it
64
+ */
65
+ export declare function keepLineComment(text: string, from: number, to: number, rendered: string): {
66
+ to: number;
67
+ rendered: string;
68
+ };
69
+ /** `key: value` as whole lines, indented to `column`. Keys are quoted by the library, never pasted. */
70
+ export declare function renderPair(key: string, value: unknown, column: number, style: IndentStyle): string;
71
+ /** `- value` as whole lines, indented to `column`. */
72
+ export declare function renderItem(value: unknown, column: number, style: IndentStyle): string;
73
+ /**
74
+ * The text that follows a key to give it `value`: `: 1`, or `:` and the
75
+ * indented lines of a list or map. It starts right after the key.
76
+ */
77
+ export declare function renderAfterKey(value: unknown, column: number, style: IndentStyle): string;
78
+ /** `- value` starting at the dash, with following lines indented to `column`. */
79
+ export declare function renderAfterDash(value: unknown, column: number, style: IndentStyle): string;
80
+ /** A whole document. */
81
+ export declare function renderDocument(value: unknown, style: IndentStyle): string;
82
+ /**
83
+ * A list or map in flow style on one line, like `[a, b]`, with spaces inside
84
+ * the brackets when `padding` is set. `undefined` when it needs more than one
85
+ * line, as a text with a line break does.
86
+ */
87
+ export declare function renderFlow(value: unknown, padding: boolean): string | undefined;
88
+ /**
89
+ * A scalar on one line, keeping a quoted text quoted the same way. `undefined`
90
+ * when it needs more than one line.
91
+ */
92
+ export declare function renderScalar(value: unknown, quoteStyle: Scalar.Type | undefined, column: number): string | undefined;