orez-sync-cf-host 0.5.20 → 0.5.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -1
- package/dist/sql-storage-adapter.d.ts +3 -3
- package/dist/sql-storage-adapter.js +6 -4
- package/dist/types.d.ts +17 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export { createSyncDurableObject, createSyncWorker } from './host.js';
|
|
|
2
2
|
export { createQueryCompiler } from './query-compiler.js';
|
|
3
3
|
export { MutationApplicationError, isMutationApplicationError, registerMutators, } from './types.js';
|
|
4
4
|
export { DEFAULT_TRANSACTION_QUERY_BUDGET, TransactionQueryBudgetError, executeTransactionQueryPlan, executeTransactionQueryPlanAsync, } from './transaction-query.js';
|
|
5
|
-
export type { DeferredEffect, JsonPrimitive, JsonValue, MutatorContext, MutatorRegistry, MutatorSql, NormalizedClaims, PullCaps, QueryResolver, RegisteredMutator, SyncHostConfig, SyncHostEnv, ServiceBinding, SyncSql, UpstreamConfig, VisibilityConfig, VisibilityFilter, ZeroSchemaConfig, } from './types.js';
|
|
5
|
+
export type { DeferredEffect, JsonPrimitive, JsonValue, MutatorContext, MutatorRegistry, MutatorSql, NormalizedClaims, PullCaps, QueryResolver, RegisteredMutator, SyncHostConfig, SyncHostEnv, ServiceBinding, SQLiteExecResult, SqlStatementMetadata, SyncSql, UpstreamConfig, VisibilityConfig, VisibilityFilter, ZeroSchemaConfig, } from './types.js';
|
|
6
6
|
export type { SyncDurableObjectConstructor } from './host.js';
|
|
7
7
|
export type { CompiledTransactionQueryNode, CompiledTransactionQueryPlan, CompiledTransactionQueryRelationship, TransactionQueryBinding, TransactionQueryBudget, TransactionQueryColumn, TransactionQueryColumnType, TransactionQueryExecutionOptions, TransactionQueryFormat, TransactionQueryWireValue, } from './transaction-query.js';
|
|
8
8
|
export type { TransactionQueryCompiler } from './query-compiler.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { CompiledTransactionQueryPlan, TransactionQueryBudget, TransactionQueryFormat } from './transaction-query.js';
|
|
2
|
-
import type { MutatorSql, SyncSql } from './types.js';
|
|
2
|
+
import type { MutatorSql, SQLiteExecResult, SqlStatementMetadata, SyncSql } from './types.js';
|
|
3
3
|
type WireValue = {
|
|
4
4
|
kind: 'null';
|
|
5
5
|
} | {
|
|
@@ -49,7 +49,7 @@ export declare class SqlStorageDirect implements SyncSql {
|
|
|
49
49
|
private readonly sql;
|
|
50
50
|
private readonly recordRowsWritten;
|
|
51
51
|
constructor(sql: SqlStorage, recordRowsWritten?: (rows: number) => void);
|
|
52
|
-
exec(sql: string, params?: readonly unknown[]):
|
|
52
|
+
exec(sql: string, params?: readonly unknown[], _metadata?: SqlStatementMetadata): SQLiteExecResult;
|
|
53
53
|
query<Row extends Record<string, unknown> = Record<string, unknown>>(sql: string, params?: readonly unknown[]): Row[];
|
|
54
54
|
}
|
|
55
55
|
/**
|
|
@@ -62,7 +62,7 @@ export declare class SqlStorageMutatorTransaction implements MutatorSql {
|
|
|
62
62
|
private readonly compileQuery;
|
|
63
63
|
private readonly queryBudget?;
|
|
64
64
|
constructor(direct: SqlStorageDirect, compileQuery: (ast: unknown, format: TransactionQueryFormat) => CompiledTransactionQueryPlan, queryBudget?: Partial<TransactionQueryBudget> | undefined);
|
|
65
|
-
exec(sql: string, params?: readonly unknown[]): Promise<
|
|
65
|
+
exec(sql: string, params?: readonly unknown[], metadata?: SqlStatementMetadata): Promise<SQLiteExecResult>;
|
|
66
66
|
query<Row extends Record<string, unknown> = Record<string, unknown>>(sql: string, params?: readonly unknown[]): Promise<Row[]>;
|
|
67
67
|
queryAst<Result = unknown>(ast: unknown, format: TransactionQueryFormat, queryName?: string): Promise<Result>;
|
|
68
68
|
}
|
|
@@ -156,9 +156,11 @@ export class SqlStorageDirect {
|
|
|
156
156
|
this.sql = sql;
|
|
157
157
|
this.recordRowsWritten = recordRowsWritten;
|
|
158
158
|
}
|
|
159
|
-
exec(sql, params = []) {
|
|
159
|
+
exec(sql, params = [], _metadata) {
|
|
160
160
|
assertHostSql(sql);
|
|
161
|
-
trackBillableCursorRows(this.sql.exec(sql, ...params), this.recordRowsWritten);
|
|
161
|
+
trackBillableCursorRows(this.sql.exec(sql, ...params), this.recordRowsWritten).toArray();
|
|
162
|
+
const changes = Number(this.sql.exec('SELECT changes() AS changes').one()?.changes ?? 0);
|
|
163
|
+
return { changes };
|
|
162
164
|
}
|
|
163
165
|
query(sql, params = []) {
|
|
164
166
|
assertHostSql(sql);
|
|
@@ -179,8 +181,8 @@ export class SqlStorageMutatorTransaction {
|
|
|
179
181
|
this.compileQuery = compileQuery;
|
|
180
182
|
this.queryBudget = queryBudget;
|
|
181
183
|
}
|
|
182
|
-
async exec(sql, params = []) {
|
|
183
|
-
this.direct.exec(sql, params);
|
|
184
|
+
async exec(sql, params = [], metadata) {
|
|
185
|
+
return this.direct.exec(sql, params, metadata);
|
|
184
186
|
}
|
|
185
187
|
async query(sql, params = []) {
|
|
186
188
|
return this.direct.query(sql, params);
|
package/dist/types.d.ts
CHANGED
|
@@ -21,12 +21,27 @@ export type ZeroSchemaConfig = {
|
|
|
21
21
|
readonly primaryKey: readonly string[];
|
|
22
22
|
}>>;
|
|
23
23
|
};
|
|
24
|
+
/**
|
|
25
|
+
* Explicit identity for a SQLite write to a published application table.
|
|
26
|
+
*
|
|
27
|
+
* The physical table installs CDC. `publicTable` is the logical Zero name
|
|
28
|
+
* emitted in the change feed. This replaces metadata recovered by parsing
|
|
29
|
+
* PostgreSQL statements.
|
|
30
|
+
*/
|
|
31
|
+
export type SqlStatementMetadata = {
|
|
32
|
+
table: string;
|
|
33
|
+
publicTable: string;
|
|
34
|
+
kind: 'insert' | 'update' | 'delete' | 'upsert';
|
|
35
|
+
};
|
|
36
|
+
export type SQLiteExecResult = {
|
|
37
|
+
changes: number;
|
|
38
|
+
};
|
|
24
39
|
export interface SyncSql {
|
|
25
|
-
exec(sql: string, params?: readonly unknown[]):
|
|
40
|
+
exec(sql: string, params?: readonly unknown[], metadata?: SqlStatementMetadata): SQLiteExecResult;
|
|
26
41
|
query<Row extends Record<string, unknown> = Record<string, unknown>>(sql: string, params?: readonly unknown[]): Row[];
|
|
27
42
|
}
|
|
28
43
|
export interface MutatorSql {
|
|
29
|
-
exec(sql: string, params?: readonly unknown[]): Promise<
|
|
44
|
+
exec(sql: string, params?: readonly unknown[], metadata?: SqlStatementMetadata): Promise<SQLiteExecResult>;
|
|
30
45
|
query<Row extends Record<string, unknown> = Record<string, unknown>>(sql: string, params?: readonly unknown[]): Promise<Row[]>;
|
|
31
46
|
/** Execute a validated Zero AST inside the current application transaction. */
|
|
32
47
|
queryAst<Result = unknown>(ast: JsonValue, format: TransactionQueryFormat, queryName?: string): Promise<Result>;
|