docpouch-client 0.8.14 → 0.8.16
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 +218 -74
- package/dist/index.d.ts +133 -0
- package/dist/index.js +133 -0
- package/package.json +38 -38
- package/src/index.ts +665 -532
package/README.md
CHANGED
|
@@ -81,35 +81,44 @@ await client.removeUser('user-id');
|
|
|
81
81
|
```typescript
|
|
82
82
|
// Create a new document
|
|
83
83
|
const newDocument = await client.createDocument({
|
|
84
|
+
_id: 'document-id',
|
|
85
|
+
owner: 'user-id',
|
|
86
|
+
title: 'Mission Statement',
|
|
84
87
|
type: 17,
|
|
85
88
|
subType: 11,
|
|
86
|
-
|
|
87
|
-
content: "{\"msg\": \"We strive for a world that...\"}",
|
|
89
|
+
content: '{"msg": "We strive for a world that..."}',
|
|
88
90
|
shareWithGroup: false,
|
|
89
91
|
shareWithDepartment: false
|
|
90
92
|
});
|
|
91
93
|
|
|
92
94
|
// Update a document
|
|
93
95
|
await client.updateDocument('document-id', {
|
|
96
|
+
_id: 'document-id',
|
|
97
|
+
owner: 'user-id',
|
|
94
98
|
title: 'Updated Mission Statement',
|
|
95
|
-
|
|
99
|
+
type: 17,
|
|
100
|
+
subType: 11,
|
|
101
|
+
content: '{"msg": "Our updated mission..."}',
|
|
102
|
+
shareWithGroup: false,
|
|
103
|
+
shareWithDepartment: false
|
|
96
104
|
});
|
|
97
105
|
|
|
98
106
|
// Delete a document
|
|
99
|
-
await client.
|
|
107
|
+
await client.removeDocument('document-id');
|
|
108
|
+
|
|
109
|
+
// List all documents
|
|
110
|
+
const allDocuments = await client.listDocuments();
|
|
100
111
|
|
|
101
112
|
// Fetch documents by query
|
|
102
|
-
const documents = await client.fetchDocuments(
|
|
103
|
-
{type: 17, subType: 11}
|
|
104
|
-
]);
|
|
113
|
+
const documents = await client.fetchDocuments({type: 17, subType: 11});
|
|
105
114
|
```
|
|
106
115
|
|
|
107
116
|
### Data Structure Management
|
|
108
117
|
|
|
109
118
|
```typescript
|
|
110
119
|
// Create a new data structure
|
|
111
|
-
const newStructure = await client.
|
|
112
|
-
|
|
120
|
+
const newStructure = await client.createStructure({
|
|
121
|
+
name: "Data resulting from Vision-Mission-Value-Canvas",
|
|
113
122
|
fields: [
|
|
114
123
|
{
|
|
115
124
|
name: "Mission value statement",
|
|
@@ -120,28 +129,30 @@ const newStructure = await client.createDataStructure({
|
|
|
120
129
|
});
|
|
121
130
|
|
|
122
131
|
// Update a data structure
|
|
123
|
-
await client.
|
|
124
|
-
|
|
132
|
+
await client.updateStructure('structure-id', {
|
|
133
|
+
_id: 'structure-id',
|
|
134
|
+
name: 'Updated Structure Title',
|
|
135
|
+
description: 'Updated structure description',
|
|
125
136
|
fields: [
|
|
126
137
|
{name: 'New Field Name', type: 'number'}
|
|
127
138
|
]
|
|
128
139
|
});
|
|
129
140
|
|
|
130
141
|
// Delete a data structure
|
|
131
|
-
await client.
|
|
142
|
+
await client.removeStructure('structure-id');
|
|
132
143
|
|
|
133
144
|
// List all data structures
|
|
134
|
-
const structures = await client.
|
|
145
|
+
const structures = await client.getStructures();
|
|
135
146
|
```
|
|
136
147
|
|
|
137
148
|
### Document Type Management
|
|
138
149
|
|
|
139
150
|
```typescript
|
|
140
151
|
// List all document types
|
|
141
|
-
const docTypes = await client.
|
|
152
|
+
const docTypes = await client.getTypes();
|
|
142
153
|
|
|
143
|
-
// Create
|
|
144
|
-
const newDocType = await client.
|
|
154
|
+
// Create a new document type
|
|
155
|
+
const newDocType = await client.createType({
|
|
145
156
|
name: "HR Wages",
|
|
146
157
|
description: "HR Wage information Document listing wages per personnel ID",
|
|
147
158
|
type: 14,
|
|
@@ -149,8 +160,16 @@ const newDocType = await client.createOrUpdateDocumentType({
|
|
|
149
160
|
defaultStructureID: 'structure-id'
|
|
150
161
|
});
|
|
151
162
|
|
|
163
|
+
// Update a document type
|
|
164
|
+
await client.updateType({
|
|
165
|
+
_id: 'doc-type-id',
|
|
166
|
+
name: 'Updated HR Wages',
|
|
167
|
+
type: 14,
|
|
168
|
+
subType: 2
|
|
169
|
+
});
|
|
170
|
+
|
|
152
171
|
// Delete a document type
|
|
153
|
-
await client.
|
|
172
|
+
await client.removeType('doc-type-id');
|
|
154
173
|
```
|
|
155
174
|
|
|
156
175
|
## API Reference
|
|
@@ -159,147 +178,272 @@ await client.deleteDocumentType('doc-type-id');
|
|
|
159
178
|
|
|
160
179
|
#### Constructor
|
|
161
180
|
|
|
162
|
-
- `new docPouchClient(
|
|
181
|
+
- `new docPouchClient(host: string, port?: number, callback?: (event: I_EventString, data: I_WsMessage) => void)`
|
|
163
182
|
|
|
164
183
|
#### Methods
|
|
165
184
|
|
|
166
|
-
- `
|
|
167
|
-
- `
|
|
168
|
-
- `listUsers(): Promise<
|
|
169
|
-
- `
|
|
170
|
-
- `
|
|
171
|
-
- `removeUser(
|
|
172
|
-
- `createDocument(
|
|
173
|
-
- `
|
|
174
|
-
- `
|
|
175
|
-
- `
|
|
176
|
-
- `
|
|
177
|
-
- `
|
|
178
|
-
- `
|
|
179
|
-
- `
|
|
180
|
-
- `
|
|
181
|
-
- `
|
|
182
|
-
- `
|
|
185
|
+
- `setRealTimeSync(newRealTimeSync: boolean): void`
|
|
186
|
+
- `login(credentials: I_UserLogin): Promise<I_LoginResponse | null>`
|
|
187
|
+
- `listUsers(): Promise<I_UserEntry[]>`
|
|
188
|
+
- `updateUser(userID: string, userData: I_UserUpdate): Promise<void>`
|
|
189
|
+
- `createUser(userData: I_UserCreation): Promise<I_UserDisplay>`
|
|
190
|
+
- `removeUser(userID: string): Promise<void>`
|
|
191
|
+
- `createDocument(document: I_DocumentEntry): Promise<I_DocumentEntry>`
|
|
192
|
+
- `listDocuments(): Promise<I_DocumentEntry[]>`
|
|
193
|
+
- `fetchDocuments(queryObject: I_DocumentQuery): Promise<I_DocumentEntry[]>`
|
|
194
|
+
- `updateDocument(documentID: string, documentData: I_DocumentEntry): Promise<void>`
|
|
195
|
+
- `removeDocument(documentID: string): Promise<void>`
|
|
196
|
+
- `createStructure(structure: I_StructureCreation): Promise<I_DataStructure>`
|
|
197
|
+
- `getStructures(): Promise<I_DataStructure[]>`
|
|
198
|
+
- `updateStructure(structureID: string, structureData: I_DataStructure): Promise<void>`
|
|
199
|
+
- `removeStructure(structureID: string): Promise<void>`
|
|
200
|
+
- `createType(type: I_DocumentType): Promise<I_DocumentType>`
|
|
201
|
+
- `removeType(typeID: string): Promise<void>`
|
|
202
|
+
- `getTypes(): Promise<I_DocumentType[]>`
|
|
203
|
+
- `updateType(updatedType: I_DocumentType): Promise<void>`
|
|
204
|
+
- `setToken(token: string | null): void`
|
|
205
|
+
- `getVersion(): string`
|
|
206
|
+
- `debugSocketConnection(): void`
|
|
183
207
|
|
|
184
208
|
## Types
|
|
185
209
|
|
|
186
|
-
###
|
|
210
|
+
### I_UserEntry
|
|
187
211
|
|
|
188
212
|
```typescript
|
|
189
213
|
{
|
|
190
|
-
_id:
|
|
214
|
+
_id: string;
|
|
191
215
|
name: string;
|
|
192
|
-
|
|
216
|
+
password: string;
|
|
217
|
+
email?: string;
|
|
193
218
|
department: string;
|
|
194
219
|
group: string;
|
|
220
|
+
isAdmin: boolean;
|
|
195
221
|
}
|
|
196
222
|
```
|
|
197
223
|
|
|
198
|
-
###
|
|
224
|
+
### I_UserLogin
|
|
199
225
|
|
|
200
226
|
```typescript
|
|
201
227
|
{
|
|
202
228
|
name: string;
|
|
203
229
|
password: string;
|
|
204
|
-
|
|
230
|
+
}
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### I_UserDisplay
|
|
234
|
+
|
|
235
|
+
```typescript
|
|
236
|
+
{
|
|
237
|
+
_id: string;
|
|
238
|
+
username: string;
|
|
239
|
+
department: string;
|
|
240
|
+
group: string;
|
|
241
|
+
email?: string;
|
|
242
|
+
}
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
### I_UserCreation
|
|
246
|
+
|
|
247
|
+
```typescript
|
|
248
|
+
{
|
|
249
|
+
name: string;
|
|
250
|
+
password: string;
|
|
251
|
+
email?: string;
|
|
205
252
|
department: string;
|
|
206
253
|
group: string;
|
|
207
254
|
isAdmin: boolean;
|
|
208
255
|
}
|
|
209
256
|
```
|
|
210
257
|
|
|
211
|
-
###
|
|
258
|
+
### I_UserUpdate
|
|
259
|
+
|
|
260
|
+
```typescript
|
|
261
|
+
{
|
|
262
|
+
_id?: string;
|
|
263
|
+
name?: string;
|
|
264
|
+
password?: string;
|
|
265
|
+
email?: string;
|
|
266
|
+
department?: string;
|
|
267
|
+
group?: string;
|
|
268
|
+
isAdmin?: boolean;
|
|
269
|
+
}
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
### I_LoginResponse
|
|
212
273
|
|
|
213
274
|
```typescript
|
|
214
275
|
{
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
isAdmin ? : boolean;
|
|
219
|
-
department ? : string;
|
|
220
|
-
group ? : string;
|
|
276
|
+
token: string;
|
|
277
|
+
isAdmin: boolean;
|
|
278
|
+
userName: string;
|
|
221
279
|
}
|
|
222
280
|
```
|
|
223
281
|
|
|
224
|
-
###
|
|
282
|
+
### I_DocumentEntry
|
|
225
283
|
|
|
226
284
|
```typescript
|
|
227
285
|
{
|
|
228
286
|
_id: string;
|
|
287
|
+
owner: string;
|
|
288
|
+
title: string;
|
|
289
|
+
description?: string;
|
|
229
290
|
type: number;
|
|
230
291
|
subType: number;
|
|
231
|
-
|
|
232
|
-
content: string;
|
|
292
|
+
content: any;
|
|
233
293
|
shareWithGroup: boolean;
|
|
234
294
|
shareWithDepartment: boolean;
|
|
235
295
|
}
|
|
236
296
|
```
|
|
237
297
|
|
|
238
|
-
###
|
|
298
|
+
### I_DocumentCreation
|
|
239
299
|
|
|
240
300
|
```typescript
|
|
241
301
|
{
|
|
302
|
+
title: string;
|
|
303
|
+
description?: string;
|
|
242
304
|
type: number;
|
|
243
305
|
subType: number;
|
|
306
|
+
content: any;
|
|
307
|
+
shareWithGroup: boolean;
|
|
308
|
+
shareWithDepartment: boolean;
|
|
309
|
+
}
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
### I_DocumentCreationOwned
|
|
313
|
+
|
|
314
|
+
```typescript
|
|
315
|
+
{
|
|
316
|
+
owner: string;
|
|
244
317
|
title: string;
|
|
245
|
-
|
|
318
|
+
description?: string;
|
|
319
|
+
type: number;
|
|
320
|
+
subType: number;
|
|
321
|
+
content: any;
|
|
246
322
|
shareWithGroup: boolean;
|
|
247
323
|
shareWithDepartment: boolean;
|
|
248
324
|
}
|
|
249
325
|
```
|
|
250
326
|
|
|
251
|
-
###
|
|
327
|
+
### I_DocumentUpdate
|
|
252
328
|
|
|
253
329
|
```typescript
|
|
254
330
|
{
|
|
255
|
-
_id
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
shareWithGroup
|
|
261
|
-
shareWithDepartment
|
|
331
|
+
_id?: string;
|
|
332
|
+
owner?: string;
|
|
333
|
+
title?: string;
|
|
334
|
+
type?: number;
|
|
335
|
+
subType?: number;
|
|
336
|
+
shareWithGroup?: boolean;
|
|
337
|
+
shareWithDepartment?: boolean;
|
|
338
|
+
content?: any;
|
|
339
|
+
description?: string;
|
|
262
340
|
}
|
|
263
341
|
```
|
|
264
342
|
|
|
265
|
-
###
|
|
343
|
+
### I_DocumentQuery
|
|
266
344
|
|
|
267
345
|
```typescript
|
|
268
346
|
{
|
|
269
|
-
_id
|
|
270
|
-
|
|
271
|
-
|
|
347
|
+
_id?: string;
|
|
348
|
+
owner?: string;
|
|
349
|
+
title?: string;
|
|
350
|
+
type?: number;
|
|
351
|
+
subType?: number;
|
|
352
|
+
shareWithGroup?: boolean;
|
|
353
|
+
shareWithDepartment?: boolean;
|
|
272
354
|
}
|
|
273
355
|
```
|
|
274
356
|
|
|
275
|
-
###
|
|
357
|
+
### I_DataStructure
|
|
276
358
|
|
|
277
359
|
```typescript
|
|
278
360
|
{
|
|
279
|
-
|
|
280
|
-
|
|
361
|
+
_id?: string;
|
|
362
|
+
name: string;
|
|
363
|
+
description: string;
|
|
364
|
+
fields: I_StructureField[];
|
|
365
|
+
}
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
### I_StructureCreation
|
|
369
|
+
|
|
370
|
+
```typescript
|
|
371
|
+
{
|
|
372
|
+
name: string;
|
|
373
|
+
description?: string;
|
|
374
|
+
fields: I_StructureField[];
|
|
375
|
+
}
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
### I_StructureUpdate
|
|
379
|
+
|
|
380
|
+
```typescript
|
|
381
|
+
{
|
|
382
|
+
_id?: string;
|
|
383
|
+
name?: string;
|
|
384
|
+
description?: string;
|
|
385
|
+
fields?: I_StructureField[];
|
|
386
|
+
}
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
### I_StructureField
|
|
390
|
+
|
|
391
|
+
```typescript
|
|
392
|
+
{
|
|
393
|
+
name: string;
|
|
394
|
+
type: string;
|
|
395
|
+
items?: string;
|
|
281
396
|
}
|
|
282
397
|
```
|
|
283
398
|
|
|
284
|
-
###
|
|
399
|
+
### I_StructureEntry
|
|
285
400
|
|
|
286
401
|
```typescript
|
|
287
402
|
{
|
|
403
|
+
_id?: string;
|
|
288
404
|
name: string;
|
|
289
|
-
|
|
290
|
-
|
|
405
|
+
description: string;
|
|
406
|
+
fields: I_StructureField[];
|
|
291
407
|
}
|
|
292
408
|
```
|
|
293
409
|
|
|
294
|
-
###
|
|
410
|
+
### I_DocumentType
|
|
295
411
|
|
|
296
412
|
```typescript
|
|
297
413
|
{
|
|
298
|
-
_id
|
|
414
|
+
_id?: string;
|
|
299
415
|
name: string;
|
|
300
|
-
description
|
|
416
|
+
description?: string;
|
|
301
417
|
type: number;
|
|
302
418
|
subType: number;
|
|
303
|
-
defaultStructureID
|
|
419
|
+
defaultStructureID?: string;
|
|
420
|
+
}
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
### I_EventString
|
|
424
|
+
|
|
425
|
+
```typescript
|
|
426
|
+
'heartbeatPong' | 'heartbeatPing' | 'newDocument' | 'newStructure' |
|
|
427
|
+
'newUser' | 'newType' | 'removedID' | 'changedDocument' |
|
|
428
|
+
'changedStructure' | 'changedUser' | 'changedType' | 'removedUser' |
|
|
429
|
+
'removedStructure' | 'removedDocument' | 'removedType'
|
|
430
|
+
```
|
|
431
|
+
|
|
432
|
+
### I_WsMessage
|
|
433
|
+
|
|
434
|
+
```typescript
|
|
435
|
+
{
|
|
436
|
+
newDocument?: I_DocumentEntry;
|
|
437
|
+
newStructure?: I_StructureEntry;
|
|
438
|
+
newUser?: I_UserEntry;
|
|
439
|
+
removedID?: string;
|
|
440
|
+
changedDocument?: I_DocumentUpdate;
|
|
441
|
+
changedStructure?: I_StructureUpdate;
|
|
442
|
+
changedUser?: I_UserUpdate;
|
|
443
|
+
confirmSubscription?: boolean;
|
|
444
|
+
confirmUnsubscription?: boolean;
|
|
445
|
+
heartbeatPing?: number;
|
|
446
|
+
heartbeatPong?: number;
|
|
447
|
+
newType?: I_DocumentType;
|
|
304
448
|
}
|
|
305
449
|
```
|
package/dist/index.d.ts
CHANGED
|
@@ -55,26 +55,148 @@ export default class docPouchClient {
|
|
|
55
55
|
* @param {boolean} newRealTimeSync - The new real-time sync setting (true/false).
|
|
56
56
|
*/
|
|
57
57
|
setRealTimeSync(newRealTimeSync: boolean): void;
|
|
58
|
+
/**
|
|
59
|
+
* Authenticates a user and stores the returned token for subsequent requests.
|
|
60
|
+
*
|
|
61
|
+
* @param {I_UserLogin} credentials - Username and password credentials.
|
|
62
|
+
* @returns {Promise<I_LoginResponse | null>} Login payload when successful, otherwise null.
|
|
63
|
+
*/
|
|
58
64
|
login(credentials: I_UserLogin): Promise<I_LoginResponse | null>;
|
|
65
|
+
/**
|
|
66
|
+
* Retrieves all users visible to the authenticated user.
|
|
67
|
+
*
|
|
68
|
+
* @returns {Promise<I_UserEntry[]>} A list of user entries.
|
|
69
|
+
*/
|
|
59
70
|
listUsers(): Promise<I_UserEntry[]>;
|
|
71
|
+
/**
|
|
72
|
+
* Updates a user by ID.
|
|
73
|
+
*
|
|
74
|
+
* @param {string} userID - The ID of the user to update.
|
|
75
|
+
* @param {I_UserUpdate} userData - Partial user fields to update.
|
|
76
|
+
* @returns {Promise<void>}
|
|
77
|
+
*/
|
|
60
78
|
updateUser(userID: string, userData: I_UserUpdate): Promise<void>;
|
|
79
|
+
/**
|
|
80
|
+
* Creates a new user.
|
|
81
|
+
*
|
|
82
|
+
* @param {I_UserCreation} userData - Data used to create the user.
|
|
83
|
+
* @returns {Promise<I_UserDisplay>} The created user payload returned by the API.
|
|
84
|
+
*/
|
|
61
85
|
createUser(userData: I_UserCreation): Promise<I_UserDisplay>;
|
|
86
|
+
/**
|
|
87
|
+
* Removes a user by ID.
|
|
88
|
+
*
|
|
89
|
+
* @param {string} userID - The ID of the user to remove.
|
|
90
|
+
* @returns {Promise<void>}
|
|
91
|
+
*/
|
|
62
92
|
removeUser(userID: string): Promise<void>;
|
|
93
|
+
/**
|
|
94
|
+
* Creates a new document.
|
|
95
|
+
*
|
|
96
|
+
* @param {I_DocumentEntry} document - The document payload to create.
|
|
97
|
+
* @returns {Promise<I_DocumentEntry>} The created document.
|
|
98
|
+
*/
|
|
63
99
|
createDocument(document: I_DocumentEntry): Promise<I_DocumentEntry>;
|
|
100
|
+
/**
|
|
101
|
+
* Retrieves all documents visible to the authenticated user.
|
|
102
|
+
*
|
|
103
|
+
* @returns {Promise<I_DocumentEntry[]>} A list of document entries.
|
|
104
|
+
*/
|
|
64
105
|
listDocuments(): Promise<I_DocumentEntry[]>;
|
|
106
|
+
/**
|
|
107
|
+
* Fetches documents matching a query object.
|
|
108
|
+
*
|
|
109
|
+
* @param {I_DocumentQuery} queryObject - Query fields used for filtering.
|
|
110
|
+
* @returns {Promise<I_DocumentEntry[]>} Matching documents.
|
|
111
|
+
*/
|
|
65
112
|
fetchDocuments(queryObject: I_DocumentQuery): Promise<I_DocumentEntry[]>;
|
|
113
|
+
/**
|
|
114
|
+
* Updates a document by ID.
|
|
115
|
+
*
|
|
116
|
+
* @param {string} documentID - The ID of the document to update.
|
|
117
|
+
* @param {I_DocumentEntry} documentData - Updated document payload.
|
|
118
|
+
* @returns {Promise<void>}
|
|
119
|
+
*/
|
|
66
120
|
updateDocument(documentID: string, documentData: I_DocumentEntry): Promise<void>;
|
|
121
|
+
/**
|
|
122
|
+
* Removes a document by ID.
|
|
123
|
+
*
|
|
124
|
+
* @param {string} documentID - The ID of the document to remove.
|
|
125
|
+
* @returns {Promise<void>}
|
|
126
|
+
*/
|
|
67
127
|
removeDocument(documentID: string): Promise<void>;
|
|
128
|
+
/**
|
|
129
|
+
* Creates a new data structure.
|
|
130
|
+
*
|
|
131
|
+
* @param {I_StructureCreation} structure - Data structure payload to create.
|
|
132
|
+
* @returns {Promise<I_DataStructure>} The created data structure.
|
|
133
|
+
*/
|
|
68
134
|
createStructure(structure: I_StructureCreation): Promise<I_DataStructure>;
|
|
135
|
+
/**
|
|
136
|
+
* Retrieves all data structures.
|
|
137
|
+
*
|
|
138
|
+
* @returns {Promise<I_DataStructure[]>} A list of data structures.
|
|
139
|
+
*/
|
|
69
140
|
getStructures(): Promise<I_DataStructure[]>;
|
|
141
|
+
/**
|
|
142
|
+
* Updates a data structure by ID.
|
|
143
|
+
*
|
|
144
|
+
* @param {string} structureID - The ID of the structure to update.
|
|
145
|
+
* @param {I_DataStructure} structureData - Updated structure payload.
|
|
146
|
+
* @returns {Promise<void>}
|
|
147
|
+
*/
|
|
70
148
|
updateStructure(structureID: string, structureData: I_DataStructure): Promise<void>;
|
|
149
|
+
/**
|
|
150
|
+
* Removes a data structure by ID.
|
|
151
|
+
*
|
|
152
|
+
* @param {string} structureID - The ID of the structure to remove.
|
|
153
|
+
* @returns {Promise<void>}
|
|
154
|
+
*/
|
|
71
155
|
removeStructure(structureID: string): Promise<void>;
|
|
156
|
+
/**
|
|
157
|
+
* Creates or writes a document type.
|
|
158
|
+
*
|
|
159
|
+
* @param {I_DocumentType} type - The type payload.
|
|
160
|
+
* @returns {Promise<I_DocumentType>} The created or updated type.
|
|
161
|
+
*/
|
|
72
162
|
createType(type: I_DocumentType): Promise<I_DocumentType>;
|
|
163
|
+
/**
|
|
164
|
+
* Removes a document type by ID.
|
|
165
|
+
*
|
|
166
|
+
* @param {string} typeID - The ID of the type to remove.
|
|
167
|
+
* @returns {Promise<void>}
|
|
168
|
+
*/
|
|
73
169
|
removeType(typeID: string): Promise<void>;
|
|
170
|
+
/**
|
|
171
|
+
* Retrieves all document types.
|
|
172
|
+
*
|
|
173
|
+
* @returns {Promise<I_DocumentType[]>} A list of document types.
|
|
174
|
+
*/
|
|
74
175
|
getTypes(): Promise<I_DocumentType[]>;
|
|
176
|
+
/**
|
|
177
|
+
* Updates a document type.
|
|
178
|
+
*
|
|
179
|
+
* @param {I_DocumentType} updatedType - The full type payload to persist.
|
|
180
|
+
* @returns {Promise<void>}
|
|
181
|
+
*/
|
|
75
182
|
updateType(updatedType: I_DocumentType): Promise<void>;
|
|
183
|
+
/**
|
|
184
|
+
* Sets or clears the authentication token used for API and WebSocket auth.
|
|
185
|
+
*
|
|
186
|
+
* @param {string | null} token - Bearer token to use, or null to clear it.
|
|
187
|
+
*/
|
|
76
188
|
setToken(token: string | null): void;
|
|
189
|
+
/**
|
|
190
|
+
* Returns the package version of this client.
|
|
191
|
+
*
|
|
192
|
+
* @returns {string} The semantic version string.
|
|
193
|
+
*/
|
|
77
194
|
getVersion(): string;
|
|
195
|
+
/**
|
|
196
|
+
* Logs socket diagnostics and attempts a reconnect when possible.
|
|
197
|
+
*
|
|
198
|
+
* @returns {void}
|
|
199
|
+
*/
|
|
78
200
|
debugSocketConnection(): void;
|
|
79
201
|
/**
|
|
80
202
|
* Sets up permanent socket listeners for the client.
|
|
@@ -88,6 +210,17 @@ export default class docPouchClient {
|
|
|
88
210
|
* @private
|
|
89
211
|
*/
|
|
90
212
|
private initWebSocket;
|
|
213
|
+
/**
|
|
214
|
+
* Sends an HTTP request to the configured docPouch backend.
|
|
215
|
+
*
|
|
216
|
+
* @template T
|
|
217
|
+
* @param {string} endpoint - Relative API endpoint (with or without leading slash).
|
|
218
|
+
* @param {string} method - HTTP method.
|
|
219
|
+
* @param {any} [body] - Optional JSON body.
|
|
220
|
+
* @param {boolean} [requiresAuth=true] - Whether the Authorization header should be attached.
|
|
221
|
+
* @returns {Promise<T>} Parsed JSON response body.
|
|
222
|
+
* @private
|
|
223
|
+
*/
|
|
91
224
|
private request;
|
|
92
225
|
}
|
|
93
226
|
export interface I_UserEntry extends I_UserCreation {
|