@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/index.mjs CHANGED
@@ -4,7 +4,7 @@ import {
4
4
  Button,
5
5
  Loading,
6
6
  QuickMenus
7
- } from "./chunk-BRNQSZ2E.mjs";
7
+ } from "./chunk-HDOMF6SD.mjs";
8
8
  import {
9
9
  useCustom
10
10
  } from "./chunk-KLPKNMIP.mjs";
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
@@ -0,0 +1,10 @@
1
+ 'use client'
2
+ import {
3
+ AizuClient,
4
+ createAizuClient
5
+ } from "./chunk-2TI7IWH7.mjs";
6
+ import "./chunk-33CPD3DF.mjs";
7
+ export {
8
+ AizuClient,
9
+ createAizuClient
10
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aizu-chat/react",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "sideEffects": ["*.css", "dist/**/*.css"],
5
5
  "license": "MIT",
6
6
  "files": ["dist"],