1- // @ts -nocheck
2-
31import { inherits } from 'node:util' ;
42import { Sequelize , DataTypes , Utils } from 'sequelize' ;
53import { sparsevecType , sparsevecToSql , sparsevecFromSql } from '../utils.js' ;
64
5+ /** @import { SparseVector } from '../index.js' */
6+
7+ // @ts -ignore
78const PgTypes = DataTypes . postgres ;
89const ABSTRACT = DataTypes . ABSTRACT . prototype . constructor ;
910
1011class SPARSEVEC extends ABSTRACT {
12+ /**
13+ * @param {number } [dimensions]
14+ */
1115 constructor ( dimensions ) {
1216 super ( ) ;
1317 this . _dimensions = dimensions ;
@@ -17,30 +21,42 @@ class SPARSEVEC extends ABSTRACT {
1721 return sparsevecType ( this . _dimensions ) . toUpperCase ( ) ;
1822 }
1923
24+ /**
25+ * @param {?SparseVector } value
26+ */
2027 _stringify ( value ) {
2128 return sparsevecToSql ( value ) ;
2229 }
2330
31+ /**
32+ * @param {?string } value
33+ */
2434 static parse ( value ) {
2535 return sparsevecFromSql ( value ) ;
2636 }
2737}
2838
2939SPARSEVEC . prototype . key = SPARSEVEC . key = 'sparsevec' ;
3040
41+ // @ts -ignore
3142DataTypes . SPARSEVEC = Utils . classToInvokable ( SPARSEVEC ) ;
43+ // @ts -ignore
3244DataTypes . SPARSEVEC . types . postgres = [ 'sparsevec' ] ;
3345
3446PgTypes . SPARSEVEC = function SPARSEVEC ( ) {
3547 if ( ! ( this instanceof PgTypes . SPARSEVEC ) ) {
3648 return new PgTypes . SPARSEVEC ( ) ;
3749 }
50+ // @ts -ignore
3851 DataTypes . SPARSEVEC . apply ( this , arguments ) ;
3952} ;
4053inherits ( PgTypes . SPARSEVEC , DataTypes . SPARSEVEC ) ;
54+ // @ts -ignore
4155PgTypes . SPARSEVEC . parse = DataTypes . SPARSEVEC . parse ;
4256PgTypes . SPARSEVEC . types = { postgres : [ 'sparsevec' ] } ;
57+ // @ts -ignore
4358DataTypes . postgres . SPARSEVEC . key = 'sparsevec' ;
4459
4560// for migrations
61+ // @ts -ignore
4662Sequelize . SPARSEVEC ??= DataTypes . SPARSEVEC ;
0 commit comments