@malloy-publisher/server 0.0.197-dev → 0.0.198-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/server.mjs CHANGED
@@ -216941,7 +216941,7 @@ class StreamableHTTPServerTransport {
216941
216941
  }
216942
216942
 
216943
216943
  // src/server.ts
216944
- var import_body_parser = __toESM(require_body_parser(), 1);
216944
+ var import_body_parser2 = __toESM(require_body_parser(), 1);
216945
216945
  var import_cors = __toESM(require_lib7(), 1);
216946
216946
  var import_express = __toESM(require_express(), 1);
216947
216947
  var import_http_proxy_middleware = __toESM(require_dist4(), 1);
@@ -236986,6 +236986,601 @@ function initializeMcpServer(environmentStore) {
236986
236986
  return mcpServer;
236987
236987
  }
236988
236988
 
236989
+ // src/server-old.ts
236990
+ var import_body_parser = __toESM(require_body_parser(), 1);
236991
+ var LEGACY_API_PREFIX = "/api/v0";
236992
+ function remapStatusResponse(status) {
236993
+ if (!status || typeof status !== "object")
236994
+ return status;
236995
+ const out = { ...status };
236996
+ if ("environments" in out) {
236997
+ out.projects = out.environments;
236998
+ delete out.environments;
236999
+ }
237000
+ return out;
237001
+ }
237002
+ function remapMaterializationResponse(mat) {
237003
+ if (!mat || typeof mat !== "object")
237004
+ return mat;
237005
+ if (Array.isArray(mat)) {
237006
+ return mat.map(remapMaterializationResponse);
237007
+ }
237008
+ const out = { ...mat };
237009
+ if ("environmentId" in out) {
237010
+ out.projectId = out.environmentId;
237011
+ delete out.environmentId;
237012
+ }
237013
+ return out;
237014
+ }
237015
+ var setVersionIdError = (res) => {
237016
+ const { json, status } = internalErrorToHttpError(new NotImplementedError("Version IDs not implemented."));
237017
+ res.status(status).json(json);
237018
+ };
237019
+ function registerLegacyRoutes(app, controllers) {
237020
+ const {
237021
+ environmentStore,
237022
+ connectionController,
237023
+ modelController,
237024
+ packageController,
237025
+ databaseController,
237026
+ queryController,
237027
+ compileController,
237028
+ materializationController,
237029
+ manifestController
237030
+ } = controllers;
237031
+ app.get(`${LEGACY_API_PREFIX}/status`, async (_req, res) => {
237032
+ try {
237033
+ const status = await environmentStore.getStatus();
237034
+ res.status(200).json(remapStatusResponse(status));
237035
+ } catch (error) {
237036
+ logger.error("Error getting status", { error });
237037
+ const { json, status } = internalErrorToHttpError(error);
237038
+ res.status(status).json(json);
237039
+ }
237040
+ });
237041
+ app.get(`${LEGACY_API_PREFIX}/projects`, async (_req, res) => {
237042
+ try {
237043
+ res.status(200).json(await environmentStore.listEnvironments());
237044
+ } catch (error) {
237045
+ logger.error(error);
237046
+ const { json, status } = internalErrorToHttpError(error);
237047
+ res.status(status).json(json);
237048
+ }
237049
+ });
237050
+ app.post(`${LEGACY_API_PREFIX}/projects`, async (req, res) => {
237051
+ try {
237052
+ logger.info("Adding project", { body: req.body });
237053
+ const environment = await environmentStore.addEnvironment(req.body);
237054
+ res.status(200).json(await environment.serialize());
237055
+ } catch (error) {
237056
+ logger.error(error);
237057
+ const { json, status } = internalErrorToHttpError(error);
237058
+ res.status(status).json(json);
237059
+ }
237060
+ });
237061
+ app.get(`${LEGACY_API_PREFIX}/projects/:projectName`, async (req, res) => {
237062
+ try {
237063
+ const environment = await environmentStore.getEnvironment(req.params.projectName, req.query.reload === "true");
237064
+ res.status(200).json(await environment.serialize());
237065
+ } catch (error) {
237066
+ logger.error(error);
237067
+ const { json, status } = internalErrorToHttpError(error);
237068
+ res.status(status).json(json);
237069
+ }
237070
+ });
237071
+ app.patch(`${LEGACY_API_PREFIX}/projects/:projectName`, async (req, res) => {
237072
+ try {
237073
+ const environment = await environmentStore.updateEnvironment(req.body);
237074
+ res.status(200).json(await environment.serialize());
237075
+ } catch (error) {
237076
+ logger.error(error);
237077
+ const { json, status } = internalErrorToHttpError(error);
237078
+ res.status(status).json(json);
237079
+ }
237080
+ });
237081
+ app.delete(`${LEGACY_API_PREFIX}/projects/:projectName`, async (req, res) => {
237082
+ try {
237083
+ const environment = await environmentStore.deleteEnvironment(req.params.projectName);
237084
+ res.status(200).json(await environment?.serialize());
237085
+ } catch (error) {
237086
+ logger.error(error);
237087
+ const { json, status } = internalErrorToHttpError(error);
237088
+ res.status(status).json(json);
237089
+ }
237090
+ });
237091
+ app.get(`${LEGACY_API_PREFIX}/projects/:projectName/connections`, async (req, res) => {
237092
+ try {
237093
+ res.status(200).json(await connectionController.listConnections(req.params.projectName));
237094
+ } catch (error) {
237095
+ logger.error(error);
237096
+ const { json, status } = internalErrorToHttpError(error);
237097
+ res.status(status).json(json);
237098
+ }
237099
+ });
237100
+ app.get(`${LEGACY_API_PREFIX}/projects/:projectName/connections/:connectionName`, async (req, res) => {
237101
+ try {
237102
+ res.status(200).json(await connectionController.getConnection(req.params.projectName, req.params.connectionName));
237103
+ } catch (error) {
237104
+ logger.error(error);
237105
+ const { json, status } = internalErrorToHttpError(error);
237106
+ res.status(status).json(json);
237107
+ }
237108
+ });
237109
+ app.post(`${LEGACY_API_PREFIX}/projects/:projectName/connections/:connectionName`, async (req, res) => {
237110
+ try {
237111
+ const result = await connectionController.addConnection(req.params.projectName, req.params.connectionName, req.body);
237112
+ res.status(201).json(result);
237113
+ } catch (error) {
237114
+ logger.error("Error creating connection", { error });
237115
+ const { json, status } = internalErrorToHttpError(error);
237116
+ res.status(status).json(json);
237117
+ }
237118
+ });
237119
+ app.patch(`${LEGACY_API_PREFIX}/projects/:projectName/connections/:connectionName`, async (req, res) => {
237120
+ try {
237121
+ const result = await connectionController.updateConnection(req.params.projectName, req.params.connectionName, req.body);
237122
+ res.status(200).json(result);
237123
+ } catch (error) {
237124
+ logger.error("Error updating connection", { error });
237125
+ const { json, status } = internalErrorToHttpError(error);
237126
+ res.status(status).json(json);
237127
+ }
237128
+ });
237129
+ app.delete(`${LEGACY_API_PREFIX}/projects/:projectName/connections/:connectionName`, async (req, res) => {
237130
+ try {
237131
+ const result = await connectionController.deleteConnection(req.params.projectName, req.params.connectionName);
237132
+ res.status(200).json(result);
237133
+ } catch (error) {
237134
+ logger.error("Error deleting connection", { error });
237135
+ const { json, status } = internalErrorToHttpError(error);
237136
+ res.status(status).json(json);
237137
+ }
237138
+ });
237139
+ app.get(`${LEGACY_API_PREFIX}/projects/:projectName/connections/:connectionName/schemas`, async (req, res) => {
237140
+ try {
237141
+ res.status(200).json(await connectionController.listSchemas(req.params.projectName, req.params.connectionName));
237142
+ } catch (error) {
237143
+ logger.error(error);
237144
+ const { json, status } = internalErrorToHttpError(error);
237145
+ res.status(status).json(json);
237146
+ }
237147
+ });
237148
+ app.get(`${LEGACY_API_PREFIX}/projects/:projectName/connections/:connectionName/schemas/:schemaName/tables`, async (req, res) => {
237149
+ try {
237150
+ const results = await connectionController.listTables(req.params.projectName, req.params.connectionName, req.params.schemaName, normalizeQueryArray(req.query.tableNames));
237151
+ res.status(200).json(results);
237152
+ } catch (error) {
237153
+ logger.error(error);
237154
+ const { json, status } = internalErrorToHttpError(error);
237155
+ res.status(status).json(json);
237156
+ }
237157
+ });
237158
+ app.get(`${LEGACY_API_PREFIX}/projects/:projectName/connections/:connectionName/schemas/:schemaName/tables/:tablePath`, async (req, res) => {
237159
+ try {
237160
+ const results = await connectionController.getTable(req.params.projectName, req.params.connectionName, req.params.schemaName, req.params.tablePath);
237161
+ res.status(200).json(results);
237162
+ } catch (error) {
237163
+ logger.error(error);
237164
+ const { json, status } = internalErrorToHttpError(error);
237165
+ res.status(status).json(json);
237166
+ }
237167
+ });
237168
+ app.get(`${LEGACY_API_PREFIX}/projects/:projectName/packages/:packageName/connections/:connectionName/schemas`, async (req, res) => {
237169
+ try {
237170
+ res.status(200).json(await connectionController.listSchemas(req.params.projectName, req.params.connectionName, req.params.packageName));
237171
+ } catch (error) {
237172
+ logger.error(error);
237173
+ const { json, status } = internalErrorToHttpError(error);
237174
+ res.status(status).json(json);
237175
+ }
237176
+ });
237177
+ app.get(`${LEGACY_API_PREFIX}/projects/:projectName/packages/:packageName/connections/:connectionName/schemas/:schemaName/tables`, async (req, res) => {
237178
+ try {
237179
+ res.status(200).json(await connectionController.listTables(req.params.projectName, req.params.connectionName, req.params.schemaName, normalizeQueryArray(req.query.tableNames), req.params.packageName));
237180
+ } catch (error) {
237181
+ logger.error(error);
237182
+ const { json, status } = internalErrorToHttpError(error);
237183
+ res.status(status).json(json);
237184
+ }
237185
+ });
237186
+ app.get(`${LEGACY_API_PREFIX}/projects/:projectName/packages/:packageName/connections/:connectionName/schemas/:schemaName/tables/:tablePath`, async (req, res) => {
237187
+ try {
237188
+ res.status(200).json(await connectionController.getTable(req.params.projectName, req.params.connectionName, req.params.schemaName, req.params.tablePath, req.params.packageName));
237189
+ } catch (error) {
237190
+ logger.error(error);
237191
+ const { json, status } = internalErrorToHttpError(error);
237192
+ res.status(status).json(json);
237193
+ }
237194
+ });
237195
+ app.get(`${LEGACY_API_PREFIX}/projects/:projectName/connections/:connectionName/sqlSource`, async (req, res) => {
237196
+ try {
237197
+ res.status(200).json(await connectionController.getConnectionSqlSource(req.params.projectName, req.params.connectionName, req.query.sqlStatement));
237198
+ } catch (error) {
237199
+ logger.error(error);
237200
+ const { json, status } = internalErrorToHttpError(error);
237201
+ res.status(status).json(json);
237202
+ }
237203
+ });
237204
+ app.post(`${LEGACY_API_PREFIX}/projects/:projectName/connections/:connectionName/sqlSource`, async (req, res) => {
237205
+ try {
237206
+ res.status(200).json(await connectionController.getConnectionSqlSource(req.params.projectName, req.params.connectionName, req.body.sqlStatement));
237207
+ } catch (error) {
237208
+ logger.error(error);
237209
+ const { json, status } = internalErrorToHttpError(error);
237210
+ res.status(status).json(json);
237211
+ }
237212
+ });
237213
+ app.get(`${LEGACY_API_PREFIX}/projects/:projectName/packages/:packageName/connections/:connectionName/sqlSource`, async (req, res) => {
237214
+ try {
237215
+ res.status(200).json(await connectionController.getConnectionSqlSource(req.params.projectName, req.params.connectionName, req.query.sqlStatement, req.params.packageName));
237216
+ } catch (error) {
237217
+ logger.error(error);
237218
+ const { json, status } = internalErrorToHttpError(error);
237219
+ res.status(status).json(json);
237220
+ }
237221
+ });
237222
+ app.post(`${LEGACY_API_PREFIX}/projects/:projectName/packages/:packageName/connections/:connectionName/sqlSource`, async (req, res) => {
237223
+ try {
237224
+ res.status(200).json(await connectionController.getConnectionSqlSource(req.params.projectName, req.params.connectionName, req.body.sqlStatement, req.params.packageName));
237225
+ } catch (error) {
237226
+ logger.error(error);
237227
+ const { json, status } = internalErrorToHttpError(error);
237228
+ res.status(status).json(json);
237229
+ }
237230
+ });
237231
+ app.get(`${LEGACY_API_PREFIX}/projects/:projectName/connections/:connectionName/queryData`, async (req, res) => {
237232
+ try {
237233
+ res.status(200).json(await connectionController.getConnectionQueryData(req.params.projectName, req.params.connectionName, req.query.sqlStatement, req.query.options));
237234
+ } catch (error) {
237235
+ logger.error(error);
237236
+ const { json, status } = internalErrorToHttpError(error);
237237
+ res.status(status).json(json);
237238
+ }
237239
+ });
237240
+ app.get(`${LEGACY_API_PREFIX}/projects/:projectName/packages/:packageName/connections/:connectionName/queryData`, async (req, res) => {
237241
+ try {
237242
+ res.status(200).json(await connectionController.getConnectionQueryData(req.params.projectName, req.params.connectionName, req.query.sqlStatement, req.query.options, req.params.packageName));
237243
+ } catch (error) {
237244
+ logger.error(error);
237245
+ const { json, status } = internalErrorToHttpError(error);
237246
+ res.status(status).json(json);
237247
+ }
237248
+ });
237249
+ app.post(`${LEGACY_API_PREFIX}/projects/:projectName/connections/:connectionName/sqlQuery`, async (req, res) => {
237250
+ try {
237251
+ let options;
237252
+ if (req.body?.options) {
237253
+ options = req.body.options;
237254
+ } else {
237255
+ options = req.query.options;
237256
+ }
237257
+ res.status(200).json(await connectionController.getConnectionQueryData(req.params.projectName, req.params.connectionName, req.body.sqlStatement, options));
237258
+ } catch (error) {
237259
+ logger.error(error);
237260
+ const { json, status } = internalErrorToHttpError(error);
237261
+ res.status(status).json(json);
237262
+ }
237263
+ });
237264
+ app.post(`${LEGACY_API_PREFIX}/projects/:projectName/packages/:packageName/connections/:connectionName/sqlQuery`, async (req, res) => {
237265
+ try {
237266
+ let options;
237267
+ if (req.body?.options) {
237268
+ options = req.body.options;
237269
+ } else {
237270
+ options = req.query.options;
237271
+ }
237272
+ res.status(200).json(await connectionController.getConnectionQueryData(req.params.projectName, req.params.connectionName, req.body.sqlStatement, options, req.params.packageName));
237273
+ } catch (error) {
237274
+ logger.error(error);
237275
+ const { json, status } = internalErrorToHttpError(error);
237276
+ res.status(status).json(json);
237277
+ }
237278
+ });
237279
+ app.get(`${LEGACY_API_PREFIX}/projects/:projectName/connections/:connectionName/temporaryTable`, async (req, res) => {
237280
+ try {
237281
+ res.status(200).json(await connectionController.getConnectionTemporaryTable(req.params.projectName, req.params.connectionName, req.query.sqlStatement));
237282
+ } catch (error) {
237283
+ logger.error(error);
237284
+ const { json, status } = internalErrorToHttpError(error);
237285
+ res.status(status).json(json);
237286
+ }
237287
+ });
237288
+ app.get(`${LEGACY_API_PREFIX}/projects/:projectName/packages/:packageName/connections/:connectionName/temporaryTable`, async (req, res) => {
237289
+ try {
237290
+ res.status(200).json(await connectionController.getConnectionTemporaryTable(req.params.projectName, req.params.connectionName, req.query.sqlStatement, req.params.packageName));
237291
+ } catch (error) {
237292
+ logger.error(error);
237293
+ const { json, status } = internalErrorToHttpError(error);
237294
+ res.status(status).json(json);
237295
+ }
237296
+ });
237297
+ app.post(`${LEGACY_API_PREFIX}/projects/:projectName/connections/:connectionName/sqlTemporaryTable`, async (req, res) => {
237298
+ try {
237299
+ res.status(200).json(await connectionController.getConnectionTemporaryTable(req.params.projectName, req.params.connectionName, req.body.sqlStatement));
237300
+ } catch (error) {
237301
+ logger.error(error);
237302
+ const { json, status } = internalErrorToHttpError(error);
237303
+ res.status(status).json(json);
237304
+ }
237305
+ });
237306
+ app.post(`${LEGACY_API_PREFIX}/projects/:projectName/packages/:packageName/connections/:connectionName/sqlTemporaryTable`, async (req, res) => {
237307
+ try {
237308
+ res.status(200).json(await connectionController.getConnectionTemporaryTable(req.params.projectName, req.params.connectionName, req.body.sqlStatement, req.params.packageName));
237309
+ } catch (error) {
237310
+ logger.error(error);
237311
+ const { json, status } = internalErrorToHttpError(error);
237312
+ res.status(status).json(json);
237313
+ }
237314
+ });
237315
+ app.get(`${LEGACY_API_PREFIX}/projects/:projectName/packages`, async (req, res) => {
237316
+ if (req.query.versionId) {
237317
+ setVersionIdError(res);
237318
+ return;
237319
+ }
237320
+ try {
237321
+ res.status(200).json(await packageController.listPackages(req.params.projectName));
237322
+ } catch (error) {
237323
+ logger.error(error);
237324
+ const { json, status } = internalErrorToHttpError(error);
237325
+ res.status(status).json(json);
237326
+ }
237327
+ });
237328
+ app.post(`${LEGACY_API_PREFIX}/projects/:projectName/packages`, async (req, res) => {
237329
+ try {
237330
+ const autoLoadManifest = req.query.autoLoadManifest === "true";
237331
+ const _package = await packageController.addPackage(req.params.projectName, req.body, { autoLoadManifest });
237332
+ res.status(200).json(_package?.getPackageMetadata());
237333
+ } catch (error) {
237334
+ logger.error(error);
237335
+ const { json, status } = internalErrorToHttpError(error);
237336
+ res.status(status).json(json);
237337
+ }
237338
+ });
237339
+ app.get(`${LEGACY_API_PREFIX}/projects/:projectName/packages/:packageName`, async (req, res) => {
237340
+ if (req.query.versionId) {
237341
+ setVersionIdError(res);
237342
+ return;
237343
+ }
237344
+ try {
237345
+ res.status(200).json(await packageController.getPackage(req.params.projectName, req.params.packageName, req.query.reload === "true"));
237346
+ } catch (error) {
237347
+ logger.error(error);
237348
+ const { json, status } = internalErrorToHttpError(error);
237349
+ res.status(status).json(json);
237350
+ }
237351
+ });
237352
+ app.patch(`${LEGACY_API_PREFIX}/projects/:projectName/packages/:packageName`, async (req, res) => {
237353
+ try {
237354
+ res.status(200).json(await packageController.updatePackage(req.params.projectName, req.params.packageName, req.body));
237355
+ } catch (error) {
237356
+ logger.error(error);
237357
+ const { json, status } = internalErrorToHttpError(error);
237358
+ res.status(status).json(json);
237359
+ }
237360
+ });
237361
+ app.delete(`${LEGACY_API_PREFIX}/projects/:projectName/packages/:packageName`, async (req, res) => {
237362
+ try {
237363
+ res.status(200).json(await packageController.deletePackage(req.params.projectName, req.params.packageName));
237364
+ } catch (error) {
237365
+ logger.error(error);
237366
+ const { json, status } = internalErrorToHttpError(error);
237367
+ res.status(status).json(json);
237368
+ }
237369
+ });
237370
+ app.get(`${LEGACY_API_PREFIX}/projects/:projectName/packages/:packageName/models`, async (req, res) => {
237371
+ if (req.query.versionId) {
237372
+ setVersionIdError(res);
237373
+ return;
237374
+ }
237375
+ try {
237376
+ res.status(200).json(await modelController.listModels(req.params.projectName, req.params.packageName));
237377
+ } catch (error) {
237378
+ logger.error(error);
237379
+ const { json, status } = internalErrorToHttpError(error);
237380
+ res.status(status).json(json);
237381
+ }
237382
+ });
237383
+ app.get(`${LEGACY_API_PREFIX}/projects/:projectName/packages/:packageName/models/*?`, async (req, res) => {
237384
+ if (req.query.versionId) {
237385
+ setVersionIdError(res);
237386
+ return;
237387
+ }
237388
+ try {
237389
+ const modelPath = req.params["0"];
237390
+ res.status(200).json(await modelController.getModel(req.params.projectName, req.params.packageName, modelPath));
237391
+ } catch (error) {
237392
+ logger.error(error);
237393
+ const { json, status } = internalErrorToHttpError(error);
237394
+ res.status(status).json(json);
237395
+ }
237396
+ });
237397
+ app.post(`${LEGACY_API_PREFIX}/projects/:projectName/packages/:packageName/models/*?/query`, async (req, res) => {
237398
+ if (req.body.versionId) {
237399
+ setVersionIdError(res);
237400
+ return;
237401
+ }
237402
+ try {
237403
+ const modelPath = req.params["0"];
237404
+ res.status(200).json(await queryController.getQuery(req.params.projectName, req.params.packageName, modelPath, req.body.sourceName, req.body.queryName, req.body.query, req.body.compactJson === true, req.body.filterParams ?? req.body.sourceFilters, req.body.bypassFilters === true ? true : undefined));
237405
+ } catch (error) {
237406
+ logger.error(error);
237407
+ const { json, status } = internalErrorToHttpError(error);
237408
+ res.status(status).json(json);
237409
+ }
237410
+ });
237411
+ app.post(`${LEGACY_API_PREFIX}/projects/:projectName/packages/:packageName/models/:modelName/compile`, async (req, res) => {
237412
+ try {
237413
+ const result = await compileController.compile(req.params.projectName, req.params.packageName, req.params.modelName, req.body.source, req.body.includeSql === true);
237414
+ res.status(200).json(result);
237415
+ } catch (error) {
237416
+ logger.error("Compilation error", { error });
237417
+ const { json, status } = internalErrorToHttpError(error);
237418
+ res.status(status).json(json);
237419
+ }
237420
+ });
237421
+ app.get(`${LEGACY_API_PREFIX}/projects/:projectName/packages/:packageName/notebooks`, async (req, res) => {
237422
+ if (req.query.versionId) {
237423
+ setVersionIdError(res);
237424
+ return;
237425
+ }
237426
+ try {
237427
+ res.status(200).json(await modelController.listNotebooks(req.params.projectName, req.params.packageName));
237428
+ } catch (error) {
237429
+ logger.error(error);
237430
+ const { json, status } = internalErrorToHttpError(error);
237431
+ res.status(status).json(json);
237432
+ }
237433
+ });
237434
+ app.get(`${LEGACY_API_PREFIX}/projects/:projectName/packages/:packageName/notebooks/*/cells/:cellIndex`, async (req, res) => {
237435
+ if (req.query.versionId) {
237436
+ setVersionIdError(res);
237437
+ return;
237438
+ }
237439
+ try {
237440
+ const cellIndex = parseInt(req.params.cellIndex, 10);
237441
+ if (isNaN(cellIndex)) {
237442
+ res.status(400).json({ error: "Invalid cell index" });
237443
+ return;
237444
+ }
237445
+ const notebookPath = req.params["0"];
237446
+ let filterParams;
237447
+ if (typeof req.query.filter_params === "string") {
237448
+ try {
237449
+ filterParams = JSON.parse(req.query.filter_params);
237450
+ } catch {
237451
+ res.status(400).json({
237452
+ error: "Invalid filter_params: must be valid JSON"
237453
+ });
237454
+ return;
237455
+ }
237456
+ }
237457
+ const bypassFilters = req.query.bypass_filters === "true" ? true : undefined;
237458
+ res.status(200).json(await modelController.executeNotebookCell(req.params.projectName, req.params.packageName, notebookPath, cellIndex, filterParams, bypassFilters));
237459
+ } catch (error) {
237460
+ logger.error(error);
237461
+ const { json, status } = internalErrorToHttpError(error);
237462
+ res.status(status).json(json);
237463
+ }
237464
+ });
237465
+ app.get(`${LEGACY_API_PREFIX}/projects/:projectName/packages/:packageName/notebooks/*?`, async (req, res) => {
237466
+ if (req.query.versionId) {
237467
+ setVersionIdError(res);
237468
+ return;
237469
+ }
237470
+ try {
237471
+ const notebookPath = req.params["0"];
237472
+ res.status(200).json(await modelController.getNotebook(req.params.projectName, req.params.packageName, notebookPath));
237473
+ } catch (error) {
237474
+ logger.error(error);
237475
+ const { json, status } = internalErrorToHttpError(error);
237476
+ res.status(status).json(json);
237477
+ }
237478
+ });
237479
+ app.get(`${LEGACY_API_PREFIX}/projects/:projectName/packages/:packageName/databases`, async (req, res) => {
237480
+ if (req.query.versionId) {
237481
+ setVersionIdError(res);
237482
+ return;
237483
+ }
237484
+ try {
237485
+ res.status(200).json(await databaseController.listDatabases(req.params.projectName, req.params.packageName));
237486
+ } catch (error) {
237487
+ logger.error(error);
237488
+ const { json, status } = internalErrorToHttpError(error);
237489
+ res.status(status).json(json);
237490
+ }
237491
+ });
237492
+ app.post(`${LEGACY_API_PREFIX}/projects/:projectName/packages/:packageName/materializations`, async (req, res) => {
237493
+ try {
237494
+ const build = await materializationController.createMaterialization(req.params.projectName, req.params.packageName, req.body || {});
237495
+ res.status(201).json(remapMaterializationResponse(build));
237496
+ } catch (error) {
237497
+ const { json, status } = internalErrorToHttpError(error);
237498
+ res.status(status).json(json);
237499
+ }
237500
+ });
237501
+ app.get(`${LEGACY_API_PREFIX}/projects/:projectName/packages/:packageName/materializations`, async (req, res) => {
237502
+ try {
237503
+ const limit = req.query.limit ? parseInt(req.query.limit, 10) : undefined;
237504
+ const offset = req.query.offset ? parseInt(req.query.offset, 10) : undefined;
237505
+ const builds = await materializationController.listMaterializations(req.params.projectName, req.params.packageName, { limit, offset });
237506
+ res.status(200).json(remapMaterializationResponse(builds));
237507
+ } catch (error) {
237508
+ const { json, status } = internalErrorToHttpError(error);
237509
+ res.status(status).json(json);
237510
+ }
237511
+ });
237512
+ app.get(`${LEGACY_API_PREFIX}/projects/:projectName/packages/:packageName/materializations/:materializationId`, async (req, res) => {
237513
+ try {
237514
+ const build = await materializationController.getMaterialization(req.params.projectName, req.params.packageName, req.params.materializationId);
237515
+ res.status(200).json(remapMaterializationResponse(build));
237516
+ } catch (error) {
237517
+ const { json, status } = internalErrorToHttpError(error);
237518
+ res.status(status).json(json);
237519
+ }
237520
+ });
237521
+ app.post(`${LEGACY_API_PREFIX}/projects/:projectName/packages/:packageName/materializations/teardown`, async (req, res) => {
237522
+ try {
237523
+ const result = await materializationController.teardownPackage(req.params.projectName, req.params.packageName, req.body || {});
237524
+ res.status(200).json(result);
237525
+ } catch (error) {
237526
+ const { json, status } = internalErrorToHttpError(error);
237527
+ res.status(status).json(json);
237528
+ }
237529
+ });
237530
+ app.post(`${LEGACY_API_PREFIX}/projects/:projectName/packages/:packageName/materializations/:materializationId`, async (req, res) => {
237531
+ try {
237532
+ const action = req.query.action;
237533
+ if (action === "start") {
237534
+ const build = await materializationController.startMaterialization(req.params.projectName, req.params.packageName, req.params.materializationId);
237535
+ res.status(202).json(remapMaterializationResponse(build));
237536
+ } else if (action === "stop") {
237537
+ const build = await materializationController.stopMaterialization(req.params.projectName, req.params.packageName, req.params.materializationId);
237538
+ res.status(200).json(remapMaterializationResponse(build));
237539
+ } else {
237540
+ throw new BadRequestError(`Unsupported action '${String(action ?? "")}'. Expected 'start' or 'stop'.`);
237541
+ }
237542
+ } catch (error) {
237543
+ const { json, status } = internalErrorToHttpError(error);
237544
+ res.status(status).json(json);
237545
+ }
237546
+ });
237547
+ app.delete(`${LEGACY_API_PREFIX}/projects/:projectName/packages/:packageName/materializations/:materializationId`, async (req, res) => {
237548
+ try {
237549
+ await materializationController.deleteMaterialization(req.params.projectName, req.params.packageName, req.params.materializationId);
237550
+ res.status(204).send();
237551
+ } catch (error) {
237552
+ const { json, status } = internalErrorToHttpError(error);
237553
+ res.status(status).json(json);
237554
+ }
237555
+ });
237556
+ app.get(`${LEGACY_API_PREFIX}/projects/:projectName/packages/:packageName/manifest`, async (req, res) => {
237557
+ try {
237558
+ const manifest = await manifestController.getManifest(req.params.projectName, req.params.packageName);
237559
+ res.status(200).json(manifest);
237560
+ } catch (error) {
237561
+ logger.error("Get manifest error", { error });
237562
+ const { json, status } = internalErrorToHttpError(error);
237563
+ res.status(status).json(json);
237564
+ }
237565
+ });
237566
+ app.post(`${LEGACY_API_PREFIX}/projects/:projectName/packages/:packageName/manifest`, async (req, res) => {
237567
+ try {
237568
+ const action = req.query.action;
237569
+ if (action === "reload") {
237570
+ const manifest = await manifestController.reloadManifest(req.params.projectName, req.params.packageName);
237571
+ res.status(200).json(manifest);
237572
+ } else {
237573
+ throw new BadRequestError(`Unsupported action '${String(action ?? "")}'. Expected 'reload'.`);
237574
+ }
237575
+ } catch (error) {
237576
+ logger.error("Manifest action error", { error });
237577
+ const { json, status } = internalErrorToHttpError(error);
237578
+ res.status(status).json(json);
237579
+ }
237580
+ });
237581
+ logger.info("Legacy /projects/* routes registered for backwards compatibility");
237582
+ }
237583
+
236989
237584
  // src/service/manifest_service.ts
236990
237585
  class ManifestService {
236991
237586
  environmentStore;
@@ -237775,7 +238370,7 @@ if (!isDevelopment) {
237775
238370
  pathFilter: (path12) => !path12.startsWith("/api/") && !path12.startsWith("/metrics") && !path12.startsWith("/health")
237776
238371
  }));
237777
238372
  }
237778
- var setVersionIdError = (res) => {
238373
+ var setVersionIdError2 = (res) => {
237779
238374
  const { json, status } = internalErrorToHttpError(new NotImplementedError("Version IDs not implemented."));
237780
238375
  res.status(status).json(json);
237781
238376
  };
@@ -237783,7 +238378,7 @@ app.use(import_cors.default({
237783
238378
  origin: "http://localhost:5173",
237784
238379
  credentials: true
237785
238380
  }));
237786
- app.use(import_body_parser.default.json({ limit: "1mb" }));
238381
+ app.use(import_body_parser2.default.json({ limit: "1mb" }));
237787
238382
  registerHealthEndpoints(app);
237788
238383
  try {
237789
238384
  const metricsHandler = getPrometheusMetricsHandler();
@@ -238094,7 +238689,7 @@ app.post(`${API_PREFIX2}/environments/:environmentName/packages/:packageName/con
238094
238689
  });
238095
238690
  app.get(`${API_PREFIX2}/environments/:environmentName/packages`, async (req, res) => {
238096
238691
  if (req.query.versionId) {
238097
- setVersionIdError(res);
238692
+ setVersionIdError2(res);
238098
238693
  return;
238099
238694
  }
238100
238695
  try {
@@ -238118,7 +238713,7 @@ app.post(`${API_PREFIX2}/environments/:environmentName/packages`, async (req, re
238118
238713
  });
238119
238714
  app.get(`${API_PREFIX2}/environments/:environmentName/packages/:packageName`, async (req, res) => {
238120
238715
  if (req.query.versionId) {
238121
- setVersionIdError(res);
238716
+ setVersionIdError2(res);
238122
238717
  return;
238123
238718
  }
238124
238719
  try {
@@ -238149,7 +238744,7 @@ app.delete(`${API_PREFIX2}/environments/:environmentName/packages/:packageName`,
238149
238744
  });
238150
238745
  app.get(`${API_PREFIX2}/environments/:environmentName/packages/:packageName/models`, async (req, res) => {
238151
238746
  if (req.query.versionId) {
238152
- setVersionIdError(res);
238747
+ setVersionIdError2(res);
238153
238748
  return;
238154
238749
  }
238155
238750
  try {
@@ -238162,7 +238757,7 @@ app.get(`${API_PREFIX2}/environments/:environmentName/packages/:packageName/mode
238162
238757
  });
238163
238758
  app.get(`${API_PREFIX2}/environments/:environmentName/packages/:packageName/models/*?`, async (req, res) => {
238164
238759
  if (req.query.versionId) {
238165
- setVersionIdError(res);
238760
+ setVersionIdError2(res);
238166
238761
  return;
238167
238762
  }
238168
238763
  try {
@@ -238176,7 +238771,7 @@ app.get(`${API_PREFIX2}/environments/:environmentName/packages/:packageName/mode
238176
238771
  });
238177
238772
  app.get(`${API_PREFIX2}/environments/:environmentName/packages/:packageName/notebooks`, async (req, res) => {
238178
238773
  if (req.query.versionId) {
238179
- setVersionIdError(res);
238774
+ setVersionIdError2(res);
238180
238775
  return;
238181
238776
  }
238182
238777
  try {
@@ -238189,7 +238784,7 @@ app.get(`${API_PREFIX2}/environments/:environmentName/packages/:packageName/note
238189
238784
  });
238190
238785
  app.get(`${API_PREFIX2}/environments/:environmentName/packages/:packageName/notebooks/*/cells/:cellIndex`, async (req, res) => {
238191
238786
  if (req.query.versionId) {
238192
- setVersionIdError(res);
238787
+ setVersionIdError2(res);
238193
238788
  return;
238194
238789
  }
238195
238790
  try {
@@ -238222,7 +238817,7 @@ app.get(`${API_PREFIX2}/environments/:environmentName/packages/:packageName/note
238222
238817
  });
238223
238818
  app.get(`${API_PREFIX2}/environments/:environmentName/packages/:packageName/notebooks/*?`, async (req, res) => {
238224
238819
  if (req.query.versionId) {
238225
- setVersionIdError(res);
238820
+ setVersionIdError2(res);
238226
238821
  return;
238227
238822
  }
238228
238823
  try {
@@ -238236,7 +238831,7 @@ app.get(`${API_PREFIX2}/environments/:environmentName/packages/:packageName/note
238236
238831
  });
238237
238832
  app.post(`${API_PREFIX2}/environments/:environmentName/packages/:packageName/models/*?/query`, async (req, res) => {
238238
238833
  if (req.body.versionId) {
238239
- setVersionIdError(res);
238834
+ setVersionIdError2(res);
238240
238835
  return;
238241
238836
  }
238242
238837
  try {
@@ -238250,7 +238845,7 @@ app.post(`${API_PREFIX2}/environments/:environmentName/packages/:packageName/mod
238250
238845
  });
238251
238846
  app.get(`${API_PREFIX2}/environments/:environmentName/packages/:packageName/databases`, async (req, res) => {
238252
238847
  if (req.query.versionId) {
238253
- setVersionIdError(res);
238848
+ setVersionIdError2(res);
238254
238849
  return;
238255
238850
  }
238256
238851
  try {
@@ -238360,6 +238955,17 @@ app.post(`${API_PREFIX2}/environments/:environmentName/packages/:packageName/man
238360
238955
  res.status(status).json(json);
238361
238956
  }
238362
238957
  });
238958
+ registerLegacyRoutes(app, {
238959
+ environmentStore,
238960
+ connectionController,
238961
+ modelController,
238962
+ packageController,
238963
+ databaseController,
238964
+ queryController,
238965
+ compileController,
238966
+ materializationController,
238967
+ manifestController
238968
+ });
238363
238969
  if (!isDevelopment) {
238364
238970
  app.get("*", (_req, res) => res.sendFile(path11.resolve(ROOT, "index.html")));
238365
238971
  }