@sprucelabs/data-stores 25.13.0 → 25.13.1
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/build/esm/stores/AbstractStore.d.ts +2 -2
- package/build/esm/types/database.types.d.ts +0 -24
- package/build/esm/types/stores.types.d.ts +25 -0
- package/build/stores/AbstractStore.d.ts +2 -2
- package/build/types/database.types.d.ts +0 -24
- package/build/types/stores.types.d.ts +25 -0
- package/package.json +8 -8
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Schema, SchemaFieldNames, SchemaPartialValues, SchemaPublicFieldNames, SchemaValues } from '@sprucelabs/schema';
|
|
2
2
|
import { FindBatchOptions } from '../cursors/BatchCursor';
|
|
3
3
|
import AbstractMutexer from '../mutexers/AbstractMutexer';
|
|
4
|
-
import {
|
|
4
|
+
import { Database } from '../types/database.types';
|
|
5
5
|
import { QueryBuilder, QueryOptions } from '../types/query.types';
|
|
6
|
-
import { PrepareOptions, PrepareResults, SaveOperations, DataStore } from '../types/stores.types';
|
|
6
|
+
import { PrepareOptions, PrepareResults, SaveOperations, DataStore, DataStorePlugin } from '../types/stores.types';
|
|
7
7
|
export default abstract class AbstractStore<FullSchema extends Schema, CreateSchema extends Schema = FullSchema, UpdateSchema extends Schema = CreateSchema, DatabaseSchema extends Schema = FullSchema, DatabaseRecord = SchemaValues<DatabaseSchema>, QueryRecord = SchemaPartialValues<FullSchema>, FullRecord = SchemaValues<FullSchema>, CreateRecord = SchemaValues<CreateSchema>, UpdateRecord = SchemaValues<UpdateSchema> & SaveOperations> extends AbstractMutexer implements DataStore {
|
|
8
8
|
abstract readonly name: string;
|
|
9
9
|
protected abstract collectionName: string;
|
|
@@ -39,27 +39,3 @@ export type TestConnect = (connectionString?: string, dbName?: string) => Promis
|
|
|
39
39
|
connectionStringWithRandomBadDatabaseName: string;
|
|
40
40
|
badDatabaseName: string;
|
|
41
41
|
}>;
|
|
42
|
-
export interface DataStorePlugin {
|
|
43
|
-
willCreateOne?: (values: Record<string, any>) => Promise<void | DataStorePluginWillCreateOneResponse>;
|
|
44
|
-
didCreateOne?: (record: Record<string, any>) => Promise<void | DataStorePluginDidCreateOneResponse>;
|
|
45
|
-
willUpdateOne?: (query: Record<string, any>, updates: Record<string, any>) => Promise<void | DataStorePluginWillUpdateOneResponse>;
|
|
46
|
-
willDeleteOne?: (query: Record<string, any>) => Promise<void | DataStorePluginWillDeleteOneResponse>;
|
|
47
|
-
didFindOne?: (query: Record<string, any>, record: Record<string, any>) => Promise<void | DataStorePluginDidFindOneResponse>;
|
|
48
|
-
getName(): string;
|
|
49
|
-
}
|
|
50
|
-
export interface DataStorePluginDidCreateOneResponse {
|
|
51
|
-
valuesToMixinBeforeReturning?: Record<string, any>;
|
|
52
|
-
}
|
|
53
|
-
export interface DataStorePluginWillCreateOneResponse {
|
|
54
|
-
valuesToMixinBeforeCreate?: Record<string, any>;
|
|
55
|
-
}
|
|
56
|
-
export interface DataStorePluginWillUpdateOneResponse {
|
|
57
|
-
query?: Record<string, any>;
|
|
58
|
-
shouldUpdate?: boolean;
|
|
59
|
-
}
|
|
60
|
-
export interface DataStorePluginWillDeleteOneResponse {
|
|
61
|
-
query?: Record<string, any>;
|
|
62
|
-
}
|
|
63
|
-
export interface DataStorePluginDidFindOneResponse {
|
|
64
|
-
valuesToMixinBeforeReturning?: Record<string, any>;
|
|
65
|
-
}
|
|
@@ -11,6 +11,7 @@ export interface UniversalStoreOptions {
|
|
|
11
11
|
export interface DataStore {
|
|
12
12
|
initialize?(): Promise<void>;
|
|
13
13
|
getCollectionName?(): string;
|
|
14
|
+
getDb?(): Database;
|
|
14
15
|
}
|
|
15
16
|
/**
|
|
16
17
|
* @deprecated SimplifiedStoreFactory -> SimpleStoreFactory
|
|
@@ -29,3 +30,27 @@ export interface PrepareOptions<IncludePrivateFields extends boolean, S extends
|
|
|
29
30
|
export type PrepareResults<S extends Schema, IncludePrivateFields extends boolean> = IncludePrivateFields extends true ? SchemaPublicValues<S> : SchemaValues<S>;
|
|
30
31
|
export type StoreName = keyof StoreMap;
|
|
31
32
|
export type StoreOptions<Name extends StoreName> = Name extends keyof StoreOptionsMap ? StoreOptionsMap[Name] : Record<string, never>;
|
|
33
|
+
export interface DataStorePlugin {
|
|
34
|
+
willCreateOne?: (values: Record<string, any>) => Promise<void | DataStorePluginWillCreateOneResponse>;
|
|
35
|
+
didCreateOne?: (record: Record<string, any>) => Promise<void | DataStorePluginDidCreateOneResponse>;
|
|
36
|
+
willUpdateOne?: (query: Record<string, any>, updates: Record<string, any>) => Promise<void | DataStorePluginWillUpdateOneResponse>;
|
|
37
|
+
willDeleteOne?: (query: Record<string, any>) => Promise<void | DataStorePluginWillDeleteOneResponse>;
|
|
38
|
+
didFindOne?: (query: Record<string, any>, record: Record<string, any>) => Promise<void | DataStorePluginDidFindOneResponse>;
|
|
39
|
+
getName(): string;
|
|
40
|
+
}
|
|
41
|
+
export interface DataStorePluginDidCreateOneResponse {
|
|
42
|
+
valuesToMixinBeforeReturning?: Record<string, any>;
|
|
43
|
+
}
|
|
44
|
+
export interface DataStorePluginWillCreateOneResponse {
|
|
45
|
+
valuesToMixinBeforeCreate?: Record<string, any>;
|
|
46
|
+
}
|
|
47
|
+
export interface DataStorePluginWillUpdateOneResponse {
|
|
48
|
+
query?: Record<string, any>;
|
|
49
|
+
shouldUpdate?: boolean;
|
|
50
|
+
}
|
|
51
|
+
export interface DataStorePluginWillDeleteOneResponse {
|
|
52
|
+
query?: Record<string, any>;
|
|
53
|
+
}
|
|
54
|
+
export interface DataStorePluginDidFindOneResponse {
|
|
55
|
+
valuesToMixinBeforeReturning?: Record<string, any>;
|
|
56
|
+
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Schema, SchemaFieldNames, SchemaPartialValues, SchemaPublicFieldNames, SchemaValues } from '@sprucelabs/schema';
|
|
2
2
|
import { FindBatchOptions } from '../cursors/BatchCursor';
|
|
3
3
|
import AbstractMutexer from '../mutexers/AbstractMutexer';
|
|
4
|
-
import {
|
|
4
|
+
import { Database } from '../types/database.types';
|
|
5
5
|
import { QueryBuilder, QueryOptions } from '../types/query.types';
|
|
6
|
-
import { PrepareOptions, PrepareResults, SaveOperations, DataStore } from '../types/stores.types';
|
|
6
|
+
import { PrepareOptions, PrepareResults, SaveOperations, DataStore, DataStorePlugin } from '../types/stores.types';
|
|
7
7
|
export default abstract class AbstractStore<FullSchema extends Schema, CreateSchema extends Schema = FullSchema, UpdateSchema extends Schema = CreateSchema, DatabaseSchema extends Schema = FullSchema, DatabaseRecord = SchemaValues<DatabaseSchema>, QueryRecord = SchemaPartialValues<FullSchema>, FullRecord = SchemaValues<FullSchema>, CreateRecord = SchemaValues<CreateSchema>, UpdateRecord = SchemaValues<UpdateSchema> & SaveOperations> extends AbstractMutexer implements DataStore {
|
|
8
8
|
abstract readonly name: string;
|
|
9
9
|
protected abstract collectionName: string;
|
|
@@ -39,27 +39,3 @@ export type TestConnect = (connectionString?: string, dbName?: string) => Promis
|
|
|
39
39
|
connectionStringWithRandomBadDatabaseName: string;
|
|
40
40
|
badDatabaseName: string;
|
|
41
41
|
}>;
|
|
42
|
-
export interface DataStorePlugin {
|
|
43
|
-
willCreateOne?: (values: Record<string, any>) => Promise<void | DataStorePluginWillCreateOneResponse>;
|
|
44
|
-
didCreateOne?: (record: Record<string, any>) => Promise<void | DataStorePluginDidCreateOneResponse>;
|
|
45
|
-
willUpdateOne?: (query: Record<string, any>, updates: Record<string, any>) => Promise<void | DataStorePluginWillUpdateOneResponse>;
|
|
46
|
-
willDeleteOne?: (query: Record<string, any>) => Promise<void | DataStorePluginWillDeleteOneResponse>;
|
|
47
|
-
didFindOne?: (query: Record<string, any>, record: Record<string, any>) => Promise<void | DataStorePluginDidFindOneResponse>;
|
|
48
|
-
getName(): string;
|
|
49
|
-
}
|
|
50
|
-
export interface DataStorePluginDidCreateOneResponse {
|
|
51
|
-
valuesToMixinBeforeReturning?: Record<string, any>;
|
|
52
|
-
}
|
|
53
|
-
export interface DataStorePluginWillCreateOneResponse {
|
|
54
|
-
valuesToMixinBeforeCreate?: Record<string, any>;
|
|
55
|
-
}
|
|
56
|
-
export interface DataStorePluginWillUpdateOneResponse {
|
|
57
|
-
query?: Record<string, any>;
|
|
58
|
-
shouldUpdate?: boolean;
|
|
59
|
-
}
|
|
60
|
-
export interface DataStorePluginWillDeleteOneResponse {
|
|
61
|
-
query?: Record<string, any>;
|
|
62
|
-
}
|
|
63
|
-
export interface DataStorePluginDidFindOneResponse {
|
|
64
|
-
valuesToMixinBeforeReturning?: Record<string, any>;
|
|
65
|
-
}
|
|
@@ -11,6 +11,7 @@ export interface UniversalStoreOptions {
|
|
|
11
11
|
export interface DataStore {
|
|
12
12
|
initialize?(): Promise<void>;
|
|
13
13
|
getCollectionName?(): string;
|
|
14
|
+
getDb?(): Database;
|
|
14
15
|
}
|
|
15
16
|
/**
|
|
16
17
|
* @deprecated SimplifiedStoreFactory -> SimpleStoreFactory
|
|
@@ -29,3 +30,27 @@ export interface PrepareOptions<IncludePrivateFields extends boolean, S extends
|
|
|
29
30
|
export type PrepareResults<S extends Schema, IncludePrivateFields extends boolean> = IncludePrivateFields extends true ? SchemaPublicValues<S> : SchemaValues<S>;
|
|
30
31
|
export type StoreName = keyof StoreMap;
|
|
31
32
|
export type StoreOptions<Name extends StoreName> = Name extends keyof StoreOptionsMap ? StoreOptionsMap[Name] : Record<string, never>;
|
|
33
|
+
export interface DataStorePlugin {
|
|
34
|
+
willCreateOne?: (values: Record<string, any>) => Promise<void | DataStorePluginWillCreateOneResponse>;
|
|
35
|
+
didCreateOne?: (record: Record<string, any>) => Promise<void | DataStorePluginDidCreateOneResponse>;
|
|
36
|
+
willUpdateOne?: (query: Record<string, any>, updates: Record<string, any>) => Promise<void | DataStorePluginWillUpdateOneResponse>;
|
|
37
|
+
willDeleteOne?: (query: Record<string, any>) => Promise<void | DataStorePluginWillDeleteOneResponse>;
|
|
38
|
+
didFindOne?: (query: Record<string, any>, record: Record<string, any>) => Promise<void | DataStorePluginDidFindOneResponse>;
|
|
39
|
+
getName(): string;
|
|
40
|
+
}
|
|
41
|
+
export interface DataStorePluginDidCreateOneResponse {
|
|
42
|
+
valuesToMixinBeforeReturning?: Record<string, any>;
|
|
43
|
+
}
|
|
44
|
+
export interface DataStorePluginWillCreateOneResponse {
|
|
45
|
+
valuesToMixinBeforeCreate?: Record<string, any>;
|
|
46
|
+
}
|
|
47
|
+
export interface DataStorePluginWillUpdateOneResponse {
|
|
48
|
+
query?: Record<string, any>;
|
|
49
|
+
shouldUpdate?: boolean;
|
|
50
|
+
}
|
|
51
|
+
export interface DataStorePluginWillDeleteOneResponse {
|
|
52
|
+
query?: Record<string, any>;
|
|
53
|
+
}
|
|
54
|
+
export interface DataStorePluginDidFindOneResponse {
|
|
55
|
+
valuesToMixinBeforeReturning?: Record<string, any>;
|
|
56
|
+
}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"publishConfig": {
|
|
4
4
|
"access": "public"
|
|
5
5
|
},
|
|
6
|
-
"version": "25.13.
|
|
6
|
+
"version": "25.13.1",
|
|
7
7
|
"files": [
|
|
8
8
|
"build/**/*",
|
|
9
9
|
"!build/__tests__",
|
|
@@ -68,23 +68,23 @@
|
|
|
68
68
|
"upgrade.packages.test": "yarn upgrade.packages.all && yarn lint && yarn build.dev && yarn test"
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"@sprucelabs/error": "^5.1.
|
|
71
|
+
"@sprucelabs/error": "^5.1.44",
|
|
72
72
|
"@sprucelabs/globby": "^1.0.3",
|
|
73
73
|
"@sprucelabs/schema": "^29.0.83",
|
|
74
|
-
"@sprucelabs/spruce-skill-utils": "^30.1.
|
|
74
|
+
"@sprucelabs/spruce-skill-utils": "^30.1.19",
|
|
75
75
|
"just-clone": "^6.2.0",
|
|
76
76
|
"lodash": "^4.17.21",
|
|
77
77
|
"mongodb": "^6.2.0",
|
|
78
78
|
"nedb": "^1.8.0"
|
|
79
79
|
},
|
|
80
80
|
"devDependencies": {
|
|
81
|
-
"@sprucelabs/esm-postbuild": "^5.0.
|
|
82
|
-
"@sprucelabs/jest-json-reporter": "^7.0.
|
|
81
|
+
"@sprucelabs/esm-postbuild": "^5.0.92",
|
|
82
|
+
"@sprucelabs/jest-json-reporter": "^7.0.119",
|
|
83
83
|
"@sprucelabs/jest-sheets-reporter": "^3.0.26",
|
|
84
|
-
"@sprucelabs/resolve-path-aliases": "^1.1.
|
|
84
|
+
"@sprucelabs/resolve-path-aliases": "^1.1.260",
|
|
85
85
|
"@sprucelabs/semantic-release": "^4.0.8",
|
|
86
86
|
"@sprucelabs/test": "^8.0.27",
|
|
87
|
-
"@sprucelabs/test-utils": "^4.0.
|
|
87
|
+
"@sprucelabs/test-utils": "^4.0.71",
|
|
88
88
|
"@types/lodash": "^4.14.201",
|
|
89
89
|
"@types/nedb": "^1.8.16",
|
|
90
90
|
"@types/node": "^20.9.0",
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
"eslint-config-spruce": "^10.13.6",
|
|
96
96
|
"jest": "^29.7.0",
|
|
97
97
|
"jest-circus": "^29.7.0",
|
|
98
|
-
"prettier": "^3.0
|
|
98
|
+
"prettier": "^3.1.0",
|
|
99
99
|
"ts-node": "^10.9.1",
|
|
100
100
|
"tsc-watch": "^6.0.4",
|
|
101
101
|
"tsconfig-paths": "^4.2.0",
|