goby-database 2.0.11 → 2.0.13

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.
@@ -0,0 +1,94 @@
1
+ import { readable_junctionlist } from './utils.js';
2
+ console.log('--------------------------------------------------------');
3
+ console.log('SANDBOX: running test...\n');
4
+ import Project from './index.js';
5
+ const project = new Project(':memory:');
6
+ console.log('--------------------------------------------------------');
7
+ console.log('SANDBOX: setting up book-author-script schema\n');
8
+ project.action_edit_class_schema({
9
+ class_edits: [
10
+ { type: 'create', class_name: 'author' },
11
+ { type: 'create', class_name: 'book' },
12
+ { type: 'create', class_name: 'script' }
13
+ ],
14
+ property_edits: [
15
+ { type: 'create', class_name: 'author', prop_name: 'age', config: { type: 'data', data_type: 'number', max_values: 1 } },
16
+ { type: 'create', class_name: 'author', prop_name: 'works', config: { type: 'relation', max_values: null } },
17
+ { type: 'create', class_name: 'author', prop_name: 'books read', config: { type: 'relation', max_values: null } },
18
+ { type: 'create', class_name: 'book', prop_name: 'author', config: { type: 'relation', max_values: 1 } }
19
+ ],
20
+ relationship_edits: [
21
+ { type: 'create', sides: [{ class_name: 'author', prop_name: 'works' }, { class_name: 'book', prop_name: 'author' }] },
22
+ { type: 'create', sides: [{ class_name: 'author', prop_name: 'works' }, { class_name: 'script' }] },
23
+ { type: 'create', sides: [{ class_name: 'author', prop_name: 'books read' }, { class_name: 'book' }] }
24
+ ]
25
+ });
26
+ console.log(project.junction_cache.map(a => a.sides));
27
+ console.log('--------------------------------------------------------');
28
+ console.log('SANDBOX: adding items to classes\n');
29
+ project.action_add_row(1);
30
+ project.action_add_row(2);
31
+ project.action_add_row(2);
32
+ project.action_add_row(3);
33
+ console.log('--------------------------------------------------------');
34
+ console.log('SANDBOX: making connections between items in classes\n');
35
+ project.action_make_relation({
36
+ class_id: 1,
37
+ prop_id: 3,
38
+ item_id: 1
39
+ }, {
40
+ class_id: 2,
41
+ prop_id: 2,
42
+ item_id: 2
43
+ });
44
+ project.action_make_relation({
45
+ class_id: 1,
46
+ prop_id: 3,
47
+ item_id: 1
48
+ }, {
49
+ class_id: 2,
50
+ prop_id: 2,
51
+ item_id: 3
52
+ });
53
+ project.action_make_relation({
54
+ class_id: 1,
55
+ prop_id: 3,
56
+ item_id: 1
57
+ }, {
58
+ class_id: 3,
59
+ item_id: 4
60
+ });
61
+ project.action_make_relation({
62
+ class_id: 1,
63
+ prop_id: 4,
64
+ item_id: 1
65
+ }, {
66
+ class_id: 2,
67
+ item_id: 2
68
+ });
69
+ project.refresh_caches(['classlist', 'items', 'junctions']);
70
+ console.log('--------------------------------------------------------');
71
+ console.log('SANDBOX: deleting author property in books\n');
72
+ project.action_edit_class_schema({
73
+ property_edits: [
74
+ {
75
+ type: 'delete',
76
+ class_id: 2,
77
+ prop_id: 2
78
+ },
79
+ {
80
+ type: 'create',
81
+ class_id: 2,
82
+ prop_name: 'author2',
83
+ config: {
84
+ type: 'relation',
85
+ max_values: 1
86
+ }
87
+ }
88
+ ],
89
+ relationship_edits: [
90
+ { type: 'create', sides: [{ class_id: 1, prop_id: 3 }, { class_id: 2, prop_name: 'author2' }] }
91
+ ]
92
+ });
93
+ console.log(readable_junctionlist(project.junction_cache, project.class_cache));
94
+ //# sourceMappingURL=sandbox.js.map
package/dist/types.d.ts CHANGED
@@ -143,15 +143,16 @@ export type JunctionTable = {
143
143
  metadata: {};
144
144
  };
145
145
  export type JunctionList = JunctionTable[];
146
+ export type WindowType = 'home' | 'hopper' | 'workspace';
146
147
  export type SQLApplicationWindow = {
147
148
  id: number;
148
- type: string;
149
+ type: WindowType;
149
150
  open: BinaryBoolean;
150
151
  metadata: string;
151
152
  };
152
153
  export type ApplicationWindow = {
153
154
  id: number;
154
- type: string;
155
+ type: WindowType;
155
156
  open: BinaryBoolean;
156
157
  metadata: {
157
158
  pos: [null, null] | [number, number];
package/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "goby-database",
3
- "version": "2.0.11",
3
+ "version": "2.0.13",
4
4
  "description": "This will hold the core better-sqlite3-powered application for creating and modifying goby databases",
5
5
  "main": "dist/index.js",
6
+ "files": [
7
+ "/dist"
8
+ ],
6
9
  "types": "dist/index.d.ts",
7
10
  "scripts": {
8
11
  "build": "tsc",