turbine-orm 0.49.0 → 0.50.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/README.md +122 -39
- package/dist/cjs/adapters/cockroachdb.d.ts +39 -0
- package/dist/cjs/adapters/index.d.ts +110 -0
- package/dist/cjs/adapters/yugabytedb.d.ts +51 -0
- package/dist/cjs/cli/config.d.ts +181 -0
- package/dist/cjs/cli/config.js +32 -6
- package/dist/cjs/cli/destructive.d.ts +38 -0
- package/dist/cjs/cli/index.d.ts +359 -0
- package/dist/cjs/cli/index.js +228 -56
- package/dist/cjs/cli/loader.d.ts +61 -0
- package/dist/cjs/cli/mcp.d.ts +42 -0
- package/dist/cjs/cli/migrate.d.ts +356 -0
- package/dist/cjs/cli/migrate.js +131 -40
- package/dist/cjs/cli/observe-ui.d.ts +1 -0
- package/dist/cjs/cli/observe-ui.js +14 -5
- package/dist/cjs/cli/observe.d.ts +25 -0
- package/dist/cjs/cli/observe.js +49 -12
- package/dist/cjs/cli/pii-tags.d.ts +53 -0
- package/dist/cjs/cli/prisma-report.d.ts +33 -0
- package/dist/cjs/cli/prisma-report.js +73 -0
- package/dist/cjs/cli/prisma-resolve.d.ts +106 -0
- package/dist/cjs/cli/prisma-resolve.js +1 -0
- package/dist/cjs/cli/prisma-schema.d.ts +176 -0
- package/dist/cjs/cli/prisma-schema.js +82 -4
- package/dist/cjs/cli/rate-limit.d.ts +32 -0
- package/dist/cjs/cli/rate-limit.js +45 -0
- package/dist/cjs/cli/studio-demo.d.ts +43 -0
- package/dist/cjs/cli/studio-ui.generated.d.ts +1 -0
- package/dist/cjs/cli/studio.d.ts +207 -0
- package/dist/cjs/cli/studio.js +136 -71
- package/dist/cjs/cli/ui.d.ts +73 -0
- package/dist/cjs/cli/ui.js +51 -9
- package/dist/cjs/client.d.ts +837 -0
- package/dist/cjs/client.js +3 -0
- package/dist/cjs/dialect.d.ts +516 -0
- package/dist/cjs/dialect.js +37 -12
- package/dist/cjs/errors.d.ts +370 -0
- package/dist/cjs/generate.d.ts +137 -0
- package/dist/cjs/generate.js +39 -6
- package/dist/cjs/index-advisor.d.ts +153 -0
- package/dist/cjs/index-stats.d.ts +384 -0
- package/dist/cjs/index.d.ts +55 -0
- package/dist/cjs/index.js +7 -2
- package/dist/cjs/introspect.d.ts +269 -0
- package/dist/cjs/mssql.d.ts +232 -0
- package/dist/cjs/mssql.js +6 -0
- package/dist/cjs/mysql.d.ts +173 -0
- package/dist/cjs/mysql.js +16 -0
- package/dist/cjs/nested-write.d.ts +96 -0
- package/dist/cjs/nested-write.js +414 -24
- package/dist/cjs/observe.d.ts +115 -0
- package/dist/cjs/optional-peer-import.d.cts +72 -0
- package/dist/cjs/pipeline-submittable.d.ts +93 -0
- package/dist/cjs/pipeline.d.ts +71 -0
- package/dist/cjs/powdb-introspect.d.ts +84 -0
- package/dist/cjs/powdb.d.ts +931 -0
- package/dist/cjs/powdb.js +106 -21
- package/dist/cjs/powql.d.ts +592 -0
- package/dist/cjs/powql.js +42 -6
- package/dist/cjs/prisma-compat.d.ts +283 -0
- package/dist/cjs/prisma-compat.js +167 -9
- package/dist/cjs/query/aggregates.d.ts +92 -0
- package/dist/cjs/query/aggregates.js +7 -3
- package/dist/cjs/query/batched-loader.d.ts +193 -0
- package/dist/cjs/query/builder.d.ts +849 -0
- package/dist/cjs/query/builder.js +571 -65
- package/dist/cjs/query/compound-unique.d.ts +51 -0
- package/dist/cjs/query/deferred.d.ts +223 -0
- package/dist/cjs/query/filters.d.ts +201 -0
- package/dist/cjs/query/index.d.ts +14 -0
- package/dist/cjs/query/index.js +6 -1
- package/dist/cjs/query/relations.d.ts +609 -0
- package/dist/cjs/query/relations.js +693 -46
- package/dist/cjs/query/types.d.ts +1300 -0
- package/dist/cjs/query/utils.d.ts +209 -0
- package/dist/cjs/query/utils.js +208 -1
- package/dist/cjs/query/warn-registry.d.ts +68 -0
- package/dist/cjs/query/warn-registry.js +9 -0
- package/dist/cjs/query/where-compile.d.ts +139 -0
- package/dist/cjs/query/where.d.ts +548 -0
- package/dist/cjs/query/where.js +58 -22
- package/dist/cjs/query/writes.d.ts +172 -0
- package/dist/cjs/query/writes.js +105 -12
- package/dist/cjs/realtime.d.ts +70 -0
- package/dist/cjs/schema-builder.d.ts +354 -0
- package/dist/cjs/schema-metadata.d.ts +83 -0
- package/dist/cjs/schema-sql.d.ts +217 -0
- package/dist/cjs/schema-sql.js +23 -5
- package/dist/cjs/schema.d.ts +356 -0
- package/dist/cjs/schema.js +125 -0
- package/dist/cjs/seed.d.ts +15 -0
- package/dist/cjs/serverless.d.ts +142 -0
- package/dist/cjs/sqlite.d.ts +143 -0
- package/dist/cjs/sqlite.js +4 -0
- package/dist/cjs/typed-sql.d.ts +102 -0
- package/dist/cli/config.d.ts +18 -4
- package/dist/cli/config.js +31 -6
- package/dist/cli/index.d.ts +123 -0
- package/dist/cli/index.js +223 -58
- package/dist/cli/migrate.d.ts +59 -10
- package/dist/cli/migrate.js +128 -41
- package/dist/cli/observe-ui.d.ts +1 -1
- package/dist/cli/observe-ui.js +14 -5
- package/dist/cli/observe.d.ts +7 -1
- package/dist/cli/observe.js +48 -12
- package/dist/cli/prisma-report.d.ts +14 -0
- package/dist/cli/prisma-report.js +72 -0
- package/dist/cli/prisma-resolve.d.ts +6 -0
- package/dist/cli/prisma-resolve.js +1 -0
- package/dist/cli/prisma-schema.d.ts +62 -2
- package/dist/cli/prisma-schema.js +81 -4
- package/dist/cli/rate-limit.d.ts +32 -0
- package/dist/cli/rate-limit.js +40 -0
- package/dist/cli/studio.d.ts +5 -5
- package/dist/cli/studio.js +135 -70
- package/dist/cli/ui.d.ts +1 -1
- package/dist/cli/ui.js +51 -9
- package/dist/client.d.ts +40 -0
- package/dist/client.js +3 -0
- package/dist/dialect.d.ts +17 -1
- package/dist/dialect.js +37 -12
- package/dist/generate.js +40 -7
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/mssql.js +6 -0
- package/dist/mysql.js +16 -0
- package/dist/nested-write.d.ts +2 -0
- package/dist/nested-write.js +415 -25
- package/dist/powdb.d.ts +4 -2
- package/dist/powdb.js +106 -21
- package/dist/powql.d.ts +5 -0
- package/dist/powql.js +42 -6
- package/dist/prisma-compat.d.ts +2 -0
- package/dist/prisma-compat.js +166 -8
- package/dist/query/aggregates.js +7 -3
- package/dist/query/builder.d.ts +292 -21
- package/dist/query/builder.js +570 -64
- package/dist/query/deferred.d.ts +39 -0
- package/dist/query/index.d.ts +1 -1
- package/dist/query/index.js +1 -1
- package/dist/query/relations.d.ts +173 -5
- package/dist/query/relations.js +688 -47
- package/dist/query/types.d.ts +123 -39
- package/dist/query/utils.d.ts +116 -0
- package/dist/query/utils.js +198 -0
- package/dist/query/warn-registry.d.ts +9 -0
- package/dist/query/warn-registry.js +9 -0
- package/dist/query/where.d.ts +38 -1
- package/dist/query/where.js +58 -23
- package/dist/query/writes.d.ts +42 -1
- package/dist/query/writes.js +104 -13
- package/dist/schema-sql.d.ts +14 -0
- package/dist/schema-sql.js +23 -5
- package/dist/schema.d.ts +38 -0
- package/dist/schema.js +123 -0
- package/dist/sqlite.js +4 -0
- package/package.json +77 -28
package/dist/generate.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
12
12
|
import { dirname, join, relative, resolve } from 'node:path';
|
|
13
|
-
import { pgTypeToTs, singularize, snakeToPascal, withDbFieldNames, } from './schema.js';
|
|
13
|
+
import { pgTypeToTs, singularize, snakeToPascal, timeOfDayKind, withDbFieldNames, } from './schema.js';
|
|
14
14
|
/** Get the TypeScript type name for a table (singularized PascalCase) */
|
|
15
15
|
function entityName(tableName) {
|
|
16
16
|
return snakeToPascal(singularize(tableName));
|
|
@@ -33,6 +33,30 @@ function columnTsType(col, enums) {
|
|
|
33
33
|
}
|
|
34
34
|
return col.tsType;
|
|
35
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Resolve the TypeScript type a column accepts on the WRITE path (the `*Create`
|
|
38
|
+
* / `*Update` input types), which is wider than the row type for time-of-day
|
|
39
|
+
* columns.
|
|
40
|
+
*
|
|
41
|
+
* A `time` / `timetz` column reads back as a `string` (`'09:00:00'`), so the
|
|
42
|
+
* row type stays `string`. On write the runtime also accepts a JS `Date` and
|
|
43
|
+
* narrows it to its UTC time of day (see `coerceWriteValue` in
|
|
44
|
+
* query/writes.ts), matching Prisma, which types a `DateTime @db.Time(6)`
|
|
45
|
+
* field as a `Date`. Consumers porting from Prisma pass Dates, so the input
|
|
46
|
+
* type has to admit them. Every other column is unchanged.
|
|
47
|
+
*/
|
|
48
|
+
function writeColumnTsType(col, enums) {
|
|
49
|
+
const tsType = columnTsType(col, enums);
|
|
50
|
+
const dt = col.dialectType ?? col.pgType;
|
|
51
|
+
const isArray = col.isArray || dt.startsWith('_');
|
|
52
|
+
const base = isArray && dt.startsWith('_') ? dt.slice(1) : dt;
|
|
53
|
+
if (!timeOfDayKind(base))
|
|
54
|
+
return tsType;
|
|
55
|
+
// A `time[]` column accepts a Date per element (the bind rewrite runs
|
|
56
|
+
// element-wise, see coerceTemporalValue in query/utils.ts).
|
|
57
|
+
const widened = isArray ? '(string | Date)[]' : 'string | Date';
|
|
58
|
+
return col.nullable ? `${widened} | null` : widened;
|
|
59
|
+
}
|
|
36
60
|
/** Escape a value for embedding in a single-quoted TypeScript string literal */
|
|
37
61
|
function escSQ(value) {
|
|
38
62
|
return value.replace(/\\/g, '\\\\').replace(/'/g, "\\'");
|
|
@@ -333,10 +357,10 @@ export function generateTypes(schema, options) {
|
|
|
333
357
|
if (isOptional) {
|
|
334
358
|
const reason = isPk ? 'auto-generated' : col.hasDefault ? 'has default' : 'nullable';
|
|
335
359
|
lines.push(` /** Optional: ${reason} */`);
|
|
336
|
-
lines.push(` ${quoteIfNeeded(col.field)}?: ${
|
|
360
|
+
lines.push(` ${quoteIfNeeded(col.field)}?: ${writeColumnTsType(col, schema.enums)};`);
|
|
337
361
|
}
|
|
338
362
|
else {
|
|
339
|
-
lines.push(` ${quoteIfNeeded(col.field)}: ${
|
|
363
|
+
lines.push(` ${quoteIfNeeded(col.field)}: ${writeColumnTsType(col, schema.enums)};`);
|
|
340
364
|
}
|
|
341
365
|
}
|
|
342
366
|
lines.push('};');
|
|
@@ -348,7 +372,7 @@ export function generateTypes(schema, options) {
|
|
|
348
372
|
lines.push(`/** Input type for updating a row in \`${table.name}\` */`);
|
|
349
373
|
lines.push(`export type ${typeName}Update = {`);
|
|
350
374
|
for (const col of nonPkCols) {
|
|
351
|
-
lines.push(` ${quoteIfNeeded(col.field)}?: ${updateFieldType(
|
|
375
|
+
lines.push(` ${quoteIfNeeded(col.field)}?: ${updateFieldType(writeColumnTsType(col, schema.enums))};`);
|
|
352
376
|
}
|
|
353
377
|
lines.push('};');
|
|
354
378
|
lines.push('');
|
|
@@ -566,8 +590,14 @@ function zodScalar(ts) {
|
|
|
566
590
|
* Base Zod expression for a column, resolving enums → `z.enum([...])`, arrays →
|
|
567
591
|
* `.array()`, and vectors → `z.array(z.number())`. Does NOT append
|
|
568
592
|
* `.nullable()` / `.optional()` — callers layer those on per-schema.
|
|
593
|
+
*
|
|
594
|
+
* `forWrite` mirrors {@link writeColumnTsType}: the Create/Update schemas
|
|
595
|
+
* validate WRITE input, where a `time` / `timetz` column also accepts a JS
|
|
596
|
+
* `Date` (narrowed to its UTC time of day at bind time), so a bare
|
|
597
|
+
* `z.string()` there would reject a value the runtime happily writes. The
|
|
598
|
+
* full-row schema keeps `z.string()`, because that is what a read returns.
|
|
569
599
|
*/
|
|
570
|
-
function zodBaseType(col, enums) {
|
|
600
|
+
function zodBaseType(col, enums, forWrite = false) {
|
|
571
601
|
const dt = col.dialectType ?? col.pgType;
|
|
572
602
|
const isArray = col.isArray || dt.startsWith('_');
|
|
573
603
|
const base = isArray && dt.startsWith('_') ? dt.slice(1) : dt;
|
|
@@ -575,6 +605,9 @@ function zodBaseType(col, enums) {
|
|
|
575
605
|
if (Object.hasOwn(enums, base)) {
|
|
576
606
|
expr = `z.enum([${enums[base].map((l) => `'${escSQ(l)}'`).join(', ')}])`;
|
|
577
607
|
}
|
|
608
|
+
else if (forWrite && timeOfDayKind(base)) {
|
|
609
|
+
expr = 'z.union([z.string(), z.date()])';
|
|
610
|
+
}
|
|
578
611
|
else {
|
|
579
612
|
expr = zodScalar(pgTypeToTs(base, false));
|
|
580
613
|
}
|
|
@@ -616,7 +649,7 @@ export function generateZod(schema, options) {
|
|
|
616
649
|
if (col.isGeneratedStored)
|
|
617
650
|
continue;
|
|
618
651
|
const isPk = table.primaryKey.includes(col.name);
|
|
619
|
-
let expr = zodBaseType(col, schema.enums);
|
|
652
|
+
let expr = zodBaseType(col, schema.enums, true);
|
|
620
653
|
if (col.nullable)
|
|
621
654
|
expr += '.nullable()';
|
|
622
655
|
if (col.hasDefault || col.nullable || isPk)
|
|
@@ -633,7 +666,7 @@ export function generateZod(schema, options) {
|
|
|
633
666
|
continue;
|
|
634
667
|
if (table.primaryKey.includes(col.name))
|
|
635
668
|
continue;
|
|
636
|
-
let expr = zodBaseType(col, schema.enums);
|
|
669
|
+
let expr = zodBaseType(col, schema.enums, true);
|
|
637
670
|
if (col.nullable)
|
|
638
671
|
expr += '.nullable()';
|
|
639
672
|
expr += '.optional()';
|
package/dist/index.d.ts
CHANGED
|
@@ -43,7 +43,7 @@ export { type IntrospectOptions, introspect } from './introspect.js';
|
|
|
43
43
|
export { executeNestedCreate, executeNestedUpdate, hasRelationFields, type NestedWriteContext, } from './nested-write.js';
|
|
44
44
|
export { HttpJsonSink, type HttpJsonSinkOptions, type MetricsFlushBatch, type MetricsFlushRow, type ObserveConfig, type ObserveHandle, type ObserveSink, PgMetricsSink, type PgMetricsSinkOptions, } from './observe.js';
|
|
45
45
|
export { executePipeline, type PipelineOptions, type PipelineResults, pipelineSupported } from './pipeline.js';
|
|
46
|
-
export { type AggregateArgs, type AggregateResult, type ArrayFilter, type ColumnRef, type ConnectOrCreateOp, type CountArgs, type CreateArgs, type CreateDataInput, type CreateManyArgs, type DeferredQuery, type DeleteArgs, type DeleteManyArgs, type FieldResult, type FindManyArgs, type FindManyStreamArgs, type FindUniqueArgs, type GlobalFilters, type GroupByAggregateSpec, type GroupByArgs, type GroupByDistinctOn, type GroupByResult, type HavingClause, type JsonFilter, type JsonPathAggregateTarget, type JsonPathGroupKey, type JsonPathOrderBy, type MiddlewareFn, type NestedCreateOp, type NestedUpdateOp, type NestedUpdateOpItem, type NestedUpsertOpItem, type OmitResult, type OrderByClause, type OrderByObject, type OrderDirection, type QueryEvent, type QueryEventListener, QueryInterface, type QueryResult, type RelationDescriptor, type RelationFilter, type RelationLoadStrategy, type RelationPickBy, type RelationPickOrderBy, type SelectResult, type SkipGlobalFilters, type TextSearchFilter, type TypedWithClause, type UpdateArgs, type UpdateDataInput, type UpdateInput, type UpdateManyArgs, type UpdateOperatorInput, type UpsertArgs, type VectorDistanceFilter, type VectorFilter, type VectorMetric, type VectorOrderBy, type VectorOrderByDistance, type WhereClause, type WhereOperator, type WhereValue, type WithClause, type WithOptions, type WithOrderByObject, type WithResult, } from './query/index.js';
|
|
46
|
+
export { type AggregateArgs, type AggregateResult, type ArrayFilter, AUTO_ASSUMED_ROUND_TRIP_MS, AUTO_JOIN_PENALTY_MS_PER_ROW, AUTO_TO_ONE_JOIN_MAX_ROWS, AUTO_TO_ONE_JOIN_ROWS_MAX, AUTO_TO_ONE_JOIN_ROWS_MIN, type ColumnRef, type ConnectOrCreateOp, type CountArgs, type CreateArgs, type CreateDataInput, type CreateManyArgs, type DeferredQuery, type DeleteArgs, type DeleteManyArgs, type FieldResult, type FindManyArgs, type FindManyStreamArgs, type FindUniqueArgs, type GlobalFilters, type GroupByAggregateSpec, type GroupByArgs, type GroupByDistinctOn, type GroupByResult, type HavingClause, type JsonFilter, type JsonPathAggregateTarget, type JsonPathGroupKey, type JsonPathOrderBy, type MiddlewareFn, type NestedCreateOp, type NestedUpdateOp, type NestedUpdateOpItem, type NestedUpsertOpItem, type OmitResult, type OrderByClause, type OrderByObject, type OrderDirection, type QueryEvent, type QueryEventListener, QueryInterface, type QueryResult, type RelationDescriptor, type RelationFilter, type RelationLoadStrategy, type RelationPickBy, type RelationPickOrderBy, type SelectResult, type SkipGlobalFilters, type TextSearchFilter, type TypedWithClause, type UpdateArgs, type UpdateDataInput, type UpdateInput, type UpdateManyArgs, type UpdateOperatorInput, type UpsertArgs, type VectorDistanceFilter, type VectorFilter, type VectorMetric, type VectorOrderBy, type VectorOrderByDistance, type WhereClause, type WhereOperator, type WhereValue, type WithClause, type WithOptions, type WithOrderByObject, type WithResult, } from './query/index.js';
|
|
47
47
|
export { type ActiveSubscription, type NotificationHandler, type Subscription, validateChannel } from './realtime.js';
|
|
48
48
|
export type { CheckMetadata, ColumnMetadata, IndexMetadata, PrismaCompatMap, PrismaModelMap, PrismaRelationMap, ReferentialAction, RelationDef, SchemaMetadata, TableMetadata, } from './schema.js';
|
|
49
49
|
export { camelToSnake, isDateType, normalizeKeyColumns, pgArrayType, pgTypeToTs, singularize, snakeToCamel, snakeToPascal, withDbFieldNames, } from './schema.js';
|
package/dist/index.js
CHANGED
|
@@ -49,7 +49,7 @@ export { HttpJsonSink, PgMetricsSink, } from './observe.js';
|
|
|
49
49
|
// Pipeline
|
|
50
50
|
export { executePipeline, pipelineSupported } from './pipeline.js';
|
|
51
51
|
// Query builder
|
|
52
|
-
export { QueryInterface, } from './query/index.js';
|
|
52
|
+
export { AUTO_ASSUMED_ROUND_TRIP_MS, AUTO_JOIN_PENALTY_MS_PER_ROW, AUTO_TO_ONE_JOIN_MAX_ROWS, AUTO_TO_ONE_JOIN_ROWS_MAX, AUTO_TO_ONE_JOIN_ROWS_MIN, QueryInterface, } from './query/index.js';
|
|
53
53
|
// Realtime — LISTEN/NOTIFY pub/sub
|
|
54
54
|
export { validateChannel } from './realtime.js';
|
|
55
55
|
// Schema utilities
|
package/dist/mssql.js
CHANGED
|
@@ -480,6 +480,12 @@ export const mssqlDialect = {
|
|
|
480
480
|
// round-trip (Phase-0 'output' strategy, executed like 'returning').
|
|
481
481
|
resultStrategy: 'output',
|
|
482
482
|
supportsReturning: false,
|
|
483
|
+
// MERGE can carry `WHEN MATCHED AND <pred>`, but the predicate the builder
|
|
484
|
+
// hands over is written in UNQUALIFIED column references, which are ambiguous
|
|
485
|
+
// between the MERGE target (T) and source (S) aliases. `buildUpsertStatement`
|
|
486
|
+
// below therefore emits no predicate; reporting false keeps the builder from
|
|
487
|
+
// compiling one (and from binding its now-orphaned parameters).
|
|
488
|
+
supportsUpsertUpdateWhere: false,
|
|
483
489
|
supportsILike: false,
|
|
484
490
|
supportsVector: false,
|
|
485
491
|
// SQL Server full-text is `CONTAINS`/`FREETEXT` over a full-text catalog: a
|
package/dist/mysql.js
CHANGED
|
@@ -364,6 +364,10 @@ export const mysqlDialect = {
|
|
|
364
364
|
// No RETURNING → run the write, then re-SELECT by PK/where (Phase-0 reselect).
|
|
365
365
|
resultStrategy: 'reselect',
|
|
366
366
|
supportsReturning: false,
|
|
367
|
+
// `ON DUPLICATE KEY UPDATE` has no predicate slot, so `buildUpsertStatement`
|
|
368
|
+
// below cannot emit `input.updateWhere`. Reporting false keeps the builder
|
|
369
|
+
// from compiling one (and from binding its now-orphaned parameters).
|
|
370
|
+
supportsUpsertUpdateWhere: false,
|
|
367
371
|
supportsILike: false,
|
|
368
372
|
supportsVector: false,
|
|
369
373
|
// MySQL full-text is `MATCH(col) AGAINST(...)` over a FULLTEXT index: a
|
|
@@ -403,6 +407,18 @@ export const mysqlDialect = {
|
|
|
403
407
|
quoteIdentifier(name) {
|
|
404
408
|
return `\`${name.replace(/`/g, '``')}\``;
|
|
405
409
|
},
|
|
410
|
+
/**
|
|
411
|
+
* MySQL is NOT Postgres here: unless the server runs with
|
|
412
|
+
* `NO_BACKSLASH_ESCAPES`, `\` is an escape character inside a string literal,
|
|
413
|
+
* so doubling only `'` (the inherited Postgres rule) leaves a value ending in
|
|
414
|
+
* a backslash able to escape its own closing quote. Escape the backslash
|
|
415
|
+
* first, then the quote; every other byte is safe raw. The only caller is
|
|
416
|
+
* `buildJsonObject` (relation / column names from schema metadata), so this
|
|
417
|
+
* is defence in depth rather than a user-value path.
|
|
418
|
+
*/
|
|
419
|
+
escapeStringLiteral(value) {
|
|
420
|
+
return value.replace(/\\/g, '\\\\').replace(/'/g, "''");
|
|
421
|
+
},
|
|
406
422
|
buildJsonObject(pairs) {
|
|
407
423
|
const args = pairs.map(([key, expr]) => `'${this.escapeStringLiteral(key)}', ${expr}`);
|
|
408
424
|
return `JSON_OBJECT(${args.join(', ')})`;
|
package/dist/nested-write.d.ts
CHANGED
|
@@ -29,6 +29,7 @@ export interface NestedWriteContext {
|
|
|
29
29
|
}): Promise<T>;
|
|
30
30
|
createMany(args: {
|
|
31
31
|
data: Partial<T>[];
|
|
32
|
+
skipDuplicates?: boolean;
|
|
32
33
|
}): Promise<T[]>;
|
|
33
34
|
update(args: {
|
|
34
35
|
where: Record<string, unknown>;
|
|
@@ -51,6 +52,7 @@ export interface NestedWriteContext {
|
|
|
51
52
|
}>;
|
|
52
53
|
findMany(args: {
|
|
53
54
|
where: Record<string, unknown>;
|
|
55
|
+
warnOnUnlimited?: boolean;
|
|
54
56
|
}): Promise<T[]>;
|
|
55
57
|
findUnique(args: {
|
|
56
58
|
where: Record<string, unknown>;
|