@reopt-ai/brandapp-sdk 3.1.0 → 3.4.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 +147 -0
- package/README.md +39 -14
- package/dist/abort--nOBFN4M.js +50 -0
- package/dist/ai/index.d.ts +2 -314
- package/dist/ai/index.js +3 -7
- package/dist/ai-provider/index.d.ts +79 -163
- package/dist/ai-provider/index.js +752 -671
- package/dist/auth/index.d.ts +27 -27
- package/dist/auth/index.js +41 -33
- 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 -133
- package/dist/client-B1q5P8rv.js +83 -0
- package/dist/client-B9QHVhdM.js +77 -0
- package/dist/client-BGGd_cpV.d.ts +103 -0
- package/dist/client-BJcy1V1a.js +140 -0
- package/dist/client-Beivhucf.js +55 -0
- package/dist/client-BruP5_nU.d.ts +147 -0
- package/dist/client-D-yNxNfk.js +28 -0
- package/dist/client-D0eBxh8j.d.ts +284 -0
- package/dist/client-D3RHHUUW.d.ts +207 -0
- package/dist/client-D6gs61w8.d.ts +53 -0
- package/dist/client-DBnK7ooQ.js +86 -0
- package/dist/client-DDw5yz_h.d.ts +53 -0
- package/dist/client-DPmoKuR9.js +305 -0
- package/dist/client-DsdakibF.js +503 -0
- package/dist/client-Dxg8_DIH.d.ts +71 -0
- package/dist/client-EbhUIhHq.js +53 -0
- package/dist/client-lk6wBu_0.d.ts +48 -0
- package/dist/client-p49ol9pg.d.ts +124 -0
- package/dist/cms/index.d.ts +52 -108
- package/dist/cms/index.js +105 -84
- package/dist/config-CRytOPPl.d.ts +394 -0
- package/dist/config-Cw0a3-C8.js +487 -0
- package/dist/dev/index.d.ts +2 -509
- package/dist/dev/index.js +2740 -2873
- 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 -125
- 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-DIAS8Rsl.d.ts → errors-CRCcErNC.d.ts} +55 -53
- package/dist/feedback/index.d.ts +2 -132
- package/dist/feedback/index.js +3 -5
- package/dist/files/index.d.ts +14 -14
- package/dist/files/index.js +41 -24
- package/dist/http-client-QKUvvirs.js +386 -0
- package/dist/index-DrVaKfhs.d.ts +456 -0
- package/dist/index-Z6OGcurJ.d.ts +169 -0
- package/dist/index.d.ts +6 -221
- package/dist/index.js +119 -70
- package/dist/logout/index.d.ts +109 -0
- package/dist/logout/index.js +264 -0
- package/dist/plans/index.d.ts +2 -236
- package/dist/plans/index.js +3 -5
- package/dist/push/index.d.ts +2 -79
- package/dist/push/index.js +3 -5
- package/dist/query-BvbCiGWb.js +35 -0
- package/dist/react/hooks.d.ts +97 -95
- package/dist/react/hooks.js +742 -356
- package/dist/sse-parser-FMjxM7sY.js +86 -0
- package/dist/terms/index.d.ts +3 -79
- package/dist/terms/index.js +3 -5
- 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 -47
- package/dist/webhooks/index.js +150 -127
- package/docs/api-reference.md +179 -2
- package/docs/dev-server.md +19 -18
- package/docs/errors.md +72 -15
- package/docs/logout.md +166 -0
- package/package.json +10 -5
- package/dist/chunk-2Q654O63.js +0 -350
- package/dist/chunk-F7BXBTZI.js +0 -54
- package/dist/chunk-IJOXTBIE.js +0 -599
- package/dist/chunk-JWXUVQRC.js +0 -157
- package/dist/chunk-L4DHB36G.js +0 -75
- package/dist/chunk-MRQY45U5.js +0 -465
- package/dist/chunk-N5JVE4WX.js +0 -449
- package/dist/chunk-O3PUWIDJ.js +0 -105
- package/dist/chunk-POLKEOYH.js +0 -63
- package/dist/chunk-R5CCGDUH.js +0 -49
- package/dist/chunk-RBHP7IZF.js +0 -96
- package/dist/chunk-REIKXSMY.js +0 -7
- package/dist/chunk-T7YTITRJ.js +0 -112
- package/dist/chunk-V73GORO3.js +0 -81
- package/dist/chunk-VRNBYSWU.js +0 -32
- 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
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { q as ReoptSDKConfig } from './config-CtxyJsDR.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* User-scoped auth types.
|
|
5
|
-
*
|
|
6
|
-
* These describe the Bearer-authenticated endpoints exposed by Reopt for
|
|
7
|
-
* apps that have obtained an OAuth access token on behalf of an end user.
|
|
8
|
-
* App-scoped (Basic Auth) operations live under `eav/`, `ai/`, `files/`,
|
|
9
|
-
* `cms/` — they never need an access token.
|
|
10
|
-
*/
|
|
11
|
-
/**
|
|
12
|
-
* OIDC userinfo claims returned by `GET /api/auth/oauth2/userinfo`.
|
|
13
|
-
*
|
|
14
|
-
* Reopt always returns the core claims when the caller's token carries the
|
|
15
|
-
* matching scopes (`openid`, `profile`, `email`). Additional claims may
|
|
16
|
-
* appear when extra scopes are granted.
|
|
17
|
-
*/
|
|
18
|
-
type UserInfoClaims = {
|
|
19
|
-
sub: string;
|
|
20
|
-
email?: string;
|
|
21
|
-
email_verified?: boolean;
|
|
22
|
-
name?: string;
|
|
23
|
-
picture?: string;
|
|
24
|
-
given_name?: string;
|
|
25
|
-
family_name?: string;
|
|
26
|
-
[claim: string]: unknown;
|
|
27
|
-
};
|
|
28
|
-
/**
|
|
29
|
-
* Result of linking the current OAuth user to the Brandapp's customer table.
|
|
30
|
-
*
|
|
31
|
-
* The call is an idempotent upsert — the first invocation creates
|
|
32
|
-
* `Customer`, `BrandCustomer`, `BrandappCustomer`, and `CustomerExternalId`
|
|
33
|
-
* rows; subsequent calls refresh `authorizedAt` and flip `status` back to
|
|
34
|
-
* `active`.
|
|
35
|
-
*/
|
|
36
|
-
type LinkCurrentUserResult = {
|
|
37
|
-
customerId: string;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Brandapp Auth client — user-scoped (Bearer) endpoints.
|
|
42
|
-
*
|
|
43
|
-
* The rest of the SDK (`eav`, `ai`, `files`, `cms`) speaks to Reopt with the
|
|
44
|
-
* app's Client Credentials (Basic Auth) and therefore returns app-wide data.
|
|
45
|
-
* When a Brandapp wants to do something *on behalf of* a signed-in user
|
|
46
|
-
* (link that user to a Customer row, fetch their OIDC claims, …), it needs
|
|
47
|
-
* the user's OAuth access token instead.
|
|
48
|
-
*
|
|
49
|
-
* This client centralises those endpoints so consumers don't hardcode paths
|
|
50
|
-
* or repeat Bearer-auth boilerplate:
|
|
51
|
-
*
|
|
52
|
-
* - `linkCurrentUser(accessToken)` — POST /api/v1/brandapp/{id}/external-auth
|
|
53
|
-
* Idempotent upsert of Customer ↔ reoptUser link. First call creates
|
|
54
|
-
* `Customer`, `BrandCustomer`, `BrandappCustomer`, and
|
|
55
|
-
* `CustomerExternalId` rows; subsequent calls refresh `authorizedAt`.
|
|
56
|
-
* - `getUserInfo(accessToken)` — GET /api/auth/oauth2/userinfo
|
|
57
|
-
* Standard OIDC claims (sub / email / name / picture / …) scoped by
|
|
58
|
-
* the access token.
|
|
59
|
-
*
|
|
60
|
-
* Errors are mapped to the SDK's error hierarchy (`AuthError` on 401,
|
|
61
|
-
* `ForbiddenError` on 403, etc.) via the shared {@link BaseHttpClient}.
|
|
62
|
-
*
|
|
63
|
-
* @example
|
|
64
|
-
* ```ts
|
|
65
|
-
* const sdk = createReoptSDK({ clientId, clientSecret, brandappId });
|
|
66
|
-
*
|
|
67
|
-
* // Inside a server handler that has the user's OAuth access token:
|
|
68
|
-
* const { customerId } = await sdk.auth.linkCurrentUser(accessToken);
|
|
69
|
-
* const claims = await sdk.auth.getUserInfo(accessToken);
|
|
70
|
-
* ```
|
|
71
|
-
*/
|
|
72
|
-
|
|
73
|
-
declare class ReoptAuthClient {
|
|
74
|
-
/**
|
|
75
|
-
* Root client for `/api/auth/*` endpoints (OIDC userinfo, etc). Pinned to
|
|
76
|
-
* the id server because Better Auth's handler is only mounted there.
|
|
77
|
-
*/
|
|
78
|
-
private readonly rootHttp;
|
|
79
|
-
/** Brandapp-scoped client — prefixed for per-brandapp endpoints. */
|
|
80
|
-
private readonly brandappHttp;
|
|
81
|
-
constructor(config: ReoptSDKConfig);
|
|
82
|
-
/**
|
|
83
|
-
* Upsert the Customer ↔ reoptUser link for the OAuth user represented by
|
|
84
|
-
* the supplied access token.
|
|
85
|
-
*/
|
|
86
|
-
linkCurrentUser(accessToken: string): Promise<LinkCurrentUserResult>;
|
|
87
|
-
/**
|
|
88
|
-
* Soft-withdraw the current OAuth user from this Brandapp: BrandappCustomer
|
|
89
|
-
* flips to `churned`, the Brand↔Customer junction is removed, all
|
|
90
|
-
* terms-consents move to `withdrawn`, and any Stripe subscription is
|
|
91
|
-
* cancelled. The Customer record itself is retained so re-linking later
|
|
92
|
-
* restores the same customerId (see `linkCurrentUser`).
|
|
93
|
-
*/
|
|
94
|
-
withdrawCurrentUser(accessToken: string): Promise<LinkCurrentUserResult>;
|
|
95
|
-
/**
|
|
96
|
-
* Fetch the OIDC userinfo claims for the supplied access token.
|
|
97
|
-
*/
|
|
98
|
-
getUserInfo(accessToken: string): Promise<UserInfoClaims>;
|
|
99
|
-
}
|
|
100
|
-
declare function createReoptAuthClient(config: ReoptSDKConfig): ReoptAuthClient;
|
|
101
|
-
|
|
102
|
-
export { type LinkCurrentUserResult as L, ReoptAuthClient as R, type UserInfoClaims as U, createReoptAuthClient as c };
|
|
@@ -1,397 +0,0 @@
|
|
|
1
|
-
type EavDataType = "string" | "textarea" | "number" | "boolean" | "date" | "email" | "url" | "select" | "multiselect";
|
|
2
|
-
/**
|
|
3
|
-
* 외부 SDK가 다루는 EAV schema host 분기.
|
|
4
|
-
*
|
|
5
|
-
* - `brandapp` (default): brandapp-scoped 자유 테이블 (EavRecord N rows).
|
|
6
|
-
* - `brandappAuthUser`: BrandappAuthUser 1:1 메타. record id = authUserId,
|
|
7
|
-
* record write/update는 BrandappAuthUser.customData JSONB로 들어간다.
|
|
8
|
-
*
|
|
9
|
-
* `customer`/`post`는 workspace 운영자 전용이라 SDK 표면에서는 노출하지 않는다.
|
|
10
|
-
*/
|
|
11
|
-
type EavSchemaLinkedTo = "brandapp" | "brandappAuthUser";
|
|
12
|
-
type EavEntity = {
|
|
13
|
-
id: string;
|
|
14
|
-
brandappId: string;
|
|
15
|
-
name: string;
|
|
16
|
-
description: string | null;
|
|
17
|
-
icon: string | null;
|
|
18
|
-
/** Host 분기. 1.7.0 부터 응답에 포함 (이전 SDK는 무시 가능). */
|
|
19
|
-
linkedTo: EavSchemaLinkedTo;
|
|
20
|
-
createdAt: string;
|
|
21
|
-
updatedAt: string;
|
|
22
|
-
};
|
|
23
|
-
type CreateEntityInput = {
|
|
24
|
-
name: string;
|
|
25
|
-
description?: string;
|
|
26
|
-
icon?: string;
|
|
27
|
-
/** 호스트 분기. 생략 시 `'brandapp'` (자유 테이블). */
|
|
28
|
-
linkedTo?: EavSchemaLinkedTo;
|
|
29
|
-
};
|
|
30
|
-
type UpdateEntityInput = {
|
|
31
|
-
name?: string;
|
|
32
|
-
description?: string | null;
|
|
33
|
-
icon?: string | null;
|
|
34
|
-
};
|
|
35
|
-
type EavAttributeOption = {
|
|
36
|
-
value: string;
|
|
37
|
-
label: string;
|
|
38
|
-
color?: string;
|
|
39
|
-
};
|
|
40
|
-
type EavValidation = {
|
|
41
|
-
min?: number;
|
|
42
|
-
max?: number;
|
|
43
|
-
pattern?: string;
|
|
44
|
-
minLength?: number;
|
|
45
|
-
maxLength?: number;
|
|
46
|
-
customMessage?: string;
|
|
47
|
-
};
|
|
48
|
-
type EavAttribute = {
|
|
49
|
-
id: string;
|
|
50
|
-
entityId: string;
|
|
51
|
-
name: string;
|
|
52
|
-
label: string;
|
|
53
|
-
dataType: EavDataType;
|
|
54
|
-
isRequired: boolean;
|
|
55
|
-
isUnique: boolean;
|
|
56
|
-
defaultValue: string | null;
|
|
57
|
-
validation: EavValidation | null;
|
|
58
|
-
options: EavAttributeOption[] | null;
|
|
59
|
-
sortOrder: number;
|
|
60
|
-
createdAt: string;
|
|
61
|
-
updatedAt: string;
|
|
62
|
-
};
|
|
63
|
-
type CreateAttributeInput = {
|
|
64
|
-
name: string;
|
|
65
|
-
label: string;
|
|
66
|
-
dataType: EavDataType;
|
|
67
|
-
isRequired?: boolean;
|
|
68
|
-
isUnique?: boolean;
|
|
69
|
-
defaultValue?: string;
|
|
70
|
-
validation?: EavValidation;
|
|
71
|
-
options?: EavAttributeOption[];
|
|
72
|
-
sortOrder?: number;
|
|
73
|
-
};
|
|
74
|
-
type UpdateAttributeInput = {
|
|
75
|
-
name?: string;
|
|
76
|
-
label?: string;
|
|
77
|
-
dataType?: EavDataType;
|
|
78
|
-
isRequired?: boolean;
|
|
79
|
-
isUnique?: boolean;
|
|
80
|
-
defaultValue?: string | null;
|
|
81
|
-
validation?: EavValidation | null;
|
|
82
|
-
options?: EavAttributeOption[] | null;
|
|
83
|
-
sortOrder?: number;
|
|
84
|
-
};
|
|
85
|
-
type EavRecord = {
|
|
86
|
-
id: string;
|
|
87
|
-
entityId: string;
|
|
88
|
-
authUserId: string | null;
|
|
89
|
-
values: Record<string, unknown>;
|
|
90
|
-
createdAt: string;
|
|
91
|
-
updatedAt: string;
|
|
92
|
-
};
|
|
93
|
-
type CreateRecordInput = {
|
|
94
|
-
authUserId?: string;
|
|
95
|
-
values: Record<string, unknown>;
|
|
96
|
-
};
|
|
97
|
-
type UpdateRecordInput = {
|
|
98
|
-
values: Record<string, unknown>;
|
|
99
|
-
};
|
|
100
|
-
type BulkUpdateItem = {
|
|
101
|
-
id: string;
|
|
102
|
-
values: Record<string, unknown>;
|
|
103
|
-
};
|
|
104
|
-
type AttributeFilterOperator = "eq" | "neq" | "contains" | "gt" | "lt" | "gte" | "lte" | "is_null" | "is_not_null" | "after" | "before";
|
|
105
|
-
type AttributeFilter = {
|
|
106
|
-
attributeId: string;
|
|
107
|
-
operator: AttributeFilterOperator;
|
|
108
|
-
value?: unknown;
|
|
109
|
-
};
|
|
110
|
-
type PaginatedResponse<T> = {
|
|
111
|
-
records: T[];
|
|
112
|
-
total: number;
|
|
113
|
-
page: number;
|
|
114
|
-
limit: number;
|
|
115
|
-
totalPages: number;
|
|
116
|
-
};
|
|
117
|
-
type ListRecordsQuery = {
|
|
118
|
-
page?: number;
|
|
119
|
-
limit?: number;
|
|
120
|
-
authUserId?: string;
|
|
121
|
-
sortBy?: "createdAt" | "updatedAt" | (string & {});
|
|
122
|
-
sortOrder?: "asc" | "desc";
|
|
123
|
-
filters?: AttributeFilter[];
|
|
124
|
-
};
|
|
125
|
-
type CountRecordsQuery = {
|
|
126
|
-
authUserId?: string;
|
|
127
|
-
filters?: AttributeFilter[];
|
|
128
|
-
};
|
|
129
|
-
type UpsertRecordInput = {
|
|
130
|
-
authUserId?: string;
|
|
131
|
-
filters: AttributeFilter[];
|
|
132
|
-
values: Record<string, unknown>;
|
|
133
|
-
};
|
|
134
|
-
type UpsertRecordResult<T = EavRecord> = {
|
|
135
|
-
data: T;
|
|
136
|
-
created: boolean;
|
|
137
|
-
};
|
|
138
|
-
type DeleteWhereInput = {
|
|
139
|
-
authUserId?: string;
|
|
140
|
-
filters: AttributeFilter[];
|
|
141
|
-
};
|
|
142
|
-
/** Return value of the backfill transformer per record. */
|
|
143
|
-
type BackfillTransform = (record: EavRecord) => Record<string, unknown> | null | undefined;
|
|
144
|
-
type BackfillOptions = {
|
|
145
|
-
/** Filters applied to `records.list` while iterating. */
|
|
146
|
-
filters?: AttributeFilter[];
|
|
147
|
-
/** Restricts the iteration to a single user's records. */
|
|
148
|
-
authUserId?: string;
|
|
149
|
-
/** Sort order during iteration (default: `createdAt` ascending). */
|
|
150
|
-
sortBy?: ListRecordsQuery["sortBy"];
|
|
151
|
-
sortOrder?: ListRecordsQuery["sortOrder"];
|
|
152
|
-
/** Page size used while streaming (default: 100, server max). */
|
|
153
|
-
pageSize?: number;
|
|
154
|
-
/**
|
|
155
|
-
* Records per `bulkUpdate` flush (default: 100, server max; clamped to
|
|
156
|
-
* 1..100). Transformed values are buffered and written in batched
|
|
157
|
-
* transactions instead of one PATCH per record — for a large backfill this
|
|
158
|
-
* cuts the request count ~100×. If a batch transaction fails, the SDK falls
|
|
159
|
-
* back to per-record updates for that batch so `failed[]` stays accurate and
|
|
160
|
-
* the run never aborts. Set `1` to update one record per request.
|
|
161
|
-
*/
|
|
162
|
-
batchSize?: number;
|
|
163
|
-
/** Maximum concurrent batch flushes in flight (default: 5). */
|
|
164
|
-
concurrency?: number;
|
|
165
|
-
/** Transformer — return the new partial values, or `null`/`undefined` to skip. */
|
|
166
|
-
transform: BackfillTransform;
|
|
167
|
-
/** Called after every record is processed (success, skip, or fail). */
|
|
168
|
-
onProgress?: (event: BackfillProgressEvent) => void;
|
|
169
|
-
};
|
|
170
|
-
type BackfillProgressEvent = {
|
|
171
|
-
processed: number;
|
|
172
|
-
total: number;
|
|
173
|
-
updated: number;
|
|
174
|
-
skipped: number;
|
|
175
|
-
failed: number;
|
|
176
|
-
};
|
|
177
|
-
type BackfillFailure = {
|
|
178
|
-
recordId: string;
|
|
179
|
-
error: string;
|
|
180
|
-
};
|
|
181
|
-
type BackfillResult = {
|
|
182
|
-
total: number;
|
|
183
|
-
updated: number;
|
|
184
|
-
skipped: number;
|
|
185
|
-
failed: BackfillFailure[];
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
type AttributeDef = {
|
|
189
|
-
dataType: EavDataType;
|
|
190
|
-
label: string;
|
|
191
|
-
isRequired?: boolean;
|
|
192
|
-
isUnique?: boolean;
|
|
193
|
-
defaultValue?: string;
|
|
194
|
-
validation?: EavValidation;
|
|
195
|
-
options?: readonly EavAttributeOption[];
|
|
196
|
-
sortOrder?: number;
|
|
197
|
-
/**
|
|
198
|
-
* Stable server-side ID (UUID). When set, `computeDiff` matches by this
|
|
199
|
-
* ID before falling back to name / previousNames / lockfile heuristics.
|
|
200
|
-
* Once chosen, never change this value — that's the whole point.
|
|
201
|
-
*
|
|
202
|
-
* Equivalent to Prisma's `@id` annotation: pin the row identity in the
|
|
203
|
-
* schema itself so renames and external mutations cannot orphan it.
|
|
204
|
-
*
|
|
205
|
-
* @example
|
|
206
|
-
* attributes: {
|
|
207
|
-
* level: {
|
|
208
|
-
* id: "01HX3K8Q9YZABCDEF1234567",
|
|
209
|
-
* dataType: "string",
|
|
210
|
-
* label: "Level",
|
|
211
|
-
* }
|
|
212
|
-
* }
|
|
213
|
-
*/
|
|
214
|
-
id?: string;
|
|
215
|
-
/**
|
|
216
|
-
* Names this attribute used to have. When present, `computeDiff` matches
|
|
217
|
-
* a server attribute with one of these names and treats it as a rename
|
|
218
|
-
* (`update` action with a `name` change) instead of `delete + create`,
|
|
219
|
-
* preserving all existing record values.
|
|
220
|
-
*
|
|
221
|
-
* @example
|
|
222
|
-
* attributes: {
|
|
223
|
-
* level: {
|
|
224
|
-
* dataType: "string",
|
|
225
|
-
* label: "Level",
|
|
226
|
-
* previousNames: ["tier"], // server still has "tier" — auto-renamed
|
|
227
|
-
* }
|
|
228
|
-
* }
|
|
229
|
-
*/
|
|
230
|
-
previousNames?: readonly string[];
|
|
231
|
-
};
|
|
232
|
-
type EntityDef<A extends Record<string, AttributeDef> = Record<string, AttributeDef>> = {
|
|
233
|
-
name: string;
|
|
234
|
-
description?: string;
|
|
235
|
-
icon?: string;
|
|
236
|
-
attributes: A;
|
|
237
|
-
};
|
|
238
|
-
type SchemaDef<E extends Record<string, EntityDef> = Record<string, EntityDef>> = {
|
|
239
|
-
entities: E;
|
|
240
|
-
};
|
|
241
|
-
type InferDataType<D extends EavDataType, O> = D extends "number" ? number : D extends "boolean" ? boolean : D extends "select" ? O extends readonly {
|
|
242
|
-
value: infer V;
|
|
243
|
-
}[] ? V : string : D extends "multiselect" ? O extends readonly {
|
|
244
|
-
value: infer V;
|
|
245
|
-
}[] ? V[] : string[] : string;
|
|
246
|
-
type RequiredKeys<A extends Record<string, AttributeDef>> = {
|
|
247
|
-
[K in keyof A]: A[K] extends {
|
|
248
|
-
isRequired: true;
|
|
249
|
-
} ? K : never;
|
|
250
|
-
}[keyof A];
|
|
251
|
-
type OptionalKeys<A extends Record<string, AttributeDef>> = {
|
|
252
|
-
[K in keyof A]: A[K] extends {
|
|
253
|
-
isRequired: true;
|
|
254
|
-
} ? never : K;
|
|
255
|
-
}[keyof A];
|
|
256
|
-
type InferValues<E extends EntityDef> = {
|
|
257
|
-
[K in RequiredKeys<E["attributes"]>]: InferDataType<E["attributes"][K]["dataType"], E["attributes"][K] extends {
|
|
258
|
-
options: infer O;
|
|
259
|
-
} ? O : never>;
|
|
260
|
-
} & {
|
|
261
|
-
[K in OptionalKeys<E["attributes"]>]?: InferDataType<E["attributes"][K]["dataType"], E["attributes"][K] extends {
|
|
262
|
-
options: infer O;
|
|
263
|
-
} ? O : never>;
|
|
264
|
-
};
|
|
265
|
-
|
|
266
|
-
/**
|
|
267
|
-
* Three-level debug logger.
|
|
268
|
-
*
|
|
269
|
-
* - "off" — silent (default)
|
|
270
|
-
* - "info" — request/response/retry/error one-liners
|
|
271
|
-
* - "trace" — everything in "info" plus request body, response status,
|
|
272
|
-
* response body, and request id
|
|
273
|
-
*
|
|
274
|
-
* Backwards compatible: `debug: true` maps to "info", `debug: false` to "off".
|
|
275
|
-
*
|
|
276
|
-
* Auto-detection:
|
|
277
|
-
* - BRANDAPP_SDK_DEBUG=trace → trace
|
|
278
|
-
* - BRANDAPP_SDK_DEBUG=info | "1" → info
|
|
279
|
-
* - DEBUG=*brandapp* → info
|
|
280
|
-
*
|
|
281
|
-
* Set BRANDAPP_SDK_LOG_FORMAT=json for machine-readable logs (AI agent consumers).
|
|
282
|
-
*/
|
|
283
|
-
type DebugLevel = "off" | "info" | "trace";
|
|
284
|
-
type DebugLogger = {
|
|
285
|
-
level: DebugLevel;
|
|
286
|
-
request(method: string, url: string, requestId: string, body?: unknown): void;
|
|
287
|
-
response(method: string, url: string, status: number, durationMs: number, requestId: string, body?: unknown): void;
|
|
288
|
-
retry(method: string, url: string, attempt: number, reason: string): void;
|
|
289
|
-
error(method: string, url: string, error: string, requestId: string): void;
|
|
290
|
-
};
|
|
291
|
-
|
|
292
|
-
/**
|
|
293
|
-
* Default API host for EAV / AI / Files / CMS / Terms. Consumers can override
|
|
294
|
-
* via `config.baseUrl` or the `REOPT_BASE_URL` env var.
|
|
295
|
-
*
|
|
296
|
-
* The canonical production host is `brandapp.reopt.ai` (the brandapp data API —
|
|
297
|
-
* distinct from `{alias}.reopt.ai` brandfront sites). The legacy `brand.reopt.ai`
|
|
298
|
-
* host stays served indefinitely as a backward-compat alias, so SDK builds
|
|
299
|
-
* published before this change keep working. ⚠️ Flip takes effect only on
|
|
300
|
-
* re-publish — republish after `brandapp.reopt.ai` is live on Vercel.
|
|
301
|
-
* (dev host stays `brand.reopt.de:3443` — bound to the local hosts file + cert.)
|
|
302
|
-
*/
|
|
303
|
-
declare const REOPT_BASE_URLS: {
|
|
304
|
-
readonly production: "https://brandapp.reopt.ai";
|
|
305
|
-
readonly development: "https://brand.reopt.de:3443";
|
|
306
|
-
};
|
|
307
|
-
type ReoptSDKConfig<S extends SchemaDef = SchemaDef> = {
|
|
308
|
-
/**
|
|
309
|
-
* OAuth Client ID. Required for Basic Auth (client credentials). **Optional**
|
|
310
|
-
* when a short-lived `token` is supplied instead — that's the secure
|
|
311
|
-
* client-side pattern (see {@link assertBrowserSafe}).
|
|
312
|
-
*/
|
|
313
|
-
clientId?: string;
|
|
314
|
-
/**
|
|
315
|
-
* OAuth Client Secret — a long-lived admin credential (`scope=['*']`, can mint
|
|
316
|
-
* tokens). **Never expose it to the browser.** Required for Basic Auth;
|
|
317
|
-
* **optional** when `token` is supplied. {@link assertBrowserSafe} throws if it
|
|
318
|
-
* is present in a browser context.
|
|
319
|
-
*/
|
|
320
|
-
clientSecret?: string;
|
|
321
|
-
/** Brandapp ID (v1 API path에 사용) */
|
|
322
|
-
brandappId: string;
|
|
323
|
-
/**
|
|
324
|
-
* Short-lived service token (Phase D-2b, RFC-0006). When set, every
|
|
325
|
-
* outbound request uses `Authorization: Bearer <token>` instead of the
|
|
326
|
-
* Basic Auth header derived from clientId/clientSecret.
|
|
327
|
-
*
|
|
328
|
-
* The Basic credentials remain required by `validateConfig` — they
|
|
329
|
-
* stay around in case the caller wants to fall back (e.g. mint a fresh
|
|
330
|
-
* token after expiry, or hit `/token/mint` itself). Per-call overrides
|
|
331
|
-
* via `FetchOptions.bearerToken` still take precedence.
|
|
332
|
-
*/
|
|
333
|
-
token?: string;
|
|
334
|
-
/**
|
|
335
|
-
* true: production (https://brandapp.reopt.ai)
|
|
336
|
-
* false: development (https://brand.reopt.de:3443)
|
|
337
|
-
* undefined (default): auto-detect from `NODE_ENV === "production"`
|
|
338
|
-
*/
|
|
339
|
-
isProduction?: boolean;
|
|
340
|
-
/**
|
|
341
|
-
* Custom base URL — overrides `REOPT_BASE_URL` env, `isProduction`, and the
|
|
342
|
-
* NODE_ENV default. Use this when you need different URLs per SDK instance
|
|
343
|
-
* in the same process. For single-process apps, prefer the `REOPT_BASE_URL`
|
|
344
|
-
* env var (no need to thread `baseUrl` through every call site).
|
|
345
|
-
*/
|
|
346
|
-
baseUrl?: string;
|
|
347
|
-
/**
|
|
348
|
-
* Custom id (auth) base URL — overrides `REOPT_ID_BASE_URL` env and the URL
|
|
349
|
-
* derived from `baseUrl` / `REOPT_BASE_URL` / `isProduction`. Set this when
|
|
350
|
-
* the Better Auth handler is hosted at a non-standard origin (custom dev
|
|
351
|
-
* cluster, on-prem deploy, etc.). For standard reopt.{ai,io,de} hosts you
|
|
352
|
-
* can omit both this and the env var — it's auto-derived from the API host.
|
|
353
|
-
*/
|
|
354
|
-
idBaseUrl?: string;
|
|
355
|
-
/** Request timeout (ms), default: 15000 (AI/Files clients default to 30000) */
|
|
356
|
-
timeout?: number;
|
|
357
|
-
/**
|
|
358
|
-
* Max **total** attempts per request, including the first — *not* the number
|
|
359
|
-
* of retries. Default 3 means 1 initial call + up to 2 retries. `1` disables
|
|
360
|
-
* retries entirely.
|
|
361
|
-
*/
|
|
362
|
-
maxRetries?: number;
|
|
363
|
-
/**
|
|
364
|
-
* Opt in to retrying non-idempotent requests (POST/PATCH) on 5xx / network /
|
|
365
|
-
* timeout failures. Off by default: a mutating request that the server may
|
|
366
|
-
* have already committed (record create, AI credit charge, terms consent) is
|
|
367
|
-
* **not** retried, to avoid duplicate side effects. 429 (rate-limited, never
|
|
368
|
-
* processed) is always retried regardless of this flag. When enabled, mutating
|
|
369
|
-
* requests still carry an `Idempotency-Key` (the request id) so a server that
|
|
370
|
-
* supports it can de-duplicate retries.
|
|
371
|
-
*/
|
|
372
|
-
retryNonIdempotent?: boolean;
|
|
373
|
-
/** EAV schema for type-safe entity() client */
|
|
374
|
-
schema?: S;
|
|
375
|
-
/**
|
|
376
|
-
* Debug logging level.
|
|
377
|
-
* - `false` / `"off"` (default): silent
|
|
378
|
-
* - `true` / `"info"`: one-line per request, response, retry, error
|
|
379
|
-
* - `"trace"`: also dumps redacted request/response bodies + request ids
|
|
380
|
-
*
|
|
381
|
-
* Auto-detected from `BRANDAPP_SDK_DEBUG=trace|info|1` or `DEBUG=*brandapp*`.
|
|
382
|
-
* Set `BRANDAPP_SDK_LOG_FORMAT=json` for machine-readable structured logs.
|
|
383
|
-
*/
|
|
384
|
-
debug?: boolean | DebugLevel;
|
|
385
|
-
};
|
|
386
|
-
/**
|
|
387
|
-
* Resolve the main API base URL for the given SDK config. Priority:
|
|
388
|
-
*
|
|
389
|
-
* 1. `config.baseUrl` — explicit override
|
|
390
|
-
* 2. `REOPT_BASE_URL` env var — set this once and skip threading
|
|
391
|
-
* `baseUrl` through every `createReoptSDK()` call
|
|
392
|
-
* 3. default by `isProduction` / `NODE_ENV` (production →
|
|
393
|
-
* `brandapp.reopt.ai`, otherwise → `brand.reopt.de:3443`)
|
|
394
|
-
*/
|
|
395
|
-
declare function resolveBaseUrl(config: ReoptSDKConfig): string;
|
|
396
|
-
|
|
397
|
-
export { type AttributeDef as A, type BackfillOptions as B, type CountRecordsQuery as C, type DebugLevel as D, type EavAttribute as E, type InferValues as I, type ListRecordsQuery as L, type PaginatedResponse as P, REOPT_BASE_URLS as R, type SchemaDef as S, type UpdateAttributeInput as U, type AttributeFilter as a, type AttributeFilterOperator as b, type BackfillResult as c, type BulkUpdateItem as d, type CreateAttributeInput as e, type CreateEntityInput as f, type CreateRecordInput as g, type DebugLogger as h, type DeleteWhereInput as i, type EavAttributeOption as j, type EavDataType as k, type EavEntity as l, type EavRecord as m, type EavSchemaLinkedTo as n, type EavValidation as o, type EntityDef as p, type ReoptSDKConfig as q, type UpdateEntityInput as r, type UpdateRecordInput as s, type UpsertRecordInput as t, type UpsertRecordResult as u, resolveBaseUrl as v };
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { p as EntityDef, L as ListRecordsQuery, P as PaginatedResponse, m as EavRecord, I as InferValues, a as AttributeFilter, u as UpsertRecordResult, C as CountRecordsQuery, d as BulkUpdateItem, i as DeleteWhereInput, B as BackfillOptions, c as BackfillResult } from './config-CtxyJsDR.js';
|
|
2
|
-
|
|
3
|
-
/** EavRecord with typed values instead of Record<string, unknown> */
|
|
4
|
-
type TypedEavRecord<V> = Omit<EavRecord, "values"> & {
|
|
5
|
-
values: V;
|
|
6
|
-
};
|
|
7
|
-
/** Entity-scoped client with typed records API */
|
|
8
|
-
type EntityClient<E extends EntityDef> = {
|
|
9
|
-
readonly entityName: string;
|
|
10
|
-
records: {
|
|
11
|
-
list(query?: ListRecordsQuery): Promise<PaginatedResponse<TypedEavRecord<InferValues<E>>>>;
|
|
12
|
-
findOne(query?: Omit<ListRecordsQuery, "page">): Promise<TypedEavRecord<InferValues<E>> | null>;
|
|
13
|
-
create(input: {
|
|
14
|
-
authUserId?: string;
|
|
15
|
-
values: InferValues<E>;
|
|
16
|
-
}): Promise<TypedEavRecord<InferValues<E>>>;
|
|
17
|
-
upsert(input: {
|
|
18
|
-
authUserId?: string;
|
|
19
|
-
filters: AttributeFilter[];
|
|
20
|
-
values: InferValues<E>;
|
|
21
|
-
}): Promise<UpsertRecordResult<TypedEavRecord<InferValues<E>>>>;
|
|
22
|
-
get(recordId: string): Promise<TypedEavRecord<InferValues<E>>>;
|
|
23
|
-
update(recordId: string, input: {
|
|
24
|
-
values: Partial<InferValues<E>>;
|
|
25
|
-
}): Promise<TypedEavRecord<InferValues<E>>>;
|
|
26
|
-
delete(recordId: string): Promise<void>;
|
|
27
|
-
count(query?: CountRecordsQuery): Promise<number>;
|
|
28
|
-
bulkCreate(records: Array<{
|
|
29
|
-
authUserId?: string;
|
|
30
|
-
values: InferValues<E>;
|
|
31
|
-
}>): Promise<TypedEavRecord<InferValues<E>>[]>;
|
|
32
|
-
bulkDelete(ids: string[]): Promise<number>;
|
|
33
|
-
bulkUpdate(updates: BulkUpdateItem[]): Promise<TypedEavRecord<InferValues<E>>[]>;
|
|
34
|
-
deleteWhere(input: DeleteWhereInput): Promise<number>;
|
|
35
|
-
listAll(query?: Omit<ListRecordsQuery, "page">): AsyncGenerator<TypedEavRecord<InferValues<E>>>;
|
|
36
|
-
backfill(opts: BackfillOptions): Promise<BackfillResult>;
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export type { EntityClient as E, TypedEavRecord as T };
|
package/dist/types-6E3ZLL9X.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
declare const REOPT_PROVIDER_ID: "reopt";
|
|
2
|
-
declare const REOPT_DEFAULT_SCOPES: readonly ["openid", "profile", "email"];
|
|
3
|
-
type AdapterOperation = "create" | "findOne" | "findMany" | "update" | "updateMany" | "delete" | "deleteMany" | "count";
|
|
4
|
-
type AdapterRequestBody = {
|
|
5
|
-
operation: AdapterOperation;
|
|
6
|
-
model: "user" | "session" | "account" | "verification";
|
|
7
|
-
data?: Record<string, unknown>;
|
|
8
|
-
where?: Array<{
|
|
9
|
-
field: string;
|
|
10
|
-
value: unknown;
|
|
11
|
-
operator?: string;
|
|
12
|
-
connector?: "AND" | "OR";
|
|
13
|
-
}>;
|
|
14
|
-
update?: Record<string, unknown>;
|
|
15
|
-
select?: string[];
|
|
16
|
-
limit?: number;
|
|
17
|
-
offset?: number;
|
|
18
|
-
sortBy?: {
|
|
19
|
-
field: string;
|
|
20
|
-
direction: "asc" | "desc";
|
|
21
|
-
};
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export { type AdapterOperation as A, REOPT_DEFAULT_SCOPES as R, type AdapterRequestBody as a, REOPT_PROVIDER_ID as b };
|
package/dist/types-DskYLVb8.d.ts
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { E as EditorSpec } from './types-ckmDDW3N.js';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Brandapp Terms types.
|
|
5
|
-
*
|
|
6
|
-
* Mirrors the response shape of `/api/v1/brandapp/{brandappId}/terms/*`.
|
|
7
|
-
*/
|
|
8
|
-
type TermsType = "termsOfService" | "privacyPolicy" | "marketingConsent" | "custom";
|
|
9
|
-
/** Mirrors the Prisma `BrandappTermsJurisdiction` enum. */
|
|
10
|
-
type TermsJurisdiction = "global" | "KR" | "US" | "EU" | "GB" | "JP" | "CN" | "BR" | "CA" | "AU";
|
|
11
|
-
type TermsVersion = {
|
|
12
|
-
id: string;
|
|
13
|
-
version: number;
|
|
14
|
-
/** 본문 언어 (BCP 47, "ko-KR", "en-US"). */
|
|
15
|
-
locale: string;
|
|
16
|
-
/** Plain-text 본문 — 검색/법적 보존용. */
|
|
17
|
-
content: string;
|
|
18
|
-
/**
|
|
19
|
-
* Rich 본문 — opt-editor `EditorSpec`과 호환되는 minimal shape.
|
|
20
|
-
* 마이그레이션 이전에 작성된 약관은 plain text가 paragraph 1개로 자동 wrap되어 들어있다.
|
|
21
|
-
* `null`은 백엔드 응답에 contentRich 필드가 빠진 구버전 호환을 위해 허용.
|
|
22
|
-
*/
|
|
23
|
-
contentRich: EditorSpec | null;
|
|
24
|
-
publishedAt: string;
|
|
25
|
-
changeSummary: string | null;
|
|
26
|
-
reConsentDeadline: string | null;
|
|
27
|
-
};
|
|
28
|
-
type TermsItem = {
|
|
29
|
-
id: string;
|
|
30
|
-
title: string;
|
|
31
|
-
type: TermsType;
|
|
32
|
-
/** 법적 관할권 */
|
|
33
|
-
jurisdiction: TermsJurisdiction;
|
|
34
|
-
isRequired: boolean;
|
|
35
|
-
sortOrder: number;
|
|
36
|
-
/** Null when no matching version exists for the requested locale. */
|
|
37
|
-
currentVersion: TermsVersion | null;
|
|
38
|
-
};
|
|
39
|
-
/** Wrapper response with jurisdiction/locale matching metadata. */
|
|
40
|
-
type TermsListResponse = {
|
|
41
|
-
/** 매칭된 jurisdiction (사용자가 받은 약관 셋의 법적 관할권) */
|
|
42
|
-
jurisdiction: TermsJurisdiction;
|
|
43
|
-
/** 매칭 결정 출처 — geo / user_locale / accept_language / explicit / brandapp_default */
|
|
44
|
-
jurisdictionSource: string;
|
|
45
|
-
/** 매칭에 사용된 country (ISO 3166-1 alpha-2). null이면 brandapp default만 사용. */
|
|
46
|
-
country: string | null;
|
|
47
|
-
/** 매칭에 사용된 locale (BCP 47). */
|
|
48
|
-
locale: string | null;
|
|
49
|
-
/** 매칭된 약관 목록 */
|
|
50
|
-
terms: TermsItem[];
|
|
51
|
-
};
|
|
52
|
-
type ConsentStatus = "granted" | "withdrawn" | "pendingReConsent";
|
|
53
|
-
type ConsentRecord = {
|
|
54
|
-
id: string;
|
|
55
|
-
status: ConsentStatus;
|
|
56
|
-
consentedAt: string;
|
|
57
|
-
withdrawnAt: string | null;
|
|
58
|
-
source: string | null;
|
|
59
|
-
versionId: string;
|
|
60
|
-
termsId: string;
|
|
61
|
-
/** 동의 시점의 국가 (법적 증거) */
|
|
62
|
-
consentCountry: string | null;
|
|
63
|
-
/** 동의 시점의 locale (법적 증거) */
|
|
64
|
-
consentLocale: string | null;
|
|
65
|
-
};
|
|
66
|
-
type ConsentInput = {
|
|
67
|
-
versionId: string;
|
|
68
|
-
consented: boolean;
|
|
69
|
-
};
|
|
70
|
-
type CreateConsentsRequest = {
|
|
71
|
-
consents: ConsentInput[];
|
|
72
|
-
/** Origin tag stored alongside each consent (e.g. "web", "mobile-app"). Defaults to "sdk". */
|
|
73
|
-
source?: string;
|
|
74
|
-
/** Optional caller IP, kept for legal evidence. Server falls back to undefined when omitted. */
|
|
75
|
-
ipAddress?: string;
|
|
76
|
-
/** 동의 시점의 사용자 국가 (ISO 3166-1 alpha-2). 미제공 시 서버가 헤더에서 추정. */
|
|
77
|
-
country?: string;
|
|
78
|
-
/** 동의 시점에 사용자가 본 locale (BCP 47). 미제공 시 서버가 헤더에서 추정. */
|
|
79
|
-
locale?: string;
|
|
80
|
-
/** User-Agent. 미제공 시 서버가 요청 헤더에서 추정. */
|
|
81
|
-
userAgent?: string;
|
|
82
|
-
};
|
|
83
|
-
type CreateConsentsResult = {
|
|
84
|
-
count: number;
|
|
85
|
-
};
|
|
86
|
-
type WithdrawConsentResult = {
|
|
87
|
-
id: string;
|
|
88
|
-
};
|
|
89
|
-
/**
|
|
90
|
-
* `list()` 호출 옵션. country/locale을 지정하면 백엔드가 매칭 약관 셋을 반환한다.
|
|
91
|
-
* 미지정 시 백엔드가 요청 헤더 (`x-vercel-ip-country`, `Accept-Language`)에서 추정한다.
|
|
92
|
-
*/
|
|
93
|
-
type ListTermsOptions = {
|
|
94
|
-
/** ISO 3166-1 alpha-2 ("KR", "DE", "US"). */
|
|
95
|
-
country?: string;
|
|
96
|
-
/** BCP 47 ("ko-KR", "en-US"). */
|
|
97
|
-
locale?: string;
|
|
98
|
-
/** Explicit jurisdiction override. */
|
|
99
|
-
jurisdiction?: TermsJurisdiction;
|
|
100
|
-
/** Bearer token. 없으면 Basic Auth. */
|
|
101
|
-
accessToken?: string;
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
export type { ConsentInput as C, ListTermsOptions as L, TermsItem as T, WithdrawConsentResult as W, ConsentRecord as a, ConsentStatus as b, CreateConsentsRequest as c, CreateConsentsResult as d, TermsJurisdiction as e, TermsListResponse as f, TermsType as g, TermsVersion as h };
|