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 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, thing_type, block_metadata, thing_id }: {
111
+ action_create_workspace_block({ workspace_id, type, block_metadata, thing_id }: {
112
112
  workspace_id: ApplicationWindow["id"];
113
- thing_type: WorkspaceBlock["thing_type"];
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, thing_type, block_metadata, thing_data }: {
121
+ action_create_and_add_to_workspace({ workspace_id, type, block_metadata, thing_data }: {
122
122
  workspace_id: number;
123
- thing_type: WorkspaceBlock["thing_type"];
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, thing_type: WorkspaceBlock["thing_type"], thing_id: number): void;
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.find((block) => { block.thing_type == 'class' && block.thing_id == cls.id; }));
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, thing_type, block_metadata, thing_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: thing_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, thing_type, block_metadata, thing_data }) {
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 (thing_type) {
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
- thing_type,
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, thing_type, thing_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 (thing_type) {
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
- thing_type: ThingType;
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
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "goby-database",
3
- "version": "2.1.17",
3
+ "version": "2.1.18",
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
6
  "files": [