@sprucelabs/data-stores 16.0.28 → 16.0.29

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.
@@ -2,10 +2,7 @@ import { DynamicSchemaAllValues, Schema, IsDynamicSchema, SchemaAllValues, Schem
2
2
  import AbstractMutexer from '../mutexers/AbstractMutexer';
3
3
  import { Database } from '../types/database.types';
4
4
  import { QueryBuilder, QueryOptions } from '../types/query.types';
5
- import { PrepareOptions, PrepareResults } from '../types/stores.types';
6
- declare const operations: readonly ["$push", "$inc", "$min", "$max", "$mul", "$push", "$pull", "$pop"];
7
- declare type SaveOperation = typeof operations[number];
8
- declare type SaveOperations = Partial<Record<SaveOperation, Record<string, any>>>;
5
+ import { PrepareOptions, PrepareResults, SaveOperations } from '../types/stores.types';
9
6
  declare type Response<FullSchema extends Schema, CreateEntityInstances extends boolean, IncludePrivateFields extends boolean, PF extends SchemaPublicFieldNames<FullSchema>, F extends SchemaFieldNames<FullSchema>> = IsDynamicSchema<FullSchema> extends true ? DynamicSchemaAllValues<FullSchema, CreateEntityInstances> : IncludePrivateFields extends false ? Pick<SchemaPublicValues<FullSchema, CreateEntityInstances>, PF> : Pick<SchemaAllValues<FullSchema, CreateEntityInstances>, F>;
10
7
  export default abstract class AbstractStore<FullSchema extends Schema, CreateSchema extends Schema = FullSchema, UpdateSchema extends Schema = CreateSchema, DatabaseSchema extends Schema = FullSchema, DatabaseRecord = SchemaValues<DatabaseSchema> & {
11
8
  id: string;
@@ -22,17 +22,8 @@ import SchemaEntity, { normalizeSchemaValues, validateSchemaValues, } from '@spr
22
22
  import { SCRAMBLE_VALUE } from '../constants.js';
23
23
  import SpruceError from '../errors/SpruceError.js';
24
24
  import AbstractMutexer from '../mutexers/AbstractMutexer.js';
25
+ import { saveOperations, } from '../types/stores.types.js';
25
26
  import errorUtil from '../utilities/error.utility.js';
26
- const operations = [
27
- '$push',
28
- '$inc',
29
- '$min',
30
- '$max',
31
- '$mul',
32
- '$push',
33
- '$pull',
34
- '$pop',
35
- ];
36
27
  export default class AbstractStore extends AbstractMutexer {
37
28
  constructor(db, collectionName) {
38
29
  super();
@@ -238,7 +229,7 @@ export default class AbstractStore extends AbstractMutexer {
238
229
  }
239
230
  pluckOperations(updates) {
240
231
  const initialUpdates = __rest(updates, []);
241
- const ops = operations
232
+ const ops = saveOperations
242
233
  .map((name) => {
243
234
  if (name in initialUpdates) {
244
235
  //@ts-ignore
@@ -1,6 +1,9 @@
1
1
  import { Schema, SchemaFieldNames, SchemaPublicValues, SchemaValues } from '@sprucelabs/schema';
2
2
  import StoreFactory from '../factories/StoreFactory';
3
3
  import { Database } from './database.types';
4
+ export declare const saveOperations: readonly ["$push", "$inc", "$min", "$max", "$mul", "$push", "$pull", "$pop"];
5
+ export declare type SaveOperation = typeof saveOperations[number];
6
+ export declare type SaveOperations = Partial<Record<SaveOperation, Record<string, any>>>;
4
7
  export interface UniversalStoreOptions {
5
8
  db: Database;
6
9
  storeFactory: StoreFactory;
@@ -1 +1,10 @@
1
- export {};
1
+ export const saveOperations = [
2
+ '$push',
3
+ '$inc',
4
+ '$min',
5
+ '$max',
6
+ '$mul',
7
+ '$push',
8
+ '$pull',
9
+ '$pop',
10
+ ];
@@ -2,10 +2,7 @@ import { DynamicSchemaAllValues, Schema, IsDynamicSchema, SchemaAllValues, Schem
2
2
  import AbstractMutexer from '../mutexers/AbstractMutexer';
3
3
  import { Database } from '../types/database.types';
4
4
  import { QueryBuilder, QueryOptions } from '../types/query.types';
5
- import { PrepareOptions, PrepareResults } from '../types/stores.types';
6
- declare const operations: readonly ["$push", "$inc", "$min", "$max", "$mul", "$push", "$pull", "$pop"];
7
- declare type SaveOperation = typeof operations[number];
8
- declare type SaveOperations = Partial<Record<SaveOperation, Record<string, any>>>;
5
+ import { PrepareOptions, PrepareResults, SaveOperations } from '../types/stores.types';
9
6
  declare type Response<FullSchema extends Schema, CreateEntityInstances extends boolean, IncludePrivateFields extends boolean, PF extends SchemaPublicFieldNames<FullSchema>, F extends SchemaFieldNames<FullSchema>> = IsDynamicSchema<FullSchema> extends true ? DynamicSchemaAllValues<FullSchema, CreateEntityInstances> : IncludePrivateFields extends false ? Pick<SchemaPublicValues<FullSchema, CreateEntityInstances>, PF> : Pick<SchemaAllValues<FullSchema, CreateEntityInstances>, F>;
10
7
  export default abstract class AbstractStore<FullSchema extends Schema, CreateSchema extends Schema = FullSchema, UpdateSchema extends Schema = CreateSchema, DatabaseSchema extends Schema = FullSchema, DatabaseRecord = SchemaValues<DatabaseSchema> & {
11
8
  id: string;
@@ -41,17 +41,8 @@ const schema_1 = __importStar(require("@sprucelabs/schema"));
41
41
  const constants_1 = require("../constants");
42
42
  const SpruceError_1 = __importDefault(require("../errors/SpruceError"));
43
43
  const AbstractMutexer_1 = __importDefault(require("../mutexers/AbstractMutexer"));
44
+ const stores_types_1 = require("../types/stores.types");
44
45
  const error_utility_1 = __importDefault(require("../utilities/error.utility"));
45
- const operations = [
46
- '$push',
47
- '$inc',
48
- '$min',
49
- '$max',
50
- '$mul',
51
- '$push',
52
- '$pull',
53
- '$pop',
54
- ];
55
46
  class AbstractStore extends AbstractMutexer_1.default {
56
47
  constructor(db, collectionName) {
57
48
  super();
@@ -237,7 +228,7 @@ class AbstractStore extends AbstractMutexer_1.default {
237
228
  }
238
229
  pluckOperations(updates) {
239
230
  const initialUpdates = __rest(updates, []);
240
- const ops = operations
231
+ const ops = stores_types_1.saveOperations
241
232
  .map((name) => {
242
233
  if (name in initialUpdates) {
243
234
  //@ts-ignore
@@ -1,6 +1,9 @@
1
1
  import { Schema, SchemaFieldNames, SchemaPublicValues, SchemaValues } from '@sprucelabs/schema';
2
2
  import StoreFactory from '../factories/StoreFactory';
3
3
  import { Database } from './database.types';
4
+ export declare const saveOperations: readonly ["$push", "$inc", "$min", "$max", "$mul", "$push", "$pull", "$pop"];
5
+ export declare type SaveOperation = typeof saveOperations[number];
6
+ export declare type SaveOperations = Partial<Record<SaveOperation, Record<string, any>>>;
4
7
  export interface UniversalStoreOptions {
5
8
  db: Database;
6
9
  storeFactory: StoreFactory;
@@ -1,2 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.saveOperations = void 0;
4
+ exports.saveOperations = [
5
+ '$push',
6
+ '$inc',
7
+ '$min',
8
+ '$max',
9
+ '$mul',
10
+ '$push',
11
+ '$pull',
12
+ '$pop',
13
+ ];
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "16.0.28",
6
+ "version": "16.0.29",
7
7
  "files": [
8
8
  "build/**/*",
9
9
  "!build/__tests__",