@visiolab/effect-firebase-client 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.
- package/LICENSE +21 -0
- package/README.md +70 -2
- package/dist/_virtual/_rolldown/runtime.mjs +12 -0
- package/dist/app/App.d.mts +117 -0
- package/dist/app/App.mjs +149 -0
- package/dist/app/App.mjs.map +1 -0
- package/dist/app/index.d.mts +2 -0
- package/dist/app/index.mjs +1 -0
- package/dist/app/internal/app.mjs +20 -0
- package/dist/app/internal/app.mjs.map +1 -0
- package/dist/firestore/ClientDocumentSnapshot.d.mts +106 -0
- package/dist/firestore/ClientDocumentSnapshot.mjs +86 -0
- package/dist/firestore/ClientDocumentSnapshot.mjs.map +1 -0
- package/dist/firestore/ClientFirestore.d.mts +331 -0
- package/dist/firestore/ClientFirestore.mjs +146 -0
- package/dist/firestore/ClientFirestore.mjs.map +1 -0
- package/dist/firestore/ClientFirestoreValue.d.mts +61 -0
- package/dist/firestore/ClientFirestoreValue.mjs +62 -0
- package/dist/firestore/ClientFirestoreValue.mjs.map +1 -0
- package/dist/firestore/ClientQuerySnapshot.d.mts +52 -0
- package/dist/firestore/ClientQuerySnapshot.mjs +58 -0
- package/dist/firestore/ClientQuerySnapshot.mjs.map +1 -0
- package/dist/firestore/index.d.mts +5 -0
- package/dist/firestore/index.mjs +5 -0
- package/dist/firestore/internal/firestore.mjs +158 -0
- package/dist/firestore/internal/firestore.mjs.map +1 -0
- package/dist/firestore/internal/firestoreValue.mjs +43 -0
- package/dist/firestore/internal/firestoreValue.mjs.map +1 -0
- package/dist/firestore/internal/snapshotMetadata.mjs +15 -0
- package/dist/firestore/internal/snapshotMetadata.mjs.map +1 -0
- package/dist/functions/CallableClient.d.mts +139 -0
- package/dist/functions/CallableClient.mjs +215 -0
- package/dist/functions/CallableClient.mjs.map +1 -0
- package/dist/functions/ClientFunctions.d.mts +112 -0
- package/dist/functions/ClientFunctions.mjs +105 -0
- package/dist/functions/ClientFunctions.mjs.map +1 -0
- package/dist/functions/index.d.mts +3 -0
- package/dist/functions/index.mjs +3 -0
- package/package.json +63 -3
- package/src/app/App.ts +163 -0
- package/src/app/index.ts +7 -0
- package/src/app/internal/app.ts +35 -0
- package/src/firestore/ClientDocumentSnapshot.ts +156 -0
- package/src/firestore/ClientFirestore.ts +410 -0
- package/src/firestore/ClientFirestoreValue.ts +94 -0
- package/src/firestore/ClientQuerySnapshot.ts +93 -0
- package/src/firestore/index.ts +30 -0
- package/src/firestore/internal/firestore.ts +264 -0
- package/src/firestore/internal/firestoreValue.ts +58 -0
- package/src/firestore/internal/snapshotMetadata.ts +14 -0
- package/src/functions/CallableClient.ts +296 -0
- package/src/functions/ClientFunctions.ts +149 -0
- package/src/functions/index.ts +15 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cloud Functions for Firebase on the client SDK: the `Functions` instance
|
|
3
|
+
* that a Callable Client calls through, for one region.
|
|
4
|
+
*
|
|
5
|
+
* A call that fails with `not-found` usually went to the wrong region, or to a
|
|
6
|
+
* name the server doesn't export: build the client of a Function Group's
|
|
7
|
+
* member from its group, so it calls `<group>-<name>`.
|
|
8
|
+
*
|
|
9
|
+
* @example Pointing the client at a region
|
|
10
|
+
* ```ts
|
|
11
|
+
* import { Layer } from "effect";
|
|
12
|
+
* import { App } from "@visiolab/effect-firebase-client/app";
|
|
13
|
+
* import { ClientFunctions } from "@visiolab/effect-firebase-client/functions";
|
|
14
|
+
*
|
|
15
|
+
* const FunctionsLive = ClientFunctions.layer({ regionOrCustomDomain: "europe-west1" }).pipe(
|
|
16
|
+
* Layer.provide(App.layer({ apiKey: "<api key>", projectId: "my-project", appId: "<app id>" })),
|
|
17
|
+
* );
|
|
18
|
+
* ```
|
|
19
|
+
*
|
|
20
|
+
* @stability unstable
|
|
21
|
+
* @since 0.3.0
|
|
22
|
+
*/
|
|
23
|
+
import { Context, Effect, Layer } from "effect";
|
|
24
|
+
import * as Client from "firebase/functions";
|
|
25
|
+
import * as App from "../app/App.ts";
|
|
26
|
+
// Only the documentation links to it.
|
|
27
|
+
// oxlint-disable-next-line no-unused-vars
|
|
28
|
+
import type * as CallableClient from "./CallableClient.ts";
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* The client SDK's `Functions` instance for one region.
|
|
32
|
+
*
|
|
33
|
+
* @stability unstable
|
|
34
|
+
* @category models
|
|
35
|
+
* @since 0.3.0
|
|
36
|
+
*/
|
|
37
|
+
export interface ClientFunctions {
|
|
38
|
+
/** The SDK's own `Functions` instance, for what this package doesn't wrap. */
|
|
39
|
+
readonly instance: Client.Functions;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Service key for {@link ClientFunctions}.
|
|
44
|
+
*
|
|
45
|
+
* **When to use**
|
|
46
|
+
*
|
|
47
|
+
* Use to give every Callable Client one region and emulator setting. Provide
|
|
48
|
+
* it with {@link layer}. A {@link CallableClient.make} client reads it once,
|
|
49
|
+
* when it is built.
|
|
50
|
+
*
|
|
51
|
+
* @see {@link layer} for providing it
|
|
52
|
+
* @see {@link CallableClient.make} for the clients that call through it
|
|
53
|
+
*
|
|
54
|
+
* @stability unstable
|
|
55
|
+
* @category services
|
|
56
|
+
* @since 0.3.0
|
|
57
|
+
*/
|
|
58
|
+
export const ClientFunctions = Context.Service<ClientFunctions>(
|
|
59
|
+
"@visiolab/effect-firebase-client/functions/ClientFunctions",
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Where the Functions emulator runs.
|
|
64
|
+
*
|
|
65
|
+
* @stability unstable
|
|
66
|
+
* @category models
|
|
67
|
+
* @since 0.3.0
|
|
68
|
+
*/
|
|
69
|
+
export interface Emulator {
|
|
70
|
+
readonly host: string;
|
|
71
|
+
readonly port: number;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Options for {@link make} and {@link layer}.
|
|
76
|
+
*
|
|
77
|
+
* @stability unstable
|
|
78
|
+
* @category models
|
|
79
|
+
* @since 0.3.0
|
|
80
|
+
*/
|
|
81
|
+
export interface Options {
|
|
82
|
+
/**
|
|
83
|
+
* The region the functions are deployed to, such as `europe-west1`, or a
|
|
84
|
+
* custom domain that serves them. Defaults to the SDK's, `us-central1`. A
|
|
85
|
+
* function called in a region it isn't deployed to fails with `not-found`.
|
|
86
|
+
*/
|
|
87
|
+
readonly regionOrCustomDomain?: string | undefined;
|
|
88
|
+
/** Calls the Functions emulator at this address instead of the deployed functions. */
|
|
89
|
+
readonly emulator?: Emulator | undefined;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Gets the client SDK's `Functions` instance of the {@link App.App} in
|
|
94
|
+
* context, for one region.
|
|
95
|
+
*
|
|
96
|
+
* **When to use**
|
|
97
|
+
*
|
|
98
|
+
* Use to build the service inside an effect of your own. Most programs provide
|
|
99
|
+
* it with {@link layer} instead.
|
|
100
|
+
*
|
|
101
|
+
* **Details**
|
|
102
|
+
*
|
|
103
|
+
* Wraps `getFunctions(app, regionOrCustomDomain)`, and connects the emulator
|
|
104
|
+
* when `emulator` is given. For a second region, build a second service.
|
|
105
|
+
*
|
|
106
|
+
* @see {@link layer} for the same as a layer
|
|
107
|
+
*
|
|
108
|
+
* @stability unstable
|
|
109
|
+
* @category constructors
|
|
110
|
+
* @since 0.3.0
|
|
111
|
+
*/
|
|
112
|
+
export const make: (options?: Options) => Effect.Effect<ClientFunctions, never, App.App> =
|
|
113
|
+
Effect.fn("ClientFunctions.make")(function* (options?: Options) {
|
|
114
|
+
const app = yield* App.App;
|
|
115
|
+
const instance = Client.getFunctions(app, options?.regionOrCustomDomain);
|
|
116
|
+
if (options?.emulator !== undefined) {
|
|
117
|
+
Client.connectFunctionsEmulator(instance, options.emulator.host, options.emulator.port);
|
|
118
|
+
}
|
|
119
|
+
return { instance };
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* A layer that provides {@link ClientFunctions} for the {@link App.App} in
|
|
124
|
+
* context.
|
|
125
|
+
*
|
|
126
|
+
* **When to use**
|
|
127
|
+
*
|
|
128
|
+
* Use to set the region and the emulator once, for every Callable Client built
|
|
129
|
+
* on it.
|
|
130
|
+
*
|
|
131
|
+
* @example Calling the Functions emulator
|
|
132
|
+
* ```ts
|
|
133
|
+
* import { Layer } from "effect";
|
|
134
|
+
* import { App } from "@visiolab/effect-firebase-client/app";
|
|
135
|
+
* import { ClientFunctions } from "@visiolab/effect-firebase-client/functions";
|
|
136
|
+
*
|
|
137
|
+
* const FunctionsLive = ClientFunctions.layer({
|
|
138
|
+
* emulator: { host: "127.0.0.1", port: 5001 },
|
|
139
|
+
* }).pipe(Layer.provide(App.layer({ projectId: "demo-project" })));
|
|
140
|
+
* ```
|
|
141
|
+
*
|
|
142
|
+
* @see {@link make} for what it wraps
|
|
143
|
+
*
|
|
144
|
+
* @stability unstable
|
|
145
|
+
* @category layers
|
|
146
|
+
* @since 0.3.0
|
|
147
|
+
*/
|
|
148
|
+
export const layer = (options?: Options): Layer.Layer<ClientFunctions, never, App.App> =>
|
|
149
|
+
Layer.effect(ClientFunctions, make(options));
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Callable Clients: call the Callables a server serves, typed by their
|
|
3
|
+
* contract.
|
|
4
|
+
*
|
|
5
|
+
* @stability unstable
|
|
6
|
+
* @since 0.3.0
|
|
7
|
+
*/
|
|
8
|
+
export * as CallableClient from "./CallableClient.ts";
|
|
9
|
+
/**
|
|
10
|
+
* Cloud Functions for Firebase on the client SDK, for one region.
|
|
11
|
+
*
|
|
12
|
+
* @stability unstable
|
|
13
|
+
* @since 0.3.0
|
|
14
|
+
*/
|
|
15
|
+
export * as ClientFunctions from "./ClientFunctions.ts";
|