@mohsinonxrm/dataverse-sdk-messages 1.0.0
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.
- package/LICENSE +661 -0
- package/README.md +444 -0
- package/dist/index.d.ts +34023 -0
- package/dist/index.js +58400 -0
- package/dist/index.js.map +1 -0
- package/package.json +56 -0
package/README.md
ADDED
|
@@ -0,0 +1,444 @@
|
|
|
1
|
+
# @mohsinonxrm/dataverse-sdk-messages
|
|
2
|
+
|
|
3
|
+
Organization Service messages for Dataverse, providing typed request/response pairs that map to Web API actions and functions.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- ✅ **1,356+ typed messages** - Complete coverage of all Dataverse Organization Service messages
|
|
8
|
+
- ✅ **Direct exports** - All message classes exported directly (e.g., `ExecuteWorkflowRequest`, `WinOpportunityRequest`)
|
|
9
|
+
- ✅ **Request/response pairs** - Full type safety for all message parameters and returns
|
|
10
|
+
- ✅ **Web API mapping** - Messages map to corresponding Web API actions, functions, or HTTP operations
|
|
11
|
+
- ✅ **Generic OrganizationRequest** - Escape hatch for custom actions
|
|
12
|
+
- ✅ **Executable interface** - All messages implement `Executable<TResponse>` for direct execution
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
pnpm add @mohsinonxrm/dataverse-sdk-messages @mohsinonxrm/dataverse-sdk-xrm
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Overview
|
|
21
|
+
|
|
22
|
+
This package provides 1,356+ typed message classes that wrap Web API actions and functions. Each message:
|
|
23
|
+
|
|
24
|
+
- Extends `OrganizationRequest` base class
|
|
25
|
+
- Implements `Executable<TResponse>` interface
|
|
26
|
+
- Provides `toRequestInformation()` for HTTP request construction
|
|
27
|
+
- Provides `parseResponse()` for type-safe response parsing
|
|
28
|
+
|
|
29
|
+
Messages execute via `OrganizationService.execute()` from `@mohsinonxrm/dataverse-sdk-xrm` or directly via `DataverseClient.execute()`.
|
|
30
|
+
|
|
31
|
+
## Message Categories
|
|
32
|
+
|
|
33
|
+
The SDK includes **1,356+ typed messages** organized into the following categories:
|
|
34
|
+
|
|
35
|
+
### Platform Messages
|
|
36
|
+
|
|
37
|
+
**Identity & Security:**
|
|
38
|
+
|
|
39
|
+
- `RetrievePrincipalAccessRequest/Response` - Get access rights
|
|
40
|
+
- `GrantAccessRequest/Response` - Grant access to record
|
|
41
|
+
- `RevokeAccessRequest/Response` - Revoke access to record
|
|
42
|
+
|
|
43
|
+
**Entity Operations:**
|
|
44
|
+
|
|
45
|
+
- `AssignRequest/Response` - Assign record ownership
|
|
46
|
+
- `SetStateRequest/Response` - Set state and status
|
|
47
|
+
- `MergeRequest/Response` - Merge duplicate records
|
|
48
|
+
|
|
49
|
+
**Metadata:**
|
|
50
|
+
|
|
51
|
+
- `RetrieveMetadataChangesRequest/Response` - Get metadata delta
|
|
52
|
+
- `CreateEntityRequest/Response` - Create custom entity
|
|
53
|
+
- `CreateAttributeRequest/Response` - Create column
|
|
54
|
+
|
|
55
|
+
### Business Messages
|
|
56
|
+
|
|
57
|
+
**Sales Module:**
|
|
58
|
+
|
|
59
|
+
- `WinOpportunityRequest/Response` - Close opportunity as won
|
|
60
|
+
- `LoseOpportunityRequest/Response` - Close opportunity as lost
|
|
61
|
+
- `QualifyLeadRequest/Response` - Qualify lead to opportunity
|
|
62
|
+
- `ConvertQuoteToSalesOrderRequest/Response` - Convert quote
|
|
63
|
+
- `CalculatePriceRequest/Response` - Calculate pricing
|
|
64
|
+
|
|
65
|
+
**Customer Service Module:**
|
|
66
|
+
|
|
67
|
+
- `CloseIncidentRequest/Response` - Close case
|
|
68
|
+
- `ExecuteWorkflowRequest/Response` - Run workflow
|
|
69
|
+
- `ApplyRoutingRuleRequest/Response` - Apply routing rules
|
|
70
|
+
|
|
71
|
+
**Solution Management:**
|
|
72
|
+
|
|
73
|
+
- `ExportSolutionRequest/Response` - Export solution
|
|
74
|
+
- `ImportSolutionRequest/Response` - Import solution
|
|
75
|
+
- `PublishXmlRequest/Response` - Publish metadata
|
|
76
|
+
- `PublishAllXmlRequest/Response` - Publish all changes
|
|
77
|
+
|
|
78
|
+
**Field Service (msdyn\_\*):**
|
|
79
|
+
|
|
80
|
+
- Work order management messages
|
|
81
|
+
- Resource scheduling messages
|
|
82
|
+
- Booking operation messages
|
|
83
|
+
|
|
84
|
+
**Marketing (msdynmkt\_\*):**
|
|
85
|
+
|
|
86
|
+
- Campaign operation messages
|
|
87
|
+
- Consent management messages
|
|
88
|
+
|
|
89
|
+
### Complete Message Reference
|
|
90
|
+
|
|
91
|
+
For a complete list of all 1,356+ messages with descriptions, see [docs/mapping/supported-messages.md](../../docs/mapping/supported-messages.md).
|
|
92
|
+
|
|
93
|
+
## Quick Start
|
|
94
|
+
|
|
95
|
+
```typescript
|
|
96
|
+
import { OrganizationService } from "@mohsinonxrm/dataverse-sdk-xrm";
|
|
97
|
+
import { ExecuteWorkflowRequest } from "@mohsinonxrm/dataverse-sdk-messages";
|
|
98
|
+
|
|
99
|
+
const service = new OrganizationService(client);
|
|
100
|
+
|
|
101
|
+
// Execute workflow message
|
|
102
|
+
const request = new ExecuteWorkflowRequest(
|
|
103
|
+
workflowId, // Workflow GUID
|
|
104
|
+
recordId, // Entity record GUID
|
|
105
|
+
{} // Input arguments (optional)
|
|
106
|
+
);
|
|
107
|
+
|
|
108
|
+
const response = await service.execute(request);
|
|
109
|
+
console.log("Async Operation ID:", response.result.asyncoperationid);
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
## Common Messages
|
|
113
|
+
|
|
114
|
+
### Assign
|
|
115
|
+
|
|
116
|
+
Assigns a record to a user or team.
|
|
117
|
+
|
|
118
|
+
**Maps to:** Assign action (POST)
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
import { AssignRequest, createEntityReference } from "@mohsinonxrm/dataverse-sdk-messages";
|
|
122
|
+
|
|
123
|
+
const request = new AssignRequest(
|
|
124
|
+
createEntityReference("account", accountId),
|
|
125
|
+
createEntityReference("systemuser", userId)
|
|
126
|
+
);
|
|
127
|
+
|
|
128
|
+
await service.execute(request);
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
**Constructor:**
|
|
132
|
+
|
|
133
|
+
- `target: EntityReference` - The record to assign
|
|
134
|
+
- `assignee: EntityReference` - The user or team to assign the record to
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
### SetState
|
|
139
|
+
|
|
140
|
+
Sets the state and status of a record.
|
|
141
|
+
|
|
142
|
+
**Maps to:** PATCH with statecode/statuscode
|
|
143
|
+
|
|
144
|
+
```typescript
|
|
145
|
+
import { SetStateRequest, createEntityReference } from "@mohsinonxrm/dataverse-sdk-messages";
|
|
146
|
+
|
|
147
|
+
// Deactivate an account
|
|
148
|
+
const request = new SetStateRequest(
|
|
149
|
+
createEntityReference("account", accountId),
|
|
150
|
+
1, // State: Inactive
|
|
151
|
+
2 // Status: Inactive
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
await service.execute(request);
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
**Constructor:**
|
|
158
|
+
|
|
159
|
+
- `entityMoniker: EntityReference` - The record to update
|
|
160
|
+
- `state: number` - The state code value (e.g., 0 = Active, 1 = Inactive)
|
|
161
|
+
- `status: number` - The status code value
|
|
162
|
+
|
|
163
|
+
---
|
|
164
|
+
|
|
165
|
+
### ExecuteWorkflow
|
|
166
|
+
|
|
167
|
+
Executes a workflow against an entity record.
|
|
168
|
+
|
|
169
|
+
**Maps to:** ExecuteWorkflow action (bound to workflow)
|
|
170
|
+
|
|
171
|
+
```typescript
|
|
172
|
+
import { ExecuteWorkflowRequest } from "@mohsinonxrm/dataverse-sdk-messages";
|
|
173
|
+
|
|
174
|
+
const request = new ExecuteWorkflowRequest(
|
|
175
|
+
workflowId, // Workflow GUID
|
|
176
|
+
recordId, // Entity record GUID
|
|
177
|
+
{} // Input arguments (optional)
|
|
178
|
+
);
|
|
179
|
+
|
|
180
|
+
const response = await service.execute(request);
|
|
181
|
+
console.log("Async Operation ID:", response.result.asyncoperationid);
|
|
182
|
+
// Poll asyncoperation entity to check workflow status
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
**Constructor:**
|
|
186
|
+
|
|
187
|
+
- `workflowId: string` - GUID of the workflow to execute
|
|
188
|
+
- `entityId: string` - GUID of the entity record to run the workflow against
|
|
189
|
+
- `inputArguments: InputArgumentCollection` - Optional input arguments
|
|
190
|
+
|
|
191
|
+
**Response:**
|
|
192
|
+
|
|
193
|
+
- `result: asyncoperation` - The async operation record (system job)
|
|
194
|
+
|
|
195
|
+
---
|
|
196
|
+
|
|
197
|
+
### WinOpportunity
|
|
198
|
+
|
|
199
|
+
Marks an opportunity as won.
|
|
200
|
+
|
|
201
|
+
**Maps to:** WinOpportunity action (POST, unbound)
|
|
202
|
+
|
|
203
|
+
```typescript
|
|
204
|
+
import { WinOpportunityRequest } from "@mohsinonxrm/dataverse-sdk-messages";
|
|
205
|
+
|
|
206
|
+
const opportunityClose = {
|
|
207
|
+
"@odata.type": "Microsoft.Dynamics.CRM.opportunityclose",
|
|
208
|
+
subject: "Won the deal!",
|
|
209
|
+
"opportunityid@odata.bind": `/opportunities(${oppId})`,
|
|
210
|
+
actualrevenue: 50000,
|
|
211
|
+
actualend: new Date().toISOString(),
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
const request = new WinOpportunityRequest(
|
|
215
|
+
opportunityClose,
|
|
216
|
+
3 // Status: Won
|
|
217
|
+
);
|
|
218
|
+
|
|
219
|
+
await service.execute(request);
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
**Constructor:**
|
|
223
|
+
|
|
224
|
+
- `opportunityClose: opportunityclose` - The opportunity close record
|
|
225
|
+
- `status: number` - The status code for won opportunities
|
|
226
|
+
|
|
227
|
+
---
|
|
228
|
+
|
|
229
|
+
### Merge
|
|
230
|
+
|
|
231
|
+
Merges two entity records.
|
|
232
|
+
|
|
233
|
+
**Maps to:** Merge action (POST, unbound)
|
|
234
|
+
**Supported entities:** account, contact, lead, incident
|
|
235
|
+
|
|
236
|
+
```typescript
|
|
237
|
+
import { MergeRequest, createEntityReference } from "@mohsinonxrm/dataverse-sdk-messages";
|
|
238
|
+
|
|
239
|
+
const request = new MergeRequest(
|
|
240
|
+
createEntityReference("account", masterAccountId), // Target (keep)
|
|
241
|
+
subordinateAccountId, // Subordinate (merge & deactivate)
|
|
242
|
+
{
|
|
243
|
+
// Update content
|
|
244
|
+
name: "Merged Company Name",
|
|
245
|
+
revenue: 1000000,
|
|
246
|
+
},
|
|
247
|
+
false // PerformParentingChecks
|
|
248
|
+
);
|
|
249
|
+
|
|
250
|
+
await service.execute(request);
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
**Constructor:**
|
|
254
|
+
|
|
255
|
+
- `target: EntityReference` - The master record (will remain after merge)
|
|
256
|
+
- `subordinateId: string` - GUID of the subordinate record (will be deactivated/deleted)
|
|
257
|
+
- `updateContent: Record<string, unknown>` - Updates to apply to the master record
|
|
258
|
+
- `performParentingChecks: boolean` - Whether to perform parenting checks
|
|
259
|
+
|
|
260
|
+
---
|
|
261
|
+
|
|
262
|
+
### ExportSolution
|
|
263
|
+
|
|
264
|
+
Exports a solution from the environment.
|
|
265
|
+
|
|
266
|
+
**Maps to:** ExportSolution action (POST, unbound)
|
|
267
|
+
|
|
268
|
+
```typescript
|
|
269
|
+
import { ExportSolutionRequest } from "@mohsinonxrm/dataverse-sdk-messages";
|
|
270
|
+
|
|
271
|
+
const request = new ExportSolutionRequest(
|
|
272
|
+
"MySolution", // Solution name
|
|
273
|
+
false, // Managed
|
|
274
|
+
false, // ExportAutoNumberingSettings
|
|
275
|
+
false, // ExportCalendarSettings
|
|
276
|
+
false, // ExportCustomizationSettings
|
|
277
|
+
false, // ExportEmailTrackingSettings
|
|
278
|
+
false, // ExportGeneralSettings
|
|
279
|
+
false, // ExportMarketingSettings
|
|
280
|
+
false, // ExportOutlookSynchronizationSettings
|
|
281
|
+
false, // ExportRelationshipRoles
|
|
282
|
+
false, // ExportIsvConfig
|
|
283
|
+
false, // ExportSales
|
|
284
|
+
false // ExportExternalApplications
|
|
285
|
+
);
|
|
286
|
+
|
|
287
|
+
const response = await service.execute(request);
|
|
288
|
+
|
|
289
|
+
// Decode base64 to file
|
|
290
|
+
const solutionFile = Buffer.from(response.exportSolutionFile, "base64");
|
|
291
|
+
fs.writeFileSync("solution.zip", solutionFile);
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
**Response:**
|
|
295
|
+
|
|
296
|
+
- `exportSolutionFile: string` - Base64-encoded solution file (zip)
|
|
297
|
+
|
|
298
|
+
---
|
|
299
|
+
|
|
300
|
+
### ImportSolution
|
|
301
|
+
|
|
302
|
+
Imports a solution into the environment.
|
|
303
|
+
|
|
304
|
+
**Maps to:** ImportSolution action (POST, unbound)
|
|
305
|
+
|
|
306
|
+
```typescript
|
|
307
|
+
import { ImportSolutionRequest } from "@mohsinonxrm/dataverse-sdk-messages";
|
|
308
|
+
|
|
309
|
+
const solutionBytes = fs.readFileSync("solution.zip");
|
|
310
|
+
|
|
311
|
+
const request = new ImportSolutionRequest(
|
|
312
|
+
solutionBytes.toString("base64"), // CustomizationFile
|
|
313
|
+
true, // PublishWorkflows
|
|
314
|
+
false, // OverwriteUnmanagedCustomizations
|
|
315
|
+
false, // SkipProductUpdateDependencies
|
|
316
|
+
false, // HoldingSolution
|
|
317
|
+
false // ConvertToManaged
|
|
318
|
+
);
|
|
319
|
+
|
|
320
|
+
const response = await service.execute(request);
|
|
321
|
+
console.log("Import Job ID:", response.importJobId);
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
**Response:**
|
|
325
|
+
|
|
326
|
+
- `importJobId: string` - GUID of the import job
|
|
327
|
+
|
|
328
|
+
---
|
|
329
|
+
|
|
330
|
+
### PublishXml
|
|
331
|
+
|
|
332
|
+
Publishes specific customizations.
|
|
333
|
+
|
|
334
|
+
**Maps to:** PublishXml action (POST, unbound)
|
|
335
|
+
|
|
336
|
+
```typescript
|
|
337
|
+
import { PublishXmlRequest } from "@mohsinonxrm/dataverse-sdk-messages";
|
|
338
|
+
|
|
339
|
+
const parameterXml = `<importexportxml>
|
|
340
|
+
<entities>
|
|
341
|
+
<entity>account</entity>
|
|
342
|
+
<entity>contact</entity>
|
|
343
|
+
</entities>
|
|
344
|
+
</importexportxml>`;
|
|
345
|
+
|
|
346
|
+
const request = new PublishXmlRequest(parameterXml);
|
|
347
|
+
await service.execute(request);
|
|
348
|
+
```
|
|
349
|
+
|
|
350
|
+
---
|
|
351
|
+
|
|
352
|
+
### PublishAllXml
|
|
353
|
+
|
|
354
|
+
Publishes all customizations.
|
|
355
|
+
|
|
356
|
+
**Maps to:** PublishAllXml action (POST, unbound)
|
|
357
|
+
|
|
358
|
+
```typescript
|
|
359
|
+
import { PublishAllXmlRequest } from "@mohsinonxrm/dataverse-sdk-messages";
|
|
360
|
+
|
|
361
|
+
const request = new PublishAllXmlRequest();
|
|
362
|
+
await service.execute(request);
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
---
|
|
366
|
+
|
|
367
|
+
## Generic OrganizationRequest
|
|
368
|
+
|
|
369
|
+
For custom actions, custom APIs, or messages not yet implemented, use the generic `OrganizationRequest`.
|
|
370
|
+
|
|
371
|
+
```typescript
|
|
372
|
+
import { OrganizationRequest } from "@mohsinonxrm/dataverse-sdk-messages";
|
|
373
|
+
|
|
374
|
+
const request = new OrganizationRequest("my_CustomAction");
|
|
375
|
+
request.Parameters["StringParameter"] = "value";
|
|
376
|
+
request.Parameters["IntParameter"] = 42;
|
|
377
|
+
request.Parameters["EntityParameter"] = createEntityReference("account", accountId);
|
|
378
|
+
|
|
379
|
+
const response = await service.execute(request);
|
|
380
|
+
console.log("Results:", response.Results);
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
**Constructor:**
|
|
384
|
+
|
|
385
|
+
- `messageName: string` - The name of the action/custom API
|
|
386
|
+
|
|
387
|
+
**Properties:**
|
|
388
|
+
|
|
389
|
+
- `Parameters: Record<string, unknown>` - The parameters for the action
|
|
390
|
+
|
|
391
|
+
**Response:**
|
|
392
|
+
|
|
393
|
+
- `Results: Record<string, unknown>` - The result values from the action
|
|
394
|
+
|
|
395
|
+
---
|
|
396
|
+
|
|
397
|
+
## Message-to-Web API Mapping
|
|
398
|
+
|
|
399
|
+
| Message | Web API Endpoint | HTTP Method | Type |
|
|
400
|
+
| --------------- | ------------------------------------------------------- | ----------- | -------------- |
|
|
401
|
+
| Assign | /Assign | POST | Action |
|
|
402
|
+
| SetState | /{entitySet}({id}) | PATCH | HTTP |
|
|
403
|
+
| ExecuteWorkflow | /workflows({id})/Microsoft.Dynamics.CRM.ExecuteWorkflow | POST | Action (bound) |
|
|
404
|
+
| WinOpportunity | /WinOpportunity | POST | Action |
|
|
405
|
+
| Merge | /Merge | POST | Action |
|
|
406
|
+
| ExportSolution | /ExportSolution | POST | Action |
|
|
407
|
+
| ImportSolution | /ImportSolution | POST | Action |
|
|
408
|
+
| PublishXml | /PublishXml | POST | Action |
|
|
409
|
+
| PublishAllXml | /PublishAllXml | POST | Action |
|
|
410
|
+
|
|
411
|
+
See [docs/mapping/message-to-webapi.md](../../docs/mapping/message-to-webapi.md) for complete mapping details.
|
|
412
|
+
|
|
413
|
+
---
|
|
414
|
+
|
|
415
|
+
## EntityReference Type
|
|
416
|
+
|
|
417
|
+
```typescript
|
|
418
|
+
interface EntityReference {
|
|
419
|
+
logicalName: string; // e.g., 'account', 'contact'
|
|
420
|
+
id: string; // GUID
|
|
421
|
+
name?: string; // Optional display name
|
|
422
|
+
}
|
|
423
|
+
```
|
|
424
|
+
|
|
425
|
+
---
|
|
426
|
+
|
|
427
|
+
## Utilities
|
|
428
|
+
|
|
429
|
+
### createEntityReference
|
|
430
|
+
|
|
431
|
+
Helper to create entity references.
|
|
432
|
+
|
|
433
|
+
```typescript
|
|
434
|
+
import { createEntityReference } from "@mohsinonxrm/dataverse-sdk-messages";
|
|
435
|
+
|
|
436
|
+
const accountRef = createEntityReference("account", accountId);
|
|
437
|
+
// { logicalName: 'account', id: '...' }
|
|
438
|
+
```
|
|
439
|
+
|
|
440
|
+
---
|
|
441
|
+
|
|
442
|
+
## License
|
|
443
|
+
|
|
444
|
+
GNU AGPL v3.0
|