@aizu-chat/react 0.0.9 → 0.0.10
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/dist/chunk-2TI7IWH7.mjs +67 -0
- package/dist/chunk-HDOMF6SD.mjs +1370 -0
- package/dist/{chunk-BRNQSZ2E.mjs → chunk-TXBCCMO7.mjs} +331 -76
- package/dist/components.d.mts +11 -3
- package/dist/components.d.ts +11 -3
- package/dist/components.js +580 -141
- package/dist/components.mjs +1 -1
- package/dist/index.js +582 -143
- package/dist/index.mjs +1 -1
- package/dist/sdk.d.mts +38 -0
- package/dist/sdk.d.ts +38 -0
- package/dist/sdk.js +136 -0
- package/dist/sdk.mjs +10 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
package/dist/sdk.d.mts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
interface AizuClientConfig {
|
|
2
|
+
hostUrl: string;
|
|
3
|
+
apiKey: string;
|
|
4
|
+
}
|
|
5
|
+
interface ChatRequest {
|
|
6
|
+
query: string;
|
|
7
|
+
thread_id?: string;
|
|
8
|
+
resource_id?: string;
|
|
9
|
+
}
|
|
10
|
+
interface ChatResponse {
|
|
11
|
+
thread_id: string;
|
|
12
|
+
resource_id: string;
|
|
13
|
+
response: string;
|
|
14
|
+
products: Product[];
|
|
15
|
+
}
|
|
16
|
+
interface Product {
|
|
17
|
+
productId: string;
|
|
18
|
+
sku: string;
|
|
19
|
+
title: string;
|
|
20
|
+
description: string;
|
|
21
|
+
price: number;
|
|
22
|
+
stock: number;
|
|
23
|
+
thumbnail: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
declare class AizuClient {
|
|
27
|
+
private hostUrl;
|
|
28
|
+
private apiKey;
|
|
29
|
+
constructor(config: AizuClientConfig);
|
|
30
|
+
private request;
|
|
31
|
+
chat(params: ChatRequest): Promise<ChatResponse>;
|
|
32
|
+
}
|
|
33
|
+
declare const createAizuClient: ({ hostUrl, apiKey, }: {
|
|
34
|
+
hostUrl: string;
|
|
35
|
+
apiKey: string;
|
|
36
|
+
}) => AizuClient;
|
|
37
|
+
|
|
38
|
+
export { AizuClient, type AizuClientConfig, type ChatRequest, type ChatResponse, type Product, createAizuClient };
|
package/dist/sdk.d.ts
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
interface AizuClientConfig {
|
|
2
|
+
hostUrl: string;
|
|
3
|
+
apiKey: string;
|
|
4
|
+
}
|
|
5
|
+
interface ChatRequest {
|
|
6
|
+
query: string;
|
|
7
|
+
thread_id?: string;
|
|
8
|
+
resource_id?: string;
|
|
9
|
+
}
|
|
10
|
+
interface ChatResponse {
|
|
11
|
+
thread_id: string;
|
|
12
|
+
resource_id: string;
|
|
13
|
+
response: string;
|
|
14
|
+
products: Product[];
|
|
15
|
+
}
|
|
16
|
+
interface Product {
|
|
17
|
+
productId: string;
|
|
18
|
+
sku: string;
|
|
19
|
+
title: string;
|
|
20
|
+
description: string;
|
|
21
|
+
price: number;
|
|
22
|
+
stock: number;
|
|
23
|
+
thumbnail: string;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
declare class AizuClient {
|
|
27
|
+
private hostUrl;
|
|
28
|
+
private apiKey;
|
|
29
|
+
constructor(config: AizuClientConfig);
|
|
30
|
+
private request;
|
|
31
|
+
chat(params: ChatRequest): Promise<ChatResponse>;
|
|
32
|
+
}
|
|
33
|
+
declare const createAizuClient: ({ hostUrl, apiKey, }: {
|
|
34
|
+
hostUrl: string;
|
|
35
|
+
apiKey: string;
|
|
36
|
+
}) => AizuClient;
|
|
37
|
+
|
|
38
|
+
export { AizuClient, type AizuClientConfig, type ChatRequest, type ChatResponse, type Product, createAizuClient };
|
package/dist/sdk.js
ADDED
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
"use strict";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __defProps = Object.defineProperties;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
7
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
8
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
|
+
for (var prop in b || (b = {}))
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
if (__getOwnPropSymbols)
|
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
+
if (__propIsEnum.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
};
|
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
+
var __objRest = (source, exclude) => {
|
|
25
|
+
var target = {};
|
|
26
|
+
for (var prop in source)
|
|
27
|
+
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
|
28
|
+
target[prop] = source[prop];
|
|
29
|
+
if (source != null && __getOwnPropSymbols)
|
|
30
|
+
for (var prop of __getOwnPropSymbols(source)) {
|
|
31
|
+
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
|
32
|
+
target[prop] = source[prop];
|
|
33
|
+
}
|
|
34
|
+
return target;
|
|
35
|
+
};
|
|
36
|
+
var __export = (target, all) => {
|
|
37
|
+
for (var name in all)
|
|
38
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
39
|
+
};
|
|
40
|
+
var __copyProps = (to, from, except, desc) => {
|
|
41
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
42
|
+
for (let key of __getOwnPropNames(from))
|
|
43
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
44
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
45
|
+
}
|
|
46
|
+
return to;
|
|
47
|
+
};
|
|
48
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
49
|
+
var __async = (__this, __arguments, generator) => {
|
|
50
|
+
return new Promise((resolve, reject) => {
|
|
51
|
+
var fulfilled = (value) => {
|
|
52
|
+
try {
|
|
53
|
+
step(generator.next(value));
|
|
54
|
+
} catch (e) {
|
|
55
|
+
reject(e);
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
var rejected = (value) => {
|
|
59
|
+
try {
|
|
60
|
+
step(generator.throw(value));
|
|
61
|
+
} catch (e) {
|
|
62
|
+
reject(e);
|
|
63
|
+
}
|
|
64
|
+
};
|
|
65
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
66
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
// src/sdk/index.ts
|
|
71
|
+
var sdk_exports = {};
|
|
72
|
+
__export(sdk_exports, {
|
|
73
|
+
AizuClient: () => AizuClient,
|
|
74
|
+
createAizuClient: () => createAizuClient
|
|
75
|
+
});
|
|
76
|
+
module.exports = __toCommonJS(sdk_exports);
|
|
77
|
+
|
|
78
|
+
// src/sdk/client.ts
|
|
79
|
+
var AizuClient = class {
|
|
80
|
+
constructor(config) {
|
|
81
|
+
const { hostUrl, apiKey } = config;
|
|
82
|
+
if (typeof hostUrl !== "string" || hostUrl.trim().length === 0) {
|
|
83
|
+
throw new Error(
|
|
84
|
+
"Invalid AizuClient configuration: 'hostUrl' must be a non-empty string."
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
if (typeof apiKey !== "string" || apiKey.trim().length === 0) {
|
|
88
|
+
throw new Error(
|
|
89
|
+
"Invalid AizuClient configuration: 'apiKey' must be a non-empty string."
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
this.hostUrl = hostUrl;
|
|
93
|
+
this.apiKey = apiKey;
|
|
94
|
+
}
|
|
95
|
+
request(_0) {
|
|
96
|
+
return __async(this, arguments, function* (path, options = {}) {
|
|
97
|
+
const url = `${this.hostUrl}${path}`;
|
|
98
|
+
const _a = options, { body } = _a, restOptions = __objRest(_a, ["body"]);
|
|
99
|
+
const response = yield fetch(url, __spreadProps(__spreadValues({}, restOptions), {
|
|
100
|
+
headers: __spreadValues({
|
|
101
|
+
"Content-Type": "application/json",
|
|
102
|
+
"x-api-key": this.apiKey
|
|
103
|
+
}, options.headers),
|
|
104
|
+
body: body ? JSON.stringify(body) : void 0
|
|
105
|
+
}));
|
|
106
|
+
if (!response.ok) {
|
|
107
|
+
const errorBody = yield response.text().catch(() => "");
|
|
108
|
+
const errorMessage = `API Error: ${response.status} ${response.statusText}${errorBody ? ` - ${errorBody}` : ""}`;
|
|
109
|
+
throw new Error(errorMessage);
|
|
110
|
+
}
|
|
111
|
+
return yield response.json();
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
chat(params) {
|
|
115
|
+
return __async(this, null, function* () {
|
|
116
|
+
if (!params.query.trim()) {
|
|
117
|
+
throw new Error("Query is required");
|
|
118
|
+
}
|
|
119
|
+
return this.request("/chat/query", {
|
|
120
|
+
method: "POST",
|
|
121
|
+
body: params
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
var createAizuClient = ({
|
|
127
|
+
hostUrl,
|
|
128
|
+
apiKey
|
|
129
|
+
}) => {
|
|
130
|
+
return new AizuClient({ hostUrl, apiKey });
|
|
131
|
+
};
|
|
132
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
133
|
+
0 && (module.exports = {
|
|
134
|
+
AizuClient,
|
|
135
|
+
createAizuClient
|
|
136
|
+
});
|
package/dist/sdk.mjs
ADDED