Describe the bug
If you have a multi-repo setup or dependencies with hard version requirements, instanced objects do not work across different library instances due to usage of instanceof. Additionally, private fields in the exported classes cause type conflicts because the classes are exported as-is, rather than exported as interface types.
Steps to reproduce
Setup a bun multi-repo workspace with surrealdb installed in multiple repos. Make one workspace contain types and utilities, and have at least one library that either depends on or is a peer dependency of Surrealdb. You'll observe that bun creates multiple bun installs for the different contexts, and instanceof checks (e.g. with RecordIds and other instanced classes) will not resolve correctly.
e.g.
Instanceof checks don't correctly resolve RecordIDs -- they emit { } to the underlying query.
Cannot execute DELETE statement using value: { }","status":500,"stack":"Error: Cannot execute DELETE statement using value: { }
Type errors because of #private properties not being rectifiable.
Types of parameters 'db' and 'db' are incompatible.
Type 'import("/home/knackstedt/TEST_REPO/node_modules/.bun/surrealdb@2.0.3+4b2c1f8f02d6f8a0/node_modules/surrealdb/dist/surrealdb").Surreal' is not assignable to type 'import("/home/knackstedt/TEST_REPO/node_modules/.bun/surrealdb@2.0.3+85580646e632dbd6/node_modules/surrealdb/dist/surrealdb").Surreal'.
Property '#private' in type 'Surreal' refers to a different member that cannot be accessed from within type 'Surreal'
Expected behaviour
Passing an instanced RecordId from v2.0.0 to v2.0.3 should run correctly, without relying on an instanceof check. Additionally, types can resolve to different libraries, but should only conflict if there's an interface delta between the versions, not because the #private fields can't be rectified between the two.
SurrealDB version
Irrelevant.
JavaScript SDK version
2.x.x
Contact Details
No response
Is there an existing issue for this?
Code of Conduct (repository /surrealdb.js)
Describe the bug
If you have a multi-repo setup or dependencies with hard version requirements, instanced objects do not work across different library instances due to usage of
instanceof. Additionally, private fields in the exported classes cause type conflicts because the classes are exported as-is, rather than exported as interface types.Steps to reproduce
Setup a bun multi-repo workspace with surrealdb installed in multiple repos. Make one workspace contain types and utilities, and have at least one library that either depends on or is a peer dependency of Surrealdb. You'll observe that bun creates multiple bun installs for the different contexts, and instanceof checks (e.g. with RecordIds and other instanced classes) will not resolve correctly.
e.g.
Instanceof checks don't correctly resolve RecordIDs -- they emit
{ }to the underlying query.Type errors because of #private properties not being rectifiable.
Expected behaviour
Passing an instanced RecordId from v2.0.0 to v2.0.3 should run correctly, without relying on an instanceof check. Additionally, types can resolve to different libraries, but should only conflict if there's an interface delta between the versions, not because the #private fields can't be rectified between the two.
SurrealDB version
Irrelevant.
JavaScript SDK version
2.x.x
Contact Details
No response
Is there an existing issue for this?
Code of Conduct (repository /surrealdb.js)