@reopt-ai/brandapp-sdk 3.3.0 → 3.5.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/CHANGELOG.md +115 -0
- package/README.md +10 -1
- package/dist/abort--nOBFN4M.js +50 -0
- package/dist/ai/index.d.ts +2 -314
- package/dist/ai/index.js +3 -8
- package/dist/ai-provider/index.d.ts +79 -163
- package/dist/ai-provider/index.js +752 -685
- package/dist/auth/index.d.ts +27 -27
- package/dist/auth/index.js +41 -34
- package/dist/better-auth/client.d.ts +6 -5
- package/dist/better-auth/client.js +28 -5
- package/dist/better-auth/index.d.ts +19 -17
- package/dist/better-auth/index.js +180 -144
- package/dist/client-61ldOHMz.js +503 -0
- package/dist/client-7PCoxVhZ.js +28 -0
- package/dist/client-B7rZQ8Zi.d.ts +272 -0
- package/dist/client-BGGd_cpV.d.ts +103 -0
- package/dist/client-BoIuyx4S.js +273 -0
- package/dist/client-BruP5_nU.d.ts +147 -0
- package/dist/client-BxtZt405.js +305 -0
- package/dist/client-ByN3EQdk.js +83 -0
- package/dist/client-CAghoGD_.js +53 -0
- package/dist/client-C_pHsPlj.js +81 -0
- package/dist/client-D0eBxh8j.d.ts +284 -0
- package/dist/client-D6gs61w8.d.ts +53 -0
- package/dist/client-DDw5yz_h.d.ts +53 -0
- package/dist/client-Dxg8_DIH.d.ts +71 -0
- package/dist/client-aMR4CRB8.d.ts +211 -0
- package/dist/client-lk6wBu_0.d.ts +48 -0
- package/dist/client-wEVKLdly.js +55 -0
- package/dist/client-zF1RG2uA.js +86 -0
- package/dist/cms/index.d.ts +52 -108
- package/dist/cms/index.js +103 -86
- package/dist/config-CRytOPPl.d.ts +394 -0
- package/dist/config-aml9oQpX.js +487 -0
- package/dist/dev/index.d.ts +2 -528
- package/dist/dev/index.js +3047 -2967
- package/dist/eav/coerce.d.ts +3 -1
- package/dist/eav/coerce.js +72 -46
- package/dist/eav/index.d.ts +72 -100
- package/dist/eav/index.js +158 -126
- package/dist/eav/migrate.d.ts +112 -109
- package/dist/eav/migrate.js +230 -196
- package/dist/eav/schema.d.ts +111 -150
- package/dist/eav/schema.js +624 -603
- package/dist/encoding-Bwfm3iaE.js +21 -0
- package/dist/{errors-BjDFIyA6.d.ts → errors-CRCcErNC.d.ts} +55 -53
- package/dist/feedback/index.d.ts +2 -132
- package/dist/feedback/index.js +3 -6
- package/dist/files/index.d.ts +14 -14
- package/dist/files/index.js +41 -25
- package/dist/http-client-BZc2mngq.js +386 -0
- package/dist/index-1j_738qk.d.ts +470 -0
- package/dist/index-CeOLGdyL.d.ts +169 -0
- package/dist/index.d.ts +6 -230
- package/dist/index.js +119 -71
- package/dist/logout/index.d.ts +56 -53
- package/dist/logout/index.js +232 -289
- package/dist/plans/index.d.ts +2 -236
- package/dist/plans/index.js +3 -6
- package/dist/push/index.d.ts +2 -79
- package/dist/push/index.js +3 -6
- package/dist/query-xWqtfkvR.js +35 -0
- package/dist/react/hooks.d.ts +157 -100
- package/dist/react/hooks.js +862 -406
- package/dist/sse-parser-FMjxM7sY.js +86 -0
- package/dist/terms/index.d.ts +3 -79
- package/dist/terms/index.js +3 -6
- package/dist/testing/index.d.ts +52 -104
- package/dist/testing/index.js +94 -72
- package/dist/types-B-SMkH6s.d.ts +26 -0
- package/dist/types-BXDcoJHG.d.ts +131 -0
- package/dist/types-BrghN2rJ.d.ts +105 -0
- package/dist/types-DjDRszNj.js +11 -0
- package/dist/webhooks/index.d.ts +77 -50
- package/dist/webhooks/index.js +150 -127
- package/docs/api-reference.md +121 -8
- package/docs/errors.md +19 -0
- package/docs/files.md +165 -7
- package/package.json +7 -6
- package/dist/chunk-2LSCQHAU.js +0 -21
- package/dist/chunk-4U4ZPPL4.js +0 -599
- package/dist/chunk-55KHY5GH.js +0 -96
- package/dist/chunk-C5VTRZWX.js +0 -458
- package/dist/chunk-F7BXBTZI.js +0 -54
- package/dist/chunk-FJUCWXX3.js +0 -350
- package/dist/chunk-H33OTQEN.js +0 -112
- package/dist/chunk-L4DHB36G.js +0 -75
- package/dist/chunk-OG7R3UAR.js +0 -105
- package/dist/chunk-PF24XU54.js +0 -32
- package/dist/chunk-QN3QD67K.js +0 -49
- package/dist/chunk-REIKXSMY.js +0 -7
- package/dist/chunk-UGBBXCZE.js +0 -157
- package/dist/chunk-UVT2E6KD.js +0 -81
- package/dist/chunk-YPLT3RFL.js +0 -63
- package/dist/chunk-YTKSAWV2.js +0 -463
- package/dist/client-BkcO-0C2.d.ts +0 -216
- package/dist/client-CN5_tNOC.d.ts +0 -147
- package/dist/client-DttyeM_h.d.ts +0 -102
- package/dist/config-CtxyJsDR.d.ts +0 -397
- package/dist/typed-client-BxOVIiMU.d.ts +0 -40
- package/dist/types-6E3ZLL9X.d.ts +0 -24
- package/dist/types-DskYLVb8.d.ts +0 -104
- package/dist/types-ckmDDW3N.d.ts +0 -129
package/dist/index.d.ts
CHANGED
|
@@ -1,230 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
|
|
7
|
-
export { h as DebugLogger, R as REOPT_BASE_URLS, v as resolveBaseUrl } from './config-CtxyJsDR.js';
|
|
8
|
-
import { a as ListPostsQuery, C as CmsPaginatedResponse, P as Post, c as PostDetail, L as ListPostGroupsQuery, d as PostGroup, b as ListTagsQuery, T as Tag } from './types-ckmDDW3N.js';
|
|
9
|
-
import { R as ReoptAuthClient } from './client-DttyeM_h.js';
|
|
10
|
-
import { ReoptAiClient } from './ai/index.js';
|
|
11
|
-
export { AgentInfo, ChatMessage, CompletionOptions, CompletionResult, CreditInfo, FinishReason, ImageGenerateOptions, ImageGenerateResult, MessageRole, ModelInfo, StreamDoneData, StreamEvent } from './ai/index.js';
|
|
12
|
-
export { A as AuthError, a as AuthUserNotFoundError, b as AuthUserRecordExistsError, B as BadRequestError, C as ConflictError, c as ContentFilterError, d as CreditLimitError, D as DuplicateAuthUserError, E as ErrorDiagnostic, F as FieldError, e as ForbiddenError, L as LimitExceededError, M as ModelAccessError, f as ModelNotFoundError, N as NotFoundError, R as RateLimitError, g as ReoptSDKError, h as ReoptSDKErrorContext, i as RequiredTermsError, S as ServerError, V as ValidationError, j as isCreditLimitError, k as isModelAccessError, l as isReoptSDKError, m as isRequiredTermsError, n as isValidationError, o as mapHttpStatusToError } from './errors-BjDFIyA6.js';
|
|
13
|
-
import { E as EntityClient } from './typed-client-BxOVIiMU.js';
|
|
14
|
-
export { T as TypedEavRecord } from './typed-client-BxOVIiMU.js';
|
|
15
|
-
import './types-DskYLVb8.js';
|
|
16
|
-
|
|
17
|
-
type FetchOptions = {
|
|
18
|
-
/** Abort the request via an external AbortSignal (merged with timeout signal). */
|
|
19
|
-
signal?: AbortSignal;
|
|
20
|
-
/** Override the client-level timeout for this call only (ms). */
|
|
21
|
-
timeout?: number;
|
|
22
|
-
/**
|
|
23
|
-
* Swap the default Basic Auth header for `Authorization: Bearer <token>` on
|
|
24
|
-
* this call only. Used by user-scoped endpoints (e.g. `/external-auth`,
|
|
25
|
-
* OIDC userinfo) where the caller supplies an OAuth access token rather
|
|
26
|
-
* than client credentials.
|
|
27
|
-
*/
|
|
28
|
-
bearerToken?: string;
|
|
29
|
-
/**
|
|
30
|
-
* Treat this request as idempotent for retry purposes even when the HTTP
|
|
31
|
-
* method is POST/PATCH. Use for read-style operations tunneled over POST
|
|
32
|
-
* (e.g. the Better Auth adapter's `findOne`/`findMany`/`count`) so transient
|
|
33
|
-
* 5xx / network / timeout failures are retried without opting the whole
|
|
34
|
-
* client into `retryNonIdempotent`. **Never** set this on a mutation — a
|
|
35
|
-
* retried write may duplicate a committed side effect.
|
|
36
|
-
*/
|
|
37
|
-
idempotent?: boolean;
|
|
38
|
-
};
|
|
39
|
-
type BaseHttpClientOptions = {
|
|
40
|
-
/**
|
|
41
|
-
* Route requests at the id (auth) server instead of the main API host.
|
|
42
|
-
* Used for OIDC userinfo, Better Auth, and other `/api/auth/*` endpoints
|
|
43
|
-
* that only exist on `id.reopt.ai`.
|
|
44
|
-
*/
|
|
45
|
-
useIdServer?: boolean;
|
|
46
|
-
};
|
|
47
|
-
declare class BaseHttpClient {
|
|
48
|
-
private readonly baseUrl;
|
|
49
|
-
private readonly authHeader;
|
|
50
|
-
private readonly timeout;
|
|
51
|
-
private readonly maxRetries;
|
|
52
|
-
private readonly retryNonIdempotent;
|
|
53
|
-
private readonly debug;
|
|
54
|
-
constructor(config: ReoptSDKConfig, pathPrefix: string, options?: BaseHttpClientOptions);
|
|
55
|
-
/**
|
|
56
|
-
* Resolved request origin + path prefix
|
|
57
|
-
* (e.g. `https://brandapp.reopt.ai/api/v1/brandapp/{id}/ai`). Exposed so domain
|
|
58
|
-
* clients that must hand-roll `fetch` (SSE streaming, multipart upload) reuse
|
|
59
|
-
* the same resolved host instead of re-deriving it.
|
|
60
|
-
*/
|
|
61
|
-
get requestBaseUrl(): string;
|
|
62
|
-
/** The default `Authorization` header value (Basic or pre-minted Bearer). */
|
|
63
|
-
get authorizationHeader(): string;
|
|
64
|
-
/** Configured request timeout in ms. */
|
|
65
|
-
get timeoutMs(): number;
|
|
66
|
-
fetch<T>(method: string, path: string, body?: unknown, options?: FetchOptions): Promise<T>;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Create a lazy SDK instance that initializes on first property access.
|
|
71
|
-
*
|
|
72
|
-
* @example
|
|
73
|
-
* ```ts
|
|
74
|
-
* import { createLazySDK } from "@reopt-ai/brandapp-sdk";
|
|
75
|
-
* import schema from "./eav.schema";
|
|
76
|
-
*
|
|
77
|
-
* export const sdk = createLazySDK(() => ({
|
|
78
|
-
* clientId: process.env.BRANDAPP_CLIENT_ID!,
|
|
79
|
-
* clientSecret: process.env.BRANDAPP_CLIENT_SECRET!,
|
|
80
|
-
* brandappId: process.env.BRANDAPP_ID!,
|
|
81
|
-
* schema,
|
|
82
|
-
* }));
|
|
83
|
-
*
|
|
84
|
-
* // First property access triggers initialization
|
|
85
|
-
* await sdk.eav.entity("contacts").records.list();
|
|
86
|
-
* ```
|
|
87
|
-
*/
|
|
88
|
-
declare function createLazySDK<S extends SchemaDef = SchemaDef>(configFactory: () => ReoptSDKConfig<S>): ReoptSDK<S>;
|
|
89
|
-
/**
|
|
90
|
-
* Initialize the global SDK singleton with explicit config.
|
|
91
|
-
*
|
|
92
|
-
* @example
|
|
93
|
-
* ```ts
|
|
94
|
-
* import { initReoptSDK } from "@reopt-ai/brandapp-sdk";
|
|
95
|
-
*
|
|
96
|
-
* initReoptSDK({
|
|
97
|
-
* clientId: process.env.BRANDAPP_CLIENT_ID!,
|
|
98
|
-
* clientSecret: process.env.BRANDAPP_CLIENT_SECRET!,
|
|
99
|
-
* brandappId: process.env.BRANDAPP_ID!,
|
|
100
|
-
* });
|
|
101
|
-
* ```
|
|
102
|
-
*/
|
|
103
|
-
declare function initReoptSDK<S extends SchemaDef = SchemaDef>(config: ReoptSDKConfig<S>): ReoptSDK<S>;
|
|
104
|
-
/**
|
|
105
|
-
* Get the global SDK singleton.
|
|
106
|
-
*
|
|
107
|
-
* Returns the instance set by `initReoptSDK()`, or auto-creates one
|
|
108
|
-
* from environment variables (`BRANDAPP_CLIENT_ID`, `BRANDAPP_CLIENT_SECRET`,
|
|
109
|
-
* `BRANDAPP_ID`).
|
|
110
|
-
*
|
|
111
|
-
* ⚠️ **Schema generic is not carried here.** A single module-global variable
|
|
112
|
-
* structurally cannot preserve a per-call schema type, so this always returns
|
|
113
|
-
* the default-schema `ReoptSDK` — `sdk.eav.entity(name)` falls back to untyped
|
|
114
|
-
* access (no autocomplete / `InferValues`). For type-safe EAV, prefer
|
|
115
|
-
* {@link createLazySDK} (or `createReoptSDK`) with your `schema`, which keeps
|
|
116
|
-
* the generic intact.
|
|
117
|
-
*
|
|
118
|
-
* @throws {Error} If no instance exists and env vars are missing
|
|
119
|
-
*/
|
|
120
|
-
declare function getReoptSDK(): ReoptSDK;
|
|
121
|
-
/** Reset the global SDK singleton. Useful for testing. */
|
|
122
|
-
declare function resetSDK(): void;
|
|
123
|
-
|
|
124
|
-
/**
|
|
125
|
-
* Create a unified Reopt SDK instance
|
|
126
|
-
*
|
|
127
|
-
* @example
|
|
128
|
-
* ```ts
|
|
129
|
-
* import { createReoptSDK } from "@reopt-ai/brandapp-sdk";
|
|
130
|
-
*
|
|
131
|
-
* const sdk = createReoptSDK({
|
|
132
|
-
* clientId: process.env.BRANDAPP_CLIENT_ID!,
|
|
133
|
-
* clientSecret: process.env.BRANDAPP_CLIENT_SECRET!,
|
|
134
|
-
* brandappId: process.env.BRANDAPP_ID!,
|
|
135
|
-
* });
|
|
136
|
-
*
|
|
137
|
-
* // EAV client
|
|
138
|
-
* const entities = await sdk.eav.entities.list();
|
|
139
|
-
*
|
|
140
|
-
* // AI client
|
|
141
|
-
* const result = await sdk.ai.complete({
|
|
142
|
-
* messages: [{ role: "user", content: "Hello" }],
|
|
143
|
-
* });
|
|
144
|
-
*
|
|
145
|
-
* // File client
|
|
146
|
-
* const { data: files } = await sdk.files.list();
|
|
147
|
-
* const uploaded = await sdk.files.upload(blob, { name: "banner.png" });
|
|
148
|
-
*
|
|
149
|
-
* // CMS client
|
|
150
|
-
* const { records: posts } = await sdk.cms.posts.list({ status: "published" });
|
|
151
|
-
* const post = await sdk.cms.posts.get(postId);
|
|
152
|
-
* ```
|
|
153
|
-
*/
|
|
154
|
-
type ReoptSDK<S extends SchemaDef = SchemaDef> = ReturnType<typeof createReoptSDK<S>>;
|
|
155
|
-
declare function createReoptSDK<S extends SchemaDef = SchemaDef>(config: ReoptSDKConfig<S>): {
|
|
156
|
-
config: {
|
|
157
|
-
brandappId: string;
|
|
158
|
-
debug: boolean | DebugLevel;
|
|
159
|
-
};
|
|
160
|
-
ai: ReoptAiClient;
|
|
161
|
-
auth: ReoptAuthClient;
|
|
162
|
-
cms: {
|
|
163
|
-
posts: {
|
|
164
|
-
list(query?: ListPostsQuery): Promise<CmsPaginatedResponse<Post>>;
|
|
165
|
-
get(postId: string): Promise<PostDetail>;
|
|
166
|
-
getBySlug(slug: string, opts?: {
|
|
167
|
-
groupId?: string;
|
|
168
|
-
groupSlug?: string;
|
|
169
|
-
}): Promise<PostDetail>;
|
|
170
|
-
};
|
|
171
|
-
postGroups: {
|
|
172
|
-
list(query?: ListPostGroupsQuery): Promise<CmsPaginatedResponse<PostGroup>>;
|
|
173
|
-
get(groupId: string): Promise<PostGroup>;
|
|
174
|
-
getBySlug(slug: string): Promise<PostGroup>;
|
|
175
|
-
};
|
|
176
|
-
tags: {
|
|
177
|
-
list(query?: ListTagsQuery): Promise<Tag[]>;
|
|
178
|
-
};
|
|
179
|
-
};
|
|
180
|
-
eav: {
|
|
181
|
-
entities: {
|
|
182
|
-
list(): Promise<EavEntity[]>;
|
|
183
|
-
create(input: CreateEntityInput): Promise<EavEntity>;
|
|
184
|
-
get(entityId: string): Promise<EavEntity & {
|
|
185
|
-
attributes: EavAttribute[];
|
|
186
|
-
}>;
|
|
187
|
-
update(entityId: string, input: UpdateEntityInput): Promise<EavEntity>;
|
|
188
|
-
delete(entityId: string): Promise<void>;
|
|
189
|
-
};
|
|
190
|
-
attributes: {
|
|
191
|
-
create(entityId: string, input: CreateAttributeInput): Promise<EavAttribute>;
|
|
192
|
-
update(entityId: string, attributeId: string, input: UpdateAttributeInput): Promise<EavAttribute>;
|
|
193
|
-
delete(entityId: string, attributeId: string): Promise<void>;
|
|
194
|
-
};
|
|
195
|
-
records: {
|
|
196
|
-
list(entityId: string, query?: ListRecordsQuery): Promise<PaginatedResponse<EavRecord>>;
|
|
197
|
-
create(entityId: string, input: CreateRecordInput): Promise<EavRecord>;
|
|
198
|
-
get(entityId: string, recordId: string): Promise<EavRecord>;
|
|
199
|
-
update(entityId: string, recordId: string, input: UpdateRecordInput): Promise<EavRecord>;
|
|
200
|
-
delete(entityId: string, recordId: string): Promise<void>;
|
|
201
|
-
count(entityId: string, query?: CountRecordsQuery): Promise<number>;
|
|
202
|
-
bulkDelete(entityId: string, ids: string[]): Promise<number>;
|
|
203
|
-
bulkUpdate(entityId: string, updates: BulkUpdateItem[]): Promise<EavRecord[]>;
|
|
204
|
-
findOne(entityId: string, query?: Omit<ListRecordsQuery, "page">): Promise<EavRecord | null>;
|
|
205
|
-
upsert(entityId: string, input: UpsertRecordInput): Promise<UpsertRecordResult<EavRecord>>;
|
|
206
|
-
bulkCreate(entityId: string, records: CreateRecordInput[]): Promise<EavRecord[]>;
|
|
207
|
-
deleteWhere(entityId: string, input: DeleteWhereInput): Promise<number>;
|
|
208
|
-
listAll(entityId: string, query?: Omit<ListRecordsQuery, "page">): AsyncGenerator<EavRecord>;
|
|
209
|
-
backfill(entityId: string, opts: BackfillOptions): Promise<BackfillResult>;
|
|
210
|
-
};
|
|
211
|
-
users: {
|
|
212
|
-
getRecords(authUserId: string, query?: Omit<ListRecordsQuery, "authUserId">): Promise<PaginatedResponse<EavRecord>>;
|
|
213
|
-
};
|
|
214
|
-
schemaHash(): Promise<{
|
|
215
|
-
hash: string;
|
|
216
|
-
schemaCount: number;
|
|
217
|
-
fieldCount: number;
|
|
218
|
-
generatedAt: string;
|
|
219
|
-
}>;
|
|
220
|
-
entity<K extends string & keyof S["entities"]>(name: K): EntityClient<S["entities"][K] extends EntityDef ? S["entities"][K] : EntityDef>;
|
|
221
|
-
invalidateCache(): void;
|
|
222
|
-
};
|
|
223
|
-
feedback: ReoptFeedbackClient;
|
|
224
|
-
files: ReoptFileClient;
|
|
225
|
-
plans: ReoptPlansClient;
|
|
226
|
-
push: ReoptPushClient;
|
|
227
|
-
terms: ReoptTermsClient;
|
|
228
|
-
};
|
|
229
|
-
|
|
230
|
-
export { BaseHttpClient, DebugLevel, EntityClient, type ReoptSDK, ReoptSDKConfig, createLazySDK, createReoptSDK, getReoptSDK, initReoptSDK, resetSDK };
|
|
1
|
+
import { a as DebugLogger, i as DebugLevel, n as ReoptSDKConfig, r as resolveBaseUrl, t as REOPT_BASE_URLS } from "./config-CRytOPPl.js";
|
|
2
|
+
import { a as CompletionOptions, c as FinishReason, d as MessageRole, f as ModelInfo, i as ChatMessage, l as ImageGenerateOptions, m as StreamEvent, o as CompletionResult, p as StreamDoneData, r as AgentInfo, s as CreditInfo, u as ImageGenerateResult } from "./client-D0eBxh8j.js";
|
|
3
|
+
import { C as isModelAccessError, D as mapHttpStatusToError, E as isValidationError, S as isCreditLimitError, T as isRequiredTermsError, _ as ReoptSDKError, a as ConflictError, b as ServerError, c as DuplicateAuthUserError, d as ForbiddenError, f as LimitExceededError, g as RateLimitError, h as NotFoundError, i as BadRequestError, l as ErrorDiagnostic, m as ModelNotFoundError, n as AuthUserNotFoundError, o as ContentFilterError, p as ModelAccessError, r as AuthUserRecordExistsError, s as CreditLimitError, t as AuthError, u as FieldError, v as ReoptSDKErrorContext, w as isReoptSDKError, x as ValidationError, y as RequiredTermsError } from "./errors-CRCcErNC.js";
|
|
4
|
+
import { i as TypedEavRecord, r as EntityClient } from "./client-BGGd_cpV.js";
|
|
5
|
+
import { a as initReoptSDK, i as getReoptSDK, n as createReoptSDK, o as resetSDK, r as createLazySDK, s as BaseHttpClient, t as ReoptSDK } from "./index-CeOLGdyL.js";
|
|
6
|
+
export { type AgentInfo, AuthError, AuthUserNotFoundError, AuthUserRecordExistsError, BadRequestError, BaseHttpClient, type ChatMessage, type CompletionOptions, type CompletionResult, ConflictError, ContentFilterError, type CreditInfo, CreditLimitError, type DebugLevel, type DebugLogger, DuplicateAuthUserError, type EntityClient, type ErrorDiagnostic, type FieldError, type FinishReason, ForbiddenError, type ImageGenerateOptions, type ImageGenerateResult, LimitExceededError, type MessageRole, ModelAccessError, type ModelInfo, ModelNotFoundError, NotFoundError, REOPT_BASE_URLS, RateLimitError, ReoptSDK, type ReoptSDKConfig, ReoptSDKError, type ReoptSDKErrorContext, RequiredTermsError, ServerError, type StreamDoneData, type StreamEvent, type TypedEavRecord, ValidationError, createLazySDK, createReoptSDK, getReoptSDK, initReoptSDK, isCreditLimitError, isModelAccessError, isReoptSDKError, isRequiredTermsError, isValidationError, mapHttpStatusToError, resetSDK, resolveBaseUrl };
|
package/dist/index.js
CHANGED
|
@@ -1,85 +1,133 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import './chunk-PF24XU54.js';
|
|
13
|
-
export { BaseHttpClient } from './chunk-YTKSAWV2.js';
|
|
14
|
-
import './chunk-2LSCQHAU.js';
|
|
15
|
-
import { assertBrowserSafe } from './chunk-C5VTRZWX.js';
|
|
16
|
-
export { AuthError, AuthUserNotFoundError, AuthUserRecordExistsError, BadRequestError, ConflictError, ContentFilterError, CreditLimitError, DuplicateAuthUserError, ForbiddenError, LimitExceededError, ModelAccessError, ModelNotFoundError, NotFoundError, REOPT_BASE_URLS, RateLimitError, ReoptSDKError, RequiredTermsError, ServerError, ValidationError, isCreditLimitError, isModelAccessError, isReoptSDKError, isRequiredTermsError, isValidationError, mapHttpStatusToError, resolveBaseUrl } from './chunk-C5VTRZWX.js';
|
|
1
|
+
import { A as mapHttpStatusToError, C as ServerError, D as isReoptSDKError, E as isModelAccessError, O as isRequiredTermsError, S as RequiredTermsError, T as isCreditLimitError, _ as ModelAccessError, b as RateLimitError, c as AuthUserNotFoundError, d as ConflictError, f as ContentFilterError, g as LimitExceededError, h as ForbiddenError, i as resolveBaseUrl, k as isValidationError, l as AuthUserRecordExistsError, m as DuplicateAuthUserError, p as CreditLimitError, r as assertBrowserSafe, s as AuthError, t as REOPT_BASE_URLS, u as BadRequestError, v as ModelNotFoundError, w as ValidationError, x as ReoptSDKError, y as NotFoundError } from "./config-aml9oQpX.js";
|
|
2
|
+
import { t as BaseHttpClient } from "./http-client-BZc2mngq.js";
|
|
3
|
+
import { n as createReoptAiClient } from "./client-BxtZt405.js";
|
|
4
|
+
import { n as createReoptAuthClient } from "./client-CAghoGD_.js";
|
|
5
|
+
import { t as createReoptCmsClient } from "./client-wEVKLdly.js";
|
|
6
|
+
import { t as createReoptEavClient } from "./client-61ldOHMz.js";
|
|
7
|
+
import { n as createReoptFeedbackClient } from "./client-zF1RG2uA.js";
|
|
8
|
+
import { n as createReoptFileClient } from "./client-BoIuyx4S.js";
|
|
9
|
+
import { n as createReoptPlansClient } from "./client-C_pHsPlj.js";
|
|
10
|
+
import { n as createReoptPushClient } from "./client-7PCoxVhZ.js";
|
|
11
|
+
import { n as createReoptTermsClient } from "./client-ByN3EQdk.js";
|
|
17
12
|
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
//#region src/singleton.ts
|
|
14
|
+
let _instance;
|
|
15
|
+
/**
|
|
16
|
+
* Create a lazy SDK instance that initializes on first property access.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```ts
|
|
20
|
+
* import { createLazySDK } from "@reopt-ai/brandapp-sdk";
|
|
21
|
+
* import schema from "./eav.schema";
|
|
22
|
+
*
|
|
23
|
+
* export const sdk = createLazySDK(() => ({
|
|
24
|
+
* clientId: process.env.BRANDAPP_CLIENT_ID!,
|
|
25
|
+
* clientSecret: process.env.BRANDAPP_CLIENT_SECRET!,
|
|
26
|
+
* brandappId: process.env.BRANDAPP_ID!,
|
|
27
|
+
* schema,
|
|
28
|
+
* }));
|
|
29
|
+
*
|
|
30
|
+
* // First property access triggers initialization
|
|
31
|
+
* await sdk.eav.entity("contacts").records.list();
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
20
34
|
function createLazySDK(configFactory) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
35
|
+
let instance;
|
|
36
|
+
function init() {
|
|
37
|
+
if (!instance) instance = createReoptSDK(configFactory());
|
|
38
|
+
return instance;
|
|
39
|
+
}
|
|
40
|
+
return new Proxy({}, {
|
|
41
|
+
get(_target, prop, receiver) {
|
|
42
|
+
return Reflect.get(init(), prop, receiver);
|
|
43
|
+
},
|
|
44
|
+
has(_target, prop) {
|
|
45
|
+
return Reflect.has(init(), prop);
|
|
46
|
+
},
|
|
47
|
+
ownKeys() {
|
|
48
|
+
return Reflect.ownKeys(init());
|
|
49
|
+
},
|
|
50
|
+
getOwnPropertyDescriptor(_target, prop) {
|
|
51
|
+
return Reflect.getOwnPropertyDescriptor(init(), prop);
|
|
52
|
+
}
|
|
53
|
+
});
|
|
40
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Initialize the global SDK singleton with explicit config.
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* import { initReoptSDK } from "@reopt-ai/brandapp-sdk";
|
|
61
|
+
*
|
|
62
|
+
* initReoptSDK({
|
|
63
|
+
* clientId: process.env.BRANDAPP_CLIENT_ID!,
|
|
64
|
+
* clientSecret: process.env.BRANDAPP_CLIENT_SECRET!,
|
|
65
|
+
* brandappId: process.env.BRANDAPP_ID!,
|
|
66
|
+
* });
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
41
69
|
function initReoptSDK(config) {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
70
|
+
const sdk = createReoptSDK(config);
|
|
71
|
+
_instance = sdk;
|
|
72
|
+
return sdk;
|
|
45
73
|
}
|
|
74
|
+
/**
|
|
75
|
+
* Get the global SDK singleton.
|
|
76
|
+
*
|
|
77
|
+
* Returns the instance set by `initReoptSDK()`, or auto-creates one
|
|
78
|
+
* from environment variables (`BRANDAPP_CLIENT_ID`, `BRANDAPP_CLIENT_SECRET`,
|
|
79
|
+
* `BRANDAPP_ID`).
|
|
80
|
+
*
|
|
81
|
+
* ⚠️ **Schema generic is not carried here.** A single module-global variable
|
|
82
|
+
* structurally cannot preserve a per-call schema type, so this always returns
|
|
83
|
+
* the default-schema `ReoptSDK` — `sdk.eav.entity(name)` falls back to untyped
|
|
84
|
+
* access (no autocomplete / `InferValues`). For type-safe EAV, prefer
|
|
85
|
+
* {@link createLazySDK} (or `createReoptSDK`) with your `schema`, which keeps
|
|
86
|
+
* the generic intact.
|
|
87
|
+
*
|
|
88
|
+
* @throws {Error} If no instance exists and env vars are missing
|
|
89
|
+
*/
|
|
46
90
|
function getReoptSDK() {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
91
|
+
if (_instance) return _instance;
|
|
92
|
+
const clientId = process.env.BRANDAPP_CLIENT_ID;
|
|
93
|
+
const clientSecret = process.env.BRANDAPP_CLIENT_SECRET;
|
|
94
|
+
const brandappId = process.env.BRANDAPP_ID;
|
|
95
|
+
if (clientId && clientSecret && brandappId) {
|
|
96
|
+
_instance = createReoptSDK({
|
|
97
|
+
clientId,
|
|
98
|
+
clientSecret,
|
|
99
|
+
brandappId
|
|
100
|
+
});
|
|
101
|
+
return _instance;
|
|
102
|
+
}
|
|
103
|
+
throw new Error("ReoptSDK: No instance available. Call initReoptSDK() first or set BRANDAPP_CLIENT_ID, BRANDAPP_CLIENT_SECRET, and BRANDAPP_ID env vars.");
|
|
58
104
|
}
|
|
105
|
+
/** Reset the global SDK singleton. Useful for testing. */
|
|
59
106
|
function resetSDK() {
|
|
60
|
-
|
|
107
|
+
_instance = void 0;
|
|
61
108
|
}
|
|
62
109
|
|
|
63
|
-
|
|
110
|
+
//#endregion
|
|
111
|
+
//#region src/index.ts
|
|
64
112
|
function createReoptSDK(config) {
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
113
|
+
assertBrowserSafe(config);
|
|
114
|
+
return {
|
|
115
|
+
config: {
|
|
116
|
+
brandappId: config.brandappId,
|
|
117
|
+
debug: config.debug ?? false
|
|
118
|
+
},
|
|
119
|
+
ai: createReoptAiClient(config),
|
|
120
|
+
auth: createReoptAuthClient(config),
|
|
121
|
+
cms: createReoptCmsClient(config),
|
|
122
|
+
eav: createReoptEavClient(config),
|
|
123
|
+
feedback: createReoptFeedbackClient(config),
|
|
124
|
+
files: createReoptFileClient(config),
|
|
125
|
+
plans: createReoptPlansClient(config),
|
|
126
|
+
push: createReoptPushClient(config),
|
|
127
|
+
terms: createReoptTermsClient(config)
|
|
128
|
+
};
|
|
81
129
|
}
|
|
82
130
|
|
|
83
|
-
|
|
84
|
-
|
|
131
|
+
//#endregion
|
|
132
|
+
export { AuthError, AuthUserNotFoundError, AuthUserRecordExistsError, BadRequestError, BaseHttpClient, ConflictError, ContentFilterError, CreditLimitError, DuplicateAuthUserError, ForbiddenError, LimitExceededError, ModelAccessError, ModelNotFoundError, NotFoundError, REOPT_BASE_URLS, RateLimitError, ReoptSDKError, RequiredTermsError, ServerError, ValidationError, createLazySDK, createReoptSDK, getReoptSDK, initReoptSDK, isCreditLimitError, isModelAccessError, isReoptSDKError, isRequiredTermsError, isValidationError, mapHttpStatusToError, resetSDK, resolveBaseUrl };
|
|
85
133
|
//# sourceMappingURL=index.js.map
|
package/dist/logout/index.d.ts
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { n as ReoptSDKConfig } from "../config-CRytOPPl.js";
|
|
2
|
+
//#region src/logout/verify.d.ts
|
|
3
3
|
type VerifyLogoutTokenOptions = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
4
|
+
/** 자기 OAuth client_id — logout_token `aud` 검증. 미지정 시 config/env에서 유도. */
|
|
5
|
+
clientId?: string;
|
|
6
|
+
/** id(IdP) 호스트 override. 미지정 시 resolveIdBaseUrl(config). */
|
|
7
|
+
idBaseUrl?: string;
|
|
8
|
+
/** SDK config (clientId·idBaseUrl 유도용). 개별 옵션이 우선. */
|
|
9
|
+
config?: ReoptSDKConfig;
|
|
10
|
+
/** iat 허용 나이(ms). 기본 5분. */
|
|
11
|
+
maxTokenAgeMs?: number;
|
|
12
12
|
};
|
|
13
13
|
type LogoutTokenClaims = {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
14
|
+
/** 폐기된 IdP 세션 ID — RP 세션 종료 키. */
|
|
15
|
+
sid: string;
|
|
16
|
+
/** 사용자 식별자(선택). */
|
|
17
|
+
sub?: string;
|
|
18
|
+
/** 검증된 issuer. */
|
|
19
|
+
iss: string;
|
|
20
|
+
/** 검증된 audience(들). */
|
|
21
|
+
aud: string[];
|
|
22
22
|
};
|
|
23
23
|
/**
|
|
24
24
|
* logout_token을 검증하고 폐기 대상 클레임(sid·sub)을 반환한다.
|
|
@@ -27,7 +27,8 @@ type LogoutTokenClaims = {
|
|
|
27
27
|
declare function verifyBackchannelLogoutToken(logoutToken: string, options?: VerifyLogoutTokenOptions): Promise<LogoutTokenClaims>;
|
|
28
28
|
/** 테스트·장수명 프로세스용 — JWKS/discovery 캐시와 refetch 스로틀 상태를 비운다. */
|
|
29
29
|
declare function clearLogoutTokenCaches(): void;
|
|
30
|
-
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src/logout/handler.d.ts
|
|
31
32
|
/**
|
|
32
33
|
* OIDC Back-Channel Logout 수신 핸들러 팩토리.
|
|
33
34
|
*
|
|
@@ -46,23 +47,24 @@ declare function clearLogoutTokenCaches(): void;
|
|
|
46
47
|
* });
|
|
47
48
|
*/
|
|
48
49
|
type BackchannelLogoutHandlerConfig = {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
50
|
+
/**
|
|
51
|
+
* 폐기 대상 통지 콜백. `sid`(reopt IdP 세션 ID)로 그 세션에서 파생된 RP
|
|
52
|
+
* 세션을 모두 종료한다. 발급 시 sid를 자기 세션에 저장해 두면 역참조가 쉽다.
|
|
53
|
+
* 예외를 던지면 501을 반환해 reopt가 재시도한다(멱등하게 구현할 것).
|
|
54
|
+
*/
|
|
55
|
+
onLogout: (event: LogoutTokenClaims) => Promise<void> | void;
|
|
56
|
+
/** 자기 client_id — 미지정 시 config/BRANDAPP_CLIENT_ID. */
|
|
57
|
+
clientId?: string;
|
|
58
|
+
/** id 호스트 override — 미지정 시 resolveIdBaseUrl(config). */
|
|
59
|
+
idBaseUrl?: string;
|
|
60
|
+
/** SDK config (clientId·idBaseUrl 유도용). */
|
|
61
|
+
config?: ReoptSDKConfig;
|
|
62
|
+
/** logout_token iat 허용 나이(ms). 기본 5분. */
|
|
63
|
+
maxTokenAgeMs?: number;
|
|
63
64
|
};
|
|
64
65
|
declare function createBackchannelLogoutHandler(config: BackchannelLogoutHandlerConfig): (request: Request) => Promise<Response>;
|
|
65
|
-
|
|
66
|
+
//#endregion
|
|
67
|
+
//#region src/logout/end-session.d.ts
|
|
66
68
|
/**
|
|
67
69
|
* RP-Initiated Logout — reopt의 `end_session_endpoint`로 보낼 URL을 조립한다.
|
|
68
70
|
*
|
|
@@ -82,25 +84,26 @@ declare function createBackchannelLogoutHandler(config: BackchannelLogoutHandler
|
|
|
82
84
|
* redirect(url); // 사용자를 reopt end-session으로 이동
|
|
83
85
|
*/
|
|
84
86
|
type BuildEndSessionUrlOptions = {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
87
|
+
/**
|
|
88
|
+
* `id_token_hint` — 로그인 시 받은 id_token. 어느 세션을 끝낼지 식별한다.
|
|
89
|
+
* 없으면 reopt가 어떤 세션인지 알 수 없어 로그아웃이 무의미하므로 필수.
|
|
90
|
+
*/
|
|
91
|
+
idToken: string;
|
|
92
|
+
/** 자기 client_id(선택 — id_token_hint의 aud와 대조에 쓰이며 미지정 가능). */
|
|
93
|
+
clientId?: string;
|
|
94
|
+
/**
|
|
95
|
+
* 로그아웃 후 복귀 URL. reopt OAuth 클라이언트의 `post_logout_redirect_uris`에
|
|
96
|
+
* 사전 등록된 값이어야 reopt가 redirect한다(미등록 시 종료만 하고 안 돌아옴).
|
|
97
|
+
*/
|
|
98
|
+
postLogoutRedirectUri?: string;
|
|
99
|
+
/** CSRF/상태 보존용 state — 복귀 URL에 그대로 실려 돌아온다. */
|
|
100
|
+
state?: string;
|
|
101
|
+
/** id 호스트 override — 미지정 시 resolveIdBaseUrl(config). */
|
|
102
|
+
idBaseUrl?: string;
|
|
103
|
+
/** SDK config (idBaseUrl 유도용). */
|
|
104
|
+
config?: ReoptSDKConfig;
|
|
103
105
|
};
|
|
104
106
|
declare function buildEndSessionUrl(options: BuildEndSessionUrlOptions): string;
|
|
105
|
-
|
|
107
|
+
//#endregion
|
|
106
108
|
export { type BackchannelLogoutHandlerConfig, type BuildEndSessionUrlOptions, type LogoutTokenClaims, type VerifyLogoutTokenOptions, buildEndSessionUrl, clearLogoutTokenCaches, createBackchannelLogoutHandler, verifyBackchannelLogoutToken };
|
|
109
|
+
//# sourceMappingURL=index.d.ts.map
|