@cocreate/mysql 1.0.0 → 1.1.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 (3) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/package.json +14 -10
  3. package/src/index.js +27 -18
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [1.1.0](https://github.com/CoCreate-app/CoCreate-mysql/compare/v1.0.0...v1.1.0) (2026-07-18)
2
+
3
+
4
+ ### Features
5
+
6
+ * update package.json description and keywords; migrate to ES modules in index.js ([1d6710a](https://github.com/CoCreate-app/CoCreate-mysql/commit/1d6710a5c0f0251762d3560eef9b1a49021e12ba))
7
+
1
8
  # 1.0.0 (2026-07-18)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,16 +1,20 @@
1
1
  {
2
2
  "name": "@cocreate/mysql",
3
- "version": "1.0.0",
4
- "description": "A simple mysql component in vanilla javascript. Easily configured using HTML5 data-attributes and/or JavaScript API.",
3
+ "version": "1.1.0",
4
+ "description": "Lightweight MySQL, MariaDB, and Aurora CRUD wrapper and multi-tenant state routing client for the CoCreate ecosystem.",
5
5
  "keywords": [
6
6
  "mysql",
7
- "low-code",
8
- "realtime",
9
- "realtime-framework",
10
- "collaboration",
11
- "shared-editing",
12
- "html5-framework",
13
- "javascript-framework"
7
+ "mariadb",
8
+ "aurora",
9
+ "sql",
10
+ "json",
11
+ "crud-api",
12
+ "abstract-crud",
13
+ "database-abstraction",
14
+ "multi-tenant",
15
+ "multi-tenant-routing",
16
+ "realtime-sync",
17
+ "state-synchronization"
14
18
  ],
15
19
  "publishConfig": {
16
20
  "access": "public"
@@ -38,6 +42,6 @@
38
42
  "main": "./src/index.js",
39
43
  "dependencies": {
40
44
  "@cocreate/utils": "^1.44.0",
41
- "mysql": "^7.5.0"
45
+ "mysql2": "^3.22.6"
42
46
  }
43
47
  }
package/src/index.js CHANGED
@@ -1,11 +1,28 @@
1
- const mysql = require("mysql2/promise");
2
- const {
1
+ /********************************************************************************
2
+ * Copyright (C) 2026 CoCreate and Contributors.
3
+ *
4
+ * This program is free software: you can redistribute it and/or modify
5
+ * it under the terms of the GNU Affero General Public License as published
6
+ * by the Free Software Foundation, either version 3 of the License, or
7
+ * (at your option) any later version.
8
+ *
9
+ * This program is distributed in the hope that it will be useful,
10
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ * GNU Affero General Public License for more details.
13
+ *
14
+ * You should have received a copy of the GNU Affero General Public License
15
+ * along with this program. If not, see <https://www.gnu.org/licenses/>.
16
+ ********************************************************************************/
17
+
18
+ import mysql from "mysql2/promise";
19
+ import {
3
20
  dotNotationToObject,
4
21
  queryData,
5
22
  searchData,
6
23
  sortData,
7
24
  isValidDate
8
- } = require("@cocreate/utils");
25
+ } from "@cocreate/utils";
9
26
 
10
27
  const organizations = {};
11
28
 
@@ -91,7 +108,7 @@ process.on("orgDeleted", (organization_id) => {
91
108
  /**
92
109
  * Universal router routing request methods safely.
93
110
  */
94
- function send(data) {
111
+ export function send(data) {
95
112
  let [type, method] = data.method.split(".");
96
113
  if (type === "database") return database(method, data);
97
114
  if (type === "array") return array(method, data);
@@ -109,7 +126,7 @@ function database(method, data) {
109
126
 
110
127
  try {
111
128
  const pool = await dbClient(data);
112
- if (!pool || pool.status === false) return data;
129
+ if (!pool || pool.status === false) return resolve(data);
113
130
 
114
131
  if (method === "read") {
115
132
  const sql = "SHOW DATABASES;";
@@ -171,9 +188,6 @@ function database(method, data) {
171
188
  console.log(method, "error", error);
172
189
  resolve(data);
173
190
  }
174
- },
175
- (error) => {
176
- errorHandler(data, error);
177
191
  }
178
192
  );
179
193
  }
@@ -189,7 +203,7 @@ function array(method, data) {
189
203
 
190
204
  try {
191
205
  const pool = await dbClient(data);
192
- if (!pool || pool.status === false) return data;
206
+ if (!pool || pool.status === false) return resolve(data);
193
207
 
194
208
  if (data.request) data.array = data.request;
195
209
 
@@ -334,9 +348,6 @@ function array(method, data) {
334
348
  console.log(method, "error", error);
335
349
  resolve(data);
336
350
  }
337
- },
338
- (error) => {
339
- errorHandler(data, error);
340
351
  }
341
352
  );
342
353
  }
@@ -349,7 +360,7 @@ function object(method, data) {
349
360
  async (resolve, reject) => {
350
361
  try {
351
362
  const pool = await dbClient(data);
352
- if (!pool || pool.status === false) return data;
363
+ if (!pool || pool.status === false) return resolve(data);
353
364
 
354
365
  let type = "object";
355
366
  let documents = [];
@@ -584,9 +595,6 @@ function object(method, data) {
584
595
  console.log(method, "error", error);
585
596
  resolve(data);
586
597
  }
587
- },
588
- (error) => {
589
- errorHandler(data, error);
590
598
  }
591
599
  );
592
600
  }
@@ -654,7 +662,8 @@ async function executeUpdateTransaction(pool, arrayName, docId, rawUpdateInput,
654
662
  }
655
663
 
656
664
  /**
657
- * Applies MongoDB update operators recursively to maintain unified schema manipulation behaviors.
665
+ * Applies MongoDB update operators ($set, $unset, $push, $pull, $addToSet, $inc)
666
+ * recursively on a target record to maintain unified schema manipulation behaviors.
658
667
  */
659
668
  function applyMongoUpdate(record, updatePayload) {
660
669
  let target = { ...record };
@@ -907,4 +916,4 @@ function errorHandler(data, error, database, array) {
907
916
  }
908
917
  }
909
918
 
910
- module.exports = { send };
919
+ export default { send };