docpouch-client 0.8.6 → 0.8.7

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/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- import type { I_UserEntry, I_UserLogin, I_UserCreation, I_UserUpdate, I_UserDisplay, I_DocumentEntry, I_DataStructure, I_LoginResponse, I_DocumentQuery, I_StructureCreation, I_WsMessage, I_EventString, I_DocumentType } from "./types.js";
2
1
  import { Socket } from "socket.io-client";
3
2
  /**
4
3
  * Client for interacting with docPouch API.
@@ -91,3 +90,119 @@ export default class docPouchClient {
91
90
  private initWebSocket;
92
91
  private request;
93
92
  }
93
+ export interface I_UserEntry extends I_UserCreation {
94
+ _id: string;
95
+ }
96
+ export interface I_UserLogin {
97
+ name: string;
98
+ password: string;
99
+ }
100
+ export interface I_UserCreation {
101
+ name: string;
102
+ password: string;
103
+ email?: string;
104
+ department: string;
105
+ group: string;
106
+ isAdmin: boolean;
107
+ }
108
+ export interface I_UserUpdate {
109
+ _id: string;
110
+ name?: string;
111
+ password?: string;
112
+ email?: string;
113
+ department?: string;
114
+ group?: string;
115
+ isAdmin?: boolean;
116
+ }
117
+ export interface I_UserDisplay {
118
+ _id: string;
119
+ username: string;
120
+ department: string;
121
+ group: string;
122
+ email?: string;
123
+ }
124
+ export interface I_LoginResponse {
125
+ token: string;
126
+ isAdmin: boolean;
127
+ userName: string;
128
+ }
129
+ export interface I_DocumentEntry extends I_DocumentCreationOwned {
130
+ _id: string;
131
+ }
132
+ export interface I_DocumentCreation {
133
+ title: string;
134
+ description?: string;
135
+ type: number;
136
+ subType: number;
137
+ content: any;
138
+ shareWithGroup: boolean;
139
+ shareWithDepartment: boolean;
140
+ }
141
+ export interface I_DocumentCreationOwned extends I_DocumentCreation {
142
+ owner: string;
143
+ }
144
+ export interface I_DocumentUpdate extends I_DocumentQuery {
145
+ _id: string;
146
+ content?: any;
147
+ description?: string;
148
+ }
149
+ export interface I_DocumentQuery {
150
+ _id?: string;
151
+ owner?: string;
152
+ title?: string;
153
+ type?: number;
154
+ subType?: number;
155
+ shareWithGroup?: boolean;
156
+ shareWithDepartment?: boolean;
157
+ }
158
+ export interface I_DataStructure {
159
+ _id?: string | undefined;
160
+ name: string;
161
+ description: string;
162
+ fields: I_StructureField[];
163
+ }
164
+ export interface I_StructureField {
165
+ name: string;
166
+ type: string;
167
+ items?: string;
168
+ }
169
+ export interface I_StructureEntry {
170
+ _id?: string;
171
+ name: string;
172
+ description: string;
173
+ fields: I_StructureField[];
174
+ }
175
+ export interface I_StructureCreation {
176
+ name: string;
177
+ description?: string;
178
+ fields: I_StructureField[];
179
+ }
180
+ export interface I_StructureUpdate {
181
+ _id: string;
182
+ name?: string;
183
+ description?: string;
184
+ fields?: I_StructureField[];
185
+ }
186
+ export interface I_DocumentType {
187
+ _id?: string;
188
+ type: number;
189
+ subType: number;
190
+ name: string;
191
+ description?: string;
192
+ defaultStructureID?: string;
193
+ }
194
+ export type I_EventString = 'heartbeatPong' | "heartbeatPing" | "newDocument" | "newStructure" | "newUser" | "newType" | "removedID" | "changedDocument" | "changedStructure" | "changedUser" | "changedType" | "removedUser" | "removedStructure" | "removedDocument" | "removedType";
195
+ export interface I_WsMessage {
196
+ newDocument?: I_DocumentEntry;
197
+ newStructure?: I_StructureEntry;
198
+ newUser?: I_UserEntry;
199
+ removedID?: string;
200
+ changedDocument?: I_DocumentUpdate;
201
+ changedStructure?: I_StructureUpdate;
202
+ changedUser?: I_UserUpdate;
203
+ confirmSubscription?: boolean;
204
+ confirmUnsubscription?: boolean;
205
+ heartbeatPing?: number;
206
+ heartbeatPong?: number;
207
+ newType?: I_DocumentType;
208
+ }
package/dist/index.js CHANGED
@@ -141,7 +141,7 @@ export default class docPouchClient {
141
141
  }
142
142
  // Data Type Endpoints
143
143
  async createType(type) {
144
- return await this.request('/types/write', 'PATCH', type);
144
+ return await this.request('/types/write', 'POST', type);
145
145
  }
146
146
  async removeType(typeID) {
147
147
  return await this.request(`/types/remove/${typeID}`, 'DELETE');
@@ -150,7 +150,7 @@ export default class docPouchClient {
150
150
  return await this.request('/types/list', 'GET');
151
151
  }
152
152
  async updateType(updatedType) {
153
- await this.request(`/types/write`, 'PATCH', updatedType);
153
+ await this.request(`/types/write`, 'POST', updatedType);
154
154
  }
155
155
  setToken(token) {
156
156
  console.log("Setting token to:", token ? "***token***" : "null");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "docpouch-client",
3
- "version": "0.8.6",
3
+ "version": "0.8.7",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "exports": {
@@ -21,14 +21,18 @@
21
21
  "author": "Jan Frecè",
22
22
  "license": "MIT",
23
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
+ },
24
28
  "devDependencies": {
25
29
  "@types/jest": "^30.0.0",
26
30
  "@types/node": "^24.0.7",
27
31
  "jest": "^30.0.3",
28
- "ts-jest": "^29.4.0"
32
+ "ts-jest": "^29.4.0",
33
+ "typescript": "^5.8.3"
29
34
  },
30
35
  "dependencies": {
31
- "socket.io-client": "^4.8.1",
32
- "typescript": "^5.8.3"
36
+ "socket.io-client": "^4.8.1"
33
37
  }
34
38
  }
package/src/index.ts CHANGED
@@ -1,13 +1,3 @@
1
- import type {
2
- I_UserEntry,
3
- I_UserLogin,
4
- I_UserCreation,
5
- I_UserUpdate,
6
- I_UserDisplay,
7
- I_DocumentEntry,
8
- I_DataStructure,
9
- I_LoginResponse, I_DocumentQuery, I_StructureCreation, I_WsMessage, I_EventString, I_DocumentType
10
- } from "./types.js";
11
1
  import {io, Socket} from "socket.io-client";
12
2
  import packetJson from '../package.json'
13
3
 
@@ -393,5 +383,151 @@ export default class docPouchClient {
393
383
 
394
384
  return await response.json() as T;
395
385
  }
396
-
386
+ }
387
+
388
+ // Common type definitions for both frontend and backend
389
+
390
+ // User related types
391
+ export interface I_UserEntry extends I_UserCreation{
392
+ _id: string;
393
+ }
394
+
395
+ export interface I_UserLogin {
396
+ name: string;
397
+ password: string;
398
+ }
399
+
400
+ export interface I_UserCreation {
401
+ name: string;
402
+ password: string;
403
+ email?: string;
404
+ department: string;
405
+ group: string;
406
+ isAdmin: boolean;
407
+ }
408
+
409
+ export interface I_UserUpdate {
410
+ _id: string;
411
+ name?: string;
412
+ password?: string;
413
+ email?: string;
414
+ department?: string;
415
+ group?: string;
416
+ isAdmin?: boolean;
417
+ }
418
+
419
+ export interface I_UserDisplay {
420
+ _id: string;
421
+ username: string;
422
+ department: string;
423
+ group: string;
424
+ email?: string;
425
+ }
426
+
427
+ export interface I_LoginResponse {
428
+ token: string;
429
+ isAdmin: boolean;
430
+ userName: string;
431
+ }
432
+
433
+ // Document related types
434
+ export interface I_DocumentEntry extends I_DocumentCreationOwned{
435
+ _id: string;
436
+ }
437
+
438
+ export interface I_DocumentCreation {
439
+ title: string;
440
+ description?: string;
441
+ type: number;
442
+ subType: number;
443
+ content: any;
444
+ shareWithGroup: boolean;
445
+ shareWithDepartment: boolean;
446
+ }
447
+
448
+
449
+ export interface I_DocumentCreationOwned extends I_DocumentCreation {
450
+ owner: string;
451
+ }
452
+
453
+ export interface I_DocumentUpdate extends I_DocumentQuery{
454
+ _id: string;
455
+ content?: any;
456
+ description?: string;
457
+ }
458
+
459
+ export interface I_DocumentQuery {
460
+ _id?: string;
461
+ owner?: string;
462
+ title?: string;
463
+ type?: number;
464
+ subType?: number;
465
+ shareWithGroup?: boolean;
466
+ shareWithDepartment?: boolean;
467
+ }
468
+
469
+
470
+ // Structure related types
471
+ export interface I_DataStructure {
472
+ _id?: string | undefined;
473
+ name: string;
474
+ description: string;
475
+ fields: I_StructureField[];
476
+ }
477
+
478
+ export interface I_StructureField {
479
+ name: string;
480
+ type: string;
481
+ items?: string;
482
+ }
483
+
484
+ export interface I_StructureEntry {
485
+ _id?: string;
486
+ name: string;
487
+ description: string;
488
+ fields: I_StructureField[];
489
+ }
490
+
491
+
492
+ export interface I_StructureCreation {
493
+ name: string;
494
+ description?: string;
495
+ fields: I_StructureField[];
496
+ }
497
+
498
+ export interface I_StructureUpdate {
499
+ _id: string;
500
+ name?: string;
501
+ description?: string;
502
+ fields?: I_StructureField[];
503
+ }
504
+
505
+ // Document type related types
506
+ export interface I_DocumentType {
507
+ _id?: string;
508
+ type: number;
509
+ subType: number;
510
+ name: string;
511
+ description?: string;
512
+ defaultStructureID?: string;
513
+ }
514
+
515
+ // WebSocket-related types
516
+ export type I_EventString = 'heartbeatPong' | "heartbeatPing" | "newDocument" | "newStructure" |
517
+ "newUser" | "newType" | "removedID" | "changedDocument" | "changedStructure" | "changedUser" | "changedType" |
518
+ "removedUser" | "removedStructure" | "removedDocument" | "removedType";
519
+
520
+ export interface I_WsMessage {
521
+ newDocument?: I_DocumentEntry;
522
+ newStructure?: I_StructureEntry;
523
+ newUser?: I_UserEntry;
524
+ removedID?: string;
525
+ changedDocument?: I_DocumentUpdate;
526
+ changedStructure?: I_StructureUpdate;
527
+ changedUser?: I_UserUpdate;
528
+ confirmSubscription?: boolean;
529
+ confirmUnsubscription?: boolean;
530
+ heartbeatPing?: number;
531
+ heartbeatPong?: number;
532
+ newType?: I_DocumentType;
397
533
  }
package/tsconfig.json CHANGED
@@ -17,5 +17,5 @@
17
17
  "allowSyntheticDefaultImports": true
18
18
  },
19
19
  "include": ["**/*.ts", "**/*.tsx"],
20
- "exclude": ["node_modules", "**/*.test.ts", "**/*.types.ts", "./dist/**/*"]
20
+ "exclude": ["node_modules", "**/*.test.ts", "./dist/**/*"]
21
21
  }
package/dist/types.d.ts DELETED
@@ -1,116 +0,0 @@
1
- export interface I_UserEntry extends I_UserCreation {
2
- _id: string;
3
- }
4
- export interface I_UserLogin {
5
- name: string;
6
- password: string;
7
- }
8
- export interface I_UserCreation {
9
- name: string;
10
- password: string;
11
- email?: string;
12
- department: string;
13
- group: string;
14
- isAdmin: boolean;
15
- }
16
- export interface I_UserUpdate {
17
- _id: string;
18
- name?: string;
19
- password?: string;
20
- email?: string;
21
- department?: string;
22
- group?: string;
23
- isAdmin?: boolean;
24
- }
25
- export interface I_UserDisplay {
26
- _id: string;
27
- username: string;
28
- department: string;
29
- group: string;
30
- email?: string;
31
- }
32
- export interface I_LoginResponse {
33
- token: string;
34
- isAdmin: boolean;
35
- userName: string;
36
- }
37
- export interface I_DocumentEntry extends I_DocumentCreationOwned {
38
- _id: string;
39
- }
40
- export interface I_DocumentCreation {
41
- title: string;
42
- description?: string;
43
- type: number;
44
- subType: number;
45
- content: any;
46
- shareWithGroup: boolean;
47
- shareWithDepartment: boolean;
48
- }
49
- export interface I_DocumentCreationOwned extends I_DocumentCreation {
50
- owner: string;
51
- }
52
- export interface I_DocumentUpdate extends I_DocumentQuery {
53
- _id: string;
54
- content?: any;
55
- description?: string;
56
- }
57
- export interface I_DocumentQuery {
58
- _id?: string;
59
- owner?: string;
60
- title?: string;
61
- type?: number;
62
- subType?: number;
63
- shareWithGroup?: boolean;
64
- shareWithDepartment?: boolean;
65
- }
66
- export interface I_DataStructure {
67
- _id?: string | undefined;
68
- name: string;
69
- description: string;
70
- fields: I_StructureField[];
71
- }
72
- export interface I_StructureField {
73
- name: string;
74
- type: string;
75
- items?: string;
76
- }
77
- export interface I_StructureEntry {
78
- _id?: string;
79
- name: string;
80
- description: string;
81
- fields: I_StructureField[];
82
- }
83
- export interface I_StructureCreation {
84
- name: string;
85
- description?: string;
86
- fields: I_StructureField[];
87
- }
88
- export interface I_StructureUpdate {
89
- _id: string;
90
- name?: string;
91
- description?: string;
92
- fields?: I_StructureField[];
93
- }
94
- export interface I_DocumentType {
95
- _id?: string;
96
- type: number;
97
- subType: number;
98
- name: string;
99
- description?: string;
100
- defaultStructureID?: string;
101
- }
102
- export type I_EventString = 'heartbeatPong' | "heartbeatPing" | "newDocument" | "newStructure" | "newUser" | "newType" | "removedID" | "changedDocument" | "changedStructure" | "changedUser" | "changedType" | "removedUser" | "removedStructure" | "removedDocument" | "removedType";
103
- export interface I_WsMessage {
104
- newDocument?: I_DocumentEntry;
105
- newStructure?: I_StructureEntry;
106
- newUser?: I_UserEntry;
107
- removedID?: string;
108
- changedDocument?: I_DocumentUpdate;
109
- changedStructure?: I_StructureUpdate;
110
- changedUser?: I_UserUpdate;
111
- confirmSubscription?: boolean;
112
- confirmUnsubscription?: boolean;
113
- heartbeatPing?: number;
114
- heartbeatPong?: number;
115
- newType?: I_DocumentType;
116
- }
package/dist/types.js DELETED
@@ -1,2 +0,0 @@
1
- // Common type definitions for both frontend and backend
2
- export {};
package/src/types.ts DELETED
@@ -1,146 +0,0 @@
1
- // Common type definitions for both frontend and backend
2
-
3
- // User related types
4
- export interface I_UserEntry extends I_UserCreation{
5
- _id: string;
6
- }
7
-
8
- export interface I_UserLogin {
9
- name: string;
10
- password: string;
11
- }
12
-
13
- export interface I_UserCreation {
14
- name: string;
15
- password: string;
16
- email?: string;
17
- department: string;
18
- group: string;
19
- isAdmin: boolean;
20
- }
21
-
22
- export interface I_UserUpdate {
23
- _id: string;
24
- name?: string;
25
- password?: string;
26
- email?: string;
27
- department?: string;
28
- group?: string;
29
- isAdmin?: boolean;
30
- }
31
-
32
- export interface I_UserDisplay {
33
- _id: string;
34
- username: string;
35
- department: string;
36
- group: string;
37
- email?: string;
38
- }
39
-
40
- export interface I_LoginResponse {
41
- token: string;
42
- isAdmin: boolean;
43
- userName: string;
44
- }
45
-
46
- // Document related types
47
- export interface I_DocumentEntry extends I_DocumentCreationOwned{
48
- _id: string;
49
- }
50
-
51
- export interface I_DocumentCreation {
52
- title: string;
53
- description?: string;
54
- type: number;
55
- subType: number;
56
- content: any;
57
- shareWithGroup: boolean;
58
- shareWithDepartment: boolean;
59
- }
60
-
61
-
62
- export interface I_DocumentCreationOwned extends I_DocumentCreation {
63
- owner: string;
64
- }
65
-
66
- export interface I_DocumentUpdate extends I_DocumentQuery{
67
- _id: string;
68
- content?: any;
69
- description?: string;
70
- }
71
-
72
- export interface I_DocumentQuery {
73
- _id?: string;
74
- owner?: string;
75
- title?: string;
76
- type?: number;
77
- subType?: number;
78
- shareWithGroup?: boolean;
79
- shareWithDepartment?: boolean;
80
- }
81
-
82
-
83
- // Structure related types
84
- export interface I_DataStructure {
85
- _id?: string | undefined;
86
- name: string;
87
- description: string;
88
- fields: I_StructureField[];
89
- }
90
-
91
- export interface I_StructureField {
92
- name: string;
93
- type: string;
94
- items?: string;
95
- }
96
-
97
- export interface I_StructureEntry {
98
- _id?: string;
99
- name: string;
100
- description: string;
101
- fields: I_StructureField[];
102
- }
103
-
104
-
105
- export interface I_StructureCreation {
106
- name: string;
107
- description?: string;
108
- fields: I_StructureField[];
109
- }
110
-
111
- export interface I_StructureUpdate {
112
- _id: string;
113
- name?: string;
114
- description?: string;
115
- fields?: I_StructureField[];
116
- }
117
-
118
- // Document type related types
119
- export interface I_DocumentType {
120
- _id?: string;
121
- type: number;
122
- subType: number;
123
- name: string;
124
- description?: string;
125
- defaultStructureID?: string;
126
- }
127
-
128
- // WebSocket-related types
129
- export type I_EventString = 'heartbeatPong' | "heartbeatPing" | "newDocument" | "newStructure" |
130
- "newUser" | "newType" | "removedID" | "changedDocument" | "changedStructure" | "changedUser" | "changedType" |
131
- "removedUser" | "removedStructure" | "removedDocument" | "removedType";
132
-
133
- export interface I_WsMessage {
134
- newDocument?: I_DocumentEntry;
135
- newStructure?: I_StructureEntry;
136
- newUser?: I_UserEntry;
137
- removedID?: string;
138
- changedDocument?: I_DocumentUpdate;
139
- changedStructure?: I_StructureUpdate;
140
- changedUser?: I_UserUpdate;
141
- confirmSubscription?: boolean;
142
- confirmUnsubscription?: boolean;
143
- heartbeatPing?: number;
144
- heartbeatPong?: number;
145
- newType?: I_DocumentType;
146
- }