@brokr/sdk 1.0.0 → 2.0.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/dist/account.js +34 -0
- package/dist/account.mjs +7 -0
- package/dist/auth.js +628 -114
- package/dist/auth.mjs +611 -111
- package/dist/chat.js +34 -0
- package/dist/chat.mjs +7 -0
- package/dist/events.js +64 -0
- package/dist/events.mjs +37 -0
- package/dist/feature.js +6304 -0
- package/dist/feature.mjs +6278 -0
- package/dist/files.js +428 -0
- package/dist/files.mjs +408 -0
- package/dist/index.d.ts +18 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4069 -454
- package/dist/index.mjs +4040 -448
- package/dist/logs.js +148 -0
- package/dist/logs.mjs +124 -0
- package/dist/management.js +14 -13
- package/dist/management.mjs +14 -13
- package/dist/next.js +2725 -0
- package/dist/next.mjs +2710 -0
- package/dist/notifications.js +140 -0
- package/dist/notifications.mjs +110 -0
- package/dist/payments.js +32 -0
- package/dist/payments.mjs +7 -0
- package/dist/react-notifications.js +286 -0
- package/dist/react-notifications.mjs +254 -0
- package/dist/react-styles.js +2718 -0
- package/dist/react-styles.mjs +2682 -0
- package/dist/react-theme.js +4194 -0
- package/dist/react-theme.mjs +4170 -0
- package/dist/react.js +8512 -209
- package/dist/react.mjs +8488 -179
- package/dist/runtime.js +2113 -385
- package/dist/runtime.mjs +2085 -397
- package/dist/src/account/config.d.ts +42 -0
- package/dist/src/account/config.d.ts.map +1 -0
- package/dist/src/account/index.d.ts +3 -0
- package/dist/src/account/index.d.ts.map +1 -0
- package/dist/src/ai/client.d.ts +58 -0
- package/dist/src/ai/client.d.ts.map +1 -0
- package/dist/src/ai/conversation-title.d.ts +13 -0
- package/dist/src/ai/conversation-title.d.ts.map +1 -0
- package/dist/src/ai/types.d.ts +81 -0
- package/dist/src/ai/types.d.ts.map +1 -0
- package/dist/src/auth.d.ts +133 -20
- package/dist/src/auth.d.ts.map +1 -1
- package/dist/src/chat/config.d.ts +61 -0
- package/dist/src/chat/config.d.ts.map +1 -0
- package/dist/src/chat/index.d.ts +3 -0
- package/dist/src/chat/index.d.ts.map +1 -0
- package/dist/src/chat/sse-parser.d.ts +44 -0
- package/dist/src/chat/sse-parser.d.ts.map +1 -0
- package/dist/src/dev-console.d.ts +18 -0
- package/dist/src/dev-console.d.ts.map +1 -0
- package/dist/src/email/client.d.ts +33 -0
- package/dist/src/email/client.d.ts.map +1 -0
- package/dist/src/email/templates.d.ts +15 -0
- package/dist/src/email/templates.d.ts.map +1 -0
- package/dist/src/email/types.d.ts +35 -0
- package/dist/src/email/types.d.ts.map +1 -0
- package/dist/src/env-detect.d.ts +25 -0
- package/dist/src/env-detect.d.ts.map +1 -0
- package/dist/src/errors.d.ts +53 -0
- package/dist/src/errors.d.ts.map +1 -0
- package/dist/src/events/client.d.ts +25 -0
- package/dist/src/events/client.d.ts.map +1 -0
- package/dist/src/events/index.d.ts +9 -0
- package/dist/src/events/index.d.ts.map +1 -0
- package/dist/src/events/types.d.ts +10 -0
- package/dist/src/events/types.d.ts.map +1 -0
- package/dist/src/feature/canonical.d.ts +33 -0
- package/dist/src/feature/canonical.d.ts.map +1 -0
- package/dist/src/feature/create-feature.d.ts +33 -0
- package/dist/src/feature/create-feature.d.ts.map +1 -0
- package/dist/src/feature/db.d.ts +16 -0
- package/dist/src/feature/db.d.ts.map +1 -0
- package/dist/src/feature/handlers.d.ts +28 -0
- package/dist/src/feature/handlers.d.ts.map +1 -0
- package/dist/src/feature/index.d.ts +21 -0
- package/dist/src/feature/index.d.ts.map +1 -0
- package/dist/src/feature/manifest.d.ts +173 -0
- package/dist/src/feature/manifest.d.ts.map +1 -0
- package/dist/src/feature/mapping.d.ts +18 -0
- package/dist/src/feature/mapping.d.ts.map +1 -0
- package/dist/src/feature/runtime.d.ts +45 -0
- package/dist/src/feature/runtime.d.ts.map +1 -0
- package/dist/src/feature/types.d.ts +65 -0
- package/dist/src/feature/types.d.ts.map +1 -0
- package/dist/src/files/client.d.ts +28 -0
- package/dist/src/files/client.d.ts.map +1 -0
- package/dist/src/files/types.d.ts +28 -0
- package/dist/src/files/types.d.ts.map +1 -0
- package/dist/src/fix-registry.d.ts +8 -0
- package/dist/src/fix-registry.d.ts.map +1 -0
- package/dist/src/gateway.d.ts +32 -0
- package/dist/src/gateway.d.ts.map +1 -0
- package/dist/src/logs/capture.d.ts +56 -0
- package/dist/src/logs/capture.d.ts.map +1 -0
- package/dist/src/logs/index.d.ts +2 -0
- package/dist/src/logs/index.d.ts.map +1 -0
- package/dist/src/management.d.ts +1 -1
- package/dist/src/management.d.ts.map +1 -1
- package/dist/src/models.d.ts +32 -0
- package/dist/src/models.d.ts.map +1 -0
- package/dist/src/next/auth.d.ts +54 -0
- package/dist/src/next/auth.d.ts.map +1 -0
- package/dist/src/next/chat.d.ts +31 -0
- package/dist/src/next/chat.d.ts.map +1 -0
- package/dist/src/next/index.d.ts +14 -0
- package/dist/src/next/index.d.ts.map +1 -0
- package/dist/src/next/notifications.d.ts +67 -0
- package/dist/src/next/notifications.d.ts.map +1 -0
- package/dist/src/notifications/built-ins.d.ts +9 -0
- package/dist/src/notifications/built-ins.d.ts.map +1 -0
- package/dist/src/notifications/client.d.ts +38 -0
- package/dist/src/notifications/client.d.ts.map +1 -0
- package/dist/src/notifications/config.d.ts +71 -0
- package/dist/src/notifications/config.d.ts.map +1 -0
- package/dist/src/notifications/index.d.ts +6 -0
- package/dist/src/notifications/index.d.ts.map +1 -0
- package/dist/src/notifications/registry.d.ts +67 -0
- package/dist/src/notifications/registry.d.ts.map +1 -0
- package/dist/src/notifications/types.d.ts +48 -0
- package/dist/src/notifications/types.d.ts.map +1 -0
- package/dist/src/payments/client.d.ts +64 -0
- package/dist/src/payments/client.d.ts.map +1 -0
- package/dist/src/payments/config.d.ts +46 -0
- package/dist/src/payments/config.d.ts.map +1 -0
- package/dist/src/payments/entitlements.d.ts +48 -0
- package/dist/src/payments/entitlements.d.ts.map +1 -0
- package/dist/src/payments/types.d.ts +135 -0
- package/dist/src/payments/types.d.ts.map +1 -0
- package/dist/src/react/BrokrErrorBoundary.d.ts +23 -0
- package/dist/src/react/BrokrErrorBoundary.d.ts.map +1 -0
- package/dist/src/react/account/AccountPanel.d.ts +12 -0
- package/dist/src/react/account/AccountPanel.d.ts.map +1 -0
- package/dist/src/react/account/Avatar.d.ts +11 -0
- package/dist/src/react/account/Avatar.d.ts.map +1 -0
- package/dist/src/react/account/ProfilePhotoButton.d.ts +7 -0
- package/dist/src/react/account/ProfilePhotoButton.d.ts.map +1 -0
- package/dist/src/react/account/UserButton.d.ts +7 -0
- package/dist/src/react/account/UserButton.d.ts.map +1 -0
- package/dist/src/react/auth-pages/AuthPageShell.d.ts +9 -0
- package/dist/src/react/auth-pages/AuthPageShell.d.ts.map +1 -0
- package/dist/src/react/auth-pages/SignInPage.d.ts +9 -0
- package/dist/src/react/auth-pages/SignInPage.d.ts.map +1 -0
- package/dist/src/react/auth-pages/SignUpPage.d.ts +8 -0
- package/dist/src/react/auth-pages/SignUpPage.d.ts.map +1 -0
- package/dist/src/react/auth.d.ts +1 -49
- package/dist/src/react/auth.d.ts.map +1 -1
- package/dist/src/react/chat/AIChat.d.ts +4 -0
- package/dist/src/react/chat/AIChat.d.ts.map +1 -0
- package/dist/src/react/chat/ChatContext.d.ts +76 -0
- package/dist/src/react/chat/ChatContext.d.ts.map +1 -0
- package/dist/src/react/chat/ChatInput.d.ts +3 -0
- package/dist/src/react/chat/ChatInput.d.ts.map +1 -0
- package/dist/src/react/chat/MarkdownRenderer.d.ts +5 -0
- package/dist/src/react/chat/MarkdownRenderer.d.ts.map +1 -0
- package/dist/src/react/chat/MessageBubble.d.ts +14 -0
- package/dist/src/react/chat/MessageBubble.d.ts.map +1 -0
- package/dist/src/react/chat/MessagePane.d.ts +10 -0
- package/dist/src/react/chat/MessagePane.d.ts.map +1 -0
- package/dist/src/react/chat/ModelSelector.d.ts +13 -0
- package/dist/src/react/chat/ModelSelector.d.ts.map +1 -0
- package/dist/src/react/chat/ThreadSidebar.d.ts +3 -0
- package/dist/src/react/chat/ThreadSidebar.d.ts.map +1 -0
- package/dist/src/react/chat/index.d.ts +5 -0
- package/dist/src/react/chat/index.d.ts.map +1 -0
- package/dist/src/react/chat/token-limit.d.ts +14 -0
- package/dist/src/react/chat/token-limit.d.ts.map +1 -0
- package/dist/src/react/chat/types.d.ts +65 -0
- package/dist/src/react/chat/types.d.ts.map +1 -0
- package/dist/src/react/chat/useChat.d.ts +57 -0
- package/dist/src/react/chat/useChat.d.ts.map +1 -0
- package/dist/src/react/composites/FabAI.d.ts +15 -0
- package/dist/src/react/composites/FabAI.d.ts.map +1 -0
- package/dist/src/react/composites/FeedbackWidget.d.ts +10 -0
- package/dist/src/react/composites/FeedbackWidget.d.ts.map +1 -0
- package/dist/src/react/composites/SmartUpload.d.ts +12 -0
- package/dist/src/react/composites/SmartUpload.d.ts.map +1 -0
- package/dist/src/react/config.d.ts +23 -0
- package/dist/src/react/config.d.ts.map +1 -0
- package/dist/src/react/context.d.ts +4 -0
- package/dist/src/react/context.d.ts.map +1 -0
- package/dist/src/react/css/account.d.ts +2 -0
- package/dist/src/react/css/account.d.ts.map +1 -0
- package/dist/src/react/css/animations.d.ts +2 -0
- package/dist/src/react/css/animations.d.ts.map +1 -0
- package/dist/src/react/css/auth.d.ts +2 -0
- package/dist/src/react/css/auth.d.ts.map +1 -0
- package/dist/src/react/css/chat-extras.d.ts +2 -0
- package/dist/src/react/css/chat-extras.d.ts.map +1 -0
- package/dist/src/react/css/chat.d.ts +2 -0
- package/dist/src/react/css/chat.d.ts.map +1 -0
- package/dist/src/react/css/composites.d.ts +2 -0
- package/dist/src/react/css/composites.d.ts.map +1 -0
- package/dist/src/react/css/gates.d.ts +2 -0
- package/dist/src/react/css/gates.d.ts.map +1 -0
- package/dist/src/react/css/index.d.ts +3 -0
- package/dist/src/react/css/index.d.ts.map +1 -0
- package/dist/src/react/css/markdown.d.ts +2 -0
- package/dist/src/react/css/markdown.d.ts.map +1 -0
- package/dist/src/react/css/notifications.d.ts +2 -0
- package/dist/src/react/css/notifications.d.ts.map +1 -0
- package/dist/src/react/css/primitives.d.ts +2 -0
- package/dist/src/react/css/primitives.d.ts.map +1 -0
- package/dist/src/react/css/reset.d.ts +2 -0
- package/dist/src/react/css/reset.d.ts.map +1 -0
- package/dist/src/react/css/responsive.d.ts +2 -0
- package/dist/src/react/css/responsive.d.ts.map +1 -0
- package/dist/src/react/css/skeleton.d.ts +2 -0
- package/dist/src/react/css/skeleton.d.ts.map +1 -0
- package/dist/src/react/css/tokens.d.ts +2 -0
- package/dist/src/react/css/tokens.d.ts.map +1 -0
- package/dist/src/react/gates/AuthWall.d.ts +7 -0
- package/dist/src/react/gates/AuthWall.d.ts.map +1 -0
- package/dist/src/react/gates/BillingBoundary.d.ts +4 -0
- package/dist/src/react/gates/BillingBoundary.d.ts.map +1 -0
- package/dist/src/react/gates/Gate.d.ts +9 -0
- package/dist/src/react/gates/Gate.d.ts.map +1 -0
- package/dist/src/react/gates/RequirePlan.d.ts +4 -0
- package/dist/src/react/gates/RequirePlan.d.ts.map +1 -0
- package/dist/src/react/gates/RequireUser.d.ts +4 -0
- package/dist/src/react/gates/RequireUser.d.ts.map +1 -0
- package/dist/src/react/gates/UsageGate.d.ts +4 -0
- package/dist/src/react/gates/UsageGate.d.ts.map +1 -0
- package/dist/src/react/helpers.d.ts +7 -0
- package/dist/src/react/helpers.d.ts.map +1 -0
- package/dist/src/react/hooks/use-theme.d.ts +15 -0
- package/dist/src/react/hooks/use-theme.d.ts.map +1 -0
- package/dist/src/react/hooks/use-user.d.ts +12 -0
- package/dist/src/react/hooks/use-user.d.ts.map +1 -0
- package/dist/src/react/icons.d.ts +26 -0
- package/dist/src/react/icons.d.ts.map +1 -0
- package/dist/src/react/index.d.ts +48 -0
- package/dist/src/react/index.d.ts.map +1 -0
- package/dist/src/react/notifications/NotificationBell.d.ts +7 -0
- package/dist/src/react/notifications/NotificationBell.d.ts.map +1 -0
- package/dist/src/react/notifications/NotificationList.d.ts +7 -0
- package/dist/src/react/notifications/NotificationList.d.ts.map +1 -0
- package/dist/src/react/notifications/Toast.d.ts +13 -0
- package/dist/src/react/notifications/Toast.d.ts.map +1 -0
- package/dist/src/react/notifications/index.d.ts +8 -0
- package/dist/src/react/notifications/index.d.ts.map +1 -0
- package/dist/src/react/notifications/provider.d.ts +14 -0
- package/dist/src/react/notifications/provider.d.ts.map +1 -0
- package/dist/src/react/notifications/use-notifications.d.ts +24 -0
- package/dist/src/react/notifications/use-notifications.d.ts.map +1 -0
- package/dist/src/react/payments/AutoReloadToggle.d.ts +6 -0
- package/dist/src/react/payments/AutoReloadToggle.d.ts.map +1 -0
- package/dist/src/react/payments/Balance.d.ts +8 -0
- package/dist/src/react/payments/Balance.d.ts.map +1 -0
- package/dist/src/react/payments/CancelSubscription.d.ts +6 -0
- package/dist/src/react/payments/CancelSubscription.d.ts.map +1 -0
- package/dist/src/react/payments/CheckoutButton.d.ts +7 -0
- package/dist/src/react/payments/CheckoutButton.d.ts.map +1 -0
- package/dist/src/react/payments/CustomerPortalButton.d.ts +6 -0
- package/dist/src/react/payments/CustomerPortalButton.d.ts.map +1 -0
- package/dist/src/react/payments/FeatureMeter.d.ts +6 -0
- package/dist/src/react/payments/FeatureMeter.d.ts.map +1 -0
- package/dist/src/react/payments/Plans.d.ts +8 -0
- package/dist/src/react/payments/Plans.d.ts.map +1 -0
- package/dist/src/react/payments/TopUpButton.d.ts +8 -0
- package/dist/src/react/payments/TopUpButton.d.ts.map +1 -0
- package/dist/src/react/payments/UpdateBilling.d.ts +3 -0
- package/dist/src/react/payments/UpdateBilling.d.ts.map +1 -0
- package/dist/src/react/payments/UpgradePrompt.d.ts +8 -0
- package/dist/src/react/payments/UpgradePrompt.d.ts.map +1 -0
- package/dist/src/react/primitives/Skeleton.d.ts +15 -0
- package/dist/src/react/primitives/Skeleton.d.ts.map +1 -0
- package/dist/src/react/provider.d.ts +21 -0
- package/dist/src/react/provider.d.ts.map +1 -0
- package/dist/src/react/request.d.ts +2 -0
- package/dist/src/react/request.d.ts.map +1 -0
- package/dist/src/react/styles-entry.d.ts +4 -0
- package/dist/src/react/styles-entry.d.ts.map +1 -0
- package/dist/src/react/styles.d.ts +2 -0
- package/dist/src/react/styles.d.ts.map +1 -0
- package/dist/src/react/theme-entry.d.ts +3 -0
- package/dist/src/react/theme-entry.d.ts.map +1 -0
- package/dist/src/react/theme.d.ts +6 -0
- package/dist/src/react/theme.d.ts.map +1 -0
- package/dist/src/react/types.d.ts +191 -0
- package/dist/src/react/types.d.ts.map +1 -0
- package/dist/src/react/use-brokr-theme.d.ts +6 -0
- package/dist/src/react/use-brokr-theme.d.ts.map +1 -0
- package/dist/src/runtime.d.ts +69 -180
- package/dist/src/runtime.d.ts.map +1 -1
- package/dist/src/storage/client.d.ts +113 -0
- package/dist/src/storage/client.d.ts.map +1 -0
- package/dist/src/storage/types.d.ts +60 -0
- package/dist/src/storage/types.d.ts.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +2 -2
- package/dist/types.d.ts.map +1 -1
- package/package.json +70 -9
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles-entry.d.ts","sourceRoot":"","sources":["../../../src/react/styles-entry.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,wBAAgB,WAAW,sBAE1B;AAED,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"styles.d.ts","sourceRoot":"","sources":["../../../src/react/styles.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { defaultBrokrTheme, getBrokrRootStyle, resolveBrokrTheme } from './theme';
|
|
2
|
+
export { defineBrokrTheme, type BrokrThemeColors, type BrokrThemeDef, type BrokrThemeMode, type BrokrThemeRadii, type BrokrThemeResolved, } from './types';
|
|
3
|
+
//# sourceMappingURL=theme-entry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme-entry.d.ts","sourceRoot":"","sources":["../../../src/react/theme-entry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAClF,OAAO,EACL,gBAAgB,EAChB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,kBAAkB,GACxB,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { CSSProperties } from 'react';
|
|
2
|
+
import { type BrokrThemeDef, type BrokrThemeResolved } from './types';
|
|
3
|
+
export declare const defaultBrokrTheme: BrokrThemeDef;
|
|
4
|
+
export declare function resolveBrokrTheme(theme: BrokrThemeDef, mode: 'light' | 'dark'): BrokrThemeResolved;
|
|
5
|
+
export declare function getBrokrRootStyle(theme: BrokrThemeResolved): CSSProperties;
|
|
6
|
+
//# sourceMappingURL=theme.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"theme.d.ts","sourceRoot":"","sources":["../../../src/react/theme.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAoB,KAAK,aAAa,EAAE,KAAK,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAIxF,eAAO,MAAM,iBAAiB,eA2C5B,CAAC;AAEH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,aAAa,EACpB,IAAI,EAAE,OAAO,GAAG,MAAM,GACrB,kBAAkB,CAEpB;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,kBAAkB,GAAG,aAAa,CA0B1E"}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Brokr SDK — React type contracts
|
|
3
|
+
*
|
|
4
|
+
* *** CODEX CONTRACT ***
|
|
5
|
+
*
|
|
6
|
+
* These types define the exact shape that BrokrProvider exposes via context,
|
|
7
|
+
* the theme system, and the gate component props. Codex builds the React
|
|
8
|
+
* components; this file is their source of truth.
|
|
9
|
+
*
|
|
10
|
+
* DO NOT modify these types without coordinating with the UI track.
|
|
11
|
+
*/
|
|
12
|
+
import type { UserPlan, EntitlementMap, PlanCatalogEntry, BillingSummary } from '../payments/types';
|
|
13
|
+
import type { BrokrConfig } from './config';
|
|
14
|
+
export interface BrokrUser {
|
|
15
|
+
id: string;
|
|
16
|
+
email: string;
|
|
17
|
+
name?: string;
|
|
18
|
+
image?: string;
|
|
19
|
+
emailVerified: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface BrokrSession {
|
|
22
|
+
id: string;
|
|
23
|
+
/** When the session was created. */
|
|
24
|
+
createdAt: Date;
|
|
25
|
+
/** When the session expires. */
|
|
26
|
+
expiresAt: Date;
|
|
27
|
+
/** User agent string (browser/device info). */
|
|
28
|
+
userAgent?: string;
|
|
29
|
+
/** IP address (last known). */
|
|
30
|
+
ipAddress?: string;
|
|
31
|
+
/** Whether this is the current session. */
|
|
32
|
+
isCurrent: boolean;
|
|
33
|
+
}
|
|
34
|
+
export interface SignInParams {
|
|
35
|
+
email: string;
|
|
36
|
+
password: string;
|
|
37
|
+
}
|
|
38
|
+
export interface SignUpParams {
|
|
39
|
+
email: string;
|
|
40
|
+
password: string;
|
|
41
|
+
name?: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* The shape exposed by BrokrProvider via React context.
|
|
45
|
+
*
|
|
46
|
+
* Design principles:
|
|
47
|
+
* - Provider owns cross-cutting state: auth, theme, billing, entitlements.
|
|
48
|
+
* - Only UI-facing data and actions — no raw API responses.
|
|
49
|
+
* - Composite components (FabAI, SmartUpload, FeedbackWidget) are self-contained
|
|
50
|
+
* but context-aware — they read from this context, they don't add to it.
|
|
51
|
+
*/
|
|
52
|
+
export interface BrokrContextValue {
|
|
53
|
+
user: BrokrUser | null;
|
|
54
|
+
session: {
|
|
55
|
+
sessionId: string;
|
|
56
|
+
expiresAt: Date;
|
|
57
|
+
} | null;
|
|
58
|
+
isLoaded: boolean;
|
|
59
|
+
/** Current user's plan. */
|
|
60
|
+
plan: UserPlan | null;
|
|
61
|
+
/** Full plan catalog for UI (Plans grid, upgrade prompts). */
|
|
62
|
+
plans: PlanCatalogEntry[];
|
|
63
|
+
/** Per-feature entitlement map. */
|
|
64
|
+
entitlements: EntitlementMap | null;
|
|
65
|
+
/** Billing summary (payment method, balance, auto-reload). */
|
|
66
|
+
billing: BillingSummary | null;
|
|
67
|
+
/** Whether payments are in sandbox or live mode. */
|
|
68
|
+
paymentsMode: 'sandbox' | 'live' | null;
|
|
69
|
+
/** Active sessions for the current user (for AccountPanel). */
|
|
70
|
+
sessions: BrokrSession[];
|
|
71
|
+
theme: BrokrThemeResolved;
|
|
72
|
+
mode: 'light' | 'dark';
|
|
73
|
+
config?: BrokrConfig;
|
|
74
|
+
signIn: (params: SignInParams) => Promise<void>;
|
|
75
|
+
signUp: (params: SignUpParams) => Promise<void>;
|
|
76
|
+
signOut: () => Promise<void>;
|
|
77
|
+
/** Update user profile fields (name, etc.). Refreshes context.user on success. */
|
|
78
|
+
updateProfile: (params: {
|
|
79
|
+
name?: string;
|
|
80
|
+
}) => Promise<void>;
|
|
81
|
+
/** Upload and set a new profile photo. Refreshes context.user.image on success. */
|
|
82
|
+
updateProfilePhoto: (file: File) => Promise<void>;
|
|
83
|
+
/** Revoke a specific session by ID. Refreshes context.sessions. */
|
|
84
|
+
revokeSession: (sessionId: string) => Promise<void>;
|
|
85
|
+
/** Revoke all sessions except the current one. Refreshes context.sessions. */
|
|
86
|
+
revokeOtherSessions: () => Promise<void>;
|
|
87
|
+
/** Start checkout for a plan. Returns checkout URL — caller should redirect. */
|
|
88
|
+
checkout: (params: {
|
|
89
|
+
plan: string;
|
|
90
|
+
}) => Promise<string>;
|
|
91
|
+
/** Open Stripe Customer Portal. Returns portal URL — caller should redirect. */
|
|
92
|
+
portal: () => Promise<string>;
|
|
93
|
+
/** Check if current user has access to a feature. Synchronous, reads from context. */
|
|
94
|
+
can: (feature: string) => boolean;
|
|
95
|
+
/** Get usage stats for a metered feature. Synchronous, reads from context. */
|
|
96
|
+
usage: (feature: string) => {
|
|
97
|
+
used: number;
|
|
98
|
+
limit: number | null;
|
|
99
|
+
remaining: number | null;
|
|
100
|
+
} | null;
|
|
101
|
+
/** Re-fetch all context state (auth, billing). Call after external changes. */
|
|
102
|
+
refresh: () => Promise<void>;
|
|
103
|
+
/** Fetch active sessions list. Only call from account/settings UI — not on every page. */
|
|
104
|
+
refreshSessions: () => Promise<void>;
|
|
105
|
+
}
|
|
106
|
+
export interface BrokrThemeColors {
|
|
107
|
+
bg: string;
|
|
108
|
+
surface: string;
|
|
109
|
+
surfaceMuted: string;
|
|
110
|
+
textPrimary: string;
|
|
111
|
+
textSecondary: string;
|
|
112
|
+
border: string;
|
|
113
|
+
primary: string;
|
|
114
|
+
primaryContrast: string;
|
|
115
|
+
/** Optional semantic color for error states. If omitted, use primary at reduced opacity. */
|
|
116
|
+
error?: string;
|
|
117
|
+
/** Optional semantic color for success states. If omitted, use primary at reduced opacity. */
|
|
118
|
+
success?: string;
|
|
119
|
+
/** Optional semantic color for warning states. If omitted, use primary at reduced opacity. */
|
|
120
|
+
warning?: string;
|
|
121
|
+
/** Toast background. Defaults to #ffffff (white in both modes — pops against any background). */
|
|
122
|
+
toastBg?: string;
|
|
123
|
+
/** Toast text color. Defaults to #0a0a0a. */
|
|
124
|
+
toastText?: string;
|
|
125
|
+
/** Toast secondary text color. Defaults to #52525b. */
|
|
126
|
+
toastTextSecondary?: string;
|
|
127
|
+
/** Toast border color. Defaults to #e4e4e7. */
|
|
128
|
+
toastBorder?: string;
|
|
129
|
+
}
|
|
130
|
+
export interface BrokrThemeRadii {
|
|
131
|
+
card: number;
|
|
132
|
+
input: number;
|
|
133
|
+
button: number;
|
|
134
|
+
}
|
|
135
|
+
export interface BrokrThemeMode {
|
|
136
|
+
brand: {
|
|
137
|
+
name: string;
|
|
138
|
+
logo?: string;
|
|
139
|
+
};
|
|
140
|
+
auth?: {
|
|
141
|
+
variant?: number | `${number}`;
|
|
142
|
+
heroImage?: string;
|
|
143
|
+
heroText?: string;
|
|
144
|
+
};
|
|
145
|
+
colors: BrokrThemeColors;
|
|
146
|
+
radii: BrokrThemeRadii;
|
|
147
|
+
}
|
|
148
|
+
export interface BrokrThemeDef {
|
|
149
|
+
light: BrokrThemeMode;
|
|
150
|
+
dark: BrokrThemeMode;
|
|
151
|
+
}
|
|
152
|
+
/** The resolved theme for the current mode (light or dark). */
|
|
153
|
+
export type BrokrThemeResolved = BrokrThemeMode;
|
|
154
|
+
/**
|
|
155
|
+
* Define the Brokr theme for your app.
|
|
156
|
+
* Type-checked passthrough — used by BrokrProvider to resolve the current mode.
|
|
157
|
+
*/
|
|
158
|
+
export declare function defineBrokrTheme(def: BrokrThemeDef): BrokrThemeDef;
|
|
159
|
+
/**
|
|
160
|
+
* Gate fallback modes (v1).
|
|
161
|
+
*
|
|
162
|
+
* Only modes we actually ship primitives for. No modal/toast until
|
|
163
|
+
* the SDK owns those primitives.
|
|
164
|
+
*
|
|
165
|
+
* - 'redirect' — router.push(redirectTo)
|
|
166
|
+
* - 'upgrade-card' — inline card with plan comparison + CTA
|
|
167
|
+
* - 'hidden' — render nothing (no visual feedback)
|
|
168
|
+
* - React.ReactNode — custom fallback UI
|
|
169
|
+
*/
|
|
170
|
+
export type GateFallback = 'redirect' | 'upgrade-card' | 'hidden' | React.ReactNode;
|
|
171
|
+
export interface GateProps {
|
|
172
|
+
/** What to show when the gate blocks access. */
|
|
173
|
+
fallback?: GateFallback;
|
|
174
|
+
/** Custom message for the fallback UI. */
|
|
175
|
+
message?: string;
|
|
176
|
+
/** Redirect destination (used when fallback='redirect'). */
|
|
177
|
+
redirectTo?: string;
|
|
178
|
+
children: React.ReactNode;
|
|
179
|
+
}
|
|
180
|
+
export interface RequirePlanProps extends GateProps {
|
|
181
|
+
/** Plan slugs that grant access. */
|
|
182
|
+
plans: string[];
|
|
183
|
+
}
|
|
184
|
+
export interface UsageGateProps extends GateProps {
|
|
185
|
+
/** Feature slug to check usage for. */
|
|
186
|
+
feature: string;
|
|
187
|
+
/** Minimum remaining usage required (default: 1). */
|
|
188
|
+
min?: number;
|
|
189
|
+
}
|
|
190
|
+
export type { UserPlan, EntitlementMap, PlanCatalogEntry, BillingSummary, } from '../payments/types';
|
|
191
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/react/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EACV,QAAQ,EACR,cAAc,EACd,gBAAgB,EAChB,cAAc,EACf,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAO5C,MAAM,WAAW,SAAS;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,oCAAoC;IACpC,SAAS,EAAE,IAAI,CAAC;IAChB,gCAAgC;IAChC,SAAS,EAAE,IAAI,CAAC;IAChB,+CAA+C;IAC/C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,+BAA+B;IAC/B,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2CAA2C;IAC3C,SAAS,EAAE,OAAO,CAAC;CACpB;AAMD,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM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EAAE,MAAM,CAAC;IACpB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B;AAED,MAAM,WAAW,gBAAiB,SAAQ,SAAS;IACjD,oCAAoC;IACpC,KAAK,EAAE,MAAM,EAAE,CAAC;CACjB;AAED,MAAM,WAAW,cAAe,SAAQ,SAAS;IAC/C,uCAAuC;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,qDAAqD;IACrD,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAMD,YAAY,EACV,QAAQ,EACR,cAAc,EACd,gBAAgB,EAChB,cAAc,GACf,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-brokr-theme.d.ts","sourceRoot":"","sources":["../../../src/react/use-brokr-theme.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAElD,wBAAgB,aAAa,IAAI;IAAE,KAAK,EAAE,kBAAkB,CAAC;IAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAAA;CAAE,CAGrF"}
|
package/dist/src/runtime.d.ts
CHANGED
|
@@ -11,207 +11,96 @@
|
|
|
11
11
|
* import { createBrokr } from '@brokr/sdk';
|
|
12
12
|
* export const brokr = createBrokr();
|
|
13
13
|
*
|
|
14
|
-
* //
|
|
15
|
-
* const reply = await brokr.
|
|
16
|
-
* const
|
|
17
|
-
* await brokr.
|
|
14
|
+
* // Root aliases
|
|
15
|
+
* const reply = await brokr.chat('Explain quantum computing');
|
|
16
|
+
* const file = await brokr.upload({ file: buffer, path: 'photo.jpg' });
|
|
17
|
+
* const { checkoutUrl } = await brokr.purchase({ plan: 'pro' });
|
|
18
|
+
*
|
|
19
|
+
* // Namespaces
|
|
20
|
+
* const data = await brokr.ai.structured({ prompt: '...', schema: { ... } });
|
|
21
|
+
* await brokr.email.sendTemplate({ template: 'welcome', to: '...', variables: { ... } });
|
|
18
22
|
* ```
|
|
19
23
|
*/
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
export
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
};
|
|
49
|
-
export
|
|
50
|
-
role: 'user' | 'assistant' | 'system';
|
|
51
|
-
content: string;
|
|
52
|
-
}
|
|
53
|
-
export interface ChatOptions {
|
|
54
|
-
model?: string;
|
|
55
|
-
maxTokens?: number;
|
|
56
|
-
temperature?: number;
|
|
57
|
-
}
|
|
58
|
-
export interface ChatResponse {
|
|
59
|
-
content: string;
|
|
60
|
-
model: string;
|
|
61
|
-
usage: {
|
|
62
|
-
promptTokens: number;
|
|
63
|
-
completionTokens: number;
|
|
64
|
-
};
|
|
65
|
-
}
|
|
66
|
-
export interface UploadResult {
|
|
67
|
-
/** The stable object key — use this to retrieve the file later. */
|
|
68
|
-
key: string;
|
|
69
|
-
}
|
|
70
|
-
export interface EmailParams {
|
|
71
|
-
to: string | string[];
|
|
72
|
-
subject: string;
|
|
73
|
-
html?: string;
|
|
74
|
-
text?: string;
|
|
75
|
-
/**
|
|
76
|
-
* Override the from address. Must be on your stack's verified domain.
|
|
77
|
-
* Defaults to noreply@{your stack domain}.
|
|
78
|
-
*/
|
|
79
|
-
from?: string;
|
|
80
|
-
}
|
|
24
|
+
import { BrokrAIClient } from './ai/client';
|
|
25
|
+
import { BrokrStorageClient } from './storage/client';
|
|
26
|
+
import { BrokrEmailClient } from './email/client';
|
|
27
|
+
import { BrokrFilesClient } from './files/client';
|
|
28
|
+
import { BrokrPaymentsClient } from './payments/client';
|
|
29
|
+
import { BrokrEntitlementsClient } from './payments/entitlements';
|
|
30
|
+
import { BrokrNotificationsClient } from './notifications/client';
|
|
31
|
+
import { BrokrAuthClient } from './auth';
|
|
32
|
+
import type { ChatInput, ChatOptions, ChatResponse } from './ai/types';
|
|
33
|
+
import type { UploadParams } from './storage/types';
|
|
34
|
+
import type { UploadedFile } from './storage/types';
|
|
35
|
+
import type { CheckoutResult } from './payments/types';
|
|
36
|
+
export { GATEWAY_URL } from './gateway';
|
|
37
|
+
export { detectEnv, isDev, isStaging, isProd } from './env-detect';
|
|
38
|
+
export type { BrokrEnv } from './env-detect';
|
|
39
|
+
export { BrokrError, BrokrAuthError, BrokrRateLimitError, BrokrNetworkError, BrokrTimeoutError, BrokrNotFoundError, BrokrValidationError } from './errors';
|
|
40
|
+
export { models } from './models';
|
|
41
|
+
export { BrokrAIClient } from './ai/client';
|
|
42
|
+
export { BrokrStorageClient } from './storage/client';
|
|
43
|
+
export { BrokrEmailClient } from './email/client';
|
|
44
|
+
export { BrokrFilesClient } from './files/client';
|
|
45
|
+
export { BrokrPaymentsClient } from './payments/client';
|
|
46
|
+
export { BrokrEntitlementsClient } from './payments/entitlements';
|
|
47
|
+
export { BrokrNotificationsClient } from './notifications/client';
|
|
48
|
+
export type { ChatMessage, ChatOptions, ChatResponse, ChatInput, ChatContentPart } from './ai/types';
|
|
49
|
+
export type { StorageFile, UploadedFile, UploadParams, UploadResult } from './storage/types';
|
|
50
|
+
export type { EmailParams, SendTemplateParams } from './email/types';
|
|
51
|
+
export type { CheckoutResult, PortalResult, UserPlan, EntitlementMap, PaymentsConfig, GatingContext, PlanCatalogEntry, BillingSummary } from './payments/types';
|
|
52
|
+
export type { Notification } from './notifications/types';
|
|
53
|
+
export type { SendParams as NotificationSendParams, ListParams as NotificationListParams } from './notifications/client';
|
|
81
54
|
export interface RuntimeOptions {
|
|
82
55
|
/** Override the BROKR_TOKEN env var. Useful for testing. */
|
|
83
56
|
token?: string;
|
|
84
57
|
/** Override the gateway URL. Defaults to https://api.brokr.sh */
|
|
85
58
|
gatewayUrl?: string;
|
|
86
59
|
}
|
|
87
|
-
export declare class
|
|
88
|
-
private readonly _token;
|
|
89
|
-
private readonly _gatewayUrl;
|
|
90
|
-
constructor(_token: string | undefined, _gatewayUrl: string);
|
|
91
|
-
/**
|
|
92
|
-
* Send a chat completion request.
|
|
93
|
-
*
|
|
94
|
-
* @example
|
|
95
|
-
* ```typescript
|
|
96
|
-
* const reply = await brokr.ai.chat([
|
|
97
|
-
* { role: 'user', content: 'Explain quantum computing in one sentence.' }
|
|
98
|
-
* ]);
|
|
99
|
-
* console.log(reply.content);
|
|
100
|
-
* ```
|
|
101
|
-
*/
|
|
102
|
-
chat(messages: ChatMessage[], options?: ChatOptions): Promise<ChatResponse>;
|
|
103
|
-
/**
|
|
104
|
-
* Stream a chat completion. Yields text strings directly.
|
|
105
|
-
*
|
|
106
|
-
* @example
|
|
107
|
-
* ```typescript
|
|
108
|
-
* for await (const text of brokr.ai.stream(messages)) {
|
|
109
|
-
* process.stdout.write(text);
|
|
110
|
-
* }
|
|
111
|
-
* ```
|
|
112
|
-
*/
|
|
113
|
-
stream(messages: ChatMessage[], options?: ChatOptions): AsyncGenerator<string>;
|
|
114
|
-
/**
|
|
115
|
-
* OpenAI-SDK compatible base URL.
|
|
116
|
-
*
|
|
117
|
-
* @example
|
|
118
|
-
* ```typescript
|
|
119
|
-
* const openai = new OpenAI({ baseURL: brokr.ai.baseURL, apiKey: brokr.ai.apiKey });
|
|
120
|
-
* ```
|
|
121
|
-
*/
|
|
122
|
-
get baseURL(): string;
|
|
123
|
-
/** Use as `apiKey` with the official OpenAI SDK to route through Brokr's gateway. */
|
|
124
|
-
get apiKey(): string;
|
|
125
|
-
}
|
|
126
|
-
export declare class BrokrStorageClient {
|
|
127
|
-
private readonly _token;
|
|
128
|
-
private readonly _gatewayUrl;
|
|
129
|
-
constructor(_token: string | undefined, _gatewayUrl: string);
|
|
130
|
-
/**
|
|
131
|
-
* Get a presigned upload URL for browser-direct or streaming uploads.
|
|
132
|
-
*
|
|
133
|
-
* @example
|
|
134
|
-
* ```typescript
|
|
135
|
-
* const { url, key } = await brokr.storage.getUploadUrl('avatar.png', 'image/png');
|
|
136
|
-
* await fetch(url, { method: 'PUT', body: file });
|
|
137
|
-
* ```
|
|
138
|
-
*/
|
|
139
|
-
getUploadUrl(filename: string, contentType?: string): Promise<{
|
|
140
|
-
url: string;
|
|
141
|
-
key: string;
|
|
142
|
-
}>;
|
|
143
|
-
/**
|
|
144
|
-
* Upload data to R2. Returns the stable object key.
|
|
145
|
-
*
|
|
146
|
-
* @example
|
|
147
|
-
* ```typescript
|
|
148
|
-
* const { key } = await brokr.storage.upload(fileBuffer, 'photo.jpg', 'image/jpeg');
|
|
149
|
-
* ```
|
|
150
|
-
*/
|
|
151
|
-
upload(data: Uint8Array | string | Blob, filename: string, contentType?: string): Promise<UploadResult>;
|
|
152
|
-
/**
|
|
153
|
-
* Get a presigned download URL for a stored object.
|
|
154
|
-
*
|
|
155
|
-
* @example
|
|
156
|
-
* ```typescript
|
|
157
|
-
* const { url } = await brokr.storage.url('photos/avatar.jpg');
|
|
158
|
-
* // use url in <img src={url} /> or redirect
|
|
159
|
-
* ```
|
|
160
|
-
*/
|
|
161
|
-
url(key: string, options?: {
|
|
162
|
-
expiresIn?: number;
|
|
163
|
-
}): Promise<{
|
|
164
|
-
url: string;
|
|
165
|
-
}>;
|
|
166
|
-
/** @deprecated Use `url()` instead. */
|
|
167
|
-
getUrl(key: string, options?: {
|
|
168
|
-
expiresIn?: number;
|
|
169
|
-
}): Promise<{
|
|
170
|
-
url: string;
|
|
171
|
-
}>;
|
|
172
|
-
}
|
|
173
|
-
export declare class BrokrEmailClient {
|
|
60
|
+
export declare class BrokrRuntime {
|
|
174
61
|
private readonly _token;
|
|
175
62
|
private readonly _gatewayUrl;
|
|
176
|
-
constructor(_token: string | undefined, _gatewayUrl: string);
|
|
177
|
-
/**
|
|
178
|
-
* Send an email. The from address and API credentials are resolved server-side.
|
|
179
|
-
*
|
|
180
|
-
* @example
|
|
181
|
-
* ```typescript
|
|
182
|
-
* await brokr.email.send({
|
|
183
|
-
* to: 'user@example.com',
|
|
184
|
-
* subject: 'Welcome!',
|
|
185
|
-
* html: '<h1>Welcome to the app</h1>',
|
|
186
|
-
* });
|
|
187
|
-
* ```
|
|
188
|
-
*/
|
|
189
|
-
send(params: EmailParams): Promise<{
|
|
190
|
-
id: string;
|
|
191
|
-
}>;
|
|
192
|
-
}
|
|
193
|
-
export declare class BrokrRuntime {
|
|
194
63
|
readonly ai: BrokrAIClient;
|
|
195
64
|
readonly storage: BrokrStorageClient;
|
|
196
65
|
readonly email: BrokrEmailClient;
|
|
66
|
+
private _files;
|
|
67
|
+
private _payments;
|
|
68
|
+
private _entitlements;
|
|
69
|
+
private _notifications;
|
|
197
70
|
private _auth;
|
|
198
|
-
private readonly _token;
|
|
199
|
-
private readonly _gatewayUrl;
|
|
200
71
|
constructor(options?: RuntimeOptions);
|
|
201
|
-
/**
|
|
202
|
-
get
|
|
72
|
+
/** Files client (upload + AI processing). */
|
|
73
|
+
get files(): BrokrFilesClient;
|
|
74
|
+
/** Payments client (checkout, portal, plan queries). */
|
|
75
|
+
get payments(): BrokrPaymentsClient;
|
|
76
|
+
/** Notifications client (send + list notifications). */
|
|
77
|
+
get notifications(): BrokrNotificationsClient;
|
|
78
|
+
/** Entitlements client (feature checks, usage queries). */
|
|
79
|
+
get entitlements(): BrokrEntitlementsClient;
|
|
80
|
+
/** Auth client — lazily initialized. */
|
|
81
|
+
get auth(): BrokrAuthClient;
|
|
82
|
+
/** Send a chat message. Alias for `brokr.ai.chat()`. */
|
|
83
|
+
chat(input: ChatInput, options?: ChatOptions): Promise<ChatResponse>;
|
|
84
|
+
/** Upload a file. Alias for `brokr.storage.upload()`. */
|
|
85
|
+
upload(params: UploadParams): Promise<UploadedFile>;
|
|
86
|
+
/** Start a checkout flow. Alias for `brokr.payments.checkout()`. */
|
|
87
|
+
checkout(params: {
|
|
88
|
+
plan: string;
|
|
89
|
+
userId: string;
|
|
90
|
+
returnUrl?: string;
|
|
91
|
+
}): Promise<CheckoutResult>;
|
|
92
|
+
/** Start a checkout flow. Alias for `brokr.checkout()` — north star one-liner. */
|
|
93
|
+
purchase(params: {
|
|
94
|
+
plan: string;
|
|
95
|
+
userId: string;
|
|
96
|
+
returnUrl?: string;
|
|
97
|
+
}): Promise<CheckoutResult>;
|
|
203
98
|
}
|
|
204
99
|
/**
|
|
205
100
|
* Create a Brokr runtime client. Zero config required.
|
|
206
101
|
*
|
|
207
102
|
* BROKR_TOKEN is injected automatically at deploy time.
|
|
208
103
|
* For local development, run: brokr env pull --stack <name>
|
|
209
|
-
*
|
|
210
|
-
* @example
|
|
211
|
-
* ```typescript
|
|
212
|
-
* import { createBrokr } from '@brokr/sdk';
|
|
213
|
-
* export const brokr = createBrokr();
|
|
214
|
-
* ```
|
|
215
104
|
*/
|
|
216
105
|
export declare function createBrokr(options?: RuntimeOptions): BrokrRuntime;
|
|
217
106
|
//# sourceMappingURL=runtime.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/runtime.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../src/runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAIH,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAClE,OAAO,EAAE,wBAAwB,EAAE,MAA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