@fonderie/client 1.2.0 → 1.4.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;
@@ -1590,4 +1616,32 @@ declare class CourierAdminClient {
1590
1616
  previewTemplate(type: string, input: IPreviewTemplateInput, locale?: string | null): Promise<IApiResponse<IRenderedTemplateResult>>;
1591
1617
  }
1592
1618
 
1593
- export { AdminClient, type AdminRouteGuard, type AdminScope, AuditAdminClient, AuditClient, AuthAdminClient, AuthClient, BillingAdminClient, BillingClient, ConfigAdminClient, 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, createMemoryCache, describeLocation, isMfaRequired };
1619
+ type ConfigValueType = 'string' | 'number' | 'boolean' | 'json';
1620
+ declare const CONFIG_VALUE_TYPES: readonly ConfigValueType[];
1621
+ /** The editor type for a stored value. Objects, arrays and null are JSON. */
1622
+ declare function configValueType(value: unknown): ConfigValueType;
1623
+ /** What an input should show for a stored value of that type. */
1624
+ declare function formatConfigValue(value: unknown, type?: ConfigValueType): string;
1625
+ type CastResult = {
1626
+ ok: true;
1627
+ value: unknown;
1628
+ } | {
1629
+ ok: false;
1630
+ error: string;
1631
+ };
1632
+ /**
1633
+ * Turn what an operator typed into the typed value to store.
1634
+ * - string: kept verbatim (an empty string is a valid value)
1635
+ * - number: finite numbers only — "1e3" and "-2.5" are fine, "12px" is not
1636
+ * - boolean: true/false, also 1/0, yes/no, on/off (case-insensitive)
1637
+ * - json: any valid JSON
1638
+ */
1639
+ declare function castConfigValue(type: ConfigValueType, raw: string): CastResult;
1640
+ /**
1641
+ * Config keys: letters, digits, `.`, `_`, `-`; must start with a letter; up to
1642
+ * 128 characters. Both styles work — `ENABLE_JOB_LISTING` and `feature.dark-mode`.
1643
+ */
1644
+ declare const CONFIG_KEY_PATTERN: RegExp;
1645
+ declare function configKeyProblem(key: string): string | null;
1646
+
1647
+ 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 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, configValueType, createMemoryCache, describeLocation, formatConfigValue, 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;
@@ -1590,4 +1616,32 @@ declare class CourierAdminClient {
1590
1616
  previewTemplate(type: string, input: IPreviewTemplateInput, locale?: string | null): Promise<IApiResponse<IRenderedTemplateResult>>;
1591
1617
  }
1592
1618
 
1593
- export { AdminClient, type AdminRouteGuard, type AdminScope, AuditAdminClient, AuditClient, AuthAdminClient, AuthClient, BillingAdminClient, BillingClient, ConfigAdminClient, 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, createMemoryCache, describeLocation, isMfaRequired };
1619
+ type ConfigValueType = 'string' | 'number' | 'boolean' | 'json';
1620
+ declare const CONFIG_VALUE_TYPES: readonly ConfigValueType[];
1621
+ /** The editor type for a stored value. Objects, arrays and null are JSON. */
1622
+ declare function configValueType(value: unknown): ConfigValueType;
1623
+ /** What an input should show for a stored value of that type. */
1624
+ declare function formatConfigValue(value: unknown, type?: ConfigValueType): string;
1625
+ type CastResult = {
1626
+ ok: true;
1627
+ value: unknown;
1628
+ } | {
1629
+ ok: false;
1630
+ error: string;
1631
+ };
1632
+ /**
1633
+ * Turn what an operator typed into the typed value to store.
1634
+ * - string: kept verbatim (an empty string is a valid value)
1635
+ * - number: finite numbers only — "1e3" and "-2.5" are fine, "12px" is not
1636
+ * - boolean: true/false, also 1/0, yes/no, on/off (case-insensitive)
1637
+ * - json: any valid JSON
1638
+ */
1639
+ declare function castConfigValue(type: ConfigValueType, raw: string): CastResult;
1640
+ /**
1641
+ * Config keys: letters, digits, `.`, `_`, `-`; must start with a letter; up to
1642
+ * 128 characters. Both styles work — `ENABLE_JOB_LISTING` and `feature.dark-mode`.
1643
+ */
1644
+ declare const CONFIG_KEY_PATTERN: RegExp;
1645
+ declare function configKeyProblem(key: string): string | null;
1646
+
1647
+ 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 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, configValueType, createMemoryCache, describeLocation, formatConfigValue, 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
@@ -2081,6 +2140,46 @@ function describeLocation(loc, countryName) {
2081
2140
  );
2082
2141
  return parts.length > 0 ? parts.join(", ") : null;
2083
2142
  }
2143
+
2144
+ // src/config-value.ts
2145
+ var CONFIG_VALUE_TYPES = ["string", "number", "boolean", "json"];
2146
+ function configValueType(value) {
2147
+ if (typeof value === "string") return "string";
2148
+ if (typeof value === "number") return "number";
2149
+ if (typeof value === "boolean") return "boolean";
2150
+ return "json";
2151
+ }
2152
+ function formatConfigValue(value, type = configValueType(value)) {
2153
+ if (type === "string") return typeof value === "string" ? value : String(value ?? "");
2154
+ if (type === "number") return typeof value === "number" ? String(value) : "";
2155
+ if (type === "boolean") return value === true ? "true" : "false";
2156
+ return JSON.stringify(value ?? null, null, 2);
2157
+ }
2158
+ function castConfigValue(type, raw) {
2159
+ if (type === "string") return { ok: true, value: raw };
2160
+ const t = raw.trim();
2161
+ if (type === "number") {
2162
+ if (t === "") return { ok: false, error: "Enter a number." };
2163
+ const n = Number(t);
2164
+ return Number.isFinite(n) ? { ok: true, value: n } : { ok: false, error: `"${raw}" is not a number.` };
2165
+ }
2166
+ if (type === "boolean") {
2167
+ const v = t.toLowerCase();
2168
+ if (["true", "1", "yes", "on"].includes(v)) return { ok: true, value: true };
2169
+ if (["false", "0", "no", "off"].includes(v)) return { ok: true, value: false };
2170
+ return { ok: false, error: "Use true or false." };
2171
+ }
2172
+ try {
2173
+ return { ok: true, value: JSON.parse(t) };
2174
+ } catch (err) {
2175
+ return { ok: false, error: `Not valid JSON: ${err.message}` };
2176
+ }
2177
+ }
2178
+ var CONFIG_KEY_PATTERN = /^[A-Za-z][A-Za-z0-9._-]{0,127}$/;
2179
+ function configKeyProblem(key) {
2180
+ if (!key) return "Enter a key.";
2181
+ return CONFIG_KEY_PATTERN.test(key) ? null : 'Start with a letter; use letters, digits, ".", "_" or "-" (max 128).';
2182
+ }
2084
2183
  export {
2085
2184
  AdminClient,
2086
2185
  AuditAdminClient,
@@ -2089,7 +2188,10 @@ export {
2089
2188
  AuthClient,
2090
2189
  BillingAdminClient,
2091
2190
  BillingClient,
2191
+ CONFIG_KEY_PATTERN,
2192
+ CONFIG_VALUE_TYPES,
2092
2193
  ConfigAdminClient,
2194
+ ConfigClient,
2093
2195
  CourierAdminClient,
2094
2196
  CustomersClient,
2095
2197
  FonderieApiError,
@@ -2097,8 +2199,12 @@ export {
2097
2199
  MediaClient,
2098
2200
  WebhooksClient,
2099
2201
  WorkspacesClient,
2202
+ castConfigValue,
2203
+ configKeyProblem,
2204
+ configValueType,
2100
2205
  createMemoryCache,
2101
2206
  describeLocation,
2207
+ formatConfigValue,
2102
2208
  isMfaRequired
2103
2209
  };
2104
2210
  //# sourceMappingURL=index.js.map