@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
package/dist/chunk-RBHP7IZF.js
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { BaseHttpClient } from './chunk-N5JVE4WX.js';
|
|
2
|
-
|
|
3
|
-
// src/feedback/client.ts
|
|
4
|
-
function buildListQuery(query) {
|
|
5
|
-
const params = new URLSearchParams();
|
|
6
|
-
if (query.status) params.set("status", query.status);
|
|
7
|
-
if (query.customerId) params.set("customerId", query.customerId);
|
|
8
|
-
if (query.page != null) params.set("page", String(query.page));
|
|
9
|
-
if (query.limit != null) params.set("limit", String(query.limit));
|
|
10
|
-
const qs = params.toString();
|
|
11
|
-
return qs ? `?${qs}` : "";
|
|
12
|
-
}
|
|
13
|
-
var ReoptFeedbackClient = class {
|
|
14
|
-
http;
|
|
15
|
-
constructor(config) {
|
|
16
|
-
this.http = new BaseHttpClient(
|
|
17
|
-
config,
|
|
18
|
-
`/api/v1/brandapp/${config.brandappId}/feedback`
|
|
19
|
-
);
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Create a feedback with app credentials (server-to-server collection).
|
|
23
|
-
* Pass `customerId` to attribute it to a customer linked to this brandapp.
|
|
24
|
-
*/
|
|
25
|
-
async create(input) {
|
|
26
|
-
const body = await this.http.fetch(
|
|
27
|
-
"POST",
|
|
28
|
-
"",
|
|
29
|
-
input
|
|
30
|
-
);
|
|
31
|
-
return body.data;
|
|
32
|
-
}
|
|
33
|
-
/** List feedback this brandapp collected (app credentials). */
|
|
34
|
-
async list(query = {}) {
|
|
35
|
-
const body = await this.http.fetch(
|
|
36
|
-
"GET",
|
|
37
|
-
buildListQuery(query)
|
|
38
|
-
);
|
|
39
|
-
return { feedbacks: body.data, meta: body.meta };
|
|
40
|
-
}
|
|
41
|
-
/** Fetch one feedback with its reply thread (app credentials). */
|
|
42
|
-
async get(feedbackId) {
|
|
43
|
-
const body = await this.http.fetch(
|
|
44
|
-
"GET",
|
|
45
|
-
`/${encodeURIComponent(feedbackId)}`
|
|
46
|
-
);
|
|
47
|
-
return body.data;
|
|
48
|
-
}
|
|
49
|
-
/** End-user surface — requires the signed-in user's OAuth access token. */
|
|
50
|
-
me = {
|
|
51
|
-
/**
|
|
52
|
-
* Create a feedback as the signed-in user. The server resolves the
|
|
53
|
-
* token's linked customer; unlinked users get 403 `LINK_REQUIRED`
|
|
54
|
-
* (call `sdk.auth.linkCurrentUser` first).
|
|
55
|
-
*/
|
|
56
|
-
create: async (input, accessToken) => {
|
|
57
|
-
const body = await this.http.fetch(
|
|
58
|
-
"POST",
|
|
59
|
-
"/me",
|
|
60
|
-
input,
|
|
61
|
-
{ bearerToken: accessToken }
|
|
62
|
-
);
|
|
63
|
-
return body.data;
|
|
64
|
-
},
|
|
65
|
-
/**
|
|
66
|
-
* List the signed-in user's own feedback (all collection sources —
|
|
67
|
-
* brand form submissions included).
|
|
68
|
-
*/
|
|
69
|
-
list: async (accessToken, query = {}) => {
|
|
70
|
-
const body = await this.http.fetch(
|
|
71
|
-
"GET",
|
|
72
|
-
`/me${buildListQuery(query)}`,
|
|
73
|
-
void 0,
|
|
74
|
-
{ bearerToken: accessToken }
|
|
75
|
-
);
|
|
76
|
-
return { feedbacks: body.data, meta: body.meta };
|
|
77
|
-
},
|
|
78
|
-
/** Fetch one of the signed-in user's feedback with staff replies. */
|
|
79
|
-
get: async (feedbackId, accessToken) => {
|
|
80
|
-
const body = await this.http.fetch(
|
|
81
|
-
"GET",
|
|
82
|
-
`/me/${encodeURIComponent(feedbackId)}`,
|
|
83
|
-
void 0,
|
|
84
|
-
{ bearerToken: accessToken }
|
|
85
|
-
);
|
|
86
|
-
return body.data;
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
};
|
|
90
|
-
function createReoptFeedbackClient(config) {
|
|
91
|
-
return new ReoptFeedbackClient(config);
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
export { ReoptFeedbackClient, createReoptFeedbackClient };
|
|
95
|
-
//# sourceMappingURL=chunk-RBHP7IZF.js.map
|
|
96
|
-
//# sourceMappingURL=chunk-RBHP7IZF.js.map
|
package/dist/chunk-REIKXSMY.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
// src/better-auth/types.ts
|
|
2
|
-
var REOPT_PROVIDER_ID = "reopt";
|
|
3
|
-
var REOPT_DEFAULT_SCOPES = ["openid", "profile", "email"];
|
|
4
|
-
|
|
5
|
-
export { REOPT_DEFAULT_SCOPES, REOPT_PROVIDER_ID };
|
|
6
|
-
//# sourceMappingURL=chunk-REIKXSMY.js.map
|
|
7
|
-
//# sourceMappingURL=chunk-REIKXSMY.js.map
|
package/dist/chunk-T7YTITRJ.js
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { BaseHttpClient } from './chunk-N5JVE4WX.js';
|
|
2
|
-
|
|
3
|
-
// src/terms/client.ts
|
|
4
|
-
function unwrap(body) {
|
|
5
|
-
if (body && typeof body === "object" && "data" in body) {
|
|
6
|
-
const withData = body;
|
|
7
|
-
if (withData.data !== void 0) return withData.data;
|
|
8
|
-
}
|
|
9
|
-
return body;
|
|
10
|
-
}
|
|
11
|
-
function isListOptions(value) {
|
|
12
|
-
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
13
|
-
}
|
|
14
|
-
function buildListQuery(options) {
|
|
15
|
-
const params = new URLSearchParams();
|
|
16
|
-
if (options.country) params.set("country", options.country);
|
|
17
|
-
if (options.locale) params.set("locale", options.locale);
|
|
18
|
-
if (options.jurisdiction) params.set("jurisdiction", options.jurisdiction);
|
|
19
|
-
const qs = params.toString();
|
|
20
|
-
return qs ? `?${qs}` : "";
|
|
21
|
-
}
|
|
22
|
-
var ReoptTermsClient = class {
|
|
23
|
-
http;
|
|
24
|
-
constructor(config) {
|
|
25
|
-
this.http = new BaseHttpClient(
|
|
26
|
-
config,
|
|
27
|
-
`/api/v1/brandapp/${config.brandappId}/terms`
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* List active terms for this Brandapp with their currently-published
|
|
32
|
-
* version. Works with either Basic Auth (default) or Bearer Auth — when
|
|
33
|
-
* called from a server handler that has the user's access token, pass
|
|
34
|
-
* `accessToken` to avoid sending app credentials.
|
|
35
|
-
*
|
|
36
|
-
* Accepts either an `accessToken` string (legacy) or an options object
|
|
37
|
-
* (`country`/`locale`/`jurisdiction`/`accessToken`) for jurisdiction-aware
|
|
38
|
-
* matching. When `country` / `locale` are omitted, the server falls back to
|
|
39
|
-
* request headers (`x-vercel-ip-country`, `Accept-Language`).
|
|
40
|
-
*
|
|
41
|
-
* Returns the matched terms array. For matching metadata
|
|
42
|
-
* (jurisdiction, locale, source) use {@link listWithMeta}.
|
|
43
|
-
*/
|
|
44
|
-
async list(optionsOrToken) {
|
|
45
|
-
const response = await this.listWithMeta(optionsOrToken);
|
|
46
|
-
return response.terms;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Same as {@link list} but returns the full {@link TermsListResponse} including
|
|
50
|
-
* matched jurisdiction, country and locale — useful for displaying "약관이
|
|
51
|
-
* 어떤 국가 기준으로 적용됐는지" hint in the signup UX.
|
|
52
|
-
*/
|
|
53
|
-
async listWithMeta(optionsOrToken) {
|
|
54
|
-
const options = isListOptions(optionsOrToken) ? optionsOrToken : optionsOrToken ? { accessToken: optionsOrToken } : {};
|
|
55
|
-
const query = buildListQuery(options);
|
|
56
|
-
const path = query || "";
|
|
57
|
-
const body = await this.http.fetch(
|
|
58
|
-
"GET",
|
|
59
|
-
path,
|
|
60
|
-
void 0,
|
|
61
|
-
options.accessToken ? { bearerToken: options.accessToken } : void 0
|
|
62
|
-
);
|
|
63
|
-
return unwrap(body);
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Fetch the consent history (granted / withdrawn / pendingReConsent) for
|
|
67
|
-
* the OAuth user represented by `accessToken`.
|
|
68
|
-
*/
|
|
69
|
-
async listMyConsents(accessToken) {
|
|
70
|
-
const body = await this.http.fetch(
|
|
71
|
-
"GET",
|
|
72
|
-
"/me/consents",
|
|
73
|
-
void 0,
|
|
74
|
-
{ bearerToken: accessToken }
|
|
75
|
-
);
|
|
76
|
-
return unwrap(body);
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Record consent for one or more terms versions. The server rejects the
|
|
80
|
-
* call with `REQUIRED_NOT_CONSENTED` (422) if any required term is missing
|
|
81
|
-
* or marked as `consented: false`.
|
|
82
|
-
*/
|
|
83
|
-
async consent(input, accessToken) {
|
|
84
|
-
const body = await this.http.fetch(
|
|
85
|
-
"POST",
|
|
86
|
-
"/me/consents",
|
|
87
|
-
input,
|
|
88
|
-
{ bearerToken: accessToken }
|
|
89
|
-
);
|
|
90
|
-
return unwrap(body);
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Withdraw a previously-granted consent. The server returns 409 for
|
|
94
|
-
* required terms or already-withdrawn records.
|
|
95
|
-
*/
|
|
96
|
-
async withdraw(consentId, accessToken) {
|
|
97
|
-
const body = await this.http.fetch(
|
|
98
|
-
"DELETE",
|
|
99
|
-
`/me/consents/${encodeURIComponent(consentId)}`,
|
|
100
|
-
void 0,
|
|
101
|
-
{ bearerToken: accessToken }
|
|
102
|
-
);
|
|
103
|
-
return unwrap(body);
|
|
104
|
-
}
|
|
105
|
-
};
|
|
106
|
-
function createReoptTermsClient(config) {
|
|
107
|
-
return new ReoptTermsClient(config);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
export { ReoptTermsClient, createReoptTermsClient };
|
|
111
|
-
//# sourceMappingURL=chunk-T7YTITRJ.js.map
|
|
112
|
-
//# sourceMappingURL=chunk-T7YTITRJ.js.map
|
package/dist/chunk-V73GORO3.js
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { buildQuery } from './chunk-VRNBYSWU.js';
|
|
2
|
-
import { BaseHttpClient } from './chunk-N5JVE4WX.js';
|
|
3
|
-
|
|
4
|
-
// src/cms/client.ts
|
|
5
|
-
function createReoptCmsClient(config) {
|
|
6
|
-
const http = new BaseHttpClient(
|
|
7
|
-
config,
|
|
8
|
-
`/api/v1/brandapp/${config.brandappId}/cms`
|
|
9
|
-
);
|
|
10
|
-
return {
|
|
11
|
-
posts: {
|
|
12
|
-
async list(query) {
|
|
13
|
-
const qs = buildQuery(query ?? {});
|
|
14
|
-
const res = await http.fetch(
|
|
15
|
-
"GET",
|
|
16
|
-
`/posts${qs}`
|
|
17
|
-
);
|
|
18
|
-
return res.data;
|
|
19
|
-
},
|
|
20
|
-
async get(postId) {
|
|
21
|
-
const res = await http.fetch(
|
|
22
|
-
"GET",
|
|
23
|
-
`/posts/${postId}`
|
|
24
|
-
);
|
|
25
|
-
return res.data;
|
|
26
|
-
},
|
|
27
|
-
/**
|
|
28
|
-
* Slug 기반 단건 조회. URL 라우트(`/blog/[slug]`)에서 id 매핑 없이 사용.
|
|
29
|
-
* 같은 slug가 여러 그룹에 있을 수 있는 경우 `groupId` 또는 `groupSlug`로 좁힐 수 있다.
|
|
30
|
-
*/
|
|
31
|
-
async getBySlug(slug, opts) {
|
|
32
|
-
const qs = buildQuery({
|
|
33
|
-
groupId: opts?.groupId,
|
|
34
|
-
groupSlug: opts?.groupSlug
|
|
35
|
-
});
|
|
36
|
-
const res = await http.fetch(
|
|
37
|
-
"GET",
|
|
38
|
-
`/posts/by-slug/${encodeURIComponent(slug)}${qs}`
|
|
39
|
-
);
|
|
40
|
-
return res.data;
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
postGroups: {
|
|
44
|
-
async list(query) {
|
|
45
|
-
const qs = buildQuery(query ?? {});
|
|
46
|
-
const res = await http.fetch("GET", `/post-groups${qs}`);
|
|
47
|
-
return res.data;
|
|
48
|
-
},
|
|
49
|
-
async get(groupId) {
|
|
50
|
-
const res = await http.fetch(
|
|
51
|
-
"GET",
|
|
52
|
-
`/post-groups/${groupId}`
|
|
53
|
-
);
|
|
54
|
-
return res.data;
|
|
55
|
-
},
|
|
56
|
-
/**
|
|
57
|
-
* Slug 기반 그룹 단건 조회. env var(`REOPT_*_GROUP_ID`) 대신 slug 하드코딩
|
|
58
|
-
* 패턴(`CONTENT_GROUPS.blog.slug`)을 권장.
|
|
59
|
-
*/
|
|
60
|
-
async getBySlug(slug) {
|
|
61
|
-
const res = await http.fetch(
|
|
62
|
-
"GET",
|
|
63
|
-
`/post-groups/by-slug/${encodeURIComponent(slug)}`
|
|
64
|
-
);
|
|
65
|
-
return res.data;
|
|
66
|
-
}
|
|
67
|
-
},
|
|
68
|
-
tags: {
|
|
69
|
-
/** Brand 범위 안에서 사용된 포스트 태그 목록을 반환. */
|
|
70
|
-
async list(query) {
|
|
71
|
-
const qs = buildQuery(query ?? {});
|
|
72
|
-
const res = await http.fetch("GET", `/tags${qs}`);
|
|
73
|
-
return res.data;
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
};
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export { createReoptCmsClient };
|
|
80
|
-
//# sourceMappingURL=chunk-V73GORO3.js.map
|
|
81
|
-
//# sourceMappingURL=chunk-V73GORO3.js.map
|
package/dist/chunk-VRNBYSWU.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { ReoptSDKError } from './chunk-MRQY45U5.js';
|
|
2
|
-
|
|
3
|
-
// src/core/query.ts
|
|
4
|
-
var MAX_QUERY_STRING_LENGTH = 7500;
|
|
5
|
-
function buildQuery(params) {
|
|
6
|
-
const entries = Object.entries(params).filter(
|
|
7
|
-
([, v]) => v !== void 0 && v !== null
|
|
8
|
-
);
|
|
9
|
-
if (entries.length === 0) return "";
|
|
10
|
-
const qs = "?" + entries.map(([k, v]) => {
|
|
11
|
-
const value = typeof v === "object" ? JSON.stringify(v) : String(v);
|
|
12
|
-
return `${k}=${encodeURIComponent(value)}`;
|
|
13
|
-
}).join("&");
|
|
14
|
-
if (qs.length > MAX_QUERY_STRING_LENGTH) {
|
|
15
|
-
throw new ReoptSDKError(
|
|
16
|
-
`Query string is too large (${qs.length} chars, limit ${MAX_QUERY_STRING_LENGTH}). Reduce the number of filters or the size of filter values.`,
|
|
17
|
-
0,
|
|
18
|
-
"QUERY_TOO_LARGE",
|
|
19
|
-
void 0,
|
|
20
|
-
{
|
|
21
|
-
cause: "GET \uC694\uCCAD\uC758 \uCFFC\uB9AC\uC2A4\uD2B8\uB9C1\uC774 \uC11C\uBC84/\uD504\uB85D\uC2DC\uC758 URL \uAE38\uC774 \uD55C\uB3C4(\uD1B5\uC0C1 8KB)\uB97C \uCD08\uACFC\uD560 \uC704\uD5D8\uC774 \uC788\uC74C",
|
|
22
|
-
fix: "filters \uAC1C\uC218\uB97C \uC904\uC774\uAC70\uB098, \uD070 value(\uC608: \uAE34 contains \uBB38\uC790\uC5F4)\uB97C \uBD84\uB9AC/\uCD95\uC18C. \uB300\uB7C9 \uC870\uAC74\uC740 \uC5EC\uB7EC \uBC88 \uB098\uB220 \uC870\uD68C",
|
|
23
|
-
doc: "docs/errors.md#query_too_large"
|
|
24
|
-
}
|
|
25
|
-
);
|
|
26
|
-
}
|
|
27
|
-
return qs;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export { buildQuery };
|
|
31
|
-
//# sourceMappingURL=chunk-VRNBYSWU.js.map
|
|
32
|
-
//# sourceMappingURL=chunk-VRNBYSWU.js.map
|
|
@@ -1,216 +0,0 @@
|
|
|
1
|
-
import { S as SchemaDef, q as ReoptSDKConfig, l as EavEntity, f as CreateEntityInput, E as EavAttribute, r as UpdateEntityInput, e as CreateAttributeInput, U as UpdateAttributeInput, L as ListRecordsQuery, P as PaginatedResponse, m as EavRecord, g as CreateRecordInput, s as UpdateRecordInput, C as CountRecordsQuery, d as BulkUpdateItem, t as UpsertRecordInput, u as UpsertRecordResult, i as DeleteWhereInput, B as BackfillOptions, c as BackfillResult, p as EntityDef } from './config-CtxyJsDR.js';
|
|
2
|
-
import { E as EntityClient } from './typed-client-BxOVIiMU.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Reopt EAV Client
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```ts
|
|
9
|
-
* import { createReoptEavClient } from "@reopt-ai/brandapp-sdk/eav";
|
|
10
|
-
*
|
|
11
|
-
* const eav = createReoptEavClient({
|
|
12
|
-
* clientId: process.env.BRANDAPP_CLIENT_ID!,
|
|
13
|
-
* clientSecret: process.env.BRANDAPP_CLIENT_SECRET!,
|
|
14
|
-
* brandappId: process.env.BRANDAPP_ID!,
|
|
15
|
-
* });
|
|
16
|
-
*
|
|
17
|
-
* const entity = await eav.entities.create({ name: "agent_configs" });
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
type ReoptEavClient<S extends SchemaDef = SchemaDef> = ReturnType<typeof createReoptEavClient<S>>;
|
|
21
|
-
declare function createReoptEavClient<S extends SchemaDef = SchemaDef>(config: ReoptSDKConfig<S>): {
|
|
22
|
-
entities: {
|
|
23
|
-
list(): Promise<EavEntity[]>;
|
|
24
|
-
create(input: CreateEntityInput): Promise<EavEntity>;
|
|
25
|
-
get(entityId: string): Promise<EavEntity & {
|
|
26
|
-
attributes: EavAttribute[];
|
|
27
|
-
}>;
|
|
28
|
-
update(entityId: string, input: UpdateEntityInput): Promise<EavEntity>;
|
|
29
|
-
delete(entityId: string): Promise<void>;
|
|
30
|
-
};
|
|
31
|
-
attributes: {
|
|
32
|
-
create(entityId: string, input: CreateAttributeInput): Promise<EavAttribute>;
|
|
33
|
-
update(entityId: string, attributeId: string, input: UpdateAttributeInput): Promise<EavAttribute>;
|
|
34
|
-
delete(entityId: string, attributeId: string): Promise<void>;
|
|
35
|
-
};
|
|
36
|
-
records: {
|
|
37
|
-
/** List records with pagination, filtering, and sorting.
|
|
38
|
-
* @example
|
|
39
|
-
* ```ts
|
|
40
|
-
* const result = await eav.records.list(entityId, {
|
|
41
|
-
* authUserId: userId,
|
|
42
|
-
* filters: [{ attributeId: "status-attr-id", operator: "eq", value: "active" }],
|
|
43
|
-
* sortBy: "createdAt",
|
|
44
|
-
* sortOrder: "desc",
|
|
45
|
-
* page: 1,
|
|
46
|
-
* limit: 50,
|
|
47
|
-
* });
|
|
48
|
-
* ```
|
|
49
|
-
*/
|
|
50
|
-
list(entityId: string, query?: ListRecordsQuery): Promise<PaginatedResponse<EavRecord>>;
|
|
51
|
-
/** Create a new record with attribute values.
|
|
52
|
-
* @example
|
|
53
|
-
* ```ts
|
|
54
|
-
* const record = await eav.records.create(entityId, {
|
|
55
|
-
* authUserId: userId,
|
|
56
|
-
* values: { [attrs.name]: "John", [attrs.email]: "john@example.com" },
|
|
57
|
-
* });
|
|
58
|
-
* ```
|
|
59
|
-
*/
|
|
60
|
-
create(entityId: string, input: CreateRecordInput): Promise<EavRecord>;
|
|
61
|
-
/** Get a single record by ID.
|
|
62
|
-
* @example
|
|
63
|
-
* ```ts
|
|
64
|
-
* const record = await eav.records.get(entityId, recordId);
|
|
65
|
-
* ```
|
|
66
|
-
*/
|
|
67
|
-
get(entityId: string, recordId: string): Promise<EavRecord>;
|
|
68
|
-
/** Update a record's attribute values. Only specified values are changed.
|
|
69
|
-
* @example
|
|
70
|
-
* ```ts
|
|
71
|
-
* const updated = await eav.records.update(entityId, recordId, {
|
|
72
|
-
* values: { [attrs.status]: "completed" },
|
|
73
|
-
* });
|
|
74
|
-
* ```
|
|
75
|
-
*/
|
|
76
|
-
update(entityId: string, recordId: string, input: UpdateRecordInput): Promise<EavRecord>;
|
|
77
|
-
/** Delete a single record by ID. */
|
|
78
|
-
delete(entityId: string, recordId: string): Promise<void>;
|
|
79
|
-
/** Count records matching filters without fetching bodies.
|
|
80
|
-
* @example
|
|
81
|
-
* ```ts
|
|
82
|
-
* // Count active tasks
|
|
83
|
-
* const count = await eav.records.count(entityId, {
|
|
84
|
-
* authUserId: userId,
|
|
85
|
-
* filters: [{ attributeId: attrs.deleted_at, operator: "is_null" }],
|
|
86
|
-
* });
|
|
87
|
-
* ```
|
|
88
|
-
*/
|
|
89
|
-
count(entityId: string, query?: CountRecordsQuery): Promise<number>;
|
|
90
|
-
/** Delete multiple records by ID (max 100). Returns count of deleted records. */
|
|
91
|
-
bulkDelete(entityId: string, ids: string[]): Promise<number>;
|
|
92
|
-
/** Update multiple records in a single transaction (max 100).
|
|
93
|
-
* @example
|
|
94
|
-
* ```ts
|
|
95
|
-
* const updated = await eav.records.bulkUpdate(entityId, [
|
|
96
|
-
* { id: "record-1", values: { [attrs.is_active]: false } },
|
|
97
|
-
* { id: "record-2", values: { [attrs.is_active]: false } },
|
|
98
|
-
* ]);
|
|
99
|
-
* ```
|
|
100
|
-
*/
|
|
101
|
-
bulkUpdate(entityId: string, updates: BulkUpdateItem[]): Promise<EavRecord[]>;
|
|
102
|
-
/** Find a single record matching filters. Returns null if not found.
|
|
103
|
-
* Prefer this over list() + filter when you need exactly one record.
|
|
104
|
-
* @example
|
|
105
|
-
* ```ts
|
|
106
|
-
* // Find setting by key
|
|
107
|
-
* const record = await eav.records.findOne(entityId, {
|
|
108
|
-
* authUserId: userId,
|
|
109
|
-
* filters: [{ attributeId: attrs.key, operator: "eq", value: "theme" }],
|
|
110
|
-
* });
|
|
111
|
-
* ```
|
|
112
|
-
*/
|
|
113
|
-
findOne(entityId: string, query?: Omit<ListRecordsQuery, "page">): Promise<EavRecord | null>;
|
|
114
|
-
/** Find a record by filters -- update if exists, create if not. Atomic operation.
|
|
115
|
-
* @returns `{ data: EavRecord, created: boolean }`
|
|
116
|
-
* @example
|
|
117
|
-
* ```ts
|
|
118
|
-
* // Upsert a user setting
|
|
119
|
-
* const { data, created } = await eav.records.upsert(entityId, {
|
|
120
|
-
* authUserId: userId,
|
|
121
|
-
* filters: [{ attributeId: attrs.key, operator: "eq", value: "theme" }],
|
|
122
|
-
* values: { [attrs.key]: "theme", [attrs.value]: "dark" },
|
|
123
|
-
* });
|
|
124
|
-
* ```
|
|
125
|
-
*/
|
|
126
|
-
upsert(entityId: string, input: UpsertRecordInput): Promise<UpsertRecordResult<EavRecord>>;
|
|
127
|
-
/** Create multiple records in a single transaction (max 100).
|
|
128
|
-
* @example
|
|
129
|
-
* ```ts
|
|
130
|
-
* const records = await eav.records.bulkCreate(entityId, [
|
|
131
|
-
* { values: { [attrs.name]: "Alice" } },
|
|
132
|
-
* { values: { [attrs.name]: "Bob" } },
|
|
133
|
-
* ]);
|
|
134
|
-
* ```
|
|
135
|
-
*/
|
|
136
|
-
bulkCreate(entityId: string, records: CreateRecordInput[]): Promise<EavRecord[]>;
|
|
137
|
-
/** Delete all records matching filters. Returns count of deleted records.
|
|
138
|
-
* @example
|
|
139
|
-
* ```ts
|
|
140
|
-
* // Delete all inactive records
|
|
141
|
-
* const count = await eav.records.deleteWhere(entityId, {
|
|
142
|
-
* authUserId: userId,
|
|
143
|
-
* filters: [{ attributeId: attrs.status, operator: "eq", value: "inactive" }],
|
|
144
|
-
* });
|
|
145
|
-
* ```
|
|
146
|
-
*/
|
|
147
|
-
deleteWhere(entityId: string, input: DeleteWhereInput): Promise<number>;
|
|
148
|
-
/** Iterate all records across pages as an AsyncGenerator.
|
|
149
|
-
* @example
|
|
150
|
-
* ```ts
|
|
151
|
-
* // Stream all records
|
|
152
|
-
* for await (const record of eav.records.listAll(entityId, { authUserId: userId })) {
|
|
153
|
-
* process.stdout.write(".");
|
|
154
|
-
* }
|
|
155
|
-
*
|
|
156
|
-
* // Or collect to array
|
|
157
|
-
* import { collectAll } from "@reopt-ai/brandapp-sdk/eav";
|
|
158
|
-
* const all = await collectAll(eav.records.listAll(entityId));
|
|
159
|
-
* ```
|
|
160
|
-
*/
|
|
161
|
-
listAll(entityId: string, query?: Omit<ListRecordsQuery, "page">): AsyncGenerator<EavRecord>;
|
|
162
|
-
/**
|
|
163
|
-
* Backfill records by streaming through pages, calling `transform` per
|
|
164
|
-
* record, and applying `update` for each non-null result.
|
|
165
|
-
*
|
|
166
|
-
* Designed for the "expand-contract" middle step of an EAV migration —
|
|
167
|
-
* e.g. copy values from a soon-to-be-deleted attribute to a new one.
|
|
168
|
-
*
|
|
169
|
-
* @example
|
|
170
|
-
* ```ts
|
|
171
|
-
* await sdk.eav.records.backfill(entityId, {
|
|
172
|
-
* filters: [{ attributeId: levelAttrId, operator: "is_null" }],
|
|
173
|
-
* concurrency: 10,
|
|
174
|
-
* transform: (r) => ({ level: r.values.tier ?? "free" }),
|
|
175
|
-
* onProgress: ({ processed, total }) =>
|
|
176
|
-
* console.log(`${processed}/${total}`),
|
|
177
|
-
* });
|
|
178
|
-
* ```
|
|
179
|
-
*
|
|
180
|
-
* Failed updates are collected in `result.failed[]` rather than aborting
|
|
181
|
-
* the run — inspect that array after the call to retry or escalate.
|
|
182
|
-
*/
|
|
183
|
-
backfill(entityId: string, opts: BackfillOptions): Promise<BackfillResult>;
|
|
184
|
-
};
|
|
185
|
-
users: {
|
|
186
|
-
getRecords(authUserId: string, query?: Omit<ListRecordsQuery, "authUserId">): Promise<PaginatedResponse<EavRecord>>;
|
|
187
|
-
};
|
|
188
|
-
/**
|
|
189
|
-
* Fetch the server's current EAV schema fingerprint (Phase C, RFC-0005).
|
|
190
|
-
*
|
|
191
|
-
* Pair with `verifyEavSchema(localHash, client)` to detect drift between
|
|
192
|
-
* a deployed bundle and the live schema. Cacheable for ~60s — the server
|
|
193
|
-
* recomputes on every schema mutation.
|
|
194
|
-
*/
|
|
195
|
-
schemaHash(): Promise<{
|
|
196
|
-
hash: string;
|
|
197
|
-
schemaCount: number;
|
|
198
|
-
fieldCount: number;
|
|
199
|
-
generatedAt: string;
|
|
200
|
-
}>;
|
|
201
|
-
/** Create a type-safe entity-scoped client. Resolves entity name to ID automatically.
|
|
202
|
-
* Requires `schema` in SDK config for type inference.
|
|
203
|
-
* @example
|
|
204
|
-
* ```ts
|
|
205
|
-
* const contacts = sdk.eav.entity("contacts");
|
|
206
|
-
* const record = await contacts.records.create({
|
|
207
|
-
* values: { name: "John", email: "john@example.com" }, // typed!
|
|
208
|
-
* });
|
|
209
|
-
* ```
|
|
210
|
-
*/
|
|
211
|
-
entity<K extends string & keyof S["entities"]>(name: K): EntityClient<S["entities"][K] extends EntityDef ? S["entities"][K] : EntityDef>;
|
|
212
|
-
/** Clear the entity name → ID cache and schema cache. Call after creating/deleting entities externally. */
|
|
213
|
-
invalidateCache(): void;
|
|
214
|
-
};
|
|
215
|
-
|
|
216
|
-
export { type ReoptEavClient as R, createReoptEavClient as c };
|
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import { q as ReoptSDKConfig } from './config-CtxyJsDR.js';
|
|
2
|
-
|
|
3
|
-
/** 파일 정보 */
|
|
4
|
-
type FileInfo = {
|
|
5
|
-
/** 파일 ID */
|
|
6
|
-
id: string;
|
|
7
|
-
/** 파일명 */
|
|
8
|
-
name: string;
|
|
9
|
-
/** 파일 URL (Vercel Blob) */
|
|
10
|
-
url: string | null;
|
|
11
|
-
/** 파일 크기 (bytes) */
|
|
12
|
-
size: number;
|
|
13
|
-
/** MIME 타입 */
|
|
14
|
-
contentType: string | null;
|
|
15
|
-
/** 저장 경로 */
|
|
16
|
-
pathname: string;
|
|
17
|
-
/** 생성일 (ISO 8601) */
|
|
18
|
-
createdAt: string;
|
|
19
|
-
/** 수정일 (ISO 8601) */
|
|
20
|
-
updatedAt: string;
|
|
21
|
-
};
|
|
22
|
-
/** 파일 목록 조회 쿼리 */
|
|
23
|
-
type FileListQuery = {
|
|
24
|
-
/** 페이지 번호 (기본 1) */
|
|
25
|
-
page?: number;
|
|
26
|
-
/** 페이지 당 항목 수 (기본 20) */
|
|
27
|
-
limit?: number;
|
|
28
|
-
/** MIME 타입 필터 (e.g. "image/png", "image/*") */
|
|
29
|
-
contentType?: string;
|
|
30
|
-
/** 정렬 기준 */
|
|
31
|
-
sortBy?: "createdAt" | "name" | "size";
|
|
32
|
-
/** 정렬 순서 */
|
|
33
|
-
sortOrder?: "asc" | "desc";
|
|
34
|
-
};
|
|
35
|
-
/** 파일 목록 응답 */
|
|
36
|
-
type FileListResponse = {
|
|
37
|
-
data: FileInfo[];
|
|
38
|
-
meta: {
|
|
39
|
-
page: number;
|
|
40
|
-
limit: number;
|
|
41
|
-
total: number;
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
/** 파일 업로드 옵션 */
|
|
45
|
-
type UploadOptions = {
|
|
46
|
-
/** 파일명 (미지정 시 원본 파일명 또는 자동 생성) */
|
|
47
|
-
name?: string;
|
|
48
|
-
/** MIME 타입 (미지정 시 자동 감지) */
|
|
49
|
-
contentType?: string;
|
|
50
|
-
/** 외부 AbortSignal — 업로드 중도 취소용. SDK 타임아웃과 병합됨. */
|
|
51
|
-
signal?: AbortSignal;
|
|
52
|
-
/** 이 호출에만 적용할 타임아웃 (ms). 미지정 시 SDK 기본값. */
|
|
53
|
-
timeout?: number;
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* BrandApp File 클라이언트
|
|
58
|
-
*
|
|
59
|
-
* 기존 BaseHttpClient를 활용하여 파일 목록/조회/삭제를 처리하고,
|
|
60
|
-
* 업로드는 FormData(multipart)가 필요하므로 globalThis.fetch를 직접 사용합니다.
|
|
61
|
-
*
|
|
62
|
-
* @example
|
|
63
|
-
* ```ts
|
|
64
|
-
* const sdk = createReoptSDK({ ... });
|
|
65
|
-
*
|
|
66
|
-
* // List files
|
|
67
|
-
* const { data: files, meta } = await sdk.files.list({ page: 1, limit: 20 });
|
|
68
|
-
*
|
|
69
|
-
* // Get single file
|
|
70
|
-
* const file = await sdk.files.get(fileId);
|
|
71
|
-
*
|
|
72
|
-
* // Upload file
|
|
73
|
-
* const uploaded = await sdk.files.upload(blob, { name: "banner.png" });
|
|
74
|
-
* console.log(uploaded.url);
|
|
75
|
-
*
|
|
76
|
-
* // Delete file
|
|
77
|
-
* await sdk.files.delete(fileId);
|
|
78
|
-
* ```
|
|
79
|
-
*/
|
|
80
|
-
|
|
81
|
-
declare class ReoptFileClient {
|
|
82
|
-
private readonly http;
|
|
83
|
-
private readonly timeout;
|
|
84
|
-
constructor(config: ReoptSDKConfig);
|
|
85
|
-
/**
|
|
86
|
-
* 파일 목록 조회
|
|
87
|
-
*
|
|
88
|
-
* @example
|
|
89
|
-
* ```ts
|
|
90
|
-
* const { data: files, meta } = await sdk.files.list({
|
|
91
|
-
* page: 1,
|
|
92
|
-
* limit: 20,
|
|
93
|
-
* contentType: "image/*",
|
|
94
|
-
* sortBy: "createdAt",
|
|
95
|
-
* sortOrder: "desc",
|
|
96
|
-
* });
|
|
97
|
-
* console.log(`Total: ${meta.total}`);
|
|
98
|
-
* ```
|
|
99
|
-
*/
|
|
100
|
-
list(query?: FileListQuery): Promise<FileListResponse>;
|
|
101
|
-
/**
|
|
102
|
-
* 단일 파일 조회
|
|
103
|
-
*
|
|
104
|
-
* @example
|
|
105
|
-
* ```ts
|
|
106
|
-
* const file = await sdk.files.get("file-uuid");
|
|
107
|
-
* console.log(file.name, file.url);
|
|
108
|
-
* ```
|
|
109
|
-
*/
|
|
110
|
-
get(fileId: string): Promise<FileInfo>;
|
|
111
|
-
/**
|
|
112
|
-
* 파일 삭제
|
|
113
|
-
*
|
|
114
|
-
* @example
|
|
115
|
-
* ```ts
|
|
116
|
-
* await sdk.files.delete("file-uuid");
|
|
117
|
-
* ```
|
|
118
|
-
*/
|
|
119
|
-
delete(fileId: string): Promise<void>;
|
|
120
|
-
/**
|
|
121
|
-
* 파일 업로드
|
|
122
|
-
*
|
|
123
|
-
* FormData(multipart)로 파일을 전송합니다.
|
|
124
|
-
* BaseHttpClient는 JSON 전용이므로 globalThis.fetch를 직접 사용합니다.
|
|
125
|
-
*
|
|
126
|
-
* @example
|
|
127
|
-
* ```ts
|
|
128
|
-
* // Blob 업로드
|
|
129
|
-
* const blob = new Blob(["hello"], { type: "text/plain" });
|
|
130
|
-
* const file = await sdk.files.upload(blob, { name: "hello.txt" });
|
|
131
|
-
*
|
|
132
|
-
* // File 업로드 (브라우저)
|
|
133
|
-
* const file = await sdk.files.upload(inputEl.files[0]);
|
|
134
|
-
*
|
|
135
|
-
* // Buffer 업로드 (Node.js)
|
|
136
|
-
* const buf = fs.readFileSync("image.png");
|
|
137
|
-
* const file = await sdk.files.upload(buf, {
|
|
138
|
-
* name: "image.png",
|
|
139
|
-
* contentType: "image/png",
|
|
140
|
-
* });
|
|
141
|
-
* ```
|
|
142
|
-
*/
|
|
143
|
-
upload(file: Blob | Uint8Array | File, options?: UploadOptions): Promise<FileInfo>;
|
|
144
|
-
}
|
|
145
|
-
declare function createReoptFileClient(config: ReoptSDKConfig): ReoptFileClient;
|
|
146
|
-
|
|
147
|
-
export { type FileInfo as F, ReoptFileClient as R, type UploadOptions as U, type FileListQuery as a, type FileListResponse as b, createReoptFileClient as c };
|