nucleus-core-ts 0.9.968 → 0.9.970

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.
@@ -11,5 +11,5 @@ export { createServerFactory, type ServerFactory } from './server';
11
11
  * in the app and not the one that holds the accounts.
12
12
  */
13
13
  export { SYSTEM_TABLES } from './system-tables';
14
- export type { AdminCreateUserPayload, AdminCreateUserResponse, AlertEvent, AlertType, AllGeneratedEndpoints, AllGeneratedEndpointsWithConfig, AllGeneratedEndpointsWithEntityTypes, ApiCallerConfig, ApiResponse, ApplicationMetrics, AuditCategory, AuditSeverity, AuthEndpointDefinitions, AuthenticationConfig, AuthFeatureConfig, AuthFeatureKey, BaseErrorResponse, BulkCreateUsersPayload, BulkCreateUsersResponse, BulkEndpointKey, ChangeUserIdPayload, ChangeUserIdResponse, ChatActionResponse, ChatAttachmentDTO, ChatConversationDTO, ChatConversationListResponse, ChatConversationResponse, ChatCreateConversationPayload, ChatEndpointDefinitions, ChatMessageDTO, ChatMessageListResponse, ChatMessageResponse, ChatParticipantDTO, ChatParticipantsResponse, ChatReadResponse, ChatSendMessagePayload, CheckSubdomainPayload, CheckSubdomainResponse, ClientHookConfig, CohortBulkOpsResponse, CohortEndpointDefinitions, CohortPayload, CohortUpdatePayload, ConfigEndpointDefinitions, ConfigEnvResponse, ConfigGetResponse, ConfigOverridesClearResponse, ConfigOverridesGetResponse, ConfigRestartPayload, ConfigRestartResponse, ConfigSectionGetResponse, ConfigSectionMeta, ConfigSectionsListResponse, ConfigSectionUpdatePayload, ConfigSectionUpdateResponse, CookieStore, CreateHostnamePayload, CreateHostnameResponse, CreateRegistrationPayload, DatabaseMetrics, DeleteResponse, DnsInstructionDTO, DomainEndpointDefinitions, DomainHostnameDTO, DomainHostnameListResponse, DomainHostnameResponse, DomainInstructionsResponse, DomainRegistrationDTO, DomainRegistrationListResponse, DomainRegistrationResponse, DomainResolutionDTO, DomainResolveResponse, EndpointAction, EndpointActions, EndpointDefinition, EndpointMethod, EndpointState, EntityEndpointKey, EntityRecord, ExtraEndpoints, FlowDeleteResponse, FlowDetailResponse, FlowListResponse, FlowPublishResponse, FlowSavePayload, FlowSaveResponse, GeneratedAuthEndpoints, GeneratedEndpointsFromConfig, HeadersStore, HttpMethod, ImpersonatePayload, ImpersonateResponse, ImpersonateStopResponse, InferEntity, ListResponse, LiveCpuLog, LiveDaprEvent, LiveDaprEventType, LiveMemoryLog, LiveMonitoringChangeSettingsPayload, LiveMonitoringConfigs, LiveMonitoringLogLimits, LiveMonitoringLogsResponse, LiveMonitoringSettingsResponse, LiveMonitoringStreamSnapshot, LiveMonitoringStreamUpdate, LiveRequest, LiveWorkerInfo, LiveWsEvent, LiveWsEventType, LoginPayload, LoginSuccess, LoginSuccessData, LogLevel, MagicLinkPayload, MarketplaceBalanceDTO, MarketplaceBalanceResponse, MarketplaceEndpointDefinitions, MeResponse, MeResponseData, MeSuccessResponse, MetricPeak, MonitoringAcknowledgeResponse, MonitoringAlertsResponse, MonitoringEndpointDefinitions, MonitoringHistoryResponse, MonitoringSnapshot, MonitoringSnapshotResponse, MutationResponse, NotificationListResponse, NotificationSeenAllResponse, NotificationSeenResponse, NotificationUnseenCountResponse, OpenDisputePayload, PaginationMeta, PasswordChangePayload, PasswordResetConfirmPayload, PasswordResetRequestPayload, PasswordResetResponse, PasswordSetPayload, PaymentDisputeDTO, PaymentDisputeListResponse, PaymentDisputeResponse, PaymentSplitDTO, PaymentSplitListResponse, PaymentSplitResponse, PayoutRequestDTO, PayoutRequestListResponse, PayoutRequestResponse, ProvisionTenantPayload, ProvisionTenantResponse, RecordSplitPayload, RedisMetrics, RefreshSuccess, RefreshSuccessData, RegisterPayload, RegisterSuccess, RegisterSuccessData, RequestPayoutPayload, ResolvedEnvEntry, SelfSignupPayload, SelfSignupResponse, ServerFactoryConfig, ServerLogPage, ServerLogQuery, ServerLogRecord, ServerLogSource, ServerLogsResponse, SessionApprovePayload, SessionApproveResponse, SessionCurrentResponse, SessionInfo, SessionRejectPayload, SessionRejectResponse, SessionRevokeAllPayload, SessionRevokeAllResponse, SessionRevokePayload, SessionRevokeResponse, SessionStatsResponse, SessionsListResponse, SessionsPendingResponse, SettlementPolicyDTO, SettlementPolicyPayload, SettlementPolicyResponse, SingleResponse, StandardQueryParams, StandardReturn, StartOptions, SystemAddressEntity, SystemAuditLogEntity, SystemClaimEntity, SystemFileEntity, SystemMetrics, SystemMonitoringMetricEntity, SystemPhoneEntity, SystemProfileEntity, SystemRoleClaimEntity, SystemRoleEntity, SystemUserCohortEntity, SystemUserEntity, SystemUserRoleEntity, TenantDetailResponse, TenantEndpointDefinitions, TenantListItem, TenantListResponse, TenantReactivatePayload, TenantReactivateResponse, TenantSuspendPayload, TenantSuspendResponse, UserData, VerificationDecidePayload, VerificationDecideResponse, VerificationEndpointDefinitions, VerificationPendingResponse, VerificationStartPayload, VerificationStartResponse, VerificationStatusResponse, WebAuthnAuthenticationOptions, WebAuthnAuthenticationResponseJSON, WebAuthnAuthenticatorAttachment, WebAuthnAuthOptionsPayload, WebAuthnAuthOptionsResponse, WebAuthnAuthVerifyPayload, WebAuthnAuthVerifyResponse, WebAuthnCredentialSummary, WebAuthnDeviceType, WebAuthnListResponse, WebAuthnPublicKeyCredentialDescriptor, WebAuthnRegisterOptionsPayload, WebAuthnRegisterOptionsResponse, WebAuthnRegisterVerifyPayload, WebAuthnRegisterVerifyResponse, WebAuthnRegistrationOptions, WebAuthnRegistrationResponseJSON, WebAuthnRenamePayload, WebAuthnRenameResponse, WebAuthnRevokePayload, WebAuthnRevokeResponse, WebAuthnTransport, } from './types';
14
+ export type { AdminCreateUserPayload, AdminCreateUserResponse, AdminLockUserPayload, AdminLockUserResponse, AdminMarkEmailVerifiedPayload, AdminMarkEmailVerifiedResponse, AdminUnlockUserPayload, AdminUnlockUserResponse, AlertEvent, AlertType, AllGeneratedEndpoints, AllGeneratedEndpointsWithConfig, AllGeneratedEndpointsWithEntityTypes, ApiCallerConfig, ApiResponse, ApplicationMetrics, AuditCategory, AuditSeverity, AuthEndpointDefinitions, AuthenticationConfig, AuthFeatureConfig, AuthFeatureKey, BaseErrorResponse, BulkCreateUsersPayload, BulkCreateUsersResponse, BulkEndpointKey, ChangeUserIdPayload, ChangeUserIdResponse, ChatActionResponse, ChatAttachmentDTO, ChatConversationDTO, ChatConversationListResponse, ChatConversationResponse, ChatCreateConversationPayload, ChatEndpointDefinitions, ChatMessageDTO, ChatMessageListResponse, ChatMessageResponse, ChatParticipantDTO, ChatParticipantsResponse, ChatReadResponse, ChatSendMessagePayload, CheckSubdomainPayload, CheckSubdomainResponse, ClientHookConfig, CohortBulkOpsResponse, CohortEndpointDefinitions, CohortPayload, CohortUpdatePayload, ConfigEndpointDefinitions, ConfigEnvResponse, ConfigGetResponse, ConfigOverridesClearResponse, ConfigOverridesGetResponse, ConfigRestartPayload, ConfigRestartResponse, ConfigSectionGetResponse, ConfigSectionMeta, ConfigSectionsListResponse, ConfigSectionUpdatePayload, ConfigSectionUpdateResponse, CookieStore, CreateHostnamePayload, CreateHostnameResponse, CreateRegistrationPayload, DatabaseMetrics, DeleteResponse, DnsInstructionDTO, DomainEndpointDefinitions, DomainHostnameDTO, DomainHostnameListResponse, DomainHostnameResponse, DomainInstructionsResponse, DomainRegistrationDTO, DomainRegistrationListResponse, DomainRegistrationResponse, DomainResolutionDTO, DomainResolveResponse, EndpointAction, EndpointActions, EndpointDefinition, EndpointMethod, EndpointState, EntityEndpointKey, EntityRecord, ExtraEndpoints, FlowDeleteResponse, FlowDetailResponse, FlowListResponse, FlowPublishResponse, FlowSavePayload, FlowSaveResponse, GeneratedAuthEndpoints, GeneratedEndpointsFromConfig, HeadersStore, HttpMethod, ImpersonatePayload, ImpersonateResponse, ImpersonateStopResponse, InferEntity, ListResponse, LiveCpuLog, LiveDaprEvent, LiveDaprEventType, LiveMemoryLog, LiveMonitoringChangeSettingsPayload, LiveMonitoringConfigs, LiveMonitoringLogLimits, LiveMonitoringLogsResponse, LiveMonitoringSettingsResponse, LiveMonitoringStreamSnapshot, LiveMonitoringStreamUpdate, LiveRequest, LiveWorkerInfo, LiveWsEvent, LiveWsEventType, LoginPayload, LoginSuccess, LoginSuccessData, LogLevel, MagicLinkPayload, MarketplaceBalanceDTO, MarketplaceBalanceResponse, MarketplaceEndpointDefinitions, MeResponse, MeResponseData, MeSuccessResponse, MetricPeak, MonitoringAcknowledgeResponse, MonitoringAlertsResponse, MonitoringEndpointDefinitions, MonitoringHistoryResponse, MonitoringSnapshot, MonitoringSnapshotResponse, MutationResponse, NotificationListResponse, NotificationSeenAllResponse, NotificationSeenResponse, NotificationUnseenCountResponse, OpenDisputePayload, PaginationMeta, PasswordChangePayload, PasswordResetConfirmPayload, PasswordResetRequestPayload, PasswordResetResponse, PasswordSetPayload, PaymentDisputeDTO, PaymentDisputeListResponse, PaymentDisputeResponse, PaymentSplitDTO, PaymentSplitListResponse, PaymentSplitResponse, PayoutRequestDTO, PayoutRequestListResponse, PayoutRequestResponse, ProvisionTenantPayload, ProvisionTenantResponse, RecordSplitPayload, RedisMetrics, RefreshSuccess, RefreshSuccessData, RegisterPayload, RegisterSuccess, RegisterSuccessData, RequestPayoutPayload, ResolvedEnvEntry, SelfSignupPayload, SelfSignupResponse, ServerFactoryConfig, ServerLogPage, ServerLogQuery, ServerLogRecord, ServerLogSource, ServerLogsResponse, SessionApprovePayload, SessionApproveResponse, SessionCurrentResponse, SessionInfo, SessionRejectPayload, SessionRejectResponse, SessionRevokeAllPayload, SessionRevokeAllResponse, SessionRevokePayload, SessionRevokeResponse, SessionStatsResponse, SessionsListResponse, SessionsPendingResponse, SettlementPolicyDTO, SettlementPolicyPayload, SettlementPolicyResponse, SingleResponse, StandardQueryParams, StandardReturn, StartOptions, SystemAddressEntity, SystemAuditLogEntity, SystemClaimEntity, SystemFileEntity, SystemMetrics, SystemMonitoringMetricEntity, SystemPhoneEntity, SystemProfileEntity, SystemRoleClaimEntity, SystemRoleEntity, SystemUserCohortEntity, SystemUserEntity, SystemUserRoleEntity, TenantDetailResponse, TenantEndpointDefinitions, TenantListItem, TenantListResponse, TenantReactivatePayload, TenantReactivateResponse, TenantSuspendPayload, TenantSuspendResponse, UserData, VerificationDecidePayload, VerificationDecideResponse, VerificationEndpointDefinitions, VerificationPendingResponse, VerificationStartPayload, VerificationStartResponse, VerificationStatusResponse, WebAuthnAuthenticationOptions, WebAuthnAuthenticationResponseJSON, WebAuthnAuthenticatorAttachment, WebAuthnAuthOptionsPayload, WebAuthnAuthOptionsResponse, WebAuthnAuthVerifyPayload, WebAuthnAuthVerifyResponse, WebAuthnCredentialSummary, WebAuthnDeviceType, WebAuthnListResponse, WebAuthnPublicKeyCredentialDescriptor, WebAuthnRegisterOptionsPayload, WebAuthnRegisterOptionsResponse, WebAuthnRegisterVerifyPayload, WebAuthnRegisterVerifyResponse, WebAuthnRegistrationOptions, WebAuthnRegistrationResponseJSON, WebAuthnRenamePayload, WebAuthnRenameResponse, WebAuthnRevokePayload, WebAuthnRevokeResponse, WebAuthnTransport, } from './types';
15
15
  export { AUTH_ENDPOINT_CONFIGS, AUTH_ENDPOINTS, CHAT_ENDPOINTS, COHORT_ENDPOINTS, CONFIG_ENDPOINTS, DOMAIN_ENDPOINTS, MARKETPLACE_ENDPOINTS, MONITORING_ENDPOINTS, PAYMENT_ENDPOINTS, TENANT_ENDPOINTS, VERIFICATION_ENDPOINTS, } from './types';
@@ -1,3 +1,12 @@
1
1
  import type { ApiResponse, CookieStore, EndpointDefinition, HeadersStore, ServerFactoryConfig } from './types';
2
+ /**
3
+ * Give a `{success, …}` response the same `{success, message, data}` shape the
4
+ * rest of the API already has — without swallowing the fields that steer the
5
+ * caller.
6
+ *
7
+ * A response that already carries `data` is left exactly as it is; so is
8
+ * anything that is not a plain object.
9
+ */
10
+ export declare function normalizeResponseShape(response: unknown): unknown;
2
11
  export declare function createServerFactory<TEndpoints extends Record<string, EndpointDefinition>>(endpoints: TEndpoints, config: ServerFactoryConfig, getCookies: () => Promise<CookieStore>, getHeaders: () => Promise<HeadersStore>): <K extends keyof TEndpoints & string>(endpointKey: K, payload: TEndpoints[K]["_payload"]) => Promise<ApiResponse<TEndpoints[K]["_success"], TEndpoints[K]["_error"]>>;
3
12
  export type ServerFactory<TEndpoints extends Record<string, EndpointDefinition>> = ReturnType<typeof createServerFactory<TEndpoints>>;
@@ -12,6 +12,16 @@ export interface ApiResponse<TSuccess, TError> {
12
12
  errors?: TError;
13
13
  code?: number | null;
14
14
  message?: string;
15
+ /**
16
+ * The server's id for this request, present on failures.
17
+ *
18
+ * The API deliberately does not return the reason a 5xx happened — it can
19
+ * carry SQL, schema, paths, secrets — and logs it instead. This is the thread
20
+ * between the two: quote it and the reason is one grep away. Without it
21
+ * "Internal Server Error" on screen and the explanation in the log had
22
+ * nothing joining them.
23
+ */
24
+ requestId?: string;
15
25
  }
16
26
  export type EndpointMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
17
27
  export interface EndpointDefinition<TPayload = unknown, TSuccess = unknown, TError = unknown> {
@@ -0,0 +1,16 @@
1
+ /**
2
+ * The cookies an impersonation session leaves in the browser.
3
+ *
4
+ * Three of them are labels the UI reads to show "you are viewing as …". The
5
+ * fourth, `nucleus_imp_sig`, is not a label: it is `signRefreshToken(godminId)`,
6
+ * a real refresh token with a real lifetime, and `/auth/admin/impersonate/stop`
7
+ * mints a full administrator session for whoever presents it.
8
+ *
9
+ * Logging out cleared the three auth cookies and left all four of these behind.
10
+ * An administrator who started an impersonation, then logged out, walked away
11
+ * from a browser still holding a thirty-day key back into their own account —
12
+ * on a shared or kiosk machine that is the whole story. They are listed here so
13
+ * both the stop handler and the logout handler clear the same set, and so the
14
+ * next cookie added to the flow has one place to be added to.
15
+ */
16
+ export declare const IMPERSONATION_COOKIE_NAMES: readonly ["nucleus_impersonating_as", "nucleus_godmin_id", "nucleus_impersonating_email", "nucleus_imp_sig"];
@@ -517,6 +517,16 @@ export interface NucleusConfigOptions {
517
517
  passwordTools?: {
518
518
  enabled?: boolean;
519
519
  };
520
+ /**
521
+ * Viewing the product as another account. On by default.
522
+ *
523
+ * The route layer already honoured this key; it was missing from the type,
524
+ * so anything reading the config in a type-checked context could not see
525
+ * it.
526
+ */
527
+ impersonate?: {
528
+ enabled?: boolean;
529
+ };
520
530
  };
521
531
  register?: {
522
532
  route?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "nucleus-core-ts",
3
- "version": "0.9.968",
3
+ "version": "0.9.970",
4
4
  "description": "Production-ready, enterprise-grade TypeScript framework for building multi-tenant APIs",
5
5
  "author": "Hidayet Can Özcan <hidayetcan@gmail.com>",
6
6
  "license": "SEE LICENSE IN LICENSE",
package/scripts/build.ts CHANGED
@@ -383,12 +383,9 @@ async function removeSourceMaps() {
383
383
  // to have GNU findutils on PATH.
384
384
  let removed = 0
385
385
  const walk = async (dir: string): Promise<void> => {
386
- let entries: Awaited<ReturnType<typeof readdir>>
387
- try {
388
- entries = await readdir(dir, { withFileTypes: true })
389
- } catch {
390
- return // the directory is optional; nothing to clean if it was never built
391
- }
386
+ // An unreadable directory is not an error here: nothing to clean if it was
387
+ // never built.
388
+ const entries = await readdir(dir, { withFileTypes: true }).catch(() => [])
392
389
  for (const entry of entries) {
393
390
  const full = join(dir, entry.name)
394
391
  if (entry.isDirectory()) {