@magicx-eng/ai-autocomplete-vanilla 0.38.3 → 0.40.0

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/README.md CHANGED
@@ -80,6 +80,7 @@ const ac = new AIAutocomplete(container, {
80
80
  maskCompletedText: false, // when true, omits completed params' text from API requests (PII masking)
81
81
  commitOnWordEnd: false, // true = a word still being typed never becomes a chip until a space, Enter, or Tab ends it (exact matches and server identified params). Picking an option is unchanged.
82
82
  additionalContext: { tier: "gold" }, // optional user context, to personalize suggestions and options
83
+ language: "es", // BCP 47 tag sent with every suggestion request and telemetry event. Default: navigator.language, else "en-US"
83
84
 
84
85
  // Appearance
85
86
  mode: "auto", // "light" | "dark" | "auto"
@@ -729,13 +730,14 @@ A discriminated union: `APIKeyConfig | AccessTokenConfig`.
729
730
  getAccessToken: async () => {
730
731
  const res = await fetch("/api/ac-token");
731
732
  const { access_token, expires_at } = await res.json();
732
- return { accessToken: access_token, expiresAt: expires_at };
733
+ // expires_at is Unix seconds; the SDK's expiresAt is Unix milliseconds.
734
+ return { accessToken: access_token, expiresAt: expires_at * 1000 };
733
735
  },
734
736
  endpoint: "https://api.ai-autocomplete.com/api/suggest", // optional, this is the default
735
737
  }
736
738
  ```
737
739
 
738
- The SDK handles token refresh transparently: if a request returns 401, it calls `getAccessToken` once, retries, and only surfaces an error if the retry also fails. Concurrent 401s share a single refresh call. Tokens are refreshed proactively 30 seconds before `expiresAt`.
740
+ The SDK handles token refresh transparently: if a request returns 401, it calls `getAccessToken` once, retries, and only surfaces an error if the retry also fails. Concurrent 401s share a single refresh call. Tokens are refreshed proactively 30 seconds before `expiresAt` (Unix milliseconds).
739
741
 
740
742
  ### `AutocompleteResult`
741
743
 
package/dist/index.d.mts CHANGED
@@ -138,6 +138,12 @@ interface AutocompleteResponse {
138
138
  request_at: string;
139
139
  /** The server's funnel-telemetry switch. Absent means off: send no funnel events. */
140
140
  funnel_telemetry?: boolean;
141
+ /**
142
+ * The server's phrase exact match switch. When true, a typed phrase that
143
+ * starts at the word the last request ended in can match an option
144
+ * exactly. Absent means off.
145
+ */
146
+ phrase_exact_match?: boolean;
141
147
  /** The request's `schema_version`, echoed back. */
142
148
  schema_version?: string;
143
149
  };
@@ -931,6 +937,11 @@ interface CoreOptions {
931
937
  * parameters and options to them.
932
938
  */
933
939
  additionalContext?: Record<string, unknown>;
940
+ /**
941
+ * BCP 47 language tag (e.g. `"es"`), sent with every suggestion request and telemetry event.
942
+ * Default: the browser language (`navigator.language`), else `"en-US"`.
943
+ */
944
+ language?: string;
934
945
  /**
935
946
  * Stable id for this visitor, kept by the host across page loads (e.g. a
936
947
  * first-party cookie). Rides on funnel telemetry so searches can be joined
package/dist/index.d.ts CHANGED
@@ -138,6 +138,12 @@ interface AutocompleteResponse {
138
138
  request_at: string;
139
139
  /** The server's funnel-telemetry switch. Absent means off: send no funnel events. */
140
140
  funnel_telemetry?: boolean;
141
+ /**
142
+ * The server's phrase exact match switch. When true, a typed phrase that
143
+ * starts at the word the last request ended in can match an option
144
+ * exactly. Absent means off.
145
+ */
146
+ phrase_exact_match?: boolean;
141
147
  /** The request's `schema_version`, echoed back. */
142
148
  schema_version?: string;
143
149
  };
@@ -931,6 +937,11 @@ interface CoreOptions {
931
937
  * parameters and options to them.
932
938
  */
933
939
  additionalContext?: Record<string, unknown>;
940
+ /**
941
+ * BCP 47 language tag (e.g. `"es"`), sent with every suggestion request and telemetry event.
942
+ * Default: the browser language (`navigator.language`), else `"en-US"`.
943
+ */
944
+ language?: string;
934
945
  /**
935
946
  * Stable id for this visitor, kept by the host across page loads (e.g. a
936
947
  * first-party cookie). Rides on funnel telemetry so searches can be joined