@pgxsinkit/server 0.1.30 → 0.1.31
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/cli/generate.d.ts +18 -0
- package/dist/cli/generate.d.ts.map +1 -0
- package/dist/electric-proxy.d.ts +16 -0
- package/dist/electric-proxy.d.ts.map +1 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +83 -75
- package/dist/index.js.map +10 -10
- package/dist/mutations/bulk/plpgsql-strategy.d.ts +17 -0
- package/dist/mutations/bulk/plpgsql-strategy.d.ts.map +1 -0
- package/dist/mutations/bulk/route.d.ts +7 -0
- package/dist/mutations/bulk/route.d.ts.map +1 -0
- package/dist/mutations/bulk/types.d.ts +5 -0
- package/dist/mutations/bulk/types.d.ts.map +1 -0
- package/dist/operations-log/ddl.d.ts +12 -0
- package/dist/operations-log/ddl.d.ts.map +1 -0
- package/dist/operations-log/schema.d.ts +265 -0
- package/dist/operations-log/schema.d.ts.map +1 -0
- package/dist/operations-log/types.d.ts +31 -0
- package/dist/operations-log/types.d.ts.map +1 -0
- package/dist/operations-log/writer.d.ts +4 -0
- package/dist/operations-log/writer.d.ts.map +1 -0
- package/package.json +5 -5
- package/src/electric-proxy.ts +40 -10
- package/src/index.ts +14 -5
- package/src/mutations/bulk/plpgsql-strategy.ts +6 -6
- package/src/mutations/bulk/route.ts +5 -5
- package/src/operations-log/ddl.ts +3 -3
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type PgAsyncDatabase, type PgQueryResultHKT } from "drizzle-orm/pg-core";
|
|
2
|
+
import { type BatchMutationRequest, type RegistryRelations, type SyncTableRegistry } from "@pgxsinkit/contracts";
|
|
3
|
+
import type { TransactionClient } from "./types";
|
|
4
|
+
export declare function buildPlpgsqlBatchFunctionDdl(registry: SyncTableRegistry, options?: {
|
|
5
|
+
functionSchema?: string;
|
|
6
|
+
}): string;
|
|
7
|
+
export declare function installPlpgsqlBatchFunction<TRegistry extends SyncTableRegistry>(db: PgAsyncDatabase<PgQueryResultHKT, RegistryRelations<TRegistry>>, registry: TRegistry, options?: {
|
|
8
|
+
functionSchema?: string;
|
|
9
|
+
}): Promise<void>;
|
|
10
|
+
export declare function verifyPlpgsqlBatchFunction<TRegistry extends SyncTableRegistry>(db: PgAsyncDatabase<PgQueryResultHKT, RegistryRelations<TRegistry>>, options?: {
|
|
11
|
+
functionSchema?: string;
|
|
12
|
+
}): Promise<void>;
|
|
13
|
+
export declare function verifyArtifactRlsAuthHelpers<TRegistry extends SyncTableRegistry>(db: PgAsyncDatabase<PgQueryResultHKT, RegistryRelations<TRegistry>>): Promise<void>;
|
|
14
|
+
export declare function executePlpgsqlBatch(tx: TransactionClient, batch: BatchMutationRequest, requestPath: string, logEnabled: boolean, rlsEnabled: boolean, userClaims: Record<string, unknown>, options?: {
|
|
15
|
+
functionSchema?: string;
|
|
16
|
+
}): Promise<void>;
|
|
17
|
+
//# sourceMappingURL=plpgsql-strategy.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plpgsql-strategy.d.ts","sourceRoot":"","sources":["../../../src/mutations/bulk/plpgsql-strategy.ts"],"names":[],"mappings":"AACA,OAAO,EAAmC,KAAK,eAAe,EAAE,KAAK,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAGnH,OAAO,EAEL,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EAEtB,KAAK,iBAAiB,EACvB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAqJjD,wBAAgB,4BAA4B,CAC1C,QAAQ,EAAE,iBAAiB,EAC3B,OAAO,GAAE;IACP,cAAc,CAAC,EAAE,MAAM,CAAC;CACpB,GACL,MAAM,CA8HR;AAED,wBAAsB,2BAA2B,CAAC,SAAS,SAAS,iBAAiB,EACnF,EAAE,EAAE,eAAe,CAAC,gBAAgB,EAAE,iBAAiB,CAAC,SAAS,CAAC,CAAC,EACnE,QAAQ,EAAE,SAAS,EACnB,OAAO,GAAE;IACP,cAAc,CAAC,EAAE,MAAM,CAAC;CACpB,GACL,OAAO,CAAC,IAAI,CAAC,CAGf;AAMD,wBAAsB,0BAA0B,CAAC,SAAS,SAAS,iBAAiB,EAClF,EAAE,EAAE,eAAe,CAAC,gBAAgB,EAAE,iBAAiB,CAAC,SAAS,CAAC,CAAC,EACnE,OAAO,GAAE;IACP,cAAc,CAAC,EAAE,MAAM,CAAC;CACpB,GACL,OAAO,CAAC,IAAI,CAAC,CAaf;AAMD,wBAAsB,4BAA4B,CAAC,SAAS,SAAS,iBAAiB,EACpF,EAAE,EAAE,eAAe,CAAC,gBAAgB,EAAE,iBAAiB,CAAC,SAAS,CAAC,CAAC,GAClE,OAAO,CAAC,IAAI,CAAC,CAef;AAED,wBAAsB,mBAAmB,CACvC,EAAE,EAAE,iBAAiB,EACrB,KAAK,EAAE,oBAAoB,EAC3B,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,OAAO,EACnB,UAAU,EAAE,OAAO,EACnB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACnC,OAAO,GAAE;IACP,cAAc,CAAC,EAAE,MAAM,CAAC;CACpB,GACL,OAAO,CAAC,IAAI,CAAC,CAOf"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { PgAsyncDatabase, PgQueryResultHKT } from "drizzle-orm/pg-core";
|
|
2
|
+
import type { Hono } from "hono";
|
|
3
|
+
import type { JwtClaims, RegistryRelations, SyncTableRegistry } from "@pgxsinkit/contracts";
|
|
4
|
+
import type { OperationsLogConfig } from "../../operations-log/types";
|
|
5
|
+
import type { BulkMutationBackend } from "./types";
|
|
6
|
+
export declare function registerBulkMutationRoute<TRegistry extends SyncTableRegistry>(app: Hono, db: PgAsyncDatabase<PgQueryResultHKT, RegistryRelations<TRegistry>>, registry: TRegistry, backend: BulkMutationBackend, operationsLogConfig: OperationsLogConfig, operationsLogReady: Promise<void>, resolveAuthClaims?: (request: Request) => Promise<JwtClaims | null> | JwtClaims | null): void;
|
|
7
|
+
//# sourceMappingURL=route.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../src/mutations/bulk/route.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAG7E,OAAO,KAAK,EAAW,IAAI,EAAE,MAAM,MAAM,CAAC;AAE1C,OAAO,KAAK,EAEV,SAAS,EAET,iBAAiB,EAEjB,iBAAiB,EAClB,MAAM,sBAAsB,CAAC;AAM9B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AAGtE,OAAO,KAAK,EAAE,mBAAmB,EAAqB,MAAM,SAAS,CAAC;AAQtE,wBAAgB,yBAAyB,CAAC,SAAS,SAAS,iBAAiB,EAC3E,GAAG,EAAE,IAAI,EACT,EAAE,EAAE,eAAe,CAAC,gBAAgB,EAAE,iBAAiB,CAAC,SAAS,CAAC,CAAC,EACnE,QAAQ,EAAE,SAAS,EACnB,OAAO,EAAE,mBAAmB,EAC5B,mBAAmB,EAAE,mBAAmB,EACxC,kBAAkB,EAAE,OAAO,CAAC,IAAI,CAAC,EACjC,iBAAiB,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,SAAS,GAAG,IAAI,CAAC,GAAG,SAAS,GAAG,IAAI,QA8QvF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/mutations/bulk/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,mBAAmB,GAAG,uBAAuB,CAAC;AAE1D,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CAC/C"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { PgAsyncDatabase, PgQueryResultHKT } from "drizzle-orm/pg-core";
|
|
2
|
+
import type { RegistryRelations, SyncTableRegistry } from "@pgxsinkit/contracts";
|
|
3
|
+
import type { OperationsLogConfig } from "./types";
|
|
4
|
+
/**
|
|
5
|
+
* Ensures the operations_log table exists in the database.
|
|
6
|
+
*
|
|
7
|
+
* Returns `true` if the table is present, `false` if missing.
|
|
8
|
+
* Consumers should include `operationsLogTable` from `@pgxsinkit/server`
|
|
9
|
+
* in their Drizzle schema so `drizzle-kit generate`/`push` creates it.
|
|
10
|
+
*/
|
|
11
|
+
export declare function ensureOperationsLogSchema<TRegistry extends SyncTableRegistry>(db: PgAsyncDatabase<PgQueryResultHKT, RegistryRelations<TRegistry>>, config: OperationsLogConfig): Promise<boolean>;
|
|
12
|
+
//# sourceMappingURL=ddl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ddl.d.ts","sourceRoot":"","sources":["../../src/operations-log/ddl.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAE7E,OAAO,KAAK,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEjF,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAMnD;;;;;;GAMG;AACH,wBAAsB,yBAAyB,CAAC,SAAS,SAAS,iBAAiB,EACjF,EAAE,EAAE,eAAe,CAAC,gBAAgB,EAAE,iBAAiB,CAAC,SAAS,CAAC,CAAC,EACnE,MAAM,EAAE,mBAAmB,GAC1B,OAAO,CAAC,OAAO,CAAC,CA0BlB"}
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
export declare const operationsLogTable: import("drizzle-orm/pg-core").PgTableWithColumns<{
|
|
2
|
+
name: "operations_log";
|
|
3
|
+
schema: undefined;
|
|
4
|
+
columns: {
|
|
5
|
+
id: import("drizzle-orm/pg-core").PgBuildColumn<"operations_log", import("drizzle-orm/pg-core").SetIsPrimaryKey<import("drizzle-orm/pg-core").PgBigSerial53Builder>, {
|
|
6
|
+
name: string;
|
|
7
|
+
tableName: "operations_log";
|
|
8
|
+
dataType: "number int53";
|
|
9
|
+
data: number;
|
|
10
|
+
driverParam: number;
|
|
11
|
+
notNull: true;
|
|
12
|
+
hasDefault: true;
|
|
13
|
+
isPrimaryKey: false;
|
|
14
|
+
isAutoincrement: false;
|
|
15
|
+
hasRuntimeDefault: false;
|
|
16
|
+
enumValues: undefined;
|
|
17
|
+
identity: undefined;
|
|
18
|
+
generated: undefined;
|
|
19
|
+
}>;
|
|
20
|
+
source: import("drizzle-orm/pg-core").PgBuildColumn<"operations_log", import("drizzle-orm/pg-core").SetNotNull<import("drizzle-orm/pg-core").PgVarcharBuilder<[string, ...string[]]>>, {
|
|
21
|
+
name: string;
|
|
22
|
+
tableName: "operations_log";
|
|
23
|
+
dataType: "string";
|
|
24
|
+
data: string;
|
|
25
|
+
driverParam: string;
|
|
26
|
+
notNull: true;
|
|
27
|
+
hasDefault: false;
|
|
28
|
+
isPrimaryKey: false;
|
|
29
|
+
isAutoincrement: false;
|
|
30
|
+
hasRuntimeDefault: false;
|
|
31
|
+
enumValues: undefined;
|
|
32
|
+
identity: undefined;
|
|
33
|
+
generated: undefined;
|
|
34
|
+
}>;
|
|
35
|
+
backend: import("drizzle-orm/pg-core").PgBuildColumn<"operations_log", import("drizzle-orm/pg-core").SetNotNull<import("drizzle-orm/pg-core").PgVarcharBuilder<[string, ...string[]]>>, {
|
|
36
|
+
name: string;
|
|
37
|
+
tableName: "operations_log";
|
|
38
|
+
dataType: "string";
|
|
39
|
+
data: string;
|
|
40
|
+
driverParam: string;
|
|
41
|
+
notNull: true;
|
|
42
|
+
hasDefault: false;
|
|
43
|
+
isPrimaryKey: false;
|
|
44
|
+
isAutoincrement: false;
|
|
45
|
+
hasRuntimeDefault: false;
|
|
46
|
+
enumValues: undefined;
|
|
47
|
+
identity: undefined;
|
|
48
|
+
generated: undefined;
|
|
49
|
+
}>;
|
|
50
|
+
tableName: import("drizzle-orm/pg-core").PgBuildColumn<"operations_log", import("drizzle-orm/pg-core").PgVarcharBuilder<[string, ...string[]]>, {
|
|
51
|
+
name: string;
|
|
52
|
+
tableName: "operations_log";
|
|
53
|
+
dataType: "string";
|
|
54
|
+
data: string;
|
|
55
|
+
driverParam: string;
|
|
56
|
+
notNull: false;
|
|
57
|
+
hasDefault: false;
|
|
58
|
+
isPrimaryKey: false;
|
|
59
|
+
isAutoincrement: false;
|
|
60
|
+
hasRuntimeDefault: false;
|
|
61
|
+
enumValues: undefined;
|
|
62
|
+
identity: undefined;
|
|
63
|
+
generated: undefined;
|
|
64
|
+
}>;
|
|
65
|
+
operationKind: import("drizzle-orm/pg-core").PgBuildColumn<"operations_log", import("drizzle-orm/pg-core").PgVarcharBuilder<[string, ...string[]]>, {
|
|
66
|
+
name: string;
|
|
67
|
+
tableName: "operations_log";
|
|
68
|
+
dataType: "string";
|
|
69
|
+
data: string;
|
|
70
|
+
driverParam: string;
|
|
71
|
+
notNull: false;
|
|
72
|
+
hasDefault: false;
|
|
73
|
+
isPrimaryKey: false;
|
|
74
|
+
isAutoincrement: false;
|
|
75
|
+
hasRuntimeDefault: false;
|
|
76
|
+
enumValues: undefined;
|
|
77
|
+
identity: undefined;
|
|
78
|
+
generated: undefined;
|
|
79
|
+
}>;
|
|
80
|
+
userId: import("drizzle-orm/pg-core").PgBuildColumn<"operations_log", import("drizzle-orm/pg-core").PgUUIDBuilder, {
|
|
81
|
+
name: string;
|
|
82
|
+
tableName: "operations_log";
|
|
83
|
+
dataType: "string uuid";
|
|
84
|
+
data: string;
|
|
85
|
+
driverParam: string;
|
|
86
|
+
notNull: false;
|
|
87
|
+
hasDefault: false;
|
|
88
|
+
isPrimaryKey: false;
|
|
89
|
+
isAutoincrement: false;
|
|
90
|
+
hasRuntimeDefault: false;
|
|
91
|
+
enumValues: undefined;
|
|
92
|
+
identity: undefined;
|
|
93
|
+
generated: undefined;
|
|
94
|
+
}>;
|
|
95
|
+
entityKeyJson: import("drizzle-orm/pg-core").PgBuildColumn<"operations_log", import("drizzle-orm/pg-core").PgJsonbBuilder, {
|
|
96
|
+
name: string;
|
|
97
|
+
tableName: "operations_log";
|
|
98
|
+
dataType: "object json";
|
|
99
|
+
data: unknown;
|
|
100
|
+
driverParam: unknown;
|
|
101
|
+
notNull: false;
|
|
102
|
+
hasDefault: false;
|
|
103
|
+
isPrimaryKey: false;
|
|
104
|
+
isAutoincrement: false;
|
|
105
|
+
hasRuntimeDefault: false;
|
|
106
|
+
enumValues: undefined;
|
|
107
|
+
identity: undefined;
|
|
108
|
+
generated: undefined;
|
|
109
|
+
}>;
|
|
110
|
+
payloadJson: import("drizzle-orm/pg-core").PgBuildColumn<"operations_log", import("drizzle-orm/pg-core").PgJsonbBuilder, {
|
|
111
|
+
name: string;
|
|
112
|
+
tableName: "operations_log";
|
|
113
|
+
dataType: "object json";
|
|
114
|
+
data: unknown;
|
|
115
|
+
driverParam: unknown;
|
|
116
|
+
notNull: false;
|
|
117
|
+
hasDefault: false;
|
|
118
|
+
isPrimaryKey: false;
|
|
119
|
+
isAutoincrement: false;
|
|
120
|
+
hasRuntimeDefault: false;
|
|
121
|
+
enumValues: undefined;
|
|
122
|
+
identity: undefined;
|
|
123
|
+
generated: undefined;
|
|
124
|
+
}>;
|
|
125
|
+
status: import("drizzle-orm/pg-core").PgBuildColumn<"operations_log", import("drizzle-orm/pg-core").SetNotNull<import("drizzle-orm/pg-core").PgVarcharBuilder<[string, ...string[]]>>, {
|
|
126
|
+
name: string;
|
|
127
|
+
tableName: "operations_log";
|
|
128
|
+
dataType: "string";
|
|
129
|
+
data: string;
|
|
130
|
+
driverParam: string;
|
|
131
|
+
notNull: true;
|
|
132
|
+
hasDefault: false;
|
|
133
|
+
isPrimaryKey: false;
|
|
134
|
+
isAutoincrement: false;
|
|
135
|
+
hasRuntimeDefault: false;
|
|
136
|
+
enumValues: undefined;
|
|
137
|
+
identity: undefined;
|
|
138
|
+
generated: undefined;
|
|
139
|
+
}>;
|
|
140
|
+
errorMessage: import("drizzle-orm/pg-core").PgBuildColumn<"operations_log", import("drizzle-orm/pg-core").PgTextBuilder<[string, ...string[]]>, {
|
|
141
|
+
name: string;
|
|
142
|
+
tableName: "operations_log";
|
|
143
|
+
dataType: "string";
|
|
144
|
+
data: string;
|
|
145
|
+
driverParam: string;
|
|
146
|
+
notNull: false;
|
|
147
|
+
hasDefault: false;
|
|
148
|
+
isPrimaryKey: false;
|
|
149
|
+
isAutoincrement: false;
|
|
150
|
+
hasRuntimeDefault: false;
|
|
151
|
+
enumValues: undefined;
|
|
152
|
+
identity: undefined;
|
|
153
|
+
generated: undefined;
|
|
154
|
+
}>;
|
|
155
|
+
httpStatus: import("drizzle-orm/pg-core").PgBuildColumn<"operations_log", import("drizzle-orm/pg-core").PgIntegerBuilder, {
|
|
156
|
+
name: string;
|
|
157
|
+
tableName: "operations_log";
|
|
158
|
+
dataType: "number int32";
|
|
159
|
+
data: number;
|
|
160
|
+
driverParam: string | number;
|
|
161
|
+
notNull: false;
|
|
162
|
+
hasDefault: false;
|
|
163
|
+
isPrimaryKey: false;
|
|
164
|
+
isAutoincrement: false;
|
|
165
|
+
hasRuntimeDefault: false;
|
|
166
|
+
enumValues: undefined;
|
|
167
|
+
identity: undefined;
|
|
168
|
+
generated: undefined;
|
|
169
|
+
}>;
|
|
170
|
+
mutationId: import("drizzle-orm/pg-core").PgBuildColumn<"operations_log", import("drizzle-orm/pg-core").PgUUIDBuilder, {
|
|
171
|
+
name: string;
|
|
172
|
+
tableName: "operations_log";
|
|
173
|
+
dataType: "string uuid";
|
|
174
|
+
data: string;
|
|
175
|
+
driverParam: string;
|
|
176
|
+
notNull: false;
|
|
177
|
+
hasDefault: false;
|
|
178
|
+
isPrimaryKey: false;
|
|
179
|
+
isAutoincrement: false;
|
|
180
|
+
hasRuntimeDefault: false;
|
|
181
|
+
enumValues: undefined;
|
|
182
|
+
identity: undefined;
|
|
183
|
+
generated: undefined;
|
|
184
|
+
}>;
|
|
185
|
+
mutationSeq: import("drizzle-orm/pg-core").PgBuildColumn<"operations_log", import("drizzle-orm/pg-core").PgIntegerBuilder, {
|
|
186
|
+
name: string;
|
|
187
|
+
tableName: "operations_log";
|
|
188
|
+
dataType: "number int32";
|
|
189
|
+
data: number;
|
|
190
|
+
driverParam: string | number;
|
|
191
|
+
notNull: false;
|
|
192
|
+
hasDefault: false;
|
|
193
|
+
isPrimaryKey: false;
|
|
194
|
+
isAutoincrement: false;
|
|
195
|
+
hasRuntimeDefault: false;
|
|
196
|
+
enumValues: undefined;
|
|
197
|
+
identity: undefined;
|
|
198
|
+
generated: undefined;
|
|
199
|
+
}>;
|
|
200
|
+
clientTimestampUs: import("drizzle-orm/pg-core").PgBuildColumn<"operations_log", import("drizzle-orm/pg-core").PgBigInt64Builder, {
|
|
201
|
+
name: string;
|
|
202
|
+
tableName: "operations_log";
|
|
203
|
+
dataType: "bigint int64";
|
|
204
|
+
data: bigint;
|
|
205
|
+
driverParam: string;
|
|
206
|
+
notNull: false;
|
|
207
|
+
hasDefault: false;
|
|
208
|
+
isPrimaryKey: false;
|
|
209
|
+
isAutoincrement: false;
|
|
210
|
+
hasRuntimeDefault: false;
|
|
211
|
+
enumValues: undefined;
|
|
212
|
+
identity: undefined;
|
|
213
|
+
generated: undefined;
|
|
214
|
+
}>;
|
|
215
|
+
requestPath: import("drizzle-orm/pg-core").PgBuildColumn<"operations_log", import("drizzle-orm/pg-core").PgTextBuilder<[string, ...string[]]>, {
|
|
216
|
+
name: string;
|
|
217
|
+
tableName: "operations_log";
|
|
218
|
+
dataType: "string";
|
|
219
|
+
data: string;
|
|
220
|
+
driverParam: string;
|
|
221
|
+
notNull: false;
|
|
222
|
+
hasDefault: false;
|
|
223
|
+
isPrimaryKey: false;
|
|
224
|
+
isAutoincrement: false;
|
|
225
|
+
hasRuntimeDefault: false;
|
|
226
|
+
enumValues: undefined;
|
|
227
|
+
identity: undefined;
|
|
228
|
+
generated: undefined;
|
|
229
|
+
}>;
|
|
230
|
+
serverTimestampUs: import("drizzle-orm/pg-core").PgBuildColumn<"operations_log", import("drizzle-orm/pg-core").SetHasDefault<import("drizzle-orm/pg-core").SetNotNull<import("drizzle-orm/pg-core").PgBigInt64Builder>>, {
|
|
231
|
+
name: string;
|
|
232
|
+
tableName: "operations_log";
|
|
233
|
+
dataType: "bigint int64";
|
|
234
|
+
data: bigint;
|
|
235
|
+
driverParam: string;
|
|
236
|
+
notNull: true;
|
|
237
|
+
hasDefault: true;
|
|
238
|
+
isPrimaryKey: false;
|
|
239
|
+
isAutoincrement: false;
|
|
240
|
+
hasRuntimeDefault: false;
|
|
241
|
+
enumValues: undefined;
|
|
242
|
+
identity: undefined;
|
|
243
|
+
generated: undefined;
|
|
244
|
+
}>;
|
|
245
|
+
createdAt: import("drizzle-orm/pg-core").PgBuildColumn<"operations_log", import("drizzle-orm/pg-core").SetHasDefault<import("drizzle-orm/pg-core").SetNotNull<import("drizzle-orm/pg-core").PgTimestampBuilder>>, {
|
|
246
|
+
name: string;
|
|
247
|
+
tableName: "operations_log";
|
|
248
|
+
dataType: "object date";
|
|
249
|
+
data: Date;
|
|
250
|
+
driverParam: string;
|
|
251
|
+
notNull: true;
|
|
252
|
+
hasDefault: true;
|
|
253
|
+
isPrimaryKey: false;
|
|
254
|
+
isAutoincrement: false;
|
|
255
|
+
hasRuntimeDefault: false;
|
|
256
|
+
enumValues: undefined;
|
|
257
|
+
identity: undefined;
|
|
258
|
+
generated: undefined;
|
|
259
|
+
}>;
|
|
260
|
+
};
|
|
261
|
+
dialect: 'pg';
|
|
262
|
+
}>;
|
|
263
|
+
export type OperationsLogRow = typeof operationsLogTable.$inferSelect;
|
|
264
|
+
export type NewOperationsLogRow = typeof operationsLogTable.$inferInsert;
|
|
265
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/operations-log/schema.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA4B9B,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,OAAO,kBAAkB,CAAC,YAAY,CAAC;AACtE,MAAM,MAAM,mBAAmB,GAAG,OAAO,kBAAkB,CAAC,YAAY,CAAC"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { SQLWrapper } from "drizzle-orm";
|
|
2
|
+
import type { AnyPgTable } from "drizzle-orm/pg-core";
|
|
3
|
+
export type OpsLogSource = "crud" | "batch";
|
|
4
|
+
export type OpsLogBackend = "bulk-plpgsql-artifact";
|
|
5
|
+
export type OpsLogStatus = "succeeded" | "validation_failed" | "not_found" | "execution_failed";
|
|
6
|
+
export interface OperationsLogConfig {
|
|
7
|
+
enabled: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface OpsLogEntry {
|
|
10
|
+
source: OpsLogSource;
|
|
11
|
+
backend: OpsLogBackend;
|
|
12
|
+
tableName?: string | null;
|
|
13
|
+
operationKind?: "create" | "update" | "delete" | null;
|
|
14
|
+
userId?: string | null;
|
|
15
|
+
entityKey?: Record<string, string> | null;
|
|
16
|
+
payload?: unknown;
|
|
17
|
+
status: OpsLogStatus;
|
|
18
|
+
errorMessage?: string | null;
|
|
19
|
+
httpStatus?: number | null;
|
|
20
|
+
mutationId?: string | null;
|
|
21
|
+
mutationSeq?: number | null;
|
|
22
|
+
clientTimestampUs?: string | null;
|
|
23
|
+
requestPath?: string | null;
|
|
24
|
+
}
|
|
25
|
+
export interface SqlExecutor {
|
|
26
|
+
execute: (query: string | SQLWrapper<unknown>) => Promise<unknown>;
|
|
27
|
+
insert: (table: AnyPgTable) => {
|
|
28
|
+
values: (values: Record<string, unknown>) => PromiseLike<unknown>;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/operations-log/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,OAAO,CAAC;AAE5C,MAAM,MAAM,aAAa,GAAG,uBAAuB,CAAC;AAEpD,MAAM,MAAM,YAAY,GAAG,WAAW,GAAG,mBAAmB,GAAG,WAAW,GAAG,kBAAkB,CAAC;AAEhG,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,EAAE,YAAY,CAAC;IACrB,OAAO,EAAE,aAAa,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,aAAa,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,IAAI,CAAC;IACtD,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAAC;IAC1C,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,YAAY,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,iBAAiB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAClC,WAAW,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,CAAC,OAAO,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IACnE,MAAM,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK;QAC7B,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,WAAW,CAAC,OAAO,CAAC,CAAC;KACnE,CAAC;CACH"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { OpsLogEntry, OperationsLogConfig, SqlExecutor } from "./types";
|
|
2
|
+
export declare function logOperation(executor: SqlExecutor, config: OperationsLogConfig, entry: OpsLogEntry): Promise<void>;
|
|
3
|
+
export declare function logOperationSafely(executor: SqlExecutor, config: OperationsLogConfig, entry: OpsLogEntry): Promise<void>;
|
|
4
|
+
//# sourceMappingURL=writer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"writer.d.ts","sourceRoot":"","sources":["../../src/operations-log/writer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAkB7E,wBAAsB,YAAY,CAChC,QAAQ,EAAE,WAAW,EACrB,MAAM,EAAE,mBAAmB,EAC3B,KAAK,EAAE,WAAW,GACjB,OAAO,CAAC,IAAI,CAAC,CAqBf;AAED,wBAAsB,kBAAkB,CACtC,QAAQ,EAAE,WAAW,EACrB,MAAM,EAAE,mBAAmB,EAC3B,KAAK,EAAE,WAAW,GACjB,OAAO,CAAC,IAAI,CAAC,CAMf"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pgxsinkit/server",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.31",
|
|
4
4
|
"bin": {
|
|
5
5
|
"pgxsinkit-generate": "src/cli/generate.ts"
|
|
6
6
|
},
|
|
@@ -11,10 +11,10 @@
|
|
|
11
11
|
],
|
|
12
12
|
"type": "module",
|
|
13
13
|
"main": "./dist/index.js",
|
|
14
|
-
"types": "./
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
15
|
"exports": {
|
|
16
16
|
".": {
|
|
17
|
-
"types": "./
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
18
|
"default": "./dist/index.js"
|
|
19
19
|
}
|
|
20
20
|
},
|
|
@@ -25,10 +25,10 @@
|
|
|
25
25
|
"build": "bun --cwd ../.. run build:public-packages"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@pgxsinkit/contracts": "^0.1.
|
|
28
|
+
"@pgxsinkit/contracts": "^0.1.31"
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
31
|
"drizzle-orm": "1.0.0-rc.2",
|
|
32
|
-
"hono": "^4.12.
|
|
32
|
+
"hono": "^4.12.25"
|
|
33
33
|
}
|
|
34
34
|
}
|
package/src/electric-proxy.ts
CHANGED
|
@@ -2,6 +2,8 @@ import {
|
|
|
2
2
|
buildRowFilterWhere,
|
|
3
3
|
getOmittedProjectedColumnNames,
|
|
4
4
|
type JwtClaims,
|
|
5
|
+
type RowTransform,
|
|
6
|
+
type RowTransformContext,
|
|
5
7
|
type SyncTableRegistry,
|
|
6
8
|
} from "@pgxsinkit/contracts";
|
|
7
9
|
|
|
@@ -46,17 +48,22 @@ export async function proxyElectricShapeRequest(
|
|
|
46
48
|
|
|
47
49
|
const table = new URL(request.url).searchParams.get("table");
|
|
48
50
|
const omittedColumns = table ? getOmittedProjectedColumnsForTable(options.registry, table) : [];
|
|
51
|
+
const rowTransform = table ? getRowTransformForTable(options.registry, table) : undefined;
|
|
49
52
|
const contentType = responseHeaders.get("content-type") ?? "";
|
|
50
53
|
|
|
51
|
-
|
|
54
|
+
// Re-serialize the shape log when this table needs any row-level rewriting: column
|
|
55
|
+
// omission and/or a registry-declared row transform. The transform runs first so it can
|
|
56
|
+
// read a column (e.g. a control flag) that omission then strips from the client row.
|
|
57
|
+
if ((omittedColumns.length > 0 || rowTransform) && contentType.includes("application/json")) {
|
|
52
58
|
const payload = await response
|
|
53
59
|
.clone()
|
|
54
60
|
.json()
|
|
55
61
|
.catch(() => undefined);
|
|
56
62
|
|
|
57
63
|
if (Array.isArray(payload)) {
|
|
58
|
-
const
|
|
59
|
-
|
|
64
|
+
const context: RowTransformContext = { claims, ...(options.extraParams ? { params: options.extraParams } : {}) };
|
|
65
|
+
const rewritten = rewriteShapeLogEntries(payload, omittedColumns, rowTransform, context);
|
|
66
|
+
return new Response(JSON.stringify(rewritten), {
|
|
60
67
|
status: response.status,
|
|
61
68
|
statusText: response.statusText,
|
|
62
69
|
headers: responseHeaders,
|
|
@@ -133,6 +140,10 @@ function getOmittedProjectedColumnsForTable(registry: SyncTableRegistry, table:
|
|
|
133
140
|
return entry ? getOmittedProjectedColumnNames(entry) : [];
|
|
134
141
|
}
|
|
135
142
|
|
|
143
|
+
function getRowTransformForTable(registry: SyncTableRegistry, table: string): RowTransform | undefined {
|
|
144
|
+
return getRegistryEntry(registry, table)?.clientProjection?.rowTransform;
|
|
145
|
+
}
|
|
146
|
+
|
|
136
147
|
function isObjectRecord(value: unknown): value is Record<string, unknown> {
|
|
137
148
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
138
149
|
}
|
|
@@ -152,26 +163,45 @@ function isShapeLogEntry(value: unknown): value is ShapeLogEntry {
|
|
|
152
163
|
return isObjectRecord(value);
|
|
153
164
|
}
|
|
154
165
|
|
|
155
|
-
|
|
166
|
+
/**
|
|
167
|
+
* Rewrite each shape-log row: apply the registry row transform (if any), then strip
|
|
168
|
+
* omitted columns. Both passes preserve object identity when nothing changes, so an
|
|
169
|
+
* untouched entry flows through unmodified.
|
|
170
|
+
*/
|
|
171
|
+
function rewriteRow(
|
|
172
|
+
row: Record<string, unknown>,
|
|
173
|
+
omittedColumns: readonly string[],
|
|
174
|
+
rowTransform: RowTransform | undefined,
|
|
175
|
+
context: RowTransformContext,
|
|
176
|
+
): Record<string, unknown> {
|
|
177
|
+
const transformed = rowTransform ? rowTransform(row, context) : row;
|
|
178
|
+
return omittedColumns.length > 0 ? omitColumnsFromRow(transformed, omittedColumns) : transformed;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function rewriteShapeLogEntries(
|
|
182
|
+
payload: unknown[],
|
|
183
|
+
omittedColumns: readonly string[],
|
|
184
|
+
rowTransform: RowTransform | undefined,
|
|
185
|
+
context: RowTransformContext,
|
|
186
|
+
): unknown[] {
|
|
156
187
|
return payload.map((entry) => {
|
|
157
188
|
if (!isShapeLogEntry(entry)) {
|
|
158
189
|
return entry;
|
|
159
190
|
}
|
|
160
191
|
|
|
161
|
-
let
|
|
192
|
+
let currentEntry: ShapeLogEntry = entry;
|
|
162
193
|
|
|
163
194
|
if (isObjectRecord(entry.value)) {
|
|
164
|
-
const nextValue =
|
|
195
|
+
const nextValue = rewriteRow(entry.value, omittedColumns, rowTransform, context);
|
|
165
196
|
if (nextValue !== entry.value) {
|
|
166
|
-
|
|
197
|
+
currentEntry = { ...currentEntry, value: nextValue };
|
|
167
198
|
}
|
|
168
199
|
}
|
|
169
200
|
|
|
170
|
-
const currentEntry = nextEntry ?? entry;
|
|
171
201
|
if (isObjectRecord(currentEntry.old_value)) {
|
|
172
|
-
const nextOldValue =
|
|
202
|
+
const nextOldValue = rewriteRow(currentEntry.old_value, omittedColumns, rowTransform, context);
|
|
173
203
|
if (nextOldValue !== currentEntry.old_value) {
|
|
174
|
-
|
|
204
|
+
currentEntry = { ...currentEntry, old_value: nextOldValue };
|
|
175
205
|
}
|
|
176
206
|
}
|
|
177
207
|
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { PgAsyncDatabase } from "drizzle-orm/pg-core";
|
|
1
|
+
import type { PgAsyncDatabase, PgQueryResultHKT } from "drizzle-orm/pg-core";
|
|
2
2
|
import { Hono } from "hono";
|
|
3
3
|
import { cors } from "hono/cors";
|
|
4
4
|
|
|
@@ -33,7 +33,10 @@ interface BunNamespace {
|
|
|
33
33
|
|
|
34
34
|
export interface CreateSyncServerOptions<
|
|
35
35
|
TRegistry extends SyncTableRegistry,
|
|
36
|
-
TDb extends PgAsyncDatabase<
|
|
36
|
+
TDb extends PgAsyncDatabase<PgQueryResultHKT, RegistryRelations<TRegistry>> = PgAsyncDatabase<
|
|
37
|
+
PgQueryResultHKT,
|
|
38
|
+
RegistryRelations<TRegistry>
|
|
39
|
+
>,
|
|
37
40
|
> {
|
|
38
41
|
registry: TRegistry;
|
|
39
42
|
db: TDb;
|
|
@@ -60,7 +63,10 @@ export interface ServerDiagnostics<TRegistry extends SyncTableRegistry> {
|
|
|
60
63
|
|
|
61
64
|
export interface SyncServer<
|
|
62
65
|
TRegistry extends SyncTableRegistry,
|
|
63
|
-
TDb extends PgAsyncDatabase<
|
|
66
|
+
TDb extends PgAsyncDatabase<PgQueryResultHKT, RegistryRelations<TRegistry>> = PgAsyncDatabase<
|
|
67
|
+
PgQueryResultHKT,
|
|
68
|
+
RegistryRelations<TRegistry>
|
|
69
|
+
>,
|
|
64
70
|
> {
|
|
65
71
|
drizzle: TDb;
|
|
66
72
|
fetch: (request: Request) => Promise<Response>;
|
|
@@ -74,7 +80,10 @@ export interface SyncServer<
|
|
|
74
80
|
|
|
75
81
|
export function createSyncServer<
|
|
76
82
|
TRegistry extends SyncTableRegistry,
|
|
77
|
-
TDb extends PgAsyncDatabase<
|
|
83
|
+
TDb extends PgAsyncDatabase<PgQueryResultHKT, RegistryRelations<TRegistry>> = PgAsyncDatabase<
|
|
84
|
+
PgQueryResultHKT,
|
|
85
|
+
RegistryRelations<TRegistry>
|
|
86
|
+
>,
|
|
78
87
|
>(options: CreateSyncServerOptions<TRegistry, TDb>): SyncServer<TRegistry, TDb> {
|
|
79
88
|
const ownsApp = !options.app;
|
|
80
89
|
const db = options.db;
|
|
@@ -151,7 +160,7 @@ export function createSyncServer<
|
|
|
151
160
|
fetch,
|
|
152
161
|
request: (path, init) => {
|
|
153
162
|
const baseUrl = address === null ? "http://localhost" : `http://${address.host}:${address.port}`;
|
|
154
|
-
return fetch(new Request(new URL(path, baseUrl), init));
|
|
163
|
+
return fetch(new Request(new URL(path, baseUrl).toString(), init));
|
|
155
164
|
},
|
|
156
165
|
start: async () => {
|
|
157
166
|
if (bunServer) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getTableName, sql } from "drizzle-orm";
|
|
2
|
-
import { getTableConfig, type AnyPgTable, type PgAsyncDatabase } from "drizzle-orm/pg-core";
|
|
2
|
+
import { getTableConfig, type AnyPgTable, type PgAsyncDatabase, type PgQueryResultHKT } from "drizzle-orm/pg-core";
|
|
3
3
|
import { getColumns } from "drizzle-orm/utils";
|
|
4
4
|
|
|
5
5
|
import {
|
|
@@ -293,7 +293,7 @@ $$;
|
|
|
293
293
|
}
|
|
294
294
|
|
|
295
295
|
export async function installPlpgsqlBatchFunction<TRegistry extends SyncTableRegistry>(
|
|
296
|
-
db: PgAsyncDatabase<
|
|
296
|
+
db: PgAsyncDatabase<PgQueryResultHKT, RegistryRelations<TRegistry>>,
|
|
297
297
|
registry: TRegistry,
|
|
298
298
|
options: {
|
|
299
299
|
functionSchema?: string;
|
|
@@ -308,7 +308,7 @@ type FunctionPresenceRow = {
|
|
|
308
308
|
};
|
|
309
309
|
|
|
310
310
|
export async function verifyPlpgsqlBatchFunction<TRegistry extends SyncTableRegistry>(
|
|
311
|
-
db: PgAsyncDatabase<
|
|
311
|
+
db: PgAsyncDatabase<PgQueryResultHKT, RegistryRelations<TRegistry>>,
|
|
312
312
|
options: {
|
|
313
313
|
functionSchema?: string;
|
|
314
314
|
} = {},
|
|
@@ -318,7 +318,7 @@ export async function verifyPlpgsqlBatchFunction<TRegistry extends SyncTableRegi
|
|
|
318
318
|
SELECT to_regprocedure(${functionSignature})::text AS "functionName"
|
|
319
319
|
`);
|
|
320
320
|
|
|
321
|
-
const row = Array.from(result
|
|
321
|
+
const row = Array.from(result as Iterable<unknown>, (entry) => entry as FunctionPresenceRow)[0];
|
|
322
322
|
|
|
323
323
|
if (!row?.functionName) {
|
|
324
324
|
throw new Error(
|
|
@@ -332,14 +332,14 @@ type AuthHelperPresenceRow = {
|
|
|
332
332
|
};
|
|
333
333
|
|
|
334
334
|
export async function verifyArtifactRlsAuthHelpers<TRegistry extends SyncTableRegistry>(
|
|
335
|
-
db: PgAsyncDatabase<
|
|
335
|
+
db: PgAsyncDatabase<PgQueryResultHKT, RegistryRelations<TRegistry>>,
|
|
336
336
|
): Promise<void> {
|
|
337
337
|
const result = await db.execute<AuthHelperPresenceRow>(sql`
|
|
338
338
|
SELECT
|
|
339
339
|
to_regprocedure('auth.uid()')::text AS "authUid"
|
|
340
340
|
`);
|
|
341
341
|
|
|
342
|
-
const row = Array.from(result
|
|
342
|
+
const row = Array.from(result as Iterable<unknown>, (entry) => entry as AuthHelperPresenceRow)[0];
|
|
343
343
|
const missingHelpers = [row?.authUid ? null : "auth.uid()"].filter((value): value is string => value !== null);
|
|
344
344
|
|
|
345
345
|
if (missingHelpers.length > 0) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { and, eq, sql } from "drizzle-orm";
|
|
1
|
+
import { and, eq, sql, type AnyRelations } from "drizzle-orm";
|
|
2
2
|
import { getTableConfig, type AnyPgTable } from "drizzle-orm/pg-core";
|
|
3
|
-
import type { PgAsyncDatabase } from "drizzle-orm/pg-core";
|
|
3
|
+
import type { PgAsyncDatabase, PgQueryResultHKT } from "drizzle-orm/pg-core";
|
|
4
4
|
import { getColumns } from "drizzle-orm/utils";
|
|
5
5
|
import { createSchemaFactory } from "drizzle-orm/zod";
|
|
6
6
|
import type { Context, Hono } from "hono";
|
|
@@ -27,11 +27,11 @@ const { createInsertSchema: createMutationInsertSchema } = createSchemaFactory({
|
|
|
27
27
|
coerce: { date: true },
|
|
28
28
|
});
|
|
29
29
|
|
|
30
|
-
type RouteReadQueryClient = Pick<PgAsyncDatabase<
|
|
30
|
+
type RouteReadQueryClient = Pick<PgAsyncDatabase<PgQueryResultHKT, AnyRelations>, "select">;
|
|
31
31
|
|
|
32
32
|
export function registerBulkMutationRoute<TRegistry extends SyncTableRegistry>(
|
|
33
33
|
app: Hono,
|
|
34
|
-
db: PgAsyncDatabase<
|
|
34
|
+
db: PgAsyncDatabase<PgQueryResultHKT, RegistryRelations<TRegistry>>,
|
|
35
35
|
registry: TRegistry,
|
|
36
36
|
backend: BulkMutationBackend,
|
|
37
37
|
operationsLogConfig: OperationsLogConfig,
|
|
@@ -568,7 +568,7 @@ async function readServerUpdatedAtUs(
|
|
|
568
568
|
}
|
|
569
569
|
|
|
570
570
|
async function installBulkStartupDdl<TRegistry extends SyncTableRegistry>(
|
|
571
|
-
db: PgAsyncDatabase<
|
|
571
|
+
db: PgAsyncDatabase<PgQueryResultHKT, RegistryRelations<TRegistry>>,
|
|
572
572
|
registry: TRegistry,
|
|
573
573
|
_backend: BulkMutationBackend,
|
|
574
574
|
): Promise<void> {
|