@donotdev/core 0.0.18 → 0.0.20
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/functions/index.d.ts +1 -1448
- package/i18n/locales/lazy/crud_ar.json +34 -0
- package/i18n/locales/lazy/crud_de.json +34 -0
- package/i18n/locales/lazy/crud_en.json +34 -0
- package/i18n/locales/lazy/crud_es.json +34 -0
- package/i18n/locales/lazy/crud_fr.json +34 -0
- package/i18n/locales/lazy/crud_it.json +34 -0
- package/i18n/locales/lazy/crud_ja.json +34 -0
- package/i18n/locales/lazy/crud_ko.json +34 -0
- package/index.d.ts +757 -134
- package/index.js +46 -46
- package/next/index.d.ts +15 -777
- package/next/index.js +15 -15
- package/package.json +10 -10
- package/server.d.ts +712 -130
- package/server.js +1 -1
- package/vite/index.d.ts +17 -779
- package/vite/index.js +29 -29
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
|
-
:
|
|
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
|
-
|
|
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
|
|
@@ -6669,7 +6678,7 @@ interface AggregateResponse {
|
|
|
6669
6678
|
/**
|
|
6670
6679
|
* Visibility levels for entity fields (runtime constants)
|
|
6671
6680
|
* Controls who can SEE this field in responses
|
|
6672
|
-
* Matches USER_ROLES hierarchy + technical + hidden
|
|
6681
|
+
* Matches USER_ROLES hierarchy + technical + hidden + owner
|
|
6673
6682
|
*
|
|
6674
6683
|
* - guest: Everyone (even unauthenticated)
|
|
6675
6684
|
* - user: Authenticated users (users see guest + user fields)
|
|
@@ -6677,6 +6686,7 @@ interface AggregateResponse {
|
|
|
6677
6686
|
* - super: Super admins only (see all non-technical fields)
|
|
6678
6687
|
* - technical: System fields (shown as read-only in edit forms, admins+ only)
|
|
6679
6688
|
* - hidden: Never exposed to client (passwords, tokens, API keys)
|
|
6689
|
+
* - owner: Visible only when request.auth.uid matches one of entity.ownership.ownerFields on the document
|
|
6680
6690
|
*/
|
|
6681
6691
|
declare const VISIBILITY: {
|
|
6682
6692
|
readonly GUEST: "guest";
|
|
@@ -6685,6 +6695,7 @@ declare const VISIBILITY: {
|
|
|
6685
6695
|
readonly SUPER: "super";
|
|
6686
6696
|
readonly TECHNICAL: "technical";
|
|
6687
6697
|
readonly HIDDEN: "hidden";
|
|
6698
|
+
readonly OWNER: "owner";
|
|
6688
6699
|
};
|
|
6689
6700
|
/**
|
|
6690
6701
|
* Editable levels for entity fields (runtime constants)
|
|
@@ -6720,7 +6731,7 @@ declare const DEFAULT_ENTITY_ACCESS: {
|
|
|
6720
6731
|
* @since 0.0.1
|
|
6721
6732
|
* @author AMBROISE PARK Consulting
|
|
6722
6733
|
*/
|
|
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", "
|
|
6734
|
+
declare const FIELD_TYPES: readonly ["address", "array", "avatar", "badge", "boolean", "checkbox", "color", "combobox", "date", "datetime-local", "document", "documents", "duration", "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
6735
|
|
|
6725
6736
|
/**
|
|
6726
6737
|
* @fileoverview Schema-Related Type Definitions
|
|
@@ -6797,6 +6808,37 @@ interface EntityAccessConfig {
|
|
|
6797
6808
|
}
|
|
6798
6809
|
/** Type derived from DEFAULT_ENTITY_ACCESS for type safety */
|
|
6799
6810
|
type EntityAccessDefaults = typeof DEFAULT_ENTITY_ACCESS;
|
|
6811
|
+
/**
|
|
6812
|
+
* Single condition for public read/update in Firestore rules.
|
|
6813
|
+
* Joined with && when publicCondition is an array.
|
|
6814
|
+
*/
|
|
6815
|
+
interface EntityOwnershipPublicCondition {
|
|
6816
|
+
field: string;
|
|
6817
|
+
op: string;
|
|
6818
|
+
value: string | boolean | number;
|
|
6819
|
+
}
|
|
6820
|
+
/**
|
|
6821
|
+
* Ownership configuration for stakeholder access (marketplace-style entities).
|
|
6822
|
+
* When set, drives Firestore rule condition generation, list/listCard query constraints,
|
|
6823
|
+
* and visibility: 'owner' field masking.
|
|
6824
|
+
*
|
|
6825
|
+
* @example
|
|
6826
|
+
* ```typescript
|
|
6827
|
+
* ownership: {
|
|
6828
|
+
* ownerFields: ['providerId', 'customerId'],
|
|
6829
|
+
* publicCondition: [
|
|
6830
|
+
* { field: 'status', op: '==', value: 'available' },
|
|
6831
|
+
* { field: 'isApproved', op: '==', value: true },
|
|
6832
|
+
* ],
|
|
6833
|
+
* }
|
|
6834
|
+
* ```
|
|
6835
|
+
*/
|
|
6836
|
+
interface EntityOwnershipConfig {
|
|
6837
|
+
/** Document fields whose value is a user id (e.g. providerId, customerId) */
|
|
6838
|
+
ownerFields: string[];
|
|
6839
|
+
/** Conditions joined with && for "public" read (e.g. status == 'available') */
|
|
6840
|
+
publicCondition?: EntityOwnershipPublicCondition[];
|
|
6841
|
+
}
|
|
6800
6842
|
/**
|
|
6801
6843
|
* Supported field types for entities
|
|
6802
6844
|
* These determine the UI components and validation rules used for each field
|
|
@@ -6970,6 +7012,12 @@ type FieldTypeToValue = {
|
|
|
6970
7012
|
month: string;
|
|
6971
7013
|
multiselect: string[];
|
|
6972
7014
|
number: number;
|
|
7015
|
+
price: {
|
|
7016
|
+
amount: number;
|
|
7017
|
+
currency?: string;
|
|
7018
|
+
vatIncluded?: boolean;
|
|
7019
|
+
discountPercent?: number;
|
|
7020
|
+
};
|
|
6973
7021
|
password: string;
|
|
6974
7022
|
radio: string;
|
|
6975
7023
|
reference: string;
|
|
@@ -6982,7 +7030,6 @@ type FieldTypeToValue = {
|
|
|
6982
7030
|
textarea: string;
|
|
6983
7031
|
time: string;
|
|
6984
7032
|
timestamp: string;
|
|
6985
|
-
toggle: boolean;
|
|
6986
7033
|
switch: string | boolean;
|
|
6987
7034
|
url: string;
|
|
6988
7035
|
week: string;
|
|
@@ -6997,6 +7044,16 @@ type FieldTypeToValue = {
|
|
|
6997
7044
|
* @author AMBROISE PARK Consulting
|
|
6998
7045
|
*/
|
|
6999
7046
|
type ValueTypeForField<T extends FieldType> = T extends keyof FieldTypeToValue ? FieldTypeToValue[T] : never;
|
|
7047
|
+
/**
|
|
7048
|
+
* Any valid field value - includes built-in types plus custom registered types
|
|
7049
|
+
* Uses `unknown` since consumers can register custom field types via RegisterFieldType
|
|
7050
|
+
*/
|
|
7051
|
+
type AnyFieldValue = unknown;
|
|
7052
|
+
/**
|
|
7053
|
+
* Entity record type - a record where values are valid field values
|
|
7054
|
+
* Accepts unknown since consumers can register custom field types
|
|
7055
|
+
*/
|
|
7056
|
+
type EntityRecord = Record<string, AnyFieldValue>;
|
|
7000
7057
|
/**
|
|
7001
7058
|
* Enhanced validation rules with type checking
|
|
7002
7059
|
* @template T - The field type
|
|
@@ -7334,10 +7391,82 @@ interface BaseEntityFields {
|
|
|
7334
7391
|
*/
|
|
7335
7392
|
status: EntityField<'select'>;
|
|
7336
7393
|
}
|
|
7394
|
+
/**
|
|
7395
|
+
* Unique key constraint definition for entity deduplication
|
|
7396
|
+
* Enables automatic checking for duplicates on create/update operations
|
|
7397
|
+
*
|
|
7398
|
+
* @example
|
|
7399
|
+
* ```typescript
|
|
7400
|
+
* // Single field unique key with findOrCreate
|
|
7401
|
+
* uniqueKeys: [{ fields: ['email'], findOrCreate: true }]
|
|
7402
|
+
*
|
|
7403
|
+
* // Composite unique key
|
|
7404
|
+
* uniqueKeys: [{ fields: ['vin', 'make'], skipForDrafts: true }]
|
|
7405
|
+
*
|
|
7406
|
+
* // Multiple keys (OR logic - either can identify)
|
|
7407
|
+
* uniqueKeys: [
|
|
7408
|
+
* { fields: ['email'], findOrCreate: true },
|
|
7409
|
+
* { fields: ['phone'], findOrCreate: true }
|
|
7410
|
+
* ]
|
|
7411
|
+
* ```
|
|
7412
|
+
*
|
|
7413
|
+
* @version 0.0.1
|
|
7414
|
+
* @since 0.0.5
|
|
7415
|
+
* @author AMBROISE PARK Consulting
|
|
7416
|
+
*/
|
|
7417
|
+
interface UniqueKeyDefinition {
|
|
7418
|
+
/** Field names that together form the unique key (single or composite) */
|
|
7419
|
+
fields: string[];
|
|
7420
|
+
/** Custom error message when duplicate is found */
|
|
7421
|
+
errorMessage?: string;
|
|
7422
|
+
/** Skip validation for draft documents (default: true) */
|
|
7423
|
+
skipForDrafts?: boolean;
|
|
7424
|
+
/**
|
|
7425
|
+
* Return existing document instead of throwing error on duplicate (default: false)
|
|
7426
|
+
* When true, create operations will return the existing document if a match is found
|
|
7427
|
+
*/
|
|
7428
|
+
findOrCreate?: boolean;
|
|
7429
|
+
}
|
|
7430
|
+
/**
|
|
7431
|
+
* Multi-tenancy scope configuration for entities
|
|
7432
|
+
* Enables automatic scoping of data by tenant/company/workspace
|
|
7433
|
+
*
|
|
7434
|
+
* @example
|
|
7435
|
+
* ```typescript
|
|
7436
|
+
* const clientEntity = defineEntity({
|
|
7437
|
+
* name: 'Client',
|
|
7438
|
+
* collection: 'clients',
|
|
7439
|
+
* scope: { field: 'companyId', provider: 'company' },
|
|
7440
|
+
* fields: { ... } // No need to manually define companyId
|
|
7441
|
+
* });
|
|
7442
|
+
* ```
|
|
7443
|
+
*
|
|
7444
|
+
* @version 0.0.4
|
|
7445
|
+
* @since 0.0.4
|
|
7446
|
+
* @author AMBROISE PARK Consulting
|
|
7447
|
+
*/
|
|
7448
|
+
interface ScopeConfig {
|
|
7449
|
+
/**
|
|
7450
|
+
* Field name that stores the scope ID (e.g., 'companyId', 'tenantId', 'workspaceId')
|
|
7451
|
+
* This field will be auto-added to the entity with type 'reference'
|
|
7452
|
+
*/
|
|
7453
|
+
field: string;
|
|
7454
|
+
/**
|
|
7455
|
+
* Name of the scope provider registered with registerScopeProvider()
|
|
7456
|
+
* The provider function returns the current scope ID from app state
|
|
7457
|
+
* @example 'company', 'tenant', 'workspace'
|
|
7458
|
+
*/
|
|
7459
|
+
provider: string;
|
|
7460
|
+
/**
|
|
7461
|
+
* Collection being referenced (optional, defaults to field name without 'Id' suffix + 's')
|
|
7462
|
+
* @example 'companies' for field 'companyId'
|
|
7463
|
+
*/
|
|
7464
|
+
collection?: string;
|
|
7465
|
+
}
|
|
7337
7466
|
/**
|
|
7338
7467
|
* Definition of a business entity without base fields
|
|
7339
7468
|
*
|
|
7340
|
-
* @version 0.0.
|
|
7469
|
+
* @version 0.0.4
|
|
7341
7470
|
* @since 0.0.1
|
|
7342
7471
|
* @author AMBROISE PARK Consulting
|
|
7343
7472
|
*/
|
|
@@ -7352,6 +7481,31 @@ interface BusinessEntity {
|
|
|
7352
7481
|
* @default `entity-${name.toLowerCase()}`
|
|
7353
7482
|
*/
|
|
7354
7483
|
namespace?: string;
|
|
7484
|
+
/**
|
|
7485
|
+
* Multi-tenancy scope configuration (optional)
|
|
7486
|
+
* When set, the scope field is auto-added and CRUD operations auto-inject/filter by scope
|
|
7487
|
+
*
|
|
7488
|
+
* @example
|
|
7489
|
+
* ```typescript
|
|
7490
|
+
* scope: { field: 'companyId', provider: 'company' }
|
|
7491
|
+
* ```
|
|
7492
|
+
*/
|
|
7493
|
+
scope?: ScopeConfig;
|
|
7494
|
+
/**
|
|
7495
|
+
* Stakeholder ownership configuration (optional).
|
|
7496
|
+
* When set, drives Firestore rule condition (read/update), list/listCard query constraints,
|
|
7497
|
+
* and visibility: 'owner' field masking. Use for marketplace-style entities (e.g. schedules:
|
|
7498
|
+
* public when available, private to partner/customer when booked).
|
|
7499
|
+
*
|
|
7500
|
+
* @example
|
|
7501
|
+
* ```typescript
|
|
7502
|
+
* ownership: {
|
|
7503
|
+
* ownerFields: ['providerId', 'customerId'],
|
|
7504
|
+
* publicCondition: [{ field: 'status', op: '==', value: 'available' }],
|
|
7505
|
+
* }
|
|
7506
|
+
* ```
|
|
7507
|
+
*/
|
|
7508
|
+
ownership?: EntityOwnershipConfig;
|
|
7355
7509
|
/** Field definitions - name and label are required */
|
|
7356
7510
|
fields: Record<string, EntityField>;
|
|
7357
7511
|
/** Form configuration for advanced forms */
|
|
@@ -7399,12 +7553,39 @@ interface BusinessEntity {
|
|
|
7399
7553
|
* ```
|
|
7400
7554
|
*/
|
|
7401
7555
|
access?: EntityAccessConfig;
|
|
7556
|
+
/**
|
|
7557
|
+
* Unique key constraints for deduplication
|
|
7558
|
+
* Checked during create/update operations
|
|
7559
|
+
*
|
|
7560
|
+
* - Single field: `[{ fields: ['email'] }]`
|
|
7561
|
+
* - Composite: `[{ fields: ['vin', 'make'] }]`
|
|
7562
|
+
* - Multiple keys (OR): `[{ fields: ['email'] }, { fields: ['phone'] }]`
|
|
7563
|
+
*
|
|
7564
|
+
* @example
|
|
7565
|
+
* ```typescript
|
|
7566
|
+
* // Customer: email OR phone identifies (findOrCreate behavior)
|
|
7567
|
+
* uniqueKeys: [
|
|
7568
|
+
* { fields: ['email'], findOrCreate: true },
|
|
7569
|
+
* { fields: ['phone'], findOrCreate: true }
|
|
7570
|
+
* ]
|
|
7571
|
+
*
|
|
7572
|
+
* // Car: VIN is unique, skip for drafts
|
|
7573
|
+
* uniqueKeys: [{ fields: ['vin'], skipForDrafts: true }]
|
|
7574
|
+
* ```
|
|
7575
|
+
*/
|
|
7576
|
+
uniqueKeys?: UniqueKeyDefinition[];
|
|
7402
7577
|
}
|
|
7403
7578
|
/**
|
|
7404
7579
|
* Complete entity definition including base fields
|
|
7405
7580
|
* Created by defineEntity() which merges defaults
|
|
7406
7581
|
*
|
|
7407
|
-
*
|
|
7582
|
+
* Extends BusinessEntity but overrides optional properties to required:
|
|
7583
|
+
* - namespace: always computed (defaults to `entity-${name.toLowerCase()}`)
|
|
7584
|
+
* - access: always merged with defaults
|
|
7585
|
+
* - fields: includes base fields (id, createdAt, etc.)
|
|
7586
|
+
* - scope: preserved if provided (for multi-tenancy)
|
|
7587
|
+
*
|
|
7588
|
+
* @version 0.0.4
|
|
7408
7589
|
* @since 0.0.1
|
|
7409
7590
|
* @author AMBROISE PARK Consulting
|
|
7410
7591
|
*/
|
|
@@ -7415,6 +7596,8 @@ interface Entity extends BusinessEntity {
|
|
|
7415
7596
|
access: Required<EntityAccessConfig>;
|
|
7416
7597
|
/** i18n namespace for translations (always present after defineEntity, defaults to `entity-${name.toLowerCase()}`) */
|
|
7417
7598
|
namespace: string;
|
|
7599
|
+
/** Multi-tenancy scope configuration (preserved from BusinessEntity if provided) */
|
|
7600
|
+
scope?: ScopeConfig;
|
|
7418
7601
|
}
|
|
7419
7602
|
/**
|
|
7420
7603
|
* Unified metadata structure for all schemas (CRUD, Functions, etc.)
|
|
@@ -7436,6 +7619,11 @@ interface SchemaMetadata {
|
|
|
7436
7619
|
field: string;
|
|
7437
7620
|
errorMessage?: string;
|
|
7438
7621
|
}>;
|
|
7622
|
+
/**
|
|
7623
|
+
* Unique key constraints from entity definition
|
|
7624
|
+
* Used by backend CRUD functions for deduplication
|
|
7625
|
+
*/
|
|
7626
|
+
uniqueKeys?: UniqueKeyDefinition[];
|
|
7439
7627
|
/** Custom validation function (for function validation) */
|
|
7440
7628
|
customValidate?: (data: Record<string, any>, operation: 'create' | 'update') => Promise<void>;
|
|
7441
7629
|
}
|
|
@@ -7638,6 +7826,179 @@ interface ListEntitiesResponse {
|
|
|
7638
7826
|
hasMore: boolean;
|
|
7639
7827
|
}
|
|
7640
7828
|
|
|
7829
|
+
/**
|
|
7830
|
+
* @fileoverview CRUD Component Props Types
|
|
7831
|
+
* @description Shared prop types for CRUD components used across UI, Templates, and CRUD packages
|
|
7832
|
+
*
|
|
7833
|
+
* @version 0.0.1
|
|
7834
|
+
* @since 0.0.1
|
|
7835
|
+
* @author AMBROISE PARK Consulting
|
|
7836
|
+
*/
|
|
7837
|
+
|
|
7838
|
+
interface EntityListProps {
|
|
7839
|
+
/** The entity definition */
|
|
7840
|
+
entity: Entity;
|
|
7841
|
+
/** Current user role (for UI toggle only - backend enforces security) */
|
|
7842
|
+
userRole?: string;
|
|
7843
|
+
/**
|
|
7844
|
+
* Base path for view/edit/create. Default: `/${collection}`.
|
|
7845
|
+
* View/Edit = `${basePath}/${id}`, Create = `${basePath}/new`.
|
|
7846
|
+
*/
|
|
7847
|
+
basePath?: string;
|
|
7848
|
+
/**
|
|
7849
|
+
* Called when user clicks a row. If provided, overrides default navigation to basePath/:id (e.g. open sheet).
|
|
7850
|
+
*/
|
|
7851
|
+
onClick?: (id: string) => void;
|
|
7852
|
+
/** Hide filters section (default: false) */
|
|
7853
|
+
hideFilters?: boolean;
|
|
7854
|
+
/** Pagination mode: 'client' (default) or 'server' for massive datasets */
|
|
7855
|
+
pagination?: 'client' | 'server';
|
|
7856
|
+
/** Page size - passed to DataTable. If not provided, DataTable uses its default (12) */
|
|
7857
|
+
pageSize?: number;
|
|
7858
|
+
/** Optional query constraints (e.g. where companyId == currentCompanyId) passed to useCrudList */
|
|
7859
|
+
queryOptions?: {
|
|
7860
|
+
where?: Array<{
|
|
7861
|
+
field: string;
|
|
7862
|
+
operator: string;
|
|
7863
|
+
value: unknown;
|
|
7864
|
+
}>;
|
|
7865
|
+
orderBy?: Array<{
|
|
7866
|
+
field: string;
|
|
7867
|
+
direction?: 'asc' | 'desc';
|
|
7868
|
+
}>;
|
|
7869
|
+
limit?: number;
|
|
7870
|
+
startAfterId?: string;
|
|
7871
|
+
};
|
|
7872
|
+
}
|
|
7873
|
+
interface EntityCardListProps {
|
|
7874
|
+
/** The entity definition */
|
|
7875
|
+
entity: Entity;
|
|
7876
|
+
/**
|
|
7877
|
+
* Base path for view. Default: `/${collection}`. View = `${basePath}/${id}`.
|
|
7878
|
+
*/
|
|
7879
|
+
basePath?: string;
|
|
7880
|
+
/**
|
|
7881
|
+
* Called when user clicks a card. If provided, overrides default navigation to basePath/:id (e.g. open sheet).
|
|
7882
|
+
*/
|
|
7883
|
+
onClick?: (id: string) => void;
|
|
7884
|
+
/** Grid columns (responsive) - defaults to [1, 2, 3, 4] */
|
|
7885
|
+
cols?: number | [number, number, number, number];
|
|
7886
|
+
/** Cache stale time is ms - defaults to 30 mins */
|
|
7887
|
+
staleTime?: number;
|
|
7888
|
+
/** Optional filter function to filter items client-side */
|
|
7889
|
+
filter?: (item: any) => boolean;
|
|
7890
|
+
/** Hide filters section (default: false) */
|
|
7891
|
+
hideFilters?: boolean;
|
|
7892
|
+
}
|
|
7893
|
+
interface EntityFormRendererProps<T extends EntityRecord = EntityRecord> {
|
|
7894
|
+
/** Entity definition - pass the full entity from defineEntity() */
|
|
7895
|
+
entity: Entity;
|
|
7896
|
+
/** Form submission handler */
|
|
7897
|
+
onSubmit: (data: T) => void | Promise<void>;
|
|
7898
|
+
/** Translation function */
|
|
7899
|
+
t?: (key: string, options?: Record<string, unknown>) => string;
|
|
7900
|
+
/** Additional CSS classes */
|
|
7901
|
+
className?: string;
|
|
7902
|
+
/** Submit button text */
|
|
7903
|
+
submitText?: string;
|
|
7904
|
+
/**
|
|
7905
|
+
* Whether form data is loading (shows loading overlay)
|
|
7906
|
+
* Use this when fetching existing entity data for edit mode
|
|
7907
|
+
*/
|
|
7908
|
+
loading?: boolean;
|
|
7909
|
+
/** Initial form values */
|
|
7910
|
+
defaultValues?: Partial<T>;
|
|
7911
|
+
/** Submit button variant */
|
|
7912
|
+
submitVariant?: 'primary' | 'destructive' | 'outline' | 'ghost' | 'link';
|
|
7913
|
+
/** Secondary button text */
|
|
7914
|
+
secondaryButtonText?: string;
|
|
7915
|
+
/** Secondary button variant */
|
|
7916
|
+
secondaryButtonVariant?: 'primary' | 'destructive' | 'outline' | 'ghost' | 'link';
|
|
7917
|
+
/** Secondary button submission handler */
|
|
7918
|
+
onSecondarySubmit?: (data: T) => void | Promise<void>;
|
|
7919
|
+
/**
|
|
7920
|
+
* Current viewer's role for editability checks
|
|
7921
|
+
* If not provided, defaults to 'guest' (most restrictive)
|
|
7922
|
+
* @default 'guest'
|
|
7923
|
+
*/
|
|
7924
|
+
viewerRole?: string;
|
|
7925
|
+
/**
|
|
7926
|
+
* Form operation type
|
|
7927
|
+
* @default 'create' (or 'edit' if defaultValues provided)
|
|
7928
|
+
*/
|
|
7929
|
+
operation?: 'create' | 'edit';
|
|
7930
|
+
/**
|
|
7931
|
+
* Enable auto-save to localStorage for crash recovery.
|
|
7932
|
+
* @default true for create mode
|
|
7933
|
+
*/
|
|
7934
|
+
autoSave?: boolean;
|
|
7935
|
+
/**
|
|
7936
|
+
* Optional form ID for tracking loading state.
|
|
7937
|
+
* If not provided, one will be generated automatically.
|
|
7938
|
+
*/
|
|
7939
|
+
formId?: string;
|
|
7940
|
+
/**
|
|
7941
|
+
* Cancel button text. If provided, shows a cancel button.
|
|
7942
|
+
* If not provided but onCancel is provided, shows default "Cancel" text.
|
|
7943
|
+
* Set to null to explicitly hide cancel button.
|
|
7944
|
+
*/
|
|
7945
|
+
cancelText?: string | null;
|
|
7946
|
+
/**
|
|
7947
|
+
* Success path - full path to navigate after successful submit (e.g., `/products`).
|
|
7948
|
+
* If not provided, navigates back (optimistic - user came from list, go back there).
|
|
7949
|
+
*/
|
|
7950
|
+
successPath?: string;
|
|
7951
|
+
/**
|
|
7952
|
+
* Cancel path - full path (e.g., `/products`). If not provided, navigates back.
|
|
7953
|
+
* If onCancel callback is provided, it takes precedence over cancelPath.
|
|
7954
|
+
*/
|
|
7955
|
+
cancelPath?: string;
|
|
7956
|
+
/**
|
|
7957
|
+
* Callback when cancel is clicked (after confirmation if dirty).
|
|
7958
|
+
* If not provided, cancel navigates to cancelPath or `/${collection}`.
|
|
7959
|
+
* If provided, cancel button will show (with cancelText or default "Cancel").
|
|
7960
|
+
*/
|
|
7961
|
+
onCancel?: () => void;
|
|
7962
|
+
/**
|
|
7963
|
+
* Whether to show unsaved changes warning when navigating away.
|
|
7964
|
+
* @default true
|
|
7965
|
+
*/
|
|
7966
|
+
warnOnUnsavedChanges?: boolean;
|
|
7967
|
+
/**
|
|
7968
|
+
* Custom message for unsaved changes confirmation.
|
|
7969
|
+
*/
|
|
7970
|
+
unsavedChangesMessage?: string;
|
|
7971
|
+
/**
|
|
7972
|
+
* Hide visibility indicators (badges + View As toggle).
|
|
7973
|
+
* When false (default), shows badge next to non-guest fields and View As role selector.
|
|
7974
|
+
* @default false
|
|
7975
|
+
*/
|
|
7976
|
+
hideVisibilityInfo?: boolean;
|
|
7977
|
+
}
|
|
7978
|
+
interface EntityDisplayRendererProps<T extends EntityRecord = EntityRecord> {
|
|
7979
|
+
/** Entity definition - pass the full entity from defineEntity() */
|
|
7980
|
+
entity: Entity;
|
|
7981
|
+
/** Entity ID to fetch */
|
|
7982
|
+
id: string;
|
|
7983
|
+
/** Translation function (optional - auto-generated if not provided) */
|
|
7984
|
+
t?: (key: string, options?: Record<string, unknown>) => string;
|
|
7985
|
+
/** Additional CSS classes */
|
|
7986
|
+
className?: string;
|
|
7987
|
+
/** Backend to use */
|
|
7988
|
+
backend?: 'firestore' | 'functions';
|
|
7989
|
+
/** Custom loading message */
|
|
7990
|
+
loadingMessage?: string;
|
|
7991
|
+
/** Custom not found message */
|
|
7992
|
+
notFoundMessage?: string;
|
|
7993
|
+
/**
|
|
7994
|
+
* Current viewer's role for visibility checks
|
|
7995
|
+
* Used to determine which fields should be visible based on their visibility setting
|
|
7996
|
+
* If not provided, defaults to 'guest' (most restrictive - shows only public fields)
|
|
7997
|
+
* @default 'guest'
|
|
7998
|
+
*/
|
|
7999
|
+
viewerRole?: string;
|
|
8000
|
+
}
|
|
8001
|
+
|
|
7641
8002
|
type FieldValues = Record<string, any>;
|
|
7642
8003
|
|
|
7643
8004
|
/**
|
|
@@ -7675,13 +8036,21 @@ interface CrudAPI<T = unknown> {
|
|
|
7675
8036
|
/** Fetch single document by ID */
|
|
7676
8037
|
get: (id: string) => Promise<T | null>;
|
|
7677
8038
|
/** Set/replace document by ID */
|
|
7678
|
-
set: (id: string, data: T
|
|
8039
|
+
set: (id: string, data: T, options?: {
|
|
8040
|
+
showSuccessToast?: boolean;
|
|
8041
|
+
}) => Promise<void>;
|
|
7679
8042
|
/** Partial update document by ID */
|
|
7680
|
-
update: (id: string, data: Partial<T
|
|
8043
|
+
update: (id: string, data: Partial<T>, options?: {
|
|
8044
|
+
showSuccessToast?: boolean;
|
|
8045
|
+
}) => Promise<void>;
|
|
7681
8046
|
/** Delete document by ID */
|
|
7682
|
-
delete: (id: string
|
|
8047
|
+
delete: (id: string, options?: {
|
|
8048
|
+
showSuccessToast?: boolean;
|
|
8049
|
+
}) => Promise<void>;
|
|
7683
8050
|
/** Add new document (auto-generated ID) */
|
|
7684
|
-
add: (data: T
|
|
8051
|
+
add: (data: T, options?: {
|
|
8052
|
+
showSuccessToast?: boolean;
|
|
8053
|
+
}) => Promise<string>;
|
|
7685
8054
|
/** Query collection with filters */
|
|
7686
8055
|
query: (options: any) => Promise<T[]>;
|
|
7687
8056
|
/** Subscribe to document changes */
|
|
@@ -9694,8 +10063,6 @@ interface AppMetadata {
|
|
|
9694
10063
|
name?: string;
|
|
9695
10064
|
/** Short application name for mobile/compact displays (defaults to name if not set) */
|
|
9696
10065
|
shortName?: string;
|
|
9697
|
-
/** Application URL (base URL for production, defaults to localhost in development) */
|
|
9698
|
-
url?: string;
|
|
9699
10066
|
/** Application description */
|
|
9700
10067
|
description?: string;
|
|
9701
10068
|
/** Social and external links */
|
|
@@ -9836,7 +10203,7 @@ interface AuthConfig {
|
|
|
9836
10203
|
interface SEOConfig {
|
|
9837
10204
|
/** Enable automatic SEO (default: true) */
|
|
9838
10205
|
enabled?: boolean;
|
|
9839
|
-
/** Base URL for SEO files (robots.txt, sitemap.xml) -
|
|
10206
|
+
/** Base URL for SEO files (robots.txt, sitemap.xml) - reads from VITE_APP_URL/NEXT_PUBLIC_APP_URL env var */
|
|
9840
10207
|
baseUrl?: string;
|
|
9841
10208
|
/** Site name for SEO - defaults to APP_NAME from app.ts */
|
|
9842
10209
|
siteName?: string;
|
|
@@ -12581,6 +12948,29 @@ declare function createErrorHandler(config: ErrorHandlerConfig): ErrorHandlerFun
|
|
|
12581
12948
|
*/
|
|
12582
12949
|
declare const commonErrorCodeMappings: Record<string, ErrorCode>;
|
|
12583
12950
|
|
|
12951
|
+
/**
|
|
12952
|
+
* @fileoverview Firestore rule condition generator for stakeholder ownership
|
|
12953
|
+
* @description Given EntityOwnershipConfig, returns a rule condition string suitable for
|
|
12954
|
+
* allow read and allow update. Use the same condition for both (owners can read and update).
|
|
12955
|
+
*
|
|
12956
|
+
* @version 0.0.1
|
|
12957
|
+
* @since 0.0.1
|
|
12958
|
+
* @author AMBROISE PARK Consulting
|
|
12959
|
+
*/
|
|
12960
|
+
|
|
12961
|
+
/**
|
|
12962
|
+
* Generates a Firestore rule condition for read and update based on ownership config.
|
|
12963
|
+
* Use the returned string in firestore.rules like:
|
|
12964
|
+
*
|
|
12965
|
+
* allow read, update: if <generated>;
|
|
12966
|
+
*
|
|
12967
|
+
* The condition is: (publicCondition AND ...) OR request.auth.uid == resource.data.<ownerField1> OR ...
|
|
12968
|
+
*
|
|
12969
|
+
* @param ownership - Entity ownership config (ownerFields + optional publicCondition array)
|
|
12970
|
+
* @returns Rule condition expression string
|
|
12971
|
+
*/
|
|
12972
|
+
declare function generateFirestoreRuleCondition(ownership: EntityOwnershipConfig): string;
|
|
12973
|
+
|
|
12584
12974
|
/**
|
|
12585
12975
|
* @fileoverview Smart translation helper
|
|
12586
12976
|
* @description Auto-detects translation keys vs raw strings
|
|
@@ -12829,6 +13219,18 @@ declare function lazyImport<T>(importFn: () => Promise<T>, cacheKey: string): Pr
|
|
|
12829
13219
|
|
|
12830
13220
|
*/
|
|
12831
13221
|
declare function hasRoleAccess(userRole: string | undefined, requiredRole: string): boolean;
|
|
13222
|
+
/**
|
|
13223
|
+
* Extract canonical role from auth claims
|
|
13224
|
+
*
|
|
13225
|
+
* Handles:
|
|
13226
|
+
* - 'role' claim (primary)
|
|
13227
|
+
* - Boolean flags (isAdmin, isSuper) (legacy/convenience)
|
|
13228
|
+
* - Fallbacks to USER_ROLES.USER
|
|
13229
|
+
*
|
|
13230
|
+
* @param claims - Auth claims object
|
|
13231
|
+
* @returns Canonical role string
|
|
13232
|
+
*/
|
|
13233
|
+
declare function getRoleFromClaims(claims: Record<string, any>): string;
|
|
12832
13234
|
|
|
12833
13235
|
/**
|
|
12834
13236
|
|
|
@@ -13095,38 +13497,6 @@ declare function updateMetadata(userId: string): {
|
|
|
13095
13497
|
_updatedBy: string;
|
|
13096
13498
|
};
|
|
13097
13499
|
|
|
13098
|
-
/**
|
|
13099
|
-
* @fileoverview Field visibility filter utility
|
|
13100
|
-
* @description Filters document fields based on visibility and user role using a Valibot schema.
|
|
13101
|
-
*
|
|
13102
|
-
* Uses 6-level hierarchical visibility system:
|
|
13103
|
-
*
|
|
13104
|
-
* Hierarchy: guest < user < admin < super
|
|
13105
|
-
*
|
|
13106
|
-
* - `guest`: Everyone (including unauthenticated)
|
|
13107
|
-
* - `user`: Authenticated users (see guest + user)
|
|
13108
|
-
* - `admin`: Admins (see guest + user + admin)
|
|
13109
|
-
* - `super`: Super admins (see guest + user + admin + super)
|
|
13110
|
-
* - `technical`: System fields (admins+ only, read-only in forms)
|
|
13111
|
-
* - `hidden`: Never exposed to client
|
|
13112
|
-
*
|
|
13113
|
-
* @version 0.0.3
|
|
13114
|
-
* @since 0.0.1
|
|
13115
|
-
* @author AMBROISE PARK Consulting
|
|
13116
|
-
*/
|
|
13117
|
-
|
|
13118
|
-
/**
|
|
13119
|
-
* Filters the fields of a data object based on visibility rules defined
|
|
13120
|
-
* in a Valibot schema and the user's role.
|
|
13121
|
-
*
|
|
13122
|
-
* @template T - The expected type of the data object
|
|
13123
|
-
* @param data - The document data object to filter
|
|
13124
|
-
* @param schema - The Valibot schema with visibility metadata on each field
|
|
13125
|
-
* @param userRole - The current user's role (guest, user, admin, super)
|
|
13126
|
-
* @returns A new object containing only the fields visible to the user
|
|
13127
|
-
*/
|
|
13128
|
-
declare function filterVisibleFields<T extends Record<string, any>>(data: T | null | undefined, schema: v.BaseSchema<unknown, any, v.BaseIssue<unknown>> | dndevSchema<any>, userRole: UserRole): Partial<T>;
|
|
13129
|
-
|
|
13130
13500
|
/**
|
|
13131
13501
|
* @fileoverview Field visibility utility
|
|
13132
13502
|
* @description Extracts visible field names from a Valibot schema based on user role.
|
|
@@ -13141,8 +13511,9 @@ declare function filterVisibleFields<T extends Record<string, any>>(data: T | nu
|
|
|
13141
13511
|
* - `super`: Super admins (see guest + user + admin + super)
|
|
13142
13512
|
* - `technical`: System fields (admins+ only, read-only in forms)
|
|
13143
13513
|
* - `hidden`: Never exposed to client
|
|
13514
|
+
* - `owner`: Visible only when request.auth.uid matches one of entity.ownership.ownerFields on the document (requires options)
|
|
13144
13515
|
*
|
|
13145
|
-
* @version 0.0.
|
|
13516
|
+
* @version 0.0.5
|
|
13146
13517
|
* @since 0.0.1
|
|
13147
13518
|
* @author AMBROISE PARK Consulting
|
|
13148
13519
|
*/
|
|
@@ -13164,15 +13535,64 @@ declare function filterVisibleFields<T extends Record<string, any>>(data: T | nu
|
|
|
13164
13535
|
* @returns True if the field should be visible
|
|
13165
13536
|
*/
|
|
13166
13537
|
declare function isFieldVisible(visibility: Visibility | undefined, userRole: UserRole): boolean;
|
|
13538
|
+
/**
|
|
13539
|
+
* Options for owner-level visibility (per-document check).
|
|
13540
|
+
*/
|
|
13541
|
+
interface GetVisibleFieldsOptions {
|
|
13542
|
+
documentData?: Record<string, unknown>;
|
|
13543
|
+
uid?: string;
|
|
13544
|
+
ownership?: EntityOwnershipConfig;
|
|
13545
|
+
}
|
|
13167
13546
|
/**
|
|
13168
13547
|
* Extracts the names of all fields from a Valibot object schema that should be visible
|
|
13169
|
-
* based on the user's role.
|
|
13548
|
+
* based on the user's role and optional ownership context (for visibility: 'owner').
|
|
13170
13549
|
*
|
|
13171
13550
|
* @param schema - The Valibot schema, expected to be an object schema (v.object)
|
|
13172
13551
|
* @param userRole - The current user's role (guest, user, admin, super)
|
|
13552
|
+
* @param options - Optional: documentData, uid, ownership for owner-level visibility
|
|
13173
13553
|
* @returns An array of visible field names
|
|
13174
13554
|
*/
|
|
13175
|
-
declare function getVisibleFields(schema: v.BaseSchema<unknown, any, v.BaseIssue<unknown>> | dndevSchema<any>, userRole: UserRole): string[];
|
|
13555
|
+
declare function getVisibleFields(schema: v.BaseSchema<unknown, any, v.BaseIssue<unknown>> | dndevSchema<any>, userRole: UserRole, options?: GetVisibleFieldsOptions): string[];
|
|
13556
|
+
|
|
13557
|
+
/**
|
|
13558
|
+
* @fileoverview Field visibility filter utility
|
|
13559
|
+
* @description Filters document fields based on visibility and user role using a Valibot schema.
|
|
13560
|
+
*
|
|
13561
|
+
* Uses 6-level hierarchical visibility system:
|
|
13562
|
+
*
|
|
13563
|
+
* Hierarchy: guest < user < admin < super
|
|
13564
|
+
*
|
|
13565
|
+
* - `guest`: Everyone (including unauthenticated)
|
|
13566
|
+
* - `user`: Authenticated users (see guest + user)
|
|
13567
|
+
* - `admin`: Admins (see guest + user + admin)
|
|
13568
|
+
* - `super`: Super admins (see guest + user + admin + super)
|
|
13569
|
+
* - `technical`: System fields (admins+ only, read-only in forms)
|
|
13570
|
+
* - `hidden`: Never exposed to client
|
|
13571
|
+
*
|
|
13572
|
+
* @version 0.0.3
|
|
13573
|
+
* @since 0.0.1
|
|
13574
|
+
* @author AMBROISE PARK Consulting
|
|
13575
|
+
*/
|
|
13576
|
+
|
|
13577
|
+
/**
|
|
13578
|
+
* Options for owner-level visibility (per-document check).
|
|
13579
|
+
* Pass documentData, uid, and ownership so fields with visibility: 'owner' are included when uid matches an owner field.
|
|
13580
|
+
*/
|
|
13581
|
+
type FilterVisibleFieldsOptions = GetVisibleFieldsOptions;
|
|
13582
|
+
/**
|
|
13583
|
+
* Filters the fields of a data object based on visibility rules defined
|
|
13584
|
+
* in a Valibot schema and the user's role. When options (documentData, uid, ownership)
|
|
13585
|
+
* are provided, fields with visibility: 'owner' are included only if uid matches
|
|
13586
|
+
* one of ownership.ownerFields in documentData.
|
|
13587
|
+
*
|
|
13588
|
+
* @template T - The expected type of the data object
|
|
13589
|
+
* @param data - The document data object to filter
|
|
13590
|
+
* @param schema - The Valibot schema with visibility metadata on each field
|
|
13591
|
+
* @param userRole - The current user's role (guest, user, admin, super)
|
|
13592
|
+
* @param options - Optional: documentData, uid, ownership for owner-level visibility
|
|
13593
|
+
* @returns A new object containing only the fields visible to the user
|
|
13594
|
+
*/
|
|
13595
|
+
declare function filterVisibleFields<T extends Record<string, any>>(data: T | null | undefined, schema: v.BaseSchema<unknown, any, v.BaseIssue<unknown>> | dndevSchema<any>, userRole: UserRole, options?: FilterVisibleFieldsOptions): Partial<T>;
|
|
13176
13596
|
|
|
13177
13597
|
/**
|
|
13178
13598
|
* @fileoverview Server-side date utilities
|
|
@@ -13301,6 +13721,8 @@ declare function parseServerCookie(cookieHeader: string | undefined, name: strin
|
|
|
13301
13721
|
*/
|
|
13302
13722
|
//# sourceMappingURL=index.d.ts.map
|
|
13303
13723
|
|
|
13724
|
+
declare const index_d_CURRENCY_MAP: typeof CURRENCY_MAP;
|
|
13725
|
+
type index_d_CurrencyEntry = CurrencyEntry;
|
|
13304
13726
|
declare const index_d_DEFAULT_ERROR_MESSAGES: typeof DEFAULT_ERROR_MESSAGES;
|
|
13305
13727
|
type index_d_DateFormatOptions = DateFormatOptions;
|
|
13306
13728
|
type index_d_DateFormatPreset = DateFormatPreset;
|
|
@@ -13308,6 +13730,8 @@ type index_d_DoNotDevError = DoNotDevError;
|
|
|
13308
13730
|
declare const index_d_DoNotDevError: typeof DoNotDevError;
|
|
13309
13731
|
type index_d_ErrorHandlerConfig = ErrorHandlerConfig;
|
|
13310
13732
|
type index_d_ErrorHandlerFunction = ErrorHandlerFunction;
|
|
13733
|
+
type index_d_FilterVisibleFieldsOptions = FilterVisibleFieldsOptions;
|
|
13734
|
+
type index_d_GetVisibleFieldsOptions = GetVisibleFieldsOptions;
|
|
13311
13735
|
type index_d_HandleErrorOptions = HandleErrorOptions;
|
|
13312
13736
|
type index_d_SingletonManager = SingletonManager;
|
|
13313
13737
|
declare const index_d_SingletonManager: typeof SingletonManager;
|
|
@@ -13325,12 +13749,17 @@ declare const index_d_createSingleton: typeof createSingleton;
|
|
|
13325
13749
|
declare const index_d_createSingletonWithParams: typeof createSingletonWithParams;
|
|
13326
13750
|
declare const index_d_detectErrorSource: typeof detectErrorSource;
|
|
13327
13751
|
declare const index_d_filterVisibleFields: typeof filterVisibleFields;
|
|
13752
|
+
declare const index_d_formatCurrency: typeof formatCurrency;
|
|
13328
13753
|
declare const index_d_formatDate: typeof formatDate;
|
|
13329
13754
|
declare const index_d_formatRelativeTime: typeof formatRelativeTime;
|
|
13330
13755
|
declare const index_d_generateCodeChallenge: typeof generateCodeChallenge;
|
|
13331
13756
|
declare const index_d_generateCodeVerifier: typeof generateCodeVerifier;
|
|
13757
|
+
declare const index_d_generateFirestoreRuleCondition: typeof generateFirestoreRuleCondition;
|
|
13332
13758
|
declare const index_d_generatePKCEPair: typeof generatePKCEPair;
|
|
13759
|
+
declare const index_d_getCurrencyLocale: typeof getCurrencyLocale;
|
|
13760
|
+
declare const index_d_getCurrencySymbol: typeof getCurrencySymbol;
|
|
13333
13761
|
declare const index_d_getCurrentTimestamp: typeof getCurrentTimestamp;
|
|
13762
|
+
declare const index_d_getRoleFromClaims: typeof getRoleFromClaims;
|
|
13334
13763
|
declare const index_d_getVisibleFields: typeof getVisibleFields;
|
|
13335
13764
|
declare const index_d_getWeekFromISOString: typeof getWeekFromISOString;
|
|
13336
13765
|
declare const index_d_handleError: typeof handleError;
|
|
@@ -13365,8 +13794,8 @@ declare const index_d_validateUrl: typeof validateUrl;
|
|
|
13365
13794
|
declare const index_d_withErrorHandling: typeof withErrorHandling;
|
|
13366
13795
|
declare const index_d_withGracefulDegradation: typeof withGracefulDegradation;
|
|
13367
13796
|
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 };
|
|
13797
|
+
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_generateFirestoreRuleCondition as generateFirestoreRuleCondition, index_d_generatePKCEPair as generatePKCEPair, index_d_getCurrencyLocale as getCurrencyLocale, index_d_getCurrencySymbol as getCurrencySymbol, index_d_getCurrentTimestamp as getCurrentTimestamp, index_d_getRoleFromClaims as getRoleFromClaims, 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 };
|
|
13798
|
+
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_FilterVisibleFieldsOptions as FilterVisibleFieldsOptions, index_d_GetVisibleFieldsOptions as GetVisibleFieldsOptions, index_d_HandleErrorOptions as HandleErrorOptions };
|
|
13370
13799
|
}
|
|
13371
13800
|
|
|
13372
13801
|
/**
|
|
@@ -13478,6 +13907,34 @@ declare function getRegisteredSchemaTypes(): string[];
|
|
|
13478
13907
|
* Clear all schema generators (testing)
|
|
13479
13908
|
*/
|
|
13480
13909
|
declare function clearSchemaGenerators(): void;
|
|
13910
|
+
/**
|
|
13911
|
+
* Schema generators exported for unified registry
|
|
13912
|
+
* These are also auto-registered below for backward compatibility
|
|
13913
|
+
*/
|
|
13914
|
+
declare const textSchema: CustomSchemaGenerator;
|
|
13915
|
+
declare const emailSchema: CustomSchemaGenerator;
|
|
13916
|
+
declare const passwordSchema: CustomSchemaGenerator;
|
|
13917
|
+
declare const urlSchema: CustomSchemaGenerator;
|
|
13918
|
+
declare const numberSchema: CustomSchemaGenerator;
|
|
13919
|
+
declare const booleanSchema: CustomSchemaGenerator;
|
|
13920
|
+
declare const dateSchema: CustomSchemaGenerator;
|
|
13921
|
+
declare const fileSchema: CustomSchemaGenerator;
|
|
13922
|
+
declare const filesSchema: CustomSchemaGenerator;
|
|
13923
|
+
declare const pictureSchema: CustomSchemaGenerator;
|
|
13924
|
+
declare const picturesSchema: CustomSchemaGenerator;
|
|
13925
|
+
declare const geopointSchema: CustomSchemaGenerator;
|
|
13926
|
+
declare const addressSchema: CustomSchemaGenerator;
|
|
13927
|
+
declare const mapSchema: CustomSchemaGenerator;
|
|
13928
|
+
declare const arraySchema: CustomSchemaGenerator;
|
|
13929
|
+
declare const selectSchema: CustomSchemaGenerator;
|
|
13930
|
+
declare const multiselectSchema: CustomSchemaGenerator;
|
|
13931
|
+
declare const referenceSchema: CustomSchemaGenerator;
|
|
13932
|
+
declare const stringSchema: CustomSchemaGenerator;
|
|
13933
|
+
declare const telSchema: CustomSchemaGenerator;
|
|
13934
|
+
declare const neverSchema: CustomSchemaGenerator;
|
|
13935
|
+
declare const switchSchema: CustomSchemaGenerator;
|
|
13936
|
+
declare const gdprConsentSchema: CustomSchemaGenerator;
|
|
13937
|
+
declare const priceSchema: CustomSchemaGenerator;
|
|
13481
13938
|
/**
|
|
13482
13939
|
* Get Valibot schema for an entity field
|
|
13483
13940
|
*
|
|
@@ -13863,5 +14320,130 @@ interface SelectOption {
|
|
|
13863
14320
|
*/
|
|
13864
14321
|
declare function rangeOptions(start: number, end: number, step?: number, descending?: boolean): SelectOption[];
|
|
13865
14322
|
|
|
13866
|
-
|
|
13867
|
-
|
|
14323
|
+
/**
|
|
14324
|
+
* @fileoverview Scope Provider Registry for Multi-Tenancy
|
|
14325
|
+
* @description Global registry for scope providers that supply tenant/company/workspace IDs
|
|
14326
|
+
* to CRUD operations. Apps register providers once, entities declare which provider to use.
|
|
14327
|
+
*
|
|
14328
|
+
* @example
|
|
14329
|
+
* ```typescript
|
|
14330
|
+
* // 1. App registers scope provider (once, at startup)
|
|
14331
|
+
* import { registerScopeProvider } from '@donotdev/core';
|
|
14332
|
+
* import { useCurrentCompanyStore } from './stores/currentCompanyStore';
|
|
14333
|
+
*
|
|
14334
|
+
* registerScopeProvider('company', () =>
|
|
14335
|
+
* useCurrentCompanyStore.getState().currentCompanyId
|
|
14336
|
+
* );
|
|
14337
|
+
*
|
|
14338
|
+
* // 2. Entity declares scope
|
|
14339
|
+
* const clientEntity = defineEntity({
|
|
14340
|
+
* name: 'Client',
|
|
14341
|
+
* collection: 'clients',
|
|
14342
|
+
* scope: { field: 'companyId', provider: 'company' },
|
|
14343
|
+
* fields: { ... }
|
|
14344
|
+
* });
|
|
14345
|
+
*
|
|
14346
|
+
* // 3. CRUD operations auto-inject/filter by scope (transparent)
|
|
14347
|
+
* const { add } = useCrud(clientEntity);
|
|
14348
|
+
* await add({ name: 'Acme' }); // companyId auto-injected
|
|
14349
|
+
* ```
|
|
14350
|
+
*
|
|
14351
|
+
* @version 0.0.4
|
|
14352
|
+
* @since 0.0.4
|
|
14353
|
+
* @author AMBROISE PARK Consulting
|
|
14354
|
+
*/
|
|
14355
|
+
/**
|
|
14356
|
+
* Function that returns the current scope ID from app state
|
|
14357
|
+
* Returns null if no scope is currently selected (e.g., no company selected)
|
|
14358
|
+
*/
|
|
14359
|
+
type ScopeProviderFn = () => string | null;
|
|
14360
|
+
/**
|
|
14361
|
+
* Register a scope provider function
|
|
14362
|
+
*
|
|
14363
|
+
* Call this once at app startup to register scope providers.
|
|
14364
|
+
* The provider function should return the current scope ID from your app's state.
|
|
14365
|
+
*
|
|
14366
|
+
* @param name - Provider name (e.g., 'company', 'tenant', 'workspace')
|
|
14367
|
+
* @param provider - Function that returns the current scope ID
|
|
14368
|
+
*
|
|
14369
|
+
* @example
|
|
14370
|
+
* ```typescript
|
|
14371
|
+
* // Using Zustand store
|
|
14372
|
+
* registerScopeProvider('company', () =>
|
|
14373
|
+
* useCurrentCompanyStore.getState().currentCompanyId
|
|
14374
|
+
* );
|
|
14375
|
+
*
|
|
14376
|
+
* // Using React context (via ref)
|
|
14377
|
+
* const companyIdRef = { current: null };
|
|
14378
|
+
* registerScopeProvider('company', () => companyIdRef.current);
|
|
14379
|
+
* // Update ref in your context provider
|
|
14380
|
+
* ```
|
|
14381
|
+
*
|
|
14382
|
+
* @version 0.0.4
|
|
14383
|
+
* @since 0.0.4
|
|
14384
|
+
* @author AMBROISE PARK Consulting
|
|
14385
|
+
*/
|
|
14386
|
+
declare function registerScopeProvider(name: string, provider: ScopeProviderFn): void;
|
|
14387
|
+
/**
|
|
14388
|
+
* Unregister a scope provider (for testing or cleanup)
|
|
14389
|
+
*
|
|
14390
|
+
* @param name - Provider name to unregister
|
|
14391
|
+
*
|
|
14392
|
+
* @version 0.0.4
|
|
14393
|
+
* @since 0.0.4
|
|
14394
|
+
* @author AMBROISE PARK Consulting
|
|
14395
|
+
*/
|
|
14396
|
+
declare function unregisterScopeProvider(name: string): void;
|
|
14397
|
+
/**
|
|
14398
|
+
* Get the current scope value from a registered provider
|
|
14399
|
+
*
|
|
14400
|
+
* Used internally by CRUD operations to inject/filter by scope.
|
|
14401
|
+
*
|
|
14402
|
+
* @param providerName - Name of the registered provider
|
|
14403
|
+
* @returns Current scope ID, or null if not available
|
|
14404
|
+
*
|
|
14405
|
+
* @example
|
|
14406
|
+
* ```typescript
|
|
14407
|
+
* const companyId = getScopeValue('company');
|
|
14408
|
+
* if (!companyId) {
|
|
14409
|
+
* throw new Error('No company selected');
|
|
14410
|
+
* }
|
|
14411
|
+
* ```
|
|
14412
|
+
*
|
|
14413
|
+
* @version 0.0.4
|
|
14414
|
+
* @since 0.0.4
|
|
14415
|
+
* @author AMBROISE PARK Consulting
|
|
14416
|
+
*/
|
|
14417
|
+
declare function getScopeValue(providerName: string): string | null;
|
|
14418
|
+
/**
|
|
14419
|
+
* Check if a scope provider is registered
|
|
14420
|
+
*
|
|
14421
|
+
* @param providerName - Name of the provider to check
|
|
14422
|
+
* @returns True if provider is registered
|
|
14423
|
+
*
|
|
14424
|
+
* @version 0.0.4
|
|
14425
|
+
* @since 0.0.4
|
|
14426
|
+
* @author AMBROISE PARK Consulting
|
|
14427
|
+
*/
|
|
14428
|
+
declare function hasScopeProvider(providerName: string): boolean;
|
|
14429
|
+
/**
|
|
14430
|
+
* Get all registered scope provider names (for debugging)
|
|
14431
|
+
*
|
|
14432
|
+
* @returns Array of registered provider names
|
|
14433
|
+
*
|
|
14434
|
+
* @version 0.0.4
|
|
14435
|
+
* @since 0.0.4
|
|
14436
|
+
* @author AMBROISE PARK Consulting
|
|
14437
|
+
*/
|
|
14438
|
+
declare function getRegisteredScopeProviders(): string[];
|
|
14439
|
+
/**
|
|
14440
|
+
* Clear all scope providers (for testing)
|
|
14441
|
+
*
|
|
14442
|
+
* @version 0.0.4
|
|
14443
|
+
* @since 0.0.4
|
|
14444
|
+
* @author AMBROISE PARK Consulting
|
|
14445
|
+
*/
|
|
14446
|
+
declare function clearScopeProviders(): void;
|
|
14447
|
+
|
|
14448
|
+
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, generateFirestoreRuleCondition, generatePKCEPair, geopointSchema, getBreakpointFromWidth, getBreakpointUtils, getCollectionName, getConnectionsSchema, getCurrencyLocale, getCurrencySymbol, getCurrentTimestamp, getEntitySchema, getRegisteredSchemaTypes, getRegisteredScopeProviders, getRoleFromClaims, 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 };
|
|
14449
|
+
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, EntityOwnershipConfig, EntityOwnershipPublicCondition, 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, FilterVisibleFieldsOptions, 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, GetVisibleFieldsOptions, 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 };
|