effect-zero 0.5.0 → 0.6.0-beta.0
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/README.md +56 -38
- package/dist/client-transaction.d.ts +11 -9
- package/dist/client-transaction.d.ts.map +1 -1
- package/dist/client-transaction.js +4 -1
- package/dist/client-transaction.js.map +1 -1
- package/dist/client.d.ts +68 -66
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +7 -10
- package/dist/client.js.map +1 -1
- package/dist/client.test.d.ts +2 -0
- package/dist/client.test.d.ts.map +1 -0
- package/dist/client.test.js +19 -0
- package/dist/client.test.js.map +1 -0
- package/dist/internal/server-synchronization-context.d.ts.map +1 -1
- package/dist/internal/server-synchronization-context.js +2 -2
- package/dist/internal/server-synchronization-context.js.map +1 -1
- package/dist/internal/server.d.ts +13 -28
- package/dist/internal/server.d.ts.map +1 -1
- package/dist/internal/server.js +5 -19
- package/dist/internal/server.js.map +1 -1
- package/dist/internal/server.test.js +5 -3
- package/dist/internal/server.test.js.map +1 -1
- package/dist/server-transaction.d.ts +82 -109
- package/dist/server-transaction.d.ts.map +1 -1
- package/dist/server-transaction.js +26 -74
- package/dist/server-transaction.js.map +1 -1
- package/dist/server.d.ts +207 -354
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +60 -80
- package/dist/server.js.map +1 -1
- package/dist/types/ast.d.ts +4 -0
- package/dist/types/ast.d.ts.map +1 -0
- package/dist/types/ast.js +4 -0
- package/dist/types/ast.js.map +1 -0
- package/dist/types/{queries.d.ts → custom-queries.d.ts} +19 -1
- package/dist/types/custom-queries.d.ts.map +1 -0
- package/dist/types/{queries.js → custom-queries.js} +5 -6
- package/dist/types/custom-queries.js.map +1 -0
- package/dist/types/mutate-server.d.ts +160 -0
- package/dist/types/mutate-server.d.ts.map +1 -0
- package/dist/types/mutate-server.js +29 -0
- package/dist/types/mutate-server.js.map +1 -0
- package/dist/types/mutation-id.d.ts +7 -0
- package/dist/types/mutation-id.d.ts.map +1 -0
- package/dist/types/mutation-id.js +8 -0
- package/dist/types/mutation-id.js.map +1 -0
- package/dist/types/mutation.d.ts +79 -0
- package/dist/types/mutation.d.ts.map +1 -0
- package/dist/types/mutation.js +125 -0
- package/dist/types/mutation.js.map +1 -0
- package/dist/types/push.d.ts +100 -85
- package/dist/types/push.d.ts.map +1 -1
- package/dist/types/push.js +7 -134
- package/dist/types/push.js.map +1 -1
- package/dist/types/query-server.d.ts +144 -0
- package/dist/types/query-server.d.ts.map +1 -0
- package/dist/types/query-server.js +19 -0
- package/dist/types/query-server.js.map +1 -0
- package/dist/types.test.js +4 -4
- package/dist/types.test.js.map +1 -1
- package/package.json +35 -5
- package/src/client-transaction.ts +5 -1
- package/src/client.ts +14 -15
- package/src/internal/server-synchronization-context.ts +37 -39
- package/src/internal/server.ts +8 -31
- package/src/server-transaction.ts +55 -101
- package/src/server.ts +147 -151
- package/src/types/ast.ts +4 -0
- package/src/types/{queries.ts → custom-queries.ts} +4 -6
- package/src/types/mutate-server.ts +37 -0
- package/src/types/mutation-id.ts +10 -0
- package/src/types/mutation.ts +155 -0
- package/src/types/push.ts +7 -167
- package/src/types/query-server.ts +27 -0
- package/dist/types/queries.d.ts.map +0 -1
- package/dist/types/queries.js.map +0 -1
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,
|
|
1
|
+
{"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,iBAAiB,EACjB,MAAM,IAAI,UAAU,EACpB,iBAAiB,IAAI,qBAAqB,EAC3C,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,kBAAkB,EAAsB,MAAM,uBAAuB,CAAC;AAEtH,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC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,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,oDAI/D,CAAC;;;;AAcF,cAAM,iBAAkB,SAAQ,uBAAsC;IAAE,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;CAAE,CAAC;CAAG;AAElH,eAAO,MAAM,WAAW,GAAwB,CAAC,EAAE,EAAE,EAAE,EAAE;aAM9C,eAAe,CAAC,CAAC,EAAE,EAAE,EAAE,EAAE,CAAC,EAAE;YAC7B,UAAU;UACZ,uBAAuB;YACrB,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;8BAqBnB,CAAC;;;;AAQH,cAAM,gBAAiB,SAAQ,sBAAqC;IAAE,KAAK,EAAE,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAA;CAAE,CAAC;CAAG"}
|
package/dist/server.js
CHANGED
|
@@ -1,103 +1,90 @@
|
|
|
1
|
-
import { handleQueryRequest } from "@rocicorp/zero/server";
|
|
1
|
+
import { ApplicationError, handleMutateRequest, handleQueryRequest, OutOfOrderMutation } from "@rocicorp/zero/server";
|
|
2
2
|
import * as Arr from "effect/Array";
|
|
3
3
|
import * as Cause from "effect/Cause";
|
|
4
4
|
import * as Data from "effect/Data";
|
|
5
|
+
import * as Deferred from "effect/Deferred";
|
|
5
6
|
import * as Effect from "effect/Effect";
|
|
6
7
|
import * as Exit from "effect/Exit";
|
|
7
8
|
import * as Fn from "effect/Function";
|
|
9
|
+
import * as Layer from "effect/Layer";
|
|
8
10
|
import * as Match from "effect/Match";
|
|
9
11
|
import * as Option from "effect/Option";
|
|
10
12
|
import * as Predicate from "effect/Predicate";
|
|
11
13
|
import * as Rec from "effect/Record";
|
|
12
14
|
import * as Schema from "effect/Schema";
|
|
13
|
-
import * as Stream from "effect/Stream";
|
|
14
15
|
import * as Str from "effect/String";
|
|
15
|
-
import {
|
|
16
|
+
import { TransactCallbackNotInvokedError, TransactInternalError } from "./internal/server.js";
|
|
16
17
|
import * as ServerSynchronizationContext from "./internal/server-synchronization-context.js";
|
|
17
|
-
import { normalizeArgs
|
|
18
|
+
import { normalizeArgs } from "./internal/utils.js";
|
|
18
19
|
import * as Mutators from "./mutators.js";
|
|
19
20
|
import { QueryNameSymbol, RunQuerySymbol } from "./query.js";
|
|
20
|
-
import
|
|
21
|
-
export const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
21
|
+
import { DatabaseSymbol, ServerTransactionCallbackSymbol } from "./server-transaction.js";
|
|
22
|
+
export const handleMutate = Effect.fn(function* ({ transaction, mutators, query, body, userId, }) {
|
|
23
|
+
const ctx = yield* Effect.context();
|
|
24
|
+
return yield* Effect.tryPromise({
|
|
25
|
+
try: () => handleMutateRequest({
|
|
26
|
+
dbProvider: transaction[DatabaseSymbol],
|
|
27
|
+
handler: (transact_, mutation) => Effect.gen(function* () {
|
|
28
|
+
const response = yield* Deferred.make();
|
|
29
|
+
const transact = Effect.fn(function* (fn) {
|
|
30
|
+
const innerCtx = yield* Effect.context();
|
|
31
|
+
const exitDeferred = yield* Deferred.make();
|
|
32
|
+
yield* Effect.tryPromise({
|
|
33
|
+
try: (signal) => transact_((transaction) => fn(transaction).pipe(Effect.onExit((exit) => Deferred.done(exitDeferred, exit)), Effect.catchCause((cause) => Effect.die(makeApplicationError(cause))), Effect.asVoid, Effect.provide(innerCtx), (effect) => Effect.runPromise(effect, { signal }))),
|
|
34
|
+
catch: (error) => new TransactInternalError({ cause: Cause.fail(error) }),
|
|
35
|
+
}).pipe(Effect.flatMap((value) => Deferred.succeed(response, value)));
|
|
36
|
+
return yield* Deferred.poll(exitDeferred).pipe(Effect.flatMap(Effect.fromOption), Effect.catchTag("NoSuchElementError", () => Effect.fail(new TransactCallbackNotInvokedError())), Effect.flatten);
|
|
37
|
+
}, ServerSynchronizationContext.guard);
|
|
38
|
+
const exit = yield* runMutation(mutators, mutation).pipe(ServerSynchronizationContext.finalize, Effect.provide([
|
|
39
|
+
Layer.succeed(transaction[ServerTransactionCallbackSymbol], { transact }),
|
|
40
|
+
ServerSynchronizationContext.layer,
|
|
41
|
+
]), Effect.exit);
|
|
42
|
+
return yield* Deferred.poll(response).pipe(Effect.flatMap(Effect.fromOption), Effect.catchTag("NoSuchElementError", () => Effect.failCause(Exit.isFailure(exit) ? exit.cause : Cause.empty)), Effect.flatten);
|
|
43
|
+
}).pipe(Effect.catchCause((cause) => {
|
|
44
|
+
const error = cause.pipe(Cause.squash, (squashed) => TransactInternalError.is(squashed) ? Cause.squash(squashed.cause) : squashed);
|
|
45
|
+
// Split out-of-order mutations from application errors, as `handleMutateRequest` expects.
|
|
46
|
+
return Effect.fail(error instanceof OutOfOrderMutation ? error : makeApplicationError(Cause.fail(error)));
|
|
47
|
+
}), Effect.provide(ctx), Effect.runPromise),
|
|
48
|
+
query,
|
|
49
|
+
body: body,
|
|
50
|
+
userID: userId,
|
|
51
|
+
}),
|
|
52
|
+
catch: (e) => new HandleMutateError({ cause: Cause.fail(e) }),
|
|
53
|
+
});
|
|
41
54
|
});
|
|
42
|
-
const
|
|
55
|
+
const runMutation = Effect.fn(function* (mutators, mutation) {
|
|
43
56
|
// Support both "namespace|name" and "namespace.name" formats, and single-segment names.
|
|
44
57
|
const [namespace, name] = mutation.name.includes("|") ? Str.split(mutation.name, "|") : Str.split(mutation.name, ".");
|
|
45
58
|
const mutator = yield* Fn.pipe(mutators, Rec.get(namespace), Option.flatMap((mutator) => Match.value([mutator, name]).pipe(Match.when([Predicate.isObject, Predicate.isString], ([mutator, name]) => Rec.get(name)(mutator)), Match.when([Predicate.isFunction, Predicate.isUndefined], ([mutator]) => Option.some(mutator)), Match.orElse(() => Option.none()))), Effect.fromOption, Effect.catchTag("NoSuchElementError", () => Effect.fail(new MutatorNotFoundError({ name: mutation.name }))));
|
|
46
59
|
const args = yield* Schema.decodeUnknownEffect(mutator[Mutators.MutatorSchemaSymbol])(normalizeArgs(mutation.args[0])).pipe(Effect.catchTag("SchemaError", (e) => Effect.fail(new ServerArgsParseError({ cause: Cause.fail(e) }))));
|
|
47
|
-
return yield* mutator(args)
|
|
48
|
-
// Case #5 "Zero transactions then fail" / #6 "Fail before transaction"
|
|
49
|
-
// Catches all errors that are produced before the transaction is executed
|
|
50
|
-
Effect.catchCause((cause) => Effect.fail(new MutationUserError({ cause }))));
|
|
60
|
+
return yield* mutator(args);
|
|
51
61
|
});
|
|
52
|
-
const
|
|
53
|
-
const
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
error: "app",
|
|
58
|
-
details: errorMessage,
|
|
59
|
-
};
|
|
60
|
-
yield* transaction
|
|
61
|
-
.execute(Effect.gen(function* () {
|
|
62
|
-
const { transactionHooks } = yield* transaction.Context;
|
|
63
|
-
return yield* Effect.tryPromise({
|
|
64
|
-
try: () => transactionHooks.writeMutationResult({ id: { id: mutationID, clientID }, result: appError }),
|
|
65
|
-
catch: (error) => new WriteMutationResultError({ cause: Cause.fail(error) }),
|
|
66
|
-
});
|
|
67
|
-
}))
|
|
68
|
-
.pipe(Effect.catchCause(Effect.logError));
|
|
69
|
-
yield* Effect.logWarning(`Mutation ${mutationID} for client ${clientID} was retried after an error: ${e}`);
|
|
70
|
-
return appError;
|
|
71
|
-
});
|
|
72
|
-
class WriteMutationResultError extends Data.TaggedError("WriteMutationResultError") {
|
|
73
|
-
}
|
|
74
|
-
class CustomMutationExpectedError extends Data.TaggedError("CustomMutationExpectedError") {
|
|
75
|
-
}
|
|
62
|
+
export const makeApplicationError = (cause) => {
|
|
63
|
+
const error = Cause.squash(cause);
|
|
64
|
+
const message = Predicate.isError(error) ? error.message : "Internal error";
|
|
65
|
+
return new ApplicationError(message, { cause: error });
|
|
66
|
+
};
|
|
76
67
|
class MutatorNotFoundError extends Data.TaggedError("MutatorNotFoundError") {
|
|
68
|
+
get message() {
|
|
69
|
+
return `Mutator not found: ${this.name}`;
|
|
70
|
+
}
|
|
77
71
|
}
|
|
78
72
|
class ServerArgsParseError extends Data.TaggedError("ServerArgsParseError") {
|
|
79
73
|
}
|
|
80
|
-
|
|
81
|
-
class MutationUserError extends Data.TaggedError("MutationUserError") {
|
|
82
|
-
[MutationUserErrorTypeId] = MutationUserErrorTypeId;
|
|
83
|
-
static is(e) {
|
|
84
|
-
return Predicate.hasProperty(e, MutationUserErrorTypeId);
|
|
85
|
-
}
|
|
86
|
-
get message() {
|
|
87
|
-
const err = Cause.squash(this.cause);
|
|
88
|
-
return err instanceof Error ? err.message : "exception was not of type `Error`";
|
|
89
|
-
}
|
|
74
|
+
class HandleMutateError extends Data.TaggedError("HandleMutateError") {
|
|
90
75
|
}
|
|
91
|
-
export const handleQuery = Effect.fn(function* (queries, schema,
|
|
76
|
+
export const handleQuery = Effect.fn(function* ({ queries, schema, body, userId, }) {
|
|
92
77
|
const ctx = yield* Effect.context();
|
|
93
78
|
return yield* Effect.tryPromise({
|
|
94
|
-
try: () => handleQueryRequest(
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
79
|
+
try: () => handleQueryRequest({
|
|
80
|
+
handler: (name, args) => Arr.findFirst(queries, (q) => q[QueryNameSymbol] === name).pipe(Effect.fromOption, Effect.catchTag("NoSuchElementError", () => Effect.fail(new QueryNotFound({ name }))), Effect.flatMap((query) => query[RunQuerySymbol]({ _tag: "Encoded", args })), Effect.runSyncWith(ctx)),
|
|
81
|
+
schema,
|
|
82
|
+
// `query` params are unused by the query endpoint at runtime but required by the options type.
|
|
83
|
+
query: {},
|
|
84
|
+
body: body,
|
|
85
|
+
userID: userId,
|
|
86
|
+
}),
|
|
87
|
+
catch: (e) => new HandleQueryError({ cause: Cause.fail(e) }),
|
|
101
88
|
});
|
|
102
89
|
});
|
|
103
90
|
class QueryNotFound extends Data.TaggedError("QueryNotFound") {
|
|
@@ -105,13 +92,6 @@ class QueryNotFound extends Data.TaggedError("QueryNotFound") {
|
|
|
105
92
|
return `Query not found: ${this.name}`;
|
|
106
93
|
}
|
|
107
94
|
}
|
|
108
|
-
|
|
109
|
-
class QueryUserError extends Data.TaggedError("QueryUserError") {
|
|
110
|
-
[QueryUserErrorTypeId] = QueryUserErrorTypeId;
|
|
111
|
-
static is(e) {
|
|
112
|
-
return Predicate.hasProperty(e, QueryUserErrorTypeId);
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
class QueryRequestError extends Data.TaggedError("QueryRequestError") {
|
|
95
|
+
class HandleQueryError extends Data.TaggedError("HandleQueryError") {
|
|
116
96
|
}
|
|
117
97
|
//# sourceMappingURL=server.js.map
|
package/dist/server.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AACtH,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,IAAI,MAAM,aAAa,CAAC;AACpC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,IAAI,MAAM,aAAa,CAAC;AACpC,OAAO,KAAK,EAAE,MAAM,iBAAiB,CAAC;AAEtC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,KAAK,MAAM,cA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,CAAC,CACxB;YACH,MAAM;YACN,+FAA+F;YAC/F,KAAK,EAAE,EAAE;YACT,IAAI,EAAE,IAAyB;YAC/B,MAAM,EAAE,MAAM;SACf,CAAC;QACJ,KAAK,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,gBAAgB,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;KAC7D,CAAC,CAAC;AACL,CAAC,CAAC,CAAC;AAEH,MAAM,aAAc,SAAQ,IAAI,CAAC,WAAW,CAAC,eAAe,CAAmB;IAC7E,IAAa,OAAO;QAClB,OAAO,oBAAoB,IAAI,CAAC,IAAI,EAAE,CAAC;IACzC,CAAC;CACF;AAED,MAAM,gBAAiB,SAAQ,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAAkC;CAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ast.d.ts","sourceRoot":"","sources":["../../src/types/ast.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,uCAAuC;AACvC,eAAO,MAAM,GAAG,gBAAiB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ast.js","sourceRoot":"","sources":["../../src/types/ast.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,uCAAuC;AACvC,MAAM,CAAC,MAAM,GAAG,GAAG,MAAM,CAAC,OAAO,CAAC"}
|
|
@@ -1,4 +1,22 @@
|
|
|
1
1
|
import * as Schema from "effect/Schema";
|
|
2
|
+
export declare const TransformedQuery: Schema.Struct<{
|
|
3
|
+
readonly id: Schema.String;
|
|
4
|
+
readonly name: Schema.String;
|
|
5
|
+
readonly ast: Schema.Unknown;
|
|
6
|
+
}>;
|
|
7
|
+
export declare const ErroredQuery: Schema.Union<readonly [Schema.Struct<{
|
|
8
|
+
readonly error: Schema.Literal<"app">;
|
|
9
|
+
readonly id: Schema.String;
|
|
10
|
+
readonly name: Schema.String;
|
|
11
|
+
readonly message: Schema.optional<Schema.String>;
|
|
12
|
+
readonly details: Schema.optional<Schema.Unknown>;
|
|
13
|
+
}>, Schema.Struct<{
|
|
14
|
+
readonly error: Schema.Literal<"parse">;
|
|
15
|
+
readonly id: Schema.String;
|
|
16
|
+
readonly name: Schema.String;
|
|
17
|
+
readonly message: Schema.String;
|
|
18
|
+
readonly details: Schema.optional<Schema.Unknown>;
|
|
19
|
+
}>]>;
|
|
2
20
|
export declare const TransformRequestMessage: Schema.Tuple<readonly [Schema.Literal<"transform">, Schema.$Array<Schema.Struct<{
|
|
3
21
|
readonly id: Schema.String;
|
|
4
22
|
readonly name: Schema.String;
|
|
@@ -45,4 +63,4 @@ export declare const TransformResponseMessage: Schema.Union<readonly [Schema.Tup
|
|
|
45
63
|
readonly queryIDs: Schema.$Array<Schema.String>;
|
|
46
64
|
readonly message: Schema.String;
|
|
47
65
|
}>]>]>]>;
|
|
48
|
-
//# sourceMappingURL=queries.d.ts.map
|
|
66
|
+
//# sourceMappingURL=custom-queries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom-queries.d.ts","sourceRoot":"","sources":["../../src/types/custom-queries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAgBxC,eAAO,MAAM,gBAAgB;;;;EAI3B,CAAC;AAmBH,eAAO,MAAM,YAAY;;;;;;;;;;;;IAAqD,CAAC;AAI/E,eAAO,MAAM,uBAAuB;;;;KAAoE,CAAC;AACzG,MAAM,MAAM,uBAAuB,GAAG,OAAO,uBAAuB,CAAC,IAAI,CAAC;AAS1E,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAA6D,CAAC"}
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import * as Schema from "effect/Schema";
|
|
2
|
+
import { Ast } from "./ast.js";
|
|
2
3
|
import { JsonSchema } from "./common.js";
|
|
3
4
|
import { TransformFailedBody } from "./error.js";
|
|
4
5
|
// The code below was converted to Effect Schema from:
|
|
5
|
-
// https://github.com/rocicorp/mono/blob/
|
|
6
|
-
/** TODO: Defined as unknown for now */
|
|
7
|
-
const Ast = Schema.Unknown;
|
|
6
|
+
// https://github.com/rocicorp/mono/blob/74273167af5d15ed07045e04165cb04d3983d44f/packages/zero-protocol/src/custom-queries.ts
|
|
8
7
|
const TransformRequestBody = Schema.Array(Schema.Struct({
|
|
9
8
|
id: Schema.String,
|
|
10
9
|
name: Schema.String,
|
|
11
10
|
args: Schema.Array(JsonSchema),
|
|
12
11
|
}));
|
|
13
|
-
const TransformedQuery = Schema.Struct({
|
|
12
|
+
export const TransformedQuery = Schema.Struct({
|
|
14
13
|
id: Schema.String,
|
|
15
14
|
name: Schema.String,
|
|
16
15
|
ast: Ast,
|
|
@@ -30,7 +29,7 @@ const ParseErroredQuery = Schema.Struct({
|
|
|
30
29
|
message: Schema.String,
|
|
31
30
|
details: Schema.optional(JsonSchema),
|
|
32
31
|
});
|
|
33
|
-
const ErroredQuery = Schema.Union([AppErroredQuery, ParseErroredQuery]);
|
|
32
|
+
export const ErroredQuery = Schema.Union([AppErroredQuery, ParseErroredQuery]);
|
|
34
33
|
const TransformResponseBody = Schema.Array(Schema.Union([TransformedQuery, ErroredQuery]));
|
|
35
34
|
export const TransformRequestMessage = Schema.Tuple([Schema.Literal("transform"), TransformRequestBody]);
|
|
36
35
|
// biome-ignore lint/correctness/noUnusedVariables: borrowed code
|
|
@@ -38,4 +37,4 @@ const TransformErrorMessage = Schema.Tuple([Schema.Literal("transformError"), Sc
|
|
|
38
37
|
const TransformFailedMessage = Schema.Tuple([Schema.Literal("transformFailed"), TransformFailedBody]);
|
|
39
38
|
const TransformOkMessage = Schema.Tuple([Schema.Literal("transformed"), TransformResponseBody]);
|
|
40
39
|
export const TransformResponseMessage = Schema.Union([TransformOkMessage, TransformFailedMessage]);
|
|
41
|
-
//# sourceMappingURL=queries.js.map
|
|
40
|
+
//# sourceMappingURL=custom-queries.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"custom-queries.js","sourceRoot":"","sources":["../../src/types/custom-queries.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAEjD,sDAAsD;AACtD,8HAA8H;AAE9H,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,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAC,MAAM,CAAC;IAC5C,EAAE,EAAE,MAAM,CAAC,MAAM;IACjB,IAAI,EAAE,MAAM,CAAC,MAAM;IACnB,GAAG,EAAE,GAAG;CACT,CAAC,CAAC;AAEH,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,CAAC;IACpC,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC;IAC5B,EAAE,EAAE,MAAM,CAAC,MAAM;IACjB,IAAI,EAAE,MAAM,CAAC,MAAM;IACnB,uCAAuC;IACvC,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC;IACvC,OAAO,EAAE,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC;CACrC,CAAC,CAAC;AAEH,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,CAAC;IACtC,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC;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
4
|
+
readonly userID: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
5
|
+
readonly mutations: Schema.$Array<Schema.Struct<{
|
|
6
|
+
readonly id: Schema.Struct<{
|
|
7
|
+
readonly id: Schema.Number;
|
|
8
|
+
readonly clientID: Schema.String;
|
|
9
|
+
}>;
|
|
10
|
+
readonly result: Schema.Union<readonly [Schema.Union<readonly [Schema.Struct<{
|
|
11
|
+
readonly error: Schema.Literal<"app">;
|
|
12
|
+
readonly message: Schema.optional<Schema.String>;
|
|
13
|
+
readonly details: Schema.optional<Schema.Unknown>;
|
|
14
|
+
}>, Schema.Struct<{
|
|
15
|
+
readonly error: Schema.Literals<readonly ["oooMutation", "alreadyProcessed"]>;
|
|
16
|
+
readonly details: Schema.optional<Schema.Unknown>;
|
|
17
|
+
}>]>, Schema.Struct<{
|
|
18
|
+
readonly data: Schema.optional<Schema.Unknown>;
|
|
19
|
+
}>]>;
|
|
20
|
+
}>>;
|
|
21
|
+
}>;
|
|
22
|
+
export type MutateSuccess = typeof MutateSuccess.Type;
|
|
23
|
+
export declare const MutateResponse: Schema.Union<readonly [Schema.Struct<{
|
|
24
|
+
readonly kind: Schema.Literal<"MutateResponse">;
|
|
25
|
+
readonly userID: Schema.optional<Schema.NullOr<Schema.String>>;
|
|
26
|
+
readonly mutations: Schema.$Array<Schema.Struct<{
|
|
27
|
+
readonly id: Schema.Struct<{
|
|
28
|
+
readonly id: Schema.Number;
|
|
29
|
+
readonly clientID: Schema.String;
|
|
30
|
+
}>;
|
|
31
|
+
readonly result: Schema.Union<readonly [Schema.Union<readonly [Schema.Struct<{
|
|
32
|
+
readonly error: Schema.Literal<"app">;
|
|
33
|
+
readonly message: Schema.optional<Schema.String>;
|
|
34
|
+
readonly details: Schema.optional<Schema.Unknown>;
|
|
35
|
+
}>, Schema.Struct<{
|
|
36
|
+
readonly error: Schema.Literals<readonly ["oooMutation", "alreadyProcessed"]>;
|
|
37
|
+
readonly details: Schema.optional<Schema.Unknown>;
|
|
38
|
+
}>]>, Schema.Struct<{
|
|
39
|
+
readonly data: Schema.optional<Schema.Unknown>;
|
|
40
|
+
}>]>;
|
|
41
|
+
}>>;
|
|
42
|
+
}>, Schema.Union<readonly [Schema.Struct<{
|
|
43
|
+
readonly origin: Schema.Literal<"server">;
|
|
44
|
+
readonly reason: Schema.Literals<readonly ["database", "parse", "oooMutation", "unsupportedPushVersion", "internal"]>;
|
|
45
|
+
readonly kind: Schema.Literal<"PushFailed">;
|
|
46
|
+
readonly details: Schema.optional<Schema.Unknown>;
|
|
47
|
+
readonly mutationIDs: Schema.$Array<Schema.Struct<{
|
|
48
|
+
readonly id: Schema.Number;
|
|
49
|
+
readonly clientID: Schema.String;
|
|
50
|
+
}>>;
|
|
51
|
+
readonly message: Schema.String;
|
|
52
|
+
}>, Schema.Struct<{
|
|
53
|
+
readonly origin: Schema.Literal<"zeroCache">;
|
|
54
|
+
readonly reason: Schema.Literal<"http">;
|
|
55
|
+
readonly status: Schema.Number;
|
|
56
|
+
readonly bodyPreview: Schema.optional<Schema.String>;
|
|
57
|
+
readonly kind: Schema.Literal<"PushFailed">;
|
|
58
|
+
readonly details: Schema.optional<Schema.Unknown>;
|
|
59
|
+
readonly mutationIDs: Schema.$Array<Schema.Struct<{
|
|
60
|
+
readonly id: Schema.Number;
|
|
61
|
+
readonly clientID: Schema.String;
|
|
62
|
+
}>>;
|
|
63
|
+
readonly message: Schema.String;
|
|
64
|
+
}>, Schema.Struct<{
|
|
65
|
+
readonly origin: Schema.Literal<"zeroCache">;
|
|
66
|
+
readonly reason: Schema.Literals<readonly ["timeout", "parse", "internal"]>;
|
|
67
|
+
readonly kind: Schema.Literal<"PushFailed">;
|
|
68
|
+
readonly details: Schema.optional<Schema.Unknown>;
|
|
69
|
+
readonly mutationIDs: Schema.$Array<Schema.Struct<{
|
|
70
|
+
readonly id: Schema.Number;
|
|
71
|
+
readonly clientID: Schema.String;
|
|
72
|
+
}>>;
|
|
73
|
+
readonly message: Schema.String;
|
|
74
|
+
}>]>, Schema.Union<readonly [Schema.Struct<{
|
|
75
|
+
readonly mutations: Schema.$Array<Schema.Struct<{
|
|
76
|
+
readonly id: Schema.Struct<{
|
|
77
|
+
readonly id: Schema.Number;
|
|
78
|
+
readonly clientID: Schema.String;
|
|
79
|
+
}>;
|
|
80
|
+
readonly result: Schema.Union<readonly [Schema.Union<readonly [Schema.Struct<{
|
|
81
|
+
readonly error: Schema.Literal<"app">;
|
|
82
|
+
readonly message: Schema.optional<Schema.String>;
|
|
83
|
+
readonly details: Schema.optional<Schema.Unknown>;
|
|
84
|
+
}>, Schema.Struct<{
|
|
85
|
+
readonly error: Schema.Literals<readonly ["oooMutation", "alreadyProcessed"]>;
|
|
86
|
+
readonly details: Schema.optional<Schema.Unknown>;
|
|
87
|
+
}>]>, Schema.Struct<{
|
|
88
|
+
readonly data: Schema.optional<Schema.Unknown>;
|
|
89
|
+
}>]>;
|
|
90
|
+
}>>;
|
|
91
|
+
}>, Schema.Union<readonly [Schema.Struct<{
|
|
92
|
+
readonly error: Schema.Literal<"unsupportedPushVersion">;
|
|
93
|
+
readonly mutationIDs: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
94
|
+
readonly id: Schema.Number;
|
|
95
|
+
readonly clientID: Schema.String;
|
|
96
|
+
}>>>;
|
|
97
|
+
}>, Schema.Struct<{
|
|
98
|
+
readonly error: Schema.Literal<"unsupportedSchemaVersion">;
|
|
99
|
+
readonly mutationIDs: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
100
|
+
readonly id: Schema.Number;
|
|
101
|
+
readonly clientID: Schema.String;
|
|
102
|
+
}>>>;
|
|
103
|
+
}>, Schema.Struct<{
|
|
104
|
+
readonly error: Schema.Literal<"http">;
|
|
105
|
+
readonly status: Schema.Number;
|
|
106
|
+
readonly details: Schema.String;
|
|
107
|
+
readonly mutationIDs: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
108
|
+
readonly id: Schema.Number;
|
|
109
|
+
readonly clientID: Schema.String;
|
|
110
|
+
}>>>;
|
|
111
|
+
}>, Schema.Struct<{
|
|
112
|
+
readonly error: Schema.Literal<"zeroPusher">;
|
|
113
|
+
readonly details: Schema.String;
|
|
114
|
+
readonly mutationIDs: Schema.optional<Schema.$Array<Schema.Struct<{
|
|
115
|
+
readonly id: Schema.Number;
|
|
116
|
+
readonly clientID: Schema.String;
|
|
117
|
+
}>>>;
|
|
118
|
+
}>]>, Schema.Union<readonly [Schema.Struct<{
|
|
119
|
+
readonly origin: Schema.Literal<"server">;
|
|
120
|
+
readonly reason: Schema.Literals<readonly ["database", "parse", "oooMutation", "unsupportedPushVersion", "internal"]>;
|
|
121
|
+
readonly kind: Schema.Literal<"PushFailed">;
|
|
122
|
+
readonly details: Schema.optional<Schema.Unknown>;
|
|
123
|
+
readonly mutationIDs: Schema.$Array<Schema.Struct<{
|
|
124
|
+
readonly id: Schema.Number;
|
|
125
|
+
readonly clientID: Schema.String;
|
|
126
|
+
}>>;
|
|
127
|
+
readonly message: Schema.String;
|
|
128
|
+
}>, Schema.Struct<{
|
|
129
|
+
readonly origin: Schema.Literal<"zeroCache">;
|
|
130
|
+
readonly reason: Schema.Literal<"http">;
|
|
131
|
+
readonly status: Schema.Number;
|
|
132
|
+
readonly bodyPreview: Schema.optional<Schema.String>;
|
|
133
|
+
readonly kind: Schema.Literal<"PushFailed">;
|
|
134
|
+
readonly details: Schema.optional<Schema.Unknown>;
|
|
135
|
+
readonly mutationIDs: Schema.$Array<Schema.Struct<{
|
|
136
|
+
readonly id: Schema.Number;
|
|
137
|
+
readonly clientID: Schema.String;
|
|
138
|
+
}>>;
|
|
139
|
+
readonly message: Schema.String;
|
|
140
|
+
}>, Schema.Struct<{
|
|
141
|
+
readonly origin: Schema.Literal<"zeroCache">;
|
|
142
|
+
readonly reason: Schema.Literals<readonly ["timeout", "parse", "internal"]>;
|
|
143
|
+
readonly kind: Schema.Literal<"PushFailed">;
|
|
144
|
+
readonly details: Schema.optional<Schema.Unknown>;
|
|
145
|
+
readonly mutationIDs: Schema.$Array<Schema.Struct<{
|
|
146
|
+
readonly id: Schema.Number;
|
|
147
|
+
readonly clientID: Schema.String;
|
|
148
|
+
}>>;
|
|
149
|
+
readonly message: Schema.String;
|
|
150
|
+
}>]>]>]>;
|
|
151
|
+
export type MutateResponse = typeof MutateResponse.Type;
|
|
152
|
+
/**
|
|
153
|
+
* The schema for the querystring parameters of the custom mutate endpoint.
|
|
154
|
+
*/
|
|
155
|
+
export declare const MutateParams: Schema.Struct<{
|
|
156
|
+
readonly schema: Schema.String;
|
|
157
|
+
readonly appID: Schema.String;
|
|
158
|
+
}>;
|
|
159
|
+
export type MutateParams = typeof MutateParams.Type;
|
|
160
|
+
//# sourceMappingURL=mutate-server.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutate-server.d.ts","sourceRoot":"","sources":["../../src/types/mutate-server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAcxC,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;EAIxB,CAAC;AACH,MAAM,MAAM,aAAa,GAAG,OAAO,aAAa,CAAC,IAAI,CAAC;AAEtD,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAKzB,CAAC;AACH,MAAM,MAAM,cAAc,GAAG,OAAO,cAAc,CAAC,IAAI,CAAC;AAExD;;GAEG;AACH,eAAO,MAAM,YAAY;;;EAGvB,CAAC;AACH,MAAM,MAAM,YAAY,GAAG,OAAO,YAAY,CAAC,IAAI,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as Schema from "effect/Schema";
|
|
2
|
+
import { PushFailedBody } from "./error.js";
|
|
3
|
+
import { MutationResponse } from "./mutation.js";
|
|
4
|
+
import { PushError } from "./push.js";
|
|
5
|
+
// The code below was converted to Effect Schema from:
|
|
6
|
+
// https://github.com/rocicorp/mono/blob/74273167af5d15ed07045e04165cb04d3983d44f/packages/zero-protocol/src/mutate-server.ts
|
|
7
|
+
const LegacyPushSuccess = Schema.Struct({
|
|
8
|
+
mutations: Schema.Array(MutationResponse),
|
|
9
|
+
});
|
|
10
|
+
const LegacyPushResponse = Schema.Union([LegacyPushSuccess, PushError, PushFailedBody]);
|
|
11
|
+
export const MutateSuccess = Schema.Struct({
|
|
12
|
+
kind: Schema.Literal("MutateResponse"),
|
|
13
|
+
userID: Schema.optional(Schema.NullOr(Schema.String)),
|
|
14
|
+
mutations: Schema.Array(MutationResponse),
|
|
15
|
+
});
|
|
16
|
+
export const MutateResponse = Schema.Union([
|
|
17
|
+
MutateSuccess,
|
|
18
|
+
PushFailedBody,
|
|
19
|
+
// for backwards compatibility
|
|
20
|
+
LegacyPushResponse,
|
|
21
|
+
]);
|
|
22
|
+
/**
|
|
23
|
+
* The schema for the querystring parameters of the custom mutate endpoint.
|
|
24
|
+
*/
|
|
25
|
+
export const MutateParams = Schema.Struct({
|
|
26
|
+
schema: Schema.String,
|
|
27
|
+
appID: Schema.String,
|
|
28
|
+
});
|
|
29
|
+
//# sourceMappingURL=mutate-server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutate-server.js","sourceRoot":"","sources":["../../src/types/mutate-server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAEtC,sDAAsD;AACtD,6HAA6H;AAE7H,MAAM,iBAAiB,GAAG,MAAM,CAAC,MAAM,CAAC;IACtC,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAAC;CAC1C,CAAC,CAAC;AAEH,MAAM,kBAAkB,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC,iBAAiB,EAAE,SAAS,EAAE,cAAc,CAAC,CAAC,CAAC;AAExF,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC,MAAM,CAAC;IACzC,IAAI,EAAE,MAAM,CAAC,OAAO,CAAC,gBAAgB,CAAC;IACtC,MAAM,EAAE,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACrD,SAAS,EAAE,MAAM,CAAC,KAAK,CAAC,gBAAgB,CAAC;CAC1C,CAAC,CAAC;AAGH,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,KAAK,CAAC;IACzC,aAAa;IACb,cAAc;IACd,8BAA8B;IAC9B,kBAAkB;CACnB,CAAC,CAAC;AAGH;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC,MAAM,CAAC;IACxC,MAAM,EAAE,MAAM,CAAC,MAAM;IACrB,KAAK,EAAE,MAAM,CAAC,MAAM;CACrB,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutation-id.d.ts","sourceRoot":"","sources":["../../src/types/mutation-id.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAKxC,eAAO,MAAM,UAAU;;;EAGrB,CAAC;AACH,MAAM,MAAM,UAAU,GAAG,OAAO,UAAU,CAAC,IAAI,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import * as Schema from "effect/Schema";
|
|
2
|
+
// The code below was converted to Effect Schema from:
|
|
3
|
+
// https://github.com/rocicorp/mono/blob/74273167af5d15ed07045e04165cb04d3983d44f/packages/zero-protocol/src/mutation-id.ts
|
|
4
|
+
export const MutationId = Schema.Struct({
|
|
5
|
+
id: Schema.Number,
|
|
6
|
+
clientID: Schema.String,
|
|
7
|
+
});
|
|
8
|
+
//# sourceMappingURL=mutation-id.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutation-id.js","sourceRoot":"","sources":["../../src/types/mutation-id.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AAExC,sDAAsD;AACtD,2HAA2H;AAE3H,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,CAAC;IACtC,EAAE,EAAE,MAAM,CAAC,MAAM;IACjB,QAAQ,EAAE,MAAM,CAAC,MAAM;CACxB,CAAC,CAAC"}
|