@confect/server 9.0.0-next.2 → 9.0.0-next.3
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 +29 -0
- package/dist/Api.d.ts +15 -2
- package/dist/Api.d.ts.map +1 -1
- package/dist/Api.js +19 -2
- package/dist/Api.js.map +1 -1
- package/dist/FunctionImpl.d.ts +1 -1
- package/dist/FunctionImpl.d.ts.map +1 -1
- package/dist/FunctionImpl.js +2 -2
- package/dist/FunctionImpl.js.map +1 -1
- package/dist/GroupImpl.d.ts.map +1 -1
- package/dist/GroupImpl.js +2 -2
- package/dist/GroupImpl.js.map +1 -1
- package/dist/RegisteredConvexFunction.d.ts +5 -5
- package/dist/RegisteredConvexFunction.d.ts.map +1 -1
- package/dist/RegisteredFunction.d.ts +2 -2
- package/dist/RegisteredFunction.d.ts.map +1 -1
- package/dist/RegisteredFunctions.d.ts +1 -1
- package/package.json +2 -2
- package/src/Api.ts +27 -0
- package/src/FunctionImpl.ts +2 -3
- package/src/GroupImpl.ts +2 -3
- package/dist/GroupPath.d.ts +0 -8
- package/dist/GroupPath.d.ts.map +0 -1
- package/dist/GroupPath.js +0 -10
- package/dist/GroupPath.js.map +0 -1
- package/src/GroupPath.ts +0 -43
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,34 @@
|
|
|
1
1
|
# @confect/server
|
|
2
2
|
|
|
3
|
+
## 9.0.0-next.3
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 6d85210: Resolve `FunctionImpl` / `GroupImpl` group paths via an immutable `paths` map on `Spec` instead of identity-walking the assembled tree.
|
|
8
|
+
|
|
9
|
+
### Why
|
|
10
|
+
|
|
11
|
+
Since `9.0.0-next.1`, codegen has wrapped every parent leaf that has sibling subdirectory specs in `<parent>.addGroupAt("child", <child>)`. Because `GroupSpec.addGroupAt` is immutable, that produced a fresh object in the assembled tree, while the parent's `*.impl.ts` continued to hold a reference to the original imported leaf. The runtime resolver compared by `===`, so every such impl failed `validateImpl` with "Could not resolve group path for the provided GroupSpec." Child impls happened to work only because `GroupSpec.withName` was secretly mutating its argument in place to keep the child's identity stable — an asymmetry that was load-bearing for one half of the API and broken for the other.
|
|
12
|
+
|
|
13
|
+
### What changed
|
|
14
|
+
- `@confect/core/Spec` carries a new `readonly paths: ReadonlyMap<GroupSpec.AnyWithProps, string>` field and exposes a chainable `Spec#addPath(group, path)` builder. `add` / `addAt` / `merge` propagate `paths` unchanged; `merge` re-prefixes a node spec's entries with `"node."` to match the merged tree.
|
|
15
|
+
- `@confect/core/GroupSpec.withName` is now pure: it returns a fresh copy when the name differs and no longer rewrites the input in place. No new identity-tracking machinery is introduced.
|
|
16
|
+
- `@confect/server/FunctionImpl.make` and `GroupImpl.make` resolve their group path via `api.spec.paths.get(group)` — an O(1) map lookup instead of a tree walk — and throw a clearer error pointing at `Spec.addPath` when the spec hasn't been registered.
|
|
17
|
+
- `@confect/server/GroupPath` (the old identity-based resolver) is deleted.
|
|
18
|
+
- `@confect/cli` codegen emits one `.addPath(<binding>, "<dot.path>")` call per leaf in `_generated/spec.ts` (and `_generated/nodeSpec.ts`) so the imported leaves carry their full paths into the assembled spec value.
|
|
19
|
+
|
|
20
|
+
### User-facing impact
|
|
21
|
+
- Spec authoring (`*.spec.ts`) and impl authoring (`*.impl.ts`) APIs are unchanged. `FunctionImpl.make(api, spec, name, handler)` and `GroupImpl.make(api, spec)` keep their exact signatures.
|
|
22
|
+
- Generated `_generated/spec.ts` (and `_generated/nodeSpec.ts`) pick up one `.addPath(...)` chain entry per leaf on the next `confect codegen` run. The shape is fully immutable — no module-load mutation, no hidden side effects.
|
|
23
|
+
- Hand-rolled tests that construct a `Spec` and pass it to `Api.make` must now also call `.addPath(spec, "dot.path")` for any group they intend to look up.
|
|
24
|
+
|
|
25
|
+
### Fixes
|
|
26
|
+
|
|
27
|
+
This eliminates the runtime regression introduced in `9.0.0-next.1` for any project layout where a `confect/{path}.spec.ts` declares functions alongside a sibling `confect/{path}/` subdirectory of further specs.
|
|
28
|
+
|
|
29
|
+
- Updated dependencies [6d85210]
|
|
30
|
+
- @confect/core@9.0.0-next.3
|
|
31
|
+
|
|
3
32
|
## 9.0.0-next.2
|
|
4
33
|
|
|
5
34
|
### Patch Changes
|
package/dist/Api.d.ts
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { AnyWithProps as AnyWithProps$1 } from "./DatabaseSchema.js";
|
|
2
2
|
import { GenericSchema, SchemaDefinition } from "convex/server";
|
|
3
3
|
import { RuntimeAndFunctionType } from "@confect/core";
|
|
4
|
+
import * as GroupSpec from "@confect/core/GroupSpec";
|
|
4
5
|
import * as Spec from "@confect/core/Spec";
|
|
5
6
|
|
|
6
7
|
//#region src/Api.d.ts
|
|
7
8
|
declare namespace Api_d_exports {
|
|
8
|
-
export { Any, AnyWithProps, AnyWithPropsWithRuntime, Api, GetSpec, Groups, Schema, TypeId, isApi, make };
|
|
9
|
+
export { Any, AnyWithProps, AnyWithPropsWithRuntime, Api, GetSpec, Groups, Schema, TypeId, isApi, make, resolveGroupPathUnsafe };
|
|
9
10
|
}
|
|
10
11
|
declare const TypeId = "@confect/server/Api";
|
|
11
12
|
type TypeId = typeof TypeId;
|
|
@@ -25,6 +26,18 @@ type Schema<Api_ extends AnyWithProps> = Api_["databaseSchema"];
|
|
|
25
26
|
type GetSpec<Api_ extends AnyWithProps> = Api_["spec"];
|
|
26
27
|
type Groups<Api_ extends AnyWithProps> = Spec.Groups<Api_["spec"]>;
|
|
27
28
|
declare const make: <DatabaseSchema_ extends AnyWithProps$1, Spec_ extends Spec.AnyWithProps>(databaseSchema: DatabaseSchema_, spec: Spec_) => Api<DatabaseSchema_, Spec_>;
|
|
29
|
+
/**
|
|
30
|
+
* Resolve the dot-path of `group` within `api.spec` by reading the immutable
|
|
31
|
+
* `paths` mapping that codegen populated in `_generated/spec.ts`. Throws when
|
|
32
|
+
* the spec is not registered, with a message pointing the caller at the
|
|
33
|
+
* place to register it.
|
|
34
|
+
*
|
|
35
|
+
* The legacy identity-based tree walk (`packages/server/src/GroupPath.ts`)
|
|
36
|
+
* was deleted in favor of this O(1) map lookup; both the registration
|
|
37
|
+
* mechanism (`Spec.addPath`) and the lookup key are the same JS reference
|
|
38
|
+
* thanks to ES module dedup between `_generated/spec.ts` and `*.impl.ts`.
|
|
39
|
+
*/
|
|
40
|
+
declare const resolveGroupPathUnsafe: (api: AnyWithProps, group: GroupSpec.AnyWithProps) => string;
|
|
28
41
|
//#endregion
|
|
29
|
-
export { Any, AnyWithProps, AnyWithPropsWithRuntime, Api, Api_d_exports, GetSpec, Groups, Schema, TypeId, isApi, make };
|
|
42
|
+
export { Any, AnyWithProps, AnyWithPropsWithRuntime, Api, Api_d_exports, GetSpec, Groups, Schema, TypeId, isApi, make, resolveGroupPathUnsafe };
|
|
30
43
|
//# sourceMappingURL=Api.d.ts.map
|
package/dist/Api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Api.d.ts","names":[],"sources":["../src/Api.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Api.d.ts","names":[],"sources":["../src/Api.ts"],"mappings":";;;;;;;;;;cAQa,MAAA;AAAA,KACD,MAAA,UAAgB,MAAA;AAAA,cAEf,KAAA,GAAS,CAAA,cAAa,CAAA,IAAK,GAAA;AAAA,UAEvB,GAAA,yBACS,cAAA,gBACV,IAAA,CAAK,YAAA;EAAA,UAET,MAAA,GAAS,MAAA;EAAA,SACV,IAAA,EAAM,KAAA;EAAA,SACN,cAAA,EAAgB,eAAA;EAAA,SAChB,sBAAA,EAAwB,gBAAA,CAAiB,aAAA;AAAA;AAAA,UAGnC,GAAA;EAAA,UACL,MAAA,GAAS,MAAA;AAAA;AAAA,UAGJ,YAAA,SAAqB,GAAA,CACpC,cAAA,EACA,IAAA,CAAK,YAAA;AAAA,UAGU,uBAAA,iBACC,sBAAA,CAAuB,OAAA,UAC/B,GAAA,CACR,cAAA,EACA,IAAA,CAAK,uBAAA,CAAwB,OAAA;AAAA,KAGnB,MAAA,cAAoB,YAAA,IAAgB,IAAA;AAAA,KAEpC,OAAA,cAAqB,YAAA,IAAgB,IAAA;AAAA,KAErC,MAAA,cAAoB,YAAA,IAAgB,IAAA,CAAK,MAAA,CAAO,IAAA;AAAA,cA0B/C,IAAA,2BACa,cAAA,gBACV,IAAA,CAAK,YAAA,EAEnB,cAAA,EAAgB,eAAA,EAChB,IAAA,EAAM,KAAA,KACL,GAAA,CAAI,eAAA,EAAiB,KAAA;;AAlExB;;;;;AAEA;;;;;cA6Ea,sBAAA,GACX,GAAA,EAAK,YAAA,EACL,KAAA,EAAO,SAAA,CAAU,YAAA"}
|
package/dist/Api.js
CHANGED
|
@@ -6,7 +6,8 @@ import { defineSchema } from "convex/server";
|
|
|
6
6
|
var Api_exports = /* @__PURE__ */ __exportAll({
|
|
7
7
|
TypeId: () => TypeId,
|
|
8
8
|
isApi: () => isApi,
|
|
9
|
-
make: () => make
|
|
9
|
+
make: () => make,
|
|
10
|
+
resolveGroupPathUnsafe: () => resolveGroupPathUnsafe
|
|
10
11
|
});
|
|
11
12
|
const TypeId = "@confect/server/Api";
|
|
12
13
|
const isApi = (u) => Predicate.hasProperty(u, TypeId);
|
|
@@ -20,7 +21,23 @@ const make = (databaseSchema, spec) => makeProto({
|
|
|
20
21
|
databaseSchema,
|
|
21
22
|
spec
|
|
22
23
|
});
|
|
24
|
+
/**
|
|
25
|
+
* Resolve the dot-path of `group` within `api.spec` by reading the immutable
|
|
26
|
+
* `paths` mapping that codegen populated in `_generated/spec.ts`. Throws when
|
|
27
|
+
* the spec is not registered, with a message pointing the caller at the
|
|
28
|
+
* place to register it.
|
|
29
|
+
*
|
|
30
|
+
* The legacy identity-based tree walk (`packages/server/src/GroupPath.ts`)
|
|
31
|
+
* was deleted in favor of this O(1) map lookup; both the registration
|
|
32
|
+
* mechanism (`Spec.addPath`) and the lookup key are the same JS reference
|
|
33
|
+
* thanks to ES module dedup between `_generated/spec.ts` and `*.impl.ts`.
|
|
34
|
+
*/
|
|
35
|
+
const resolveGroupPathUnsafe = (api, group) => {
|
|
36
|
+
const groupPath = api.spec.paths.get(group);
|
|
37
|
+
if (groupPath === void 0) throw new Error("GroupSpec has no registered path in this api's spec. Ensure the spec is added via Spec.addPath in _generated/spec.ts (or, in tests, call .addPath(spec, 'dot.path') on the Spec you pass to Api.make).");
|
|
38
|
+
return groupPath;
|
|
39
|
+
};
|
|
23
40
|
|
|
24
41
|
//#endregion
|
|
25
|
-
export { Api_exports, TypeId, isApi, make };
|
|
42
|
+
export { Api_exports, TypeId, isApi, make, resolveGroupPathUnsafe };
|
|
26
43
|
//# sourceMappingURL=Api.js.map
|
package/dist/Api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Api.js","names":["defineConvexSchema"],"sources":["../src/Api.ts"],"sourcesContent":["import type { RuntimeAndFunctionType } from \"@confect/core\";\nimport type * as Spec from \"@confect/core/Spec\";\nimport type { GenericSchema, SchemaDefinition } from \"convex/server\";\nimport { defineSchema as defineConvexSchema } from \"convex/server\";\nimport { pipe, Predicate, Record } from \"effect\";\nimport type * as DatabaseSchema from \"./DatabaseSchema\";\n\nexport const TypeId = \"@confect/server/Api\";\nexport type TypeId = typeof TypeId;\n\nexport const isApi = (u: unknown): u is Any => Predicate.hasProperty(u, TypeId);\n\nexport interface Api<\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n Spec_ extends Spec.AnyWithProps,\n> {\n readonly [TypeId]: TypeId;\n readonly spec: Spec_;\n readonly databaseSchema: DatabaseSchema_;\n readonly convexSchemaDefinition: SchemaDefinition<GenericSchema, true>;\n}\n\nexport interface Any {\n readonly [TypeId]: TypeId;\n}\n\nexport interface AnyWithProps extends Api<\n DatabaseSchema.AnyWithProps,\n Spec.AnyWithProps\n> {}\n\nexport interface AnyWithPropsWithRuntime<\n Runtime extends RuntimeAndFunctionType.Runtime,\n> extends Api<\n DatabaseSchema.AnyWithProps,\n Spec.AnyWithPropsWithRuntime<Runtime>\n> {}\n\nexport type Schema<Api_ extends AnyWithProps> = Api_[\"databaseSchema\"];\n\nexport type GetSpec<Api_ extends AnyWithProps> = Api_[\"spec\"];\n\nexport type Groups<Api_ extends AnyWithProps> = Spec.Groups<Api_[\"spec\"]>;\n\nconst Proto = {\n [TypeId]: TypeId,\n};\n\nconst makeProto = <\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n Spec_ extends Spec.AnyWithProps,\n>({\n databaseSchema,\n spec,\n}: {\n databaseSchema: DatabaseSchema.AnyWithProps;\n spec: Spec_;\n}): Api<DatabaseSchema_, Spec_> =>\n Object.assign(Object.create(Proto), {\n databaseSchema,\n spec,\n convexSchemaDefinition: pipe(\n databaseSchema.tables,\n Record.map(({ tableDefinition }) => tableDefinition),\n defineConvexSchema,\n ),\n });\n\nexport const make = <\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n Spec_ extends Spec.AnyWithProps,\n>(\n databaseSchema: DatabaseSchema_,\n spec: Spec_,\n): Api<DatabaseSchema_, Spec_> => makeProto({ databaseSchema, spec });\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"Api.js","names":["defineConvexSchema"],"sources":["../src/Api.ts"],"sourcesContent":["import type { RuntimeAndFunctionType } from \"@confect/core\";\nimport type * as GroupSpec from \"@confect/core/GroupSpec\";\nimport type * as Spec from \"@confect/core/Spec\";\nimport type { GenericSchema, SchemaDefinition } from \"convex/server\";\nimport { defineSchema as defineConvexSchema } from \"convex/server\";\nimport { pipe, Predicate, Record } from \"effect\";\nimport type * as DatabaseSchema from \"./DatabaseSchema\";\n\nexport const TypeId = \"@confect/server/Api\";\nexport type TypeId = typeof TypeId;\n\nexport const isApi = (u: unknown): u is Any => Predicate.hasProperty(u, TypeId);\n\nexport interface Api<\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n Spec_ extends Spec.AnyWithProps,\n> {\n readonly [TypeId]: TypeId;\n readonly spec: Spec_;\n readonly databaseSchema: DatabaseSchema_;\n readonly convexSchemaDefinition: SchemaDefinition<GenericSchema, true>;\n}\n\nexport interface Any {\n readonly [TypeId]: TypeId;\n}\n\nexport interface AnyWithProps extends Api<\n DatabaseSchema.AnyWithProps,\n Spec.AnyWithProps\n> {}\n\nexport interface AnyWithPropsWithRuntime<\n Runtime extends RuntimeAndFunctionType.Runtime,\n> extends Api<\n DatabaseSchema.AnyWithProps,\n Spec.AnyWithPropsWithRuntime<Runtime>\n> {}\n\nexport type Schema<Api_ extends AnyWithProps> = Api_[\"databaseSchema\"];\n\nexport type GetSpec<Api_ extends AnyWithProps> = Api_[\"spec\"];\n\nexport type Groups<Api_ extends AnyWithProps> = Spec.Groups<Api_[\"spec\"]>;\n\nconst Proto = {\n [TypeId]: TypeId,\n};\n\nconst makeProto = <\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n Spec_ extends Spec.AnyWithProps,\n>({\n databaseSchema,\n spec,\n}: {\n databaseSchema: DatabaseSchema.AnyWithProps;\n spec: Spec_;\n}): Api<DatabaseSchema_, Spec_> =>\n Object.assign(Object.create(Proto), {\n databaseSchema,\n spec,\n convexSchemaDefinition: pipe(\n databaseSchema.tables,\n Record.map(({ tableDefinition }) => tableDefinition),\n defineConvexSchema,\n ),\n });\n\nexport const make = <\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n Spec_ extends Spec.AnyWithProps,\n>(\n databaseSchema: DatabaseSchema_,\n spec: Spec_,\n): Api<DatabaseSchema_, Spec_> => makeProto({ databaseSchema, spec });\n\n/**\n * Resolve the dot-path of `group` within `api.spec` by reading the immutable\n * `paths` mapping that codegen populated in `_generated/spec.ts`. Throws when\n * the spec is not registered, with a message pointing the caller at the\n * place to register it.\n *\n * The legacy identity-based tree walk (`packages/server/src/GroupPath.ts`)\n * was deleted in favor of this O(1) map lookup; both the registration\n * mechanism (`Spec.addPath`) and the lookup key are the same JS reference\n * thanks to ES module dedup between `_generated/spec.ts` and `*.impl.ts`.\n */\nexport const resolveGroupPathUnsafe = (\n api: AnyWithProps,\n group: GroupSpec.AnyWithProps,\n): string => {\n const groupPath = api.spec.paths.get(group);\n if (groupPath === undefined) {\n throw new Error(\n \"GroupSpec has no registered path in this api's spec. \" +\n \"Ensure the spec is added via Spec.addPath in _generated/spec.ts \" +\n \"(or, in tests, call .addPath(spec, 'dot.path') on the Spec you pass to Api.make).\",\n );\n }\n return groupPath;\n};\n"],"mappings":";;;;;;;;;;;AAQA,MAAa,SAAS;AAGtB,MAAa,SAAS,MAAyB,UAAU,YAAY,GAAG,OAAO;AAkC/E,MAAM,QAAQ,GACX,SAAS,QACX;AAED,MAAM,aAGJ,EACA,gBACA,WAKA,OAAO,OAAO,OAAO,OAAO,MAAM,EAAE;CAClC;CACA;CACA,wBAAwB,KACtB,eAAe,QACf,OAAO,KAAK,EAAE,sBAAsB,gBAAgB,EACpDA,aACD;CACF,CAAC;AAEJ,MAAa,QAIX,gBACA,SACgC,UAAU;CAAE;CAAgB;CAAM,CAAC;;;;;;;;;;;;AAarE,MAAa,0BACX,KACA,UACW;CACX,MAAM,YAAY,IAAI,KAAK,MAAM,IAAI,MAAM;AAC3C,KAAI,cAAc,OAChB,OAAM,IAAI,MACR,yMAGD;AAEH,QAAO"}
|
package/dist/FunctionImpl.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { AnyWithProps, Schema as Schema$1 } from "./Api.js";
|
|
2
2
|
import { WithName } from "./Handler.js";
|
|
3
3
|
import { Context, Layer } from "effect";
|
|
4
|
-
import * as FunctionSpec from "@confect/core/FunctionSpec";
|
|
5
4
|
import * as GroupSpec from "@confect/core/GroupSpec";
|
|
5
|
+
import * as FunctionSpec from "@confect/core/FunctionSpec";
|
|
6
6
|
|
|
7
7
|
//#region src/FunctionImpl.d.ts
|
|
8
8
|
declare namespace FunctionImpl_d_exports {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FunctionImpl.d.ts","names":[],"sources":["../src/FunctionImpl.ts"],"mappings":";;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"FunctionImpl.d.ts","names":[],"sources":["../src/FunctionImpl.ts"],"mappings":";;;;;;;;;;UASiB,YAAA;EAAA,SAIN,SAAA,EAAW,UAAA;EAAA,SACX,YAAA,EAAc,YAAA;AAAA;AAAA,cAGZ,YAAA;EAGX,SAAA;EAAA;AAAA;EAIA,SAAA,EAAW,UAAA;EACX,YAAA,EAAc,YAAA;AAAA,MACf,OAAA,CAAA,GAAA,CAAA,YAAA,CAAA,UAAA,EAAA,YAAA,GAAA,YAAA,CAAA,UAAA,EAAA,YAAA;AAAA,cAKY,IAAA,gBACE,YAAA,gBACC,SAAA,CAAU,YAAA,6BACG,YAAA,CAAa,IAAA,CAAK,SAAA,CAAU,SAAA,CAAU,KAAA,IAEjE,GAAA,EAAK,IAAA,EACL,KAAA,EAAO,KAAA,EACP,YAAA,EAAc,YAAA,EACd,OAAA,EAAS,QAAA,CACP,QAAA,CAAW,IAAA,GACX,SAAA,CAAU,SAAA,CAAU,KAAA,GACpB,YAAA,MAED,KAAA,CAAM,KAAA,CAAM,YAAA,SAAqB,YAAA;;AAnCpC;;KAqEY,uBAAA,2DAGR,YAAA,CAAa,UAAA,EAAY,YAAA;;;;KAKjB,aAAA,eAA4B,SAAA,CAAU,YAAA,IAChD,YAAA,CAAa,IAAA,CACX,SAAA,CAAU,SAAA,CAAU,KAAA,gDAElB,aAAA,kBACE,YAAA,SAAqB,aAAA;;;;KAOjB,eAAA,0CAEI,SAAA,CAAU,YAAA,IACtB,aAAA,CAAc,KAAA"}
|
package/dist/FunctionImpl.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
-
import { resolveGroupPathUnsafe } from "./
|
|
2
|
+
import { resolveGroupPathUnsafe } from "./Api.js";
|
|
3
3
|
import { setNestedProperty } from "./internal/utils.js";
|
|
4
4
|
import { make as make$1 } from "./RegistryItem.js";
|
|
5
5
|
import { Context, Effect, Layer, Ref, String } from "effect";
|
|
@@ -12,7 +12,7 @@ var FunctionImpl_exports = /* @__PURE__ */ __exportAll({
|
|
|
12
12
|
});
|
|
13
13
|
const FunctionImpl = ({ groupPath, functionName }) => Context.GenericTag(`@confect/server/FunctionImpl/${groupPath}/${functionName}`);
|
|
14
14
|
const make = (api, group, functionName, handler) => {
|
|
15
|
-
const groupPath = resolveGroupPathUnsafe(api
|
|
15
|
+
const groupPath = resolveGroupPathUnsafe(api, group);
|
|
16
16
|
const functionSpec = group.functions[functionName];
|
|
17
17
|
return Layer.effect(FunctionImpl({
|
|
18
18
|
groupPath,
|
package/dist/FunctionImpl.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FunctionImpl.js","names":["RegistryItem.make"],"sources":["../src/FunctionImpl.ts"],"sourcesContent":["import type * as FunctionSpec from \"@confect/core/FunctionSpec\";\nimport type * as GroupSpec from \"@confect/core/GroupSpec\";\nimport * as Registry from \"@confect/core/Registry\";\nimport { Context, Effect, Layer, Ref, String } from \"effect\";\nimport
|
|
1
|
+
{"version":3,"file":"FunctionImpl.js","names":["Api.resolveGroupPathUnsafe","RegistryItem.make"],"sources":["../src/FunctionImpl.ts"],"sourcesContent":["import type * as FunctionSpec from \"@confect/core/FunctionSpec\";\nimport type * as GroupSpec from \"@confect/core/GroupSpec\";\nimport * as Registry from \"@confect/core/Registry\";\nimport { Context, Effect, Layer, Ref, String } from \"effect\";\nimport * as Api from \"./Api\";\nimport type * as Handler from \"./Handler\";\nimport { setNestedProperty } from \"./internal/utils\";\nimport * as RegistryItem from \"./RegistryItem\";\n\nexport interface FunctionImpl<\n GroupPath_ extends string,\n FunctionName extends string,\n> {\n readonly groupPath: GroupPath_;\n readonly functionName: FunctionName;\n}\n\nexport const FunctionImpl = <\n GroupPath_ extends string,\n FunctionName extends string,\n>({\n groupPath,\n functionName,\n}: {\n groupPath: GroupPath_;\n functionName: FunctionName;\n}) =>\n Context.GenericTag<FunctionImpl<GroupPath_, FunctionName>>(\n `@confect/server/FunctionImpl/${groupPath}/${functionName}`,\n );\n\nexport const make = <\n Api_ extends Api.AnyWithProps,\n Group extends GroupSpec.AnyWithProps,\n const FunctionName extends FunctionSpec.Name<GroupSpec.Functions<Group>>,\n>(\n api: Api_,\n group: Group,\n functionName: FunctionName,\n handler: Handler.WithName<\n Api.Schema<Api_>,\n GroupSpec.Functions<Group>,\n FunctionName\n >,\n): Layer.Layer<FunctionImpl<string, FunctionName>> => {\n const groupPath = Api.resolveGroupPathUnsafe(api, group);\n const functionSpec = group.functions[functionName]!;\n\n return Layer.effect(\n FunctionImpl<string, FunctionName>({\n groupPath,\n functionName,\n }),\n Effect.gen(function* () {\n const registry = yield* Registry.Registry;\n\n yield* Ref.update(registry, (registryItems) =>\n setNestedProperty(\n registryItems,\n [...String.split(groupPath, \".\"), functionName],\n RegistryItem.make({\n functionSpec,\n handler,\n }),\n ),\n );\n\n return {\n groupPath,\n functionName,\n };\n }),\n );\n};\n\n/**\n * Get the function implementation service type for a specific group path and function name.\n */\nexport type ForGroupPathAndFunction<\n GroupPath_ extends string,\n FunctionName extends string,\n> = FunctionImpl<GroupPath_, FunctionName>;\n\n/**\n * Get all function implementation services required for a group spec.\n */\nexport type FromGroupSpec<Group extends GroupSpec.AnyWithProps> =\n FunctionSpec.Name<\n GroupSpec.Functions<Group>\n > extends infer FunctionNames extends string\n ? FunctionNames extends string\n ? FunctionImpl<string, FunctionNames>\n : never\n : never;\n\n/**\n * @deprecated Use {@link FromGroupSpec} instead.\n */\nexport type FromGroupAtPath<\n _GroupPath extends string,\n Group extends GroupSpec.AnyWithProps,\n> = FromGroupSpec<Group>;\n"],"mappings":";;;;;;;;;;;;AAiBA,MAAa,gBAGX,EACA,WACA,mBAKA,QAAQ,WACN,gCAAgC,UAAU,GAAG,eAC9C;AAEH,MAAa,QAKX,KACA,OACA,cACA,YAKoD;CACpD,MAAM,YAAYA,uBAA2B,KAAK,MAAM;CACxD,MAAM,eAAe,MAAM,UAAU;AAErC,QAAO,MAAM,OACX,aAAmC;EACjC;EACA;EACD,CAAC,EACF,OAAO,IAAI,aAAa;EACtB,MAAM,WAAW,OAAO,SAAS;AAEjC,SAAO,IAAI,OAAO,WAAW,kBAC3B,kBACE,eACA,CAAC,GAAG,OAAO,MAAM,WAAW,IAAI,EAAE,aAAa,EAC/CC,OAAkB;GAChB;GACA;GACD,CAAC,CACH,CACF;AAED,SAAO;GACL;GACA;GACD;GACD,CACH"}
|
package/dist/GroupImpl.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupImpl.d.ts","names":[],"sources":["../src/GroupImpl.ts"],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"GroupImpl.d.ts","names":[],"sources":["../src/GroupImpl.ts"],"mappings":";;;;;;;;;cAiBa,MAAA;AAAA,KACD,MAAA,UAAgB,MAAA;AAAA,KAEhB,kBAAA;AAAA,UAEK,SAAA,wDAEa,kBAAA;EAAA,UAElB,MAAA,GAAS,MAAA;EAAA,SACV,SAAA,EAAW,UAAA;EAAA,SACX,kBAAA,EAAoB,mBAAA;;;;;;;WAOpB,uBAAA,EAAyB,aAAA;AAAA;AAAA,UAGnB,GAAA,SAAY,SAAA,SAAkB,kBAAA;AAAA,cAElC,WAAA,GAAe,CAAA,cAAa,CAAA,IAAK,GAAA;AAAA,UAG7B,YAAA,SAAqB,SAAA;AAAA,UACrB,cAAA,SAAuB,SAAA;AAAA,cAE3B,oBAAA,GAAwB,CAAA,cAAa,CAAA,IAAK,YAAA;AAAA,cAG1C,sBAAA,GAA0B,CAAA,cAAa,CAAA,IAAK,cAAA;;;;AA7BzD;;;;cAuCa,SAAA,0DAEiB,kBAAA;EAC5B,SAAA;EAAA;AAAA;EAIA,SAAA,EAAW,UAAA;EACX,kBAAA,EAAoB,mBAAA;AAAA,MACrB,OAAA,CAAA,GAAA,CAAA,SAAA,CAAA,UAAA,EAAA,mBAAA,GAAA,SAAA,CAAA,UAAA,EAAA,mBAAA;AAAA,cAKY,IAAA,gBACE,YAAA,gBACC,SAAA,CAAU,YAAA,EAExB,GAAA,EAAK,IAAA,EACL,KAAA,EAAO,KAAA,KACN,KAAA,CAAM,KAAA,CACP,SAAA,gCAEA,eAAA,CAA2B,KAAA;;;;;;;;;;;;;;cAuEhB,QAAA,8BACX,KAAA,EAAO,KAAA,CAAM,KAAA,CAAM,SAAA,CAAU,UAAA,sBAC5B,KAAA,CAAM,KAAA,CAAM,SAAA,CAAU,UAAA;AAAA,KAsCb,aAAA,eAA4B,SAAA,CAAU,YAAA,IAChD,eAAA,CAA2B,KAAA"}
|
package/dist/GroupImpl.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
-
import { resolveGroupPathUnsafe } from "./
|
|
2
|
+
import { resolveGroupPathUnsafe } from "./Api.js";
|
|
3
3
|
import { Array, Context, Effect, Layer, Option, Predicate, Record, Ref, String, pipe } from "effect";
|
|
4
4
|
import * as Registry from "@confect/core/Registry";
|
|
5
5
|
|
|
@@ -26,7 +26,7 @@ const isUnfinalizedGroupImpl = (u) => isGroupImpl(u) && u.finalizationStatus ===
|
|
|
26
26
|
*/
|
|
27
27
|
const GroupImpl = ({ groupPath, finalizationStatus }) => Context.GenericTag(`@confect/server/GroupImpl/${finalizationStatus}/${groupPath}`);
|
|
28
28
|
const make = (api, group) => {
|
|
29
|
-
const groupPath = resolveGroupPathUnsafe(api
|
|
29
|
+
const groupPath = resolveGroupPathUnsafe(api, group);
|
|
30
30
|
return Layer.succeed(GroupImpl({
|
|
31
31
|
groupPath,
|
|
32
32
|
finalizationStatus: "Unfinalized"
|
package/dist/GroupImpl.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupImpl.js","names":[],"sources":["../src/GroupImpl.ts"],"sourcesContent":["import type * as GroupSpec from \"@confect/core/GroupSpec\";\nimport * as Registry from \"@confect/core/Registry\";\nimport {\n Array,\n Context,\n Effect,\n Layer,\n Option,\n pipe,\n Predicate,\n Record,\n Ref,\n String,\n} from \"effect\";\nimport
|
|
1
|
+
{"version":3,"file":"GroupImpl.js","names":["Api.resolveGroupPathUnsafe"],"sources":["../src/GroupImpl.ts"],"sourcesContent":["import type * as GroupSpec from \"@confect/core/GroupSpec\";\nimport * as Registry from \"@confect/core/Registry\";\nimport {\n Array,\n Context,\n Effect,\n Layer,\n Option,\n pipe,\n Predicate,\n Record,\n Ref,\n String,\n} from \"effect\";\nimport * as Api from \"./Api\";\nimport type * as FunctionImpl from \"./FunctionImpl\";\n\nexport const TypeId = \"@confect/server/GroupImpl\";\nexport type TypeId = typeof TypeId;\n\nexport type FinalizationStatus = \"Unfinalized\" | \"Finalized\";\n\nexport interface GroupImpl<\n GroupPath_ extends string,\n FinalizationStatus_ extends FinalizationStatus = \"Unfinalized\",\n> {\n readonly [TypeId]: TypeId;\n readonly groupPath: GroupPath_;\n readonly finalizationStatus: FinalizationStatus_;\n /**\n * Names of every function registered into this group's layer scope by\n * `FunctionImpl.make`. Authoritative only when `finalizationStatus` is\n * `\"Finalized\"`; the `\"Unfinalized\"` value is set to `[]` at `make`-time\n * since the list is only known once `finalize` snapshots the registry.\n */\n readonly registeredFunctionNames: ReadonlyArray<string>;\n}\n\nexport interface Any extends GroupImpl<string, FinalizationStatus> {}\n\nexport const isGroupImpl = (u: unknown): u is Any =>\n Predicate.hasProperty(u, TypeId);\n\nexport interface AnyFinalized extends GroupImpl<string, \"Finalized\"> {}\nexport interface AnyUnfinalized extends GroupImpl<string, \"Unfinalized\"> {}\n\nexport const isFinalizedGroupImpl = (u: unknown): u is AnyFinalized =>\n isGroupImpl(u) && u.finalizationStatus === \"Finalized\";\n\nexport const isUnfinalizedGroupImpl = (u: unknown): u is AnyUnfinalized =>\n isGroupImpl(u) && u.finalizationStatus === \"Unfinalized\";\n\n/**\n * Build the runtime tag for a `GroupImpl` service. The finalization status is\n * embedded in the tag string so that `Unfinalized` and `Finalized` are distinct\n * services at runtime; consumers of a finalized layer (the server's\n * `RegisteredFunctions.buildForGroup` and the CLI's `implValidation`) retrieve\n * the typed `Finalized` service directly rather than scanning the context.\n */\nexport const GroupImpl = <\n GroupPath_ extends string,\n FinalizationStatus_ extends FinalizationStatus,\n>({\n groupPath,\n finalizationStatus,\n}: {\n groupPath: GroupPath_;\n finalizationStatus: FinalizationStatus_;\n}) =>\n Context.GenericTag<GroupImpl<GroupPath_, FinalizationStatus_>>(\n `@confect/server/GroupImpl/${finalizationStatus}/${groupPath}`,\n );\n\nexport const make = <\n Api_ extends Api.AnyWithProps,\n Group extends GroupSpec.AnyWithProps,\n>(\n api: Api_,\n group: Group,\n): Layer.Layer<\n GroupImpl<string, \"Unfinalized\">,\n never,\n FunctionImpl.FromGroupSpec<Group>\n> => {\n const groupPath = Api.resolveGroupPathUnsafe(api, group);\n\n return Layer.succeed(\n GroupImpl<string, \"Unfinalized\">({\n groupPath,\n finalizationStatus: \"Unfinalized\",\n }),\n {\n [TypeId]: TypeId,\n groupPath,\n finalizationStatus: \"Unfinalized\" as const,\n registeredFunctionNames: [],\n },\n ) as Layer.Layer<\n GroupImpl<string, \"Unfinalized\">,\n never,\n FunctionImpl.FromGroupSpec<Group>\n >;\n};\n\nconst isFunctionShaped = (value: unknown): boolean =>\n Predicate.isRecord(value) && \"functionSpec\" in value;\n\n/**\n * Walk a `RegistryItems` tree to the entries at `groupPath` and return the\n * names of the function-shaped leaves directly underneath.\n */\nconst collectFunctionNamesAtPath = (\n items: Registry.RegistryItems,\n groupPath: string,\n): ReadonlyArray<string> =>\n pipe(\n String.split(groupPath, \".\"),\n Array.reduce(Option.some<unknown>(items), (acc, segment) =>\n acc.pipe(\n Option.filter(Predicate.isRecord),\n Option.flatMap((node) =>\n segment in node ? Option.some(node[segment]) : Option.none(),\n ),\n ),\n ),\n Option.filter(Predicate.isRecord),\n Option.map(Record.toEntries),\n Option.map(\n Array.filterMap(([name, value]) =>\n isFunctionShaped(value) ? Option.some(name) : Option.none(),\n ),\n ),\n Option.getOrElse((): ReadonlyArray<string> => []),\n );\n\nconst findUnfinalizedGroupImpl = <S>(\n context: Context.Context<S>,\n): Option.Option<AnyUnfinalized> =>\n Array.findFirst(context.unsafeMap.values(), isUnfinalizedGroupImpl);\n\n/**\n * Mark a `GroupImpl` layer as fully implemented. The parameter type defaults\n * `RIn = never`, so passing a layer that still requires any `FunctionImpl`\n * service produces a type error at the impl author's site. The codegen\n * boundary requires the resulting `\"Finalized\"` brand, so omitting this call\n * is also rejected downstream.\n *\n * As a side effect of finalization, the names of every `FunctionImpl` that\n * registered into this group's scope are snapshotted onto the produced\n * service value's `registeredFunctionNames` field, so consumers can verify\n * impl completeness against a `GroupSpec`'s expected functions without\n * having to inspect the `Registry` themselves.\n */\nexport const finalize = <GroupPath_ extends string>(\n group: Layer.Layer<GroupImpl<GroupPath_, \"Unfinalized\">>,\n): Layer.Layer<GroupImpl<GroupPath_, \"Finalized\">> =>\n Layer.flatMap(\n group,\n (context): Layer.Layer<GroupImpl<GroupPath_, \"Finalized\">> =>\n findUnfinalizedGroupImpl(context).pipe(\n Option.match({\n onNone: () =>\n Layer.die(\n new Error(\n \"GroupImpl.finalize: no Unfinalized GroupImpl service was found in the layer's context.\",\n ),\n ),\n onSome: (unfinalized) => {\n const groupPath = unfinalized.groupPath as GroupPath_;\n return Layer.effect(\n GroupImpl<GroupPath_, \"Finalized\">({\n groupPath,\n finalizationStatus: \"Finalized\",\n }),\n Effect.gen(function* () {\n const registry = yield* Registry.Registry;\n const items = yield* Ref.get(registry);\n return {\n [TypeId]: TypeId,\n groupPath,\n finalizationStatus: \"Finalized\" as const,\n registeredFunctionNames: collectFunctionNamesAtPath(\n items,\n groupPath,\n ),\n };\n }),\n );\n },\n }),\n ),\n );\n\nexport type FromGroupSpec<Group extends GroupSpec.AnyWithProps> =\n FunctionImpl.FromGroupSpec<Group>;\n"],"mappings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CACH,SAAS,gBAAgB;EACvB,MAAM,YAAY,YAAY;AAC9B,SAAO,MAAM,OACX,UAAmC;GACjC;GACA,oBAAoB;GACrB,CAAC,EACF,OAAO,IAAI,aAAa;GACtB,MAAM,WAAW,OAAO,SAAS;GACjC,MAAM,QAAQ,OAAO,IAAI,IAAI,SAAS;AACtC,UAAO;KACJ,SAAS;IACV;IACA,oBAAoB;IACpB,yBAAyB,2BACvB,OACA,UACD;IACF;IACD,CACH;;CAEJ,CAAC,CACH,CACJ"}
|
|
@@ -35,7 +35,10 @@ declare const make: <Api_ extends AnyWithPropsWithRuntime<"Convex">>(api: Api_,
|
|
|
35
35
|
functionSpec,
|
|
36
36
|
handler
|
|
37
37
|
}: AnyWithProps$1) => Any;
|
|
38
|
-
declare const mutationLayer: <Schema extends AnyWithProps>(schema: Schema, ctx: GenericMutationCtx<ToConvex<FromSchema<Schema>>>) => Layer.Layer<(<Mutation extends _confect_core_Ref0.AnyMutation>(mutation: Mutation, ...args: _confect_core_Ref0.OptionalArgs<Mutation>) => Effect.Effect<_confect_core_Ref0.Returns<Mutation>, _confect_core_Ref0.Error<Mutation> | effect_ParseResult0.ParseError>) | (<Query extends _confect_core_Ref0.AnyQuery>(query: Query, ...args: _confect_core_Ref0.OptionalArgs<Query>) => Effect.Effect<_confect_core_Ref0.Returns<Query>, _confect_core_Ref0.Error<Query> | effect_ParseResult0.ParseError>) |
|
|
38
|
+
declare const mutationLayer: <Schema extends AnyWithProps>(schema: Schema, ctx: GenericMutationCtx<ToConvex<FromSchema<Schema>>>) => Layer.Layer<Auth$1 | (<Mutation extends _confect_core_Ref0.AnyMutation>(mutation: Mutation, ...args: _confect_core_Ref0.OptionalArgs<Mutation>) => Effect.Effect<_confect_core_Ref0.Returns<Mutation>, _confect_core_Ref0.Error<Mutation> | effect_ParseResult0.ParseError>) | (<Query extends _confect_core_Ref0.AnyQuery>(query: Query, ...args: _confect_core_Ref0.OptionalArgs<Query>) => Effect.Effect<_confect_core_Ref0.Returns<Query>, _confect_core_Ref0.Error<Query> | effect_ParseResult0.ParseError>) | {
|
|
39
|
+
runAfter: <Ref_ extends _confect_core_Ref0.AnyMutation | _confect_core_Ref0.AnyAction>(delay: effect_Duration0.Duration, ref: Ref_, ...args: _confect_core_Ref0.OptionalArgs<Ref_>) => Effect.Effect<convex_values0.GenericId<"_scheduled_functions">, never, never>;
|
|
40
|
+
runAt: <Ref_ extends _confect_core_Ref0.AnyMutation | _confect_core_Ref0.AnyAction>(dateTime: effect_DateTime0.DateTime, ref: Ref_, ...args: _confect_core_Ref0.OptionalArgs<Ref_>) => Effect.Effect<convex_values0.GenericId<"_scheduled_functions">, never, never>;
|
|
41
|
+
} | StorageReader$1 | StorageWriter$1 | GenericMutationCtx<ToConvex<FromSchema<Schema>>> | {
|
|
39
42
|
table: <const TableName extends Name<IncludeSystemTables<Tables<Schema>>>>(tableName: TableName) => {
|
|
40
43
|
readonly get: {
|
|
41
44
|
(id: convex_values0.GenericId<TableName>): Effect.Effect<TableInfo<WithName<IncludeSystemTables<Tables<Schema>>, TableName>>["document"], DocumentDecodeError | GetByIdFailure, never>;
|
|
@@ -54,10 +57,7 @@ declare const mutationLayer: <Schema extends AnyWithProps>(schema: Schema, ctx:
|
|
|
54
57
|
replace: (id: convex_values0.GenericId<TableName>, value: convex_server0.Expand<convex_server0.BetterOmit<DocumentByName<FromSchema<Schema>, TableName>, "_id" | "_creationTime">>) => Effect.Effect<void, DocumentEncodeError, never>;
|
|
55
58
|
delete: (id: convex_values0.GenericId<TableName>) => Effect.Effect<void, never, never>;
|
|
56
59
|
};
|
|
57
|
-
}
|
|
58
|
-
runAfter: <Ref_ extends _confect_core_Ref0.AnyMutation | _confect_core_Ref0.AnyAction>(delay: effect_Duration0.Duration, ref: Ref_, ...args: _confect_core_Ref0.OptionalArgs<Ref_>) => Effect.Effect<convex_values0.GenericId<"_scheduled_functions">, never, never>;
|
|
59
|
-
runAt: <Ref_ extends _confect_core_Ref0.AnyMutation | _confect_core_Ref0.AnyAction>(dateTime: effect_DateTime0.DateTime, ref: Ref_, ...args: _confect_core_Ref0.OptionalArgs<Ref_>) => Effect.Effect<convex_values0.GenericId<"_scheduled_functions">, never, never>;
|
|
60
|
-
} | StorageReader$1 | StorageWriter$1, never, never>;
|
|
60
|
+
}, never, never>;
|
|
61
61
|
type MutationServices<Schema extends AnyWithProps> = DatabaseReader<Schema> | DatabaseWriter<Schema> | Auth$1 | Scheduler$1 | StorageReader$1 | StorageWriter$1 | QueryRunner | MutationRunner | MutationCtx<ToConvex<FromSchema<Schema>>>;
|
|
62
62
|
//#endregion
|
|
63
63
|
export { MutationServices, RegisteredConvexFunction_d_exports, make, mutationLayer };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RegisteredConvexFunction.d.ts","names":[],"sources":["../src/RegisteredConvexFunction.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAiCa,IAAA,gBAAqB,uBAAA,YAChC,GAAA,EAAK,IAAA;EACL,YAAA;EAAA;AAAA,GAA2B,cAAA,KAC1B,GAAA;AAAA,cAkLU,aAAA,kBAAgC,YAAA,EAC3C,MAAA,EAAQ,MAAA,EACR,GAAA,EAAK,kBAAA,CAAmB,QAAA,CAAmB,UAAA,CAAqB,MAAA,QAAS,KAAA,CAAA,KAAA,
|
|
1
|
+
{"version":3,"file":"RegisteredConvexFunction.d.ts","names":[],"sources":["../src/RegisteredConvexFunction.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAiCa,IAAA,gBAAqB,uBAAA,YAChC,GAAA,EAAK,IAAA;EACL,YAAA;EAAA;AAAA,GAA2B,cAAA,KAC1B,GAAA;AAAA,cAkLU,aAAA,kBAAgC,YAAA,EAC3C,MAAA,EAAQ,MAAA,EACR,GAAA,EAAK,kBAAA,CAAmB,QAAA,CAAmB,UAAA,CAAqB,MAAA,QAAS,KAAA,CAAA,KAAA,CAAA,MAAA,sBAAA,kBAAA,CAAA,WAAA,EAAA,QAAA,EAAA,QAAA,KAAA,IAAA,EAAA,kBAAA,CAAA,YAAA,CAAA,QAAA,MAAA,MAAA,CAAA,MAAA,CAAA,kBAAA,CAAA,OAAA,CAAA,QAAA,GAAA,kBAAA,CAAA,KAAA,CAAA,QAAA,IAAA,mBAAA,CAAA,UAAA,qBAAA,kBAAA,CAAA,QAAA,EAAA,KAAA,EAAA,KAAA,KAAA,IAAA,EAAA,kBAAA,CAAA,YAAA,CAAA,KAAA,MAAA,MAAA,CAAA,MAAA,CAAA,kBAAA,CAAA,OAAA,CAAA,KAAA,GAAA,kBAAA,CAAA,KAAA,CAAA,KAAA,IAAA,mBAAA,CAAA,UAAA;0BAAA,kBAAA,CAAA,WAAA;;;;;;;;;;;;;;;;;;;;;;KAoB/D,gBAAA,gBAAgC,YAAA,IACxC,cAAA,CAA8B,MAAA,IAC9B,cAAA,CAA8B,MAAA,IAC9B,MAAA,GACA,WAAA,GACA,eAAA,GACA,eAAA,GACA,WAAA,GACA,cAAA,GACA,WAAA,CAAwB,QAAA,CAAmB,UAAA,CAAqB,MAAA"}
|
|
@@ -70,10 +70,10 @@ declare const actionFunctionBase: <Schema extends AnyWithProps, Args, ConvexArgs
|
|
|
70
70
|
handler: (ctx: GenericActionCtx<ToConvex<FromSchema<Schema>>>, actualArgs: ConvexArgs) => Promise<ConvexReturns>;
|
|
71
71
|
};
|
|
72
72
|
type ActionServices<DatabaseSchema_ extends AnyWithProps> = Scheduler$1 | Auth$1 | StorageReader$1 | StorageWriter$1 | StorageActionWriter$1 | QueryRunner | MutationRunner | ActionRunner | VectorSearch<FromSchema<DatabaseSchema_>> | ActionCtx<ToConvex<FromSchema<DatabaseSchema_>>>;
|
|
73
|
-
declare const actionLayer: <DatabaseSchema_ extends AnyWithProps>(databaseSchema: DatabaseSchema_, ctx: GenericActionCtx<ToConvex<FromSchema<DatabaseSchema_>>>) => Layer.Layer<(<Mutation extends _confect_core_Ref0.AnyMutation>(mutation: Mutation, ...args: _confect_core_Ref0.OptionalArgs<Mutation>) => Effect.Effect<_confect_core_Ref0.Returns<Mutation>, _confect_core_Ref0.Error<Mutation> | effect_ParseResult0.ParseError>) | (<Query extends _confect_core_Ref0.AnyQuery>(query: Query, ...args: _confect_core_Ref0.OptionalArgs<Query>) => Effect.Effect<_confect_core_Ref0.Returns<Query>, _confect_core_Ref0.Error<Query> | effect_ParseResult0.ParseError>) |
|
|
73
|
+
declare const actionLayer: <DatabaseSchema_ extends AnyWithProps>(databaseSchema: DatabaseSchema_, ctx: GenericActionCtx<ToConvex<FromSchema<DatabaseSchema_>>>) => Layer.Layer<Auth$1 | (<Mutation extends _confect_core_Ref0.AnyMutation>(mutation: Mutation, ...args: _confect_core_Ref0.OptionalArgs<Mutation>) => Effect.Effect<_confect_core_Ref0.Returns<Mutation>, _confect_core_Ref0.Error<Mutation> | effect_ParseResult0.ParseError>) | (<Query extends _confect_core_Ref0.AnyQuery>(query: Query, ...args: _confect_core_Ref0.OptionalArgs<Query>) => Effect.Effect<_confect_core_Ref0.Returns<Query>, _confect_core_Ref0.Error<Query> | effect_ParseResult0.ParseError>) | GenericActionCtx<ToConvex<FromSchema<DatabaseSchema_>>> | {
|
|
74
74
|
runAfter: <Ref_ extends _confect_core_Ref0.AnyMutation | _confect_core_Ref0.AnyAction>(delay: effect_Duration0.Duration, ref: Ref_, ...args: _confect_core_Ref0.OptionalArgs<Ref_>) => Effect.Effect<convex_values0.GenericId<"_scheduled_functions">, never, never>;
|
|
75
75
|
runAt: <Ref_ extends _confect_core_Ref0.AnyMutation | _confect_core_Ref0.AnyAction>(dateTime: effect_DateTime0.DateTime, ref: Ref_, ...args: _confect_core_Ref0.OptionalArgs<Ref_>) => Effect.Effect<convex_values0.GenericId<"_scheduled_functions">, never, never>;
|
|
76
|
-
} | StorageReader$1 | StorageWriter$1 |
|
|
76
|
+
} | StorageReader$1 | StorageWriter$1 | StorageActionWriter$1 | (<Action extends _confect_core_Ref0.AnyAction>(action: Action, ...args: _confect_core_Ref0.OptionalArgs<Action>) => Effect.Effect<_confect_core_Ref0.Returns<Action>, _confect_core_Ref0.Error<Action> | effect_ParseResult0.ParseError>) | (<TableName extends TableNames<FromSchema<DatabaseSchema_>>, IndexName extends keyof convex_server0.VectorIndexes<convex_server0.NamedTableInfo<ToConvex<FromSchema<DatabaseSchema_>>, TableName>>>(tableName: TableName, indexName: IndexName, query: {
|
|
77
77
|
vector: number[];
|
|
78
78
|
limit?: number;
|
|
79
79
|
filter?: (q: convex_server0.VectorFilterBuilder<convex_server0.DocumentByInfo<convex_server0.NamedTableInfo<ToConvex<FromSchema<DatabaseSchema_>>, TableName>>, convex_server0.NamedVectorIndex<convex_server0.NamedTableInfo<ToConvex<FromSchema<DatabaseSchema_>>, TableName>, IndexName>>) => convex_server0.FilterExpression<boolean>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RegisteredFunction.d.ts","names":[],"sources":["../src/RegisteredFunction.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;KA2BY,GAAA,GACR,eAAA,CAAgB,kBAAA,EAAoB,mBAAA,SACpC,kBAAA,CAAmB,kBAAA,EAAoB,mBAAA,SACvC,gBAAA,CAAiB,kBAAA,EAAoB,mBAAA;AAAA,KAEpC,yBAAA,uBACmB,YAAA,CAAa,YAAA,IAEnC,YAAA,CAAa,WAAA,CAAY,aAAA,8BACvB,mBAAA,GACE,sBAAA,CAAuB,eAAA,CACrB,aAAA,8CAEA,eAAA,CACE,YAAA,CAAa,qBAAA,CAAsB,aAAA,GACnC,KAAA,EACA,OAAA,CAAQ,YAAA,CAAa,cAAA,CAAe,aAAA,MAEtC,sBAAA,CAAuB,eAAA,CACnB,aAAA,iDAEF,kBAAA,CACE,YAAA,CAAa,qBAAA,CAAsB,aAAA,GACnC,KAAA,EACA,OAAA,CAAQ,YAAA,CAAa,cAAA,CAAe,aAAA,MAEtC,sBAAA,CAAuB,eAAA,CACnB,aAAA,+CAEF,gBAAA,CACE,YAAA,CAAa,qBAA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AA,KAAA,KAAA,IAAA,EAAA,kBAAA,CAAA,YAAA,CAAA,KAAA,MAAA,MAAA,CAAA,MAAA,CAAA,kBAAA,CAAA,OAAA,CAAA,KAAA,GAAA,kBAAA,CAAA,KAAA,CAAA,KAAA,IAAA,mBAAA,CAAA,UAAA,KAAA,gBAAA,CAAA,QAAA,CAAA,UAAA,CAAA,eAAA;0BAAA,kBAAA,CAAA,WAAA"}
|
|
@@ -3,9 +3,9 @@ import { Any, RegisteredFunction } from "./RegisteredFunction.js";
|
|
|
3
3
|
import { GroupImpl } from "./GroupImpl.js";
|
|
4
4
|
import { AnyWithProps as AnyWithProps$2 } from "./RegistryItem.js";
|
|
5
5
|
import { Layer, Types } from "effect";
|
|
6
|
+
import * as GroupSpec from "@confect/core/GroupSpec";
|
|
6
7
|
import * as Spec from "@confect/core/Spec";
|
|
7
8
|
import * as FunctionSpec from "@confect/core/FunctionSpec";
|
|
8
|
-
import * as GroupSpec from "@confect/core/GroupSpec";
|
|
9
9
|
|
|
10
10
|
//#region src/RegisteredFunctions.d.ts
|
|
11
11
|
declare namespace RegisteredFunctions_d_exports {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@confect/server",
|
|
3
|
-
"version": "9.0.0-next.
|
|
3
|
+
"version": "9.0.0-next.3",
|
|
4
4
|
"description": "Backend bindings to the Convex platform",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -73,7 +73,7 @@
|
|
|
73
73
|
"@effect/platform-node": "^0.106.0",
|
|
74
74
|
"convex": "1.39.1",
|
|
75
75
|
"effect": "^3.21.2",
|
|
76
|
-
"@confect/core": "^9.0.0-next.
|
|
76
|
+
"@confect/core": "^9.0.0-next.3"
|
|
77
77
|
},
|
|
78
78
|
"engines": {
|
|
79
79
|
"node": ">=22",
|
package/src/Api.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { RuntimeAndFunctionType } from "@confect/core";
|
|
2
|
+
import type * as GroupSpec from "@confect/core/GroupSpec";
|
|
2
3
|
import type * as Spec from "@confect/core/Spec";
|
|
3
4
|
import type { GenericSchema, SchemaDefinition } from "convex/server";
|
|
4
5
|
import { defineSchema as defineConvexSchema } from "convex/server";
|
|
@@ -73,3 +74,29 @@ export const make = <
|
|
|
73
74
|
databaseSchema: DatabaseSchema_,
|
|
74
75
|
spec: Spec_,
|
|
75
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
|
+
};
|
package/src/FunctionImpl.ts
CHANGED
|
@@ -2,8 +2,7 @@ import type * as FunctionSpec from "@confect/core/FunctionSpec";
|
|
|
2
2
|
import type * as GroupSpec from "@confect/core/GroupSpec";
|
|
3
3
|
import * as Registry from "@confect/core/Registry";
|
|
4
4
|
import { Context, Effect, Layer, Ref, String } from "effect";
|
|
5
|
-
import
|
|
6
|
-
import { resolveGroupPathUnsafe } from "./GroupPath";
|
|
5
|
+
import * as Api from "./Api";
|
|
7
6
|
import type * as Handler from "./Handler";
|
|
8
7
|
import { setNestedProperty } from "./internal/utils";
|
|
9
8
|
import * as RegistryItem from "./RegistryItem";
|
|
@@ -44,7 +43,7 @@ export const make = <
|
|
|
44
43
|
FunctionName
|
|
45
44
|
>,
|
|
46
45
|
): Layer.Layer<FunctionImpl<string, FunctionName>> => {
|
|
47
|
-
const groupPath = resolveGroupPathUnsafe(api
|
|
46
|
+
const groupPath = Api.resolveGroupPathUnsafe(api, group);
|
|
48
47
|
const functionSpec = group.functions[functionName]!;
|
|
49
48
|
|
|
50
49
|
return Layer.effect(
|
package/src/GroupImpl.ts
CHANGED
|
@@ -12,9 +12,8 @@ import {
|
|
|
12
12
|
Ref,
|
|
13
13
|
String,
|
|
14
14
|
} from "effect";
|
|
15
|
-
import
|
|
15
|
+
import * as Api from "./Api";
|
|
16
16
|
import type * as FunctionImpl from "./FunctionImpl";
|
|
17
|
-
import { resolveGroupPathUnsafe } from "./GroupPath";
|
|
18
17
|
|
|
19
18
|
export const TypeId = "@confect/server/GroupImpl";
|
|
20
19
|
export type TypeId = typeof TypeId;
|
|
@@ -83,7 +82,7 @@ export const make = <
|
|
|
83
82
|
never,
|
|
84
83
|
FunctionImpl.FromGroupSpec<Group>
|
|
85
84
|
> => {
|
|
86
|
-
const groupPath = resolveGroupPathUnsafe(api
|
|
85
|
+
const groupPath = Api.resolveGroupPathUnsafe(api, group);
|
|
87
86
|
|
|
88
87
|
return Layer.succeed(
|
|
89
88
|
GroupImpl<string, "Unfinalized">({
|
package/dist/GroupPath.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import * as Spec from "@confect/core/Spec";
|
|
2
|
-
import * as GroupSpec from "@confect/core/GroupSpec";
|
|
3
|
-
|
|
4
|
-
//#region src/GroupPath.d.ts
|
|
5
|
-
declare const resolveGroupPathUnsafe: (spec: Spec.AnyWithProps, target: GroupSpec.AnyWithProps) => string;
|
|
6
|
-
//#endregion
|
|
7
|
-
export { resolveGroupPathUnsafe };
|
|
8
|
-
//# sourceMappingURL=GroupPath.d.ts.map
|
package/dist/GroupPath.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GroupPath.d.ts","names":[],"sources":["../src/GroupPath.ts"],"mappings":";;;;cA+Ba,sBAAA,GACX,IAAA,EAAM,IAAA,CAAK,YAAA,EACX,MAAA,EAAQ,SAAA,CAAU,YAAA"}
|
package/dist/GroupPath.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Array, Option, Record, pipe } from "effect";
|
|
2
|
-
|
|
3
|
-
//#region src/GroupPath.ts
|
|
4
|
-
const resolveGroupPathInGroup = (group, target, pathSegments) => pipe(Record.toEntries(group.groups), Array.findFirst(([name, child]) => child === target ? Option.some(Array.join([...pathSegments, name], ".")) : resolveGroupPathInGroup(child, target, [...pathSegments, name])));
|
|
5
|
-
const resolveGroupPath = (spec, target) => pipe(Record.toEntries(spec.groups), Array.findFirst(([name, group]) => group === target ? Option.some(name) : resolveGroupPathInGroup(group, target, [name])));
|
|
6
|
-
const resolveGroupPathUnsafe = (spec, target) => resolveGroupPath(spec, target).pipe(Option.getOrThrowWith(() => /* @__PURE__ */ new Error("Could not resolve group path for the provided GroupSpec. Ensure the spec is part of the assembled API spec tree.")));
|
|
7
|
-
|
|
8
|
-
//#endregion
|
|
9
|
-
export { resolveGroupPathUnsafe };
|
|
10
|
-
//# sourceMappingURL=GroupPath.js.map
|
package/dist/GroupPath.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"GroupPath.js","names":[],"sources":["../src/GroupPath.ts"],"sourcesContent":["import type * as GroupSpec from \"@confect/core/GroupSpec\";\nimport type * as Spec from \"@confect/core/Spec\";\nimport { Array, Option, pipe, Record } from \"effect\";\n\nconst resolveGroupPathInGroup = (\n group: GroupSpec.AnyWithProps,\n target: GroupSpec.AnyWithProps,\n pathSegments: ReadonlyArray<string>,\n): Option.Option<string> =>\n pipe(\n Record.toEntries(group.groups),\n Array.findFirst(([name, child]) =>\n child === target\n ? Option.some(Array.join([...pathSegments, name], \".\"))\n : resolveGroupPathInGroup(child, target, [...pathSegments, name]),\n ),\n );\n\nconst resolveGroupPath = (\n spec: Spec.AnyWithProps,\n target: GroupSpec.AnyWithProps,\n): Option.Option<string> =>\n pipe(\n Record.toEntries(spec.groups),\n Array.findFirst(([name, group]) =>\n group === target\n ? Option.some(name)\n : resolveGroupPathInGroup(group, target, [name]),\n ),\n );\n\nexport const resolveGroupPathUnsafe = (\n spec: Spec.AnyWithProps,\n target: GroupSpec.AnyWithProps,\n): string =>\n resolveGroupPath(spec, target).pipe(\n Option.getOrThrowWith(\n () =>\n new Error(\n \"Could not resolve group path for the provided GroupSpec. Ensure the spec is part of the assembled API spec tree.\",\n ),\n ),\n );\n"],"mappings":";;;AAIA,MAAM,2BACJ,OACA,QACA,iBAEA,KACE,OAAO,UAAU,MAAM,OAAO,EAC9B,MAAM,WAAW,CAAC,MAAM,WACtB,UAAU,SACN,OAAO,KAAK,MAAM,KAAK,CAAC,GAAG,cAAc,KAAK,EAAE,IAAI,CAAC,GACrD,wBAAwB,OAAO,QAAQ,CAAC,GAAG,cAAc,KAAK,CAAC,CACpE,CACF;AAEH,MAAM,oBACJ,MACA,WAEA,KACE,OAAO,UAAU,KAAK,OAAO,EAC7B,MAAM,WAAW,CAAC,MAAM,WACtB,UAAU,SACN,OAAO,KAAK,KAAK,GACjB,wBAAwB,OAAO,QAAQ,CAAC,KAAK,CAAC,CACnD,CACF;AAEH,MAAa,0BACX,MACA,WAEA,iBAAiB,MAAM,OAAO,CAAC,KAC7B,OAAO,qCAEH,IAAI,MACF,mHACD,CACJ,CACF"}
|
package/src/GroupPath.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import type * as GroupSpec from "@confect/core/GroupSpec";
|
|
2
|
-
import type * as Spec from "@confect/core/Spec";
|
|
3
|
-
import { Array, Option, pipe, Record } from "effect";
|
|
4
|
-
|
|
5
|
-
const resolveGroupPathInGroup = (
|
|
6
|
-
group: GroupSpec.AnyWithProps,
|
|
7
|
-
target: GroupSpec.AnyWithProps,
|
|
8
|
-
pathSegments: ReadonlyArray<string>,
|
|
9
|
-
): Option.Option<string> =>
|
|
10
|
-
pipe(
|
|
11
|
-
Record.toEntries(group.groups),
|
|
12
|
-
Array.findFirst(([name, child]) =>
|
|
13
|
-
child === target
|
|
14
|
-
? Option.some(Array.join([...pathSegments, name], "."))
|
|
15
|
-
: resolveGroupPathInGroup(child, target, [...pathSegments, name]),
|
|
16
|
-
),
|
|
17
|
-
);
|
|
18
|
-
|
|
19
|
-
const resolveGroupPath = (
|
|
20
|
-
spec: Spec.AnyWithProps,
|
|
21
|
-
target: GroupSpec.AnyWithProps,
|
|
22
|
-
): Option.Option<string> =>
|
|
23
|
-
pipe(
|
|
24
|
-
Record.toEntries(spec.groups),
|
|
25
|
-
Array.findFirst(([name, group]) =>
|
|
26
|
-
group === target
|
|
27
|
-
? Option.some(name)
|
|
28
|
-
: resolveGroupPathInGroup(group, target, [name]),
|
|
29
|
-
),
|
|
30
|
-
);
|
|
31
|
-
|
|
32
|
-
export const resolveGroupPathUnsafe = (
|
|
33
|
-
spec: Spec.AnyWithProps,
|
|
34
|
-
target: GroupSpec.AnyWithProps,
|
|
35
|
-
): string =>
|
|
36
|
-
resolveGroupPath(spec, target).pipe(
|
|
37
|
-
Option.getOrThrowWith(
|
|
38
|
-
() =>
|
|
39
|
-
new Error(
|
|
40
|
-
"Could not resolve group path for the provided GroupSpec. Ensure the spec is part of the assembled API spec tree.",
|
|
41
|
-
),
|
|
42
|
-
),
|
|
43
|
-
);
|