@visiolab/effect-firebase 0.0.0-stage → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (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 +66 -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,297 @@
1
+ import { Schema } from "effect";
2
+ declare namespace CallableError_d_exports {
3
+ export { AlreadyExists, CallableError, DecodeError, EncodeError, ErrorCode, FailedPrecondition, InvalidArgument, NotFound, PermissionDenied, Reason, ResourceExhausted, ResponseError, TransportError, Unauthenticated, Unavailable };
4
+ }
5
+ /**
6
+ * Firebase's error codes, as `firebase-functions` and the client SDK name
7
+ * them, without `ok`.
8
+ *
9
+ * @stability unstable
10
+ * @category schemas
11
+ * @since 0.3.0
12
+ */
13
+ export declare const ErrorCode: Schema.Literals<readonly ["cancelled", "unknown", "invalid-argument", "deadline-exceeded", "not-found", "already-exists", "permission-denied", "resource-exhausted", "failed-precondition", "aborted", "out-of-range", "unimplemented", "internal", "unavailable", "data-loss", "unauthenticated"]>;
14
+ /**
15
+ * One of Firebase's error codes, such as `not-found`.
16
+ *
17
+ * @stability unstable
18
+ * @category models
19
+ * @since 0.3.0
20
+ */
21
+ export type ErrorCode = typeof ErrorCode.Type;
22
+ declare module "effect/Schema" {
23
+ namespace Annotations {
24
+ interface Annotations {
25
+ /**
26
+ * The Firebase error code a Callable answers with when it fails with
27
+ * this error. Set it with `Callable.errorCode` or in a `TaggedError`'s
28
+ * annotations, and read it with `Callable.getErrorCode`.
29
+ */
30
+ readonly callableErrorCode?: ErrorCode | undefined;
31
+ }
32
+ }
33
+ }
34
+ declare const NotFound_base: Schema.Class<NotFound, Schema.TaggedStruct<"NotFound", {
35
+ readonly message: Schema.optional<Schema.String>;
36
+ }>, import("effect/Cause").YieldableError & {
37
+ readonly brand: unique symbol;
38
+ }>;
39
+ /**
40
+ * The resource the call asks for doesn't exist. Its code is `not-found`.
41
+ *
42
+ * @example Failing with a built-in error
43
+ * ```ts
44
+ * import { Effect, Schema } from "effect";
45
+ * import { Callable, CallableError } from "@visiolab/effect-firebase/functions";
46
+ *
47
+ * const GetUser = Callable.make("getUser", {
48
+ * payload: { id: Schema.String },
49
+ * success: Schema.String,
50
+ * error: CallableError.NotFound,
51
+ * });
52
+ *
53
+ * const GetUserLive = Callable.toLayer(GetUser, ({ id }) =>
54
+ * Effect.fail(new CallableError.NotFound({ message: `No user ${id}` })),
55
+ * );
56
+ * ```
57
+ *
58
+ * @stability unstable
59
+ * @category built-in errors
60
+ * @since 0.3.0
61
+ */
62
+ export declare class NotFound extends NotFound_base {}
63
+ declare const PermissionDenied_base: Schema.Class<PermissionDenied, Schema.TaggedStruct<"PermissionDenied", {
64
+ readonly message: Schema.optional<Schema.String>;
65
+ }>, import("effect/Cause").YieldableError & {
66
+ readonly brand: unique symbol;
67
+ }>;
68
+ /**
69
+ * The caller may not do what the call asks. Its code is `permission-denied`.
70
+ *
71
+ * @see {@link Unauthenticated} for a caller who isn't signed in
72
+ *
73
+ * @stability unstable
74
+ * @category built-in errors
75
+ * @since 0.3.0
76
+ */
77
+ export declare class PermissionDenied extends PermissionDenied_base {}
78
+ declare const Unauthenticated_base: Schema.Class<Unauthenticated, Schema.TaggedStruct<"Unauthenticated", {
79
+ readonly message: Schema.optional<Schema.String>;
80
+ }>, import("effect/Cause").YieldableError & {
81
+ readonly brand: unique symbol;
82
+ }>;
83
+ /**
84
+ * The caller isn't signed in. Its code is `unauthenticated`.
85
+ *
86
+ * @see {@link PermissionDenied} for a signed-in caller who may not do this
87
+ *
88
+ * @stability unstable
89
+ * @category built-in errors
90
+ * @since 0.3.0
91
+ */
92
+ export declare class Unauthenticated extends Unauthenticated_base {}
93
+ declare const InvalidArgument_base: Schema.Class<InvalidArgument, Schema.TaggedStruct<"InvalidArgument", {
94
+ readonly message: Schema.optional<Schema.String>;
95
+ }>, import("effect/Cause").YieldableError & {
96
+ readonly brand: unique symbol;
97
+ }>;
98
+ /**
99
+ * The Payload is well-formed but its values are wrong. Its code is
100
+ * `invalid-argument`.
101
+ *
102
+ * **Details**
103
+ *
104
+ * A Payload that doesn't decode is answered with `invalid-argument` already,
105
+ * without this error. Use it for checks the Payload's schema can't express.
106
+ *
107
+ * @see {@link FailedPrecondition} for a valid Payload the current state rejects
108
+ *
109
+ * @stability unstable
110
+ * @category built-in errors
111
+ * @since 0.3.0
112
+ */
113
+ export declare class InvalidArgument extends InvalidArgument_base {}
114
+ declare const AlreadyExists_base: Schema.Class<AlreadyExists, Schema.TaggedStruct<"AlreadyExists", {
115
+ readonly message: Schema.optional<Schema.String>;
116
+ }>, import("effect/Cause").YieldableError & {
117
+ readonly brand: unique symbol;
118
+ }>;
119
+ /**
120
+ * What the call would create exists already. Its code is `already-exists`.
121
+ *
122
+ * @stability unstable
123
+ * @category built-in errors
124
+ * @since 0.3.0
125
+ */
126
+ export declare class AlreadyExists extends AlreadyExists_base {}
127
+ declare const FailedPrecondition_base: Schema.Class<FailedPrecondition, Schema.TaggedStruct<"FailedPrecondition", {
128
+ readonly message: Schema.optional<Schema.String>;
129
+ }>, import("effect/Cause").YieldableError & {
130
+ readonly brand: unique symbol;
131
+ }>;
132
+ /**
133
+ * The system isn't in the state the call needs. Its code is
134
+ * `failed-precondition`.
135
+ *
136
+ * @see {@link InvalidArgument} for a Payload that is wrong whatever the state
137
+ *
138
+ * @stability unstable
139
+ * @category built-in errors
140
+ * @since 0.3.0
141
+ */
142
+ export declare class FailedPrecondition extends FailedPrecondition_base {}
143
+ declare const ResourceExhausted_base: Schema.Class<ResourceExhausted, Schema.TaggedStruct<"ResourceExhausted", {
144
+ readonly message: Schema.optional<Schema.String>;
145
+ }>, import("effect/Cause").YieldableError & {
146
+ readonly brand: unique symbol;
147
+ }>;
148
+ /**
149
+ * A quota or rate limit ran out. Its code is `resource-exhausted`.
150
+ *
151
+ * @stability unstable
152
+ * @category built-in errors
153
+ * @since 0.3.0
154
+ */
155
+ export declare class ResourceExhausted extends ResourceExhausted_base {}
156
+ declare const Unavailable_base: Schema.Class<Unavailable, Schema.TaggedStruct<"Unavailable", {
157
+ readonly message: Schema.optional<Schema.String>;
158
+ }>, import("effect/Cause").YieldableError & {
159
+ readonly brand: unique symbol;
160
+ }>;
161
+ /**
162
+ * The service can't answer right now, and the call may succeed if retried.
163
+ * Its code is `unavailable`.
164
+ *
165
+ * @stability unstable
166
+ * @category built-in errors
167
+ * @since 0.3.0
168
+ */
169
+ export declare class Unavailable extends Unavailable_base {}
170
+ declare const TransportError_base: Schema.Class<TransportError, Schema.TaggedStruct<"TransportError", {
171
+ /** What the SDK threw. */
172
+ readonly cause: Schema.Defect;
173
+ }>, import("effect/Cause").YieldableError & {
174
+ readonly brand: unique symbol;
175
+ }>;
176
+ /**
177
+ * No response arrived: the request never reached the server, the connection
178
+ * broke before it answered, or the client gave up waiting.
179
+ *
180
+ * **Details**
181
+ *
182
+ * The client SDK appends the HTTP status of an answer to its error's message
183
+ * as ` [<status>]`, and reports a network failure as status 0. The errors the
184
+ * SDK makes itself carry no status: its timeout (`deadline-exceeded`), a
185
+ * cancelled call, and a deleted Functions instance. `CallableClient` treats
186
+ * an error without a status, or with status 0, as a `TransportError`, except
187
+ * for an answer the SDK can't read, which is a {@link DecodeError}.
188
+ *
189
+ * @see {@link ResponseError} for an error the server answered with
190
+ *
191
+ * @stability unstable
192
+ * @category errors
193
+ * @since 0.3.0
194
+ */
195
+ export declare class TransportError extends TransportError_base {}
196
+ declare const ResponseError_base: Schema.Class<ResponseError, Schema.TaggedStruct<"ResponseError", {
197
+ /** Firebase's error code, such as `internal`. */
198
+ readonly code: Schema.Literals<readonly ["cancelled", "unknown", "invalid-argument", "deadline-exceeded", "not-found", "already-exists", "permission-denied", "resource-exhausted", "failed-precondition", "aborted", "out-of-range", "unimplemented", "internal", "unavailable", "data-loss", "unauthenticated"]>;
199
+ /** The error's message, without the SDK's ` [status]` suffix. */
200
+ readonly message: Schema.String;
201
+ /** The error's `details`, as the server sent them. */
202
+ readonly details: Schema.Unknown;
203
+ }>, import("effect/Cause").YieldableError & {
204
+ readonly brand: unique symbol;
205
+ }>;
206
+ /**
207
+ * The server answered with an error the contract doesn't declare.
208
+ *
209
+ * **Details**
210
+ *
211
+ * `code` is Firebase's error code without its `functions/` prefix, such as
212
+ * `not-found`. `not-found` usually means the client calls the wrong region or
213
+ * a name the server doesn't export.
214
+ *
215
+ * Only an error the server answered with, with a non-zero HTTP status, is a
216
+ * `ResponseError`. A `deadline-exceeded` the server sends is one; the client
217
+ * SDK's own timeout, which has the same code, is a {@link TransportError}.
218
+ *
219
+ * @see {@link TransportError} for a call no answer arrived for
220
+ *
221
+ * @stability unstable
222
+ * @category errors
223
+ * @since 0.3.0
224
+ */
225
+ export declare class ResponseError extends ResponseError_base {}
226
+ declare const EncodeError_base: Schema.Class<EncodeError, Schema.TaggedStruct<"EncodeError", {
227
+ /** The `Schema.SchemaError` of the encode. */
228
+ readonly cause: Schema.Defect;
229
+ }>, import("effect/Cause").YieldableError & {
230
+ readonly brand: unique symbol;
231
+ }>;
232
+ /**
233
+ * The Payload didn't encode through its `Schema.toCodecJson`, so nothing was
234
+ * sent.
235
+ *
236
+ * @stability unstable
237
+ * @category errors
238
+ * @since 0.3.0
239
+ */
240
+ export declare class EncodeError extends EncodeError_base {}
241
+ declare const DecodeError_base: Schema.Class<DecodeError, Schema.TaggedStruct<"DecodeError", {
242
+ /** The `Schema.SchemaError` of the decode. */
243
+ readonly cause: Schema.Defect;
244
+ }>, import("effect/Cause").YieldableError & {
245
+ readonly brand: unique symbol;
246
+ }>;
247
+ /**
248
+ * The server's answer didn't decode against the contract, as after the server
249
+ * and the client drift apart.
250
+ *
251
+ * @stability unstable
252
+ * @category errors
253
+ * @since 0.3.0
254
+ */
255
+ export declare class DecodeError extends DecodeError_base {}
256
+ /**
257
+ * What went wrong with a call, as one of the reasons above.
258
+ *
259
+ * @stability unstable
260
+ * @category models
261
+ * @since 0.3.0
262
+ */
263
+ export type Reason = TransportError | ResponseError | EncodeError | DecodeError;
264
+ declare const CallableError_base: Schema.Class<CallableError, Schema.TaggedStruct<"CallableError", {
265
+ /** The deployed name of the Callable Function that was called. */
266
+ readonly callable: Schema.String;
267
+ /** What went wrong. */
268
+ readonly reason: Schema.Union<readonly [typeof TransportError, typeof ResponseError, typeof EncodeError, typeof DecodeError]>;
269
+ }>, import("effect/Cause").YieldableError & {
270
+ readonly brand: unique symbol;
271
+ }>;
272
+ /**
273
+ * A call to a Callable failed in a way the contract doesn't declare.
274
+ *
275
+ * **When to use**
276
+ *
277
+ * Use `Effect.catchReason` on its `reason` to recover from one kind of
278
+ * failure, such as a missing response.
279
+ *
280
+ * @example Recovering from a missing response
281
+ * ```ts
282
+ * import { Effect } from "effect";
283
+ * import type { CallableError } from "@visiolab/effect-firebase/functions";
284
+ *
285
+ * declare const call: Effect.Effect<string, CallableError.CallableError>;
286
+ *
287
+ * const program = call.pipe(
288
+ * Effect.catchReason("CallableError", "TransportError", () => Effect.succeed("offline")),
289
+ * );
290
+ * ```
291
+ *
292
+ * @stability unstable
293
+ * @category errors
294
+ * @since 0.3.0
295
+ */
296
+ export declare class CallableError extends CallableError_base {}
297
+ export { CallableError_d_exports };
@@ -0,0 +1,256 @@
1
+ import { __exportAll } from "../_virtual/_rolldown/runtime.mjs";
2
+ import { Schema } from "effect";
3
+ // src/functions/CallableError.ts
4
+ /**
5
+ * Errors of Callables: Firebase's error codes, built-in errors that carry
6
+ * them, and the error a Callable Client fails with when a call goes wrong in a
7
+ * way the contract doesn't declare.
8
+ *
9
+ * @stability unstable
10
+ * @since 0.3.0
11
+ */
12
+ var CallableError_exports = /* @__PURE__ */ __exportAll({
13
+ AlreadyExists: () => AlreadyExists,
14
+ CallableError: () => CallableError,
15
+ DecodeError: () => DecodeError,
16
+ EncodeError: () => EncodeError,
17
+ ErrorCode: () => ErrorCode,
18
+ FailedPrecondition: () => FailedPrecondition,
19
+ InvalidArgument: () => InvalidArgument,
20
+ NotFound: () => NotFound,
21
+ PermissionDenied: () => PermissionDenied,
22
+ ResourceExhausted: () => ResourceExhausted,
23
+ ResponseError: () => ResponseError,
24
+ TransportError: () => TransportError,
25
+ Unauthenticated: () => Unauthenticated,
26
+ Unavailable: () => Unavailable
27
+ });
28
+ /**
29
+ * Firebase's error codes, as `firebase-functions` and the client SDK name
30
+ * them, without `ok`.
31
+ *
32
+ * @stability unstable
33
+ * @category schemas
34
+ * @since 0.3.0
35
+ */
36
+ const ErrorCode = Schema.Literals([
37
+ "cancelled",
38
+ "unknown",
39
+ "invalid-argument",
40
+ "deadline-exceeded",
41
+ "not-found",
42
+ "already-exists",
43
+ "permission-denied",
44
+ "resource-exhausted",
45
+ "failed-precondition",
46
+ "aborted",
47
+ "out-of-range",
48
+ "unimplemented",
49
+ "internal",
50
+ "unavailable",
51
+ "data-loss",
52
+ "unauthenticated"
53
+ ]);
54
+ /**
55
+ * The resource the call asks for doesn't exist. Its code is `not-found`.
56
+ *
57
+ * @example Failing with a built-in error
58
+ * ```ts
59
+ * import { Effect, Schema } from "effect";
60
+ * import { Callable, CallableError } from "@visiolab/effect-firebase/functions";
61
+ *
62
+ * const GetUser = Callable.make("getUser", {
63
+ * payload: { id: Schema.String },
64
+ * success: Schema.String,
65
+ * error: CallableError.NotFound,
66
+ * });
67
+ *
68
+ * const GetUserLive = Callable.toLayer(GetUser, ({ id }) =>
69
+ * Effect.fail(new CallableError.NotFound({ message: `No user ${id}` })),
70
+ * );
71
+ * ```
72
+ *
73
+ * @stability unstable
74
+ * @category built-in errors
75
+ * @since 0.3.0
76
+ */
77
+ var NotFound = class extends Schema.TaggedError()("NotFound", { message: Schema.optional(Schema.String) }, { callableErrorCode: "not-found" }) {};
78
+ /**
79
+ * The caller may not do what the call asks. Its code is `permission-denied`.
80
+ *
81
+ * @see {@link Unauthenticated} for a caller who isn't signed in
82
+ *
83
+ * @stability unstable
84
+ * @category built-in errors
85
+ * @since 0.3.0
86
+ */
87
+ var PermissionDenied = class extends Schema.TaggedError()("PermissionDenied", { message: Schema.optional(Schema.String) }, { callableErrorCode: "permission-denied" }) {};
88
+ /**
89
+ * The caller isn't signed in. Its code is `unauthenticated`.
90
+ *
91
+ * @see {@link PermissionDenied} for a signed-in caller who may not do this
92
+ *
93
+ * @stability unstable
94
+ * @category built-in errors
95
+ * @since 0.3.0
96
+ */
97
+ var Unauthenticated = class extends Schema.TaggedError()("Unauthenticated", { message: Schema.optional(Schema.String) }, { callableErrorCode: "unauthenticated" }) {};
98
+ /**
99
+ * The Payload is well-formed but its values are wrong. Its code is
100
+ * `invalid-argument`.
101
+ *
102
+ * **Details**
103
+ *
104
+ * A Payload that doesn't decode is answered with `invalid-argument` already,
105
+ * without this error. Use it for checks the Payload's schema can't express.
106
+ *
107
+ * @see {@link FailedPrecondition} for a valid Payload the current state rejects
108
+ *
109
+ * @stability unstable
110
+ * @category built-in errors
111
+ * @since 0.3.0
112
+ */
113
+ var InvalidArgument = class extends Schema.TaggedError()("InvalidArgument", { message: Schema.optional(Schema.String) }, { callableErrorCode: "invalid-argument" }) {};
114
+ /**
115
+ * What the call would create exists already. Its code is `already-exists`.
116
+ *
117
+ * @stability unstable
118
+ * @category built-in errors
119
+ * @since 0.3.0
120
+ */
121
+ var AlreadyExists = class extends Schema.TaggedError()("AlreadyExists", { message: Schema.optional(Schema.String) }, { callableErrorCode: "already-exists" }) {};
122
+ /**
123
+ * The system isn't in the state the call needs. Its code is
124
+ * `failed-precondition`.
125
+ *
126
+ * @see {@link InvalidArgument} for a Payload that is wrong whatever the state
127
+ *
128
+ * @stability unstable
129
+ * @category built-in errors
130
+ * @since 0.3.0
131
+ */
132
+ var FailedPrecondition = class extends Schema.TaggedError()("FailedPrecondition", { message: Schema.optional(Schema.String) }, { callableErrorCode: "failed-precondition" }) {};
133
+ /**
134
+ * A quota or rate limit ran out. Its code is `resource-exhausted`.
135
+ *
136
+ * @stability unstable
137
+ * @category built-in errors
138
+ * @since 0.3.0
139
+ */
140
+ var ResourceExhausted = class extends Schema.TaggedError()("ResourceExhausted", { message: Schema.optional(Schema.String) }, { callableErrorCode: "resource-exhausted" }) {};
141
+ /**
142
+ * The service can't answer right now, and the call may succeed if retried.
143
+ * Its code is `unavailable`.
144
+ *
145
+ * @stability unstable
146
+ * @category built-in errors
147
+ * @since 0.3.0
148
+ */
149
+ var Unavailable = class extends Schema.TaggedError()("Unavailable", { message: Schema.optional(Schema.String) }, { callableErrorCode: "unavailable" }) {};
150
+ /**
151
+ * No response arrived: the request never reached the server, the connection
152
+ * broke before it answered, or the client gave up waiting.
153
+ *
154
+ * **Details**
155
+ *
156
+ * The client SDK appends the HTTP status of an answer to its error's message
157
+ * as ` [<status>]`, and reports a network failure as status 0. The errors the
158
+ * SDK makes itself carry no status: its timeout (`deadline-exceeded`), a
159
+ * cancelled call, and a deleted Functions instance. `CallableClient` treats
160
+ * an error without a status, or with status 0, as a `TransportError`, except
161
+ * for an answer the SDK can't read, which is a {@link DecodeError}.
162
+ *
163
+ * @see {@link ResponseError} for an error the server answered with
164
+ *
165
+ * @stability unstable
166
+ * @category errors
167
+ * @since 0.3.0
168
+ */
169
+ var TransportError = class extends Schema.TaggedError()("TransportError", {
170
+ /** What the SDK threw. */
171
+ cause: Schema.Defect() }) {};
172
+ /**
173
+ * The server answered with an error the contract doesn't declare.
174
+ *
175
+ * **Details**
176
+ *
177
+ * `code` is Firebase's error code without its `functions/` prefix, such as
178
+ * `not-found`. `not-found` usually means the client calls the wrong region or
179
+ * a name the server doesn't export.
180
+ *
181
+ * Only an error the server answered with, with a non-zero HTTP status, is a
182
+ * `ResponseError`. A `deadline-exceeded` the server sends is one; the client
183
+ * SDK's own timeout, which has the same code, is a {@link TransportError}.
184
+ *
185
+ * @see {@link TransportError} for a call no answer arrived for
186
+ *
187
+ * @stability unstable
188
+ * @category errors
189
+ * @since 0.3.0
190
+ */
191
+ var ResponseError = class extends Schema.TaggedError()("ResponseError", {
192
+ /** Firebase's error code, such as `internal`. */
193
+ code: ErrorCode,
194
+ /** The error's message, without the SDK's ` [status]` suffix. */
195
+ message: Schema.String,
196
+ /** The error's `details`, as the server sent them. */
197
+ details: Schema.Unknown
198
+ }) {};
199
+ /**
200
+ * The Payload didn't encode through its `Schema.toCodecJson`, so nothing was
201
+ * sent.
202
+ *
203
+ * @stability unstable
204
+ * @category errors
205
+ * @since 0.3.0
206
+ */
207
+ var EncodeError = class extends Schema.TaggedError()("EncodeError", {
208
+ /** The `Schema.SchemaError` of the encode. */
209
+ cause: Schema.Defect() }) {};
210
+ /**
211
+ * The server's answer didn't decode against the contract, as after the server
212
+ * and the client drift apart.
213
+ *
214
+ * @stability unstable
215
+ * @category errors
216
+ * @since 0.3.0
217
+ */
218
+ var DecodeError = class extends Schema.TaggedError()("DecodeError", {
219
+ /** The `Schema.SchemaError` of the decode. */
220
+ cause: Schema.Defect() }) {};
221
+ /**
222
+ * A call to a Callable failed in a way the contract doesn't declare.
223
+ *
224
+ * **When to use**
225
+ *
226
+ * Use `Effect.catchReason` on its `reason` to recover from one kind of
227
+ * failure, such as a missing response.
228
+ *
229
+ * @example Recovering from a missing response
230
+ * ```ts
231
+ * import { Effect } from "effect";
232
+ * import type { CallableError } from "@visiolab/effect-firebase/functions";
233
+ *
234
+ * declare const call: Effect.Effect<string, CallableError.CallableError>;
235
+ *
236
+ * const program = call.pipe(
237
+ * Effect.catchReason("CallableError", "TransportError", () => Effect.succeed("offline")),
238
+ * );
239
+ * ```
240
+ *
241
+ * @stability unstable
242
+ * @category errors
243
+ * @since 0.3.0
244
+ */
245
+ var CallableError = class extends Schema.TaggedError()("CallableError", {
246
+ /** The deployed name of the Callable Function that was called. */
247
+ callable: Schema.String,
248
+ /** What went wrong. */
249
+ reason: Schema.Union([
250
+ TransportError,
251
+ ResponseError,
252
+ EncodeError,
253
+ DecodeError
254
+ ])
255
+ }) {};
256
+ export { AlreadyExists, CallableError, CallableError_exports, DecodeError, EncodeError, ErrorCode, FailedPrecondition, InvalidArgument, NotFound, PermissionDenied, ResourceExhausted, ResponseError, TransportError, Unauthenticated, Unavailable };