@confect/server 9.0.0-next.5 → 9.0.0-next.7
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/CHANGELOG.md +163 -0
- package/dist/Auth.d.ts +1 -1
- package/dist/DatabaseReader.d.ts +4299 -26
- package/dist/DatabaseReader.d.ts.map +1 -1
- package/dist/DatabaseReader.js +5 -6
- package/dist/DatabaseReader.js.map +1 -1
- package/dist/DatabaseSchema.d.ts +25 -112
- package/dist/DatabaseSchema.d.ts.map +1 -1
- package/dist/DatabaseSchema.js +20 -30
- package/dist/DatabaseSchema.js.map +1 -1
- package/dist/DatabaseWriter.d.ts +4 -4
- package/dist/DatabaseWriter.d.ts.map +1 -1
- package/dist/DatabaseWriter.js +3 -4
- package/dist/DatabaseWriter.js.map +1 -1
- package/dist/FunctionImpl.d.ts +26 -17
- package/dist/FunctionImpl.d.ts.map +1 -1
- package/dist/FunctionImpl.js +22 -14
- package/dist/FunctionImpl.js.map +1 -1
- package/dist/GroupImpl.d.ts +22 -13
- package/dist/GroupImpl.d.ts.map +1 -1
- package/dist/GroupImpl.js +34 -35
- package/dist/GroupImpl.js.map +1 -1
- package/dist/Handler.d.ts +1 -1
- package/dist/QueryInitializer.d.ts.map +1 -1
- package/dist/QueryInitializer.js.map +1 -1
- package/dist/RegisteredConvexFunction.d.ts +1081 -14
- package/dist/RegisteredConvexFunction.d.ts.map +1 -1
- package/dist/RegisteredConvexFunction.js +4 -4
- package/dist/RegisteredConvexFunction.js.map +1 -1
- package/dist/RegisteredFunction.d.ts +3 -3
- package/dist/RegisteredFunction.d.ts.map +1 -1
- package/dist/RegisteredFunctions.d.ts +36 -12
- package/dist/RegisteredFunctions.d.ts.map +1 -1
- package/dist/RegisteredFunctions.js +21 -9
- package/dist/RegisteredFunctions.js.map +1 -1
- package/dist/RegisteredNodeFunction.d.ts +4 -4
- package/dist/RegisteredNodeFunction.d.ts.map +1 -1
- package/dist/RegisteredNodeFunction.js +2 -2
- package/dist/RegisteredNodeFunction.js.map +1 -1
- package/dist/Table.d.ts +39 -31
- package/dist/Table.d.ts.map +1 -1
- package/dist/Table.js +69 -60
- package/dist/Table.js.map +1 -1
- package/dist/index.d.ts +4 -5
- package/dist/index.js +4 -5
- package/package.json +51 -52
- package/src/DatabaseReader.ts +17 -21
- package/src/DatabaseSchema.ts +38 -98
- package/src/DatabaseWriter.ts +8 -5
- package/src/FunctionImpl.ts +33 -43
- package/src/GroupImpl.ts +45 -69
- package/src/QueryInitializer.ts +10 -2
- package/src/RegisteredConvexFunction.ts +5 -6
- package/src/RegisteredFunctions.ts +67 -93
- package/src/RegisteredNodeFunction.ts +3 -4
- package/src/Table.ts +251 -131
- package/src/index.ts +0 -1
- package/dist/Api.d.ts +0 -43
- package/dist/Api.d.ts.map +0 -1
- package/dist/Api.js +0 -43
- package/dist/Api.js.map +0 -1
- package/src/Api.ts +0 -102
package/src/Api.ts
DELETED
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import type { RuntimeAndFunctionType } from "@confect/core";
|
|
2
|
-
import type * as GroupSpec from "@confect/core/GroupSpec";
|
|
3
|
-
import type * as Spec from "@confect/core/Spec";
|
|
4
|
-
import type { GenericSchema, SchemaDefinition } from "convex/server";
|
|
5
|
-
import { defineSchema as defineConvexSchema } from "convex/server";
|
|
6
|
-
import { pipe, Predicate, Record } from "effect";
|
|
7
|
-
import type * as DatabaseSchema from "./DatabaseSchema";
|
|
8
|
-
|
|
9
|
-
export const TypeId = "@confect/server/Api";
|
|
10
|
-
export type TypeId = typeof TypeId;
|
|
11
|
-
|
|
12
|
-
export const isApi = (u: unknown): u is Any => Predicate.hasProperty(u, TypeId);
|
|
13
|
-
|
|
14
|
-
export interface Api<
|
|
15
|
-
DatabaseSchema_ extends DatabaseSchema.AnyWithProps,
|
|
16
|
-
Spec_ extends Spec.AnyWithProps,
|
|
17
|
-
> {
|
|
18
|
-
readonly [TypeId]: TypeId;
|
|
19
|
-
readonly spec: Spec_;
|
|
20
|
-
readonly databaseSchema: DatabaseSchema_;
|
|
21
|
-
readonly convexSchemaDefinition: SchemaDefinition<GenericSchema, true>;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export interface Any {
|
|
25
|
-
readonly [TypeId]: TypeId;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export interface AnyWithProps extends Api<
|
|
29
|
-
DatabaseSchema.AnyWithProps,
|
|
30
|
-
Spec.AnyWithProps
|
|
31
|
-
> {}
|
|
32
|
-
|
|
33
|
-
export interface AnyWithPropsWithRuntime<
|
|
34
|
-
Runtime extends RuntimeAndFunctionType.Runtime,
|
|
35
|
-
> extends Api<
|
|
36
|
-
DatabaseSchema.AnyWithProps,
|
|
37
|
-
Spec.AnyWithPropsWithRuntime<Runtime>
|
|
38
|
-
> {}
|
|
39
|
-
|
|
40
|
-
export type Schema<Api_ extends AnyWithProps> = Api_["databaseSchema"];
|
|
41
|
-
|
|
42
|
-
export type GetSpec<Api_ extends AnyWithProps> = Api_["spec"];
|
|
43
|
-
|
|
44
|
-
export type Groups<Api_ extends AnyWithProps> = Spec.Groups<Api_["spec"]>;
|
|
45
|
-
|
|
46
|
-
const Proto = {
|
|
47
|
-
[TypeId]: TypeId,
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
const makeProto = <
|
|
51
|
-
DatabaseSchema_ extends DatabaseSchema.AnyWithProps,
|
|
52
|
-
Spec_ extends Spec.AnyWithProps,
|
|
53
|
-
>({
|
|
54
|
-
databaseSchema,
|
|
55
|
-
spec,
|
|
56
|
-
}: {
|
|
57
|
-
databaseSchema: DatabaseSchema.AnyWithProps;
|
|
58
|
-
spec: Spec_;
|
|
59
|
-
}): Api<DatabaseSchema_, Spec_> =>
|
|
60
|
-
Object.assign(Object.create(Proto), {
|
|
61
|
-
databaseSchema,
|
|
62
|
-
spec,
|
|
63
|
-
convexSchemaDefinition: pipe(
|
|
64
|
-
databaseSchema.tables,
|
|
65
|
-
Record.map(({ tableDefinition }) => tableDefinition),
|
|
66
|
-
defineConvexSchema,
|
|
67
|
-
),
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
export const make = <
|
|
71
|
-
DatabaseSchema_ extends DatabaseSchema.AnyWithProps,
|
|
72
|
-
Spec_ extends Spec.AnyWithProps,
|
|
73
|
-
>(
|
|
74
|
-
databaseSchema: DatabaseSchema_,
|
|
75
|
-
spec: Spec_,
|
|
76
|
-
): Api<DatabaseSchema_, Spec_> => makeProto({ databaseSchema, spec });
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Resolve the dot-path of `group` within `api.spec` by reading the immutable
|
|
80
|
-
* `paths` mapping that codegen populated in `_generated/spec.ts`. Throws when
|
|
81
|
-
* the spec is not registered, with a message pointing the caller at the
|
|
82
|
-
* place to register it.
|
|
83
|
-
*
|
|
84
|
-
* The legacy identity-based tree walk (`packages/server/src/GroupPath.ts`)
|
|
85
|
-
* was deleted in favor of this O(1) map lookup; both the registration
|
|
86
|
-
* mechanism (`Spec.addPath`) and the lookup key are the same JS reference
|
|
87
|
-
* thanks to ES module dedup between `_generated/spec.ts` and `*.impl.ts`.
|
|
88
|
-
*/
|
|
89
|
-
export const resolveGroupPathUnsafe = (
|
|
90
|
-
api: AnyWithProps,
|
|
91
|
-
group: GroupSpec.AnyWithProps,
|
|
92
|
-
): string => {
|
|
93
|
-
const groupPath = api.spec.paths.get(group);
|
|
94
|
-
if (groupPath === undefined) {
|
|
95
|
-
throw new Error(
|
|
96
|
-
"GroupSpec has no registered path in this api's spec. " +
|
|
97
|
-
"Ensure the spec is added via Spec.addPath in _generated/spec.ts " +
|
|
98
|
-
"(or, in tests, call .addPath(spec, 'dot.path') on the Spec you pass to Api.make).",
|
|
99
|
-
);
|
|
100
|
-
}
|
|
101
|
-
return groupPath;
|
|
102
|
-
};
|