Skip to content

Commit b2cc7c1

Browse files
committed
start fleshing out interactions between stubs and bdos
1 parent 95676c5 commit b2cc7c1

File tree

14 files changed

+2986
-231
lines changed

14 files changed

+2986
-231
lines changed

e2e/data-connect/dataconnect-generated/js/default-connector/README.md

Lines changed: 55 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,25 @@
1+
# Generated TypeScript README
2+
This README will guide you through the process of using the generated JavaScript SDK package for the connector `default`. It will also provide examples on how to use your generated SDK to call your Data Connect queries and mutations.
3+
4+
***NOTE:** This README is generated alongside the generated SDK. If you make changes to this file, they will be overwritten when the SDK is regenerated.*
5+
16
# Table of Contents
2-
- [**Overview**](#generated-typescript-readme)
7+
- [**Overview**](#generated-javascript-readme)
38
- [**Accessing the connector**](#accessing-the-connector)
49
- [*Connecting to the local Emulator*](#connecting-to-the-local-emulator)
510
- [**Queries**](#queries)
611
- [*ListMovies*](#listmovies)
712
- [**Mutations**](#mutations)
813
- [*CreateMovie*](#createmovie)
914

10-
# Generated TypeScript README
11-
This README will guide you through the process of using the generated TypeScript SDK package for the connector `default`. It will also provide examples on how to use your generated SDK to call your Data Connect queries and mutations.
12-
13-
***NOTE:** This README is generated alongside the generated SDK. If you make changes to this file, they will be overwritten when the SDK is regenerated.*
15+
# Accessing the connector
16+
A connector is a collection of Queries and Mutations. One SDK is generated for each connector - this SDK is generated for the connector `default`. You can find more information about connectors in the [Data Connect documentation](https://firebase.google.com/docs/data-connect#how-does).
1417

1518
You can use this generated SDK by importing from the package `@firebasegen/default-connector` as shown below. Both CommonJS and ESM imports are supported.
1619

1720
You can also follow the instructions from the [Data Connect documentation](https://firebase.google.com/docs/data-connect/web-sdk#set-client).
1821

19-
# Accessing the connector
20-
A connector is a collection of Queries and Mutations. One SDK is generated for each connector - this SDK is generated for the connector `default`.
21-
22-
You can find more information about connectors in the [Data Connect documentation](https://firebase.google.com/docs/data-connect#how-does).
23-
24-
```javascript
22+
```typescript
2523
import { getDataConnect } from 'firebase/data-connect';
2624
import { connectorConfig } from '@firebasegen/default-connector';
2725

@@ -34,7 +32,7 @@ By default, the connector will connect to the production service.
3432
To connect to the emulator, you can use the following code.
3533
You can also follow the emulator instructions from the [Data Connect documentation](https://firebase.google.com/docs/data-connect/web-sdk#instrument-clients).
3634

37-
```javascript
35+
```typescript
3836
import { connectDataConnectEmulator, getDataConnect } from 'firebase/data-connect';
3937
import { connectorConfig } from '@firebasegen/default-connector';
4038

@@ -61,16 +59,31 @@ Below are examples of how to use the `default` connector's generated functions t
6159

6260
## ListMovies
6361
You can execute the `ListMovies` query using the following action shortcut function, or by calling `executeQuery()` after calling the following `QueryRef` function, both of which are defined in [default-connector/index.d.ts](./index.d.ts):
64-
```javascript
62+
```typescript
6563
listMovies(): QueryPromise<ListMoviesData, undefined>;
6664

67-
listMoviesRef(): QueryRef<ListMoviesData, undefined>;
65+
interface ListMoviesRef {
66+
...
67+
/* Allow users to create refs without passing in DataConnect */
68+
(): QueryRef<ListMoviesData, undefined>;
69+
}
70+
export const listMoviesRef: ListMoviesRef;
6871
```
6972
You can also pass in a `DataConnect` instance to the action shortcut function or `QueryRef` function.
70-
```javascript
73+
```typescript
7174
listMovies(dc: DataConnect): QueryPromise<ListMoviesData, undefined>;
7275

73-
listMoviesRef(dc: DataConnect): QueryRef<ListMoviesData, undefined>;
76+
interface ListMoviesRef {
77+
...
78+
(dc: DataConnect): QueryRef<ListMoviesData, undefined>;
79+
}
80+
export const listMoviesRef: ListMoviesRef;
81+
```
82+
83+
If you need the name of the operation without creating a ref, you can retrieve the operation name by calling the `operationName` property on the listMoviesRef:
84+
```typescript
85+
const name = listMoviesRef.operationName;
86+
console.log(name);
7487
```
7588

7689
### Variables
@@ -79,7 +92,7 @@ The `ListMovies` query has no variables.
7992
Recall that executing the `ListMovies` query returns a `QueryPromise` that resolves to an object with a `data` property.
8093

8194
The `data` property is an object of type `ListMoviesData`, which is defined in [default-connector/index.d.ts](./index.d.ts). It has the following fields:
82-
```javascript
95+
```typescript
8396
export interface ListMoviesData {
8497
movies: ({
8598
id: UUIDString;
@@ -91,7 +104,7 @@ export interface ListMoviesData {
91104
```
92105
### Using `ListMovies`'s action shortcut function
93106

94-
```javascript
107+
```typescript
95108
import { getDataConnect } from 'firebase/data-connect';
96109
import { connectorConfig, listMovies } from '@firebasegen/default-connector';
97110

@@ -115,7 +128,7 @@ listMovies().then((response) => {
115128

116129
### Using `ListMovies`'s `QueryRef` function
117130

118-
```javascript
131+
```typescript
119132
import { getDataConnect, executeQuery } from 'firebase/data-connect';
120133
import { connectorConfig, listMoviesRef } from '@firebasegen/default-connector';
121134

@@ -157,22 +170,37 @@ Below are examples of how to use the `default` connector's generated functions t
157170

158171
## CreateMovie
159172
You can execute the `CreateMovie` mutation using the following action shortcut function, or by calling `executeMutation()` after calling the following `MutationRef` function, both of which are defined in [default-connector/index.d.ts](./index.d.ts):
160-
```javascript
173+
```typescript
161174
createMovie(vars: CreateMovieVariables): MutationPromise<CreateMovieData, CreateMovieVariables>;
162175

163-
createMovieRef(vars: CreateMovieVariables): MutationRef<CreateMovieData, CreateMovieVariables>;
176+
interface CreateMovieRef {
177+
...
178+
/* Allow users to create refs without passing in DataConnect */
179+
(vars: CreateMovieVariables): MutationRef<CreateMovieData, CreateMovieVariables>;
180+
}
181+
export const createMovieRef: CreateMovieRef;
164182
```
165183
You can also pass in a `DataConnect` instance to the action shortcut function or `MutationRef` function.
166-
```javascript
184+
```typescript
167185
createMovie(dc: DataConnect, vars: CreateMovieVariables): MutationPromise<CreateMovieData, CreateMovieVariables>;
168186

169-
createMovieRef(dc: DataConnect, vars: CreateMovieVariables): MutationRef<CreateMovieData, CreateMovieVariables>;
187+
interface CreateMovieRef {
188+
...
189+
(dc: DataConnect, vars: CreateMovieVariables): MutationRef<CreateMovieData, CreateMovieVariables>;
190+
}
191+
export const createMovieRef: CreateMovieRef;
192+
```
193+
194+
If you need the name of the operation without creating a ref, you can retrieve the operation name by calling the `operationName` property on the createMovieRef:
195+
```typescript
196+
const name = createMovieRef.operationName;
197+
console.log(name);
170198
```
171199

172200
### Variables
173201
The `CreateMovie` mutation requires an argument of type `CreateMovieVariables`, which is defined in [default-connector/index.d.ts](./index.d.ts). It has the following fields:
174202

175-
```javascript
203+
```typescript
176204
export interface CreateMovieVariables {
177205
title: string;
178206
genre: string;
@@ -183,14 +211,14 @@ export interface CreateMovieVariables {
183211
Recall that executing the `CreateMovie` mutation returns a `MutationPromise` that resolves to an object with a `data` property.
184212

185213
The `data` property is an object of type `CreateMovieData`, which is defined in [default-connector/index.d.ts](./index.d.ts). It has the following fields:
186-
```javascript
214+
```typescript
187215
export interface CreateMovieData {
188216
movie_insert: Movie_Key;
189217
}
190218
```
191219
### Using `CreateMovie`'s action shortcut function
192220

193-
```javascript
221+
```typescript
194222
import { getDataConnect } from 'firebase/data-connect';
195223
import { connectorConfig, createMovie, CreateMovieVariables } from '@firebasegen/default-connector';
196224

@@ -222,7 +250,7 @@ createMovie(createMovieVars).then((response) => {
222250

223251
### Using `CreateMovie`'s `MutationRef` function
224252

225-
```javascript
253+
```typescript
226254
import { getDataConnect, executeMutation } from 'firebase/data-connect';
227255
import { connectorConfig, createMovieRef, CreateMovieVariables } from '@firebasegen/default-connector';
228256

Lines changed: 8 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,30 @@
1-
/**
2-
* @license
3-
* Copyright 2025 Google LLC
4-
*
5-
* Licensed under the Apache License, Version 2.0 (the "License");
6-
* you may not use this file except in compliance with the License.
7-
* You may obtain a copy of the License at
8-
*
9-
* http://www.apache.org/licenses/LICENSE-2.0
10-
*
11-
* Unless required by applicable law or agreed to in writing, software
12-
* distributed under the License is distributed on an "AS IS" BASIS,
13-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14-
* See the License for the specific language governing permissions and
15-
* limitations under the License.
16-
*/
17-
18-
import {
19-
queryRef,
20-
executeQuery,
21-
mutationRef,
22-
executeMutation,
23-
validateArgs
24-
} from 'firebase/data-connect';
1+
import { queryRef, executeQuery, mutationRef, executeMutation, validateArgs } from 'firebase/data-connect';
252

263
export const connectorConfig = {
274
connector: 'default',
285
service: 'fdc-test',
296
location: 'us-central1'
307
};
318

32-
export function createMovieRef(dcOrVars, vars) {
33-
const { dc: dcInstance, vars: inputVars } = validateArgs(
34-
connectorConfig,
35-
dcOrVars,
36-
vars,
37-
true
38-
);
9+
export const createMovieRef = (dcOrVars, vars) => {
10+
const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true);
3911
dcInstance._useGeneratedSdk();
4012
return mutationRef(dcInstance, 'CreateMovie', inputVars);
4113
}
14+
createMovieRef.operationName = 'CreateMovie';
4215

4316
export function createMovie(dcOrVars, vars) {
4417
return executeMutation(createMovieRef(dcOrVars, vars));
4518
}
4619

47-
export function listMoviesRef(dc) {
48-
const { dc: dcInstance } = validateArgs(connectorConfig, dc, undefined);
20+
export const listMoviesRef = (dc) => {
21+
const { dc: dcInstance} = validateArgs(connectorConfig, dc, undefined);
4922
dcInstance._useGeneratedSdk();
5023
return queryRef(dcInstance, 'ListMovies');
5124
}
25+
listMoviesRef.operationName = 'ListMovies';
5226

5327
export function listMovies(dc) {
5428
return executeQuery(listMoviesRef(dc));
5529
}
30+

e2e/data-connect/dataconnect-generated/js/default-connector/index.cjs.js

Lines changed: 11 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,4 @@
1-
/**
2-
* @license
3-
* Copyright 2025 Google LLC
4-
*
5-
* Licensed under the Apache License, Version 2.0 (the "License");
6-
* you may not use this file except in compliance with the License.
7-
* You may obtain a copy of the License at
8-
*
9-
* http://www.apache.org/licenses/LICENSE-2.0
10-
*
11-
* Unless required by applicable law or agreed to in writing, software
12-
* distributed under the License is distributed on an "AS IS" BASIS,
13-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14-
* See the License for the specific language governing permissions and
15-
* limitations under the License.
16-
*/
17-
18-
const {
19-
queryRef,
20-
executeQuery,
21-
mutationRef,
22-
executeMutation,
23-
validateArgs
24-
} = require('firebase/data-connect');
1+
const { queryRef, executeQuery, mutationRef, executeMutation, validateArgs } = require('firebase/data-connect');
252

263
const connectorConfig = {
274
connector: 'default',
@@ -30,26 +7,25 @@ const connectorConfig = {
307
};
318
exports.connectorConfig = connectorConfig;
329

33-
exports.createMovieRef = function createMovieRef(dcOrVars, vars) {
34-
const { dc: dcInstance, vars: inputVars } = validateArgs(
35-
connectorConfig,
36-
dcOrVars,
37-
vars,
38-
true
39-
);
10+
const createMovieRef = (dcOrVars, vars) => {
11+
const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true);
4012
dcInstance._useGeneratedSdk();
4113
return mutationRef(dcInstance, 'CreateMovie', inputVars);
42-
};
14+
}
15+
createMovieRef.operationName = 'CreateMovie';
16+
exports.createMovieRef = createMovieRef;
4317

4418
exports.createMovie = function createMovie(dcOrVars, vars) {
4519
return executeMutation(createMovieRef(dcOrVars, vars));
4620
};
4721

48-
exports.listMoviesRef = function listMoviesRef(dc) {
49-
const { dc: dcInstance } = validateArgs(connectorConfig, dc, undefined);
22+
const listMoviesRef = (dc) => {
23+
const { dc: dcInstance} = validateArgs(connectorConfig, dc, undefined);
5024
dcInstance._useGeneratedSdk();
5125
return queryRef(dcInstance, 'ListMovies');
52-
};
26+
}
27+
listMoviesRef.operationName = 'ListMovies';
28+
exports.listMoviesRef = listMoviesRef;
5329

5430
exports.listMovies = function listMovies(dc) {
5531
return executeQuery(listMoviesRef(dc));

0 commit comments

Comments
 (0)