@donotdev/core 0.0.14 → 0.0.16

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/server.d.ts CHANGED
@@ -2,8 +2,6 @@ import * as React from 'react';
2
2
  import { ReactNode, ComponentType } from 'react';
3
3
  export { ReactNode } from 'react';
4
4
  import * as v from 'valibot';
5
- export * from '@donotdev/schemas/server';
6
- export { global } from '@donotdev/schemas/server';
7
5
 
8
6
  // Types
9
7
 
@@ -13367,5 +13365,465 @@ declare namespace index_d {
13367
13365
  export type { index_d_DateFormatOptions as DateFormatOptions, index_d_DateFormatPreset as DateFormatPreset, index_d_ErrorHandlerConfig as ErrorHandlerConfig, index_d_ErrorHandlerFunction as ErrorHandlerFunction, index_d_HandleErrorOptions as HandleErrorOptions };
13368
13366
  }
13369
13367
 
13370
- export { AUTH_EVENTS, AUTH_PARTNERS, AUTH_PARTNER_STATE, AuthUserSchema, BILLING_EVENTS, BREAKPOINT_RANGES, BREAKPOINT_THRESHOLDS, COMMON_TIER_CONFIGS, CONFIDENCE_LEVELS, CONSENT_CATEGORY, CONTEXTS, CheckoutSessionMetadataSchema, CreateCheckoutSessionRequestSchema, CreateCheckoutSessionResponseSchema, CustomClaimsSchema, DEFAULT_ENTITY_ACCESS, DEFAULT_ERROR_MESSAGES, DEFAULT_LAYOUT_PRESET, DEFAULT_SUBSCRIPTION, DENSITY, DoNotDevError, ENVIRONMENTS, EntityHookError, FEATURES, FEATURE_CONSENT_MATRIX, FEATURE_STATUS, FIREBASE_ERROR_MAP, FIRESTORE_ID_PATTERN, GITHUB_PERMISSION_LEVELS, LAYOUT_PRESET, OAUTH_EVENTS, OAUTH_PARTNERS, PARTNER_ICONS, PAYLOAD_EVENTS, PERMISSIONS, PLATFORMS, PWA_ASSET_TYPES, PWA_DISPLAY_MODES, ProductDeclarationSchema, ProductDeclarationsSchema, ROUTE_SOURCES, STORAGE_SCOPES, STORAGE_TYPES, STRIPE_EVENTS, STRIPE_MODES, SUBSCRIPTION_DURATIONS, SUBSCRIPTION_STATUS, SUBSCRIPTION_TIERS, index_d as ServerUtils, SingletonManager, StripeBackConfigSchema, StripeFrontConfigSchema, StripePaymentSchema, StripeSubscriptionSchema, SubscriptionClaimsSchema, SubscriptionDataSchema, USER_ROLES, UserSubscriptionSchema, WebhookEventSchema, addMonths, addYears, calculateSubscriptionEndDate, captureErrorToSentry, checkGitHubAccessSchema, commonErrorCodeMappings, compactToISOString, createAsyncSingleton, createDefaultSubscriptionClaims, createDefaultUserProfile, createEntitySchema, createErrorHandler, createMetadata, createMethodProxy, createSingleton, createSingletonWithParams, deleteEntitySchema, detectErrorSource, disconnectOAuthSchema, exchangeTokenSchema, filterVisibleFields, formatDate, formatRelativeTime, generateCodeChallenge, generateCodeVerifier, generatePKCEPair, getBreakpointFromWidth, getBreakpointUtils, getConnectionsSchema, getCurrentTimestamp, getEntitySchema, getVisibleFields, getWeekFromISOString, githubPermissionSchema, githubRepoConfigSchema, grantGitHubAccessSchema, handleError, hasRoleAccess, hasTierAccess, isAuthPartnerId, isBreakpoint, isCompactDateString, isFieldVisible, isOAuthPartnerId, isPKCESupported, isoToCompactString, lazyImport, listEntitiesSchema, mapToDoNotDevError, maybeTranslate, normalizeToISOString, overrideFeatures, overridePaymentModes, overridePermissions, overrideSubscriptionStatus, overrideSubscriptionTiers, overrideUserRoles, parseDate, parseDateToNoonUTC, parseISODate, parseServerCookie, refreshTokenSchema, revokeGitHubAccessSchema, showNotification, timestampToISOString, toDateOnly, toISOString, translateArray, translateArrayRange, translateArrayWithIndices, translateObjectArray, updateEntitySchema, updateMetadata, validateAuthPartners, validateAuthSchemas, validateAuthUser, validateBillingSchemas, validateCheckoutSessionMetadata, validateCodeChallenge, validateCodeVerifier, validateCreateCheckoutSessionRequest, validateCreateCheckoutSessionResponse, validateCustomClaims, validateEnvVar, validateMetadata, validateOAuthPartners, validateStripeBackConfig, validateStripeFrontConfig, validateSubscriptionClaims, validateSubscriptionData, validateUrl, validateUserSubscription, validateWebhookEvent, withErrorHandling, withGracefulDegradation };
13371
- export type { AccountLinkResult, AccountLinkingInfo, AdminCheckHookResult, AdminClaims, AggregateConfig, AggregateFilterOperator, AggregateOperation, AggregateRequest, AggregateResponse, ApiResponse, AppConfig, AppCookieCategories, AppMetadata, AppProvidersProps, AssetsPluginConfig, AttemptRecord, AuthAPI, AuthActions, AuthConfig, AuthContextValue, AuthCoreHookResult, AuthError, AuthEventData, AuthEventKey, AuthEventName, AuthMethod, AuthPartner, AuthPartnerButton, AuthPartnerHookResult, AuthPartnerId, AuthPartnerResult, AuthPartnerState, AuthProvider, AuthProviderProps, AuthRedirectHookResult, AuthRedirectOperation, AuthRedirectOptions, AuthResult, AuthState, AuthStateStore, AuthStatus, AuthTokenHookResult, AuthUser, BaseActions, BaseCredentials, BaseDocument, BaseEntityFields, BasePartnerState, BaseState, BaseStoreActions, BaseStoreState, BaseUserProfile, BasicUserInfo, BillingAPI, BillingAdapter, BillingErrorCode, BillingEvent, BillingEventData, BillingEventKey, BillingEventName, BillingProvider, BillingProviderConfig, BillingRedirectOperation, Breakpoint, BreakpointUtils, BusinessEntity, CachedError, CanAPI, CheckGitHubAccessRequest, CheckoutMode, CheckoutOptions, CheckoutSessionMetadata, ColumnDef, CommonSubscriptionFeatures, CommonTranslations, ConfidenceLevel, ConsentAPI, ConsentActions, ConsentCategory, ConsentState, Context, CookieOptions, CreateCheckoutSessionRequest, CreateCheckoutSessionResponse, CreateEntityData, CreateEntityRequest, CreateEntityResponse, CrudAPI, CrudConfig, CustomClaims, CustomStoreConfig, DateFormatOptions, DateFormatPreset, DateValue, DeleteEntityRequest, DeleteEntityResponse, Density, DnDevLayoutProps, DnDevOverride, DndevFrameworkConfig, DoNotDevCookieCategories, DynamicFormRule, Editable, EffectiveConnectionType, EmailVerificationHookResult, EmailVerificationStatus, Entity, EntityAccessConfig, EntityAccessDefaults, EntityField, EntityHookErrors, EntityMetadata, EntityTemplateProps, EntityTranslations, EnvironmentMode, ErrorCode, ErrorHandlerConfig, ErrorHandlerFunction, ErrorSeverity, ErrorSource, ExchangeTokenParams, ExchangeTokenRequest, FaviconConfig, Feature, FeatureAccessHookResult, FeatureConsentRequirement, FeatureHookResult, FeatureId, FeatureName, FeatureStatus, FeaturesConfig, FeaturesPluginConfig, FeaturesRequiringAnyConsent, FeaturesRequiringConsent, FeaturesWithoutConsent, FieldCondition, FieldType, FieldTypeToValue, FileAsset, FirebaseCallOptions, FirebaseConfig, FirestoreTimestamp, FirestoreUniqueConstraintValidator, FooterConfig, FooterZoneConfig, FormConfig, FormStep, FunctionCallConfig, FunctionCallContext, FunctionCallOptions, FunctionCallResult, FunctionClient, FunctionClientFactoryOptions, FunctionDefaults, FunctionEndpoint, FunctionError, FunctionLoader, FunctionMemory, FunctionMeta, FunctionPlatform, FunctionResponse, FunctionSchema, FunctionSchemas, FunctionSystem, FunctionTrigger, FunctionsConfig, GetCustomClaimsResponse, GetEntityData, GetEntityRequest, GetEntityResponse, GetUserAuthStatusResponse, GitHubPermission, GitHubRepoConfig, GrantGitHubAccessRequest, GroupByDefinition, HandleErrorOptions, HeaderZoneConfig, I18nConfig, I18nPluginConfig, I18nProviderProps, ID, INetworkManager, IStorageManager, IStorageStrategy, Invoice, InvoiceItem, LanguageInfo, LayoutConfig, LayoutInput, LayoutPreset, LegalCompanyInfo, LegalConfig, LegalContactInfo, LegalDirectorInfo, LegalHostingInfo, LegalJurisdictionInfo, LegalSectionsConfig, LegalWebsiteInfo, ListEntitiesRequest, ListEntitiesResponse, ListEntityData, ListOptions, ListResponse, LoadingActions, LoadingState, MergedBarConfig, MetricDefinition, MobileBehaviorConfig, ModalActions, ModalState, MutationResponse, NavigationRoute, NetworkCheckConfig, NetworkConnectionType, NetworkReconnectCallback, NetworkState, NetworkStatus, NetworkStatusHookResult, OAuthAPI, OAuthApiRequestOptions, OAuthCallbackHookResult, OAuthConnection, OAuthConnectionInfo, OAuthConnectionRequest, OAuthConnectionStatus, OAuthCredentials, OAuthEventData, OAuthEventKey, OAuthEventName, OAuthPartner, OAuthPartnerButton, OAuthPartnerHookResult, OAuthPartnerId, OAuthPartnerResult, OAuthPartnerState, OAuthPurpose, OAuthRedirectOperation, OAuthRefreshRequest, OAuthRefreshResponse, OAuthResult, OAuthStoreActions, OAuthStoreState, Observable, OrderByClause, PWAAssetType, PWADisplayMode, PWAPluginConfig, PageAuth, PageMeta, PaginationOptions, PartnerButton, PartnerConnectionState, PartnerIconId, PartnerId, PartnerResult, PartnerType, PayloadCacheEventData, PayloadDocument, PayloadDocumentEventData, PayloadEventKey, PayloadEventName, PayloadGlobalEventData, PayloadMediaEventData, PayloadPageRegenerationEventData, PayloadRequest, PayloadUserEventData, PaymentEventData, PaymentMethod, PaymentMethodType, PaymentMode, Permission, Picture, Platform, PresetConfig, PresetRegistry, ProcessPaymentSuccessRequest, ProcessPaymentSuccessResponse, ProductDeclaration, ProviderInstances, QueryConfig, RateLimitConfig, RateLimitManager, RateLimitResult, RateLimitState, RateLimiter, ReadCallback, RedirectOperation, RedirectOverlayActions, RedirectOverlayConfig, RedirectOverlayPhase, RedirectOverlayState, Reference, RefreshSubscriptionRequest, RefreshSubscriptionResponse, RemoveCustomClaimsResponse, ResolvedLayoutConfig, RevokeGitHubAccessRequest, RouteMeta, RouteSource, RoutesPluginConfig, SEOConfig, SchemaMetadata, SetCustomClaimsResponse, SidebarZoneConfig, SlotContent, StorageOptions, StorageScope, StorageType, Store, StoreApi, StripeBackConfig, StripeCheckoutRequest, StripeCheckoutResponse, StripeCheckoutSessionEventData, StripeConfig, StripeCustomer, StripeCustomerEventData, StripeEventData, StripeEventKey, StripeEventName, StripeFrontConfig, StripeInvoice, StripeInvoiceEventData, StripePayment, StripePaymentIntentEventData, StripePaymentMethod, StripePrice, StripeProduct, StripeProvider, StripeSubscription, StripeSubscriptionData, StripeWebhookEvent, StripeWebhookEventData, Subscription, SubscriptionClaims, SubscriptionConfig, SubscriptionData, SubscriptionDuration, SubscriptionEventData, SubscriptionHookResult, SubscriptionInfo, SubscriptionStatus, SubscriptionTier, SupportedLanguage, ThemeActions, ThemeInfo, ThemeMode, ThemeState, ThemesPluginConfig, TierAccessHookResult, Timestamp, TokenInfo, TokenResponse, TokenState, TokenStatus, TranslationOptions, TranslationResource, UIFieldOptions, UniqueConstraintValidator, UnsubscribeFn, UpdateEntityData, UpdateEntityRequest, UpdateEntityResponse, UseFunctionsMutationOptions, UseFunctionsQueryOptions, UseTranslationOptionsEnhanced, UserContext, UserProfile, UserProviderData, UserRole, UserSubscription, ValidationRules, ValueTypeForField, Visibility, WebhookEvent, WebhookEventData, WhereClause, WhereOperator, WithMetadata, dndevSchema };
13368
+ /**
13369
+ * @fileoverview Unified Schema Generation
13370
+ * @description Creates Valibot schemas from entity definitions with visibility metadata.
13371
+ *
13372
+ * Entity → Schema (with visibility) → Used everywhere (frontend + backend)
13373
+ *
13374
+ * Isomorphic code (works in both client and server environments).
13375
+ *
13376
+ * @version 0.0.2
13377
+ * @since 0.0.1
13378
+ * @author AMBROISE PARK Consulting
13379
+ */
13380
+
13381
+ /**
13382
+ * Valibot schema with visibility metadata attached
13383
+ */
13384
+ interface SchemaWithVisibility extends v.BaseSchema<unknown, unknown, v.BaseIssue<unknown>> {
13385
+ visibility?: Visibility;
13386
+ }
13387
+ /**
13388
+ * Operation-specific schemas generated from entity
13389
+ */
13390
+ interface OperationSchemas {
13391
+ /** Create: excludes technical fields, enforces required */
13392
+ create: dndevSchema<unknown>;
13393
+ /** Draft: excludes technical fields, all optional except status='draft' */
13394
+ draft: dndevSchema<unknown>;
13395
+ /** Update: excludes technical fields, all optional */
13396
+ update: dndevSchema<unknown>;
13397
+ /** Get: includes all fields with visibility metadata */
13398
+ get: dndevSchema<unknown>;
13399
+ /** List: optimized for admin table (uses listFields) */
13400
+ list: dndevSchema<unknown>;
13401
+ /** ListCard: optimized for public cards (uses listCardFields, falls back to listFields) */
13402
+ listCard: dndevSchema<unknown>;
13403
+ /** Delete: just { id: string } */
13404
+ delete: dndevSchema<unknown>;
13405
+ }
13406
+ /**
13407
+ * Creates all operation-specific schemas from an entity definition
13408
+ *
13409
+ * Each schema field has `.visibility` attached for backend filtering.
13410
+ *
13411
+ * @param entity - Entity definition
13412
+ * @returns Operation-specific schemas with visibility metadata
13413
+ *
13414
+ * @example
13415
+ * ```typescript
13416
+ * const schemas = createSchemas(carEntity);
13417
+ * // schemas.create - for creating documents
13418
+ * // schemas.draft - for saving incomplete
13419
+ * // schemas.update - for partial updates
13420
+ * // schemas.get - for reading (includes technical fields)
13421
+ * // schemas.list - array of get
13422
+ * // schemas.delete - just { id }
13423
+ * ```
13424
+ */
13425
+ declare function createSchemas(entity: Entity): OperationSchemas;
13426
+
13427
+ /**
13428
+ * @fileoverview Schema enhancement utility
13429
+ * @description Enhances a Valibot schema with additional metadata
13430
+ *
13431
+ * @version 0.0.1
13432
+ * @since 0.0.1
13433
+ * @author AMBROISE PARK Consulting
13434
+ */
13435
+
13436
+ /**
13437
+ * Enhances a Valibot schema with additional metadata.
13438
+ *
13439
+ * @param schema - The base Valibot schema
13440
+ * @param metadata - The metadata to attach
13441
+ * @returns The enhanced schema
13442
+ * @version 0.0.1
13443
+ * @since 0.0.1
13444
+ * @author AMBROISE PARK Consulting
13445
+ */
13446
+ declare function enhanceSchema<T>(schema: v.BaseSchema<unknown, T, v.BaseIssue<unknown>>, metadata: SchemaMetadata): dndevSchema<T>;
13447
+
13448
+ /**
13449
+ * @fileoverview Schema type generation utility
13450
+ * @description Creates Valibot schemas via registry - extensible for custom types
13451
+ *
13452
+ * @version 0.0.2
13453
+ * @since 0.0.1
13454
+ * @author AMBROISE PARK Consulting
13455
+ */
13456
+
13457
+ /**
13458
+ * Schema generator function type
13459
+ */
13460
+ type CustomSchemaGenerator = (field: EntityField<FieldType>) => v.BaseSchema<unknown, unknown, v.BaseIssue<unknown>> | null;
13461
+ /**
13462
+ * Register a schema generator for a field type
13463
+ */
13464
+ declare function registerSchemaGenerator(type: string, generator: CustomSchemaGenerator): void;
13465
+ /**
13466
+ * Check if a schema generator is registered
13467
+ */
13468
+ declare function hasCustomSchemaGenerator(type: string): boolean;
13469
+ /**
13470
+ * Get all registered schema types
13471
+ */
13472
+ declare function getRegisteredSchemaTypes(): string[];
13473
+ /**
13474
+ * Clear all schema generators (testing)
13475
+ */
13476
+ declare function clearSchemaGenerators(): void;
13477
+ /**
13478
+ * Get Valibot schema for an entity field
13479
+ *
13480
+ * Priority order:
13481
+ * 1. field.validation?.schema (custom schema defined directly in entity)
13482
+ * 2. Registry lookup (built-in or registered custom types)
13483
+ * 3. Fallback to v.unknown() for unregistered types
13484
+ */
13485
+ declare function getSchemaType(field: EntityField<FieldType>): v.BaseSchema<unknown, unknown, v.BaseIssue<unknown>>;
13486
+
13487
+ /**
13488
+ * Recursively validates that all string values that look like potential dates
13489
+ * within an object adhere to the ISO 8601 format (YYYY-MM-DDTHH:mm:ss.sssZ).
13490
+ *
13491
+ * @param data - The object or data structure to validate
13492
+ * @param {string} [currentPath=''] - Internal tracking of the object path for error messages
13493
+ * @throws Error if any string resembling a date is not in the correct ISO format
13494
+ * @version 0.0.1
13495
+ * @since 0.0.1
13496
+ * @author AMBROISE PARK Consulting
13497
+ */
13498
+ declare function validateDates(data: Record<string, any> | any[], currentPath?: string): void;
13499
+
13500
+ /**
13501
+ * Validates a document against the schema, including uniqueness and custom validations.
13502
+ * @param schema - The enhanced schema.
13503
+ * @param data - The document data.
13504
+ * @param operation - 'create' or 'update'.
13505
+ * @param currentDocId - Optional current document ID for update operations.
13506
+ * @throws DoNotDevError if validation fails.
13507
+ *
13508
+ * @version 0.0.1
13509
+ * @since 0.0.1
13510
+ * @author AMBROISE PARK Consulting
13511
+ */
13512
+ declare function validateDocument<T>(schema: dndevSchema<T>, data: Record<string, any>, operation: 'create' | 'update', currentDocId?: string): Promise<void>;
13513
+
13514
+ /**
13515
+ * @fileoverview Unique field validation utility
13516
+ * @description Validates uniqueness constraints for schema fields
13517
+ *
13518
+ * @version 0.0.1
13519
+ * @since 0.0.1
13520
+ * @author AMBROISE PARK Consulting
13521
+ */
13522
+
13523
+ /**
13524
+ * Registers a validator for uniqueness constraints
13525
+ *
13526
+ * @param validator - The validator implementation
13527
+ * @version 0.0.1
13528
+ * @since 0.0.1
13529
+ * @author AMBROISE PARK Consulting
13530
+ */
13531
+ declare function registerUniqueConstraintValidator(validator: UniqueConstraintValidator): void;
13532
+ /**
13533
+ * Validates unique fields for a document across environments.
13534
+ *
13535
+ * @param schema - The Valibot schema with metadata.
13536
+ * @param data - The document data.
13537
+ * @param currentDocId - Optional ID of the current document (for updates).
13538
+ * @throws Error if a unique constraint is violated.
13539
+ * @version 0.0.1
13540
+ * @since 0.0.1
13541
+ * @author AMBROISE PARK Consulting
13542
+ */
13543
+ declare function validateUniqueFields<T>(schema: dndevSchema<T>, data: Record<string, any>, currentDocId?: string): Promise<void>;
13544
+
13545
+ /**
13546
+ * @fileoverview Schema Utilities
13547
+ * @description Common utility functions for working with schemas. Provides helper functions for schema metadata checking and manipulation.
13548
+ *
13549
+ * @version 0.0.1
13550
+ * @since 0.0.1
13551
+ * @author AMBROISE PARK Consulting
13552
+ */
13553
+
13554
+ /**
13555
+ * Checks if an object has schema metadata (works with Valibot schemas)
13556
+ *
13557
+ * @param obj - The object to check
13558
+ * @returns Whether the object has schema metadata
13559
+ * @version 0.0.1
13560
+ * @since 0.0.1
13561
+ * @author AMBROISE PARK Consulting
13562
+ */
13563
+ declare function hasMetadata(obj: unknown): obj is dndevSchema<unknown>;
13564
+ /**
13565
+ * Gets the collection name from a schema
13566
+ *
13567
+ * @param schema - The schema to get the collection name from
13568
+ * @returns The collection name
13569
+ * @version 0.0.1
13570
+ * @since 0.0.1
13571
+ * @author AMBROISE PARK Consulting
13572
+ */
13573
+ declare function getCollectionName(schema: dndevSchema<unknown>): string;
13574
+
13575
+ /**
13576
+ * @fileoverview The 4 Field Families
13577
+ * @description Every entity in the framework is composed of 4 families
13578
+ *
13579
+ * ## The 4 Families
13580
+ *
13581
+ * ```
13582
+ * Entity = Technical Fields + Status Field + User Fields (Framework Types or Custom Types)
13583
+ * ```
13584
+ *
13585
+ * ### Family 1: TECHNICAL_FIELDS (Backend-Generated)
13586
+ * **Members**: `id`, `createdAt`, `updatedAt`, `createdById`, `updatedById`
13587
+ *
13588
+ * **Rules**:
13589
+ * - ✓ Always present (framework adds automatically)
13590
+ * - ✗ Users cannot set (stripped from submissions)
13591
+ * - ✓ Read-only in edit forms
13592
+ * - ✓ Auto-generated by server
13593
+ *
13594
+ * ### Family 2: STATUS_FIELD (Lifecycle Management)
13595
+ * **Member**: `status`
13596
+ *
13597
+ * **Default Values**: `'draft'`, `'available'`, `'deleted'`
13598
+ *
13599
+ * **Rules**:
13600
+ * - ✓ Always present (framework adds)
13601
+ * - ✓ Users must set value
13602
+ * - ✓ Users can add custom values (`'reserved'`, `'sold'`)
13603
+ * - ✗ Cannot remove default values
13604
+ * - ✓ Draft mode (`status === 'draft'`) relaxes validation
13605
+ *
13606
+ * ### Family 3: FRAMEWORK_TYPES (~30 Built-in)
13607
+ * **Available Types**:
13608
+ * - Text: `text`, `textarea`, `email`, `tel`, `url`, `password`
13609
+ * - Numbers: `number`, `range`
13610
+ * - Dates: `date`, `datetime-local`, `time`, `timestamp`
13611
+ * - Choices: `select`, `multiselect`, `radio`, `checkbox`, `combobox`, `switch`
13612
+ * - Media: `image`, `images`, `file`
13613
+ * - Special: `reference`, `geopoint`, `address`, `map`
13614
+ *
13615
+ * ### Family 4: CUSTOM_TYPES (User-Registered)
13616
+ * **What**: Custom field types registered via `registerFieldType()`
13617
+ *
13618
+ * **Examples**: `repairOperations`, `ratp`, custom widgets
13619
+ *
13620
+ * ## Complete Example
13621
+ *
13622
+ * ```typescript
13623
+ * import { defineEntity } from '@donotdev/core';
13624
+ * import { registerFieldType } from '@donotdev/crud';
13625
+ *
13626
+ * // Register custom type (Family 4)
13627
+ * registerFieldType('repairOperations', {
13628
+ * schema: (field) => v.array(v.object({ operation: v.string(), cost: v.number() })),
13629
+ * component: RepairOperationsField
13630
+ * });
13631
+ *
13632
+ * // Define entity
13633
+ * const carEntity = defineEntity({
13634
+ * name: 'Car',
13635
+ * collection: 'cars',
13636
+ * fields: {
13637
+ * // User fields using FRAMEWORK_TYPES (Family 3)
13638
+ * make: { type: 'text', validation: { required: true } },
13639
+ * year: { type: 'number' },
13640
+ * images: { type: 'images' },
13641
+ * fuelType: { type: 'select', validation: { options: [...] } },
13642
+ *
13643
+ * // User field using CUSTOM_TYPES (Family 4)
13644
+ * repairs: { type: 'repairOperations', visibility: 'admin' },
13645
+ *
13646
+ * // Extend STATUS_FIELD (Family 2)
13647
+ * status: {
13648
+ * validation: {
13649
+ * options: [
13650
+ * { value: 'reserved', label: 'Reserved' },
13651
+ * { value: 'sold', label: 'Sold' }
13652
+ * ]
13653
+ * }
13654
+ * }
13655
+ *
13656
+ * // TECHNICAL_FIELDS (Family 1) auto-added by framework
13657
+ * }
13658
+ * });
13659
+ * ```
13660
+ *
13661
+ * **Result**:
13662
+ * - Family 1 (Technical): `id`, `createdAt`, `updatedAt`, `createdById`, `updatedById`
13663
+ * - Family 2 (Status): `status` with `draft/available/deleted/reserved/sold`
13664
+ * - User fields: `make`, `year`, `images`, `fuelType`, `repairs`
13665
+ *
13666
+ * @version 0.0.1
13667
+ * @since 0.0.1
13668
+ * @author AMBROISE PARK Consulting
13669
+ */
13670
+
13671
+ /**
13672
+ * Type-safe base fields that all entities inherit
13673
+ * Each field has its specific type for proper TypeScript inference
13674
+ */
13675
+ interface TypedBaseFields {
13676
+ id: EntityField<'text'>;
13677
+ createdAt: EntityField<'timestamp'>;
13678
+ updatedAt: EntityField<'timestamp'>;
13679
+ createdById: EntityField<'reference'>;
13680
+ updatedById: EntityField<'reference'>;
13681
+ status: EntityField<'select'>;
13682
+ }
13683
+ /**
13684
+ * Default status options for draft/publish/delete workflow
13685
+ * Framework provides 'draft', 'available', 'deleted' - consumers can extend
13686
+ * Labels use translation keys (dndev:status.*) for i18n support
13687
+ */
13688
+ declare const DEFAULT_STATUS_OPTIONS: readonly [{
13689
+ readonly value: "draft";
13690
+ readonly label: "dndev:status.draft";
13691
+ }, {
13692
+ readonly value: "available";
13693
+ readonly label: "dndev:status.available";
13694
+ }, {
13695
+ readonly value: "deleted";
13696
+ readonly label: "dndev:status.deleted";
13697
+ }];
13698
+ /**
13699
+ * Default status value for new documents (published by default)
13700
+ */
13701
+ declare const DEFAULT_STATUS_VALUE: "available";
13702
+ /**
13703
+ * Statuses that are hidden from non-admin users
13704
+ */
13705
+ declare const HIDDEN_STATUSES: readonly ["draft", "deleted"];
13706
+ /**
13707
+ * Fields that are TRULY backend-generated (cannot be set by user)
13708
+ * These are stripped from create operations - backend creates them automatically
13709
+ *
13710
+ * @category Field Families
13711
+ * @constant BACKEND_GENERATED_FIELD_NAMES
13712
+ */
13713
+ declare const BACKEND_GENERATED_FIELD_NAMES: readonly ["id", "createdAt", "updatedAt", "createdById", "updatedById"];
13714
+ /**
13715
+ * List of technical field names that are auto-generated by the backend
13716
+ * Includes backend-generated fields + status field
13717
+ *
13718
+ * These fields are optional in create schemas (backend creates them automatically).
13719
+ * They can be updated in update operations if provided.
13720
+ *
13721
+ * **Note**: Status is included here for visibility/editability logic but is NOT stripped
13722
+ * from form submissions since users MUST set it. Use BACKEND_GENERATED_FIELD_NAMES for stripping.
13723
+ *
13724
+ * @category Field Families
13725
+ * @constant TECHNICAL_FIELD_NAMES
13726
+ */
13727
+ declare const TECHNICAL_FIELD_NAMES: readonly ["id", "createdAt", "updatedAt", "createdById", "updatedById", "status"];
13728
+ /**
13729
+ * TypeScript Helper Types for Field Families
13730
+ * @category Field Families
13731
+ */
13732
+ /** Type for backend-generated field names */
13733
+ type BackendGeneratedField = (typeof BACKEND_GENERATED_FIELD_NAMES)[number];
13734
+ /** Type for the status field */
13735
+ type StatusField = 'status';
13736
+ /** Type for all technical field names */
13737
+ type TechnicalField = (typeof TECHNICAL_FIELD_NAMES)[number];
13738
+ /**
13739
+ * Type guard to check if a field name is a framework-managed field
13740
+ * @param fieldName - Field name to check
13741
+ * @returns True if field is in TECHNICAL_FIELD_NAMES
13742
+ *
13743
+ * @example
13744
+ * ```typescript
13745
+ * if (isFrameworkField('status')) {
13746
+ * // Field is framework-managed (cannot remove)
13747
+ * }
13748
+ * ```
13749
+ */
13750
+ declare function isFrameworkField(fieldName: string): fieldName is TechnicalField;
13751
+ /**
13752
+ * Type guard to check if a field is backend-generated
13753
+ * @param fieldName - Field name to check
13754
+ * @returns True if field is auto-generated by backend
13755
+ *
13756
+ * @example
13757
+ * ```typescript
13758
+ * if (isBackendGeneratedField('createdAt')) {
13759
+ * // Field is backend-generated (should be stripped on create)
13760
+ * }
13761
+ * ```
13762
+ */
13763
+ declare function isBackendGeneratedField(fieldName: string): fieldName is BackendGeneratedField;
13764
+ declare const baseFields: TypedBaseFields;
13765
+
13766
+ /**
13767
+ * Defines an entity with validation and default configuration
13768
+ *
13769
+ * Automatically adds technical fields (`id`, `createdAt`, `updatedAt`, `createdById`, `updatedById`)
13770
+ * with `visibility: 'technical'`. User-defined technical fields are merged with defaults, allowing
13771
+ * customization (e.g., `editable: 'admin'`, custom `label`, additional `validation`).
13772
+ *
13773
+ * @param entity - The business entity definition
13774
+ * @returns The validated and configured entity
13775
+ *
13776
+ * @example
13777
+ * ```typescript
13778
+ * export const productEntity = defineEntity({
13779
+ * name: 'Product',
13780
+ * collection: 'products',
13781
+ * fields: {
13782
+ * name: {
13783
+ * type: 'text',
13784
+ * visibility: 'user',
13785
+ * validation: { required: true, minLength: 3 }
13786
+ * },
13787
+ * // Customize technical field (optional)
13788
+ * createdAt: {
13789
+ * editable: 'admin',
13790
+ * label: 'Created Date'
13791
+ * }
13792
+ * },
13793
+ * // Override access defaults (optional)
13794
+ * access: { create: 'guest' } // Public inquiry form
13795
+ * });
13796
+ * ```
13797
+ *
13798
+ * **Technical Fields:**
13799
+ * - Automatically added: `id`, `createdAt`, `updatedAt`, `createdById`, `updatedById`, `status`
13800
+ * - Default: `visibility: 'technical'`, read-only in edit forms
13801
+ * - Customizable: Can override `editable`, `label`, `hint`, `validation` (merged with defaults)
13802
+ *
13803
+ * **Access Configuration:**
13804
+ * - Defaults: `{ read: 'guest', create: 'admin', update: 'admin', delete: 'admin' }`
13805
+ * - Uses role hierarchy: guest (0) < user (1) < admin (2) < super (3)
13806
+ * - Override individual operations: `access: { create: 'guest' }` for public forms
13807
+ * - Field visibility still applies for sensitive data filtering
13808
+ *
13809
+ * **Status Field (Draft/Publish/Delete):**
13810
+ * - Auto-added with `visibility: 'admin'` and options: `['draft', 'available', 'deleted']`
13811
+ * - Default value: `'available'` (new documents are published by default)
13812
+ * - `draft` and `deleted` statuses hidden from non-admin users (server-side filtering)
13813
+ * - `validation.required` on other fields only enforced when status !== 'draft'
13814
+ * - Extend options: `status: { validation: { options: [{ value: 'sold', label: 'sold' }] } }`
13815
+ * - Hide field: `status: { visibility: 'technical' }` if you don't want it in forms
13816
+ *
13817
+ * **Dropdown Options Format:**
13818
+ * - For `select`, `multiselect`, and `radio` field types, options must be defined in `validation.options`
13819
+ * - Options must be an array of objects with `value` (string) and `label` (string)
13820
+ * - Labels can use i18n keys (e.g., `'entities.product.status.active'`) for translation
13821
+ *
13822
+ * @version 0.0.2
13823
+ * @since 0.0.1
13824
+ * @author AMBROISE PARK Consulting
13825
+ */
13826
+ declare function defineEntity(entity: BusinessEntity): Entity;
13827
+
13828
+ export { AUTH_EVENTS, AUTH_PARTNERS, AUTH_PARTNER_STATE, AuthUserSchema, BACKEND_GENERATED_FIELD_NAMES, BILLING_EVENTS, BREAKPOINT_RANGES, BREAKPOINT_THRESHOLDS, COMMON_TIER_CONFIGS, CONFIDENCE_LEVELS, CONSENT_CATEGORY, CONTEXTS, CheckoutSessionMetadataSchema, CreateCheckoutSessionRequestSchema, CreateCheckoutSessionResponseSchema, CustomClaimsSchema, DEFAULT_ENTITY_ACCESS, DEFAULT_ERROR_MESSAGES, DEFAULT_LAYOUT_PRESET, DEFAULT_STATUS_OPTIONS, DEFAULT_STATUS_VALUE, DEFAULT_SUBSCRIPTION, DENSITY, DoNotDevError, ENVIRONMENTS, EntityHookError, FEATURES, FEATURE_CONSENT_MATRIX, FEATURE_STATUS, FIREBASE_ERROR_MAP, FIRESTORE_ID_PATTERN, GITHUB_PERMISSION_LEVELS, HIDDEN_STATUSES, LAYOUT_PRESET, OAUTH_EVENTS, OAUTH_PARTNERS, PARTNER_ICONS, PAYLOAD_EVENTS, PERMISSIONS, PLATFORMS, PWA_ASSET_TYPES, PWA_DISPLAY_MODES, ProductDeclarationSchema, ProductDeclarationsSchema, ROUTE_SOURCES, STORAGE_SCOPES, STORAGE_TYPES, STRIPE_EVENTS, STRIPE_MODES, SUBSCRIPTION_DURATIONS, SUBSCRIPTION_STATUS, SUBSCRIPTION_TIERS, index_d as ServerUtils, SingletonManager, StripeBackConfigSchema, StripeFrontConfigSchema, StripePaymentSchema, StripeSubscriptionSchema, SubscriptionClaimsSchema, SubscriptionDataSchema, TECHNICAL_FIELD_NAMES, USER_ROLES, UserSubscriptionSchema, WebhookEventSchema, addMonths, addYears, baseFields, calculateSubscriptionEndDate, captureErrorToSentry, checkGitHubAccessSchema, clearSchemaGenerators, commonErrorCodeMappings, compactToISOString, createAsyncSingleton, createDefaultSubscriptionClaims, createDefaultUserProfile, createEntitySchema, createErrorHandler, createMetadata, createMethodProxy, createSchemas, createSingleton, createSingletonWithParams, defineEntity, deleteEntitySchema, detectErrorSource, disconnectOAuthSchema, enhanceSchema, exchangeTokenSchema, filterVisibleFields, formatDate, formatRelativeTime, generateCodeChallenge, generateCodeVerifier, generatePKCEPair, getBreakpointFromWidth, getBreakpointUtils, getCollectionName, getConnectionsSchema, getCurrentTimestamp, getEntitySchema, getRegisteredSchemaTypes, getSchemaType, getVisibleFields, getWeekFromISOString, githubPermissionSchema, githubRepoConfigSchema, grantGitHubAccessSchema, handleError, hasCustomSchemaGenerator, hasMetadata, hasRoleAccess, hasTierAccess, isAuthPartnerId, isBackendGeneratedField, isBreakpoint, isCompactDateString, isFieldVisible, isFrameworkField, isOAuthPartnerId, isPKCESupported, isoToCompactString, lazyImport, listEntitiesSchema, mapToDoNotDevError, maybeTranslate, normalizeToISOString, overrideFeatures, overridePaymentModes, overridePermissions, overrideSubscriptionStatus, overrideSubscriptionTiers, overrideUserRoles, parseDate, parseDateToNoonUTC, parseISODate, parseServerCookie, refreshTokenSchema, registerSchemaGenerator, registerUniqueConstraintValidator, revokeGitHubAccessSchema, showNotification, timestampToISOString, toDateOnly, toISOString, translateArray, translateArrayRange, translateArrayWithIndices, translateObjectArray, updateEntitySchema, updateMetadata, validateAuthPartners, validateAuthSchemas, validateAuthUser, validateBillingSchemas, validateCheckoutSessionMetadata, validateCodeChallenge, validateCodeVerifier, validateCreateCheckoutSessionRequest, validateCreateCheckoutSessionResponse, validateCustomClaims, validateDates, validateDocument, validateEnvVar, validateMetadata, validateOAuthPartners, validateStripeBackConfig, validateStripeFrontConfig, validateSubscriptionClaims, validateSubscriptionData, validateUniqueFields, validateUrl, validateUserSubscription, validateWebhookEvent, withErrorHandling, withGracefulDegradation };
13829
+ export type { AccountLinkResult, AccountLinkingInfo, AdminCheckHookResult, AdminClaims, AggregateConfig, AggregateFilterOperator, AggregateOperation, AggregateRequest, AggregateResponse, ApiResponse, AppConfig, AppCookieCategories, AppMetadata, AppProvidersProps, AssetsPluginConfig, AttemptRecord, AuthAPI, AuthActions, AuthConfig, AuthContextValue, AuthCoreHookResult, AuthError, AuthEventData, AuthEventKey, AuthEventName, AuthMethod, AuthPartner, AuthPartnerButton, AuthPartnerHookResult, AuthPartnerId, AuthPartnerResult, AuthPartnerState, AuthProvider, AuthProviderProps, AuthRedirectHookResult, AuthRedirectOperation, AuthRedirectOptions, AuthResult, AuthState, AuthStateStore, AuthStatus, AuthTokenHookResult, AuthUser, BackendGeneratedField, BaseActions, BaseCredentials, BaseDocument, BaseEntityFields, BasePartnerState, BaseState, BaseStoreActions, BaseStoreState, BaseUserProfile, BasicUserInfo, BillingAPI, BillingAdapter, BillingErrorCode, BillingEvent, BillingEventData, BillingEventKey, BillingEventName, BillingProvider, BillingProviderConfig, BillingRedirectOperation, Breakpoint, BreakpointUtils, BusinessEntity, CachedError, CanAPI, CheckGitHubAccessRequest, CheckoutMode, CheckoutOptions, CheckoutSessionMetadata, ColumnDef, CommonSubscriptionFeatures, CommonTranslations, ConfidenceLevel, ConsentAPI, ConsentActions, ConsentCategory, ConsentState, Context, CookieOptions, CreateCheckoutSessionRequest, CreateCheckoutSessionResponse, CreateEntityData, CreateEntityRequest, CreateEntityResponse, CrudAPI, CrudConfig, CustomClaims, CustomSchemaGenerator, CustomStoreConfig, DateFormatOptions, DateFormatPreset, DateValue, DeleteEntityRequest, DeleteEntityResponse, Density, DnDevLayoutProps, DnDevOverride, DndevFrameworkConfig, DoNotDevCookieCategories, DynamicFormRule, Editable, EffectiveConnectionType, EmailVerificationHookResult, EmailVerificationStatus, Entity, EntityAccessConfig, EntityAccessDefaults, EntityField, EntityHookErrors, EntityMetadata, EntityTemplateProps, EntityTranslations, EnvironmentMode, ErrorCode, ErrorHandlerConfig, ErrorHandlerFunction, ErrorSeverity, ErrorSource, ExchangeTokenParams, ExchangeTokenRequest, FaviconConfig, Feature, FeatureAccessHookResult, FeatureConsentRequirement, FeatureHookResult, FeatureId, FeatureName, FeatureStatus, FeaturesConfig, FeaturesPluginConfig, FeaturesRequiringAnyConsent, FeaturesRequiringConsent, FeaturesWithoutConsent, FieldCondition, FieldType, FieldTypeToValue, FileAsset, FirebaseCallOptions, FirebaseConfig, FirestoreTimestamp, FirestoreUniqueConstraintValidator, FooterConfig, FooterZoneConfig, FormConfig, FormStep, FunctionCallConfig, FunctionCallContext, FunctionCallOptions, FunctionCallResult, FunctionClient, FunctionClientFactoryOptions, FunctionDefaults, FunctionEndpoint, FunctionError, FunctionLoader, FunctionMemory, FunctionMeta, FunctionPlatform, FunctionResponse, FunctionSchema, FunctionSchemas, FunctionSystem, FunctionTrigger, FunctionsConfig, GetCustomClaimsResponse, GetEntityData, GetEntityRequest, GetEntityResponse, GetUserAuthStatusResponse, GitHubPermission, GitHubRepoConfig, GrantGitHubAccessRequest, GroupByDefinition, HandleErrorOptions, HeaderZoneConfig, I18nConfig, I18nPluginConfig, I18nProviderProps, ID, INetworkManager, IStorageManager, IStorageStrategy, Invoice, InvoiceItem, LanguageInfo, LayoutConfig, LayoutInput, LayoutPreset, LegalCompanyInfo, LegalConfig, LegalContactInfo, LegalDirectorInfo, LegalHostingInfo, LegalJurisdictionInfo, LegalSectionsConfig, LegalWebsiteInfo, ListEntitiesRequest, ListEntitiesResponse, ListEntityData, ListOptions, ListResponse, LoadingActions, LoadingState, MergedBarConfig, MetricDefinition, MobileBehaviorConfig, ModalActions, ModalState, MutationResponse, NavigationRoute, NetworkCheckConfig, NetworkConnectionType, NetworkReconnectCallback, NetworkState, NetworkStatus, NetworkStatusHookResult, OAuthAPI, OAuthApiRequestOptions, OAuthCallbackHookResult, OAuthConnection, OAuthConnectionInfo, OAuthConnectionRequest, OAuthConnectionStatus, OAuthCredentials, OAuthEventData, OAuthEventKey, OAuthEventName, OAuthPartner, OAuthPartnerButton, OAuthPartnerHookResult, OAuthPartnerId, OAuthPartnerResult, OAuthPartnerState, OAuthPurpose, OAuthRedirectOperation, OAuthRefreshRequest, OAuthRefreshResponse, OAuthResult, OAuthStoreActions, OAuthStoreState, Observable, OperationSchemas, OrderByClause, PWAAssetType, PWADisplayMode, PWAPluginConfig, PageAuth, PageMeta, PaginationOptions, PartnerButton, PartnerConnectionState, PartnerIconId, PartnerId, PartnerResult, PartnerType, PayloadCacheEventData, PayloadDocument, PayloadDocumentEventData, PayloadEventKey, PayloadEventName, PayloadGlobalEventData, PayloadMediaEventData, PayloadPageRegenerationEventData, PayloadRequest, PayloadUserEventData, PaymentEventData, PaymentMethod, PaymentMethodType, PaymentMode, Permission, Picture, Platform, PresetConfig, PresetRegistry, ProcessPaymentSuccessRequest, ProcessPaymentSuccessResponse, ProductDeclaration, ProviderInstances, QueryConfig, RateLimitConfig, RateLimitManager, RateLimitResult, RateLimitState, RateLimiter, ReadCallback, RedirectOperation, RedirectOverlayActions, RedirectOverlayConfig, RedirectOverlayPhase, RedirectOverlayState, Reference, RefreshSubscriptionRequest, RefreshSubscriptionResponse, RemoveCustomClaimsResponse, ResolvedLayoutConfig, RevokeGitHubAccessRequest, RouteMeta, RouteSource, RoutesPluginConfig, SEOConfig, SchemaMetadata, SchemaWithVisibility, SetCustomClaimsResponse, SidebarZoneConfig, SlotContent, StatusField, StorageOptions, StorageScope, StorageType, Store, StoreApi, StripeBackConfig, StripeCheckoutRequest, StripeCheckoutResponse, StripeCheckoutSessionEventData, StripeConfig, StripeCustomer, StripeCustomerEventData, StripeEventData, StripeEventKey, StripeEventName, StripeFrontConfig, StripeInvoice, StripeInvoiceEventData, StripePayment, StripePaymentIntentEventData, StripePaymentMethod, StripePrice, StripeProduct, StripeProvider, StripeSubscription, StripeSubscriptionData, StripeWebhookEvent, StripeWebhookEventData, Subscription, SubscriptionClaims, SubscriptionConfig, SubscriptionData, SubscriptionDuration, SubscriptionEventData, SubscriptionHookResult, SubscriptionInfo, SubscriptionStatus, SubscriptionTier, SupportedLanguage, TechnicalField, ThemeActions, ThemeInfo, ThemeMode, ThemeState, ThemesPluginConfig, TierAccessHookResult, Timestamp, TokenInfo, TokenResponse, TokenState, TokenStatus, TranslationOptions, TranslationResource, TypedBaseFields, UIFieldOptions, UniqueConstraintValidator, UnsubscribeFn, UpdateEntityData, UpdateEntityRequest, UpdateEntityResponse, UseFunctionsMutationOptions, UseFunctionsQueryOptions, UseTranslationOptionsEnhanced, UserContext, UserProfile, UserProviderData, UserRole, UserSubscription, ValidationRules, ValueTypeForField, Visibility, WebhookEvent, WebhookEventData, WhereClause, WhereOperator, WithMetadata, dndevSchema };