ts-prorm-orm 1.1.0
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/CHANGELOG.md +1111 -0
- package/LICENSE +21 -0
- package/README.md +573 -0
- package/dist/audit/history-query.js +180 -0
- package/dist/audit/index.js +23 -0
- package/dist/audit/logger.js +236 -0
- package/dist/cache/cache-manager.js +84 -0
- package/dist/cache/index.js +16 -0
- package/dist/cache/redis-cluster-cache.js +557 -0
- package/dist/cli.js +2200 -0
- package/dist/compliance/audit-trail.js +68 -0
- package/dist/compliance/backup-verification.js +685 -0
- package/dist/compliance/breach-detector.js +505 -0
- package/dist/compliance/consent-record.js +227 -0
- package/dist/compliance/consent-versioning.js +331 -0
- package/dist/compliance/cross-border-log.js +530 -0
- package/dist/compliance/data-classifier.js +258 -0
- package/dist/compliance/data-lineage.js +565 -0
- package/dist/compliance/data-masker.js +303 -0
- package/dist/compliance/data-portability.js +265 -0
- package/dist/compliance/data-retention.js +195 -0
- package/dist/compliance/dsar-workflow.js +342 -0
- package/dist/compliance/field-encryption.js +223 -0
- package/dist/compliance/immutable-record.js +148 -0
- package/dist/compliance/index.js +260 -0
- package/dist/compliance/privacy-impact-assessment.js +364 -0
- package/dist/compliance/pseudonymization.js +269 -0
- package/dist/compliance/query-firewall.js +1182 -0
- package/dist/compliance/rate-limiter.js +580 -0
- package/dist/compliance/right-to-erasure.js +117 -0
- package/dist/compliance/row-level-security.js +246 -0
- package/dist/compliance/security-decorator.js +574 -0
- package/dist/compliance/security-monitor.js +525 -0
- package/dist/compliance/sensitive-data-discovery.js +476 -0
- package/dist/compliance/session-isolation.js +472 -0
- package/dist/compliance/tls-enforcer.js +108 -0
- package/dist/compliance/worm-storage.js +712 -0
- package/dist/connection-manager.js +198 -0
- package/dist/connection-pool.js +519 -0
- package/dist/decorators/audit.js +136 -0
- package/dist/decorators/belongs-to-many.js +115 -0
- package/dist/decorators/belongs-to.js +115 -0
- package/dist/decorators/check.js +435 -0
- package/dist/decorators/collate.js +329 -0
- package/dist/decorators/comment.js +205 -0
- package/dist/decorators/database-settings.js +236 -0
- package/dist/decorators/default.js +244 -0
- package/dist/decorators/encryption.js +235 -0
- package/dist/decorators/engine.js +97 -0
- package/dist/decorators/fk-constraints.js +594 -0
- package/dist/decorators/foreign-table.js +136 -0
- package/dist/decorators/generated.js +274 -0
- package/dist/decorators/has-many.js +127 -0
- package/dist/decorators/has-one.js +116 -0
- package/dist/decorators/hstore.js +129 -0
- package/dist/decorators/index.js +355 -0
- package/dist/decorators/json-column.js +83 -0
- package/dist/decorators/jsonb.js +101 -0
- package/dist/decorators/orm-decorators.js +425 -0
- package/dist/decorators/permissions.js +294 -0
- package/dist/decorators/procedure.js +210 -0
- package/dist/decorators/query-options.js +556 -0
- package/dist/decorators/range.js +167 -0
- package/dist/decorators/set-column.js +83 -0
- package/dist/decorators/spatial.js +114 -0
- package/dist/decorators/storage.js +580 -0
- package/dist/decorators/timezone.js +512 -0
- package/dist/decorators/trigger.js +90 -0
- package/dist/decorators/uuid.js +135 -0
- package/dist/decorators/view.js +258 -0
- package/dist/diagrams/chen-diagram.js +354 -0
- package/dist/diagrams/class-diagram.js +384 -0
- package/dist/diagrams/dependency-diagram.js +432 -0
- package/dist/diagrams/er-diagram.js +605 -0
- package/dist/diagrams/flow-diagram.js +394 -0
- package/dist/diagrams/gantt-diagram.js +411 -0
- package/dist/diagrams/index-diagram.js +353 -0
- package/dist/diagrams/index.js +184 -0
- package/dist/diagrams/migration-diagram.js +316 -0
- package/dist/diagrams/model-diagram.js +616 -0
- package/dist/diagrams/package-diagram.js +376 -0
- package/dist/diagrams/palette.js +85 -0
- package/dist/diagrams/relational-diagram.js +455 -0
- package/dist/diagrams/schemadoc-diagram.js +309 -0
- package/dist/diagrams/sequence-diagram.js +307 -0
- package/dist/diagrams/state-diagram.js +344 -0
- package/dist/diagrams/svg-dom.js +111 -0
- package/dist/diagrams/tree-diagram.js +250 -0
- package/dist/dialects/clickhouse/index.js +1742 -0
- package/dist/dialects/cockroachdb/index.js +4677 -0
- package/dist/dialects/cratedb/index.js +441 -0
- package/dist/dialects/databricks/index.js +517 -0
- package/dist/dialects/db2/index.js +2225 -0
- package/dist/dialects/dialect.js +720 -0
- package/dist/dialects/duckdb/index.js +2014 -0
- package/dist/dialects/exasol/index.js +357 -0
- package/dist/dialects/firebird/index.js +495 -0
- package/dist/dialects/greenplum/index.js +457 -0
- package/dist/dialects/hana/index.js +1741 -0
- package/dist/dialects/mariadb/index.js +3590 -0
- package/dist/dialects/mssql/index.js +2296 -0
- package/dist/dialects/mysql/index.js +4058 -0
- package/dist/dialects/oracle/index.js +2999 -0
- package/dist/dialects/postgres/index.js +5319 -0
- package/dist/dialects/query-stream-helper.js +152 -0
- package/dist/dialects/questdb/index.js +433 -0
- package/dist/dialects/redshift/index.js +2277 -0
- package/dist/dialects/singlestore/index.js +354 -0
- package/dist/dialects/snowflake/index.js +2082 -0
- package/dist/dialects/spanner/index.js +1768 -0
- package/dist/dialects/sqlite/index.js +3382 -0
- package/dist/dialects/tidb/index.js +377 -0
- package/dist/dialects/timescaledb/index.js +164 -0
- package/dist/dialects/trino/index.js +420 -0
- package/dist/dialects/turso/index.js +227 -0
- package/dist/dialects/vertica/index.js +317 -0
- package/dist/dialects/yugabytedb/index.js +424 -0
- package/dist/errors/index.js +472 -0
- package/dist/errors/utils.js +340 -0
- package/dist/errors.js +21 -0
- package/dist/extensions/catalog/cloud-warehouse-features.js +207 -0
- package/dist/extensions/catalog/mssql-features.js +147 -0
- package/dist/extensions/catalog/mysql-mariadb-plugins.js +229 -0
- package/dist/extensions/catalog/oracle-db2-features.js +196 -0
- package/dist/extensions/catalog/postgres-extensions.js +516 -0
- package/dist/extensions/index.js +71 -0
- package/dist/extensions/types.js +13 -0
- package/dist/foreign-data.js +173 -0
- package/dist/hooks/hooks-manager.js +350 -0
- package/dist/hooks/index.js +37 -0
- package/dist/index.js +463 -0
- package/dist/logging.js +335 -0
- package/dist/migrations/index.js +40 -0
- package/dist/migrations/migration.js +196 -0
- package/dist/migrations/migrator.js +411 -0
- package/dist/migrations/prormmigration.js +275 -0
- package/dist/migrations/query-interface.js +435 -0
- package/dist/migrations/seeder.js +353 -0
- package/dist/models/associations.js +852 -0
- package/dist/models/constraints.js +288 -0
- package/dist/models/data-types.js +2518 -0
- package/dist/models/decorators.js +445 -0
- package/dist/models/index.js +33 -0
- package/dist/models/indexes.js +531 -0
- package/dist/models/methods.js +382 -0
- package/dist/models/model-manager.js +103 -0
- package/dist/models/model.js +5349 -0
- package/dist/models/operators.js +67 -0
- package/dist/models/scopes.js +189 -0
- package/dist/models/typescript-types.js +26 -0
- package/dist/nosql/aerospike/index.js +205 -0
- package/dist/nosql/allegrograph/index.js +169 -0
- package/dist/nosql/arangodb/index.js +364 -0
- package/dist/nosql/azure-blob/index.js +206 -0
- package/dist/nosql/beanstalkd/index.js +231 -0
- package/dist/nosql/beequeue/index.js +210 -0
- package/dist/nosql/bigchaindb/index.js +195 -0
- package/dist/nosql/bigtable/index.js +224 -0
- package/dist/nosql/blazegraph/index.js +173 -0
- package/dist/nosql/bullmq/index.js +191 -0
- package/dist/nosql/cassandra/index.js +174 -0
- package/dist/nosql/chroma/index.js +190 -0
- package/dist/nosql/cloudflare-kv/index.js +220 -0
- package/dist/nosql/coherence/index.js +200 -0
- package/dist/nosql/cosmosdb/index.js +157 -0
- package/dist/nosql/couchbase/index.js +213 -0
- package/dist/nosql/dax/index.js +212 -0
- package/dist/nosql/deno-kv/index.js +206 -0
- package/dist/nosql/dgraph/index.js +171 -0
- package/dist/nosql/doris/index.js +169 -0
- package/dist/nosql/druid/index.js +162 -0
- package/dist/nosql/dynamodb/index.js +937 -0
- package/dist/nosql/elasticsearch/index.js +377 -0
- package/dist/nosql/etcd/index.js +502 -0
- package/dist/nosql/eventhubs/index.js +213 -0
- package/dist/nosql/eventstore/index.js +254 -0
- package/dist/nosql/faunadb/index.js +188 -0
- package/dist/nosql/firestore/index.js +177 -0
- package/dist/nosql/fluree/index.js +148 -0
- package/dist/nosql/fuseki/index.js +170 -0
- package/dist/nosql/gcs/index.js +172 -0
- package/dist/nosql/gearman/index.js +160 -0
- package/dist/nosql/geode/index.js +196 -0
- package/dist/nosql/graphdb/index.js +169 -0
- package/dist/nosql/graylog/index.js +188 -0
- package/dist/nosql/gridgain/index.js +171 -0
- package/dist/nosql/hazelcast/index.js +162 -0
- package/dist/nosql/hbase/index.js +230 -0
- package/dist/nosql/ignite/index.js +173 -0
- package/dist/nosql/immudb/index.js +184 -0
- package/dist/nosql/index.js +232 -0
- package/dist/nosql/infinispan/index.js +200 -0
- package/dist/nosql/influxdb/index.js +0 -0
- package/dist/nosql/kafka/index.js +234 -0
- package/dist/nosql/keyspaces/index.js +189 -0
- package/dist/nosql/kinesis/index.js +253 -0
- package/dist/nosql/leveldb/index.js +153 -0
- package/dist/nosql/lmdb/index.js +160 -0
- package/dist/nosql/loki/index.js +201 -0
- package/dist/nosql/marklogic/index.js +204 -0
- package/dist/nosql/materialize/index.js +145 -0
- package/dist/nosql/meilisearch/index.js +154 -0
- package/dist/nosql/memcached/index.js +223 -0
- package/dist/nosql/milvus/index.js +410 -0
- package/dist/nosql/minio/index.js +265 -0
- package/dist/nosql/momento/index.js +179 -0
- package/dist/nosql/mongodb/index.js +461 -0
- package/dist/nosql/nats/index.js +247 -0
- package/dist/nosql/nedb/index.js +164 -0
- package/dist/nosql/neo4j/index.js +450 -0
- package/dist/nosql/neptune/index.js +470 -0
- package/dist/nosql/nsq/index.js +200 -0
- package/dist/nosql/opensearch/index.js +186 -0
- package/dist/nosql/orientdb/index.js +175 -0
- package/dist/nosql/papertrail/index.js +200 -0
- package/dist/nosql/pinecone/index.js +0 -0
- package/dist/nosql/pinot/index.js +133 -0
- package/dist/nosql/pouchdb/index.js +172 -0
- package/dist/nosql/prometheus/index.js +174 -0
- package/dist/nosql/provendb/index.js +147 -0
- package/dist/nosql/pubsub/index.js +187 -0
- package/dist/nosql/pulsar/index.js +232 -0
- package/dist/nosql/qdrant/index.js +295 -0
- package/dist/nosql/qldb/index.js +192 -0
- package/dist/nosql/r2/index.js +281 -0
- package/dist/nosql/rabbitmq/index.js +237 -0
- package/dist/nosql/ravendb/index.js +175 -0
- package/dist/nosql/redis/index.js +607 -0
- package/dist/nosql/redpanda/index.js +237 -0
- package/dist/nosql/resque/index.js +203 -0
- package/dist/nosql/rethinkdb/index.js +232 -0
- package/dist/nosql/rocksdb/index.js +152 -0
- package/dist/nosql/rockset/index.js +126 -0
- package/dist/nosql/s3/index.js +298 -0
- package/dist/nosql/scylladb/index.js +178 -0
- package/dist/nosql/signoz/index.js +227 -0
- package/dist/nosql/sns/index.js +201 -0
- package/dist/nosql/solr/index.js +231 -0
- package/dist/nosql/splunk/index.js +227 -0
- package/dist/nosql/sqs/index.js +246 -0
- package/dist/nosql/stardog/index.js +169 -0
- package/dist/nosql/starrocks/index.js +170 -0
- package/dist/nosql/store.js +2 -0
- package/dist/nosql/sumologic/index.js +213 -0
- package/dist/nosql/surrealdb/index.js +179 -0
- package/dist/nosql/terminusdb/index.js +151 -0
- package/dist/nosql/tigergraph/index.js +469 -0
- package/dist/nosql/typesense/index.js +148 -0
- package/dist/nosql/unqlite/index.js +157 -0
- package/dist/nosql/upstash/index.js +167 -0
- package/dist/nosql/vercel-kv/index.js +166 -0
- package/dist/nosql/victoriametrics/index.js +213 -0
- package/dist/nosql/virtuoso/index.js +169 -0
- package/dist/nosql/weaviate/index.js +276 -0
- package/dist/operators/index.js +108 -0
- package/dist/operators.js +2690 -0
- package/dist/prisma-migrate/index.js +38 -0
- package/dist/prisma-migrate/migration-generator.js +125 -0
- package/dist/prisma-migrate/model-generator.js +172 -0
- package/dist/prisma-migrate/relations.js +100 -0
- package/dist/prisma-migrate/schema-parser.js +167 -0
- package/dist/prisma-migrate/type-mapper.js +40 -0
- package/dist/prorm.js +6832 -0
- package/dist/query-builders/cte-builder.js +80 -0
- package/dist/query-builders/functions/aggregate.js +390 -0
- package/dist/query-builders/functions/conditional.js +503 -0
- package/dist/query-builders/functions/datetime.js +695 -0
- package/dist/query-builders/functions/fulltext.js +439 -0
- package/dist/query-builders/functions/index.js +93 -0
- package/dist/query-builders/functions/json.js +427 -0
- package/dist/query-builders/functions/math.js +399 -0
- package/dist/query-builders/functions/string.js +518 -0
- package/dist/query-builders/functions/window.js +328 -0
- package/dist/query-builders/include-builder.js +323 -0
- package/dist/query-builders/index-expression-builder.js +242 -0
- package/dist/query-builders/index.js +161 -0
- package/dist/query-builders/insert-builder.js +164 -0
- package/dist/query-builders/model-helpers.js +38 -0
- package/dist/query-builders/order-limit-builder.js +239 -0
- package/dist/query-builders/sql-compiler.js +2040 -0
- package/dist/query-builders/subquery-builder.js +152 -0
- package/dist/query-builders/update-builder.js +182 -0
- package/dist/query-builders/view-builder.js +218 -0
- package/dist/query-builders/where-builder.js +1532 -0
- package/dist/query-interface.js +622 -0
- package/dist/query-optimizers/batch-optimizer.js +426 -0
- package/dist/query-optimizers/explain-plans.js +415 -0
- package/dist/query-optimizers/index.js +51 -0
- package/dist/query-optimizers/prepared-statement-cache.js +423 -0
- package/dist/query-optimizers/query-hints.js +438 -0
- package/dist/query-optimizers/query-optimizer.js +278 -0
- package/dist/query-optimizers/slow-query-logger.js +271 -0
- package/dist/replica-manager.js +507 -0
- package/dist/schema/index.js +15 -0
- package/dist/schema/migration-generator.js +374 -0
- package/dist/schema/schema-differ.js +549 -0
- package/dist/schema/types.js +6 -0
- package/dist/sql-constants.js +300 -0
- package/dist/sqlite-advanced.js +1047 -0
- package/dist/streams/index.js +12 -0
- package/dist/streams/transforms.js +178 -0
- package/dist/transaction.js +456 -0
- package/dist/types/index.js +180 -0
- package/dist/user-management.js +127 -0
- package/dist/utils/date.js +300 -0
- package/dist/utils/index.js +1079 -0
- package/dist/utils/string.js +161 -0
- package/dist/validators/index.js +19 -0
- package/dist/validators/validator.js +911 -0
- package/package.json +190 -0
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Error utility functions for the ORM
|
|
4
|
+
* Provides helpers for error handling and conversion
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.wrapError = wrapError;
|
|
8
|
+
exports.aggregateErrors = aggregateErrors;
|
|
9
|
+
exports.createValidationError = createValidationError;
|
|
10
|
+
exports.isErrorCode = isErrorCode;
|
|
11
|
+
exports.isRetryableError = isRetryableError;
|
|
12
|
+
exports.getRootCause = getRootCause;
|
|
13
|
+
exports.formatError = formatError;
|
|
14
|
+
exports.defaultErrorHandler = defaultErrorHandler;
|
|
15
|
+
const index_1 = require("./index");
|
|
16
|
+
/**
|
|
17
|
+
* Wraps a database error into the appropriate Prorm error type
|
|
18
|
+
* @param error - The original error from the database
|
|
19
|
+
* @param sql - The SQL query that caused the error
|
|
20
|
+
* @returns The appropriate Prorm error
|
|
21
|
+
*/
|
|
22
|
+
function wrapError(error, sql) {
|
|
23
|
+
const errorMessage = error.message.toLowerCase();
|
|
24
|
+
// Check for connection errors
|
|
25
|
+
if (isConnectionErrorMessage(errorMessage)) {
|
|
26
|
+
return handleConnectionError(error, sql);
|
|
27
|
+
}
|
|
28
|
+
// Check for constraint violations. Foreign key and exclusion constraints
|
|
29
|
+
// must be checked before the (broader) unique constraint check, since
|
|
30
|
+
// messages like "FOREIGN KEY constraint failed" or Oracle's
|
|
31
|
+
// "integrity constraint ... violated - parent key not found" would
|
|
32
|
+
// otherwise be swallowed by the generic unique-constraint keyword match.
|
|
33
|
+
if (isForeignKeyConstraintError(errorMessage)) {
|
|
34
|
+
return handleForeignKeyConstraintError(error, sql);
|
|
35
|
+
}
|
|
36
|
+
if (isExclusionConstraintError(errorMessage)) {
|
|
37
|
+
return handleExclusionConstraintError(error, sql);
|
|
38
|
+
}
|
|
39
|
+
if (isUniqueConstraintError(errorMessage)) {
|
|
40
|
+
return handleUniqueConstraintError(error, sql);
|
|
41
|
+
}
|
|
42
|
+
// Check for timeout errors
|
|
43
|
+
if (isTimeoutError(errorMessage)) {
|
|
44
|
+
return new index_1.TimeoutError('Query timeout', { parent: error, sql });
|
|
45
|
+
}
|
|
46
|
+
// Check for resource locked errors
|
|
47
|
+
if (isResourceLockedError(errorMessage)) {
|
|
48
|
+
return new index_1.ResourceLockedError('Resource is locked', { parent: error, sql });
|
|
49
|
+
}
|
|
50
|
+
// Default to database error
|
|
51
|
+
return index_1.DatabaseError.from(error, { sql });
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Handle connection-related errors
|
|
55
|
+
*/
|
|
56
|
+
function handleConnectionError(error, sql) {
|
|
57
|
+
const message = error.message.toLowerCase();
|
|
58
|
+
if (message.includes('refused') || message.includes('unable to connect')) {
|
|
59
|
+
return index_1.ConnectionError.refused({ parent: error });
|
|
60
|
+
}
|
|
61
|
+
if (message.includes('timeout') || message.includes('timed out')) {
|
|
62
|
+
return index_1.ConnectionError.timedOut({ parent: error });
|
|
63
|
+
}
|
|
64
|
+
if (message.includes('not reachable') || message.includes('not found')) {
|
|
65
|
+
return index_1.ConnectionError.unreachable({ parent: error });
|
|
66
|
+
}
|
|
67
|
+
return new index_1.ConnectionError(error.message, { parent: error, sql });
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Handle unique constraint errors
|
|
71
|
+
*/
|
|
72
|
+
function handleUniqueConstraintError(error, sql) {
|
|
73
|
+
// Try to extract field names from error message
|
|
74
|
+
const fields = extractFieldNames(error.message);
|
|
75
|
+
return index_1.UniqueConstraintError.from(error, { sql, fields });
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Handle foreign key constraint errors
|
|
79
|
+
*/
|
|
80
|
+
function handleForeignKeyConstraintError(error, sql) {
|
|
81
|
+
// Try to extract field/table information from error message
|
|
82
|
+
const info = extractForeignKeyInfo(error.message);
|
|
83
|
+
return index_1.ForeignKeyConstraintError.from(error, {
|
|
84
|
+
sql,
|
|
85
|
+
field: info.field,
|
|
86
|
+
table: info.table,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Handle exclusion constraint errors
|
|
91
|
+
*/
|
|
92
|
+
function handleExclusionConstraintError(error, sql) {
|
|
93
|
+
// Try to extract constraint name
|
|
94
|
+
const constraint = extractConstraintName(error.message);
|
|
95
|
+
return new index_1.ExclusionConstraintError(error.message, { parent: error, sql, constraint });
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Check if error message indicates connection issue
|
|
99
|
+
*/
|
|
100
|
+
function isConnectionErrorMessage(message) {
|
|
101
|
+
const connectionKeywords = [
|
|
102
|
+
'connection',
|
|
103
|
+
'connect',
|
|
104
|
+
'refused',
|
|
105
|
+
'timeout',
|
|
106
|
+
'unreachable',
|
|
107
|
+
'network',
|
|
108
|
+
'econnrefused',
|
|
109
|
+
'econnreset',
|
|
110
|
+
'enotfound',
|
|
111
|
+
];
|
|
112
|
+
return connectionKeywords.some((keyword) => message.includes(keyword));
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Check if error message indicates unique constraint violation
|
|
116
|
+
*/
|
|
117
|
+
function isUniqueConstraintError(message) {
|
|
118
|
+
const uniqueKeywords = [
|
|
119
|
+
'unique',
|
|
120
|
+
'duplicate',
|
|
121
|
+
'already exists',
|
|
122
|
+
'duplicate key',
|
|
123
|
+
// NOTE: the bare word 'constraint' was previously included here, but it
|
|
124
|
+
// is far too generic - it also matches foreign key, check, and
|
|
125
|
+
// exclusion constraint messages (e.g. SQLite's "FOREIGN KEY constraint
|
|
126
|
+
// failed" or Oracle's "integrity constraint ... violated"), causing
|
|
127
|
+
// those errors to be misclassified as UniqueConstraintError.
|
|
128
|
+
];
|
|
129
|
+
return uniqueKeywords.some((keyword) => message.includes(keyword));
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Check if error message indicates foreign key constraint violation
|
|
133
|
+
*/
|
|
134
|
+
function isForeignKeyConstraintError(message) {
|
|
135
|
+
const fkKeywords = [
|
|
136
|
+
'foreign key',
|
|
137
|
+
'reference',
|
|
138
|
+
'referential integrity',
|
|
139
|
+
'foreign key constraint failed',
|
|
140
|
+
'foreign key constraint',
|
|
141
|
+
'has no child',
|
|
142
|
+
'cannot delete',
|
|
143
|
+
// Oracle: "ORA-02291: integrity constraint (...) violated - parent key not found"
|
|
144
|
+
// and "ORA-02292: integrity constraint (...) violated - child record found"
|
|
145
|
+
// don't mention "foreign key" literally.
|
|
146
|
+
'parent key not found',
|
|
147
|
+
'child record found',
|
|
148
|
+
];
|
|
149
|
+
return fkKeywords.some((keyword) => message.includes(keyword));
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Check if error message indicates exclusion constraint violation
|
|
153
|
+
*/
|
|
154
|
+
function isExclusionConstraintError(message) {
|
|
155
|
+
const exclusionKeywords = ['exclusion', 'OVERLAPS'];
|
|
156
|
+
return exclusionKeywords.some((keyword) => message.includes(keyword));
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Check if error message indicates timeout
|
|
160
|
+
*/
|
|
161
|
+
function isTimeoutError(message) {
|
|
162
|
+
const timeoutKeywords = ['timeout', 'timed out', 'etimedout'];
|
|
163
|
+
return timeoutKeywords.some((keyword) => message.includes(keyword));
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Check if error message indicates resource locked
|
|
167
|
+
*/
|
|
168
|
+
function isResourceLockedError(message) {
|
|
169
|
+
const lockedKeywords = ['locked', 'busy', 'exclusive', 'sqlite_busy', 'database is locked'];
|
|
170
|
+
return lockedKeywords.some((keyword) => message.includes(keyword));
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Extract field names from error message
|
|
174
|
+
*/
|
|
175
|
+
function extractFieldNames(message) {
|
|
176
|
+
// SQLite format: UNIQUE constraint failed: tableName.columnName
|
|
177
|
+
const sqliteMatch = message.match(/UNIQUE constraint failed:\s*(.+)/i);
|
|
178
|
+
if (sqliteMatch) {
|
|
179
|
+
return sqliteMatch[1].split('.').map((s) => s.trim());
|
|
180
|
+
}
|
|
181
|
+
// PostgreSQL format: Key (column)=(value) already exists
|
|
182
|
+
const pgMatch = message.match(/Key \(([^)]+)\)=/i);
|
|
183
|
+
if (pgMatch) {
|
|
184
|
+
return [pgMatch[1]];
|
|
185
|
+
}
|
|
186
|
+
// MySQL format: Duplicate entry 'value' for key 'key'
|
|
187
|
+
const mysqlMatch = message.match(/Duplicate entry.*for key '(.+)'/i);
|
|
188
|
+
if (mysqlMatch) {
|
|
189
|
+
return [mysqlMatch[1]];
|
|
190
|
+
}
|
|
191
|
+
return [];
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Extract foreign key info from error message
|
|
195
|
+
*/
|
|
196
|
+
function extractForeignKeyInfo(message) {
|
|
197
|
+
// SQLite format: FOREIGN KEY constraint failed
|
|
198
|
+
const sqliteMatch = message.match(/FOREIGN KEY constraint failed:\s*(.+)/i);
|
|
199
|
+
if (sqliteMatch) {
|
|
200
|
+
const parts = sqliteMatch[1].split('.');
|
|
201
|
+
return { field: parts[1]?.trim(), table: parts[0]?.trim() };
|
|
202
|
+
}
|
|
203
|
+
// PostgreSQL format: Key (field)=(value) is not present in table "table"
|
|
204
|
+
const pgMatch = message.match(/Key \(([^)]+)\)=.*is not present in table "([^"]+)"/i);
|
|
205
|
+
if (pgMatch) {
|
|
206
|
+
return { field: pgMatch[1], table: pgMatch[2] };
|
|
207
|
+
}
|
|
208
|
+
// MySQL format: Cannot add or update a child row: a foreign key constraint fails
|
|
209
|
+
const mysqlMatch = message.match(/foreign key constraint fails.*`([^`]+)`.`([^`]+)`/i);
|
|
210
|
+
if (mysqlMatch) {
|
|
211
|
+
return { table: mysqlMatch[1], field: mysqlMatch[2] };
|
|
212
|
+
}
|
|
213
|
+
return {};
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Extract constraint name from error message
|
|
217
|
+
*/
|
|
218
|
+
function extractConstraintName(message) {
|
|
219
|
+
// Try to extract constraint name
|
|
220
|
+
const match = message.match(/constraint ["']?([^"'"]+)["']?/i);
|
|
221
|
+
return match?.[1];
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Aggregates multiple validation errors into a single ValidationError
|
|
225
|
+
* @param errors - Array of validation errors or error arrays
|
|
226
|
+
* @returns A single ValidationError with all errors combined
|
|
227
|
+
*/
|
|
228
|
+
function aggregateErrors(...errors) {
|
|
229
|
+
const allErrors = [];
|
|
230
|
+
for (const error of errors) {
|
|
231
|
+
if (!error)
|
|
232
|
+
continue;
|
|
233
|
+
if (error instanceof index_1.ValidationError) {
|
|
234
|
+
allErrors.push(...error.errors);
|
|
235
|
+
}
|
|
236
|
+
else if (Array.isArray(error)) {
|
|
237
|
+
allErrors.push(...error);
|
|
238
|
+
}
|
|
239
|
+
else if (error instanceof Error) {
|
|
240
|
+
allErrors.push({
|
|
241
|
+
message: error.message,
|
|
242
|
+
type: 'Error',
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
else if (typeof error === 'string') {
|
|
246
|
+
allErrors.push({
|
|
247
|
+
message: error,
|
|
248
|
+
type: 'String Error',
|
|
249
|
+
});
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
return new index_1.ValidationError('Validation error', allErrors);
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Creates a ValidationError with a single error item
|
|
256
|
+
*/
|
|
257
|
+
function createValidationError(message, path, value) {
|
|
258
|
+
return new index_1.ValidationError(message, [
|
|
259
|
+
{
|
|
260
|
+
message,
|
|
261
|
+
type: 'Validation Error',
|
|
262
|
+
path,
|
|
263
|
+
value,
|
|
264
|
+
},
|
|
265
|
+
]);
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Check if an error is a specific Prorm error type by code
|
|
269
|
+
*/
|
|
270
|
+
function isErrorCode(error, code) {
|
|
271
|
+
if (error instanceof index_1.PrormError) {
|
|
272
|
+
return error.code === code;
|
|
273
|
+
}
|
|
274
|
+
return false;
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Check if error is retryable
|
|
278
|
+
*/
|
|
279
|
+
function isRetryableError(error) {
|
|
280
|
+
if (error instanceof index_1.TimeoutError)
|
|
281
|
+
return true;
|
|
282
|
+
if (error instanceof index_1.ResourceLockedError)
|
|
283
|
+
return true;
|
|
284
|
+
if (error instanceof index_1.ConnectionError) {
|
|
285
|
+
return (error.code === index_1.ErrorCodes.CONNECTION_TIMED_OUT || error.code === index_1.ErrorCodes.HOST_NOT_REACHABLE);
|
|
286
|
+
}
|
|
287
|
+
return false;
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Get the root cause of an error (unwrap nested errors)
|
|
291
|
+
*/
|
|
292
|
+
function getRootCause(error) {
|
|
293
|
+
if (error instanceof index_1.PrormError && error.parent) {
|
|
294
|
+
return getRootCause(error.parent);
|
|
295
|
+
}
|
|
296
|
+
return error;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Format error for logging
|
|
300
|
+
*/
|
|
301
|
+
function formatError(error) {
|
|
302
|
+
if (error instanceof index_1.PrormError) {
|
|
303
|
+
const lines = [`[${error.name}] ${error.message}`, ` Code: ${error.code}`];
|
|
304
|
+
if (error.sql) {
|
|
305
|
+
lines.push(` SQL: ${error.sql}`);
|
|
306
|
+
}
|
|
307
|
+
if (error.parent) {
|
|
308
|
+
lines.push(` Parent: ${error.parent.message}`);
|
|
309
|
+
}
|
|
310
|
+
if (error instanceof index_1.ValidationError && error.errors.length > 0) {
|
|
311
|
+
lines.push(' Errors:');
|
|
312
|
+
for (const err of error.errors) {
|
|
313
|
+
lines.push(` - ${err.path || 'unknown'}: ${err.message}`);
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
return lines.join('\n');
|
|
317
|
+
}
|
|
318
|
+
if (error instanceof Error) {
|
|
319
|
+
return `[${error.name}] ${error.message}\n${error.stack || ''}`;
|
|
320
|
+
}
|
|
321
|
+
return String(error);
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* Default error handler that logs and re-throws
|
|
325
|
+
*/
|
|
326
|
+
function defaultErrorHandler(error) {
|
|
327
|
+
const formattedError = formatError(error);
|
|
328
|
+
console.error('Error occurred:', formattedError);
|
|
329
|
+
throw error;
|
|
330
|
+
}
|
|
331
|
+
exports.default = {
|
|
332
|
+
wrapError,
|
|
333
|
+
aggregateErrors,
|
|
334
|
+
createValidationError,
|
|
335
|
+
isErrorCode,
|
|
336
|
+
isRetryableError,
|
|
337
|
+
getRootCause,
|
|
338
|
+
formatError,
|
|
339
|
+
defaultErrorHandler,
|
|
340
|
+
};
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Re-export all error classes and utilities
|
|
4
|
+
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
17
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
__exportStar(require("./errors/index"), exports);
|
|
21
|
+
__exportStar(require("./errors/utils"), exports);
|
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Cloud warehouse / embedded-engine feature catalog: Snowflake, Redshift,
|
|
4
|
+
* ClickHouse, and SQLite.
|
|
5
|
+
*
|
|
6
|
+
* None of these four dialects have a genuine Postgres-style `CREATE EXTENSION`
|
|
7
|
+
* mechanism, so every entry below is `isNativeSqlExtension: false`. Instead they
|
|
8
|
+
* expose installable/enableable capabilities through a mix of:
|
|
9
|
+
* - dedicated DDL objects (`CREATE STREAM`, `CREATE EXTERNAL SCHEMA`, `CREATE
|
|
10
|
+
* VIRTUAL TABLE ... USING fts5`, table `ENGINE = ...` clauses),
|
|
11
|
+
* - account/session-level enablement with no single-statement toggle
|
|
12
|
+
* (Snowpark, external functions, Redshift ML),
|
|
13
|
+
* - or compile-time/loadable-module features (SQLite's FTS5/R-Tree/JSON1,
|
|
14
|
+
* which are compiled into `better-sqlite3` rather than "installed" via SQL).
|
|
15
|
+
*
|
|
16
|
+
* `installCommand` is only populated where a real, verifiable single SQL
|
|
17
|
+
* statement enables the feature; left undefined where enabling it requires
|
|
18
|
+
* case-by-case DDL, an external console/CLI step, or is compiled in by default.
|
|
19
|
+
*
|
|
20
|
+
* Where this ORM's own Snowflake/Redshift/ClickHouse/SQLite dialects (see
|
|
21
|
+
* `src/dialects/<dialect>/index.ts` and `src/dialects/<dialect>/GAPS.md`)
|
|
22
|
+
* already implement real support for a capability, the description says so
|
|
23
|
+
* explicitly and names the relevant method(s); where support is absent, the
|
|
24
|
+
* description says the capability is reachable only via raw SQL through this
|
|
25
|
+
* ORM today.
|
|
26
|
+
*/
|
|
27
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
+
exports.cloudWarehouseFeatures = void 0;
|
|
29
|
+
exports.cloudWarehouseFeatures = [
|
|
30
|
+
// ---------------------------------------------------------------------
|
|
31
|
+
// Snowflake
|
|
32
|
+
// ---------------------------------------------------------------------
|
|
33
|
+
{
|
|
34
|
+
name: 'Time Travel',
|
|
35
|
+
dialects: ['snowflake'],
|
|
36
|
+
category: 'utility',
|
|
37
|
+
description: 'Query historical versions of a table/schema/database via AT(TIMESTAMP=>...)/AT(OFFSET=>...)/AT(STATEMENT=>...)/BEFORE(STATEMENT=>...), and restore dropped objects with UNDROP. Implemented in this ORM\'s Snowflake dialect (buildTimeTravelClause, wired into buildSelectQuery).',
|
|
38
|
+
isNativeSqlExtension: false,
|
|
39
|
+
minVersion: 'Standard edition: 1 day retention; Enterprise+: up to 90 days',
|
|
40
|
+
docsUrl: 'https://docs.snowflake.com/en/user-guide/data-time-travel',
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: 'Zero-Copy Clone',
|
|
44
|
+
dialects: ['snowflake'],
|
|
45
|
+
category: 'utility',
|
|
46
|
+
description: 'Instant, storage-efficient copy of a table/schema/database via CREATE TABLE|SCHEMA|DATABASE ... CLONE <source>, optionally combined with a Time Travel clause to clone a historical version. Implemented in this ORM\'s Snowflake dialect (cloneTable/cloneSchema/cloneDatabase).',
|
|
47
|
+
installCommand: 'CREATE TABLE <target> CLONE <source>',
|
|
48
|
+
isNativeSqlExtension: false,
|
|
49
|
+
docsUrl: 'https://docs.snowflake.com/en/sql-reference/sql/create-clone',
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: 'Streams',
|
|
53
|
+
dialects: ['snowflake'],
|
|
54
|
+
category: 'replication',
|
|
55
|
+
description: 'Native change-data-capture primitive that tracks row-level INSERT/UPDATE/DELETE changes on a table (or view) since it was last consumed. Implemented in this ORM\'s Snowflake dialect (createStream/dropStream/showStreams).',
|
|
56
|
+
installCommand: 'CREATE STREAM <name> ON TABLE <table>',
|
|
57
|
+
isNativeSqlExtension: false,
|
|
58
|
+
docsUrl: 'https://docs.snowflake.com/en/user-guide/streams-intro',
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: 'Tasks',
|
|
62
|
+
dialects: ['snowflake'],
|
|
63
|
+
category: 'scheduling',
|
|
64
|
+
description: 'Scheduled or DAG-chained SQL/procedure execution (CREATE TASK ... [SCHEDULE=...|AFTER <task>] AS <sql>), Snowflake\'s native job-scheduling primitive, often paired with Streams for incremental ETL. Implemented in this ORM\'s Snowflake dialect (createTask/dropTask/executeTask).',
|
|
65
|
+
installCommand: "CREATE TASK <name> SCHEDULE = '5 MINUTE' AS <sql>",
|
|
66
|
+
isNativeSqlExtension: false,
|
|
67
|
+
docsUrl: 'https://docs.snowflake.com/en/user-guide/tasks-intro',
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: 'Snowpark',
|
|
71
|
+
dialects: ['snowflake'],
|
|
72
|
+
category: 'procedural-language',
|
|
73
|
+
description: 'Run Python, Java, or Scala UDFs, UDTFs, and stored procedures inside Snowflake\'s compute engine via CREATE FUNCTION/CREATE PROCEDURE ... LANGUAGE PYTHON|JAVA|SCALA, avoiding data movement to an external client. Not implemented in this ORM\'s Snowflake dialect, which only wraps SQL stored procedures (CREATE PROCEDURE ... LANGUAGE SQL); non-SQL UDFs/procedures require hand-written raw SQL today.',
|
|
74
|
+
installCommand: "CREATE FUNCTION my_udf(x FLOAT) RETURNS FLOAT LANGUAGE PYTHON RUNTIME_VERSION='3.11' HANDLER='udf' AS $$...$$",
|
|
75
|
+
isNativeSqlExtension: false,
|
|
76
|
+
docsUrl: 'https://docs.snowflake.com/en/developer-guide/snowpark/index',
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
name: 'External Functions',
|
|
80
|
+
dialects: ['snowflake'],
|
|
81
|
+
category: 'connectivity',
|
|
82
|
+
description: 'Call out to AWS Lambda, Azure Functions, or Google Cloud Functions from SQL via CREATE EXTERNAL FUNCTION ... API_INTEGRATION=... AS <endpoint URL>, after first creating an API integration object. Not implemented in this ORM\'s Snowflake dialect; reachable only via raw SQL.',
|
|
83
|
+
isNativeSqlExtension: false,
|
|
84
|
+
docsUrl: 'https://docs.snowflake.com/en/sql-reference/external-functions',
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
name: 'Cortex AISQL Functions',
|
|
88
|
+
dialects: ['snowflake'],
|
|
89
|
+
category: 'machine-learning',
|
|
90
|
+
description: 'Built-in SQL functions (e.g. SNOWFLAKE.CORTEX.COMPLETE, SUMMARIZE, TRANSLATE, EMBED_TEXT) that call hosted LLMs directly from a query, with no separate install step beyond having ACCOUNTADMIN-granted CORTEX access on the account. Not implemented in this ORM\'s Snowflake dialect; reachable only via raw SQL/attributes.',
|
|
91
|
+
isNativeSqlExtension: false,
|
|
92
|
+
docsUrl: 'https://docs.snowflake.com/en/user-guide/snowflake-cortex/aisql',
|
|
93
|
+
},
|
|
94
|
+
// ---------------------------------------------------------------------
|
|
95
|
+
// Redshift
|
|
96
|
+
// ---------------------------------------------------------------------
|
|
97
|
+
{
|
|
98
|
+
name: 'Redshift Spectrum',
|
|
99
|
+
dialects: ['redshift'],
|
|
100
|
+
category: 'foreign-data',
|
|
101
|
+
description: 'Query data directly in S3 (via the Glue/Athena Data Catalog or a Hive metastore) without loading it, using CREATE EXTERNAL SCHEMA ... FROM DATA CATALOG/HIVE METASTORE and CREATE EXTERNAL TABLE. This ORM\'s Redshift dialect explicitly throws on foreign-data-wrapper calls and its error message points callers at Spectrum, but does not itself build CREATE EXTERNAL SCHEMA/TABLE DDL — it must be issued as raw SQL today.',
|
|
102
|
+
installCommand: "CREATE EXTERNAL SCHEMA spectrum_schema FROM DATA CATALOG DATABASE 'db' IAM_ROLE '<role-arn>'",
|
|
103
|
+
isNativeSqlExtension: false,
|
|
104
|
+
docsUrl: 'https://docs.aws.amazon.com/redshift/latest/dg/c-getting-started-using-spectrum.html',
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
name: 'Redshift ML',
|
|
108
|
+
dialects: ['redshift'],
|
|
109
|
+
category: 'machine-learning',
|
|
110
|
+
description: "Train and deploy machine learning models from SQL via CREATE MODEL ... FROM (<query>) TARGET <col> FUNCTION <name> IAM_ROLE '<role-arn>', which Redshift compiles to a SageMaker Autopilot job behind the scenes and exposes as a callable SQL function for inference. Not implemented in this ORM's Redshift dialect; reachable only via raw SQL.",
|
|
111
|
+
isNativeSqlExtension: false,
|
|
112
|
+
docsUrl: 'https://docs.aws.amazon.com/redshift/latest/dg/machine_learning.html',
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
name: 'Federated Query',
|
|
116
|
+
dialects: ['redshift'],
|
|
117
|
+
category: 'foreign-data',
|
|
118
|
+
description: 'Query live data in Amazon RDS/Aurora PostgreSQL or MySQL directly from Redshift via CREATE EXTERNAL SCHEMA ... FROM POSTGRES/MYSQL, without ETL-ing it in first. Not implemented in this ORM\'s Redshift dialect (flagged as a gap with zero representation, not even a pointing error message); reachable only via raw SQL.',
|
|
119
|
+
installCommand: "CREATE EXTERNAL SCHEMA fed_schema FROM POSTGRES DATABASE 'db' URI '<host>' PORT 5432 IAM_ROLE '<role-arn>' SECRET_ARN '<secret-arn>'",
|
|
120
|
+
isNativeSqlExtension: false,
|
|
121
|
+
docsUrl: 'https://docs.aws.amazon.com/redshift/latest/dg/federated-overview.html',
|
|
122
|
+
},
|
|
123
|
+
// ---------------------------------------------------------------------
|
|
124
|
+
// ClickHouse
|
|
125
|
+
// ---------------------------------------------------------------------
|
|
126
|
+
{
|
|
127
|
+
name: 'Kafka Table Engine',
|
|
128
|
+
dialects: ['clickhouse'],
|
|
129
|
+
category: 'connectivity',
|
|
130
|
+
description: 'Streaming ingestion from a Kafka topic by creating a table with ENGINE = Kafka(broker_list, topic, group, format), typically paired with a materialized view that copies rows into a MergeTree table as they arrive. Not implemented as a typed helper in this ORM\'s ClickHouse dialect (createTable only defaults engine to MergeTree()); reachable by passing a raw engine string via TableOptions.engine.',
|
|
131
|
+
installCommand: "CREATE TABLE kafka_queue (...) ENGINE = Kafka('host:9092', 'topic', 'group1', 'JSONEachRow')",
|
|
132
|
+
isNativeSqlExtension: false,
|
|
133
|
+
docsUrl: 'https://clickhouse.com/docs/en/engines/table-engines/integrations/kafka',
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
name: 'S3 Table Engine',
|
|
137
|
+
dialects: ['clickhouse'],
|
|
138
|
+
category: 'foreign-data',
|
|
139
|
+
description: 'Read/write data directly in S3 (or S3-compatible storage) by creating a table with ENGINE = S3(path, format), or query it ad hoc via the s3() table function without creating a table at all. Not implemented as a typed helper in this ORM\'s ClickHouse dialect; reachable via a raw engine string or the s3() table function in raw SQL.',
|
|
140
|
+
installCommand: "CREATE TABLE s3_data (...) ENGINE = S3('https://bucket.s3.amazonaws.com/path/*.csv', 'CSV')",
|
|
141
|
+
isNativeSqlExtension: false,
|
|
142
|
+
docsUrl: 'https://clickhouse.com/docs/en/engines/table-engines/integrations/s3',
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
name: 'MySQL / PostgreSQL Table Engines',
|
|
146
|
+
dialects: ['clickhouse'],
|
|
147
|
+
category: 'foreign-data',
|
|
148
|
+
description: 'Federated queries against a live MySQL or PostgreSQL database by creating a table with ENGINE = MySQL(host, database, table, user, password) or ENGINE = PostgreSQL(...), or via the mysql()/postgresql() table functions. Not implemented as a typed helper in this ORM\'s ClickHouse dialect; reachable via a raw engine string or table function in raw SQL.',
|
|
149
|
+
installCommand: "CREATE TABLE mysql_users (...) ENGINE = MySQL('host:3306', 'db', 'users', 'user', 'password')",
|
|
150
|
+
isNativeSqlExtension: false,
|
|
151
|
+
docsUrl: 'https://clickhouse.com/docs/en/engines/table-engines/integrations/mysql',
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
name: 'Dictionary',
|
|
155
|
+
dialects: ['clickhouse'],
|
|
156
|
+
category: 'data-types',
|
|
157
|
+
description: 'In-memory (or cached) key-value lookup structure backed by another table, file, or HTTP source, created via CREATE DICTIONARY ... SOURCE(...) LAYOUT(...) LIFETIME(...) and queried with dictGet(). Not implemented in this ORM\'s ClickHouse dialect (no createDictionary/dropDictionary methods); reachable only via raw SQL.',
|
|
158
|
+
installCommand: "CREATE DICTIONARY dict_name (id UInt64, value String) PRIMARY KEY id SOURCE(HTTP(url 'http://...' format 'JSONEachRow')) LAYOUT(HASHED()) LIFETIME(300)",
|
|
159
|
+
isNativeSqlExtension: false,
|
|
160
|
+
docsUrl: 'https://clickhouse.com/docs/en/sql-reference/dictionaries',
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
name: 'Approximate Aggregate Functions',
|
|
164
|
+
dialects: ['clickhouse'],
|
|
165
|
+
category: 'utility',
|
|
166
|
+
description: 'Approximate cardinality (uniq/uniqCombined/uniqHLL12) and approximate percentile (quantile/quantiles/quantileTDigest) estimation functions for large-scale analytics. Implemented in this ORM\'s ClickHouse dialect as typed Literal-producing helper methods (uniq, uniqCombined, uniqHLL12, uniqExact, quantile, quantiles, quantileExact) usable in query attributes.',
|
|
167
|
+
isNativeSqlExtension: false,
|
|
168
|
+
docsUrl: 'https://clickhouse.com/docs/en/sql-reference/aggregate-functions/reference/uniq',
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
name: 'User-Defined Functions',
|
|
172
|
+
dialects: ['clickhouse'],
|
|
173
|
+
category: 'procedural-language',
|
|
174
|
+
description: 'Lambda-expression-based SQL UDFs defined via CREATE FUNCTION <name> AS (args) -> <expression>, reusable across queries by name. Not implemented in this ORM\'s ClickHouse dialect; reachable only via raw SQL.',
|
|
175
|
+
installCommand: 'CREATE FUNCTION my_func AS (x, y) -> x + y',
|
|
176
|
+
isNativeSqlExtension: false,
|
|
177
|
+
docsUrl: 'https://clickhouse.com/docs/en/sql-reference/statements/create/function',
|
|
178
|
+
},
|
|
179
|
+
// ---------------------------------------------------------------------
|
|
180
|
+
// SQLite
|
|
181
|
+
// ---------------------------------------------------------------------
|
|
182
|
+
{
|
|
183
|
+
name: 'FTS5',
|
|
184
|
+
dialects: ['sqlite'],
|
|
185
|
+
category: 'full-text-search',
|
|
186
|
+
description: 'Full-text search virtual table module (CREATE VIRTUAL TABLE ... USING fts5(...)) with MATCH queries, BM25 ranking, snippet/highlight functions, and porter/unicode61/trigram/ascii tokenizers. Compiled into better-sqlite3 by default (no separate install statement). Implemented in this ORM\'s SQLite dialect and sqlite-advanced.ts (createFTS5Table, createFTS5FromTable, dropFTS5Table, rebuildFTS5, optimizeFTS5, fts5Search; also used by createFulltextIndex).',
|
|
187
|
+
isNativeSqlExtension: false,
|
|
188
|
+
docsUrl: 'https://www.sqlite.org/fts5.html',
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
name: 'R-Tree',
|
|
192
|
+
dialects: ['sqlite'],
|
|
193
|
+
category: 'spatial-gis',
|
|
194
|
+
description: 'Spatial indexing virtual table module (CREATE VIRTUAL TABLE ... USING rtree(id, minX, maxX, ...)) for efficient range/bounding-box queries. Compiled into better-sqlite3 by default (no separate install statement). Implemented in this ORM\'s SQLite dialect (createSpatialIndex builds the rtree virtual table); auxiliary (+col) columns and rtree_i32 are not currently supported by that helper.',
|
|
195
|
+
isNativeSqlExtension: false,
|
|
196
|
+
docsUrl: 'https://www.sqlite.org/rtree.html',
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
name: 'JSON1',
|
|
200
|
+
dialects: ['sqlite'],
|
|
201
|
+
category: 'json',
|
|
202
|
+
description: 'JSON functions and table-valued functions (json_extract, json_set, json_remove, json_each, json_tree, json_valid, json_type) for querying and manipulating JSON stored in TEXT columns. Compiled into better-sqlite3 by default (no separate install statement) and integrated as SQLite\'s default; ~3.38+. Implemented in this ORM (sqlite-advanced.ts JSON1 section, used by json path-query/containment helpers); json_group_array/json_group_object aggregates and json_patch are not yet wired up.',
|
|
203
|
+
isNativeSqlExtension: false,
|
|
204
|
+
minVersion: '3.38+ (built-in by default; loadable extension on earlier versions)',
|
|
205
|
+
docsUrl: 'https://www.sqlite.org/json1.html',
|
|
206
|
+
},
|
|
207
|
+
];
|