@confect/server 1.0.0-next.0 → 1.0.0-next.1
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 +7 -0
- package/dist/Auth.d.ts +8 -8
- package/dist/DatabaseReader.d.ts +4 -4
- package/dist/DatabaseReader.d.ts.map +1 -1
- package/dist/DatabaseSchema.d.ts +22 -22
- package/dist/DatabaseWriter.d.ts +4 -4
- package/dist/Impl.d.ts.map +1 -1
- package/dist/MutationRunner.d.ts +3 -3
- package/dist/QueryInitializer.d.ts +1 -1
- package/dist/QueryInitializer.d.ts.map +1 -1
- package/dist/RegisteredFunctions.d.ts +15 -15
- package/dist/RegisteredFunctions.d.ts.map +1 -1
- package/dist/RegisteredFunctions.js.map +1 -1
- package/dist/Scheduler.d.ts +7 -7
- package/dist/Scheduler.d.ts.map +1 -1
- package/dist/SchemaToValidator.d.ts.map +1 -1
- package/dist/SchemaToValidator.js.map +1 -1
- package/dist/Table.d.ts +43 -43
- package/dist/TableInfo.d.ts.map +1 -1
- package/dist/TableInfo.js.map +1 -1
- package/package.json +8 -8
- package/src/RegisteredFunctions.ts +1 -9
- package/src/SchemaToValidator.ts +1 -3
- package/src/TableInfo.ts +0 -1
package/CHANGELOG.md
CHANGED
package/dist/Auth.d.ts
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { Effect, Layer, Schema } from "effect";
|
|
2
|
-
import * as
|
|
2
|
+
import * as convex_server23 from "convex/server";
|
|
3
3
|
import { Auth as Auth$1 } from "convex/server";
|
|
4
|
-
import * as
|
|
5
|
-
import * as
|
|
4
|
+
import * as effect_Context0 from "effect/Context";
|
|
5
|
+
import * as effect_Cause0 from "effect/Cause";
|
|
6
6
|
|
|
7
7
|
//#region src/Auth.d.ts
|
|
8
8
|
declare namespace Auth_d_exports {
|
|
9
9
|
export { Auth, NoUserIdentityFoundError, layer };
|
|
10
10
|
}
|
|
11
|
-
declare const Auth_base:
|
|
12
|
-
getUserIdentity: Effect.Effect<
|
|
11
|
+
declare const Auth_base: effect_Context0.TagClass<Auth, "@confect/server/Auth", {
|
|
12
|
+
getUserIdentity: Effect.Effect<convex_server23.UserIdentity, NoUserIdentityFoundError, never>;
|
|
13
13
|
}> & Effect.Tag.Proxy<Auth, {
|
|
14
|
-
getUserIdentity: Effect.Effect<
|
|
14
|
+
getUserIdentity: Effect.Effect<convex_server23.UserIdentity, NoUserIdentityFoundError, never>;
|
|
15
15
|
}> & {
|
|
16
16
|
use: <X>(body: (_: {
|
|
17
|
-
getUserIdentity: Effect.Effect<
|
|
18
|
-
}) => X) => [X] extends [Effect.Effect<infer A, infer E, infer R>] ? Effect.Effect<A, E, Auth | R> : [X] extends [PromiseLike<infer A_1>] ? Effect.Effect<A_1,
|
|
17
|
+
getUserIdentity: Effect.Effect<convex_server23.UserIdentity, NoUserIdentityFoundError, never>;
|
|
18
|
+
}) => X) => [X] extends [Effect.Effect<infer A, infer E, infer R>] ? Effect.Effect<A, E, Auth | R> : [X] extends [PromiseLike<infer A_1>] ? Effect.Effect<A_1, effect_Cause0.UnknownException, Auth> : Effect.Effect<X, never, Auth>;
|
|
19
19
|
};
|
|
20
20
|
declare class Auth extends Auth_base {}
|
|
21
21
|
declare const layer: (auth: Auth$1) => Layer.Layer<Auth, never, never>;
|
package/dist/DatabaseReader.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ declare namespace DatabaseReader_d_exports {
|
|
|
19
19
|
declare const make: <DatabaseSchema_ extends AnyWithProps>(databaseSchema: DatabaseSchema_, convexDatabaseReader: GenericDatabaseReader<ToConvex<FromSchema<DatabaseSchema_>>>) => {
|
|
20
20
|
table: <const TableName extends Name<IncludeSystemTables<Tables<DatabaseSchema_>>>>(tableName: TableName) => {
|
|
21
21
|
readonly get: {
|
|
22
|
-
(id: convex_values0.GenericId<TableName>): effect_Effect0.Effect<TableInfo<WithName<IncludeSystemTables<Tables<DatabaseSchema_>>, TableName>>["document"],
|
|
22
|
+
(id: convex_values0.GenericId<TableName>): effect_Effect0.Effect<TableInfo<WithName<IncludeSystemTables<Tables<DatabaseSchema_>>, TableName>>["document"], DocumentDecodeError | GetByIdFailure, never>;
|
|
23
23
|
<IndexName extends keyof TableInfo<WithName<IncludeSystemTables<Tables<DatabaseSchema_>>, TableName>>["indexes"]>(indexName: IndexName, ...indexFieldValues: _confect_core_Types0.IndexFieldTypesForEq<ToConvex<DataModel<IncludeSystemTables<Tables<DatabaseSchema_>>>>, TableName, TableInfo<WithName<IncludeSystemTables<Tables<DatabaseSchema_>>, TableName>>["indexes"][IndexName]>): effect_Effect0.Effect<TableInfo<WithName<IncludeSystemTables<Tables<DatabaseSchema_>>, TableName>>["document"], DocumentDecodeError | GetByIndexFailure, never>;
|
|
24
24
|
};
|
|
25
25
|
readonly index: {
|
|
@@ -32,7 +32,7 @@ declare const make: <DatabaseSchema_ extends AnyWithProps>(databaseSchema: Datab
|
|
|
32
32
|
declare const DatabaseReader: <DatabaseSchema_ extends AnyWithProps>() => Context.Tag<{
|
|
33
33
|
table: <const TableName extends Name<IncludeSystemTables<Tables<DatabaseSchema_>>>>(tableName: TableName) => {
|
|
34
34
|
readonly get: {
|
|
35
|
-
(id: convex_values0.GenericId<TableName>): effect_Effect0.Effect<TableInfo<WithName<IncludeSystemTables<Tables<DatabaseSchema_>>, TableName>>["document"],
|
|
35
|
+
(id: convex_values0.GenericId<TableName>): effect_Effect0.Effect<TableInfo<WithName<IncludeSystemTables<Tables<DatabaseSchema_>>, TableName>>["document"], DocumentDecodeError | GetByIdFailure, never>;
|
|
36
36
|
<IndexName extends keyof TableInfo<WithName<IncludeSystemTables<Tables<DatabaseSchema_>>, TableName>>["indexes"]>(indexName: IndexName, ...indexFieldValues: _confect_core_Types0.IndexFieldTypesForEq<ToConvex<DataModel<IncludeSystemTables<Tables<DatabaseSchema_>>>>, TableName, TableInfo<WithName<IncludeSystemTables<Tables<DatabaseSchema_>>, TableName>>["indexes"][IndexName]>): effect_Effect0.Effect<TableInfo<WithName<IncludeSystemTables<Tables<DatabaseSchema_>>, TableName>>["document"], DocumentDecodeError | GetByIndexFailure, never>;
|
|
37
37
|
};
|
|
38
38
|
readonly index: {
|
|
@@ -44,7 +44,7 @@ declare const DatabaseReader: <DatabaseSchema_ extends AnyWithProps>() => Contex
|
|
|
44
44
|
}, {
|
|
45
45
|
table: <const TableName extends Name<IncludeSystemTables<Tables<DatabaseSchema_>>>>(tableName: TableName) => {
|
|
46
46
|
readonly get: {
|
|
47
|
-
(id: convex_values0.GenericId<TableName>): effect_Effect0.Effect<TableInfo<WithName<IncludeSystemTables<Tables<DatabaseSchema_>>, TableName>>["document"],
|
|
47
|
+
(id: convex_values0.GenericId<TableName>): effect_Effect0.Effect<TableInfo<WithName<IncludeSystemTables<Tables<DatabaseSchema_>>, TableName>>["document"], DocumentDecodeError | GetByIdFailure, never>;
|
|
48
48
|
<IndexName extends keyof TableInfo<WithName<IncludeSystemTables<Tables<DatabaseSchema_>>, TableName>>["indexes"]>(indexName: IndexName, ...indexFieldValues: _confect_core_Types0.IndexFieldTypesForEq<ToConvex<DataModel<IncludeSystemTables<Tables<DatabaseSchema_>>>>, TableName, TableInfo<WithName<IncludeSystemTables<Tables<DatabaseSchema_>>, TableName>>["indexes"][IndexName]>): effect_Effect0.Effect<TableInfo<WithName<IncludeSystemTables<Tables<DatabaseSchema_>>, TableName>>["document"], DocumentDecodeError | GetByIndexFailure, never>;
|
|
49
49
|
};
|
|
50
50
|
readonly index: {
|
|
@@ -58,7 +58,7 @@ type DatabaseReader<DatabaseSchema_ extends AnyWithProps> = ReturnType<typeof Da
|
|
|
58
58
|
declare const layer: <DatabaseSchema_ extends AnyWithProps>(databaseSchema: DatabaseSchema_, convexDatabaseReader: GenericDatabaseReader<ToConvex<FromSchema<DatabaseSchema_>>>) => Layer.Layer<{
|
|
59
59
|
table: <const TableName extends Name<IncludeSystemTables<Tables<DatabaseSchema_>>>>(tableName: TableName) => {
|
|
60
60
|
readonly get: {
|
|
61
|
-
(id: convex_values0.GenericId<TableName>): effect_Effect0.Effect<TableInfo<WithName<IncludeSystemTables<Tables<DatabaseSchema_>>, TableName>>["document"],
|
|
61
|
+
(id: convex_values0.GenericId<TableName>): effect_Effect0.Effect<TableInfo<WithName<IncludeSystemTables<Tables<DatabaseSchema_>>, TableName>>["document"], DocumentDecodeError | GetByIdFailure, never>;
|
|
62
62
|
<IndexName extends keyof TableInfo<WithName<IncludeSystemTables<Tables<DatabaseSchema_>>, TableName>>["indexes"]>(indexName: IndexName, ...indexFieldValues: _confect_core_Types0.IndexFieldTypesForEq<ToConvex<DataModel<IncludeSystemTables<Tables<DatabaseSchema_>>>>, TableName, TableInfo<WithName<IncludeSystemTables<Tables<DatabaseSchema_>>, TableName>>["indexes"][IndexName]>): effect_Effect0.Effect<TableInfo<WithName<IncludeSystemTables<Tables<DatabaseSchema_>>, TableName>>["document"], DocumentDecodeError | GetByIndexFailure, never>;
|
|
63
63
|
};
|
|
64
64
|
readonly index: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DatabaseReader.d.ts","names":[],"sources":["../src/DatabaseReader.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;cAQa,+BAAgC,8BAC3B,uCACM,sBACpB,SAAmB,WAAqB;kCAUR,KAAU,oBAAA,OAAA,+BAC7B;;;;;;;;;;;;cAgCJ,yCACa,mBAA2B,OAAA,CAAA;kCAlC1B,KAAA,oBAAA,OAAA,+BAAA;IAbd,SA4CZ,GAAA,EAAA;MA5C4C,CAAA,EAAA,0BAAA,UAAA,CAAA,CAAA,uBAAA,UAAA,SAAA,oBAAA,OAAA,gBAAA,CAAA,CAAA,WAAA,CAAA,CAAA,CAAA,UAAA,CAAA,
|
|
1
|
+
{"version":3,"file":"DatabaseReader.d.ts","names":[],"sources":["../src/DatabaseReader.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;cAQa,+BAAgC,8BAC3B,uCACM,sBACpB,SAAmB,WAAqB;kCAU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OAAA,gBAAA,CAAA,CAAA,WAAA,CAAA,CAAA,WAAA,CAAA;MADoB,CAAA,kBAAA,eAAA,SAAA,oBAAA,OAAA,gBAAA,CAAA,CAAA,WAAA,CAAA,CAAA,CAAA,SAAA,CAAA,CAAA,CAAA,SAAA,WAAA,EAAA,KAAA,CAAA,EAAA,KAAA,GAAA,MAAA,CAAA,gBAAA,UAAA,SAAA,oBAAA,OAAA,gBAAA,CAAA,CAAA,WAAA,CAAA,CAAA,WAAA,CAAA;IAWsB,CAAA;IAAA,SAAA,MAAA,EAAA,CAAA,kBAAA,eAAA,SAAA,oBAAA,OAAA,gBAAA,CAAA,CAAA,WAAA,CAAA,CAAA,CAAA,eAAA,CAAA,CAAA,CAAA,SAAA,WAAA,EAAA,YAAA,EAAA,CAAA,CAAA,oCAAA,UAAA,SAAA,oBAAA,OAAA,gBAAA,CAAA,CAAA,WAAA,CAAA,CAAA,CAAA,gBAAA,CAAA,iCAAA,kBAAA,UAAA,oBAAA,OAAA,gBAAA,CAAA,CAAA,CAAA,WAAA,CAAA,WAAA,CAAA,CAAA,EAAA,8BAAA,EAAA,iBAAA,UAAA,SAAA,oBAAA,OAAA,gBAAA,CAAA,CAAA,WAAA,CAAA,CAAA,WAAA,CAAA;EAAA,CAAA;CAAV,EAAA;EACnB,KAAA,EAAA,CAAA,wBADU,IACV,CADU,mBACV,CADU,MACV,CADU,eACV,CAAA,CAAA,CAAA,CAAA,CAAA,SAAA,EADU,SACV,EAAA,GAAA;;;;;;;;;;;;KAuCL,uCACc,gBACtB,kBAAkB,eAAe;cAExB,gCAAiC,8BAC5B,uCACM,sBACpB,SAAmB,WAAqB,uBACzC,KAAA,CAAA;kCAhDwB,KAAA,oBAAA,OAAA,+BAAA"}
|
package/dist/DatabaseSchema.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { AnyWithProps as AnyWithProps$1, Name, SystemTables, Table, TablesRecord, WithName } from "./Table.js";
|
|
2
2
|
import { Expand, GenericSchema, SchemaDefinition } from "convex/server";
|
|
3
|
-
import * as
|
|
3
|
+
import * as convex_values16 from "convex/values";
|
|
4
4
|
import * as effect_Schema0 from "effect/Schema";
|
|
5
5
|
|
|
6
6
|
//#region src/DatabaseSchema.d.ts
|
|
@@ -60,7 +60,7 @@ declare const systemSchema: DatabaseSchema<Table<"_scheduled_functions", effect_
|
|
|
60
60
|
}>, effect_Schema0.Struct<{
|
|
61
61
|
kind: effect_Schema0.Literal<["canceled"]>;
|
|
62
62
|
}>]>;
|
|
63
|
-
}>,
|
|
63
|
+
}>, convex_values16.VObject<{
|
|
64
64
|
name: string;
|
|
65
65
|
args: any[];
|
|
66
66
|
scheduledTime: number;
|
|
@@ -78,10 +78,10 @@ declare const systemSchema: DatabaseSchema<Table<"_scheduled_functions", effect_
|
|
|
78
78
|
};
|
|
79
79
|
completedTime?: number;
|
|
80
80
|
}, {
|
|
81
|
-
name:
|
|
82
|
-
args:
|
|
83
|
-
scheduledTime:
|
|
84
|
-
state:
|
|
81
|
+
name: convex_values16.VString<string, "required">;
|
|
82
|
+
args: convex_values16.VArray<any[], convex_values16.VAny<any, "required", string>, "required">;
|
|
83
|
+
scheduledTime: convex_values16.VFloat64<number, "required">;
|
|
84
|
+
state: convex_values16.VUnion<{
|
|
85
85
|
kind: "pending";
|
|
86
86
|
} | {
|
|
87
87
|
kind: "inProgress";
|
|
@@ -92,44 +92,44 @@ declare const systemSchema: DatabaseSchema<Table<"_scheduled_functions", effect_
|
|
|
92
92
|
error: string;
|
|
93
93
|
} | {
|
|
94
94
|
kind: "canceled";
|
|
95
|
-
}, [
|
|
95
|
+
}, [convex_values16.VObject<{
|
|
96
96
|
kind: "pending";
|
|
97
97
|
}, {
|
|
98
|
-
kind:
|
|
99
|
-
}, "required", "kind">,
|
|
98
|
+
kind: convex_values16.VLiteral<"pending", "required">;
|
|
99
|
+
}, "required", "kind">, convex_values16.VObject<{
|
|
100
100
|
kind: "inProgress";
|
|
101
101
|
}, {
|
|
102
|
-
kind:
|
|
103
|
-
}, "required", "kind">,
|
|
102
|
+
kind: convex_values16.VLiteral<"inProgress", "required">;
|
|
103
|
+
}, "required", "kind">, convex_values16.VObject<{
|
|
104
104
|
kind: "success";
|
|
105
105
|
}, {
|
|
106
|
-
kind:
|
|
107
|
-
}, "required", "kind">,
|
|
106
|
+
kind: convex_values16.VLiteral<"success", "required">;
|
|
107
|
+
}, "required", "kind">, convex_values16.VObject<{
|
|
108
108
|
kind: "failed";
|
|
109
109
|
error: string;
|
|
110
110
|
}, {
|
|
111
|
-
kind:
|
|
112
|
-
error:
|
|
113
|
-
}, "required", "kind" | "error">,
|
|
111
|
+
kind: convex_values16.VLiteral<"failed", "required">;
|
|
112
|
+
error: convex_values16.VString<string, "required">;
|
|
113
|
+
}, "required", "kind" | "error">, convex_values16.VObject<{
|
|
114
114
|
kind: "canceled";
|
|
115
115
|
}, {
|
|
116
|
-
kind:
|
|
116
|
+
kind: convex_values16.VLiteral<"canceled", "required">;
|
|
117
117
|
}, "required", "kind">], "required", "kind" | "error">;
|
|
118
|
-
completedTime:
|
|
118
|
+
completedTime: convex_values16.VFloat64<number | undefined, "optional">;
|
|
119
119
|
}, "required", "name" | "args" | "scheduledTime" | "completedTime" | "state" | "state.kind" | "state.error">, {}, {}, {}> | Table<"_storage", effect_Schema0.Struct<{
|
|
120
120
|
sha256: typeof effect_Schema0.String;
|
|
121
121
|
size: typeof effect_Schema0.Number;
|
|
122
122
|
contentType: effect_Schema0.optionalWith<typeof effect_Schema0.String, {
|
|
123
123
|
exact: true;
|
|
124
124
|
}>;
|
|
125
|
-
}>,
|
|
125
|
+
}>, convex_values16.VObject<{
|
|
126
126
|
sha256: string;
|
|
127
127
|
size: number;
|
|
128
128
|
contentType?: string;
|
|
129
129
|
}, {
|
|
130
|
-
sha256:
|
|
131
|
-
size:
|
|
132
|
-
contentType:
|
|
130
|
+
sha256: convex_values16.VString<string, "required">;
|
|
131
|
+
size: convex_values16.VFloat64<number, "required">;
|
|
132
|
+
contentType: convex_values16.VString<string | undefined, "optional">;
|
|
133
133
|
}, "required", "sha256" | "size" | "contentType">, {}, {}, {}>>;
|
|
134
134
|
declare const extendWithSystemTables: <Tables_$1 extends AnyWithProps$1>(tables: TablesRecord<Tables_$1>) => ExtendWithSystemTables<Tables_$1>;
|
|
135
135
|
type ExtendWithSystemTables<Tables_$1 extends AnyWithProps$1> = TablesRecord<Tables_$1 | SystemTables>;
|
package/dist/DatabaseWriter.d.ts
CHANGED
|
@@ -12,25 +12,25 @@ declare namespace DatabaseWriter_d_exports {
|
|
|
12
12
|
}
|
|
13
13
|
declare const make: <DatabaseSchema_ extends AnyWithProps>(databaseSchema: DatabaseSchema_, convexDatabaseWriter: GenericDatabaseWriter<ToConvex<FromSchema<DatabaseSchema_>>>) => {
|
|
14
14
|
insert: <TableName extends TableNames<FromSchema<DatabaseSchema_>>>(tableName: TableName, document: WithoutSystemFields$1<DocumentByName<FromSchema<DatabaseSchema_>, TableName>>) => Effect.Effect<GenericId<TableName>, DocumentEncodeError, never>;
|
|
15
|
-
patch: <TableName extends TableNames<FromSchema<DatabaseSchema_>>>(tableName: TableName, id: GenericId<TableName>, patchedValues: Partial<WithoutSystemFields<DocumentByName<FromSchema<DatabaseSchema_>, TableName>>>) => Effect.Effect<void,
|
|
15
|
+
patch: <TableName extends TableNames<FromSchema<DatabaseSchema_>>>(tableName: TableName, id: GenericId<TableName>, patchedValues: Partial<WithoutSystemFields<DocumentByName<FromSchema<DatabaseSchema_>, TableName>>>) => Effect.Effect<void, DocumentDecodeError | GetByIdFailure | DocumentEncodeError, never>;
|
|
16
16
|
replace: <TableName extends TableNames<FromSchema<DatabaseSchema_>>>(tableName: TableName, id: GenericId<TableName>, value: WithoutSystemFields<DocumentByName<FromSchema<DatabaseSchema_>, TableName>>) => Effect.Effect<void, DocumentEncodeError, never>;
|
|
17
17
|
delete: <TableName extends TableNames<FromSchema<DatabaseSchema_>>>(_tableName: TableName, id: GenericId<TableName>) => Effect.Effect<void, never, never>;
|
|
18
18
|
};
|
|
19
19
|
declare const DatabaseWriter: <DatabaseSchema_ extends AnyWithProps>() => Context.Tag<{
|
|
20
20
|
insert: <TableName extends TableNames<FromSchema<DatabaseSchema_>>>(tableName: TableName, document: WithoutSystemFields$1<DocumentByName<FromSchema<DatabaseSchema_>, TableName>>) => Effect.Effect<GenericId<TableName>, DocumentEncodeError, never>;
|
|
21
|
-
patch: <TableName extends TableNames<FromSchema<DatabaseSchema_>>>(tableName: TableName, id: GenericId<TableName>, patchedValues: Partial<Expand<BetterOmit<DocumentByName<FromSchema<DatabaseSchema_>, TableName>, "_id" | "_creationTime">>>) => Effect.Effect<void,
|
|
21
|
+
patch: <TableName extends TableNames<FromSchema<DatabaseSchema_>>>(tableName: TableName, id: GenericId<TableName>, patchedValues: Partial<Expand<BetterOmit<DocumentByName<FromSchema<DatabaseSchema_>, TableName>, "_id" | "_creationTime">>>) => Effect.Effect<void, DocumentDecodeError | GetByIdFailure | DocumentEncodeError, never>;
|
|
22
22
|
replace: <TableName extends TableNames<FromSchema<DatabaseSchema_>>>(tableName: TableName, id: GenericId<TableName>, value: Expand<BetterOmit<DocumentByName<FromSchema<DatabaseSchema_>, TableName>, "_id" | "_creationTime">>) => Effect.Effect<void, DocumentEncodeError, never>;
|
|
23
23
|
delete: <TableName extends TableNames<FromSchema<DatabaseSchema_>>>(_tableName: TableName, id: GenericId<TableName>) => Effect.Effect<void, never, never>;
|
|
24
24
|
}, {
|
|
25
25
|
insert: <TableName extends TableNames<FromSchema<DatabaseSchema_>>>(tableName: TableName, document: WithoutSystemFields$1<DocumentByName<FromSchema<DatabaseSchema_>, TableName>>) => Effect.Effect<GenericId<TableName>, DocumentEncodeError, never>;
|
|
26
|
-
patch: <TableName extends TableNames<FromSchema<DatabaseSchema_>>>(tableName: TableName, id: GenericId<TableName>, patchedValues: Partial<Expand<BetterOmit<DocumentByName<FromSchema<DatabaseSchema_>, TableName>, "_id" | "_creationTime">>>) => Effect.Effect<void,
|
|
26
|
+
patch: <TableName extends TableNames<FromSchema<DatabaseSchema_>>>(tableName: TableName, id: GenericId<TableName>, patchedValues: Partial<Expand<BetterOmit<DocumentByName<FromSchema<DatabaseSchema_>, TableName>, "_id" | "_creationTime">>>) => Effect.Effect<void, DocumentDecodeError | GetByIdFailure | DocumentEncodeError, never>;
|
|
27
27
|
replace: <TableName extends TableNames<FromSchema<DatabaseSchema_>>>(tableName: TableName, id: GenericId<TableName>, value: Expand<BetterOmit<DocumentByName<FromSchema<DatabaseSchema_>, TableName>, "_id" | "_creationTime">>) => Effect.Effect<void, DocumentEncodeError, never>;
|
|
28
28
|
delete: <TableName extends TableNames<FromSchema<DatabaseSchema_>>>(_tableName: TableName, id: GenericId<TableName>) => Effect.Effect<void, never, never>;
|
|
29
29
|
}>;
|
|
30
30
|
type DatabaseWriter<DatabaseSchema_ extends AnyWithProps> = ReturnType<typeof DatabaseWriter<DatabaseSchema_>>["Identifier"];
|
|
31
31
|
declare const layer: <DatabaseSchema_ extends AnyWithProps>(databaseSchema: DatabaseSchema_, convexDatabaseWriter: GenericDatabaseWriter<ToConvex<FromSchema<DatabaseSchema_>>>) => Layer.Layer<{
|
|
32
32
|
insert: <TableName extends TableNames<FromSchema<DatabaseSchema_>>>(tableName: TableName, document: WithoutSystemFields$1<DocumentByName<FromSchema<DatabaseSchema_>, TableName>>) => Effect.Effect<GenericId<TableName>, DocumentEncodeError, never>;
|
|
33
|
-
patch: <TableName extends TableNames<FromSchema<DatabaseSchema_>>>(tableName: TableName, id: GenericId<TableName>, patchedValues: Partial<Expand<BetterOmit<DocumentByName<FromSchema<DatabaseSchema_>, TableName>, "_id" | "_creationTime">>>) => Effect.Effect<void,
|
|
33
|
+
patch: <TableName extends TableNames<FromSchema<DatabaseSchema_>>>(tableName: TableName, id: GenericId<TableName>, patchedValues: Partial<Expand<BetterOmit<DocumentByName<FromSchema<DatabaseSchema_>, TableName>, "_id" | "_creationTime">>>) => Effect.Effect<void, DocumentDecodeError | GetByIdFailure | DocumentEncodeError, never>;
|
|
34
34
|
replace: <TableName extends TableNames<FromSchema<DatabaseSchema_>>>(tableName: TableName, id: GenericId<TableName>, value: Expand<BetterOmit<DocumentByName<FromSchema<DatabaseSchema_>, TableName>, "_id" | "_creationTime">>) => Effect.Effect<void, DocumentEncodeError, never>;
|
|
35
35
|
delete: <TableName extends TableNames<FromSchema<DatabaseSchema_>>>(_tableName: TableName, id: GenericId<TableName>) => Effect.Effect<void, never, never>;
|
|
36
36
|
}, never, never>;
|
package/dist/Impl.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Impl.d.ts","names":[],"sources":["../src/Impl.ts"],"sourcesContent":[],"mappings":";;;;;;;;cAKa,MAAA;KACD,MAAA,UAAgB;cAEf,6BAA4B;UAGxB,kBACF,4CACe;YAElB,MAAA,GAAS;gBACL;+BACe;;KAGnB,kBAAA;UAEK,YAAA,SACP,KAAK,gBAAkB;AAlBpB,cAoBA,IApBM,EAAA,CAAA,aAqBJ,cArBI,EAAA,4BAsBW,kBAtBX,CAAA,GAAA,GAsB6B,OAAA,CAAA,GAtB7B,CAsB6B,IAtB7B,CAsB6B,IAtB7B,EAsB6B,mBAtB7B,CAAA,EAsB6B,IAtB7B,CAsB6B,IAtB7B,EAsB6B,mBAtB7B,CAAA,CAAA;AACP,cAyBC,
|
|
1
|
+
{"version":3,"file":"Impl.d.ts","names":[],"sources":["../src/Impl.ts"],"sourcesContent":[],"mappings":";;;;;;;;cAKa,MAAA;KACD,MAAA,UAAgB;cAEf,6BAA4B;UAGxB,kBACF,4CACe;YAElB,MAAA,GAAS;gBACL;+BACe;;KAGnB,kBAAA;UAEK,YAAA,SACP,KAAK,gBAAkB;AAlBpB,cAoBA,IApBM,EAAA,CAAA,aAqBJ,cArBI,EAAA,4BAsBW,kBAtBX,CAAA,GAAA,GAsB6B,OAAA,CAAA,GAtB7B,CAsB6B,IAtB7B,CAsB6B,IAtB7B,EAsB6B,mBAtB7B,CAAA,EAsB6B,IAtB7B,CAsB6B,IAtB7B,EAsB6B,mBAtB7B,CAAA,CAAA;AACP,cAyBC,IAzBK,EAAU,CAAA,aAyBM,cAzBA,CAAA,CAAA,GAAA,EA0B3B,IA1B2B,EAAA,GA2B/B,KAAA,CAAM,KA3ByB,CA4BhC,IA5BgC,CA4B3B,IA5B2B,EAAA,aAAA,CAAA,EAAA,KAAA,EA8BhC,UA9BgC,CA8BX,MA9BW,CA8BD,IA9BC,CAAA,CAAA,CAAA;AAErB,cAuCA,QAvC4B,EAAA,CAAA,aAuCH,cAtCJ,CAAA,CAAA,IAAA,EAuC1B,KAAA,CAAM,KAvCoB,CAuCd,IAvCc,CAuCT,IAvCS,EAAA,aAAA,CAAA,CAAA,EAAA,GAwC/B,KAAA,CAAM,KAxCyB,CAwCnB,IAxCmB,CAwCd,IAxCc,EAAA,WAAA,CAAA,CAAA"}
|
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_ParseResult4 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_ParseResult4.ParseError, never>), <Mutation extends Ref$1.AnyMutation>(mutation: Mutation, args: Ref$1.Args<Mutation>["Type"]) => Effect.Effect<any, effect_ParseResult4.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_ParseResult4.ParseError, never>), never, never>;
|
|
13
13
|
declare const MutationRollback_base: Schema.TaggedErrorClass<MutationRollback, "MutationRollback", {
|
|
14
14
|
readonly _tag: Schema.tag<"MutationRollback">;
|
|
15
15
|
} & {
|
|
@@ -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"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;KA6BK,oCACgB,kCACD,WAAqB,sCACd,qCACN;;SAIX,UAAU,aACb,MAAA,CAAO,OACR,wBACA,sBAA+B;6BAER,QAAQ,8BACpB,gCACU,qBACnB,SAAmB,aACnB,WACA,QAAQ,kBAAkB,cAE3B,MAAA,CAAO,OACR,wBACA,sBAA+B;;;6BAIR,QAAQ,8BACpB,4BAEN,kBACD,8BACA,WAAW,kBAAkB,gBAE5B,qCAEJ,eAA0B,YAAY;6BAChB,QAAQ,8BACpB,oCAEV,eAA0B,YAAY;;EAvCxC,SAAA,MAAA,EAAA,CAAA,kBAAgB,MAyCuB,aAzCvB,CAyCqC,gBAzCrC,CAAA,CAAA,CAAA,SAAA,EA0CN,SA1CM,EAAA,YAAA,EAAA,CAAA,CAAA,EA4CZ,mBA5CY,CA6Cb,cA7Ca,CA6CE,gBA7CF,CAAA,EA8Cb,gBA9Ca,CA8CI,gBA9CJ,EA8CsB,SA9CtB,CAAA,CAAA,EAAA,GAgDZ,YAhDY,EAAA,GAiDd,cAjDc,CAiDY,UAjDZ,EAiDwB,SAjDxB,CAAA;CACA;AACoB,cAkD5B,IAlD4B,EAAA,CAAA,eAmDxB,YAnDwB,EAAA,kBAoDrB,IApDqB,CAoDV,MApDU,CAAA,CAAA,CAAA,SAAA,EAsD5B,SAtD4B,EAAA,oBAAA,EAuDjB,kBAvDiB,CAwDrC,QAxDqC,CAwDlB,UAxDkB,CAwDG,MAxDH,CAAA,CAAA,CAAA,EA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AA,EAAA,gBAAA,EAAA;EACN,SAAA,IAAA,YAAA,CAAA,gBAAA,CAAA;CAID,GAAA;EAAV,EAAA,EAAA,oBAAA;EAEJ,SAAA,EAAA,oBAAA;CACA,CAAA;AAA+B,cAkPxB,cAAA,SAAuB,mBAAA,CAlPC;EAF9B,IAAO,OAAA,CAAA,CAAA,EAAA,MAAA;;cAiQb,sBA7P4B,yBAAA,kBAAA,EAAA,mBAAA,EAAA;EACZ,SAAA,IAAA,YAAA,CAAA,mBAAA,CAAA;CAEU,GAAA;EAAnB,SAAA,EAAA,oBAAA;EACA,SAAA,EAAA,oBAAA;EACQ,gBAAA,eAAA,CAAA,oBAAA,CAAA;CAAR,CAAA;AAA0B,cA0PrB,iBAAA,SAA0B,sBAAA,CA1PL;EAHP,IAAA,OAAA,CAAA,CAAA,EAAA,MAAA"}
|
|
@@ -17,10 +17,10 @@ import { StorageReader as StorageReader$1, StorageWriter as StorageWriter$1 } fr
|
|
|
17
17
|
import { Impl } from "./Impl.js";
|
|
18
18
|
import { Effect, Layer, Types } from "effect";
|
|
19
19
|
import * as _confect_core_Ref0 from "@confect/core/Ref";
|
|
20
|
-
import * as
|
|
20
|
+
import * as convex_server26 from "convex/server";
|
|
21
21
|
import { DefaultFunctionArgs, FunctionVisibility, GenericMutationCtx, RegisteredAction, RegisteredMutation, RegisteredQuery } from "convex/server";
|
|
22
|
-
import * as
|
|
23
|
-
import * as
|
|
22
|
+
import * as convex_values9 from "convex/values";
|
|
23
|
+
import * as effect_ParseResult2 from "effect/ParseResult";
|
|
24
24
|
import * as Spec from "@confect/core/Spec";
|
|
25
25
|
import * as _confect_core_Types3 from "@confect/core/Types";
|
|
26
26
|
import * as FunctionSpec from "@confect/core/FunctionSpec";
|
|
@@ -39,27 +39,27 @@ interface AnyWithProps {
|
|
|
39
39
|
readonly [key: string]: RegisteredFunction | AnyWithProps;
|
|
40
40
|
}
|
|
41
41
|
declare const make: <Api_ extends AnyWithProps$2>(impl: Layer.Layer<Impl<Api_, "Finalized">>) => Types.Simplify<RegisteredFunctionsHelper<Spec.Groups<Api_["spec"]>>>;
|
|
42
|
-
declare const mutationLayer: <Schema$1 extends AnyWithProps$1>(schema: Schema$1, ctx: GenericMutationCtx<ToConvex<FromSchema<Schema$1>>>) => Layer.Layer<
|
|
42
|
+
declare const mutationLayer: <Schema$1 extends AnyWithProps$1>(schema: Schema$1, ctx: GenericMutationCtx<ToConvex<FromSchema<Schema$1>>>) => Layer.Layer<{
|
|
43
|
+
runAfter: <FuncRef extends convex_server26.SchedulableFunctionReference>(delay: effect_Duration0.Duration, functionReference: FuncRef, ...args: convex_server26.OptionalRestArgs<FuncRef>) => Effect.Effect<convex_values9.GenericId<"_scheduled_functions">, never, never>;
|
|
44
|
+
runAt: <FuncRef extends convex_server26.SchedulableFunctionReference>(dateTime: effect_DateTime0.DateTime, functionReference: FuncRef, ...args: convex_server26.OptionalRestArgs<FuncRef>) => Effect.Effect<convex_values9.GenericId<"_scheduled_functions">, never, never>;
|
|
45
|
+
} | (<Query extends _confect_core_Ref0.AnyQuery>(query: Query, args: _confect_core_Ref0.Args<Query>["Type"]) => Effect.Effect<_confect_core_Ref0.Returns<Query>["Type"], effect_ParseResult2.ParseError>) | Auth$1 | GenericMutationCtx<ToConvex<FromSchema<Schema$1>>> | {
|
|
43
46
|
table: <const TableName extends Name<IncludeSystemTables<Tables<Schema$1>>>>(tableName: TableName) => {
|
|
44
47
|
readonly get: {
|
|
45
|
-
(id:
|
|
48
|
+
(id: convex_values9.GenericId<TableName>): Effect.Effect<TableInfo<WithName<IncludeSystemTables<Tables<Schema$1>>, TableName>>["document"], DocumentDecodeError | GetByIdFailure, never>;
|
|
46
49
|
<IndexName extends keyof TableInfo<WithName<IncludeSystemTables<Tables<Schema$1>>, TableName>>["indexes"]>(indexName: IndexName, ...indexFieldValues: _confect_core_Types3.IndexFieldTypesForEq<ToConvex<DataModel<IncludeSystemTables<Tables<Schema$1>>>>, TableName, TableInfo<WithName<IncludeSystemTables<Tables<Schema$1>>, TableName>>["indexes"][IndexName]>): Effect.Effect<TableInfo<WithName<IncludeSystemTables<Tables<Schema$1>>, TableName>>["document"], DocumentDecodeError | GetByIndexFailure, never>;
|
|
47
50
|
};
|
|
48
51
|
readonly index: {
|
|
49
|
-
<IndexName extends keyof TableInfo<WithName<IncludeSystemTables<Tables<Schema$1>>, TableName>>["indexes"]>(indexName: IndexName, indexRange?: ((q:
|
|
52
|
+
<IndexName extends keyof TableInfo<WithName<IncludeSystemTables<Tables<Schema$1>>, TableName>>["indexes"]>(indexName: IndexName, indexRange?: ((q: convex_server26.IndexRangeBuilder<TableInfo<WithName<IncludeSystemTables<Tables<Schema$1>>, TableName>>["convexDocument"], convex_server26.NamedIndex<TableInfoWithName<DataModel<IncludeSystemTables<Tables<Schema$1>>>, TableName>, IndexName>, 0>) => convex_server26.IndexRange) | undefined, order?: "asc" | "desc"): OrderedQuery$1<TableInfo<WithName<IncludeSystemTables<Tables<Schema$1>>, TableName>>, TableName>;
|
|
50
53
|
<IndexName extends keyof TableInfo<WithName<IncludeSystemTables<Tables<Schema$1>>, TableName>>["indexes"]>(indexName: IndexName, order?: "asc" | "desc"): OrderedQuery$1<TableInfo<WithName<IncludeSystemTables<Tables<Schema$1>>, TableName>>, TableName>;
|
|
51
54
|
};
|
|
52
|
-
readonly search: <IndexName extends keyof TableInfo<WithName<IncludeSystemTables<Tables<Schema$1>>, TableName>>["searchIndexes"]>(indexName: IndexName, searchFilter: (q:
|
|
55
|
+
readonly search: <IndexName extends keyof TableInfo<WithName<IncludeSystemTables<Tables<Schema$1>>, TableName>>["searchIndexes"]>(indexName: IndexName, searchFilter: (q: convex_server26.SearchFilterBuilder<TableInfo<WithName<IncludeSystemTables<Tables<Schema$1>>, TableName>>["convexDocument"], convex_server26.NamedSearchIndex<TableInfoWithName<DataModel<IncludeSystemTables<Tables<Schema$1>>>, TableName>, IndexName>>) => convex_server26.SearchFilter) => OrderedQuery$1<TableInfo<WithName<IncludeSystemTables<Tables<Schema$1>>, TableName>>, TableName>;
|
|
53
56
|
};
|
|
54
57
|
} | {
|
|
55
|
-
insert: <TableName extends TableNames<FromSchema<Schema$1>>>(tableName: TableName, document: WithoutSystemFields$1<DocumentByName<FromSchema<Schema$1>, TableName>>) => Effect.Effect<
|
|
56
|
-
patch: <TableName extends TableNames<FromSchema<Schema$1>>>(tableName: TableName, id:
|
|
57
|
-
replace: <TableName extends TableNames<FromSchema<Schema$1>>>(tableName: TableName, id:
|
|
58
|
-
delete: <TableName extends TableNames<FromSchema<Schema$1>>>(_tableName: TableName, id:
|
|
59
|
-
} |
|
|
60
|
-
runAfter: <FuncRef extends convex_server23.SchedulableFunctionReference>(delay: effect_Duration0.Duration, functionReference: FuncRef, ...args: convex_server23.OptionalRestArgs<FuncRef>) => Effect.Effect<convex_values3.GenericId<"_scheduled_functions">, never, never>;
|
|
61
|
-
runAt: <FuncRef extends convex_server23.SchedulableFunctionReference>(dateTime: effect_DateTime0.DateTime, functionReference: FuncRef, ...args: convex_server23.OptionalRestArgs<FuncRef>) => Effect.Effect<convex_values3.GenericId<"_scheduled_functions">, never, never>;
|
|
62
|
-
} | StorageReader$1 | StorageWriter$1, never, never>;
|
|
58
|
+
insert: <TableName extends TableNames<FromSchema<Schema$1>>>(tableName: TableName, document: WithoutSystemFields$1<DocumentByName<FromSchema<Schema$1>, TableName>>) => Effect.Effect<convex_values9.GenericId<TableName>, DocumentEncodeError, never>;
|
|
59
|
+
patch: <TableName extends TableNames<FromSchema<Schema$1>>>(tableName: TableName, id: convex_values9.GenericId<TableName>, patchedValues: Partial<convex_server26.Expand<convex_server26.BetterOmit<DocumentByName<FromSchema<Schema$1>, TableName>, "_id" | "_creationTime">>>) => Effect.Effect<void, DocumentDecodeError | GetByIdFailure | DocumentEncodeError, never>;
|
|
60
|
+
replace: <TableName extends TableNames<FromSchema<Schema$1>>>(tableName: TableName, id: convex_values9.GenericId<TableName>, value: convex_server26.Expand<convex_server26.BetterOmit<DocumentByName<FromSchema<Schema$1>, TableName>, "_id" | "_creationTime">>) => Effect.Effect<void, DocumentEncodeError, never>;
|
|
61
|
+
delete: <TableName extends TableNames<FromSchema<Schema$1>>>(_tableName: TableName, id: convex_values9.GenericId<TableName>) => Effect.Effect<void, never, never>;
|
|
62
|
+
} | StorageReader$1 | StorageWriter$1 | (<Mutation extends _confect_core_Ref0.AnyMutation>(mutation: Mutation, args: _confect_core_Ref0.Args<Mutation>["Type"]) => Effect.Effect<any, effect_ParseResult2.ParseError, never>), never, never>;
|
|
63
63
|
type MutationServices<Schema$1 extends AnyWithProps$1> = DatabaseReader<Schema$1> | DatabaseWriter<Schema$1> | Auth$1 | Scheduler$1 | StorageReader$1 | StorageWriter$1 | QueryRunner | MutationRunner | MutationCtx<ToConvex<FromSchema<Schema$1>>>;
|
|
64
64
|
//#endregion
|
|
65
65
|
export { AnyWithProps, MutationServices, RegisteredFunction, RegisteredFunctions, RegisteredFunctions_d_exports, make, mutationLayer };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RegisteredFunctions.d.ts","names":[],"sources":["../src/RegisteredFunctions.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"RegisteredFunctions.d.ts","names":[],"sources":["../src/RegisteredFunctions.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAyCY,kBAAA,GACR,gBAAgB,oBAAoB,4BACpC,mBAAmB,oBAAoB,4BACvC,iBAAiB,oBAAoB;KAE7B,kCAAkC,IAAA,CAAK,gBACjD,KAAA,CAAM,SAAS,0BAA0B,IAAA,CAAK,OAAO;KAElD,yCAAyC,SAAA,CAAU,gCACxC,SAAA,CAAU,KAAK,UAAU,SAAA,CAAU,SAC/C,QACA,uCAC4B,SAAA,CAAU,eACpC,SAAA,CAAU,OAAO,uCACf,SAAA,CAAU,eACV,KAAA,CAAM,SACJ,0BAA0B,gCACP,YAAA,CAA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EAArC,MAAA,EAAA,CAAA,4BAAA,WAAA,SAAA,CAAA,CAAA,CAAA,CAAA,UAAA,WAAA,EAAA,EAAA,0BAAA,UAAA,CAAA,EAAA,gBAAA,CAAA,IAAA,EAAA,KAAA,EAAA,KAAA,CAAA;CAAgB,kBAAA,kBAAA,GAAA,CAAA,CAAA,+CAAA,CAAA,CAAA,QAAA,UAAA,EAAA,IAAA,yBAAA,SAAA,CAAA,CAAA,MAAA,CAAA,EAAA,gBAAA,CAAA,GAAA,kCAAA,KAAA,CAAA,CAAA,EAAA,KAAA,EAAA,KAAA,CAAA;AAER,KA8MA,gBA9MmB,CAAA,iBA8Ma,cA9Mb,CAAA,GA+M3B,cA/M2B,CA+MG,QA/MH,CAAA,GAgN3B,cAhN2B,CAgNG,QAhNH,CAAA,GAiN3B,MAjN2B,GAkN3B,WAlN2B,GAmN3B,eAnN2B,GAoN3B,eApN2B,GAqN3B,WArN2B,GAsN3B,cAtN2B,GAuN3B,WAvN2B,CAuNH,QAvNG,CAuNgB,UAvNhB,CAuNqC,QAvNrC,CAAA,CAAA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RegisteredFunctions.js","names":["Registry.Registry","Impl.Impl","RegistryItem.isRegistryItem","SchemaToValidator.compileArgsSchema","SchemaToValidator.compileReturnsSchema","DatabaseReader.layer","Auth.layer","StorageReader","QueryRunner.layer","QueryCtx.QueryCtx","DatabaseWriter.layer","Scheduler.layer","StorageWriter","MutationRunner.layer","MutationCtx.MutationCtx","StorageActionWriter","ActionRunner.layer","VectorSearch.layer","ActionCtx.ActionCtx"],"sources":["../src/RegisteredFunctions.ts"],"sourcesContent":["import type * as FunctionSpec from \"@confect/core/FunctionSpec\";\nimport type * as GroupSpec from \"@confect/core/GroupSpec\";\nimport type * as Spec from \"@confect/core/Spec\";\nimport {\n actionGeneric,\n type DefaultFunctionArgs,\n type FunctionVisibility,\n type GenericActionCtx,\n type GenericMutationCtx,\n type GenericQueryCtx,\n internalActionGeneric,\n internalMutationGeneric,\n internalQueryGeneric,\n mutationGeneric,\n queryGeneric,\n type RegisteredAction,\n type RegisteredMutation,\n type RegisteredQuery,\n} from \"convex/server\";\nimport {\n Effect,\n Layer,\n Match,\n pipe,\n Ref,\n Schema,\n type Types,\n} from \"effect\";\nimport * as ActionCtx from \"./ActionCtx\";\nimport * as ActionRunner from \"./ActionRunner\";\nimport type * as Api from \"./Api\";\nimport * as Auth from \"./Auth\";\nimport * as DatabaseReader from \"./DatabaseReader\";\nimport type * as DatabaseSchema from \"./DatabaseSchema\";\nimport * as DatabaseWriter from \"./DatabaseWriter\";\nimport type * as DataModel from \"./DataModel\";\nimport * as Impl from \"./Impl\";\nimport { mapLeaves } from \"./internal/utils\";\nimport * as MutationCtx from \"./MutationCtx\";\nimport * as MutationRunner from \"./MutationRunner\";\nimport * as QueryCtx from \"./QueryCtx\";\nimport * as QueryRunner from \"./QueryRunner\";\nimport * as Registry from \"./Registry\";\nimport * as RegistryItem from \"./RegistryItem\";\nimport * as Scheduler from \"./Scheduler\";\nimport * as SchemaToValidator from \"./SchemaToValidator\";\nimport { StorageActionWriter, StorageReader, StorageWriter } from \"./Storage\";\nimport * as VectorSearch from \"./VectorSearch\";\n\nexport type RegisteredFunction =\n | RegisteredQuery<FunctionVisibility, DefaultFunctionArgs, any>\n | RegisteredMutation<FunctionVisibility, DefaultFunctionArgs, any>\n | RegisteredAction<FunctionVisibility, DefaultFunctionArgs, any>;\n\nexport type RegisteredFunctions<Spec_ extends Spec.AnyWithProps> =\n Types.Simplify<RegisteredFunctionsHelper<Spec.Groups<Spec_>>>;\n\ntype RegisteredFunctionsHelper<Groups extends GroupSpec.AnyWithProps> = {\n [GroupName in GroupSpec.Name<Groups>]: GroupSpec.WithName<\n Groups,\n GroupName\n > extends infer Group extends GroupSpec.AnyWithProps\n ? GroupSpec.Groups<Group> extends infer SubGroups extends\n GroupSpec.AnyWithProps\n ? Types.Simplify<\n RegisteredFunctionsHelper<SubGroups> & {\n [FunctionName in FunctionSpec.Name<\n GroupSpec.Functions<Group>\n >]: FunctionSpec.WithName<\n GroupSpec.Functions<Group>,\n FunctionName\n > extends infer Function extends FunctionSpec.AnyWithProps\n ? FunctionSpec.RegisteredFunction<Function>\n : never;\n }\n >\n : {\n [FunctionName in FunctionSpec.Name<\n GroupSpec.Functions<Group>\n >]: FunctionSpec.WithName<\n GroupSpec.Functions<Group>,\n FunctionName\n > extends infer Function extends FunctionSpec.AnyWithProps\n ? FunctionSpec.RegisteredFunction<Function>\n : never;\n }\n : never;\n};\n\nexport interface AnyWithProps {\n readonly [key: string]: RegisteredFunction | AnyWithProps;\n}\n\nexport const make = <Api_ extends Api.AnyWithProps>(\n impl: Layer.Layer<Impl.Impl<Api_, \"Finalized\">>,\n) =>\n Effect.gen(function* () {\n const registry = yield* Registry.Registry;\n const functionImplItems = yield* Ref.get(registry);\n const { api, finalizationStatus } = yield* Impl.Impl<Api_, \"Finalized\">();\n\n return yield* Match.value(\n finalizationStatus as Impl.FinalizationStatus,\n ).pipe(\n Match.withReturnType<Effect.Effect<RegisteredFunctions<Api_[\"spec\"]>>>(),\n Match.when(\"Unfinalized\", () =>\n Effect.dieMessage(\"Impl is not finalized\"),\n ),\n Match.when(\"Finalized\", () =>\n Effect.succeed(\n mapLeaves<RegistryItem.AnyWithProps, RegisteredFunction>(\n functionImplItems,\n RegistryItem.isRegistryItem,\n (registryItem) => makeRegisteredFunction(api, registryItem),\n ) as RegisteredFunctions<Api_[\"spec\"]>,\n ),\n ),\n Match.exhaustive,\n );\n }).pipe(Effect.provide(impl), Effect.runSync);\n\nconst makeRegisteredFunction = <Api_ extends Api.AnyWithProps>(\n api: Api_,\n { function_, handler }: RegistryItem.AnyWithProps,\n): RegisteredFunction =>\n Match.value(function_.functionType).pipe(\n Match.when(\"query\", () => {\n const genericFunction = Match.value(function_.functionVisibility).pipe(\n Match.when(\"public\", () => queryGeneric),\n Match.when(\"internal\", () => internalQueryGeneric),\n Match.exhaustive,\n );\n\n return genericFunction(\n queryFunction(api.databaseSchema, {\n args: function_.args,\n returns: function_.returns,\n handler,\n }),\n );\n }),\n Match.when(\"mutation\", () => {\n const genericFunction = Match.value(function_.functionVisibility).pipe(\n Match.when(\"public\", () => mutationGeneric),\n Match.when(\"internal\", () => internalMutationGeneric),\n Match.exhaustive,\n );\n\n return genericFunction(\n mutationFunction(api.databaseSchema, {\n args: function_.args,\n returns: function_.returns,\n handler,\n }),\n );\n }),\n Match.when(\"action\", () => {\n const genericFunction = Match.value(function_.functionVisibility).pipe(\n Match.when(\"public\", () => actionGeneric),\n Match.when(\"internal\", () => internalActionGeneric),\n Match.exhaustive,\n );\n\n return genericFunction(\n actionFunction({\n args: function_.args,\n returns: function_.returns,\n handler,\n }),\n );\n }),\n Match.exhaustive,\n );\n\nconst queryFunction = <\n Schema extends DatabaseSchema.AnyWithProps,\n Args,\n ConvexArgs extends DefaultFunctionArgs,\n Returns,\n ConvexReturns,\n E,\n>(\n schema: Schema,\n {\n args,\n returns,\n handler,\n }: {\n args: Schema.Schema<Args, ConvexArgs>;\n returns: Schema.Schema<Returns, ConvexReturns>;\n handler: (\n a: Args,\n ) => Effect.Effect<\n Returns,\n E,\n | DatabaseReader.DatabaseReader<Schema>\n | Auth.Auth\n | StorageReader\n | QueryRunner.QueryRunner\n | QueryCtx.QueryCtx<DataModel.ToConvex<DataModel.FromSchema<Schema>>>\n >;\n },\n) => ({\n args: SchemaToValidator.compileArgsSchema(args),\n returns: SchemaToValidator.compileReturnsSchema(returns),\n handler: (\n ctx: GenericQueryCtx<DataModel.ToConvex<DataModel.FromSchema<Schema>>>,\n actualArgs: ConvexArgs,\n ): Promise<ConvexReturns> =>\n pipe(\n actualArgs,\n Schema.decode(args),\n Effect.orDie,\n Effect.andThen((decodedArgs) =>\n pipe(\n handler(decodedArgs),\n Effect.provide(\n Layer.mergeAll(\n DatabaseReader.layer(schema, ctx.db),\n Auth.layer(ctx.auth),\n StorageReader.layer(ctx.storage),\n QueryRunner.layer(ctx.runQuery),\n Layer.succeed(\n QueryCtx.QueryCtx<\n DataModel.ToConvex<DataModel.FromSchema<Schema>>\n >(),\n ctx,\n ),\n ),\n ),\n ),\n ),\n Effect.andThen((convexReturns) =>\n Schema.encodeUnknown(returns)(convexReturns),\n ),\n Effect.runPromise,\n ),\n});\n\nexport const mutationLayer = <Schema extends DatabaseSchema.AnyWithProps>(\n schema: Schema,\n ctx: GenericMutationCtx<DataModel.ToConvex<DataModel.FromSchema<Schema>>>,\n) =>\n Layer.mergeAll(\n DatabaseReader.layer(schema, ctx.db),\n DatabaseWriter.layer(schema, ctx.db),\n Auth.layer(ctx.auth),\n Scheduler.layer(ctx.scheduler),\n StorageReader.layer(ctx.storage),\n StorageWriter.layer(ctx.storage),\n QueryRunner.layer(ctx.runQuery),\n MutationRunner.layer(ctx.runMutation),\n Layer.succeed(\n MutationCtx.MutationCtx<\n DataModel.ToConvex<DataModel.FromSchema<Schema>>\n >(),\n ctx,\n ),\n );\n\nexport type MutationServices<Schema extends DatabaseSchema.AnyWithProps> =\n | DatabaseReader.DatabaseReader<Schema>\n | DatabaseWriter.DatabaseWriter<Schema>\n | Auth.Auth\n | Scheduler.Scheduler\n | StorageReader\n | StorageWriter\n | QueryRunner.QueryRunner\n | MutationRunner.MutationRunner\n | MutationCtx.MutationCtx<DataModel.ToConvex<DataModel.FromSchema<Schema>>>;\n\nconst mutationFunction = <\n Schema extends DatabaseSchema.AnyWithProps,\n Args,\n ConvexArgs extends DefaultFunctionArgs,\n Returns,\n ConvexReturns,\n E,\n>(\n schema: Schema,\n {\n args,\n returns,\n handler,\n }: {\n args: Schema.Schema<Args, ConvexArgs>;\n returns: Schema.Schema<Returns, ConvexReturns>;\n handler: (a: Args) => Effect.Effect<Returns, E, MutationServices<Schema>>;\n },\n) => ({\n args: SchemaToValidator.compileArgsSchema(args),\n returns: SchemaToValidator.compileReturnsSchema(returns),\n handler: (\n ctx: GenericMutationCtx<DataModel.ToConvex<DataModel.FromSchema<Schema>>>,\n actualArgs: ConvexArgs,\n ): Promise<ConvexReturns> =>\n pipe(\n actualArgs,\n Schema.decode(args),\n Effect.orDie,\n Effect.andThen((decodedArgs) =>\n handler(decodedArgs).pipe(Effect.provide(mutationLayer(schema, ctx))),\n ),\n Effect.andThen((convexReturns) =>\n Schema.encodeUnknown(returns)(convexReturns),\n ),\n Effect.runPromise,\n ),\n});\n\nconst actionFunction = <\n Schema extends DatabaseSchema.AnyWithProps,\n Args,\n ConvexArgs extends DefaultFunctionArgs,\n Returns,\n ConvexReturns,\n E,\n>({\n args,\n returns,\n handler,\n}: {\n args: Schema.Schema<Args, ConvexArgs>;\n returns: Schema.Schema<Returns, ConvexReturns>;\n handler: (\n a: Args,\n ) => Effect.Effect<\n Returns,\n E,\n | Scheduler.Scheduler\n | Auth.Auth\n | StorageReader\n | StorageWriter\n | StorageActionWriter\n | QueryRunner.QueryRunner\n | MutationRunner.MutationRunner\n | ActionRunner.ActionRunner\n | VectorSearch.VectorSearch<DataModel.FromSchema<Schema>>\n | ActionCtx.ActionCtx<DataModel.ToConvex<DataModel.FromSchema<Schema>>>\n >;\n}) => ({\n args: SchemaToValidator.compileArgsSchema(args),\n returns: SchemaToValidator.compileReturnsSchema(returns),\n handler: (\n ctx: GenericActionCtx<DataModel.ToConvex<DataModel.FromSchema<Schema>>>,\n actualArgs: ConvexArgs,\n ): Promise<ConvexReturns> =>\n pipe(\n actualArgs,\n Schema.decode(args),\n Effect.orDie,\n Effect.andThen((decodedArgs) =>\n pipe(\n handler(decodedArgs),\n Effect.provide(\n Layer.mergeAll(\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 QueryRunner.layer(ctx.runQuery),\n MutationRunner.layer(ctx.runMutation),\n ActionRunner.layer(ctx.runAction),\n VectorSearch.layer(ctx.vectorSearch),\n Layer.succeed(\n ActionCtx.ActionCtx<\n DataModel.ToConvex<DataModel.FromSchema<Schema>>\n >(),\n ctx,\n ),\n ),\n ),\n ),\n ),\n Effect.andThen((convexReturns) =>\n Schema.encodeUnknown(returns)(convexReturns),\n ),\n Effect.runPromise,\n ),\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA6FA,MAAa,QACX,SAEA,OAAO,IAAI,aAAa;CACtB,MAAM,WAAW,OAAOA;CACxB,MAAM,oBAAoB,OAAO,IAAI,IAAI,SAAS;CAClD,MAAM,EAAE,KAAK,uBAAuB,OAAOC,MAA8B;AAEzE,QAAO,OAAO,MAAM,MAClB,mBACD,CAAC,KACA,MAAM,gBAAkE,EACxE,MAAM,KAAK,qBACT,OAAO,WAAW,wBAAwB,CAC3C,EACD,MAAM,KAAK,mBACT,OAAO,QACL,UACE,mBACAC,iBACC,iBAAiB,uBAAuB,KAAK,aAAa,CAC5D,CACF,CACF,EACD,MAAM,WACP;EACD,CAAC,KAAK,OAAO,QAAQ,KAAK,EAAE,OAAO,QAAQ;AAE/C,MAAM,0BACJ,KACA,EAAE,WAAW,cAEb,MAAM,MAAM,UAAU,aAAa,CAAC,KAClC,MAAM,KAAK,eAAe;AAOxB,QANwB,MAAM,MAAM,UAAU,mBAAmB,CAAC,KAChE,MAAM,KAAK,gBAAgB,aAAa,EACxC,MAAM,KAAK,kBAAkB,qBAAqB,EAClD,MAAM,WACP,CAGC,cAAc,IAAI,gBAAgB;EAChC,MAAM,UAAU;EAChB,SAAS,UAAU;EACnB;EACD,CAAC,CACH;EACD,EACF,MAAM,KAAK,kBAAkB;AAO3B,QANwB,MAAM,MAAM,UAAU,mBAAmB,CAAC,KAChE,MAAM,KAAK,gBAAgB,gBAAgB,EAC3C,MAAM,KAAK,kBAAkB,wBAAwB,EACrD,MAAM,WACP,CAGC,iBAAiB,IAAI,gBAAgB;EACnC,MAAM,UAAU;EAChB,SAAS,UAAU;EACnB;EACD,CAAC,CACH;EACD,EACF,MAAM,KAAK,gBAAgB;AAOzB,QANwB,MAAM,MAAM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,IAAI,CAAC,CAAC,CACtE,EACD,OAAO,SAAS,kBACd,OAAO,cAAc,QAAQ,CAAC,cAAc,CAC7C,EACD,OAAO,WACR;CACJ;AAED,MAAM,kBAOJ,EACA,MACA,SACA,eAoBK;CACL,MAAMD,kBAAoC,KAAK;CAC/C,SAASC,qBAAuC,QAAQ;CACxD,UACE,KACA,eAEA,KACE,YACA,OAAO,OAAO,KAAK,EACnB,OAAO,OACP,OAAO,SAAS,gBACd,KACE,QAAQ,YAAY,EACpB,OAAO,QACL,MAAM,SACJO,QAAgB,IAAI,UAAU,EAC9BL,QAAW,IAAI,KAAK,EACpBC,gBAAc,MAAM,IAAI,QAAQ,EAChCK,gBAAc,MAAM,IAAI,QAAQ,EAChCG,sBAAoB,MAAM,IAAI,QAAQ,EACtCP,QAAkB,IAAI,SAAS,EAC/BK,QAAqB,IAAI,YAAY,EACrCG,MAAmB,IAAI,UAAU,EACjCC,QAAmB,IAAI,aAAa,EACpC,MAAM,QACJC,WAEG,EACH,IACD,CACF,CACF,CACF,CACF,EACD,OAAO,SAAS,kBACd,OAAO,cAAc,QAAQ,CAAC,cAAc,CAC7C,EACD,OAAO,WACR;CACJ"}
|
|
1
|
+
{"version":3,"file":"RegisteredFunctions.js","names":["Registry.Registry","Impl.Impl","RegistryItem.isRegistryItem","SchemaToValidator.compileArgsSchema","SchemaToValidator.compileReturnsSchema","DatabaseReader.layer","Auth.layer","StorageReader","QueryRunner.layer","QueryCtx.QueryCtx","DatabaseWriter.layer","Scheduler.layer","StorageWriter","MutationRunner.layer","MutationCtx.MutationCtx","StorageActionWriter","ActionRunner.layer","VectorSearch.layer","ActionCtx.ActionCtx"],"sources":["../src/RegisteredFunctions.ts"],"sourcesContent":["import type * as FunctionSpec from \"@confect/core/FunctionSpec\";\nimport type * as GroupSpec from \"@confect/core/GroupSpec\";\nimport type * as Spec from \"@confect/core/Spec\";\nimport {\n actionGeneric,\n type DefaultFunctionArgs,\n type FunctionVisibility,\n type GenericActionCtx,\n type GenericMutationCtx,\n type GenericQueryCtx,\n internalActionGeneric,\n internalMutationGeneric,\n internalQueryGeneric,\n mutationGeneric,\n queryGeneric,\n type RegisteredAction,\n type RegisteredMutation,\n type RegisteredQuery,\n} from \"convex/server\";\nimport { Effect, Layer, Match, pipe, Ref, Schema, type Types } from \"effect\";\nimport * as ActionCtx from \"./ActionCtx\";\nimport * as ActionRunner from \"./ActionRunner\";\nimport type * as Api from \"./Api\";\nimport * as Auth from \"./Auth\";\nimport * as DatabaseReader from \"./DatabaseReader\";\nimport type * as DatabaseSchema from \"./DatabaseSchema\";\nimport * as DatabaseWriter from \"./DatabaseWriter\";\nimport type * as DataModel from \"./DataModel\";\nimport * as Impl from \"./Impl\";\nimport { mapLeaves } from \"./internal/utils\";\nimport * as MutationCtx from \"./MutationCtx\";\nimport * as MutationRunner from \"./MutationRunner\";\nimport * as QueryCtx from \"./QueryCtx\";\nimport * as QueryRunner from \"./QueryRunner\";\nimport * as Registry from \"./Registry\";\nimport * as RegistryItem from \"./RegistryItem\";\nimport * as Scheduler from \"./Scheduler\";\nimport * as SchemaToValidator from \"./SchemaToValidator\";\nimport { StorageActionWriter, StorageReader, StorageWriter } from \"./Storage\";\nimport * as VectorSearch from \"./VectorSearch\";\n\nexport type RegisteredFunction =\n | RegisteredQuery<FunctionVisibility, DefaultFunctionArgs, any>\n | RegisteredMutation<FunctionVisibility, DefaultFunctionArgs, any>\n | RegisteredAction<FunctionVisibility, DefaultFunctionArgs, any>;\n\nexport type RegisteredFunctions<Spec_ extends Spec.AnyWithProps> =\n Types.Simplify<RegisteredFunctionsHelper<Spec.Groups<Spec_>>>;\n\ntype RegisteredFunctionsHelper<Groups extends GroupSpec.AnyWithProps> = {\n [GroupName in GroupSpec.Name<Groups>]: GroupSpec.WithName<\n Groups,\n GroupName\n > extends infer Group extends GroupSpec.AnyWithProps\n ? GroupSpec.Groups<Group> extends infer SubGroups extends\n GroupSpec.AnyWithProps\n ? Types.Simplify<\n RegisteredFunctionsHelper<SubGroups> & {\n [FunctionName in FunctionSpec.Name<\n GroupSpec.Functions<Group>\n >]: FunctionSpec.WithName<\n GroupSpec.Functions<Group>,\n FunctionName\n > extends infer Function extends FunctionSpec.AnyWithProps\n ? FunctionSpec.RegisteredFunction<Function>\n : never;\n }\n >\n : {\n [FunctionName in FunctionSpec.Name<\n GroupSpec.Functions<Group>\n >]: FunctionSpec.WithName<\n GroupSpec.Functions<Group>,\n FunctionName\n > extends infer Function extends FunctionSpec.AnyWithProps\n ? FunctionSpec.RegisteredFunction<Function>\n : never;\n }\n : never;\n};\n\nexport interface AnyWithProps {\n readonly [key: string]: RegisteredFunction | AnyWithProps;\n}\n\nexport const make = <Api_ extends Api.AnyWithProps>(\n impl: Layer.Layer<Impl.Impl<Api_, \"Finalized\">>,\n) =>\n Effect.gen(function* () {\n const registry = yield* Registry.Registry;\n const functionImplItems = yield* Ref.get(registry);\n const { api, finalizationStatus } = yield* Impl.Impl<Api_, \"Finalized\">();\n\n return yield* Match.value(\n finalizationStatus as Impl.FinalizationStatus,\n ).pipe(\n Match.withReturnType<Effect.Effect<RegisteredFunctions<Api_[\"spec\"]>>>(),\n Match.when(\"Unfinalized\", () =>\n Effect.dieMessage(\"Impl is not finalized\"),\n ),\n Match.when(\"Finalized\", () =>\n Effect.succeed(\n mapLeaves<RegistryItem.AnyWithProps, RegisteredFunction>(\n functionImplItems,\n RegistryItem.isRegistryItem,\n (registryItem) => makeRegisteredFunction(api, registryItem),\n ) as RegisteredFunctions<Api_[\"spec\"]>,\n ),\n ),\n Match.exhaustive,\n );\n }).pipe(Effect.provide(impl), Effect.runSync);\n\nconst makeRegisteredFunction = <Api_ extends Api.AnyWithProps>(\n api: Api_,\n { function_, handler }: RegistryItem.AnyWithProps,\n): RegisteredFunction =>\n Match.value(function_.functionType).pipe(\n Match.when(\"query\", () => {\n const genericFunction = Match.value(function_.functionVisibility).pipe(\n Match.when(\"public\", () => queryGeneric),\n Match.when(\"internal\", () => internalQueryGeneric),\n Match.exhaustive,\n );\n\n return genericFunction(\n queryFunction(api.databaseSchema, {\n args: function_.args,\n returns: function_.returns,\n handler,\n }),\n );\n }),\n Match.when(\"mutation\", () => {\n const genericFunction = Match.value(function_.functionVisibility).pipe(\n Match.when(\"public\", () => mutationGeneric),\n Match.when(\"internal\", () => internalMutationGeneric),\n Match.exhaustive,\n );\n\n return genericFunction(\n mutationFunction(api.databaseSchema, {\n args: function_.args,\n returns: function_.returns,\n handler,\n }),\n );\n }),\n Match.when(\"action\", () => {\n const genericFunction = Match.value(function_.functionVisibility).pipe(\n Match.when(\"public\", () => actionGeneric),\n Match.when(\"internal\", () => internalActionGeneric),\n Match.exhaustive,\n );\n\n return genericFunction(\n actionFunction({\n args: function_.args,\n returns: function_.returns,\n handler,\n }),\n );\n }),\n Match.exhaustive,\n );\n\nconst queryFunction = <\n Schema extends DatabaseSchema.AnyWithProps,\n Args,\n ConvexArgs extends DefaultFunctionArgs,\n Returns,\n ConvexReturns,\n E,\n>(\n schema: Schema,\n {\n args,\n returns,\n handler,\n }: {\n args: Schema.Schema<Args, ConvexArgs>;\n returns: Schema.Schema<Returns, ConvexReturns>;\n handler: (\n a: Args,\n ) => Effect.Effect<\n Returns,\n E,\n | DatabaseReader.DatabaseReader<Schema>\n | Auth.Auth\n | StorageReader\n | QueryRunner.QueryRunner\n | QueryCtx.QueryCtx<DataModel.ToConvex<DataModel.FromSchema<Schema>>>\n >;\n },\n) => ({\n args: SchemaToValidator.compileArgsSchema(args),\n returns: SchemaToValidator.compileReturnsSchema(returns),\n handler: (\n ctx: GenericQueryCtx<DataModel.ToConvex<DataModel.FromSchema<Schema>>>,\n actualArgs: ConvexArgs,\n ): Promise<ConvexReturns> =>\n pipe(\n actualArgs,\n Schema.decode(args),\n Effect.orDie,\n Effect.andThen((decodedArgs) =>\n pipe(\n handler(decodedArgs),\n Effect.provide(\n Layer.mergeAll(\n DatabaseReader.layer(schema, ctx.db),\n Auth.layer(ctx.auth),\n StorageReader.layer(ctx.storage),\n QueryRunner.layer(ctx.runQuery),\n Layer.succeed(\n QueryCtx.QueryCtx<\n DataModel.ToConvex<DataModel.FromSchema<Schema>>\n >(),\n ctx,\n ),\n ),\n ),\n ),\n ),\n Effect.andThen((convexReturns) =>\n Schema.encodeUnknown(returns)(convexReturns),\n ),\n Effect.runPromise,\n ),\n});\n\nexport const mutationLayer = <Schema extends DatabaseSchema.AnyWithProps>(\n schema: Schema,\n ctx: GenericMutationCtx<DataModel.ToConvex<DataModel.FromSchema<Schema>>>,\n) =>\n Layer.mergeAll(\n DatabaseReader.layer(schema, ctx.db),\n DatabaseWriter.layer(schema, ctx.db),\n Auth.layer(ctx.auth),\n Scheduler.layer(ctx.scheduler),\n StorageReader.layer(ctx.storage),\n StorageWriter.layer(ctx.storage),\n QueryRunner.layer(ctx.runQuery),\n MutationRunner.layer(ctx.runMutation),\n Layer.succeed(\n MutationCtx.MutationCtx<\n DataModel.ToConvex<DataModel.FromSchema<Schema>>\n >(),\n ctx,\n ),\n );\n\nexport type MutationServices<Schema extends DatabaseSchema.AnyWithProps> =\n | DatabaseReader.DatabaseReader<Schema>\n | DatabaseWriter.DatabaseWriter<Schema>\n | Auth.Auth\n | Scheduler.Scheduler\n | StorageReader\n | StorageWriter\n | QueryRunner.QueryRunner\n | MutationRunner.MutationRunner\n | MutationCtx.MutationCtx<DataModel.ToConvex<DataModel.FromSchema<Schema>>>;\n\nconst mutationFunction = <\n Schema extends DatabaseSchema.AnyWithProps,\n Args,\n ConvexArgs extends DefaultFunctionArgs,\n Returns,\n ConvexReturns,\n E,\n>(\n schema: Schema,\n {\n args,\n returns,\n handler,\n }: {\n args: Schema.Schema<Args, ConvexArgs>;\n returns: Schema.Schema<Returns, ConvexReturns>;\n handler: (a: Args) => Effect.Effect<Returns, E, MutationServices<Schema>>;\n },\n) => ({\n args: SchemaToValidator.compileArgsSchema(args),\n returns: SchemaToValidator.compileReturnsSchema(returns),\n handler: (\n ctx: GenericMutationCtx<DataModel.ToConvex<DataModel.FromSchema<Schema>>>,\n actualArgs: ConvexArgs,\n ): Promise<ConvexReturns> =>\n pipe(\n actualArgs,\n Schema.decode(args),\n Effect.orDie,\n Effect.andThen((decodedArgs) =>\n handler(decodedArgs).pipe(Effect.provide(mutationLayer(schema, ctx))),\n ),\n Effect.andThen((convexReturns) =>\n Schema.encodeUnknown(returns)(convexReturns),\n ),\n Effect.runPromise,\n ),\n});\n\nconst actionFunction = <\n Schema extends DatabaseSchema.AnyWithProps,\n Args,\n ConvexArgs extends DefaultFunctionArgs,\n Returns,\n ConvexReturns,\n E,\n>({\n args,\n returns,\n handler,\n}: {\n args: Schema.Schema<Args, ConvexArgs>;\n returns: Schema.Schema<Returns, ConvexReturns>;\n handler: (\n a: Args,\n ) => Effect.Effect<\n Returns,\n E,\n | Scheduler.Scheduler\n | Auth.Auth\n | StorageReader\n | StorageWriter\n | StorageActionWriter\n | QueryRunner.QueryRunner\n | MutationRunner.MutationRunner\n | ActionRunner.ActionRunner\n | VectorSearch.VectorSearch<DataModel.FromSchema<Schema>>\n | ActionCtx.ActionCtx<DataModel.ToConvex<DataModel.FromSchema<Schema>>>\n >;\n}) => ({\n args: SchemaToValidator.compileArgsSchema(args),\n returns: SchemaToValidator.compileReturnsSchema(returns),\n handler: (\n ctx: GenericActionCtx<DataModel.ToConvex<DataModel.FromSchema<Schema>>>,\n actualArgs: ConvexArgs,\n ): Promise<ConvexReturns> =>\n pipe(\n actualArgs,\n Schema.decode(args),\n Effect.orDie,\n Effect.andThen((decodedArgs) =>\n pipe(\n handler(decodedArgs),\n Effect.provide(\n Layer.mergeAll(\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 QueryRunner.layer(ctx.runQuery),\n MutationRunner.layer(ctx.runMutation),\n ActionRunner.layer(ctx.runAction),\n VectorSearch.layer(ctx.vectorSearch),\n Layer.succeed(\n ActionCtx.ActionCtx<\n DataModel.ToConvex<DataModel.FromSchema<Schema>>\n >(),\n ctx,\n ),\n ),\n ),\n ),\n ),\n Effect.andThen((convexReturns) =>\n Schema.encodeUnknown(returns)(convexReturns),\n ),\n Effect.runPromise,\n ),\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAqFA,MAAa,QACX,SAEA,OAAO,IAAI,aAAa;CACtB,MAAM,WAAW,OAAOA;CACxB,MAAM,oBAAoB,OAAO,IAAI,IAAI,SAAS;CAClD,MAAM,EAAE,KAAK,uBAAuB,OAAOC,MAA8B;AAEzE,QAAO,OAAO,MAAM,MAClB,mBACD,CAAC,KACA,MAAM,gBAAkE,EACxE,MAAM,KAAK,qBACT,OAAO,WAAW,wBAAwB,CAC3C,EACD,MAAM,KAAK,mBACT,OAAO,QACL,UACE,mBACAC,iBACC,iBAAiB,uBAAuB,KAAK,aAAa,CAC5D,CACF,CACF,EACD,MAAM,WACP;EACD,CAAC,KAAK,OAAO,QAAQ,KAAK,EAAE,OAAO,QAAQ;AAE/C,MAAM,0BACJ,KACA,EAAE,WAAW,cAEb,MAAM,MAAM,UAAU,aAAa,CAAC,KAClC,MAAM,KAAK,eAAe;AAOxB,QANwB,MAAM,MAAM,UAAU,mBAAmB,CAAC,KAChE,MAAM,KAAK,gBAAgB,aAAa,EACxC,MAAM,KAAK,kBAAkB,qBAAqB,EAClD,MAAM,WACP,CAGC,cAAc,IAAI,gBAAgB;EAChC,MAAM,UAAU;EAChB,SAAS,UAAU;EACnB;EACD,CAAC,CACH;EACD,EACF,MAAM,KAAK,kBAAkB;AAO3B,QANwB,MAAM,MAAM,UAAU,mBAAmB,CAAC,KAChE,MAAM,KAAK,gBAAgB,gBAAgB,EAC3C,MAAM,KAAK,kBAAkB,wBAAwB,EACrD,MAAM,WACP,CAGC,iBAAiB,IAAI,gBAAgB;EACnC,MAAM,UAAU;EAChB,SAAS,UAAU;EACnB;EACD,CAAC,CACH;EACD,EACF,MAAM,KAAK,gBAAgB;AAOzB,QANwB,M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Ac,QAAQ,IAAI,CAAC,CAAC,CACtE,EACD,OAAO,SAAS,kBACd,OAAO,cAAc,QAAQ,CAAC,cAAc,CAC7C,EACD,OAAO,WACR;CACJ;AAED,MAAM,kBAOJ,EACA,MACA,SACA,eAoBK;CACL,MAAMD,kBAAoC,KAAK;CAC/C,SAASC,qBAAuC,QAAQ;CACxD,UACE,KACA,eAEA,KACE,YACA,OAAO,OAAO,KAAK,EACnB,OAAO,OACP,OAAO,SAAS,gBACd,KACE,QAAQ,YAAY,EACpB,OAAO,QACL,MAAM,SACJO,QAAgB,IAAI,UAAU,EAC9BL,QAAW,IAAI,KAAK,EACpBC,gBAAc,MAAM,IAAI,QAAQ,EAChCK,gBAAc,MAAM,IAAI,QAAQ,EAChCG,sBAAoB,MAAM,IAAI,QAAQ,EACtCP,QAAkB,IAAI,SAAS,EAC/BK,QAAqB,IAAI,YAAY,EACrCG,MAAmB,IAAI,UAAU,EACjCC,QAAmB,IAAI,aAAa,EACpC,MAAM,QACJC,WAEG,EACH,IACD,CACF,CACF,CACF,CACF,EACD,OAAO,SAAS,kBACd,OAAO,cAAc,QAAQ,CAAC,cAAc,CAC7C,EACD,OAAO,WACR;CACJ"}
|
package/dist/Scheduler.d.ts
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { Context, DateTime, Duration, Effect, Layer } from "effect";
|
|
2
2
|
import { OptionalRestArgs, SchedulableFunctionReference, Scheduler as Scheduler$1 } from "convex/server";
|
|
3
|
-
import * as
|
|
3
|
+
import * as convex_values3 from "convex/values";
|
|
4
4
|
|
|
5
5
|
//#region src/Scheduler.d.ts
|
|
6
6
|
declare namespace Scheduler_d_exports {
|
|
7
7
|
export { Scheduler, layer };
|
|
8
8
|
}
|
|
9
9
|
declare const Scheduler: Context.Tag<{
|
|
10
|
-
runAfter: <FuncRef extends SchedulableFunctionReference>(delay: Duration.Duration, functionReference: FuncRef, ...args: OptionalRestArgs<FuncRef>) => Effect.Effect<
|
|
11
|
-
runAt: <FuncRef extends SchedulableFunctionReference>(dateTime: DateTime.DateTime, functionReference: FuncRef, ...args: OptionalRestArgs<FuncRef>) => Effect.Effect<
|
|
10
|
+
runAfter: <FuncRef extends SchedulableFunctionReference>(delay: Duration.Duration, functionReference: FuncRef, ...args: OptionalRestArgs<FuncRef>) => Effect.Effect<convex_values3.GenericId<"_scheduled_functions">, never, never>;
|
|
11
|
+
runAt: <FuncRef extends SchedulableFunctionReference>(dateTime: DateTime.DateTime, functionReference: FuncRef, ...args: OptionalRestArgs<FuncRef>) => Effect.Effect<convex_values3.GenericId<"_scheduled_functions">, never, never>;
|
|
12
12
|
}, {
|
|
13
|
-
runAfter: <FuncRef extends SchedulableFunctionReference>(delay: Duration.Duration, functionReference: FuncRef, ...args: OptionalRestArgs<FuncRef>) => Effect.Effect<
|
|
14
|
-
runAt: <FuncRef extends SchedulableFunctionReference>(dateTime: DateTime.DateTime, functionReference: FuncRef, ...args: OptionalRestArgs<FuncRef>) => Effect.Effect<
|
|
13
|
+
runAfter: <FuncRef extends SchedulableFunctionReference>(delay: Duration.Duration, functionReference: FuncRef, ...args: OptionalRestArgs<FuncRef>) => Effect.Effect<convex_values3.GenericId<"_scheduled_functions">, never, never>;
|
|
14
|
+
runAt: <FuncRef extends SchedulableFunctionReference>(dateTime: DateTime.DateTime, functionReference: FuncRef, ...args: OptionalRestArgs<FuncRef>) => Effect.Effect<convex_values3.GenericId<"_scheduled_functions">, never, never>;
|
|
15
15
|
}>;
|
|
16
16
|
type Scheduler = typeof Scheduler.Identifier;
|
|
17
17
|
declare const layer: (scheduler: Scheduler$1) => Layer.Layer<{
|
|
18
|
-
runAfter: <FuncRef extends SchedulableFunctionReference>(delay: Duration.Duration, functionReference: FuncRef, ...args: OptionalRestArgs<FuncRef>) => Effect.Effect<
|
|
19
|
-
runAt: <FuncRef extends SchedulableFunctionReference>(dateTime: DateTime.DateTime, functionReference: FuncRef, ...args: OptionalRestArgs<FuncRef>) => Effect.Effect<
|
|
18
|
+
runAfter: <FuncRef extends SchedulableFunctionReference>(delay: Duration.Duration, functionReference: FuncRef, ...args: OptionalRestArgs<FuncRef>) => Effect.Effect<convex_values3.GenericId<"_scheduled_functions">, never, never>;
|
|
19
|
+
runAt: <FuncRef extends SchedulableFunctionReference>(dateTime: DateTime.DateTime, functionReference: FuncRef, ...args: OptionalRestArgs<FuncRef>) => Effect.Effect<convex_values3.GenericId<"_scheduled_functions">, never, never>;
|
|
20
20
|
}, never, never>;
|
|
21
21
|
//#endregion
|
|
22
22
|
export { Scheduler, Scheduler_d_exports, layer };
|
package/dist/Scheduler.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Scheduler.d.ts","names":[],"sources":["../src/Scheduler.ts"],"sourcesContent":[],"mappings":";;;;;;;;cAgCa,WAAS,OAAA,CAAA;6BAxBO,qCAClB,QAAA,CAAS,6BACG,kBACV,iBAAiB,aAAQ,MAAA,CAAA,OAAT,
|
|
1
|
+
{"version":3,"file":"Scheduler.d.ts","names":[],"sources":["../src/Scheduler.ts"],"sourcesContent":[],"mappings":";;;;;;;;cAgCa,WAAS,OAAA,CAAA;6BAxBO,qCAClB,QAAA,CAAS,6BACG,kBACV,iBAAiB,aAAQ,MAAA,CAAA,OAAT,cAAA,CAAS;0BAQZ,wCACZ,QAAA,CAAS,6BACA,kBACV,iBAAiB,aAAQ,MAAA,CAAA,OAAT,cAAA,CAAS;;6BAdT,qCAClB,QAAA,CAAS,6BACG,kBACV,iBAAiB,aAAQ,MAAA,CAAA,OAAT,cAAA,CAAS;0BAQZ,wCACZ,QAAA,CAAS,6BACA,kBACV,iBAAiB,aAAQ,MAAA,CAAA,OAAT,cAAA,CAAS;;KAa1B,SAAA,UAAmB,SAAA,CAAU;AAH5B,cAKA,KAHZ,EAAA,CAAA,SAAA,EAGgC,WAHhC,EAAA,GAG+C,KAAA,CAAA,KAH/C,CAAA;EA1B4B,QAAA,EAAA,CAAA,gBAAA,4BAAA,CAAA,CAAA,KAAA,EAClB,QAAA,CAAS,QADS,EAAA,iBAAA,EAEN,OAFM,EAAA,GAAA,IAAA,EAGhB,gBAHgB,CAGC,OAHD,CAAA,EAAA,GAGS,MAAA,CAAA,MAHT,CAGA,cAAA,CAAS,SAHT,CAAA,sBAAA,CAAA,EAAA,KAAA,EAAA,KAAA,CAAA;EAClB,KAAA,EAAS,CAAA,gBAUM,4BAVN,CAAA,CAAA,QAAA,EAWN,QAAA,CAAS,QAXH,EAAA,iBAAA,EAYG,OAZH,EAAA,GAAA,IAAA,EAaP,gBAbO,CAaU,OAbV,CAAA,EAAA,GAakB,MAAA,CAAA,MAblB,CAaS,cAAA,CAAS,SAblB,CAAA,sBAAA,CAAA,EAAA,KAAA,EAAA,KAAA,CAAA;CACG,EAAA,KAAA,EAAA,KAAA,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaToValidator.d.ts","names":[],"sources":["../src/SchemaToValidator.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;cAmDa,2DACC,MAAA,CAAO,OAAO,cAAc,iBACvC;cAkBU,0DACH,MAAA,CAAO,OAAO,cAAc,iBACnC;;;;KAQS,gDACU,MAAA,CAAO,MAAA,CAAO,gBAElC,iBAAiB,iDACb,8BACA,6BACA;
|
|
1
|
+
{"version":3,"file":"SchemaToValidator.d.ts","names":[],"sources":["../src/SchemaToValidator.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;cAmDa,2DACC,MAAA,CAAO,OAAO,cAAc,iBACvC;cAkBU,0DACH,MAAA,CAAO,OAAO,cAAc,iBACnC;;;;KAQS,gDACU,MAAA,CAAO,MAAA,CAAO,gBAElC,iBAAiB,iDACb,8BACA,6BACA;cAGO,yCACS,MAAA,CAAO,MAAA,CAAO,sBAE1B,gBACP,4BAA4B;KAmBnB,aAAA,wCAKR,cACA,qBACA;KAGC,kBAAA,YAA8B;KAEvB,mBAAA;0BACc;;KAGd,yBACV,YAAY,qBACR,QACC,gCAEC,MAAM,qBACJ,QAC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CAAA,CAhcnB;EAApB,IAAA,OAAU,CAAA,CAAA,EAAA,MAAA;;cAwc3B,wDAvc4B,EAAA,IAAA,CAAA,gBAAA,CAAA,MAAA,EAAA,GAAA,CAAA,GAAA,CAAA,CAAA,CAAA,CAAA,IAAA,sBAAA,EAAA,EAAA,CAAA,CAAA,CAAA,SAAA,IAAA,GAAA,IAAA,GAAA,iBAAA,OAAA,KAAA,SAAA,MAAA,GAAA,KAAA,IAAA,IAAA,EAAA,CAAA,EAAA,EAAA,uBAAA,GAAA;EAAf,SAAA,IAAA,EAAA,qDAAA;CACW,WAAA,EAAA,CAAA;AAAT,cAwcH,mDAAA,SAA4D,wDAAA,CAxczD;EACC,IAAA,OAAA,CAAA,CAAA,EAAA,MAAA;;cA+chB,8CA7ckB,EAAA,IAAA,CAAA,gBAAA,CAAA,MAAA,EAAA,GAAA,CAAA,GAAA,CAAA,CAAA,CAAA,CAAA,IAAA,sBAAA,EAAA,EAAA,CAAA,CAAA,CAAA,SAAA,IAAA,GAAA,IAAA,GAAA,iBAAA,OAAA,KAAA,SAAA,MAAA,GAAA,KAAA,IAAA,IAAA,EAAA,CAAA,EAAA,EAAA,uBAAA,GAAA;EACC,SAAA,IAAA,EAAA,2CAAA;CACQ,WAAA,EAAA,CAAA;AAAR,cA6cP,yCAAA,SAAkD,8CAAA,CA7c3C;EACwB,IAAA,OAAA,CAAA,CAAA,EAAA,MAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaToValidator.js","names":["GenericId"],"sources":["../src/SchemaToValidator.ts"],"sourcesContent":["import type {\n PropertyValidators,\n Validator,\n VAny,\n VArray,\n VBoolean,\n VBytes,\n VFloat64,\n VId,\n VInt64,\n VLiteral,\n VNull,\n VObject,\n VOptional,\n VRecord,\n VString,\n VUnion,\n} from \"convex/values\";\nimport { v } from \"convex/values\";\nimport {\n Array,\n Cause,\n Data,\n Effect,\n Exit,\n Match,\n Number,\n Option,\n type ParseResult,\n pipe,\n Predicate,\n Schema,\n SchemaAST,\n String,\n} from \"effect\";\n\nimport * as GenericId from \"@confect/core/GenericId\";\nimport type {\n DeepMutable,\n IsAny,\n IsOptional,\n IsRecord,\n IsRecursive,\n IsUnion,\n IsValueLiteral,\n TypeError,\n UnionToTuple,\n} from \"@confect/core/Types\";\n\n// Args\n\nexport const compileArgsSchema = <ConfectValue, ConvexValue>(\n argsSchema: Schema.Schema<ConfectValue, ConvexValue>,\n): PropertyValidators => {\n const ast = Schema.encodedSchema(argsSchema).ast;\n\n return pipe(\n ast,\n Match.value,\n Match.tag(\"TypeLiteral\", (typeLiteralAst) =>\n Array.isEmptyReadonlyArray(typeLiteralAst.indexSignatures)\n ? handlePropertySignatures(typeLiteralAst)\n : Effect.fail(new IndexSignaturesAreNotSupportedError()),\n ),\n Match.orElse(() => Effect.fail(new TopLevelMustBeObjectError())),\n runSyncThrow,\n );\n};\n\n// Returns\n\nexport const compileReturnsSchema = <ConfectValue, ConvexValue>(\n schema: Schema.Schema<ConfectValue, ConvexValue>,\n): Validator<any, any, any> =>\n runSyncThrow(compileAst(Schema.encodedSchema(schema).ast));\n\n// Table\n\n/**\n * Convert a table `Schema` to a table `Validator`.\n */\nexport type TableSchemaToTableValidator<\n TableSchema extends Schema.Schema.AnyNoContext,\n> =\n ValueToValidator<TableSchema[\"Encoded\"]> extends infer Vd extends\n | VObject<any, any, any, any>\n | VUnion<any, any, any, any>\n ? Vd\n : // TODO: Add type error message\n never;\n\nexport const compileTableSchema = <\n TableSchema extends Schema.Schema.AnyNoContext,\n>(\n schema: TableSchema,\n): TableSchemaToTableValidator<TableSchema> => {\n const ast = Schema.encodedSchema(schema).ast;\n\n return pipe(\n ast,\n Match.value,\n Match.tag(\"TypeLiteral\", ({ indexSignatures }) =>\n Array.isEmptyReadonlyArray(indexSignatures)\n ? (compileAst(ast) as Effect.Effect<any>)\n : Effect.fail(new IndexSignaturesAreNotSupportedError()),\n ),\n Match.tag(\"Union\", (unionAst) => compileAst(unionAst)),\n Match.orElse(() => Effect.fail(new TopLevelMustBeObjectOrUnionError())),\n runSyncThrow,\n );\n};\n\n// Compiler\n\nexport type ReadonlyValue =\n | string\n | number\n | bigint\n | boolean\n | ArrayBuffer\n | ReadonlyArrayValue\n | ReadonlyRecordValue\n | null;\n\ntype ReadonlyArrayValue = readonly ReadonlyValue[];\n\nexport type ReadonlyRecordValue = {\n readonly [key: string]: ReadonlyValue | undefined;\n};\n\nexport type ValueToValidator<Vl> =\n IsRecursive<Vl> extends true\n ? VAny\n : [Vl] extends [never]\n ? never\n : IsAny<Vl> extends true\n ? VAny\n : [Vl] extends [ReadonlyValue]\n ? Vl extends {\n __tableName: infer TableName extends string;\n }\n ? VId<GenericId.GenericId<TableName>>\n : IsValueLiteral<Vl> extends true\n ? VLiteral<Vl>\n : [Vl] extends [null]\n ? VNull\n : [Vl] extends [boolean]\n ? VBoolean\n : IsUnion<Vl> extends true\n ? UnionValueToValidator<Vl>\n : [Vl] extends [number]\n ? VFloat64\n : [Vl] extends [bigint]\n ? VInt64\n : [Vl] extends [string]\n ? VString\n : [Vl] extends [ArrayBuffer]\n ? VBytes\n : Vl extends ReadonlyArray<ReadonlyValue>\n ? ArrayValueToValidator<Vl>\n : Vl extends ReadonlyRecordValue\n ? RecordValueToValidator<Vl>\n : TypeError<\"Unexpected value\", Vl>\n : TypeError<\"Provided value is not a valid Convex value\", Vl>;\n\ntype ArrayValueToValidator<Vl extends ReadonlyArray<ReadonlyValue>> =\n Vl extends ReadonlyArray<infer El extends ReadonlyValue>\n ? ValueToValidator<El> extends infer Vd extends Validator<any, any, any>\n ? VArray<DeepMutable<El[]>, Vd>\n : never\n : never;\n\ntype RecordValueToValidator<Vl> = Vl extends ReadonlyRecordValue\n ? {\n -readonly [K in keyof Vl]-?: IsAny<Vl[K]> extends true\n ? IsOptional<Vl, K> extends true\n ? VOptional<VAny>\n : VAny\n : UndefinedOrValueToValidator<Vl[K]>;\n } extends infer VdRecord extends Record<string, any>\n ? {\n -readonly [K in keyof Vl]: undefined extends Vl[K]\n ? DeepMutable<Exclude<Vl[K], undefined>>\n : DeepMutable<Vl[K]>;\n } extends infer VlRecord extends Record<string, any>\n ? IsRecord<VlRecord> extends true\n ? VRecord<VlRecord, VString, VdRecord[keyof VdRecord]>\n : VObject<VlRecord, VdRecord>\n : never\n : never\n : never;\n\nexport type UndefinedOrValueToValidator<Vl extends ReadonlyValue | undefined> =\n undefined extends Vl\n ? [Vl] extends [(infer Val extends ReadonlyValue) | undefined]\n ? ValueToValidator<Val> extends infer Vd extends Validator<\n any,\n \"required\",\n any\n >\n ? VOptional<Vd>\n : never\n : never\n : [Vl] extends [ReadonlyValue]\n ? ValueToValidator<Vl>\n : never;\n\ntype UnionValueToValidator<Vl extends ReadonlyValue> = [Vl] extends [\n ReadonlyValue,\n]\n ? IsUnion<Vl> extends true\n ? UnionToTuple<Vl> extends infer VlTuple extends\n ReadonlyArray<ReadonlyValue>\n ? ValueTupleToValidatorTuple<VlTuple> extends infer VdTuple extends\n Validator<any, \"required\", any>[]\n ? VUnion<DeepMutable<Vl>, VdTuple>\n : TypeError<\"Failed to convert value tuple to validator tuple\">\n : TypeError<\"Failed to convert union to tuple\">\n : TypeError<\"Expected a union of values, but got a single value instead\">\n : TypeError<\"Provided value is not a valid Convex value\">;\n\ntype ValueTupleToValidatorTuple<VlTuple extends ReadonlyArray<ReadonlyValue>> =\n VlTuple extends\n | [true, false, ...infer VlRest extends ReadonlyArray<ReadonlyValue>]\n | [false, true, ...infer VlRest extends ReadonlyArray<ReadonlyValue>]\n ? ValueTupleToValidatorTuple<VlRest> extends infer VdRest extends Validator<\n any,\n any,\n any\n >[]\n ? [VBoolean<boolean>, ...VdRest]\n : never\n : VlTuple extends [\n infer Vl extends ReadonlyValue,\n ...infer VlRest extends ReadonlyArray<ReadonlyValue>,\n ]\n ? ValueToValidator<Vl> extends infer Vd extends Validator<any, any, any>\n ? ValueTupleToValidatorTuple<VlRest> extends infer VdRest extends\n Validator<any, \"required\", any>[]\n ? [Vd, ...VdRest]\n : never\n : never\n : [];\n\nexport const compileSchema = <T, E>(\n schema: Schema.Schema<T, E>,\n // TODO: Can `ValueToValidator` here just accept `E` directly?\n): ValueToValidator<(typeof schema)[\"Encoded\"]> =>\n runSyncThrow(compileAst(schema.ast)) as any;\n\nexport const isRecursive = (ast: SchemaAST.AST): boolean =>\n pipe(\n ast,\n Match.value,\n Match.tag(\n \"Literal\",\n \"BooleanKeyword\",\n \"StringKeyword\",\n \"NumberKeyword\",\n \"BigIntKeyword\",\n \"UnknownKeyword\",\n \"AnyKeyword\",\n \"Declaration\",\n \"UniqueSymbol\",\n \"SymbolKeyword\",\n \"UndefinedKeyword\",\n \"VoidKeyword\",\n \"NeverKeyword\",\n \"Enums\",\n \"TemplateLiteral\",\n \"ObjectKeyword\",\n \"Transformation\",\n () => false,\n ),\n Match.tag(\"Union\", ({ types }) =>\n Array.some(types, (type) => isRecursive(type)),\n ),\n Match.tag(\"TypeLiteral\", ({ propertySignatures }) =>\n Array.some(propertySignatures, ({ type }) => isRecursive(type)),\n ),\n Match.tag(\n \"TupleType\",\n ({ elements: optionalElements, rest: elements }) =>\n Array.some(optionalElements, (optionalElement) =>\n isRecursive(optionalElement.type),\n ) || Array.some(elements, (element) => isRecursive(element.type)),\n ),\n Match.tag(\"Refinement\", ({ from }) => isRecursive(from)),\n Match.tag(\"Suspend\", () => true),\n Match.exhaustive,\n );\n\nexport const compileAst = (\n ast: SchemaAST.AST,\n isOptionalPropertyOfTypeLiteral = false,\n): Effect.Effect<\n Validator<any, any, any>,\n | UnsupportedSchemaTypeError\n | UnsupportedPropertySignatureKeyTypeError\n | IndexSignaturesAreNotSupportedError\n | MixedIndexAndPropertySignaturesAreNotSupportedError\n | OptionalTupleElementsAreNotSupportedError\n | EmptyTupleIsNotSupportedError\n> =>\n isRecursive(ast)\n ? Effect.succeed(v.any())\n : pipe(\n ast,\n Match.value,\n Match.tag(\"Literal\", ({ literal }) =>\n pipe(\n literal,\n Match.value,\n Match.whenOr(\n Match.string,\n Match.number,\n Match.bigint,\n Match.boolean,\n (l) => v.literal(l),\n ),\n Match.when(Match.null, () => v.null()),\n Match.exhaustive,\n Effect.succeed,\n ),\n ),\n Match.tag(\"BooleanKeyword\", () => Effect.succeed(v.boolean())),\n Match.tag(\"StringKeyword\", (stringAst) =>\n GenericId.tableName(stringAst).pipe(\n Option.match({\n onNone: () => Effect.succeed(v.string()),\n onSome: (tableName) => Effect.succeed(v.id(tableName)),\n }),\n ),\n ),\n Match.tag(\"NumberKeyword\", () => Effect.succeed(v.float64())),\n Match.tag(\"BigIntKeyword\", () => Effect.succeed(v.int64())),\n Match.tag(\"Union\", (unionAst) =>\n handleUnion(unionAst, isOptionalPropertyOfTypeLiteral),\n ),\n Match.tag(\"TypeLiteral\", (typeLiteralAst) =>\n handleTypeLiteral(typeLiteralAst),\n ),\n Match.tag(\"TupleType\", (tupleTypeAst) => handleTupleType(tupleTypeAst)),\n Match.tag(\"UnknownKeyword\", \"AnyKeyword\", () =>\n Effect.succeed(v.any()),\n ),\n Match.tag(\"Declaration\", (declaration) =>\n Effect.mapBoth(\n declaration.decodeUnknown(...declaration.typeParameters)(\n new ArrayBuffer(0),\n {},\n declaration,\n ) as Effect.Effect<ArrayBuffer, ParseResult.ParseIssue>,\n {\n onSuccess: () => v.bytes(),\n onFailure: () =>\n new UnsupportedSchemaTypeError({\n schemaType: declaration._tag,\n }),\n },\n ),\n ),\n Match.tag(\"Refinement\", ({ from }) => compileAst(from)),\n Match.tag(\"Suspend\", () => Effect.succeed(v.any())),\n Match.tag(\n \"UniqueSymbol\",\n \"SymbolKeyword\",\n \"UndefinedKeyword\",\n \"VoidKeyword\",\n \"NeverKeyword\",\n \"Enums\",\n \"TemplateLiteral\",\n \"ObjectKeyword\",\n \"Transformation\",\n () =>\n new UnsupportedSchemaTypeError({\n schemaType: ast._tag,\n }),\n ),\n Match.exhaustive,\n );\n\nconst handleUnion = (\n { types: [first, second, ...rest] }: SchemaAST.Union,\n isOptionalPropertyOfTypeLiteral: boolean,\n) =>\n Effect.gen(function* () {\n const validatorEffects = isOptionalPropertyOfTypeLiteral\n ? Array.filterMap([first, second, ...rest], (type) =>\n Predicate.not(SchemaAST.isUndefinedKeyword)(type)\n ? Option.some(compileAst(type))\n : Option.none(),\n )\n : Array.map([first, second, ...rest], (type) => compileAst(type));\n\n const [firstValidator, secondValidator, ...restValidators] =\n yield* Effect.all(validatorEffects);\n\n /* v8 ignore start */\n if (firstValidator === undefined) {\n return yield* Effect.dieMessage(\n \"First validator of union is undefined; this should be impossible.\",\n );\n /* v8 ignore stop */\n } else if (secondValidator === undefined) {\n return firstValidator;\n } else {\n return v.union(firstValidator, secondValidator, ...restValidators);\n }\n });\n\nconst handleTypeLiteral = (typeLiteralAst: SchemaAST.TypeLiteral) =>\n pipe(\n typeLiteralAst.indexSignatures,\n Array.head,\n Option.match({\n onNone: () =>\n Effect.map(handlePropertySignatures(typeLiteralAst), v.object),\n onSome: ({ parameter, type }) =>\n pipe(\n typeLiteralAst.propertySignatures,\n Array.head,\n Option.match({\n onNone: () =>\n Effect.map(\n Effect.all({\n parameter_: compileAst(parameter),\n type_: compileAst(type),\n }),\n ({ parameter_, type_ }) => v.record(parameter_, type_),\n ),\n onSome: () =>\n Effect.fail(\n new MixedIndexAndPropertySignaturesAreNotSupportedError(),\n ),\n }),\n ),\n }),\n );\n\nconst handleTupleType = ({ elements, rest }: SchemaAST.TupleType) =>\n Effect.gen(function* () {\n const restValidator = pipe(\n rest,\n Array.head,\n Option.map(({ type }) => compileAst(type)),\n Effect.flatten,\n );\n\n const [f, s, ...r] = elements;\n\n const elementToValidator = ({ type, isOptional }: SchemaAST.OptionalType) =>\n Effect.if(isOptional, {\n onTrue: () =>\n Effect.fail(new OptionalTupleElementsAreNotSupportedError()),\n onFalse: () => compileAst(type),\n });\n\n const arrayItemsValidator = yield* f === undefined\n ? pipe(\n restValidator,\n Effect.catchTag(\"NoSuchElementException\", () =>\n Effect.fail(new EmptyTupleIsNotSupportedError()),\n ),\n )\n : s === undefined\n ? elementToValidator(f)\n : Effect.gen(function* () {\n const firstValidator = yield* elementToValidator(f);\n const secondValidator = yield* elementToValidator(s);\n const restValidators = yield* Effect.forEach(r, elementToValidator);\n\n return v.union(firstValidator, secondValidator, ...restValidators);\n });\n\n return v.array(arrayItemsValidator);\n });\n\nconst handlePropertySignatures = (typeLiteralAst: SchemaAST.TypeLiteral) =>\n pipe(\n typeLiteralAst.propertySignatures,\n Effect.forEach(({ type, name, isOptional }) => {\n if (String.isString(name)) {\n // Somehow, somewhere, keys of type number are being coerced to strings…\n return Option.match(Number.parse(name), {\n onNone: () =>\n Effect.gen(function* () {\n const validator = yield* compileAst(type, isOptional);\n\n return {\n propertyName: name,\n validator: isOptional ? v.optional(validator) : validator,\n };\n }),\n onSome: (number) =>\n Effect.fail(\n new UnsupportedPropertySignatureKeyTypeError({\n propertyKey: number,\n }),\n ),\n });\n } else {\n return Effect.fail(\n new UnsupportedPropertySignatureKeyTypeError({ propertyKey: name }),\n );\n }\n }),\n Effect.andThen((propertyNamesWithValidators) =>\n pipe(\n propertyNamesWithValidators,\n Array.reduce(\n {} as Record<string, Validator<any, any, any>>,\n (acc, { propertyName, validator }) => ({\n [propertyName]: validator,\n ...acc,\n }),\n ),\n Effect.succeed,\n ),\n ),\n );\n\n// Errors\n\nconst runSyncThrow = <A, E>(effect: Effect.Effect<A, E>) =>\n pipe(\n effect,\n Effect.runSyncExit,\n Exit.match({\n onSuccess: (validator) => validator,\n onFailure: (cause) => {\n throw Cause.squash(cause);\n },\n }),\n );\n\nexport class TopLevelMustBeObjectError extends Data.TaggedError(\n \"TopLevelMustBeObjectError\",\n) {\n /* v8 ignore start */\n override get message() {\n return \"Top level schema must be an object\";\n }\n /* v8 ignore stop */\n}\n\nexport class TopLevelMustBeObjectOrUnionError extends Data.TaggedError(\n \"TopLevelMustBeObjectOrUnionError\",\n) {\n /* v8 ignore start */\n override get message() {\n return \"Top level schema must be an object or a union\";\n }\n /* v8 ignore stop */\n}\n\nexport class UnsupportedPropertySignatureKeyTypeError extends Data.TaggedError(\n \"UnsupportedPropertySignatureKeyTypeError\",\n)<{\n readonly propertyKey: number | symbol;\n}> {\n /* v8 ignore start */\n override get message() {\n return `Unsupported property signature '${this.propertyKey.toString()}'. Property is of type '${typeof this.propertyKey}' but only 'string' properties are supported.`;\n }\n /* v8 ignore stop */\n}\n\nexport class EmptyTupleIsNotSupportedError extends Data.TaggedError(\n \"EmptyTupleIsNotSupportedError\",\n) {\n /* v8 ignore start */\n override get message() {\n return \"Tuple must have at least one element\";\n }\n /* v8 ignore stop */\n}\n\nexport class UnsupportedSchemaTypeError extends Data.TaggedError(\n \"UnsupportedSchemaTypeError\",\n)<{\n readonly schemaType: SchemaAST.AST[\"_tag\"];\n}> {\n /* v8 ignore start */\n override get message() {\n return `Unsupported schema type '${this.schemaType}'`;\n }\n /* v8 ignore stop */\n}\n\nexport class IndexSignaturesAreNotSupportedError extends Data.TaggedError(\n \"IndexSignaturesAreNotSupportedError\",\n) {\n /* v8 ignore start */\n override get message() {\n return \"Index signatures are not supported\";\n }\n /* v8 ignore stop */\n}\n\nexport class MixedIndexAndPropertySignaturesAreNotSupportedError extends Data.TaggedError(\n \"MixedIndexAndPropertySignaturesAreNotSupportedError\",\n) {\n /* v8 ignore start */\n override get message() {\n return \"Mixed index and property signatures are not supported\";\n }\n /* v8 ignore stop */\n}\n\nexport class OptionalTupleElementsAreNotSupportedError extends Data.TaggedError(\n \"OptionalTupleElementsAreNotSupportedError\",\n) {\n /* v8 ignore start */\n override get message() {\n return \"Optional tuple elements are not supported\";\n }\n /* v8 ignore stop */\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAmDA,MAAa,qBACX,eACuB;CACvB,MAAM,MAAM,OAAO,cAAc,WAAW,CAAC;AAE7C,QAAO,KACL,KACA,MAAM,OACN,MAAM,IAAI,gBAAgB,mBACxB,MAAM,qBAAqB,eAAe,gBAAgB,GACtD,yBAAyB,eAAe,GACx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J,EACF,EACD,OAAO,QACR,CACF,CACF;AAIH,MAAM,gBAAsB,WAC1B,KACE,QACA,OAAO,aACP,KAAK,MAAM;CACT,YAAY,cAAc;CAC1B,YAAY,UAAU;AACpB,QAAM,MAAM,OAAO,MAAM;;CAE5B,CAAC,CACH;AAEH,IAAa,4BAAb,cAA+C,KAAK,YAClD,4BACD,CAAC;;CAEA,IAAa,UAAU;AACrB,SAAO;;;AAKX,IAAa,mCAAb,cAAsD,KAAK,YACzD,mCACD,CAAC;;CAEA,IAAa,UAAU;AACrB,SAAO;;;AAKX,IAAa,2CAAb,cAA8D,KAAK,YACjE,2CACD,CAEE;;CAED,IAAa,UAAU;AACrB,SAAO,mCAAmC,KAAK,YAAY,UAAU,CAAC,0BAA0B,OAAO,KAAK,YAAY;;;AAK5H,IAAa,gCAAb,cAAmD,KAAK,YACtD,gCACD,CAAC;;CAEA,IAAa,UAAU;AACrB,SAAO;;;AAKX,IAAa,6BAAb,cAAgD,KAAK,YACnD,6BACD,CAEE;;CAED,IAAa,UAAU;AACrB,SAAO,4BAA4B,KAAK,WAAW;;;AAKvD,IAAa,sCAAb,cAAyD,KAAK,YAC5D,sCACD,CAAC;;CAEA,IAAa,UAAU;AACrB,SAAO;;;AAKX,IAAa,sDAAb,cAAyE,KAAK,YAC5E,sDACD,CAAC;;CAEA,IAAa,UAAU;AACrB,SAAO;;;AAKX,IAAa,4CAAb,cAA+D,KAAK,YAClE,4CACD,CAAC;;CAEA,IAAa,UAAU;AACrB,SAAO"}
|
|
1
|
+
{"version":3,"file":"SchemaToValidator.js","names":["GenericId"],"sources":["../src/SchemaToValidator.ts"],"sourcesContent":["import type {\n PropertyValidators,\n Validator,\n VAny,\n VArray,\n VBoolean,\n VBytes,\n VFloat64,\n VId,\n VInt64,\n VLiteral,\n VNull,\n VObject,\n VOptional,\n VRecord,\n VString,\n VUnion,\n} from \"convex/values\";\nimport { v } from \"convex/values\";\nimport {\n Array,\n Cause,\n Data,\n Effect,\n Exit,\n Match,\n Number,\n Option,\n type ParseResult,\n pipe,\n Predicate,\n Schema,\n SchemaAST,\n String,\n} from \"effect\";\n\nimport * as GenericId from \"@confect/core/GenericId\";\nimport type {\n DeepMutable,\n IsAny,\n IsOptional,\n IsRecord,\n IsRecursive,\n IsUnion,\n IsValueLiteral,\n TypeError,\n UnionToTuple,\n} from \"@confect/core/Types\";\n\n// Args\n\nexport const compileArgsSchema = <ConfectValue, ConvexValue>(\n argsSchema: Schema.Schema<ConfectValue, ConvexValue>,\n): PropertyValidators => {\n const ast = Schema.encodedSchema(argsSchema).ast;\n\n return pipe(\n ast,\n Match.value,\n Match.tag(\"TypeLiteral\", (typeLiteralAst) =>\n Array.isEmptyReadonlyArray(typeLiteralAst.indexSignatures)\n ? handlePropertySignatures(typeLiteralAst)\n : Effect.fail(new IndexSignaturesAreNotSupportedError()),\n ),\n Match.orElse(() => Effect.fail(new TopLevelMustBeObjectError())),\n runSyncThrow,\n );\n};\n\n// Returns\n\nexport const compileReturnsSchema = <ConfectValue, ConvexValue>(\n schema: Schema.Schema<ConfectValue, ConvexValue>,\n): Validator<any, any, any> =>\n runSyncThrow(compileAst(Schema.encodedSchema(schema).ast));\n\n// Table\n\n/**\n * Convert a table `Schema` to a table `Validator`.\n */\nexport type TableSchemaToTableValidator<\n TableSchema extends Schema.Schema.AnyNoContext,\n> =\n ValueToValidator<TableSchema[\"Encoded\"]> extends infer Vd extends\n | VObject<any, any, any, any>\n | VUnion<any, any, any, any>\n ? Vd\n : never;\n\nexport const compileTableSchema = <\n TableSchema extends Schema.Schema.AnyNoContext,\n>(\n schema: TableSchema,\n): TableSchemaToTableValidator<TableSchema> => {\n const ast = Schema.encodedSchema(schema).ast;\n\n return pipe(\n ast,\n Match.value,\n Match.tag(\"TypeLiteral\", ({ indexSignatures }) =>\n Array.isEmptyReadonlyArray(indexSignatures)\n ? (compileAst(ast) as Effect.Effect<any>)\n : Effect.fail(new IndexSignaturesAreNotSupportedError()),\n ),\n Match.tag(\"Union\", (unionAst) => compileAst(unionAst)),\n Match.orElse(() => Effect.fail(new TopLevelMustBeObjectOrUnionError())),\n runSyncThrow,\n );\n};\n\n// Compiler\n\nexport type ReadonlyValue =\n | string\n | number\n | bigint\n | boolean\n | ArrayBuffer\n | ReadonlyArrayValue\n | ReadonlyRecordValue\n | null;\n\ntype ReadonlyArrayValue = readonly ReadonlyValue[];\n\nexport type ReadonlyRecordValue = {\n readonly [key: string]: ReadonlyValue | undefined;\n};\n\nexport type ValueToValidator<Vl> =\n IsRecursive<Vl> extends true\n ? VAny\n : [Vl] extends [never]\n ? never\n : IsAny<Vl> extends true\n ? VAny\n : [Vl] extends [ReadonlyValue]\n ? Vl extends {\n __tableName: infer TableName extends string;\n }\n ? VId<GenericId.GenericId<TableName>>\n : IsValueLiteral<Vl> extends true\n ? VLiteral<Vl>\n : [Vl] extends [null]\n ? VNull\n : [Vl] extends [boolean]\n ? VBoolean\n : IsUnion<Vl> extends true\n ? UnionValueToValidator<Vl>\n : [Vl] extends [number]\n ? VFloat64\n : [Vl] extends [bigint]\n ? VInt64\n : [Vl] extends [string]\n ? VString\n : [Vl] extends [ArrayBuffer]\n ? VBytes\n : Vl extends ReadonlyArray<ReadonlyValue>\n ? ArrayValueToValidator<Vl>\n : Vl extends ReadonlyRecordValue\n ? RecordValueToValidator<Vl>\n : TypeError<\"Unexpected value\", Vl>\n : TypeError<\"Provided value is not a valid Convex value\", Vl>;\n\ntype ArrayValueToValidator<Vl extends ReadonlyArray<ReadonlyValue>> =\n Vl extends ReadonlyArray<infer El extends ReadonlyValue>\n ? ValueToValidator<El> extends infer Vd extends Validator<any, any, any>\n ? VArray<DeepMutable<El[]>, Vd>\n : never\n : never;\n\ntype RecordValueToValidator<Vl> = Vl extends ReadonlyRecordValue\n ? {\n -readonly [K in keyof Vl]-?: IsAny<Vl[K]> extends true\n ? IsOptional<Vl, K> extends true\n ? VOptional<VAny>\n : VAny\n : UndefinedOrValueToValidator<Vl[K]>;\n } extends infer VdRecord extends Record<string, any>\n ? {\n -readonly [K in keyof Vl]: undefined extends Vl[K]\n ? DeepMutable<Exclude<Vl[K], undefined>>\n : DeepMutable<Vl[K]>;\n } extends infer VlRecord extends Record<string, any>\n ? IsRecord<VlRecord> extends true\n ? VRecord<VlRecord, VString, VdRecord[keyof VdRecord]>\n : VObject<VlRecord, VdRecord>\n : never\n : never\n : never;\n\nexport type UndefinedOrValueToValidator<Vl extends ReadonlyValue | undefined> =\n undefined extends Vl\n ? [Vl] extends [(infer Val extends ReadonlyValue) | undefined]\n ? ValueToValidator<Val> extends infer Vd extends Validator<\n any,\n \"required\",\n any\n >\n ? VOptional<Vd>\n : never\n : never\n : [Vl] extends [ReadonlyValue]\n ? ValueToValidator<Vl>\n : never;\n\ntype UnionValueToValidator<Vl extends ReadonlyValue> = [Vl] extends [\n ReadonlyValue,\n]\n ? IsUnion<Vl> extends true\n ? UnionToTuple<Vl> extends infer VlTuple extends\n ReadonlyArray<ReadonlyValue>\n ? ValueTupleToValidatorTuple<VlTuple> extends infer VdTuple extends\n Validator<any, \"required\", any>[]\n ? VUnion<DeepMutable<Vl>, VdTuple>\n : TypeError<\"Failed to convert value tuple to validator tuple\">\n : TypeError<\"Failed to convert union to tuple\">\n : TypeError<\"Expected a union of values, but got a single value instead\">\n : TypeError<\"Provided value is not a valid Convex value\">;\n\ntype ValueTupleToValidatorTuple<VlTuple extends ReadonlyArray<ReadonlyValue>> =\n VlTuple extends\n | [true, false, ...infer VlRest extends ReadonlyArray<ReadonlyValue>]\n | [false, true, ...infer VlRest extends ReadonlyArray<ReadonlyValue>]\n ? ValueTupleToValidatorTuple<VlRest> extends infer VdRest extends Validator<\n any,\n any,\n any\n >[]\n ? [VBoolean<boolean>, ...VdRest]\n : never\n : VlTuple extends [\n infer Vl extends ReadonlyValue,\n ...infer VlRest extends ReadonlyArray<ReadonlyValue>,\n ]\n ? ValueToValidator<Vl> extends infer Vd extends Validator<any, any, any>\n ? ValueTupleToValidatorTuple<VlRest> extends infer VdRest extends\n Validator<any, \"required\", any>[]\n ? [Vd, ...VdRest]\n : never\n : never\n : [];\n\nexport const compileSchema = <T, E>(\n schema: Schema.Schema<T, E>,\n): ValueToValidator<(typeof schema)[\"Encoded\"]> =>\n runSyncThrow(compileAst(schema.ast)) as any;\n\nexport const isRecursive = (ast: SchemaAST.AST): boolean =>\n pipe(\n ast,\n Match.value,\n Match.tag(\n \"Literal\",\n \"BooleanKeyword\",\n \"StringKeyword\",\n \"NumberKeyword\",\n \"BigIntKeyword\",\n \"UnknownKeyword\",\n \"AnyKeyword\",\n \"Declaration\",\n \"UniqueSymbol\",\n \"SymbolKeyword\",\n \"UndefinedKeyword\",\n \"VoidKeyword\",\n \"NeverKeyword\",\n \"Enums\",\n \"TemplateLiteral\",\n \"ObjectKeyword\",\n \"Transformation\",\n () => false,\n ),\n Match.tag(\"Union\", ({ types }) =>\n Array.some(types, (type) => isRecursive(type)),\n ),\n Match.tag(\"TypeLiteral\", ({ propertySignatures }) =>\n Array.some(propertySignatures, ({ type }) => isRecursive(type)),\n ),\n Match.tag(\n \"TupleType\",\n ({ elements: optionalElements, rest: elements }) =>\n Array.some(optionalElements, (optionalElement) =>\n isRecursive(optionalElement.type),\n ) || Array.some(elements, (element) => isRecursive(element.type)),\n ),\n Match.tag(\"Refinement\", ({ from }) => isRecursive(from)),\n Match.tag(\"Suspend\", () => true),\n Match.exhaustive,\n );\n\nexport const compileAst = (\n ast: SchemaAST.AST,\n isOptionalPropertyOfTypeLiteral = false,\n): Effect.Effect<\n Validator<any, any, any>,\n | UnsupportedSchemaTypeError\n | UnsupportedPropertySignatureKeyTypeError\n | IndexSignaturesAreNotSupportedError\n | MixedIndexAndPropertySignaturesAreNotSupportedError\n | OptionalTupleElementsAreNotSupportedError\n | EmptyTupleIsNotSupportedError\n> =>\n isRecursive(ast)\n ? Effect.succeed(v.any())\n : pipe(\n ast,\n Match.value,\n Match.tag(\"Literal\", ({ literal }) =>\n pipe(\n literal,\n Match.value,\n Match.whenOr(\n Match.string,\n Match.number,\n Match.bigint,\n Match.boolean,\n (l) => v.literal(l),\n ),\n Match.when(Match.null, () => v.null()),\n Match.exhaustive,\n Effect.succeed,\n ),\n ),\n Match.tag(\"BooleanKeyword\", () => Effect.succeed(v.boolean())),\n Match.tag(\"StringKeyword\", (stringAst) =>\n GenericId.tableName(stringAst).pipe(\n Option.match({\n onNone: () => Effect.succeed(v.string()),\n onSome: (tableName) => Effect.succeed(v.id(tableName)),\n }),\n ),\n ),\n Match.tag(\"NumberKeyword\", () => Effect.succeed(v.float64())),\n Match.tag(\"BigIntKeyword\", () => Effect.succeed(v.int64())),\n Match.tag(\"Union\", (unionAst) =>\n handleUnion(unionAst, isOptionalPropertyOfTypeLiteral),\n ),\n Match.tag(\"TypeLiteral\", (typeLiteralAst) =>\n handleTypeLiteral(typeLiteralAst),\n ),\n Match.tag(\"TupleType\", (tupleTypeAst) => handleTupleType(tupleTypeAst)),\n Match.tag(\"UnknownKeyword\", \"AnyKeyword\", () =>\n Effect.succeed(v.any()),\n ),\n Match.tag(\"Declaration\", (declaration) =>\n Effect.mapBoth(\n declaration.decodeUnknown(...declaration.typeParameters)(\n new ArrayBuffer(0),\n {},\n declaration,\n ) as Effect.Effect<ArrayBuffer, ParseResult.ParseIssue>,\n {\n onSuccess: () => v.bytes(),\n onFailure: () =>\n new UnsupportedSchemaTypeError({\n schemaType: declaration._tag,\n }),\n },\n ),\n ),\n Match.tag(\"Refinement\", ({ from }) => compileAst(from)),\n Match.tag(\"Suspend\", () => Effect.succeed(v.any())),\n Match.tag(\n \"UniqueSymbol\",\n \"SymbolKeyword\",\n \"UndefinedKeyword\",\n \"VoidKeyword\",\n \"NeverKeyword\",\n \"Enums\",\n \"TemplateLiteral\",\n \"ObjectKeyword\",\n \"Transformation\",\n () =>\n new UnsupportedSchemaTypeError({\n schemaType: ast._tag,\n }),\n ),\n Match.exhaustive,\n );\n\nconst handleUnion = (\n { types: [first, second, ...rest] }: SchemaAST.Union,\n isOptionalPropertyOfTypeLiteral: boolean,\n) =>\n Effect.gen(function* () {\n const validatorEffects = isOptionalPropertyOfTypeLiteral\n ? Array.filterMap([first, second, ...rest], (type) =>\n Predicate.not(SchemaAST.isUndefinedKeyword)(type)\n ? Option.some(compileAst(type))\n : Option.none(),\n )\n : Array.map([first, second, ...rest], (type) => compileAst(type));\n\n const [firstValidator, secondValidator, ...restValidators] =\n yield* Effect.all(validatorEffects);\n\n /* v8 ignore start */\n if (firstValidator === undefined) {\n return yield* Effect.dieMessage(\n \"First validator of union is undefined; this should be impossible.\",\n );\n /* v8 ignore stop */\n } else if (secondValidator === undefined) {\n return firstValidator;\n } else {\n return v.union(firstValidator, secondValidator, ...restValidators);\n }\n });\n\nconst handleTypeLiteral = (typeLiteralAst: SchemaAST.TypeLiteral) =>\n pipe(\n typeLiteralAst.indexSignatures,\n Array.head,\n Option.match({\n onNone: () =>\n Effect.map(handlePropertySignatures(typeLiteralAst), v.object),\n onSome: ({ parameter, type }) =>\n pipe(\n typeLiteralAst.propertySignatures,\n Array.head,\n Option.match({\n onNone: () =>\n Effect.map(\n Effect.all({\n parameter_: compileAst(parameter),\n type_: compileAst(type),\n }),\n ({ parameter_, type_ }) => v.record(parameter_, type_),\n ),\n onSome: () =>\n Effect.fail(\n new MixedIndexAndPropertySignaturesAreNotSupportedError(),\n ),\n }),\n ),\n }),\n );\n\nconst handleTupleType = ({ elements, rest }: SchemaAST.TupleType) =>\n Effect.gen(function* () {\n const restValidator = pipe(\n rest,\n Array.head,\n Option.map(({ type }) => compileAst(type)),\n Effect.flatten,\n );\n\n const [f, s, ...r] = elements;\n\n const elementToValidator = ({ type, isOptional }: SchemaAST.OptionalType) =>\n Effect.if(isOptional, {\n onTrue: () =>\n Effect.fail(new OptionalTupleElementsAreNotSupportedError()),\n onFalse: () => compileAst(type),\n });\n\n const arrayItemsValidator = yield* f === undefined\n ? pipe(\n restValidator,\n Effect.catchTag(\"NoSuchElementException\", () =>\n Effect.fail(new EmptyTupleIsNotSupportedError()),\n ),\n )\n : s === undefined\n ? elementToValidator(f)\n : Effect.gen(function* () {\n const firstValidator = yield* elementToValidator(f);\n const secondValidator = yield* elementToValidator(s);\n const restValidators = yield* Effect.forEach(r, elementToValidator);\n\n return v.union(firstValidator, secondValidator, ...restValidators);\n });\n\n return v.array(arrayItemsValidator);\n });\n\nconst handlePropertySignatures = (typeLiteralAst: SchemaAST.TypeLiteral) =>\n pipe(\n typeLiteralAst.propertySignatures,\n Effect.forEach(({ type, name, isOptional }) => {\n if (String.isString(name)) {\n // Somehow, somewhere, keys of type number are being coerced to strings…\n return Option.match(Number.parse(name), {\n onNone: () =>\n Effect.gen(function* () {\n const validator = yield* compileAst(type, isOptional);\n\n return {\n propertyName: name,\n validator: isOptional ? v.optional(validator) : validator,\n };\n }),\n onSome: (number) =>\n Effect.fail(\n new UnsupportedPropertySignatureKeyTypeError({\n propertyKey: number,\n }),\n ),\n });\n } else {\n return Effect.fail(\n new UnsupportedPropertySignatureKeyTypeError({ propertyKey: name }),\n );\n }\n }),\n Effect.andThen((propertyNamesWithValidators) =>\n pipe(\n propertyNamesWithValidators,\n Array.reduce(\n {} as Record<string, Validator<any, any, any>>,\n (acc, { propertyName, validator }) => ({\n [propertyName]: validator,\n ...acc,\n }),\n ),\n Effect.succeed,\n ),\n ),\n );\n\n// Errors\n\nconst runSyncThrow = <A, E>(effect: Effect.Effect<A, E>) =>\n pipe(\n effect,\n Effect.runSyncExit,\n Exit.match({\n onSuccess: (validator) => validator,\n onFailure: (cause) => {\n throw Cause.squash(cause);\n },\n }),\n );\n\nexport class TopLevelMustBeObjectError extends Data.TaggedError(\n \"TopLevelMustBeObjectError\",\n) {\n /* v8 ignore start */\n override get message() {\n return \"Top level schema must be an object\";\n }\n /* v8 ignore stop */\n}\n\nexport class TopLevelMustBeObjectOrUnionError extends Data.TaggedError(\n \"TopLevelMustBeObjectOrUnionError\",\n) {\n /* v8 ignore start */\n override get message() {\n return \"Top level schema must be an object or a union\";\n }\n /* v8 ignore stop */\n}\n\nexport class UnsupportedPropertySignatureKeyTypeError extends Data.TaggedError(\n \"UnsupportedPropertySignatureKeyTypeError\",\n)<{\n readonly propertyKey: number | symbol;\n}> {\n /* v8 ignore start */\n override get message() {\n return `Unsupported property signature '${this.propertyKey.toString()}'. Property is of type '${typeof this.propertyKey}' but only 'string' properties are supported.`;\n }\n /* v8 ignore stop */\n}\n\nexport class EmptyTupleIsNotSupportedError extends Data.TaggedError(\n \"EmptyTupleIsNotSupportedError\",\n) {\n /* v8 ignore start */\n override get message() {\n return \"Tuple must have at least one element\";\n }\n /* v8 ignore stop */\n}\n\nexport class UnsupportedSchemaTypeError extends Data.TaggedError(\n \"UnsupportedSchemaTypeError\",\n)<{\n readonly schemaType: SchemaAST.AST[\"_tag\"];\n}> {\n /* v8 ignore start */\n override get message() {\n return `Unsupported schema type '${this.schemaType}'`;\n }\n /* v8 ignore stop */\n}\n\nexport class IndexSignaturesAreNotSupportedError extends Data.TaggedError(\n \"IndexSignaturesAreNotSupportedError\",\n) {\n /* v8 ignore start */\n override get message() {\n return \"Index signatures are not supported\";\n }\n /* v8 ignore stop */\n}\n\nexport class MixedIndexAndPropertySignaturesAreNotSupportedError extends Data.TaggedError(\n \"MixedIndexAndPropertySignaturesAreNotSupportedError\",\n) {\n /* v8 ignore start */\n override get message() {\n return \"Mixed index and property signatures are not supported\";\n }\n /* v8 ignore stop */\n}\n\nexport class OptionalTupleElementsAreNotSupportedError extends Data.TaggedError(\n \"OptionalTupleElementsAreNotSupportedError\",\n) {\n /* v8 ignore start */\n override get message() {\n return \"Optional tuple elements are not supported\";\n }\n /* v8 ignore stop */\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAmDA,MAAa,qBACX,eACuB;CACvB,MAAM,MAAM,OAAO,cAAc,WAAW,CAAC;AAE7C,QAAO,KACL,KACA,MAAM,OACN,MAAM,IAAI,gBAAgB,mBACxB,MAAM,qBAAqB,eAAe,gBAAgB,GACtD,yBAAyB,eAAe,GACxC,OAAO,KA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D,OAAO,QACR,CACF,CACF;AAIH,MAAM,gBAAsB,WAC1B,KACE,QACA,OAAO,aACP,KAAK,MAAM;CACT,YAAY,cAAc;CAC1B,YAAY,UAAU;AACpB,QAAM,MAAM,OAAO,MAAM;;CAE5B,CAAC,CACH;AAEH,IAAa,4BAAb,cAA+C,KAAK,YAClD,4BACD,CAAC;;CAEA,IAAa,UAAU;AACrB,SAAO;;;AAKX,IAAa,mCAAb,cAAsD,KAAK,YACzD,mCACD,CAAC;;CAEA,IAAa,UAAU;AACrB,SAAO;;;AAKX,IAAa,2CAAb,cAA8D,KAAK,YACjE,2CACD,CAEE;;CAED,IAAa,UAAU;AACrB,SAAO,mCAAmC,KAAK,YAAY,UAAU,CAAC,0BAA0B,OAAO,KAAK,YAAY;;;AAK5H,IAAa,gCAAb,cAAmD,KAAK,YACtD,gCACD,CAAC;;CAEA,IAAa,UAAU;AACrB,SAAO;;;AAKX,IAAa,6BAAb,cAAgD,KAAK,YACnD,6BACD,CAEE;;CAED,IAAa,UAAU;AACrB,SAAO,4BAA4B,KAAK,WAAW;;;AAKvD,IAAa,sCAAb,cAAyD,KAAK,YAC5D,sCACD,CAAC;;CAEA,IAAa,UAAU;AACrB,SAAO;;;AAKX,IAAa,sDAAb,cAAyE,KAAK,YAC5E,sDACD,CAAC;;CAEA,IAAa,UAAU;AACrB,SAAO;;;AAKX,IAAa,4CAAb,cAA+D,KAAK,YAClE,4CACD,CAAC;;CAEA,IAAa,UAAU;AACrB,SAAO"}
|
package/dist/Table.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { TableSchemaToTableValidator } from "./SchemaToValidator.js";
|
|
|
2
2
|
import { Schema } from "effect";
|
|
3
3
|
import { Expand, GenericTableIndexes, GenericTableSearchIndexes, GenericTableVectorIndexes, IndexTiebreakerField, SearchIndexConfig, SystemFields, TableDefinition, VectorIndexConfig } from "convex/server";
|
|
4
4
|
import * as SystemFields$1 from "@confect/core/SystemFields";
|
|
5
|
-
import * as
|
|
5
|
+
import * as convex_values38 from "convex/values";
|
|
6
6
|
import { GenericValidator, Validator } from "convex/values";
|
|
7
7
|
|
|
8
8
|
//#region src/Table.d.ts
|
|
@@ -69,7 +69,7 @@ declare const scheduledFunctionsTable: Table<"_scheduled_functions", Schema.Stru
|
|
|
69
69
|
}>, Schema.Struct<{
|
|
70
70
|
kind: Schema.Literal<["canceled"]>;
|
|
71
71
|
}>]>;
|
|
72
|
-
}>,
|
|
72
|
+
}>, convex_values38.VObject<{
|
|
73
73
|
name: string;
|
|
74
74
|
args: any[];
|
|
75
75
|
scheduledTime: number;
|
|
@@ -87,10 +87,10 @@ declare const scheduledFunctionsTable: Table<"_scheduled_functions", Schema.Stru
|
|
|
87
87
|
};
|
|
88
88
|
completedTime?: number;
|
|
89
89
|
}, {
|
|
90
|
-
name:
|
|
91
|
-
args:
|
|
92
|
-
scheduledTime:
|
|
93
|
-
state:
|
|
90
|
+
name: convex_values38.VString<string, "required">;
|
|
91
|
+
args: convex_values38.VArray<any[], convex_values38.VAny<any, "required", string>, "required">;
|
|
92
|
+
scheduledTime: convex_values38.VFloat64<number, "required">;
|
|
93
|
+
state: convex_values38.VUnion<{
|
|
94
94
|
kind: "pending";
|
|
95
95
|
} | {
|
|
96
96
|
kind: "inProgress";
|
|
@@ -101,30 +101,30 @@ declare const scheduledFunctionsTable: Table<"_scheduled_functions", Schema.Stru
|
|
|
101
101
|
error: string;
|
|
102
102
|
} | {
|
|
103
103
|
kind: "canceled";
|
|
104
|
-
}, [
|
|
104
|
+
}, [convex_values38.VObject<{
|
|
105
105
|
kind: "pending";
|
|
106
106
|
}, {
|
|
107
|
-
kind:
|
|
108
|
-
}, "required", "kind">,
|
|
107
|
+
kind: convex_values38.VLiteral<"pending", "required">;
|
|
108
|
+
}, "required", "kind">, convex_values38.VObject<{
|
|
109
109
|
kind: "inProgress";
|
|
110
110
|
}, {
|
|
111
|
-
kind:
|
|
112
|
-
}, "required", "kind">,
|
|
111
|
+
kind: convex_values38.VLiteral<"inProgress", "required">;
|
|
112
|
+
}, "required", "kind">, convex_values38.VObject<{
|
|
113
113
|
kind: "success";
|
|
114
114
|
}, {
|
|
115
|
-
kind:
|
|
116
|
-
}, "required", "kind">,
|
|
115
|
+
kind: convex_values38.VLiteral<"success", "required">;
|
|
116
|
+
}, "required", "kind">, convex_values38.VObject<{
|
|
117
117
|
kind: "failed";
|
|
118
118
|
error: string;
|
|
119
119
|
}, {
|
|
120
|
-
kind:
|
|
121
|
-
error:
|
|
122
|
-
}, "required", "kind" | "error">,
|
|
120
|
+
kind: convex_values38.VLiteral<"failed", "required">;
|
|
121
|
+
error: convex_values38.VString<string, "required">;
|
|
122
|
+
}, "required", "kind" | "error">, convex_values38.VObject<{
|
|
123
123
|
kind: "canceled";
|
|
124
124
|
}, {
|
|
125
|
-
kind:
|
|
125
|
+
kind: convex_values38.VLiteral<"canceled", "required">;
|
|
126
126
|
}, "required", "kind">], "required", "kind" | "error">;
|
|
127
|
-
completedTime:
|
|
127
|
+
completedTime: convex_values38.VFloat64<number | undefined, "optional">;
|
|
128
128
|
}, "required", "name" | "args" | "scheduledTime" | "completedTime" | "state" | "state.kind" | "state.error">, {}, {}, {}>;
|
|
129
129
|
declare const storageTable: Table<"_storage", Schema.Struct<{
|
|
130
130
|
sha256: typeof Schema.String;
|
|
@@ -132,14 +132,14 @@ declare const storageTable: Table<"_storage", Schema.Struct<{
|
|
|
132
132
|
contentType: Schema.optionalWith<typeof Schema.String, {
|
|
133
133
|
exact: true;
|
|
134
134
|
}>;
|
|
135
|
-
}>,
|
|
135
|
+
}>, convex_values38.VObject<{
|
|
136
136
|
sha256: string;
|
|
137
137
|
size: number;
|
|
138
138
|
contentType?: string;
|
|
139
139
|
}, {
|
|
140
|
-
sha256:
|
|
141
|
-
size:
|
|
142
|
-
contentType:
|
|
140
|
+
sha256: convex_values38.VString<string, "required">;
|
|
141
|
+
size: convex_values38.VFloat64<number, "required">;
|
|
142
|
+
contentType: convex_values38.VString<string | undefined, "optional">;
|
|
143
143
|
}, "required", "sha256" | "size" | "contentType">, {}, {}, {}>;
|
|
144
144
|
declare const systemTables: {
|
|
145
145
|
readonly _scheduled_functions: Table<"_scheduled_functions", Schema.Struct<{
|
|
@@ -161,7 +161,7 @@ declare const systemTables: {
|
|
|
161
161
|
}>, Schema.Struct<{
|
|
162
162
|
kind: Schema.Literal<["canceled"]>;
|
|
163
163
|
}>]>;
|
|
164
|
-
}>,
|
|
164
|
+
}>, convex_values38.VObject<{
|
|
165
165
|
name: string;
|
|
166
166
|
args: any[];
|
|
167
167
|
scheduledTime: number;
|
|
@@ -179,10 +179,10 @@ declare const systemTables: {
|
|
|
179
179
|
};
|
|
180
180
|
completedTime?: number;
|
|
181
181
|
}, {
|
|
182
|
-
name:
|
|
183
|
-
args:
|
|
184
|
-
scheduledTime:
|
|
185
|
-
state:
|
|
182
|
+
name: convex_values38.VString<string, "required">;
|
|
183
|
+
args: convex_values38.VArray<any[], convex_values38.VAny<any, "required", string>, "required">;
|
|
184
|
+
scheduledTime: convex_values38.VFloat64<number, "required">;
|
|
185
|
+
state: convex_values38.VUnion<{
|
|
186
186
|
kind: "pending";
|
|
187
187
|
} | {
|
|
188
188
|
kind: "inProgress";
|
|
@@ -193,30 +193,30 @@ declare const systemTables: {
|
|
|
193
193
|
error: string;
|
|
194
194
|
} | {
|
|
195
195
|
kind: "canceled";
|
|
196
|
-
}, [
|
|
196
|
+
}, [convex_values38.VObject<{
|
|
197
197
|
kind: "pending";
|
|
198
198
|
}, {
|
|
199
|
-
kind:
|
|
200
|
-
}, "required", "kind">,
|
|
199
|
+
kind: convex_values38.VLiteral<"pending", "required">;
|
|
200
|
+
}, "required", "kind">, convex_values38.VObject<{
|
|
201
201
|
kind: "inProgress";
|
|
202
202
|
}, {
|
|
203
|
-
kind:
|
|
204
|
-
}, "required", "kind">,
|
|
203
|
+
kind: convex_values38.VLiteral<"inProgress", "required">;
|
|
204
|
+
}, "required", "kind">, convex_values38.VObject<{
|
|
205
205
|
kind: "success";
|
|
206
206
|
}, {
|
|
207
|
-
kind:
|
|
208
|
-
}, "required", "kind">,
|
|
207
|
+
kind: convex_values38.VLiteral<"success", "required">;
|
|
208
|
+
}, "required", "kind">, convex_values38.VObject<{
|
|
209
209
|
kind: "failed";
|
|
210
210
|
error: string;
|
|
211
211
|
}, {
|
|
212
|
-
kind:
|
|
213
|
-
error:
|
|
214
|
-
}, "required", "kind" | "error">,
|
|
212
|
+
kind: convex_values38.VLiteral<"failed", "required">;
|
|
213
|
+
error: convex_values38.VString<string, "required">;
|
|
214
|
+
}, "required", "kind" | "error">, convex_values38.VObject<{
|
|
215
215
|
kind: "canceled";
|
|
216
216
|
}, {
|
|
217
|
-
kind:
|
|
217
|
+
kind: convex_values38.VLiteral<"canceled", "required">;
|
|
218
218
|
}, "required", "kind">], "required", "kind" | "error">;
|
|
219
|
-
completedTime:
|
|
219
|
+
completedTime: convex_values38.VFloat64<number | undefined, "optional">;
|
|
220
220
|
}, "required", "name" | "args" | "scheduledTime" | "completedTime" | "state" | "state.kind" | "state.error">, {}, {}, {}>;
|
|
221
221
|
readonly _storage: Table<"_storage", Schema.Struct<{
|
|
222
222
|
sha256: typeof Schema.String;
|
|
@@ -224,14 +224,14 @@ declare const systemTables: {
|
|
|
224
224
|
contentType: Schema.optionalWith<typeof Schema.String, {
|
|
225
225
|
exact: true;
|
|
226
226
|
}>;
|
|
227
|
-
}>,
|
|
227
|
+
}>, convex_values38.VObject<{
|
|
228
228
|
sha256: string;
|
|
229
229
|
size: number;
|
|
230
230
|
contentType?: string;
|
|
231
231
|
}, {
|
|
232
|
-
sha256:
|
|
233
|
-
size:
|
|
234
|
-
contentType:
|
|
232
|
+
sha256: convex_values38.VString<string, "required">;
|
|
233
|
+
size: convex_values38.VFloat64<number, "required">;
|
|
234
|
+
contentType: convex_values38.VString<string | undefined, "optional">;
|
|
235
235
|
}, "required", "sha256" | "size" | "contentType">, {}, {}, {}>;
|
|
236
236
|
};
|
|
237
237
|
type SystemTables = typeof scheduledFunctionsTable | typeof storageTable;
|
package/dist/TableInfo.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableInfo.d.ts","names":[],"sources":["../src/TableInfo.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;cAgBqB;KACT,MAAA,UAAgB;KAEhB,yBAAyB,kBACnC,eAAe;YASC,MAAA,GAAS;qBACA;4BACO;
|
|
1
|
+
{"version":3,"file":"TableInfo.d.ts","names":[],"sources":["../src/TableInfo.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;cAgBqB;KACT,MAAA,UAAgB;KAEhB,yBAAyB,kBACnC,eAAe;YASC,MAAA,GAAS;qBACA;4BACO;2BACD,sBACvB,WACA;6BAGQ,QAAQ,aACd,kBAAkB;oBACJ,KAAA,CAAM,SAAS,UAAU;0BACnB;0BACA;;AAzBX,UA6BJ,GAAA,CA7BuC;EAC5C,UA6BA,MAAA,CA7BM,EA6BG,MA7BO;AAE5B;AAAqC,UA8BpB,YAAA,SAAqB,GA9BD,CAAA;EACnC,SAAA,QAAA,EA8BmB,KA9BnB;EAAe,SAAA,eAAA,EA+BW,UA/BX;EASU,SAAA,cAAA,EAuBA,eAvBA;EAAT,SAAA,UAAA,EAwBK,iBAxBL;EACS,SAAA,OAAA,EAwBP,mBAxBO;EACO,SAAA,aAAA,EAwBR,yBAxBQ;EAExB,SAAA,aAAA,EAuBgB,yBAvBhB;;AADuB,KA2BrB,eA3BqB,CAAA,mBA2Bc,YA3Bd,CAAA,GAAA;EAKP,QAAA,EAuBd,UAvBc,CAAA,gBAAA,CAAA;EAAR,UAAA,EAwBJ,UAxBI,CAAA,YAAA,CAAA;EACY,OAAA,EAwBnB,UAxBmB,CAAA,SAAA,CAAA;EAAlB,aAAA,EAyBK,UAzBL,CAAA,eAAA,CAAA;EAC6B,aAAA,EAyBxB,UAzBwB,CAAA,eAAA,CAAA;CAAU;AAAnB,KA4BpB,WA5BoB,CAAA,mBA4BW,YA5BX,CAAA,GA4B2B,MAAA,CAAO,MA5BlC,CA6B9B,UA7B8B,CAAA,UAAA,CAAA,EA8B9B,UA9B8B,CAAA,iBAAA,CAAA,CAAA;AACA,KAgCpB,QAhCoB,CAAA,mBAgCQ,YAhCR,CAAA,GAgCwB,UAhCxB,CAAA,UAAA,CAAA;KAqC3B,iBApC2B,CAAA,UAoCC,gBApCD,CAAA,GAqC5B,CArC4B,CAAA,YAAA,CAAA,GAAA,MAsCtB,YAtCsB;KAwC3B,qBAxCwC,CAAA,oBAAA,MAAA,EAAA,UA0CjC,gBA1CiC,CAAA,GA4C3C,MA5C2C,CA4CpC,OA5CoC,CA4C5B,WA5C4B,CAAA,GA4Cf,YA5Ce,GA4CA,CA5CA,CAAA,MAAA,CAAA,CAAA,SA4CmB,eA5CnB,GA6CvC,MA7CuC,CA6ChC,OA7CgC,CA6CxB,WA7CwB,CAAA,GA6CX,YA7CW,GA6CI,CA7CJ,CAAA,MAAA,CAAA,CAAA,GAAA,KAAA"}
|
package/dist/TableInfo.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableInfo.js","names":[],"sources":["../src/TableInfo.ts"],"sourcesContent":["import type {\n Expand,\n GenericDocument,\n GenericFieldPaths,\n GenericTableIndexes,\n GenericTableSearchIndexes,\n GenericTableVectorIndexes,\n IdField,\n SystemFields,\n SystemIndexes,\n} from \"convex/server\";\nimport type { GenericValidator } from \"convex/values\";\nimport type { Schema, Types } from \"effect\";\nimport type * as Document_ from \"./Document\";\nimport type * as Table from \"./Table\";\n\nexport declare const TypeId: \"@confect/server/TableInfo\";\nexport type TypeId = typeof TypeId;\n\nexport type TableInfo<Table_ extends Table.AnyWithProps> =\n Table_ extends Table.Table<\n infer TableName,\n infer _TableSchema,\n infer TableValidator,\n infer Indexes,\n infer SearchIndexes,\n infer VectorIndexes\n >\n ? {\n readonly [TypeId]: TypeId;\n readonly document: Table_[\"Doc\"][\"Type\"];\n readonly encodedDocument: Table_[\"Doc\"][\"Encoded\"];\n
|
|
1
|
+
{"version":3,"file":"TableInfo.js","names":[],"sources":["../src/TableInfo.ts"],"sourcesContent":["import type {\n Expand,\n GenericDocument,\n GenericFieldPaths,\n GenericTableIndexes,\n GenericTableSearchIndexes,\n GenericTableVectorIndexes,\n IdField,\n SystemFields,\n SystemIndexes,\n} from \"convex/server\";\nimport type { GenericValidator } from \"convex/values\";\nimport type { Schema, Types } from \"effect\";\nimport type * as Document_ from \"./Document\";\nimport type * as Table from \"./Table\";\n\nexport declare const TypeId: \"@confect/server/TableInfo\";\nexport type TypeId = typeof TypeId;\n\nexport type TableInfo<Table_ extends Table.AnyWithProps> =\n Table_ extends Table.Table<\n infer TableName,\n infer _TableSchema,\n infer TableValidator,\n infer Indexes,\n infer SearchIndexes,\n infer VectorIndexes\n >\n ? {\n readonly [TypeId]: TypeId;\n readonly document: Table_[\"Doc\"][\"Type\"];\n readonly encodedDocument: Table_[\"Doc\"][\"Encoded\"];\n readonly convexDocument: ExtractConvexDocument<\n TableName,\n TableValidator\n >;\n readonly fieldPaths:\n | keyof IdField<TableName>\n | ExtractFieldPaths<TableValidator>;\n readonly indexes: Types.Simplify<Indexes & SystemIndexes>;\n readonly searchIndexes: SearchIndexes;\n readonly vectorIndexes: VectorIndexes;\n }\n : never;\n\nexport interface Any {\n readonly [TypeId]: TypeId;\n}\n\nexport interface AnyWithProps extends Any {\n readonly document: Document_.Any;\n readonly encodedDocument: Document_.AnyEncoded;\n readonly convexDocument: GenericDocument;\n readonly fieldPaths: GenericFieldPaths;\n readonly indexes: GenericTableIndexes;\n readonly searchIndexes: GenericTableSearchIndexes;\n readonly vectorIndexes: GenericTableVectorIndexes;\n}\n\nexport type ConvexTableInfo<TableInfo_ extends AnyWithProps> = {\n document: TableInfo_[\"convexDocument\"];\n fieldPaths: TableInfo_[\"fieldPaths\"];\n indexes: TableInfo_[\"indexes\"];\n searchIndexes: TableInfo_[\"searchIndexes\"];\n vectorIndexes: TableInfo_[\"vectorIndexes\"];\n};\n\nexport type TableSchema<TableInfo_ extends AnyWithProps> = Schema.Schema<\n TableInfo_[\"document\"],\n TableInfo_[\"encodedDocument\"]\n>;\n\nexport type Document<TableInfo_ extends AnyWithProps> = TableInfo_[\"document\"];\n\n// Vendored types from convex-js, partially modified.\n// See https://github.com/get-convex/convex-js/pull/14\n\ntype ExtractFieldPaths<T extends GenericValidator> =\n | T[\"fieldPaths\"]\n | keyof SystemFields;\n\ntype ExtractConvexDocument<\n TableName extends string,\n T extends GenericValidator,\n> =\n Expand<IdField<TableName> & SystemFields & T[\"type\"]> extends GenericDocument\n ? Expand<IdField<TableName> & SystemFields & T[\"type\"]>\n : never;\n\n// End of vendored types from convex-js, partially modified.\n"],"mappings":""}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@confect/server",
|
|
3
|
-
"version": "1.0.0-next.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "1.0.0-next.1",
|
|
4
|
+
"description": "Backend bindings to the Convex platform",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/rjdellecese/confect.git"
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"bugs": {
|
|
10
10
|
"url": "https://github.com/rjdellecese/confect/issues"
|
|
11
11
|
},
|
|
12
|
-
"homepage": "https://confect.
|
|
12
|
+
"homepage": "https://confect.dev",
|
|
13
13
|
"sideEffects": false,
|
|
14
14
|
"type": "module",
|
|
15
15
|
"files": [
|
|
@@ -49,7 +49,6 @@
|
|
|
49
49
|
"@effect/workflow": "^0.12.5",
|
|
50
50
|
"@eslint/js": "9.39.1",
|
|
51
51
|
"@swc/jest": "0.2.39",
|
|
52
|
-
"@tsconfig/strictest": "2.0.8",
|
|
53
52
|
"@types/node": "24.10.1",
|
|
54
53
|
"@vitest/coverage-v8": "3.2.4",
|
|
55
54
|
"convex-test": "0.0.38",
|
|
@@ -62,14 +61,14 @@
|
|
|
62
61
|
"vite": "7.2.2",
|
|
63
62
|
"vite-tsconfig-paths": "5.1.4",
|
|
64
63
|
"vitest": "3.2.4",
|
|
65
|
-
"@confect/cli": "1.0.0-next.
|
|
66
|
-
"@confect/test": "1.0.0-next.
|
|
64
|
+
"@confect/cli": "1.0.0-next.1",
|
|
65
|
+
"@confect/test": "1.0.0-next.1"
|
|
67
66
|
},
|
|
68
67
|
"peerDependencies": {
|
|
69
68
|
"@effect/platform": "^0.93.2",
|
|
70
69
|
"convex": "^1.30.0",
|
|
71
70
|
"effect": "^3.19.3",
|
|
72
|
-
"@confect/core": "1.0.0-next.
|
|
71
|
+
"@confect/core": "1.0.0-next.1"
|
|
73
72
|
},
|
|
74
73
|
"engines": {
|
|
75
74
|
"node": ">=22",
|
|
@@ -84,7 +83,8 @@
|
|
|
84
83
|
"test": "vitest run",
|
|
85
84
|
"typecheck": "tsc --noEmit --project tsconfig.json",
|
|
86
85
|
"fix": "prettier --write . && eslint --fix . --max-warnings=0",
|
|
87
|
-
"
|
|
86
|
+
"format": "prettier --check .",
|
|
87
|
+
"lint": "eslint . --max-warnings=0",
|
|
88
88
|
"clean": "rm -rf dist coverage node_modules"
|
|
89
89
|
}
|
|
90
90
|
}
|
|
@@ -17,15 +17,7 @@ import {
|
|
|
17
17
|
type RegisteredMutation,
|
|
18
18
|
type RegisteredQuery,
|
|
19
19
|
} from "convex/server";
|
|
20
|
-
import {
|
|
21
|
-
Effect,
|
|
22
|
-
Layer,
|
|
23
|
-
Match,
|
|
24
|
-
pipe,
|
|
25
|
-
Ref,
|
|
26
|
-
Schema,
|
|
27
|
-
type Types,
|
|
28
|
-
} from "effect";
|
|
20
|
+
import { Effect, Layer, Match, pipe, Ref, Schema, type Types } from "effect";
|
|
29
21
|
import * as ActionCtx from "./ActionCtx";
|
|
30
22
|
import * as ActionRunner from "./ActionRunner";
|
|
31
23
|
import type * as Api from "./Api";
|
package/src/SchemaToValidator.ts
CHANGED
|
@@ -86,8 +86,7 @@ export type TableSchemaToTableValidator<
|
|
|
86
86
|
| VObject<any, any, any, any>
|
|
87
87
|
| VUnion<any, any, any, any>
|
|
88
88
|
? Vd
|
|
89
|
-
:
|
|
90
|
-
never;
|
|
89
|
+
: never;
|
|
91
90
|
|
|
92
91
|
export const compileTableSchema = <
|
|
93
92
|
TableSchema extends Schema.Schema.AnyNoContext,
|
|
@@ -244,7 +243,6 @@ type ValueTupleToValidatorTuple<VlTuple extends ReadonlyArray<ReadonlyValue>> =
|
|
|
244
243
|
|
|
245
244
|
export const compileSchema = <T, E>(
|
|
246
245
|
schema: Schema.Schema<T, E>,
|
|
247
|
-
// TODO: Can `ValueToValidator` here just accept `E` directly?
|
|
248
246
|
): ValueToValidator<(typeof schema)["Encoded"]> =>
|
|
249
247
|
runSyncThrow(compileAst(schema.ast)) as any;
|
|
250
248
|
|
package/src/TableInfo.ts
CHANGED
|
@@ -30,7 +30,6 @@ export type TableInfo<Table_ extends Table.AnyWithProps> =
|
|
|
30
30
|
readonly [TypeId]: TypeId;
|
|
31
31
|
readonly document: Table_["Doc"]["Type"];
|
|
32
32
|
readonly encodedDocument: Table_["Doc"]["Encoded"];
|
|
33
|
-
// TODO: Can we exclude this and derive the convex document type from the encoded document?
|
|
34
33
|
readonly convexDocument: ExtractConvexDocument<
|
|
35
34
|
TableName,
|
|
36
35
|
TableValidator
|