extractia-sdk 1.0.4 → 1.0.6

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/README.md CHANGED
@@ -2,13 +2,18 @@
2
2
 
3
3
  A JavaScript SDK for interacting with the Extractia API.
4
4
 
5
+ > **Note:** This SDK is designed for the implementation of the [extractia.info](https://extractia.info) public API.
6
+ > You must have an Extractia account and a valid API token to use it.
7
+
5
8
  ## Installation
6
9
 
7
10
  ```sh
8
11
  npm install extractia-sdk
12
+ ```
9
13
 
10
- Usage
14
+ ## Usage
11
15
 
16
+ ```js
12
17
  import { setToken, getMyProfile, getTemplates, processImage } from 'extractia-sdk';
13
18
 
14
19
  // Set your API token
@@ -22,32 +27,42 @@ const templates = await getTemplates();
22
27
 
23
28
  // Process an image with a template
24
29
  const result = await processImage(templateId, base64Image);
30
+ ```
25
31
 
26
- API Reference
32
+ ## API Reference
27
33
 
28
- Authentication
34
+ ### Authentication
29
35
 
30
- setToken(token) – Set the API token for requests.
31
- getMyProfile() – Get the authenticated user´s profile.
32
- updateWebhook(url) – Update the webhook URL for the user.
36
+ - `setToken(token)` – Set the API token for requests.
37
+ - `getMyProfile()` – Get the authenticated user's profile.
38
+ - `updateWebhook(url)` – Update the webhook URL for the user.
33
39
 
34
- Templates
40
+ ### Templates
35
41
 
36
- getTemplates() – Retrieve all templates.
37
- getTemplateById(id) – Get a template by its ID.
38
- getTemplateByName(name) – Get a template by its name.
39
- createTemplate(template) – Create a new template.
40
- updateTemplate(id, template) – Update an existing template.
41
- deleteTemplate(id) – Delete a template.
42
- deleteAllTemplateDocuments(id) – Delete all documents for a template.
42
+ - `getTemplates()` – Retrieve all templates.
43
+ - `getTemplateById(id)` – Get a template by its ID.
44
+ - `getTemplateByName(name)` – Get a template by its name.
45
+ - `createTemplate(template)` – Create a new template.
46
+ - `updateTemplate(id, template)` – Update an existing template.
47
+ - `deleteTemplate(id)` – Delete a template.
48
+ - `deleteAllTemplateDocuments(id)` – Delete all documents for a template.
43
49
 
44
- Documents
50
+ ### Documents
45
51
 
46
- getDocumentsByTemplateId(templateId, options) – Get documents for a template.
47
- deleteDocument(documentId) – Delete a document.
48
- processImage(templateId, base64Image) – Process a single image.
49
- processImagesMultipage(templateId, base64ImagesArray) – Process multiple images (multipage).
52
+ - `getDocumentsByTemplateId(templateId, options)` – Get documents for a template.
53
+ - `options`:
54
+ ```js
55
+ {
56
+ preconformed?: boolean,
57
+ index?: number, // Paging index (each page contains 10 documents)
58
+ sort?: number, // 1 for ascending, -1 for descending
59
+ includeImage?: boolean
60
+ }
61
+ ```
62
+ - `deleteDocument(documentId)` – Delete a document.
63
+ - `processImage(templateId, base64Image)` – Process a single image.
64
+ - `processImagesMultipage(templateId, base64ImagesArray)` – Process multiple images (multipage).
50
65
 
51
- License
66
+ ## License
52
67
 
53
- ISC
68
+ ISC
@@ -2615,9 +2615,10 @@ var ExtractiaSDK = (() => {
2615
2615
  timeout: 1e4
2616
2616
  });
2617
2617
  api.interceptors.request.use((config) => {
2618
- if (token) {
2619
- config.headers.Authorization = `Bearer ${token}`;
2618
+ if (!token) {
2619
+ throw new Error("API token is required");
2620
2620
  }
2621
+ config.headers.Authorization = `Bearer ${token}`;
2621
2622
  return config;
2622
2623
  });
2623
2624
  function setToken(newToken) {