@korajs/core 0.5.0 → 0.6.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.
package/dist/index.d.cts CHANGED
@@ -1,5 +1,7 @@
1
- import { R as RandomSource, A as AtomicOpType, a as AtomicOp, F as FieldBuilder, C as CustomResolver, M as MigrationDefinition, S as SchemaDefinition, b as CollectionDefinition, c as RelationDefinition, O as OperationType, E as EnumFieldBuilder, d as ArrayFieldBuilder, e as FieldKind, f as Operation, V as VersionVector, g as MigrationStep, h as StateMachineConstraint, T as TransitionMap, i as TransitionValidationResult } from './events-BeIEDJBW.cjs';
2
- export { j as CONNECTION_QUALITIES, k as ConnectionQuality, l as Constraint, m as FieldDescriptor, n as FieldMergeStrategy, H as HLCTimestamp, o as HybridLogicalClock, K as KoraEvent, p as KoraEventByType, q as KoraEventEmitter, r as KoraEventListener, s as KoraEventType, t as MERGE_STRATEGIES, u as MergeStrategy, v as MergeTrace, w as MigrationBuilder, x as OnDeleteAction, y as OperationInput, z as RelationType, B as RollbackBuilder, D as SequenceConfig, G as StateMachineDefinition, I as SyncDiagnosticsSnapshot, J as SyncRuleDefinition, L as TimeSource, N as createOperation, P as isValidOperation, Q as migrate, U as t, W as verifyOperationIntegrity } from './events-BeIEDJBW.cjs';
1
+ import { R as RandomSource, A as AtomicOpType, a as AtomicOp, F as FieldBuilder, C as CustomResolver, M as MigrationDefinition, S as SchemaDefinition, b as CollectionDefinition, c as RelationDefinition, O as OperationType, E as EnumFieldBuilder, d as ArrayFieldBuilder, e as FieldKind, f as Operation, V as VersionVector, g as MigrationStep, h as StateMachineConstraint, T as TransitionMap, i as TransitionValidationResult } from './events-D-FWfFg8.cjs';
2
+ export { j as CONNECTION_QUALITIES, k as ConnectionQuality, l as Constraint, m as FieldDescriptor, n as FieldMergeStrategy, H as HLCTimestamp, K as KoraEvent, o as KoraEventByType, p as KoraEventEmitter, q as KoraEventListener, r as KoraEventType, s as MERGE_STRATEGIES, t as MergeStrategy, u as MergeTrace, v as MigrationBuilder, w as OnDeleteAction, x as OperationInput, y as RelationType, z as RollbackBuilder, B as SequenceConfig, D as StateMachineDefinition, G as SyncDiagnosticsSnapshot, I as SyncRuleDefinition, J as TimeSource, L as migrate, N as t } from './events-D-FWfFg8.cjs';
3
+ export { H as HybridLogicalClock, c as createOperation, i as isValidOperation, v as verifyOperationIntegrity } from './operation-3-ZJJf3w.cjs';
4
+ export { S as ScopeMap, b as buildScopeMap } from './build-scope-map-B1CcncZN.cjs';
3
5
 
4
6
  /**
5
7
  * Base error class for all Kora errors.
@@ -59,6 +61,12 @@ declare class SyncError extends KoraError {
59
61
  declare class StorageError extends KoraError {
60
62
  constructor(message: string, context?: Record<string, unknown>);
61
63
  }
64
+ /**
65
+ * Thrown when collection/query APIs are used before {@link KoraApp.ready} resolves.
66
+ */
67
+ declare class AppNotReadyError extends KoraError {
68
+ constructor(detail: string);
69
+ }
62
70
  /**
63
71
  * Thrown when the HLC detects excessive clock drift.
64
72
  * Drift > 60s: warning. Drift > 5min: this error is thrown, refusing to generate timestamps.
@@ -546,36 +554,6 @@ declare function isCollectionSyncScoped(schema: SchemaDefinition, collectionName
546
554
  */
547
555
  declare function collectSchemaScopeValueKeys(schema: SchemaDefinition): string[];
548
556
 
549
- /**
550
- * Per-collection scope map: `{ collectionName: { field: value, ... } }`
551
- *
552
- * Used to filter which operations a client should receive during sync.
553
- */
554
- type ScopeMap = Record<string, Record<string, unknown>>;
555
- /**
556
- * Build a per-collection scope map from the schema's scope declarations
557
- * and the client's flat scope values.
558
- *
559
- * Supports both legacy `collection.scope` arrays and declarative `schema.sync`
560
- * rules (`sync: { todos: { where: { userId: true } } }`).
561
- *
562
- * When `schema.sync` is present, only collections with sync rules or legacy
563
- * scope fields are included in the result. Other collections are omitted so
564
- * sync engines treat them as out of scope (partial sync).
565
- *
566
- * @param schema - The schema definition with scope declarations
567
- * @param scopeValues - Flat key-value scope values from the client
568
- * @returns A per-collection scope map
569
- *
570
- * @example
571
- * ```typescript
572
- * // Schema declares: sales.scope = ['orgId', 'storeId']
573
- * // Client provides: { orgId: 'org-123', storeId: 'store-456' }
574
- * // Result: { sales: { orgId: 'org-123', storeId: 'store-456' }, products: {} }
575
- * ```
576
- */
577
- declare function buildScopeMap(schema: SchemaDefinition, scopeValues: Record<string, unknown>): ScopeMap;
578
-
579
557
  /**
580
558
  * Collect every unique scope field name declared across all collections.
581
559
  *
@@ -864,4 +842,4 @@ interface ProtoOutput {
864
842
  */
865
843
  declare function generateProtoDefinitions(schema: SchemaDefinition): ProtoOutput;
866
844
 
867
- export { APPLY_FAILURE_CODES, APPLY_RESULTS, type ApplyFailureReason, type ApplyResult, ArrayFieldBuilder, AtomicOp, type AtomicOpSentinel, AtomicOpType, CausalTracker, ClockDriftError, CollectionDefinition, type CollectionInput, type ConstraintInput, CustomResolver, EnumFieldBuilder, FieldBuilder, FieldKind, type FieldKindToType, type InferFieldType, type InferInsertInput, type InferRecord, type InferUpdateInput, KORA_ERROR_FIX_SUGGESTIONS, KoraError, MergeConflictError, MigrationDefinition, MigrationRollbackError, MigrationStep, Operation, OperationError, type OperationLog, type OperationTransform, OperationType, type ProtoOutput, RandomSource, RelationDefinition, type RelationInput, type ReversibleMigration, SchemaDefinition, type SchemaInput, SchemaValidationError, type ScopeMap, StateMachineConstraint, type StateMachineInput, StorageError, SyncError, TransitionMap, TransitionValidationResult, type TypedSchemaDefinition, VersionVector, advanceVector, applyOperationTransforms, buildScopeMap, buildStateMachineConstraints, canAutoRollback, collectSchemaScopeFields, collectSchemaScopeValueKeys, computeDelta, createReversibleMigration, createVersionVector, defaultApplyFailureReason, defaultSequenceFormat, defineSchema, deserializeVector, dominates, extractScopeValuesFromClaims, extractTimestamp, formatSequenceValue, generateFullDDL, generateProtoDefinitions, generateRollbackSteps, generateSQL, generateUUIDv7, getCollectionScopeBindings, getKoraErrorFix, getTransitionMap, hasSchemaSyncRules, isApplyFailure, isAtomicOp, isCollectionSyncScoped, isValidUUIDv7, mergeVectors, migrationStepsToSQL, op, resolveAtomicOp, rollbackStepsToSQL, serializeVector, toAtomicOp, validateRecord, validateTransition, vectorsEqual };
845
+ export { APPLY_FAILURE_CODES, APPLY_RESULTS, AppNotReadyError, type ApplyFailureReason, type ApplyResult, ArrayFieldBuilder, AtomicOp, type AtomicOpSentinel, AtomicOpType, CausalTracker, ClockDriftError, CollectionDefinition, type CollectionInput, type ConstraintInput, CustomResolver, EnumFieldBuilder, FieldBuilder, FieldKind, type FieldKindToType, type InferFieldType, type InferInsertInput, type InferRecord, type InferUpdateInput, KORA_ERROR_FIX_SUGGESTIONS, KoraError, MergeConflictError, MigrationDefinition, MigrationRollbackError, MigrationStep, Operation, OperationError, type OperationLog, type OperationTransform, OperationType, type ProtoOutput, RandomSource, RelationDefinition, type RelationInput, type ReversibleMigration, SchemaDefinition, type SchemaInput, SchemaValidationError, StateMachineConstraint, type StateMachineInput, StorageError, SyncError, TransitionMap, TransitionValidationResult, type TypedSchemaDefinition, VersionVector, advanceVector, applyOperationTransforms, buildStateMachineConstraints, canAutoRollback, collectSchemaScopeFields, collectSchemaScopeValueKeys, computeDelta, createReversibleMigration, createVersionVector, defaultApplyFailureReason, defaultSequenceFormat, defineSchema, deserializeVector, dominates, extractScopeValuesFromClaims, extractTimestamp, formatSequenceValue, generateFullDDL, generateProtoDefinitions, generateRollbackSteps, generateSQL, generateUUIDv7, getCollectionScopeBindings, getKoraErrorFix, getTransitionMap, hasSchemaSyncRules, isApplyFailure, isAtomicOp, isCollectionSyncScoped, isValidUUIDv7, mergeVectors, migrationStepsToSQL, op, resolveAtomicOp, rollbackStepsToSQL, serializeVector, toAtomicOp, validateRecord, validateTransition, vectorsEqual };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,7 @@
1
- import { R as RandomSource, A as AtomicOpType, a as AtomicOp, F as FieldBuilder, C as CustomResolver, M as MigrationDefinition, S as SchemaDefinition, b as CollectionDefinition, c as RelationDefinition, O as OperationType, E as EnumFieldBuilder, d as ArrayFieldBuilder, e as FieldKind, f as Operation, V as VersionVector, g as MigrationStep, h as StateMachineConstraint, T as TransitionMap, i as TransitionValidationResult } from './events-BeIEDJBW.js';
2
- export { j as CONNECTION_QUALITIES, k as ConnectionQuality, l as Constraint, m as FieldDescriptor, n as FieldMergeStrategy, H as HLCTimestamp, o as HybridLogicalClock, K as KoraEvent, p as KoraEventByType, q as KoraEventEmitter, r as KoraEventListener, s as KoraEventType, t as MERGE_STRATEGIES, u as MergeStrategy, v as MergeTrace, w as MigrationBuilder, x as OnDeleteAction, y as OperationInput, z as RelationType, B as RollbackBuilder, D as SequenceConfig, G as StateMachineDefinition, I as SyncDiagnosticsSnapshot, J as SyncRuleDefinition, L as TimeSource, N as createOperation, P as isValidOperation, Q as migrate, U as t, W as verifyOperationIntegrity } from './events-BeIEDJBW.js';
1
+ import { R as RandomSource, A as AtomicOpType, a as AtomicOp, F as FieldBuilder, C as CustomResolver, M as MigrationDefinition, S as SchemaDefinition, b as CollectionDefinition, c as RelationDefinition, O as OperationType, E as EnumFieldBuilder, d as ArrayFieldBuilder, e as FieldKind, f as Operation, V as VersionVector, g as MigrationStep, h as StateMachineConstraint, T as TransitionMap, i as TransitionValidationResult } from './events-D-FWfFg8.js';
2
+ export { j as CONNECTION_QUALITIES, k as ConnectionQuality, l as Constraint, m as FieldDescriptor, n as FieldMergeStrategy, H as HLCTimestamp, K as KoraEvent, o as KoraEventByType, p as KoraEventEmitter, q as KoraEventListener, r as KoraEventType, s as MERGE_STRATEGIES, t as MergeStrategy, u as MergeTrace, v as MigrationBuilder, w as OnDeleteAction, x as OperationInput, y as RelationType, z as RollbackBuilder, B as SequenceConfig, D as StateMachineDefinition, G as SyncDiagnosticsSnapshot, I as SyncRuleDefinition, J as TimeSource, L as migrate, N as t } from './events-D-FWfFg8.js';
3
+ export { H as HybridLogicalClock, c as createOperation, i as isValidOperation, v as verifyOperationIntegrity } from './operation-CygOwIjZ.js';
4
+ export { S as ScopeMap, b as buildScopeMap } from './build-scope-map-BmgAT82h.js';
3
5
 
4
6
  /**
5
7
  * Base error class for all Kora errors.
@@ -59,6 +61,12 @@ declare class SyncError extends KoraError {
59
61
  declare class StorageError extends KoraError {
60
62
  constructor(message: string, context?: Record<string, unknown>);
61
63
  }
64
+ /**
65
+ * Thrown when collection/query APIs are used before {@link KoraApp.ready} resolves.
66
+ */
67
+ declare class AppNotReadyError extends KoraError {
68
+ constructor(detail: string);
69
+ }
62
70
  /**
63
71
  * Thrown when the HLC detects excessive clock drift.
64
72
  * Drift > 60s: warning. Drift > 5min: this error is thrown, refusing to generate timestamps.
@@ -546,36 +554,6 @@ declare function isCollectionSyncScoped(schema: SchemaDefinition, collectionName
546
554
  */
547
555
  declare function collectSchemaScopeValueKeys(schema: SchemaDefinition): string[];
548
556
 
549
- /**
550
- * Per-collection scope map: `{ collectionName: { field: value, ... } }`
551
- *
552
- * Used to filter which operations a client should receive during sync.
553
- */
554
- type ScopeMap = Record<string, Record<string, unknown>>;
555
- /**
556
- * Build a per-collection scope map from the schema's scope declarations
557
- * and the client's flat scope values.
558
- *
559
- * Supports both legacy `collection.scope` arrays and declarative `schema.sync`
560
- * rules (`sync: { todos: { where: { userId: true } } }`).
561
- *
562
- * When `schema.sync` is present, only collections with sync rules or legacy
563
- * scope fields are included in the result. Other collections are omitted so
564
- * sync engines treat them as out of scope (partial sync).
565
- *
566
- * @param schema - The schema definition with scope declarations
567
- * @param scopeValues - Flat key-value scope values from the client
568
- * @returns A per-collection scope map
569
- *
570
- * @example
571
- * ```typescript
572
- * // Schema declares: sales.scope = ['orgId', 'storeId']
573
- * // Client provides: { orgId: 'org-123', storeId: 'store-456' }
574
- * // Result: { sales: { orgId: 'org-123', storeId: 'store-456' }, products: {} }
575
- * ```
576
- */
577
- declare function buildScopeMap(schema: SchemaDefinition, scopeValues: Record<string, unknown>): ScopeMap;
578
-
579
557
  /**
580
558
  * Collect every unique scope field name declared across all collections.
581
559
  *
@@ -864,4 +842,4 @@ interface ProtoOutput {
864
842
  */
865
843
  declare function generateProtoDefinitions(schema: SchemaDefinition): ProtoOutput;
866
844
 
867
- export { APPLY_FAILURE_CODES, APPLY_RESULTS, type ApplyFailureReason, type ApplyResult, ArrayFieldBuilder, AtomicOp, type AtomicOpSentinel, AtomicOpType, CausalTracker, ClockDriftError, CollectionDefinition, type CollectionInput, type ConstraintInput, CustomResolver, EnumFieldBuilder, FieldBuilder, FieldKind, type FieldKindToType, type InferFieldType, type InferInsertInput, type InferRecord, type InferUpdateInput, KORA_ERROR_FIX_SUGGESTIONS, KoraError, MergeConflictError, MigrationDefinition, MigrationRollbackError, MigrationStep, Operation, OperationError, type OperationLog, type OperationTransform, OperationType, type ProtoOutput, RandomSource, RelationDefinition, type RelationInput, type ReversibleMigration, SchemaDefinition, type SchemaInput, SchemaValidationError, type ScopeMap, StateMachineConstraint, type StateMachineInput, StorageError, SyncError, TransitionMap, TransitionValidationResult, type TypedSchemaDefinition, VersionVector, advanceVector, applyOperationTransforms, buildScopeMap, buildStateMachineConstraints, canAutoRollback, collectSchemaScopeFields, collectSchemaScopeValueKeys, computeDelta, createReversibleMigration, createVersionVector, defaultApplyFailureReason, defaultSequenceFormat, defineSchema, deserializeVector, dominates, extractScopeValuesFromClaims, extractTimestamp, formatSequenceValue, generateFullDDL, generateProtoDefinitions, generateRollbackSteps, generateSQL, generateUUIDv7, getCollectionScopeBindings, getKoraErrorFix, getTransitionMap, hasSchemaSyncRules, isApplyFailure, isAtomicOp, isCollectionSyncScoped, isValidUUIDv7, mergeVectors, migrationStepsToSQL, op, resolveAtomicOp, rollbackStepsToSQL, serializeVector, toAtomicOp, validateRecord, validateTransition, vectorsEqual };
845
+ export { APPLY_FAILURE_CODES, APPLY_RESULTS, AppNotReadyError, type ApplyFailureReason, type ApplyResult, ArrayFieldBuilder, AtomicOp, type AtomicOpSentinel, AtomicOpType, CausalTracker, ClockDriftError, CollectionDefinition, type CollectionInput, type ConstraintInput, CustomResolver, EnumFieldBuilder, FieldBuilder, FieldKind, type FieldKindToType, type InferFieldType, type InferInsertInput, type InferRecord, type InferUpdateInput, KORA_ERROR_FIX_SUGGESTIONS, KoraError, MergeConflictError, MigrationDefinition, MigrationRollbackError, MigrationStep, Operation, OperationError, type OperationLog, type OperationTransform, OperationType, type ProtoOutput, RandomSource, RelationDefinition, type RelationInput, type ReversibleMigration, SchemaDefinition, type SchemaInput, SchemaValidationError, StateMachineConstraint, type StateMachineInput, StorageError, SyncError, TransitionMap, TransitionValidationResult, type TypedSchemaDefinition, VersionVector, advanceVector, applyOperationTransforms, buildStateMachineConstraints, canAutoRollback, collectSchemaScopeFields, collectSchemaScopeValueKeys, computeDelta, createReversibleMigration, createVersionVector, defaultApplyFailureReason, defaultSequenceFormat, defineSchema, deserializeVector, dominates, extractScopeValuesFromClaims, extractTimestamp, formatSequenceValue, generateFullDDL, generateProtoDefinitions, generateRollbackSteps, generateSQL, generateUUIDv7, getCollectionScopeBindings, getKoraErrorFix, getTransitionMap, hasSchemaSyncRules, isApplyFailure, isAtomicOp, isCollectionSyncScoped, isValidUUIDv7, mergeVectors, migrationStepsToSQL, op, resolveAtomicOp, rollbackStepsToSQL, serializeVector, toAtomicOp, validateRecord, validateTransition, vectorsEqual };
package/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import {
2
+ AppNotReadyError,
2
3
  ClockDriftError,
3
4
  HybridLogicalClock,
4
5
  KORA_ERROR_FIX_SUGGESTIONS,
@@ -13,7 +14,7 @@ import {
13
14
  isValidOperation,
14
15
  topologicalSort,
15
16
  verifyOperationIntegrity
16
- } from "./chunk-H4FXU5OP.js";
17
+ } from "./chunk-3VIOZT7D.js";
17
18
 
18
19
  // src/types.ts
19
20
  var MERGE_STRATEGIES = [
@@ -1906,6 +1907,7 @@ function generateProtoDefinitions(schema) {
1906
1907
  export {
1907
1908
  APPLY_FAILURE_CODES,
1908
1909
  APPLY_RESULTS,
1910
+ AppNotReadyError,
1909
1911
  ArrayFieldBuilder,
1910
1912
  CONNECTION_QUALITIES,
1911
1913
  CausalTracker,