drizzle-orm 0.40.0-bbf78ae → 0.40.0-f8a2f3c
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/aws-data-api/pg/driver.cjs +1 -5
- package/aws-data-api/pg/driver.cjs.map +1 -1
- package/aws-data-api/pg/driver.d.cts +0 -1
- package/aws-data-api/pg/driver.d.ts +0 -1
- package/aws-data-api/pg/driver.js +1 -5
- package/aws-data-api/pg/driver.js.map +1 -1
- package/aws-data-api/pg/session.cjs +4 -15
- package/aws-data-api/pg/session.cjs.map +1 -1
- package/aws-data-api/pg/session.d.cts +3 -13
- package/aws-data-api/pg/session.d.ts +3 -13
- package/aws-data-api/pg/session.js +4 -15
- package/aws-data-api/pg/session.js.map +1 -1
- package/bun-sql/driver.cjs +1 -5
- package/bun-sql/driver.cjs.map +1 -1
- package/bun-sql/driver.js +1 -5
- package/bun-sql/driver.js.map +1 -1
- package/bun-sql/session.cjs +9 -21
- package/bun-sql/session.cjs.map +1 -1
- package/bun-sql/session.d.cts +3 -12
- package/bun-sql/session.d.ts +3 -12
- package/bun-sql/session.js +9 -21
- package/bun-sql/session.js.map +1 -1
- package/neon-http/driver.cjs +2 -9
- package/neon-http/driver.cjs.map +1 -1
- package/neon-http/driver.d.cts +0 -2
- package/neon-http/driver.d.ts +0 -2
- package/neon-http/driver.js +2 -9
- package/neon-http/driver.js.map +1 -1
- package/neon-http/session.cjs +15 -25
- package/neon-http/session.cjs.map +1 -1
- package/neon-http/session.d.cts +3 -12
- package/neon-http/session.d.ts +3 -12
- package/neon-http/session.js +15 -25
- package/neon-http/session.js.map +1 -1
- package/neon-serverless/driver.cjs +2 -9
- package/neon-serverless/driver.cjs.map +1 -1
- package/neon-serverless/driver.d.cts +0 -2
- package/neon-serverless/driver.d.ts +0 -2
- package/neon-serverless/driver.js +2 -9
- package/neon-serverless/driver.js.map +1 -1
- package/neon-serverless/session.cjs +7 -21
- package/neon-serverless/session.cjs.map +1 -1
- package/neon-serverless/session.d.cts +3 -12
- package/neon-serverless/session.d.ts +3 -12
- package/neon-serverless/session.js +7 -21
- package/neon-serverless/session.js.map +1 -1
- package/node-postgres/driver.cjs +2 -9
- package/node-postgres/driver.cjs.map +1 -1
- package/node-postgres/driver.d.cts +0 -2
- package/node-postgres/driver.d.ts +0 -2
- package/node-postgres/driver.js +2 -9
- package/node-postgres/driver.js.map +1 -1
- package/node-postgres/session.cjs +6 -19
- package/node-postgres/session.cjs.map +1 -1
- package/node-postgres/session.d.cts +3 -13
- package/node-postgres/session.d.ts +3 -13
- package/node-postgres/session.js +6 -19
- package/node-postgres/session.js.map +1 -1
- package/package.json +135 -196
- package/pg-core/db.cjs +0 -1
- package/pg-core/db.cjs.map +1 -1
- package/pg-core/db.d.cts +0 -4
- package/pg-core/db.d.ts +0 -4
- package/pg-core/db.js +0 -1
- package/pg-core/db.js.map +1 -1
- package/pg-core/query-builders/delete.cjs +1 -6
- package/pg-core/query-builders/delete.cjs.map +1 -1
- package/pg-core/query-builders/delete.d.cts +1 -2
- package/pg-core/query-builders/delete.d.ts +1 -2
- package/pg-core/query-builders/delete.js +1 -6
- package/pg-core/query-builders/delete.js.map +1 -1
- package/pg-core/query-builders/insert.cjs +1 -6
- package/pg-core/query-builders/insert.cjs.map +1 -1
- package/pg-core/query-builders/insert.d.cts +1 -2
- package/pg-core/query-builders/insert.d.ts +1 -2
- package/pg-core/query-builders/insert.js +1 -6
- package/pg-core/query-builders/insert.js.map +1 -1
- package/pg-core/query-builders/select.cjs +5 -31
- package/pg-core/query-builders/select.cjs.map +1 -1
- package/pg-core/query-builders/select.d.cts +2 -11
- package/pg-core/query-builders/select.d.ts +2 -11
- package/pg-core/query-builders/select.js +5 -31
- package/pg-core/query-builders/select.js.map +1 -1
- package/pg-core/query-builders/select.types.cjs.map +1 -1
- package/pg-core/query-builders/select.types.d.cts +0 -7
- package/pg-core/query-builders/select.types.d.ts +0 -7
- package/pg-core/query-builders/update.cjs +1 -6
- package/pg-core/query-builders/update.cjs.map +1 -1
- package/pg-core/query-builders/update.d.cts +3 -4
- package/pg-core/query-builders/update.d.ts +3 -4
- package/pg-core/query-builders/update.js +1 -6
- package/pg-core/query-builders/update.js.map +1 -1
- package/pg-core/session.cjs +1 -58
- package/pg-core/session.cjs.map +1 -1
- package/pg-core/session.d.cts +3 -14
- package/pg-core/session.d.ts +3 -14
- package/pg-core/session.js +2 -59
- package/pg-core/session.js.map +1 -1
- package/pg-core/utils.cjs +0 -16
- package/pg-core/utils.cjs.map +1 -1
- package/pg-core/utils.d.cts +4 -8
- package/pg-core/utils.d.ts +4 -8
- package/pg-core/utils.js +1 -16
- package/pg-core/utils.js.map +1 -1
- package/pg-proxy/driver.cjs +2 -7
- package/pg-proxy/driver.cjs.map +1 -1
- package/pg-proxy/driver.js +2 -7
- package/pg-proxy/driver.js.map +1 -1
- package/pg-proxy/session.cjs +5 -15
- package/pg-proxy/session.cjs.map +1 -1
- package/pg-proxy/session.d.cts +3 -12
- package/pg-proxy/session.d.ts +3 -12
- package/pg-proxy/session.js +5 -15
- package/pg-proxy/session.js.map +1 -1
- package/pglite/driver.cjs +2 -9
- package/pglite/driver.cjs.map +1 -1
- package/pglite/driver.d.cts +0 -2
- package/pglite/driver.d.ts +0 -2
- package/pglite/driver.js +2 -9
- package/pglite/driver.js.map +1 -1
- package/pglite/session.cjs +7 -19
- package/pglite/session.cjs.map +1 -1
- package/pglite/session.d.cts +3 -12
- package/pglite/session.d.ts +3 -12
- package/pglite/session.js +7 -19
- package/pglite/session.js.map +1 -1
- package/postgres-js/driver.cjs +1 -5
- package/postgres-js/driver.cjs.map +1 -1
- package/postgres-js/driver.js +1 -5
- package/postgres-js/driver.js.map +1 -1
- package/postgres-js/session.cjs +6 -18
- package/postgres-js/session.cjs.map +1 -1
- package/postgres-js/session.d.cts +3 -12
- package/postgres-js/session.d.ts +3 -12
- package/postgres-js/session.js +6 -18
- package/postgres-js/session.js.map +1 -1
- package/prisma/pg/session.cjs +1 -1
- package/prisma/pg/session.cjs.map +1 -1
- package/prisma/pg/session.js +1 -1
- package/prisma/pg/session.js.map +1 -1
- package/query-builders/query-builder.cjs.map +1 -1
- package/query-builders/query-builder.d.cts +1 -2
- package/query-builders/query-builder.d.ts +1 -2
- package/query-builders/query-builder.js.map +1 -1
- package/sql/sql.cjs +0 -7
- package/sql/sql.cjs.map +1 -1
- package/sql/sql.js +0 -7
- package/sql/sql.js.map +1 -1
- package/subquery.cjs +3 -4
- package/subquery.cjs.map +1 -1
- package/subquery.d.cts +1 -2
- package/subquery.d.ts +1 -2
- package/subquery.js +3 -4
- package/subquery.js.map +1 -1
- package/utils.cjs.map +1 -1
- package/utils.d.cts +0 -2
- package/utils.d.ts +0 -2
- package/utils.js.map +1 -1
- package/vercel-postgres/driver.cjs +2 -9
- package/vercel-postgres/driver.cjs.map +1 -1
- package/vercel-postgres/driver.d.cts +0 -2
- package/vercel-postgres/driver.d.ts +0 -2
- package/vercel-postgres/driver.js +2 -9
- package/vercel-postgres/driver.js.map +1 -1
- package/vercel-postgres/session.cjs +7 -21
- package/vercel-postgres/session.cjs.map +1 -1
- package/vercel-postgres/session.d.cts +3 -12
- package/vercel-postgres/session.d.ts +3 -12
- package/vercel-postgres/session.js +7 -21
- package/vercel-postgres/session.js.map +1 -1
- package/version.cjs +1 -1
- package/version.d.cts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/xata-http/driver.cjs +2 -7
- package/xata-http/driver.cjs.map +1 -1
- package/xata-http/driver.d.cts +0 -2
- package/xata-http/driver.d.ts +0 -2
- package/xata-http/driver.js +2 -7
- package/xata-http/driver.js.map +1 -1
- package/xata-http/session.cjs +7 -21
- package/xata-http/session.cjs.map +1 -1
- package/xata-http/session.d.cts +3 -12
- package/xata-http/session.d.ts +3 -12
- package/xata-http/session.js +7 -21
- package/xata-http/session.js.map +1 -1
- package/cache/core/cache.cjs +0 -47
- package/cache/core/cache.cjs.map +0 -1
- package/cache/core/cache.d.cts +0 -35
- package/cache/core/cache.d.ts +0 -35
- package/cache/core/cache.js +0 -22
- package/cache/core/cache.js.map +0 -1
- package/cache/core/index.cjs +0 -23
- package/cache/core/index.cjs.map +0 -1
- package/cache/core/index.d.cts +0 -1
- package/cache/core/index.d.ts +0 -1
- package/cache/core/index.js +0 -2
- package/cache/core/index.js.map +0 -1
- package/cache/core/types.cjs +0 -17
- package/cache/core/types.cjs.map +0 -1
- package/cache/core/types.d.cts +0 -22
- package/cache/core/types.d.ts +0 -22
- package/cache/core/types.js +0 -1
- package/cache/core/types.js.map +0 -1
- package/cache/upstash/cache.cjs +0 -98
- package/cache/upstash/cache.cjs.map +0 -1
- package/cache/upstash/cache.d.cts +0 -23
- package/cache/upstash/cache.d.ts +0 -23
- package/cache/upstash/cache.js +0 -73
- package/cache/upstash/cache.js.map +0 -1
- package/cache/upstash/index.cjs +0 -23
- package/cache/upstash/index.cjs.map +0 -1
- package/cache/upstash/index.d.cts +0 -1
- package/cache/upstash/index.d.ts +0 -1
- package/cache/upstash/index.js +0 -2
- package/cache/upstash/index.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/xata-http/session.ts"],"sourcesContent":["import type { SQLPluginResult, SQLQueryResult } from '@xata.io/client';\nimport
|
|
1
|
+
{"version":3,"sources":["../../src/xata-http/session.ts"],"sourcesContent":["import type { SQLPluginResult, SQLQueryResult } from '@xata.io/client';\nimport { entityKind } from '~/entity.ts';\nimport type { Logger } from '~/logger.ts';\nimport { NoopLogger } from '~/logger.ts';\nimport type { PgDialect } from '~/pg-core/dialect.ts';\nimport { PgTransaction } from '~/pg-core/index.ts';\nimport type { SelectedFieldsOrdered } from '~/pg-core/query-builders/select.types.ts';\nimport type { PgQueryResultHKT, PgTransactionConfig, PreparedQueryConfig } from '~/pg-core/session.ts';\nimport { PgPreparedQuery, PgSession } from '~/pg-core/session.ts';\nimport type { RelationalSchemaConfig, TablesRelationalConfig } from '~/relations.ts';\nimport { fillPlaceholders, type Query } from '~/sql/sql.ts';\nimport { mapResultRow } from '~/utils.ts';\n\nexport type XataHttpClient = {\n\tsql: SQLPluginResult;\n};\n\nexport interface QueryResults<ArrayMode extends 'json' | 'array'> {\n\trowCount: number;\n\trows: ArrayMode extends 'array' ? any[][] : Record<string, any>[];\n\trowAsArray: ArrayMode extends 'array' ? true : false;\n}\n\nexport class XataHttpPreparedQuery<T extends PreparedQueryConfig> extends PgPreparedQuery<T> {\n\tstatic override readonly [entityKind]: string = 'XataHttpPreparedQuery';\n\n\tconstructor(\n\t\tprivate client: XataHttpClient,\n\t\tquery: Query,\n\t\tprivate logger: Logger,\n\t\tprivate fields: SelectedFieldsOrdered | undefined,\n\t\tprivate _isResponseInArrayMode: boolean,\n\t\tprivate customResultMapper?: (rows: unknown[][]) => T['execute'],\n\t) {\n\t\tsuper(query);\n\t}\n\n\tasync execute(placeholderValues: Record<string, unknown> | undefined = {}): Promise<T['execute']> {\n\t\tconst params = fillPlaceholders(this.query.params, placeholderValues);\n\n\t\tthis.logger.logQuery(this.query.sql, params);\n\n\t\tconst { fields, client, query, customResultMapper, joinsNotNullableMap } = this;\n\n\t\tif (!fields && !customResultMapper) {\n\t\t\treturn await client.sql<Record<string, any>>({ statement: query.sql, params });\n\t\t\t// return { rowCount: result.records.length, rows: result.records, rowAsArray: false };\n\t\t}\n\n\t\tconst { rows, warning } = await client.sql({ statement: query.sql, params, responseType: 'array' });\n\t\tif (warning) console.warn(warning);\n\n\t\treturn customResultMapper\n\t\t\t? customResultMapper(rows as unknown[][])\n\t\t\t: rows.map((row) => mapResultRow<T['execute']>(fields!, row as unknown[], joinsNotNullableMap));\n\t}\n\n\tall(placeholderValues: Record<string, unknown> | undefined = {}): Promise<T['all']> {\n\t\tconst params = fillPlaceholders(this.query.params, placeholderValues);\n\t\tthis.logger.logQuery(this.query.sql, params);\n\t\treturn this.client.sql({ statement: this.query.sql, params, responseType: 'array' }).then((result) => result.rows);\n\t}\n\n\tvalues(placeholderValues: Record<string, unknown> | undefined = {}): Promise<T['values']> {\n\t\tconst params = fillPlaceholders(this.query.params, placeholderValues);\n\t\tthis.logger.logQuery(this.query.sql, params);\n\t\treturn this.client.sql({ statement: this.query.sql, params }).then((result) => result.records);\n\t}\n\n\t/** @internal */\n\tisResponseInArrayMode() {\n\t\treturn this._isResponseInArrayMode;\n\t}\n}\n\nexport interface XataHttpSessionOptions {\n\tlogger?: Logger;\n}\n\nexport class XataHttpSession<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig>\n\textends PgSession<\n\t\tXataHttpQueryResultHKT,\n\t\tTFullSchema,\n\t\tTSchema\n\t>\n{\n\tstatic override readonly [entityKind]: string = 'XataHttpSession';\n\n\tprivate logger: Logger;\n\n\tconstructor(\n\t\tprivate client: XataHttpClient,\n\t\tdialect: PgDialect,\n\t\tprivate schema: RelationalSchemaConfig<TSchema> | undefined,\n\t\tprivate options: XataHttpSessionOptions = {},\n\t) {\n\t\tsuper(dialect);\n\t\tthis.logger = options.logger ?? new NoopLogger();\n\t}\n\n\tprepareQuery<T extends PreparedQueryConfig = PreparedQueryConfig>(\n\t\tquery: Query,\n\t\tfields: SelectedFieldsOrdered | undefined,\n\t\tname: string | undefined,\n\t\tisResponseInArrayMode: boolean,\n\t\tcustomResultMapper?: (rows: unknown[][]) => T['execute'],\n\t): PgPreparedQuery<T> {\n\t\treturn new XataHttpPreparedQuery(\n\t\t\tthis.client,\n\t\t\tquery,\n\t\t\tthis.logger,\n\t\t\tfields,\n\t\t\tisResponseInArrayMode,\n\t\t\tcustomResultMapper,\n\t\t);\n\t}\n\n\tasync query(query: string, params: unknown[]): Promise<QueryResults<'array'>> {\n\t\tthis.logger.logQuery(query, params);\n\t\tconst result = await this.client.sql({ statement: query, params, responseType: 'array' });\n\n\t\treturn {\n\t\t\trowCount: result.rows.length,\n\t\t\trows: result.rows,\n\t\t\trowAsArray: true,\n\t\t};\n\t}\n\n\tasync queryObjects(query: string, params: unknown[]): Promise<QueryResults<'json'>> {\n\t\tconst result = await this.client.sql<Record<string, any>>({ statement: query, params });\n\n\t\treturn {\n\t\t\trowCount: result.records.length,\n\t\t\trows: result.records,\n\t\t\trowAsArray: false,\n\t\t};\n\t}\n\n\toverride async transaction<T>(\n\t\t_transaction: (tx: XataTransaction<TFullSchema, TSchema>) => Promise<T>,\n\t\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\t\t_config: PgTransactionConfig = {},\n\t): Promise<T> {\n\t\tthrow new Error('No transactions support in Xata Http driver');\n\t}\n}\n\nexport class XataTransaction<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig>\n\textends PgTransaction<\n\t\tXataHttpQueryResultHKT,\n\t\tTFullSchema,\n\t\tTSchema\n\t>\n{\n\tstatic override readonly [entityKind]: string = 'XataHttpTransaction';\n\n\toverride async transaction<T>(_transaction: (tx: XataTransaction<TFullSchema, TSchema>) => Promise<T>): Promise<T> {\n\t\tthrow new Error('No transactions support in Xata Http driver');\n\t}\n}\n\nexport interface XataHttpQueryResultHKT extends PgQueryResultHKT {\n\ttype: SQLQueryResult<this['row']>;\n}\n"],"mappings":"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","names":[]}
|
package/xata-http/session.d.cts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type { SQLPluginResult, SQLQueryResult } from '@xata.io/client';
|
|
2
|
-
import type { Cache } from "../cache/core/index.cjs";
|
|
3
2
|
import { entityKind } from "../entity.cjs";
|
|
4
3
|
import type { Logger } from "../logger.cjs";
|
|
5
4
|
import type { PgDialect } from "../pg-core/dialect.cjs";
|
|
6
5
|
import { PgTransaction } from "../pg-core/index.cjs";
|
|
7
|
-
import type { SelectedFieldsOrdered
|
|
6
|
+
import type { SelectedFieldsOrdered } from "../pg-core/query-builders/select.types.cjs";
|
|
8
7
|
import type { PgQueryResultHKT, PgTransactionConfig, PreparedQueryConfig } from "../pg-core/session.cjs";
|
|
9
8
|
import { PgPreparedQuery, PgSession } from "../pg-core/session.cjs";
|
|
10
9
|
import type { RelationalSchemaConfig, TablesRelationalConfig } from "../relations.cjs";
|
|
@@ -24,17 +23,13 @@ export declare class XataHttpPreparedQuery<T extends PreparedQueryConfig> extend
|
|
|
24
23
|
private _isResponseInArrayMode;
|
|
25
24
|
private customResultMapper?;
|
|
26
25
|
static readonly [entityKind]: string;
|
|
27
|
-
constructor(client: XataHttpClient, query: Query, logger: Logger,
|
|
28
|
-
type: 'select' | 'update' | 'delete' | 'insert';
|
|
29
|
-
tables: string[];
|
|
30
|
-
} | undefined, cacheConfig: WithCacheConfig | undefined, fields: SelectedFieldsOrdered | undefined, _isResponseInArrayMode: boolean, customResultMapper?: ((rows: unknown[][]) => T["execute"]) | undefined);
|
|
26
|
+
constructor(client: XataHttpClient, query: Query, logger: Logger, fields: SelectedFieldsOrdered | undefined, _isResponseInArrayMode: boolean, customResultMapper?: ((rows: unknown[][]) => T["execute"]) | undefined);
|
|
31
27
|
execute(placeholderValues?: Record<string, unknown> | undefined): Promise<T['execute']>;
|
|
32
28
|
all(placeholderValues?: Record<string, unknown> | undefined): Promise<T['all']>;
|
|
33
29
|
values(placeholderValues?: Record<string, unknown> | undefined): Promise<T['values']>;
|
|
34
30
|
}
|
|
35
31
|
export interface XataHttpSessionOptions {
|
|
36
32
|
logger?: Logger;
|
|
37
|
-
cache?: Cache;
|
|
38
33
|
}
|
|
39
34
|
export declare class XataHttpSession<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends PgSession<XataHttpQueryResultHKT, TFullSchema, TSchema> {
|
|
40
35
|
private client;
|
|
@@ -42,12 +37,8 @@ export declare class XataHttpSession<TFullSchema extends Record<string, unknown>
|
|
|
42
37
|
private options;
|
|
43
38
|
static readonly [entityKind]: string;
|
|
44
39
|
private logger;
|
|
45
|
-
private cache;
|
|
46
40
|
constructor(client: XataHttpClient, dialect: PgDialect, schema: RelationalSchemaConfig<TSchema> | undefined, options?: XataHttpSessionOptions);
|
|
47
|
-
prepareQuery<T extends PreparedQueryConfig = PreparedQueryConfig>(query: Query, fields: SelectedFieldsOrdered | undefined, name: string | undefined, isResponseInArrayMode: boolean, customResultMapper?: (rows: unknown[][]) => T['execute']
|
|
48
|
-
type: 'select' | 'update' | 'delete' | 'insert';
|
|
49
|
-
tables: string[];
|
|
50
|
-
}, cacheConfig?: WithCacheConfig): PgPreparedQuery<T>;
|
|
41
|
+
prepareQuery<T extends PreparedQueryConfig = PreparedQueryConfig>(query: Query, fields: SelectedFieldsOrdered | undefined, name: string | undefined, isResponseInArrayMode: boolean, customResultMapper?: (rows: unknown[][]) => T['execute']): PgPreparedQuery<T>;
|
|
51
42
|
query(query: string, params: unknown[]): Promise<QueryResults<'array'>>;
|
|
52
43
|
queryObjects(query: string, params: unknown[]): Promise<QueryResults<'json'>>;
|
|
53
44
|
transaction<T>(_transaction: (tx: XataTransaction<TFullSchema, TSchema>) => Promise<T>, _config?: PgTransactionConfig): Promise<T>;
|
package/xata-http/session.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type { SQLPluginResult, SQLQueryResult } from '@xata.io/client';
|
|
2
|
-
import type { Cache } from "../cache/core/index.js";
|
|
3
2
|
import { entityKind } from "../entity.js";
|
|
4
3
|
import type { Logger } from "../logger.js";
|
|
5
4
|
import type { PgDialect } from "../pg-core/dialect.js";
|
|
6
5
|
import { PgTransaction } from "../pg-core/index.js";
|
|
7
|
-
import type { SelectedFieldsOrdered
|
|
6
|
+
import type { SelectedFieldsOrdered } from "../pg-core/query-builders/select.types.js";
|
|
8
7
|
import type { PgQueryResultHKT, PgTransactionConfig, PreparedQueryConfig } from "../pg-core/session.js";
|
|
9
8
|
import { PgPreparedQuery, PgSession } from "../pg-core/session.js";
|
|
10
9
|
import type { RelationalSchemaConfig, TablesRelationalConfig } from "../relations.js";
|
|
@@ -24,17 +23,13 @@ export declare class XataHttpPreparedQuery<T extends PreparedQueryConfig> extend
|
|
|
24
23
|
private _isResponseInArrayMode;
|
|
25
24
|
private customResultMapper?;
|
|
26
25
|
static readonly [entityKind]: string;
|
|
27
|
-
constructor(client: XataHttpClient, query: Query, logger: Logger,
|
|
28
|
-
type: 'select' | 'update' | 'delete' | 'insert';
|
|
29
|
-
tables: string[];
|
|
30
|
-
} | undefined, cacheConfig: WithCacheConfig | undefined, fields: SelectedFieldsOrdered | undefined, _isResponseInArrayMode: boolean, customResultMapper?: ((rows: unknown[][]) => T["execute"]) | undefined);
|
|
26
|
+
constructor(client: XataHttpClient, query: Query, logger: Logger, fields: SelectedFieldsOrdered | undefined, _isResponseInArrayMode: boolean, customResultMapper?: ((rows: unknown[][]) => T["execute"]) | undefined);
|
|
31
27
|
execute(placeholderValues?: Record<string, unknown> | undefined): Promise<T['execute']>;
|
|
32
28
|
all(placeholderValues?: Record<string, unknown> | undefined): Promise<T['all']>;
|
|
33
29
|
values(placeholderValues?: Record<string, unknown> | undefined): Promise<T['values']>;
|
|
34
30
|
}
|
|
35
31
|
export interface XataHttpSessionOptions {
|
|
36
32
|
logger?: Logger;
|
|
37
|
-
cache?: Cache;
|
|
38
33
|
}
|
|
39
34
|
export declare class XataHttpSession<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig> extends PgSession<XataHttpQueryResultHKT, TFullSchema, TSchema> {
|
|
40
35
|
private client;
|
|
@@ -42,12 +37,8 @@ export declare class XataHttpSession<TFullSchema extends Record<string, unknown>
|
|
|
42
37
|
private options;
|
|
43
38
|
static readonly [entityKind]: string;
|
|
44
39
|
private logger;
|
|
45
|
-
private cache;
|
|
46
40
|
constructor(client: XataHttpClient, dialect: PgDialect, schema: RelationalSchemaConfig<TSchema> | undefined, options?: XataHttpSessionOptions);
|
|
47
|
-
prepareQuery<T extends PreparedQueryConfig = PreparedQueryConfig>(query: Query, fields: SelectedFieldsOrdered | undefined, name: string | undefined, isResponseInArrayMode: boolean, customResultMapper?: (rows: unknown[][]) => T['execute']
|
|
48
|
-
type: 'select' | 'update' | 'delete' | 'insert';
|
|
49
|
-
tables: string[];
|
|
50
|
-
}, cacheConfig?: WithCacheConfig): PgPreparedQuery<T>;
|
|
41
|
+
prepareQuery<T extends PreparedQueryConfig = PreparedQueryConfig>(query: Query, fields: SelectedFieldsOrdered | undefined, name: string | undefined, isResponseInArrayMode: boolean, customResultMapper?: (rows: unknown[][]) => T['execute']): PgPreparedQuery<T>;
|
|
51
42
|
query(query: string, params: unknown[]): Promise<QueryResults<'array'>>;
|
|
52
43
|
queryObjects(query: string, params: unknown[]): Promise<QueryResults<'json'>>;
|
|
53
44
|
transaction<T>(_transaction: (tx: XataTransaction<TFullSchema, TSchema>) => Promise<T>, _config?: PgTransactionConfig): Promise<T>;
|
package/xata-http/session.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { NoopCache } from "../cache/core/index.js";
|
|
2
1
|
import { entityKind } from "../entity.js";
|
|
3
2
|
import { NoopLogger } from "../logger.js";
|
|
4
3
|
import { PgTransaction } from "../pg-core/index.js";
|
|
@@ -6,8 +5,8 @@ import { PgPreparedQuery, PgSession } from "../pg-core/session.js";
|
|
|
6
5
|
import { fillPlaceholders } from "../sql/sql.js";
|
|
7
6
|
import { mapResultRow } from "../utils.js";
|
|
8
7
|
class XataHttpPreparedQuery extends PgPreparedQuery {
|
|
9
|
-
constructor(client, query, logger,
|
|
10
|
-
super(query
|
|
8
|
+
constructor(client, query, logger, fields, _isResponseInArrayMode, customResultMapper) {
|
|
9
|
+
super(query);
|
|
11
10
|
this.client = client;
|
|
12
11
|
this.logger = logger;
|
|
13
12
|
this.fields = fields;
|
|
@@ -20,13 +19,9 @@ class XataHttpPreparedQuery extends PgPreparedQuery {
|
|
|
20
19
|
this.logger.logQuery(this.query.sql, params);
|
|
21
20
|
const { fields, client, query, customResultMapper, joinsNotNullableMap } = this;
|
|
22
21
|
if (!fields && !customResultMapper) {
|
|
23
|
-
return
|
|
24
|
-
return await client.sql({ statement: query.sql, params });
|
|
25
|
-
});
|
|
22
|
+
return await client.sql({ statement: query.sql, params });
|
|
26
23
|
}
|
|
27
|
-
const { rows, warning } = await
|
|
28
|
-
return await client.sql({ statement: query.sql, params, responseType: "array" });
|
|
29
|
-
});
|
|
24
|
+
const { rows, warning } = await client.sql({ statement: query.sql, params, responseType: "array" });
|
|
30
25
|
if (warning)
|
|
31
26
|
console.warn(warning);
|
|
32
27
|
return customResultMapper ? customResultMapper(rows) : rows.map((row) => mapResultRow(fields, row, joinsNotNullableMap));
|
|
@@ -34,16 +29,12 @@ class XataHttpPreparedQuery extends PgPreparedQuery {
|
|
|
34
29
|
all(placeholderValues = {}) {
|
|
35
30
|
const params = fillPlaceholders(this.query.params, placeholderValues);
|
|
36
31
|
this.logger.logQuery(this.query.sql, params);
|
|
37
|
-
return this.
|
|
38
|
-
return this.client.sql({ statement: this.query.sql, params, responseType: "array" });
|
|
39
|
-
}).then((result) => result.rows);
|
|
32
|
+
return this.client.sql({ statement: this.query.sql, params, responseType: "array" }).then((result) => result.rows);
|
|
40
33
|
}
|
|
41
34
|
values(placeholderValues = {}) {
|
|
42
35
|
const params = fillPlaceholders(this.query.params, placeholderValues);
|
|
43
36
|
this.logger.logQuery(this.query.sql, params);
|
|
44
|
-
return this.
|
|
45
|
-
return this.client.sql({ statement: this.query.sql, params });
|
|
46
|
-
}).then((result) => result.records);
|
|
37
|
+
return this.client.sql({ statement: this.query.sql, params }).then((result) => result.records);
|
|
47
38
|
}
|
|
48
39
|
/** @internal */
|
|
49
40
|
isResponseInArrayMode() {
|
|
@@ -57,19 +48,14 @@ class XataHttpSession extends PgSession {
|
|
|
57
48
|
this.schema = schema;
|
|
58
49
|
this.options = options;
|
|
59
50
|
this.logger = options.logger ?? new NoopLogger();
|
|
60
|
-
this.cache = options.cache ?? new NoopCache();
|
|
61
51
|
}
|
|
62
52
|
static [entityKind] = "XataHttpSession";
|
|
63
53
|
logger;
|
|
64
|
-
|
|
65
|
-
prepareQuery(query, fields, name, isResponseInArrayMode, customResultMapper, queryMetadata, cacheConfig) {
|
|
54
|
+
prepareQuery(query, fields, name, isResponseInArrayMode, customResultMapper) {
|
|
66
55
|
return new XataHttpPreparedQuery(
|
|
67
56
|
this.client,
|
|
68
57
|
query,
|
|
69
58
|
this.logger,
|
|
70
|
-
this.cache,
|
|
71
|
-
queryMetadata,
|
|
72
|
-
cacheConfig,
|
|
73
59
|
fields,
|
|
74
60
|
isResponseInArrayMode,
|
|
75
61
|
customResultMapper
|
package/xata-http/session.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/xata-http/session.ts"],"sourcesContent":["import type { SQLPluginResult, SQLQueryResult } from '@xata.io/client';\nimport
|
|
1
|
+
{"version":3,"sources":["../../src/xata-http/session.ts"],"sourcesContent":["import type { SQLPluginResult, SQLQueryResult } from '@xata.io/client';\nimport { entityKind } from '~/entity.ts';\nimport type { Logger } from '~/logger.ts';\nimport { NoopLogger } from '~/logger.ts';\nimport type { PgDialect } from '~/pg-core/dialect.ts';\nimport { PgTransaction } from '~/pg-core/index.ts';\nimport type { SelectedFieldsOrdered } from '~/pg-core/query-builders/select.types.ts';\nimport type { PgQueryResultHKT, PgTransactionConfig, PreparedQueryConfig } from '~/pg-core/session.ts';\nimport { PgPreparedQuery, PgSession } from '~/pg-core/session.ts';\nimport type { RelationalSchemaConfig, TablesRelationalConfig } from '~/relations.ts';\nimport { fillPlaceholders, type Query } from '~/sql/sql.ts';\nimport { mapResultRow } from '~/utils.ts';\n\nexport type XataHttpClient = {\n\tsql: SQLPluginResult;\n};\n\nexport interface QueryResults<ArrayMode extends 'json' | 'array'> {\n\trowCount: number;\n\trows: ArrayMode extends 'array' ? any[][] : Record<string, any>[];\n\trowAsArray: ArrayMode extends 'array' ? true : false;\n}\n\nexport class XataHttpPreparedQuery<T extends PreparedQueryConfig> extends PgPreparedQuery<T> {\n\tstatic override readonly [entityKind]: string = 'XataHttpPreparedQuery';\n\n\tconstructor(\n\t\tprivate client: XataHttpClient,\n\t\tquery: Query,\n\t\tprivate logger: Logger,\n\t\tprivate fields: SelectedFieldsOrdered | undefined,\n\t\tprivate _isResponseInArrayMode: boolean,\n\t\tprivate customResultMapper?: (rows: unknown[][]) => T['execute'],\n\t) {\n\t\tsuper(query);\n\t}\n\n\tasync execute(placeholderValues: Record<string, unknown> | undefined = {}): Promise<T['execute']> {\n\t\tconst params = fillPlaceholders(this.query.params, placeholderValues);\n\n\t\tthis.logger.logQuery(this.query.sql, params);\n\n\t\tconst { fields, client, query, customResultMapper, joinsNotNullableMap } = this;\n\n\t\tif (!fields && !customResultMapper) {\n\t\t\treturn await client.sql<Record<string, any>>({ statement: query.sql, params });\n\t\t\t// return { rowCount: result.records.length, rows: result.records, rowAsArray: false };\n\t\t}\n\n\t\tconst { rows, warning } = await client.sql({ statement: query.sql, params, responseType: 'array' });\n\t\tif (warning) console.warn(warning);\n\n\t\treturn customResultMapper\n\t\t\t? customResultMapper(rows as unknown[][])\n\t\t\t: rows.map((row) => mapResultRow<T['execute']>(fields!, row as unknown[], joinsNotNullableMap));\n\t}\n\n\tall(placeholderValues: Record<string, unknown> | undefined = {}): Promise<T['all']> {\n\t\tconst params = fillPlaceholders(this.query.params, placeholderValues);\n\t\tthis.logger.logQuery(this.query.sql, params);\n\t\treturn this.client.sql({ statement: this.query.sql, params, responseType: 'array' }).then((result) => result.rows);\n\t}\n\n\tvalues(placeholderValues: Record<string, unknown> | undefined = {}): Promise<T['values']> {\n\t\tconst params = fillPlaceholders(this.query.params, placeholderValues);\n\t\tthis.logger.logQuery(this.query.sql, params);\n\t\treturn this.client.sql({ statement: this.query.sql, params }).then((result) => result.records);\n\t}\n\n\t/** @internal */\n\tisResponseInArrayMode() {\n\t\treturn this._isResponseInArrayMode;\n\t}\n}\n\nexport interface XataHttpSessionOptions {\n\tlogger?: Logger;\n}\n\nexport class XataHttpSession<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig>\n\textends PgSession<\n\t\tXataHttpQueryResultHKT,\n\t\tTFullSchema,\n\t\tTSchema\n\t>\n{\n\tstatic override readonly [entityKind]: string = 'XataHttpSession';\n\n\tprivate logger: Logger;\n\n\tconstructor(\n\t\tprivate client: XataHttpClient,\n\t\tdialect: PgDialect,\n\t\tprivate schema: RelationalSchemaConfig<TSchema> | undefined,\n\t\tprivate options: XataHttpSessionOptions = {},\n\t) {\n\t\tsuper(dialect);\n\t\tthis.logger = options.logger ?? new NoopLogger();\n\t}\n\n\tprepareQuery<T extends PreparedQueryConfig = PreparedQueryConfig>(\n\t\tquery: Query,\n\t\tfields: SelectedFieldsOrdered | undefined,\n\t\tname: string | undefined,\n\t\tisResponseInArrayMode: boolean,\n\t\tcustomResultMapper?: (rows: unknown[][]) => T['execute'],\n\t): PgPreparedQuery<T> {\n\t\treturn new XataHttpPreparedQuery(\n\t\t\tthis.client,\n\t\t\tquery,\n\t\t\tthis.logger,\n\t\t\tfields,\n\t\t\tisResponseInArrayMode,\n\t\t\tcustomResultMapper,\n\t\t);\n\t}\n\n\tasync query(query: string, params: unknown[]): Promise<QueryResults<'array'>> {\n\t\tthis.logger.logQuery(query, params);\n\t\tconst result = await this.client.sql({ statement: query, params, responseType: 'array' });\n\n\t\treturn {\n\t\t\trowCount: result.rows.length,\n\t\t\trows: result.rows,\n\t\t\trowAsArray: true,\n\t\t};\n\t}\n\n\tasync queryObjects(query: string, params: unknown[]): Promise<QueryResults<'json'>> {\n\t\tconst result = await this.client.sql<Record<string, any>>({ statement: query, params });\n\n\t\treturn {\n\t\t\trowCount: result.records.length,\n\t\t\trows: result.records,\n\t\t\trowAsArray: false,\n\t\t};\n\t}\n\n\toverride async transaction<T>(\n\t\t_transaction: (tx: XataTransaction<TFullSchema, TSchema>) => Promise<T>,\n\t\t// eslint-disable-next-line @typescript-eslint/no-unused-vars\n\t\t_config: PgTransactionConfig = {},\n\t): Promise<T> {\n\t\tthrow new Error('No transactions support in Xata Http driver');\n\t}\n}\n\nexport class XataTransaction<TFullSchema extends Record<string, unknown>, TSchema extends TablesRelationalConfig>\n\textends PgTransaction<\n\t\tXataHttpQueryResultHKT,\n\t\tTFullSchema,\n\t\tTSchema\n\t>\n{\n\tstatic override readonly [entityKind]: string = 'XataHttpTransaction';\n\n\toverride async transaction<T>(_transaction: (tx: XataTransaction<TFullSchema, TSchema>) => Promise<T>): Promise<T> {\n\t\tthrow new Error('No transactions support in Xata Http driver');\n\t}\n}\n\nexport interface XataHttpQueryResultHKT extends PgQueryResultHKT {\n\ttype: SQLQueryResult<this['row']>;\n}\n"],"mappings":"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","names":[]}
|
package/cache/core/cache.cjs
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var cache_exports = {};
|
|
20
|
-
__export(cache_exports, {
|
|
21
|
-
Cache: () => Cache,
|
|
22
|
-
NoopCache: () => NoopCache
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(cache_exports);
|
|
25
|
-
var import_entity = require("../../entity.cjs");
|
|
26
|
-
class Cache {
|
|
27
|
-
static [import_entity.entityKind] = "Cache";
|
|
28
|
-
}
|
|
29
|
-
class NoopCache extends Cache {
|
|
30
|
-
strategy() {
|
|
31
|
-
return "all";
|
|
32
|
-
}
|
|
33
|
-
static [import_entity.entityKind] = "NoopCache";
|
|
34
|
-
async get(_key) {
|
|
35
|
-
return void 0;
|
|
36
|
-
}
|
|
37
|
-
async put(_hashedQuery, _response, _tables, _config) {
|
|
38
|
-
}
|
|
39
|
-
async onMutate(_params) {
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
43
|
-
0 && (module.exports = {
|
|
44
|
-
Cache,
|
|
45
|
-
NoopCache
|
|
46
|
-
});
|
|
47
|
-
//# sourceMappingURL=cache.cjs.map
|
package/cache/core/cache.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/cache/core/cache.ts"],"sourcesContent":["import { entityKind } from '~/entity.ts';\nimport type { Table } from '~/index.ts';\nimport type { CacheConfig } from './types.ts';\n\nexport abstract class Cache {\n\tstatic readonly [entityKind]: string = 'Cache';\n\n\tabstract strategy(): 'explicit' | 'all';\n\n\t/**\n\t * Invoked if we should check cache for cached response\n\t * @param sql\n\t * @param tables\n\t */\n\tabstract get(\n\t\tkey: string,\n\t\ttables: string[],\n\t\tisTag: boolean,\n\t): Promise<any[] | undefined>;\n\n\t/**\n\t * Invoked if new query should be inserted to cache\n\t * @param sql\n\t * @param tables\n\t */\n\tabstract put(\n\t\thashedQuery: string,\n\t\tresponse: any,\n\t\ttables: string[],\n\t\tisTag: boolean,\n\t\tconfig?: CacheConfig,\n\t): Promise<void>;\n\n\t/**\n\t * Invoked if insert, update, delete was invoked\n\t * @param tables\n\t */\n\tabstract onMutate(\n\t\tparams: MutationOption,\n\t): Promise<void>;\n}\n\nexport class NoopCache extends Cache {\n\toverride strategy() {\n\t\treturn 'all' as const;\n\t}\n\n\tstatic override readonly [entityKind]: string = 'NoopCache';\n\n\toverride async get(_key: string): Promise<any[] | undefined> {\n\t\treturn undefined;\n\t}\n\toverride async put(\n\t\t_hashedQuery: string,\n\t\t_response: any,\n\t\t_tables: string[],\n\t\t_config?: any,\n\t): Promise<void> {\n\t\t// noop\n\t}\n\toverride async onMutate(_params: MutationOption): Promise<void> {\n\t\t// noop\n\t}\n}\n\nexport type MutationOption = { tags?: string | string[]; tables?: Table<any> | Table<any>[] | string | string[] };\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAA2B;AAIpB,MAAe,MAAM;AAAA,EAC3B,QAAiB,wBAAU,IAAY;AAmCxC;AAEO,MAAM,kBAAkB,MAAM;AAAA,EAC3B,WAAW;AACnB,WAAO;AAAA,EACR;AAAA,EAEA,QAA0B,wBAAU,IAAY;AAAA,EAEhD,MAAe,IAAI,MAA0C;AAC5D,WAAO;AAAA,EACR;AAAA,EACA,MAAe,IACd,cACA,WACA,SACA,SACgB;AAAA,EAEjB;AAAA,EACA,MAAe,SAAS,SAAwC;AAAA,EAEhE;AACD;","names":[]}
|
package/cache/core/cache.d.cts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { entityKind } from "../../entity.cjs";
|
|
2
|
-
import type { Table } from "../../index.cjs";
|
|
3
|
-
import type { CacheConfig } from "./types.cjs";
|
|
4
|
-
export declare abstract class Cache {
|
|
5
|
-
static readonly [entityKind]: string;
|
|
6
|
-
abstract strategy(): 'explicit' | 'all';
|
|
7
|
-
/**
|
|
8
|
-
* Invoked if we should check cache for cached response
|
|
9
|
-
* @param sql
|
|
10
|
-
* @param tables
|
|
11
|
-
*/
|
|
12
|
-
abstract get(key: string, tables: string[], isTag: boolean): Promise<any[] | undefined>;
|
|
13
|
-
/**
|
|
14
|
-
* Invoked if new query should be inserted to cache
|
|
15
|
-
* @param sql
|
|
16
|
-
* @param tables
|
|
17
|
-
*/
|
|
18
|
-
abstract put(hashedQuery: string, response: any, tables: string[], isTag: boolean, config?: CacheConfig): Promise<void>;
|
|
19
|
-
/**
|
|
20
|
-
* Invoked if insert, update, delete was invoked
|
|
21
|
-
* @param tables
|
|
22
|
-
*/
|
|
23
|
-
abstract onMutate(params: MutationOption): Promise<void>;
|
|
24
|
-
}
|
|
25
|
-
export declare class NoopCache extends Cache {
|
|
26
|
-
strategy(): "all";
|
|
27
|
-
static readonly [entityKind]: string;
|
|
28
|
-
get(_key: string): Promise<any[] | undefined>;
|
|
29
|
-
put(_hashedQuery: string, _response: any, _tables: string[], _config?: any): Promise<void>;
|
|
30
|
-
onMutate(_params: MutationOption): Promise<void>;
|
|
31
|
-
}
|
|
32
|
-
export type MutationOption = {
|
|
33
|
-
tags?: string | string[];
|
|
34
|
-
tables?: Table<any> | Table<any>[] | string | string[];
|
|
35
|
-
};
|
package/cache/core/cache.d.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { entityKind } from "../../entity.js";
|
|
2
|
-
import type { Table } from "../../index.js";
|
|
3
|
-
import type { CacheConfig } from "./types.js";
|
|
4
|
-
export declare abstract class Cache {
|
|
5
|
-
static readonly [entityKind]: string;
|
|
6
|
-
abstract strategy(): 'explicit' | 'all';
|
|
7
|
-
/**
|
|
8
|
-
* Invoked if we should check cache for cached response
|
|
9
|
-
* @param sql
|
|
10
|
-
* @param tables
|
|
11
|
-
*/
|
|
12
|
-
abstract get(key: string, tables: string[], isTag: boolean): Promise<any[] | undefined>;
|
|
13
|
-
/**
|
|
14
|
-
* Invoked if new query should be inserted to cache
|
|
15
|
-
* @param sql
|
|
16
|
-
* @param tables
|
|
17
|
-
*/
|
|
18
|
-
abstract put(hashedQuery: string, response: any, tables: string[], isTag: boolean, config?: CacheConfig): Promise<void>;
|
|
19
|
-
/**
|
|
20
|
-
* Invoked if insert, update, delete was invoked
|
|
21
|
-
* @param tables
|
|
22
|
-
*/
|
|
23
|
-
abstract onMutate(params: MutationOption): Promise<void>;
|
|
24
|
-
}
|
|
25
|
-
export declare class NoopCache extends Cache {
|
|
26
|
-
strategy(): "all";
|
|
27
|
-
static readonly [entityKind]: string;
|
|
28
|
-
get(_key: string): Promise<any[] | undefined>;
|
|
29
|
-
put(_hashedQuery: string, _response: any, _tables: string[], _config?: any): Promise<void>;
|
|
30
|
-
onMutate(_params: MutationOption): Promise<void>;
|
|
31
|
-
}
|
|
32
|
-
export type MutationOption = {
|
|
33
|
-
tags?: string | string[];
|
|
34
|
-
tables?: Table<any> | Table<any>[] | string | string[];
|
|
35
|
-
};
|
package/cache/core/cache.js
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { entityKind } from "../../entity.js";
|
|
2
|
-
class Cache {
|
|
3
|
-
static [entityKind] = "Cache";
|
|
4
|
-
}
|
|
5
|
-
class NoopCache extends Cache {
|
|
6
|
-
strategy() {
|
|
7
|
-
return "all";
|
|
8
|
-
}
|
|
9
|
-
static [entityKind] = "NoopCache";
|
|
10
|
-
async get(_key) {
|
|
11
|
-
return void 0;
|
|
12
|
-
}
|
|
13
|
-
async put(_hashedQuery, _response, _tables, _config) {
|
|
14
|
-
}
|
|
15
|
-
async onMutate(_params) {
|
|
16
|
-
}
|
|
17
|
-
}
|
|
18
|
-
export {
|
|
19
|
-
Cache,
|
|
20
|
-
NoopCache
|
|
21
|
-
};
|
|
22
|
-
//# sourceMappingURL=cache.js.map
|
package/cache/core/cache.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/cache/core/cache.ts"],"sourcesContent":["import { entityKind } from '~/entity.ts';\nimport type { Table } from '~/index.ts';\nimport type { CacheConfig } from './types.ts';\n\nexport abstract class Cache {\n\tstatic readonly [entityKind]: string = 'Cache';\n\n\tabstract strategy(): 'explicit' | 'all';\n\n\t/**\n\t * Invoked if we should check cache for cached response\n\t * @param sql\n\t * @param tables\n\t */\n\tabstract get(\n\t\tkey: string,\n\t\ttables: string[],\n\t\tisTag: boolean,\n\t): Promise<any[] | undefined>;\n\n\t/**\n\t * Invoked if new query should be inserted to cache\n\t * @param sql\n\t * @param tables\n\t */\n\tabstract put(\n\t\thashedQuery: string,\n\t\tresponse: any,\n\t\ttables: string[],\n\t\tisTag: boolean,\n\t\tconfig?: CacheConfig,\n\t): Promise<void>;\n\n\t/**\n\t * Invoked if insert, update, delete was invoked\n\t * @param tables\n\t */\n\tabstract onMutate(\n\t\tparams: MutationOption,\n\t): Promise<void>;\n}\n\nexport class NoopCache extends Cache {\n\toverride strategy() {\n\t\treturn 'all' as const;\n\t}\n\n\tstatic override readonly [entityKind]: string = 'NoopCache';\n\n\toverride async get(_key: string): Promise<any[] | undefined> {\n\t\treturn undefined;\n\t}\n\toverride async put(\n\t\t_hashedQuery: string,\n\t\t_response: any,\n\t\t_tables: string[],\n\t\t_config?: any,\n\t): Promise<void> {\n\t\t// noop\n\t}\n\toverride async onMutate(_params: MutationOption): Promise<void> {\n\t\t// noop\n\t}\n}\n\nexport type MutationOption = { tags?: string | string[]; tables?: Table<any> | Table<any>[] | string | string[] };\n"],"mappings":"AAAA,SAAS,kBAAkB;AAIpB,MAAe,MAAM;AAAA,EAC3B,QAAiB,UAAU,IAAY;AAmCxC;AAEO,MAAM,kBAAkB,MAAM;AAAA,EAC3B,WAAW;AACnB,WAAO;AAAA,EACR;AAAA,EAEA,QAA0B,UAAU,IAAY;AAAA,EAEhD,MAAe,IAAI,MAA0C;AAC5D,WAAO;AAAA,EACR;AAAA,EACA,MAAe,IACd,cACA,WACA,SACA,SACgB;AAAA,EAEjB;AAAA,EACA,MAAe,SAAS,SAAwC;AAAA,EAEhE;AACD;","names":[]}
|
package/cache/core/index.cjs
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
-
for (let key of __getOwnPropNames(from))
|
|
9
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
}
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
15
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
16
|
-
var core_exports = {};
|
|
17
|
-
module.exports = __toCommonJS(core_exports);
|
|
18
|
-
__reExport(core_exports, require("./cache.cjs"), module.exports);
|
|
19
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
20
|
-
0 && (module.exports = {
|
|
21
|
-
...require("./cache.cjs")
|
|
22
|
-
});
|
|
23
|
-
//# sourceMappingURL=index.cjs.map
|
package/cache/core/index.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/cache/core/index.ts"],"sourcesContent":["export * from './cache.ts';\n"],"mappings":";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,yBAAc,uBAAd;","names":[]}
|
package/cache/core/index.d.cts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./cache.cjs";
|
package/cache/core/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./cache.js";
|
package/cache/core/index.js
DELETED
package/cache/core/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/cache/core/index.ts"],"sourcesContent":["export * from './cache.ts';\n"],"mappings":"AAAA,cAAc;","names":[]}
|
package/cache/core/types.cjs
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
|
-
for (let key of __getOwnPropNames(from))
|
|
9
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
11
|
-
}
|
|
12
|
-
return to;
|
|
13
|
-
};
|
|
14
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
15
|
-
var types_exports = {};
|
|
16
|
-
module.exports = __toCommonJS(types_exports);
|
|
17
|
-
//# sourceMappingURL=types.cjs.map
|
package/cache/core/types.cjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/cache/core/types.ts"],"sourcesContent":["export type CacheConfig = {\n\t/**\n\t * expire time, in seconds (a positive integer)\n\t */\n\tex?: number;\n\t/**\n\t * expire time, in milliseconds (a positive integer).\n\t */\n\tpx?: number;\n\t/**\n\t * Unix time at which the key will expire, in seconds (a positive integer).\n\t */\n\texat?: number;\n\t/**\n\t * Unix time at which the key will expire, in milliseconds (a positive integer)\n\t */\n\tpxat?: number;\n\t/**\n\t * Retain the time to live associated with the key.\n\t */\n\tkeepTtl?: boolean;\n};\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
|
package/cache/core/types.d.cts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export type CacheConfig = {
|
|
2
|
-
/**
|
|
3
|
-
* expire time, in seconds (a positive integer)
|
|
4
|
-
*/
|
|
5
|
-
ex?: number;
|
|
6
|
-
/**
|
|
7
|
-
* expire time, in milliseconds (a positive integer).
|
|
8
|
-
*/
|
|
9
|
-
px?: number;
|
|
10
|
-
/**
|
|
11
|
-
* Unix time at which the key will expire, in seconds (a positive integer).
|
|
12
|
-
*/
|
|
13
|
-
exat?: number;
|
|
14
|
-
/**
|
|
15
|
-
* Unix time at which the key will expire, in milliseconds (a positive integer)
|
|
16
|
-
*/
|
|
17
|
-
pxat?: number;
|
|
18
|
-
/**
|
|
19
|
-
* Retain the time to live associated with the key.
|
|
20
|
-
*/
|
|
21
|
-
keepTtl?: boolean;
|
|
22
|
-
};
|
package/cache/core/types.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export type CacheConfig = {
|
|
2
|
-
/**
|
|
3
|
-
* expire time, in seconds (a positive integer)
|
|
4
|
-
*/
|
|
5
|
-
ex?: number;
|
|
6
|
-
/**
|
|
7
|
-
* expire time, in milliseconds (a positive integer).
|
|
8
|
-
*/
|
|
9
|
-
px?: number;
|
|
10
|
-
/**
|
|
11
|
-
* Unix time at which the key will expire, in seconds (a positive integer).
|
|
12
|
-
*/
|
|
13
|
-
exat?: number;
|
|
14
|
-
/**
|
|
15
|
-
* Unix time at which the key will expire, in milliseconds (a positive integer)
|
|
16
|
-
*/
|
|
17
|
-
pxat?: number;
|
|
18
|
-
/**
|
|
19
|
-
* Retain the time to live associated with the key.
|
|
20
|
-
*/
|
|
21
|
-
keepTtl?: boolean;
|
|
22
|
-
};
|
package/cache/core/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
//# sourceMappingURL=types.js.map
|
package/cache/core/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/cache/upstash/cache.cjs
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var cache_exports = {};
|
|
20
|
-
__export(cache_exports, {
|
|
21
|
-
UpstashCache: () => UpstashCache,
|
|
22
|
-
upstashCache: () => upstashCache
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(cache_exports);
|
|
25
|
-
var import_redis = require("@upstash/redis");
|
|
26
|
-
var import_core = require("../core/index.cjs");
|
|
27
|
-
var import_entity = require("../../entity.cjs");
|
|
28
|
-
var import__ = require("../../index.cjs");
|
|
29
|
-
class UpstashCache extends import_core.Cache {
|
|
30
|
-
constructor(redis, config, useGlobally) {
|
|
31
|
-
super();
|
|
32
|
-
this.redis = redis;
|
|
33
|
-
this.useGlobally = useGlobally;
|
|
34
|
-
this.internalConfig = this.toInternalConfig(config);
|
|
35
|
-
}
|
|
36
|
-
static [import_entity.entityKind] = "UpstashCache";
|
|
37
|
-
internalConfig;
|
|
38
|
-
strategy() {
|
|
39
|
-
return this.useGlobally ? "all" : "explicit";
|
|
40
|
-
}
|
|
41
|
-
toInternalConfig(config) {
|
|
42
|
-
return config ? {
|
|
43
|
-
ex: config.ex,
|
|
44
|
-
exat: config.exat,
|
|
45
|
-
px: config.px,
|
|
46
|
-
pxat: config.pxat,
|
|
47
|
-
keepTtl: config.keepTtl
|
|
48
|
-
} : void 0;
|
|
49
|
-
}
|
|
50
|
-
async get(key, _tables, _isTag) {
|
|
51
|
-
const res = (await this.redis.get(key)) ?? void 0;
|
|
52
|
-
return res;
|
|
53
|
-
}
|
|
54
|
-
async put(key, response, tables, isTag, config) {
|
|
55
|
-
await this.redis.set(key, response, config ? this.toInternalConfig(config) : this.internalConfig);
|
|
56
|
-
for (const table of tables) {
|
|
57
|
-
await this.redis.sadd(table, key);
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
async onMutate(params) {
|
|
61
|
-
const tagsArray = params.tags ? Array.isArray(params.tags) ? params.tags : [params.tags] : [];
|
|
62
|
-
const tablesArray = params.tables ? Array.isArray(params.tables) ? params.tables : [params.tables] : [];
|
|
63
|
-
const keysToDelete = /* @__PURE__ */ new Set();
|
|
64
|
-
for (const table of tablesArray) {
|
|
65
|
-
const tableName = (0, import_entity.is)(table, import__.Table) ? table[import__.OriginalName] : table;
|
|
66
|
-
const keys = await this.redis.smembers(tableName);
|
|
67
|
-
for (const key of keys)
|
|
68
|
-
keysToDelete.add(key);
|
|
69
|
-
}
|
|
70
|
-
if (keysToDelete.size > 0 || tagsArray.length > 0) {
|
|
71
|
-
const pipeline = this.redis.pipeline();
|
|
72
|
-
for (const tag of tagsArray) {
|
|
73
|
-
pipeline.del(tag);
|
|
74
|
-
}
|
|
75
|
-
for (const key of keysToDelete) {
|
|
76
|
-
pipeline.del(key);
|
|
77
|
-
for (const table of tablesArray) {
|
|
78
|
-
const tableName = (0, import_entity.is)(table, import__.Table) ? table[import__.OriginalName] : table;
|
|
79
|
-
pipeline.srem(tableName, key);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
await pipeline.exec();
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
function upstashCache({ url, token, config, global = false }) {
|
|
87
|
-
const redis = new import_redis.Redis({
|
|
88
|
-
url,
|
|
89
|
-
token
|
|
90
|
-
});
|
|
91
|
-
return new UpstashCache(redis, config, global);
|
|
92
|
-
}
|
|
93
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
94
|
-
0 && (module.exports = {
|
|
95
|
-
UpstashCache,
|
|
96
|
-
upstashCache
|
|
97
|
-
});
|
|
98
|
-
//# sourceMappingURL=cache.cjs.map
|