@confect/core 9.0.0-next.8 → 9.0.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.
Files changed (45) hide show
  1. package/CHANGELOG.md +170 -4
  2. package/dist/FunctionProvenance.d.ts +87 -93
  3. package/dist/FunctionProvenance.d.ts.map +1 -1
  4. package/dist/FunctionSpec.d.ts +178 -218
  5. package/dist/FunctionSpec.d.ts.map +1 -1
  6. package/dist/GenericId.d.ts +6 -13
  7. package/dist/GenericId.d.ts.map +1 -1
  8. package/dist/GroupPath.d.ts +10 -16
  9. package/dist/GroupPath.d.ts.map +1 -1
  10. package/dist/GroupSpec.d.ts +38 -37
  11. package/dist/GroupSpec.d.ts.map +1 -1
  12. package/dist/GroupSpec.js.map +1 -1
  13. package/dist/Identifier.d.ts +2 -7
  14. package/dist/Identifier.d.ts.map +1 -1
  15. package/dist/Lazy.d.ts +1 -6
  16. package/dist/Lazy.d.ts.map +1 -1
  17. package/dist/PaginationResult.d.ts +10 -17
  18. package/dist/PaginationResult.d.ts.map +1 -1
  19. package/dist/Ref.d.ts +54 -52
  20. package/dist/Ref.d.ts.map +1 -1
  21. package/dist/Refs.d.ts +21 -21
  22. package/dist/Refs.d.ts.map +1 -1
  23. package/dist/Refs.js +2 -10
  24. package/dist/Refs.js.map +1 -1
  25. package/dist/Registry.d.ts +5 -10
  26. package/dist/Registry.d.ts.map +1 -1
  27. package/dist/RuntimeAndFunctionType.d.ts +36 -41
  28. package/dist/RuntimeAndFunctionType.d.ts.map +1 -1
  29. package/dist/Spec.d.ts +23 -33
  30. package/dist/Spec.d.ts.map +1 -1
  31. package/dist/Spec.js +7 -50
  32. package/dist/Spec.js.map +1 -1
  33. package/dist/SystemFields.d.ts +9 -15
  34. package/dist/SystemFields.d.ts.map +1 -1
  35. package/dist/Types.d.ts +27 -27
  36. package/dist/Types.d.ts.map +1 -1
  37. package/dist/UserIdentity.d.ts +55 -62
  38. package/dist/UserIdentity.d.ts.map +1 -1
  39. package/dist/index.d.ts +17 -17
  40. package/dist/index.d.ts.map +1 -0
  41. package/dist/tsconfig.src.tsbuildinfo +1 -0
  42. package/package.json +3 -11
  43. package/src/GroupSpec.ts +7 -6
  44. package/src/Refs.ts +10 -44
  45. package/src/Spec.ts +16 -83
package/src/Spec.ts CHANGED
@@ -1,9 +1,6 @@
1
- import * as Array from "effect/Array";
2
- import * as Option from "effect/Option";
3
1
  import * as Predicate from "effect/Predicate";
4
2
  import * as Record from "effect/Record";
5
3
  import * as GroupSpec from "./GroupSpec";
6
- import type * as RuntimeAndFunctionType from "./RuntimeAndFunctionType";
7
4
 
8
5
  export const TypeId = "@confect/core/Spec";
9
6
  export type TypeId = typeof TypeId;
@@ -11,24 +8,15 @@ export type TypeId = typeof TypeId;
11
8
  export const isSpec = (u: unknown): u is AnyWithProps =>
12
9
  Predicate.hasProperty(u, TypeId);
13
10
 
14
- export const isConvexSpec = (
15
- u: unknown,
16
- ): u is AnyWithPropsWithRuntime<"Convex"> =>
17
- Predicate.hasProperty(u, TypeId) &&
18
- Predicate.hasProperty(u, "runtime") &&
19
- u.runtime === "Convex";
20
-
21
- export const isNodeSpec = (u: unknown): u is AnyWithPropsWithRuntime<"Node"> =>
22
- Predicate.hasProperty(u, TypeId) &&
23
- Predicate.hasProperty(u, "runtime") &&
24
- u.runtime === "Node";
25
-
26
- export interface Spec<
27
- Runtime extends RuntimeAndFunctionType.Runtime,
28
- Groups_ extends GroupSpec.AnyWithPropsWithRuntime<Runtime> = never,
29
- > {
11
+ /**
12
+ * A Confect spec: a flat container of function groups. Groups may be of any
13
+ * runtime — a group built with `GroupSpec.makeNode()` (a Node action group) sits
14
+ * alongside `GroupSpec.make()` groups in the same namespace. The runtime of a
15
+ * group lives on the group itself (`GroupSpec.runtime`) and on each function's
16
+ * `RuntimeAndFunctionType`; the spec does not carry a runtime of its own.
17
+ */
18
+ export interface Spec<Groups_ extends GroupSpec.AnyWithProps = never> {
30
19
  readonly [TypeId]: TypeId;
31
- readonly runtime: Runtime;
32
20
  readonly groups: {
33
21
  [GroupName in GroupSpec.Name<Groups_>]: GroupSpec.WithName<
34
22
  Groups_,
@@ -36,31 +24,21 @@ export interface Spec<
36
24
  >;
37
25
  };
38
26
 
39
- add<Group extends GroupSpec.AnyWithPropsWithRuntime<Runtime>>(
27
+ add<Group extends GroupSpec.AnyWithProps>(
40
28
  group: Group,
41
- ): Spec<Runtime, Groups_ | Group>;
29
+ ): Spec<Groups_ | Group>;
42
30
 
43
- addAt<
44
- const Name extends string,
45
- Group extends GroupSpec.AnyWithPropsWithRuntime<Runtime>,
46
- >(
31
+ addAt<const Name extends string, Group extends GroupSpec.AnyWithProps>(
47
32
  name: Name,
48
33
  group: Group,
49
- ): Spec<Runtime, Groups_ | GroupSpec.NamedAt<Group, Name>>;
34
+ ): Spec<Groups_ | GroupSpec.NamedAt<Group, Name>>;
50
35
  }
51
36
 
52
37
  export interface Any {
53
38
  readonly [TypeId]: TypeId;
54
39
  }
55
40
 
56
- export interface AnyWithProps extends Spec<
57
- RuntimeAndFunctionType.Runtime,
58
- GroupSpec.AnyWithProps
59
- > {}
60
-
61
- export interface AnyWithPropsWithRuntime<
62
- Runtime extends RuntimeAndFunctionType.Runtime,
63
- > extends Spec<Runtime, GroupSpec.AnyWithPropsWithRuntime<Runtime>> {}
41
+ export interface AnyWithProps extends Spec<GroupSpec.AnyWithProps> {}
64
42
 
65
43
  export type Groups<Spec_ extends AnyWithProps> =
66
44
  Spec_["groups"][keyof Spec_["groups"]];
@@ -70,7 +48,6 @@ const Proto = {
70
48
 
71
49
  add<Group extends GroupSpec.AnyWithProps>(this: AnyWithProps, group: Group) {
72
50
  return makeProto({
73
- runtime: this.runtime,
74
51
  groups: Record.set(this.groups, group.name, group),
75
52
  });
76
53
  },
@@ -81,62 +58,18 @@ const Proto = {
81
58
  group: Group,
82
59
  ) {
83
60
  return makeProto({
84
- runtime: this.runtime,
85
61
  groups: Record.set(this.groups, name, GroupSpec.withName(name, group)),
86
62
  });
87
63
  },
88
64
  };
89
65
 
90
- const makeProto = <
91
- Runtime extends RuntimeAndFunctionType.Runtime,
92
- Groups_ extends GroupSpec.AnyWithPropsWithRuntime<Runtime>,
93
- >({
94
- runtime,
66
+ const makeProto = <Groups_ extends GroupSpec.AnyWithProps>({
95
67
  groups,
96
68
  }: {
97
- runtime: Runtime;
98
69
  groups: Record.ReadonlyRecord<string, Groups_>;
99
- }): Spec<Runtime, Groups_> =>
70
+ }): Spec<Groups_> =>
100
71
  Object.assign(Object.create(Proto), {
101
- runtime,
102
72
  groups,
103
73
  });
104
74
 
105
- export const make = (): Spec<"Convex"> =>
106
- makeProto({ runtime: "Convex", groups: {} });
107
-
108
- export const makeNode = (): Spec<"Node"> =>
109
- makeProto({ runtime: "Node", groups: {} });
110
-
111
- /**
112
- * Merges a Convex spec with an optional Node spec into a single assembled
113
- * spec (used by codegen to build `Refs.make` and to enumerate function paths).
114
- * When `nodeSpec` is provided, its groups are merged under a "node" namespace,
115
- * mirroring the structure used by `Refs.make`.
116
- */
117
- export const merge = <
118
- ConvexSpec extends AnyWithPropsWithRuntime<"Convex">,
119
- NodeSpec extends AnyWithPropsWithRuntime<"Node">,
120
- >(
121
- convexSpec: ConvexSpec,
122
- nodeSpec?: NodeSpec,
123
- ): AnyWithProps => {
124
- const groups = Option.fromNullable(nodeSpec).pipe(
125
- Option.map((nodeSpec_) =>
126
- Array.reduce(
127
- Record.toEntries(nodeSpec_.groups),
128
- GroupSpec.makeNodeAt("node"),
129
- (nodeGroupSpec, [name, group]) => nodeGroupSpec.addGroupAt(name, group),
130
- ),
131
- ),
132
- Option.match({
133
- onNone: () => convexSpec.groups,
134
- onSome: (nodeGroup) => ({ ...convexSpec.groups, node: nodeGroup }),
135
- }),
136
- );
137
-
138
- return Object.assign(Object.create(Proto), {
139
- runtime: "Convex" as const,
140
- groups,
141
- }) as AnyWithProps;
142
- };
75
+ export const make = (): Spec => makeProto({ groups: {} });