totalum-api-sdk 3.0.3 → 3.0.4
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 +1 -77
- package/dist/common/interfaces.d.ts +4 -4
- package/dist/common/response-types.d.ts +1 -1
- package/package.json +1 -1
package/README.MD
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
## Totalum API SDK (v3.0.
|
|
1
|
+
## Totalum API SDK (v3.0.4)
|
|
2
2
|
|
|
3
3
|
Official TypeScript/JavaScript SDK for the Totalum API. This library provides a fully typed, modern interface to interact with all Totalum endpoints.
|
|
4
4
|
|
|
@@ -17,82 +17,6 @@ npm i totalum-api-sdk
|
|
|
17
17
|
- **Improved Type Safety**: Full TypeScript support with detailed response types
|
|
18
18
|
- **No Breaking Changes in API**: Same Totalum API, just better developer experience
|
|
19
19
|
|
|
20
|
-
## Migration Guide (v2.x → v3.0)
|
|
21
|
-
|
|
22
|
-
### Breaking Changes
|
|
23
|
-
|
|
24
|
-
#### 1. Method Names (CRUD Service)
|
|
25
|
-
```javascript
|
|
26
|
-
// v2.x
|
|
27
|
-
await totalumClient.crud.getItemById(table, id);
|
|
28
|
-
await totalumClient.crud.getItems(table, query);
|
|
29
|
-
await totalumClient.crud.createItem(table, data);
|
|
30
|
-
await totalumClient.crud.editItemById(table, id, data);
|
|
31
|
-
await totalumClient.crud.deleteItemById(table, id);
|
|
32
|
-
await totalumClient.crud.addManyToManyReferenceItem(table, id, prop, refId);
|
|
33
|
-
await totalumClient.crud.dropManyToManyReferenceItem(table, id, prop, refId);
|
|
34
|
-
await totalumClient.crud.getManyToManyReferencesItems(table, id, prop, query);
|
|
35
|
-
|
|
36
|
-
// v3.0
|
|
37
|
-
await totalumClient.crud.getRecordById(table, id);
|
|
38
|
-
await totalumClient.crud.getRecords(table, query);
|
|
39
|
-
await totalumClient.crud.createRecord(table, data);
|
|
40
|
-
await totalumClient.crud.editRecordById(table, id, data);
|
|
41
|
-
await totalumClient.crud.deleteRecordById(table, id);
|
|
42
|
-
await totalumClient.crud.addManyToManyReferenceRecord(table, id, prop, refId);
|
|
43
|
-
await totalumClient.crud.dropManyToManyReferenceRecord(table, id, prop, refId);
|
|
44
|
-
await totalumClient.crud.getManyToManyReferencesRecords(table, id, prop, query);
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
#### 2. Response Structure
|
|
48
|
-
```javascript
|
|
49
|
-
// v2.x (using axios)
|
|
50
|
-
const result = await totalumClient.crud.getItems(table, {});
|
|
51
|
-
const items = result.data; // Double .data because of axios wrapper
|
|
52
|
-
|
|
53
|
-
// v3.0 (using fetch)
|
|
54
|
-
const result = await totalumClient.crud.getRecords(table, {});
|
|
55
|
-
if (result.errors) {
|
|
56
|
-
console.error('Error:', result.errors.errorMessage);
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
const records = result.data; // Direct access to data
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
#### 3. Error Handling
|
|
63
|
-
```javascript
|
|
64
|
-
// v2.x (axios throws errors)
|
|
65
|
-
try {
|
|
66
|
-
const result = await totalumClient.crud.getItems(table, {});
|
|
67
|
-
const items = result.data;
|
|
68
|
-
} catch (error) {
|
|
69
|
-
console.error('Error:', error.message);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// v3.0 (errors in response object)
|
|
73
|
-
const result = await totalumClient.crud.getRecords(table, {});
|
|
74
|
-
if (result.errors) {
|
|
75
|
-
console.error('Error:', result.errors.errorMessage);
|
|
76
|
-
console.error('Error Code:', result.errors.errorCode);
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
|
-
const records = result.data;
|
|
80
|
-
```
|
|
81
|
-
|
|
82
|
-
### Dependencies
|
|
83
|
-
```json
|
|
84
|
-
// v2.x
|
|
85
|
-
{
|
|
86
|
-
"dependencies": {
|
|
87
|
-
"axios": "^1.x.x"
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
// v3.0 (no dependencies!)
|
|
92
|
-
{
|
|
93
|
-
"dependencies": {}
|
|
94
|
-
}
|
|
95
|
-
```
|
|
96
20
|
|
|
97
21
|
**Note:** v3.0 requires Node.js 18+ (for native fetch support). If you're using an older Node.js version, you'll need to polyfill `fetch` or upgrade to Node.js 18+.
|
|
98
22
|
|
|
@@ -84,10 +84,10 @@ export type fieldFileI = {
|
|
|
84
84
|
};
|
|
85
85
|
export type fieldTypesEnabled = 'string' | 'number' | 'boolean' | 'date' | 'options' | 'file' | 'long-string' | /*'array' |*/ 'objectReference';
|
|
86
86
|
export interface DataValues {
|
|
87
|
-
_id
|
|
88
|
-
createdAt
|
|
89
|
-
updatedAt
|
|
90
|
-
[key: string]: fieldValuesEnabled;
|
|
87
|
+
_id?: string;
|
|
88
|
+
createdAt?: Date;
|
|
89
|
+
updatedAt?: Date;
|
|
90
|
+
[key: string]: fieldValuesEnabled | any;
|
|
91
91
|
}
|
|
92
92
|
export interface DataProperties {
|
|
93
93
|
[key: string]: fieldValuesEnabled | any;
|
|
@@ -155,7 +155,7 @@ export interface UpdatesRecordResponse {
|
|
|
155
155
|
_id: string;
|
|
156
156
|
objectId: string;
|
|
157
157
|
typeId: string;
|
|
158
|
-
|
|
158
|
+
updatesRecord: UpdateRecordChange[];
|
|
159
159
|
}
|
|
160
160
|
export interface ManyToManyReferenceResponse {
|
|
161
161
|
acknowledged: boolean;
|