orez-sync-executor 0.12.13 → 0.12.14-canary.1786319369047
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/sql-billing.d.ts +20 -0
- package/dist/sql-billing.d.ts.map +1 -0
- package/dist/sql-billing.js +69 -0
- package/dist/sql-billing.js.map +1 -0
- package/package.json +5 -1
- package/dist/adapters.d.ts +0 -25
- package/dist/adapters.d.ts.map +0 -1
- package/dist/adapters.js +0 -116
- package/dist/adapters.js.map +0 -1
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type BillableCursor = {
|
|
2
|
+
rowsRead?: number;
|
|
3
|
+
rowsWritten?: number;
|
|
4
|
+
next?: (...args: unknown[]) => unknown;
|
|
5
|
+
one?: (...args: unknown[]) => unknown;
|
|
6
|
+
toArray?: (...args: unknown[]) => unknown;
|
|
7
|
+
raw?: (...args: unknown[]) => unknown;
|
|
8
|
+
[Symbol.iterator]?: () => Iterator<unknown>;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Account a cursor's final billing rows as it is consumed.
|
|
12
|
+
*
|
|
13
|
+
* Cloudflare's `rowsRead` and `rowsWritten` can increase during cursor
|
|
14
|
+
* iteration (notably for `... RETURNING` statements). Sampling only when
|
|
15
|
+
* `sql.exec()` returns misses that work. This proxy records monotonic deltas
|
|
16
|
+
* after every consumption method while preserving the cursor's native `this`
|
|
17
|
+
* binding.
|
|
18
|
+
*/
|
|
19
|
+
export declare function trackBillableCursorRows<Cursor extends BillableCursor>(cursor: Cursor, recordWritten: (rows: number) => void, recordRead?: (rows: number) => void): Cursor;
|
|
20
|
+
//# sourceMappingURL=sql-billing.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sql-billing.d.ts","sourceRoot":"","sources":["../src/sql-billing.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAA;IACtC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAA;IACrC,OAAO,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAA;IACzC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAA;IACrC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,MAAM,QAAQ,CAAC,OAAO,CAAC,CAAA;CAC5C,CAAA;AAED;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,SAAS,cAAc,EACnE,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,EACrC,UAAU,GAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAe,GAC5C,MAAM,CA4DR"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Account a cursor's final billing rows as it is consumed.
|
|
3
|
+
*
|
|
4
|
+
* Cloudflare's `rowsRead` and `rowsWritten` can increase during cursor
|
|
5
|
+
* iteration (notably for `... RETURNING` statements). Sampling only when
|
|
6
|
+
* `sql.exec()` returns misses that work. This proxy records monotonic deltas
|
|
7
|
+
* after every consumption method while preserving the cursor's native `this`
|
|
8
|
+
* binding.
|
|
9
|
+
*/
|
|
10
|
+
export function trackBillableCursorRows(cursor, recordWritten, recordRead = () => { }) {
|
|
11
|
+
if (!cursor || typeof cursor !== 'object')
|
|
12
|
+
return cursor;
|
|
13
|
+
let accountedWritten = 0;
|
|
14
|
+
let accountedRead = 0;
|
|
15
|
+
const account = () => {
|
|
16
|
+
const written = Number(cursor.rowsWritten ?? 0);
|
|
17
|
+
if (Number.isSafeInteger(written) && written > accountedWritten) {
|
|
18
|
+
recordWritten(written - accountedWritten);
|
|
19
|
+
accountedWritten = written;
|
|
20
|
+
}
|
|
21
|
+
const read = Number(cursor.rowsRead ?? 0);
|
|
22
|
+
if (Number.isSafeInteger(read) && read > accountedRead) {
|
|
23
|
+
recordRead(read - accountedRead);
|
|
24
|
+
accountedRead = read;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
const wrapIterator = (iterator) => {
|
|
28
|
+
const next = iterator.next.bind(iterator);
|
|
29
|
+
return {
|
|
30
|
+
next(...args) {
|
|
31
|
+
try {
|
|
32
|
+
return next(...args);
|
|
33
|
+
}
|
|
34
|
+
finally {
|
|
35
|
+
account();
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
[Symbol.iterator]() {
|
|
39
|
+
return this;
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
let proxy;
|
|
44
|
+
proxy = new Proxy(cursor, {
|
|
45
|
+
get(target, property) {
|
|
46
|
+
const value = Reflect.get(target, property, target);
|
|
47
|
+
if (property === Symbol.iterator)
|
|
48
|
+
return () => proxy;
|
|
49
|
+
if ((property === 'next' || property === 'one' || property === 'toArray') &&
|
|
50
|
+
typeof value === 'function') {
|
|
51
|
+
return (...args) => {
|
|
52
|
+
try {
|
|
53
|
+
return Reflect.apply(value, target, args);
|
|
54
|
+
}
|
|
55
|
+
finally {
|
|
56
|
+
account();
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
if (property === 'raw' && typeof value === 'function') {
|
|
61
|
+
return (...args) => wrapIterator(Reflect.apply(value, target, args));
|
|
62
|
+
}
|
|
63
|
+
return typeof value === 'function' ? value.bind(target) : value;
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
account();
|
|
67
|
+
return proxy;
|
|
68
|
+
}
|
|
69
|
+
//# sourceMappingURL=sql-billing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sql-billing.js","sour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|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.14-canary.1786319369047",
|
|
4
4
|
"description": "Internal orez engine package. Do not import directly: consumers use orez-lite (e.g. orez-lite/realtime).",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
@@ -24,6 +24,10 @@
|
|
|
24
24
|
"./realtime": {
|
|
25
25
|
"types": "./dist/realtime/index.d.ts",
|
|
26
26
|
"import": "./dist/realtime/index.js"
|
|
27
|
+
},
|
|
28
|
+
"./sql-billing": {
|
|
29
|
+
"types": "./dist/sql-billing.d.ts",
|
|
30
|
+
"import": "./dist/sql-billing.js"
|
|
27
31
|
}
|
|
28
32
|
},
|
|
29
33
|
"scripts": {
|
package/dist/adapters.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import type { ApplicationDatabase, ApplicationTransaction, JsonValue, TransactionQueryFormat } from './types.js';
|
|
2
|
-
import type { Schema } from '@rocicorp/zero';
|
|
3
|
-
export type PostgreSQLQueryResult<Row extends Record<string, unknown>> = {
|
|
4
|
-
readonly rows: readonly Row[];
|
|
5
|
-
readonly rowCount?: number | null;
|
|
6
|
-
};
|
|
7
|
-
export type PostgreSQLClient = {
|
|
8
|
-
query<Row extends Record<string, unknown> = Record<string, unknown>>(sql: string, params?: readonly unknown[]): Promise<PostgreSQLQueryResult<Row>>;
|
|
9
|
-
release(): void;
|
|
10
|
-
};
|
|
11
|
-
export type PostgreSQLPool = {
|
|
12
|
-
connect(): Promise<PostgreSQLClient>;
|
|
13
|
-
query<Row extends Record<string, unknown> = Record<string, unknown>>(sql: string, params?: readonly unknown[]): Promise<PostgreSQLQueryResult<Row>>;
|
|
14
|
-
};
|
|
15
|
-
export type PostgreSQLApplicationDatabaseOptions = {
|
|
16
|
-
readonly internalSchema?: string;
|
|
17
|
-
readonly schema?: Schema;
|
|
18
|
-
readonly queryAst?: <Result>(tx: PostgreSQLClient, ast: JsonValue, format: TransactionQueryFormat, queryName?: string) => Promise<Result>;
|
|
19
|
-
};
|
|
20
|
-
export declare function createPostgreSQLApplicationDatabase(pool: PostgreSQLPool, options?: PostgreSQLApplicationDatabaseOptions): ApplicationDatabase;
|
|
21
|
-
export declare function createSQLiteApplicationDatabase(options: {
|
|
22
|
-
transaction<Value>(work: (tx: ApplicationTransaction) => Value | Promise<Value>): Promise<Value>;
|
|
23
|
-
query<Row extends Record<string, unknown> = Record<string, unknown>>(sql: string, params?: readonly unknown[]): Promise<readonly Row[]>;
|
|
24
|
-
}): ApplicationDatabase;
|
|
25
|
-
//# sourceMappingURL=adapters.d.ts.map
|
package/dist/adapters.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"adapters.d.ts","sourceRoot":"","sources":["../src/adapters.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,mBAAmB,EACnB,sBAAsB,EAEtB,SAAS,EAET,sBAAsB,EACvB,MAAM,YAAY,CAAA;AACnB,OAAO,KAAK,EAA8B,MAAM,EAAE,MAAM,gBAAgB,CAAA;AAGxE,MAAM,MAAM,qBAAqB,CAAC,GAAG,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI;IACvE,QAAQ,CAAC,IAAI,EAAE,SAAS,GAAG,EAAE,CAAA;IAC7B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAClC,CAAA;AAED,MAAM,MAAM,gBAAgB,GAAG;IAC7B,KAAK,CAAC,GAAG,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjE,GAAG,EAAE,MAAM,EACX,MAAM,CAAC,EAAE,SAAS,OAAO,EAAE,GAC1B,OAAO,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC,CAAA;IACtC,OAAO,IAAI,IAAI,CAAA;CAChB,CAAA;AAED,MAAM,MAAM,cAAc,GAAG;IAC3B,OAAO,IAAI,OAAO,CAAC,gBAAgB,C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reSQLApplicationDatabase(pool, options = {}) {
|
|
3
|
-
let serverSchema;
|
|
4
|
-
async function introspectServerSchema(client) {
|
|
5
|
-
if (!options.schema) {
|
|
6
|
-
throw new TypeError('PostgreSQL application database requires schema or queryAst for ZQL reads');
|
|
7
|
-
}
|
|
8
|
-
const tables = Object.values(options.schema.tables).map((table) => {
|
|
9
|
-
const serverName = table.serverName ?? table.name;
|
|
10
|
-
const period = serverName.indexOf('.');
|
|
11
|
-
return period < 0
|
|
12
|
-
? { schema: 'public', table: serverName }
|
|
13
|
-
: {
|
|
14
|
-
schema: serverName.slice(0, period),
|
|
15
|
-
table: serverName.slice(period + 1),
|
|
16
|
-
};
|
|
17
|
-
});
|
|
18
|
-
if (tables.length === 0)
|
|
19
|
-
return {};
|
|
20
|
-
const params = tables.flatMap((table) => [table.schema, table.table]);
|
|
21
|
-
const where = tables
|
|
22
|
-
.map((_, index) => `(c.table_schema = $${index * 2 + 1} AND c.table_name = $${index * 2 + 2})`)
|
|
23
|
-
.join(' OR ');
|
|
24
|
-
const rows = (await client.query(`SELECT
|
|
25
|
-
c.table_schema::text AS schema,
|
|
26
|
-
c.table_name::text AS table,
|
|
27
|
-
c.column_name::text AS column,
|
|
28
|
-
c.data_type::text AS "dataType",
|
|
29
|
-
t.typtype::text AS typtype,
|
|
30
|
-
t.typname::text AS typename,
|
|
31
|
-
CASE WHEN t.typelem <> 0 THEN et.typtype::text ELSE NULL END AS "elemTyptype",
|
|
32
|
-
CASE WHEN t.typelem <> 0 THEN et.typname::text ELSE NULL END AS "elemTypname"
|
|
33
|
-
FROM information_schema.columns c
|
|
34
|
-
JOIN pg_catalog.pg_type t ON c.udt_name = t.typname
|
|
35
|
-
LEFT JOIN pg_catalog.pg_type et ON t.typelem = et.oid
|
|
36
|
-
JOIN pg_catalog.pg_namespace n ON t.typnamespace = n.oid
|
|
37
|
-
WHERE ${where}`, params)).rows;
|
|
38
|
-
const result = {};
|
|
39
|
-
for (const row of rows) {
|
|
40
|
-
const tableName = row.schema === 'public' ? row.table : `${row.schema}.${row.table}`;
|
|
41
|
-
const table = (result[tableName] ??= {});
|
|
42
|
-
const isArray = row.elemTyptype !== null;
|
|
43
|
-
const isEnum = (row.elemTyptype ?? row.typtype) === 'e';
|
|
44
|
-
table[row.column] = {
|
|
45
|
-
type: isArray
|
|
46
|
-
? (row.elemTypname ?? row.dataType.toLowerCase())
|
|
47
|
-
: isEnum
|
|
48
|
-
? row.typename
|
|
49
|
-
: row.dataType.toLowerCase(),
|
|
50
|
-
isArray,
|
|
51
|
-
isEnum,
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
return result;
|
|
55
|
-
}
|
|
56
|
-
const transactionFor = (client) => ({
|
|
57
|
-
async exec(sql, params = [], _metadata) {
|
|
58
|
-
const result = await client.query(sql, params);
|
|
59
|
-
return { changes: result.rowCount ?? 0 };
|
|
60
|
-
},
|
|
61
|
-
async query(sql, params = []) {
|
|
62
|
-
return (await client.query(sql, params)).rows;
|
|
63
|
-
},
|
|
64
|
-
queryAst(ast, format, queryName) {
|
|
65
|
-
if (!options.queryAst) {
|
|
66
|
-
if (!options.schema) {
|
|
67
|
-
throw new TypeError('PostgreSQL application database requires schema or queryAst for ZQL reads');
|
|
68
|
-
}
|
|
69
|
-
serverSchema ??= introspectServerSchema(client);
|
|
70
|
-
const dbTransaction = {
|
|
71
|
-
wrappedTransaction: client,
|
|
72
|
-
async query(sql, params) {
|
|
73
|
-
return (await client.query(sql, params)).rows;
|
|
74
|
-
},
|
|
75
|
-
runQuery(queryAst, queryFormat, schema, resolvedServerSchema) {
|
|
76
|
-
return executePostgresQuery(this, queryAst, queryFormat, schema, resolvedServerSchema);
|
|
77
|
-
},
|
|
78
|
-
};
|
|
79
|
-
return serverSchema.then((resolved) => executePostgresQuery(dbTransaction, ast, format, options.schema, resolved));
|
|
80
|
-
}
|
|
81
|
-
return options.queryAst(client, ast, format, queryName);
|
|
82
|
-
},
|
|
83
|
-
});
|
|
84
|
-
return {
|
|
85
|
-
dialect: 'postgresql',
|
|
86
|
-
internalSchema: options.internalSchema,
|
|
87
|
-
async transaction(work) {
|
|
88
|
-
const client = await pool.connect();
|
|
89
|
-
try {
|
|
90
|
-
await client.query('BEGIN');
|
|
91
|
-
const result = await work(transactionFor(client));
|
|
92
|
-
await client.query('COMMIT');
|
|
93
|
-
return result;
|
|
94
|
-
}
|
|
95
|
-
catch (error) {
|
|
96
|
-
try {
|
|
97
|
-
await client.query('ROLLBACK');
|
|
98
|
-
}
|
|
99
|
-
catch {
|
|
100
|
-
// preserve the application or commit error that caused the rollback.
|
|
101
|
-
}
|
|
102
|
-
throw error;
|
|
103
|
-
}
|
|
104
|
-
finally {
|
|
105
|
-
client.release();
|
|
106
|
-
}
|
|
107
|
-
},
|
|
108
|
-
async query(sql, params = []) {
|
|
109
|
-
return (await pool.query(sql, params)).rows;
|
|
110
|
-
},
|
|
111
|
-
};
|
|
112
|
-
}
|
|
113
|
-
export function createSQLiteApplicationDatabase(options) {
|
|
114
|
-
return { dialect: 'sqlite', ...options };
|
|
115
|
-
}
|
|
116
|
-
//# sourceMappingURL=adapters.js.map
|
package/dist/adapters.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"adapters.js","sourceRoot":"","sources":["../src/adapters.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAA;AA6C5D,MAAM,UAAU,mCAAmC,CACjD,IAAoB,EACpB,UAAgD,EAAE;IAElD,IAAI,YAA+C,CAAA;IAEnD,KAAK,UAAU,sBAAsB,CAAC,MAAwB;QAC5D,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;YACpB,MAAM,IAAI,SAAS,CACjB,2EAA2E,CAC5E,CAAA;QACH,CAAC;QACD,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;YACh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