@confect/server 1.0.0-next.0 → 1.0.0-next.2
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 +16 -0
- package/dist/ActionCtx.d.ts.map +1 -1
- package/dist/ActionCtx.js +2 -2
- package/dist/ActionRunner.d.ts.map +1 -1
- package/dist/ActionRunner.js +2 -2
- package/dist/Api.d.ts.map +1 -1
- package/dist/Api.js +2 -2
- package/dist/Api.js.map +1 -1
- package/dist/Auth.d.ts +8 -8
- package/dist/Auth.d.ts.map +1 -1
- package/dist/Auth.js +2 -2
- package/dist/DataModel.d.ts +3 -3
- package/dist/DataModel.d.ts.map +1 -1
- package/dist/DataModel.js +3 -1
- package/dist/DatabaseReader.d.ts +4 -4
- package/dist/DatabaseReader.d.ts.map +1 -1
- package/dist/DatabaseReader.js +2 -2
- package/dist/DatabaseReader.js.map +1 -1
- package/dist/DatabaseSchema.d.ts +32 -32
- package/dist/DatabaseSchema.d.ts.map +1 -1
- package/dist/DatabaseSchema.js +2 -2
- package/dist/DatabaseWriter.d.ts +24 -16
- package/dist/DatabaseWriter.d.ts.map +1 -1
- package/dist/DatabaseWriter.js +27 -25
- package/dist/DatabaseWriter.js.map +1 -1
- package/dist/Document.d.ts.map +1 -1
- package/dist/Document.js +2 -2
- package/dist/FunctionImpl.d.ts.map +1 -1
- package/dist/FunctionImpl.js +2 -2
- package/dist/GroupImpl.d.ts +1 -1
- package/dist/GroupImpl.d.ts.map +1 -1
- package/dist/GroupImpl.js +2 -2
- package/dist/Handler.d.ts.map +1 -1
- package/dist/Handler.js +3 -1
- package/dist/HttpApi.d.ts.map +1 -1
- package/dist/HttpApi.js +2 -2
- package/dist/HttpApi.js.map +1 -1
- package/dist/Impl.d.ts.map +1 -1
- package/dist/Impl.js +2 -2
- package/dist/Impl.js.map +1 -1
- package/dist/MutationCtx.d.ts.map +1 -1
- package/dist/MutationCtx.js +2 -2
- package/dist/MutationRunner.d.ts +3 -3
- package/dist/MutationRunner.d.ts.map +1 -1
- package/dist/MutationRunner.js +2 -2
- package/dist/OrderedQuery.d.ts.map +1 -1
- package/dist/OrderedQuery.js +2 -2
- package/dist/OrderedQuery.js.map +1 -1
- package/dist/QueryCtx.d.ts.map +1 -1
- package/dist/QueryCtx.js +2 -2
- package/dist/QueryInitializer.d.ts +1 -1
- package/dist/QueryInitializer.d.ts.map +1 -1
- package/dist/QueryInitializer.js +2 -2
- package/dist/QueryInitializer.js.map +1 -1
- package/dist/QueryRunner.d.ts.map +1 -1
- package/dist/QueryRunner.js +2 -2
- package/dist/RegisteredFunctions.d.ts +22 -20
- package/dist/RegisteredFunctions.d.ts.map +1 -1
- package/dist/RegisteredFunctions.js +2 -2
- package/dist/RegisteredFunctions.js.map +1 -1
- package/dist/Registry.d.ts.map +1 -1
- package/dist/Registry.js +2 -2
- package/dist/RegistryItem.d.ts.map +1 -1
- package/dist/RegistryItem.js +2 -2
- package/dist/Scheduler.d.ts +7 -7
- package/dist/Scheduler.d.ts.map +1 -1
- package/dist/Scheduler.js +2 -2
- package/dist/SchemaToValidator.d.ts +7 -7
- package/dist/SchemaToValidator.d.ts.map +1 -1
- package/dist/SchemaToValidator.js +2 -2
- package/dist/SchemaToValidator.js.map +1 -1
- package/dist/Storage.d.ts.map +1 -1
- package/dist/Storage.js +2 -2
- package/dist/Table.d.ts +53 -53
- package/dist/Table.d.ts.map +1 -1
- package/dist/Table.js +2 -2
- package/dist/Table.js.map +1 -1
- package/dist/TableInfo.d.ts +1 -1
- package/dist/TableInfo.d.ts.map +1 -1
- package/dist/TableInfo.js +3 -1
- package/dist/TableInfo.js.map +1 -1
- package/dist/VectorSearch.d.ts +7 -7
- package/dist/VectorSearch.d.ts.map +1 -1
- package/dist/VectorSearch.js +2 -2
- package/dist/_virtual/_rolldown/runtime.js +18 -0
- package/dist/internal/utils.d.ts.map +1 -1
- package/dist/internal/utils.js +2 -2
- package/dist/internal/utils.js.map +1 -1
- package/package.json +29 -27
- package/src/Api.ts +4 -2
- package/src/DatabaseWriter.ts +102 -113
- package/src/Impl.ts +4 -2
- package/src/RegisteredFunctions.ts +1 -9
- package/src/SchemaToValidator.ts +1 -3
- package/src/Table.ts +4 -4
- package/src/TableInfo.ts +0 -1
- package/dist/_virtual/rolldown_runtime.js +0 -13
package/dist/DatabaseWriter.js
CHANGED
|
@@ -1,39 +1,41 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { encode } from "./Document.js";
|
|
3
3
|
import { getById } from "./QueryInitializer.js";
|
|
4
4
|
import { Context, Effect, Layer, Record, pipe } from "effect";
|
|
5
5
|
|
|
6
6
|
//#region src/DatabaseWriter.ts
|
|
7
|
-
var DatabaseWriter_exports = /* @__PURE__ */
|
|
7
|
+
var DatabaseWriter_exports = /* @__PURE__ */ __exportAll({
|
|
8
8
|
DatabaseWriter: () => DatabaseWriter,
|
|
9
9
|
layer: () => layer,
|
|
10
10
|
make: () => make
|
|
11
11
|
});
|
|
12
12
|
const make = (databaseSchema, convexDatabaseWriter) => {
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
const
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
13
|
+
const tables = databaseSchema.tables;
|
|
14
|
+
const table = (tableName) => {
|
|
15
|
+
const tableDef = tables[tableName];
|
|
16
|
+
const tableSchema = tableDef.Fields;
|
|
17
|
+
const insert = (document) => Effect.gen(function* () {
|
|
18
|
+
const encodedDocument = yield* encode(document, tableName, tableDef.Fields);
|
|
19
|
+
return yield* Effect.promise(() => convexDatabaseWriter.insert(tableName, encodedDocument));
|
|
20
|
+
});
|
|
21
|
+
const patch = (id, patchedValues) => Effect.gen(function* () {
|
|
22
|
+
const originalDecodedDoc = yield* getById(tableName, convexDatabaseWriter, tableDef)(id);
|
|
23
|
+
const updatedEncodedDoc = yield* pipe(patchedValues, Record.reduce(originalDecodedDoc, (acc, value, key) => value === void 0 ? Record.remove(acc, key) : Record.set(acc, key, value)), encode(tableName, tableSchema));
|
|
24
|
+
yield* Effect.promise(() => convexDatabaseWriter.replace(id, updatedEncodedDoc));
|
|
25
|
+
});
|
|
26
|
+
const replace = (id, value) => Effect.gen(function* () {
|
|
27
|
+
const updatedEncodedDoc = yield* encode(value, tableName, tableSchema);
|
|
28
|
+
yield* Effect.promise(() => convexDatabaseWriter.replace(id, updatedEncodedDoc));
|
|
29
|
+
});
|
|
30
|
+
const delete_ = (id) => Effect.promise(() => convexDatabaseWriter.delete(id));
|
|
31
|
+
return {
|
|
32
|
+
insert,
|
|
33
|
+
patch,
|
|
34
|
+
replace,
|
|
35
|
+
delete: delete_
|
|
36
|
+
};
|
|
36
37
|
};
|
|
38
|
+
return { table };
|
|
37
39
|
};
|
|
38
40
|
const DatabaseWriter = () => Context.GenericTag("@confect/server/DatabaseWriter");
|
|
39
41
|
const layer = (databaseSchema, convexDatabaseWriter) => Layer.succeed(DatabaseWriter(), make(databaseSchema, convexDatabaseWriter));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatabaseWriter.js","names":["Document.encode","QueryInitializer.getById"],"sources":["../src/DatabaseWriter.ts"],"sourcesContent":["import type {\n BetterOmit,\n DocumentByName,\n Expand,\n GenericDatabaseWriter,\n WithoutSystemFields,\n} from \"convex/server\";\nimport type { GenericId } from \"convex/values\";\nimport { Context, Effect, Layer, pipe, Record } from \"effect\";\nimport type * as DatabaseSchema from \"./DatabaseSchema\";\nimport type * as DataModel from \"./DataModel\";\nimport type { DocumentByName as DocumentByName_ } from \"./DataModel\";\nimport * as Document from \"./Document\";\nimport * as QueryInitializer from \"./QueryInitializer\";\nimport type * as Table from \"./Table\";\nimport type * as TableInfo from \"./TableInfo\";\n\nexport const make = <DatabaseSchema_ extends DatabaseSchema.AnyWithProps>(\n databaseSchema: DatabaseSchema_,\n convexDatabaseWriter: GenericDatabaseWriter<\n DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>\n >,\n) => {\n type DataModel_ = DataModel.FromSchema<DatabaseSchema_>;\n\n const
|
|
1
|
+
{"version":3,"file":"DatabaseWriter.js","names":["Document.encode","QueryInitializer.getById"],"sources":["../src/DatabaseWriter.ts"],"sourcesContent":["import type {\n BetterOmit,\n DocumentByName,\n Expand,\n GenericDatabaseWriter,\n WithoutSystemFields,\n} from \"convex/server\";\nimport type { GenericId } from \"convex/values\";\nimport { Context, Effect, Layer, pipe, Record } from \"effect\";\nimport type * as DatabaseSchema from \"./DatabaseSchema\";\nimport type * as DataModel from \"./DataModel\";\nimport type { DocumentByName as DocumentByName_ } from \"./DataModel\";\nimport * as Document from \"./Document\";\nimport * as QueryInitializer from \"./QueryInitializer\";\nimport type * as Table from \"./Table\";\nimport type * as TableInfo from \"./TableInfo\";\n\nexport const make = <DatabaseSchema_ extends DatabaseSchema.AnyWithProps>(\n databaseSchema: DatabaseSchema_,\n convexDatabaseWriter: GenericDatabaseWriter<\n DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>\n >,\n) => {\n type DataModel_ = DataModel.FromSchema<DatabaseSchema_>;\n const tables = databaseSchema.tables as Record<string, Table.AnyWithProps>;\n\n const table = <const TableName extends DataModel.TableNames<DataModel_>>(\n tableName: TableName,\n ) => {\n const tableDef = tables[tableName]!;\n const tableSchema = tableDef.Fields as TableInfo.TableSchema<\n DataModel.TableInfoWithName_<DataModel_, TableName>\n >;\n\n const insert = (\n document: Document.WithoutSystemFields<\n DocumentByName_<DataModel_, TableName>\n >,\n ) =>\n Effect.gen(function* () {\n const encodedDocument = yield* Document.encode(\n document,\n tableName,\n tableDef.Fields,\n );\n\n const id = yield* Effect.promise(() =>\n convexDatabaseWriter.insert(\n tableName,\n encodedDocument as WithoutSystemFields<\n DocumentByName<DataModel.ToConvex<DataModel_>, TableName>\n >,\n ),\n );\n\n return id;\n });\n\n const patch = (\n id: GenericId<TableName>,\n patchedValues: Partial<\n WithoutSystemFields<DocumentByName_<DataModel_, TableName>>\n >,\n ) =>\n Effect.gen(function* () {\n const originalDecodedDoc = yield* QueryInitializer.getById(\n tableName,\n convexDatabaseWriter as any,\n tableDef,\n )(id);\n\n const updatedEncodedDoc = yield* pipe(\n patchedValues,\n Record.reduce(originalDecodedDoc, (acc, value, key) =>\n value === undefined\n ? Record.remove(acc, key)\n : Record.set(acc, key, value),\n ),\n Document.encode(tableName, tableSchema),\n );\n\n yield* Effect.promise(() =>\n convexDatabaseWriter.replace(\n id,\n updatedEncodedDoc as Expand<\n BetterOmit<\n DocumentByName<DataModel.ToConvex<DataModel_>, TableName>,\n \"_creationTime\" | \"_id\"\n >\n >,\n ),\n );\n });\n\n const replace = (\n id: GenericId<TableName>,\n value: WithoutSystemFields<DocumentByName_<DataModel_, TableName>>,\n ) =>\n Effect.gen(function* () {\n const updatedEncodedDoc = yield* Document.encode(\n value,\n tableName,\n tableSchema,\n );\n\n yield* Effect.promise(() =>\n convexDatabaseWriter.replace(\n id,\n updatedEncodedDoc as Expand<\n BetterOmit<\n DocumentByName<DataModel.ToConvex<DataModel_>, TableName>,\n \"_creationTime\" | \"_id\"\n >\n >,\n ),\n );\n });\n\n const delete_ = (id: GenericId<TableName>) =>\n Effect.promise(() => convexDatabaseWriter.delete(id));\n\n return {\n insert,\n patch,\n replace,\n delete: delete_,\n };\n };\n\n return {\n table,\n };\n};\n\nexport const DatabaseWriter = <\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n>() =>\n Context.GenericTag<ReturnType<typeof make<DatabaseSchema_>>>(\n \"@confect/server/DatabaseWriter\",\n );\n\nexport type DatabaseWriter<\n DatabaseSchema_ extends DatabaseSchema.AnyWithProps,\n> = ReturnType<typeof DatabaseWriter<DatabaseSchema_>>[\"Identifier\"];\n\nexport const layer = <DatabaseSchema_ extends DatabaseSchema.AnyWithProps>(\n databaseSchema: DatabaseSchema_,\n convexDatabaseWriter: GenericDatabaseWriter<\n DataModel.ToConvex<DataModel.FromSchema<DatabaseSchema_>>\n >,\n) =>\n Layer.succeed(\n DatabaseWriter<DatabaseSchema_>(),\n make(databaseSchema, convexDatabaseWriter),\n );\n"],"mappings":";;;;;;;;;;;AAiBA,MAAa,QACX,gBACA,yBAGG;CAEH,MAAM,SAAS,eAAe;CAE9B,MAAM,SACJ,cACG;EACH,MAAM,WAAW,OAAO;EACxB,MAAM,cAAc,SAAS;EAI7B,MAAM,UACJ,aAIA,OAAO,IAAI,aAAa;GACtB,MAAM,kBAAkB,OAAOA,OAC7B,UACA,WACA,SAAS,OACV;AAWD,UATW,OAAO,OAAO,cACvB,qBAAqB,OACnB,WACA,gBAGD,CACF;IAGD;EAEJ,MAAM,SACJ,IACA,kBAIA,OAAO,IAAI,aAAa;GACtB,MAAM,qBAAqB,OAAOC,QAChC,WACA,sBACA,SACD,CAAC,GAAG;GAEL,MAAM,oBAAoB,OAAO,KAC/B,eACA,OAAO,OAAO,qBAAqB,KAAK,OAAO,QAC7C,UAAU,SACN,OAAO,OAAO,KAAK,IAAI,GACvB,OAAO,IAAI,KAAK,KAAK,MAAM,CAChC,EACDD,OAAgB,WAAW,YAAY,CACxC;AAED,UAAO,OAAO,cACZ,qBAAqB,QACnB,IACA,kBAMD,CACF;IACD;EAEJ,MAAM,WACJ,IACA,UAEA,OAAO,IAAI,aAAa;GACtB,MAAM,oBAAoB,OAAOA,OAC/B,OACA,WACA,YACD;AAED,UAAO,OAAO,cACZ,qBAAqB,QACnB,IACA,kBAMD,CACF;IACD;EAEJ,MAAM,WAAW,OACf,OAAO,cAAc,qBAAqB,OAAO,GAAG,CAAC;AAEvD,SAAO;GACL;GACA;GACA;GACA,QAAQ;GACT;;AAGH,QAAO,EACL,OACD;;AAGH,MAAa,uBAGX,QAAQ,WACN,iCACD;AAMH,MAAa,SACX,gBACA,yBAIA,MAAM,QACJ,gBAAiC,EACjC,KAAK,gBAAgB,qBAAqB,CAC3C"}
|
package/dist/Document.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Document.d.ts","names":[],"sources":["../src/Document.ts"],"
|
|
1
|
+
{"version":3,"file":"Document.d.ts","names":[],"sources":["../src/Document.ts"],"mappings":";;;;;;;;;;KAOY,mBAAA,QAA2B,IAAA,CAAK,GAAA;AAAA,KAEhC,GAAA;AAAA,KACA,UAAA,GAAa,cAAA,SAAuB,aAAA;AAAA,cAEnC,MAAA,uBAEU,YAAA,oBACD,UAAA,CAAqB,UAAA,GAAW,SAAA,EAEvC,SAAA,EAAS,WAAA,EACP,WAAA,CACX,kBAAA,CAA6B,UAAA,EAAY,SAAA,QAG3C,IAAA,EAAM,kBAAA,CAA6B,UAAA,EAAY,SAAA,wBAC5C,MAAA,CAAO,MAAA,CACV,kBAAA,CAA6B,UAAA,EAAY,SAAA,eACzC,mBAAA,0BAGmB,YAAA,oBACD,UAAA,CAAqB,UAAA,GAAW,IAAA,EAE5C,kBAAA,CAA6B,UAAA,EAAY,SAAA,qBAA4B,SAAA,EAChE,SAAA,EAAS,WAAA,EACP,WAAA,CACX,kBAAA,CAA6B,UAAA,EAAY,SAAA,OAExC,MAAA,CAAO,MAAA,CACV,kBAAA,CAA6B,UAAA,EAAY,SAAA,eACzC,mBAAA;AAAA,cA+CS,MAAA,uBAEU,YAAA,oBACD,UAAA,CAAqB,UAAA,GAAW,SAAA,EAEvC,SAAA,EAAS,WAAA,EACP,WAAA,CACX,kBAAA,CAA6B,UAAA,EAAY,SAAA,QAG3C,IAAA,EAAM,kBAAA,CAA6B,UAAA,EAAY,SAAA,kBAC5C,MAAA,CAAO,MAAA,CACV,kBAAA,CAA6B,UAAA,EAAY,SAAA,sBACzC,mBAAA,0BAGmB,YAAA,oBACD,UAAA,CAAqB,UAAA,GAAW,IAAA,EAE5C,kBAAA,CAA6B,UAAA,EAAY,SAAA,eAAsB,SAAA,EAC1D,SAAA,EAAS,WAAA,EACP,WAAA,CACX,kBAAA,CAA6B,UAAA,EAAY,SAAA,OAExC,MAAA,CAAO,MAAA,CACV,kBAAA,CAA6B,UAAA,EAAY,SAAA,sBACzC,mBAAA;AAAA,cA8CF,wBAAA;;;;;;;cAEW,mBAAA,SAA4B,wBAAA;EAAA,IAO1B,OAAA,CAAA;AAAA;AAAA,cAOd,wBAAA;;;;;;;cAEY,mBAAA,SAA4B,wBAAA;EAAA,IAO1B,OAAA,CAAA;AAAA;AAAA,cASF,oBAAA;EAAwB,EAAA;EAAA,SAAA;EAAA;AAAA;EAKnC,EAAA;EACA,SAAA;EACA,OAAA;AAAA"}
|
package/dist/Document.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { Effect, Function, ParseResult, Schema, pipe } from "effect";
|
|
3
3
|
import * as SystemFields from "@confect/core/SystemFields";
|
|
4
4
|
|
|
5
5
|
//#region src/Document.ts
|
|
6
|
-
var Document_exports = /* @__PURE__ */
|
|
6
|
+
var Document_exports = /* @__PURE__ */ __exportAll({
|
|
7
7
|
DocumentDecodeError: () => DocumentDecodeError,
|
|
8
8
|
DocumentEncodeError: () => DocumentEncodeError,
|
|
9
9
|
decode: () => decode,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FunctionImpl.d.ts","names":[],"sources":["../src/FunctionImpl.ts"],"
|
|
1
|
+
{"version":3,"file":"FunctionImpl.d.ts","names":[],"sources":["../src/FunctionImpl.ts"],"mappings":";;;;;;;;;;;UAUiB,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,2BACY,SAAA,CAAU,GAAA,CAAI,MAAA,CAAW,IAAA,+BACvB,YAAA,CAAa,IAAA,CACtC,SAAA,CAAU,SAAA,CAAU,SAAA,CAAU,OAAA,CAAQ,MAAA,CAAW,IAAA,GAAO,UAAA,KAG1D,GAAA,EAAK,IAAA,EACL,SAAA,EAAW,UAAA,EACX,YAAA,EAAc,YAAA,EACd,OAAA,EAAS,QAAA,CACP,QAAA,CAAW,IAAA,GACX,SAAA,CAAU,SAAA,CAAU,SAAA,CAAU,OAAA,CAAQ,MAAA,CAAW,IAAA,GAAO,UAAA,IACxD,YAAA,MAED,KAAA,CAAM,KAAA,CAAM,YAAA,CAAa,UAAA,EAAY,YAAA;AArCxC;;;AAAA,KAgFY,uBAAA,2DAGR,YAAA,CAAa,UAAA,EAAY,YAAA;;;;KAKjB,eAAA,0CAEI,SAAA,CAAU,YAAA,IAExB,SAAA,CAAU,OAAA,CAAQ,KAAA,EAAO,UAAA,oCACvB,SAAA,CAAU,YAAA,GACR,YAAA,CAAa,IAAA,CACX,SAAA,CAAU,SAAA,CAAU,WAAA,gDAEpB,aAAA,kBACE,YAAA,CAAa,UAAA,EAAY,aAAA"}
|
package/dist/FunctionImpl.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { setNestedProperty } from "./internal/utils.js";
|
|
3
3
|
import { Registry } from "./Registry.js";
|
|
4
4
|
import { make as make$1 } from "./RegistryItem.js";
|
|
5
5
|
import { Array, Context, Effect, Layer, Ref, String } from "effect";
|
|
6
6
|
|
|
7
7
|
//#region src/FunctionImpl.ts
|
|
8
|
-
var FunctionImpl_exports = /* @__PURE__ */
|
|
8
|
+
var FunctionImpl_exports = /* @__PURE__ */ __exportAll({
|
|
9
9
|
FunctionImpl: () => FunctionImpl,
|
|
10
10
|
make: () => make
|
|
11
11
|
});
|
package/dist/GroupImpl.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ declare const GroupImpl: <GroupPath_ extends string>({
|
|
|
17
17
|
groupPath: GroupPath_;
|
|
18
18
|
}) => Context.Tag<GroupImpl<GroupPath_>, GroupImpl<GroupPath_>>;
|
|
19
19
|
declare const make: <Api_ extends AnyWithProps, const GroupPath_ extends GroupPath.All<Groups<Api_>>>(_api: Api_, groupPath: GroupPath_) => Layer.Layer<GroupImpl<GroupPath_>, never, FromGroupWithPath<GroupPath_, Groups<Api_>> | FromGroupAtPath<GroupPath_, Groups<Api_>>>;
|
|
20
|
-
type FromGroups<Groups
|
|
20
|
+
type FromGroups<Groups extends GroupSpec.Any> = Groups extends never ? never : Groups extends GroupSpec.AnyWithProps ? GroupImpl<GroupSpec.Name<Groups>> : never;
|
|
21
21
|
type FromGroupWithPath<GroupPath_ extends string, Group extends GroupSpec.AnyWithProps> = GroupPath.SubGroupsAt<Group, GroupPath_> extends infer SubGroupPaths ? SubGroupPaths extends string ? GroupImpl<SubGroupPaths> : never : never;
|
|
22
22
|
//#endregion
|
|
23
23
|
export { FromGroupWithPath, FromGroups, GroupImpl, GroupImpl_d_exports, make };
|
package/dist/GroupImpl.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GroupImpl.d.ts","names":[],"sources":["../src/GroupImpl.ts"],"
|
|
1
|
+
{"version":3,"file":"GroupImpl.d.ts","names":[],"sources":["../src/GroupImpl.ts"],"mappings":";;;;;;;;;;UAMiB,SAAA;EAAA,SACN,SAAA,EAAW,UAAA;AAAA;AAAA,cAGT,SAAA;EAAwC;AAAA;EAGnD,SAAA,EAAW,UAAA;AAAA,MACZ,OAAA,CAAA,GAAA,CAAA,SAAA,CAAA,UAAA,GAAA,SAAA,CAAA,UAAA;AAAA,cAKY,IAAA,gBACE,YAAA,2BACY,SAAA,CAAU,GAAA,CAAI,MAAA,CAAW,IAAA,IAElD,IAAA,EAAM,IAAA,EACN,SAAA,EAAW,UAAA,KACV,KAAA,CAAM,KAAA,CACP,SAAA,CAAU,UAAA,UAER,iBAAA,CAAkB,UAAA,EAAY,MAAA,CAAW,IAAA,KACzC,eAAA,CAA6B,UAAA,EAAY,MAAA,CAAW,IAAA;AAAA,KAgB5C,UAAA,gBAA0B,SAAA,CAAU,GAAA,IAAO,MAAA,yBAEnD,MAAA,SAAe,SAAA,CAAU,YAAA,GACvB,SAAA,CAAU,SAAA,CAAU,IAAA,CAAK,MAAA;AAAA,KAGnB,iBAAA,0CAEI,SAAA,CAAU,YAAA,IAExB,SAAA,CAAU,WAAA,CAAY,KAAA,EAAO,UAAA,gCACzB,aAAA,kBACE,SAAA,CAAU,aAAA"}
|
package/dist/GroupImpl.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { Context, Layer } from "effect";
|
|
3
3
|
|
|
4
4
|
//#region src/GroupImpl.ts
|
|
5
|
-
var GroupImpl_exports = /* @__PURE__ */
|
|
5
|
+
var GroupImpl_exports = /* @__PURE__ */ __exportAll({
|
|
6
6
|
GroupImpl: () => GroupImpl,
|
|
7
7
|
make: () => make
|
|
8
8
|
});
|
package/dist/Handler.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Handler.d.ts","names":[],"sources":["../src/Handler.ts"],"
|
|
1
|
+
{"version":3,"file":"Handler.d.ts","names":[],"sources":["../src/Handler.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;KAqBY,OAAA,yBACc,cAAA,wBACF,YAAA,CAAa,YAAA,IAEnC,aAAA,SAAsB,YAAA,CAAa,gBAAA,CAAiB,aAAA,aAChD,KAAA,CAAM,eAAA,EAAiB,aAAA,IACvB,aAAA,SAAsB,YAAA,CAAa,gBAAA,CAC/B,aAAA,gBAGF,QAAA,CAAS,eAAA,EAAiB,aAAA,IAC1B,aAAA,SAAsB,YAAA,CAAa,gBAAA,CAC/B,aAAA,cAGF,MAAA,CAAO,eAAA,EAAiB,aAAA;AAAA,KAGtB,KAAA,yBACc,cAAA,wBACF,YAAA,CAAa,4BAAA,aACjC,IAAA,CACF,aAAA,EACE,cAAA,CAA8B,eAAA,IAC9B,IAAA,GACA,aAAA,GACA,WAAA,GACA,QAAA,CAAkB,QAAA,CAAmB,UAAA,CAAqB,eAAA;AAAA,KAGlD,QAAA,yBACc,cAAA,wBACF,YAAA,CAAa,4BAAA,gBACjC,IAAA,CACF,aAAA,EACE,cAAA,CAA8B,eAAA,IAC9B,cAAA,CAA8B,eAAA,IAC9B,IAAA,GACA,SAAA,GACA,aAAA,GACA,aAAA,GACA,WAAA,GACA,cAAA,GACA,WAAA,CACE,QAAA,CAAmB,UAAA,CAAqB,eAAA;AAAA,KAIlC,MAAA,yBACc,cAAA,wBACF,YAAA,CAAa,4BAAA,cACjC,IAAA,CACF,aAAA,EACE,SAAA,GACA,IAAA,GACA,aAAA,GACA,aAAA,GACA,mBAAA,GACA,WAAA,GACA,cAAA,GACA,YAAA,GACA,YAAA,CAA0B,UAAA,CAAqB,eAAA,KAC/C,SAAA,CACE,QAAA,CAAmB,UAAA,CAAqB,eAAA;AAAA,KAIzC,IAAA,uBAA2B,YAAA,CAAa,YAAA,QAC3C,IAAA,EAAM,YAAA,CAAa,IAAA,CAAK,aAAA,cACrB,MAAA,CAAO,MAAA,CAAO,YAAA,CAAa,OAAA,CAAQ,aAAA,kBAA+B,CAAA;AAAA,KAE3D,YAAA,GAAe,OAAA,CACzB,cAAA,EACA,YAAA,CAAa,YAAA;AAAA,KAGH,QAAA,yBACc,cAAA,wBACF,YAAA,CAAa,YAAA,iCAEjC,OAAA,CACF,eAAA,EACA,YAAA,CAAa,QAAA,CAAS,aAAA,EAAe,YAAA"}
|
package/dist/Handler.js
CHANGED
package/dist/HttpApi.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpApi.d.ts","names":[],"sources":["../src/HttpApi.ts"],"
|
|
1
|
+
{"version":3,"file":"HttpApi.d.ts","names":[],"sources":["../src/HttpApi.ts"],"mappings":";;;;;;;;;;;;;;KA0BK,UAAA,IACH,OAAA,EAAS,OAAA,CAAQ,OAAA,KACd,OAAA,CAAQ,OAAA,QAEX,OAAA,CAAQ,GAAA,GAAM,cAAA,CAAe,MAAA,GAAS,YAAA,CAAW,UAAA,CAAW,eAAA;AAAA,KAqGlD,QAAA;EACV,OAAA,EAAS,KAAA,CAAM,KAAA,CACb,OAAA,CAAQ,GAAA,SAEN,WAAA,GACA,cAAA,GACA,YAAA,GACA,WAAA,GACA,MAAA,GACA,eAAA,GACA,eAAA,GACA,qBAAA;EAEJ,UAAA,GAAa,UAAA;EACb,MAAA,GAAS,aAAA,CAAc,YAAA;AAAA;AAAA,KAGb,SAAA;AAAA,KA8CP,QAAA,GAAW,OAAA,CAAQ,MAAA,CAAO,SAAA,EAAW,QAAA;AAAA,cAE7B,IAAA,GAAQ,QAAA,EAAU,QAAA,KAAW,UAAA"}
|
package/dist/HttpApi.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { ActionCtx } from "./ActionCtx.js";
|
|
3
3
|
import { layer } from "./ActionRunner.js";
|
|
4
4
|
import { layer as layer$1 } from "./Auth.js";
|
|
@@ -11,7 +11,7 @@ import { ROUTABLE_HTTP_METHODS, httpActionGeneric, httpRouter } from "convex/ser
|
|
|
11
11
|
import { HttpApiBuilder, HttpApiScalar, HttpServer } from "@effect/platform";
|
|
12
12
|
|
|
13
13
|
//#region src/HttpApi.ts
|
|
14
|
-
var HttpApi_exports = /* @__PURE__ */
|
|
14
|
+
var HttpApi_exports = /* @__PURE__ */ __exportAll({ make: () => make });
|
|
15
15
|
const makeHandler = ({ pathPrefix, apiLive, middleware, scalar }) => (ctx, request) => {
|
|
16
16
|
const ApiLive = apiLive.pipe(Layer.provide(Layer.mergeAll(layer$3(ctx.runQuery), layer$2(ctx.runMutation), layer(ctx.runAction), layer$4(ctx.scheduler), layer$1(ctx.auth), StorageReader$1.layer(ctx.storage), StorageWriter$1.layer(ctx.storage), StorageActionWriter$1.layer(ctx.storage), Layer.succeed(ActionCtx(), ctx))));
|
|
17
17
|
const ApiDocsLive = HttpApiScalar.layer({
|
package/dist/HttpApi.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HttpApi.js","names":["QueryRunner.layer","MutationRunner.layer","ActionRunner.layer","Scheduler.layer","Auth.layer","StorageReader","StorageWriter","StorageActionWriter","ActionCtx.ActionCtx"
|
|
1
|
+
{"version":3,"file":"HttpApi.js","names":["QueryRunner.layer","MutationRunner.layer","ActionRunner.layer","Scheduler.layer","Auth.layer","StorageReader","StorageWriter","StorageActionWriter","ActionCtx.ActionCtx"],"sources":["../src/HttpApi.ts"],"sourcesContent":["import {\n type HttpApi,\n HttpApiBuilder,\n HttpApiScalar,\n type HttpApp,\n type HttpRouter,\n HttpServer,\n} from \"@effect/platform\";\nimport {\n type HttpRouter as ConvexHttpRouter,\n type GenericActionCtx,\n type GenericDataModel,\n httpActionGeneric,\n httpRouter,\n ROUTABLE_HTTP_METHODS,\n type RouteSpecWithPathPrefix,\n} from \"convex/server\";\nimport { Array, Layer, pipe, Record } from \"effect\";\nimport * as ActionRunner from \"./ActionRunner\";\nimport * as Auth from \"./Auth\";\nimport * as MutationRunner from \"./MutationRunner\";\nimport * as QueryRunner from \"./QueryRunner\";\nimport * as Scheduler from \"./Scheduler\";\nimport { StorageActionWriter, StorageReader, StorageWriter } from \"./Storage\";\nimport * as ActionCtx from \"./ActionCtx\";\n\ntype Middleware = (\n httpApp: HttpApp.Default,\n) => HttpApp.Default<\n never,\n HttpApi.Api | HttpApiBuilder.Router | HttpRouter.HttpRouter.DefaultServices\n>;\n\nconst makeHandler =\n <DataModel extends GenericDataModel>({\n pathPrefix,\n apiLive,\n middleware,\n scalar,\n }: {\n pathPrefix: RoutePath;\n apiLive: Layer.Layer<\n HttpApi.Api,\n never,\n | QueryRunner.QueryRunner\n | MutationRunner.MutationRunner\n | ActionRunner.ActionRunner\n | Scheduler.Scheduler\n | Auth.Auth\n | StorageReader\n | StorageWriter\n | StorageActionWriter\n | GenericActionCtx<DataModel>\n >;\n middleware?: Middleware;\n scalar?: HttpApiScalar.ScalarConfig;\n }) =>\n (ctx: GenericActionCtx<DataModel>, request: Request): Promise<Response> => {\n const ApiLive = apiLive.pipe(\n Layer.provide(\n Layer.mergeAll(\n QueryRunner.layer(ctx.runQuery),\n MutationRunner.layer(ctx.runMutation),\n ActionRunner.layer(ctx.runAction),\n Scheduler.layer(ctx.scheduler),\n Auth.layer(ctx.auth),\n StorageReader.layer(ctx.storage),\n StorageWriter.layer(ctx.storage),\n StorageActionWriter.layer(ctx.storage),\n Layer.succeed(ActionCtx.ActionCtx<DataModel>(), ctx),\n ),\n ),\n );\n\n const ApiDocsLive = HttpApiScalar.layer({\n path: `${pathPrefix}docs`,\n scalar: {\n baseServerURL: `${process.env[\"CONVEX_SITE_URL\"]}${pathPrefix}`,\n ...scalar,\n },\n }).pipe(Layer.provide(ApiLive));\n\n const EnvLive = Layer.mergeAll(\n ApiLive,\n ApiDocsLive,\n HttpServer.layerContext,\n );\n\n const { handler } = HttpApiBuilder.toWebHandler(\n EnvLive,\n middleware ? { middleware } : {},\n );\n\n return handler(request);\n };\n\nconst makeHttpAction = <DataModel extends GenericDataModel>({\n pathPrefix,\n apiLive,\n middleware,\n scalar,\n}: {\n pathPrefix: RoutePath;\n apiLive: Layer.Layer<\n HttpApi.Api,\n never,\n | QueryRunner.QueryRunner\n | MutationRunner.MutationRunner\n | ActionRunner.ActionRunner\n | Scheduler.Scheduler\n | Auth.Auth\n | StorageReader\n | StorageWriter\n | StorageActionWriter\n | GenericActionCtx<DataModel>\n >;\n middleware?: Middleware;\n scalar?: HttpApiScalar.ScalarConfig;\n}) =>\n httpActionGeneric(\n makeHandler<DataModel>({\n pathPrefix,\n apiLive,\n ...(middleware ? { middleware } : {}),\n ...(scalar ? { scalar } : {}),\n }) as unknown as (\n ctx: GenericActionCtx<GenericDataModel>,\n request: Request,\n ) => Promise<Response>,\n );\n\nexport type HttpApi_ = {\n apiLive: Layer.Layer<\n HttpApi.Api,\n never,\n | QueryRunner.QueryRunner\n | MutationRunner.MutationRunner\n | ActionRunner.ActionRunner\n | Scheduler.Scheduler\n | Auth.Auth\n | StorageReader\n | StorageWriter\n | StorageActionWriter\n >;\n middleware?: Middleware;\n scalar?: HttpApiScalar.ScalarConfig;\n};\n\nexport type RoutePath = \"/\" | `/${string}/`;\n\nconst mountEffectHttpApi =\n <DataModel extends GenericDataModel>({\n pathPrefix,\n apiLive,\n middleware,\n scalar,\n }: {\n pathPrefix: RoutePath;\n apiLive: Layer.Layer<\n HttpApi.Api,\n never,\n | QueryRunner.QueryRunner\n | MutationRunner.MutationRunner\n | ActionRunner.ActionRunner\n | Scheduler.Scheduler\n | Auth.Auth\n | StorageReader\n | StorageWriter\n | StorageActionWriter\n | GenericActionCtx<DataModel>\n >;\n middleware?: Middleware;\n scalar?: HttpApiScalar.ScalarConfig;\n }) =>\n (convexHttpRouter: ConvexHttpRouter): ConvexHttpRouter => {\n const handler = makeHttpAction<DataModel>({\n pathPrefix,\n apiLive,\n ...(middleware ? { middleware } : {}),\n ...(scalar ? { scalar } : {}),\n });\n\n Array.forEach(ROUTABLE_HTTP_METHODS, (method) => {\n const routeSpec: RouteSpecWithPathPrefix = {\n pathPrefix,\n method,\n handler,\n };\n convexHttpRouter.route(routeSpec);\n });\n\n return convexHttpRouter;\n };\n\ntype HttpApis = Partial<Record<RoutePath, HttpApi_>>;\n\nexport const make = (httpApis: HttpApis): ConvexHttpRouter => {\n applyMonkeyPatches();\n\n return pipe(\n httpApis as Record<RoutePath, HttpApi_>,\n Record.toEntries,\n Array.reduce(\n httpRouter(),\n (convexHttpRouter, [pathPrefix, { apiLive, middleware, scalar }]) =>\n mountEffectHttpApi({\n pathPrefix: pathPrefix as RoutePath,\n apiLive,\n ...(middleware ? { middleware } : {}),\n ...(scalar ? { scalar } : {}),\n })(convexHttpRouter),\n ),\n );\n};\n\nconst applyMonkeyPatches = () => {\n // These are necessary until the Convex runtime supports these APIs. See https://discord.com/channels/1019350475847499849/1281364098419785760\n\n // eslint-disable-next-line no-global-assign\n URL = class extends URL {\n override get username() {\n return \"\";\n }\n override get password() {\n return \"\";\n }\n };\n\n Object.defineProperty(Request.prototype, \"signal\", {\n get: () => new AbortSignal(),\n });\n};\n"],"mappings":";;;;;;;;;;;;;;AAiCA,MAAM,eACiC,EACnC,YACA,SACA,YACA,cAmBD,KAAkC,YAAwC;CACzE,MAAM,UAAU,QAAQ,KACtB,MAAM,QACJ,MAAM,SACJA,QAAkB,IAAI,SAAS,EAC/BC,QAAqB,IAAI,YAAY,EACrCC,MAAmB,IAAI,UAAU,EACjCC,QAAgB,IAAI,UAAU,EAC9BC,QAAW,IAAI,KAAK,EACpBC,gBAAc,MAAM,IAAI,QAAQ,EAChCC,gBAAc,MAAM,IAAI,QAAQ,EAChCC,sBAAoB,MAAM,IAAI,QAAQ,EACtC,MAAM,QAAQC,WAAgC,EAAE,IAAI,CACrD,CACF,CACF;CAED,MAAM,cAAc,cAAc,MAAM;EACtC,MAAM,GAAG,WAAW;EACpB,QAAQ;GACN,eAAe,GAAG,QAAQ,IAAI,qBAAqB;GACnD,GAAG;GACJ;EACF,CAAC,CAAC,KAAK,MAAM,QAAQ,QAAQ,CAAC;CAE/B,MAAM,UAAU,MAAM,SACpB,SACA,aACA,WAAW,aACZ;CAED,MAAM,EAAE,YAAY,eAAe,aACjC,SACA,aAAa,EAAE,YAAY,GAAG,EAAE,CACjC;AAED,QAAO,QAAQ,QAAQ;;AAG3B,MAAM,kBAAsD,EAC1D,YACA,SACA,YACA,aAmBA,kBACE,YAAuB;CACrB;CACA;CACA,GAAI,aAAa,EAAE,YAAY,GAAG,EAAE;CACpC,GAAI,SAAS,EAAE,QAAQ,GAAG,EAAE;CAC7B,CAAC,CAIH;AAqBH,MAAM,sBACiC,EACnC,YACA,SACA,YACA,cAmBD,qBAAyD;CACxD,MAAM,UAAU,eAA0B;EACxC;EACA;EACA,GAAI,aAAa,EAAE,YAAY,GAAG,EAAE;EACpC,GAAI,SAAS,EAAE,QAAQ,GAAG,EAAE;EAC7B,CAAC;AAEF,OAAM,QAAQ,wBAAwB,WAAW;EAC/C,MAAM,YAAqC;GACzC;GACA;GACA;GACD;AACD,mBAAiB,MAAM,UAAU;GACjC;AAEF,QAAO;;AAKX,MAAa,QAAQ,aAAyC;AAC5D,qBAAoB;AAEpB,QAAO,KACL,UACA,OAAO,WACP,MAAM,OACJ,YAAY,GACX,kBAAkB,CAAC,YAAY,EAAE,SAAS,YAAY,cACrD,mBAAmB;EACL;EACZ;EACA,GAAI,aAAa,EAAE,YAAY,GAAG,EAAE;EACpC,GAAI,SAAS,EAAE,QAAQ,GAAG,EAAE;EAC7B,CAAC,CAAC,iBAAiB,CACvB,CACF;;AAGH,MAAM,2BAA2B;AAI/B,OAAM,cAAc,IAAI;EACtB,IAAa,WAAW;AACtB,UAAO;;EAET,IAAa,WAAW;AACtB,UAAO;;;AAIX,QAAO,eAAe,QAAQ,WAAW,UAAU,EACjD,WAAW,IAAI,aAAa,EAC7B,CAAC"}
|
package/dist/Impl.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Impl.d.ts","names":[],"sources":["../src/Impl.ts"],"
|
|
1
|
+
{"version":3,"file":"Impl.d.ts","names":[],"sources":["../src/Impl.ts"],"mappings":";;;;;;;;cAKa,MAAA;AAAA,KACD,MAAA,UAAgB,MAAA;AAAA,cAEf,MAAA,GAAU,CAAA,cAAa,CAAA,IAAK,YAAA;AAAA,UAGxB,IAAA,cACF,cAAA,8BACe,kBAAA;EAAA,UAElB,MAAA,GAAS,MAAA;EAAA,SACV,GAAA,EAAK,IAAA;EAAA,SACL,kBAAA,EAAoB,mBAAA;AAAA;AAAA,KAGnB,kBAAA;AAAA,UAEK,YAAA,SAAqB,IAAA,CACpC,cAAA,EACA,kBAAA;AAAA,cAGW,IAAA,gBACE,cAAA,8BACe,kBAAA,OAAkB,OAAA,CAAA,GAAA,CAAA,IAAA,CAAA,IAAA,EAAA,mBAAA,GAAA,IAAA,CAAA,IAAA,EAAA,mBAAA;AAAA,cAInC,IAAA,gBAAqB,cAAA,EAChC,GAAA,EAAK,IAAA,KACJ,KAAA,CAAM,KAAA,CACP,IAAA,CAAK,IAAA,yBAEL,UAAA,CAAqB,MAAA,CAAU,IAAA;AAAA,cAWpB,QAAA,gBAAyB,cAAA,EACpC,IAAA,EAAM,KAAA,CAAM,KAAA,CAAM,IAAA,CAAK,IAAA,sBACtB,KAAA,CAAM,KAAA,CAAM,IAAA,CAAK,IAAA"}
|
package/dist/Impl.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { Context, Effect, Layer, Predicate } from "effect";
|
|
3
3
|
|
|
4
4
|
//#region src/Impl.ts
|
|
5
|
-
var Impl_exports = /* @__PURE__ */
|
|
5
|
+
var Impl_exports = /* @__PURE__ */ __exportAll({
|
|
6
6
|
Impl: () => Impl,
|
|
7
7
|
TypeId: () => TypeId,
|
|
8
8
|
finalize: () => finalize,
|
package/dist/Impl.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Impl.js","names":[],"sources":["../src/Impl.ts"],"sourcesContent":["import { Context, Effect, Layer, Predicate } from \"effect\";\nimport type * as Api from \"./Api\";\nimport type { Groups as ApiGroups } from \"./Api\";\nimport type * as GroupImpl from \"./GroupImpl\";\n\nexport const TypeId = \"@confect/server/Impl\";\nexport type TypeId = typeof TypeId;\n\nexport const isImpl = (u: unknown): u is AnyWithProps =>\n Predicate.hasProperty(u, TypeId);\n\nexport interface Impl<\n Api_ extends Api.AnyWithProps,\n FinalizationStatus_ extends FinalizationStatus,\n> {\n readonly [TypeId]: TypeId;\n readonly api: Api_;\n readonly finalizationStatus: FinalizationStatus_;\n}\n\nexport type FinalizationStatus = \"Unfinalized\" | \"Finalized\";\n\nexport interface AnyWithProps
|
|
1
|
+
{"version":3,"file":"Impl.js","names":[],"sources":["../src/Impl.ts"],"sourcesContent":["import { Context, Effect, Layer, Predicate } from \"effect\";\nimport type * as Api from \"./Api\";\nimport type { Groups as ApiGroups } from \"./Api\";\nimport type * as GroupImpl from \"./GroupImpl\";\n\nexport const TypeId = \"@confect/server/Impl\";\nexport type TypeId = typeof TypeId;\n\nexport const isImpl = (u: unknown): u is AnyWithProps =>\n Predicate.hasProperty(u, TypeId);\n\nexport interface Impl<\n Api_ extends Api.AnyWithProps,\n FinalizationStatus_ extends FinalizationStatus,\n> {\n readonly [TypeId]: TypeId;\n readonly api: Api_;\n readonly finalizationStatus: FinalizationStatus_;\n}\n\nexport type FinalizationStatus = \"Unfinalized\" | \"Finalized\";\n\nexport interface AnyWithProps extends Impl<\n Api.AnyWithProps,\n FinalizationStatus\n> {}\n\nexport const Impl = <\n Api_ extends Api.AnyWithProps,\n FinalizationStatus_ extends FinalizationStatus,\n>() =>\n Context.GenericTag<Impl<Api_, FinalizationStatus_>>(`@confect/server/Impl`);\n\nexport const make = <Api_ extends Api.AnyWithProps>(\n api: Api_,\n): Layer.Layer<\n Impl<Api_, \"Unfinalized\">,\n never,\n GroupImpl.FromGroups<ApiGroups<Api_>>\n> =>\n Layer.effect(\n Impl<Api_, \"Unfinalized\">(),\n Effect.succeed({\n [TypeId]: TypeId,\n api,\n finalizationStatus: \"Unfinalized\" as const,\n }),\n );\n\nexport const finalize = <Api_ extends Api.AnyWithProps>(\n impl: Layer.Layer<Impl<Api_, \"Unfinalized\">>,\n): Layer.Layer<Impl<Api_, \"Finalized\">> =>\n Layer.map(impl, (context) =>\n Context.make(Impl<Api_, \"Finalized\">(), {\n [TypeId]: TypeId,\n api: Context.get(context, Impl<Api_, \"Unfinalized\">()).api,\n finalizationStatus: \"Finalized\",\n }),\n );\n"],"mappings":";;;;;;;;;;;AAKA,MAAa,SAAS;AAGtB,MAAa,UAAU,MACrB,UAAU,YAAY,GAAG,OAAO;AAkBlC,MAAa,aAIX,QAAQ,WAA4C,uBAAuB;AAE7E,MAAa,QACX,QAMA,MAAM,OACJ,MAA2B,EAC3B,OAAO,QAAQ;EACZ,SAAS;CACV;CACA,oBAAoB;CACrB,CAAC,CACH;AAEH,MAAa,YACX,SAEA,MAAM,IAAI,OAAO,YACf,QAAQ,KAAK,MAAyB,EAAE;EACrC,SAAS;CACV,KAAK,QAAQ,IAAI,SAAS,MAA2B,CAAC,CAAC;CACvD,oBAAoB;CACrB,CAAC,CACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MutationCtx.d.ts","names":[],"sources":["../src/MutationCtx.ts"],"
|
|
1
|
+
{"version":3,"file":"MutationCtx.d.ts","names":[],"sources":["../src/MutationCtx.ts"],"mappings":";;;;;;;cAGa,WAAA,qBAAiC,gBAAA,OAAgB,OAAA,CAAA,GAAA,CAAA,kBAAA,CAAA,SAAA,GAAA,kBAAA,CAAA,SAAA;AAAA,KAKlD,WAAA,mBAA8B,gBAAA,IAAoB,UAAA,QACrD,WAAA,CAAY,SAAA"}
|
package/dist/MutationCtx.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { Context } from "effect";
|
|
3
3
|
|
|
4
4
|
//#region src/MutationCtx.ts
|
|
5
|
-
var MutationCtx_exports = /* @__PURE__ */
|
|
5
|
+
var MutationCtx_exports = /* @__PURE__ */ __exportAll({ MutationCtx: () => MutationCtx });
|
|
6
6
|
const MutationCtx = () => Context.GenericTag("@confect/server/MutationCtx");
|
|
7
7
|
|
|
8
8
|
//#endregion
|
package/dist/MutationRunner.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { Context, Effect, Layer, Schema } from "effect";
|
|
2
2
|
import * as Ref$1 from "@confect/core/Ref";
|
|
3
3
|
import { GenericMutationCtx } from "convex/server";
|
|
4
|
-
import * as
|
|
4
|
+
import * as effect_ParseResult0 from "effect/ParseResult";
|
|
5
5
|
|
|
6
6
|
//#region src/MutationRunner.d.ts
|
|
7
7
|
declare namespace MutationRunner_d_exports {
|
|
8
8
|
export { MutationRollback, MutationRunner, layer };
|
|
9
9
|
}
|
|
10
|
-
declare const MutationRunner: Context.Tag<(<Mutation extends Ref$1.AnyMutation>(mutation: Mutation, args: Ref$1.Args<Mutation>["Type"]) => Effect.Effect<any,
|
|
10
|
+
declare const MutationRunner: Context.Tag<(<Mutation extends Ref$1.AnyMutation>(mutation: Mutation, args: Ref$1.Args<Mutation>["Type"]) => Effect.Effect<any, effect_ParseResult0.ParseError, never>), <Mutation extends Ref$1.AnyMutation>(mutation: Mutation, args: Ref$1.Args<Mutation>["Type"]) => Effect.Effect<any, effect_ParseResult0.ParseError, never>>;
|
|
11
11
|
type MutationRunner = typeof MutationRunner.Identifier;
|
|
12
|
-
declare const layer: (runMutation: GenericMutationCtx<any>["runMutation"]) => Layer.Layer<(<Mutation extends Ref$1.AnyMutation>(mutation: Mutation, args: Ref$1.Args<Mutation>["Type"]) => Effect.Effect<any,
|
|
12
|
+
declare const layer: (runMutation: GenericMutationCtx<any>["runMutation"]) => Layer.Layer<(<Mutation extends Ref$1.AnyMutation>(mutation: Mutation, args: Ref$1.Args<Mutation>["Type"]) => Effect.Effect<any, effect_ParseResult0.ParseError, never>), never, never>;
|
|
13
13
|
declare const MutationRollback_base: Schema.TaggedErrorClass<MutationRollback, "MutationRollback", {
|
|
14
14
|
readonly _tag: Schema.tag<"MutationRollback">;
|
|
15
15
|
} & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MutationRunner.d.ts","names":[],"sources":["../src/MutationRunner.ts"],"
|
|
1
|
+
{"version":3,"file":"MutationRunner.d.ts","names":[],"sources":["../src/MutationRunner.ts"],"mappings":";;;;;;;;;cAqBa,cAAA,EAAc,OAAA,CAAA,GAAA,oBAfP,KAAA,CAAI,WAAA,EAAW,QAAA,EACrB,QAAA,EAAQ,IAAA,EACZ,KAAA,CAAI,IAAA,CAAK,QAAA,cAAiB,MAAA,CAAA,MAAA,MAAlB,mBAAA,CAAkB,UAAA,6BAFhB,KAAA,CAAI,WAAA,EAAW,QAAA,EACrB,QAAA,EAAQ,IAAA,EACZ,KAAA,CAAI,IAAA,CAAK,QAAA,cAAiB,MAAA,CAAA,MAAA,MAAlB,mBAAA,CAAkB,UAAA;AAAA,KAgBxB,cAAA,UAAwB,cAAA,CAAe,UAAA;AAAA,cAEtC,KAAA,GAAS,WAAA,EAAa,kBAAA,yBAAsC,KAAA,CAAA,KAAA,oBApBrD,KAAA,CAAI,WAAA,EAAW,QAAA,EACrB,QAAA,EAAQ,IAAA,EACZ,KAAA,CAAI,IAAA,CAAK,QAAA,cAAiB,MAAA,CAAA,MAAA,MAAlB,mBAAA,CAAkB,UAAA;AAAA,cAmB6B,qBAAA;;;;;;cAEpD,gBAAA,SAAyB,qBAAA;EAAA,IAOvB,OAAA,CAAA;AAAA"}
|
package/dist/MutationRunner.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { Context, Effect, Layer, Schema } from "effect";
|
|
3
3
|
import * as Ref$1 from "@confect/core/Ref";
|
|
4
4
|
import "convex/server";
|
|
5
5
|
|
|
6
6
|
//#region src/MutationRunner.ts
|
|
7
|
-
var MutationRunner_exports = /* @__PURE__ */
|
|
7
|
+
var MutationRunner_exports = /* @__PURE__ */ __exportAll({
|
|
8
8
|
MutationRollback: () => MutationRollback,
|
|
9
9
|
MutationRunner: () => MutationRunner,
|
|
10
10
|
layer: () => layer
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OrderedQuery.d.ts","names":[],"sources":["../src/OrderedQuery.ts"],"
|
|
1
|
+
{"version":3,"file":"OrderedQuery.d.ts","names":[],"sources":["../src/OrderedQuery.ts"],"mappings":";;;;;;;;;KAQY,YAAA,oBACS,YAAA;EAAA,SAGV,KAAA,QAAa,MAAA,CAAO,MAAA,CAC3B,MAAA,CAAO,MAAA,CAAO,UAAA,eACd,mBAAA;EAAA,SAEO,IAAA,GACP,CAAA,aACG,MAAA,CAAO,MAAA,CACV,aAAA,CAAc,UAAA,eACd,mBAAA;EAAA,SAEO,OAAA,QAAe,MAAA,CAAO,MAAA,CAC7B,aAAA,CAAc,UAAA,eACd,mBAAA;EAAA,SAEO,MAAA,QAAc,MAAA,CAAO,MAAA,CAC5B,UAAA,cACA,mBAAA;EAAA,SAEO,QAAA,GAAW,OAAA;IAClB,MAAA;IACA,QAAA;EAAA,MACI,MAAA,CAAO,MAAA,CACX,gBAAA,CAAiB,UAAA,eACjB,mBAAA;AAAA;AAAA,cAIS,IAAA,sBACQ,YAAA,4BAGnB,KAAA,EAAO,cAAA,CAAmB,eAAA,CAA0B,UAAA,IACpD,SAAA,EAAW,SAAA,EACX,WAAA,EAAa,WAAA,CAAsB,UAAA,MAClC,YAAA,CAAa,UAAA,EAAY,SAAA"}
|
package/dist/OrderedQuery.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { decode } from "./Document.js";
|
|
3
3
|
import { Chunk, Effect, Stream, identity, pipe } from "effect";
|
|
4
4
|
|
|
5
5
|
//#region src/OrderedQuery.ts
|
|
6
|
-
var OrderedQuery_exports = /* @__PURE__ */
|
|
6
|
+
var OrderedQuery_exports = /* @__PURE__ */ __exportAll({ make: () => make });
|
|
7
7
|
const make = (query, tableName, tableSchema) => {
|
|
8
8
|
const streamEncoded = Stream.fromAsyncIterable(query, identity).pipe(Stream.orDie);
|
|
9
9
|
const stream = () => pipe(streamEncoded, Stream.mapEffect(decode(tableName, tableSchema)));
|
package/dist/OrderedQuery.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OrderedQuery.js","names":["
|
|
1
|
+
{"version":3,"file":"OrderedQuery.js","names":["Document.decode"],"sources":["../src/OrderedQuery.ts"],"sourcesContent":["import type {\n OrderedQuery as ConvexOrderedQuery,\n PaginationResult,\n} from \"convex/server\";\nimport { Chunk, Effect, identity, type Option, pipe, Stream } from \"effect\";\nimport * as Document from \"./Document\";\nimport type * as TableInfo from \"./TableInfo\";\n\nexport type OrderedQuery<\n TableInfo_ extends TableInfo.AnyWithProps,\n _TableName extends string,\n> = {\n readonly first: () => Effect.Effect<\n Option.Option<TableInfo_[\"document\"]>,\n Document.DocumentDecodeError\n >;\n readonly take: (\n n: number,\n ) => Effect.Effect<\n ReadonlyArray<TableInfo_[\"document\"]>,\n Document.DocumentDecodeError\n >;\n readonly collect: () => Effect.Effect<\n ReadonlyArray<TableInfo_[\"document\"]>,\n Document.DocumentDecodeError\n >;\n readonly stream: () => Stream.Stream<\n TableInfo_[\"document\"],\n Document.DocumentDecodeError\n >;\n readonly paginate: (options: {\n cursor: string | null;\n numItems: number;\n }) => Effect.Effect<\n PaginationResult<TableInfo_[\"document\"]>,\n Document.DocumentDecodeError\n >;\n};\n\nexport const make = <\n TableInfo_ extends TableInfo.AnyWithProps,\n TableName extends string,\n>(\n query: ConvexOrderedQuery<TableInfo.ConvexTableInfo<TableInfo_>>,\n tableName: TableName,\n tableSchema: TableInfo.TableSchema<TableInfo_>,\n): OrderedQuery<TableInfo_, TableName> => {\n type OrderedQueryFunction<\n FunctionName extends keyof OrderedQuery<TableInfo_, TableName>,\n > = OrderedQuery<TableInfo_, TableName>[FunctionName];\n\n const streamEncoded = Stream.fromAsyncIterable(query, identity).pipe(\n Stream.orDie,\n );\n\n const stream: OrderedQueryFunction<\"stream\"> = () =>\n pipe(\n streamEncoded,\n Stream.mapEffect(Document.decode(tableName, tableSchema)),\n );\n\n const first: OrderedQueryFunction<\"first\"> = () =>\n pipe(stream(), Stream.take(1), Stream.runHead);\n\n const take: OrderedQueryFunction<\"take\"> = (n: number) =>\n pipe(\n stream(),\n Stream.take(n),\n Stream.runCollect,\n Effect.map((chunk) => Chunk.toReadonlyArray(chunk)),\n );\n\n const collect: OrderedQueryFunction<\"collect\"> = () =>\n pipe(stream(), Stream.runCollect, Effect.map(Chunk.toReadonlyArray));\n\n const paginate: OrderedQueryFunction<\"paginate\"> = (options) =>\n Effect.gen(function* () {\n const paginationResult = yield* Effect.promise(() =>\n query.paginate(options),\n );\n\n const parsedPage = yield* Effect.forEach(\n paginationResult.page,\n Document.decode(tableName, tableSchema),\n );\n\n return {\n page: parsedPage,\n isDone: paginationResult.isDone,\n continueCursor: paginationResult.continueCursor,\n /* v8 ignore start */\n ...(paginationResult.splitCursor\n ? { splitCursor: paginationResult.splitCursor }\n : {}),\n ...(paginationResult.pageStatus\n ? { pageStatus: paginationResult.pageStatus }\n : {}),\n /* v8 ignore stop */\n };\n });\n\n return {\n first,\n take,\n collect,\n paginate,\n stream,\n };\n};\n"],"mappings":";;;;;;AAuCA,MAAa,QAIX,OACA,WACA,gBACwC;CAKxC,MAAM,gBAAgB,OAAO,kBAAkB,OAAO,SAAS,CAAC,KAC9D,OAAO,MACR;CAED,MAAM,eACJ,KACE,eACA,OAAO,UAAUA,OAAgB,WAAW,YAAY,CAAC,CAC1D;CAEH,MAAM,cACJ,KAAK,QAAQ,EAAE,OAAO,KAAK,EAAE,EAAE,OAAO,QAAQ;CAEhD,MAAM,QAAsC,MAC1C,KACE,QAAQ,EACR,OAAO,KAAK,EAAE,EACd,OAAO,YACP,OAAO,KAAK,UAAU,MAAM,gBAAgB,MAAM,CAAC,CACpD;CAEH,MAAM,gBACJ,KAAK,QAAQ,EAAE,OAAO,YAAY,OAAO,IAAI,MAAM,gBAAgB,CAAC;CAEtE,MAAM,YAA8C,YAClD,OAAO,IAAI,aAAa;EACtB,MAAM,mBAAmB,OAAO,OAAO,cACrC,MAAM,SAAS,QAAQ,CACxB;AAOD,SAAO;GACL,MANiB,OAAO,OAAO,QAC/B,iBAAiB,MACjBA,OAAgB,WAAW,YAAY,CACxC;GAIC,QAAQ,iBAAiB;GACzB,gBAAgB,iBAAiB;GAEjC,GAAI,iBAAiB,cACjB,EAAE,aAAa,iBAAiB,aAAa,GAC7C,EAAE;GACN,GAAI,iBAAiB,aACjB,EAAE,YAAY,iBAAiB,YAAY,GAC3C,EAAE;GAEP;GACD;AAEJ,QAAO;EACL;EACA;EACA;EACA;EACA;EACD"}
|
package/dist/QueryCtx.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryCtx.d.ts","names":[],"sources":["../src/QueryCtx.ts"],"
|
|
1
|
+
{"version":3,"file":"QueryCtx.d.ts","names":[],"sources":["../src/QueryCtx.ts"],"mappings":";;;;;;;cAGa,QAAA,qBAA8B,gBAAA,OAAgB,OAAA,CAAA,GAAA,CAAA,eAAA,CAAA,SAAA,GAAA,eAAA,CAAA,SAAA;AAAA,KAG/C,QAAA,mBAA2B,gBAAA,IAAoB,UAAA,QAClD,QAAA,CAAS,SAAA"}
|
package/dist/QueryCtx.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { Context } from "effect";
|
|
3
3
|
|
|
4
4
|
//#region src/QueryCtx.ts
|
|
5
|
-
var QueryCtx_exports = /* @__PURE__ */
|
|
5
|
+
var QueryCtx_exports = /* @__PURE__ */ __exportAll({ QueryCtx: () => QueryCtx });
|
|
6
6
|
const QueryCtx = () => Context.GenericTag("@confect/server/QueryCtx");
|
|
7
7
|
|
|
8
8
|
//#endregion
|
|
@@ -24,7 +24,7 @@ type QueryInitializer<DataModel_ extends AnyWithProps$2, TableName extends Table
|
|
|
24
24
|
readonly search: <IndexName extends keyof SearchIndexes<_ConvexTableInfo>>(indexName: IndexName, searchFilter: (q: SearchFilterBuilder<DocumentByInfo<_ConvexTableInfo>, NamedSearchIndex<_ConvexTableInfo, IndexName>>) => SearchFilter) => OrderedQuery$1<_TableInfo, TableName>;
|
|
25
25
|
};
|
|
26
26
|
declare const make: <Tables extends AnyWithProps, TableName extends Name<Tables>>(tableName: TableName, convexDatabaseReader: BaseDatabaseReader<ToConvex<FromTables<Tables>>>, table: WithName<Tables, TableName>) => QueryInitializer<DataModel<Tables>, TableName, TableInfoWithName<DataModel<Tables>, TableName>, TableInfoWithName_<DataModel<Tables>, TableName>>;
|
|
27
|
-
declare const getById: <Tables extends AnyWithProps, TableName extends Name<Tables>>(tableName: TableName, convexDatabaseReader: BaseDatabaseReader<ToConvex<FromTables<Tables>>>, table: WithName<Tables, TableName>) => (id: GenericId<TableName>) => Effect.Effect<any,
|
|
27
|
+
declare const getById: <Tables extends AnyWithProps, TableName extends Name<Tables>>(tableName: TableName, convexDatabaseReader: BaseDatabaseReader<ToConvex<FromTables<Tables>>>, table: WithName<Tables, TableName>) => (id: GenericId<TableName>) => Effect.Effect<any, DocumentDecodeError | GetByIdFailure, never>;
|
|
28
28
|
declare const GetByIdFailure_base: Schema.TaggedErrorClass<GetByIdFailure, "GetByIdFailure", {
|
|
29
29
|
readonly _tag: Schema.tag<"GetByIdFailure">;
|
|
30
30
|
} & {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryInitializer.d.ts","names":[],"sources":["../src/QueryInitializer.ts"],"
|
|
1
|
+
{"version":3,"file":"QueryInitializer.d.ts","names":[],"sources":["../src/QueryInitializer.ts"],"mappings":";;;;;;;;;;;;;;KA6BK,gBAAA,oBACgB,cAAA,oBACD,UAAA,CAAqB,UAAA,4BACd,gBAAA,qBACN,cAAA;EAAA,SAEV,GAAA;IAAA,CAEL,EAAA,EAAI,SAAA,CAAU,SAAA,IACb,MAAA,CAAO,MAAA,CACR,UAAA,cACA,mBAAA,GAA+B,cAAA;IAAA,yBAER,OAAA,CAAQ,gBAAA,GAC/B,SAAA,EAAW,SAAA,KACR,gBAAA,EAAkB,oBAAA,CACnB,QAAA,CAAmB,UAAA,GACnB,SAAA,EACA,OAAA,CAAQ,gBAAA,EAAkB,SAAA,KAE3B,MAAA,CAAO,MAAA,CACR,UAAA,cACA,mBAAA,GAA+B,iBAAA;EAAA;EAAA,SAG1B,KAAA;IAAA,yBACkB,OAAA,CAAQ,gBAAA,GAC/B,SAAA,EAAW,SAAA,EACX,UAAA,IACE,CAAA,EAAG,iBAAA,CACD,UAAA,oBACA,UAAA,CAAW,gBAAA,EAAkB,SAAA,OAE5B,UAAA,EACL,KAAA,oBACC,cAAA,CAA0B,UAAA,EAAY,SAAA;IAAA,yBAChB,OAAA,CAAQ,gBAAA,GAC/B,SAAA,EAAW,SAAA,EACX,KAAA,oBACC,cAAA,CAA0B,UAAA,EAAY,SAAA;EAAA;EAAA,SAElC,MAAA,2BAAiC,aAAA,CAAc,gBAAA,GACtD,SAAA,EAAW,SAAA,EACX,YAAA,GACE,CAAA,EAAG,mBAAA,CACD,cAAA,CAAe,gBAAA,GACf,gBAAA,CAAiB,gBAAA,EAAkB,SAAA,OAElC,YAAA,KACF,cAAA,CAA0B,UAAA,EAAY,SAAA;AAAA;AAAA,cAGhC,IAAA,kBACI,YAAA,oBACG,IAAA,CAAW,MAAA,GAE7B,SAAA,EAAW,SAAA,EACX,oBAAA,EAAsB,kBAAA,CACpB,QAAA,CAAmB,UAAA,CAAqB,MAAA,KAE1C,KAAA,EAAO,QAAA,CAAe,MAAA,EAAQ,SAAA,MAC7B,gBAAA,CACD,SAAA,CAAoB,MAAA,GACpB,SAAA,EACA,iBAAA,CAA4B,SAAA,CAAoB,MAAA,GAAS,SAAA,GACzD,kBAAA,CAA6B,SAAA,CAAoB,MAAA,GAAS,SAAA;AAAA,cA2K/C,OAAA,kBACK,YAAA,oBAAsC,IAAA,CAAW,MAAA,GAC/D,SAAA,EAAW,SAAA,EACX,oBAAA,EAAsB,kBAAA,CACpB,QAAA,CAAmB,UAAA,CAAqB,MAAA,KAE1C,KAAA,EAAO,QAAA,CAAe,MAAA,EAAQ,SAAA,OAE/B,EAAA,EAAI,SAAA,CAAU,SAAA,MAAU,MAAA,CAAA,MAAA,MAAA,mBAAA,GAAA,cAAA;AAAA,cAOrB,mBAAA;;;;;;cAEO,cAAA,SAAuB,mBAAA;EAAA,IAMrB,OAAA,CAAA;AAAA;AAAA,cAOd,sBAAA;;;;;;;cAEY,iBAAA,SAA0B,sBAAA;EAAA,IAOxB,OAAA,CAAA;AAAA"}
|
package/dist/QueryInitializer.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { decode, documentErrorMessage } from "./Document.js";
|
|
3
3
|
import { make as make$1 } from "./OrderedQuery.js";
|
|
4
4
|
import { Array, Effect, Either, Schema, pipe } from "effect";
|
|
5
5
|
|
|
6
6
|
//#region src/QueryInitializer.ts
|
|
7
|
-
var QueryInitializer_exports = /* @__PURE__ */
|
|
7
|
+
var QueryInitializer_exports = /* @__PURE__ */ __exportAll({
|
|
8
8
|
GetByIdFailure: () => GetByIdFailure,
|
|
9
9
|
GetByIndexFailure: () => GetByIndexFailure,
|
|
10
10
|
getById: () => getById,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryInitializer.js","names":["indexFields: GenericTableIndexes[keyof GenericTableIndexes]","Document.decode","get: QueryInitializerFunction<\"get\">","index: QueryInitializerFunction<\"index\">","OrderedQuery.make","search: QueryInitializerFunction<\"search\">","Document.documentErrorMessage"],"sources":["../src/QueryInitializer.ts"],"sourcesContent":["import type {\n OrderedQuery as ConvexOrderedQuery,\n QueryInitializer as ConvexQueryInitializer,\n DocumentByInfo,\n GenericTableIndexes,\n GenericTableInfo,\n Indexes,\n IndexRange,\n IndexRangeBuilder,\n NamedIndex,\n NamedSearchIndex,\n NamedTableInfo,\n Query,\n SearchFilter,\n SearchFilterBuilder,\n SearchIndexes,\n} from \"convex/server\";\nimport type { GenericId } from \"convex/values\";\nimport { Array, Effect, Either, pipe, Schema } from \"effect\";\nimport type {\n BaseDatabaseReader,\n IndexFieldTypesForEq,\n} from \"@confect/core/Types\";\nimport type * as DataModel from \"./DataModel\";\nimport * as Document from \"./Document\";\nimport * as OrderedQuery from \"./OrderedQuery\";\nimport type * as Table from \"./Table\";\nimport type * as TableInfo from \"./TableInfo\";\n\ntype QueryInitializer<\n DataModel_ extends DataModel.AnyWithProps,\n TableName extends DataModel.TableNames<DataModel_>,\n _ConvexTableInfo extends GenericTableInfo,\n _TableInfo extends TableInfo.AnyWithProps,\n> = {\n readonly get: {\n (\n id: GenericId<TableName>,\n ): Effect.Effect<\n _TableInfo[\"document\"],\n Document.DocumentDecodeError | GetByIdFailure\n >;\n <IndexName extends keyof Indexes<_ConvexTableInfo>>(\n indexName: IndexName,\n ...indexFieldValues: IndexFieldTypesForEq<\n DataModel.ToConvex<DataModel_>,\n TableName,\n Indexes<_ConvexTableInfo>[IndexName]\n >\n ): Effect.Effect<\n _TableInfo[\"document\"],\n Document.DocumentDecodeError | GetByIndexFailure\n >;\n };\n readonly index: {\n <IndexName extends keyof Indexes<_ConvexTableInfo>>(\n indexName: IndexName,\n indexRange?: (\n q: IndexRangeBuilder<\n _TableInfo[\"convexDocument\"],\n NamedIndex<_ConvexTableInfo, IndexName>\n >,\n ) => IndexRange,\n order?: \"asc\" | \"desc\",\n ): OrderedQuery.OrderedQuery<_TableInfo, TableName>;\n <IndexName extends keyof Indexes<_ConvexTableInfo>>(\n indexName: IndexName,\n order?: \"asc\" | \"desc\",\n ): OrderedQuery.OrderedQuery<_TableInfo, TableName>;\n };\n readonly search: <IndexName extends keyof SearchIndexes<_ConvexTableInfo>>(\n indexName: IndexName,\n searchFilter: (\n q: SearchFilterBuilder<\n DocumentByInfo<_ConvexTableInfo>,\n NamedSearchIndex<_ConvexTableInfo, IndexName>\n >,\n ) => SearchFilter,\n ) => OrderedQuery.OrderedQuery<_TableInfo, TableName>;\n};\n\nexport const make = <\n Tables extends Table.AnyWithProps,\n TableName extends Table.Name<Tables>,\n>(\n tableName: TableName,\n convexDatabaseReader: BaseDatabaseReader<\n DataModel.ToConvex<DataModel.FromTables<Tables>>\n >,\n table: Table.WithName<Tables, TableName>,\n): QueryInitializer<\n DataModel.DataModel<Tables>,\n TableName,\n DataModel.TableInfoWithName<DataModel.DataModel<Tables>, TableName>,\n DataModel.TableInfoWithName_<DataModel.DataModel<Tables>, TableName>\n> => {\n type DataModel_ = DataModel.DataModel<Tables>;\n type ConvexDataModel_ = DataModel.ToConvex<DataModel_>;\n type ThisQueryInitializer = QueryInitializer<\n DataModel_,\n TableName,\n DataModel.TableInfoWithName<DataModel_, TableName>,\n DataModel.TableInfoWithName_<DataModel_, TableName>\n >;\n type QueryInitializerFunction<\n FunctionName extends keyof ThisQueryInitializer,\n > = ThisQueryInitializer[FunctionName];\n\n const getByIndex = <\n IndexName extends keyof Indexes<\n DataModel.TableInfoWithName<DataModel_, TableName>\n >,\n >(\n indexName: IndexName,\n indexFieldValues: IndexFieldTypesForEq<\n DataModel.ToConvex<DataModel_>,\n TableName,\n Indexes<DataModel.TableInfoWithName<DataModel_, TableName>>[IndexName]\n >,\n ): Effect.Effect<\n DataModel.DocumentWithName<DataModel_, TableName>,\n Document.DocumentDecodeError | GetByIndexFailure\n > => {\n const indexFields: GenericTableIndexes[keyof GenericTableIndexes] = (\n table.indexes as GenericTableIndexes\n )[indexName as keyof GenericTableIndexes]!;\n\n return pipe(\n Effect.promise(() =>\n convexDatabaseReader\n .query(tableName)\n .withIndex(indexName, (q) =>\n Array.reduce(\n indexFieldValues,\n q,\n (q_, v, i) => q_.eq(indexFields[i] as any, v as any) as any,\n ),\n )\n .unique(),\n ),\n Effect.andThen(\n Either.fromNullable(\n () =>\n new GetByIndexFailure({\n tableName,\n indexName: indexName as string,\n indexFieldValues: indexFieldValues as string[],\n }),\n ),\n ),\n Effect.andThen(Document.decode(tableName, table.Fields)),\n );\n };\n\n const get: QueryInitializerFunction<\"get\"> = ((\n ...args: Parameters<QueryInitializerFunction<\"get\">>\n ) => {\n if (args.length === 1) {\n const id = args[0] as GenericId<TableName>;\n\n return getById(tableName, convexDatabaseReader, table)(id);\n } else {\n const [indexName, ...indexFieldValues] = args;\n\n return getByIndex(\n indexName as keyof Indexes<\n DataModel.TableInfoWithName<DataModel_, TableName>\n >,\n indexFieldValues,\n );\n }\n }) as QueryInitializerFunction<\"get\">;\n\n const index: QueryInitializerFunction<\"index\"> = <\n IndexName extends keyof Indexes<\n DataModel.TableInfoWithName<DataModel_, TableName>\n >,\n >(\n indexName: IndexName,\n indexRangeOrOrder?:\n | ((\n q: IndexRangeBuilder<\n DataModel.TableInfoWithName_<\n DataModel_,\n TableName\n >[\"convexDocument\"],\n NamedIndex<\n DataModel.TableInfoWithName<DataModel_, TableName>,\n IndexName\n >\n >,\n ) => IndexRange)\n | \"asc\"\n | \"desc\",\n order?: \"asc\" | \"desc\",\n ) => {\n const {\n applyWithIndex,\n applyOrder,\n }: {\n applyWithIndex: (\n queryInitializer: ConvexQueryInitializer<\n NamedTableInfo<ConvexDataModel_, TableName>\n >,\n ) => Query<NamedTableInfo<ConvexDataModel_, TableName>>;\n applyOrder: (\n query: Query<NamedTableInfo<ConvexDataModel_, TableName>>,\n ) => ConvexOrderedQuery<NamedTableInfo<ConvexDataModel_, TableName>>;\n } =\n indexRangeOrOrder === undefined\n ? {\n applyWithIndex: (q) => q.withIndex(indexName),\n applyOrder: (q) => q.order(\"asc\"),\n }\n : typeof indexRangeOrOrder === \"function\"\n ? order === undefined\n ? {\n applyWithIndex: (q) =>\n q.withIndex(indexName, indexRangeOrOrder),\n applyOrder: (q) => q.order(\"asc\"),\n }\n : {\n applyWithIndex: (q) =>\n q.withIndex(indexName, indexRangeOrOrder),\n applyOrder: (q) => q.order(order),\n }\n : {\n applyWithIndex: (q) => q.withIndex(indexName),\n applyOrder: (q) => q.order(indexRangeOrOrder),\n };\n\n const orderedQuery = pipe(\n convexDatabaseReader.query(tableName),\n applyWithIndex,\n applyOrder,\n );\n\n return OrderedQuery.make<\n DataModel.TableInfoWithName_<DataModel_, TableName>,\n TableName\n >(orderedQuery, tableName, table.Fields);\n };\n\n const search: QueryInitializerFunction<\"search\"> = (\n indexName,\n searchFilter,\n ) =>\n OrderedQuery.make<\n DataModel.TableInfoWithName_<DataModel_, TableName>,\n TableName\n >(\n convexDatabaseReader\n .query(tableName)\n .withSearchIndex(indexName, searchFilter),\n tableName,\n table.Fields,\n );\n\n return {\n get,\n index,\n search,\n };\n};\n\nexport const getById =\n <Tables extends Table.AnyWithProps, TableName extends Table.Name<Tables>>(\n tableName: TableName,\n convexDatabaseReader: BaseDatabaseReader<\n DataModel.ToConvex<DataModel.FromTables<Tables>>\n >,\n table: Table.WithName<Tables, TableName>,\n ) =>\n (id: GenericId<TableName>) =>\n pipe(\n Effect.promise(() => convexDatabaseReader.get(id)),\n Effect.andThen(\n Either.fromNullable(() => new GetByIdFailure({ tableName, id })),\n ),\n Effect.andThen(Document.decode(tableName, table.Fields)),\n );\n\nexport class GetByIdFailure extends Schema.TaggedError<GetByIdFailure>(\n \"GetByIdFailure\",\n)(\"GetByIdFailure\", {\n id: Schema.String,\n tableName: Schema.String,\n}) {\n override get message(): string {\n return Document.documentErrorMessage({\n id: this.id,\n tableName: this.tableName,\n message: \"not found\",\n });\n }\n}\n\nexport class GetByIndexFailure extends Schema.TaggedError<GetByIndexFailure>(\n \"GetByIndexFailure\",\n)(\"GetByIndexFailure\", {\n tableName: Schema.String,\n indexName: Schema.String,\n indexFieldValues: Schema.Array(Schema.String),\n}) {\n override get message(): string {\n return `No documents found in table '${this.tableName}' with index '${this.indexName}' and field values '${this.indexFieldValues}'`;\n }\n}\n"],"mappings":";;;;;;;;;;;;AAiFA,MAAa,QAIX,WACA,sBAGA,UAMG;CAaH,MAAM,cAKJ,WACA,qBAQG;EACH,MAAMA,cACJ,MAAM,QACN;AAEF,SAAO,KACL,OAAO,cACL,qBACG,MAAM,UAAU,CAChB,UAAU,YAAY,MACrB,MAAM,OACJ,kBACA,IACC,IAAI,GAAG,MAAM,GAAG,GAAG,YAAY,IAAW,EAAS,CACrD,CACF,CACA,QAAQ,CACZ,EACD,OAAO,QACL,OAAO,mBAEH,IAAI,kBAAkB;GACpB;GACW;GACO;GACnB,CAAC,CACL,CACF,EACD,OAAO,QAAQC,OAAgB,WAAW,MAAM,OAAO,CAAC,CACzD;;CAGH,MAAMC,QACJ,GAAG,SACA;AACH,MAAI,KAAK,WAAW,GAAG;GACrB,MAAM,KAAK,KAAK;AAEhB,UAAO,QAAQ,WAAW,sBAAsB,MAAM,CAAC,GAAG;SACrD;GACL,MAAM,CAAC,WAAW,GAAG,oBAAoB;AAEzC,UAAO,WACL,WAGA,iBACD;;;CAIL,MAAMC,SAKJ,WACA,mBAeA,UACG;EACH,MAAM,EACJ,gBACA,eAWA,sBAAsB,SAClB;GACE,iBAAiB,MAAM,EAAE,UAAU,UAAU;GAC7C,aAAa,MAAM,EAAE,MAAM,MAAM;GAClC,GACD,OAAO,sBAAsB,aAC3B,UAAU,SACR;GACE,iBAAiB,MACf,EAAE,UAAU,WAAW,kBAAkB;GAC3C,aAAa,MAAM,EAAE,MAAM,MAAM;GAClC,GACD;GACE,iBAAiB,MACf,EAAE,UAAU,WAAW,kBAAkB;GAC3C,aAAa,MAAM,EAAE,MAAM,MAAM;GAClC,GACH;GACE,iBAAiB,MAAM,EAAE,UAAU,UAAU;GAC7C,aAAa,MAAM,EAAE,MAAM,kBAAkB;GAC9C;EAET,MAAM,eAAe,KACnB,qBAAqB,MAAM,UAAU,EACrC,gBACA,WACD;AAED,SAAOC,OAGL,cAAc,WAAW,MAAM,OAAO;;CAG1C,MAAMC,UACJ,WACA,iBAEAD,OAIE,qBACG,MAAM,UAAU,CAChB,gBAAgB,WAAW,aAAa,EAC3C,WACA,MAAM,OACP;AAEH,QAAO;EACL;EACA;EACA;EACD;;AAGH,MAAa,WAET,WACA,sBAGA,WAED,OACC,KACE,OAAO,cAAc,qBAAqB,IAAI,GAAG,CAAC,EAClD,OAAO,QACL,OAAO,mBAAmB,IAAI,eAAe;CAAE;CAAW;CAAI,CAAC,CAAC,CACjE,EACD,OAAO,QAAQH,OAAgB,WAAW,MAAM,OAAO,CAAC,CACzD;AAEL,IAAa,iBAAb,cAAoC,OAAO,YACzC,iBACD,CAAC,kBAAkB;CAClB,IAAI,OAAO;CACX,WAAW,OAAO;CACnB,CAAC,CAAC;CACD,IAAa,UAAkB;AAC7B,SAAOK,qBAA8B;GACnC,IAAI,KAAK;GACT,WAAW,KAAK;GAChB,SAAS;GACV,CAAC;;;AAIN,IAAa,oBAAb,cAAuC,OAAO,YAC5C,oBACD,CAAC,qBAAqB;CACrB,WAAW,OAAO;CAClB,WAAW,OAAO;CAClB,kBAAkB,OAAO,MAAM,OAAO,OAAO;CAC9C,CAAC,CAAC;CACD,IAAa,UAAkB;AAC7B,SAAO,gCAAgC,KAAK,UAAU,gBAAgB,KAAK,UAAU,sBAAsB,KAAK,iBAAiB"}
|
|
1
|
+
{"version":3,"file":"QueryInitializer.js","names":["Document.decode","OrderedQuery.make","Document.documentErrorMessage"],"sources":["../src/QueryInitializer.ts"],"sourcesContent":["import type {\n OrderedQuery as ConvexOrderedQuery,\n QueryInitializer as ConvexQueryInitializer,\n DocumentByInfo,\n GenericTableIndexes,\n GenericTableInfo,\n Indexes,\n IndexRange,\n IndexRangeBuilder,\n NamedIndex,\n NamedSearchIndex,\n NamedTableInfo,\n Query,\n SearchFilter,\n SearchFilterBuilder,\n SearchIndexes,\n} from \"convex/server\";\nimport type { GenericId } from \"convex/values\";\nimport { Array, Effect, Either, pipe, Schema } from \"effect\";\nimport type {\n BaseDatabaseReader,\n IndexFieldTypesForEq,\n} from \"@confect/core/Types\";\nimport type * as DataModel from \"./DataModel\";\nimport * as Document from \"./Document\";\nimport * as OrderedQuery from \"./OrderedQuery\";\nimport type * as Table from \"./Table\";\nimport type * as TableInfo from \"./TableInfo\";\n\ntype QueryInitializer<\n DataModel_ extends DataModel.AnyWithProps,\n TableName extends DataModel.TableNames<DataModel_>,\n _ConvexTableInfo extends GenericTableInfo,\n _TableInfo extends TableInfo.AnyWithProps,\n> = {\n readonly get: {\n (\n id: GenericId<TableName>,\n ): Effect.Effect<\n _TableInfo[\"document\"],\n Document.DocumentDecodeError | GetByIdFailure\n >;\n <IndexName extends keyof Indexes<_ConvexTableInfo>>(\n indexName: IndexName,\n ...indexFieldValues: IndexFieldTypesForEq<\n DataModel.ToConvex<DataModel_>,\n TableName,\n Indexes<_ConvexTableInfo>[IndexName]\n >\n ): Effect.Effect<\n _TableInfo[\"document\"],\n Document.DocumentDecodeError | GetByIndexFailure\n >;\n };\n readonly index: {\n <IndexName extends keyof Indexes<_ConvexTableInfo>>(\n indexName: IndexName,\n indexRange?: (\n q: IndexRangeBuilder<\n _TableInfo[\"convexDocument\"],\n NamedIndex<_ConvexTableInfo, IndexName>\n >,\n ) => IndexRange,\n order?: \"asc\" | \"desc\",\n ): OrderedQuery.OrderedQuery<_TableInfo, TableName>;\n <IndexName extends keyof Indexes<_ConvexTableInfo>>(\n indexName: IndexName,\n order?: \"asc\" | \"desc\",\n ): OrderedQuery.OrderedQuery<_TableInfo, TableName>;\n };\n readonly search: <IndexName extends keyof SearchIndexes<_ConvexTableInfo>>(\n indexName: IndexName,\n searchFilter: (\n q: SearchFilterBuilder<\n DocumentByInfo<_ConvexTableInfo>,\n NamedSearchIndex<_ConvexTableInfo, IndexName>\n >,\n ) => SearchFilter,\n ) => OrderedQuery.OrderedQuery<_TableInfo, TableName>;\n};\n\nexport const make = <\n Tables extends Table.AnyWithProps,\n TableName extends Table.Name<Tables>,\n>(\n tableName: TableName,\n convexDatabaseReader: BaseDatabaseReader<\n DataModel.ToConvex<DataModel.FromTables<Tables>>\n >,\n table: Table.WithName<Tables, TableName>,\n): QueryInitializer<\n DataModel.DataModel<Tables>,\n TableName,\n DataModel.TableInfoWithName<DataModel.DataModel<Tables>, TableName>,\n DataModel.TableInfoWithName_<DataModel.DataModel<Tables>, TableName>\n> => {\n type DataModel_ = DataModel.DataModel<Tables>;\n type ConvexDataModel_ = DataModel.ToConvex<DataModel_>;\n type ThisQueryInitializer = QueryInitializer<\n DataModel_,\n TableName,\n DataModel.TableInfoWithName<DataModel_, TableName>,\n DataModel.TableInfoWithName_<DataModel_, TableName>\n >;\n type QueryInitializerFunction<\n FunctionName extends keyof ThisQueryInitializer,\n > = ThisQueryInitializer[FunctionName];\n\n const getByIndex = <\n IndexName extends keyof Indexes<\n DataModel.TableInfoWithName<DataModel_, TableName>\n >,\n >(\n indexName: IndexName,\n indexFieldValues: IndexFieldTypesForEq<\n DataModel.ToConvex<DataModel_>,\n TableName,\n Indexes<DataModel.TableInfoWithName<DataModel_, TableName>>[IndexName]\n >,\n ): Effect.Effect<\n DataModel.DocumentWithName<DataModel_, TableName>,\n Document.DocumentDecodeError | GetByIndexFailure\n > => {\n const indexFields: GenericTableIndexes[keyof GenericTableIndexes] = (\n table.indexes as GenericTableIndexes\n )[indexName as keyof GenericTableIndexes]!;\n\n return pipe(\n Effect.promise(() =>\n convexDatabaseReader\n .query(tableName)\n .withIndex(indexName, (q) =>\n Array.reduce(\n indexFieldValues,\n q,\n (q_, v, i) => q_.eq(indexFields[i] as any, v as any) as any,\n ),\n )\n .unique(),\n ),\n Effect.andThen(\n Either.fromNullable(\n () =>\n new GetByIndexFailure({\n tableName,\n indexName: indexName as string,\n indexFieldValues: indexFieldValues as string[],\n }),\n ),\n ),\n Effect.andThen(Document.decode(tableName, table.Fields)),\n );\n };\n\n const get: QueryInitializerFunction<\"get\"> = ((\n ...args: Parameters<QueryInitializerFunction<\"get\">>\n ) => {\n if (args.length === 1) {\n const id = args[0] as GenericId<TableName>;\n\n return getById(tableName, convexDatabaseReader, table)(id);\n } else {\n const [indexName, ...indexFieldValues] = args;\n\n return getByIndex(\n indexName as keyof Indexes<\n DataModel.TableInfoWithName<DataModel_, TableName>\n >,\n indexFieldValues,\n );\n }\n }) as QueryInitializerFunction<\"get\">;\n\n const index: QueryInitializerFunction<\"index\"> = <\n IndexName extends keyof Indexes<\n DataModel.TableInfoWithName<DataModel_, TableName>\n >,\n >(\n indexName: IndexName,\n indexRangeOrOrder?:\n | ((\n q: IndexRangeBuilder<\n DataModel.TableInfoWithName_<\n DataModel_,\n TableName\n >[\"convexDocument\"],\n NamedIndex<\n DataModel.TableInfoWithName<DataModel_, TableName>,\n IndexName\n >\n >,\n ) => IndexRange)\n | \"asc\"\n | \"desc\",\n order?: \"asc\" | \"desc\",\n ) => {\n const {\n applyWithIndex,\n applyOrder,\n }: {\n applyWithIndex: (\n queryInitializer: ConvexQueryInitializer<\n NamedTableInfo<ConvexDataModel_, TableName>\n >,\n ) => Query<NamedTableInfo<ConvexDataModel_, TableName>>;\n applyOrder: (\n query: Query<NamedTableInfo<ConvexDataModel_, TableName>>,\n ) => ConvexOrderedQuery<NamedTableInfo<ConvexDataModel_, TableName>>;\n } =\n indexRangeOrOrder === undefined\n ? {\n applyWithIndex: (q) => q.withIndex(indexName),\n applyOrder: (q) => q.order(\"asc\"),\n }\n : typeof indexRangeOrOrder === \"function\"\n ? order === undefined\n ? {\n applyWithIndex: (q) =>\n q.withIndex(indexName, indexRangeOrOrder),\n applyOrder: (q) => q.order(\"asc\"),\n }\n : {\n applyWithIndex: (q) =>\n q.withIndex(indexName, indexRangeOrOrder),\n applyOrder: (q) => q.order(order),\n }\n : {\n applyWithIndex: (q) => q.withIndex(indexName),\n applyOrder: (q) => q.order(indexRangeOrOrder),\n };\n\n const orderedQuery = pipe(\n convexDatabaseReader.query(tableName),\n applyWithIndex,\n applyOrder,\n );\n\n return OrderedQuery.make<\n DataModel.TableInfoWithName_<DataModel_, TableName>,\n TableName\n >(orderedQuery, tableName, table.Fields);\n };\n\n const search: QueryInitializerFunction<\"search\"> = (\n indexName,\n searchFilter,\n ) =>\n OrderedQuery.make<\n DataModel.TableInfoWithName_<DataModel_, TableName>,\n TableName\n >(\n convexDatabaseReader\n .query(tableName)\n .withSearchIndex(indexName, searchFilter),\n tableName,\n table.Fields,\n );\n\n return {\n get,\n index,\n search,\n };\n};\n\nexport const getById =\n <Tables extends Table.AnyWithProps, TableName extends Table.Name<Tables>>(\n tableName: TableName,\n convexDatabaseReader: BaseDatabaseReader<\n DataModel.ToConvex<DataModel.FromTables<Tables>>\n >,\n table: Table.WithName<Tables, TableName>,\n ) =>\n (id: GenericId<TableName>) =>\n pipe(\n Effect.promise(() => convexDatabaseReader.get(id)),\n Effect.andThen(\n Either.fromNullable(() => new GetByIdFailure({ tableName, id })),\n ),\n Effect.andThen(Document.decode(tableName, table.Fields)),\n );\n\nexport class GetByIdFailure extends Schema.TaggedError<GetByIdFailure>(\n \"GetByIdFailure\",\n)(\"GetByIdFailure\", {\n id: Schema.String,\n tableName: Schema.String,\n}) {\n override get message(): string {\n return Document.documentErrorMessage({\n id: this.id,\n tableName: this.tableName,\n message: \"not found\",\n });\n }\n}\n\nexport class GetByIndexFailure extends Schema.TaggedError<GetByIndexFailure>(\n \"GetByIndexFailure\",\n)(\"GetByIndexFailure\", {\n tableName: Schema.String,\n indexName: Schema.String,\n indexFieldValues: Schema.Array(Schema.String),\n}) {\n override get message(): string {\n return `No documents found in table '${this.tableName}' with index '${this.indexName}' and field values '${this.indexFieldValues}'`;\n }\n}\n"],"mappings":";;;;;;;;;;;;AAiFA,MAAa,QAIX,WACA,sBAGA,UAMG;CAaH,MAAM,cAKJ,WACA,qBAQG;EACH,MAAM,cACJ,MAAM,QACN;AAEF,SAAO,KACL,OAAO,cACL,qBACG,MAAM,UAAU,CAChB,UAAU,YAAY,MACrB,MAAM,OACJ,kBACA,IACC,IAAI,GAAG,MAAM,GAAG,GAAG,YAAY,IAAW,EAAS,CACrD,CACF,CACA,QAAQ,CACZ,EACD,OAAO,QACL,OAAO,mBAEH,IAAI,kBAAkB;GACpB;GACW;GACO;GACnB,CAAC,CACL,CACF,EACD,OAAO,QAAQA,OAAgB,WAAW,MAAM,OAAO,CAAC,CACzD;;CAGH,MAAM,QACJ,GAAG,SACA;AACH,MAAI,KAAK,WAAW,GAAG;GACrB,MAAM,KAAK,KAAK;AAEhB,UAAO,QAAQ,WAAW,sBAAsB,MAAM,CAAC,GAAG;SACrD;GACL,MAAM,CAAC,WAAW,GAAG,oBAAoB;AAEzC,UAAO,WACL,WAGA,iBACD;;;CAIL,MAAM,SAKJ,WACA,mBAeA,UACG;EACH,MAAM,EACJ,gBACA,eAWA,sBAAsB,SAClB;GACE,iBAAiB,MAAM,EAAE,UAAU,UAAU;GAC7C,aAAa,MAAM,EAAE,MAAM,MAAM;GAClC,GACD,OAAO,sBAAsB,aAC3B,UAAU,SACR;GACE,iBAAiB,MACf,EAAE,UAAU,WAAW,kBAAkB;GAC3C,aAAa,MAAM,EAAE,MAAM,MAAM;GAClC,GACD;GACE,iBAAiB,MACf,EAAE,UAAU,WAAW,kBAAkB;GAC3C,aAAa,MAAM,EAAE,MAAM,MAAM;GAClC,GACH;GACE,iBAAiB,MAAM,EAAE,UAAU,UAAU;GAC7C,aAAa,MAAM,EAAE,MAAM,kBAAkB;GAC9C;EAET,MAAM,eAAe,KACnB,qBAAqB,MAAM,UAAU,EACrC,gBACA,WACD;AAED,SAAOC,OAGL,cAAc,WAAW,MAAM,OAAO;;CAG1C,MAAM,UACJ,WACA,iBAEAA,OAIE,qBACG,MAAM,UAAU,CAChB,gBAAgB,WAAW,aAAa,EAC3C,WACA,MAAM,OACP;AAEH,QAAO;EACL;EACA;EACA;EACD;;AAGH,MAAa,WAET,WACA,sBAGA,WAED,OACC,KACE,OAAO,cAAc,qBAAqB,IAAI,GAAG,CAAC,EAClD,OAAO,QACL,OAAO,mBAAmB,IAAI,eAAe;CAAE;CAAW;CAAI,CAAC,CAAC,CACjE,EACD,OAAO,QAAQD,OAAgB,WAAW,MAAM,OAAO,CAAC,CACzD;AAEL,IAAa,iBAAb,cAAoC,OAAO,YACzC,iBACD,CAAC,kBAAkB;CAClB,IAAI,OAAO;CACX,WAAW,OAAO;CACnB,CAAC,CAAC;CACD,IAAa,UAAkB;AAC7B,SAAOE,qBAA8B;GACnC,IAAI,KAAK;GACT,WAAW,KAAK;GAChB,SAAS;GACV,CAAC;;;AAIN,IAAa,oBAAb,cAAuC,OAAO,YAC5C,oBACD,CAAC,qBAAqB;CACrB,WAAW,OAAO;CAClB,WAAW,OAAO;CAClB,kBAAkB,OAAO,MAAM,OAAO,OAAO;CAC9C,CAAC,CAAC;CACD,IAAa,UAAkB;AAC7B,SAAO,gCAAgC,KAAK,UAAU,gBAAgB,KAAK,UAAU,sBAAsB,KAAK,iBAAiB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"QueryRunner.d.ts","names":[],"sources":["../src/QueryRunner.ts"],"
|
|
1
|
+
{"version":3,"file":"QueryRunner.d.ts","names":[],"sources":["../src/QueryRunner.ts"],"mappings":";;;;;;;;cAsBa,WAAA,EAAW,OAAA,CAAA,GAAA,iBAfP,KAAA,CAAI,QAAA,EAAQ,KAAA,EAClB,KAAA,EAAK,IAAA,EACN,KAAA,CAAI,IAAA,CAAK,KAAA,cACd,MAAA,CAAO,MAAA,CAAO,KAAA,CAAI,OAAA,CAAQ,KAAA,WAAgB,WAAA,CAAY,UAAA,mBAH1C,KAAA,CAAI,QAAA,EAAQ,KAAA,EAClB,KAAA,EAAK,IAAA,EACN,KAAA,CAAI,IAAA,CAAK,KAAA,cACd,MAAA,CAAO,MAAA,CAAO,KAAA,CAAI,OAAA,CAAQ,KAAA,WAAgB,WAAA,CAAY,UAAA;AAAA,KAe/C,WAAA,UAAqB,WAAA,CAAY,UAAA;AAAA,cAEhC,KAAA,GAAS,QAAA,EAAU,eAAA,sBAAgC,KAAA,CAAA,KAAA,iBApB/C,KAAA,CAAI,QAAA,EAAQ,KAAA,EAClB,KAAA,EAAK,IAAA,EACN,KAAA,CAAI,IAAA,CAAK,KAAA,cACd,MAAA,CAAO,MAAA,CAAO,KAAA,CAAI,OAAA,CAAQ,KAAA,WAAgB,WAAA,CAAY,UAAA"}
|
package/dist/QueryRunner.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
2
|
import { Context, Effect, Layer, Schema } from "effect";
|
|
3
3
|
import * as Ref$1 from "@confect/core/Ref";
|
|
4
4
|
import "convex/server";
|
|
5
5
|
|
|
6
6
|
//#region src/QueryRunner.ts
|
|
7
|
-
var QueryRunner_exports = /* @__PURE__ */
|
|
7
|
+
var QueryRunner_exports = /* @__PURE__ */ __exportAll({
|
|
8
8
|
QueryRunner: () => QueryRunner,
|
|
9
9
|
layer: () => layer
|
|
10
10
|
});
|