@js4cytoscape/ndex-client 0.6.0-alpha.1 → 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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@js4cytoscape/ndex-client",
3
- "version": "0.6.0-alpha.1",
3
+ "version": "0.6.0-alpha.2",
4
4
  "description": "NDEx client library - Modern TypeScript implementation",
5
5
  "repository": {
6
6
  "type": "git",
@@ -32,10 +32,10 @@
32
32
  "build": "tsup",
33
33
  "build:docs": "typedoc",
34
34
  "docs:api": "npm run build:docs",
35
- "docs:site": "cd docs-site && npm install && npm run build",
36
- "docs:serve": "cd docs-site && npm run start",
35
+ "docs:site": "cd docs-root/guide && npm install && npm run build",
36
+ "docs:serve": "cd docs-root/guide && npm run start",
37
37
  "docs:build": "npm run docs:api && npm run docs:site",
38
- "docs:clean": "rimraf docs docs-site/build docs-site/docs/api",
38
+ "docs:clean": "rimraf docs-root/api docs-root/guide/build",
39
39
  "test": "npm run test:unit",
40
40
  "test:unit": "jest --config jest.unit.config.js",
41
41
  "test:integration": "jest --config jest.integration.config.js",
@@ -88,8 +88,9 @@
88
88
  "rimraf": "^5.0.5",
89
89
  "ts-jest": "^29.1.2",
90
90
  "tsup": "^8.0.2",
91
- "typedoc": "^0.25.12",
92
- "typedoc-plugin-markdown": "^3.17.1",
91
+ "typedoc": "^0.28.12",
92
+ "typedoc-material-theme": "^1.4.0",
93
+ "typedoc-plugin-markdown": "^4.8.1",
93
94
  "typescript": "^5.4.2"
94
95
  },
95
96
  "peerDependencies": {
package/src/index.ts CHANGED
@@ -13,7 +13,6 @@ export * from './types';
13
13
  export { CX2Network } from './models/CX2Network';
14
14
 
15
15
  // Core Services
16
- export { HTTPService } from './services/HTTPService';
17
16
  export { NetworkServiceV2 } from './services/NetworkServiceV2';
18
17
  export { NetworkServiceV3 } from './services/NetworkServiceV3';
19
18
  export { UnifiedNetworkService } from './services/UnifiedNetworkService';
@@ -203,5 +202,29 @@ export class NDExClient {
203
202
 
204
203
  // Version information - imported from package.json to ensure consistency
205
204
  import { version as packageVersion } from '../package.json';
205
+
206
+ /**
207
+ * Library version string imported from package.json
208
+ *
209
+ * Provides programmatic access to the current library version for:
210
+ * - Runtime version checking and validation
211
+ * - Debugging and error reporting
212
+ * - Logging and telemetry
213
+ * - Version-dependent feature detection
214
+ *
215
+ * @example
216
+ * ```typescript
217
+ * import { NDExClient, version } from '@js4cytoscape/ndex-client';
218
+ *
219
+ * console.log(`Using NDEx Client v${version}`);
220
+ *
221
+ * // In error reports
222
+ * const errorReport = {
223
+ * error: err.message,
224
+ * libraryVersion: version,
225
+ * timestamp: new Date().toISOString()
226
+ * };
227
+ * ```
228
+ */
206
229
  export const version = packageVersion;
207
230
 
@@ -20,6 +20,7 @@ import { version } from '../../package.json';
20
20
  *
21
21
  * @note User-Agent header is set to 'NDEx-JS-Client/${version}' but only works in Node.js.
22
22
  * Browsers will ignore custom User-Agent headers for security reasons.
23
+ * @internal
23
24
  */
24
25
  export class HTTPService {
25
26
  private axiosInstance: AxiosInstance;
@@ -163,7 +164,7 @@ export class HTTPService {
163
164
  }
164
165
 
165
166
 
166
- /**
167
+ /*
167
168
  * Upload a file to the NDEx API with progress tracking support
168
169
  *
169
170
  * This method handles file uploads using multipart/form-data encoding and supports
@@ -177,14 +178,11 @@ export class HTTPService {
177
178
  * - `Buffer` (Node.js): Binary data as Buffer for server-side uploads
178
179
  * - `string`: Text content that will be converted to Blob (useful for CX/CX2 JSON)
179
180
  * @param options - Upload configuration options
180
- * @param options.filename - Custom filename for the upload. Defaults:
181
- * - File objects: uses `file.name`
182
- * - Other types: 'file.cx2'
181
+ *
183
182
  * @param options.contentType - MIME type for string content (default: 'application/json')
184
183
  * @param options.onProgress - Progress callback that receives percentage (0-100)
185
184
  * Called periodically during upload with current progress
186
185
  * @param options.version - API version to use ('v2' or 'v3', defaults to 'v2')
187
- * @param options.config - Additional Axios configuration options
188
186
  *
189
187
  * @returns Promise resolving to upload result
190
188
  *
@@ -226,27 +224,26 @@ export class HTTPService {
226
224
  endpoint: string,
227
225
  file: File | Blob | Buffer | string,
228
226
  options: {
229
- filename?: string;
230
227
  contentType?: string;
231
228
  onProgress?: (progress: number) => void;
232
229
  version?: 'v2' | 'v3';
233
230
  } = {}
234
231
  ): Promise<T> {
235
- const { version, onProgress, filename, contentType, ...config } = options;
232
+ const { version, onProgress, contentType, ...config } = options;
236
233
  const url = this.buildUrl(endpoint, version);
237
234
 
238
235
  const formData = new FormData();
239
236
 
240
237
  if (file instanceof File) {
241
- formData.append('file', file, filename || file.name);
238
+ formData.append('file', file, file.name);
242
239
  } else if (file instanceof Blob) {
243
- formData.append('file', file, filename || 'file.cx2');
240
+ formData.append('file', file, 'file.cx2');
244
241
  } else if (typeof file === 'string') {
245
242
  const blob = new Blob([file], { type: contentType || 'application/json' });
246
- formData.append('file', blob, filename || 'file.cx2');
243
+ formData.append('file', blob,'file.cx2');
247
244
  } else {
248
245
  // Buffer (Node.js environment)
249
- formData.append('file', file as any, filename || 'file.cx2');
246
+ formData.append('file', file as any, 'file.cx2');
250
247
  }
251
248
 
252
249
  try {
@@ -5,7 +5,8 @@ import {
5
5
  SearchParameters,
6
6
  PaginationParams,
7
7
  AccessParams,
8
- CX2Network as CX2NetworkType
8
+ CX2Network as CX2NetworkType,
9
+ NDExObjectUpdateStatus
9
10
  } from '../types';
10
11
  import { CX2Network } from '../models/CX2Network';
11
12
 
@@ -199,14 +200,14 @@ export class NetworkServiceV3 {
199
200
  */
200
201
  async createNetworkFromCX2(
201
202
  cx2Data: CX2NetworkType | CX2Network,
202
- options: { visibility?: 'PUBLIC' | 'PRIVATE'; name?: string } = {}
203
- ): Promise<{ uuid: string }> {
204
- const endpoint = 'networks/cx2';
203
+ options: { visibility?: 'PUBLIC' | 'PRIVATE'; folderId?: string } = {}
204
+ ): Promise<NDExObjectUpdateStatus> {
205
+ const endpoint = 'networks';
205
206
 
206
207
  // Convert CX2Network object to plain object if needed
207
208
  const data = cx2Data instanceof CX2Network ? JSON.parse(cx2Data.toJSON()) : cx2Data;
208
209
 
209
- return this.http.post<{ uuid: string }>(endpoint, data, {
210
+ return this.http.post<NDExObjectUpdateStatus>(endpoint, data, {
210
211
  version: 'v3',
211
212
  params: options
212
213
  });
@@ -218,13 +219,13 @@ export class NetworkServiceV3 {
218
219
  async updateNetworkCX2(
219
220
  networkUUID: string,
220
221
  cx2Data: CX2NetworkType | CX2Network
221
- ): Promise<void> {
222
- const endpoint = `networks/${networkUUID}/cx2`;
222
+ ): Promise<NDExObjectUpdateStatus> {
223
+ const endpoint = `networks/${networkUUID}`;
223
224
 
224
225
  // Convert CX2Network object to plain object if needed
225
226
  const data = cx2Data instanceof CX2Network ? JSON.parse(cx2Data.toJSON()) : cx2Data;
226
227
 
227
- return this.http.put<void>(endpoint, data, { version: 'v3' });
228
+ return this.http.put<NDExObjectUpdateStatus>(endpoint, data, { version: 'v3' });
228
229
  }
229
230
 
230
231
  /**
@@ -9,7 +9,8 @@ import {
9
9
  CX2Edge,
10
10
  CX1Edge,
11
11
  CX2MetaData,
12
- NetworkPermission
12
+ NetworkPermission,
13
+ NDExObjectUpdateStatus
13
14
  } from '../types';
14
15
  import { CX2Network } from '../models/CX2Network';
15
16
 
@@ -573,47 +574,34 @@ export class UnifiedNetworkService {
573
574
  /**
574
575
  * Create network from raw CX2 data (migrated from original NDEx.js)
575
576
  *
576
- * Creates a new network in NDEx from raw CX2 network data. This is an unstable function
577
- * for uploading CX2 format networks directly to NDEx using the V3 API. The function
578
- * extracts the network UUID from the response location header.
577
+ * Creates a new network on NDEx from raw CX2 data using the V3 API.
578
+ * This function delegates to the NetworkServiceV3 implementation.
579
579
  *
580
- * @param rawCX2 - Raw CX2 network data as an object or CX2Network instance
581
- * @param makePublic - Whether to make the network public (default: false = private)
582
- * @returns Promise resolving to an object containing the UUID of the created network
580
+ * @param cx2Data - Raw CX2 network data as an object or CX2Network instance
581
+ * @param options - Creation options including visibility and folderId
582
+ * @param options.visibility - Network visibility: 'PUBLIC' or 'PRIVATE' (default: 'PRIVATE')
583
+ * @param options.folderId - UUID of the folder to create the network in. If omitted, network is created in user's home directory
584
+ * @returns Promise resolving to NDExObjectUpdateStatus with uuid and modificationTime
583
585
  *
584
586
  * @example
585
587
  * ```typescript
586
- * // Create private network from raw CX2 data
588
+ * // Create private network from raw CX2 data in user's home directory
587
589
  * const result = await client.networks.createNetworkFromRawCX2(cx2Data);
588
590
  * console.log(result.uuid); // "12345678-1234-1234-1234-123456789abc"
589
591
  *
590
- * // Create public network from raw CX2 data
591
- * const publicResult = await client.networks.createNetworkFromRawCX2(cx2Data, true);
592
+ * // Create public network from raw CX2 data in a specific folder
593
+ * const publicResult = await client.networks.createNetworkFromRawCX2(cx2Data, {
594
+ * visibility: 'PUBLIC',
595
+ * folderId: '87654321-4321-4321-4321-876543210fed'
596
+ * });
592
597
  * console.log(publicResult.uuid);
593
598
  * ```
594
599
  */
595
600
  async createNetworkFromRawCX2(
596
- rawCX2: CX2NetworkType | any,
597
- makePublic: boolean = false
598
- ): Promise<{ uuid: string }> {
599
- const params = {
600
- visibility: makePublic ? 'PUBLIC' as const : 'PRIVATE' as const
601
- };
602
-
603
- const endpoint = 'networks';
604
- const response = await this.http.post<string>(endpoint, rawCX2, {
605
- version: 'v3',
606
- params
607
- });
608
-
609
- // Extract UUID from response location header (e.g., "/v3/networks/12345" -> "12345")
610
- const uuid = response.split('/').pop();
611
-
612
- if (!uuid) {
613
- throw new Error('Failed to extract network UUID from response');
614
- }
615
-
616
- return { uuid };
601
+ cx2Data: CX2NetworkType | CX2Network,
602
+ options: { visibility?: 'PUBLIC' | 'PRIVATE'; folderId?: string } = {}
603
+ ): Promise<NDExObjectUpdateStatus> {
604
+ return this.v3.createNetworkFromCX2(cx2Data, options);
617
605
  }
618
606
 
619
607
  /**
@@ -513,3 +513,12 @@ export interface AccessKeyResponse {
513
513
  */
514
514
  export type AccessKeyAction = 'enable' | 'disable';
515
515
 
516
+ /**
517
+ * NDEx object update status - returned from network creation and update operations
518
+ * Corresponds to server-side NdexObjectUpdateStatus class
519
+ */
520
+ export interface NDExObjectUpdateStatus {
521
+ uuid: string;
522
+ modificationTime: number; // Timestamp in milliseconds
523
+ }
524
+