orange-orm 4.5.0-beta.2 → 4.5.0-beta.3
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/README.md +21 -1
- package/package.json +1 -2
- package/src/applyPatch.js +7 -3
- package/src/client/index.mjs +25 -20
- package/src/validateDeleteConflict.js +7 -3
package/README.md
CHANGED
|
@@ -29,7 +29,8 @@ The ultimate Object Relational Mapper for Node.js and Typescript, offering seaml
|
|
|
29
29
|
✅ MySQL
|
|
30
30
|
✅ Oracle
|
|
31
31
|
✅ SAP ASE
|
|
32
|
-
✅ SQLite
|
|
32
|
+
✅ SQLite
|
|
33
|
+
✅ Cloudflare D1
|
|
33
34
|
|
|
34
35
|
|
|
35
36
|
This is the _Modern Typescript Documentation_. Are you looking for the [_Classic Documentation_](https://github.com/alfateam/orange-orm/blob/master/docs/docs.md) ?
|
|
@@ -319,6 +320,22 @@ import map from './map';
|
|
|
319
320
|
|
|
320
321
|
const db = map.http('http://localhost:3000/orange');
|
|
321
322
|
```
|
|
323
|
+
__Cloudflare D1__
|
|
324
|
+
<sub>📄 wrangler.toml</sub>
|
|
325
|
+
```toml
|
|
326
|
+
# Bind a D1 database. D1 is Cloudflare’s native serverless SQL database.
|
|
327
|
+
# Docs: https://developers.cloudflare.com/workers/wrangler/configuration/#d1-databases
|
|
328
|
+
[[d1_databases]]
|
|
329
|
+
binding = "DB"
|
|
330
|
+
database_name = "<your-name-for-the-database>"
|
|
331
|
+
database_id = "<your-guid-for-the-database>"
|
|
332
|
+
```
|
|
333
|
+
|
|
334
|
+
```javascript
|
|
335
|
+
import map from './map';
|
|
336
|
+
// Must match the binding name in wrangler.toml
|
|
337
|
+
const db = map.d1(env.DB);
|
|
338
|
+
```
|
|
322
339
|
__MySQL__
|
|
323
340
|
```bash
|
|
324
341
|
$ npm install mysql2
|
|
@@ -1580,6 +1597,8 @@ async function getRows() {
|
|
|
1580
1597
|
Within the transaction, a customer is retrieved and its balance updated using the tx object to ensure operations are transactional.
|
|
1581
1598
|
An error is deliberately thrown to demonstrate a rollback, ensuring all previous changes within the transaction are reverted.
|
|
1582
1599
|
Always use the provided tx object for operations within the transaction to maintain data integrity.</p>
|
|
1600
|
+
<p>(NOTE: Transactions are not supported for Cloudflare D1)</p>
|
|
1601
|
+
|
|
1583
1602
|
|
|
1584
1603
|
```javascript
|
|
1585
1604
|
import map from './map';
|
|
@@ -1597,6 +1616,7 @@ async function execute() {
|
|
|
1597
1616
|
}
|
|
1598
1617
|
|
|
1599
1618
|
```
|
|
1619
|
+
|
|
1600
1620
|
</details>
|
|
1601
1621
|
|
|
1602
1622
|
<details><summary><strong>Data types</strong></summary>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "orange-orm",
|
|
3
|
-
"version": "4.5.0-beta.
|
|
3
|
+
"version": "4.5.0-beta.3",
|
|
4
4
|
"main": "./src/index.js",
|
|
5
5
|
"browser": "./src/client/index.mjs",
|
|
6
6
|
"bin": {
|
|
@@ -57,7 +57,6 @@
|
|
|
57
57
|
"@types/oracledb": "^6.0.4",
|
|
58
58
|
"@types/tedious": "^4.0.14",
|
|
59
59
|
"ajv": "^6.10.2",
|
|
60
|
-
"assert": "^2.1.0",
|
|
61
60
|
"axios": "^1.6.2",
|
|
62
61
|
"fast-json-patch": "^3.1.1",
|
|
63
62
|
"findup-sync": "^5.0.0",
|
package/src/applyPatch.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
const fastjson = require('fast-json-patch');
|
|
2
|
-
let assert = require('assert');
|
|
3
2
|
let fromCompareObject = require('./fromCompareObject');
|
|
4
3
|
let toCompareObject = require('./toCompareObject');
|
|
5
4
|
|
|
@@ -42,7 +41,7 @@ function applyPatch({ options = {} }, dto, changes, column) {
|
|
|
42
41
|
assertDatesEqual(oldValue, expectedOldValue);
|
|
43
42
|
}
|
|
44
43
|
else
|
|
45
|
-
|
|
44
|
+
assertDeepEqual(oldValue, expectedOldValue);
|
|
46
45
|
}
|
|
47
46
|
catch (e) {
|
|
48
47
|
if (concurrency === 'skipOnConflict')
|
|
@@ -98,7 +97,12 @@ function assertDatesEqual(date1, date2) {
|
|
|
98
97
|
date1 = `${parts1[0]}T${time1parts[0]}`;
|
|
99
98
|
date2 = `${parts2[0]}T${time2parts[0]}`;
|
|
100
99
|
}
|
|
101
|
-
|
|
100
|
+
assertDeepEqual(date1, date2);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
function assertDeepEqual(a, b) {
|
|
104
|
+
if (JSON.stringify(a) !== JSON.stringify(b))
|
|
105
|
+
throw new Error('A, b are not equal');
|
|
102
106
|
}
|
|
103
107
|
|
|
104
108
|
function inspect(obj) {
|
package/src/client/index.mjs
CHANGED
|
@@ -7,7 +7,6 @@ import * as axios from 'axios';
|
|
|
7
7
|
import * as _default from 'rfdc/default';
|
|
8
8
|
import * as ajv from 'ajv';
|
|
9
9
|
import * as onChange from '@lroal/on-change';
|
|
10
|
-
import * as assert from 'assert';
|
|
11
10
|
|
|
12
11
|
function getDefaultExportFromCjs (x) {
|
|
13
12
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
@@ -724,7 +723,7 @@ function requireHostExpress () {
|
|
|
724
723
|
return hostExpress_1;
|
|
725
724
|
}
|
|
726
725
|
|
|
727
|
-
var require$$0$
|
|
726
|
+
var require$$0$3 = /*@__PURE__*/getDefaultExportFromNamespaceIfPresent(fastJsonPatch);
|
|
728
727
|
|
|
729
728
|
var dateToISOString_1;
|
|
730
729
|
var hasRequiredDateToISOString;
|
|
@@ -784,7 +783,7 @@ function requireStringify () {
|
|
|
784
783
|
return stringify_1;
|
|
785
784
|
}
|
|
786
785
|
|
|
787
|
-
var require$$0$
|
|
786
|
+
var require$$0$2 = /*@__PURE__*/getDefaultExportFromNamespaceIfPresent(uuid);
|
|
788
787
|
|
|
789
788
|
var createPatch;
|
|
790
789
|
var hasRequiredCreatePatch;
|
|
@@ -792,10 +791,10 @@ var hasRequiredCreatePatch;
|
|
|
792
791
|
function requireCreatePatch () {
|
|
793
792
|
if (hasRequiredCreatePatch) return createPatch;
|
|
794
793
|
hasRequiredCreatePatch = 1;
|
|
795
|
-
const jsonpatch = require$$0$
|
|
794
|
+
const jsonpatch = require$$0$3;
|
|
796
795
|
let dateToIsoString = requireDateToISOString();
|
|
797
796
|
let stringify = requireStringify();
|
|
798
|
-
let { v4: uuid } = require$$0$
|
|
797
|
+
let { v4: uuid } = require$$0$2;
|
|
799
798
|
|
|
800
799
|
createPatch = function createPatch(original, dto, options) {
|
|
801
800
|
let subject = toCompareObject({ d: original }, options, true);
|
|
@@ -2315,7 +2314,7 @@ function requireCloneFromDb () {
|
|
|
2315
2314
|
return cloneFromDb_1;
|
|
2316
2315
|
}
|
|
2317
2316
|
|
|
2318
|
-
var require$$0$
|
|
2317
|
+
var require$$0$1 = /*@__PURE__*/getDefaultExportFromNamespaceIfPresent(axios);
|
|
2319
2318
|
|
|
2320
2319
|
var netAdapter_1;
|
|
2321
2320
|
var hasRequiredNetAdapter;
|
|
@@ -2323,7 +2322,7 @@ var hasRequiredNetAdapter;
|
|
|
2323
2322
|
function requireNetAdapter () {
|
|
2324
2323
|
if (hasRequiredNetAdapter) return netAdapter_1;
|
|
2325
2324
|
hasRequiredNetAdapter = 1;
|
|
2326
|
-
const _axios = require$$0$
|
|
2325
|
+
const _axios = require$$0$1;
|
|
2327
2326
|
|
|
2328
2327
|
function httpAdapter(baseURL, path, axiosInterceptor) {
|
|
2329
2328
|
//@ts-ignore
|
|
@@ -2466,7 +2465,7 @@ function requireToKeyPositionMap () {
|
|
|
2466
2465
|
if (hasRequiredToKeyPositionMap) return toKeyPositionMap_1;
|
|
2467
2466
|
hasRequiredToKeyPositionMap = 1;
|
|
2468
2467
|
const stringify = requireStringify();
|
|
2469
|
-
const { v4: uuid } = require$$0$
|
|
2468
|
+
const { v4: uuid } = require$$0$2;
|
|
2470
2469
|
|
|
2471
2470
|
function toKeyPositionMap(rows, options) {
|
|
2472
2471
|
return rows.reduce((map, element, i) => {
|
|
@@ -4053,7 +4052,7 @@ function requireNewColumn () {
|
|
|
4053
4052
|
return newColumn;
|
|
4054
4053
|
}
|
|
4055
4054
|
|
|
4056
|
-
var require$$0
|
|
4055
|
+
var require$$0 = /*@__PURE__*/getDefaultExportFromNamespaceIfPresent(ajv);
|
|
4057
4056
|
|
|
4058
4057
|
var purify_1$5;
|
|
4059
4058
|
var hasRequiredPurify$6;
|
|
@@ -5216,7 +5215,7 @@ var hasRequiredColumn;
|
|
|
5216
5215
|
function requireColumn () {
|
|
5217
5216
|
if (hasRequiredColumn) return column;
|
|
5218
5217
|
hasRequiredColumn = 1;
|
|
5219
|
-
const Ajv = require$$0
|
|
5218
|
+
const Ajv = require$$0;
|
|
5220
5219
|
|
|
5221
5220
|
function defineColumn(column, table) {
|
|
5222
5221
|
var c = {};
|
|
@@ -7004,8 +7003,6 @@ function requireToDto () {
|
|
|
7004
7003
|
return toDto_1;
|
|
7005
7004
|
}
|
|
7006
7005
|
|
|
7007
|
-
var require$$0 = /*@__PURE__*/getDefaultExportFromNamespaceIfPresent(assert);
|
|
7008
|
-
|
|
7009
7006
|
var fromCompareObject_1;
|
|
7010
7007
|
var hasRequiredFromCompareObject;
|
|
7011
7008
|
|
|
@@ -7095,8 +7092,7 @@ var hasRequiredApplyPatch;
|
|
|
7095
7092
|
function requireApplyPatch () {
|
|
7096
7093
|
if (hasRequiredApplyPatch) return applyPatch_1;
|
|
7097
7094
|
hasRequiredApplyPatch = 1;
|
|
7098
|
-
const fastjson = require$$0$
|
|
7099
|
-
let assert = require$$0;
|
|
7095
|
+
const fastjson = require$$0$3;
|
|
7100
7096
|
let fromCompareObject = requireFromCompareObject();
|
|
7101
7097
|
let toCompareObject = requireToCompareObject();
|
|
7102
7098
|
|
|
@@ -7139,7 +7135,7 @@ function requireApplyPatch () {
|
|
|
7139
7135
|
assertDatesEqual(oldValue, expectedOldValue);
|
|
7140
7136
|
}
|
|
7141
7137
|
else
|
|
7142
|
-
|
|
7138
|
+
assertDeepEqual(oldValue, expectedOldValue);
|
|
7143
7139
|
}
|
|
7144
7140
|
catch (e) {
|
|
7145
7141
|
if (concurrency === 'skipOnConflict')
|
|
@@ -7195,7 +7191,12 @@ function requireApplyPatch () {
|
|
|
7195
7191
|
date1 = `${parts1[0]}T${time1parts[0]}`;
|
|
7196
7192
|
date2 = `${parts2[0]}T${time2parts[0]}`;
|
|
7197
7193
|
}
|
|
7198
|
-
|
|
7194
|
+
assertDeepEqual(date1, date2);
|
|
7195
|
+
}
|
|
7196
|
+
|
|
7197
|
+
function assertDeepEqual(a, b) {
|
|
7198
|
+
if (JSON.stringify(a) !== JSON.stringify(b))
|
|
7199
|
+
throw new Error('A, b are not equal');
|
|
7199
7200
|
}
|
|
7200
7201
|
|
|
7201
7202
|
function inspect(obj) {
|
|
@@ -7214,7 +7215,6 @@ function requireValidateDeleteConflict () {
|
|
|
7214
7215
|
hasRequiredValidateDeleteConflict = 1;
|
|
7215
7216
|
// @ts-nocheck
|
|
7216
7217
|
/* eslint-disable */
|
|
7217
|
-
let assert = require$$0;
|
|
7218
7218
|
const toCompareObject = requireToCompareObject();
|
|
7219
7219
|
|
|
7220
7220
|
async function validateDeleteConflict({ row, oldValue, options, table }) {
|
|
@@ -7229,7 +7229,7 @@ function requireValidateDeleteConflict () {
|
|
|
7229
7229
|
assertDatesEqual(oldValue[p], toCompareObject(row[p]));
|
|
7230
7230
|
}
|
|
7231
7231
|
else
|
|
7232
|
-
|
|
7232
|
+
assertDeepEqual(oldValue[p], toCompareObject(row[p]));
|
|
7233
7233
|
}
|
|
7234
7234
|
catch (e) {
|
|
7235
7235
|
throw new Error(`The field ${p} was changed by another user. Expected ${inspect(oldValue[p])}, but was ${inspect(row[p])}.`);
|
|
@@ -7298,7 +7298,12 @@ function requireValidateDeleteConflict () {
|
|
|
7298
7298
|
date1 = `${parts1[0]}T${time1parts[0]}`;
|
|
7299
7299
|
date2 = `${parts2[0]}T${time2parts[0]}`;
|
|
7300
7300
|
}
|
|
7301
|
-
|
|
7301
|
+
assertDeepEqual(date1, date2);
|
|
7302
|
+
}
|
|
7303
|
+
|
|
7304
|
+
function assertDeepEqual(a, b) {
|
|
7305
|
+
if (JSON.stringify(a) !== JSON.stringify(b))
|
|
7306
|
+
throw new Error('A, b are not equal');
|
|
7302
7307
|
}
|
|
7303
7308
|
|
|
7304
7309
|
function inspect(obj) {
|
|
@@ -10043,7 +10048,7 @@ var hasRequiredNewId;
|
|
|
10043
10048
|
function requireNewId () {
|
|
10044
10049
|
if (hasRequiredNewId) return newId;
|
|
10045
10050
|
hasRequiredNewId = 1;
|
|
10046
|
-
const { v4 : uuid} = require$$0$
|
|
10051
|
+
const { v4 : uuid} = require$$0$2;
|
|
10047
10052
|
newId = uuid;
|
|
10048
10053
|
return newId;
|
|
10049
10054
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
/* eslint-disable */
|
|
3
|
-
let assert = require('assert');
|
|
4
3
|
const toCompareObject = require('./toCompareObject');
|
|
5
4
|
|
|
6
5
|
async function validateDeleteConflict({ row, oldValue, options, table }) {
|
|
@@ -15,7 +14,7 @@ async function validateDeleteConflict({ row, oldValue, options, table }) {
|
|
|
15
14
|
assertDatesEqual(oldValue[p], toCompareObject(row[p]));
|
|
16
15
|
}
|
|
17
16
|
else
|
|
18
|
-
|
|
17
|
+
assertDeepEqual(oldValue[p], toCompareObject(row[p]));
|
|
19
18
|
}
|
|
20
19
|
catch (e) {
|
|
21
20
|
throw new Error(`The field ${p} was changed by another user. Expected ${inspect(oldValue[p])}, but was ${inspect(row[p])}.`);
|
|
@@ -84,7 +83,12 @@ function assertDatesEqual(date1, date2) {
|
|
|
84
83
|
date1 = `${parts1[0]}T${time1parts[0]}`;
|
|
85
84
|
date2 = `${parts2[0]}T${time2parts[0]}`;
|
|
86
85
|
}
|
|
87
|
-
|
|
86
|
+
assertDeepEqual(date1, date2);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function assertDeepEqual(a, b) {
|
|
90
|
+
if (JSON.stringify(a) !== JSON.stringify(b))
|
|
91
|
+
throw new Error('A, b are not equal');
|
|
88
92
|
}
|
|
89
93
|
|
|
90
94
|
function inspect(obj) {
|