goby-database 2.1.17 → 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 +5 -5
- package/dist/index.js +8 -8
- package/dist/types.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -108,9 +108,9 @@ export default class Project {
|
|
|
108
108
|
id?: number;
|
|
109
109
|
}): number | undefined;
|
|
110
110
|
create_workspace(open: ApplicationWindow["open"], metadata: ApplicationWindow["metadata"]): number;
|
|
111
|
-
action_create_workspace_block({ workspace_id,
|
|
111
|
+
action_create_workspace_block({ workspace_id, type, block_metadata, thing_id }: {
|
|
112
112
|
workspace_id: ApplicationWindow["id"];
|
|
113
|
-
|
|
113
|
+
type: WorkspaceBlock["type"];
|
|
114
114
|
block_metadata: WorkspaceBlock["metadata"];
|
|
115
115
|
thing_id: WorkspaceBlock["thing_id"];
|
|
116
116
|
}): number;
|
|
@@ -118,14 +118,14 @@ export default class Project {
|
|
|
118
118
|
workspace_id: number;
|
|
119
119
|
block_id: number;
|
|
120
120
|
}): void;
|
|
121
|
-
action_create_and_add_to_workspace({ workspace_id,
|
|
121
|
+
action_create_and_add_to_workspace({ workspace_id, type, block_metadata, thing_data }: {
|
|
122
122
|
workspace_id: number;
|
|
123
|
-
|
|
123
|
+
type: WorkspaceBlock["type"];
|
|
124
124
|
block_metadata: WorkspaceBlock["metadata"];
|
|
125
125
|
thing_data: any;
|
|
126
126
|
}): {
|
|
127
127
|
thing_id: number;
|
|
128
128
|
block_id: number;
|
|
129
129
|
};
|
|
130
|
-
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;
|
|
131
131
|
}
|
package/dist/index.js
CHANGED
|
@@ -949,7 +949,7 @@ export default class Project {
|
|
|
949
949
|
WHERE workspace_${id}.type = 'item';
|
|
950
950
|
`).all();
|
|
951
951
|
// get any relevant classes
|
|
952
|
-
const classes = this.class_cache.filter((cls) => blocks.
|
|
952
|
+
const classes = this.class_cache.filter((cls) => blocks.some((block) => block.type == 'class' && block.thing_id == cls.id));
|
|
953
953
|
// NOTE: could possibly add class items as well in the future
|
|
954
954
|
return {
|
|
955
955
|
blocks,
|
|
@@ -988,11 +988,11 @@ export default class Project {
|
|
|
988
988
|
]);
|
|
989
989
|
return id;
|
|
990
990
|
}
|
|
991
|
-
action_create_workspace_block({ workspace_id,
|
|
991
|
+
action_create_workspace_block({ workspace_id, type, block_metadata, thing_id }) {
|
|
992
992
|
var _a;
|
|
993
993
|
// should return block id
|
|
994
994
|
this.db.prepare(`INSERT INTO workspace_${workspace_id}(type,metadata,thing_id) VALUES (@type,@metadata,@thing_id)`).run({
|
|
995
|
-
type:
|
|
995
|
+
type: type,
|
|
996
996
|
metadata: JSON.stringify(block_metadata),
|
|
997
997
|
thing_id
|
|
998
998
|
});
|
|
@@ -1005,10 +1005,10 @@ export default class Project {
|
|
|
1005
1005
|
this.db.prepare(`DELETE FROM workspace_${workspace_id} WHERE block_id = ${block_id}`).run();
|
|
1006
1006
|
}
|
|
1007
1007
|
;
|
|
1008
|
-
action_create_and_add_to_workspace({ workspace_id,
|
|
1008
|
+
action_create_and_add_to_workspace({ workspace_id, type, block_metadata, thing_data }) {
|
|
1009
1009
|
let thing_id;
|
|
1010
1010
|
// thing creation
|
|
1011
|
-
switch (
|
|
1011
|
+
switch (type) {
|
|
1012
1012
|
case 'item':
|
|
1013
1013
|
let { value: item_value, type: item_type } = thing_data;
|
|
1014
1014
|
thing_id = this.create_item_in_root({ type: item_type, value: item_value });
|
|
@@ -1019,7 +1019,7 @@ export default class Project {
|
|
|
1019
1019
|
throw Error('Something went wrong saving an item from a workspace');
|
|
1020
1020
|
let block_id = this.action_create_workspace_block({
|
|
1021
1021
|
workspace_id,
|
|
1022
|
-
|
|
1022
|
+
type,
|
|
1023
1023
|
block_metadata,
|
|
1024
1024
|
thing_id
|
|
1025
1025
|
});
|
|
@@ -1029,9 +1029,9 @@ export default class Project {
|
|
|
1029
1029
|
};
|
|
1030
1030
|
// should return the block id and item id
|
|
1031
1031
|
}
|
|
1032
|
-
action_remove_from_workspace_and_delete(workspace_id, block_id,
|
|
1032
|
+
action_remove_from_workspace_and_delete(workspace_id, block_id, type, thing_id) {
|
|
1033
1033
|
this.action_remove_workspace_block({ workspace_id, block_id });
|
|
1034
|
-
switch (
|
|
1034
|
+
switch (type) {
|
|
1035
1035
|
case 'item':
|
|
1036
1036
|
this.delete_item_from_root(thing_id);
|
|
1037
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
|
};
|