@deterministic-code/datasources-cli 0.1.12 → 0.1.13
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/node_modules/@deterministic-code/datasources-code-generators/dist/sql/common/version-apply.d.ts +1 -0
- package/node_modules/@deterministic-code/datasources-code-generators/dist/sql/common/version-apply.js +38 -1
- package/node_modules/@deterministic-code/datasources-code-generators/package.json +1 -1
- package/package.json +2 -2
|
@@ -14,5 +14,6 @@ export declare const applyDocument: (before: {
|
|
|
14
14
|
[path: string]: Json;
|
|
15
15
|
};
|
|
16
16
|
export declare const isObject: (value: Json | undefined) => value is JsonObject;
|
|
17
|
+
/** Keyed lists compare by key. Version diffs append `added` entries and do not store position. */
|
|
17
18
|
export declare const snapshotsEqual: (left: Json | undefined, right: Json | undefined) => boolean;
|
|
18
19
|
export {};
|
|
@@ -80,4 +80,41 @@ const isKeyedCollection = (value) => Array.isArray(value) &&
|
|
|
80
80
|
typeof item === "object" &&
|
|
81
81
|
!Array.isArray(item) &&
|
|
82
82
|
Object.keys(item).length === 1);
|
|
83
|
-
|
|
83
|
+
/** Keyed lists compare by key. Version diffs append `added` entries and do not store position. */
|
|
84
|
+
export const snapshotsEqual = (left, right) => same(left ?? null, right ?? null);
|
|
85
|
+
const same = (left, right) => {
|
|
86
|
+
if (isKeyedCollection(left) && isKeyedCollection(right))
|
|
87
|
+
return keyedEqual(left, right);
|
|
88
|
+
if (isObject(left) && isObject(right))
|
|
89
|
+
return objectEqual(left, right);
|
|
90
|
+
if (Array.isArray(left) && Array.isArray(right))
|
|
91
|
+
return left.length === right.length && left.every((item, index) => same(item, right[index]));
|
|
92
|
+
return isDeepStrictEqual(left, right);
|
|
93
|
+
};
|
|
94
|
+
const keyedEqual = (left, right) => {
|
|
95
|
+
const leftMap = uniqueKeyed(left);
|
|
96
|
+
const rightMap = uniqueKeyed(right);
|
|
97
|
+
if (leftMap === undefined || rightMap === undefined)
|
|
98
|
+
return isDeepStrictEqual(left, right);
|
|
99
|
+
if (leftMap.size !== rightMap.size)
|
|
100
|
+
return false;
|
|
101
|
+
for (const [key, value] of leftMap)
|
|
102
|
+
if (!rightMap.has(key) || !same(value, rightMap.get(key)))
|
|
103
|
+
return false;
|
|
104
|
+
return true;
|
|
105
|
+
};
|
|
106
|
+
const uniqueKeyed = (items) => {
|
|
107
|
+
const map = new Map();
|
|
108
|
+
for (const entry of items) {
|
|
109
|
+
const key = Object.keys(entry)[0];
|
|
110
|
+
if (map.has(key))
|
|
111
|
+
return undefined;
|
|
112
|
+
map.set(key, entry[key]);
|
|
113
|
+
}
|
|
114
|
+
return map;
|
|
115
|
+
};
|
|
116
|
+
const objectEqual = (left, right) => {
|
|
117
|
+
const keys = Object.keys(left);
|
|
118
|
+
return (keys.length === Object.keys(right).length &&
|
|
119
|
+
keys.every((key) => key in right && same(left[key], right[key])));
|
|
120
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@deterministic-code/datasources-cli",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.13",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"datasources": "./bin/datasources.mjs"
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"access": "public"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"@deterministic-code/datasources-code-generators": "0.1.
|
|
16
|
+
"@deterministic-code/datasources-code-generators": "0.1.2",
|
|
17
17
|
"@deterministic-code/generators-common": "0.0.1",
|
|
18
18
|
"@deterministic-code/deterministic-generators-common": "0.1.0",
|
|
19
19
|
"@deterministic-code/typescript-generators": "0.0.1",
|