@atscript/db-mongo 0.1.169 → 0.1.171

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/index.cjs CHANGED
@@ -1870,7 +1870,7 @@ function pathCrossesArray(host, logicalPath) {
1870
1870
  /** Resolves a field's default value for bulk $set during column sync. */
1871
1871
  function resolveSyncDefault(field) {
1872
1872
  if (!field.defaultValue) return;
1873
- if (field.defaultValue.kind === "value") return field.designType === "string" ? field.defaultValue.value : JSON.parse(field.defaultValue.value);
1873
+ if (field.defaultValue.kind === "value") return (0, _atscript_db.parseDefaultLiteral)(field.designType, field.defaultValue.value);
1874
1874
  }
1875
1875
  /**
1876
1876
  * Whether an index's fields include one of `paths` or a path under one —
@@ -2020,10 +2020,12 @@ async function syncIndexesImpl(host, opts, dryRun = false) {
2020
2020
  action: replaced.has(key) ? "rebuild" : "add"
2021
2021
  }, label, () => host.collection.createIndex(value.fields, indexOptions));
2022
2022
  }
2023
- const search = (0, _atscript_db.createChangeRecorder)(dryRun);
2023
+ let existingSearchIndexes;
2024
2024
  try {
2025
+ existingSearchIndexes = await host.collection.listSearchIndexes().toArray();
2026
+ } catch {}
2027
+ if (existingSearchIndexes) {
2025
2028
  const toUpdate = /* @__PURE__ */ new Set();
2026
- const existingSearchIndexes = await host.collection.listSearchIndexes().toArray();
2027
2029
  for (const remote of existingSearchIndexes) {
2028
2030
  if (!remote.name.startsWith("atscript__")) continue;
2029
2031
  if (indexesToCreate.has(remote.name)) {
@@ -2043,7 +2045,7 @@ async function syncIndexesImpl(host, opts, dryRun = false) {
2043
2045
  break;
2044
2046
  default:
2045
2047
  }
2046
- } else if (remote.status !== "DELETING") await search.apply({
2048
+ } else if (remote.status !== "DELETING") await apply({
2047
2049
  name: remote.name,
2048
2050
  action: "drop"
2049
2051
  }, remote.name, () => {
@@ -2056,7 +2058,7 @@ async function syncIndexesImpl(host, opts, dryRun = false) {
2056
2058
  case "search_text":
2057
2059
  case "vector": {
2058
2060
  const update = toUpdate.has(key);
2059
- await search.apply({
2061
+ await apply({
2060
2062
  name: key,
2061
2063
  action: update ? "rebuild" : "add"
2062
2064
  }, key, () => {
@@ -2075,9 +2077,9 @@ async function syncIndexesImpl(host, opts, dryRun = false) {
2075
2077
  }
2076
2078
  default:
2077
2079
  }
2078
- } catch {}
2080
+ }
2079
2081
  throwIfAny();
2080
- return [...changes, ...search.changes];
2082
+ return changes;
2081
2083
  }
2082
2084
  /**
2083
2085
  * The collation a plain / unique index is built with (since 0.1.151): the
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import { a as buildMongoQuery, c as planStages, f as sortStages, h as queryNodeToExpr, i as buildMongoFilter, l as correlate, m as orNull, n as distinctCountExpr, o as collationOfAdapter, p as exprToMongo, r as REL_FILTER_TEMP_PREFIX, s as mongoFilterStages, t as buildAccumulator, u as hasNullsPlacement } from "./mongo-accumulator-D4drEz0-.mjs";
2
2
  import { t as dynamicSearchEncryptedMessage } from "./search-messages-mQSpJ4GD.mjs";
3
- import { ALL_AGGREGATE_FNS, ALL_BUCKET_UNITS, ALL_VIEW_CAPABILITIES, BaseDbAdapter, DbError, DbSpace, andFilters, bucketTimeZoneUnavailable, computeInsights, constraintViolation, containsRelationFilter, createChangeRecorder, createFailureCollector, defaultFulltextIndex, geoIndexNotFoundMessage, getDbFieldOp, getKeyProps, getPath, isAtscriptDbView, isFieldRef, isPlainObject, isViewType, queryReadColumns, relationStaticFilter, resolveDesignType, searchIndexNotFoundMessage, searchTermInteger, tableNameOf, translateQueryTree, uniqueKeyTuple, vectorIndexNotFoundMessage } from "@atscript/db";
3
+ import { ALL_AGGREGATE_FNS, ALL_BUCKET_UNITS, ALL_VIEW_CAPABILITIES, BaseDbAdapter, DbError, DbSpace, andFilters, bucketTimeZoneUnavailable, computeInsights, constraintViolation, containsRelationFilter, createChangeRecorder, createFailureCollector, defaultFulltextIndex, geoIndexNotFoundMessage, getDbFieldOp, getKeyProps, getPath, isAtscriptDbView, isFieldRef, isPlainObject, isViewType, parseDefaultLiteral, queryReadColumns, relationStaticFilter, resolveDesignType, searchIndexNotFoundMessage, searchTermInteger, tableNameOf, translateQueryTree, uniqueKeyTuple, vectorIndexNotFoundMessage } from "@atscript/db";
4
4
  import { MongoBulkWriteError, MongoClient, MongoServerError, ObjectId } from "mongodb";
5
5
  import { resolveAggregateSearch } from "@atscript/db/agg";
6
6
  //#region src/lib/path-utils.ts
@@ -1869,7 +1869,7 @@ function pathCrossesArray(host, logicalPath) {
1869
1869
  /** Resolves a field's default value for bulk $set during column sync. */
1870
1870
  function resolveSyncDefault(field) {
1871
1871
  if (!field.defaultValue) return;
1872
- if (field.defaultValue.kind === "value") return field.designType === "string" ? field.defaultValue.value : JSON.parse(field.defaultValue.value);
1872
+ if (field.defaultValue.kind === "value") return parseDefaultLiteral(field.designType, field.defaultValue.value);
1873
1873
  }
1874
1874
  /**
1875
1875
  * Whether an index's fields include one of `paths` or a path under one —
@@ -2019,10 +2019,12 @@ async function syncIndexesImpl(host, opts, dryRun = false) {
2019
2019
  action: replaced.has(key) ? "rebuild" : "add"
2020
2020
  }, label, () => host.collection.createIndex(value.fields, indexOptions));
2021
2021
  }
2022
- const search = createChangeRecorder(dryRun);
2022
+ let existingSearchIndexes;
2023
2023
  try {
2024
+ existingSearchIndexes = await host.collection.listSearchIndexes().toArray();
2025
+ } catch {}
2026
+ if (existingSearchIndexes) {
2024
2027
  const toUpdate = /* @__PURE__ */ new Set();
2025
- const existingSearchIndexes = await host.collection.listSearchIndexes().toArray();
2026
2028
  for (const remote of existingSearchIndexes) {
2027
2029
  if (!remote.name.startsWith("atscript__")) continue;
2028
2030
  if (indexesToCreate.has(remote.name)) {
@@ -2042,7 +2044,7 @@ async function syncIndexesImpl(host, opts, dryRun = false) {
2042
2044
  break;
2043
2045
  default:
2044
2046
  }
2045
- } else if (remote.status !== "DELETING") await search.apply({
2047
+ } else if (remote.status !== "DELETING") await apply({
2046
2048
  name: remote.name,
2047
2049
  action: "drop"
2048
2050
  }, remote.name, () => {
@@ -2055,7 +2057,7 @@ async function syncIndexesImpl(host, opts, dryRun = false) {
2055
2057
  case "search_text":
2056
2058
  case "vector": {
2057
2059
  const update = toUpdate.has(key);
2058
- await search.apply({
2060
+ await apply({
2059
2061
  name: key,
2060
2062
  action: update ? "rebuild" : "add"
2061
2063
  }, key, () => {
@@ -2074,9 +2076,9 @@ async function syncIndexesImpl(host, opts, dryRun = false) {
2074
2076
  }
2075
2077
  default:
2076
2078
  }
2077
- } catch {}
2079
+ }
2078
2080
  throwIfAny();
2079
- return [...changes, ...search.changes];
2081
+ return changes;
2080
2082
  }
2081
2083
  /**
2082
2084
  * The collation a plain / unique index is built with (since 0.1.151): the
package/dist/plugin.cjs CHANGED
@@ -6,22 +6,62 @@ const require_search_messages = require("./search-messages-BqLxxrb8.cjs");
6
6
  let _atscript_core = require("@atscript/core");
7
7
  let _atscript_db_shared = require("@atscript/db/shared");
8
8
  //#region src/plugin/annotations.ts
9
+ /**
10
+ * Atlas Search built-in analyzers, offered by completion. Not a closed list:
11
+ * any name is accepted, and one Atlas does not know fails the schema sync.
12
+ */
9
13
  const analyzers = [
10
14
  "lucene.standard",
11
15
  "lucene.simple",
12
16
  "lucene.whitespace",
13
- "lucene.english",
14
- "lucene.french",
15
- "lucene.german",
16
- "lucene.italian",
17
- "lucene.portuguese",
18
- "lucene.spanish",
19
- "lucene.chinese",
20
- "lucene.hindi",
21
- "lucene.bengali",
22
- "lucene.russian",
23
- "lucene.arabic"
17
+ "lucene.keyword",
18
+ ...[
19
+ "arabic",
20
+ "armenian",
21
+ "basque",
22
+ "bengali",
23
+ "brazilian",
24
+ "bulgarian",
25
+ "catalan",
26
+ "chinese",
27
+ "cjk",
28
+ "czech",
29
+ "danish",
30
+ "dutch",
31
+ "english",
32
+ "finnish",
33
+ "french",
34
+ "galician",
35
+ "german",
36
+ "greek",
37
+ "hindi",
38
+ "hungarian",
39
+ "indonesian",
40
+ "irish",
41
+ "italian",
42
+ "japanese",
43
+ "korean",
44
+ "kuromoji",
45
+ "latvian",
46
+ "lithuanian",
47
+ "morfologik",
48
+ "nori",
49
+ "norwegian",
50
+ "persian",
51
+ "polish",
52
+ "portuguese",
53
+ "romanian",
54
+ "russian",
55
+ "smartcn",
56
+ "sorani",
57
+ "spanish",
58
+ "swedish",
59
+ "thai",
60
+ "turkish",
61
+ "ukrainian"
62
+ ].map((language) => `lucene.${language}`)
24
63
  ];
64
+ const analyzerScope = () => analyzers.map((value) => ({ value }));
25
65
  const tokenizations = [
26
66
  "edgeGram",
27
67
  "rightEdgeGram",
@@ -127,8 +167,8 @@ const annotations = {
127
167
  optional: true,
128
168
  name: "analyzer",
129
169
  type: "string",
130
- description: "The **text analyzer** for tokenization. Defaults to `\"lucene.standard\"`.\n\n**Available options:** `\"lucene.standard\"`, `\"lucene.english\"`, `\"lucene.spanish\"`, etc.",
131
- values: analyzers
170
+ description: "The **text analyzer** for tokenization. Defaults to `\"lucene.standard\"`.\n\n**Available options:** `\"lucene.standard\"`, `\"lucene.english\"`, `\"lucene.spanish\"`, etc.\n\nAny Atlas Search analyzer name is accepted (completion lists the built-in ones); one Atlas does not know fails the schema sync.",
171
+ valueScope: analyzerScope
132
172
  }, {
133
173
  optional: true,
134
174
  name: "fuzzy",
@@ -146,8 +186,8 @@ const annotations = {
146
186
  optional: true,
147
187
  name: "analyzer",
148
188
  type: "string",
149
- description: "The text analyzer for tokenization. Defaults to `\"lucene.standard\"`.\n\n**Available options:** `\"lucene.standard\"`, `\"lucene.english\"`, `\"lucene.spanish\"`, `\"lucene.german\"`, etc.",
150
- values: analyzers
189
+ description: "The text analyzer for tokenization. Defaults to `\"lucene.standard\"`.\n\n**Available options:** `\"lucene.standard\"`, `\"lucene.english\"`, `\"lucene.spanish\"`, `\"lucene.german\"`, etc.\n\nAny Atlas Search analyzer name is accepted (completion lists the built-in ones); one Atlas does not know fails the schema sync.",
190
+ valueScope: analyzerScope
151
191
  },
152
192
  {
153
193
  optional: true,
@@ -180,8 +220,8 @@ const annotations = {
180
220
  optional: true,
181
221
  name: "analyzer",
182
222
  type: "string",
183
- description: "The text analyzer for tokenization. Defaults to `\"lucene.standard\"`.\n\n**Available options:** `\"lucene.standard\"`, `\"lucene.english\"`, `\"lucene.spanish\"`, `\"lucene.german\"`, etc.",
184
- values: analyzers
223
+ description: "The text analyzer for tokenization. Defaults to `\"lucene.standard\"`.\n\n**Available options:** `\"lucene.standard\"`, `\"lucene.english\"`, `\"lucene.spanish\"`, `\"lucene.german\"`, etc.\n\nAny Atlas Search analyzer name is accepted (completion lists the built-in ones); one Atlas does not know fails the schema sync.",
224
+ valueScope: analyzerScope
185
225
  }, {
186
226
  optional: true,
187
227
  name: "indexName",
@@ -231,8 +271,8 @@ const annotations = {
231
271
  optional: true,
232
272
  name: "analyzer",
233
273
  type: "string",
234
- description: "The text analyzer for the companion `string` mapping. Defaults to `\"lucene.standard\"`.",
235
- values: analyzers
274
+ description: "The text analyzer for the companion `string` mapping. Defaults to `\"lucene.standard\"`.\n\nAny Atlas Search analyzer name is accepted (completion lists the built-in ones); one Atlas does not know fails the schema sync.",
275
+ valueScope: analyzerScope
236
276
  }
237
277
  ]
238
278
  })
package/dist/plugin.mjs CHANGED
@@ -2,22 +2,62 @@ import { t as dynamicSearchEncryptedMessage } from "./search-messages-mQSpJ4GD.m
2
2
  import { AnnotationSpec, annotationExample, isInterface, isPrimitive, isRef, isStructure } from "@atscript/core";
3
3
  import { findStoredField, refuseCiphertext } from "@atscript/db/shared";
4
4
  //#region src/plugin/annotations.ts
5
+ /**
6
+ * Atlas Search built-in analyzers, offered by completion. Not a closed list:
7
+ * any name is accepted, and one Atlas does not know fails the schema sync.
8
+ */
5
9
  const analyzers = [
6
10
  "lucene.standard",
7
11
  "lucene.simple",
8
12
  "lucene.whitespace",
9
- "lucene.english",
10
- "lucene.french",
11
- "lucene.german",
12
- "lucene.italian",
13
- "lucene.portuguese",
14
- "lucene.spanish",
15
- "lucene.chinese",
16
- "lucene.hindi",
17
- "lucene.bengali",
18
- "lucene.russian",
19
- "lucene.arabic"
13
+ "lucene.keyword",
14
+ ...[
15
+ "arabic",
16
+ "armenian",
17
+ "basque",
18
+ "bengali",
19
+ "brazilian",
20
+ "bulgarian",
21
+ "catalan",
22
+ "chinese",
23
+ "cjk",
24
+ "czech",
25
+ "danish",
26
+ "dutch",
27
+ "english",
28
+ "finnish",
29
+ "french",
30
+ "galician",
31
+ "german",
32
+ "greek",
33
+ "hindi",
34
+ "hungarian",
35
+ "indonesian",
36
+ "irish",
37
+ "italian",
38
+ "japanese",
39
+ "korean",
40
+ "kuromoji",
41
+ "latvian",
42
+ "lithuanian",
43
+ "morfologik",
44
+ "nori",
45
+ "norwegian",
46
+ "persian",
47
+ "polish",
48
+ "portuguese",
49
+ "romanian",
50
+ "russian",
51
+ "smartcn",
52
+ "sorani",
53
+ "spanish",
54
+ "swedish",
55
+ "thai",
56
+ "turkish",
57
+ "ukrainian"
58
+ ].map((language) => `lucene.${language}`)
20
59
  ];
60
+ const analyzerScope = () => analyzers.map((value) => ({ value }));
21
61
  const tokenizations = [
22
62
  "edgeGram",
23
63
  "rightEdgeGram",
@@ -123,8 +163,8 @@ const annotations = {
123
163
  optional: true,
124
164
  name: "analyzer",
125
165
  type: "string",
126
- description: "The **text analyzer** for tokenization. Defaults to `\"lucene.standard\"`.\n\n**Available options:** `\"lucene.standard\"`, `\"lucene.english\"`, `\"lucene.spanish\"`, etc.",
127
- values: analyzers
166
+ description: "The **text analyzer** for tokenization. Defaults to `\"lucene.standard\"`.\n\n**Available options:** `\"lucene.standard\"`, `\"lucene.english\"`, `\"lucene.spanish\"`, etc.\n\nAny Atlas Search analyzer name is accepted (completion lists the built-in ones); one Atlas does not know fails the schema sync.",
167
+ valueScope: analyzerScope
128
168
  }, {
129
169
  optional: true,
130
170
  name: "fuzzy",
@@ -142,8 +182,8 @@ const annotations = {
142
182
  optional: true,
143
183
  name: "analyzer",
144
184
  type: "string",
145
- description: "The text analyzer for tokenization. Defaults to `\"lucene.standard\"`.\n\n**Available options:** `\"lucene.standard\"`, `\"lucene.english\"`, `\"lucene.spanish\"`, `\"lucene.german\"`, etc.",
146
- values: analyzers
185
+ description: "The text analyzer for tokenization. Defaults to `\"lucene.standard\"`.\n\n**Available options:** `\"lucene.standard\"`, `\"lucene.english\"`, `\"lucene.spanish\"`, `\"lucene.german\"`, etc.\n\nAny Atlas Search analyzer name is accepted (completion lists the built-in ones); one Atlas does not know fails the schema sync.",
186
+ valueScope: analyzerScope
147
187
  },
148
188
  {
149
189
  optional: true,
@@ -176,8 +216,8 @@ const annotations = {
176
216
  optional: true,
177
217
  name: "analyzer",
178
218
  type: "string",
179
- description: "The text analyzer for tokenization. Defaults to `\"lucene.standard\"`.\n\n**Available options:** `\"lucene.standard\"`, `\"lucene.english\"`, `\"lucene.spanish\"`, `\"lucene.german\"`, etc.",
180
- values: analyzers
219
+ description: "The text analyzer for tokenization. Defaults to `\"lucene.standard\"`.\n\n**Available options:** `\"lucene.standard\"`, `\"lucene.english\"`, `\"lucene.spanish\"`, `\"lucene.german\"`, etc.\n\nAny Atlas Search analyzer name is accepted (completion lists the built-in ones); one Atlas does not know fails the schema sync.",
220
+ valueScope: analyzerScope
181
221
  }, {
182
222
  optional: true,
183
223
  name: "indexName",
@@ -227,8 +267,8 @@ const annotations = {
227
267
  optional: true,
228
268
  name: "analyzer",
229
269
  type: "string",
230
- description: "The text analyzer for the companion `string` mapping. Defaults to `\"lucene.standard\"`.",
231
- values: analyzers
270
+ description: "The text analyzer for the companion `string` mapping. Defaults to `\"lucene.standard\"`.\n\nAny Atlas Search analyzer name is accepted (completion lists the built-in ones); one Atlas does not know fails the schema sync.",
271
+ valueScope: analyzerScope
232
272
  }
233
273
  ]
234
274
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atscript/db-mongo",
3
- "version": "0.1.169",
3
+ "version": "0.1.171",
4
4
  "description": "Mongodb plugin for atscript.",
5
5
  "keywords": [
6
6
  "atscript",
@@ -46,19 +46,19 @@
46
46
  "access": "public"
47
47
  },
48
48
  "devDependencies": {
49
- "@atscript/core": "^0.2.4",
50
- "@atscript/typescript": "^0.2.4",
51
- "@uniqu/core": "^0.2.0",
49
+ "@atscript/core": "^0.2.8",
50
+ "@atscript/typescript": "^0.2.8",
51
+ "@uniqu/core": "^0.2.1",
52
52
  "mongodb": "^6.17.0",
53
53
  "mongodb-memory-server-core": "^10.0.0",
54
- "unplugin-atscript": "^0.2.4"
54
+ "unplugin-atscript": "^0.2.8"
55
55
  },
56
56
  "peerDependencies": {
57
- "@atscript/core": "^0.2.4",
58
- "@atscript/typescript": "^0.2.4",
59
- "@uniqu/core": "^0.2.0",
57
+ "@atscript/core": "^0.2.8",
58
+ "@atscript/typescript": "^0.2.8",
59
+ "@uniqu/core": "^0.2.1",
60
60
  "mongodb": "^6.17.0",
61
- "@atscript/db": "^0.1.169"
61
+ "@atscript/db": "^0.1.171"
62
62
  },
63
63
  "scripts": {
64
64
  "build": "vp pack",