Skip to content

Commit

Permalink
chore: Add React example
Browse files Browse the repository at this point in the history
  • Loading branch information
Ehesp committed Dec 17, 2024
1 parent 73a0b64 commit 8c721c0
Show file tree
Hide file tree
Showing 29 changed files with 3,388 additions and 307 deletions.
44 changes: 22 additions & 22 deletions dataconnect-sdk/js/default-connector/esm/index.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,63 +6,63 @@ export const connectorConfig = {
location: 'us-central1'
};

export function listMoviesRef(dc) {
const { dc: dcInstance} = validateArgs(connectorConfig, dc, undefined);
export function createMovieRef(dcOrVars, vars) {
const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true);
if('_useGeneratedSdk' in dcInstance) {
dcInstance._useGeneratedSdk();
} else {
console.error('Please update to the latest version of the Data Connect SDK by running `npm install firebase@dataconnect-preview`.');
}
return queryRef(dcInstance, 'ListMovies');
return mutationRef(dcInstance, 'CreateMovie', inputVars);
}
export function listMovies(dc) {
return executeQuery(listMoviesRef(dc));
export function createMovie(dcOrVars, vars) {
return executeMutation(createMovieRef(dcOrVars, vars));
}
export function getMovieByIdRef(dcOrVars, vars) {
export function upsertMovieRef(dcOrVars, vars) {
const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true);
if('_useGeneratedSdk' in dcInstance) {
dcInstance._useGeneratedSdk();
} else {
console.error('Please update to the latest version of the Data Connect SDK by running `npm install firebase@dataconnect-preview`.');
}
return queryRef(dcInstance, 'GetMovieById', inputVars);
return mutationRef(dcInstance, 'UpsertMovie', inputVars);
}
export function getMovieById(dcOrVars, vars) {
return executeQuery(getMovieByIdRef(dcOrVars, vars));
export function upsertMovie(dcOrVars, vars) {
return executeMutation(upsertMovieRef(dcOrVars, vars));
}
export function createMovieRef(dcOrVars, vars) {
export function deleteMovieRef(dcOrVars, vars) {
const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true);
if('_useGeneratedSdk' in dcInstance) {
dcInstance._useGeneratedSdk();
} else {
console.error('Please update to the latest version of the Data Connect SDK by running `npm install firebase@dataconnect-preview`.');
}
return mutationRef(dcInstance, 'CreateMovie', inputVars);
return mutationRef(dcInstance, 'DeleteMovie', inputVars);
}
export function createMovie(dcOrVars, vars) {
return executeMutation(createMovieRef(dcOrVars, vars));
export function deleteMovie(dcOrVars, vars) {
return executeMutation(deleteMovieRef(dcOrVars, vars));
}
export function upsertMovieRef(dcOrVars, vars) {
const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true);
export function listMoviesRef(dc) {
const { dc: dcInstance} = validateArgs(connectorConfig, dc, undefined);
if('_useGeneratedSdk' in dcInstance) {
dcInstance._useGeneratedSdk();
} else {
console.error('Please update to the latest version of the Data Connect SDK by running `npm install firebase@dataconnect-preview`.');
}
return mutationRef(dcInstance, 'UpsertMovie', inputVars);
return queryRef(dcInstance, 'ListMovies');
}
export function upsertMovie(dcOrVars, vars) {
return executeMutation(upsertMovieRef(dcOrVars, vars));
export function listMovies(dc) {
return executeQuery(listMoviesRef(dc));
}
export function deleteMovieRef(dcOrVars, vars) {
export function getMovieByIdRef(dcOrVars, vars) {
const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true);
if('_useGeneratedSdk' in dcInstance) {
dcInstance._useGeneratedSdk();
} else {
console.error('Please update to the latest version of the Data Connect SDK by running `npm install firebase@dataconnect-preview`.');
}
return mutationRef(dcInstance, 'DeleteMovie', inputVars);
return queryRef(dcInstance, 'GetMovieById', inputVars);
}
export function deleteMovie(dcOrVars, vars) {
return executeMutation(deleteMovieRef(dcOrVars, vars));
export function getMovieById(dcOrVars, vars) {
return executeQuery(getMovieByIdRef(dcOrVars, vars));
}
54 changes: 27 additions & 27 deletions dataconnect-sdk/js/default-connector/index.cjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,73 +7,73 @@ const connectorConfig = {
};
exports.connectorConfig = connectorConfig;

function listMoviesRef(dc) {
const { dc: dcInstance} = validateArgs(connectorConfig, dc, undefined);
function createMovieRef(dcOrVars, vars) {
const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true);
if('_useGeneratedSdk' in dcInstance) {
dcInstance._useGeneratedSdk();
} else {
console.error('Please update to the latest version of the Data Connect SDK by running `npm install firebase@dataconnect-preview`.');
}
return queryRef(dcInstance, 'ListMovies');
return mutationRef(dcInstance, 'CreateMovie', inputVars);
}
exports.listMoviesRef = listMoviesRef;
exports.listMovies = function listMovies(dc) {
return executeQuery(listMoviesRef(dc));
exports.createMovieRef = createMovieRef;
exports.createMovie = function createMovie(dcOrVars, vars) {
return executeMutation(createMovieRef(dcOrVars, vars));
};

function getMovieByIdRef(dcOrVars, vars) {
function upsertMovieRef(dcOrVars, vars) {
const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true);
if('_useGeneratedSdk' in dcInstance) {
dcInstance._useGeneratedSdk();
} else {
console.error('Please update to the latest version of the Data Connect SDK by running `npm install firebase@dataconnect-preview`.');
}
return queryRef(dcInstance, 'GetMovieById', inputVars);
return mutationRef(dcInstance, 'UpsertMovie', inputVars);
}
exports.getMovieByIdRef = getMovieByIdRef;
exports.getMovieById = function getMovieById(dcOrVars, vars) {
return executeQuery(getMovieByIdRef(dcOrVars, vars));
exports.upsertMovieRef = upsertMovieRef;
exports.upsertMovie = function upsertMovie(dcOrVars, vars) {
return executeMutation(upsertMovieRef(dcOrVars, vars));
};

function createMovieRef(dcOrVars, vars) {
function deleteMovieRef(dcOrVars, vars) {
const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true);
if('_useGeneratedSdk' in dcInstance) {
dcInstance._useGeneratedSdk();
} else {
console.error('Please update to the latest version of the Data Connect SDK by running `npm install firebase@dataconnect-preview`.');
}
return mutationRef(dcInstance, 'CreateMovie', inputVars);
return mutationRef(dcInstance, 'DeleteMovie', inputVars);
}
exports.createMovieRef = createMovieRef;
exports.createMovie = function createMovie(dcOrVars, vars) {
return executeMutation(createMovieRef(dcOrVars, vars));
exports.deleteMovieRef = deleteMovieRef;
exports.deleteMovie = function deleteMovie(dcOrVars, vars) {
return executeMutation(deleteMovieRef(dcOrVars, vars));
};

function upsertMovieRef(dcOrVars, vars) {
const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true);
function listMoviesRef(dc) {
const { dc: dcInstance} = validateArgs(connectorConfig, dc, undefined);
if('_useGeneratedSdk' in dcInstance) {
dcInstance._useGeneratedSdk();
} else {
console.error('Please update to the latest version of the Data Connect SDK by running `npm install firebase@dataconnect-preview`.');
}
return mutationRef(dcInstance, 'UpsertMovie', inputVars);
return queryRef(dcInstance, 'ListMovies');
}
exports.upsertMovieRef = upsertMovieRef;
exports.upsertMovie = function upsertMovie(dcOrVars, vars) {
return executeMutation(upsertMovieRef(dcOrVars, vars));
exports.listMoviesRef = listMoviesRef;
exports.listMovies = function listMovies(dc) {
return executeQuery(listMoviesRef(dc));
};

function deleteMovieRef(dcOrVars, vars) {
function getMovieByIdRef(dcOrVars, vars) {
const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true);
if('_useGeneratedSdk' in dcInstance) {
dcInstance._useGeneratedSdk();
} else {
console.error('Please update to the latest version of the Data Connect SDK by running `npm install firebase@dataconnect-preview`.');
}
return mutationRef(dcInstance, 'DeleteMovie', inputVars);
return queryRef(dcInstance, 'GetMovieById', inputVars);
}
exports.deleteMovieRef = deleteMovieRef;
exports.deleteMovie = function deleteMovie(dcOrVars, vars) {
return executeMutation(deleteMovieRef(dcOrVars, vars));
exports.getMovieByIdRef = getMovieByIdRef;
exports.getMovieById = function getMovieById(dcOrVars, vars) {
return executeQuery(getMovieByIdRef(dcOrVars, vars));
};

34 changes: 17 additions & 17 deletions dataconnect-sdk/js/default-connector/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,23 +73,6 @@ export interface UpsertMovieVariables {



/* Allow users to create refs without passing in DataConnect */
export function listMoviesRef(): QueryRef<ListMoviesData, undefined>;/* Allow users to pass in custom DataConnect instances */
export function listMoviesRef(dc: DataConnect): QueryRef<ListMoviesData,undefined>;

export function listMovies(): QueryPromise<ListMoviesData, undefined>;
export function listMovies(dc: DataConnect): QueryPromise<ListMoviesData,undefined>;


/* Allow users to create refs without passing in DataConnect */
export function getMovieByIdRef(vars: GetMovieByIdVariables): QueryRef<GetMovieByIdData, GetMovieByIdVariables>;
/* Allow users to pass in custom DataConnect instances */
export function getMovieByIdRef(dc: DataConnect, vars: GetMovieByIdVariables): QueryRef<GetMovieByIdData,GetMovieByIdVariables>;

export function getMovieById(vars: GetMovieByIdVariables): QueryPromise<GetMovieByIdData, GetMovieByIdVariables>;
export function getMovieById(dc: DataConnect, vars: GetMovieByIdVariables): QueryPromise<GetMovieByIdData,GetMovieByIdVariables>;


/* Allow users to create refs without passing in DataConnect */
export function createMovieRef(vars: CreateMovieVariables): MutationRef<CreateMovieData, CreateMovieVariables>;
/* Allow users to pass in custom DataConnect instances */
Expand Down Expand Up @@ -117,3 +100,20 @@ export function deleteMovie(vars: DeleteMovieVariables): MutationPromise<DeleteM
export function deleteMovie(dc: DataConnect, vars: DeleteMovieVariables): MutationPromise<DeleteMovieData,DeleteMovieVariables>;


/* Allow users to create refs without passing in DataConnect */
export function listMoviesRef(): QueryRef<ListMoviesData, undefined>;/* Allow users to pass in custom DataConnect instances */
export function listMoviesRef(dc: DataConnect): QueryRef<ListMoviesData,undefined>;

export function listMovies(): QueryPromise<ListMoviesData, undefined>;
export function listMovies(dc: DataConnect): QueryPromise<ListMoviesData,undefined>;


/* Allow users to create refs without passing in DataConnect */
export function getMovieByIdRef(vars: GetMovieByIdVariables): QueryRef<GetMovieByIdData, GetMovieByIdVariables>;
/* Allow users to pass in custom DataConnect instances */
export function getMovieByIdRef(dc: DataConnect, vars: GetMovieByIdVariables): QueryRef<GetMovieByIdData,GetMovieByIdVariables>;

export function getMovieById(vars: GetMovieByIdVariables): QueryPromise<GetMovieByIdData, GetMovieByIdVariables>;
export function getMovieById(dc: DataConnect, vars: GetMovieByIdVariables): QueryPromise<GetMovieByIdData,GetMovieByIdVariables>;


2 changes: 1 addition & 1 deletion dataconnect-sdk/js/default-connector/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,6 @@
"./package.json": "./package.json"
},
"peerDependencies": {
"firebase": "^10.14.0 || ^11.0.0"
"firebase": "^10.14.0"
}
}
Loading

0 comments on commit 8c721c0

Please sign in to comment.