@reopt-ai/brandapp-sdk 3.3.0 → 3.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/CHANGELOG.md +115 -0
  2. package/README.md +10 -1
  3. package/dist/abort--nOBFN4M.js +50 -0
  4. package/dist/ai/index.d.ts +2 -314
  5. package/dist/ai/index.js +3 -8
  6. package/dist/ai-provider/index.d.ts +79 -163
  7. package/dist/ai-provider/index.js +752 -685
  8. package/dist/auth/index.d.ts +27 -27
  9. package/dist/auth/index.js +41 -34
  10. package/dist/better-auth/client.d.ts +6 -5
  11. package/dist/better-auth/client.js +28 -5
  12. package/dist/better-auth/index.d.ts +19 -17
  13. package/dist/better-auth/index.js +180 -144
  14. package/dist/client-61ldOHMz.js +503 -0
  15. package/dist/client-7PCoxVhZ.js +28 -0
  16. package/dist/client-B7rZQ8Zi.d.ts +272 -0
  17. package/dist/client-BGGd_cpV.d.ts +103 -0
  18. package/dist/client-BoIuyx4S.js +273 -0
  19. package/dist/client-BruP5_nU.d.ts +147 -0
  20. package/dist/client-BxtZt405.js +305 -0
  21. package/dist/client-ByN3EQdk.js +83 -0
  22. package/dist/client-CAghoGD_.js +53 -0
  23. package/dist/client-C_pHsPlj.js +81 -0
  24. package/dist/client-D0eBxh8j.d.ts +284 -0
  25. package/dist/client-D6gs61w8.d.ts +53 -0
  26. package/dist/client-DDw5yz_h.d.ts +53 -0
  27. package/dist/client-Dxg8_DIH.d.ts +71 -0
  28. package/dist/client-aMR4CRB8.d.ts +211 -0
  29. package/dist/client-lk6wBu_0.d.ts +48 -0
  30. package/dist/client-wEVKLdly.js +55 -0
  31. package/dist/client-zF1RG2uA.js +86 -0
  32. package/dist/cms/index.d.ts +52 -108
  33. package/dist/cms/index.js +103 -86
  34. package/dist/config-CRytOPPl.d.ts +394 -0
  35. package/dist/config-aml9oQpX.js +487 -0
  36. package/dist/dev/index.d.ts +2 -528
  37. package/dist/dev/index.js +3047 -2967
  38. package/dist/eav/coerce.d.ts +3 -1
  39. package/dist/eav/coerce.js +72 -46
  40. package/dist/eav/index.d.ts +72 -100
  41. package/dist/eav/index.js +158 -126
  42. package/dist/eav/migrate.d.ts +112 -109
  43. package/dist/eav/migrate.js +230 -196
  44. package/dist/eav/schema.d.ts +111 -150
  45. package/dist/eav/schema.js +624 -603
  46. package/dist/encoding-Bwfm3iaE.js +21 -0
  47. package/dist/{errors-BjDFIyA6.d.ts → errors-CRCcErNC.d.ts} +55 -53
  48. package/dist/feedback/index.d.ts +2 -132
  49. package/dist/feedback/index.js +3 -6
  50. package/dist/files/index.d.ts +14 -14
  51. package/dist/files/index.js +41 -25
  52. package/dist/http-client-BZc2mngq.js +386 -0
  53. package/dist/index-1j_738qk.d.ts +470 -0
  54. package/dist/index-CeOLGdyL.d.ts +169 -0
  55. package/dist/index.d.ts +6 -230
  56. package/dist/index.js +119 -71
  57. package/dist/logout/index.d.ts +56 -53
  58. package/dist/logout/index.js +232 -289
  59. package/dist/plans/index.d.ts +2 -236
  60. package/dist/plans/index.js +3 -6
  61. package/dist/push/index.d.ts +2 -79
  62. package/dist/push/index.js +3 -6
  63. package/dist/query-xWqtfkvR.js +35 -0
  64. package/dist/react/hooks.d.ts +157 -100
  65. package/dist/react/hooks.js +862 -406
  66. package/dist/sse-parser-FMjxM7sY.js +86 -0
  67. package/dist/terms/index.d.ts +3 -79
  68. package/dist/terms/index.js +3 -6
  69. package/dist/testing/index.d.ts +52 -104
  70. package/dist/testing/index.js +94 -72
  71. package/dist/types-B-SMkH6s.d.ts +26 -0
  72. package/dist/types-BXDcoJHG.d.ts +131 -0
  73. package/dist/types-BrghN2rJ.d.ts +105 -0
  74. package/dist/types-DjDRszNj.js +11 -0
  75. package/dist/webhooks/index.d.ts +77 -50
  76. package/dist/webhooks/index.js +150 -127
  77. package/docs/api-reference.md +121 -8
  78. package/docs/errors.md +19 -0
  79. package/docs/files.md +165 -7
  80. package/package.json +7 -6
  81. package/dist/chunk-2LSCQHAU.js +0 -21
  82. package/dist/chunk-4U4ZPPL4.js +0 -599
  83. package/dist/chunk-55KHY5GH.js +0 -96
  84. package/dist/chunk-C5VTRZWX.js +0 -458
  85. package/dist/chunk-F7BXBTZI.js +0 -54
  86. package/dist/chunk-FJUCWXX3.js +0 -350
  87. package/dist/chunk-H33OTQEN.js +0 -112
  88. package/dist/chunk-L4DHB36G.js +0 -75
  89. package/dist/chunk-OG7R3UAR.js +0 -105
  90. package/dist/chunk-PF24XU54.js +0 -32
  91. package/dist/chunk-QN3QD67K.js +0 -49
  92. package/dist/chunk-REIKXSMY.js +0 -7
  93. package/dist/chunk-UGBBXCZE.js +0 -157
  94. package/dist/chunk-UVT2E6KD.js +0 -81
  95. package/dist/chunk-YPLT3RFL.js +0 -63
  96. package/dist/chunk-YTKSAWV2.js +0 -463
  97. package/dist/client-BkcO-0C2.d.ts +0 -216
  98. package/dist/client-CN5_tNOC.d.ts +0 -147
  99. package/dist/client-DttyeM_h.d.ts +0 -102
  100. package/dist/config-CtxyJsDR.d.ts +0 -397
  101. package/dist/typed-client-BxOVIiMU.d.ts +0 -40
  102. package/dist/types-6E3ZLL9X.d.ts +0 -24
  103. package/dist/types-DskYLVb8.d.ts +0 -104
  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
@@ -1,79 +1,3 @@
1
- import { q as ReoptSDKConfig } from '../config-CtxyJsDR.js';
2
- import { L as ListTermsOptions, T as TermsItem, f as TermsListResponse, a as ConsentRecord, c as CreateConsentsRequest, d as CreateConsentsResult, W as WithdrawConsentResult } from '../types-DskYLVb8.js';
3
- export { C as ConsentInput, b as ConsentStatus, e as TermsJurisdiction, g as TermsType, h as TermsVersion } from '../types-DskYLVb8.js';
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 };
@@ -1,6 +1,3 @@
1
- export { ReoptTermsClient, createReoptTermsClient } from '../chunk-H33OTQEN.js';
2
- import '../chunk-YTKSAWV2.js';
3
- import '../chunk-2LSCQHAU.js';
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-ByN3EQdk.js";
2
+
3
+ export { ReoptTermsClient, createReoptTermsClient };
@@ -1,110 +1,57 @@
1
- import { DevSchema, SeedData, SeedAllInput, SeedPostGroupInput, SeedPostInput, SeedTermsItem, DevServer } from '../dev/index.js';
2
- import { ReoptSDK } from '../index.js';
3
- import '../types-ckmDDW3N.js';
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-1j_738qk.js";
2
+ import { t as ReoptSDK } from "../index-CeOLGdyL.js";
3
+ //#region src/testing/index.d.ts
57
4
  type TestSDKOptions = {
58
- /** EAV schema to seed entities and attributes */
59
- schema?: DevSchema;
60
- /** BrandApp ID (default: "test-brandapp") */
61
- brandappId?: string;
62
- /** EAV records initial seed (backward-compat). Use `seedAll` for posts/terms. */
63
- seed?: SeedData;
64
- /** Unified initial seed (postGroups, posts, entities, terms). Runs after `seed`. */
65
- seedAll?: SeedAllInput;
66
- /** Convenience shortcut — equivalent to `seedAll: { postGroups }`. */
67
- postGroups?: SeedPostGroupInput[];
68
- /** Convenience shortcut — equivalent to `seedAll: { posts }`. */
69
- posts?: SeedPostInput[];
70
- /** Convenience shortcut — equivalent to `seedAll: { terms }`. */
71
- terms?: SeedTermsItem[];
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
- /** Pre-configured SDK instance pointing to the test server */
75
- sdk: ReoptSDK;
76
- /** The underlying dev server (for seed/reset/snapshot/restore) */
77
- devServer: DevServer;
78
- /** Base URL of the test server */
79
- url: string;
80
- /**
81
- * Reset server data AND recreate the SDK (clears client-side caches).
82
- * Use this in `beforeEach` instead of `devServer.reset()`.
83
- */
84
- resetAll: () => Promise<void>;
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
- /** EAV schema to seed */
88
- schema?: DevSchema;
89
- /** BrandApp ID (default: "test-brandapp") */
90
- brandappId?: string;
91
- /** Initial seed data */
92
- seed?: SeedData;
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
- /** The dev server instance */
96
- devServer: DevServer;
97
- /** Base URL */
98
- url: string;
99
- /** Port */
100
- port: number;
101
- /** SDK config ready to pass to createReoptSDK */
102
- sdkConfig: {
103
- clientId: string;
104
- clientSecret: string;
105
- brandappId: string;
106
- baseUrl: string;
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
- authUserId?: string;
151
- values: Record<string, unknown>;
97
+ authUserId?: string;
98
+ values: Record<string, unknown>;
152
99
  }>>(factories: T): T;
153
-
154
- export { DevSchema, DevServer, SeedAllInput, SeedData, SeedPostGroupInput, SeedPostInput, SeedTermsItem, type TestSDKOptions, type TestSDKResult, type TestServerOptions, type TestServerResult, createFixture, createTestSDK, createTestServer };
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
@@ -1,81 +1,103 @@
1
- // src/testing/index.ts
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
- const {
4
- schema,
5
- brandappId = "test-brandapp",
6
- seed: initialSeed,
7
- seedAll,
8
- postGroups,
9
- posts,
10
- terms
11
- } = options;
12
- const { createDevServer } = await import('../dev/index.js');
13
- const { createReoptSDK } = await import('../index.js');
14
- const devServer = await createDevServer({
15
- port: 0,
16
- // Auto-assign port
17
- brandappId,
18
- schema
19
- });
20
- if (initialSeed) {
21
- await devServer.seed(initialSeed);
22
- }
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) {
30
- await devServer.seedAll(merged);
31
- }
32
- const sdkConfig = {
33
- clientId: "test",
34
- clientSecret: "test",
35
- brandappId,
36
- baseUrl: devServer.url
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
- const { schema, brandappId = "test-brandapp", seed: initialSeed } = options;
54
- const { createDevServer } = await import('../dev/index.js');
55
- const devServer = await createDevServer({
56
- port: 0,
57
- brandappId,
58
- schema
59
- });
60
- if (initialSeed) {
61
- await devServer.seed(initialSeed);
62
- }
63
- return {
64
- devServer,
65
- url: devServer.url,
66
- port: devServer.port,
67
- sdkConfig: {
68
- clientId: "test",
69
- clientSecret: "test",
70
- brandappId,
71
- baseUrl: devServer.url
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
- return factories;
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