@sylphx/sdk 0.10.7 → 0.11.1

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.
@@ -1,4 +1,4 @@
1
- import { SdkBillingPlan, SdkBillingSubscription, SdkConsentType, UserConsent as UserConsent$1, ReferralRewardDefaults as ReferralRewardDefaults$1, WebhookDelivery as WebhookDelivery$2, OrgSdkRole, OrgInvitation, OrgMember, Organization, File as File$1, FileId } from '@sylphx/contract';
1
+ import { SdkBillingPlan, SdkBillingSubscription, SdkConsentType, UserConsent as UserConsent$1, ReferralRewardDefaults as ReferralRewardDefaults$1, WebhookDelivery as WebhookDelivery$2, OrgSdkRole, OrgInvitation, OrgMember, CreateOrgInput as CreateOrgInput$1, Organization, File as File$1, FileId } from '@sylphx/contract';
2
2
  export { Organization, File as StorageFile, FileId as StorageFileId } from '@sylphx/contract';
3
3
  import * as react_jsx_runtime from 'react/jsx-runtime';
4
4
  import * as react from 'react';
@@ -2466,6 +2466,7 @@ type OrganizationMember = Omit<OrgMember, 'role'> & {
2466
2466
  };
2467
2467
  type OrganizationInvitation = OrgInvitation;
2468
2468
  type OrgRole = OrgSdkRole;
2469
+ type CreateOrgInput = CreateOrgInput$1;
2469
2470
 
2470
2471
  /**
2471
2472
  * OAuth SDK — customer-app-facing social login (ADR-089 Phase 4a)
@@ -2834,11 +2835,7 @@ interface UseOrganizationReturn {
2834
2835
  /** Switch to a different organization and refresh the active session token. */
2835
2836
  switchOrg: (orgIdOrSlug: string | null) => Promise<void>;
2836
2837
  /** Create a new organization */
2837
- createOrganization: (data: {
2838
- name: string;
2839
- slug?: string;
2840
- email?: string;
2841
- }) => Promise<Organization>;
2838
+ createOrganization: (data: CreateOrgInput) => Promise<Organization>;
2842
2839
  /** Update current organization */
2843
2840
  updateOrganization: (data: {
2844
2841
  name?: string;
@@ -3954,6 +3951,7 @@ declare function useAIContext(): AIContextValue;
3954
3951
  /** Job type with all optional fields for flexibility */
3955
3952
  interface Job {
3956
3953
  id: string;
3954
+ scheduleId?: string | null;
3957
3955
  name: string | null;
3958
3956
  type: string;
3959
3957
  status: JobStatus;
@@ -3972,8 +3970,6 @@ interface Job {
3972
3970
  /** Result of checkStatus() for the Tasks service */
3973
3971
  interface TasksStatusResult {
3974
3972
  available: boolean;
3975
- configured: boolean;
3976
- status: string;
3977
3973
  }
3978
3974
  /** @deprecated Use TaskStatusFilter */
3979
3975
  type JobStatusFilter = TaskStatusFilter$1;
@@ -13586,7 +13582,7 @@ interface StreamMessage<T = unknown> {
13586
13582
  /**
13587
13583
  * Real-time Streaming Hooks
13588
13584
  *
13589
- * SSE-based real-time subscriptions for Redis Streams.
13585
+ * SSE-based real-time subscriptions for managed durable streams.
13590
13586
  * Automatic reconnection, message history, and optimistic updates.
13591
13587
  *
13592
13588
  * @example
@@ -13759,7 +13755,7 @@ interface KvZMember {
13759
13755
  /**
13760
13756
  * KV (Key-Value Store) React Hooks
13761
13757
  *
13762
- * Client-side hooks for key-value operations via Upstash Redis.
13758
+ * Client-side hooks for managed key-value operations.
13763
13759
  * Provides React Query integration for caching and state management.
13764
13760
  *
13765
13761
  * @example
@@ -526,14 +526,23 @@ var NotFoundError = class extends SylphxError {
526
526
  function isSylphxError(error) {
527
527
  return error instanceof SylphxError;
528
528
  }
529
- function getErrorMessage(error) {
529
+ function getErrorMessage(error, fallback = "An unknown error occurred") {
530
530
  if (error instanceof Error) {
531
531
  return error.message;
532
532
  }
533
533
  if (typeof error === "string") {
534
534
  return error;
535
535
  }
536
- return "An unknown error occurred";
536
+ if (error && typeof error === "object" && "message" in error) {
537
+ const message = error.message;
538
+ if (typeof message === "string") return message;
539
+ }
540
+ if (error && typeof error === "object" && "response" in error) {
541
+ const response = error.response;
542
+ if (response?.data?.message) return response.data.message;
543
+ if (response?.data?.error) return response.data.error;
544
+ }
545
+ return fallback;
537
546
  }
538
547
  function toSylphxError(error) {
539
548
  if (error instanceof SylphxError) {
@@ -1448,8 +1457,9 @@ async function getOrganization(config2, orgIdOrSlug) {
1448
1457
  return callApi(config2, `/orgs/${orgIdOrSlug}`);
1449
1458
  }
1450
1459
  async function createOrganization(config2, input) {
1451
- return callApi(config2, "/orgs", {
1452
- method: "POST",
1460
+ const endpoint = organizationsEndpoints.create;
1461
+ return callApi(config2, endpoint.path, {
1462
+ method: endpoint.method,
1453
1463
  body: input
1454
1464
  });
1455
1465
  }
@@ -2050,7 +2060,7 @@ function DeveloperSetupCard({ theme }) {
2050
2060
  /* @__PURE__ */ jsxs(
2051
2061
  "a",
2052
2062
  {
2053
- href: "https://sylphx.com/docs/sdk/getting-started",
2063
+ href: "https://sylphx.com/docs/installation",
2054
2064
  target: "_blank",
2055
2065
  rel: "noopener noreferrer",
2056
2066
  style: styles.docsButton,
@@ -5471,8 +5481,7 @@ function OrganizationSwitcherInner({
5471
5481
  if (!newOrgName.trim()) return;
5472
5482
  setError(null);
5473
5483
  try {
5474
- const slug = newOrgName.toLowerCase().replace(/[^a-z0-9]+/g, "-");
5475
- const newOrg = await createOrganization2({ name: newOrgName, slug });
5484
+ const newOrg = await createOrganization2({ name: newOrgName.trim() });
5476
5485
  setNewOrgName("");
5477
5486
  setIsCreating(false);
5478
5487
  setIsOpen(false);
@@ -17538,6 +17547,42 @@ function CheckIcon10({ color }) {
17538
17547
 
17539
17548
  // src/react/ui/billing-management.tsx
17540
17549
  import { useEffect as useEffect28, useState as useState36 } from "react";
17550
+
17551
+ // src/formatting.ts
17552
+ function formatCurrency(amount, optsOrCompact = false) {
17553
+ const opts = typeof optsOrCompact === "boolean" ? { compact: optsOrCompact } : optsOrCompact;
17554
+ const currency = (opts.currency ?? "USD").toUpperCase();
17555
+ const decimals = opts.decimals ?? 2;
17556
+ if (opts.compact && Math.abs(amount) >= 1e3) {
17557
+ return new Intl.NumberFormat("en-US", {
17558
+ style: "currency",
17559
+ currency,
17560
+ notation: "compact",
17561
+ minimumFractionDigits: 1,
17562
+ maximumFractionDigits: 1
17563
+ }).format(amount);
17564
+ }
17565
+ return new Intl.NumberFormat("en-US", {
17566
+ style: "currency",
17567
+ currency,
17568
+ minimumFractionDigits: decimals,
17569
+ maximumFractionDigits: decimals
17570
+ }).format(amount);
17571
+ }
17572
+ var relativeTimeFormatter = new Intl.RelativeTimeFormat("en", {
17573
+ numeric: "auto"
17574
+ });
17575
+ var TIME_DIVISIONS = [
17576
+ { amount: 60, unit: "second" },
17577
+ { amount: 60, unit: "minute" },
17578
+ { amount: 24, unit: "hour" },
17579
+ { amount: 7, unit: "day" },
17580
+ { amount: 4.34524, unit: "week" },
17581
+ { amount: 12, unit: "month" },
17582
+ { amount: Number.POSITIVE_INFINITY, unit: "year" }
17583
+ ];
17584
+
17585
+ // src/react/ui/billing-management.tsx
17541
17586
  import { Fragment as Fragment20, jsx as jsx28, jsxs as jsxs23 } from "react/jsx-runtime";
17542
17587
  function InvoiceHistory({
17543
17588
  theme = defaultTheme,
@@ -17557,12 +17602,7 @@ function InvoiceHistory({
17557
17602
  }, []);
17558
17603
  const totalPages = Math.ceil(invoices.length / pageSize);
17559
17604
  const paginatedInvoices = invoices.slice((currentPage - 1) * pageSize, currentPage * pageSize);
17560
- const formatCurrency = (amount, currency) => {
17561
- return new Intl.NumberFormat("en-US", {
17562
- style: "currency",
17563
- currency: currency.toUpperCase()
17564
- }).format(amount / 100);
17565
- };
17605
+ const formatInvoice = (amountCents, currency) => formatCurrency(amountCents / 100, { currency });
17566
17606
  const formatDate = (dateStr) => {
17567
17607
  return new Date(dateStr).toLocaleDateString("en-US", {
17568
17608
  year: "numeric",
@@ -17660,7 +17700,7 @@ function InvoiceHistory({
17660
17700
  )
17661
17701
  ] }),
17662
17702
  /* @__PURE__ */ jsx28("td", { style: tdStyle, children: formatDate(invoice.date) }),
17663
- /* @__PURE__ */ jsx28("td", { style: tdStyle, children: /* @__PURE__ */ jsx28("span", { style: { fontWeight: 500 }, children: formatCurrency(invoice.amount, invoice.currency) }) }),
17703
+ /* @__PURE__ */ jsx28("td", { style: tdStyle, children: /* @__PURE__ */ jsx28("span", { style: { fontWeight: 500 }, children: formatInvoice(invoice.amount, invoice.currency) }) }),
17664
17704
  /* @__PURE__ */ jsx28("td", { style: tdStyle, children: /* @__PURE__ */ jsx28(
17665
17705
  "span",
17666
17706
  {
@@ -17954,12 +17994,7 @@ function UsageOverview({
17954
17994
  useEffect28(() => {
17955
17995
  injectGlobalStyles();
17956
17996
  }, []);
17957
- const formatCurrency = (amount) => {
17958
- return new Intl.NumberFormat("en-US", {
17959
- style: "currency",
17960
- currency: currency.toUpperCase()
17961
- }).format(amount);
17962
- };
17997
+ const format = (amount) => formatCurrency(amount, { currency });
17963
17998
  const containerStyle = {
17964
17999
  fontFamily: theme.fontFamily,
17965
18000
  border: `1px solid ${theme.colorBorder}`,
@@ -17994,7 +18029,7 @@ function UsageOverview({
17994
18029
  )
17995
18030
  ] }),
17996
18031
  totalCost !== void 0 && /* @__PURE__ */ jsxs23("div", { style: { textAlign: "right" }, children: [
17997
- /* @__PURE__ */ jsx28("div", { style: { fontSize: theme.fontSizeXl, fontWeight: 600 }, children: formatCurrency(totalCost) }),
18032
+ /* @__PURE__ */ jsx28("div", { style: { fontSize: theme.fontSizeXl, fontWeight: 600 }, children: format(totalCost) }),
17998
18033
  /* @__PURE__ */ jsx28(
17999
18034
  "div",
18000
18035
  {
@@ -18048,7 +18083,7 @@ function UsageOverview({
18048
18083
  item.limit.toLocaleString(),
18049
18084
  " ",
18050
18085
  item.unit,
18051
- item.cost !== void 0 && ` \u2022 ${formatCurrency(item.cost)}`
18086
+ item.cost !== void 0 && ` \u2022 ${format(item.cost)}`
18052
18087
  ]
18053
18088
  }
18054
18089
  )
@@ -35315,41 +35350,24 @@ function useFeatureFlags2() {
35315
35350
  }
35316
35351
  function useFlag(flagKey, defaultValue = false) {
35317
35352
  const { isEnabled, updateVersion } = useFeatureFlagsContext();
35318
- return useMemo12(
35319
- () => isEnabled(flagKey, defaultValue),
35320
- // eslint-disable-next-line react-hooks/exhaustive-deps
35321
- [flagKey, defaultValue, isEnabled]
35322
- );
35353
+ return useMemo12(() => isEnabled(flagKey, defaultValue), [flagKey, defaultValue, isEnabled]);
35323
35354
  }
35324
35355
  function useFlagString(flagKey, defaultValue = "") {
35325
35356
  const { getString, updateVersion } = useFeatureFlagsContext();
35326
- return useMemo12(
35327
- () => getString(flagKey, defaultValue),
35328
- // eslint-disable-next-line react-hooks/exhaustive-deps
35329
- [flagKey, defaultValue, getString]
35330
- );
35357
+ return useMemo12(() => getString(flagKey, defaultValue), [flagKey, defaultValue, getString]);
35331
35358
  }
35332
35359
  function useFlagNumber(flagKey, defaultValue = 0) {
35333
35360
  const { getNumber, updateVersion } = useFeatureFlagsContext();
35334
- return useMemo12(
35335
- () => getNumber(flagKey, defaultValue),
35336
- // eslint-disable-next-line react-hooks/exhaustive-deps
35337
- [flagKey, defaultValue, getNumber]
35338
- );
35361
+ return useMemo12(() => getNumber(flagKey, defaultValue), [flagKey, defaultValue, getNumber]);
35339
35362
  }
35340
35363
  function useFlagJSON(flagKey, defaultValue) {
35341
35364
  const { getJSON, updateVersion } = useFeatureFlagsContext();
35342
- return useMemo12(
35343
- () => getJSON(flagKey, defaultValue),
35344
- // eslint-disable-next-line react-hooks/exhaustive-deps
35345
- [flagKey, defaultValue, getJSON]
35346
- );
35365
+ return useMemo12(() => getJSON(flagKey, defaultValue), [flagKey, defaultValue, getJSON]);
35347
35366
  }
35348
35367
  function useFlagEvaluation(flagKey, defaultValue, contextOverride) {
35349
35368
  const { evaluate, updateVersion } = useFeatureFlagsContext();
35350
35369
  return useMemo12(
35351
35370
  () => evaluate(flagKey, defaultValue, contextOverride),
35352
- // eslint-disable-next-line react-hooks/exhaustive-deps
35353
35371
  [flagKey, defaultValue, contextOverride, evaluate]
35354
35372
  );
35355
35373
  }