@sprucelabs/data-stores 22.2.0 → 22.3.0

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/README.md CHANGED
@@ -15,6 +15,7 @@ Spruce XP Documentation
15
15
  </p>
16
16
 
17
17
  <br />
18
+
18
19
  <p align="center">
19
20
  <a href="https://developer.spruce.ai/#/"><img width="250" src="https://raw.githubusercontent.com/sprucelabsai/data-stores/master/docs/images/read-full-docs.png" /></a>
20
21
  </p>
@@ -0,0 +1,3 @@
1
+ import { SpruceErrors } from '../errors.types';
2
+ declare const notImplementedSchema: SpruceErrors.DataStores.NotImplementedSchema;
3
+ export default notImplementedSchema;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const schema_1 = require("@sprucelabs/schema");
4
+ const notImplementedSchema = {
5
+ id: 'notImplemented',
6
+ namespace: 'DataStores',
7
+ name: 'Not implemented',
8
+ fields: {}
9
+ };
10
+ schema_1.SchemaRegistry.getInstance().trackSchema(notImplementedSchema);
11
+ exports.default = notImplementedSchema;
@@ -134,6 +134,17 @@ export declare namespace SpruceErrors.DataStores {
134
134
  }
135
135
  type RecordNotFoundEntity = SchemaEntity<SpruceErrors.DataStores.RecordNotFoundSchema>;
136
136
  }
137
+ export declare namespace SpruceErrors.DataStores {
138
+ interface NotImplemented {
139
+ }
140
+ interface NotImplementedSchema extends SpruceSchema.Schema {
141
+ id: 'notImplemented';
142
+ namespace: 'DataStores';
143
+ name: 'Not implemented';
144
+ fields: {};
145
+ }
146
+ type NotImplementedEntity = SchemaEntity<SpruceErrors.DataStores.NotImplementedSchema>;
147
+ }
137
148
  export declare namespace SpruceErrors.DataStores {
138
149
  interface MongoIdMappingError {
139
150
  }
@@ -18,6 +18,9 @@ export interface ScrambleNotConfiguredErrorOptions extends SpruceErrors.DataStor
18
18
  export interface RecordNotFoundErrorOptions extends SpruceErrors.DataStores.RecordNotFound, ISpruceErrorOptions {
19
19
  code: 'RECORD_NOT_FOUND';
20
20
  }
21
+ export interface NotImplementedErrorOptions extends SpruceErrors.DataStores.NotImplemented, ISpruceErrorOptions {
22
+ code: 'NOT_IMPLEMENTED';
23
+ }
21
24
  export interface MongoIdMappingErrorErrorOptions extends SpruceErrors.DataStores.MongoIdMappingError, ISpruceErrorOptions {
22
25
  code: 'MONGO_ID_MAPPING_ERROR';
23
26
  }
@@ -57,5 +60,5 @@ export interface DuplicateKeyErrorOptions extends SpruceErrors.DataStores.Duplic
57
60
  export interface DatabaseNotConnectedErrorOptions extends SpruceErrors.DataStores.DatabaseNotConnected, ISpruceErrorOptions {
58
61
  code: 'DATABASE_NOT_CONNECTED';
59
62
  }
60
- type ErrorOptions = UnknownStoreErrorErrorOptions | UnknownErrorErrorOptions | UnknownDatabaseErrorErrorOptions | UnableToConnectToDbErrorOptions | ScrambleNotConfiguredErrorOptions | RecordNotFoundErrorOptions | MongoIdMappingErrorErrorOptions | InvalidStoreNameErrorOptions | InvalidStoreErrorOptions | InvalidDbConnectionStringErrorOptions | InvalidDatabaseNameErrorOptions | InvalidConnectionStringSchemeErrorOptions | IndexNotFoundErrorOptions | IndexExistsErrorOptions | FailedToLoadStoresErrorOptions | FailedToLoadStoreErrorOptions | DuplicateRecordErrorOptions | DuplicateKeyErrorOptions | DatabaseNotConnectedErrorOptions;
63
+ type ErrorOptions = UnknownStoreErrorErrorOptions | UnknownErrorErrorOptions | UnknownDatabaseErrorErrorOptions | UnableToConnectToDbErrorOptions | ScrambleNotConfiguredErrorOptions | RecordNotFoundErrorOptions | NotImplementedErrorOptions | MongoIdMappingErrorErrorOptions | InvalidStoreNameErrorOptions | InvalidStoreErrorOptions | InvalidDbConnectionStringErrorOptions | InvalidDatabaseNameErrorOptions | InvalidConnectionStringSchemeErrorOptions | IndexNotFoundErrorOptions | IndexExistsErrorOptions | FailedToLoadStoresErrorOptions | FailedToLoadStoreErrorOptions | DuplicateRecordErrorOptions | DuplicateKeyErrorOptions | DatabaseNotConnectedErrorOptions;
61
64
  export default ErrorOptions;
@@ -39,4 +39,5 @@ export default class MongoDatabase implements Database {
39
39
  updateOne(collection: string, query: Record<string, any>, updates: Record<string, any>): Promise<Record<string, any>>;
40
40
  upsertOne(collection: string, query: Record<string, any>, updates: Record<string, any>): Promise<Record<string, any>>;
41
41
  private generateDuplicateFieldsForError;
42
+ query<T>(): Promise<T>;
42
43
  }
@@ -441,5 +441,10 @@ class MongoDatabase {
441
441
  duplicateValues,
442
442
  };
443
443
  }
444
+ async query() {
445
+ throw new SpruceError_1.default({
446
+ code: 'NOT_IMPLEMENTED',
447
+ });
448
+ }
444
449
  }
445
450
  exports.default = MongoDatabase;
@@ -38,4 +38,5 @@ export default class NeDbDatabase extends AbstractMutexer implements Database {
38
38
  createIndex(collection: string, fields: string[]): Promise<void>;
39
39
  syncUniqueIndexes(collectionName: string, indexes: string[][]): Promise<void>;
40
40
  syncIndexes(collectionName: string, indexes: string[][]): Promise<void>;
41
+ query<T>(): Promise<T>;
41
42
  }
@@ -451,5 +451,10 @@ class NeDbDatabase extends AbstractMutexer_1.default {
451
451
  await this.dropIndex(collectionName, extra);
452
452
  }
453
453
  }
454
+ async query() {
455
+ throw new SpruceError_1.default({
456
+ code: 'NOT_IMPLEMENTED',
457
+ });
458
+ }
454
459
  }
455
460
  exports.default = NeDbDatabase;
@@ -99,6 +99,9 @@ If you are on a mac, using brew is recommended: https://brew.sh`;
99
99
  case 'INVALID_CONNECTION_STRING_SCHEME':
100
100
  message = `There is no database adapter setup for: ${options.connectionString.split('://')[0]}`;
101
101
  break;
102
+ case 'NOT_IMPLEMENTED':
103
+ message = 'A Not implemented just happened!';
104
+ break;
102
105
  default:
103
106
  message = super.friendlyMessage();
104
107
  }
@@ -0,0 +1,6 @@
1
+ declare const _default: {
2
+ id: string;
3
+ name: string;
4
+ fields: {};
5
+ };
6
+ export default _default;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const schema_1 = require("@sprucelabs/schema");
4
+ exports.default = (0, schema_1.buildErrorSchema)({
5
+ id: 'notImplemented',
6
+ name: 'Not implemented',
7
+ fields: {},
8
+ });
@@ -134,6 +134,17 @@ export declare namespace SpruceErrors.DataStores {
134
134
  }
135
135
  type RecordNotFoundEntity = SchemaEntity<SpruceErrors.DataStores.RecordNotFoundSchema>;
136
136
  }
137
+ export declare namespace SpruceErrors.DataStores {
138
+ interface NotImplemented {
139
+ }
140
+ interface NotImplementedSchema extends SpruceSchema.Schema {
141
+ id: 'notImplemented';
142
+ namespace: 'DataStores';
143
+ name: 'Not implemented';
144
+ fields: {};
145
+ }
146
+ type NotImplementedEntity = SchemaEntity<SpruceErrors.DataStores.NotImplementedSchema>;
147
+ }
137
148
  export declare namespace SpruceErrors.DataStores {
138
149
  interface MongoIdMappingError {
139
150
  }
@@ -18,6 +18,9 @@ export interface ScrambleNotConfiguredErrorOptions extends SpruceErrors.DataStor
18
18
  export interface RecordNotFoundErrorOptions extends SpruceErrors.DataStores.RecordNotFound, ISpruceErrorOptions {
19
19
  code: 'RECORD_NOT_FOUND';
20
20
  }
21
+ export interface NotImplementedErrorOptions extends SpruceErrors.DataStores.NotImplemented, ISpruceErrorOptions {
22
+ code: 'NOT_IMPLEMENTED';
23
+ }
21
24
  export interface MongoIdMappingErrorErrorOptions extends SpruceErrors.DataStores.MongoIdMappingError, ISpruceErrorOptions {
22
25
  code: 'MONGO_ID_MAPPING_ERROR';
23
26
  }
@@ -57,5 +60,5 @@ export interface DuplicateKeyErrorOptions extends SpruceErrors.DataStores.Duplic
57
60
  export interface DatabaseNotConnectedErrorOptions extends SpruceErrors.DataStores.DatabaseNotConnected, ISpruceErrorOptions {
58
61
  code: 'DATABASE_NOT_CONNECTED';
59
62
  }
60
- type ErrorOptions = UnknownStoreErrorErrorOptions | UnknownErrorErrorOptions | UnknownDatabaseErrorErrorOptions | UnableToConnectToDbErrorOptions | ScrambleNotConfiguredErrorOptions | RecordNotFoundErrorOptions | MongoIdMappingErrorErrorOptions | InvalidStoreNameErrorOptions | InvalidStoreErrorOptions | InvalidDbConnectionStringErrorOptions | InvalidDatabaseNameErrorOptions | InvalidConnectionStringSchemeErrorOptions | IndexNotFoundErrorOptions | IndexExistsErrorOptions | FailedToLoadStoresErrorOptions | FailedToLoadStoreErrorOptions | DuplicateRecordErrorOptions | DuplicateKeyErrorOptions | DatabaseNotConnectedErrorOptions;
63
+ type ErrorOptions = UnknownStoreErrorErrorOptions | UnknownErrorErrorOptions | UnknownDatabaseErrorErrorOptions | UnableToConnectToDbErrorOptions | ScrambleNotConfiguredErrorOptions | RecordNotFoundErrorOptions | NotImplementedErrorOptions | MongoIdMappingErrorErrorOptions | InvalidStoreNameErrorOptions | InvalidStoreErrorOptions | InvalidDbConnectionStringErrorOptions | InvalidDatabaseNameErrorOptions | InvalidConnectionStringSchemeErrorOptions | IndexNotFoundErrorOptions | IndexExistsErrorOptions | FailedToLoadStoresErrorOptions | FailedToLoadStoreErrorOptions | DuplicateRecordErrorOptions | DuplicateKeyErrorOptions | DatabaseNotConnectedErrorOptions;
61
64
  export default ErrorOptions;
@@ -39,4 +39,5 @@ export default class MongoDatabase implements Database {
39
39
  updateOne(collection: string, query: Record<string, any>, updates: Record<string, any>): Promise<Record<string, any>>;
40
40
  upsertOne(collection: string, query: Record<string, any>, updates: Record<string, any>): Promise<Record<string, any>>;
41
41
  private generateDuplicateFieldsForError;
42
+ query<T>(): Promise<T>;
42
43
  }
@@ -486,4 +486,11 @@ export default class MongoDatabase {
486
486
  duplicateValues,
487
487
  };
488
488
  }
489
+ query() {
490
+ return __awaiter(this, void 0, void 0, function* () {
491
+ throw new SpruceError({
492
+ code: 'NOT_IMPLEMENTED',
493
+ });
494
+ });
495
+ }
489
496
  }
@@ -38,4 +38,5 @@ export default class NeDbDatabase extends AbstractMutexer implements Database {
38
38
  createIndex(collection: string, fields: string[]): Promise<void>;
39
39
  syncUniqueIndexes(collectionName: string, indexes: string[][]): Promise<void>;
40
40
  syncIndexes(collectionName: string, indexes: string[][]): Promise<void>;
41
+ query<T>(): Promise<T>;
41
42
  }
@@ -501,4 +501,11 @@ export default class NeDbDatabase extends AbstractMutexer {
501
501
  }
502
502
  });
503
503
  }
504
+ query() {
505
+ return __awaiter(this, void 0, void 0, function* () {
506
+ throw new SpruceError({
507
+ code: 'NOT_IMPLEMENTED',
508
+ });
509
+ });
510
+ }
504
511
  }
@@ -94,6 +94,9 @@ If you are on a mac, using brew is recommended: https://brew.sh`;
94
94
  case 'INVALID_CONNECTION_STRING_SCHEME':
95
95
  message = `There is no database adapter setup for: ${options.connectionString.split('://')[0]}`;
96
96
  break;
97
+ case 'NOT_IMPLEMENTED':
98
+ message = 'A Not implemented just happened!';
99
+ break;
97
100
  default:
98
101
  message = super.friendlyMessage();
99
102
  }
@@ -0,0 +1,6 @@
1
+ declare const _default: {
2
+ id: string;
3
+ name: string;
4
+ fields: {};
5
+ };
6
+ export default _default;
@@ -0,0 +1,6 @@
1
+ import { buildErrorSchema } from '@sprucelabs/schema';
2
+ export default buildErrorSchema({
3
+ id: 'notImplemented',
4
+ name: 'Not implemented',
5
+ fields: {},
6
+ });
@@ -27,6 +27,7 @@ export interface Database {
27
27
  count(collection: string, query?: Record<string, any>): Promise<number>;
28
28
  createUniqueIndex(collection: string, fields: UniqueIndex): Promise<void>;
29
29
  createIndex(collection: string, fields: Index): Promise<void>;
30
+ query<T>(query: string): Promise<T>;
30
31
  }
31
32
  export interface DatabaseOptions {
32
33
  dbName?: string;
@@ -27,6 +27,7 @@ export interface Database {
27
27
  count(collection: string, query?: Record<string, any>): Promise<number>;
28
28
  createUniqueIndex(collection: string, fields: UniqueIndex): Promise<void>;
29
29
  createIndex(collection: string, fields: Index): Promise<void>;
30
+ query<T>(query: string): Promise<T>;
30
31
  }
31
32
  export interface DatabaseOptions {
32
33
  dbName?: string;
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "22.2.0",
6
+ "version": "22.3.0",
7
7
  "files": [
8
8
  "build/**/*",
9
9
  "!build/__tests__",