@js4cytoscape/ndex-client 0.5.0-alpha.9 → 0.6.0-alpha.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.
@@ -0,0 +1,427 @@
1
+ import { HTTPService } from './HTTPService';
2
+ import {
3
+ NetworkSummaryV2,
4
+ NetworkPermission,
5
+ PaginationParams,
6
+ AccessParams,
7
+ CX1MetaDataResponse,
8
+ AccessKeyResponse,
9
+ AccessKeyAction
10
+ } from '../types';
11
+
12
+ /**
13
+ * NetworkServiceV2 - NDEx API v2 network operations
14
+ * Handles legacy v2 endpoints with modern TypeScript interface
15
+ */
16
+ export class NetworkServiceV2 {
17
+ constructor(private http: HTTPService) {}
18
+
19
+ /**
20
+ * Get raw network in CX1 format
21
+ *
22
+ * Returns raw CX1 data as an array of aspects. This data may contain fragmented aspects
23
+ * that need to be assembled into a complete CX1 network model for proper usage.
24
+ * For a fully assembled network object, consider using getNetworkAsCX2Object() instead.
25
+ *
26
+ * @param networkUUID - The UUID of the network to retrieve
27
+ * @param options - Access options including optional access key
28
+ * @returns Promise resolving to raw CX1 data as an array of aspects
29
+ */
30
+ async getRawCX1Network(
31
+ networkUUID: string,
32
+ options: AccessParams = {}
33
+ ): Promise<any[]> {
34
+ const params = new URLSearchParams();
35
+ if (options.accesskey) {
36
+ params.append('accesskey', options.accesskey);
37
+ }
38
+
39
+ const endpoint = `network/${networkUUID}${params.toString() ? `?${params.toString()}` : ''}`;
40
+ return this.http.get<any[]>(endpoint, {
41
+ version: 'v2',
42
+ headers: { 'Accept': 'application/json' }
43
+ });
44
+ }
45
+
46
+ /**
47
+ * Get network summary by UUID
48
+ */
49
+ async getNetworkSummary(
50
+ networkUUID: string,
51
+ options: AccessParams = {}
52
+ ): Promise<NetworkSummaryV2> {
53
+ const params = new URLSearchParams();
54
+ if (options.accesskey) {
55
+ params.append('accesskey', options.accesskey);
56
+ }
57
+
58
+ const endpoint = `network/${networkUUID}/summary${params.toString() ? `?${params.toString()}` : ''}`;
59
+ return this.http.get<NetworkSummaryV2>(endpoint, { version: 'v2' });
60
+ }
61
+
62
+ /**
63
+ * Copy network
64
+ *
65
+ * Creates a copy of an existing network using the server's copy endpoint.
66
+ * The copied network will have the same content but will be assigned a new UUID
67
+ * and will be owned by the authenticated user.
68
+ *
69
+ * @param networkUUID - The UUID of the network to copy
70
+ * @returns Promise resolving to the URL of the cloned CX1 network
71
+ */
72
+ async copyNetwork(networkUUID: string): Promise<string> {
73
+ const endpoint = `network/${networkUUID}/copy`;
74
+ return this.http.post<string>(endpoint, {}, {
75
+ version: 'v2'
76
+ });
77
+ }
78
+
79
+
80
+ /**
81
+ * Search networks (migrated from original NDEx.js)
82
+ *
83
+ * Searches networks using POST request with search parameters in the request body.
84
+ * This implementation matches the original NDEx.js searchNetworks function.
85
+ *
86
+ * @param searchTerms - Search string to find networks
87
+ * @param start - Starting offset for pagination (optional)
88
+ * @param size - Maximum number of results to return (optional)
89
+ * @param optionalParameters - Additional search filters
90
+ * @param optionalParameters.permission - Filter by permission level
91
+ * @param optionalParameters.includeGroups - Whether to include group networks
92
+ * @param optionalParameters.accountName - Filter by account name
93
+ * @returns Promise resolving to search results
94
+ */
95
+ async searchNetworks(
96
+ searchTerms: string,
97
+ start?: number,
98
+ size?: number,
99
+ optionalParameters?: {
100
+ permission?: string;
101
+ includeGroups?: boolean;
102
+ accountName?: string;
103
+ }
104
+ ): Promise<any> {
105
+ const params: Record<string, string> = {};
106
+
107
+ if (start !== undefined) {
108
+ params.start = start.toString();
109
+ }
110
+ if (size !== undefined) {
111
+ params.limit = size.toString();
112
+ }
113
+
114
+ const data: Record<string, any> = { searchString: searchTerms };
115
+
116
+ if (optionalParameters !== undefined) {
117
+ if (optionalParameters.permission !== undefined) {
118
+ data.permission = optionalParameters.permission;
119
+ }
120
+ if (optionalParameters.includeGroups !== undefined) {
121
+ data.includeGroups = optionalParameters.includeGroups;
122
+ }
123
+ if (optionalParameters.accountName !== undefined) {
124
+ data.accountName = optionalParameters.accountName;
125
+ }
126
+ }
127
+
128
+ const endpoint = 'search/network';
129
+ return this.http.post<any>(endpoint, data, {
130
+ version: 'v2',
131
+ params
132
+ });
133
+ }
134
+
135
+
136
+
137
+ /**
138
+ * Create new network from raw CX1 data
139
+ *
140
+ * Creates a new network in NDEx from raw CX1 network data. This method handles
141
+ * the server response parsing to extract the network UUID from the location header.
142
+ *
143
+ * @param rawCX - Raw CX1 network data as an array of aspects
144
+ * @param options - Optional options for network creation (visibility settings)
145
+ * @returns Promise resolving to the UUID string of the newly created network
146
+ */
147
+ async createNetworkFromRawCX1(
148
+ rawCX: any[],
149
+ options: { visibility?: 'PUBLIC' | 'PRIVATE' } = {}
150
+ ): Promise<string> {
151
+ const endpoint = 'network';
152
+ const response = await this.http.post<string>(endpoint, rawCX, {
153
+ version: 'v2',
154
+ params: options
155
+ });
156
+
157
+ // Extract UUID from response URL (e.g., "/v2/network/12345" -> "12345")
158
+ const uuidr = response.split('/');
159
+ const uuid = uuidr[uuidr.length - 1];
160
+
161
+ return uuid;
162
+ }
163
+
164
+
165
+ /**
166
+ * Update network from raw CX1 data
167
+ *
168
+ * Updates an existing network in NDEx with new raw CX1 network data.
169
+ * This completely replaces the network content with the provided CX1 data.
170
+ * Uses the legacy v2 endpoint format from the original NDEx.js implementation.
171
+ *
172
+ * @param networkUUID - The UUID of the network to update
173
+ * @param rawCX - Raw CX1 network data as an array of aspects
174
+ * @returns Promise resolving when the update is complete
175
+ */
176
+ async updateNetworkFromRawCX1(
177
+ networkUUID: string,
178
+ rawCX: any[]
179
+ ): Promise<void> {
180
+ const endpoint = `network/${networkUUID}`;
181
+ return this.http.put<void>(endpoint, rawCX, { version: 'v2' });
182
+ }
183
+
184
+ /**
185
+ * Delete network
186
+ */
187
+ async deleteNetwork(networkUUID: string): Promise<void> {
188
+ const endpoint = `network/${networkUUID}`;
189
+ return this.http.delete<void>(endpoint, { version: 'v2' });
190
+ }
191
+
192
+ /**
193
+ * Get network summaries by UUIDs (migrated from original NDEx.js)
194
+ *
195
+ * Retrieves network summaries for multiple networks in a single batch request.
196
+ * Uses the V2 API batch endpoint for efficient bulk operations.
197
+ *
198
+ * @param uuidList - Array of network UUIDs to retrieve summaries for
199
+ * @param accessKey - Optional access key for private networks
200
+ * @returns Promise resolving to array of network summaries
201
+ */
202
+ async getNetworkSummariesByUUIDs(
203
+ uuidList: string[],
204
+ accessKey?: string
205
+ ): Promise<NetworkSummaryV2[]> {
206
+ const params = accessKey ? { accesskey: accessKey } : undefined;
207
+
208
+ const endpoint = 'batch/network/summary';
209
+ return this.http.post<NetworkSummaryV2[]>(endpoint, uuidList, {
210
+ version: 'v2',
211
+ params
212
+ });
213
+ }
214
+
215
+ // The following functions need to be either reviewed or removed.
216
+
217
+
218
+ /**
219
+ * Get user's networks
220
+ */
221
+ async getUserNetworks(
222
+ accountName: string,
223
+ options: PaginationParams = {}
224
+ ): Promise<NetworkSummaryV2[]> {
225
+ const params = new URLSearchParams();
226
+ if (options.start !== undefined) {
227
+ params.append('start', options.start.toString());
228
+ }
229
+ if (options.size !== undefined) {
230
+ params.append('size', options.size.toString());
231
+ }
232
+
233
+ const endpoint = `user/${accountName}/networks${params.toString() ? `?${params.toString()}` : ''}`;
234
+ return this.http.get<NetworkSummaryV2[]>(endpoint, { version: 'v2' });
235
+ }
236
+
237
+
238
+ /**
239
+ * Set network system properties
240
+ */
241
+ async setNetworkSystemProperties(
242
+ networkUUID: string,
243
+ properties: Record<string, any>
244
+ ): Promise<void> {
245
+ const endpoint = `networks/${networkUUID}/systemproperty`;
246
+ return this.http.put<void>(endpoint, properties, { version: 'v2' });
247
+ }
248
+
249
+ /**
250
+ * Get network permissions
251
+ */
252
+ async getNetworkPermissions(networkUUID: string): Promise<NetworkPermission[]> {
253
+ const endpoint = `networks/${networkUUID}/permission`;
254
+ return this.http.get<NetworkPermission[]>(endpoint, { version: 'v2' });
255
+ }
256
+
257
+ /**
258
+ * Set network permissions
259
+ */
260
+ async setNetworkPermissions(
261
+ networkUUID: string,
262
+ permissions: NetworkPermission[]
263
+ ): Promise<void> {
264
+ const endpoint = `networks/${networkUUID}/permission`;
265
+ return this.http.put<void>(endpoint, permissions, { version: 'v2' });
266
+ }
267
+
268
+ /**
269
+ * Grant network permission to user
270
+ */
271
+ async grantNetworkPermission(
272
+ networkUUID: string,
273
+ userUUID: string,
274
+ permission: 'READ' | 'WRITE' | 'ADMIN'
275
+ ): Promise<void> {
276
+ const endpoint = `networks/${networkUUID}/permission`;
277
+ const permissionData = {
278
+ memberUUID: userUUID,
279
+ permission: permission
280
+ };
281
+ return this.http.post<void>(endpoint, permissionData, { version: 'v2' });
282
+ }
283
+
284
+ /**
285
+ * Revoke network permission from user
286
+ */
287
+ async revokeNetworkPermission(
288
+ networkUUID: string,
289
+ userUUID: string
290
+ ): Promise<void> {
291
+ const endpoint = `networks/${networkUUID}/permission`;
292
+ return this.http.delete<void>(endpoint, {
293
+ version: 'v2',
294
+ data: { memberUUID: userUUID }
295
+ });
296
+ }
297
+
298
+ /**
299
+ * Get network profile (additional metadata)
300
+ */
301
+ async getNetworkProfile(networkUUID: string): Promise<any> {
302
+ const endpoint = `networks/${networkUUID}/profile`;
303
+ return this.http.get<any>(endpoint, { version: 'v2' });
304
+ }
305
+
306
+ /**
307
+ * Set network profile
308
+ */
309
+ async setNetworkProfile(
310
+ networkUUID: string,
311
+ profile: any
312
+ ): Promise<void> {
313
+ const endpoint = `networks/${networkUUID}/profile`;
314
+ return this.http.put<void>(endpoint, profile, { version: 'v2' });
315
+ }
316
+
317
+ /**
318
+ * Make network public
319
+ */
320
+ async makeNetworkPublic(networkUUID: string): Promise<void> {
321
+ const endpoint = `networks/${networkUUID}/systemproperty`;
322
+ const properties = { visibility: 'PUBLIC' };
323
+ return this.http.put<void>(endpoint, properties, { version: 'v2' });
324
+ }
325
+
326
+ /**
327
+ * Make network private
328
+ */
329
+ async makeNetworkPrivate(networkUUID: string): Promise<void> {
330
+ const endpoint = `networks/${networkUUID}/systemproperty`;
331
+ const properties = { visibility: 'PRIVATE' };
332
+ return this.http.put<void>(endpoint, properties, { version: 'v2' });
333
+ }
334
+
335
+ /**
336
+ * Get network sample (if available)
337
+ */
338
+ async getNetworkSample(
339
+ networkUUID: string,
340
+ options: AccessParams = {}
341
+ ): Promise<any[]> {
342
+ const params = new URLSearchParams();
343
+ if (options.accesskey) {
344
+ params.append('accesskey', options.accesskey);
345
+ }
346
+
347
+ const endpoint = `networks/${networkUUID}/sample${params.toString() ? `?${params.toString()}` : ''}`;
348
+ return this.http.get<any[]>(endpoint, { version: 'v2' });
349
+ }
350
+
351
+ /**
352
+ * Get network metadata (migrated from original NDEx.js)
353
+ *
354
+ * Retrieves metadata information about network aspects including element counts,
355
+ * versions, and ID counters for each aspect in the network. This provides
356
+ * an overview of the network's structure and content organization.
357
+ *
358
+ * @param networkUUID - The UUID of the network to get metadata for
359
+ * @param accessKey - Optional access key for private networks
360
+ * @returns Promise resolving to metadata containing aspect information
361
+ * @example
362
+ * ```typescript
363
+ * const metadata = await networkService.getMetaData('network-uuid');
364
+ * // Returns: { metaData: [{ name: 'nodes', elementCount: 330, version: '1.0' }, ...] }
365
+ * ```
366
+ */
367
+ async getMetaData(
368
+ networkUUID: string,
369
+ accessKey?: string
370
+ ): Promise<CX1MetaDataResponse> {
371
+ const params = new URLSearchParams();
372
+ if (accessKey !== undefined) {
373
+ params.append('accesskey', accessKey);
374
+ }
375
+
376
+ const endpoint = `network/${networkUUID}/aspect${params.toString() ? `?${params.toString()}` : ''}`;
377
+ return this.http.get<CX1MetaDataResponse>(endpoint, { version: 'v2' });
378
+ }
379
+
380
+ /**
381
+ * Get network access key (migrated from original NDEx.js)
382
+ *
383
+ * Retrieves the current access key for a network. Access keys allow
384
+ * users to share private networks without requiring individual permissions.
385
+ *
386
+ * @param networkUUID - The UUID of the network to get access key for
387
+ * @returns Promise resolving to access key response object
388
+ *
389
+ * @example
390
+ * ```typescript
391
+ * const response = await networkService.getAccessKey('network-uuid');
392
+ * console.log(response.accessKey); // "acialdfeoa03430023" or null
393
+ * ```
394
+ */
395
+ async getAccessKey(networkUUID: string): Promise<AccessKeyResponse> {
396
+ const endpoint = `networks/${networkUUID}/accesskey`;
397
+ return this.http.get<AccessKeyResponse>(endpoint, { version: 'v2' });
398
+ }
399
+
400
+ /**
401
+ * Update network access key (migrated from original NDEx.js)
402
+ *
403
+ * Enables or disables the access key for a network. When enabled, creates
404
+ * a new access key that can be shared. When disabled, invalidates the
405
+ * current access key.
406
+ *
407
+ * @param networkUUID - The UUID of the network to update access key for
408
+ * @param action - Action to perform: 'enable' creates/updates key, 'disable' removes it
409
+ * @returns Promise resolving to access key response (accessKey will be null when disabled)
410
+ *
411
+ * @example
412
+ * ```typescript
413
+ * // Enable access key
414
+ * const enabled = await networkService.updateAccessKey('network-uuid', 'enable');
415
+ * console.log(enabled.accessKey); // "new-access-key-string"
416
+ *
417
+ * // Disable access key
418
+ * const disabled = await networkService.updateAccessKey('network-uuid', 'disable');
419
+ * console.log(disabled.accessKey); // null
420
+ * ```
421
+ */
422
+ async updateAccessKey(networkUUID: string, action: AccessKeyAction): Promise<AccessKeyResponse> {
423
+ const endpoint = `networks/${networkUUID}/accesskey`;
424
+ return this.http.put<AccessKeyResponse>(endpoint, { action }, { version: 'v2' });
425
+ }
426
+
427
+ }
@@ -0,0 +1,288 @@
1
+ import { HTTPService } from './HTTPService';
2
+ import {
3
+ NetworkSummaryV3,
4
+ SearchResult,
5
+ SearchParameters,
6
+ PaginationParams,
7
+ AccessParams,
8
+ CX2Network as CX2NetworkType,
9
+ NDExObjectUpdateStatus
10
+ } from '../types';
11
+ import { CX2Network } from '../models/CX2Network';
12
+
13
+ /**
14
+ * NetworkServiceV3 - NDEx API v3 network operations
15
+ * Handles modern v3 endpoints with native CX2 support
16
+ */
17
+ export class NetworkServiceV3 {
18
+ constructor(private http: HTTPService) {}
19
+
20
+ /**
21
+ * Get network summary by UUID
22
+ */
23
+ async getNetworkSummary(
24
+ networkUUID: string,
25
+ options: AccessParams = {}
26
+ ): Promise<NetworkSummaryV3> {
27
+ const params = new URLSearchParams();
28
+ if (options.accesskey) {
29
+ params.append('accesskey', options.accesskey);
30
+ }
31
+
32
+ const endpoint = `networks/${networkUUID}/summary${params.toString() ? `?${params.toString()}` : ''}`;
33
+ return this.http.get<NetworkSummaryV3>(endpoint, { version: 'v3' });
34
+ }
35
+
36
+
37
+ /**
38
+ * Get raw network in CX2 format (native V3)
39
+ *
40
+ * Returns raw CX2 data which may contain fragmented aspects that need to be assembled
41
+ * into a complete CX2 network model for proper usage. The returned data follows the
42
+ * CX2 specification but may have aspects split across multiple fragments.
43
+ * For a fully assembled network object with utility methods, use getNetworkAsCX2Object() instead.
44
+ *
45
+ * @param networkUUID - The UUID of the network to retrieve
46
+ * @param options - Access options including optional access key
47
+ * @returns Promise resolving to raw CX2 network data that may be fragmented
48
+ */
49
+ async getRawCX2Network(
50
+ networkUUID: string,
51
+ options: AccessParams = {}
52
+ ): Promise<CX2NetworkType> {
53
+ const params = new URLSearchParams();
54
+ if (options.accesskey) {
55
+ params.append('accesskey', options.accesskey);
56
+ }
57
+
58
+ const endpoint = `networks/${networkUUID}${params.toString() ? `?${params.toString()}` : ''}`;
59
+ return this.http.get<CX2NetworkType>(endpoint, { version: 'v3' });
60
+ }
61
+
62
+
63
+ /**
64
+ * Create network DOI
65
+ *
66
+ * @param networkUUID - The UUID of the network to create a DOI for
67
+ * @param key - DOI creation key
68
+ * @param email - Email address for DOI registration
69
+ * @returns Promise resolving to a confirmation message string from the server
70
+ */
71
+ async createNetworkDOI(
72
+ networkUUID: string,
73
+ key: string,
74
+ email: string
75
+ ): Promise<string> {
76
+ const params = new URLSearchParams();
77
+ params.append('key', key);
78
+ params.append('email', email);
79
+
80
+ const endpoint = `networks/${networkUUID}/DOI?${params.toString()}`;
81
+ return this.http.get<string>(endpoint, { version: 'v3' });
82
+ }
83
+
84
+ /**
85
+ * Get attributes of selected nodes
86
+ *
87
+ * Retrieves specific attributes for a set of nodes in a network. The server will return
88
+ * a 404 error if the network has no attributes on nodes.
89
+ *
90
+ * @param networkUUID - The UUID of the network
91
+ * @param nodeSelection - Object containing node IDs and attribute names to retrieve
92
+ * @param nodeSelection.ids - Array of node IDs (long numbers) to get attributes for
93
+ * @param nodeSelection.attributeNames - Array of attribute names to retrieve
94
+ * @param options - Access options including optional access key
95
+ * @returns Promise resolving to a JSON object where keys are stringified node IDs
96
+ * and values are the selected attributes for that node
97
+ * @throws {404} When the network has no attributes on nodes
98
+ */
99
+ async getAttributesOfSelectedNodes(
100
+ networkUUID: string,
101
+ nodeSelection: { ids: number[]; attributeNames: string[] },
102
+ options: AccessParams = {}
103
+ ): Promise<Record<string, any>> {
104
+ const params = new URLSearchParams();
105
+ if (options.accesskey) {
106
+ params.append('accesskey', options.accesskey);
107
+ }
108
+
109
+ const data = {
110
+ ids: nodeSelection.ids,
111
+ attributeNames: nodeSelection.attributeNames
112
+ };
113
+
114
+ const endpoint = `search/networks/${networkUUID}/nodes${params.toString() ? `?${params.toString()}` : ''}`;
115
+ return this.http.post<Record<string, any>>(endpoint, data, { version: 'v3' });
116
+ }
117
+
118
+ /**
119
+ * Get network summaries by UUIDs using V3 API (migrated from original NDEx.js)
120
+ *
121
+ * Retrieves network summaries for multiple networks in a single batch request using V3 API.
122
+ * Uses the V3 API batch endpoint with format parameter support.
123
+ *
124
+ * @param uuidList - Array of network UUIDs to retrieve summaries for
125
+ * @param accessKey - Optional access key for private networks
126
+ * @param format - Summary format ("FULL" by default, can be "BASIC" or other supported formats)
127
+ * @returns Promise resolving to array of V3 network summaries
128
+ */
129
+ async getNetworkSummariesV3ByUUIDs(
130
+ uuidList: string[],
131
+ accessKey?: string,
132
+ format?: string
133
+ ): Promise<NetworkSummaryV3[]> {
134
+ const params: Record<string, string> = {
135
+ format: format === undefined ? 'FULL' : format
136
+ };
137
+
138
+ if (accessKey != null) {
139
+ params.accesskey = accessKey;
140
+ }
141
+
142
+ const endpoint = 'batch/networks/summary';
143
+ return this.http.post<NetworkSummaryV3[]>(endpoint, uuidList, {
144
+ version: 'v3',
145
+ params
146
+ });
147
+ }
148
+
149
+
150
+
151
+ // following functions need to be reviewed or removed.
152
+
153
+ /**
154
+ * Search networks with V3 enhanced features
155
+ */
156
+ async searchNetworks(searchParams: SearchParameters = {}): Promise<SearchResult> {
157
+ const params = new URLSearchParams();
158
+
159
+ if (searchParams.searchString) {
160
+ params.append('searchString', searchParams.searchString);
161
+ }
162
+ if (searchParams.accountName) {
163
+ params.append('accountName', searchParams.accountName);
164
+ }
165
+ if (searchParams.permission) {
166
+ params.append('permission', searchParams.permission);
167
+ }
168
+ if (searchParams.includeGroups !== undefined) {
169
+ params.append('includeGroups', searchParams.includeGroups.toString());
170
+ }
171
+ if (searchParams.admin) {
172
+ params.append('admin', searchParams.admin);
173
+ }
174
+ if (searchParams.start !== undefined) {
175
+ params.append('start', searchParams.start.toString());
176
+ }
177
+ if (searchParams.size !== undefined) {
178
+ params.append('size', searchParams.size.toString());
179
+ }
180
+ if (searchParams.source) {
181
+ params.append('source', searchParams.source);
182
+ }
183
+
184
+ const endpoint = `search/network${params.toString() ? `?${params.toString()}` : ''}`;
185
+ return this.http.get<SearchResult>(endpoint, { version: 'v3' });
186
+ }
187
+ /**
188
+ * Get network as CX2Network object with utilities
189
+ */
190
+ async getNetworkAsCX2Object(
191
+ networkUUID: string,
192
+ options: AccessParams = {}
193
+ ): Promise<CX2Network> {
194
+ const cx2Data = await this.getRawCX2Network(networkUUID, options);
195
+ return new CX2Network(cx2Data);
196
+ }
197
+
198
+ /**
199
+ * Create new network from CX2
200
+ */
201
+ async createNetworkFromCX2(
202
+ cx2Data: CX2NetworkType | CX2Network,
203
+ options: { visibility?: 'PUBLIC' | 'PRIVATE'; folderId?: string } = {}
204
+ ): Promise<NDExObjectUpdateStatus> {
205
+ const endpoint = 'networks';
206
+
207
+ // Convert CX2Network object to plain object if needed
208
+ const data = cx2Data instanceof CX2Network ? JSON.parse(cx2Data.toJSON()) : cx2Data;
209
+
210
+ return this.http.post<NDExObjectUpdateStatus>(endpoint, data, {
211
+ version: 'v3',
212
+ params: options
213
+ });
214
+ }
215
+
216
+ /**
217
+ * Update network with CX2 data
218
+ */
219
+ async updateNetworkCX2(
220
+ networkUUID: string,
221
+ cx2Data: CX2NetworkType | CX2Network
222
+ ): Promise<NDExObjectUpdateStatus> {
223
+ const endpoint = `networks/${networkUUID}`;
224
+
225
+ // Convert CX2Network object to plain object if needed
226
+ const data = cx2Data instanceof CX2Network ? JSON.parse(cx2Data.toJSON()) : cx2Data;
227
+
228
+ return this.http.put<NDExObjectUpdateStatus>(endpoint, data, { version: 'v3' });
229
+ }
230
+
231
+ /**
232
+ * Upload network file (CX2, CX, or other formats)
233
+ */
234
+ async uploadNetworkFile(
235
+ file: File | Blob | string,
236
+ options: {
237
+ filename?: string;
238
+ visibility?: 'PUBLIC' | 'PRIVATE';
239
+ name?: string;
240
+ onProgress?: (progress: number) => void;
241
+ } = {}
242
+ ): Promise<{ uuid: string }> {
243
+ return this.http.uploadFile<{ uuid: string }>('networks/upload', file, {
244
+ version: 'v3',
245
+ ...options,
246
+ });
247
+ }
248
+
249
+ /**
250
+ * Get network metadata (V3 enhanced)
251
+ */
252
+ async getNetworkMetadata(networkUUID: string): Promise<any> {
253
+ const endpoint = `networks/${networkUUID}/metadata`;
254
+ return this.http.get<any>(endpoint, { version: 'v3' });
255
+ }
256
+
257
+ /**
258
+ * Update network metadata
259
+ */
260
+ async updateNetworkMetadata(
261
+ networkUUID: string,
262
+ metadata: Record<string, any>
263
+ ): Promise<void> {
264
+ const endpoint = `networks/${networkUUID}/metadata`;
265
+ return this.http.put<void>(endpoint, metadata, { version: 'v3' });
266
+ }
267
+
268
+
269
+
270
+ /**
271
+ * Get network aspect (specific CX2 aspect)
272
+ */
273
+ async getNetworkAspect(
274
+ networkUUID: string,
275
+ aspectName: string,
276
+ options: AccessParams = {}
277
+ ): Promise<any> {
278
+ const params = new URLSearchParams();
279
+ if (options.accesskey) {
280
+ params.append('accesskey', options.accesskey);
281
+ }
282
+
283
+ const endpoint = `networks/${networkUUID}/aspects/${aspectName}${params.toString() ? `?${params.toString()}` : ''}`;
284
+ return this.http.get<any>(endpoint, { version: 'v3' });
285
+ }
286
+
287
+
288
+ }