@atscript/db-mongo 0.1.193 → 0.1.194
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 +3 -4
- package/dist/index.mjs +3 -4
- package/dist/plugin.cjs +3 -21
- package/dist/plugin.mjs +4 -22
- package/package.json +7 -7
package/dist/index.cjs
CHANGED
|
@@ -2760,10 +2760,9 @@ var MongoAdapter = class MongoAdapter extends _atscript_db.BaseDbAdapter {
|
|
|
2760
2760
|
const fieldType = _fieldType;
|
|
2761
2761
|
const tags = fieldType.type.tags;
|
|
2762
2762
|
if (tags?.has("objectId") && tags?.has("mongo")) return id instanceof mongodb.ObjectId ? id : new mongodb.ObjectId(id);
|
|
2763
|
-
|
|
2764
|
-
if (
|
|
2765
|
-
|
|
2766
|
-
}
|
|
2763
|
+
const designType = (0, _atscript_db.resolveDesignType)(fieldType);
|
|
2764
|
+
if (designType === "boolean") return id;
|
|
2765
|
+
if (designType === "number") return Number(id);
|
|
2767
2766
|
return String(id);
|
|
2768
2767
|
}
|
|
2769
2768
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -2759,10 +2759,9 @@ var MongoAdapter = class MongoAdapter extends BaseDbAdapter {
|
|
|
2759
2759
|
const fieldType = _fieldType;
|
|
2760
2760
|
const tags = fieldType.type.tags;
|
|
2761
2761
|
if (tags?.has("objectId") && tags?.has("mongo")) return id instanceof ObjectId ? id : new ObjectId(id);
|
|
2762
|
-
|
|
2763
|
-
if (
|
|
2764
|
-
|
|
2765
|
-
}
|
|
2762
|
+
const designType = resolveDesignType(fieldType);
|
|
2763
|
+
if (designType === "boolean") return id;
|
|
2764
|
+
if (designType === "number") return Number(id);
|
|
2766
2765
|
return String(id);
|
|
2767
2766
|
}
|
|
2768
2767
|
/**
|
package/dist/plugin.cjs
CHANGED
|
@@ -108,24 +108,6 @@ function nonStringValue(node, doc, depth = 0) {
|
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
110
|
/**
|
|
111
|
-
* The prop an annotation on `field` describes: the prop itself, or — for an
|
|
112
|
-
* `annotate` block entry — the prop the entry names (`undefined` when it names
|
|
113
|
-
* several, through a union).
|
|
114
|
-
*/
|
|
115
|
-
function describedProp(field, doc) {
|
|
116
|
-
if (!(0, _atscript_core.isRef)(field)) return {
|
|
117
|
-
prop: field,
|
|
118
|
-
doc
|
|
119
|
-
};
|
|
120
|
-
const at = field.token("identifier")?.range.start;
|
|
121
|
-
const block = at && doc.annotateBlockAt(at.line, at.character);
|
|
122
|
-
const found = block && doc.unwindType(block.targetName, [field.id, ...field.chain.map((c) => c.text)]);
|
|
123
|
-
return found?.node ? {
|
|
124
|
-
prop: found.node,
|
|
125
|
-
doc: found.doc
|
|
126
|
-
} : void 0;
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
111
|
* `validate` of a field annotation that maps the field as an Atlas Search
|
|
130
112
|
* `string`: the ciphertext refusal, then the rule that the field's declared
|
|
131
113
|
* type holds strings only.
|
|
@@ -139,8 +121,8 @@ function stringMappingValidate(annotation) {
|
|
|
139
121
|
const target = doc.annotatedDefinition(field);
|
|
140
122
|
const held = target && nonStringValue(target.def, target.doc);
|
|
141
123
|
if (held) {
|
|
142
|
-
const described =
|
|
143
|
-
const verdict = described && (0, _atscript_db_shared.searchFieldVerdict)(described
|
|
124
|
+
const described = (0, _atscript_db_shared.annotationTarget)(token, doc);
|
|
125
|
+
const verdict = described && (0, _atscript_db_shared.searchFieldVerdict)(described, doc);
|
|
144
126
|
const instead = verdict && "kind" in verdict && verdict.kind === "integer" ? "to match it by exact number, list it in @db.index.fulltext; for text search, annotate a string field" : "annotate a string field instead";
|
|
145
127
|
const name = (0, _atscript_core.isRef)(field) ? [field.id, ...field.chain.map((c) => c.text)].join(".") : field.id;
|
|
146
128
|
messages.push({
|
|
@@ -233,7 +215,7 @@ const annotations = {
|
|
|
233
215
|
passedWhenReferred: false,
|
|
234
216
|
multiple: false,
|
|
235
217
|
validate(token, _args, doc) {
|
|
236
|
-
const encrypted = (0, _atscript_db_shared.findStoredField)(token
|
|
218
|
+
const encrypted = (0, _atscript_db_shared.findStoredField)((0, _atscript_db_shared.annotationTarget)(token, doc), doc, (prop, path) => prop.countAnnotations("db.encrypted") > 0 ? path : void 0);
|
|
237
219
|
if (!encrypted) return [];
|
|
238
220
|
return [{
|
|
239
221
|
message: require_search_messages.dynamicSearchEncryptedMessage(encrypted),
|
package/dist/plugin.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { t as dynamicSearchEncryptedMessage } from "./search-messages-mQSpJ4GD.mjs";
|
|
2
2
|
import { AnnotationSpec, annotationExample, isArray, isGroup, isInterface, isPrimitive, isRef, isStructure } from "@atscript/core";
|
|
3
|
-
import { encryptedSearchProblem, findStoredField, primitiveBaseType, searchFieldVerdict } from "@atscript/db/shared";
|
|
3
|
+
import { annotationTarget, encryptedSearchProblem, findStoredField, primitiveBaseType, searchFieldVerdict } from "@atscript/db/shared";
|
|
4
4
|
//#region src/plugin/annotations.ts
|
|
5
5
|
/**
|
|
6
6
|
* Atlas Search built-in analyzers, offered by completion. Not a closed list:
|
|
@@ -104,24 +104,6 @@ function nonStringValue(node, doc, depth = 0) {
|
|
|
104
104
|
}
|
|
105
105
|
}
|
|
106
106
|
/**
|
|
107
|
-
* The prop an annotation on `field` describes: the prop itself, or — for an
|
|
108
|
-
* `annotate` block entry — the prop the entry names (`undefined` when it names
|
|
109
|
-
* several, through a union).
|
|
110
|
-
*/
|
|
111
|
-
function describedProp(field, doc) {
|
|
112
|
-
if (!isRef(field)) return {
|
|
113
|
-
prop: field,
|
|
114
|
-
doc
|
|
115
|
-
};
|
|
116
|
-
const at = field.token("identifier")?.range.start;
|
|
117
|
-
const block = at && doc.annotateBlockAt(at.line, at.character);
|
|
118
|
-
const found = block && doc.unwindType(block.targetName, [field.id, ...field.chain.map((c) => c.text)]);
|
|
119
|
-
return found?.node ? {
|
|
120
|
-
prop: found.node,
|
|
121
|
-
doc: found.doc
|
|
122
|
-
} : void 0;
|
|
123
|
-
}
|
|
124
|
-
/**
|
|
125
107
|
* `validate` of a field annotation that maps the field as an Atlas Search
|
|
126
108
|
* `string`: the ciphertext refusal, then the rule that the field's declared
|
|
127
109
|
* type holds strings only.
|
|
@@ -135,8 +117,8 @@ function stringMappingValidate(annotation) {
|
|
|
135
117
|
const target = doc.annotatedDefinition(field);
|
|
136
118
|
const held = target && nonStringValue(target.def, target.doc);
|
|
137
119
|
if (held) {
|
|
138
|
-
const described =
|
|
139
|
-
const verdict = described && searchFieldVerdict(described
|
|
120
|
+
const described = annotationTarget(token, doc);
|
|
121
|
+
const verdict = described && searchFieldVerdict(described, doc);
|
|
140
122
|
const instead = verdict && "kind" in verdict && verdict.kind === "integer" ? "to match it by exact number, list it in @db.index.fulltext; for text search, annotate a string field" : "annotate a string field instead";
|
|
141
123
|
const name = isRef(field) ? [field.id, ...field.chain.map((c) => c.text)].join(".") : field.id;
|
|
142
124
|
messages.push({
|
|
@@ -229,7 +211,7 @@ const annotations = {
|
|
|
229
211
|
passedWhenReferred: false,
|
|
230
212
|
multiple: false,
|
|
231
213
|
validate(token, _args, doc) {
|
|
232
|
-
const encrypted = findStoredField(token
|
|
214
|
+
const encrypted = findStoredField(annotationTarget(token, doc), doc, (prop, path) => prop.countAnnotations("db.encrypted") > 0 ? path : void 0);
|
|
233
215
|
if (!encrypted) return [];
|
|
234
216
|
return [{
|
|
235
217
|
message: dynamicSearchEncryptedMessage(encrypted),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atscript/db-mongo",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.194",
|
|
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.
|
|
50
|
-
"@atscript/typescript": "^0.2.
|
|
49
|
+
"@atscript/core": "^0.2.21",
|
|
50
|
+
"@atscript/typescript": "^0.2.21",
|
|
51
51
|
"@uniqu/core": "^0.2.2",
|
|
52
52
|
"mongodb": "^6.17.0",
|
|
53
53
|
"mongodb-memory-server-core": "^10.0.0",
|
|
54
|
-
"unplugin-atscript": "^0.2.
|
|
54
|
+
"unplugin-atscript": "^0.2.21"
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
|
-
"@atscript/core": "^0.2.
|
|
58
|
-
"@atscript/typescript": "^0.2.
|
|
57
|
+
"@atscript/core": "^0.2.21",
|
|
58
|
+
"@atscript/typescript": "^0.2.21",
|
|
59
59
|
"@uniqu/core": "^0.2.2",
|
|
60
60
|
"mongodb": "^6.17.0",
|
|
61
|
-
"@atscript/db": "^0.1.
|
|
61
|
+
"@atscript/db": "^0.1.194"
|
|
62
62
|
},
|
|
63
63
|
"scripts": {
|
|
64
64
|
"build": "vp pack",
|