@remit/backend 0.0.94 → 0.0.95

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remit/backend",
3
- "version": "0.0.94",
3
+ "version": "0.0.95",
4
4
  "description": "Remit Mail Inspector API backend",
5
5
  "license": "MIT",
6
6
  "author": "",
@@ -14,6 +14,10 @@ import type { AccountConfigItem, MailboxItem } from "@remit/data-ports";
14
14
  import { ConfigNotEmptyError, NotFoundError } from "@remit/data-ports/errors";
15
15
  import type { CanonicalMailboxRoleValue } from "@remit/data-ports/folder-role";
16
16
  import { logger } from "@remit/logger-lambda";
17
+ import {
18
+ EMBEDDING_PROVIDER_OFF,
19
+ readEmbeddingProviderFromEnv,
20
+ } from "@remit/search-service/from-env";
17
21
  import type { APIGatewayProxyEvent } from "aws-lambda";
18
22
  import { env } from "expect-env";
19
23
  import type { Context } from "openapi-backend";
@@ -138,9 +142,22 @@ const emptyConfigResponse = (
138
142
  updatedAt: now,
139
143
  },
140
144
  accounts: [],
145
+ semanticSearchEnabled: semanticSearchEnabled(),
141
146
  };
142
147
  };
143
148
 
149
+ /**
150
+ * Whether this instance embeds anything, read from the same
151
+ * `SEARCH_EMBEDDING_PROVIDER` the search-index worker and the `remit` wrapper
152
+ * read. It rides GET /config because the semantic surfaces need it before they
153
+ * have a query to send: an off instance stores no vectors, so the Organize
154
+ * widen and semantic filters have nothing to read, and a client that learns
155
+ * that only from an empty result cannot tell it from a mailbox with nothing
156
+ * similar in it (#1068).
157
+ */
158
+ const semanticSearchEnabled = (): boolean =>
159
+ readEmbeddingProviderFromEnv() !== EMBEDDING_PROVIDER_OFF;
160
+
144
161
  export const ConfigOperations: Record<
145
162
  ConfigOperationIds,
146
163
  OperationHandler<ConfigOperationIds>
@@ -220,6 +237,7 @@ export const ConfigOperations: Record<
220
237
 
221
238
  return {
222
239
  accountConfig: toAccountConfigResponse(accountConfig),
240
+ semanticSearchEnabled: semanticSearchEnabled(),
223
241
  ...(pendingImport ? { pendingImport } : {}),
224
242
  accounts: activeAccounts.map((acc) =>
225
243
  toAccountResponse(