convex-ents
Advanced tools
Comparing version 0.9.3 to 0.9.4
@@ -26,7 +26,11 @@ "use strict"; | ||
module.exports = __toCommonJS(deletion_exports); | ||
var import_server2 = require("convex/server"); | ||
var import_server3 = require("convex/server"); | ||
var import_values2 = require("convex/values"); | ||
// src/schema.ts | ||
var import_server = require("convex/server"); | ||
var import_values = require("convex/values"); | ||
// src/writer.ts | ||
var import_server = require("convex/server"); | ||
var import_server2 = require("convex/server"); | ||
@@ -39,37 +43,37 @@ // src/functions.ts | ||
// src/deletion.ts | ||
var vApproach = import_values.v.union(import_values.v.literal("cascade"), import_values.v.literal("paginate")); | ||
var vApproach = import_values2.v.union(import_values2.v.literal("cascade"), import_values2.v.literal("paginate")); | ||
function scheduledDeleteFactory(entDefinitions, options) { | ||
const selfRef = options?.scheduledDelete ?? (0, import_server2.makeFunctionReference)( | ||
const selfRef = options?.scheduledDelete ?? (0, import_server3.makeFunctionReference)( | ||
"functions:scheduledDelete" | ||
); | ||
return (0, import_server2.internalMutationGeneric)({ | ||
return (0, import_server3.internalMutationGeneric)({ | ||
args: { | ||
origin: import_values.v.object({ | ||
id: import_values.v.string(), | ||
table: import_values.v.string(), | ||
deletionTime: import_values.v.number() | ||
origin: import_values2.v.object({ | ||
id: import_values2.v.string(), | ||
table: import_values2.v.string(), | ||
deletionTime: import_values2.v.number() | ||
}), | ||
stack: import_values.v.array( | ||
import_values.v.union( | ||
import_values.v.object({ | ||
id: import_values.v.string(), | ||
table: import_values.v.string(), | ||
edges: import_values.v.array( | ||
import_values.v.object({ | ||
stack: import_values2.v.array( | ||
import_values2.v.union( | ||
import_values2.v.object({ | ||
id: import_values2.v.string(), | ||
table: import_values2.v.string(), | ||
edges: import_values2.v.array( | ||
import_values2.v.object({ | ||
approach: vApproach, | ||
table: import_values.v.string(), | ||
indexName: import_values.v.string() | ||
table: import_values2.v.string(), | ||
indexName: import_values2.v.string() | ||
}) | ||
) | ||
}), | ||
import_values.v.object({ | ||
import_values2.v.object({ | ||
approach: vApproach, | ||
cursor: import_values.v.union(import_values.v.string(), import_values.v.null()), | ||
table: import_values.v.string(), | ||
indexName: import_values.v.string(), | ||
fieldValue: import_values.v.any() | ||
cursor: import_values2.v.union(import_values2.v.string(), import_values2.v.null()), | ||
table: import_values2.v.string(), | ||
indexName: import_values2.v.string(), | ||
fieldValue: import_values2.v.any() | ||
}) | ||
) | ||
), | ||
inProgress: import_values.v.boolean() | ||
inProgress: import_values2.v.boolean() | ||
}, | ||
@@ -264,3 +268,3 @@ handler: async (ctx, { origin, stack, inProgress }) => { | ||
} | ||
const size = JSON.stringify((0, import_values.convexToJson)(doc)).length * 8; | ||
const size = JSON.stringify((0, import_values2.convexToJson)(doc)).length * 8; | ||
results.push(doc); | ||
@@ -267,0 +271,0 @@ bytesRead += size; |
@@ -33,4 +33,11 @@ "use strict"; | ||
// src/schema.ts | ||
var import_server = require("convex/server"); | ||
var import_values = require("convex/values"); | ||
function edgeCompoundIndexName(idA, idB) { | ||
return `${idA}_${idB}`; | ||
} | ||
// src/writer.ts | ||
var import_server = require("convex/server"); | ||
var import_server2 = require("convex/server"); | ||
var WriterImplBase = class _WriterImplBase { | ||
@@ -92,3 +99,3 @@ constructor(ctx, entDefinitions, table) { | ||
if (deletionConfig !== void 0 && deletionConfig.type === "scheduled") { | ||
const fnRef = this.ctx.scheduledDelete ?? (0, import_server.makeFunctionReference)( | ||
const fnRef = this.ctx.scheduledDelete ?? (0, import_server2.makeFunctionReference)( | ||
"functions:scheduledDelete" | ||
@@ -158,3 +165,6 @@ ); | ||
const existing = await this.ctx.db.query(edgeDefinition.table).withIndex( | ||
edgeDefinition.field, | ||
edgeCompoundIndexName( | ||
edgeDefinition.field, | ||
edgeDefinition.ref | ||
), | ||
(q) => q.eq(edgeDefinition.field, docId).eq( | ||
@@ -810,3 +820,6 @@ edgeDefinition.ref, | ||
const edgeDoc = this.ctx.db.query(this.edgeDefinition.table).withIndex( | ||
`${this.edgeDefinition.field}_${this.edgeDefinition.ref}`, | ||
edgeCompoundIndexName( | ||
this.edgeDefinition.field, | ||
this.edgeDefinition.ref | ||
), | ||
(q) => q.eq(this.edgeDefinition.field, sourceId).eq( | ||
@@ -813,0 +826,0 @@ this.edgeDefinition.ref, |
@@ -5,2 +5,3 @@ import { DefineSchemaOptions, SchemaDefinition, GenericTableIndexes, GenericTableSearchIndexes, GenericTableVectorIndexes, TableDefinition, SearchIndexConfig, VectorIndexConfig, GenericDataModel, DataModelFromSchemaDefinition } from 'convex/server'; | ||
declare function defineEntSchema<Schema extends Record<string, EntDefinition>, StrictTableNameTypes extends boolean = true>(schema: Schema, options?: DefineSchemaOptions<StrictTableNameTypes>): SchemaDefinition<Schema, StrictTableNameTypes>; | ||
declare function edgeCompoundIndexName(idA: string, idB: string): string; | ||
declare function defineEnt<DocumentSchema extends PropertyValidators>(documentSchema: DocumentSchema): EntDefinition<ObjectValidator<DocumentSchema>>; | ||
@@ -331,2 +332,2 @@ declare function defineEntFromTable<DocumentType extends GenericValidator = GenericValidator, Indexes extends GenericTableIndexes = {}, SearchIndexes extends GenericTableSearchIndexes = {}, VectorIndexes extends GenericTableVectorIndexes = {}>(definition: TableDefinition<DocumentType, Indexes, SearchIndexes, VectorIndexes>): EntDefinition<DocumentType, Indexes, SearchIndexes, VectorIndexes>; | ||
export { type DeletionConfig, type EdgeConfig, type EntDataModelFromSchema, type EntDefinition, type Expand, type FieldConfig, type GenericEdgeConfig, type GenericEntModel, type GenericEntsDataModel, type SystemFields, defineEnt, defineEntFromTable, defineEntSchema, defineEntsFromTables, getEntDefinitions }; | ||
export { type DeletionConfig, type EdgeConfig, type EntDataModelFromSchema, type EntDefinition, type Expand, type FieldConfig, type GenericEdgeConfig, type GenericEntModel, type GenericEntsDataModel, type SystemFields, defineEnt, defineEntFromTable, defineEntSchema, defineEntsFromTables, edgeCompoundIndexName, getEntDefinitions }; |
@@ -27,2 +27,3 @@ "use strict"; | ||
defineEntsFromTables: () => defineEntsFromTables, | ||
edgeCompoundIndexName: () => edgeCompoundIndexName, | ||
getEntDefinitions: () => getEntDefinitions | ||
@@ -133,6 +134,9 @@ }); | ||
[inverseId]: import_values.v.id(otherTableName) | ||
}).index(forwardId, [forwardId]).index(inverseId, [inverseId]).index(`${forwardId}_${inverseId}`, [forwardId, inverseId]); | ||
}).index(forwardId, [forwardId]).index(inverseId, [inverseId]).index(edgeCompoundIndexName(forwardId, inverseId), [ | ||
forwardId, | ||
inverseId | ||
]); | ||
const isSymmetric = inverseEdge === void 0; | ||
if (!isSymmetric) { | ||
edgeTable.index(`${inverseId}_${forwardId}`, [ | ||
edgeTable.index(edgeCompoundIndexName(inverseId, forwardId), [ | ||
inverseId, | ||
@@ -161,2 +165,5 @@ forwardId | ||
} | ||
function edgeCompoundIndexName(idA, idB) { | ||
return `${idA}_${idB}`; | ||
} | ||
function canBeInverseEdge(tableName, edge, isSelfDirected) { | ||
@@ -401,4 +408,5 @@ return (candidate) => { | ||
defineEntsFromTables, | ||
edgeCompoundIndexName, | ||
getEntDefinitions | ||
}); | ||
//# sourceMappingURL=schema.js.map |
@@ -26,3 +26,10 @@ "use strict"; | ||
module.exports = __toCommonJS(writer_exports); | ||
var import_server2 = require("convex/server"); | ||
// src/schema.ts | ||
var import_server = require("convex/server"); | ||
var import_values = require("convex/values"); | ||
function edgeCompoundIndexName(idA, idB) { | ||
return `${idA}_${idB}`; | ||
} | ||
@@ -408,3 +415,6 @@ // src/functions.ts | ||
const edgeDoc = this.ctx.db.query(this.edgeDefinition.table).withIndex( | ||
`${this.edgeDefinition.field}_${this.edgeDefinition.ref}`, | ||
edgeCompoundIndexName( | ||
this.edgeDefinition.field, | ||
this.edgeDefinition.ref | ||
), | ||
(q) => q.eq(this.edgeDefinition.field, sourceId).eq( | ||
@@ -1074,3 +1084,3 @@ this.edgeDefinition.ref, | ||
if (deletionConfig !== void 0 && deletionConfig.type === "scheduled") { | ||
const fnRef = this.ctx.scheduledDelete ?? (0, import_server.makeFunctionReference)( | ||
const fnRef = this.ctx.scheduledDelete ?? (0, import_server2.makeFunctionReference)( | ||
"functions:scheduledDelete" | ||
@@ -1140,3 +1150,6 @@ ); | ||
const existing = await this.ctx.db.query(edgeDefinition.table).withIndex( | ||
edgeDefinition.field, | ||
edgeCompoundIndexName( | ||
edgeDefinition.field, | ||
edgeDefinition.ref | ||
), | ||
(q) => q.eq(edgeDefinition.field, docId).eq( | ||
@@ -1143,0 +1156,0 @@ edgeDefinition.ref, |
{ | ||
"name": "convex-ents", | ||
"version": "0.9.3", | ||
"version": "0.9.4", | ||
"description": "Relations, default values, unique fields, RLS for Convex", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1015127
6549