@pptb/types 1.0.19-beta.3 → 1.0.19

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 (2) hide show
  1. package/dataverseAPI.d.ts +640 -0
  2. package/package.json +1 -1
package/dataverseAPI.d.ts CHANGED
@@ -224,6 +224,92 @@ declare namespace DataverseAPI {
224
224
  parameters?: Record<string, unknown>;
225
225
  }
226
226
 
227
+ /**
228
+ * Localized label for metadata display names and descriptions
229
+ */
230
+ export interface LocalizedLabel {
231
+ "@odata.type"?: "Microsoft.Dynamics.CRM.LocalizedLabel";
232
+ Label: string;
233
+ LanguageCode: number;
234
+ }
235
+
236
+ /**
237
+ * Label structure for metadata properties
238
+ */
239
+ export interface Label {
240
+ "@odata.type"?: "Microsoft.Dynamics.CRM.Label";
241
+ LocalizedLabels: LocalizedLabel[];
242
+ UserLocalizedLabel?: LocalizedLabel;
243
+ }
244
+
245
+ /**
246
+ * Attribute metadata types for Dataverse columns
247
+ * Used with getAttributeODataType() to generate full Microsoft.Dynamics.CRM.*AttributeMetadata type strings
248
+ */
249
+ export enum AttributeMetadataType {
250
+ /** Single-line text field */
251
+ String = "String",
252
+ /** Multi-line text field */
253
+ Memo = "Memo",
254
+ /** Whole number */
255
+ Integer = "Integer",
256
+ /** Big integer (large whole number) */
257
+ BigInt = "BigInt",
258
+ /** Decimal number */
259
+ Decimal = "Decimal",
260
+ /** Floating point number */
261
+ Double = "Double",
262
+ /** Currency field */
263
+ Money = "Money",
264
+ /** Yes/No (boolean) field */
265
+ Boolean = "Boolean",
266
+ /** Date and time */
267
+ DateTime = "DateTime",
268
+ /** Lookup (foreign key reference) */
269
+ Lookup = "Lookup",
270
+ /** Choice (option set/picklist) */
271
+ Picklist = "Picklist",
272
+ /** Multi-select choice */
273
+ MultiSelectPicklist = "MultiSelectPicklist",
274
+ /** State field (active/inactive) */
275
+ State = "State",
276
+ /** Status field (status reason) */
277
+ Status = "Status",
278
+ /** Owner field */
279
+ Owner = "Owner",
280
+ /** Customer field (Account or Contact lookup) */
281
+ Customer = "Customer",
282
+ /** File attachment field */
283
+ File = "File",
284
+ /** Image field */
285
+ Image = "Image",
286
+ /** Unique identifier (GUID) */
287
+ UniqueIdentifier = "UniqueIdentifier",
288
+ }
289
+
290
+ /**
291
+ * Options for metadata CRUD operations
292
+ */
293
+ export interface MetadataOperationOptions {
294
+ /**
295
+ * Associate metadata changes with a specific solution
296
+ * Uses MSCRM.SolutionUniqueName header
297
+ */
298
+ solutionUniqueName?: string;
299
+
300
+ /**
301
+ * Preserve existing localized labels during PUT operations
302
+ * Uses MSCRM.MergeLabels header (defaults to true for updates)
303
+ */
304
+ mergeLabels?: boolean;
305
+
306
+ /**
307
+ * Force fresh metadata read after create/update operations
308
+ * Uses Consistency: Strong header to bypass cache
309
+ */
310
+ consistencyStrong?: boolean;
311
+ }
312
+
227
313
  /**
228
314
  * Dataverse Web API for CRUD operations, queries, and metadata
229
315
  */
@@ -849,6 +935,560 @@ declare namespace DataverseAPI {
849
935
  * const status = await dataverseAPI.getImportJobStatus(importJobId, 'secondary');
850
936
  */
851
937
  getImportJobStatus: (importJobId: string, connectionTarget?: "primary" | "secondary") => Promise<Record<string, unknown>>;
938
+
939
+ // ========================================
940
+ // Metadata Helper Utilities
941
+ // ========================================
942
+
943
+ /**
944
+ * Build a Label structure for metadata display names and descriptions
945
+ * Helper utility to simplify creating localized labels for metadata operations
946
+ *
947
+ * @param text - Display text for the label
948
+ * @param languageCode - Optional language code (defaults to 1033 for English)
949
+ * @returns Label object with properly formatted LocalizedLabels array
950
+ *
951
+ * @example
952
+ * const label = dataverseAPI.buildLabel("Account Name");
953
+ * // Returns: { LocalizedLabels: [{ Label: "Account Name", LanguageCode: 1033 }] }
954
+ *
955
+ * @example
956
+ * // Create label with specific language code
957
+ * const frenchLabel = dataverseAPI.buildLabel("Nom du compte", 1036);
958
+ */
959
+ buildLabel: (text: string, languageCode?: number) => Label;
960
+
961
+ /**
962
+ * Get the OData type string for an attribute metadata type
963
+ * Converts AttributeMetadataType enum to full Microsoft.Dynamics.CRM type path
964
+ *
965
+ * @param attributeType - Attribute metadata type enum value
966
+ * @returns Full OData type string (e.g., "Microsoft.Dynamics.CRM.StringAttributeMetadata")
967
+ *
968
+ * @example
969
+ * const odataType = dataverseAPI.getAttributeODataType(DataverseAPI.AttributeMetadataType.String);
970
+ * // Returns: "Microsoft.Dynamics.CRM.StringAttributeMetadata"
971
+ *
972
+ * @example
973
+ * // Use in attribute definition
974
+ * const attributeDef = {
975
+ * "@odata.type": dataverseAPI.getAttributeODataType(DataverseAPI.AttributeMetadataType.Integer),
976
+ * "SchemaName": "new_priority",
977
+ * "DisplayName": dataverseAPI.buildLabel("Priority")
978
+ * };
979
+ */
980
+ getAttributeODataType: (attributeType: AttributeMetadataType) => string;
981
+
982
+ // ========================================
983
+ // Entity (Table) Metadata CRUD Operations
984
+ // ========================================
985
+
986
+ /**
987
+ * Create a new entity (table) definition in Dataverse
988
+ * NOTE: Metadata changes require explicit publishCustomizations() call to become active
989
+ *
990
+ * @param entityDefinition - Entity metadata payload (must include SchemaName, DisplayName, OwnershipType, and at least one Attribute with IsPrimaryName=true)
991
+ * @param options - Optional metadata operation options (solution assignment, etc.)
992
+ * @param connectionTarget - Optional connection target for multi-connection tools ('primary' or 'secondary'). Defaults to 'primary'.
993
+ * @returns Object containing the created entity's MetadataId
994
+ *
995
+ * @example
996
+ * // Create a new custom table
997
+ * const result = await dataverseAPI.createEntityDefinition({
998
+ * "@odata.type": "Microsoft.Dynamics.CRM.EntityMetadata",
999
+ * "SchemaName": "new_project",
1000
+ * "DisplayName": dataverseAPI.buildLabel("Project"),
1001
+ * "DisplayCollectionName": dataverseAPI.buildLabel("Projects"),
1002
+ * "Description": dataverseAPI.buildLabel("Project tracking table"),
1003
+ * "OwnershipType": "UserOwned",
1004
+ * "HasActivities": true,
1005
+ * "HasNotes": true,
1006
+ * "Attributes": [{
1007
+ * "@odata.type": dataverseAPI.getAttributeODataType(DataverseAPI.AttributeMetadataType.String),
1008
+ * "SchemaName": "new_name",
1009
+ * "RequiredLevel": { "Value": "None" },
1010
+ * "MaxLength": 100,
1011
+ * "FormatName": { "Value": "Text" },
1012
+ * "IsPrimaryName": true,
1013
+ * "DisplayName": dataverseAPI.buildLabel("Project Name"),
1014
+ * "Description": dataverseAPI.buildLabel("The name of the project")
1015
+ * }]
1016
+ * }, {
1017
+ * solutionUniqueName: "MySolution"
1018
+ * });
1019
+ *
1020
+ * console.log("Created entity with MetadataId:", result.id);
1021
+ *
1022
+ * // IMPORTANT: Publish customizations to make changes active
1023
+ * await dataverseAPI.publishCustomizations("new_project");
1024
+ */
1025
+ createEntityDefinition: (entityDefinition: Record<string, unknown>, options?: MetadataOperationOptions, connectionTarget?: "primary" | "secondary") => Promise<{ id: string }>;
1026
+
1027
+ /**
1028
+ * Update an entity (table) definition
1029
+ * NOTE: Uses PUT method which requires the FULL entity definition (retrieve-modify-PUT pattern)
1030
+ * NOTE: Metadata changes require explicit publishCustomizations() call to become active
1031
+ *
1032
+ * @param entityIdentifier - Entity LogicalName or MetadataId
1033
+ * @param entityDefinition - Complete entity metadata payload with all properties
1034
+ * @param options - Optional metadata operation options (mergeLabels defaults to true to preserve translations)
1035
+ * @param connectionTarget - Optional connection target for multi-connection tools ('primary' or 'secondary'). Defaults to 'primary'.
1036
+ *
1037
+ * @example
1038
+ * // Retrieve-Modify-PUT Pattern for updating entity metadata
1039
+ *
1040
+ * // Step 1: Retrieve current entity definition
1041
+ * const currentDef = await dataverseAPI.getEntityMetadata("new_project", true);
1042
+ *
1043
+ * // Step 2: Modify desired properties (must include ALL properties, not just changes)
1044
+ * currentDef.DisplayName = dataverseAPI.buildLabel("Updated Project Name");
1045
+ * currentDef.Description = dataverseAPI.buildLabel("Updated description");
1046
+ *
1047
+ * // Step 3: PUT the entire definition back (mergeLabels=true preserves other language translations)
1048
+ * await dataverseAPI.updateEntityDefinition("new_project", currentDef, {
1049
+ * mergeLabels: true, // Preserve existing translations
1050
+ * solutionUniqueName: "MySolution"
1051
+ * });
1052
+ *
1053
+ * // Step 4: Publish customizations to activate changes
1054
+ * await dataverseAPI.publishCustomizations("new_project");
1055
+ *
1056
+ * @example
1057
+ * // Update using MetadataId instead of LogicalName
1058
+ * await dataverseAPI.updateEntityDefinition(
1059
+ * "70816501-edb9-4740-a16c-6a5efbc05d84",
1060
+ * updatedDefinition,
1061
+ * { mergeLabels: true }
1062
+ * );
1063
+ */
1064
+ updateEntityDefinition: (entityIdentifier: string, entityDefinition: Record<string, unknown>, options?: MetadataOperationOptions, connectionTarget?: "primary" | "secondary") => Promise<void>;
1065
+
1066
+ /**
1067
+ * Delete an entity (table) definition
1068
+ * WARNING: This is a destructive operation that removes the table and all its data
1069
+ *
1070
+ * @param entityIdentifier - Entity LogicalName or MetadataId
1071
+ * @param connectionTarget - Optional connection target for multi-connection tools ('primary' or 'secondary'). Defaults to 'primary'.
1072
+ *
1073
+ * @example
1074
+ * // Delete a custom table (will fail if dependencies exist)
1075
+ * await dataverseAPI.deleteEntityDefinition("new_project");
1076
+ *
1077
+ * @example
1078
+ * // Delete using MetadataId
1079
+ * await dataverseAPI.deleteEntityDefinition("70816501-edb9-4740-a16c-6a5efbc05d84");
1080
+ */
1081
+ deleteEntityDefinition: (entityIdentifier: string, connectionTarget?: "primary" | "secondary") => Promise<void>;
1082
+
1083
+ // ========================================
1084
+ // Attribute (Column) Metadata CRUD Operations
1085
+ // ========================================
1086
+
1087
+ /**
1088
+ * Create a new attribute (column) on an existing entity
1089
+ * NOTE: Metadata changes require explicit publishCustomizations() call to become active
1090
+ *
1091
+ * @param entityLogicalName - Logical name of the entity to add the attribute to
1092
+ * @param attributeDefinition - Attribute metadata payload (must include @odata.type, SchemaName, DisplayName)
1093
+ * @param options - Optional metadata operation options
1094
+ * @param connectionTarget - Optional connection target for multi-connection tools ('primary' or 'secondary'). Defaults to 'primary'.
1095
+ * @returns Object containing the created attribute's MetadataId
1096
+ *
1097
+ * @example
1098
+ * // Create a text column
1099
+ * const result = await dataverseAPI.createAttribute("new_project", {
1100
+ * "@odata.type": dataverseAPI.getAttributeODataType(DataverseAPI.AttributeMetadataType.String),
1101
+ * "SchemaName": "new_description",
1102
+ * "DisplayName": dataverseAPI.buildLabel("Description"),
1103
+ * "Description": dataverseAPI.buildLabel("Project description"),
1104
+ * "RequiredLevel": { "Value": "None" },
1105
+ * "MaxLength": 500,
1106
+ * "FormatName": { "Value": "Text" }
1107
+ * }, {
1108
+ * solutionUniqueName: "MySolution"
1109
+ * });
1110
+ *
1111
+ * console.log("Created attribute with MetadataId:", result.id);
1112
+ * await dataverseAPI.publishCustomizations("new_project");
1113
+ *
1114
+ * @example
1115
+ * // Create a whole number column
1116
+ * await dataverseAPI.createAttribute("new_project", {
1117
+ * "@odata.type": dataverseAPI.getAttributeODataType(DataverseAPI.AttributeMetadataType.Integer),
1118
+ * "SchemaName": "new_priority",
1119
+ * "DisplayName": dataverseAPI.buildLabel("Priority"),
1120
+ * "RequiredLevel": { "Value": "None" },
1121
+ * "MinValue": 1,
1122
+ * "MaxValue": 100
1123
+ * });
1124
+ * await dataverseAPI.publishCustomizations("new_project");
1125
+ *
1126
+ * @example
1127
+ * // Create a choice (picklist) column
1128
+ * await dataverseAPI.createAttribute("new_project", {
1129
+ * "@odata.type": dataverseAPI.getAttributeODataType(DataverseAPI.AttributeMetadataType.Picklist),
1130
+ * "SchemaName": "new_status",
1131
+ * "DisplayName": dataverseAPI.buildLabel("Status"),
1132
+ * "RequiredLevel": { "Value": "None" },
1133
+ * "OptionSet": {
1134
+ * "@odata.type": "Microsoft.Dynamics.CRM.OptionSetMetadata",
1135
+ * "OptionSetType": "Picklist",
1136
+ * "Options": [
1137
+ * { "Value": 1, "Label": dataverseAPI.buildLabel("Active") },
1138
+ * { "Value": 2, "Label": dataverseAPI.buildLabel("On Hold") },
1139
+ * { "Value": 3, "Label": dataverseAPI.buildLabel("Completed") }
1140
+ * ]
1141
+ * }
1142
+ * });
1143
+ * await dataverseAPI.publishCustomizations("new_project");
1144
+ */
1145
+ createAttribute: (entityLogicalName: string, attributeDefinition: Record<string, unknown>, options?: MetadataOperationOptions, connectionTarget?: "primary" | "secondary") => Promise<{ id: string }>;
1146
+
1147
+ /**
1148
+ * Update an attribute (column) definition
1149
+ * NOTE: Uses PUT method which requires the FULL attribute definition (retrieve-modify-PUT pattern)
1150
+ * NOTE: Metadata changes require explicit publishCustomizations() call to become active
1151
+ *
1152
+ * @param entityLogicalName - Logical name of the entity
1153
+ * @param attributeIdentifier - Attribute LogicalName or MetadataId
1154
+ * @param attributeDefinition - Complete attribute metadata payload
1155
+ * @param options - Optional metadata operation options (mergeLabels defaults to true)
1156
+ * @param connectionTarget - Optional connection target for multi-connection tools ('primary' or 'secondary'). Defaults to 'primary'.
1157
+ *
1158
+ * @example
1159
+ * // Retrieve-Modify-PUT Pattern for updating attribute metadata
1160
+ *
1161
+ * // Step 1: Retrieve current attribute definition
1162
+ * const currentAttr = await dataverseAPI.getEntityRelatedMetadata(
1163
+ * "new_project",
1164
+ * "Attributes(LogicalName='new_description')"
1165
+ * );
1166
+ *
1167
+ * // Step 2: Modify desired properties
1168
+ * currentAttr.DisplayName = dataverseAPI.buildLabel("Updated Description");
1169
+ * currentAttr.MaxLength = 1000; // Increase max length
1170
+ *
1171
+ * // Step 3: PUT entire definition back
1172
+ * await dataverseAPI.updateAttribute(
1173
+ * "new_project",
1174
+ * "new_description",
1175
+ * currentAttr,
1176
+ * { mergeLabels: true }
1177
+ * );
1178
+ *
1179
+ * // Step 4: Publish customizations
1180
+ * await dataverseAPI.publishCustomizations("new_project");
1181
+ */
1182
+ updateAttribute: (entityLogicalName: string, attributeIdentifier: string, attributeDefinition: Record<string, unknown>, options?: MetadataOperationOptions, connectionTarget?: "primary" | "secondary") => Promise<void>;
1183
+
1184
+ /**
1185
+ * Delete an attribute (column) from an entity
1186
+ * WARNING: This is a destructive operation that removes the column and all its data
1187
+ *
1188
+ * @param entityLogicalName - Logical name of the entity
1189
+ * @param attributeIdentifier - Attribute LogicalName or MetadataId
1190
+ * @param connectionTarget - Optional connection target for multi-connection tools ('primary' or 'secondary'). Defaults to 'primary'.
1191
+ *
1192
+ * @example
1193
+ * await dataverseAPI.deleteAttribute("new_project", "new_description");
1194
+ *
1195
+ * @example
1196
+ * // Delete using MetadataId
1197
+ * await dataverseAPI.deleteAttribute("new_project", "00aa00aa-bb11-cc22-dd33-44ee44ee44ee");
1198
+ */
1199
+ deleteAttribute: (entityLogicalName: string, attributeIdentifier: string, connectionTarget?: "primary" | "secondary") => Promise<void>;
1200
+
1201
+ /**
1202
+ * Create a polymorphic lookup attribute (Customer/Regarding field)
1203
+ * Creates a lookup that can reference multiple entity types
1204
+ * NOTE: Metadata changes require explicit publishCustomizations() call to become active
1205
+ *
1206
+ * @param entityLogicalName - Logical name of the entity to add the attribute to
1207
+ * @param attributeDefinition - Lookup attribute metadata with Targets array
1208
+ * @param options - Optional metadata operation options
1209
+ * @returns Object containing the created attribute's MetadataId
1210
+ * @param connectionTarget - Optional connection target ("primary" or "secondary")
1211
+ *
1212
+ * @example
1213
+ * // Create a Customer lookup (Account or Contact)
1214
+ * const result = await dataverseAPI.createPolymorphicLookupAttribute("new_order", {
1215
+ * "@odata.type": "Microsoft.Dynamics.CRM.LookupAttributeMetadata",
1216
+ * "SchemaName": "new_CustomerId",
1217
+ * "LogicalName": "new_customerid",
1218
+ * "DisplayName": buildLabel("Customer"),
1219
+ * "Description": buildLabel("Customer for this order"),
1220
+ * "RequiredLevel": { Value: "None", CanBeChanged: true, ManagedPropertyLogicalName: "canmodifyrequirementlevelsettings" },
1221
+ * "AttributeType": "Lookup",
1222
+ * "AttributeTypeName": { Value: "LookupType" },
1223
+ * "Targets": ["account", "contact"]
1224
+ * });
1225
+ * await dataverseAPI.publishCustomizations();
1226
+ */
1227
+ createPolymorphicLookupAttribute: (
1228
+ entityLogicalName: string,
1229
+ attributeDefinition: Record<string, unknown>,
1230
+ options?: Record<string, unknown>,
1231
+ connectionTarget?: "primary" | "secondary",
1232
+ ) => Promise<{ AttributeId: string }>;
1233
+
1234
+ // ========================================
1235
+ // Relationship Metadata CRUD Operations
1236
+ // ========================================
1237
+
1238
+ /**
1239
+ * Create a new relationship (1:N or N:N)
1240
+ * NOTE: Metadata changes require explicit publishCustomizations() call to become active
1241
+ *
1242
+ * @param relationshipDefinition - Relationship metadata payload (must include @odata.type for OneToManyRelationshipMetadata or ManyToManyRelationshipMetadata)
1243
+ * @param options - Optional metadata operation options
1244
+ * @param connectionTarget - Optional connection target for multi-connection tools ('primary' or 'secondary'). Defaults to 'primary'.
1245
+ * @returns Object containing the created relationship's MetadataId
1246
+ *
1247
+ * @example
1248
+ * // Create 1:N relationship (Project -> Tasks)
1249
+ * const result = await dataverseAPI.createRelationship({
1250
+ * "@odata.type": "Microsoft.Dynamics.CRM.OneToManyRelationshipMetadata",
1251
+ * "SchemaName": "new_project_tasks",
1252
+ * "ReferencedEntity": "new_project",
1253
+ * "ReferencedAttribute": "new_projectid",
1254
+ * "ReferencingEntity": "task",
1255
+ * "CascadeConfiguration": {
1256
+ * "Assign": "NoCascade",
1257
+ * "Delete": "RemoveLink",
1258
+ * "Merge": "NoCascade",
1259
+ * "Reparent": "NoCascade",
1260
+ * "Share": "NoCascade",
1261
+ * "Unshare": "NoCascade"
1262
+ * },
1263
+ * "Lookup": {
1264
+ * "@odata.type": dataverseAPI.getAttributeODataType(DataverseAPI.AttributeMetadataType.Lookup),
1265
+ * "SchemaName": "new_projectid",
1266
+ * "DisplayName": dataverseAPI.buildLabel("Project"),
1267
+ * "RequiredLevel": { "Value": "None" }
1268
+ * }
1269
+ * }, {
1270
+ * solutionUniqueName: "MySolution"
1271
+ * });
1272
+ *
1273
+ * await dataverseAPI.publishCustomizations();
1274
+ *
1275
+ * @example
1276
+ * // Create N:N relationship (Projects <-> Users)
1277
+ * await dataverseAPI.createRelationship({
1278
+ * "@odata.type": "Microsoft.Dynamics.CRM.ManyToManyRelationshipMetadata",
1279
+ * "SchemaName": "new_project_systemuser",
1280
+ * "Entity1LogicalName": "new_project",
1281
+ * "Entity2LogicalName": "systemuser",
1282
+ * "IntersectEntityName": "new_project_systemuser"
1283
+ * });
1284
+ * await dataverseAPI.publishCustomizations();
1285
+ */
1286
+ createRelationship: (relationshipDefinition: Record<string, unknown>, options?: MetadataOperationOptions, connectionTarget?: "primary" | "secondary") => Promise<{ id: string }>;
1287
+
1288
+ /**
1289
+ * Update a relationship definition
1290
+ * NOTE: Uses PUT method which requires the FULL relationship definition (retrieve-modify-PUT pattern)
1291
+ * NOTE: Metadata changes require explicit publishCustomizations() call to become active
1292
+ *
1293
+ * @param relationshipIdentifier - Relationship SchemaName or MetadataId
1294
+ * @param relationshipDefinition - Complete relationship metadata payload
1295
+ * @param options - Optional metadata operation options (mergeLabels defaults to true)
1296
+ * @param connectionTarget - Optional connection target for multi-connection tools ('primary' or 'secondary'). Defaults to 'primary'.
1297
+ */
1298
+ updateRelationship: (relationshipIdentifier: string, relationshipDefinition: Record<string, unknown>, options?: MetadataOperationOptions, connectionTarget?: "primary" | "secondary") => Promise<void>;
1299
+
1300
+ /**
1301
+ * Delete a relationship
1302
+ * WARNING: This removes the relationship and any associated lookup columns
1303
+ *
1304
+ * @param relationshipIdentifier - Relationship SchemaName or MetadataId
1305
+ * @param connectionTarget - Optional connection target for multi-connection tools ('primary' or 'secondary'). Defaults to 'primary'.
1306
+ *
1307
+ * @example
1308
+ * await dataverseAPI.deleteRelationship("new_project_tasks");
1309
+ */
1310
+ deleteRelationship: (relationshipIdentifier: string, connectionTarget?: "primary" | "secondary") => Promise<void>;
1311
+
1312
+ // ========================================
1313
+ // Global Option Set (Choice) CRUD Operations
1314
+ // ========================================
1315
+
1316
+ /**
1317
+ * Create a new global option set (global choice)
1318
+ * NOTE: Metadata changes require explicit publishCustomizations() call to become active
1319
+ *
1320
+ * @param optionSetDefinition - Global option set metadata payload
1321
+ * @param options - Optional metadata operation options
1322
+ * @param connectionTarget - Optional connection target for multi-connection tools ('primary' or 'secondary'). Defaults to 'primary'.
1323
+ * @returns Object containing the created option set's MetadataId
1324
+ *
1325
+ * @example
1326
+ * const result = await dataverseAPI.createGlobalOptionSet({
1327
+ * "@odata.type": "Microsoft.Dynamics.CRM.OptionSetMetadata",
1328
+ * "Name": "new_projectstatus",
1329
+ * "DisplayName": dataverseAPI.buildLabel("Project Status"),
1330
+ * "Description": dataverseAPI.buildLabel("Global choice for project status"),
1331
+ * "OptionSetType": "Picklist",
1332
+ * "IsGlobal": true,
1333
+ * "Options": [
1334
+ * { "Value": 1, "Label": dataverseAPI.buildLabel("Active") },
1335
+ * { "Value": 2, "Label": dataverseAPI.buildLabel("On Hold") },
1336
+ * { "Value": 3, "Label": dataverseAPI.buildLabel("Completed") },
1337
+ * { "Value": 4, "Label": dataverseAPI.buildLabel("Cancelled") }
1338
+ * ]
1339
+ * }, {
1340
+ * solutionUniqueName: "MySolution"
1341
+ * });
1342
+ *
1343
+ * await dataverseAPI.publishCustomizations();
1344
+ */
1345
+ createGlobalOptionSet: (optionSetDefinition: Record<string, unknown>, options?: MetadataOperationOptions, connectionTarget?: "primary" | "secondary") => Promise<{ id: string }>;
1346
+
1347
+ /**
1348
+ * Update a global option set definition
1349
+ * NOTE: Uses PUT method which requires the FULL option set definition (retrieve-modify-PUT pattern)
1350
+ * NOTE: Metadata changes require explicit publishCustomizations() call to become active
1351
+ *
1352
+ * @param optionSetIdentifier - Option set Name or MetadataId
1353
+ * @param optionSetDefinition - Complete option set metadata payload
1354
+ * @param options - Optional metadata operation options (mergeLabels defaults to true)
1355
+ * @param connectionTarget - Optional connection target for multi-connection tools ('primary' or 'secondary'). Defaults to 'primary'.
1356
+ */
1357
+ updateGlobalOptionSet: (optionSetIdentifier: string, optionSetDefinition: Record<string, unknown>, options?: MetadataOperationOptions, connectionTarget?: "primary" | "secondary") => Promise<void>;
1358
+
1359
+ /**
1360
+ * Delete a global option set
1361
+ * WARNING: This will fail if any attributes reference this global option set
1362
+ *
1363
+ * @param optionSetIdentifier - Option set Name or MetadataId
1364
+ * @param connectionTarget - Optional connection target for multi-connection tools ('primary' or 'secondary'). Defaults to 'primary'.
1365
+ *
1366
+ * @example
1367
+ * await dataverseAPI.deleteGlobalOptionSet("new_projectstatus");
1368
+ */
1369
+ deleteGlobalOptionSet: (optionSetIdentifier: string, connectionTarget?: "primary" | "secondary") => Promise<void>;
1370
+
1371
+ // ========================================
1372
+ // Option Value Modification Actions
1373
+ // ========================================
1374
+
1375
+ /**
1376
+ * Insert a new option value into a local or global option set
1377
+ * NOTE: Works for both local option sets (specify EntityLogicalName + AttributeLogicalName)
1378
+ * and global option sets (specify OptionSetName)
1379
+ * NOTE: Metadata changes require explicit publishCustomizations() call to become active
1380
+ *
1381
+ * @param params - Parameters for inserting the option value
1382
+ * @param connectionTarget - Optional connection target for multi-connection tools ('primary' or 'secondary'). Defaults to 'primary'.
1383
+ * @returns Result of the insert operation
1384
+ *
1385
+ * @example
1386
+ * // Insert into local option set on an entity
1387
+ * await dataverseAPI.insertOptionValue({
1388
+ * EntityLogicalName: "new_project",
1389
+ * AttributeLogicalName: "new_priority",
1390
+ * Value: 4,
1391
+ * Label: dataverseAPI.buildLabel("Critical"),
1392
+ * Description: dataverseAPI.buildLabel("Highest priority level")
1393
+ * });
1394
+ * await dataverseAPI.publishCustomizations("new_project");
1395
+ *
1396
+ * @example
1397
+ * // Insert into global option set
1398
+ * await dataverseAPI.insertOptionValue({
1399
+ * OptionSetName: "new_projectstatus",
1400
+ * Value: 5,
1401
+ * Label: dataverseAPI.buildLabel("Archived"),
1402
+ * SolutionUniqueName: "MySolution"
1403
+ * });
1404
+ * await dataverseAPI.publishCustomizations();
1405
+ */
1406
+ insertOptionValue: (params: Record<string, unknown>, connectionTarget?: "primary" | "secondary") => Promise<Record<string, unknown>>;
1407
+
1408
+ /**
1409
+ * Update an existing option value in a local or global option set
1410
+ * NOTE: Metadata changes require explicit publishCustomizations() call to become active
1411
+ *
1412
+ * @param params - Parameters for updating the option value
1413
+ * @param connectionTarget - Optional connection target for multi-connection tools ('primary' or 'secondary'). Defaults to 'primary'.
1414
+ * @returns Result of the update operation
1415
+ *
1416
+ * @example
1417
+ * // Update option label in local option set
1418
+ * await dataverseAPI.updateOptionValue({
1419
+ * EntityLogicalName: "new_project",
1420
+ * AttributeLogicalName: "new_priority",
1421
+ * Value: 4,
1422
+ * Label: dataverseAPI.buildLabel("High Priority"),
1423
+ * MergeLabels: true // Preserve other language translations
1424
+ * });
1425
+ * await dataverseAPI.publishCustomizations("new_project");
1426
+ *
1427
+ * @example
1428
+ * // Update option in global option set
1429
+ * await dataverseAPI.updateOptionValue({
1430
+ * OptionSetName: "new_projectstatus",
1431
+ * Value: 5,
1432
+ * Label: dataverseAPI.buildLabel("Closed"),
1433
+ * MergeLabels: true
1434
+ * });
1435
+ * await dataverseAPI.publishCustomizations();
1436
+ */
1437
+ updateOptionValue: (params: Record<string, unknown>, connectionTarget?: "primary" | "secondary") => Promise<Record<string, unknown>>;
1438
+
1439
+ /**
1440
+ * Delete an option value from a local or global option set
1441
+ * NOTE: Metadata changes require explicit publishCustomizations() call to become active
1442
+ *
1443
+ * @param params - Parameters for deleting the option value
1444
+ * @param connectionTarget - Optional connection target for multi-connection tools ('primary' or 'secondary'). Defaults to 'primary'.
1445
+ * @returns Result of the delete operation
1446
+ *
1447
+ * @example
1448
+ * // Delete option from local option set
1449
+ * await dataverseAPI.deleteOptionValue({
1450
+ * EntityLogicalName: "new_project",
1451
+ * AttributeLogicalName: "new_priority",
1452
+ * Value: 4
1453
+ * });
1454
+ * await dataverseAPI.publishCustomizations("new_project");
1455
+ *
1456
+ * @example
1457
+ * // Delete option from global option set
1458
+ * await dataverseAPI.deleteOptionValue({
1459
+ * OptionSetName: "new_projectstatus",
1460
+ * Value: 5
1461
+ * });
1462
+ * await dataverseAPI.publishCustomizations();
1463
+ */
1464
+ deleteOptionValue: (params: Record<string, unknown>, connectionTarget?: "primary" | "secondary") => Promise<Record<string, unknown>>;
1465
+
1466
+ /**
1467
+ * Reorder options in a local or global option set
1468
+ * NOTE: Metadata changes require explicit publishCustomizations() call to become active
1469
+ *
1470
+ * @param params - Parameters for ordering options
1471
+ * @param connectionTarget - Optional connection target for multi-connection tools ('primary' or 'secondary'). Defaults to 'primary'.
1472
+ * @returns Result of the order operation
1473
+ *
1474
+ * @example
1475
+ * // Reorder options in local option set
1476
+ * await dataverseAPI.orderOption({
1477
+ * EntityLogicalName: "new_project",
1478
+ * AttributeLogicalName: "new_priority",
1479
+ * Values: [3, 1, 2, 4] // Reorder by option values
1480
+ * });
1481
+ * await dataverseAPI.publishCustomizations("new_project");
1482
+ *
1483
+ * @example
1484
+ * // Reorder global option set
1485
+ * await dataverseAPI.orderOption({
1486
+ * OptionSetName: "new_projectstatus",
1487
+ * Values: [1, 2, 3, 5, 4]
1488
+ * });
1489
+ * await dataverseAPI.publishCustomizations();
1490
+ */
1491
+ orderOption: (params: Record<string, unknown>, connectionTarget?: "primary" | "secondary") => Promise<Record<string, unknown>>;
852
1492
  }
853
1493
  }
854
1494
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pptb/types",
3
- "version": "1.0.19-beta.3",
3
+ "version": "1.0.19",
4
4
  "description": "TypeScript type definitions for Power Platform ToolBox API",
5
5
  "main": "index.d.ts",
6
6
  "types": "index.d.ts",