Skip to content

Commit 3eae4e3

Browse files
committed
Fixed bdo parsing
1 parent 4058d93 commit 3eae4e3

File tree

15 files changed

+199
-279
lines changed

15 files changed

+199
-279
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@ If a user is not using a supported framework, they can use the generated SDK dir
1414
Here's an example of how to use it with the first 5 operations:
1515

1616
```js
17-
import { createMovie, listMovies } from '@firebasegen/default-connector';
17+
import { listMovies, createMovie } from '@firebasegen/default-connector';
1818

1919

20-
// Operation CreateMovie: For variables, look at type CreateMovieVars in ../index.d.ts
21-
const { data } = await CreateMovie(dataConnect, createMovieVars);
22-
2320
// Operation ListMovies:
2421
const { data } = await ListMovies(dataConnect);
2522

23+
// Operation CreateMovie: For variables, look at type CreateMovieVars in ../index.d.ts
24+
const { data } = await CreateMovie(dataConnect, createMovieVars);
25+
2626

2727
```
Lines changed: 14 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +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

9+
export const listMoviesRef = (dc) => {
10+
const { dc: dcInstance} = validateArgs(connectorConfig, dc, undefined);
11+
dcInstance._useGeneratedSdk();
12+
return queryRef(dcInstance, 'ListMovies');
13+
}
14+
listMoviesRef.operationName = 'ListMovies';
15+
16+
export function listMovies(dc) {
17+
return executeQuery(listMoviesRef(dc));
18+
}
19+
3220
export const createMovieRef = (dcOrVars, vars) => {
33-
const { dc: dcInstance, vars: inputVars } = validateArgs(
34-
connectorConfig,
35-
dcOrVars,
36-
vars,
37-
true
38-
);
21+
const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true);
3922
dcInstance._useGeneratedSdk();
4023
return mutationRef(dcInstance, 'CreateMovie', inputVars);
41-
};
24+
}
4225
createMovieRef.operationName = 'CreateMovie';
4326

4427
export function createMovie(dcOrVars, vars) {
4528
return executeMutation(createMovieRef(dcOrVars, vars));
4629
}
4730

48-
export const listMoviesRef = dc => {
49-
const { dc: dcInstance } = validateArgs(connectorConfig, dc, undefined);
50-
dcInstance._useGeneratedSdk();
51-
return queryRef(dcInstance, 'ListMovies');
52-
};
53-
listMoviesRef.operationName = 'ListMovies';
54-
55-
export function listMovies(dc) {
56-
return executeQuery(listMoviesRef(dc));
57-
}
Lines changed: 15 additions & 43 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,31 +7,26 @@ const connectorConfig = {
307
};
318
exports.connectorConfig = connectorConfig;
329

10+
const listMoviesRef = (dc) => {
11+
const { dc: dcInstance} = validateArgs(connectorConfig, dc, undefined);
12+
dcInstance._useGeneratedSdk();
13+
return queryRef(dcInstance, 'ListMovies');
14+
}
15+
listMoviesRef.operationName = 'ListMovies';
16+
exports.listMoviesRef = listMoviesRef;
17+
18+
exports.listMovies = function listMovies(dc) {
19+
return executeQuery(listMoviesRef(dc));
20+
};
21+
3322
const createMovieRef = (dcOrVars, vars) => {
34-
const { dc: dcInstance, vars: inputVars } = validateArgs(
35-
connectorConfig,
36-
dcOrVars,
37-
vars,
38-
true
39-
);
23+
const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true);
4024
dcInstance._useGeneratedSdk();
4125
return mutationRef(dcInstance, 'CreateMovie', inputVars);
42-
};
26+
}
4327
createMovieRef.operationName = 'CreateMovie';
4428
exports.createMovieRef = createMovieRef;
4529

4630
exports.createMovie = function createMovie(dcOrVars, vars) {
4731
return executeMutation(createMovieRef(dcOrVars, vars));
4832
};
49-
50-
const listMoviesRef = dc => {
51-
const { dc: dcInstance } = validateArgs(connectorConfig, dc, undefined);
52-
dcInstance._useGeneratedSdk();
53-
return queryRef(dcInstance, 'ListMovies');
54-
};
55-
listMoviesRef.operationName = 'ListMovies';
56-
exports.listMoviesRef = listMoviesRef;
57-
58-
exports.listMovies = function listMovies(dc) {
59-
return executeQuery(listMoviesRef(dc));
60-
};
Lines changed: 17 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +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-
import {
19-
ConnectorConfig,
20-
DataConnect,
21-
QueryRef,
22-
QueryPromise,
23-
MutationRef,
24-
MutationPromise
25-
} from 'firebase/data-connect';
1+
import { ConnectorConfig, DataConnect, QueryRef, QueryPromise, MutationRef, MutationPromise } from 'firebase/data-connect';
262

273
export const connectorConfig: ConnectorConfig;
284

@@ -31,6 +7,9 @@ export type UUIDString = string;
317
export type Int64String = string;
328
export type DateString = string;
339

10+
11+
12+
3413
export interface CreateMovieData {
3514
movie_insert: Movie_Key;
3615
}
@@ -55,39 +34,27 @@ export interface Movie_Key {
5534
__typename?: 'Movie_Key';
5635
}
5736

58-
interface CreateMovieRef {
37+
interface ListMoviesRef {
5938
/* Allow users to create refs without passing in DataConnect */
60-
(vars: CreateMovieVariables): MutationRef<
61-
CreateMovieData,
62-
CreateMovieVariables
63-
>;
39+
(): QueryRef<ListMoviesData, undefined>;
6440
/* Allow users to pass in custom DataConnect instances */
65-
(dc: DataConnect, vars: CreateMovieVariables): MutationRef<
66-
CreateMovieData,
67-
CreateMovieVariables
68-
>;
41+
(dc: DataConnect): QueryRef<ListMoviesData, undefined>;
6942
operationName: string;
7043
}
71-
export const createMovieRef: CreateMovieRef;
44+
export const listMoviesRef: ListMoviesRef;
7245

73-
export function createMovie(
74-
vars: CreateMovieVariables
75-
): MutationPromise<CreateMovieData, CreateMovieVariables>;
76-
export function createMovie(
77-
dc: DataConnect,
78-
vars: CreateMovieVariables
79-
): MutationPromise<CreateMovieData, CreateMovieVariables>;
46+
export function listMovies(): QueryPromise<ListMoviesData, undefined>;
47+
export function listMovies(dc: DataConnect): QueryPromise<ListMoviesData, undefined>;
8048

81-
interface ListMoviesRef {
49+
interface CreateMovieRef {
8250
/* Allow users to create refs without passing in DataConnect */
83-
(): QueryRef<ListMoviesData, undefined>;
51+
(vars: CreateMovieVariables): MutationRef<CreateMovieData, CreateMovieVariables>;
8452
/* Allow users to pass in custom DataConnect instances */
85-
(dc: DataConnect): QueryRef<ListMoviesData, undefined>;
53+
(dc: DataConnect, vars: CreateMovieVariables): MutationRef<CreateMovieData, CreateMovieVariables>;
8654
operationName: string;
8755
}
88-
export const listMoviesRef: ListMoviesRef;
56+
export const createMovieRef: CreateMovieRef;
57+
58+
export function createMovie(vars: CreateMovieVariables): MutationPromise<CreateMovieData, CreateMovieVariables>;
59+
export function createMovie(dc: DataConnect, vars: CreateMovieVariables): MutationPromise<CreateMovieData, CreateMovieVariables>;
8960

90-
export function listMovies(): QueryPromise<ListMoviesData, undefined>;
91-
export function listMovies(
92-
dc: DataConnect
93-
): QueryPromise<ListMoviesData, undefined>;

packages/data-connect/src/api/DataConnect.ts

Lines changed: 28 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,10 @@ import {
3333
import {
3434
CacheSettings,
3535
DataConnectCache,
36-
InMemoryCacheProvider
36+
IndexedDBStub,
37+
PersistentStub,
3738
} from '../cache/Cache';
38-
import { CacheProvider } from '../cache/CacheProvider';
39-
import { IndexedDBCacheProvider } from '../cache/IndexedDBCacheProvider';
39+
import { InternalCacheProvider } from '../cache/CacheProvider';
4040
import { AppCheckTokenProvider } from '../core/AppCheckTokenProvider';
4141
import { Code, DataConnectError } from '../core/error';
4242
import {
@@ -56,6 +56,8 @@ import { PROD_HOST } from '../util/url';
5656

5757
import { MutationManager } from './Mutation';
5858

59+
60+
5961
/**
6062
* Connector Config for calling Data Connect backend.
6163
*/
@@ -276,28 +278,6 @@ export function connectDataConnectEmulator(
276278
dc.enableEmulator({ host, port, sslEnabled });
277279
}
278280

279-
export type CacheProviderImpl =
280-
| PublicIndexedDbProvider
281-
| PublicEphemeralDbProvider;
282-
283-
export class PublicIndexedDbProvider {
284-
/**
285-
* @internal
286-
*/
287-
initializeProvider(cacheId: string): CacheProvider {
288-
return new IndexedDBCacheProvider(cacheId);
289-
}
290-
}
291-
292-
export class PublicEphemeralDbProvider {
293-
/**
294-
* @internal
295-
*/
296-
initializeProvider(cacheId: string): CacheProvider {
297-
return new InMemoryCacheProvider(cacheId);
298-
}
299-
}
300-
301281
export interface DataConnectSettings {
302282
cacheSettings?: CacheSettings;
303283
}
@@ -408,3 +388,26 @@ export function terminate(dataConnect: DataConnect): Promise<void> {
408388
return dataConnect._delete();
409389
// TODO(mtewani): Stop pending tasks
410390
}
391+
export const StorageType = {
392+
PERSISTENT: 'PERSISTENT',
393+
MEMORY: 'MEMORY'
394+
};
395+
396+
export type StorageType = (typeof StorageType)[keyof typeof StorageType];
397+
398+
399+
export interface CacheProvider<T extends StorageType> {
400+
type: T
401+
/**
402+
* @internal
403+
*/
404+
initialize(cacheId: string): InternalCacheProvider;
405+
}
406+
407+
export function makePersistentCacheProvider(): CacheProvider<'PERSISTENT'> {
408+
return new IndexedDBStub();
409+
}
410+
export function makeMemoryCacheProvider(): CacheProvider<'MEMORY'> {
411+
return new PersistentStub();
412+
}
413+

packages/data-connect/src/api/index.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,6 @@ export {
2525
export {
2626
ExecuteQueryOptions,
2727
QueryFetchPolicy,
28-
PreferCache,
29-
CacheOnly,
30-
ServerOnly
3128
} from '../core/query/queryOptions';
3229
export * from './DataConnect';
3330
export * from './Reference';

packages/data-connect/src/api/query.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import {
2525
SerializedRef
2626
} from './Reference';
2727

28+
2829
/**
2930
* QueryRef object
3031
*/

0 commit comments

Comments
 (0)