@fonderie/client 1.3.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1203,6 +1203,30 @@ declare class MediaClient {
1203
1203
  assetIdFromUrl(url: string | null | undefined): string | null;
1204
1204
  }
1205
1205
 
1206
+ interface IRemoteConfigState {
1207
+ /** key → value, as last loaded. Empty until the first load succeeds. */
1208
+ values: Readonly<Record<string, unknown>>;
1209
+ /** When values were last loaded successfully; null before that. */
1210
+ loadedAt: Date | null;
1211
+ isLoading: boolean;
1212
+ /** The last load's failure, cleared by the next success. Values are kept. */
1213
+ error: unknown;
1214
+ }
1215
+ type Listener = (state: IRemoteConfigState) => void;
1216
+ declare class ConfigClient {
1217
+ private http;
1218
+ private tokens;
1219
+ private state;
1220
+ private listeners;
1221
+ private inFlight;
1222
+ constructor(http: HttpClient, tokens: TokenStore);
1223
+ load(): Promise<IRemoteConfigState>;
1224
+ get<T>(key: string, fallback: T): T;
1225
+ snapshot(): IRemoteConfigState;
1226
+ subscribe(listener: Listener): () => void;
1227
+ private set;
1228
+ }
1229
+
1206
1230
  interface ICreateWebhookEndpointInput {
1207
1231
  url: string;
1208
1232
  events?: string[];
@@ -1345,6 +1369,8 @@ declare class FonderieClient {
1345
1369
  readonly webhooks: WebhooksClient;
1346
1370
  readonly customers: CustomersClient;
1347
1371
  readonly media: MediaClient;
1372
+ /** Public remote config: flags and settings the server exposes to frontends. */
1373
+ readonly config: ConfigClient;
1348
1374
  private http;
1349
1375
  private tokens;
1350
1376
  private workspaceId;
@@ -1378,6 +1404,9 @@ interface ISetConfigInput {
1378
1404
  description?: string;
1379
1405
  active?: boolean;
1380
1406
  ifVersion?: number;
1407
+ /** Required to change an existing key's value kind (on/off → text, list → object);
1408
+ * without it the server answers 409 CONFIG_TYPE_CHANGE. */
1409
+ allowTypeChange?: boolean;
1381
1410
  }
1382
1411
  interface ISetSecretInput {
1383
1412
  value: string;
@@ -1617,5 +1646,25 @@ declare function castConfigValue(type: ConfigValueType, raw: string): CastResult
1617
1646
  */
1618
1647
  declare const CONFIG_KEY_PATTERN: RegExp;
1619
1648
  declare function configKeyProblem(key: string): string | null;
1649
+ interface IInferredConfigValue {
1650
+ type: ConfigValueType;
1651
+ value: unknown;
1652
+ /** Human label for the detected shape: Text, Number, On/off, Object, List. */
1653
+ label: string;
1654
+ /**
1655
+ * True when the input could equally be meant as text — "true", "42". The
1656
+ * editor offers "save as text instead" for exactly these, and never needs
1657
+ * to ask about anything else.
1658
+ */
1659
+ ambiguous: boolean;
1660
+ }
1661
+ /** Human label for a stored value's shape. */
1662
+ declare function configValueLabel(value: unknown): string;
1663
+ /**
1664
+ * Work out what an operator typed, without asking. Objects and lists (JSON
1665
+ * starting with { or [), on/off (true/false), plain numbers, and text for
1666
+ * everything else — including anything that merely resembles a number.
1667
+ */
1668
+ declare function inferConfigValue(raw: string): IInferredConfigValue;
1620
1669
 
1621
- export { AdminClient, type AdminRouteGuard, type AdminScope, AuditAdminClient, AuditClient, AuthAdminClient, AuthClient, BillingAdminClient, BillingClient, CONFIG_KEY_PATTERN, CONFIG_VALUE_TYPES, type CastResult, ConfigAdminClient, type ConfigValueType, CourierAdminClient, type CustomerLabelType, type CustomerSex, type CustomerType, CustomersClient, FonderieApiError, FonderieClient, type IAcceptInvitationResult, type IAddAddressInput, type IAddEmailInput, type IAddPhoneInput, type IAddRelationshipInput, type IAddressDTO, type IAdminAttention, type IAdminAttentionItem, type IAdminAuditQuery, type IAdminCatalog, type IAdminCheckResult, type IAdminClientOptions, type IAdminDoctorReport, type IAdminEnvironmentReport, type IAdminGrantInput, type IAdminIssueTokenInput, type IAdminIssuedToken, type IAdminLedgerQuery, type IAdminLogEntry, type IAdminLogPage, type IAdminLogQuery, type IAdminLoginHistoryQuery, type IAdminManifest, type IAdminMigrationModule, type IAdminMigrationsReport, type IAdminModuleEntry, type IAdminPendingMigration, type IAdminPlanInput, type IAdminReadiness, type IAdminReadinessProblem, type IAdminRouteEntry, type IAdminRoutesReport, type IAdminSubscriptionDTO, type IAdminSubscriptionPage, type IAdminSubscriptionsQuery, type IAdminTokenRecord, type IAdminTokensReport, type IAdminUserDTO, type IAdminUserPageResult, type IAdminUsersQuery, type IAdminWalletDTO, type IAdminWalletLedgerPage, type IApiError, type IApiResponse, type IAppleNativeInput, type IAuditAdminClientOptions, type IAuditEventDTO, type IAuditPageResult, type IAuthAdminClientOptions, type IBillingAdminClientOptions, type IBlacklistCustomerInput, type ICache, type ICancelSubscriptionInput, type IChangePasswordInput, type ICheckoutInput, type ICheckoutUrlResult, type IClientAuthConfig, type IConfigAdminClientOptions, type IConfigEntry, type IConfigRevision, type ICourierAdminClientOptions, type ICreateCustomerInput, type ICreatePlanInput, type ICreateRoleInput, type ICreateWebhookEndpointInput, type ICreateWorkspaceInput, type ICustomerAddressDTO, type ICustomerAddressListResult, type ICustomerAddressResult, type ICustomerDTO, type ICustomerDetailD2DTO, type ICustomerDetailDTO, type ICustomerEmailDTO, type ICustomerEmailListResult, type ICustomerEmailResult, type ICustomerLabelDTO, type ICustomerLabelListResult, type ICustomerListResult, type ICustomerNoteDTO, type ICustomerNoteListResult, type ICustomerNoteResult, type ICustomerPhoneDTO, type ICustomerPhoneListResult, type ICustomerPhoneResult, type ICustomerRelationshipDTO, type ICustomerRelationshipExpandedD2DTO, type ICustomerRelationshipExpandedDTO, type ICustomerRelationshipListResult, type ICustomerRelationshipResult, type ICustomerResult, type ICustomerShallowDTO, type ICustomerTagListResult, type IFonderieClientOptions, type IGetCustomerInput, type IGetLoginHistoryInput, type IInvitationDTO, type IInvitationListResult, type IInviteEntry, type IInviteResult, type IInvoiceDTO, type IInvoicesResult, type IListAuditEventsInput, type IListCustomersInput, type ILoginEventDTO, type ILoginHistoryPageResult, type ILoginInput, type ILoginResult, type IMeResult, type IMediaAssetDTO, type IMediaAssetResult, type IMemberDTO, type IMemberListResult, type IMemoryCacheOptions, type IMfaEnabledResult, type IMfaRequiredResult, type IMfaSetupResult, type IPaymentMethodDTO, type IPaymentMethodResult, type IPlanDTO, type IPlanFeature, type IPlanListResult, type IPlanResult, type IPortalUrlResult, type IPreviewTemplateInput, type IReadOptions, type IRecordUsageInput, type IRefreshResult, type IRegisterInput, type IRegisterResult, type IRenderedTemplateResult, type IRequestConfig, type IRequestLocationDTO, type IResendVerificationResult, type IResetPasswordInput, type IRevealSecretResult, type IRoleDTO, type IRoleListResult, type IRolePermission, type IRolePermissionInput, type IRolePermissionsResult, type IRoleResult, type IRollbackInput, type IRollbackTemplateInput, type ISecretEntry, type ISecretRevision, type ISessionDTO, type ISessionsResult, type ISetConfigInput, type ISetSecretInput, type ISetTemplateInput, type ISubscriptionChangeResult, type ISubscriptionDTO, type ISubscriptionResult, type ITemplateEntry, type ITemplateRevision, type ITestWebhookResult, type ITokens, type IUpdateCustomerInput, type IUpdatePlanInput, type IUpdatePreferencesInput, type IUpdateProfileInput, type IUpdateRoleInput, type IUpdateSettingsInput, type IUpdateWebhookEndpointInput, type IUpdateWorkspaceInput, type IUploadMediaInput, type IUsageResult, type IUserDTO, type IUserPreferences, type IVerifyEmailResult, type IWalletCheckoutInput, type IWalletDTO, type IWalletPreferencesInput, type IWalletPurchaseInput, type IWalletPurchaseResult, type IWalletResult, type IWalletTransactionDTO, type IWalletTransactionsResult, type IWebhookDeliveryDTO, type IWebhookDeliveryListResult, type IWebhookEndpointCreatedDTO, type IWebhookEndpointDTO, type IWebhookEndpointListResult, type IWorkspaceAddressDTO, type IWorkspaceDTO, type IWorkspaceListResult, type IWorkspaceResult, type IWorkspaceSettingsDTO, type IWorkspaceSettingsResult, MediaClient, type MigrationImpact, type SubscriberType, WebhooksClient, WorkspacesClient, castConfigValue, configKeyProblem, configValueType, createMemoryCache, describeLocation, formatConfigValue, isMfaRequired };
1670
+ export { AdminClient, type AdminRouteGuard, type AdminScope, AuditAdminClient, AuditClient, AuthAdminClient, AuthClient, BillingAdminClient, BillingClient, CONFIG_KEY_PATTERN, CONFIG_VALUE_TYPES, type CastResult, ConfigAdminClient, ConfigClient, type ConfigValueType, CourierAdminClient, type CustomerLabelType, type CustomerSex, type CustomerType, CustomersClient, FonderieApiError, FonderieClient, type IAcceptInvitationResult, type IAddAddressInput, type IAddEmailInput, type IAddPhoneInput, type IAddRelationshipInput, type IAddressDTO, type IAdminAttention, type IAdminAttentionItem, type IAdminAuditQuery, type IAdminCatalog, type IAdminCheckResult, type IAdminClientOptions, type IAdminDoctorReport, type IAdminEnvironmentReport, type IAdminGrantInput, type IAdminIssueTokenInput, type IAdminIssuedToken, type IAdminLedgerQuery, type IAdminLogEntry, type IAdminLogPage, type IAdminLogQuery, type IAdminLoginHistoryQuery, type IAdminManifest, type IAdminMigrationModule, type IAdminMigrationsReport, type IAdminModuleEntry, type IAdminPendingMigration, type IAdminPlanInput, type IAdminReadiness, type IAdminReadinessProblem, type IAdminRouteEntry, type IAdminRoutesReport, type IAdminSubscriptionDTO, type IAdminSubscriptionPage, type IAdminSubscriptionsQuery, type IAdminTokenRecord, type IAdminTokensReport, type IAdminUserDTO, type IAdminUserPageResult, type IAdminUsersQuery, type IAdminWalletDTO, type IAdminWalletLedgerPage, type IApiError, type IApiResponse, type IAppleNativeInput, type IAuditAdminClientOptions, type IAuditEventDTO, type IAuditPageResult, type IAuthAdminClientOptions, type IBillingAdminClientOptions, type IBlacklistCustomerInput, type ICache, type ICancelSubscriptionInput, type IChangePasswordInput, type ICheckoutInput, type ICheckoutUrlResult, type IClientAuthConfig, type IConfigAdminClientOptions, type IConfigEntry, type IConfigRevision, type ICourierAdminClientOptions, type ICreateCustomerInput, type ICreatePlanInput, type ICreateRoleInput, type ICreateWebhookEndpointInput, type ICreateWorkspaceInput, type ICustomerAddressDTO, type ICustomerAddressListResult, type ICustomerAddressResult, type ICustomerDTO, type ICustomerDetailD2DTO, type ICustomerDetailDTO, type ICustomerEmailDTO, type ICustomerEmailListResult, type ICustomerEmailResult, type ICustomerLabelDTO, type ICustomerLabelListResult, type ICustomerListResult, type ICustomerNoteDTO, type ICustomerNoteListResult, type ICustomerNoteResult, type ICustomerPhoneDTO, type ICustomerPhoneListResult, type ICustomerPhoneResult, type ICustomerRelationshipDTO, type ICustomerRelationshipExpandedD2DTO, type ICustomerRelationshipExpandedDTO, type ICustomerRelationshipListResult, type ICustomerRelationshipResult, type ICustomerResult, type ICustomerShallowDTO, type ICustomerTagListResult, type IFonderieClientOptions, type IGetCustomerInput, type IGetLoginHistoryInput, type IInferredConfigValue, type IInvitationDTO, type IInvitationListResult, type IInviteEntry, type IInviteResult, type IInvoiceDTO, type IInvoicesResult, type IListAuditEventsInput, type IListCustomersInput, type ILoginEventDTO, type ILoginHistoryPageResult, type ILoginInput, type ILoginResult, type IMeResult, type IMediaAssetDTO, type IMediaAssetResult, type IMemberDTO, type IMemberListResult, type IMemoryCacheOptions, type IMfaEnabledResult, type IMfaRequiredResult, type IMfaSetupResult, type IPaymentMethodDTO, type IPaymentMethodResult, type IPlanDTO, type IPlanFeature, type IPlanListResult, type IPlanResult, type IPortalUrlResult, type IPreviewTemplateInput, type IReadOptions, type IRecordUsageInput, type IRefreshResult, type IRegisterInput, type IRegisterResult, type IRemoteConfigState, type IRenderedTemplateResult, type IRequestConfig, type IRequestLocationDTO, type IResendVerificationResult, type IResetPasswordInput, type IRevealSecretResult, type IRoleDTO, type IRoleListResult, type IRolePermission, type IRolePermissionInput, type IRolePermissionsResult, type IRoleResult, type IRollbackInput, type IRollbackTemplateInput, type ISecretEntry, type ISecretRevision, type ISessionDTO, type ISessionsResult, type ISetConfigInput, type ISetSecretInput, type ISetTemplateInput, type ISubscriptionChangeResult, type ISubscriptionDTO, type ISubscriptionResult, type ITemplateEntry, type ITemplateRevision, type ITestWebhookResult, type ITokens, type IUpdateCustomerInput, type IUpdatePlanInput, type IUpdatePreferencesInput, type IUpdateProfileInput, type IUpdateRoleInput, type IUpdateSettingsInput, type IUpdateWebhookEndpointInput, type IUpdateWorkspaceInput, type IUploadMediaInput, type IUsageResult, type IUserDTO, type IUserPreferences, type IVerifyEmailResult, type IWalletCheckoutInput, type IWalletDTO, type IWalletPreferencesInput, type IWalletPurchaseInput, type IWalletPurchaseResult, type IWalletResult, type IWalletTransactionDTO, type IWalletTransactionsResult, type IWebhookDeliveryDTO, type IWebhookDeliveryListResult, type IWebhookEndpointCreatedDTO, type IWebhookEndpointDTO, type IWebhookEndpointListResult, type IWorkspaceAddressDTO, type IWorkspaceDTO, type IWorkspaceListResult, type IWorkspaceResult, type IWorkspaceSettingsDTO, type IWorkspaceSettingsResult, MediaClient, type MigrationImpact, type SubscriberType, WebhooksClient, WorkspacesClient, castConfigValue, configKeyProblem, configValueLabel, configValueType, createMemoryCache, describeLocation, formatConfigValue, inferConfigValue, isMfaRequired };
package/dist/index.d.ts CHANGED
@@ -1203,6 +1203,30 @@ declare class MediaClient {
1203
1203
  assetIdFromUrl(url: string | null | undefined): string | null;
1204
1204
  }
1205
1205
 
1206
+ interface IRemoteConfigState {
1207
+ /** key → value, as last loaded. Empty until the first load succeeds. */
1208
+ values: Readonly<Record<string, unknown>>;
1209
+ /** When values were last loaded successfully; null before that. */
1210
+ loadedAt: Date | null;
1211
+ isLoading: boolean;
1212
+ /** The last load's failure, cleared by the next success. Values are kept. */
1213
+ error: unknown;
1214
+ }
1215
+ type Listener = (state: IRemoteConfigState) => void;
1216
+ declare class ConfigClient {
1217
+ private http;
1218
+ private tokens;
1219
+ private state;
1220
+ private listeners;
1221
+ private inFlight;
1222
+ constructor(http: HttpClient, tokens: TokenStore);
1223
+ load(): Promise<IRemoteConfigState>;
1224
+ get<T>(key: string, fallback: T): T;
1225
+ snapshot(): IRemoteConfigState;
1226
+ subscribe(listener: Listener): () => void;
1227
+ private set;
1228
+ }
1229
+
1206
1230
  interface ICreateWebhookEndpointInput {
1207
1231
  url: string;
1208
1232
  events?: string[];
@@ -1345,6 +1369,8 @@ declare class FonderieClient {
1345
1369
  readonly webhooks: WebhooksClient;
1346
1370
  readonly customers: CustomersClient;
1347
1371
  readonly media: MediaClient;
1372
+ /** Public remote config: flags and settings the server exposes to frontends. */
1373
+ readonly config: ConfigClient;
1348
1374
  private http;
1349
1375
  private tokens;
1350
1376
  private workspaceId;
@@ -1378,6 +1404,9 @@ interface ISetConfigInput {
1378
1404
  description?: string;
1379
1405
  active?: boolean;
1380
1406
  ifVersion?: number;
1407
+ /** Required to change an existing key's value kind (on/off → text, list → object);
1408
+ * without it the server answers 409 CONFIG_TYPE_CHANGE. */
1409
+ allowTypeChange?: boolean;
1381
1410
  }
1382
1411
  interface ISetSecretInput {
1383
1412
  value: string;
@@ -1617,5 +1646,25 @@ declare function castConfigValue(type: ConfigValueType, raw: string): CastResult
1617
1646
  */
1618
1647
  declare const CONFIG_KEY_PATTERN: RegExp;
1619
1648
  declare function configKeyProblem(key: string): string | null;
1649
+ interface IInferredConfigValue {
1650
+ type: ConfigValueType;
1651
+ value: unknown;
1652
+ /** Human label for the detected shape: Text, Number, On/off, Object, List. */
1653
+ label: string;
1654
+ /**
1655
+ * True when the input could equally be meant as text — "true", "42". The
1656
+ * editor offers "save as text instead" for exactly these, and never needs
1657
+ * to ask about anything else.
1658
+ */
1659
+ ambiguous: boolean;
1660
+ }
1661
+ /** Human label for a stored value's shape. */
1662
+ declare function configValueLabel(value: unknown): string;
1663
+ /**
1664
+ * Work out what an operator typed, without asking. Objects and lists (JSON
1665
+ * starting with { or [), on/off (true/false), plain numbers, and text for
1666
+ * everything else — including anything that merely resembles a number.
1667
+ */
1668
+ declare function inferConfigValue(raw: string): IInferredConfigValue;
1620
1669
 
1621
- export { AdminClient, type AdminRouteGuard, type AdminScope, AuditAdminClient, AuditClient, AuthAdminClient, AuthClient, BillingAdminClient, BillingClient, CONFIG_KEY_PATTERN, CONFIG_VALUE_TYPES, type CastResult, ConfigAdminClient, type ConfigValueType, CourierAdminClient, type CustomerLabelType, type CustomerSex, type CustomerType, CustomersClient, FonderieApiError, FonderieClient, type IAcceptInvitationResult, type IAddAddressInput, type IAddEmailInput, type IAddPhoneInput, type IAddRelationshipInput, type IAddressDTO, type IAdminAttention, type IAdminAttentionItem, type IAdminAuditQuery, type IAdminCatalog, type IAdminCheckResult, type IAdminClientOptions, type IAdminDoctorReport, type IAdminEnvironmentReport, type IAdminGrantInput, type IAdminIssueTokenInput, type IAdminIssuedToken, type IAdminLedgerQuery, type IAdminLogEntry, type IAdminLogPage, type IAdminLogQuery, type IAdminLoginHistoryQuery, type IAdminManifest, type IAdminMigrationModule, type IAdminMigrationsReport, type IAdminModuleEntry, type IAdminPendingMigration, type IAdminPlanInput, type IAdminReadiness, type IAdminReadinessProblem, type IAdminRouteEntry, type IAdminRoutesReport, type IAdminSubscriptionDTO, type IAdminSubscriptionPage, type IAdminSubscriptionsQuery, type IAdminTokenRecord, type IAdminTokensReport, type IAdminUserDTO, type IAdminUserPageResult, type IAdminUsersQuery, type IAdminWalletDTO, type IAdminWalletLedgerPage, type IApiError, type IApiResponse, type IAppleNativeInput, type IAuditAdminClientOptions, type IAuditEventDTO, type IAuditPageResult, type IAuthAdminClientOptions, type IBillingAdminClientOptions, type IBlacklistCustomerInput, type ICache, type ICancelSubscriptionInput, type IChangePasswordInput, type ICheckoutInput, type ICheckoutUrlResult, type IClientAuthConfig, type IConfigAdminClientOptions, type IConfigEntry, type IConfigRevision, type ICourierAdminClientOptions, type ICreateCustomerInput, type ICreatePlanInput, type ICreateRoleInput, type ICreateWebhookEndpointInput, type ICreateWorkspaceInput, type ICustomerAddressDTO, type ICustomerAddressListResult, type ICustomerAddressResult, type ICustomerDTO, type ICustomerDetailD2DTO, type ICustomerDetailDTO, type ICustomerEmailDTO, type ICustomerEmailListResult, type ICustomerEmailResult, type ICustomerLabelDTO, type ICustomerLabelListResult, type ICustomerListResult, type ICustomerNoteDTO, type ICustomerNoteListResult, type ICustomerNoteResult, type ICustomerPhoneDTO, type ICustomerPhoneListResult, type ICustomerPhoneResult, type ICustomerRelationshipDTO, type ICustomerRelationshipExpandedD2DTO, type ICustomerRelationshipExpandedDTO, type ICustomerRelationshipListResult, type ICustomerRelationshipResult, type ICustomerResult, type ICustomerShallowDTO, type ICustomerTagListResult, type IFonderieClientOptions, type IGetCustomerInput, type IGetLoginHistoryInput, type IInvitationDTO, type IInvitationListResult, type IInviteEntry, type IInviteResult, type IInvoiceDTO, type IInvoicesResult, type IListAuditEventsInput, type IListCustomersInput, type ILoginEventDTO, type ILoginHistoryPageResult, type ILoginInput, type ILoginResult, type IMeResult, type IMediaAssetDTO, type IMediaAssetResult, type IMemberDTO, type IMemberListResult, type IMemoryCacheOptions, type IMfaEnabledResult, type IMfaRequiredResult, type IMfaSetupResult, type IPaymentMethodDTO, type IPaymentMethodResult, type IPlanDTO, type IPlanFeature, type IPlanListResult, type IPlanResult, type IPortalUrlResult, type IPreviewTemplateInput, type IReadOptions, type IRecordUsageInput, type IRefreshResult, type IRegisterInput, type IRegisterResult, type IRenderedTemplateResult, type IRequestConfig, type IRequestLocationDTO, type IResendVerificationResult, type IResetPasswordInput, type IRevealSecretResult, type IRoleDTO, type IRoleListResult, type IRolePermission, type IRolePermissionInput, type IRolePermissionsResult, type IRoleResult, type IRollbackInput, type IRollbackTemplateInput, type ISecretEntry, type ISecretRevision, type ISessionDTO, type ISessionsResult, type ISetConfigInput, type ISetSecretInput, type ISetTemplateInput, type ISubscriptionChangeResult, type ISubscriptionDTO, type ISubscriptionResult, type ITemplateEntry, type ITemplateRevision, type ITestWebhookResult, type ITokens, type IUpdateCustomerInput, type IUpdatePlanInput, type IUpdatePreferencesInput, type IUpdateProfileInput, type IUpdateRoleInput, type IUpdateSettingsInput, type IUpdateWebhookEndpointInput, type IUpdateWorkspaceInput, type IUploadMediaInput, type IUsageResult, type IUserDTO, type IUserPreferences, type IVerifyEmailResult, type IWalletCheckoutInput, type IWalletDTO, type IWalletPreferencesInput, type IWalletPurchaseInput, type IWalletPurchaseResult, type IWalletResult, type IWalletTransactionDTO, type IWalletTransactionsResult, type IWebhookDeliveryDTO, type IWebhookDeliveryListResult, type IWebhookEndpointCreatedDTO, type IWebhookEndpointDTO, type IWebhookEndpointListResult, type IWorkspaceAddressDTO, type IWorkspaceDTO, type IWorkspaceListResult, type IWorkspaceResult, type IWorkspaceSettingsDTO, type IWorkspaceSettingsResult, MediaClient, type MigrationImpact, type SubscriberType, WebhooksClient, WorkspacesClient, castConfigValue, configKeyProblem, configValueType, createMemoryCache, describeLocation, formatConfigValue, isMfaRequired };
1670
+ export { AdminClient, type AdminRouteGuard, type AdminScope, AuditAdminClient, AuditClient, AuthAdminClient, AuthClient, BillingAdminClient, BillingClient, CONFIG_KEY_PATTERN, CONFIG_VALUE_TYPES, type CastResult, ConfigAdminClient, ConfigClient, type ConfigValueType, CourierAdminClient, type CustomerLabelType, type CustomerSex, type CustomerType, CustomersClient, FonderieApiError, FonderieClient, type IAcceptInvitationResult, type IAddAddressInput, type IAddEmailInput, type IAddPhoneInput, type IAddRelationshipInput, type IAddressDTO, type IAdminAttention, type IAdminAttentionItem, type IAdminAuditQuery, type IAdminCatalog, type IAdminCheckResult, type IAdminClientOptions, type IAdminDoctorReport, type IAdminEnvironmentReport, type IAdminGrantInput, type IAdminIssueTokenInput, type IAdminIssuedToken, type IAdminLedgerQuery, type IAdminLogEntry, type IAdminLogPage, type IAdminLogQuery, type IAdminLoginHistoryQuery, type IAdminManifest, type IAdminMigrationModule, type IAdminMigrationsReport, type IAdminModuleEntry, type IAdminPendingMigration, type IAdminPlanInput, type IAdminReadiness, type IAdminReadinessProblem, type IAdminRouteEntry, type IAdminRoutesReport, type IAdminSubscriptionDTO, type IAdminSubscriptionPage, type IAdminSubscriptionsQuery, type IAdminTokenRecord, type IAdminTokensReport, type IAdminUserDTO, type IAdminUserPageResult, type IAdminUsersQuery, type IAdminWalletDTO, type IAdminWalletLedgerPage, type IApiError, type IApiResponse, type IAppleNativeInput, type IAuditAdminClientOptions, type IAuditEventDTO, type IAuditPageResult, type IAuthAdminClientOptions, type IBillingAdminClientOptions, type IBlacklistCustomerInput, type ICache, type ICancelSubscriptionInput, type IChangePasswordInput, type ICheckoutInput, type ICheckoutUrlResult, type IClientAuthConfig, type IConfigAdminClientOptions, type IConfigEntry, type IConfigRevision, type ICourierAdminClientOptions, type ICreateCustomerInput, type ICreatePlanInput, type ICreateRoleInput, type ICreateWebhookEndpointInput, type ICreateWorkspaceInput, type ICustomerAddressDTO, type ICustomerAddressListResult, type ICustomerAddressResult, type ICustomerDTO, type ICustomerDetailD2DTO, type ICustomerDetailDTO, type ICustomerEmailDTO, type ICustomerEmailListResult, type ICustomerEmailResult, type ICustomerLabelDTO, type ICustomerLabelListResult, type ICustomerListResult, type ICustomerNoteDTO, type ICustomerNoteListResult, type ICustomerNoteResult, type ICustomerPhoneDTO, type ICustomerPhoneListResult, type ICustomerPhoneResult, type ICustomerRelationshipDTO, type ICustomerRelationshipExpandedD2DTO, type ICustomerRelationshipExpandedDTO, type ICustomerRelationshipListResult, type ICustomerRelationshipResult, type ICustomerResult, type ICustomerShallowDTO, type ICustomerTagListResult, type IFonderieClientOptions, type IGetCustomerInput, type IGetLoginHistoryInput, type IInferredConfigValue, type IInvitationDTO, type IInvitationListResult, type IInviteEntry, type IInviteResult, type IInvoiceDTO, type IInvoicesResult, type IListAuditEventsInput, type IListCustomersInput, type ILoginEventDTO, type ILoginHistoryPageResult, type ILoginInput, type ILoginResult, type IMeResult, type IMediaAssetDTO, type IMediaAssetResult, type IMemberDTO, type IMemberListResult, type IMemoryCacheOptions, type IMfaEnabledResult, type IMfaRequiredResult, type IMfaSetupResult, type IPaymentMethodDTO, type IPaymentMethodResult, type IPlanDTO, type IPlanFeature, type IPlanListResult, type IPlanResult, type IPortalUrlResult, type IPreviewTemplateInput, type IReadOptions, type IRecordUsageInput, type IRefreshResult, type IRegisterInput, type IRegisterResult, type IRemoteConfigState, type IRenderedTemplateResult, type IRequestConfig, type IRequestLocationDTO, type IResendVerificationResult, type IResetPasswordInput, type IRevealSecretResult, type IRoleDTO, type IRoleListResult, type IRolePermission, type IRolePermissionInput, type IRolePermissionsResult, type IRoleResult, type IRollbackInput, type IRollbackTemplateInput, type ISecretEntry, type ISecretRevision, type ISessionDTO, type ISessionsResult, type ISetConfigInput, type ISetSecretInput, type ISetTemplateInput, type ISubscriptionChangeResult, type ISubscriptionDTO, type ISubscriptionResult, type ITemplateEntry, type ITemplateRevision, type ITestWebhookResult, type ITokens, type IUpdateCustomerInput, type IUpdatePlanInput, type IUpdatePreferencesInput, type IUpdateProfileInput, type IUpdateRoleInput, type IUpdateSettingsInput, type IUpdateWebhookEndpointInput, type IUpdateWorkspaceInput, type IUploadMediaInput, type IUsageResult, type IUserDTO, type IUserPreferences, type IVerifyEmailResult, type IWalletCheckoutInput, type IWalletDTO, type IWalletPreferencesInput, type IWalletPurchaseInput, type IWalletPurchaseResult, type IWalletResult, type IWalletTransactionDTO, type IWalletTransactionsResult, type IWebhookDeliveryDTO, type IWebhookDeliveryListResult, type IWebhookEndpointCreatedDTO, type IWebhookEndpointDTO, type IWebhookEndpointListResult, type IWorkspaceAddressDTO, type IWorkspaceDTO, type IWorkspaceListResult, type IWorkspaceResult, type IWorkspaceSettingsDTO, type IWorkspaceSettingsResult, MediaClient, type MigrationImpact, type SubscriberType, WebhooksClient, WorkspacesClient, castConfigValue, configKeyProblem, configValueLabel, configValueType, createMemoryCache, describeLocation, formatConfigValue, inferConfigValue, isMfaRequired };
package/dist/index.js CHANGED
@@ -1096,6 +1096,62 @@ var MediaClient = class {
1096
1096
  }
1097
1097
  };
1098
1098
 
1099
+ // src/modules/config.ts
1100
+ var ConfigClient = class {
1101
+ constructor(http, tokens) {
1102
+ this.http = http;
1103
+ this.tokens = tokens;
1104
+ }
1105
+ http;
1106
+ tokens;
1107
+ state = { values: {}, loadedAt: null, isLoading: false, error: null };
1108
+ listeners = /* @__PURE__ */ new Set();
1109
+ inFlight = null;
1110
+ // GET /config/public — fetch the public values into the shared snapshot.
1111
+ // Concurrent calls share one request. A failure keeps the previous values
1112
+ // (a flag that was on does not flicker off because one refresh failed) and
1113
+ // is reported in `error`; before any success, reads fall back to defaults.
1114
+ load() {
1115
+ if (this.inFlight) return this.inFlight;
1116
+ this.set({ isLoading: true });
1117
+ this.inFlight = this.http.request({
1118
+ method: "GET",
1119
+ path: "/config/public",
1120
+ // Sent when signed in, so per-user values can be served later
1121
+ // without a client change; the route itself is public.
1122
+ token: this.tokens.get()
1123
+ }).then(
1124
+ (res) => this.set({ values: res.result?.values ?? {}, loadedAt: /* @__PURE__ */ new Date(), isLoading: false, error: null }),
1125
+ (error) => this.set({ isLoading: false, error })
1126
+ ).finally(() => {
1127
+ this.inFlight = null;
1128
+ });
1129
+ return this.inFlight;
1130
+ }
1131
+ // One value, with the fallback used when the key is absent — before the
1132
+ // first load, when it failed, or when the server does not expose the key.
1133
+ // Pick the SAFE fallback (feature off), not the optimistic one.
1134
+ get(key, fallback) {
1135
+ return Object.hasOwn(this.state.values, key) ? this.state.values[key] : fallback;
1136
+ }
1137
+ // The whole current state (values, loadedAt, isLoading, error).
1138
+ snapshot() {
1139
+ return this.state;
1140
+ }
1141
+ // Called with the new state after every change; returns an unsubscribe.
1142
+ subscribe(listener) {
1143
+ this.listeners.add(listener);
1144
+ return () => {
1145
+ this.listeners.delete(listener);
1146
+ };
1147
+ }
1148
+ set(patch) {
1149
+ this.state = { ...this.state, ...patch };
1150
+ for (const listener of this.listeners) listener(this.state);
1151
+ return this.state;
1152
+ }
1153
+ };
1154
+
1099
1155
  // src/modules/webhooks.ts
1100
1156
  var WebhooksClient = class {
1101
1157
  constructor(http, tokens) {
@@ -1432,6 +1488,8 @@ var FonderieClient = class {
1432
1488
  webhooks;
1433
1489
  customers;
1434
1490
  media;
1491
+ /** Public remote config: flags and settings the server exposes to frontends. */
1492
+ config;
1435
1493
  http;
1436
1494
  tokens;
1437
1495
  workspaceId;
@@ -1455,6 +1513,7 @@ var FonderieClient = class {
1455
1513
  this.webhooks = new WebhooksClient(this.http, this.tokens);
1456
1514
  this.customers = new CustomersClient(this.http, this.tokens);
1457
1515
  this.media = new MediaClient(this.http, this.tokens);
1516
+ this.config = new ConfigClient(this.http, this.tokens);
1458
1517
  if (opts.workspaceId !== void 0) this.setWorkspaceId(opts.workspaceId);
1459
1518
  }
1460
1519
  // Single-flight refresh: POST /auth/refresh with the app-supplied refresh
@@ -2121,6 +2180,35 @@ function configKeyProblem(key) {
2121
2180
  if (!key) return "Enter a key.";
2122
2181
  return CONFIG_KEY_PATTERN.test(key) ? null : 'Start with a letter; use letters, digits, ".", "_" or "-" (max 128).';
2123
2182
  }
2183
+ var PLAIN_NUMBER = /^-?(0|[1-9]\d*)(\.\d+)?$/;
2184
+ function configValueLabel(value) {
2185
+ if (typeof value === "string") return "Text";
2186
+ if (typeof value === "number") return "Number";
2187
+ if (typeof value === "boolean") return "On/off";
2188
+ if (Array.isArray(value)) return "List";
2189
+ if (value === null) return "Empty";
2190
+ return "Object";
2191
+ }
2192
+ function inferConfigValue(raw) {
2193
+ const t = raw.trim();
2194
+ if (t === "true" || t === "false") {
2195
+ return { type: "boolean", value: t === "true", label: "On/off", ambiguous: true };
2196
+ }
2197
+ if (PLAIN_NUMBER.test(t)) {
2198
+ const n = Number(t);
2199
+ if (Number.isFinite(n) && String(n) === t) return { type: "number", value: n, label: "Number", ambiguous: true };
2200
+ }
2201
+ if (t.startsWith("{") || t.startsWith("[")) {
2202
+ try {
2203
+ const parsed = JSON.parse(t);
2204
+ if (parsed !== null && typeof parsed === "object") {
2205
+ return { type: "json", value: parsed, label: Array.isArray(parsed) ? "List" : "Object", ambiguous: false };
2206
+ }
2207
+ } catch {
2208
+ }
2209
+ }
2210
+ return { type: "string", value: raw, label: "Text", ambiguous: false };
2211
+ }
2124
2212
  export {
2125
2213
  AdminClient,
2126
2214
  AuditAdminClient,
@@ -2132,6 +2220,7 @@ export {
2132
2220
  CONFIG_KEY_PATTERN,
2133
2221
  CONFIG_VALUE_TYPES,
2134
2222
  ConfigAdminClient,
2223
+ ConfigClient,
2135
2224
  CourierAdminClient,
2136
2225
  CustomersClient,
2137
2226
  FonderieApiError,
@@ -2141,10 +2230,12 @@ export {
2141
2230
  WorkspacesClient,
2142
2231
  castConfigValue,
2143
2232
  configKeyProblem,
2233
+ configValueLabel,
2144
2234
  configValueType,
2145
2235
  createMemoryCache,
2146
2236
  describeLocation,
2147
2237
  formatConfigValue,
2238
+ inferConfigValue,
2148
2239
  isMfaRequired
2149
2240
  };
2150
2241
  //# sourceMappingURL=index.js.map