goby-database 2.1.16 → 2.1.18
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 +6 -5
- package/dist/index.js +13 -10
- package/dist/types.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -99,6 +99,7 @@ export default class Project {
|
|
|
99
99
|
retrieve_workspace_contents(id: number): {
|
|
100
100
|
blocks: WorkspaceBlock[];
|
|
101
101
|
items: unknown[];
|
|
102
|
+
classes: ClassData[];
|
|
102
103
|
};
|
|
103
104
|
action_config_window({ type, open, metadata, id }: {
|
|
104
105
|
type: ApplicationWindow["type"];
|
|
@@ -107,9 +108,9 @@ export default class Project {
|
|
|
107
108
|
id?: number;
|
|
108
109
|
}): number | undefined;
|
|
109
110
|
create_workspace(open: ApplicationWindow["open"], metadata: ApplicationWindow["metadata"]): number;
|
|
110
|
-
action_create_workspace_block({ workspace_id,
|
|
111
|
+
action_create_workspace_block({ workspace_id, type, block_metadata, thing_id }: {
|
|
111
112
|
workspace_id: ApplicationWindow["id"];
|
|
112
|
-
|
|
113
|
+
type: WorkspaceBlock["type"];
|
|
113
114
|
block_metadata: WorkspaceBlock["metadata"];
|
|
114
115
|
thing_id: WorkspaceBlock["thing_id"];
|
|
115
116
|
}): number;
|
|
@@ -117,14 +118,14 @@ export default class Project {
|
|
|
117
118
|
workspace_id: number;
|
|
118
119
|
block_id: number;
|
|
119
120
|
}): void;
|
|
120
|
-
action_create_and_add_to_workspace({ workspace_id,
|
|
121
|
+
action_create_and_add_to_workspace({ workspace_id, type, block_metadata, thing_data }: {
|
|
121
122
|
workspace_id: number;
|
|
122
|
-
|
|
123
|
+
type: WorkspaceBlock["type"];
|
|
123
124
|
block_metadata: WorkspaceBlock["metadata"];
|
|
124
125
|
thing_data: any;
|
|
125
126
|
}): {
|
|
126
127
|
thing_id: number;
|
|
127
128
|
block_id: number;
|
|
128
129
|
};
|
|
129
|
-
action_remove_from_workspace_and_delete(workspace_id: number, block_id: number,
|
|
130
|
+
action_remove_from_workspace_and_delete(workspace_id: number, block_id: number, type: WorkspaceBlock["type"], thing_id: number): void;
|
|
130
131
|
}
|
package/dist/index.js
CHANGED
|
@@ -942,16 +942,19 @@ export default class Project {
|
|
|
942
942
|
let blocks = blocks_sql.map(a => (Object.assign(Object.assign({}, a), { metadata: JSON.parse(a.metadata) })));
|
|
943
943
|
// for(let block of blocks) block.metadata=JSON.parse(block.metadata);
|
|
944
944
|
// get any relevant root items
|
|
945
|
-
|
|
945
|
+
const items = this.db.prepare(`SELECT system_root.*
|
|
946
946
|
FROM system_root
|
|
947
947
|
LEFT JOIN workspace_${id}
|
|
948
948
|
ON system_root.id = workspace_${id}.thing_id
|
|
949
949
|
WHERE workspace_${id}.type = 'item';
|
|
950
950
|
`).all();
|
|
951
|
-
// get any relevant classes
|
|
951
|
+
// get any relevant classes
|
|
952
|
+
const classes = this.class_cache.filter((cls) => blocks.some((block) => block.type == 'class' && block.thing_id == cls.id));
|
|
953
|
+
// NOTE: could possibly add class items as well in the future
|
|
952
954
|
return {
|
|
953
955
|
blocks,
|
|
954
|
-
items
|
|
956
|
+
items,
|
|
957
|
+
classes
|
|
955
958
|
};
|
|
956
959
|
}
|
|
957
960
|
action_config_window({ type, open, metadata = { pos: [null, null], size: [1000, 700] }, id }) {
|
|
@@ -985,11 +988,11 @@ export default class Project {
|
|
|
985
988
|
]);
|
|
986
989
|
return id;
|
|
987
990
|
}
|
|
988
|
-
action_create_workspace_block({ workspace_id,
|
|
991
|
+
action_create_workspace_block({ workspace_id, type, block_metadata, thing_id }) {
|
|
989
992
|
var _a;
|
|
990
993
|
// should return block id
|
|
991
994
|
this.db.prepare(`INSERT INTO workspace_${workspace_id}(type,metadata,thing_id) VALUES (@type,@metadata,@thing_id)`).run({
|
|
992
|
-
type:
|
|
995
|
+
type: type,
|
|
993
996
|
metadata: JSON.stringify(block_metadata),
|
|
994
997
|
thing_id
|
|
995
998
|
});
|
|
@@ -1002,10 +1005,10 @@ export default class Project {
|
|
|
1002
1005
|
this.db.prepare(`DELETE FROM workspace_${workspace_id} WHERE block_id = ${block_id}`).run();
|
|
1003
1006
|
}
|
|
1004
1007
|
;
|
|
1005
|
-
action_create_and_add_to_workspace({ workspace_id,
|
|
1008
|
+
action_create_and_add_to_workspace({ workspace_id, type, block_metadata, thing_data }) {
|
|
1006
1009
|
let thing_id;
|
|
1007
1010
|
// thing creation
|
|
1008
|
-
switch (
|
|
1011
|
+
switch (type) {
|
|
1009
1012
|
case 'item':
|
|
1010
1013
|
let { value: item_value, type: item_type } = thing_data;
|
|
1011
1014
|
thing_id = this.create_item_in_root({ type: item_type, value: item_value });
|
|
@@ -1016,7 +1019,7 @@ export default class Project {
|
|
|
1016
1019
|
throw Error('Something went wrong saving an item from a workspace');
|
|
1017
1020
|
let block_id = this.action_create_workspace_block({
|
|
1018
1021
|
workspace_id,
|
|
1019
|
-
|
|
1022
|
+
type,
|
|
1020
1023
|
block_metadata,
|
|
1021
1024
|
thing_id
|
|
1022
1025
|
});
|
|
@@ -1026,9 +1029,9 @@ export default class Project {
|
|
|
1026
1029
|
};
|
|
1027
1030
|
// should return the block id and item id
|
|
1028
1031
|
}
|
|
1029
|
-
action_remove_from_workspace_and_delete(workspace_id, block_id,
|
|
1032
|
+
action_remove_from_workspace_and_delete(workspace_id, block_id, type, thing_id) {
|
|
1030
1033
|
this.action_remove_workspace_block({ workspace_id, block_id });
|
|
1031
|
-
switch (
|
|
1034
|
+
switch (type) {
|
|
1032
1035
|
case 'item':
|
|
1033
1036
|
this.delete_item_from_root(thing_id);
|
|
1034
1037
|
break;
|
package/dist/types.d.ts
CHANGED
|
@@ -163,7 +163,7 @@ export type ThingType = 'item' | 'class';
|
|
|
163
163
|
export type BaseWorkspaceBlock = {
|
|
164
164
|
/** this is the ID of the display element in the workspace, generated by the workspace table */
|
|
165
165
|
block_id: number;
|
|
166
|
-
|
|
166
|
+
type: ThingType;
|
|
167
167
|
/** this is the ID of the class, item, or other “thing” represented in the data */
|
|
168
168
|
thing_id: number;
|
|
169
169
|
};
|