|
@@ -197,6 +197,12 @@
|
|
|
// dropping either set silently would widen the result.
|
|
// dropping either set silently would widen the result.
|
|
|
search: function (options) {
|
|
search: function (options) {
|
|
|
need(options !== null && typeof options === 'object', '.search() takes an options object');
|
|
need(options !== null && typeof options === 'object', '.search() takes an options object');
|
|
|
|
|
+ // Refused here, not host-side: the payload below is built from an
|
|
|
|
|
+ // explicit key list, so a misspelled option would be dropped before
|
|
|
|
|
+ // the host ever saw it. Measured over HTTP, where the same hole gave
|
|
|
|
|
+ // `topK` the DEFAULT top_k and a singular `filter` the rows the caller
|
|
|
|
|
+ // meant to exclude - both with a success status.
|
|
|
|
|
+ onlyKnownKeys(options, kSearchKeys, '.search()');
|
|
|
const extra = options.filters === undefined || options.filters === null
|
|
const extra = options.filters === undefined || options.filters === null
|
|
|
? [] : options.filters;
|
|
? [] : options.filters;
|
|
|
need(Array.isArray(extra), '.search() filters must be an array of strings');
|
|
need(Array.isArray(extra), '.search() filters must be an array of strings');
|
|
@@ -217,6 +223,7 @@
|
|
|
},
|
|
},
|
|
|
store: function (options) {
|
|
store: function (options) {
|
|
|
need(options !== null && typeof options === 'object', '.store() takes an options object');
|
|
need(options !== null && typeof options === 'object', '.store() takes an options object');
|
|
|
|
|
+ onlyKnownKeys(options, kStoreKeys, '.store()');
|
|
|
// A stored vector is an inserted document, so it takes the same expiry
|
|
// A stored vector is an inserted document, so it takes the same expiry
|
|
|
// option an .insert() does - a cache of embeddings that cannot expire
|
|
// option an .insert() does - a cache of embeddings that cannot expire
|
|
|
// is a cache that grows forever.
|
|
// is a cache that grows forever.
|
|
@@ -393,7 +400,18 @@
|
|
|
const kMailReadKeys = ['host', 'port', 'user', 'userSecret', 'password', 'passwordSecret',
|
|
const kMailReadKeys = ['host', 'port', 'user', 'userSecret', 'password', 'passwordSecret',
|
|
|
'tls', 'startTls', 'timeoutMs', 'mailbox', 'criteria', 'limit'];
|
|
'tls', 'startTls', 'timeoutMs', 'mailbox', 'criteria', 'limit'];
|
|
|
|
|
|
|
|
- function mailOnlyKeys(o, allowed, what) {
|
|
|
|
|
|
|
+ // Refuse an option name this surface does not take. Named for the job
|
|
|
|
|
+ // rather than for mail, which needed it first: the vector calls need it too,
|
|
|
|
|
+ // and for a sharper reason - their payload is built from an explicit key
|
|
|
|
|
+ // list, so an unrecognised key is DISCARDED here before the host can see it.
|
|
|
|
|
+ // The host therefore cannot refuse what never arrives, which is exactly how
|
|
|
|
|
+ // embedTimeoutMs came to be honoured by the host and never sent by the
|
|
|
|
|
+ // prelude while a consumer believed a bound was in force.
|
|
|
|
|
+ const kSearchKeys = ['query_text', 'query_vector', 'top_k', 'min_score', 'filters',
|
|
|
|
|
+ 'embedTimeoutMs'];
|
|
|
|
|
+ const kStoreKeys = ['text', 'vector', 'metadata', 'id', 'ttl_seconds', 'embedTimeoutMs'];
|
|
|
|
|
+
|
|
|
|
|
+ function onlyKnownKeys(o, allowed, what) {
|
|
|
for (const key in o) {
|
|
for (const key in o) {
|
|
|
if (!Object.prototype.hasOwnProperty.call(o, key)) continue;
|
|
if (!Object.prototype.hasOwnProperty.call(o, key)) continue;
|
|
|
if (o[key] === undefined) continue;
|
|
if (o[key] === undefined) continue;
|
|
@@ -506,7 +524,7 @@
|
|
|
// stated rather than assumed.
|
|
// stated rather than assumed.
|
|
|
read: function (options) {
|
|
read: function (options) {
|
|
|
const o = opts(options, 'ctx.mail.read() options');
|
|
const o = opts(options, 'ctx.mail.read() options');
|
|
|
- mailOnlyKeys(o, kMailReadKeys, 'ctx.mail.read()');
|
|
|
|
|
|
|
+ onlyKnownKeys(o, kMailReadKeys, 'ctx.mail.read()');
|
|
|
const out = mailConnection(o, 'ctx.mail.read()');
|
|
const out = mailConnection(o, 'ctx.mail.read()');
|
|
|
if (o.mailbox !== undefined && o.mailbox !== null) {
|
|
if (o.mailbox !== undefined && o.mailbox !== null) {
|
|
|
need(typeof o.mailbox === 'string' && o.mailbox.length > 0,
|
|
need(typeof o.mailbox === 'string' && o.mailbox.length > 0,
|
|
@@ -534,7 +552,7 @@
|
|
|
// a flat namespace, never "unknown".
|
|
// a flat namespace, never "unknown".
|
|
|
mailboxes: function (options) {
|
|
mailboxes: function (options) {
|
|
|
const o = opts(options, 'ctx.mail.mailboxes() options');
|
|
const o = opts(options, 'ctx.mail.mailboxes() options');
|
|
|
- mailOnlyKeys(o, kMailReadKeys, 'ctx.mail.mailboxes()');
|
|
|
|
|
|
|
+ onlyKnownKeys(o, kMailReadKeys, 'ctx.mail.mailboxes()');
|
|
|
return __hostMail('mailboxes', mailConnection(o, 'ctx.mail.mailboxes()'));
|
|
return __hostMail('mailboxes', mailConnection(o, 'ctx.mail.mailboxes()'));
|
|
|
},
|
|
},
|
|
|
|
|
|
|
@@ -543,7 +561,7 @@
|
|
|
// carries no Bcc and which a sender may make say anything.
|
|
// carries no Bcc and which a sender may make say anything.
|
|
|
send: function (options) {
|
|
send: function (options) {
|
|
|
const o = opts(options, 'ctx.mail.send() options');
|
|
const o = opts(options, 'ctx.mail.send() options');
|
|
|
- mailOnlyKeys(o, kMailSendKeys, 'ctx.mail.send()');
|
|
|
|
|
|
|
+ onlyKnownKeys(o, kMailSendKeys, 'ctx.mail.send()');
|
|
|
const out = mailConnection(o, 'ctx.mail.send()');
|
|
const out = mailConnection(o, 'ctx.mail.send()');
|
|
|
|
|
|
|
|
need(typeof o.from === 'string' && o.from.length > 0,
|
|
need(typeof o.from === 'string' && o.from.length > 0,
|