goby-database 2.2.33 → 2.2.35

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
@@ -94,12 +94,17 @@ export default class Project {
94
94
  /**
95
95
  * Adds/removes relations between items/item properties.
96
96
  * Can create new items in a class if a label is specified instead of an item id.
97
+ * Returns modified list of items, including IDs of any newly created items
97
98
  * @param relations - list of pairs of items for which relations should be added or removed between specified properties
98
99
  */
99
100
  action_edit_relations(relations: {
100
101
  change: 'add' | 'remove';
101
102
  sides: [input_1: ItemRelationSideInput, input_2: ItemRelationSideInput];
102
- }[]): void;
103
+ }[]): {
104
+ class_id: number;
105
+ prop_id?: number;
106
+ item_id: number;
107
+ }[];
103
108
  retrieve_class_items({ class_id, class_name, class_data, pagination }: {
104
109
  class_id: number;
105
110
  class_name?: string;
package/dist/index.js CHANGED
@@ -775,13 +775,15 @@ export default class Project {
775
775
  /**
776
776
  * Adds/removes relations between items/item properties.
777
777
  * Can create new items in a class if a label is specified instead of an item id.
778
+ * Returns modified list of items, including IDs of any newly created items
778
779
  * @param relations - list of pairs of items for which relations should be added or removed between specified properties
779
780
  */
780
781
  action_edit_relations(relations) {
782
+ var _a;
783
+ const edited_items = [];
781
784
  // NOTE: changes to make to this in the future:
782
785
  // - for input readability, allow class_name and prop_name as input options, assuming they’re enforced as unique, and use them to look up IDs
783
786
  // - enforce max_values here
784
- var _a;
785
787
  for (let { change, sides } of relations) {
786
788
  let [input_1, input_2] = sides;
787
789
  const column_names = {
@@ -820,6 +822,7 @@ export default class Project {
820
822
  };
821
823
  }
822
824
  });
825
+ record_if_new(sides_registered);
823
826
  input_1 = sides_registered[0];
824
827
  input_2 = sides_registered[1];
825
828
  const column_value_set = [
@@ -882,13 +885,26 @@ export default class Project {
882
885
  DELETE FROM junction_${junction_id}
883
886
  WHERE "${column_names.input_1}" = ${input_1.item_id}
884
887
  AND "${column_names.input_2}" = ${input_2.item_id}`).run();
888
+ record_if_new([input_1, input_2]);
885
889
  }
886
890
  else {
887
891
  console.log('skipped relation delete (either item input is missing an ID)');
888
892
  }
889
893
  }
890
894
  }
891
- // NOTE: should this trigger a refresh to items?
895
+ function record_if_new(item_inputs) {
896
+ for (let { class_id, item_id, prop_id } of item_inputs) {
897
+ const new_edge = { class_id, item_id, prop_id };
898
+ if (!edited_items.some((edge) => {
899
+ return edge.class_id == new_edge.class_id &&
900
+ edge.item_id == new_edge.item_id &&
901
+ edge.prop_id == new_edge.prop_id;
902
+ })) {
903
+ edited_items.push(new_edge);
904
+ }
905
+ }
906
+ }
907
+ return edited_items;
892
908
  }
893
909
  // MARKER: modify item retrieval
894
910
  retrieve_class_items({ class_id, class_name, class_data, pagination = {} }) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "goby-database",
3
- "version": "2.2.33",
3
+ "version": "2.2.35",
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
  "repository":{