tina4-nodejs 3.13.136 → 3.13.138
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/CLAUDE.md +33 -3
- package/COMMERCIAL-LICENSE.md +8 -0
- package/LICENSE +373 -0
- package/NOTICE +11 -0
- package/README.md +24 -2
- package/package.json +44 -6
- package/packages/cli/dist/bin.js +19440 -18017
- package/packages/cli/src/bin.ts +8 -0
- package/packages/cli/src/commands/build.ts +8 -0
- package/packages/cli/src/commands/generate.ts +8 -0
- package/packages/cli/src/commands/init.ts +8 -0
- package/packages/cli/src/commands/lint.ts +8 -0
- package/packages/cli/src/commands/migrate.ts +8 -0
- package/packages/cli/src/commands/migrateCreate.ts +8 -0
- package/packages/cli/src/commands/migrateRollback.ts +8 -0
- package/packages/cli/src/commands/migrateStatus.ts +8 -0
- package/packages/cli/src/commands/queue.ts +8 -0
- package/packages/cli/src/commands/routes.ts +8 -0
- package/packages/cli/src/commands/seed.ts +8 -0
- package/packages/cli/src/commands/serve.ts +11 -0
- package/packages/cli/src/commands/test.ts +8 -0
- package/packages/core/dist/index.js +19432 -18012
- package/packages/core/gallery/auth/src/routes/api/gallery/auth/login/post.ts +8 -0
- package/packages/core/gallery/auth/src/routes/api/gallery/auth/verify/get.ts +8 -0
- package/packages/core/gallery/auth/src/routes/gallery/auth/get.ts +8 -0
- package/packages/core/gallery/database/src/routes/api/gallery/db/notes/get.ts +8 -0
- package/packages/core/gallery/database/src/routes/api/gallery/db/notes/post.ts +8 -0
- package/packages/core/gallery/database/src/routes/api/gallery/db/tables/get.ts +8 -0
- package/packages/core/gallery/error-overlay/src/routes/api/gallery/crash/get.ts +8 -0
- package/packages/core/gallery/orm/src/routes/api/gallery/products/get.ts +8 -0
- package/packages/core/gallery/orm/src/routes/api/gallery/products/post.ts +8 -0
- package/packages/core/gallery/queue/src/lib/queueDb.ts +8 -0
- package/packages/core/gallery/queue/src/routes/api/gallery/queue/consume/post.ts +8 -0
- package/packages/core/gallery/queue/src/routes/api/gallery/queue/fail/post.ts +8 -0
- package/packages/core/gallery/queue/src/routes/api/gallery/queue/produce/post.ts +8 -0
- package/packages/core/gallery/queue/src/routes/api/gallery/queue/retry/post.ts +8 -0
- package/packages/core/gallery/queue/src/routes/api/gallery/queue/status/get.ts +8 -0
- package/packages/core/gallery/queue/src/routes/gallery/queue/get.ts +8 -0
- package/packages/core/gallery/rest-api/src/routes/api/gallery/hello/get.ts +8 -0
- package/packages/core/gallery/rest-api/src/routes/api/gallery/hello/post.ts +8 -0
- package/packages/core/gallery/templates/src/routes/gallery/page/get.ts +8 -0
- package/packages/core/gallery/templates/src/templates/gallery_page.twig +8 -0
- package/packages/core/public/THIRD-PARTY-NOTICES.md +55 -0
- package/packages/core/public/bundled-component-provenance.json +48 -0
- package/packages/core/public/js/tina4js.min.js +13 -3
- package/packages/core/public/licenses/swagger-ui-3.10.0-original-notice.txt +11 -0
- package/packages/core/public/licenses/swagger-ui-5.17.14-NOTICE.txt +2 -0
- package/packages/core/public/licenses/swagger-ui-Apache-2.0.txt +202 -0
- package/packages/core/public/licenses/tina4-css-MIT.txt +21 -0
- package/packages/core/public/licenses/tina4-dev-admin-components.json +240 -0
- package/packages/core/public/licenses/tina4-dev-admin-third-party.txt +919 -0
- package/packages/core/public/licenses/tina4-js-MIT.txt +20 -0
- package/packages/core/src/__feedback/widget.js +8 -0
- package/packages/core/src/_missing.ts +8 -0
- package/packages/core/src/ai.ts +8 -0
- package/packages/core/src/aiClient.ts +22 -7
- package/packages/core/src/api.ts +15 -3
- package/packages/core/src/auth.ts +21 -8
- package/packages/core/src/authGate.ts +8 -0
- package/packages/core/src/background.ts +8 -0
- package/packages/core/src/cache.ts +43 -4
- package/packages/core/src/constants.ts +8 -0
- package/packages/core/src/container.ts +8 -0
- package/packages/core/src/context/chunker.ts +8 -0
- package/packages/core/src/context/index.ts +8 -0
- package/packages/core/src/devAdmin.ts +185 -59
- package/packages/core/src/devMailbox.ts +8 -0
- package/packages/core/src/dispatchPipeline.ts +8 -0
- package/packages/core/src/docs.ts +8 -0
- package/packages/core/src/docsAutoDiscovery.ts +8 -0
- package/packages/core/src/docsParser.ts +8 -0
- package/packages/core/src/docsScanner.ts +44 -0
- package/packages/core/src/docsSignatures.ts +8 -0
- package/packages/core/src/dotenv.ts +8 -0
- package/packages/core/src/env.ts +8 -0
- package/packages/core/src/errorOverlay.ts +8 -0
- package/packages/core/src/events.ts +8 -0
- package/packages/core/src/fakeData.ts +8 -0
- package/packages/core/src/feedback.ts +8 -0
- package/packages/core/src/graphql.ts +16 -5
- package/packages/core/src/health.ts +8 -0
- package/packages/core/src/htmlElement.ts +8 -0
- package/packages/core/src/i18n.ts +8 -0
- package/packages/core/src/index.ts +8 -0
- package/packages/core/src/job.ts +8 -0
- package/packages/core/src/logger.ts +8 -0
- package/packages/core/src/mcp.test.ts +8 -0
- package/packages/core/src/mcp.ts +8 -0
- package/packages/core/src/messenger.ts +143 -86
- package/packages/core/src/metrics.ts +13 -0
- package/packages/core/src/middleware.ts +1178 -1096
- package/packages/core/src/mqtt.ts +8 -0
- package/packages/core/src/mqttMessage.ts +8 -0
- package/packages/core/src/optionalPackage.ts +48 -0
- package/packages/core/src/plan.ts +8 -0
- package/packages/core/src/portTakeover.ts +8 -0
- package/packages/core/src/projectIndex.ts +8 -0
- package/packages/core/src/projectIndexExtractors.ts +8 -0
- package/packages/core/src/projectIndexStorage.ts +8 -0
- package/packages/core/src/push.ts +8 -0
- package/packages/core/src/queue.ts +8 -0
- package/packages/core/src/queueBackends/kafkaBackend.ts +8 -0
- package/packages/core/src/queueBackends/liteBackend.ts +8 -0
- package/packages/core/src/queueBackends/mongoBackend.ts +21 -8
- package/packages/core/src/queueBackends/rabbitmqBackend.ts +8 -0
- package/packages/core/src/rateLimiter.ts +8 -0
- package/packages/core/src/request.ts +59 -10
- package/packages/core/src/response.ts +79 -5
- package/packages/core/src/routeDiscovery.ts +8 -0
- package/packages/core/src/router.ts +8 -0
- package/packages/core/src/server.ts +73 -24
- package/packages/core/src/service.ts +8 -0
- package/packages/core/src/session.ts +8 -0
- package/packages/core/src/sessionHandlers/childError.ts +8 -0
- package/packages/core/src/sessionHandlers/databaseHandler.ts +8 -0
- package/packages/core/src/sessionHandlers/memcachedHandler.ts +8 -0
- package/packages/core/src/sessionHandlers/mongoClient.ts +8 -0
- package/packages/core/src/sessionHandlers/mongoHandler.ts +8 -0
- package/packages/core/src/sessionHandlers/respClient.ts +8 -0
- package/packages/core/src/sessionHandlers/sqlClient.ts +8 -0
- package/packages/core/src/sessionHandlers/syncBridge.ts +8 -0
- package/packages/core/src/sessionHandlers/syncSocket.ts +8 -0
- package/packages/core/src/sessionHandlers/valkeyHandler.ts +8 -0
- package/packages/core/src/sso.ts +8 -0
- package/packages/core/src/static.ts +8 -0
- package/packages/core/src/test.ts +8 -0
- package/packages/core/src/testClient.ts +8 -0
- package/packages/core/src/testing.ts +8 -0
- package/packages/core/src/transport.ts +369 -0
- package/packages/core/src/trustedProxy.ts +8 -0
- package/packages/core/src/types.ts +13 -0
- package/packages/core/src/validator.ts +8 -0
- package/packages/core/src/version.ts +8 -0
- package/packages/core/src/websocket.ts +8 -0
- package/packages/core/src/websocketBackplane.ts +49 -32
- package/packages/core/src/websocketConnection.ts +8 -0
- package/packages/core/src/wsdl.ts +197 -115
- package/packages/core/templates/errors/302.twig +8 -0
- package/packages/core/templates/errors/401.twig +8 -0
- package/packages/core/templates/errors/403.twig +8 -0
- package/packages/core/templates/errors/404.twig +8 -0
- package/packages/core/templates/errors/500.twig +8 -0
- package/packages/core/templates/errors/502.twig +8 -0
- package/packages/core/templates/errors/503.twig +8 -0
- package/packages/core/templates/errors/base.twig +8 -0
- package/packages/frond/dist/index.js +151 -17
- package/packages/frond/src/engine.ts +177 -17
- package/packages/frond/src/index.ts +8 -0
- package/packages/orm/dist/index.js +8135 -6713
- package/packages/orm/src/adapters/firebird.ts +50 -3
- package/packages/orm/src/adapters/mongodb.ts +8 -0
- package/packages/orm/src/adapters/mssql.ts +29 -7
- package/packages/orm/src/adapters/mysql.ts +17 -1
- package/packages/orm/src/adapters/odbc.ts +11 -0
- package/packages/orm/src/adapters/pg-types.d.ts +8 -0
- package/packages/orm/src/adapters/postgres.ts +34 -8
- package/packages/orm/src/adapters/sqlDialect.ts +57 -0
- package/packages/orm/src/adapters/sqlite.ts +26 -0
- package/packages/orm/src/autoCrud.ts +78 -36
- package/packages/orm/src/baseModel.ts +61 -29
- package/packages/orm/src/cachedDatabase.ts +67 -1
- package/packages/orm/src/connectTimeout.ts +8 -0
- package/packages/orm/src/database.ts +649 -401
- package/packages/orm/src/databaseResult.ts +8 -0
- package/packages/orm/src/databaseUrl.ts +8 -0
- package/packages/orm/src/docstore.ts +23 -1
- package/packages/orm/src/fakeData.ts +8 -0
- package/packages/orm/src/graph/adapters/arango.ts +8 -0
- package/packages/orm/src/graph/adapters/bolt.ts +8 -0
- package/packages/orm/src/graph/adapters/ultipa.ts +8 -0
- package/packages/orm/src/graph/connectTimeout.ts +8 -0
- package/packages/orm/src/graph/errors.ts +8 -0
- package/packages/orm/src/graph/graphAdapter.ts +8 -0
- package/packages/orm/src/graph/graphDatabase.ts +8 -0
- package/packages/orm/src/graph/graphUrl.ts +10 -1
- package/packages/orm/src/graph/shapes.ts +8 -0
- package/packages/orm/src/index.ts +147 -139
- package/packages/orm/src/migration.ts +21 -0
- package/packages/orm/src/model.ts +8 -0
- package/packages/orm/src/modelCollection.ts +8 -0
- package/packages/orm/src/point.ts +8 -0
- package/packages/orm/src/query.ts +149 -33
- package/packages/orm/src/queryBuilder.ts +8 -0
- package/packages/orm/src/realtime/index.ts +8 -0
- package/packages/orm/src/realtime/models/attachment.ts +8 -0
- package/packages/orm/src/realtime/models/channel.ts +8 -0
- package/packages/orm/src/realtime/models/channelMember.ts +8 -0
- package/packages/orm/src/realtime/models/message.ts +8 -0
- package/packages/orm/src/realtime/models/workspace.ts +8 -0
- package/packages/orm/src/realtime/realtime.ts +8 -0
- package/packages/orm/src/realtime/storage.ts +43 -12
- package/packages/orm/src/seeder.ts +8 -0
- package/packages/orm/src/seederTable.ts +8 -0
- package/packages/orm/src/seederTypes.ts +8 -0
- package/packages/orm/src/sqlTranslator.ts +185 -8
- package/packages/orm/src/types.ts +15 -0
- package/packages/orm/src/validation.ts +8 -0
- package/packages/swagger/src/generator.ts +8 -0
- package/packages/swagger/src/index.ts +8 -0
- package/packages/swagger/src/ui.ts +8 -0
- package/types/core/src/aiClient.d.ts +2 -2
- package/types/core/src/background.d.ts +0 -16
- package/types/core/src/cache.d.ts +6 -0
- package/types/core/src/devAdmin.d.ts +18 -12
- package/types/core/src/docs.d.ts +0 -17
- package/types/core/src/errorOverlay.d.ts +0 -24
- package/types/core/src/events.d.ts +0 -12
- package/types/core/src/feedback.d.ts +0 -23
- package/types/core/src/graphql.d.ts +0 -21
- package/types/core/src/htmlElement.d.ts +0 -15
- package/types/core/src/messenger.d.ts +12 -1
- package/types/core/src/metrics.d.ts +2 -0
- package/types/core/src/middleware.d.ts +45 -1
- package/types/core/src/mqtt.d.ts +0 -33
- package/types/core/src/optionalPackage.d.ts +25 -0
- package/types/core/src/plan.d.ts +0 -10
- package/types/core/src/projectIndex.d.ts +0 -10
- package/types/core/src/queueBackends/mongoBackend.d.ts +2 -0
- package/types/core/src/request.d.ts +12 -0
- package/types/core/src/response.d.ts +13 -0
- package/types/core/src/server.d.ts +19 -0
- package/types/core/src/sessionHandlers/childError.d.ts +0 -15
- package/types/core/src/transport.d.ts +28 -0
- package/types/core/src/trustedProxy.d.ts +0 -16
- package/types/core/src/types.d.ts +5 -0
- package/types/core/src/websocketBackplane.d.ts +1 -0
- package/types/core/src/wsdl.d.ts +8 -22
- package/types/frond/src/engine.d.ts +7 -1
- package/types/orm/src/adapters/firebird.d.ts +12 -0
- package/types/orm/src/adapters/mssql.d.ts +11 -0
- package/types/orm/src/adapters/mysql.d.ts +2 -0
- package/types/orm/src/adapters/postgres.d.ts +11 -0
- package/types/orm/src/adapters/sqlDialect.d.ts +25 -0
- package/types/orm/src/adapters/sqlite.d.ts +7 -0
- package/types/orm/src/baseModel.d.ts +5 -0
- package/types/orm/src/cachedDatabase.d.ts +27 -0
- package/types/orm/src/database.d.ts +46 -7
- package/types/orm/src/graph/graphUrl.d.ts +0 -8
- package/types/orm/src/index.d.ts +1 -1
- package/types/orm/src/query.d.ts +48 -2
- package/types/orm/src/realtime/storage.d.ts +2 -1
- package/types/orm/src/sqlTranslator.d.ts +70 -18
- package/types/orm/src/types.d.ts +6 -0
package/types/core/src/mqtt.d.ts
CHANGED
|
@@ -1,36 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Zero-dependency MQTT 3.1.1 client — the protocol every broker and every IoT
|
|
3
|
-
* device already speaks.
|
|
4
|
-
*
|
|
5
|
-
* Built on Node's `node:net` and `node:tls` stdlib modules only: no npm package,
|
|
6
|
-
* so an app that talks to Mosquitto / EMQX / HiveMQ / AWS IoT adds nothing to its
|
|
7
|
-
* dependency tree. Shaped like the Queue on purpose — publish / subscribe /
|
|
8
|
-
* consume:
|
|
9
|
-
*
|
|
10
|
-
* import { Mqtt } from "@tina4stack/tina4-node";
|
|
11
|
-
*
|
|
12
|
-
* const mqtt = new Mqtt({ url: "mqtt://broker:1883" }); // TINA4_MQTT_URL
|
|
13
|
-
* await mqtt.connect();
|
|
14
|
-
* await mqtt.publish("fleet/meter-42/telemetry", '{"kwh":12.5}', 1);
|
|
15
|
-
*
|
|
16
|
-
* for await (const message of mqtt.consume("fleet/+/telemetry", 1)) {
|
|
17
|
-
* if (message.isDuplicate()) continue; // QoS 1 is at-least-once
|
|
18
|
-
* store(message.topic, message.payload);
|
|
19
|
-
* }
|
|
20
|
-
*
|
|
21
|
-
* Environment: TINA4_MQTT_URL (default mqtt://127.0.0.1:1883),
|
|
22
|
-
* TINA4_MQTT_CLIENT_ID, TINA4_MQTT_KEEPALIVE (seconds, default 60),
|
|
23
|
-
* TINA4_MQTT_CA_FILE, TINA4_MQTT_TLS_VERIFY.
|
|
24
|
-
*
|
|
25
|
-
* Node has no synchronous blocking socket read, so connect()/publish()/
|
|
26
|
-
* subscribe()/receive() are async and consume() is an async generator — the same
|
|
27
|
-
* idiom as the Queue. No background task runs by default; opt in to the
|
|
28
|
-
* cooperative keepalive with startKeepalive(), which registers a background()
|
|
29
|
-
* task exactly like the queue consumers do.
|
|
30
|
-
*
|
|
31
|
-
* Single reader: like every MQTT client the socket has ONE network reader. Call
|
|
32
|
-
* receive()/consume() from one place.
|
|
33
|
-
*/
|
|
34
1
|
import { MqttMessage } from "./mqttMessage.js";
|
|
35
2
|
/** Any MQTT protocol / connection failure. */
|
|
36
3
|
export declare class MqttError extends Error {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Optional peer packages: the database drivers and service clients an
|
|
3
|
+
* APPLICATION installs, never the framework (ADR-0067).
|
|
4
|
+
*
|
|
5
|
+
* tina4-nodejs installs as exactly one package. `pg`, `mongodb`, `redis` and
|
|
6
|
+
* the `@aws-sdk` S3 client are optional peerDependencies, which npm does not
|
|
7
|
+
* install, so for most apps "missing" is the normal state. Every feature that
|
|
8
|
+
* reaches for one must therefore fail at the point of use with the exact
|
|
9
|
+
* command that fixes it - never a bare MODULE_NOT_FOUND, never a silent no-op.
|
|
10
|
+
*/
|
|
11
|
+
/** The actionable "install it" error, one wording for every optional peer. */
|
|
12
|
+
export declare function optionalPackageMissing(feature: string, packageNames: string[]): Error;
|
|
13
|
+
/**
|
|
14
|
+
* Resolve an optional peer from the FRAMEWORK's location and return its module
|
|
15
|
+
* URL, or throw the actionable error. Synchronous, so a constructor can refuse
|
|
16
|
+
* immediately (parity with the Python master, which raises ImportError in the
|
|
17
|
+
* constructor) instead of leaving a rejected promise for later.
|
|
18
|
+
*
|
|
19
|
+
* Resolving from here rather than from process.cwd() is what finds the peer an
|
|
20
|
+
* app installed, wherever the server was started from.
|
|
21
|
+
*
|
|
22
|
+
* @param installTogether packages the feature needs as a set (S3 needs the
|
|
23
|
+
* client AND the presigner), all named in the one install command.
|
|
24
|
+
*/
|
|
25
|
+
export declare function resolveOptionalPackage(packageName: string, feature: string, installTogether?: string[]): string;
|
package/types/core/src/plan.d.ts
CHANGED
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Project plan management — persistent, human-readable task state.
|
|
3
|
-
*
|
|
4
|
-
* Ported from tina4_python/dev_admin/plan.py (master reference).
|
|
5
|
-
* A plan is a markdown file under plan/ at the project root with sections
|
|
6
|
-
* for title, goal, steps (checkboxes), and notes. Exactly one plan is
|
|
7
|
-
* "current" at a time, recorded in plan/.current.
|
|
8
|
-
*
|
|
9
|
-
* Byte-for-byte compatible with Python's plan/*.md storage.
|
|
10
|
-
*/
|
|
11
1
|
export interface PlanStep {
|
|
12
2
|
text: string;
|
|
13
3
|
done: boolean;
|
|
@@ -1,13 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Project index — lightweight, persistent "where is what" map.
|
|
3
|
-
*
|
|
4
|
-
* Ported from tina4_python/dev_admin/project_index.py (master reference).
|
|
5
|
-
*
|
|
6
|
-
* Storage: .tina4/project_index.json at the project root.
|
|
7
|
-
* Freshness: lazy-refreshes on read via mtime compare — no watchers.
|
|
8
|
-
* Extractors: per-language symbol extraction (TS/JS, Twig/HTML, SQL, Markdown,
|
|
9
|
-
* Python) using regex. No LLM involvement — pure static analysis.
|
|
10
|
-
*/
|
|
11
1
|
export interface FileRoute {
|
|
12
2
|
method: string;
|
|
13
3
|
path: string;
|
|
@@ -42,6 +42,8 @@ export declare class MongoBackend implements QueueBackend {
|
|
|
42
42
|
private collection;
|
|
43
43
|
private visibilityTimeout;
|
|
44
44
|
private maxRetries;
|
|
45
|
+
/** Module URL of the app-installed `mongodb` driver, resolved once. */
|
|
46
|
+
private driverUrl;
|
|
45
47
|
constructor(config?: MongoConfig);
|
|
46
48
|
/**
|
|
47
49
|
* Resolved connection config — exposed for testing/introspection.
|
|
@@ -11,6 +11,18 @@ import type { Tina4Request, UploadedFile } from "./types.js";
|
|
|
11
11
|
*/
|
|
12
12
|
export declare function makeCaseInsensitiveHeaders(raw: IncomingHttpHeaders): IncomingHttpHeaders;
|
|
13
13
|
export declare function createRequest(req: IncomingMessage): Tina4Request;
|
|
14
|
+
export declare const DEFAULT_MAX_UPLOAD_SIZE = 10485760;
|
|
15
|
+
/**
|
|
16
|
+
* Read a numeric limit from the environment. A value that is not a usable
|
|
17
|
+
* number falls back to the default with a warning naming the variable (the
|
|
18
|
+
* same rule as PHP's Server::resolveLimit) - a typo must never be what
|
|
19
|
+
* disables a DoS guard.
|
|
20
|
+
*/
|
|
21
|
+
export declare function resolveLimit(name: string, fallback: number, zeroAllowed?: boolean): number;
|
|
22
|
+
/** TINA4_MAX_UPLOAD_SIZE, read when it is needed so a value from .env counts. */
|
|
23
|
+
export declare function maxUploadSize(): number;
|
|
24
|
+
/** The one 413 wording (ADR-0068 section 4). */
|
|
25
|
+
export declare function bodyTooLargeMessage(bytes: number | bigint | string, limit: number): string;
|
|
14
26
|
export declare class PayloadTooLargeError extends Error {
|
|
15
27
|
statusCode: number;
|
|
16
28
|
constructor(actual: number, limit: number);
|
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
import type { ServerResponse } from "node:http";
|
|
2
2
|
import type { Tina4Response } from "./types.js";
|
|
3
|
+
/**
|
|
4
|
+
* The caller's name as a JSON string literal with non-ASCII escaped, byte-
|
|
5
|
+
* identical to Python's json.dumps (ADR-0068), so a name that is itself broken
|
|
6
|
+
* cannot break the error message or the log line carrying it.
|
|
7
|
+
*/
|
|
8
|
+
export declare function quoteHeaderName(name: string): string;
|
|
9
|
+
/**
|
|
10
|
+
* Refuse a response header whose name is not an HTTP token or whose value
|
|
11
|
+
* carries CR, LF or NUL, with the exact ADR-0068 wording. node:http refuses
|
|
12
|
+
* these too, but names a broken header raw (a CR/LF in the name reaches the
|
|
13
|
+
* log line) - this is the ADR's form, checked first.
|
|
14
|
+
*/
|
|
15
|
+
export declare function assertSafeHeader(name: string, value: unknown): void;
|
|
3
16
|
/**
|
|
4
17
|
* Set the default templates directory for render().
|
|
5
18
|
* Called by server.ts during startup.
|
|
@@ -88,6 +88,25 @@ export declare function _checkLegacyEnvVars(): void;
|
|
|
88
88
|
* of killing an innocent process.
|
|
89
89
|
*/
|
|
90
90
|
export declare function killPort(port: number): void;
|
|
91
|
+
/**
|
|
92
|
+
* Variables that mark a CI run, in ADR-0070's order (ci_env_vars). A run is CI
|
|
93
|
+
* when any of them holds a value that, trimmed and lower-cased, is non-empty
|
|
94
|
+
* and not in CI_NOT_SET_VALUES.
|
|
95
|
+
*/
|
|
96
|
+
export declare const CI_ENVIRONMENT_VARIABLES: string[];
|
|
97
|
+
/** Values that say "not under CI" (ADR-0070 ci_not_set_values), compared trimmed and lower-cased. */
|
|
98
|
+
export declare const CI_NOT_SET_VALUES: string[];
|
|
99
|
+
/**
|
|
100
|
+
* Whether the server may open a browser (ADR-0070): only for a developer at a
|
|
101
|
+
* desk. Every rule is a veto; nothing forces a browser open past one.
|
|
102
|
+
*
|
|
103
|
+
* 1. development only - the caller's resolved debug mode, and never with
|
|
104
|
+
* TINA4_PRODUCTION truthy or in a cluster worker (the primary decides);
|
|
105
|
+
* 2. never when TINA4_NO_BROWSER is truthy (true/1/yes/on);
|
|
106
|
+
* 3. never with --no-browser / a programmatic noBrowser (it can only veto);
|
|
107
|
+
* 4. never under CI.
|
|
108
|
+
*/
|
|
109
|
+
export declare function shouldOpenBrowser(isDevelopment: boolean, noBrowser?: boolean): boolean;
|
|
91
110
|
/**
|
|
92
111
|
* Resolve port and host with priority: explicit config > ENV var > default.
|
|
93
112
|
* Exported for testability.
|
|
@@ -1,18 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tina4 session handlers — turn a failed `execFileSync` child into a readable cause.
|
|
3
|
-
*
|
|
4
|
-
* The session-handler interface is synchronous but every backend client is async,
|
|
5
|
-
* so each command runs in a short-lived `node -e` child. When that child fails,
|
|
6
|
-
* `execFileSync` throws an error whose `.message` begins "Command failed:" and
|
|
7
|
-
* then embeds THE ENTIRE GENERATED SCRIPT — kilobytes of source with the real
|
|
8
|
-
* reason nowhere in it. Every handler used to throw exactly that, so an
|
|
9
|
-
* operator debugging a Redis outage got a wall of JavaScript instead of
|
|
10
|
-
* "connect ECONNREFUSED 127.0.0.1:6379".
|
|
11
|
-
*
|
|
12
|
-
* The children already write the real reason to stderr; `execFileSync` captures
|
|
13
|
-
* it on `err.stderr`. This module is the ONE place that prefers it, so the three
|
|
14
|
-
* call sites (respClient, mongoClient, redisHandler's npm path) cannot drift.
|
|
15
|
-
*/
|
|
16
1
|
/**
|
|
17
2
|
* Extract the most useful one-line cause from a thrown `execFileSync` error.
|
|
18
3
|
*
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { IncomingMessage, ServerResponse, Server } from "node:http";
|
|
2
|
+
/**
|
|
3
|
+
* Answer through a ServerResponse with the rejection shape and close. Every
|
|
4
|
+
* header already on the response is dropped: the shape is exact. Node closes
|
|
5
|
+
* the connection once the answer is flushed (Connection: close), so the rest
|
|
6
|
+
* of a refused upload is never read.
|
|
7
|
+
*/
|
|
8
|
+
export declare function sendTransportRejection(res: ServerResponse, status: number, message: string, end?: {
|
|
9
|
+
(cb?: () => void): ServerResponse<IncomingMessage>;
|
|
10
|
+
(chunk: any, cb?: () => void): ServerResponse<IncomingMessage>;
|
|
11
|
+
(chunk: any, encoding: BufferEncoding, cb?: () => void): ServerResponse<IncomingMessage>;
|
|
12
|
+
}): void;
|
|
13
|
+
/**
|
|
14
|
+
* ADR-0068 section 2 for Node. node:http refuses an unsafe header where it is
|
|
15
|
+
* set (setHeader / appendHeader / writeHead). A header set straight on the raw
|
|
16
|
+
* response - past Tina4's own call-site check - used to surface as a route
|
|
17
|
+
* error page. Here the refusal is recorded instead, and whatever the handler
|
|
18
|
+
* sends next becomes the fixture's 500 {"error":"Invalid response header"},
|
|
19
|
+
* logged by header name. Tina4's own Response keeps refusing at the call site
|
|
20
|
+
* (its check runs before this layer is reached).
|
|
21
|
+
*/
|
|
22
|
+
export declare function guardUnsafeHeaders(res: ServerResponse): void;
|
|
23
|
+
/**
|
|
24
|
+
* Create the HTTP server Tina4 listens with - the main port, its loopback
|
|
25
|
+
* siblings, the AI port and every cluster worker - so every one of them keeps
|
|
26
|
+
* the same limits and answers.
|
|
27
|
+
*/
|
|
28
|
+
export declare function createTina4HttpServer(handler: (req: IncomingMessage, res: ServerResponse) => unknown): Server;
|
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Which upstream hops are allowed to speak for a client (ADR-0019).
|
|
3
|
-
*
|
|
4
|
-
* X-Forwarded-For is written by whoever sends it. Reading it unconditionally
|
|
5
|
-
* lets any client choose its own rate-limit bucket, and - worse - choose
|
|
6
|
-
* SOMEONE ELSE'S, which is a starvation primitive against a third party. So
|
|
7
|
-
* the forwarding headers are believed only when the raw socket peer is a proxy
|
|
8
|
-
* the operator has explicitly declared.
|
|
9
|
-
*
|
|
10
|
-
* Configured by TINA4_TRUSTED_PROXIES: comma-separated exact addresses and/or
|
|
11
|
-
* CIDR ranges, IPv4 and IPv6, e.g. "10.0.0.0/8, 192.168.1.5, ::1, fd00::/8".
|
|
12
|
-
* Empty or unset means trust NOTHING, which is the secure default.
|
|
13
|
-
*
|
|
14
|
-
* Zero-dependency: node: has no CIDR matcher, so the packing and prefix
|
|
15
|
-
* comparison are done here over plain byte arrays.
|
|
16
|
-
*/
|
|
17
1
|
/** [packed network address, prefix bits] */
|
|
18
2
|
type Network = [Uint8Array, number];
|
|
19
3
|
/**
|
|
@@ -198,6 +198,11 @@ export interface Tina4Config {
|
|
|
198
198
|
* and staticDir are resolved relative to this path instead of process.cwd(). */
|
|
199
199
|
basePath?: string;
|
|
200
200
|
routesDir?: string;
|
|
201
|
+
/**
|
|
202
|
+
* Never open a browser on start (ADR-0070 rule 3, the programmatic
|
|
203
|
+
* --no-browser). It can only veto: false does not force one open.
|
|
204
|
+
*/
|
|
205
|
+
noBrowser?: boolean;
|
|
201
206
|
modelsDir?: string;
|
|
202
207
|
templatesDir?: string;
|
|
203
208
|
staticDir?: string;
|
|
@@ -47,6 +47,7 @@ export declare class NATSBackplane implements WebSocketBackplane {
|
|
|
47
47
|
private url;
|
|
48
48
|
private subs;
|
|
49
49
|
private ready;
|
|
50
|
+
private natsModuleUrl;
|
|
50
51
|
constructor(url?: string);
|
|
51
52
|
publish(channel: string, message: string): Promise<void>;
|
|
52
53
|
subscribe(channel: string, callback: (message: string) => void): Promise<void>;
|
package/types/core/src/wsdl.d.ts
CHANGED
|
@@ -1,23 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Tina4 WSDL/SOAP — SOAP 1.1 / WSDL 1.1 service base class.
|
|
3
|
-
*
|
|
4
|
-
* Auto-generates WSDL definitions and handles SOAP XML requests.
|
|
5
|
-
* Zero external dependencies — uses simple string parsing for XML.
|
|
6
|
-
*
|
|
7
|
-
* Matches the PHP reference implementation (Tina4\WSDL).
|
|
8
|
-
*
|
|
9
|
-
* import { WSDLService, WSDLOperation } from "@tina4/core";
|
|
10
|
-
*
|
|
11
|
-
* class Calculator extends WSDLService {
|
|
12
|
-
* serviceName = "Calculator";
|
|
13
|
-
* serviceUrl = "/api/calculator";
|
|
14
|
-
*
|
|
15
|
-
* @WSDLOperation({ output: { Result: "int" } })
|
|
16
|
-
* async Add(a: number, b: number): Promise<Record<string, unknown>> {
|
|
17
|
-
* return { Result: a + b };
|
|
18
|
-
* }
|
|
19
|
-
* }
|
|
20
|
-
*/
|
|
21
1
|
export interface WSDLOperationMeta {
|
|
22
2
|
name: string;
|
|
23
3
|
description?: string;
|
|
@@ -34,8 +14,14 @@ interface WSDLOperationConfig {
|
|
|
34
14
|
*
|
|
35
15
|
* @WSDLOperation({ description: "Add two numbers", input: { a: "int", b: "int" }, output: { Result: "int" } })
|
|
36
16
|
* async Add(a: number, b: number): Promise<Record<string, unknown>> { ... }
|
|
17
|
+
*
|
|
18
|
+
* Works under both decorator flavours: TC39 standard decorators (what tsx and
|
|
19
|
+
* esbuild compile by default: `(method, context)`) and TypeScript's
|
|
20
|
+
* experimentalDecorators (`(prototype, name, descriptor)`).
|
|
37
21
|
*/
|
|
38
|
-
export declare function WSDLOperation(config?: WSDLOperationConfig): (
|
|
22
|
+
export declare function WSDLOperation(config?: WSDLOperationConfig): (target: unknown, context: string | symbol | {
|
|
23
|
+
name: string | symbol;
|
|
24
|
+
}, descriptor?: PropertyDescriptor) => PropertyDescriptor | undefined;
|
|
39
25
|
export declare abstract class WSDLService {
|
|
40
26
|
abstract serviceName: string;
|
|
41
27
|
abstract serviceUrl: string;
|
|
@@ -72,7 +58,7 @@ export declare abstract class WSDLService {
|
|
|
72
58
|
/**
|
|
73
59
|
* Handle incoming SOAP request (parse XML, dispatch to method, return SOAP response).
|
|
74
60
|
*/
|
|
75
|
-
handle(soapXml?: string): Promise<string>;
|
|
61
|
+
handle(soapXml?: string | Uint8Array): Promise<string>;
|
|
76
62
|
/**
|
|
77
63
|
* Register this service's routes on a router.
|
|
78
64
|
* GET /service-url?wsdl -> WSDL XML
|
|
@@ -241,7 +241,13 @@ export declare class Frond {
|
|
|
241
241
|
*/
|
|
242
242
|
private applyFastFilter;
|
|
243
243
|
private applyRenderedFilter;
|
|
244
|
-
|
|
244
|
+
/**
|
|
245
|
+
* Sandbox gate for a WHOLE expression (F6/ADR-0077): refuse a dunder walk or
|
|
246
|
+
* a root variable outside the allow-list. Applied to output, if conditions,
|
|
247
|
+
* set right-hand sides and for iterables so none can smuggle a blocked
|
|
248
|
+
* variable past the per-output gate.
|
|
249
|
+
*/
|
|
250
|
+
private sandboxExprOk;
|
|
245
251
|
private resolveConcatenation;
|
|
246
252
|
private applyRenderedFilters;
|
|
247
253
|
private evalVarInner;
|
|
@@ -98,6 +98,12 @@ export declare class FirebirdAdapter implements DatabaseAdapter {
|
|
|
98
98
|
/** Connect to Firebird. Must be called before using the adapter. */
|
|
99
99
|
/** ADR-0044 required adapter capability. */
|
|
100
100
|
getDatabaseType(): string;
|
|
101
|
+
/**
|
|
102
|
+
* Quote a name the ORM emits the way Firebird stores it: UPPER CASE (see
|
|
103
|
+
* fbQuote). An already-quoted name passes through - the escape hatch for a
|
|
104
|
+
* genuinely case-sensitive table. Python master: FirebirdAdapter.quote_identifier.
|
|
105
|
+
*/
|
|
106
|
+
quoteIdentifier(name: string): string;
|
|
101
107
|
/** ADR-0044: readable/writable native boolean. */
|
|
102
108
|
autocommit: boolean;
|
|
103
109
|
/**
|
|
@@ -186,6 +192,12 @@ export declare class FirebirdAdapter implements DatabaseAdapter {
|
|
|
186
192
|
lastId?: number | bigint;
|
|
187
193
|
}>;
|
|
188
194
|
executeAsync(sql: string, params?: unknown[]): Promise<unknown>;
|
|
195
|
+
/**
|
|
196
|
+
* Run a row-producing statement ONCE and return its rows, for
|
|
197
|
+
* Database.execute(). node-firebird's execute() returns no rows, so a SELECT
|
|
198
|
+
* or an `INSERT ... RETURNING` through execute() used to lose them.
|
|
199
|
+
*/
|
|
200
|
+
executeRowsAsync<T = Record<string, unknown>>(sql: string, params?: unknown[]): Promise<T[]>;
|
|
189
201
|
query<T = Record<string, unknown>>(sql: string, params?: unknown[]): T[];
|
|
190
202
|
queryAsync<T = Record<string, unknown>>(sql: string, params?: unknown[]): Promise<T[]>;
|
|
191
203
|
/**
|
|
@@ -45,8 +45,19 @@ export declare class MssqlAdapter implements DatabaseAdapter {
|
|
|
45
45
|
* `startAt` lets a caller that has already consumed N placeholders (an UPDATE
|
|
46
46
|
* whose SET values are @p0..@p{N-1}) continue the numbering into a raw WHERE
|
|
47
47
|
* fragment instead of restarting at @p0.
|
|
48
|
+
*
|
|
49
|
+
* Only REAL placeholders are rewritten: a `?` inside a string literal, a
|
|
50
|
+
* quoted identifier or a comment is left alone (tina4-python#138).
|
|
48
51
|
*/
|
|
49
52
|
private convertPlaceholders;
|
|
53
|
+
/**
|
|
54
|
+
* The SQL the driver receives. With NO parameters it is sent EXACTLY as
|
|
55
|
+
* written (the cross-framework contract): there is nothing to bind.
|
|
56
|
+
*
|
|
57
|
+
* tina4: with parameters every `?` outside a literal, quoted identifier or
|
|
58
|
+
* comment is a placeholder.
|
|
59
|
+
*/
|
|
60
|
+
private bindable;
|
|
50
61
|
execute(sql: string, params?: unknown[]): unknown;
|
|
51
62
|
executeMany(sql: string, paramsList: unknown[][]): {
|
|
52
63
|
totalAffected: number;
|
|
@@ -23,6 +23,8 @@ export declare class MysqlAdapter implements DatabaseAdapter {
|
|
|
23
23
|
/** Connect to MySQL. Must be called before using the adapter. */
|
|
24
24
|
/** ADR-0044 required adapter capability. */
|
|
25
25
|
getDatabaseType(): string;
|
|
26
|
+
/** MySQL identifiers are backtick-quoted; a double-quoted token is a string. */
|
|
27
|
+
quoteIdentifier(name: string): string;
|
|
26
28
|
/** ADR-0044: readable/writable native boolean. */
|
|
27
29
|
autocommit: boolean;
|
|
28
30
|
/**
|
|
@@ -38,6 +38,17 @@ export declare class PostgresAdapter implements DatabaseAdapter {
|
|
|
38
38
|
/** Ensure bytea columns are Buffer (already the case with pg). No-op guard. */
|
|
39
39
|
private decodeBlobs;
|
|
40
40
|
private convertPlaceholders;
|
|
41
|
+
/**
|
|
42
|
+
* The SQL the driver receives. With NO parameters it is sent EXACTLY as
|
|
43
|
+
* written (the cross-framework contract): there is nothing to bind, and the
|
|
44
|
+
* rewrite would turn PostgreSQL's jsonb operators `?`, `?|` and `?&` into
|
|
45
|
+
* unbound markers.
|
|
46
|
+
*
|
|
47
|
+
* tina4: with parameters every `?` outside a literal, quoted identifier or
|
|
48
|
+
* comment is a placeholder - use jsonb_exists(), jsonb_exists_any() or
|
|
49
|
+
* jsonb_exists_all() instead of the `?`, `?|` or `?&` operators.
|
|
50
|
+
*/
|
|
51
|
+
private bindable;
|
|
41
52
|
/**
|
|
42
53
|
* Normalise an `id` column value (typed `unknown` because pg row values are
|
|
43
54
|
* `unknown`) into the shape `_lastInsertId` / `DatabaseResult.lastId`
|
|
@@ -29,6 +29,21 @@ export interface Dialect {
|
|
|
29
29
|
*/
|
|
30
30
|
marker(index: number): string;
|
|
31
31
|
}
|
|
32
|
+
/**
|
|
33
|
+
* Quote a table/column name the ORM emits, in one engine's identifier quotes.
|
|
34
|
+
*
|
|
35
|
+
* Port of the Python master's `quote_identifier` (adapter.py; Firebird's
|
|
36
|
+
* override upper-cases): idempotent (an already-quoted name is returned
|
|
37
|
+
* unchanged), dot-aware (`schema.table` quotes each part), and a non-identifier
|
|
38
|
+
* (`*`, `COUNT(*)`, an expression) is passed through untouched. An embedded
|
|
39
|
+
* closing quote is doubled.
|
|
40
|
+
*
|
|
41
|
+
* `upperCase` is Firebird's rule: an unquoted identifier is stored UPPER CASE,
|
|
42
|
+
* so a lower-case name must be quoted upper-case to match it.
|
|
43
|
+
*/
|
|
44
|
+
export declare function quoteIdentifierWith(name: string, open: string, close: string, upperCase?: boolean): string;
|
|
45
|
+
/** The ANSI default: `"name"` (SQLite, PostgreSQL, MSSQL, ODBC). */
|
|
46
|
+
export declare function quoteIdentifierAnsi(name: string): string;
|
|
32
47
|
/** SQLite, and ODBC which follows the SQL standard spelling. */
|
|
33
48
|
export declare const ANSI_DIALECT: Dialect;
|
|
34
49
|
/** PostgreSQL: standard quoting, positional $N markers. */
|
|
@@ -43,6 +58,16 @@ export declare const MSSQL_DIALECT: Dialect;
|
|
|
43
58
|
* adapter owns that rule and passes its own quoter in.
|
|
44
59
|
*/
|
|
45
60
|
export declare function firebirdDialect(fbQuote: (name: string) => string): Dialect;
|
|
61
|
+
/**
|
|
62
|
+
* Refuse a data or filter-map key that is not a plain identifier.
|
|
63
|
+
*
|
|
64
|
+
* tina4: ADR-0069 (G3) - the write helpers emit these keys as column names, and
|
|
65
|
+
* the dialect quoters do not escape, so a key must be a plain identifier
|
|
66
|
+
* (letters, digits, underscore, dollar; not starting with a digit) before any
|
|
67
|
+
* SQL is built. Valid names are emitted exactly as before. Table names are
|
|
68
|
+
* developer code and are not checked here.
|
|
69
|
+
*/
|
|
70
|
+
export declare function assertColumnNames(keys: Iterable<string>): void;
|
|
46
71
|
/**
|
|
47
72
|
* `INSERT INTO <table> (<cols>) VALUES (<markers>)`.
|
|
48
73
|
*
|
|
@@ -36,6 +36,13 @@ export declare class SQLiteAdapter implements DatabaseAdapter {
|
|
|
36
36
|
execute(sql: string, params?: unknown[]): unknown;
|
|
37
37
|
executeMany(sql: string, paramsList: unknown[][]): DatabaseResult;
|
|
38
38
|
query<T = Record<string, unknown>>(sql: string, params?: unknown[]): T[];
|
|
39
|
+
/**
|
|
40
|
+
* Run a row-producing statement ONCE and return its rows, for
|
|
41
|
+
* Database.execute(). execute()'s run() discards rows, so a SELECT or an
|
|
42
|
+
* `INSERT ... RETURNING` through execute() used to lose them. A write still
|
|
43
|
+
* records its last insert id, exactly as execute() does.
|
|
44
|
+
*/
|
|
45
|
+
executeRows<T = Record<string, unknown>>(sql: string, params?: unknown[]): T[];
|
|
39
46
|
fetch<T = Record<string, unknown>>(sql: string, params?: unknown[], limit?: number, skip?: number): T[];
|
|
40
47
|
fetchOne<T = Record<string, unknown>>(sql: string, params?: unknown[]): T | null;
|
|
41
48
|
insert(table: string, data: Record<string, unknown> | Record<string, unknown>[]): DatabaseResult;
|
|
@@ -112,6 +112,11 @@ export declare class BaseModel {
|
|
|
112
112
|
* SQLite URLs are initialised synchronously. Other engines require initDatabase()
|
|
113
113
|
* to be called before first use.
|
|
114
114
|
*/
|
|
115
|
+
/**
|
|
116
|
+
* Quote a table/column name in the dialect of the adapter this model runs on
|
|
117
|
+
* (MySQL backticks, Firebird upper-cased, `"name"` elsewhere).
|
|
118
|
+
*/
|
|
119
|
+
protected static quoteName(name: string): string;
|
|
115
120
|
protected static getDb(): DatabaseAdapter;
|
|
116
121
|
/**
|
|
117
122
|
* Get the primary key field name (JS property name).
|
|
@@ -144,10 +144,31 @@ export declare class CachedDatabaseAdapter implements DatabaseAdapter {
|
|
|
144
144
|
private backendSetRows;
|
|
145
145
|
private backendGetOne;
|
|
146
146
|
private backendSetOne;
|
|
147
|
+
/**
|
|
148
|
+
* A write that arrives through a READ method (fetch/fetchOne/query of an
|
|
149
|
+
* `INSERT ... RETURNING`) is still a write: its result must never be cached
|
|
150
|
+
* (a repeat would answer from the cache and never insert) and it flushes the
|
|
151
|
+
* cache like every other write (tina4-python#133 contract).
|
|
152
|
+
*/
|
|
153
|
+
private isWriteRead;
|
|
154
|
+
/** Run a write that came through a read method, then flush (never store). */
|
|
155
|
+
private runWrite;
|
|
156
|
+
private runWriteAsync;
|
|
147
157
|
/** ADR-0044 required capability — delegates to the wrapped adapter. */
|
|
148
158
|
connect(): void | Promise<void>;
|
|
159
|
+
/**
|
|
160
|
+
* The derived-table alias the COUNT probe needs, forwarded from the wrapped
|
|
161
|
+
* adapter. SQL Server and MySQL REQUIRE `FROM (<sql>) AS _count_query`; the
|
|
162
|
+
* probe reads this property off whatever adapter it is handed, and
|
|
163
|
+
* Database.create() hands it THIS wrapper. Without the forward the probe ran
|
|
164
|
+
* unaliased, the engine rejected it, the error was swallowed, and
|
|
165
|
+
* `result.count` silently became the page length on those two engines.
|
|
166
|
+
*/
|
|
167
|
+
get countSubqueryAlias(): string | undefined;
|
|
149
168
|
/** ADR-0044 required capability — delegates to the wrapped adapter. */
|
|
150
169
|
getDatabaseType(): string;
|
|
170
|
+
/** Identifier quoting is the wrapped engine's, never the wrapper's. */
|
|
171
|
+
quoteIdentifier(name: string): string;
|
|
151
172
|
/**
|
|
152
173
|
* ADR-0044 required capability — a native boolean, readable and writable.
|
|
153
174
|
* A getter/setter pair (not a plain field) so it genuinely delegates to the
|
|
@@ -158,6 +179,12 @@ export declare class CachedDatabaseAdapter implements DatabaseAdapter {
|
|
|
158
179
|
get supportsAtomicBatch(): boolean;
|
|
159
180
|
set supportsAtomicBatch(value: boolean);
|
|
160
181
|
execute(sql: string, params?: unknown[]): unknown;
|
|
182
|
+
/**
|
|
183
|
+
* Forward an adapter's row-returning execute (SQLite, Firebird), for
|
|
184
|
+
* Database.execute(). Resolves `undefined` when the wrapped adapter has none
|
|
185
|
+
* - WITHOUT running anything - so the caller falls back to execute().
|
|
186
|
+
*/
|
|
187
|
+
executeRowsAsync(sql: string, params?: unknown[]): Promise<unknown[] | undefined>;
|
|
161
188
|
executeMany(sql: string, paramsList: unknown[][]): import("./types.js").DatabaseResult | {
|
|
162
189
|
totalAffected: number;
|
|
163
190
|
lastId?: number | bigint;
|
|
@@ -28,8 +28,27 @@ export declare function stripTrailingSemicolons(sql: string): string;
|
|
|
28
28
|
* the single chokepoint every public read/write flows through.
|
|
29
29
|
*/
|
|
30
30
|
export declare function adapterFetch<T = Record<string, unknown>>(adapter: DatabaseAdapter, sql: string, params?: unknown[], limit?: number, skip?: number, noCache?: boolean): Promise<T[]>;
|
|
31
|
+
/**
|
|
32
|
+
* Quote a table/column name the ORM emits, in the bound adapter's dialect
|
|
33
|
+
* (MySQL backticks, Firebird upper-cased, `"name"` elsewhere). Python master:
|
|
34
|
+
* `Database.quote_identifier`. Only for framework-emitted identifiers - a
|
|
35
|
+
* user's raw SQL is never rewritten.
|
|
36
|
+
*/
|
|
37
|
+
export declare function quoteIdentifier(adapter: DatabaseAdapter | null | undefined, name: string): string;
|
|
31
38
|
export declare function adapterQuery<T = Record<string, unknown>>(adapter: DatabaseAdapter, sql: string, params?: unknown[]): Promise<T[]>;
|
|
32
39
|
export declare function adapterFetchOne<T = Record<string, unknown>>(adapter: DatabaseAdapter, sql: string, params?: unknown[]): Promise<T | null>;
|
|
40
|
+
/**
|
|
41
|
+
* Run a row-producing statement through an adapter's own row-returning execute
|
|
42
|
+
* (SQLite's executeRows, Firebird's executeRowsAsync, or the cache wrapper
|
|
43
|
+
* forwarding either). `undefined` means the adapter has none and NOTHING ran.
|
|
44
|
+
*/
|
|
45
|
+
export declare function adapterExecuteRows(adapter: DatabaseAdapter, sql: string, params?: unknown[]): Promise<unknown[] | undefined>;
|
|
46
|
+
/**
|
|
47
|
+
* The rows inside a driver's execute() result: pg and tedious carry `.rows`,
|
|
48
|
+
* mysql2 and odbc return the row array itself, and a MySQL CALL returns
|
|
49
|
+
* `[[rows], OkPacket]`. `undefined` when the result carries no row list.
|
|
50
|
+
*/
|
|
51
|
+
export declare function rowsFromExecuteResult(result: unknown): unknown[] | undefined;
|
|
33
52
|
export declare function adapterExecute(adapter: DatabaseAdapter, sql: string, params?: unknown[]): Promise<unknown>;
|
|
34
53
|
/**
|
|
35
54
|
* ADR-0044: the adapter-level batch primitive, called exactly once by
|
|
@@ -277,6 +296,11 @@ export declare class Database {
|
|
|
277
296
|
* the same Database don't clobber each other. startTransaction() sets the
|
|
278
297
|
* pin via .enterWith(); commit()/rollback() clear it.
|
|
279
298
|
*/
|
|
299
|
+
private leases;
|
|
300
|
+
private discardedSlots;
|
|
301
|
+
private repairs;
|
|
302
|
+
private leaseOwner;
|
|
303
|
+
private operationStore;
|
|
280
304
|
private txStore;
|
|
281
305
|
/**
|
|
282
306
|
* Create a Database wrapping an existing adapter.
|
|
@@ -317,8 +341,13 @@ export declare class Database {
|
|
|
317
341
|
* that adapter is returned for every call so the whole transaction is
|
|
318
342
|
* atomic on one connection. Otherwise pooled mode round-robins.
|
|
319
343
|
*/
|
|
344
|
+
private availableAdapter;
|
|
345
|
+
private reserveAdapter;
|
|
346
|
+
private releaseAdapter;
|
|
347
|
+
private repairDiscardedConnections;
|
|
348
|
+
private withConnectionOperation;
|
|
320
349
|
private getNextAdapter;
|
|
321
|
-
/**
|
|
350
|
+
/** Non-owning peek excluding leased connections. Use checkout/checkin for concurrent raw driver work. */
|
|
322
351
|
getAdapter(): DatabaseAdapter;
|
|
323
352
|
/** Get the pool size (0 = single connection mode). */
|
|
324
353
|
poolSize(): number;
|
|
@@ -331,12 +360,8 @@ export declare class Database {
|
|
|
331
360
|
* The caller is responsible for returning it via checkin().
|
|
332
361
|
*/
|
|
333
362
|
checkout(): DatabaseAdapter;
|
|
334
|
-
/**
|
|
335
|
-
|
|
336
|
-
* For round-robin pools this is a no-op (connections stay in the pool array),
|
|
337
|
-
* but the method exists for API parity and future pooling strategies.
|
|
338
|
-
*/
|
|
339
|
-
checkin(_adapter: DatabaseAdapter): void;
|
|
363
|
+
/** Only the borrowing async context can release an explicit lease. */
|
|
364
|
+
checkin(adapter: DatabaseAdapter): void;
|
|
340
365
|
/**
|
|
341
366
|
* Close all pooled connections and clear the pool.
|
|
342
367
|
* Equivalent to close() but named for explicit pool teardown.
|
|
@@ -405,6 +430,12 @@ export declare class Database {
|
|
|
405
430
|
fetchAll<T = Record<string, unknown>>(sql: string, params?: unknown[], limit?: number, offset?: number, opts?: {
|
|
406
431
|
noCache?: boolean;
|
|
407
432
|
}): Promise<T[]>;
|
|
433
|
+
/**
|
|
434
|
+
* Close a write that ran through fetch()/fetchOne() the way execute() closes
|
|
435
|
+
* its own: auto-commit outside an explicit transaction, and leave it to the
|
|
436
|
+
* caller's commit()/rollback() inside one.
|
|
437
|
+
*/
|
|
438
|
+
private commitFetchWrite;
|
|
408
439
|
/**
|
|
409
440
|
* Execute a write statement.
|
|
410
441
|
*
|
|
@@ -459,6 +490,14 @@ export declare class Database {
|
|
|
459
490
|
* throws rather than silently changing nothing (audit feature 4, P1).
|
|
460
491
|
*/
|
|
461
492
|
update(table: string, data: Record<string, unknown>, filter?: Record<string, unknown> | string, params?: unknown[]): Promise<DatabaseWriteResult>;
|
|
493
|
+
/**
|
|
494
|
+
* ADR-0069 (G3): a data or filter-map key must be a plain identifier - it is
|
|
495
|
+
* emitted as a column name. Checked here, before any adapter work, so every
|
|
496
|
+
* engine raises the same error; the SQL builders (sqlDialect) check again for
|
|
497
|
+
* callers that use an adapter directly. MongoDB builds no SQL and its keys are
|
|
498
|
+
* document paths, so it is left alone.
|
|
499
|
+
*/
|
|
500
|
+
private assertWriteKeys;
|
|
462
501
|
/** Delete rows. A filterless delete throws; use truncate() to empty a table. */
|
|
463
502
|
delete(table: string, filter?: Record<string, unknown> | string | Record<string, unknown>[], params?: unknown[]): Promise<DatabaseWriteResult>;
|
|
464
503
|
/** Remove every row. The explicit spelling of a whole-table delete. */
|
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Graph connection URL parser — the DatabaseUrl sibling for graph engines.
|
|
3
|
-
*
|
|
4
|
-
* Parse a graph connection URL into its parts, the same way DatabaseUrl does for
|
|
5
|
-
* SQL. `engine` is the CANONICAL name the factory selects an adapter by; a scheme
|
|
6
|
-
* alias (bolt/neo4j/memgraph all speak Bolt/Cypher and share ONE adapter) resolves
|
|
7
|
-
* to its engine here. See tina4-documentation/plan/v3/features/139-graph-databases.md.
|
|
8
|
-
*/
|
|
9
1
|
/** The canonical graph engine names. */
|
|
10
2
|
export type GraphEngine = "ultipa" | "bolt" | "arango";
|
|
11
3
|
/** A parsed graph URL: engine, host, port, graph, credentials, params. */
|
package/types/orm/src/index.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export { syncModels, ensureMigrationTable, getNextBatch, isMigrationApplied, rec
|
|
|
15
15
|
export type { MigrationResult, MigrationStatus } from "./migration.js";
|
|
16
16
|
export { AutoCrud, generateCrudRoutes, crudEligibleModels } from "./autoCrud.js";
|
|
17
17
|
export type { AutoCrudOptions } from "./autoCrud.js";
|
|
18
|
-
export { buildQuery, parseQueryString } from "./query.js";
|
|
18
|
+
export { buildQuery, parseQueryString, UnknownFieldError, InvalidQueryParameterError } from "./query.js";
|
|
19
19
|
export { validate } from "./validation.js";
|
|
20
20
|
export type { ValidationError } from "./validation.js";
|
|
21
21
|
export { BaseModel, snakeToCamel, camelToSnake } from "./baseModel.js";
|