@confect/server 9.0.0-next.5 → 9.0.0-next.6

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.
Files changed (64) hide show
  1. package/CHANGELOG.md +156 -0
  2. package/dist/Auth.d.ts +1 -1
  3. package/dist/DatabaseReader.d.ts +4299 -26
  4. package/dist/DatabaseReader.d.ts.map +1 -1
  5. package/dist/DatabaseReader.js +5 -6
  6. package/dist/DatabaseReader.js.map +1 -1
  7. package/dist/DatabaseSchema.d.ts +25 -112
  8. package/dist/DatabaseSchema.d.ts.map +1 -1
  9. package/dist/DatabaseSchema.js +20 -30
  10. package/dist/DatabaseSchema.js.map +1 -1
  11. package/dist/DatabaseWriter.d.ts +4 -4
  12. package/dist/DatabaseWriter.d.ts.map +1 -1
  13. package/dist/DatabaseWriter.js +3 -4
  14. package/dist/DatabaseWriter.js.map +1 -1
  15. package/dist/FunctionImpl.d.ts +26 -17
  16. package/dist/FunctionImpl.d.ts.map +1 -1
  17. package/dist/FunctionImpl.js +22 -14
  18. package/dist/FunctionImpl.js.map +1 -1
  19. package/dist/GroupImpl.d.ts +22 -13
  20. package/dist/GroupImpl.d.ts.map +1 -1
  21. package/dist/GroupImpl.js +34 -35
  22. package/dist/GroupImpl.js.map +1 -1
  23. package/dist/Handler.d.ts +1 -1
  24. package/dist/QueryInitializer.d.ts +1 -1
  25. package/dist/QueryInitializer.d.ts.map +1 -1
  26. package/dist/QueryInitializer.js.map +1 -1
  27. package/dist/RegisteredConvexFunction.d.ts +1084 -17
  28. package/dist/RegisteredConvexFunction.d.ts.map +1 -1
  29. package/dist/RegisteredConvexFunction.js +4 -4
  30. package/dist/RegisteredConvexFunction.js.map +1 -1
  31. package/dist/RegisteredFunction.d.ts +3 -3
  32. package/dist/RegisteredFunction.d.ts.map +1 -1
  33. package/dist/RegisteredFunctions.d.ts +36 -12
  34. package/dist/RegisteredFunctions.d.ts.map +1 -1
  35. package/dist/RegisteredFunctions.js +21 -9
  36. package/dist/RegisteredFunctions.js.map +1 -1
  37. package/dist/RegisteredNodeFunction.d.ts +4 -4
  38. package/dist/RegisteredNodeFunction.d.ts.map +1 -1
  39. package/dist/RegisteredNodeFunction.js +2 -2
  40. package/dist/RegisteredNodeFunction.js.map +1 -1
  41. package/dist/StorageActionWriter.d.ts +1 -1
  42. package/dist/Table.d.ts +35 -27
  43. package/dist/Table.d.ts.map +1 -1
  44. package/dist/Table.js +69 -60
  45. package/dist/Table.js.map +1 -1
  46. package/dist/index.d.ts +4 -5
  47. package/dist/index.js +4 -5
  48. package/package.json +51 -52
  49. package/src/DatabaseReader.ts +17 -21
  50. package/src/DatabaseSchema.ts +38 -98
  51. package/src/DatabaseWriter.ts +8 -5
  52. package/src/FunctionImpl.ts +33 -43
  53. package/src/GroupImpl.ts +45 -69
  54. package/src/QueryInitializer.ts +10 -2
  55. package/src/RegisteredConvexFunction.ts +5 -6
  56. package/src/RegisteredFunctions.ts +67 -93
  57. package/src/RegisteredNodeFunction.ts +3 -4
  58. package/src/Table.ts +251 -131
  59. package/src/index.ts +0 -1
  60. package/dist/Api.d.ts +0 -43
  61. package/dist/Api.d.ts.map +0 -1
  62. package/dist/Api.js +0 -43
  63. package/dist/Api.js.map +0 -1
  64. 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
- };