@smart-cloud/ai-kit-ui 1.5.14 → 1.5.16

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 (55) hide show
  1. package/dist/LocaleDirectionProvider.d.ts +5 -0
  2. package/dist/ai-feature/AiFeature.d.ts +1 -0
  3. package/dist/index.cjs +9 -9
  4. package/dist/index.js +9 -9
  5. package/dist/locale.d.ts +13 -0
  6. package/package.json +35 -19
  7. package/eslint.config.js +0 -18
  8. package/src/ShadowBoundary.tsx +0 -229
  9. package/src/ai-chatbot/AiChatbot.tsx +0 -2325
  10. package/src/ai-chatbot/attachmentStorage.ts +0 -238
  11. package/src/ai-chatbot/index.tsx +0 -1
  12. package/src/ai-feature/AiFeature.tsx +0 -2334
  13. package/src/ai-feature/AiFeatureBorder.tsx +0 -22
  14. package/src/ai-feature/ProofreadDiff.tsx +0 -118
  15. package/src/ai-feature/index.tsx +0 -2
  16. package/src/ai-feature/utils.tsx +0 -20
  17. package/src/doc-search/DocSearch.tsx +0 -1313
  18. package/src/doc-search/index.tsx +0 -1
  19. package/src/doc-search/initialFilters.ts +0 -10
  20. package/src/errorHandling.ts +0 -305
  21. package/src/i18n/ar.ts +0 -254
  22. package/src/i18n/de.ts +0 -257
  23. package/src/i18n/en.ts +0 -269
  24. package/src/i18n/es.ts +0 -257
  25. package/src/i18n/fr.ts +0 -258
  26. package/src/i18n/he.ts +0 -250
  27. package/src/i18n/hi.ts +0 -256
  28. package/src/i18n/hu.ts +0 -269
  29. package/src/i18n/id.ts +0 -256
  30. package/src/i18n/index.ts +0 -47
  31. package/src/i18n/it.ts +0 -259
  32. package/src/i18n/ja.ts +0 -256
  33. package/src/i18n/ko.ts +0 -254
  34. package/src/i18n/nb.ts +0 -254
  35. package/src/i18n/nl.ts +0 -255
  36. package/src/i18n/pl.ts +0 -258
  37. package/src/i18n/pt.ts +0 -254
  38. package/src/i18n/ru.ts +0 -254
  39. package/src/i18n/sv.ts +0 -253
  40. package/src/i18n/th.ts +0 -252
  41. package/src/i18n/tr.ts +0 -256
  42. package/src/i18n/ua.ts +0 -257
  43. package/src/i18n/zh.ts +0 -247
  44. package/src/index.tsx +0 -7
  45. package/src/poweredBy.tsx +0 -39
  46. package/src/styles/ai-kit-ui.css +0 -1006
  47. package/src/useAiRun.ts +0 -182
  48. package/src/withAiKitShell.tsx +0 -363
  49. package/tests/ai-disclosures.test.ts +0 -126
  50. package/tests/doc-search-initial-filters.test.ts +0 -20
  51. package/tests/error-handling.test.ts +0 -140
  52. package/tsconfig.json +0 -32
  53. package/tsconfig.node.json +0 -13
  54. package/tsconfig.types.json +0 -13
  55. package/tsup.config.ts +0 -22
@@ -1,140 +0,0 @@
1
- import assert from "node:assert/strict";
2
- import test from "node:test";
3
-
4
- import {
5
- clearAiRunErrorFeedback,
6
- createAiRunErrorFeedback,
7
- getAiRunErrorMessage,
8
- normalizeAiRunError,
9
- } from "../src/errorHandling.ts";
10
-
11
- function backendError(status: number, body: Record<string, unknown>) {
12
- return {
13
- name: "ApiError",
14
- message: `Backend request failed: ${JSON.stringify(body)}`,
15
- response: {
16
- statusCode: status,
17
- body: JSON.stringify(body),
18
- headers: { "x-request-id": body.requestId },
19
- },
20
- };
21
- }
22
-
23
- test("normalizes reCAPTCHA rejection without exposing request data", () => {
24
- const details = normalizeAiRunError(
25
- backendError(403, {
26
- error: {
27
- code: "HUMAN_VERIFICATION_FAILED",
28
- classification: "RISK_REJECTED",
29
- message: "reCAPTCHA verification failed",
30
- retryable: true,
31
- requestId: "req-human-1",
32
- token: "must-not-leak",
33
- },
34
- }),
35
- );
36
-
37
- assert.deepEqual(details, {
38
- kind: "human-verification",
39
- status: 403,
40
- code: "HUMAN_VERIFICATION_FAILED",
41
- safeMessage: "reCAPTCHA verification failed",
42
- requestId: "req-human-1",
43
- classification: "RISK_REJECTED",
44
- retryable: true,
45
- });
46
- assert.equal(
47
- getAiRunErrorMessage(details),
48
- "We couldn't verify that you're human. Please try again.",
49
- );
50
- assert.doesNotMatch(JSON.stringify(details), /must-not-leak/);
51
- });
52
-
53
- test("normalizes a reCAPTCHA provider outage as retryable human verification", () => {
54
- const details = normalizeAiRunError(
55
- backendError(503, {
56
- error: {
57
- code: "HUMAN_VERIFICATION_UNAVAILABLE",
58
- classification: "PROVIDER_UNAVAILABLE",
59
- message: "reCAPTCHA verification is temporarily unavailable",
60
- retryable: true,
61
- requestId: "req-human-503",
62
- },
63
- }),
64
- );
65
-
66
- assert.equal(details.kind, "human-verification");
67
- assert.equal(details.classification, "PROVIDER_UNAVAILABLE");
68
- assert.equal(details.retryable, true);
69
- assert.equal(
70
- getAiRunErrorMessage(details),
71
- "Human verification is temporarily unavailable. Please try again.",
72
- );
73
- });
74
-
75
- test("continues to recognize the legacy AI Kit reCAPTCHA response during rollout", () => {
76
- const details = normalizeAiRunError(
77
- backendError(403, {
78
- code: "HUMAN_VERIFICATION_ERROR",
79
- message: "Assessment rejected",
80
- requestId: "req-human-legacy",
81
- }),
82
- );
83
-
84
- assert.equal(details.kind, "human-verification");
85
- assert.equal(details.classification, undefined);
86
- });
87
-
88
- test("distinguishes authorization, throttling, network, and backend failures", () => {
89
- assert.equal(
90
- normalizeAiRunError(backendError(401, { code: "UNAUTHORIZED" })).kind,
91
- "authorization",
92
- );
93
- assert.equal(
94
- normalizeAiRunError(backendError(429, { code: "THROTTLED" })).kind,
95
- "throttled",
96
- );
97
- assert.equal(
98
- normalizeAiRunError(new TypeError("Failed to fetch")).kind,
99
- "network",
100
- );
101
- assert.equal(
102
- normalizeAiRunError(backendError(503, { code: "UPSTREAM_ERROR" })).kind,
103
- "server",
104
- );
105
- });
106
-
107
- test("explains a configured model capability mismatch", () => {
108
- const details = normalizeAiRunError(
109
- backendError(400, {
110
- code: "MODEL_CAPABILITY_ERROR",
111
- message: "The configured AI model does not support image attachments.",
112
- requestId: "req-model-capability",
113
- }),
114
- );
115
-
116
- assert.equal(details.kind, "validation");
117
- assert.equal(details.code, "MODEL_CAPABILITY_ERROR");
118
- assert.equal(
119
- getAiRunErrorMessage(details),
120
- "The configured AI model does not support image attachments. Contact the site administrator.",
121
- );
122
- });
123
-
124
- test("treats intentional cancellation as non-error feedback", () => {
125
- const feedback = createAiRunErrorFeedback(
126
- new DOMException("Aborted", "AbortError"),
127
- );
128
- assert.equal(feedback.details?.kind, "cancelled");
129
- assert.equal(feedback.message, null);
130
- });
131
-
132
- test("beginning a successful retry clears stale error feedback", () => {
133
- const failed = createAiRunErrorFeedback(
134
- backendError(429, { code: "THROTTLED" }),
135
- );
136
- assert.equal(failed.details?.kind, "throttled");
137
-
138
- const retry = clearAiRunErrorFeedback();
139
- assert.deepEqual(retry, { message: null, details: null });
140
- });
package/tsconfig.json DELETED
@@ -1,32 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "esnext",
4
- "useDefineForClassFields": true,
5
- "lib": ["ESNext", "DOM", "DOM.Iterable"],
6
- "module": "esnext",
7
- "skipLibCheck": true,
8
-
9
- /* Bundler mode */
10
- "moduleResolution": "bundler",
11
- "allowImportingTsExtensions": true,
12
- "resolveJsonModule": true,
13
- "isolatedModules": true,
14
- "noEmit": true,
15
- "jsx": "react-jsx",
16
-
17
- /* Linting */
18
- "strict": true,
19
- "noUnusedLocals": true,
20
- "noUnusedParameters": true,
21
- "noFallthroughCasesInSwitch": true,
22
-
23
- "types": ["jquery", "dom-chromium-ai"]
24
- },
25
- "include": ["src"],
26
- "exclude": ["dist", "build", "node_modules"],
27
- "references": [
28
- {
29
- "path": "./tsconfig.node.json"
30
- }
31
- ]
32
- }
@@ -1,13 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "esnext",
4
- "module": "esnext",
5
- "moduleResolution": "bundler",
6
- "composite": true,
7
- "lib": ["ESNext"],
8
- "allowSyntheticDefaultImports": true,
9
- "types": ["node"]
10
- },
11
- "include": ["tsup.config.ts"],
12
- "exclude": ["src/**", "dist/**", "node_modules/**"]
13
- }
@@ -1,13 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "compilerOptions": {
4
- "noEmit": false,
5
- "declaration": true,
6
- "emitDeclarationOnly": true,
7
- "declarationMap": false,
8
- "rootDir": "src",
9
- "outDir": "dist"
10
- },
11
- "include": ["src"],
12
- "exclude": ["dist", "build", "node_modules", "tsup.config.ts"]
13
- }
package/tsup.config.ts DELETED
@@ -1,22 +0,0 @@
1
- import { defineConfig } from "tsup";
2
-
3
- export default defineConfig({
4
- // Copy non-hashed global CSS so consumers can import it (like Mantine styles)
5
- onSuccess:
6
- "node -e \"const fs=require('fs'); const path=require('path'); fs.mkdirSync('dist',{recursive:true}); fs.copyFileSync(path.join('src','styles','ai-kit-ui.css'), path.join('dist','ai-kit-ui.css'));\"",
7
-
8
- entry: ["src/index.tsx"],
9
- format: ["cjs", "esm"],
10
- dts: false,
11
- splitting: false,
12
- sourcemap: false,
13
- clean: true,
14
- external: [
15
- "react",
16
- "react-dom",
17
- /^aws-amplify(\/.*)?$/,
18
- /^@mantine\/.*?$/,
19
- "jquery",
20
- "@wordpress/data",
21
- ],
22
- });