@hexclave/shared 1.0.2 → 1.0.5
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/ai/unified-prompts/reminders.js +4 -3
- package/dist/ai/unified-prompts/reminders.js.map +1 -1
- package/dist/ai/unified-prompts/skill-site-prompt-parts/ai-setup-prompt.d.ts +3 -1
- package/dist/ai/unified-prompts/skill-site-prompt-parts/ai-setup-prompt.d.ts.map +1 -1
- package/dist/ai/unified-prompts/skill-site-prompt-parts/ai-setup-prompt.js +217 -30
- package/dist/ai/unified-prompts/skill-site-prompt-parts/ai-setup-prompt.js.map +1 -1
- package/dist/ai/unified-prompts/skill-site-prompt-parts/docs-index.d.ts.map +1 -1
- package/dist/ai/unified-prompts/skill-site-prompt-parts/docs-index.js +1 -0
- package/dist/ai/unified-prompts/skill-site-prompt-parts/docs-index.js.map +1 -1
- package/dist/ai/unified-prompts/skill-site-prompt-parts/docs-json.generated.d.ts +18 -6
- package/dist/ai/unified-prompts/skill-site-prompt-parts/docs-json.generated.js +23 -8
- package/dist/ai/unified-prompts/skill-site-prompt-parts/docs-json.generated.js.map +1 -1
- package/dist/ai/unified-prompts/skill-site-prompt-parts/openapi-specs.js +1 -1
- package/dist/ai/unified-prompts/skill-site-prompt-parts/openapi-specs.js.map +1 -1
- package/dist/config/schema.d.ts +63 -63
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +5 -5
- package/dist/config/schema.js.map +1 -1
- package/dist/config-authoring.d.ts +4 -4
- package/dist/config-authoring.d.ts.map +1 -1
- package/dist/config-authoring.js +2 -2
- package/dist/config-authoring.js.map +1 -1
- package/dist/config-rendering.d.ts +4 -4
- package/dist/config-rendering.d.ts.map +1 -1
- package/dist/config-rendering.js +19 -18
- package/dist/config-rendering.js.map +1 -1
- package/dist/esm/ai/unified-prompts/reminders.js +4 -3
- package/dist/esm/ai/unified-prompts/reminders.js.map +1 -1
- package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/ai-setup-prompt.d.ts +3 -1
- package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/ai-setup-prompt.d.ts.map +1 -1
- package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/ai-setup-prompt.js +216 -31
- package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/ai-setup-prompt.js.map +1 -1
- package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/docs-index.d.ts.map +1 -1
- package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/docs-index.js +1 -0
- package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/docs-index.js.map +1 -1
- package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/docs-json.generated.d.ts +18 -6
- package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/docs-json.generated.js +23 -8
- package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/docs-json.generated.js.map +1 -1
- package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/openapi-specs.js +1 -1
- package/dist/esm/ai/unified-prompts/skill-site-prompt-parts/openapi-specs.js.map +1 -1
- package/dist/esm/config/schema.d.ts +63 -63
- package/dist/esm/config/schema.d.ts.map +1 -1
- package/dist/esm/config/schema.js +5 -5
- package/dist/esm/config/schema.js.map +1 -1
- package/dist/esm/config-authoring.d.ts +4 -4
- package/dist/esm/config-authoring.d.ts.map +1 -1
- package/dist/esm/config-authoring.js +2 -2
- package/dist/esm/config-authoring.js.map +1 -1
- package/dist/esm/config-rendering.d.ts +4 -4
- package/dist/esm/config-rendering.d.ts.map +1 -1
- package/dist/esm/config-rendering.js +15 -14
- package/dist/esm/config-rendering.js.map +1 -1
- package/dist/esm/helpers/vault/client-side.d.ts.map +1 -1
- package/dist/esm/helpers/vault/client-side.js.map +1 -1
- package/dist/esm/helpers/vault/server-side.d.ts.map +1 -1
- package/dist/esm/helpers/vault/server-side.js.map +1 -1
- package/dist/esm/hexclave-config-file.d.ts +15 -0
- package/dist/esm/hexclave-config-file.d.ts.map +1 -0
- package/dist/esm/{stack-config-file.js → hexclave-config-file.js} +7 -7
- package/dist/esm/hexclave-config-file.js.map +1 -0
- package/dist/esm/hooks/use-async-callback.js +1 -1
- package/dist/esm/hooks/use-async-external-store.js +1 -1
- package/dist/esm/hooks/use-strict-memo.js +1 -1
- package/dist/esm/interface/admin-metrics.d.ts +8 -8
- package/dist/esm/interface/admin-metrics.js.map +1 -1
- package/dist/esm/interface/client-interface.js +2 -2
- package/dist/esm/interface/client-interface.js.map +1 -1
- package/dist/esm/interface/conversations.d.ts +32 -32
- package/dist/esm/interface/crud/current-user.d.ts +9 -9
- package/dist/esm/interface/crud/email-outbox.d.ts +200 -200
- package/dist/esm/interface/crud/products.d.ts +13 -13
- package/dist/esm/interface/crud/products.d.ts.map +1 -1
- package/dist/esm/interface/crud/project-api-keys.d.ts +4 -4
- package/dist/esm/interface/crud/project-permissions.js +5 -5
- package/dist/esm/interface/crud/project-permissions.js.map +1 -1
- package/dist/esm/interface/crud/projects.d.ts +36 -36
- package/dist/esm/interface/crud/team-member-profiles.d.ts +18 -18
- package/dist/esm/interface/crud/team-permissions.js +5 -5
- package/dist/esm/interface/crud/team-permissions.js.map +1 -1
- package/dist/esm/interface/crud/transactions.d.ts +6 -6
- package/dist/esm/interface/crud/transactions.d.ts.map +1 -1
- package/dist/esm/interface/crud/users.d.ts +12 -12
- package/dist/esm/interface/page-component-versions.js +107 -107
- package/dist/esm/interface/page-component-versions.js.map +1 -1
- package/dist/esm/interface/webhooks.d.ts +2 -2
- package/dist/esm/known-errors.d.ts +2 -2
- package/dist/esm/known-errors.js +4 -4
- package/dist/esm/known-errors.js.map +1 -1
- package/dist/esm/schema-fields.d.ts +17 -7
- package/dist/esm/schema-fields.d.ts.map +1 -1
- package/dist/esm/schema-fields.js +26 -16
- package/dist/esm/schema-fields.js.map +1 -1
- package/dist/esm/sessions.d.ts +7 -7
- package/dist/esm/utils/crypto.d.ts.map +1 -1
- package/dist/esm/utils/crypto.js.map +1 -1
- package/dist/esm/utils/currency-constants.d.ts +6 -0
- package/dist/esm/utils/currency-constants.d.ts.map +1 -1
- package/dist/esm/utils/currency-constants.js.map +1 -1
- package/dist/esm/utils/dev-env-state-path.d.ts +3 -3
- package/dist/esm/utils/dev-env-state-path.d.ts.map +1 -1
- package/dist/esm/utils/dev-env-state-path.js +4 -4
- package/dist/esm/utils/dev-env-state-path.js.map +1 -1
- package/dist/esm/utils/errors.js +2 -2
- package/dist/esm/utils/errors.js.map +1 -1
- package/dist/esm/utils/esbuild.d.ts.map +1 -1
- package/dist/esm/utils/esbuild.js +0 -1
- package/dist/esm/utils/esbuild.js.map +1 -1
- package/dist/esm/utils/featurebase.d.ts +3 -3
- package/dist/esm/utils/featurebase.d.ts.map +1 -1
- package/dist/esm/utils/featurebase.js +15 -15
- package/dist/esm/utils/featurebase.js.map +1 -1
- package/dist/esm/utils/fs.js +6 -6
- package/dist/esm/utils/fs.js.map +1 -1
- package/dist/esm/utils/globals.d.ts.map +1 -1
- package/dist/esm/utils/globals.js +10 -10
- package/dist/esm/utils/globals.js.map +1 -1
- package/dist/esm/utils/jwt.d.ts.map +1 -1
- package/dist/esm/utils/jwt.js +3 -3
- package/dist/esm/utils/jwt.js.map +1 -1
- package/dist/esm/utils/redirect-urls.d.ts +3 -3
- package/dist/esm/utils/redirect-urls.d.ts.map +1 -1
- package/dist/esm/utils/redirect-urls.js +5 -5
- package/dist/esm/utils/redirect-urls.js.map +1 -1
- package/dist/esm/utils/urls.js.map +1 -1
- package/dist/helpers/vault/client-side.d.ts.map +1 -1
- package/dist/helpers/vault/client-side.js.map +1 -1
- package/dist/helpers/vault/server-side.d.ts.map +1 -1
- package/dist/helpers/vault/server-side.js.map +1 -1
- package/dist/hexclave-config-file.d.ts +15 -0
- package/dist/hexclave-config-file.d.ts.map +1 -0
- package/dist/{stack-config-file.js → hexclave-config-file.js} +8 -8
- package/dist/hexclave-config-file.js.map +1 -0
- package/dist/hooks/use-async-callback.js +1 -1
- package/dist/hooks/use-async-external-store.js +1 -1
- package/dist/hooks/use-strict-memo.js +1 -1
- package/dist/interface/admin-metrics.d.ts +8 -8
- package/dist/interface/admin-metrics.js.map +1 -1
- package/dist/interface/client-interface.js +2 -2
- package/dist/interface/client-interface.js.map +1 -1
- package/dist/interface/conversations.d.ts +32 -32
- package/dist/interface/crud/current-user.d.ts +9 -9
- package/dist/interface/crud/email-outbox.d.ts +200 -200
- package/dist/interface/crud/products.d.ts +13 -13
- package/dist/interface/crud/products.d.ts.map +1 -1
- package/dist/interface/crud/project-api-keys.d.ts +4 -4
- package/dist/interface/crud/project-permissions.js +5 -5
- package/dist/interface/crud/project-permissions.js.map +1 -1
- package/dist/interface/crud/projects.d.ts +36 -36
- package/dist/interface/crud/team-member-profiles.d.ts +18 -18
- package/dist/interface/crud/team-permissions.js +5 -5
- package/dist/interface/crud/team-permissions.js.map +1 -1
- package/dist/interface/crud/transactions.d.ts +6 -6
- package/dist/interface/crud/transactions.d.ts.map +1 -1
- package/dist/interface/crud/users.d.ts +12 -12
- package/dist/interface/page-component-versions.js +107 -107
- package/dist/interface/page-component-versions.js.map +1 -1
- package/dist/interface/webhooks.d.ts +2 -2
- package/dist/known-errors.d.ts +2 -2
- package/dist/known-errors.js +4 -4
- package/dist/known-errors.js.map +1 -1
- package/dist/schema-fields.d.ts +17 -7
- package/dist/schema-fields.d.ts.map +1 -1
- package/dist/schema-fields.js +26 -16
- package/dist/schema-fields.js.map +1 -1
- package/dist/sessions.d.ts +7 -7
- package/dist/utils/crypto.d.ts.map +1 -1
- package/dist/utils/crypto.js.map +1 -1
- package/dist/utils/currency-constants.d.ts +6 -0
- package/dist/utils/currency-constants.d.ts.map +1 -1
- package/dist/utils/currency-constants.js.map +1 -1
- package/dist/utils/dev-env-state-path.d.ts +3 -3
- package/dist/utils/dev-env-state-path.d.ts.map +1 -1
- package/dist/utils/dev-env-state-path.js +5 -5
- package/dist/utils/dev-env-state-path.js.map +1 -1
- package/dist/utils/errors.js +2 -2
- package/dist/utils/errors.js.map +1 -1
- package/dist/utils/esbuild.d.ts.map +1 -1
- package/dist/utils/esbuild.js +0 -1
- package/dist/utils/esbuild.js.map +1 -1
- package/dist/utils/featurebase.d.ts +3 -3
- package/dist/utils/featurebase.d.ts.map +1 -1
- package/dist/utils/featurebase.js +15 -15
- package/dist/utils/featurebase.js.map +1 -1
- package/dist/utils/fs.js.map +1 -1
- package/dist/utils/globals.d.ts.map +1 -1
- package/dist/utils/globals.js +10 -10
- package/dist/utils/globals.js.map +1 -1
- package/dist/utils/jwt.d.ts.map +1 -1
- package/dist/utils/jwt.js +3 -3
- package/dist/utils/jwt.js.map +1 -1
- package/dist/utils/redirect-urls.d.ts +3 -3
- package/dist/utils/redirect-urls.d.ts.map +1 -1
- package/dist/utils/redirect-urls.js +5 -5
- package/dist/utils/redirect-urls.js.map +1 -1
- package/dist/utils/urls.js.map +1 -1
- package/package.json +2 -1
- package/src/ai/image-limits.ts +62 -0
- package/src/ai/llms/llms.ts +36 -0
- package/src/ai/unified-prompts/reminders.ts +27 -0
- package/src/ai/unified-prompts/skill-site-prompt-parts/ai-setup-prompt.ts +1047 -0
- package/src/ai/unified-prompts/skill-site-prompt-parts/brain.ts +5 -0
- package/src/ai/unified-prompts/skill-site-prompt-parts/cli-help.ts +5 -0
- package/src/ai/unified-prompts/skill-site-prompt-parts/config-docs.ts +5 -0
- package/src/ai/unified-prompts/skill-site-prompt-parts/custom-components-instructions.ts +5 -0
- package/src/ai/unified-prompts/skill-site-prompt-parts/dashboard-instructions.ts +5 -0
- package/src/ai/unified-prompts/skill-site-prompt-parts/docs-index.ts +80 -0
- package/src/ai/unified-prompts/skill-site-prompt-parts/docs-json.generated.ts +322 -0
- package/src/ai/unified-prompts/skill-site-prompt-parts/openapi-specs.ts +5 -0
- package/src/ai/unified-prompts/skill-site-prompt-parts/sdk-interface-source.ts +5 -0
- package/src/ai/unified-prompts/skill-site-prompt.ts +72 -0
- package/src/apps/apps-config.ts +177 -0
- package/src/apps/apps-ui.tsx +112 -0
- package/src/config/README.md +154 -0
- package/src/config/db-sync-mappings.ts +2293 -0
- package/src/config/format.ts +388 -0
- package/src/config/migrate-catalogs-to-product-lines.ts +475 -0
- package/src/config/schema-fuzzer.test.ts +377 -0
- package/src/config/schema.ts +1507 -0
- package/src/config-authoring.test.ts +52 -0
- package/src/config-authoring.ts +37 -0
- package/src/config-rendering.ts +142 -0
- package/src/crud.tsx +275 -0
- package/src/global.d.ts +1 -0
- package/src/helpers/emails.ts +250 -0
- package/src/helpers/init-prompt.ts +39 -0
- package/src/helpers/password.ts +16 -0
- package/src/helpers/production-mode.ts +58 -0
- package/src/helpers/support-sla.test.ts +124 -0
- package/src/helpers/support-sla.ts +93 -0
- package/src/helpers/vault/client-side.ts +92 -0
- package/src/helpers/vault/server-side.ts +153 -0
- package/src/hexclave-config-file.ts +120 -0
- package/src/hooks/use-async-callback.tsx +43 -0
- package/src/hooks/use-async-external-store.tsx +24 -0
- package/src/hooks/use-hash.tsx +14 -0
- package/src/hooks/use-hover.tsx +88 -0
- package/src/hooks/use-strict-memo.tsx +157 -0
- package/src/index.ts +17 -0
- package/src/interface/admin-interface.ts +1043 -0
- package/src/interface/admin-metrics.ts +214 -0
- package/src/interface/client-interface.test.ts +765 -0
- package/src/interface/client-interface.ts +2586 -0
- package/src/interface/conversations.ts +109 -0
- package/src/interface/crud/analytics.ts +11 -0
- package/src/interface/crud/connected-accounts.ts +52 -0
- package/src/interface/crud/contact-channels.ts +74 -0
- package/src/interface/crud/current-user.ts +72 -0
- package/src/interface/crud/email-outbox.ts +263 -0
- package/src/interface/crud/email-templates.ts +50 -0
- package/src/interface/crud/emails.ts +22 -0
- package/src/interface/crud/internal-api-keys.ts +69 -0
- package/src/interface/crud/invoices.ts +36 -0
- package/src/interface/crud/items.ts +24 -0
- package/src/interface/crud/notification-preferences.ts +33 -0
- package/src/interface/crud/oauth-providers.ts +91 -0
- package/src/interface/crud/products.ts +42 -0
- package/src/interface/crud/project-api-keys.ts +100 -0
- package/src/interface/crud/project-permissions.ts +118 -0
- package/src/interface/crud/projects.ts +229 -0
- package/src/interface/crud/session-replays.ts +85 -0
- package/src/interface/crud/sessions.ts +66 -0
- package/src/interface/crud/sign-up-rules.ts +12 -0
- package/src/interface/crud/svix-token.ts +20 -0
- package/src/interface/crud/team-invitation-details.ts +22 -0
- package/src/interface/crud/team-invitation.ts +35 -0
- package/src/interface/crud/team-member-profiles.ts +61 -0
- package/src/interface/crud/team-memberships.ts +56 -0
- package/src/interface/crud/team-permissions.ts +119 -0
- package/src/interface/crud/teams.ts +142 -0
- package/src/interface/crud/transactions.ts +131 -0
- package/src/interface/crud/users.ts +185 -0
- package/src/interface/handler-urls.ts +74 -0
- package/src/interface/page-component-versions.ts +1702 -0
- package/src/interface/server-interface.ts +1146 -0
- package/src/interface/webhooks.ts +28 -0
- package/src/known-errors.tsx +2031 -0
- package/src/local-emulator.ts +5 -0
- package/src/payments/payment-methods.ts +167 -0
- package/src/payments/stripe-limits.ts +18 -0
- package/src/plans.ts +107 -0
- package/src/schema-fields.ts +944 -0
- package/src/sessions.ts +310 -0
- package/src/utils/api-keys.tsx +122 -0
- package/src/utils/arrays.tsx +248 -0
- package/src/utils/auth-methods.ts +8 -0
- package/src/utils/base64.tsx +24 -0
- package/src/utils/booleans.tsx +34 -0
- package/src/utils/browser-compat.tsx +17 -0
- package/src/utils/bytes.tsx +280 -0
- package/src/utils/caches.tsx +280 -0
- package/src/utils/cel-fields.ts +92 -0
- package/src/utils/cloud-hosts.tsx +92 -0
- package/src/utils/compile-time.tsx +11 -0
- package/src/utils/country-codes.ts +39 -0
- package/src/utils/crypto.tsx +174 -0
- package/src/utils/currencies.tsx +53 -0
- package/src/utils/currency-constants.tsx +51 -0
- package/src/utils/dates.tsx +246 -0
- package/src/utils/dev-env-state-path.ts +14 -0
- package/src/utils/dom.tsx +7 -0
- package/src/utils/env.tsx +117 -0
- package/src/utils/errors.tsx +284 -0
- package/src/utils/esbuild.tsx +235 -0
- package/src/utils/featurebase.tsx +247 -0
- package/src/utils/fs.tsx +33 -0
- package/src/utils/functions.tsx +22 -0
- package/src/utils/geo.tsx +16 -0
- package/src/utils/globals.tsx +48 -0
- package/src/utils/hashes.tsx +52 -0
- package/src/utils/html.tsx +60 -0
- package/src/utils/http.tsx +91 -0
- package/src/utils/ips.tsx +47 -0
- package/src/utils/json.tsx +200 -0
- package/src/utils/jsx-editable-transpiler.test.ts +156 -0
- package/src/utils/jsx-editable-transpiler.tsx +401 -0
- package/src/utils/jwt.tsx +170 -0
- package/src/utils/locks.tsx +71 -0
- package/src/utils/maps.tsx +407 -0
- package/src/utils/math.tsx +18 -0
- package/src/utils/monkey-patch.tsx +29 -0
- package/src/utils/node-http.tsx +47 -0
- package/src/utils/numbers.tsx +82 -0
- package/src/utils/oauth.tsx +9 -0
- package/src/utils/objects.tsx +581 -0
- package/src/utils/paginated-lists.test.ts +1039 -0
- package/src/utils/paginated-lists.tsx +479 -0
- package/src/utils/passkey.tsx +1 -0
- package/src/utils/promises.tsx +540 -0
- package/src/utils/proxies.tsx +212 -0
- package/src/utils/react.tsx +308 -0
- package/src/utils/redirect-urls.tsx +299 -0
- package/src/utils/regex.tsx +10 -0
- package/src/utils/results.tsx +411 -0
- package/src/utils/sentry.tsx +20 -0
- package/src/utils/stores.tsx +238 -0
- package/src/utils/strings.nicify.test.ts +253 -0
- package/src/utils/strings.tsx +723 -0
- package/src/utils/telemetry.tsx +37 -0
- package/src/utils/turnstile-browser.ts +106 -0
- package/src/utils/turnstile-flow.test.ts +101 -0
- package/src/utils/turnstile-flow.ts +266 -0
- package/src/utils/turnstile.ts +34 -0
- package/src/utils/typed-arrays.tsx +17 -0
- package/src/utils/types.tsx +208 -0
- package/src/utils/unicode.tsx +24 -0
- package/src/utils/urls.tsx +411 -0
- package/src/utils/uuids.tsx +47 -0
- package/dist/esm/stack-config-file.d.ts +0 -15
- package/dist/esm/stack-config-file.d.ts.map +0 -1
- package/dist/esm/stack-config-file.js.map +0 -1
- package/dist/stack-config-file.d.ts +0 -15
- package/dist/stack-config-file.d.ts.map +0 -1
- package/dist/stack-config-file.js.map +0 -1
|
@@ -0,0 +1,1043 @@
|
|
|
1
|
+
import * as yup from "yup";
|
|
2
|
+
import { KnownErrors } from "../known-errors";
|
|
3
|
+
import { branchConfigSourceSchema, type RestrictedReason } from "../schema-fields";
|
|
4
|
+
import { AccessToken, InternalSession, RefreshToken } from "../sessions";
|
|
5
|
+
import type { MoneyAmount } from "../utils/currency-constants";
|
|
6
|
+
import type { Json } from "../utils/json";
|
|
7
|
+
import { Result } from "../utils/results";
|
|
8
|
+
import { urlString } from "../utils/urls";
|
|
9
|
+
import type { MetricsResponse, MetricsUserCounts, UserActivityResponse } from "./admin-metrics";
|
|
10
|
+
import type { AnalyticsQueryOptions, AnalyticsQueryResponse } from "./crud/analytics";
|
|
11
|
+
import { EmailOutboxCrud } from "./crud/email-outbox";
|
|
12
|
+
import { InternalEmailsCrud } from "./crud/emails";
|
|
13
|
+
import { InternalApiKeysCrud } from "./crud/internal-api-keys";
|
|
14
|
+
import { ProjectPermissionDefinitionsCrud } from "./crud/project-permissions";
|
|
15
|
+
import { ProjectsCrud } from "./crud/projects";
|
|
16
|
+
import type {
|
|
17
|
+
AdminGetSessionReplayResponse,
|
|
18
|
+
AdminGetSessionReplayAllEventsResponse,
|
|
19
|
+
AdminGetSessionReplayChunkEventsResponse,
|
|
20
|
+
AdminListSessionReplayChunksOptions,
|
|
21
|
+
AdminListSessionReplayChunksResponse,
|
|
22
|
+
AdminListSessionReplaysOptions,
|
|
23
|
+
AdminListSessionReplaysResponse
|
|
24
|
+
} from "./crud/session-replays";
|
|
25
|
+
import { SvixTokenCrud } from "./crud/svix-token";
|
|
26
|
+
import { TeamPermissionDefinitionsCrud } from "./crud/team-permissions";
|
|
27
|
+
import type { Transaction, TransactionType } from "./crud/transactions";
|
|
28
|
+
import { ServerAuthApplicationOptions, HexclaveServerInterface } from "./server-interface";
|
|
29
|
+
|
|
30
|
+
type BranchConfigSourceApi = yup.InferType<typeof branchConfigSourceSchema>;
|
|
31
|
+
|
|
32
|
+
export type ChatContent = Array<
|
|
33
|
+
| { type: "text", text: string }
|
|
34
|
+
| { type: "tool-call", toolName: string, toolCallId: string, args: any, argsText: string, result: any }
|
|
35
|
+
>;
|
|
36
|
+
|
|
37
|
+
export type AdminAuthApplicationOptions = ServerAuthApplicationOptions &(
|
|
38
|
+
| {
|
|
39
|
+
superSecretAdminKey: string,
|
|
40
|
+
}
|
|
41
|
+
| {
|
|
42
|
+
projectOwnerSession: InternalSession | (() => Promise<string | null>),
|
|
43
|
+
}
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
export type InternalApiKeyCreateCrudRequest = {
|
|
47
|
+
has_publishable_client_key: boolean,
|
|
48
|
+
has_secret_server_key: boolean,
|
|
49
|
+
has_super_secret_admin_key: boolean,
|
|
50
|
+
expires_at_millis: number,
|
|
51
|
+
description: string,
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export type InternalApiKeyCreateCrudResponse = InternalApiKeysCrud["Admin"]["Read"] & {
|
|
55
|
+
publishable_client_key?: string,
|
|
56
|
+
secret_server_key?: string,
|
|
57
|
+
super_secret_admin_key?: string,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
export class HexclaveAdminInterface extends HexclaveServerInterface {
|
|
62
|
+
constructor(public readonly options: AdminAuthApplicationOptions) {
|
|
63
|
+
super(options);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
public async sendAdminRequest(path: string, options: RequestInit, session: InternalSession | null, requestType: "admin" = "admin") {
|
|
67
|
+
return await this.sendServerRequest(
|
|
68
|
+
path,
|
|
69
|
+
{
|
|
70
|
+
...options,
|
|
71
|
+
headers: {
|
|
72
|
+
// Hexclave rebrand: emit x-hexclave-* request header; the backend proxy dual-accepts both names.
|
|
73
|
+
"x-hexclave-super-secret-admin-key": "superSecretAdminKey" in this.options ? this.options.superSecretAdminKey : "",
|
|
74
|
+
...options.headers,
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
session,
|
|
78
|
+
requestType,
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
protected async sendAdminRequestAndCatchKnownError<E extends typeof KnownErrors[keyof KnownErrors]>(
|
|
83
|
+
path: string,
|
|
84
|
+
requestOptions: RequestInit,
|
|
85
|
+
tokenStoreOrNull: InternalSession | null,
|
|
86
|
+
errorsToCatch: readonly E[],
|
|
87
|
+
): Promise<Result<
|
|
88
|
+
Response & {
|
|
89
|
+
usedTokens: {
|
|
90
|
+
accessToken: AccessToken,
|
|
91
|
+
refreshToken: RefreshToken | null,
|
|
92
|
+
} | null,
|
|
93
|
+
},
|
|
94
|
+
InstanceType<E>
|
|
95
|
+
>> {
|
|
96
|
+
try {
|
|
97
|
+
return Result.ok(await this.sendAdminRequest(path, requestOptions, tokenStoreOrNull));
|
|
98
|
+
} catch (e) {
|
|
99
|
+
for (const errorType of errorsToCatch) {
|
|
100
|
+
if (errorType.isInstance(e)) {
|
|
101
|
+
return Result.error(e as InstanceType<E>);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
throw e;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
async getProject(): Promise<ProjectsCrud["Admin"]["Read"]> {
|
|
109
|
+
const response = await this.sendAdminRequest(
|
|
110
|
+
"/internal/projects/current",
|
|
111
|
+
{
|
|
112
|
+
method: "GET",
|
|
113
|
+
},
|
|
114
|
+
null,
|
|
115
|
+
);
|
|
116
|
+
return await response.json();
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
async updateProject(update: ProjectsCrud["Admin"]["Update"]): Promise<ProjectsCrud["Admin"]["Read"]> {
|
|
120
|
+
const response = await this.sendAdminRequest(
|
|
121
|
+
"/internal/projects/current",
|
|
122
|
+
{
|
|
123
|
+
method: "PATCH",
|
|
124
|
+
headers: {
|
|
125
|
+
"content-type": "application/json",
|
|
126
|
+
},
|
|
127
|
+
body: JSON.stringify(update),
|
|
128
|
+
},
|
|
129
|
+
null,
|
|
130
|
+
);
|
|
131
|
+
return await response.json();
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
async createInternalApiKey(
|
|
135
|
+
options: InternalApiKeyCreateCrudRequest,
|
|
136
|
+
): Promise<InternalApiKeyCreateCrudResponse> {
|
|
137
|
+
const response = await this.sendAdminRequest(
|
|
138
|
+
"/internal/api-keys",
|
|
139
|
+
{
|
|
140
|
+
method: "POST",
|
|
141
|
+
headers: {
|
|
142
|
+
"content-type": "application/json",
|
|
143
|
+
},
|
|
144
|
+
body: JSON.stringify(options),
|
|
145
|
+
},
|
|
146
|
+
null,
|
|
147
|
+
);
|
|
148
|
+
return await response.json();
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
async listInternalApiKeys(): Promise<InternalApiKeysCrud["Admin"]["Read"][]> {
|
|
152
|
+
const response = await this.sendAdminRequest("/internal/api-keys", {}, null);
|
|
153
|
+
const result = await response.json() as InternalApiKeysCrud["Admin"]["List"];
|
|
154
|
+
return result.items;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
async revokeInternalApiKeyById(id: string) {
|
|
158
|
+
await this.sendAdminRequest(
|
|
159
|
+
`/internal/api-keys/${id}`, {
|
|
160
|
+
method: "PATCH",
|
|
161
|
+
headers: {
|
|
162
|
+
"content-type": "application/json",
|
|
163
|
+
},
|
|
164
|
+
body: JSON.stringify({
|
|
165
|
+
revoked: true,
|
|
166
|
+
}),
|
|
167
|
+
},
|
|
168
|
+
null,
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
async getInternalApiKey(id: string, session: InternalSession): Promise<InternalApiKeysCrud["Admin"]["Read"]> {
|
|
173
|
+
const response = await this.sendAdminRequest(`/internal/api-keys/${id}`, {}, session);
|
|
174
|
+
return await response.json();
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
async listInternalEmailTemplates(): Promise<{ id: string, display_name: string, theme_id?: string, tsx_source: string }[]> {
|
|
178
|
+
const response = await this.sendAdminRequest(`/internal/email-templates`, {}, null);
|
|
179
|
+
const result = await response.json() as { templates: { id: string, display_name: string, theme_id?: string, tsx_source: string }[] };
|
|
180
|
+
return result.templates;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
async listInternalEmailDrafts(): Promise<{ id: string, display_name: string, theme_id?: string | undefined | false, tsx_source: string, sent_at_millis?: number | null }[]> {
|
|
184
|
+
const response = await this.sendAdminRequest(`/internal/email-drafts`, {}, null);
|
|
185
|
+
const result = await response.json() as { drafts: { id: string, display_name: string, theme_id?: string | undefined | false, tsx_source: string, sent_at_millis?: number | null }[] };
|
|
186
|
+
return result.drafts;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
async createEmailDraft(options: { display_name?: string, theme_id?: string | false, tsx_source?: string }): Promise<{ id: string }> {
|
|
190
|
+
const response = await this.sendAdminRequest(
|
|
191
|
+
`/internal/email-drafts`,
|
|
192
|
+
{
|
|
193
|
+
method: "POST",
|
|
194
|
+
headers: {
|
|
195
|
+
"content-type": "application/json",
|
|
196
|
+
},
|
|
197
|
+
body: JSON.stringify(options),
|
|
198
|
+
},
|
|
199
|
+
null,
|
|
200
|
+
);
|
|
201
|
+
return await response.json();
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
async updateEmailDraft(id: string, data: { display_name?: string, theme_id?: string | null | false, tsx_source?: string, sent_at_millis?: number | null }): Promise<void> {
|
|
205
|
+
await this.sendAdminRequest(
|
|
206
|
+
`/internal/email-drafts/${id}`,
|
|
207
|
+
{
|
|
208
|
+
method: "PATCH",
|
|
209
|
+
headers: {
|
|
210
|
+
"content-type": "application/json",
|
|
211
|
+
},
|
|
212
|
+
body: JSON.stringify(data),
|
|
213
|
+
},
|
|
214
|
+
null,
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
async deleteEmailDraft(id: string): Promise<void> {
|
|
219
|
+
await this.sendAdminRequest(
|
|
220
|
+
`/internal/email-drafts/${id}`,
|
|
221
|
+
{
|
|
222
|
+
method: "DELETE",
|
|
223
|
+
},
|
|
224
|
+
null,
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
async listEmailThemes(): Promise<{ id: string, display_name: string }[]> {
|
|
229
|
+
const response = await this.sendAdminRequest(`/internal/email-themes`, {}, null);
|
|
230
|
+
const result = await response.json() as { themes: { id: string, display_name: string }[] };
|
|
231
|
+
return result.themes;
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
|
|
235
|
+
// Team permission definitions methods
|
|
236
|
+
async listTeamPermissionDefinitions(): Promise<TeamPermissionDefinitionsCrud['Admin']['Read'][]> {
|
|
237
|
+
const response = await this.sendAdminRequest(`/team-permission-definitions`, {}, null);
|
|
238
|
+
const result = await response.json() as TeamPermissionDefinitionsCrud['Admin']['List'];
|
|
239
|
+
return result.items;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
async listTeamPermissionDefinitionsPaginated(
|
|
243
|
+
options: { limit: number, cursor?: string, query?: string },
|
|
244
|
+
): Promise<{ items: TeamPermissionDefinitionsCrud['Admin']['Read'][], nextCursor: string | null }> {
|
|
245
|
+
const params = new URLSearchParams();
|
|
246
|
+
params.set("limit", String(options.limit));
|
|
247
|
+
if (options.cursor) params.set("cursor", options.cursor);
|
|
248
|
+
if (options.query) params.set("query", options.query);
|
|
249
|
+
const response = await this.sendAdminRequest(`/team-permission-definitions?${params.toString()}`, {}, null);
|
|
250
|
+
const result = await response.json() as TeamPermissionDefinitionsCrud['Admin']['List'];
|
|
251
|
+
return {
|
|
252
|
+
items: result.items,
|
|
253
|
+
nextCursor: result.pagination?.next_cursor ?? null,
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
async createTeamPermissionDefinition(data: TeamPermissionDefinitionsCrud['Admin']['Create']): Promise<TeamPermissionDefinitionsCrud['Admin']['Read']> {
|
|
258
|
+
const response = await this.sendAdminRequest(
|
|
259
|
+
"/team-permission-definitions",
|
|
260
|
+
{
|
|
261
|
+
method: "POST",
|
|
262
|
+
headers: {
|
|
263
|
+
"content-type": "application/json",
|
|
264
|
+
},
|
|
265
|
+
body: JSON.stringify(data),
|
|
266
|
+
},
|
|
267
|
+
null,
|
|
268
|
+
);
|
|
269
|
+
return await response.json();
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
async updateTeamPermissionDefinition(permissionId: string, data: TeamPermissionDefinitionsCrud['Admin']['Update']): Promise<TeamPermissionDefinitionsCrud['Admin']['Read']> {
|
|
273
|
+
const response = await this.sendAdminRequest(
|
|
274
|
+
`/team-permission-definitions/${permissionId}`,
|
|
275
|
+
{
|
|
276
|
+
method: "PATCH",
|
|
277
|
+
headers: {
|
|
278
|
+
"content-type": "application/json",
|
|
279
|
+
},
|
|
280
|
+
body: JSON.stringify(data),
|
|
281
|
+
},
|
|
282
|
+
null,
|
|
283
|
+
);
|
|
284
|
+
return await response.json();
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
async deleteTeamPermissionDefinition(permissionId: string): Promise<void> {
|
|
288
|
+
await this.sendAdminRequest(
|
|
289
|
+
`/team-permission-definitions/${permissionId}`,
|
|
290
|
+
{ method: "DELETE" },
|
|
291
|
+
null,
|
|
292
|
+
);
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
async listProjectPermissionDefinitions(): Promise<ProjectPermissionDefinitionsCrud['Admin']['Read'][]> {
|
|
296
|
+
const response = await this.sendAdminRequest(`/project-permission-definitions`, {}, null);
|
|
297
|
+
const result = await response.json() as ProjectPermissionDefinitionsCrud['Admin']['List'];
|
|
298
|
+
return result.items;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
async createProjectPermissionDefinition(data: ProjectPermissionDefinitionsCrud['Admin']['Create']): Promise<ProjectPermissionDefinitionsCrud['Admin']['Read']> {
|
|
302
|
+
const response = await this.sendAdminRequest(
|
|
303
|
+
"/project-permission-definitions",
|
|
304
|
+
{
|
|
305
|
+
method: "POST",
|
|
306
|
+
headers: {
|
|
307
|
+
"content-type": "application/json",
|
|
308
|
+
},
|
|
309
|
+
body: JSON.stringify(data),
|
|
310
|
+
},
|
|
311
|
+
null,
|
|
312
|
+
);
|
|
313
|
+
return await response.json();
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
async updateProjectPermissionDefinition(permissionId: string, data: ProjectPermissionDefinitionsCrud['Admin']['Update']): Promise<ProjectPermissionDefinitionsCrud['Admin']['Read']> {
|
|
317
|
+
const response = await this.sendAdminRequest(
|
|
318
|
+
`/project-permission-definitions/${permissionId}`,
|
|
319
|
+
{
|
|
320
|
+
method: "PATCH",
|
|
321
|
+
headers: {
|
|
322
|
+
"content-type": "application/json",
|
|
323
|
+
},
|
|
324
|
+
body: JSON.stringify(data),
|
|
325
|
+
},
|
|
326
|
+
null,
|
|
327
|
+
);
|
|
328
|
+
return await response.json();
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
async deleteProjectPermissionDefinition(permissionId: string): Promise<void> {
|
|
332
|
+
await this.sendAdminRequest(
|
|
333
|
+
`/project-permission-definitions/${permissionId}`,
|
|
334
|
+
{ method: "DELETE" },
|
|
335
|
+
null,
|
|
336
|
+
);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
async getSvixToken(): Promise<SvixTokenCrud["Admin"]["Read"]> {
|
|
340
|
+
const response = await this.sendAdminRequest(
|
|
341
|
+
"/webhooks/svix-token",
|
|
342
|
+
{
|
|
343
|
+
method: "POST",
|
|
344
|
+
headers: {
|
|
345
|
+
"content-type": "application/json",
|
|
346
|
+
},
|
|
347
|
+
body: JSON.stringify({}),
|
|
348
|
+
},
|
|
349
|
+
null,
|
|
350
|
+
);
|
|
351
|
+
return await response.json();
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
async deleteProject(): Promise<void> {
|
|
355
|
+
await this.sendAdminRequest(
|
|
356
|
+
"/internal/projects/current",
|
|
357
|
+
{
|
|
358
|
+
method: "DELETE",
|
|
359
|
+
},
|
|
360
|
+
null,
|
|
361
|
+
);
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
async getMetrics(includeAnonymous: boolean = false): Promise<MetricsResponse> {
|
|
365
|
+
const params = new URLSearchParams();
|
|
366
|
+
if (includeAnonymous) {
|
|
367
|
+
params.append('include_anonymous', 'true');
|
|
368
|
+
}
|
|
369
|
+
const queryString = params.toString();
|
|
370
|
+
const response = await this.sendAdminRequest(
|
|
371
|
+
`/internal/metrics${queryString ? `?${queryString}` : ''}`,
|
|
372
|
+
{
|
|
373
|
+
method: "GET",
|
|
374
|
+
},
|
|
375
|
+
null,
|
|
376
|
+
);
|
|
377
|
+
return (await response.json()) as MetricsResponse;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
async getUserActivity(userId: string): Promise<UserActivityResponse> {
|
|
381
|
+
const response = await this.sendAdminRequest(
|
|
382
|
+
urlString`/internal/user-activity?user_id=${userId}`,
|
|
383
|
+
{
|
|
384
|
+
method: "GET",
|
|
385
|
+
},
|
|
386
|
+
null,
|
|
387
|
+
);
|
|
388
|
+
return (await response.json()) as UserActivityResponse;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
async getMetricsUserCounts(): Promise<MetricsUserCounts> {
|
|
392
|
+
const response = await this.sendAdminRequest(
|
|
393
|
+
"/internal/metrics/user-counts",
|
|
394
|
+
{
|
|
395
|
+
method: "GET",
|
|
396
|
+
},
|
|
397
|
+
null,
|
|
398
|
+
);
|
|
399
|
+
return (await response.json()) as MetricsUserCounts;
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
async sendTestEmail(data: {
|
|
403
|
+
recipient_email: string,
|
|
404
|
+
email_config: {
|
|
405
|
+
host: string,
|
|
406
|
+
port: number,
|
|
407
|
+
username: string,
|
|
408
|
+
password: string,
|
|
409
|
+
sender_email: string,
|
|
410
|
+
sender_name: string,
|
|
411
|
+
},
|
|
412
|
+
}): Promise<{ success: boolean, error_message?: string }> {
|
|
413
|
+
const response = await this.sendAdminRequest(`/internal/send-test-email`, {
|
|
414
|
+
method: "POST",
|
|
415
|
+
headers: {
|
|
416
|
+
"content-type": "application/json",
|
|
417
|
+
},
|
|
418
|
+
body: JSON.stringify(data),
|
|
419
|
+
}, null);
|
|
420
|
+
return await response.json();
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
async sendTestWebhook(data: {
|
|
424
|
+
endpoint_id: string,
|
|
425
|
+
}): Promise<{ success: boolean, error_message?: string }> {
|
|
426
|
+
const response = await this.sendAdminRequest(`/internal/send-test-webhook`, {
|
|
427
|
+
method: "POST",
|
|
428
|
+
headers: {
|
|
429
|
+
"content-type": "application/json",
|
|
430
|
+
},
|
|
431
|
+
body: JSON.stringify(data),
|
|
432
|
+
}, null);
|
|
433
|
+
return await response.json();
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
async listSentEmails(): Promise<InternalEmailsCrud["Admin"]["List"]> {
|
|
437
|
+
const response = await this.sendAdminRequest("/internal/emails", {
|
|
438
|
+
method: "GET",
|
|
439
|
+
}, null);
|
|
440
|
+
return await response.json();
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
async setupManagedEmailProvider(data: {
|
|
444
|
+
subdomain: string,
|
|
445
|
+
sender_local_part: string,
|
|
446
|
+
}): Promise<{
|
|
447
|
+
domain_id: string,
|
|
448
|
+
subdomain: string,
|
|
449
|
+
sender_local_part: string,
|
|
450
|
+
name_server_records: string[],
|
|
451
|
+
status: "pending_dns" | "pending_verification" | "verified" | "applied" | "failed",
|
|
452
|
+
}> {
|
|
453
|
+
const response = await this.sendAdminRequest("/internal/emails/managed-onboarding/setup", {
|
|
454
|
+
method: "POST",
|
|
455
|
+
headers: {
|
|
456
|
+
"content-type": "application/json",
|
|
457
|
+
},
|
|
458
|
+
body: JSON.stringify(data),
|
|
459
|
+
}, null);
|
|
460
|
+
return await response.json();
|
|
461
|
+
}
|
|
462
|
+
|
|
463
|
+
async checkManagedEmailStatus(data: {
|
|
464
|
+
domain_id: string,
|
|
465
|
+
subdomain: string,
|
|
466
|
+
sender_local_part: string,
|
|
467
|
+
}): Promise<{ status: "pending_dns" | "pending_verification" | "verified" | "applied" | "failed" }> {
|
|
468
|
+
const response = await this.sendAdminRequest("/internal/emails/managed-onboarding/check", {
|
|
469
|
+
method: "POST",
|
|
470
|
+
headers: {
|
|
471
|
+
"content-type": "application/json",
|
|
472
|
+
},
|
|
473
|
+
body: JSON.stringify(data),
|
|
474
|
+
}, null);
|
|
475
|
+
return await response.json();
|
|
476
|
+
}
|
|
477
|
+
|
|
478
|
+
async listManagedEmailDomains(): Promise<{
|
|
479
|
+
items: Array<{
|
|
480
|
+
domain_id: string,
|
|
481
|
+
subdomain: string,
|
|
482
|
+
sender_local_part: string,
|
|
483
|
+
status: "pending_dns" | "pending_verification" | "verified" | "applied" | "failed",
|
|
484
|
+
name_server_records: string[],
|
|
485
|
+
}>,
|
|
486
|
+
}> {
|
|
487
|
+
const response = await this.sendAdminRequest("/internal/emails/managed-onboarding/list", {
|
|
488
|
+
method: "GET",
|
|
489
|
+
}, null);
|
|
490
|
+
return await response.json();
|
|
491
|
+
}
|
|
492
|
+
|
|
493
|
+
async deleteManagedEmailDomain(data: {
|
|
494
|
+
resend_domain_id: string,
|
|
495
|
+
}): Promise<{ status: "deleted" }> {
|
|
496
|
+
const response = await this.sendAdminRequest("/internal/emails/managed-onboarding/delete", {
|
|
497
|
+
method: "POST",
|
|
498
|
+
headers: {
|
|
499
|
+
"content-type": "application/json",
|
|
500
|
+
},
|
|
501
|
+
body: JSON.stringify(data),
|
|
502
|
+
}, null);
|
|
503
|
+
return await response.json();
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
async applyManagedEmailProvider(data: {
|
|
507
|
+
domain_id: string,
|
|
508
|
+
}): Promise<{ status: "applied" }> {
|
|
509
|
+
const response = await this.sendAdminRequest("/internal/emails/managed-onboarding/apply", {
|
|
510
|
+
method: "POST",
|
|
511
|
+
headers: {
|
|
512
|
+
"content-type": "application/json",
|
|
513
|
+
},
|
|
514
|
+
body: JSON.stringify(data),
|
|
515
|
+
}, null);
|
|
516
|
+
return await response.json();
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
async sendSignInInvitationEmail(
|
|
520
|
+
email: string,
|
|
521
|
+
callbackUrl: string,
|
|
522
|
+
): Promise<void> {
|
|
523
|
+
await this.sendAdminRequest(
|
|
524
|
+
"/internal/send-sign-in-invitation",
|
|
525
|
+
{
|
|
526
|
+
method: "POST",
|
|
527
|
+
headers: {
|
|
528
|
+
"Content-Type": "application/json"
|
|
529
|
+
},
|
|
530
|
+
body: JSON.stringify({
|
|
531
|
+
email,
|
|
532
|
+
callback_url: callbackUrl,
|
|
533
|
+
}),
|
|
534
|
+
},
|
|
535
|
+
null,
|
|
536
|
+
);
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
async saveChatMessage(threadId: string, message: any): Promise<void> {
|
|
540
|
+
await this.sendAdminRequest(
|
|
541
|
+
`/internal/ai-chat/${threadId}`,
|
|
542
|
+
{
|
|
543
|
+
method: "PATCH",
|
|
544
|
+
headers: {
|
|
545
|
+
"content-type": "application/json",
|
|
546
|
+
},
|
|
547
|
+
body: JSON.stringify({ message }),
|
|
548
|
+
},
|
|
549
|
+
null,
|
|
550
|
+
);
|
|
551
|
+
}
|
|
552
|
+
|
|
553
|
+
async listChatMessages(threadId: string): Promise<{ messages: Array<any> }> {
|
|
554
|
+
const response = await this.sendAdminRequest(
|
|
555
|
+
`/internal/ai-chat/${threadId}`,
|
|
556
|
+
{ method: "GET" },
|
|
557
|
+
null,
|
|
558
|
+
);
|
|
559
|
+
return await response.json();
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
async renderEmailPreview(options: {
|
|
563
|
+
themeId?: string | null | false,
|
|
564
|
+
themeTsxSource?: string,
|
|
565
|
+
templateId?: string,
|
|
566
|
+
templateTsxSource?: string,
|
|
567
|
+
editableMarkers?: boolean,
|
|
568
|
+
editableSource?: 'template' | 'theme' | 'both',
|
|
569
|
+
}): Promise<{ html: string, editable_regions?: Record<string, unknown> }> {
|
|
570
|
+
const response = await this.sendAdminRequest(`/emails/render-email`, {
|
|
571
|
+
method: "POST",
|
|
572
|
+
headers: {
|
|
573
|
+
"content-type": "application/json",
|
|
574
|
+
},
|
|
575
|
+
body: JSON.stringify({
|
|
576
|
+
theme_id: options.themeId,
|
|
577
|
+
theme_tsx_source: options.themeTsxSource,
|
|
578
|
+
template_id: options.templateId,
|
|
579
|
+
template_tsx_source: options.templateTsxSource,
|
|
580
|
+
editable_markers: options.editableMarkers,
|
|
581
|
+
editable_source: options.editableSource,
|
|
582
|
+
}),
|
|
583
|
+
}, null);
|
|
584
|
+
return await response.json();
|
|
585
|
+
}
|
|
586
|
+
|
|
587
|
+
async rewriteTemplateSourceWithAI(templateTsxSource: string): Promise<{ tsx_source: string }> {
|
|
588
|
+
const response = await this.sendAdminRequest(`/internal/rewrite-template-source`, {
|
|
589
|
+
method: "POST",
|
|
590
|
+
headers: {
|
|
591
|
+
"content-type": "application/json",
|
|
592
|
+
},
|
|
593
|
+
body: JSON.stringify({
|
|
594
|
+
template_tsx_source: templateTsxSource,
|
|
595
|
+
}),
|
|
596
|
+
}, null);
|
|
597
|
+
return await response.json();
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
async createEmailTheme(displayName: string): Promise<{ id: string }> {
|
|
601
|
+
const response = await this.sendAdminRequest(
|
|
602
|
+
`/internal/email-themes`,
|
|
603
|
+
{
|
|
604
|
+
method: "POST",
|
|
605
|
+
headers: {
|
|
606
|
+
"content-type": "application/json",
|
|
607
|
+
},
|
|
608
|
+
body: JSON.stringify({
|
|
609
|
+
display_name: displayName,
|
|
610
|
+
}),
|
|
611
|
+
},
|
|
612
|
+
null,
|
|
613
|
+
);
|
|
614
|
+
return await response.json();
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
async getEmailTheme(id: string): Promise<{ display_name: string, tsx_source: string }> {
|
|
618
|
+
const response = await this.sendAdminRequest(
|
|
619
|
+
`/internal/email-themes/${id}`,
|
|
620
|
+
{ method: "GET" },
|
|
621
|
+
null,
|
|
622
|
+
);
|
|
623
|
+
return await response.json();
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
async updateEmailTheme(id: string, tsxSource: string): Promise<void> {
|
|
627
|
+
await this.sendAdminRequest(
|
|
628
|
+
`/internal/email-themes/${id}`,
|
|
629
|
+
{
|
|
630
|
+
method: "PATCH",
|
|
631
|
+
headers: {
|
|
632
|
+
"content-type": "application/json",
|
|
633
|
+
},
|
|
634
|
+
body: JSON.stringify({
|
|
635
|
+
tsx_source: tsxSource,
|
|
636
|
+
}),
|
|
637
|
+
},
|
|
638
|
+
null,
|
|
639
|
+
);
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
async deleteEmailTheme(id: string): Promise<void> {
|
|
643
|
+
await this.sendAdminRequest(
|
|
644
|
+
`/internal/email-themes/${id}`,
|
|
645
|
+
{
|
|
646
|
+
method: "DELETE",
|
|
647
|
+
},
|
|
648
|
+
null,
|
|
649
|
+
);
|
|
650
|
+
}
|
|
651
|
+
|
|
652
|
+
async updateEmailTemplate(id: string, tsxSource: string, themeId: string | null | false): Promise<{ rendered_html: string }> {
|
|
653
|
+
const response = await this.sendAdminRequest(
|
|
654
|
+
`/internal/email-templates/${id}`,
|
|
655
|
+
{
|
|
656
|
+
method: "PATCH",
|
|
657
|
+
headers: {
|
|
658
|
+
"content-type": "application/json",
|
|
659
|
+
},
|
|
660
|
+
body: JSON.stringify({ tsx_source: tsxSource, theme_id: themeId }),
|
|
661
|
+
},
|
|
662
|
+
null,
|
|
663
|
+
);
|
|
664
|
+
return await response.json();
|
|
665
|
+
}
|
|
666
|
+
|
|
667
|
+
async getConfig(): Promise<{ config_string: string }> {
|
|
668
|
+
const response = await this.sendAdminRequest(
|
|
669
|
+
`/internal/config`,
|
|
670
|
+
{ method: "GET" },
|
|
671
|
+
null,
|
|
672
|
+
);
|
|
673
|
+
return await response.json();
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
async getConfigOverride(level: "project" | "branch" | "environment"): Promise<{ config_string: string }> {
|
|
677
|
+
const response = await this.sendAdminRequest(
|
|
678
|
+
`/internal/config/override/${level}`,
|
|
679
|
+
{ method: "GET" },
|
|
680
|
+
null,
|
|
681
|
+
);
|
|
682
|
+
return await response.json();
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
async setConfigOverride(level: "project" | "branch" | "environment", configOverride: any, source?: BranchConfigSourceApi): Promise<void> {
|
|
686
|
+
await this.sendAdminRequest(
|
|
687
|
+
`/internal/config/override/${level}`,
|
|
688
|
+
{
|
|
689
|
+
method: "PUT",
|
|
690
|
+
headers: {
|
|
691
|
+
"content-type": "application/json",
|
|
692
|
+
},
|
|
693
|
+
body: JSON.stringify({
|
|
694
|
+
config_string: JSON.stringify(configOverride),
|
|
695
|
+
...(source && { source }),
|
|
696
|
+
}),
|
|
697
|
+
},
|
|
698
|
+
null,
|
|
699
|
+
);
|
|
700
|
+
}
|
|
701
|
+
|
|
702
|
+
async updateConfigOverride(level: "project" | "branch" | "environment", configOverrideOverride: any): Promise<void> {
|
|
703
|
+
await this.sendAdminRequest(
|
|
704
|
+
`/internal/config/override/${level}`,
|
|
705
|
+
{
|
|
706
|
+
method: "PATCH",
|
|
707
|
+
headers: {
|
|
708
|
+
"content-type": "application/json",
|
|
709
|
+
},
|
|
710
|
+
body: JSON.stringify({ config_override_string: JSON.stringify(configOverrideOverride) }),
|
|
711
|
+
},
|
|
712
|
+
null,
|
|
713
|
+
);
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
async getPushedConfigSource(): Promise<BranchConfigSourceApi> {
|
|
717
|
+
const response = await this.sendAdminRequest(
|
|
718
|
+
`/internal/config/source`,
|
|
719
|
+
{ method: "GET" },
|
|
720
|
+
null,
|
|
721
|
+
);
|
|
722
|
+
const data = await response.json();
|
|
723
|
+
return data.source;
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
async unlinkPushedConfigSource(): Promise<void> {
|
|
727
|
+
await this.sendAdminRequest(
|
|
728
|
+
`/internal/config/source`,
|
|
729
|
+
{ method: "DELETE" },
|
|
730
|
+
null,
|
|
731
|
+
);
|
|
732
|
+
}
|
|
733
|
+
|
|
734
|
+
async resetConfigOverrideKeys(level: "branch" | "environment", keys: string[]): Promise<void> {
|
|
735
|
+
await this.sendAdminRequest(
|
|
736
|
+
`/internal/config/override/${level}/reset-keys`,
|
|
737
|
+
{
|
|
738
|
+
method: "POST",
|
|
739
|
+
headers: {
|
|
740
|
+
"content-type": "application/json",
|
|
741
|
+
},
|
|
742
|
+
body: JSON.stringify({ keys }),
|
|
743
|
+
},
|
|
744
|
+
null,
|
|
745
|
+
);
|
|
746
|
+
}
|
|
747
|
+
async createEmailTemplate(displayName: string): Promise<{ id: string }> {
|
|
748
|
+
const response = await this.sendAdminRequest(
|
|
749
|
+
`/internal/email-templates`,
|
|
750
|
+
{
|
|
751
|
+
method: "POST",
|
|
752
|
+
headers: {
|
|
753
|
+
"content-type": "application/json",
|
|
754
|
+
},
|
|
755
|
+
body: JSON.stringify({
|
|
756
|
+
display_name: displayName,
|
|
757
|
+
}),
|
|
758
|
+
},
|
|
759
|
+
null,
|
|
760
|
+
);
|
|
761
|
+
return await response.json();
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
async deleteEmailTemplate(id: string): Promise<void> {
|
|
765
|
+
await this.sendAdminRequest(
|
|
766
|
+
`/internal/email-templates/${id}`,
|
|
767
|
+
{
|
|
768
|
+
method: "DELETE",
|
|
769
|
+
},
|
|
770
|
+
null,
|
|
771
|
+
);
|
|
772
|
+
}
|
|
773
|
+
|
|
774
|
+
async setupPayments(): Promise<{ url: string }> {
|
|
775
|
+
const response = await this.sendAdminRequest(
|
|
776
|
+
"/internal/payments/setup",
|
|
777
|
+
{
|
|
778
|
+
method: "POST",
|
|
779
|
+
headers: {
|
|
780
|
+
"content-type": "application/json",
|
|
781
|
+
},
|
|
782
|
+
body: JSON.stringify({}),
|
|
783
|
+
},
|
|
784
|
+
null,
|
|
785
|
+
);
|
|
786
|
+
return await response.json();
|
|
787
|
+
}
|
|
788
|
+
|
|
789
|
+
async getStripeAccountInfo(): Promise<null | { account_id: string, charges_enabled: boolean, details_submitted: boolean, payouts_enabled: boolean }> {
|
|
790
|
+
const response = await this.sendAdminRequestAndCatchKnownError(
|
|
791
|
+
"/internal/payments/stripe/account-info",
|
|
792
|
+
{},
|
|
793
|
+
null,
|
|
794
|
+
[KnownErrors.StripeAccountInfoNotFound],
|
|
795
|
+
);
|
|
796
|
+
if (response.status === "error") {
|
|
797
|
+
return null;
|
|
798
|
+
}
|
|
799
|
+
return await response.data.json();
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
async getPaymentMethodConfigs(): Promise<{ configId: string, methods: Array<{ id: string, name: string, enabled: boolean, available: boolean, overridable: boolean }> } | null> {
|
|
803
|
+
const response = await this.sendAdminRequestAndCatchKnownError(
|
|
804
|
+
"/internal/payments/method-configs",
|
|
805
|
+
{ method: "GET" },
|
|
806
|
+
null,
|
|
807
|
+
[KnownErrors.StripeAccountInfoNotFound],
|
|
808
|
+
);
|
|
809
|
+
if (response.status === "error") {
|
|
810
|
+
return null;
|
|
811
|
+
}
|
|
812
|
+
const data = await response.data.json();
|
|
813
|
+
return {
|
|
814
|
+
configId: data.config_id,
|
|
815
|
+
methods: data.methods,
|
|
816
|
+
};
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
async updatePaymentMethodConfigs(configId: string, updates: Record<string, 'on' | 'off'>): Promise<void> {
|
|
820
|
+
await this.sendAdminRequest(
|
|
821
|
+
"/internal/payments/method-configs",
|
|
822
|
+
{
|
|
823
|
+
method: "PATCH",
|
|
824
|
+
headers: { "content-type": "application/json" },
|
|
825
|
+
body: JSON.stringify({ config_id: configId, updates }),
|
|
826
|
+
},
|
|
827
|
+
null,
|
|
828
|
+
);
|
|
829
|
+
}
|
|
830
|
+
|
|
831
|
+
async createStripeWidgetAccountSession(): Promise<{ client_secret: string }> {
|
|
832
|
+
const response = await this.sendAdminRequest(
|
|
833
|
+
"/internal/payments/stripe-widgets/account-session",
|
|
834
|
+
{
|
|
835
|
+
method: "POST",
|
|
836
|
+
headers: {
|
|
837
|
+
"content-type": "application/json",
|
|
838
|
+
},
|
|
839
|
+
body: JSON.stringify({}),
|
|
840
|
+
},
|
|
841
|
+
null,
|
|
842
|
+
);
|
|
843
|
+
return await response.json();
|
|
844
|
+
}
|
|
845
|
+
|
|
846
|
+
async listTransactions(params?: { cursor?: string, limit?: number, type?: TransactionType, customerType?: 'user' | 'team' | 'custom', customerId?: string }): Promise<{ transactions: Transaction[], nextCursor: string | null }> {
|
|
847
|
+
const qs = new URLSearchParams();
|
|
848
|
+
if (params?.cursor) qs.set('cursor', params.cursor);
|
|
849
|
+
if (typeof params?.limit === 'number') qs.set('limit', String(params.limit));
|
|
850
|
+
if (params?.type) qs.set('type', params.type);
|
|
851
|
+
if (params?.customerType) qs.set('customer_type', params.customerType);
|
|
852
|
+
if (params?.customerId) qs.set('customer_id', params.customerId);
|
|
853
|
+
const response = await this.sendAdminRequest(
|
|
854
|
+
`/internal/payments/transactions${qs.size ? `?${qs.toString()}` : ''}`,
|
|
855
|
+
{ method: 'GET' },
|
|
856
|
+
null,
|
|
857
|
+
);
|
|
858
|
+
const json = await response.json() as { transactions: Transaction[], next_cursor: string | null };
|
|
859
|
+
return { transactions: json.transactions, nextCursor: json.next_cursor };
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
async listSessionReplays(params?: AdminListSessionReplaysOptions): Promise<AdminListSessionReplaysResponse> {
|
|
863
|
+
const qs = new URLSearchParams();
|
|
864
|
+
if (params?.cursor) qs.set("cursor", params.cursor);
|
|
865
|
+
if (typeof params?.limit === "number") qs.set("limit", String(params.limit));
|
|
866
|
+
if (params?.user_ids && params.user_ids.length > 0) qs.set("user_ids", params.user_ids.join(","));
|
|
867
|
+
if (params?.team_ids && params.team_ids.length > 0) qs.set("team_ids", params.team_ids.join(","));
|
|
868
|
+
if (typeof params?.duration_ms_min === "number") qs.set("duration_ms_min", String(params.duration_ms_min));
|
|
869
|
+
if (typeof params?.duration_ms_max === "number") qs.set("duration_ms_max", String(params.duration_ms_max));
|
|
870
|
+
if (typeof params?.last_event_at_from_millis === "number") qs.set("last_event_at_from_millis", String(params.last_event_at_from_millis));
|
|
871
|
+
if (typeof params?.last_event_at_to_millis === "number") qs.set("last_event_at_to_millis", String(params.last_event_at_to_millis));
|
|
872
|
+
if (typeof params?.click_count_min === "number") qs.set("click_count_min", String(params.click_count_min));
|
|
873
|
+
const response = await this.sendAdminRequest(
|
|
874
|
+
`/internal/session-replays${qs.size ? `?${qs.toString()}` : ""}`,
|
|
875
|
+
{ method: "GET" },
|
|
876
|
+
null,
|
|
877
|
+
);
|
|
878
|
+
return await response.json();
|
|
879
|
+
}
|
|
880
|
+
|
|
881
|
+
async getSessionReplay(sessionReplayId: string): Promise<AdminGetSessionReplayResponse> {
|
|
882
|
+
const response = await this.sendAdminRequest(
|
|
883
|
+
`/internal/session-replays/${encodeURIComponent(sessionReplayId)}`,
|
|
884
|
+
{ method: "GET" },
|
|
885
|
+
null,
|
|
886
|
+
);
|
|
887
|
+
return await response.json();
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
async listSessionReplayChunks(sessionReplayId: string, params?: AdminListSessionReplayChunksOptions): Promise<AdminListSessionReplayChunksResponse> {
|
|
891
|
+
const qs = new URLSearchParams();
|
|
892
|
+
if (params?.cursor) qs.set("cursor", params.cursor);
|
|
893
|
+
if (typeof params?.limit === "number") qs.set("limit", String(params.limit));
|
|
894
|
+
const response = await this.sendAdminRequest(
|
|
895
|
+
`/internal/session-replays/${encodeURIComponent(sessionReplayId)}/chunks${qs.size ? `?${qs.toString()}` : ""}`,
|
|
896
|
+
{ method: "GET" },
|
|
897
|
+
null,
|
|
898
|
+
);
|
|
899
|
+
return await response.json();
|
|
900
|
+
}
|
|
901
|
+
|
|
902
|
+
async getSessionReplayChunkEvents(sessionReplayId: string, chunkId: string): Promise<AdminGetSessionReplayChunkEventsResponse> {
|
|
903
|
+
const response = await this.sendAdminRequest(
|
|
904
|
+
`/internal/session-replays/${encodeURIComponent(sessionReplayId)}/chunks/${encodeURIComponent(chunkId)}/events`,
|
|
905
|
+
{ method: "GET" },
|
|
906
|
+
null,
|
|
907
|
+
);
|
|
908
|
+
return await response.json();
|
|
909
|
+
}
|
|
910
|
+
|
|
911
|
+
async getSessionReplayEvents(sessionReplayId: string, options?: { offset?: number, limit?: number }): Promise<AdminGetSessionReplayAllEventsResponse> {
|
|
912
|
+
const qs = new URLSearchParams();
|
|
913
|
+
if (typeof options?.offset === "number") qs.set("offset", String(options.offset));
|
|
914
|
+
if (typeof options?.limit === "number") qs.set("limit", String(options.limit));
|
|
915
|
+
const response = await this.sendAdminRequest(
|
|
916
|
+
`/internal/session-replays/${encodeURIComponent(sessionReplayId)}/events${qs.size ? `?${qs.toString()}` : ""}`,
|
|
917
|
+
{ method: "GET" },
|
|
918
|
+
null,
|
|
919
|
+
);
|
|
920
|
+
return await response.json();
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
async refundTransaction(options: {
|
|
924
|
+
type: "subscription" | "one-time-purchase",
|
|
925
|
+
id: string,
|
|
926
|
+
invoiceId?: string,
|
|
927
|
+
amountUsd: MoneyAmount,
|
|
928
|
+
/**
|
|
929
|
+
* Lifecycle action for the source purchase:
|
|
930
|
+
* "now" — end product access immediately (revokes product,
|
|
931
|
+
* expires item grants, cancels Stripe sub if any).
|
|
932
|
+
* "at-period-end" — schedule sub cancel-at-period-end; subscriptions
|
|
933
|
+
* only — rejected for one-time purchases.
|
|
934
|
+
* undefined — no lifecycle change; refund money only.
|
|
935
|
+
*/
|
|
936
|
+
endAction?: "now" | "at-period-end",
|
|
937
|
+
}): Promise<{ success: boolean, refundTransactionId: string }> {
|
|
938
|
+
const response = await this.sendAdminRequest(
|
|
939
|
+
"/internal/payments/transactions/refund",
|
|
940
|
+
{
|
|
941
|
+
method: "POST",
|
|
942
|
+
headers: {
|
|
943
|
+
"content-type": "application/json",
|
|
944
|
+
},
|
|
945
|
+
body: JSON.stringify({
|
|
946
|
+
type: options.type,
|
|
947
|
+
id: options.id,
|
|
948
|
+
...(options.invoiceId !== undefined ? { invoice_id: options.invoiceId } : {}),
|
|
949
|
+
amount_usd: options.amountUsd,
|
|
950
|
+
...(options.endAction !== undefined ? { end_action: options.endAction } : {}),
|
|
951
|
+
}),
|
|
952
|
+
},
|
|
953
|
+
null,
|
|
954
|
+
);
|
|
955
|
+
const json = await response.json();
|
|
956
|
+
return { success: json.success, refundTransactionId: json.refund_transaction_id };
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
|
|
960
|
+
async previewAffectedUsersByOnboardingChange(
|
|
961
|
+
onboarding: { require_email_verification?: boolean },
|
|
962
|
+
limit?: number,
|
|
963
|
+
): Promise<{
|
|
964
|
+
affected_users: Array<{
|
|
965
|
+
id: string,
|
|
966
|
+
display_name: string | null,
|
|
967
|
+
primary_email: string | null,
|
|
968
|
+
restricted_reason: RestrictedReason,
|
|
969
|
+
}>,
|
|
970
|
+
total_affected_count: number,
|
|
971
|
+
}> {
|
|
972
|
+
const response = await this.sendAdminRequest(
|
|
973
|
+
`/internal/onboarding/preview-affected-users${limit ? `?limit=${limit}` : ''}`,
|
|
974
|
+
{
|
|
975
|
+
method: "POST",
|
|
976
|
+
headers: {
|
|
977
|
+
"content-type": "application/json",
|
|
978
|
+
},
|
|
979
|
+
body: JSON.stringify({ onboarding }),
|
|
980
|
+
},
|
|
981
|
+
null,
|
|
982
|
+
);
|
|
983
|
+
return await response.json();
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
async queryAnalytics(options: AnalyticsQueryOptions): Promise<AnalyticsQueryResponse> {
|
|
987
|
+
const response = await this.sendAdminRequest(
|
|
988
|
+
"/internal/analytics/query",
|
|
989
|
+
{
|
|
990
|
+
method: "POST",
|
|
991
|
+
headers: { "content-type": "application/json" },
|
|
992
|
+
body: JSON.stringify({
|
|
993
|
+
query: options.query,
|
|
994
|
+
params: options.params ?? {},
|
|
995
|
+
timeout_ms: options.timeout_ms ?? 1000,
|
|
996
|
+
include_all_branches: options.include_all_branches ?? false,
|
|
997
|
+
}),
|
|
998
|
+
},
|
|
999
|
+
null,
|
|
1000
|
+
);
|
|
1001
|
+
|
|
1002
|
+
return await response.json();
|
|
1003
|
+
}
|
|
1004
|
+
|
|
1005
|
+
async listOutboxEmails(options?: { status?: string, simple_status?: string, limit?: number, cursor?: string }): Promise<EmailOutboxCrud["Server"]["List"]> {
|
|
1006
|
+
const qs = new URLSearchParams();
|
|
1007
|
+
if (options?.status) qs.set('status', options.status);
|
|
1008
|
+
if (options?.simple_status) qs.set('simple_status', options.simple_status);
|
|
1009
|
+
if (options?.limit !== undefined) qs.set('limit', options.limit.toString());
|
|
1010
|
+
if (options?.cursor) qs.set('cursor', options.cursor);
|
|
1011
|
+
const response = await this.sendServerRequest(
|
|
1012
|
+
`/emails/outbox${qs.size ? `?${qs.toString()}` : ''}`,
|
|
1013
|
+
{ method: 'GET' },
|
|
1014
|
+
null,
|
|
1015
|
+
);
|
|
1016
|
+
return await response.json();
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
async getOutboxEmail(id: string): Promise<EmailOutboxCrud["Server"]["Read"]> {
|
|
1020
|
+
const response = await this.sendServerRequest(
|
|
1021
|
+
`/emails/outbox/${id}`,
|
|
1022
|
+
{ method: 'GET' },
|
|
1023
|
+
null,
|
|
1024
|
+
);
|
|
1025
|
+
return await response.json();
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
async updateOutboxEmail(id: string, data: EmailOutboxCrud["Server"]["Update"]): Promise<EmailOutboxCrud["Server"]["Read"]> {
|
|
1029
|
+
const response = await this.sendServerRequest(
|
|
1030
|
+
`/emails/outbox/${id}`,
|
|
1031
|
+
{
|
|
1032
|
+
method: 'PATCH',
|
|
1033
|
+
headers: {
|
|
1034
|
+
"content-type": "application/json",
|
|
1035
|
+
},
|
|
1036
|
+
body: JSON.stringify(data),
|
|
1037
|
+
},
|
|
1038
|
+
null,
|
|
1039
|
+
);
|
|
1040
|
+
return await response.json();
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
}
|