@reopt-ai/brandapp-sdk 3.3.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 +67 -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-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 +103 -86
- package/dist/config-CRytOPPl.d.ts +394 -0
- package/dist/config-Cw0a3-C8.js +487 -0
- package/dist/dev/index.d.ts +2 -528
- package/dist/dev/index.js +2731 -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-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 -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-BvbCiGWb.js +35 -0
- package/dist/react/hooks.d.ts +97 -99
- package/dist/react/hooks.js +742 -404
- 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 +87 -6
- package/package.json +6 -5
- 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
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
//#region src/core/sse-parser.ts
|
|
2
|
+
/**
|
|
3
|
+
* Stateful SSE line processor.
|
|
4
|
+
*
|
|
5
|
+
* Feed raw text chunks via `feed()`. The `onEvent` callback is invoked
|
|
6
|
+
* for each complete SSE event (delimited by a blank line per spec).
|
|
7
|
+
*/
|
|
8
|
+
function createSSELineProcessor(onEvent) {
|
|
9
|
+
let buffer = "";
|
|
10
|
+
let currentEvent = "";
|
|
11
|
+
let dataBuffer = "";
|
|
12
|
+
function processLine(line) {
|
|
13
|
+
const stripped = line.endsWith("\r") ? line.slice(0, -1) : line;
|
|
14
|
+
if (stripped.startsWith("event:")) {
|
|
15
|
+
const raw = stripped.slice(6);
|
|
16
|
+
currentEvent = raw.startsWith(" ") ? raw.slice(1) : raw;
|
|
17
|
+
} else if (stripped.startsWith("data:")) {
|
|
18
|
+
const raw = stripped.slice(5);
|
|
19
|
+
const data = raw.startsWith(" ") ? raw.slice(1) : raw;
|
|
20
|
+
dataBuffer = dataBuffer ? dataBuffer + "\n" + data : data;
|
|
21
|
+
} else if (stripped === "") {
|
|
22
|
+
if (dataBuffer) onEvent({
|
|
23
|
+
event: currentEvent,
|
|
24
|
+
data: dataBuffer
|
|
25
|
+
});
|
|
26
|
+
currentEvent = "";
|
|
27
|
+
dataBuffer = "";
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return {
|
|
31
|
+
feed(chunk) {
|
|
32
|
+
buffer += chunk;
|
|
33
|
+
const lines = buffer.split("\n");
|
|
34
|
+
buffer = lines.pop() ?? "";
|
|
35
|
+
for (const line of lines) processLine(line);
|
|
36
|
+
},
|
|
37
|
+
/**
|
|
38
|
+
* Flush any buffered input at stream end.
|
|
39
|
+
* Processes the last partial line (if any) and emits a final event
|
|
40
|
+
* if a data buffer is still pending.
|
|
41
|
+
*/
|
|
42
|
+
flush() {
|
|
43
|
+
if (buffer.length > 0) {
|
|
44
|
+
processLine(buffer);
|
|
45
|
+
buffer = "";
|
|
46
|
+
}
|
|
47
|
+
if (dataBuffer) {
|
|
48
|
+
onEvent({
|
|
49
|
+
event: currentEvent,
|
|
50
|
+
data: dataBuffer
|
|
51
|
+
});
|
|
52
|
+
currentEvent = "";
|
|
53
|
+
dataBuffer = "";
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Parse an SSE ReadableStream as an AsyncGenerator of events.
|
|
60
|
+
*
|
|
61
|
+
* Used by ai/client.ts for `stream()` and `streamWithMetadata()`.
|
|
62
|
+
*/
|
|
63
|
+
async function* parseSSEStream(body) {
|
|
64
|
+
const reader = body.getReader();
|
|
65
|
+
const decoder = new TextDecoder();
|
|
66
|
+
const pending = [];
|
|
67
|
+
const processor = createSSELineProcessor((event) => {
|
|
68
|
+
pending.push(event);
|
|
69
|
+
});
|
|
70
|
+
try {
|
|
71
|
+
while (true) {
|
|
72
|
+
const { done, value } = await reader.read();
|
|
73
|
+
if (done) break;
|
|
74
|
+
processor.feed(decoder.decode(value, { stream: true }));
|
|
75
|
+
while (pending.length > 0) yield pending.shift();
|
|
76
|
+
}
|
|
77
|
+
processor.flush();
|
|
78
|
+
while (pending.length > 0) yield pending.shift();
|
|
79
|
+
} finally {
|
|
80
|
+
reader.releaseLock();
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
//#endregion
|
|
85
|
+
export { parseSSEStream as n, createSSELineProcessor as t };
|
|
86
|
+
//# sourceMappingURL=sse-parser-FMjxM7sY.js.map
|
package/dist/terms/index.d.ts
CHANGED
|
@@ -1,79 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export {
|
|
4
|
-
import '../types-ckmDDW3N.js';
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Brandapp Terms client.
|
|
8
|
-
*
|
|
9
|
-
* Lets a Brandapp fetch the agreements it has defined and record/withdraw a
|
|
10
|
-
* signed-in user's consent.
|
|
11
|
-
*
|
|
12
|
-
* - `list()` — public-ish (Basic or Bearer). Returns active terms with the
|
|
13
|
-
* currently-published version body so the caller can render them.
|
|
14
|
-
* - `listMyConsents(accessToken)` — Bearer. The user's consent history.
|
|
15
|
-
* - `consent(input, accessToken)` — Bearer. Batch-creates `granted` records.
|
|
16
|
-
* - `withdraw(consentId, accessToken)` — Bearer. Soft-revokes one record.
|
|
17
|
-
* The server rejects withdrawal of consents tied to required terms.
|
|
18
|
-
*
|
|
19
|
-
* @example
|
|
20
|
-
* ```ts
|
|
21
|
-
* const sdk = createReoptSDK({ clientId, clientSecret, brandappId });
|
|
22
|
-
*
|
|
23
|
-
* // Render the agreements (no user context required):
|
|
24
|
-
* const terms = await sdk.terms.list();
|
|
25
|
-
*
|
|
26
|
-
* // After the user signs in via OAuth:
|
|
27
|
-
* await sdk.terms.consent(
|
|
28
|
-
* { consents: terms.map((t) => ({ versionId: t.currentVersion!.id, consented: true })) },
|
|
29
|
-
* accessToken,
|
|
30
|
-
* );
|
|
31
|
-
*
|
|
32
|
-
* const mine = await sdk.terms.listMyConsents(accessToken);
|
|
33
|
-
* ```
|
|
34
|
-
*/
|
|
35
|
-
|
|
36
|
-
declare class ReoptTermsClient {
|
|
37
|
-
private readonly http;
|
|
38
|
-
constructor(config: ReoptSDKConfig);
|
|
39
|
-
/**
|
|
40
|
-
* List active terms for this Brandapp with their currently-published
|
|
41
|
-
* version. Works with either Basic Auth (default) or Bearer Auth — when
|
|
42
|
-
* called from a server handler that has the user's access token, pass
|
|
43
|
-
* `accessToken` to avoid sending app credentials.
|
|
44
|
-
*
|
|
45
|
-
* Accepts either an `accessToken` string (legacy) or an options object
|
|
46
|
-
* (`country`/`locale`/`jurisdiction`/`accessToken`) for jurisdiction-aware
|
|
47
|
-
* matching. When `country` / `locale` are omitted, the server falls back to
|
|
48
|
-
* request headers (`x-vercel-ip-country`, `Accept-Language`).
|
|
49
|
-
*
|
|
50
|
-
* Returns the matched terms array. For matching metadata
|
|
51
|
-
* (jurisdiction, locale, source) use {@link listWithMeta}.
|
|
52
|
-
*/
|
|
53
|
-
list(optionsOrToken?: string | ListTermsOptions): Promise<TermsItem[]>;
|
|
54
|
-
/**
|
|
55
|
-
* Same as {@link list} but returns the full {@link TermsListResponse} including
|
|
56
|
-
* matched jurisdiction, country and locale — useful for displaying "약관이
|
|
57
|
-
* 어떤 국가 기준으로 적용됐는지" hint in the signup UX.
|
|
58
|
-
*/
|
|
59
|
-
listWithMeta(optionsOrToken?: string | ListTermsOptions): Promise<TermsListResponse>;
|
|
60
|
-
/**
|
|
61
|
-
* Fetch the consent history (granted / withdrawn / pendingReConsent) for
|
|
62
|
-
* the OAuth user represented by `accessToken`.
|
|
63
|
-
*/
|
|
64
|
-
listMyConsents(accessToken: string): Promise<ConsentRecord[]>;
|
|
65
|
-
/**
|
|
66
|
-
* Record consent for one or more terms versions. The server rejects the
|
|
67
|
-
* call with `REQUIRED_NOT_CONSENTED` (422) if any required term is missing
|
|
68
|
-
* or marked as `consented: false`.
|
|
69
|
-
*/
|
|
70
|
-
consent(input: CreateConsentsRequest, accessToken: string): Promise<CreateConsentsResult>;
|
|
71
|
-
/**
|
|
72
|
-
* Withdraw a previously-granted consent. The server returns 409 for
|
|
73
|
-
* required terms or already-withdrawn records.
|
|
74
|
-
*/
|
|
75
|
-
withdraw(consentId: string, accessToken: string): Promise<WithdrawConsentResult>;
|
|
76
|
-
}
|
|
77
|
-
declare function createReoptTermsClient(config: ReoptSDKConfig): ReoptTermsClient;
|
|
78
|
-
|
|
79
|
-
export { ConsentRecord, CreateConsentsRequest, CreateConsentsResult, ListTermsOptions, ReoptTermsClient, TermsItem, TermsListResponse, WithdrawConsentResult, createReoptTermsClient };
|
|
1
|
+
import { a as CreateConsentsResult, c as TermsJurisdiction, d as TermsVersion, f as WithdrawConsentResult, i as CreateConsentsRequest, l as TermsListResponse, n as ConsentRecord, o as ListTermsOptions, r as ConsentStatus, s as TermsItem, t as ConsentInput, u as TermsType } from "../types-BrghN2rJ.js";
|
|
2
|
+
import { n as createReoptTermsClient, t as ReoptTermsClient } from "../client-lk6wBu_0.js";
|
|
3
|
+
export { type ConsentInput, type ConsentRecord, type ConsentStatus, type CreateConsentsRequest, type CreateConsentsResult, type ListTermsOptions, ReoptTermsClient, type TermsItem, type TermsJurisdiction, type TermsListResponse, type TermsType, type TermsVersion, type WithdrawConsentResult, createReoptTermsClient };
|
package/dist/terms/index.js
CHANGED
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import '../chunk-C5VTRZWX.js';
|
|
5
|
-
//# sourceMappingURL=index.js.map
|
|
6
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
import { n as createReoptTermsClient, t as ReoptTermsClient } from "../client-B1q5P8rv.js";
|
|
2
|
+
|
|
3
|
+
export { ReoptTermsClient, createReoptTermsClient };
|
package/dist/testing/index.d.ts
CHANGED
|
@@ -1,110 +1,57 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { ReoptSDK } from
|
|
3
|
-
|
|
4
|
-
import '../types-DskYLVb8.js';
|
|
5
|
-
import '../terms/index.js';
|
|
6
|
-
import '../config-CtxyJsDR.js';
|
|
7
|
-
import '../push/index.js';
|
|
8
|
-
import '../plans/index.js';
|
|
9
|
-
import '../client-CN5_tNOC.js';
|
|
10
|
-
import '../feedback/index.js';
|
|
11
|
-
import '../client-DttyeM_h.js';
|
|
12
|
-
import '../ai/index.js';
|
|
13
|
-
import '../errors-BjDFIyA6.js';
|
|
14
|
-
import '../typed-client-BxOVIiMU.js';
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* @reopt-ai/brandapp-sdk/testing
|
|
18
|
-
*
|
|
19
|
-
* Test utilities for BrandApp consumer projects.
|
|
20
|
-
* Provides isolated dev server instances per test suite.
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* ```ts
|
|
24
|
-
* import { createTestSDK } from "@reopt-ai/brandapp-sdk/testing";
|
|
25
|
-
* import { describe, it, expect, beforeEach, afterAll } from "vitest";
|
|
26
|
-
*
|
|
27
|
-
* const schema = {
|
|
28
|
-
* entities: {
|
|
29
|
-
* contacts: {
|
|
30
|
-
* attributes: {
|
|
31
|
-
* name: { label: "Name", dataType: "text" },
|
|
32
|
-
* email: { label: "Email", dataType: "text" },
|
|
33
|
-
* },
|
|
34
|
-
* },
|
|
35
|
-
* },
|
|
36
|
-
* };
|
|
37
|
-
*
|
|
38
|
-
* describe("contacts", () => {
|
|
39
|
-
* const { sdk, devServer } = await createTestSDK({ schema });
|
|
40
|
-
*
|
|
41
|
-
* beforeEach(async () => {
|
|
42
|
-
* await devServer.reset();
|
|
43
|
-
* });
|
|
44
|
-
*
|
|
45
|
-
* afterAll(async () => {
|
|
46
|
-
* await devServer.close();
|
|
47
|
-
* });
|
|
48
|
-
*
|
|
49
|
-
* it("creates a contact", async () => {
|
|
50
|
-
* const entities = await sdk.eav.entities.list();
|
|
51
|
-
* expect(entities.length).toBeGreaterThan(0);
|
|
52
|
-
* });
|
|
53
|
-
* });
|
|
54
|
-
* ```
|
|
55
|
-
*/
|
|
56
|
-
|
|
1
|
+
import { a as SeedAllInput, c as SeedPostGroupInput, d as SeedTermsItem, l as SeedPostInput, n as DevServer, o as SeedData, t as DevSchema } from "../index-DrVaKfhs.js";
|
|
2
|
+
import { t as ReoptSDK } from "../index-Z6OGcurJ.js";
|
|
3
|
+
//#region src/testing/index.d.ts
|
|
57
4
|
type TestSDKOptions = {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
5
|
+
/** EAV schema to seed entities and attributes */
|
|
6
|
+
schema?: DevSchema;
|
|
7
|
+
/** BrandApp ID (default: "test-brandapp") */
|
|
8
|
+
brandappId?: string;
|
|
9
|
+
/** EAV records initial seed (backward-compat). Use `seedAll` for posts/terms. */
|
|
10
|
+
seed?: SeedData;
|
|
11
|
+
/** Unified initial seed (postGroups, posts, entities, terms). Runs after `seed`. */
|
|
12
|
+
seedAll?: SeedAllInput;
|
|
13
|
+
/** Convenience shortcut — equivalent to `seedAll: { postGroups }`. */
|
|
14
|
+
postGroups?: SeedPostGroupInput[];
|
|
15
|
+
/** Convenience shortcut — equivalent to `seedAll: { posts }`. */
|
|
16
|
+
posts?: SeedPostInput[];
|
|
17
|
+
/** Convenience shortcut — equivalent to `seedAll: { terms }`. */
|
|
18
|
+
terms?: SeedTermsItem[];
|
|
72
19
|
};
|
|
73
20
|
type TestSDKResult = {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
21
|
+
/** Pre-configured SDK instance pointing to the test server */
|
|
22
|
+
sdk: ReoptSDK;
|
|
23
|
+
/** The underlying dev server (for seed/reset/snapshot/restore) */
|
|
24
|
+
devServer: DevServer;
|
|
25
|
+
/** Base URL of the test server */
|
|
26
|
+
url: string;
|
|
27
|
+
/**
|
|
28
|
+
* Reset server data AND recreate the SDK (clears client-side caches).
|
|
29
|
+
* Use this in `beforeEach` instead of `devServer.reset()`.
|
|
30
|
+
*/
|
|
31
|
+
resetAll: () => Promise<void>;
|
|
85
32
|
};
|
|
86
33
|
type TestServerOptions = {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
34
|
+
/** EAV schema to seed */
|
|
35
|
+
schema?: DevSchema;
|
|
36
|
+
/** BrandApp ID (default: "test-brandapp") */
|
|
37
|
+
brandappId?: string;
|
|
38
|
+
/** Initial seed data */
|
|
39
|
+
seed?: SeedData;
|
|
93
40
|
};
|
|
94
41
|
type TestServerResult = {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
42
|
+
/** The dev server instance */
|
|
43
|
+
devServer: DevServer;
|
|
44
|
+
/** Base URL */
|
|
45
|
+
url: string;
|
|
46
|
+
/** Port */
|
|
47
|
+
port: number;
|
|
48
|
+
/** SDK config ready to pass to createReoptSDK */
|
|
49
|
+
sdkConfig: {
|
|
50
|
+
clientId: string;
|
|
51
|
+
clientSecret: string;
|
|
52
|
+
brandappId: string;
|
|
53
|
+
baseUrl: string;
|
|
54
|
+
};
|
|
108
55
|
};
|
|
109
56
|
/**
|
|
110
57
|
* Create an isolated test SDK with its own dev server.
|
|
@@ -147,8 +94,9 @@ declare function createTestServer(options?: TestServerOptions): Promise<TestServ
|
|
|
147
94
|
* ```
|
|
148
95
|
*/
|
|
149
96
|
declare function createFixture<T extends Record<string, (overrides?: Record<string, unknown>) => {
|
|
150
|
-
|
|
151
|
-
|
|
97
|
+
authUserId?: string;
|
|
98
|
+
values: Record<string, unknown>;
|
|
152
99
|
}>>(factories: T): T;
|
|
153
|
-
|
|
154
|
-
export { DevSchema, DevServer, SeedAllInput, SeedData, SeedPostGroupInput, SeedPostInput, SeedTermsItem,
|
|
100
|
+
//#endregion
|
|
101
|
+
export { type DevSchema, type DevServer, type SeedAllInput, type SeedData, type SeedPostGroupInput, type SeedPostInput, type SeedTermsItem, TestSDKOptions, TestSDKResult, TestServerOptions, TestServerResult, createFixture, createTestSDK, createTestServer };
|
|
102
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/testing/index.js
CHANGED
|
@@ -1,81 +1,103 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/testing/index.ts
|
|
2
|
+
/**
|
|
3
|
+
* Create an isolated test SDK with its own dev server.
|
|
4
|
+
* Each call spins up a new server on a random port.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* const { sdk, devServer } = await createTestSDK({ schema });
|
|
9
|
+
* // use sdk.eav, sdk.ai, sdk.files, etc.
|
|
10
|
+
* await devServer.close(); // cleanup
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
2
13
|
async function createTestSDK(options = {}) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
};
|
|
38
|
-
let sdk = createReoptSDK(sdkConfig);
|
|
39
|
-
const result = {
|
|
40
|
-
get sdk() {
|
|
41
|
-
return sdk;
|
|
42
|
-
},
|
|
43
|
-
devServer,
|
|
44
|
-
url: devServer.url,
|
|
45
|
-
async resetAll() {
|
|
46
|
-
await devServer.reset();
|
|
47
|
-
sdk = createReoptSDK(sdkConfig);
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
return result;
|
|
14
|
+
const { schema, brandappId = "test-brandapp", seed: initialSeed, seedAll, postGroups, posts, terms } = options;
|
|
15
|
+
const { createDevServer } = await import("../dev/index.js");
|
|
16
|
+
const { createReoptSDK } = await import("../index.js");
|
|
17
|
+
const devServer = await createDevServer({
|
|
18
|
+
port: 0,
|
|
19
|
+
brandappId,
|
|
20
|
+
schema
|
|
21
|
+
});
|
|
22
|
+
if (initialSeed) await devServer.seed(initialSeed);
|
|
23
|
+
const merged = {
|
|
24
|
+
postGroups: [...seedAll?.postGroups ?? [], ...postGroups ?? []],
|
|
25
|
+
posts: [...seedAll?.posts ?? [], ...posts ?? []],
|
|
26
|
+
entities: seedAll?.entities,
|
|
27
|
+
terms: [...seedAll?.terms ?? [], ...terms ?? []]
|
|
28
|
+
};
|
|
29
|
+
if (merged.postGroups?.length || merged.posts?.length || merged.entities || merged.terms?.length) await devServer.seedAll(merged);
|
|
30
|
+
const sdkConfig = {
|
|
31
|
+
clientId: "test",
|
|
32
|
+
clientSecret: "test",
|
|
33
|
+
brandappId,
|
|
34
|
+
baseUrl: devServer.url
|
|
35
|
+
};
|
|
36
|
+
let sdk = createReoptSDK(sdkConfig);
|
|
37
|
+
return {
|
|
38
|
+
get sdk() {
|
|
39
|
+
return sdk;
|
|
40
|
+
},
|
|
41
|
+
devServer,
|
|
42
|
+
url: devServer.url,
|
|
43
|
+
async resetAll() {
|
|
44
|
+
await devServer.reset();
|
|
45
|
+
sdk = createReoptSDK(sdkConfig);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
51
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Create an isolated test server without an SDK instance.
|
|
51
|
+
* Useful when you need more control over SDK configuration.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```ts
|
|
55
|
+
* const { devServer, sdkConfig } = await createTestServer({ schema });
|
|
56
|
+
* const sdk = createReoptSDK({ ...sdkConfig, debug: true });
|
|
57
|
+
* await devServer.close();
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
52
60
|
async function createTestServer(options = {}) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
};
|
|
61
|
+
const { schema, brandappId = "test-brandapp", seed: initialSeed } = options;
|
|
62
|
+
const { createDevServer } = await import("../dev/index.js");
|
|
63
|
+
const devServer = await createDevServer({
|
|
64
|
+
port: 0,
|
|
65
|
+
brandappId,
|
|
66
|
+
schema
|
|
67
|
+
});
|
|
68
|
+
if (initialSeed) await devServer.seed(initialSeed);
|
|
69
|
+
return {
|
|
70
|
+
devServer,
|
|
71
|
+
url: devServer.url,
|
|
72
|
+
port: devServer.port,
|
|
73
|
+
sdkConfig: {
|
|
74
|
+
clientId: "test",
|
|
75
|
+
clientSecret: "test",
|
|
76
|
+
brandappId,
|
|
77
|
+
baseUrl: devServer.url
|
|
78
|
+
}
|
|
79
|
+
};
|
|
74
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* Create a fixture factory for repeated test data patterns.
|
|
83
|
+
*
|
|
84
|
+
* @example
|
|
85
|
+
* ```ts
|
|
86
|
+
* const fixture = createFixture({
|
|
87
|
+
* contacts: (overrides) => ({
|
|
88
|
+
* values: { name: "Test User", email: "test@example.com", ...overrides },
|
|
89
|
+
* }),
|
|
90
|
+
* });
|
|
91
|
+
*
|
|
92
|
+
* await devServer.seed({
|
|
93
|
+
* contacts: [fixture.contacts(), fixture.contacts({ name: "Alice" })],
|
|
94
|
+
* });
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
75
97
|
function createFixture(factories) {
|
|
76
|
-
|
|
98
|
+
return factories;
|
|
77
99
|
}
|
|
78
100
|
|
|
101
|
+
//#endregion
|
|
79
102
|
export { createFixture, createTestSDK, createTestServer };
|
|
80
|
-
//# sourceMappingURL=index.js.map
|
|
81
103
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
//#region src/better-auth/types.d.ts
|
|
2
|
+
declare const REOPT_PROVIDER_ID: "reopt";
|
|
3
|
+
declare const REOPT_DEFAULT_SCOPES: readonly ["openid", "profile", "email"];
|
|
4
|
+
type AdapterOperation = "create" | "findOne" | "findMany" | "update" | "updateMany" | "delete" | "deleteMany" | "count";
|
|
5
|
+
type AdapterRequestBody = {
|
|
6
|
+
operation: AdapterOperation;
|
|
7
|
+
model: "user" | "session" | "account" | "verification";
|
|
8
|
+
data?: Record<string, unknown>;
|
|
9
|
+
where?: Array<{
|
|
10
|
+
field: string;
|
|
11
|
+
value: unknown;
|
|
12
|
+
operator?: string;
|
|
13
|
+
connector?: "AND" | "OR";
|
|
14
|
+
}>;
|
|
15
|
+
update?: Record<string, unknown>;
|
|
16
|
+
select?: string[];
|
|
17
|
+
limit?: number;
|
|
18
|
+
offset?: number;
|
|
19
|
+
sortBy?: {
|
|
20
|
+
field: string;
|
|
21
|
+
direction: "asc" | "desc";
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
//#endregion
|
|
25
|
+
export { REOPT_PROVIDER_ID as i, AdapterRequestBody as n, REOPT_DEFAULT_SCOPES as r, AdapterOperation as t };
|
|
26
|
+
//# sourceMappingURL=types-B-SMkH6s.d.ts.map
|