effect-zero 0.4.2 → 0.5.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/dist/client-transaction.d.ts +77 -7
- package/dist/client-transaction.d.ts.map +1 -1
- package/dist/client-transaction.js +11 -7
- package/dist/client-transaction.js.map +1 -1
- package/dist/client.d.ts +119 -7
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +7 -6
- package/dist/client.js.map +1 -1
- package/dist/internal/server-synchronization-context.d.ts +19 -0
- package/dist/internal/server-synchronization-context.d.ts.map +1 -0
- package/dist/internal/server-synchronization-context.js +46 -0
- package/dist/internal/server-synchronization-context.js.map +1 -0
- package/dist/internal/server.d.ts +5 -16
- package/dist/internal/server.d.ts.map +1 -1
- package/dist/internal/server.js +1 -38
- package/dist/internal/server.js.map +1 -1
- package/dist/internal/server.test.js +7 -8
- package/dist/internal/server.test.js.map +1 -1
- package/dist/internal/utils.d.ts +7 -0
- package/dist/internal/utils.d.ts.map +1 -1
- package/dist/internal/utils.js +7 -0
- package/dist/internal/utils.js.map +1 -1
- package/dist/mutators.d.ts +1 -1
- package/dist/mutators.d.ts.map +1 -1
- package/dist/mutators.js +1 -1
- package/dist/query.d.ts +3 -5
- package/dist/query.d.ts.map +1 -1
- package/dist/query.js +6 -12
- package/dist/query.js.map +1 -1
- package/dist/result.d.ts +15 -15
- package/dist/result.d.ts.map +1 -1
- package/dist/result.js +11 -11
- package/dist/result.js.map +1 -1
- package/dist/server-transaction.d.ts +142 -15
- package/dist/server-transaction.d.ts.map +1 -1
- package/dist/server-transaction.js +24 -19
- package/dist/server-transaction.js.map +1 -1
- package/dist/server.d.ts +247 -12
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +21 -18
- package/dist/server.js.map +1 -1
- package/dist/types/common.d.ts +1 -1
- package/dist/types/common.d.ts.map +1 -1
- package/dist/types/error.d.ts +69 -48
- package/dist/types/error.d.ts.map +1 -1
- package/dist/types/error.js +38 -30
- package/dist/types/error.js.map +1 -1
- package/dist/types/push.d.ts +149 -149
- package/dist/types/push.d.ts.map +1 -1
- package/dist/types/push.js +45 -40
- package/dist/types/push.js.map +1 -1
- package/dist/types/queries.d.ts +42 -42
- package/dist/types/queries.d.ts.map +1 -1
- package/dist/types/queries.js +7 -7
- package/dist/types/queries.js.map +1 -1
- package/dist/types.test.js +13 -15
- package/dist/types.test.js.map +1 -1
- package/package.json +5 -7
- package/src/client-transaction.ts +13 -11
- package/src/client.ts +17 -19
- package/src/internal/server-synchronization-context.ts +64 -0
- package/src/internal/server.ts +3 -59
- package/src/internal/utils.ts +8 -0
- package/src/mutators.ts +2 -2
- package/src/query.ts +8 -20
- package/src/result.ts +40 -37
- package/src/server-transaction.ts +32 -37
- package/src/server.ts +34 -37
- package/src/types/error.ts +8 -8
- package/src/types/push.ts +22 -22
- package/src/types/queries.ts +7 -7
package/src/types/push.ts
CHANGED
|
@@ -7,12 +7,12 @@ import { PushFailedBody } from "./error.js";
|
|
|
7
7
|
|
|
8
8
|
const PrimaryKey = Schema.Array(Schema.String);
|
|
9
9
|
|
|
10
|
-
const PrimaryKeyValue = Schema.Union(Schema.String, Schema.Number, Schema.Boolean);
|
|
10
|
+
const PrimaryKeyValue = Schema.Union([Schema.String, Schema.Number, Schema.Boolean]);
|
|
11
11
|
|
|
12
|
-
const PrimaryKeyValueRecord = Schema.Record(
|
|
12
|
+
const PrimaryKeyValueRecord = Schema.Record(Schema.String, PrimaryKeyValue);
|
|
13
13
|
|
|
14
|
-
const Value = Schema.Union(JsonSchema, Schema.Undefined);
|
|
15
|
-
const Row = Schema.Record(
|
|
14
|
+
const Value = Schema.Union([JsonSchema, Schema.Undefined]);
|
|
15
|
+
const Row = Schema.Record(Schema.String, Value);
|
|
16
16
|
|
|
17
17
|
const CRUD_MUTATION_NAME = "_zero_crud";
|
|
18
18
|
|
|
@@ -20,7 +20,7 @@ const CRUD_MUTATION_NAME = "_zero_crud";
|
|
|
20
20
|
const CLEANUP_RESULTS_MUTATION_NAME = "_zero_cleanupResults";
|
|
21
21
|
|
|
22
22
|
// biome-ignore lint/correctness/noUnusedVariables: borrowed code
|
|
23
|
-
const CleanupResultsArg = Schema.Union(
|
|
23
|
+
const CleanupResultsArg = Schema.Union([
|
|
24
24
|
// Legacy format (no type field) - treat as single
|
|
25
25
|
Schema.Struct({
|
|
26
26
|
clientGroupID: Schema.String,
|
|
@@ -40,7 +40,7 @@ const CleanupResultsArg = Schema.Union(
|
|
|
40
40
|
clientGroupID: Schema.String,
|
|
41
41
|
clientIDs: Schema.NonEmptyArray(Schema.String),
|
|
42
42
|
}),
|
|
43
|
-
);
|
|
43
|
+
]);
|
|
44
44
|
|
|
45
45
|
/**
|
|
46
46
|
* Inserts if entity with id does not already exist.
|
|
@@ -85,13 +85,13 @@ const DeleteOp = Schema.Struct({
|
|
|
85
85
|
value: PrimaryKeyValueRecord,
|
|
86
86
|
});
|
|
87
87
|
|
|
88
|
-
const CrudOp = Schema.Union(InsertOp, UpsertOp, UpdateOp, DeleteOp);
|
|
88
|
+
const CrudOp = Schema.Union([InsertOp, UpsertOp, UpdateOp, DeleteOp]);
|
|
89
89
|
|
|
90
90
|
const CrudArg = Schema.Struct({
|
|
91
91
|
ops: Schema.Array(CrudOp),
|
|
92
92
|
});
|
|
93
93
|
|
|
94
|
-
const CrudArgs = Schema.Tuple(CrudArg);
|
|
94
|
+
const CrudArgs = Schema.Tuple([CrudArg]);
|
|
95
95
|
|
|
96
96
|
const CrudMutation = Schema.Struct({
|
|
97
97
|
type: Schema.Literal("crud"),
|
|
@@ -111,7 +111,7 @@ const CustomMutation = Schema.Struct({
|
|
|
111
111
|
timestamp: Schema.Number,
|
|
112
112
|
});
|
|
113
113
|
|
|
114
|
-
export const Mutation = Schema.Union(CrudMutation, CustomMutation);
|
|
114
|
+
export const Mutation = Schema.Union([CrudMutation, CustomMutation]);
|
|
115
115
|
export type Mutation = typeof Mutation.Type;
|
|
116
116
|
|
|
117
117
|
export const PushBody = Schema.Struct({
|
|
@@ -133,7 +133,7 @@ export const PushBody = Schema.Struct({
|
|
|
133
133
|
export type PushBody = typeof PushBody.Type;
|
|
134
134
|
|
|
135
135
|
// biome-ignore lint/correctness/noUnusedVariables: borrowed code
|
|
136
|
-
const PushMessage = Schema.Tuple(Schema.Literal("push"), PushBody);
|
|
136
|
+
const PushMessage = Schema.Tuple([Schema.Literal("push"), PushBody]);
|
|
137
137
|
|
|
138
138
|
const MutationId = Schema.Struct({
|
|
139
139
|
id: Schema.Number,
|
|
@@ -150,11 +150,11 @@ export const AppError = Schema.Struct({
|
|
|
150
150
|
export type AppError = typeof AppError.Type;
|
|
151
151
|
|
|
152
152
|
export const ZeroError = Schema.Struct({
|
|
153
|
-
error: Schema.
|
|
153
|
+
error: Schema.Literals([
|
|
154
154
|
/** @deprecated push oooMutation errors are now represented as ['error', { ... }] messages */
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
),
|
|
155
|
+
"oooMutation",
|
|
156
|
+
"alreadyProcessed",
|
|
157
|
+
]),
|
|
158
158
|
details: Schema.optional(JsonSchema),
|
|
159
159
|
});
|
|
160
160
|
|
|
@@ -165,13 +165,13 @@ const MutationOk = Schema.Struct({
|
|
|
165
165
|
data: Schema.optional(JsonSchema),
|
|
166
166
|
});
|
|
167
167
|
|
|
168
|
-
const MutationError = Schema.Union(AppError, ZeroError);
|
|
168
|
+
const MutationError = Schema.Union([AppError, ZeroError]);
|
|
169
169
|
|
|
170
|
-
export const MutationResult = Schema.Union(
|
|
170
|
+
export const MutationResult = Schema.Union([
|
|
171
171
|
// We flip the original order here as otherwise values of type MutationError would get parsed as MutationOk with empty `data`
|
|
172
172
|
MutationError,
|
|
173
173
|
MutationOk,
|
|
174
|
-
);
|
|
174
|
+
]);
|
|
175
175
|
export type MutationResult = typeof MutationResult.Type;
|
|
176
176
|
|
|
177
177
|
export const MutationResponse = Schema.Struct({
|
|
@@ -233,18 +233,18 @@ const ZeroPusherError = Schema.Struct({
|
|
|
233
233
|
/**
|
|
234
234
|
* @deprecated push errors are now represented as ['error', { ... }] messages
|
|
235
235
|
*/
|
|
236
|
-
const PushError = Schema.Union(UnsupportedPushVersion, UnsupportedSchemaVersion, HttpError, ZeroPusherError);
|
|
236
|
+
const PushError = Schema.Union([UnsupportedPushVersion, UnsupportedSchemaVersion, HttpError, ZeroPusherError]);
|
|
237
237
|
|
|
238
|
-
const PushResponseBody = Schema.Union(PushOk, PushError);
|
|
238
|
+
const PushResponseBody = Schema.Union([PushOk, PushError]);
|
|
239
239
|
|
|
240
|
-
export const PushResponse = Schema.Union(PushResponseBody, PushFailedBody);
|
|
240
|
+
export const PushResponse = Schema.Union([PushResponseBody, PushFailedBody]);
|
|
241
241
|
export type PushResponse = typeof PushResponse.Type;
|
|
242
242
|
|
|
243
243
|
// biome-ignore lint/correctness/noUnusedVariables: borrowed code
|
|
244
|
-
const PushResponseMessage = Schema.Tuple(Schema.Literal("pushResponse"), PushResponseBody);
|
|
244
|
+
const PushResponseMessage = Schema.Tuple([Schema.Literal("pushResponse"), PushResponseBody]);
|
|
245
245
|
|
|
246
246
|
// biome-ignore lint/correctness/noUnusedVariables: borrowed code
|
|
247
|
-
const AckMutationResponsesMessage = Schema.Tuple(Schema.Literal("ackMutationResponses"), MutationId);
|
|
247
|
+
const AckMutationResponsesMessage = Schema.Tuple([Schema.Literal("ackMutationResponses"), MutationId]);
|
|
248
248
|
|
|
249
249
|
/**
|
|
250
250
|
* The schema for the querystring parameters of the custom push endpoint.
|
package/src/types/queries.ts
CHANGED
|
@@ -39,18 +39,18 @@ const ParseErroredQuery = Schema.Struct({
|
|
|
39
39
|
details: Schema.optional(JsonSchema),
|
|
40
40
|
});
|
|
41
41
|
|
|
42
|
-
const ErroredQuery = Schema.Union(AppErroredQuery, ParseErroredQuery);
|
|
42
|
+
const ErroredQuery = Schema.Union([AppErroredQuery, ParseErroredQuery]);
|
|
43
43
|
|
|
44
|
-
const TransformResponseBody = Schema.Array(Schema.Union(TransformedQuery, ErroredQuery));
|
|
44
|
+
const TransformResponseBody = Schema.Array(Schema.Union([TransformedQuery, ErroredQuery]));
|
|
45
45
|
|
|
46
|
-
export const TransformRequestMessage = Schema.Tuple(Schema.Literal("transform"), TransformRequestBody);
|
|
46
|
+
export const TransformRequestMessage = Schema.Tuple([Schema.Literal("transform"), TransformRequestBody]);
|
|
47
47
|
export type TransformRequestMessage = typeof TransformRequestMessage.Type;
|
|
48
48
|
|
|
49
49
|
// biome-ignore lint/correctness/noUnusedVariables: borrowed code
|
|
50
|
-
const TransformErrorMessage = Schema.Tuple(Schema.Literal("transformError"), Schema.Array(ErroredQuery));
|
|
50
|
+
const TransformErrorMessage = Schema.Tuple([Schema.Literal("transformError"), Schema.Array(ErroredQuery)]);
|
|
51
51
|
|
|
52
|
-
const TransformFailedMessage = Schema.Tuple(Schema.Literal("transformFailed"), TransformFailedBody);
|
|
52
|
+
const TransformFailedMessage = Schema.Tuple([Schema.Literal("transformFailed"), TransformFailedBody]);
|
|
53
53
|
|
|
54
|
-
const TransformOkMessage = Schema.Tuple(Schema.Literal("transformed"), TransformResponseBody);
|
|
54
|
+
const TransformOkMessage = Schema.Tuple([Schema.Literal("transformed"), TransformResponseBody]);
|
|
55
55
|
|
|
56
|
-
export const TransformResponseMessage = Schema.Union(TransformOkMessage, TransformFailedMessage);
|
|
56
|
+
export const TransformResponseMessage = Schema.Union([TransformOkMessage, TransformFailedMessage]);
|