@malloy-publisher/server 0.0.235 → 0.0.236
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 +47 -17
- package/dist/package_load_worker.mjs +8 -1
- package/dist/server.mjs +471 -54
- package/package.json +5 -2
- package/.eslintrc.json +0 -44
- package/.prettierignore +0 -1
- package/.prettierrc +0 -4
- package/build.ts +0 -97
- package/eslint.config.mjs +0 -76
- package/k6-tests/README.md +0 -144
- package/k6-tests/bun.lock +0 -797
- package/k6-tests/load-test/load-test-crud-connections.ts +0 -263
- package/k6-tests/load-test/load-test-crud-packages.ts +0 -461
- package/k6-tests/load-test/load-test-crud-projects.ts +0 -160
- package/k6-tests/load-test/load-test-crud.ts +0 -142
- package/k6-tests/load-test/load-test.ts +0 -784
- package/k6-tests/package.json +0 -27
- package/k6-tests/scripts/run-with-otel.sh +0 -50
- package/k6-tests/smoke-test/smoke-test.ts +0 -158
- package/k6-tests/tsconfig.json +0 -29
- package/k6-tests/utils/client_factory.ts +0 -128
- package/k6-tests/utils/common.ts +0 -489
- package/k6-tests/utils/logger.ts +0 -62
- package/k6-tests/utils/types.d.ts +0 -35
- package/malloy_mcp.dxt +0 -0
- package/publisher.config.example.bigquery.json +0 -33
- package/publisher.config.example.duckdb.json +0 -23
- package/publisher.config.json +0 -23
- package/scripts/bake-duckdb-extensions.js +0 -110
- package/src/config.spec.ts +0 -1535
- package/src/config.theme.spec.ts +0 -178
- package/src/config.ts +0 -1142
- package/src/constants.ts +0 -105
- package/src/controller/compile.controller.ts +0 -40
- package/src/controller/connection.controller.spec.ts +0 -849
- package/src/controller/connection.controller.ts +0 -901
- package/src/controller/database.controller.ts +0 -24
- package/src/controller/materialization.controller.spec.ts +0 -293
- package/src/controller/materialization.controller.ts +0 -319
- package/src/controller/model.controller.ts +0 -164
- package/src/controller/package.controller.spec.ts +0 -273
- package/src/controller/package.controller.ts +0 -306
- package/src/controller/query.controller.ts +0 -152
- package/src/controller/theme.controller.ts +0 -83
- package/src/controller/watch-mode.controller.ts +0 -243
- package/src/data_styles.ts +0 -71
- package/src/default-publisher.config.json +0 -23
- package/src/ducklake_version.spec.ts +0 -163
- package/src/ducklake_version.ts +0 -153
- package/src/errors.spec.ts +0 -119
- package/src/errors.ts +0 -237
- package/src/filter_deprecation.spec.ts +0 -64
- package/src/filter_deprecation.ts +0 -42
- package/src/health.spec.ts +0 -123
- package/src/health.ts +0 -233
- package/src/heap_check.spec.ts +0 -144
- package/src/heap_check.ts +0 -144
- package/src/instrumentation.ts +0 -214
- package/src/json_utils.spec.ts +0 -51
- package/src/json_utils.ts +0 -33
- package/src/logger.spec.ts +0 -210
- package/src/logger.ts +0 -251
- package/src/malloy_pin_prereqs.spec.ts +0 -25
- package/src/materialization_metrics.spec.ts +0 -169
- package/src/materialization_metrics.ts +0 -346
- package/src/mcp/error_messages.spec.ts +0 -35
- package/src/mcp/error_messages.ts +0 -183
- package/src/mcp/handler_utils.spec.ts +0 -108
- package/src/mcp/handler_utils.ts +0 -251
- package/src/mcp/mcp_constants.ts +0 -6
- package/src/mcp/query_envelope.spec.ts +0 -229
- package/src/mcp/query_envelope.ts +0 -240
- package/src/mcp/server.protocol.spec.ts +0 -250
- package/src/mcp/server.ts +0 -87
- package/src/mcp/skills/build_skills_bundle.spec.ts +0 -51
- package/src/mcp/skills/build_skills_bundle.ts +0 -176
- package/src/mcp/skills/skills_bundle.json +0 -1
- package/src/mcp/skills/skills_bundle.spec.ts +0 -171
- package/src/mcp/tool_response.spec.ts +0 -108
- package/src/mcp/tool_response.ts +0 -138
- package/src/mcp/tools/compile_tool.spec.ts +0 -315
- package/src/mcp/tools/compile_tool.ts +0 -208
- package/src/mcp/tools/docs_search/build_docs_index.ts +0 -132
- package/src/mcp/tools/docs_search/malloy_docs_index.json +0 -1
- package/src/mcp/tools/docs_search_tool.spec.ts +0 -32
- package/src/mcp/tools/docs_search_tool.ts +0 -128
- package/src/mcp/tools/embedding_index.spec.ts +0 -1236
- package/src/mcp/tools/embedding_index.ts +0 -808
- package/src/mcp/tools/execute_query_tool.spec.ts +0 -294
- package/src/mcp/tools/execute_query_tool.ts +0 -316
- package/src/mcp/tools/get_context_eval.ts +0 -275
- package/src/mcp/tools/get_context_tool.spec.ts +0 -592
- package/src/mcp/tools/get_context_tool.ts +0 -585
- package/src/mcp/tools/reload_package_tool.spec.ts +0 -232
- package/src/mcp/tools/reload_package_tool.ts +0 -132
- package/src/mcp_config.spec.ts +0 -919
- package/src/mcp_config.ts +0 -425
- package/src/oom_guards.integration.spec.ts +0 -269
- package/src/package_load/package_load_pool.spec.ts +0 -252
- package/src/package_load/package_load_pool.ts +0 -931
- package/src/package_load/package_load_worker.ts +0 -1034
- package/src/package_load/protocol.ts +0 -364
- package/src/package_load/rpc_wait_accountant.spec.ts +0 -109
- package/src/package_load/rpc_wait_accountant.ts +0 -76
- package/src/package_load_metrics.spec.ts +0 -114
- package/src/package_load_metrics.ts +0 -127
- package/src/path_safety.spec.ts +0 -158
- package/src/path_safety.ts +0 -146
- package/src/pg_helpers.spec.ts +0 -223
- package/src/pg_helpers.ts +0 -52
- package/src/query_cap_metrics.spec.ts +0 -89
- package/src/query_cap_metrics.ts +0 -116
- package/src/query_concurrency.spec.ts +0 -247
- package/src/query_concurrency.ts +0 -237
- package/src/query_metadata_metrics.ts +0 -49
- package/src/query_param_utils.ts +0 -29
- package/src/query_timeout.spec.ts +0 -224
- package/src/query_timeout.ts +0 -179
- package/src/runtime/publisher.js +0 -328
- package/src/server-old.ts +0 -988
- package/src/server.ts +0 -2059
- package/src/service/annotations.spec.ts +0 -118
- package/src/service/annotations.ts +0 -91
- package/src/service/authorize.spec.ts +0 -154
- package/src/service/authorize.ts +0 -498
- package/src/service/authorize_integration.spec.ts +0 -2041
- package/src/service/build_plan.spec.ts +0 -685
- package/src/service/build_plan.ts +0 -797
- package/src/service/compile_authorize.spec.ts +0 -85
- package/src/service/compile_fragment_techniques.spec.ts +0 -156
- package/src/service/connection.spec.ts +0 -2360
- package/src/service/connection.ts +0 -2187
- package/src/service/connection_config.spec.ts +0 -734
- package/src/service/connection_config.ts +0 -899
- package/src/service/connection_federation.spec.ts +0 -184
- package/src/service/connection_fingerprint.spec.ts +0 -102
- package/src/service/connection_service.spec.ts +0 -711
- package/src/service/connection_service.ts +0 -291
- package/src/service/cron_evaluator.spec.ts +0 -79
- package/src/service/cron_evaluator.ts +0 -105
- package/src/service/db_utils.spec.ts +0 -1085
- package/src/service/db_utils.ts +0 -1502
- package/src/service/duckdb_instance_isolation.spec.ts +0 -137
- package/src/service/ducklake_lazy_attach.spec.ts +0 -110
- package/src/service/embedding_provider.spec.ts +0 -329
- package/src/service/embedding_provider.ts +0 -236
- package/src/service/environment.ts +0 -2191
- package/src/service/environment_admission.spec.ts +0 -344
- package/src/service/environment_compile.spec.ts +0 -197
- package/src/service/environment_store.spec.ts +0 -2274
- package/src/service/environment_store.ts +0 -2434
- package/src/service/environment_store_anchoring.spec.ts +0 -107
- package/src/service/environment_store_clone.spec.ts +0 -350
- package/src/service/explore_visibility.spec.ts +0 -434
- package/src/service/exports_probe.spec.ts +0 -107
- package/src/service/extension_fetch_policy.spec.ts +0 -256
- package/src/service/filter.spec.ts +0 -458
- package/src/service/filter.ts +0 -341
- package/src/service/filter_bypass.spec.ts +0 -418
- package/src/service/filter_integration.spec.ts +0 -1004
- package/src/service/freshness.spec.ts +0 -183
- package/src/service/freshness.ts +0 -112
- package/src/service/gcs_s3_utils.ts +0 -427
- package/src/service/given.ts +0 -105
- package/src/service/givens_integration.spec.ts +0 -219
- package/src/service/manifest_loader.spec.ts +0 -189
- package/src/service/manifest_loader.ts +0 -156
- package/src/service/materialization_build_session.spec.ts +0 -435
- package/src/service/materialization_build_session.ts +0 -681
- package/src/service/materialization_config_validation.spec.ts +0 -99
- package/src/service/materialization_config_validation.ts +0 -120
- package/src/service/materialization_eligibility.spec.ts +0 -158
- package/src/service/materialization_eligibility.ts +0 -305
- package/src/service/materialization_schedule_surface.spec.ts +0 -256
- package/src/service/materialization_scheduler.spec.ts +0 -289
- package/src/service/materialization_scheduler.ts +0 -304
- package/src/service/materialization_serve_transform.spec.ts +0 -1003
- package/src/service/materialization_serve_transform.ts +0 -779
- package/src/service/materialization_service.spec.ts +0 -2373
- package/src/service/materialization_service.ts +0 -2342
- package/src/service/materialization_test_fixtures.ts +0 -249
- package/src/service/model.spec.ts +0 -1157
- package/src/service/model.ts +0 -3370
- package/src/service/model_limits.spec.ts +0 -209
- package/src/service/model_limits.ts +0 -131
- package/src/service/model_storage_serve.spec.ts +0 -193
- package/src/service/model_storage_serve_joins.spec.ts +0 -193
- package/src/service/package.spec.ts +0 -612
- package/src/service/package.ts +0 -1799
- package/src/service/package_manifest.spec.ts +0 -230
- package/src/service/package_manifest.ts +0 -241
- package/src/service/package_memory_governor.spec.ts +0 -173
- package/src/service/package_memory_governor.ts +0 -233
- package/src/service/package_quote_bound_tables.spec.ts +0 -171
- package/src/service/package_race.spec.ts +0 -208
- package/src/service/package_reload_safety.spec.ts +0 -193
- package/src/service/package_rollback.spec.ts +0 -190
- package/src/service/package_worker_path.spec.ts +0 -645
- package/src/service/path_injection.spec.ts +0 -39
- package/src/service/persist_annotation_validation.spec.ts +0 -89
- package/src/service/persist_annotation_validation.ts +0 -59
- package/src/service/persistence_policy.spec.ts +0 -374
- package/src/service/proxy.spec.ts +0 -414
- package/src/service/proxy.ts +0 -248
- package/src/service/query_boundary.spec.ts +0 -470
- package/src/service/query_metadata.spec.ts +0 -408
- package/src/service/query_metadata.ts +0 -492
- package/src/service/query_metadata_identity.spec.ts +0 -149
- package/src/service/query_text.spec.ts +0 -79
- package/src/service/query_text.ts +0 -43
- package/src/service/quoting.spec.ts +0 -135
- package/src/service/quoting.ts +0 -78
- package/src/service/resolve_environment.ts +0 -15
- package/src/service/restricted_mode.spec.ts +0 -299
- package/src/service/source_extraction.ts +0 -225
- package/src/service/theme_store.ts +0 -199
- package/src/storage/DatabaseInterface.ts +0 -198
- package/src/storage/StorageManager.ts +0 -113
- package/src/storage/duckdb/ConnectionRepository.ts +0 -143
- package/src/storage/duckdb/DuckDBConnection.ts +0 -123
- package/src/storage/duckdb/DuckDBRepository.ts +0 -208
- package/src/storage/duckdb/EnvironmentRepository.ts +0 -148
- package/src/storage/duckdb/MaterializationRepository.spec.ts +0 -191
- package/src/storage/duckdb/MaterializationRepository.ts +0 -336
- package/src/storage/duckdb/PackageRepository.ts +0 -135
- package/src/storage/duckdb/schema.ts +0 -229
- package/src/stream_helpers.spec.ts +0 -280
- package/src/stream_helpers.ts +0 -162
- package/src/telemetry.ts +0 -20
- package/src/test_helpers/metrics_harness.ts +0 -166
- package/src/theme_key_parity.spec.ts +0 -57
- package/src/utils.ts +0 -29
- package/tests/fixtures/authorize-compile/model.malloy +0 -9
- package/tests/fixtures/authorize-compile/publisher.json +0 -4
- package/tests/fixtures/html-pages-nopublic/model.malloy +0 -1
- package/tests/fixtures/html-pages-nopublic/publisher.json +0 -5
- package/tests/fixtures/html-pages-test/data.csv +0 -3
- package/tests/fixtures/html-pages-test/public/assets/app.css +0 -3
- package/tests/fixtures/html-pages-test/public/barehtml.html +0 -4
- package/tests/fixtures/html-pages-test/public/bodymeta.html +0 -8
- package/tests/fixtures/html-pages-test/public/data.json +0 -1
- package/tests/fixtures/html-pages-test/public/fitcomment.html +0 -11
- package/tests/fixtures/html-pages-test/public/index.html +0 -9
- package/tests/fixtures/html-pages-test/public/nohead.html +0 -8
- package/tests/fixtures/html-pages-test/public/notfit.html +0 -13
- package/tests/fixtures/html-pages-test/public/slides.html +0 -12
- package/tests/fixtures/html-pages-test/public/sub/page2.html +0 -9
- package/tests/fixtures/html-pages-test/public/unterminated.html +0 -10
- package/tests/fixtures/html-pages-test/publisher.json +0 -5
- package/tests/fixtures/html-pages-test/report.malloy +0 -1
- package/tests/fixtures/persist-multi-level/data/orders.csv +0 -5
- package/tests/fixtures/persist-multi-level/multi_level.malloy +0 -18
- package/tests/fixtures/persist-multi-level/publisher.json +0 -5
- package/tests/fixtures/persist-schedule-test/data/orders.csv +0 -5
- package/tests/fixtures/persist-schedule-test/persist_schedule_test.malloy +0 -11
- package/tests/fixtures/persist-schedule-test/publisher.json +0 -7
- package/tests/fixtures/persist-schedule-warn-test/data/orders.csv +0 -5
- package/tests/fixtures/persist-schedule-warn-test/persist_warn_test.malloy +0 -11
- package/tests/fixtures/persist-schedule-warn-test/publisher.json +0 -6
- package/tests/fixtures/persist-test/data/orders.csv +0 -5
- package/tests/fixtures/persist-test/persist_test.malloy +0 -11
- package/tests/fixtures/persist-test/publisher.json +0 -5
- package/tests/fixtures/publisher.config.json +0 -15
- package/tests/fixtures/query-givens/data/orders.csv +0 -7
- package/tests/fixtures/query-givens/model.malloy +0 -34
- package/tests/fixtures/query-givens/publisher.json +0 -5
- package/tests/fixtures/xlsx/database.xlsx +0 -0
- package/tests/harness/mcp_test_setup.ts +0 -332
- package/tests/harness/rest_e2e.ts +0 -68
- package/tests/integration/authorize/compile_authorize_http.integration.spec.ts +0 -92
- package/tests/integration/concurrent_package/concurrent_package.integration.spec.ts +0 -280
- package/tests/integration/duckdb_storage/duckdb_storage.integration.spec.ts +0 -138
- package/tests/integration/first_boot/readiness_line.integration.spec.ts +0 -177
- package/tests/integration/html_pages/html_pages.integration.spec.ts +0 -440
- package/tests/integration/legacy_routes/legacy_routes.integration.spec.ts +0 -259
- package/tests/integration/materialization/environment_list.integration.spec.ts +0 -133
- package/tests/integration/materialization/freshness_gate.integration.spec.ts +0 -292
- package/tests/integration/materialization/manifest_binding.integration.spec.ts +0 -430
- package/tests/integration/materialization/materialization_lifecycle.integration.spec.ts +0 -441
- package/tests/integration/materialization/orchestrated_rebind.integration.spec.ts +0 -150
- package/tests/integration/materialization/reference_manifest.integration.spec.ts +0 -251
- package/tests/integration/materialization/schedule_edit.integration.spec.ts +0 -126
- package/tests/integration/materialization/scheduler.integration.spec.ts +0 -200
- package/tests/integration/materialization/scheduler_recovery.integration.spec.ts +0 -172
- package/tests/integration/materialization/scheduler_transitions.integration.spec.ts +0 -256
- package/tests/integration/materialization/scheduler_wiring.integration.spec.ts +0 -143
- package/tests/integration/mcp/mcp_execute_query_tool.integration.spec.ts +0 -438
- package/tests/integration/mcp/mcp_get_context_semantic.integration.spec.ts +0 -235
- package/tests/integration/mcp/mcp_transport.integration.spec.ts +0 -98
- package/tests/integration/query_givens/query_givens.integration.spec.ts +0 -146
- package/tests/integration/query_givens/query_givens_authorize.integration.spec.ts +0 -121
- package/tests/integration/sdk_givens/sdk_givens.integration.spec.ts +0 -110
- package/tests/integration/watch-mode/watch_mode.integration.spec.ts +0 -421
- package/tests/unit/controller/theme.controller.spec.ts +0 -141
- package/tests/unit/duckdb/attached_databases.test.ts +0 -1243
- package/tests/unit/duckdb/duckdb_connection.test.ts +0 -181
- package/tests/unit/duckdb/legacy_schema_migration.test.ts +0 -197
- package/tests/unit/duckdb/repositories.test.ts +0 -208
- package/tests/unit/ducklake/ducklake.test.ts +0 -952
- package/tests/unit/service/theme_store.spec.ts +0 -139
- package/tsconfig.json +0 -32
package/src/server-old.ts
DELETED
|
@@ -1,988 +0,0 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
-
// TODO: Remove this during projects cleanup
|
|
3
|
-
/**
|
|
4
|
-
* Legacy `/projects/...` route registration.
|
|
5
|
-
*
|
|
6
|
-
* The publisher's API was renamed from `projects` to `environments`. This module
|
|
7
|
-
* registers the old `/projects/...` paths on the same Express app so existing
|
|
8
|
-
* SDK clients (e.g. `@malloydata/db-publisher`) keep working without code
|
|
9
|
-
* changes on their side.
|
|
10
|
-
*
|
|
11
|
-
* Implementation strategy:
|
|
12
|
-
* - Reuse the same controllers that `server.ts` wires up; only the URL
|
|
13
|
-
* surface changes.
|
|
14
|
-
* - Most response models (`Connection`, `Package`, `Model`, `Notebook`,
|
|
15
|
-
* `Database`, `Table`, `QueryResult`, etc.) have identical JSON wire
|
|
16
|
-
* format between old (`Project`) and new (`Environment`) specs, so they
|
|
17
|
-
* pass through unchanged.
|
|
18
|
-
* - The handful of payloads that DO have field-level renames are remapped:
|
|
19
|
-
* * Materialization responses — `environmentId` -> `projectId`
|
|
20
|
-
*
|
|
21
|
-
* - Watch-mode is intentionally not exposed under the legacy prefix; clients
|
|
22
|
-
* that need it should use the new `/environments/...` paths directly.
|
|
23
|
-
* - `/status` is shared with the new server.ts handler — both old and new
|
|
24
|
-
* clients receive the new `environments`-keyed payload.
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
import bodyParser from "body-parser";
|
|
28
|
-
import type { Express, Response } from "express";
|
|
29
|
-
import { ParsedQs } from "qs";
|
|
30
|
-
import { CompileController } from "./controller/compile.controller";
|
|
31
|
-
import { ConnectionController } from "./controller/connection.controller";
|
|
32
|
-
import { DatabaseController } from "./controller/database.controller";
|
|
33
|
-
import { MaterializationController } from "./controller/materialization.controller";
|
|
34
|
-
import { ModelController } from "./controller/model.controller";
|
|
35
|
-
import { PackageController } from "./controller/package.controller";
|
|
36
|
-
import { QueryController } from "./controller/query.controller";
|
|
37
|
-
import {
|
|
38
|
-
BadRequestError,
|
|
39
|
-
internalErrorToHttpError,
|
|
40
|
-
NotImplementedError,
|
|
41
|
-
} from "./errors";
|
|
42
|
-
import { logger } from "./logger";
|
|
43
|
-
import { queryConcurrency } from "./query_concurrency";
|
|
44
|
-
import { normalizeQueryArray } from "./query_param_utils";
|
|
45
|
-
import { EnvironmentStore } from "./service/environment_store";
|
|
46
|
-
|
|
47
|
-
const LEGACY_API_PREFIX = "/api/v0";
|
|
48
|
-
|
|
49
|
-
/** Bag of controllers shared with the new server. */
|
|
50
|
-
export interface LegacyControllerSet {
|
|
51
|
-
environmentStore: EnvironmentStore;
|
|
52
|
-
connectionController: ConnectionController;
|
|
53
|
-
modelController: ModelController;
|
|
54
|
-
packageController: PackageController;
|
|
55
|
-
databaseController: DatabaseController;
|
|
56
|
-
queryController: QueryController;
|
|
57
|
-
compileController: CompileController;
|
|
58
|
-
materializationController: MaterializationController;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// ─── response/body field mappers ───────────────────────────────────────────
|
|
62
|
-
|
|
63
|
-
function remapMaterializationResponse(mat: any): any {
|
|
64
|
-
if (!mat || typeof mat !== "object") return mat;
|
|
65
|
-
if (Array.isArray(mat)) {
|
|
66
|
-
return mat.map(remapMaterializationResponse);
|
|
67
|
-
}
|
|
68
|
-
const out: Record<string, any> = { ...mat };
|
|
69
|
-
if ("environmentId" in out) {
|
|
70
|
-
out.projectId = out.environmentId;
|
|
71
|
-
delete out.environmentId;
|
|
72
|
-
}
|
|
73
|
-
return out;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const setVersionIdError = (res: Response) => {
|
|
77
|
-
const { json, status } = internalErrorToHttpError(
|
|
78
|
-
new NotImplementedError("Version IDs not implemented."),
|
|
79
|
-
);
|
|
80
|
-
res.status(status).json(json);
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
// ─── route registration ────────────────────────────────────────────────────
|
|
84
|
-
|
|
85
|
-
export function registerLegacyRoutes(
|
|
86
|
-
app: Express,
|
|
87
|
-
controllers: LegacyControllerSet,
|
|
88
|
-
) {
|
|
89
|
-
const {
|
|
90
|
-
environmentStore,
|
|
91
|
-
connectionController,
|
|
92
|
-
modelController,
|
|
93
|
-
packageController,
|
|
94
|
-
databaseController,
|
|
95
|
-
queryController,
|
|
96
|
-
compileController,
|
|
97
|
-
materializationController,
|
|
98
|
-
} = controllers;
|
|
99
|
-
|
|
100
|
-
// body-parser is already registered on the main app for `${API_PREFIX}/*`
|
|
101
|
-
// paths via `app.use(bodyParser.json(...))`. The legacy routes share the
|
|
102
|
-
// same `${API_PREFIX}` prefix so they inherit it automatically.
|
|
103
|
-
void bodyParser; // keep the import; helper file reference for clarity
|
|
104
|
-
|
|
105
|
-
// ── projects (== environments) ──────────────────────────────────────────
|
|
106
|
-
app.get(`${LEGACY_API_PREFIX}/projects`, async (_req, res) => {
|
|
107
|
-
try {
|
|
108
|
-
res.status(200).json(await environmentStore.listEnvironments());
|
|
109
|
-
} catch (error) {
|
|
110
|
-
logger.error(error);
|
|
111
|
-
const { json, status } = internalErrorToHttpError(error as Error);
|
|
112
|
-
res.status(status).json(json);
|
|
113
|
-
}
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
app.post(`${LEGACY_API_PREFIX}/projects`, async (req, res) => {
|
|
117
|
-
try {
|
|
118
|
-
logger.info("Adding project", { body: req.body });
|
|
119
|
-
const environment = await environmentStore.addEnvironment(req.body);
|
|
120
|
-
res.status(200).json(await environment.serialize());
|
|
121
|
-
} catch (error) {
|
|
122
|
-
logger.error(error);
|
|
123
|
-
const { json, status } = internalErrorToHttpError(error as Error);
|
|
124
|
-
res.status(status).json(json);
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
app.get(`${LEGACY_API_PREFIX}/projects/:projectName`, async (req, res) => {
|
|
129
|
-
try {
|
|
130
|
-
const environment = await environmentStore.getEnvironment(
|
|
131
|
-
req.params.projectName,
|
|
132
|
-
req.query.reload === "true",
|
|
133
|
-
);
|
|
134
|
-
res.status(200).json(await environment.serialize());
|
|
135
|
-
} catch (error) {
|
|
136
|
-
logger.error(error);
|
|
137
|
-
const { json, status } = internalErrorToHttpError(error as Error);
|
|
138
|
-
res.status(status).json(json);
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
app.patch(`${LEGACY_API_PREFIX}/projects/:projectName`, async (req, res) => {
|
|
143
|
-
try {
|
|
144
|
-
const environment = await environmentStore.updateEnvironment(req.body);
|
|
145
|
-
res.status(200).json(await environment.serialize());
|
|
146
|
-
} catch (error) {
|
|
147
|
-
logger.error(error);
|
|
148
|
-
const { json, status } = internalErrorToHttpError(error as Error);
|
|
149
|
-
res.status(status).json(json);
|
|
150
|
-
}
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
app.delete(
|
|
154
|
-
`${LEGACY_API_PREFIX}/projects/:projectName`,
|
|
155
|
-
async (req, res) => {
|
|
156
|
-
try {
|
|
157
|
-
const environment = await environmentStore.deleteEnvironment(
|
|
158
|
-
req.params.projectName,
|
|
159
|
-
);
|
|
160
|
-
res.status(200).json(await environment?.serialize());
|
|
161
|
-
} catch (error) {
|
|
162
|
-
logger.error(error);
|
|
163
|
-
const { json, status } = internalErrorToHttpError(error as Error);
|
|
164
|
-
res.status(status).json(json);
|
|
165
|
-
}
|
|
166
|
-
},
|
|
167
|
-
);
|
|
168
|
-
|
|
169
|
-
// ── connections ─────────────────────────────────────────────────────────
|
|
170
|
-
app.get(
|
|
171
|
-
`${LEGACY_API_PREFIX}/projects/:projectName/connections`,
|
|
172
|
-
async (req, res) => {
|
|
173
|
-
try {
|
|
174
|
-
res.status(200).json(
|
|
175
|
-
await connectionController.listConnections(
|
|
176
|
-
req.params.projectName,
|
|
177
|
-
),
|
|
178
|
-
);
|
|
179
|
-
} catch (error) {
|
|
180
|
-
logger.error(error);
|
|
181
|
-
const { json, status } = internalErrorToHttpError(error as Error);
|
|
182
|
-
res.status(status).json(json);
|
|
183
|
-
}
|
|
184
|
-
},
|
|
185
|
-
);
|
|
186
|
-
|
|
187
|
-
app.get(
|
|
188
|
-
`${LEGACY_API_PREFIX}/projects/:projectName/connections/:connectionName`,
|
|
189
|
-
async (req, res) => {
|
|
190
|
-
try {
|
|
191
|
-
res.status(200).json(
|
|
192
|
-
await connectionController.getConnection(
|
|
193
|
-
req.params.projectName,
|
|
194
|
-
req.params.connectionName,
|
|
195
|
-
),
|
|
196
|
-
);
|
|
197
|
-
} catch (error) {
|
|
198
|
-
logger.error(error);
|
|
199
|
-
const { json, status } = internalErrorToHttpError(error as Error);
|
|
200
|
-
res.status(status).json(json);
|
|
201
|
-
}
|
|
202
|
-
},
|
|
203
|
-
);
|
|
204
|
-
|
|
205
|
-
app.post(
|
|
206
|
-
`${LEGACY_API_PREFIX}/projects/:projectName/connections/:connectionName`,
|
|
207
|
-
async (req, res) => {
|
|
208
|
-
try {
|
|
209
|
-
const result = await connectionController.addConnection(
|
|
210
|
-
req.params.projectName,
|
|
211
|
-
req.params.connectionName,
|
|
212
|
-
req.body,
|
|
213
|
-
);
|
|
214
|
-
res.status(201).json(result);
|
|
215
|
-
} catch (error) {
|
|
216
|
-
logger.error("Error creating connection", { error });
|
|
217
|
-
const { json, status } = internalErrorToHttpError(error as Error);
|
|
218
|
-
res.status(status).json(json);
|
|
219
|
-
}
|
|
220
|
-
},
|
|
221
|
-
);
|
|
222
|
-
|
|
223
|
-
app.patch(
|
|
224
|
-
`${LEGACY_API_PREFIX}/projects/:projectName/connections/:connectionName`,
|
|
225
|
-
async (req, res) => {
|
|
226
|
-
try {
|
|
227
|
-
const result = await connectionController.updateConnection(
|
|
228
|
-
req.params.projectName,
|
|
229
|
-
req.params.connectionName,
|
|
230
|
-
req.body,
|
|
231
|
-
);
|
|
232
|
-
res.status(200).json(result);
|
|
233
|
-
} catch (error) {
|
|
234
|
-
logger.error("Error updating connection", { error });
|
|
235
|
-
const { json, status } = internalErrorToHttpError(error as Error);
|
|
236
|
-
res.status(status).json(json);
|
|
237
|
-
}
|
|
238
|
-
},
|
|
239
|
-
);
|
|
240
|
-
|
|
241
|
-
app.delete(
|
|
242
|
-
`${LEGACY_API_PREFIX}/projects/:projectName/connections/:connectionName`,
|
|
243
|
-
async (req, res) => {
|
|
244
|
-
try {
|
|
245
|
-
const result = await connectionController.deleteConnection(
|
|
246
|
-
req.params.projectName,
|
|
247
|
-
req.params.connectionName,
|
|
248
|
-
);
|
|
249
|
-
res.status(200).json(result);
|
|
250
|
-
} catch (error) {
|
|
251
|
-
logger.error("Error deleting connection", { error });
|
|
252
|
-
const { json, status } = internalErrorToHttpError(error as Error);
|
|
253
|
-
res.status(status).json(json);
|
|
254
|
-
}
|
|
255
|
-
},
|
|
256
|
-
);
|
|
257
|
-
|
|
258
|
-
// /connections/test is org-level (no projectName) and unchanged between
|
|
259
|
-
// old and new specs — it's already registered on the main app.
|
|
260
|
-
|
|
261
|
-
app.get(
|
|
262
|
-
`${LEGACY_API_PREFIX}/projects/:projectName/connections/:connectionName/schemas`,
|
|
263
|
-
async (req, res) => {
|
|
264
|
-
try {
|
|
265
|
-
res.status(200).json(
|
|
266
|
-
await connectionController.listSchemas(
|
|
267
|
-
req.params.projectName,
|
|
268
|
-
req.params.connectionName,
|
|
269
|
-
),
|
|
270
|
-
);
|
|
271
|
-
} catch (error) {
|
|
272
|
-
logger.error(error);
|
|
273
|
-
const { json, status } = internalErrorToHttpError(error as Error);
|
|
274
|
-
res.status(status).json(json);
|
|
275
|
-
}
|
|
276
|
-
},
|
|
277
|
-
);
|
|
278
|
-
|
|
279
|
-
app.get(
|
|
280
|
-
`${LEGACY_API_PREFIX}/projects/:projectName/connections/:connectionName/schemas/:schemaName/tables`,
|
|
281
|
-
async (req, res) => {
|
|
282
|
-
try {
|
|
283
|
-
const results = await connectionController.listTables(
|
|
284
|
-
req.params.projectName,
|
|
285
|
-
req.params.connectionName,
|
|
286
|
-
req.params.schemaName,
|
|
287
|
-
normalizeQueryArray(req.query.tableNames),
|
|
288
|
-
);
|
|
289
|
-
res.status(200).json(results);
|
|
290
|
-
} catch (error) {
|
|
291
|
-
logger.error(error);
|
|
292
|
-
const { json, status } = internalErrorToHttpError(error as Error);
|
|
293
|
-
res.status(status).json(json);
|
|
294
|
-
}
|
|
295
|
-
},
|
|
296
|
-
);
|
|
297
|
-
|
|
298
|
-
app.get(
|
|
299
|
-
`${LEGACY_API_PREFIX}/projects/:projectName/connections/:connectionName/schemas/:schemaName/tables/:tablePath`,
|
|
300
|
-
async (req, res) => {
|
|
301
|
-
try {
|
|
302
|
-
const results = await connectionController.getTable(
|
|
303
|
-
req.params.projectName,
|
|
304
|
-
req.params.connectionName,
|
|
305
|
-
req.params.schemaName,
|
|
306
|
-
req.params.tablePath,
|
|
307
|
-
);
|
|
308
|
-
res.status(200).json(results);
|
|
309
|
-
} catch (error) {
|
|
310
|
-
logger.error(error);
|
|
311
|
-
const { json, status } = internalErrorToHttpError(error as Error);
|
|
312
|
-
res.status(status).json(json);
|
|
313
|
-
}
|
|
314
|
-
},
|
|
315
|
-
);
|
|
316
|
-
|
|
317
|
-
// Per-package connection routes (duckdb context)
|
|
318
|
-
app.get(
|
|
319
|
-
`${LEGACY_API_PREFIX}/projects/:projectName/packages/:packageName/connections/:connectionName/schemas`,
|
|
320
|
-
async (req, res) => {
|
|
321
|
-
try {
|
|
322
|
-
res.status(200).json(
|
|
323
|
-
await connectionController.listSchemas(
|
|
324
|
-
req.params.projectName,
|
|
325
|
-
req.params.connectionName,
|
|
326
|
-
req.params.packageName,
|
|
327
|
-
),
|
|
328
|
-
);
|
|
329
|
-
} catch (error) {
|
|
330
|
-
logger.error(error);
|
|
331
|
-
const { json, status } = internalErrorToHttpError(error as Error);
|
|
332
|
-
res.status(status).json(json);
|
|
333
|
-
}
|
|
334
|
-
},
|
|
335
|
-
);
|
|
336
|
-
|
|
337
|
-
app.get(
|
|
338
|
-
`${LEGACY_API_PREFIX}/projects/:projectName/packages/:packageName/connections/:connectionName/schemas/:schemaName/tables`,
|
|
339
|
-
async (req, res) => {
|
|
340
|
-
try {
|
|
341
|
-
res.status(200).json(
|
|
342
|
-
await connectionController.listTables(
|
|
343
|
-
req.params.projectName,
|
|
344
|
-
req.params.connectionName,
|
|
345
|
-
req.params.schemaName,
|
|
346
|
-
normalizeQueryArray(req.query.tableNames),
|
|
347
|
-
req.params.packageName,
|
|
348
|
-
),
|
|
349
|
-
);
|
|
350
|
-
} catch (error) {
|
|
351
|
-
logger.error(error);
|
|
352
|
-
const { json, status } = internalErrorToHttpError(error as Error);
|
|
353
|
-
res.status(status).json(json);
|
|
354
|
-
}
|
|
355
|
-
},
|
|
356
|
-
);
|
|
357
|
-
|
|
358
|
-
app.get(
|
|
359
|
-
`${LEGACY_API_PREFIX}/projects/:projectName/packages/:packageName/connections/:connectionName/schemas/:schemaName/tables/:tablePath`,
|
|
360
|
-
async (req, res) => {
|
|
361
|
-
try {
|
|
362
|
-
res.status(200).json(
|
|
363
|
-
await connectionController.getTable(
|
|
364
|
-
req.params.projectName,
|
|
365
|
-
req.params.connectionName,
|
|
366
|
-
req.params.schemaName,
|
|
367
|
-
req.params.tablePath,
|
|
368
|
-
req.params.packageName,
|
|
369
|
-
),
|
|
370
|
-
);
|
|
371
|
-
} catch (error) {
|
|
372
|
-
logger.error(error);
|
|
373
|
-
const { json, status } = internalErrorToHttpError(error as Error);
|
|
374
|
-
res.status(status).json(json);
|
|
375
|
-
}
|
|
376
|
-
},
|
|
377
|
-
);
|
|
378
|
-
|
|
379
|
-
// sqlSource (POST), per-project + per-package
|
|
380
|
-
app.post(
|
|
381
|
-
`${LEGACY_API_PREFIX}/projects/:projectName/connections/:connectionName/sqlSource`,
|
|
382
|
-
async (req, res) => {
|
|
383
|
-
try {
|
|
384
|
-
res.status(200).json(
|
|
385
|
-
await connectionController.getConnectionSqlSource(
|
|
386
|
-
req.params.projectName,
|
|
387
|
-
req.params.connectionName,
|
|
388
|
-
req.body.sqlStatement as string,
|
|
389
|
-
),
|
|
390
|
-
);
|
|
391
|
-
} catch (error) {
|
|
392
|
-
logger.error(error);
|
|
393
|
-
const { json, status } = internalErrorToHttpError(error as Error);
|
|
394
|
-
res.status(status).json(json);
|
|
395
|
-
}
|
|
396
|
-
},
|
|
397
|
-
);
|
|
398
|
-
|
|
399
|
-
app.post(
|
|
400
|
-
`${LEGACY_API_PREFIX}/projects/:projectName/packages/:packageName/connections/:connectionName/sqlSource`,
|
|
401
|
-
async (req, res) => {
|
|
402
|
-
try {
|
|
403
|
-
res.status(200).json(
|
|
404
|
-
await connectionController.getConnectionSqlSource(
|
|
405
|
-
req.params.projectName,
|
|
406
|
-
req.params.connectionName,
|
|
407
|
-
req.body.sqlStatement as string,
|
|
408
|
-
req.params.packageName,
|
|
409
|
-
),
|
|
410
|
-
);
|
|
411
|
-
} catch (error) {
|
|
412
|
-
logger.error(error);
|
|
413
|
-
const { json, status } = internalErrorToHttpError(error as Error);
|
|
414
|
-
res.status(status).json(json);
|
|
415
|
-
}
|
|
416
|
-
},
|
|
417
|
-
);
|
|
418
|
-
|
|
419
|
-
// queryData (deprecated GET) + sqlQuery (supported POST), per-project +
|
|
420
|
-
// per-package
|
|
421
|
-
// Legacy `/projects/...` query routes keep the GET `queryData`
|
|
422
|
-
// endpoints (unlike the modern `/environments/...` surface, which
|
|
423
|
-
// removed them) so existing SDK clients are not broken. The
|
|
424
|
-
// missing protection is concurrency: without `queryConcurrency()`
|
|
425
|
-
// a flood of legacy clients can saturate the pod even while the
|
|
426
|
-
// modern routes are properly gated. Apply the same per-pod cap
|
|
427
|
-
// here so the legacy surface respects PUBLISHER_MAX_CONCURRENT_QUERIES.
|
|
428
|
-
// Admission, timeout, and row/byte caps are already enforced by
|
|
429
|
-
// the shared controllers downstream.
|
|
430
|
-
app.get(
|
|
431
|
-
`${LEGACY_API_PREFIX}/projects/:projectName/connections/:connectionName/queryData`,
|
|
432
|
-
queryConcurrency(),
|
|
433
|
-
async (req, res) => {
|
|
434
|
-
try {
|
|
435
|
-
res.status(200).json(
|
|
436
|
-
await connectionController.getConnectionQueryData(
|
|
437
|
-
req.params.projectName,
|
|
438
|
-
req.params.connectionName,
|
|
439
|
-
req.query.sqlStatement as string,
|
|
440
|
-
req.query.options as string,
|
|
441
|
-
),
|
|
442
|
-
);
|
|
443
|
-
} catch (error) {
|
|
444
|
-
logger.error(error);
|
|
445
|
-
const { json, status } = internalErrorToHttpError(error as Error);
|
|
446
|
-
res.status(status).json(json);
|
|
447
|
-
}
|
|
448
|
-
},
|
|
449
|
-
);
|
|
450
|
-
|
|
451
|
-
app.get(
|
|
452
|
-
`${LEGACY_API_PREFIX}/projects/:projectName/packages/:packageName/connections/:connectionName/queryData`,
|
|
453
|
-
queryConcurrency(),
|
|
454
|
-
async (req, res) => {
|
|
455
|
-
try {
|
|
456
|
-
res.status(200).json(
|
|
457
|
-
await connectionController.getConnectionQueryData(
|
|
458
|
-
req.params.projectName,
|
|
459
|
-
req.params.connectionName,
|
|
460
|
-
req.query.sqlStatement as string,
|
|
461
|
-
req.query.options as string,
|
|
462
|
-
req.params.packageName,
|
|
463
|
-
),
|
|
464
|
-
);
|
|
465
|
-
} catch (error) {
|
|
466
|
-
logger.error(error);
|
|
467
|
-
const { json, status } = internalErrorToHttpError(error as Error);
|
|
468
|
-
res.status(status).json(json);
|
|
469
|
-
}
|
|
470
|
-
},
|
|
471
|
-
);
|
|
472
|
-
|
|
473
|
-
app.post(
|
|
474
|
-
`${LEGACY_API_PREFIX}/projects/:projectName/connections/:connectionName/sqlQuery`,
|
|
475
|
-
queryConcurrency(),
|
|
476
|
-
async (req, res) => {
|
|
477
|
-
try {
|
|
478
|
-
let options: string | ParsedQs | (string | ParsedQs)[] | undefined;
|
|
479
|
-
if (req.body?.options) {
|
|
480
|
-
options = req.body.options;
|
|
481
|
-
} else {
|
|
482
|
-
options = req.query.options;
|
|
483
|
-
}
|
|
484
|
-
res.status(200).json(
|
|
485
|
-
await connectionController.getConnectionQueryData(
|
|
486
|
-
req.params.projectName,
|
|
487
|
-
req.params.connectionName,
|
|
488
|
-
req.body.sqlStatement as string,
|
|
489
|
-
options as string,
|
|
490
|
-
),
|
|
491
|
-
);
|
|
492
|
-
} catch (error) {
|
|
493
|
-
logger.error(error);
|
|
494
|
-
const { json, status } = internalErrorToHttpError(error as Error);
|
|
495
|
-
res.status(status).json(json);
|
|
496
|
-
}
|
|
497
|
-
},
|
|
498
|
-
);
|
|
499
|
-
|
|
500
|
-
app.post(
|
|
501
|
-
`${LEGACY_API_PREFIX}/projects/:projectName/packages/:packageName/connections/:connectionName/sqlQuery`,
|
|
502
|
-
queryConcurrency(),
|
|
503
|
-
async (req, res) => {
|
|
504
|
-
try {
|
|
505
|
-
let options: string | ParsedQs | (string | ParsedQs)[] | undefined;
|
|
506
|
-
if (req.body?.options) {
|
|
507
|
-
options = req.body.options;
|
|
508
|
-
} else {
|
|
509
|
-
options = req.query.options;
|
|
510
|
-
}
|
|
511
|
-
res.status(200).json(
|
|
512
|
-
await connectionController.getConnectionQueryData(
|
|
513
|
-
req.params.projectName,
|
|
514
|
-
req.params.connectionName,
|
|
515
|
-
req.body.sqlStatement as string,
|
|
516
|
-
options as string,
|
|
517
|
-
req.params.packageName,
|
|
518
|
-
),
|
|
519
|
-
);
|
|
520
|
-
} catch (error) {
|
|
521
|
-
logger.error(error);
|
|
522
|
-
const { json, status } = internalErrorToHttpError(error as Error);
|
|
523
|
-
res.status(status).json(json);
|
|
524
|
-
}
|
|
525
|
-
},
|
|
526
|
-
);
|
|
527
|
-
|
|
528
|
-
// sqlTemporaryTable (POST), per-project + per-package
|
|
529
|
-
app.post(
|
|
530
|
-
`${LEGACY_API_PREFIX}/projects/:projectName/connections/:connectionName/sqlTemporaryTable`,
|
|
531
|
-
queryConcurrency(),
|
|
532
|
-
async (req, res) => {
|
|
533
|
-
try {
|
|
534
|
-
res.status(200).json(
|
|
535
|
-
await connectionController.getConnectionTemporaryTable(
|
|
536
|
-
req.params.projectName,
|
|
537
|
-
req.params.connectionName,
|
|
538
|
-
req.body.sqlStatement as string,
|
|
539
|
-
),
|
|
540
|
-
);
|
|
541
|
-
} catch (error) {
|
|
542
|
-
logger.error(error);
|
|
543
|
-
const { json, status } = internalErrorToHttpError(error as Error);
|
|
544
|
-
res.status(status).json(json);
|
|
545
|
-
}
|
|
546
|
-
},
|
|
547
|
-
);
|
|
548
|
-
|
|
549
|
-
app.post(
|
|
550
|
-
`${LEGACY_API_PREFIX}/projects/:projectName/packages/:packageName/connections/:connectionName/sqlTemporaryTable`,
|
|
551
|
-
queryConcurrency(),
|
|
552
|
-
async (req, res) => {
|
|
553
|
-
try {
|
|
554
|
-
res.status(200).json(
|
|
555
|
-
await connectionController.getConnectionTemporaryTable(
|
|
556
|
-
req.params.projectName,
|
|
557
|
-
req.params.connectionName,
|
|
558
|
-
req.body.sqlStatement as string,
|
|
559
|
-
req.params.packageName,
|
|
560
|
-
),
|
|
561
|
-
);
|
|
562
|
-
} catch (error) {
|
|
563
|
-
logger.error(error);
|
|
564
|
-
const { json, status } = internalErrorToHttpError(error as Error);
|
|
565
|
-
res.status(status).json(json);
|
|
566
|
-
}
|
|
567
|
-
},
|
|
568
|
-
);
|
|
569
|
-
|
|
570
|
-
// ── packages ────────────────────────────────────────────────────────────
|
|
571
|
-
app.get(
|
|
572
|
-
`${LEGACY_API_PREFIX}/projects/:projectName/packages`,
|
|
573
|
-
async (req, res) => {
|
|
574
|
-
if (req.query.versionId) {
|
|
575
|
-
setVersionIdError(res);
|
|
576
|
-
return;
|
|
577
|
-
}
|
|
578
|
-
try {
|
|
579
|
-
res.status(200).json(
|
|
580
|
-
await packageController.listPackages(req.params.projectName),
|
|
581
|
-
);
|
|
582
|
-
} catch (error) {
|
|
583
|
-
logger.error(error);
|
|
584
|
-
const { json, status } = internalErrorToHttpError(error as Error);
|
|
585
|
-
res.status(status).json(json);
|
|
586
|
-
}
|
|
587
|
-
},
|
|
588
|
-
);
|
|
589
|
-
|
|
590
|
-
app.post(
|
|
591
|
-
`${LEGACY_API_PREFIX}/projects/:projectName/packages`,
|
|
592
|
-
async (req, res) => {
|
|
593
|
-
try {
|
|
594
|
-
const _package = await packageController.addPackage(
|
|
595
|
-
req.params.projectName,
|
|
596
|
-
req.body,
|
|
597
|
-
);
|
|
598
|
-
res.status(200).json(_package?.getPackageMetadata());
|
|
599
|
-
} catch (error) {
|
|
600
|
-
logger.error(error);
|
|
601
|
-
const { json, status } = internalErrorToHttpError(error as Error);
|
|
602
|
-
res.status(status).json(json);
|
|
603
|
-
}
|
|
604
|
-
},
|
|
605
|
-
);
|
|
606
|
-
|
|
607
|
-
app.get(
|
|
608
|
-
`${LEGACY_API_PREFIX}/projects/:projectName/packages/:packageName`,
|
|
609
|
-
async (req, res) => {
|
|
610
|
-
if (req.query.versionId) {
|
|
611
|
-
setVersionIdError(res);
|
|
612
|
-
return;
|
|
613
|
-
}
|
|
614
|
-
try {
|
|
615
|
-
res.status(200).json(
|
|
616
|
-
await packageController.getPackage(
|
|
617
|
-
req.params.projectName,
|
|
618
|
-
req.params.packageName,
|
|
619
|
-
req.query.reload === "true",
|
|
620
|
-
),
|
|
621
|
-
);
|
|
622
|
-
} catch (error) {
|
|
623
|
-
logger.error(error);
|
|
624
|
-
const { json, status } = internalErrorToHttpError(error as Error);
|
|
625
|
-
res.status(status).json(json);
|
|
626
|
-
}
|
|
627
|
-
},
|
|
628
|
-
);
|
|
629
|
-
|
|
630
|
-
app.patch(
|
|
631
|
-
`${LEGACY_API_PREFIX}/projects/:projectName/packages/:packageName`,
|
|
632
|
-
async (req, res) => {
|
|
633
|
-
try {
|
|
634
|
-
res.status(200).json(
|
|
635
|
-
await packageController.updatePackage(
|
|
636
|
-
req.params.projectName,
|
|
637
|
-
req.params.packageName,
|
|
638
|
-
req.body,
|
|
639
|
-
),
|
|
640
|
-
);
|
|
641
|
-
} catch (error) {
|
|
642
|
-
logger.error(error);
|
|
643
|
-
const { json, status } = internalErrorToHttpError(error as Error);
|
|
644
|
-
res.status(status).json(json);
|
|
645
|
-
}
|
|
646
|
-
},
|
|
647
|
-
);
|
|
648
|
-
|
|
649
|
-
app.delete(
|
|
650
|
-
`${LEGACY_API_PREFIX}/projects/:projectName/packages/:packageName`,
|
|
651
|
-
async (req, res) => {
|
|
652
|
-
try {
|
|
653
|
-
res.status(200).json(
|
|
654
|
-
await packageController.deletePackage(
|
|
655
|
-
req.params.projectName,
|
|
656
|
-
req.params.packageName,
|
|
657
|
-
),
|
|
658
|
-
);
|
|
659
|
-
} catch (error) {
|
|
660
|
-
logger.error(error);
|
|
661
|
-
const { json, status } = internalErrorToHttpError(error as Error);
|
|
662
|
-
res.status(status).json(json);
|
|
663
|
-
}
|
|
664
|
-
},
|
|
665
|
-
);
|
|
666
|
-
|
|
667
|
-
// ── models ──────────────────────────────────────────────────────────────
|
|
668
|
-
app.get(
|
|
669
|
-
`${LEGACY_API_PREFIX}/projects/:projectName/packages/:packageName/models`,
|
|
670
|
-
async (req, res) => {
|
|
671
|
-
if (req.query.versionId) {
|
|
672
|
-
setVersionIdError(res);
|
|
673
|
-
return;
|
|
674
|
-
}
|
|
675
|
-
try {
|
|
676
|
-
res.status(200).json(
|
|
677
|
-
await modelController.listModels(
|
|
678
|
-
req.params.projectName,
|
|
679
|
-
req.params.packageName,
|
|
680
|
-
),
|
|
681
|
-
);
|
|
682
|
-
} catch (error) {
|
|
683
|
-
logger.error(error);
|
|
684
|
-
const { json, status } = internalErrorToHttpError(error as Error);
|
|
685
|
-
res.status(status).json(json);
|
|
686
|
-
}
|
|
687
|
-
},
|
|
688
|
-
);
|
|
689
|
-
|
|
690
|
-
app.get(
|
|
691
|
-
`${LEGACY_API_PREFIX}/projects/:projectName/packages/:packageName/models/*?`,
|
|
692
|
-
async (req, res) => {
|
|
693
|
-
if (req.query.versionId) {
|
|
694
|
-
setVersionIdError(res);
|
|
695
|
-
return;
|
|
696
|
-
}
|
|
697
|
-
try {
|
|
698
|
-
const modelPath = (req.params as Record<string, string>)["0"];
|
|
699
|
-
res.status(200).json(
|
|
700
|
-
await modelController.getModel(
|
|
701
|
-
req.params.projectName,
|
|
702
|
-
req.params.packageName,
|
|
703
|
-
modelPath,
|
|
704
|
-
),
|
|
705
|
-
);
|
|
706
|
-
} catch (error) {
|
|
707
|
-
logger.error(error);
|
|
708
|
-
const { json, status } = internalErrorToHttpError(error as Error);
|
|
709
|
-
res.status(status).json(json);
|
|
710
|
-
}
|
|
711
|
-
},
|
|
712
|
-
);
|
|
713
|
-
|
|
714
|
-
app.post(
|
|
715
|
-
`${LEGACY_API_PREFIX}/projects/:projectName/packages/:packageName/models/*?/query`,
|
|
716
|
-
queryConcurrency(),
|
|
717
|
-
async (req, res) => {
|
|
718
|
-
if (req.body.versionId) {
|
|
719
|
-
setVersionIdError(res);
|
|
720
|
-
return;
|
|
721
|
-
}
|
|
722
|
-
try {
|
|
723
|
-
const modelPath = (req.params as Record<string, string>)["0"];
|
|
724
|
-
res.status(200).json(
|
|
725
|
-
await queryController.getQuery(
|
|
726
|
-
req.params.projectName,
|
|
727
|
-
req.params.packageName,
|
|
728
|
-
modelPath,
|
|
729
|
-
req.body.sourceName as string,
|
|
730
|
-
req.body.queryName as string,
|
|
731
|
-
req.body.query as string,
|
|
732
|
-
req.body.compactJson === true,
|
|
733
|
-
(req.body.filterParams ?? req.body.sourceFilters) as
|
|
734
|
-
| Record<string, string | string[]>
|
|
735
|
-
| undefined,
|
|
736
|
-
req.body.bypassFilters === true ? true : undefined,
|
|
737
|
-
),
|
|
738
|
-
);
|
|
739
|
-
} catch (error) {
|
|
740
|
-
logger.error(error);
|
|
741
|
-
const { json, status } = internalErrorToHttpError(error as Error);
|
|
742
|
-
res.status(status).json(json);
|
|
743
|
-
}
|
|
744
|
-
},
|
|
745
|
-
);
|
|
746
|
-
|
|
747
|
-
app.post(
|
|
748
|
-
`${LEGACY_API_PREFIX}/projects/:projectName/packages/:packageName/models/:modelName/compile`,
|
|
749
|
-
async (req, res) => {
|
|
750
|
-
try {
|
|
751
|
-
const result = await compileController.compile(
|
|
752
|
-
req.params.projectName,
|
|
753
|
-
req.params.packageName,
|
|
754
|
-
req.params.modelName,
|
|
755
|
-
req.body.source,
|
|
756
|
-
req.body.includeSql === true,
|
|
757
|
-
);
|
|
758
|
-
res.status(200).json(result);
|
|
759
|
-
} catch (error) {
|
|
760
|
-
logger.error("Compilation error", { error });
|
|
761
|
-
const { json, status } = internalErrorToHttpError(error as Error);
|
|
762
|
-
res.status(status).json(json);
|
|
763
|
-
}
|
|
764
|
-
},
|
|
765
|
-
);
|
|
766
|
-
|
|
767
|
-
// ── notebooks ───────────────────────────────────────────────────────────
|
|
768
|
-
app.get(
|
|
769
|
-
`${LEGACY_API_PREFIX}/projects/:projectName/packages/:packageName/notebooks`,
|
|
770
|
-
async (req, res) => {
|
|
771
|
-
if (req.query.versionId) {
|
|
772
|
-
setVersionIdError(res);
|
|
773
|
-
return;
|
|
774
|
-
}
|
|
775
|
-
try {
|
|
776
|
-
res.status(200).json(
|
|
777
|
-
await modelController.listNotebooks(
|
|
778
|
-
req.params.projectName,
|
|
779
|
-
req.params.packageName,
|
|
780
|
-
),
|
|
781
|
-
);
|
|
782
|
-
} catch (error) {
|
|
783
|
-
logger.error(error);
|
|
784
|
-
const { json, status } = internalErrorToHttpError(error as Error);
|
|
785
|
-
res.status(status).json(json);
|
|
786
|
-
}
|
|
787
|
-
},
|
|
788
|
-
);
|
|
789
|
-
|
|
790
|
-
// Cell execution route comes BEFORE the general getNotebook wildcard
|
|
791
|
-
app.get(
|
|
792
|
-
`${LEGACY_API_PREFIX}/projects/:projectName/packages/:packageName/notebooks/*/cells/:cellIndex`,
|
|
793
|
-
queryConcurrency(),
|
|
794
|
-
async (req, res) => {
|
|
795
|
-
if (req.query.versionId) {
|
|
796
|
-
setVersionIdError(res);
|
|
797
|
-
return;
|
|
798
|
-
}
|
|
799
|
-
try {
|
|
800
|
-
const cellIndex = parseInt(req.params.cellIndex, 10);
|
|
801
|
-
if (isNaN(cellIndex)) {
|
|
802
|
-
res.status(400).json({ error: "Invalid cell index" });
|
|
803
|
-
return;
|
|
804
|
-
}
|
|
805
|
-
const notebookPath = (req.params as Record<string, string>)["0"];
|
|
806
|
-
let filterParams: Record<string, string | string[]> | undefined;
|
|
807
|
-
if (typeof req.query.filter_params === "string") {
|
|
808
|
-
try {
|
|
809
|
-
filterParams = JSON.parse(req.query.filter_params);
|
|
810
|
-
} catch {
|
|
811
|
-
res.status(400).json({
|
|
812
|
-
error: "Invalid filter_params: must be valid JSON",
|
|
813
|
-
});
|
|
814
|
-
return;
|
|
815
|
-
}
|
|
816
|
-
}
|
|
817
|
-
const bypassFilters =
|
|
818
|
-
req.query.bypass_filters === "true" ? true : undefined;
|
|
819
|
-
res.status(200).json(
|
|
820
|
-
await modelController.executeNotebookCell(
|
|
821
|
-
req.params.projectName,
|
|
822
|
-
req.params.packageName,
|
|
823
|
-
notebookPath,
|
|
824
|
-
cellIndex,
|
|
825
|
-
filterParams,
|
|
826
|
-
bypassFilters,
|
|
827
|
-
),
|
|
828
|
-
);
|
|
829
|
-
} catch (error) {
|
|
830
|
-
logger.error(error);
|
|
831
|
-
const { json, status } = internalErrorToHttpError(error as Error);
|
|
832
|
-
res.status(status).json(json);
|
|
833
|
-
}
|
|
834
|
-
},
|
|
835
|
-
);
|
|
836
|
-
|
|
837
|
-
app.get(
|
|
838
|
-
`${LEGACY_API_PREFIX}/projects/:projectName/packages/:packageName/notebooks/*?`,
|
|
839
|
-
async (req, res) => {
|
|
840
|
-
if (req.query.versionId) {
|
|
841
|
-
setVersionIdError(res);
|
|
842
|
-
return;
|
|
843
|
-
}
|
|
844
|
-
try {
|
|
845
|
-
const notebookPath = (req.params as Record<string, string>)["0"];
|
|
846
|
-
res.status(200).json(
|
|
847
|
-
await modelController.getNotebook(
|
|
848
|
-
req.params.projectName,
|
|
849
|
-
req.params.packageName,
|
|
850
|
-
notebookPath,
|
|
851
|
-
),
|
|
852
|
-
);
|
|
853
|
-
} catch (error) {
|
|
854
|
-
logger.error(error);
|
|
855
|
-
const { json, status } = internalErrorToHttpError(error as Error);
|
|
856
|
-
res.status(status).json(json);
|
|
857
|
-
}
|
|
858
|
-
},
|
|
859
|
-
);
|
|
860
|
-
|
|
861
|
-
// ── databases ───────────────────────────────────────────────────────────
|
|
862
|
-
app.get(
|
|
863
|
-
`${LEGACY_API_PREFIX}/projects/:projectName/packages/:packageName/databases`,
|
|
864
|
-
async (req, res) => {
|
|
865
|
-
if (req.query.versionId) {
|
|
866
|
-
setVersionIdError(res);
|
|
867
|
-
return;
|
|
868
|
-
}
|
|
869
|
-
try {
|
|
870
|
-
res.status(200).json(
|
|
871
|
-
await databaseController.listDatabases(
|
|
872
|
-
req.params.projectName,
|
|
873
|
-
req.params.packageName,
|
|
874
|
-
),
|
|
875
|
-
);
|
|
876
|
-
} catch (error) {
|
|
877
|
-
logger.error(error);
|
|
878
|
-
const { json, status } = internalErrorToHttpError(error as Error);
|
|
879
|
-
res.status(status).json(json);
|
|
880
|
-
}
|
|
881
|
-
},
|
|
882
|
-
);
|
|
883
|
-
|
|
884
|
-
// ── materializations ────────────────────────────────────────────────────
|
|
885
|
-
app.post(
|
|
886
|
-
`${LEGACY_API_PREFIX}/projects/:projectName/packages/:packageName/materializations`,
|
|
887
|
-
async (req, res) => {
|
|
888
|
-
try {
|
|
889
|
-
const build = await materializationController.createMaterialization(
|
|
890
|
-
req.params.projectName,
|
|
891
|
-
req.params.packageName,
|
|
892
|
-
req.body || {},
|
|
893
|
-
);
|
|
894
|
-
res.status(201).json(remapMaterializationResponse(build));
|
|
895
|
-
} catch (error) {
|
|
896
|
-
const { json, status } = internalErrorToHttpError(error as Error);
|
|
897
|
-
res.status(status).json(json);
|
|
898
|
-
}
|
|
899
|
-
},
|
|
900
|
-
);
|
|
901
|
-
|
|
902
|
-
app.get(
|
|
903
|
-
`${LEGACY_API_PREFIX}/projects/:projectName/packages/:packageName/materializations`,
|
|
904
|
-
async (req, res) => {
|
|
905
|
-
try {
|
|
906
|
-
const limit = req.query.limit
|
|
907
|
-
? parseInt(req.query.limit as string, 10)
|
|
908
|
-
: undefined;
|
|
909
|
-
const offset = req.query.offset
|
|
910
|
-
? parseInt(req.query.offset as string, 10)
|
|
911
|
-
: undefined;
|
|
912
|
-
const builds = await materializationController.listMaterializations(
|
|
913
|
-
req.params.projectName,
|
|
914
|
-
req.params.packageName,
|
|
915
|
-
{ limit, offset },
|
|
916
|
-
);
|
|
917
|
-
res.status(200).json(remapMaterializationResponse(builds));
|
|
918
|
-
} catch (error) {
|
|
919
|
-
const { json, status } = internalErrorToHttpError(error as Error);
|
|
920
|
-
res.status(status).json(json);
|
|
921
|
-
}
|
|
922
|
-
},
|
|
923
|
-
);
|
|
924
|
-
|
|
925
|
-
app.get(
|
|
926
|
-
`${LEGACY_API_PREFIX}/projects/:projectName/packages/:packageName/materializations/:materializationId`,
|
|
927
|
-
async (req, res) => {
|
|
928
|
-
try {
|
|
929
|
-
const build = await materializationController.getMaterialization(
|
|
930
|
-
req.params.projectName,
|
|
931
|
-
req.params.packageName,
|
|
932
|
-
req.params.materializationId,
|
|
933
|
-
);
|
|
934
|
-
res.status(200).json(remapMaterializationResponse(build));
|
|
935
|
-
} catch (error) {
|
|
936
|
-
const { json, status } = internalErrorToHttpError(error as Error);
|
|
937
|
-
res.status(status).json(json);
|
|
938
|
-
}
|
|
939
|
-
},
|
|
940
|
-
);
|
|
941
|
-
|
|
942
|
-
app.post(
|
|
943
|
-
`${LEGACY_API_PREFIX}/projects/:projectName/packages/:packageName/materializations/:materializationId`,
|
|
944
|
-
async (req, res) => {
|
|
945
|
-
try {
|
|
946
|
-
const action = req.query.action;
|
|
947
|
-
if (action === "stop") {
|
|
948
|
-
const build =
|
|
949
|
-
await materializationController.stopMaterialization(
|
|
950
|
-
req.params.projectName,
|
|
951
|
-
req.params.packageName,
|
|
952
|
-
req.params.materializationId,
|
|
953
|
-
);
|
|
954
|
-
res.status(200).json(remapMaterializationResponse(build));
|
|
955
|
-
} else {
|
|
956
|
-
throw new BadRequestError(
|
|
957
|
-
`Unsupported action '${String(action ?? "")}'. Expected 'stop'.`,
|
|
958
|
-
);
|
|
959
|
-
}
|
|
960
|
-
} catch (error) {
|
|
961
|
-
const { json, status } = internalErrorToHttpError(error as Error);
|
|
962
|
-
res.status(status).json(json);
|
|
963
|
-
}
|
|
964
|
-
},
|
|
965
|
-
);
|
|
966
|
-
|
|
967
|
-
app.delete(
|
|
968
|
-
`${LEGACY_API_PREFIX}/projects/:projectName/packages/:packageName/materializations/:materializationId`,
|
|
969
|
-
async (req, res) => {
|
|
970
|
-
try {
|
|
971
|
-
await materializationController.deleteMaterialization(
|
|
972
|
-
req.params.projectName,
|
|
973
|
-
req.params.packageName,
|
|
974
|
-
req.params.materializationId,
|
|
975
|
-
{ dropTables: req.query.dropTables === "true" },
|
|
976
|
-
);
|
|
977
|
-
res.status(204).send();
|
|
978
|
-
} catch (error) {
|
|
979
|
-
const { json, status } = internalErrorToHttpError(error as Error);
|
|
980
|
-
res.status(status).json(json);
|
|
981
|
-
}
|
|
982
|
-
},
|
|
983
|
-
);
|
|
984
|
-
|
|
985
|
-
logger.info(
|
|
986
|
-
"Legacy /projects/* routes registered for backwards compatibility",
|
|
987
|
-
);
|
|
988
|
-
}
|