effect-zero 0.4.0 → 0.4.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/dist/query.d.ts.map +1 -1
- package/dist/query.js +7 -3
- package/dist/query.js.map +1 -1
- package/dist/server.d.ts +2 -0
- package/dist/server.d.ts.map +1 -1
- package/dist/snapshot.d.ts +2 -2
- package/dist/snapshot.d.ts.map +1 -1
- package/dist/snapshot.js +66 -8
- package/dist/snapshot.js.map +1 -1
- package/dist/types/error.d.ts +59 -0
- package/dist/types/error.d.ts.map +1 -0
- package/dist/types/error.js +58 -0
- package/dist/types/error.js.map +1 -0
- package/dist/types/push.d.ts +53 -1
- package/dist/types/push.d.ts.map +1 -1
- package/dist/types/push.js +63 -10
- package/dist/types/push.js.map +1 -1
- package/dist/types/queries.d.ts +28 -9
- package/dist/types/queries.d.ts.map +1 -1
- package/dist/types/queries.js +14 -15
- package/dist/types/queries.js.map +1 -1
- package/package.json +7 -1
- package/src/query.ts +12 -3
- package/src/snapshot.ts +70 -11
- package/src/types/error.ts +71 -0
- package/src/types/push.ts +69 -10
- package/src/types/queries.ts +16 -16
package/dist/query.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAiB,iBAAiB,EAAE,IAAI,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEvH,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAGtC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,YAAY,MAAM,qBAAqB,CAAC;AACpD,OAAO,KAAK,WAAW,MAAM,4BAA4B,CAAC;AAK1D,KAAK,SAAS,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};
|
|
43
43
|
export const stream = (zero, query) => Effect.gen(function* () {
|
|
44
44
|
const view = yield* Effect.acquireRelease(Effect.sync(() => zero.materialize(query)), (view) => Effect.sync(() => view.destroy()));
|
|
45
|
-
return Stream.asyncEffect((emit) => Effect.sync(() => view.addListener((...args) => emit.single(args)))).pipe(Stream.mapEffect(([data, resultType]) => Effect.sync(() => {
|
|
46
|
-
// logic here borrowed from: https://github.com/rocicorp/mono/blob/
|
|
45
|
+
return Stream.asyncEffect((emit) => Effect.sync(() => view.addListener((...args) => emit.single(args)))).pipe(Stream.mapEffect(([data, resultType, error]) => Effect.sync(() => {
|
|
46
|
+
// logic here borrowed from: https://github.com/rocicorp/mono/blob/8e0f600fb3a9185facf60cfd4971d260b266690e/packages/zero-react/src/use-query.tsx#L543
|
|
47
47
|
const cloned = data === undefined ? data : deepClone(data);
|
|
48
|
-
return getSnapshot(asQueryInternals(query).format.singular, cloned, resultType
|
|
48
|
+
return getSnapshot(asQueryInternals(query).format.singular, cloned, resultType,
|
|
49
|
+
// TODO: Look into this. It seems like this is difficult but not impossible to model in the Effect paradigm.
|
|
50
|
+
// Likely need some kind of stateful piece between the publisher and and subscriber, allowing the subscriber to swap out
|
|
51
|
+
// the publisher when this function is called.
|
|
52
|
+
() => Effect.dieMessage("retry not available in `effect-zero`"), error);
|
|
49
53
|
})), Stream.map(QueryResult.make));
|
|
50
54
|
}).pipe(Stream.unwrapScoped);
|
|
51
55
|
export const initialValue = (query) => QueryResult.make(getDefaultSnapshot(asQueryInternals(query).format.singular));
|
package/dist/query.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.js","sourceRoot":"","sources":["../src/query.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,IAAI,MAAM,aAAa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AM,CAAC,QAAQ,CAAC,CAAC,CAAC;AAEtF,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,IAAa,EACb,KAAyB,EACzB,EAAE;IACF,OAAO,YAAY,CAAC,IAAI,CAAC;QACvB,GAAG,EAAE,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,IAAI,CAClE,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,CAA8C,CAAC,CACjG;QACD,OAAO,EAAE,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC;KAC7B,CAAC,CAAC;AACL,CAAC,CAAC"}
|
package/dist/server.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export declare const processPush: <TSchema extends ZeroSchema, TTransaction, TMu
|
|
|
11
11
|
readonly schema: string;
|
|
12
12
|
readonly appID: string;
|
|
13
13
|
}, request: {
|
|
14
|
+
readonly auth?: string | undefined;
|
|
14
15
|
readonly timestamp: number;
|
|
15
16
|
readonly clientGroupID: string;
|
|
16
17
|
readonly mutations: readonly ({
|
|
@@ -72,6 +73,7 @@ export declare const processPush: <TSchema extends ZeroSchema, TTransaction, TMu
|
|
|
72
73
|
};
|
|
73
74
|
readonly result: {
|
|
74
75
|
readonly error: "app";
|
|
76
|
+
readonly message?: string | undefined;
|
|
75
77
|
readonly details?: unknown;
|
|
76
78
|
} | {
|
|
77
79
|
readonly error: "oooMutation" | "alreadyProcessed";
|
package/dist/server.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,IAAI,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAG9E,OAAO,KAAK,K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,OAAO,iBAAiB,CAAC,IAAI,CAAC,MAAM,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC,EACxE,KAAK,CACN,CAAC;AAEF,eAAO,MAAM,WAAW,GACtB,OAAO,SAAS,UAAU,EAC1B,YAAY,EACZ,SAAS,SAAS,QAAQ,CAAC,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wJAyCtC,CAAC;;;;AA+EH,cAAM,2BAA4B,SAAQ,gCAA+C;CAAG;AAwB5F,eAAO,MAAM,WAAW,GAAwB,CAAC,EAAE,EAAE,EAAE,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4EA2BvD,CAAC;;;;AAEH,cAAM,aAAc,SAAQ,mBAAkC;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;IAC7E,IAAa,OAAO,WAEnB;CACF;;;;AAYD,cAAM,iBAAkB,SAAQ,uBAAsC;IAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;CAAE,CAAC;CAAG"}
|
package/dist/snapshot.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import type { HumanReadable, JSONValue, ReadonlyJSONValue } from "@rocicorp/zero";
|
|
1
|
+
import type { ErroredQuery, HumanReadable, JSONValue, ReadonlyJSONValue, ResultType } from "@rocicorp/zero";
|
|
2
2
|
import type { QueryResult } from "@rocicorp/zero/react";
|
|
3
3
|
export declare function getDefaultSnapshot<TReturn>(singular: boolean): QueryResult<TReturn>;
|
|
4
4
|
/**
|
|
5
5
|
* Returns a new snapshot or one of the empty predefined ones. Returning the
|
|
6
6
|
* predefined ones is important to prevent unnecessary re-renders in React.
|
|
7
7
|
*/
|
|
8
|
-
export declare function getSnapshot<TReturn>(singular: boolean, data: HumanReadable<TReturn>, resultType:
|
|
8
|
+
export declare function getSnapshot<TReturn>(singular: boolean, data: HumanReadable<TReturn>, resultType: ResultType, retryFn: () => void, error?: ErroredQuery): QueryResult<TReturn>;
|
|
9
9
|
export declare function deepClone(value: ReadonlyJSONValue): JSONValue;
|
|
10
10
|
//# sourceMappingURL=snapshot.d.ts.map
|
package/dist/snapshot.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snapshot.d.ts","sourceRoot":"","sources":["../src/snapshot.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"snapshot.d.ts","sourceRoot":"","sources":["../src/snapshot.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,YAAY,EAAE,aAAa,EAAE,SAAS,EAAqB,iBAAiB,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC/H,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAexD,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,CAEnF;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,OAAO,EACjC,QAAQ,EAAE,OAAO,EACjB,IAAI,EAAE,aAAa,CAAC,OAAO,CAAC,EAC5B,UAAU,EAAE,UAAU,EACtB,OAAO,EAAE,MAAM,IAAI,EACnB,KAAK,CAAC,EAAE,YAAY,GACnB,WAAW,CAAC,OAAO,CAAC,CAsDtB;AAgBD,wBAAgB,SAAS,CAAC,KAAK,EAAE,iBAAiB,GAAG,SAAS,CAG7D"}
|
package/dist/snapshot.js
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
// Code borrowed from:
|
|
2
|
-
// https://github.com/rocicorp/mono/blob/
|
|
3
|
-
// https://github.com/rocicorp/mono/blob/
|
|
2
|
+
// https://github.com/rocicorp/mono/blob/8e0f600fb3a9185facf60cfd4971d260b266690e/packages/zero-react/src/use-query.tsx
|
|
3
|
+
// https://github.com/rocicorp/mono/blob/8e0f600fb3a9185facf60cfd4971d260b266690e/packages/shared/src/deep-clone.ts
|
|
4
4
|
const emptyArray = [];
|
|
5
5
|
const resultTypeUnknown = { type: "unknown" };
|
|
6
6
|
const resultTypeComplete = { type: "complete" };
|
|
7
|
+
const resultTypeError = { type: 'error' };
|
|
7
8
|
const emptySnapshotSingularUnknown = [undefined, resultTypeUnknown];
|
|
8
9
|
const emptySnapshotSingularComplete = [undefined, resultTypeComplete];
|
|
10
|
+
const emptySnapshotSingularErrorUnknown = [undefined, resultTypeError];
|
|
9
11
|
const emptySnapshotPluralUnknown = [emptyArray, resultTypeUnknown];
|
|
10
12
|
const emptySnapshotPluralComplete = [emptyArray, resultTypeComplete];
|
|
13
|
+
const emptySnapshotErrorUnknown = [emptyArray, resultTypeError];
|
|
11
14
|
export function getDefaultSnapshot(singular) {
|
|
12
15
|
return (singular ? emptySnapshotSingularUnknown : emptySnapshotPluralUnknown);
|
|
13
16
|
}
|
|
@@ -15,16 +18,71 @@ export function getDefaultSnapshot(singular) {
|
|
|
15
18
|
* Returns a new snapshot or one of the empty predefined ones. Returning the
|
|
16
19
|
* predefined ones is important to prevent unnecessary re-renders in React.
|
|
17
20
|
*/
|
|
18
|
-
export function getSnapshot(singular, data, resultType) {
|
|
21
|
+
export function getSnapshot(singular, data, resultType, retryFn, error) {
|
|
19
22
|
if (singular && data === undefined) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
+
switch (resultType) {
|
|
24
|
+
case 'error':
|
|
25
|
+
if (error) {
|
|
26
|
+
return [
|
|
27
|
+
undefined,
|
|
28
|
+
makeError(retryFn, error),
|
|
29
|
+
];
|
|
30
|
+
}
|
|
31
|
+
return emptySnapshotSingularErrorUnknown;
|
|
32
|
+
case 'complete':
|
|
33
|
+
return emptySnapshotSingularComplete;
|
|
34
|
+
case 'unknown':
|
|
35
|
+
return emptySnapshotSingularUnknown;
|
|
36
|
+
}
|
|
23
37
|
}
|
|
24
38
|
if (!singular && data.length === 0) {
|
|
25
|
-
|
|
39
|
+
switch (resultType) {
|
|
40
|
+
case 'error':
|
|
41
|
+
if (error) {
|
|
42
|
+
return [
|
|
43
|
+
emptyArray,
|
|
44
|
+
makeError(retryFn, error),
|
|
45
|
+
];
|
|
46
|
+
}
|
|
47
|
+
return emptySnapshotErrorUnknown;
|
|
48
|
+
case 'complete':
|
|
49
|
+
return emptySnapshotPluralComplete;
|
|
50
|
+
case 'unknown':
|
|
51
|
+
return emptySnapshotPluralUnknown;
|
|
52
|
+
}
|
|
26
53
|
}
|
|
27
|
-
|
|
54
|
+
switch (resultType) {
|
|
55
|
+
case 'error':
|
|
56
|
+
if (error) {
|
|
57
|
+
return [data, makeError(retryFn, error)];
|
|
58
|
+
}
|
|
59
|
+
return [
|
|
60
|
+
data,
|
|
61
|
+
makeError(retryFn, {
|
|
62
|
+
error: 'app',
|
|
63
|
+
id: 'unknown',
|
|
64
|
+
name: 'unknown',
|
|
65
|
+
message: 'An unknown error occurred',
|
|
66
|
+
}),
|
|
67
|
+
];
|
|
68
|
+
case 'complete':
|
|
69
|
+
return [data, resultTypeComplete];
|
|
70
|
+
case 'unknown':
|
|
71
|
+
return [data, resultTypeUnknown];
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function makeError(retry, error) {
|
|
75
|
+
const message = error.message ?? 'An unknown error occurred';
|
|
76
|
+
return {
|
|
77
|
+
type: 'error',
|
|
78
|
+
retry,
|
|
79
|
+
refetch: retry,
|
|
80
|
+
error: {
|
|
81
|
+
type: error.error,
|
|
82
|
+
message,
|
|
83
|
+
...(error.details ? { details: error.details } : {}),
|
|
84
|
+
},
|
|
85
|
+
};
|
|
28
86
|
}
|
|
29
87
|
export function deepClone(value) {
|
|
30
88
|
const seen = [];
|
package/dist/snapshot.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snapshot.js","sourceRoot":"","sources":["../src/snapshot.ts"],"names":[],"mappings":"AAAA,sBAAsB;AACtB,uH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5B,MAAM,CAAC,GAAI,KAA2C,CAAC,CAAC,CAAC,CAAC;oBAC1D,IAAI,CAAC,KAAK,SAAS,EAAE,CAAC;wBACpB,GAAG,CAAC,CAAC,CAAC,GAAG,iBAAiB,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC;oBACtC,CAAC;gBACH,CAAC;YACH,CAAC;YACD,IAAI,CAAC,GAAG,EAAE,CAAC;YACX,OAAO,GAAG,CAAC;QACb,CAAC;QAED;YACE,MAAM,IAAI,KAAK,CAAC,iBAAiB,OAAO,KAAK,EAAE,CAAC,CAAC;IACrD,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import * as Schema from "effect/Schema";
|
|
2
|
+
export declare const PushFailedBody: Schema.Union<[Schema.Struct<{
|
|
3
|
+
origin: Schema.Literal<["server"]>;
|
|
4
|
+
reason: Schema.Literal<["database", "parse", "oooMutation", "unsupportedPushVersion", "internal"]>;
|
|
5
|
+
kind: Schema.Literal<["PushFailed"]>;
|
|
6
|
+
details: Schema.optional<typeof Schema.Unknown>;
|
|
7
|
+
mutationIDs: Schema.Array$<Schema.Struct<{
|
|
8
|
+
id: typeof Schema.Number;
|
|
9
|
+
clientID: typeof Schema.String;
|
|
10
|
+
}>>;
|
|
11
|
+
message: typeof Schema.String;
|
|
12
|
+
}>, Schema.Struct<{
|
|
13
|
+
origin: Schema.Literal<["zeroCache"]>;
|
|
14
|
+
reason: Schema.Literal<["http"]>;
|
|
15
|
+
status: typeof Schema.Number;
|
|
16
|
+
bodyPreview: Schema.optional<typeof Schema.String>;
|
|
17
|
+
kind: Schema.Literal<["PushFailed"]>;
|
|
18
|
+
details: Schema.optional<typeof Schema.Unknown>;
|
|
19
|
+
mutationIDs: Schema.Array$<Schema.Struct<{
|
|
20
|
+
id: typeof Schema.Number;
|
|
21
|
+
clientID: typeof Schema.String;
|
|
22
|
+
}>>;
|
|
23
|
+
message: typeof Schema.String;
|
|
24
|
+
}>, Schema.Struct<{
|
|
25
|
+
origin: Schema.Literal<["zeroCache"]>;
|
|
26
|
+
reason: Schema.Literal<["timeout", "parse", "internal"]>;
|
|
27
|
+
kind: Schema.Literal<["PushFailed"]>;
|
|
28
|
+
details: Schema.optional<typeof Schema.Unknown>;
|
|
29
|
+
mutationIDs: Schema.Array$<Schema.Struct<{
|
|
30
|
+
id: typeof Schema.Number;
|
|
31
|
+
clientID: typeof Schema.String;
|
|
32
|
+
}>>;
|
|
33
|
+
message: typeof Schema.String;
|
|
34
|
+
}>]>;
|
|
35
|
+
export declare const TransformFailedBody: Schema.Union<[Schema.Struct<{
|
|
36
|
+
origin: Schema.Literal<["server"]>;
|
|
37
|
+
reason: Schema.Literal<["database", "parse", "internal"]>;
|
|
38
|
+
kind: Schema.Literal<["TransformFailed"]>;
|
|
39
|
+
details: Schema.optional<typeof Schema.Unknown>;
|
|
40
|
+
queryIDs: Schema.Array$<typeof Schema.String>;
|
|
41
|
+
message: typeof Schema.String;
|
|
42
|
+
}>, Schema.Struct<{
|
|
43
|
+
origin: Schema.Literal<["zeroCache"]>;
|
|
44
|
+
reason: Schema.Literal<["http"]>;
|
|
45
|
+
status: typeof Schema.Number;
|
|
46
|
+
bodyPreview: Schema.optional<typeof Schema.String>;
|
|
47
|
+
kind: Schema.Literal<["TransformFailed"]>;
|
|
48
|
+
details: Schema.optional<typeof Schema.Unknown>;
|
|
49
|
+
queryIDs: Schema.Array$<typeof Schema.String>;
|
|
50
|
+
message: typeof Schema.String;
|
|
51
|
+
}>, Schema.Struct<{
|
|
52
|
+
origin: Schema.Literal<["zeroCache"]>;
|
|
53
|
+
reason: Schema.Literal<["timeout", "parse", "internal"]>;
|
|
54
|
+
kind: Schema.Literal<["TransformFailed"]>;
|
|
55
|
+
details: Schema.optional<typeof Schema.Unknown>;
|
|
56
|
+
queryIDs: Schema.Array$<typeof Schema.String>;
|
|
57
|
+
message: typeof Schema.String;
|
|
58
|
+
}>]>;
|
|
59
|
+
//# sourceMappingURL=error.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/types/error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAsBxC,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAkB1B,CAAC;AAYF,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;IAkB/B,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import * as Schema from "effect/Schema";
|
|
2
|
+
import { JsonSchema } from "./common.js";
|
|
3
|
+
// The code below was converted to Effect Schema from:
|
|
4
|
+
// https://github.com/rocicorp/mono/blob/8e0f600fb3a9185facf60cfd4971d260b266690e/packages/zero-protocol/src/error.ts
|
|
5
|
+
const MutationId = Schema.Struct({
|
|
6
|
+
id: Schema.Number,
|
|
7
|
+
clientID: Schema.String,
|
|
8
|
+
});
|
|
9
|
+
const PushFailedBase = Schema.Struct({
|
|
10
|
+
kind: Schema.Literal("PushFailed"),
|
|
11
|
+
details: Schema.optional(JsonSchema),
|
|
12
|
+
/**
|
|
13
|
+
* The mutationIDs of the mutations that failed to process.
|
|
14
|
+
* This can be a subset of the mutationIDs in the request.
|
|
15
|
+
*/
|
|
16
|
+
mutationIDs: Schema.Array(MutationId),
|
|
17
|
+
message: Schema.String,
|
|
18
|
+
});
|
|
19
|
+
export const PushFailedBody = Schema.Union(Schema.Struct({
|
|
20
|
+
...PushFailedBase.fields,
|
|
21
|
+
origin: Schema.Literal("server"),
|
|
22
|
+
reason: Schema.Literal("database", "parse", "oooMutation", "unsupportedPushVersion", "internal"),
|
|
23
|
+
}), Schema.Struct({
|
|
24
|
+
...PushFailedBase.fields,
|
|
25
|
+
origin: Schema.Literal("zeroCache"),
|
|
26
|
+
reason: Schema.Literal("http"),
|
|
27
|
+
status: Schema.Number,
|
|
28
|
+
bodyPreview: Schema.optional(Schema.String),
|
|
29
|
+
}), Schema.Struct({
|
|
30
|
+
...PushFailedBase.fields,
|
|
31
|
+
origin: Schema.Literal("zeroCache"),
|
|
32
|
+
reason: Schema.Literal("timeout", "parse", "internal"),
|
|
33
|
+
}));
|
|
34
|
+
const TransformFailedBase = Schema.Struct({
|
|
35
|
+
kind: Schema.Literal("TransformFailed"),
|
|
36
|
+
details: Schema.optional(JsonSchema),
|
|
37
|
+
/**
|
|
38
|
+
* The queryIDs of the queries that failed to transform.
|
|
39
|
+
*/
|
|
40
|
+
queryIDs: Schema.Array(Schema.String),
|
|
41
|
+
message: Schema.String,
|
|
42
|
+
});
|
|
43
|
+
export const TransformFailedBody = Schema.Union(Schema.Struct({
|
|
44
|
+
...TransformFailedBase.fields,
|
|
45
|
+
origin: Schema.Literal("server"),
|
|
46
|
+
reason: Schema.Literal("database", "parse", "internal"),
|
|
47
|
+
}), Schema.Struct({
|
|
48
|
+
...TransformFailedBase.fields,
|
|
49
|
+
origin: Schema.Literal("zeroCache"),
|
|
50
|
+
reason: Schema.Literal("http"),
|
|
51
|
+
status: Schema.Number,
|
|
52
|
+
bodyPreview: Schema.optional(Schema.String),
|
|
53
|
+
}), Schema.Struct({
|
|
54
|
+
...TransformFailedBase.fields,
|
|
55
|
+
origin: Schema.Literal("zeroCache"),
|
|
56
|
+
reason: Schema.Literal("timeout", "parse", "internal"),
|
|
57
|
+
}));
|
|
58
|
+
//# sourceMappingURL=error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/types/error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,sDAAsD;AACtD,qHAAqH;AAErH,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC;IAC/B,EAAE,EAAE,MAAM,CAAC,MAAM;IACjB,QAAQ,EAAE,MAAM,CAAC,MAAM;CACxB,CAAC,CAAC;AAEH,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G;IACH,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC;IACrC,OAAO,EAAE,MAAM,CAAC,MAAM;CACvB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,mBAAmB,GAAG,MAAM,CAAC,KAAK,CAC7C,MAAM,CAAC,MAAM,CAAC;IACZ,GAAG,mBAAmB,CAAC,MAAM;IAC7B,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC;IAChC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,UAAU,EAAE,OAAO,EAAE,UAAU,CAAC;CACxD,CAAC,EACF,MAAM,CAAC,MAAM,CAAC;IACZ,GAAG,mBAAmB,CAAC,MAAM;IAC7B,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC;IACnC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;IAC9B,MAAM,EAAE,MAAM,CAAC,MAAM;IACrB,WAAW,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;CAC5C,CAAC,EACF,MAAM,CAAC,MAAM,CAAC;IACZ,GAAG,mBAAmB,CAAC,MAAM;IAC7B,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,WAAW,CAAC;IACnC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,SAAS,EAAE,OAAO,EAAE,UAAU,CAAC;CACvD,CAAC,CACH,CAAC"}
|
package/dist/types/push.d.ts
CHANGED
|
@@ -80,10 +80,16 @@ export declare const PushBody: Schema.Struct<{
|
|
|
80
80
|
schemaVersion: Schema.optional<typeof Schema.Number>;
|
|
81
81
|
timestamp: typeof Schema.Number;
|
|
82
82
|
requestID: typeof Schema.String;
|
|
83
|
+
/**
|
|
84
|
+
* @deprecated auth is managed at client-group scope via connect/updateAuth
|
|
85
|
+
* and should not be included in push messages.
|
|
86
|
+
*/
|
|
87
|
+
auth: Schema.optional<typeof Schema.String>;
|
|
83
88
|
}>;
|
|
84
89
|
export type PushBody = typeof PushBody.Type;
|
|
85
90
|
export declare const AppError: Schema.Struct<{
|
|
86
91
|
error: Schema.Literal<["app"]>;
|
|
92
|
+
message: Schema.optional<typeof Schema.String>;
|
|
87
93
|
details: Schema.optional<typeof Schema.Unknown>;
|
|
88
94
|
}>;
|
|
89
95
|
export type AppError = typeof AppError.Type;
|
|
@@ -94,6 +100,7 @@ export declare const ZeroError: Schema.Struct<{
|
|
|
94
100
|
export type ZeroError = typeof ZeroError.Type;
|
|
95
101
|
export declare const MutationResult: Schema.Union<[Schema.Union<[Schema.Struct<{
|
|
96
102
|
error: Schema.Literal<["app"]>;
|
|
103
|
+
message: Schema.optional<typeof Schema.String>;
|
|
97
104
|
details: Schema.optional<typeof Schema.Unknown>;
|
|
98
105
|
}>, Schema.Struct<{
|
|
99
106
|
error: Schema.Union<[Schema.Literal<["oooMutation"]>, Schema.Literal<["alreadyProcessed"]>]>;
|
|
@@ -109,6 +116,7 @@ export declare const MutationResponse: Schema.Struct<{
|
|
|
109
116
|
}>;
|
|
110
117
|
result: Schema.Union<[Schema.Union<[Schema.Struct<{
|
|
111
118
|
error: Schema.Literal<["app"]>;
|
|
119
|
+
message: Schema.optional<typeof Schema.String>;
|
|
112
120
|
details: Schema.optional<typeof Schema.Unknown>;
|
|
113
121
|
}>, Schema.Struct<{
|
|
114
122
|
error: Schema.Union<[Schema.Literal<["oooMutation"]>, Schema.Literal<["alreadyProcessed"]>]>;
|
|
@@ -118,7 +126,7 @@ export declare const MutationResponse: Schema.Struct<{
|
|
|
118
126
|
}>]>;
|
|
119
127
|
}>;
|
|
120
128
|
export type MutationResponse = typeof MutationResponse.Type;
|
|
121
|
-
export declare const PushResponse: Schema.Union<[Schema.Struct<{
|
|
129
|
+
export declare const PushResponse: Schema.Union<[Schema.Union<[Schema.Struct<{
|
|
122
130
|
mutations: Schema.Array$<Schema.Struct<{
|
|
123
131
|
id: Schema.Struct<{
|
|
124
132
|
id: typeof Schema.Number;
|
|
@@ -126,6 +134,7 @@ export declare const PushResponse: Schema.Union<[Schema.Struct<{
|
|
|
126
134
|
}>;
|
|
127
135
|
result: Schema.Union<[Schema.Union<[Schema.Struct<{
|
|
128
136
|
error: Schema.Literal<["app"]>;
|
|
137
|
+
message: Schema.optional<typeof Schema.String>;
|
|
129
138
|
details: Schema.optional<typeof Schema.Unknown>;
|
|
130
139
|
}>, Schema.Struct<{
|
|
131
140
|
error: Schema.Union<[Schema.Literal<["oooMutation"]>, Schema.Literal<["alreadyProcessed"]>]>;
|
|
@@ -135,32 +144,75 @@ export declare const PushResponse: Schema.Union<[Schema.Struct<{
|
|
|
135
144
|
}>]>;
|
|
136
145
|
}>>;
|
|
137
146
|
}>, Schema.Union<[Schema.Struct<{
|
|
147
|
+
/** @deprecated */
|
|
138
148
|
error: Schema.Literal<["unsupportedPushVersion"]>;
|
|
149
|
+
/** @deprecated */
|
|
139
150
|
mutationIDs: Schema.optional<Schema.Array$<Schema.Struct<{
|
|
140
151
|
id: typeof Schema.Number;
|
|
141
152
|
clientID: typeof Schema.String;
|
|
142
153
|
}>>>;
|
|
143
154
|
}>, Schema.Struct<{
|
|
155
|
+
/** @deprecated */
|
|
144
156
|
error: Schema.Literal<["unsupportedSchemaVersion"]>;
|
|
157
|
+
/** @deprecated */
|
|
145
158
|
mutationIDs: Schema.optional<Schema.Array$<Schema.Struct<{
|
|
146
159
|
id: typeof Schema.Number;
|
|
147
160
|
clientID: typeof Schema.String;
|
|
148
161
|
}>>>;
|
|
149
162
|
}>, Schema.Struct<{
|
|
163
|
+
/** @deprecated */
|
|
150
164
|
error: Schema.Literal<["http"]>;
|
|
165
|
+
/** @deprecated */
|
|
151
166
|
status: typeof Schema.Number;
|
|
167
|
+
/** @deprecated */
|
|
152
168
|
details: typeof Schema.String;
|
|
169
|
+
/** @deprecated */
|
|
153
170
|
mutationIDs: Schema.optional<Schema.Array$<Schema.Struct<{
|
|
154
171
|
id: typeof Schema.Number;
|
|
155
172
|
clientID: typeof Schema.String;
|
|
156
173
|
}>>>;
|
|
157
174
|
}>, Schema.Struct<{
|
|
175
|
+
/** @deprecated */
|
|
158
176
|
error: Schema.Literal<["zeroPusher"]>;
|
|
177
|
+
/** @deprecated */
|
|
159
178
|
details: typeof Schema.String;
|
|
179
|
+
/** @deprecated */
|
|
160
180
|
mutationIDs: Schema.optional<Schema.Array$<Schema.Struct<{
|
|
161
181
|
id: typeof Schema.Number;
|
|
162
182
|
clientID: typeof Schema.String;
|
|
163
183
|
}>>>;
|
|
184
|
+
}>]>]>, Schema.Union<[Schema.Struct<{
|
|
185
|
+
origin: Schema.Literal<["server"]>;
|
|
186
|
+
reason: Schema.Literal<["database", "parse", "oooMutation", "unsupportedPushVersion", "internal"]>;
|
|
187
|
+
kind: Schema.Literal<["PushFailed"]>;
|
|
188
|
+
details: Schema.optional<typeof Schema.Unknown>;
|
|
189
|
+
mutationIDs: Schema.Array$<Schema.Struct<{
|
|
190
|
+
id: typeof Schema.Number;
|
|
191
|
+
clientID: typeof Schema.String;
|
|
192
|
+
}>>;
|
|
193
|
+
message: typeof Schema.String;
|
|
194
|
+
}>, Schema.Struct<{
|
|
195
|
+
origin: Schema.Literal<["zeroCache"]>;
|
|
196
|
+
reason: Schema.Literal<["http"]>;
|
|
197
|
+
status: typeof Schema.Number;
|
|
198
|
+
bodyPreview: Schema.optional<typeof Schema.String>;
|
|
199
|
+
kind: Schema.Literal<["PushFailed"]>;
|
|
200
|
+
details: Schema.optional<typeof Schema.Unknown>;
|
|
201
|
+
mutationIDs: Schema.Array$<Schema.Struct<{
|
|
202
|
+
id: typeof Schema.Number;
|
|
203
|
+
clientID: typeof Schema.String;
|
|
204
|
+
}>>;
|
|
205
|
+
message: typeof Schema.String;
|
|
206
|
+
}>, Schema.Struct<{
|
|
207
|
+
origin: Schema.Literal<["zeroCache"]>;
|
|
208
|
+
reason: Schema.Literal<["timeout", "parse", "internal"]>;
|
|
209
|
+
kind: Schema.Literal<["PushFailed"]>;
|
|
210
|
+
details: Schema.optional<typeof Schema.Unknown>;
|
|
211
|
+
mutationIDs: Schema.Array$<Schema.Struct<{
|
|
212
|
+
id: typeof Schema.Number;
|
|
213
|
+
clientID: typeof Schema.String;
|
|
214
|
+
}>>;
|
|
215
|
+
message: typeof Schema.String;
|
|
164
216
|
}>]>]>;
|
|
165
217
|
export type PushResponse = typeof PushResponse.Type;
|
|
166
218
|
/**
|
package/dist/types/push.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"push.d.ts","sourceRoot":"","sources":["../../src/types/push.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"push.d.ts","sourceRoot":"","sources":["../../src/types/push.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAiHxC,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAA6C,CAAC;AACnE,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC,IAAI,CAAC;AAE5C,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAUnB;;;OAGG;;EAEH,CAAC;AACH,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC,IAAI,CAAC;AAU5C,eAAO,MAAM,QAAQ;;;;EAKnB,CAAC;AAEH,MAAM,MAAM,QAAQ,GAAG,OAAO,QAAQ,CAAC,IAAI,CAAC;AAE5C,eAAO,MAAM,SAAS;;;EAOpB,CAAC;AAEH,MAAM,MAAM,SAAS,GAAG,OAAO,SAAS,CAAC,IAAI,CAAC;AAS9C,eAAO,MAAM,cAAc;;;;;;;;;IAI1B,CAAC;AACF,MAAM,MAAM,cAAc,GAAG,OAAO,cAAc,CAAC,IAAI,CAAC;AAExD,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;EAG3B,CAAC;AACH,MAAM,MAAM,gBAAgB,GAAG,OAAO,gBAAgB,CAAC,IAAI,CAAC;AA2D5D,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;IAjDvB,kBAAkB;;IAElB,kBAAkB;;;;;;IAQlB,kBAAkB;;IAElB,kBAAkB;;;;;;IAQlB,kBAAkB;;IAElB,kBAAkB;;IAElB,kBAAkB;;IAElB,kBAAkB;;;;;;IAQlB,kBAAkB;;IAElB,kBAAkB;;IAElB,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MAWsD,CAAC;AAC3E,MAAM,MAAM,YAAY,GAAG,OAAO,YAAY,CAAC,IAAI,CAAC;AAQpD;;GAEG;AACH,eAAO,MAAM,UAAU;;;EAGrB,CAAC;AACH,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAC,IAAI,CAAC"}
|
package/dist/types/push.js
CHANGED
|
@@ -1,13 +1,37 @@
|
|
|
1
1
|
import * as Schema from "effect/Schema";
|
|
2
2
|
import { JsonSchema } from "./common.js";
|
|
3
|
+
import { PushFailedBody } from "./error.js";
|
|
3
4
|
// The code below was converted to Effect Schema from:
|
|
4
|
-
// https://github.com/rocicorp/mono/blob/
|
|
5
|
+
// https://github.com/rocicorp/mono/blob/8e0f600fb3a9185facf60cfd4971d260b266690e/packages/zero-protocol/src/push.ts
|
|
5
6
|
const PrimaryKey = Schema.Array(Schema.String);
|
|
6
7
|
const PrimaryKeyValue = Schema.Union(Schema.String, Schema.Number, Schema.Boolean);
|
|
7
8
|
const PrimaryKeyValueRecord = Schema.Record({ key: Schema.String, value: PrimaryKeyValue });
|
|
8
9
|
const Value = Schema.Union(JsonSchema, Schema.Undefined);
|
|
9
10
|
const Row = Schema.Record({ key: Schema.String, value: Value });
|
|
10
11
|
const CRUD_MUTATION_NAME = "_zero_crud";
|
|
12
|
+
// biome-ignore lint/correctness/noUnusedVariables: borrowed code
|
|
13
|
+
const CLEANUP_RESULTS_MUTATION_NAME = "_zero_cleanupResults";
|
|
14
|
+
// biome-ignore lint/correctness/noUnusedVariables: borrowed code
|
|
15
|
+
const CleanupResultsArg = Schema.Union(
|
|
16
|
+
// Legacy format (no type field) - treat as single
|
|
17
|
+
Schema.Struct({
|
|
18
|
+
clientGroupID: Schema.String,
|
|
19
|
+
clientID: Schema.String,
|
|
20
|
+
upToMutationID: Schema.Number,
|
|
21
|
+
}),
|
|
22
|
+
// Explicit single: delete up to a specific mutation ID for one client
|
|
23
|
+
Schema.Struct({
|
|
24
|
+
type: Schema.Literal("single"),
|
|
25
|
+
clientGroupID: Schema.String,
|
|
26
|
+
clientID: Schema.String,
|
|
27
|
+
upToMutationID: Schema.Number,
|
|
28
|
+
}),
|
|
29
|
+
// Bulk: delete all mutations for multiple clients
|
|
30
|
+
Schema.Struct({
|
|
31
|
+
type: Schema.Literal("bulk"),
|
|
32
|
+
clientGroupID: Schema.String,
|
|
33
|
+
clientIDs: Schema.NonEmptyArray(Schema.String),
|
|
34
|
+
}));
|
|
11
35
|
/**
|
|
12
36
|
* Inserts if entity with id does not already exist.
|
|
13
37
|
*/
|
|
@@ -79,6 +103,11 @@ export const PushBody = Schema.Struct({
|
|
|
79
103
|
schemaVersion: Schema.optional(Schema.Number),
|
|
80
104
|
timestamp: Schema.Number,
|
|
81
105
|
requestID: Schema.String,
|
|
106
|
+
/**
|
|
107
|
+
* @deprecated auth is managed at client-group scope via connect/updateAuth
|
|
108
|
+
* and should not be included in push messages.
|
|
109
|
+
*/
|
|
110
|
+
auth: Schema.optional(Schema.String),
|
|
82
111
|
});
|
|
83
112
|
// biome-ignore lint/correctness/noUnusedVariables: borrowed code
|
|
84
113
|
const PushMessage = Schema.Tuple(Schema.Literal("push"), PushBody);
|
|
@@ -89,10 +118,13 @@ const MutationId = Schema.Struct({
|
|
|
89
118
|
export const AppError = Schema.Struct({
|
|
90
119
|
error: Schema.Literal("app"),
|
|
91
120
|
// The user can return any additional data here
|
|
121
|
+
message: Schema.optional(Schema.String),
|
|
92
122
|
details: Schema.optional(JsonSchema),
|
|
93
123
|
});
|
|
94
124
|
export const ZeroError = Schema.Struct({
|
|
95
|
-
error: Schema.Union(
|
|
125
|
+
error: Schema.Union(
|
|
126
|
+
/** @deprecated push oooMutation errors are now represented as ['error', { ... }] messages */
|
|
127
|
+
Schema.Literal("oooMutation"), Schema.Literal("alreadyProcessed")),
|
|
96
128
|
details: Schema.optional(JsonSchema),
|
|
97
129
|
});
|
|
98
130
|
const MutationOk = Schema.Struct({
|
|
@@ -110,35 +142,56 @@ export const MutationResponse = Schema.Struct({
|
|
|
110
142
|
const PushOk = Schema.Struct({
|
|
111
143
|
mutations: Schema.Array(MutationResponse),
|
|
112
144
|
});
|
|
145
|
+
/**
|
|
146
|
+
* @deprecated push errors are now represented as ['error', { ... }] messages
|
|
147
|
+
*/
|
|
113
148
|
const UnsupportedPushVersion = Schema.Struct({
|
|
149
|
+
/** @deprecated */
|
|
114
150
|
error: Schema.Literal("unsupportedPushVersion"),
|
|
115
|
-
|
|
116
|
-
// This field is included so the client knows which mutations
|
|
117
|
-
// were not processed by the server.
|
|
151
|
+
/** @deprecated */
|
|
118
152
|
mutationIDs: Schema.optional(Schema.Array(MutationId)),
|
|
119
153
|
});
|
|
154
|
+
/**
|
|
155
|
+
* @deprecated push errors are now represented as ['error', { ... }] messages
|
|
156
|
+
*/
|
|
120
157
|
const UnsupportedSchemaVersion = Schema.Struct({
|
|
158
|
+
/** @deprecated */
|
|
121
159
|
error: Schema.Literal("unsupportedSchemaVersion"),
|
|
122
|
-
|
|
123
|
-
// This field is included so the client knows which mutations
|
|
124
|
-
// were not processed by the server.
|
|
160
|
+
/** @deprecated */
|
|
125
161
|
mutationIDs: Schema.optional(Schema.Array(MutationId)),
|
|
126
162
|
});
|
|
163
|
+
/**
|
|
164
|
+
* @deprecated push http errors are now represented as ['error', { ... }] messages
|
|
165
|
+
*/
|
|
127
166
|
const HttpError = Schema.Struct({
|
|
167
|
+
/** @deprecated */
|
|
128
168
|
error: Schema.Literal("http"),
|
|
169
|
+
/** @deprecated */
|
|
129
170
|
status: Schema.Number,
|
|
171
|
+
/** @deprecated */
|
|
130
172
|
details: Schema.String,
|
|
173
|
+
/** @deprecated */
|
|
131
174
|
mutationIDs: Schema.optional(Schema.Array(MutationId)),
|
|
132
175
|
});
|
|
176
|
+
/**
|
|
177
|
+
* @deprecated push zero errors are now represented as ['error', { ... }] messages
|
|
178
|
+
*/
|
|
133
179
|
const ZeroPusherError = Schema.Struct({
|
|
180
|
+
/** @deprecated */
|
|
134
181
|
error: Schema.Literal("zeroPusher"),
|
|
182
|
+
/** @deprecated */
|
|
135
183
|
details: Schema.String,
|
|
184
|
+
/** @deprecated */
|
|
136
185
|
mutationIDs: Schema.optional(Schema.Array(MutationId)),
|
|
137
186
|
});
|
|
187
|
+
/**
|
|
188
|
+
* @deprecated push errors are now represented as ['error', { ... }] messages
|
|
189
|
+
*/
|
|
138
190
|
const PushError = Schema.Union(UnsupportedPushVersion, UnsupportedSchemaVersion, HttpError, ZeroPusherError);
|
|
139
|
-
|
|
191
|
+
const PushResponseBody = Schema.Union(PushOk, PushError);
|
|
192
|
+
export const PushResponse = Schema.Union(PushResponseBody, PushFailedBody);
|
|
140
193
|
// biome-ignore lint/correctness/noUnusedVariables: borrowed code
|
|
141
|
-
const PushResponseMessage = Schema.Tuple(Schema.Literal("pushResponse"),
|
|
194
|
+
const PushResponseMessage = Schema.Tuple(Schema.Literal("pushResponse"), PushResponseBody);
|
|
142
195
|
// biome-ignore lint/correctness/noUnusedVariables: borrowed code
|
|
143
196
|
const AckMutationResponsesMessage = Schema.Tuple(Schema.Literal("ackMutationResponses"), MutationId);
|
|
144
197
|
/**
|
package/dist/types/push.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"push.js","sourceRoot":"","sources":["../../src/types/push.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version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|
7
7
|
export type TransformRequestMessage = typeof TransformRequestMessage.Type;
|
|
8
|
-
export declare const TransformResponseMessage: Schema.Tuple2<Schema.Literal<["transformed"]>, Schema.Array$<Schema.Union<[Schema.Struct<{
|
|
8
|
+
export declare const TransformResponseMessage: Schema.Union<[Schema.Tuple2<Schema.Literal<["transformed"]>, Schema.Array$<Schema.Union<[Schema.Struct<{
|
|
9
9
|
id: typeof Schema.String;
|
|
10
10
|
name: typeof Schema.String;
|
|
11
11
|
ast: typeof Schema.Unknown;
|
|
@@ -13,17 +13,36 @@ export declare const TransformResponseMessage: Schema.Tuple2<Schema.Literal<["tr
|
|
|
13
13
|
error: Schema.Literal<["app"]>;
|
|
14
14
|
id: typeof Schema.String;
|
|
15
15
|
name: typeof Schema.String;
|
|
16
|
-
|
|
16
|
+
message: Schema.optional<typeof Schema.String>;
|
|
17
|
+
details: Schema.optional<typeof Schema.Unknown>;
|
|
17
18
|
}>, Schema.Struct<{
|
|
18
|
-
error: Schema.Literal<["
|
|
19
|
+
error: Schema.Literal<["parse"]>;
|
|
19
20
|
id: typeof Schema.String;
|
|
20
21
|
name: typeof Schema.String;
|
|
22
|
+
message: typeof Schema.String;
|
|
23
|
+
details: Schema.optional<typeof Schema.Unknown>;
|
|
24
|
+
}>]>]>>>, Schema.Tuple2<Schema.Literal<["transformFailed"]>, Schema.Union<[Schema.Struct<{
|
|
25
|
+
origin: Schema.Literal<["server"]>;
|
|
26
|
+
reason: Schema.Literal<["database", "parse", "internal"]>;
|
|
27
|
+
kind: Schema.Literal<["TransformFailed"]>;
|
|
28
|
+
details: Schema.optional<typeof Schema.Unknown>;
|
|
29
|
+
queryIDs: Schema.Array$<typeof Schema.String>;
|
|
30
|
+
message: typeof Schema.String;
|
|
31
|
+
}>, Schema.Struct<{
|
|
32
|
+
origin: Schema.Literal<["zeroCache"]>;
|
|
33
|
+
reason: Schema.Literal<["http"]>;
|
|
21
34
|
status: typeof Schema.Number;
|
|
22
|
-
|
|
35
|
+
bodyPreview: Schema.optional<typeof Schema.String>;
|
|
36
|
+
kind: Schema.Literal<["TransformFailed"]>;
|
|
37
|
+
details: Schema.optional<typeof Schema.Unknown>;
|
|
38
|
+
queryIDs: Schema.Array$<typeof Schema.String>;
|
|
39
|
+
message: typeof Schema.String;
|
|
23
40
|
}>, Schema.Struct<{
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
details: typeof Schema.Unknown
|
|
28
|
-
|
|
41
|
+
origin: Schema.Literal<["zeroCache"]>;
|
|
42
|
+
reason: Schema.Literal<["timeout", "parse", "internal"]>;
|
|
43
|
+
kind: Schema.Literal<["TransformFailed"]>;
|
|
44
|
+
details: Schema.optional<typeof Schema.Unknown>;
|
|
45
|
+
queryIDs: Schema.Array$<typeof Schema.String>;
|
|
46
|
+
message: typeof Schema.String;
|
|
47
|
+
}>]>>]>;
|
|
29
48
|
//# sourceMappingURL=queries.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../src/types/queries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../src/types/queries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AA6CxC,eAAO,MAAM,uBAAuB;;;;IAAkE,CAAC;AACvG,MAAM,MAAM,uBAAuB,GAAG,OAAO,uBAAuB,CAAC,IAAI,CAAC;AAS1E,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAA2D,CAAC"}
|
package/dist/types/queries.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import * as Schema from "effect/Schema";
|
|
2
2
|
import { JsonSchema } from "./common.js";
|
|
3
|
+
import { TransformFailedBody } from "./error.js";
|
|
3
4
|
// The code below was converted to Effect Schema from:
|
|
4
|
-
// https://github.com/rocicorp/mono/blob/
|
|
5
|
+
// https://github.com/rocicorp/mono/blob/8e0f600fb3a9185facf60cfd4971d260b266690e/packages/zero-protocol/src/custom-queries.ts
|
|
5
6
|
/** TODO: Defined as unknown for now */
|
|
6
7
|
const Ast = Schema.Unknown;
|
|
7
8
|
const TransformRequestBody = Schema.Array(Schema.Struct({
|
|
@@ -14,29 +15,27 @@ const TransformedQuery = Schema.Struct({
|
|
|
14
15
|
name: Schema.String,
|
|
15
16
|
ast: Ast,
|
|
16
17
|
});
|
|
17
|
-
const
|
|
18
|
+
const AppErroredQuery = Schema.Struct({
|
|
18
19
|
error: Schema.Literal("app"),
|
|
19
20
|
id: Schema.String,
|
|
20
21
|
name: Schema.String,
|
|
21
|
-
|
|
22
|
+
// optional for backwards compatibility
|
|
23
|
+
message: Schema.optional(Schema.String),
|
|
24
|
+
details: Schema.optional(JsonSchema),
|
|
22
25
|
});
|
|
23
|
-
const
|
|
24
|
-
error: Schema.Literal("
|
|
26
|
+
const ParseErroredQuery = Schema.Struct({
|
|
27
|
+
error: Schema.Literal("parse"),
|
|
25
28
|
id: Schema.String,
|
|
26
29
|
name: Schema.String,
|
|
27
|
-
|
|
30
|
+
message: Schema.String,
|
|
31
|
+
details: Schema.optional(JsonSchema),
|
|
28
32
|
});
|
|
29
|
-
const
|
|
30
|
-
error: Schema.Literal("http"),
|
|
31
|
-
id: Schema.String,
|
|
32
|
-
name: Schema.String,
|
|
33
|
-
status: Schema.Number,
|
|
34
|
-
details: JsonSchema,
|
|
35
|
-
});
|
|
36
|
-
const ErroredQuery = Schema.Union(AppQueryError, HttpQueryError, ErrorSchema);
|
|
33
|
+
const ErroredQuery = Schema.Union(AppErroredQuery, ParseErroredQuery);
|
|
37
34
|
const TransformResponseBody = Schema.Array(Schema.Union(TransformedQuery, ErroredQuery));
|
|
38
35
|
export const TransformRequestMessage = Schema.Tuple(Schema.Literal("transform"), TransformRequestBody);
|
|
39
36
|
// biome-ignore lint/correctness/noUnusedVariables: borrowed code
|
|
40
37
|
const TransformErrorMessage = Schema.Tuple(Schema.Literal("transformError"), Schema.Array(ErroredQuery));
|
|
41
|
-
|
|
38
|
+
const TransformFailedMessage = Schema.Tuple(Schema.Literal("transformFailed"), TransformFailedBody);
|
|
39
|
+
const TransformOkMessage = Schema.Tuple(Schema.Literal("transformed"), TransformResponseBody);
|
|
40
|
+
export const TransformResponseMessage = Schema.Union(TransformOkMessage, TransformFailedMessage);
|
|
42
41
|
//# sourceMappingURL=queries.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"queries.js","sourceRoot":"","sources":["../../src/types/queries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"queries.js","sourceRoot":"","sources":["../../src/types/queries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD,sDAAsD;AACtD,8HAA8H;AAE9H,uCAAuC;AACvC,MAAM,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC;AAE3B,MAAM,oBAAoB,GAAG,MAAM,CAAC,KAAK,CACvC,MAAM,CAAC,MAAM,CAAC;IACZ,EAAE,EAAE,MAAM,CAAC,MAAM;IACjB,IAAI,EAAE,MAAM,CAAC,MAAM;IACnB,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC;CAC/B,CAAC,CACH,CAAC;AAEF,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC;IACrC,EAAE,EAAE,MAAM,CAAC,MAAM;IACjB,IAAI,EAAE,MAAM,CAAC,MAAM;IACnB,GAAG,EAAE,GAAG;CACT,CAAC,CAAC;AAEH,MAAM,eAAe,GAAG,MAAM,CAAC,MAA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,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,qBAAqB,CAAC,CAAC;AAE9F,MAAM,CAAC,MAAM,wBAAwB,GAAG,MAAM,CAAC,KAAK,CAAC,kBAAkB,EAAE,sBAAsB,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "effect-zero",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.4.
|
|
4
|
+
"version": "0.4.1",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
7
7
|
"url": "https://github.com/realms-labs/effect-zero"
|
|
@@ -94,6 +94,12 @@
|
|
|
94
94
|
"default": "./dist/types/queries.js"
|
|
95
95
|
}
|
|
96
96
|
},
|
|
97
|
+
"./types/error": {
|
|
98
|
+
"import": {
|
|
99
|
+
"types": "./dist/types/error.d.ts",
|
|
100
|
+
"default": "./dist/types/error.js"
|
|
101
|
+
}
|
|
102
|
+
},
|
|
97
103
|
"./types/common": {
|
|
98
104
|
"import": {
|
|
99
105
|
"types": "./dist/types/common.d.ts",
|
package/src/query.ts
CHANGED
|
@@ -91,11 +91,20 @@ export const stream = <T extends keyof S["tables"] & string, S extends ZeroSchem
|
|
|
91
91
|
return Stream.asyncEffect<Parameters<Parameters<(typeof view)["addListener"]>[0]>>((emit) =>
|
|
92
92
|
Effect.sync(() => view.addListener((...args) => emit.single(args))),
|
|
93
93
|
).pipe(
|
|
94
|
-
Stream.mapEffect(([data, resultType]) =>
|
|
94
|
+
Stream.mapEffect(([data, resultType, error]) =>
|
|
95
95
|
Effect.sync(() => {
|
|
96
|
-
// logic here borrowed from: https://github.com/rocicorp/mono/blob/
|
|
96
|
+
// logic here borrowed from: https://github.com/rocicorp/mono/blob/8e0f600fb3a9185facf60cfd4971d260b266690e/packages/zero-react/src/use-query.tsx#L543
|
|
97
97
|
const cloned = data === undefined ? data : (deepClone(data as ReadonlyJSONValue) as HumanReadable<R>);
|
|
98
|
-
return getSnapshot<R>(
|
|
98
|
+
return getSnapshot<R>(
|
|
99
|
+
asQueryInternals(query).format.singular,
|
|
100
|
+
cloned,
|
|
101
|
+
resultType,
|
|
102
|
+
// TODO: Look into this. It seems like this is difficult but not impossible to model in the Effect paradigm.
|
|
103
|
+
// Likely need some kind of stateful piece between the publisher and and subscriber, allowing the subscriber to swap out
|
|
104
|
+
// the publisher when this function is called.
|
|
105
|
+
() => Effect.dieMessage("retry not available in `effect-zero`"),
|
|
106
|
+
error,
|
|
107
|
+
);
|
|
99
108
|
}),
|
|
100
109
|
),
|
|
101
110
|
Stream.map(QueryResult.make),
|
package/src/snapshot.ts
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
1
|
// Code borrowed from:
|
|
2
|
-
// https://github.com/rocicorp/mono/blob/
|
|
3
|
-
// https://github.com/rocicorp/mono/blob/
|
|
2
|
+
// https://github.com/rocicorp/mono/blob/8e0f600fb3a9185facf60cfd4971d260b266690e/packages/zero-react/src/use-query.tsx
|
|
3
|
+
// https://github.com/rocicorp/mono/blob/8e0f600fb3a9185facf60cfd4971d260b266690e/packages/shared/src/deep-clone.ts
|
|
4
4
|
|
|
5
|
-
import type { HumanReadable, JSONValue, ReadonlyJSONValue } from "@rocicorp/zero";
|
|
5
|
+
import type { ErroredQuery, HumanReadable, JSONValue, QueryErrorDetails, ReadonlyJSONValue, ResultType } from "@rocicorp/zero";
|
|
6
6
|
import type { QueryResult } from "@rocicorp/zero/react";
|
|
7
7
|
|
|
8
8
|
const emptyArray: unknown[] = [];
|
|
9
9
|
|
|
10
10
|
const resultTypeUnknown = { type: "unknown" } as const;
|
|
11
11
|
const resultTypeComplete = { type: "complete" } as const;
|
|
12
|
+
const resultTypeError = {type: 'error'} as const;
|
|
12
13
|
|
|
13
14
|
const emptySnapshotSingularUnknown = [undefined, resultTypeUnknown] as const;
|
|
14
15
|
const emptySnapshotSingularComplete = [undefined, resultTypeComplete] as const;
|
|
16
|
+
const emptySnapshotSingularErrorUnknown = [undefined, resultTypeError] as const;
|
|
15
17
|
const emptySnapshotPluralUnknown = [emptyArray, resultTypeUnknown] as const;
|
|
16
18
|
const emptySnapshotPluralComplete = [emptyArray, resultTypeComplete] as const;
|
|
19
|
+
const emptySnapshotErrorUnknown = [emptyArray, resultTypeError] as const;
|
|
17
20
|
|
|
18
21
|
export function getDefaultSnapshot<TReturn>(singular: boolean): QueryResult<TReturn> {
|
|
19
22
|
return (singular ? emptySnapshotSingularUnknown : emptySnapshotPluralUnknown) as QueryResult<TReturn>;
|
|
@@ -26,21 +29,77 @@ export function getDefaultSnapshot<TReturn>(singular: boolean): QueryResult<TRet
|
|
|
26
29
|
export function getSnapshot<TReturn>(
|
|
27
30
|
singular: boolean,
|
|
28
31
|
data: HumanReadable<TReturn>,
|
|
29
|
-
resultType:
|
|
32
|
+
resultType: ResultType,
|
|
33
|
+
retryFn: () => void,
|
|
34
|
+
error?: ErroredQuery,
|
|
30
35
|
): QueryResult<TReturn> {
|
|
31
36
|
if (singular && data === undefined) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
37
|
+
switch (resultType) {
|
|
38
|
+
case 'error':
|
|
39
|
+
if (error) {
|
|
40
|
+
return [
|
|
41
|
+
undefined,
|
|
42
|
+
makeError(retryFn, error),
|
|
43
|
+
] as unknown as QueryResult<TReturn>;
|
|
44
|
+
}
|
|
45
|
+
return emptySnapshotSingularErrorUnknown as unknown as QueryResult<TReturn>;
|
|
46
|
+
case 'complete':
|
|
47
|
+
return emptySnapshotSingularComplete as unknown as QueryResult<TReturn>;
|
|
48
|
+
case 'unknown':
|
|
49
|
+
return emptySnapshotSingularUnknown as unknown as QueryResult<TReturn>;
|
|
50
|
+
}
|
|
35
51
|
}
|
|
36
52
|
|
|
37
53
|
if (!singular && (data as unknown[]).length === 0) {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
54
|
+
switch (resultType) {
|
|
55
|
+
case 'error':
|
|
56
|
+
if (error) {
|
|
57
|
+
return [
|
|
58
|
+
emptyArray,
|
|
59
|
+
makeError(retryFn, error),
|
|
60
|
+
] as unknown as QueryResult<TReturn>;
|
|
61
|
+
}
|
|
62
|
+
return emptySnapshotErrorUnknown as unknown as QueryResult<TReturn>;
|
|
63
|
+
case 'complete':
|
|
64
|
+
return emptySnapshotPluralComplete as unknown as QueryResult<TReturn>;
|
|
65
|
+
case 'unknown':
|
|
66
|
+
return emptySnapshotPluralUnknown as unknown as QueryResult<TReturn>;
|
|
67
|
+
}
|
|
41
68
|
}
|
|
42
69
|
|
|
43
|
-
|
|
70
|
+
switch (resultType) {
|
|
71
|
+
case 'error':
|
|
72
|
+
if (error) {
|
|
73
|
+
return [data, makeError(retryFn, error)];
|
|
74
|
+
}
|
|
75
|
+
return [
|
|
76
|
+
data,
|
|
77
|
+
makeError(retryFn, {
|
|
78
|
+
error: 'app',
|
|
79
|
+
id: 'unknown',
|
|
80
|
+
name: 'unknown',
|
|
81
|
+
message: 'An unknown error occurred',
|
|
82
|
+
}),
|
|
83
|
+
];
|
|
84
|
+
case 'complete':
|
|
85
|
+
return [data, resultTypeComplete];
|
|
86
|
+
case 'unknown':
|
|
87
|
+
return [data, resultTypeUnknown];
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function makeError(retry: () => void, error: ErroredQuery): QueryErrorDetails {
|
|
92
|
+
const message = error.message ?? 'An unknown error occurred';
|
|
93
|
+
return {
|
|
94
|
+
type: 'error',
|
|
95
|
+
retry,
|
|
96
|
+
refetch: retry,
|
|
97
|
+
error: {
|
|
98
|
+
type: error.error,
|
|
99
|
+
message,
|
|
100
|
+
...(error.details ? {details: error.details} : {}),
|
|
101
|
+
},
|
|
102
|
+
};
|
|
44
103
|
}
|
|
45
104
|
|
|
46
105
|
export function deepClone(value: ReadonlyJSONValue): JSONValue {
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import * as Schema from "effect/Schema";
|
|
2
|
+
import { JsonSchema } from "./common.js";
|
|
3
|
+
|
|
4
|
+
// The code below was converted to Effect Schema from:
|
|
5
|
+
// https://github.com/rocicorp/mono/blob/8e0f600fb3a9185facf60cfd4971d260b266690e/packages/zero-protocol/src/error.ts
|
|
6
|
+
|
|
7
|
+
const MutationId = Schema.Struct({
|
|
8
|
+
id: Schema.Number,
|
|
9
|
+
clientID: Schema.String,
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
const PushFailedBase = Schema.Struct({
|
|
13
|
+
kind: Schema.Literal("PushFailed"),
|
|
14
|
+
details: Schema.optional(JsonSchema),
|
|
15
|
+
/**
|
|
16
|
+
* The mutationIDs of the mutations that failed to process.
|
|
17
|
+
* This can be a subset of the mutationIDs in the request.
|
|
18
|
+
*/
|
|
19
|
+
mutationIDs: Schema.Array(MutationId),
|
|
20
|
+
message: Schema.String,
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
export const PushFailedBody = Schema.Union(
|
|
24
|
+
Schema.Struct({
|
|
25
|
+
...PushFailedBase.fields,
|
|
26
|
+
origin: Schema.Literal("server"),
|
|
27
|
+
reason: Schema.Literal("database", "parse", "oooMutation", "unsupportedPushVersion", "internal"),
|
|
28
|
+
}),
|
|
29
|
+
Schema.Struct({
|
|
30
|
+
...PushFailedBase.fields,
|
|
31
|
+
origin: Schema.Literal("zeroCache"),
|
|
32
|
+
reason: Schema.Literal("http"),
|
|
33
|
+
status: Schema.Number,
|
|
34
|
+
bodyPreview: Schema.optional(Schema.String),
|
|
35
|
+
}),
|
|
36
|
+
Schema.Struct({
|
|
37
|
+
...PushFailedBase.fields,
|
|
38
|
+
origin: Schema.Literal("zeroCache"),
|
|
39
|
+
reason: Schema.Literal("timeout", "parse", "internal"),
|
|
40
|
+
}),
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
const TransformFailedBase = Schema.Struct({
|
|
44
|
+
kind: Schema.Literal("TransformFailed"),
|
|
45
|
+
details: Schema.optional(JsonSchema),
|
|
46
|
+
/**
|
|
47
|
+
* The queryIDs of the queries that failed to transform.
|
|
48
|
+
*/
|
|
49
|
+
queryIDs: Schema.Array(Schema.String),
|
|
50
|
+
message: Schema.String,
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
export const TransformFailedBody = Schema.Union(
|
|
54
|
+
Schema.Struct({
|
|
55
|
+
...TransformFailedBase.fields,
|
|
56
|
+
origin: Schema.Literal("server"),
|
|
57
|
+
reason: Schema.Literal("database", "parse", "internal"),
|
|
58
|
+
}),
|
|
59
|
+
Schema.Struct({
|
|
60
|
+
...TransformFailedBase.fields,
|
|
61
|
+
origin: Schema.Literal("zeroCache"),
|
|
62
|
+
reason: Schema.Literal("http"),
|
|
63
|
+
status: Schema.Number,
|
|
64
|
+
bodyPreview: Schema.optional(Schema.String),
|
|
65
|
+
}),
|
|
66
|
+
Schema.Struct({
|
|
67
|
+
...TransformFailedBase.fields,
|
|
68
|
+
origin: Schema.Literal("zeroCache"),
|
|
69
|
+
reason: Schema.Literal("timeout", "parse", "internal"),
|
|
70
|
+
}),
|
|
71
|
+
);
|
package/src/types/push.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as Schema from "effect/Schema";
|
|
2
2
|
import { JsonSchema } from "./common.js";
|
|
3
|
+
import { PushFailedBody } from "./error.js";
|
|
3
4
|
|
|
4
5
|
// The code below was converted to Effect Schema from:
|
|
5
|
-
// https://github.com/rocicorp/mono/blob/
|
|
6
|
+
// https://github.com/rocicorp/mono/blob/8e0f600fb3a9185facf60cfd4971d260b266690e/packages/zero-protocol/src/push.ts
|
|
6
7
|
|
|
7
8
|
const PrimaryKey = Schema.Array(Schema.String);
|
|
8
9
|
|
|
@@ -15,6 +16,32 @@ const Row = Schema.Record({ key: Schema.String, value: Value });
|
|
|
15
16
|
|
|
16
17
|
const CRUD_MUTATION_NAME = "_zero_crud";
|
|
17
18
|
|
|
19
|
+
// biome-ignore lint/correctness/noUnusedVariables: borrowed code
|
|
20
|
+
const CLEANUP_RESULTS_MUTATION_NAME = "_zero_cleanupResults";
|
|
21
|
+
|
|
22
|
+
// biome-ignore lint/correctness/noUnusedVariables: borrowed code
|
|
23
|
+
const CleanupResultsArg = Schema.Union(
|
|
24
|
+
// Legacy format (no type field) - treat as single
|
|
25
|
+
Schema.Struct({
|
|
26
|
+
clientGroupID: Schema.String,
|
|
27
|
+
clientID: Schema.String,
|
|
28
|
+
upToMutationID: Schema.Number,
|
|
29
|
+
}),
|
|
30
|
+
// Explicit single: delete up to a specific mutation ID for one client
|
|
31
|
+
Schema.Struct({
|
|
32
|
+
type: Schema.Literal("single"),
|
|
33
|
+
clientGroupID: Schema.String,
|
|
34
|
+
clientID: Schema.String,
|
|
35
|
+
upToMutationID: Schema.Number,
|
|
36
|
+
}),
|
|
37
|
+
// Bulk: delete all mutations for multiple clients
|
|
38
|
+
Schema.Struct({
|
|
39
|
+
type: Schema.Literal("bulk"),
|
|
40
|
+
clientGroupID: Schema.String,
|
|
41
|
+
clientIDs: Schema.NonEmptyArray(Schema.String),
|
|
42
|
+
}),
|
|
43
|
+
);
|
|
44
|
+
|
|
18
45
|
/**
|
|
19
46
|
* Inserts if entity with id does not already exist.
|
|
20
47
|
*/
|
|
@@ -97,6 +124,11 @@ export const PushBody = Schema.Struct({
|
|
|
97
124
|
schemaVersion: Schema.optional(Schema.Number),
|
|
98
125
|
timestamp: Schema.Number,
|
|
99
126
|
requestID: Schema.String,
|
|
127
|
+
/**
|
|
128
|
+
* @deprecated auth is managed at client-group scope via connect/updateAuth
|
|
129
|
+
* and should not be included in push messages.
|
|
130
|
+
*/
|
|
131
|
+
auth: Schema.optional(Schema.String),
|
|
100
132
|
});
|
|
101
133
|
export type PushBody = typeof PushBody.Type;
|
|
102
134
|
|
|
@@ -111,13 +143,18 @@ const MutationId = Schema.Struct({
|
|
|
111
143
|
export const AppError = Schema.Struct({
|
|
112
144
|
error: Schema.Literal("app"),
|
|
113
145
|
// The user can return any additional data here
|
|
146
|
+
message: Schema.optional(Schema.String),
|
|
114
147
|
details: Schema.optional(JsonSchema),
|
|
115
148
|
});
|
|
116
149
|
|
|
117
150
|
export type AppError = typeof AppError.Type;
|
|
118
151
|
|
|
119
152
|
export const ZeroError = Schema.Struct({
|
|
120
|
-
error: Schema.Union(
|
|
153
|
+
error: Schema.Union(
|
|
154
|
+
/** @deprecated push oooMutation errors are now represented as ['error', { ... }] messages */
|
|
155
|
+
Schema.Literal("oooMutation"),
|
|
156
|
+
Schema.Literal("alreadyProcessed"),
|
|
157
|
+
),
|
|
121
158
|
details: Schema.optional(JsonSchema),
|
|
122
159
|
});
|
|
123
160
|
|
|
@@ -147,42 +184,64 @@ const PushOk = Schema.Struct({
|
|
|
147
184
|
mutations: Schema.Array(MutationResponse),
|
|
148
185
|
});
|
|
149
186
|
|
|
187
|
+
/**
|
|
188
|
+
* @deprecated push errors are now represented as ['error', { ... }] messages
|
|
189
|
+
*/
|
|
150
190
|
const UnsupportedPushVersion = Schema.Struct({
|
|
191
|
+
/** @deprecated */
|
|
151
192
|
error: Schema.Literal("unsupportedPushVersion"),
|
|
152
|
-
|
|
153
|
-
// This field is included so the client knows which mutations
|
|
154
|
-
// were not processed by the server.
|
|
193
|
+
/** @deprecated */
|
|
155
194
|
mutationIDs: Schema.optional(Schema.Array(MutationId)),
|
|
156
195
|
});
|
|
157
196
|
|
|
197
|
+
/**
|
|
198
|
+
* @deprecated push errors are now represented as ['error', { ... }] messages
|
|
199
|
+
*/
|
|
158
200
|
const UnsupportedSchemaVersion = Schema.Struct({
|
|
201
|
+
/** @deprecated */
|
|
159
202
|
error: Schema.Literal("unsupportedSchemaVersion"),
|
|
160
|
-
|
|
161
|
-
// This field is included so the client knows which mutations
|
|
162
|
-
// were not processed by the server.
|
|
203
|
+
/** @deprecated */
|
|
163
204
|
mutationIDs: Schema.optional(Schema.Array(MutationId)),
|
|
164
205
|
});
|
|
165
206
|
|
|
207
|
+
/**
|
|
208
|
+
* @deprecated push http errors are now represented as ['error', { ... }] messages
|
|
209
|
+
*/
|
|
166
210
|
const HttpError = Schema.Struct({
|
|
211
|
+
/** @deprecated */
|
|
167
212
|
error: Schema.Literal("http"),
|
|
213
|
+
/** @deprecated */
|
|
168
214
|
status: Schema.Number,
|
|
215
|
+
/** @deprecated */
|
|
169
216
|
details: Schema.String,
|
|
217
|
+
/** @deprecated */
|
|
170
218
|
mutationIDs: Schema.optional(Schema.Array(MutationId)),
|
|
171
219
|
});
|
|
172
220
|
|
|
221
|
+
/**
|
|
222
|
+
* @deprecated push zero errors are now represented as ['error', { ... }] messages
|
|
223
|
+
*/
|
|
173
224
|
const ZeroPusherError = Schema.Struct({
|
|
225
|
+
/** @deprecated */
|
|
174
226
|
error: Schema.Literal("zeroPusher"),
|
|
227
|
+
/** @deprecated */
|
|
175
228
|
details: Schema.String,
|
|
229
|
+
/** @deprecated */
|
|
176
230
|
mutationIDs: Schema.optional(Schema.Array(MutationId)),
|
|
177
231
|
});
|
|
178
232
|
|
|
233
|
+
/**
|
|
234
|
+
* @deprecated push errors are now represented as ['error', { ... }] messages
|
|
235
|
+
*/
|
|
179
236
|
const PushError = Schema.Union(UnsupportedPushVersion, UnsupportedSchemaVersion, HttpError, ZeroPusherError);
|
|
180
237
|
|
|
181
|
-
|
|
238
|
+
const PushResponseBody = Schema.Union(PushOk, PushError);
|
|
239
|
+
|
|
240
|
+
export const PushResponse = Schema.Union(PushResponseBody, PushFailedBody);
|
|
182
241
|
export type PushResponse = typeof PushResponse.Type;
|
|
183
242
|
|
|
184
243
|
// biome-ignore lint/correctness/noUnusedVariables: borrowed code
|
|
185
|
-
const PushResponseMessage = Schema.Tuple(Schema.Literal("pushResponse"),
|
|
244
|
+
const PushResponseMessage = Schema.Tuple(Schema.Literal("pushResponse"), PushResponseBody);
|
|
186
245
|
|
|
187
246
|
// biome-ignore lint/correctness/noUnusedVariables: borrowed code
|
|
188
247
|
const AckMutationResponsesMessage = Schema.Tuple(Schema.Literal("ackMutationResponses"), MutationId);
|
package/src/types/queries.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import * as Schema from "effect/Schema";
|
|
2
2
|
import { JsonSchema } from "./common.js";
|
|
3
|
+
import { TransformFailedBody } from "./error.js";
|
|
3
4
|
|
|
4
5
|
// The code below was converted to Effect Schema from:
|
|
5
|
-
// https://github.com/rocicorp/mono/blob/
|
|
6
|
+
// https://github.com/rocicorp/mono/blob/8e0f600fb3a9185facf60cfd4971d260b266690e/packages/zero-protocol/src/custom-queries.ts
|
|
6
7
|
|
|
7
8
|
/** TODO: Defined as unknown for now */
|
|
8
9
|
const Ast = Schema.Unknown;
|
|
@@ -21,29 +22,24 @@ const TransformedQuery = Schema.Struct({
|
|
|
21
22
|
ast: Ast,
|
|
22
23
|
});
|
|
23
24
|
|
|
24
|
-
const
|
|
25
|
+
const AppErroredQuery = Schema.Struct({
|
|
25
26
|
error: Schema.Literal("app"),
|
|
26
27
|
id: Schema.String,
|
|
27
28
|
name: Schema.String,
|
|
28
|
-
|
|
29
|
+
// optional for backwards compatibility
|
|
30
|
+
message: Schema.optional(Schema.String),
|
|
31
|
+
details: Schema.optional(JsonSchema),
|
|
29
32
|
});
|
|
30
33
|
|
|
31
|
-
const
|
|
32
|
-
error: Schema.Literal("
|
|
34
|
+
const ParseErroredQuery = Schema.Struct({
|
|
35
|
+
error: Schema.Literal("parse"),
|
|
33
36
|
id: Schema.String,
|
|
34
37
|
name: Schema.String,
|
|
35
|
-
|
|
38
|
+
message: Schema.String,
|
|
39
|
+
details: Schema.optional(JsonSchema),
|
|
36
40
|
});
|
|
37
41
|
|
|
38
|
-
const
|
|
39
|
-
error: Schema.Literal("http"),
|
|
40
|
-
id: Schema.String,
|
|
41
|
-
name: Schema.String,
|
|
42
|
-
status: Schema.Number,
|
|
43
|
-
details: JsonSchema,
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
const ErroredQuery = Schema.Union(AppQueryError, HttpQueryError, ErrorSchema);
|
|
42
|
+
const ErroredQuery = Schema.Union(AppErroredQuery, ParseErroredQuery);
|
|
47
43
|
|
|
48
44
|
const TransformResponseBody = Schema.Array(Schema.Union(TransformedQuery, ErroredQuery));
|
|
49
45
|
|
|
@@ -53,4 +49,8 @@ export type TransformRequestMessage = typeof TransformRequestMessage.Type;
|
|
|
53
49
|
// biome-ignore lint/correctness/noUnusedVariables: borrowed code
|
|
54
50
|
const TransformErrorMessage = Schema.Tuple(Schema.Literal("transformError"), Schema.Array(ErroredQuery));
|
|
55
51
|
|
|
56
|
-
|
|
52
|
+
const TransformFailedMessage = Schema.Tuple(Schema.Literal("transformFailed"), TransformFailedBody);
|
|
53
|
+
|
|
54
|
+
const TransformOkMessage = Schema.Tuple(Schema.Literal("transformed"), TransformResponseBody);
|
|
55
|
+
|
|
56
|
+
export const TransformResponseMessage = Schema.Union(TransformOkMessage, TransformFailedMessage);
|