@donotdev/core 0.0.18 → 0.0.19

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
@@ -1089,6 +1089,26 @@ type KeyWithContext<Key, TOpt extends TOptions> = TOpt['context'] extends string
1089
1089
  ? `${Key & string}${_ContextSeparator}${TOpt['context']}`
1090
1090
  : Key;
1091
1091
 
1092
+ // helper that maps the configured fallbackNS value to the matching resources slice
1093
+ type FallbackResourcesOf<FallbackNS, R> = FallbackNS extends readonly (infer FN)[]
1094
+ ? R[FN & keyof R]
1095
+ : [FallbackNS] extends [false]
1096
+ ? never
1097
+ : R[Extract<FallbackNS, keyof R> & keyof R];
1098
+
1099
+ /* reuse the parse helpers as top-level aliases (no nested type declarations) */
1100
+ type _PrimaryParse<
1101
+ ActualKey,
1102
+ PrimaryNS extends keyof Resources,
1103
+ TOpt extends TOptions,
1104
+ > = ParseTReturn<ActualKey, Resources[PrimaryNS], TOpt>;
1105
+
1106
+ type _FallbackParse<ActualKey, FallbackNS, TOpt extends TOptions> = [
1107
+ FallbackResourcesOf<FallbackNS, Resources>,
1108
+ ] extends [never]
1109
+ ? never
1110
+ : ParseTReturn<ActualKey, FallbackResourcesOf<FallbackNS, Resources>, TOpt>;
1111
+
1092
1112
  type TFunctionReturn<
1093
1113
  Ns extends Namespace,
1094
1114
  Key,
@@ -1098,7 +1118,15 @@ type TFunctionReturn<
1098
1118
  > = $IsResourcesDefined extends true
1099
1119
  ? ActualKey extends `${infer Nsp}${_NsSeparator}${infer RestKey}`
1100
1120
  ? ParseTReturn<RestKey, Resources[Nsp & keyof Resources], TOpt>
1101
- : ParseTReturn<ActualKey, Resources[$FirstNamespace<ActualNS>], TOpt>
1121
+ : $FirstNamespace<ActualNS> extends infer PrimaryNS
1122
+ ? [PrimaryNS] extends [keyof Resources]
1123
+ ? [_PrimaryParse<ActualKey, PrimaryNS & keyof Resources, TOpt>] extends [never]
1124
+ ? [_FallbackParse<ActualKey, _FallbackNamespace, TOpt>] extends [never]
1125
+ ? DefaultTReturn<TOpt>
1126
+ : _FallbackParse<ActualKey, _FallbackNamespace, TOpt>
1127
+ : _PrimaryParse<ActualKey, PrimaryNS & keyof Resources, TOpt>
1128
+ : never
1129
+ : never
1102
1130
  : DefaultTReturn<TOpt>;
1103
1131
 
1104
1132
  type TFunctionDetailedResult<T = string, TOpt extends TOptions = {}> = {
@@ -1201,17 +1229,24 @@ type KeyPrefix<Ns extends Namespace> = ResourceKeys<true>[$FirstNamespace<Ns>] |
1201
1229
  /// ↆ selector ↆ ///
1202
1230
  /// ////////////// ///
1203
1231
 
1232
+ type NsArg<Ns extends Namespace> = Ns[number] | readonly Ns[number][];
1233
+
1204
1234
  interface TFunctionSelector<Ns extends Namespace, KPrefix, Source> extends Branded<Ns> {
1205
1235
  <
1206
1236
  Target extends ConstrainTarget<Opts>,
1237
+ const NewNs extends NsArg<Ns> & Namespace,
1207
1238
  const Opts extends SelectorOptions<NewNs>,
1208
- NewNs extends Namespace,
1209
1239
  NewSrc extends GetSource<NewNs, KPrefix>,
1210
1240
  >(
1211
1241
  selector: SelectorFn<NewSrc, ApplyTarget<Target, Opts>, Opts>,
1212
1242
  options: Opts & InterpolationMap<Target> & { ns: NewNs },
1213
1243
  ): SelectorReturn<Target, Opts>;
1214
- <Target extends ConstrainTarget<Opts>, const Opts extends SelectorOptions<Ns>>(
1244
+
1245
+ <
1246
+ Target extends ConstrainTarget<Opts>,
1247
+ const NewNs extends NsArg<Ns> = Ns[number],
1248
+ const Opts extends SelectorOptions<NewNs> = SelectorOptions<NewNs>,
1249
+ >(
1215
1250
  selector: SelectorFn<Source, ApplyTarget<Target, Opts>, Opts>,
1216
1251
  options?: Opts & InterpolationMap<Target>,
1217
1252
  ): SelectorReturn<Target, Opts>;
@@ -2023,6 +2058,56 @@ declare function createMetadata(userId: string): {
2023
2058
  _updatedBy: string;
2024
2059
  };
2025
2060
 
2061
+ /**
2062
+ * @fileoverview Currency Formatting Utilities
2063
+ * @description Single mapping of ISO 4217 currency codes to locale and symbol. Top ~50 currencies.
2064
+ *
2065
+ * @version 0.0.1
2066
+ * @since 0.0.1
2067
+ * @author AMBROISE PARK Consulting
2068
+ */
2069
+ /** Entry: 3-letter code → locale (for Intl) and display symbol */
2070
+ interface CurrencyEntry {
2071
+ locale: string;
2072
+ symbol: string;
2073
+ }
2074
+ /**
2075
+ * Top ~50 currencies: 3-letter code, locale, symbol.
2076
+ * Unknown codes: getCurrencyLocale → 'en-US', getCurrencySymbol → code as-is.
2077
+ */
2078
+ declare const CURRENCY_MAP: Record<string, CurrencyEntry>;
2079
+ /**
2080
+ * Returns the locale for a currency code (for Intl formatting).
2081
+ * Unknown codes → 'en-US'.
2082
+ *
2083
+ * @param currencyCode - ISO 4217 currency code (e.g. 'EUR', 'USD')
2084
+ * @returns Locale string
2085
+ */
2086
+ declare function getCurrencyLocale(currencyCode: string): string;
2087
+ /**
2088
+ * Returns the symbol for a currency code (e.g. EUR → '€').
2089
+ * Unknown codes → code as-is (no validation).
2090
+ *
2091
+ * @param currencyCode - ISO 4217 currency code or any string
2092
+ * @returns Symbol string or the code itself
2093
+ */
2094
+ declare function getCurrencySymbol(currencyCode: string): string;
2095
+ /**
2096
+ * Format currency value with proper locale based on currency code
2097
+ *
2098
+ * @param value - Numeric value to format
2099
+ * @param currencyCode - ISO 4217 currency code
2100
+ * @param options - Additional Intl.NumberFormat options
2101
+ * @returns Formatted currency string
2102
+ *
2103
+ * @example
2104
+ * ```typescript
2105
+ * formatCurrency(12345, 'EUR') // → "12 345 €"
2106
+ * formatCurrency(12345, 'USD') // → "$12,345"
2107
+ * ```
2108
+ */
2109
+ declare function formatCurrency(value: number | null | undefined, currencyCode: string, options?: Intl.NumberFormatOptions): string;
2110
+
2026
2111
  /**
2027
2112
  * @fileoverview Partners Constants
2028
2113
  * @description Constants for partners domain. Defines partner icon mappings and partner-related constants.
@@ -4197,82 +4282,6 @@ interface DndevFrameworkConfig {
4197
4282
  /** Environment variables (VITE_* variables from .env files) */
4198
4283
  env?: Record<string, string>;
4199
4284
  }
4200
- declare global {
4201
- interface Window {
4202
- /**
4203
- * Single source of truth for all DoNotDev framework configuration
4204
- * @description Set by platform detection and populated by discovery plugins
4205
- */
4206
- _DNDEV_CONFIG_?: DndevFrameworkConfig;
4207
- /**
4208
- * Global store registry for singleton Zustand stores
4209
- * @description Ensures single instance across code-split chunks
4210
- */
4211
- _DNDEV_STORES_?: Record<string, any>;
4212
- /** PapaParse CSV parser library (external) */
4213
- Papa?: {
4214
- parse: (input: string | File, config?: any) => any;
4215
- unparse: (data: any[], config?: any) => string;
4216
- };
4217
- /** Sentry error tracking library (external) */
4218
- Sentry?: {
4219
- captureException: (error: unknown) => void;
4220
- withScope: (callback: (scope: any) => void) => void;
4221
- getClient: () => {
4222
- close: () => Promise<boolean>;
4223
- } | undefined;
4224
- };
4225
- /**
4226
- * Google APIs (Maps, One Tap, etc.)
4227
- * @description Unified type for all Google services
4228
- */
4229
- google?: {
4230
- /** Google Maps API */
4231
- maps?: {
4232
- places?: {
4233
- AutocompleteService: new () => any;
4234
- PlacesService: new (element: HTMLElement) => any;
4235
- PlacesServiceStatus: {
4236
- OK: string;
4237
- };
4238
- };
4239
- [key: string]: any;
4240
- };
4241
- /** Google Identity Services (One Tap) */
4242
- accounts?: {
4243
- id?: {
4244
- initialize: (config: any) => void;
4245
- prompt: (callback?: (notification: any) => void) => void;
4246
- cancel?: () => void;
4247
- disableAutoSelect?: () => void;
4248
- };
4249
- };
4250
- [key: string]: any;
4251
- };
4252
- /** FedCM Identity Credential API */
4253
- IdentityCredential?: any;
4254
- }
4255
- namespace NodeJS {
4256
- interface ProcessEnv {
4257
- /** Serialized framework config for Node.js environment */
4258
- _DNDEV_CONFIG_?: string;
4259
- }
4260
- }
4261
- namespace globalThis {
4262
- /** Framework configuration (same as window._DNDEV_CONFIG_) */
4263
- var _DNDEV_CONFIG_: DndevFrameworkConfig | undefined;
4264
- /** Store registry (same as window._DNDEV_STORES_) */
4265
- var _DNDEV_STORES_: Record<string, any> | undefined;
4266
- var __vite_plugin_react_preamble_installed__: boolean | undefined;
4267
- var __vite_hmr_port: number | undefined;
4268
- var __NEXT_DATA__: any | undefined;
4269
- var __REACT_QUERY_CLIENT__: any | undefined;
4270
- var __REACT_QUERY_PROVIDER__: any | undefined;
4271
- var __DNDEV_DEBUG: boolean | undefined;
4272
- var __FIREBASE_DEMO_MODE__: boolean | undefined;
4273
- var getAvailableThemes: (() => string[]) | undefined;
4274
- }
4275
- }
4276
4285
 
4277
4286
  /**
4278
4287
  * @fileoverview Billing Constants
@@ -6720,7 +6729,7 @@ declare const DEFAULT_ENTITY_ACCESS: {
6720
6729
  * @since 0.0.1
6721
6730
  * @author AMBROISE PARK Consulting
6722
6731
  */
6723
- declare const FIELD_TYPES: readonly ["address", "array", "avatar", "badge", "boolean", "checkbox", "color", "combobox", "date", "datetime-local", "document", "documents", "email", "file", "files", "gdprConsent", "geopoint", "hidden", "image", "images", "map", "month", "multiselect", "number", "password", "radio", "reference", "range", "reset", "richtext", "select", "submit", "switch", "tel", "text", "textarea", "time", "timestamp", "toggle", "url", "week", "year"];
6732
+ declare const FIELD_TYPES: readonly ["address", "array", "avatar", "badge", "boolean", "checkbox", "color", "combobox", "date", "datetime-local", "document", "documents", "email", "file", "files", "gdprConsent", "geopoint", "hidden", "image", "images", "map", "month", "multiselect", "number", "currency", "price", "password", "radio", "reference", "range", "rating", "reset", "richtext", "select", "submit", "switch", "tel", "text", "textarea", "time", "timestamp", "url", "week", "year"];
6724
6733
 
6725
6734
  /**
6726
6735
  * @fileoverview Schema-Related Type Definitions
@@ -6970,6 +6979,12 @@ type FieldTypeToValue = {
6970
6979
  month: string;
6971
6980
  multiselect: string[];
6972
6981
  number: number;
6982
+ price: {
6983
+ amount: number;
6984
+ currency?: string;
6985
+ vatIncluded?: boolean;
6986
+ discountPercent?: number;
6987
+ };
6973
6988
  password: string;
6974
6989
  radio: string;
6975
6990
  reference: string;
@@ -6982,7 +6997,6 @@ type FieldTypeToValue = {
6982
6997
  textarea: string;
6983
6998
  time: string;
6984
6999
  timestamp: string;
6985
- toggle: boolean;
6986
7000
  switch: string | boolean;
6987
7001
  url: string;
6988
7002
  week: string;
@@ -6997,6 +7011,16 @@ type FieldTypeToValue = {
6997
7011
  * @author AMBROISE PARK Consulting
6998
7012
  */
6999
7013
  type ValueTypeForField<T extends FieldType> = T extends keyof FieldTypeToValue ? FieldTypeToValue[T] : never;
7014
+ /**
7015
+ * Any valid field value - includes built-in types plus custom registered types
7016
+ * Uses `unknown` since consumers can register custom field types via RegisterFieldType
7017
+ */
7018
+ type AnyFieldValue = unknown;
7019
+ /**
7020
+ * Entity record type - a record where values are valid field values
7021
+ * Accepts unknown since consumers can register custom field types
7022
+ */
7023
+ type EntityRecord = Record<string, AnyFieldValue>;
7000
7024
  /**
7001
7025
  * Enhanced validation rules with type checking
7002
7026
  * @template T - The field type
@@ -7334,10 +7358,82 @@ interface BaseEntityFields {
7334
7358
  */
7335
7359
  status: EntityField<'select'>;
7336
7360
  }
7361
+ /**
7362
+ * Unique key constraint definition for entity deduplication
7363
+ * Enables automatic checking for duplicates on create/update operations
7364
+ *
7365
+ * @example
7366
+ * ```typescript
7367
+ * // Single field unique key with findOrCreate
7368
+ * uniqueKeys: [{ fields: ['email'], findOrCreate: true }]
7369
+ *
7370
+ * // Composite unique key
7371
+ * uniqueKeys: [{ fields: ['vin', 'make'], skipForDrafts: true }]
7372
+ *
7373
+ * // Multiple keys (OR logic - either can identify)
7374
+ * uniqueKeys: [
7375
+ * { fields: ['email'], findOrCreate: true },
7376
+ * { fields: ['phone'], findOrCreate: true }
7377
+ * ]
7378
+ * ```
7379
+ *
7380
+ * @version 0.0.1
7381
+ * @since 0.0.5
7382
+ * @author AMBROISE PARK Consulting
7383
+ */
7384
+ interface UniqueKeyDefinition {
7385
+ /** Field names that together form the unique key (single or composite) */
7386
+ fields: string[];
7387
+ /** Custom error message when duplicate is found */
7388
+ errorMessage?: string;
7389
+ /** Skip validation for draft documents (default: true) */
7390
+ skipForDrafts?: boolean;
7391
+ /**
7392
+ * Return existing document instead of throwing error on duplicate (default: false)
7393
+ * When true, create operations will return the existing document if a match is found
7394
+ */
7395
+ findOrCreate?: boolean;
7396
+ }
7397
+ /**
7398
+ * Multi-tenancy scope configuration for entities
7399
+ * Enables automatic scoping of data by tenant/company/workspace
7400
+ *
7401
+ * @example
7402
+ * ```typescript
7403
+ * const clientEntity = defineEntity({
7404
+ * name: 'Client',
7405
+ * collection: 'clients',
7406
+ * scope: { field: 'companyId', provider: 'company' },
7407
+ * fields: { ... } // No need to manually define companyId
7408
+ * });
7409
+ * ```
7410
+ *
7411
+ * @version 0.0.4
7412
+ * @since 0.0.4
7413
+ * @author AMBROISE PARK Consulting
7414
+ */
7415
+ interface ScopeConfig {
7416
+ /**
7417
+ * Field name that stores the scope ID (e.g., 'companyId', 'tenantId', 'workspaceId')
7418
+ * This field will be auto-added to the entity with type 'reference'
7419
+ */
7420
+ field: string;
7421
+ /**
7422
+ * Name of the scope provider registered with registerScopeProvider()
7423
+ * The provider function returns the current scope ID from app state
7424
+ * @example 'company', 'tenant', 'workspace'
7425
+ */
7426
+ provider: string;
7427
+ /**
7428
+ * Collection being referenced (optional, defaults to field name without 'Id' suffix + 's')
7429
+ * @example 'companies' for field 'companyId'
7430
+ */
7431
+ collection?: string;
7432
+ }
7337
7433
  /**
7338
7434
  * Definition of a business entity without base fields
7339
7435
  *
7340
- * @version 0.0.3
7436
+ * @version 0.0.4
7341
7437
  * @since 0.0.1
7342
7438
  * @author AMBROISE PARK Consulting
7343
7439
  */
@@ -7352,6 +7448,16 @@ interface BusinessEntity {
7352
7448
  * @default `entity-${name.toLowerCase()}`
7353
7449
  */
7354
7450
  namespace?: string;
7451
+ /**
7452
+ * Multi-tenancy scope configuration (optional)
7453
+ * When set, the scope field is auto-added and CRUD operations auto-inject/filter by scope
7454
+ *
7455
+ * @example
7456
+ * ```typescript
7457
+ * scope: { field: 'companyId', provider: 'company' }
7458
+ * ```
7459
+ */
7460
+ scope?: ScopeConfig;
7355
7461
  /** Field definitions - name and label are required */
7356
7462
  fields: Record<string, EntityField>;
7357
7463
  /** Form configuration for advanced forms */
@@ -7399,12 +7505,39 @@ interface BusinessEntity {
7399
7505
  * ```
7400
7506
  */
7401
7507
  access?: EntityAccessConfig;
7508
+ /**
7509
+ * Unique key constraints for deduplication
7510
+ * Checked during create/update operations
7511
+ *
7512
+ * - Single field: `[{ fields: ['email'] }]`
7513
+ * - Composite: `[{ fields: ['vin', 'make'] }]`
7514
+ * - Multiple keys (OR): `[{ fields: ['email'] }, { fields: ['phone'] }]`
7515
+ *
7516
+ * @example
7517
+ * ```typescript
7518
+ * // Customer: email OR phone identifies (findOrCreate behavior)
7519
+ * uniqueKeys: [
7520
+ * { fields: ['email'], findOrCreate: true },
7521
+ * { fields: ['phone'], findOrCreate: true }
7522
+ * ]
7523
+ *
7524
+ * // Car: VIN is unique, skip for drafts
7525
+ * uniqueKeys: [{ fields: ['vin'], skipForDrafts: true }]
7526
+ * ```
7527
+ */
7528
+ uniqueKeys?: UniqueKeyDefinition[];
7402
7529
  }
7403
7530
  /**
7404
7531
  * Complete entity definition including base fields
7405
7532
  * Created by defineEntity() which merges defaults
7406
7533
  *
7407
- * @version 0.0.2
7534
+ * Extends BusinessEntity but overrides optional properties to required:
7535
+ * - namespace: always computed (defaults to `entity-${name.toLowerCase()}`)
7536
+ * - access: always merged with defaults
7537
+ * - fields: includes base fields (id, createdAt, etc.)
7538
+ * - scope: preserved if provided (for multi-tenancy)
7539
+ *
7540
+ * @version 0.0.4
7408
7541
  * @since 0.0.1
7409
7542
  * @author AMBROISE PARK Consulting
7410
7543
  */
@@ -7415,6 +7548,8 @@ interface Entity extends BusinessEntity {
7415
7548
  access: Required<EntityAccessConfig>;
7416
7549
  /** i18n namespace for translations (always present after defineEntity, defaults to `entity-${name.toLowerCase()}`) */
7417
7550
  namespace: string;
7551
+ /** Multi-tenancy scope configuration (preserved from BusinessEntity if provided) */
7552
+ scope?: ScopeConfig;
7418
7553
  }
7419
7554
  /**
7420
7555
  * Unified metadata structure for all schemas (CRUD, Functions, etc.)
@@ -7436,6 +7571,11 @@ interface SchemaMetadata {
7436
7571
  field: string;
7437
7572
  errorMessage?: string;
7438
7573
  }>;
7574
+ /**
7575
+ * Unique key constraints from entity definition
7576
+ * Used by backend CRUD functions for deduplication
7577
+ */
7578
+ uniqueKeys?: UniqueKeyDefinition[];
7439
7579
  /** Custom validation function (for function validation) */
7440
7580
  customValidate?: (data: Record<string, any>, operation: 'create' | 'update') => Promise<void>;
7441
7581
  }
@@ -7638,6 +7778,178 @@ interface ListEntitiesResponse {
7638
7778
  hasMore: boolean;
7639
7779
  }
7640
7780
 
7781
+ /**
7782
+ * @fileoverview CRUD Component Props Types
7783
+ * @description Shared prop types for CRUD components used across UI, Templates, and CRUD packages
7784
+ *
7785
+ * @version 0.0.1
7786
+ * @since 0.0.1
7787
+ * @author AMBROISE PARK Consulting
7788
+ */
7789
+
7790
+ interface EntityListProps {
7791
+ /** The entity definition */
7792
+ entity: Entity;
7793
+ /** Current user role (for UI toggle only - backend enforces security) */
7794
+ userRole?: string;
7795
+ /**
7796
+ * Base path for view/edit/create. Default: `/${collection}`.
7797
+ * View/Edit = `${basePath}/${id}`, Create = `${basePath}/new`.
7798
+ */
7799
+ basePath?: string;
7800
+ /**
7801
+ * Called when user clicks a row. If provided, overrides default navigation to basePath/:id (e.g. open sheet).
7802
+ */
7803
+ onClick?: (id: string) => void;
7804
+ /** Hide filters section (default: false) */
7805
+ hideFilters?: boolean;
7806
+ /** Pagination mode: 'client' (default) or 'server' for massive datasets */
7807
+ pagination?: 'client' | 'server';
7808
+ /** Page size - passed to DataTable. If not provided, DataTable uses its default (12) */
7809
+ pageSize?: number;
7810
+ /** Optional query constraints (e.g. where companyId == currentCompanyId) passed to useCrudList */
7811
+ queryOptions?: {
7812
+ where?: Array<{
7813
+ field: string;
7814
+ operator: string;
7815
+ value: unknown;
7816
+ }>;
7817
+ orderBy?: Array<{
7818
+ field: string;
7819
+ direction?: 'asc' | 'desc';
7820
+ }>;
7821
+ limit?: number;
7822
+ startAfterId?: string;
7823
+ };
7824
+ }
7825
+ interface EntityCardListProps {
7826
+ /** The entity definition */
7827
+ entity: Entity;
7828
+ /**
7829
+ * Base path for view. Default: `/${collection}`. View = `${basePath}/${id}`.
7830
+ */
7831
+ basePath?: string;
7832
+ /**
7833
+ * Called when user clicks a card. If provided, overrides default navigation to basePath/:id (e.g. open sheet).
7834
+ */
7835
+ onClick?: (id: string) => void;
7836
+ /** Grid columns (responsive) - defaults to [1, 2, 3, 4] */
7837
+ cols?: number | [number, number, number, number];
7838
+ /** Cache stale time is ms - defaults to 30 mins */
7839
+ staleTime?: number;
7840
+ /** Optional filter function to filter items client-side */
7841
+ filter?: (item: any) => boolean;
7842
+ /** Hide filters section (default: false) */
7843
+ hideFilters?: boolean;
7844
+ }
7845
+ interface EntityFormRendererProps<T extends EntityRecord = EntityRecord> {
7846
+ /** Entity definition - pass the full entity from defineEntity() */
7847
+ entity: Entity;
7848
+ /** Form submission handler */
7849
+ onSubmit: (data: T) => void | Promise<void>;
7850
+ /** Translation function */
7851
+ t?: (key: string, options?: Record<string, unknown>) => string;
7852
+ /** Additional CSS classes */
7853
+ className?: string;
7854
+ /** Submit button text */
7855
+ submitText?: string;
7856
+ /**
7857
+ * Whether form data is loading (shows loading overlay)
7858
+ * Use this when fetching existing entity data for edit mode
7859
+ */
7860
+ loading?: boolean;
7861
+ /** Initial form values */
7862
+ defaultValues?: Partial<T>;
7863
+ /** Submit button variant */
7864
+ submitVariant?: 'primary' | 'destructive' | 'outline' | 'ghost' | 'link';
7865
+ /** Secondary button text */
7866
+ secondaryButtonText?: string;
7867
+ /** Secondary button variant */
7868
+ secondaryButtonVariant?: 'primary' | 'destructive' | 'outline' | 'ghost' | 'link';
7869
+ /** Secondary button submission handler */
7870
+ onSecondarySubmit?: (data: T) => void | Promise<void>;
7871
+ /**
7872
+ * Current viewer's role for editability checks
7873
+ * @default 'admin'
7874
+ */
7875
+ viewerRole?: 'public' | 'guest' | 'user' | 'admin' | 'super';
7876
+ /**
7877
+ * Form operation type
7878
+ * @default 'create' (or 'edit' if defaultValues provided)
7879
+ */
7880
+ operation?: 'create' | 'edit';
7881
+ /**
7882
+ * Enable auto-save to localStorage for crash recovery.
7883
+ * @default true for create mode
7884
+ */
7885
+ autoSave?: boolean;
7886
+ /**
7887
+ * Optional form ID for tracking loading state.
7888
+ * If not provided, one will be generated automatically.
7889
+ */
7890
+ formId?: string;
7891
+ /**
7892
+ * Cancel button text. If provided, shows a cancel button.
7893
+ * If not provided but onCancel is provided, shows default "Cancel" text.
7894
+ * Set to null to explicitly hide cancel button.
7895
+ */
7896
+ cancelText?: string | null;
7897
+ /**
7898
+ * Success path - full path to navigate after successful submit (e.g., `/products`).
7899
+ * If not provided, navigates back (optimistic - user came from list, go back there).
7900
+ */
7901
+ successPath?: string;
7902
+ /**
7903
+ * Cancel path - full path (e.g., `/products`). If not provided, navigates back.
7904
+ * If onCancel callback is provided, it takes precedence over cancelPath.
7905
+ */
7906
+ cancelPath?: string;
7907
+ /**
7908
+ * Callback when cancel is clicked (after confirmation if dirty).
7909
+ * If not provided, cancel navigates to cancelPath or `/${collection}`.
7910
+ * If provided, cancel button will show (with cancelText or default "Cancel").
7911
+ */
7912
+ onCancel?: () => void;
7913
+ /**
7914
+ * Whether to show unsaved changes warning when navigating away.
7915
+ * @default true
7916
+ */
7917
+ warnOnUnsavedChanges?: boolean;
7918
+ /**
7919
+ * Custom message for unsaved changes confirmation.
7920
+ */
7921
+ unsavedChangesMessage?: string;
7922
+ /**
7923
+ * Hide visibility indicators (badges + View As toggle).
7924
+ * When false (default), shows badge next to non-guest fields and View As role selector.
7925
+ * @default false
7926
+ */
7927
+ hideVisibilityInfo?: boolean;
7928
+ }
7929
+ interface EntityDisplayRendererProps<T extends EntityRecord = EntityRecord> {
7930
+ /** Entity definition - pass the full entity from defineEntity() */
7931
+ entity: Entity;
7932
+ /** Entity ID to fetch */
7933
+ id: string;
7934
+ /** Translation function (optional - auto-generated if not provided) */
7935
+ t?: (key: string, options?: Record<string, unknown>) => string;
7936
+ /** Additional CSS classes */
7937
+ className?: string;
7938
+ /** Backend to use */
7939
+ backend?: 'firestore' | 'functions';
7940
+ /** Custom loading message */
7941
+ loadingMessage?: string;
7942
+ /** Custom not found message */
7943
+ notFoundMessage?: string;
7944
+ /**
7945
+ * Current viewer's role for visibility checks
7946
+ * Used to determine which fields should be visible based on their visibility setting
7947
+ * If not provided, defaults to 'guest' (most restrictive - shows only public fields)
7948
+ * @default 'guest'
7949
+ */
7950
+ viewerRole?: UserRole;
7951
+ }
7952
+
7641
7953
  type FieldValues = Record<string, any>;
7642
7954
 
7643
7955
  /**
@@ -7675,13 +7987,21 @@ interface CrudAPI<T = unknown> {
7675
7987
  /** Fetch single document by ID */
7676
7988
  get: (id: string) => Promise<T | null>;
7677
7989
  /** Set/replace document by ID */
7678
- set: (id: string, data: T) => Promise<void>;
7990
+ set: (id: string, data: T, options?: {
7991
+ showSuccessToast?: boolean;
7992
+ }) => Promise<void>;
7679
7993
  /** Partial update document by ID */
7680
- update: (id: string, data: Partial<T>) => Promise<void>;
7994
+ update: (id: string, data: Partial<T>, options?: {
7995
+ showSuccessToast?: boolean;
7996
+ }) => Promise<void>;
7681
7997
  /** Delete document by ID */
7682
- delete: (id: string) => Promise<void>;
7998
+ delete: (id: string, options?: {
7999
+ showSuccessToast?: boolean;
8000
+ }) => Promise<void>;
7683
8001
  /** Add new document (auto-generated ID) */
7684
- add: (data: T) => Promise<string>;
8002
+ add: (data: T, options?: {
8003
+ showSuccessToast?: boolean;
8004
+ }) => Promise<string>;
7685
8005
  /** Query collection with filters */
7686
8006
  query: (options: any) => Promise<T[]>;
7687
8007
  /** Subscribe to document changes */
@@ -9694,8 +10014,6 @@ interface AppMetadata {
9694
10014
  name?: string;
9695
10015
  /** Short application name for mobile/compact displays (defaults to name if not set) */
9696
10016
  shortName?: string;
9697
- /** Application URL (base URL for production, defaults to localhost in development) */
9698
- url?: string;
9699
10017
  /** Application description */
9700
10018
  description?: string;
9701
10019
  /** Social and external links */
@@ -9836,7 +10154,7 @@ interface AuthConfig {
9836
10154
  interface SEOConfig {
9837
10155
  /** Enable automatic SEO (default: true) */
9838
10156
  enabled?: boolean;
9839
- /** Base URL for SEO files (robots.txt, sitemap.xml) - defaults to appConfig.app.url (set at build time) */
10157
+ /** Base URL for SEO files (robots.txt, sitemap.xml) - reads from VITE_APP_URL/NEXT_PUBLIC_APP_URL env var */
9840
10158
  baseUrl?: string;
9841
10159
  /** Site name for SEO - defaults to APP_NAME from app.ts */
9842
10160
  siteName?: string;
@@ -13301,6 +13619,8 @@ declare function parseServerCookie(cookieHeader: string | undefined, name: strin
13301
13619
  */
13302
13620
  //# sourceMappingURL=index.d.ts.map
13303
13621
 
13622
+ declare const index_d_CURRENCY_MAP: typeof CURRENCY_MAP;
13623
+ type index_d_CurrencyEntry = CurrencyEntry;
13304
13624
  declare const index_d_DEFAULT_ERROR_MESSAGES: typeof DEFAULT_ERROR_MESSAGES;
13305
13625
  type index_d_DateFormatOptions = DateFormatOptions;
13306
13626
  type index_d_DateFormatPreset = DateFormatPreset;
@@ -13325,11 +13645,14 @@ declare const index_d_createSingleton: typeof createSingleton;
13325
13645
  declare const index_d_createSingletonWithParams: typeof createSingletonWithParams;
13326
13646
  declare const index_d_detectErrorSource: typeof detectErrorSource;
13327
13647
  declare const index_d_filterVisibleFields: typeof filterVisibleFields;
13648
+ declare const index_d_formatCurrency: typeof formatCurrency;
13328
13649
  declare const index_d_formatDate: typeof formatDate;
13329
13650
  declare const index_d_formatRelativeTime: typeof formatRelativeTime;
13330
13651
  declare const index_d_generateCodeChallenge: typeof generateCodeChallenge;
13331
13652
  declare const index_d_generateCodeVerifier: typeof generateCodeVerifier;
13332
13653
  declare const index_d_generatePKCEPair: typeof generatePKCEPair;
13654
+ declare const index_d_getCurrencyLocale: typeof getCurrencyLocale;
13655
+ declare const index_d_getCurrencySymbol: typeof getCurrencySymbol;
13333
13656
  declare const index_d_getCurrentTimestamp: typeof getCurrentTimestamp;
13334
13657
  declare const index_d_getVisibleFields: typeof getVisibleFields;
13335
13658
  declare const index_d_getWeekFromISOString: typeof getWeekFromISOString;
@@ -13365,8 +13688,8 @@ declare const index_d_validateUrl: typeof validateUrl;
13365
13688
  declare const index_d_withErrorHandling: typeof withErrorHandling;
13366
13689
  declare const index_d_withGracefulDegradation: typeof withGracefulDegradation;
13367
13690
  declare namespace index_d {
13368
- export { index_d_DEFAULT_ERROR_MESSAGES as DEFAULT_ERROR_MESSAGES, index_d_DoNotDevError as DoNotDevError, index_d_SingletonManager as SingletonManager, index_d_addMonths as addMonths, index_d_addYears as addYears, index_d_calculateSubscriptionEndDate as calculateSubscriptionEndDate, index_d_captureErrorToSentry as captureErrorToSentry, index_d_commonErrorCodeMappings as commonErrorCodeMappings, index_d_compactToISOString as compactToISOString, index_d_createAsyncSingleton as createAsyncSingleton, index_d_createErrorHandler as createErrorHandler, index_d_createMetadata as createMetadata, index_d_createMethodProxy as createMethodProxy, index_d_createSingleton as createSingleton, index_d_createSingletonWithParams as createSingletonWithParams, index_d_detectErrorSource as detectErrorSource, index_d_filterVisibleFields as filterVisibleFields, index_d_formatDate as formatDate, index_d_formatRelativeTime as formatRelativeTime, index_d_generateCodeChallenge as generateCodeChallenge, index_d_generateCodeVerifier as generateCodeVerifier, index_d_generatePKCEPair as generatePKCEPair, index_d_getCurrentTimestamp as getCurrentTimestamp, index_d_getVisibleFields as getVisibleFields, index_d_getWeekFromISOString as getWeekFromISOString, index_d_handleError as handleError, index_d_hasRoleAccess as hasRoleAccess, index_d_hasTierAccess as hasTierAccess, index_d_isCompactDateString as isCompactDateString, index_d_isFieldVisible as isFieldVisible, index_d_isPKCESupported as isPKCESupported, index_d_isoToCompactString as isoToCompactString, index_d_lazyImport as lazyImport, index_d_mapToDoNotDevError as mapToDoNotDevError, index_d_maybeTranslate as maybeTranslate, index_d_normalizeToISOString as normalizeToISOString, index_d_parseDate as parseDate, index_d_parseDateToNoonUTC as parseDateToNoonUTC, index_d_parseISODate as parseISODate, index_d_parseServerCookie as parseServerCookie, index_d_showNotification as showNotification, index_d_timestampToISOString as timestampToISOString, index_d_toDateOnly as toDateOnly, index_d_toISOString as toISOString, index_d_translateArray as translateArray, index_d_translateArrayRange as translateArrayRange, index_d_translateArrayWithIndices as translateArrayWithIndices, index_d_translateObjectArray as translateObjectArray, index_d_updateMetadata as updateMetadata, index_d_validateCodeChallenge as validateCodeChallenge, index_d_validateCodeVerifier as validateCodeVerifier, index_d_validateEnvVar as validateEnvVar, index_d_validateMetadata as validateMetadata, index_d_validateUrl as validateUrl, index_d_withErrorHandling as withErrorHandling, index_d_withGracefulDegradation as withGracefulDegradation };
13369
- 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 };
13691
+ export { index_d_CURRENCY_MAP as CURRENCY_MAP, index_d_DEFAULT_ERROR_MESSAGES as DEFAULT_ERROR_MESSAGES, index_d_DoNotDevError as DoNotDevError, index_d_SingletonManager as SingletonManager, index_d_addMonths as addMonths, index_d_addYears as addYears, index_d_calculateSubscriptionEndDate as calculateSubscriptionEndDate, index_d_captureErrorToSentry as captureErrorToSentry, index_d_commonErrorCodeMappings as commonErrorCodeMappings, index_d_compactToISOString as compactToISOString, index_d_createAsyncSingleton as createAsyncSingleton, index_d_createErrorHandler as createErrorHandler, index_d_createMetadata as createMetadata, index_d_createMethodProxy as createMethodProxy, index_d_createSingleton as createSingleton, index_d_createSingletonWithParams as createSingletonWithParams, index_d_detectErrorSource as detectErrorSource, index_d_filterVisibleFields as filterVisibleFields, index_d_formatCurrency as formatCurrency, index_d_formatDate as formatDate, index_d_formatRelativeTime as formatRelativeTime, index_d_generateCodeChallenge as generateCodeChallenge, index_d_generateCodeVerifier as generateCodeVerifier, index_d_generatePKCEPair as generatePKCEPair, index_d_getCurrencyLocale as getCurrencyLocale, index_d_getCurrencySymbol as getCurrencySymbol, index_d_getCurrentTimestamp as getCurrentTimestamp, index_d_getVisibleFields as getVisibleFields, index_d_getWeekFromISOString as getWeekFromISOString, index_d_handleError as handleError, index_d_hasRoleAccess as hasRoleAccess, index_d_hasTierAccess as hasTierAccess, index_d_isCompactDateString as isCompactDateString, index_d_isFieldVisible as isFieldVisible, index_d_isPKCESupported as isPKCESupported, index_d_isoToCompactString as isoToCompactString, index_d_lazyImport as lazyImport, index_d_mapToDoNotDevError as mapToDoNotDevError, index_d_maybeTranslate as maybeTranslate, index_d_normalizeToISOString as normalizeToISOString, index_d_parseDate as parseDate, index_d_parseDateToNoonUTC as parseDateToNoonUTC, index_d_parseISODate as parseISODate, index_d_parseServerCookie as parseServerCookie, index_d_showNotification as showNotification, index_d_timestampToISOString as timestampToISOString, index_d_toDateOnly as toDateOnly, index_d_toISOString as toISOString, index_d_translateArray as translateArray, index_d_translateArrayRange as translateArrayRange, index_d_translateArrayWithIndices as translateArrayWithIndices, index_d_translateObjectArray as translateObjectArray, index_d_updateMetadata as updateMetadata, index_d_validateCodeChallenge as validateCodeChallenge, index_d_validateCodeVerifier as validateCodeVerifier, index_d_validateEnvVar as validateEnvVar, index_d_validateMetadata as validateMetadata, index_d_validateUrl as validateUrl, index_d_withErrorHandling as withErrorHandling, index_d_withGracefulDegradation as withGracefulDegradation };
13692
+ export type { index_d_CurrencyEntry as CurrencyEntry, 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 };
13370
13693
  }
13371
13694
 
13372
13695
  /**
@@ -13478,6 +13801,34 @@ declare function getRegisteredSchemaTypes(): string[];
13478
13801
  * Clear all schema generators (testing)
13479
13802
  */
13480
13803
  declare function clearSchemaGenerators(): void;
13804
+ /**
13805
+ * Schema generators exported for unified registry
13806
+ * These are also auto-registered below for backward compatibility
13807
+ */
13808
+ declare const textSchema: CustomSchemaGenerator;
13809
+ declare const emailSchema: CustomSchemaGenerator;
13810
+ declare const passwordSchema: CustomSchemaGenerator;
13811
+ declare const urlSchema: CustomSchemaGenerator;
13812
+ declare const numberSchema: CustomSchemaGenerator;
13813
+ declare const booleanSchema: CustomSchemaGenerator;
13814
+ declare const dateSchema: CustomSchemaGenerator;
13815
+ declare const fileSchema: CustomSchemaGenerator;
13816
+ declare const filesSchema: CustomSchemaGenerator;
13817
+ declare const pictureSchema: CustomSchemaGenerator;
13818
+ declare const picturesSchema: CustomSchemaGenerator;
13819
+ declare const geopointSchema: CustomSchemaGenerator;
13820
+ declare const addressSchema: CustomSchemaGenerator;
13821
+ declare const mapSchema: CustomSchemaGenerator;
13822
+ declare const arraySchema: CustomSchemaGenerator;
13823
+ declare const selectSchema: CustomSchemaGenerator;
13824
+ declare const multiselectSchema: CustomSchemaGenerator;
13825
+ declare const referenceSchema: CustomSchemaGenerator;
13826
+ declare const stringSchema: CustomSchemaGenerator;
13827
+ declare const telSchema: CustomSchemaGenerator;
13828
+ declare const neverSchema: CustomSchemaGenerator;
13829
+ declare const switchSchema: CustomSchemaGenerator;
13830
+ declare const gdprConsentSchema: CustomSchemaGenerator;
13831
+ declare const priceSchema: CustomSchemaGenerator;
13481
13832
  /**
13482
13833
  * Get Valibot schema for an entity field
13483
13834
  *
@@ -13863,5 +14214,130 @@ interface SelectOption {
13863
14214
  */
13864
14215
  declare function rangeOptions(start: number, end: number, step?: number, descending?: boolean): SelectOption[];
13865
14216
 
13866
- 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, rangeOptions, 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 };
13867
- 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, 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, 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, SelectOption, 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 };
14217
+ /**
14218
+ * @fileoverview Scope Provider Registry for Multi-Tenancy
14219
+ * @description Global registry for scope providers that supply tenant/company/workspace IDs
14220
+ * to CRUD operations. Apps register providers once, entities declare which provider to use.
14221
+ *
14222
+ * @example
14223
+ * ```typescript
14224
+ * // 1. App registers scope provider (once, at startup)
14225
+ * import { registerScopeProvider } from '@donotdev/core';
14226
+ * import { useCurrentCompanyStore } from './stores/currentCompanyStore';
14227
+ *
14228
+ * registerScopeProvider('company', () =>
14229
+ * useCurrentCompanyStore.getState().currentCompanyId
14230
+ * );
14231
+ *
14232
+ * // 2. Entity declares scope
14233
+ * const clientEntity = defineEntity({
14234
+ * name: 'Client',
14235
+ * collection: 'clients',
14236
+ * scope: { field: 'companyId', provider: 'company' },
14237
+ * fields: { ... }
14238
+ * });
14239
+ *
14240
+ * // 3. CRUD operations auto-inject/filter by scope (transparent)
14241
+ * const { add } = useCrud(clientEntity);
14242
+ * await add({ name: 'Acme' }); // companyId auto-injected
14243
+ * ```
14244
+ *
14245
+ * @version 0.0.4
14246
+ * @since 0.0.4
14247
+ * @author AMBROISE PARK Consulting
14248
+ */
14249
+ /**
14250
+ * Function that returns the current scope ID from app state
14251
+ * Returns null if no scope is currently selected (e.g., no company selected)
14252
+ */
14253
+ type ScopeProviderFn = () => string | null;
14254
+ /**
14255
+ * Register a scope provider function
14256
+ *
14257
+ * Call this once at app startup to register scope providers.
14258
+ * The provider function should return the current scope ID from your app's state.
14259
+ *
14260
+ * @param name - Provider name (e.g., 'company', 'tenant', 'workspace')
14261
+ * @param provider - Function that returns the current scope ID
14262
+ *
14263
+ * @example
14264
+ * ```typescript
14265
+ * // Using Zustand store
14266
+ * registerScopeProvider('company', () =>
14267
+ * useCurrentCompanyStore.getState().currentCompanyId
14268
+ * );
14269
+ *
14270
+ * // Using React context (via ref)
14271
+ * const companyIdRef = { current: null };
14272
+ * registerScopeProvider('company', () => companyIdRef.current);
14273
+ * // Update ref in your context provider
14274
+ * ```
14275
+ *
14276
+ * @version 0.0.4
14277
+ * @since 0.0.4
14278
+ * @author AMBROISE PARK Consulting
14279
+ */
14280
+ declare function registerScopeProvider(name: string, provider: ScopeProviderFn): void;
14281
+ /**
14282
+ * Unregister a scope provider (for testing or cleanup)
14283
+ *
14284
+ * @param name - Provider name to unregister
14285
+ *
14286
+ * @version 0.0.4
14287
+ * @since 0.0.4
14288
+ * @author AMBROISE PARK Consulting
14289
+ */
14290
+ declare function unregisterScopeProvider(name: string): void;
14291
+ /**
14292
+ * Get the current scope value from a registered provider
14293
+ *
14294
+ * Used internally by CRUD operations to inject/filter by scope.
14295
+ *
14296
+ * @param providerName - Name of the registered provider
14297
+ * @returns Current scope ID, or null if not available
14298
+ *
14299
+ * @example
14300
+ * ```typescript
14301
+ * const companyId = getScopeValue('company');
14302
+ * if (!companyId) {
14303
+ * throw new Error('No company selected');
14304
+ * }
14305
+ * ```
14306
+ *
14307
+ * @version 0.0.4
14308
+ * @since 0.0.4
14309
+ * @author AMBROISE PARK Consulting
14310
+ */
14311
+ declare function getScopeValue(providerName: string): string | null;
14312
+ /**
14313
+ * Check if a scope provider is registered
14314
+ *
14315
+ * @param providerName - Name of the provider to check
14316
+ * @returns True if provider is registered
14317
+ *
14318
+ * @version 0.0.4
14319
+ * @since 0.0.4
14320
+ * @author AMBROISE PARK Consulting
14321
+ */
14322
+ declare function hasScopeProvider(providerName: string): boolean;
14323
+ /**
14324
+ * Get all registered scope provider names (for debugging)
14325
+ *
14326
+ * @returns Array of registered provider names
14327
+ *
14328
+ * @version 0.0.4
14329
+ * @since 0.0.4
14330
+ * @author AMBROISE PARK Consulting
14331
+ */
14332
+ declare function getRegisteredScopeProviders(): string[];
14333
+ /**
14334
+ * Clear all scope providers (for testing)
14335
+ *
14336
+ * @version 0.0.4
14337
+ * @since 0.0.4
14338
+ * @author AMBROISE PARK Consulting
14339
+ */
14340
+ declare function clearScopeProviders(): void;
14341
+
14342
+ 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, CURRENCY_MAP, 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, addressSchema, arraySchema, baseFields, booleanSchema, calculateSubscriptionEndDate, captureErrorToSentry, checkGitHubAccessSchema, clearSchemaGenerators, clearScopeProviders, commonErrorCodeMappings, compactToISOString, createAsyncSingleton, createDefaultSubscriptionClaims, createDefaultUserProfile, createEntitySchema, createErrorHandler, createMetadata, createMethodProxy, createSchemas, createSingleton, createSingletonWithParams, dateSchema, defineEntity, deleteEntitySchema, detectErrorSource, disconnectOAuthSchema, emailSchema, enhanceSchema, exchangeTokenSchema, fileSchema, filesSchema, filterVisibleFields, formatCurrency, formatDate, formatRelativeTime, gdprConsentSchema, generateCodeChallenge, generateCodeVerifier, generatePKCEPair, geopointSchema, getBreakpointFromWidth, getBreakpointUtils, getCollectionName, getConnectionsSchema, getCurrencyLocale, getCurrencySymbol, getCurrentTimestamp, getEntitySchema, getRegisteredSchemaTypes, getRegisteredScopeProviders, getSchemaType, getScopeValue, getVisibleFields, getWeekFromISOString, githubPermissionSchema, githubRepoConfigSchema, grantGitHubAccessSchema, handleError, hasCustomSchemaGenerator, hasMetadata, hasRoleAccess, hasScopeProvider, hasTierAccess, isAuthPartnerId, isBackendGeneratedField, isBreakpoint, isCompactDateString, isFieldVisible, isFrameworkField, isOAuthPartnerId, isPKCESupported, isoToCompactString, lazyImport, listEntitiesSchema, mapSchema, mapToDoNotDevError, maybeTranslate, multiselectSchema, neverSchema, normalizeToISOString, numberSchema, overrideFeatures, overridePaymentModes, overridePermissions, overrideSubscriptionStatus, overrideSubscriptionTiers, overrideUserRoles, parseDate, parseDateToNoonUTC, parseISODate, parseServerCookie, passwordSchema, pictureSchema, picturesSchema, priceSchema, rangeOptions, referenceSchema, refreshTokenSchema, registerSchemaGenerator, registerScopeProvider, registerUniqueConstraintValidator, revokeGitHubAccessSchema, selectSchema, showNotification, stringSchema, switchSchema, telSchema, textSchema, timestampToISOString, toDateOnly, toISOString, translateArray, translateArrayRange, translateArrayWithIndices, translateObjectArray, unregisterScopeProvider, updateEntitySchema, updateMetadata, urlSchema, 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 };
14343
+ export type { AccountLinkResult, AccountLinkingInfo, AdminCheckHookResult, AdminClaims, AggregateConfig, AggregateFilterOperator, AggregateOperation, AggregateRequest, AggregateResponse, AnyFieldValue, 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, CurrencyEntry, CustomClaims, CustomSchemaGenerator, CustomStoreConfig, DateFormatOptions, DateFormatPreset, DateValue, DeleteEntityRequest, DeleteEntityResponse, Density, DnDevOverride, DndevFrameworkConfig, DoNotDevCookieCategories, DynamicFormRule, Editable, EffectiveConnectionType, EmailVerificationHookResult, EmailVerificationStatus, Entity, EntityAccessConfig, EntityAccessDefaults, EntityCardListProps, EntityDisplayRendererProps, EntityField, EntityFormRendererProps, EntityHookErrors, EntityListProps, EntityMetadata, EntityRecord, 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, 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, ScopeConfig, ScopeProviderFn, SelectOption, 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, UniqueKeyDefinition, UnsubscribeFn, UpdateEntityData, UpdateEntityRequest, UpdateEntityResponse, UseFunctionsMutationOptions, UseFunctionsQueryOptions, UseTranslationOptionsEnhanced, UserContext, UserProfile, UserProviderData, UserRole, UserSubscription, ValidationRules, ValueTypeForField, Visibility, WebhookEvent, WebhookEventData, WhereClause, WhereOperator, WithMetadata, dndevSchema };