@intentius/chant-lexicon-pulumi 0.124.97 → 0.124.99

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 (316) hide show
  1. package/dist/adopt.d.ts +0 -1
  2. package/dist/capability-plugin.d.ts +0 -1
  3. package/dist/change-set.d.ts +0 -1
  4. package/dist/changed-units.d.ts +0 -1
  5. package/dist/check-step.d.ts +0 -1
  6. package/dist/ci-setup.d.ts +0 -1
  7. package/dist/codegen/docs-cli.d.ts +0 -1
  8. package/dist/codegen/docs.d.ts +0 -1
  9. package/dist/codegen/package.d.ts +0 -1
  10. package/dist/composites/pulumi-adopt-op.d.ts +0 -1
  11. package/dist/composites/pulumi-watch-op.d.ts +0 -1
  12. package/dist/config.d.ts +0 -1
  13. package/dist/describe-resources.d.ts +0 -1
  14. package/dist/drift-read.d.ts +0 -1
  15. package/dist/drift-record.d.ts +0 -1
  16. package/dist/engine-events.d.ts +0 -1
  17. package/dist/engine-graph.d.ts +0 -1
  18. package/dist/exit-codes.d.ts +0 -1
  19. package/dist/index.d.ts +0 -1
  20. package/dist/init-templates.d.ts +0 -1
  21. package/dist/integrity.json +2 -2
  22. package/dist/lint/audit-catalog.d.ts +0 -1
  23. package/dist/lint/post-synth/index.d.ts +0 -1
  24. package/dist/lint/post-synth/member-read-helpers.d.ts +0 -1
  25. package/dist/lint/post-synth/pul001.d.ts +0 -1
  26. package/dist/lint/post-synth/pul002.d.ts +0 -1
  27. package/dist/lint/post-synth/pul003.d.ts +0 -1
  28. package/dist/lint/post-synth/pul004.d.ts +0 -1
  29. package/dist/lint/post-synth/pul005.d.ts +0 -1
  30. package/dist/lint/post-synth/pul006.d.ts +0 -1
  31. package/dist/lint/post-synth/pul007.d.ts +0 -1
  32. package/dist/lint/post-synth/pul008.d.ts +0 -1
  33. package/dist/lint/post-synth/pul009.d.ts +0 -1
  34. package/dist/lint/post-synth/pul010.d.ts +0 -1
  35. package/dist/lint/post-synth/pul011.d.ts +0 -1
  36. package/dist/lint/post-synth/pul012.d.ts +0 -1
  37. package/dist/lint/post-synth/pul013.d.ts +0 -1
  38. package/dist/lint/post-synth/pul014.d.ts +0 -1
  39. package/dist/lint/post-synth/pul015.d.ts +0 -1
  40. package/dist/lint/rules/index.d.ts +0 -1
  41. package/dist/lint/rules/member-dir-absolute.d.ts +0 -1
  42. package/dist/lock-rows.d.ts +0 -1
  43. package/dist/lsp/completions.d.ts +0 -1
  44. package/dist/lsp/documents.d.ts +0 -1
  45. package/dist/lsp/hover.d.ts +0 -1
  46. package/dist/lsp/keys.d.ts +0 -1
  47. package/dist/lsp/object-path.d.ts +0 -1
  48. package/dist/lsp/yaml-cursor.d.ts +0 -1
  49. package/dist/manifest.json +1 -1
  50. package/dist/member-engine.d.ts +0 -1
  51. package/dist/member-outputs.d.ts +0 -1
  52. package/dist/op/activities/index.d.ts +0 -1
  53. package/dist/op/activities/pulumi-adopt.d.ts +0 -1
  54. package/dist/op/activities/pulumi.d.ts +0 -1
  55. package/dist/op/activity-contracts.d.ts +0 -1
  56. package/dist/op/builders.d.ts +0 -1
  57. package/dist/package-cli.d.ts +0 -1
  58. package/dist/plan-shape.d.ts +0 -1
  59. package/dist/planned-output-changes.d.ts +0 -1
  60. package/dist/plugin.d.ts +0 -1
  61. package/dist/plunge-timings.d.ts +0 -1
  62. package/dist/preview-tips.d.ts +0 -1
  63. package/dist/pulumi-up.d.ts +0 -1
  64. package/dist/release-copy.d.ts +0 -1
  65. package/dist/review-stack.d.ts +0 -1
  66. package/dist/run.d.ts +0 -1
  67. package/dist/serializer.d.ts +0 -1
  68. package/dist/stack-export-snapshot.d.ts +0 -1
  69. package/dist/stack-ops.d.ts +0 -1
  70. package/dist/stack-outputs.d.ts +0 -1
  71. package/dist/stack-references.d.ts +0 -1
  72. package/dist/trace-facts.d.ts +0 -1
  73. package/dist/values.d.ts +0 -1
  74. package/dist/workspace-member.d.ts +0 -1
  75. package/package.json +3 -4
  76. package/dist/adopt.d.ts.map +0 -1
  77. package/dist/capability-plugin.d.ts.map +0 -1
  78. package/dist/change-set.d.ts.map +0 -1
  79. package/dist/changed-units.d.ts.map +0 -1
  80. package/dist/check-step.d.ts.map +0 -1
  81. package/dist/ci-setup.d.ts.map +0 -1
  82. package/dist/codegen/docs-cli.d.ts.map +0 -1
  83. package/dist/codegen/docs.d.ts.map +0 -1
  84. package/dist/codegen/package.d.ts.map +0 -1
  85. package/dist/composites/pulumi-adopt-op.d.ts.map +0 -1
  86. package/dist/composites/pulumi-watch-op.d.ts.map +0 -1
  87. package/dist/config.d.ts.map +0 -1
  88. package/dist/describe-resources.d.ts.map +0 -1
  89. package/dist/drift-read.d.ts.map +0 -1
  90. package/dist/drift-record.d.ts.map +0 -1
  91. package/dist/engine-events.d.ts.map +0 -1
  92. package/dist/engine-graph.d.ts.map +0 -1
  93. package/dist/exit-codes.d.ts.map +0 -1
  94. package/dist/index.d.ts.map +0 -1
  95. package/dist/init-templates.d.ts.map +0 -1
  96. package/dist/lint/audit-catalog.d.ts.map +0 -1
  97. package/dist/lint/post-synth/index.d.ts.map +0 -1
  98. package/dist/lint/post-synth/member-read-helpers.d.ts.map +0 -1
  99. package/dist/lint/post-synth/pul001.d.ts.map +0 -1
  100. package/dist/lint/post-synth/pul002.d.ts.map +0 -1
  101. package/dist/lint/post-synth/pul003.d.ts.map +0 -1
  102. package/dist/lint/post-synth/pul004.d.ts.map +0 -1
  103. package/dist/lint/post-synth/pul005.d.ts.map +0 -1
  104. package/dist/lint/post-synth/pul006.d.ts.map +0 -1
  105. package/dist/lint/post-synth/pul007.d.ts.map +0 -1
  106. package/dist/lint/post-synth/pul008.d.ts.map +0 -1
  107. package/dist/lint/post-synth/pul009.d.ts.map +0 -1
  108. package/dist/lint/post-synth/pul010.d.ts.map +0 -1
  109. package/dist/lint/post-synth/pul011.d.ts.map +0 -1
  110. package/dist/lint/post-synth/pul012.d.ts.map +0 -1
  111. package/dist/lint/post-synth/pul013.d.ts.map +0 -1
  112. package/dist/lint/post-synth/pul014.d.ts.map +0 -1
  113. package/dist/lint/post-synth/pul015.d.ts.map +0 -1
  114. package/dist/lint/rules/index.d.ts.map +0 -1
  115. package/dist/lint/rules/member-dir-absolute.d.ts.map +0 -1
  116. package/dist/lock-rows.d.ts.map +0 -1
  117. package/dist/lsp/completions.d.ts.map +0 -1
  118. package/dist/lsp/documents.d.ts.map +0 -1
  119. package/dist/lsp/hover.d.ts.map +0 -1
  120. package/dist/lsp/keys.d.ts.map +0 -1
  121. package/dist/lsp/object-path.d.ts.map +0 -1
  122. package/dist/lsp/yaml-cursor.d.ts.map +0 -1
  123. package/dist/member-engine.d.ts.map +0 -1
  124. package/dist/member-outputs.d.ts.map +0 -1
  125. package/dist/op/activities/index.d.ts.map +0 -1
  126. package/dist/op/activities/pulumi-adopt.d.ts.map +0 -1
  127. package/dist/op/activities/pulumi.d.ts.map +0 -1
  128. package/dist/op/activity-contracts.d.ts.map +0 -1
  129. package/dist/op/builders.d.ts.map +0 -1
  130. package/dist/package-cli.d.ts.map +0 -1
  131. package/dist/plan-shape.d.ts.map +0 -1
  132. package/dist/planned-output-changes.d.ts.map +0 -1
  133. package/dist/plugin.d.ts.map +0 -1
  134. package/dist/plunge-timings.d.ts.map +0 -1
  135. package/dist/preview-tips.d.ts.map +0 -1
  136. package/dist/pulumi-up.d.ts.map +0 -1
  137. package/dist/release-copy.d.ts.map +0 -1
  138. package/dist/review-stack.d.ts.map +0 -1
  139. package/dist/run.d.ts.map +0 -1
  140. package/dist/serializer.d.ts.map +0 -1
  141. package/dist/stack-export-snapshot.d.ts.map +0 -1
  142. package/dist/stack-ops.d.ts.map +0 -1
  143. package/dist/stack-outputs.d.ts.map +0 -1
  144. package/dist/stack-references.d.ts.map +0 -1
  145. package/dist/trace-facts.d.ts.map +0 -1
  146. package/dist/values.d.ts.map +0 -1
  147. package/dist/workspace-member.d.ts.map +0 -1
  148. package/src/adopt.ts +0 -202
  149. package/src/capability-plugin.ts +0 -34
  150. package/src/change-set.test.ts +0 -245
  151. package/src/change-set.ts +0 -508
  152. package/src/changed-units.test.ts +0 -87
  153. package/src/changed-units.ts +0 -96
  154. package/src/check-step.test.ts +0 -191
  155. package/src/check-step.ts +0 -316
  156. package/src/ci-setup.test.ts +0 -234
  157. package/src/ci-setup.ts +0 -224
  158. package/src/codegen/docs-cli.ts +0 -4
  159. package/src/codegen/docs.ts +0 -58
  160. package/src/codegen/package.ts +0 -63
  161. package/src/composites/pulumi-adopt-op.test.ts +0 -258
  162. package/src/composites/pulumi-adopt-op.ts +0 -193
  163. package/src/composites/pulumi-watch-op.test.ts +0 -42
  164. package/src/composites/pulumi-watch-op.ts +0 -85
  165. package/src/config.ts +0 -43
  166. package/src/describe-resources.test.ts +0 -112
  167. package/src/describe-resources.ts +0 -118
  168. package/src/drift-read.test.ts +0 -178
  169. package/src/drift-read.ts +0 -94
  170. package/src/drift-record.test.ts +0 -197
  171. package/src/drift-record.ts +0 -326
  172. package/src/engine-events.test.ts +0 -160
  173. package/src/engine-events.ts +0 -395
  174. package/src/engine-graph.test.ts +0 -141
  175. package/src/engine-graph.ts +0 -149
  176. package/src/exit-codes.test.ts +0 -21
  177. package/src/exit-codes.ts +0 -71
  178. package/src/index.ts +0 -139
  179. package/src/init-templates.ts +0 -85
  180. package/src/lint/audit-catalog.test.ts +0 -33
  181. package/src/lint/audit-catalog.ts +0 -174
  182. package/src/lint/post-synth/index.ts +0 -35
  183. package/src/lint/post-synth/member-read-helpers.ts +0 -122
  184. package/src/lint/post-synth/post-synth.test.ts +0 -245
  185. package/src/lint/post-synth/pul001.ts +0 -38
  186. package/src/lint/post-synth/pul002.ts +0 -38
  187. package/src/lint/post-synth/pul003.ts +0 -43
  188. package/src/lint/post-synth/pul004.ts +0 -32
  189. package/src/lint/post-synth/pul005.ts +0 -31
  190. package/src/lint/post-synth/pul006.ts +0 -31
  191. package/src/lint/post-synth/pul007.ts +0 -35
  192. package/src/lint/post-synth/pul008.ts +0 -35
  193. package/src/lint/post-synth/pul009.ts +0 -32
  194. package/src/lint/post-synth/pul010.ts +0 -42
  195. package/src/lint/post-synth/pul011.ts +0 -38
  196. package/src/lint/post-synth/pul012.ts +0 -35
  197. package/src/lint/post-synth/pul013.ts +0 -35
  198. package/src/lint/post-synth/pul014.ts +0 -32
  199. package/src/lint/post-synth/pul015.ts +0 -39
  200. package/src/lint/rules/index.ts +0 -7
  201. package/src/lint/rules/member-dir-absolute.test.ts +0 -37
  202. package/src/lint/rules/member-dir-absolute.ts +0 -83
  203. package/src/lock-rows.test.ts +0 -60
  204. package/src/lock-rows.ts +0 -56
  205. package/src/lsp/completions.test.ts +0 -69
  206. package/src/lsp/completions.ts +0 -119
  207. package/src/lsp/documents.ts +0 -48
  208. package/src/lsp/hover.test.ts +0 -56
  209. package/src/lsp/hover.ts +0 -83
  210. package/src/lsp/keys.ts +0 -169
  211. package/src/lsp/object-path.ts +0 -71
  212. package/src/lsp/yaml-cursor.ts +0 -85
  213. package/src/member-engine.test.ts +0 -112
  214. package/src/member-engine.ts +0 -97
  215. package/src/member-outputs.test.ts +0 -339
  216. package/src/member-outputs.ts +0 -157
  217. package/src/op/activities/index.ts +0 -36
  218. package/src/op/activities/pulumi-adopt.ts +0 -345
  219. package/src/op/activities/pulumi.ts +0 -136
  220. package/src/op/activity-contracts.ts +0 -129
  221. package/src/op/builders.ts +0 -67
  222. package/src/package-cli.ts +0 -14
  223. package/src/plan-shape.test.ts +0 -91
  224. package/src/plan-shape.ts +0 -105
  225. package/src/planned-output-changes.test.ts +0 -85
  226. package/src/planned-output-changes.ts +0 -141
  227. package/src/plugin.test.ts +0 -96
  228. package/src/plugin.ts +0 -272
  229. package/src/plunge-timings.test.ts +0 -241
  230. package/src/plunge-timings.ts +0 -115
  231. package/src/plunge-up-failed.test.ts +0 -54
  232. package/src/pr-note.test.ts +0 -87
  233. package/src/preview-generated.test.ts +0 -124
  234. package/src/preview-tips.test.ts +0 -134
  235. package/src/preview-tips.ts +0 -128
  236. package/src/pulumi-up.test.ts +0 -581
  237. package/src/pulumi-up.ts +0 -1102
  238. package/src/pulumi-urn-node.test.ts +0 -94
  239. package/src/release-copy.test.ts +0 -162
  240. package/src/release-copy.ts +0 -223
  241. package/src/review-stack.test.ts +0 -254
  242. package/src/review-stack.ts +0 -266
  243. package/src/run-plan-flags.test.ts +0 -53
  244. package/src/run.test.ts +0 -540
  245. package/src/run.ts +0 -1129
  246. package/src/serializer.test.ts +0 -9
  247. package/src/serializer.ts +0 -15
  248. package/src/skills/chant-pulumi-plunge.md +0 -51
  249. package/src/skills/chant-pulumi-stack-export.md +0 -54
  250. package/src/skills/chant-pulumi.md +0 -83
  251. package/src/stack-export-snapshot.test.ts +0 -192
  252. package/src/stack-export-snapshot.ts +0 -312
  253. package/src/stack-ops.fake-binary.test.ts +0 -323
  254. package/src/stack-ops.test.ts +0 -511
  255. package/src/stack-ops.ts +0 -1082
  256. package/src/stack-outputs.ts +0 -66
  257. package/src/stack-references.test.ts +0 -96
  258. package/src/stack-references.ts +0 -110
  259. package/src/testdata/plunge-drift/README.md +0 -10
  260. package/src/testdata/plunge-drift/assets-drifted.ndjson +0 -3
  261. package/src/testdata/plunge-drift/component-unsupported.ndjson +0 -3
  262. package/src/testdata/plunge-drift/role-in-sync.ndjson +0 -3
  263. package/src/testdata/plunge-drift/settled-empty.ndjson +0 -2
  264. package/src/testdata/plunge-graph/Pulumi.yaml +0 -4
  265. package/src/testdata/plunge-graph/README.md +0 -12
  266. package/src/testdata/plunge-graph/engine-graph.json +0 -158
  267. package/src/testdata/plunge-graph/stack-export.json +0 -49
  268. package/src/testdata/plunge-member/Pulumi.yaml +0 -4
  269. package/src/testdata/plunge-member/README.md +0 -3
  270. package/src/testdata/plunge-member/stack-export.json +0 -480
  271. package/src/testdata/plunge-outputs/Pulumi.yaml +0 -9
  272. package/src/testdata/plunge-outputs/README.md +0 -7
  273. package/src/testdata/plunge-outputs/stack-export.json +0 -2003
  274. package/src/testdata/plunge-outputs/stack-output.json +0 -19
  275. package/src/testdata/pulumi-member/Pulumi.yaml +0 -2
  276. package/src/testdata/pulumi-member/README.md +0 -50
  277. package/src/testdata/pulumi-member/recording/Pulumi.dev.yaml +0 -19
  278. package/src/testdata/pulumi-member/recording/Pulumi.yaml +0 -7
  279. package/src/testdata/pulumi-member/recording/index.js +0 -47
  280. package/src/testdata/pulumi-member/recording/package-lock.json +0 -2707
  281. package/src/testdata/pulumi-member/recording/package.json +0 -9
  282. package/src/testdata/pulumi-member/stack-export.json +0 -746
  283. package/src/testdata/pulumi-outputs/Pulumi.yaml +0 -7
  284. package/src/testdata/pulumi-outputs/README.md +0 -9
  285. package/src/testdata/pulumi-outputs/preview-replaced.json +0 -2894
  286. package/src/testdata/pulumi-outputs/preview-settled.json +0 -2894
  287. package/src/testdata/pulumi-outputs/stack-export.json +0 -1919
  288. package/src/testdata/pulumi-outputs/stack-output.json +0 -19
  289. package/src/testdata/pulumi-preview/Pulumi.yaml +0 -7
  290. package/src/testdata/pulumi-preview/README.md +0 -9
  291. package/src/testdata/pulumi-preview/preview-create.json +0 -992
  292. package/src/testdata/pulumi-preview/preview.json +0 -2894
  293. package/src/testdata/pulumi-preview/stack-export.json +0 -1919
  294. package/src/testdata/pulumi-refresh/Pulumi.yaml +0 -7
  295. package/src/testdata/pulumi-refresh/README.md +0 -14
  296. package/src/testdata/pulumi-refresh/all.json +0 -3742
  297. package/src/testdata/pulumi-refresh/bucket-edited.json +0 -468
  298. package/src/testdata/pulumi-refresh/policy-deleted.json +0 -95
  299. package/src/testdata/pulumi-refresh/queue-edited.json +0 -250
  300. package/src/testdata/pulumi-refresh/role-same.json +0 -242
  301. package/src/testdata/pulumi-refresh/secret-edited.json +0 -247
  302. package/src/testdata/pulumi-refresh/stack-export.json +0 -1907
  303. package/src/testdata/pulumi-stream/README.md +0 -16
  304. package/src/testdata/pulumi-stream/preview-stream.ndjson +0 -42
  305. package/src/testdata/pulumi-stream/up-failed-plunge.ndjson +0 -5
  306. package/src/testdata/pulumi-unexported/Pulumi.yaml +0 -2
  307. package/src/testdata/pulumi-urn-node/Pulumi.yaml +0 -7
  308. package/src/testdata/pulumi-urn-node/README.md +0 -9
  309. package/src/testdata/pulumi-urn-node/preview.json +0 -2894
  310. package/src/testdata/pulumi-urn-node/stack-export.json +0 -1919
  311. package/src/trace-facts.test.ts +0 -38
  312. package/src/trace-facts.ts +0 -83
  313. package/src/values.ts +0 -147
  314. package/src/workspace-kinds.test.ts +0 -47
  315. package/src/workspace-member.test.ts +0 -127
  316. package/src/workspace-member.ts +0 -304
@@ -1,304 +0,0 @@
1
- /**
2
- * Reading a pulumi workspace member into the graph (#3179).
3
- *
4
- * `chant workspace graph` writes a reader project for a member of kind
5
- * `pulumi`, with `pulumi.member` in its config (see `workspace-kinds.json`).
6
- * The plugin's `buildRoots` hook calls {@link readPulumiMember} with the
7
- * `pulumi stack export` the index store holds for the member (#4546): the
8
- * `pulumi-up` capability writes it, secrets stripped, after each apply
9
- * (`./stack-export-snapshot.ts`, `refs/chant/snapshots` by default). When
10
- * the store holds none, the read takes the export the member has checked in,
11
- * at {@link PULUMI_EXPORT_FILE} in its directory. The graph read never runs
12
- * the program or `pulumi`: with no export there are no nodes, and
13
- * `meta.pulumiMember` says `exported: false` and why.
14
- *
15
- * The kind lived in the terraform lexicon until #4453 moved it here. The
16
- * ruling on #4450 lets chant run `pulumi preview` and `pulumi refresh
17
- * --preview-only` for a Pulumi member, so the old "chant never calls
18
- * `pulumi`" rule now covers this graph read only. The change set
19
- * (`./change-set.ts`) and drift (`./drift-record.ts`) run those two
20
- * commands, which change nothing, and the outputs read (`./member-outputs.ts`,
21
- * #4455) adds `pulumi stack output --json --show-secrets=false`; nothing else.
22
- *
23
- * Nodes are the export's resources, keyed `<label>/<urn tail>`, where the tail
24
- * is the URN after its stack and project (`aws:s3/bucket:Bucket::assets`).
25
- * That is the rule in `@intentius/chant/pulumi-urn` (#4456), which a
26
- * change set over `pulumi preview --json` and a drift record use too, so all
27
- * three put a resource on the same node. Provider resources
28
- * (`pulumi:providers:*`) and the root `pulumi:pulumi:Stack` are left out; the
29
- * resources that name them are not edged to them. Edges come from each
30
- * resource's `dependencies` and `parent`, kept only when the target is a node,
31
- * each with `grain: "instance"` (#4529): it joins two resources, not two
32
- * blocks of source. Inputs and outputs are not copied into the node, since an
33
- * export can hold secrets.
34
- *
35
- * A member on plunge may also check in {@link PULUMI_ENGINE_GRAPH_FILE}
36
- * beside the export: what `plunge graph --json --stack <stack>` printed
37
- * (#4529, the document designed on #4520). When it is there, each node whose
38
- * URN it lists gets the engine's facts (`IRNode.facts`: ownership, the
39
- * markers plunge's record says it wrote, how ownership is known, cloud IDs,
40
- * record versions), and its `property` edges join the graph with `grain:
41
- * "property"` and the property's name as `viaAttr`. Its `dependencies`,
42
- * `parent` and `provider` edges are not taken: the export already gives the
43
- * first two, and providers have no node. The read still runs nothing. A
44
- * stock member's `engine-graph.json`, if one is there, is not read.
45
- */
46
- import { existsSync, readFileSync } from "node:fs";
47
- import { basename, join } from "node:path";
48
- import { DECLARABLE_MARKER, type Declarable } from "@intentius/chant/declarable";
49
- import type { EntityReference } from "@intentius/chant/graph-ir";
50
- import type { EngineFacts } from "@intentius/chant/engine-facts";
51
- import { isPulumiNodeless, pulumiNodeKey } from "@intentius/chant/pulumi-urn";
52
- import { PULUMI_ENGINE_GRAPH_FILE, readPlungeEngineGraph } from "./engine-graph";
53
- import { pulumiMemberEngine } from "./member-engine";
54
-
55
- /** The conventional place of the export, in the member's directory. */
56
- export const PULUMI_EXPORT_FILE = "stack-export.json";
57
-
58
- export interface PulumiMemberConfig {
59
- /** The member's directory, absolute. */
60
- dir: string;
61
- /** Names the entities (`<label>/...`): the member's name. */
62
- label?: string;
63
- /** What runs the stack, when the config says; see `./run.ts`'s `pulumiMemberEngine`. The graph read ignores it. */
64
- engine?: "pulumi" | "plunge";
65
- /** The stack the drift read passes as `--stack`, when the config says. The graph read ignores it. */
66
- stack?: string;
67
- }
68
-
69
- /** What the read found, carried on the graph's `meta.pulumiMember`. */
70
- export interface PulumiMemberReport {
71
- /** The export read: relative to the member's directory, or `<store>:<env>/<key>` for the index store's. */
72
- export?: string;
73
- /** Where the export came from (#4546): the index store, or the checked-in file. Absent on a read before #4546. */
74
- exportSource?: "store" | "file";
75
- objects: number;
76
- /** False when the member has no readable export. */
77
- exported: boolean;
78
- /** Why nothing was read; set with `exported: false`. */
79
- reason?: string;
80
- /**
81
- * How many `deployment.pending_operations` the export records, set only
82
- * when there are some (#4468). Pulumi writes one for each step an update
83
- * started and never finished, so a non-zero count means the last update was
84
- * interrupted and the stack may hold resources its state does not. PUL002
85
- * reports it.
86
- */
87
- pendingOperations?: number;
88
- /**
89
- * The member's checked-in {@link PULUMI_ENGINE_GRAPH_FILE} (#4529), set
90
- * only for a member on plunge that has one. `read: false` with `reason`
91
- * when it could not be read; the graph is then the export's alone.
92
- */
93
- engineGraph?: PulumiMemberEngineGraphReport;
94
- }
95
-
96
- /** What the read took from a plunge member's engine graph (#4529). */
97
- export interface PulumiMemberEngineGraphReport {
98
- /** The file, relative to the member's directory. */
99
- file: string;
100
- read: boolean;
101
- /** Why it was not read; set with `read: false`. */
102
- reason?: string;
103
- /** The stack plunge read, from `meta.engineGraph.scope`. */
104
- stack?: string;
105
- /** When plunge's record read started, from `meta.engineGraph.observedAt`. */
106
- observedAt?: string;
107
- /** How many of the graph's nodes carry facts the document gave. */
108
- facts?: number;
109
- /** How many `property` edges joined the graph. */
110
- propertyEdges?: number;
111
- }
112
-
113
- interface ExportedResource {
114
- urn?: unknown;
115
- type?: unknown;
116
- parent?: unknown;
117
- dependencies?: unknown;
118
- }
119
-
120
- /** An export the index store held for the member, read by the caller (#4546). */
121
- export interface PulumiMemberStoredExport {
122
- doc: unknown;
123
- /** The store, for messages. */
124
- where: string;
125
- /** `<env>/<stack>__pulumi-export`. */
126
- key: string;
127
- }
128
-
129
- export function readPulumiMember(opts: { member: PulumiMemberConfig; stored?: PulumiMemberStoredExport }): {
130
- entities: Map<string, Declarable>;
131
- warnings: string[];
132
- report: PulumiMemberReport;
133
- /** The parsed export, when there is one that reads as JSON. The post-synth checks read it; `meta` does not carry it. */
134
- doc?: unknown;
135
- } {
136
- const { member } = opts;
137
- const label = member.label ?? basename(member.dir);
138
- const missing = (reason: string) => ({
139
- entities: new Map<string, Declarable>(),
140
- warnings: [`pulumi member "${label}" was not read: ${reason}`],
141
- report: { objects: 0, exported: false, reason } as PulumiMemberReport,
142
- });
143
-
144
- const file = join(member.dir, PULUMI_EXPORT_FILE);
145
- const stored = opts.stored;
146
- const exportName = stored ? `${stored.where}:${stored.key}` : PULUMI_EXPORT_FILE;
147
- if (!stored && !existsSync(file)) {
148
- return missing(
149
- `no export in the index store and no ${PULUMI_EXPORT_FILE} in the member; an apply through chant's pulumi-up writes the export to the store, or run \`pulumi stack export --file ${PULUMI_EXPORT_FILE}\` and check it in (the graph read does not run the program)`,
150
- );
151
- }
152
- let resources: ExportedResource[];
153
- let pendingOperations = 0;
154
- let doc: { deployment?: { resources?: unknown; pending_operations?: unknown } };
155
- try {
156
- doc = (stored ? stored.doc : JSON.parse(readFileSync(file, "utf-8"))) as { deployment?: { resources?: unknown; pending_operations?: unknown } };
157
- const list = doc?.deployment?.resources;
158
- if (list !== undefined && !Array.isArray(list)) return missing(`${exportName} has a deployment.resources that is not a list`);
159
- resources = (list ?? []) as ExportedResource[];
160
- const pending = doc?.deployment?.pending_operations;
161
- pendingOperations = Array.isArray(pending) ? pending.length : 0;
162
- } catch (e) {
163
- return missing(`${PULUMI_EXPORT_FILE} is not readable JSON: ${(e as Error).message}`);
164
- }
165
-
166
- const keyOf = new Map<string, string>();
167
- for (const r of resources) {
168
- if (typeof r?.urn !== "string" || typeof r.type !== "string" || isPulumiNodeless(r.type)) continue;
169
- const tail = pulumiNodeKey(r.urn);
170
- if (tail !== null) keyOf.set(r.urn, `${label}/${tail}`);
171
- }
172
-
173
- const warnings: string[] = [];
174
- const engine = pulumiMemberEngine(member.dir, member.engine).engine === "plunge" ? readMemberEngineGraph(member.dir, label, warnings) : undefined;
175
-
176
- const entities = new Map<string, Declarable>();
177
- let withFacts = 0;
178
- let propertyEdges = 0;
179
- for (const r of resources) {
180
- const key = typeof r?.urn === "string" ? keyOf.get(r.urn) : undefined;
181
- if (!key) continue;
182
- const urn = r.urn as string;
183
- const references = new Map<string, EntityReference>();
184
- const add = (to: string | undefined, via: string, grain: "instance" | "property") => {
185
- if (to && to !== key) references.set(`${to}|${via}|${grain}`, { to, viaAttr: via, grain });
186
- };
187
- const node = (u: unknown) => (typeof u === "string" ? keyOf.get(u) : undefined);
188
- add(node(r.parent), "parent", "instance");
189
- for (const d of Array.isArray(r.dependencies) ? r.dependencies : []) add(node(d), "dependencies", "instance");
190
- for (const e of engine?.propertyEdges.get(urn) ?? []) {
191
- const before = references.size;
192
- add(node(e.to), e.viaAttr, "property");
193
- if (references.size > before) propertyEdges++;
194
- }
195
- const entity = {
196
- lexicon: "pulumi",
197
- entityType: r.type as string,
198
- kind: "resource",
199
- props: {},
200
- references: [...references.values()],
201
- [DECLARABLE_MARKER]: true,
202
- } as unknown as Declarable;
203
- const facts = engine?.facts.get(urn);
204
- if (facts) {
205
- // Not enumerable: core's `entityFacts` reads it onto `IRNode.facts`, and a
206
- // chant older than #4529 does not project it into the node's attrs.
207
- Object.defineProperty(entity, "facts", { value: facts, enumerable: false });
208
- withFacts++;
209
- }
210
- entities.set(key, entity);
211
- }
212
-
213
- const report: PulumiMemberReport = { export: exportName, exportSource: stored ? "store" : "file", objects: entities.size, exported: true };
214
- if (pendingOperations > 0) report.pendingOperations = pendingOperations;
215
- if (engine) report.engineGraph = engine.report.read ? { ...engine.report, facts: withFacts, propertyEdges } : engine.report;
216
- return { entities, warnings, report, doc };
217
- }
218
-
219
- /**
220
- * A plunge member's checked-in engine graph, indexed by URN, or undefined
221
- * when the member has none. One that does not read leaves a warning and a
222
- * report saying why, and the graph is the export's alone.
223
- */
224
- function readMemberEngineGraph(
225
- dir: string,
226
- label: string,
227
- warnings: string[],
228
- ): { facts: Map<string, EngineFacts>; propertyEdges: Map<string, { to: string; viaAttr: string }[]>; report: PulumiMemberEngineGraphReport } | undefined {
229
- const file = join(dir, PULUMI_ENGINE_GRAPH_FILE);
230
- if (!existsSync(file)) return undefined;
231
- const unread = (reason: string) => {
232
- warnings.push(`pulumi member "${label}": ${PULUMI_ENGINE_GRAPH_FILE} was not read: ${reason}; the graph has no engine facts`);
233
- return { facts: new Map(), propertyEdges: new Map(), report: { file: PULUMI_ENGINE_GRAPH_FILE, read: false, reason } };
234
- };
235
- let parsed: unknown;
236
- try {
237
- parsed = JSON.parse(readFileSync(file, "utf-8")) as unknown;
238
- } catch (e) {
239
- return unread(`it is not readable JSON: ${(e as Error).message}`);
240
- }
241
- const read = readPlungeEngineGraph(parsed);
242
- if ("error" in read) return unread(read.error);
243
- const { graph } = read;
244
- const facts = new Map<string, EngineFacts>();
245
- for (const n of graph.nodes) if (n.facts) facts.set(n.urn, n.facts);
246
- const propertyEdges = new Map<string, { to: string; viaAttr: string }[]>();
247
- for (const e of graph.edges) {
248
- if (e.grain !== "property") continue;
249
- const list = propertyEdges.get(e.from) ?? [];
250
- list.push({ to: e.to, viaAttr: e.viaAttr });
251
- propertyEdges.set(e.from, list);
252
- }
253
- return {
254
- facts,
255
- propertyEdges,
256
- report: {
257
- file: PULUMI_ENGINE_GRAPH_FILE,
258
- read: true,
259
- ...(graph.scope ? { stack: graph.scope.stack } : {}),
260
- ...(graph.observedAt ? { observedAt: graph.observedAt } : {}),
261
- },
262
- };
263
- }
264
-
265
- /**
266
- * What the last member read in this process saw, for the post-synth checks
267
- * PUL003 to PUL015 (`./lint/post-synth/`). It holds the parsed export, so it
268
- * stays in the process and never reaches the graph's `meta`, which carries
269
- * only {@link PulumiMemberReport}.
270
- */
271
- export interface PulumiMemberRead {
272
- /** The member's directory, absolute. */
273
- dir: string;
274
- /** The label the entities are keyed by. */
275
- label: string;
276
- /** `pulumi.member.engine`, when the config sets it. */
277
- engine?: "pulumi" | "plunge";
278
- /** `pulumi.member.stack`, when the config sets it. */
279
- stack?: string;
280
- /** The parsed export, the index store's or the checked-in `stack-export.json`; undefined when there is none or it is not JSON. */
281
- doc?: unknown;
282
- }
283
-
284
- let lastRead: PulumiMemberRead | undefined;
285
-
286
- /** Left by the plugin's `buildRoots` beside the report; see {@link PulumiMemberRead}. */
287
- export function setLastMemberRead(read: PulumiMemberRead | undefined): void {
288
- lastRead = read;
289
- }
290
-
291
- export function lastMemberRead(): PulumiMemberRead | undefined {
292
- return lastRead;
293
- }
294
-
295
- let lastReport: PulumiMemberReport | undefined;
296
-
297
- /** The report of the read in this process, left for `graphMeta` (see the aws member reader). */
298
- export function setLastMemberReport(report: PulumiMemberReport | undefined): void {
299
- lastReport = report;
300
- }
301
-
302
- export function lastMemberReport(): PulumiMemberReport | undefined {
303
- return lastReport;
304
- }