@pptb/types 1.0.10 → 1.0.12

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/dataverseAPI.d.ts CHANGED
@@ -81,6 +81,7 @@ declare namespace DataverseAPI {
81
81
  *
82
82
  * @param entityLogicalName - Logical name of the entity (e.g., 'account', 'contact')
83
83
  * @param record - Record data to create
84
+ * @param connectionTarget - Optional connection target for multi-connection tools ('primary' or 'secondary'). Defaults to 'primary'.
84
85
  * @returns Object containing the created record ID and any returned fields
85
86
  *
86
87
  * @example
@@ -90,8 +91,14 @@ declare namespace DataverseAPI {
90
91
  * telephone1: '555-0100'
91
92
  * });
92
93
  * console.log('Created account ID:', result.id);
94
+ *
95
+ * @example
96
+ * // Multi-connection tool using secondary connection
97
+ * const result = await dataverseAPI.create('account', {
98
+ * name: 'Contoso Ltd'
99
+ * }, 'secondary');
93
100
  */
94
- create: (entityLogicalName: string, record: Record<string, unknown>) => Promise<CreateResult>;
101
+ create: (entityLogicalName: string, record: Record<string, unknown>, connectionTarget?: "primary" | "secondary") => Promise<CreateResult>;
95
102
 
96
103
  /**
97
104
  * Retrieve a single record by ID
@@ -99,6 +106,7 @@ declare namespace DataverseAPI {
99
106
  * @param entityLogicalName - Logical name of the entity
100
107
  * @param id - GUID of the record
101
108
  * @param columns - Optional array of column names to retrieve (retrieves all if not specified)
109
+ * @param connectionTarget - Optional connection target for multi-connection tools ('primary' or 'secondary'). Defaults to 'primary'.
102
110
  * @returns Object containing the requested record
103
111
  *
104
112
  * @example
@@ -108,8 +116,12 @@ declare namespace DataverseAPI {
108
116
  * ['name', 'emailaddress1', 'telephone1']
109
117
  * );
110
118
  * console.log('Account name:', account.name);
119
+ *
120
+ * @example
121
+ * // Multi-connection tool using secondary connection
122
+ * const account = await dataverseAPI.retrieve('account', 'guid-here', ['name'], 'secondary');
111
123
  */
112
- retrieve: (entityLogicalName: string, id: string, columns?: string[]) => Promise<Record<string, unknown>>;
124
+ retrieve: (entityLogicalName: string, id: string, columns?: string[], connectionTarget?: "primary" | "secondary") => Promise<Record<string, unknown>>;
113
125
 
114
126
  /**
115
127
  * Update an existing record
@@ -117,30 +129,41 @@ declare namespace DataverseAPI {
117
129
  * @param entityLogicalName - Logical name of the entity
118
130
  * @param id - GUID of the record
119
131
  * @param record - Fields to update
132
+ * @param connectionTarget - Optional connection target for multi-connection tools ('primary' or 'secondary'). Defaults to 'primary'.
120
133
  *
121
134
  * @example
122
135
  * await dataverseAPI.update('account', 'guid-here', {
123
136
  * name: 'Updated Account Name',
124
137
  * description: 'Updated description'
125
138
  * });
139
+ *
140
+ * @example
141
+ * // Multi-connection tool using secondary connection
142
+ * await dataverseAPI.update('account', 'guid-here', { name: 'Updated' }, 'secondary');
126
143
  */
127
- update: (entityLogicalName: string, id: string, record: Record<string, unknown>) => Promise<void>;
144
+ update: (entityLogicalName: string, id: string, record: Record<string, unknown>, connectionTarget?: "primary" | "secondary") => Promise<void>;
128
145
 
129
146
  /**
130
147
  * Delete a record
131
148
  *
132
149
  * @param entityLogicalName - Logical name of the entity
133
150
  * @param id - GUID of the record
151
+ * @param connectionTarget - Optional connection target for multi-connection tools ('primary' or 'secondary'). Defaults to 'primary'.
134
152
  *
135
153
  * @example
136
154
  * await dataverseAPI.delete('account', 'guid-here');
155
+ *
156
+ * @example
157
+ * // Multi-connection tool using secondary connection
158
+ * await dataverseAPI.delete('account', 'guid-here', 'secondary');
137
159
  */
138
- delete: (entityLogicalName: string, id: string) => Promise<void>;
160
+ delete: (entityLogicalName: string, id: string, connectionTarget?: "primary" | "secondary") => Promise<void>;
139
161
 
140
162
  /**
141
163
  * Execute a FetchXML query
142
164
  *
143
165
  * @param fetchXml - FetchXML query string
166
+ * @param connectionTarget - Optional connection target for multi-connection tools ('primary' or 'secondary'). Defaults to 'primary'.
144
167
  * @returns Object with value array containing matching records
145
168
  *
146
169
  * @example
@@ -162,21 +185,27 @@ declare namespace DataverseAPI {
162
185
  * result.value.forEach(record => {
163
186
  * console.log(record.name);
164
187
  * });
188
+ *
189
+ * @example
190
+ * // Multi-connection tool using secondary connection
191
+ * const result = await dataverseAPI.fetchXmlQuery(fetchXml, 'secondary');
165
192
  */
166
- fetchXmlQuery: (fetchXml: string) => Promise<FetchXmlResult>;
193
+ fetchXmlQuery: (fetchXml: string, connectionTarget?: "primary" | "secondary") => Promise<FetchXmlResult>;
167
194
 
168
195
  /**
169
196
  * Retrieve multiple records (alias for fetchXmlQuery for backward compatibility)
170
197
  *
171
198
  * @param fetchXml - FetchXML query string
199
+ * @param connectionTarget - Optional connection target for multi-connection tools ('primary' or 'secondary'). Defaults to 'primary'.
172
200
  * @returns Object with value array containing matching records
173
201
  */
174
- retrieveMultiple: (fetchXml: string) => Promise<FetchXmlResult>;
202
+ retrieveMultiple: (fetchXml: string, connectionTarget?: "primary" | "secondary") => Promise<FetchXmlResult>;
175
203
 
176
204
  /**
177
205
  * Execute a Dataverse Web API action or function
178
206
  *
179
207
  * @param request - Execute request configuration
208
+ * @param connectionTarget - Optional connection target for multi-connection tools ('primary' or 'secondary'). Defaults to 'primary'.
180
209
  * @returns Object containing the operation result
181
210
  *
182
211
  * @example
@@ -198,8 +227,15 @@ declare namespace DataverseAPI {
198
227
  * FieldName: 'total_revenue'
199
228
  * }
200
229
  * });
230
+ *
231
+ * @example
232
+ * // Multi-connection tool using secondary connection
233
+ * const result = await dataverseAPI.execute({
234
+ * operationName: 'WhoAmI',
235
+ * operationType: 'function'
236
+ * }, 'secondary');
201
237
  */
202
- execute: (request: ExecuteRequest) => Promise<Record<string, unknown>>;
238
+ execute: (request: ExecuteRequest, connectionTarget?: "primary" | "secondary") => Promise<Record<string, unknown>>;
203
239
 
204
240
  /**
205
241
  * Get metadata for a specific entity
@@ -207,6 +243,7 @@ declare namespace DataverseAPI {
207
243
  * @param entityLogicalName - Logical name of the entity
208
244
  * @param searchByLogicalName - Whether to search by logical name (true) or metadata ID (false)
209
245
  * @param selectColumns - Optional array of column names to retrieve (retrieves all if not specified)
246
+ * @param connectionTarget - Optional connection target for multi-connection tools ('primary' or 'secondary'). Defaults to 'primary'.
210
247
  * @returns Object containing entity metadata
211
248
  *
212
249
  * @example
@@ -220,12 +257,17 @@ declare namespace DataverseAPI {
220
257
  * console.log('Entity Metadata ID:', metadata.MetadataId);
221
258
  * console.log('Logical Name:', metadata.LogicalName);
222
259
  * console.log('Display Name:', metadata.DisplayName?.LocalizedLabels[0]?.Label);
260
+ *
261
+ * @example
262
+ * // Multi-connection tool using secondary connection
263
+ * const metadata = await dataverseAPI.getEntityMetadata('account', true, ['LogicalName'], 'secondary');
223
264
  */
224
- getEntityMetadata: (entityLogicalName: string, searchByLogicalName: boolean, selectColumns?: string[]) => Promise<EntityMetadata>;
265
+ getEntityMetadata: (entityLogicalName: string, searchByLogicalName: boolean, selectColumns?: string[], connectionTarget?: "primary" | "secondary") => Promise<EntityMetadata>;
225
266
 
226
267
  /**
227
268
  * Get metadata for all entities
228
269
  * @param selectColumns - Optional array of column names to retrieve (retrieves LogicalName, DisplayName, MetadataId by default)
270
+ * @param connectionTarget - Optional connection target for multi-connection tools ('primary' or 'secondary'). Defaults to 'primary'.
229
271
  * @returns Object with value array containing all entity metadata
230
272
  *
231
273
  * @example
@@ -234,8 +276,12 @@ declare namespace DataverseAPI {
234
276
  * allEntities.value.forEach(entity => {
235
277
  * console.log(`${entity.LogicalName} - ${entity.DisplayName?.LocalizedLabels[0]?.Label}`);
236
278
  * });
279
+ *
280
+ * @example
281
+ * // Multi-connection tool using secondary connection
282
+ * const allEntities = await dataverseAPI.getAllEntitiesMetadata(['LogicalName'], 'secondary');
237
283
  */
238
- getAllEntitiesMetadata: (selectColumns?: string[]) => Promise<EntityMetadataCollection>;
284
+ getAllEntitiesMetadata: (selectColumns?: string[], connectionTarget?: "primary" | "secondary") => Promise<EntityMetadataCollection>;
239
285
 
240
286
  /**
241
287
  * Get related metadata for a specific entity (attributes, relationships, etc.)
@@ -243,6 +289,7 @@ declare namespace DataverseAPI {
243
289
  * @param entityLogicalName - Logical name of the entity
244
290
  * @param relatedPath - Path after EntityDefinitions(LogicalName='name') (e.g., 'Attributes', 'OneToManyRelationships', 'ManyToOneRelationships', 'ManyToManyRelationships', 'Keys')
245
291
  * @param selectColumns - Optional array of column names to retrieve (retrieves all if not specified)
292
+ * @param connectionTarget - Optional connection target for multi-connection tools ('primary' or 'secondary'). Defaults to 'primary'.
246
293
  * @returns Object containing the related metadata
247
294
  *
248
295
  * @example
@@ -266,13 +313,18 @@ declare namespace DataverseAPI {
266
313
  * 'OneToManyRelationships'
267
314
  * );
268
315
  * console.log('One-to-many relationships:', relationships.value);
316
+ *
317
+ * @example
318
+ * // Multi-connection tool using secondary connection
319
+ * const attributes = await dataverseAPI.getEntityRelatedMetadata('account', 'Attributes', ['LogicalName'], 'secondary');
269
320
  */
270
- getEntityRelatedMetadata: (entityLogicalName: string, relatedPath: string, selectColumns?: string[]) => Promise<Record<string, unknown>>;
321
+ getEntityRelatedMetadata: (entityLogicalName: string, relatedPath: string, selectColumns?: string[], connectionTarget?: "primary" | "secondary") => Promise<Record<string, unknown>>;
271
322
 
272
323
  /**
273
324
  * Get solutions from the environment
274
325
  *
275
326
  * @param selectColumns - Required array of column names to retrieve (must contain at least one column)
327
+ * @param connectionTarget - Optional connection target for multi-connection tools ('primary' or 'secondary'). Defaults to 'primary'.
276
328
  * @returns Object with value array containing solutions
277
329
  *
278
330
  * @example
@@ -287,13 +339,18 @@ declare namespace DataverseAPI {
287
339
  * solutions.value.forEach(solution => {
288
340
  * console.log(`${solution.friendlyname} (${solution.uniquename}) - v${solution.version}`);
289
341
  * });
342
+ *
343
+ * @example
344
+ * // Multi-connection tool using secondary connection
345
+ * const solutions = await dataverseAPI.getSolutions(['uniquename'], 'secondary');
290
346
  */
291
- getSolutions: (selectColumns: string[]) => Promise<{ value: Record<string, unknown>[] }>;
347
+ getSolutions: (selectColumns: string[], connectionTarget?: "primary" | "secondary") => Promise<{ value: Record<string, unknown>[] }>;
292
348
 
293
349
  /**
294
350
  * Query data from Dataverse using OData query parameters
295
351
  *
296
352
  * @param odataQuery - OData query string with parameters like $select, $filter, $orderby, $top, $skip, $expand
353
+ * @param connectionTarget - Optional connection target for multi-connection tools ('primary' or 'secondary'). Defaults to 'primary'.
297
354
  * @returns Object with value array containing matching records
298
355
  *
299
356
  * @example
@@ -317,8 +374,62 @@ declare namespace DataverseAPI {
317
374
  * const result = await dataverseAPI.queryData(
318
375
  * '$filter=contains(fullname, \'Smith\')&$top=20'
319
376
  * );
377
+ *
378
+ * @example
379
+ * // Multi-connection tool using secondary connection
380
+ * const result = await dataverseAPI.queryData('$filter=statecode eq 0', 'secondary');
381
+ */
382
+ queryData: (odataQuery: string, connectionTarget?: "primary" | "secondary") => Promise<{ value: Record<string, unknown>[] }>;
383
+
384
+ /**
385
+ * Create multiple records in Dataverse
386
+ *
387
+ * @param entityLogicalName - Logical name of the entity (e.g., 'account', 'contact')
388
+ * @param records - Array of record data to create, including the "@odata.type" property for each record
389
+ * @param connectionTarget - Optional connection target for multi-connection tools ('primary' or 'secondary'). Defaults to 'primary'.
390
+ * @returns Array of strings representing the created record IDs
391
+ *
392
+ * @example
393
+ * const results = await dataverseAPI.createMultiple('account', [
394
+ * { name: 'Contoso Ltd', "@odata.type": "Microsoft.Dynamics.CRM.account" },
395
+ * { name: 'Fabrikam Inc', "@odata.type": "Microsoft.Dynamics.CRM.account" }
396
+ * ]);
397
+ */
398
+ createMultiple: (entityLogicalName: string, records: Record<string, unknown>[], connectionTarget?: "primary" | "secondary") => Promise<string[]>;
399
+
400
+ /**
401
+ * Update multiple records in Dataverse
402
+ * @param entityLogicalName - Logical name of the entity
403
+ * @param records - Array of record data to update, each including the "id" property and the "odata.type" property
404
+ * @param connectionTarget - Optional connection target for multi-connection tools ('primary' or 'secondary'). Defaults to 'primary'.
405
+ *
406
+ * @example
407
+ * await dataverseAPI.updateMultiple('account', [
408
+ * { accountid: 'guid-1', name: 'Updated Name 1', "@odata.type": "Microsoft.Dynamics.CRM.account" },
409
+ * { accountid: 'guid-2', name: 'Updated Name 2', "@odata.type": "Microsoft.Dynamics.CRM.account" }
410
+ * ]);
411
+ */
412
+ updateMultiple: (entityLogicalName: string, records: Record<string, unknown>[], connectionTarget?: "primary" | "secondary") => Promise<void>;
413
+ * Gets the Dataverse entity set (collection) name for the specified table.
414
+ *
415
+ * This is typically used when building OData queries where the collection name
416
+ * (entity set name) is required instead of the logical table name.
417
+ *
418
+ * Note: This is a utility method that applies pluralization rules and does not
419
+ * require an active connection to Dataverse.
420
+ *
421
+ * @param entityLogicalName - The logical name of the Dataverse table (for example, "account").
422
+ * @returns The corresponding entity set name (for example, "accounts").
423
+ *
424
+ * @example
425
+ * const entitySetName = await dataverseAPI.getEntitySetName('account');
426
+ * console.log(entitySetName); // Output: "accounts"
427
+ *
428
+ * @example
429
+ * const entitySetName = await dataverseAPI.getEntitySetName('opportunity');
430
+ * console.log(entitySetName); // Output: "opportunities"
320
431
  */
321
- queryData: (odataQuery: string) => Promise<{ value: Record<string, unknown>[] }>;
432
+ getEntitySetName: (entityLogicalName: string) => Promise<string>;
322
433
  }
323
434
  }
324
435
 
package/package.json CHANGED
@@ -1,22 +1,22 @@
1
1
  {
2
- "name": "@pptb/types",
3
- "version": "1.0.10",
4
- "description": "TypeScript type definitions for Power Platform Tool Box API",
5
- "main": "index.d.ts",
6
- "types": "index.d.ts",
7
- "keywords": [
8
- "powerplatform",
9
- "pptb",
10
- "toolbox",
11
- "types",
12
- "typescript",
13
- "dataverse"
14
- ],
15
- "author": "Power Platform Tool Box",
16
- "license": "GPL-3.0",
17
- "repository": {
18
- "type": "git",
19
- "url": "https://github.com/PowerPlatformToolBox/desktop-app.git",
20
- "directory": "packages"
21
- }
22
- }
2
+ "name": "@pptb/types",
3
+ "version": "1.0.12",
4
+ "description": "TypeScript type definitions for Power Platform Tool Box API",
5
+ "main": "index.d.ts",
6
+ "types": "index.d.ts",
7
+ "keywords": [
8
+ "powerplatform",
9
+ "pptb",
10
+ "toolbox",
11
+ "types",
12
+ "typescript",
13
+ "dataverse"
14
+ ],
15
+ "author": "Power Platform Tool Box",
16
+ "license": "GPL-3.0",
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "https://github.com/PowerPlatformToolBox/desktop-app.git",
20
+ "directory": "packages"
21
+ }
22
+ }
package/toolboxAPI.d.ts CHANGED
@@ -12,6 +12,9 @@ declare namespace ToolBoxAPI {
12
12
  export interface ToolContext {
13
13
  toolId: string | null;
14
14
  connectionUrl: string | null;
15
+ connectionId?: string | null;
16
+ secondaryConnectionUrl?: string | null;
17
+ secondaryConnectionId?: string | null;
15
18
  }
16
19
 
17
20
  /**
@@ -62,6 +65,11 @@ declare namespace ToolBoxAPI {
62
65
  tenantId?: string;
63
66
  createdAt: string;
64
67
  lastUsedAt?: string;
68
+ /**
69
+ * @deprecated isActive is a legacy field that is no longer persisted.
70
+ * It may be present in older tool code but should not be relied upon.
71
+ * Use the connection context provided by the ToolBox API instead.
72
+ */
65
73
  isActive?: boolean;
66
74
  }
67
75
 
@@ -120,6 +128,21 @@ declare namespace ToolBoxAPI {
120
128
  * Get the currently active Dataverse connection
121
129
  */
122
130
  getActiveConnection: () => Promise<DataverseConnection | null>;
131
+
132
+ /**
133
+ * Get the secondary connection for multi-connection tools
134
+ */
135
+ getSecondaryConnection: () => Promise<DataverseConnection | null>;
136
+
137
+ /**
138
+ * Get the secondary connection URL for multi-connection tools
139
+ */
140
+ getSecondaryConnectionUrl: () => Promise<string | null>;
141
+
142
+ /**
143
+ * Get the secondary connection ID for multi-connection tools
144
+ */
145
+ getSecondaryConnectionId: () => Promise<string | null>;
123
146
  }
124
147
 
125
148
  /**