@dxos/echo 0.8.4-main.03d5cd7b56 → 0.8.4-main.05e74ebcff

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 (95) hide show
  1. package/LICENSE +102 -5
  2. package/README.md +1 -1
  3. package/dist/lib/neutral/Database.mjs +1 -1
  4. package/dist/lib/neutral/Entity.mjs +6 -6
  5. package/dist/lib/neutral/Feed.mjs +14 -12
  6. package/dist/lib/neutral/Filter.mjs +9 -7
  7. package/dist/lib/neutral/JsonSchema.mjs +4 -4
  8. package/dist/lib/neutral/Migration.mjs +6 -6
  9. package/dist/lib/neutral/Obj.mjs +8 -8
  10. package/dist/lib/neutral/Query.mjs +12 -12
  11. package/dist/lib/neutral/Ref.mjs +6 -4
  12. package/dist/lib/neutral/Relation.mjs +9 -9
  13. package/dist/lib/neutral/Tag.mjs +10 -10
  14. package/dist/lib/neutral/Type.mjs +6 -6
  15. package/dist/lib/neutral/{chunk-6VIJV543.mjs → chunk-APHSOTIX.mjs} +2 -2
  16. package/dist/lib/neutral/{chunk-RF7ZBZ4A.mjs → chunk-APJKDGFL.mjs} +16 -5
  17. package/dist/lib/neutral/chunk-APJKDGFL.mjs.map +7 -0
  18. package/dist/lib/neutral/{chunk-MPAI2MHO.mjs → chunk-BMB7IHGB.mjs} +2 -2
  19. package/dist/lib/neutral/{chunk-SUZMWP3Y.mjs → chunk-FIWO2FZK.mjs} +1 -1
  20. package/dist/lib/neutral/chunk-FIWO2FZK.mjs.map +7 -0
  21. package/dist/lib/neutral/{chunk-SJKBWMJY.mjs → chunk-G54OX4IX.mjs} +34 -18
  22. package/dist/lib/neutral/chunk-G54OX4IX.mjs.map +7 -0
  23. package/dist/lib/neutral/{chunk-FHYIM4RD.mjs → chunk-I2DARWPX.mjs} +1 -1
  24. package/dist/lib/neutral/chunk-I2DARWPX.mjs.map +7 -0
  25. package/dist/lib/neutral/{chunk-SW5CUSBY.mjs → chunk-J54QMAKF.mjs} +5 -4
  26. package/dist/lib/neutral/{chunk-SW5CUSBY.mjs.map → chunk-J54QMAKF.mjs.map} +3 -3
  27. package/dist/lib/neutral/{chunk-QXIANHKU.mjs → chunk-MGSQGHOD.mjs} +8 -8
  28. package/dist/lib/neutral/chunk-MGSQGHOD.mjs.map +7 -0
  29. package/dist/lib/neutral/{chunk-O5LRY6CO.mjs → chunk-MLS7U7AT.mjs} +2 -2
  30. package/dist/lib/neutral/{chunk-VYAGNFSJ.mjs → chunk-N7VOEPSV.mjs} +6 -3
  31. package/dist/lib/neutral/{chunk-VYAGNFSJ.mjs.map → chunk-N7VOEPSV.mjs.map} +3 -3
  32. package/dist/lib/neutral/{chunk-FZHVQEHN.mjs → chunk-PSZBLH53.mjs} +2 -2
  33. package/dist/lib/neutral/{chunk-WRVRDZDA.mjs → chunk-PT37DG2F.mjs} +4 -4
  34. package/dist/lib/neutral/{chunk-HPNQTEEQ.mjs → chunk-Q2KKKJSV.mjs} +3 -3
  35. package/dist/lib/neutral/{chunk-VGKLHHRT.mjs → chunk-Q7ZL2P5H.mjs} +18 -16
  36. package/dist/lib/neutral/{chunk-VGKLHHRT.mjs.map → chunk-Q7ZL2P5H.mjs.map} +3 -3
  37. package/dist/lib/neutral/{chunk-QGMIH2SN.mjs → chunk-QRZ2I3ZM.mjs} +2 -2
  38. package/dist/lib/neutral/{chunk-LVGOVFDV.mjs → chunk-SCPFDS2E.mjs} +2 -2
  39. package/dist/lib/neutral/{chunk-S7IMFVTB.mjs → chunk-ZFACXBY6.mjs} +19 -15
  40. package/dist/lib/neutral/chunk-ZFACXBY6.mjs.map +7 -0
  41. package/dist/lib/neutral/index.mjs +17 -17
  42. package/dist/lib/neutral/internal/index.mjs +5 -5
  43. package/dist/lib/neutral/meta.json +1 -1
  44. package/dist/lib/neutral/testing/index.mjs +17 -17
  45. package/dist/types/src/Database.d.ts +1 -1
  46. package/dist/types/src/Feed.d.ts +36 -12
  47. package/dist/types/src/Feed.d.ts.map +1 -1
  48. package/dist/types/src/Filter.d.ts +21 -0
  49. package/dist/types/src/Filter.d.ts.map +1 -1
  50. package/dist/types/src/Hypergraph.d.ts +3 -3
  51. package/dist/types/src/Hypergraph.d.ts.map +1 -1
  52. package/dist/types/src/Migration.d.ts +15 -3
  53. package/dist/types/src/Migration.d.ts.map +1 -1
  54. package/dist/types/src/Obj.d.ts +1 -1
  55. package/dist/types/src/Obj.d.ts.map +1 -1
  56. package/dist/types/src/Query.d.ts.map +1 -1
  57. package/dist/types/src/Ref.d.ts +1 -0
  58. package/dist/types/src/Ref.d.ts.map +1 -1
  59. package/dist/types/src/internal/Entity/model.d.ts +2 -0
  60. package/dist/types/src/internal/Entity/model.d.ts.map +1 -1
  61. package/dist/types/src/internal/Obj/ids.d.ts +1 -1
  62. package/dist/types/src/internal/Query.d.ts.map +1 -1
  63. package/dist/types/src/internal/common/types/meta.d.ts +10 -0
  64. package/dist/types/src/internal/common/types/meta.d.ts.map +1 -1
  65. package/dist/types/tsconfig.tsbuildinfo +1 -1
  66. package/package.json +14 -14
  67. package/src/Database.ts +1 -1
  68. package/src/Feed.ts +55 -24
  69. package/src/Filter.ts +31 -0
  70. package/src/Hypergraph.ts +3 -3
  71. package/src/Migration.ts +19 -7
  72. package/src/Obj.ts +1 -0
  73. package/src/Query.test.ts +16 -16
  74. package/src/Query.ts +12 -7
  75. package/src/Ref.ts +2 -0
  76. package/src/internal/Entity/model.ts +2 -0
  77. package/src/internal/Obj/ids.ts +1 -1
  78. package/src/internal/Obj/json-serializer.ts +9 -9
  79. package/src/internal/Query.ts +23 -4
  80. package/src/internal/common/proxy/reactive.test.ts +1 -1
  81. package/src/internal/common/types/meta.ts +12 -0
  82. package/dist/lib/neutral/chunk-FHYIM4RD.mjs.map +0 -7
  83. package/dist/lib/neutral/chunk-QXIANHKU.mjs.map +0 -7
  84. package/dist/lib/neutral/chunk-RF7ZBZ4A.mjs.map +0 -7
  85. package/dist/lib/neutral/chunk-S7IMFVTB.mjs.map +0 -7
  86. package/dist/lib/neutral/chunk-SJKBWMJY.mjs.map +0 -7
  87. package/dist/lib/neutral/chunk-SUZMWP3Y.mjs.map +0 -7
  88. /package/dist/lib/neutral/{chunk-6VIJV543.mjs.map → chunk-APHSOTIX.mjs.map} +0 -0
  89. /package/dist/lib/neutral/{chunk-MPAI2MHO.mjs.map → chunk-BMB7IHGB.mjs.map} +0 -0
  90. /package/dist/lib/neutral/{chunk-O5LRY6CO.mjs.map → chunk-MLS7U7AT.mjs.map} +0 -0
  91. /package/dist/lib/neutral/{chunk-FZHVQEHN.mjs.map → chunk-PSZBLH53.mjs.map} +0 -0
  92. /package/dist/lib/neutral/{chunk-WRVRDZDA.mjs.map → chunk-PT37DG2F.mjs.map} +0 -0
  93. /package/dist/lib/neutral/{chunk-HPNQTEEQ.mjs.map → chunk-Q2KKKJSV.mjs.map} +0 -0
  94. /package/dist/lib/neutral/{chunk-QGMIH2SN.mjs.map → chunk-QRZ2I3ZM.mjs.map} +0 -0
  95. /package/dist/lib/neutral/{chunk-LVGOVFDV.mjs.map → chunk-SCPFDS2E.mjs.map} +0 -0
package/LICENSE CHANGED
@@ -1,8 +1,105 @@
1
- MIT License
2
- Copyright (c) 2022 DXOS
1
+ # Functional Source License, Version 1.1, ALv2 Future License
3
2
 
4
- Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
3
+ ## Abbreviation
5
4
 
6
- The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
5
+ FSL-1.1-Apache-2.0
7
6
 
8
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
7
+ ## Notice
8
+
9
+ Copyright 2026 DXOS
10
+
11
+ ## Terms and Conditions
12
+
13
+ ### Licensor ("We")
14
+
15
+ The party offering the Software under these Terms and Conditions.
16
+
17
+ ### The Software
18
+
19
+ The "Software" is each version of the software that we make available under
20
+ these Terms and Conditions, as indicated by our inclusion of these Terms and
21
+ Conditions with the Software.
22
+
23
+ ### License Grant
24
+
25
+ Subject to your compliance with this License Grant and the Patents,
26
+ Redistribution and Trademark clauses below, we hereby grant you the right to
27
+ use, copy, modify, create derivative works, publicly perform, publicly display
28
+ and redistribute the Software for any Permitted Purpose identified below.
29
+
30
+ ### Permitted Purpose
31
+
32
+ A Permitted Purpose is any purpose other than a Competing Use. A Competing Use
33
+ means making the Software available to others in a commercial product or
34
+ service that:
35
+
36
+ 1. substitutes for the Software;
37
+
38
+ 2. substitutes for any other product or service we offer using the Software
39
+ that exists as of the date we make the Software available; or
40
+
41
+ 3. offers the same or substantially similar functionality as the Software.
42
+
43
+ Permitted Purposes specifically include using the Software:
44
+
45
+ 1. for your internal use and access;
46
+
47
+ 2. for non-commercial education;
48
+
49
+ 3. for non-commercial research; and
50
+
51
+ 4. in connection with professional services that you provide to a licensee
52
+ using the Software in accordance with these Terms and Conditions.
53
+
54
+ ### Patents
55
+
56
+ To the extent your use for a Permitted Purpose would necessarily infringe our
57
+ patents, the license grant above includes a license under our patents. If you
58
+ make a claim against any party that the Software infringes or contributes to
59
+ the infringement of any patent, then your patent license to the Software ends
60
+ immediately.
61
+
62
+ ### Redistribution
63
+
64
+ The Terms and Conditions apply to all copies, modifications and derivatives of
65
+ the Software.
66
+
67
+ If you redistribute any copies, modifications or derivatives of the Software,
68
+ you must include a copy of or a link to these Terms and Conditions and not
69
+ remove any copyright notices provided in or with the Software.
70
+
71
+ ### Disclaimer
72
+
73
+ THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR
74
+ IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR
75
+ PURPOSE, MERCHANTABILITY, TITLE OR NON-INFRINGEMENT.
76
+
77
+ IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO THE
78
+ SOFTWARE, INCLUDING INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES,
79
+ EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
80
+
81
+ ### Trademarks
82
+
83
+ Except for displaying the License Details and identifying us as the origin of
84
+ the Software, you have no right under these Terms and Conditions to use our
85
+ trademarks, trade names, service marks or product names.
86
+
87
+ ## Grant of Future License
88
+
89
+ We hereby irrevocably grant you an additional license to use the Software under
90
+ the Apache License, Version 2.0 that is effective on the second anniversary of
91
+ the date we make the Software available. On or after that date, you may use the
92
+ Software under the Apache License, Version 2.0, in which case the following
93
+ will apply:
94
+
95
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use
96
+ this file except in compliance with the License.
97
+
98
+ You may obtain a copy of the License at
99
+
100
+ http://www.apache.org/licenses/LICENSE-2.0
101
+
102
+ Unless required by applicable law or agreed to in writing, software distributed
103
+ under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
104
+ CONDITIONS OF ANY KIND, either express or implied. See the License for the
105
+ specific language governing permissions and limitations under the License.
package/README.md CHANGED
@@ -18,7 +18,7 @@ pnpm i @dxos/echo
18
18
 
19
19
  Your ideas, issues, and code are most welcome. Please take a look at our [community code of conduct](https://github.com/dxos/dxos/blob/main/CODE_OF_CONDUCT.md), the [issue guide](https://github.com/dxos/dxos/blob/main/CONTRIBUTING.md#submitting-issues), and the [PR contribution guide](https://github.com/dxos/dxos/blob/main/CONTRIBUTING.md#submitting-prs).
20
20
 
21
- License: [MIT](./LICENSE) Copyright 2022 © DXOS
21
+ License: [FSL-1.1-Apache-2.0](./LICENSE) Copyright 2022 © DXOS
22
22
 
23
23
  ## API
24
24
 
@@ -19,7 +19,7 @@ import {
19
19
  runSchemaQuery,
20
20
  schemaQuery,
21
21
  spaceId
22
- } from "./chunk-FHYIM4RD.mjs";
22
+ } from "./chunk-I2DARWPX.mjs";
23
23
  import "./chunk-TNBK56IN.mjs";
24
24
  import "./chunk-N4B7FHQT.mjs";
25
25
  import "./chunk-ZISMEVKD.mjs";
@@ -22,13 +22,13 @@ import {
22
22
  subscribe,
23
23
  toJSON,
24
24
  update
25
- } from "./chunk-LVGOVFDV.mjs";
26
- import "./chunk-SJKBWMJY.mjs";
27
- import "./chunk-6VIJV543.mjs";
28
- import "./chunk-O5LRY6CO.mjs";
25
+ } from "./chunk-SCPFDS2E.mjs";
26
+ import "./chunk-G54OX4IX.mjs";
27
+ import "./chunk-APHSOTIX.mjs";
28
+ import "./chunk-MLS7U7AT.mjs";
29
29
  import "./chunk-TRPZU2HV.mjs";
30
- import "./chunk-MPAI2MHO.mjs";
31
- import "./chunk-FHYIM4RD.mjs";
30
+ import "./chunk-BMB7IHGB.mjs";
31
+ import "./chunk-I2DARWPX.mjs";
32
32
  import "./chunk-TNBK56IN.mjs";
33
33
  import "./chunk-N4B7FHQT.mjs";
34
34
  import "./chunk-ZISMEVKD.mjs";
@@ -1,4 +1,5 @@
1
1
  import {
2
+ ContextFeedService,
2
3
  Feed,
3
4
  FeedService,
4
5
  Service,
@@ -13,24 +14,25 @@ import {
13
14
  remove,
14
15
  runQuery,
15
16
  setRetention,
16
- unsafeFromQueueDXN
17
- } from "./chunk-S7IMFVTB.mjs";
18
- import "./chunk-FZHVQEHN.mjs";
19
- import "./chunk-SW5CUSBY.mjs";
20
- import "./chunk-VYAGNFSJ.mjs";
21
- import "./chunk-LVGOVFDV.mjs";
22
- import "./chunk-SJKBWMJY.mjs";
23
- import "./chunk-6VIJV543.mjs";
24
- import "./chunk-O5LRY6CO.mjs";
17
+ sync
18
+ } from "./chunk-ZFACXBY6.mjs";
19
+ import "./chunk-PSZBLH53.mjs";
20
+ import "./chunk-J54QMAKF.mjs";
21
+ import "./chunk-N7VOEPSV.mjs";
22
+ import "./chunk-SCPFDS2E.mjs";
23
+ import "./chunk-G54OX4IX.mjs";
24
+ import "./chunk-APHSOTIX.mjs";
25
+ import "./chunk-MLS7U7AT.mjs";
25
26
  import "./chunk-TRPZU2HV.mjs";
26
- import "./chunk-MPAI2MHO.mjs";
27
+ import "./chunk-BMB7IHGB.mjs";
27
28
  import "./chunk-5SL5LDLD.mjs";
28
- import "./chunk-FHYIM4RD.mjs";
29
+ import "./chunk-I2DARWPX.mjs";
29
30
  import "./chunk-TNBK56IN.mjs";
30
31
  import "./chunk-N4B7FHQT.mjs";
31
32
  import "./chunk-ZISMEVKD.mjs";
32
33
  import "./chunk-J5LGTIGS.mjs";
33
34
  export {
35
+ ContextFeedService,
34
36
  Feed,
35
37
  FeedService,
36
38
  Service,
@@ -45,6 +47,6 @@ export {
45
47
  remove,
46
48
  runQuery,
47
49
  setRetention,
48
- unsafeFromQueueDXN
50
+ sync
49
51
  };
50
52
  //# sourceMappingURL=Feed.mjs.map
@@ -13,6 +13,7 @@ import {
13
13
  id,
14
14
  in$,
15
15
  is,
16
+ key,
16
17
  lt,
17
18
  lte,
18
19
  neq,
@@ -27,14 +28,14 @@ import {
27
28
  typeDXN,
28
29
  typename,
29
30
  updated
30
- } from "./chunk-RF7ZBZ4A.mjs";
31
- import "./chunk-VYAGNFSJ.mjs";
32
- import "./chunk-SJKBWMJY.mjs";
33
- import "./chunk-6VIJV543.mjs";
34
- import "./chunk-O5LRY6CO.mjs";
31
+ } from "./chunk-APJKDGFL.mjs";
32
+ import "./chunk-N7VOEPSV.mjs";
33
+ import "./chunk-G54OX4IX.mjs";
34
+ import "./chunk-APHSOTIX.mjs";
35
+ import "./chunk-MLS7U7AT.mjs";
35
36
  import "./chunk-TRPZU2HV.mjs";
36
- import "./chunk-MPAI2MHO.mjs";
37
- import "./chunk-FHYIM4RD.mjs";
37
+ import "./chunk-BMB7IHGB.mjs";
38
+ import "./chunk-I2DARWPX.mjs";
38
39
  import "./chunk-TNBK56IN.mjs";
39
40
  import "./chunk-N4B7FHQT.mjs";
40
41
  import "./chunk-ZISMEVKD.mjs";
@@ -54,6 +55,7 @@ export {
54
55
  id,
55
56
  in$ as in,
56
57
  is,
58
+ key,
57
59
  lt,
58
60
  lte,
59
61
  neq,
@@ -2,11 +2,11 @@ import {
2
2
  JsonSchema,
3
3
  toEffectSchema,
4
4
  toJsonSchema
5
- } from "./chunk-QGMIH2SN.mjs";
6
- import "./chunk-O5LRY6CO.mjs";
5
+ } from "./chunk-QRZ2I3ZM.mjs";
6
+ import "./chunk-MLS7U7AT.mjs";
7
7
  import "./chunk-TRPZU2HV.mjs";
8
- import "./chunk-MPAI2MHO.mjs";
9
- import "./chunk-FHYIM4RD.mjs";
8
+ import "./chunk-BMB7IHGB.mjs";
9
+ import "./chunk-I2DARWPX.mjs";
10
10
  import "./chunk-TNBK56IN.mjs";
11
11
  import "./chunk-N4B7FHQT.mjs";
12
12
  import "./chunk-ZISMEVKD.mjs";
@@ -1,12 +1,12 @@
1
1
  import {
2
2
  define
3
- } from "./chunk-SUZMWP3Y.mjs";
4
- import "./chunk-SJKBWMJY.mjs";
5
- import "./chunk-6VIJV543.mjs";
6
- import "./chunk-O5LRY6CO.mjs";
3
+ } from "./chunk-FIWO2FZK.mjs";
4
+ import "./chunk-G54OX4IX.mjs";
5
+ import "./chunk-APHSOTIX.mjs";
6
+ import "./chunk-MLS7U7AT.mjs";
7
7
  import "./chunk-TRPZU2HV.mjs";
8
- import "./chunk-MPAI2MHO.mjs";
9
- import "./chunk-FHYIM4RD.mjs";
8
+ import "./chunk-BMB7IHGB.mjs";
9
+ import "./chunk-I2DARWPX.mjs";
10
10
  import "./chunk-TNBK56IN.mjs";
11
11
  import "./chunk-N4B7FHQT.mjs";
12
12
  import "./chunk-ZISMEVKD.mjs";
@@ -47,15 +47,15 @@ import {
47
47
  updateFrom,
48
48
  version,
49
49
  versionValid
50
- } from "./chunk-SW5CUSBY.mjs";
51
- import "./chunk-VYAGNFSJ.mjs";
52
- import "./chunk-LVGOVFDV.mjs";
53
- import "./chunk-SJKBWMJY.mjs";
54
- import "./chunk-6VIJV543.mjs";
55
- import "./chunk-O5LRY6CO.mjs";
50
+ } from "./chunk-J54QMAKF.mjs";
51
+ import "./chunk-N7VOEPSV.mjs";
52
+ import "./chunk-SCPFDS2E.mjs";
53
+ import "./chunk-G54OX4IX.mjs";
54
+ import "./chunk-APHSOTIX.mjs";
55
+ import "./chunk-MLS7U7AT.mjs";
56
56
  import "./chunk-TRPZU2HV.mjs";
57
- import "./chunk-MPAI2MHO.mjs";
58
- import "./chunk-FHYIM4RD.mjs";
57
+ import "./chunk-BMB7IHGB.mjs";
58
+ import "./chunk-I2DARWPX.mjs";
59
59
  import "./chunk-TNBK56IN.mjs";
60
60
  import "./chunk-N4B7FHQT.mjs";
61
61
  import "./chunk-ZISMEVKD.mjs";
@@ -7,20 +7,20 @@ import {
7
7
  select,
8
8
  type,
9
9
  without
10
- } from "./chunk-VGKLHHRT.mjs";
11
- import "./chunk-S7IMFVTB.mjs";
12
- import "./chunk-FZHVQEHN.mjs";
13
- import "./chunk-RF7ZBZ4A.mjs";
14
- import "./chunk-SW5CUSBY.mjs";
15
- import "./chunk-VYAGNFSJ.mjs";
16
- import "./chunk-LVGOVFDV.mjs";
17
- import "./chunk-SJKBWMJY.mjs";
18
- import "./chunk-6VIJV543.mjs";
19
- import "./chunk-O5LRY6CO.mjs";
10
+ } from "./chunk-Q7ZL2P5H.mjs";
11
+ import "./chunk-ZFACXBY6.mjs";
12
+ import "./chunk-PSZBLH53.mjs";
13
+ import "./chunk-APJKDGFL.mjs";
14
+ import "./chunk-J54QMAKF.mjs";
15
+ import "./chunk-N7VOEPSV.mjs";
16
+ import "./chunk-SCPFDS2E.mjs";
17
+ import "./chunk-G54OX4IX.mjs";
18
+ import "./chunk-APHSOTIX.mjs";
19
+ import "./chunk-MLS7U7AT.mjs";
20
20
  import "./chunk-TRPZU2HV.mjs";
21
- import "./chunk-MPAI2MHO.mjs";
21
+ import "./chunk-BMB7IHGB.mjs";
22
22
  import "./chunk-5SL5LDLD.mjs";
23
- import "./chunk-FHYIM4RD.mjs";
23
+ import "./chunk-I2DARWPX.mjs";
24
24
  import "./chunk-TNBK56IN.mjs";
25
25
  import "./chunk-N4B7FHQT.mjs";
26
26
  import "./chunk-ZISMEVKD.mjs";
@@ -2,13 +2,14 @@ import {
2
2
  Array,
3
3
  Ref,
4
4
  fromDXN,
5
+ hasObjectId,
5
6
  isRef,
6
7
  isRefType,
7
8
  make
8
- } from "./chunk-VYAGNFSJ.mjs";
9
- import "./chunk-6VIJV543.mjs";
10
- import "./chunk-MPAI2MHO.mjs";
11
- import "./chunk-FHYIM4RD.mjs";
9
+ } from "./chunk-N7VOEPSV.mjs";
10
+ import "./chunk-APHSOTIX.mjs";
11
+ import "./chunk-BMB7IHGB.mjs";
12
+ import "./chunk-I2DARWPX.mjs";
12
13
  import "./chunk-TNBK56IN.mjs";
13
14
  import "./chunk-N4B7FHQT.mjs";
14
15
  import "./chunk-ZISMEVKD.mjs";
@@ -17,6 +18,7 @@ export {
17
18
  Array,
18
19
  Ref,
19
20
  fromDXN,
21
+ hasObjectId,
20
22
  isRef,
21
23
  isRefType,
22
24
  make
@@ -37,16 +37,16 @@ import {
37
37
  toJSON,
38
38
  update,
39
39
  version
40
- } from "./chunk-WRVRDZDA.mjs";
41
- import "./chunk-SW5CUSBY.mjs";
42
- import "./chunk-VYAGNFSJ.mjs";
43
- import "./chunk-LVGOVFDV.mjs";
44
- import "./chunk-SJKBWMJY.mjs";
45
- import "./chunk-6VIJV543.mjs";
46
- import "./chunk-O5LRY6CO.mjs";
40
+ } from "./chunk-PT37DG2F.mjs";
41
+ import "./chunk-J54QMAKF.mjs";
42
+ import "./chunk-N7VOEPSV.mjs";
43
+ import "./chunk-SCPFDS2E.mjs";
44
+ import "./chunk-G54OX4IX.mjs";
45
+ import "./chunk-APHSOTIX.mjs";
46
+ import "./chunk-MLS7U7AT.mjs";
47
47
  import "./chunk-TRPZU2HV.mjs";
48
- import "./chunk-MPAI2MHO.mjs";
49
- import "./chunk-FHYIM4RD.mjs";
48
+ import "./chunk-BMB7IHGB.mjs";
49
+ import "./chunk-I2DARWPX.mjs";
50
50
  import "./chunk-TNBK56IN.mjs";
51
51
  import "./chunk-N4B7FHQT.mjs";
52
52
  import "./chunk-ZISMEVKD.mjs";
@@ -4,17 +4,17 @@ import {
4
4
  findTagByLabel,
5
5
  make,
6
6
  sortTags
7
- } from "./chunk-HPNQTEEQ.mjs";
8
- import "./chunk-FZHVQEHN.mjs";
9
- import "./chunk-SW5CUSBY.mjs";
10
- import "./chunk-VYAGNFSJ.mjs";
11
- import "./chunk-LVGOVFDV.mjs";
12
- import "./chunk-SJKBWMJY.mjs";
13
- import "./chunk-6VIJV543.mjs";
14
- import "./chunk-O5LRY6CO.mjs";
7
+ } from "./chunk-Q2KKKJSV.mjs";
8
+ import "./chunk-PSZBLH53.mjs";
9
+ import "./chunk-J54QMAKF.mjs";
10
+ import "./chunk-N7VOEPSV.mjs";
11
+ import "./chunk-SCPFDS2E.mjs";
12
+ import "./chunk-G54OX4IX.mjs";
13
+ import "./chunk-APHSOTIX.mjs";
14
+ import "./chunk-MLS7U7AT.mjs";
15
15
  import "./chunk-TRPZU2HV.mjs";
16
- import "./chunk-MPAI2MHO.mjs";
17
- import "./chunk-FHYIM4RD.mjs";
16
+ import "./chunk-BMB7IHGB.mjs";
17
+ import "./chunk-I2DARWPX.mjs";
18
18
  import "./chunk-TNBK56IN.mjs";
19
19
  import "./chunk-N4B7FHQT.mjs";
20
20
  import "./chunk-ZISMEVKD.mjs";
@@ -10,13 +10,13 @@ import {
10
10
  isRelationSchema,
11
11
  object,
12
12
  relation
13
- } from "./chunk-FZHVQEHN.mjs";
14
- import "./chunk-SJKBWMJY.mjs";
15
- import "./chunk-6VIJV543.mjs";
16
- import "./chunk-O5LRY6CO.mjs";
13
+ } from "./chunk-PSZBLH53.mjs";
14
+ import "./chunk-G54OX4IX.mjs";
15
+ import "./chunk-APHSOTIX.mjs";
16
+ import "./chunk-MLS7U7AT.mjs";
17
17
  import "./chunk-TRPZU2HV.mjs";
18
- import "./chunk-MPAI2MHO.mjs";
19
- import "./chunk-FHYIM4RD.mjs";
18
+ import "./chunk-BMB7IHGB.mjs";
19
+ import "./chunk-I2DARWPX.mjs";
20
20
  import "./chunk-TNBK56IN.mjs";
21
21
  import "./chunk-N4B7FHQT.mjs";
22
22
  import "./chunk-ZISMEVKD.mjs";
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Ref
3
- } from "./chunk-MPAI2MHO.mjs";
3
+ } from "./chunk-BMB7IHGB.mjs";
4
4
 
5
5
  // src/internal/Ref/ref-array.ts
6
6
  import { isNonNullable } from "@dxos/util";
@@ -31,4 +31,4 @@ var RefArray = Object.freeze({
31
31
  export {
32
32
  RefArray
33
33
  };
34
- //# sourceMappingURL=chunk-6VIJV543.mjs.map
34
+ //# sourceMappingURL=chunk-APHSOTIX.mjs.map
@@ -1,10 +1,10 @@
1
1
  import {
2
2
  isRef
3
- } from "./chunk-VYAGNFSJ.mjs";
3
+ } from "./chunk-N7VOEPSV.mjs";
4
4
  import {
5
5
  getDXN,
6
6
  prettyFilter
7
- } from "./chunk-SJKBWMJY.mjs";
7
+ } from "./chunk-G54OX4IX.mjs";
8
8
  import {
9
9
  getTypeDXNFromSpecifier
10
10
  } from "./chunk-TNBK56IN.mjs";
@@ -29,6 +29,7 @@ __export(Filter_exports, {
29
29
  id: () => id,
30
30
  in: () => in$,
31
31
  is: () => is,
32
+ key: () => key,
32
33
  lt: () => lt,
33
34
  lte: () => lte,
34
35
  neq: () => neq,
@@ -132,6 +133,15 @@ var tag = (tag2) => {
132
133
  tag: tag2
133
134
  });
134
135
  };
136
+ var key = (key2, options) => {
137
+ return new FilterClass({
138
+ type: "object",
139
+ typename: null,
140
+ props: {},
141
+ metaKey: key2,
142
+ metaVersion: options?.version
143
+ });
144
+ };
135
145
  var props = (props2) => {
136
146
  return new FilterClass({
137
147
  type: "object",
@@ -305,8 +315,8 @@ var processPredicate = (predicate) => {
305
315
  throw new Error("Array predicates are not yet supported.");
306
316
  }),
307
317
  Match.when((predicate2) => !isRef(predicate2) && typeof predicate2 === "object" && predicate2 !== null, (predicate2) => {
308
- const nestedProps = Object.fromEntries(Object.entries(predicate2).map(([key, value2]) => [
309
- key,
318
+ const nestedProps = Object.fromEntries(Object.entries(predicate2).map(([key2, value2]) => [
319
+ key2,
310
320
  processPredicate(value2)
311
321
  ]));
312
322
  return {
@@ -330,6 +340,7 @@ export {
330
340
  typename,
331
341
  typeDXN,
332
342
  tag,
343
+ key,
333
344
  props,
334
345
  text,
335
346
  foreignKeys,
@@ -351,4 +362,4 @@ export {
351
362
  pretty,
352
363
  Filter_exports
353
364
  };
354
- //# sourceMappingURL=chunk-RF7ZBZ4A.mjs.map
365
+ //# sourceMappingURL=chunk-APJKDGFL.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/Filter.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2025 DXOS.org\n//\n\n// @import-as-namespace\n\nimport * as Match from 'effect/Match';\nimport * as Schema from 'effect/Schema';\nimport * as SchemaAST from 'effect/SchemaAST';\nimport type * as Types from 'effect/Types';\n\nimport { type ForeignKey, type QueryAST } from '@dxos/echo-protocol';\nimport { assertArgument } from '@dxos/invariant';\nimport { DXN, ObjectId } from '@dxos/keys';\n\nimport * as internal from './internal';\nimport type * as Obj from './Obj';\nimport * as Ref from './Ref';\n\nexport interface Filter<T> {\n // TODO(dmaretskyi): See new effect-schema approach to variance.\n '~Filter': { value: Types.Covariant<T> };\n\n ast: QueryAST.Filter;\n}\n\nexport type Props<T> = {\n // Predicate or a value as a shorthand for `eq`.\n [K in keyof T & string]?: Filter<T[K]> | T[K];\n};\n\nexport type Any = Filter<any>;\n\nexport type Type<F extends Any> = F extends Filter<infer T> ? T : never;\n\nclass FilterClass implements Any {\n private static 'variance': Any['~Filter'] = {} as Any['~Filter'];\n\n constructor(public readonly ast: QueryAST.Filter) {}\n\n '~Filter' = FilterClass.variance;\n}\n\nexport const is = (value: unknown): value is Any => {\n return typeof value === 'object' && value !== null && '~Filter' in value;\n};\n\n/** Construct a filter from an ast. */\nexport const fromAst = (ast: QueryAST.Filter): Any => {\n return new FilterClass(ast);\n};\n\n/**\n * Filter that matches all objects.\n */\n// TODO(dmaretskyi): `Entity.Any` would be more type-safe, but causes annoying errors in existing code\nexport const everything = (): FilterClass => {\n return new FilterClass({\n type: 'object',\n typename: null,\n props: {},\n });\n};\n\n/**\n * Filter that matches no objects.\n */\nexport const nothing = (): FilterClass => {\n return new FilterClass({\n type: 'not',\n filter: {\n type: 'object',\n typename: null,\n props: {},\n },\n });\n};\n\n/*\n * Filter by ObjectId.\n */\nexport const id = (...ids: ObjectId[]): Any => {\n assertArgument(\n ids.every((id) => ObjectId.isValid(id)),\n 'ids',\n 'ids must be valid',\n );\n\n if (ids.length === 0) {\n return nothing();\n }\n\n return new FilterClass({\n type: 'object',\n typename: null,\n id: ids,\n props: {},\n });\n};\n\n/**\n * Filter by type.\n */\nexport const type = <S extends Schema.Schema.All>(\n schema: S | string,\n props?: Props<Schema.Schema.Type<S>>,\n): Filter<Schema.Schema.Type<S>> => {\n if (Schema.isSchema(schema) && SchemaAST.isUnion(schema.ast)) {\n const typenames = schema.ast.types.map((type) => internal.getTypeDXNFromSpecifier(Schema.make(type)));\n return new FilterClass({\n type: 'or',\n filters: typenames.map((typename) => ({\n type: 'object',\n typename: typename.toString(),\n props: {},\n })),\n });\n }\n\n const dxn = internal.getTypeDXNFromSpecifier(schema);\n return new FilterClass({\n type: 'object',\n typename: dxn.toString(),\n ...propsFilterToAst(props ?? {}),\n });\n};\n\n/**\n * Filter by non-qualified typename.\n */\nexport const typename = (typename: string): Any => {\n assertArgument(!typename.startsWith('dxn:'), 'typename', 'Typename must no be qualified');\n return new FilterClass({\n type: 'object',\n typename: DXN.fromTypename(typename).toString(),\n props: {},\n });\n};\n\n/**\n * Filter by fully qualified type DXN.\n */\nexport const typeDXN = (dxn: DXN): Any => {\n return new FilterClass({\n type: 'object',\n typename: dxn.toString(),\n props: {},\n });\n};\n\n/**\n * Filter by tag.\n */\nexport const tag = (tag: string): Any => {\n return new FilterClass({\n type: 'tag',\n tag,\n });\n};\n\n/**\n * Options for {@link key} filter.\n */\nexport type KeyFilterOptions = {\n /**\n * Optional semver range expression (e.g. `^1.2.3`, `~2.0.0`, `>=1.0.0 <2.0.0`).\n * Matches the object's meta `version` field against the range.\n * If omitted, matches any version (including objects with no version).\n */\n version?: string;\n};\n\n/**\n * Filter by registry key stored in object meta.\n *\n * @example\n * ```ts\n * Filter.key('org.example.type.foo');\n * Filter.key('org.example.type.foo', { version: '^1.2.3' });\n * ```\n */\nexport const key = (key: string, options?: KeyFilterOptions): Any => {\n return new FilterClass({\n type: 'object',\n typename: null,\n props: {},\n metaKey: key,\n metaVersion: options?.version,\n });\n};\n\n/**\n * Filter by properties.\n */\nexport const props = <T>(props: Props<T>): Filter<T> => {\n return new FilterClass({\n type: 'object',\n typename: null,\n ...propsFilterToAst(props),\n });\n};\n\nexport type TextSearchOptions = {\n // TODO(dmaretskyi): Hybrid search.\n type?: 'full-text' | 'vector';\n};\n\n/**\n * Full-text or vector search.\n */\nexport const text = (\n // TODO(dmaretskyi): Consider passing a vector here, but really the embedding should be done on the query-executor side.\n text: string,\n options?: TextSearchOptions,\n): Any => {\n return new FilterClass({\n type: 'text-search',\n text,\n searchKind: options?.type,\n });\n};\n\n/**\n * Filter by foreign keys.\n */\nexport const foreignKeys = <S extends Schema.Schema.All>(\n schema: S | string,\n keys: ForeignKey[],\n): Filter<Schema.Schema.Type<S>> => {\n const dxn = internal.getTypeDXNFromSpecifier(schema);\n return new FilterClass({\n type: 'object',\n typename: dxn.toString(),\n props: {},\n foreignKeys: keys,\n });\n};\n\n/**\n * Predicate for property to be equal to the provided value.\n */\nexport const eq = <T>(value: T): Filter<T | undefined> => {\n if (!Ref.isRef(value) && typeof value === 'object' && value !== null) {\n throw new TypeError('Cannot use object as a value for eq filter');\n }\n\n return new FilterClass({\n type: 'compare',\n operator: 'eq',\n value: Ref.isRef(value) ? value.noInline().encode() : value,\n });\n};\n\n/**\n * Predicate for property to be not equal to the provided value.\n */\nexport const neq = <T>(value: T): Filter<T | undefined> => {\n return new FilterClass({\n type: 'compare',\n operator: 'neq',\n value,\n });\n};\n\n/**\n * Predicate for property to be greater than the provided value.\n */\nexport const gt = <T>(value: T): Filter<T | undefined> => {\n return new FilterClass({\n type: 'compare',\n operator: 'gt',\n value,\n });\n};\n\n/**\n * Predicate for property to be greater than or equal to the provided value.\n */\nexport const gte = <T>(value: T): Filter<T | undefined> => {\n return new FilterClass({\n type: 'compare',\n operator: 'gte',\n value,\n });\n};\n\n/**\n * Predicate for property to be less than the provided value.\n */\nexport const lt = <T>(value: T): Filter<T | undefined> => {\n return new FilterClass({\n type: 'compare',\n operator: 'lt',\n value,\n });\n};\n\n/**\n * Predicate for property to be less than or equal to the provided value.\n */\nexport const lte = <T>(value: T): Filter<T | undefined> => {\n return new FilterClass({\n type: 'compare',\n operator: 'lte',\n value,\n });\n};\n\n/**\n * Predicate for property to be in the provided array.\n * @param values - Values to check against.\n */\nconst in$ = <T>(...values: T[]): Filter<T> => {\n return new FilterClass({\n type: 'in',\n values,\n });\n};\nexport { in$ as in };\n\n/**\n * Predicate for an array property to contain the provided value.\n * @param value - Value to check against.\n */\nexport const contains = <T>(value: T): Filter<readonly T[] | undefined> => {\n return new FilterClass({\n type: 'contains',\n value,\n });\n};\n\n/**\n * Predicate for property to be in the provided range.\n * @param from - Start of the range (inclusive).\n * @param to - End of the range (exclusive).\n */\nexport const between = <T>(from: T, to: T): Filter<T> => {\n return new FilterClass({\n type: 'range',\n from,\n to,\n });\n};\n\ntype TimeRange = { after?: Date | number; before?: Date | number };\n\nconst _toUnixMs = (date: Date | number): number => (typeof date === 'number' ? date : date.getTime());\n\nconst _timeRangeFilter = (field: 'updatedAt' | 'createdAt', range: TimeRange): Any => {\n const filters: Any[] = [];\n if (range.after != null) {\n filters.push(new FilterClass({ type: 'timestamp', field, operator: 'gte', value: _toUnixMs(range.after) }));\n }\n if (range.before != null) {\n filters.push(new FilterClass({ type: 'timestamp', field, operator: 'lte', value: _toUnixMs(range.before) }));\n }\n if (filters.length === 0) {\n return everything();\n }\n return filters.length === 1 ? filters[0] : and(...filters);\n};\n\n/**\n * Filter objects by updatedAt timestamp.\n */\nexport const updated = (range: TimeRange): Any => _timeRangeFilter('updatedAt', range);\n\n/**\n * Filter objects by createdAt timestamp.\n */\nexport const created = (range: TimeRange): Any => _timeRangeFilter('createdAt', range);\n\nexport type ChildOfOptions = {\n /** Whether to match transitively (grandchildren, etc.). Defaults to true. */\n transitive?: boolean;\n};\n\n/**\n * Filter objects that are children of the specified parent(s).\n * Accepts ECHO objects, Refs, or arrays of either.\n * Refs are resolved to DXNs without loading; objects use {@link Obj.getDXN}.\n * With transitive=true (default), also matches grandchildren and beyond.\n */\nexport const childOf = (\n parents: Obj.Unknown | Ref.Unknown | readonly (Obj.Unknown | Ref.Unknown)[],\n options?: ChildOfOptions,\n): Any => {\n const items = Array.isArray(parents) ? parents : [parents];\n const dxns = items.map((item) => {\n if (Ref.isRef(item)) {\n return item.dxn.toString();\n }\n return internal.getDXN(item).toString();\n });\n return new FilterClass({\n type: 'child-of',\n parents: dxns,\n transitive: options?.transitive ?? true,\n });\n};\n\n/**\n * Negate the filter.\n */\nexport const not = <F extends Any>(filter: F): Filter<Type<F>> => {\n return new FilterClass({\n type: 'not',\n filter: filter.ast,\n });\n};\n\n/**\n * Combine filters with a logical AND.\n */\nexport const and = <Filters extends readonly Any[]>(...filters: Filters): Filter<Type<Filters[number]>> => {\n return new FilterClass({\n type: 'and',\n filters: filters.map((f) => f.ast),\n });\n};\n\n/**\n * Combine filters with a logical OR.\n */\nexport const or = <Filters extends readonly Any[]>(...filters: Filters): Filter<Type<Filters[number]>> => {\n return new FilterClass({\n type: 'or',\n filters: filters.map((f) => f.ast),\n });\n};\n\n// TODO(dmaretskyi): Add `Filter.match` to support pattern matching on string props.\n\nconst propsFilterToAst = (predicates: Props<any>): Pick<QueryAST.FilterObject, 'id' | 'props'> => {\n let idFilter: readonly ObjectId[] | undefined;\n if ('id' in predicates) {\n assertArgument(\n typeof predicates.id === 'string' || Array.isArray(predicates.id),\n 'predicates.id',\n 'invalid id filter',\n );\n idFilter = typeof predicates.id === 'string' ? [predicates.id] : predicates.id;\n Schema.Array(ObjectId).pipe(Schema.validateSync)(idFilter);\n }\n\n return {\n id: idFilter,\n props: Object.fromEntries(\n Object.entries(predicates)\n .filter(([prop, _value]) => prop !== 'id')\n .map(([prop, predicate]) => [prop, processPredicate(predicate)]),\n ) as Record<string, QueryAST.Filter>,\n };\n};\n\nconst processPredicate = (predicate: any): QueryAST.Filter => {\n return Match.value(predicate).pipe(\n Match.withReturnType<QueryAST.Filter>(),\n Match.when(is, (predicate) => predicate.ast),\n // TODO(wittjosiah): Add support for array predicates.\n Match.when(Array.isArray, (_predicate) => {\n throw new Error('Array predicates are not yet supported.');\n }),\n Match.when(\n (predicate: any) => !Ref.isRef(predicate) && typeof predicate === 'object' && predicate !== null,\n (predicate) => {\n const nestedProps = Object.fromEntries(\n Object.entries(predicate).map(([key, value]) => [key, processPredicate(value)]),\n );\n\n return {\n type: 'object',\n typename: null,\n props: nestedProps,\n };\n },\n ),\n Match.orElse((value) => eq(value).ast),\n );\n};\n\n/**\n * Returns a human-readable string representation of a Filter AST.\n */\nexport const pretty = (filter: Any): string => internal.prettyFilter(filter.ast);\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;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,YACzBD,OAAOE,QAAQG,UAAAA,EAAW3B,IAAI,CAAC,CAACmC,MAAKhE,MAAAA,MAAW;QAACgE;QAAKP,iBAAiBzD,MAAAA;OAAO,CAAA;AAGhF,aAAO;QACLE,MAAM;QACN+D,UAAU;QACVf,OAAOa;MACT;IACF,CAAA;IAEIG,aAAO,CAAClE,WAAUmE,GAAGnE,MAAAA,EAAOsC,GAAG;EAAA;AAEzC;AAKO,IAAM8B,SAAS,CAAC/B,WAAiCgC,aAAahC,OAAOC,GAAG;",
6
+ "names": ["Match", "Schema", "SchemaAST", "assertArgument", "DXN", "ObjectId", "FilterClass", "ast", "variance", "is", "value", "fromAst", "everything", "type", "typename", "props", "nothing", "filter", "id", "ids", "assertArgument", "every", "ObjectId", "isValid", "length", "schema", "isSchema", "isUnion", "typenames", "types", "map", "getTypeDXNFromSpecifier", "make", "filters", "toString", "dxn", "propsFilterToAst", "startsWith", "DXN", "fromTypename", "typeDXN", "tag", "key", "options", "metaKey", "metaVersion", "version", "text", "searchKind", "foreignKeys", "keys", "eq", "isRef", "TypeError", "operator", "noInline", "encode", "neq", "gt", "gte", "lt", "lte", "in$", "values", "contains", "value", "FilterClass", "type", "between", "from", "to", "_toUnixMs", "date", "getTime", "_timeRangeFilter", "field", "range", "filters", "after", "push", "operator", "before", "length", "everything", "and", "updated", "created", "childOf", "parents", "options", "items", "Array", "isArray", "dxns", "map", "item", "isRef", "dxn", "toString", "getDXN", "transitive", "not", "filter", "ast", "f", "or", "propsFilterToAst", "predicates", "idFilter", "assertArgument", "id", "Schema", "ObjectId", "pipe", "validateSync", "props", "Object", "fromEntries", "entries", "prop", "_value", "predicate", "processPredicate", "withReturnType", "when", "is", "_predicate", "Error", "nestedProps", "key", "typename", "orElse", "eq", "pretty", "prettyFilter"]
7
+ }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  Service
3
- } from "./chunk-FHYIM4RD.mjs";
3
+ } from "./chunk-I2DARWPX.mjs";
4
4
  import {
5
5
  ReferenceAnnotationId,
6
6
  getSchemaDXN,
@@ -343,4 +343,4 @@ export {
343
343
  refFromEncodedReference,
344
344
  StaticRefResolver
345
345
  };
346
- //# sourceMappingURL=chunk-MPAI2MHO.mjs.map
346
+ //# sourceMappingURL=chunk-BMB7IHGB.mjs.map
@@ -33,4 +33,4 @@ export {
33
33
  define,
34
34
  Migration_exports
35
35
  };
36
- //# sourceMappingURL=chunk-SUZMWP3Y.mjs.map
36
+ //# sourceMappingURL=chunk-FIWO2FZK.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../../src/Migration.ts"],
4
+ "sourcesContent": ["//\n// Copyright 2024 DXOS.org\n//\n\n// @import-as-namespace\n\nimport type * as Schema from 'effect/Schema';\n\nimport { type DXN } from '@dxos/keys';\n\nimport type * as Database from './Database';\nimport type * as Entity from './Entity';\nimport { MetaId, type ObjectMeta, getSchemaDXN } from './internal';\n\n/**\n * Result returned by a migration's `transform` callback.\n * The data shape matches the target schema; the optional `[Obj.Meta]` symbol key lets the\n * transform update the object's meta (e.g. `key` / `version`) atomically with the data swap.\n */\nexport type TransformResult<To extends Schema.Schema.AnyNoContext> = Omit<\n Schema.Schema.Type<To>,\n 'id' | Entity.KindId\n> & {\n [MetaId]?: Partial<ObjectMeta>;\n};\n\ntype DefineObjectMigrationOptions<From extends Schema.Schema.AnyNoContext, To extends Schema.Schema.AnyNoContext> = {\n from: From;\n to: To;\n /**\n * Pure function that converts the old object data to the new object data.\n *\n * The returned object may include an optional `[Obj.Meta]` entry to update the object's meta\n * (e.g. registry `key` / `version`) atomically with the data swap.\n */\n // TODO(dmaretskyi): `id` should not be a part of the schema.\n transform: (from: Schema.Schema.Type<From>, context: ObjectMigrationContext) => Promise<TransformResult<To>>;\n\n /**\n * Callback that is called after the object is migrated. Called for every object that is migrated.\n *\n * NOTE: Database mutations performed in this callback are not guaranteed to be idempotent.\n * If multiple peers run the migration separately, the effects may be applied multiple times.\n */\n onMigration?: (params: OnMigrateProps<From, To>) => Promise<void>;\n};\n\n/**\n * Context passed to object migration callbacks.\n */\nexport type ObjectMigrationContext = {\n db: Database.Database;\n};\n\ntype OnMigrateProps<From extends Schema.Schema.AnyNoContext, To extends Schema.Schema.AnyNoContext> = {\n before: Schema.Schema.Type<From>;\n object: Schema.Schema.Type<To>;\n db: Database.Database;\n};\n\n/**\n * Definition of a migration from one object schema version to another.\n */\nexport type ObjectMigration = {\n fromType: DXN;\n toType: DXN;\n fromSchema: Schema.Schema.AnyNoContext;\n toSchema: Schema.Schema.AnyNoContext;\n transform: (from: unknown, context: ObjectMigrationContext) => Promise<unknown>;\n onMigration?: (params: OnMigrateProps<any, any>) => Promise<void>;\n};\n\n/**\n * Define a migration between two object schemas.\n *\n * @example\n * ```ts\n * const migration = Migration.define({\n * from: ContactV1,\n * to: ContactV2,\n * transform: async (from) => ({ name: `${from.firstName} ${from.lastName}` }),\n * onMigration: async () => {},\n * });\n * ```\n */\nexport const define = <From extends Schema.Schema.AnyNoContext, To extends Schema.Schema.AnyNoContext>(\n options: DefineObjectMigrationOptions<From, To>,\n): ObjectMigration => {\n const fromType = getSchemaDXN(options.from);\n if (!fromType) {\n throw new Error('Invalid from schema');\n }\n const toType = getSchemaDXN(options.to);\n if (!toType) {\n throw new Error('Invalid to schema');\n }\n\n return {\n fromType,\n toType,\n fromSchema: options.from,\n toSchema: options.to,\n transform: options.transform as any,\n onMigration: options.onMigration as any,\n };\n};\n"],
5
+ "mappings": ";;;;;;;;AAAA;;;;AAqFO,IAAMA,SAAS,CACpBC,YAAAA;AAEA,QAAMC,WAAWC,aAAaF,QAAQG,IAAI;AAC1C,MAAI,CAACF,UAAU;AACb,UAAM,IAAIG,MAAM,qBAAA;EAClB;AACA,QAAMC,SAASH,aAAaF,QAAQM,EAAE;AACtC,MAAI,CAACD,QAAQ;AACX,UAAM,IAAID,MAAM,mBAAA;EAClB;AAEA,SAAO;IACLH;IACAI;IACAE,YAAYP,QAAQG;IACpBK,UAAUR,QAAQM;IAClBG,WAAWT,QAAQS;IACnBC,aAAaV,QAAQU;EACvB;AACF;",
6
+ "names": ["define", "options", "fromType", "getSchemaDXN", "from", "Error", "toType", "to", "fromSchema", "toSchema", "transform", "onMigration"]
7
+ }