@magicx-eng/ai-autocomplete-vanilla 0.39.0 → 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 +4 -3
- package/dist/index.d.mts +7 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -80,7 +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. Default: navigator.language, else "en-US"
|
|
83
|
+
language: "es", // BCP 47 tag sent with every suggestion request and telemetry event. Default: navigator.language, else "en-US"
|
|
84
84
|
|
|
85
85
|
// Appearance
|
|
86
86
|
mode: "auto", // "light" | "dark" | "auto"
|
|
@@ -730,13 +730,14 @@ A discriminated union: `APIKeyConfig | AccessTokenConfig`.
|
|
|
730
730
|
getAccessToken: async () => {
|
|
731
731
|
const res = await fetch("/api/ac-token");
|
|
732
732
|
const { access_token, expires_at } = await res.json();
|
|
733
|
-
|
|
733
|
+
// expires_at is Unix seconds; the SDK's expiresAt is Unix milliseconds.
|
|
734
|
+
return { accessToken: access_token, expiresAt: expires_at * 1000 };
|
|
734
735
|
},
|
|
735
736
|
endpoint: "https://api.ai-autocomplete.com/api/suggest", // optional, this is the default
|
|
736
737
|
}
|
|
737
738
|
```
|
|
738
739
|
|
|
739
|
-
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).
|
|
740
741
|
|
|
741
742
|
### `AutocompleteResult`
|
|
742
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
|
};
|
|
@@ -932,7 +938,7 @@ interface CoreOptions {
|
|
|
932
938
|
*/
|
|
933
939
|
additionalContext?: Record<string, unknown>;
|
|
934
940
|
/**
|
|
935
|
-
* BCP 47 language tag (e.g. `"es"`), sent with every suggestion request.
|
|
941
|
+
* BCP 47 language tag (e.g. `"es"`), sent with every suggestion request and telemetry event.
|
|
936
942
|
* Default: the browser language (`navigator.language`), else `"en-US"`.
|
|
937
943
|
*/
|
|
938
944
|
language?: string;
|
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
|
};
|
|
@@ -932,7 +938,7 @@ interface CoreOptions {
|
|
|
932
938
|
*/
|
|
933
939
|
additionalContext?: Record<string, unknown>;
|
|
934
940
|
/**
|
|
935
|
-
* BCP 47 language tag (e.g. `"es"`), sent with every suggestion request.
|
|
941
|
+
* BCP 47 language tag (e.g. `"es"`), sent with every suggestion request and telemetry event.
|
|
936
942
|
* Default: the browser language (`navigator.language`), else `"en-US"`.
|
|
937
943
|
*/
|
|
938
944
|
language?: string;
|