docpouch-client 0.8.13 → 0.8.15
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/package.json +38 -38
- package/src/index.ts +665 -532
- package/dist/index.d.ts +0 -207
- package/dist/index.js +0 -308
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/package.json
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "docpouch-client",
|
|
3
|
-
"version": "0.8.
|
|
4
|
-
"main": "dist/index.js",
|
|
5
|
-
"types": "dist/index.d.ts",
|
|
6
|
-
"exports": {
|
|
7
|
-
".": {
|
|
8
|
-
"import": "./dist/index.js",
|
|
9
|
-
"require": "./dist/index.js"
|
|
10
|
-
}
|
|
11
|
-
},
|
|
12
|
-
"type": "module",
|
|
13
|
-
"scripts": {
|
|
14
|
-
"build": "tsc",
|
|
15
|
-
"test": "jest"
|
|
16
|
-
},
|
|
17
|
-
"keywords": [
|
|
18
|
-
"docPouch",
|
|
19
|
-
"API"
|
|
20
|
-
],
|
|
21
|
-
"author": "Jan Frecè",
|
|
22
|
-
"license": "MIT",
|
|
23
|
-
"description": "A small class to more easily access the docPouch API",
|
|
24
|
-
"repository": {
|
|
25
|
-
"type": "git",
|
|
26
|
-
"url": "https://github.com/BFH-JTF/docpouch-client"
|
|
27
|
-
},
|
|
28
|
-
"devDependencies": {
|
|
29
|
-
"@types/jest": "^30.0.0",
|
|
30
|
-
"@types/node": "^24.3.0",
|
|
31
|
-
"jest": "^30.0.5",
|
|
32
|
-
"ts-jest": "^29.4.1",
|
|
33
|
-
"typescript": "^5.9.2"
|
|
34
|
-
},
|
|
35
|
-
"dependencies": {
|
|
36
|
-
"socket.io-client": "^4.8.1"
|
|
37
|
-
}
|
|
38
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "docpouch-client",
|
|
3
|
+
"version": "0.8.15",
|
|
4
|
+
"main": "dist/index.js",
|
|
5
|
+
"types": "dist/index.d.ts",
|
|
6
|
+
"exports": {
|
|
7
|
+
".": {
|
|
8
|
+
"import": "./dist/index.js",
|
|
9
|
+
"require": "./dist/index.js"
|
|
10
|
+
}
|
|
11
|
+
},
|
|
12
|
+
"type": "module",
|
|
13
|
+
"scripts": {
|
|
14
|
+
"build": "tsc",
|
|
15
|
+
"test": "jest"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"docPouch",
|
|
19
|
+
"API"
|
|
20
|
+
],
|
|
21
|
+
"author": "Jan Frecè",
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"description": "A small class to more easily access the docPouch API",
|
|
24
|
+
"repository": {
|
|
25
|
+
"type": "git",
|
|
26
|
+
"url": "https://github.com/BFH-JTF/docpouch-client"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/jest": "^30.0.0",
|
|
30
|
+
"@types/node": "^24.3.0",
|
|
31
|
+
"jest": "^30.0.5",
|
|
32
|
+
"ts-jest": "^29.4.1",
|
|
33
|
+
"typescript": "^5.9.2"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"socket.io-client": "^4.8.1"
|
|
37
|
+
}
|
|
38
|
+
}
|