@wxn0brp/db 0.7.4 → 0.7.5

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.
Files changed (32) hide show
  1. package/dist/{action.d.ts → actions/action.d.ts} +7 -7
  2. package/dist/{action.js → actions/action.js} +3 -2
  3. package/dist/{memory.d.ts → actions/memory.d.ts} +8 -8
  4. package/dist/{memory.js → actions/memory.js} +3 -3
  5. package/dist/client/valthera.d.ts +1 -1
  6. package/dist/client/valthera.js +1 -1
  7. package/dist/{graph.d.ts → db/graph.d.ts} +1 -1
  8. package/dist/{valthera.d.ts → db/valthera.d.ts} +10 -10
  9. package/dist/{valthera.js → db/valthera.js} +4 -4
  10. package/dist/file/find.js +1 -1
  11. package/dist/file/index.js +1 -1
  12. package/dist/file/remove.js +1 -1
  13. package/dist/file/transactions.js +2 -2
  14. package/dist/file/update.js +1 -1
  15. package/dist/{CollectionManager.d.ts → helpers/CollectionManager.d.ts} +5 -5
  16. package/dist/{autoCreate.d.ts → helpers/autoCreate.d.ts} +2 -2
  17. package/dist/{autoCreate.js → helpers/autoCreate.js} +2 -2
  18. package/dist/{gen.d.ts → helpers/gen.d.ts} +1 -1
  19. package/dist/{relation.d.ts → helpers/relation.d.ts} +3 -3
  20. package/dist/{relation.js → helpers/relation.js} +2 -2
  21. package/dist/index.d.ts +6 -6
  22. package/dist/index.js +6 -6
  23. package/dist/types/options.d.ts +2 -2
  24. package/dist/types/valthera.d.ts +1 -1
  25. package/package.json +1 -1
  26. /package/dist/{graph.js → db/graph.js} +0 -0
  27. /package/dist/{CollectionManager.js → helpers/CollectionManager.js} +0 -0
  28. /package/dist/{executor.d.ts → helpers/executor.d.ts} +0 -0
  29. /package/dist/{executor.js → helpers/executor.js} +0 -0
  30. /package/dist/{format.d.ts → helpers/format.d.ts} +0 -0
  31. /package/dist/{format.js → helpers/format.js} +0 -0
  32. /package/dist/{gen.js → helpers/gen.js} +0 -0
@@ -1,10 +1,10 @@
1
- import { Arg, Search, Updater } from "./types/arg.js";
2
- import { DbFindOpts, DbOpts, FindOpts } from "./types/options.js";
3
- import { Context } from "./types/types.js";
4
- import { SearchOptions } from "./types/searchOpts.js";
5
- import Data from "./types/data.js";
6
- import FileCpu from "./types/fileCpu.js";
7
- import { Transaction } from "./types/transactions.js";
1
+ import { Context } from "vm";
2
+ import { Arg, Search, Updater } from "../types/arg.js";
3
+ import Data from "../types/data.js";
4
+ import FileCpu from "../types/fileCpu.js";
5
+ import { DbOpts, DbFindOpts, FindOpts } from "../types/options.js";
6
+ import { SearchOptions } from "../types/searchOpts.js";
7
+ import { Transaction } from "../types/transactions.js";
8
8
  /**
9
9
  * A class representing database actions on files.
10
10
  * @class
@@ -1,5 +1,6 @@
1
- import gen from "./gen.js";
2
- import { existsSync, mkdirSync, statSync, promises } from "fs";
1
+ import { promises } from "fs";
2
+ import { existsSync, mkdirSync, statSync } from "fs";
3
+ import gen from "../helpers/gen.js";
3
4
  /**
4
5
  * A class representing database actions on files.
5
6
  * @class
@@ -1,12 +1,12 @@
1
+ import Valthera from "../db/valthera.js";
2
+ import { Arg, Search, Updater } from "../types/arg.js";
3
+ import Data from "../types/data.js";
4
+ import FileCpu from "../types/fileCpu.js";
5
+ import { DbFindOpts, DbOpts, FindOpts } from "../types/options.js";
6
+ import { SearchOptions } from "../types/searchOpts.js";
7
+ import { Transaction } from "../types/transactions.js";
8
+ import { Context } from "../types/types.js";
1
9
  import dbActionC from "./action.js";
2
- import Valthera from "./valthera.js";
3
- import { Arg, Search, Updater } from "./types/arg.js";
4
- import Data from "./types/data.js";
5
- import FileCpu from "./types/fileCpu.js";
6
- import { DbFindOpts, DbOpts, FindOpts } from "./types/options.js";
7
- import { SearchOptions } from "./types/searchOpts.js";
8
- import { Transaction } from "./types/transactions.js";
9
- import { Context } from "./types/types.js";
10
10
  export declare class MemoryAction implements dbActionC {
11
11
  folder: string;
12
12
  options: DbOpts;
@@ -1,6 +1,6 @@
1
- import Valthera from "./valthera.js";
2
- import CustomFileCpu from "./file/customFileCpu.js";
3
- import genId from "./gen.js";
1
+ import Valthera from "../db/valthera.js";
2
+ import CustomFileCpu from "../file/customFileCpu.js";
3
+ import genId from "../helpers/gen.js";
4
4
  export class MemoryAction {
5
5
  folder;
6
6
  options;
@@ -1,4 +1,4 @@
1
- import CollectionManager from "../CollectionManager.js";
1
+ import CollectionManager from "../helpers/CollectionManager.js";
2
2
  import { Remote } from "./remote.js";
3
3
  import { Arg, Search, Updater } from "../types/arg.js";
4
4
  import { DbFindOpts, FindOpts } from "../types/options.js";
@@ -1,5 +1,5 @@
1
1
  import ky from "ky";
2
- import CollectionManager from "../CollectionManager.js";
2
+ import CollectionManager from "../helpers/CollectionManager.js";
3
3
  import serializeFunctions from "./function.js";
4
4
  /**
5
5
  * Represents a database management class for performing CRUD operations.
@@ -1,5 +1,5 @@
1
1
  import Valthera from "./valthera.js";
2
- import Data from "./types/data.js";
2
+ import Data from "../types/data.js";
3
3
  /**
4
4
  * A class representing a graph database.
5
5
  * @class
@@ -1,14 +1,14 @@
1
- import dbActionC from "./action.js";
2
- import executorC from "./executor.js";
3
- import CollectionManager from "./CollectionManager.js";
4
- import { DbFindOpts, DbOpts, FindOpts } from "./types/options.js";
5
- import { Arg, Search, Updater } from "./types/arg.js";
6
- import Data from "./types/data.js";
7
- import { Context } from "./types/types.js";
8
- import FileCpu from "./types/fileCpu.js";
9
- import { Transaction } from "./types/transactions.js";
1
+ import dbActionC from "../actions/action.js";
2
+ import executorC from "../helpers/executor.js";
3
+ import CollectionManager from "../helpers/CollectionManager.js";
4
+ import { DbFindOpts, DbOpts, FindOpts } from "../types/options.js";
5
+ import { Arg, Search, Updater } from "../types/arg.js";
6
+ import Data from "../types/data.js";
7
+ import { Context } from "../types/types.js";
8
+ import FileCpu from "../types/fileCpu.js";
9
+ import { Transaction } from "../types/transactions.js";
10
10
  import { EventEmitter } from "events";
11
- import { ValtheraCompatible } from "./types/valthera.js";
11
+ import { ValtheraCompatible } from "../types/valthera.js";
12
12
  /**
13
13
  * Represents a database management class for performing CRUD operations.
14
14
  * @class
@@ -1,7 +1,7 @@
1
- import dbActionC from "./action.js";
2
- import executorC from "./executor.js";
3
- import CollectionManager from "./CollectionManager.js";
4
- import vFileCpu from "./file/index.js";
1
+ import dbActionC from "../actions/action.js";
2
+ import executorC from "../helpers/executor.js";
3
+ import CollectionManager from "../helpers/CollectionManager.js";
4
+ import vFileCpu from "../file/index.js";
5
5
  import { EventEmitter } from "events";
6
6
  /**
7
7
  * Represents a database management class for performing CRUD operations.
package/dist/file/find.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { existsSync, promises } from "fs";
2
2
  import { pathRepair, createRL } from "./utils.js";
3
- import { parse } from "../format.js";
3
+ import { parse } from "../helpers/format.js";
4
4
  import hasFieldsAdvanced from "../utils/hasFieldsAdvanced.js";
5
5
  import updateFindObject from "../utils/updateFindObject.js";
6
6
  /**
@@ -2,7 +2,7 @@ import update from "./update.js";
2
2
  import remove from "./remove.js";
3
3
  import { find, findOne, findStream } from "./find.js";
4
4
  import { appendFileSync } from "fs";
5
- import { stringify } from "../format.js";
5
+ import { stringify } from "../helpers/format.js";
6
6
  import transactions from "./transactions.js";
7
7
  const vFileCpu = {
8
8
  add: async (file, data) => {
@@ -1,6 +1,6 @@
1
1
  import { existsSync, promises, appendFileSync } from "fs";
2
2
  import { pathRepair, createRL } from "./utils.js";
3
- import { parse } from "../format.js";
3
+ import { parse } from "../helpers/format.js";
4
4
  import hasFieldsAdvanced from "../utils/hasFieldsAdvanced.js";
5
5
  /**
6
6
  * Removes entries from a file based on search criteria.
@@ -1,6 +1,6 @@
1
1
  import { existsSync, promises } from "fs";
2
- import { parse, stringify } from "../format.js";
3
- import genId from "../gen.js";
2
+ import { parse, stringify } from "../helpers/format.js";
3
+ import genId from "../helpers/gen.js";
4
4
  import hasFieldsAdvanced from "../utils/hasFieldsAdvanced.js";
5
5
  import updateObjectAdvanced from "../utils/updateObject.js";
6
6
  import { createRL, pathRepair } from "./utils.js";
@@ -1,6 +1,6 @@
1
1
  import { existsSync, promises } from "fs";
2
2
  import { pathRepair, createRL } from "./utils.js";
3
- import { parse, stringify } from "../format.js";
3
+ import { parse, stringify } from "../helpers/format.js";
4
4
  import hasFieldsAdvanced from "../utils/hasFieldsAdvanced.js";
5
5
  import updateObjectAdvanced from "../utils/updateObject.js";
6
6
  /**
@@ -1,8 +1,8 @@
1
- import { Arg, Search, Updater } from "./types/arg.js";
2
- import { DbFindOpts, FindOpts } from "./types/options.js";
3
- import { Context } from "./types/types.js";
4
- import Data from "./types/data.js";
5
- import { ValtheraCompatible } from "./types/valthera.js";
1
+ import { Arg, Search, Updater } from "../types/arg.js";
2
+ import { DbFindOpts, FindOpts } from "../types/options.js";
3
+ import { Context } from "../types/types.js";
4
+ import Data from "../types/data.js";
5
+ import { ValtheraCompatible } from "../types/valthera.js";
6
6
  declare class CollectionManager {
7
7
  private db;
8
8
  private collection;
@@ -1,5 +1,5 @@
1
- import { Remote } from "./client/remote.js";
2
- import { ValtheraCompatible } from "./types/valthera.js";
1
+ import { Remote } from "../client/remote.js";
2
+ import { ValtheraCompatible } from "../types/valthera.js";
3
3
  /**
4
4
  * Creates a database instance based on the provided configuration.
5
5
  * If the configuration is an object, it creates a DataBaseRemote instance.
@@ -1,5 +1,5 @@
1
- import ValtheraRemote from "./client/valthera.js";
2
- import Valthera from "./valthera.js";
1
+ import ValtheraRemote from "../client/valthera.js";
2
+ import Valthera from "../db/valthera.js";
3
3
  /**
4
4
  * Creates a database instance based on the provided configuration.
5
5
  * If the configuration is an object, it creates a DataBaseRemote instance.
@@ -1,4 +1,4 @@
1
- import Id from "./types/Id.js";
1
+ import Id from "../types/Id.js";
2
2
  /**
3
3
  * Generates a unique random identifier based on time and parts.
4
4
  *
@@ -1,6 +1,6 @@
1
- import { Search } from "./types/arg.js";
2
- import { DbFindOpts } from "./types/options.js";
3
- import { RelationTypes } from "./types/relation.js";
1
+ import { Search } from "../types/arg.js";
2
+ import { DbFindOpts } from "../types/options.js";
3
+ import { RelationTypes } from "../types/relation.js";
4
4
  declare class Relation {
5
5
  dbs: RelationTypes.DBS;
6
6
  constructor(dbs: RelationTypes.DBS);
@@ -42,12 +42,12 @@ async function processRelations(dbs, cfg, data, parentList = null) {
42
42
  if (!cfg.hasOwnProperty(key))
43
43
  continue;
44
44
  const rel = cfg[key];
45
- const { pk = "_id", fk = "_id", type = "1", path, as = key, select = [], findOpts = {}, through } = rel;
45
+ const { pk = "_id", fk = "_id", type = "1", path, as = key, select, findOpts = {}, through } = rel;
46
46
  const [dbKey, coll] = path;
47
47
  const db = dbs[dbKey];
48
48
  if (type === "1") {
49
49
  const keys = [...new Set(targets.map(i => i[pk]))];
50
- const results = await db.find(coll, { $in: { [pk]: keys } }, {}, {}, { select });
50
+ const results = await db.find(coll, { $in: { [fk]: keys } }, {}, {}, { select });
51
51
  const map = new Map(results.map(row => [row[fk], row]));
52
52
  for (const item of targets) {
53
53
  const result = map.get(item[pk]) || null;
package/dist/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
- import Valthera from "./valthera.js";
2
- import Graph from "./graph.js";
1
+ import Valthera from "./db/valthera.js";
2
+ import Graph from "./db/graph.js";
3
3
  import ValtheraRemote from "./client/valthera.js";
4
4
  import GraphRemote from "./client/graph.js";
5
- import genId from "./gen.js";
6
- import Relation from "./relation.js";
5
+ import genId from "./helpers/gen.js";
6
+ import Relation from "./helpers/relation.js";
7
7
  import CustomFileCpu from "./file/customFileCpu.js";
8
- import ValtheraMemory, { createMemoryValthera } from "./memory.js";
9
- import { ValtheraAutoCreate } from "./autoCreate.js";
8
+ import ValtheraMemory, { createMemoryValthera } from "./actions/memory.js";
9
+ import { ValtheraAutoCreate } from "./helpers/autoCreate.js";
10
10
  import { RelationTypes } from "./types/relation.js";
11
11
  import { ValtheraCompatible } from "./types/valthera.js";
12
12
  export { Valthera, Graph, ValtheraRemote, GraphRemote, Relation, genId, CustomFileCpu, ValtheraMemory, createMemoryValthera, ValtheraAutoCreate, };
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
- import Valthera from "./valthera.js";
2
- import Graph from "./graph.js";
1
+ import Valthera from "./db/valthera.js";
2
+ import Graph from "./db/graph.js";
3
3
  import ValtheraRemote from "./client/valthera.js";
4
4
  import GraphRemote from "./client/graph.js";
5
- import genId from "./gen.js";
6
- import Relation from "./relation.js";
5
+ import genId from "./helpers/gen.js";
6
+ import Relation from "./helpers/relation.js";
7
7
  import CustomFileCpu from "./file/customFileCpu.js";
8
- import ValtheraMemory, { createMemoryValthera } from "./memory.js";
9
- import { ValtheraAutoCreate } from "./autoCreate.js";
8
+ import ValtheraMemory, { createMemoryValthera } from "./actions/memory.js";
9
+ import { ValtheraAutoCreate } from "./helpers/autoCreate.js";
10
10
  export { Valthera, Graph, ValtheraRemote, GraphRemote, Relation, genId, CustomFileCpu, ValtheraMemory, createMemoryValthera, ValtheraAutoCreate, };
@@ -1,5 +1,5 @@
1
- import dbActionC from "../action.js";
2
- import executorC from "../executor.js";
1
+ import dbActionC from "../actions/action.js";
2
+ import executorC from "../helpers/executor.js";
3
3
  export interface DbOpts {
4
4
  maxFileSize?: number;
5
5
  dbAction?: dbActionC;
@@ -1,4 +1,4 @@
1
- import CollectionManager from "../CollectionManager.js";
1
+ import CollectionManager from "../helpers/CollectionManager.js";
2
2
  import { Arg, Search, Updater } from "./arg.js";
3
3
  import Data from "./data.js";
4
4
  import { DbFindOpts, FindOpts } from "./options.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wxn0brp/db",
3
- "version": "0.7.4",
3
+ "version": "0.7.5",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "description": "A simple file-based database management system with support for CRUD operations, custom queries, and graph structures.",
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes