@malloy-publisher/server 0.0.188 → 0.0.382-dev
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/dist/app/api-doc.yaml +423 -60
- package/dist/app/assets/{HomePage-DsuUvSI_.js → HomePage-Dn3E4CuB.js} +1 -1
- package/dist/app/assets/{MainPage-DHWFkEN6.js → MainPage-BzB3yoqi.js} +1 -1
- package/dist/app/assets/{ModelPage-DNwcx1nE.js → ModelPage-C9O_sAXT.js} +1 -1
- package/dist/app/assets/{PackagePage-DSgz9G2V.js → PackagePage-DcxKEjBX.js} +1 -1
- package/dist/app/assets/{ProjectPage-CSdPosLV.js → ProjectPage-BDj307rF.js} +1 -1
- package/dist/app/assets/{RouteError-orw1RX8q.js → RouteError-DAShbVCG.js} +1 -1
- package/dist/app/assets/{WorkbookPage-Bp-BpGjL.js → WorkbookPage-Cs_XYEaB.js} +1 -1
- package/dist/app/assets/{core-B4ZYB7aS.es-8Zh0TkSr.js → core-CjeTkq8O.es-BqRc6yhC.js} +1 -1
- package/dist/app/assets/{index-BL2TJgTw.js → index-15BOvhp0.js} +4 -4
- package/dist/app/assets/{index-BWJkzsfl.js → index-Bb2jqquW.js} +1 -1
- package/dist/app/assets/{index-BefdHHMa.js → index-D68X76-7.js} +1 -1
- package/dist/app/assets/{index.umd-lY-87l4L.js → index.umd-DGBekgSu.js} +1 -1
- package/dist/app/index.html +1 -1
- package/dist/instrumentation.js +98 -77
- package/dist/server.js +1834 -450
- package/package.json +5 -3
- package/src/controller/connection.controller.ts +27 -20
- package/src/controller/manifest.controller.ts +29 -0
- package/src/controller/materialization.controller.ts +125 -0
- package/src/controller/model.controller.ts +0 -2
- package/src/controller/package.controller.ts +53 -2
- package/src/errors.ts +24 -0
- package/src/server.ts +196 -5
- package/src/service/manifest_service.spec.ts +201 -0
- package/src/service/manifest_service.ts +106 -0
- package/src/service/materialization_service.spec.ts +648 -0
- package/src/service/materialization_service.ts +929 -0
- package/src/service/materialized_table_gc.spec.ts +383 -0
- package/src/service/materialized_table_gc.ts +279 -0
- package/src/service/model.ts +25 -4
- package/src/service/package.ts +50 -0
- package/src/service/project_store.ts +21 -2
- package/src/service/quoting.ts +41 -0
- package/src/service/resolve_project.ts +13 -0
- package/src/storage/DatabaseInterface.ts +103 -1
- package/src/storage/{StorageManager.spec.ts → StorageManager.mock.ts} +9 -0
- package/src/storage/StorageManager.ts +119 -1
- package/src/storage/duckdb/DuckDBManifestStore.ts +70 -0
- package/src/storage/duckdb/DuckDBRepository.ts +99 -9
- package/src/storage/duckdb/ManifestRepository.ts +119 -0
- package/src/storage/duckdb/MaterializationRepository.ts +249 -0
- package/src/storage/duckdb/manifest_store.spec.ts +133 -0
- package/src/storage/duckdb/schema.ts +59 -1
- package/src/storage/ducklake/DuckLakeManifestStore.ts +146 -0
- package/tests/fixtures/persist-test/data/orders.csv +5 -0
- package/tests/fixtures/persist-test/persist_test.malloy +11 -0
- package/tests/fixtures/persist-test/publisher.json +5 -0
- package/tests/fixtures/publisher.config.json +15 -0
- package/tests/harness/rest_e2e.ts +68 -0
- package/tests/integration/materialization/materialization_lifecycle.integration.spec.ts +470 -0
- package/tests/integration/mcp/mcp_execute_query_tool.integration.spec.ts +2 -2
package/dist/server.js
CHANGED
|
@@ -5,39 +5,60 @@ var __defProp = Object.defineProperty;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
function __accessProp(key) {
|
|
9
|
+
return this[key];
|
|
10
|
+
}
|
|
11
|
+
var __toESMCache_node;
|
|
12
|
+
var __toESMCache_esm;
|
|
8
13
|
var __toESM = (mod2, isNodeMode, target) => {
|
|
14
|
+
var canCache = mod2 != null && typeof mod2 === "object";
|
|
15
|
+
if (canCache) {
|
|
16
|
+
var cache = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
|
|
17
|
+
var cached = cache.get(mod2);
|
|
18
|
+
if (cached)
|
|
19
|
+
return cached;
|
|
20
|
+
}
|
|
9
21
|
target = mod2 != null ? __create(__getProtoOf(mod2)) : {};
|
|
10
22
|
const to = isNodeMode || !mod2 || !mod2.__esModule ? __defProp(target, "default", { value: mod2, enumerable: true }) : target;
|
|
11
23
|
for (let key of __getOwnPropNames(mod2))
|
|
12
24
|
if (!__hasOwnProp.call(to, key))
|
|
13
25
|
__defProp(to, key, {
|
|
14
|
-
get: (
|
|
26
|
+
get: __accessProp.bind(mod2, key),
|
|
15
27
|
enumerable: true
|
|
16
28
|
});
|
|
29
|
+
if (canCache)
|
|
30
|
+
cache.set(mod2, to);
|
|
17
31
|
return to;
|
|
18
32
|
};
|
|
19
|
-
var __moduleCache = /* @__PURE__ */ new WeakMap;
|
|
20
33
|
var __toCommonJS = (from) => {
|
|
21
|
-
var entry = __moduleCache.get(from), desc;
|
|
34
|
+
var entry = (__moduleCache ??= new WeakMap).get(from), desc;
|
|
22
35
|
if (entry)
|
|
23
36
|
return entry;
|
|
24
37
|
entry = __defProp({}, "__esModule", { value: true });
|
|
25
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
38
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
39
|
+
for (var key of __getOwnPropNames(from))
|
|
40
|
+
if (!__hasOwnProp.call(entry, key))
|
|
41
|
+
__defProp(entry, key, {
|
|
42
|
+
get: __accessProp.bind(from, key),
|
|
43
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
44
|
+
});
|
|
45
|
+
}
|
|
30
46
|
__moduleCache.set(from, entry);
|
|
31
47
|
return entry;
|
|
32
48
|
};
|
|
49
|
+
var __moduleCache;
|
|
33
50
|
var __commonJS = (cb, mod2) => () => (mod2 || cb((mod2 = { exports: {} }).exports, mod2), mod2.exports);
|
|
51
|
+
var __returnValue = (v) => v;
|
|
52
|
+
function __exportSetter(name, newValue) {
|
|
53
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
54
|
+
}
|
|
34
55
|
var __export = (target, all) => {
|
|
35
56
|
for (var name in all)
|
|
36
57
|
__defProp(target, name, {
|
|
37
58
|
get: all[name],
|
|
38
59
|
enumerable: true,
|
|
39
60
|
configurable: true,
|
|
40
|
-
set: (
|
|
61
|
+
set: __exportSetter.bind(all, name)
|
|
41
62
|
});
|
|
42
63
|
};
|
|
43
64
|
|
|
@@ -5982,7 +6003,7 @@ var require_path_parse = __commonJS((exports2, module2) => {
|
|
|
5982
6003
|
var require_node_modules_paths = __commonJS((exports2, module2) => {
|
|
5983
6004
|
var path = require("path");
|
|
5984
6005
|
var parse = path.parse || require_path_parse();
|
|
5985
|
-
var getNodeModulesDirs = function
|
|
6006
|
+
var getNodeModulesDirs = function getNodeModulesDirs2(absoluteStart, modules) {
|
|
5986
6007
|
var prefix = "/";
|
|
5987
6008
|
if (/^([A-Za-z]:)/.test(absoluteStart)) {
|
|
5988
6009
|
prefix = "";
|
|
@@ -6026,7 +6047,7 @@ var require_implementation = __commonJS((exports2, module2) => {
|
|
|
6026
6047
|
var toStr = Object.prototype.toString;
|
|
6027
6048
|
var max = Math.max;
|
|
6028
6049
|
var funcType = "[object Function]";
|
|
6029
|
-
var concatty = function
|
|
6050
|
+
var concatty = function concatty2(a, b) {
|
|
6030
6051
|
var arr = [];
|
|
6031
6052
|
for (var i = 0;i < a.length; i += 1) {
|
|
6032
6053
|
arr[i] = a[i];
|
|
@@ -6036,7 +6057,7 @@ var require_implementation = __commonJS((exports2, module2) => {
|
|
|
6036
6057
|
}
|
|
6037
6058
|
return arr;
|
|
6038
6059
|
};
|
|
6039
|
-
var slicy = function
|
|
6060
|
+
var slicy = function slicy2(arrLike, offset) {
|
|
6040
6061
|
var arr = [];
|
|
6041
6062
|
for (var i = offset || 0, j = 0;i < arrLike.length; i += 1, j += 1) {
|
|
6042
6063
|
arr[j] = arrLike[i];
|
|
@@ -6077,7 +6098,7 @@ var require_implementation = __commonJS((exports2, module2) => {
|
|
|
6077
6098
|
}
|
|
6078
6099
|
bound = Function("binder", "return function (" + joiny(boundArgs, ",") + "){ return binder.apply(this,arguments); }")(binder);
|
|
6079
6100
|
if (target.prototype) {
|
|
6080
|
-
var Empty = function
|
|
6101
|
+
var Empty = function Empty2() {};
|
|
6081
6102
|
Empty.prototype = target.prototype;
|
|
6082
6103
|
bound.prototype = new Empty;
|
|
6083
6104
|
Empty.prototype = null;
|
|
@@ -6371,14 +6392,14 @@ var require_async = __commonJS((exports2, module2) => {
|
|
|
6371
6392
|
cb(null, realpathErr ? x : realPath);
|
|
6372
6393
|
});
|
|
6373
6394
|
};
|
|
6374
|
-
var maybeRealpath = function
|
|
6395
|
+
var maybeRealpath = function maybeRealpath2(realpath, x, opts, cb) {
|
|
6375
6396
|
if (opts && opts.preserveSymlinks === false) {
|
|
6376
6397
|
realpath(x, cb);
|
|
6377
6398
|
} else {
|
|
6378
6399
|
cb(null, x);
|
|
6379
6400
|
}
|
|
6380
6401
|
};
|
|
6381
|
-
var defaultReadPackage = function
|
|
6402
|
+
var defaultReadPackage = function defaultReadPackage2(readFile, pkgfile, cb) {
|
|
6382
6403
|
readFile(pkgfile, function(readFileErr, body) {
|
|
6383
6404
|
if (readFileErr)
|
|
6384
6405
|
cb(readFileErr);
|
|
@@ -6392,7 +6413,7 @@ var require_async = __commonJS((exports2, module2) => {
|
|
|
6392
6413
|
}
|
|
6393
6414
|
});
|
|
6394
6415
|
};
|
|
6395
|
-
var getPackageCandidates = function
|
|
6416
|
+
var getPackageCandidates = function getPackageCandidates2(x, start, opts) {
|
|
6396
6417
|
var dirs = nodeModulesPaths(start, opts, x);
|
|
6397
6418
|
for (var i = 0;i < dirs.length; i++) {
|
|
6398
6419
|
dirs[i] = path.join(dirs[i], x);
|
|
@@ -6885,20 +6906,20 @@ var require_sync = __commonJS((exports2, module2) => {
|
|
|
6885
6906
|
}
|
|
6886
6907
|
return x;
|
|
6887
6908
|
};
|
|
6888
|
-
var maybeRealpathSync = function
|
|
6909
|
+
var maybeRealpathSync = function maybeRealpathSync2(realpathSync, x, opts) {
|
|
6889
6910
|
if (opts && opts.preserveSymlinks === false) {
|
|
6890
6911
|
return realpathSync(x);
|
|
6891
6912
|
}
|
|
6892
6913
|
return x;
|
|
6893
6914
|
};
|
|
6894
|
-
var defaultReadPackageSync = function
|
|
6915
|
+
var defaultReadPackageSync = function defaultReadPackageSync2(readFileSync, pkgfile) {
|
|
6895
6916
|
var body = readFileSync(pkgfile);
|
|
6896
6917
|
try {
|
|
6897
6918
|
var pkg = JSON.parse(body);
|
|
6898
6919
|
return pkg;
|
|
6899
6920
|
} catch (jsonErr) {}
|
|
6900
6921
|
};
|
|
6901
|
-
var getPackageCandidates = function
|
|
6922
|
+
var getPackageCandidates = function getPackageCandidates2(x, start, opts) {
|
|
6902
6923
|
var dirs = nodeModulesPaths(start, opts, x);
|
|
6903
6924
|
for (var i = 0;i < dirs.length; i++) {
|
|
6904
6925
|
dirs[i] = path.join(dirs[i], x);
|
|
@@ -24706,13 +24727,13 @@ var require_extend = __commonJS((exports2, module2) => {
|
|
|
24706
24727
|
var toStr = Object.prototype.toString;
|
|
24707
24728
|
var defineProperty = Object.defineProperty;
|
|
24708
24729
|
var gOPD = Object.getOwnPropertyDescriptor;
|
|
24709
|
-
var isArray = function
|
|
24730
|
+
var isArray = function isArray2(arr) {
|
|
24710
24731
|
if (typeof Array.isArray === "function") {
|
|
24711
24732
|
return Array.isArray(arr);
|
|
24712
24733
|
}
|
|
24713
24734
|
return toStr.call(arr) === "[object Array]";
|
|
24714
24735
|
};
|
|
24715
|
-
var isPlainObject = function
|
|
24736
|
+
var isPlainObject = function isPlainObject2(obj) {
|
|
24716
24737
|
if (!obj || toStr.call(obj) !== "[object Object]") {
|
|
24717
24738
|
return false;
|
|
24718
24739
|
}
|
|
@@ -24725,7 +24746,7 @@ var require_extend = __commonJS((exports2, module2) => {
|
|
|
24725
24746
|
for (key in obj) {}
|
|
24726
24747
|
return typeof key === "undefined" || hasOwn.call(obj, key);
|
|
24727
24748
|
};
|
|
24728
|
-
var setProperty = function
|
|
24749
|
+
var setProperty = function setProperty2(target, options) {
|
|
24729
24750
|
if (defineProperty && options.name === "__proto__") {
|
|
24730
24751
|
defineProperty(target, options.name, {
|
|
24731
24752
|
enumerable: true,
|
|
@@ -24737,7 +24758,7 @@ var require_extend = __commonJS((exports2, module2) => {
|
|
|
24737
24758
|
target[options.name] = options.newValue;
|
|
24738
24759
|
}
|
|
24739
24760
|
};
|
|
24740
|
-
var getProperty = function
|
|
24761
|
+
var getProperty = function getProperty2(obj, name) {
|
|
24741
24762
|
if (name === "__proto__") {
|
|
24742
24763
|
if (!hasOwn.call(obj, name)) {
|
|
24743
24764
|
return;
|
|
@@ -30967,12 +30988,12 @@ var require_lib3 = __commonJS((exports2, module2) => {
|
|
|
30967
30988
|
AbortError.prototype.name = "AbortError";
|
|
30968
30989
|
var URL$1 = Url.URL || whatwgUrl.URL;
|
|
30969
30990
|
var PassThrough$1 = Stream.PassThrough;
|
|
30970
|
-
var isDomainOrSubdomain = function
|
|
30991
|
+
var isDomainOrSubdomain = function isDomainOrSubdomain2(destination, original) {
|
|
30971
30992
|
const orig = new URL$1(original).hostname;
|
|
30972
30993
|
const dest = new URL$1(destination).hostname;
|
|
30973
30994
|
return orig === dest || orig[orig.length - dest.length - 1] === "." && orig.endsWith(dest);
|
|
30974
30995
|
};
|
|
30975
|
-
var isSameProtocol = function
|
|
30996
|
+
var isSameProtocol = function isSameProtocol2(destination, original) {
|
|
30976
30997
|
const orig = new URL$1(original).protocol;
|
|
30977
30998
|
const dest = new URL$1(destination).protocol;
|
|
30978
30999
|
return orig === dest;
|
|
@@ -30988,7 +31009,7 @@ var require_lib3 = __commonJS((exports2, module2) => {
|
|
|
30988
31009
|
const send = (options.protocol === "https:" ? https : http).request;
|
|
30989
31010
|
const signal = request.signal;
|
|
30990
31011
|
let response = null;
|
|
30991
|
-
const abort = function
|
|
31012
|
+
const abort = function abort2() {
|
|
30992
31013
|
let error = new AbortError("The user aborted a request.");
|
|
30993
31014
|
reject(error);
|
|
30994
31015
|
if (request.body && request.body instanceof Stream.Readable) {
|
|
@@ -31002,7 +31023,7 @@ var require_lib3 = __commonJS((exports2, module2) => {
|
|
|
31002
31023
|
abort();
|
|
31003
31024
|
return;
|
|
31004
31025
|
}
|
|
31005
|
-
const abortAndFinalize = function
|
|
31026
|
+
const abortAndFinalize = function abortAndFinalize2() {
|
|
31006
31027
|
abort();
|
|
31007
31028
|
finalize();
|
|
31008
31029
|
};
|
|
@@ -32747,7 +32768,7 @@ Content-Type: ${partContentType}\r
|
|
|
32747
32768
|
}
|
|
32748
32769
|
}
|
|
32749
32770
|
exports2.Gaxios = Gaxios;
|
|
32750
|
-
_a = Gaxios, _Gaxios_instances = new WeakSet, _Gaxios_urlMayUseProxy = function
|
|
32771
|
+
_a = Gaxios, _Gaxios_instances = new WeakSet, _Gaxios_urlMayUseProxy = function _Gaxios_urlMayUseProxy2(url, noProxy = []) {
|
|
32751
32772
|
var _b, _c;
|
|
32752
32773
|
const candidate = new url_1.URL(url);
|
|
32753
32774
|
const noProxyList = [...noProxy];
|
|
@@ -32774,7 +32795,7 @@ Content-Type: ${partContentType}\r
|
|
|
32774
32795
|
}
|
|
32775
32796
|
}
|
|
32776
32797
|
return true;
|
|
32777
|
-
}, _Gaxios_applyRequestInterceptors = async function
|
|
32798
|
+
}, _Gaxios_applyRequestInterceptors = async function _Gaxios_applyRequestInterceptors2(options) {
|
|
32778
32799
|
let promiseChain = Promise.resolve(options);
|
|
32779
32800
|
for (const interceptor of this.interceptors.request.values()) {
|
|
32780
32801
|
if (interceptor) {
|
|
@@ -32782,7 +32803,7 @@ Content-Type: ${partContentType}\r
|
|
|
32782
32803
|
}
|
|
32783
32804
|
}
|
|
32784
32805
|
return promiseChain;
|
|
32785
|
-
}, _Gaxios_applyResponseInterceptors = async function
|
|
32806
|
+
}, _Gaxios_applyResponseInterceptors = async function _Gaxios_applyResponseInterceptors2(response) {
|
|
32786
32807
|
let promiseChain = Promise.resolve(response);
|
|
32787
32808
|
for (const interceptor of this.interceptors.response.values()) {
|
|
32788
32809
|
if (interceptor) {
|
|
@@ -32790,7 +32811,7 @@ Content-Type: ${partContentType}\r
|
|
|
32790
32811
|
}
|
|
32791
32812
|
}
|
|
32792
32813
|
return promiseChain;
|
|
32793
|
-
}, _Gaxios_prepareRequest = async function
|
|
32814
|
+
}, _Gaxios_prepareRequest = async function _Gaxios_prepareRequest2(options) {
|
|
32794
32815
|
var _b, _c, _d, _e;
|
|
32795
32816
|
const opts = (0, extend_1.default)(true, {}, this.defaults, options);
|
|
32796
32817
|
if (!opts.url) {
|
|
@@ -32880,7 +32901,7 @@ Content-Type: ${partContentType}\r
|
|
|
32880
32901
|
opts.errorRedactor = common_1.defaultErrorRedactor;
|
|
32881
32902
|
}
|
|
32882
32903
|
return opts;
|
|
32883
|
-
}, _Gaxios_getProxyAgent = async function
|
|
32904
|
+
}, _Gaxios_getProxyAgent = async function _Gaxios_getProxyAgent2() {
|
|
32884
32905
|
__classPrivateFieldSet(this, _a, __classPrivateFieldGet(this, _a, "f", _Gaxios_proxyAgent) || (await Promise.resolve().then(() => __importStar(require_dist3()))).HttpsProxyAgent, "f", _Gaxios_proxyAgent);
|
|
32885
32906
|
return __classPrivateFieldGet(this, _a, "f", _Gaxios_proxyAgent);
|
|
32886
32907
|
};
|
|
@@ -39060,7 +39081,7 @@ var require_writer = __commonJS((exports2, module2) => {
|
|
|
39060
39081
|
this.tail = this.head;
|
|
39061
39082
|
this.states = null;
|
|
39062
39083
|
}
|
|
39063
|
-
var create = function
|
|
39084
|
+
var create = function create2() {
|
|
39064
39085
|
return util.Buffer ? function create_buffer_setup() {
|
|
39065
39086
|
return (Writer.create = function create_buffer() {
|
|
39066
39087
|
return new BufferWriter;
|
|
@@ -39284,12 +39305,12 @@ var require_reader = __commonJS((exports2, module2) => {
|
|
|
39284
39305
|
if (buffer instanceof Uint8Array || Array.isArray(buffer))
|
|
39285
39306
|
return new Reader(buffer);
|
|
39286
39307
|
throw Error("illegal buffer");
|
|
39287
|
-
} : function
|
|
39308
|
+
} : function create_array2(buffer) {
|
|
39288
39309
|
if (Array.isArray(buffer))
|
|
39289
39310
|
return new Reader(buffer);
|
|
39290
39311
|
throw Error("illegal buffer");
|
|
39291
39312
|
};
|
|
39292
|
-
var create = function
|
|
39313
|
+
var create = function create2() {
|
|
39293
39314
|
return util.Buffer ? function create_buffer_setup(buffer) {
|
|
39294
39315
|
return (Reader.create = function create_buffer(buffer2) {
|
|
39295
39316
|
return util.Buffer.isBuffer(buffer2) ? new BufferReader(buffer2) : create_array(buffer2);
|
|
@@ -75653,10 +75674,10 @@ var require_fetch = __commonJS((exports2, module2) => {
|
|
|
75653
75674
|
// ../../node_modules/@protobufjs/path/index.js
|
|
75654
75675
|
var require_path = __commonJS((exports2) => {
|
|
75655
75676
|
var path = exports2;
|
|
75656
|
-
var isAbsolute = path.isAbsolute = function
|
|
75677
|
+
var isAbsolute = path.isAbsolute = function isAbsolute2(path2) {
|
|
75657
75678
|
return /^(?:\/|\w+:)/.test(path2);
|
|
75658
75679
|
};
|
|
75659
|
-
var normalize = path.normalize = function
|
|
75680
|
+
var normalize = path.normalize = function normalize2(path2) {
|
|
75660
75681
|
path2 = path2.replace(/\\/g, "/").replace(/\/{2,}/g, "/");
|
|
75661
75682
|
var parts = path2.split("/"), absolute = isAbsolute(path2), prefix = "";
|
|
75662
75683
|
if (absolute)
|
|
@@ -75821,7 +75842,7 @@ var require_namespace = __commonJS((exports2, module2) => {
|
|
|
75821
75842
|
object.onRemove(this);
|
|
75822
75843
|
return clearCache(this);
|
|
75823
75844
|
};
|
|
75824
|
-
Namespace.prototype.define = function
|
|
75845
|
+
Namespace.prototype.define = function define2(path, json) {
|
|
75825
75846
|
if (util.isString(path))
|
|
75826
75847
|
path = path.split(".");
|
|
75827
75848
|
else if (!Array.isArray(path))
|
|
@@ -105390,7 +105411,7 @@ var require_colors = __commonJS((exports2, module2) => {
|
|
|
105390
105411
|
colors.stripColors = colors.strip = function(str) {
|
|
105391
105412
|
return ("" + str).replace(/\x1B\[\d+m/g, "");
|
|
105392
105413
|
};
|
|
105393
|
-
var stylize = colors.stylize = function
|
|
105414
|
+
var stylize = colors.stylize = function stylize2(str, style) {
|
|
105394
105415
|
if (!colors.enabled) {
|
|
105395
105416
|
return str + "";
|
|
105396
105417
|
}
|
|
@@ -105408,8 +105429,8 @@ var require_colors = __commonJS((exports2, module2) => {
|
|
|
105408
105429
|
return str.replace(matchOperatorsRe, "\\$&");
|
|
105409
105430
|
};
|
|
105410
105431
|
function build(_styles) {
|
|
105411
|
-
var builder = function
|
|
105412
|
-
return applyStyle.apply(
|
|
105432
|
+
var builder = function builder2() {
|
|
105433
|
+
return applyStyle.apply(builder2, arguments);
|
|
105413
105434
|
};
|
|
105414
105435
|
builder._styles = _styles;
|
|
105415
105436
|
builder.__proto__ = proto;
|
|
@@ -105428,7 +105449,7 @@ var require_colors = __commonJS((exports2, module2) => {
|
|
|
105428
105449
|
});
|
|
105429
105450
|
return ret;
|
|
105430
105451
|
}();
|
|
105431
|
-
var proto = defineProps(function
|
|
105452
|
+
var proto = defineProps(function colors2() {}, styles);
|
|
105432
105453
|
function applyStyle() {
|
|
105433
105454
|
var args = Array.prototype.slice.call(arguments);
|
|
105434
105455
|
var str = args.map(function(arg) {
|
|
@@ -105487,7 +105508,7 @@ var require_colors = __commonJS((exports2, module2) => {
|
|
|
105487
105508
|
});
|
|
105488
105509
|
return ret;
|
|
105489
105510
|
}
|
|
105490
|
-
var sequencer = function
|
|
105511
|
+
var sequencer = function sequencer2(map2, str) {
|
|
105491
105512
|
var exploded = str.split("");
|
|
105492
105513
|
exploded = exploded.map(map2);
|
|
105493
105514
|
return exploded.join("");
|
|
@@ -108110,28 +108131,28 @@ var require_end_of_stream = __commonJS((exports2, module2) => {
|
|
|
108110
108131
|
callback = once(callback || noop);
|
|
108111
108132
|
var readable = opts.readable || opts.readable !== false && stream.readable;
|
|
108112
108133
|
var writable = opts.writable || opts.writable !== false && stream.writable;
|
|
108113
|
-
var onlegacyfinish = function
|
|
108134
|
+
var onlegacyfinish = function onlegacyfinish2() {
|
|
108114
108135
|
if (!stream.writable)
|
|
108115
108136
|
onfinish();
|
|
108116
108137
|
};
|
|
108117
108138
|
var writableEnded = stream._writableState && stream._writableState.finished;
|
|
108118
|
-
var onfinish = function
|
|
108139
|
+
var onfinish = function onfinish2() {
|
|
108119
108140
|
writable = false;
|
|
108120
108141
|
writableEnded = true;
|
|
108121
108142
|
if (!readable)
|
|
108122
108143
|
callback.call(stream);
|
|
108123
108144
|
};
|
|
108124
108145
|
var readableEnded = stream._readableState && stream._readableState.endEmitted;
|
|
108125
|
-
var onend = function
|
|
108146
|
+
var onend = function onend2() {
|
|
108126
108147
|
readable = false;
|
|
108127
108148
|
readableEnded = true;
|
|
108128
108149
|
if (!writable)
|
|
108129
108150
|
callback.call(stream);
|
|
108130
108151
|
};
|
|
108131
|
-
var onerror = function
|
|
108152
|
+
var onerror = function onerror2(err) {
|
|
108132
108153
|
callback.call(stream, err);
|
|
108133
108154
|
};
|
|
108134
|
-
var onclose = function
|
|
108155
|
+
var onclose = function onclose2() {
|
|
108135
108156
|
var err;
|
|
108136
108157
|
if (readable && !readableEnded) {
|
|
108137
108158
|
if (!stream._readableState || !stream._readableState.ended)
|
|
@@ -108144,7 +108165,7 @@ var require_end_of_stream = __commonJS((exports2, module2) => {
|
|
|
108144
108165
|
return callback.call(stream, err);
|
|
108145
108166
|
}
|
|
108146
108167
|
};
|
|
108147
|
-
var onrequest = function
|
|
108168
|
+
var onrequest = function onrequest2() {
|
|
108148
108169
|
stream.req.on("finish", onfinish);
|
|
108149
108170
|
};
|
|
108150
108171
|
if (isRequest(stream)) {
|
|
@@ -108301,7 +108322,7 @@ var require_async_iterator = __commonJS((exports2, module2) => {
|
|
|
108301
108322
|
});
|
|
108302
108323
|
});
|
|
108303
108324
|
}), _Object$setPrototypeO), AsyncIteratorPrototype);
|
|
108304
|
-
var createReadableStreamAsyncIterator = function
|
|
108325
|
+
var createReadableStreamAsyncIterator = function createReadableStreamAsyncIterator2(stream) {
|
|
108305
108326
|
var _Object$create;
|
|
108306
108327
|
var iterator = Object.create(ReadableStreamAsyncIteratorPrototype, (_Object$create = {}, _defineProperty(_Object$create, kStream, {
|
|
108307
108328
|
value: stream,
|
|
@@ -108490,7 +108511,7 @@ var require__stream_readable = __commonJS((exports2, module2) => {
|
|
|
108490
108511
|
var Duplex;
|
|
108491
108512
|
Readable.ReadableState = ReadableState;
|
|
108492
108513
|
var EE = require("events").EventEmitter;
|
|
108493
|
-
var EElistenerCount = function
|
|
108514
|
+
var EElistenerCount = function EElistenerCount2(emitter, type) {
|
|
108494
108515
|
return emitter.listeners(type).length;
|
|
108495
108516
|
};
|
|
108496
108517
|
var Stream = require_stream();
|
|
@@ -108507,7 +108528,7 @@ var require__stream_readable = __commonJS((exports2, module2) => {
|
|
|
108507
108528
|
if (debugUtil && debugUtil.debuglog) {
|
|
108508
108529
|
debug = debugUtil.debuglog("stream");
|
|
108509
108530
|
} else {
|
|
108510
|
-
debug = function
|
|
108531
|
+
debug = function debug2() {};
|
|
108511
108532
|
}
|
|
108512
108533
|
var BufferList = require_buffer_list();
|
|
108513
108534
|
var destroyImpl = require_destroy();
|
|
@@ -109453,7 +109474,7 @@ var require__stream_writable = __commonJS((exports2, module2) => {
|
|
|
109453
109474
|
}
|
|
109454
109475
|
});
|
|
109455
109476
|
} else {
|
|
109456
|
-
realHasInstance = function
|
|
109477
|
+
realHasInstance = function realHasInstance2(object) {
|
|
109457
109478
|
return object instanceof this;
|
|
109458
109479
|
};
|
|
109459
109480
|
}
|
|
@@ -109831,7 +109852,7 @@ var require_modern = __commonJS((exports2, module2) => {
|
|
|
109831
109852
|
var util = require("util");
|
|
109832
109853
|
var Writable = require__stream_writable();
|
|
109833
109854
|
var { LEVEL } = require_triple_beam();
|
|
109834
|
-
var TransportStream = module2.exports = function
|
|
109855
|
+
var TransportStream = module2.exports = function TransportStream2(options = {}) {
|
|
109835
109856
|
Writable.call(this, { objectMode: true, highWaterMark: options.highWaterMark });
|
|
109836
109857
|
this.format = options.format;
|
|
109837
109858
|
this.level = options.level;
|
|
@@ -109942,7 +109963,7 @@ var require_legacy = __commonJS((exports2, module2) => {
|
|
|
109942
109963
|
var util = require("util");
|
|
109943
109964
|
var { LEVEL } = require_triple_beam();
|
|
109944
109965
|
var TransportStream = require_modern();
|
|
109945
|
-
var LegacyTransportStream = module2.exports = function
|
|
109966
|
+
var LegacyTransportStream = module2.exports = function LegacyTransportStream2(options = {}) {
|
|
109946
109967
|
TransportStream.call(this, options);
|
|
109947
109968
|
if (!options.transport || typeof options.transport.log !== "function") {
|
|
109948
109969
|
throw new Error("Invalid transport, must be an object with a log method.");
|
|
@@ -111161,7 +111182,7 @@ var require__stream_writable2 = __commonJS((exports2, module2) => {
|
|
|
111161
111182
|
}
|
|
111162
111183
|
});
|
|
111163
111184
|
} else {
|
|
111164
|
-
realHasInstance = function
|
|
111185
|
+
realHasInstance = function realHasInstance2(object) {
|
|
111165
111186
|
return object instanceof this;
|
|
111166
111187
|
};
|
|
111167
111188
|
}
|
|
@@ -111645,28 +111666,28 @@ var require_end_of_stream2 = __commonJS((exports2, module2) => {
|
|
|
111645
111666
|
callback = once(callback || noop);
|
|
111646
111667
|
var readable = opts.readable || opts.readable !== false && stream.readable;
|
|
111647
111668
|
var writable = opts.writable || opts.writable !== false && stream.writable;
|
|
111648
|
-
var onlegacyfinish = function
|
|
111669
|
+
var onlegacyfinish = function onlegacyfinish2() {
|
|
111649
111670
|
if (!stream.writable)
|
|
111650
111671
|
onfinish();
|
|
111651
111672
|
};
|
|
111652
111673
|
var writableEnded = stream._writableState && stream._writableState.finished;
|
|
111653
|
-
var onfinish = function
|
|
111674
|
+
var onfinish = function onfinish2() {
|
|
111654
111675
|
writable = false;
|
|
111655
111676
|
writableEnded = true;
|
|
111656
111677
|
if (!readable)
|
|
111657
111678
|
callback.call(stream);
|
|
111658
111679
|
};
|
|
111659
111680
|
var readableEnded = stream._readableState && stream._readableState.endEmitted;
|
|
111660
|
-
var onend = function
|
|
111681
|
+
var onend = function onend2() {
|
|
111661
111682
|
readable = false;
|
|
111662
111683
|
readableEnded = true;
|
|
111663
111684
|
if (!writable)
|
|
111664
111685
|
callback.call(stream);
|
|
111665
111686
|
};
|
|
111666
|
-
var onerror = function
|
|
111687
|
+
var onerror = function onerror2(err) {
|
|
111667
111688
|
callback.call(stream, err);
|
|
111668
111689
|
};
|
|
111669
|
-
var onclose = function
|
|
111690
|
+
var onclose = function onclose2() {
|
|
111670
111691
|
var err;
|
|
111671
111692
|
if (readable && !readableEnded) {
|
|
111672
111693
|
if (!stream._readableState || !stream._readableState.ended)
|
|
@@ -111679,7 +111700,7 @@ var require_end_of_stream2 = __commonJS((exports2, module2) => {
|
|
|
111679
111700
|
return callback.call(stream, err);
|
|
111680
111701
|
}
|
|
111681
111702
|
};
|
|
111682
|
-
var onrequest = function
|
|
111703
|
+
var onrequest = function onrequest2() {
|
|
111683
111704
|
stream.req.on("finish", onfinish);
|
|
111684
111705
|
};
|
|
111685
111706
|
if (isRequest(stream)) {
|
|
@@ -111836,7 +111857,7 @@ var require_async_iterator2 = __commonJS((exports2, module2) => {
|
|
|
111836
111857
|
});
|
|
111837
111858
|
});
|
|
111838
111859
|
}), _Object$setPrototypeO), AsyncIteratorPrototype);
|
|
111839
|
-
var createReadableStreamAsyncIterator = function
|
|
111860
|
+
var createReadableStreamAsyncIterator = function createReadableStreamAsyncIterator2(stream) {
|
|
111840
111861
|
var _Object$create;
|
|
111841
111862
|
var iterator = Object.create(ReadableStreamAsyncIteratorPrototype, (_Object$create = {}, _defineProperty(_Object$create, kStream, {
|
|
111842
111863
|
value: stream,
|
|
@@ -112025,7 +112046,7 @@ var require__stream_readable2 = __commonJS((exports2, module2) => {
|
|
|
112025
112046
|
var Duplex;
|
|
112026
112047
|
Readable.ReadableState = ReadableState;
|
|
112027
112048
|
var EE = require("events").EventEmitter;
|
|
112028
|
-
var EElistenerCount = function
|
|
112049
|
+
var EElistenerCount = function EElistenerCount2(emitter, type) {
|
|
112029
112050
|
return emitter.listeners(type).length;
|
|
112030
112051
|
};
|
|
112031
112052
|
var Stream = require_stream2();
|
|
@@ -112042,7 +112063,7 @@ var require__stream_readable2 = __commonJS((exports2, module2) => {
|
|
|
112042
112063
|
if (debugUtil && debugUtil.debuglog) {
|
|
112043
112064
|
debug = debugUtil.debuglog("stream");
|
|
112044
112065
|
} else {
|
|
112045
|
-
debug = function
|
|
112066
|
+
debug = function debug2() {};
|
|
112046
112067
|
}
|
|
112047
112068
|
var BufferList = require_buffer_list2();
|
|
112048
112069
|
var destroyImpl = require_destroy2();
|
|
@@ -133832,7 +133853,7 @@ var require_round = __commonJS((exports2, module2) => {
|
|
|
133832
133853
|
|
|
133833
133854
|
// ../../node_modules/math-intrinsics/isNaN.js
|
|
133834
133855
|
var require_isNaN = __commonJS((exports2, module2) => {
|
|
133835
|
-
module2.exports = Number.isNaN || function
|
|
133856
|
+
module2.exports = Number.isNaN || function isNaN2(a) {
|
|
133836
133857
|
return a !== a;
|
|
133837
133858
|
};
|
|
133838
133859
|
});
|
|
@@ -134176,7 +134197,7 @@ var require_get_intrinsic = __commonJS((exports2, module2) => {
|
|
|
134176
134197
|
}
|
|
134177
134198
|
}
|
|
134178
134199
|
var errorProto;
|
|
134179
|
-
var doEval = function
|
|
134200
|
+
var doEval = function doEval2(name) {
|
|
134180
134201
|
var value;
|
|
134181
134202
|
if (name === "%AsyncFunction%") {
|
|
134182
134203
|
value = getEvalledConstructor("async function () {}");
|
|
@@ -134185,12 +134206,12 @@ var require_get_intrinsic = __commonJS((exports2, module2) => {
|
|
|
134185
134206
|
} else if (name === "%AsyncGeneratorFunction%") {
|
|
134186
134207
|
value = getEvalledConstructor("async function* () {}");
|
|
134187
134208
|
} else if (name === "%AsyncGenerator%") {
|
|
134188
|
-
var fn =
|
|
134209
|
+
var fn = doEval2("%AsyncGeneratorFunction%");
|
|
134189
134210
|
if (fn) {
|
|
134190
134211
|
value = fn.prototype;
|
|
134191
134212
|
}
|
|
134192
134213
|
} else if (name === "%AsyncIteratorPrototype%") {
|
|
134193
|
-
var gen =
|
|
134214
|
+
var gen = doEval2("%AsyncGenerator%");
|
|
134194
134215
|
if (gen && getProto) {
|
|
134195
134216
|
value = getProto(gen.prototype);
|
|
134196
134217
|
}
|
|
@@ -134261,7 +134282,7 @@ var require_get_intrinsic = __commonJS((exports2, module2) => {
|
|
|
134261
134282
|
var $exec = bind.call($call, RegExp.prototype.exec);
|
|
134262
134283
|
var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g;
|
|
134263
134284
|
var reEscapeChar = /\\(\\)?/g;
|
|
134264
|
-
var stringToPath = function
|
|
134285
|
+
var stringToPath = function stringToPath2(string) {
|
|
134265
134286
|
var first = $strSlice(string, 0, 1);
|
|
134266
134287
|
var last = $strSlice(string, -1);
|
|
134267
134288
|
if (first === "%" && last !== "%") {
|
|
@@ -134275,7 +134296,7 @@ var require_get_intrinsic = __commonJS((exports2, module2) => {
|
|
|
134275
134296
|
});
|
|
134276
134297
|
return result;
|
|
134277
134298
|
};
|
|
134278
|
-
var getBaseIntrinsic = function
|
|
134299
|
+
var getBaseIntrinsic = function getBaseIntrinsic2(name, allowMissing) {
|
|
134279
134300
|
var intrinsicName = name;
|
|
134280
134301
|
var alias;
|
|
134281
134302
|
if (hasOwn(LEGACY_ALIASES, intrinsicName)) {
|
|
@@ -134565,7 +134586,7 @@ var require_utils70 = __commonJS((exports2, module2) => {
|
|
|
134565
134586
|
}
|
|
134566
134587
|
return array;
|
|
134567
134588
|
}();
|
|
134568
|
-
var compactQueue = function
|
|
134589
|
+
var compactQueue = function compactQueue2(queue) {
|
|
134569
134590
|
while (queue.length > 1) {
|
|
134570
134591
|
var item = queue.pop();
|
|
134571
134592
|
var obj = item.obj[item.prop];
|
|
@@ -134580,7 +134601,7 @@ var require_utils70 = __commonJS((exports2, module2) => {
|
|
|
134580
134601
|
}
|
|
134581
134602
|
}
|
|
134582
134603
|
};
|
|
134583
|
-
var arrayToObject = function
|
|
134604
|
+
var arrayToObject = function arrayToObject2(source, options) {
|
|
134584
134605
|
var obj = options && options.plainObjects ? Object.create(null) : {};
|
|
134585
134606
|
for (var i = 0;i < source.length; ++i) {
|
|
134586
134607
|
if (typeof source[i] !== "undefined") {
|
|
@@ -134589,7 +134610,7 @@ var require_utils70 = __commonJS((exports2, module2) => {
|
|
|
134589
134610
|
}
|
|
134590
134611
|
return obj;
|
|
134591
134612
|
};
|
|
134592
|
-
var merge = function
|
|
134613
|
+
var merge = function merge2(target, source, options) {
|
|
134593
134614
|
if (!source) {
|
|
134594
134615
|
return target;
|
|
134595
134616
|
}
|
|
@@ -134617,7 +134638,7 @@ var require_utils70 = __commonJS((exports2, module2) => {
|
|
|
134617
134638
|
if (has.call(target, i)) {
|
|
134618
134639
|
var targetItem = target[i];
|
|
134619
134640
|
if (targetItem && typeof targetItem === "object" && item && typeof item === "object") {
|
|
134620
|
-
target[i] =
|
|
134641
|
+
target[i] = merge2(targetItem, item, options);
|
|
134621
134642
|
} else {
|
|
134622
134643
|
target.push(item);
|
|
134623
134644
|
}
|
|
@@ -134630,7 +134651,7 @@ var require_utils70 = __commonJS((exports2, module2) => {
|
|
|
134630
134651
|
return Object.keys(source).reduce(function(acc, key) {
|
|
134631
134652
|
var value = source[key];
|
|
134632
134653
|
if (has.call(acc, key)) {
|
|
134633
|
-
acc[key] =
|
|
134654
|
+
acc[key] = merge2(acc[key], value, options);
|
|
134634
134655
|
} else {
|
|
134635
134656
|
acc[key] = value;
|
|
134636
134657
|
}
|
|
@@ -134655,7 +134676,7 @@ var require_utils70 = __commonJS((exports2, module2) => {
|
|
|
134655
134676
|
}
|
|
134656
134677
|
};
|
|
134657
134678
|
var limit = 1024;
|
|
134658
|
-
var encode = function
|
|
134679
|
+
var encode = function encode2(str, defaultEncoder, charset, kind, format) {
|
|
134659
134680
|
if (str.length === 0) {
|
|
134660
134681
|
return str;
|
|
134661
134682
|
}
|
|
@@ -134700,7 +134721,7 @@ var require_utils70 = __commonJS((exports2, module2) => {
|
|
|
134700
134721
|
}
|
|
134701
134722
|
return out;
|
|
134702
134723
|
};
|
|
134703
|
-
var compact = function
|
|
134724
|
+
var compact = function compact2(value) {
|
|
134704
134725
|
var queue = [{ obj: { o: value }, prop: "o" }];
|
|
134705
134726
|
var refs = [];
|
|
134706
134727
|
for (var i = 0;i < queue.length; ++i) {
|
|
@@ -134719,19 +134740,19 @@ var require_utils70 = __commonJS((exports2, module2) => {
|
|
|
134719
134740
|
compactQueue(queue);
|
|
134720
134741
|
return value;
|
|
134721
134742
|
};
|
|
134722
|
-
var isRegExp = function
|
|
134743
|
+
var isRegExp = function isRegExp2(obj) {
|
|
134723
134744
|
return Object.prototype.toString.call(obj) === "[object RegExp]";
|
|
134724
134745
|
};
|
|
134725
|
-
var isBuffer = function
|
|
134746
|
+
var isBuffer = function isBuffer2(obj) {
|
|
134726
134747
|
if (!obj || typeof obj !== "object") {
|
|
134727
134748
|
return false;
|
|
134728
134749
|
}
|
|
134729
134750
|
return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
|
|
134730
134751
|
};
|
|
134731
|
-
var combine = function
|
|
134752
|
+
var combine = function combine2(a, b) {
|
|
134732
134753
|
return [].concat(a, b);
|
|
134733
134754
|
};
|
|
134734
|
-
var maybeMap = function
|
|
134755
|
+
var maybeMap = function maybeMap2(val, fn) {
|
|
134735
134756
|
if (isArray(val)) {
|
|
134736
134757
|
var mapped = [];
|
|
134737
134758
|
for (var i = 0;i < val.length; i += 1) {
|
|
@@ -134801,11 +134822,11 @@ var require_stringify3 = __commonJS((exports2, module2) => {
|
|
|
134801
134822
|
skipNulls: false,
|
|
134802
134823
|
strictNullHandling: false
|
|
134803
134824
|
};
|
|
134804
|
-
var isNonNullishPrimitive = function
|
|
134825
|
+
var isNonNullishPrimitive = function isNonNullishPrimitive2(v) {
|
|
134805
134826
|
return typeof v === "string" || typeof v === "number" || typeof v === "boolean" || typeof v === "symbol" || typeof v === "bigint";
|
|
134806
134827
|
};
|
|
134807
134828
|
var sentinel = {};
|
|
134808
|
-
var stringify = function
|
|
134829
|
+
var stringify = function stringify2(object, prefix, generateArrayPrefix, commaRoundTrip, allowEmptyArrays, strictNullHandling, skipNulls, encodeDotInKeys, encoder, filter, sort, allowDots, serializeDate, format, formatter, encodeValuesOnly, charset, sideChannel) {
|
|
134809
134830
|
var obj = object;
|
|
134810
134831
|
var tmpSc = sideChannel;
|
|
134811
134832
|
var step = 0;
|
|
@@ -134881,11 +134902,11 @@ var require_stringify3 = __commonJS((exports2, module2) => {
|
|
|
134881
134902
|
sideChannel.set(object, step);
|
|
134882
134903
|
var valueSideChannel = getSideChannel();
|
|
134883
134904
|
valueSideChannel.set(sentinel, sideChannel);
|
|
134884
|
-
pushToArray(values,
|
|
134905
|
+
pushToArray(values, stringify2(value, keyPrefix, generateArrayPrefix, commaRoundTrip, allowEmptyArrays, strictNullHandling, skipNulls, encodeDotInKeys, generateArrayPrefix === "comma" && encodeValuesOnly && isArray(obj) ? null : encoder, filter, sort, allowDots, serializeDate, format, formatter, encodeValuesOnly, charset, valueSideChannel));
|
|
134885
134906
|
}
|
|
134886
134907
|
return values;
|
|
134887
134908
|
};
|
|
134888
|
-
var normalizeStringifyOptions = function
|
|
134909
|
+
var normalizeStringifyOptions = function normalizeStringifyOptions2(opts) {
|
|
134889
134910
|
if (!opts) {
|
|
134890
134911
|
return defaults;
|
|
134891
134912
|
}
|
|
@@ -135148,7 +135169,7 @@ var require_parse4 = __commonJS((exports2, module2) => {
|
|
|
135148
135169
|
}
|
|
135149
135170
|
return parseObject(keys, val, options, valuesParsed);
|
|
135150
135171
|
};
|
|
135151
|
-
var normalizeParseOptions = function
|
|
135172
|
+
var normalizeParseOptions = function normalizeParseOptions2(opts) {
|
|
135152
135173
|
if (!opts) {
|
|
135153
135174
|
return defaults;
|
|
135154
135175
|
}
|
|
@@ -135444,7 +135465,7 @@ var require_body_parser = __commonJS((exports2, module2) => {
|
|
|
135444
135465
|
});
|
|
135445
135466
|
var _urlencoded = exports2.urlencoded(opts);
|
|
135446
135467
|
var _json = exports2.json(opts);
|
|
135447
|
-
return function
|
|
135468
|
+
return function bodyParser2(req, res, next) {
|
|
135448
135469
|
_json(req, res, function(err) {
|
|
135449
135470
|
if (err)
|
|
135450
135471
|
return next(err);
|
|
@@ -137186,7 +137207,7 @@ var require_layer = __commonJS((exports2, module2) => {
|
|
|
137186
137207
|
}
|
|
137187
137208
|
};
|
|
137188
137209
|
Layer.prototype.match = function match(path) {
|
|
137189
|
-
var
|
|
137210
|
+
var match2;
|
|
137190
137211
|
if (path != null) {
|
|
137191
137212
|
if (this.regexp.fast_slash) {
|
|
137192
137213
|
this.params = {};
|
|
@@ -137198,21 +137219,21 @@ var require_layer = __commonJS((exports2, module2) => {
|
|
|
137198
137219
|
this.path = path;
|
|
137199
137220
|
return true;
|
|
137200
137221
|
}
|
|
137201
|
-
|
|
137222
|
+
match2 = this.regexp.exec(path);
|
|
137202
137223
|
}
|
|
137203
|
-
if (!
|
|
137224
|
+
if (!match2) {
|
|
137204
137225
|
this.params = undefined;
|
|
137205
137226
|
this.path = undefined;
|
|
137206
137227
|
return false;
|
|
137207
137228
|
}
|
|
137208
137229
|
this.params = {};
|
|
137209
|
-
this.path =
|
|
137230
|
+
this.path = match2[0];
|
|
137210
137231
|
var keys = this.keys;
|
|
137211
137232
|
var params = this.params;
|
|
137212
|
-
for (var i = 1;i <
|
|
137233
|
+
for (var i = 1;i < match2.length; i++) {
|
|
137213
137234
|
var key = keys[i - 1];
|
|
137214
137235
|
var prop = key.name;
|
|
137215
|
-
var val = decode_param(
|
|
137236
|
+
var val = decode_param(match2[i]);
|
|
137216
137237
|
if (val !== undefined || !hasOwnProperty.call(params, prop)) {
|
|
137217
137238
|
params[prop] = val;
|
|
137218
137239
|
}
|
|
@@ -137686,15 +137707,15 @@ var require_router = __commonJS((exports2, module2) => {
|
|
|
137686
137707
|
return this;
|
|
137687
137708
|
};
|
|
137688
137709
|
proto.route = function route(path) {
|
|
137689
|
-
var
|
|
137710
|
+
var route2 = new Route(path);
|
|
137690
137711
|
var layer = new Layer(path, {
|
|
137691
137712
|
sensitive: this.caseSensitive,
|
|
137692
137713
|
strict: this.strict,
|
|
137693
137714
|
end: true
|
|
137694
|
-
},
|
|
137695
|
-
layer.route =
|
|
137715
|
+
}, route2.dispatch.bind(route2));
|
|
137716
|
+
layer.route = route2;
|
|
137696
137717
|
this.stack.push(layer);
|
|
137697
|
-
return
|
|
137718
|
+
return route2;
|
|
137698
137719
|
};
|
|
137699
137720
|
methods.concat("all").forEach(function(method) {
|
|
137700
137721
|
proto[method] = function(path) {
|
|
@@ -137847,7 +137868,7 @@ var require_query = __commonJS((exports2, module2) => {
|
|
|
137847
137868
|
if (opts !== undefined && opts.allowPrototypes === undefined) {
|
|
137848
137869
|
opts.allowPrototypes = true;
|
|
137849
137870
|
}
|
|
137850
|
-
return function
|
|
137871
|
+
return function query2(req, res, next) {
|
|
137851
137872
|
if (!req.query) {
|
|
137852
137873
|
var val = parseUrl(req).query;
|
|
137853
137874
|
req.query = queryparse(val, opts);
|
|
@@ -137918,7 +137939,7 @@ var require_view = __commonJS((exports2, module2) => {
|
|
|
137918
137939
|
debug('render "%s"', this.path);
|
|
137919
137940
|
this.engine(this.path, options, callback);
|
|
137920
137941
|
};
|
|
137921
|
-
View.prototype.resolve = function
|
|
137942
|
+
View.prototype.resolve = function resolve2(dir, file) {
|
|
137922
137943
|
var ext = this.ext;
|
|
137923
137944
|
var path2 = join(dir, file);
|
|
137924
137945
|
var stat = tryStat(path2);
|
|
@@ -138870,7 +138891,7 @@ var require_send = __commonJS((exports2, module2) => {
|
|
|
138870
138891
|
}
|
|
138871
138892
|
}
|
|
138872
138893
|
util3.inherits(SendStream, Stream);
|
|
138873
|
-
SendStream.prototype.etag = deprecate.function(function
|
|
138894
|
+
SendStream.prototype.etag = deprecate.function(function etag2(val) {
|
|
138874
138895
|
this._etag = Boolean(val);
|
|
138875
138896
|
debug("etag %s", this._etag);
|
|
138876
138897
|
return this;
|
|
@@ -138882,9 +138903,9 @@ var require_send = __commonJS((exports2, module2) => {
|
|
|
138882
138903
|
return this;
|
|
138883
138904
|
}, "send.hidden: use dotfiles option");
|
|
138884
138905
|
SendStream.prototype.index = deprecate.function(function index(paths) {
|
|
138885
|
-
var
|
|
138906
|
+
var index2 = !paths ? [] : normalizeList(paths, "paths argument");
|
|
138886
138907
|
debug("index %o", paths);
|
|
138887
|
-
this._index =
|
|
138908
|
+
this._index = index2;
|
|
138888
138909
|
return this;
|
|
138889
138910
|
}, "send.index: pass index as option");
|
|
138890
138911
|
SendStream.prototype.root = function root(path2) {
|
|
@@ -139073,7 +139094,7 @@ var require_send = __commonJS((exports2, module2) => {
|
|
|
139073
139094
|
this.sendFile(path2);
|
|
139074
139095
|
return res;
|
|
139075
139096
|
};
|
|
139076
|
-
SendStream.prototype.send = function
|
|
139097
|
+
SendStream.prototype.send = function send2(path2, stat) {
|
|
139077
139098
|
var len = stat.size;
|
|
139078
139099
|
var options = this.options;
|
|
139079
139100
|
var opts = {};
|
|
@@ -139195,18 +139216,18 @@ var require_send = __commonJS((exports2, module2) => {
|
|
|
139195
139216
|
SendStream.prototype.stream = function stream(path2, options) {
|
|
139196
139217
|
var self2 = this;
|
|
139197
139218
|
var res = this.res;
|
|
139198
|
-
var
|
|
139199
|
-
this.emit("stream",
|
|
139200
|
-
|
|
139219
|
+
var stream2 = fs.createReadStream(path2, options);
|
|
139220
|
+
this.emit("stream", stream2);
|
|
139221
|
+
stream2.pipe(res);
|
|
139201
139222
|
function cleanup() {
|
|
139202
|
-
destroy(
|
|
139223
|
+
destroy(stream2, true);
|
|
139203
139224
|
}
|
|
139204
139225
|
onFinished(res, cleanup);
|
|
139205
|
-
|
|
139226
|
+
stream2.on("error", function onerror(err) {
|
|
139206
139227
|
cleanup();
|
|
139207
139228
|
self2.onStatError(err);
|
|
139208
139229
|
});
|
|
139209
|
-
|
|
139230
|
+
stream2.on("end", function onend() {
|
|
139210
139231
|
self2.emit("end");
|
|
139211
139232
|
});
|
|
139212
139233
|
};
|
|
@@ -139214,14 +139235,14 @@ var require_send = __commonJS((exports2, module2) => {
|
|
|
139214
139235
|
var res = this.res;
|
|
139215
139236
|
if (res.getHeader("Content-Type"))
|
|
139216
139237
|
return;
|
|
139217
|
-
var
|
|
139218
|
-
if (!
|
|
139238
|
+
var type2 = mime.lookup(path2);
|
|
139239
|
+
if (!type2) {
|
|
139219
139240
|
debug("no content-type");
|
|
139220
139241
|
return;
|
|
139221
139242
|
}
|
|
139222
|
-
var charset = mime.charsets.lookup(
|
|
139223
|
-
debug("content-type %s",
|
|
139224
|
-
res.setHeader("Content-Type",
|
|
139243
|
+
var charset = mime.charsets.lookup(type2);
|
|
139244
|
+
debug("content-type %s", type2);
|
|
139245
|
+
res.setHeader("Content-Type", type2 + (charset ? "; charset=" + charset : ""));
|
|
139225
139246
|
};
|
|
139226
139247
|
SendStream.prototype.setHeader = function setHeader(path2, stat) {
|
|
139227
139248
|
var res = this.res;
|
|
@@ -141249,10 +141270,10 @@ var require_request = __commonJS((exports2, module2) => {
|
|
|
141249
141270
|
};
|
|
141250
141271
|
req.acceptsLanguage = deprecate.function(req.acceptsLanguages, "req.acceptsLanguage: Use acceptsLanguages instead");
|
|
141251
141272
|
req.range = function range(size, options) {
|
|
141252
|
-
var
|
|
141253
|
-
if (!
|
|
141273
|
+
var range2 = this.get("Range");
|
|
141274
|
+
if (!range2)
|
|
141254
141275
|
return;
|
|
141255
|
-
return parseRange(size,
|
|
141276
|
+
return parseRange(size, range2, options);
|
|
141256
141277
|
};
|
|
141257
141278
|
req.param = function param(name, defaultValue) {
|
|
141258
141279
|
var params = this.params || {};
|
|
@@ -141306,8 +141327,8 @@ var require_request = __commonJS((exports2, module2) => {
|
|
|
141306
141327
|
if (!hostname)
|
|
141307
141328
|
return [];
|
|
141308
141329
|
var offset = this.app.get("subdomain offset");
|
|
141309
|
-
var
|
|
141310
|
-
return
|
|
141330
|
+
var subdomains2 = !isIP(hostname) ? hostname.split(".").reverse() : [hostname];
|
|
141331
|
+
return subdomains2.slice(offset);
|
|
141311
141332
|
});
|
|
141312
141333
|
defineGetter(req, "path", function path() {
|
|
141313
141334
|
return parse(this).pathname;
|
|
@@ -141603,7 +141624,7 @@ var require_response = __commonJS((exports2, module2) => {
|
|
|
141603
141624
|
return "<" + links[rel] + '>; rel="' + rel + '"';
|
|
141604
141625
|
}).join(", "));
|
|
141605
141626
|
};
|
|
141606
|
-
res.send = function
|
|
141627
|
+
res.send = function send2(body) {
|
|
141607
141628
|
var chunk = body;
|
|
141608
141629
|
var encoding;
|
|
141609
141630
|
var req = this.req;
|
|
@@ -141847,7 +141868,7 @@ var require_response = __commonJS((exports2, module2) => {
|
|
|
141847
141868
|
var fullPath = !opts.root ? resolve(path2) : path2;
|
|
141848
141869
|
return this.sendFile(fullPath, opts, done);
|
|
141849
141870
|
};
|
|
141850
|
-
res.contentType = res.type = function
|
|
141871
|
+
res.contentType = res.type = function contentType2(type) {
|
|
141851
141872
|
var ct = type.indexOf("/") === -1 ? mime.lookup(type) : type;
|
|
141852
141873
|
return this.set("Content-Type", ct);
|
|
141853
141874
|
};
|
|
@@ -142145,7 +142166,7 @@ var require_serve_static = __commonJS((exports2, module2) => {
|
|
|
142145
142166
|
opts.maxage = opts.maxage || opts.maxAge || 0;
|
|
142146
142167
|
opts.root = resolve(root);
|
|
142147
142168
|
var onDirectory = redirect ? createRedirectDirectoryListener() : createNotFoundDirectoryListener();
|
|
142148
|
-
return function
|
|
142169
|
+
return function serveStatic2(req, res, next) {
|
|
142149
142170
|
if (req.method !== "GET" && req.method !== "HEAD") {
|
|
142150
142171
|
if (fallthrough) {
|
|
142151
142172
|
return next();
|
|
@@ -143271,7 +143292,7 @@ var require_web_incoming = __commonJS((exports2, module2) => {
|
|
|
143271
143292
|
req.on("error", proxyError);
|
|
143272
143293
|
proxyReq.on("error", proxyError);
|
|
143273
143294
|
function createErrorHandler(proxyReq2, url) {
|
|
143274
|
-
return function
|
|
143295
|
+
return function proxyError2(err) {
|
|
143275
143296
|
if (req.socket.destroyed && err.code === "ECONNRESET") {
|
|
143276
143297
|
server.emit("econnreset", err, req, res, url);
|
|
143277
143298
|
return proxyReq2.abort();
|
|
@@ -149180,13 +149201,13 @@ var require_util10 = __commonJS((exports2) => {
|
|
|
149180
149201
|
}
|
|
149181
149202
|
}
|
|
149182
149203
|
exports2.LRUCache = LRUCache;
|
|
149183
|
-
_LRUCache_cache = new WeakMap, _LRUCache_instances = new WeakSet, _LRUCache_moveToEnd = function
|
|
149204
|
+
_LRUCache_cache = new WeakMap, _LRUCache_instances = new WeakSet, _LRUCache_moveToEnd = function _LRUCache_moveToEnd2(key, value) {
|
|
149184
149205
|
__classPrivateFieldGet(this, _LRUCache_cache, "f").delete(key);
|
|
149185
149206
|
__classPrivateFieldGet(this, _LRUCache_cache, "f").set(key, {
|
|
149186
149207
|
value,
|
|
149187
149208
|
lastAccessed: Date.now()
|
|
149188
149209
|
});
|
|
149189
|
-
}, _LRUCache_evict = function
|
|
149210
|
+
}, _LRUCache_evict = function _LRUCache_evict2() {
|
|
149190
149211
|
const cutoffDate = this.maxAge ? Date.now() - this.maxAge : 0;
|
|
149191
149212
|
let oldestItem = __classPrivateFieldGet(this, _LRUCache_cache, "f").entries().next();
|
|
149192
149213
|
while (!oldestItem.done && (__classPrivateFieldGet(this, _LRUCache_cache, "f").size > this.capacity || oldestItem.value[1].lastAccessed < cutoffDate)) {
|
|
@@ -150239,12 +150260,12 @@ var require_jwa = __commonJS((exports2, module2) => {
|
|
|
150239
150260
|
};
|
|
150240
150261
|
}
|
|
150241
150262
|
var bufferEqual;
|
|
150242
|
-
var timingSafeEqual = "timingSafeEqual" in crypto3 ? function
|
|
150263
|
+
var timingSafeEqual = "timingSafeEqual" in crypto3 ? function timingSafeEqual2(a, b) {
|
|
150243
150264
|
if (a.byteLength !== b.byteLength) {
|
|
150244
150265
|
return false;
|
|
150245
150266
|
}
|
|
150246
150267
|
return crypto3.timingSafeEqual(a, b);
|
|
150247
|
-
} : function
|
|
150268
|
+
} : function timingSafeEqual2(a, b) {
|
|
150248
150269
|
if (!bufferEqual) {
|
|
150249
150270
|
bufferEqual = require_buffer_equal_constant_time();
|
|
150250
150271
|
}
|
|
@@ -150358,7 +150379,7 @@ var require_jwa = __commonJS((exports2, module2) => {
|
|
|
150358
150379
|
// ../../node_modules/jws/lib/tostring.js
|
|
150359
150380
|
var require_tostring = __commonJS((exports2, module2) => {
|
|
150360
150381
|
var Buffer2 = require("buffer").Buffer;
|
|
150361
|
-
module2.exports = function
|
|
150382
|
+
module2.exports = function toString3(obj) {
|
|
150362
150383
|
if (typeof obj === "string")
|
|
150363
150384
|
return obj;
|
|
150364
150385
|
if (typeof obj === "number" || Buffer2.isBuffer(obj))
|
|
@@ -150710,7 +150731,7 @@ var require_src113 = __commonJS((exports2) => {
|
|
|
150710
150731
|
}
|
|
150711
150732
|
}
|
|
150712
150733
|
exports2.GoogleToken = GoogleToken;
|
|
150713
|
-
_GoogleToken_inFlightRequest = new WeakMap, _GoogleToken_instances = new WeakSet, _GoogleToken_getTokenAsync = async function
|
|
150734
|
+
_GoogleToken_inFlightRequest = new WeakMap, _GoogleToken_instances = new WeakSet, _GoogleToken_getTokenAsync = async function _GoogleToken_getTokenAsync2(opts) {
|
|
150714
150735
|
if (__classPrivateFieldGet(this, _GoogleToken_inFlightRequest, "f") && !opts.forceRefresh) {
|
|
150715
150736
|
return __classPrivateFieldGet(this, _GoogleToken_inFlightRequest, "f");
|
|
150716
150737
|
}
|
|
@@ -150719,7 +150740,7 @@ var require_src113 = __commonJS((exports2) => {
|
|
|
150719
150740
|
} finally {
|
|
150720
150741
|
__classPrivateFieldSet(this, _GoogleToken_inFlightRequest, undefined, "f");
|
|
150721
150742
|
}
|
|
150722
|
-
}, _GoogleToken_getTokenAsyncInner = async function
|
|
150743
|
+
}, _GoogleToken_getTokenAsyncInner = async function _GoogleToken_getTokenAsyncInner2(opts) {
|
|
150723
150744
|
if (this.isTokenExpiring() === false && opts.forceRefresh === false) {
|
|
150724
150745
|
return Promise.resolve(this.rawToken);
|
|
150725
150746
|
}
|
|
@@ -150735,11 +150756,11 @@ var require_src113 = __commonJS((exports2) => {
|
|
|
150735
150756
|
}
|
|
150736
150757
|
}
|
|
150737
150758
|
return __classPrivateFieldGet(this, _GoogleToken_instances, "m", _GoogleToken_requestToken).call(this);
|
|
150738
|
-
}, _GoogleToken_ensureEmail = function
|
|
150759
|
+
}, _GoogleToken_ensureEmail = function _GoogleToken_ensureEmail2() {
|
|
150739
150760
|
if (!this.iss) {
|
|
150740
150761
|
throw new ErrorWithCode("email is required.", "MISSING_CREDENTIALS");
|
|
150741
150762
|
}
|
|
150742
|
-
}, _GoogleToken_revokeTokenAsync = async function
|
|
150763
|
+
}, _GoogleToken_revokeTokenAsync = async function _GoogleToken_revokeTokenAsync2() {
|
|
150743
150764
|
if (!this.accessToken) {
|
|
150744
150765
|
throw new Error("No token to revoke.");
|
|
150745
150766
|
}
|
|
@@ -150756,7 +150777,7 @@ var require_src113 = __commonJS((exports2) => {
|
|
|
150756
150777
|
scope: this.scope,
|
|
150757
150778
|
additionalClaims: this.additionalClaims
|
|
150758
150779
|
});
|
|
150759
|
-
}, _GoogleToken_configure = function
|
|
150780
|
+
}, _GoogleToken_configure = function _GoogleToken_configure2(options = {}) {
|
|
150760
150781
|
this.keyFile = options.keyFile;
|
|
150761
150782
|
this.key = options.key;
|
|
150762
150783
|
this.rawToken = undefined;
|
|
@@ -150772,7 +150793,7 @@ var require_src113 = __commonJS((exports2) => {
|
|
|
150772
150793
|
if (options.transporter) {
|
|
150773
150794
|
this.transporter = options.transporter;
|
|
150774
150795
|
}
|
|
150775
|
-
}, _GoogleToken_requestToken = async function
|
|
150796
|
+
}, _GoogleToken_requestToken = async function _GoogleToken_requestToken2() {
|
|
150776
150797
|
var _a, _b;
|
|
150777
150798
|
const iat = Math.floor(new Date().getTime() / 1000);
|
|
150778
150799
|
const additionalClaims = this.additionalClaims || {};
|
|
@@ -151769,7 +151790,7 @@ var require_baseexternalclient = __commonJS((exports2) => {
|
|
|
151769
151790
|
}
|
|
151770
151791
|
}
|
|
151771
151792
|
exports2.BaseExternalAccountClient = BaseExternalAccountClient;
|
|
151772
|
-
_BaseExternalAccountClient_pendingAccessToken = new WeakMap, _BaseExternalAccountClient_instances = new WeakSet, _BaseExternalAccountClient_internalRefreshAccessTokenAsync = async function
|
|
151793
|
+
_BaseExternalAccountClient_pendingAccessToken = new WeakMap, _BaseExternalAccountClient_instances = new WeakSet, _BaseExternalAccountClient_internalRefreshAccessTokenAsync = async function _BaseExternalAccountClient_internalRefreshAccessTokenAsync2() {
|
|
151773
151794
|
const subjectToken = await this.retrieveSubjectToken();
|
|
151774
151795
|
const stsCredentialsOptions = {
|
|
151775
151796
|
grantType: STS_GRANT_TYPE,
|
|
@@ -152146,7 +152167,7 @@ var require_defaultawssecuritycredentialssupplier = __commonJS((exports2) => {
|
|
|
152146
152167
|
}
|
|
152147
152168
|
}
|
|
152148
152169
|
exports2.DefaultAwsSecurityCredentialsSupplier = DefaultAwsSecurityCredentialsSupplier;
|
|
152149
|
-
_DefaultAwsSecurityCredentialsSupplier_instances = new WeakSet, _DefaultAwsSecurityCredentialsSupplier_getImdsV2SessionToken = async function
|
|
152170
|
+
_DefaultAwsSecurityCredentialsSupplier_instances = new WeakSet, _DefaultAwsSecurityCredentialsSupplier_getImdsV2SessionToken = async function _DefaultAwsSecurityCredentialsSupplier_getImdsV2SessionToken2(transporter) {
|
|
152150
152171
|
const opts = {
|
|
152151
152172
|
...this.additionalGaxiosOptions,
|
|
152152
152173
|
url: this.imdsV2SessionTokenUrl,
|
|
@@ -152156,7 +152177,7 @@ var require_defaultawssecuritycredentialssupplier = __commonJS((exports2) => {
|
|
|
152156
152177
|
};
|
|
152157
152178
|
const response = await transporter.request(opts);
|
|
152158
152179
|
return response.data;
|
|
152159
|
-
}, _DefaultAwsSecurityCredentialsSupplier_getAwsRoleName = async function
|
|
152180
|
+
}, _DefaultAwsSecurityCredentialsSupplier_getAwsRoleName = async function _DefaultAwsSecurityCredentialsSupplier_getAwsRoleName2(headers, transporter) {
|
|
152160
152181
|
if (!this.securityCredentialsUrl) {
|
|
152161
152182
|
throw new Error("Unable to determine AWS role name due to missing " + '"options.credential_source.url"');
|
|
152162
152183
|
}
|
|
@@ -152169,7 +152190,7 @@ var require_defaultawssecuritycredentialssupplier = __commonJS((exports2) => {
|
|
|
152169
152190
|
};
|
|
152170
152191
|
const response = await transporter.request(opts);
|
|
152171
152192
|
return response.data;
|
|
152172
|
-
}, _DefaultAwsSecurityCredentialsSupplier_retrieveAwsSecurityCredentials = async function
|
|
152193
|
+
}, _DefaultAwsSecurityCredentialsSupplier_retrieveAwsSecurityCredentials = async function _DefaultAwsSecurityCredentialsSupplier_retrieveAwsSecurityCredentials2(roleName, headers, transporter) {
|
|
152173
152194
|
const response = await transporter.request({
|
|
152174
152195
|
...this.additionalGaxiosOptions,
|
|
152175
152196
|
url: `${this.securityCredentialsUrl}/${roleName}`,
|
|
@@ -152177,9 +152198,9 @@ var require_defaultawssecuritycredentialssupplier = __commonJS((exports2) => {
|
|
|
152177
152198
|
headers
|
|
152178
152199
|
});
|
|
152179
152200
|
return response.data;
|
|
152180
|
-
}, _DefaultAwsSecurityCredentialsSupplier_regionFromEnv_get = function
|
|
152201
|
+
}, _DefaultAwsSecurityCredentialsSupplier_regionFromEnv_get = function _DefaultAwsSecurityCredentialsSupplier_regionFromEnv_get2() {
|
|
152181
152202
|
return process.env["AWS_REGION"] || process.env["AWS_DEFAULT_REGION"] || null;
|
|
152182
|
-
}, _DefaultAwsSecurityCredentialsSupplier_securityCredentialsFromEnv_get = function
|
|
152203
|
+
}, _DefaultAwsSecurityCredentialsSupplier_securityCredentialsFromEnv_get = function _DefaultAwsSecurityCredentialsSupplier_securityCredentialsFromEnv_get2() {
|
|
152183
152204
|
if (process.env["AWS_ACCESS_KEY_ID"] && process.env["AWS_SECRET_ACCESS_KEY"]) {
|
|
152184
152205
|
return {
|
|
152185
152206
|
accessKeyId: process.env["AWS_ACCESS_KEY_ID"],
|
|
@@ -153286,14 +153307,14 @@ var require_googleauth = __commonJS((exports2) => {
|
|
|
153286
153307
|
}
|
|
153287
153308
|
}
|
|
153288
153309
|
exports2.GoogleAuth = GoogleAuth;
|
|
153289
|
-
_GoogleAuth_pendingAuthClient = new WeakMap, _GoogleAuth_instances = new WeakSet, _GoogleAuth_prepareAndCacheClient = async function
|
|
153310
|
+
_GoogleAuth_pendingAuthClient = new WeakMap, _GoogleAuth_instances = new WeakSet, _GoogleAuth_prepareAndCacheClient = async function _GoogleAuth_prepareAndCacheClient2(credential, quotaProjectIdOverride = process.env["GOOGLE_CLOUD_QUOTA_PROJECT"] || null) {
|
|
153290
153311
|
const projectId = await this.getProjectIdOptional();
|
|
153291
153312
|
if (quotaProjectIdOverride) {
|
|
153292
153313
|
credential.quotaProjectId = quotaProjectIdOverride;
|
|
153293
153314
|
}
|
|
153294
153315
|
this.cachedCredential = credential;
|
|
153295
153316
|
return { credential, projectId };
|
|
153296
|
-
}, _GoogleAuth_determineClient = async function
|
|
153317
|
+
}, _GoogleAuth_determineClient = async function _GoogleAuth_determineClient2() {
|
|
153297
153318
|
if (this.jsonContent) {
|
|
153298
153319
|
return this._cacheClientFromJSON(this.jsonContent, this.clientOptions);
|
|
153299
153320
|
} else if (this.keyFilename) {
|
|
@@ -156107,7 +156128,7 @@ var require__stream_writable3 = __commonJS((exports2, module2) => {
|
|
|
156107
156128
|
}
|
|
156108
156129
|
});
|
|
156109
156130
|
} else {
|
|
156110
|
-
realHasInstance = function
|
|
156131
|
+
realHasInstance = function realHasInstance2(object) {
|
|
156111
156132
|
return object instanceof this;
|
|
156112
156133
|
};
|
|
156113
156134
|
}
|
|
@@ -156591,28 +156612,28 @@ var require_end_of_stream3 = __commonJS((exports2, module2) => {
|
|
|
156591
156612
|
callback = once(callback || noop2);
|
|
156592
156613
|
var readable = opts.readable || opts.readable !== false && stream4.readable;
|
|
156593
156614
|
var writable = opts.writable || opts.writable !== false && stream4.writable;
|
|
156594
|
-
var onlegacyfinish = function
|
|
156615
|
+
var onlegacyfinish = function onlegacyfinish2() {
|
|
156595
156616
|
if (!stream4.writable)
|
|
156596
156617
|
onfinish();
|
|
156597
156618
|
};
|
|
156598
156619
|
var writableEnded = stream4._writableState && stream4._writableState.finished;
|
|
156599
|
-
var onfinish = function
|
|
156620
|
+
var onfinish = function onfinish2() {
|
|
156600
156621
|
writable = false;
|
|
156601
156622
|
writableEnded = true;
|
|
156602
156623
|
if (!readable)
|
|
156603
156624
|
callback.call(stream4);
|
|
156604
156625
|
};
|
|
156605
156626
|
var readableEnded = stream4._readableState && stream4._readableState.endEmitted;
|
|
156606
|
-
var onend = function
|
|
156627
|
+
var onend = function onend2() {
|
|
156607
156628
|
readable = false;
|
|
156608
156629
|
readableEnded = true;
|
|
156609
156630
|
if (!writable)
|
|
156610
156631
|
callback.call(stream4);
|
|
156611
156632
|
};
|
|
156612
|
-
var onerror = function
|
|
156633
|
+
var onerror = function onerror2(err) {
|
|
156613
156634
|
callback.call(stream4, err);
|
|
156614
156635
|
};
|
|
156615
|
-
var onclose = function
|
|
156636
|
+
var onclose = function onclose2() {
|
|
156616
156637
|
var err;
|
|
156617
156638
|
if (readable && !readableEnded) {
|
|
156618
156639
|
if (!stream4._readableState || !stream4._readableState.ended)
|
|
@@ -156625,7 +156646,7 @@ var require_end_of_stream3 = __commonJS((exports2, module2) => {
|
|
|
156625
156646
|
return callback.call(stream4, err);
|
|
156626
156647
|
}
|
|
156627
156648
|
};
|
|
156628
|
-
var onrequest = function
|
|
156649
|
+
var onrequest = function onrequest2() {
|
|
156629
156650
|
stream4.req.on("finish", onfinish);
|
|
156630
156651
|
};
|
|
156631
156652
|
if (isRequest2(stream4)) {
|
|
@@ -156782,7 +156803,7 @@ var require_async_iterator3 = __commonJS((exports2, module2) => {
|
|
|
156782
156803
|
});
|
|
156783
156804
|
});
|
|
156784
156805
|
}), _Object$setPrototypeO), AsyncIteratorPrototype);
|
|
156785
|
-
var createReadableStreamAsyncIterator = function
|
|
156806
|
+
var createReadableStreamAsyncIterator = function createReadableStreamAsyncIterator2(stream4) {
|
|
156786
156807
|
var _Object$create;
|
|
156787
156808
|
var iterator2 = Object.create(ReadableStreamAsyncIteratorPrototype, (_Object$create = {}, _defineProperty(_Object$create, kStream, {
|
|
156788
156809
|
value: stream4,
|
|
@@ -156971,7 +156992,7 @@ var require__stream_readable3 = __commonJS((exports2, module2) => {
|
|
|
156971
156992
|
var Duplex;
|
|
156972
156993
|
Readable2.ReadableState = ReadableState;
|
|
156973
156994
|
var EE = require("events").EventEmitter;
|
|
156974
|
-
var EElistenerCount = function
|
|
156995
|
+
var EElistenerCount = function EElistenerCount2(emitter, type) {
|
|
156975
156996
|
return emitter.listeners(type).length;
|
|
156976
156997
|
};
|
|
156977
156998
|
var Stream = require_stream4();
|
|
@@ -156988,7 +157009,7 @@ var require__stream_readable3 = __commonJS((exports2, module2) => {
|
|
|
156988
157009
|
if (debugUtil && debugUtil.debuglog) {
|
|
156989
157010
|
debug = debugUtil.debuglog("stream");
|
|
156990
157011
|
} else {
|
|
156991
|
-
debug = function
|
|
157012
|
+
debug = function debug2() {};
|
|
156992
157013
|
}
|
|
156993
157014
|
var BufferList = require_buffer_list3();
|
|
156994
157015
|
var destroyImpl = require_destroy4();
|
|
@@ -167596,7 +167617,7 @@ var require_serde = __commonJS((exports2) => {
|
|
|
167596
167617
|
}
|
|
167597
167618
|
return value.slice(idx);
|
|
167598
167619
|
};
|
|
167599
|
-
var LazyJsonString = function
|
|
167620
|
+
var LazyJsonString = function LazyJsonString2(val) {
|
|
167600
167621
|
const str = Object.assign(new String(val), {
|
|
167601
167622
|
deserializeJSON() {
|
|
167602
167623
|
return JSON.parse(String(val));
|
|
@@ -169137,7 +169158,7 @@ var require_dist_cjs17 = __commonJS((exports2) => {
|
|
|
169137
169158
|
return httpRequest;
|
|
169138
169159
|
}
|
|
169139
169160
|
}
|
|
169140
|
-
var createIsIdentityExpiredFunction = (expirationMs) => function
|
|
169161
|
+
var createIsIdentityExpiredFunction = (expirationMs) => function isIdentityExpired2(identity) {
|
|
169141
169162
|
return doesIdentityRequireRefresh(identity) && identity.expiration.getTime() - Date.now() < expirationMs;
|
|
169142
169163
|
};
|
|
169143
169164
|
var EXPIRATION_MS = 300000;
|
|
@@ -199494,25 +199515,25 @@ var require_minimatch = __commonJS((exports2, module2) => {
|
|
|
199494
199515
|
return minimatch;
|
|
199495
199516
|
}
|
|
199496
199517
|
var orig = minimatch;
|
|
199497
|
-
var m = function
|
|
199518
|
+
var m = function minimatch2(p, pattern, options) {
|
|
199498
199519
|
return orig(p, pattern, ext(def, options));
|
|
199499
199520
|
};
|
|
199500
|
-
m.Minimatch = function
|
|
199521
|
+
m.Minimatch = function Minimatch2(pattern, options) {
|
|
199501
199522
|
return new orig.Minimatch(pattern, ext(def, options));
|
|
199502
199523
|
};
|
|
199503
|
-
m.Minimatch.defaults = function
|
|
199524
|
+
m.Minimatch.defaults = function defaults2(options) {
|
|
199504
199525
|
return orig.defaults(ext(def, options)).Minimatch;
|
|
199505
199526
|
};
|
|
199506
|
-
m.filter = function
|
|
199527
|
+
m.filter = function filter3(pattern, options) {
|
|
199507
199528
|
return orig.filter(pattern, ext(def, options));
|
|
199508
199529
|
};
|
|
199509
|
-
m.defaults = function
|
|
199530
|
+
m.defaults = function defaults2(options) {
|
|
199510
199531
|
return orig.defaults(ext(def, options));
|
|
199511
199532
|
};
|
|
199512
|
-
m.makeRe = function
|
|
199533
|
+
m.makeRe = function makeRe2(pattern, options) {
|
|
199513
199534
|
return orig.makeRe(pattern, ext(def, options));
|
|
199514
199535
|
};
|
|
199515
|
-
m.braceExpand = function
|
|
199536
|
+
m.braceExpand = function braceExpand2(pattern, options) {
|
|
199516
199537
|
return orig.braceExpand(pattern, ext(def, options));
|
|
199517
199538
|
};
|
|
199518
199539
|
m.match = function(list, pattern, options) {
|
|
@@ -199569,7 +199590,7 @@ var require_minimatch = __commonJS((exports2, module2) => {
|
|
|
199569
199590
|
this.parseNegate();
|
|
199570
199591
|
var set = this.globSet = this.braceExpand();
|
|
199571
199592
|
if (options.debug)
|
|
199572
|
-
this.debug = function
|
|
199593
|
+
this.debug = function debug2() {
|
|
199573
199594
|
console.error.apply(console, arguments);
|
|
199574
199595
|
};
|
|
199575
199596
|
this.debug(this.pattern, set);
|
|
@@ -199675,7 +199696,7 @@ var require_minimatch = __commonJS((exports2, module2) => {
|
|
|
199675
199696
|
}
|
|
199676
199697
|
}
|
|
199677
199698
|
for (var i = 0, len = pattern.length, c;i < len && (c = pattern.charAt(i)); i++) {
|
|
199678
|
-
this.debug("%s
|
|
199699
|
+
this.debug("%s\t%s %s %j", pattern, i, re, c);
|
|
199679
199700
|
if (escaping && reSpecials[c]) {
|
|
199680
199701
|
re += "\\" + c;
|
|
199681
199702
|
escaping = false;
|
|
@@ -199694,7 +199715,7 @@ var require_minimatch = __commonJS((exports2, module2) => {
|
|
|
199694
199715
|
case "+":
|
|
199695
199716
|
case "@":
|
|
199696
199717
|
case "!":
|
|
199697
|
-
this.debug("%s
|
|
199718
|
+
this.debug("%s\t%s %s %j <-- stateChar", pattern, i, re, c);
|
|
199698
199719
|
if (inClass) {
|
|
199699
199720
|
this.debug(" in class");
|
|
199700
199721
|
if (c === "!" && i === classStart + 1)
|
|
@@ -200278,10 +200299,10 @@ var require_uri_all = __commonJS((exports2, module2) => {
|
|
|
200278
200299
|
}
|
|
200279
200300
|
return output;
|
|
200280
200301
|
}
|
|
200281
|
-
var ucs2encode = function
|
|
200302
|
+
var ucs2encode = function ucs2encode2(array) {
|
|
200282
200303
|
return String.fromCodePoint.apply(String, toConsumableArray(array));
|
|
200283
200304
|
};
|
|
200284
|
-
var basicToDigit = function
|
|
200305
|
+
var basicToDigit = function basicToDigit2(codePoint) {
|
|
200285
200306
|
if (codePoint - 48 < 10) {
|
|
200286
200307
|
return codePoint - 22;
|
|
200287
200308
|
}
|
|
@@ -200293,10 +200314,10 @@ var require_uri_all = __commonJS((exports2, module2) => {
|
|
|
200293
200314
|
}
|
|
200294
200315
|
return base;
|
|
200295
200316
|
};
|
|
200296
|
-
var digitToBasic = function
|
|
200317
|
+
var digitToBasic = function digitToBasic2(digit, flag) {
|
|
200297
200318
|
return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
|
|
200298
200319
|
};
|
|
200299
|
-
var adapt = function
|
|
200320
|
+
var adapt = function adapt2(delta, numPoints, firstTime) {
|
|
200300
200321
|
var k = 0;
|
|
200301
200322
|
delta = firstTime ? floor(delta / damp) : delta >> 1;
|
|
200302
200323
|
delta += floor(delta / numPoints);
|
|
@@ -200305,7 +200326,7 @@ var require_uri_all = __commonJS((exports2, module2) => {
|
|
|
200305
200326
|
}
|
|
200306
200327
|
return floor(k + (baseMinusTMin + 1) * delta / (delta + skew));
|
|
200307
200328
|
};
|
|
200308
|
-
var decode = function
|
|
200329
|
+
var decode = function decode2(input) {
|
|
200309
200330
|
var output = [];
|
|
200310
200331
|
var inputLength = input.length;
|
|
200311
200332
|
var i = 0;
|
|
@@ -200353,7 +200374,7 @@ var require_uri_all = __commonJS((exports2, module2) => {
|
|
|
200353
200374
|
}
|
|
200354
200375
|
return String.fromCodePoint.apply(String, output);
|
|
200355
200376
|
};
|
|
200356
|
-
var encode3 = function
|
|
200377
|
+
var encode3 = function encode4(input) {
|
|
200357
200378
|
var output = [];
|
|
200358
200379
|
input = ucs2decode(input);
|
|
200359
200380
|
var inputLength = input.length;
|
|
@@ -200467,12 +200488,12 @@ var require_uri_all = __commonJS((exports2, module2) => {
|
|
|
200467
200488
|
}
|
|
200468
200489
|
return output.join("");
|
|
200469
200490
|
};
|
|
200470
|
-
var toUnicode = function
|
|
200491
|
+
var toUnicode = function toUnicode2(input) {
|
|
200471
200492
|
return mapDomain(input, function(string) {
|
|
200472
200493
|
return regexPunycode.test(string) ? decode(string.slice(4).toLowerCase()) : string;
|
|
200473
200494
|
});
|
|
200474
200495
|
};
|
|
200475
|
-
var toASCII = function
|
|
200496
|
+
var toASCII = function toASCII2(input) {
|
|
200476
200497
|
return mapDomain(input, function(string) {
|
|
200477
200498
|
return regexNonASCII.test(string) ? "xn--" + encode3(string) : string;
|
|
200478
200499
|
});
|
|
@@ -200869,13 +200890,13 @@ var require_uri_all = __commonJS((exports2, module2) => {
|
|
|
200869
200890
|
var handler = {
|
|
200870
200891
|
scheme: "http",
|
|
200871
200892
|
domainHost: true,
|
|
200872
|
-
parse: function
|
|
200893
|
+
parse: function parse2(components, options) {
|
|
200873
200894
|
if (!components.host) {
|
|
200874
200895
|
components.error = components.error || "HTTP URIs must have a host.";
|
|
200875
200896
|
}
|
|
200876
200897
|
return components;
|
|
200877
200898
|
},
|
|
200878
|
-
serialize: function
|
|
200899
|
+
serialize: function serialize2(components, options) {
|
|
200879
200900
|
var secure = String(components.scheme).toLowerCase() === "https";
|
|
200880
200901
|
if (components.port === (secure ? 443 : 80) || components.port === "") {
|
|
200881
200902
|
components.port = undefined;
|
|
@@ -200898,7 +200919,7 @@ var require_uri_all = __commonJS((exports2, module2) => {
|
|
|
200898
200919
|
var handler$2 = {
|
|
200899
200920
|
scheme: "ws",
|
|
200900
200921
|
domainHost: true,
|
|
200901
|
-
parse: function
|
|
200922
|
+
parse: function parse2(components, options) {
|
|
200902
200923
|
var wsComponents = components;
|
|
200903
200924
|
wsComponents.secure = isSecure(wsComponents);
|
|
200904
200925
|
wsComponents.resourceName = (wsComponents.path || "/") + (wsComponents.query ? "?" + wsComponents.query : "");
|
|
@@ -200906,7 +200927,7 @@ var require_uri_all = __commonJS((exports2, module2) => {
|
|
|
200906
200927
|
wsComponents.query = undefined;
|
|
200907
200928
|
return wsComponents;
|
|
200908
200929
|
},
|
|
200909
|
-
serialize: function
|
|
200930
|
+
serialize: function serialize2(wsComponents, options) {
|
|
200910
200931
|
if (wsComponents.port === (isSecure(wsComponents) ? 443 : 80) || wsComponents.port === "") {
|
|
200911
200932
|
wsComponents.port = undefined;
|
|
200912
200933
|
}
|
|
@@ -201074,7 +201095,7 @@ var require_uri_all = __commonJS((exports2, module2) => {
|
|
|
201074
201095
|
var UUID = /^[0-9A-Fa-f]{8}(?:\-[0-9A-Fa-f]{4}){3}\-[0-9A-Fa-f]{12}$/;
|
|
201075
201096
|
var handler$6 = {
|
|
201076
201097
|
scheme: "urn:uuid",
|
|
201077
|
-
parse: function
|
|
201098
|
+
parse: function parse2(urnComponents, options) {
|
|
201078
201099
|
var uuidComponents = urnComponents;
|
|
201079
201100
|
uuidComponents.uuid = uuidComponents.nss;
|
|
201080
201101
|
uuidComponents.nss = undefined;
|
|
@@ -201083,7 +201104,7 @@ var require_uri_all = __commonJS((exports2, module2) => {
|
|
|
201083
201104
|
}
|
|
201084
201105
|
return uuidComponents;
|
|
201085
201106
|
},
|
|
201086
|
-
serialize: function
|
|
201107
|
+
serialize: function serialize2(uuidComponents, options) {
|
|
201087
201108
|
var urnComponents = uuidComponents;
|
|
201088
201109
|
urnComponents.nss = (uuidComponents.uuid || "").toLowerCase();
|
|
201089
201110
|
return urnComponents;
|
|
@@ -202529,7 +202550,7 @@ var require_compile2 = __commonJS((exports2, module2) => {
|
|
|
202529
202550
|
|
|
202530
202551
|
// ../../node_modules/@modelcontextprotocol/sdk/node_modules/ajv/lib/cache.js
|
|
202531
202552
|
var require_cache = __commonJS((exports2, module2) => {
|
|
202532
|
-
var Cache = module2.exports = function
|
|
202553
|
+
var Cache = module2.exports = function Cache2() {
|
|
202533
202554
|
this._cache = {};
|
|
202534
202555
|
};
|
|
202535
202556
|
Cache.prototype.put = function Cache_put(key, value) {
|
|
@@ -206311,7 +206332,7 @@ var require_utils75 = __commonJS((exports2) => {
|
|
|
206311
206332
|
}
|
|
206312
206333
|
var toString3 = Object.prototype.toString;
|
|
206313
206334
|
exports2.toString = toString3;
|
|
206314
|
-
var isFunction3 = function
|
|
206335
|
+
var isFunction3 = function isFunction4(value) {
|
|
206315
206336
|
return typeof value === "function";
|
|
206316
206337
|
};
|
|
206317
206338
|
if (isFunction3(/x/)) {
|
|
@@ -206965,7 +206986,7 @@ var require_wrapHelper = __commonJS((exports2) => {
|
|
|
206965
206986
|
if (typeof helper !== "function") {
|
|
206966
206987
|
return helper;
|
|
206967
206988
|
}
|
|
206968
|
-
var wrapper = function
|
|
206989
|
+
var wrapper = function wrapper2() {
|
|
206969
206990
|
var options = arguments[arguments.length - 1];
|
|
206970
206991
|
arguments[arguments.length - 1] = transformOptionsFn(options);
|
|
206971
206992
|
return helper.apply(this, arguments);
|
|
@@ -208629,7 +208650,7 @@ var require_compiler = __commonJS((exports2) => {
|
|
|
208629
208650
|
return true;
|
|
208630
208651
|
},
|
|
208631
208652
|
guid: 0,
|
|
208632
|
-
compile: function
|
|
208653
|
+
compile: function compile2(program, options) {
|
|
208633
208654
|
this.sourceNode = [];
|
|
208634
208655
|
this.opcodes = [];
|
|
208635
208656
|
this.children = [];
|
|
@@ -210718,7 +210739,7 @@ var require_code_gen = __commonJS((exports2, module2) => {
|
|
|
210718
210739
|
toStringWithSourceMap: function toStringWithSourceMap() {
|
|
210719
210740
|
return { code: this.toString() };
|
|
210720
210741
|
},
|
|
210721
|
-
toString: function
|
|
210742
|
+
toString: function toString3() {
|
|
210722
210743
|
return this.src;
|
|
210723
210744
|
}
|
|
210724
210745
|
};
|
|
@@ -210749,7 +210770,7 @@ var require_code_gen = __commonJS((exports2, module2) => {
|
|
|
210749
210770
|
push: function push(source, loc) {
|
|
210750
210771
|
this.source.push(this.wrap(source, loc));
|
|
210751
210772
|
},
|
|
210752
|
-
merge: function
|
|
210773
|
+
merge: function merge2() {
|
|
210753
210774
|
var source = this.empty();
|
|
210754
210775
|
this.each(function(line) {
|
|
210755
210776
|
source.add([" ", line, `
|
|
@@ -211094,7 +211115,7 @@ var require_javascript_compiler = __commonJS((exports2, module2) => {
|
|
|
211094
211115
|
}
|
|
211095
211116
|
this.pendingContent = content;
|
|
211096
211117
|
},
|
|
211097
|
-
append: function
|
|
211118
|
+
append: function append3() {
|
|
211098
211119
|
if (this.isInline()) {
|
|
211099
211120
|
this.replaceStack(function(current) {
|
|
211100
211121
|
return [" != null ? ", current, ' : ""'];
|
|
@@ -211796,20 +211817,20 @@ __export(exports_instrumentation, {
|
|
|
211796
211817
|
getPrometheusMetricsHandler: () => getPrometheusMetricsHandler
|
|
211797
211818
|
});
|
|
211798
211819
|
module.exports = __toCommonJS(exports_instrumentation);
|
|
211799
|
-
var import_api = __toESM(require_src());
|
|
211800
|
-
var import_auto_instrumentations_node = __toESM(require_src59());
|
|
211801
|
-
var import_exporter_logs_otlp_proto = __toESM(require_src66());
|
|
211802
|
-
var import_exporter_prometheus = __toESM(require_src71());
|
|
211803
|
-
var import_exporter_trace_otlp_proto = __toESM(require_src72());
|
|
211804
|
-
var import_instrumentation_express = __toESM(require_src17());
|
|
211805
|
-
var import_resources = __toESM(require_src57());
|
|
211806
|
-
var import_sdk_logs = __toESM(require_src75());
|
|
211807
|
-
var import_sdk_node = __toESM(require_src106());
|
|
211808
|
-
var import_sdk_trace_base = __toESM(require_src82());
|
|
211809
|
-
var import_semantic_conventions = __toESM(require_src2());
|
|
211820
|
+
var import_api = __toESM(require_src(), 1);
|
|
211821
|
+
var import_auto_instrumentations_node = __toESM(require_src59(), 1);
|
|
211822
|
+
var import_exporter_logs_otlp_proto = __toESM(require_src66(), 1);
|
|
211823
|
+
var import_exporter_prometheus = __toESM(require_src71(), 1);
|
|
211824
|
+
var import_exporter_trace_otlp_proto = __toESM(require_src72(), 1);
|
|
211825
|
+
var import_instrumentation_express = __toESM(require_src17(), 1);
|
|
211826
|
+
var import_resources = __toESM(require_src57(), 1);
|
|
211827
|
+
var import_sdk_logs = __toESM(require_src75(), 1);
|
|
211828
|
+
var import_sdk_node = __toESM(require_src106(), 1);
|
|
211829
|
+
var import_sdk_trace_base = __toESM(require_src82(), 1);
|
|
211830
|
+
var import_semantic_conventions = __toESM(require_src2(), 1);
|
|
211810
211831
|
|
|
211811
211832
|
// src/logger.ts
|
|
211812
|
-
var import_winston = __toESM(require_winston());
|
|
211833
|
+
var import_winston = __toESM(require_winston(), 1);
|
|
211813
211834
|
var isTelemetryEnabled = Boolean(process.env.OTEL_EXPORTER_OTLP_ENDPOINT);
|
|
211814
211835
|
var VALID_LOG_LEVELS = ["error", "warn", "info", "verbose", "debug", "silly"];
|
|
211815
211836
|
var getLogLevel = () => {
|
|
@@ -212004,7 +212025,8 @@ function httpMetricsMiddleware(req, res, next) {
|
|
|
212004
212025
|
var exports_server = {};
|
|
212005
212026
|
__export(exports_server, {
|
|
212006
212027
|
normalizeQueryArray: () => normalizeQueryArray,
|
|
212007
|
-
mcpApp: () => mcpApp
|
|
212028
|
+
mcpApp: () => mcpApp,
|
|
212029
|
+
app: () => app
|
|
212008
212030
|
});
|
|
212009
212031
|
module.exports = __toCommonJS(exports_server);
|
|
212010
212032
|
|
|
@@ -216544,8 +216566,8 @@ class McpError extends Error {
|
|
|
216544
216566
|
}
|
|
216545
216567
|
|
|
216546
216568
|
// ../../node_modules/@modelcontextprotocol/sdk/dist/esm/server/streamableHttp.js
|
|
216547
|
-
var import_raw_body = __toESM(require_raw_body());
|
|
216548
|
-
var import_content_type = __toESM(require_content_type());
|
|
216569
|
+
var import_raw_body = __toESM(require_raw_body(), 1);
|
|
216570
|
+
var import_content_type = __toESM(require_content_type(), 1);
|
|
216549
216571
|
var import_node_crypto = require("node:crypto");
|
|
216550
216572
|
var MAXIMUM_MESSAGE_SIZE = "4mb";
|
|
216551
216573
|
|
|
@@ -217020,11 +217042,11 @@ class StreamableHTTPServerTransport {
|
|
|
217020
217042
|
}
|
|
217021
217043
|
|
|
217022
217044
|
// src/server.ts
|
|
217023
|
-
var bodyParser = __toESM(require_body_parser());
|
|
217024
|
-
var import_cors = __toESM(require_lib7());
|
|
217025
|
-
var import_express = __toESM(require_express2());
|
|
217045
|
+
var bodyParser = __toESM(require_body_parser(), 1);
|
|
217046
|
+
var import_cors = __toESM(require_lib7(), 1);
|
|
217047
|
+
var import_express = __toESM(require_express2(), 1);
|
|
217026
217048
|
var http2 = __toESM(require("http"));
|
|
217027
|
-
var import_http_proxy_middleware = __toESM(require_dist4());
|
|
217049
|
+
var import_http_proxy_middleware = __toESM(require_dist4(), 1);
|
|
217028
217050
|
var path10 = __toESM(require("path"));
|
|
217029
217051
|
|
|
217030
217052
|
// src/controller/compile.controller.ts
|
|
@@ -217080,6 +217102,12 @@ function internalErrorToHttpError(error) {
|
|
|
217080
217102
|
return httpError(424, error.message);
|
|
217081
217103
|
} else if (error instanceof ConnectionError) {
|
|
217082
217104
|
return httpError(502, error.message);
|
|
217105
|
+
} else if (error instanceof MaterializationNotFoundError) {
|
|
217106
|
+
return httpError(404, error.message);
|
|
217107
|
+
} else if (error instanceof MaterializationConflictError) {
|
|
217108
|
+
return httpError(409, error.message);
|
|
217109
|
+
} else if (error instanceof InvalidStateTransitionError) {
|
|
217110
|
+
return httpError(409, error.message);
|
|
217083
217111
|
} else {
|
|
217084
217112
|
return httpError(500, error.message);
|
|
217085
217113
|
}
|
|
@@ -217148,6 +217176,24 @@ class FrozenConfigError extends Error {
|
|
|
217148
217176
|
}
|
|
217149
217177
|
}
|
|
217150
217178
|
|
|
217179
|
+
class MaterializationNotFoundError extends Error {
|
|
217180
|
+
constructor(message) {
|
|
217181
|
+
super(message);
|
|
217182
|
+
}
|
|
217183
|
+
}
|
|
217184
|
+
|
|
217185
|
+
class MaterializationConflictError extends Error {
|
|
217186
|
+
constructor(message) {
|
|
217187
|
+
super(message);
|
|
217188
|
+
}
|
|
217189
|
+
}
|
|
217190
|
+
|
|
217191
|
+
class InvalidStateTransitionError extends Error {
|
|
217192
|
+
constructor(message) {
|
|
217193
|
+
super(message);
|
|
217194
|
+
}
|
|
217195
|
+
}
|
|
217196
|
+
|
|
217151
217197
|
// src/service/connection.ts
|
|
217152
217198
|
var import_db_bigquery = require("@malloydata/db-bigquery");
|
|
217153
217199
|
var import_db_duckdb = require("@malloydata/db-duckdb");
|
|
@@ -217620,7 +217666,7 @@ AxiosError.from = (error, code, config, request, response, customProps) => {
|
|
|
217620
217666
|
var AxiosError_default = AxiosError;
|
|
217621
217667
|
|
|
217622
217668
|
// ../../node_modules/axios/lib/platform/node/classes/FormData.js
|
|
217623
|
-
var import_form_data = __toESM(require_form_data());
|
|
217669
|
+
var import_form_data = __toESM(require_form_data(), 1);
|
|
217624
217670
|
var FormData_default = import_form_data.default;
|
|
217625
217671
|
|
|
217626
217672
|
// ../../node_modules/axios/lib/helpers/toFormData.js
|
|
@@ -218401,11 +218447,11 @@ function buildFullPath(baseURL, requestedURL, allowAbsoluteUrls) {
|
|
|
218401
218447
|
}
|
|
218402
218448
|
|
|
218403
218449
|
// ../../node_modules/axios/lib/adapters/http.js
|
|
218404
|
-
var import_proxy_from_env = __toESM(require_proxy_from_env());
|
|
218450
|
+
var import_proxy_from_env = __toESM(require_proxy_from_env(), 1);
|
|
218405
218451
|
var import_http = __toESM(require("http"));
|
|
218406
218452
|
var import_https = __toESM(require("https"));
|
|
218407
218453
|
var import_util5 = __toESM(require("util"));
|
|
218408
|
-
var import_follow_redirects = __toESM(require_follow_redirects());
|
|
218454
|
+
var import_follow_redirects = __toESM(require_follow_redirects(), 1);
|
|
218409
218455
|
var import_zlib = __toESM(require("zlib"));
|
|
218410
218456
|
|
|
218411
218457
|
// ../../node_modules/axios/lib/env/data.js
|
|
@@ -220424,31 +220470,30 @@ var {
|
|
|
220424
220470
|
// src/service/connection.ts
|
|
220425
220471
|
var import_promises = __toESM(require("fs/promises"));
|
|
220426
220472
|
var import_path = __toESM(require("path"));
|
|
220427
|
-
|
|
220428
|
-
|
|
220429
|
-
var
|
|
220430
|
-
for (let i = 0;i < 256; ++i) {
|
|
220431
|
-
byteToHex.push((i + 256).toString(16).slice(1));
|
|
220432
|
-
}
|
|
220433
|
-
function unsafeStringify(arr, offset = 0) {
|
|
220434
|
-
return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
|
|
220435
|
-
}
|
|
220473
|
+
// ../../node_modules/uuid/dist/esm/native.js
|
|
220474
|
+
var import_crypto2 = require("crypto");
|
|
220475
|
+
var native_default = { randomUUID: import_crypto2.randomUUID };
|
|
220436
220476
|
|
|
220437
220477
|
// ../../node_modules/uuid/dist/esm/rng.js
|
|
220438
|
-
var
|
|
220478
|
+
var import_crypto3 = require("crypto");
|
|
220439
220479
|
var rnds8Pool = new Uint8Array(256);
|
|
220440
220480
|
var poolPtr = rnds8Pool.length;
|
|
220441
220481
|
function rng() {
|
|
220442
220482
|
if (poolPtr > rnds8Pool.length - 16) {
|
|
220443
|
-
|
|
220483
|
+
import_crypto3.randomFillSync(rnds8Pool);
|
|
220444
220484
|
poolPtr = 0;
|
|
220445
220485
|
}
|
|
220446
220486
|
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
|
220447
220487
|
}
|
|
220448
220488
|
|
|
220449
|
-
// ../../node_modules/uuid/dist/esm/
|
|
220450
|
-
var
|
|
220451
|
-
|
|
220489
|
+
// ../../node_modules/uuid/dist/esm/stringify.js
|
|
220490
|
+
var byteToHex = [];
|
|
220491
|
+
for (let i = 0;i < 256; ++i) {
|
|
220492
|
+
byteToHex.push((i + 256).toString(16).slice(1));
|
|
220493
|
+
}
|
|
220494
|
+
function unsafeStringify(arr, offset = 0) {
|
|
220495
|
+
return (byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]]).toLowerCase();
|
|
220496
|
+
}
|
|
220452
220497
|
|
|
220453
220498
|
// ../../node_modules/uuid/dist/esm/v4.js
|
|
220454
220499
|
function v4(options, buf, offset) {
|
|
@@ -221476,10 +221521,10 @@ class ConnectionService {
|
|
|
221476
221521
|
// src/service/db_utils.ts
|
|
221477
221522
|
var import_identity = require("@azure/identity");
|
|
221478
221523
|
var import_storage_blob = require("@azure/storage-blob");
|
|
221479
|
-
var import_bigquery = __toESM(require_src121());
|
|
221524
|
+
var import_bigquery = __toESM(require_src121(), 1);
|
|
221480
221525
|
|
|
221481
221526
|
// src/service/gcs_s3_utils.ts
|
|
221482
|
-
var import_client_s3 = __toESM(require_dist_cjs75());
|
|
221527
|
+
var import_client_s3 = __toESM(require_dist_cjs75(), 1);
|
|
221483
221528
|
function gcsConnectionToCredentials(gcsConnection) {
|
|
221484
221529
|
return {
|
|
221485
221530
|
type: "gcs",
|
|
@@ -222513,6 +222558,9 @@ class ConnectionController {
|
|
|
222513
222558
|
if (!source) {
|
|
222514
222559
|
throw new ConnectionError(`Table ${tablePath} not found`);
|
|
222515
222560
|
}
|
|
222561
|
+
if (typeof source === "string") {
|
|
222562
|
+
throw new ConnectionError(source);
|
|
222563
|
+
}
|
|
222516
222564
|
return {
|
|
222517
222565
|
source: JSON.stringify(source),
|
|
222518
222566
|
resource: tablePath,
|
|
@@ -222535,8 +222583,8 @@ class ConnectionController {
|
|
|
222535
222583
|
if (!projectName || !connectionName) {
|
|
222536
222584
|
throw new BadRequestError("Connection payload is required");
|
|
222537
222585
|
}
|
|
222538
|
-
const
|
|
222539
|
-
return
|
|
222586
|
+
const project = await this.projectStore.getProject(projectName, false);
|
|
222587
|
+
return project.getApiConnection(connectionName);
|
|
222540
222588
|
}
|
|
222541
222589
|
async listConnections(projectName) {
|
|
222542
222590
|
const project = await this.projectStore.getProject(projectName, false);
|
|
@@ -222557,11 +222605,15 @@ class ConnectionController {
|
|
|
222557
222605
|
async getConnectionSqlSource(projectName, connectionName, sqlStatement) {
|
|
222558
222606
|
const malloyConnection = await this.getMalloyConnection(projectName, connectionName);
|
|
222559
222607
|
try {
|
|
222608
|
+
const schema = await malloyConnection.fetchSelectSchema({
|
|
222609
|
+
connection: connectionName,
|
|
222610
|
+
selectStr: sqlStatement
|
|
222611
|
+
});
|
|
222612
|
+
if (typeof schema === "string") {
|
|
222613
|
+
throw new ConnectionError(schema);
|
|
222614
|
+
}
|
|
222560
222615
|
return {
|
|
222561
|
-
source: JSON.stringify(
|
|
222562
|
-
connection: connectionName,
|
|
222563
|
-
selectStr: sqlStatement
|
|
222564
|
-
}))
|
|
222616
|
+
source: JSON.stringify(schema)
|
|
222565
222617
|
};
|
|
222566
222618
|
} catch (error) {
|
|
222567
222619
|
throw new ConnectionError(error.message);
|
|
@@ -222764,8 +222816,10 @@ class ModelController {
|
|
|
222764
222816
|
var path2 = __toESM(require("path"));
|
|
222765
222817
|
class PackageController {
|
|
222766
222818
|
projectStore;
|
|
222767
|
-
|
|
222819
|
+
manifestService;
|
|
222820
|
+
constructor(projectStore, manifestService) {
|
|
222768
222821
|
this.projectStore = projectStore;
|
|
222822
|
+
this.manifestService = manifestService;
|
|
222769
222823
|
}
|
|
222770
222824
|
async listPackages(projectName) {
|
|
222771
222825
|
const project = await this.projectStore.getProject(projectName, false);
|
|
@@ -222780,7 +222834,7 @@ class PackageController {
|
|
|
222780
222834
|
}
|
|
222781
222835
|
return _package.getPackageMetadata();
|
|
222782
222836
|
}
|
|
222783
|
-
async addPackage(projectName, body) {
|
|
222837
|
+
async addPackage(projectName, body, options) {
|
|
222784
222838
|
if (this.projectStore.publisherConfigIsFrozen) {
|
|
222785
222839
|
throw new FrozenConfigError;
|
|
222786
222840
|
}
|
|
@@ -222793,8 +222847,34 @@ class PackageController {
|
|
|
222793
222847
|
}
|
|
222794
222848
|
const result = await project.addPackage(body.name);
|
|
222795
222849
|
await this.projectStore.addPackageToDatabase(projectName, body.name);
|
|
222850
|
+
if (options?.autoLoadManifest === true) {
|
|
222851
|
+
await this.tryLoadExistingManifest(projectName, body.name);
|
|
222852
|
+
}
|
|
222796
222853
|
return result;
|
|
222797
222854
|
}
|
|
222855
|
+
async tryLoadExistingManifest(projectName, packageName) {
|
|
222856
|
+
try {
|
|
222857
|
+
const repository = this.projectStore.storageManager.getRepository();
|
|
222858
|
+
const dbProject = await repository.getProjectByName(projectName);
|
|
222859
|
+
if (!dbProject)
|
|
222860
|
+
return;
|
|
222861
|
+
const manifest = await this.manifestService.getManifest(dbProject.id, packageName);
|
|
222862
|
+
if (Object.keys(manifest.entries).length === 0)
|
|
222863
|
+
return;
|
|
222864
|
+
await this.manifestService.reloadManifest(dbProject.id, packageName, projectName);
|
|
222865
|
+
logger.info("Auto-loaded existing manifest for added package", {
|
|
222866
|
+
projectName,
|
|
222867
|
+
packageName,
|
|
222868
|
+
entryCount: Object.keys(manifest.entries).length
|
|
222869
|
+
});
|
|
222870
|
+
} catch (error) {
|
|
222871
|
+
logger.warn("Failed to auto-load manifest for package", {
|
|
222872
|
+
projectName,
|
|
222873
|
+
packageName,
|
|
222874
|
+
error
|
|
222875
|
+
});
|
|
222876
|
+
}
|
|
222877
|
+
}
|
|
222798
222878
|
async deletePackage(projectName, packageName) {
|
|
222799
222879
|
if (this.projectStore.publisherConfigIsFrozen) {
|
|
222800
222880
|
throw new FrozenConfigError;
|
|
@@ -222833,7 +222913,7 @@ class PackageController {
|
|
|
222833
222913
|
}
|
|
222834
222914
|
|
|
222835
222915
|
// src/controller/query.controller.ts
|
|
222836
|
-
var import_render_validator = __toESM(require_dist10());
|
|
222916
|
+
var import_render_validator = __toESM(require_dist10(), 1);
|
|
222837
222917
|
function bigIntReplacer(_key, value) {
|
|
222838
222918
|
if (typeof value === "bigint") {
|
|
222839
222919
|
return Number(value);
|
|
@@ -224439,9 +224519,9 @@ var esm_default = { watch, FSWatcher };
|
|
|
224439
224519
|
var import_path3 = __toESM(require("path"));
|
|
224440
224520
|
|
|
224441
224521
|
// src/service/project_store.ts
|
|
224442
|
-
var import_client_s32 = __toESM(require_dist_cjs75());
|
|
224522
|
+
var import_client_s32 = __toESM(require_dist_cjs75(), 1);
|
|
224443
224523
|
var import_storage = require("@google-cloud/storage");
|
|
224444
|
-
var import_adm_zip = __toESM(require_adm_zip());
|
|
224524
|
+
var import_adm_zip = __toESM(require_adm_zip(), 1);
|
|
224445
224525
|
|
|
224446
224526
|
// ../../node_modules/async-mutex/index.mjs
|
|
224447
224527
|
var E_TIMEOUT = new Error("timeout while waiting for mutex to become available");
|
|
@@ -224658,11 +224738,11 @@ var path8 = __toESM(require("path"));
|
|
|
224658
224738
|
|
|
224659
224739
|
// ../../node_modules/simple-git/dist/esm/index.js
|
|
224660
224740
|
var import_node_buffer = require("node:buffer");
|
|
224661
|
-
var import_file_exists = __toESM(require_dist11());
|
|
224662
|
-
var import_debug = __toESM(require_src5());
|
|
224741
|
+
var import_file_exists = __toESM(require_dist11(), 1);
|
|
224742
|
+
var import_debug = __toESM(require_src5(), 1);
|
|
224663
224743
|
var import_child_process = require("child_process");
|
|
224664
|
-
var import_promise_deferred = __toESM(require_dist12());
|
|
224665
|
-
var import_promise_deferred2 = __toESM(require_dist12());
|
|
224744
|
+
var import_promise_deferred = __toESM(require_dist12(), 1);
|
|
224745
|
+
var import_promise_deferred2 = __toESM(require_dist12(), 1);
|
|
224666
224746
|
var import_node_events = require("node:events");
|
|
224667
224747
|
var __defProp2 = Object.defineProperty;
|
|
224668
224748
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
@@ -229022,201 +229102,38 @@ Query: ${query}`));
|
|
|
229022
229102
|
}
|
|
229023
229103
|
}
|
|
229024
229104
|
|
|
229025
|
-
// src/storage/duckdb/
|
|
229026
|
-
class
|
|
229027
|
-
|
|
229028
|
-
constructor(
|
|
229029
|
-
this.
|
|
229030
|
-
}
|
|
229031
|
-
generateId() {
|
|
229032
|
-
return `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
229033
|
-
}
|
|
229034
|
-
now() {
|
|
229035
|
-
return new Date;
|
|
229036
|
-
}
|
|
229037
|
-
async listProjects() {
|
|
229038
|
-
const rows = await this.db.all("SELECT * FROM projects ORDER BY name");
|
|
229039
|
-
return rows.map(this.mapToProject);
|
|
229040
|
-
}
|
|
229041
|
-
async getProjectById(id) {
|
|
229042
|
-
const row = await this.db.get("SELECT * FROM projects WHERE id = ?", [id]);
|
|
229043
|
-
return row ? this.mapToProject(row) : null;
|
|
229044
|
-
}
|
|
229045
|
-
async getProjectByName(name) {
|
|
229046
|
-
const row = await this.db.get("SELECT * FROM projects WHERE name = ?", [name]);
|
|
229047
|
-
return row ? this.mapToProject(row) : null;
|
|
229048
|
-
}
|
|
229049
|
-
async createProject(project) {
|
|
229050
|
-
const id = this.generateId();
|
|
229051
|
-
const now = this.now();
|
|
229052
|
-
const params = [
|
|
229053
|
-
id,
|
|
229054
|
-
project.name,
|
|
229055
|
-
project.path,
|
|
229056
|
-
project.description || null,
|
|
229057
|
-
project.metadata ? JSON.stringify(project.metadata) : null,
|
|
229058
|
-
now.toISOString(),
|
|
229059
|
-
now.toISOString()
|
|
229060
|
-
];
|
|
229061
|
-
try {
|
|
229062
|
-
await this.db.run(`INSERT INTO projects (id, name, path, description, metadata, created_at, updated_at)
|
|
229063
|
-
VALUES (?, ?, ?, ?, ?, ?, ?)`, params);
|
|
229064
|
-
return {
|
|
229065
|
-
id,
|
|
229066
|
-
...project,
|
|
229067
|
-
createdAt: now,
|
|
229068
|
-
updatedAt: now
|
|
229069
|
-
};
|
|
229070
|
-
} catch (err) {
|
|
229071
|
-
const error = err;
|
|
229072
|
-
if (error.message?.includes("UNIQUE") || error.message?.includes("Constraint")) {
|
|
229073
|
-
const existing = await this.db.get("SELECT * FROM projects WHERE name = ?", [project.name]);
|
|
229074
|
-
if (existing) {
|
|
229075
|
-
console.log("Returning existing project");
|
|
229076
|
-
return this.mapToProject(existing);
|
|
229077
|
-
}
|
|
229078
|
-
}
|
|
229079
|
-
throw error;
|
|
229080
|
-
}
|
|
229105
|
+
// src/storage/duckdb/DuckDBManifestStore.ts
|
|
229106
|
+
class DuckDBManifestStore {
|
|
229107
|
+
repository;
|
|
229108
|
+
constructor(repository) {
|
|
229109
|
+
this.repository = repository;
|
|
229081
229110
|
}
|
|
229082
|
-
async
|
|
229083
|
-
const
|
|
229084
|
-
|
|
229085
|
-
|
|
229086
|
-
|
|
229087
|
-
const now = this.now();
|
|
229088
|
-
const setClauses = [];
|
|
229089
|
-
const params = [];
|
|
229090
|
-
if (updates.name !== undefined && updates.name !== existing.name) {
|
|
229091
|
-
setClauses.push(`name = ?`);
|
|
229092
|
-
params.push(updates.name);
|
|
229093
|
-
}
|
|
229094
|
-
if (updates.path !== undefined && updates.path !== existing.path) {
|
|
229095
|
-
setClauses.push(`path = ?`);
|
|
229096
|
-
params.push(updates.path);
|
|
229097
|
-
}
|
|
229098
|
-
if (updates.description !== undefined) {
|
|
229099
|
-
setClauses.push(`description = ?`);
|
|
229100
|
-
params.push(updates.description);
|
|
229101
|
-
}
|
|
229102
|
-
if (updates.metadata !== undefined) {
|
|
229103
|
-
setClauses.push(`metadata = ?`);
|
|
229104
|
-
params.push(JSON.stringify(updates.metadata));
|
|
229105
|
-
}
|
|
229106
|
-
setClauses.push(`updated_at = ?`);
|
|
229107
|
-
params.push(now.toISOString());
|
|
229108
|
-
params.push(id);
|
|
229109
|
-
await this.db.run(`UPDATE projects SET ${setClauses.join(", ")} WHERE id = ?`, params);
|
|
229110
|
-
return this.getProjectById(id);
|
|
229111
|
-
}
|
|
229112
|
-
async deleteProject(id) {
|
|
229113
|
-
await this.db.run("DELETE FROM projects WHERE id = ?", [id]);
|
|
229114
|
-
}
|
|
229115
|
-
mapToProject(row) {
|
|
229116
|
-
return {
|
|
229117
|
-
id: row.id,
|
|
229118
|
-
name: row.name,
|
|
229119
|
-
path: row.path,
|
|
229120
|
-
description: row.description,
|
|
229121
|
-
metadata: row.metadata ? JSON.parse(row.metadata) : undefined,
|
|
229122
|
-
createdAt: new Date(row.created_at),
|
|
229123
|
-
updatedAt: new Date(row.updated_at)
|
|
229111
|
+
async getManifest(projectId, packageName) {
|
|
229112
|
+
const entries = await this.repository.listManifestEntries(projectId, packageName);
|
|
229113
|
+
const manifest = {
|
|
229114
|
+
entries: {},
|
|
229115
|
+
strict: false
|
|
229124
229116
|
};
|
|
229125
|
-
|
|
229126
|
-
}
|
|
229127
|
-
|
|
229128
|
-
// src/storage/duckdb/PackageRepository.ts
|
|
229129
|
-
class PackageRepository {
|
|
229130
|
-
db;
|
|
229131
|
-
constructor(db) {
|
|
229132
|
-
this.db = db;
|
|
229133
|
-
}
|
|
229134
|
-
generateId() {
|
|
229135
|
-
return `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
229136
|
-
}
|
|
229137
|
-
now() {
|
|
229138
|
-
return new Date;
|
|
229139
|
-
}
|
|
229140
|
-
async listPackages(projectId) {
|
|
229141
|
-
const rows = await this.db.all("SELECT * FROM packages WHERE project_id = ? ORDER BY name", [projectId]);
|
|
229142
|
-
return rows.map(this.mapToPackage);
|
|
229143
|
-
}
|
|
229144
|
-
async getPackageById(id) {
|
|
229145
|
-
const row = await this.db.get("SELECT * FROM packages WHERE id = ?", [id]);
|
|
229146
|
-
return row ? this.mapToPackage(row) : null;
|
|
229147
|
-
}
|
|
229148
|
-
async getPackageByName(projectId, name) {
|
|
229149
|
-
const row = await this.db.get("SELECT * FROM packages WHERE project_id = ? AND name = ?", [projectId, name]);
|
|
229150
|
-
return row ? this.mapToPackage(row) : null;
|
|
229151
|
-
}
|
|
229152
|
-
async createPackage(pkg) {
|
|
229153
|
-
const id = this.generateId();
|
|
229154
|
-
const now = this.now();
|
|
229155
|
-
await this.db.run(`INSERT INTO packages (id, project_id, name, description, manifest_path, metadata, created_at, updated_at)
|
|
229156
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?)`, [
|
|
229157
|
-
id,
|
|
229158
|
-
pkg.projectId,
|
|
229159
|
-
pkg.name,
|
|
229160
|
-
pkg.description || null,
|
|
229161
|
-
pkg.manifestPath,
|
|
229162
|
-
pkg.metadata ? JSON.stringify(pkg.metadata) : null,
|
|
229163
|
-
now.toISOString(),
|
|
229164
|
-
now.toISOString()
|
|
229165
|
-
]);
|
|
229166
|
-
return {
|
|
229167
|
-
id,
|
|
229168
|
-
...pkg,
|
|
229169
|
-
createdAt: now,
|
|
229170
|
-
updatedAt: now
|
|
229171
|
-
};
|
|
229172
|
-
}
|
|
229173
|
-
async updatePackage(id, updates) {
|
|
229174
|
-
const existing = await this.getPackageById(id);
|
|
229175
|
-
if (!existing) {
|
|
229176
|
-
throw new Error(`Package with id ${id} not found`);
|
|
229177
|
-
}
|
|
229178
|
-
const now = this.now();
|
|
229179
|
-
const setClauses = [];
|
|
229180
|
-
const params = [];
|
|
229181
|
-
if (updates.name !== undefined) {
|
|
229182
|
-
setClauses.push(`name = ?`);
|
|
229183
|
-
params.push(updates.name);
|
|
229184
|
-
}
|
|
229185
|
-
if (updates.description !== undefined) {
|
|
229186
|
-
setClauses.push(`description = ?`);
|
|
229187
|
-
params.push(updates.description);
|
|
229188
|
-
}
|
|
229189
|
-
if (updates.manifestPath !== undefined) {
|
|
229190
|
-
setClauses.push(`manifest_path = ?`);
|
|
229191
|
-
params.push(updates.manifestPath);
|
|
229192
|
-
}
|
|
229193
|
-
if (updates.metadata !== undefined) {
|
|
229194
|
-
setClauses.push(`metadata = ?`);
|
|
229195
|
-
params.push(JSON.stringify(updates.metadata));
|
|
229117
|
+
for (const entry of entries) {
|
|
229118
|
+
manifest.entries[entry.buildId] = { tableName: entry.tableName };
|
|
229196
229119
|
}
|
|
229197
|
-
|
|
229198
|
-
params.push(now.toISOString());
|
|
229199
|
-
params.push(id);
|
|
229200
|
-
await this.db.run(`UPDATE packages SET ${setClauses.join(", ")} WHERE id = ?`, params);
|
|
229201
|
-
return this.getPackageById(id);
|
|
229120
|
+
return manifest;
|
|
229202
229121
|
}
|
|
229203
|
-
async
|
|
229204
|
-
await this.
|
|
229122
|
+
async writeEntry(projectId, packageName, buildId, tableName, sourceName, connectionName) {
|
|
229123
|
+
await this.repository.upsertManifestEntry({
|
|
229124
|
+
projectId,
|
|
229125
|
+
packageName,
|
|
229126
|
+
buildId,
|
|
229127
|
+
tableName,
|
|
229128
|
+
sourceName,
|
|
229129
|
+
connectionName
|
|
229130
|
+
});
|
|
229205
229131
|
}
|
|
229206
|
-
async
|
|
229207
|
-
await this.
|
|
229132
|
+
async deleteEntry(id) {
|
|
229133
|
+
await this.repository.deleteManifestEntry(id);
|
|
229208
229134
|
}
|
|
229209
|
-
|
|
229210
|
-
return
|
|
229211
|
-
id: row.id,
|
|
229212
|
-
projectId: row.project_id,
|
|
229213
|
-
name: row.name,
|
|
229214
|
-
description: row.description,
|
|
229215
|
-
manifestPath: row.manifest_path,
|
|
229216
|
-
metadata: row.metadata ? JSON.parse(row.metadata) : undefined,
|
|
229217
|
-
createdAt: new Date(row.created_at),
|
|
229218
|
-
updatedAt: new Date(row.updated_at)
|
|
229219
|
-
};
|
|
229135
|
+
async listEntries(projectId, packageName) {
|
|
229136
|
+
return this.repository.listManifestEntries(projectId, packageName);
|
|
229220
229137
|
}
|
|
229221
229138
|
}
|
|
229222
229139
|
|
|
@@ -229322,17 +229239,442 @@ class ConnectionRepository {
|
|
|
229322
229239
|
}
|
|
229323
229240
|
}
|
|
229324
229241
|
|
|
229242
|
+
// src/storage/duckdb/ManifestRepository.ts
|
|
229243
|
+
class ManifestRepository {
|
|
229244
|
+
db;
|
|
229245
|
+
constructor(db) {
|
|
229246
|
+
this.db = db;
|
|
229247
|
+
}
|
|
229248
|
+
generateId() {
|
|
229249
|
+
return `${Date.now()}-${Math.random().toString(36).substring(2, 11)}`;
|
|
229250
|
+
}
|
|
229251
|
+
async listEntries(projectId, packageName) {
|
|
229252
|
+
const rows = await this.db.all("SELECT * FROM build_manifests WHERE project_id = ? AND package_name = ? ORDER BY created_at DESC", [projectId, packageName]);
|
|
229253
|
+
return rows.map(this.mapToEntry);
|
|
229254
|
+
}
|
|
229255
|
+
async getEntryByBuildId(projectId, packageName, buildId) {
|
|
229256
|
+
const row = await this.db.get("SELECT * FROM build_manifests WHERE project_id = ? AND package_name = ? AND build_id = ?", [projectId, packageName, buildId]);
|
|
229257
|
+
return row ? this.mapToEntry(row) : null;
|
|
229258
|
+
}
|
|
229259
|
+
async upsertEntry(entry) {
|
|
229260
|
+
const id = this.generateId();
|
|
229261
|
+
const now = new Date;
|
|
229262
|
+
const iso = now.toISOString();
|
|
229263
|
+
const rows = await this.db.all(`INSERT INTO build_manifests (id, project_id, package_name, build_id, table_name, source_name, connection_name, created_at, updated_at)
|
|
229264
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
229265
|
+
ON CONFLICT (project_id, package_name, build_id)
|
|
229266
|
+
DO UPDATE SET table_name = EXCLUDED.table_name,
|
|
229267
|
+
source_name = EXCLUDED.source_name,
|
|
229268
|
+
connection_name = EXCLUDED.connection_name,
|
|
229269
|
+
updated_at = EXCLUDED.updated_at
|
|
229270
|
+
RETURNING *`, [
|
|
229271
|
+
id,
|
|
229272
|
+
entry.projectId,
|
|
229273
|
+
entry.packageName,
|
|
229274
|
+
entry.buildId,
|
|
229275
|
+
entry.tableName,
|
|
229276
|
+
entry.sourceName,
|
|
229277
|
+
entry.connectionName,
|
|
229278
|
+
iso,
|
|
229279
|
+
iso
|
|
229280
|
+
]);
|
|
229281
|
+
return this.mapToEntry(rows[0]);
|
|
229282
|
+
}
|
|
229283
|
+
async deleteEntry(id) {
|
|
229284
|
+
await this.db.run("DELETE FROM build_manifests WHERE id = ?", [id]);
|
|
229285
|
+
}
|
|
229286
|
+
async deleteEntriesByProjectId(projectId) {
|
|
229287
|
+
await this.db.run("DELETE FROM build_manifests WHERE project_id = ?", [
|
|
229288
|
+
projectId
|
|
229289
|
+
]);
|
|
229290
|
+
}
|
|
229291
|
+
async deleteEntriesByPackage(projectId, packageName) {
|
|
229292
|
+
await this.db.run("DELETE FROM build_manifests WHERE project_id = ? AND package_name = ?", [projectId, packageName]);
|
|
229293
|
+
}
|
|
229294
|
+
mapToEntry(row) {
|
|
229295
|
+
return {
|
|
229296
|
+
id: row.id,
|
|
229297
|
+
projectId: row.project_id,
|
|
229298
|
+
packageName: row.package_name,
|
|
229299
|
+
buildId: row.build_id,
|
|
229300
|
+
tableName: row.table_name,
|
|
229301
|
+
sourceName: row.source_name,
|
|
229302
|
+
connectionName: row.connection_name,
|
|
229303
|
+
createdAt: new Date(row.created_at),
|
|
229304
|
+
updatedAt: new Date(row.updated_at)
|
|
229305
|
+
};
|
|
229306
|
+
}
|
|
229307
|
+
}
|
|
229308
|
+
|
|
229309
|
+
// src/storage/duckdb/MaterializationRepository.ts
|
|
229310
|
+
var TERMINAL_STATUSES = new Set([
|
|
229311
|
+
"SUCCESS",
|
|
229312
|
+
"FAILED",
|
|
229313
|
+
"CANCELLED"
|
|
229314
|
+
]);
|
|
229315
|
+
function activeKeyFor(projectId, packageName) {
|
|
229316
|
+
return `${projectId}|${packageName}`;
|
|
229317
|
+
}
|
|
229318
|
+
|
|
229319
|
+
class DuplicateActiveMaterializationError extends Error {
|
|
229320
|
+
constructor(projectId, packageName) {
|
|
229321
|
+
super(`Active materialization already exists for (${projectId}, ${packageName})`);
|
|
229322
|
+
}
|
|
229323
|
+
}
|
|
229324
|
+
|
|
229325
|
+
class MaterializationRepository {
|
|
229326
|
+
db;
|
|
229327
|
+
constructor(db) {
|
|
229328
|
+
this.db = db;
|
|
229329
|
+
}
|
|
229330
|
+
generateId() {
|
|
229331
|
+
return `${Date.now()}-${Math.random().toString(36).substring(2, 11)}`;
|
|
229332
|
+
}
|
|
229333
|
+
now() {
|
|
229334
|
+
return new Date;
|
|
229335
|
+
}
|
|
229336
|
+
async list(projectId, packageName, options) {
|
|
229337
|
+
let sql = "SELECT * FROM materializations WHERE project_id = ? AND package_name = ? ORDER BY created_at DESC";
|
|
229338
|
+
const params = [projectId, packageName];
|
|
229339
|
+
if (options?.limit !== undefined) {
|
|
229340
|
+
sql += " LIMIT ?";
|
|
229341
|
+
params.push(options.limit);
|
|
229342
|
+
}
|
|
229343
|
+
if (options?.offset !== undefined) {
|
|
229344
|
+
sql += " OFFSET ?";
|
|
229345
|
+
params.push(options.offset);
|
|
229346
|
+
}
|
|
229347
|
+
const rows = await this.db.all(sql, params);
|
|
229348
|
+
return rows.map(this.mapRow);
|
|
229349
|
+
}
|
|
229350
|
+
async getById(id) {
|
|
229351
|
+
const row = await this.db.get("SELECT * FROM materializations WHERE id = ?", [id]);
|
|
229352
|
+
return row ? this.mapRow(row) : null;
|
|
229353
|
+
}
|
|
229354
|
+
async getActive(projectId, packageName) {
|
|
229355
|
+
const row = await this.db.get("SELECT * FROM materializations WHERE project_id = ? AND package_name = ? AND status IN ('PENDING', 'RUNNING')", [projectId, packageName]);
|
|
229356
|
+
return row ? this.mapRow(row) : null;
|
|
229357
|
+
}
|
|
229358
|
+
async create(projectId, packageName, status = "PENDING", metadata = null) {
|
|
229359
|
+
const id = this.generateId();
|
|
229360
|
+
const now = this.now();
|
|
229361
|
+
const iso = now.toISOString();
|
|
229362
|
+
const activeKey = TERMINAL_STATUSES.has(status) ? null : activeKeyFor(projectId, packageName);
|
|
229363
|
+
const metadataJson = metadata ? JSON.stringify(metadata) : null;
|
|
229364
|
+
try {
|
|
229365
|
+
const rows = await this.db.all(`INSERT INTO materializations (id, project_id, package_name, status, active_key, metadata, created_at, updated_at)
|
|
229366
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?)
|
|
229367
|
+
RETURNING *`, [
|
|
229368
|
+
id,
|
|
229369
|
+
projectId,
|
|
229370
|
+
packageName,
|
|
229371
|
+
status,
|
|
229372
|
+
activeKey,
|
|
229373
|
+
metadataJson,
|
|
229374
|
+
iso,
|
|
229375
|
+
iso
|
|
229376
|
+
]);
|
|
229377
|
+
return this.mapRow(rows[0]);
|
|
229378
|
+
} catch (err) {
|
|
229379
|
+
if (isUniqueViolation(err, "idx_materializations_active_key")) {
|
|
229380
|
+
throw new DuplicateActiveMaterializationError(projectId, packageName);
|
|
229381
|
+
}
|
|
229382
|
+
throw err;
|
|
229383
|
+
}
|
|
229384
|
+
}
|
|
229385
|
+
async update(id, updates) {
|
|
229386
|
+
const now = this.now();
|
|
229387
|
+
const setClauses = [];
|
|
229388
|
+
const params = [];
|
|
229389
|
+
if (updates.status !== undefined) {
|
|
229390
|
+
setClauses.push(`status = ?`);
|
|
229391
|
+
params.push(updates.status);
|
|
229392
|
+
if (TERMINAL_STATUSES.has(updates.status)) {
|
|
229393
|
+
setClauses.push(`active_key = NULL`);
|
|
229394
|
+
} else {
|
|
229395
|
+
setClauses.push(`active_key = project_id || '|' || package_name`);
|
|
229396
|
+
}
|
|
229397
|
+
}
|
|
229398
|
+
if (updates.startedAt !== undefined) {
|
|
229399
|
+
setClauses.push(`started_at = ?`);
|
|
229400
|
+
params.push(updates.startedAt.toISOString());
|
|
229401
|
+
}
|
|
229402
|
+
if (updates.completedAt !== undefined) {
|
|
229403
|
+
setClauses.push(`completed_at = ?`);
|
|
229404
|
+
params.push(updates.completedAt.toISOString());
|
|
229405
|
+
}
|
|
229406
|
+
if (updates.error !== undefined) {
|
|
229407
|
+
setClauses.push(`error = ?`);
|
|
229408
|
+
params.push(updates.error);
|
|
229409
|
+
}
|
|
229410
|
+
if (updates.metadata !== undefined) {
|
|
229411
|
+
setClauses.push(`metadata = ?`);
|
|
229412
|
+
params.push(updates.metadata ? JSON.stringify(updates.metadata) : null);
|
|
229413
|
+
}
|
|
229414
|
+
setClauses.push(`updated_at = ?`);
|
|
229415
|
+
params.push(now.toISOString());
|
|
229416
|
+
params.push(id);
|
|
229417
|
+
await this.db.run(`UPDATE materializations SET ${setClauses.join(", ")} WHERE id = ?`, params);
|
|
229418
|
+
const updated = await this.getById(id);
|
|
229419
|
+
if (!updated) {
|
|
229420
|
+
throw new Error(`Materialization ${id} not found after update`);
|
|
229421
|
+
}
|
|
229422
|
+
return updated;
|
|
229423
|
+
}
|
|
229424
|
+
async deleteByProjectId(projectId) {
|
|
229425
|
+
await this.db.run("DELETE FROM materializations WHERE project_id = ?", [
|
|
229426
|
+
projectId
|
|
229427
|
+
]);
|
|
229428
|
+
}
|
|
229429
|
+
async deleteById(id) {
|
|
229430
|
+
await this.db.run("DELETE FROM materializations WHERE id = ?", [id]);
|
|
229431
|
+
}
|
|
229432
|
+
async deleteByPackage(projectId, packageName) {
|
|
229433
|
+
await this.db.run("DELETE FROM materializations WHERE project_id = ? AND package_name = ?", [projectId, packageName]);
|
|
229434
|
+
}
|
|
229435
|
+
mapRow(row) {
|
|
229436
|
+
let metadata = null;
|
|
229437
|
+
if (row.metadata) {
|
|
229438
|
+
try {
|
|
229439
|
+
metadata = JSON.parse(row.metadata);
|
|
229440
|
+
} catch {
|
|
229441
|
+
metadata = null;
|
|
229442
|
+
}
|
|
229443
|
+
}
|
|
229444
|
+
return {
|
|
229445
|
+
id: row.id,
|
|
229446
|
+
projectId: row.project_id,
|
|
229447
|
+
packageName: row.package_name,
|
|
229448
|
+
status: row.status,
|
|
229449
|
+
startedAt: row.started_at ? new Date(row.started_at) : null,
|
|
229450
|
+
completedAt: row.completed_at ? new Date(row.completed_at) : null,
|
|
229451
|
+
error: row.error != null ? row.error : null,
|
|
229452
|
+
metadata,
|
|
229453
|
+
createdAt: new Date(row.created_at),
|
|
229454
|
+
updatedAt: new Date(row.updated_at)
|
|
229455
|
+
};
|
|
229456
|
+
}
|
|
229457
|
+
}
|
|
229458
|
+
function isUniqueViolation(err, indexName) {
|
|
229459
|
+
if (!(err instanceof Error))
|
|
229460
|
+
return false;
|
|
229461
|
+
const msg = err.message;
|
|
229462
|
+
return msg.includes(indexName) || /duplicate key|unique constraint/i.test(msg);
|
|
229463
|
+
}
|
|
229464
|
+
|
|
229465
|
+
// src/storage/duckdb/PackageRepository.ts
|
|
229466
|
+
class PackageRepository {
|
|
229467
|
+
db;
|
|
229468
|
+
constructor(db) {
|
|
229469
|
+
this.db = db;
|
|
229470
|
+
}
|
|
229471
|
+
generateId() {
|
|
229472
|
+
return `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
229473
|
+
}
|
|
229474
|
+
now() {
|
|
229475
|
+
return new Date;
|
|
229476
|
+
}
|
|
229477
|
+
async listPackages(projectId) {
|
|
229478
|
+
const rows = await this.db.all("SELECT * FROM packages WHERE project_id = ? ORDER BY name", [projectId]);
|
|
229479
|
+
return rows.map(this.mapToPackage);
|
|
229480
|
+
}
|
|
229481
|
+
async getPackageById(id) {
|
|
229482
|
+
const row = await this.db.get("SELECT * FROM packages WHERE id = ?", [id]);
|
|
229483
|
+
return row ? this.mapToPackage(row) : null;
|
|
229484
|
+
}
|
|
229485
|
+
async getPackageByName(projectId, name) {
|
|
229486
|
+
const row = await this.db.get("SELECT * FROM packages WHERE project_id = ? AND name = ?", [projectId, name]);
|
|
229487
|
+
return row ? this.mapToPackage(row) : null;
|
|
229488
|
+
}
|
|
229489
|
+
async createPackage(pkg) {
|
|
229490
|
+
const id = this.generateId();
|
|
229491
|
+
const now = this.now();
|
|
229492
|
+
await this.db.run(`INSERT INTO packages (id, project_id, name, description, manifest_path, metadata, created_at, updated_at)
|
|
229493
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?)`, [
|
|
229494
|
+
id,
|
|
229495
|
+
pkg.projectId,
|
|
229496
|
+
pkg.name,
|
|
229497
|
+
pkg.description || null,
|
|
229498
|
+
pkg.manifestPath,
|
|
229499
|
+
pkg.metadata ? JSON.stringify(pkg.metadata) : null,
|
|
229500
|
+
now.toISOString(),
|
|
229501
|
+
now.toISOString()
|
|
229502
|
+
]);
|
|
229503
|
+
return {
|
|
229504
|
+
id,
|
|
229505
|
+
...pkg,
|
|
229506
|
+
createdAt: now,
|
|
229507
|
+
updatedAt: now
|
|
229508
|
+
};
|
|
229509
|
+
}
|
|
229510
|
+
async updatePackage(id, updates) {
|
|
229511
|
+
const existing = await this.getPackageById(id);
|
|
229512
|
+
if (!existing) {
|
|
229513
|
+
throw new Error(`Package with id ${id} not found`);
|
|
229514
|
+
}
|
|
229515
|
+
const now = this.now();
|
|
229516
|
+
const setClauses = [];
|
|
229517
|
+
const params = [];
|
|
229518
|
+
if (updates.name !== undefined) {
|
|
229519
|
+
setClauses.push(`name = ?`);
|
|
229520
|
+
params.push(updates.name);
|
|
229521
|
+
}
|
|
229522
|
+
if (updates.description !== undefined) {
|
|
229523
|
+
setClauses.push(`description = ?`);
|
|
229524
|
+
params.push(updates.description);
|
|
229525
|
+
}
|
|
229526
|
+
if (updates.manifestPath !== undefined) {
|
|
229527
|
+
setClauses.push(`manifest_path = ?`);
|
|
229528
|
+
params.push(updates.manifestPath);
|
|
229529
|
+
}
|
|
229530
|
+
if (updates.metadata !== undefined) {
|
|
229531
|
+
setClauses.push(`metadata = ?`);
|
|
229532
|
+
params.push(JSON.stringify(updates.metadata));
|
|
229533
|
+
}
|
|
229534
|
+
setClauses.push(`updated_at = ?`);
|
|
229535
|
+
params.push(now.toISOString());
|
|
229536
|
+
params.push(id);
|
|
229537
|
+
await this.db.run(`UPDATE packages SET ${setClauses.join(", ")} WHERE id = ?`, params);
|
|
229538
|
+
return this.getPackageById(id);
|
|
229539
|
+
}
|
|
229540
|
+
async deletePackage(id) {
|
|
229541
|
+
await this.db.run("DELETE FROM packages WHERE id = ?", [id]);
|
|
229542
|
+
}
|
|
229543
|
+
async deletePackagesByProjectId(id) {
|
|
229544
|
+
await this.db.run("DELETE FROM packages WHERE project_id = ?", [id]);
|
|
229545
|
+
}
|
|
229546
|
+
mapToPackage(row) {
|
|
229547
|
+
return {
|
|
229548
|
+
id: row.id,
|
|
229549
|
+
projectId: row.project_id,
|
|
229550
|
+
name: row.name,
|
|
229551
|
+
description: row.description,
|
|
229552
|
+
manifestPath: row.manifest_path,
|
|
229553
|
+
metadata: row.metadata ? JSON.parse(row.metadata) : undefined,
|
|
229554
|
+
createdAt: new Date(row.created_at),
|
|
229555
|
+
updatedAt: new Date(row.updated_at)
|
|
229556
|
+
};
|
|
229557
|
+
}
|
|
229558
|
+
}
|
|
229559
|
+
|
|
229560
|
+
// src/storage/duckdb/ProjectRepository.ts
|
|
229561
|
+
class ProjectRepository {
|
|
229562
|
+
db;
|
|
229563
|
+
constructor(db) {
|
|
229564
|
+
this.db = db;
|
|
229565
|
+
}
|
|
229566
|
+
generateId() {
|
|
229567
|
+
return `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
229568
|
+
}
|
|
229569
|
+
now() {
|
|
229570
|
+
return new Date;
|
|
229571
|
+
}
|
|
229572
|
+
async listProjects() {
|
|
229573
|
+
const rows = await this.db.all("SELECT * FROM projects ORDER BY name");
|
|
229574
|
+
return rows.map(this.mapToProject);
|
|
229575
|
+
}
|
|
229576
|
+
async getProjectById(id) {
|
|
229577
|
+
const row = await this.db.get("SELECT * FROM projects WHERE id = ?", [id]);
|
|
229578
|
+
return row ? this.mapToProject(row) : null;
|
|
229579
|
+
}
|
|
229580
|
+
async getProjectByName(name) {
|
|
229581
|
+
const row = await this.db.get("SELECT * FROM projects WHERE name = ?", [name]);
|
|
229582
|
+
return row ? this.mapToProject(row) : null;
|
|
229583
|
+
}
|
|
229584
|
+
async createProject(project) {
|
|
229585
|
+
const id = this.generateId();
|
|
229586
|
+
const now = this.now();
|
|
229587
|
+
const params = [
|
|
229588
|
+
id,
|
|
229589
|
+
project.name,
|
|
229590
|
+
project.path,
|
|
229591
|
+
project.description || null,
|
|
229592
|
+
project.metadata ? JSON.stringify(project.metadata) : null,
|
|
229593
|
+
now.toISOString(),
|
|
229594
|
+
now.toISOString()
|
|
229595
|
+
];
|
|
229596
|
+
try {
|
|
229597
|
+
await this.db.run(`INSERT INTO projects (id, name, path, description, metadata, created_at, updated_at)
|
|
229598
|
+
VALUES (?, ?, ?, ?, ?, ?, ?)`, params);
|
|
229599
|
+
return {
|
|
229600
|
+
id,
|
|
229601
|
+
...project,
|
|
229602
|
+
createdAt: now,
|
|
229603
|
+
updatedAt: now
|
|
229604
|
+
};
|
|
229605
|
+
} catch (err) {
|
|
229606
|
+
const error = err;
|
|
229607
|
+
if (error.message?.includes("UNIQUE") || error.message?.includes("Constraint")) {
|
|
229608
|
+
const existing = await this.db.get("SELECT * FROM projects WHERE name = ?", [project.name]);
|
|
229609
|
+
if (existing) {
|
|
229610
|
+
console.log("Returning existing project");
|
|
229611
|
+
return this.mapToProject(existing);
|
|
229612
|
+
}
|
|
229613
|
+
}
|
|
229614
|
+
throw error;
|
|
229615
|
+
}
|
|
229616
|
+
}
|
|
229617
|
+
async updateProject(id, updates) {
|
|
229618
|
+
const existing = await this.getProjectById(id);
|
|
229619
|
+
if (!existing) {
|
|
229620
|
+
throw new Error(`Project with id ${id} not found`);
|
|
229621
|
+
}
|
|
229622
|
+
const now = this.now();
|
|
229623
|
+
const setClauses = [];
|
|
229624
|
+
const params = [];
|
|
229625
|
+
if (updates.name !== undefined && updates.name !== existing.name) {
|
|
229626
|
+
setClauses.push(`name = ?`);
|
|
229627
|
+
params.push(updates.name);
|
|
229628
|
+
}
|
|
229629
|
+
if (updates.path !== undefined && updates.path !== existing.path) {
|
|
229630
|
+
setClauses.push(`path = ?`);
|
|
229631
|
+
params.push(updates.path);
|
|
229632
|
+
}
|
|
229633
|
+
if (updates.description !== undefined) {
|
|
229634
|
+
setClauses.push(`description = ?`);
|
|
229635
|
+
params.push(updates.description);
|
|
229636
|
+
}
|
|
229637
|
+
if (updates.metadata !== undefined) {
|
|
229638
|
+
setClauses.push(`metadata = ?`);
|
|
229639
|
+
params.push(JSON.stringify(updates.metadata));
|
|
229640
|
+
}
|
|
229641
|
+
setClauses.push(`updated_at = ?`);
|
|
229642
|
+
params.push(now.toISOString());
|
|
229643
|
+
params.push(id);
|
|
229644
|
+
await this.db.run(`UPDATE projects SET ${setClauses.join(", ")} WHERE id = ?`, params);
|
|
229645
|
+
return this.getProjectById(id);
|
|
229646
|
+
}
|
|
229647
|
+
async deleteProject(id) {
|
|
229648
|
+
await this.db.run("DELETE FROM projects WHERE id = ?", [id]);
|
|
229649
|
+
}
|
|
229650
|
+
mapToProject(row) {
|
|
229651
|
+
return {
|
|
229652
|
+
id: row.id,
|
|
229653
|
+
name: row.name,
|
|
229654
|
+
path: row.path,
|
|
229655
|
+
description: row.description,
|
|
229656
|
+
metadata: row.metadata ? JSON.parse(row.metadata) : undefined,
|
|
229657
|
+
createdAt: new Date(row.created_at),
|
|
229658
|
+
updatedAt: new Date(row.updated_at)
|
|
229659
|
+
};
|
|
229660
|
+
}
|
|
229661
|
+
}
|
|
229662
|
+
|
|
229325
229663
|
// src/storage/duckdb/DuckDBRepository.ts
|
|
229326
229664
|
class DuckDBRepository {
|
|
229327
229665
|
db;
|
|
229328
229666
|
projectRepo;
|
|
229329
229667
|
packageRepo;
|
|
229330
229668
|
connectionRepo;
|
|
229669
|
+
materializationRepo;
|
|
229670
|
+
manifestRepo;
|
|
229331
229671
|
constructor(db) {
|
|
229332
229672
|
this.db = db;
|
|
229333
229673
|
this.projectRepo = new ProjectRepository(db);
|
|
229334
229674
|
this.packageRepo = new PackageRepository(db);
|
|
229335
229675
|
this.connectionRepo = new ConnectionRepository(db);
|
|
229676
|
+
this.materializationRepo = new MaterializationRepository(db);
|
|
229677
|
+
this.manifestRepo = new ManifestRepository(db);
|
|
229336
229678
|
}
|
|
229337
229679
|
async listProjects() {
|
|
229338
229680
|
return this.projectRepo.listProjects();
|
|
@@ -229350,6 +229692,8 @@ class DuckDBRepository {
|
|
|
229350
229692
|
return this.projectRepo.updateProject(id, updates);
|
|
229351
229693
|
}
|
|
229352
229694
|
async deleteProject(id) {
|
|
229695
|
+
await this.manifestRepo.deleteEntriesByProjectId(id);
|
|
229696
|
+
await this.materializationRepo.deleteByProjectId(id);
|
|
229353
229697
|
await this.connectionRepo.deleteConnectionsByProjectId(id);
|
|
229354
229698
|
await this.packageRepo.deletePackagesByProjectId(id);
|
|
229355
229699
|
await this.projectRepo.deleteProject(id);
|
|
@@ -229370,7 +229714,12 @@ class DuckDBRepository {
|
|
|
229370
229714
|
return this.packageRepo.updatePackage(id, updates);
|
|
229371
229715
|
}
|
|
229372
229716
|
async deletePackage(id) {
|
|
229373
|
-
|
|
229717
|
+
const pkg = await this.packageRepo.getPackageById(id);
|
|
229718
|
+
if (pkg) {
|
|
229719
|
+
await this.manifestRepo.deleteEntriesByPackage(pkg.projectId, pkg.name);
|
|
229720
|
+
await this.materializationRepo.deleteByPackage(pkg.projectId, pkg.name);
|
|
229721
|
+
}
|
|
229722
|
+
await this.packageRepo.deletePackage(id);
|
|
229374
229723
|
}
|
|
229375
229724
|
async deletePackagesByProjectId(id) {
|
|
229376
229725
|
return this.packageRepo.deletePackagesByProjectId(id);
|
|
@@ -229396,6 +229745,33 @@ class DuckDBRepository {
|
|
|
229396
229745
|
async deleteConnectionsByProjectId(id) {
|
|
229397
229746
|
return this.connectionRepo.deleteConnectionsByProjectId(id);
|
|
229398
229747
|
}
|
|
229748
|
+
async listMaterializations(projectId, packageName, options) {
|
|
229749
|
+
return this.materializationRepo.list(projectId, packageName, options);
|
|
229750
|
+
}
|
|
229751
|
+
async getMaterializationById(id) {
|
|
229752
|
+
return this.materializationRepo.getById(id);
|
|
229753
|
+
}
|
|
229754
|
+
async getActiveMaterialization(projectId, packageName) {
|
|
229755
|
+
return this.materializationRepo.getActive(projectId, packageName);
|
|
229756
|
+
}
|
|
229757
|
+
async createMaterialization(projectId, packageName, status = "PENDING", metadata = null) {
|
|
229758
|
+
return this.materializationRepo.create(projectId, packageName, status, metadata);
|
|
229759
|
+
}
|
|
229760
|
+
async updateMaterialization(id, updates) {
|
|
229761
|
+
return this.materializationRepo.update(id, updates);
|
|
229762
|
+
}
|
|
229763
|
+
async deleteMaterialization(id) {
|
|
229764
|
+
return this.materializationRepo.deleteById(id);
|
|
229765
|
+
}
|
|
229766
|
+
async listManifestEntries(projectId, packageName) {
|
|
229767
|
+
return this.manifestRepo.listEntries(projectId, packageName);
|
|
229768
|
+
}
|
|
229769
|
+
async upsertManifestEntry(entry) {
|
|
229770
|
+
return this.manifestRepo.upsertEntry(entry);
|
|
229771
|
+
}
|
|
229772
|
+
async deleteManifestEntry(id) {
|
|
229773
|
+
return this.manifestRepo.deleteEntry(id);
|
|
229774
|
+
}
|
|
229399
229775
|
}
|
|
229400
229776
|
|
|
229401
229777
|
// src/storage/duckdb/schema.ts
|
|
@@ -229448,11 +229824,51 @@ async function initializeSchema(db, force = false) {
|
|
|
229448
229824
|
UNIQUE (project_id, name)
|
|
229449
229825
|
)
|
|
229450
229826
|
`);
|
|
229827
|
+
await db.run(`
|
|
229828
|
+
CREATE TABLE IF NOT EXISTS materializations (
|
|
229829
|
+
id VARCHAR PRIMARY KEY,
|
|
229830
|
+
project_id VARCHAR NOT NULL,
|
|
229831
|
+
package_name VARCHAR NOT NULL,
|
|
229832
|
+
status VARCHAR NOT NULL,
|
|
229833
|
+
active_key VARCHAR,
|
|
229834
|
+
started_at TIMESTAMP,
|
|
229835
|
+
completed_at TIMESTAMP,
|
|
229836
|
+
error TEXT,
|
|
229837
|
+
metadata JSON,
|
|
229838
|
+
created_at TIMESTAMP NOT NULL,
|
|
229839
|
+
updated_at TIMESTAMP NOT NULL,
|
|
229840
|
+
FOREIGN KEY (project_id) REFERENCES projects(id)
|
|
229841
|
+
)
|
|
229842
|
+
`);
|
|
229843
|
+
await db.run(`
|
|
229844
|
+
CREATE TABLE IF NOT EXISTS build_manifests (
|
|
229845
|
+
id VARCHAR PRIMARY KEY,
|
|
229846
|
+
project_id VARCHAR NOT NULL,
|
|
229847
|
+
package_name VARCHAR NOT NULL,
|
|
229848
|
+
build_id VARCHAR NOT NULL,
|
|
229849
|
+
table_name VARCHAR NOT NULL,
|
|
229850
|
+
source_name VARCHAR NOT NULL,
|
|
229851
|
+
connection_name VARCHAR NOT NULL,
|
|
229852
|
+
created_at TIMESTAMP NOT NULL,
|
|
229853
|
+
updated_at TIMESTAMP NOT NULL,
|
|
229854
|
+
FOREIGN KEY (project_id) REFERENCES projects(id),
|
|
229855
|
+
UNIQUE (project_id, package_name, build_id)
|
|
229856
|
+
)
|
|
229857
|
+
`);
|
|
229451
229858
|
await db.run("CREATE INDEX IF NOT EXISTS idx_packages_project_id ON packages(project_id)");
|
|
229452
229859
|
await db.run("CREATE INDEX IF NOT EXISTS idx_connections_project_id ON connections(project_id)");
|
|
229860
|
+
await db.run("CREATE INDEX IF NOT EXISTS idx_materializations_project_package ON materializations(project_id, package_name)");
|
|
229861
|
+
await db.run("CREATE UNIQUE INDEX IF NOT EXISTS idx_materializations_active_key ON materializations(active_key)");
|
|
229862
|
+
await db.run("CREATE INDEX IF NOT EXISTS idx_build_manifests_project_package ON build_manifests(project_id, package_name)");
|
|
229453
229863
|
}
|
|
229454
229864
|
async function dropAllTables(db) {
|
|
229455
|
-
const tables = [
|
|
229865
|
+
const tables = [
|
|
229866
|
+
"build_manifests",
|
|
229867
|
+
"materializations",
|
|
229868
|
+
"packages",
|
|
229869
|
+
"connections",
|
|
229870
|
+
"projects"
|
|
229871
|
+
];
|
|
229456
229872
|
logger.info("Dropping tables:", tables.join(", "));
|
|
229457
229873
|
for (const table of tables) {
|
|
229458
229874
|
try {
|
|
@@ -229464,10 +229880,93 @@ async function dropAllTables(db) {
|
|
|
229464
229880
|
}
|
|
229465
229881
|
}
|
|
229466
229882
|
|
|
229883
|
+
// src/storage/ducklake/DuckLakeManifestStore.ts
|
|
229884
|
+
class DuckLakeManifestStore {
|
|
229885
|
+
db;
|
|
229886
|
+
table;
|
|
229887
|
+
constructor(db, catalogName) {
|
|
229888
|
+
this.db = db;
|
|
229889
|
+
this.table = `${catalogName}.build_manifests`;
|
|
229890
|
+
}
|
|
229891
|
+
async bootstrapSchema() {
|
|
229892
|
+
await this.db.run(`
|
|
229893
|
+
CREATE TABLE IF NOT EXISTS ${this.table} (
|
|
229894
|
+
id VARCHAR,
|
|
229895
|
+
project_id VARCHAR NOT NULL,
|
|
229896
|
+
package_name VARCHAR NOT NULL,
|
|
229897
|
+
build_id VARCHAR NOT NULL,
|
|
229898
|
+
table_name VARCHAR NOT NULL,
|
|
229899
|
+
source_name VARCHAR NOT NULL,
|
|
229900
|
+
connection_name VARCHAR NOT NULL,
|
|
229901
|
+
created_at TIMESTAMP NOT NULL,
|
|
229902
|
+
updated_at TIMESTAMP NOT NULL
|
|
229903
|
+
)
|
|
229904
|
+
`);
|
|
229905
|
+
logger.info(`DuckLake manifest table bootstrapped: ${this.table}`);
|
|
229906
|
+
}
|
|
229907
|
+
async getManifest(projectId, packageName) {
|
|
229908
|
+
const rows = await this.db.all(`SELECT * FROM ${this.table} WHERE project_id = ? AND package_name = ? ORDER BY created_at DESC`, [projectId, packageName]);
|
|
229909
|
+
const manifest = { entries: {}, strict: false };
|
|
229910
|
+
for (const row of rows) {
|
|
229911
|
+
const buildId = row.build_id;
|
|
229912
|
+
if (!manifest.entries[buildId]) {
|
|
229913
|
+
manifest.entries[buildId] = {
|
|
229914
|
+
tableName: row.table_name
|
|
229915
|
+
};
|
|
229916
|
+
}
|
|
229917
|
+
}
|
|
229918
|
+
return manifest;
|
|
229919
|
+
}
|
|
229920
|
+
async writeEntry(projectId, packageName, buildId, tableName, sourceName, connectionName) {
|
|
229921
|
+
const now = new Date().toISOString();
|
|
229922
|
+
const id = `${Date.now()}-${Math.random().toString(36).substring(2, 11)}`;
|
|
229923
|
+
await this.db.run(`INSERT INTO ${this.table} (id, project_id, package_name, build_id, table_name, source_name, connection_name, created_at, updated_at)
|
|
229924
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`, [
|
|
229925
|
+
id,
|
|
229926
|
+
projectId,
|
|
229927
|
+
packageName,
|
|
229928
|
+
buildId,
|
|
229929
|
+
tableName,
|
|
229930
|
+
sourceName,
|
|
229931
|
+
connectionName,
|
|
229932
|
+
now,
|
|
229933
|
+
now
|
|
229934
|
+
]);
|
|
229935
|
+
}
|
|
229936
|
+
async deleteEntry(id) {
|
|
229937
|
+
await this.db.run(`DELETE FROM ${this.table} WHERE id = ?`, [id]);
|
|
229938
|
+
}
|
|
229939
|
+
async listEntries(projectId, packageName) {
|
|
229940
|
+
const rows = await this.db.all(`SELECT * FROM ${this.table} WHERE project_id = ? AND package_name = ? ORDER BY created_at DESC`, [projectId, packageName]);
|
|
229941
|
+
return rows.map(this.mapToEntry);
|
|
229942
|
+
}
|
|
229943
|
+
mapToEntry(row) {
|
|
229944
|
+
return {
|
|
229945
|
+
id: row.id,
|
|
229946
|
+
projectId: row.project_id,
|
|
229947
|
+
packageName: row.package_name,
|
|
229948
|
+
buildId: row.build_id,
|
|
229949
|
+
tableName: row.table_name,
|
|
229950
|
+
sourceName: row.source_name,
|
|
229951
|
+
connectionName: row.connection_name,
|
|
229952
|
+
createdAt: new Date(row.created_at),
|
|
229953
|
+
updatedAt: new Date(row.updated_at)
|
|
229954
|
+
};
|
|
229955
|
+
}
|
|
229956
|
+
}
|
|
229957
|
+
|
|
229467
229958
|
// src/storage/StorageManager.ts
|
|
229959
|
+
function escapeSQL2(value) {
|
|
229960
|
+
return value.replace(/'/g, "''");
|
|
229961
|
+
}
|
|
229962
|
+
|
|
229468
229963
|
class StorageManager {
|
|
229469
229964
|
connection = null;
|
|
229965
|
+
duckDbConnection = null;
|
|
229470
229966
|
repository = null;
|
|
229967
|
+
defaultManifestStore = null;
|
|
229968
|
+
projectManifestStores = new Map;
|
|
229969
|
+
attachedCatalogs = new Set;
|
|
229471
229970
|
config;
|
|
229472
229971
|
constructor(config) {
|
|
229473
229972
|
this.config = config;
|
|
@@ -229496,7 +229995,45 @@ class StorageManager {
|
|
|
229496
229995
|
await connection.initialize();
|
|
229497
229996
|
await initializeSchema(connection, reinit);
|
|
229498
229997
|
this.connection = connection;
|
|
229998
|
+
this.duckDbConnection = connection;
|
|
229499
229999
|
this.repository = new DuckDBRepository(connection);
|
|
230000
|
+
this.defaultManifestStore = new DuckDBManifestStore(this.repository);
|
|
230001
|
+
}
|
|
230002
|
+
async initializeDuckLakeForProject(projectId, config) {
|
|
230003
|
+
if (!this.duckDbConnection) {
|
|
230004
|
+
throw new Error("Storage not initialized. Call initialize() first.");
|
|
230005
|
+
}
|
|
230006
|
+
const catalogName = `manifest_lake_${projectId.replace(/[^a-zA-Z0-9_]/g, "_")}`;
|
|
230007
|
+
if (!this.attachedCatalogs.has(catalogName)) {
|
|
230008
|
+
await this.attachDuckLakeCatalog(config, catalogName);
|
|
230009
|
+
}
|
|
230010
|
+
const store = new DuckLakeManifestStore(this.duckDbConnection, catalogName);
|
|
230011
|
+
await store.bootstrapSchema();
|
|
230012
|
+
this.projectManifestStores.set(projectId, store);
|
|
230013
|
+
logger.info("DuckLake manifest store initialized for project", {
|
|
230014
|
+
projectId,
|
|
230015
|
+
catalogName
|
|
230016
|
+
});
|
|
230017
|
+
}
|
|
230018
|
+
async attachDuckLakeCatalog(config, catalogName) {
|
|
230019
|
+
const connection = this.duckDbConnection;
|
|
230020
|
+
await connection.run("INSTALL ducklake; LOAD ducklake;");
|
|
230021
|
+
const isPostgres = config.catalogUrl.startsWith("postgres:");
|
|
230022
|
+
if (isPostgres) {
|
|
230023
|
+
await connection.run("INSTALL postgres; LOAD postgres;");
|
|
230024
|
+
}
|
|
230025
|
+
const escapedCatalogUrl = escapeSQL2(config.catalogUrl);
|
|
230026
|
+
const escapedDataPath = escapeSQL2(config.dataPath);
|
|
230027
|
+
const isCloudStorage = config.dataPath.startsWith("gs://") || config.dataPath.startsWith("s3://");
|
|
230028
|
+
let attachCmd = `ATTACH 'ducklake:${escapedCatalogUrl}' AS ${catalogName}`;
|
|
230029
|
+
const attachOpts = [`DATA_PATH '${escapedDataPath}'`];
|
|
230030
|
+
if (isCloudStorage) {
|
|
230031
|
+
attachOpts.push("OVERRIDE_DATA_PATH true");
|
|
230032
|
+
}
|
|
230033
|
+
attachCmd += ` (${attachOpts.join(", ")});`;
|
|
230034
|
+
logger.info(`Attaching DuckLake manifest catalog: ${attachCmd}`);
|
|
230035
|
+
await connection.run(attachCmd);
|
|
230036
|
+
this.attachedCatalogs.add(catalogName);
|
|
229500
230037
|
}
|
|
229501
230038
|
getRepository() {
|
|
229502
230039
|
if (!this.repository) {
|
|
@@ -229504,11 +230041,27 @@ class StorageManager {
|
|
|
229504
230041
|
}
|
|
229505
230042
|
return this.repository;
|
|
229506
230043
|
}
|
|
230044
|
+
getManifestStore(projectId) {
|
|
230045
|
+
if (projectId) {
|
|
230046
|
+
const projectStore = this.projectManifestStores.get(projectId);
|
|
230047
|
+
if (projectStore) {
|
|
230048
|
+
return projectStore;
|
|
230049
|
+
}
|
|
230050
|
+
}
|
|
230051
|
+
if (!this.defaultManifestStore) {
|
|
230052
|
+
throw new Error("Storage not initialized. Call initialize() first.");
|
|
230053
|
+
}
|
|
230054
|
+
return this.defaultManifestStore;
|
|
230055
|
+
}
|
|
229507
230056
|
async close() {
|
|
229508
230057
|
if (this.connection) {
|
|
229509
230058
|
await this.connection.close();
|
|
229510
230059
|
this.connection = null;
|
|
230060
|
+
this.duckDbConnection = null;
|
|
229511
230061
|
this.repository = null;
|
|
230062
|
+
this.defaultManifestStore = null;
|
|
230063
|
+
this.projectManifestStores.clear();
|
|
230064
|
+
this.attachedCatalogs.clear();
|
|
229512
230065
|
}
|
|
229513
230066
|
}
|
|
229514
230067
|
isInitialized() {
|
|
@@ -229539,14 +230092,14 @@ var fs5 = __toESM(require("fs/promises"));
|
|
|
229539
230092
|
var path6 = __toESM(require("path"));
|
|
229540
230093
|
var import_db_duckdb2 = require("@malloydata/db-duckdb");
|
|
229541
230094
|
var import_malloy3 = require("@malloydata/malloy");
|
|
229542
|
-
var import_api3 = __toESM(require_src());
|
|
229543
|
-
var import_recursive_readdir = __toESM(require_recursive_readdir());
|
|
230095
|
+
var import_api3 = __toESM(require_src(), 1);
|
|
230096
|
+
var import_recursive_readdir = __toESM(require_recursive_readdir(), 1);
|
|
229544
230097
|
|
|
229545
230098
|
// src/service/model.ts
|
|
229546
230099
|
var import_malloy2 = require("@malloydata/malloy");
|
|
229547
230100
|
var import_malloy_sql = require("@malloydata/malloy-sql");
|
|
229548
230101
|
var import__package = __toESM(require("@malloydata/malloy/package.json"));
|
|
229549
|
-
var import_api2 = __toESM(require_src());
|
|
230102
|
+
var import_api2 = __toESM(require_src(), 1);
|
|
229550
230103
|
var fs4 = __toESM(require("fs/promises"));
|
|
229551
230104
|
var path5 = __toESM(require("path"));
|
|
229552
230105
|
var import_url3 = require("url");
|
|
@@ -229835,8 +230388,8 @@ class Model {
|
|
|
229835
230388
|
const arrowMatch = query.match(/^\s*(\w+)\s*->/m);
|
|
229836
230389
|
return runMatch?.[1] ?? arrowMatch?.[1];
|
|
229837
230390
|
}
|
|
229838
|
-
static async create(packageName, packagePath, modelPath, connections) {
|
|
229839
|
-
const { runtime, modelURL, importBaseURL, dataStyles, modelType } = await Model.getModelRuntime(packagePath, modelPath, connections);
|
|
230391
|
+
static async create(packageName, packagePath, modelPath, connections, options) {
|
|
230392
|
+
const { runtime, modelURL, importBaseURL, dataStyles, modelType } = await Model.getModelRuntime(packagePath, modelPath, connections, options);
|
|
229840
230393
|
try {
|
|
229841
230394
|
const { modelMaterializer, runnableNotebookCells } = await Model.getModelMaterializer(runtime, importBaseURL, modelURL, modelPath);
|
|
229842
230395
|
let modelDef = undefined;
|
|
@@ -229908,7 +230461,7 @@ class Model {
|
|
|
229908
230461
|
return this.sourceInfos;
|
|
229909
230462
|
}
|
|
229910
230463
|
getQueries() {
|
|
229911
|
-
return this.
|
|
230464
|
+
return this.queries;
|
|
229912
230465
|
}
|
|
229913
230466
|
async getModel() {
|
|
229914
230467
|
if (this.compilationError) {
|
|
@@ -230159,7 +230712,7 @@ run: ${sourceName ? sourceName + "->" : ""}${queryName}`;
|
|
|
230159
230712
|
newSources: cell.newSources?.map((source) => JSON.stringify(source))
|
|
230160
230713
|
};
|
|
230161
230714
|
}
|
|
230162
|
-
static async getModelRuntime(packagePath, modelPath, connections) {
|
|
230715
|
+
static async getModelRuntime(packagePath, modelPath, connections, options) {
|
|
230163
230716
|
const fullModelPath = path5.join(packagePath, modelPath);
|
|
230164
230717
|
try {
|
|
230165
230718
|
if (!(await fs4.stat(fullModelPath)).isFile()) {
|
|
@@ -230184,10 +230737,17 @@ run: ${sourceName ? sourceName + "->" : ""}${queryName}`;
|
|
|
230184
230737
|
const urlReader = new HackyDataStylesAccumulator(URL_READER);
|
|
230185
230738
|
const duckdbConnection = connections.get("duckdb");
|
|
230186
230739
|
await duckdbConnection.runSQL(`SET FILE_SEARCH_PATH='${workingDirectory}';`);
|
|
230187
|
-
const
|
|
230740
|
+
const runtimeOptions = {
|
|
230188
230741
|
urlReader,
|
|
230189
230742
|
connections: new import_malloy2.FixedConnectionMap(connections, "duckdb")
|
|
230190
|
-
}
|
|
230743
|
+
};
|
|
230744
|
+
if (options?.buildManifest) {
|
|
230745
|
+
runtimeOptions.buildManifest = {
|
|
230746
|
+
entries: options.buildManifest,
|
|
230747
|
+
strict: false
|
|
230748
|
+
};
|
|
230749
|
+
}
|
|
230750
|
+
const runtime = new import_malloy2.Runtime(runtimeOptions);
|
|
230191
230751
|
const dataStyles = urlReader.getHackyAccumulatedDataStyles();
|
|
230192
230752
|
return { runtime, modelURL, importBaseURL, dataStyles, modelType };
|
|
230193
230753
|
}
|
|
@@ -230489,6 +231049,9 @@ class Package {
|
|
|
230489
231049
|
getPackageName() {
|
|
230490
231050
|
return this.packageName;
|
|
230491
231051
|
}
|
|
231052
|
+
getPackagePath() {
|
|
231053
|
+
return this.packagePath;
|
|
231054
|
+
}
|
|
230492
231055
|
getPackageMetadata() {
|
|
230493
231056
|
return this.packageMetadata;
|
|
230494
231057
|
}
|
|
@@ -230498,6 +231061,26 @@ class Package {
|
|
|
230498
231061
|
getModel(modelPath) {
|
|
230499
231062
|
return this.models.get(modelPath);
|
|
230500
231063
|
}
|
|
231064
|
+
getModelPaths() {
|
|
231065
|
+
return Array.from(this.models.keys());
|
|
231066
|
+
}
|
|
231067
|
+
async reloadAllModels(buildManifest) {
|
|
231068
|
+
const modelPaths = Array.from(this.models.keys());
|
|
231069
|
+
logger.info("Reloading all models with build manifest", {
|
|
231070
|
+
packageName: this.packageName,
|
|
231071
|
+
modelCount: modelPaths.length,
|
|
231072
|
+
manifestEntryCount: Object.keys(buildManifest).length
|
|
231073
|
+
});
|
|
231074
|
+
const reloaded = await Promise.all(modelPaths.map((modelPath) => Model.create(this.packageName, this.packagePath, modelPath, this.connections, { buildManifest })));
|
|
231075
|
+
const nextModels = new Map;
|
|
231076
|
+
for (const model of reloaded) {
|
|
231077
|
+
nextModels.set(model.getPath(), model);
|
|
231078
|
+
}
|
|
231079
|
+
this.models = nextModels;
|
|
231080
|
+
}
|
|
231081
|
+
getConnections() {
|
|
231082
|
+
return this.connections;
|
|
231083
|
+
}
|
|
230501
231084
|
getMalloyConnection(connectionName) {
|
|
230502
231085
|
const connection = this.connections.get(connectionName);
|
|
230503
231086
|
if (!connection) {
|
|
@@ -231186,16 +231769,25 @@ class ProjectStore {
|
|
|
231186
231769
|
metadata: project.metadata || {}
|
|
231187
231770
|
};
|
|
231188
231771
|
const existingProject = await repository.getProjectByName(projectName);
|
|
231772
|
+
let dbProject;
|
|
231189
231773
|
if (existingProject) {
|
|
231190
231774
|
const updateData = {
|
|
231191
231775
|
description: projectDescription,
|
|
231192
231776
|
metadata: project.metadata || {}
|
|
231193
231777
|
};
|
|
231194
231778
|
await repository.updateProject(existingProject.id, updateData);
|
|
231195
|
-
|
|
231779
|
+
dbProject = { id: existingProject.id, name: projectName };
|
|
231196
231780
|
} else {
|
|
231197
|
-
|
|
231781
|
+
dbProject = await repository.createProject(projectData);
|
|
231782
|
+
}
|
|
231783
|
+
const materializationStorage = project.metadata?.materializationStorage;
|
|
231784
|
+
if (materializationStorage?.catalogUrl && materializationStorage?.dataPath) {
|
|
231785
|
+
await this.storageManager.initializeDuckLakeForProject(dbProject.id, {
|
|
231786
|
+
catalogUrl: materializationStorage.catalogUrl,
|
|
231787
|
+
dataPath: materializationStorage.dataPath
|
|
231788
|
+
});
|
|
231198
231789
|
}
|
|
231790
|
+
return dbProject;
|
|
231199
231791
|
}
|
|
231200
231792
|
async addPackages(project, projectId, repository) {
|
|
231201
231793
|
const packages = await project.listPackages();
|
|
@@ -231579,7 +232171,7 @@ class ProjectStore {
|
|
|
231579
232171
|
return absoluteProjectPath;
|
|
231580
232172
|
}
|
|
231581
232173
|
isLocalPath(location) {
|
|
231582
|
-
return location.startsWith("./") || location.startsWith("~/") || location.startsWith("/") || path8.isAbsolute(location);
|
|
232174
|
+
return location.startsWith("./") || location.startsWith("../") || location.startsWith("~/") || location.startsWith("/") || path8.isAbsolute(location);
|
|
231583
232175
|
}
|
|
231584
232176
|
isGitHubURL(location) {
|
|
231585
232177
|
return location.startsWith("https://github.com/") || location.startsWith("git@github.com:");
|
|
@@ -231993,6 +232585,94 @@ class WatchModeController {
|
|
|
231993
232585
|
};
|
|
231994
232586
|
}
|
|
231995
232587
|
|
|
232588
|
+
// src/service/resolve_project.ts
|
|
232589
|
+
async function resolveProjectId(repository, projectName) {
|
|
232590
|
+
const dbProject = await repository.getProjectByName(projectName);
|
|
232591
|
+
if (!dbProject) {
|
|
232592
|
+
throw new ProjectNotFoundError(`Project '${projectName}' not found`);
|
|
232593
|
+
}
|
|
232594
|
+
return dbProject.id;
|
|
232595
|
+
}
|
|
232596
|
+
|
|
232597
|
+
// src/controller/manifest.controller.ts
|
|
232598
|
+
class ManifestController {
|
|
232599
|
+
projectStore;
|
|
232600
|
+
manifestService;
|
|
232601
|
+
constructor(projectStore, manifestService) {
|
|
232602
|
+
this.projectStore = projectStore;
|
|
232603
|
+
this.manifestService = manifestService;
|
|
232604
|
+
}
|
|
232605
|
+
async getManifest(projectName, packageName) {
|
|
232606
|
+
const repository = this.projectStore.storageManager.getRepository();
|
|
232607
|
+
const projectId = await resolveProjectId(repository, projectName);
|
|
232608
|
+
const project = await this.projectStore.getProject(projectName, false);
|
|
232609
|
+
await project.getPackage(packageName, false);
|
|
232610
|
+
return this.manifestService.getManifest(projectId, packageName);
|
|
232611
|
+
}
|
|
232612
|
+
async reloadManifest(projectName, packageName) {
|
|
232613
|
+
const repository = this.projectStore.storageManager.getRepository();
|
|
232614
|
+
const projectId = await resolveProjectId(repository, projectName);
|
|
232615
|
+
return this.manifestService.reloadManifest(projectId, packageName, projectName);
|
|
232616
|
+
}
|
|
232617
|
+
}
|
|
232618
|
+
|
|
232619
|
+
// src/controller/materialization.controller.ts
|
|
232620
|
+
class MaterializationController {
|
|
232621
|
+
materializationService;
|
|
232622
|
+
constructor(materializationService) {
|
|
232623
|
+
this.materializationService = materializationService;
|
|
232624
|
+
}
|
|
232625
|
+
async createMaterialization(projectName, packageName, body) {
|
|
232626
|
+
const options = this.validateCreateBody(body);
|
|
232627
|
+
return this.materializationService.createMaterialization(projectName, packageName, options);
|
|
232628
|
+
}
|
|
232629
|
+
validateCreateBody(body) {
|
|
232630
|
+
const result = {};
|
|
232631
|
+
if (body.forceRefresh !== undefined) {
|
|
232632
|
+
if (typeof body.forceRefresh !== "boolean") {
|
|
232633
|
+
throw new BadRequestError("forceRefresh must be a boolean");
|
|
232634
|
+
}
|
|
232635
|
+
result.forceRefresh = body.forceRefresh;
|
|
232636
|
+
}
|
|
232637
|
+
if (body.autoLoadManifest !== undefined) {
|
|
232638
|
+
if (typeof body.autoLoadManifest !== "boolean") {
|
|
232639
|
+
throw new BadRequestError("autoLoadManifest must be a boolean");
|
|
232640
|
+
}
|
|
232641
|
+
result.autoLoadManifest = body.autoLoadManifest;
|
|
232642
|
+
}
|
|
232643
|
+
return result;
|
|
232644
|
+
}
|
|
232645
|
+
async startMaterialization(projectName, packageName, materializationId) {
|
|
232646
|
+
return this.materializationService.startMaterialization(projectName, packageName, materializationId);
|
|
232647
|
+
}
|
|
232648
|
+
async stopMaterialization(projectName, packageName, materializationId) {
|
|
232649
|
+
return this.materializationService.stopMaterialization(projectName, packageName, materializationId);
|
|
232650
|
+
}
|
|
232651
|
+
async listMaterializations(projectName, packageName, options) {
|
|
232652
|
+
return this.materializationService.listMaterializations(projectName, packageName, options);
|
|
232653
|
+
}
|
|
232654
|
+
async getMaterialization(projectName, packageName, materializationId) {
|
|
232655
|
+
return this.materializationService.getMaterialization(projectName, packageName, materializationId);
|
|
232656
|
+
}
|
|
232657
|
+
async deleteMaterialization(projectName, packageName, materializationId) {
|
|
232658
|
+
return this.materializationService.deleteMaterialization(projectName, packageName, materializationId);
|
|
232659
|
+
}
|
|
232660
|
+
async teardownPackage(projectName, packageName, body) {
|
|
232661
|
+
const options = this.validateTeardownBody(body);
|
|
232662
|
+
return this.materializationService.teardownPackage(projectName, packageName, options);
|
|
232663
|
+
}
|
|
232664
|
+
validateTeardownBody(body) {
|
|
232665
|
+
const options = {};
|
|
232666
|
+
if (body.dryRun !== undefined) {
|
|
232667
|
+
if (typeof body.dryRun !== "boolean") {
|
|
232668
|
+
throw new BadRequestError("dryRun must be a boolean");
|
|
232669
|
+
}
|
|
232670
|
+
options.dryRun = body.dryRun;
|
|
232671
|
+
}
|
|
232672
|
+
return options;
|
|
232673
|
+
}
|
|
232674
|
+
}
|
|
232675
|
+
|
|
231996
232676
|
// ../../node_modules/@modelcontextprotocol/sdk/dist/esm/shared/protocol.js
|
|
231997
232677
|
var DEFAULT_REQUEST_TIMEOUT_MSEC = 60000;
|
|
231998
232678
|
|
|
@@ -232334,7 +233014,7 @@ function mergeCapabilities(base, additional) {
|
|
|
232334
233014
|
}
|
|
232335
233015
|
|
|
232336
233016
|
// ../../node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js
|
|
232337
|
-
var import_ajv = __toESM(require_ajv());
|
|
233017
|
+
var import_ajv = __toESM(require_ajv(), 1);
|
|
232338
233018
|
|
|
232339
233019
|
class Server extends Protocol {
|
|
232340
233020
|
constructor(_serverInfo, options) {
|
|
@@ -234624,7 +235304,7 @@ var EMPTY_COMPLETION_RESULT = {
|
|
|
234624
235304
|
};
|
|
234625
235305
|
|
|
234626
235306
|
// src/mcp/prompts/handlers.ts
|
|
234627
|
-
var Handlebars = __toESM(require_lib8());
|
|
235307
|
+
var Handlebars = __toESM(require_lib8(), 1);
|
|
234628
235308
|
|
|
234629
235309
|
// src/mcp/prompts/prompt_definitions.ts
|
|
234630
235310
|
var withVersion = (name, v) => `${name}@${v}`;
|
|
@@ -235754,7 +236434,7 @@ function registerExecuteQueryTool(mcpServer, projectStore) {
|
|
|
235754
236434
|
try {
|
|
235755
236435
|
if (query) {
|
|
235756
236436
|
const { result } = await model.getQueryResults(undefined, undefined, query, filterParams);
|
|
235757
|
-
const { validateRenderTags: validateRenderTags2 } = await Promise.resolve().then(() => __toESM(require_dist10()));
|
|
236437
|
+
const { validateRenderTags: validateRenderTags2 } = await Promise.resolve().then(() => __toESM(require_dist10(), 1));
|
|
235758
236438
|
const renderLogs = validateRenderTags2(result);
|
|
235759
236439
|
const baseUriComponents = {
|
|
235760
236440
|
project: projectName,
|
|
@@ -235790,7 +236470,7 @@ ${JSON.stringify(renderLogs, null, 2)}`
|
|
|
235790
236470
|
return { isError: false, content };
|
|
235791
236471
|
} else if (queryName) {
|
|
235792
236472
|
const { result } = await model.getQueryResults(sourceName, queryName, undefined, filterParams);
|
|
235793
|
-
const { validateRenderTags: validateRenderTags2 } = await Promise.resolve().then(() => __toESM(require_dist10()));
|
|
236473
|
+
const { validateRenderTags: validateRenderTags2 } = await Promise.resolve().then(() => __toESM(require_dist10(), 1));
|
|
235794
236474
|
const renderLogs = validateRenderTags2(result);
|
|
235795
236475
|
const baseUriComponents = {
|
|
235796
236476
|
project: projectName,
|
|
@@ -235887,6 +236567,616 @@ function initializeMcpServer(projectStore) {
|
|
|
235887
236567
|
return mcpServer;
|
|
235888
236568
|
}
|
|
235889
236569
|
|
|
236570
|
+
// src/service/manifest_service.ts
|
|
236571
|
+
class ManifestService {
|
|
236572
|
+
projectStore;
|
|
236573
|
+
constructor(projectStore) {
|
|
236574
|
+
this.projectStore = projectStore;
|
|
236575
|
+
}
|
|
236576
|
+
manifestStoreFor(projectId) {
|
|
236577
|
+
return this.projectStore.storageManager.getManifestStore(projectId);
|
|
236578
|
+
}
|
|
236579
|
+
async getManifest(projectId, packageName) {
|
|
236580
|
+
return this.manifestStoreFor(projectId).getManifest(projectId, packageName);
|
|
236581
|
+
}
|
|
236582
|
+
async writeEntry(projectId, packageName, buildId, tableName, sourceName, connectionName) {
|
|
236583
|
+
await this.manifestStoreFor(projectId).writeEntry(projectId, packageName, buildId, tableName, sourceName, connectionName);
|
|
236584
|
+
}
|
|
236585
|
+
async deleteEntry(projectId, entryId) {
|
|
236586
|
+
await this.manifestStoreFor(projectId).deleteEntry(entryId);
|
|
236587
|
+
}
|
|
236588
|
+
async reloadManifest(projectId, packageName, projectName) {
|
|
236589
|
+
const manifest = await this.getManifest(projectId, packageName);
|
|
236590
|
+
const project = await this.projectStore.getProject(projectName, false);
|
|
236591
|
+
const pkg = await project.getPackage(packageName, false);
|
|
236592
|
+
await pkg.reloadAllModels(manifest.entries);
|
|
236593
|
+
logger.info("Reloaded manifest and recompiled models", {
|
|
236594
|
+
projectId,
|
|
236595
|
+
packageName,
|
|
236596
|
+
entryCount: Object.keys(manifest.entries).length
|
|
236597
|
+
});
|
|
236598
|
+
return manifest;
|
|
236599
|
+
}
|
|
236600
|
+
async listEntries(projectId, packageName) {
|
|
236601
|
+
return this.manifestStoreFor(projectId).listEntries(projectId, packageName);
|
|
236602
|
+
}
|
|
236603
|
+
}
|
|
236604
|
+
|
|
236605
|
+
// src/service/materialization_service.ts
|
|
236606
|
+
var import_malloy6 = require("@malloydata/malloy");
|
|
236607
|
+
|
|
236608
|
+
// src/service/materialized_table_gc.ts
|
|
236609
|
+
var import_malloy5 = require("@malloydata/malloy");
|
|
236610
|
+
|
|
236611
|
+
// src/service/quoting.ts
|
|
236612
|
+
function quoteTablePath(path10, dialect) {
|
|
236613
|
+
return path10.split(".").map((seg) => dialect.quoteTablePath(seg)).join(".");
|
|
236614
|
+
}
|
|
236615
|
+
function splitTablePath(tableName) {
|
|
236616
|
+
const lastDot = tableName.lastIndexOf(".");
|
|
236617
|
+
if (lastDot >= 0) {
|
|
236618
|
+
return {
|
|
236619
|
+
schemaPrefix: tableName.substring(0, lastDot + 1),
|
|
236620
|
+
bareName: tableName.substring(lastDot + 1)
|
|
236621
|
+
};
|
|
236622
|
+
}
|
|
236623
|
+
return { schemaPrefix: "", bareName: tableName };
|
|
236624
|
+
}
|
|
236625
|
+
|
|
236626
|
+
// src/service/materialized_table_gc.ts
|
|
236627
|
+
var DIALECTS = Object.freeze({
|
|
236628
|
+
duckdb: new import_malloy5.DuckDBDialect,
|
|
236629
|
+
standardsql: new import_malloy5.StandardSQLDialect,
|
|
236630
|
+
trino: new import_malloy5.TrinoDialect,
|
|
236631
|
+
postgres: new import_malloy5.PostgresDialect,
|
|
236632
|
+
snowflake: new import_malloy5.SnowflakeDialect,
|
|
236633
|
+
mysql: new import_malloy5.MySQLDialect,
|
|
236634
|
+
databricks: new import_malloy5.DatabricksDialect
|
|
236635
|
+
});
|
|
236636
|
+
function liveTableKey(connectionName, tableName) {
|
|
236637
|
+
return `${connectionName}::${tableName}`;
|
|
236638
|
+
}
|
|
236639
|
+
async function processOneEntry(entry, ctx, liveTables) {
|
|
236640
|
+
const stagingTableName = `${entry.tableName}${stagingSuffix(entry.buildId)}`;
|
|
236641
|
+
const targetIsLive = liveTables.has(liveTableKey(entry.connectionName, entry.tableName));
|
|
236642
|
+
const connection = ctx.connections.get(entry.connectionName);
|
|
236643
|
+
if (!connection) {
|
|
236644
|
+
if (ctx.forceDeleteRowOnMissingConnection && !ctx.dryRun) {
|
|
236645
|
+
try {
|
|
236646
|
+
await ctx.manifestService.deleteEntry(ctx.projectId, entry.id);
|
|
236647
|
+
logger.warn("GC: deleted manifest row whose connection is gone; physical table (if any) is orphaned", {
|
|
236648
|
+
manifestEntryId: entry.id,
|
|
236649
|
+
tableName: entry.tableName,
|
|
236650
|
+
connectionName: entry.connectionName
|
|
236651
|
+
});
|
|
236652
|
+
return {
|
|
236653
|
+
dropped: {
|
|
236654
|
+
buildId: entry.buildId,
|
|
236655
|
+
tableName: entry.tableName,
|
|
236656
|
+
connectionName: entry.connectionName,
|
|
236657
|
+
stagingTableName,
|
|
236658
|
+
targetDropSkipped: true
|
|
236659
|
+
}
|
|
236660
|
+
};
|
|
236661
|
+
} catch (err) {
|
|
236662
|
+
return {
|
|
236663
|
+
error: {
|
|
236664
|
+
buildId: entry.buildId,
|
|
236665
|
+
tableName: entry.tableName,
|
|
236666
|
+
connectionName: entry.connectionName,
|
|
236667
|
+
error: err instanceof Error ? err.message : String(err)
|
|
236668
|
+
}
|
|
236669
|
+
};
|
|
236670
|
+
}
|
|
236671
|
+
}
|
|
236672
|
+
return {
|
|
236673
|
+
error: {
|
|
236674
|
+
buildId: entry.buildId,
|
|
236675
|
+
tableName: entry.tableName,
|
|
236676
|
+
connectionName: entry.connectionName,
|
|
236677
|
+
error: `Connection '${entry.connectionName}' is not available`
|
|
236678
|
+
}
|
|
236679
|
+
};
|
|
236680
|
+
}
|
|
236681
|
+
const dialect = DIALECTS[connection.dialectName];
|
|
236682
|
+
if (!dialect) {
|
|
236683
|
+
return {
|
|
236684
|
+
error: {
|
|
236685
|
+
buildId: entry.buildId,
|
|
236686
|
+
tableName: entry.tableName,
|
|
236687
|
+
connectionName: entry.connectionName,
|
|
236688
|
+
error: `No dialect registered for '${connection.dialectName}'`
|
|
236689
|
+
}
|
|
236690
|
+
};
|
|
236691
|
+
}
|
|
236692
|
+
if (ctx.dryRun) {
|
|
236693
|
+
return {
|
|
236694
|
+
dropped: {
|
|
236695
|
+
buildId: entry.buildId,
|
|
236696
|
+
tableName: entry.tableName,
|
|
236697
|
+
connectionName: entry.connectionName,
|
|
236698
|
+
stagingTableName,
|
|
236699
|
+
targetDropSkipped: targetIsLive || undefined
|
|
236700
|
+
}
|
|
236701
|
+
};
|
|
236702
|
+
}
|
|
236703
|
+
const quoted = (p) => quoteTablePath(p, dialect);
|
|
236704
|
+
try {
|
|
236705
|
+
await ctx.manifestService.deleteEntry(ctx.projectId, entry.id);
|
|
236706
|
+
} catch (err) {
|
|
236707
|
+
const error = err instanceof Error ? err.message : String(err);
|
|
236708
|
+
logger.warn("GC: failed to delete manifest row; skipping physical drop", {
|
|
236709
|
+
manifestEntryId: entry.id,
|
|
236710
|
+
tableName: entry.tableName,
|
|
236711
|
+
error
|
|
236712
|
+
});
|
|
236713
|
+
return {
|
|
236714
|
+
error: {
|
|
236715
|
+
buildId: entry.buildId,
|
|
236716
|
+
tableName: entry.tableName,
|
|
236717
|
+
connectionName: entry.connectionName,
|
|
236718
|
+
error
|
|
236719
|
+
}
|
|
236720
|
+
};
|
|
236721
|
+
}
|
|
236722
|
+
if (targetIsLive) {
|
|
236723
|
+
logger.info("GC: skipping target DROP; another active manifest entry claims this (connection, tableName)", {
|
|
236724
|
+
tableName: entry.tableName,
|
|
236725
|
+
connectionName: entry.connectionName,
|
|
236726
|
+
retiredBuildId: entry.buildId
|
|
236727
|
+
});
|
|
236728
|
+
} else {
|
|
236729
|
+
try {
|
|
236730
|
+
await connection.runSQL(`DROP TABLE IF EXISTS ${quoted(entry.tableName)}`);
|
|
236731
|
+
} catch (err) {
|
|
236732
|
+
logger.warn("GC: deleted manifest row but failed to drop materialized table (orphaned)", {
|
|
236733
|
+
tableName: entry.tableName,
|
|
236734
|
+
connectionName: entry.connectionName,
|
|
236735
|
+
error: err instanceof Error ? err.message : String(err)
|
|
236736
|
+
});
|
|
236737
|
+
}
|
|
236738
|
+
}
|
|
236739
|
+
try {
|
|
236740
|
+
await connection.runSQL(`DROP TABLE IF EXISTS ${quoted(stagingTableName)}`);
|
|
236741
|
+
} catch (err) {
|
|
236742
|
+
logger.warn("GC: failed to drop staging table (best-effort)", {
|
|
236743
|
+
stagingTableName,
|
|
236744
|
+
connectionName: entry.connectionName,
|
|
236745
|
+
error: err instanceof Error ? err.message : String(err)
|
|
236746
|
+
});
|
|
236747
|
+
}
|
|
236748
|
+
return {
|
|
236749
|
+
dropped: {
|
|
236750
|
+
buildId: entry.buildId,
|
|
236751
|
+
tableName: entry.tableName,
|
|
236752
|
+
connectionName: entry.connectionName,
|
|
236753
|
+
stagingTableName,
|
|
236754
|
+
targetDropSkipped: targetIsLive || undefined
|
|
236755
|
+
}
|
|
236756
|
+
};
|
|
236757
|
+
}
|
|
236758
|
+
async function dropManifestEntries(entries, ctx) {
|
|
236759
|
+
const dropped = [];
|
|
236760
|
+
const errors2 = [];
|
|
236761
|
+
const liveTables = ctx.liveTables ?? new Set;
|
|
236762
|
+
for (const entry of entries) {
|
|
236763
|
+
const result = await processOneEntry(entry, ctx, liveTables);
|
|
236764
|
+
if (result.dropped)
|
|
236765
|
+
dropped.push(result.dropped);
|
|
236766
|
+
if (result.error)
|
|
236767
|
+
errors2.push(result.error);
|
|
236768
|
+
}
|
|
236769
|
+
return { dropped, errors: errors2 };
|
|
236770
|
+
}
|
|
236771
|
+
|
|
236772
|
+
// src/service/materialization_service.ts
|
|
236773
|
+
var STAGING_BUILD_ID_LEN = 12;
|
|
236774
|
+
function stagingSuffix(buildId) {
|
|
236775
|
+
return `_${buildId.substring(0, STAGING_BUILD_ID_LEN)}`;
|
|
236776
|
+
}
|
|
236777
|
+
function manifestTableKey(connectionName, tableName) {
|
|
236778
|
+
return `${connectionName}::${tableName}`;
|
|
236779
|
+
}
|
|
236780
|
+
async function tablePhysicallyExists(connection, quotedTableName) {
|
|
236781
|
+
try {
|
|
236782
|
+
await connection.runSQL(`SELECT 1 FROM ${quotedTableName} WHERE 1=0`);
|
|
236783
|
+
return true;
|
|
236784
|
+
} catch {
|
|
236785
|
+
return false;
|
|
236786
|
+
}
|
|
236787
|
+
}
|
|
236788
|
+
var VALID_TRANSITIONS = {
|
|
236789
|
+
PENDING: ["RUNNING", "CANCELLED"],
|
|
236790
|
+
RUNNING: ["SUCCESS", "FAILED", "CANCELLED"],
|
|
236791
|
+
SUCCESS: [],
|
|
236792
|
+
FAILED: [],
|
|
236793
|
+
CANCELLED: []
|
|
236794
|
+
};
|
|
236795
|
+
|
|
236796
|
+
class MaterializationService {
|
|
236797
|
+
projectStore;
|
|
236798
|
+
manifestService;
|
|
236799
|
+
runningAbortControllers = new Map;
|
|
236800
|
+
constructor(projectStore, manifestService) {
|
|
236801
|
+
this.projectStore = projectStore;
|
|
236802
|
+
this.manifestService = manifestService;
|
|
236803
|
+
}
|
|
236804
|
+
get repository() {
|
|
236805
|
+
return this.projectStore.storageManager.getRepository();
|
|
236806
|
+
}
|
|
236807
|
+
validateTransition(current, next) {
|
|
236808
|
+
const allowed = VALID_TRANSITIONS[current];
|
|
236809
|
+
if (!allowed.includes(next)) {
|
|
236810
|
+
throw new InvalidStateTransitionError(`Cannot transition from ${current} to ${next}`);
|
|
236811
|
+
}
|
|
236812
|
+
}
|
|
236813
|
+
async transitionExecution(executionId, newStatus, extra) {
|
|
236814
|
+
const execution = await this.repository.getMaterializationById(executionId);
|
|
236815
|
+
if (!execution) {
|
|
236816
|
+
throw new MaterializationNotFoundError(`Execution ${executionId} not found`);
|
|
236817
|
+
}
|
|
236818
|
+
this.validateTransition(execution.status, newStatus);
|
|
236819
|
+
return this.repository.updateMaterialization(executionId, {
|
|
236820
|
+
status: newStatus,
|
|
236821
|
+
...extra
|
|
236822
|
+
});
|
|
236823
|
+
}
|
|
236824
|
+
async listMaterializations(projectName, packageName, options) {
|
|
236825
|
+
const projectId = await this.resolveProjectId(projectName);
|
|
236826
|
+
return this.repository.listMaterializations(projectId, packageName, options);
|
|
236827
|
+
}
|
|
236828
|
+
async getMaterialization(projectName, packageName, buildId) {
|
|
236829
|
+
const projectId = await this.resolveProjectId(projectName);
|
|
236830
|
+
const execution = await this.repository.getMaterializationById(buildId);
|
|
236831
|
+
if (!execution || execution.projectId !== projectId || execution.packageName !== packageName) {
|
|
236832
|
+
throw new MaterializationNotFoundError(`Materialization ${buildId} not found for package ${packageName}`);
|
|
236833
|
+
}
|
|
236834
|
+
return execution;
|
|
236835
|
+
}
|
|
236836
|
+
async createMaterialization(projectName, packageName, options = {}) {
|
|
236837
|
+
const projectId = await this.resolveProjectId(projectName);
|
|
236838
|
+
const project = await this.projectStore.getProject(projectName, false);
|
|
236839
|
+
await project.getPackage(packageName, false);
|
|
236840
|
+
const active = await this.repository.getActiveMaterialization(projectId, packageName);
|
|
236841
|
+
if (active) {
|
|
236842
|
+
throw new MaterializationConflictError(`Package ${packageName} already has an active materialization (${active.id})`);
|
|
236843
|
+
}
|
|
236844
|
+
const metadata = {
|
|
236845
|
+
forceRefresh: options.forceRefresh ?? false,
|
|
236846
|
+
autoLoadManifest: options.autoLoadManifest ?? false
|
|
236847
|
+
};
|
|
236848
|
+
try {
|
|
236849
|
+
return await this.repository.createMaterialization(projectId, packageName, "PENDING", metadata);
|
|
236850
|
+
} catch (err) {
|
|
236851
|
+
if (err instanceof DuplicateActiveMaterializationError) {
|
|
236852
|
+
const winner = await this.repository.getActiveMaterialization(projectId, packageName);
|
|
236853
|
+
throw new MaterializationConflictError(winner ? `Package ${packageName} already has an active materialization (${winner.id})` : `Package ${packageName} already has an active materialization`);
|
|
236854
|
+
}
|
|
236855
|
+
throw err;
|
|
236856
|
+
}
|
|
236857
|
+
}
|
|
236858
|
+
async startMaterialization(projectName, packageName, buildId) {
|
|
236859
|
+
const projectId = await this.resolveProjectId(projectName);
|
|
236860
|
+
const execution = await this.getMaterialization(projectName, packageName, buildId);
|
|
236861
|
+
if (execution.status !== "PENDING") {
|
|
236862
|
+
throw new InvalidStateTransitionError(`Materialization ${buildId} is ${execution.status}, expected PENDING`);
|
|
236863
|
+
}
|
|
236864
|
+
const active = await this.repository.getActiveMaterialization(projectId, packageName);
|
|
236865
|
+
if (active && active.id !== execution.id) {
|
|
236866
|
+
throw new MaterializationConflictError(`Package ${packageName} already has an active materialization (${active.id})`);
|
|
236867
|
+
}
|
|
236868
|
+
const running = await this.transitionExecution(execution.id, "RUNNING", {
|
|
236869
|
+
startedAt: new Date
|
|
236870
|
+
});
|
|
236871
|
+
const metadata = execution.metadata ?? {};
|
|
236872
|
+
this.runMaterialization(execution.id, projectName, projectId, packageName, metadata).catch((err) => {
|
|
236873
|
+
logger.error("Unhandled error in background build", {
|
|
236874
|
+
executionId: execution.id,
|
|
236875
|
+
error: err instanceof Error ? err.message : String(err)
|
|
236876
|
+
});
|
|
236877
|
+
});
|
|
236878
|
+
return running;
|
|
236879
|
+
}
|
|
236880
|
+
async runMaterialization(executionId, projectName, projectId, packageName, metadata) {
|
|
236881
|
+
const abortController = new AbortController;
|
|
236882
|
+
this.runningAbortControllers.set(executionId, abortController);
|
|
236883
|
+
try {
|
|
236884
|
+
const buildMetadata = await this.executeBuild(projectName, projectId, packageName, !!metadata.forceRefresh, abortController.signal);
|
|
236885
|
+
if (metadata.autoLoadManifest) {
|
|
236886
|
+
const updatedManifest = await this.manifestService.getManifest(projectId, packageName);
|
|
236887
|
+
const project = await this.projectStore.getProject(projectName, false);
|
|
236888
|
+
const pkg = await project.getPackage(packageName, false);
|
|
236889
|
+
await pkg.reloadAllModels(updatedManifest.entries);
|
|
236890
|
+
}
|
|
236891
|
+
await this.transitionExecution(executionId, "SUCCESS", {
|
|
236892
|
+
completedAt: new Date,
|
|
236893
|
+
metadata: { ...metadata, ...buildMetadata }
|
|
236894
|
+
});
|
|
236895
|
+
} catch (err) {
|
|
236896
|
+
const errorMessage = err instanceof Error ? err.message : String(err);
|
|
236897
|
+
try {
|
|
236898
|
+
if (abortController.signal.aborted) {
|
|
236899
|
+
await this.transitionExecution(executionId, "CANCELLED", {
|
|
236900
|
+
completedAt: new Date,
|
|
236901
|
+
error: "Build cancelled"
|
|
236902
|
+
});
|
|
236903
|
+
} else {
|
|
236904
|
+
await this.transitionExecution(executionId, "FAILED", {
|
|
236905
|
+
completedAt: new Date,
|
|
236906
|
+
error: errorMessage
|
|
236907
|
+
});
|
|
236908
|
+
}
|
|
236909
|
+
} catch (transitionErr) {
|
|
236910
|
+
logger.error("Failed to transition execution after build error", {
|
|
236911
|
+
executionId,
|
|
236912
|
+
originalError: errorMessage,
|
|
236913
|
+
transitionError: transitionErr instanceof Error ? transitionErr.message : String(transitionErr)
|
|
236914
|
+
});
|
|
236915
|
+
}
|
|
236916
|
+
} finally {
|
|
236917
|
+
this.runningAbortControllers.delete(executionId);
|
|
236918
|
+
}
|
|
236919
|
+
}
|
|
236920
|
+
async stopMaterialization(projectName, packageName, buildId) {
|
|
236921
|
+
const execution = await this.getMaterialization(projectName, packageName, buildId);
|
|
236922
|
+
if (execution.status !== "RUNNING" && execution.status !== "PENDING") {
|
|
236923
|
+
throw new InvalidStateTransitionError(`Materialization ${buildId} is ${execution.status}, cannot stop`);
|
|
236924
|
+
}
|
|
236925
|
+
if (execution.status === "PENDING") {
|
|
236926
|
+
return this.transitionExecution(execution.id, "CANCELLED", {
|
|
236927
|
+
completedAt: new Date,
|
|
236928
|
+
error: "Build cancelled before starting"
|
|
236929
|
+
});
|
|
236930
|
+
}
|
|
236931
|
+
const abortController = this.runningAbortControllers.get(execution.id);
|
|
236932
|
+
if (abortController) {
|
|
236933
|
+
abortController.abort();
|
|
236934
|
+
return execution;
|
|
236935
|
+
} else {
|
|
236936
|
+
return this.transitionExecution(execution.id, "CANCELLED", {
|
|
236937
|
+
completedAt: new Date,
|
|
236938
|
+
error: "Force cancelled: execution was orphaned"
|
|
236939
|
+
});
|
|
236940
|
+
}
|
|
236941
|
+
}
|
|
236942
|
+
async deleteMaterialization(projectName, packageName, materializationId) {
|
|
236943
|
+
const execution = await this.getMaterialization(projectName, packageName, materializationId);
|
|
236944
|
+
if (execution.status === "PENDING" || execution.status === "RUNNING") {
|
|
236945
|
+
throw new InvalidStateTransitionError(`Cannot delete materialization ${materializationId} while it is ${execution.status}`);
|
|
236946
|
+
}
|
|
236947
|
+
await this.repository.deleteMaterialization(execution.id);
|
|
236948
|
+
}
|
|
236949
|
+
async teardownPackage(projectName, packageName, options = {}) {
|
|
236950
|
+
const projectId = await this.resolveProjectId(projectName);
|
|
236951
|
+
const active = await this.repository.getActiveMaterialization(projectId, packageName);
|
|
236952
|
+
if (active) {
|
|
236953
|
+
throw new MaterializationConflictError(`Package ${packageName} has an active materialization (${active.id}); cannot tear down`);
|
|
236954
|
+
}
|
|
236955
|
+
const project = await this.projectStore.getProject(projectName, false);
|
|
236956
|
+
const pkg = await project.getPackage(packageName, false);
|
|
236957
|
+
const connections = pkg.getConnections();
|
|
236958
|
+
const entries = await this.manifestService.listEntries(projectId, packageName);
|
|
236959
|
+
return dropManifestEntries(entries, {
|
|
236960
|
+
connections,
|
|
236961
|
+
manifestService: this.manifestService,
|
|
236962
|
+
projectId,
|
|
236963
|
+
dryRun: options.dryRun,
|
|
236964
|
+
forceDeleteRowOnMissingConnection: true
|
|
236965
|
+
});
|
|
236966
|
+
}
|
|
236967
|
+
async executeBuild(projectName, projectId, packageName, forceRefresh, signal) {
|
|
236968
|
+
logger.info("Starting materialization build", {
|
|
236969
|
+
projectName,
|
|
236970
|
+
packageName
|
|
236971
|
+
});
|
|
236972
|
+
const project = await this.projectStore.getProject(projectName, false);
|
|
236973
|
+
const pkg = await project.getPackage(packageName, false);
|
|
236974
|
+
const manifest = new import_malloy6.Manifest;
|
|
236975
|
+
const existingManifest = await this.manifestService.getManifest(projectId, packageName);
|
|
236976
|
+
manifest.loadText(JSON.stringify(existingManifest));
|
|
236977
|
+
const existingEntries = await this.manifestService.listEntries(projectId, packageName);
|
|
236978
|
+
const knownMaterializedTables = new Set(existingEntries.map((e) => manifestTableKey(e.connectionName, e.tableName)));
|
|
236979
|
+
const { graphs, sources, connectionDigests } = await this.compilePackageBuildPlan(pkg, signal);
|
|
236980
|
+
if (graphs.length === 0) {
|
|
236981
|
+
logger.info("No persist sources to build");
|
|
236982
|
+
return { sourcesBuilt: 0, sourcesSkipped: 0 };
|
|
236983
|
+
}
|
|
236984
|
+
const connections = pkg.getConnections();
|
|
236985
|
+
let sourcesBuilt = 0;
|
|
236986
|
+
let sourcesSkipped = 0;
|
|
236987
|
+
const sourceResults = [];
|
|
236988
|
+
for (const graph of graphs) {
|
|
236989
|
+
const connection = connections.get(graph.connectionName);
|
|
236990
|
+
if (!connection) {
|
|
236991
|
+
throw new BadRequestError(`Connection '${graph.connectionName}' not found`);
|
|
236992
|
+
}
|
|
236993
|
+
for (const level of graph.nodes) {
|
|
236994
|
+
for (const node of level) {
|
|
236995
|
+
if (signal.aborted)
|
|
236996
|
+
throw new Error("Build cancelled");
|
|
236997
|
+
const persistSource = sources[node.sourceID];
|
|
236998
|
+
if (!persistSource) {
|
|
236999
|
+
logger.warn(`Source ${node.sourceID} not found in build plan, skipping`);
|
|
237000
|
+
continue;
|
|
237001
|
+
}
|
|
237002
|
+
const result = await this.buildOneSource(persistSource, manifest, connection, connectionDigests, forceRefresh, projectId, packageName, knownMaterializedTables);
|
|
237003
|
+
sourceResults.push(result);
|
|
237004
|
+
if (result.status === "built")
|
|
237005
|
+
sourcesBuilt++;
|
|
237006
|
+
else
|
|
237007
|
+
sourcesSkipped++;
|
|
237008
|
+
}
|
|
237009
|
+
}
|
|
237010
|
+
}
|
|
237011
|
+
const gcResult = await this.runPostBuildGc(manifest, projectId, packageName, connections);
|
|
237012
|
+
logger.info("Materialization build complete", {
|
|
237013
|
+
sourcesBuilt,
|
|
237014
|
+
sourcesSkipped,
|
|
237015
|
+
gcDropped: gcResult.dropped.length,
|
|
237016
|
+
gcErrors: gcResult.errors.length
|
|
237017
|
+
});
|
|
237018
|
+
return {
|
|
237019
|
+
sourcesBuilt,
|
|
237020
|
+
sourcesSkipped,
|
|
237021
|
+
sources: sourceResults,
|
|
237022
|
+
gcDropped: gcResult.dropped,
|
|
237023
|
+
gcErrors: gcResult.errors
|
|
237024
|
+
};
|
|
237025
|
+
}
|
|
237026
|
+
async compilePackageBuildPlan(pkg, signal) {
|
|
237027
|
+
const modelPaths = pkg.getModelPaths();
|
|
237028
|
+
const allGraphs = [];
|
|
237029
|
+
const allSources = {};
|
|
237030
|
+
for (const modelPath of modelPaths) {
|
|
237031
|
+
if (signal.aborted)
|
|
237032
|
+
throw new Error("Build cancelled");
|
|
237033
|
+
const { runtime, modelURL, importBaseURL } = await Model.getModelRuntime(pkg.getPackagePath(), modelPath, pkg.getConnections());
|
|
237034
|
+
const modelMaterializer = runtime.loadModel(modelURL, {
|
|
237035
|
+
importBaseURL
|
|
237036
|
+
});
|
|
237037
|
+
const malloyModel = await modelMaterializer.getModel();
|
|
237038
|
+
const modelTag = malloyModel.tagParse({ prefix: /^##! / }).tag;
|
|
237039
|
+
if (!modelTag.has("experimental", "persistence")) {
|
|
237040
|
+
logger.debug("Model has no ##! experimental.persistence tag, skipping", { modelPath });
|
|
237041
|
+
continue;
|
|
237042
|
+
}
|
|
237043
|
+
const buildPlan = malloyModel.getBuildPlan();
|
|
237044
|
+
for (const msg of buildPlan.tagParseLog) {
|
|
237045
|
+
logger.warn("Persist annotation issue", {
|
|
237046
|
+
modelPath,
|
|
237047
|
+
message: msg.message,
|
|
237048
|
+
severity: msg.severity,
|
|
237049
|
+
code: msg.code
|
|
237050
|
+
});
|
|
237051
|
+
}
|
|
237052
|
+
if (buildPlan.graphs.length > 0) {
|
|
237053
|
+
allGraphs.push(...buildPlan.graphs);
|
|
237054
|
+
for (const [sourceID, source] of Object.entries(buildPlan.sources)) {
|
|
237055
|
+
if (allSources[sourceID]) {
|
|
237056
|
+
logger.warn(`Duplicate sourceID "${sourceID}" from model ${modelPath}, overwriting previous definition`);
|
|
237057
|
+
}
|
|
237058
|
+
allSources[sourceID] = source;
|
|
237059
|
+
}
|
|
237060
|
+
}
|
|
237061
|
+
}
|
|
237062
|
+
logger.info("Build plan", {
|
|
237063
|
+
sourceCount: Object.keys(allSources).length,
|
|
237064
|
+
graphCount: allGraphs.length
|
|
237065
|
+
});
|
|
237066
|
+
const tableOwners = new Map;
|
|
237067
|
+
for (const [sourceID, source] of Object.entries(allSources)) {
|
|
237068
|
+
const tableName = source.tagParse({ prefix: /^#@ / }).tag.text("name") || source.name;
|
|
237069
|
+
const key = `${source.connectionName}::${tableName}`;
|
|
237070
|
+
const existing = tableOwners.get(key);
|
|
237071
|
+
if (existing) {
|
|
237072
|
+
throw new BadRequestError(`Persist target collision: sources '${existing}' and '${sourceID}' both resolve to table '${tableName}' on connection '${source.connectionName}'. Disambiguate with '#@ persist name=...'.`);
|
|
237073
|
+
}
|
|
237074
|
+
tableOwners.set(key, sourceID);
|
|
237075
|
+
}
|
|
237076
|
+
const connections = pkg.getConnections();
|
|
237077
|
+
const connectionDigests = {};
|
|
237078
|
+
for (const graph of allGraphs) {
|
|
237079
|
+
const conn = connections.get(graph.connectionName);
|
|
237080
|
+
if (conn && !connectionDigests[graph.connectionName]) {
|
|
237081
|
+
connectionDigests[graph.connectionName] = await conn.getDigest();
|
|
237082
|
+
}
|
|
237083
|
+
}
|
|
237084
|
+
return { graphs: allGraphs, sources: allSources, connectionDigests };
|
|
237085
|
+
}
|
|
237086
|
+
async buildOneSource(persistSource, manifest, connection, connectionDigests, forceRefresh, projectId, packageName, knownMaterializedTables) {
|
|
237087
|
+
const buildIdSQL = persistSource.getSQL();
|
|
237088
|
+
const digest = connectionDigests[persistSource.connectionName];
|
|
237089
|
+
const buildId = persistSource.makeBuildId(digest, buildIdSQL);
|
|
237090
|
+
if (manifest.buildManifest.entries[buildId] && !forceRefresh) {
|
|
237091
|
+
manifest.touch(buildId);
|
|
237092
|
+
logger.info(`Source ${persistSource.name} up to date, skipping`, {
|
|
237093
|
+
buildId
|
|
237094
|
+
});
|
|
237095
|
+
return { name: persistSource.name, status: "skipped", buildId };
|
|
237096
|
+
}
|
|
237097
|
+
const buildSQL = persistSource.getSQL({
|
|
237098
|
+
buildManifest: manifest.buildManifest,
|
|
237099
|
+
connectionDigests
|
|
237100
|
+
});
|
|
237101
|
+
const connectionName = persistSource.connectionName;
|
|
237102
|
+
const tableName = persistSource.tagParse({ prefix: /^#@ / }).tag.text("name") || persistSource.name;
|
|
237103
|
+
const { schemaPrefix, bareName } = splitTablePath(tableName);
|
|
237104
|
+
const stagingTableName = `${schemaPrefix}${bareName}${stagingSuffix(buildId)}`;
|
|
237105
|
+
const dialect = persistSource.dialect;
|
|
237106
|
+
const quoted = (p) => quoteTablePath(p, dialect);
|
|
237107
|
+
const tableKey = manifestTableKey(connectionName, tableName);
|
|
237108
|
+
if (!knownMaterializedTables.has(tableKey)) {
|
|
237109
|
+
if (await tablePhysicallyExists(connection, quoted(tableName))) {
|
|
237110
|
+
throw new BadRequestError(`Refusing to materialize source '${persistSource.name}': ` + `target table '${tableName}' already exists on connection ` + `'${connectionName}' but was not created by a previous ` + `materialization build. Use '#@ persist name=...' to ` + `choose a different table name, or drop the existing ` + `table manually if it is no longer needed.`);
|
|
237111
|
+
}
|
|
237112
|
+
}
|
|
237113
|
+
logger.info(`Building source ${persistSource.name}`, {
|
|
237114
|
+
tableName,
|
|
237115
|
+
connectionName
|
|
237116
|
+
});
|
|
237117
|
+
const startTime = performance.now();
|
|
237118
|
+
await connection.runSQL(`DROP TABLE IF EXISTS ${quoted(stagingTableName)}`);
|
|
237119
|
+
try {
|
|
237120
|
+
await connection.runSQL(`CREATE TABLE ${quoted(stagingTableName)} AS (${buildSQL})`);
|
|
237121
|
+
await connection.runSQL(`DROP TABLE IF EXISTS ${quoted(tableName)}`);
|
|
237122
|
+
await connection.runSQL(`ALTER TABLE ${quoted(stagingTableName)} RENAME TO ${dialect.quoteTablePath(bareName)}`);
|
|
237123
|
+
} catch (err) {
|
|
237124
|
+
try {
|
|
237125
|
+
await connection.runSQL(`DROP TABLE IF EXISTS ${quoted(stagingTableName)}`);
|
|
237126
|
+
} catch (cleanupErr) {
|
|
237127
|
+
logger.warn("Build: failed to clean up staging table after a failed rebuild; physical leak", {
|
|
237128
|
+
stagingTableName,
|
|
237129
|
+
connectionName,
|
|
237130
|
+
cleanupError: cleanupErr instanceof Error ? cleanupErr.message : String(cleanupErr)
|
|
237131
|
+
});
|
|
237132
|
+
}
|
|
237133
|
+
throw err;
|
|
237134
|
+
}
|
|
237135
|
+
const duration = performance.now() - startTime;
|
|
237136
|
+
knownMaterializedTables.add(tableKey);
|
|
237137
|
+
manifest.update(buildId, { tableName });
|
|
237138
|
+
await this.manifestService.writeEntry(projectId, packageName, buildId, tableName, persistSource.name, connectionName);
|
|
237139
|
+
logger.info(`Built source ${persistSource.name}`, {
|
|
237140
|
+
tableName,
|
|
237141
|
+
durationMs: Math.round(duration)
|
|
237142
|
+
});
|
|
237143
|
+
return {
|
|
237144
|
+
name: persistSource.name,
|
|
237145
|
+
status: "built",
|
|
237146
|
+
buildId,
|
|
237147
|
+
tableName,
|
|
237148
|
+
durationMs: Math.round(duration)
|
|
237149
|
+
};
|
|
237150
|
+
}
|
|
237151
|
+
async runPostBuildGc(manifest, projectId, packageName, connections) {
|
|
237152
|
+
const activeManifest = manifest.activeEntries;
|
|
237153
|
+
const allDbEntries = await this.manifestService.listEntries(projectId, packageName);
|
|
237154
|
+
const liveTables = new Set;
|
|
237155
|
+
for (const entry of allDbEntries) {
|
|
237156
|
+
if (activeManifest.entries[entry.buildId]) {
|
|
237157
|
+
liveTables.add(liveTableKey(entry.connectionName, entry.tableName));
|
|
237158
|
+
}
|
|
237159
|
+
}
|
|
237160
|
+
const staleEntries = allDbEntries.filter((entry) => !activeManifest.entries[entry.buildId]);
|
|
237161
|
+
const gcResult = await dropManifestEntries(staleEntries, {
|
|
237162
|
+
connections,
|
|
237163
|
+
manifestService: this.manifestService,
|
|
237164
|
+
projectId,
|
|
237165
|
+
liveTables
|
|
237166
|
+
});
|
|
237167
|
+
if (gcResult.errors.length > 0) {
|
|
237168
|
+
logger.warn("Materialization GC surfaced errors", {
|
|
237169
|
+
errorCount: gcResult.errors.length,
|
|
237170
|
+
droppedCount: gcResult.dropped.length
|
|
237171
|
+
});
|
|
237172
|
+
}
|
|
237173
|
+
return gcResult;
|
|
237174
|
+
}
|
|
237175
|
+
resolveProjectId(projectName) {
|
|
237176
|
+
return resolveProjectId(this.repository, projectName);
|
|
237177
|
+
}
|
|
237178
|
+
}
|
|
237179
|
+
|
|
235890
237180
|
// src/server.ts
|
|
235891
237181
|
var __filename = "/home/runner/work/publisher/publisher/packages/server/src/server.ts";
|
|
235892
237182
|
function normalizeQueryArray(value) {
|
|
@@ -235958,13 +237248,17 @@ var app = import_express.default();
|
|
|
235958
237248
|
app.use(loggerMiddleware);
|
|
235959
237249
|
app.use(httpMetricsMiddleware);
|
|
235960
237250
|
var projectStore = new ProjectStore(SERVER_ROOT);
|
|
237251
|
+
var manifestService = new ManifestService(projectStore);
|
|
235961
237252
|
var watchModeController = new WatchModeController(projectStore);
|
|
235962
237253
|
var connectionController = new ConnectionController(projectStore);
|
|
235963
237254
|
var modelController = new ModelController(projectStore);
|
|
235964
|
-
var packageController = new PackageController(projectStore);
|
|
237255
|
+
var packageController = new PackageController(projectStore, manifestService);
|
|
235965
237256
|
var databaseController = new DatabaseController(projectStore);
|
|
235966
237257
|
var queryController = new QueryController(projectStore);
|
|
235967
237258
|
var compileController = new CompileController(projectStore);
|
|
237259
|
+
var materializationService = new MaterializationService(projectStore, manifestService);
|
|
237260
|
+
var materializationController = new MaterializationController(materializationService);
|
|
237261
|
+
var manifestController = new ManifestController(projectStore, manifestService);
|
|
235968
237262
|
var mcpApp = import_express.default();
|
|
235969
237263
|
registerHealthEndpoints(mcpApp);
|
|
235970
237264
|
mcpApp.use(MCP_ENDPOINT, import_express.default.json());
|
|
@@ -236046,7 +237340,7 @@ app.use(import_cors.default({
|
|
|
236046
237340
|
origin: "http://localhost:5173",
|
|
236047
237341
|
credentials: true
|
|
236048
237342
|
}));
|
|
236049
|
-
app.use(bodyParser.json());
|
|
237343
|
+
app.use(bodyParser.json({ limit: "1mb" }));
|
|
236050
237344
|
registerHealthEndpoints(app);
|
|
236051
237345
|
try {
|
|
236052
237346
|
const metricsHandler = getPrometheusMetricsHandler();
|
|
@@ -236237,7 +237531,7 @@ app.get(`${API_PREFIX2}/projects/:projectName/connections/:connectionName/queryD
|
|
|
236237
237531
|
});
|
|
236238
237532
|
app.post(`${API_PREFIX2}/projects/:projectName/connections/:connectionName/sqlQuery`, async (req, res) => {
|
|
236239
237533
|
try {
|
|
236240
|
-
res.status(200).json(await connectionController.getConnectionQueryData(req.params.projectName, req.params.connectionName, req.body.sqlStatement, req.
|
|
237534
|
+
res.status(200).json(await connectionController.getConnectionQueryData(req.params.projectName, req.params.connectionName, req.body.sqlStatement, req.body.options));
|
|
236241
237535
|
} catch (error) {
|
|
236242
237536
|
logger.error(error);
|
|
236243
237537
|
const { json: json2, status } = internalErrorToHttpError(error);
|
|
@@ -236277,7 +237571,8 @@ app.get(`${API_PREFIX2}/projects/:projectName/packages`, async (req, res) => {
|
|
|
236277
237571
|
});
|
|
236278
237572
|
app.post(`${API_PREFIX2}/projects/:projectName/packages`, async (req, res) => {
|
|
236279
237573
|
try {
|
|
236280
|
-
const
|
|
237574
|
+
const autoLoadManifest = req.query.autoLoadManifest === "true";
|
|
237575
|
+
const _package = await packageController.addPackage(req.params.projectName, req.body, { autoLoadManifest });
|
|
236281
237576
|
res.status(200).json(_package?.getPackageMetadata());
|
|
236282
237577
|
} catch (error) {
|
|
236283
237578
|
logger.error(error);
|
|
@@ -236440,6 +237735,95 @@ app.post(`${API_PREFIX2}/projects/:projectName/packages/:packageName/models/:mod
|
|
|
236440
237735
|
res.status(status).json(json2);
|
|
236441
237736
|
}
|
|
236442
237737
|
});
|
|
237738
|
+
app.post(`${API_PREFIX2}/projects/:projectName/packages/:packageName/materializations`, async (req, res) => {
|
|
237739
|
+
try {
|
|
237740
|
+
const build = await materializationController.createMaterialization(req.params.projectName, req.params.packageName, req.body || {});
|
|
237741
|
+
res.status(201).json(build);
|
|
237742
|
+
} catch (error) {
|
|
237743
|
+
const { json: json2, status } = internalErrorToHttpError(error);
|
|
237744
|
+
res.status(status).json(json2);
|
|
237745
|
+
}
|
|
237746
|
+
});
|
|
237747
|
+
app.get(`${API_PREFIX2}/projects/:projectName/packages/:packageName/materializations`, async (req, res) => {
|
|
237748
|
+
try {
|
|
237749
|
+
const limit = req.query.limit ? parseInt(req.query.limit, 10) : undefined;
|
|
237750
|
+
const offset = req.query.offset ? parseInt(req.query.offset, 10) : undefined;
|
|
237751
|
+
const builds = await materializationController.listMaterializations(req.params.projectName, req.params.packageName, { limit, offset });
|
|
237752
|
+
res.status(200).json(builds);
|
|
237753
|
+
} catch (error) {
|
|
237754
|
+
const { json: json2, status } = internalErrorToHttpError(error);
|
|
237755
|
+
res.status(status).json(json2);
|
|
237756
|
+
}
|
|
237757
|
+
});
|
|
237758
|
+
app.get(`${API_PREFIX2}/projects/:projectName/packages/:packageName/materializations/:materializationId`, async (req, res) => {
|
|
237759
|
+
try {
|
|
237760
|
+
const build = await materializationController.getMaterialization(req.params.projectName, req.params.packageName, req.params.materializationId);
|
|
237761
|
+
res.status(200).json(build);
|
|
237762
|
+
} catch (error) {
|
|
237763
|
+
const { json: json2, status } = internalErrorToHttpError(error);
|
|
237764
|
+
res.status(status).json(json2);
|
|
237765
|
+
}
|
|
237766
|
+
});
|
|
237767
|
+
app.post(`${API_PREFIX2}/projects/:projectName/packages/:packageName/materializations/teardown`, async (req, res) => {
|
|
237768
|
+
try {
|
|
237769
|
+
const result = await materializationController.teardownPackage(req.params.projectName, req.params.packageName, req.body || {});
|
|
237770
|
+
res.status(200).json(result);
|
|
237771
|
+
} catch (error) {
|
|
237772
|
+
const { json: json2, status } = internalErrorToHttpError(error);
|
|
237773
|
+
res.status(status).json(json2);
|
|
237774
|
+
}
|
|
237775
|
+
});
|
|
237776
|
+
app.post(`${API_PREFIX2}/projects/:projectName/packages/:packageName/materializations/:materializationId`, async (req, res) => {
|
|
237777
|
+
try {
|
|
237778
|
+
const action = req.query.action;
|
|
237779
|
+
if (action === "start") {
|
|
237780
|
+
const build = await materializationController.startMaterialization(req.params.projectName, req.params.packageName, req.params.materializationId);
|
|
237781
|
+
res.status(202).json(build);
|
|
237782
|
+
} else if (action === "stop") {
|
|
237783
|
+
const build = await materializationController.stopMaterialization(req.params.projectName, req.params.packageName, req.params.materializationId);
|
|
237784
|
+
res.status(200).json(build);
|
|
237785
|
+
} else {
|
|
237786
|
+
throw new BadRequestError(`Unsupported action '${String(action ?? "")}'. Expected 'start' or 'stop'.`);
|
|
237787
|
+
}
|
|
237788
|
+
} catch (error) {
|
|
237789
|
+
const { json: json2, status } = internalErrorToHttpError(error);
|
|
237790
|
+
res.status(status).json(json2);
|
|
237791
|
+
}
|
|
237792
|
+
});
|
|
237793
|
+
app.delete(`${API_PREFIX2}/projects/:projectName/packages/:packageName/materializations/:materializationId`, async (req, res) => {
|
|
237794
|
+
try {
|
|
237795
|
+
await materializationController.deleteMaterialization(req.params.projectName, req.params.packageName, req.params.materializationId);
|
|
237796
|
+
res.status(204).send();
|
|
237797
|
+
} catch (error) {
|
|
237798
|
+
const { json: json2, status } = internalErrorToHttpError(error);
|
|
237799
|
+
res.status(status).json(json2);
|
|
237800
|
+
}
|
|
237801
|
+
});
|
|
237802
|
+
app.get(`${API_PREFIX2}/projects/:projectName/packages/:packageName/manifest`, async (req, res) => {
|
|
237803
|
+
try {
|
|
237804
|
+
const manifest = await manifestController.getManifest(req.params.projectName, req.params.packageName);
|
|
237805
|
+
res.status(200).json(manifest);
|
|
237806
|
+
} catch (error) {
|
|
237807
|
+
logger.error("Get manifest error", { error });
|
|
237808
|
+
const { json: json2, status } = internalErrorToHttpError(error);
|
|
237809
|
+
res.status(status).json(json2);
|
|
237810
|
+
}
|
|
237811
|
+
});
|
|
237812
|
+
app.post(`${API_PREFIX2}/projects/:projectName/packages/:packageName/manifest`, async (req, res) => {
|
|
237813
|
+
try {
|
|
237814
|
+
const action = req.query.action;
|
|
237815
|
+
if (action === "reload") {
|
|
237816
|
+
const manifest = await manifestController.reloadManifest(req.params.projectName, req.params.packageName);
|
|
237817
|
+
res.status(200).json(manifest);
|
|
237818
|
+
} else {
|
|
237819
|
+
throw new BadRequestError(`Unsupported action '${String(action ?? "")}'. Expected 'reload'.`);
|
|
237820
|
+
}
|
|
237821
|
+
} catch (error) {
|
|
237822
|
+
logger.error("Manifest action error", { error });
|
|
237823
|
+
const { json: json2, status } = internalErrorToHttpError(error);
|
|
237824
|
+
res.status(status).json(json2);
|
|
237825
|
+
}
|
|
237826
|
+
});
|
|
236443
237827
|
if (!isDevelopment) {
|
|
236444
237828
|
app.get("*", (_req, res) => res.sendFile(path10.resolve(ROOT, "index.html")));
|
|
236445
237829
|
}
|