@rocicorp/zero 0.7.2024120200 → 0.7.2024120700
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/advanced.js +1 -1
- package/out/{chunk-C7M3BJ3Z.js → chunk-6HXO6VMP.js} +13 -12
- package/out/chunk-6HXO6VMP.js.map +7 -0
- package/out/{chunk-KL66XOAW.js → chunk-PFF4AHTF.js} +331 -241
- package/out/{chunk-KL66XOAW.js.map → chunk-PFF4AHTF.js.map} +4 -4
- package/out/otel/src/noop-span-exporter.d.ts +8 -0
- package/out/otel/src/noop-span-exporter.d.ts.map +1 -0
- package/out/otel/src/noop-span-exporter.js +14 -0
- package/out/otel/src/noop-span-exporter.js.map +1 -0
- package/out/otel/src/span.d.ts +5 -0
- package/out/otel/src/span.d.ts.map +1 -0
- package/out/otel/src/span.js +30 -0
- package/out/otel/src/span.js.map +1 -0
- package/out/otel/src/version.d.ts +2 -0
- package/out/otel/src/version.d.ts.map +1 -0
- package/out/otel/src/version.js +2 -0
- package/out/otel/src/version.js.map +1 -0
- package/out/react.js +12 -6
- package/out/react.js.map +2 -2
- package/out/shared/src/asserts.d.ts +1 -1
- package/out/shared/src/asserts.d.ts.map +1 -1
- package/out/shared/src/asserts.js +2 -1
- package/out/shared/src/asserts.js.map +1 -1
- package/out/solid.js +2 -2
- package/out/zero-cache/src/auth/load-schema.d.ts.map +1 -1
- package/out/zero-cache/src/auth/load-schema.js +4 -20
- package/out/zero-cache/src/auth/load-schema.js.map +1 -1
- package/out/zero-cache/src/auth/write-authorizer.js +10 -6
- package/out/zero-cache/src/auth/write-authorizer.js.map +1 -1
- package/out/zero-cache/src/config/zero-config.d.ts +11 -7
- package/out/zero-cache/src/config/zero-config.d.ts.map +1 -1
- package/out/zero-cache/src/config/zero-config.js +11 -7
- package/out/zero-cache/src/config/zero-config.js.map +1 -1
- package/out/zero-cache/src/server/change-streamer.d.ts +1 -1
- package/out/zero-cache/src/server/change-streamer.d.ts.map +1 -1
- package/out/zero-cache/src/server/change-streamer.js +3 -3
- package/out/zero-cache/src/server/change-streamer.js.map +1 -1
- package/out/zero-cache/src/server/main.js +6 -11
- package/out/zero-cache/src/server/main.js.map +1 -1
- package/out/zero-cache/src/server/replicator.d.ts +1 -1
- package/out/zero-cache/src/server/replicator.d.ts.map +1 -1
- package/out/zero-cache/src/server/replicator.js +3 -3
- package/out/zero-cache/src/server/replicator.js.map +1 -1
- package/out/zero-cache/src/server/syncer.d.ts +1 -1
- package/out/zero-cache/src/server/syncer.d.ts.map +1 -1
- package/out/zero-cache/src/server/syncer.js +34 -5
- package/out/zero-cache/src/server/syncer.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/pg/change-source.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-streamer/pg/change-source.js +31 -21
- package/out/zero-cache/src/services/change-streamer/pg/change-source.js.map +1 -1
- package/out/zero-cache/src/services/change-streamer/storer.d.ts.map +1 -1
- package/out/zero-cache/src/services/change-streamer/storer.js +11 -6
- package/out/zero-cache/src/services/change-streamer/storer.js.map +1 -1
- package/out/zero-cache/src/services/dispatcher/connect-params.d.ts +2 -1
- package/out/zero-cache/src/services/dispatcher/connect-params.d.ts.map +1 -1
- package/out/zero-cache/src/services/dispatcher/connect-params.js +3 -2
- package/out/zero-cache/src/services/dispatcher/connect-params.js.map +1 -1
- package/out/zero-cache/src/services/dispatcher/dispatcher.d.ts.map +1 -1
- package/out/zero-cache/src/services/dispatcher/dispatcher.js +5 -5
- package/out/zero-cache/src/services/dispatcher/dispatcher.js.map +1 -1
- package/out/zero-cache/src/services/mutagen/mutagen.d.ts +3 -3
- package/out/zero-cache/src/services/mutagen/mutagen.d.ts.map +1 -1
- package/out/zero-cache/src/services/mutagen/mutagen.js +31 -22
- package/out/zero-cache/src/services/mutagen/mutagen.js.map +1 -1
- package/out/zero-cache/src/services/runner.js +1 -4
- package/out/zero-cache/src/services/runner.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/client-handler.d.ts +1 -1
- package/out/zero-cache/src/services/view-syncer/client-handler.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/client-handler.js +3 -2
- package/out/zero-cache/src/services/view-syncer/client-handler.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/cvr-store.d.ts +2 -2
- package/out/zero-cache/src/services/view-syncer/cvr-store.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/cvr-store.js +45 -34
- package/out/zero-cache/src/services/view-syncer/cvr-store.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/cvr.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/cvr.js +2 -2
- package/out/zero-cache/src/services/view-syncer/cvr.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/pipeline-driver.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/pipeline-driver.js +16 -3
- package/out/zero-cache/src/services/view-syncer/pipeline-driver.js.map +1 -1
- package/out/zero-cache/src/services/view-syncer/schema/types.d.ts +5 -195
- package/out/zero-cache/src/services/view-syncer/schema/types.d.ts.map +1 -1
- package/out/zero-cache/src/services/view-syncer/view-syncer.d.ts +5 -5
- 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 +384 -357
- package/out/zero-cache/src/services/view-syncer/view-syncer.js.map +1 -1
- package/out/zero-cache/src/types/error-for-client.d.ts +10 -3
- package/out/zero-cache/src/types/error-for-client.d.ts.map +1 -1
- package/out/zero-cache/src/types/error-for-client.js +4 -4
- package/out/zero-cache/src/types/error-for-client.js.map +1 -1
- package/out/zero-cache/src/types/lite.d.ts.map +1 -1
- package/out/zero-cache/src/types/lite.js +1 -0
- package/out/zero-cache/src/types/lite.js.map +1 -1
- package/out/zero-cache/src/types/pg.d.ts +1 -1
- package/out/zero-cache/src/types/pg.d.ts.map +1 -1
- package/out/zero-cache/src/types/pg.js +33 -7
- package/out/zero-cache/src/types/pg.js.map +1 -1
- package/out/zero-cache/src/types/processes.d.ts +5 -1
- package/out/zero-cache/src/types/processes.d.ts.map +1 -1
- package/out/zero-cache/src/types/processes.js +12 -2
- package/out/zero-cache/src/types/processes.js.map +1 -1
- package/out/zero-cache/src/types/schema-versions.d.ts.map +1 -1
- package/out/zero-cache/src/types/schema-versions.js +4 -5
- package/out/zero-cache/src/types/schema-versions.js.map +1 -1
- package/out/zero-cache/src/workers/connection.d.ts +14 -6
- package/out/zero-cache/src/workers/connection.d.ts.map +1 -1
- package/out/zero-cache/src/workers/connection.js +78 -70
- package/out/zero-cache/src/workers/connection.js.map +1 -1
- package/out/zero-cache/src/workers/syncer.d.ts.map +1 -1
- package/out/zero-cache/src/workers/syncer.js +8 -10
- package/out/zero-cache/src/workers/syncer.js.map +1 -1
- package/out/zero-client/src/client/context.d.ts +1 -1
- package/out/zero-client/src/client/context.d.ts.map +1 -1
- package/out/zero-client/src/client/options.d.ts +13 -14
- package/out/zero-client/src/client/options.d.ts.map +1 -1
- package/out/zero-client/src/client/query-manager.d.ts.map +1 -1
- package/out/zero-client/src/client/server-error.d.ts +5 -3
- package/out/zero-client/src/client/server-error.d.ts.map +1 -1
- package/out/zero-client/src/client/zero.d.ts.map +1 -1
- package/out/zero-client/src/mod.d.ts +2 -2
- package/out/zero-client/src/mod.d.ts.map +1 -1
- package/out/zero-protocol/src/ast.d.ts +8 -95
- package/out/zero-protocol/src/ast.d.ts.map +1 -1
- package/out/zero-protocol/src/ast.js +9 -9
- package/out/zero-protocol/src/ast.js.map +1 -1
- package/out/zero-protocol/src/change-desired-queries.d.ts +2 -78
- package/out/zero-protocol/src/change-desired-queries.d.ts.map +1 -1
- package/out/zero-protocol/src/connect.d.ts +2 -78
- package/out/zero-protocol/src/connect.d.ts.map +1 -1
- package/out/zero-protocol/src/down.d.ts +2 -78
- package/out/zero-protocol/src/down.d.ts.map +1 -1
- package/out/zero-protocol/src/error.d.ts +18 -1
- package/out/zero-protocol/src/error.d.ts.map +1 -1
- package/out/zero-protocol/src/error.js +12 -2
- package/out/zero-protocol/src/error.js.map +1 -1
- package/out/zero-protocol/src/poke.d.ts +4 -156
- package/out/zero-protocol/src/poke.d.ts.map +1 -1
- package/out/zero-protocol/src/protocol-version.d.ts +20 -0
- package/out/zero-protocol/src/protocol-version.d.ts.map +1 -0
- package/out/zero-protocol/src/protocol-version.js +20 -0
- package/out/zero-protocol/src/protocol-version.js.map +1 -0
- package/out/zero-protocol/src/queries-patch.d.ts +3 -117
- package/out/zero-protocol/src/queries-patch.d.ts.map +1 -1
- package/out/zero-protocol/src/up.d.ts +2 -78
- package/out/zero-protocol/src/up.d.ts.map +1 -1
- package/out/zero-react/src/use-query.d.ts +9 -1
- package/out/zero-react/src/use-query.d.ts.map +1 -1
- package/out/zero-schema/src/build-schema.d.ts.map +1 -1
- package/out/zero-schema/src/build-schema.js +2 -14
- package/out/zero-schema/src/build-schema.js.map +1 -1
- package/out/zero-schema/src/compiled-permissions.d.ts +17 -459
- package/out/zero-schema/src/compiled-permissions.d.ts.map +1 -1
- package/out/zero-schema/src/compiled-permissions.js +1 -1
- package/out/zero-schema/src/compiled-permissions.js.map +1 -1
- package/out/zero-schema/src/mod.d.ts +1 -1
- package/out/zero-schema/src/mod.d.ts.map +1 -1
- package/out/zero-schema/src/normalize-table-schema.d.ts +3 -2
- package/out/zero-schema/src/normalize-table-schema.d.ts.map +1 -1
- package/out/zero-schema/src/normalize-table-schema.js +39 -13
- package/out/zero-schema/src/normalize-table-schema.js.map +1 -1
- package/out/zero-schema/src/permissions.d.ts +2 -2
- package/out/zero-schema/src/permissions.d.ts.map +1 -1
- package/out/zero-schema/src/schema-config.d.ts +15 -29
- package/out/zero-schema/src/schema-config.d.ts.map +1 -1
- package/out/zero-schema/src/schema-config.js +39 -13
- package/out/zero-schema/src/schema-config.js.map +1 -1
- package/out/zero-schema/src/table-schema.d.ts +24 -38
- package/out/zero-schema/src/table-schema.d.ts.map +1 -1
- package/out/zero-schema/src/table-schema.js.map +1 -1
- package/out/zero.js +2 -2
- package/out/zql/src/builder/builder.d.ts.map +1 -1
- package/out/zql/src/builder/builder.js +9 -11
- package/out/zql/src/builder/builder.js.map +1 -1
- package/out/zql/src/ivm/array-view.d.ts +1 -1
- package/out/zql/src/ivm/array-view.d.ts.map +1 -1
- package/out/zql/src/ivm/array-view.js +16 -3
- package/out/zql/src/ivm/array-view.js.map +1 -1
- package/out/zql/src/ivm/data.d.ts +1 -1
- package/out/zql/src/ivm/data.d.ts.map +1 -1
- package/out/zql/src/ivm/data.js +3 -2
- package/out/zql/src/ivm/data.js.map +1 -1
- package/out/zql/src/ivm/exists.d.ts.map +1 -1
- package/out/zql/src/ivm/exists.js +13 -2
- package/out/zql/src/ivm/exists.js.map +1 -1
- package/out/zql/src/ivm/join.d.ts +3 -2
- package/out/zql/src/ivm/join.d.ts.map +1 -1
- package/out/zql/src/ivm/join.js +5 -2
- package/out/zql/src/ivm/join.js.map +1 -1
- package/out/zql/src/ivm/memory-source.d.ts +3 -12
- package/out/zql/src/ivm/memory-source.d.ts.map +1 -1
- package/out/zql/src/ivm/memory-source.js +38 -72
- package/out/zql/src/ivm/memory-source.js.map +1 -1
- package/out/zql/src/ivm/operator.d.ts +3 -1
- package/out/zql/src/ivm/operator.d.ts.map +1 -1
- package/out/zql/src/ivm/schema.d.ts +8 -3
- package/out/zql/src/ivm/schema.d.ts.map +1 -1
- package/out/zql/src/ivm/skip.d.ts.map +1 -1
- package/out/zql/src/ivm/skip.js +60 -54
- package/out/zql/src/ivm/skip.js.map +1 -1
- package/out/zql/src/ivm/source.d.ts +10 -0
- package/out/zql/src/ivm/source.d.ts.map +1 -1
- package/out/zql/src/ivm/take.d.ts.map +1 -1
- package/out/zql/src/ivm/take.js +47 -35
- package/out/zql/src/ivm/take.js.map +1 -1
- package/out/zql/src/ivm/view-apply-change.js +4 -2
- package/out/zql/src/ivm/view-apply-change.js.map +1 -1
- package/out/zql/src/ivm/view.d.ts +1 -1
- package/out/zql/src/ivm/view.d.ts.map +1 -1
- package/out/zql/src/query/auth-query.d.ts +1 -0
- package/out/zql/src/query/auth-query.d.ts.map +1 -1
- package/out/zql/src/query/auth-query.js +1 -0
- package/out/zql/src/query/auth-query.js.map +1 -1
- package/out/zql/src/query/expression.d.ts +3 -2
- package/out/zql/src/query/expression.d.ts.map +1 -1
- package/out/zql/src/query/expression.js.map +1 -1
- package/out/zql/src/query/query-impl.d.ts +8 -6
- package/out/zql/src/query/query-impl.d.ts.map +1 -1
- package/out/zql/src/query/query-impl.js +18 -4
- package/out/zql/src/query/query-impl.js.map +1 -1
- package/out/zql/src/query/query.d.ts +9 -5
- package/out/zql/src/query/query.d.ts.map +1 -1
- package/out/zql/src/query/typed-view.d.ts +2 -1
- package/out/zql/src/query/typed-view.d.ts.map +1 -1
- package/out/zqlite/src/db.js +1 -1
- package/out/zqlite/src/table-source.d.ts +1 -0
- package/out/zqlite/src/table-source.d.ts.map +1 -1
- package/out/zqlite/src/table-source.js +40 -70
- package/out/zqlite/src/table-source.js.map +1 -1
- package/package.json +5 -1
- package/out/chunk-C7M3BJ3Z.js.map +0 -7
- package/out/shared/src/random-values.js +0 -22
- package/out/shared/src/random-values.js.map +0 -1
- package/out/zero-client/src/client/protocol-version.d.ts +0 -2
- package/out/zero-client/src/client/protocol-version.d.ts.map +0 -1
- package/out/zql/src/ivm/lookahead-iterator.d.ts +0 -13
- package/out/zql/src/ivm/lookahead-iterator.d.ts.map +0 -1
- package/out/zql/src/ivm/lookahead-iterator.js +0 -45
- package/out/zql/src/ivm/lookahead-iterator.js.map +0 -1
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
must,
|
|
15
15
|
throwInvalidType,
|
|
16
16
|
unreachable
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-6HXO6VMP.js";
|
|
18
18
|
import {
|
|
19
19
|
__export,
|
|
20
20
|
__reExport
|
|
@@ -9291,8 +9291,8 @@ function isJunctionRelationship(relationship) {
|
|
|
9291
9291
|
}
|
|
9292
9292
|
|
|
9293
9293
|
// ../shared/src/sorted-entries.ts
|
|
9294
|
-
function sortedEntries(
|
|
9295
|
-
return Object.entries(
|
|
9294
|
+
function sortedEntries(object18) {
|
|
9295
|
+
return Object.entries(object18).sort((a, b) => stringCompare(a[0], b[0]));
|
|
9296
9296
|
}
|
|
9297
9297
|
|
|
9298
9298
|
// ../zero-schema/src/normalize-table-schema.ts
|
|
@@ -9344,28 +9344,36 @@ function assertNoDuplicates(arr) {
|
|
|
9344
9344
|
"Primary key must not contain duplicates"
|
|
9345
9345
|
);
|
|
9346
9346
|
}
|
|
9347
|
-
function normalizePrimaryKey(
|
|
9348
|
-
|
|
9349
|
-
|
|
9347
|
+
function normalizePrimaryKey(primaryKey) {
|
|
9348
|
+
if (typeof primaryKey === "string") {
|
|
9349
|
+
return [primaryKey];
|
|
9350
|
+
}
|
|
9351
|
+
assertNoDuplicates(primaryKey);
|
|
9352
|
+
return primaryKey;
|
|
9350
9353
|
}
|
|
9351
9354
|
function normalizeColumns(columns, primaryKey) {
|
|
9352
9355
|
const rv = {};
|
|
9353
9356
|
for (const pk of primaryKey) {
|
|
9354
9357
|
const schemaValue = columns[pk];
|
|
9355
9358
|
assert(schemaValue, `Primary key column "${pk}" not found`);
|
|
9356
|
-
|
|
9357
|
-
|
|
9358
|
-
|
|
9359
|
-
|
|
9360
|
-
|
|
9361
|
-
|
|
9359
|
+
if (typeof schemaValue !== "string") {
|
|
9360
|
+
const { type, optional } = schemaValue;
|
|
9361
|
+
assert(!optional, `Primary key column "${pk}" cannot be optional`);
|
|
9362
|
+
assert(
|
|
9363
|
+
type === "string" || type === "number" || type === "boolean",
|
|
9364
|
+
`Primary key column "${pk}" must be a string, number, or boolean. Got ${type}`
|
|
9365
|
+
);
|
|
9366
|
+
}
|
|
9362
9367
|
}
|
|
9363
9368
|
for (const [name, column] of sortedEntries(columns)) {
|
|
9364
|
-
rv[name] =
|
|
9369
|
+
rv[name] = normalizeColumn(column);
|
|
9365
9370
|
}
|
|
9366
9371
|
return rv;
|
|
9367
9372
|
}
|
|
9368
|
-
function
|
|
9373
|
+
function normalizeColumn(value) {
|
|
9374
|
+
if (typeof value === "string") {
|
|
9375
|
+
return { type: value, optional: false };
|
|
9376
|
+
}
|
|
9369
9377
|
return {
|
|
9370
9378
|
type: value.type,
|
|
9371
9379
|
optional: value.optional ?? false
|
|
@@ -9373,8 +9381,10 @@ function normalizeSchemaValue(value) {
|
|
|
9373
9381
|
}
|
|
9374
9382
|
function normalizeRelationships(relationships, tableSchemaCache) {
|
|
9375
9383
|
const rv = {};
|
|
9376
|
-
|
|
9377
|
-
|
|
9384
|
+
if (relationships) {
|
|
9385
|
+
for (const [name, relationship] of sortedEntries(relationships)) {
|
|
9386
|
+
rv[name] = normalizeRelationship(relationship, tableSchemaCache);
|
|
9387
|
+
}
|
|
9378
9388
|
}
|
|
9379
9389
|
return rv;
|
|
9380
9390
|
}
|
|
@@ -9385,13 +9395,15 @@ function normalizeRelationship(relationship, tableSchemaCache) {
|
|
|
9385
9395
|
return normalizeJunctionRelationship(relationship, tableSchemaCache);
|
|
9386
9396
|
}
|
|
9387
9397
|
function normalizeFieldRelationship(relationship, tableSchemaCache) {
|
|
9398
|
+
const sourceField = normalizeFieldName(relationship.sourceField);
|
|
9399
|
+
const destField = normalizeFieldName(relationship.destField);
|
|
9388
9400
|
assert(
|
|
9389
|
-
|
|
9401
|
+
sourceField.length === destField.length,
|
|
9390
9402
|
"Source and destination fields must have the same length"
|
|
9391
9403
|
);
|
|
9392
9404
|
return {
|
|
9393
|
-
sourceField
|
|
9394
|
-
destField
|
|
9405
|
+
sourceField,
|
|
9406
|
+
destField,
|
|
9395
9407
|
destSchema: normalizeLazyTableSchema(
|
|
9396
9408
|
relationship.destSchema,
|
|
9397
9409
|
tableSchemaCache
|
|
@@ -9413,6 +9425,20 @@ function normalizeLazyTableSchema(tableSchema, buildCache) {
|
|
|
9413
9425
|
buildCache
|
|
9414
9426
|
);
|
|
9415
9427
|
}
|
|
9428
|
+
function normalizeFieldName(sourceField) {
|
|
9429
|
+
if (typeof sourceField === "string") {
|
|
9430
|
+
return [sourceField];
|
|
9431
|
+
}
|
|
9432
|
+
assert(sourceField.length > 0, "Expected at least one field");
|
|
9433
|
+
return sourceField;
|
|
9434
|
+
}
|
|
9435
|
+
function normalizeTables(tables) {
|
|
9436
|
+
const result = {};
|
|
9437
|
+
for (const [name, table] of sortedEntries(tables)) {
|
|
9438
|
+
result[name] = normalizeTableSchemaWithCache(table, name, /* @__PURE__ */ new Map());
|
|
9439
|
+
}
|
|
9440
|
+
return result;
|
|
9441
|
+
}
|
|
9416
9442
|
|
|
9417
9443
|
// ../zero-schema/src/normalized-schema.ts
|
|
9418
9444
|
function normalizeSchema(schema) {
|
|
@@ -9426,10 +9452,10 @@ var NormalizedSchema = class {
|
|
|
9426
9452
|
tables;
|
|
9427
9453
|
constructor(schema) {
|
|
9428
9454
|
this.version = schema.version;
|
|
9429
|
-
this.tables =
|
|
9455
|
+
this.tables = normalizeTables2(schema.tables);
|
|
9430
9456
|
}
|
|
9431
9457
|
};
|
|
9432
|
-
function
|
|
9458
|
+
function normalizeTables2(tables) {
|
|
9433
9459
|
const rv = {};
|
|
9434
9460
|
const tableSchemaCache = /* @__PURE__ */ new Map();
|
|
9435
9461
|
for (const [name, table] of sortedEntries(tables)) {
|
|
@@ -9657,7 +9683,7 @@ var simpleOperatorSchema = valita_exports.union(
|
|
|
9657
9683
|
likeOpsSchema,
|
|
9658
9684
|
inOpsSchema
|
|
9659
9685
|
);
|
|
9660
|
-
var literalReferenceSchema =
|
|
9686
|
+
var literalReferenceSchema = readonlyObject({
|
|
9661
9687
|
type: valita_exports.literal("literal"),
|
|
9662
9688
|
value: valita_exports.union(
|
|
9663
9689
|
valita_exports.string(),
|
|
@@ -9667,11 +9693,11 @@ var literalReferenceSchema = valita_exports.object({
|
|
|
9667
9693
|
readonlyArray(valita_exports.union(valita_exports.string(), valita_exports.number(), valita_exports.boolean()))
|
|
9668
9694
|
)
|
|
9669
9695
|
});
|
|
9670
|
-
var columnReferenceSchema =
|
|
9696
|
+
var columnReferenceSchema = readonlyObject({
|
|
9671
9697
|
type: valita_exports.literal("column"),
|
|
9672
9698
|
name: valita_exports.string()
|
|
9673
9699
|
});
|
|
9674
|
-
var parameterReferenceSchema =
|
|
9700
|
+
var parameterReferenceSchema = readonlyObject({
|
|
9675
9701
|
type: valita_exports.literal("static"),
|
|
9676
9702
|
anchor: valita_exports.union(valita_exports.literal("authData"), valita_exports.literal("preMutationRow")),
|
|
9677
9703
|
field: valita_exports.string()
|
|
@@ -9681,16 +9707,13 @@ var conditionValueSchema = valita_exports.union(
|
|
|
9681
9707
|
columnReferenceSchema,
|
|
9682
9708
|
parameterReferenceSchema
|
|
9683
9709
|
);
|
|
9684
|
-
var simpleConditionSchema =
|
|
9710
|
+
var simpleConditionSchema = readonlyObject({
|
|
9685
9711
|
type: valita_exports.literal("simple"),
|
|
9686
9712
|
op: simpleOperatorSchema,
|
|
9687
9713
|
left: conditionValueSchema,
|
|
9688
9714
|
right: valita_exports.union(parameterReferenceSchema, literalReferenceSchema)
|
|
9689
9715
|
});
|
|
9690
|
-
var correlatedSubqueryConditionOperatorSchema = valita_exports.union(
|
|
9691
|
-
valita_exports.literal("EXISTS"),
|
|
9692
|
-
valita_exports.literal("NOT EXISTS")
|
|
9693
|
-
);
|
|
9716
|
+
var correlatedSubqueryConditionOperatorSchema = valita_exports.union(valita_exports.literal("EXISTS"), valita_exports.literal("NOT EXISTS"));
|
|
9694
9717
|
var correlatedSubqueryConditionSchema = readonlyObject({
|
|
9695
9718
|
type: valita_exports.literal("correlatedSubquery"),
|
|
9696
9719
|
related: valita_exports.lazy(() => correlatedSubquerySchema),
|
|
@@ -9710,19 +9733,22 @@ var disjunctionSchema = readonlyObject({
|
|
|
9710
9733
|
type: valita_exports.literal("or"),
|
|
9711
9734
|
conditions: readonlyArray(conditionSchema)
|
|
9712
9735
|
});
|
|
9713
|
-
var compoundKeySchema =
|
|
9736
|
+
var compoundKeySchema = readonly(
|
|
9737
|
+
valita_exports.tuple([valita_exports.string()]).concat(valita_exports.array(valita_exports.string()))
|
|
9738
|
+
);
|
|
9714
9739
|
var correlationSchema = readonlyObject({
|
|
9715
9740
|
parentField: compoundKeySchema,
|
|
9716
9741
|
childField: compoundKeySchema
|
|
9717
9742
|
});
|
|
9718
9743
|
var correlatedSubquerySchemaOmitSubquery = readonlyObject({
|
|
9719
9744
|
correlation: correlationSchema,
|
|
9720
|
-
hidden: valita_exports.boolean().optional()
|
|
9745
|
+
hidden: valita_exports.boolean().optional(),
|
|
9746
|
+
system: valita_exports.union(valita_exports.literal("permissions"), valita_exports.literal("client")).optional()
|
|
9721
9747
|
});
|
|
9722
9748
|
var correlatedSubquerySchema = correlatedSubquerySchemaOmitSubquery.extend({
|
|
9723
9749
|
subquery: valita_exports.lazy(() => astSchema)
|
|
9724
9750
|
});
|
|
9725
|
-
var astSchema =
|
|
9751
|
+
var astSchema = readonlyObject({
|
|
9726
9752
|
schema: valita_exports.string().optional(),
|
|
9727
9753
|
table: valita_exports.string(),
|
|
9728
9754
|
alias: valita_exports.string().optional(),
|
|
@@ -9752,7 +9778,8 @@ function normalizeAST(ast) {
|
|
|
9752
9778
|
(r) => ({
|
|
9753
9779
|
correlation: r.correlation,
|
|
9754
9780
|
hidden: r.hidden,
|
|
9755
|
-
subquery: normalizeAST(r.subquery)
|
|
9781
|
+
subquery: normalizeAST(r.subquery),
|
|
9782
|
+
system: r.system
|
|
9756
9783
|
})
|
|
9757
9784
|
)
|
|
9758
9785
|
) : void 0,
|
|
@@ -9813,7 +9840,7 @@ function compareValuePosition(a, b) {
|
|
|
9813
9840
|
switch (a.type) {
|
|
9814
9841
|
case "literal":
|
|
9815
9842
|
assert(b.type === "literal");
|
|
9816
|
-
return
|
|
9843
|
+
return compareUTF83(String(a.value), String(b.value));
|
|
9817
9844
|
case "column":
|
|
9818
9845
|
assert(b.type === "column");
|
|
9819
9846
|
return compareUTF83(a.name, b.name);
|
|
@@ -9913,13 +9940,14 @@ function compareValues(a, b) {
|
|
|
9913
9940
|
function normalizeUndefined(v2) {
|
|
9914
9941
|
return v2 ?? null;
|
|
9915
9942
|
}
|
|
9916
|
-
function makeComparator(order) {
|
|
9943
|
+
function makeComparator(order, reverse) {
|
|
9917
9944
|
return (a, b) => {
|
|
9918
9945
|
for (const ord of order) {
|
|
9919
9946
|
const field = ord[0];
|
|
9920
9947
|
const comp = compareValues(a[field], b[field]);
|
|
9921
9948
|
if (comp !== 0) {
|
|
9922
|
-
|
|
9949
|
+
const result = ord[1] === "asc" ? comp : -comp;
|
|
9950
|
+
return reverse ? -result : result;
|
|
9923
9951
|
}
|
|
9924
9952
|
}
|
|
9925
9953
|
return 0;
|
|
@@ -10002,7 +10030,11 @@ var Exists = class {
|
|
|
10002
10030
|
return;
|
|
10003
10031
|
}
|
|
10004
10032
|
case "remove": {
|
|
10005
|
-
this.#
|
|
10033
|
+
const size = this.#getSize(change.node.row);
|
|
10034
|
+
if (size === void 0) {
|
|
10035
|
+
return;
|
|
10036
|
+
}
|
|
10037
|
+
this.#pushWithFilter(change, size);
|
|
10006
10038
|
this.#delSize(change.node.row);
|
|
10007
10039
|
return;
|
|
10008
10040
|
}
|
|
@@ -10111,13 +10143,20 @@ var Exists = class {
|
|
|
10111
10143
|
return size;
|
|
10112
10144
|
}
|
|
10113
10145
|
#fetchNodeForRow(row) {
|
|
10114
|
-
|
|
10146
|
+
const fetched = must(
|
|
10115
10147
|
first(
|
|
10116
10148
|
this.#input.fetch({
|
|
10117
10149
|
start: { row, basis: "at" }
|
|
10118
10150
|
})
|
|
10119
10151
|
)
|
|
10120
10152
|
);
|
|
10153
|
+
assert(
|
|
10154
|
+
this.getSchema().compareRows(row, fetched.row) === 0,
|
|
10155
|
+
() => `fetchNodeForRow returned unexpected row, expected ${JSON.stringify(
|
|
10156
|
+
row
|
|
10157
|
+
)}, received ${JSON.stringify(fetched.row)}`
|
|
10158
|
+
);
|
|
10159
|
+
return fetched;
|
|
10121
10160
|
}
|
|
10122
10161
|
#makeSizeStorageKey(row) {
|
|
10123
10162
|
const primaryKey = [];
|
|
@@ -10317,7 +10356,8 @@ var Join = class {
|
|
|
10317
10356
|
parentKey,
|
|
10318
10357
|
childKey,
|
|
10319
10358
|
relationshipName,
|
|
10320
|
-
hidden
|
|
10359
|
+
hidden,
|
|
10360
|
+
system
|
|
10321
10361
|
}) {
|
|
10322
10362
|
assert(parent !== child, "Parent and child must be different operators");
|
|
10323
10363
|
assert(
|
|
@@ -10337,7 +10377,10 @@ var Join = class {
|
|
|
10337
10377
|
isHidden: hidden,
|
|
10338
10378
|
relationships: {
|
|
10339
10379
|
...parentSchema.relationships,
|
|
10340
|
-
[relationshipName]:
|
|
10380
|
+
[relationshipName]: {
|
|
10381
|
+
...childSchema,
|
|
10382
|
+
system
|
|
10383
|
+
}
|
|
10341
10384
|
}
|
|
10342
10385
|
};
|
|
10343
10386
|
parent.setOutput({
|
|
@@ -10563,10 +10606,27 @@ var Skip = class {
|
|
|
10563
10606
|
return this.#input.getSchema();
|
|
10564
10607
|
}
|
|
10565
10608
|
fetch(req) {
|
|
10566
|
-
return this.#
|
|
10609
|
+
return this.#fetchOrCleanup("fetch", req);
|
|
10567
10610
|
}
|
|
10568
10611
|
cleanup(req) {
|
|
10569
|
-
return this.#
|
|
10612
|
+
return this.#fetchOrCleanup("fetch", req);
|
|
10613
|
+
}
|
|
10614
|
+
*#fetchOrCleanup(method, req) {
|
|
10615
|
+
const start = this.#getStart(req);
|
|
10616
|
+
if (start === "empty") {
|
|
10617
|
+
return;
|
|
10618
|
+
}
|
|
10619
|
+
const nodes = this.#input[method]({ ...req, start });
|
|
10620
|
+
if (!req.reverse) {
|
|
10621
|
+
yield* nodes;
|
|
10622
|
+
return;
|
|
10623
|
+
}
|
|
10624
|
+
for (const node of nodes) {
|
|
10625
|
+
if (!this.#shouldBePresent(node.row)) {
|
|
10626
|
+
return;
|
|
10627
|
+
}
|
|
10628
|
+
yield node;
|
|
10629
|
+
}
|
|
10570
10630
|
}
|
|
10571
10631
|
setOutput(output) {
|
|
10572
10632
|
this.#output = output;
|
|
@@ -10574,12 +10634,13 @@ var Skip = class {
|
|
|
10574
10634
|
destroy() {
|
|
10575
10635
|
this.#input.destroy();
|
|
10576
10636
|
}
|
|
10637
|
+
#shouldBePresent(row) {
|
|
10638
|
+
const cmp2 = this.#comparator(this.#bound.row, row);
|
|
10639
|
+
return cmp2 < 0 || cmp2 === 0 && !this.#bound.exclusive;
|
|
10640
|
+
}
|
|
10577
10641
|
push(change) {
|
|
10578
10642
|
assert(this.#output, "Output not set");
|
|
10579
|
-
const shouldBePresent = (row) =>
|
|
10580
|
-
const cmp2 = this.#comparator(this.#bound.row, row);
|
|
10581
|
-
return cmp2 < 0 || cmp2 === 0 && !this.#bound.exclusive;
|
|
10582
|
-
};
|
|
10643
|
+
const shouldBePresent = (row) => this.#shouldBePresent(row);
|
|
10583
10644
|
if (change.type === "edit") {
|
|
10584
10645
|
maybeSplitAndPushEditChange(change, shouldBePresent, this.#output);
|
|
10585
10646
|
return;
|
|
@@ -10596,40 +10657,38 @@ var Skip = class {
|
|
|
10596
10657
|
basis: this.#bound.exclusive ? "after" : "at"
|
|
10597
10658
|
};
|
|
10598
10659
|
if (!req.start) {
|
|
10660
|
+
if (req.reverse) {
|
|
10661
|
+
return void 0;
|
|
10662
|
+
}
|
|
10599
10663
|
return boundStart;
|
|
10600
10664
|
}
|
|
10601
10665
|
const cmp2 = this.#comparator(this.#bound.row, req.start.row);
|
|
10602
|
-
if (
|
|
10603
|
-
|
|
10604
|
-
|
|
10605
|
-
|
|
10606
|
-
if (
|
|
10607
|
-
|
|
10608
|
-
|
|
10609
|
-
|
|
10610
|
-
|
|
10666
|
+
if (!req.reverse) {
|
|
10667
|
+
if (cmp2 > 0) {
|
|
10668
|
+
return boundStart;
|
|
10669
|
+
}
|
|
10670
|
+
if (cmp2 === 0) {
|
|
10671
|
+
if (this.#bound.exclusive || req.start.basis === "after") {
|
|
10672
|
+
return {
|
|
10673
|
+
row: this.#bound.row,
|
|
10674
|
+
basis: "after"
|
|
10675
|
+
};
|
|
10676
|
+
}
|
|
10677
|
+
return boundStart;
|
|
10611
10678
|
}
|
|
10612
|
-
return boundStart;
|
|
10613
|
-
}
|
|
10614
|
-
assert(cmp2 < 0);
|
|
10615
|
-
if (req.start.basis === "at" || req.start.basis === "after") {
|
|
10616
10679
|
return req.start;
|
|
10617
10680
|
}
|
|
10618
|
-
req.
|
|
10619
|
-
|
|
10620
|
-
|
|
10621
|
-
return {
|
|
10622
|
-
row: req.start.row,
|
|
10623
|
-
basis: "at"
|
|
10624
|
-
};
|
|
10681
|
+
req.reverse;
|
|
10682
|
+
if (cmp2 > 0) {
|
|
10683
|
+
return "empty";
|
|
10625
10684
|
}
|
|
10626
|
-
if (
|
|
10627
|
-
|
|
10685
|
+
if (cmp2 === 0) {
|
|
10686
|
+
if (!this.#bound.exclusive && req.start.basis === "at") {
|
|
10687
|
+
return boundStart;
|
|
10688
|
+
}
|
|
10689
|
+
return "empty";
|
|
10628
10690
|
}
|
|
10629
|
-
return
|
|
10630
|
-
row: node.row,
|
|
10631
|
-
basis: "at"
|
|
10632
|
-
};
|
|
10691
|
+
return req.start;
|
|
10633
10692
|
}
|
|
10634
10693
|
};
|
|
10635
10694
|
|
|
@@ -10697,10 +10756,8 @@ var Take = class {
|
|
|
10697
10756
|
}
|
|
10698
10757
|
*#initialFetch(req) {
|
|
10699
10758
|
assert(req.start === void 0);
|
|
10700
|
-
assert(
|
|
10701
|
-
|
|
10702
|
-
constraintMatchesPartitionKey(req.constraint, this.#partitionKey)
|
|
10703
|
-
);
|
|
10759
|
+
assert(!req.reverse);
|
|
10760
|
+
assert(constraintMatchesPartitionKey(req.constraint, this.#partitionKey));
|
|
10704
10761
|
if (this.#limit === 0) {
|
|
10705
10762
|
return;
|
|
10706
10763
|
}
|
|
@@ -10734,24 +10791,15 @@ var Take = class {
|
|
|
10734
10791
|
}
|
|
10735
10792
|
*cleanup(req) {
|
|
10736
10793
|
assert(req.start === void 0);
|
|
10737
|
-
assert(
|
|
10738
|
-
|
|
10739
|
-
|
|
10740
|
-
|
|
10741
|
-
let takeState;
|
|
10742
|
-
if (this.#limit > 0) {
|
|
10743
|
-
const takeStateKey = getTakeStateKey(this.#partitionKey, req.constraint);
|
|
10744
|
-
takeState = this.#storage.get(takeStateKey);
|
|
10745
|
-
assert(
|
|
10746
|
-
takeState !== void 0,
|
|
10747
|
-
"takeStateKey was: " + takeStateKey + ", partitionKey was: " + this.#partitionKey + ", constraint was: " + JSON.stringify(req.constraint)
|
|
10748
|
-
);
|
|
10749
|
-
this.#storage.del(takeStateKey);
|
|
10750
|
-
}
|
|
10794
|
+
assert(constraintMatchesPartitionKey(req.constraint, this.#partitionKey));
|
|
10795
|
+
const takeStateKey = getTakeStateKey(this.#partitionKey, req.constraint);
|
|
10796
|
+
this.#storage.del(takeStateKey);
|
|
10797
|
+
let size = 0;
|
|
10751
10798
|
for (const inputNode of this.#input.cleanup(req)) {
|
|
10752
|
-
if (
|
|
10799
|
+
if (size === this.#limit) {
|
|
10753
10800
|
return;
|
|
10754
10801
|
}
|
|
10802
|
+
size++;
|
|
10755
10803
|
yield inputNode;
|
|
10756
10804
|
}
|
|
10757
10805
|
}
|
|
@@ -10808,13 +10856,14 @@ var Take = class {
|
|
|
10808
10856
|
)
|
|
10809
10857
|
);
|
|
10810
10858
|
} else {
|
|
10811
|
-
[
|
|
10859
|
+
[boundNode, beforeBoundNode] = take(
|
|
10812
10860
|
this.#input.fetch({
|
|
10813
10861
|
start: {
|
|
10814
10862
|
row: takeState.bound,
|
|
10815
|
-
basis: "
|
|
10863
|
+
basis: "at"
|
|
10816
10864
|
},
|
|
10817
|
-
constraint
|
|
10865
|
+
constraint,
|
|
10866
|
+
reverse: true
|
|
10818
10867
|
}),
|
|
10819
10868
|
2
|
|
10820
10869
|
);
|
|
@@ -10839,21 +10888,41 @@ var Take = class {
|
|
|
10839
10888
|
if (compToBound > 0) {
|
|
10840
10889
|
return;
|
|
10841
10890
|
}
|
|
10891
|
+
const [beforeBoundNode] = take(
|
|
10892
|
+
this.#input.fetch({
|
|
10893
|
+
start: {
|
|
10894
|
+
row: takeState.bound,
|
|
10895
|
+
basis: "after"
|
|
10896
|
+
},
|
|
10897
|
+
constraint,
|
|
10898
|
+
reverse: true
|
|
10899
|
+
}),
|
|
10900
|
+
1
|
|
10901
|
+
);
|
|
10842
10902
|
let newBound;
|
|
10843
|
-
|
|
10844
|
-
|
|
10845
|
-
row: takeState.bound,
|
|
10846
|
-
basis: "before"
|
|
10847
|
-
},
|
|
10848
|
-
constraint
|
|
10849
|
-
})) {
|
|
10850
|
-
const push2 = compareRows(node.row, takeState.bound) > 0;
|
|
10903
|
+
if (beforeBoundNode) {
|
|
10904
|
+
const push2 = compareRows(beforeBoundNode.row, takeState.bound) > 0;
|
|
10851
10905
|
newBound = {
|
|
10852
|
-
node,
|
|
10906
|
+
node: beforeBoundNode,
|
|
10853
10907
|
push: push2
|
|
10854
10908
|
};
|
|
10855
|
-
|
|
10856
|
-
|
|
10909
|
+
}
|
|
10910
|
+
if (!newBound?.push) {
|
|
10911
|
+
for (const node of this.#input.fetch({
|
|
10912
|
+
start: {
|
|
10913
|
+
row: takeState.bound,
|
|
10914
|
+
basis: "at"
|
|
10915
|
+
},
|
|
10916
|
+
constraint
|
|
10917
|
+
})) {
|
|
10918
|
+
const push2 = compareRows(node.row, takeState.bound) > 0;
|
|
10919
|
+
newBound = {
|
|
10920
|
+
node,
|
|
10921
|
+
push: push2
|
|
10922
|
+
};
|
|
10923
|
+
if (push2) {
|
|
10924
|
+
break;
|
|
10925
|
+
}
|
|
10857
10926
|
}
|
|
10858
10927
|
}
|
|
10859
10928
|
if (newBound?.push) {
|
|
@@ -10928,9 +10997,10 @@ var Take = class {
|
|
|
10928
10997
|
this.#input.fetch({
|
|
10929
10998
|
start: {
|
|
10930
10999
|
row: takeState.bound,
|
|
10931
|
-
basis: "
|
|
11000
|
+
basis: "after"
|
|
10932
11001
|
},
|
|
10933
|
-
constraint
|
|
11002
|
+
constraint,
|
|
11003
|
+
reverse: true
|
|
10934
11004
|
})
|
|
10935
11005
|
)
|
|
10936
11006
|
);
|
|
@@ -10981,13 +11051,14 @@ var Take = class {
|
|
|
10981
11051
|
return;
|
|
10982
11052
|
}
|
|
10983
11053
|
assert(newCmp < 0);
|
|
10984
|
-
const [
|
|
11054
|
+
const [oldBoundNode, newBoundNode] = take(
|
|
10985
11055
|
this.#input.fetch({
|
|
10986
11056
|
start: {
|
|
10987
11057
|
row: takeState.bound,
|
|
10988
|
-
basis: "
|
|
11058
|
+
basis: "at"
|
|
10989
11059
|
},
|
|
10990
|
-
constraint
|
|
11060
|
+
constraint,
|
|
11061
|
+
reverse: true
|
|
10991
11062
|
}),
|
|
10992
11063
|
2
|
|
10993
11064
|
);
|
|
@@ -11070,6 +11141,12 @@ function getTakeStateKey(partitionKey, rowOrConstraint) {
|
|
|
11070
11141
|
return JSON.stringify(["take", ...partitionValues]);
|
|
11071
11142
|
}
|
|
11072
11143
|
function constraintMatchesPartitionKey(constraint, partitionKey) {
|
|
11144
|
+
if (constraint === void 0 || partitionKey === void 0) {
|
|
11145
|
+
return constraint === partitionKey;
|
|
11146
|
+
}
|
|
11147
|
+
if (partitionKey.length !== Object.keys(constraint).length) {
|
|
11148
|
+
return false;
|
|
11149
|
+
}
|
|
11073
11150
|
for (const key of partitionKey) {
|
|
11074
11151
|
if (!hasOwn(constraint, key)) {
|
|
11075
11152
|
return false;
|
|
@@ -11380,7 +11457,8 @@ function applyCorrelatedSubQuery(sq, delegate, end) {
|
|
|
11380
11457
|
parentKey: sq.correlation.parentField,
|
|
11381
11458
|
childKey: sq.correlation.childField,
|
|
11382
11459
|
relationshipName: sq.subquery.alias,
|
|
11383
|
-
hidden: sq.hidden ?? false
|
|
11460
|
+
hidden: sq.hidden ?? false,
|
|
11461
|
+
system: sq.system ?? "client"
|
|
11384
11462
|
});
|
|
11385
11463
|
return end;
|
|
11386
11464
|
}
|
|
@@ -11501,12 +11579,21 @@ var ArrayView = class {
|
|
|
11501
11579
|
#root;
|
|
11502
11580
|
onDestroy;
|
|
11503
11581
|
#dirty = false;
|
|
11504
|
-
|
|
11582
|
+
#complete = false;
|
|
11583
|
+
constructor(input, format = { singular: false, relationships: {} }, queryComplete = true) {
|
|
11505
11584
|
this.#input = input;
|
|
11506
11585
|
this.#schema = input.getSchema();
|
|
11507
11586
|
this.#format = format;
|
|
11508
11587
|
this.#root = { "": format.singular ? void 0 : [] };
|
|
11509
11588
|
input.setOutput(this);
|
|
11589
|
+
if (queryComplete === true) {
|
|
11590
|
+
this.#complete = true;
|
|
11591
|
+
} else {
|
|
11592
|
+
void queryComplete.then(() => {
|
|
11593
|
+
this.#complete = true;
|
|
11594
|
+
this.#fireListeners();
|
|
11595
|
+
});
|
|
11596
|
+
}
|
|
11510
11597
|
this.#hydrate();
|
|
11511
11598
|
}
|
|
11512
11599
|
get data() {
|
|
@@ -11515,16 +11602,22 @@ var ArrayView = class {
|
|
|
11515
11602
|
addListener(listener) {
|
|
11516
11603
|
assert(!this.#listeners.has(listener), "Listener already registered");
|
|
11517
11604
|
this.#listeners.add(listener);
|
|
11518
|
-
listener
|
|
11605
|
+
this.#fireListener(listener);
|
|
11519
11606
|
return () => {
|
|
11520
11607
|
this.#listeners.delete(listener);
|
|
11521
11608
|
};
|
|
11522
11609
|
}
|
|
11523
11610
|
#fireListeners() {
|
|
11524
11611
|
for (const listener of this.#listeners) {
|
|
11525
|
-
listener
|
|
11612
|
+
this.#fireListener(listener);
|
|
11526
11613
|
}
|
|
11527
11614
|
}
|
|
11615
|
+
#fireListener(listener) {
|
|
11616
|
+
listener(
|
|
11617
|
+
this.data,
|
|
11618
|
+
this.#complete ? "complete" : "unknown"
|
|
11619
|
+
);
|
|
11620
|
+
}
|
|
11528
11621
|
destroy() {
|
|
11529
11622
|
this.onDestroy?.();
|
|
11530
11623
|
}
|
|
@@ -11686,6 +11779,7 @@ var AbstractQuery = class {
|
|
|
11686
11779
|
related: [
|
|
11687
11780
|
...this.#ast.related ?? [],
|
|
11688
11781
|
{
|
|
11782
|
+
system: this._system,
|
|
11689
11783
|
correlation: {
|
|
11690
11784
|
parentField: related.sourceField,
|
|
11691
11785
|
childField: related.destField
|
|
@@ -11725,6 +11819,7 @@ var AbstractQuery = class {
|
|
|
11725
11819
|
related: [
|
|
11726
11820
|
...this.#ast.related ?? [],
|
|
11727
11821
|
{
|
|
11822
|
+
system: this._system,
|
|
11728
11823
|
correlation: {
|
|
11729
11824
|
parentField: firstRelation.sourceField,
|
|
11730
11825
|
childField: firstRelation.destField
|
|
@@ -11735,6 +11830,7 @@ var AbstractQuery = class {
|
|
|
11735
11830
|
orderBy: addPrimaryKeys(junctionSchema, void 0),
|
|
11736
11831
|
related: [
|
|
11737
11832
|
{
|
|
11833
|
+
system: this._system,
|
|
11738
11834
|
correlation: {
|
|
11739
11835
|
parentField: secondRelation.sourceField,
|
|
11740
11836
|
childField: secondRelation.destField
|
|
@@ -11836,6 +11932,7 @@ var AbstractQuery = class {
|
|
|
11836
11932
|
return {
|
|
11837
11933
|
type: "correlatedSubquery",
|
|
11838
11934
|
related: {
|
|
11935
|
+
system: this._system,
|
|
11839
11936
|
correlation: {
|
|
11840
11937
|
parentField: related.sourceField,
|
|
11841
11938
|
childField: related.destField
|
|
@@ -11863,6 +11960,7 @@ var AbstractQuery = class {
|
|
|
11863
11960
|
return {
|
|
11864
11961
|
type: "correlatedSubquery",
|
|
11865
11962
|
related: {
|
|
11963
|
+
system: this._system,
|
|
11866
11964
|
correlation: {
|
|
11867
11965
|
parentField: firstRelation.sourceField,
|
|
11868
11966
|
childField: firstRelation.destField
|
|
@@ -11874,6 +11972,7 @@ var AbstractQuery = class {
|
|
|
11874
11972
|
where: {
|
|
11875
11973
|
type: "correlatedSubquery",
|
|
11876
11974
|
related: {
|
|
11975
|
+
system: this._system,
|
|
11877
11976
|
correlation: {
|
|
11878
11977
|
parentField: secondRelation.sourceField,
|
|
11879
11978
|
childField: secondRelation.destField
|
|
@@ -11927,6 +12026,7 @@ var QueryImpl = class extends AbstractQuery {
|
|
|
11927
12026
|
this.#delegate = delegate;
|
|
11928
12027
|
this.#ast = ast;
|
|
11929
12028
|
}
|
|
12029
|
+
_system = "client";
|
|
11930
12030
|
// Not part of Query or QueryInternal interface
|
|
11931
12031
|
get [astForTestingSymbol]() {
|
|
11932
12032
|
return this.#ast;
|
|
@@ -11939,7 +12039,14 @@ var QueryImpl = class extends AbstractQuery {
|
|
|
11939
12039
|
}
|
|
11940
12040
|
materialize(factory) {
|
|
11941
12041
|
const ast = this._completeAst();
|
|
11942
|
-
const
|
|
12042
|
+
const queryCompleteResolver = resolver7();
|
|
12043
|
+
let queryGot = false;
|
|
12044
|
+
const removeServerQuery = this.#delegate.addServerQuery(ast, (got) => {
|
|
12045
|
+
if (got) {
|
|
12046
|
+
queryGot = true;
|
|
12047
|
+
queryCompleteResolver.resolve(true);
|
|
12048
|
+
}
|
|
12049
|
+
});
|
|
11943
12050
|
const input = buildPipeline(ast, this.#delegate);
|
|
11944
12051
|
let removeCommitObserver;
|
|
11945
12052
|
const onDestroy = () => {
|
|
@@ -11948,9 +12055,16 @@ var QueryImpl = class extends AbstractQuery {
|
|
|
11948
12055
|
removeServerQuery();
|
|
11949
12056
|
};
|
|
11950
12057
|
const view = this.#delegate.batchViewUpdates(
|
|
11951
|
-
() => (factory ?? arrayViewFactory)(
|
|
11952
|
-
|
|
11953
|
-
|
|
12058
|
+
() => (factory ?? arrayViewFactory)(
|
|
12059
|
+
this,
|
|
12060
|
+
input,
|
|
12061
|
+
this.format,
|
|
12062
|
+
onDestroy,
|
|
12063
|
+
(cb) => {
|
|
12064
|
+
removeCommitObserver = this.#delegate.onTransactionCommit(cb);
|
|
12065
|
+
},
|
|
12066
|
+
queryGot || queryCompleteResolver.promise
|
|
12067
|
+
)
|
|
11954
12068
|
);
|
|
11955
12069
|
return view;
|
|
11956
12070
|
}
|
|
@@ -11995,8 +12109,8 @@ function addPrimaryKeysToAst(schema, ast) {
|
|
|
11995
12109
|
orderBy: addPrimaryKeys(schema, ast.orderBy)
|
|
11996
12110
|
};
|
|
11997
12111
|
}
|
|
11998
|
-
function arrayViewFactory(_query, input, format, onDestroy, onTransactionCommit) {
|
|
11999
|
-
const v2 = new ArrayView(input, format);
|
|
12112
|
+
function arrayViewFactory(_query, input, format, onDestroy, onTransactionCommit, queryComplete) {
|
|
12113
|
+
const v2 = new ArrayView(input, format, queryComplete);
|
|
12000
12114
|
v2.onDestroy = onDestroy;
|
|
12001
12115
|
onTransactionCommit(() => {
|
|
12002
12116
|
v2.flush();
|
|
@@ -12012,6 +12126,7 @@ var AuthQuery = class _AuthQuery extends AbstractQuery {
|
|
|
12012
12126
|
expressionBuilder() {
|
|
12013
12127
|
return new ExpressionBuilder(this._exists);
|
|
12014
12128
|
}
|
|
12129
|
+
_system = "permissions";
|
|
12015
12130
|
_newQuery(schema, ast, format) {
|
|
12016
12131
|
return new _AuthQuery(schema, ast, format);
|
|
12017
12132
|
}
|
|
@@ -12064,8 +12179,8 @@ function compileRowConfig(rowRules, expressionBuilder) {
|
|
|
12064
12179
|
rowRules.update?.preMutation,
|
|
12065
12180
|
expressionBuilder
|
|
12066
12181
|
),
|
|
12067
|
-
|
|
12068
|
-
rowRules.update?.
|
|
12182
|
+
postMutation: compileRules(
|
|
12183
|
+
rowRules.update?.postMutation,
|
|
12069
12184
|
expressionBuilder
|
|
12070
12185
|
)
|
|
12071
12186
|
},
|
|
@@ -12094,8 +12209,8 @@ function compileCellConfig(cellRules, expressionBuilder) {
|
|
|
12094
12209
|
insert: compileRules(rules.insert, expressionBuilder),
|
|
12095
12210
|
update: {
|
|
12096
12211
|
preMutation: compileRules(rules.update?.preMutation, expressionBuilder),
|
|
12097
|
-
|
|
12098
|
-
rules.update?.
|
|
12212
|
+
postMutation: compileRules(
|
|
12213
|
+
rules.update?.postMutation,
|
|
12099
12214
|
expressionBuilder
|
|
12100
12215
|
)
|
|
12101
12216
|
},
|
|
@@ -12216,10 +12331,22 @@ var errorKindSchema = valita_exports.union(
|
|
|
12216
12331
|
valita_exports.literal("SchemaVersionNotSupported" /* SchemaVersionNotSupported */),
|
|
12217
12332
|
valita_exports.literal("Internal" /* Internal */)
|
|
12218
12333
|
);
|
|
12334
|
+
var basicErrorBodySchema = valita_exports.object({
|
|
12335
|
+
kind: errorKindSchema,
|
|
12336
|
+
message: valita_exports.string()
|
|
12337
|
+
});
|
|
12338
|
+
var serverOverloadedBodySchema = valita_exports.object({
|
|
12339
|
+
kind: valita_exports.literal("ServerOverloaded" /* ServerOverloaded */),
|
|
12340
|
+
message: valita_exports.string(),
|
|
12341
|
+
minBackoffMs: valita_exports.number().optional()
|
|
12342
|
+
});
|
|
12343
|
+
var errorBodySchema = valita_exports.union(
|
|
12344
|
+
basicErrorBodySchema,
|
|
12345
|
+
serverOverloadedBodySchema
|
|
12346
|
+
);
|
|
12219
12347
|
var errorMessageSchema = valita_exports.tuple([
|
|
12220
12348
|
valita_exports.literal("error"),
|
|
12221
|
-
|
|
12222
|
-
valita_exports.string()
|
|
12349
|
+
errorBodySchema
|
|
12223
12350
|
]);
|
|
12224
12351
|
|
|
12225
12352
|
// ../zero-protocol/src/primary-key.ts
|
|
@@ -12453,6 +12580,9 @@ var upstreamSchema = valita_exports.union(
|
|
|
12453
12580
|
pushMessageSchema
|
|
12454
12581
|
);
|
|
12455
12582
|
|
|
12583
|
+
// ../zero-protocol/src/protocol-version.ts
|
|
12584
|
+
var PROTOCOL_VERSION = 2;
|
|
12585
|
+
|
|
12456
12586
|
// ../zero-client/src/util/nanoid.ts
|
|
12457
12587
|
function nanoid(size = 21) {
|
|
12458
12588
|
const randomBytes = getNonCryptoRandomValues(new Uint8Array(size));
|
|
@@ -14108,47 +14238,6 @@ function constraintMatchesPrimaryKey(constraint, primary) {
|
|
|
14108
14238
|
return true;
|
|
14109
14239
|
}
|
|
14110
14240
|
|
|
14111
|
-
// ../zql/src/ivm/lookahead-iterator.ts
|
|
14112
|
-
var LookaheadIterator = class {
|
|
14113
|
-
#iter;
|
|
14114
|
-
#buffer;
|
|
14115
|
-
#initialized = false;
|
|
14116
|
-
constructor(iter, size = 2) {
|
|
14117
|
-
this.#iter = iter;
|
|
14118
|
-
this.#buffer = new Array(size);
|
|
14119
|
-
}
|
|
14120
|
-
[Symbol.iterator]() {
|
|
14121
|
-
return this;
|
|
14122
|
-
}
|
|
14123
|
-
next() {
|
|
14124
|
-
if (!this.#initialized) {
|
|
14125
|
-
for (let i = 0; i < this.#buffer.length; i++) {
|
|
14126
|
-
const r = this.#iter.next();
|
|
14127
|
-
this.#buffer[i] = r.done ? void 0 : r.value;
|
|
14128
|
-
}
|
|
14129
|
-
this.#initialized = true;
|
|
14130
|
-
} else {
|
|
14131
|
-
for (let i = 0; i < this.#buffer.length - 1; i++) {
|
|
14132
|
-
this.#buffer[i] = this.#buffer[i + 1];
|
|
14133
|
-
}
|
|
14134
|
-
const r = this.#iter.next();
|
|
14135
|
-
this.#buffer[this.#buffer.length - 1] = r.done ? void 0 : r.value;
|
|
14136
|
-
}
|
|
14137
|
-
if (this.#buffer[0] === void 0) {
|
|
14138
|
-
return { done: true, value: void 0 };
|
|
14139
|
-
}
|
|
14140
|
-
return { done: false, value: this.#buffer };
|
|
14141
|
-
}
|
|
14142
|
-
return(value) {
|
|
14143
|
-
this.#iter.return?.(value);
|
|
14144
|
-
return { done: true, value: void 0 };
|
|
14145
|
-
}
|
|
14146
|
-
throw(e) {
|
|
14147
|
-
this.#iter.throw?.(e);
|
|
14148
|
-
return { done: true, value: void 0 };
|
|
14149
|
-
}
|
|
14150
|
-
};
|
|
14151
|
-
|
|
14152
14241
|
// ../zql/src/ivm/memory-source.ts
|
|
14153
14242
|
var MemorySource = class {
|
|
14154
14243
|
#tableName;
|
|
@@ -14185,6 +14274,7 @@ var MemorySource = class {
|
|
|
14185
14274
|
columns: this.#columns,
|
|
14186
14275
|
primaryKey: this.#primaryKey,
|
|
14187
14276
|
sort: connection.sort,
|
|
14277
|
+
system: "client",
|
|
14188
14278
|
relationships: {},
|
|
14189
14279
|
isHidden: false,
|
|
14190
14280
|
compareRows: connection.compareRows
|
|
@@ -14276,7 +14366,8 @@ var MemorySource = class {
|
|
|
14276
14366
|
indexSort.push(...requestedSort);
|
|
14277
14367
|
}
|
|
14278
14368
|
const index = this.#getOrCreateIndex(indexSort, from);
|
|
14279
|
-
const { data, comparator } = index;
|
|
14369
|
+
const { data, comparator: compare } = index;
|
|
14370
|
+
const comparator = (r1, r2) => compare(r1, r2) * (req.reverse ? -1 : 1);
|
|
14280
14371
|
if (this.#overlay) {
|
|
14281
14372
|
if (callingConnectionNum <= this.#overlay.outputIndex) {
|
|
14282
14373
|
overlay = this.#overlay;
|
|
@@ -14284,37 +14375,11 @@ var MemorySource = class {
|
|
|
14284
14375
|
}
|
|
14285
14376
|
const { constraint } = req;
|
|
14286
14377
|
const matchesConstraint = constraint ? (row) => constraintMatchesRow(constraint, row) : (_) => true;
|
|
14287
|
-
const
|
|
14288
|
-
const matchesConstraintAndFilters = predicate ? (row) => matchesConstraint(row) && predicate(row) : matchesConstraint;
|
|
14289
|
-
const nextLowerKey = (row) => {
|
|
14290
|
-
if (!row) {
|
|
14291
|
-
return void 0;
|
|
14292
|
-
}
|
|
14293
|
-
let o = overlay;
|
|
14294
|
-
if (o) {
|
|
14295
|
-
if (comparator(o.change.row, row) >= 0) {
|
|
14296
|
-
o = void 0;
|
|
14297
|
-
}
|
|
14298
|
-
}
|
|
14299
|
-
while (row !== void 0) {
|
|
14300
|
-
row = data.nextLowerKey(row);
|
|
14301
|
-
if (row && matchesConstraintAndFilters(row)) {
|
|
14302
|
-
if (o && comparator(o.change.row, row) >= 0) {
|
|
14303
|
-
return o.change.row;
|
|
14304
|
-
}
|
|
14305
|
-
return row;
|
|
14306
|
-
}
|
|
14307
|
-
}
|
|
14308
|
-
return o?.change.row;
|
|
14309
|
-
};
|
|
14310
|
-
let startAt = req.start?.row;
|
|
14378
|
+
const startAt = req.start?.row;
|
|
14311
14379
|
if (startAt) {
|
|
14312
14380
|
if (req.constraint) {
|
|
14313
14381
|
assert(matchesConstraint(startAt), "Start row must match constraint");
|
|
14314
14382
|
}
|
|
14315
|
-
if (req.start.basis === "before") {
|
|
14316
|
-
startAt = nextLowerKey(startAt);
|
|
14317
|
-
}
|
|
14318
14383
|
}
|
|
14319
14384
|
let scanStart;
|
|
14320
14385
|
if (req.constraint) {
|
|
@@ -14323,7 +14388,11 @@ var MemorySource = class {
|
|
|
14323
14388
|
if (hasOwn(req.constraint, key)) {
|
|
14324
14389
|
scanStart[key] = req.constraint[key];
|
|
14325
14390
|
} else {
|
|
14326
|
-
|
|
14391
|
+
if (req.reverse) {
|
|
14392
|
+
scanStart[key] = dir === "asc" ? maxValue : minValue;
|
|
14393
|
+
} else {
|
|
14394
|
+
scanStart[key] = dir === "asc" ? minValue : maxValue;
|
|
14395
|
+
}
|
|
14327
14396
|
}
|
|
14328
14397
|
}
|
|
14329
14398
|
} else {
|
|
@@ -14331,16 +14400,14 @@ var MemorySource = class {
|
|
|
14331
14400
|
}
|
|
14332
14401
|
const withOverlay = generateWithOverlay(
|
|
14333
14402
|
startAt,
|
|
14334
|
-
|
|
14335
|
-
// key.
|
|
14336
|
-
data.keys(scanStart),
|
|
14403
|
+
generateRows(data, scanStart, req.reverse),
|
|
14337
14404
|
req.constraint,
|
|
14338
14405
|
overlay,
|
|
14339
14406
|
comparator,
|
|
14340
14407
|
conn.filters?.predicate
|
|
14341
14408
|
);
|
|
14342
14409
|
const withConstraint = generateWithConstraint(
|
|
14343
|
-
generateWithStart(withOverlay, req, comparator),
|
|
14410
|
+
generateWithStart(withOverlay, req.start, comparator),
|
|
14344
14411
|
req.constraint
|
|
14345
14412
|
);
|
|
14346
14413
|
yield* conn.filters ? generateWithFilter(withConstraint, conn.filters.predicate) : withConstraint;
|
|
@@ -14349,23 +14416,30 @@ var MemorySource = class {
|
|
|
14349
14416
|
return this.#fetch(req, connection);
|
|
14350
14417
|
}
|
|
14351
14418
|
push(change) {
|
|
14419
|
+
for (const _ of this.genPush(change)) {
|
|
14420
|
+
}
|
|
14421
|
+
}
|
|
14422
|
+
*genPush(change) {
|
|
14352
14423
|
const primaryIndex = this.#getPrimaryIndex();
|
|
14353
14424
|
const { data } = primaryIndex;
|
|
14354
14425
|
switch (change.type) {
|
|
14355
14426
|
case "add":
|
|
14356
|
-
|
|
14357
|
-
|
|
14358
|
-
|
|
14427
|
+
assert(
|
|
14428
|
+
!data.has(change.row),
|
|
14429
|
+
() => `Row already exists ${JSON.stringify(change)}`
|
|
14430
|
+
);
|
|
14359
14431
|
break;
|
|
14360
14432
|
case "remove":
|
|
14361
|
-
|
|
14362
|
-
|
|
14363
|
-
|
|
14433
|
+
assert(
|
|
14434
|
+
data.has(change.row),
|
|
14435
|
+
() => `Row not found ${JSON.stringify(change)}`
|
|
14436
|
+
);
|
|
14364
14437
|
break;
|
|
14365
14438
|
case "edit":
|
|
14366
|
-
|
|
14367
|
-
|
|
14368
|
-
|
|
14439
|
+
assert(
|
|
14440
|
+
data.has(change.oldRow),
|
|
14441
|
+
() => `Row not found ${JSON.stringify(change)}`
|
|
14442
|
+
);
|
|
14369
14443
|
break;
|
|
14370
14444
|
default:
|
|
14371
14445
|
unreachable(change);
|
|
@@ -14391,6 +14465,7 @@ var MemorySource = class {
|
|
|
14391
14465
|
if (output) {
|
|
14392
14466
|
this.#overlay = { outputIndex, change };
|
|
14393
14467
|
output.push(outputChange);
|
|
14468
|
+
yield;
|
|
14394
14469
|
}
|
|
14395
14470
|
}
|
|
14396
14471
|
this.#overlay = void 0;
|
|
@@ -14433,28 +14508,26 @@ function* generateWithFilter(it, filter) {
|
|
|
14433
14508
|
}
|
|
14434
14509
|
}
|
|
14435
14510
|
}
|
|
14436
|
-
function* generateWithStart(
|
|
14437
|
-
|
|
14438
|
-
|
|
14439
|
-
|
|
14511
|
+
function* generateWithStart(nodes, start, compare) {
|
|
14512
|
+
if (!start) {
|
|
14513
|
+
yield* nodes;
|
|
14514
|
+
return;
|
|
14515
|
+
}
|
|
14516
|
+
let started = false;
|
|
14517
|
+
for (const node of nodes) {
|
|
14440
14518
|
if (!started) {
|
|
14441
|
-
|
|
14442
|
-
|
|
14443
|
-
if (next === void 0 || compare(next.row, req.start.row) >= 0) {
|
|
14444
|
-
started = true;
|
|
14445
|
-
}
|
|
14446
|
-
} else if (req.start.basis === "at") {
|
|
14447
|
-
if (compare(curr.row, req.start.row) >= 0) {
|
|
14519
|
+
if (start.basis === "at") {
|
|
14520
|
+
if (compare(node.row, start.row) >= 0) {
|
|
14448
14521
|
started = true;
|
|
14449
14522
|
}
|
|
14450
|
-
} else if (
|
|
14451
|
-
if (compare(
|
|
14523
|
+
} else if (start.basis === "after") {
|
|
14524
|
+
if (compare(node.row, start.row) > 0) {
|
|
14452
14525
|
started = true;
|
|
14453
14526
|
}
|
|
14454
14527
|
}
|
|
14455
14528
|
}
|
|
14456
14529
|
if (started) {
|
|
14457
|
-
yield
|
|
14530
|
+
yield node;
|
|
14458
14531
|
}
|
|
14459
14532
|
}
|
|
14460
14533
|
}
|
|
@@ -14581,6 +14654,14 @@ function compareBounds(a, b) {
|
|
|
14581
14654
|
}
|
|
14582
14655
|
return compareValues(a, b);
|
|
14583
14656
|
}
|
|
14657
|
+
function* generateRows(data, scanStart, reverse) {
|
|
14658
|
+
for (const entry of data[reverse ? "entriesReversed" : "entries"](
|
|
14659
|
+
scanStart,
|
|
14660
|
+
[]
|
|
14661
|
+
)) {
|
|
14662
|
+
yield entry[0];
|
|
14663
|
+
}
|
|
14664
|
+
}
|
|
14584
14665
|
|
|
14585
14666
|
// ../zql/src/ivm/memory-storage.ts
|
|
14586
14667
|
var MemoryStorage = class {
|
|
@@ -14668,7 +14749,7 @@ var ZeroContext = class {
|
|
|
14668
14749
|
#commitListeners = /* @__PURE__ */ new Set();
|
|
14669
14750
|
staticQueryParameters = void 0;
|
|
14670
14751
|
constructor(tables, addQuery, batchViewUpdates) {
|
|
14671
|
-
this.#tables = tables;
|
|
14752
|
+
this.#tables = normalizeTables(tables);
|
|
14672
14753
|
this.#addQuery = addQuery;
|
|
14673
14754
|
this.#batchViewUpdates = batchViewUpdates;
|
|
14674
14755
|
}
|
|
@@ -15219,7 +15300,7 @@ function makeMessage(message, context, logLevel) {
|
|
|
15219
15300
|
}
|
|
15220
15301
|
|
|
15221
15302
|
// ../zero-client/src/client/version.ts
|
|
15222
|
-
var version2 = "0.7.
|
|
15303
|
+
var version2 = "0.7.2024120700+5421b9";
|
|
15223
15304
|
|
|
15224
15305
|
// ../zero-client/src/client/log-options.ts
|
|
15225
15306
|
var LevelFilterLogSink = class {
|
|
@@ -15505,9 +15586,6 @@ var State = class {
|
|
|
15505
15586
|
}
|
|
15506
15587
|
};
|
|
15507
15588
|
|
|
15508
|
-
// ../zero-client/src/client/protocol-version.ts
|
|
15509
|
-
var PROTOCOL_VERSION = 1;
|
|
15510
|
-
|
|
15511
15589
|
// ../zero-client/src/client/query-manager.ts
|
|
15512
15590
|
var QueryManager = class {
|
|
15513
15591
|
#clientID;
|
|
@@ -15616,9 +15694,7 @@ var QueryManager = class {
|
|
|
15616
15694
|
}
|
|
15617
15695
|
}
|
|
15618
15696
|
if (gotCallback) {
|
|
15619
|
-
|
|
15620
|
-
gotCallback(this.#gotQueries.has(astHash));
|
|
15621
|
-
});
|
|
15697
|
+
gotCallback(this.#gotQueries.has(astHash));
|
|
15622
15698
|
}
|
|
15623
15699
|
let removed = false;
|
|
15624
15700
|
return () => {
|
|
@@ -15734,11 +15810,14 @@ function nextBackoff(lc, now) {
|
|
|
15734
15810
|
|
|
15735
15811
|
// ../zero-client/src/client/server-error.ts
|
|
15736
15812
|
var ServerError = class extends Error {
|
|
15737
|
-
kind;
|
|
15738
15813
|
name = "ServerError";
|
|
15739
|
-
|
|
15740
|
-
|
|
15741
|
-
this.kind
|
|
15814
|
+
errorBody;
|
|
15815
|
+
get kind() {
|
|
15816
|
+
return this.errorBody.kind;
|
|
15817
|
+
}
|
|
15818
|
+
constructor(errorBody) {
|
|
15819
|
+
super(errorBody.kind + ": " + errorBody.message);
|
|
15820
|
+
this.errorBody = errorBody;
|
|
15742
15821
|
}
|
|
15743
15822
|
};
|
|
15744
15823
|
function isServerError(ex) {
|
|
@@ -15750,6 +15829,9 @@ function isAuthError(ex) {
|
|
|
15750
15829
|
function isAuthErrorKind(kind) {
|
|
15751
15830
|
return kind === "AuthInvalidated" /* AuthInvalidated */ || kind === "Unauthorized" /* Unauthorized */;
|
|
15752
15831
|
}
|
|
15832
|
+
function isServerOverloadedError(ex) {
|
|
15833
|
+
return isServerError(ex) && ex.errorBody.kind === "ServerOverloaded" /* ServerOverloaded */ ? ex.errorBody : void 0;
|
|
15834
|
+
}
|
|
15753
15835
|
|
|
15754
15836
|
// ../zero-client/src/client/server-option.ts
|
|
15755
15837
|
function validateServerParam(paramName, server) {
|
|
@@ -16247,7 +16329,9 @@ var Zero = class {
|
|
|
16247
16329
|
["_zero_crud"]: makeCRUDMutator(normalizedSchema)
|
|
16248
16330
|
};
|
|
16249
16331
|
const replicacheOptions = {
|
|
16250
|
-
|
|
16332
|
+
// The schema stored in IDB is dependent upon both the application schema
|
|
16333
|
+
// and the AST schema (i.e. PROTOCOL_VERSION).
|
|
16334
|
+
schemaVersion: `${normalizedSchema.version}.${PROTOCOL_VERSION}`,
|
|
16251
16335
|
logLevel: logOptions.logLevel,
|
|
16252
16336
|
logSinks: [logOptions.logSink],
|
|
16253
16337
|
mutators: replicacheMutators,
|
|
@@ -16529,14 +16613,14 @@ var Zero = class {
|
|
|
16529
16613
|
};
|
|
16530
16614
|
// An error on the connection is fatal for the connection.
|
|
16531
16615
|
async #handleErrorMessage(lc, downMessage) {
|
|
16532
|
-
const [, kind, message] = downMessage;
|
|
16616
|
+
const [, { kind, message }] = downMessage;
|
|
16533
16617
|
if (kind === "MutationRateLimited" /* MutationRateLimited */) {
|
|
16534
16618
|
this.#lastMutationIDSent = NULL_LAST_MUTATION_ID_SENT;
|
|
16535
16619
|
lc.error?.("Mutation rate limited", { message });
|
|
16536
16620
|
return;
|
|
16537
16621
|
}
|
|
16538
16622
|
lc.info?.(`${kind}: ${message}}`);
|
|
16539
|
-
const error = new ServerError(
|
|
16623
|
+
const error = new ServerError(downMessage[1]);
|
|
16540
16624
|
this.#rejectMessageError?.reject(error);
|
|
16541
16625
|
lc.debug?.("Rejecting connect resolver due to error", error);
|
|
16542
16626
|
this.#connectResolver.reject(error);
|
|
@@ -16897,9 +16981,11 @@ var Zero = class {
|
|
|
16897
16981
|
await this.#updateAuthToken(bareLogContext);
|
|
16898
16982
|
let needsReauth = false;
|
|
16899
16983
|
let gotError = false;
|
|
16984
|
+
let backoffMs = RUN_LOOP_INTERVAL_MS;
|
|
16900
16985
|
while (!this.closed) {
|
|
16901
16986
|
runLoopCounter++;
|
|
16902
16987
|
let lc = getLogContext();
|
|
16988
|
+
backoffMs = RUN_LOOP_INTERVAL_MS;
|
|
16903
16989
|
try {
|
|
16904
16990
|
switch (this.#connectionState) {
|
|
16905
16991
|
case 0 /* Disconnected */: {
|
|
@@ -16999,16 +17085,20 @@ var Zero = class {
|
|
|
16999
17085
|
if (isServerError(ex) || ex instanceof TimedOutError || ex instanceof CloseError) {
|
|
17000
17086
|
gotError = true;
|
|
17001
17087
|
}
|
|
17088
|
+
const overloaded = isServerOverloadedError(ex);
|
|
17089
|
+
if (overloaded && overloaded.minBackoffMs) {
|
|
17090
|
+
backoffMs = Math.max(backoffMs, overloaded.minBackoffMs);
|
|
17091
|
+
}
|
|
17002
17092
|
}
|
|
17003
17093
|
if (gotError) {
|
|
17004
17094
|
this.#setOnline(false);
|
|
17005
17095
|
lc.debug?.(
|
|
17006
17096
|
"Sleeping",
|
|
17007
|
-
|
|
17097
|
+
backoffMs,
|
|
17008
17098
|
"ms before reconnecting due to error, state:",
|
|
17009
17099
|
this.#connectionState
|
|
17010
17100
|
);
|
|
17011
|
-
await sleep(
|
|
17101
|
+
await sleep(backoffMs);
|
|
17012
17102
|
}
|
|
17013
17103
|
}
|
|
17014
17104
|
}
|
|
@@ -17209,4 +17299,4 @@ export {
|
|
|
17209
17299
|
escapeLike,
|
|
17210
17300
|
Zero
|
|
17211
17301
|
};
|
|
17212
|
-
//# sourceMappingURL=chunk-
|
|
17302
|
+
//# sourceMappingURL=chunk-PFF4AHTF.js.map
|