@eltjs/vectorizer 0.13.8 → 0.13.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.
@@ -113,27 +113,33 @@ export class KeywordIndex extends DerivedDataset {
113
113
  // Makes the catalog when the database has none, and the table and its
114
114
  // full-text index again when the table does not keep the hash of this
115
115
  // declaration or has no full-text index. A server with no Full-Text Search
116
- // refuses the catalog, before the member makes anything.
116
+ // makes the catalog, which is only metadata, and refuses the full-text
117
+ // index (probed on SQL Server 2022): the member then drops the table that
118
+ // it made just before, so it leaves no keywords table.
117
119
  async #declare(session) {
120
+ await session.query(`IF NOT EXISTS (SELECT 1 FROM sys.fulltext_catalogs WHERE [name] = ${literal(this.name)}) CREATE FULLTEXT CATALOG ${this.#catalog}`);
121
+ const [stored] = await session.query(`SELECT (SELECT CAST([value] AS nvarchar(100)) FROM sys.extended_properties WHERE [class] = 1 AND [major_id] = OBJECT_ID(@table) AND [minor_id] = 0 AND [name] = N'elt_declaration') AS [declared],
122
+ (SELECT COUNT(*) FROM sys.fulltext_indexes WHERE [object_id] = OBJECT_ID(@table)) AS [indexed]`, { table: this.#table });
123
+ if (stored?.declared === this.#declared && Number(stored.indexed) === 1)
124
+ return;
125
+ await session.query(`IF EXISTS (SELECT 1 FROM sys.fulltext_indexes WHERE [object_id] = OBJECT_ID(${literal(this.#table)})) DROP FULLTEXT INDEX ON ${this.#table}`);
126
+ await session.query(`DROP TABLE IF EXISTS ${this.#table}`);
118
127
  try {
119
- await session.query(`IF NOT EXISTS (SELECT 1 FROM sys.fulltext_catalogs WHERE [name] = ${literal(this.name)}) CREATE FULLTEXT CATALOG ${this.#catalog}`);
128
+ for (const statement of this.#declaration)
129
+ await session.query(statement);
120
130
  }
121
131
  catch (error) {
122
132
  if (numberOf(error) !== noFullTextSearch)
123
133
  throw error;
134
+ await session.query(`DROP TABLE IF EXISTS ${this.#table}`);
124
135
  throw new SqlServerSetupError(`Keyword index ${this.name} needs Full-Text Search, and the server has none: install it (on Linux, the package mssql-server-fts), or use Azure SQL Database, which has it`, { cause: error });
125
136
  }
126
- const [stored] = await session.query(`SELECT (SELECT CAST([value] AS nvarchar(100)) FROM sys.extended_properties WHERE [class] = 1 AND [major_id] = OBJECT_ID(@table) AND [minor_id] = 0 AND [name] = N'elt_declaration') AS [declared],
127
- (SELECT COUNT(*) FROM sys.fulltext_indexes WHERE [object_id] = OBJECT_ID(@table)) AS [indexed]`, { table: this.#table });
128
- if (stored?.declared === this.#declared && Number(stored.indexed) === 1)
129
- return;
130
- await session.query(`IF EXISTS (SELECT 1 FROM sys.fulltext_indexes WHERE [object_id] = OBJECT_ID(${literal(this.#table)})) DROP FULLTEXT INDEX ON ${this.#table}`);
131
- await session.query(`DROP TABLE IF EXISTS ${this.#table}`);
132
- for (const statement of this.#declaration)
133
- await session.query(statement);
134
137
  // Last, so a make that stopped half way is made again by the next
135
- // refresh.
136
- await session.query(`EXEC sp_addextendedproperty @name = N'elt_declaration', @value = @declared, @level0type = N'SCHEMA', @level0name = @schema, @level1type = N'TABLE', @level1name = @table`, { declared: this.#declared, schema: marts, table: this.name });
138
+ // refresh. The connection sends each parameter as nvarchar(max), which
139
+ // the sql_variant value of a property refuses (error 206), so the hash
140
+ // goes through a variable of a fixed length, as elt-sqlserver's
141
+ // descriptions do.
142
+ await session.query(`DECLARE @value nvarchar(100) = @declared; EXEC sp_addextendedproperty @name = N'elt_declaration', @value = @value, @level0type = N'SCHEMA', @level0name = @schema, @level1type = N'TABLE', @level1name = @table`, { declared: this.#declared, schema: marts, table: this.name });
137
143
  }
138
144
  // Writes each passage whose text changed and removes each one that no part
139
145
  // has, in one MERGE, and gives the parts and the passages.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eltjs/vectorizer",
3
- "version": "0.13.8",
3
+ "version": "0.13.10",
4
4
  "description": "One declaration that keeps the passage contract of @zukhruf/retrieval in step with an elt pipeline: passages with metadata, their vectors with the model identity, and a keyword index.",
5
5
  "license": "Apache-2.0",
6
6
  "repository": {
@@ -50,27 +50,47 @@
50
50
  "access": "public"
51
51
  },
52
52
  "dependencies": {
53
- "@eltjs/chunking": "^0.13.8",
54
- "@eltjs/elt": "^0.13.8",
55
- "@eltjs/elt-postgresql": "^0.13.8",
56
- "@eltjs/elt-sqlite": "^0.13.8",
57
- "@eltjs/elt-sqlserver": "^0.13.8",
58
- "@eltjs/embedding": "^0.13.8",
59
- "@zukhruf/async": "^0.8.105",
60
- "@zukhruf/sqlite-drift": "^0.8.105",
61
- "@zukhruf/sqlite-transaction": "^0.8.105",
62
- "ai": "^7.0.165",
53
+ "@eltjs/chunking": "^0.13.10",
54
+ "@eltjs/elt": "^0.13.10",
55
+ "@eltjs/embedding": "^0.13.10",
56
+ "@zukhruf/async": "^0.8.109",
57
+ "@zukhruf/sqlite-drift": "^0.8.109",
58
+ "@zukhruf/sqlite-transaction": "^0.8.109",
59
+ "ai": "^7.0.165"
60
+ },
61
+ "peerDependencies": {
62
+ "@eltjs/elt-postgresql": "^0.13.10",
63
+ "@eltjs/elt-sqlite": "^0.13.10",
64
+ "@eltjs/elt-sqlserver": "^0.13.10",
63
65
  "postgres": "^3.4.9"
64
66
  },
67
+ "peerDependenciesMeta": {
68
+ "@eltjs/elt-postgresql": {
69
+ "optional": true
70
+ },
71
+ "@eltjs/elt-sqlite": {
72
+ "optional": true
73
+ },
74
+ "@eltjs/elt-sqlserver": {
75
+ "optional": true
76
+ },
77
+ "postgres": {
78
+ "optional": true
79
+ }
80
+ },
65
81
  "devDependencies": {
66
82
  "@ai-sdk/provider": "^4.0.37",
83
+ "@eltjs/elt-postgresql": "^0.13.10",
84
+ "@eltjs/elt-sqlite": "^0.13.10",
85
+ "@eltjs/elt-sqlserver": "^0.13.10",
67
86
  "@types/mssql": "^12.3.0",
68
- "@zukhruf/fs": "^0.8.105",
69
- "@zukhruf/retrieval": "^0.8.105",
70
- "@zukhruf/sqlite-open": "^0.8.105",
71
- "@zukhruf/testing": "^0.8.105",
72
- "@zukhruf/vectors": "^0.8.105",
87
+ "@zukhruf/fs": "^0.8.109",
88
+ "@zukhruf/retrieval": "^0.8.109",
89
+ "@zukhruf/sqlite-open": "^0.8.109",
90
+ "@zukhruf/testing": "^0.8.109",
91
+ "@zukhruf/vectors": "^0.8.109",
73
92
  "gpt-tokenizer": "^4.1.2",
74
- "mssql": "^12.7.4"
93
+ "mssql": "^12.7.4",
94
+ "postgres": "^3.4.9"
75
95
  }
76
96
  }