From 9c4d5cc1ebc79688b12ecb65b3fa327ae98e7543 Mon Sep 17 00:00:00 2001 From: meow12 Date: Tue, 27 Dec 2022 12:21:27 +0200 Subject: [PATCH] fix(database): pass database to api pass database to api --- src/components/db.js | 38 ++++++++++++++++++++++++++++++++++++++ src/components/files.js | 3 +++ src/components/payments.js | 2 ++ 3 files changed, 43 insertions(+) diff --git a/src/components/db.js b/src/components/db.js index 1f74812..fdfe4fa 100644 --- a/src/components/db.js +++ b/src/components/db.js @@ -21,6 +21,7 @@ export async function getRecords({ addReferencesFirst, excludeCulture, cluster, + database, }) { const response = await server.loadJson( `${Config.apiUrl}${Endpoints.PROJECT.DATABASE.COLLECTION.RECORD.GET_ALL( @@ -31,6 +32,7 @@ export async function getRecords({ headers: { 'X-CM-ProjectId': Config.projectId, 'X-CM-Cluster': cluster, + 'X-CM-Database': database, Authorization: `Bearer ${secretKey || Config.secretKey}`, Accept: 'application/json', 'Content-Type': 'application/json', @@ -74,6 +76,7 @@ export async function getRecord({ excludeCulture, language, cluster, + database, }) { const response = await server.loadJson( `${Config.apiUrl}${Endpoints.PROJECT.DATABASE.COLLECTION.RECORD.GET( @@ -85,6 +88,7 @@ export async function getRecord({ headers: { 'X-CM-ProjectId': Config.projectId, 'X-CM-Cluster': cluster, + 'X-CM-Database': database, Authorization: `Bearer ${secretKey || Config.secretKey}`, Accept: 'application/json', 'Content-Type': 'application/json', @@ -120,6 +124,7 @@ export async function getRecordWithFilter({ excludeCulture, language, cluster, + database, }) { const response = await server.loadJson( `${ @@ -132,6 +137,7 @@ export async function getRecordWithFilter({ headers: { 'X-CM-ProjectId': Config.projectId, 'X-CM-Cluster': cluster, + 'X-CM-Database': database, Authorization: `Bearer ${secretKey || Config.secretKey}`, Accept: 'application/json', 'Content-Type': 'application/json', @@ -160,6 +166,7 @@ export async function deleteRecord({ id, ignoreTriggers, cluster, + database, }) { let url = `${ Config.apiUrl @@ -176,6 +183,7 @@ export async function deleteRecord({ headers: { 'X-CM-ProjectId': Config.projectId, 'X-CM-Cluster': cluster, + 'X-CM-Database': database, Authorization: `Bearer ${secretKey || Config.secretKey}`, Accept: 'application/json', 'Content-Type': 'application/json', @@ -192,6 +200,7 @@ export async function deleteRecordWithFilter({ filter, ignoreTriggers, cluster, + database, }) { let url = `${ Config.apiUrl @@ -211,6 +220,7 @@ export async function deleteRecordWithFilter({ headers: { 'X-CM-ProjectId': Config.projectId, 'X-CM-Cluster': cluster, + 'X-CM-Database': database, Authorization: `Bearer ${secretKey || Config.secretKey}`, Accept: 'application/json', 'Content-Type': 'application/json', @@ -227,6 +237,7 @@ export async function deleteManyRecords({ filter, ignoreTriggers, cluster, + database, }) { let url = `${ Config.apiUrl @@ -244,6 +255,7 @@ export async function deleteManyRecords({ headers: { 'X-CM-ProjectId': Config.projectId, 'X-CM-Cluster': cluster, + 'X-CM-Database': database, Authorization: `Bearer ${secretKey || Config.secretKey}`, Accept: 'application/json', 'Content-Type': 'application/json', @@ -262,6 +274,7 @@ export async function insertRecord({ waitForFileUpload, ignoreTriggers, cluster, + database, resolveProviderFiles, responsibleUserId, }) { @@ -274,6 +287,7 @@ export async function insertRecord({ headers: { 'X-CM-ProjectId': Config.projectId, 'X-CM-Cluster': cluster, + 'X-CM-Database': database, Authorization: `Bearer ${secretKey || Config.secretKey}`, Accept: 'application/json', 'Content-Type': 'application/json', @@ -299,6 +313,7 @@ export async function insertManyRecords({ bypassDocumentValidation, ignoreTriggers, cluster, + database, resolveProviderFiles, responsibleUserId, }) { @@ -318,6 +333,7 @@ export async function insertManyRecords({ headers: { 'X-CM-ProjectId': Config.projectId, 'X-CM-Cluster': cluster, + 'X-CM-Database': database, Authorization: `Bearer ${secretKey || Config.secretKey}`, Accept: 'application/json', 'Content-Type': 'application/json', @@ -344,6 +360,7 @@ export async function updateRecord({ bypassDocumentValidation, ignoreTriggers, cluster, + database, resolveProviderFiles, }) { const response = await server.loadJson( @@ -356,6 +373,7 @@ export async function updateRecord({ headers: { 'X-CM-ProjectId': Config.projectId, 'X-CM-Cluster': cluster, + 'X-CM-Database': database, Authorization: `Bearer ${secretKey || Config.secretKey}`, Accept: 'application/json', 'Content-Type': 'application/json', @@ -382,6 +400,7 @@ export async function updateRecordWithFilter({ bypassDocumentValidation, ignoreTriggers, cluster, + database, resolveProviderFiles, }) { const response = await server.loadJson( @@ -395,6 +414,7 @@ export async function updateRecordWithFilter({ headers: { 'X-CM-ProjectId': Config.projectId, 'X-CM-Cluster': cluster, + 'X-CM-Database': database, Authorization: `Bearer ${secretKey || Config.secretKey}`, Accept: 'application/json', 'Content-Type': 'application/json', @@ -421,6 +441,7 @@ export async function updateManyRecords({ bypassDocumentValidation, ignoreTriggers, cluster, + database, resolveProviderFiles, }) { const response = await server.loadJson( @@ -432,6 +453,7 @@ export async function updateManyRecords({ headers: { 'X-CM-ProjectId': Config.projectId, 'X-CM-Cluster': cluster, + 'X-CM-Database': database, Authorization: `Bearer ${secretKey || Config.secretKey}`, Accept: 'application/json', 'Content-Type': 'application/json', @@ -459,6 +481,7 @@ export async function replaceRecord({ ignoreTriggers, isUpsert, cluster, + database, resolveProviderFiles, }) { const response = await server.loadJson( @@ -470,6 +493,7 @@ export async function replaceRecord({ headers: { 'X-CM-ProjectId': Config.projectId, 'X-CM-Cluster': cluster, + 'X-CM-Database': database, Authorization: `Bearer ${secretKey || Config.secretKey}`, Accept: 'application/json', 'Content-Type': 'application/json', @@ -499,6 +523,7 @@ export async function replaceRecordWithFilter({ ignoreTriggers, isUpsert, cluster, + database, resolveProviderFiles, }) { const response = await server.loadJson( @@ -510,6 +535,7 @@ export async function replaceRecordWithFilter({ headers: { 'X-CM-ProjectId': Config.projectId, 'X-CM-Cluster': cluster, + 'X-CM-Database': database, Authorization: `Bearer ${secretKey || Config.secretKey}`, Accept: 'application/json', 'Content-Type': 'application/json', @@ -535,6 +561,7 @@ export async function executeAggregate({ id, tokens, cluster, + database, }) { const url = `${ Config.apiUrl @@ -545,6 +572,7 @@ export async function executeAggregate({ headers: { 'X-CM-ProjectId': Config.projectId, 'X-CM-Cluster': cluster, + 'X-CM-Database': database, Authorization: `Bearer ${secretKey || Config.secretKey}`, Accept: 'application/json', 'Content-Type': 'application/json', @@ -564,6 +592,7 @@ export async function count({ limit, skip, cluster, + database, }) { const response = await server.loadJson( `${Config.apiUrl}${Endpoints.PROJECT.DATABASE.COLLECTION.RECORD.COUNT( @@ -574,6 +603,7 @@ export async function count({ headers: { 'X-CM-ProjectId': Config.projectId, 'X-CM-Cluster': cluster, + 'X-CM-Database': database, Authorization: `Bearer ${secretKey || Config.secretKey}`, Accept: 'application/json', 'Content-Type': 'application/json', @@ -595,6 +625,7 @@ export async function distinct({ filter, field, cluster, + database, }) { const response = await server.loadJson( `${Config.apiUrl}${Endpoints.PROJECT.DATABASE.COLLECTION.RECORD.DISTINCT( @@ -605,6 +636,7 @@ export async function distinct({ headers: { 'X-CM-ProjectId': Config.projectId, 'X-CM-Cluster': cluster, + 'X-CM-Database': database, Authorization: `Bearer ${secretKey || Config.secretKey}`, Accept: 'application/json', 'Content-Type': 'application/json', @@ -630,6 +662,7 @@ export async function getTerms({ projection, excludeCulture, cluster, + database, }) { const response = await server.loadJson( `${Config.apiUrl}${Endpoints.PROJECT.DATABASE.TAXONOMY.TERM.GET_ALL( @@ -640,6 +673,7 @@ export async function getTerms({ headers: { 'X-CM-ProjectId': Config.projectId, 'X-CM-Cluster': cluster, + 'X-CM-Database': database, Authorization: `Bearer ${secretKey || Config.secretKey}`, Accept: 'application/json', 'Content-Type': 'application/json', @@ -673,6 +707,7 @@ export async function getChildrenOfTerms({ projection, excludeCulture, cluster, + database, }) { const response = await server.loadJson( `${Config.apiUrl}${Endpoints.PROJECT.DATABASE.TAXONOMY.TERM.GET_CHILDREN( @@ -683,6 +718,7 @@ export async function getChildrenOfTerms({ headers: { 'X-CM-ProjectId': Config.projectId, 'X-CM-Cluster': cluster, + 'X-CM-Database': database, Authorization: `Bearer ${Config.secretKey}`, Accept: 'application/json', 'Content-Type': 'application/json', @@ -712,6 +748,7 @@ export async function changeResponsibility({ id, newResponsibleUserId, cluster, + database, }) { const response = await server.loadJson( `${ @@ -724,6 +761,7 @@ export async function changeResponsibility({ headers: { 'X-CM-ProjectId': Config.projectId, 'X-CM-Cluster': cluster, + 'X-CM-Database': database, Authorization: `Bearer ${secretKey || Config.secretKey}`, Accept: 'application/json', 'Content-Type': 'application/json', diff --git a/src/components/files.js b/src/components/files.js index 72334c2..4117e7d 100644 --- a/src/components/files.js +++ b/src/components/files.js @@ -137,6 +137,7 @@ export async function uploadRecordFile({ recordId, uniqueFieldName, cluster, + database, }) { if (base64) { const response = await server.loadJson( @@ -155,6 +156,7 @@ export async function uploadRecordFile({ recordId, uniqueFieldName, cluster, + database, base64File: {data: base64, contentType: fileType, fileName}, }), } @@ -195,6 +197,7 @@ export async function uploadRecordFile({ 'X-CM-ProjectId': Config.projectId, Authorization: `Bearer ${secretKey || Config.secretKey}`, 'X-CM-Cluster': cluster || '', + 'X-CM-Database': database || '', }, body: formData, } diff --git a/src/components/payments.js b/src/components/payments.js index 898e677..f14fc71 100644 --- a/src/components/payments.js +++ b/src/components/payments.js @@ -35,11 +35,13 @@ export async function getOrders({ userId, includePaidTransactions, cluster, + database, }) { const request = { userId, includePaidTransactions, cluster, + database, pageSize: pageSize || Config.tablePageSize, pageNumber: pageNumber || 0, filter: objectOrStringToString(filter),