@proseql/core 0.1.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/LICENSE +21 -0
- package/dist/errors/crud-errors.d.ts +98 -0
- package/dist/errors/crud-errors.d.ts.map +1 -0
- package/dist/errors/crud-errors.js +23 -0
- package/dist/errors/crud-errors.js.map +1 -0
- package/dist/errors/index.d.ts +16 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/errors/index.js +12 -0
- package/dist/errors/index.js.map +1 -0
- package/dist/errors/migration-errors.d.ts +22 -0
- package/dist/errors/migration-errors.d.ts.map +1 -0
- package/dist/errors/migration-errors.js +14 -0
- package/dist/errors/migration-errors.js.map +1 -0
- package/dist/errors/plugin-errors.d.ts +15 -0
- package/dist/errors/plugin-errors.d.ts.map +1 -0
- package/dist/errors/plugin-errors.js +11 -0
- package/dist/errors/plugin-errors.js.map +1 -0
- package/dist/errors/query-errors.d.ts +31 -0
- package/dist/errors/query-errors.d.ts.map +1 -0
- package/dist/errors/query-errors.js +11 -0
- package/dist/errors/query-errors.js.map +1 -0
- package/dist/errors/storage-errors.d.ts +30 -0
- package/dist/errors/storage-errors.d.ts.map +1 -0
- package/dist/errors/storage-errors.js +11 -0
- package/dist/errors/storage-errors.js.map +1 -0
- package/dist/factories/crud-factory-with-relationships.d.ts +28 -0
- package/dist/factories/crud-factory-with-relationships.d.ts.map +1 -0
- package/dist/factories/crud-factory-with-relationships.js +8 -0
- package/dist/factories/crud-factory-with-relationships.js.map +1 -0
- package/dist/factories/crud-factory.d.ts +25 -0
- package/dist/factories/crud-factory.d.ts.map +1 -0
- package/dist/factories/crud-factory.js +8 -0
- package/dist/factories/crud-factory.js.map +1 -0
- package/dist/factories/database-effect.d.ts +241 -0
- package/dist/factories/database-effect.d.ts.map +1 -0
- package/dist/factories/database-effect.js +859 -0
- package/dist/factories/database-effect.js.map +1 -0
- package/dist/hooks/hook-runner.d.ts +60 -0
- package/dist/hooks/hook-runner.d.ts.map +1 -0
- package/dist/hooks/hook-runner.js +107 -0
- package/dist/hooks/hook-runner.js.map +1 -0
- package/dist/index.d.ts +84 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +110 -0
- package/dist/index.js.map +1 -0
- package/dist/indexes/index-lookup.d.ts +33 -0
- package/dist/indexes/index-lookup.d.ts.map +1 -0
- package/dist/indexes/index-lookup.js +180 -0
- package/dist/indexes/index-lookup.js.map +1 -0
- package/dist/indexes/index-manager.d.ts +118 -0
- package/dist/indexes/index-manager.d.ts.map +1 -0
- package/dist/indexes/index-manager.js +345 -0
- package/dist/indexes/index-manager.js.map +1 -0
- package/dist/indexes/search-index.d.ts +179 -0
- package/dist/indexes/search-index.d.ts.map +1 -0
- package/dist/indexes/search-index.js +405 -0
- package/dist/indexes/search-index.js.map +1 -0
- package/dist/migrations/migration-runner.d.ts +70 -0
- package/dist/migrations/migration-runner.d.ts.map +1 -0
- package/dist/migrations/migration-runner.js +271 -0
- package/dist/migrations/migration-runner.js.map +1 -0
- package/dist/migrations/migration-types.d.ts +63 -0
- package/dist/migrations/migration-types.d.ts.map +1 -0
- package/dist/migrations/migration-types.js +5 -0
- package/dist/migrations/migration-types.js.map +1 -0
- package/dist/operations/crud/create-with-relationships.d.ts +44 -0
- package/dist/operations/crud/create-with-relationships.d.ts.map +1 -0
- package/dist/operations/crud/create-with-relationships.js +483 -0
- package/dist/operations/crud/create-with-relationships.js.map +1 -0
- package/dist/operations/crud/create.d.ts +48 -0
- package/dist/operations/crud/create.d.ts.map +1 -0
- package/dist/operations/crud/create.js +333 -0
- package/dist/operations/crud/create.js.map +1 -0
- package/dist/operations/crud/delete-with-relationships.d.ts +63 -0
- package/dist/operations/crud/delete-with-relationships.d.ts.map +1 -0
- package/dist/operations/crud/delete-with-relationships.js +395 -0
- package/dist/operations/crud/delete-with-relationships.js.map +1 -0
- package/dist/operations/crud/delete.d.ts +58 -0
- package/dist/operations/crud/delete.d.ts.map +1 -0
- package/dist/operations/crud/delete.js +267 -0
- package/dist/operations/crud/delete.js.map +1 -0
- package/dist/operations/crud/unique-check.d.ts +114 -0
- package/dist/operations/crud/unique-check.d.ts.map +1 -0
- package/dist/operations/crud/unique-check.js +383 -0
- package/dist/operations/crud/unique-check.js.map +1 -0
- package/dist/operations/crud/update-with-relationships.d.ts +45 -0
- package/dist/operations/crud/update-with-relationships.d.ts.map +1 -0
- package/dist/operations/crud/update-with-relationships.js +516 -0
- package/dist/operations/crud/update-with-relationships.js.map +1 -0
- package/dist/operations/crud/update.d.ts +91 -0
- package/dist/operations/crud/update.d.ts.map +1 -0
- package/dist/operations/crud/update.js +505 -0
- package/dist/operations/crud/update.js.map +1 -0
- package/dist/operations/crud/upsert.d.ts +52 -0
- package/dist/operations/crud/upsert.d.ts.map +1 -0
- package/dist/operations/crud/upsert.js +386 -0
- package/dist/operations/crud/upsert.js.map +1 -0
- package/dist/operations/query/aggregate.d.ts +30 -0
- package/dist/operations/query/aggregate.d.ts.map +1 -0
- package/dist/operations/query/aggregate.js +227 -0
- package/dist/operations/query/aggregate.js.map +1 -0
- package/dist/operations/query/cursor-stream.d.ts +18 -0
- package/dist/operations/query/cursor-stream.d.ts.map +1 -0
- package/dist/operations/query/cursor-stream.js +199 -0
- package/dist/operations/query/cursor-stream.js.map +1 -0
- package/dist/operations/query/filter-stream.d.ts +12 -0
- package/dist/operations/query/filter-stream.d.ts.map +1 -0
- package/dist/operations/query/filter-stream.js +167 -0
- package/dist/operations/query/filter-stream.js.map +1 -0
- package/dist/operations/query/filter.d.ts +13 -0
- package/dist/operations/query/filter.d.ts.map +1 -0
- package/dist/operations/query/filter.js +267 -0
- package/dist/operations/query/filter.js.map +1 -0
- package/dist/operations/query/paginate-stream.d.ts +11 -0
- package/dist/operations/query/paginate-stream.d.ts.map +1 -0
- package/dist/operations/query/paginate-stream.js +22 -0
- package/dist/operations/query/paginate-stream.js.map +1 -0
- package/dist/operations/query/query-helpers.d.ts +14 -0
- package/dist/operations/query/query-helpers.d.ts.map +1 -0
- package/dist/operations/query/query-helpers.js +22 -0
- package/dist/operations/query/query-helpers.js.map +1 -0
- package/dist/operations/query/resolve-computed.d.ts +142 -0
- package/dist/operations/query/resolve-computed.d.ts.map +1 -0
- package/dist/operations/query/resolve-computed.js +197 -0
- package/dist/operations/query/resolve-computed.js.map +1 -0
- package/dist/operations/query/search.d.ts +110 -0
- package/dist/operations/query/search.d.ts.map +1 -0
- package/dist/operations/query/search.js +188 -0
- package/dist/operations/query/search.js.map +1 -0
- package/dist/operations/query/select-stream.d.ts +27 -0
- package/dist/operations/query/select-stream.d.ts.map +1 -0
- package/dist/operations/query/select-stream.js +88 -0
- package/dist/operations/query/select-stream.js.map +1 -0
- package/dist/operations/query/select.d.ts +54 -0
- package/dist/operations/query/select.d.ts.map +1 -0
- package/dist/operations/query/select.js +159 -0
- package/dist/operations/query/select.js.map +1 -0
- package/dist/operations/query/sort-stream.d.ts +46 -0
- package/dist/operations/query/sort-stream.d.ts.map +1 -0
- package/dist/operations/query/sort-stream.js +158 -0
- package/dist/operations/query/sort-stream.js.map +1 -0
- package/dist/operations/query/sort.d.ts +9 -0
- package/dist/operations/query/sort.d.ts.map +1 -0
- package/dist/operations/query/sort.js +58 -0
- package/dist/operations/query/sort.js.map +1 -0
- package/dist/operations/relationships/populate-stream.d.ts +29 -0
- package/dist/operations/relationships/populate-stream.d.ts.map +1 -0
- package/dist/operations/relationships/populate-stream.js +159 -0
- package/dist/operations/relationships/populate-stream.js.map +1 -0
- package/dist/operations/relationships/populate.d.ts +15 -0
- package/dist/operations/relationships/populate.d.ts.map +1 -0
- package/dist/operations/relationships/populate.js +228 -0
- package/dist/operations/relationships/populate.js.map +1 -0
- package/dist/plugins/plugin-hooks.d.ts +25 -0
- package/dist/plugins/plugin-hooks.d.ts.map +1 -0
- package/dist/plugins/plugin-hooks.js +64 -0
- package/dist/plugins/plugin-hooks.js.map +1 -0
- package/dist/plugins/plugin-registry.d.ts +26 -0
- package/dist/plugins/plugin-registry.d.ts.map +1 -0
- package/dist/plugins/plugin-registry.js +150 -0
- package/dist/plugins/plugin-registry.js.map +1 -0
- package/dist/plugins/plugin-types.d.ts +95 -0
- package/dist/plugins/plugin-types.d.ts.map +1 -0
- package/dist/plugins/plugin-types.js +6 -0
- package/dist/plugins/plugin-types.js.map +1 -0
- package/dist/plugins/plugin-validation.d.ts +49 -0
- package/dist/plugins/plugin-validation.d.ts.map +1 -0
- package/dist/plugins/plugin-validation.js +295 -0
- package/dist/plugins/plugin-validation.js.map +1 -0
- package/dist/reactive/change-event.d.ts +44 -0
- package/dist/reactive/change-event.d.ts.map +1 -0
- package/dist/reactive/change-event.js +49 -0
- package/dist/reactive/change-event.js.map +1 -0
- package/dist/reactive/change-pubsub.d.ts +32 -0
- package/dist/reactive/change-pubsub.d.ts.map +1 -0
- package/dist/reactive/change-pubsub.js +31 -0
- package/dist/reactive/change-pubsub.js.map +1 -0
- package/dist/reactive/evaluate-query.d.ts +62 -0
- package/dist/reactive/evaluate-query.d.ts.map +1 -0
- package/dist/reactive/evaluate-query.js +57 -0
- package/dist/reactive/evaluate-query.js.map +1 -0
- package/dist/reactive/watch-by-id.d.ts +53 -0
- package/dist/reactive/watch-by-id.d.ts.map +1 -0
- package/dist/reactive/watch-by-id.js +55 -0
- package/dist/reactive/watch-by-id.js.map +1 -0
- package/dist/reactive/watch.d.ts +78 -0
- package/dist/reactive/watch.d.ts.map +1 -0
- package/dist/reactive/watch.js +133 -0
- package/dist/reactive/watch.js.map +1 -0
- package/dist/serializers/codecs/hjson.d.ts +33 -0
- package/dist/serializers/codecs/hjson.d.ts.map +1 -0
- package/dist/serializers/codecs/hjson.js +40 -0
- package/dist/serializers/codecs/hjson.js.map +1 -0
- package/dist/serializers/codecs/json.d.ts +22 -0
- package/dist/serializers/codecs/json.d.ts.map +1 -0
- package/dist/serializers/codecs/json.js +28 -0
- package/dist/serializers/codecs/json.js.map +1 -0
- package/dist/serializers/codecs/json5.d.ts +26 -0
- package/dist/serializers/codecs/json5.d.ts.map +1 -0
- package/dist/serializers/codecs/json5.js +33 -0
- package/dist/serializers/codecs/json5.js.map +1 -0
- package/dist/serializers/codecs/jsonc.d.ts +29 -0
- package/dist/serializers/codecs/jsonc.d.ts.map +1 -0
- package/dist/serializers/codecs/jsonc.js +38 -0
- package/dist/serializers/codecs/jsonc.js.map +1 -0
- package/dist/serializers/codecs/jsonl.d.ts +17 -0
- package/dist/serializers/codecs/jsonl.d.ts.map +1 -0
- package/dist/serializers/codecs/jsonl.js +31 -0
- package/dist/serializers/codecs/jsonl.js.map +1 -0
- package/dist/serializers/codecs/prose.d.ts +419 -0
- package/dist/serializers/codecs/prose.d.ts.map +1 -0
- package/dist/serializers/codecs/prose.js +1060 -0
- package/dist/serializers/codecs/prose.js.map +1 -0
- package/dist/serializers/codecs/toml.d.ts +23 -0
- package/dist/serializers/codecs/toml.d.ts.map +1 -0
- package/dist/serializers/codecs/toml.js +66 -0
- package/dist/serializers/codecs/toml.js.map +1 -0
- package/dist/serializers/codecs/toon.d.ts +20 -0
- package/dist/serializers/codecs/toon.d.ts.map +1 -0
- package/dist/serializers/codecs/toon.js +33 -0
- package/dist/serializers/codecs/toon.js.map +1 -0
- package/dist/serializers/codecs/yaml.d.ts +24 -0
- package/dist/serializers/codecs/yaml.d.ts.map +1 -0
- package/dist/serializers/codecs/yaml.js +31 -0
- package/dist/serializers/codecs/yaml.js.map +1 -0
- package/dist/serializers/format-codec.d.ts +53 -0
- package/dist/serializers/format-codec.d.ts.map +1 -0
- package/dist/serializers/format-codec.js +148 -0
- package/dist/serializers/format-codec.js.map +1 -0
- package/dist/serializers/presets.d.ts +48 -0
- package/dist/serializers/presets.d.ts.map +1 -0
- package/dist/serializers/presets.js +72 -0
- package/dist/serializers/presets.js.map +1 -0
- package/dist/serializers/serializer-service.d.ts +11 -0
- package/dist/serializers/serializer-service.d.ts.map +1 -0
- package/dist/serializers/serializer-service.js +4 -0
- package/dist/serializers/serializer-service.js.map +1 -0
- package/dist/state/collection-state.d.ts +19 -0
- package/dist/state/collection-state.d.ts.map +1 -0
- package/dist/state/collection-state.js +15 -0
- package/dist/state/collection-state.js.map +1 -0
- package/dist/state/state-operations.d.ts +38 -0
- package/dist/state/state-operations.d.ts.map +1 -0
- package/dist/state/state-operations.js +65 -0
- package/dist/state/state-operations.js.map +1 -0
- package/dist/storage/in-memory-adapter-layer.d.ts +16 -0
- package/dist/storage/in-memory-adapter-layer.d.ts.map +1 -0
- package/dist/storage/in-memory-adapter-layer.js +81 -0
- package/dist/storage/in-memory-adapter-layer.js.map +1 -0
- package/dist/storage/persistence-effect.d.ts +244 -0
- package/dist/storage/persistence-effect.d.ts.map +1 -0
- package/dist/storage/persistence-effect.js +551 -0
- package/dist/storage/persistence-effect.js.map +1 -0
- package/dist/storage/storage-service.d.ts +22 -0
- package/dist/storage/storage-service.d.ts.map +1 -0
- package/dist/storage/storage-service.js +4 -0
- package/dist/storage/storage-service.js.map +1 -0
- package/dist/storage/transforms.d.ts +183 -0
- package/dist/storage/transforms.d.ts.map +1 -0
- package/dist/storage/transforms.js +263 -0
- package/dist/storage/transforms.js.map +1 -0
- package/dist/transactions/transaction.d.ts +87 -0
- package/dist/transactions/transaction.d.ts.map +1 -0
- package/dist/transactions/transaction.js +240 -0
- package/dist/transactions/transaction.js.map +1 -0
- package/dist/types/aggregate-types.d.ts +73 -0
- package/dist/types/aggregate-types.d.ts.map +1 -0
- package/dist/types/aggregate-types.js +14 -0
- package/dist/types/aggregate-types.js.map +1 -0
- package/dist/types/computed-types.d.ts +71 -0
- package/dist/types/computed-types.d.ts.map +1 -0
- package/dist/types/computed-types.js +8 -0
- package/dist/types/computed-types.js.map +1 -0
- package/dist/types/crud-relationship-types.d.ts +180 -0
- package/dist/types/crud-relationship-types.d.ts.map +1 -0
- package/dist/types/crud-relationship-types.js +17 -0
- package/dist/types/crud-relationship-types.js.map +1 -0
- package/dist/types/crud-types.d.ts +343 -0
- package/dist/types/crud-types.d.ts.map +1 -0
- package/dist/types/crud-types.js +43 -0
- package/dist/types/crud-types.js.map +1 -0
- package/dist/types/cursor-types.d.ts +52 -0
- package/dist/types/cursor-types.d.ts.map +1 -0
- package/dist/types/cursor-types.js +2 -0
- package/dist/types/cursor-types.js.map +1 -0
- package/dist/types/database-config-types.d.ts +196 -0
- package/dist/types/database-config-types.d.ts.map +1 -0
- package/dist/types/database-config-types.js +11 -0
- package/dist/types/database-config-types.js.map +1 -0
- package/dist/types/hook-types.d.ts +158 -0
- package/dist/types/hook-types.d.ts.map +1 -0
- package/dist/types/hook-types.js +6 -0
- package/dist/types/hook-types.js.map +1 -0
- package/dist/types/index-types.d.ts +42 -0
- package/dist/types/index-types.d.ts.map +1 -0
- package/dist/types/index-types.js +8 -0
- package/dist/types/index-types.js.map +1 -0
- package/dist/types/operators.d.ts +5 -0
- package/dist/types/operators.d.ts.map +1 -0
- package/dist/types/operators.js +297 -0
- package/dist/types/operators.js.map +1 -0
- package/dist/types/query-overloads.d.ts +54 -0
- package/dist/types/query-overloads.d.ts.map +1 -0
- package/dist/types/query-overloads.js +3 -0
- package/dist/types/query-overloads.js.map +1 -0
- package/dist/types/reactive-types.d.ts +75 -0
- package/dist/types/reactive-types.d.ts.map +1 -0
- package/dist/types/reactive-types.js +7 -0
- package/dist/types/reactive-types.js.map +1 -0
- package/dist/types/schema-types.d.ts +56 -0
- package/dist/types/schema-types.d.ts.map +1 -0
- package/dist/types/schema-types.js +8 -0
- package/dist/types/schema-types.js.map +1 -0
- package/dist/types/search-types.d.ts +82 -0
- package/dist/types/search-types.d.ts.map +1 -0
- package/dist/types/search-types.js +110 -0
- package/dist/types/search-types.js.map +1 -0
- package/dist/types/types.d.ts +286 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/types.js +2 -0
- package/dist/types/types.js.map +1 -0
- package/dist/utils/id-generator.d.ts +97 -0
- package/dist/utils/id-generator.d.ts.map +1 -0
- package/dist/utils/id-generator.js +247 -0
- package/dist/utils/id-generator.js.map +1 -0
- package/dist/utils/nested-path.d.ts +56 -0
- package/dist/utils/nested-path.d.ts.map +1 -0
- package/dist/utils/nested-path.js +119 -0
- package/dist/utils/nested-path.js.map +1 -0
- package/dist/utils/path.d.ts +16 -0
- package/dist/utils/path.d.ts.map +1 -0
- package/dist/utils/path.js +24 -0
- package/dist/utils/path.js.map +1 -0
- package/dist/validators/foreign-key.d.ts +49 -0
- package/dist/validators/foreign-key.d.ts.map +1 -0
- package/dist/validators/foreign-key.js +153 -0
- package/dist/validators/foreign-key.js.map +1 -0
- package/dist/validators/schema-validator.d.ts +19 -0
- package/dist/validators/schema-validator.d.ts.map +1 -0
- package/dist/validators/schema-validator.js +34 -0
- package/dist/validators/schema-validator.js.map +1 -0
- package/package.json +57 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Reactive query types for live subscriptions to data changes.
|
|
3
|
+
* Enables watch() and watchById() methods that emit streams of results
|
|
4
|
+
* whenever the underlying data changes.
|
|
5
|
+
*/
|
|
6
|
+
import type { PopulateConfig, SelectConfig, SortConfig, WhereClause } from "./types.js";
|
|
7
|
+
/**
|
|
8
|
+
* Represents a mutation event that occurred on a collection.
|
|
9
|
+
* Published by CRUD operations and file watchers to notify reactive subscriptions.
|
|
10
|
+
*
|
|
11
|
+
* - "create": One or more entities were created
|
|
12
|
+
* - "update": One or more entities were updated
|
|
13
|
+
* - "delete": One or more entities were deleted
|
|
14
|
+
* - "reload": Data was reloaded from disk (file watcher detected external change)
|
|
15
|
+
*/
|
|
16
|
+
export interface ChangeEvent {
|
|
17
|
+
readonly collection: string;
|
|
18
|
+
readonly operation: "create" | "update" | "delete" | "reload";
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Configuration for reactive watch queries.
|
|
22
|
+
* Mirrors QueryConfig but excludes cursor pagination (watches are continuous streams).
|
|
23
|
+
*
|
|
24
|
+
* @template T - The entity type being watched
|
|
25
|
+
* @template Relations - Relationship definitions for the collection
|
|
26
|
+
* @template DB - The full database type (for cross-collection type resolution)
|
|
27
|
+
*/
|
|
28
|
+
export type WatchConfig<T, Relations extends Record<string, unknown> = Record<string, never>, DB = unknown> = {
|
|
29
|
+
readonly where?: WhereClause<T, Relations, DB>;
|
|
30
|
+
readonly sort?: SortConfig<T, Relations, Record<string, never>, DB>;
|
|
31
|
+
readonly select?: SelectConfig<T, Relations, DB>;
|
|
32
|
+
readonly limit?: number;
|
|
33
|
+
readonly offset?: number;
|
|
34
|
+
} | {
|
|
35
|
+
readonly populate: PopulateConfig<Relations, DB>;
|
|
36
|
+
readonly where?: WhereClause<T, Relations, DB>;
|
|
37
|
+
readonly sort?: SortConfig<T, Relations, {
|
|
38
|
+
populate: PopulateConfig<Relations, DB>;
|
|
39
|
+
}, DB>;
|
|
40
|
+
readonly select?: SelectConfig<T, Relations, DB>;
|
|
41
|
+
readonly limit?: number;
|
|
42
|
+
readonly offset?: number;
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Signature for the watch() method on collections.
|
|
46
|
+
*
|
|
47
|
+
* Creates a reactive subscription that emits the current result set immediately,
|
|
48
|
+
* then re-emits whenever the underlying data changes (create/update/delete/reload).
|
|
49
|
+
*
|
|
50
|
+
* The stream is scoped: it subscribes to change notifications on creation and
|
|
51
|
+
* automatically unsubscribes when the scope closes or the stream is interrupted.
|
|
52
|
+
*
|
|
53
|
+
* @template T - The entity type being watched
|
|
54
|
+
* @template Relations - Relationship definitions for the collection
|
|
55
|
+
* @template DB - The full database type (for cross-collection type resolution)
|
|
56
|
+
* @param config - Optional query configuration (where, sort, select, limit, offset, populate)
|
|
57
|
+
* @returns A scoped Effect that produces a Stream of result arrays
|
|
58
|
+
*/
|
|
59
|
+
export type WatchMethod<T, Relations extends Record<string, unknown> = Record<string, never>, DB = unknown> = <C extends WatchConfig<T, Relations, DB>>(config?: C) => import("effect").Effect.Effect<import("effect").Stream.Stream<ReadonlyArray<T>, never, never>, never, import("effect").Scope.Scope>;
|
|
60
|
+
/**
|
|
61
|
+
* Signature for the watchById() method on collections.
|
|
62
|
+
*
|
|
63
|
+
* Creates a reactive subscription for a single entity by ID.
|
|
64
|
+
* Emits the entity immediately if it exists (or null if not), then re-emits
|
|
65
|
+
* whenever the entity is created, updated, or deleted.
|
|
66
|
+
*
|
|
67
|
+
* The stream is scoped: it subscribes to change notifications on creation and
|
|
68
|
+
* automatically unsubscribes when the scope closes or the stream is interrupted.
|
|
69
|
+
*
|
|
70
|
+
* @template T - The entity type being watched
|
|
71
|
+
* @param id - The entity ID to watch
|
|
72
|
+
* @returns A scoped Effect that produces a Stream of T | null
|
|
73
|
+
*/
|
|
74
|
+
export type WatchByIdMethod<T> = (id: string) => import("effect").Effect.Effect<import("effect").Stream.Stream<T | null, never, never>, never, import("effect").Scope.Scope>;
|
|
75
|
+
//# sourceMappingURL=reactive-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reactive-types.d.ts","sourceRoot":"","sources":["../../src/types/reactive-types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EACX,cAAc,EACd,YAAY,EACZ,UAAU,EACV,WAAW,EACX,MAAM,YAAY,CAAC;AAMpB;;;;;;;;GAQG;AACH,MAAM,WAAW,WAAW;IAC3B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,SAAS,EAAE,QAAQ,GAAG,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAC;CAC9D;AAMD;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,CACtB,CAAC,EACD,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EACjE,EAAE,GAAG,OAAO,IAEX;IACA,QAAQ,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC,CAAC,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC;IAC/C,QAAQ,CAAC,IAAI,CAAC,EAAE,UAAU,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC;IACpE,QAAQ,CAAC,MAAM,CAAC,EAAE,YAAY,CAAC,CAAC,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC;IACjD,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CACxB,GAED;IACA,QAAQ,CAAC,QAAQ,EAAE,cAAc,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;IACjD,QAAQ,CAAC,KAAK,CAAC,EAAE,WAAW,CAAC,CAAC,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC;IAC/C,QAAQ,CAAC,IAAI,CAAC,EAAE,UAAU,CACzB,CAAC,EACD,SAAS,EACT;QAAE,QAAQ,EAAE,cAAc,CAAC,SAAS,EAAE,EAAE,CAAC,CAAA;KAAE,EAC3C,EAAE,CACF,CAAC;IACF,QAAQ,CAAC,MAAM,CAAC,EAAE,YAAY,CAAC,CAAC,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC;IACjD,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAMJ;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,WAAW,CACtB,CAAC,EACD,SAAS,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,EACjE,EAAE,GAAG,OAAO,IACT,CAAC,CAAC,SAAS,WAAW,CAAC,CAAC,EAAE,SAAS,EAAE,EAAE,CAAC,EAC3C,MAAM,CAAC,EAAE,CAAC,KACN,OAAO,QAAQ,EAAE,MAAM,CAAC,MAAM,CAClC,OAAO,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,KAAK,CAAC,EAC9D,KAAK,EACL,OAAO,QAAQ,EAAE,KAAK,CAAC,KAAK,CAC5B,CAAC;AAEF;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,IAAI,CAChC,EAAE,EAAE,MAAM,KACN,OAAO,QAAQ,EAAE,MAAM,CAAC,MAAM,CAClC,OAAO,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,EACtD,KAAK,EACL,OAAO,QAAQ,EAAE,KAAK,CAAC,KAAK,CAC5B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reactive-types.js","sourceRoot":"","sources":["../../src/types/reactive-types.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Effect Schema type utilities for the database.
|
|
3
|
+
*
|
|
4
|
+
* Provides helper types for working with Effect Schema in entity definitions.
|
|
5
|
+
* All entity schemas are Schema.Struct-based and support bidirectional encode/decode.
|
|
6
|
+
*/
|
|
7
|
+
import type { Schema } from "effect";
|
|
8
|
+
/**
|
|
9
|
+
* Constraint for entity schemas: the decoded Type must include `{ readonly id: string }`.
|
|
10
|
+
* The Encoded and Context parameters are left open so schemas with transformations
|
|
11
|
+
* (e.g., DateFromString) or context requirements are accepted.
|
|
12
|
+
*
|
|
13
|
+
* Usage:
|
|
14
|
+
* ```ts
|
|
15
|
+
* const UserSchema = Schema.Struct({
|
|
16
|
+
* id: Schema.String,
|
|
17
|
+
* name: Schema.String,
|
|
18
|
+
* age: Schema.Number,
|
|
19
|
+
* })
|
|
20
|
+
*
|
|
21
|
+
* // Satisfies EntitySchema because Type includes { id: string }
|
|
22
|
+
* type Check = typeof UserSchema extends EntitySchema<Schema.Schema.Type<typeof UserSchema>> ? true : false
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export type EntitySchema<T extends {
|
|
26
|
+
readonly id: string;
|
|
27
|
+
}> = Schema.Schema<T, unknown, never>;
|
|
28
|
+
/**
|
|
29
|
+
* Extract the runtime (decoded) type from a schema.
|
|
30
|
+
* This is the type that queries return and CRUD operations work with.
|
|
31
|
+
*
|
|
32
|
+
* Usage:
|
|
33
|
+
* ```ts
|
|
34
|
+
* const UserSchema = Schema.Struct({ id: Schema.String, name: Schema.String })
|
|
35
|
+
* type User = InferEntity<typeof UserSchema>
|
|
36
|
+
* // => { readonly id: string; readonly name: string }
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export type InferEntity<S extends Schema.Schema.All> = Schema.Schema.Type<S>;
|
|
40
|
+
/**
|
|
41
|
+
* Extract the encoded (on-disk) type from a schema.
|
|
42
|
+
* This is the type stored in JSON/YAML files.
|
|
43
|
+
*
|
|
44
|
+
* For simple schemas (String, Number, etc.) this matches the runtime type.
|
|
45
|
+
* For schemas with transformations (e.g., Schema.DateFromSelf) the encoded
|
|
46
|
+
* type may differ (e.g., string on disk vs Date at runtime).
|
|
47
|
+
*
|
|
48
|
+
* Usage:
|
|
49
|
+
* ```ts
|
|
50
|
+
* const UserSchema = Schema.Struct({ id: Schema.String, name: Schema.String })
|
|
51
|
+
* type UserEncoded = InferEncoded<typeof UserSchema>
|
|
52
|
+
* // => { readonly id: string; readonly name: string }
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export type InferEncoded<S extends Schema.Schema.All> = Schema.Schema.Encoded<S>;
|
|
56
|
+
//# sourceMappingURL=schema-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-types.d.ts","sourceRoot":"","sources":["../../src/types/schema-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS;IAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAA;CAAE,IAAI,MAAM,CAAC,MAAM,CAC1E,CAAC,EACD,OAAO,EACP,KAAK,CACL,CAAC;AAEF;;;;;;;;;;GAUG;AACH,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,CAAC,GAAG,IAAI,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAE7E;;;;;;;;;;;;;;GAcG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,MAAM,CAAC,MAAM,CAAC,GAAG,IACnD,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Effect Schema type utilities for the database.
|
|
3
|
+
*
|
|
4
|
+
* Provides helper types for working with Effect Schema in entity definitions.
|
|
5
|
+
* All entity schemas are Schema.Struct-based and support bidirectional encode/decode.
|
|
6
|
+
*/
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=schema-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema-types.js","sourceRoot":"","sources":["../../src/types/schema-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for full-text search functionality.
|
|
3
|
+
*
|
|
4
|
+
* Provides types for search configuration, relevance scoring,
|
|
5
|
+
* and inverted index structures for text search operations.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Configuration for multi-field search queries.
|
|
9
|
+
* Used with the top-level $search operator in where clauses.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* // Search across specific fields
|
|
14
|
+
* const config: SearchConfig = {
|
|
15
|
+
* query: "herbert dune",
|
|
16
|
+
* fields: ["title", "author"],
|
|
17
|
+
* }
|
|
18
|
+
*
|
|
19
|
+
* // Search across all string fields (fields omitted)
|
|
20
|
+
* const config2: SearchConfig = {
|
|
21
|
+
* query: "science fiction",
|
|
22
|
+
* }
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export interface SearchConfig {
|
|
26
|
+
/**
|
|
27
|
+
* The search query string.
|
|
28
|
+
* Will be tokenized and matched against field values.
|
|
29
|
+
*/
|
|
30
|
+
readonly query: string;
|
|
31
|
+
/**
|
|
32
|
+
* Optional list of fields to search.
|
|
33
|
+
* If omitted, all string fields on the entity are searched.
|
|
34
|
+
*/
|
|
35
|
+
readonly fields?: ReadonlyArray<string>;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Represents the relevance score for a single entity.
|
|
39
|
+
* Used for ranking search results by relevance.
|
|
40
|
+
*/
|
|
41
|
+
export interface SearchScore {
|
|
42
|
+
/**
|
|
43
|
+
* The ID of the entity this score belongs to.
|
|
44
|
+
*/
|
|
45
|
+
readonly entityId: string;
|
|
46
|
+
/**
|
|
47
|
+
* The computed relevance score.
|
|
48
|
+
* Higher scores indicate better matches.
|
|
49
|
+
* Score of 0 indicates no match.
|
|
50
|
+
*/
|
|
51
|
+
readonly score: number;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Type alias for the inverted index structure used in full-text search.
|
|
55
|
+
*
|
|
56
|
+
* Maps tokens to sets of entity IDs that contain those tokens.
|
|
57
|
+
* This enables fast lookup of candidate entities for a given search term.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```ts
|
|
61
|
+
* // Example index structure:
|
|
62
|
+
* // "dune" -> Set(["book-1", "book-7"])
|
|
63
|
+
* // "gibson" -> Set(["book-3"])
|
|
64
|
+
* // "left" -> Set(["book-2"])
|
|
65
|
+
* ```
|
|
66
|
+
*/
|
|
67
|
+
export type SearchIndexMap = Map<string, Set<string>>;
|
|
68
|
+
/**
|
|
69
|
+
* Key used to store computed search relevance scores on entities.
|
|
70
|
+
* This metadata is attached after filtering and consumed by the sort stage.
|
|
71
|
+
*
|
|
72
|
+
* @internal
|
|
73
|
+
*/
|
|
74
|
+
export declare const SEARCH_SCORE_KEY: "_searchScore";
|
|
75
|
+
/**
|
|
76
|
+
* Common English stop words that can optionally be filtered from search queries.
|
|
77
|
+
* These words are typically too common to be useful for search relevance.
|
|
78
|
+
*
|
|
79
|
+
* Includes: articles, prepositions, conjunctions, and common verbs.
|
|
80
|
+
*/
|
|
81
|
+
export declare const STOP_WORDS: ReadonlySet<string>;
|
|
82
|
+
//# sourceMappingURL=search-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-types.d.ts","sourceRoot":"","sources":["../../src/types/search-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAMH;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,WAAW,YAAY;IAC5B;;;OAGG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAEvB;;;OAGG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;CACxC;AAMD;;;GAGG;AACH,MAAM,WAAW,WAAW;IAC3B;;OAEG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAE1B;;;;OAIG;IACH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACvB;AAMD;;;;;;;;;;;;;GAaG;AACH,MAAM,MAAM,cAAc,GAAG,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC;AAUtD;;;;;GAKG;AACH,eAAO,MAAM,gBAAgB,EAAG,cAAuB,CAAC;AAExD;;;;;GAKG;AACH,eAAO,MAAM,UAAU,EAAE,WAAW,CAAC,MAAM,CAmFzC,CAAC"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for full-text search functionality.
|
|
3
|
+
*
|
|
4
|
+
* Provides types for search configuration, relevance scoring,
|
|
5
|
+
* and inverted index structures for text search operations.
|
|
6
|
+
*/
|
|
7
|
+
// ============================================================================
|
|
8
|
+
// Stop Words
|
|
9
|
+
// ============================================================================
|
|
10
|
+
// ============================================================================
|
|
11
|
+
// Metadata Keys
|
|
12
|
+
// ============================================================================
|
|
13
|
+
/**
|
|
14
|
+
* Key used to store computed search relevance scores on entities.
|
|
15
|
+
* This metadata is attached after filtering and consumed by the sort stage.
|
|
16
|
+
*
|
|
17
|
+
* @internal
|
|
18
|
+
*/
|
|
19
|
+
export const SEARCH_SCORE_KEY = "_searchScore";
|
|
20
|
+
/**
|
|
21
|
+
* Common English stop words that can optionally be filtered from search queries.
|
|
22
|
+
* These words are typically too common to be useful for search relevance.
|
|
23
|
+
*
|
|
24
|
+
* Includes: articles, prepositions, conjunctions, and common verbs.
|
|
25
|
+
*/
|
|
26
|
+
export const STOP_WORDS = new Set([
|
|
27
|
+
// Articles
|
|
28
|
+
"a",
|
|
29
|
+
"an",
|
|
30
|
+
"the",
|
|
31
|
+
// Prepositions
|
|
32
|
+
"at",
|
|
33
|
+
"by",
|
|
34
|
+
"for",
|
|
35
|
+
"from",
|
|
36
|
+
"in",
|
|
37
|
+
"into",
|
|
38
|
+
"of",
|
|
39
|
+
"off",
|
|
40
|
+
"on",
|
|
41
|
+
"onto",
|
|
42
|
+
"out",
|
|
43
|
+
"over",
|
|
44
|
+
"to",
|
|
45
|
+
"up",
|
|
46
|
+
"with",
|
|
47
|
+
// Conjunctions
|
|
48
|
+
"and",
|
|
49
|
+
"but",
|
|
50
|
+
"or",
|
|
51
|
+
"nor",
|
|
52
|
+
"so",
|
|
53
|
+
"yet",
|
|
54
|
+
// Common verbs
|
|
55
|
+
"am",
|
|
56
|
+
"are",
|
|
57
|
+
"be",
|
|
58
|
+
"been",
|
|
59
|
+
"being",
|
|
60
|
+
"did",
|
|
61
|
+
"do",
|
|
62
|
+
"does",
|
|
63
|
+
"doing",
|
|
64
|
+
"done",
|
|
65
|
+
"had",
|
|
66
|
+
"has",
|
|
67
|
+
"have",
|
|
68
|
+
"having",
|
|
69
|
+
"is",
|
|
70
|
+
"it",
|
|
71
|
+
"its",
|
|
72
|
+
"was",
|
|
73
|
+
"were",
|
|
74
|
+
// Pronouns
|
|
75
|
+
"he",
|
|
76
|
+
"her",
|
|
77
|
+
"him",
|
|
78
|
+
"his",
|
|
79
|
+
"i",
|
|
80
|
+
"me",
|
|
81
|
+
"my",
|
|
82
|
+
"she",
|
|
83
|
+
"that",
|
|
84
|
+
"them",
|
|
85
|
+
"they",
|
|
86
|
+
"this",
|
|
87
|
+
"us",
|
|
88
|
+
"we",
|
|
89
|
+
"what",
|
|
90
|
+
"which",
|
|
91
|
+
"who",
|
|
92
|
+
"you",
|
|
93
|
+
"your",
|
|
94
|
+
// Other common words
|
|
95
|
+
"as",
|
|
96
|
+
"if",
|
|
97
|
+
"not",
|
|
98
|
+
"no",
|
|
99
|
+
"yes",
|
|
100
|
+
"all",
|
|
101
|
+
"any",
|
|
102
|
+
"can",
|
|
103
|
+
"will",
|
|
104
|
+
"just",
|
|
105
|
+
"than",
|
|
106
|
+
"then",
|
|
107
|
+
"too",
|
|
108
|
+
"very",
|
|
109
|
+
]);
|
|
110
|
+
//# sourceMappingURL=search-types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"search-types.js","sourceRoot":"","sources":["../../src/types/search-types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAgFH,+EAA+E;AAC/E,aAAa;AACb,+EAA+E;AAE/E,+EAA+E;AAC/E,gBAAgB;AAChB,+EAA+E;AAE/E;;;;;GAKG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,cAAuB,CAAC;AAExD;;;;;GAKG;AACH,MAAM,CAAC,MAAM,UAAU,GAAwB,IAAI,GAAG,CAAC;IACtD,WAAW;IACX,GAAG;IACH,IAAI;IACJ,KAAK;IACL,eAAe;IACf,IAAI;IACJ,IAAI;IACJ,KAAK;IACL,MAAM;IACN,IAAI;IACJ,MAAM;IACN,IAAI;IACJ,KAAK;IACL,IAAI;IACJ,MAAM;IACN,KAAK;IACL,MAAM;IACN,IAAI;IACJ,IAAI;IACJ,MAAM;IACN,eAAe;IACf,KAAK;IACL,KAAK;IACL,IAAI;IACJ,KAAK;IACL,IAAI;IACJ,KAAK;IACL,eAAe;IACf,IAAI;IACJ,KAAK;IACL,IAAI;IACJ,MAAM;IACN,OAAO;IACP,KAAK;IACL,IAAI;IACJ,MAAM;IACN,OAAO;IACP,MAAM;IACN,KAAK;IACL,KAAK;IACL,MAAM;IACN,QAAQ;IACR,IAAI;IACJ,IAAI;IACJ,KAAK;IACL,KAAK;IACL,MAAM;IACN,WAAW;IACX,IAAI;IACJ,KAAK;IACL,KAAK;IACL,KAAK;IACL,GAAG;IACH,IAAI;IACJ,IAAI;IACJ,KAAK;IACL,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,IAAI;IACJ,IAAI;IACJ,MAAM;IACN,OAAO;IACP,KAAK;IACL,KAAK;IACL,MAAM;IACN,qBAAqB;IACrB,IAAI;IACJ,IAAI;IACJ,KAAK;IACL,IAAI;IACJ,KAAK;IACL,KAAK;IACL,KAAK;IACL,KAAK;IACL,MAAM;IACN,MAAM;IACN,MAAM;IACN,MAAM;IACN,KAAK;IACL,MAAM;CACN,CAAC,CAAC"}
|