|
| 1 | +const { getDataConnect, queryRef, executeQuery, mutationRef, executeMutation, validateArgs } = require('firebase/data-connect'); |
| 2 | + |
| 3 | +const connectorConfig = { |
| 4 | + connector: 'default', |
| 5 | + service: 'tanstack-query-firebase', |
| 6 | + location: 'us-central1' |
| 7 | +}; |
| 8 | +exports.connectorConfig = connectorConfig; |
| 9 | + |
| 10 | +function listMoviesRef(dc) { |
| 11 | + const { dc: dcInstance} = validateArgs(connectorConfig, dc, undefined); |
| 12 | + if('_useGeneratedSdk' in dcInstance) { |
| 13 | + dcInstance._useGeneratedSdk(); |
| 14 | + } else { |
| 15 | + console.error('Please update to the latest version of the Data Connect SDK by running `npm install firebase@dataconnect-preview`.'); |
| 16 | + } |
| 17 | + return queryRef(dcInstance, 'ListMovies'); |
| 18 | +} |
| 19 | +exports.listMoviesRef = listMoviesRef; |
| 20 | +exports.listMovies = function listMovies(dc) { |
| 21 | + return executeQuery(listMoviesRef(dc)); |
| 22 | +}; |
| 23 | + |
| 24 | +function getMovieByIdRef(dcOrVars, vars) { |
| 25 | + const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true); |
| 26 | + if('_useGeneratedSdk' in dcInstance) { |
| 27 | + dcInstance._useGeneratedSdk(); |
| 28 | + } else { |
| 29 | + console.error('Please update to the latest version of the Data Connect SDK by running `npm install firebase@dataconnect-preview`.'); |
| 30 | + } |
| 31 | + return queryRef(dcInstance, 'GetMovieById', inputVars); |
| 32 | +} |
| 33 | +exports.getMovieByIdRef = getMovieByIdRef; |
| 34 | +exports.getMovieById = function getMovieById(dcOrVars, vars) { |
| 35 | + return executeQuery(getMovieByIdRef(dcOrVars, vars)); |
| 36 | +}; |
| 37 | + |
| 38 | +function createMovieRef(dcOrVars, vars) { |
| 39 | + const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true); |
| 40 | + if('_useGeneratedSdk' in dcInstance) { |
| 41 | + dcInstance._useGeneratedSdk(); |
| 42 | + } else { |
| 43 | + console.error('Please update to the latest version of the Data Connect SDK by running `npm install firebase@dataconnect-preview`.'); |
| 44 | + } |
| 45 | + return mutationRef(dcInstance, 'CreateMovie', inputVars); |
| 46 | +} |
| 47 | +exports.createMovieRef = createMovieRef; |
| 48 | +exports.createMovie = function createMovie(dcOrVars, vars) { |
| 49 | + return executeMutation(createMovieRef(dcOrVars, vars)); |
| 50 | +}; |
| 51 | + |
| 52 | +function upsertMovieRef(dcOrVars, vars) { |
| 53 | + const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true); |
| 54 | + if('_useGeneratedSdk' in dcInstance) { |
| 55 | + dcInstance._useGeneratedSdk(); |
| 56 | + } else { |
| 57 | + console.error('Please update to the latest version of the Data Connect SDK by running `npm install firebase@dataconnect-preview`.'); |
| 58 | + } |
| 59 | + return mutationRef(dcInstance, 'UpsertMovie', inputVars); |
| 60 | +} |
| 61 | +exports.upsertMovieRef = upsertMovieRef; |
| 62 | +exports.upsertMovie = function upsertMovie(dcOrVars, vars) { |
| 63 | + return executeMutation(upsertMovieRef(dcOrVars, vars)); |
| 64 | +}; |
| 65 | + |
| 66 | +function deleteMovieRef(dcOrVars, vars) { |
| 67 | + const { dc: dcInstance, vars: inputVars} = validateArgs(connectorConfig, dcOrVars, vars, true); |
| 68 | + if('_useGeneratedSdk' in dcInstance) { |
| 69 | + dcInstance._useGeneratedSdk(); |
| 70 | + } else { |
| 71 | + console.error('Please update to the latest version of the Data Connect SDK by running `npm install firebase@dataconnect-preview`.'); |
| 72 | + } |
| 73 | + return mutationRef(dcInstance, 'DeleteMovie', inputVars); |
| 74 | +} |
| 75 | +exports.deleteMovieRef = deleteMovieRef; |
| 76 | +exports.deleteMovie = function deleteMovie(dcOrVars, vars) { |
| 77 | + return executeMutation(deleteMovieRef(dcOrVars, vars)); |
| 78 | +}; |
| 79 | + |
0 commit comments