@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 +1 -0
- package/build/.spruce/errors/dataStores/notImplemented.schema.d.ts +3 -0
- package/build/.spruce/errors/dataStores/notImplemented.schema.js +11 -0
- package/build/.spruce/errors/errors.types.d.ts +11 -0
- package/build/.spruce/errors/options.types.d.ts +4 -1
- package/build/databases/MongoDatabase.d.ts +1 -0
- package/build/databases/MongoDatabase.js +5 -0
- package/build/databases/NeDbDatabase.d.ts +1 -0
- package/build/databases/NeDbDatabase.js +5 -0
- package/build/errors/SpruceError.js +3 -0
- package/build/errors/notImplemented.builder.d.ts +6 -0
- package/build/errors/notImplemented.builder.js +8 -0
- package/build/esm/.spruce/errors/errors.types.d.ts +11 -0
- package/build/esm/.spruce/errors/options.types.d.ts +4 -1
- package/build/esm/databases/MongoDatabase.d.ts +1 -0
- package/build/esm/databases/MongoDatabase.js +7 -0
- package/build/esm/databases/NeDbDatabase.d.ts +1 -0
- package/build/esm/databases/NeDbDatabase.js +7 -0
- package/build/esm/errors/SpruceError.js +3 -0
- package/build/esm/errors/notImplemented.builder.d.ts +6 -0
- package/build/esm/errors/notImplemented.builder.js +6 -0
- package/build/esm/types/database.types.d.ts +1 -0
- package/build/types/database.types.d.ts +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -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
|
}
|
|
@@ -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
|
}
|
|
@@ -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
|
}
|
|
@@ -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
|
}
|
|
@@ -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
|
}
|
|
@@ -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;
|