@sprucelabs/data-stores 18.0.9 → 18.0.12

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.
@@ -9,6 +9,7 @@ export default class StoreLoader {
9
9
  private static instance;
10
10
  private static defaultStoreDir;
11
11
  private static defaultDb;
12
+ private factory?;
12
13
  private constructor();
13
14
  static setStoreDir(dir: string): void;
14
15
  static setDatabase(db: Database): void;
@@ -64,12 +64,22 @@ export default class StoreLoader {
64
64
  }
65
65
  loadStoresAndErrors() {
66
66
  return __awaiter(this, void 0, void 0, function* () {
67
- const { stores, errors } = yield this.loadStoreClassesWithErrors();
68
- const factory = StoreFactory.Factory(this.db);
69
- for (const store of stores) {
70
- factory.setStoreClass(namesUtil.toCamel(store.namePascal), store.Class);
67
+ let errors = [];
68
+ if (!this.factory) {
69
+ const { stores, errors: loadedErrors } = yield this.loadStoreClassesWithErrors();
70
+ errors = loadedErrors;
71
+ const factory = StoreFactory.Factory(this.db);
72
+ for (const store of stores) {
73
+ factory.setStoreClass(namesUtil.toCamel(store.namePascal), store.Class);
74
+ }
75
+ if (errors.length === 0) {
76
+ this.factory = factory;
77
+ }
78
+ else {
79
+ return { factory, errors };
80
+ }
71
81
  }
72
- return { factory, errors };
82
+ return { factory: this.factory, errors };
73
83
  });
74
84
  }
75
85
  loadStoreClassesWithErrors() {
@@ -9,6 +9,7 @@ export default class StoreLoader {
9
9
  private static instance;
10
10
  private static defaultStoreDir;
11
11
  private static defaultDb;
12
+ private factory?;
12
13
  private constructor();
13
14
  static setStoreDir(dir: string): void;
14
15
  static setDatabase(db: Database): void;
@@ -53,12 +53,22 @@ class StoreLoader {
53
53
  return factory;
54
54
  }
55
55
  async loadStoresAndErrors() {
56
- const { stores, errors } = await this.loadStoreClassesWithErrors();
57
- const factory = StoreFactory_1.default.Factory(this.db);
58
- for (const store of stores) {
59
- factory.setStoreClass(spruce_skill_utils_1.namesUtil.toCamel(store.namePascal), store.Class);
56
+ let errors = [];
57
+ if (!this.factory) {
58
+ const { stores, errors: loadedErrors } = await this.loadStoreClassesWithErrors();
59
+ errors = loadedErrors;
60
+ const factory = StoreFactory_1.default.Factory(this.db);
61
+ for (const store of stores) {
62
+ factory.setStoreClass(spruce_skill_utils_1.namesUtil.toCamel(store.namePascal), store.Class);
63
+ }
64
+ if (errors.length === 0) {
65
+ this.factory = factory;
66
+ }
67
+ else {
68
+ return { factory, errors };
69
+ }
60
70
  }
61
- return { factory, errors };
71
+ return { factory: this.factory, errors };
62
72
  }
63
73
  async loadStoreClassesWithErrors() {
64
74
  var _a, _b;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "18.0.9",
6
+ "version": "18.0.12",
7
7
  "files": [
8
8
  "build/**/*",
9
9
  "!build/__tests__",
@@ -74,7 +74,7 @@
74
74
  "dependencies": {
75
75
  "@sprucelabs/error": "^5.0.490",
76
76
  "@sprucelabs/schema": "^28.4.2",
77
- "@sprucelabs/spruce-skill-utils": "^26.4.0",
77
+ "@sprucelabs/spruce-skill-utils": "^26.4.1",
78
78
  "globby": "^11.0.4",
79
79
  "just-clone": "^6.0.1",
80
80
  "lodash": "^4.17.21",