@visiolab/effect-firebase 0.0.0-stage → 0.3.1

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 (140) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +81 -2
  3. package/dist/_virtual/_rolldown/runtime.mjs +12 -0
  4. package/dist/app/App.d.mts +27 -0
  5. package/dist/app/App.mjs +27 -0
  6. package/dist/app/index.d.mts +2 -0
  7. package/dist/app/index.mjs +1 -0
  8. package/dist/firestore/Collection.d.mts +423 -0
  9. package/dist/firestore/Collection.mjs +133 -0
  10. package/dist/firestore/CollectionGroup.d.mts +164 -0
  11. package/dist/firestore/CollectionGroup.mjs +84 -0
  12. package/dist/firestore/DocumentPath.d.mts +95 -0
  13. package/dist/firestore/DocumentPath.mjs +71 -0
  14. package/dist/firestore/DocumentSnapshot.d.mts +239 -0
  15. package/dist/firestore/DocumentSnapshot.mjs +134 -0
  16. package/dist/firestore/FieldValue.d.mts +332 -0
  17. package/dist/firestore/FieldValue.mjs +256 -0
  18. package/dist/firestore/Firestore.d.mts +1165 -0
  19. package/dist/firestore/Firestore.mjs +274 -0
  20. package/dist/firestore/FirestoreModel.d.mts +1232 -0
  21. package/dist/firestore/FirestoreModel.mjs +586 -0
  22. package/dist/firestore/FirestoreSchema.d.mts +567 -0
  23. package/dist/firestore/FirestoreSchema.mjs +419 -0
  24. package/dist/firestore/FirestoreValue.d.mts +145 -0
  25. package/dist/firestore/FirestoreValue.mjs +87 -0
  26. package/dist/firestore/GeoPoint.d.mts +90 -0
  27. package/dist/firestore/GeoPoint.mjs +75 -0
  28. package/dist/firestore/Patch.d.mts +73 -0
  29. package/dist/firestore/Patch.mjs +57 -0
  30. package/dist/firestore/QuerySnapshot.d.mts +107 -0
  31. package/dist/firestore/QuerySnapshot.mjs +43 -0
  32. package/dist/firestore/Timestamp.d.mts +273 -0
  33. package/dist/firestore/Timestamp.mjs +255 -0
  34. package/dist/firestore/index.d.mts +14 -0
  35. package/dist/firestore/index.mjs +14 -0
  36. package/dist/firestore/internal/collection.mjs +156 -0
  37. package/dist/firestore/internal/collectionGroup.mjs +64 -0
  38. package/dist/firestore/internal/documentPath.d.mts +4 -0
  39. package/dist/firestore/internal/documentPath.mjs +42 -0
  40. package/dist/firestore/internal/documentSnapshot.mjs +63 -0
  41. package/dist/firestore/internal/fieldValue.d.mts +11 -0
  42. package/dist/firestore/internal/fieldValue.mjs +88 -0
  43. package/dist/firestore/internal/firestore.mjs +145 -0
  44. package/dist/firestore/internal/firestoreError.d.mts +29 -0
  45. package/dist/firestore/internal/firestoreError.mjs +30 -0
  46. package/dist/firestore/internal/firestoreModel.mjs +719 -0
  47. package/dist/firestore/internal/firestoreSchema.mjs +123 -0
  48. package/dist/firestore/internal/firestoreValue.mjs +108 -0
  49. package/dist/firestore/internal/firestoreValueWalk.d.mts +58 -0
  50. package/dist/firestore/internal/firestoreValueWalk.mjs +223 -0
  51. package/dist/firestore/internal/geoPoint.d.mts +4 -0
  52. package/dist/firestore/internal/geoPoint.mjs +39 -0
  53. package/dist/firestore/internal/patch.mjs +19 -0
  54. package/dist/firestore/internal/querySnapshot.mjs +24 -0
  55. package/dist/firestore/internal/schemaAST.mjs +35 -0
  56. package/dist/firestore/internal/snapshotExtra.mjs +35 -0
  57. package/dist/firestore/internal/streamFromListener.mjs +12 -0
  58. package/dist/firestore/internal/timestamp.d.mts +4 -0
  59. package/dist/firestore/internal/timestamp.mjs +66 -0
  60. package/dist/firestore/internal/timestampSchema.mjs +31 -0
  61. package/dist/firestore/internal/transactionFromCallback.mjs +66 -0
  62. package/dist/functions/Callable.d.mts +654 -0
  63. package/dist/functions/Callable.mjs +450 -0
  64. package/dist/functions/CallableError.d.mts +297 -0
  65. package/dist/functions/CallableError.mjs +256 -0
  66. package/dist/functions/CallableMiddleware.d.mts +213 -0
  67. package/dist/functions/CallableMiddleware.mjs +52 -0
  68. package/dist/functions/CallableRequest.d.mts +166 -0
  69. package/dist/functions/CallableRequest.mjs +18 -0
  70. package/dist/functions/Caller.d.mts +103 -0
  71. package/dist/functions/Caller.mjs +115 -0
  72. package/dist/functions/DocumentTrigger.d.mts +795 -0
  73. package/dist/functions/DocumentTrigger.mjs +566 -0
  74. package/dist/functions/FirebaseFunction.d.mts +79 -0
  75. package/dist/functions/FirebaseFunction.mjs +4 -0
  76. package/dist/functions/FunctionGroup.d.mts +175 -0
  77. package/dist/functions/FunctionGroup.mjs +64 -0
  78. package/dist/functions/index.d.mts +9 -0
  79. package/dist/functions/index.mjs +9 -0
  80. package/dist/functions/internal/callable.mjs +167 -0
  81. package/dist/functions/internal/callableMiddleware.d.mts +19 -0
  82. package/dist/functions/internal/callableMiddleware.mjs +15 -0
  83. package/dist/functions/internal/callableRequest.mjs +6 -0
  84. package/dist/functions/internal/documentTrigger.d.mts +10 -0
  85. package/dist/functions/internal/documentTrigger.mjs +73 -0
  86. package/dist/functions/internal/firebaseFunction.d.mts +5 -0
  87. package/dist/functions/internal/firebaseFunction.mjs +24 -0
  88. package/dist/functions/internal/functionGroup.mjs +36 -0
  89. package/package.json +72 -3
  90. package/src/app/App.ts +24 -0
  91. package/src/app/index.ts +7 -0
  92. package/src/firestore/Collection.ts +520 -0
  93. package/src/firestore/CollectionGroup.ts +245 -0
  94. package/src/firestore/DocumentPath.ts +114 -0
  95. package/src/firestore/DocumentSnapshot.ts +308 -0
  96. package/src/firestore/FieldValue.ts +375 -0
  97. package/src/firestore/Firestore.ts +1432 -0
  98. package/src/firestore/FirestoreModel.ts +1884 -0
  99. package/src/firestore/FirestoreSchema.ts +643 -0
  100. package/src/firestore/FirestoreValue.ts +207 -0
  101. package/src/firestore/GeoPoint.ts +105 -0
  102. package/src/firestore/Patch.ts +117 -0
  103. package/src/firestore/QuerySnapshot.ts +150 -0
  104. package/src/firestore/Timestamp.ts +302 -0
  105. package/src/firestore/index.ts +67 -0
  106. package/src/firestore/internal/collection.ts +246 -0
  107. package/src/firestore/internal/collectionGroup.ts +81 -0
  108. package/src/firestore/internal/documentPath.ts +53 -0
  109. package/src/firestore/internal/documentSnapshot.ts +117 -0
  110. package/src/firestore/internal/fieldValue.ts +119 -0
  111. package/src/firestore/internal/firestore.ts +322 -0
  112. package/src/firestore/internal/firestoreError.ts +36 -0
  113. package/src/firestore/internal/firestoreModel.ts +1242 -0
  114. package/src/firestore/internal/firestoreSchema.ts +218 -0
  115. package/src/firestore/internal/firestoreValue.ts +202 -0
  116. package/src/firestore/internal/firestoreValueWalk.ts +349 -0
  117. package/src/firestore/internal/geoPoint.ts +59 -0
  118. package/src/firestore/internal/patch.ts +21 -0
  119. package/src/firestore/internal/querySnapshot.ts +39 -0
  120. package/src/firestore/internal/schemaAST.ts +83 -0
  121. package/src/firestore/internal/snapshotExtra.ts +47 -0
  122. package/src/firestore/internal/streamFromListener.ts +27 -0
  123. package/src/firestore/internal/timestamp.ts +119 -0
  124. package/src/firestore/internal/timestampSchema.ts +42 -0
  125. package/src/firestore/internal/transactionFromCallback.ts +106 -0
  126. package/src/functions/Callable.ts +855 -0
  127. package/src/functions/CallableError.ts +348 -0
  128. package/src/functions/CallableMiddleware.ts +279 -0
  129. package/src/functions/CallableRequest.ts +207 -0
  130. package/src/functions/Caller.ts +141 -0
  131. package/src/functions/DocumentTrigger.ts +927 -0
  132. package/src/functions/FirebaseFunction.ts +96 -0
  133. package/src/functions/FunctionGroup.ts +225 -0
  134. package/src/functions/index.ts +62 -0
  135. package/src/functions/internal/callable.ts +272 -0
  136. package/src/functions/internal/callableMiddleware.ts +54 -0
  137. package/src/functions/internal/callableRequest.ts +8 -0
  138. package/src/functions/internal/documentTrigger.ts +143 -0
  139. package/src/functions/internal/firebaseFunction.ts +58 -0
  140. package/src/functions/internal/functionGroup.ts +47 -0
@@ -0,0 +1,256 @@
1
+ import { __exportAll } from "../_virtual/_rolldown/runtime.mjs";
2
+ import { arrayRemove as arrayRemove$1, arrayUnion as arrayUnion$1, decrement as decrement$1, deleteField as deleteField$1, increment as increment$1, isArrayRemove as isArrayRemove$1, isArrayUnion as isArrayUnion$1, isDeleteField as isDeleteField$1, isIncrement as isIncrement$1, isServerTimestamp as isServerTimestamp$1, serverTimestamp as serverTimestamp$1 } from "./internal/fieldValue.mjs";
3
+ // src/firestore/FieldValue.ts
4
+ var FieldValue_exports = /* @__PURE__ */ __exportAll({
5
+ arrayRemove: () => arrayRemove,
6
+ arrayUnion: () => arrayUnion,
7
+ decrement: () => decrement,
8
+ deleteField: () => deleteField,
9
+ increment: () => increment,
10
+ isArrayRemove: () => isArrayRemove,
11
+ isArrayUnion: () => isArrayUnion,
12
+ isDeleteField: () => isDeleteField,
13
+ isIncrement: () => isIncrement,
14
+ isServerTimestamp: () => isServerTimestamp,
15
+ serverTimestamp: () => serverTimestamp
16
+ });
17
+ /**
18
+ * Asks the server to write the time it applies the write.
19
+ *
20
+ * **When to use**
21
+ *
22
+ * Use for fields such as `createdAt` and `updatedAt` that every client should
23
+ * agree on. The local clock differs between clients, the server's does not.
24
+ *
25
+ * **Details**
26
+ *
27
+ * It carries nothing, so there is only this one value. The field reads back as
28
+ * the timestamp the server wrote.
29
+ *
30
+ * @example Stamping a document with the server's time
31
+ * ```ts
32
+ * import { Schema } from "effect";
33
+ * import { FieldValue, FirestoreModel } from "@visiolab/effect-firebase/firestore";
34
+ *
35
+ * class Post extends FirestoreModel.Class<Post>("Post")({
36
+ * updatedAt: FirestoreModel.Timestamp(Schema.DateTimeUtc),
37
+ * }) {}
38
+ *
39
+ * Post.update.make({ updatedAt: FieldValue.serverTimestamp });
40
+ * ```
41
+ *
42
+ * @see {@link Timestamp.now} for the local time instead
43
+ * @see {@link FirestoreModel.Timestamp} for a model field that accepts it
44
+ * @see {@link FirestoreSchema.ServerTimestampOr} for a schema that accepts it
45
+ * @see {@link FirestoreSchema.ServerTimestamp} for a schema that always writes it
46
+ *
47
+ * @stability unstable
48
+ * @category constructors
49
+ * @since 0.2.0
50
+ */
51
+ const serverTimestamp = serverTimestamp$1;
52
+ /**
53
+ * Checks whether `u` is the {@link ServerTimestamp} sentinel.
54
+ *
55
+ * @stability unstable
56
+ * @category guards
57
+ * @since 0.2.0
58
+ */
59
+ const isServerTimestamp = isServerTimestamp$1;
60
+ /**
61
+ * Checks whether `u` is an {@link Increment} sentinel.
62
+ *
63
+ * @stability unstable
64
+ * @category guards
65
+ * @since 0.2.0
66
+ */
67
+ const isIncrement = isIncrement$1;
68
+ /**
69
+ * Asks the server to raise a number field by `by`.
70
+ *
71
+ * **When to use**
72
+ *
73
+ * Use for counters and totals that several clients may change at once. Two
74
+ * clients that each read a number and write back the sum lose one of the
75
+ * changes; two increments do not.
76
+ *
77
+ * **Details**
78
+ *
79
+ * Throws unless `by` is a finite number. Integers and doubles both work; an
80
+ * integer added to a double gives a double. A field that holds no number, or
81
+ * is missing, counts as zero.
82
+ *
83
+ * @example Counting a visit
84
+ * ```ts
85
+ * import { Schema } from "effect";
86
+ * import { FieldValue, FirestoreModel } from "@visiolab/effect-firebase/firestore";
87
+ *
88
+ * class Page extends FirestoreModel.Class<Page>("Page")({
89
+ * visits: FirestoreModel.Number(Schema.Int),
90
+ * }) {}
91
+ *
92
+ * Page.update.make({ visits: FieldValue.increment(1) });
93
+ * ```
94
+ *
95
+ * @see {@link decrement} for lowering a field
96
+ * @see {@link FirestoreModel.Number} for a model field that accepts it
97
+ * @see {@link FirestoreSchema.IncrementOr} for a schema that accepts it
98
+ *
99
+ * @stability unstable
100
+ * @category constructors
101
+ * @since 0.2.0
102
+ */
103
+ const increment = increment$1;
104
+ /**
105
+ * Asks the server to lower a number field by `by`.
106
+ *
107
+ * **When to use**
108
+ *
109
+ * Use where the code counts down, so it reads that way rather than as an
110
+ * increment by a negative number.
111
+ *
112
+ * **Details**
113
+ *
114
+ * It is {@link increment} of `-by`: `decrement(2).by` is `-2`.
115
+ *
116
+ * @see {@link increment} for raising a field
117
+ *
118
+ * @stability unstable
119
+ * @category constructors
120
+ * @since 0.2.0
121
+ */
122
+ const decrement = decrement$1;
123
+ /**
124
+ * Asks the server to remove a field.
125
+ *
126
+ * **When to use**
127
+ *
128
+ * Use in an update to remove an optional field. Leaving a field out of an
129
+ * update keeps it as it is, so removing one has to be asked for.
130
+ *
131
+ * **Details**
132
+ *
133
+ * After the write, the document has no key at all for the field, not one
134
+ * holding `null`. Only an update accepts it: a document written whole with
135
+ * `setDoc` drops a field by leaving it out, and Firestore refuses the sentinel
136
+ * there.
137
+ *
138
+ * It carries nothing, so there is only this one value. It is not called
139
+ * `delete` because that is a reserved word in JavaScript, which is also why the
140
+ * client SDK calls its own `deleteField`.
141
+ *
142
+ * @example Removing an optional field
143
+ * ```ts
144
+ * import { Schema } from "effect";
145
+ * import { FieldValue, FirestoreModel } from "@visiolab/effect-firebase/firestore";
146
+ *
147
+ * class User extends FirestoreModel.Class<User>("User")({
148
+ * nickname: FirestoreModel.Optional(Schema.String),
149
+ * }) {}
150
+ *
151
+ * User.update.make({ nickname: FieldValue.deleteField });
152
+ * ```
153
+ *
154
+ * @see {@link FirestoreModel.Optional} for a model field that accepts it
155
+ * @see {@link FirestoreSchema.DeleteFieldOr} for a schema that accepts it
156
+ *
157
+ * @stability unstable
158
+ * @category constructors
159
+ * @since 0.2.0
160
+ */
161
+ const deleteField = deleteField$1;
162
+ /**
163
+ * Checks whether `u` is the {@link DeleteField} sentinel.
164
+ *
165
+ * @stability unstable
166
+ * @category guards
167
+ * @since 0.2.0
168
+ */
169
+ const isDeleteField = isDeleteField$1;
170
+ /**
171
+ * Checks whether `u` is an {@link ArrayUnion} sentinel.
172
+ *
173
+ * @stability unstable
174
+ * @category guards
175
+ * @since 0.2.0
176
+ */
177
+ const isArrayUnion = isArrayUnion$1;
178
+ /**
179
+ * Asks the server to add `elements` to an array, skipping any it holds already.
180
+ *
181
+ * **When to use**
182
+ *
183
+ * Use to add to an array that several clients may change at once. A client
184
+ * that reads the array, adds an element and writes it back loses whatever
185
+ * another client added in between; `arrayUnion` does not.
186
+ *
187
+ * **Details**
188
+ *
189
+ * Elements are compared by value, as {@link ArrayUnion} describes. With no
190
+ * elements it changes nothing, except that a field that held no array ends up
191
+ * holding an empty one.
192
+ *
193
+ * @example Adding a tag
194
+ * ```ts
195
+ * import { Schema } from "effect";
196
+ * import { FieldValue, FirestoreModel } from "@visiolab/effect-firebase/firestore";
197
+ *
198
+ * class Article extends FirestoreModel.Class<Article>("Article")({
199
+ * tags: FirestoreModel.Array(Schema.String),
200
+ * }) {}
201
+ *
202
+ * Article.update.make({ tags: FieldValue.arrayUnion("news") });
203
+ * ```
204
+ *
205
+ * @see {@link arrayRemove} for removing elements
206
+ * @see {@link FirestoreModel.Array} for a model field that accepts it
207
+ * @see {@link FirestoreSchema.ArrayOr} for a schema that accepts it
208
+ *
209
+ * @stability unstable
210
+ * @category constructors
211
+ * @since 0.2.0
212
+ */
213
+ const arrayUnion = arrayUnion$1;
214
+ /**
215
+ * Checks whether `u` is an {@link ArrayRemove} sentinel.
216
+ *
217
+ * @stability unstable
218
+ * @category guards
219
+ * @since 0.2.0
220
+ */
221
+ const isArrayRemove = isArrayRemove$1;
222
+ /**
223
+ * Asks the server to remove every element equal to one of `elements` from an
224
+ * array.
225
+ *
226
+ * **When to use**
227
+ *
228
+ * Use to remove from an array that several clients may change at once, keeping
229
+ * whatever they add in the meantime.
230
+ *
231
+ * **Details**
232
+ *
233
+ * The match is exact, as {@link ArrayRemove} describes.
234
+ *
235
+ * @example Removing a tag
236
+ * ```ts
237
+ * import { Schema } from "effect";
238
+ * import { FieldValue, FirestoreModel } from "@visiolab/effect-firebase/firestore";
239
+ *
240
+ * class Article extends FirestoreModel.Class<Article>("Article")({
241
+ * tags: FirestoreModel.Array(Schema.String),
242
+ * }) {}
243
+ *
244
+ * Article.update.make({ tags: FieldValue.arrayRemove("draft") });
245
+ * ```
246
+ *
247
+ * @see {@link arrayUnion} for adding elements
248
+ * @see {@link FirestoreModel.Array} for a model field that accepts it
249
+ * @see {@link FirestoreSchema.ArrayOr} for a schema that accepts it
250
+ *
251
+ * @stability unstable
252
+ * @category constructors
253
+ * @since 0.2.0
254
+ */
255
+ const arrayRemove = arrayRemove$1;
256
+ export { FieldValue_exports, arrayRemove, arrayUnion, decrement, deleteField, increment, isArrayRemove, isArrayUnion, isDeleteField, isIncrement, isServerTimestamp, serverTimestamp };