convex-ents 0.7.7 → 0.8.0
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/dist/deletion.d.ts +1 -1
- package/dist/index.js +5 -14
- package/dist/index.js.map +1 -1
- package/dist/schema.d.ts +36 -47
- package/dist/schema.js +5 -14
- package/dist/schema.js.map +1 -1
- package/package.json +2 -2
package/dist/deletion.d.ts
CHANGED
|
@@ -13,7 +13,7 @@ type Origin = {
|
|
|
13
13
|
table: string;
|
|
14
14
|
deletionTime: number;
|
|
15
15
|
};
|
|
16
|
-
declare const vApproach: convex_values.
|
|
16
|
+
declare const vApproach: convex_values.VUnion<"cascade" | "paginate", [convex_values.VLiteral<"cascade", "required">, convex_values.VLiteral<"paginate", "required">], "required", never>;
|
|
17
17
|
type Approach = Infer<typeof vApproach>;
|
|
18
18
|
declare function scheduledDeleteFactory<EntsDataModel extends GenericEntsDataModel>(entDefinitions: EntsDataModel, options?: {
|
|
19
19
|
scheduledDelete: ScheduledDeleteFuncRef;
|
package/dist/index.js
CHANGED
|
@@ -191,30 +191,20 @@ function defineEnt(documentSchema) {
|
|
|
191
191
|
return new EntDefinitionImpl(documentSchema);
|
|
192
192
|
}
|
|
193
193
|
function defineEntFromTable(definition) {
|
|
194
|
-
const validator = definition.
|
|
195
|
-
|
|
196
|
-
// @ts-expect-error Private field
|
|
197
|
-
validator.json
|
|
198
|
-
);
|
|
199
|
-
if (validatorJson.type !== "object") {
|
|
194
|
+
const validator = definition.validator;
|
|
195
|
+
if (validator.kind !== "object") {
|
|
200
196
|
throw new Error(
|
|
201
197
|
"Only tables with object definition are supported in Ents, not unions"
|
|
202
198
|
);
|
|
203
199
|
}
|
|
204
|
-
const
|
|
205
|
-
Object.entries(validatorJson.value).map(([k, v3]) => [
|
|
206
|
-
k,
|
|
207
|
-
// @ts-expect-error Private constructor
|
|
208
|
-
new import_values.Validator(v3.fieldType, v3.optional)
|
|
209
|
-
])
|
|
210
|
-
);
|
|
211
|
-
const entDefinition = defineEnt(tableSchema);
|
|
200
|
+
const entDefinition = defineEnt(validator.fields);
|
|
212
201
|
entDefinition.indexes = definition.indexes;
|
|
213
202
|
entDefinition.searchIndexes = definition.searchIndexes;
|
|
214
203
|
entDefinition.vectorIndexes = definition.vectorIndexes;
|
|
215
204
|
return entDefinition;
|
|
216
205
|
}
|
|
217
206
|
var EntDefinitionImpl = class {
|
|
207
|
+
validator;
|
|
218
208
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
219
209
|
// @ts-ignore
|
|
220
210
|
indexes = [];
|
|
@@ -231,6 +221,7 @@ var EntDefinitionImpl = class {
|
|
|
231
221
|
deletionConfig;
|
|
232
222
|
constructor(documentSchema) {
|
|
233
223
|
this.documentSchema = documentSchema;
|
|
224
|
+
this.validator = import_values.v.object(documentSchema);
|
|
234
225
|
}
|
|
235
226
|
index(name, fields) {
|
|
236
227
|
this.indexes.push({ indexDescriptor: name, fields });
|