beanbagdb 0.5.77 → 0.6.0
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/package.json +1 -1
- package/src/index.js +227 -122
- package/src/system_schema.js +208 -141
- package/test/operations.test.js +264 -581
- package/test/pouchdb.js +74 -25
- package/test/test1.js +106 -147
- package/src/plugins/text_command.js +0 -191
- package/test/plugin.test.js +0 -52
package/src/system_schema.js
CHANGED
|
@@ -1,130 +1,160 @@
|
|
|
1
1
|
export const default_app = {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
description:
|
|
2
|
+
app_id: "beanbagdb_system",
|
|
3
|
+
meta: {
|
|
4
|
+
description:
|
|
5
|
+
"This is the default system app required for proper functioning of the database",
|
|
5
6
|
},
|
|
6
|
-
schemas:[
|
|
7
|
+
schemas: [
|
|
7
8
|
{
|
|
8
9
|
name: "schema",
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
active: true,
|
|
11
|
+
description: "Meta-schema or the schema for defining other schemas",
|
|
12
|
+
system_generated: true,
|
|
13
|
+
version: 0.88,
|
|
14
|
+
title: "Schema document",
|
|
13
15
|
schema: {
|
|
14
16
|
type: "object",
|
|
15
17
|
additionalProperties: false,
|
|
16
18
|
properties: {
|
|
17
|
-
system_generated:{
|
|
18
|
-
title:"System generated schema",
|
|
19
|
-
type:"boolean",
|
|
20
|
-
default:false
|
|
19
|
+
system_generated: {
|
|
20
|
+
title: "System generated schema",
|
|
21
|
+
type: "boolean",
|
|
22
|
+
default: false,
|
|
23
|
+
},
|
|
24
|
+
active: {
|
|
25
|
+
title:"Active",
|
|
26
|
+
description: "This indicates where new documents can be created using this schema or not. Old documents can still be edited",
|
|
27
|
+
type: "boolean",
|
|
28
|
+
default: false,
|
|
21
29
|
},
|
|
22
30
|
version: {
|
|
23
31
|
type: "number",
|
|
24
|
-
title:"Version",
|
|
32
|
+
title: "Version",
|
|
25
33
|
minimum: 0,
|
|
26
34
|
default: 1,
|
|
27
|
-
description:
|
|
28
|
-
|
|
35
|
+
description:
|
|
36
|
+
"This is an optional field.To be used primarily for system schemas",
|
|
37
|
+
},
|
|
29
38
|
name: {
|
|
30
39
|
type: "string",
|
|
31
|
-
title:"Name",
|
|
40
|
+
title: "Name",
|
|
32
41
|
minLength: 4,
|
|
33
42
|
maxLength: 50,
|
|
34
43
|
pattern: "^[a-zA-Z][a-zA-Z0-9_]*$",
|
|
35
|
-
description:
|
|
44
|
+
description:
|
|
45
|
+
"This is the name of the schema.It cannot be changed later",
|
|
36
46
|
},
|
|
37
|
-
|
|
38
|
-
type:"string",
|
|
39
|
-
title:"
|
|
40
|
-
minLength:0,
|
|
41
|
-
maxLength:1000,
|
|
42
|
-
description:"A
|
|
47
|
+
title: {
|
|
48
|
+
type: "string",
|
|
49
|
+
title: "Title",
|
|
50
|
+
minLength: 0,
|
|
51
|
+
maxLength: 1000,
|
|
52
|
+
description: "A title to display with records.",
|
|
43
53
|
},
|
|
44
|
-
|
|
45
|
-
type:"string",
|
|
46
|
-
title:"About",
|
|
47
|
-
minLength:0,
|
|
48
|
-
maxLength:1000,
|
|
49
|
-
description:
|
|
54
|
+
description: {
|
|
55
|
+
type: "string",
|
|
56
|
+
title: "About",
|
|
57
|
+
minLength: 0,
|
|
58
|
+
maxLength: 1000,
|
|
59
|
+
description:
|
|
60
|
+
"A small description of what data in this schema stores.",
|
|
50
61
|
},
|
|
51
62
|
schema: {
|
|
52
63
|
type: "object",
|
|
53
|
-
title:"JSON Schema specification",
|
|
64
|
+
title: "JSON Schema specification",
|
|
54
65
|
additionalProperties: true,
|
|
55
66
|
minProperties: 1,
|
|
56
67
|
maxProperties: 50,
|
|
57
|
-
description:
|
|
68
|
+
description:
|
|
69
|
+
"This must be a valid JSON Schema which will be used to validate documents created with this schema.See this https://tour.json-schema.org/",
|
|
70
|
+
default: {},
|
|
58
71
|
},
|
|
59
72
|
settings: {
|
|
60
73
|
type: "object",
|
|
61
|
-
title:"Additional Settings",
|
|
74
|
+
title: "Additional Settings",
|
|
62
75
|
additionalProperties: true,
|
|
63
76
|
properties: {
|
|
64
77
|
primary_keys: {
|
|
65
|
-
title:"Primary key",
|
|
78
|
+
title: "Primary key",
|
|
66
79
|
type: "array",
|
|
67
80
|
default: [],
|
|
68
81
|
items: {
|
|
69
82
|
type: "string",
|
|
70
83
|
},
|
|
71
84
|
maxItems: 10,
|
|
72
|
-
description:
|
|
85
|
+
description:
|
|
86
|
+
"Fields that makes each document unique in the schema.Leave it blank if you do not need it. You can still be able to distinguish documents using the link field and the document id.",
|
|
73
87
|
},
|
|
74
88
|
non_editable_fields: {
|
|
75
89
|
type: "array",
|
|
76
|
-
title:"Non editable fields",
|
|
90
|
+
title: "Non editable fields",
|
|
77
91
|
default: [],
|
|
78
92
|
items: {
|
|
79
93
|
type: "string",
|
|
80
94
|
},
|
|
81
95
|
maxItems: 50,
|
|
82
|
-
minItems:0,
|
|
83
|
-
description:
|
|
96
|
+
minItems: 0,
|
|
97
|
+
description:
|
|
98
|
+
"The list of fields whose values are added when the document is created but cannot be edited later in future.",
|
|
84
99
|
},
|
|
85
100
|
encrypted_fields: {
|
|
86
101
|
type: "array",
|
|
87
|
-
title:"List of fields encrypted",
|
|
102
|
+
title: "List of fields encrypted",
|
|
88
103
|
default: [],
|
|
89
104
|
items: {
|
|
90
105
|
type: "string",
|
|
91
106
|
},
|
|
92
107
|
maxItems: 50,
|
|
93
|
-
description:
|
|
108
|
+
description:
|
|
109
|
+
"Once set, all the data in this field will be encrypted before storing it in the database. Encryption key must be provided during the time of BeanBagDB initialization and must be managed by the user as it is NOT stored in the database",
|
|
94
110
|
},
|
|
95
111
|
display_fields: {
|
|
96
112
|
type: "array",
|
|
97
|
-
title:"List of fields to show in short view",
|
|
113
|
+
title: "List of fields to show in short view",
|
|
98
114
|
default: [],
|
|
99
115
|
items: {
|
|
100
116
|
type: "string",
|
|
101
117
|
},
|
|
102
118
|
maxItems: 50,
|
|
103
|
-
description:
|
|
104
|
-
|
|
119
|
+
description:
|
|
120
|
+
"These fields will be used when a record is displayed in short",
|
|
121
|
+
},
|
|
122
|
+
install_source: {
|
|
123
|
+
type: "string",
|
|
124
|
+
title: "Installation source",
|
|
125
|
+
default: "human",
|
|
126
|
+
description:
|
|
127
|
+
"Describes how this schema was installed in database. This is determined by the system. By default the value is human. Possible value: name of the app , where it was cloned from etc...",
|
|
128
|
+
},
|
|
105
129
|
},
|
|
106
|
-
required
|
|
130
|
+
required: [
|
|
131
|
+
"primary_keys",
|
|
132
|
+
"non_editable_fields",
|
|
133
|
+
"encrypted_fields",
|
|
134
|
+
],
|
|
107
135
|
},
|
|
108
136
|
},
|
|
109
|
-
required: ["name","description","schema", "settings","title"],
|
|
137
|
+
required: ["name", "description", "schema", "settings", "title"],
|
|
110
138
|
},
|
|
111
139
|
settings: {
|
|
112
140
|
primary_keys: ["name"],
|
|
113
|
-
non_editable_fields:[],
|
|
114
|
-
encrypted_fields:[],
|
|
115
|
-
display_fields:["name","version","description","title"]
|
|
141
|
+
non_editable_fields: ["system_generated"],
|
|
142
|
+
encrypted_fields: [],
|
|
143
|
+
display_fields: ["name", "version", "description", "title", "active"],
|
|
116
144
|
},
|
|
117
145
|
},
|
|
118
146
|
{
|
|
119
|
-
system_generated:true,
|
|
120
|
-
version:0.
|
|
121
|
-
description:
|
|
147
|
+
system_generated: true,
|
|
148
|
+
version: 0.63,
|
|
149
|
+
description:
|
|
150
|
+
"To store user defined key. this can include anything like API tokens etc. There is a special method to fetch this. The values are encrypted",
|
|
122
151
|
name: "system_key",
|
|
123
|
-
title:"System key",
|
|
152
|
+
title: "System key",
|
|
153
|
+
active: true,
|
|
124
154
|
schema: {
|
|
125
155
|
type: "object",
|
|
126
156
|
additionalProperties: true,
|
|
127
|
-
required:["name","value"],
|
|
157
|
+
required: ["name", "value"],
|
|
128
158
|
properties: {
|
|
129
159
|
name: {
|
|
130
160
|
type: "string",
|
|
@@ -137,7 +167,7 @@ export const default_app = {
|
|
|
137
167
|
minLength: 5,
|
|
138
168
|
maxLength: 5000,
|
|
139
169
|
pattern: "^[^\n\r]*$",
|
|
140
|
-
description:"Must be a single line string"
|
|
170
|
+
description: "Must be a single line string",
|
|
141
171
|
},
|
|
142
172
|
note: {
|
|
143
173
|
type: "string",
|
|
@@ -148,18 +178,20 @@ export const default_app = {
|
|
|
148
178
|
},
|
|
149
179
|
settings: {
|
|
150
180
|
primary_keys: ["name"],
|
|
151
|
-
encrypted_fields:["value"],
|
|
152
|
-
non_editable_fields:[]
|
|
181
|
+
encrypted_fields: ["value"],
|
|
182
|
+
non_editable_fields: [],
|
|
153
183
|
},
|
|
154
184
|
},
|
|
155
185
|
{
|
|
156
|
-
version:0.
|
|
157
|
-
system_generated:true,
|
|
158
|
-
description:
|
|
186
|
+
version: 0.67,
|
|
187
|
+
system_generated: true,
|
|
188
|
+
description:
|
|
189
|
+
"The system relies on these settings for proper functioning or enabling optional features.",
|
|
159
190
|
name: "system_setting",
|
|
160
|
-
title:"System Setting",
|
|
191
|
+
title: "System Setting",
|
|
192
|
+
active: true,
|
|
161
193
|
schema: {
|
|
162
|
-
required:["name","value"],
|
|
194
|
+
required: ["name", "value"],
|
|
163
195
|
type: "object",
|
|
164
196
|
additionalProperties: true,
|
|
165
197
|
properties: {
|
|
@@ -170,79 +202,84 @@ export const default_app = {
|
|
|
170
202
|
pattern: "^[a-zA-Z][a-zA-Z0-9_]*$",
|
|
171
203
|
},
|
|
172
204
|
value: {
|
|
173
|
-
type: ["array","object"]
|
|
174
|
-
}
|
|
205
|
+
type: ["array", "object"],
|
|
206
|
+
},
|
|
175
207
|
},
|
|
176
208
|
},
|
|
177
209
|
settings: {
|
|
178
210
|
primary_keys: ["name"],
|
|
179
211
|
non_editable_fields: ["name"],
|
|
180
|
-
encrypted_fields:[]
|
|
212
|
+
encrypted_fields: [],
|
|
181
213
|
},
|
|
182
214
|
},
|
|
183
215
|
{
|
|
184
|
-
name:"system_edge_constraint",
|
|
185
|
-
title:"Edge constraint",
|
|
186
|
-
system_generated:true,
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
216
|
+
name: "system_edge_constraint",
|
|
217
|
+
title: "Edge constraint",
|
|
218
|
+
system_generated: true,
|
|
219
|
+
active: true,
|
|
220
|
+
version: 0.52,
|
|
221
|
+
description:
|
|
222
|
+
"To define edge constraints for simple directed graph of records.",
|
|
223
|
+
schema: {
|
|
190
224
|
type: "object",
|
|
191
225
|
additionalProperties: true,
|
|
192
|
-
required:["node1","node2","edge_type"],
|
|
226
|
+
required: ["node1", "node2", "edge_type"],
|
|
193
227
|
properties: {
|
|
194
228
|
node1: {
|
|
195
229
|
type: "string",
|
|
196
230
|
minLength: 1,
|
|
197
231
|
maxLength: 500,
|
|
198
|
-
pattern:
|
|
232
|
+
pattern:
|
|
233
|
+
"^(\\*|(\\*-[a-zA-Z0-9_-]+)(,[a-zA-Z0-9_-]+)*|[a-zA-Z0-9_-]+(,[a-zA-Z0-9_-]+)*)$",
|
|
199
234
|
},
|
|
200
235
|
node2: {
|
|
201
236
|
type: "string",
|
|
202
237
|
minLength: 1,
|
|
203
238
|
maxLength: 500,
|
|
204
|
-
pattern:
|
|
239
|
+
pattern:
|
|
240
|
+
"^(\\*|(\\*-[a-zA-Z0-9_-]+)(,[a-zA-Z0-9_-]+)*|[a-zA-Z0-9_-]+(,[a-zA-Z0-9_-]+)*)$",
|
|
205
241
|
},
|
|
206
|
-
name:{
|
|
242
|
+
name: {
|
|
207
243
|
type: "string",
|
|
208
244
|
minLength: 1,
|
|
209
245
|
maxLength: 500,
|
|
210
246
|
pattern: "^[a-zA-Z][a-zA-Z0-9_]*$",
|
|
211
247
|
},
|
|
212
|
-
label:{
|
|
248
|
+
label: {
|
|
213
249
|
type: "string",
|
|
214
250
|
maxLength: 500,
|
|
215
251
|
},
|
|
216
|
-
note:{
|
|
252
|
+
note: {
|
|
217
253
|
type: "string",
|
|
218
254
|
maxLength: 5000,
|
|
219
255
|
},
|
|
220
|
-
max_from_node1:{
|
|
221
|
-
type:"number",
|
|
256
|
+
max_from_node1: {
|
|
257
|
+
type: "number",
|
|
222
258
|
default: -1,
|
|
223
259
|
},
|
|
224
|
-
max_to_node2:{
|
|
225
|
-
type:"number",
|
|
260
|
+
max_to_node2: {
|
|
261
|
+
type: "number",
|
|
226
262
|
default: -1,
|
|
227
|
-
}
|
|
228
|
-
}
|
|
263
|
+
},
|
|
264
|
+
},
|
|
229
265
|
},
|
|
230
266
|
settings: {
|
|
231
267
|
primary_keys: ["name"],
|
|
232
|
-
non_editable_fields:["name"],
|
|
233
|
-
encrypted_fields:[]
|
|
268
|
+
non_editable_fields: ["name"],
|
|
269
|
+
encrypted_fields: [],
|
|
234
270
|
},
|
|
235
271
|
},
|
|
236
272
|
{
|
|
237
|
-
name:"system_edge",
|
|
238
|
-
title:"Edge in the system graph",
|
|
239
|
-
|
|
240
|
-
|
|
273
|
+
name: "system_edge",
|
|
274
|
+
title: "Edge in the system graph",
|
|
275
|
+
active: true,
|
|
276
|
+
system_generated: true,
|
|
277
|
+
version: 0.52,
|
|
241
278
|
description: "To define edges in the simple directed graph of records.",
|
|
242
|
-
schema:{
|
|
279
|
+
schema: {
|
|
243
280
|
type: "object",
|
|
244
281
|
additionalProperties: true,
|
|
245
|
-
required:["node1","node2","edge_type"],
|
|
282
|
+
required: ["node1", "node2", "edge_type"],
|
|
246
283
|
properties: {
|
|
247
284
|
node1: {
|
|
248
285
|
type: "string",
|
|
@@ -250,58 +287,60 @@ export const default_app = {
|
|
|
250
287
|
node2: {
|
|
251
288
|
type: "string",
|
|
252
289
|
},
|
|
253
|
-
edge_name:{
|
|
290
|
+
edge_name: {
|
|
254
291
|
type: "string",
|
|
255
|
-
}
|
|
256
|
-
}
|
|
292
|
+
},
|
|
293
|
+
},
|
|
257
294
|
},
|
|
258
295
|
settings: {
|
|
259
|
-
primary_keys: ["node1","node2","edge_type"],
|
|
260
|
-
non_editable_fields:["edge_type"],
|
|
261
|
-
encrypted_fields:[]
|
|
296
|
+
primary_keys: ["node1", "node2", "edge_type"],
|
|
297
|
+
non_editable_fields: ["edge_type"],
|
|
298
|
+
encrypted_fields: [],
|
|
262
299
|
},
|
|
263
300
|
},
|
|
264
301
|
{
|
|
265
|
-
name:"system_media",
|
|
266
|
-
title:"Media content",
|
|
267
|
-
|
|
268
|
-
|
|
302
|
+
name: "system_media",
|
|
303
|
+
title: "Media content",
|
|
304
|
+
active: true,
|
|
305
|
+
system_generated: true,
|
|
306
|
+
version: 0.62,
|
|
269
307
|
description: "To store images as Base64",
|
|
270
|
-
schema:{
|
|
308
|
+
schema: {
|
|
271
309
|
type: "object",
|
|
272
310
|
additionalProperties: true,
|
|
273
|
-
required:["imageBase64","caption","source"],
|
|
311
|
+
required: ["imageBase64", "caption", "source"],
|
|
274
312
|
properties: {
|
|
275
313
|
imageBase64: {
|
|
276
314
|
type: "string",
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
}
|
|
315
|
+
media: {
|
|
316
|
+
binaryEncoding: "base64",
|
|
317
|
+
},
|
|
280
318
|
},
|
|
281
319
|
caption: {
|
|
282
320
|
type: "string",
|
|
283
321
|
},
|
|
284
|
-
source:{
|
|
322
|
+
source: {
|
|
285
323
|
type: "string",
|
|
286
|
-
}
|
|
287
|
-
}
|
|
324
|
+
},
|
|
325
|
+
},
|
|
288
326
|
},
|
|
289
327
|
settings: {
|
|
290
328
|
primary_keys: ["caption"],
|
|
291
|
-
non_editable_fields:[],
|
|
292
|
-
encrypted_fields:[]
|
|
329
|
+
non_editable_fields: [],
|
|
330
|
+
encrypted_fields: [],
|
|
293
331
|
},
|
|
294
332
|
},
|
|
295
333
|
{
|
|
296
|
-
name:"system_log",
|
|
297
|
-
system_generated:true,
|
|
298
|
-
title:"System log",
|
|
299
|
-
|
|
334
|
+
name: "system_log",
|
|
335
|
+
system_generated: true,
|
|
336
|
+
title: "System log",
|
|
337
|
+
active: true,
|
|
338
|
+
version: 0.52,
|
|
300
339
|
description: "To define edges in the simple directed graph of records.",
|
|
301
|
-
schema:{
|
|
340
|
+
schema: {
|
|
302
341
|
type: "object",
|
|
303
342
|
additionalProperties: true,
|
|
304
|
-
required:["text"],
|
|
343
|
+
required: ["text"],
|
|
305
344
|
properties: {
|
|
306
345
|
text: {
|
|
307
346
|
type: "string",
|
|
@@ -310,42 +349,70 @@ export const default_app = {
|
|
|
310
349
|
type: "object",
|
|
311
350
|
additionalProperties: true,
|
|
312
351
|
},
|
|
313
|
-
app:{
|
|
352
|
+
app: {
|
|
314
353
|
type: "string",
|
|
315
354
|
},
|
|
316
|
-
time:{
|
|
317
|
-
type:"string"
|
|
318
|
-
}
|
|
319
|
-
}
|
|
355
|
+
time: {
|
|
356
|
+
type: "string",
|
|
357
|
+
},
|
|
358
|
+
},
|
|
320
359
|
},
|
|
321
360
|
settings: {
|
|
322
361
|
primary_keys: [],
|
|
323
|
-
non_editable_fields:[],
|
|
324
|
-
encrypted_fields:[]
|
|
362
|
+
non_editable_fields: [],
|
|
363
|
+
encrypted_fields: [],
|
|
325
364
|
},
|
|
326
|
-
}
|
|
327
|
-
],
|
|
328
|
-
records:[]
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
|
|
365
|
+
},
|
|
366
|
+
],
|
|
367
|
+
records: [],
|
|
368
|
+
};
|
|
332
369
|
|
|
333
370
|
// this is not stored in the DB. only for validating the metadata during doc update
|
|
334
371
|
export const editable_metadata_schema = {
|
|
335
372
|
additionalProperties: false,
|
|
336
|
-
type:"object",
|
|
337
|
-
properties:{
|
|
338
|
-
tags:{
|
|
339
|
-
type:"array",
|
|
340
|
-
items:{type:"string"},
|
|
341
|
-
default:[],
|
|
373
|
+
type: "object",
|
|
374
|
+
properties: {
|
|
375
|
+
tags: {
|
|
376
|
+
type: "array",
|
|
377
|
+
items: { type: "string" },
|
|
378
|
+
default: [],
|
|
342
379
|
maxItems: 40,
|
|
343
380
|
},
|
|
344
|
-
link:{
|
|
345
|
-
type:"string",
|
|
346
|
-
minLength:2,
|
|
347
|
-
maxLength:2000,
|
|
348
|
-
pattern: "^[a-zA-Z0-9-]+$"
|
|
381
|
+
link: {
|
|
382
|
+
type: "string",
|
|
383
|
+
minLength: 2,
|
|
384
|
+
maxLength: 2000,
|
|
385
|
+
pattern: "^[a-zA-Z0-9-]+$",
|
|
386
|
+
},
|
|
387
|
+
},
|
|
388
|
+
};
|
|
389
|
+
|
|
390
|
+
export const app_data_schema = {
|
|
391
|
+
additionalProperties: true,
|
|
392
|
+
type: "object",
|
|
393
|
+
required: ["app_id"],
|
|
394
|
+
properties: {
|
|
395
|
+
app_id: {
|
|
396
|
+
type: "string",
|
|
397
|
+
},
|
|
398
|
+
meta: {
|
|
399
|
+
type: "object",
|
|
400
|
+
additionalProperties: true,
|
|
401
|
+
},
|
|
402
|
+
schemas: {
|
|
403
|
+
type: "array",
|
|
404
|
+
minItems: 1,
|
|
405
|
+
// each schema must have a version
|
|
406
|
+
},
|
|
407
|
+
records: {
|
|
408
|
+
type: "array",
|
|
409
|
+
// each record must have a version
|
|
410
|
+
default:[]
|
|
411
|
+
},
|
|
412
|
+
default_setting:{
|
|
413
|
+
type: "object",
|
|
414
|
+
additionalProperties:true,
|
|
415
|
+
default : {}
|
|
349
416
|
}
|
|
350
|
-
}
|
|
351
|
-
}
|
|
417
|
+
},
|
|
418
|
+
};
|