@smart-cloud/ai-kit-ui 1.5.13 → 1.5.15

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 (54) hide show
  1. package/dist/LocaleDirectionProvider.d.ts +5 -0
  2. package/dist/index.cjs +9 -9
  3. package/dist/index.js +9 -9
  4. package/dist/locale.d.ts +13 -0
  5. package/package.json +35 -19
  6. package/eslint.config.js +0 -18
  7. package/src/ShadowBoundary.tsx +0 -229
  8. package/src/ai-chatbot/AiChatbot.tsx +0 -2307
  9. package/src/ai-chatbot/attachmentStorage.ts +0 -238
  10. package/src/ai-chatbot/index.tsx +0 -1
  11. package/src/ai-feature/AiFeature.tsx +0 -2334
  12. package/src/ai-feature/AiFeatureBorder.tsx +0 -22
  13. package/src/ai-feature/ProofreadDiff.tsx +0 -118
  14. package/src/ai-feature/index.tsx +0 -2
  15. package/src/ai-feature/utils.tsx +0 -20
  16. package/src/doc-search/DocSearch.tsx +0 -1313
  17. package/src/doc-search/index.tsx +0 -1
  18. package/src/doc-search/initialFilters.ts +0 -10
  19. package/src/errorHandling.ts +0 -300
  20. package/src/i18n/ar.ts +0 -252
  21. package/src/i18n/de.ts +0 -255
  22. package/src/i18n/en.ts +0 -267
  23. package/src/i18n/es.ts +0 -255
  24. package/src/i18n/fr.ts +0 -256
  25. package/src/i18n/he.ts +0 -248
  26. package/src/i18n/hi.ts +0 -254
  27. package/src/i18n/hu.ts +0 -267
  28. package/src/i18n/id.ts +0 -254
  29. package/src/i18n/index.ts +0 -47
  30. package/src/i18n/it.ts +0 -257
  31. package/src/i18n/ja.ts +0 -254
  32. package/src/i18n/ko.ts +0 -252
  33. package/src/i18n/nb.ts +0 -252
  34. package/src/i18n/nl.ts +0 -253
  35. package/src/i18n/pl.ts +0 -256
  36. package/src/i18n/pt.ts +0 -252
  37. package/src/i18n/ru.ts +0 -252
  38. package/src/i18n/sv.ts +0 -251
  39. package/src/i18n/th.ts +0 -250
  40. package/src/i18n/tr.ts +0 -254
  41. package/src/i18n/ua.ts +0 -255
  42. package/src/i18n/zh.ts +0 -245
  43. package/src/index.tsx +0 -7
  44. package/src/poweredBy.tsx +0 -39
  45. package/src/styles/ai-kit-ui.css +0 -1006
  46. package/src/useAiRun.ts +0 -182
  47. package/src/withAiKitShell.tsx +0 -363
  48. package/tests/ai-disclosures.test.ts +0 -97
  49. package/tests/doc-search-initial-filters.test.ts +0 -20
  50. package/tests/error-handling.test.ts +0 -123
  51. package/tsconfig.json +0 -32
  52. package/tsconfig.node.json +0 -13
  53. package/tsconfig.types.json +0 -13
  54. package/tsup.config.ts +0 -22
@@ -1,123 +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("treats intentional cancellation as non-error feedback", () => {
108
- const feedback = createAiRunErrorFeedback(
109
- new DOMException("Aborted", "AbortError"),
110
- );
111
- assert.equal(feedback.details?.kind, "cancelled");
112
- assert.equal(feedback.message, null);
113
- });
114
-
115
- test("beginning a successful retry clears stale error feedback", () => {
116
- const failed = createAiRunErrorFeedback(
117
- backendError(429, { code: "THROTTLED" }),
118
- );
119
- assert.equal(failed.details?.kind, "throttled");
120
-
121
- const retry = clearAiRunErrorFeedback();
122
- assert.deepEqual(retry, { message: null, details: null });
123
- });
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
- });