nervoscan-js-sdk 1.0.0 → 1.0.2-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.
@@ -0,0 +1,12 @@
1
+ name: Deploy Documentation
2
+
3
+
4
+
5
+ jobs:
6
+ deploy:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@v3
10
+ - uses: actions/setup-node@v3
11
+ with:
12
+ node-version: 18
package/README.md ADDED
@@ -0,0 +1,135 @@
1
+ ![nervotec.png](nervotec.png)
2
+
3
+ [![npm version](https://img.shields.io/npm/v/nervoscan-js-sdk)](https://www.npmjs.com/package/nervoscan-js-sdk)
4
+
5
+ ## Overview
6
+
7
+ The **NervoScan JS SDK** is a lightweight JavaScript library that enables seamless integration with the NervoScan backend services. This SDK handles authentication, video scan submission, and structured error handling — allowing developers to build React or other web-based clients effortlessly on top of NervoScan's contactless health analysis platform.
8
+
9
+ It provides a singleton `Client` interface and a full suite of custom error classes for advanced control and debugging.
10
+
11
+ ---
12
+
13
+ ## Features
14
+
15
+ - Authenticated communication with the NervoScan backend
16
+ - Video scan submission and result retrieval
17
+ - Fully type-safe implementation (written in TypeScript)
18
+ - Structured custom error classes for robust error handling
19
+ - Easy integration into any React, Vite, or JS-based frontend
20
+ - Singleton pattern for consistent client state management
21
+
22
+ ---
23
+
24
+ ## Installation
25
+
26
+ ```bash
27
+ npm install nervoscan-js-sdk
28
+ ```
29
+
30
+ ---
31
+
32
+ ## Usage
33
+
34
+ ```ts
35
+ import { Client, Errors } from 'nervoscan-js-sdk';
36
+
37
+ // Get the singleton instance
38
+ const client = Client.getInstance();
39
+
40
+ async function submitScan(videoBlob: Blob) {
41
+ try {
42
+ // Initialize with credentials
43
+ await client.initialize('username', 'password');
44
+
45
+ // Upload video and get job ID
46
+ const jobID = await client.uploadVideo(videoBlob);
47
+ console.log('Scan submitted. Job ID:', jobID);
48
+
49
+ // Check results
50
+ const results = await client.getResults(jobID);
51
+ console.log('Scan results:', results);
52
+ } catch (error) {
53
+ if (error instanceof Errors.InvalidPasswordError) {
54
+ console.error('Password incorrect.');
55
+ } else {
56
+ console.error('Unexpected error:', error);
57
+ }
58
+ }
59
+ }
60
+ ```
61
+
62
+ ---
63
+
64
+ ## API Reference
65
+
66
+ ### `Client` Class
67
+
68
+ #### Singleton Access
69
+ ```ts
70
+ Client.getInstance(): Client
71
+ ```
72
+ Returns the singleton instance of the Client class.
73
+
74
+ #### Methods
75
+
76
+ - `initialize(username: string, password: string): void`
77
+ Initializes the client with user credentials.
78
+
79
+ - `uploadVideo(videoBlob: Blob): Promise<string>`
80
+ Uploads a video scan and returns the job ID.
81
+
82
+ - `checkResults(jobID: string): Promise<string>`
83
+ Checks if results are available for the given job ID.
84
+
85
+ - `getResults(jobID: string): Promise<any>`
86
+ Fetches scan results for the given job ID.
87
+
88
+ ---
89
+
90
+ ## Error Handling
91
+
92
+ The SDK provides custom error classes for granular error control:
93
+
94
+ ```ts
95
+ import { Errors } from 'nervoscan-js-sdk';
96
+
97
+ try {
98
+ await client.initialize('username', 'password');
99
+ } catch (err) {
100
+ if (err instanceof Errors.NotInitializedError) {
101
+ console.error('Client not initialized.');
102
+ }
103
+ }
104
+ ```
105
+
106
+ ### Available Errors
107
+
108
+ - `NotInitializedError` - Client not properly initialized
109
+ - `EmptyVideoError` - Video blob is empty
110
+ - `VideoTypeError` - Invalid video type, not a blob
111
+ - `InvalidUsernameError` - Invalid username provided
112
+ - `InvalidPasswordError` - Invalid password provided
113
+ - `InvalidAccessTokenError` - Invalid or expired access token
114
+ - `NoScansAvailableError` - No scans available in current plan
115
+ - `NoScanDataError` - No scan data available for the job ID
116
+
117
+ ---
118
+
119
+ ## Requirements
120
+
121
+ - Node.js v14 or higher
122
+ - Modern browser (Chrome/Safari) for webcam support
123
+ - NervoScan backend access (credentials required)
124
+
125
+ ---
126
+
127
+ ## License
128
+
129
+ MIT License
130
+
131
+ ---
132
+
133
+ ## Maintainers
134
+
135
+ Built and maintained by the NervoScan development team.