@rocicorp/zero 1.4.0 → 1.5.0-canary.1
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/out/analyze-query/src/analyze-cli.js +2 -2
- package/out/analyze-query/src/analyze-cli.js.map +1 -1
- package/out/zero/package.js +1 -1
- package/out/zero/package.js.map +1 -1
- package/out/zero-cache/src/auth/auth.d.ts +1 -1
- package/out/zero-cache/src/auth/auth.d.ts.map +1 -1
- package/out/zero-cache/src/auth/auth.js +1 -1
- package/out/zero-cache/src/auth/auth.js.map +1 -1
- package/out/zero-cache/src/auth/write-authorizer.d.ts +1 -1
- package/out/zero-cache/src/auth/write-authorizer.d.ts.map +1 -1
- package/out/zero-cache/src/auth/write-authorizer.js.map +1 -1
- package/out/zero-cache/src/config/normalize.d.ts.map +1 -1
- package/out/zero-cache/src/config/normalize.js +8 -0
- package/out/zero-cache/src/config/normalize.js.map +1 -1
- package/out/zero-cache/src/config/zero-config.d.ts +8 -4
- package/out/zero-cache/src/config/zero-config.d.ts.map +1 -1
- package/out/zero-cache/src/config/zero-config.js +28 -6
- package/out/zero-cache/src/config/zero-config.js.map +1 -1
- package/out/zero-cache/src/custom/fetch.d.ts +1 -1
- package/out/zero-cache/src/custom/fetch.d.ts.map +1 -1
- package/out/zero-cache/src/custom/fetch.js +2 -2
- package/out/zero-cache/src/custom/fetch.js.map +1 -1
- package/out/zero-cache/src/custom-queries/transform-query.d.ts +21 -7
- package/out/zero-cache/src/custom-queries/transform-query.d.ts.map +1 -1
- package/out/zero-cache/src/custom-queries/transform-query.js +26 -9
- package/out/zero-cache/src/custom-queries/transform-query.js.map +1 -1
- package/out/zero-cache/src/server/change-streamer.d.ts.map +1 -1
- package/out/zero-cache/src/server/change-streamer.js +2 -1
- package/out/zero-cache/src/server/change-streamer.js.map +1 -1
- package/out/zero-cache/src/server/runner/run-worker.d.ts.map +1 -1
- package/out/zero-cache/src/server/runner/run-worker.js +5 -2
- package/out/zero-cache/src/server/runner/run-worker.js.map +1 -1
- package/out/zero-cache/src/server/syncer.js +3 -3
- package/out/zero-cache/src/server/syncer.js.map +1 -1
- package/out/zero-cache/src/services/change-source/custom/change-source.js +2 -2
- package/out/zero-cache/src/services/change-source/custom/change-source.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/change-source.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/change-source.js +24 -20
- package/out/zero-cache/src/services/change-source/pg/change-source.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/ddl.d.ts +258 -45
- package/out/zero-cache/src/services/change-source/pg/schema/ddl.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/ddl.js +119 -83
- package/out/zero-cache/src/services/change-source/pg/schema/ddl.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/init.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/init.js +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/init.js.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/shard.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-source/pg/schema/shard.js +2 -1
- package/out/zero-cache/src/services/change-source/pg/schema/shard.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/change-streamer-http.d.ts +1 -0
- package/out/zero-cache/src/services/change-streamer/change-streamer-http.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-streamer/change-streamer-http.js +3 -3
- package/out/zero-cache/src/services/change-streamer/change-streamer-http.js.map +1 -1
- package/out/zero-cache/src/services/http-service.d.ts +1 -0
- package/out/zero-cache/src/services/http-service.d.ts.map +1 -1
- package/out/zero-cache/src/services/http-service.js +5 -4
- package/out/zero-cache/src/services/http-service.js.map +1 -1
- package/out/zero-cache/src/services/life-cycle.d.ts +1 -1
- package/out/zero-cache/src/services/life-cycle.d.ts.map +1 -1
- package/out/zero-cache/src/services/life-cycle.js +1 -2
- package/out/zero-cache/src/services/life-cycle.js.map +1 -1
- package/out/zero-cache/src/services/mutagen/mutagen.d.ts +1 -1
- package/out/zero-cache/src/services/mutagen/mutagen.d.ts.map +1 -1
- package/out/zero-cache/src/services/mutagen/mutagen.js +1 -1
- package/out/zero-cache/src/services/mutagen/mutagen.js.map +1 -1
- package/out/zero-cache/src/services/mutagen/pusher.d.ts +4 -3
- package/out/zero-cache/src/services/mutagen/pusher.d.ts.map +1 -1
- package/out/zero-cache/src/services/mutagen/pusher.js +57 -38
- package/out/zero-cache/src/services/mutagen/pusher.js.map +1 -1
- package/out/zero-cache/src/services/shadow-sync/shadow-sync-service.js +2 -1
- package/out/zero-cache/src/services/shadow-sync/shadow-sync-service.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/client-handler.js +1 -1
- package/out/zero-cache/src/services/view-syncer/client-handler.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/connection-context-manager.d.ts +41 -27
- package/out/zero-cache/src/services/view-syncer/connection-context-manager.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/connection-context-manager.js +147 -104
- package/out/zero-cache/src/services/view-syncer/connection-context-manager.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/cvr.d.ts +6 -0
- package/out/zero-cache/src/services/view-syncer/cvr.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/cvr.js +8 -0
- package/out/zero-cache/src/services/view-syncer/cvr.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/view-syncer.d.ts +3 -3
- package/out/zero-cache/src/services/view-syncer/view-syncer.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/view-syncer.js +119 -86
- package/out/zero-cache/src/services/view-syncer/view-syncer.js.map +1 -1
- package/out/zero-cache/src/workers/connection.js +2 -2
- package/out/zero-cache/src/workers/connection.js.map +1 -1
- package/out/zero-cache/src/workers/syncer-ws-message-handler.d.ts +1 -1
- package/out/zero-cache/src/workers/syncer-ws-message-handler.d.ts.map +1 -1
- package/out/zero-cache/src/workers/syncer-ws-message-handler.js +7 -7
- package/out/zero-cache/src/workers/syncer-ws-message-handler.js.map +1 -1
- package/out/zero-cache/src/workers/syncer.d.ts +1 -1
- package/out/zero-cache/src/workers/syncer.d.ts.map +1 -1
- package/out/zero-cache/src/workers/syncer.js +11 -10
- package/out/zero-cache/src/workers/syncer.js.map +1 -1
- package/out/zero-client/src/client/connection.d.ts +15 -7
- package/out/zero-client/src/client/connection.d.ts.map +1 -1
- package/out/zero-client/src/client/connection.js.map +1 -1
- package/out/zero-client/src/client/crud-impl.d.ts +1 -1
- package/out/zero-client/src/client/crud-impl.d.ts.map +1 -1
- package/out/zero-client/src/client/crud-impl.js +1 -1
- package/out/zero-client/src/client/crud-impl.js.map +1 -1
- package/out/zero-client/src/client/crud.d.ts +1 -1
- package/out/zero-client/src/client/crud.d.ts.map +1 -1
- package/out/zero-client/src/client/crud.js +1 -1
- package/out/zero-client/src/client/crud.js.map +1 -1
- package/out/zero-client/src/client/keys.d.ts +1 -1
- package/out/zero-client/src/client/keys.d.ts.map +1 -1
- package/out/zero-client/src/client/keys.js.map +1 -1
- package/out/zero-client/src/client/make-replicache-mutators.js +1 -1
- package/out/zero-client/src/client/make-replicache-mutators.js.map +1 -1
- package/out/zero-client/src/client/mutation-tracker.d.ts +2 -1
- package/out/zero-client/src/client/mutation-tracker.d.ts.map +1 -1
- package/out/zero-client/src/client/mutation-tracker.js +3 -3
- package/out/zero-client/src/client/mutation-tracker.js.map +1 -1
- package/out/zero-client/src/client/version.js +1 -1
- package/out/zero-client/src/client/zero.d.ts.map +1 -1
- package/out/zero-client/src/client/zero.js +2 -2
- package/out/zero-client/src/client/zero.js.map +1 -1
- package/out/zero-client/src/types/client-state.d.ts +1 -1
- package/out/zero-client/src/types/client-state.d.ts.map +1 -1
- package/out/zero-protocol/src/custom-queries.js +1 -1
- package/out/zero-protocol/src/down.js +1 -1
- package/out/zero-protocol/src/error-kind-enum.d.ts +1 -2
- package/out/zero-protocol/src/error-kind-enum.d.ts.map +1 -1
- package/out/zero-protocol/src/error-kind-enum.js.map +1 -1
- package/out/zero-protocol/src/mutate-server.d.ts +165 -0
- package/out/zero-protocol/src/mutate-server.d.ts.map +1 -0
- package/out/zero-protocol/src/mutate-server.js +24 -0
- package/out/zero-protocol/src/mutate-server.js.map +1 -0
- package/out/zero-protocol/src/mutation.d.ts +229 -0
- package/out/zero-protocol/src/mutation.d.ts.map +1 -0
- package/out/zero-protocol/src/mutation.js +112 -0
- package/out/zero-protocol/src/mutation.js.map +1 -0
- package/out/zero-protocol/src/mutations-patch.js +1 -1
- package/out/zero-protocol/src/mutations-patch.js.map +1 -1
- package/out/zero-protocol/src/push.d.ts +3 -234
- package/out/zero-protocol/src/push.d.ts.map +1 -1
- package/out/zero-protocol/src/push.js +3 -114
- package/out/zero-protocol/src/push.js.map +1 -1
- package/out/zero-protocol/src/query-server.d.ts +150 -0
- package/out/zero-protocol/src/query-server.d.ts.map +1 -0
- package/out/zero-protocol/src/query-server.js +16 -0
- package/out/zero-protocol/src/query-server.js.map +1 -0
- package/out/zero-protocol/src/up.js +1 -1
- package/out/zero-server/src/mod.d.ts +4 -2
- package/out/zero-server/src/mod.d.ts.map +1 -1
- package/out/zero-server/src/process-mutations.d.ts +50 -4
- package/out/zero-server/src/process-mutations.d.ts.map +1 -1
- package/out/zero-server/src/process-mutations.js +73 -36
- package/out/zero-server/src/process-mutations.js.map +1 -1
- package/out/zero-server/src/push-processor.d.ts +3 -3
- package/out/zero-server/src/push-processor.d.ts.map +1 -1
- package/out/zero-server/src/push-processor.js.map +1 -1
- package/out/zero-server/src/queries/process-queries.d.ts +45 -53
- package/out/zero-server/src/queries/process-queries.d.ts.map +1 -1
- package/out/zero-server/src/queries/process-queries.js +72 -53
- package/out/zero-server/src/queries/process-queries.js.map +1 -1
- package/out/zero-server/src/zql-database.js.map +1 -1
- package/out/zero-types/src/default-types.d.ts +1 -0
- package/out/zero-types/src/default-types.d.ts.map +1 -1
- package/out/zql/src/builder/builder.d.ts.map +1 -1
- package/out/zql/src/builder/builder.js +17 -7
- package/out/zql/src/builder/builder.js.map +1 -1
- package/out/zql/src/ivm/cap.d.ts +32 -0
- package/out/zql/src/ivm/cap.d.ts.map +1 -0
- package/out/zql/src/ivm/cap.js +205 -0
- package/out/zql/src/ivm/cap.js.map +1 -0
- package/out/zql/src/ivm/constraint.js +1 -1
- package/out/zql/src/ivm/flipped-join.d.ts.map +1 -1
- package/out/zql/src/ivm/flipped-join.js +61 -15
- package/out/zql/src/ivm/flipped-join.js.map +1 -1
- package/out/zql/src/ivm/memory-source.d.ts.map +1 -1
- package/out/zql/src/ivm/memory-source.js +3 -4
- package/out/zql/src/ivm/memory-source.js.map +1 -1
- package/out/zql/src/ivm/schema.d.ts +8 -0
- package/out/zql/src/ivm/schema.d.ts.map +1 -1
- package/out/zql/src/ivm/take.js +2 -2
- package/out/zql/src/mutate/mutator-registry.js.map +1 -1
- package/out/zql/src/mutate/mutator.d.ts +11 -2
- package/out/zql/src/mutate/mutator.d.ts.map +1 -1
- package/out/zql/src/mutate/mutator.js.map +1 -1
- package/out/zql/src/query/query-registry.d.ts +9 -2
- package/out/zql/src/query/query-registry.d.ts.map +1 -1
- package/out/zql/src/query/query-registry.js.map +1 -1
- package/out/zqlite/src/table-source.d.ts.map +1 -1
- package/out/zqlite/src/table-source.js +4 -1
- package/out/zqlite/src/table-source.js.map +1 -1
- package/package.json +1 -1
|
@@ -45,6 +45,24 @@ export declare const ddlEventSchema: v.ObjectType<Omit<{
|
|
|
45
45
|
tag: v.Type<string>;
|
|
46
46
|
}, undefined>;
|
|
47
47
|
}, undefined>;
|
|
48
|
+
/**
|
|
49
|
+
* A {@link DdlStartEvent} message is emitted before every DDL event, containing
|
|
50
|
+
* the current `schema` and the command `tag`.
|
|
51
|
+
*
|
|
52
|
+
* In most cases, the `DdlStartEvent` itself will not be associated with a
|
|
53
|
+
* schema change, in which case `previousSchema` will be `null`. However, the
|
|
54
|
+
* message is still emitted, both for backwards compatibility and to provide
|
|
55
|
+
* the command `tag` context in case an immediately following `DdlStartEvent`
|
|
56
|
+
* tag is emitted with a schema change (which can happen when another event
|
|
57
|
+
* trigger results in a nested ddl statement).
|
|
58
|
+
*
|
|
59
|
+
* In such cases, the `previousSchema` and `schema` fields of the latter event
|
|
60
|
+
* are used to determine the necessary schema change operations (as they are
|
|
61
|
+
* with `ddlUpdate` and `schemaSnapshot` events), and the `tag` of the
|
|
62
|
+
* preceding start event indicates the command that precipitated the schema
|
|
63
|
+
* change (e.g. a CREATE vs ALTER) to determine whether a backfill is
|
|
64
|
+
* necessary.
|
|
65
|
+
*/
|
|
48
66
|
export declare const ddlStartEventSchema: v.ObjectType<Omit<Omit<{
|
|
49
67
|
context: v.ObjectType<{
|
|
50
68
|
query: v.Type<string>;
|
|
@@ -88,24 +106,51 @@ export declare const ddlStartEventSchema: v.ObjectType<Omit<Omit<{
|
|
|
88
106
|
event: v.ObjectType<{
|
|
89
107
|
tag: v.Type<string>;
|
|
90
108
|
}, undefined>;
|
|
91
|
-
}, "type" | "event"> & {
|
|
109
|
+
}, "type" | "event" | "previousSchema"> & {
|
|
92
110
|
type: v.Type<"ddlStart">;
|
|
111
|
+
previousSchema: v.Optional<{
|
|
112
|
+
indexes: {
|
|
113
|
+
isReplicaIdentity?: boolean | undefined;
|
|
114
|
+
isPrimaryKey?: boolean | undefined;
|
|
115
|
+
isImmediate?: boolean | undefined;
|
|
116
|
+
name: string;
|
|
117
|
+
columns: Record<string, "ASC" | "DESC">;
|
|
118
|
+
schema: string;
|
|
119
|
+
tableName: string;
|
|
120
|
+
unique: boolean;
|
|
121
|
+
}[];
|
|
122
|
+
tables: {
|
|
123
|
+
replicaIdentityColumns: string[];
|
|
124
|
+
primaryKey?: string[] | undefined;
|
|
125
|
+
schemaOID?: number | undefined;
|
|
126
|
+
replicaIdentity?: "n" | "d" | "f" | "i" | undefined;
|
|
127
|
+
name: string;
|
|
128
|
+
schema: string;
|
|
129
|
+
oid: number;
|
|
130
|
+
columns: Record<string, {
|
|
131
|
+
pgTypeClass?: "e" | "d" | "b" | "c" | "p" | "r" | "m" | undefined;
|
|
132
|
+
elemPgTypeClass?: "e" | "d" | "b" | "c" | "p" | "r" | "m" | null | undefined;
|
|
133
|
+
characterMaximumLength?: number | null | undefined;
|
|
134
|
+
notNull?: boolean | null | undefined;
|
|
135
|
+
dflt?: string | null | undefined;
|
|
136
|
+
pos: number;
|
|
137
|
+
dataType: string;
|
|
138
|
+
typeOID: number;
|
|
139
|
+
}>;
|
|
140
|
+
publications: Record<string, {
|
|
141
|
+
rowFilter: string | null;
|
|
142
|
+
}>;
|
|
143
|
+
}[];
|
|
144
|
+
} | null>;
|
|
93
145
|
event: v.Type<{
|
|
94
146
|
tag: string;
|
|
95
147
|
}>;
|
|
96
148
|
}, undefined>;
|
|
97
149
|
export type DdlStartEvent = v.Infer<typeof ddlStartEventSchema>;
|
|
98
150
|
/**
|
|
99
|
-
*
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
* {@link DdlStartEvent}.
|
|
103
|
-
*
|
|
104
|
-
* Note that in almost all cases (the exception being `CREATE` events),
|
|
105
|
-
* it is possible that there is no relevant difference between the
|
|
106
|
-
* ddl-start schema and the ddl-update schema, as many aspects of the
|
|
107
|
-
* schema (e.g. column constraints) are not relevant to downstream
|
|
108
|
-
* replication.
|
|
151
|
+
* A {@link DdlUpdateEvent} is emitted if there was a change in the schema.
|
|
152
|
+
* It always contains `previousSchema` and (current) `schema` fields, leaving
|
|
153
|
+
* it to the receiver to compute the necessary schema change operations.
|
|
109
154
|
*/
|
|
110
155
|
export declare const ddlUpdateEventSchema: v.ObjectType<Omit<Omit<{
|
|
111
156
|
context: v.ObjectType<{
|
|
@@ -150,51 +195,65 @@ export declare const ddlUpdateEventSchema: v.ObjectType<Omit<Omit<{
|
|
|
150
195
|
event: v.ObjectType<{
|
|
151
196
|
tag: v.Type<string>;
|
|
152
197
|
}, undefined>;
|
|
153
|
-
}, "type"> & {
|
|
198
|
+
}, "type" | "previousSchema"> & {
|
|
154
199
|
type: v.Type<"ddlUpdate">;
|
|
200
|
+
previousSchema: v.Optional<{
|
|
201
|
+
indexes: {
|
|
202
|
+
isReplicaIdentity?: boolean | undefined;
|
|
203
|
+
isPrimaryKey?: boolean | undefined;
|
|
204
|
+
isImmediate?: boolean | undefined;
|
|
205
|
+
name: string;
|
|
206
|
+
columns: Record<string, "ASC" | "DESC">;
|
|
207
|
+
schema: string;
|
|
208
|
+
tableName: string;
|
|
209
|
+
unique: boolean;
|
|
210
|
+
}[];
|
|
211
|
+
tables: {
|
|
212
|
+
replicaIdentityColumns: string[];
|
|
213
|
+
primaryKey?: string[] | undefined;
|
|
214
|
+
schemaOID?: number | undefined;
|
|
215
|
+
replicaIdentity?: "n" | "d" | "f" | "i" | undefined;
|
|
216
|
+
name: string;
|
|
217
|
+
schema: string;
|
|
218
|
+
oid: number;
|
|
219
|
+
columns: Record<string, {
|
|
220
|
+
pgTypeClass?: "e" | "d" | "b" | "c" | "p" | "r" | "m" | undefined;
|
|
221
|
+
elemPgTypeClass?: "e" | "d" | "b" | "c" | "p" | "r" | "m" | null | undefined;
|
|
222
|
+
characterMaximumLength?: number | null | undefined;
|
|
223
|
+
notNull?: boolean | null | undefined;
|
|
224
|
+
dflt?: string | null | undefined;
|
|
225
|
+
pos: number;
|
|
226
|
+
dataType: string;
|
|
227
|
+
typeOID: number;
|
|
228
|
+
}>;
|
|
229
|
+
publications: Record<string, {
|
|
230
|
+
rowFilter: string | null;
|
|
231
|
+
}>;
|
|
232
|
+
}[];
|
|
233
|
+
}>;
|
|
155
234
|
}, undefined>;
|
|
156
235
|
export type DdlUpdateEvent = v.Infer<typeof ddlUpdateEventSchema>;
|
|
157
236
|
/**
|
|
158
237
|
* The `schemaSnapshot` message is a snapshot of a schema taken in response to
|
|
159
238
|
* a `COMMENT ON PUBLICATION` command, which is a hook recognized by zero
|
|
160
|
-
* to manually emit schema snapshots
|
|
161
|
-
*
|
|
162
|
-
*
|
|
239
|
+
* to manually emit `previousSchema` and `schema` snapshots when a difference
|
|
240
|
+
* is detected. This is a workaround provided to support detection of schema
|
|
241
|
+
* changes from `ALTER PUBLICATION` commands on supabase, which does not fire
|
|
242
|
+
* event triggers for them (https://github.com/supabase/supautils/issues/123).
|
|
163
243
|
*
|
|
164
|
-
* The hook is exercised by
|
|
165
|
-
* `COMMENT ON PUBLICATION`
|
|
244
|
+
* The hook is exercised by trailing the publication change with a
|
|
245
|
+
* `COMMENT ON PUBLICATION` statement, e.g.
|
|
166
246
|
*
|
|
167
247
|
* ```sql
|
|
168
248
|
* BEGIN;
|
|
169
|
-
* COMMENT ON PUBLICATION my_publication IS 'whatever';
|
|
170
249
|
* ALTER PUBLICATION my_publication ...;
|
|
171
250
|
* COMMENT ON PUBLICATION my_publication IS 'whatever';
|
|
172
251
|
* COMMIT;
|
|
173
252
|
* ```
|
|
174
253
|
*
|
|
175
|
-
*
|
|
176
|
-
*
|
|
177
|
-
*
|
|
178
|
-
*
|
|
179
|
-
* In the case where event trigger support is missing, this results in
|
|
180
|
-
* diffing the `schemaSnapshot`s before and after the `ALTER PUBLICATION`
|
|
181
|
-
* statement, thus effecting the same logic that would have been exercised
|
|
182
|
-
* between the `ddlStart` and `ddlEvent` events fired by a database with
|
|
183
|
-
* fully functional event triggers.
|
|
184
|
-
*
|
|
185
|
-
* Note that if the same transaction is run on a database that *does*
|
|
186
|
-
* support event triggers on `ALTER PUBLICATION` statements, the sequence
|
|
187
|
-
* of emitted messages will be:
|
|
188
|
-
*
|
|
189
|
-
* * `schemaSnapshot`
|
|
190
|
-
* * `ddlStart`
|
|
191
|
-
* * `ddlUpdate`
|
|
192
|
-
* * `schemaSnapshot`
|
|
193
|
-
*
|
|
194
|
-
* Since `schemaSnapshot` messages are diffed with the preceding
|
|
195
|
-
* `schemaSnapshot` or `ddlUpdate` event (if any), there will be no schema
|
|
196
|
-
* difference between the `ddlUpdate` and the second `schemaSnapshot`, and
|
|
197
|
-
* thus the extra `COMMENT` statements will effectively be no-ops.
|
|
254
|
+
* Note that it is fine to invoke `COMMENT ON PUBLICATION` statements
|
|
255
|
+
* on a database that *does* support event triggers on
|
|
256
|
+
* `ALTER PUBLICATION` statements, as it will simply be a no-op.
|
|
198
257
|
*/
|
|
199
258
|
export declare const schemaSnapshotEventSchema: v.ObjectType<Omit<Omit<{
|
|
200
259
|
context: v.ObjectType<{
|
|
@@ -239,8 +298,42 @@ export declare const schemaSnapshotEventSchema: v.ObjectType<Omit<Omit<{
|
|
|
239
298
|
event: v.ObjectType<{
|
|
240
299
|
tag: v.Type<string>;
|
|
241
300
|
}, undefined>;
|
|
242
|
-
}, "type"> & {
|
|
301
|
+
}, "type" | "previousSchema"> & {
|
|
243
302
|
type: v.Type<"schemaSnapshot">;
|
|
303
|
+
previousSchema: v.Optional<{
|
|
304
|
+
indexes: {
|
|
305
|
+
isReplicaIdentity?: boolean | undefined;
|
|
306
|
+
isPrimaryKey?: boolean | undefined;
|
|
307
|
+
isImmediate?: boolean | undefined;
|
|
308
|
+
name: string;
|
|
309
|
+
columns: Record<string, "ASC" | "DESC">;
|
|
310
|
+
schema: string;
|
|
311
|
+
tableName: string;
|
|
312
|
+
unique: boolean;
|
|
313
|
+
}[];
|
|
314
|
+
tables: {
|
|
315
|
+
replicaIdentityColumns: string[];
|
|
316
|
+
primaryKey?: string[] | undefined;
|
|
317
|
+
schemaOID?: number | undefined;
|
|
318
|
+
replicaIdentity?: "n" | "d" | "f" | "i" | undefined;
|
|
319
|
+
name: string;
|
|
320
|
+
schema: string;
|
|
321
|
+
oid: number;
|
|
322
|
+
columns: Record<string, {
|
|
323
|
+
pgTypeClass?: "e" | "d" | "b" | "c" | "p" | "r" | "m" | undefined;
|
|
324
|
+
elemPgTypeClass?: "e" | "d" | "b" | "c" | "p" | "r" | "m" | null | undefined;
|
|
325
|
+
characterMaximumLength?: number | null | undefined;
|
|
326
|
+
notNull?: boolean | null | undefined;
|
|
327
|
+
dflt?: string | null | undefined;
|
|
328
|
+
pos: number;
|
|
329
|
+
dataType: string;
|
|
330
|
+
typeOID: number;
|
|
331
|
+
}>;
|
|
332
|
+
publications: Record<string, {
|
|
333
|
+
rowFilter: string | null;
|
|
334
|
+
}>;
|
|
335
|
+
}[];
|
|
336
|
+
}>;
|
|
244
337
|
}, undefined>;
|
|
245
338
|
export type SchemaSnapshotEvent = v.Infer<typeof schemaSnapshotEventSchema>;
|
|
246
339
|
export declare const replicationEventSchema: v.UnionType<[v.ObjectType<Omit<Omit<{
|
|
@@ -286,8 +379,42 @@ export declare const replicationEventSchema: v.UnionType<[v.ObjectType<Omit<Omit
|
|
|
286
379
|
event: v.ObjectType<{
|
|
287
380
|
tag: v.Type<string>;
|
|
288
381
|
}, undefined>;
|
|
289
|
-
}, "type" | "event"> & {
|
|
382
|
+
}, "type" | "event" | "previousSchema"> & {
|
|
290
383
|
type: v.Type<"ddlStart">;
|
|
384
|
+
previousSchema: v.Optional<{
|
|
385
|
+
indexes: {
|
|
386
|
+
isReplicaIdentity?: boolean | undefined;
|
|
387
|
+
isPrimaryKey?: boolean | undefined;
|
|
388
|
+
isImmediate?: boolean | undefined;
|
|
389
|
+
name: string;
|
|
390
|
+
columns: Record<string, "ASC" | "DESC">;
|
|
391
|
+
schema: string;
|
|
392
|
+
tableName: string;
|
|
393
|
+
unique: boolean;
|
|
394
|
+
}[];
|
|
395
|
+
tables: {
|
|
396
|
+
replicaIdentityColumns: string[];
|
|
397
|
+
primaryKey?: string[] | undefined;
|
|
398
|
+
schemaOID?: number | undefined;
|
|
399
|
+
replicaIdentity?: "n" | "d" | "f" | "i" | undefined;
|
|
400
|
+
name: string;
|
|
401
|
+
schema: string;
|
|
402
|
+
oid: number;
|
|
403
|
+
columns: Record<string, {
|
|
404
|
+
pgTypeClass?: "e" | "d" | "b" | "c" | "p" | "r" | "m" | undefined;
|
|
405
|
+
elemPgTypeClass?: "e" | "d" | "b" | "c" | "p" | "r" | "m" | null | undefined;
|
|
406
|
+
characterMaximumLength?: number | null | undefined;
|
|
407
|
+
notNull?: boolean | null | undefined;
|
|
408
|
+
dflt?: string | null | undefined;
|
|
409
|
+
pos: number;
|
|
410
|
+
dataType: string;
|
|
411
|
+
typeOID: number;
|
|
412
|
+
}>;
|
|
413
|
+
publications: Record<string, {
|
|
414
|
+
rowFilter: string | null;
|
|
415
|
+
}>;
|
|
416
|
+
}[];
|
|
417
|
+
} | null>;
|
|
291
418
|
event: v.Type<{
|
|
292
419
|
tag: string;
|
|
293
420
|
}>;
|
|
@@ -334,8 +461,42 @@ export declare const replicationEventSchema: v.UnionType<[v.ObjectType<Omit<Omit
|
|
|
334
461
|
event: v.ObjectType<{
|
|
335
462
|
tag: v.Type<string>;
|
|
336
463
|
}, undefined>;
|
|
337
|
-
}, "type"> & {
|
|
464
|
+
}, "type" | "previousSchema"> & {
|
|
338
465
|
type: v.Type<"ddlUpdate">;
|
|
466
|
+
previousSchema: v.Optional<{
|
|
467
|
+
indexes: {
|
|
468
|
+
isReplicaIdentity?: boolean | undefined;
|
|
469
|
+
isPrimaryKey?: boolean | undefined;
|
|
470
|
+
isImmediate?: boolean | undefined;
|
|
471
|
+
name: string;
|
|
472
|
+
columns: Record<string, "ASC" | "DESC">;
|
|
473
|
+
schema: string;
|
|
474
|
+
tableName: string;
|
|
475
|
+
unique: boolean;
|
|
476
|
+
}[];
|
|
477
|
+
tables: {
|
|
478
|
+
replicaIdentityColumns: string[];
|
|
479
|
+
primaryKey?: string[] | undefined;
|
|
480
|
+
schemaOID?: number | undefined;
|
|
481
|
+
replicaIdentity?: "n" | "d" | "f" | "i" | undefined;
|
|
482
|
+
name: string;
|
|
483
|
+
schema: string;
|
|
484
|
+
oid: number;
|
|
485
|
+
columns: Record<string, {
|
|
486
|
+
pgTypeClass?: "e" | "d" | "b" | "c" | "p" | "r" | "m" | undefined;
|
|
487
|
+
elemPgTypeClass?: "e" | "d" | "b" | "c" | "p" | "r" | "m" | null | undefined;
|
|
488
|
+
characterMaximumLength?: number | null | undefined;
|
|
489
|
+
notNull?: boolean | null | undefined;
|
|
490
|
+
dflt?: string | null | undefined;
|
|
491
|
+
pos: number;
|
|
492
|
+
dataType: string;
|
|
493
|
+
typeOID: number;
|
|
494
|
+
}>;
|
|
495
|
+
publications: Record<string, {
|
|
496
|
+
rowFilter: string | null;
|
|
497
|
+
}>;
|
|
498
|
+
}[];
|
|
499
|
+
}>;
|
|
339
500
|
}, undefined>, v.ObjectType<Omit<Omit<{
|
|
340
501
|
context: v.ObjectType<{
|
|
341
502
|
query: v.Type<string>;
|
|
@@ -379,10 +540,62 @@ export declare const replicationEventSchema: v.UnionType<[v.ObjectType<Omit<Omit
|
|
|
379
540
|
event: v.ObjectType<{
|
|
380
541
|
tag: v.Type<string>;
|
|
381
542
|
}, undefined>;
|
|
382
|
-
}, "type"> & {
|
|
543
|
+
}, "type" | "previousSchema"> & {
|
|
383
544
|
type: v.Type<"schemaSnapshot">;
|
|
545
|
+
previousSchema: v.Optional<{
|
|
546
|
+
indexes: {
|
|
547
|
+
isReplicaIdentity?: boolean | undefined;
|
|
548
|
+
isPrimaryKey?: boolean | undefined;
|
|
549
|
+
isImmediate?: boolean | undefined;
|
|
550
|
+
name: string;
|
|
551
|
+
columns: Record<string, "ASC" | "DESC">;
|
|
552
|
+
schema: string;
|
|
553
|
+
tableName: string;
|
|
554
|
+
unique: boolean;
|
|
555
|
+
}[];
|
|
556
|
+
tables: {
|
|
557
|
+
replicaIdentityColumns: string[];
|
|
558
|
+
primaryKey?: string[] | undefined;
|
|
559
|
+
schemaOID?: number | undefined;
|
|
560
|
+
replicaIdentity?: "n" | "d" | "f" | "i" | undefined;
|
|
561
|
+
name: string;
|
|
562
|
+
schema: string;
|
|
563
|
+
oid: number;
|
|
564
|
+
columns: Record<string, {
|
|
565
|
+
pgTypeClass?: "e" | "d" | "b" | "c" | "p" | "r" | "m" | undefined;
|
|
566
|
+
elemPgTypeClass?: "e" | "d" | "b" | "c" | "p" | "r" | "m" | null | undefined;
|
|
567
|
+
characterMaximumLength?: number | null | undefined;
|
|
568
|
+
notNull?: boolean | null | undefined;
|
|
569
|
+
dflt?: string | null | undefined;
|
|
570
|
+
pos: number;
|
|
571
|
+
dataType: string;
|
|
572
|
+
typeOID: number;
|
|
573
|
+
}>;
|
|
574
|
+
publications: Record<string, {
|
|
575
|
+
rowFilter: string | null;
|
|
576
|
+
}>;
|
|
577
|
+
}[];
|
|
578
|
+
}>;
|
|
384
579
|
}, undefined>]>;
|
|
385
580
|
export type ReplicationEvent = v.Infer<typeof replicationEventSchema>;
|
|
581
|
+
/**
|
|
582
|
+
* Event trigger functions contain the core logic that are invoked by triggers.
|
|
583
|
+
*
|
|
584
|
+
* Note that although many of these functions can theoretically be parameterized and
|
|
585
|
+
* shared across shards, it is advantageous to keep the functions in each shard
|
|
586
|
+
* isolated from each other in order to avoid the complexity of shared-function
|
|
587
|
+
* versioning.
|
|
588
|
+
*
|
|
589
|
+
* In a sense, shards (and their triggers and functions) should be thought of as
|
|
590
|
+
* execution environments that can be updated at different schedules. If per-shard
|
|
591
|
+
* triggers called into shared functions, we would have to consider versioning the
|
|
592
|
+
* functions when changing their behavior, backwards compatibility, removal of
|
|
593
|
+
* unused versions, etc. (not unlike versioning of npm packages).
|
|
594
|
+
*
|
|
595
|
+
* Instead, we opt for the simplicity and isolation of having each shard
|
|
596
|
+
* completely own (and maintain) the entirety of its trigger/function stack.
|
|
597
|
+
*/
|
|
598
|
+
export declare function createEventFunctionStatements(shard: ShardConfig): string;
|
|
386
599
|
export declare const TAGS: readonly ["CREATE TABLE", "ALTER TABLE", "CREATE INDEX", "DROP TABLE", "DROP INDEX", "ALTER PUBLICATION", "ALTER SCHEMA"];
|
|
387
600
|
export declare function createEventTriggerStatements(shard: ShardConfig): string;
|
|
388
601
|
export declare function dropEventTriggerStatements(appID: string, shardID: string | number): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ddl.d.ts","sourceRoot":"","sources":["../../../../../../../../zero-cache/src/services/change-source/pg/schema/ddl.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,CAAC,MAAM,wCAAwC,CAAC;AAC5D,OAAO,EAAiB,KAAK,WAAW,EAAC,MAAM,6BAA6B,CAAC;AAU7E,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAQlC,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAIzB,CAAC;
|
|
1
|
+
{"version":3,"file":"ddl.d.ts","sourceRoot":"","sources":["../../../../../../../../zero-cache/src/services/change-source/pg/schema/ddl.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,CAAC,MAAM,wCAAwC,CAAC;AAC5D,OAAO,EAAiB,KAAK,WAAW,EAAC,MAAM,6BAA6B,CAAC;AAU7E,eAAO,MAAM,gBAAgB,IAAI,CAAC;AAQlC,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAIzB,CAAC;AAEH;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAc9B,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE;;;;GAIG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAQ/B,CAAC;AAEH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC;AAElE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;aAGpC,CAAC;AAEH,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAE5E,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAIlC,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,sBAAsB,CAAC,CAAC;AAYtE;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,6BAA6B,CAAC,KAAK,EAAE,WAAW,UAwM/D;AAGD,eAAO,MAAM,IAAI,2HAQP,CAAC;AAEX,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,WAAW,UAoC9D;AAGD,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,GAAG,MAAM,UAMzB"}
|