@proseql/rpc 0.1.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/LICENSE +21 -0
- package/dist/index.d.ts +33 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +61 -0
- package/dist/index.js.map +1 -0
- package/dist/rpc-errors.d.ts +208 -0
- package/dist/rpc-errors.d.ts.map +1 -0
- package/dist/rpc-errors.js +159 -0
- package/dist/rpc-errors.js.map +1 -0
- package/dist/rpc-group.d.ts +819 -0
- package/dist/rpc-group.d.ts.map +1 -0
- package/dist/rpc-group.js +614 -0
- package/dist/rpc-group.js.map +1 -0
- package/dist/rpc-handlers.d.ts +247 -0
- package/dist/rpc-handlers.d.ts.map +1 -0
- package/dist/rpc-handlers.js +266 -0
- package/dist/rpc-handlers.js.map +1 -0
- package/dist/rpc-schemas.d.ts +382 -0
- package/dist/rpc-schemas.d.ts.map +1 -0
- package/dist/rpc-schemas.js +382 -0
- package/dist/rpc-schemas.js.map +1 -0
- package/package.json +50 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rpc-group.d.ts","sourceRoot":"","sources":["../src/rpc-group.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,KAAK,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AACtE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EACN,4BAA4B,EAC5B,uBAAuB,EACvB,qBAAqB,EACrB,eAAe,EACf,mBAAmB,EACnB,oBAAoB,EACpB,2BAA2B,EAC3B,qBAAqB,EACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACN,sBAAsB,EAEtB,uBAAuB,EACvB,sBAAsB,EACtB,mBAAmB,EACnB,uBAAuB,EACvB,sBAAsB,EACtB,mBAAmB,EAEnB,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;AAED;;;;;;;;;GASG;AACH,wBAAgB,kBAAkB,CACjC,cAAc,SAAS,MAAM,EAC7B,YAAY,SAAS,MAAM,CAAC,MAAM,CAAC,GAAG,EAEtC,cAAc,EAAE,cAAc,EAC9B,YAAY,EAAE,YAAY,GACxB,wBAAwB,CAAC,cAAc,EAAE,YAAY,CAAC,CAiCxD;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiEG;AACH,wBAAgB,YAAY,CAAC,MAAM,SAAS,cAAc,EACzD,MAAM,EAAE,MAAM,GACZ,kBAAkB,CAAC,MAAM,CAAC,CAe5B;AAMD;;GAEG;AACH,KAAK,uBAAuB,CAAC,CAAC,SAAS,gBAAgB,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC;AAEvE;;;GAGG;AACH,MAAM,MAAM,kBAAkB,CAAC,MAAM,SAAS,cAAc,IAAI;IAC/D,QAAQ,EAAE,CAAC,IAAI,MAAM,MAAM,GAAG,wBAAwB,CACrD,CAAC,GAAG,MAAM,EACV,uBAAuB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,CAAC,GAAG,GACzD,uBAAuB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,GAClC,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,CACzC;CACD,CAAC;AAMF,YAAY,EAAE,cAAc,EAAE,gBAAgB,EAAE,CAAC;AAGjD,OAAO,EAAE,SAAS,EAAE,CAAC"}
|
|
@@ -0,0 +1,614 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* RPC Group derivation for proseql databases.
|
|
3
|
+
*
|
|
4
|
+
* Derives RPC request schemas and router from a DatabaseConfig, creating typed
|
|
5
|
+
* procedures for each collection. Each procedure's payload, success, and error
|
|
6
|
+
* schemas are derived from the collection's Effect Schema.
|
|
7
|
+
*
|
|
8
|
+
* Uses `Schema.TaggedRequest` pattern as required by @effect/rpc v0.51.x.
|
|
9
|
+
*
|
|
10
|
+
* @module
|
|
11
|
+
*/
|
|
12
|
+
import { Rpc, RpcRouter } from "@effect/rpc";
|
|
13
|
+
import { Schema } from "effect";
|
|
14
|
+
import { DanglingReferenceErrorSchema, DuplicateKeyErrorSchema, ForeignKeyErrorSchema, HookErrorSchema, NotFoundErrorSchema, OperationErrorSchema, UniqueConstraintErrorSchema, ValidationErrorSchema, } from "./rpc-errors.js";
|
|
15
|
+
import { AggregatePayloadSchema, AggregateResultSchema, CreateManyPayloadSchema, CreateManyResultSchema, CreatePayloadSchema, DeleteManyPayloadSchema, DeleteManyResultSchema, DeletePayloadSchema, GroupedAggregateResultSchema, QueryPayloadSchema, UpdateManyPayloadSchema, UpdateManyResultSchema, UpdatePayloadSchema, UpsertManyPayloadSchema, UpsertManyResultSchema, UpsertPayloadSchema, UpsertResultSchema, } from "./rpc-schemas.js";
|
|
16
|
+
// ============================================================================
|
|
17
|
+
// TaggedRequest Schema Factories
|
|
18
|
+
// ============================================================================
|
|
19
|
+
/**
|
|
20
|
+
* Creates a FindById TaggedRequest class for a collection.
|
|
21
|
+
*
|
|
22
|
+
* The returned class extends Schema.TaggedRequest and can be used to:
|
|
23
|
+
* 1. Create request instances: new FindByIdRequest({ id: "123" })
|
|
24
|
+
* 2. Define RPC handlers: Rpc.effect(FindByIdRequest, (req) => ...)
|
|
25
|
+
* 3. Build RPC routers: RpcRouter.make(findByIdRpc, ...)
|
|
26
|
+
*
|
|
27
|
+
* @param collectionName - The name of the collection (used as the request _tag prefix)
|
|
28
|
+
* @param entitySchema - The Effect Schema for the collection's entities
|
|
29
|
+
* @returns A TaggedRequest class for findById operations
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* const BookSchema = Schema.Struct({
|
|
34
|
+
* id: Schema.String,
|
|
35
|
+
* title: Schema.String,
|
|
36
|
+
* })
|
|
37
|
+
*
|
|
38
|
+
* const FindByIdRequest = makeFindByIdRequest("books", BookSchema)
|
|
39
|
+
* // _tag: "books.findById"
|
|
40
|
+
* // payload: { id: string }
|
|
41
|
+
* // success: Book
|
|
42
|
+
* // failure: NotFoundError
|
|
43
|
+
* ```
|
|
44
|
+
*/
|
|
45
|
+
export function makeFindByIdRequest(collectionName, entitySchema) {
|
|
46
|
+
// Create a TaggedRequest class dynamically
|
|
47
|
+
// The class extends Schema.TaggedRequest with the collection-specific tag
|
|
48
|
+
const RequestClass = class FindByIdRequest extends Schema.TaggedRequest()(`${collectionName}.findById`, {
|
|
49
|
+
failure: NotFoundErrorSchema,
|
|
50
|
+
success: entitySchema,
|
|
51
|
+
payload: {
|
|
52
|
+
id: Schema.String,
|
|
53
|
+
},
|
|
54
|
+
}) {
|
|
55
|
+
};
|
|
56
|
+
return RequestClass;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Union schema for query errors (DanglingReferenceError | ValidationError).
|
|
60
|
+
*/
|
|
61
|
+
const QueryErrorUnionSchema = Schema.Union(DanglingReferenceErrorSchema, ValidationErrorSchema);
|
|
62
|
+
/**
|
|
63
|
+
* Union schema for create errors (ValidationError | DuplicateKeyError | UniqueConstraintError | ForeignKeyError | HookError).
|
|
64
|
+
*/
|
|
65
|
+
const CreateErrorUnionSchema = Schema.Union(ValidationErrorSchema, DuplicateKeyErrorSchema, UniqueConstraintErrorSchema, ForeignKeyErrorSchema, HookErrorSchema);
|
|
66
|
+
/**
|
|
67
|
+
* Union schema for update errors (ValidationError | NotFoundError | UniqueConstraintError | HookError).
|
|
68
|
+
*/
|
|
69
|
+
const UpdateErrorUnionSchema = Schema.Union(ValidationErrorSchema, NotFoundErrorSchema, UniqueConstraintErrorSchema, HookErrorSchema);
|
|
70
|
+
/**
|
|
71
|
+
* Union schema for delete errors (NotFoundError | HookError).
|
|
72
|
+
*/
|
|
73
|
+
const DeleteErrorUnionSchema = Schema.Union(NotFoundErrorSchema, HookErrorSchema);
|
|
74
|
+
/**
|
|
75
|
+
* Union schema for createMany errors (ValidationError | DuplicateKeyError | UniqueConstraintError | ForeignKeyError | HookError).
|
|
76
|
+
* Same as CreateErrorUnionSchema.
|
|
77
|
+
*/
|
|
78
|
+
const CreateManyErrorUnionSchema = CreateErrorUnionSchema;
|
|
79
|
+
/**
|
|
80
|
+
* Union schema for updateMany errors (ValidationError | ForeignKeyError | HookError | UniqueConstraintError).
|
|
81
|
+
*/
|
|
82
|
+
const UpdateManyErrorUnionSchema = Schema.Union(ValidationErrorSchema, ForeignKeyErrorSchema, HookErrorSchema, UniqueConstraintErrorSchema);
|
|
83
|
+
/**
|
|
84
|
+
* Union schema for deleteMany errors (OperationError | ForeignKeyError | HookError).
|
|
85
|
+
*/
|
|
86
|
+
const DeleteManyErrorUnionSchema = Schema.Union(OperationErrorSchema, ForeignKeyErrorSchema, HookErrorSchema);
|
|
87
|
+
/**
|
|
88
|
+
* Union schema for upsert errors (ValidationError | ForeignKeyError | HookError | UniqueConstraintError).
|
|
89
|
+
*/
|
|
90
|
+
const UpsertErrorUnionSchema = Schema.Union(ValidationErrorSchema, ForeignKeyErrorSchema, HookErrorSchema, UniqueConstraintErrorSchema);
|
|
91
|
+
/**
|
|
92
|
+
* Union schema for upsertMany errors (ValidationError | ForeignKeyError | HookError | UniqueConstraintError).
|
|
93
|
+
* Same as UpsertErrorUnionSchema.
|
|
94
|
+
*/
|
|
95
|
+
const UpsertManyErrorUnionSchema = UpsertErrorUnionSchema;
|
|
96
|
+
/**
|
|
97
|
+
* Creates a Query TaggedRequest class for a collection.
|
|
98
|
+
*
|
|
99
|
+
* The returned class extends Schema.TaggedRequest and can be used to:
|
|
100
|
+
* 1. Create request instances: new QueryRequest({ where: { ... } })
|
|
101
|
+
* 2. Define RPC handlers: Rpc.effect(QueryRequest, (req) => ...)
|
|
102
|
+
* 3. Build RPC routers: RpcRouter.make(queryRpc, ...)
|
|
103
|
+
*
|
|
104
|
+
* @param collectionName - The name of the collection (used as the request _tag prefix)
|
|
105
|
+
* @param entitySchema - The Effect Schema for the collection's entities
|
|
106
|
+
* @returns A TaggedRequest class for query operations
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* ```ts
|
|
110
|
+
* const BookSchema = Schema.Struct({
|
|
111
|
+
* id: Schema.String,
|
|
112
|
+
* title: Schema.String,
|
|
113
|
+
* })
|
|
114
|
+
*
|
|
115
|
+
* const QueryRequest = makeQueryRequest("books", BookSchema)
|
|
116
|
+
* // _tag: "books.query"
|
|
117
|
+
* // payload: QueryPayload
|
|
118
|
+
* // success: ReadonlyArray<Book>
|
|
119
|
+
* // failure: DanglingReferenceError | ValidationError
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
export function makeQueryRequest(collectionName, entitySchema) {
|
|
123
|
+
// Create a TaggedRequest class dynamically
|
|
124
|
+
// The class extends Schema.TaggedRequest with the collection-specific tag
|
|
125
|
+
const RequestClass = class QueryRequest extends Schema.TaggedRequest()(`${collectionName}.query`, {
|
|
126
|
+
failure: QueryErrorUnionSchema,
|
|
127
|
+
success: Schema.Array(entitySchema),
|
|
128
|
+
payload: {
|
|
129
|
+
where: QueryPayloadSchema.fields.where,
|
|
130
|
+
sort: QueryPayloadSchema.fields.sort,
|
|
131
|
+
select: QueryPayloadSchema.fields.select,
|
|
132
|
+
populate: QueryPayloadSchema.fields.populate,
|
|
133
|
+
limit: QueryPayloadSchema.fields.limit,
|
|
134
|
+
offset: QueryPayloadSchema.fields.offset,
|
|
135
|
+
cursor: QueryPayloadSchema.fields.cursor,
|
|
136
|
+
},
|
|
137
|
+
}) {
|
|
138
|
+
};
|
|
139
|
+
return RequestClass;
|
|
140
|
+
}
|
|
141
|
+
// ============================================================================
|
|
142
|
+
// Streaming Query Request Factory
|
|
143
|
+
// ============================================================================
|
|
144
|
+
/**
|
|
145
|
+
* Creates a streaming Query TaggedRequest class for a collection.
|
|
146
|
+
*
|
|
147
|
+
* Unlike makeQueryRequest which returns an array-collecting RPC,
|
|
148
|
+
* this creates an RPC that streams results incrementally, allowing
|
|
149
|
+
* large result sets to flow through the transport without buffering.
|
|
150
|
+
*
|
|
151
|
+
* Uses `Rpc.StreamRequest` which marks the request for streaming handling.
|
|
152
|
+
* Handlers must return a `Stream<Entity, Error>` instead of `Effect<Array<Entity>, Error>`.
|
|
153
|
+
*
|
|
154
|
+
* @param collectionName - The name of the collection (used as the request _tag prefix)
|
|
155
|
+
* @param entitySchema - The Effect Schema for the collection's entities
|
|
156
|
+
* @returns A StreamRequest class for streaming query operations
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* ```ts
|
|
160
|
+
* const BookSchema = Schema.Struct({
|
|
161
|
+
* id: Schema.String,
|
|
162
|
+
* title: Schema.String,
|
|
163
|
+
* })
|
|
164
|
+
*
|
|
165
|
+
* const QueryStreamRequest = makeQueryStreamRequest("books", BookSchema)
|
|
166
|
+
* // _tag: "books.queryStream"
|
|
167
|
+
* // payload: QueryPayload
|
|
168
|
+
* // success: Stream<Book, DanglingReferenceError | ValidationError>
|
|
169
|
+
*
|
|
170
|
+
* // Use with Rpc.stream to create a handler
|
|
171
|
+
* const handler = Rpc.stream(QueryStreamRequest, (req) =>
|
|
172
|
+
* db.books.query({ where: req.where, sort: req.sort })
|
|
173
|
+
* )
|
|
174
|
+
* ```
|
|
175
|
+
*/
|
|
176
|
+
export function makeQueryStreamRequest(collectionName, entitySchema) {
|
|
177
|
+
// Use Rpc.StreamRequest to create a streaming RPC schema
|
|
178
|
+
// The handler for this request must return a Stream, not an Effect
|
|
179
|
+
const RequestClass = Rpc.StreamRequest()(`${collectionName}.queryStream`, {
|
|
180
|
+
failure: QueryErrorUnionSchema,
|
|
181
|
+
success: entitySchema,
|
|
182
|
+
payload: {
|
|
183
|
+
where: QueryPayloadSchema.fields.where,
|
|
184
|
+
sort: QueryPayloadSchema.fields.sort,
|
|
185
|
+
select: QueryPayloadSchema.fields.select,
|
|
186
|
+
populate: QueryPayloadSchema.fields.populate,
|
|
187
|
+
limit: QueryPayloadSchema.fields.limit,
|
|
188
|
+
offset: QueryPayloadSchema.fields.offset,
|
|
189
|
+
cursor: QueryPayloadSchema.fields.cursor,
|
|
190
|
+
streamingOptions: QueryPayloadSchema.fields.streamingOptions,
|
|
191
|
+
},
|
|
192
|
+
});
|
|
193
|
+
return RequestClass;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Creates a Create TaggedRequest class for a collection.
|
|
197
|
+
*
|
|
198
|
+
* The returned class extends Schema.TaggedRequest and can be used to:
|
|
199
|
+
* 1. Create request instances: new CreateRequest({ data: { ... } })
|
|
200
|
+
* 2. Define RPC handlers: Rpc.effect(CreateRequest, (req) => ...)
|
|
201
|
+
* 3. Build RPC routers: RpcRouter.make(createRpc, ...)
|
|
202
|
+
*
|
|
203
|
+
* @param collectionName - The name of the collection (used as the request _tag prefix)
|
|
204
|
+
* @param entitySchema - The Effect Schema for the collection's entities
|
|
205
|
+
* @returns A TaggedRequest class for create operations
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* ```ts
|
|
209
|
+
* const BookSchema = Schema.Struct({
|
|
210
|
+
* id: Schema.String,
|
|
211
|
+
* title: Schema.String,
|
|
212
|
+
* })
|
|
213
|
+
*
|
|
214
|
+
* const CreateRequest = makeCreateRequest("books", BookSchema)
|
|
215
|
+
* // _tag: "books.create"
|
|
216
|
+
* // payload: { data: Record<string, unknown> }
|
|
217
|
+
* // success: Book
|
|
218
|
+
* // failure: ValidationError | DuplicateKeyError | UniqueConstraintError | ForeignKeyError | HookError
|
|
219
|
+
* ```
|
|
220
|
+
*/
|
|
221
|
+
export function makeCreateRequest(collectionName, entitySchema) {
|
|
222
|
+
// Create a TaggedRequest class dynamically
|
|
223
|
+
// The class extends Schema.TaggedRequest with the collection-specific tag
|
|
224
|
+
const RequestClass = class CreateRequest extends Schema.TaggedRequest()(`${collectionName}.create`, {
|
|
225
|
+
failure: CreateErrorUnionSchema,
|
|
226
|
+
success: entitySchema,
|
|
227
|
+
payload: {
|
|
228
|
+
data: CreatePayloadSchema.fields.data,
|
|
229
|
+
},
|
|
230
|
+
}) {
|
|
231
|
+
};
|
|
232
|
+
return RequestClass;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Creates an Update TaggedRequest class for a collection.
|
|
236
|
+
*
|
|
237
|
+
* The returned class extends Schema.TaggedRequest and can be used to:
|
|
238
|
+
* 1. Create request instances: new UpdateRequest({ id: "123", updates: { ... } })
|
|
239
|
+
* 2. Define RPC handlers: Rpc.effect(UpdateRequest, (req) => ...)
|
|
240
|
+
* 3. Build RPC routers: RpcRouter.make(updateRpc, ...)
|
|
241
|
+
*
|
|
242
|
+
* @param collectionName - The name of the collection (used as the request _tag prefix)
|
|
243
|
+
* @param entitySchema - The Effect Schema for the collection's entities
|
|
244
|
+
* @returns A TaggedRequest class for update operations
|
|
245
|
+
*
|
|
246
|
+
* @example
|
|
247
|
+
* ```ts
|
|
248
|
+
* const BookSchema = Schema.Struct({
|
|
249
|
+
* id: Schema.String,
|
|
250
|
+
* title: Schema.String,
|
|
251
|
+
* })
|
|
252
|
+
*
|
|
253
|
+
* const UpdateRequest = makeUpdateRequest("books", BookSchema)
|
|
254
|
+
* // _tag: "books.update"
|
|
255
|
+
* // payload: { id: string, updates: Record<string, unknown> }
|
|
256
|
+
* // success: Book
|
|
257
|
+
* // failure: ValidationError | NotFoundError | UniqueConstraintError | HookError
|
|
258
|
+
* ```
|
|
259
|
+
*/
|
|
260
|
+
export function makeUpdateRequest(collectionName, entitySchema) {
|
|
261
|
+
// Create a TaggedRequest class dynamically
|
|
262
|
+
// The class extends Schema.TaggedRequest with the collection-specific tag
|
|
263
|
+
const RequestClass = class UpdateRequest extends Schema.TaggedRequest()(`${collectionName}.update`, {
|
|
264
|
+
failure: UpdateErrorUnionSchema,
|
|
265
|
+
success: entitySchema,
|
|
266
|
+
payload: {
|
|
267
|
+
id: UpdatePayloadSchema.fields.id,
|
|
268
|
+
updates: UpdatePayloadSchema.fields.updates,
|
|
269
|
+
},
|
|
270
|
+
}) {
|
|
271
|
+
};
|
|
272
|
+
return RequestClass;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Creates a Delete TaggedRequest class for a collection.
|
|
276
|
+
*
|
|
277
|
+
* The returned class extends Schema.TaggedRequest and can be used to:
|
|
278
|
+
* 1. Create request instances: new DeleteRequest({ id: "123" })
|
|
279
|
+
* 2. Define RPC handlers: Rpc.effect(DeleteRequest, (req) => ...)
|
|
280
|
+
* 3. Build RPC routers: RpcRouter.make(deleteRpc, ...)
|
|
281
|
+
*
|
|
282
|
+
* @param collectionName - The name of the collection (used as the request _tag prefix)
|
|
283
|
+
* @param entitySchema - The Effect Schema for the collection's entities
|
|
284
|
+
* @returns A TaggedRequest class for delete operations
|
|
285
|
+
*
|
|
286
|
+
* @example
|
|
287
|
+
* ```ts
|
|
288
|
+
* const BookSchema = Schema.Struct({
|
|
289
|
+
* id: Schema.String,
|
|
290
|
+
* title: Schema.String,
|
|
291
|
+
* })
|
|
292
|
+
*
|
|
293
|
+
* const DeleteRequest = makeDeleteRequest("books", BookSchema)
|
|
294
|
+
* // _tag: "books.delete"
|
|
295
|
+
* // payload: { id: string }
|
|
296
|
+
* // success: Book
|
|
297
|
+
* // failure: NotFoundError | HookError
|
|
298
|
+
* ```
|
|
299
|
+
*/
|
|
300
|
+
export function makeDeleteRequest(collectionName, entitySchema) {
|
|
301
|
+
// Create a TaggedRequest class dynamically
|
|
302
|
+
// The class extends Schema.TaggedRequest with the collection-specific tag
|
|
303
|
+
const RequestClass = class DeleteRequest extends Schema.TaggedRequest()(`${collectionName}.delete`, {
|
|
304
|
+
failure: DeleteErrorUnionSchema,
|
|
305
|
+
success: entitySchema,
|
|
306
|
+
payload: {
|
|
307
|
+
id: DeletePayloadSchema.fields.id,
|
|
308
|
+
},
|
|
309
|
+
}) {
|
|
310
|
+
};
|
|
311
|
+
return RequestClass;
|
|
312
|
+
}
|
|
313
|
+
/**
|
|
314
|
+
* Union schema for aggregate results (AggregateResult | GroupedAggregateResult).
|
|
315
|
+
* The aggregate operation never fails, so we use Schema.Never for failure.
|
|
316
|
+
*/
|
|
317
|
+
const AggregateResultUnionSchema = Schema.Union(AggregateResultSchema, GroupedAggregateResultSchema);
|
|
318
|
+
/**
|
|
319
|
+
* Creates an Aggregate TaggedRequest class for a collection.
|
|
320
|
+
*
|
|
321
|
+
* The returned class extends Schema.TaggedRequest and can be used to:
|
|
322
|
+
* 1. Create request instances: new AggregateRequest({ count: true })
|
|
323
|
+
* 2. Define RPC handlers: Rpc.effect(AggregateRequest, (req) => ...)
|
|
324
|
+
* 3. Build RPC routers: RpcRouter.make(aggregateRpc, ...)
|
|
325
|
+
*
|
|
326
|
+
* @param collectionName - The name of the collection (used as the request _tag prefix)
|
|
327
|
+
* @returns A TaggedRequest class for aggregate operations
|
|
328
|
+
*
|
|
329
|
+
* @example
|
|
330
|
+
* ```ts
|
|
331
|
+
* const AggregateRequest = makeAggregateRequest("books")
|
|
332
|
+
* // _tag: "books.aggregate"
|
|
333
|
+
* // payload: AggregateConfig
|
|
334
|
+
* // success: AggregateResult | GroupedAggregateResult
|
|
335
|
+
* // failure: never (aggregate operations cannot fail)
|
|
336
|
+
* ```
|
|
337
|
+
*/
|
|
338
|
+
export function makeAggregateRequest(collectionName) {
|
|
339
|
+
// Create a TaggedRequest class dynamically
|
|
340
|
+
// The class extends Schema.TaggedRequest with the collection-specific tag
|
|
341
|
+
const RequestClass = class AggregateRequest extends Schema.TaggedRequest()(`${collectionName}.aggregate`, {
|
|
342
|
+
failure: Schema.Never,
|
|
343
|
+
success: AggregateResultUnionSchema,
|
|
344
|
+
payload: {
|
|
345
|
+
where: AggregatePayloadSchema.fields.where,
|
|
346
|
+
groupBy: AggregatePayloadSchema.fields.groupBy,
|
|
347
|
+
count: AggregatePayloadSchema.fields.count,
|
|
348
|
+
sum: AggregatePayloadSchema.fields.sum,
|
|
349
|
+
avg: AggregatePayloadSchema.fields.avg,
|
|
350
|
+
min: AggregatePayloadSchema.fields.min,
|
|
351
|
+
max: AggregatePayloadSchema.fields.max,
|
|
352
|
+
},
|
|
353
|
+
}) {
|
|
354
|
+
};
|
|
355
|
+
return RequestClass;
|
|
356
|
+
}
|
|
357
|
+
// ============================================================================
|
|
358
|
+
// Batch Operation TaggedRequest Schema Factories
|
|
359
|
+
// ============================================================================
|
|
360
|
+
/**
|
|
361
|
+
* Creates a CreateMany TaggedRequest class for a collection.
|
|
362
|
+
*
|
|
363
|
+
* @param collectionName - The name of the collection (used as the request _tag prefix)
|
|
364
|
+
* @returns A TaggedRequest class for createMany operations
|
|
365
|
+
*
|
|
366
|
+
* @example
|
|
367
|
+
* ```ts
|
|
368
|
+
* const CreateManyRequest = makeCreateManyRequest("books")
|
|
369
|
+
* // _tag: "books.createMany"
|
|
370
|
+
* // payload: { data: Array<Record<string, unknown>>, options?: { skipDuplicates?: boolean } }
|
|
371
|
+
* // success: CreateManyResult
|
|
372
|
+
* // failure: ValidationError | DuplicateKeyError | UniqueConstraintError | ForeignKeyError | HookError
|
|
373
|
+
* ```
|
|
374
|
+
*/
|
|
375
|
+
export function makeCreateManyRequest(collectionName) {
|
|
376
|
+
const RequestClass = class CreateManyRequest extends Schema.TaggedRequest()(`${collectionName}.createMany`, {
|
|
377
|
+
failure: CreateManyErrorUnionSchema,
|
|
378
|
+
success: CreateManyResultSchema,
|
|
379
|
+
payload: {
|
|
380
|
+
data: CreateManyPayloadSchema.fields.data,
|
|
381
|
+
options: CreateManyPayloadSchema.fields.options,
|
|
382
|
+
},
|
|
383
|
+
}) {
|
|
384
|
+
};
|
|
385
|
+
return RequestClass;
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Creates an UpdateMany TaggedRequest class for a collection.
|
|
389
|
+
*
|
|
390
|
+
* @param collectionName - The name of the collection (used as the request _tag prefix)
|
|
391
|
+
* @returns A TaggedRequest class for updateMany operations
|
|
392
|
+
*
|
|
393
|
+
* @example
|
|
394
|
+
* ```ts
|
|
395
|
+
* const UpdateManyRequest = makeUpdateManyRequest("books")
|
|
396
|
+
* // _tag: "books.updateMany"
|
|
397
|
+
* // payload: { where: Record<string, unknown>, updates: Record<string, unknown> }
|
|
398
|
+
* // success: UpdateManyResult
|
|
399
|
+
* // failure: ValidationError | ForeignKeyError | HookError | UniqueConstraintError
|
|
400
|
+
* ```
|
|
401
|
+
*/
|
|
402
|
+
export function makeUpdateManyRequest(collectionName) {
|
|
403
|
+
const RequestClass = class UpdateManyRequest extends Schema.TaggedRequest()(`${collectionName}.updateMany`, {
|
|
404
|
+
failure: UpdateManyErrorUnionSchema,
|
|
405
|
+
success: UpdateManyResultSchema,
|
|
406
|
+
payload: {
|
|
407
|
+
where: UpdateManyPayloadSchema.fields.where,
|
|
408
|
+
updates: UpdateManyPayloadSchema.fields.updates,
|
|
409
|
+
},
|
|
410
|
+
}) {
|
|
411
|
+
};
|
|
412
|
+
return RequestClass;
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* Creates a DeleteMany TaggedRequest class for a collection.
|
|
416
|
+
*
|
|
417
|
+
* @param collectionName - The name of the collection (used as the request _tag prefix)
|
|
418
|
+
* @returns A TaggedRequest class for deleteMany operations
|
|
419
|
+
*
|
|
420
|
+
* @example
|
|
421
|
+
* ```ts
|
|
422
|
+
* const DeleteManyRequest = makeDeleteManyRequest("books")
|
|
423
|
+
* // _tag: "books.deleteMany"
|
|
424
|
+
* // payload: { where: Record<string, unknown>, options?: { limit?: number } }
|
|
425
|
+
* // success: DeleteManyResult
|
|
426
|
+
* // failure: OperationError | ForeignKeyError | HookError
|
|
427
|
+
* ```
|
|
428
|
+
*/
|
|
429
|
+
export function makeDeleteManyRequest(collectionName) {
|
|
430
|
+
const RequestClass = class DeleteManyRequest extends Schema.TaggedRequest()(`${collectionName}.deleteMany`, {
|
|
431
|
+
failure: DeleteManyErrorUnionSchema,
|
|
432
|
+
success: DeleteManyResultSchema,
|
|
433
|
+
payload: {
|
|
434
|
+
where: DeleteManyPayloadSchema.fields.where,
|
|
435
|
+
options: DeleteManyPayloadSchema.fields.options,
|
|
436
|
+
},
|
|
437
|
+
}) {
|
|
438
|
+
};
|
|
439
|
+
return RequestClass;
|
|
440
|
+
}
|
|
441
|
+
/**
|
|
442
|
+
* Creates an Upsert TaggedRequest class for a collection.
|
|
443
|
+
*
|
|
444
|
+
* @param collectionName - The name of the collection (used as the request _tag prefix)
|
|
445
|
+
* @returns A TaggedRequest class for upsert operations
|
|
446
|
+
*
|
|
447
|
+
* @example
|
|
448
|
+
* ```ts
|
|
449
|
+
* const UpsertRequest = makeUpsertRequest("books")
|
|
450
|
+
* // _tag: "books.upsert"
|
|
451
|
+
* // payload: { where: Record<string, unknown>, create: Record<string, unknown>, update: Record<string, unknown> }
|
|
452
|
+
* // success: UpsertResult
|
|
453
|
+
* // failure: ValidationError | ForeignKeyError | HookError | UniqueConstraintError
|
|
454
|
+
* ```
|
|
455
|
+
*/
|
|
456
|
+
export function makeUpsertRequest(collectionName) {
|
|
457
|
+
const RequestClass = class UpsertRequest extends Schema.TaggedRequest()(`${collectionName}.upsert`, {
|
|
458
|
+
failure: UpsertErrorUnionSchema,
|
|
459
|
+
success: UpsertResultSchema,
|
|
460
|
+
payload: {
|
|
461
|
+
where: UpsertPayloadSchema.fields.where,
|
|
462
|
+
create: UpsertPayloadSchema.fields.create,
|
|
463
|
+
update: UpsertPayloadSchema.fields.update,
|
|
464
|
+
},
|
|
465
|
+
}) {
|
|
466
|
+
};
|
|
467
|
+
return RequestClass;
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* Creates an UpsertMany TaggedRequest class for a collection.
|
|
471
|
+
*
|
|
472
|
+
* @param collectionName - The name of the collection (used as the request _tag prefix)
|
|
473
|
+
* @returns A TaggedRequest class for upsertMany operations
|
|
474
|
+
*
|
|
475
|
+
* @example
|
|
476
|
+
* ```ts
|
|
477
|
+
* const UpsertManyRequest = makeUpsertManyRequest("books")
|
|
478
|
+
* // _tag: "books.upsertMany"
|
|
479
|
+
* // payload: { data: Array<{ where, create, update }> }
|
|
480
|
+
* // success: UpsertManyResult
|
|
481
|
+
* // failure: ValidationError | ForeignKeyError | HookError | UniqueConstraintError
|
|
482
|
+
* ```
|
|
483
|
+
*/
|
|
484
|
+
export function makeUpsertManyRequest(collectionName) {
|
|
485
|
+
const RequestClass = class UpsertManyRequest extends Schema.TaggedRequest()(`${collectionName}.upsertMany`, {
|
|
486
|
+
failure: UpsertManyErrorUnionSchema,
|
|
487
|
+
success: UpsertManyResultSchema,
|
|
488
|
+
payload: {
|
|
489
|
+
data: UpsertManyPayloadSchema.fields.data,
|
|
490
|
+
},
|
|
491
|
+
}) {
|
|
492
|
+
};
|
|
493
|
+
return RequestClass;
|
|
494
|
+
}
|
|
495
|
+
/**
|
|
496
|
+
* Creates RPC definitions for a collection.
|
|
497
|
+
*
|
|
498
|
+
* Returns an object containing the request schemas that can be used to
|
|
499
|
+
* create RPC handlers and add them to an RpcRouter.
|
|
500
|
+
*
|
|
501
|
+
* @param collectionName - The name of the collection
|
|
502
|
+
* @param entitySchema - The Effect Schema for the collection's entities
|
|
503
|
+
* @returns Object with request schemas
|
|
504
|
+
*/
|
|
505
|
+
export function makeCollectionRpcs(collectionName, entitySchema) {
|
|
506
|
+
const FindByIdRequest = makeFindByIdRequest(collectionName, entitySchema);
|
|
507
|
+
const QueryRequest = makeQueryRequest(collectionName, entitySchema);
|
|
508
|
+
const QueryStreamRequest = makeQueryStreamRequest(collectionName, entitySchema);
|
|
509
|
+
const CreateRequest = makeCreateRequest(collectionName, entitySchema);
|
|
510
|
+
const UpdateRequest = makeUpdateRequest(collectionName, entitySchema);
|
|
511
|
+
const DeleteRequest = makeDeleteRequest(collectionName, entitySchema);
|
|
512
|
+
const AggregateRequest = makeAggregateRequest(collectionName);
|
|
513
|
+
const CreateManyRequest = makeCreateManyRequest(collectionName);
|
|
514
|
+
const UpdateManyRequest = makeUpdateManyRequest(collectionName);
|
|
515
|
+
const DeleteManyRequest = makeDeleteManyRequest(collectionName);
|
|
516
|
+
const UpsertRequest = makeUpsertRequest(collectionName);
|
|
517
|
+
const UpsertManyRequest = makeUpsertManyRequest(collectionName);
|
|
518
|
+
return {
|
|
519
|
+
FindByIdRequest,
|
|
520
|
+
QueryRequest,
|
|
521
|
+
QueryStreamRequest,
|
|
522
|
+
CreateRequest,
|
|
523
|
+
UpdateRequest,
|
|
524
|
+
DeleteRequest,
|
|
525
|
+
AggregateRequest,
|
|
526
|
+
CreateManyRequest,
|
|
527
|
+
UpdateManyRequest,
|
|
528
|
+
DeleteManyRequest,
|
|
529
|
+
UpsertRequest,
|
|
530
|
+
UpsertManyRequest,
|
|
531
|
+
collectionName,
|
|
532
|
+
entitySchema,
|
|
533
|
+
};
|
|
534
|
+
}
|
|
535
|
+
// ============================================================================
|
|
536
|
+
// RpcGroup Factory
|
|
537
|
+
// ============================================================================
|
|
538
|
+
/**
|
|
539
|
+
* Creates a mapping of collection RPC definitions from a DatabaseConfig.
|
|
540
|
+
*
|
|
541
|
+
* This is the primary entry point for deriving RPC schemas from a database config.
|
|
542
|
+
* Each collection gets typed request schemas for:
|
|
543
|
+
* - findById: Find entity by ID
|
|
544
|
+
* - query: Query entities with filtering, sorting, pagination (collected array result)
|
|
545
|
+
* - queryStream: Query entities with streaming results (incremental delivery)
|
|
546
|
+
* - create: Create a new entity
|
|
547
|
+
* - update: Update an existing entity by ID
|
|
548
|
+
* - delete: Delete an entity by ID
|
|
549
|
+
* - aggregate: Compute aggregates (count, sum, avg, min, max) with optional groupBy
|
|
550
|
+
* - createMany: Create multiple entities in batch
|
|
551
|
+
* - updateMany: Update multiple entities matching a predicate
|
|
552
|
+
* - deleteMany: Delete multiple entities matching a predicate
|
|
553
|
+
* - upsert: Create or update an entity based on a where clause
|
|
554
|
+
* - upsertMany: Create or update multiple entities in batch
|
|
555
|
+
*
|
|
556
|
+
* @param config - The database configuration
|
|
557
|
+
* @returns A mapping of collection names to their RPC definitions
|
|
558
|
+
*
|
|
559
|
+
* @example
|
|
560
|
+
* ```ts
|
|
561
|
+
* import { makeRpcGroup } from "@proseql/rpc"
|
|
562
|
+
* import { Rpc, RpcRouter } from "@effect/rpc"
|
|
563
|
+
*
|
|
564
|
+
* const config = {
|
|
565
|
+
* books: { schema: BookSchema, relationships: {} },
|
|
566
|
+
* authors: { schema: AuthorSchema, relationships: {} },
|
|
567
|
+
* } as const
|
|
568
|
+
*
|
|
569
|
+
* const rpcs = makeRpcGroup(config)
|
|
570
|
+
*
|
|
571
|
+
* // Create handlers using the request schemas
|
|
572
|
+
* const findBookById = Rpc.effect(rpcs.books.FindByIdRequest, (req) =>
|
|
573
|
+
* db.books.findById(req.id)
|
|
574
|
+
* )
|
|
575
|
+
*
|
|
576
|
+
* const queryBooks = Rpc.effect(rpcs.books.QueryRequest, (req) =>
|
|
577
|
+
* db.books.query({ where: req.where, sort: req.sort }).runPromise
|
|
578
|
+
* )
|
|
579
|
+
*
|
|
580
|
+
* const createBook = Rpc.effect(rpcs.books.CreateRequest, (req) =>
|
|
581
|
+
* db.books.create(req.data)
|
|
582
|
+
* )
|
|
583
|
+
*
|
|
584
|
+
* const updateBook = Rpc.effect(rpcs.books.UpdateRequest, (req) =>
|
|
585
|
+
* db.books.update(req.id, req.updates)
|
|
586
|
+
* )
|
|
587
|
+
*
|
|
588
|
+
* const deleteBook = Rpc.effect(rpcs.books.DeleteRequest, (req) =>
|
|
589
|
+
* db.books.delete(req.id)
|
|
590
|
+
* )
|
|
591
|
+
*
|
|
592
|
+
* const aggregateBooks = Rpc.effect(rpcs.books.AggregateRequest, (req) =>
|
|
593
|
+
* db.books.aggregate({ count: req.count, groupBy: req.groupBy, ...req })
|
|
594
|
+
* )
|
|
595
|
+
*
|
|
596
|
+
* const createManyBooks = Rpc.effect(rpcs.books.CreateManyRequest, (req) =>
|
|
597
|
+
* db.books.createMany(req.data, req.options)
|
|
598
|
+
* )
|
|
599
|
+
*
|
|
600
|
+
* // Build a router
|
|
601
|
+
* const router = RpcRouter.make(findBookById, queryBooks, createBook, updateBook, deleteBook, aggregateBooks, createManyBooks)
|
|
602
|
+
* ```
|
|
603
|
+
*/
|
|
604
|
+
export function makeRpcGroup(config) {
|
|
605
|
+
const result = {};
|
|
606
|
+
for (const collectionName of Object.keys(config)) {
|
|
607
|
+
const collectionConfig = config[collectionName];
|
|
608
|
+
result[collectionName] = makeCollectionRpcs(collectionName, collectionConfig.schema);
|
|
609
|
+
}
|
|
610
|
+
return result;
|
|
611
|
+
}
|
|
612
|
+
// Re-export RpcRouter for convenience
|
|
613
|
+
export { RpcRouter };
|
|
614
|
+
//# sourceMappingURL=rpc-group.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rpc-group.js","sourceRoot":"","sources":["../src/rpc-group.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EACN,4BAA4B,EAC5B,uBAAuB,EACvB,qBAAqB,EACrB,eAAe,EACf,mBAAmB,EACnB,oBAAoB,EACpB,2BAA2B,EAC3B,qBAAqB,GACrB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACN,sBAAsB,EACtB,qBAAqB,EACrB,uBAAuB,EACvB,sBAAsB,EACtB,mBAAmB,EACnB,uBAAuB,EACvB,sBAAsB,EACtB,mBAAmB,EACnB,4BAA4B,EAC5B,kBAAkB,EAClB,uBAAuB,EACvB,sBAAsB,EACtB,mBAAmB,EACnB,uBAAuB,EACvB,sBAAsB,EACtB,mBAAmB,EACnB,kBAAkB,GAClB,MAAM,kBAAkB,CAAC;AAE1B,+EAA+E;AAC/E,iCAAiC;AACjC,+EAA+E;AAE/E;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,UAAU,mBAAmB,CAIlC,cAA8B,EAC9B,YAA0B;IAE1B,2CAA2C;IAC3C,0EAA0E;IAC1E,M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