@onurege3467/zerohelper 10.2.6 → 11.0.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.
Files changed (79) hide show
  1. package/README.md +9 -704
  2. package/dist/index.js +19 -44
  3. package/package.json +21 -70
  4. package/dist/bin/commands/cache.d.ts +0 -2
  5. package/dist/bin/commands/cache.js +0 -92
  6. package/dist/bin/commands/db-backup.d.ts +0 -3
  7. package/dist/bin/commands/db-backup.js +0 -118
  8. package/dist/bin/commands/db.d.ts +0 -2
  9. package/dist/bin/commands/db.js +0 -334
  10. package/dist/bin/commands/import-export.d.ts +0 -3
  11. package/dist/bin/commands/import-export.js +0 -123
  12. package/dist/bin/commands/init.d.ts +0 -2
  13. package/dist/bin/commands/init.js +0 -85
  14. package/dist/bin/commands/migrate.d.ts +0 -3
  15. package/dist/bin/commands/migrate.js +0 -167
  16. package/dist/bin/commands/repl.d.ts +0 -2
  17. package/dist/bin/commands/repl.js +0 -96
  18. package/dist/bin/commands/seed.d.ts +0 -2
  19. package/dist/bin/commands/seed.js +0 -76
  20. package/dist/bin/commands/zpack.d.ts +0 -2
  21. package/dist/bin/commands/zpack.js +0 -36
  22. package/dist/bin/index.d.ts +0 -2
  23. package/dist/bin/index.js +0 -28
  24. package/dist/bin/types.d.ts +0 -22
  25. package/dist/bin/types.js +0 -2
  26. package/dist/bin/utils/config.d.ts +0 -3
  27. package/dist/bin/utils/config.js +0 -78
  28. package/dist/bin/utils/prompts.d.ts +0 -3
  29. package/dist/bin/utils/prompts.js +0 -115
  30. package/dist/bin/zero.d.ts +0 -2
  31. package/dist/bin/zero.js +0 -849
  32. package/dist/database/IDatabase.d.ts +0 -71
  33. package/dist/database/IDatabase.js +0 -48
  34. package/dist/database/cacheWrapper.d.ts +0 -34
  35. package/dist/database/cacheWrapper.js +0 -214
  36. package/dist/database/index.d.ts +0 -12
  37. package/dist/database/index.js +0 -100
  38. package/dist/database/json.d.ts +0 -32
  39. package/dist/database/json.js +0 -208
  40. package/dist/database/migration.d.ts +0 -21
  41. package/dist/database/migration.js +0 -97
  42. package/dist/database/mongodb.d.ts +0 -26
  43. package/dist/database/mongodb.js +0 -145
  44. package/dist/database/mysql.d.ts +0 -29
  45. package/dist/database/mysql.js +0 -282
  46. package/dist/database/pg.d.ts +0 -28
  47. package/dist/database/pg.js +0 -200
  48. package/dist/database/redis.d.ts +0 -31
  49. package/dist/database/redis.js +0 -176
  50. package/dist/database/seeder.d.ts +0 -20
  51. package/dist/database/seeder.js +0 -37
  52. package/dist/database/sqlite.d.ts +0 -26
  53. package/dist/database/sqlite.js +0 -211
  54. package/dist/database/telemetry.d.ts +0 -35
  55. package/dist/database/telemetry.js +0 -41
  56. package/dist/database/toon.d.ts +0 -33
  57. package/dist/database/toon.js +0 -244
  58. package/dist/database/types.d.ts +0 -71
  59. package/dist/database/types.js +0 -2
  60. package/dist/database/zpack.d.ts +0 -75
  61. package/dist/database/zpack.js +0 -616
  62. package/dist/functions/index.d.ts +0 -199
  63. package/dist/functions/index.js +0 -682
  64. package/dist/functions/security.d.ts +0 -15
  65. package/dist/functions/security.js +0 -46
  66. package/dist/functions/toon.d.ts +0 -10
  67. package/dist/functions/toon.js +0 -214
  68. package/dist/functions/worker.d.ts +0 -5
  69. package/dist/functions/worker.js +0 -35
  70. package/dist/index.d.ts +0 -8
  71. package/dist/migrations/1767521950635_test_migration.d.ts +0 -3
  72. package/dist/migrations/1767521950635_test_migration.js +0 -11
  73. package/dist/migrations/1767522158826_create_users_table.d.ts +0 -2
  74. package/dist/migrations/1767522158826_create_users_table.js +0 -11
  75. package/dist/package.json +0 -79
  76. package/dist/tests/test.d.ts +0 -1
  77. package/dist/tests/test.js +0 -26
  78. package/dist/zero.config.d.ts +0 -10
  79. package/dist/zero.config.js +0 -13
@@ -1,46 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.checkRateLimit = checkRateLimit;
4
- const localStore = new Map();
5
- /**
6
- * Advanced Rate Limiter for API protection.
7
- * Returns true if allowed, false if rate limited.
8
- */
9
- async function checkRateLimit(key, options) {
10
- const { limit, window, storage = 'memory', redisClient } = options;
11
- const now = Date.now();
12
- if (storage === 'redis' && redisClient) {
13
- const redisKey = `rate_limit:${key}`;
14
- const multi = redisClient.multi();
15
- multi.incr(redisKey);
16
- multi.ttl(redisKey);
17
- const [count, ttl] = await multi.exec();
18
- if (count === 1) {
19
- await redisClient.expire(redisKey, window);
20
- }
21
- const isAllowed = count <= limit;
22
- return {
23
- allowed: isAllowed,
24
- remaining: Math.max(0, limit - Number(count)),
25
- reset: ttl > 0 ? now + (ttl * 1000) : now + (window * 1000)
26
- };
27
- }
28
- else {
29
- // Memory Storage
30
- let data = localStore.get(key);
31
- if (!data || now > data.resetTime) {
32
- data = {
33
- count: 0,
34
- resetTime: now + (window * 1000)
35
- };
36
- }
37
- data.count++;
38
- localStore.set(key, data);
39
- const isAllowed = data.count <= limit;
40
- return {
41
- allowed: isAllowed,
42
- remaining: Math.max(0, limit - data.count),
43
- reset: data.resetTime
44
- };
45
- }
46
- }
@@ -1,10 +0,0 @@
1
- /**
2
- * TOON (Token-Oriented Object Notation) Support for ZeroHelper
3
- * Optimized for LLM token efficiency and now supports Native Storage.
4
- * API matches standard JSON object (stringify/parse).
5
- */
6
- export declare function stringify(data: any, indent?: number): string;
7
- /**
8
- * Advanced TOON Parser with Indentation Support for Deep Nesting
9
- */
10
- export declare function parse(toonStr: string): any;
@@ -1,214 +0,0 @@
1
- "use strict";
2
- /**
3
- * TOON (Token-Oriented Object Notation) Support for ZeroHelper
4
- * Optimized for LLM token efficiency and now supports Native Storage.
5
- * API matches standard JSON object (stringify/parse).
6
- */
7
- Object.defineProperty(exports, "__esModule", { value: true });
8
- exports.stringify = stringify;
9
- exports.parse = parse;
10
- function stringify(data, indent = 0) {
11
- const space = ' '.repeat(indent);
12
- if (data === null)
13
- return 'null';
14
- if (typeof data === 'boolean' || typeof data === 'number')
15
- return String(data);
16
- if (typeof data === 'string') {
17
- const hasSpecial = /[,\n: ]/.test(data);
18
- if (hasSpecial)
19
- return '"' + data.replace(/"/g, '\\"') + '"';
20
- return data;
21
- }
22
- if (Array.isArray(data)) {
23
- if (data.length === 0)
24
- return '[]';
25
- const first = data[0];
26
- // ✅ FIX: Object array'leri için HER ZAMAN tabular format kullan (1+ eleman için)
27
- if (typeof first === 'object' && first !== null && !Array.isArray(first)) {
28
- const keys = Object.keys(first);
29
- const isUniform = data.every(item => item && typeof item === 'object' &&
30
- Object.keys(item).length === keys.length &&
31
- Object.keys(item).every(k => keys.includes(k)));
32
- if (isUniform) {
33
- const header = '[' + data.length + ']{' + keys.join(',') + '}:';
34
- const rows = data.map(item => {
35
- const rowValues = keys.map(k => {
36
- const val = item[k];
37
- if (val === null)
38
- return 'null';
39
- if (Array.isArray(val)) {
40
- return '"' + JSON.stringify(val) + '"';
41
- }
42
- const valStr = String(val);
43
- const hasSpecialRow = /[,\n: ]/.test(valStr);
44
- return (typeof val === 'string' && hasSpecialRow) ? '"' + valStr.replace(/"/g, '\\"') + '"' : valStr;
45
- }).join(',');
46
- return space + ' ' + rowValues;
47
- });
48
- return header + '\n' + rows.join('\n');
49
- }
50
- }
51
- // Non-object array'ler için inline format
52
- return '[' + data.length + ']: ' + data.map(v => stringify(v)).join(',');
53
- }
54
- if (typeof data === 'object') {
55
- const entries = Object.entries(data);
56
- if (entries.length === 0)
57
- return '{}';
58
- return entries.map(([key, value]) => {
59
- const valStr = stringify(value, indent + 2);
60
- const isComplex = typeof value === 'object' && value !== null && !Array.isArray(value);
61
- const separator = isComplex ? '\n' : ' ';
62
- return space + key + ':' + separator + valStr;
63
- }).join('\n');
64
- }
65
- return '';
66
- }
67
- /**
68
- * Advanced TOON Parser with Indentation Support for Deep Nesting
69
- */
70
- function parse(toonStr) {
71
- if (!toonStr || toonStr.trim() === '')
72
- return {};
73
- const lines = toonStr.split('\n');
74
- function parseValue(val) {
75
- const trimmed = val.trim();
76
- // Tırnak içindeki string
77
- if (trimmed.startsWith('"') && trimmed.endsWith('"')) {
78
- const unquoted = trimmed.slice(1, -1).replace(/\\"/g, '"');
79
- // JSON array string'i kontrol et
80
- try {
81
- if (unquoted.startsWith('[') && unquoted.endsWith(']')) {
82
- return JSON.parse(unquoted);
83
- }
84
- }
85
- catch (e) {
86
- // JSON değilse normal string döndür
87
- }
88
- return unquoted;
89
- }
90
- if (trimmed === 'true')
91
- return true;
92
- if (trimmed === 'false')
93
- return false;
94
- if (trimmed === 'null')
95
- return null;
96
- if (trimmed === '[]')
97
- return [];
98
- if (trimmed === '{}')
99
- return {};
100
- if (!isNaN(Number(trimmed)) && trimmed !== '')
101
- return Number(trimmed);
102
- return trimmed;
103
- }
104
- function getIndent(line) {
105
- const match = line.match(/^(\s*)/);
106
- return match ? match[1].length : 0;
107
- }
108
- // CSV row parser with proper quote handling
109
- function parseCSVRow(row) {
110
- const result = [];
111
- let current = '';
112
- let inQuotes = false;
113
- for (let i = 0; i < row.length; i++) {
114
- const char = row[i];
115
- if (char === '"' && (i === 0 || row[i - 1] !== '\\')) {
116
- inQuotes = !inQuotes;
117
- current += char;
118
- }
119
- else if (char === ',' && !inQuotes) {
120
- result.push(current.trim());
121
- current = '';
122
- }
123
- else {
124
- current += char;
125
- }
126
- }
127
- if (current.trim()) {
128
- result.push(current.trim());
129
- }
130
- return result;
131
- }
132
- function processLines(startIndex, currentIndent) {
133
- const result = {};
134
- let i = startIndex;
135
- while (i < lines.length) {
136
- const line = lines[i];
137
- const indent = getIndent(line);
138
- const content = line.trim();
139
- // Boş satırları atla
140
- if (content === '') {
141
- i++;
142
- continue;
143
- }
144
- if (indent < currentIndent)
145
- break;
146
- // Standard Key-Value match
147
- const kvMatch = content.match(/^([^:]+):\s*(.*)$/);
148
- if (kvMatch) {
149
- const key = kvMatch[1].trim();
150
- const valuePart = kvMatch[2].trim();
151
- // ✅ FIX: Tabular array header - Format: [count]{field1,field2,...}:
152
- const tabularMatch = valuePart.match(/^\[(\d+)\]\{([^}]+)\}:$/);
153
- if (tabularMatch) {
154
- const expectedRowCount = parseInt(tabularMatch[1]);
155
- const fields = tabularMatch[2].split(',').map(f => f.trim());
156
- const rows = [];
157
- let rowsRead = 0;
158
- i++; // Header'dan sonraki satıra geç
159
- while (i < lines.length && rowsRead < expectedRowCount) {
160
- const rowLine = lines[i];
161
- const rowIndent = getIndent(rowLine);
162
- const rowContent = rowLine.trim();
163
- // Boş satırları atla
164
- if (rowContent === '') {
165
- i++;
166
- continue;
167
- }
168
- // Indent kontrolü - child satır olmalı
169
- if (rowIndent <= currentIndent) {
170
- break;
171
- }
172
- // CSV parsing with quote support
173
- const values = parseCSVRow(rowContent);
174
- const row = {};
175
- fields.forEach((f, idx) => {
176
- row[f] = idx < values.length ? parseValue(values[idx]) : null;
177
- });
178
- rows.push(row);
179
- rowsRead++;
180
- i++;
181
- }
182
- result[key] = rows;
183
- continue;
184
- }
185
- // ✅ FIX: Inline array - [count]: value1,value2,...
186
- const inlineArrayMatch = valuePart.match(/^\[(\d+)\]:\s*(.+)$/);
187
- if (inlineArrayMatch) {
188
- const count = parseInt(inlineArrayMatch[1]);
189
- const valueStr = inlineArrayMatch[2].trim();
190
- // Normal değer array'i (virgülle ayrılmış basit değerler)
191
- const values = parseCSVRow(valueStr);
192
- result[key] = values.map(v => parseValue(v));
193
- i++;
194
- continue;
195
- }
196
- // Nested object check
197
- if (valuePart === '' && i + 1 < lines.length && getIndent(lines[i + 1]) > indent) {
198
- const [nestedObj, nextIndex] = processLines(i + 1, getIndent(lines[i + 1]));
199
- result[key] = nestedObj;
200
- i = nextIndex;
201
- continue;
202
- }
203
- // Simple value
204
- result[key] = parseValue(valuePart);
205
- i++;
206
- continue;
207
- }
208
- i++;
209
- }
210
- return [result, i];
211
- }
212
- const [finalResult] = processLines(0, 0);
213
- return finalResult;
214
- }
@@ -1,5 +0,0 @@
1
- /**
2
- * Runs a function in a separate background thread.
3
- * Ideal for heavy math, data processing, or large ZPack manipulations.
4
- */
5
- export declare function runAsyncTask<T>(taskFn: string, data: any): Promise<T>;
@@ -1,35 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.runAsyncTask = runAsyncTask;
4
- // functions/worker.ts
5
- const worker_threads_1 = require("worker_threads");
6
- /**
7
- * Runs a function in a separate background thread.
8
- * Ideal for heavy math, data processing, or large ZPack manipulations.
9
- */
10
- async function runAsyncTask(taskFn, data) {
11
- return new Promise((resolve, reject) => {
12
- const workerCode = `
13
- const { parentPort, workerData } = require('worker_threads');
14
- try {
15
- const fn = ${taskFn};
16
- const result = fn(workerData);
17
- parentPort.postMessage({ result });
18
- } catch (error) {
19
- parentPort.postMessage({ error: error.message });
20
- }
21
- `;
22
- const worker = new worker_threads_1.Worker(workerCode, { eval: true, workerData: data });
23
- worker.on('message', (msg) => {
24
- if (msg.error)
25
- reject(new Error(msg.error));
26
- else
27
- resolve(msg.result);
28
- });
29
- worker.on('error', reject);
30
- worker.on('exit', (code) => {
31
- if (code !== 0)
32
- reject(new Error(`Worker stopped with exit code ${code}`));
33
- });
34
- });
35
- }
package/dist/index.d.ts DELETED
@@ -1,8 +0,0 @@
1
- import * as database from "./database";
2
- import * as functions from "./functions";
3
- export { database, functions, };
4
- declare const _default: {
5
- database: typeof database;
6
- functions: typeof functions;
7
- };
8
- export default _default;
@@ -1,3 +0,0 @@
1
- import { IDatabase } from "@onurege3467/zerohelper";
2
- export declare const up: (db: IDatabase) => Promise<void>;
3
- export declare const down: (db: IDatabase) => Promise<void>;
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.down = exports.up = void 0;
4
- const up = async (db) => {
5
- // Write your migration logic here
6
- };
7
- exports.up = up;
8
- const down = async (db) => {
9
- // Write your rollback logic here
10
- };
11
- exports.down = down;
@@ -1,2 +0,0 @@
1
- export declare const up: (db: any) => Promise<void>;
2
- export declare const down: (db: any) => Promise<void>;
@@ -1,11 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.down = exports.up = void 0;
4
- const up = async (db) => {
5
- await db.insert('migration_test', { name: 'test', created_at: new Date() });
6
- };
7
- exports.up = up;
8
- const down = async (db) => {
9
- await db.delete('migration_test', { name: 'test' });
10
- };
11
- exports.down = down;
package/dist/package.json DELETED
@@ -1,79 +0,0 @@
1
- {
2
- "name": "@onurege3467/zerohelper",
3
- "version": "10.2.6",
4
- "description": "ZeroHelper is a versatile high-performance utility library and database framework for Node.js, fully written in TypeScript.",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
7
- "bin": {
8
- "zero": "./dist/bin/index.js"
9
- },
10
- "scripts": {
11
- "build": "tsc",
12
- "prepublishOnly": "npm run build",
13
- "test": "jest"
14
- },
15
- "files": [
16
- "dist"
17
- ],
18
- "keywords": [
19
- "helper",
20
- "zerohelper",
21
- "database",
22
- "uuid",
23
- "mongodb",
24
- "mysql",
25
- "jsondatabase",
26
- "sqlite3",
27
- "quick.db",
28
- "postgresql",
29
- "utility",
30
- "functions",
31
- "nodejs",
32
- "validation",
33
- "logger",
34
- "migration",
35
- "increment",
36
- "decrement",
37
- "zpack",
38
- "typescript",
39
- "cli",
40
- "worker"
41
- ],
42
- "author": "Onure9e",
43
- "license": "ISC",
44
- "dependencies": {
45
- "bcrypt": "^5.1.1",
46
- "chalk": "^4.1.2",
47
- "commander": "^11.1.0",
48
- "crypto": "^1.0.1",
49
- "csv": "^6.3.11",
50
- "dotenv": "^16.4.7",
51
- "fs": "^0.0.1-security",
52
- "inquirer": "^8.2.5",
53
- "js-yaml": "^4.1.0",
54
- "jsonwebtoken": "^9.0.2",
55
- "lodash": "^4.17.21",
56
- "lru-cache": "^10.0.0",
57
- "mongodb": "^6.12.0",
58
- "mysql2": "^3.14.1",
59
- "ora": "^5.4.1",
60
- "path": "^0.12.7",
61
- "pg": "^8.14.1",
62
- "promise-mysql": "^5.2.0",
63
- "redis": "^4.7.0",
64
- "sqlite3": "^5.1.7"
65
- },
66
- "devDependencies": {
67
- "@types/bcrypt": "^5.0.2",
68
- "@types/inquirer": "^8.2.5",
69
- "@types/jest": "^29.5.14",
70
- "@types/js-yaml": "^4.0.9",
71
- "@types/jsonwebtoken": "^9.0.7",
72
- "@types/lodash": "^4.17.13",
73
- "@types/node": "^22.10.2",
74
- "@types/pg": "^8.11.10",
75
- "jest": "^29.7.0",
76
- "ts-jest": "^29.2.5",
77
- "typescript": "^5.7.2"
78
- }
79
- }
@@ -1 +0,0 @@
1
- export {};
@@ -1,26 +0,0 @@
1
- "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- const database_1 = __importDefault(require("../database"));
7
- const run = async () => {
8
- const db = (0, database_1.default)({
9
- adapter: 'toon',
10
- config: {
11
- path: './data.toon',
12
- cache: {
13
- type: 'memory',
14
- ttl: 1000,
15
- max: 1000,
16
- }
17
- }
18
- });
19
- await db.insert('testTable', { userName: 'Onur Ege', age: 21 });
20
- await db.insert('testTable', { userName: 'Onur Ege', age: 21 });
21
- await db.insert('testTable', { userName: 'Onur Ege', age: 21 });
22
- await db.insert('users', { userName: 'Onur Ege' });
23
- await db.insert('users', { userName: 'Onur Ege' });
24
- console.log(await db.select('testTable', { age: 21 }));
25
- };
26
- run();
@@ -1,10 +0,0 @@
1
- /**
2
- * ZeroHelper Configuration
3
- * Generated on 1/4/2026
4
- */
5
- export declare const zeroConfig: {
6
- adapter: string;
7
- config: {
8
- path: string;
9
- };
10
- };
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.zeroConfig = void 0;
4
- /**
5
- * ZeroHelper Configuration
6
- * Generated on 1/4/2026
7
- */
8
- exports.zeroConfig = {
9
- "adapter": "json",
10
- "config": {
11
- "path": "./test_data.json"
12
- }
13
- };