@ppdostudio/ppdo-cli 1.0.0-beta.1 → 1.0.0-beta.2

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 (141) hide show
  1. package/CHANGELOG.md +31 -1
  2. package/README.md +22 -3
  3. package/THIRD-PARTY-NOTICES +1 -0
  4. package/dist/bin.js +2 -2
  5. package/dist/chunks/{ado-XAHQWYNQ.js → ado-OTSVKTOE.js} +6 -6
  6. package/dist/chunks/{api-KN24TLH6.js → api-IRGGH5DJ.js} +1 -1
  7. package/dist/chunks/{api-7RAWLIQV.js → api-TZJXGWWQ.js} +1 -1
  8. package/dist/chunks/{auth-VZSJMSMF.js → auth-7CDWOYJE.js} +1 -1
  9. package/dist/chunks/{azCli-AEZK2RBQ.js → azCli-UEDQHRLP.js} +1 -1
  10. package/dist/chunks/batch-LKWCBKAB.js +2 -0
  11. package/dist/chunks/{build-LSQEAEFK.js → build-PBPXO3GJ.js} +1 -1
  12. package/dist/chunks/bulk-NY5XX752.js +2 -0
  13. package/dist/chunks/chunk-2IUXH534.js +2 -0
  14. package/dist/chunks/{chunk-STWQDANK.js → chunk-3L7657R3.js} +1 -1
  15. package/dist/chunks/{chunk-MGZDEW3X.js → chunk-46KBBWEH.js} +1 -1
  16. package/dist/chunks/{chunk-B4FPKDMH.js → chunk-6NBCHK6X.js} +1 -1
  17. package/dist/chunks/chunk-6VLFO5FJ.js +7 -0
  18. package/dist/chunks/{chunk-BCAXUZIO.js → chunk-B3TJ3RJN.js} +1 -1
  19. package/dist/chunks/chunk-BG2OIOSN.js +2 -0
  20. package/dist/chunks/{chunk-MZEUD7ET.js → chunk-BWOEIEFY.js} +1 -1
  21. package/dist/chunks/chunk-ELSYHAYC.js +2 -0
  22. package/dist/chunks/chunk-FOEBNCSD.js +3 -0
  23. package/dist/chunks/{chunk-TM3M633T.js → chunk-GLU4X7PT.js} +2 -2
  24. package/dist/chunks/{chunk-HIW2K6OP.js → chunk-GQLXEQVQ.js} +1 -1
  25. package/dist/chunks/{chunk-4KP27OCL.js → chunk-GY6BUIDP.js} +1 -1
  26. package/dist/chunks/chunk-HJQJ77F2.js +3 -0
  27. package/dist/chunks/chunk-I7MHI5CU.js +151 -0
  28. package/dist/chunks/chunk-ITP35SAY.js +2 -0
  29. package/dist/chunks/{chunk-LL4XQ3L7.js → chunk-J67P6QFC.js} +2 -2
  30. package/dist/chunks/{chunk-WNQERCOO.js → chunk-KBZI5UDL.js} +1 -1
  31. package/dist/chunks/chunk-MNGA7IHQ.js +4 -0
  32. package/dist/chunks/{chunk-MK6QZ4ES.js → chunk-P4IFCLVF.js} +1 -1
  33. package/dist/chunks/chunk-Q2RD4TRK.js +2 -0
  34. package/dist/chunks/chunk-S6NK6GX2.js +5 -0
  35. package/dist/chunks/chunk-SWXCK5C2.js +2 -0
  36. package/dist/chunks/chunk-T4IH34D7.js +2 -0
  37. package/dist/chunks/{chunk-WMDKJRDC.js → chunk-TCLZ4XM6.js} +1 -1
  38. package/dist/chunks/chunk-VC7ADQ6E.js +2 -0
  39. package/dist/chunks/{chunk-I3TMFYRJ.js → chunk-XUHLW6B2.js} +1 -1
  40. package/dist/chunks/{commands-GRWX32IX.js → commands-EOUU353W.js} +1 -1
  41. package/dist/chunks/component-JCIJQELN.js +2 -0
  42. package/dist/chunks/{config-UKI5TBH5.js → config-WV3NZGTI.js} +1 -1
  43. package/dist/chunks/connection-L6CUFUPJ.js +2 -0
  44. package/dist/chunks/connref-IT6K56UT.js +2 -0
  45. package/dist/chunks/convert-ILMJ2HHN.js +5 -0
  46. package/dist/chunks/customizations-AX7ZSXCK.js +2 -0
  47. package/dist/chunks/data-UWOV3LBO.js +5 -0
  48. package/dist/chunks/dependency-V4ZJIWQL.js +3 -0
  49. package/dist/chunks/{discovery-IWAWXXWF.js → discovery-PSGWFMJH.js} +1 -1
  50. package/dist/chunks/{dv-C45WDXRG.js → dv-SD5LTNZJ.js} +109 -48
  51. package/dist/chunks/{env-GL5ZPAZI.js → env-6RZCHQUC.js} +2 -2
  52. package/dist/chunks/environment-IBLJHUAL.js +2 -0
  53. package/dist/chunks/{environments-VZWNFJYE.js → environments-3P2I4QUC.js} +1 -1
  54. package/dist/chunks/envvar-KJ2TUZGJ.js +2 -0
  55. package/dist/chunks/fanout-2WQYFUWL.js +2 -0
  56. package/dist/chunks/{fetchxml-FWUQZP4M.js → fetchxml-M6EOF7N6.js} +1 -1
  57. package/dist/chunks/functions-NILMLS4R.js +2 -0
  58. package/dist/chunks/{graph-OK24IOUV.js → graph-NO2OT2TL.js} +1 -1
  59. package/dist/chunks/{group-TLGLTTUG.js → group-ISSJ4H2A.js} +2 -2
  60. package/dist/chunks/history-JPMLQDJI.js +2 -0
  61. package/dist/chunks/{identity-SRTOEQVC.js → identity-SBQNHSBF.js} +1 -1
  62. package/dist/chunks/init-X2VEK4T2.js +2 -0
  63. package/dist/chunks/jobs-XC7EYPBP.js +2 -0
  64. package/dist/chunks/lifecycle-2F7MF6EP.js +2 -0
  65. package/dist/chunks/{main-HOYSLMHZ.js → main-J3O5YMIY.js} +2 -2
  66. package/dist/chunks/metadata-NZFQIAAG.js +2 -0
  67. package/dist/chunks/metadataCreate-XSHK32TR.js +2 -0
  68. package/dist/chunks/{msalUser-3PBGT655.js → msalUser-KC75VDVV.js} +1 -1
  69. package/dist/chunks/names-N5JRXO33.js +2 -0
  70. package/dist/chunks/{pat-KGOBISLG.js → pat-PCMOZYM5.js} +1 -1
  71. package/dist/chunks/{pipelines-62CVDRXV.js → pipelines-OCHSIQ2E.js} +1 -1
  72. package/dist/chunks/pluginRegister-LEVZNDZN.js +4 -0
  73. package/dist/chunks/{plugins-SBMDFXVA.js → plugins-TEME2R77.js} +1 -1
  74. package/dist/chunks/{policies-BZR5437X.js → policies-EWCANNBE.js} +1 -1
  75. package/dist/chunks/{pools-I4NVR67Z.js → pools-54KMEL5D.js} +1 -1
  76. package/dist/chunks/process-KR7LIXZB.js +2 -0
  77. package/dist/chunks/{projects-GXIQO7HV.js → projects-LPVDFLPC.js} +1 -1
  78. package/dist/chunks/{provider-FN7TXWRE.js → provider-D7DMMAS6.js} +1 -1
  79. package/dist/chunks/{prs-F2EVQJRV.js → prs-C4EKGJWA.js} +1 -1
  80. package/dist/chunks/records-C4RLQXFK.js +2 -0
  81. package/dist/chunks/{run-LNEOCXZA.js → run-27MYTWHY.js} +1 -1
  82. package/dist/chunks/{run-SB4QN5Q4.js → run-46PEJS3S.js} +1 -1
  83. package/dist/chunks/{run-ICS4FNZA.js → run-7L6W2YWJ.js} +1 -1
  84. package/dist/chunks/run-CD3ZOB5V.js +4 -0
  85. package/dist/chunks/{run-APD3TRCW.js → run-EUNN6OZO.js} +1 -1
  86. package/dist/chunks/{run-H2OLE76P.js → run-JDNEQMJC.js} +1 -1
  87. package/dist/chunks/{run-G2MVOV3C.js → run-T3IIJ7SK.js} +1 -1
  88. package/dist/chunks/{run-XRPU3YZF.js → run-ZHIDOKQH.js} +1 -1
  89. package/dist/chunks/{runtime-MIU5CS5B.js → runtime-FJJPTBEE.js} +1 -1
  90. package/dist/chunks/security-SBIAK6QD.js +2 -0
  91. package/dist/chunks/{service-4VHAPTA6.js → service-4N3YP4Z7.js} +1 -1
  92. package/dist/chunks/{service-RFKOKM72.js → service-HASXLUGE.js} +1 -1
  93. package/dist/chunks/{services-4BORTJPM.js → services-C6G4XRXR.js} +1 -1
  94. package/dist/chunks/{skills-6O2GSTU4.js → skills-FW4F3EIW.js} +1 -1
  95. package/dist/chunks/solution-CNBNIS7Z.js +2 -0
  96. package/dist/chunks/solutionExport-Y524HMGN.js +2 -0
  97. package/dist/chunks/{solutionfiles-VWZHFZZ6.js → solutionfiles-2TP3Y2RW.js} +1 -1
  98. package/dist/chunks/{spn-2RZJLCML.js → spn-YSYMDTOI.js} +1 -1
  99. package/dist/chunks/{users-JIBQKPYA.js → users-Q7BJKBPP.js} +1 -1
  100. package/dist/chunks/{vargroups-Q2KG7LHR.js → vargroups-GNZBODVJ.js} +1 -1
  101. package/dist/chunks/{whoami-V54TCLT5.js → whoami-6G6UFTNS.js} +1 -1
  102. package/dist/chunks/{workitems-UG5O3EGB.js → workitems-2IOGD3EL.js} +1 -1
  103. package/package.json +7 -3
  104. package/schema/reference-data.schema.json +192 -0
  105. package/skills/ppdo-cli/SKILL.md +1 -0
  106. package/skills/ppdo-cli-data/SKILL.md +669 -0
  107. package/skills/ppdo-cli-dataverse/SKILL.md +6 -0
  108. package/skills/ppdo-cli-plugins/PluginRegistration.cs +229 -0
  109. package/skills/ppdo-cli-plugins/SKILL.md +95 -0
  110. package/skills/ppdo-cli-plugins/reference.md +72 -0
  111. package/dist/chunks/batch-EZPKLWEI.js +0 -4
  112. package/dist/chunks/bulk-7FZCDH5U.js +0 -2
  113. package/dist/chunks/chunk-5SBBTR3Y.js +0 -2
  114. package/dist/chunks/chunk-BODUSF3V.js +0 -2
  115. package/dist/chunks/chunk-DVQ7OYIJ.js +0 -2
  116. package/dist/chunks/chunk-KBQYSAJX.js +0 -2
  117. package/dist/chunks/chunk-OXZG44O5.js +0 -2
  118. package/dist/chunks/chunk-PYTSDUPY.js +0 -2
  119. package/dist/chunks/chunk-RC5VPVGC.js +0 -2
  120. package/dist/chunks/chunk-TXVNEV3M.js +0 -3
  121. package/dist/chunks/component-TCL43QXZ.js +0 -2
  122. package/dist/chunks/connection-QNXMJGHZ.js +0 -2
  123. package/dist/chunks/connref-U3CMQ64O.js +0 -2
  124. package/dist/chunks/customizations-VNEASPWI.js +0 -7
  125. package/dist/chunks/dependency-U6OQA5PS.js +0 -3
  126. package/dist/chunks/environment-FPS4AFM5.js +0 -2
  127. package/dist/chunks/envvar-52V6K6LF.js +0 -2
  128. package/dist/chunks/fanout-Q3656CCP.js +0 -2
  129. package/dist/chunks/functions-SNCK2IYV.js +0 -2
  130. package/dist/chunks/history-67SQS54S.js +0 -2
  131. package/dist/chunks/jobs-2ZPBDDHT.js +0 -2
  132. package/dist/chunks/lifecycle-OJRM7K2I.js +0 -2
  133. package/dist/chunks/metadata-WYVJ7NP7.js +0 -2
  134. package/dist/chunks/metadataCreate-PBA3KH3A.js +0 -2
  135. package/dist/chunks/names-ZRM6SAYU.js +0 -2
  136. package/dist/chunks/process-WS76WV3T.js +0 -2
  137. package/dist/chunks/records-7IQET422.js +0 -2
  138. package/dist/chunks/run-KP2SNX2A.js +0 -3
  139. package/dist/chunks/security-RC3EI7CZ.js +0 -2
  140. package/dist/chunks/solution-3WUUDYF3.js +0 -2
  141. package/dist/chunks/solutionExport-GTBTHG2D.js +0 -2
package/CHANGELOG.md CHANGED
@@ -7,6 +7,35 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [1.0.0-beta.2] - 2026-11-19
11
+
12
+ ### Added
13
+
14
+ - `dv plugin register` registers a plugin DLL from attributes on its classes in a development environment: assembly, plugin types, steps, images, Custom APIs with their parameters and properties, and workflow activities, with `--dry-run`, `--solution` and the part options `--assembly`, `--steps` and `--apis`.
15
+ - `dv plugin inspect` reads and checks the registration attributes of a plugin DLL, without .NET.
16
+ - `dv plugin migrate` prints registration attributes for classes that use spkl attributes, with the step ids of the environment.
17
+ - `dv plugin register` also reads spkl `CrmPluginRegistration` attributes, so a spkl project registers without code changes.
18
+ - The `ppdo-cli-plugins` skill gives agents the attribute class file (`PluginRegistration.cs`) and the procedures to set up, change and deploy plugin registrations.
19
+ - `dv data export` writes the configuration data of a solution as YAML files in a `reference-data` folder (one file for each table or for each record, many-to-many links, and the files of file and image columns), with `--check` to find out-of-date files. A record is identified by its GUID, and a lookup is the GUID of its target.
20
+ - `dv data import` makes an environment equal to a `reference-data` folder and writes only the differences, with a plan (`--check`) and `--overlay` for the values of one environment (also a GUID that is different in that environment). It creates each record with the GUID of the file, and it never deletes.
21
+ - `dv data delete` deletes the records and removes the links that the delete modes of the schema give, after a person types `delete` at the terminal, or with `--yes` in a pipeline; `--check` lists each delete.
22
+ - `dv data convert` converts a Configuration Migration Tool `data.xml` and its schema to a `reference-data` folder; it reads the metadata of the environment (reads only) for the schema names and order of many-to-many relationships, and leaves out, with a warning, columns that cannot be written and relationships to tables outside the CMT schema, so the first export needs no hand edits.
23
+ - A `dv data` schema file accepts a full CMT `<fetch>` document in `fetchXmlFilter` and uses the `<filter>` elements of its `<entity>`.
24
+ - `dv data export` keeps the records and links deleted in the source environment in a deletion log, `data/.deleted`, by GUID, for tables and relationships with the delete mode `manifest` or `mirror`; the log only grows, and `dv data delete` deletes the logged records and removes the logged links in the target.
25
+ - `dv data delete` continues after a delete or link removal that Dataverse refuses, and reports it in `failures`; `--delete-log-file <file>` writes each record and link that it deleted to a JSON file.
26
+ - `dv data init` adds a schema file for each table from the metadata of the environment.
27
+ - `dv data export`, `import` and `convert` keep the attachments of notes and email attachments (`annotation.documentbody`, `activitymimeattachment.body`) as files in `data/files`, not as base64 text in the YAML.
28
+ - A `dv data` schema file can set the path of each file in `data/files` with a file name pattern (`files.name` for the table, `file` for one column), for example `"{objectid.name}/{$filename}"`.
29
+ - `dv data export`, `dv data import` and `dv data delete` show their progress on stderr with `--verbose`, and `--log-file <file>` keeps the progress, the retries, the result and the error in a file.
30
+ - The `ppdo-cli-data` skill gives agents the `dv data` commands, the `reference-data` folder and file formats, overlays, deletes, errors and pipeline steps.
31
+ - `schema/reference-data.schema.json` describes the format of a `dv data` schema file, so an editor can check it and complete its properties.
32
+
33
+ ### Fixed
34
+
35
+ - A `.ppdo-cli.json` that pins no environment (for example one with only a `plugins` section) no longer stops commands with "names no environment"; the search goes on up to the git root, then to the default.
36
+ - `env pin` keeps the other keys of `.ppdo-cli.json`, such as `plugins`, instead of writing only the pins.
37
+ - `env unpin` removes only the pins, and deletes `.ppdo-cli.json` only when nothing else is in it.
38
+
10
39
  ## [1.0.0-beta.1] - 2026-11-12
11
40
 
12
41
  ### Added
@@ -61,6 +90,7 @@ First public release, on npm as `@ppdostudio/ppdo-cli`. Free to use under the pp
61
90
  - The config is JSON, with a JSON schema for editors.
62
91
  - `THIRD-PARTY-NOTICES` lists the open source packages bundled into ppdo-cli and their licences.
63
92
 
64
- [Unreleased]: https://github.com/PPDOStudio/ppdo-cli-release/compare/v1.0.0-beta.1...HEAD
93
+ [Unreleased]: https://github.com/PPDOStudio/ppdo-cli-release/compare/v1.0.0-beta.2...HEAD
94
+ [1.0.0-beta.2]: https://github.com/PPDOStudio/ppdo-cli-release/releases/tag/v1.0.0-beta.2
65
95
  [1.0.0-beta.1]: https://github.com/PPDOStudio/ppdo-cli-release/releases/tag/v1.0.0-beta.1
66
96
  [1.0.0-beta.0]: https://github.com/PPDOStudio/ppdo-cli-release/releases/tag/v1.0.0-beta.0
package/README.md CHANGED
@@ -241,7 +241,7 @@ A JSON schema for the file ships with the package as `schema/ppdo-cli.schema.jso
241
241
 
242
242
  A group whose `identity` names an identity that isn't in the file is still read: commands that use it stop with "no identity named …". Add the identity again with `ppdo-cli identity add` (for a writable group, that needs a person at a terminal).
243
243
 
244
- **`.ppdo-cli.json`** pins environments for one repo, by name. ppdo-cli looks for it from the current folder up to the git root (outside a git repo, only in the current folder). It can also hold a `$schema`, which `env pin` keeps:
244
+ **`.ppdo-cli.json`** pins environments for one repo, by name. ppdo-cli uses the nearest one that pins an environment, from the current folder up to the git root (outside a git repo, only in the current folder); a file that pins none, for example one that holds only a `plugins` section, is skipped. `env pin` changes only the pins and keeps the other keys (`$schema`, `plugins`); `env unpin` removes the pins and deletes the file only when nothing else is in it:
245
245
 
246
246
  ```json
247
247
  {
@@ -325,13 +325,18 @@ In PowerShell, quote values that contain commas, such as `--env 'dev,uat'` or `-
325
325
  | `dv solution create \| update \| patch \| add-component \| remove-component \| promote` | The solution lifecycle without pac; `dv publisher list \| create` for publishers. |
326
326
  | `dv component ... \| dependency list` | A component's layers, dependencies, unpublished changes and names; dependency rows for solutions or one component. |
327
327
  | `dv envvar \| connref \| connection` | Environment variables and connection references (with typed `set`), and the connections available. |
328
- | `dv workflow \| plugin \| job` | Flows and processes (on/off, runs, swap-connref), plugin registrations, traces and stats, and system jobs. |
328
+ | `dv workflow \| plugin \| job` | Flows and processes (on/off, runs, swap-connref), plugin registrations, traces and stats, and system jobs. `dv plugin register` registers a plugin DLL from attributes on its classes (or spkl attributes) in a development environment. |
329
329
  | `dv org \| setting \| team \| role \| user \| access` | Environment details and settings, security roles and privileges, and why someone can see a record. |
330
330
  | `dv view \| form \| webresource` | Edit views and forms as XML files and push web resources from files. |
331
331
  | `dv solution unpack <file.zip>` | Unpack a solution into a source folder without pac. The layout and bytes match `pac solution unpack`, only changed files are written, and `--check` exits 6 when the folder differs. |
332
332
  | `dv solution pack <folder> --save <file.zip>` | Pack a source folder into a solution zip without pac, with the same bytes every time. A `.cdsproj` folder builds its PCF and plug-in references first; `--map` reads files from a mapping file. |
333
333
  | `dv solution clone <uniquename>` | Export a solution (unmanaged and managed together) into a new `.cdsproj` project with the source in `src/`. |
334
334
  | `dv solution sync [folder]` | Re-export the folder's solution and write only what changed, deleting files of removed components; `--check` exits 6 when the folder is out of date. |
335
+ | `dv data export <folder>` | Write the configuration data of a solution as YAML files: one file for each table (or for each record), many-to-many links, and the files of file and image columns; `--check` exits 6 when the folder is out of date. |
336
+ | `dv data import <folder>` | Make an environment equal to the files and write only the differences (CreateMultiple, UpdateMultiple); `--check` shows the plan; `--overlay` for values of one environment. It never deletes. |
337
+ | `dv data delete <folder>` | Delete the records and remove the links that the delete modes of the schema give, after a person types `delete` (or `--yes` in a pipeline); `--check` lists each delete; `--delete-log-file` keeps what was deleted. |
338
+ | `dv data convert <source> <folder>` | Convert a Configuration Migration Tool `data.xml` (a file, a folder or a `.zip`) and its schema to the new format, with the relationship names and the columns from the metadata of the environment (reads only), so the first export needs no hand edits. |
339
+ | `dv data init <folder> --table <name>` | Add a schema file for each table, from the metadata of the environment. |
335
340
  | `ado api <method> <path>` | Any Azure DevOps REST request; `{project}` is replaced with the environment's project, and `--host` reaches the other DevOps hosts. |
336
341
  | `ado project list`, `ado repo list \| get \| file \| tree \| branches \| commits \| diff \| policies` | Projects and Git repositories: a file at a branch, tag or commit, commit history, a unified diff between two refs (`--stat` for the file list), and branch policies. |
337
342
  | `ado pipeline list \| get \| run \| stages`, `ado run list \| get \| logs \| retry \| cancel` | Pipelines and runs: queue a run (`--wait`, `--skip-stage`, `--only-stage`), its stages and errors, step logs (`--failed-only`, `--save`), and re-running failed stages. |
@@ -343,6 +348,20 @@ In PowerShell, quote values that contain commas, such as `--env 'dev,uat'` or `-
343
348
 
344
349
  Deployment commands, which replace the Studio runners, are coming next.
345
350
 
351
+ ## Configuration data
352
+
353
+ `dv data` keeps the configuration data (reference data) of a solution in source control as YAML files, as an alternative to `pac data export`, `pac data import` and the Configuration Migration Tool. A folder such as `MySolution/reference-data` has `schema/<table>.yaml`, one file for each table that you write (`dv data init` makes the first version), and `data/`, which the export writes. One changed value is one changed line in a pull request.
354
+
355
+ ```
356
+ ppdo-cli dv data init MySolution/reference-data --table contoso_category,contoso_item --env dev
357
+ ppdo-cli dv data export MySolution/reference-data --env dev
358
+ ppdo-cli dv data import MySolution/reference-data --env test --check
359
+ ppdo-cli dv data import MySolution/reference-data --env test
360
+ ppdo-cli dv data delete MySolution/reference-data --env test --check
361
+ ```
362
+
363
+ A record is identified by its GUID, which is the same in each environment (the import creates a record with the GUID of the file), and a lookup is the GUID of its target; an overlay gives a GUID that is different in one environment, such as a currency or a team. The import reads the target, compares each record, and sends only the differences: an import with nothing different sends no write, and an import that stops can run again. It stops before the first write if a lookup has no target, and it never deletes. Deletes are a separate command, `dv data delete`, which asks a person to confirm (or takes `--yes` in a pipeline) and deletes only in a table or relationship whose schema file has a delete mode (`manifest` or `mirror`). In such a table, the export moves each record deleted in the development environment out of the data file and into a deletion log, `data/.deleted`, which only grows: `dv data delete` deletes the logged records (by GUID) in each target, a delete that Dataverse refuses does not stop the other deletes, and the log keeps the history in source control. `--verbose` shows the progress on stderr (each table, wave, request, failure and retry), and `--log-file <file>` keeps it in a file with the result, for example as a pipeline artifact. `dv data convert` makes the new files from a `ReferenceData` folder and the metadata of the source environment. The format of a schema file is a [JSON Schema](https://raw.githubusercontent.com/PPDOStudio/ppdo-cli-release/main/schema/reference-data.schema.json) that an editor can use; the `ppdo-cli-data` skill has the full rules.
364
+
346
365
  ## Agent skills
347
366
 
348
367
  ```
@@ -353,7 +372,7 @@ ppdo-cli skills install --target claude --link # link instead of copy
353
372
 
354
373
  `--link` (a junction on Windows, a symlink elsewhere) suits a local build: the agents always see the skills in your clone. `ppdo-cli skills uninstall` removes only the copies or links ppdo-cli made.
355
374
 
356
- The bundled skills are `ppdo-cli` (load first: accounts, modes, exit codes, output), `ppdo-cli-dataverse` (data, metadata, solutions and source folders, diagnosis) and `ppdo-cli-devops` (repos, pull requests, work items, pipelines, failed runs). Together they list every `dv`, `ado` and `graph` command with all of its options.
375
+ The bundled skills are `ppdo-cli` (load first: accounts, modes, exit codes, output), `ppdo-cli-data` (configuration data with `dv data`: the folder, the file formats, overlays, deletes, pipelines), `ppdo-cli-dataverse` (data, metadata, solutions and source folders, diagnosis), `ppdo-cli-devops` (repos, pull requests, work items, pipelines, failed runs) and `ppdo-cli-plugins` (plugin registration attributes and `dv plugin register`). Together they list every `dv`, `ado` and `graph` command with all of its options.
357
376
 
358
377
  ## License
359
378
 
@@ -23,3 +23,4 @@ lodash.once 4.1.1 MIT https://github.com/lodash/lodash
23
23
  ms 2.1.3 MIT https://github.com/vercel/ms
24
24
  safe-buffer 5.2.1 MIT https://github.com/feross/safe-buffer
25
25
  semver 7.8.6 ISC https://github.com/npm/node-semver
26
+ yaml 2.9.1 ISC https://github.com/eemeli/yaml
package/dist/bin.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
3
- import{a as t}from"./chunks/chunk-WMDKJRDC.js";import{a as e,k as s}from"./chunks/chunk-WXOTXJNG.js";import"./chunks/chunk-ZHHVG47C.js";import d from"node:module";d.enableCompileCache?.();async function a(){let o=process.argv.slice(2);if(o.length===1&&(o[0]==="--version"||o[0]==="-V")){process.stdout.write(`ppdo-cli ${t}
4
- `),process.exitCode=0;return}let{main:n}=await import("./chunks/main-HOYSLMHZ.js");process.once("SIGINT",()=>{process.stderr.write(`{"error":"interrupted"}
3
+ import{a as t}from"./chunks/chunk-TCLZ4XM6.js";import{a as e,k as s}from"./chunks/chunk-WXOTXJNG.js";import"./chunks/chunk-ZHHVG47C.js";import d from"node:module";d.enableCompileCache?.();async function a(){let o=process.argv.slice(2);if(o.length===1&&(o[0]==="--version"||o[0]==="-V")){process.stdout.write(`ppdo-cli ${t}
4
+ `),process.exitCode=0;return}let{main:n}=await import("./chunks/main-J3O5YMIY.js");process.once("SIGINT",()=>{process.stderr.write(`{"error":"interrupted"}
5
5
  `),process.exit(130)}),process.stdout.on("error",r=>{r.code==="EPIPE"&&process.exit(0),s(new e(`cannot write to stdout: ${r.message}`)),process.exit(1)}),process.exitCode=await n(o)}a();
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
2
- import{d as P,e as r,i as d,j as l,k as j,l as S,n as U,o as m,q as E,r as o}from"./chunk-BALEFXOL.js";import{a as z}from"./chunk-MTF66YXU.js";import{b as O}from"./chunk-WXOTXJNG.js";import"./chunk-ZHHVG47C.js";var N=100;function p(a){return a.addOption(new r("--limit <n>",`return at most n items (default ${N})`).argParser(d)).option("--all","no cap")}function T(a){let t=a;for(;t.parent;)t=t.parent;return t}function f(a,t,e=!1){return a.hook("preAction",(s,i)=>{let G=T(i).rawArgs??[],L=w=>G.findIndex(y=>y===w||y.startsWith(w+"=")),v=t.filter(w=>i.getOptionValueSource(E(w.replace(/^--/,"")))==="cli").sort((w,y)=>L(w)-L(y)),x=`run: ${[T(i).name(),...U(i)].join(" ")} --help`;if(v.length>1)throw new O(`argument ${v[1]}: not allowed with argument ${v[0]}`,{hint:x});if(e&&!v.length)throw new O(`one of the arguments ${t.join(" ")} is required`,{hint:x})}),a}var n=(a,t)=>async e=>t(await a())(e);var $=()=>import("./users-JIBQKPYA.js"),b=()=>import("./vargroups-Q2KG7LHR.js"),k=()=>import("./environments-VZWNFJYE.js"),q=()=>import("./pools-I4NVR67Z.js");function A(a){o(m(a,"user","users and groups in the organization"),"get","R","a user by email, UPN or full display name",{description:`a user by email, UPN or full display name ('me' for the signed-in account)
2
+ import{d as P,e as r,i as d,j as l,k as j,l as S,n as U,o as m,q as E,r as o}from"./chunk-BALEFXOL.js";import{a as z}from"./chunk-MTF66YXU.js";import{b as O}from"./chunk-WXOTXJNG.js";import"./chunk-ZHHVG47C.js";var N=100;function p(a){return a.addOption(new r("--limit <n>",`return at most n items (default ${N})`).argParser(d)).option("--all","no cap")}function T(a){let t=a;for(;t.parent;)t=t.parent;return t}function f(a,t,e=!1){return a.hook("preAction",(s,i)=>{let G=T(i).rawArgs??[],L=w=>G.findIndex(y=>y===w||y.startsWith(w+"=")),v=t.filter(w=>i.getOptionValueSource(E(w.replace(/^--/,"")))==="cli").sort((w,y)=>L(w)-L(y)),x=`run: ${[T(i).name(),...U(i)].join(" ")} --help`;if(v.length>1)throw new O(`argument ${v[1]}: not allowed with argument ${v[0]}`,{hint:x});if(e&&!v.length)throw new O(`one of the arguments ${t.join(" ")} is required`,{hint:x})}),a}var n=(a,t)=>async e=>t(await a())(e);var $=()=>import("./users-Q7BJKBPP.js"),b=()=>import("./vargroups-GNZBODVJ.js"),k=()=>import("./environments-3P2I4QUC.js"),q=()=>import("./pools-54KMEL5D.js");function A(a){o(m(a,"user","users and groups in the organization"),"get","R","a user by email, UPN or full display name",{description:`a user by email, UPN or full display name ('me' for the signed-in account)
3
3
 
4
4
  Returns id, name, upn, mail, descriptor (the subject descriptor), active, kind (User or
5
5
  Group) and object_id (Entra). Matching is exact: part of a name finds nobody.`}).argument("<email|upn|name|me>").argKey("email|upn|name|me","who").handler(n($,i=>i.getUser));let t=m(a,"vargroup","variable groups (secret values are never shown)");p(o(t,"list","R","variable groups in the project").option("--name <pattern>","name filter; a trailing * is a wildcard")).handler(n(b,i=>i.list)),o(t,"get","R","one variable group").argument("<group>","variable group id or name").argKey("group","vargroup").handler(n(b,i=>i.getGroup)),o(t,"create","W","create a variable group",{description:`create a variable group
@@ -14,7 +14,7 @@ Without it, a run that deploys to the environment waits for someone to permit it
14
14
 
15
15
  From the pool's job requests: wait = queued until an agent was assigned; run = assigned
16
16
  until finished; peak = most jobs running at the same time. --top adds the pipelines that
17
- used the pool most.`}).argument("<pool>","pool id or name").option("--since <when>","30m, 12h, 7d, 2w or a date (default 7d)").addOption(new r("--limit <n>","job requests to read (default 5000)").argParser(d)).addOption(new r("--top <n>","busiest pipelines to show (default 5)").argParser(d)).handler(n(q,i=>i.usage))}var u=()=>import("./pipelines-62CVDRXV.js"),Q=["succeeded","partiallySucceeded","failed","canceled"],Y="manual, individualCI, batchedCI, schedule, scheduleForced, pullRequest, resourceTrigger, buildCompletion, triggered, userCreated, validateShelveset, checkInShelveset";function C(a){let t=m(a,"pipeline","pipelines: list, inspect, run");p(o(t,"list","R","pipelines in the project").option("--folder <path>","only pipelines in this folder")).handler(n(u,s=>s.list)),o(t,"get","R","one pipeline").argument("<pipeline>","pipeline id, name or URL").handler(n(u,s=>s.getPipeline)),f(o(t,"run","W","queue a run",{description:`--param sets YAML parameters (templateParameters); --variable sets runtime variables.
17
+ used the pool most.`}).argument("<pool>","pool id or name").option("--since <when>","30m, 12h, 7d, 2w or a date (default 7d)").addOption(new r("--limit <n>","job requests to read (default 5000)").argParser(d)).addOption(new r("--top <n>","busiest pipelines to show (default 5)").argParser(d)).handler(n(q,i=>i.usage))}var u=()=>import("./pipelines-OCHSIQ2E.js"),Q=["succeeded","partiallySucceeded","failed","canceled"],Y="manual, individualCI, batchedCI, schedule, scheduleForced, pullRequest, resourceTrigger, buildCompletion, triggered, userCreated, validateShelveset, checkInShelveset";function C(a){let t=m(a,"pipeline","pipelines: list, inspect, run");p(o(t,"list","R","pipelines in the project").option("--folder <path>","only pipelines in this folder")).handler(n(u,s=>s.list)),o(t,"get","R","one pipeline").argument("<pipeline>","pipeline id, name or URL").handler(n(u,s=>s.getPipeline)),f(o(t,"run","W","queue a run",{description:`--param sets YAML parameters (templateParameters); --variable sets runtime variables.
18
18
  Example: ppdo-cli ado pipeline run deploy --branch main --param env=test --wait --logs-on-failure`}).argument("<pipeline>","pipeline id, name or URL").option("--branch <ref>","branch to run (default: the pipeline's default)").option("--param <k=v>","YAML parameter (repeatable)",l).option("--variable <k=v>","runtime variable (repeatable)",l).option("--wait","wait for the run; non-zero exit unless it succeeds").option("--logs-on-failure","with --wait: include failed steps' log tails").option("--skip-stage <stage>[,<stage>...]","stages not to run").option("--only-stage <stage>[,<stage>...]","run only these stages"),["--skip-stage","--only-stage"]).handler(n(u,s=>s.runPipeline)),o(t,"stages","R","the stages a run would have, from the expanded YAML",{description:`the stages a run would have, from the expanded YAML
19
19
 
20
20
  Uses a preview run (nothing is queued), so templates and parameters are applied.
@@ -24,7 +24,7 @@ Stage names are what --skip-stage, --only-stage and run retry --stage take.`}).a
24
24
  --tail is given) and prints the files instead of the logs.`}).argument("<run>","run id or its dev.azure.com URL").option("--failed-only").option("--step <name>","steps whose name contains this text").addOption(new r("--tail <n>","last n lines per step (default 100, or all with --save; 0 = all)").argParser(d)).option("--timestamps","keep each line's timestamp").option("--save <dir>","write one .log file per step to this folder").handler(n(u,s=>s.logs)),o(e,"retry","W","re-run failed or canceled stages of a finished run",{description:`re-run failed or canceled stages of a finished run
25
25
 
26
26
  Without --stage, every failed or canceled stage. Only the failed jobs in a stage run again
27
- unless --all-jobs.`}).argument("<run>","run id or its dev.azure.com URL").option("--stage <stage>[,<stage>...]","stage names or display names").option("--all-jobs","re-run every job in the stage, not only failed ones").option("--wait","wait for the run; non-zero exit unless it succeeds").option("--logs-on-failure","with --wait: include failed steps' log tails").handler(n(u,s=>s.retry)),o(e,"cancel","W","cancel a run").argument("<run>","run id or its dev.azure.com URL").handler(n(u,s=>s.cancel))}var g=()=>import("./projects-GXIQO7HV.js"),F=()=>import("./policies-BZR5437X.js"),R=`<ref> is a branch (default: the repo's default branch), a tag as refs/tags/<name>, or a full
27
+ unless --all-jobs.`}).argument("<run>","run id or its dev.azure.com URL").option("--stage <stage>[,<stage>...]","stage names or display names").option("--all-jobs","re-run every job in the stage, not only failed ones").option("--wait","wait for the run; non-zero exit unless it succeeds").option("--logs-on-failure","with --wait: include failed steps' log tails").handler(n(u,s=>s.retry)),o(e,"cancel","W","cancel a run").argument("<run>","run id or its dev.azure.com URL").handler(n(u,s=>s.cancel))}var g=()=>import("./projects-LPVDFLPC.js"),F=()=>import("./policies-EWCANNBE.js"),R=`<ref> is a branch (default: the repo's default branch), a tag as refs/tags/<name>, or a full
28
28
  40-character commit SHA. Paths start at the repo root, with or without a leading /.`;function M(a){p(o(m(a,"project","projects"),"list","R","projects in the organization")).handler(n(g,e=>e.projects));let t=m(a,"repo","Git repositories");p(o(t,"list","R","repositories in the project")).handler(n(g,e=>e.repos)),o(t,"get","R","one repository").argument("<name>","repository name or id").handler(n(g,e=>e.repo)),o(t,"file","R","a file's content at a branch, tag or commit",{description:`a file's content at a branch, tag or commit
29
29
 
30
30
  JSON output carries the content as text; -o table or tsv prints it raw. A binary file needs
@@ -53,7 +53,7 @@ and behind (commits <target> has that <base> doesn't, and the reverse) and merge
53
53
  Each has its id, type, required (blocking) or optional, enabled, branches (main, release/*,
54
54
  or (default branch)) or none for a push restriction on the whole repository, all_repos for
55
55
  a project-wide policy, and settings. --branch lists only the policies that apply to that
56
- branch, including project-wide ones.`}).argument("<repo>","repository name or id").option("--branch <branch>","only the policies that apply to this branch").handler(n(F,e=>e.repoPolicies))}var h=()=>import("./prs-F2EVQJRV.js"),K=()=>import("./policies-BZR5437X.js"),J=["merge","squash","rebase","rebase-merge"],B=["active","pending","fixed","wont-fix","closed","by-design"];function W(a){return a.addOption(new r("--merge-strategy <strategy>","merge is a no-fast-forward merge").choices(J)).option("--delete-source-branch").option("--transition-work-items","move linked work items to their next state").option("--message <text|@file>","merge commit message").option("--conflict-authorship-commits","merge option: author conflict resolutions as their own commits").option("--no-renames","merge option: don't detect renames")}function H(a){let t=m(a,"pr","pull requests");p(o(t,"list","R","pull requests in the project (newest first)").option("--repo <name>").addOption(new r("--status <status>").choices(["active","completed","abandoned","all"]).default("active")).option("--creator <me|upn>").option("--reviewer <me|upn>").option("--source <branch>","only PRs from this branch").option("--target <branch>","only PRs into this branch")).handler(n(h,e=>e.list)),o(t,"get","R","pull request details, reviewers and status").argument("<pr>","PR id or its dev.azure.com URL").handler(n(h,e=>e.getOne)),o(t,"diff","R","changes in a pull request (unified diff, or --stat)").argument("<pr>","PR id or its dev.azure.com URL").option("--file <path>","only this file").option("--stat","list changed files only").addOption(new r("-U, --unified <n>","context lines (default 3)").argParser(d)).handler(n(h,e=>e.diff)),o(t,"checks","R","how each branch policy stands on a pull request",{description:`how each branch policy stands on a pull request
56
+ branch, including project-wide ones.`}).argument("<repo>","repository name or id").option("--branch <branch>","only the policies that apply to this branch").handler(n(F,e=>e.repoPolicies))}var h=()=>import("./prs-C4EKGJWA.js"),K=()=>import("./policies-EWCANNBE.js"),J=["merge","squash","rebase","rebase-merge"],B=["active","pending","fixed","wont-fix","closed","by-design"];function W(a){return a.addOption(new r("--merge-strategy <strategy>","merge is a no-fast-forward merge").choices(J)).option("--delete-source-branch").option("--transition-work-items","move linked work items to their next state").option("--message <text|@file>","merge commit message").option("--conflict-authorship-commits","merge option: author conflict resolutions as their own commits").option("--no-renames","merge option: don't detect renames")}function H(a){let t=m(a,"pr","pull requests");p(o(t,"list","R","pull requests in the project (newest first)").option("--repo <name>").addOption(new r("--status <status>").choices(["active","completed","abandoned","all"]).default("active")).option("--creator <me|upn>").option("--reviewer <me|upn>").option("--source <branch>","only PRs from this branch").option("--target <branch>","only PRs into this branch")).handler(n(h,e=>e.list)),o(t,"get","R","pull request details, reviewers and status").argument("<pr>","PR id or its dev.azure.com URL").handler(n(h,e=>e.getOne)),o(t,"diff","R","changes in a pull request (unified diff, or --stat)").argument("<pr>","PR id or its dev.azure.com URL").option("--file <path>","only this file").option("--stat","list changed files only").addOption(new r("-U, --unified <n>","context lines (default 3)").argParser(d)).handler(n(h,e=>e.diff)),o(t,"checks","R","how each branch policy stands on a pull request",{description:`how each branch policy stands on a pull request
57
57
 
58
58
  Each has its policy id (what pr auto-complete --ignore-policy takes for an optional one),
59
59
  type, required, status (approved, queued, running, rejected or broken) and blocks: true when
@@ -63,7 +63,7 @@ Options the PR already has are kept unless given. Policies must pass first; ther
63
63
  bypass. --ignore-policy names optional policies (configuration ids) not to wait for.`}).argument("<pr>","PR id or its dev.azure.com URL").option("--off","turn auto-complete off")).option("--ignore-policy <id>[,<id>...]","optional policy configuration ids not to wait for").handler(n(h,e=>e.autoComplete)),W(o(t,"complete","W","complete (merge) a pull request now",{description:`complete (merge) a pull request now
64
64
 
65
65
  Never bypasses branch policies: if a required policy isn't passing, it stops with exit 8.
66
- Options the PR already has are kept unless given.`}).argument("<pr>","PR id or its dev.azure.com URL")).handler(n(h,e=>e.complete))}var c=()=>import("./workitems-UG5O3EGB.js"),_=a=>`${a}
66
+ Options the PR already has are kept unless given.`}).argument("<pr>","PR id or its dev.azure.com URL")).handler(n(h,e=>e.complete))}var c=()=>import("./workitems-2IOGD3EL.js"),_=a=>`${a}
67
67
 
68
68
  Long-text fields (Description, Repro Steps, Acceptance Criteria, History, custom
69
69
  HTML fields) are written as Markdown; --html writes HTML. A field takes the format
@@ -100,4 +100,4 @@ Examples:
100
100
  ppdo-cli ado api GET _apis/projects
101
101
  ppdo-cli ado api GET {project}/_apis/build/builds --param '$top=5'
102
102
  ppdo-cli ado api GET _apis/graph/users --host vssps
103
- ppdo-cli ado api POST {project}/_apis/wit/wiql --body @query.json`).addArgument(S(j)).argument("<path>").option("--body <@file|-|json>","request body: @file, - for stdin, or inline JSON").option("--header <k:v>","extra header (repeatable)",l).option("--param <k=v>","query parameter (repeatable)",l).option("--api-version <v>","default 7.1").addOption(new r("--host <host>","DevOps host (default: core = dev.azure.com)").choices(z).default("core")).option("--paginate","follow continuation tokens; items are the output").addOption(new r("--limit <n>","stop after n items (with --paginate)").argParser(d)).option("--save <file>","write the response body to a file").handler(async e=>(await import("./api-7RAWLIQV.js")).api(e)),M(t),C(t),H(t),D(t),A(t)}export{Se as register};
103
+ ppdo-cli ado api POST {project}/_apis/wit/wiql --body @query.json`).addArgument(S(j)).argument("<path>").option("--body <@file|-|json>","request body: @file, - for stdin, or inline JSON").option("--header <k:v>","extra header (repeatable)",l).option("--param <k=v>","query parameter (repeatable)",l).option("--api-version <v>","default 7.1").addOption(new r("--host <host>","DevOps host (default: core = dev.azure.com)").choices(z).default("core")).option("--paginate","follow continuation tokens; items are the output").addOption(new r("--limit <n>","stop after n items (with --paginate)").argParser(d)).option("--save <file>","write the response body to a file").handler(async e=>(await import("./api-TZJXGWWQ.js")).api(e)),M(t),C(t),H(t),D(t),A(t)}export{Se as register};
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
2
- import{a,b,c,d,e}from"./chunk-LL4XQ3L7.js";import"./chunk-UCTMKA2J.js";import"./chunk-BALEFXOL.js";import"./chunk-5SBBTR3Y.js";import"./chunk-WXOTXJNG.js";import"./chunk-ZHHVG47C.js";export{e as api,c as checkJsonBody,d as emitResponse,b as forbiddenHeaders,a as headerDict};
2
+ import{a,b,c,d,e}from"./chunk-J67P6QFC.js";import"./chunk-UCTMKA2J.js";import"./chunk-BALEFXOL.js";import"./chunk-2IUXH534.js";import"./chunk-WXOTXJNG.js";import"./chunk-ZHHVG47C.js";export{e as api,c as checkJsonBody,d as emitResponse,b as forbiddenHeaders,a as headerDict};
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
2
- import{a as V,b as j,c as P,d as R}from"./chunk-LL4XQ3L7.js";import"./chunk-UCTMKA2J.js";import{w,y as h}from"./chunk-BALEFXOL.js";import{b as k}from"./chunk-5SBBTR3Y.js";import{e as g}from"./chunk-S4KF5Z3S.js";import{a as y,b as v}from"./chunk-WXOTXJNG.js";import"./chunk-ZHHVG47C.js";function x(n){return/_apis\/wit\/workitems\/(\$|%24)?[^/?]+\/?(\?|$)/i.test(n)}async function C(n,e,o){let{DevOps:r}=await import("./service-4VHAPTA6.js"),s=await n.client("devops"),c=s.target.env;return s.service=new r({org:c.org,project:c.project},e,o),s}async function I(n){let e=n.args,o=String(e.method),r=String(e.path),s=typeof e.apiVersion=="string"&&e.apiVersion?e.apiVersion:null,c=typeof e.limit=="number"?e.limit:null,a=V(e.header);j(a);let m=h(typeof e.body=="string"?e.body:null);m!==null&&!Object.keys(a).some(t=>t.toLowerCase()==="content-type")&&(P(m,a),(o==="POST"||o==="PATCH")&&x(r)&&(a["Content-Type"]="application/json-patch+json"));let d=await C(n,typeof e.host=="string"?e.host:"core",s);k(n,d,o,r,m);let u=w(e.param,"--param");if(e.paginate&&o!=="GET")throw new v("--paginate only applies to GET");let f=await import("./service-4VHAPTA6.js"),l=async()=>{if(e.paginate){let i=d.paginate(r,{params:u,headers:a,limit:c,nextLink:f.nextUrl,items:f.items});return{kind:"stream",first:await i.next(),stream:i}}let t=typeof e.save=="string"?e.save:null;return{kind:"resp",resp:await d.request(o,r,{params:u,headers:a,body:m,saveTo:t})}},p;try{p=await l()}catch(t){if(!(t instanceof y)||t.code!=="VssInvalidPreviewVersionException"||s)throw t;let i=d.service;i.apiVersion=i.apiVersion+"-preview",g(`note: this endpoint needs a preview api-version; retried with ${i.apiVersion}`),p=await l()}if(p.kind==="stream"){let{first:t,stream:i}=p;async function*b(){t.done||(yield t.value),yield*i}await n.emitStream(b());return}await R(n,p.resp,!1)}export{I as api,x as isWorkItemPath};
2
+ import{a as V,b as j,c as P,d as R}from"./chunk-J67P6QFC.js";import"./chunk-UCTMKA2J.js";import{w,y as h}from"./chunk-BALEFXOL.js";import{b as k}from"./chunk-2IUXH534.js";import{e as g}from"./chunk-S4KF5Z3S.js";import{a as y,b as v}from"./chunk-WXOTXJNG.js";import"./chunk-ZHHVG47C.js";function x(n){return/_apis\/wit\/workitems\/(\$|%24)?[^/?]+\/?(\?|$)/i.test(n)}async function C(n,e,o){let{DevOps:r}=await import("./service-4N3YP4Z7.js"),s=await n.client("devops"),c=s.target.env;return s.service=new r({org:c.org,project:c.project},e,o),s}async function I(n){let e=n.args,o=String(e.method),r=String(e.path),s=typeof e.apiVersion=="string"&&e.apiVersion?e.apiVersion:null,c=typeof e.limit=="number"?e.limit:null,a=V(e.header);j(a);let m=h(typeof e.body=="string"?e.body:null);m!==null&&!Object.keys(a).some(t=>t.toLowerCase()==="content-type")&&(P(m,a),(o==="POST"||o==="PATCH")&&x(r)&&(a["Content-Type"]="application/json-patch+json"));let d=await C(n,typeof e.host=="string"?e.host:"core",s);k(n,d,o,r,m);let u=w(e.param,"--param");if(e.paginate&&o!=="GET")throw new v("--paginate only applies to GET");let f=await import("./service-4N3YP4Z7.js"),l=async()=>{if(e.paginate){let i=d.paginate(r,{params:u,headers:a,limit:c,nextLink:f.nextUrl,items:f.items});return{kind:"stream",first:await i.next(),stream:i}}let t=typeof e.save=="string"?e.save:null;return{kind:"resp",resp:await d.request(o,r,{params:u,headers:a,body:m,saveTo:t})}},p;try{p=await l()}catch(t){if(!(t instanceof y)||t.code!=="VssInvalidPreviewVersionException"||s)throw t;let i=d.service;i.apiVersion=i.apiVersion+"-preview",g(`note: this endpoint needs a preview api-version; retried with ${i.apiVersion}`),p=await l()}if(p.kind==="stream"){let{first:t,stream:i}=p;async function*b(){t.done||(yield t.value),yield*i}await n.emitStream(b());return}await R(n,p.resp,!1)}export{I as api,x as isWorkItemPath};
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
2
- import{e as o,o as a,r as t}from"./chunk-BALEFXOL.js";import"./chunk-WXOTXJNG.js";import"./chunk-ZHHVG47C.js";var s=["dv","dataverse","ado","devops"];function p(d){let n=a(d,"auth","sign in, sign out, tokens"),i=()=>import("./run-ICS4FNZA.js");t(n,"login","L","interactive sign-in for an identity",{description:`ppdo-cli auth login <identity> sign in one identity
2
+ import{e as o,o as a,r as t}from"./chunk-BALEFXOL.js";import"./chunk-WXOTXJNG.js";import"./chunk-ZHHVG47C.js";var s=["dv","dataverse","ado","devops"];function p(d){let n=a(d,"auth","sign in, sign out, tokens"),i=()=>import("./run-7L6W2YWJ.js");t(n,"login","L","interactive sign-in for an identity",{description:`ppdo-cli auth login <identity> sign in one identity
3
3
  ppdo-cli auth login --service ado sign in the identity the default DevOps environment uses
4
4
  ppdo-cli auth login --env <name> sign in the identity that environment's group uses
5
5
  ppdo-cli auth login sign in every identity the default environments need that
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
2
- import{a as g}from"./chunk-BCAXUZIO.js";import"./chunk-I3TMFYRJ.js";import{a as d}from"./chunk-MK6QZ4ES.js";import"./chunk-STWQDANK.js";import{b as l}from"./chunk-MBNUMAAZ.js";import"./chunk-LB7WNZVK.js";import"./chunk-4KP27OCL.js";import"./chunk-J4R6QXW7.js";import"./chunk-5SBBTR3Y.js";import"./chunk-WMDKJRDC.js";import"./chunk-H4OY4EFC.js";import"./chunk-TQLZ3TRU.js";import"./chunk-S4KF5Z3S.js";import{b as m,c as p}from"./chunk-WXOTXJNG.js";import"./chunk-ZHHVG47C.js";import{execFile as x}from"node:child_process";import{statSync as h}from"node:fs";import{delimiter as E,extname as b,join as y}from"node:path";var v=12e4;function A(t){let n=d();return t.configDir&&(n.AZURE_CONFIG_DIR=g(t.configDir)),n}function w(t){return`run: ${t.configDir?`AZURE_CONFIG_DIR=${t.configDir} `:""}az login --tenant ${t.tenant}`}function I(t){let n=process.platform==="win32"?(process.env.PATHEXT||".COM;.EXE;.BAT;.CMD").split(";").filter(o=>o):[""];for(let o of(process.env.PATH||"").split(E))if(o)for(let i of b(t)?[""]:n){let e=y(o,t+i);try{if(h(e).isFile())return e}catch{}}return null}function _(t,n,o){let i=t,e=n,s=!1;if(process.platform==="win32"&&/\.(cmd|bat)$/i.test(t)){for(let r of[t,...n])if(/["%\r\n]/.test(r))throw new m(`cannot pass '${r}' to az safely`);i=process.env.ComSpec||"cmd.exe",e=["/d","/s","/c",`"${[t,...n].map(r=>`"${r}"`).join(" ")}"`],s=!0}return new Promise(r=>{x(i,e,{env:o,timeout:v,windowsHide:!0,windowsVerbatimArguments:s,maxBuffer:16<<20},(c,a,u)=>{let f=c;r({code:f?typeof f.code=="number"?f.code:1:0,stdout:String(a),stderr:String(u),timedOut:!!f?.killed})})})}async function D(t,n){let o=I("az");if(!o)throw new m("method 'az_cli' needs the Azure CLI on PATH",{hint:"install it, or use --method browser"});let i=["account","get-access-token","--scope",n,"--output","json"];t.tenant&&i.push("--tenant",t.tenant);let e=await _(o,i,A(t));if(e.timedOut)throw new p("az account get-access-token timed out",{hint:w(t)});if(e.code!==0){let a=e.stderr.split(/\r?\n/).map(u=>u.trim()).find(u=>u)??"az failed";throw new p(`az could not get a token for identity '${t.name}': ${a}`,{hint:w(t)})}let s=JSON.parse(e.stdout),r=s.accessToken,c=s.expires_on;if(c==null){let a=l(r)?.exp;c=typeof a=="number"?a:Date.now()/1e3+300}return[r,Number(c),s.tenant??null]}export{v as AZ_TIMEOUT_MS,D as acquire,w as loginHint,I as which};
2
+ import{a as g}from"./chunk-B3TJ3RJN.js";import"./chunk-XUHLW6B2.js";import{a as d}from"./chunk-P4IFCLVF.js";import"./chunk-3L7657R3.js";import{b as l}from"./chunk-MBNUMAAZ.js";import"./chunk-LB7WNZVK.js";import"./chunk-GY6BUIDP.js";import"./chunk-J4R6QXW7.js";import"./chunk-2IUXH534.js";import"./chunk-TCLZ4XM6.js";import"./chunk-H4OY4EFC.js";import"./chunk-TQLZ3TRU.js";import"./chunk-S4KF5Z3S.js";import{b as m,c as p}from"./chunk-WXOTXJNG.js";import"./chunk-ZHHVG47C.js";import{execFile as x}from"node:child_process";import{statSync as h}from"node:fs";import{delimiter as E,extname as b,join as y}from"node:path";var v=12e4;function A(t){let n=d();return t.configDir&&(n.AZURE_CONFIG_DIR=g(t.configDir)),n}function w(t){return`run: ${t.configDir?`AZURE_CONFIG_DIR=${t.configDir} `:""}az login --tenant ${t.tenant}`}function I(t){let n=process.platform==="win32"?(process.env.PATHEXT||".COM;.EXE;.BAT;.CMD").split(";").filter(o=>o):[""];for(let o of(process.env.PATH||"").split(E))if(o)for(let i of b(t)?[""]:n){let e=y(o,t+i);try{if(h(e).isFile())return e}catch{}}return null}function _(t,n,o){let i=t,e=n,s=!1;if(process.platform==="win32"&&/\.(cmd|bat)$/i.test(t)){for(let r of[t,...n])if(/["%\r\n]/.test(r))throw new m(`cannot pass '${r}' to az safely`);i=process.env.ComSpec||"cmd.exe",e=["/d","/s","/c",`"${[t,...n].map(r=>`"${r}"`).join(" ")}"`],s=!0}return new Promise(r=>{x(i,e,{env:o,timeout:v,windowsHide:!0,windowsVerbatimArguments:s,maxBuffer:16<<20},(c,a,u)=>{let f=c;r({code:f?typeof f.code=="number"?f.code:1:0,stdout:String(a),stderr:String(u),timedOut:!!f?.killed})})})}async function D(t,n){let o=I("az");if(!o)throw new m("method 'az_cli' needs the Azure CLI on PATH",{hint:"install it, or use --method browser"});let i=["account","get-access-token","--scope",n,"--output","json"];t.tenant&&i.push("--tenant",t.tenant);let e=await _(o,i,A(t));if(e.timedOut)throw new p("az account get-access-token timed out",{hint:w(t)});if(e.code!==0){let a=e.stderr.split(/\r?\n/).map(u=>u.trim()).find(u=>u)??"az failed";throw new p(`az could not get a token for identity '${t.name}': ${a}`,{hint:w(t)})}let s=JSON.parse(e.stdout),r=s.accessToken,c=s.expires_on;if(c==null){let a=l(r)?.exp;c=typeof a=="number"?a:Date.now()/1e3+300}return[r,Number(c),s.tenant??null]}export{v as AZ_TIMEOUT_MS,D as acquire,w as loginHint,I as which};
@@ -0,0 +1,2 @@
1
+ import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
2
+ import{a,b,c,d,e,f}from"./chunk-MNGA7IHQ.js";import"./chunk-KBZI5UDL.js";import"./chunk-GY6BUIDP.js";import"./chunk-J4R6QXW7.js";import"./chunk-2IUXH534.js";import"./chunk-TCLZ4XM6.js";import"./chunk-H4OY4EFC.js";import"./chunk-TQLZ3TRU.js";import"./chunk-S4KF5Z3S.js";import"./chunk-WXOTXJNG.js";import"./chunk-ZHHVG47C.js";export{b as RawJson,a as WRITE_METHODS,d as build,f as distribute,c as noResponse,e as parse};
@@ -1,4 +1,4 @@
1
1
  import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
2
- import{a as y,b as S,d as L,e as F}from"./chunk-JEAIFLEN.js";import{a as M}from"./chunk-JAGU2NM5.js";import{Y as m,ca as b}from"./chunk-TZSB4PR7.js";import{b as k,g as A}from"./chunk-ZNJ4DRCA.js";import{e as O,o as T,p as C,q as X,t as $}from"./chunk-WIA546AL.js";import{a as v}from"./chunk-MK6QZ4ES.js";import"./chunk-STWQDANK.js";import"./chunk-TQLZ3TRU.js";import"./chunk-S4KF5Z3S.js";import"./chunk-WXOTXJNG.js";import"./chunk-ZHHVG47C.js";import{spawnSync as B}from"node:child_process";import{existsSync as U,readdirSync as D,readFileSync as E,statSync as x}from"node:fs";import*as p from"node:path";function I(i){let t=C(i),o=p.dirname(i),s=[];for(let n of L(t,"ProjectReference")){let r=n.get("Include");r&&s.push(S(o,r))}let e=F(t,"SolutionPackageMapFilePath");return{package_type:F(t,"SolutionPackageType"),map_file:e?S(o,e):null,references:s}}function _(i){let t=process.platform==="win32"?(process.env.PATHEXT??".COM;.EXE;.BAT;.CMD").split(";"):[""];for(let o of(process.env.PATH??"").split(p.delimiter))if(o)for(let s of t){let e=p.join(o,i+s.toLowerCase());try{if(x(e).isFile())return e}catch{}}return null}function G(){let i=_("dotnet");if(i===null)throw new m("building the project's references needs the .NET SDK (dotnet) on PATH");return i}function H(i,t,o,s){if(!U(i))throw new m(`the referenced project ${i} doesn't exist`);let n=["msbuild",i,"-nologo",`-t:${o?"Build;GetProjectOutputPath":"GetProjectOutputPath"}`,`-p:Configuration=${t}`,"-getTargetResult:GetProjectOutputPath"];o&&n.splice(2,0,"-restore"),s(`${o?"building":"reading"} ${p.basename(i)} (${t})`);let r=B(G(),n,{encoding:"utf8",stdio:["ignore","pipe","pipe"],env:v(),maxBuffer:256*1024*1024});if(r.error)throw r.error;let c=r.stdout??"",u=r.stderr??"",l=c.trim(),f=null;try{f=l.includes("{")?JSON.parse(l.slice(l.indexOf("{"))):null}catch{f=null}let d=f?.TargetResults?.GetProjectOutputPath??{};if(r.status!==0||d.Result!=="Success"){let a=(c+`
2
+ import{a as M}from"./chunk-JAGU2NM5.js";import{a as y,b as S,d as L,e as F}from"./chunk-JEAIFLEN.js";import{Y as m,ca as b}from"./chunk-TZSB4PR7.js";import{b as k,g as A}from"./chunk-ZNJ4DRCA.js";import{e as O,o as T,p as C,q as X,t as $}from"./chunk-WIA546AL.js";import{a as v}from"./chunk-P4IFCLVF.js";import"./chunk-3L7657R3.js";import"./chunk-TQLZ3TRU.js";import"./chunk-S4KF5Z3S.js";import"./chunk-WXOTXJNG.js";import"./chunk-ZHHVG47C.js";import{spawnSync as B}from"node:child_process";import{existsSync as U,readdirSync as D,readFileSync as E,statSync as x}from"node:fs";import*as p from"node:path";function I(i){let t=C(i),o=p.dirname(i),s=[];for(let n of L(t,"ProjectReference")){let r=n.get("Include");r&&s.push(S(o,r))}let e=F(t,"SolutionPackageMapFilePath");return{package_type:F(t,"SolutionPackageType"),map_file:e?S(o,e):null,references:s}}function _(i){let t=process.platform==="win32"?(process.env.PATHEXT??".COM;.EXE;.BAT;.CMD").split(";"):[""];for(let o of(process.env.PATH??"").split(p.delimiter))if(o)for(let s of t){let e=p.join(o,i+s.toLowerCase());try{if(x(e).isFile())return e}catch{}}return null}function G(){let i=_("dotnet");if(i===null)throw new m("building the project's references needs the .NET SDK (dotnet) on PATH");return i}function H(i,t,o,s){if(!U(i))throw new m(`the referenced project ${i} doesn't exist`);let n=["msbuild",i,"-nologo",`-t:${o?"Build;GetProjectOutputPath":"GetProjectOutputPath"}`,`-p:Configuration=${t}`,"-getTargetResult:GetProjectOutputPath"];o&&n.splice(2,0,"-restore"),s(`${o?"building":"reading"} ${p.basename(i)} (${t})`);let r=B(G(),n,{encoding:"utf8",stdio:["ignore","pipe","pipe"],env:v(),maxBuffer:256*1024*1024});if(r.error)throw r.error;let c=r.stdout??"",u=r.stderr??"",l=c.trim(),f=null;try{f=l.includes("{")?JSON.parse(l.slice(l.indexOf("{"))):null}catch{f=null}let d=f?.TargetResults?.GetProjectOutputPath??{};if(r.status!==0||d.Result!=="Success"){let a=(c+`
3
3
  `+u).split(/\r\n|\r|\n/).filter(w=>w.toLowerCase().includes("error")),g=[...new Set(a.slice(0,5).map(w=>w.trim()))].join("; ")||l.slice(-500)||"no output";throw new m(`building ${i} failed: ${g}`)}let h=[];for(let a of d.Items??[]){let g=a.FullPath||a.Identity||"",w=a.PowerAppsComponentType||"";if(!w)throw new m(`${i} gives output ${g} without a PowerAppsComponentType (only PCF and plug-in projects can be referenced)`);h.push([g,w])}return h}function R(i){let t=[],o=s=>{let e;try{e=D(s,{withFileTypes:!0})}catch{return}e.sort((n,r)=>b(n.name.toUpperCase(),r.name.toUpperCase()));for(let n of e)n.isDirectory()||t.push(y(s,n.name));for(let n of e)n.isDirectory()&&o(y(s,n.name))};return o(i),t}function z(i,t){return R(i).find(o=>p.basename(o).toLowerCase()===t.toLowerCase())??null}function N(i,t){return p.relative(t,i).split(p.sep).join("/")}var j=class{constructor(t){this.root=t}files=new Map;solution=null;sol(){return this.solution??=X(p.join(this.root,"Other","Solution.xml"))}exists(t){let o=t.toLowerCase();if([...this.files.keys()].some(s=>s.toLowerCase()===o))return!0;try{return x(p.join(this.root,...t.split("/"))).isFile()}catch{return!1}}result(){let t=new Map(this.files);return this.solution!==null&&t.set("Other/Solution.xml",$(this.solution)),t}addControls(t){let o=!1;try{o=x(t).isDirectory()}catch{o=!1}if(!o)throw new m(`the PCF project's output folder ${t} doesn't exist; build it first`);let s=null,e=this.sol().root.element("SolutionManifest"),n=e!==null?e.element("Publisher"):null;n!==null&&n.element("CustomizationPrefix")!==null&&(s=n.element("CustomizationPrefix").value);let r=[],c=D(t,{withFileTypes:!0}).sort((u,l)=>b(u.name.toUpperCase(),l.name.toUpperCase()));for(let u of c){if(!u.isDirectory())continue;let l=y(t,u.name),f=z(l,"ControlManifest.xml");if(f===null)throw new m(`ControlManifest.xml not found for the control in ${l}`);let d=C(f).element("control");if(d===null||!d.get("namespace")||!d.get("constructor"))throw new m(`${f} has no control namespace and constructor`);let h=`${d.get("namespace")}.${d.get("constructor")}`,a=s?`${s}_${h}`:h,g=`Controls/${a}`;for(let P of R(l))this.files.set(`${g}/${N(P,l)}`,new Uint8Array(E(P)));let w=`${g}/ControlManifest.xml.data.xml`;if(!this.exists(w)){let P="/"+k(g,N(f,l));this.files.set(w,$(T(Buffer.from(`<CustomControl><Name>${a}</Name><FileName>${P}</FileName></CustomControl>`,"utf8"))))}this.addRoot("66",a),r.push(a)}return r}addRoot(t,o){let s=this.sol().root.element("SolutionManifest"),e=s!==null?s.element("RootComponents"):null;if(e===null)throw new m("Other/Solution.xml has no RootComponents");let n=e.elements("RootComponent");if(n.some(a=>a.get("type")===t&&a.get("schemaName")===o))return;let r=new O("RootComponent",[["type",t],["schemaName",o],["behavior","0"]],null,{empty:!0,ns:e.ns,scope:e.scope});r.parent=e;let c=a=>{let g=(a.get("type")??"").trim();return g&&/^[+-]?(\d+\.?\d*|\.\d+)([eE][+-]?\d+)?$/.test(g)?Number(g):NaN},u=Number(t),l=n.filter(a=>c(a)===u),f=n.filter(a=>c(a)>u),d=n.filter(a=>c(a)<u),h;l.length?h=e.kids.indexOf(l[l.length-1])+1:f.length?h=e.kids.indexOf(f[0]):d.length?h=e.kids.indexOf(d[d.length-1])+1:h=e.kids.length,e.kids.splice(h,0,r),e.empty=!1}addPlugin(t){let o=!1;try{o=x(t).isFile()}catch{o=!1}if(!o)throw new m(`the plug-in project's output ${t} doesn't exist; build it first`);let s=new Uint8Array(E(t)),e=M(s);if(e===null)throw new m(`${t} is not a .NET assembly`);let n=y(this.root,"PluginAssemblies");for(let r of R(n)){if(!r.toLowerCase().endsWith("dll.data.xml"))continue;let c=C(r);if((c.get("FullName")??"").toLowerCase()!==e.toLowerCase())continue;let u=c.element("FileName"),l=(u!==null?u.value:"")||"",f=N(r.slice(0,-9),this.root);return l&&(f=A(l.replaceAll("\\","/"))),this.files.set(f,s),f}throw new m(`no plug-in assembly in ${n} is registered as ${e}; the assembly's name, version and key must match a PluginAssemblies/**/*.dll.data.xml`)}};function tt(i,t,o,s=!0,e=n=>process.stderr.write(n+`
4
4
  `)){let n=new j(t),r=[];for(let c of I(i).references)for(let[u,l]of H(c,o,s,e))if(l.toLowerCase()==="pcf")r.push({project:c,type:"pcf",controls:n.addControls(u)});else if(l.toLowerCase()==="plugin")r.push({project:c,type:"plugin",assembly:n.addPlugin(u)});else throw new m(`${c}: component type ${l} is not supported (only Pcf and Plugin)`);return[n.result(),r]}export{j as Overlay,tt as buildProject,H as buildReference,I as settings};
@@ -0,0 +1,2 @@
1
+ import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
2
+ import{a as W}from"./chunk-SWXCK5C2.js";import{p as O}from"./chunk-ELSYHAYC.js";import{D as Z,F,G as B,H as V,d as m,f as w,g as _,h as R,i as z,t as S,u as p,v as P}from"./chunk-BG2OIOSN.js";import{a as T}from"./chunk-UCTMKA2J.js";import{a as k,b as x,d as H,e as A,f as U,g as v}from"./chunk-FOEBNCSD.js";import{b as M}from"./chunk-KBZI5UDL.js";import{y as J}from"./chunk-BALEFXOL.js";import"./chunk-GY6BUIDP.js";import"./chunk-J4R6QXW7.js";import{b as j}from"./chunk-2IUXH534.js";import"./chunk-TCLZ4XM6.js";import"./chunk-H4OY4EFC.js";import"./chunk-TQLZ3TRU.js";import"./chunk-S4KF5Z3S.js";import{a as E,b as f,d as G,j as D}from"./chunk-WXOTXJNG.js";import"./chunk-ZHHVG47C.js";var K=/^([A-Za-z_][A-Za-z0-9_]*)\((.+)\)\n?$/;function tt(t){let n=F(J(t).toString("utf8")).trim(),e;if(n.startsWith("["))try{e=T(n)}catch(r){throw new f(`--body is not valid JSON: ${r.message}`)}else{let r=[];W(n).forEach((i,a)=>{if(i.trim())try{r.push(T(i))}catch(s){throw new f(`line ${a+1}: not JSON (${s.message})`)}}),e=r}let o=r=>typeof r=="object"&&r!==null&&!Array.isArray(r);if(!Array.isArray(e)||!e.length||!e.every(o))throw new f("--body needs one JSON object per row");return e}function et(t){return typeof t=="boolean"?t?"true":"false":typeof t=="number"?String(t):A(String(t))}function nt(t,n,e,o,r){return t.map((i,a)=>{let s=a+1,l,d;if(e&&e.length){let c=e.filter(u=>i[u]===null||i[u]===void 0||i[u]==="");if(c.length)throw new f(`row ${s} has no value for ${c.join(", ")}`);l=`${n}(`+e.map(u=>`${u}=${et(i[u])}`).join(",")+")",d=Object.fromEntries(Object.entries(i).filter(([u])=>!e.includes(u)))}else{let c=i[o];if(!x(m(c)?String(c):""))throw new f(`row ${s} has no ${o}`,{hint:"pass --key <columns> to match on an alternate key"});l=`${n}(${H(String(c))})`,d=Object.fromEntries(Object.entries(i).filter(([u])=>u!==o))}return{method:"PATCH",path:`${l}?$select=${o}`,body:d,headers:{Prefer:"return=representation",...r}}})}var rt={201:"created",200:"updated",204:"updated"};async function Q(t,n,e){let o=await p(t,n,"GET",`EntityDefinitions(LogicalName='${e}')`,{params:[["$select","PrimaryIdAttribute"]]}),r=P(o).PrimaryIdAttribute;if(r===void 0)throw new E("'PrimaryIdAttribute'");return r}async function pt(t){let n=t.args,e=k(B(n.entityset),"entity set name"),o=tt(String(n.body)),r=m(n.key)?String(n.key).split(",").map(c=>c.trim()).filter(c=>c):null,i=await S(t),a=await i.lookups(async()=>Q(t,i,await O(t,i,e))),s=nt(o,e,r,a,Z(t,i)),l=[];for await(let[c,u,N]of V(t,i,s,!1,!!n.continueOnError))for(let h=0;h<u.length;h++){let q=c+h,y=N[h],C=o[q],$=w(y,"status"),b={row:q+1,key:r&&r.length?Object.fromEntries(r.map(L=>[L,C[L]??null])):w(C,a),status:m($)?$:null,action:rt[$]??null},g=w(y,"body"),I=typeof g=="object"&&g!==null&&!Array.isArray(g);I&&m(g[a])&&(b.id=g[a]),I&&"error"in g?b.error=M(w(_(g.error),"message"))??null:(m(y.error)||!m($))&&(b.error=m(y.error)?y.error:"not run (an earlier row failed)"),l.push(z(b))}await t.emit(l);let d=l.filter(c=>"error"in c||(c.status||0)>=400);if(d.length)throw new E(`${d.length} of ${l.length} rows failed or didn't run`,{service:"dataverse",hint:"see each row's error"+(n.continueOnError?"":"; --continue-on-error keeps going after a failure")})}function X(t,n){let e=K.exec(U(n));if(!e)throw new f(`'${n}' is not a record reference`,{hint:"e.g. contacts(<id>) or contacts(name=value)"});let o=e[2].replace(/=\s*'((?:[^']|'')*)'/g,(i,a)=>"="+a.split("''").join("'"));return`${t.service.origin}/api/data/v9.2/${v(e[1],o)}`}async function ot(t,n,e){let o=e.indexOf("/api/data/v9.2/"),r=e.slice(0,o),i=e.slice(o+15),a=K.exec(i);if(x(a[2]))return e;let s=a[1],l=await Q(t,n,await O(t,n,s)),d=P(await p(t,n,"GET",i,{params:[["$select",l]]}))[l];if(d===void 0)throw new E(`'${l}'`);return`${r}/api/data/v9.2/${s}(${d})`}async function Y(t,n,e,o){k(o,"navigation property");let r=await O(t,n,e),i=`EntityDefinitions(LogicalName='${r}')`,a=A(o),s=async(u,N)=>P(await p(t,n,"GET",`${i}/${u}`,{params:[["$select","SchemaName"],["$filter",N]]})),l=await s("ManyToOneRelationships",`ReferencingEntityNavigationPropertyName eq ${a}`);if(R(l.value).length)return!0;let d=await s("OneToManyRelationships",`ReferencedEntityNavigationPropertyName eq ${a}`),c=await s("ManyToManyRelationships",`Entity1NavigationPropertyName eq ${a} or Entity2NavigationPropertyName eq ${a}`);if(R(d.value).length||R(c.value).length)return!1;throw new G(`${r} has no navigation property '${o}'`,{service:"dataverse",hint:`run: ppdo-cli dv metadata get ${r} --relationships`})}async function yt(t){let n=t.args,e=await S(t),o=v(String(n.entityset),String(n.id));j(t,e,"POST",o,Buffer.from("{}"));let r=X(e,String(n.target)),i=String(n.navigation),a=await e.lookups(()=>Y(t,e,String(n.entityset),i)),s=Buffer.from(D({"@odata.id":r}),"utf8");await p(t,e,a?"PUT":"POST",`${o}/${i}/$ref`,{body:s}),await t.emit({record:o,navigation:i,target:r.slice(r.indexOf("/v9.2/")+6),linked:!0})}async function wt(t){let n=t.args,e=await S(t),o=v(String(n.entityset),String(n.id));j(t,e,"DELETE",o,null);let r=String(n.navigation),i=await e.lookups(()=>Y(t,e,String(n.entityset),r)),a=B(n.target);if(i)await p(t,e,"DELETE",`${o}/${r}/$ref`);else{if(!a)throw new f(`${r} is a collection: name the record to unlink, e.g. contacts(<id>)`);let s=X(e,a),l=await e.lookups(()=>ot(t,e,s));await p(t,e,"DELETE",`${o}/${r}/$ref`,{params:[["$id",l]]})}await t.emit({record:o,navigation:r,target:a,unlinked:!0})}export{yt as associate,wt as disassociate,et as literal,tt as readRows,X as targetUrl,pt as upsert,nt as upsertRequests};
@@ -0,0 +1,2 @@
1
+ import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
2
+ import{g as u}from"./chunk-WXOTXJNG.js";var c=["GET","HEAD"],d={dataverse:["exportsolution","exportsolutionasync","downloadsolutionexportdata"],devops:["_apis/wit/wiql","_apis/wit/workitemsbatch"]},E=/_apis\/pipelines\/\d+\/preview$/,m=/^(GET|HEAD|POST|PATCH|PUT|DELETE|MERGE)[ \t\n\r\f\v]+[^ \t\n\r\f\v]+[ \t\n\r\f\v]+HTTP\/1\.[01][ \t\n\r\f\v]*$/gim;function f(e){return!e||!e.length?[]:[...(typeof e=="string"?e:Buffer.from(e).toString("latin1")).matchAll(m)].map(r=>r[1].toUpperCase())}function g(e){let t;if(e.includes("://")){let r=/^[A-Za-z][A-Za-z0-9+.-]*:\/\/[^/?#]*([^?#]*)/.exec(e);t=r?r[1]??"":""}else t=e.split("?",1)[0]??"";return t.replace(/^\/+|\/+$/g,"").toLowerCase()}function p(e){return g(e).endsWith("$batch")}function h(e,t){let r=g(t);if(e==="dataverse"){let n=r.slice(r.lastIndexOf("/")+1);return n=n.replace(/\(.*\)$/,""),n=n.slice(n.lastIndexOf(".")+1),(d.dataverse??[]).includes(n)}return e==="devops"&&E.test(r)?!0:(d[e]??[]).some(n=>r.endsWith(n))}function v(e,t,r,n,i,o){if(n=n.toUpperCase(),t==="V")return n!=="DELETE"?`a request of class V must be a DELETE, not ${n}`:e==="read-only"?"this request writes; mode is 'read-only'":null;if(t==="D"&&e!=="full")return`this command deletes; mode is '${e}' (needs 'full')`;if(t==="W"&&e==="read-only")return"this command writes; mode is 'read-only'";if(e==="full"||c.includes(n))return null;if(e==="read-write")return n==="DELETE"?"DELETE needs mode 'full' (current: 'read-write')":p(i)&&f(o).includes("DELETE")?"this $batch contains a DELETE part; needs mode 'full'":null;if(n==="POST"){if(p(i)){let a=f(o),s=a.filter(l=>!c.includes(l));return a.length&&!s.length?null:s.length?`this $batch contains a ${s[0]} part; mode is 'read-only'`:"cannot read the $batch parts; mode is 'read-only'"}if(h(r,i))return null}return`${n} is not allowed in mode 'read-only'`}function $(e,t,r,n,i,o){let a=o||(typeof e.args._cls=="string"?e.args._cls:"M"),s=t.target,l=v(s.mode,a,t.service.name,r,n,i);if(l)throw new u(`blocked: ${l}`,{service:t.service.name,hint:w(s)})}function w(e){if(e.app){let t=e.mode==="read-write"?"full":"read-write (full to delete)";return`this runs as an app with --mode ${e.mode}; pass --mode ${t} if the change is intended`}return`stop and ask the user: environment '${e.env.name}' is in group '${e.group.name}' (${e.mode}); only they can change that`}export{h as a,$ as b,w as c};
@@ -2,4 +2,4 @@ import { createRequire as __cr } from 'node:module'; const require = __cr(import
2
2
  import{b as w}from"./chunk-TQLZ3TRU.js";import{e as R}from"./chunk-S4KF5Z3S.js";import{b as a}from"./chunk-WXOTXJNG.js";import{existsSync as M,readFileSync as W,realpathSync as Y,statSync as q}from"node:fs";import{basename as K,dirname as T,join as f,resolve as Q}from"node:path";var X=/^[a-z0-9][a-z0-9_-]*$/,A=["broker","browser","device_code","az_cli","spn","pat"],O=["read-only","read-write","full"],nn={"read-only":0,"read-write":1,full:2},I=["dataverse","devops"],wn={dv:"dataverse",dataverse:"dataverse",ado:"devops",devops:"devops"},h={dataverse:"Dataverse",devops:"DevOps"},z={dataverse:"PPDEVOPS_DATAVERSE",devops:"PPDEVOPS_DEVOPS"},N=".ppdo-cli.json",tn="config.toml",F=".ppdevops.toml",en="PPDEVOPS_CLIENT_SECRET",on="04b07795-8ddb-461a-bbee-02f9e1bf7b46",k=/^[A-Za-z0-9](?:[A-Za-z0-9-]{0,48}[A-Za-z0-9])?$/,rn=/^[A-Za-z_][A-Za-z0-9_]*$/;function yn(i,n){if(!X.test(i??""))throw new a(`invalid ${n} name '${i}'`,{hint:"use lowercase letters, digits, '-' and '_' (start with a letter or digit)"});return i}function g(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function d(i,n){let t=i[n];return typeof t=="string"?t:null}var C=[["tenant","tenant"],["username","username"],["method","method"],["client_id","clientId"],["config_dir","configDir"],["secret_env","secretEnv"],["certificate","certificate"],["organization","organization"],["pat_env","patEnv"]],y=class i{name;tenant;username;method;clientId;configDir;secretEnv;certificate;organization;patEnv;ephemeral=!1;constructor(n,t){this.name=n,this.tenant=t.tenant,this.username=t.username??null,this.method=t.method,this.clientId=t.clientId??null,this.configDir=t.configDir??null,this.secretEnv=t.secretEnv??null,this.certificate=t.certificate??null,this.organization=t.organization??null,this.patEnv=t.patEnv??null}get effectiveClientId(){return this.clientId||on}account(){return JSON.stringify(C.map(([,n])=>this[n]))}toDict(){let n={};for(let[t,o]of C)this[o]!==null&&this[o]!==""&&(n[t]=this[o]);return n}static fromDict(n,t){return new i(n,{tenant:d(t,"tenant")??"",username:d(t,"username"),method:d(t,"method")??"browser",clientId:d(t,"client_id"),configDir:d(t,"config_dir"),secretEnv:d(t,"secret_env"),certificate:d(t,"certificate"),organization:d(t,"organization"),patEnv:d(t,"pat_env")})}clone(){let n=new i(this.name,this);return n.ephemeral=this.ephemeral,n}},$=class i{name;identity;mode;constructor(n,t=null,o="read-only"){this.name=n,this.identity=t,this.mode=o}clone(){return new i(this.name,this.identity,this.mode)}},m=class i{name;group;service;url;org;project;constructor(n,t,o,e={}){this.name=n,this.group=t,this.service=o,this.url=e.url??null,this.org=e.org??null,this.project=e.project??null}get endpoint(){return this.service==="dataverse"?this.url??"":[this.org,this.project].filter(n=>n).join("/")}spec(){return this.service==="dataverse"?{url:this.url}:{org:this.org,project:this.project}}toDict(){return{[this.service]:this.endpoint}}static fromDict(n,t,o){let e=d(o,"dataverse");if(e!==null)return new i(n,t,"dataverse",{url:e});let r=d(o,"devops");if(r!==null){let s=r.indexOf("/"),c=s<0?r:r.slice(0,s),l=s<0?"":r.slice(s+1);return new i(n,t,"devops",{org:c,project:l||null})}throw new a(`environment '${n}' in group '${t}' needs 'dataverse = "<url>"' or 'devops = "<org>/<project>"'`)}clone(){return new i(this.name,this.group,this.service,this)}};function x(i){return i?i instanceof Map?new Map(i):new Map(Object.entries(i)):new Map}function U(i){if(!g(i))return i;let n={};for(let[t,o]of Object.entries(i))o!=null&&(n[t]=U(o));return n}function V(i){let n;try{n=W(i)}catch(e){if(e.code==="ENOENT")return null;throw e}let t;try{t=new TextDecoder("utf-8",{fatal:!0}).decode(n)}catch{throw new a(`cannot read ${i}: not valid UTF-8`,{hint:"fix or delete the file"})}let o;try{o=JSON.parse(t)}catch(e){throw new a(`cannot read ${i}: ${e.message}`,{hint:"fix or delete the file"})}if(!g(o))throw new a(`cannot read ${i}: expected a JSON object`,{hint:"fix or delete the file"});return o}var L=new Set;function G(i,n){L.has(i)||(L.add(i),R(`ignored ${i}: ppdo-cli now reads ${K(i)===F?N:"config.json"}; ${n}`))}function S(i,n,t){let o=i[n];if(o==null)return{};if(!g(o))throw new a(`cannot read ${t}: '${n}' must be an object`,{hint:"fix or delete the file"});return o}var j=class i{identities;groups;environments;current;output;schema;path;constructor(n={}){this.identities=x(n.identities),this.groups=x(n.groups),this.environments=x(n.environments),this.current={...n.current??{}},this.output=n.output??null,this.schema=n.schema??null,this.path=n.path??null}static async load(n=w()){let t=V(n);if(t)return i.fromData(t,n);let o=f(T(n),tn);return D(o)&&G(o,"set up again with ppdo-cli identity add, group add and env add"),new i({path:n})}static fromData(n,t=null){let o=t??"the config",e=new Map,r=new Map;for(let[u,p]of Object.entries(S(n,"groups",o))){let b=g(p)?p:{};e.set(u,new $(u,d(b,"identity"),d(b,"mode")??"read-only"));for(let[v,P]of Object.entries(S(b,"environments",o))){if(r.has(v))throw new a(`environment '${v}' is in more than one group`,{hint:`fix ${o}`});r.set(v,m.fromDict(v,u,g(P)?P:{}))}}let s=new Map;for(let[u,p]of Object.entries(S(n,"identities",o)))s.set(u,y.fromDict(u,g(p)?p:{}));let c={};for(let u of I){let p=d(n,`current-${u}`);p&&(c[u]=p)}let l=new i({identities:s,groups:e,environments:r,current:c,output:d(n,"output"),schema:d(n,"$schema"),path:t});return l.checkFile(o),l}checkFile(n){let t={hint:`fix ${n}`};for(let e of this.identities.values())if(!A.includes(e.method))throw new a(`identity '${e.name}' has method '${e.method}'; use one of: ${A.join(", ")}`,t);for(let e of this.groups.values())if(!O.includes(e.mode))throw new a(`group '${e.name}' has mode '${e.mode}'; use one of: ${O.join(", ")}`,t);let o=new Map;for(let e of this.environments.values()){let r=`${e.service}
3
3
  ${e.endpoint.toLowerCase()}`,s=o.get(r);if(s!==void 0)throw new a(`${e.endpoint} is both environment '${s}' and '${e.name}'`,{hint:`an environment belongs to one group, so it has one account and one mode; keep one of them in ${n}`});o.set(r,e.name)}this.checkPat(n)}checkPat(n){let t=n?`fix ${n}`:"a PAT identity is for one Azure DevOps organization: see ppdo-cli identity show <name>",o=n?`; fix ${n}`:"";for(let e of this.identities.values()){let r=`identity '${e.name}'`;if(e.method!=="pat"){if(e.organization!==null||e.patEnv!==null)throw new a(`${r}: 'organization' and 'pat_env' are for method 'pat' only`,{hint:t});continue}if(!e.organization||!k.test(e.organization))throw new a(`${r} (method 'pat') needs 'organization': an Azure DevOps organization name`,{hint:t});if(!e.username)throw new a(`${r} (method 'pat') needs 'username': the account the PAT belongs to`,{hint:t});if(e.clientId!==null||e.configDir!==null||e.secretEnv!==null||e.certificate!==null)throw new a(`${r}: 'client_id', 'config_dir', 'secret_env' and 'certificate' don't apply to method 'pat'`,{hint:t});if(e.patEnv!==null&&!rn.test(e.patEnv))throw new a(`${r}: 'pat_env' must be an environment variable name`,{hint:t})}for(let e of this.groups.values()){let r=e.identity?this.identities.get(e.identity):void 0;if(!r||r.method!=="pat")continue;let s=(r.organization??"").toLowerCase();for(let c of this.members(e.name)){if(c.service!=="devops")throw new a(`group '${e.name}' uses PAT identity '${r.name}', so it can't hold Dataverse environment '${c.name}'`,{hint:"a PAT reaches Azure DevOps only: put the environment in a group with another identity"+o});if(!c.org||!k.test(c.org)||c.org.toLowerCase()!==s)throw new a(`group '${e.name}' uses PAT identity '${r.name}' for organization '${r.organization}', so it can't hold '${c.name}' (${c.endpoint})`,{hint:"a PAT is for one organization: use another group and identity for this one"+o})}}}toDict(){let n={};for(let e of this.groups.values()){let r={identity:e.identity,mode:e.mode},s={};for(let c of this.members(e.name))s[c.name]=c.toDict();Object.keys(s).length&&(r.environments=s),n[e.name]=r}let t={};for(let[e,r]of this.identities)t[e]=r.toDict();let o={$schema:this.schema};for(let e of I)o[`current-${e}`]=this.current[e]??null;return o.output=this.output,o.identities=t,o.groups=n,o}async dumps(){let n=U(this.toDict());for(let t of["identities","groups"])g(n[t])&&!Object.keys(n[t]).length&&delete n[t];return JSON.stringify(n,null,2)+`
4
4
  `}async save(){let{atomicWrite:n}=await import("./protect-X2J7LU7X.js");n(this.path??w(),await this.dumps())}static async edit(n){let{withFileLock:t}=await import("./protect-X2J7LU7X.js"),o=w();return t(o,async()=>{let e=await i.load(o),r=await n(e);return await e.save(),r})}clone(){let n=t=>new Map([...t].map(([o,e])=>[o,e.clone()]));return new i({identities:n(this.identities),groups:n(this.groups),environments:n(this.environments),current:this.current,output:this.output,schema:this.schema,path:this.path})}validate(){let n=new Map;for(let t of this.environments.values()){this.group(t.group);let o=`${t.service}
5
- ${t.endpoint.toLowerCase()}`,e=n.get(o);if(e!==void 0)throw new a(`${t.endpoint} is already environment '${e}'`,{hint:`an environment belongs to one group; move it instead: ppdo-cli env move ${e} --to <group>`});n.set(o,t.name)}for(let t of this.groups.values())t.identity&&this.identity(t.identity);this.checkPat(null)}identity(n){let t=this.identities.get(n);if(!t)throw new a(`no identity named '${n}'`,{hint:"run: ppdo-cli identity list"});return t}group(n){let t=this.groups.get(n);if(!t)throw new a(`no group named '${n}'`,{hint:"run: ppdo-cli group list"});return t}environment(n){let t=this.environments.get(n);if(!t)throw new a(`no environment named '${n}'`,{hint:"run: ppdo-cli env list"});return t}members(n){return[...this.environments.values()].filter(t=>t.group===n)}};function _(i){let n=new Map;for(let t of i.environments.values()){let o=i.groups.get(t.group),e=o&&o.identity?i.identities.get(o.identity):void 0;if(!o||!e)continue;let r=JSON.stringify([t.service,t.endpoint.toLowerCase(),e.account()]),s=nn[o.mode]??0;s>=(n.get(r)?.[0]??-1)&&n.set(r,[s,t.name])}return n}function $n(i,n){let t=_(i),o=[];for(let[e,[r,s]]of _(n))if(r>(t.get(e)?.[0]??0)){let c=n.environment(s),l=n.group(c.group),u=n.identity(l.identity??""),p=l.mode==="full"?"write and delete":"write";o.push(`agents could ${p} in '${s}' (${c.endpoint}) as ${u.username||u.name} (group '${l.name}', ${l.mode})`)}return o}function J(i){let n=Q(i??process.cwd());try{return Y(n)}catch{return n}}function Z(i){let n=[i];for(let t=T(i);t!==n[n.length-1];t=T(t))n.push(t);return n}function D(i){try{return q(i).isFile()}catch{return!1}}async function sn(i){let n=Z(J(i)),t=n.findIndex(e=>M(f(e,".git"))),o=t>=0?n.slice(0,t+1):n.slice(0,1);for(let e of o){let r=f(e,N);if(!D(r)){let l=f(e,F);D(l)&&G(l,"pin again with ppdo-cli env pin <env>");continue}let s;try{s=V(r)}catch(l){throw l instanceof a?new a(l.message):l}if(!s)continue;let c={};for(let l of I){let u=s[l];typeof u=="string"&&u&&(c[l]=u)}if(!Object.keys(c).length)throw new a(`${r} names no environment`,{hint:'expected {"dataverse": "<env>"} and/or {"devops": "<env>"}; run: ppdo-cli env pin <env>'});return[c,r]}return null}function En(i){for(let n of Z(J(i)))if(M(f(n,".git")))return n;return null}var E=class{env;group;source;app;constructor(n,t,o,e=!1){this.env=n,this.group=t,this.source=o,this.app=e}get mode(){return this.group.mode}};function B(i){return!!i&&i.includes("://")}function an(i){return`run: ppdo-cli env list --service ${i==="devops"?"ado":"dv"}`}async function bn(i,n,t){let[o,e]=await H(i,n,t);if(B(o))throw new a(`'${o}' is a URL; a URL target needs --client-id and --tenant`,{hint:"or pass an environment name (see ppdo-cli env list)"});let r=i.environment(o);if(r.service!==n)throw new a(`environment '${o}' is a ${h[r.service]} environment, not ${h[n]}`,{hint:an(n)});return new E(r,i.group(r.group),e)}async function H(i,n,t){let o,e="",r=process.env[z[n]];if(t)[o,e]=[t,"flag"];else if(r)[o,e]=[r,`env ${z[n]}`];else{let s=await sn();s&&s[0][n]?[o,e]=[s[0][n],`file ${s[1]}`]:i.current[n]&&([o,e]=[i.current[n],`global current-${n}`])}if(!o)throw new a(`no ${h[n]} environment selected`,{hint:"pass --env <name>, or run: ppdo-cli env use <name> (see ppdo-cli env list)"});return[o,e]}var cn=[["clientId","--client-id"],["tenant","--tenant"],["certificate","--certificate"],["mode","--mode"]];function xn(i){let n=cn.filter(([t])=>i[t]);if(!n.length)return!1;if(!n.some(([t])=>t==="clientId")){let t=n.map(([,o])=>o).join(", ");throw new a(`${t} ${n.length===1?"applies":"apply"} only with --client-id`,{hint:"a configured environment's mode comes from its group (ppdo-cli group list)"})}if(!i.tenant)throw new a("--client-id needs --tenant <id|domain>");if(i.identity)throw new a("use --identity or --client-id, not both");return!0}function ln(i){let n=String(i.clientId).trim(),t=i.certificate?String(i.certificate):null,o=new y(`app:${n}`,{tenant:String(i.tenant).trim(),username:null,method:"spn",clientId:n,secretEnv:t?null:en,certificate:t});return o.ephemeral=!0,o}function un(i){if(!i.includes("://"))return null;let n;try{n=new URL(i.trim())}catch{throw new a(`'${i}' is not a dev.azure.com URL`)}let t=n.hostname.toLowerCase(),o=n.pathname.split("/").filter(c=>c).map(c=>decodeURIComponent(c)),e,r;if(t==="dev.azure.com"&&o.length)e=o[0]??"",r=o.slice(1);else if(t.endsWith(".visualstudio.com"))e=t.split(".")[0]??"",r=o,r[0]?.toLowerCase()==="defaultcollection"&&(r=r.slice(1));else throw new a(`'${i}' is not a dev.azure.com URL`);let s=r[0];return[e,s&&!s.startsWith("_")?s:null]}function dn(i,n){if(i==="dataverse"){let r=pn(n);return new m(r.slice(r.indexOf("://")+3),"app","dataverse",{url:r})}let t=un(n);if(!t)throw new a(`'${n}' is not a dev.azure.com URL`);let[o,e]=t;return new m([o,e].filter(r=>r).join("/"),"app","devops",{org:o,project:e})}async function Sn(i,n,t){let o=typeof t.env=="string"?t.env:null,[e,r]=await H(i,n,o),s;if(B(e))s=dn(n,e);else if(s=i.environment(e),s.service!==n)throw new a(`environment '${e}' is a ${h[s.service]} environment, not ${h[n]}`);let c=new $("app",null,typeof t.mode=="string"&&t.mode?t.mode:"read-only");return[new E(s,c,r,!0),ln(t)]}function Tn(i,n,t){if(t)return[i.identity(t),"flag"];let o=process.env.PPDEVOPS_IDENTITY;if(o)return[i.identity(o),"env PPDEVOPS_IDENTITY"];let e=n.group.identity;if(!e)throw new a(`group '${n.group.name}' has no identity`,{hint:`run: ppdo-cli group update ${n.group.name} --identity <name>`});return[i.identity(e),`group ${n.group.name}`]}function pn(i){let n=i.trim();n.includes("://")||(n="https://"+n);let t=null;try{t=new URL(n)}catch{t=null}if(!t||t.protocol!=="https:"||!t.hostname)throw new a(`invalid Dataverse URL '${n}'`,{hint:"use https://<org>.crm.dynamics.com"});return`https://${t.hostname.toLowerCase()}`}export{X as a,A as b,O as c,nn as d,I as e,wn as f,h as g,z as h,N as i,en as j,on as k,k as l,rn as m,yn as n,y as o,$ as p,m as q,V as r,j as s,_ as t,$n as u,sn as v,En as w,E as x,B as y,bn as z,xn as A,ln as B,un as C,dn as D,Sn as E,Tn as F,pn as G};
5
+ ${t.endpoint.toLowerCase()}`,e=n.get(o);if(e!==void 0)throw new a(`${t.endpoint} is already environment '${e}'`,{hint:`an environment belongs to one group; move it instead: ppdo-cli env move ${e} --to <group>`});n.set(o,t.name)}for(let t of this.groups.values())t.identity&&this.identity(t.identity);this.checkPat(null)}identity(n){let t=this.identities.get(n);if(!t)throw new a(`no identity named '${n}'`,{hint:"run: ppdo-cli identity list"});return t}group(n){let t=this.groups.get(n);if(!t)throw new a(`no group named '${n}'`,{hint:"run: ppdo-cli group list"});return t}environment(n){let t=this.environments.get(n);if(!t)throw new a(`no environment named '${n}'`,{hint:"run: ppdo-cli env list"});return t}members(n){return[...this.environments.values()].filter(t=>t.group===n)}};function _(i){let n=new Map;for(let t of i.environments.values()){let o=i.groups.get(t.group),e=o&&o.identity?i.identities.get(o.identity):void 0;if(!o||!e)continue;let r=JSON.stringify([t.service,t.endpoint.toLowerCase(),e.account()]),s=nn[o.mode]??0;s>=(n.get(r)?.[0]??-1)&&n.set(r,[s,t.name])}return n}function $n(i,n){let t=_(i),o=[];for(let[e,[r,s]]of _(n))if(r>(t.get(e)?.[0]??0)){let c=n.environment(s),l=n.group(c.group),u=n.identity(l.identity??""),p=l.mode==="full"?"write and delete":"write";o.push(`agents could ${p} in '${s}' (${c.endpoint}) as ${u.username||u.name} (group '${l.name}', ${l.mode})`)}return o}function J(i){let n=Q(i??process.cwd());try{return Y(n)}catch{return n}}function Z(i){let n=[i];for(let t=T(i);t!==n[n.length-1];t=T(t))n.push(t);return n}function D(i){try{return q(i).isFile()}catch{return!1}}async function sn(i){let n=Z(J(i)),t=n.findIndex(e=>M(f(e,".git"))),o=t>=0?n.slice(0,t+1):n.slice(0,1);for(let e of o){let r=f(e,N);if(!D(r)){let l=f(e,F);D(l)&&G(l,"pin again with ppdo-cli env pin <env>");continue}let s;try{s=V(r)}catch(l){throw l instanceof a?new a(l.message):l}if(!s)continue;let c={};for(let l of I){let u=s[l];typeof u=="string"&&u&&(c[l]=u)}if(Object.keys(c).length)return[c,r]}return null}function En(i){for(let n of Z(J(i)))if(M(f(n,".git")))return n;return null}var E=class{env;group;source;app;constructor(n,t,o,e=!1){this.env=n,this.group=t,this.source=o,this.app=e}get mode(){return this.group.mode}};function B(i){return!!i&&i.includes("://")}function an(i){return`run: ppdo-cli env list --service ${i==="devops"?"ado":"dv"}`}async function bn(i,n,t){let[o,e]=await H(i,n,t);if(B(o))throw new a(`'${o}' is a URL; a URL target needs --client-id and --tenant`,{hint:"or pass an environment name (see ppdo-cli env list)"});let r=i.environment(o);if(r.service!==n)throw new a(`environment '${o}' is a ${h[r.service]} environment, not ${h[n]}`,{hint:an(n)});return new E(r,i.group(r.group),e)}async function H(i,n,t){let o,e="",r=process.env[z[n]];if(t)[o,e]=[t,"flag"];else if(r)[o,e]=[r,`env ${z[n]}`];else{let s=await sn();s&&s[0][n]?[o,e]=[s[0][n],`file ${s[1]}`]:i.current[n]&&([o,e]=[i.current[n],`global current-${n}`])}if(!o)throw new a(`no ${h[n]} environment selected`,{hint:"pass --env <name>, or run: ppdo-cli env use <name> (see ppdo-cli env list)"});return[o,e]}var cn=[["clientId","--client-id"],["tenant","--tenant"],["certificate","--certificate"],["mode","--mode"]];function xn(i){let n=cn.filter(([t])=>i[t]);if(!n.length)return!1;if(!n.some(([t])=>t==="clientId")){let t=n.map(([,o])=>o).join(", ");throw new a(`${t} ${n.length===1?"applies":"apply"} only with --client-id`,{hint:"a configured environment's mode comes from its group (ppdo-cli group list)"})}if(!i.tenant)throw new a("--client-id needs --tenant <id|domain>");if(i.identity)throw new a("use --identity or --client-id, not both");return!0}function ln(i){let n=String(i.clientId).trim(),t=i.certificate?String(i.certificate):null,o=new y(`app:${n}`,{tenant:String(i.tenant).trim(),username:null,method:"spn",clientId:n,secretEnv:t?null:en,certificate:t});return o.ephemeral=!0,o}function un(i){if(!i.includes("://"))return null;let n;try{n=new URL(i.trim())}catch{throw new a(`'${i}' is not a dev.azure.com URL`)}let t=n.hostname.toLowerCase(),o=n.pathname.split("/").filter(c=>c).map(c=>decodeURIComponent(c)),e,r;if(t==="dev.azure.com"&&o.length)e=o[0]??"",r=o.slice(1);else if(t.endsWith(".visualstudio.com"))e=t.split(".")[0]??"",r=o,r[0]?.toLowerCase()==="defaultcollection"&&(r=r.slice(1));else throw new a(`'${i}' is not a dev.azure.com URL`);let s=r[0];return[e,s&&!s.startsWith("_")?s:null]}function dn(i,n){if(i==="dataverse"){let r=pn(n);return new m(r.slice(r.indexOf("://")+3),"app","dataverse",{url:r})}let t=un(n);if(!t)throw new a(`'${n}' is not a dev.azure.com URL`);let[o,e]=t;return new m([o,e].filter(r=>r).join("/"),"app","devops",{org:o,project:e})}async function Sn(i,n,t){let o=typeof t.env=="string"?t.env:null,[e,r]=await H(i,n,o),s;if(B(e))s=dn(n,e);else if(s=i.environment(e),s.service!==n)throw new a(`environment '${e}' is a ${h[s.service]} environment, not ${h[n]}`);let c=new $("app",null,typeof t.mode=="string"&&t.mode?t.mode:"read-only");return[new E(s,c,r,!0),ln(t)]}function Tn(i,n,t){if(t)return[i.identity(t),"flag"];let o=process.env.PPDEVOPS_IDENTITY;if(o)return[i.identity(o),"env PPDEVOPS_IDENTITY"];let e=n.group.identity;if(!e)throw new a(`group '${n.group.name}' has no identity`,{hint:`run: ppdo-cli group update ${n.group.name} --identity <name>`});return[i.identity(e),`group ${n.group.name}`]}function pn(i){let n=i.trim();n.includes("://")||(n="https://"+n);let t=null;try{t=new URL(n)}catch{t=null}if(!t||t.protocol!=="https:"||!t.hostname)throw new a(`invalid Dataverse URL '${n}'`,{hint:"use https://<org>.crm.dynamics.com"});return`https://${t.hostname.toLowerCase()}`}export{X as a,A as b,O as c,nn as d,I as e,wn as f,h as g,z as h,N as i,en as j,on as k,k as l,rn as m,yn as n,y as o,$ as p,m as q,V as r,j as s,_ as t,$n as u,sn as v,En as w,E as x,B as y,bn as z,xn as A,ln as B,un as C,dn as D,Sn as E,Tn as F,pn as G};
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
2
- import{y as P}from"./chunk-BALEFXOL.js";import{c as K}from"./chunk-B4FPKDMH.js";import{a as R,b as U,e as J}from"./chunk-J4R6QXW7.js";import{b as v}from"./chunk-5SBBTR3Y.js";import{e as $}from"./chunk-S4KF5Z3S.js";import{a as E,b as h,j as L}from"./chunk-WXOTXJNG.js";var C=class{constructor(e,t){this.a=e;this.b=t;t.forEach((i,o)=>{let s=this.b2j.get(i);s?s.push(o):this.b2j.set(i,[o])});let r=t.length;if(r>=200){let i=Math.floor(r/100)+1;for(let[o,s]of[...this.b2j])s.length>i&&this.b2j.delete(o)}}b2j=new Map;findLongestMatch(e,t,r,i){let{a:o,b:s}=this,u=e,c=r,l=0,a=new Map;for(let f=e;f<t;f++){let p=new Map;for(let d of this.b2j.get(o[f])??[]){if(d<r)continue;if(d>=i)break;let m=(a.get(d-1)??0)+1;p.set(d,m),m>l&&(u=f-m+1,c=d-m+1,l=m)}a=p}for(;u>e&&c>r&&o[u-1]===s[c-1];)u--,c--,l++;for(;u+l<t&&c+l<i&&o[u+l]===s[c+l];)l++;return[u,c,l]}matchingBlocks(){let e=this.a.length,t=this.b.length,r=[[0,e,0,t]],i=[];for(;r.length;){let[l,a,f,p]=r.pop(),d=this.findLongestMatch(l,a,f,p),[m,g,x]=d;x&&(i.push(d),l<m&&f<g&&r.push([l,m,f,g]),m+x<a&&g+x<p&&r.push([m+x,a,g+x,p]))}i.sort((l,a)=>l[0]-a[0]||l[1]-a[1]||l[2]-a[2]);let[o,s,u]=[0,0,0],c=[];for(let[l,a,f]of i)o+u===l&&s+u===a?u+=f:(u&&c.push([o,s,u]),[o,s,u]=[l,a,f]);return u&&c.push([o,s,u]),c.push([e,t,0]),c}opcodes(){let e=0,t=0,r=[];for(let[i,o,s]of this.matchingBlocks()){let u=e<i&&t<o?"replace":e<i?"delete":t<o?"insert":"";u&&r.push([u,e,i,t,o]),e=i+s,t=o+s,s&&r.push(["equal",i,e,o,t])}return r}groupedOpcodes(e=3){let t=this.opcodes();t.length||(t=[["equal",0,1,0,1]]);let r=t[0];if(r[0]==="equal"){let[c,l,a,f,p]=r;t[0]=[c,Math.max(l,a-e),a,Math.max(f,p-e),p]}let i=t[t.length-1];if(i[0]==="equal"){let[c,l,a,f,p]=i;t[t.length-1]=[c,l,Math.min(a,l+e),f,Math.min(p,f+e)]}let o=e+e,s=[],u=[];for(let c of t){let[l,a,f,p,d]=c;l==="equal"&&f-a>o&&(u.push([l,a,Math.min(f,a+e),p,Math.min(d,p+e)]),s.push(u),u=[],a=Math.max(a,f-e),p=Math.max(p,d-e)),u.push([l,a,f,p,d])}return u.length&&!(u.length===1&&u[0][0]==="equal")&&s.push(u),s}};function D(n,e){let t=n+1,r=e-n;return r===1?String(t):(r||(t-=1),`${t},${r}`)}function _(n,e,t,r,i=3){let o=[],s=!1;for(let u of new C(n,e).groupedOpcodes(i)){s||(s=!0,o.push(`--- ${t}
2
+ import{y as P}from"./chunk-BALEFXOL.js";import{c as K}from"./chunk-6NBCHK6X.js";import{a as R,b as U,e as J}from"./chunk-J4R6QXW7.js";import{b as v}from"./chunk-2IUXH534.js";import{e as $}from"./chunk-S4KF5Z3S.js";import{a as E,b as h,j as L}from"./chunk-WXOTXJNG.js";var C=class{constructor(e,t){this.a=e;this.b=t;t.forEach((i,o)=>{let s=this.b2j.get(i);s?s.push(o):this.b2j.set(i,[o])});let r=t.length;if(r>=200){let i=Math.floor(r/100)+1;for(let[o,s]of[...this.b2j])s.length>i&&this.b2j.delete(o)}}b2j=new Map;findLongestMatch(e,t,r,i){let{a:o,b:s}=this,u=e,c=r,l=0,a=new Map;for(let f=e;f<t;f++){let p=new Map;for(let d of this.b2j.get(o[f])??[]){if(d<r)continue;if(d>=i)break;let m=(a.get(d-1)??0)+1;p.set(d,m),m>l&&(u=f-m+1,c=d-m+1,l=m)}a=p}for(;u>e&&c>r&&o[u-1]===s[c-1];)u--,c--,l++;for(;u+l<t&&c+l<i&&o[u+l]===s[c+l];)l++;return[u,c,l]}matchingBlocks(){let e=this.a.length,t=this.b.length,r=[[0,e,0,t]],i=[];for(;r.length;){let[l,a,f,p]=r.pop(),d=this.findLongestMatch(l,a,f,p),[m,g,x]=d;x&&(i.push(d),l<m&&f<g&&r.push([l,m,f,g]),m+x<a&&g+x<p&&r.push([m+x,a,g+x,p]))}i.sort((l,a)=>l[0]-a[0]||l[1]-a[1]||l[2]-a[2]);let[o,s,u]=[0,0,0],c=[];for(let[l,a,f]of i)o+u===l&&s+u===a?u+=f:(u&&c.push([o,s,u]),[o,s,u]=[l,a,f]);return u&&c.push([o,s,u]),c.push([e,t,0]),c}opcodes(){let e=0,t=0,r=[];for(let[i,o,s]of this.matchingBlocks()){let u=e<i&&t<o?"replace":e<i?"delete":t<o?"insert":"";u&&r.push([u,e,i,t,o]),e=i+s,t=o+s,s&&r.push(["equal",i,e,o,t])}return r}groupedOpcodes(e=3){let t=this.opcodes();t.length||(t=[["equal",0,1,0,1]]);let r=t[0];if(r[0]==="equal"){let[c,l,a,f,p]=r;t[0]=[c,Math.max(l,a-e),a,Math.max(f,p-e),p]}let i=t[t.length-1];if(i[0]==="equal"){let[c,l,a,f,p]=i;t[t.length-1]=[c,l,Math.min(a,l+e),f,Math.min(p,f+e)]}let o=e+e,s=[],u=[];for(let c of t){let[l,a,f,p,d]=c;l==="equal"&&f-a>o&&(u.push([l,a,Math.min(f,a+e),p,Math.min(d,p+e)]),s.push(u),u=[],a=Math.max(a,f-e),p=Math.max(p,d-e)),u.push([l,a,f,p,d])}return u.length&&!(u.length===1&&u[0][0]==="equal")&&s.push(u),s}};function D(n,e){let t=n+1,r=e-n;return r===1?String(t):(r||(t-=1),`${t},${r}`)}function _(n,e,t,r,i=3){let o=[],s=!1;for(let u of new C(n,e).groupedOpcodes(i)){s||(s=!0,o.push(`--- ${t}
3
3
  `,`+++ ${r}
4
4
  `));let c=u[0],l=u[u.length-1];o.push(`@@ -${D(c[1],l[2])} +${D(c[3],l[4])} @@
5
5
  `);for(let[a,f,p,d,m]of u){if(a==="equal"){for(let g of n.slice(f,p))o.push(" "+g);continue}if(a==="replace"||a==="delete")for(let g of n.slice(f,p))o.push("-"+g);if(a==="replace"||a==="insert")for(let g of e.slice(d,m))o.push("+"+g)}}return o.join("")}var S=[10,11,12,13,28,29,30,133,8232,8233].map(n=>String.fromCharCode(n)).join(""),G=new RegExp(`[^${S}]*(?:\\r\\n|[${S}]|$)`,"g");function O(n){let e=[];for(let t of n.matchAll(G)){if(t[0]===""){if((t.index??0)>=n.length)break;continue}e.push(t[0])}return e}function wn(n){return O(n).map(e=>e.replace(new RegExp(`(?:\\r\\n|[${S}])$`),""))}function Y(n){return n.replace(/[.*+?^${}()|[\]\\/]/g,"\\$&")}var N=new Map;function Z(n){let e=N.get(n);if(e)return e;let t="",r=!1,i=0,o=n.length;for(;i<o;){let u=n[i];if(i++,u==="*"){r||(t+="[\\s\\S]*"),r=!0;continue}if(r=!1,u==="?")t+="[\\s\\S]";else if(u==="["){let c=i;for(c<o&&n[c]==="!"&&c++,c<o&&n[c]==="]"&&c++;c<o&&n[c]!=="]";)c++;if(c>=o)t+="\\[";else{let l=n.slice(i,c).replace(/\\/g,"\\\\");i=c+1,l?l==="!"?t+="[\\s\\S]":(l[0]==="!"?l="^"+l.slice(1):(l[0]==="^"||l[0]==="[")&&(l="\\"+l),t+=`[${l.replace(/\]/g,"\\]")}]`):t+="(?!)"}}else t+=Y(u)}let s=new RegExp(`^${t}$`,"u");return N.set(n,s),s}function xn(n,e){try{return Z(e).test(n)}catch{return n===e}}var Q={run:[/[?&]buildId=(\d+)/i],pr:[/\/pullrequests?\/(\d+)/i],wi:[/\/_workitems\/edit\/(\d+)/i,/\/workitems\/(\d+)/i],pipeline:[/[?&]definitionId=(\d+)/i,/\/_apis\/pipelines\/(\d+)/i,/\/_apis\/build\/definitions\/(\d+)/i]},X={run:"run",pr:"PR",wi:"work item",pipeline:"pipeline"};function nn(n){let e=n.slice(n.lastIndexOf("@")+1);return e.startsWith("[")?e=e.slice(1,e.indexOf("]")<0?void 0:e.indexOf("]")):e.includes(":")&&(e=e.slice(0,e.indexOf(":"))),e.toLowerCase()}function en(n){if(!n.includes("://"))return null;let e=J(n.trim()),t=nn(e.netloc),r=e.path.split("/").filter(c=>c).map(c=>U(c)),i,o;if(t==="dev.azure.com"&&r.length)i=r[0],o=r.slice(1);else if(t.endsWith(".visualstudio.com"))i=t.split(".",1)[0],o=r,o.length&&o[0].toLowerCase()==="defaultcollection"&&(o=o.slice(1));else throw new h(`'${n}' is not a dev.azure.com URL`);let s=o[0],u=s!==void 0&&!s.startsWith("_")?s:null;return[i,u]}function q(n,e,t){let r=e?en(n):null;if(!r||!e)return;let[i,o]=r,s=e.service,u=i.toLowerCase()===s.org.toLowerCase(),c=t==="wi"||!o||!s.project||o.toLowerCase()===s.project.toLowerCase();if(!(u&&c)){let l=o?`${i}/${o}`:i,a=e.target.env.name;throw new h(`that URL is for ${l}, but environment '${a}' is ${s.org}/${s.project??""}`.replace(/\/+$/,""),{hint:`pass --env with the environment for ${l} (ppdo-cli env list)`})}}function T(n,e,t){let r=String(n).trim();if(/^\d+$/.test(r))return parseInt(r,10);for(let i of Q[e]??[]){let o=i.exec(r);if(o)return q(r,t,e),parseInt(o[1],10)}throw new h(`expected a ${X[e]??e} id or its dev.azure.com URL, got '${r}'`)}function z(n,e,t){let r=[];for(let i of n??[])for(let o of String(i).split(","))o.trim()&&r.push(T(o,e,t));return[...new Set(r)]}function F(n,e){let t=n.trim();if(/^[0-9a-fA-F]{40}$/.test(t))return t.toLowerCase();if(/^[0-9a-fA-F]{7,39}$/.test(t))throw new h(`'${t}' is a short SHA; Azure DevOps needs all 40 characters`,{hint:"use git rev-parse <sha>, or paste the commit's URL"});let r=/\/commits?\/([0-9a-fA-F]{40})/.exec(t);if(r)return q(t,e,"commit"),r[1].toLowerCase();throw new h(`expected a commit SHA or its dev.azure.com URL, got '${t}'`)}var rn=100;function k(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}function w(n){return n==null||n===!1||n===0||n===""?!1:Array.isArray(n)?n.length>0:k(n)?Object.keys(n).length>0:!0}function A(...n){for(let e of n)if(w(e))return e;return n[n.length-1]}function on(n,e){return k(n)?n[e]??null:null}function I(n){return k(n)&&w(n)?n:{}}function sn(n){return Array.isArray(n)?n:[]}function y(n){return typeof n=="string"?n:n==null?null:String(n)}function Tn(n,e=[]){let t={};for(let[r,i]of Object.entries(n))i!=null&&(e.some(o=>o===i||Array.isArray(o)&&Array.isArray(i)&&!o.length&&!i.length)||(t[r]=i));return t}function b(n){return n==null?"None":n===!0?"True":n===!1?"False":String(n)}function An(n){return/^\d+$/.test(n)}function un(n,e){let t=typeof n=="boolean"?Number(n):n,r=typeof e=="boolean"?Number(e):e;return t===r?0:t==null?-1:r==null?1:t<r?-1:1}function In(n,e,t=!1){let r=n.map((i,o)=>({r:i,i:o,k:[e(i)].flat()}));return r.sort((i,o)=>{for(let s=0;s<Math.max(i.k.length,o.k.length);s++){let u=un(i.k[s],o.k[s]);if(u)return t?-u:u}return i.i-o.i}),r.map(i=>i.r)}function Mn(n){let e=Math.floor(n),t=n-e;return t>.5?e+1:t<.5||e%2===0?e:e+1}function Bn(n){if(Number.isInteger(n*4)&&!Number.isInteger(n*2)){let e=Math.floor(n*10)/10,t=Math.ceil(n*10)/10;return Math.round(e*10)%2===0?e:t}return Number(n.toFixed(1))}function W(n){let e=new Error(n);return e.name="ValueError",e}function En(n){if(!/^\s*[+-]?\d+\s*$/.test(n))throw W(`invalid literal for int() with base 10: '${n}'`);return parseInt(n,10)}function ln(n){if(n.all)return null;let e=n.limit;return typeof e=="number"&&e>0?e:rn}function Ln(n,e,t){let r=ln(e);return r!==null&&n.length>r?($(`showing the first ${r} ${t}; pass --limit n or --all for more`),n.slice(0,r)):n}function Pn(n,e,t){e&&$(`showing the first ${n} ${t}; pass --limit n or --all for more`)}async function Un(n){return n.client("devops")}function M(n){return n.service}function B(n){return n?{service:M(n),target:n.target}:null}function Jn(n,e,t){return T(n,e,B(t))}function Kn(n,e,t){return z(n,e,B(t))}function Dn(n,e){return F(n,B(e))}function V(n){let e=M(n).project;if(!e)throw new h("this command needs a DevOps environment with a project",{hint:"ask the user to set one: ppdo-cli env update <name> --devops-project <project>"});return R(e)}async function j(n,e,t,r,i={}){v(n,e,t,r,i.body??null,i.cls??null);let o=()=>e.request(t,r,{params:i.params??null,headers:i.headers??null,body:i.body??null,check:i.check??!0,saveTo:i.saveTo??null});try{return await o()}catch(s){let u=M(e);if(!(s instanceof E)||s.code!=="VssInvalidPreviewVersionException"||u.apiVersion.includes("-preview"))throw s;return u.apiVersion+="-preview",n.log(` preview-only endpoint; retrying with api-version=${u.apiVersion}`),o()}}async function cn(n,e,t,r=null,i={}){let o=(await j(n,e,"GET",t,{...i,params:r})).json();return w(o)?o:{}}function an(n){let e=n.json();return w(e)?e:{}}function Nn(n){return Buffer.from(fn(n),"utf8")}function fn(n){return L(n)}async function _n(n,e,t){return v(n,e,"PATCH","_apis",Buffer.from("{}")),e.lookups(t)}function pn(n){return k(n)?sn(n.value):Array.isArray(n)?n:[]}async function qn(n,e,t){let r=await cn(n,e,`${V(e)}/_apis/git/repositories/${R(t)}`);return String(r.id)}async function zn(n,e){let t=an(await j(n,e,"GET","_apis/connectionData",{params:[["api-version","7.1-preview"]]})),r=I(t.authenticatedUser);return{id:y(r.id),name:y(r.providerDisplayName)}}async function Fn(n,e,t){let r=e.service,i=e.target.env;e.service=new K({org:i.org,project:i.project},"vssps","7.1");try{let o=await j(n,e,"GET","_apis/identities",{params:[...t,["queryMembership","None"]]});return pn(o.json())}finally{e.service=r}}function Hn(n){if(!w(n))return null;let e=n;return y(A(e.uniqueName,e.displayName)??null)}function Wn(n){let e=y(n);return e&&e.startsWith("refs/heads/")?e.slice(11):e}function Vn(n){return n.startsWith("refs/")?n:`refs/heads/${n}`}function Gn(n){if(/^[A-Za-z]:[\\/]/.test(n))throw new h(`'${n}' looks like a Windows path (Git Bash rewrites arguments that start with /)`,{hint:"drop the leading /, or set MSYS_NO_PATHCONV=1"});return n}var dn=new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0}),mn=new TextDecoder("utf-8",{fatal:!0});function gn(n){try{return dn.decode(n)}catch{return null}}function hn(n){try{return mn.decode(n)}catch{return null}}async function H(n,e,t,r){if(!w(r))return[];let i=await j(n,e,"GET",`${V(e)}/_apis/git/repositories/${t}/blobs/${b(r)}`,{params:[["$format","octetStream"]],headers:{Accept:"application/octet-stream"}}),o=gn(i.body);return o===null?[`<binary file>
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
2
- import{a as b,b as k}from"./chunk-MTF66YXU.js";import{b as j,c as x}from"./chunk-4KP27OCL.js";import{a as l,b as p,c as h,d as g,e as u,f as m,g as f}from"./chunk-J4R6QXW7.js";import{b as v,h as w}from"./chunk-WXOTXJNG.js";var A="499b84ac-1321-427f-aa17-267ca6975798",C="7.1";function y(o){return typeof o=="object"&&o!==null&&!Array.isArray(o)}var S=class extends j{name="devops";org;project;hostKey;apiVersion;constructor(e,n="core",t){super(),this.org=e.org??"",this.project=e.project??null,this.hostKey=n,this.apiVersion=t||C}scope(){return A+"/.default"}base(){return`https://${this.hostKey==="core"?"dev.azure.com":`${this.hostKey}.dev.azure.com`}/${l(this.org)}/`}expand(e){if(e.includes("{project}")){if(!this.project)throw new v("the path uses {project} but the environment has no DevOps project",{hint:"ask the user to set one: ppdo-cli env update <name> --devops-project <project>"});e=e.split("{project}").join(l(this.project))}return e}url(e,n){e=this.expand(e);let t=e.includes("://")?e:this.base()+e.replace(/^\/+/,""),r=u(t),i=[...g(r.query),...n??[]],s=f(t).host||r.netloc.toLowerCase();return!(r.path.includes("/_odata/")||s==="analytics.dev.azure.com")&&!i.some(([d])=>d.toLowerCase()==="api-version")&&i.push(["api-version",this.apiVersion]),m({...r,query:h(i,"$'(),/:@*"),fragment:""})}allowed(e){let n=f(e);if(n.scheme!=="https"||!n.host)return!1;let t=this.org.toLowerCase();if(!t)return!1;if(new Set(["dev.azure.com",...b.filter(s=>s!=="core").map(s=>`${s}.dev.azure.com`)]).has(n.host)){let s=(n.path.replace(/^\/+/,"").split("/",1)[0]??"").toLowerCase();if(s!==t&&s!==l(t).toLowerCase())return!1;let c=u(e).path.replace(/^\/+/,"").split("/");for(let d of c){let a=p(d);if(a==="."||a===".."||a.includes("/")||a.includes("\\"))return!1}return p(c[0]??"").toLowerCase()===t}return new Set([`${t}.visualstudio.com`,...k.map(s=>`${t}.${s}.visualstudio.com`)]).has(n.host)}requestId(e){return e.header("activityid")||e.header("x-vss-e2eid")}authTrap(e){let n=e.header("content-type")??"";return e.status===203||e.status>=200&&e.status<300&&n.includes("text/html")&&e.body.subarray(0,2e3).toString("latin1").toLowerCase().includes("<html")?"Azure DevOps returned a sign-in page instead of data (the token was rejected)":null}error(e){let n=null,t=null,r=null;if(e.body.length)try{let i=e.json(),s=y(i)?i:{};t=typeof s.message=="string"?s.message:null,n=typeof s.typeKey=="string"&&s.typeKey||(s.errorCode?String(s.errorCode):null)||null}catch{t=e.text.trim().slice(0,300)||null}if(t&&t.includes("TF401444"))r="a service principal must be added to the organization first: Organization settings > Users > Add users, with an access level and project permissions";else if(e.status===401||t&&t.includes("TF400813"))r="this account isn't a member of the organization, or the token is for another tenant";else if(e.status===404)r="404 also means 'no permission to see it' in Azure DevOps";else if(n==="WorkItemTrackingFieldDefinitionNotFoundException")r="use the field's reference name (e.g. Microsoft.VSTS.Common.Priority) or a System field name";else if(n==="GitPullRequestUpdateRejectedByPolicyException")r="a branch policy isn't passing yet (approvals, builds, linked work items): ppdo-cli ado pr checks <pr> shows which; get it passing, don't bypass it";else if(n==="TestPatchOperationFailedException")r="the work item changed after ppdo-cli read it; run the command again";else if(n==="VssInvalidPreviewVersionException")r="this endpoint is preview-only: pass --api-version <version>-preview";else if(t&&t.includes("VS403664")){let i=this.requestId(e);return new w(t,{service:this.name,status:e.status,...n?{code:n}:{},...i?{requestId:i}:{},hint:"only a comment's author can edit or delete it"})}return x(this.name,e,n,t,this.requestId(e),r)}};function O(o){let e=o.header("x-ms-continuationtoken");if(e){let t=u(o.url),r=g(t.query).filter(([i])=>i!=="continuationToken");return r.push(["continuationToken",e]),m({...t,query:h(r),fragment:""})}let n=o.isJson?o.json():null;return y(n)&&n["@odata.nextLink"]?String(n["@odata.nextLink"]):null}function T(o){let e=o.isJson?o.json():null;return y(e)&&Array.isArray(e.value)?e.value:Array.isArray(e)?e:e!=null?[e]:[]}export{A as a,C as b,S as c,O as d,T as e};
2
+ import{a as b,b as k}from"./chunk-MTF66YXU.js";import{b as j,c as x}from"./chunk-GY6BUIDP.js";import{a as l,b as p,c as h,d as g,e as u,f as m,g as f}from"./chunk-J4R6QXW7.js";import{b as v,h as w}from"./chunk-WXOTXJNG.js";var A="499b84ac-1321-427f-aa17-267ca6975798",C="7.1";function y(o){return typeof o=="object"&&o!==null&&!Array.isArray(o)}var S=class extends j{name="devops";org;project;hostKey;apiVersion;constructor(e,n="core",t){super(),this.org=e.org??"",this.project=e.project??null,this.hostKey=n,this.apiVersion=t||C}scope(){return A+"/.default"}base(){return`https://${this.hostKey==="core"?"dev.azure.com":`${this.hostKey}.dev.azure.com`}/${l(this.org)}/`}expand(e){if(e.includes("{project}")){if(!this.project)throw new v("the path uses {project} but the environment has no DevOps project",{hint:"ask the user to set one: ppdo-cli env update <name> --devops-project <project>"});e=e.split("{project}").join(l(this.project))}return e}url(e,n){e=this.expand(e);let t=e.includes("://")?e:this.base()+e.replace(/^\/+/,""),r=u(t),i=[...g(r.query),...n??[]],s=f(t).host||r.netloc.toLowerCase();return!(r.path.includes("/_odata/")||s==="analytics.dev.azure.com")&&!i.some(([d])=>d.toLowerCase()==="api-version")&&i.push(["api-version",this.apiVersion]),m({...r,query:h(i,"$'(),/:@*"),fragment:""})}allowed(e){let n=f(e);if(n.scheme!=="https"||!n.host)return!1;let t=this.org.toLowerCase();if(!t)return!1;if(new Set(["dev.azure.com",...b.filter(s=>s!=="core").map(s=>`${s}.dev.azure.com`)]).has(n.host)){let s=(n.path.replace(/^\/+/,"").split("/",1)[0]??"").toLowerCase();if(s!==t&&s!==l(t).toLowerCase())return!1;let c=u(e).path.replace(/^\/+/,"").split("/");for(let d of c){let a=p(d);if(a==="."||a===".."||a.includes("/")||a.includes("\\"))return!1}return p(c[0]??"").toLowerCase()===t}return new Set([`${t}.visualstudio.com`,...k.map(s=>`${t}.${s}.visualstudio.com`)]).has(n.host)}requestId(e){return e.header("activityid")||e.header("x-vss-e2eid")}authTrap(e){let n=e.header("content-type")??"";return e.status===203||e.status>=200&&e.status<300&&n.includes("text/html")&&e.body.subarray(0,2e3).toString("latin1").toLowerCase().includes("<html")?"Azure DevOps returned a sign-in page instead of data (the token was rejected)":null}error(e){let n=null,t=null,r=null;if(e.body.length)try{let i=e.json(),s=y(i)?i:{};t=typeof s.message=="string"?s.message:null,n=typeof s.typeKey=="string"&&s.typeKey||(s.errorCode?String(s.errorCode):null)||null}catch{t=e.text.trim().slice(0,300)||null}if(t&&t.includes("TF401444"))r="a service principal must be added to the organization first: Organization settings > Users > Add users, with an access level and project permissions";else if(e.status===401||t&&t.includes("TF400813"))r="this account isn't a member of the organization, or the token is for another tenant";else if(e.status===404)r="404 also means 'no permission to see it' in Azure DevOps";else if(n==="WorkItemTrackingFieldDefinitionNotFoundException")r="use the field's reference name (e.g. Microsoft.VSTS.Common.Priority) or a System field name";else if(n==="GitPullRequestUpdateRejectedByPolicyException")r="a branch policy isn't passing yet (approvals, builds, linked work items): ppdo-cli ado pr checks <pr> shows which; get it passing, don't bypass it";else if(n==="TestPatchOperationFailedException")r="the work item changed after ppdo-cli read it; run the command again";else if(n==="VssInvalidPreviewVersionException")r="this endpoint is preview-only: pass --api-version <version>-preview";else if(t&&t.includes("VS403664")){let i=this.requestId(e);return new w(t,{service:this.name,status:e.status,...n?{code:n}:{},...i?{requestId:i}:{},hint:"only a comment's author can edit or delete it"})}return x(this.name,e,n,t,this.requestId(e),r)}};function O(o){let e=o.header("x-ms-continuationtoken");if(e){let t=u(o.url),r=g(t.query).filter(([i])=>i!=="continuationToken");return r.push(["continuationToken",e]),m({...t,query:h(r),fragment:""})}let n=o.isJson?o.json():null;return y(n)&&n["@odata.nextLink"]?String(n["@odata.nextLink"]):null}function T(o){let e=o.isJson?o.json():null;return y(e)&&Array.isArray(e.value)?e.value:Array.isArray(e)?e:e!=null?[e]:[]}export{A as a,C as b,S as c,O as d,T as e};
@@ -0,0 +1,7 @@
1
+ import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
2
+ var C=class extends Error{},I=class{tag;attrib;text=null;tail=null;children=[];constructor(t,r){this.tag=t,this.attrib=r??new Map}get(t,r=null){return this.attrib.has(t)?this.attrib.get(t):r}set(t,r){this.attrib.set(t,r)}[Symbol.iterator](){return this.children[Symbol.iterator]()}find(t){return this.findall(t)[0]??null}findall(t){let r=[this];for(let i of t.split("/")){let w=[];for(let l of r)for(let c of l.children)(i==="*"||c.tag===i)&&w.push(c);r=w}return r}*iter(t){(t===void 0||this.tag===t)&&(yield this);for(let r of this.children)yield*r.iter(t)}},S={amp:"&",lt:"<",gt:">",quot:'"',apos:"'"};function W(f){return f===" "||f===" "||f===`
3
+ `||f==="\r"}function $(f){return f!==void 0&&(/[A-Za-z0-9_.:-]/.test(f)||f.charCodeAt(0)>=183)}function N(f){let t=f.replace(/\r\n?/g,`
4
+ `),r=t.length,i=(e,g)=>{let n=t.slice(0,Math.min(g,r)),d=n.split(`
5
+ `).length,o=g-(n.lastIndexOf(`
6
+ `)+1);throw new C(`${e}: line ${d}, column ${o}`)},w=(e,g,n)=>{let d="";for(let o=0;o<e.length;o++){let p=e[o];if(p==="&"){let m=e.indexOf(";",o+1);m<0&&i("not well-formed (invalid token)",g+o);let x=e.slice(o+1,m);if(x.startsWith("#")){let b=x[1]==="x"?parseInt(x.slice(2),16):parseInt(x.slice(1),10);Number.isFinite(b)||i("not well-formed (invalid token)",g+o),d+=String.fromCodePoint(b)}else x in S?d+=S[x]:i("undefined entity",g+o);o=m}else p==="<"&&n?i("not well-formed (invalid token)",g+o):n&&(p===" "||p===`
7
+ `)?d+=" ":d+=p}return d},l=[],c=[new Map],u=null,a=null,v=!1,M=e=>{e&&a!==null&&(v?a.tail=(a.tail??"")+e:a.text=(a.text??"")+e)},y=(e,g,n)=>{let d=e.indexOf(":");if(d>0){let p=g.get(e.slice(0,d));return p!==void 0?`{${p}}${e.slice(d+1)}`:e}if(n)return e;let o=g.get("");return o?`{${o}}${e}`:e},h=0;if(t.startsWith("<?xml")){let e=t.indexOf("?>");e<0&&i("unclosed token",0),h=e+2}for(;h<r;){let e=t.indexOf("<",h),g=e<0?r:e;if(g>h){let s=t.slice(h,g);l.length?M(w(s,h,!1)):s.trim()&&i(u?"junk after document element":"syntax error",h+s.search(/\S/))}if(e<0)break;if(!l.length&&u&&!t.startsWith("<!--",e)&&!t.startsWith("<?",e)&&i("junk after document element",e),t.startsWith("<!--",e)){let s=t.indexOf("-->",e+4);s<0&&i("unclosed token",e),h=s+3;continue}if(t.startsWith("<![CDATA[",e)){let s=t.indexOf("]]>",e+9);s<0&&i("unclosed CDATA section",e),l.length||i("syntax error",e),M(t.slice(e+9,s)),h=s+3;continue}if(t.startsWith("<?",e)){let s=t.indexOf("?>",e+2);s<0&&i("unclosed token",e),h=s+2;continue}if(t.startsWith("<!",e)&&i("not well-formed (invalid token)",e),t[e+1]==="/"){let s=e+2;for(;s<r&&$(t[s]);)s++;let k=t.slice(e+2,s);for(;s<r&&W(t[s]);)s++;s>=r&&i("unclosed token",e),t[s]!==">"&&i("not well-formed (invalid token)",s);let E=l[l.length-1];(!E||E.tag!==y(k,c[c.length-1],!1))&&i("mismatched tag",e+2),a=l.pop(),v=!0,c.pop(),h=s+1;continue}let n=e+1;for((!$(t[n])||/[0-9.\-]/.test(t[n]))&&i("not well-formed (invalid token)",n);n<r&&$(t[n]);)n++;let d=t.slice(e+1,n),o=[],p=!1;for(;;){let s=n;for(;n<r&&W(t[n]);)n++;if(n>=r&&i("unclosed token",e),t[n]===">"){n++;break}if(t[n]==="/"){t[n+1]!==">"&&i("not well-formed (invalid token)",n),p=!0,n+=2;break}(n===s||!$(t[n]))&&i("not well-formed (invalid token)",n);let k=n;for(;n<r&&$(t[n]);)n++;let E=t.slice(k,n);for(;n<r&&W(t[n]);)n++;for(t[n]!=="="&&i("not well-formed (invalid token)",n),n++;n<r&&W(t[n]);)n++;let A=t[n];A!=='"'&&A!=="'"&&i("not well-formed (invalid token)",n);let O=t.indexOf(A,n+1);O<0&&i("unclosed token",e),o.some(([D])=>D===E)&&i("duplicate attribute",k),o.push([E,w(t.slice(n+1,O),n+1,!0)]),n=O+1}let m=c[c.length-1];if(o.some(([s])=>s==="xmlns"||s.startsWith("xmlns:"))){m=new Map(m);for(let[s,k]of o)s==="xmlns"?m.set("",k):s.startsWith("xmlns:")&&m.set(s.slice(6),k)}let x=new Map;for(let[s,k]of o)s!=="xmlns"&&!s.startsWith("xmlns:")&&x.set(y(s,m,!0),k);let b=new I(y(d,m,!1),x);l.length?l[l.length-1].children.push(b):u===null?u=b:i("junk after document element",e),a=b,v=!1,p?v=!0:(l.push(b),c.push(m)),h=n}return(l.length||u===null)&&i("no element found",r),u}function j(f){return f.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function T(f){return f.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/\r/g,"&#13;").replace(/\n/g,"&#10;").replace(/\t/g,"&#09;")}function z(f){let t=new Map,r=l=>{if(!l.startsWith("{"))return l;let c=l.indexOf("}"),u=l.slice(1,c),a=t.get(u);return a===void 0&&(a=`ns${t.size}`,t.set(u,a)),`${a}:${l.slice(c+1)}`};for(let l of f.iter()){r(l.tag);for(let c of l.attrib.keys())r(c)}let i=[],w=(l,c)=>{if(i.push("<"+r(l.tag)),c)for(let[u,a]of[...t].sort((v,M)=>v[1]<M[1]?-1:1))i.push(` xmlns:${a}="${T(u)}"`);for(let[u,a]of l.attrib)i.push(` ${r(u)}="${T(a)}"`);if(l.text||l.children.length){i.push(">"),l.text&&i.push(j(l.text));for(let u of l.children)w(u,!1);i.push(`</${r(l.tag)}>`)}else i.push(" />");l.tail&&!c&&i.push(j(l.tail))};return w(f,!0),i.join("")}export{C as a,N as b,z as c};
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
2
- import{a as F,b as N,c as H,j as M}from"./chunk-I3TMFYRJ.js";import{a as K,b as _,e as O}from"./chunk-MBNUMAAZ.js";import{d as D}from"./chunk-LB7WNZVK.js";import{a as P,b as E,c as B}from"./chunk-WXOTXJNG.js";import{createHash as Z,createPrivateKey as ye}from"node:crypto";import{existsSync as ve,readFileSync as Q,statSync as xe}from"node:fs";import{createDecipheriv as ee,createHash as Y,createPrivateKey as X,pbkdf2Sync as te,X509Certificate as ne}from"node:crypto";var l=class extends Error{};function S(e,n){if(n+2>e.length)throw new l("truncated DER");let r=e[n];if((r&31)===31)throw new l("unsupported DER tag");let t=n+1,o=e[t++];if(o===128){let a=t;for(;;){if(t+2>e.length)throw new l("truncated BER");if(e[t]===0&&e[t+1]===0)return{tag:r,value:e.subarray(a,t),end:t+2};t=S(e,t).end}}let c=o;if(o&128){let a=o&127;if(a>4)throw new l("DER length too long");c=0;for(let f=0;f<a;f++)c=c*256+e[t++]}if(t+c>e.length)throw new l("truncated DER");return{tag:r,value:e.subarray(t,t+c),end:t+c}}function u(e){let n=[];for(let r=0;r<e.value.length;){let t=S(e.value,r);n.push(t),r=t.end}return n}function C(e){return S(e,0)}function d(e,n,r){let t=e[n];if(!t)throw new l(`missing ${r}`);return t}function y(e){if(e.tag===4)return e.value;if(e.tag===36)return Buffer.concat(u(e).map(y));throw new l("expected an OCTET STRING")}function b(e){if(e.tag!==160)throw new l("expected [0]");return d(u(e),0,"[0] content")}function x(e){if(e.tag!==6)throw new l("expected an OID");let n=e.value,r=[],t=0;for(let o=0;o<n.length;o++)t=t*128+(n[o]&127),n[o]&128||(r.length?r.push(t):r.push(t<80?Math.floor(t/40):2,t<80?t%40:t-80),t=0);return r.join(".")}function G(e){if(e.tag!==2)throw new l("expected an INTEGER");let n=0;for(let r of e.value)n=n*256+r;return n}var j="1.2.840.113549.1.7.1",re="1.2.840.113549.1.7.6",oe="1.2.840.113549.1.12.10.1.1",ce="1.2.840.113549.1.12.10.1.2",se="1.2.840.113549.1.12.10.1.3",ie="1.2.840.113549.1.9.22.1",ae="1.2.840.113549.1.9.21",fe="1.2.840.113549.1.5.13",le="1.2.840.113549.1.5.12",ue="1.2.840.113549.1.12.1.3",L="1.2.840.113549.1.12.1.4",pe="1.2.840.113549.1.12.1.5",de="1.2.840.113549.1.12.1.6",he={"1.2.840.113549.2.7":"sha1","1.2.840.113549.2.8":"sha224","1.2.840.113549.2.9":"sha256","1.2.840.113549.2.10":"sha384","1.2.840.113549.2.11":"sha512"},ge={"2.16.840.1.101.3.4.1.2":["aes-128-cbc",16],"2.16.840.1.101.3.4.1.22":["aes-192-cbc",24],"2.16.840.1.101.3.4.1.42":["aes-256-cbc",32],"1.2.840.113549.3.7":["des-ede3-cbc",24]};function W(e,n,r,t,o){let f=h=>{if(!h.length)return Buffer.alloc(0);let m=Buffer.alloc(64*Math.ceil(h.length/64));for(let p=0;p<m.length;p++)m[p]=h[p%h.length];return m},s=Buffer.alloc(64,r),i=Buffer.concat([f(n),f(e)]),g=[],w=0;for(;w<o;){let h=Y("sha1").update(s).update(i).digest();for(let p=1;p<t;p++)h=Y("sha1").update(h).digest();if(g.push(h),w+=20,w>=o)break;let m=Buffer.alloc(64);for(let p=0;p<64;p++)m[p]=h[p%20];for(let p=0;p<i.length;p+=64){let k=1;for(let v=63;v>=0;v--){let T=i[p+v]+m[v]+k;i[p+v]=T&255,k=T>>8}}}return Buffer.concat(g).subarray(0,o)}var we=[Buffer.from([0,0]),Buffer.alloc(0)];function J(e,n,r,t){let o=ee(e,n,r);return Buffer.concat([o.update(t),o.final()])}function q(e,n,r){let t=u(e),o=x(d(t,0,"algorithm")),c=t[1],a=[];if(o===fe&&c){let[s,i]=u(c);if(!s||!i)throw new l("bad PBES2 parameters");let g=u(s);if(x(d(g,0,"KDF"))!==le)throw new l("unsupported key derivation");let w=u(d(g,1,"PBKDF2 parameters")),h=y(d(w,0,"salt")),m=G(d(w,1,"iterations")),p="sha1";for(let A of w.slice(2))A.tag===48&&(p=he[x(d(u(A),0,"PRF"))]??"");if(!p)throw new l("unsupported PRF");let k=u(i),v=ge[x(d(k,0,"cipher"))];if(!v)throw new l("unsupported cipher");let T=y(d(k,1,"IV"));a.push(()=>J(v[0],te(Buffer.alloc(0),h,m,v[1],p),T,n))}else if((o===ue||o===L)&&c){let s=u(c),i=y(d(s,0,"salt")),g=G(d(s,1,"iterations"));for(let w of we)a.push(()=>{let h=W(w,i,1,g,24);return o===L&&(h=Buffer.concat([h.subarray(0,16),h.subarray(0,8)])),J("des-ede3-cbc",h,W(w,i,2,g,8),n)})}else throw o===de||o===pe?new l("it uses RC2 encryption, which Node cannot decrypt"):new l(`unsupported encryption ${o}`);let f;for(let s of a)try{let i=s();return r(i),i}catch(i){f=i}throw new l(`cannot decrypt it without a password (${f?.message??"no key"})`)}function I(e){let n=e[2];if(!n||n.tag!==49)return null;for(let r of u(n)){let[t,o]=u(r);if(t&&o&&x(t)===ae){let c=u(o)[0];if(c)return y(c).toString("hex")}}return null}function U(e,n){for(let r of u(C(e))){let t=u(r),o=x(d(t,0,"bag type")),c=b(d(t,1,"bag value"));if(o===oe)n.keys.push({der:me(c),id:I(t)});else if(o===ce){let[a,f]=u(c);if(!a||!f)throw new l("bad shrouded key bag");let s=q(a,y(f),i=>{X({key:i,format:"der",type:"pkcs8"})});n.keys.push({der:s,id:I(t)})}else if(o===se){let a=u(c);if(x(d(a,0,"certificate type"))!==ie)continue;n.certs.push({der:y(b(d(a,1,"certificate"))),id:I(t)})}}}function me(e){let n=e.value.length,r;if(n<128)r=[e.tag,n];else{let t=[];for(let o=n;o>0;o=Math.floor(o/256))t.unshift(o&255);r=[e.tag,128|t.length,...t]}return Buffer.concat([Buffer.from(r),e.value])}function V(e){let n=u(C(e)),r=u(d(n,1,"authSafe"));if(x(d(r,0,"content type"))!==j)throw new l("it is signed, not password-protected");let t={keys:[],certs:[]};for(let f of u(C(y(b(d(r,1,"content")))))){let s=u(f),i=x(d(s,0,"content type"));if(i===j)U(y(b(d(s,1,"content"))),t);else if(i===re){let g=u(b(d(s,1,"content"))),w=u(d(g,1,"encrypted content info")),h=d(w,1,"algorithm"),m=w[2];if(!m)continue;let p=m.tag===160?Buffer.concat(u(m).map(y)):m.value;U(q(h,p,k=>{u(C(k))}),t)}}let o=t.keys[0];if(!o)throw new l("it has no private key");if(!t.certs.length)throw new l("it has no certificate");let c=X({key:o.der,format:"der",type:"pkcs8"}),a=o.id&&t.certs.find(f=>f.id===o.id)||t.certs.find(f=>{try{return new ne(f.der).checkPrivateKey(c)}catch{return!1}})||t.certs[0];return{privateKey:c.export({type:"pkcs8",format:"pem"}).toString(),certificate:a.der}}var $=new Map,R=new Map,z={7000215:"the client secret is wrong: check {where}",7000222:"the client secret has expired: create a new one on the app registration and update {where}",700016:"no app with this client id in tenant '{tenant}': check --client-id and --tenant",90002:"tenant '{tenant}' was not found: check --tenant",700027:"the certificate is not registered on the app, or its key doesn't match"};function ke(e){return e.certificate?e.certificate:e.secretEnv||"the secret"}function Ee(e){let n=e.replace(/\$(\w+)|\$\{([^}]*)\}/g,(r,t,o)=>process.env[t??o]??r);if(process.platform==="win32"&&(n=n.replace(/%([^%]+)%/g,(r,t)=>process.env[t]??r)),n==="~"||n.startsWith("~/")||n.startsWith("~\\")){let r=process.env.USERPROFILE||process.env.HOME||"";r&&(n=r+n.slice(1))}return n}var Be=/-----BEGIN ([A-Z ]+)-----[\s\S]+?-----END \1-----/g;function be(e){e=Ee(e);let n=e.toLowerCase();if(n.endsWith(".pfx")||n.endsWith(".p12")){if(!ve(e)||!xe(e).isFile())throw new E(`cannot read certificate ${e}: no such file`);let s;try{s=V(Q(e))}catch(i){let g=i instanceof Error?i.message:String(i);throw new E(`cannot read certificate ${e}: ${g}`,{hint:i instanceof l?"export it again without a password, or convert it to PEM: openssl pkcs12 -in <pfx> -nodes -out <pem>":void 0})}return{privateKey:s.privateKey,thumbprint:Z("sha1").update(s.certificate).digest("hex")}}let r;try{let s=Q(e);if(s.some(i=>i>127))throw new Error("'ascii' codec can't decode the file");r=s.toString("ascii")}catch(s){let i=s,g=i.code==="ENOENT"?`[Errno 2] No such file or directory: '${e}'`:i.message;throw new E(`cannot read certificate ${e}: ${g}`)}let t=new Map;for(let s of r.matchAll(Be))t.set(s[1],s[0]);let o=t.get("CERTIFICATE"),c=[...t].find(([s])=>s.endsWith("PRIVATE KEY")&&!s.includes("ENCRYPTED"))?.[1];if(!o||!c){let s=c?"the certificate":"an unencrypted private key";throw new E(`${e} has no ${s}`,{hint:"the PEM file needs both the private key and the certificate"})}let a=Buffer.from(o.replace(/-----[A-Z ]+-----/g,"").replace(/\s+/g,""),"base64"),f;try{f=ye(c).export({type:"pkcs8",format:"pem"}).toString()}catch(s){throw new E(`cannot read certificate ${e}: ${s.message}`)}return{privateKey:f,thumbprint:Z("sha1").update(a).digest("hex")}}async function Te(e){let n=JSON.stringify([e.clientId,e.tenant,e.certificate]),r=e.ephemeral?R.get(n):void 0;if(r!==void 0)return r;let t;if(e.certificate)t=be(e.certificate);else{let o=process.env[e.secretEnv||""]||"";if(!o&&e.ephemeral&&process.stdin.isTTY&&process.stderr.isTTY&&(o=await D(`Client secret for app ${e.clientId}: `)),!o)throw new B(`no client secret for app ${e.clientId}`,{hint:`set ${e.secretEnv}, or pass --certificate <pem|pfx>`});t=o}return e.ephemeral&&R.set(n,t),t}function Ce(e,n){if(e instanceof P)throw e;let r=e instanceof F?e:N();if(r)throw new P(`cannot reach login.microsoftonline.com: ${r.message}`,{hint:"check the network and proxy (HTTPS_PROXY)"});let t=M(e);if(!t)throw e;if(!(e.name==="ServerError"||t.codes.length>0)){let f=(t.description.split(/\r?\n/)[0]??"").split(". ")[0];throw new B(`cannot sign in as app ${n.clientId}: ${f}`,{hint:"check --tenant, and --certificate if given"})}let c=t.codes.find(f=>f in z),a=(c!==void 0?z[c]:"check --client-id, --tenant and the secret or certificate").replace("{where}",ke(n)).replace("{tenant}",n.tenant);throw new B(`sign-in as app ${n.clientId} failed: ${t.description}`,{code:t.error,hint:a})}async function Pe(e,n){let r=await Te(e),t=await import("./dist-ILNYGTM2.js"),o;try{o=await new t.ConfidentialClientApplication({auth:{clientId:e.clientId??"",authority:`https://login.microsoftonline.com/${e.tenant}`,...typeof r=="string"?{clientSecret:r}:{clientCertificate:r}},system:{networkClient:new H}}).acquireTokenByClientCredential({scopes:[n]})}catch(a){Ce(a,e)}if(!o?.accessToken)throw new B(`sign-in as app ${e.clientId} failed: no token returned`,{hint:"check --client-id, --tenant and the secret or certificate"});let c=o.expiresOn?o.expiresOn.getTime()/1e3:Date.now()/1e3;return[o.accessToken,c]}async function He(e,n,r,t){let o=JSON.stringify([e.clientId,e.tenant,n]),c=$.get(o);if(c&&!r&&c[1]-Date.now()/1e3>120)return t(` token: process (${e.name})`),c[0];t(` token: client credentials (${e.name}${r?", forced":""})`);let[a,f]=await Pe(e,n);return Ie(e,_(a)),$.set(o,[a,f]),a}function Ie(e,n){O(e.name,null,K(e.tenant)?e.tenant:null,n);let r=n?.appid||n?.azp;if(typeof r=="string"&&r&&r.toLowerCase()!==(e.clientId??"").toLowerCase())throw new B(`the token is for app ${r}, expected ${e.clientId}`)}function Me(){$.clear(),R.clear()}export{Ee as a,be as b,Te as c,Pe as d,He as e,Ie as f,Me as g};
2
+ import{a as F,b as N,c as H,j as M}from"./chunk-XUHLW6B2.js";import{a as K,b as _,e as O}from"./chunk-MBNUMAAZ.js";import{d as D}from"./chunk-LB7WNZVK.js";import{a as P,b as E,c as B}from"./chunk-WXOTXJNG.js";import{createHash as Z,createPrivateKey as ye}from"node:crypto";import{existsSync as ve,readFileSync as Q,statSync as xe}from"node:fs";import{createDecipheriv as ee,createHash as Y,createPrivateKey as X,pbkdf2Sync as te,X509Certificate as ne}from"node:crypto";var l=class extends Error{};function S(e,n){if(n+2>e.length)throw new l("truncated DER");let r=e[n];if((r&31)===31)throw new l("unsupported DER tag");let t=n+1,o=e[t++];if(o===128){let a=t;for(;;){if(t+2>e.length)throw new l("truncated BER");if(e[t]===0&&e[t+1]===0)return{tag:r,value:e.subarray(a,t),end:t+2};t=S(e,t).end}}let c=o;if(o&128){let a=o&127;if(a>4)throw new l("DER length too long");c=0;for(let f=0;f<a;f++)c=c*256+e[t++]}if(t+c>e.length)throw new l("truncated DER");return{tag:r,value:e.subarray(t,t+c),end:t+c}}function u(e){let n=[];for(let r=0;r<e.value.length;){let t=S(e.value,r);n.push(t),r=t.end}return n}function C(e){return S(e,0)}function d(e,n,r){let t=e[n];if(!t)throw new l(`missing ${r}`);return t}function y(e){if(e.tag===4)return e.value;if(e.tag===36)return Buffer.concat(u(e).map(y));throw new l("expected an OCTET STRING")}function b(e){if(e.tag!==160)throw new l("expected [0]");return d(u(e),0,"[0] content")}function x(e){if(e.tag!==6)throw new l("expected an OID");let n=e.value,r=[],t=0;for(let o=0;o<n.length;o++)t=t*128+(n[o]&127),n[o]&128||(r.length?r.push(t):r.push(t<80?Math.floor(t/40):2,t<80?t%40:t-80),t=0);return r.join(".")}function G(e){if(e.tag!==2)throw new l("expected an INTEGER");let n=0;for(let r of e.value)n=n*256+r;return n}var j="1.2.840.113549.1.7.1",re="1.2.840.113549.1.7.6",oe="1.2.840.113549.1.12.10.1.1",ce="1.2.840.113549.1.12.10.1.2",se="1.2.840.113549.1.12.10.1.3",ie="1.2.840.113549.1.9.22.1",ae="1.2.840.113549.1.9.21",fe="1.2.840.113549.1.5.13",le="1.2.840.113549.1.5.12",ue="1.2.840.113549.1.12.1.3",L="1.2.840.113549.1.12.1.4",pe="1.2.840.113549.1.12.1.5",de="1.2.840.113549.1.12.1.6",he={"1.2.840.113549.2.7":"sha1","1.2.840.113549.2.8":"sha224","1.2.840.113549.2.9":"sha256","1.2.840.113549.2.10":"sha384","1.2.840.113549.2.11":"sha512"},ge={"2.16.840.1.101.3.4.1.2":["aes-128-cbc",16],"2.16.840.1.101.3.4.1.22":["aes-192-cbc",24],"2.16.840.1.101.3.4.1.42":["aes-256-cbc",32],"1.2.840.113549.3.7":["des-ede3-cbc",24]};function W(e,n,r,t,o){let f=h=>{if(!h.length)return Buffer.alloc(0);let m=Buffer.alloc(64*Math.ceil(h.length/64));for(let p=0;p<m.length;p++)m[p]=h[p%h.length];return m},s=Buffer.alloc(64,r),i=Buffer.concat([f(n),f(e)]),g=[],w=0;for(;w<o;){let h=Y("sha1").update(s).update(i).digest();for(let p=1;p<t;p++)h=Y("sha1").update(h).digest();if(g.push(h),w+=20,w>=o)break;let m=Buffer.alloc(64);for(let p=0;p<64;p++)m[p]=h[p%20];for(let p=0;p<i.length;p+=64){let k=1;for(let v=63;v>=0;v--){let T=i[p+v]+m[v]+k;i[p+v]=T&255,k=T>>8}}}return Buffer.concat(g).subarray(0,o)}var we=[Buffer.from([0,0]),Buffer.alloc(0)];function J(e,n,r,t){let o=ee(e,n,r);return Buffer.concat([o.update(t),o.final()])}function q(e,n,r){let t=u(e),o=x(d(t,0,"algorithm")),c=t[1],a=[];if(o===fe&&c){let[s,i]=u(c);if(!s||!i)throw new l("bad PBES2 parameters");let g=u(s);if(x(d(g,0,"KDF"))!==le)throw new l("unsupported key derivation");let w=u(d(g,1,"PBKDF2 parameters")),h=y(d(w,0,"salt")),m=G(d(w,1,"iterations")),p="sha1";for(let A of w.slice(2))A.tag===48&&(p=he[x(d(u(A),0,"PRF"))]??"");if(!p)throw new l("unsupported PRF");let k=u(i),v=ge[x(d(k,0,"cipher"))];if(!v)throw new l("unsupported cipher");let T=y(d(k,1,"IV"));a.push(()=>J(v[0],te(Buffer.alloc(0),h,m,v[1],p),T,n))}else if((o===ue||o===L)&&c){let s=u(c),i=y(d(s,0,"salt")),g=G(d(s,1,"iterations"));for(let w of we)a.push(()=>{let h=W(w,i,1,g,24);return o===L&&(h=Buffer.concat([h.subarray(0,16),h.subarray(0,8)])),J("des-ede3-cbc",h,W(w,i,2,g,8),n)})}else throw o===de||o===pe?new l("it uses RC2 encryption, which Node cannot decrypt"):new l(`unsupported encryption ${o}`);let f;for(let s of a)try{let i=s();return r(i),i}catch(i){f=i}throw new l(`cannot decrypt it without a password (${f?.message??"no key"})`)}function I(e){let n=e[2];if(!n||n.tag!==49)return null;for(let r of u(n)){let[t,o]=u(r);if(t&&o&&x(t)===ae){let c=u(o)[0];if(c)return y(c).toString("hex")}}return null}function U(e,n){for(let r of u(C(e))){let t=u(r),o=x(d(t,0,"bag type")),c=b(d(t,1,"bag value"));if(o===oe)n.keys.push({der:me(c),id:I(t)});else if(o===ce){let[a,f]=u(c);if(!a||!f)throw new l("bad shrouded key bag");let s=q(a,y(f),i=>{X({key:i,format:"der",type:"pkcs8"})});n.keys.push({der:s,id:I(t)})}else if(o===se){let a=u(c);if(x(d(a,0,"certificate type"))!==ie)continue;n.certs.push({der:y(b(d(a,1,"certificate"))),id:I(t)})}}}function me(e){let n=e.value.length,r;if(n<128)r=[e.tag,n];else{let t=[];for(let o=n;o>0;o=Math.floor(o/256))t.unshift(o&255);r=[e.tag,128|t.length,...t]}return Buffer.concat([Buffer.from(r),e.value])}function V(e){let n=u(C(e)),r=u(d(n,1,"authSafe"));if(x(d(r,0,"content type"))!==j)throw new l("it is signed, not password-protected");let t={keys:[],certs:[]};for(let f of u(C(y(b(d(r,1,"content")))))){let s=u(f),i=x(d(s,0,"content type"));if(i===j)U(y(b(d(s,1,"content"))),t);else if(i===re){let g=u(b(d(s,1,"content"))),w=u(d(g,1,"encrypted content info")),h=d(w,1,"algorithm"),m=w[2];if(!m)continue;let p=m.tag===160?Buffer.concat(u(m).map(y)):m.value;U(q(h,p,k=>{u(C(k))}),t)}}let o=t.keys[0];if(!o)throw new l("it has no private key");if(!t.certs.length)throw new l("it has no certificate");let c=X({key:o.der,format:"der",type:"pkcs8"}),a=o.id&&t.certs.find(f=>f.id===o.id)||t.certs.find(f=>{try{return new ne(f.der).checkPrivateKey(c)}catch{return!1}})||t.certs[0];return{privateKey:c.export({type:"pkcs8",format:"pem"}).toString(),certificate:a.der}}var $=new Map,R=new Map,z={7000215:"the client secret is wrong: check {where}",7000222:"the client secret has expired: create a new one on the app registration and update {where}",700016:"no app with this client id in tenant '{tenant}': check --client-id and --tenant",90002:"tenant '{tenant}' was not found: check --tenant",700027:"the certificate is not registered on the app, or its key doesn't match"};function ke(e){return e.certificate?e.certificate:e.secretEnv||"the secret"}function Ee(e){let n=e.replace(/\$(\w+)|\$\{([^}]*)\}/g,(r,t,o)=>process.env[t??o]??r);if(process.platform==="win32"&&(n=n.replace(/%([^%]+)%/g,(r,t)=>process.env[t]??r)),n==="~"||n.startsWith("~/")||n.startsWith("~\\")){let r=process.env.USERPROFILE||process.env.HOME||"";r&&(n=r+n.slice(1))}return n}var Be=/-----BEGIN ([A-Z ]+)-----[\s\S]+?-----END \1-----/g;function be(e){e=Ee(e);let n=e.toLowerCase();if(n.endsWith(".pfx")||n.endsWith(".p12")){if(!ve(e)||!xe(e).isFile())throw new E(`cannot read certificate ${e}: no such file`);let s;try{s=V(Q(e))}catch(i){let g=i instanceof Error?i.message:String(i);throw new E(`cannot read certificate ${e}: ${g}`,{hint:i instanceof l?"export it again without a password, or convert it to PEM: openssl pkcs12 -in <pfx> -nodes -out <pem>":void 0})}return{privateKey:s.privateKey,thumbprint:Z("sha1").update(s.certificate).digest("hex")}}let r;try{let s=Q(e);if(s.some(i=>i>127))throw new Error("'ascii' codec can't decode the file");r=s.toString("ascii")}catch(s){let i=s,g=i.code==="ENOENT"?`[Errno 2] No such file or directory: '${e}'`:i.message;throw new E(`cannot read certificate ${e}: ${g}`)}let t=new Map;for(let s of r.matchAll(Be))t.set(s[1],s[0]);let o=t.get("CERTIFICATE"),c=[...t].find(([s])=>s.endsWith("PRIVATE KEY")&&!s.includes("ENCRYPTED"))?.[1];if(!o||!c){let s=c?"the certificate":"an unencrypted private key";throw new E(`${e} has no ${s}`,{hint:"the PEM file needs both the private key and the certificate"})}let a=Buffer.from(o.replace(/-----[A-Z ]+-----/g,"").replace(/\s+/g,""),"base64"),f;try{f=ye(c).export({type:"pkcs8",format:"pem"}).toString()}catch(s){throw new E(`cannot read certificate ${e}: ${s.message}`)}return{privateKey:f,thumbprint:Z("sha1").update(a).digest("hex")}}async function Te(e){let n=JSON.stringify([e.clientId,e.tenant,e.certificate]),r=e.ephemeral?R.get(n):void 0;if(r!==void 0)return r;let t;if(e.certificate)t=be(e.certificate);else{let o=process.env[e.secretEnv||""]||"";if(!o&&e.ephemeral&&process.stdin.isTTY&&process.stderr.isTTY&&(o=await D(`Client secret for app ${e.clientId}: `)),!o)throw new B(`no client secret for app ${e.clientId}`,{hint:`set ${e.secretEnv}, or pass --certificate <pem|pfx>`});t=o}return e.ephemeral&&R.set(n,t),t}function Ce(e,n){if(e instanceof P)throw e;let r=e instanceof F?e:N();if(r)throw new P(`cannot reach login.microsoftonline.com: ${r.message}`,{hint:"check the network and proxy (HTTPS_PROXY)"});let t=M(e);if(!t)throw e;if(!(e.name==="ServerError"||t.codes.length>0)){let f=(t.description.split(/\r?\n/)[0]??"").split(". ")[0];throw new B(`cannot sign in as app ${n.clientId}: ${f}`,{hint:"check --tenant, and --certificate if given"})}let c=t.codes.find(f=>f in z),a=(c!==void 0?z[c]:"check --client-id, --tenant and the secret or certificate").replace("{where}",ke(n)).replace("{tenant}",n.tenant);throw new B(`sign-in as app ${n.clientId} failed: ${t.description}`,{code:t.error,hint:a})}async function Pe(e,n){let r=await Te(e),t=await import("./dist-ILNYGTM2.js"),o;try{o=await new t.ConfidentialClientApplication({auth:{clientId:e.clientId??"",authority:`https://login.microsoftonline.com/${e.tenant}`,...typeof r=="string"?{clientSecret:r}:{clientCertificate:r}},system:{networkClient:new H}}).acquireTokenByClientCredential({scopes:[n]})}catch(a){Ce(a,e)}if(!o?.accessToken)throw new B(`sign-in as app ${e.clientId} failed: no token returned`,{hint:"check --client-id, --tenant and the secret or certificate"});let c=o.expiresOn?o.expiresOn.getTime()/1e3:Date.now()/1e3;return[o.accessToken,c]}async function He(e,n,r,t){let o=JSON.stringify([e.clientId,e.tenant,n]),c=$.get(o);if(c&&!r&&c[1]-Date.now()/1e3>120)return t(` token: process (${e.name})`),c[0];t(` token: client credentials (${e.name}${r?", forced":""})`);let[a,f]=await Pe(e,n);return Ie(e,_(a)),$.set(o,[a,f]),a}function Ie(e,n){O(e.name,null,K(e.tenant)?e.tenant:null,n);let r=n?.appid||n?.azp;if(typeof r=="string"&&r&&r.toLowerCase()!==(e.clientId??"").toLowerCase())throw new B(`the token is for app ${r}, expected ${e.clientId}`)}function Me(){$.clear(),R.clear()}export{Ee as a,be as b,Te as c,Pe as d,He as e,Ie as f,Me as g};
@@ -0,0 +1,2 @@
1
+ import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
2
+ import{a as j}from"./chunk-UCTMKA2J.js";import{b as $,d as C,f as P}from"./chunk-FOEBNCSD.js";import{b as A,e as x,i as S,y as B}from"./chunk-BALEFXOL.js";import{b as T,c as O}from"./chunk-2IUXH534.js";import{e as R}from"./chunk-S4KF5Z3S.js";import{b as m,g as k}from"./chunk-WXOTXJNG.js";var h=100,L=5e3,nn="OData.Community.Display.V1.FormattedValue",en="@OData.Community.Display.V1.FormattedValue";function w(n){return n==null||n===!1||n===0||n===""||Number.isNaN(n)?!1:Array.isArray(n)?n.length>0:n instanceof Map||n instanceof Set?n.size>0:typeof n=="object"?Object.keys(n).length>0:!0}function tn(n,e){return w(n)?n:e}function K(n,e){if(typeof n!="object"||n===null||Array.isArray(n))return null;let t=n[e];return t===void 0?null:t}function M(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)&&w(n)?n:{}}function E(n){return Array.isArray(n)?n:[]}function rn(n){let e={};for(let[t,r]of Object.entries(n))r!=null&&(e[t]=r);return e}function on(n){let e={};for(let[t,r]of Object.entries(n))r!=null&&r!==""&&(e[t]=r);return e}function I(n,e){if(Array.isArray(n)&&Array.isArray(e)){for(let s=0;s<Math.min(n.length,e.length);s++){let o=I(n[s],e[s]);if(o)return o}return n.length-e.length}if(typeof n=="string"&&typeof e=="string"){let s=[...n],o=[...e];for(let i=0;i<Math.min(s.length,o.length);i++){let u=s[i].codePointAt(0)-o[i].codePointAt(0);if(u)return u}return s.length-o.length}let t=Number(n),r=Number(e);return t<r?-1:t>r?1:0}function U(n,e,t=!1){let r=[...n];return r.sort((s,o)=>(t?-1:1)*I(e(s),e(o))),r}function sn(n){return[...new Set(n)]}function un(n){return n.addOption(new x("--limit <n>",`return at most n rows (default ${h})`).argParser(S)).option("--all","return every row (no cap)")}function ln(n){if(n.all)return null;let e=n.limit;return typeof e=="number"&&e>0?e:h}var N={sync:"CustomSync",async:"CustomAsync",all:"CustomSync,CustomAsync"};function z(n,e,t){let r=new x(n,e);return r.argParser(D(t)),r}function D(n){return e=>{if(!n.includes(e))throw new A(`invalid choice: '${e}' (choose from ${n.join(", ")})`);return e}}function an(n){return n.addOption(z("--bypass-plugins <sync|async|all>","skip custom synchronous and/or asynchronous logic (plugins, classic workflows; not cloud flows); needs a full-mode group",Object.keys(N))).option("--bypass-step <step-id>[,...]","skip only these plugin steps")}function cn(n,e=!1,t="request body: @file.json, - for stdin, or inline JSON"){return e?n.requiredOption("--body <@file|-|json>",t):n.option("--body <@file|-|json>",t)}function fn(n,e,t=!1,r=null){let s=r?{hint:`run: ppdo-cli ${r} --help`}:{},o=Object.keys(e).filter(i=>n[i]!==void 0&&n[i]!==!1&&n[i]!==null);if(o.length>1)throw new m(`argument ${e[o[1]]}: not allowed with argument ${e[o[0]]}`,s);if(t&&!o.length)throw new m(`one of the arguments ${Object.values(e).join(" ")} is required`,s)}function dn(n){return n.client("dataverse")}function pn(n,e,t,r,s={}){return T(n,e,t,r,s.body??null,s.cls??null),e.request(t,r,{params:s.params??null,headers:s.headers??null,body:s.body??null,saveTo:s.saveTo??null,check:s.check??!0})}function F(n){return M(n.json())}function yn(n){return Buffer.from(JSON.stringify(n),"utf8")}function gn(...n){let e=n.filter(t=>!!t);return e.length?{Prefer:e.join(", ")}:{}}async function*G(n,e,t=null,r=null){let{nextLink:s}=await import("./service-HASXLUGE.js"),o=await n.request("GET",e,{params:t,headers:r});for(;;){yield o;let i=s(o);if(!i)return;o=await n.request("GET",i,{headers:r})}}async function q(n,e,t,r=null,s=null,o=h,i="rows"){let u=[],c={},l=!1,f=o?Math.min(L,o+1):L,y={...s??{}},g=y.Prefer;(g??"").includes("maxpagesize")||(y.Prefer=[g,`odata.maxpagesize=${f}`].filter(a=>a).join(", "));for await(let a of G(e,t,r,y)){let d=F(a);if(!w(c)){c={};for(let[p,b]of Object.entries(d))p!=="value"&&(c[p]=b)}for(let p of E(d.value)){if(o!==null&&u.length>=o){l=!0;break}u.push(p)}if(l)break;if(o!==null&&u.length>=o){l="@odata.nextLink"in d;break}}return l&&R(`showing the first ${o} ${i}; pass --limit n or --all for more`),[u,c]}async function mn(n,e,t,r,s,o,i=null,u=h,c="rows",l=null){if(s===null)return(await q(n,e,t,o,i,u,c))[0];let f=[],y=o.find(([a])=>a==="$filter")?.[1]??null,g=o.filter(([a])=>a!=="$filter"&&a!=="$orderby");for(let a=0;a<s.length;a+=50){let d="("+s.slice(a,a+50).map(p=>`${r} eq ${p}`).join(" or ")+")";y&&(d+=` and (${y})`),f=f.concat((await q(n,e,t,[...g,["$filter",d]],i,null,c))[0])}return l&&(f=U(f,l)),u!==null&&f.length>u&&(R(`showing the first ${u} ${c}; pass --limit n or --all for more`),f=f.slice(0,u)),f}function wn(n){let e=n.header("odata-entityid")||"",t=/\(([0-9a-fA-F-]{36})\)\s*$/.exec(e);return t?t[1]:null}function hn(n){if(typeof n=="object"&&n!==null&&!Array.isArray(n)){let e=M(n.UserLocalizedLabel);if(w(e.Label))return e.Label;for(let t of E(n.LocalizedLabels))if(w(K(t,"Label")))return t.Label}return null}function bn(n,e){let t=n.args,r={},s=t.bypassPlugins;typeof s=="string"&&s&&(r["MSCRM.BypassBusinessLogicExecution"]=N[s]);let o=t.bypassStep;if(typeof o=="string"&&o){let u=o.split(",").map(l=>P(l)).filter(l=>l),c=u.filter(l=>!$(l));if(c.length)throw new m(`--bypass-step takes plugin step ids, got '${c[0]}'`);r["MSCRM.BypassBusinessLogicExecutionStepIds"]=u.map(l=>C(l)).join(",")}let i=e.target;if(Object.keys(r).length&&i.mode!=="full")throw new k(`blocked: skipping plugins needs mode 'full'; mode is '${i.mode}'`,{service:"dataverse",hint:O(i)});return r}async function xn(n,e=!1){if(n==null){if(e)throw new m("--body is required");return null}let t=B(String(n));try{j(V(t.toString("utf8")))}catch(r){throw new m(`--body is not valid JSON: ${r.message}`,{hint:"pass a file with --body @file.json"})}return t}var J="\uFEFF";function V(n){return n.startsWith(J)?n.slice(1):n}function Rn(n){return typeof n=="string"?n:null}var H=1e3;async function*Tn(n,e,t,r,s){let o=await import("./batch-LKWCBKAB.js"),i=e.service.origin;for(let u=0;u<t.length;u+=H){let c=t.slice(u,u+H),[l,f,y]=o.build(c,i,r),g=Buffer.from(f,"utf8");T(n,e,"POST","$batch",g);let a={"Content-Type":`multipart/mixed; boundary=${l}`};s&&(a.Prefer="odata.continue-on-error");let d=await e.request("POST","$batch",{headers:a,body:g,check:!1});if(d.status>=400&&!(d.header("content-type")||"").includes("multipart"))throw e.service.error(d);let p=/boundary=([^\s;]+)/.exec(d.header("content-type")||""),b=p?o.parse(d.text,p[1]):[];yield[u,c,o.distribute(y,b,c.length)]}}export{L as a,nn as b,en as c,w as d,tn as e,K as f,M as g,E as h,rn as i,on as j,U as k,sn as l,un as m,ln as n,z as o,D as p,an as q,cn as r,fn as s,dn as t,pn as u,F as v,yn as w,gn as x,G as y,q as z,mn as A,wn as B,hn as C,bn as D,xn as E,V as F,Rn as G,Tn as H};