@fragment-dev/cli 2026.10.1-3 → 2026.10.1-6
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 +16 -4
- package/dist/{chunk-T7PAZDQ2.js → chunk-23KWDUJZ.js} +7 -1
- package/dist/{chunk-JMFDKBJW.js → chunk-2LDAYJQR.js} +2 -2
- package/dist/{chunk-Q62TGFNL.js → chunk-2QR6NGWG.js} +1 -1
- package/dist/{chunk-LINOTI5E.js → chunk-3IA6BI6A.js} +1 -1
- package/dist/{chunk-GZF5GHBV.js → chunk-3IGRQ6LL.js} +3 -3
- package/dist/{chunk-MUN6P2HN.js → chunk-3K6ERQYV.js} +1 -1
- package/dist/{chunk-D65TXRLZ.js → chunk-5NKCOZCW.js} +2 -2
- package/dist/{chunk-VZA2YKI6.js → chunk-5UOYY7GS.js} +2 -2
- package/dist/{chunk-F6IDBMXZ.js → chunk-6PRTPBP7.js} +1 -1
- package/dist/{chunk-XUOVQRQH.js → chunk-D45KVQKB.js} +1 -1
- package/dist/{chunk-7LEHQFLL.js → chunk-DT372IG6.js} +1 -1
- package/dist/{chunk-I7HWZUNL.js → chunk-DYIB3NZM.js} +59 -12
- package/dist/{chunk-3QIKHVTA.js → chunk-E7ZKZZP4.js} +2 -2
- package/dist/{chunk-C67WHN2H.js → chunk-F4DGB2QI.js} +2 -2
- package/dist/{chunk-TXPR56T5.js → chunk-H3ZCVAW3.js} +1 -1
- package/dist/{chunk-B3OMOGVU.js → chunk-HK327LQP.js} +3 -3
- package/dist/{chunk-JV34IPXX.js → chunk-IQIFAKDJ.js} +3 -3
- package/dist/{chunk-BMPSZNHE.js → chunk-JO6OQM5C.js} +1 -1
- package/dist/{chunk-DURV4GOT.js → chunk-KVBNKJBH.js} +2 -2
- package/dist/{chunk-5VGUS75G.js → chunk-LDS5IWT5.js} +6 -6
- package/dist/{chunk-SWVXV42Y.js → chunk-M7BM6YC2.js} +1 -1
- package/dist/{chunk-5JTGKU4S.js → chunk-NJSYUXAC.js} +2 -2
- package/dist/chunk-NT74GT6W.js +1287 -0
- package/dist/{chunk-WUKDB7IX.js → chunk-PHWV3NOP.js} +162 -51
- package/dist/{chunk-KP7MQPVO.js → chunk-Q3JFAZ3A.js} +1 -1
- package/dist/{chunk-WCXDVPWC.js → chunk-Q6ZKCAYH.js} +2 -2
- package/dist/{chunk-EIF4FTEI.js → chunk-QBQANVTD.js} +2 -2
- package/dist/{chunk-E4TL7SOK.js → chunk-QGFJ5H4G.js} +2 -2
- package/dist/{chunk-PU52GTGB.js → chunk-QZNZYG2G.js} +24 -14
- package/dist/{chunk-76JJLPFT.js → chunk-RML6NQHP.js} +1 -1
- package/dist/{chunk-4IMXVHLX.js → chunk-SU5G5HM2.js} +2 -2
- package/dist/{chunk-2DFNUYYB.js → chunk-THGEB6PT.js} +3 -3
- package/dist/{chunk-I65PNYBQ.js → chunk-UJP55YSW.js} +25 -25
- package/dist/{chunk-JXIMFTTA.js → chunk-V3NABYUX.js} +2 -2
- package/dist/{chunk-MOBC7AAW.js → chunk-V4IQY3DF.js} +1 -1
- package/dist/{chunk-DVQMZBTY.js → chunk-WRUBCN4G.js} +2 -2
- package/dist/{chunk-DKAEBT2M.js → chunk-XJ2TNWI7.js} +8 -0
- package/dist/commands/add-ledger-entry.js +4 -4
- package/dist/commands/api-client/create.js +3 -3
- package/dist/commands/create-custom-link.js +4 -4
- package/dist/commands/create-ledger.js +4 -4
- package/dist/commands/delete-custom-txs.js +4 -4
- package/dist/commands/delete-ledger.js +4 -4
- package/dist/commands/delete-schema.js +4 -4
- package/dist/commands/gen-graphql.js +8 -8
- package/dist/commands/get-schema.js +5 -5
- package/dist/commands/init.js +3 -3
- package/dist/commands/login.js +4 -4
- package/dist/commands/migrate-ledger-entry.js +4 -4
- package/dist/commands/query/ledgerAccounts.js +4 -4
- package/dist/commands/query/ledgers.js +4 -4
- package/dist/commands/query/schema.js +4 -4
- package/dist/commands/query/schemas.js +4 -4
- package/dist/commands/reverse-ledger-entry.js +4 -4
- package/dist/commands/start.js +3 -3
- package/dist/commands/store-schema.js +4 -4
- package/dist/commands/token.js +4 -4
- package/dist/commands/update-ledger-account.js +4 -4
- package/dist/commands/update.js +4 -4
- package/dist/commands/verify-schema.js +9 -8
- package/dist/commands/version.js +3 -3
- package/dist/commands/workspace.js +4 -4
- package/dist/commands.js +37 -36
- package/dist/graphql.js +3 -3
- package/dist/index.js +37 -36
- package/dist/lib/authenticatedCommand.js +3 -3
- package/dist/lib/baseCommand.js +2 -2
- package/dist/utils/formatValidationErrors.js +2 -2
- package/dist/utils/schemaBackCompat.js +21 -0
- package/dist/utils/schemaValidation.js +5 -5
- package/dist/utils.js +5 -3
- package/oclif.manifest.json +18 -2
- package/package.json +1 -1
|
@@ -0,0 +1,1287 @@
|
|
|
1
|
+
import {
|
|
2
|
+
validateSchemaStructure
|
|
3
|
+
} from "./chunk-IQIFAKDJ.js";
|
|
4
|
+
import {
|
|
5
|
+
ChartOfAccounts,
|
|
6
|
+
MIN_SCHEMA_LEDGER_ENTRY_DISABLED_DURATION_SECONDS,
|
|
7
|
+
N,
|
|
8
|
+
Schema,
|
|
9
|
+
areExpressionsEqual,
|
|
10
|
+
evaluateExpressionWithVars,
|
|
11
|
+
getAccountStatus,
|
|
12
|
+
parseWithError,
|
|
13
|
+
stringify,
|
|
14
|
+
z
|
|
15
|
+
} from "./chunk-PHWV3NOP.js";
|
|
16
|
+
import {
|
|
17
|
+
PaymentAccountingEventKey,
|
|
18
|
+
VALID_LEDGER_ACCOUNT_STATUS_TRANSITIONS,
|
|
19
|
+
getSchemaObjectParameters
|
|
20
|
+
} from "./chunk-23KWDUJZ.js";
|
|
21
|
+
import {
|
|
22
|
+
BadRequestError,
|
|
23
|
+
InternalError,
|
|
24
|
+
assert_default,
|
|
25
|
+
isEqual_default
|
|
26
|
+
} from "./chunk-XJ2TNWI7.js";
|
|
27
|
+
import {
|
|
28
|
+
getParsedSchemaString,
|
|
29
|
+
parseJSON
|
|
30
|
+
} from "./chunk-QZNZYG2G.js";
|
|
31
|
+
import {
|
|
32
|
+
__commonJS,
|
|
33
|
+
__require,
|
|
34
|
+
__toESM,
|
|
35
|
+
init_cjs_shims
|
|
36
|
+
} from "./chunk-7GH3YGSC.js";
|
|
37
|
+
|
|
38
|
+
// ../../node_modules/object-hash/index.js
|
|
39
|
+
var require_object_hash = __commonJS({
|
|
40
|
+
"../../node_modules/object-hash/index.js"(exports, module) {
|
|
41
|
+
"use strict";
|
|
42
|
+
init_cjs_shims();
|
|
43
|
+
var crypto = __require("crypto");
|
|
44
|
+
exports = module.exports = objectHash;
|
|
45
|
+
function objectHash(object, options) {
|
|
46
|
+
options = applyDefaults(object, options);
|
|
47
|
+
return hash2(object, options);
|
|
48
|
+
}
|
|
49
|
+
exports.sha1 = function(object) {
|
|
50
|
+
return objectHash(object);
|
|
51
|
+
};
|
|
52
|
+
exports.keys = function(object) {
|
|
53
|
+
return objectHash(object, { excludeValues: true, algorithm: "sha1", encoding: "hex" });
|
|
54
|
+
};
|
|
55
|
+
exports.MD5 = function(object) {
|
|
56
|
+
return objectHash(object, { algorithm: "md5", encoding: "hex" });
|
|
57
|
+
};
|
|
58
|
+
exports.keysMD5 = function(object) {
|
|
59
|
+
return objectHash(object, { algorithm: "md5", encoding: "hex", excludeValues: true });
|
|
60
|
+
};
|
|
61
|
+
var hashes = crypto.getHashes ? crypto.getHashes().slice() : ["sha1", "md5"];
|
|
62
|
+
hashes.push("passthrough");
|
|
63
|
+
var encodings = ["buffer", "hex", "binary", "base64"];
|
|
64
|
+
function applyDefaults(object, sourceOptions) {
|
|
65
|
+
sourceOptions = sourceOptions || {};
|
|
66
|
+
var options = {};
|
|
67
|
+
options.algorithm = sourceOptions.algorithm || "sha1";
|
|
68
|
+
options.encoding = sourceOptions.encoding || "hex";
|
|
69
|
+
options.excludeValues = sourceOptions.excludeValues ? true : false;
|
|
70
|
+
options.algorithm = options.algorithm.toLowerCase();
|
|
71
|
+
options.encoding = options.encoding.toLowerCase();
|
|
72
|
+
options.ignoreUnknown = sourceOptions.ignoreUnknown !== true ? false : true;
|
|
73
|
+
options.respectType = sourceOptions.respectType === false ? false : true;
|
|
74
|
+
options.respectFunctionNames = sourceOptions.respectFunctionNames === false ? false : true;
|
|
75
|
+
options.respectFunctionProperties = sourceOptions.respectFunctionProperties === false ? false : true;
|
|
76
|
+
options.unorderedArrays = sourceOptions.unorderedArrays !== true ? false : true;
|
|
77
|
+
options.unorderedSets = sourceOptions.unorderedSets === false ? false : true;
|
|
78
|
+
options.unorderedObjects = sourceOptions.unorderedObjects === false ? false : true;
|
|
79
|
+
options.replacer = sourceOptions.replacer || void 0;
|
|
80
|
+
options.excludeKeys = sourceOptions.excludeKeys || void 0;
|
|
81
|
+
if (typeof object === "undefined") {
|
|
82
|
+
throw new Error("Object argument required.");
|
|
83
|
+
}
|
|
84
|
+
for (var i = 0; i < hashes.length; ++i) {
|
|
85
|
+
if (hashes[i].toLowerCase() === options.algorithm.toLowerCase()) {
|
|
86
|
+
options.algorithm = hashes[i];
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (hashes.indexOf(options.algorithm) === -1) {
|
|
90
|
+
throw new Error('Algorithm "' + options.algorithm + '" not supported. supported values: ' + hashes.join(", "));
|
|
91
|
+
}
|
|
92
|
+
if (encodings.indexOf(options.encoding) === -1 && options.algorithm !== "passthrough") {
|
|
93
|
+
throw new Error('Encoding "' + options.encoding + '" not supported. supported values: ' + encodings.join(", "));
|
|
94
|
+
}
|
|
95
|
+
return options;
|
|
96
|
+
}
|
|
97
|
+
function isNativeFunction(f) {
|
|
98
|
+
if (typeof f !== "function") {
|
|
99
|
+
return false;
|
|
100
|
+
}
|
|
101
|
+
var exp = /^function\s+\w*\s*\(\s*\)\s*{\s+\[native code\]\s+}$/i;
|
|
102
|
+
return exp.exec(Function.prototype.toString.call(f)) != null;
|
|
103
|
+
}
|
|
104
|
+
function hash2(object, options) {
|
|
105
|
+
var hashingStream;
|
|
106
|
+
if (options.algorithm !== "passthrough") {
|
|
107
|
+
hashingStream = crypto.createHash(options.algorithm);
|
|
108
|
+
} else {
|
|
109
|
+
hashingStream = new PassThrough();
|
|
110
|
+
}
|
|
111
|
+
if (typeof hashingStream.write === "undefined") {
|
|
112
|
+
hashingStream.write = hashingStream.update;
|
|
113
|
+
hashingStream.end = hashingStream.update;
|
|
114
|
+
}
|
|
115
|
+
var hasher = typeHasher(options, hashingStream);
|
|
116
|
+
hasher.dispatch(object);
|
|
117
|
+
if (!hashingStream.update) {
|
|
118
|
+
hashingStream.end("");
|
|
119
|
+
}
|
|
120
|
+
if (hashingStream.digest) {
|
|
121
|
+
return hashingStream.digest(options.encoding === "buffer" ? void 0 : options.encoding);
|
|
122
|
+
}
|
|
123
|
+
var buf = hashingStream.read();
|
|
124
|
+
if (options.encoding === "buffer") {
|
|
125
|
+
return buf;
|
|
126
|
+
}
|
|
127
|
+
return buf.toString(options.encoding);
|
|
128
|
+
}
|
|
129
|
+
exports.writeToStream = function(object, options, stream) {
|
|
130
|
+
if (typeof stream === "undefined") {
|
|
131
|
+
stream = options;
|
|
132
|
+
options = {};
|
|
133
|
+
}
|
|
134
|
+
options = applyDefaults(object, options);
|
|
135
|
+
return typeHasher(options, stream).dispatch(object);
|
|
136
|
+
};
|
|
137
|
+
function typeHasher(options, writeTo, context) {
|
|
138
|
+
context = context || [];
|
|
139
|
+
var write = function(str) {
|
|
140
|
+
if (writeTo.update) {
|
|
141
|
+
return writeTo.update(str, "utf8");
|
|
142
|
+
} else {
|
|
143
|
+
return writeTo.write(str, "utf8");
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
return {
|
|
147
|
+
dispatch: function(value) {
|
|
148
|
+
if (options.replacer) {
|
|
149
|
+
value = options.replacer(value);
|
|
150
|
+
}
|
|
151
|
+
var type = typeof value;
|
|
152
|
+
if (value === null) {
|
|
153
|
+
type = "null";
|
|
154
|
+
}
|
|
155
|
+
return this["_" + type](value);
|
|
156
|
+
},
|
|
157
|
+
_object: function(object) {
|
|
158
|
+
var pattern = /\[object (.*)\]/i;
|
|
159
|
+
var objString = Object.prototype.toString.call(object);
|
|
160
|
+
var objType = pattern.exec(objString);
|
|
161
|
+
if (!objType) {
|
|
162
|
+
objType = "unknown:[" + objString + "]";
|
|
163
|
+
} else {
|
|
164
|
+
objType = objType[1];
|
|
165
|
+
}
|
|
166
|
+
objType = objType.toLowerCase();
|
|
167
|
+
var objectNumber = null;
|
|
168
|
+
if ((objectNumber = context.indexOf(object)) >= 0) {
|
|
169
|
+
return this.dispatch("[CIRCULAR:" + objectNumber + "]");
|
|
170
|
+
} else {
|
|
171
|
+
context.push(object);
|
|
172
|
+
}
|
|
173
|
+
if (typeof Buffer !== "undefined" && Buffer.isBuffer && Buffer.isBuffer(object)) {
|
|
174
|
+
write("buffer:");
|
|
175
|
+
return write(object);
|
|
176
|
+
}
|
|
177
|
+
if (objType !== "object" && objType !== "function" && objType !== "asyncfunction") {
|
|
178
|
+
if (this["_" + objType]) {
|
|
179
|
+
this["_" + objType](object);
|
|
180
|
+
} else if (options.ignoreUnknown) {
|
|
181
|
+
return write("[" + objType + "]");
|
|
182
|
+
} else {
|
|
183
|
+
throw new Error('Unknown object type "' + objType + '"');
|
|
184
|
+
}
|
|
185
|
+
} else {
|
|
186
|
+
var keys = Object.keys(object);
|
|
187
|
+
if (options.unorderedObjects) {
|
|
188
|
+
keys = keys.sort();
|
|
189
|
+
}
|
|
190
|
+
if (options.respectType !== false && !isNativeFunction(object)) {
|
|
191
|
+
keys.splice(0, 0, "prototype", "__proto__", "constructor");
|
|
192
|
+
}
|
|
193
|
+
if (options.excludeKeys) {
|
|
194
|
+
keys = keys.filter(function(key) {
|
|
195
|
+
return !options.excludeKeys(key);
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
write("object:" + keys.length + ":");
|
|
199
|
+
var self = this;
|
|
200
|
+
return keys.forEach(function(key) {
|
|
201
|
+
self.dispatch(key);
|
|
202
|
+
write(":");
|
|
203
|
+
if (!options.excludeValues) {
|
|
204
|
+
self.dispatch(object[key]);
|
|
205
|
+
}
|
|
206
|
+
write(",");
|
|
207
|
+
});
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
_array: function(arr, unordered) {
|
|
211
|
+
unordered = typeof unordered !== "undefined" ? unordered : options.unorderedArrays !== false;
|
|
212
|
+
var self = this;
|
|
213
|
+
write("array:" + arr.length + ":");
|
|
214
|
+
if (!unordered || arr.length <= 1) {
|
|
215
|
+
return arr.forEach(function(entry) {
|
|
216
|
+
return self.dispatch(entry);
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
var contextAdditions = [];
|
|
220
|
+
var entries = arr.map(function(entry) {
|
|
221
|
+
var strm = new PassThrough();
|
|
222
|
+
var localContext = context.slice();
|
|
223
|
+
var hasher = typeHasher(options, strm, localContext);
|
|
224
|
+
hasher.dispatch(entry);
|
|
225
|
+
contextAdditions = contextAdditions.concat(localContext.slice(context.length));
|
|
226
|
+
return strm.read().toString();
|
|
227
|
+
});
|
|
228
|
+
context = context.concat(contextAdditions);
|
|
229
|
+
entries.sort();
|
|
230
|
+
return this._array(entries, false);
|
|
231
|
+
},
|
|
232
|
+
_date: function(date) {
|
|
233
|
+
return write("date:" + date.toJSON());
|
|
234
|
+
},
|
|
235
|
+
_symbol: function(sym) {
|
|
236
|
+
return write("symbol:" + sym.toString());
|
|
237
|
+
},
|
|
238
|
+
_error: function(err) {
|
|
239
|
+
return write("error:" + err.toString());
|
|
240
|
+
},
|
|
241
|
+
_boolean: function(bool) {
|
|
242
|
+
return write("bool:" + bool.toString());
|
|
243
|
+
},
|
|
244
|
+
_string: function(string) {
|
|
245
|
+
write("string:" + string.length + ":");
|
|
246
|
+
write(string.toString());
|
|
247
|
+
},
|
|
248
|
+
_function: function(fn) {
|
|
249
|
+
write("fn:");
|
|
250
|
+
if (isNativeFunction(fn)) {
|
|
251
|
+
this.dispatch("[native]");
|
|
252
|
+
} else {
|
|
253
|
+
this.dispatch(fn.toString());
|
|
254
|
+
}
|
|
255
|
+
if (options.respectFunctionNames !== false) {
|
|
256
|
+
this.dispatch("function-name:" + String(fn.name));
|
|
257
|
+
}
|
|
258
|
+
if (options.respectFunctionProperties) {
|
|
259
|
+
this._object(fn);
|
|
260
|
+
}
|
|
261
|
+
},
|
|
262
|
+
_number: function(number) {
|
|
263
|
+
return write("number:" + number.toString());
|
|
264
|
+
},
|
|
265
|
+
_xml: function(xml) {
|
|
266
|
+
return write("xml:" + xml.toString());
|
|
267
|
+
},
|
|
268
|
+
_null: function() {
|
|
269
|
+
return write("Null");
|
|
270
|
+
},
|
|
271
|
+
_undefined: function() {
|
|
272
|
+
return write("Undefined");
|
|
273
|
+
},
|
|
274
|
+
_regexp: function(regex) {
|
|
275
|
+
return write("regex:" + regex.toString());
|
|
276
|
+
},
|
|
277
|
+
_uint8array: function(arr) {
|
|
278
|
+
write("uint8array:");
|
|
279
|
+
return this.dispatch(Array.prototype.slice.call(arr));
|
|
280
|
+
},
|
|
281
|
+
_uint8clampedarray: function(arr) {
|
|
282
|
+
write("uint8clampedarray:");
|
|
283
|
+
return this.dispatch(Array.prototype.slice.call(arr));
|
|
284
|
+
},
|
|
285
|
+
_int8array: function(arr) {
|
|
286
|
+
write("int8array:");
|
|
287
|
+
return this.dispatch(Array.prototype.slice.call(arr));
|
|
288
|
+
},
|
|
289
|
+
_uint16array: function(arr) {
|
|
290
|
+
write("uint16array:");
|
|
291
|
+
return this.dispatch(Array.prototype.slice.call(arr));
|
|
292
|
+
},
|
|
293
|
+
_int16array: function(arr) {
|
|
294
|
+
write("int16array:");
|
|
295
|
+
return this.dispatch(Array.prototype.slice.call(arr));
|
|
296
|
+
},
|
|
297
|
+
_uint32array: function(arr) {
|
|
298
|
+
write("uint32array:");
|
|
299
|
+
return this.dispatch(Array.prototype.slice.call(arr));
|
|
300
|
+
},
|
|
301
|
+
_int32array: function(arr) {
|
|
302
|
+
write("int32array:");
|
|
303
|
+
return this.dispatch(Array.prototype.slice.call(arr));
|
|
304
|
+
},
|
|
305
|
+
_float32array: function(arr) {
|
|
306
|
+
write("float32array:");
|
|
307
|
+
return this.dispatch(Array.prototype.slice.call(arr));
|
|
308
|
+
},
|
|
309
|
+
_float64array: function(arr) {
|
|
310
|
+
write("float64array:");
|
|
311
|
+
return this.dispatch(Array.prototype.slice.call(arr));
|
|
312
|
+
},
|
|
313
|
+
_arraybuffer: function(arr) {
|
|
314
|
+
write("arraybuffer:");
|
|
315
|
+
return this.dispatch(new Uint8Array(arr));
|
|
316
|
+
},
|
|
317
|
+
_url: function(url) {
|
|
318
|
+
return write("url:" + url.toString(), "utf8");
|
|
319
|
+
},
|
|
320
|
+
_map: function(map) {
|
|
321
|
+
write("map:");
|
|
322
|
+
var arr = Array.from(map);
|
|
323
|
+
return this._array(arr, options.unorderedSets !== false);
|
|
324
|
+
},
|
|
325
|
+
_set: function(set) {
|
|
326
|
+
write("set:");
|
|
327
|
+
var arr = Array.from(set);
|
|
328
|
+
return this._array(arr, options.unorderedSets !== false);
|
|
329
|
+
},
|
|
330
|
+
_file: function(file) {
|
|
331
|
+
write("file:");
|
|
332
|
+
return this.dispatch([file.name, file.size, file.type, file.lastModfied]);
|
|
333
|
+
},
|
|
334
|
+
_blob: function() {
|
|
335
|
+
if (options.ignoreUnknown) {
|
|
336
|
+
return write("[blob]");
|
|
337
|
+
}
|
|
338
|
+
throw Error('Hashing Blob objects is currently not supported\n(see https://github.com/puleos/object-hash/issues/26)\nUse "options.replacer" or "options.ignoreUnknown"\n');
|
|
339
|
+
},
|
|
340
|
+
_domwindow: function() {
|
|
341
|
+
return write("domwindow");
|
|
342
|
+
},
|
|
343
|
+
_bigint: function(number) {
|
|
344
|
+
return write("bigint:" + number.toString());
|
|
345
|
+
},
|
|
346
|
+
/* Node.js standard native objects */
|
|
347
|
+
_process: function() {
|
|
348
|
+
return write("process");
|
|
349
|
+
},
|
|
350
|
+
_timer: function() {
|
|
351
|
+
return write("timer");
|
|
352
|
+
},
|
|
353
|
+
_pipe: function() {
|
|
354
|
+
return write("pipe");
|
|
355
|
+
},
|
|
356
|
+
_tcp: function() {
|
|
357
|
+
return write("tcp");
|
|
358
|
+
},
|
|
359
|
+
_udp: function() {
|
|
360
|
+
return write("udp");
|
|
361
|
+
},
|
|
362
|
+
_tty: function() {
|
|
363
|
+
return write("tty");
|
|
364
|
+
},
|
|
365
|
+
_statwatcher: function() {
|
|
366
|
+
return write("statwatcher");
|
|
367
|
+
},
|
|
368
|
+
_securecontext: function() {
|
|
369
|
+
return write("securecontext");
|
|
370
|
+
},
|
|
371
|
+
_connection: function() {
|
|
372
|
+
return write("connection");
|
|
373
|
+
},
|
|
374
|
+
_zlib: function() {
|
|
375
|
+
return write("zlib");
|
|
376
|
+
},
|
|
377
|
+
_context: function() {
|
|
378
|
+
return write("context");
|
|
379
|
+
},
|
|
380
|
+
_nodescript: function() {
|
|
381
|
+
return write("nodescript");
|
|
382
|
+
},
|
|
383
|
+
_httpparser: function() {
|
|
384
|
+
return write("httpparser");
|
|
385
|
+
},
|
|
386
|
+
_dataview: function() {
|
|
387
|
+
return write("dataview");
|
|
388
|
+
},
|
|
389
|
+
_signal: function() {
|
|
390
|
+
return write("signal");
|
|
391
|
+
},
|
|
392
|
+
_fsevent: function() {
|
|
393
|
+
return write("fsevent");
|
|
394
|
+
},
|
|
395
|
+
_tlswrap: function() {
|
|
396
|
+
return write("tlswrap");
|
|
397
|
+
}
|
|
398
|
+
};
|
|
399
|
+
}
|
|
400
|
+
function PassThrough() {
|
|
401
|
+
return {
|
|
402
|
+
buf: "",
|
|
403
|
+
write: function(b) {
|
|
404
|
+
this.buf += b;
|
|
405
|
+
},
|
|
406
|
+
end: function(b) {
|
|
407
|
+
this.buf += b;
|
|
408
|
+
},
|
|
409
|
+
read: function() {
|
|
410
|
+
return this.buf;
|
|
411
|
+
}
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
});
|
|
416
|
+
|
|
417
|
+
// src/utils/schemaBackCompat.ts
|
|
418
|
+
init_cjs_shims();
|
|
419
|
+
|
|
420
|
+
// ../../libs/schema-validation/utils/backcompat/evaluateDeployBackCompat.ts
|
|
421
|
+
init_cjs_shims();
|
|
422
|
+
|
|
423
|
+
// ../../libs/schema-validation/utils/backcompat/verifySchemaBackCompat.ts
|
|
424
|
+
init_cjs_shims();
|
|
425
|
+
|
|
426
|
+
// ../../libs/schema-validation/utils/validateSchema.ts
|
|
427
|
+
init_cjs_shims();
|
|
428
|
+
var validateSchema = (schema) => {
|
|
429
|
+
const validatedSchema = parseWithError(Schema, schema, BadRequestError, {
|
|
430
|
+
message: "Invalid schema provided"
|
|
431
|
+
});
|
|
432
|
+
return validatedSchema;
|
|
433
|
+
};
|
|
434
|
+
|
|
435
|
+
// ../../libs/schema-validation/utils/backcompat/entries.ts
|
|
436
|
+
init_cjs_shims();
|
|
437
|
+
var import_object_hash = __toESM(require_object_hash(), 1);
|
|
438
|
+
|
|
439
|
+
// ../../libs/comparison-utils/index.ts
|
|
440
|
+
init_cjs_shims();
|
|
441
|
+
var createComparator = (paths) => {
|
|
442
|
+
return (t1, t2) => paths.filter((path) => {
|
|
443
|
+
const left = path.serializer(t1);
|
|
444
|
+
const right = path.serializer(t2);
|
|
445
|
+
const comparisonFn = path.comparisonFn ?? isEqual_default;
|
|
446
|
+
return !comparisonFn(left, right);
|
|
447
|
+
}).map(
|
|
448
|
+
(path) => `Found a mismatch at ${path.name}: ${stringify(
|
|
449
|
+
path.serializer(t1)
|
|
450
|
+
)} !== ${stringify(path.serializer(t2))}`
|
|
451
|
+
);
|
|
452
|
+
};
|
|
453
|
+
|
|
454
|
+
// ../../libs/schema-validation/utils/backcompat/entries.ts
|
|
455
|
+
var areSetsEqual = (a, b) => a.size === b.size && [...a].every((value) => b.has(value));
|
|
456
|
+
var isFieldCheck = (value) => typeof value.serializer === "function";
|
|
457
|
+
var flattenChecks = (checks) => isFieldCheck(checks) ? [checks] : Object.values(checks);
|
|
458
|
+
var verifyAmountBackCompat = (oldLine, newLine, basePath) => {
|
|
459
|
+
if (!oldLine.amount?.trim()) {
|
|
460
|
+
return newLine.amount?.trim() ? [{ path: [...basePath, "amount"], message: `Amount added to line.` }] : [];
|
|
461
|
+
}
|
|
462
|
+
if (!newLine.amount?.trim()) {
|
|
463
|
+
return [
|
|
464
|
+
{ path: [...basePath, "amount"], message: `Amount removed from line.` }
|
|
465
|
+
];
|
|
466
|
+
}
|
|
467
|
+
try {
|
|
468
|
+
const oldAmountExpression = evaluateExpressionWithVars(oldLine.amount);
|
|
469
|
+
const newAmountExpression = evaluateExpressionWithVars(newLine.amount);
|
|
470
|
+
return areExpressionsEqual(oldAmountExpression, newAmountExpression) ? [] : [
|
|
471
|
+
{
|
|
472
|
+
path: [...basePath, "amount"],
|
|
473
|
+
message: `Amount changed from '${oldLine.amount}' to '${newLine.amount}'.`
|
|
474
|
+
}
|
|
475
|
+
];
|
|
476
|
+
} catch (err) {
|
|
477
|
+
return [];
|
|
478
|
+
}
|
|
479
|
+
};
|
|
480
|
+
var verifyLineTagsBackCompat = (oldLine, newLine, basePath) => {
|
|
481
|
+
const oldTags = new Set((oldLine.tags ?? []).map((tag) => (0, import_object_hash.default)(tag)));
|
|
482
|
+
const newTags = new Set((newLine.tags ?? []).map((tag) => (0, import_object_hash.default)(tag)));
|
|
483
|
+
return areSetsEqual(oldTags, newTags) ? [] : [{ path: [...basePath, "tags"], message: `Tags changed on line.` }];
|
|
484
|
+
};
|
|
485
|
+
var linePolicies = {
|
|
486
|
+
amount: { kind: "custom", check: verifyAmountBackCompat },
|
|
487
|
+
key: {
|
|
488
|
+
kind: "compare",
|
|
489
|
+
checks: { serializer: (line) => line.key, name: "key" }
|
|
490
|
+
},
|
|
491
|
+
account: {
|
|
492
|
+
kind: "compare",
|
|
493
|
+
checks: {
|
|
494
|
+
path: { serializer: (line) => line.account?.path, name: "accountPath" }
|
|
495
|
+
}
|
|
496
|
+
},
|
|
497
|
+
currency: {
|
|
498
|
+
kind: "compare",
|
|
499
|
+
checks: {
|
|
500
|
+
code: {
|
|
501
|
+
serializer: (line) => line.currency?.code,
|
|
502
|
+
name: "currency.code"
|
|
503
|
+
},
|
|
504
|
+
customCurrencyId: {
|
|
505
|
+
serializer: (line) => line.currency?.customCurrencyId,
|
|
506
|
+
name: "currency.customCurrencyId"
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
},
|
|
510
|
+
tx: {
|
|
511
|
+
kind: "compare",
|
|
512
|
+
checks: {
|
|
513
|
+
id: { serializer: (line) => line.tx?.id, name: "tx.id" },
|
|
514
|
+
externalId: {
|
|
515
|
+
serializer: (line) => line.tx?.externalId,
|
|
516
|
+
name: "tx.externalId"
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
},
|
|
520
|
+
repeated: {
|
|
521
|
+
kind: "compare",
|
|
522
|
+
checks: {
|
|
523
|
+
key: { serializer: (line) => line.repeated?.key, name: "repeated.key" }
|
|
524
|
+
}
|
|
525
|
+
},
|
|
526
|
+
tags: { kind: "custom", check: verifyLineTagsBackCompat },
|
|
527
|
+
description: {
|
|
528
|
+
kind: "ignored",
|
|
529
|
+
reason: "Not part of the posted line; changing it does not affect entries."
|
|
530
|
+
}
|
|
531
|
+
};
|
|
532
|
+
var lineCheckers = Object.values(linePolicies).map(
|
|
533
|
+
(policy) => z(policy).returnType().with({ kind: "ignored" }, () => () => []).with({ kind: "compare" }, ({ checks }) => {
|
|
534
|
+
const comparator = createComparator(
|
|
535
|
+
flattenChecks(checks)
|
|
536
|
+
);
|
|
537
|
+
return (oldLine, newLine, basePath) => comparator(oldLine, newLine).map((message) => ({
|
|
538
|
+
path: [...basePath],
|
|
539
|
+
message
|
|
540
|
+
}));
|
|
541
|
+
}).with({ kind: "custom" }, ({ check }) => check).exhaustive()
|
|
542
|
+
);
|
|
543
|
+
var conditionComparator = createComparator([
|
|
544
|
+
{ serializer: (condition) => condition.account?.path, name: "accountPath" },
|
|
545
|
+
{
|
|
546
|
+
serializer: (condition) => condition.currency?.code,
|
|
547
|
+
name: "currency.code"
|
|
548
|
+
},
|
|
549
|
+
{
|
|
550
|
+
serializer: (condition) => condition.currency?.customCurrencyId,
|
|
551
|
+
name: "currency.customCurrencyId"
|
|
552
|
+
},
|
|
553
|
+
{
|
|
554
|
+
serializer: (condition) => condition.repeated?.key,
|
|
555
|
+
name: "repeated.key"
|
|
556
|
+
}
|
|
557
|
+
]);
|
|
558
|
+
var verifyLineBackCompat = (oldLine, newLine, basePath) => lineCheckers.flatMap((checker) => checker(oldLine, newLine, basePath));
|
|
559
|
+
var verifyConditionBackCompat = (oldCondition, newCondition, basePath) => {
|
|
560
|
+
const issues = [];
|
|
561
|
+
const compareComparatorValue = (oldValue, newValue, comparator, balanceType, conditionType) => {
|
|
562
|
+
const oldTrimmed = oldValue?.trim();
|
|
563
|
+
const newTrimmed = newValue?.trim();
|
|
564
|
+
if (!oldTrimmed && newTrimmed) {
|
|
565
|
+
issues.push({
|
|
566
|
+
path: [...basePath, conditionType, balanceType, comparator],
|
|
567
|
+
message: `${conditionType} ${balanceType} ${comparator} added.`
|
|
568
|
+
});
|
|
569
|
+
} else if (oldTrimmed && !newTrimmed) {
|
|
570
|
+
issues.push({
|
|
571
|
+
path: [...basePath, conditionType, balanceType, comparator],
|
|
572
|
+
message: `${conditionType} ${balanceType} ${comparator} removed.`
|
|
573
|
+
});
|
|
574
|
+
} else if (oldTrimmed && newTrimmed) {
|
|
575
|
+
try {
|
|
576
|
+
const oldExpression = evaluateExpressionWithVars(oldTrimmed);
|
|
577
|
+
const newExpression = evaluateExpressionWithVars(newTrimmed);
|
|
578
|
+
if (!areExpressionsEqual(oldExpression, newExpression)) {
|
|
579
|
+
issues.push({
|
|
580
|
+
path: [...basePath, conditionType, balanceType, comparator],
|
|
581
|
+
message: `${conditionType} ${balanceType} ${comparator} changed from '${oldTrimmed}' to '${newTrimmed}'.`
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
} catch (err) {
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
};
|
|
588
|
+
const compareConditionBalance = (oldBalance, newBalance, balanceType, conditionType) => {
|
|
589
|
+
compareComparatorValue(
|
|
590
|
+
oldBalance?.eq,
|
|
591
|
+
newBalance?.eq,
|
|
592
|
+
"eq",
|
|
593
|
+
balanceType,
|
|
594
|
+
conditionType
|
|
595
|
+
);
|
|
596
|
+
compareComparatorValue(
|
|
597
|
+
oldBalance?.lte,
|
|
598
|
+
newBalance?.lte,
|
|
599
|
+
"lte",
|
|
600
|
+
balanceType,
|
|
601
|
+
conditionType
|
|
602
|
+
);
|
|
603
|
+
compareComparatorValue(
|
|
604
|
+
oldBalance?.gte,
|
|
605
|
+
newBalance?.gte,
|
|
606
|
+
"gte",
|
|
607
|
+
balanceType,
|
|
608
|
+
conditionType
|
|
609
|
+
);
|
|
610
|
+
};
|
|
611
|
+
["precondition", "postcondition"].forEach((conditionType) => {
|
|
612
|
+
const oldPart = oldCondition[conditionType];
|
|
613
|
+
const newPart = newCondition[conditionType];
|
|
614
|
+
const label = conditionType.charAt(0).toUpperCase() + conditionType.slice(1);
|
|
615
|
+
z([oldPart, newPart]).with([void 0, void 0], () => {
|
|
616
|
+
}).with([void 0, N.nonNullable], () => {
|
|
617
|
+
issues.push({
|
|
618
|
+
path: [...basePath, conditionType],
|
|
619
|
+
message: `${label} added.`
|
|
620
|
+
});
|
|
621
|
+
}).with([N.nonNullable, void 0], () => {
|
|
622
|
+
issues.push({
|
|
623
|
+
path: [...basePath, conditionType],
|
|
624
|
+
message: `${label} removed.`
|
|
625
|
+
});
|
|
626
|
+
}).with(
|
|
627
|
+
[N.nonNullable, N.nonNullable],
|
|
628
|
+
([oldPartDefined, newPartDefined]) => {
|
|
629
|
+
const oldHasOwn = Boolean(oldPartDefined.ownBalance);
|
|
630
|
+
const oldHasTotal = Boolean(oldPartDefined.totalBalance);
|
|
631
|
+
const newHasOwn = Boolean(newPartDefined.ownBalance);
|
|
632
|
+
const newHasTotal = Boolean(newPartDefined.totalBalance);
|
|
633
|
+
const isOwnToTotal = oldHasOwn && !oldHasTotal && !newHasOwn && newHasTotal;
|
|
634
|
+
const isTotalToOwn = !oldHasOwn && oldHasTotal && newHasOwn && !newHasTotal;
|
|
635
|
+
if (isOwnToTotal) {
|
|
636
|
+
compareConditionBalance(
|
|
637
|
+
oldPartDefined.ownBalance,
|
|
638
|
+
newPartDefined.totalBalance,
|
|
639
|
+
"totalBalance",
|
|
640
|
+
conditionType
|
|
641
|
+
);
|
|
642
|
+
} else if (isTotalToOwn) {
|
|
643
|
+
compareConditionBalance(
|
|
644
|
+
oldPartDefined.totalBalance,
|
|
645
|
+
newPartDefined.ownBalance,
|
|
646
|
+
"ownBalance",
|
|
647
|
+
conditionType
|
|
648
|
+
);
|
|
649
|
+
} else {
|
|
650
|
+
compareConditionBalance(
|
|
651
|
+
oldPartDefined.ownBalance,
|
|
652
|
+
newPartDefined.ownBalance,
|
|
653
|
+
"ownBalance",
|
|
654
|
+
conditionType
|
|
655
|
+
);
|
|
656
|
+
compareConditionBalance(
|
|
657
|
+
oldPartDefined.totalBalance,
|
|
658
|
+
newPartDefined.totalBalance,
|
|
659
|
+
"totalBalance",
|
|
660
|
+
conditionType
|
|
661
|
+
);
|
|
662
|
+
}
|
|
663
|
+
}
|
|
664
|
+
).exhaustive();
|
|
665
|
+
});
|
|
666
|
+
issues.push(
|
|
667
|
+
...conditionComparator(oldCondition, newCondition).map((message) => ({
|
|
668
|
+
path: [...basePath],
|
|
669
|
+
message
|
|
670
|
+
}))
|
|
671
|
+
);
|
|
672
|
+
return issues;
|
|
673
|
+
};
|
|
674
|
+
var verifyEntryBackCompat = (oldEntry, newEntry, basePath) => {
|
|
675
|
+
const issues = [];
|
|
676
|
+
const flag = (path, message) => {
|
|
677
|
+
const prefix = (oldEntry.typeVersion ?? 1) === 1 ? `Entry type '${oldEntry.type}'` : `Entry type '${oldEntry.type}' version ${oldEntry.typeVersion}`;
|
|
678
|
+
issues.push({
|
|
679
|
+
path: [...basePath, ...path],
|
|
680
|
+
message: `${prefix} ${message}`
|
|
681
|
+
});
|
|
682
|
+
};
|
|
683
|
+
const oldRuntimeParameters = new Set(getSchemaObjectParameters(oldEntry));
|
|
684
|
+
const newRuntimeParameters = new Set(getSchemaObjectParameters(newEntry));
|
|
685
|
+
newRuntimeParameters.forEach((param) => {
|
|
686
|
+
if (!oldRuntimeParameters.has(param)) {
|
|
687
|
+
flag([], `new runtime parameter added: '${param}'.`);
|
|
688
|
+
}
|
|
689
|
+
});
|
|
690
|
+
if (oldEntry.description !== newEntry.description) {
|
|
691
|
+
flag(
|
|
692
|
+
["description"],
|
|
693
|
+
`description changed from '${oldEntry.description}' to '${newEntry.description}'.`
|
|
694
|
+
);
|
|
695
|
+
}
|
|
696
|
+
const oldStaticParameters = new Map(
|
|
697
|
+
Object.entries(oldEntry.parameters ?? {})
|
|
698
|
+
);
|
|
699
|
+
const newStaticParameters = new Map(
|
|
700
|
+
Object.entries(newEntry.parameters ?? {})
|
|
701
|
+
);
|
|
702
|
+
oldStaticParameters.forEach((oldValue, oldKey) => {
|
|
703
|
+
if (!newStaticParameters.has(oldKey)) {
|
|
704
|
+
flag(["parameters"], `static parameter '${oldKey}' removed.`);
|
|
705
|
+
} else if (newStaticParameters.get(oldKey) !== oldValue) {
|
|
706
|
+
flag(
|
|
707
|
+
["parameters", oldKey],
|
|
708
|
+
`static parameter '${oldKey}' changed from '${oldValue}' to '${newStaticParameters.get(
|
|
709
|
+
oldKey
|
|
710
|
+
)}'.`
|
|
711
|
+
);
|
|
712
|
+
}
|
|
713
|
+
});
|
|
714
|
+
newStaticParameters.forEach((newValue, newKey) => {
|
|
715
|
+
if (!oldStaticParameters.has(newKey)) {
|
|
716
|
+
flag(["parameters", newKey], `static parameter '${newKey}' added.`);
|
|
717
|
+
}
|
|
718
|
+
});
|
|
719
|
+
{
|
|
720
|
+
const oldLines = oldEntry.lines ?? [];
|
|
721
|
+
const newLines = newEntry.lines ?? [];
|
|
722
|
+
if (oldLines.length !== newLines.length) {
|
|
723
|
+
flag(
|
|
724
|
+
["lines"],
|
|
725
|
+
`number of lines changed from ${oldLines.length} to ${newLines.length}.`
|
|
726
|
+
);
|
|
727
|
+
}
|
|
728
|
+
const oldLinesByKey = /* @__PURE__ */ new Map();
|
|
729
|
+
oldLines.forEach((line) => {
|
|
730
|
+
oldLinesByKey.set(line.key, line);
|
|
731
|
+
});
|
|
732
|
+
newLines.forEach((line, idx) => {
|
|
733
|
+
const oldLine = oldLinesByKey.get(line.key);
|
|
734
|
+
if (!oldLine) {
|
|
735
|
+
flag(["lines", idx], `line with key '${line.key}' added.`);
|
|
736
|
+
return;
|
|
737
|
+
}
|
|
738
|
+
issues.push(
|
|
739
|
+
...verifyLineBackCompat(oldLine, line, [...basePath, "lines", idx])
|
|
740
|
+
);
|
|
741
|
+
});
|
|
742
|
+
}
|
|
743
|
+
const oldTags = new Set((oldEntry.tags ?? []).map((tag) => (0, import_object_hash.default)(tag)));
|
|
744
|
+
const newTags = new Set((newEntry.tags ?? []).map((tag) => (0, import_object_hash.default)(tag)));
|
|
745
|
+
if (!areSetsEqual(oldTags, newTags)) {
|
|
746
|
+
flag(["tags"], `tags changed.`);
|
|
747
|
+
}
|
|
748
|
+
const oldGroups = new Set(
|
|
749
|
+
(oldEntry.groups ?? []).map((group) => (0, import_object_hash.default)(group))
|
|
750
|
+
);
|
|
751
|
+
const newGroups = new Set(
|
|
752
|
+
(newEntry.groups ?? []).map((group) => (0, import_object_hash.default)(group))
|
|
753
|
+
);
|
|
754
|
+
if (!areSetsEqual(oldGroups, newGroups)) {
|
|
755
|
+
flag(["groups"], `groups changed.`);
|
|
756
|
+
}
|
|
757
|
+
{
|
|
758
|
+
const oldConditions = oldEntry.conditions ?? [];
|
|
759
|
+
const newConditions = newEntry.conditions ?? [];
|
|
760
|
+
if (oldConditions.length !== newConditions.length) {
|
|
761
|
+
flag(
|
|
762
|
+
["conditions"],
|
|
763
|
+
`number of conditions changed from ${oldConditions.length} to ${newConditions.length}.`
|
|
764
|
+
);
|
|
765
|
+
}
|
|
766
|
+
const maxLength = Math.max(oldConditions.length, newConditions.length);
|
|
767
|
+
for (let idx = 0; idx < maxLength; idx++) {
|
|
768
|
+
const oldCondition = oldConditions[idx];
|
|
769
|
+
const newCondition = newConditions[idx];
|
|
770
|
+
if (!oldCondition && newCondition) {
|
|
771
|
+
flag(["conditions", idx], `Condition at index ${idx} added.`);
|
|
772
|
+
} else if (oldCondition && !newCondition) {
|
|
773
|
+
flag(["conditions", idx], `Condition at index ${idx} removed.`);
|
|
774
|
+
} else if (oldCondition && newCondition) {
|
|
775
|
+
issues.push(
|
|
776
|
+
...verifyConditionBackCompat(oldCondition, newCondition, [
|
|
777
|
+
...basePath,
|
|
778
|
+
"conditions",
|
|
779
|
+
idx
|
|
780
|
+
])
|
|
781
|
+
);
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
return issues;
|
|
786
|
+
};
|
|
787
|
+
var verifyDeprecationBackCompat = (oldEntry, newEntry, oldSchemaTimestamp, basePath) => {
|
|
788
|
+
const issues = [];
|
|
789
|
+
const shouldSkipTimestampCheck = process.env.DANGEROUSLY_SKIP_DEPRECATION_TIMESTAMP_CHECK === "true" && process.env.NODE_ENV === "test";
|
|
790
|
+
if (newEntry.status === "archived" && oldEntry.status !== "archived") {
|
|
791
|
+
if (!oldEntry || oldEntry.status !== "disabled") {
|
|
792
|
+
issues.push({
|
|
793
|
+
path: [...basePath, "status"],
|
|
794
|
+
message: `Entry type '${newEntry.type}' version ${newEntry.typeVersion ?? 1} cannot be set to archived status without first being disabled for at least ${MIN_SCHEMA_LEDGER_ENTRY_DISABLED_DURATION_SECONDS} seconds.`
|
|
795
|
+
});
|
|
796
|
+
return issues;
|
|
797
|
+
}
|
|
798
|
+
if (oldSchemaTimestamp && !shouldSkipTimestampCheck) {
|
|
799
|
+
const currentTime = /* @__PURE__ */ new Date();
|
|
800
|
+
const schemaTime = new Date(oldSchemaTimestamp);
|
|
801
|
+
if (Number.isNaN(schemaTime.getTime()) || schemaTime > currentTime) {
|
|
802
|
+
issues.push({
|
|
803
|
+
path: [...basePath, "status"],
|
|
804
|
+
message: `Entry type '${newEntry.type}' version ${newEntry.typeVersion ?? 1} cannot be set to archived status. Invalid schema timestamp detected.`
|
|
805
|
+
});
|
|
806
|
+
return issues;
|
|
807
|
+
}
|
|
808
|
+
const timeSinceSchemaUpdate = (currentTime.getTime() - schemaTime.getTime()) / 1e3;
|
|
809
|
+
if (timeSinceSchemaUpdate < MIN_SCHEMA_LEDGER_ENTRY_DISABLED_DURATION_SECONDS) {
|
|
810
|
+
issues.push({
|
|
811
|
+
path: [...basePath, "status"],
|
|
812
|
+
message: `Entry type '${newEntry.type}' version ${newEntry.typeVersion ?? 1} cannot be set to archived status. It must first remain disabled for at least 45 seconds (currently ${Math.round(
|
|
813
|
+
timeSinceSchemaUpdate
|
|
814
|
+
)} seconds).`
|
|
815
|
+
});
|
|
816
|
+
return issues;
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
}
|
|
820
|
+
return issues;
|
|
821
|
+
};
|
|
822
|
+
var entryTypeIdentifier = (entryType, version) => `type:${entryType}:version:${version ?? "1"}`;
|
|
823
|
+
var verifyEntriesBackCompat = (oldEntries, newEntries, basePath, oldSchemaTimestamp) => {
|
|
824
|
+
const issues = [];
|
|
825
|
+
const oldEntriesByKey = /* @__PURE__ */ new Map();
|
|
826
|
+
oldEntries.forEach((entry) => {
|
|
827
|
+
oldEntriesByKey.set(
|
|
828
|
+
entryTypeIdentifier(entry.type, entry.typeVersion),
|
|
829
|
+
entry
|
|
830
|
+
);
|
|
831
|
+
});
|
|
832
|
+
const newEntriesByKey = /* @__PURE__ */ new Map();
|
|
833
|
+
newEntries.forEach((entry) => {
|
|
834
|
+
newEntriesByKey.set(
|
|
835
|
+
entryTypeIdentifier(entry.type, entry.typeVersion),
|
|
836
|
+
entry
|
|
837
|
+
);
|
|
838
|
+
});
|
|
839
|
+
oldEntries.forEach((oldEntry) => {
|
|
840
|
+
if (!newEntriesByKey.has(
|
|
841
|
+
entryTypeIdentifier(oldEntry.type, oldEntry.typeVersion)
|
|
842
|
+
)) {
|
|
843
|
+
issues.push({
|
|
844
|
+
path: [...basePath],
|
|
845
|
+
message: `Entry type '${oldEntry.type}' version ${oldEntry.typeVersion ?? 1} removed.`
|
|
846
|
+
});
|
|
847
|
+
}
|
|
848
|
+
});
|
|
849
|
+
newEntries.forEach((newEntry, idx) => {
|
|
850
|
+
const oldEntry = oldEntriesByKey.get(
|
|
851
|
+
entryTypeIdentifier(newEntry.type, newEntry.typeVersion)
|
|
852
|
+
);
|
|
853
|
+
if (!oldEntry) {
|
|
854
|
+
return;
|
|
855
|
+
}
|
|
856
|
+
issues.push(
|
|
857
|
+
...verifyEntryBackCompat(oldEntry, newEntry, [...basePath, idx])
|
|
858
|
+
);
|
|
859
|
+
if (newEntry.status === "archived") {
|
|
860
|
+
const deprecationIssues = verifyDeprecationBackCompat(
|
|
861
|
+
oldEntry,
|
|
862
|
+
newEntry,
|
|
863
|
+
oldSchemaTimestamp,
|
|
864
|
+
[...basePath, idx]
|
|
865
|
+
);
|
|
866
|
+
issues.push(...deprecationIssues);
|
|
867
|
+
}
|
|
868
|
+
});
|
|
869
|
+
return issues;
|
|
870
|
+
};
|
|
871
|
+
|
|
872
|
+
// ../../libs/schema-validation/utils/backcompat/payments.ts
|
|
873
|
+
init_cjs_shims();
|
|
874
|
+
var normalize = (value) => JSON.parse(JSON.stringify(value));
|
|
875
|
+
var verifyAccountingBackCompat = (oldType, newType, basePath) => Object.values(PaymentAccountingEventKey).flatMap(
|
|
876
|
+
(event) => isEqual_default(oldType.accounting[event], newType.accounting[event]) ? [] : [
|
|
877
|
+
{
|
|
878
|
+
path: [...basePath, "accounting", event],
|
|
879
|
+
message: `accounting entry '${event}' changed.`
|
|
880
|
+
}
|
|
881
|
+
]
|
|
882
|
+
);
|
|
883
|
+
var paymentTypePolicies = {
|
|
884
|
+
type: {
|
|
885
|
+
kind: "compare",
|
|
886
|
+
checks: { serializer: (paymentType) => paymentType.type, name: "type" }
|
|
887
|
+
},
|
|
888
|
+
typeVersion: {
|
|
889
|
+
kind: "compare",
|
|
890
|
+
checks: {
|
|
891
|
+
serializer: (paymentType) => paymentType.typeVersion,
|
|
892
|
+
name: "typeVersion"
|
|
893
|
+
}
|
|
894
|
+
},
|
|
895
|
+
status: {
|
|
896
|
+
kind: "compare",
|
|
897
|
+
checks: { serializer: (paymentType) => paymentType.status, name: "status" }
|
|
898
|
+
},
|
|
899
|
+
payment: {
|
|
900
|
+
kind: "compare",
|
|
901
|
+
checks: {
|
|
902
|
+
amount: {
|
|
903
|
+
serializer: (paymentType) => paymentType.payment.amount,
|
|
904
|
+
name: "payment.amount"
|
|
905
|
+
},
|
|
906
|
+
direction: {
|
|
907
|
+
serializer: (paymentType) => paymentType.payment.direction,
|
|
908
|
+
name: "payment.direction"
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
},
|
|
912
|
+
accounting: { kind: "custom", check: verifyAccountingBackCompat }
|
|
913
|
+
};
|
|
914
|
+
var paymentTypeCheckers = Object.values(
|
|
915
|
+
paymentTypePolicies
|
|
916
|
+
).map(
|
|
917
|
+
(policy) => z(policy).returnType().with({ kind: "ignored" }, () => () => []).with({ kind: "compare" }, ({ checks }) => {
|
|
918
|
+
const comparator = createComparator(flattenChecks(checks));
|
|
919
|
+
return (oldType, newType, basePath) => comparator(oldType, newType).map((message) => ({
|
|
920
|
+
path: [...basePath],
|
|
921
|
+
message
|
|
922
|
+
}));
|
|
923
|
+
}).with({ kind: "custom" }, ({ check }) => check).exhaustive()
|
|
924
|
+
);
|
|
925
|
+
var paymentTypeIdentifier = (paymentType) => `type:${paymentType.type}:version:${paymentType.typeVersion}`;
|
|
926
|
+
var verifyPaymentTypeBackCompat = (oldType, newType, basePath) => paymentTypeCheckers.flatMap(
|
|
927
|
+
(checker) => checker(oldType, newType, basePath).map(({ path, message }) => ({
|
|
928
|
+
path,
|
|
929
|
+
message: `Payment type '${oldType.type}' version ${oldType.typeVersion}: ${message}`
|
|
930
|
+
}))
|
|
931
|
+
);
|
|
932
|
+
var verifyPaymentsBackCompat = (unnormalizedOldPayments, unnormalizedNewPayments, basePath) => {
|
|
933
|
+
const oldTypes = normalize(unnormalizedOldPayments?.types ?? []);
|
|
934
|
+
const newTypes = normalize(unnormalizedNewPayments?.types ?? []);
|
|
935
|
+
const issues = [];
|
|
936
|
+
const oldTypesByKey = new Map(
|
|
937
|
+
oldTypes.map((paymentType) => [
|
|
938
|
+
paymentTypeIdentifier(paymentType),
|
|
939
|
+
paymentType
|
|
940
|
+
])
|
|
941
|
+
);
|
|
942
|
+
const newTypesByKey = new Map(
|
|
943
|
+
newTypes.map((paymentType) => [
|
|
944
|
+
paymentTypeIdentifier(paymentType),
|
|
945
|
+
paymentType
|
|
946
|
+
])
|
|
947
|
+
);
|
|
948
|
+
oldTypes.forEach((oldType) => {
|
|
949
|
+
if (!newTypesByKey.has(paymentTypeIdentifier(oldType))) {
|
|
950
|
+
issues.push({
|
|
951
|
+
path: [...basePath],
|
|
952
|
+
message: `Payment type '${oldType.type}' version ${oldType.typeVersion} removed.`
|
|
953
|
+
});
|
|
954
|
+
}
|
|
955
|
+
});
|
|
956
|
+
newTypes.forEach((newType, idx) => {
|
|
957
|
+
const oldType = oldTypesByKey.get(paymentTypeIdentifier(newType));
|
|
958
|
+
if (!oldType) {
|
|
959
|
+
return;
|
|
960
|
+
}
|
|
961
|
+
issues.push(
|
|
962
|
+
...verifyPaymentTypeBackCompat(oldType, newType, [...basePath, idx])
|
|
963
|
+
);
|
|
964
|
+
});
|
|
965
|
+
return issues;
|
|
966
|
+
};
|
|
967
|
+
|
|
968
|
+
// ../../libs/schema-validation/utils/backcompat/verifySchemaBackCompat.ts
|
|
969
|
+
var isSchemaInput = (schema) => {
|
|
970
|
+
return schema.key !== void 0;
|
|
971
|
+
};
|
|
972
|
+
var encodePath = (path) => path.map((part, idx) => {
|
|
973
|
+
if (idx === 0) {
|
|
974
|
+
return part;
|
|
975
|
+
}
|
|
976
|
+
if (typeof part === "number") {
|
|
977
|
+
return `[${part}]`;
|
|
978
|
+
}
|
|
979
|
+
if (typeof part === "string" && /^[a-zA-Z_][a-zA-Z0-9_]*$/.test(part)) {
|
|
980
|
+
return `.${part}`;
|
|
981
|
+
}
|
|
982
|
+
return `[${JSON.stringify(part)}]`;
|
|
983
|
+
}).join("");
|
|
984
|
+
var isValidAccountStatusTransition = (oldStatus, newStatus) => {
|
|
985
|
+
if (oldStatus === newStatus) {
|
|
986
|
+
return true;
|
|
987
|
+
}
|
|
988
|
+
return VALID_LEDGER_ACCOUNT_STATUS_TRANSITIONS[oldStatus]?.includes(newStatus) ?? false;
|
|
989
|
+
};
|
|
990
|
+
var verifyCoaSchemaBackCompat = ({
|
|
991
|
+
oldSchema,
|
|
992
|
+
newSchema
|
|
993
|
+
}) => {
|
|
994
|
+
const oldCoa = ChartOfAccounts.parse(oldSchema.chartOfAccounts);
|
|
995
|
+
const newCoa = parseWithError(
|
|
996
|
+
ChartOfAccounts,
|
|
997
|
+
newSchema.chartOfAccounts,
|
|
998
|
+
BadRequestError,
|
|
999
|
+
{
|
|
1000
|
+
message: "Invalid schema provided"
|
|
1001
|
+
}
|
|
1002
|
+
);
|
|
1003
|
+
assert_default(
|
|
1004
|
+
newCoa.defaultCurrency?.code === oldCoa.defaultCurrency?.code && newCoa.defaultCurrency?.customCurrencyId === oldCoa.defaultCurrency?.customCurrencyId,
|
|
1005
|
+
BadRequestError,
|
|
1006
|
+
{
|
|
1007
|
+
message: `Changing defaultCurrency is backwards-incompatible.`
|
|
1008
|
+
}
|
|
1009
|
+
);
|
|
1010
|
+
assert_default(
|
|
1011
|
+
newCoa.defaultCurrencyMode === oldCoa.defaultCurrencyMode,
|
|
1012
|
+
BadRequestError,
|
|
1013
|
+
{
|
|
1014
|
+
message: `Changing defaultCurrencyMode is backwards-incompatible.`
|
|
1015
|
+
}
|
|
1016
|
+
);
|
|
1017
|
+
const oldAccountPaths = [];
|
|
1018
|
+
const oldAccountPathToAccount = /* @__PURE__ */ new Map();
|
|
1019
|
+
const newAccountPaths = [];
|
|
1020
|
+
const newAccountPathToAccount = /* @__PURE__ */ new Map();
|
|
1021
|
+
const walkAccounts = (account, accountPaths, accountPathToAccount, path) => {
|
|
1022
|
+
const newPath = path ? `${path}/${account.key}` : account.key;
|
|
1023
|
+
accountPaths.push(newPath);
|
|
1024
|
+
assert_default(account.type, BadRequestError, {
|
|
1025
|
+
message: `Account type not provided for ${account.type}`
|
|
1026
|
+
});
|
|
1027
|
+
accountPathToAccount.set(newPath, account);
|
|
1028
|
+
account.children?.forEach(
|
|
1029
|
+
(child) => walkAccounts(child, accountPaths, accountPathToAccount, newPath)
|
|
1030
|
+
);
|
|
1031
|
+
};
|
|
1032
|
+
oldCoa.accounts.forEach(
|
|
1033
|
+
(account) => walkAccounts(account, oldAccountPaths, oldAccountPathToAccount)
|
|
1034
|
+
);
|
|
1035
|
+
newCoa.accounts.forEach(
|
|
1036
|
+
(account) => walkAccounts(account, newAccountPaths, newAccountPathToAccount)
|
|
1037
|
+
);
|
|
1038
|
+
const accountsRemoved = oldAccountPaths.filter(
|
|
1039
|
+
(path) => !newAccountPaths.includes(path)
|
|
1040
|
+
);
|
|
1041
|
+
assert_default(accountsRemoved.length === 0, BadRequestError, {
|
|
1042
|
+
message: `Cannot delete accounts in a schema update. You removed accounts with these paths: [${accountsRemoved.join(
|
|
1043
|
+
", "
|
|
1044
|
+
)}]`,
|
|
1045
|
+
info: {
|
|
1046
|
+
accountsRemoved
|
|
1047
|
+
}
|
|
1048
|
+
});
|
|
1049
|
+
const schemaUpgrades = /* @__PURE__ */ new Map();
|
|
1050
|
+
oldAccountPaths.forEach((path) => {
|
|
1051
|
+
const oldAccount = oldAccountPathToAccount.get(path);
|
|
1052
|
+
const newAccount = newAccountPathToAccount.get(path);
|
|
1053
|
+
assert_default(oldAccount, InternalError, {
|
|
1054
|
+
message: `Account with path ${path} not found in cache`
|
|
1055
|
+
});
|
|
1056
|
+
assert_default(newAccount, InternalError, {
|
|
1057
|
+
message: `Account with path ${path} not found in cache`
|
|
1058
|
+
});
|
|
1059
|
+
assert_default(oldAccount.type === newAccount.type, BadRequestError, {
|
|
1060
|
+
message: `Cannot change account type from ${oldAccount.type} to ${newAccount.type} (path: ${path}).`
|
|
1061
|
+
});
|
|
1062
|
+
assert_default(
|
|
1063
|
+
isEqual_default(oldAccount.linkedAccount, newAccount.linkedAccount),
|
|
1064
|
+
BadRequestError,
|
|
1065
|
+
{
|
|
1066
|
+
message: `Cannot change linked account property on account (path: ${path}).`
|
|
1067
|
+
}
|
|
1068
|
+
);
|
|
1069
|
+
assert_default(isEqual_default(oldAccount.payment, newAccount.payment), BadRequestError, {
|
|
1070
|
+
message: `Cannot change payment property on account (path: ${path}).`
|
|
1071
|
+
});
|
|
1072
|
+
const oldTemplate = oldAccount.template;
|
|
1073
|
+
const newTemplate = newAccount.template;
|
|
1074
|
+
const isTemplateChangeValid = oldTemplate === newTemplate || oldTemplate === void 0 && newTemplate === false || oldTemplate === false && newTemplate === void 0;
|
|
1075
|
+
assert_default(isTemplateChangeValid, BadRequestError, {
|
|
1076
|
+
message: `Cannot change template property from ${oldTemplate} to ${newTemplate} on account (path: ${path}).`
|
|
1077
|
+
});
|
|
1078
|
+
const normalizedOldClearing = oldAccount.clearing ?? false;
|
|
1079
|
+
const normalizedNewClearing = newAccount.clearing ?? false;
|
|
1080
|
+
if (!normalizedOldClearing && normalizedNewClearing) {
|
|
1081
|
+
assert_default(false, BadRequestError, {
|
|
1082
|
+
message: `Cannot change clearing property on active account (path: ${path}).`
|
|
1083
|
+
});
|
|
1084
|
+
}
|
|
1085
|
+
if (normalizedOldClearing && !normalizedNewClearing) {
|
|
1086
|
+
assert_default(false, BadRequestError, {
|
|
1087
|
+
message: `Cannot change clearing property on active account (path: ${path}).`
|
|
1088
|
+
});
|
|
1089
|
+
}
|
|
1090
|
+
const oldStatus = getAccountStatus(oldAccount);
|
|
1091
|
+
const newStatus = getAccountStatus(newAccount);
|
|
1092
|
+
assert_default(
|
|
1093
|
+
isValidAccountStatusTransition(oldStatus, newStatus),
|
|
1094
|
+
BadRequestError,
|
|
1095
|
+
{
|
|
1096
|
+
message: `Invalid account status transition from ${oldStatus} to ${newStatus} (path: ${path}). Valid transitions: active\u2192disabled, disabled\u2192archived, disabled\u2192active, archived\u2192active.`
|
|
1097
|
+
}
|
|
1098
|
+
);
|
|
1099
|
+
if (oldStatus !== newStatus) {
|
|
1100
|
+
const accountUpgrade = z(newStatus).returnType().with("active", () => "toActiveStatus").with("disabled", () => "toDisabledStatus").with("archived", () => "toArchivedStatus").exhaustive();
|
|
1101
|
+
schemaUpgrades.set(accountUpgrade, [
|
|
1102
|
+
...schemaUpgrades.get(accountUpgrade) ?? [],
|
|
1103
|
+
path
|
|
1104
|
+
]);
|
|
1105
|
+
}
|
|
1106
|
+
if (oldAccount.currencyMode === "single" && newAccount.currencyMode === "multi") {
|
|
1107
|
+
schemaUpgrades.set("singleCurrencyToMultiCurrency", [
|
|
1108
|
+
...schemaUpgrades.get("singleCurrencyToMultiCurrency") ?? [],
|
|
1109
|
+
path
|
|
1110
|
+
]);
|
|
1111
|
+
} else {
|
|
1112
|
+
assert_default(
|
|
1113
|
+
oldAccount.currencyMode === newAccount.currencyMode,
|
|
1114
|
+
BadRequestError,
|
|
1115
|
+
{
|
|
1116
|
+
message: `Cannot change account currency mode from ${oldAccount.currencyMode} to ${newAccount.currencyMode} (path: ${path}).`
|
|
1117
|
+
}
|
|
1118
|
+
);
|
|
1119
|
+
assert_default(
|
|
1120
|
+
oldAccount.currency?.code === newAccount.currency?.code,
|
|
1121
|
+
BadRequestError,
|
|
1122
|
+
{
|
|
1123
|
+
message: `Cannot change account currency code from ${oldAccount.currency?.code} to ${newAccount.currency?.code} (path: ${path}).`
|
|
1124
|
+
}
|
|
1125
|
+
);
|
|
1126
|
+
assert_default(
|
|
1127
|
+
oldAccount.currency?.customCurrencyId === newAccount.currency?.customCurrencyId,
|
|
1128
|
+
BadRequestError,
|
|
1129
|
+
{
|
|
1130
|
+
message: `Cannot change account custom currency id from ${oldAccount.currency?.customCurrencyId} to ${newAccount.currency?.customCurrencyId} (path: ${path}).`
|
|
1131
|
+
}
|
|
1132
|
+
);
|
|
1133
|
+
}
|
|
1134
|
+
});
|
|
1135
|
+
return schemaUpgrades;
|
|
1136
|
+
};
|
|
1137
|
+
var verifyTypedEntriesBackCompat = ({
|
|
1138
|
+
oldSchema: unvalidatedOldSchema,
|
|
1139
|
+
newSchema: unvalidatedNewSchema
|
|
1140
|
+
}) => {
|
|
1141
|
+
const basePath = ["ledgerEntries", "types"];
|
|
1142
|
+
const newSchema = isSchemaInput(unvalidatedNewSchema) ? validateSchema(unvalidatedNewSchema) : unvalidatedNewSchema;
|
|
1143
|
+
const oldSchema = isSchemaInput(unvalidatedOldSchema) ? validateSchema(unvalidatedOldSchema) : unvalidatedOldSchema;
|
|
1144
|
+
const oldEntries = oldSchema.ledgerEntries?.types ?? [];
|
|
1145
|
+
const newEntries = newSchema.ledgerEntries?.types ?? [];
|
|
1146
|
+
let oldSchemaTimestamp;
|
|
1147
|
+
if (!isSchemaInput(unvalidatedOldSchema)) {
|
|
1148
|
+
if ("created" in unvalidatedOldSchema && "modified" in unvalidatedOldSchema) {
|
|
1149
|
+
oldSchemaTimestamp = unvalidatedOldSchema.modified || unvalidatedOldSchema.created;
|
|
1150
|
+
}
|
|
1151
|
+
}
|
|
1152
|
+
const issues = verifyEntriesBackCompat(
|
|
1153
|
+
oldEntries,
|
|
1154
|
+
newEntries,
|
|
1155
|
+
basePath,
|
|
1156
|
+
oldSchemaTimestamp
|
|
1157
|
+
);
|
|
1158
|
+
assert_default(issues.length === 0, BadRequestError, {
|
|
1159
|
+
message: `The following backwards-incompatible Ledger Entry changes were detected:
|
|
1160
|
+
${issues.map((issue) => `At ${encodePath(issue.path)}: ${issue.message}`).join("\n")}`
|
|
1161
|
+
});
|
|
1162
|
+
};
|
|
1163
|
+
var verifyPaymentTypesBackCompat = ({
|
|
1164
|
+
oldSchema: unvalidatedOldSchema,
|
|
1165
|
+
newSchema: unvalidatedNewSchema
|
|
1166
|
+
}) => {
|
|
1167
|
+
const basePath = ["payments", "types"];
|
|
1168
|
+
const newSchema = isSchemaInput(unvalidatedNewSchema) ? validateSchema(unvalidatedNewSchema) : unvalidatedNewSchema;
|
|
1169
|
+
const oldSchema = isSchemaInput(unvalidatedOldSchema) ? validateSchema(unvalidatedOldSchema) : unvalidatedOldSchema;
|
|
1170
|
+
const issues = verifyPaymentsBackCompat(
|
|
1171
|
+
oldSchema.payments,
|
|
1172
|
+
newSchema.payments,
|
|
1173
|
+
basePath
|
|
1174
|
+
);
|
|
1175
|
+
assert_default(issues.length === 0, BadRequestError, {
|
|
1176
|
+
message: `The following backwards-incompatible Payment Type changes were detected:
|
|
1177
|
+
${issues.map((issue) => `At ${encodePath(issue.path)}: ${issue.message}`).join("\n")}`
|
|
1178
|
+
});
|
|
1179
|
+
};
|
|
1180
|
+
var verifySchemaBackCompat = ({
|
|
1181
|
+
oldSchema,
|
|
1182
|
+
newSchema
|
|
1183
|
+
}) => {
|
|
1184
|
+
if (!oldSchema) {
|
|
1185
|
+
return {
|
|
1186
|
+
backwardsCompatible: true,
|
|
1187
|
+
schemaUpgrades: /* @__PURE__ */ new Map()
|
|
1188
|
+
};
|
|
1189
|
+
}
|
|
1190
|
+
let newSchemaKey;
|
|
1191
|
+
if (isSchemaInput(newSchema)) {
|
|
1192
|
+
newSchemaKey = newSchema.key;
|
|
1193
|
+
} else {
|
|
1194
|
+
newSchemaKey = newSchema.schemaKey;
|
|
1195
|
+
}
|
|
1196
|
+
assert_default(oldSchema.schemaKey === newSchemaKey, BadRequestError, {
|
|
1197
|
+
message: `New schema key ${newSchemaKey} must match old key ${oldSchema.schemaKey}`
|
|
1198
|
+
});
|
|
1199
|
+
const schemaUpgrades = verifyCoaSchemaBackCompat({ oldSchema, newSchema });
|
|
1200
|
+
verifyTypedEntriesBackCompat({ oldSchema, newSchema });
|
|
1201
|
+
verifyPaymentTypesBackCompat({ oldSchema, newSchema });
|
|
1202
|
+
return {
|
|
1203
|
+
backwardsCompatible: true,
|
|
1204
|
+
schemaUpgrades
|
|
1205
|
+
};
|
|
1206
|
+
};
|
|
1207
|
+
|
|
1208
|
+
// ../../libs/schema-validation/utils/backcompat/evaluateDeployBackCompat.ts
|
|
1209
|
+
var evaluateDeployBackCompat = ({
|
|
1210
|
+
oldSchema,
|
|
1211
|
+
newSchema,
|
|
1212
|
+
hasLedgers
|
|
1213
|
+
}) => {
|
|
1214
|
+
if (!oldSchema || !hasLedgers) {
|
|
1215
|
+
return { backwardsCompatible: true, message: null };
|
|
1216
|
+
}
|
|
1217
|
+
try {
|
|
1218
|
+
verifySchemaBackCompat({ oldSchema, newSchema });
|
|
1219
|
+
return { backwardsCompatible: true, message: null };
|
|
1220
|
+
} catch (e) {
|
|
1221
|
+
if (e instanceof BadRequestError) {
|
|
1222
|
+
return { backwardsCompatible: false, message: e.message };
|
|
1223
|
+
}
|
|
1224
|
+
throw e;
|
|
1225
|
+
}
|
|
1226
|
+
};
|
|
1227
|
+
|
|
1228
|
+
// src/utils/schemaBackCompat.ts
|
|
1229
|
+
var BackCompatCheckError = class extends Error {
|
|
1230
|
+
};
|
|
1231
|
+
var ComparisonSchemaError = class extends BackCompatCheckError {
|
|
1232
|
+
constructor() {
|
|
1233
|
+
super(...arguments);
|
|
1234
|
+
this.jsonType = "comparison_schema_error";
|
|
1235
|
+
}
|
|
1236
|
+
};
|
|
1237
|
+
var BackCompatError = class extends BackCompatCheckError {
|
|
1238
|
+
constructor() {
|
|
1239
|
+
super(...arguments);
|
|
1240
|
+
this.jsonType = "backcompat_error";
|
|
1241
|
+
}
|
|
1242
|
+
};
|
|
1243
|
+
var verifySchemaAgainstFile = ({
|
|
1244
|
+
command,
|
|
1245
|
+
schema,
|
|
1246
|
+
againstPath,
|
|
1247
|
+
requireEnvVariables
|
|
1248
|
+
}) => {
|
|
1249
|
+
const [oldSchema, parseError] = parseJSON(
|
|
1250
|
+
getParsedSchemaString({
|
|
1251
|
+
command,
|
|
1252
|
+
schemaPath: againstPath,
|
|
1253
|
+
silenceNonErrorLogging: true,
|
|
1254
|
+
requireEnvVariables
|
|
1255
|
+
})
|
|
1256
|
+
);
|
|
1257
|
+
if (parseError) {
|
|
1258
|
+
throw new ComparisonSchemaError(
|
|
1259
|
+
`Failed to parse ${againstPath}: ${parseError.message}`
|
|
1260
|
+
);
|
|
1261
|
+
}
|
|
1262
|
+
try {
|
|
1263
|
+
validateSchemaStructure(oldSchema);
|
|
1264
|
+
} catch {
|
|
1265
|
+
throw new ComparisonSchemaError(
|
|
1266
|
+
`${againstPath} is not a valid schema, so it cannot be compared.`
|
|
1267
|
+
);
|
|
1268
|
+
}
|
|
1269
|
+
const { backwardsCompatible, message } = evaluateDeployBackCompat({
|
|
1270
|
+
oldSchema: { ...oldSchema, schemaKey: oldSchema.key },
|
|
1271
|
+
newSchema: schema,
|
|
1272
|
+
hasLedgers: true
|
|
1273
|
+
});
|
|
1274
|
+
if (!backwardsCompatible) {
|
|
1275
|
+
throw new BackCompatError(
|
|
1276
|
+
`Schema is not backwards-compatible with ${againstPath}.
|
|
1277
|
+
${message}`
|
|
1278
|
+
);
|
|
1279
|
+
}
|
|
1280
|
+
};
|
|
1281
|
+
|
|
1282
|
+
export {
|
|
1283
|
+
BackCompatCheckError,
|
|
1284
|
+
ComparisonSchemaError,
|
|
1285
|
+
BackCompatError,
|
|
1286
|
+
verifySchemaAgainstFile
|
|
1287
|
+
};
|