@vertesia/client 1.5.0-dev.20260901.052906Z → 1.5.0-dev.20260910.051115Z

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.
Files changed (42) hide show
  1. package/lib/IamApi.d.ts +2 -2
  2. package/lib/IamApi.d.ts.map +1 -1
  3. package/lib/IamApi.js +2 -2
  4. package/lib/IamApi.js.map +1 -1
  5. package/lib/InteractionBase.d.ts +4 -2
  6. package/lib/InteractionBase.d.ts.map +1 -1
  7. package/lib/client.d.ts +0 -1
  8. package/lib/client.d.ts.map +1 -1
  9. package/lib/client.js +42 -3
  10. package/lib/client.js.map +1 -1
  11. package/lib/store/AgentsApi.d.ts +5 -0
  12. package/lib/store/AgentsApi.d.ts.map +1 -1
  13. package/lib/store/AgentsApi.js +11 -4
  14. package/lib/store/AgentsApi.js.map +1 -1
  15. package/lib/store/DataApi.d.ts +8 -2
  16. package/lib/store/DataApi.d.ts.map +1 -1
  17. package/lib/store/DataApi.js +8 -2
  18. package/lib/store/DataApi.js.map +1 -1
  19. package/lib/store/IndexingApi.d.ts +2 -18
  20. package/lib/store/IndexingApi.d.ts.map +1 -1
  21. package/lib/store/IndexingApi.js +0 -45
  22. package/lib/store/IndexingApi.js.map +1 -1
  23. package/lib/store/client.d.ts.map +1 -1
  24. package/lib/store/client.js +13 -0
  25. package/lib/store/client.js.map +1 -1
  26. package/lib/unknown-options.d.ts +23 -0
  27. package/lib/unknown-options.d.ts.map +1 -0
  28. package/lib/unknown-options.js +51 -0
  29. package/lib/unknown-options.js.map +1 -0
  30. package/lib/vertesia-client.js +2 -2
  31. package/lib/vertesia-client.js.map +1 -1
  32. package/package.json +5 -5
  33. package/src/IamApi.ts +3 -3
  34. package/src/client.test.ts +114 -1
  35. package/src/client.ts +47 -4
  36. package/src/store/AgentsApi.artifacts.test.ts +119 -0
  37. package/src/store/AgentsApi.ts +12 -4
  38. package/src/store/DataApi.test.ts +42 -0
  39. package/src/store/DataApi.ts +8 -2
  40. package/src/store/IndexingApi.ts +1 -70
  41. package/src/store/client.ts +14 -0
  42. package/src/unknown-options.ts +56 -0
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Client constructors take a plain options object, so an option name that does not exist is not a
3
+ * runtime error — it is silently dropped. TypeScript's excess-property check catches it for an
4
+ * object literal, but not for a spread, an `any`, or plain JavaScript, and the resulting client
5
+ * looks healthy right up to the first request. A credential passed under the wrong name produces a
6
+ * client with no `Authorization` header, so every call fails with
7
+ * `401 Unauthorized: Authorization token is required` and nothing points at the constructor.
8
+ *
9
+ * These helpers make that case say so, once per unknown option name.
10
+ */
11
+
12
+ /** Options that never existed, mapped to what the caller almost certainly meant. */
13
+ const OPTION_HINTS: Record<string, string> = {
14
+ token: 'pass the credential as `apikey`, or build the client with `VertesiaClient.fromAuthToken(token)`',
15
+ accessToken: 'pass the credential as `apikey`, or build the client with `VertesiaClient.fromAuthToken(token)`',
16
+ authToken: 'pass the credential as `apikey`, or build the client with `VertesiaClient.fromAuthToken(token)`',
17
+ apiKey: 'the option is spelled `apikey`, all lowercase',
18
+ api_key: 'the option is spelled `apikey`, all lowercase',
19
+ appVersion: 'pin the app version with the `withAppVersion(version)` method after construction',
20
+ apiVersion: 'pin the API version with the `withApiVersion(version)` method after construction',
21
+ projectId: 'the project is determined by the credential; this option was never read',
22
+ baseUrl: 'use `serverUrl` for studio and `storeUrl` for the store',
23
+ };
24
+
25
+ const warned = new Set<string>();
26
+
27
+ /**
28
+ * Warn once per unknown option name. Deliberately a warning and not a throw: passing a harmless
29
+ * extra key is common (spreading a wider config object) and has never failed, so throwing would
30
+ * break working callers to report a mistake they may not have made.
31
+ *
32
+ * @param clientName the constructor name, used to prefix the message
33
+ * @param opts the options object as given by the caller
34
+ * @param known the options the constructor actually reads
35
+ */
36
+ export function warnUnknownOptions(clientName: string, opts: object, known: Record<string, true>): void {
37
+ // `Object.hasOwn`, not `in`: `in` walks the prototype chain, so options named `toString`,
38
+ // `constructor` or `valueOf` would look like known options and go unreported.
39
+ const unknown = Object.keys(opts).filter((key) => !Object.hasOwn(known, key) && !warned.has(key));
40
+ if (unknown.length === 0) {
41
+ return;
42
+ }
43
+ for (const key of unknown) {
44
+ warned.add(key);
45
+ }
46
+ const details = unknown.map((key) => (Object.hasOwn(OPTION_HINTS, key) ? `${key} (${OPTION_HINTS[key]})` : key));
47
+ console.warn(
48
+ `[${clientName}] Ignoring unknown constructor option(s): ${details.join('; ')}. ` +
49
+ 'Unknown options have no effect.',
50
+ );
51
+ }
52
+
53
+ /** Test-only: forget which option names have already been reported. */
54
+ export function resetUnknownOptionWarnings(): void {
55
+ warned.clear();
56
+ }