@confect/server 9.0.0-next.0 → 9.0.0-next.10
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 +299 -4
- package/dist/ActionCtx.d.ts +4 -11
- package/dist/ActionCtx.d.ts.map +1 -1
- package/dist/ActionCtx.js +1 -1
- package/dist/ActionCtx.js.map +1 -1
- package/dist/ActionRunner.d.ts +8 -13
- package/dist/ActionRunner.d.ts.map +1 -1
- package/dist/ActionRunner.js +4 -3
- package/dist/ActionRunner.js.map +1 -1
- package/dist/Auth.d.ts +17 -23
- package/dist/Auth.d.ts.map +1 -1
- package/dist/Auth.js +5 -1
- package/dist/Auth.js.map +1 -1
- package/dist/BlobNotFoundError.d.ts +6 -12
- package/dist/BlobNotFoundError.d.ts.map +1 -1
- package/dist/BlobNotFoundError.js +1 -1
- package/dist/BlobNotFoundError.js.map +1 -1
- package/dist/ConvexConfigProvider.d.ts +2 -9
- package/dist/ConvexConfigProvider.d.ts.map +1 -1
- package/dist/ConvexConfigProvider.js +6 -1
- package/dist/ConvexConfigProvider.js.map +1 -1
- package/dist/CronJob.d.ts +12 -19
- package/dist/CronJob.d.ts.map +1 -1
- package/dist/CronJob.js +1 -1
- package/dist/CronJob.js.map +1 -1
- package/dist/CronJobs.d.ts +11 -18
- package/dist/CronJobs.d.ts.map +1 -1
- package/dist/CronJobs.js +11 -4
- package/dist/CronJobs.js.map +1 -1
- package/dist/DataModel.d.ts +24 -29
- package/dist/DataModel.d.ts.map +1 -1
- package/dist/DatabaseReader.d.ts +4323 -64
- package/dist/DatabaseReader.d.ts.map +1 -1
- package/dist/DatabaseReader.js +6 -6
- package/dist/DatabaseReader.js.map +1 -1
- package/dist/DatabaseSchema.d.ts +38 -130
- package/dist/DatabaseSchema.d.ts.map +1 -1
- package/dist/DatabaseSchema.js +20 -30
- package/dist/DatabaseSchema.js.map +1 -1
- package/dist/DatabaseWriter.d.ts +38 -42
- package/dist/DatabaseWriter.d.ts.map +1 -1
- package/dist/DatabaseWriter.js +8 -5
- package/dist/DatabaseWriter.js.map +1 -1
- package/dist/Document.d.ts +28 -37
- package/dist/Document.d.ts.map +1 -1
- package/dist/Document.js +5 -1
- package/dist/Document.js.map +1 -1
- package/dist/FunctionImpl.d.ts +30 -29
- package/dist/FunctionImpl.d.ts.map +1 -1
- package/dist/FunctionImpl.js +25 -14
- package/dist/FunctionImpl.js.map +1 -1
- package/dist/GroupImpl.d.ts +45 -41
- package/dist/GroupImpl.d.ts.map +1 -1
- package/dist/GroupImpl.js +42 -35
- package/dist/GroupImpl.js.map +1 -1
- package/dist/Handler.d.ts +34 -40
- package/dist/Handler.d.ts.map +1 -1
- package/dist/HttpApi.d.ts +21 -25
- package/dist/HttpApi.d.ts.map +1 -1
- package/dist/HttpApi.js +11 -6
- package/dist/HttpApi.js.map +1 -1
- package/dist/MutationCtx.d.ts +4 -11
- package/dist/MutationCtx.d.ts.map +1 -1
- package/dist/MutationCtx.js +1 -1
- package/dist/MutationCtx.js.map +1 -1
- package/dist/MutationRunner.d.ts +8 -13
- package/dist/MutationRunner.d.ts.map +1 -1
- package/dist/MutationRunner.js +4 -3
- package/dist/MutationRunner.js.map +1 -1
- package/dist/OrderedQuery.d.ts +16 -21
- package/dist/OrderedQuery.d.ts.map +1 -1
- package/dist/OrderedQuery.js +4 -1
- package/dist/OrderedQuery.js.map +1 -1
- package/dist/QueryCtx.d.ts +4 -11
- package/dist/QueryCtx.d.ts.map +1 -1
- package/dist/QueryCtx.js +1 -1
- package/dist/QueryCtx.js.map +1 -1
- package/dist/QueryInitializer.d.ts +34 -39
- package/dist/QueryInitializer.d.ts.map +1 -1
- package/dist/QueryInitializer.js +5 -1
- package/dist/QueryInitializer.js.map +1 -1
- package/dist/QueryRunner.d.ts +8 -13
- package/dist/QueryRunner.d.ts.map +1 -1
- package/dist/QueryRunner.js +4 -3
- package/dist/QueryRunner.js.map +1 -1
- package/dist/RegisteredConvexFunction.d.ts +1107 -60
- package/dist/RegisteredConvexFunction.d.ts.map +1 -1
- package/dist/RegisteredConvexFunction.js +14 -9
- package/dist/RegisteredConvexFunction.js.map +1 -1
- package/dist/RegisteredFunction.d.ts +48 -64
- package/dist/RegisteredFunction.d.ts.map +1 -1
- package/dist/RegisteredFunction.js +9 -5
- package/dist/RegisteredFunction.js.map +1 -1
- package/dist/RegisteredFunctions.d.ts +48 -26
- package/dist/RegisteredFunctions.d.ts.map +1 -1
- package/dist/RegisteredFunctions.js +22 -9
- package/dist/RegisteredFunctions.js.map +1 -1
- package/dist/RegisteredNodeFunction.d.ts +4 -14
- package/dist/RegisteredNodeFunction.d.ts.map +1 -1
- package/dist/RegisteredNodeFunction.js +5 -4
- package/dist/RegisteredNodeFunction.js.map +1 -1
- package/dist/RegistryItem.d.ts +17 -27
- package/dist/RegistryItem.d.ts.map +1 -1
- package/dist/RegistryItem.js +1 -1
- package/dist/RegistryItem.js.map +1 -1
- package/dist/Scheduler.d.ts +16 -20
- package/dist/Scheduler.d.ts.map +1 -1
- package/dist/Scheduler.js +10 -6
- package/dist/Scheduler.js.map +1 -1
- package/dist/SchemaToValidator.d.ts +71 -64
- package/dist/SchemaToValidator.d.ts.map +1 -1
- package/dist/SchemaToValidator.js +15 -3
- package/dist/SchemaToValidator.js.map +1 -1
- package/dist/StorageActionWriter.d.ts +21 -28
- package/dist/StorageActionWriter.d.ts.map +1 -1
- package/dist/StorageActionWriter.js +4 -1
- package/dist/StorageActionWriter.js.map +1 -1
- package/dist/StorageReader.d.ts +14 -21
- package/dist/StorageReader.d.ts.map +1 -1
- package/dist/StorageReader.js +5 -1
- package/dist/StorageReader.js.map +1 -1
- package/dist/StorageWriter.d.ts +16 -23
- package/dist/StorageWriter.d.ts.map +1 -1
- package/dist/StorageWriter.js +4 -1
- package/dist/StorageWriter.js.map +1 -1
- package/dist/Table.d.ts +204 -197
- package/dist/Table.d.ts.map +1 -1
- package/dist/Table.js +72 -62
- package/dist/Table.js.map +1 -1
- package/dist/TableInfo.d.ts +35 -41
- package/dist/TableInfo.d.ts.map +1 -1
- package/dist/VectorSearch.d.ts +30 -35
- package/dist/VectorSearch.d.ts.map +1 -1
- package/dist/VectorSearch.js +3 -1
- package/dist/VectorSearch.js.map +1 -1
- package/dist/index.d.ts +35 -36
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -5
- package/dist/internal/utils.d.ts +9 -11
- package/dist/internal/utils.d.ts.map +1 -1
- package/dist/internal/utils.js +3 -1
- package/dist/internal/utils.js.map +1 -1
- package/dist/node.d.ts +2 -2
- package/dist/node.d.ts.map +1 -0
- package/dist/tsconfig.src.tsbuildinfo +1 -0
- package/package.json +50 -59
- package/src/ActionCtx.ts +1 -1
- package/src/ActionRunner.ts +2 -1
- package/src/Auth.ts +5 -1
- package/src/BlobNotFoundError.ts +1 -1
- package/src/ConvexConfigProvider.ts +6 -8
- package/src/CronJob.ts +1 -1
- package/src/CronJobs.ts +8 -10
- package/src/DatabaseReader.ts +18 -21
- package/src/DatabaseSchema.ts +38 -98
- package/src/DatabaseWriter.ts +13 -6
- package/src/Document.ts +5 -1
- package/src/FunctionImpl.ts +36 -44
- package/src/GroupImpl.ts +54 -81
- package/src/HttpApi.ts +8 -9
- package/src/MutationCtx.ts +1 -1
- package/src/MutationRunner.ts +2 -1
- package/src/OrderedQuery.ts +5 -1
- package/src/QueryCtx.ts +1 -1
- package/src/QueryInitializer.ts +15 -3
- package/src/QueryRunner.ts +2 -1
- package/src/RegisteredConvexFunction.ts +11 -7
- package/src/RegisteredFunction.ts +5 -1
- package/src/RegisteredFunctions.ts +69 -93
- package/src/RegisteredNodeFunction.ts +7 -6
- package/src/RegistryItem.ts +1 -1
- package/src/Scheduler.ts +5 -1
- package/src/SchemaToValidator.ts +14 -16
- package/src/StorageActionWriter.ts +4 -1
- package/src/StorageReader.ts +5 -1
- package/src/StorageWriter.ts +4 -1
- package/src/Table.ts +253 -132
- package/src/VectorSearch.ts +3 -1
- package/src/index.ts +0 -1
- package/src/internal/utils.ts +3 -1
- package/dist/Api.d.ts +0 -30
- package/dist/Api.d.ts.map +0 -1
- package/dist/Api.js +0 -26
- package/dist/Api.js.map +0 -1
- package/dist/GroupPath.d.ts +0 -8
- package/dist/GroupPath.d.ts.map +0 -1
- package/dist/GroupPath.js +0 -10
- package/dist/GroupPath.js.map +0 -1
- package/src/Api.ts +0 -75
- package/src/GroupPath.ts +0 -43
package/src/SchemaToValidator.ts
CHANGED
|
@@ -17,22 +17,20 @@ import type {
|
|
|
17
17
|
VUnion,
|
|
18
18
|
} from "convex/values";
|
|
19
19
|
import { v } from "convex/values";
|
|
20
|
-
import {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
String,
|
|
35
|
-
} from "effect";
|
|
20
|
+
import { pipe } from "effect/Function";
|
|
21
|
+
import type { ParseResult } from "effect";
|
|
22
|
+
import * as Array from "effect/Array";
|
|
23
|
+
import * as Cause from "effect/Cause";
|
|
24
|
+
import * as Data from "effect/Data";
|
|
25
|
+
import * as Effect from "effect/Effect";
|
|
26
|
+
import * as Exit from "effect/Exit";
|
|
27
|
+
import * as Match from "effect/Match";
|
|
28
|
+
import * as Number from "effect/Number";
|
|
29
|
+
import * as Option from "effect/Option";
|
|
30
|
+
import * as Predicate from "effect/Predicate";
|
|
31
|
+
import * as Schema from "effect/Schema";
|
|
32
|
+
import * as SchemaAST from "effect/SchemaAST";
|
|
33
|
+
import * as String from "effect/String";
|
|
36
34
|
|
|
37
35
|
import * as GenericId from "@confect/core/GenericId";
|
|
38
36
|
import type {
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { StorageActionWriter as ConvexStorageActionWriter } from "convex/server";
|
|
2
2
|
import type { GenericId } from "convex/values";
|
|
3
|
-
import {
|
|
3
|
+
import { flow } from "effect/Function";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Layer from "effect/Layer";
|
|
6
|
+
import * as Option from "effect/Option";
|
|
4
7
|
import { BlobNotFoundError } from "./BlobNotFoundError";
|
|
5
8
|
|
|
6
9
|
const make = (storageActionWriter: ConvexStorageActionWriter) => ({
|
package/src/StorageReader.ts
CHANGED
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import type { StorageReader as ConvexStorageReader } from "convex/server";
|
|
2
2
|
import type { GenericId } from "convex/values";
|
|
3
|
-
import {
|
|
3
|
+
import { flow, pipe } from "effect/Function";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Layer from "effect/Layer";
|
|
6
|
+
import * as Option from "effect/Option";
|
|
7
|
+
import * as Schema from "effect/Schema";
|
|
4
8
|
import { BlobNotFoundError } from "./BlobNotFoundError";
|
|
5
9
|
|
|
6
10
|
const make = (storageReader: ConvexStorageReader) => ({
|
package/src/StorageWriter.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import type { StorageWriter as ConvexStorageWriter } from "convex/server";
|
|
2
2
|
import type { GenericId } from "convex/values";
|
|
3
|
-
import {
|
|
3
|
+
import { pipe } from "effect/Function";
|
|
4
|
+
import * as Effect from "effect/Effect";
|
|
5
|
+
import * as Layer from "effect/Layer";
|
|
6
|
+
import * as Schema from "effect/Schema";
|
|
4
7
|
import { BlobNotFoundError } from "./BlobNotFoundError";
|
|
5
8
|
|
|
6
9
|
const make = (storageWriter: ConvexStorageWriter) => ({
|
package/src/Table.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import * as Lazy from "@confect/core/Lazy";
|
|
1
2
|
import * as SystemFields from "@confect/core/SystemFields";
|
|
2
3
|
import {
|
|
3
4
|
defineTable,
|
|
@@ -12,7 +13,8 @@ import {
|
|
|
12
13
|
type VectorIndexConfig,
|
|
13
14
|
} from "convex/server";
|
|
14
15
|
import type { GenericValidator, Validator } from "convex/values";
|
|
15
|
-
import
|
|
16
|
+
import * as Predicate from "effect/Predicate";
|
|
17
|
+
import * as Schema from "effect/Schema";
|
|
16
18
|
import {
|
|
17
19
|
compileTableSchema,
|
|
18
20
|
type TableSchemaToTableValidator,
|
|
@@ -21,8 +23,26 @@ import {
|
|
|
21
23
|
export const TypeId = "@confect/server/Table";
|
|
22
24
|
export type TypeId = typeof TypeId;
|
|
23
25
|
|
|
26
|
+
// -----------------------------------------------------------------------------
|
|
27
|
+
// Predicates
|
|
28
|
+
// -----------------------------------------------------------------------------
|
|
29
|
+
//
|
|
30
|
+
// Both bound `Table`s and `UnnamedTable` callables share the same `[TypeId]`
|
|
31
|
+
// brand. They disambiguate by whether a `tableName` property is set: bound
|
|
32
|
+
// tables have one, unnamed callables do not.
|
|
33
|
+
//
|
|
34
|
+
// The discriminator is `tableName` (not `name`) so it does not collide with
|
|
35
|
+
// the built-in `Function.prototype.name` that every JS function carries.
|
|
36
|
+
|
|
24
37
|
export const isTable = (u: unknown): u is Any =>
|
|
25
|
-
Predicate.hasProperty(u, TypeId);
|
|
38
|
+
Predicate.hasProperty(u, TypeId) && Predicate.hasProperty(u, "tableName");
|
|
39
|
+
|
|
40
|
+
export const isUnnamedTable = (u: unknown): u is UnnamedAny =>
|
|
41
|
+
Predicate.hasProperty(u, TypeId) && !Predicate.hasProperty(u, "tableName");
|
|
42
|
+
|
|
43
|
+
// -----------------------------------------------------------------------------
|
|
44
|
+
// Bound Table
|
|
45
|
+
// -----------------------------------------------------------------------------
|
|
26
46
|
|
|
27
47
|
export interface Table<
|
|
28
48
|
Name_ extends string,
|
|
@@ -34,18 +54,65 @@ export interface Table<
|
|
|
34
54
|
VectorIndexes_ extends GenericTableVectorIndexes = {},
|
|
35
55
|
> {
|
|
36
56
|
readonly [TypeId]: TypeId;
|
|
57
|
+
readonly tableName: Name_;
|
|
37
58
|
readonly tableDefinition: TableDefinition<
|
|
38
59
|
TableValidator_,
|
|
39
60
|
Indexes_,
|
|
40
61
|
SearchIndexes_,
|
|
41
62
|
VectorIndexes_
|
|
42
63
|
>;
|
|
43
|
-
|
|
44
|
-
readonly name: Name_;
|
|
45
|
-
|
|
46
64
|
readonly Fields: TableSchema_;
|
|
47
65
|
readonly Doc: SystemFields.ExtendWithSystemFields<Name_, TableSchema_>;
|
|
66
|
+
readonly indexes: Indexes_;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface Any {
|
|
70
|
+
readonly [TypeId]: TypeId;
|
|
71
|
+
readonly tableName: string;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
export type AnyWithProps = Table<
|
|
75
|
+
any,
|
|
76
|
+
Schema.Schema.AnyNoContext,
|
|
77
|
+
GenericValidator,
|
|
78
|
+
GenericTableIndexes,
|
|
79
|
+
GenericTableSearchIndexes,
|
|
80
|
+
GenericTableVectorIndexes
|
|
81
|
+
>;
|
|
82
|
+
|
|
83
|
+
// -----------------------------------------------------------------------------
|
|
84
|
+
// UnnamedTable (callable)
|
|
85
|
+
// -----------------------------------------------------------------------------
|
|
86
|
+
//
|
|
87
|
+
// `Table.make(lazyFields)` returns an `UnnamedTable`: a callable that
|
|
88
|
+
// produces a fully bound `Table` when invoked with a name. Chaining methods
|
|
89
|
+
// (`.index`, `.searchIndex`, `.vectorIndex`) live here and return new
|
|
90
|
+
// `UnnamedTable`s, accumulating plain index metadata records. Neither the
|
|
91
|
+
// field-schema nor the deploy-time `tableDefinition` is constructed at this
|
|
92
|
+
// stage — the user-supplied `lazyFields` callback is just carried through.
|
|
93
|
+
// The codegen pipeline emits a wrapper file per user-authored table that
|
|
94
|
+
// simply invokes the unnamed callable with the filename basename.
|
|
95
|
+
|
|
96
|
+
export interface UnnamedTable<
|
|
97
|
+
TableSchema_ extends Schema.Schema.AnyNoContext,
|
|
98
|
+
TableValidator_ extends GenericValidator =
|
|
99
|
+
TableSchemaToTableValidator<TableSchema_>,
|
|
100
|
+
Indexes_ extends GenericTableIndexes = {},
|
|
101
|
+
SearchIndexes_ extends GenericTableSearchIndexes = {},
|
|
102
|
+
VectorIndexes_ extends GenericTableVectorIndexes = {},
|
|
103
|
+
> {
|
|
104
|
+
<const Name_ extends string>(
|
|
105
|
+
tableName: Name_,
|
|
106
|
+
): Table<
|
|
107
|
+
Name_,
|
|
108
|
+
TableSchema_,
|
|
109
|
+
TableValidator_,
|
|
110
|
+
Indexes_,
|
|
111
|
+
SearchIndexes_,
|
|
112
|
+
VectorIndexes_
|
|
113
|
+
>;
|
|
48
114
|
|
|
115
|
+
readonly [TypeId]: TypeId;
|
|
49
116
|
readonly indexes: Indexes_;
|
|
50
117
|
|
|
51
118
|
index<
|
|
@@ -55,8 +122,7 @@ export interface Table<
|
|
|
55
122
|
>(
|
|
56
123
|
name: IndexName,
|
|
57
124
|
fields: [FirstFieldPath, ...RestFieldPaths],
|
|
58
|
-
):
|
|
59
|
-
Name_,
|
|
125
|
+
): UnnamedTable<
|
|
60
126
|
TableSchema_,
|
|
61
127
|
TableValidator_,
|
|
62
128
|
Expand<
|
|
@@ -77,8 +143,7 @@ export interface Table<
|
|
|
77
143
|
>(
|
|
78
144
|
name: IndexName,
|
|
79
145
|
indexConfig: Expand<SearchIndexConfig<SearchField, FilterFields>>,
|
|
80
|
-
):
|
|
81
|
-
Name_,
|
|
146
|
+
): UnnamedTable<
|
|
82
147
|
TableSchema_,
|
|
83
148
|
TableValidator_,
|
|
84
149
|
Indexes_,
|
|
@@ -102,8 +167,7 @@ export interface Table<
|
|
|
102
167
|
>(
|
|
103
168
|
name: IndexName,
|
|
104
169
|
indexConfig: Expand<VectorIndexConfig<VectorField, FilterFields>>,
|
|
105
|
-
):
|
|
106
|
-
Name_,
|
|
170
|
+
): UnnamedTable<
|
|
107
171
|
TableSchema_,
|
|
108
172
|
TableValidator_,
|
|
109
173
|
Indexes_,
|
|
@@ -122,12 +186,11 @@ export interface Table<
|
|
|
122
186
|
>;
|
|
123
187
|
}
|
|
124
188
|
|
|
125
|
-
export interface
|
|
189
|
+
export interface UnnamedAny {
|
|
126
190
|
readonly [TypeId]: TypeId;
|
|
127
191
|
}
|
|
128
192
|
|
|
129
|
-
export type
|
|
130
|
-
any,
|
|
193
|
+
export type UnnamedAnyWithProps = UnnamedTable<
|
|
131
194
|
Schema.Schema.AnyNoContext,
|
|
132
195
|
GenericValidator,
|
|
133
196
|
GenericTableIndexes,
|
|
@@ -135,6 +198,10 @@ export type AnyWithProps = Table<
|
|
|
135
198
|
GenericTableVectorIndexes
|
|
136
199
|
>;
|
|
137
200
|
|
|
201
|
+
// -----------------------------------------------------------------------------
|
|
202
|
+
// Type extractors
|
|
203
|
+
// -----------------------------------------------------------------------------
|
|
204
|
+
|
|
138
205
|
export type Name<TableDef extends AnyWithProps> =
|
|
139
206
|
TableDef extends Table<
|
|
140
207
|
infer TableName,
|
|
@@ -234,162 +301,217 @@ export type Fields<TableDef extends AnyWithProps> =
|
|
|
234
301
|
export type WithName<
|
|
235
302
|
TableDef extends AnyWithProps,
|
|
236
303
|
Name_ extends string,
|
|
237
|
-
> = TableDef extends { readonly
|
|
304
|
+
> = TableDef extends { readonly tableName: Name_ } ? TableDef : never;
|
|
238
305
|
|
|
239
306
|
export type TablesRecord<Tables extends AnyWithProps> = {
|
|
240
307
|
readonly [TableName_ in Name<Tables>]: WithName<Tables, TableName_>;
|
|
241
308
|
};
|
|
242
309
|
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
name: IndexName,
|
|
270
|
-
indexConfig: SearchIndexConfig<SearchField, any>,
|
|
271
|
-
) {
|
|
272
|
-
return makeProto({
|
|
273
|
-
name: this.name,
|
|
274
|
-
Fields: this.Fields,
|
|
275
|
-
Doc: this.Doc,
|
|
276
|
-
tableDefinition: this.tableDefinition.searchIndex(name, indexConfig),
|
|
277
|
-
indexes: this.indexes,
|
|
278
|
-
});
|
|
279
|
-
},
|
|
280
|
-
|
|
281
|
-
vectorIndex<IndexName extends string, VectorField extends string>(
|
|
282
|
-
this: AnyWithProps,
|
|
283
|
-
name: IndexName,
|
|
284
|
-
indexConfig: {
|
|
285
|
-
vectorField: VectorField;
|
|
286
|
-
dimensions: number;
|
|
287
|
-
filterFields?: string[] | undefined;
|
|
288
|
-
},
|
|
289
|
-
) {
|
|
290
|
-
return makeProto({
|
|
291
|
-
name: this.name,
|
|
292
|
-
Fields: this.Fields,
|
|
293
|
-
Doc: this.Doc,
|
|
294
|
-
tableDefinition: this.tableDefinition.vectorIndex(name, {
|
|
295
|
-
vectorField: indexConfig.vectorField,
|
|
296
|
-
dimensions: indexConfig.dimensions,
|
|
297
|
-
...(indexConfig.filterFields
|
|
298
|
-
? { filterFields: indexConfig.filterFields }
|
|
299
|
-
: {}),
|
|
300
|
-
}),
|
|
301
|
-
indexes: this.indexes,
|
|
302
|
-
});
|
|
303
|
-
},
|
|
304
|
-
};
|
|
310
|
+
// -----------------------------------------------------------------------------
|
|
311
|
+
// Construction
|
|
312
|
+
// -----------------------------------------------------------------------------
|
|
313
|
+
//
|
|
314
|
+
// `make` only stores the user-supplied `lazyFields` callback alongside any
|
|
315
|
+
// chained index metadata. Neither `Fields` nor `Doc` nor `tableDefinition`
|
|
316
|
+
// is constructed until first access on a bound `Table`. Each chain step is
|
|
317
|
+
// O(1) (plain object spread of the metadata records) and never invokes the
|
|
318
|
+
// callback. Binding via `unnamed(tableName)` installs lazy memoised getters
|
|
319
|
+
// for `Fields`, `Doc`, and `tableDefinition` via `Lazy.defineProperty`, so the
|
|
320
|
+
// first access materialises the value and replaces the getter with a plain
|
|
321
|
+
// data property — second-and-subsequent accesses are observably
|
|
322
|
+
// indistinguishable from a plain property and avoid all function-call
|
|
323
|
+
// overhead.
|
|
324
|
+
|
|
325
|
+
interface UnnamedState<
|
|
326
|
+
TableSchema_ extends Schema.Schema.AnyNoContext,
|
|
327
|
+
Indexes_ extends GenericTableIndexes,
|
|
328
|
+
SearchIndexes_ extends GenericTableSearchIndexes,
|
|
329
|
+
VectorIndexes_ extends GenericTableVectorIndexes,
|
|
330
|
+
> {
|
|
331
|
+
readonly lazyFields: () => TableSchema_;
|
|
332
|
+
readonly indexes: Indexes_;
|
|
333
|
+
readonly searchIndexes: SearchIndexes_;
|
|
334
|
+
readonly vectorIndexes: VectorIndexes_;
|
|
335
|
+
}
|
|
305
336
|
|
|
306
|
-
const
|
|
337
|
+
const makeBound = <
|
|
307
338
|
Name_ extends string,
|
|
308
339
|
TableSchema_ extends Schema.Schema.AnyNoContext,
|
|
309
340
|
TableValidator_ extends Validator<any, any, any>,
|
|
310
341
|
Indexes_ extends GenericTableIndexes,
|
|
311
342
|
SearchIndexes_ extends GenericTableSearchIndexes,
|
|
312
343
|
VectorIndexes_ extends GenericTableVectorIndexes,
|
|
313
|
-
>(
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
tableDefinition,
|
|
318
|
-
indexes,
|
|
319
|
-
}: {
|
|
320
|
-
name: Name_;
|
|
321
|
-
Fields: TableSchema_;
|
|
322
|
-
Doc: SystemFields.ExtendWithSystemFields<Name_, TableSchema_>;
|
|
323
|
-
tableDefinition: TableDefinition<
|
|
324
|
-
TableValidator_,
|
|
325
|
-
Indexes_,
|
|
326
|
-
SearchIndexes_,
|
|
327
|
-
VectorIndexes_
|
|
328
|
-
>;
|
|
329
|
-
indexes: Indexes_;
|
|
330
|
-
}): Table<
|
|
344
|
+
>(
|
|
345
|
+
tableName: Name_,
|
|
346
|
+
state: UnnamedState<TableSchema_, Indexes_, SearchIndexes_, VectorIndexes_>,
|
|
347
|
+
): Table<
|
|
331
348
|
Name_,
|
|
332
349
|
TableSchema_,
|
|
333
350
|
TableValidator_,
|
|
334
351
|
Indexes_,
|
|
335
352
|
SearchIndexes_,
|
|
336
353
|
VectorIndexes_
|
|
337
|
-
> =>
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
354
|
+
> => {
|
|
355
|
+
const bound = {
|
|
356
|
+
[TypeId]: TypeId as TypeId,
|
|
357
|
+
tableName,
|
|
358
|
+
indexes: state.indexes,
|
|
359
|
+
} as Table<
|
|
360
|
+
Name_,
|
|
361
|
+
TableSchema_,
|
|
362
|
+
TableValidator_,
|
|
363
|
+
Indexes_,
|
|
364
|
+
SearchIndexes_,
|
|
365
|
+
VectorIndexes_
|
|
366
|
+
>;
|
|
367
|
+
|
|
368
|
+
Lazy.defineProperty(bound, "Fields", () => state.lazyFields());
|
|
369
|
+
|
|
370
|
+
Lazy.defineProperty(bound, "Doc", () =>
|
|
371
|
+
SystemFields.extendWithSystemFields(
|
|
372
|
+
tableName,
|
|
373
|
+
(bound as { Fields: TableSchema_ }).Fields,
|
|
374
|
+
),
|
|
375
|
+
);
|
|
376
|
+
|
|
377
|
+
Lazy.defineProperty(bound, "tableDefinition", () => {
|
|
378
|
+
const fields = (bound as { Fields: TableSchema_ }).Fields;
|
|
379
|
+
let definition: TableDefinition<any, any, any, any> = defineTable(
|
|
380
|
+
compileTableSchema(fields),
|
|
381
|
+
);
|
|
382
|
+
for (const [name, indexFields] of Object.entries(
|
|
383
|
+
state.indexes as Record<string, any>,
|
|
384
|
+
)) {
|
|
385
|
+
definition = definition.index(name, indexFields);
|
|
386
|
+
}
|
|
387
|
+
for (const [name, config] of Object.entries(
|
|
388
|
+
state.searchIndexes as Record<string, any>,
|
|
389
|
+
)) {
|
|
390
|
+
definition = definition.searchIndex(name, config);
|
|
391
|
+
}
|
|
392
|
+
for (const [name, config] of Object.entries(
|
|
393
|
+
state.vectorIndexes as Record<string, any>,
|
|
394
|
+
)) {
|
|
395
|
+
definition = definition.vectorIndex(name, config);
|
|
396
|
+
}
|
|
397
|
+
return definition;
|
|
344
398
|
});
|
|
345
399
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
const Name_ extends string,
|
|
400
|
+
return bound;
|
|
401
|
+
};
|
|
402
|
+
|
|
403
|
+
const makeUnnamed = <
|
|
351
404
|
TableSchema_ extends Schema.Schema.AnyNoContext,
|
|
352
|
-
TableValidator_ extends
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
VectorIndexes_ extends GenericTableVectorIndexes = {},
|
|
405
|
+
TableValidator_ extends Validator<any, any, any>,
|
|
406
|
+
Indexes_ extends GenericTableIndexes,
|
|
407
|
+
SearchIndexes_ extends GenericTableSearchIndexes,
|
|
408
|
+
VectorIndexes_ extends GenericTableVectorIndexes,
|
|
357
409
|
>(
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
): Table<
|
|
361
|
-
Name_,
|
|
410
|
+
state: UnnamedState<TableSchema_, Indexes_, SearchIndexes_, VectorIndexes_>,
|
|
411
|
+
): UnnamedTable<
|
|
362
412
|
TableSchema_,
|
|
363
413
|
TableValidator_,
|
|
364
414
|
Indexes_,
|
|
365
415
|
SearchIndexes_,
|
|
366
416
|
VectorIndexes_
|
|
367
417
|
> => {
|
|
368
|
-
|
|
369
|
-
|
|
418
|
+
type UnnamedTable_ = UnnamedTable<
|
|
419
|
+
TableSchema_,
|
|
420
|
+
TableValidator_,
|
|
421
|
+
Indexes_,
|
|
422
|
+
SearchIndexes_,
|
|
423
|
+
VectorIndexes_
|
|
424
|
+
>;
|
|
370
425
|
|
|
371
|
-
|
|
426
|
+
type UnnamedTableFunction<FunctionName extends keyof UnnamedTable_> =
|
|
427
|
+
UnnamedTable_[FunctionName];
|
|
428
|
+
|
|
429
|
+
const bind = <const Name_ extends string>(
|
|
430
|
+
tableName: Name_,
|
|
431
|
+
): Table<
|
|
372
432
|
Name_,
|
|
373
433
|
TableSchema_,
|
|
374
434
|
TableValidator_,
|
|
375
435
|
Indexes_,
|
|
376
436
|
SearchIndexes_,
|
|
377
437
|
VectorIndexes_
|
|
378
|
-
>
|
|
438
|
+
> =>
|
|
439
|
+
makeBound<
|
|
440
|
+
Name_,
|
|
441
|
+
TableSchema_,
|
|
442
|
+
TableValidator_,
|
|
443
|
+
Indexes_,
|
|
444
|
+
SearchIndexes_,
|
|
445
|
+
VectorIndexes_
|
|
446
|
+
>(tableName, state);
|
|
447
|
+
|
|
448
|
+
const index: UnnamedTableFunction<"index"> = (name, fields) =>
|
|
449
|
+
makeUnnamed({
|
|
450
|
+
lazyFields: state.lazyFields,
|
|
451
|
+
indexes: {
|
|
452
|
+
...state.indexes,
|
|
453
|
+
[name]: fields,
|
|
454
|
+
} as any,
|
|
455
|
+
searchIndexes: state.searchIndexes,
|
|
456
|
+
vectorIndexes: state.vectorIndexes,
|
|
457
|
+
});
|
|
458
|
+
|
|
459
|
+
const searchIndex: UnnamedTableFunction<"searchIndex"> = (
|
|
379
460
|
name,
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
461
|
+
indexConfig,
|
|
462
|
+
) =>
|
|
463
|
+
makeUnnamed({
|
|
464
|
+
lazyFields: state.lazyFields,
|
|
465
|
+
indexes: state.indexes,
|
|
466
|
+
searchIndexes: {
|
|
467
|
+
...state.searchIndexes,
|
|
468
|
+
[name]: indexConfig,
|
|
469
|
+
} as any,
|
|
470
|
+
vectorIndexes: state.vectorIndexes,
|
|
471
|
+
});
|
|
472
|
+
|
|
473
|
+
const vectorIndex: UnnamedTableFunction<"vectorIndex"> = (
|
|
474
|
+
name,
|
|
475
|
+
indexConfig,
|
|
476
|
+
) =>
|
|
477
|
+
makeUnnamed({
|
|
478
|
+
lazyFields: state.lazyFields,
|
|
479
|
+
indexes: state.indexes,
|
|
480
|
+
searchIndexes: state.searchIndexes,
|
|
481
|
+
vectorIndexes: {
|
|
482
|
+
...state.vectorIndexes,
|
|
483
|
+
[name]: indexConfig,
|
|
484
|
+
} as any,
|
|
485
|
+
});
|
|
486
|
+
|
|
487
|
+
return Object.assign(bind, {
|
|
488
|
+
[TypeId]: TypeId as TypeId,
|
|
489
|
+
indexes: state.indexes,
|
|
490
|
+
index,
|
|
491
|
+
searchIndex,
|
|
492
|
+
vectorIndex,
|
|
493
|
+
}) satisfies UnnamedTable_;
|
|
494
|
+
};
|
|
495
|
+
|
|
496
|
+
export const make = <const TableSchema_ extends Schema.Schema.AnyNoContext>(
|
|
497
|
+
lazyFields: () => TableSchema_,
|
|
498
|
+
): UnnamedTable<TableSchema_, TableSchemaToTableValidator<TableSchema_>> => {
|
|
499
|
+
type TableValidator_ = TableSchemaToTableValidator<TableSchema_>;
|
|
500
|
+
type UnnamedTable_ = UnnamedTable<TableSchema_, TableValidator_>;
|
|
501
|
+
|
|
502
|
+
return makeUnnamed<TableSchema_, TableValidator_, {}, {}, {}>({
|
|
503
|
+
lazyFields,
|
|
504
|
+
indexes: {},
|
|
505
|
+
searchIndexes: {},
|
|
506
|
+
vectorIndexes: {},
|
|
507
|
+
}) satisfies UnnamedTable_;
|
|
385
508
|
};
|
|
386
509
|
|
|
387
510
|
// -----------------------------------------------------------------------------
|
|
388
511
|
// System tables
|
|
389
512
|
// -----------------------------------------------------------------------------
|
|
390
513
|
|
|
391
|
-
export const scheduledFunctionsTable = make(
|
|
392
|
-
"_scheduled_functions",
|
|
514
|
+
export const scheduledFunctionsTable = make(() =>
|
|
393
515
|
Schema.Struct({
|
|
394
516
|
name: Schema.String,
|
|
395
517
|
args: Schema.Array(Schema.Any),
|
|
@@ -406,16 +528,15 @@ export const scheduledFunctionsTable = make(
|
|
|
406
528
|
Schema.Struct({ kind: Schema.Literal("canceled") }),
|
|
407
529
|
),
|
|
408
530
|
}),
|
|
409
|
-
);
|
|
531
|
+
)("_scheduled_functions");
|
|
410
532
|
|
|
411
|
-
export const storageTable = make(
|
|
412
|
-
"_storage",
|
|
533
|
+
export const storageTable = make(() =>
|
|
413
534
|
Schema.Struct({
|
|
414
535
|
sha256: Schema.String,
|
|
415
536
|
size: Schema.Number,
|
|
416
537
|
contentType: Schema.optionalWith(Schema.String, { exact: true }),
|
|
417
538
|
}),
|
|
418
|
-
);
|
|
539
|
+
)("_storage");
|
|
419
540
|
|
|
420
541
|
export const systemTables = {
|
|
421
542
|
_scheduled_functions: scheduledFunctionsTable,
|
package/src/VectorSearch.ts
CHANGED
|
@@ -6,7 +6,9 @@ import type {
|
|
|
6
6
|
VectorSearchQuery,
|
|
7
7
|
} from "convex/server";
|
|
8
8
|
import type { GenericId } from "convex/values";
|
|
9
|
-
import
|
|
9
|
+
import * as Context from "effect/Context";
|
|
10
|
+
import * as Effect from "effect/Effect";
|
|
11
|
+
import * as Layer from "effect/Layer";
|
|
10
12
|
import type * as DataModel from "./DataModel";
|
|
11
13
|
|
|
12
14
|
type ConvexVectorSearch<DataModel_ extends DataModel.AnyWithProps> =
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
export * as ActionCtx from "./ActionCtx";
|
|
2
2
|
export * as ActionRunner from "./ActionRunner";
|
|
3
|
-
export * as Api from "./Api";
|
|
4
3
|
export * as Auth from "./Auth";
|
|
5
4
|
export * as BlobNotFoundError from "./BlobNotFoundError";
|
|
6
5
|
export * as ConvexConfigProvider from "./ConvexConfigProvider";
|
package/src/internal/utils.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { Predicate } from "effect";
|
|
2
|
-
import
|
|
2
|
+
import * as Array from "effect/Array";
|
|
3
|
+
import * as Effect from "effect/Effect";
|
|
4
|
+
import * as Record from "effect/Record";
|
|
3
5
|
|
|
4
6
|
type NestedObject<T> = {
|
|
5
7
|
[key: string]: T | NestedObject<T>;
|
package/dist/Api.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { AnyWithProps as AnyWithProps$1 } from "./DatabaseSchema.js";
|
|
2
|
-
import { GenericSchema, SchemaDefinition } from "convex/server";
|
|
3
|
-
import { RuntimeAndFunctionType } from "@confect/core";
|
|
4
|
-
import * as Spec from "@confect/core/Spec";
|
|
5
|
-
|
|
6
|
-
//#region src/Api.d.ts
|
|
7
|
-
declare namespace Api_d_exports {
|
|
8
|
-
export { Any, AnyWithProps, AnyWithPropsWithRuntime, Api, GetSpec, Groups, Schema, TypeId, isApi, make };
|
|
9
|
-
}
|
|
10
|
-
declare const TypeId = "@confect/server/Api";
|
|
11
|
-
type TypeId = typeof TypeId;
|
|
12
|
-
declare const isApi: (u: unknown) => u is Any;
|
|
13
|
-
interface Api<DatabaseSchema_ extends AnyWithProps$1, Spec_ extends Spec.AnyWithProps> {
|
|
14
|
-
readonly [TypeId]: TypeId;
|
|
15
|
-
readonly spec: Spec_;
|
|
16
|
-
readonly databaseSchema: DatabaseSchema_;
|
|
17
|
-
readonly convexSchemaDefinition: SchemaDefinition<GenericSchema, true>;
|
|
18
|
-
}
|
|
19
|
-
interface Any {
|
|
20
|
-
readonly [TypeId]: TypeId;
|
|
21
|
-
}
|
|
22
|
-
interface AnyWithProps extends Api<AnyWithProps$1, Spec.AnyWithProps> {}
|
|
23
|
-
interface AnyWithPropsWithRuntime<Runtime extends RuntimeAndFunctionType.Runtime> extends Api<AnyWithProps$1, Spec.AnyWithPropsWithRuntime<Runtime>> {}
|
|
24
|
-
type Schema<Api_ extends AnyWithProps> = Api_["databaseSchema"];
|
|
25
|
-
type GetSpec<Api_ extends AnyWithProps> = Api_["spec"];
|
|
26
|
-
type Groups<Api_ extends AnyWithProps> = Spec.Groups<Api_["spec"]>;
|
|
27
|
-
declare const make: <DatabaseSchema_ extends AnyWithProps$1, Spec_ extends Spec.AnyWithProps>(databaseSchema: DatabaseSchema_, spec: Spec_) => Api<DatabaseSchema_, Spec_>;
|
|
28
|
-
//#endregion
|
|
29
|
-
export { Any, AnyWithProps, AnyWithPropsWithRuntime, Api, Api_d_exports, GetSpec, Groups, Schema, TypeId, isApi, make };
|
|
30
|
-
//# sourceMappingURL=Api.d.ts.map
|
package/dist/Api.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Api.d.ts","names":[],"sources":["../src/Api.ts"],"mappings":";;;;;;;;;cAOa,MAAA;AAAA,KACD,MAAA,UAAgB,MAAA;AAAA,cAEf,KAAA,GAAS,CAAA,cAAa,CAAA,IAAK,GAAA;AAAA,UAEvB,GAAA,yBACS,cAAA,gBACV,IAAA,CAAK,YAAA;EAAA,UAET,MAAA,GAAS,MAAA;EAAA,SACV,IAAA,EAAM,KAAA;EAAA,SACN,cAAA,EAAgB,eAAA;EAAA,SAChB,sBAAA,EAAwB,gBAAA,CAAiB,aAAA;AAAA;AAAA,UAGnC,GAAA;EAAA,UACL,MAAA,GAAS,MAAA;AAAA;AAAA,UAGJ,YAAA,SAAqB,GAAA,CACpC,cAAA,EACA,IAAA,CAAK,YAAA;AAAA,UAGU,uBAAA,iBACC,sBAAA,CAAuB,OAAA,UAC/B,GAAA,CACR,cAAA,EACA,IAAA,CAAK,uBAAA,CAAwB,OAAA;AAAA,KAGnB,MAAA,cAAoB,YAAA,IAAgB,IAAA;AAAA,KAEpC,OAAA,cAAqB,YAAA,IAAgB,IAAA;AAAA,KAErC,MAAA,cAAoB,YAAA,IAAgB,IAAA,CAAK,MAAA,CAAO,IAAA;AAAA,cA0B/C,IAAA,2BACa,cAAA,gBACV,IAAA,CAAK,YAAA,EAEnB,cAAA,EAAgB,eAAA,EAChB,IAAA,EAAM,KAAA,KACL,GAAA,CAAI,eAAA,EAAiB,KAAA"}
|
package/dist/Api.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { __exportAll } from "./_virtual/_rolldown/runtime.js";
|
|
2
|
-
import { Predicate, Record, pipe } from "effect";
|
|
3
|
-
import { defineSchema } from "convex/server";
|
|
4
|
-
|
|
5
|
-
//#region src/Api.ts
|
|
6
|
-
var Api_exports = /* @__PURE__ */ __exportAll({
|
|
7
|
-
TypeId: () => TypeId,
|
|
8
|
-
isApi: () => isApi,
|
|
9
|
-
make: () => make
|
|
10
|
-
});
|
|
11
|
-
const TypeId = "@confect/server/Api";
|
|
12
|
-
const isApi = (u) => Predicate.hasProperty(u, TypeId);
|
|
13
|
-
const Proto = { [TypeId]: TypeId };
|
|
14
|
-
const makeProto = ({ databaseSchema, spec }) => Object.assign(Object.create(Proto), {
|
|
15
|
-
databaseSchema,
|
|
16
|
-
spec,
|
|
17
|
-
convexSchemaDefinition: pipe(databaseSchema.tables, Record.map(({ tableDefinition }) => tableDefinition), defineSchema)
|
|
18
|
-
});
|
|
19
|
-
const make = (databaseSchema, spec) => makeProto({
|
|
20
|
-
databaseSchema,
|
|
21
|
-
spec
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
//#endregion
|
|
25
|
-
export { Api_exports, TypeId, isApi, make };
|
|
26
|
-
//# sourceMappingURL=Api.js.map
|