@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
@@ -142,6 +142,10 @@ ppdo-cli dv solution pack <folder> --save <file.zip> [--package-type unmanaged|m
142
142
  - `--map <map.xml>` is a SolutionPackager mapping file (`<Mapping>` with `FileToFile`, `FileToPath` and `Folder` elements; `map` is the path in the folder, `to` where the file is, both relative to the folder; `%NAME%` takes an environment variable). `pack` reads a mapped file from where it points and adds files mapped into other folders; `unpack`, `clone` and `sync` don't write mapped files and never delete them as stale. A `.cdsproj`'s `SolutionPackageMapFilePath` is the default.
143
143
  - `pack --remap-plugins`: when a plug-in `.dll`'s version or key differs from its record, the assembly, its root component, plug-in types, steps and workflow activity references take the `.dll`'s full name. pac does this only with `--disablePluginRemap` (the switch is wired backwards), so it is off by default.
144
144
 
145
+ ## Configuration data: `dv data`
146
+
147
+ To keep configuration data (reference data) in source control as YAML and move it between environments (`dv data export`, `import`, `convert`, `prune`, `init`), or to work with a CMT `data.xml` or a `reference-data` folder, load the ppdo-cli-data skill.
148
+
145
149
  ## Publishers: `dv publisher`
146
150
 
147
151
  ```
@@ -203,6 +207,8 @@ ppdo-cli dv workflow runs <flow> [--state succeeded|failed|cancelled] [--since <
203
207
 
204
208
  ## Plug-ins: `dv plugin`
205
209
 
210
+ To register plugins from attributes (`dv plugin inspect`, `register`, `migrate`), load the ppdo-cli-plugins skill.
211
+
206
212
  ```
207
213
  ppdo-cli dv plugin trace list [--type <pattern>] [--message <name>] [--table <table>] [--correlation <id>] [--state failed] [--since <when>] [--limit n] [--all]
208
214
  ppdo-cli dv plugin trace get <id>
@@ -0,0 +1,229 @@
1
+ // Plugin registration attributes for ppdo-cli (dv plugin inspect | register).
2
+ //
3
+ // Copy this file into the plugin project. You can change the namespace.
4
+ // Do not change the name of a class, a property, a constructor parameter or an
5
+ // enum value, and do not change a number: ppdo-cli reads these attributes from
6
+ // the built DLL and stops if they are not the ones it knows.
7
+ //
8
+ // The attributes are internal: the plugin gets no dependency at run time.
9
+
10
+ using System;
11
+
12
+ namespace PluginRegistration
13
+ {
14
+ /// <summary>The version of this file. ppdo-cli accepts the versions it knows.</summary>
15
+ internal static class PluginRegistrationInfo
16
+ {
17
+ public const int Version = 1;
18
+ }
19
+
20
+ /// <summary>Names of common SDK messages. A step can also give any other message name as a string.</summary>
21
+ internal static class Messages
22
+ {
23
+ public const string Assign = "Assign";
24
+ public const string Associate = "Associate";
25
+ public const string Create = "Create";
26
+ public const string Delete = "Delete";
27
+ public const string Disassociate = "Disassociate";
28
+ public const string GrantAccess = "GrantAccess";
29
+ public const string Merge = "Merge";
30
+ public const string ModifyAccess = "ModifyAccess";
31
+ public const string Retrieve = "Retrieve";
32
+ public const string RetrieveMultiple = "RetrieveMultiple";
33
+ public const string RevokeAccess = "RevokeAccess";
34
+ public const string SetState = "SetState";
35
+ public const string SetStateDynamicEntity = "SetStateDynamicEntity";
36
+ public const string Update = "Update";
37
+ public const string Upsert = "Upsert";
38
+ }
39
+
40
+ /// <summary>The stage of a step. The numbers are the Dataverse values.</summary>
41
+ internal enum Stage
42
+ {
43
+ PreValidation = 10,
44
+ PreOperation = 20,
45
+ PostOperation = 40,
46
+ }
47
+
48
+ /// <summary>The execution mode of a step. The numbers are the Dataverse values.</summary>
49
+ internal enum Mode
50
+ {
51
+ Synchronous = 0,
52
+ Asynchronous = 1,
53
+ }
54
+
55
+ /// <summary>The binding of a Custom API.</summary>
56
+ internal enum Binding
57
+ {
58
+ Global = 0,
59
+ Table = 1,
60
+ TableCollection = 2,
61
+ }
62
+
63
+ /// <summary>The steps that other plugins can register on a Custom API message.</summary>
64
+ internal enum StepsAllowed
65
+ {
66
+ None = 0,
67
+ AsyncOnly = 1,
68
+ SyncAndAsync = 2,
69
+ }
70
+
71
+ /// <summary>The type of a Custom API request parameter or response property.</summary>
72
+ internal enum ApiType
73
+ {
74
+ Boolean = 0,
75
+ DateTime = 1,
76
+ Decimal = 2,
77
+ Entity = 3,
78
+ EntityCollection = 4,
79
+ EntityReference = 5,
80
+ Float = 6,
81
+ Integer = 7,
82
+ Money = 8,
83
+ Picklist = 9,
84
+ String = 10,
85
+ StringArray = 11,
86
+ Guid = 12,
87
+ }
88
+
89
+ /// <summary>
90
+ /// One plugin step. Give each new step an Id: a new GUID that you make for that step.
91
+ /// A property that you do not set gets the default that ppdo-cli gives.
92
+ /// </summary>
93
+ [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
94
+ internal sealed class PluginStepAttribute : Attribute
95
+ {
96
+ /// <summary>A step on a message with no table (a global message).</summary>
97
+ public PluginStepAttribute(string message)
98
+ {
99
+ Message = message;
100
+ }
101
+
102
+ /// <summary>A step on a message of one table.</summary>
103
+ public PluginStepAttribute(string message, string table)
104
+ {
105
+ Message = message;
106
+ Table = table;
107
+ }
108
+
109
+ public string Message { get; private set; }
110
+ public string Table { get; private set; }
111
+
112
+ /// <summary>Default: PostOperation.</summary>
113
+ public Stage Stage { get; set; }
114
+ /// <summary>Default: Synchronous.</summary>
115
+ public Mode Mode { get; set; }
116
+ /// <summary>The execution order (rank). Default: 1.</summary>
117
+ public int Order { get; set; }
118
+ /// <summary>The columns that start the step (Update and some other messages). Default: all columns.</summary>
119
+ public string[] Columns { get; set; }
120
+ /// <summary>The columns of the pre-image. "*" is all columns. Default: no pre-image.</summary>
121
+ public string[] PreImage { get; set; }
122
+ /// <summary>The columns of the post-image. "*" is all columns. Default: no post-image.</summary>
123
+ public string[] PostImage { get; set; }
124
+ /// <summary>Default: PreImage.</summary>
125
+ public string PreImageAlias { get; set; }
126
+ /// <summary>Default: PostImage.</summary>
127
+ public string PostImageAlias { get; set; }
128
+ /// <summary>Default: "&lt;type&gt;: &lt;message&gt; of &lt;table&gt;".</summary>
129
+ public string Name { get; set; }
130
+ public string Description { get; set; }
131
+ /// <summary>The unsecure configuration. Not for secrets.</summary>
132
+ public string Configuration { get; set; }
133
+ /// <summary>An alias. The deploy gives the secure configuration for it.</summary>
134
+ public string SecureConfig { get; set; }
135
+ /// <summary>An alias. The deploy gives the user for it. "caller" is the calling user.</summary>
136
+ public string RunAs { get; set; }
137
+ /// <summary>Async steps only. Default: false (the system job is deleted when it succeeds).</summary>
138
+ public bool KeepJob { get; set; }
139
+ /// <summary>The step id: a GUID that is the same in each environment.</summary>
140
+ public string Id { get; set; }
141
+ }
142
+
143
+ /// <summary>A Custom API that this plugin class runs. Give it an Id: a new GUID.</summary>
144
+ [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
145
+ internal sealed class CustomApiAttribute : Attribute
146
+ {
147
+ /// <summary>The unique name, with the publisher prefix.</summary>
148
+ public CustomApiAttribute(string uniqueName)
149
+ {
150
+ UniqueName = uniqueName;
151
+ }
152
+
153
+ public string UniqueName { get; private set; }
154
+
155
+ public string DisplayName { get; set; }
156
+ public string Description { get; set; }
157
+ /// <summary>Default: Global.</summary>
158
+ public Binding Binding { get; set; }
159
+ /// <summary>The logical name of the bound table. Only with a binding.</summary>
160
+ public string BoundTable { get; set; }
161
+ public bool IsFunction { get; set; }
162
+ public bool IsPrivate { get; set; }
163
+ /// <summary>Default: None.</summary>
164
+ public StepsAllowed StepsAllowed { get; set; }
165
+ public bool WorkflowEnabled { get; set; }
166
+ /// <summary>The name of the privilege needed to run the API.</summary>
167
+ public string Privilege { get; set; }
168
+ /// <summary>Default: true. False only binds this class to an API that another solution owns.</summary>
169
+ public bool Define { get; set; }
170
+ /// <summary>The Custom API id: a GUID that is the same in each environment.</summary>
171
+ public string Id { get; set; }
172
+ }
173
+
174
+ /// <summary>A request parameter of the Custom API of this class. Give it an Id: a new GUID.</summary>
175
+ [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
176
+ internal sealed class CustomApiInputAttribute : Attribute
177
+ {
178
+ public CustomApiInputAttribute(string name, ApiType type)
179
+ {
180
+ Name = name;
181
+ Type = type;
182
+ }
183
+
184
+ public string Name { get; private set; }
185
+ public ApiType Type { get; private set; }
186
+
187
+ public bool Optional { get; set; }
188
+ /// <summary>The table, for Entity, EntityReference and EntityCollection.</summary>
189
+ public string Table { get; set; }
190
+ public string DisplayName { get; set; }
191
+ public string Description { get; set; }
192
+ public string Id { get; set; }
193
+ }
194
+
195
+ /// <summary>A response property of the Custom API of this class. Give it an Id: a new GUID.</summary>
196
+ [AttributeUsage(AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
197
+ internal sealed class CustomApiOutputAttribute : Attribute
198
+ {
199
+ public CustomApiOutputAttribute(string name, ApiType type)
200
+ {
201
+ Name = name;
202
+ Type = type;
203
+ }
204
+
205
+ public string Name { get; private set; }
206
+ public ApiType Type { get; private set; }
207
+
208
+ /// <summary>The table, for Entity and EntityReference.</summary>
209
+ public string Table { get; set; }
210
+ public string DisplayName { get; set; }
211
+ public string Description { get; set; }
212
+ public string Id { get; set; }
213
+ }
214
+
215
+ /// <summary>A custom workflow activity.</summary>
216
+ [AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = false)]
217
+ internal sealed class WorkflowActivityAttribute : Attribute
218
+ {
219
+ public WorkflowActivityAttribute(string name)
220
+ {
221
+ Name = name;
222
+ }
223
+
224
+ public string Name { get; private set; }
225
+
226
+ public string Group { get; set; }
227
+ public string Description { get; set; }
228
+ }
229
+ }
@@ -0,0 +1,95 @@
1
+ ---
2
+ name: ppdo-cli-plugins
3
+ description: Register Dataverse plugins from attributes on the plugin classes with ppdo-cli, in a development environment - set up the registration attributes (PluginRegistration.cs) in a plugin project, add or change plugin steps, images, Custom APIs (with their request parameters and response properties) and workflow activities, deploy them with dv plugin register into an unmanaged solution, and move a project from spkl (CrmPluginRegistration) attributes. Use for any task that registers, deploys or changes plugin registrations, or that sets up or edits plugin registration attributes.
4
+ ---
5
+
6
+ # Plugin registration with ppdo-cli
7
+
8
+ Load the ppdo-cli skill first (account, modes, exit codes, output). Read `reference.md` in this folder for each attribute, its default and its Dataverse column.
9
+
10
+ `dv plugin register` is only for **development environments**. It puts plugin changes into an unmanaged solution in a development environment. Then `dv solution sync` puts them into source control, and the other environments (test, production) get them through the solution (`dv solution pack`, `dv solution import`). Never run `register` against test or production. The groups and modes of the ppdo-cli configuration control where it can write.
11
+
12
+ ## Commands
13
+
14
+ ```
15
+ ppdo-cli dv plugin inspect <file>
16
+ ppdo-cli dv plugin register [<file>] [--solution <name> | --no-solution] [--assembly] [--steps] [--apis]
17
+ [--prune | --keep-undeclared] [--force] [--add-bound-apis]
18
+ ppdo-cli dv plugin migrate <file>
19
+ ```
20
+
21
+ - `inspect`: reads a built plugin DLL without loading it (no .NET needed) and prints the manifest: each class with its steps, images, Custom API and workflow activity, and the `issues` (errors and warnings). Exit 1 if there is an error. No environment needed.
22
+ - `register`: makes the environment match the attributes. Always run it with `--dry-run` first and show the plan (`actions`, `warnings`, `blocked`) to the user. With no `<file>`, it registers each assembly in `plugins.assemblies` of `.ppdo-cli.json`.
23
+ - `--solution <name>`: also adds the assembly, the steps, the Custom APIs with their parameters and properties to that unmanaged solution. Without it, a solution export does not include them. `--no-solution` ignores the solution of `.ppdo-cli.json` for one run.
24
+ - `--assembly`, `--steps`, `--apis`: do only these parts (any combination). No part flag means all three. After a change to step attributes only, `--steps` does not upload the DLL.
25
+ - Exit 6 (conflict) with `blocked` in the output when the plan cannot be applied: a registered step, image or type is not in the code, or a Custom API column that cannot change has changed. Nothing is changed. Then ask the user:
26
+ - `--prune` deletes the registered steps, images and types that the code does not declare (needs mode `full`).
27
+ - `--keep-undeclared` leaves those steps and images.
28
+ - `--force` deletes and creates a Custom API, parameter or property whose fixed column changed, and deletes Custom API rows that the code does not declare (needs mode `full`). Without `--force`, ppdo-cli never deletes a Custom API row.
29
+ - Give `--prune`, `--keep-undeclared` or `--force` only when the user agrees to the rows that the plan names.
30
+ - `--add-bound-apis`: with `--solution`, also adds the Custom APIs with `Define = false` (another solution owns them).
31
+ - `migrate`: for each class with spkl attributes, prints the registration attributes that give the same registration, with the `Id` of each step in the environment. It does not change files. `not_converted` lists what the attributes cannot give (an image of type Both, two images of one type, Offline); those classes keep their spkl attributes.
32
+
33
+ ## Procedures
34
+
35
+ ### 1. Set up the attributes in a plugin project
36
+
37
+ 1. Copy `PluginRegistration.cs` from this skill folder into the plugin project, in the folder that the project uses for shared code. You can change its namespace. Do not change the name of a class, a property, a constructor parameter or an enum value, and do not change a number.
38
+ 2. Never change `PluginRegistration.cs` in this skill folder: after `ppdo-cli skills install --link` it is the ppdo-cli source.
39
+ 3. Build the project, then run `ppdo-cli dv plugin inspect <dll>`. It must show no error.
40
+
41
+ ### 2. Add or change a registration
42
+
43
+ 1. Put the attributes on the plugin class (see the examples below and `reference.md`).
44
+ 2. Give each new `PluginStep`, `CustomApi`, `CustomApiInput` and `CustomApiOutput` an `Id`: a new GUID that you make for that row. Never copy a GUID from a different row. When you change a row, keep its `Id`. With the `Id` in the code, each development environment and each solution export has the same id.
45
+ 3. Build, then run `ppdo-cli dv plugin inspect <dll>`. Correct each error, and each warning about a missing `Id`.
46
+
47
+ ### 3. Deploy to the development environment
48
+
49
+ 1. `ppdo-cli dv plugin register <dll> --solution <name> --dry-run`. Show the plan to the user.
50
+ 2. If `blocked` is not empty, tell the user each item and ask which flag to use (see Commands).
51
+ 3. `ppdo-cli dv plugin register <dll> --solution <name>` with the same flags.
52
+ 4. `ppdo-cli dv solution sync <folder>` and show the changed files to the user.
53
+
54
+ ### 4. Move a class from spkl attributes
55
+
56
+ 1. Do procedure 1.
57
+ 2. `ppdo-cli dv plugin migrate <dll>` against the development environment.
58
+ 3. For each class in the output, replace the `CrmPluginRegistration` attributes with the text in `attributes`. Leave the classes in `not_converted` as they are.
59
+ 4. When no class uses spkl attributes, remove the spkl attribute file.
60
+ 5. Build, then do procedure 3 with `--dry-run`: the plan must show no `create` and no `delete` for the moved classes.
61
+
62
+ ### 5. Find a failure
63
+
64
+ Use the read commands of the ppdo-cli-dataverse skill: `dv plugin step list`, `dv plugin trace list`, `dv plugin assembly get --compare <dll>`.
65
+
66
+ ## Examples
67
+
68
+ ```csharp
69
+ [PluginStep(Messages.Update, "account",
70
+ Mode = Mode.Asynchronous,
71
+ Columns = new[] { "name", "telephone1" },
72
+ PreImage = new[] { "name" },
73
+ PostImage = new[] { "name", "telephone1" },
74
+ Id = "6f1c2a4e-0b7d-4c1e-9a52-3d8e7f6b1a90")]
75
+ [PluginStep(Messages.Create, "account", Stage = Stage.PreOperation, Id = "b2d94e17-5c3a-4f86-8e0b-71a9c4d2e5f3")]
76
+ public sealed class AccountPlugin : IPlugin { }
77
+
78
+ [CustomApi("contoso_CalculateRisk", DisplayName = "Calculate risk", Id = "0c5e8a31-9f24-4b7d-a6e1-58d3b2c9f704")]
79
+ [CustomApiInput("Threshold", ApiType.Integer, Optional = true, Id = "e7a41b98-2d6c-4e53-b0f8-9c1a7d35e216")]
80
+ [CustomApiOutput("Score", ApiType.Decimal, Id = "3b9f0d6a-71e4-4c28-8a5d-e4f26b1c0937")]
81
+ public sealed class CalculateRisk : IPlugin { }
82
+
83
+ [WorkflowActivity("Send reminder", Group = "Contoso")]
84
+ public sealed class SendReminder : CodeActivity { }
85
+ ```
86
+
87
+ The GUIDs above are examples: make new ones.
88
+
89
+ ## Rules that ppdo-cli checks
90
+
91
+ - An asynchronous step is only in `PostOperation`. No pre-image on Create; no post-image on Delete or in a pre stage. Images only on messages that can have them.
92
+ - `KeepJob` only on an asynchronous step. The default deletes the system job of a step that succeeds.
93
+ - A value that you do not give for `Description`, `Configuration`, `SecureConfig` or `RunAs` is not changed in the environment. To remove one, give `""` (or `RunAs = "caller"`).
94
+ - `SecureConfig` and `RunAs` are aliases. Their values come from `.ppdo-cli.json`: `"plugins": {"runAs": {"<alias>": {"<env>": "<user id or domain name>"}}, "secureConfig": {"<alias>": "<ENV_VAR>"}}`. A secret is never in the DLL.
95
+ - A Custom API's unique name has the prefix of the solution's publisher. Its binding, bound table, is-function, steps allowed and workflow-enabled, and a parameter's type, table and optional, cannot change after the create (`--force` deletes and creates it).
@@ -0,0 +1,72 @@
1
+ # Registration attributes: reference
2
+
3
+ The classes are in `PluginRegistration.cs` (version 1). Only the values with no default are constructor arguments; all others are named properties.
4
+
5
+ ## PluginStep (many for each class)
6
+
7
+ | Value | Kind | Default | Dataverse column |
8
+ |---|---|---|---|
9
+ | message | constructor | | `sdkmessageid` |
10
+ | table | constructor (leave out for a global message) | none | `sdkmessagefilterid` |
11
+ | `Stage` | `Stage.PreValidation` (10), `PreOperation` (20), `PostOperation` (40) | `PostOperation` | `stage` |
12
+ | `Mode` | `Mode.Synchronous` (0), `Asynchronous` (1) | `Synchronous` | `mode` |
13
+ | `Order` | int | 1 | `rank` |
14
+ | `Columns` | `string[]` | all columns | `filteringattributes` |
15
+ | `PreImage`, `PostImage` | `string[]`; `"*"` is all columns | no image | step image |
16
+ | `PreImageAlias`, `PostImageAlias` | string | `PreImage`, `PostImage` | `entityalias`, `name` |
17
+ | `Name` | string | `<type>: <message> of <table>` | `name` |
18
+ | `Description` | string | not changed | `description` |
19
+ | `Configuration` | string (not for secrets) | not changed | `configuration` |
20
+ | `SecureConfig` | alias | not changed | secure configuration |
21
+ | `RunAs` | alias, or `"caller"` | not changed | `impersonatinguserid` |
22
+ | `KeepJob` | bool, asynchronous only | false (the job is deleted) | `asyncautodelete` |
23
+ | `Id` | GUID string | a new GUID at the create | `sdkmessageprocessingstepid` |
24
+
25
+ ## CustomApi (one for each class), CustomApiInput, CustomApiOutput
26
+
27
+ | Attribute | Value | Default | Column |
28
+ |---|---|---|---|
29
+ | `CustomApi` | unique name (constructor, with the publisher prefix) | | `uniquename`, `name` |
30
+ | | `DisplayName`, `Description` | the unique name | `displayname`, `description` |
31
+ | | `Binding`: `Global` 0, `Table` 1, `TableCollection` 2 | `Global` | `bindingtype` (fixed) |
32
+ | | `BoundTable` | none | `boundentitylogicalname` (fixed) |
33
+ | | `IsFunction` | false | `isfunction` (fixed) |
34
+ | | `IsPrivate` | false | `isprivate` |
35
+ | | `StepsAllowed`: `None` 0, `AsyncOnly` 1, `SyncAndAsync` 2 | `None` | `allowedcustomprocessingsteptype` (fixed) |
36
+ | | `WorkflowEnabled` | false | `workflowsdkstepenabled` (fixed) |
37
+ | | `Privilege` | none | `executeprivilegename` |
38
+ | | `Define` | true; false only binds this class to an API that exists | |
39
+ | | `Id` | a new GUID at the create | `customapiid` |
40
+ | `CustomApiInput` | name, `ApiType` (constructor) | | `uniquename`, `name`, `type` (fixed) |
41
+ | | `Optional` | false | `isoptional` (fixed) |
42
+ | | `Table` (Entity, EntityReference, EntityCollection) | none | `logicalentityname` (fixed) |
43
+ | | `DisplayName`, `Description`, `Id` | the name; a new GUID | |
44
+ | `CustomApiOutput` | name, `ApiType` (constructor) | | `uniquename`, `name`, `type` (fixed) |
45
+ | | `Table`, `DisplayName`, `Description`, `Id` | | |
46
+
47
+ `ApiType`: Boolean 0, DateTime 1, Decimal 2, Entity 3, EntityCollection 4, EntityReference 5, Float 6, Integer 7, Money 8, Picklist 9, String 10, StringArray 11, Guid 12.
48
+
49
+ "Fixed" columns cannot change after the create. A change stops `register` (exit 6) unless `--force`, which deletes and creates the row. Dataverse refuses the delete of a Custom API while a step is on its message, so `--force` first deletes the steps of this assembly on that message and makes them again (it needs the part `steps`).
50
+
51
+ Checks: a function has one or more outputs; an API with binding `Table` does not declare `Target`; an EntityCollection output has no `Table`; a workflow-enabled API is not a function, has no Entity, EntityCollection or StringArray parameter, and has an EntityReference input only when it is bound.
52
+
53
+ ## WorkflowActivity (one for each class)
54
+
55
+ Name (constructor), `Group`, `Description`. Columns: `name`, `workflowactivitygroupname`, `description`.
56
+
57
+ ## Rows that the code does not declare
58
+
59
+ | Row | No flag | `--keep-undeclared` | `--prune` | `--force` |
60
+ |---|---|---|---|---|
61
+ | Step (and its images) | stop | leave | delete | no effect |
62
+ | Image on a declared step | stop | leave | delete | no effect |
63
+ | Type not in the DLL | stop | stop | delete it and its steps | no effect |
64
+ | Type not in the DLL that runs a Custom API | stop | stop | stop, unless the API moves to another class | with `--prune --apis`: remove it from the API, then delete |
65
+ | Request parameter or response property | leave, with a warning | leave | leave | delete |
66
+ | Custom API that no class declares now | leave | leave | leave | remove its plugin type (the API stays) |
67
+
68
+ Managed rows, hidden rows and the platform step of a Custom API are never changed.
69
+
70
+ ## spkl attributes
71
+
72
+ A class with `CrmPluginRegistration` is read as spkl. One assembly can have classes of each set; one class cannot have both. ppdo-cli reads the spkl enums by name (spkl's numbers are not Dataverse's). `SecureConfiguration` and `Action` are ignored, as spkl did. Only public classes that are not abstract are read. `spkl.json` is not read: give the DLL and `--solution`, or list them in `.ppdo-cli.json`. A step that is registered and not in the code stops the command (spkl deleted it).
@@ -1,4 +0,0 @@
1
- import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
2
- import{a as R}from"./chunk-WNQERCOO.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{j as $}from"./chunk-WXOTXJNG.js";import"./chunk-ZHHVG47C.js";import{randomUUID as x}from"node:crypto";var S=["POST","PUT","PATCH","DELETE"];function w(){return{status:0,error:"no response (stopped after an earlier error)"}}var c=`\r
3
- `;function y(){return x().replace(/-/g,"")}function C(u,p,o,e){let t=[`${u} ${p} HTTP/1.1`,"Accept: application/json"];for(let[s,r]of Object.entries(e??{}))t.push(`${s}: ${r}`);if(["POST","PUT","PATCH"].includes(u)&&o!==null&&o!==void 0){let s=$(o,!1);return t.push("Content-Type: application/json",`Content-Length: ${Buffer.byteLength(s,"utf8")}`,"",s),t.join(c)}return t.join(c)+c}function T(u,p,o,e,t=null){let s=["Content-Type: application/http","Content-Transfer-Encoding: binary"];return t!==null&&s.push(`Content-ID: ${t}`),s.join(c)+c+c+C(u,p,o,e)}function H(u,p,o){let e=`batch_${y()}`,t=[],s=[],r=[],i=n=>n.includes("://")?n:p+(n.startsWith("/")?n:R+n),l=()=>{if(!r.length)return;let n=`changeset_${y()}`,g=r.map(([,a],h)=>`--${n}${c}${T(a.method,i(a.path),a.body,a.headers,h+1)}${c}`).join("");t.push(`Content-Type: multipart/mixed; boundary=${n}${c}${c}${g}--${n}--`),s.push(r.map(([a])=>a)),r=[]};u.forEach((n,g)=>{if(o&&S.includes(n.method)){r.push([g,n]);return}l(),t.push(T(n.method,i(n.path),n.body,n.headers)),s.push([g])}),l();let d=t.map(n=>`--${e}${c}${n}${c}`).join("")+`--${e}--${c}`;return[e,d,s]}function P(u){return u.replace(/^[\r\n]+|[\r\n]+$/g,"")}function j(u,p){let o=[];for(let e of u.split(`--${p}`)){if(e=P(e),!e||e==="--")continue;let t=/\r?\n\r?\n/.exec(e),s=t?e.slice(0,t.index):e,r=t?e.slice(t.index+t[0].length):"";if(s.toLowerCase().includes("multipart/mixed")){let f=/boundary=([^\s;]+)/.exec(s);f&&o.push(j(r,f[1]).flat());continue}let i=r.split(/\r?\n/),l=i.findIndex(f=>f.startsWith("HTTP/1."));if(l<0){r.trim()&&o.push([{status:0,error:"unparseable sub-response",raw:r.trim().slice(0,200)}]);continue}let d=i[l].split(" ")[1],n=d!==void 0&&/^\s*[+-]?\d+\s*$/.test(d)?parseInt(d,10):0;Number.isNaN(n)&&(n=0);let g={},a=l+1;for(;a<i.length&&i[a].trim();){let f=i[a],m=f.indexOf(":");m>=0&&(g[f.slice(0,m).trim().toLowerCase()]=f.slice(m+1).trim()),a++}let h=i.slice(a+1).join(`
4
- `).trim(),b=null;if(h)try{b=JSON.parse(h)}catch{b=h}o.push([{status:n,headers:g,body:b}])}return o}function L(u,p,o){let e=Array.from({length:o},()=>w()),t=Math.min(u.length,p.length);for(let s=0;s<t;s++){let r=u[s],i=p[s];if(i.length===r.length)r.forEach((l,d)=>{e[l]=i[d]});else if(i.length){let l={...i[0]};r.length>1&&(l.rolled_back=!0);for(let d of r)e[d]=l}}return e}export{S as WRITE_METHODS,H as build,L as distribute,w as noResponse,j as parse};
@@ -1,2 +0,0 @@
1
- import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
2
- import{a as W}from"./chunk-KBQYSAJX.js";import{p as O}from"./chunk-BODUSF3V.js";import{C as S,D as p,E as P,M as Z,O as F,P as B,Q as V,a as k,b as x,d as H,e as A,f as U,g as v,m,o as w,p as _,q as R,r as z}from"./chunk-TXVNEV3M.js";import{a as T}from"./chunk-UCTMKA2J.js";import{b as M}from"./chunk-WNQERCOO.js";import{y as J}from"./chunk-BALEFXOL.js";import"./chunk-4KP27OCL.js";import"./chunk-J4R6QXW7.js";import{b as j}from"./chunk-5SBBTR3Y.js";import"./chunk-WMDKJRDC.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};
@@ -1,2 +0,0 @@
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,s,o){if(n=n.toUpperCase(),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(s)&&f(o).includes("DELETE")?"this $batch contains a DELETE part; needs mode 'full'":null;if(n==="POST"){if(p(s)){let l=f(o),i=l.filter(a=>!c.includes(a));return l.length&&!i.length?null:i.length?`this $batch contains a ${i[0]} part; mode is 'read-only'`:"cannot read the $batch parts; mode is 'read-only'"}if(h(r,s))return null}return`${n} is not allowed in mode 'read-only'`}function $(e,t,r,n,s,o){let l=o||(typeof e.args._cls=="string"?e.args._cls:"M"),i=t.target,a=v(i.mode,l,t.service.name,r,n,s);if(a)throw new u(`blocked: ${a}`,{service:t.service.name,hint:w(i)})}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};
@@ -1,2 +0,0 @@
1
- import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
2
- import{B as V,C as f,D as m,E as d,G as Y,I as h,P as v,a as B,b as A,d as _,e as P,f as z,h as j,i as D,k as W,l as H,m as J,n as $,o as i,p as U,q as y,r as T,t as S,w as L}from"./chunk-TXVNEV3M.js";import{b as G}from"./chunk-5SBBTR3Y.js";import{e as F}from"./chunk-S4KF5Z3S.js";import{b as I,d as E,j as C}from"./chunk-WXOTXJNG.js";var Z={owner:0,access:1,"aad-group":2,"aad-office":3},K=new Map(Object.entries(Z).map(([e,a])=>[a,e])),re=["Create","Read","Write","Delete","Append","AppendTo","Assign","Share"],ee="name,teamtype,azureactivedirectoryobjectid,membershiptype,isdefault,_businessunitid_value,_administratorid_value,description,teamid",Q="name,ismanaged,_businessunitid_value,_parentrootroleid_value,roleid";function M(){return Y(`odata.include-annotations="${W}"`)}function ce(e){return e.service.origin}function te(e){return typeof e=="number"&&K.has(e)?K.get(e):e===void 0?null:e}async function N(e,a,t){let n="fullname,domainname,isdisabled,_businessunitid_value,azureactivedirectoryobjectid,accessmode,systemuserid";t.toLowerCase()==="me"&&(t=d(await m(e,a,"GET","WhoAmI")).UserId);let s=A(t)?`systemuserid eq ${_(t)}`:`domainname eq ${P(t)}`,r=y(d(await m(e,a,"GET","systemusers",{params:[["$select",n],["$filter",s]],headers:M()})).value);if(!r.length)throw new E(`no user '${t}'`,{service:"dataverse",hint:"use me, a user id, or a sign-in name"});return r[0]}async function k(e,a,t){let n=A(t)?`teamid eq ${_(t)}`:`name eq ${P(t)}`,s=y(d(await m(e,a,"GET","teams",{params:[["$select",ee],["$filter",n]],headers:M()})).value);if(!s.length)throw new E(`no team '${t}'`,{service:"dataverse",hint:"run: ppdo-cli dv team list --name '*<part>*'"});if(s.length>1)throw new I(`${s.length} teams are named '${t}'; use an id`,{hint:s.map(r=>r.teamid).join(", ")});return s[0]}async function ae(e,a,t,n=null){if(A(t)){let o=d(await m(e,a,"GET",`roles(${_(t)})`,{params:[["$select",Q]]}));if(!n||i(o,"_businessunitid_value")===n)return o;t=o.name}let s=`name eq ${P(t)} and `+(n?`_businessunitid_value eq ${n}`:"_parentroleid_value eq null"),r=y(d(await m(e,a,"GET","roles",{params:[["$select",Q],["$filter",s]]})).value);if(!r.length)throw new E(`no role '${t}'`+(n?" in that business unit":""),{service:"dataverse",hint:"run: ppdo-cli dv role list --name '*<part>*'"});return r[0]}function q(e,a){return $(i(e,`${a}${H}`),i(e,a))}function ne(e){let a=i(e,"teamtype");return T({name:i(e,"name"),type:te(a),business_unit:q(e,"_businessunitid_value"),default:J(i(e,"isdefault"))?e.isdefault:null,entra_group:i(e,"azureactivedirectoryobjectid"),membership:a===2||a===3?q(e,"membershiptype"):null,id:i(e,"teamid")})}async function fe(e){let a=e.args,t=await f(e);G(e,t,"GET","teams",null);let n=[],s=v(a.type);s&&n.push(`teamtype eq ${Z[s]}`);let r=v(a.name);r&&n.push(D("name",r));let o=[["$select",ee],["$orderby","name"]];n.length&&o.push(["$filter",n.join(" and ")]);let[c]=await h(e,t,"teams",o,M(),L(a),"teams");await e.emit(c.map(ne))}async function O(e,a,t){let[n]=await h(e,a,`teams(${t})/teamroles_association`,[["$select","name"]],null,null);return S(n.map(s=>i(s,"name")),s=>s)}async function ye(e){let a=await f(e),t=await k(e,a,String(e.args.team)),[n]=await h(e,a,`teams(${t.teamid})/teammembership_association`,[["$select","fullname,domainname"],["$orderby","fullname"]],null,L(e.args),"members");await e.emit(T({...ne(t),description:i(t,"description"),roles:await O(e,a,t.teamid),members:n.map(s=>({name:i(s,"fullname"),upn:i(s,"domainname")}))}))}async function ie(e,a){let t=e.args,n=await f(e);G(e,n,a?"POST":"DELETE","teams",Buffer.from("{}"));let[s,r]=await n.lookups(async()=>{let c=await k(e,n,String(t.team));return[c,await ae(e,n,String(t.role),i(c,"_businessunitid_value"))]}),o=`teams(${s.teamid})/teamroles_association`;if(a){let c={"@odata.id":`${ce(n)}/api/data/v9.2/roles(${r.roleid})`};await m(e,n,"POST",`${o}/$ref`,{body:Buffer.from(C(c),"utf8")})}else await m(e,n,"DELETE",`${o}(${r.roleid})/$ref`);await e.emit({team:i(s,"name"),role:i(r,"name"),roles:await O(e,n,s.teamid)})}function Re(e){return ie(e,!0)}function $e(e){return ie(e,!1)}var X=["Basic","Local","Deep","Global"];async function se(e,a,t,n,s,r=m){if(n){let l=d(await r(e,a,"GET",`EntityDefinitions(LogicalName='${n}')`,{params:[["$select","SchemaName"]]})).SchemaName,p={};for(let R of re){let g=t.filter(u=>String(i(u,"PrivilegeName")??"").toLowerCase()===`prv${R}${l}`.toLowerCase()).map(u=>i(u,"Depth")),w="none";if(g.length){w=g[0];for(let u of g.slice(1))X.indexOf(u)>X.indexOf(w)&&(w=u)}p[R.toLowerCase()]=w}return{table:n,access:p}}let o=L(e.args),c=S(t.map(l=>({privilege:i(l,"PrivilegeName"),depth:i(l,"Depth")})),l=>l.privilege||"");return o!==null&&c.length>o&&(F(`showing the first ${o} of ${c.length} ${s}; pass --table <name>, --limit n or --all`),c=c.slice(0,o)),{total:t.length,privileges:c}}async function he(e){let a=e.args,t=await f(e);G(e,t,"GET","roles",null);let n=v(a.name),s=["_parentroleid_value eq null",...n?[D("name",n)]:[]],[r]=await h(e,t,"roles",[["$select","name,ismanaged,modifiedon,roleid"],["$filter",s.join(" and ")],["$orderby","name"]],null,L(a),"roles");await e.emit(r.map(o=>({name:i(o,"name"),managed:i(o,"ismanaged"),modified:i(o,"modifiedon"),id:i(o,"roleid")})))}async function ve(e){let a=e.args,t=await f(e),n=await ae(e,t,String(a.role)),[s,r]=j("RetrieveRolePrivilegesRole",[["RoleId",n.roleid]]),o=y(d(await m(e,t,"GET",s,{params:r})).RolePrivileges);await e.emit({name:n.name,managed:i(n,"ismanaged"),id:n.roleid,...await se(e,t,o,v(a.table),"privileges")})}async function be(e){let a=await f(e),t=await N(e,a,String(e.args.user)),n=t.systemuserid,[s]=await h(e,a,`systemusers(${n})/systemuserroles_association`,[["$select","name"]],null,null),[r]=await h(e,a,`systemusers(${n})/teammembership_association`,[["$select","name,teamtype,isdefault,teamid"]],null,null),o=[];for(let c of S(r,l=>String(i(l,"name")||"").toLowerCase()))o.push({name:i(c,"name"),type:te(i(c,"teamtype")),roles:await O(e,a,c.teamid)});await e.emit(T({name:i(t,"fullname"),upn:i(t,"domainname"),business_unit:q(t,"_businessunitid_value"),disabled:i(t,"isdisabled"),access_mode:q(t,"accessmode"),entra_object_id:i(t,"azureactivedirectoryobjectid"),id:n,roles:S(s.map(c=>i(c,"name")),c=>c),teams:o}))}async function _e(e){let a=await f(e),t=await N(e,a,String(e.args.user)),n=y(d(await m(e,a,"GET",`systemusers(${t.systemuserid})/Microsoft.Dynamics.CRM.RetrieveUserPrivileges`)).RolePrivileges);await e.emit({user:$(i(t,"domainname"),i(t,"fullname")),id:t.systemuserid,...await se(e,a,n,v(e.args.table),"privileges")})}async function le(e,a,t){B(t,"entity set name");let n=y(d(await m(e,a,"GET","EntityDefinitions",{params:[["$select","LogicalName"],["$filter",`EntitySetName eq ${P(t)}`]]})).value);if(!n.length)throw new E(`no table with entity set '${t}'`,{service:"dataverse",hint:"use the plural entity set name, e.g. accounts"});return n[0].LogicalName}function oe(e){return(e||"").split(",").map(a=>z(a)).filter(a=>a&&a!=="None").map(a=>a.replace(/Access$/,"").toLowerCase())}async function Ee(e){let a=e.args;V(a,{user:"--user",team:"--team"},!0,"dv access origin");let t=String(a.entityset),n=await f(e),s=await le(e,n,t),r=_(String(a.id)),o,c,l,p=v(a.user);if(p){let b=await N(e,n,p);[o,c,l]=[b.systemuserid,$(i(b,"domainname"),i(b,"fullname")),"systemusers"]}else{let b=await k(e,n,String(a.team));[o,c,l]=[b.teamid,i(b,"name"),"teams"]}let[R,g]=j("RetrieveAccessOrigin",[["ObjectId",r],["LogicalName",s],["PrincipalId",o]],new Set(["LogicalName"])),w=i(d(await m(e,n,"GET",R,{params:g})),"Response"),u=C({"@odata.id":`${t}(${r})`}),x=i(d(await m(e,n,"GET",`${l}(${o})/Microsoft.Dynamics.CRM.RetrievePrincipalAccess(Target=@t)`,{params:[["@t",u]]})),"AccessRights");await e.emit({record:`${t}(${r})`,principal:c,rights:oe(x),origin:w})}async function Pe(e){let a=e.args,t=String(a.entityset),n=await f(e);B(t,"entity set name");let s=_(String(a.id)),r=C({"@odata.id":`${t}(${s})`}),o=y(d(await m(e,n,"GET","RetrieveSharedPrincipalsAndAccess(Target=@t)",{params:[["@t",r]]})).PrincipalAccesses),c=[];for(let l of o){let p=U(i(l,"Principal")),R=String(i(p,"@odata.type")||""),g=R.slice(R.lastIndexOf(".")+1),w=$($(i(p,"ownerid"),i(p,"teamid")),i(p,"systemuserid")),u=null;try{if(g==="team")u=i(await k(e,n,w),"name");else if(g==="systemuser"){let x=await N(e,n,w);u=$(i(x,"domainname"),i(x,"fullname"))}}catch{}c.push(T({principal:u,type:g==="systemuser"?"user":g,id:w,rights:oe(i(l,"AccessMask"))}))}await e.emit(c)}export{Z as a,K as b,re as c,N as d,k as e,ae as f,fe as g,ye as h,Re as i,$e as j,se as k,he as l,ve as m,be as n,_e as o,le as p,oe as q,Ee as r,Pe as s};
@@ -1,2 +0,0 @@
1
- import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
2
- import{d as z}from"./chunk-PYTSDUPY.js";import{C as Q,D as X,E as ee,I as te,L as ne,P as C,Q as oe,b as W,d as Z,m as q,n as K,o as r,p as D,q as R,t as B,u as G}from"./chunk-TXVNEV3M.js";import{a as V}from"./chunk-UCTMKA2J.js";import{b as Y}from"./chunk-5SBBTR3Y.js";import{e as T}from"./chunk-S4KF5Z3S.js";import{b as A}from"./chunk-WXOTXJNG.js";import{readFileSync as U}from"node:fs";import{gunzipSync as le}from"node:zlib";var ue=["resolved","not-found","type-unsupported"],ce=new Map([[3,"relationship-internal"],[4,"choice-value"],[5,"lookup-value"],[6,"view-column"],[7,"label"],[8,"relationship-condition"],[11,"relationship-role"],[12,"relationship-role-link"],[14,"key"],[46,"table-map"],[47,"column-map"],[48,"ribbon-command"],[49,"ribbon-context-group"],[50,"ribbon-customization"],[52,"ribbon-rule"],[53,"ribbon-tab-command-map"],[55,"ribbon-diff"],[68,"custom-control-default"],[88,"app-role"],[90,"plugin-type"],[93,"step-image"]]),ae=500,pe=new Map([[20,["role","name",null]],[26,["savedquery","name","returnedtypecode"]],[29,["workflow","uniquename|name","primaryentity"]],[36,["template","title","templatetypecode"]],[48,["ribboncommand","command","entity"]],[49,["ribboncontextgroup","contextgroupid","entity"]],[50,["ribboncustomization","entity","entity"]],[52,["ribbonrule","ruleid","entity"]],[53,["ribbontabtocommandmap","controlid","entity"]],[55,["ribbondiff","diffid","entity"]],[59,["savedqueryvisualization","name","primaryentitytypecode"]],[60,["systemform","name","objecttypecode"]],[61,["webresource","name",null]],[62,["sitemap","sitemapnameunique|sitemapname",null]],[63,["connectionrole","name",null]],[66,["customcontrol","name",null]],[70,["fieldsecurityprofile","name",null]],[80,["appmodule","uniquename|name",null]],[90,["plugintype","typename",null]],[91,["pluginassembly","name",null]],[92,["sdkmessageprocessingstep","name",null]],[93,["sdkmessageprocessingstepimage","name",null]],[95,["serviceendpoint","name",null]],[300,["canvasapp","name",null]],[380,["environmentvariabledefinition","schemaname",null]],[381,["environmentvariablevalue","schemaname",null]]]),se=["PicklistAttributeMetadata","MultiSelectPicklistAttributeMetadata","StateAttributeMetadata","StatusAttributeMetadata","BooleanAttributeMetadata"],fe="00000000-0000-0000-0000-000000000000";function ie(t){if(typeof t!="string"||!W(t))return null;let o=Z(t);return o===fe?null:o}function I(t){if(t==null)return"None";if(t===!0)return"True";if(t===!1)return"False";if(typeof t=="number")return String(t);if(typeof t=="string"){let o=t.includes("'")&&!t.includes('"')?'"':"'",s=t.replace(/\\/g,"\\\\").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t");return o==="'"&&(s=s.replace(/'/g,"\\'")),o+s+o}return Array.isArray(t)?"["+t.map(I).join(", ")+"]":"{"+Object.entries(t).map(([o,s])=>`${I(o)}: ${I(s)}`).join(", ")+"}"}var L=(t,o)=>`${t}|${o}`;function de(t){let o=new Map,s=(u,i,p=null)=>{let f=ie(i);if(typeof u!="number"||!Number.isInteger(u)||f===null)throw new A(`not a component (type, id): ${I(u)}, ${I(i)}`);let b=L(u,f),y=o.get(b);o.set(b,{key:[u,f],parent:y?.parent||ie(p)})},c=0;for(let u of t){if(c++,!u.trim())continue;let i;try{i=V(u)}catch(p){throw new A(`line ${c} is not JSON: ${p.message}`)}if("requiredcomponentobjectid"in i||"dependentcomponentobjectid"in i)for(let p of["required","dependent"])s(r(i,p+"componenttype"),r(i,p+"componentobjectid"),r(i,p+"componentparentid"));else"componenttype"in i?s(r(i,"componenttype"),r(i,"objectid")):s(r(i,"type"),r(i,"id"),r(i,"parent_id"))}return o}function re(t){return ne(t)}function ge(t,o){for(let s of o.split("|"))if(q(r(t,s)))return t[s];return null}var ye=["type","id","type_name","name_status","name","logical_name","schema_name","parent_type","parent_id","parent_logical_name","parent_schema_name","source"];function w(t,o,s,c={}){let u={};for(let i of ye)u[i]=null;Object.assign(u,{type:t,id:o,type_name:z.get(t)??ce.get(t)??null,name_status:s});for(let[i,p]of Object.entries(c))i in u&&(u[i]=p===void 0?null:p);return u}var F=class{constructor(o,s){this.rt=o;this.client=s}tablesCache=null;async get(o,s){return ee(await X(this.rt,this.client,"GET",o,{params:s}))}async all(o,s){return(await te(this.rt,this.client,o,s,null,null))[0]}async tables(){if(this.tablesCache===null){let o=await this.get("EntityDefinitions",[["$select","MetadataId,LogicalName,SchemaName,DisplayName,EntitySetName,PrimaryIdAttribute,PrimaryNameAttribute,ObjectTypeCode"]]);this.tablesCache=new Map(R(o.value).map(s=>[String(s.MetadataId).toLowerCase(),s]))}return this.tablesCache}async tableByName(o){if(!q(o))return null;for(let s of(await this.tables()).values())if(s.LogicalName===o)return s;return null}async batch(o){let s=[],c=o.map(u=>({method:"GET",path:u}));for await(let[,,u]of oe(this.rt,this.client,c,!1,!0))s.push(...u);return s}};async function we(t,o,s){let c=new F(t,o),u=new Map,i=(e,n,a)=>{u.set(L(e,n),{key:[e,n],row:a})},p=new Map;for(let{key:e}of s.values()){let[n,a]=e;p.has(n)||p.set(n,[]),p.get(n).push(a)}let f=e=>p.get(e)??[],b=(e,n)=>s.get(L(e,n))?.parent??null,y=await c.tables(),S=async e=>{let n=await c.tableByName(e);return{parent_type:1,parent_id:n?n.MetadataId:null,parent_logical_name:e,parent_schema_name:n?n.SchemaName:null}};for(let e of f(1)){let n=y.get(e);i(1,e,n?w(1,e,"resolved",{name:re(r(n,"DisplayName")),logical_name:n.LogicalName,schema_name:n.SchemaName,source:"EntityDefinitions"}):w(1,e,"not-found",{source:"EntityDefinitions"}))}let h=new Map,$=B(G(f(2).map(e=>b(2,e)).filter(e=>e!==null&&y.has(e))),e=>e),x=await c.batch($.map(e=>`EntityDefinitions(${e})/Attributes?$select=MetadataId,LogicalName,SchemaName,DisplayName`));if($.forEach((e,n)=>{let a=x[n];if(a)for(let m of R(r(D(r(a,"body")),"value")))h.set(String(m.MetadataId).toLowerCase(),[m,y.get(e)])}),f(2).some(e=>!h.has(e))){let e=await c.get("EntityDefinitions",[["$select","MetadataId"],["$expand","Attributes($select=MetadataId,LogicalName,SchemaName,DisplayName)"]]);for(let n of R(e.value))for(let a of R(r(n,"Attributes"))){let m=String(a.MetadataId).toLowerCase();h.has(m)||h.set(m,[a,y.get(String(n.MetadataId).toLowerCase())??{}])}}for(let e of f(2)){let n=h.get(e);if(n){let[a,m]=n;i(2,e,w(2,e,"resolved",{name:re(r(a,"DisplayName")),logical_name:a.LogicalName,schema_name:a.SchemaName,parent_type:1,parent_id:r(m,"MetadataId"),parent_logical_name:r(m,"LogicalName"),parent_schema_name:r(m,"SchemaName"),source:"Attributes"}))}else i(2,e,w(2,e,"not-found",{source:"Attributes"}))}let me=[...f(10),...f(3)],H=new Map;if(me.length){let e=await c.get("RelationshipDefinitions",[["$select","MetadataId,SchemaName"]]);for(let n of R(e.value))H.set(String(n.MetadataId).toLowerCase(),n)}for(let e of[10,3])for(let n of f(e)){let a=H.get(n);i(e,n,a?w(e,n,"resolved",{name:a.SchemaName,schema_name:a.SchemaName,source:"RelationshipDefinitions"}):w(e,n,e===10?"not-found":"type-unsupported",{source:"RelationshipDefinitions"}))}if(f(14).length){let e=new Map,n=await c.get("EntityDefinitions",[["$select","MetadataId"],["$expand","Keys($select=MetadataId,LogicalName,SchemaName)"]]);for(let a of R(n.value))for(let m of R(r(a,"Keys")))e.set(String(m.MetadataId).toLowerCase(),[m,y.get(String(a.MetadataId).toLowerCase())??{}]);for(let a of f(14)){let m=e.get(a);if(m){let[_,N]=m;i(14,a,w(14,a,"resolved",{name:_.SchemaName,logical_name:_.LogicalName,schema_name:_.SchemaName,parent_type:1,parent_id:r(N,"MetadataId"),parent_logical_name:r(N,"LogicalName"),parent_schema_name:r(N,"SchemaName"),source:"Keys"}))}else i(14,a,w(14,a,"not-found",{source:"Keys"}))}}if(f(9).length){let e=new Map,n=await c.get("GlobalOptionSetDefinitions",[["$select","MetadataId,Name"]]);for(let l of R(n.value))e.set(String(l.MetadataId).toLowerCase(),l);let a=new Set;for(let l of f(9)){let g=e.get(l);g?i(9,l,w(9,l,"resolved",{name:g.Name,schema_name:g.Name,source:"GlobalOptionSetDefinitions"})):a.add(l)}let m=new Set;for(let{key:l,parent:g}of s.values())l[0]===2&&g&&m.add(g);for(let l of f(1))m.add(l);let _=[...y.keys()],N=[_.filter(l=>m.has(l)),_.filter(l=>!m.has(l))];for(let l=0;l<N.length;l++){let g=N[l];if(!a.size||!g.length)continue;l===1&&T(`looking for ${a.size} local choice(s) in the choice columns of every other table`);let j=g.flatMap(d=>se.map(k=>`EntityDefinitions(${d})/Attributes/Microsoft.Dynamics.CRM.${k}?$select=MetadataId,LogicalName,SchemaName&$expand=OptionSet($select=MetadataId,Name,IsGlobal)`));(await c.batch(j)).forEach((d,k)=>{let M=y.get(g[Math.floor(k/se.length)]);for(let v of R(r(D(r(d,"body")),"value"))){let P=D(r(v,"OptionSet")),E=String(K(r(P,"MetadataId"),"")).toLowerCase();a.has(E)&&(a.delete(E),i(9,E,w(9,E,"resolved",{name:r(P,"Name"),schema_name:r(P,"Name"),parent_type:2,parent_id:v.MetadataId,parent_logical_name:`${M.LogicalName}.${v.LogicalName}`,parent_schema_name:`${M.SchemaName}.${v.SchemaName}`,source:"Attributes/OptionSet"})))}})}for(let l of a)i(9,l,w(9,l,"not-found",{source:"GlobalOptionSetDefinitions"}))}let J=new Map;for(let e of y.values())J.set(r(e,"ObjectTypeCode"),e);for(let[e,n]of p){if([1,2,3,9,10,14].includes(e))continue;let a=pe.get(e),m=a?await c.tableByName(a[0]):e>=1e4?J.get(e)??null:null;if(!m){for(let d of n)i(e,d,w(e,d,"type-unsupported"));continue}let _=m.EntitySetName,N=m.PrimaryIdAttribute,l=a?a[1]:K(r(m,"PrimaryNameAttribute"),N),g=a?a[2]:null,j=G([N,...l.split("|"),...g?[g]:[]]).join(","),O=new Map;for(let d=0;d<n.length;d+=ae){let k=n.slice(d,d+ae).map(M=>`'${M}'`).join(",");for(let M of await c.all(_,[["$select",j],["$filter",`Microsoft.Dynamics.CRM.In(PropertyName='${N}',PropertyValues=[${k}])`]]))O.set(String(M[N]).toLowerCase(),M)}for(let d of n){let k=O.get(d);if(!k){i(e,d,w(e,d,"not-found",{source:_}));continue}let M=g?r(k,g):null,v=g&&M!==null&&M!=="none"?await S(M):{};i(e,d,w(e,d,"resolved",{name:ge(k,l),source:_,type_name:z.get(e)||ce.get(e)||m.LogicalName,...v}))}}return B([...u.values()],e=>[e.key[0],e.key[1]]).map(e=>e.row)}function be(t){let o;t==="-"?o=U(0,"utf8"):t.toLowerCase().endsWith(".gz")?o=le(U(t)).toString("utf8"):o=U(t,"utf8");let s="\\n\\r\\x0b\\x0c\\x1c\\x1d\\x1e\\x85\u2028\u2029",c=o.split(new RegExp(`\\r\\n|[${s}]`));return c.length&&c[c.length-1]===""&&c.pop(),c}async function xe(t){let o=t.args,s=C(o.file),c=C(o.type),u=C(o.component);if(!s&&!(c&&u))throw new A("give <type> <component>, or --file with components to name");let i=await Q(t);Y(t,i,"GET","EntityDefinitions",null);let p=new Map;if(s)for(let[S,h]of de(be(s)))p.set(S,h);if(c&&u){let{componentId:S,componentType:h}=await import("./lifecycle-OJRM7K2I.js"),$=await h(t,i,c),x=await S(t,i,$,u,c);p.has(L($,x))||p.set(L($,x),{key:[$,x],parent:null})}let f=await we(t,i,p),b={};for(let S of ue)b[S]=f.filter(h=>h.name_status===S).length;let y=C(o.save);if(y){let{save:S}=await import("./dependency-U6OQA5PS.js");await S(y,f),await t.emit({saved:y,components:f.length,...b})}else await t.emit(f);(b["not-found"]||b["type-unsupported"])&&T(`${b["not-found"]} not found, ${b["type-unsupported"]} of a type ppdo-cli can't name`)}export{ue as a,ce as b,ae as c,pe as d,I as e,de as f,re as g,ge as h,w as i,we as j,be as k,xe as l};
@@ -1,2 +0,0 @@
1
- import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
2
- import{C as h,D as S,G as x,I,K as P,M as E,N as k,O as N,Q as D,a as T,g as R,k as $,m as c,o as l,p as b,w as v}from"./chunk-TXVNEV3M.js";import{a as q}from"./chunk-UCTMKA2J.js";import{b as C}from"./chunk-WNQERCOO.js";import{y as B}from"./chunk-BALEFXOL.js";import{b as M}from"./chunk-5SBBTR3Y.js";import{e as H}from"./chunk-S4KF5Z3S.js";import{a as j,b as w}from"./chunk-WXOTXJNG.js";var J=t=>typeof t=="string"?t:null,L=new RegExp("\\r\\n|[\\n\\r\\x0b\\x0c\\x1c\\x1d\\x1e\\x85\u2028\u2029]");function U(t){let e=t.split(L);return e.length&&e[e.length-1]===""&&e.pop(),e}async function tt(t){let e=t.args,a=T(J(e.entityset),"entity set name"),r=await h(t),o=x(e.formatted?`odata.include-annotations="${$}"`:null),s=v(e);if(e.fetchxml){if(["select","filter","expand","orderby","top","apply","count"].some(u=>c(e[u])))throw new w("--fetchxml can't be combined with OData options");let{run:d}=await import("./fetchxml-FWUQZP4M.js"),y=await d(t,r,a,String(e.fetchxml),!!e.formatted,s);await t.emitStream(y);return}let i=[];for(let[d,y]of[["select","$select"],["filter","$filter"],["expand","$expand"],["orderby","$orderby"],["apply","$apply"]]){let u=e[d];c(u)&&i.push([y,String(u)])}c(e.top)&&i.push(["$top",String(e.top)]),e.count&&i.push(["$count","true"]),M(t,r,"GET",a,null);let[n,m]=await I(t,r,a,i,o,s);if(e.count){let d=l(m,"@odata.count");if(await t.format()==="json"){await t.emit({count:d,value:n});return}H(`count: ${d===null?"None":String(d)}`)}await t.emit(n)}async function et(t){let e=t.args,a=await h(t),r=[];c(e.select)&&r.push(["$select",String(e.select)]),c(e.expand)&&r.push(["$expand",String(e.expand)]);let o=x(e.formatted?`odata.include-annotations="${$}"`:null),s=await S(t,a,"GET",R(String(e.entityset),String(e.key)),{params:r,headers:o});await t.emit(s.json())}async function nt(t){let e=t.args,a=T(J(e.entityset),"entity set name"),r=await k(e.body,!0),o=await h(t),s=e.return&&c(e.select)?[["$select",String(e.select)]]:null,i={...x(e.return?"return=representation":null),...E(t,o)},n=await S(t,o,"POST",a,{params:s,headers:i,body:r});e.return&&n.body.length?await t.emit(n.json()):await t.emit({id:P(n),entity_id:n.header("odata-entityid")})}async function st(t){let e=t.args,a=R(String(e.entityset),String(e.key)),r=await k(e.body,!0),o=await h(t),s={...x(e.return?"return=representation":null),...E(t,o)};c(e.ifMatch)?s["If-Match"]=String(e.ifMatch):e.upsert||(s["If-Match"]="*");let i=await S(t,o,"PATCH",a,{headers:s,body:r});e.return&&i.body.length?await t.emit(i.json()):await t.emit({id:P(i),status:i.status})}async function at(t){let e=t.args,a=R(String(e.entityset),String(e.key)),r=await h(t),o={...c(e.ifMatch)?{"If-Match":String(e.ifMatch)}:{},...E(t,r)},s=await S(t,r,"DELETE",a,{headers:Object.keys(o).length?o:null});await t.emit({deleted:a,status:s.status})}function _(t){return t==null?"None":t===!0?"True":t===!1?"False":typeof t=="string"?t:JSON.stringify(t)}function G(t){let e=N(B(t==="-"?t:"@"+t).toString("utf8")),a=[];if(U(e).forEach((r,o)=>{let s=o+1;if(!r.trim())return;let i;try{i=q(r)}catch(d){throw new w(`line ${s}: not JSON (${d.message})`)}let n=b(i),m=_(n.method??"").toUpperCase();if(!["GET","POST","PATCH","PUT","DELETE"].includes(m)||!c(n.path))throw new w(`line ${s}: needs a method (GET/POST/PATCH/PUT/DELETE) and a path`);if(String(n.path).includes("://"))throw new w(`line ${s}: use a path relative to the Web API, not a full URL`);a.push({method:m,path:n.path,body:l(n,"body"),headers:l(n,"headers")})}),!a.length)throw new w("no requests in the input");return a}async function rt(t){let e=t.args,a=G(String(e.file)),r=await h(t),o=E(t,r);Object.keys(o).length&&(a=a.map(n=>({...n,headers:{...b(n.headers),...o}})));let s=[];for await(let[n,m,d]of D(t,r,a,!!e.changeset,!!e.continueOnError))m.forEach((y,u)=>{let g=d[u],p={index:n+u,method:y.method,path:y.path,status:l(g,"status")},A=b(g.headers);c(A["odata-entityid"])&&(p.entity_id=A["odata-entityid"]);let f=l(g,"body");if(c(g.rolled_back)&&(p.rolled_back=!0),typeof f=="object"&&f!==null&&!Array.isArray(f)&&"error"in f){let O=b(f.error);p.error=C(l(O,"message"))??null,p.code=l(O,"code")}else f!==null&&(p.body=f);c(g.error)&&(p.error=g.error),s.push(p)});await t.emit(s);let i=s.filter(n=>!c(n.status)||n.status>=400);if(i.length)throw new j(`${i.length} of ${s.length} batch requests failed`,{service:"dataverse",hint:"see each result's status and error"})}export{U as a,tt as b,et as c,nt as d,st as e,at as f,G as g,rt as h};
@@ -1,2 +0,0 @@
1
- import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
2
- import{c as tt,i as J,j as et}from"./chunk-RC5VPVGC.js";import{B as Q,C as P,D as y,E as b,F as A,G,H as bt,I as B,O as vt,P as D,a as dt,b as pt,c as mt,d as ft,e as q,f as Z,h as Y,k as X,l as I,m as C,n as T,o as i,p as O,q as R,r as gt,s as wt,t as ht,u as yt,w as N}from"./chunk-TXVNEV3M.js";import{a as ut}from"./chunk-UCTMKA2J.js";import{x as ct,y as lt}from"./chunk-BALEFXOL.js";import{b as z}from"./chunk-5SBBTR3Y.js";import{e as k}from"./chunk-S4KF5Z3S.js";import{a as F,b as j,d as M,f as at}from"./chunk-WXOTXJNG.js";import{randomUUID as Bt}from"node:crypto";import{mkdtempSync as Lt,readdirSync as Et,readFileSync as xt,rmSync as Ut,statSync as Rt,mkdirSync as Ft,writeFileSync as Mt}from"node:fs";import{tmpdir as zt}from"node:os";import{basename as Xt,dirname as jt,extname as Gt,join as L,normalize as Jt}from"node:path";var kt="uniquename,friendlyname,version,ismanaged,installedon,modifiedon,solutionid",Wt={import:0,uninstall:1,export:2,publish:3,"publish-all":4},Ct="publisherid($select=uniquename,customizationprefix)";function w(t){return t==null?"None":t===!0?"True":t===!1?"False":String(t)}function Pt(t){let e=O(i(t,"publisherid"));return{uniquename:i(t,"uniquename"),name:i(t,"friendlyname"),version:i(t,"version"),managed:i(t,"ismanaged"),publisher:i(e,"uniquename"),prefix:i(e,"customizationprefix"),installed:i(t,"installedon"),modified:i(t,"modifiedon"),id:i(t,"solutionid")}}async function V(t,e,n){let s=await y(t,e,"GET","solutions",{params:[["$select",kt],["$expand",Ct],["$filter",`uniquename eq ${q(n)}`]]}),o=R(b(s).value);if(!o.length)throw new M(`no solution named '${n}'`,{service:"dataverse",hint:"run: ppdo-cli dv solution list"});return o[0]}function Se(t){return t.split(",").map(e=>Z(e)).filter(e=>e)}async function Ee(t,e,n){let s=await y(t,e,"GET",`EntityDefinitions(LogicalName=${q(n)})`,{params:[["$select","ObjectTypeCode"]]});return _t(b(s),"ObjectTypeCode")}function _t(t,e){if(!(e in t))throw new Error(`KeyError: '${e}'`);return t[e]}async function xe(t,e,n,s){let o=[];for(let c of n)o.push((await V(t,e,c)).solutionid);let r=o.map(c=>`_solutionid_value eq ${c}`).join(" or "),l=[["$select","objectid"],["$filter",`(${r}) and componenttype eq ${s}`]],[a]=await B(t,e,"solutioncomponents",l,null,null);return yt(a.map(c=>c.objectid))}async function je(t){let e=t.args,n=await P(t),s=["isvisible eq true"];e.unmanaged&&s.push("ismanaged eq false"),e.managed&&s.push("ismanaged eq true"),e.publisher&&s.push(`publisherid/customizationprefix eq ${q(String(e.publisher))}`);let o=[["$select",kt],["$expand",Ct],["$filter",s.join(" and ")],["$orderby","uniquename"]];z(t,n,"GET","solutions",null);let[r]=await B(t,n,"solutions",o,null,N(e),"solutions");await t.emit(r.map(Pt))}async function ke(t){let e=await P(t);await t.emit(Pt(await V(t,e,String(t.args.uniquename))))}async function Ce(t){let e=t.args,n=await P(t),s=await V(t,n,String(e.uniquename)),o=`_solutionid_value eq ${w(s.solutionid)}`;typeof e.type=="number"&&(o+=` and componenttype eq ${e.type}`);let r=[["$select","componenttype,objectid,rootcomponentbehavior,ismetadata"],["$filter",o]],l=G(`odata.include-annotations="${X}"`),[a]=await B(t,n,"solutioncomponents",r,l,N(e),"components");await t.emit(a.map(c=>({type:i(c,"componenttype"),type_name:i(c,`componenttype${I}`),object_id:i(c,"objectid"),behavior:T(i(c,`rootcomponentbehavior${I}`),i(c,"rootcomponentbehavior"))})))}var Vt=["dependencytype","requiredcomponenttype","requiredcomponentobjectid","requiredcomponentparentid","dependentcomponenttype","dependentcomponentobjectid","dependentcomponentparentid"];async function Pe(t){let e=t.args,n=await P(t),s=e.forUninstall?"RetrieveDependenciesForUninstall":"RetrieveMissingDependencies",[o,r]=Y(s,[["SolutionUniqueName",String(e.uniquename)]],new Set(["SolutionUniqueName"])),l=G(`odata.include-annotations="${X}"`),a=b(await y(t,n,"GET",o,{params:r,headers:l})),c=R(T(i(a,"value"),T(i(O(i(a,"EntityCollection")),"Entities"),[]))),u=[];for(let d of c){let p={};for(let m of Vt)i(d,m)!==null&&(p[m]=d[m]),C(i(d,`${m}${I}`))&&(p[`${m}_name`]=d[`${m}${I}`]);u.push(C(p)?p:d)}await t.emit(u)}async function _e(t){let e=t.args,n=D(e.save),s=D(e.unpack),o=String(e.uniquename);if(!(n||s))throw new j("pass --save <file.zip>, --unpack <folder>, or both");if(e.both&&e.managed)throw new j("--both already exports managed");if(e.allowDelete&&!s)throw new j("--allow-delete is for --unpack");let r=await P(t);await V(t,r,o);let l=Lt(L(zt(),"ppdevops-export-"));try{let a=n?Jt(n):L(l,`${o}.zip`),c=Xt(a,Gt(a)),u=L(jt(a),`${c}_managed.zip`),d=e.both?[[!1,a],[!0,u]]:[[!!e.managed,a]],p=[];for(let[v,f]of d)p.push(await Ht(t,r,o,v,f));if(!n)for(let v of p)delete v.saved;if(!s){await t.emit(p.length===1?p[0]:{solution:o,exports:p});return}let m=e.both?"Both":e.managed?"Managed":"Unmanaged",g=await Kt(a,s,m,!!e.allowDelete),x={};for(let[v,f]of Object.entries(g))x[v]=Array.isArray(f)?f.length:f;await t.emit({solution:o,exports:p,unpacked:s,package_type:m,deleted_allowed:!!e.allowDelete,files:x})}finally{Ut(l,{recursive:!0,force:!0})}}async function Ht(t,e,n,s,o){let r=b(await y(t,e,"POST","ExportSolutionAsync",{body:A({SolutionName:n,Managed:s})})),l=i(r,"AsyncOperationId"),a=i(r,"ExportJobId");k(`exporting ${n} (${s?"managed":"unmanaged"}), job ${w(l)}`);let c=await J(t,e,l);et(c);let u=b(await y(t,e,"POST","DownloadSolutionExportData",{body:A({ExportJobId:a})})),d=Buffer.from(String(_t(u,"ExportSolutionFile")),"base64");return Ft(jt(o),{recursive:!0}),Mt(o,d),{solution:n,managed:s,saved:o,bytes:d.length,job_id:l}}async function Kt(t,e,n,s){let{PackError:o}=await import("./components-LRHXR5HR.js"),r=await import("./plan-ALLKT2QZ.js"),l=await import("./unpack-HUH7OJMP.js");k(`unpacking into ${e} (${n})`);let a=new r.Snapshot(e),c;try{[c]=l.buildPlan(t,n)}catch(u){throw u instanceof o||u instanceof Error&&!u.code&&!(u instanceof F)?new j(`can't unpack the export: ${u.message}`):u}return await r.apply(c,e,{delete:s,snapshot:a})}function Zt(t,e){let n=new Set;for(let l of e){let a=O(i(l,"Attributes")),c=R(i(a,"Keys")),u=R(i(a,"Values")),d=new Map;c.slice(0,u.length).forEach((p,m)=>d.set(p,u[m]));for(let p of["schemaname","connectionreferencelogicalname"])C(d.get(p))&&n.add(w(d.get(p)).toLowerCase())}let s=[],o=[],r=e.length>0;for(let l of R(i(t,"EnvironmentVariables"))){let a=i(l,"SchemaName");if(r&&C(a)&&!n.has(String(a).toLowerCase())){o.push(`environment variable ${a}`);continue}s.push({"@odata.type":"Microsoft.Dynamics.CRM.environmentvariablevalue",schemaname:a,value:i(l,"Value")})}for(let l of R(i(t,"ConnectionReferences"))){let a=i(l,"LogicalName");if(r&&C(a)&&!n.has(String(a).toLowerCase())){o.push(`connection reference ${a}`);continue}s.push({"@odata.type":"Microsoft.Dynamics.CRM.connectionreference",connectionreferencelogicalname:a,connectionid:i(l,"ConnectionId"),connectorid:i(l,"ConnectorId")})}return[s,o]}function qt(t,e){let n;try{n=Et(t,{withFileTypes:!0})}catch{return}let s=[];for(let o of n)o.isDirectory()?s.push(o.name):e.push(L(t,o.name));for(let o of s)qt(L(t,o),e)}function Yt(t){let e=0;try{e=Et(t).filter(l=>l.toLowerCase().endsWith(".cdsproj")).length}catch{e=0}if(e!==1)throw new j("name the solution .zip to import",{hint:"without a file, the folder must hold one .cdsproj"});let n=[];qt(t,n);let s=n.filter(l=>l.toLowerCase().endsWith(".zip"));if(!s.length)throw new j(`no .zip under ${t}`,{hint:"build the project first: ppdo-cli dv solution pack"});let o=s[0],r=Rt(o).mtimeMs;for(let l of s.slice(1)){let a=Rt(l).mtimeMs;a>r&&([o,r]=[l,a])}return o}function Tt(t){let e=null;for(let n of t)if(typeof n=="string")e=(e??"")+n;else if(n&&typeof n=="object"&&"value"in n&&!("kids"in n))e=(e??"")+String(n.value);else break;return e}async function $t(t){let{unzipSync:e}=await import("./esm-Z4QMBGAD.js"),n=await import("./xmldoc-B2HUNTVK.js"),s=()=>new j(`${t} is not a solution .zip`),o;try{o=e(new Uint8Array(xt(t)),{filter:u=>u.name.toLowerCase()==="solution.xml"})}catch(u){throw u.code?u:s()}let r=Object.keys(o)[0];if(r===void 0)throw s();let l;try{l=n.parseElement(o[r])}catch{throw s()}let a=l.element("SolutionManifest");if(!a)throw s();let c=u=>{let d=a.element(u);return d?Tt(d.kids)??"":null};return[c("UniqueName"),c("Version")]}function Qt(t,e){let n=r=>r.split(".").map(l=>{if(!/^\s*[+-]?\d+\s*$/.test(l))throw new Error(`ValueError: invalid literal for int() with base 10: '${l}'`);return parseInt(l,10)}),s=n(t),o=n(e);for(let r=0;r<Math.min(s.length,o.length);r++)if(s[r]!==o[r])return s[r]>o[r];return s.length>=o.length}var te="workflow,dialog,business-rule,action,bpf";async function ee(t,e,n){let s={};for(let o of R(i(O(n),"Workflows"))){let r=i(o,"UserEmail"),l=i(o,"WorkflowId"),a=R(i(b(await y(t,e,"GET","systemusers",{params:[["$select","systemuserid"],["$filter",`internalemailaddress eq ${q(w(r))}`]]})),"value"));if(!a.length)throw new M(`no user with the email ${w(r)}, named for flow ${w(T(i(o,"Name"),l))}`,{service:"dataverse"});s[mt(w(l),"{}").toLowerCase()]=a[0].systemuserid}return s}async function ne(t,e,n,s,o){let r=await import("./process-WS76WV3T.js"),l=await import("./plugins-SBMDFXVA.js"),a=[[te,s.activateWorkflows],["flow",s.activateFlows]].filter(([,f])=>f).map(([f])=>f),c={solution:n,category:a.join(",")},[u,d]=await e.lookups(async()=>[a.length?await r.rows(t,e,c):[],s.activatePlugins?await l.stepRows(t,e,c):[]]),p=new Set(u.map(f=>String(f.workflowid).toLowerCase()));for(let f of ht(Object.keys(o).filter($=>!p.has($)),$=>$))k(`warning: flow ${f} is in the settings but not in the solution; skipped`);let[m,g]=await r.applyState(t,e,u,!0,o),[x,v]=await l.applyState(t,e,d,!0);return[[...m,...x],{...g,...v}]}var oe={ENOENT:"No such file or directory",EACCES:"Permission denied",EPERM:"Operation not permitted",EISDIR:"Is a directory"};async function qe(t){let e=t.args;Q(e,{holding:"--holding",upgrade:"--upgrade"},!1,"dv solution import");let n=D(e.file),s=D(e.path);if(n&&s)throw new j("give the file once, as an argument or with --path");if(!e.async&&(e.activatePlugins||e.activateWorkflows||e.activateFlows||e.publishChanges))throw new j("the --activate options and --publish-changes run after the import, so they need --async");let o=n||s;o||(o=Yt(process.cwd()),k(`importing ${o}`));let r;try{r=xt(o).toString("base64")}catch(h){let S=h;throw new j(`cannot read ${o}: ${oe[S.code??""]??S.message}`)}let l=D(e.settings),a=null;if(l)try{a=ut(vt(lt(l).toString("utf8")))}catch(h){throw h instanceof SyntaxError&&(h.name="JSONDecodeError"),h}let c=await P(t),u=e.upgrade?"StageAndUpgradeAsync":"ImportSolutionAsync";if(z(t,c,"POST",u,null),e.skipLowerVersion){let[h,S]=await $t(o),K=await c.lookups(async()=>R(i(b(await y(t,c,"GET","solutions",{params:[["$select","version"],["$filter",`uniquename eq ${q(w(h))}`]]})),"value")));if(K.length&&Qt(K[0].version,w(S))){let rt=K[0].version;k(`${w(h)} ${rt} is installed, so ${w(S)} was not imported`),await t.emit({solution:h,version:S,installed_version:rt,status:"skipped"});return}}let[d,p]=await c.lookups(async()=>{let h=e.activateFlows?await ee(t,c,a):{},S=b(await y(t,c,"POST","StageSolution",{body:A({CustomizationFile:r})}));return[h,S]},["StageSolution"]),m=O(i(p,"StageSolutionResults")),g=R(i(m,"MissingDependencies"));if(g.length&&e.skipDependencyCheck)k(`warning: staging found ${g.length} missing dependencies; importing anyway`);else if(g.length)throw await t.emit({stage:"failed",missing_dependencies:g}),new at(`${g.length} missing dependencies; nothing was imported`,{service:"dataverse",hint:"install the required solutions first, or check the export"});let x=[];if(C(a)){let h;[x,h]=Zt(a,R(i(m,"SolutionComponentsDetails")));for(let S of h)k(`warning: ${S} is in the settings but not in the solution; skipped`)}let v=Bt(),f={OverwriteUnmanagedCustomizations:!!e.overwriteUnmanaged,PublishWorkflows:!!e.activatePlugins,ImportJobId:v};g.length?f.CustomizationFile=r:f.SolutionParameters={StageSolutionUploadId:i(m,"StageSolutionUploadId")},e.holding&&(f.HoldingSolution=!0),e.skipDependencyCheck&&(f.SkipProductUpdateDependencies=!0),x.length&&(f.ComponentParameters=x);let $=b(await y(t,c,"POST",u,{body:A(f)})),_=i($,"AsyncOperationId"),nt=O(i(m,"SolutionDetails")),H=i(nt,"SolutionUniqueName"),ot=i(nt,"SolutionVersion");C(H)||([H,ot]=await $t(o));let E={solution:H,version:ot,mode:e.upgrade?"upgrade":e.holding?"holding":"update",job_id:_,import_job_id:v,settings_applied:x.length};if(!e.async){await t.emit({...E,status:"started",hint:`ppdo-cli dv job wait ${w(_)}`});return}k(`importing ${w(E.solution)} ${w(E.version)}, job ${w(_)}`);let U=await J(t,c,_);if(E.status=i(U,"status"),E.message=i(U,"message"),i(U,"statuscode")!==tt&&(await t.emit(E),et(U,`run: ppdo-cli dv solution import-results ${v}`)),e.publishChanges){let h=b(await y(t,c,"POST","PublishAllXmlAsync",{body:Buffer.from("{}")}));k(`publishing customizations, job ${w(i(h,"AsyncOperationId"))}`);let S=await J(t,c,i(h,"AsyncOperationId"));if(E.published=i(S,"statuscode")===tt,!E.published)throw await t.emit(E),new F(`the import succeeded, but publishing failed: ${w(i(S,"message"))}`,{service:"dataverse"})}let Nt=w(E.solution)+(e.holding?"_Upgrade":""),[st,it]=await ne(t,c,Nt,e,d);if(st.length&&(E.activated=st),await t.emit(E),C(it))throw new F(`the import succeeded, but ${Object.keys(it).length} components could not be turned on`,{service:"dataverse",hint:"each one's error is under activated"})}var It="urn:schemas-microsoft-com:office:spreadsheet",St={"Date/Time":"time",ItemType:"type",Name:"name","Localized Name":"display_name",Status:"status",ErrorCode:"error_code",ErrorText:"error"};function Ot(t,e){for(let n=t;n;n=n.parent){let s=n.scope?.get(e);if(s!==void 0)return s;let o=n.attrs.find(([r])=>r===(e?`xmlns:${e}`:"xmlns"));if(o)return o[1]}}function W(t,e){if(t.local!==e)return!1;let n=t.name.indexOf(":");return(t.ns||Ot(t,n<0?"":t.name.slice(0,n)))===It}function At(t,e){for(let[n,s]of t.attrs){let o=n.indexOf(":");if(!(o<0||n.slice(o+1)!==e)&&Ot(t,n.slice(0,o))===It)return s}return null}function*Dt(t,e){W(t,e)&&(yield t);for(let n of t.descendants())W(n,e)&&(yield n)}function se(t){let e=[];for(let n of Dt(t,"Row")){let s=[];for(let o of n.elements().filter(r=>W(r,"Cell"))){let r=At(o,"Index");if(r)for(let a=parseInt(r,10)-1-s.length;a>0;a--)s.push("");let l=o.elements().find(a=>W(a,"Data"));s.push(l?Z(Tt(l.kids)??""):"")}e.push(s)}return e}async function ie(t){let e=await import("./xmldoc-B2HUNTVK.js"),n;try{n=e.parseElement(t)}catch(u){throw new Error(`ParseError: ${u.message}`)}let s=new Map;for(let u of Dt(n,"Worksheet"))s.set(At(u,"Name"),se(u));let o={},r="solution";for(let u of s.get("Solution")??[])if(u.length===1&&u[0])r=u[0].toLowerCase();else if(u.length>=2&&u[0]){let d=u[0].toLowerCase().split(" ").join("_");r==="solution"&&["name","display_name","version","package_type"].includes(d)?o[d]=u[1]:r==="publisher"&&d==="name"&&(o.publisher=u[1])}let l=s.get("Components")??[],a=l[0]??[],c=[];for(let u of l.slice(1)){let d={};a.slice(0,u.length).forEach((p,m)=>{let g=u[m];p in St&&g&&(d[St[p]]=g)}),(d.type||d.name||d.error)&&c.push(d)}return[o,c]}async function re(t,e,n){let s=R(b(await y(t,e,"GET","importjobs",{params:[["$select","importjobid"],["$filter",`solutionname eq ${q(n)}`],["$orderby","createdon desc"],["$top","1"]]})).value);if(!s.length)throw new M(`no import job for solution '${n}'`,{service:"dataverse",hint:"run: ppdo-cli dv solution history --operation import"});return s[0].importjobid}function ae(t){let e=t*10,n=Math.round(e);return(Math.abs(e%1)===.5?n%2===0?n:n-1:n)/10}async function Te(t){let e=t.args,n=String(e.target),s=await P(t),o=pt(n)?ft(n):await re(t,s,n),r=b(await y(t,s,"GET",`importjobs(${o})`,{params:[["$select","solutionname,progress,createdon,startedon,completedon"]]})),[l,a]=Y("RetrieveFormattedImportJobResults",[["ImportJobId",o]]),c=b(await y(t,s,"GET",l,{params:a})),[u,d]=await ie(String(T(i(c,"FormattedResults"),""))),p=d.filter($=>$.status==="Failure"||C($.error)),m={};for(let $ of d){let _=$.status??"";m[_]=(m[_]??0)+1}let g=i(r,"progress"),x=p.length?"failed":g!==null&&typeof g=="number"&&g>=100?"succeeded":"incomplete",v={};for(let[$,_]of Object.entries(m))$&&(v[$]=_);let f={import_job_id:o,solution:T(i(u,"name"),i(r,"solutionname")),version:i(u,"version"),package:i(u,"package_type"),publisher:i(u,"publisher"),result:x,progress:typeof g=="number"?ae(g):null,started:i(r,"startedon"),completed:i(r,"completedon"),counts:v,failed:p};e.components&&(f.components=d),await t.emit(gt(f))}async function ce(t,e,n,s,o){let r=[],l={...n,Prefer:[n.Prefer,"odata.maxpagesize=500"].filter(a=>a).join(", ")};for await(let a of bt(t,"msdyn_solutionhistories",e,l))for(let c of R(b(a).value)){if(String(T(i(c,"msdyn_starttime"),""))<s)return r;if(o!==null&&r.length>=o)return k(`showing the first ${o} operations; pass --limit n or --all for more`),r;r.push(c)}return r}async function Ie(t){let e=t.args,n=await P(t),s=[];e.uniquename&&s.push(`msdyn_name eq ${q(String(e.uniquename))}`),e.state&&s.push(`msdyn_result eq ${e.state==="failed"?"false":"true"}`),e.operation&&s.push(`msdyn_operation eq ${Wt[String(e.operation)]}`);let o=[["$orderby","msdyn_starttime desc"]];s.length&&o.push(["$filter",s.join(" and ")]),z(t,n,"GET","msdyn_solutionhistories",null);let r=G(`odata.include-annotations="${X}"`),l;e.since?l=await ce(n,o,r,ct(String(e.since)),N(e)):[l]=await B(t,n,"msdyn_solutionhistories",o,r,N(e),"operations");let a=[];for(let c of l){let u={solution:i(c,"msdyn_name"),version:i(c,"msdyn_solutionversion"),operation:i(c,`msdyn_operation${I}`),suboperation:i(c,`msdyn_suboperation${I}`),result:i(c,"msdyn_result")===!0?"succeeded":"failed",started:i(c,"msdyn_starttime"),ended:i(c,"msdyn_endtime"),seconds:i(c,"msdyn_totaltime"),managed:i(c,"msdyn_ismanaged"),publisher:i(c,"msdyn_publishername"),id:i(c,"msdyn_solutionhistoryid")};i(c,"msdyn_result")!==!0&&(u.error_code=i(c,"msdyn_errorcode"),u.error=i(c,"msdyn_exceptionmessage")),u.suboperation==="None"&&delete u.suboperation,a.push(wt(u))}await t.emit(a)}function le(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}async function Oe(t){let e=t.args;Q(e,{all:"--all",entity:"--entity"},!0,"dv solution publish");let n=await P(t);if(e.all){await y(t,n,"POST","PublishAllXml",{body:Buffer.from("{}")}),await t.emit({published:"all"});return}let s=e.entity.map(r=>dt(r,"table logical name").toLowerCase()),o="<importexportxml><entities>"+s.map(r=>`<entity>${le(r)}</entity>`).join("")+"</entities></importexportxml>";await y(t,n,"POST","PublishXml",{body:A({ParameterXml:o})}),await t.emit({published:s})}export{Wt as a,Pt as b,V as c,Se as d,Ee as e,xe as f,je as g,ke as h,Ce as i,Pe as j,_e as k,Zt as l,Yt as m,$t as n,Qt as o,qe as p,ie as q,Te as r,Ie as s,Oe as t};
@@ -1,2 +0,0 @@
1
- import { createRequire as __cr } from 'node:module'; const require = __cr(import.meta.url);
2
- import{B as W,C as R,D as f,E as b,F as U,I as M,d as G,h as x,m as $,n as v,o as s,p as I,q as _,r as D,t as L,u as O,w as z}from"./chunk-TXVNEV3M.js";import{b as k}from"./chunk-5SBBTR3Y.js";import{e as T}from"./chunk-S4KF5Z3S.js";import{b as N}from"./chunk-WXOTXJNG.js";var Y=new Map([[1,"Entity"],[2,"Attribute"],[9,"OptionSet"],[10,"EntityRelationship"]]),F=new Map([[1,"entity"],[2,"attribute"],[9,"optionset"],[10,"entityrelationship"]]),V=new Map([[20,"role"],[26,"savedquery"],[29,"workflow"],[36,"template"],[60,"systemform"],[61,"webresource"],[62,"sitemap"],[63,"connectionrole"],[66,"customcontrol"],[70,"fieldsecurityprofile"],[80,"appmodule"],[91,"pluginassembly"],[92,"sdkmessageprocessingstep"],[95,"serviceendpoint"],[300,"canvasapp"],[380,"environmentvariabledefinition"],[381,"environmentvariablevalue"]]),Q=new Map([[1,"table"],[2,"column"],[3,"relationship"],[9,"choice"],[10,"relationship"],[20,"role"],[26,"view"],[29,"process"],[31,"report"],[36,"email-template"],[50,"ribbon"],[59,"chart"],[60,"form"],[61,"webresource"],[62,"sitemap"],[66,"custom-control"],[80,"app"],[91,"assembly"],[92,"step"],[300,"canvas-app"],[380,"envvar"],[381,"envvar-value"]]),J=new Map([[0,"none"],[1,"solution-internal"],[2,"published"],[4,"unpublished"]]),X=new Map([[61,["webresourceset","webresourceid",["name","displayname","content","description"]]],[60,["systemforms","formid",["name","formxml","description"]]],[26,["savedqueries","savedqueryid",["name","fetchxml","layoutxml","description"]]],[80,["appmodules","appmoduleid",["name","descriptor","description"]]]]),P=new Map,q=new Map;async function E(e,n){let{componentId:t,componentType:a}=await import("./lifecycle-OJRM7K2I.js"),o=e.args,c=await a(e,n,String(o.type));return[c,await t(e,n,c,String(o.component),String(o.type))]}async function Z(e,n,t){let a=Y.get(t);if(a)return a;let o=await A(e,n,t);if(!o)throw new N(`component type ${t} has no layers ppdo-cli can read`);let c=b(await f(e,n,"GET",`EntityDefinitions(LogicalName='${o}')`,{params:[["$select","SchemaName"]]}));return v(s(c,"SchemaName"),o)}async function A(e,n,t){let a=V.get(t);if(a)return a;if(t<1e4)return null;if(!q.has(t)){let o=_(b(await f(e,n,"GET","EntityDefinitions",{params:[["$select","LogicalName"],["$filter",`ObjectTypeCode eq ${t}`]]})).value);q.set(t,o.length?o[0].LogicalName:null)}return q.get(t)??null}async function ee(e,n,t){if(!t)return null;if(!P.has(t)){let a=b(await f(e,n,"GET",`EntityDefinitions(LogicalName='${t}')`,{params:[["$select","EntitySetName,PrimaryNameAttribute"]]})),o=s(a,"EntitySetName"),c=s(a,"PrimaryNameAttribute");P.set(t,$(o)&&$(c)?[o,c]:null)}return P.get(t)??null}async function C(e,n,t){return Q.get(t)||await A(e,n,t)||String(t)}var ne=new Set(["componentstate","overwritetime","solutionid","supportingsolutionid","versionnumber","ismanaged","componentidunique","modifiedon","modifiedby","createdon","createdby","organizationid"]);function te(e,n){let t;try{t=_(s(I(JSON.parse(e||"{}")),"Attributes"))}catch{return null}let a={};for(let o of t){let c=s(o,"Key");if(!$(c))continue;let l=String(c).toLowerCase();ne.has(l)||l.endsWith("idunique")||(a[c]=s(o,"Value"))}return n?a:L(Object.keys(a),o=>o)}async function re(e){let n=await R(e);k(e,n,"GET","msdyn_componentlayers",null);let[t,a]=await E(e,n),o=await Z(e,n,t),[c]=await M(e,n,"msdyn_componentlayers",[["$select","msdyn_order,msdyn_solutionname,msdyn_publishername,msdyn_overwritetime,msdyn_changes"],["$filter",`msdyn_componentid eq '${a}' and msdyn_solutioncomponentname eq '${o}'`]],null,null);c.length||T(`no layers for ${await C(e,n,t)} ${a}: check the type and id`);let l=!!e.args.values,p=[];L(c,i=>v(s(i,"msdyn_order"),0)).forEach((i,r)=>{let u=s(i,"msdyn_overwritetime"),m=te(s(i,"msdyn_changes"),l),g={order:s(i,"msdyn_order"),solution:s(i,"msdyn_solutionname"),publisher:s(i,"msdyn_publishername"),updated:String(u||"").startsWith("1900-")?null:u};r===0&&!l?g.base=`${(Array.isArray(m)?m:[]).length} properties`:g.changes=m,p.push(D(g))}),await e.emit(p)}async function oe(e,n,t){let{find:a}=await import("./solution-3WUUDYF3.js"),o=new Map,c=(await a(e,n,"Default")).solutionid,l=O(t.map(([,i])=>i));for(let i=0;i<l.length;i+=25){let r=l.slice(i,i+25).map(m=>`msdyn_objectid eq '${m}'`).join(" or "),[u]=await M(e,n,"msdyn_solutioncomponentsummaries",[["$select","msdyn_objectid,msdyn_name,msdyn_displayname"],["$filter",`msdyn_solutionid eq ${c} and (${r})`]],null,null);for(let m of u)o.set(String(m.msdyn_objectid).toLowerCase(),v(s(m,"msdyn_name"),s(m,"msdyn_displayname")))}let p=async(i,r)=>b(await f(e,n,"GET",i,{params:[["$select",r]]}));for(let[i,r,u]of t){if(r===null)continue;let m=r.toLowerCase();if(!o.has(m))try{if(i===1)o.set(m,s(await p(`EntityDefinitions(${r})`,"LogicalName"),"LogicalName"));else if(i===3||i===10)o.set(m,s(await p(`RelationshipDefinitions(${r})`,"SchemaName"),"SchemaName"));else if(i===2&&u&&!u.startsWith("00000000")){let g=s(await p(`EntityDefinitions(${u})`,"LogicalName"),"LogicalName"),y=s(await p(`EntityDefinitions(${u})/Attributes(${r})`,"LogicalName"),"LogicalName");o.set(m,`${g??"None"}.${y??"None"}`)}else if(i!==null){let g=await ee(e,n,await A(e,n,i));if(g){let[y,w]=g;o.set(m,s(await p(`${y}(${G(r)})`,w),w))}}}catch{continue}}return o}async function le(e){let n=e.args;W(n,{dependents:"--dependents",blockingDelete:"--blocking-delete"},!1,"dv component dependencies");let t=await R(e),[a,o]=await E(e,t),c=n.dependents?"RetrieveDependentComponents":n.blockingDelete?"RetrieveDependenciesForDelete":"RetrieveRequiredComponents",[l,p]=x(c,[["ObjectId",o],["ComponentType",String(a)]]),i=_(b(await f(e,t,"GET",l,{params:p})).value),r=c==="RetrieveRequiredComponents"?"required":"dependent",u=z(n);u!==null&&(i=i.slice(0,u)),u!==null&&i.length===u&&T(`showing the first ${u} dependencies; pass --limit n or --all for more`);let m=i.map(d=>[s(d,`${r}componenttype`),s(d,`${r}componentobjectid`),s(d,`${r}componentparentid`)]),g=i.length?await oe(e,t,m):new Map,y=new Map;if(i.length){let[d]=await M(e,t,"solutions",[["$select","solutionid,uniquename"]],null,null);for(let h of d)y.set(String(h.solutionid).toLowerCase(),h.uniquename)}let w=[];for(let d=0;d<i.length;d++){let h=i[d],[j,B]=m[d],H=String(v(s(h,`${r}componentbasesolutionid`),"")).toLowerCase(),S=s(h,"dependencytype"),K={type:j===null?"None":await C(e,t,j),name:g.get(String(B||"").toLowerCase())??null,id:B,dependency:typeof S=="number"&&J.has(S)?J.get(S):S,solution:y.get(H)??null};w.push(D(K))}w=L(w,d=>[String(d.type),String(v(s(d,"name"),"")).toLowerCase()]),await e.emit(w)}async function ue(e){let n=await R(e),[t,a]=await E(e,n),[o,c]=x("IsComponentCustomizable",[["ComponentId",a],["ComponentType",String(t)]]),l=b(await f(e,n,"GET",o,{params:c}));await e.emit({type:await C(e,n,t),id:a,customizable:s(l,"IsComponentCustomizable")})}async function de(e){let n=await R(e),[t,a]=await E(e,n),o=X.get(t);if(!o)throw new N("unpublished works for forms, views, web resources and apps",{hint:"Dataverse's RetrieveUnpublished doesn't support other types (site maps included)"});let[c,,l]=o,p=l.join(","),i=b(await f(e,n,"GET",`${c}(${a})`,{params:[["$select",p]]})),r=b(await f(e,n,"GET",`${c}(${a})/Microsoft.Dynamics.CRM.RetrieveUnpublished()`,{params:[["$select",p]]})),u=(y,w)=>{let d=v(y,null),h=v(w,null);return typeof d=="object"||typeof h=="object"?JSON.stringify(d)===JSON.stringify(h):d===h},m=l.filter(y=>!u(s(i,y),s(r,y))),g={type:await C(e,n,t),id:a,name:v(s(r,"name"),s(i,"name")),pending:m.length>0,changed:m};if(e.args.show&&m.length){let y={};for(let w of m)y[w]=s(r,w);g.unpublished=y}await e.emit(g)}async function pe(e){let n=await R(e);k(e,n,"POST","RemoveActiveCustomization",Buffer.from("{}"));let[t,a,o]=await n.lookups(async()=>{let[l,p]=await E(e,n);return[l,p,F.get(l)||await A(e,n,l)]});if(!o)throw new N(`component type ${t} isn't supported here`);let c=b(await f(e,n,"POST","RemoveActiveCustomization",{body:U({LogicalName:o,Id:a})}));await e.emit({type:await C(e,n,t),id:a,removed:$(s(c,"Success"))})}export{Y as a,F as b,V as c,Q as d,J as e,X as f,Z as g,A as h,ee as i,C as j,te as k,re as l,le as m,ue as n,de as o,pe as p};