@asaidimu/anansi 1.6.6 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (6) hide show
  1. package/README.md +750 -65
  2. package/index.cjs +13 -13
  3. package/index.d.cts +733 -164
  4. package/index.d.ts +733 -164
  5. package/index.js +14 -14
  6. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as _faker_js_faker from '@faker-js/faker';
2
2
  import { Faker } from '@faker-js/faker';
3
- import { QueryDSL, QueryFilter } from '@asaidimu/query';
3
+ import { LogicalOperator, QueryDSL, QueryFilter } from '@asaidimu/query';
4
4
  import { StandardSchemaV1 } from '@standard-schema/spec';
5
5
  import LightningFS from '@isomorphic-git/lightning-fs';
6
6
  import { FieldValues, ResolverOptions, ResolverResult } from 'react-hook-form';
@@ -172,10 +172,6 @@ type SchemaHint = {
172
172
  groups?: GroupDefinition[];
173
173
  };
174
174
 
175
- /**
176
- * Logical operators for combining constraints or index conditions.
177
- */
178
- type LogicalOperator = "and" | "or" | "not" | "nor" | "xor";
179
175
  /**
180
176
  * Basic field types supported by the schema system.
181
177
  */
@@ -415,73 +411,195 @@ interface IndexDefinition {
415
411
  name: string;
416
412
  }
417
413
  /**
418
- * Represents a nested schema definition embedded within a parent schema.
419
- * Unlike SchemaDefinition, this can use a discriminated array of field sets for variant-specific fields,
420
- * but only when concrete is false. This restriction avoids complexity in RDBMS implementations,
421
- * where concrete schemas map directly to tables with fixed columns. Non-concrete schemas, as embedded
422
- * structures, can leverage this flexibility without affecting physical table design.
414
+ * Defines a reusable nested schema structure.
415
+ * This can represent either a complex object with defined fields, or a direct primitive literal (string, number, boolean).
416
+ * Nested schemas are stored in the `nestedSchemas` map of a `SchemaDefinition` and referenced by their `id`.
417
+ * They facilitate schema reusability, modularity, and the definition of polymorphic structures.
418
+ *
419
+ * @template T - The TypeScript type this schema represents. When `literal` is `true`, this `T`
420
+ * corresponds to the actual primitive type (e.g., `string`, `number`).
421
+ * When `literal` is `false`, `T` is typically an object type.
423
422
  *
424
423
  * @example
424
+ * // Example of a concrete, object-based nested schema (like a fixed address structure)
425
425
  * ```typescript
426
426
  * const addressSchema: NestedSchemaDefinition = {
427
- * name: "address",
428
- * fields: {
429
- * street: { name: "street", type: "string" },
430
- * city: { name: "city", type: "string" },
431
- * zip: { name: "zip", type: "string" }
432
- * },
433
- * concrete: true
427
+ * name: "AddressSchema",
428
+ * description: "A concrete schema for geographical addresses.",
429
+ * fields: {
430
+ * street: { name: "street", type: "string", description: "Street name and number." },
431
+ * city: { name: "city", type: "string", description: "City or town." },
432
+ * zip: { name: "zip", type: "string", description: "Postal or zip code." }
433
+ * },
434
+ * concrete: true // Suitable for RDBMS table mapping
434
435
  * };
436
+ * ```
435
437
  *
438
+ * @example
439
+ * // Example of a non-concrete, object-based nested schema with discriminated fields (like a contact method)
440
+ * ```typescript
436
441
  * const contactSchema: NestedSchemaDefinition = {
437
- * name: "contact",
438
- * fields: [
439
- * { fields: { email: { name: "email", type: "string" } }, when: { field: "type", value: "email" } },
440
- * { fields: { phone: { name: "phone", type: "string" } }, when: { field: "type", value: "phone" } }
441
- * ]
442
+ * name: "ContactMethod",
443
+ * description: "Represents various contact methods using a discriminated union.",
444
+ * fields: [
445
+ * {
446
+ * fields: {
447
+ * type: { name: "type", type: "enum", values: ["email"], required: true },
448
+ * email: { name: "email", type: "string", hint: { input: { type: "email" } } }
449
+ * },
450
+ * when: { field: "type", value: "email" }
451
+ * },
452
+ * {
453
+ * fields: {
454
+ * type: { name: "type", type: "enum", values: ["phone"], required: true },
455
+ * phone: { name: "phone", type: "string", hint: { input: { type: "tel" } } }
456
+ * },
457
+ * when: { field: "type", value: "phone" }
458
+ * }
459
+ * ],
460
+ * concrete: false // Allows for discriminated field sets
461
+ * };
462
+ * ```
463
+ *
464
+ * @example
465
+ * // Example of a literal nested schema (reusable email string definition)
466
+ * ```typescript
467
+ * const emailStringSchema: NestedSchemaDefinition<string> = {
468
+ * name: "EmailAddressString",
469
+ * description: "A literal schema for a validated email address string.",
470
+ * literal: true,
471
+ * type: "string",
472
+ * constraints: {
473
+ * predicates: {
474
+ * matches: "/^[^\s@]+@[^\s@]+\\.[^\s@]+$/" // Regex for email format validation
475
+ * }
476
+ * }
442
477
  * };
443
478
  * ```
444
479
  */
445
- interface NestedSchemaDefinition {
480
+ type NestedSchemaDefinition<T> = {
446
481
  /**
447
- * The name of the nested schema, unique within the parent schema's nestedSchemas.
482
+ * The unique name or identifier of the nested schema within the parent schema's `nestedSchemas` map.
483
+ * This `name` is used by `FieldDefinition.schema.id` to reference this nested schema.
484
+ * @example "AddressSchema" or "EmailString"
448
485
  */
449
486
  name: string;
450
487
  /**
451
- * A description of the nested schema's purpose.
488
+ * A clear and concise description of the nested schema's purpose, structure, or expected data.
489
+ * This is crucial for documentation and understanding the schema's intent.
452
490
  */
453
491
  description?: string;
492
+ } & (
493
+ /**
494
+ * Defines a literal nested schema.
495
+ * When `literal` is `true`, this `NestedSchemaDefinition` represents a direct primitive value
496
+ * (string, number, or boolean) rather than an object with fields.
497
+ * This is particularly useful for:
498
+ * - Defining reusable primitive types with specific constraints (e.g., a regex for an "EmailAddress" string).
499
+ * - Enabling direct unions between primitive types and object types within a `FieldDefinition`
500
+ * (e.g., `FieldType: "union"`, where one `FieldSchema` references a literal type).
501
+ */
502
+ {
503
+ literal: true;
504
+ /**
505
+ * The basic primitive type that this literal schema represents.
506
+ * Must be one of "string", "number", or "boolean".
507
+ */
508
+ type: "string" | "number" | "boolean";
509
+ /**
510
+ * An optional default value for this literal schema.
511
+ * If provided, the type of `default` must strictly match the `type` specified.
512
+ * @example "default@example.com" for type "string"
513
+ * @example 0 for type "number"
514
+ */
515
+ default?: T;
516
+ /**
517
+ * Optional constraints for additional validation rules specific to this literal type.
518
+ * These constraints apply directly to the primitive value.
519
+ */
520
+ constraints?: Array<Constraint<any> | ConstraintGroup<any>>;
521
+ /**
522
+ * Optional generic metadata associated with the literal schema.
523
+ * This can store any additional information relevant to tooling or specific domain requirements.
524
+ * @example `{ uiComponent: "emailInput", validationMessage: "Invalid email format" }`
525
+ */
526
+ metadata?: Record<string, any>;
527
+ } |
528
+ /**
529
+ * Defines a structured nested schema that represents an object with defined fields.
530
+ * This is the traditional way of defining complex data structures within the schema.
531
+ */
532
+ {
454
533
  /**
455
- * Indicates whether this schema represents a standalone entity (true) or is embedded (false).
456
- * When true, fields must be a Record<string, FieldDefinition<any>> to ensure a fixed structure
457
- * suitable for RDBMS table mapping. When false, fields can be an array of discriminated field sets.
534
+ * Explicitly indicates that this is a non-literal, structured schema.
535
+ * Default value is `false` if omitted.
536
+ */
537
+ literal?: false;
538
+ /**
539
+ * Indicates whether this schema represents a standalone entity (`true`) or is embedded (`false`).
540
+ * - When `true` (`concrete: true`), the schema is treated as a distinct, fixed-structure entity,
541
+ * often suitable for direct mapping to RDBMS tables. In this case, `fields` *must* be a
542
+ * `Record<string, FieldDefinition<any>>` to ensure a consistent, non-polymorphic structure.
543
+ * - When `false` (`concrete: false` or omitted), the schema is considered embedded or polymorphic.
544
+ * `fields` can be either a `Record<string, FieldDefinition<any>>` (for a fixed embedded object)
545
+ * or an `Array<{ fields: Record<string, FieldDefinition<any>>; when?: { field: string; value: any } }>`,
546
+ * allowing discriminated field sets based on a specific field's value (e.g., a 'type' field).
547
+ * The array form enables defining variants within a single schema without imposing strict concrete
548
+ * constraints, but is not supported for `concrete: true` schemas to maintain simplicity in RDBMS table mappings.
458
549
  * @default false
459
550
  */
460
551
  concrete?: boolean;
461
552
  /**
462
- * Defines the fields of the nested schema.
463
- * - If concrete is true, must be a Record<string, FieldDefinition<any>> for a fixed field set.
464
- * - If concrete is false, can be either a Record<string, FieldDefinition<any>> or an
465
- * Array<{ fields: Record<string, FieldDefinition<any>>; when?: { field: string; value: any } }>,
466
- * allowing discriminated field sets based on a field value (e.g., 'type').
467
- * The array form enables variant-specific fields without constraints, but is not supported for
468
- * concrete schemas to maintain simplicity in RDBMS table mappings.
553
+ * Defines the fields (properties) that constitute this nested schema.
554
+ * The structure of `fields` depends on the `concrete` property:
555
+ * - If `concrete` is `true`, `fields` must be a `Record<string, FieldDefinition<any>>`
556
+ * to define a fixed set of named fields (e.g., for a database table).
557
+ * - If `concrete` is `false` (or omitted), `fields` can be:
558
+ * - A `Record<string, FieldDefinition<any>>` for a simple, embedded object.
559
+ * - An `Array<{ fields: Record<string, FieldDefinition<any>>; when?: { field: string; value: any } }>`
560
+ * to define a discriminated union or polymorphic structure. Each object in the array defines a
561
+ * set of fields that apply `when` a specified `field` (within this schema's own fields)
562
+ * has a particular `value`. This allows for variant-specific fields.
469
563
  */
470
564
  fields: Record<string, FieldDefinition<any>> | Array<{
565
+ /**
566
+ * A set of field definitions that apply when the `when` condition is met.
567
+ */
471
568
  fields: Record<string, FieldDefinition<any>>;
569
+ /**
570
+ * An optional condition that makes this set of fields active.
571
+ * This object specifies a `field` (its name within this schema) and a `value`.
572
+ * When the specified `field` in the data matches this `value`, these `fields` are considered active.
573
+ * Used for discriminated unions or polymorphic structures (e.g., `when: { field: "type", value: "car" }`).
574
+ * If `when` is omitted for an entry in the array, those fields are always present in the union's base,
575
+ * or it acts as a fallback if no other `when` condition matches.
576
+ */
472
577
  when?: {
473
578
  field: string;
474
579
  value: any;
475
580
  };
476
581
  }>;
477
582
  /**
478
- * Optional constraints for additional validation rules.
479
- * Less necessary when using discriminated field sets, as variant logic can be structural.
583
+ * Optional constraints for additional validation rules that apply to the entire structured schema.
584
+ * These constraints provide an extra layer of data integrity beyond basic type checking.
585
+ * They are less strictly necessary when using discriminated field sets (`fields` as an array),
586
+ * as much of the variant logic can be enforced structurally through the `when` clauses.
480
587
  */
481
588
  constraints?: SchemaConstraint<any>;
589
+ /**
590
+ * Defines database indexes for the fields within this nested schema.
591
+ * This is primarily applicable when `concrete` is `true`, indicating that the schema
592
+ * maps directly to a persistent data store table. Indexes help optimize data retrieval.
593
+ */
482
594
  indexes?: IndexDefinition[];
595
+ /**
596
+ * Optional generic metadata associated with the structured schema.
597
+ * This can store any additional information relevant to tooling, UI generation,
598
+ * or specific domain requirements that are not covered by other properties.
599
+ * @example `{ graphqlType: "Address", apiEndpoint: "/api/addresses" }`
600
+ */
483
601
  metadata?: Record<string, any>;
484
- }
602
+ });
485
603
  /**
486
604
  * Defines a complete schema, intended as an atomic unit within a larger domain model.
487
605
  *
@@ -519,7 +637,7 @@ interface SchemaDefinition {
519
637
  description?: string;
520
638
  fields: Record<string, FieldDefinition<any>>;
521
639
  /** Reusable nested schema definitions, now as mini-SchemaDefinitions. */
522
- nestedSchemas: Record<string, NestedSchemaDefinition>;
640
+ nestedSchemas?: Record<string, NestedSchemaDefinition<any>>;
523
641
  indexes?: IndexDefinition[];
524
642
  constraints?: SchemaConstraint<any>;
525
643
  metadata?: Record<string, any>;
@@ -598,14 +716,14 @@ type SchemaChange<T> = {
598
716
  } | {
599
717
  type: "addNestedSchema";
600
718
  id: string;
601
- definition: NestedSchemaDefinition;
719
+ definition: NestedSchemaDefinition<any>;
602
720
  } | {
603
721
  type: "removeNestedSchema";
604
722
  id: string;
605
723
  } | {
606
724
  type: "modifyNestedSchema";
607
725
  id: string;
608
- changes: Partial<NestedSchemaDefinition>;
726
+ changes: Partial<NestedSchemaDefinition<any>>;
609
727
  };
610
728
  /**
611
729
  * Defines a transform function for data migration between schema versions.
@@ -962,7 +1080,7 @@ interface SchemaMigrationHelper {
962
1080
  * @param {string} schemaId - The ID of the nested schema to add.
963
1081
  * @param {NestedSchemaDefinition} nestedDefinition - The definition of the nested schema to add.
964
1082
  */
965
- addNestedSchema(schemaId: string, nestedDefinition: NestedSchemaDefinition): void;
1083
+ addNestedSchema(schemaId: string, nestedDefinition: NestedSchemaDefinition<any>): void;
966
1084
  /**
967
1085
  * Removes a nested schema from the schema.
968
1086
  * @param {string} schemaId - The ID of the nested schema to remove.
@@ -973,7 +1091,7 @@ interface SchemaMigrationHelper {
973
1091
  * @param {string} schemaId - The ID of the nested schema to modify.
974
1092
  * @param {Partial<NestedSchemaDefinition>} changes - The changes to apply to the nested schema.
975
1093
  */
976
- modifyNestedSchema(schemaId: string, changes: Partial<NestedSchemaDefinition>): void;
1094
+ modifyNestedSchema(schemaId: string, changes: Partial<NestedSchemaDefinition<any>>): void;
977
1095
  /**
978
1096
  * Returns the list of changes made through this helper.
979
1097
  * @returns An array of schema changes.
@@ -984,185 +1102,635 @@ interface SchemaMigrationHelper {
984
1102
  };
985
1103
  }
986
1104
 
1105
+ /**
1106
+ * Defines the possible event types for persistence operations.
1107
+ */
1108
+ type PersistenceEventType = "create:start" | "create:success" | "create:failed" | "read:start" | "read:success" | "read:failed" | "migrate:start" | "migrate:success" | "migrate:failed" | "rollback:start" | "rollback:success" | "rollback:failed" | "update:start" | "update:success" | "update:failed" | "delete:start" | "delete:success" | "delete:failed" | "transaction:start" | "transaction:success" | "transaction:failed" | "telemetry" | "collection:create:start" | "collection:create:success" | "collection:create:failed" | "collection:delete:start" | "collection:delete:success" | "collection:delete:failed" | "subscription:register" | "subscription:unregister" | "trigger:register" | "trigger:unregister" | "trigger:execute" | "trigger:failed" | "task:register" | "task:unregister" | "task:start" | "task:success" | "task:failed" | "metadata:called";
1109
+ /**
1110
+ * Interface representing events emitted during persistence operations.
1111
+ */
1112
+ interface PersistenceEvent<DataType> {
1113
+ /** The type of event (e.g., 'create:start', 'trigger:execute'). */
1114
+ type: PersistenceEventType;
1115
+ /** Timestamp when the event occurred. */
1116
+ timestamp: number;
1117
+ /** The operation being performed (e.g., 'create', 'trigger'). */
1118
+ operation: string;
1119
+ /** Name of the collection affected by the operation (if applicable). */
1120
+ collection?: string;
1121
+ /** Data passed to the operation (if applicable). */
1122
+ input?: any;
1123
+ /** Data returned by the operation (if applicable). */
1124
+ output?: any;
1125
+ /** Error object if the operation failed (if applicable). */
1126
+ error?: Error;
1127
+ /** Issues that caused the operation to fail (if applicable). */
1128
+ issues?: Array<StandardSchemaV1.Issue>;
1129
+ /** Query used in the operation (if applicable). */
1130
+ query?: QueryDSL<DataType, any>;
1131
+ /** Identifier for the transaction (if part of one). */
1132
+ transactionId?: string;
1133
+ /** Duration of the operation in milliseconds. */
1134
+ duration?: number;
1135
+ /** Additional context or metadata specific to the operation. */
1136
+ context?: Record<string, any>;
1137
+ }
1138
+ /**
1139
+ * Describes a subscription configuration.
1140
+ */
1141
+ interface SubscriptionInfo {
1142
+ /** The event subscribed to. */
1143
+ event: PersistenceEventType;
1144
+ /** Unique identifier for the callback. */
1145
+ callbackId: string;
1146
+ /** Optional short identifier (max 50 chars, unique within scope). */
1147
+ label?: string;
1148
+ /** Optional description of the subscription's purpose (max 500 chars). */
1149
+ description?: string;
1150
+ }
1151
+ /**
1152
+ * Describes a trigger configuration.
1153
+ */
1154
+ interface TriggerInfo<T, FunctionMap = Record<string, any>> {
1155
+ /** The event(s) or pattern triggering the callback. */
1156
+ event: PersistenceEventType | PersistenceEventType[] | `${string}:*`;
1157
+ /** Optional condition for the trigger. */
1158
+ condition?: QueryFilter<T, FunctionMap>;
1159
+ /** Unique identifier for the callback. */
1160
+ callbackId: string;
1161
+ /** Whether the trigger executes synchronously. */
1162
+ isSync: boolean;
1163
+ /** Short identifier (max 50 chars, unique within scope). */
1164
+ label: string;
1165
+ /** Description of the trigger's purpose (max 500 chars). */
1166
+ description: string;
1167
+ }
1168
+ /**
1169
+ * Describes a scheduled task configuration.
1170
+ */
1171
+ interface TaskInfo {
1172
+ /** Unique identifier for the task. */
1173
+ id: string;
1174
+ /** Schedule for task execution. */
1175
+ schedule: TaskSchedule;
1176
+ /** Unique identifier for the callback. */
1177
+ callbackId: string;
1178
+ /** Whether the task executes synchronously. */
1179
+ isSync: boolean;
1180
+ /** Optional metadata for logging or telemetry. */
1181
+ metadata?: Record<string, any>;
1182
+ /** Short identifier (max 50 chars, unique within scope). */
1183
+ label: string;
1184
+ /** Description of the task's purpose (max 500 chars). */
1185
+ description: string;
1186
+ }
1187
+ /**
1188
+ * Filter criteria for metadata queries.
1189
+ */
1190
+ interface MetadataFilter {
1191
+ /** Filter for subscriptions. */
1192
+ subscriptions?: {
1193
+ event?: PersistenceEventType | PersistenceEventType[];
1194
+ label?: string;
1195
+ };
1196
+ /** Filter for triggers. */
1197
+ triggers?: {
1198
+ event?: PersistenceEventType | PersistenceEventType[] | `${string}:*`;
1199
+ label?: string;
1200
+ };
1201
+ /** Filter for tasks. */
1202
+ tasks?: {
1203
+ id?: string;
1204
+ metadata?: Record<string, any>;
1205
+ label?: string;
1206
+ };
1207
+ /** Filter for schemas. */
1208
+ schemas?: {
1209
+ id?: string;
1210
+ };
1211
+ }
1212
+ /**
1213
+ * Metadata for a single collection.
1214
+ */
1215
+ interface CollectionMetadata<T, FunctionMap = Record<string, any>> {
1216
+ /** Collection identifier. */
1217
+ id: string;
1218
+ /** Active subscriptions for the collection. */
1219
+ subscriptions: SubscriptionInfo[];
1220
+ /** Active triggers for the collection. */
1221
+ triggers: TriggerInfo<T, FunctionMap>[];
1222
+ /** Scheduled tasks for the collection. */
1223
+ tasks: TaskInfo[];
1224
+ /** Number of records in the collection. */
1225
+ recordCount: number;
1226
+ /** Storage used by the collection in bytes. */
1227
+ dataSizeBytes: number;
1228
+ /** Schema definition for the collection. */
1229
+ schema: SchemaDefinition;
1230
+ /** Timestamp of the last operation on the collection. */
1231
+ lastModified: number;
1232
+ }
1233
+ /**
1234
+ * Metadata for Persistence or PersistenceCollection.
1235
+ */
1236
+ interface Metadata<T, FunctionMap = Record<string, any>> {
1237
+ /** Active subscriptions. */
1238
+ subscriptions: SubscriptionInfo[];
1239
+ /** Active triggers. */
1240
+ triggers: TriggerInfo<T, FunctionMap>[];
1241
+ /** Scheduled tasks. */
1242
+ tasks: TaskInfo[];
1243
+ /** Number of collections (Persistence only). */
1244
+ collectionCount?: number;
1245
+ /** Total storage used by all collections in bytes (Persistence only). */
1246
+ storageUsageBytes?: number;
1247
+ /** Database connection status (Persistence only). */
1248
+ connectionStatus?: "connected" | "disconnected" | "error";
1249
+ /** Database connection error, if any (Persistence only). */
1250
+ connectionError?: string | null;
1251
+ /** Schema definitions for all collections, if requested (Persistence only). */
1252
+ schemas?: SchemaDefinition[];
1253
+ /** Per-collection metadata, if requested (Persistence only). */
1254
+ collections?: CollectionMetadata<any, FunctionMap>[];
1255
+ /** Number of records in the collection (PersistenceCollection only). */
1256
+ recordCount?: number;
1257
+ /** Storage used by the collection in bytes (PersistenceCollection only). */
1258
+ dataSizeBytes?: number;
1259
+ /** Schema definition for the collection (PersistenceCollection only). */
1260
+ schema?: SchemaDefinition;
1261
+ /** Timestamp of the last operation on the collection (PersistenceCollection only). */
1262
+ lastModified?: number;
1263
+ }
1264
+ /**
1265
+ * Interface for querying observability data.
1266
+ */
1267
+ interface ObservabilityInterface<T, FunctionMap = Record<string, any>> {
1268
+ /**
1269
+ * Returns metadata about active subscriptions, triggers, tasks, and system state.
1270
+ * @param filter Optional filter to limit returned data (e.g., by event or label).
1271
+ * @param includeCollections For Persistence, whether to include per-collection metadata.
1272
+ * @param includeSchemas For Persistence, whether to include schema definitions.
1273
+ * @param forceRefresh Whether to force real-time queries for storageUsageBytes and dataSizeBytes.
1274
+ * @returns Metadata object containing observability data.
1275
+ * @example
1276
+ * // Collection metadata with label filter
1277
+ * const metadata = collection.metadata({ triggers: { label: "user-*" } });
1278
+ * console.log(metadata.triggers); // Triggers with label "user-*"
1279
+ * console.log(metadata.dataSizeBytes); // Storage used
1280
+ *
1281
+ * // Persistence metadata
1282
+ * const globalMetadata = persistence.metadata({ includeCollections: true });
1283
+ * console.log(globalMetadata.storageUsageBytes); // Total storage
1284
+ * console.log(globalMetadata.collections); // Per-collection metadata
1285
+ */
1286
+ metadata(filter?: MetadataFilter, includeCollections?: boolean, includeSchemas?: boolean, forceRefresh?: boolean): Metadata<T, FunctionMap>;
1287
+ }
1288
+ /**
1289
+ * Interface for event handling and task scheduling.
1290
+ */
1291
+ interface EventTaskInterface<T, FunctionMap = Record<string, any>> {
1292
+ /**
1293
+ * Subscribes to persistence events.
1294
+ * @param event The event to subscribe to.
1295
+ * @param callback The callback to handle the event.
1296
+ * @param options Optional label and description for the subscription.
1297
+ * @returns A function to unsubscribe from the event.
1298
+ * @example
1299
+ * const unsubscribe = persistence.subscribe("telemetry", (event) => {
1300
+ * console.log(event);
1301
+ * }, { label: "telemetry-log", description: "Logs telemetry events" });
1302
+ * unsubscribe();
1303
+ */
1304
+ subscribe(event: PersistenceEventType, callback: (payload: PersistenceEvent<T>) => void, options?: {
1305
+ label?: string;
1306
+ description?: string;
1307
+ }): () => void;
1308
+ /**
1309
+ * Registers a trigger callback for specific events.
1310
+ * @param config Configuration including event, callback, label, description, and options.
1311
+ * @returns A function to unsubscribe the trigger.
1312
+ * @example
1313
+ * collection.trigger("create:success",
1314
+ * ({ collection, results }) => {
1315
+ * console.log(`Created: ${results.id}`);
1316
+ * },
1317
+ * {
1318
+ * label: "user-create-hook",
1319
+ * description: "Syncs new users with CRM",
1320
+ * sync: true
1321
+ * });
1322
+ */
1323
+ trigger(event: PersistenceEventType | PersistenceEventType[] | `${string}:*`, callback: (context: TriggerContext<T, FunctionMap>) => void | Promise<void>, options: {
1324
+ condition?: QueryFilter<T, FunctionMap>;
1325
+ sync?: boolean;
1326
+ label: string;
1327
+ description: string;
1328
+ }): () => void;
1329
+ /**
1330
+ * Schedules a task to run at specified times or intervals.
1331
+ * @param config Configuration including ID, schedule, callback, label, description, and options.
1332
+ * @returns A function to cancel the scheduled task.
1333
+ * @example
1334
+ * collection.schedule({
1335
+ * id: "cleanup-inactive",
1336
+ * label: "inactive-cleanup",
1337
+ * description: "Deletes inactive records hourly",
1338
+ * schedule: { cron: "0 * * * *" },
1339
+ * callback: ({ collection }) => {
1340
+ * collection.delete({ query: { filter: { status: { $eq: "inactive" } } } });
1341
+ * }
1342
+ * });
1343
+ */
1344
+ schedule(config: {
1345
+ id: string;
1346
+ schedule: TaskSchedule;
1347
+ callback: (context: TaskContext<T, FunctionMap>) => void | Promise<void>;
1348
+ sync?: boolean;
1349
+ metadata?: Record<string, any>;
1350
+ label: string;
1351
+ description: string;
1352
+ }): () => void;
1353
+ }
987
1354
  /**
988
1355
  * Interface defining persistence operations for data management.
989
- * Provides methods for CRUD operations, transactions, validation, and event subscription.
990
- *
991
- * @generic DataType - The type of data being persisted.
992
- * @generic FunctionMap - A map of functions used in the persistence operations (default: Record<string, any>).
993
1356
  */
994
- interface Persistence<FunctionMap> {
1357
+ interface Persistence<FunctionMap = Record<string, any>> extends ObservabilityInterface<any, FunctionMap>, EventTaskInterface<any, FunctionMap> {
995
1358
  /**
996
- * Returns a list of all collections
997
- * @returns A promise that resolves to a list of collection names
1359
+ * Returns a list of all collection names.
1360
+ * @returns A promise that resolves to an array of collection names.
998
1361
  */
999
1362
  collections(): Promise<Array<string>>;
1000
1363
  /**
1001
1364
  * Creates a new collection with the specified schema.
1002
- * @param schema - The schema definition for the new collection.
1003
- * @returns A promise that resolves when the collection is created.
1365
+ * @param schema The schema definition for the new collection.
1366
+ * @returns A promise that resolves to the created PersistenceCollection.
1004
1367
  */
1005
- createCollection<T>(schema: SchemaDefinition): Promise<PersistenceCollection<T, FunctionMap>>;
1368
+ create<T>(schema: SchemaDefinition): Promise<PersistenceCollection<T, FunctionMap>>;
1006
1369
  /**
1007
1370
  * Deletes the specified collection.
1008
- * @param id - The ID of the collection to delete.
1009
- * @returns A promise that resolves when the collection is deleted.
1371
+ * @param id The ID of the collection to delete.
1372
+ * @returns A promise that resolves indicating whether the collection was deleted.
1010
1373
  */
1011
- deleteCollection(id: string): Promise<void>;
1374
+ delete(id: string): Promise<boolean>;
1012
1375
  /**
1013
1376
  * Retrieves the schema definition for the specified collection.
1014
- * @param id - The ID of the collection.
1015
- * @returns A promise that resolves to the schema definition of the collection.
1377
+ * @param id The ID of the collection.
1378
+ * @returns A promise that resolves to the schema definition.
1016
1379
  */
1017
1380
  schema(id: string): Promise<SchemaDefinition>;
1018
1381
  /**
1019
- * Returns an object that can be used to interact with a collection of data
1020
- *
1382
+ * Returns a PersistenceCollection instance for interacting with a collection.
1383
+ * @param id The ID of the collection.
1384
+ * @returns The PersistenceCollection instance.
1021
1385
  */
1022
1386
  collection<T>(id: string): PersistenceCollection<T, FunctionMap>;
1023
- /**
1024
- * Subscribe to persistence events
1025
- * @param event - The event to subscribe to
1026
- * @param callback - A callback to handle the event
1027
- * @returns A callback that can be used to unsubscribe from the event
1028
- */
1029
- subscribe(event: PersistenceEventType, callback: (payload: PersistenceEvent<any>) => void): () => void;
1030
1387
  /**
1031
1388
  * Executes a transaction with multiple operations.
1032
- * @param callback A function that receives a PersistenceTransaction object to perform multiple operations.
1033
- * @param callback.tx The PersistenceTransaction object used to perform transactional operations.
1034
- * @returns A promise that resolves to the result of the transaction.
1389
+ * @param callback A function that receives a PersistenceTransaction object.
1390
+ * @returns A promise that resolves to the transaction result.
1035
1391
  */
1036
1392
  transact<ReturnType>(callback: (tx: PersistenceTransaction<FunctionMap>) => Promise<ReturnType>): Promise<ReturnType>;
1037
1393
  }
1038
- type PersistenceTransaction<F> = Omit<Persistence<F>, "subscribe" | "transact">;
1039
- interface PersistenceCollection<T, FunctionMap> {
1394
+ /**
1395
+ * Transaction interface, omitting subscribe, trigger, schedule, and transact methods.
1396
+ */
1397
+ type PersistenceTransaction<F> = Omit<Persistence<F>, "subscribe" | "trigger" | "schedule" | "transact">;
1398
+ /**
1399
+ * Interface for managing a single collection's data operations.
1400
+ */
1401
+ interface PersistenceCollection<T, FunctionMap = Record<string, any>> extends ObservabilityInterface<T, FunctionMap>, EventTaskInterface<T, FunctionMap> {
1040
1402
  /**
1041
- * Creates a new record or multiple records in the specified collection.
1042
- * @param params An object containing the data to create and the collection name.
1043
- * @param params.data The data to be inserted; can be a single record or an array of records.
1044
- * @param params.collection The name of the collection to create records in.
1045
- * @returns A promise that resolves to the created record(s) with their generated IDs.
1403
+ * Creates a new record or multiple records in the collection.
1404
+ * @param params The data to create.
1405
+ * @returns A promise that resolves to the created record(s).
1046
1406
  */
1047
1407
  create(params: {
1048
1408
  data: T | T[];
1049
1409
  }): Promise<T | T[]>;
1050
1410
  /**
1051
- * Retrieves one or more records from the specified collection.
1052
- * @param params An object containing the query and collection name.
1053
- * @param params.query The query defining the filter, sort, pagination, and projection options.
1054
- * @returns A promise that resolves to a single record or an array of matching records.
1411
+ * Retrieves one or more records from the collection.
1412
+ * @param params The query defining the filter, sort, pagination, and projection.
1413
+ * @returns A promise that resolves to the matching record or array of records.
1055
1414
  */
1056
1415
  read(params: {
1057
1416
  query: QueryDSL<T, FunctionMap>;
1058
- }): Promise<T | T[]>;
1417
+ }): Promise<T | Array<T>>;
1059
1418
  /**
1060
- * Updates one or more records in the specified collection.
1061
- * @param params An object containing the updated data, query, and collection name.
1062
- * @param params.data The updated data to be applied; can be a single partial record or an array of partial records.
1063
- * @param params.query The query defining which records to update.
1419
+ * Updates one or more records in the collection.
1420
+ * @param params The updated data, patch, or query.
1064
1421
  * @returns A promise that resolves to the updated records.
1065
1422
  */
1066
1423
  update(params: {
1067
1424
  data?: Partial<T>;
1068
1425
  patch?: PatchOperation | Array<PatchOperation>;
1069
- query: QueryFilter<T, any>;
1426
+ query: QueryFilter<T, FunctionMap>;
1070
1427
  }): Promise<Array<T>>;
1071
1428
  /**
1072
- * Deletes one or more records from the specified collection.
1073
- * @param params An object containing either the query or records to delete, and the collection name.
1074
- * @param params.query The query defining which records to delete.
1075
- * @param params.records An array of records to delete.
1076
- * @returns A promise that resolves to the number of deleted records or the deleted records themselves.
1429
+ * Deletes one or more records from the collection.
1430
+ * @param params The query defining which records to delete.
1431
+ * @returns A promise that resolves to the number of deleted records.
1077
1432
  */
1078
1433
  delete(params: {
1079
- query: QueryFilter<T, any>;
1434
+ query: QueryFilter<T, FunctionMap>;
1080
1435
  }): Promise<number>;
1081
1436
  /**
1082
- * Validates an object against a schema.
1083
- * @param params An object containing the data, and collection name.
1084
- * @param params.data The object to validate.
1085
- * @returns An object containing validation results.
1437
+ * Validates an object against the collection's schema.
1438
+ * @param data The object to validate.
1439
+ * @returns Validation results.
1086
1440
  */
1087
1441
  validate(data: any): {
1088
1442
  valid: boolean;
1089
1443
  issues: ReadonlyArray<StandardSchemaV1.Issue> | null;
1090
1444
  };
1091
1445
  /**
1092
- * Subscribe to persistence events
1093
- * @param event - The event to subscribe to
1094
- * @param callback - A callback to handle the event
1095
- * @returns A callback that can be used to unsubscribe from the event
1446
+ * Rolls back the collection to a previous schema version.
1447
+ * @param version The version to roll back to (optional).
1448
+ * @param dryRun Whether to simulate the rollback.
1449
+ * @returns A promise that resolves to the new schema and data preview, or undefined.
1096
1450
  */
1097
- subscribe(event: PersistenceEventType, callback: (payload: PersistenceEvent<T>) => void): () => void;
1098
1451
  rollback(version?: string, dryRun?: boolean): Promise<{
1099
- newSchema: SchemaDefinition;
1100
- dataPreview: ReadableStream<any>;
1452
+ schema: SchemaDefinition;
1453
+ preview: ReadableStream<any>;
1101
1454
  } | undefined>;
1455
+ /**
1456
+ * Applies a schema migration to the collection.
1457
+ * @param description A description of the migration.
1458
+ * @param cb A callback defining the transformation logic.
1459
+ * @param dryRun Whether to simulate the migration.
1460
+ * @returns A promise that resolves to the new schema and data preview, or undefined.
1461
+ */
1102
1462
  migrate(description: string, cb: (h: Omit<SchemaMigrationHelper, "changes">) => DataTransform<any, any> | undefined, dryRun?: boolean): Promise<{
1103
- newSchema: SchemaDefinition;
1104
- dataPreview: ReadableStream<any>;
1463
+ schema: SchemaDefinition;
1464
+ preview: ReadableStream<any>;
1105
1465
  } | undefined>;
1106
1466
  }
1107
1467
  /**
1108
- * Defines the possible event types for persistence operations
1468
+ * Context for collection-specific triggers.
1469
+ */
1470
+ type CollectionTriggerContext<T, FunctionMap = Record<string, any>> = {
1471
+ event: PersistenceEvent<T> & {
1472
+ type: "create:start";
1473
+ operation: "create";
1474
+ };
1475
+ persistence: Persistence<FunctionMap>;
1476
+ collection: PersistenceCollection<T, FunctionMap>;
1477
+ params: {
1478
+ data: T | T[];
1479
+ };
1480
+ results: undefined;
1481
+ } | {
1482
+ event: PersistenceEvent<T> & {
1483
+ type: "create:success";
1484
+ operation: "create";
1485
+ };
1486
+ persistence: Persistence<FunctionMap>;
1487
+ collection: PersistenceCollection<T, FunctionMap>;
1488
+ params: {
1489
+ data: T | T[];
1490
+ };
1491
+ results: T | T[];
1492
+ } | {
1493
+ event: PersistenceEvent<T> & {
1494
+ type: "create:failed";
1495
+ operation: "create";
1496
+ };
1497
+ persistence: Persistence<FunctionMap>;
1498
+ collection: PersistenceCollection<T, FunctionMap>;
1499
+ params: {
1500
+ data: T | T[];
1501
+ };
1502
+ results: undefined;
1503
+ } | {
1504
+ event: PersistenceEvent<T> & {
1505
+ type: "read:start";
1506
+ operation: "read";
1507
+ };
1508
+ persistence: Persistence<FunctionMap>;
1509
+ collection: PersistenceCollection<T, FunctionMap>;
1510
+ params: {
1511
+ query: QueryDSL<T, FunctionMap>;
1512
+ };
1513
+ results: undefined;
1514
+ } | {
1515
+ event: PersistenceEvent<T> & {
1516
+ type: "read:success";
1517
+ operation: "read";
1518
+ };
1519
+ persistence: Persistence<FunctionMap>;
1520
+ collection: PersistenceCollection<T, FunctionMap>;
1521
+ params: {
1522
+ query: QueryDSL<T, FunctionMap>;
1523
+ };
1524
+ results: T | T[];
1525
+ } | {
1526
+ event: PersistenceEvent<T> & {
1527
+ type: "read:failed";
1528
+ operation: "read";
1529
+ };
1530
+ persistence: Persistence<FunctionMap>;
1531
+ collection: PersistenceCollection<T, FunctionMap>;
1532
+ params: {
1533
+ query: QueryDSL<T, FunctionMap>;
1534
+ };
1535
+ results: undefined;
1536
+ } | {
1537
+ event: PersistenceEvent<T> & {
1538
+ type: "update:start";
1539
+ operation: "update";
1540
+ };
1541
+ persistence: Persistence<FunctionMap>;
1542
+ collection: PersistenceCollection<T, FunctionMap>;
1543
+ params: {
1544
+ data?: Partial<T>;
1545
+ patch?: PatchOperation | Array<PatchOperation>;
1546
+ query: QueryFilter<T, FunctionMap>;
1547
+ };
1548
+ results: undefined;
1549
+ } | {
1550
+ event: PersistenceEvent<T> & {
1551
+ type: "update:success";
1552
+ operation: "update";
1553
+ };
1554
+ persistence: Persistence<FunctionMap>;
1555
+ collection: PersistenceCollection<T, FunctionMap>;
1556
+ params: {
1557
+ data?: Partial<T>;
1558
+ patch?: PatchOperation | Array<PatchOperation>;
1559
+ query: QueryFilter<T, FunctionMap>;
1560
+ };
1561
+ results: Array<T>;
1562
+ } | {
1563
+ event: PersistenceEvent<T> & {
1564
+ type: "update:failed";
1565
+ operation: "update";
1566
+ };
1567
+ persistence: Persistence<FunctionMap>;
1568
+ collection: PersistenceCollection<T, FunctionMap>;
1569
+ params: {
1570
+ data?: Partial<T>;
1571
+ patch?: PatchOperation | Array<PatchOperation>;
1572
+ query: QueryFilter<T, FunctionMap>;
1573
+ };
1574
+ results: undefined;
1575
+ } | {
1576
+ event: PersistenceEvent<T> & {
1577
+ type: "delete:start";
1578
+ operation: "delete";
1579
+ };
1580
+ persistence: Persistence<FunctionMap>;
1581
+ collection: PersistenceCollection<T, FunctionMap>;
1582
+ params: {
1583
+ query: QueryFilter<T, FunctionMap>;
1584
+ };
1585
+ results: undefined;
1586
+ } | {
1587
+ event: PersistenceEvent<T> & {
1588
+ type: "delete:success";
1589
+ operation: "delete";
1590
+ };
1591
+ persistence: Persistence<FunctionMap>;
1592
+ collection: PersistenceCollection<T, FunctionMap>;
1593
+ params: {
1594
+ query: QueryFilter<T, FunctionMap>;
1595
+ };
1596
+ results: number;
1597
+ } | {
1598
+ event: PersistenceEvent<T> & {
1599
+ type: "delete:failed";
1600
+ operation: "delete";
1601
+ };
1602
+ persistence: Persistence<FunctionMap>;
1603
+ collection: PersistenceCollection<T, FunctionMap>;
1604
+ params: {
1605
+ query: QueryFilter<T, FunctionMap>;
1606
+ };
1607
+ results: undefined;
1608
+ } | {
1609
+ event: PersistenceEvent<T> & {
1610
+ type: "migrate:start";
1611
+ operation: "migrate";
1612
+ };
1613
+ persistence: Persistence<FunctionMap>;
1614
+ collection: PersistenceCollection<T, FunctionMap>;
1615
+ params: {
1616
+ description: string;
1617
+ dryRun?: boolean;
1618
+ };
1619
+ results: undefined;
1620
+ } | {
1621
+ event: PersistenceEvent<T> & {
1622
+ type: "migrate:success";
1623
+ operation: "migrate";
1624
+ };
1625
+ persistence: Persistence<FunctionMap>;
1626
+ collection: PersistenceCollection<T, FunctionMap>;
1627
+ params: {
1628
+ description: string;
1629
+ dryRun?: boolean;
1630
+ };
1631
+ results: {
1632
+ schema: SchemaDefinition;
1633
+ preview: ReadableStream<any>;
1634
+ } | undefined;
1635
+ } | {
1636
+ event: PersistenceEvent<T> & {
1637
+ type: "migrate:failed";
1638
+ operation: "migrate";
1639
+ };
1640
+ persistence: Persistence<FunctionMap>;
1641
+ collection: PersistenceCollection<T, FunctionMap>;
1642
+ params: {
1643
+ description: string;
1644
+ dryRun?: boolean;
1645
+ };
1646
+ results: undefined;
1647
+ } | {
1648
+ event: PersistenceEvent<T> & {
1649
+ type: "rollback:start";
1650
+ operation: "rollback";
1651
+ };
1652
+ persistence: Persistence<FunctionMap>;
1653
+ collection: PersistenceCollection<T, FunctionMap>;
1654
+ params: {
1655
+ version?: string;
1656
+ dryRun?: boolean;
1657
+ };
1658
+ results: undefined;
1659
+ } | {
1660
+ event: PersistenceEvent<T> & {
1661
+ type: "rollback:success";
1662
+ operation: "rollback";
1663
+ };
1664
+ persistence: Persistence<FunctionMap>;
1665
+ collection: PersistenceCollection<T, FunctionMap>;
1666
+ params: {
1667
+ version?: string;
1668
+ dryRun?: boolean;
1669
+ };
1670
+ results: {
1671
+ schema: SchemaDefinition;
1672
+ preview: ReadableStream<any>;
1673
+ } | undefined;
1674
+ } | {
1675
+ event: PersistenceEvent<T> & {
1676
+ type: "rollback:failed";
1677
+ operation: "rollback";
1678
+ };
1679
+ persistence: Persistence<FunctionMap>;
1680
+ collection: PersistenceCollection<T, FunctionMap>;
1681
+ params: {
1682
+ version?: string;
1683
+ dryRun?: boolean;
1684
+ };
1685
+ results: undefined;
1686
+ };
1687
+ /**
1688
+ * Context for global triggers (Persistence-level, non-collection-specific).
1109
1689
  */
1110
- type PersistenceEventType = "create:start" | "create:success" | "create:failed" | "read:start" | "read:success" | "read:failed" | "migrate:start" | "migrate:success" | "migrate:failed" | "rollback:start" | "rollback:success" | "rollback:failed" | "read:failed" | "update:start" | "update:success" | "update:failed" | "delete:start" | "delete:success" | "delete:failed" | "transaction:start" | "transaction:success" | "transaction:failed" | "telemetry" | "collection:create:start" | "collection:create:success" | "collection:create:failed" | "collection:update:start" | "collection:update:success" | "collection:update:failed" | "collection:delete:start" | "collection:delete:success" | "collection:delete:failed";
1690
+ type GlobalTriggerContext<T, FunctionMap = Record<string, any>> = {
1691
+ event: PersistenceEvent<T> & {
1692
+ type: "transaction:start" | "transaction:success" | "transaction:failed" | "collection:create:start" | "collection:create:success" | "collection:create:failed" | "collection:delete:start" | "collection:delete:success" | "collection:delete:failed" | "telemetry";
1693
+ operation: "transaction" | "collection:create" | "collection:delete";
1694
+ };
1695
+ persistence: Persistence<FunctionMap>;
1696
+ collection?: undefined;
1697
+ params: any;
1698
+ results: any;
1699
+ };
1111
1700
  /**
1112
- * Interface representing events emitted during persistence operations
1701
+ * Union of trigger contexts.
1113
1702
  */
1114
- interface PersistenceEvent<DataType> {
1115
- /**
1116
- * The type of event (e.g., 'create:start', 'read:success')
1117
- */
1118
- type: PersistenceEventType;
1119
- /**
1120
- * Timestamp when the event occurred
1121
- */
1122
- timestamp: number;
1123
- /**
1124
- * The operation being performed (e.g., 'create', 'read')
1125
- */
1126
- operation: string;
1127
- /**
1128
- * Name of the collection affected by the operation (if applicable)
1129
- */
1130
- collection?: string;
1131
- /**
1132
- * Data passed to the operation (if applicable)
1133
- */
1134
- input?: any;
1135
- /**
1136
- * Data returned by the operation (if applicable)
1137
- */
1138
- output?: any;
1139
- /**
1140
- * Error object if the operation failed (if applicable)
1141
- */
1142
- error?: Error;
1143
- /**
1144
- * issues that caused the operation to fail (if applicable)
1145
- */
1146
- issues?: Array<StandardSchemaV1.Issue>;
1147
- /**
1148
- * Query used in the operation (if applicable)
1149
- */
1150
- query?: QueryDSL<DataType, any>;
1151
- /**
1152
- * Identifier for the transaction (if part of one)
1153
- */
1154
- transactionId?: string;
1155
- /**
1156
- * Duration of the operation in milliseconds.
1157
- * Useful for performance monitoring.
1158
- */
1159
- duration?: number;
1160
- /**
1161
- * Additional context or metadata specific to the operation.
1162
- * This field can be used to include extra debugging or contextual data.
1163
- */
1164
- context?: Record<string, any>;
1165
- }
1703
+ type TriggerContext<T, FunctionMap = Record<string, any>> = CollectionTriggerContext<T, FunctionMap> | GlobalTriggerContext<T, FunctionMap>;
1704
+ /**
1705
+ * Defines a schedule for a task.
1706
+ */
1707
+ type TaskSchedule = {
1708
+ cron: string;
1709
+ } | {
1710
+ at: string;
1711
+ } | {
1712
+ interval: number;
1713
+ };
1714
+ /**
1715
+ * Context provided to task callbacks.
1716
+ */
1717
+ type TaskContext<T, FunctionMap = Record<string, any>> = {
1718
+ persistence: Persistence<FunctionMap>;
1719
+ collection: PersistenceCollection<T, FunctionMap>;
1720
+ taskId: string;
1721
+ executionTime: number;
1722
+ metadata?: Record<string, any>;
1723
+ label: string;
1724
+ description: string;
1725
+ } | {
1726
+ persistence: Persistence<FunctionMap>;
1727
+ collection?: undefined;
1728
+ taskId: string;
1729
+ executionTime: number;
1730
+ metadata?: Record<string, any>;
1731
+ label: string;
1732
+ description: string;
1733
+ };
1166
1734
 
1167
1735
  type SchemaIndex = {
1168
1736
  schema: string;
@@ -1502,9 +2070,10 @@ declare class SchemaRegistry implements SchemaRegistryInterface {
1502
2070
  }
1503
2071
 
1504
2072
  /**
1505
- * @fileoverview Provides a MigrationEngine class that handles schema migrations,
2073
+ * @fileoverview
2074
+ * Provides a MigrationEngine class that handles schema migrations,
1506
2075
  * including validation, checksum generation, and migration application.
1507
- * @author Your Name
2076
+ * @author Saidimu
1508
2077
  */
1509
2078
 
1510
2079
  /**
@@ -1880,4 +2449,4 @@ declare function docgen(schema: SchemaDefinition, options?: {
1880
2449
  faker?: Faker;
1881
2450
  }): string;
1882
2451
 
1883
- export { type ArrayHint, type BooleanHint, type CodeHint, type Constraint, type ConstraintGroup, type ConstraintParameters, type ConstraintsMap, type DataTransform, type DateHint, type EnumHint, type FieldDefinition, type FieldGroup, type FieldSchema, type FieldType, type FileHint, type FunctionMap, type GroupDefinition, type IndexDefinition, type IndexType, type InputHint, JsonPatchError, type LogicalOperator, type Migration, MigrationEngine, type MigrationEngineInterface, MigrationError, MigrationErrorCode, type MigrationMetadata, type NestedSchemaDefinition, type NumberHint, type ObjectHint, type PartialIndexCondition, type PatchOperation, type Persistence, type PersistenceCollection, type PersistenceEvent, type PersistenceEventType, type PersistenceTransaction, type Predicate, type PredicateMap, type PredicateName, type PredicateParameters, type RegistryLock, type RegistryMetadata, type RemoteRepository, type Schema, type SchemaChange, type SchemaConstraint, type SchemaDefinition, type SchemaEvent, type SchemaEventType, type SchemaHint, type SchemaIndex, type SchemaMetadata, type SchemaMigrationHelper, SchemaRegistry, type SchemaRegistryInterface, type SchemaVersion, type SecretHint, type SetHint, type TextHint, type TransformFunction, applyPatch, calculateNextVersion, compareSemanticVersions, createGitSchemaRegistry, createPatch, createSchemaMigrationHelper, createStandardSchemaValidator, deepMerge, docgen, extractInputFieldGroups, formResolver, generateSHA256Hash, normalizePath, schemaChangeToPatch, schemaDefaults, schemaToTypes, serializeParams, sortSemanticVars, validate, validateMigration, validateSchemaChange, validateSchemaDefinition };
2452
+ export { type ArrayHint, type BooleanHint, type CodeHint, type CollectionMetadata, type CollectionTriggerContext, type Constraint, type ConstraintGroup, type ConstraintParameters, type ConstraintsMap, type DataTransform, type DateHint, type EnumHint, type EventTaskInterface, type FieldDefinition, type FieldGroup, type FieldSchema, type FieldType, type FileHint, type FunctionMap, type GlobalTriggerContext, type GroupDefinition, type IndexDefinition, type IndexType, type InputHint, JsonPatchError, type Metadata, type MetadataFilter, type Migration, MigrationEngine, type MigrationEngineInterface, MigrationError, MigrationErrorCode, type MigrationMetadata, type NestedSchemaDefinition, type NumberHint, type ObjectHint, type ObservabilityInterface, type PartialIndexCondition, type PatchOperation, type Persistence, type PersistenceCollection, type PersistenceEvent, type PersistenceEventType, type PersistenceTransaction, type Predicate, type PredicateMap, type PredicateName, type PredicateParameters, type RegistryLock, type RegistryMetadata, type RemoteRepository, type Schema, type SchemaChange, type SchemaConstraint, type SchemaDefinition, type SchemaEvent, type SchemaEventType, type SchemaHint, type SchemaIndex, type SchemaMetadata, type SchemaMigrationHelper, SchemaRegistry, type SchemaRegistryInterface, type SchemaVersion, type SecretHint, type SetHint, type SubscriptionInfo, type TaskContext, type TaskInfo, type TaskSchedule, type TextHint, type TransformFunction, type TriggerContext, type TriggerInfo, applyPatch, calculateNextVersion, compareSemanticVersions, createGitSchemaRegistry, createPatch, createSchemaMigrationHelper, createStandardSchemaValidator, deepMerge, docgen, extractInputFieldGroups, formResolver, generateSHA256Hash, normalizePath, schemaChangeToPatch, schemaDefaults, schemaToTypes, serializeParams, sortSemanticVars, validate, validateMigration, validateSchemaChange, validateSchemaDefinition };