@confect/core 9.0.0-next.8 → 9.0.0-next.9
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 +23 -0
- package/dist/FunctionProvenance.d.ts +30 -30
- package/dist/FunctionProvenance.d.ts.map +1 -1
- package/dist/GroupSpec.d.ts +7 -7
- package/dist/GroupSpec.d.ts.map +1 -1
- package/dist/GroupSpec.js.map +1 -1
- package/dist/Refs.d.ts +6 -6
- package/dist/Refs.d.ts.map +1 -1
- package/dist/Refs.js +2 -10
- package/dist/Refs.js.map +1 -1
- package/dist/Spec.d.ts +15 -21
- package/dist/Spec.d.ts.map +1 -1
- package/dist/Spec.js +7 -50
- package/dist/Spec.js.map +1 -1
- package/package.json +1 -1
- package/src/GroupSpec.ts +7 -6
- package/src/Refs.ts +10 -44
- package/src/Spec.ts +16 -83
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @confect/core
|
|
2
2
|
|
|
3
|
+
## 9.0.0-next.9
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- 4894959: Make Node-runtime functions first-class and remove the separate `node` namespace.
|
|
8
|
+
|
|
9
|
+
A function group's runtime is now declared solely by its spec — `GroupSpec.makeNode()` for a Node action group, `GroupSpec.make()` for a Convex group — exactly like vanilla Convex's per-file `"use node"` directive. The `confect/node/` directory is no longer special: Node specs/impls are ordinary colocated `.spec.ts`/`.impl.ts` pairs that can live anywhere in `confect/`, and codegen emits the `"use node"` directive into the generated `convex/` module based on the spec. This is safe because v9's per-group registries already isolate each Convex function's bundle from every other group's impl, so Node-only code can no longer leak into a Convex-runtime bundle regardless of namespace.
|
|
10
|
+
|
|
11
|
+
### Why
|
|
12
|
+
|
|
13
|
+
The `node` namespace existed only because the pre-v9 architecture aggregated every function's impl into one module that all generated `convex/` modules imported; Node functions had to be quarantined into a separate spec/impl/registry tree so Convex-runtime functions wouldn't transitively import Node-only code. v9's per-group isolation removed that constraint, so the namespace was no longer load-bearing — only ergonomic overhead that diverged from vanilla Convex (which identifies Node modules per-file, with no directory requirement).
|
|
14
|
+
|
|
15
|
+
### Breaking changes
|
|
16
|
+
- **API namespace removed.** A Node group at `confect/email.spec.ts` is now referenced as `refs.public.email.send` instead of `refs.public.node.email.send`. Node groups are ordinary groups in the refs tree, nesting preserved like any other group.
|
|
17
|
+
- **Generated layout changed.** Node modules are emitted at `convex/<path>.ts` (carrying `"use node"`) instead of `convex/node/<path>.ts`, and their registries at `confect/_generated/registeredFunctions/<path>.ts`. The single assembled `confect/_generated/spec.ts` now contains every group regardless of runtime; `confect/_generated/nodeSpec.ts` is no longer generated (codegen deletes any stale copy on upgrade).
|
|
18
|
+
- **`@confect/core` API.** Removed `Spec.makeNode`, `Spec.merge`, and `Spec.isConvexSpec`/`Spec.isNodeSpec`. `Spec` is now a single mixed-runtime container (`Spec.make()` accepts groups of any runtime). `Refs.make(spec)` takes a single argument (the unified spec) instead of `(convexSpec, nodeSpec)`. `GroupSpec.makeNode()`/`makeNodeAt()` and `FunctionSpec.publicNodeAction()`/`internalNodeAction()` are unchanged; `GroupSpec` subgroups may now be of any runtime (a group is just a namespace for its children).
|
|
19
|
+
|
|
20
|
+
### Migration
|
|
21
|
+
1. Move any `confect/node/<path>.spec.ts`/`.impl.ts` files to wherever you want them under `confect/` (e.g. `confect/<path>.spec.ts`); the `node/` directory has no special meaning anymore. Their specs already use `GroupSpec.makeNode()`, so no spec-body change is needed — only fix the impl's relative import of `_generated/schema` if its depth changed.
|
|
22
|
+
2. Update call sites to drop the `node` segment: `refs.public.node.<group>.<fn>` → `refs.public.<group>.<fn>`.
|
|
23
|
+
3. Replace `Refs.make(spec, nodeSpec)` with `Refs.make(spec)` (codegen does this for `_generated/refs.ts` automatically).
|
|
24
|
+
4. Run `confect codegen`. The `convex/` tree and `confect/_generated/` are re-emitted; the stale `_generated/nodeSpec.ts` is removed.
|
|
25
|
+
|
|
3
26
|
## 9.0.0-next.8
|
|
4
27
|
|
|
5
28
|
### Patch Changes
|
|
@@ -29,76 +29,76 @@ interface Convex<Args extends DefaultFunctionArgs, Returns> {
|
|
|
29
29
|
}
|
|
30
30
|
interface AnyConvex extends Convex<DefaultFunctionArgs, any> {}
|
|
31
31
|
declare const FunctionProvenance: {
|
|
32
|
-
readonly Convex: Data.Case.Constructor<{
|
|
33
|
-
readonly _tag: "Convex";
|
|
34
|
-
readonly _args: DefaultFunctionArgs;
|
|
35
|
-
readonly _returns: any;
|
|
36
|
-
}, "_tag">;
|
|
37
32
|
readonly Confect: Data.Case.Constructor<{
|
|
38
33
|
readonly _tag: "Confect";
|
|
39
34
|
readonly args: Schema.Schema.AnyNoContext;
|
|
40
35
|
readonly returns: Schema.Schema.AnyNoContext;
|
|
41
36
|
readonly error?: Schema.Schema.AnyNoContext;
|
|
42
37
|
}, "_tag">;
|
|
43
|
-
readonly
|
|
38
|
+
readonly Convex: Data.Case.Constructor<{
|
|
44
39
|
readonly _tag: "Convex";
|
|
45
40
|
readonly _args: DefaultFunctionArgs;
|
|
46
41
|
readonly _returns: any;
|
|
47
|
-
},
|
|
48
|
-
|
|
49
|
-
}> | Extract<{
|
|
42
|
+
}, "_tag">;
|
|
43
|
+
readonly $is: <Tag extends "Confect" | "Convex">(tag: Tag) => (u: unknown) => u is Extract<{
|
|
50
44
|
readonly _tag: "Confect";
|
|
51
45
|
readonly args: Schema.Schema.AnyNoContext;
|
|
52
46
|
readonly returns: Schema.Schema.AnyNoContext;
|
|
53
47
|
readonly error?: Schema.Schema.AnyNoContext;
|
|
54
48
|
}, {
|
|
55
49
|
readonly _tag: Tag;
|
|
50
|
+
}> | Extract<{
|
|
51
|
+
readonly _tag: "Convex";
|
|
52
|
+
readonly _args: DefaultFunctionArgs;
|
|
53
|
+
readonly _returns: any;
|
|
54
|
+
}, {
|
|
55
|
+
readonly _tag: Tag;
|
|
56
56
|
}>;
|
|
57
57
|
readonly $match: {
|
|
58
58
|
<const Cases extends {
|
|
59
|
-
readonly Convex: (args: {
|
|
60
|
-
readonly _tag: "Convex";
|
|
61
|
-
readonly _args: DefaultFunctionArgs;
|
|
62
|
-
readonly _returns: any;
|
|
63
|
-
}) => any;
|
|
64
59
|
readonly Confect: (args: {
|
|
65
60
|
readonly _tag: "Confect";
|
|
66
61
|
readonly args: Schema.Schema.AnyNoContext;
|
|
67
62
|
readonly returns: Schema.Schema.AnyNoContext;
|
|
68
63
|
readonly error?: Schema.Schema.AnyNoContext;
|
|
69
64
|
}) => any;
|
|
70
|
-
}>(cases: Cases & { [K in Exclude<keyof Cases, "Convex" | "Confect">]: never }): (value: {
|
|
71
|
-
readonly _tag: "Convex";
|
|
72
|
-
readonly _args: DefaultFunctionArgs;
|
|
73
|
-
readonly _returns: any;
|
|
74
|
-
} | {
|
|
75
|
-
readonly _tag: "Confect";
|
|
76
|
-
readonly args: Schema.Schema.AnyNoContext;
|
|
77
|
-
readonly returns: Schema.Schema.AnyNoContext;
|
|
78
|
-
readonly error?: Schema.Schema.AnyNoContext;
|
|
79
|
-
}) => effect_Unify0.Unify<ReturnType<Cases["Convex" | "Confect"]>>;
|
|
80
|
-
<const Cases extends {
|
|
81
65
|
readonly Convex: (args: {
|
|
82
66
|
readonly _tag: "Convex";
|
|
83
67
|
readonly _args: DefaultFunctionArgs;
|
|
84
68
|
readonly _returns: any;
|
|
85
69
|
}) => any;
|
|
70
|
+
}>(cases: Cases & { [K in Exclude<keyof Cases, "Confect" | "Convex">]: never }): (value: {
|
|
71
|
+
readonly _tag: "Confect";
|
|
72
|
+
readonly args: Schema.Schema.AnyNoContext;
|
|
73
|
+
readonly returns: Schema.Schema.AnyNoContext;
|
|
74
|
+
readonly error?: Schema.Schema.AnyNoContext;
|
|
75
|
+
} | {
|
|
76
|
+
readonly _tag: "Convex";
|
|
77
|
+
readonly _args: DefaultFunctionArgs;
|
|
78
|
+
readonly _returns: any;
|
|
79
|
+
}) => effect_Unify0.Unify<ReturnType<Cases["Confect" | "Convex"]>>;
|
|
80
|
+
<const Cases extends {
|
|
86
81
|
readonly Confect: (args: {
|
|
87
82
|
readonly _tag: "Confect";
|
|
88
83
|
readonly args: Schema.Schema.AnyNoContext;
|
|
89
84
|
readonly returns: Schema.Schema.AnyNoContext;
|
|
90
85
|
readonly error?: Schema.Schema.AnyNoContext;
|
|
91
86
|
}) => any;
|
|
87
|
+
readonly Convex: (args: {
|
|
88
|
+
readonly _tag: "Convex";
|
|
89
|
+
readonly _args: DefaultFunctionArgs;
|
|
90
|
+
readonly _returns: any;
|
|
91
|
+
}) => any;
|
|
92
92
|
}>(value: {
|
|
93
|
-
readonly _tag: "Convex";
|
|
94
|
-
readonly _args: DefaultFunctionArgs;
|
|
95
|
-
readonly _returns: any;
|
|
96
|
-
} | {
|
|
97
93
|
readonly _tag: "Confect";
|
|
98
94
|
readonly args: Schema.Schema.AnyNoContext;
|
|
99
95
|
readonly returns: Schema.Schema.AnyNoContext;
|
|
100
96
|
readonly error?: Schema.Schema.AnyNoContext;
|
|
101
|
-
}
|
|
97
|
+
} | {
|
|
98
|
+
readonly _tag: "Convex";
|
|
99
|
+
readonly _args: DefaultFunctionArgs;
|
|
100
|
+
readonly _returns: any;
|
|
101
|
+
}, cases: Cases & { [K in Exclude<keyof Cases, "Confect" | "Convex">]: never }): effect_Unify0.Unify<ReturnType<Cases["Confect" | "Convex"]>>;
|
|
102
102
|
};
|
|
103
103
|
};
|
|
104
104
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FunctionProvenance.d.ts","names":[],"sources":["../src/FunctionProvenance.ts"],"mappings":";;;;;;;;;KAKY,kBAAA,GAAqB,IAAA,CAAK,UAAA;EACpC,OAAA;IACE,IAAA,EAAM,MAAA,CAAO,MAAA,CAAO,YAAA;IACpB,OAAA,EAAS,MAAA,CAAO,MAAA,CAAO,YAAA;IACvB,KAAA,GAAQ,MAAA,CAAO,MAAA,CAAO,YAAA;EAAA;EAExB,MAAA;AAAA;AAAA,UAQe,OAAA,cACF,MAAA,CAAO,MAAA,CAAO,YAAA,kBACX,MAAA,CAAO,MAAA,CAAO,YAAA,gBAChB,MAAA,CAAO,MAAA,CAAO,YAAA;EAAA,SAEnB,IAAA;EAAA,SACA,IAAA,EAAM,IAAA;EAAA,SACN,OAAA,EAAS,OAAA;EAAA,SACT,KAAA,GAAQ,KAAA;AAAA;AAAA,UAGF,UAAA,SAAmB,OAAA,CAClC,MAAA,CAAO,MAAA,CAAO,YAAA,EACd,MAAA,CAAO,MAAA,CAAO,YAAA,EACd,MAAA,CAAO,MAAA,CAAO,YAAA;AAAA,UAGC,MAAA,cAAoB,mBAAA;EAAA,SAC1B,IAAA;EAAA,SACA,KAAA,EAAO,IAAA;EAAA,SACP,QAAA,EAAU,OAAA;AAAA;AAAA,UAGJ,SAAA,SAAkB,MAAA,CAAO,mBAAA;AAAA,cAE7B,kBAAA;EAAA;;
|
|
1
|
+
{"version":3,"file":"FunctionProvenance.d.ts","names":[],"sources":["../src/FunctionProvenance.ts"],"mappings":";;;;;;;;;KAKY,kBAAA,GAAqB,IAAA,CAAK,UAAA;EACpC,OAAA;IACE,IAAA,EAAM,MAAA,CAAO,MAAA,CAAO,YAAA;IACpB,OAAA,EAAS,MAAA,CAAO,MAAA,CAAO,YAAA;IACvB,KAAA,GAAQ,MAAA,CAAO,MAAA,CAAO,YAAA;EAAA;EAExB,MAAA;AAAA;AAAA,UAQe,OAAA,cACF,MAAA,CAAO,MAAA,CAAO,YAAA,kBACX,MAAA,CAAO,MAAA,CAAO,YAAA,gBAChB,MAAA,CAAO,MAAA,CAAO,YAAA;EAAA,SAEnB,IAAA;EAAA,SACA,IAAA,EAAM,IAAA;EAAA,SACN,OAAA,EAAS,OAAA;EAAA,SACT,KAAA,GAAQ,KAAA;AAAA;AAAA,UAGF,UAAA,SAAmB,OAAA,CAClC,MAAA,CAAO,MAAA,CAAO,YAAA,EACd,MAAA,CAAO,MAAA,CAAO,YAAA,EACd,MAAA,CAAO,MAAA,CAAO,YAAA;AAAA,UAGC,MAAA,cAAoB,mBAAA;EAAA,SAC1B,IAAA;EAAA,SACA,KAAA,EAAO,IAAA;EAAA,SACP,QAAA,EAAU,OAAA;AAAA;AAAA,UAGJ,SAAA,SAAkB,MAAA,CAAO,mBAAA;AAAA,cAE7B,kBAAA;EAAA;;mBArCH,MAAA,CAAO,MAAA,CAAO,YAAA;IAAA,kBACX,MAAA,CAAO,MAAA,CAAO,YAAA;IAAA,iBACf,MAAA,CAAO,MAAA,CAAO,YAAA;EAAA;EAAA;;oBAIf,mBAAA;IAAA;;;;mBAND,MAAA,CAAO,MAAA,CAAO,YAAA;IAAA,kBACX,MAAA,CAAO,MAAA,CAAO,YAAA;IAAA,iBACf,MAAA,CAAO,MAAA,CAAO,YAAA;EAAA;IAAA;;;oBAIf,mBAAA;IAAA;;;;;;;;uBAND,MAAA,CAAO,MAAA,CAAO,YAAA;QAAA,kBACX,MAAA,CAAO,MAAA,CAAO,YAAA;QAAA,iBACf,MAAA,CAAO,MAAA,CAAO,YAAA;MAAA;MAAA;;wBAIf,mBAAA;QAAA;;;;qBAND,MAAA,CAAO,MAAA,CAAO,YAAA;MAAA,kBACX,MAAA,CAAO,MAAA,CAAO,YAAA;MAAA,iBACf,MAAA,CAAO,MAAA,CAAO,YAAA;IAAA;MAAA;sBAIf,mBAAA;MAAA;;;;;uBAND,MAAA,CAAO,MAAA,CAAO,YAAA;QAAA,kBACX,MAAA,CAAO,MAAA,CAAO,YAAA;QAAA,iBACf,MAAA,CAAO,MAAA,CAAO,YAAA;MAAA;MAAA;;wBAIf,mBAAA;QAAA;;;;qBAND,MAAA,CAAO,MAAA,CAAO,YAAA;MAAA,kBACX,MAAA,CAAO,MAAA,CAAO,YAAA;MAAA,iBACf,MAAA,CAAO,MAAA,CAAO,YAAA;IAAA;MAAA;sBAIf,mBAAA;MAAA;;;;;;;;;;;;;;;;;AA6BX;;;cAoBa,OAAA,gBACE,MAAA,CAAO,MAAA,CAAO,YAAA,kBACX,MAAA,CAAO,MAAA,CAAO,YAAA,gBAChB,MAAA,CAAO,MAAA,CAAO,YAAA,UAE5B,IAAA,QAAY,IAAA,EACZ,OAAA,QAAe,OAAA,EACf,KAAA,SAAc,KAAA,KACb,OAAA,CAAQ,IAAA,EAAM,OAAA,EAAS,KAAA;AAAA,cAYb,MAAA,iBAAwB,mBAAA;EAAA;kBArE1B,mBAAA;EAAA"}
|
package/dist/GroupSpec.d.ts
CHANGED
|
@@ -8,21 +8,21 @@ declare namespace GroupSpec_d_exports {
|
|
|
8
8
|
declare const TypeId = "@confect/core/GroupSpec";
|
|
9
9
|
type TypeId = typeof TypeId;
|
|
10
10
|
declare const isGroupSpec: (u: unknown) => u is AnyWithProps;
|
|
11
|
-
interface GroupSpec<Runtime$
|
|
11
|
+
interface GroupSpec<Runtime$1 extends Runtime, Name_ extends string, Functions_ extends AnyWithPropsWithRuntime$1<Runtime$1> = never, Groups_ extends AnyWithProps = never> {
|
|
12
12
|
readonly [TypeId]: TypeId;
|
|
13
|
-
readonly runtime: Runtime$
|
|
13
|
+
readonly runtime: Runtime$1;
|
|
14
14
|
readonly name: Name_;
|
|
15
|
-
readonly functions: { [FunctionName in Name$1<AnyWithPropsWithRuntime$1<Runtime$
|
|
15
|
+
readonly functions: { [FunctionName in Name$1<AnyWithPropsWithRuntime$1<Runtime$1>>]: WithName$1<Functions_, FunctionName> };
|
|
16
16
|
readonly groups: { [GroupName in Name<Groups_>]: WithName<Groups_, GroupName> };
|
|
17
|
-
addFunction<Function extends AnyWithPropsWithRuntime$1<Runtime$
|
|
18
|
-
addGroup<Group extends
|
|
19
|
-
addGroupAt<const AtName extends string, Group extends
|
|
17
|
+
addFunction<Function extends AnyWithPropsWithRuntime$1<Runtime$1>>(function_: Function): GroupSpec<Runtime$1, Name_, Functions_ | Function, Groups_>;
|
|
18
|
+
addGroup<Group extends AnyWithProps>(group: Group): GroupSpec<Runtime$1, Name_, Functions_, Groups_ | Group>;
|
|
19
|
+
addGroupAt<const AtName extends string, Group extends AnyWithProps>(name: AtName, group: Group): GroupSpec<Runtime$1, Name_, Functions_, Groups_ | NamedAt<Group, AtName>>;
|
|
20
20
|
}
|
|
21
21
|
interface Any {
|
|
22
22
|
readonly [TypeId]: TypeId;
|
|
23
23
|
}
|
|
24
24
|
interface AnyWithProps extends GroupSpec<Runtime, string, AnyWithProps$1, AnyWithProps> {}
|
|
25
|
-
interface AnyWithPropsWithRuntime<Runtime$
|
|
25
|
+
interface AnyWithPropsWithRuntime<Runtime$2 extends Runtime> extends GroupSpec<Runtime$2, string, AnyWithPropsWithRuntime$1<Runtime$2>, AnyWithPropsWithRuntime<Runtime$2>> {}
|
|
26
26
|
type Name<Group extends AnyWithProps> = Group["name"];
|
|
27
27
|
type Functions<Group extends AnyWithProps> = Group["functions"][keyof Group["functions"]];
|
|
28
28
|
type Groups<Group extends AnyWithProps> = Group["groups"][keyof Group["groups"]];
|
package/dist/GroupSpec.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupSpec.d.ts","names":[],"sources":["../src/GroupSpec.ts"],"mappings":";;;;;;;cAMa,MAAA;AAAA,KACD,MAAA,UAAgB,MAAA;AAAA,cAEf,WAAA,GAAe,CAAA,cAAa,CAAA,IAAK,YAAA;AAAA,UAG7B,SAAA,mBACC,OAAA,2CAEG,yBAAA,CAAqC,SAAA,
|
|
1
|
+
{"version":3,"file":"GroupSpec.d.ts","names":[],"sources":["../src/GroupSpec.ts"],"mappings":";;;;;;;cAMa,MAAA;AAAA,KACD,MAAA,UAAgB,MAAA;AAAA,cAEf,WAAA,GAAe,CAAA,cAAa,CAAA,IAAK,YAAA;AAAA,UAG7B,SAAA,mBACC,OAAA,2CAEG,yBAAA,CAAqC,SAAA,2BAKxC,YAAA;EAAA,UAEN,MAAA,GAAS,MAAA;EAAA,SACV,OAAA,EAAS,SAAA;EAAA,SACT,IAAA,EAAM,KAAA;EAAA,SACN,SAAA,qBACU,MAAA,CACf,yBAAA,CAAqC,SAAA,KACnC,UAAA,CAAsB,UAAA,EAAY,YAAA;EAAA,SAE/B,MAAA,kBACO,IAAA,CAAK,OAAA,IAAW,QAAA,CAAS,OAAA,EAAS,SAAA;EAGlD,WAAA,kBAA6B,yBAAA,CAAqC,SAAA,GAChE,SAAA,EAAW,QAAA,GACV,SAAA,CAAU,SAAA,EAAS,KAAA,EAAO,UAAA,GAAa,QAAA,EAAU,OAAA;EAEpD,QAAA,eAAuB,YAAA,EACrB,KAAA,EAAO,KAAA,GACN,SAAA,CAAU,SAAA,EAAS,KAAA,EAAO,UAAA,EAAY,OAAA,GAAU,KAAA;EAEnD,UAAA,4CAAsD,YAAA,EACpD,IAAA,EAAM,MAAA,EACN,KAAA,EAAO,KAAA,GACN,SAAA,CAAU,SAAA,EAAS,KAAA,EAAO,UAAA,EAAY,OAAA,GAAU,OAAA,CAAQ,KAAA,EAAO,MAAA;AAAA;AAAA,UAGnD,GAAA;EAAA,UACL,MAAA,GAAS,MAAA;AAAA;AAAA,UAGJ,YAAA,SAAqB,SAAA,CACpC,OAAA,UAEA,cAAA,EACA,YAAA;AAAA,UAGe,uBAAA,mBACC,OAAA,UACR,SAAA,CACR,SAAA,UAEA,yBAAA,CAAqC,SAAA,GACrC,uBAAA,CAAwB,SAAA;AAAA,KAGd,IAAA,eAAmB,YAAA,IAAgB,KAAA;AAAA,KAEnC,SAAA,eAAwB,YAAA,IAClC,KAAA,oBAAyB,KAAA;AAAA,KAEf,MAAA,eAAqB,YAAA,IAC/B,KAAA,iBAAsB,KAAA;AAAA,KAEZ,UAAA,eAAyB,YAAA,KAAiB,MAAA,CAAO,KAAA,6BAIzD,IAAA,CAAK,MAAA,CAAO,KAAA;AAAA,KAEJ,QAAA,eACI,YAAA,gBACA,IAAA,CAAK,KAAA,KACjB,OAAA,CAAQ,KAAA;EAAA,SAAkB,IAAA,EAAM,KAAA;AAAA;;KAGxB,OAAA,eAAsB,GAAA,0BAA6B,IAAA,CAC7D,KAAA;EAAA,SAGS,IAAA,EAAM,KAAA;AAAA;AAAA,cAoEJ,IAAA,QAAW,SAAA;AAAA,cAQX,MAAA,+BACX,IAAA,EAAM,KAAA,KACL,SAAA,WAAoB,KAAA;AAAA,cAWV,QAAA,QAAe,SAAA;AAAA,cAQf,UAAA,+BACX,IAAA,EAAM,KAAA,KACL,SAAA,SAAkB,KAAA;AAAA,cAWR,QAAA,+BACX,IAAA,EAAM,KAAA,EACN,KAAA,EAAO,GAAA,KACN,YAAA"}
|
package/dist/GroupSpec.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupSpec.js","names":[],"sources":["../src/GroupSpec.ts"],"sourcesContent":["import * as Predicate from \"effect/Predicate\";\nimport * as Record from \"effect/Record\";\nimport type * as FunctionSpec from \"./FunctionSpec\";\nimport type * as RuntimeAndFunctionType from \"./RuntimeAndFunctionType\";\nimport { validateConfectFunctionIdentifier } from \"./Identifier\";\n\nexport const TypeId = \"@confect/core/GroupSpec\";\nexport type TypeId = typeof TypeId;\n\nexport const isGroupSpec = (u: unknown): u is AnyWithProps =>\n Predicate.hasProperty(u, TypeId);\n\nexport interface GroupSpec<\n Runtime extends RuntimeAndFunctionType.Runtime,\n Name_ extends string,\n Functions_ extends FunctionSpec.AnyWithPropsWithRuntime<Runtime> = never,\n Groups_ extends
|
|
1
|
+
{"version":3,"file":"GroupSpec.js","names":[],"sources":["../src/GroupSpec.ts"],"sourcesContent":["import * as Predicate from \"effect/Predicate\";\nimport * as Record from \"effect/Record\";\nimport type * as FunctionSpec from \"./FunctionSpec\";\nimport type * as RuntimeAndFunctionType from \"./RuntimeAndFunctionType\";\nimport { validateConfectFunctionIdentifier } from \"./Identifier\";\n\nexport const TypeId = \"@confect/core/GroupSpec\";\nexport type TypeId = typeof TypeId;\n\nexport const isGroupSpec = (u: unknown): u is AnyWithProps =>\n Predicate.hasProperty(u, TypeId);\n\nexport interface GroupSpec<\n Runtime extends RuntimeAndFunctionType.Runtime,\n Name_ extends string,\n Functions_ extends FunctionSpec.AnyWithPropsWithRuntime<Runtime> = never,\n // Subgroups may be of any runtime, independent of this group's own runtime: a\n // group is only a namespace for its children, which are otherwise-independent\n // modules. Functions, by contrast, stay homogeneous (a Node group only accepts\n // Node actions) — `addFunction` keeps the `<Runtime>` bound below.\n Groups_ extends AnyWithProps = never,\n> {\n readonly [TypeId]: TypeId;\n readonly runtime: Runtime;\n readonly name: Name_;\n readonly functions: {\n [FunctionName in FunctionSpec.Name<\n FunctionSpec.AnyWithPropsWithRuntime<Runtime>\n >]: FunctionSpec.WithName<Functions_, FunctionName>;\n };\n readonly groups: {\n [GroupName in Name<Groups_>]: WithName<Groups_, GroupName>;\n };\n\n addFunction<Function extends FunctionSpec.AnyWithPropsWithRuntime<Runtime>>(\n function_: Function,\n ): GroupSpec<Runtime, Name_, Functions_ | Function, Groups_>;\n\n addGroup<Group extends AnyWithProps>(\n group: Group,\n ): GroupSpec<Runtime, Name_, Functions_, Groups_ | Group>;\n\n addGroupAt<const AtName extends string, Group extends AnyWithProps>(\n name: AtName,\n group: Group,\n ): GroupSpec<Runtime, Name_, Functions_, Groups_ | NamedAt<Group, AtName>>;\n}\n\nexport interface Any {\n readonly [TypeId]: TypeId;\n}\n\nexport interface AnyWithProps extends GroupSpec<\n RuntimeAndFunctionType.Runtime,\n string,\n FunctionSpec.AnyWithProps,\n AnyWithProps\n> {}\n\nexport interface AnyWithPropsWithRuntime<\n Runtime extends RuntimeAndFunctionType.Runtime,\n> extends GroupSpec<\n Runtime,\n string,\n FunctionSpec.AnyWithPropsWithRuntime<Runtime>,\n AnyWithPropsWithRuntime<Runtime>\n> {}\n\nexport type Name<Group extends AnyWithProps> = Group[\"name\"];\n\nexport type Functions<Group extends AnyWithProps> =\n Group[\"functions\"][keyof Group[\"functions\"]];\n\nexport type Groups<Group extends AnyWithProps> =\n Group[\"groups\"][keyof Group[\"groups\"]];\n\nexport type GroupNames<Group extends AnyWithProps> = [Groups<Group>] extends [\n never,\n]\n ? never\n : Name<Groups<Group>>;\n\nexport type WithName<\n Group extends AnyWithProps,\n Name_ extends Name<Group>,\n> = Extract<Group, { readonly name: Name_ }>;\n\n/** Assigns a segment name to a leaf group created with {@link make} for typing and refs. */\nexport type NamedAt<Group extends Any, Name_ extends string> = Omit<\n Group,\n \"name\"\n> & {\n readonly name: Name_;\n};\n\nconst Proto = {\n [TypeId]: TypeId,\n\n addFunction<Function extends FunctionSpec.AnyWithProps>(\n this: Any,\n function_: Function,\n ) {\n const this_ = this as AnyWithProps;\n\n return makeProto({\n runtime: this_.runtime,\n name: this_.name,\n functions: Record.set(this_.functions, function_.name, function_),\n groups: this_.groups,\n });\n },\n\n addGroup<Group extends Any>(this: Any, group: Group) {\n const this_ = this as AnyWithProps;\n const group_ = group as unknown as AnyWithProps;\n\n return makeProto({\n runtime: this_.runtime,\n name: this_.name,\n functions: this_.functions,\n groups: Record.set(this_.groups, group_.name, group_),\n });\n },\n\n addGroupAt<Group extends Any>(this: Any, name: string, group: Group) {\n const this_ = this as AnyWithProps;\n const group_ = group as unknown as AnyWithProps;\n\n return makeProto({\n runtime: this_.runtime,\n name: this_.name,\n functions: this_.functions,\n groups: Record.set(this_.groups, name, withName(name, group_)),\n });\n },\n};\n\nconst makeProto = <\n Runtime extends RuntimeAndFunctionType.Runtime,\n Name_ extends string,\n Functions_ extends FunctionSpec.AnyWithPropsWithRuntime<Runtime>,\n Groups_ extends AnyWithPropsWithRuntime<Runtime>,\n>({\n runtime,\n name,\n functions,\n groups,\n}: {\n runtime: Runtime;\n name: Name_;\n functions: Record.ReadonlyRecord<string, Functions_>;\n groups: Record.ReadonlyRecord<string, Groups_>;\n}): GroupSpec<Runtime, Name_, Functions_, Groups_> =>\n Object.assign(Object.create(Proto), {\n runtime,\n name,\n functions,\n groups,\n });\n\nexport const make = (): GroupSpec<\"Convex\", \"\"> =>\n makeProto({\n runtime: \"Convex\",\n name: \"\",\n functions: Record.empty(),\n groups: Record.empty(),\n });\n\nexport const makeAt = <const Name_ extends string>(\n name: Name_,\n): GroupSpec<\"Convex\", Name_> => {\n validateConfectFunctionIdentifier(name);\n\n return makeProto({\n runtime: \"Convex\",\n name,\n functions: Record.empty(),\n groups: Record.empty(),\n });\n};\n\nexport const makeNode = (): GroupSpec<\"Node\", \"\"> =>\n makeProto({\n runtime: \"Node\",\n name: \"\",\n functions: Record.empty(),\n groups: Record.empty(),\n });\n\nexport const makeNodeAt = <const Name_ extends string>(\n name: Name_,\n): GroupSpec<\"Node\", Name_> => {\n validateConfectFunctionIdentifier(name);\n\n return makeProto({\n runtime: \"Node\",\n name,\n functions: Record.empty(),\n groups: Record.empty(),\n });\n};\n\nexport const withName = <const Name_ extends string>(\n name: Name_,\n group: Any,\n): AnyWithProps => {\n validateConfectFunctionIdentifier(name);\n const group_ = group as AnyWithProps;\n\n if (group_.name === name) {\n return group_;\n }\n\n return makeProto({\n runtime: group_.runtime,\n name,\n functions: group_.functions,\n groups: group_.groups,\n });\n};\n"],"mappings":";;;;;;;;;;;;;;;AAMA,MAAa,SAAS;AAGtB,MAAa,eAAe,MAC1B,UAAU,YAAY,GAAG,OAAO;AAqFlC,MAAM,QAAQ;EACX,SAAS;CAEV,YAEE,WACA;EACA,MAAM,QAAQ;AAEd,SAAO,UAAU;GACf,SAAS,MAAM;GACf,MAAM,MAAM;GACZ,WAAW,OAAO,IAAI,MAAM,WAAW,UAAU,MAAM,UAAU;GACjE,QAAQ,MAAM;GACf,CAAC;;CAGJ,SAAuC,OAAc;EACnD,MAAM,QAAQ;EACd,MAAM,SAAS;AAEf,SAAO,UAAU;GACf,SAAS,MAAM;GACf,MAAM,MAAM;GACZ,WAAW,MAAM;GACjB,QAAQ,OAAO,IAAI,MAAM,QAAQ,OAAO,MAAM,OAAO;GACtD,CAAC;;CAGJ,WAAyC,MAAc,OAAc;EACnE,MAAM,QAAQ;EACd,MAAM,SAAS;AAEf,SAAO,UAAU;GACf,SAAS,MAAM;GACf,MAAM,MAAM;GACZ,WAAW,MAAM;GACjB,QAAQ,OAAO,IAAI,MAAM,QAAQ,MAAM,SAAS,MAAM,OAAO,CAAC;GAC/D,CAAC;;CAEL;AAED,MAAM,aAKJ,EACA,SACA,MACA,WACA,aAOA,OAAO,OAAO,OAAO,OAAO,MAAM,EAAE;CAClC;CACA;CACA;CACA;CACD,CAAC;AAEJ,MAAa,aACX,UAAU;CACR,SAAS;CACT,MAAM;CACN,WAAW,OAAO,OAAO;CACzB,QAAQ,OAAO,OAAO;CACvB,CAAC;AAEJ,MAAa,UACX,SAC+B;AAC/B,mCAAkC,KAAK;AAEvC,QAAO,UAAU;EACf,SAAS;EACT;EACA,WAAW,OAAO,OAAO;EACzB,QAAQ,OAAO,OAAO;EACvB,CAAC;;AAGJ,MAAa,iBACX,UAAU;CACR,SAAS;CACT,MAAM;CACN,WAAW,OAAO,OAAO;CACzB,QAAQ,OAAO,OAAO;CACvB,CAAC;AAEJ,MAAa,cACX,SAC6B;AAC7B,mCAAkC,KAAK;AAEvC,QAAO,UAAU;EACf,SAAS;EACT;EACA,WAAW,OAAO,OAAO;EACzB,QAAQ,OAAO,OAAO;EACvB,CAAC;;AAGJ,MAAa,YACX,MACA,UACiB;AACjB,mCAAkC,KAAK;CACvC,MAAM,SAAS;AAEf,KAAI,OAAO,SAAS,KAClB,QAAO;AAGT,QAAO,UAAU;EACf,SAAS,OAAO;EAChB;EACA,WAAW,OAAO;EAClB,QAAQ,OAAO;EAChB,CAAC"}
|
package/dist/Refs.d.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { AnyWithProps, GetFunctionVisibility, GetRuntimeAndFunctionType, Name as Name$1, WithName } from "./FunctionSpec.js";
|
|
2
|
-
import { AnyWithProps as AnyWithProps$1, Functions,
|
|
2
|
+
import { AnyWithProps as AnyWithProps$1, Functions, Groups, Name as Name$2, WithName as WithName$1 } from "./GroupSpec.js";
|
|
3
3
|
import { Any, AnyInternal, AnyPublic, FromFunctionSpec, Ref } from "./Ref.js";
|
|
4
|
-
import {
|
|
4
|
+
import { AnyWithProps as AnyWithProps$2, Groups as Groups$1 } from "./Spec.js";
|
|
5
5
|
import { Types } from "effect";
|
|
6
6
|
|
|
7
7
|
//#region src/Refs.d.ts
|
|
8
8
|
declare namespace Refs_d_exports {
|
|
9
9
|
export { Refs, make };
|
|
10
10
|
}
|
|
11
|
-
type Refs<
|
|
11
|
+
type Refs<Spec_ extends AnyWithProps$2, Predicate extends Any = Any> = Types.Simplify<OmitEmpty<Helper<Groups$1<Spec_>, Predicate>>>;
|
|
12
12
|
type GroupRefs<Group extends AnyWithProps$1, Predicate extends Any> = Types.Simplify<OmitEmpty<Helper<Groups<Group>, Predicate>> & FilteredFunctions<Functions<Group>, Predicate>>;
|
|
13
13
|
type OmitEmpty<T> = { [K in keyof T as keyof T[K] extends never ? never : K]: T[K] };
|
|
14
14
|
type FunctionSpecMatchesPredicate<FunctionSpec_ extends AnyWithProps, Predicate extends Any> = Ref<GetRuntimeAndFunctionType<FunctionSpec_>, GetFunctionVisibility<FunctionSpec_>, any, any> extends Predicate ? true : false;
|
|
15
15
|
type FilteredFunctions<FunctionSpecs extends AnyWithProps, Predicate extends Any> = { [Name in Name$1<FunctionSpecs> as WithName<FunctionSpecs, Name> extends infer FunctionSpec_ extends AnyWithProps ? FunctionSpecMatchesPredicate<FunctionSpec_, Predicate> extends true ? Name : never : never]: WithName<FunctionSpecs, Name> extends infer F extends AnyWithProps ? FromFunctionSpec<F> : never };
|
|
16
16
|
type Helper<Groups extends AnyWithProps$1, Predicate extends Any> = { [GroupName in Name$2<Groups>]: WithName$1<Groups, GroupName> extends infer Group extends AnyWithProps$1 ? GroupRefs<Group, Predicate> : never };
|
|
17
|
-
declare const make: <
|
|
18
|
-
public: Refs<
|
|
19
|
-
internal: Refs<
|
|
17
|
+
declare const make: <Spec_ extends AnyWithProps$2>(spec: Spec_) => {
|
|
18
|
+
public: Refs<Spec_, AnyPublic>;
|
|
19
|
+
internal: Refs<Spec_, AnyInternal>;
|
|
20
20
|
};
|
|
21
21
|
//#endregion
|
|
22
22
|
export { Refs, Refs_d_exports, make };
|
package/dist/Refs.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Refs.d.ts","names":[],"sources":["../src/Refs.ts"],"mappings":";;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"Refs.d.ts","names":[],"sources":["../src/Refs.ts"],"mappings":";;;;;;;;;;KASY,IAAA,eACI,cAAA,oBACI,GAAA,GAAU,GAAA,IAC1B,KAAA,CAAM,QAAA,CAAS,SAAA,CAAU,MAAA,CAAO,QAAA,CAAY,KAAA,GAAQ,SAAA;AAAA,KAEnD,SAAA,eACW,cAAA,oBACI,GAAA,IAChB,KAAA,CAAM,QAAA,CACR,SAAA,CAAU,MAAA,CAAO,MAAA,CAAiB,KAAA,GAAQ,SAAA,KACxC,iBAAA,CAAkB,SAAA,CAAoB,KAAA,GAAQ,SAAA;AAAA,KAG7C,SAAA,oBACS,CAAA,UAAW,CAAA,CAAE,CAAA,0BAA2B,CAAA,GAAI,CAAA,CAAE,CAAA;AAAA,KAGvD,4BAAA,uBACmB,YAAA,oBACJ,GAAA,IAElB,GAAA,CACE,yBAAA,CAAuC,aAAA,GACvC,qBAAA,CAAmC,aAAA,qBAG3B,SAAA;AAAA,KAIP,iBAAA,uBACmB,YAAA,oBACJ,GAAA,eAET,MAAA,CAAkB,aAAA,KAAkB,QAAA,CAC3C,aAAA,EACA,IAAA,sCACoC,YAAA,GAClC,4BAAA,CAA6B,aAAA,EAAe,SAAA,iBAC1C,IAAA,mBAEM,QAAA,CAAsB,aAAA,EAAe,IAAA,0BAC/C,YAAA,GACE,gBAAA,CAAqB,CAAA;AAAA,KAItB,MAAA,gBACY,cAAA,oBACG,GAAA,oBAEJ,MAAA,CAAe,MAAA,IAAU,UAAA,CACrC,MAAA,EACA,SAAA,8BAC4B,cAAA,GAC1B,SAAA,CAAU,KAAA,EAAO,SAAA;AAAA,cAUV,IAAA,iBAAsB,cAAA,EACjC,IAAA,EAAM,KAAA;EAEN,MAAA,EAAQ,IAAA,CAAK,KAAA,EAAO,SAAA;EACpB,QAAA,EAAU,IAAA,CAAK,KAAA,EAAO,WAAA;AAAA"}
|
package/dist/Refs.js
CHANGED
|
@@ -1,21 +1,13 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
-
import { makeNodeAt } from "./GroupSpec.js";
|
|
3
2
|
import { getConvexFunctionName, make as make$1 } from "./Ref.js";
|
|
4
3
|
import * as Record from "effect/Record";
|
|
5
4
|
import * as Option from "effect/Option";
|
|
6
5
|
import { pipe } from "effect/Function";
|
|
7
|
-
import * as Array from "effect/Array";
|
|
8
6
|
|
|
9
7
|
//#region src/Refs.ts
|
|
10
8
|
var Refs_exports = /* @__PURE__ */ __exportAll({ make: () => make });
|
|
11
|
-
const make = (
|
|
12
|
-
const refs = makeHelper(
|
|
13
|
-
onNone: () => convexSpec.groups,
|
|
14
|
-
onSome: (nodeGroup) => ({
|
|
15
|
-
...convexSpec.groups,
|
|
16
|
-
node: nodeGroup
|
|
17
|
-
})
|
|
18
|
-
})));
|
|
9
|
+
const make = (spec) => {
|
|
10
|
+
const refs = makeHelper(spec.groups);
|
|
19
11
|
return {
|
|
20
12
|
public: refs,
|
|
21
13
|
internal: refs
|
package/dist/Refs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Refs.js","names":["
|
|
1
|
+
{"version":3,"file":"Refs.js","names":["Ref.make","Ref.getConvexFunctionName"],"sources":["../src/Refs.ts"],"sourcesContent":["import type { Types } from \"effect\";\nimport { pipe } from \"effect/Function\";\nimport * as Option from \"effect/Option\";\nimport * as Record from \"effect/Record\";\nimport type * as FunctionSpec from \"./FunctionSpec\";\nimport type * as GroupSpec from \"./GroupSpec\";\nimport * as Ref from \"./Ref\";\nimport type * as Spec from \"./Spec\";\n\nexport type Refs<\n Spec_ extends Spec.AnyWithProps,\n Predicate extends Ref.Any = Ref.Any,\n> = Types.Simplify<OmitEmpty<Helper<Spec.Groups<Spec_>, Predicate>>>;\n\ntype GroupRefs<\n Group extends GroupSpec.AnyWithProps,\n Predicate extends Ref.Any,\n> = Types.Simplify<\n OmitEmpty<Helper<GroupSpec.Groups<Group>, Predicate>> &\n FilteredFunctions<GroupSpec.Functions<Group>, Predicate>\n>;\n\ntype OmitEmpty<T> = {\n [K in keyof T as keyof T[K] extends never ? never : K]: T[K];\n};\n\ntype FunctionSpecMatchesPredicate<\n FunctionSpec_ extends FunctionSpec.AnyWithProps,\n Predicate extends Ref.Any,\n> =\n Ref.Ref<\n FunctionSpec.GetRuntimeAndFunctionType<FunctionSpec_>,\n FunctionSpec.GetFunctionVisibility<FunctionSpec_>,\n any,\n any\n > extends Predicate\n ? true\n : false;\n\ntype FilteredFunctions<\n FunctionSpecs extends FunctionSpec.AnyWithProps,\n Predicate extends Ref.Any,\n> = {\n [Name in FunctionSpec.Name<FunctionSpecs> as FunctionSpec.WithName<\n FunctionSpecs,\n Name\n > extends infer FunctionSpec_ extends FunctionSpec.AnyWithProps\n ? FunctionSpecMatchesPredicate<FunctionSpec_, Predicate> extends true\n ? Name\n : never\n : never]: FunctionSpec.WithName<FunctionSpecs, Name> extends infer F extends\n FunctionSpec.AnyWithProps\n ? Ref.FromFunctionSpec<F>\n : never;\n};\n\ntype Helper<\n Groups extends GroupSpec.AnyWithProps,\n Predicate extends Ref.Any,\n> = {\n [GroupName in GroupSpec.Name<Groups>]: GroupSpec.WithName<\n Groups,\n GroupName\n > extends infer Group extends GroupSpec.AnyWithProps\n ? GroupRefs<Group, Predicate>\n : never;\n};\n\ntype Any =\n | {\n readonly [key: string]: Any;\n }\n | Ref.Any;\n\nexport const make = <Spec_ extends Spec.AnyWithProps>(\n spec: Spec_,\n): {\n public: Refs<Spec_, Ref.AnyPublic>;\n internal: Refs<Spec_, Ref.AnyInternal>;\n} => {\n const refs = makeHelper(spec.groups);\n return {\n public: refs as Refs<Spec_, Ref.AnyPublic>,\n internal: refs as Refs<Spec_, Ref.AnyInternal>,\n };\n};\n\nconst makeHelper = (\n groups: Record.ReadonlyRecord<string, GroupSpec.Any>,\n functionNamespace: Option.Option<string> = Option.none(),\n): Any =>\n pipe(\n groups as Record.ReadonlyRecord<string, GroupSpec.AnyWithProps>,\n Record.map((group, name) => {\n const currentFunctionNamespace = Option.match(functionNamespace, {\n onNone: () => name,\n onSome: (parentNamespace) => `${parentNamespace}/${name}`,\n });\n\n return Record.union(\n makeHelper(group.groups, Option.some(currentFunctionNamespace)),\n Record.map(group.functions, (function_) =>\n Ref.make(currentFunctionNamespace, function_),\n ),\n (_subGroup, _function) => {\n throw new Error(\n `Group and function at same level have same name ('${Ref.getConvexFunctionName(_function)}')`,\n );\n },\n );\n }),\n );\n"],"mappings":";;;;;;;;AA0EA,MAAa,QACX,SAIG;CACH,MAAM,OAAO,WAAW,KAAK,OAAO;AACpC,QAAO;EACL,QAAQ;EACR,UAAU;EACX;;AAGH,MAAM,cACJ,QACA,oBAA2C,OAAO,MAAM,KAExD,KACE,QACA,OAAO,KAAK,OAAO,SAAS;CAC1B,MAAM,2BAA2B,OAAO,MAAM,mBAAmB;EAC/D,cAAc;EACd,SAAS,oBAAoB,GAAG,gBAAgB,GAAG;EACpD,CAAC;AAEF,QAAO,OAAO,MACZ,WAAW,MAAM,QAAQ,OAAO,KAAK,yBAAyB,CAAC,EAC/D,OAAO,IAAI,MAAM,YAAY,cAC3BA,OAAS,0BAA0B,UAAU,CAC9C,GACA,WAAW,cAAc;AACxB,QAAM,IAAI,MACR,qDAAqDC,sBAA0B,UAAU,CAAC,IAC3F;GAEJ;EACD,CACH"}
|
package/dist/Spec.d.ts
CHANGED
|
@@ -1,37 +1,31 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { AnyWithProps as AnyWithProps$1, AnyWithPropsWithRuntime as AnyWithPropsWithRuntime$1, Name, NamedAt, WithName } from "./GroupSpec.js";
|
|
1
|
+
import { AnyWithProps as AnyWithProps$1, Name, NamedAt, WithName } from "./GroupSpec.js";
|
|
3
2
|
|
|
4
3
|
//#region src/Spec.d.ts
|
|
5
4
|
declare namespace Spec_d_exports {
|
|
6
|
-
export { Any, AnyWithProps,
|
|
5
|
+
export { Any, AnyWithProps, Groups, Spec, TypeId, isSpec, make };
|
|
7
6
|
}
|
|
8
7
|
declare const TypeId = "@confect/core/Spec";
|
|
9
8
|
type TypeId = typeof TypeId;
|
|
10
9
|
declare const isSpec: (u: unknown) => u is AnyWithProps;
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
/**
|
|
11
|
+
* A Confect spec: a flat container of function groups. Groups may be of any
|
|
12
|
+
* runtime — a group built with `GroupSpec.makeNode()` (a Node action group) sits
|
|
13
|
+
* alongside `GroupSpec.make()` groups in the same namespace. The runtime of a
|
|
14
|
+
* group lives on the group itself (`GroupSpec.runtime`) and on each function's
|
|
15
|
+
* `RuntimeAndFunctionType`; the spec does not carry a runtime of its own.
|
|
16
|
+
*/
|
|
17
|
+
interface Spec<Groups_ extends AnyWithProps$1 = never> {
|
|
14
18
|
readonly [TypeId]: TypeId;
|
|
15
|
-
readonly runtime: Runtime$1;
|
|
16
19
|
readonly groups: { [GroupName in Name<Groups_>]: WithName<Groups_, GroupName> };
|
|
17
|
-
add<Group extends
|
|
18
|
-
addAt<const Name$1 extends string, Group extends
|
|
20
|
+
add<Group extends AnyWithProps$1>(group: Group): Spec<Groups_ | Group>;
|
|
21
|
+
addAt<const Name$1 extends string, Group extends AnyWithProps$1>(name: Name$1, group: Group): Spec<Groups_ | NamedAt<Group, Name$1>>;
|
|
19
22
|
}
|
|
20
23
|
interface Any {
|
|
21
24
|
readonly [TypeId]: TypeId;
|
|
22
25
|
}
|
|
23
|
-
interface AnyWithProps extends Spec<
|
|
24
|
-
interface AnyWithPropsWithRuntime<Runtime$2 extends Runtime> extends Spec<Runtime$2, AnyWithPropsWithRuntime$1<Runtime$2>> {}
|
|
26
|
+
interface AnyWithProps extends Spec<AnyWithProps$1> {}
|
|
25
27
|
type Groups<Spec_ extends AnyWithProps> = Spec_["groups"][keyof Spec_["groups"]];
|
|
26
|
-
declare const make: () => Spec
|
|
27
|
-
declare const makeNode: () => Spec<"Node">;
|
|
28
|
-
/**
|
|
29
|
-
* Merges a Convex spec with an optional Node spec into a single assembled
|
|
30
|
-
* spec (used by codegen to build `Refs.make` and to enumerate function paths).
|
|
31
|
-
* When `nodeSpec` is provided, its groups are merged under a "node" namespace,
|
|
32
|
-
* mirroring the structure used by `Refs.make`.
|
|
33
|
-
*/
|
|
34
|
-
declare const merge: <ConvexSpec extends AnyWithPropsWithRuntime<"Convex">, NodeSpec extends AnyWithPropsWithRuntime<"Node">>(convexSpec: ConvexSpec, nodeSpec?: NodeSpec) => AnyWithProps;
|
|
28
|
+
declare const make: () => Spec;
|
|
35
29
|
//#endregion
|
|
36
|
-
export { Any, AnyWithProps,
|
|
30
|
+
export { Any, AnyWithProps, Groups, Spec, Spec_d_exports, TypeId, isSpec, make };
|
|
37
31
|
//# sourceMappingURL=Spec.d.ts.map
|
package/dist/Spec.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Spec.d.ts","names":[],"sources":["../src/Spec.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Spec.d.ts","names":[],"sources":["../src/Spec.ts"],"mappings":";;;;;;cAIa,MAAA;AAAA,KACD,MAAA,UAAgB,MAAA;AAAA,cAEf,MAAA,GAAU,CAAA,cAAa,CAAA,IAAK,YAAA;;;;;;;;UAUxB,IAAA,iBAAqB,cAAA;EAAA,UAC1B,MAAA,GAAS,MAAA;EAAA,SACV,MAAA,kBACO,IAAA,CAAe,OAAA,IAAW,QAAA,CACtC,OAAA,EACA,SAAA;EAIJ,GAAA,eAAkB,cAAA,EAChB,KAAA,EAAO,KAAA,GACN,IAAA,CAAK,OAAA,GAAU,KAAA;EAElB,KAAA,4CAA+C,cAAA,EAC7C,IAAA,EAAM,MAAA,EACN,KAAA,EAAO,KAAA,GACN,IAAA,CAAK,OAAA,GAAU,OAAA,CAAkB,KAAA,EAAO,MAAA;AAAA;AAAA,UAG5B,GAAA;EAAA,UACL,MAAA,GAAS,MAAA;AAAA;AAAA,UAGJ,YAAA,SAAqB,IAAA,CAAK,cAAA;AAAA,KAE/B,MAAA,eAAqB,YAAA,IAC/B,KAAA,iBAAsB,KAAA;AAAA,cA+BX,IAAA,QAAW,IAAA"}
|
package/dist/Spec.js
CHANGED
|
@@ -1,71 +1,28 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
-
import {
|
|
2
|
+
import { withName } from "./GroupSpec.js";
|
|
3
3
|
import * as Predicate from "effect/Predicate";
|
|
4
4
|
import * as Record from "effect/Record";
|
|
5
|
-
import * as Option from "effect/Option";
|
|
6
|
-
import * as Array from "effect/Array";
|
|
7
5
|
|
|
8
6
|
//#region src/Spec.ts
|
|
9
7
|
var Spec_exports = /* @__PURE__ */ __exportAll({
|
|
10
8
|
TypeId: () => TypeId,
|
|
11
|
-
isConvexSpec: () => isConvexSpec,
|
|
12
|
-
isNodeSpec: () => isNodeSpec,
|
|
13
9
|
isSpec: () => isSpec,
|
|
14
|
-
make: () => make
|
|
15
|
-
makeNode: () => makeNode,
|
|
16
|
-
merge: () => merge
|
|
10
|
+
make: () => make
|
|
17
11
|
});
|
|
18
12
|
const TypeId = "@confect/core/Spec";
|
|
19
13
|
const isSpec = (u) => Predicate.hasProperty(u, TypeId);
|
|
20
|
-
const isConvexSpec = (u) => Predicate.hasProperty(u, TypeId) && Predicate.hasProperty(u, "runtime") && u.runtime === "Convex";
|
|
21
|
-
const isNodeSpec = (u) => Predicate.hasProperty(u, TypeId) && Predicate.hasProperty(u, "runtime") && u.runtime === "Node";
|
|
22
14
|
const Proto = {
|
|
23
15
|
[TypeId]: TypeId,
|
|
24
16
|
add(group) {
|
|
25
|
-
return makeProto({
|
|
26
|
-
runtime: this.runtime,
|
|
27
|
-
groups: Record.set(this.groups, group.name, group)
|
|
28
|
-
});
|
|
17
|
+
return makeProto({ groups: Record.set(this.groups, group.name, group) });
|
|
29
18
|
},
|
|
30
19
|
addAt(name, group) {
|
|
31
|
-
return makeProto({
|
|
32
|
-
runtime: this.runtime,
|
|
33
|
-
groups: Record.set(this.groups, name, withName(name, group))
|
|
34
|
-
});
|
|
20
|
+
return makeProto({ groups: Record.set(this.groups, name, withName(name, group)) });
|
|
35
21
|
}
|
|
36
22
|
};
|
|
37
|
-
const makeProto = ({
|
|
38
|
-
|
|
39
|
-
groups
|
|
40
|
-
});
|
|
41
|
-
const make = () => makeProto({
|
|
42
|
-
runtime: "Convex",
|
|
43
|
-
groups: {}
|
|
44
|
-
});
|
|
45
|
-
const makeNode = () => makeProto({
|
|
46
|
-
runtime: "Node",
|
|
47
|
-
groups: {}
|
|
48
|
-
});
|
|
49
|
-
/**
|
|
50
|
-
* Merges a Convex spec with an optional Node spec into a single assembled
|
|
51
|
-
* spec (used by codegen to build `Refs.make` and to enumerate function paths).
|
|
52
|
-
* When `nodeSpec` is provided, its groups are merged under a "node" namespace,
|
|
53
|
-
* mirroring the structure used by `Refs.make`.
|
|
54
|
-
*/
|
|
55
|
-
const merge = (convexSpec, nodeSpec) => {
|
|
56
|
-
const groups = Option.fromNullable(nodeSpec).pipe(Option.map((nodeSpec_) => Array.reduce(Record.toEntries(nodeSpec_.groups), makeNodeAt("node"), (nodeGroupSpec, [name, group]) => nodeGroupSpec.addGroupAt(name, group))), Option.match({
|
|
57
|
-
onNone: () => convexSpec.groups,
|
|
58
|
-
onSome: (nodeGroup) => ({
|
|
59
|
-
...convexSpec.groups,
|
|
60
|
-
node: nodeGroup
|
|
61
|
-
})
|
|
62
|
-
}));
|
|
63
|
-
return Object.assign(Object.create(Proto), {
|
|
64
|
-
runtime: "Convex",
|
|
65
|
-
groups
|
|
66
|
-
});
|
|
67
|
-
};
|
|
23
|
+
const makeProto = ({ groups }) => Object.assign(Object.create(Proto), { groups });
|
|
24
|
+
const make = () => makeProto({ groups: {} });
|
|
68
25
|
|
|
69
26
|
//#endregion
|
|
70
|
-
export { Spec_exports, TypeId,
|
|
27
|
+
export { Spec_exports, TypeId, isSpec, make };
|
|
71
28
|
//# sourceMappingURL=Spec.js.map
|
package/dist/Spec.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Spec.js","names":["GroupSpec.withName"
|
|
1
|
+
{"version":3,"file":"Spec.js","names":["GroupSpec.withName"],"sources":["../src/Spec.ts"],"sourcesContent":["import * as Predicate from \"effect/Predicate\";\nimport * as Record from \"effect/Record\";\nimport * as GroupSpec from \"./GroupSpec\";\n\nexport const TypeId = \"@confect/core/Spec\";\nexport type TypeId = typeof TypeId;\n\nexport const isSpec = (u: unknown): u is AnyWithProps =>\n Predicate.hasProperty(u, TypeId);\n\n/**\n * A Confect spec: a flat container of function groups. Groups may be of any\n * runtime — a group built with `GroupSpec.makeNode()` (a Node action group) sits\n * alongside `GroupSpec.make()` groups in the same namespace. The runtime of a\n * group lives on the group itself (`GroupSpec.runtime`) and on each function's\n * `RuntimeAndFunctionType`; the spec does not carry a runtime of its own.\n */\nexport interface Spec<Groups_ extends GroupSpec.AnyWithProps = never> {\n readonly [TypeId]: TypeId;\n readonly groups: {\n [GroupName in GroupSpec.Name<Groups_>]: GroupSpec.WithName<\n Groups_,\n GroupName\n >;\n };\n\n add<Group extends GroupSpec.AnyWithProps>(\n group: Group,\n ): Spec<Groups_ | Group>;\n\n addAt<const Name extends string, Group extends GroupSpec.AnyWithProps>(\n name: Name,\n group: Group,\n ): Spec<Groups_ | GroupSpec.NamedAt<Group, Name>>;\n}\n\nexport interface Any {\n readonly [TypeId]: TypeId;\n}\n\nexport interface AnyWithProps extends Spec<GroupSpec.AnyWithProps> {}\n\nexport type Groups<Spec_ extends AnyWithProps> =\n Spec_[\"groups\"][keyof Spec_[\"groups\"]];\n\nconst Proto = {\n [TypeId]: TypeId,\n\n add<Group extends GroupSpec.AnyWithProps>(this: AnyWithProps, group: Group) {\n return makeProto({\n groups: Record.set(this.groups, group.name, group),\n });\n },\n\n addAt<Group extends GroupSpec.AnyWithProps>(\n this: AnyWithProps,\n name: string,\n group: Group,\n ) {\n return makeProto({\n groups: Record.set(this.groups, name, GroupSpec.withName(name, group)),\n });\n },\n};\n\nconst makeProto = <Groups_ extends GroupSpec.AnyWithProps>({\n groups,\n}: {\n groups: Record.ReadonlyRecord<string, Groups_>;\n}): Spec<Groups_> =>\n Object.assign(Object.create(Proto), {\n groups,\n });\n\nexport const make = (): Spec => makeProto({ groups: {} });\n"],"mappings":";;;;;;;;;;;AAIA,MAAa,SAAS;AAGtB,MAAa,UAAU,MACrB,UAAU,YAAY,GAAG,OAAO;AAqClC,MAAM,QAAQ;EACX,SAAS;CAEV,IAA8D,OAAc;AAC1E,SAAO,UAAU,EACf,QAAQ,OAAO,IAAI,KAAK,QAAQ,MAAM,MAAM,MAAM,EACnD,CAAC;;CAGJ,MAEE,MACA,OACA;AACA,SAAO,UAAU,EACf,QAAQ,OAAO,IAAI,KAAK,QAAQ,MAAMA,SAAmB,MAAM,MAAM,CAAC,EACvE,CAAC;;CAEL;AAED,MAAM,aAAqD,EACzD,aAIA,OAAO,OAAO,OAAO,OAAO,MAAM,EAAE,EAClC,QACD,CAAC;AAEJ,MAAa,aAAmB,UAAU,EAAE,QAAQ,EAAE,EAAE,CAAC"}
|
package/package.json
CHANGED
package/src/GroupSpec.ts
CHANGED
|
@@ -14,7 +14,11 @@ export interface GroupSpec<
|
|
|
14
14
|
Runtime extends RuntimeAndFunctionType.Runtime,
|
|
15
15
|
Name_ extends string,
|
|
16
16
|
Functions_ extends FunctionSpec.AnyWithPropsWithRuntime<Runtime> = never,
|
|
17
|
-
|
|
17
|
+
// Subgroups may be of any runtime, independent of this group's own runtime: a
|
|
18
|
+
// group is only a namespace for its children, which are otherwise-independent
|
|
19
|
+
// modules. Functions, by contrast, stay homogeneous (a Node group only accepts
|
|
20
|
+
// Node actions) — `addFunction` keeps the `<Runtime>` bound below.
|
|
21
|
+
Groups_ extends AnyWithProps = never,
|
|
18
22
|
> {
|
|
19
23
|
readonly [TypeId]: TypeId;
|
|
20
24
|
readonly runtime: Runtime;
|
|
@@ -32,14 +36,11 @@ export interface GroupSpec<
|
|
|
32
36
|
function_: Function,
|
|
33
37
|
): GroupSpec<Runtime, Name_, Functions_ | Function, Groups_>;
|
|
34
38
|
|
|
35
|
-
addGroup<Group extends
|
|
39
|
+
addGroup<Group extends AnyWithProps>(
|
|
36
40
|
group: Group,
|
|
37
41
|
): GroupSpec<Runtime, Name_, Functions_, Groups_ | Group>;
|
|
38
42
|
|
|
39
|
-
addGroupAt<
|
|
40
|
-
const AtName extends string,
|
|
41
|
-
Group extends AnyWithPropsWithRuntime<Runtime>,
|
|
42
|
-
>(
|
|
43
|
+
addGroupAt<const AtName extends string, Group extends AnyWithProps>(
|
|
43
44
|
name: AtName,
|
|
44
45
|
group: Group,
|
|
45
46
|
): GroupSpec<Runtime, Name_, Functions_, Groups_ | NamedAt<Group, AtName>>;
|
package/src/Refs.ts
CHANGED
|
@@ -1,33 +1,16 @@
|
|
|
1
1
|
import type { Types } from "effect";
|
|
2
2
|
import { pipe } from "effect/Function";
|
|
3
|
-
import * as Array from "effect/Array";
|
|
4
3
|
import * as Option from "effect/Option";
|
|
5
4
|
import * as Record from "effect/Record";
|
|
6
5
|
import type * as FunctionSpec from "./FunctionSpec";
|
|
7
|
-
import * as GroupSpec from "./GroupSpec";
|
|
6
|
+
import type * as GroupSpec from "./GroupSpec";
|
|
8
7
|
import * as Ref from "./Ref";
|
|
9
8
|
import type * as Spec from "./Spec";
|
|
10
9
|
|
|
11
10
|
export type Refs<
|
|
12
|
-
|
|
13
|
-
NodeSpec extends Spec.AnyWithPropsWithRuntime<"Node"> = never,
|
|
11
|
+
Spec_ extends Spec.AnyWithProps,
|
|
14
12
|
Predicate extends Ref.Any = Ref.Any,
|
|
15
|
-
> = Types.Simplify<
|
|
16
|
-
OmitEmpty<
|
|
17
|
-
Helper<
|
|
18
|
-
| Spec.Groups<ConvexSpec>
|
|
19
|
-
| (NodeSpec extends never
|
|
20
|
-
? never
|
|
21
|
-
: GroupSpec.GroupSpec<
|
|
22
|
-
"Node",
|
|
23
|
-
"node",
|
|
24
|
-
never,
|
|
25
|
-
NodeSpec["groups"][keyof NodeSpec["groups"]]
|
|
26
|
-
>),
|
|
27
|
-
Predicate
|
|
28
|
-
>
|
|
29
|
-
>
|
|
30
|
-
>;
|
|
13
|
+
> = Types.Simplify<OmitEmpty<Helper<Spec.Groups<Spec_>, Predicate>>>;
|
|
31
14
|
|
|
32
15
|
type GroupRefs<
|
|
33
16
|
Group extends GroupSpec.AnyWithProps,
|
|
@@ -89,33 +72,16 @@ type Any =
|
|
|
89
72
|
}
|
|
90
73
|
| Ref.Any;
|
|
91
74
|
|
|
92
|
-
export const make = <
|
|
93
|
-
|
|
94
|
-
NodeSpec extends Spec.AnyWithPropsWithRuntime<"Node"> = never,
|
|
95
|
-
>(
|
|
96
|
-
convexSpec: ConvexSpec,
|
|
97
|
-
nodeSpec?: NodeSpec,
|
|
75
|
+
export const make = <Spec_ extends Spec.AnyWithProps>(
|
|
76
|
+
spec: Spec_,
|
|
98
77
|
): {
|
|
99
|
-
public: Refs<
|
|
100
|
-
internal: Refs<
|
|
78
|
+
public: Refs<Spec_, Ref.AnyPublic>;
|
|
79
|
+
internal: Refs<Spec_, Ref.AnyInternal>;
|
|
101
80
|
} => {
|
|
102
|
-
const
|
|
103
|
-
Option.map((nodeSpec_) =>
|
|
104
|
-
Array.reduce(
|
|
105
|
-
Record.toEntries(nodeSpec_.groups),
|
|
106
|
-
GroupSpec.makeNodeAt("node"),
|
|
107
|
-
(nodeGroupSpec, [name, group]) => nodeGroupSpec.addGroupAt(name, group),
|
|
108
|
-
),
|
|
109
|
-
),
|
|
110
|
-
Option.match({
|
|
111
|
-
onNone: () => convexSpec.groups,
|
|
112
|
-
onSome: (nodeGroup) => ({ ...convexSpec.groups, node: nodeGroup }),
|
|
113
|
-
}),
|
|
114
|
-
);
|
|
115
|
-
const refs = makeHelper(groups);
|
|
81
|
+
const refs = makeHelper(spec.groups);
|
|
116
82
|
return {
|
|
117
|
-
public: refs as Refs<
|
|
118
|
-
internal: refs as Refs<
|
|
83
|
+
public: refs as Refs<Spec_, Ref.AnyPublic>,
|
|
84
|
+
internal: refs as Refs<Spec_, Ref.AnyInternal>,
|
|
119
85
|
};
|
|
120
86
|
};
|
|
121
87
|
|
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
|
-
|
|
15
|
-
|
|
16
|
-
)
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
export
|
|
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.
|
|
27
|
+
add<Group extends GroupSpec.AnyWithProps>(
|
|
40
28
|
group: Group,
|
|
41
|
-
): Spec<
|
|
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<
|
|
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<
|
|
70
|
+
}): Spec<Groups_> =>
|
|
100
71
|
Object.assign(Object.create(Proto), {
|
|
101
|
-
runtime,
|
|
102
72
|
groups,
|
|
103
73
|
});
|
|
104
74
|
|
|
105
|
-
export const make = (): Spec
|
|
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: {} });
|