Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(database): pass database to api #106

Merged
merged 1 commit into from
Dec 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 38 additions & 0 deletions src/components/db.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand 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',
Expand Down Expand Up @@ -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(
Expand All @@ -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',
Expand Down Expand Up @@ -120,6 +124,7 @@ export async function getRecordWithFilter({
excludeCulture,
language,
cluster,
database,
}) {
const response = await server.loadJson(
`${
Expand All @@ -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',
Expand Down Expand Up @@ -160,6 +166,7 @@ export async function deleteRecord({
id,
ignoreTriggers,
cluster,
database,
}) {
let url = `${
Config.apiUrl
Expand All @@ -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',
Expand All @@ -192,6 +200,7 @@ export async function deleteRecordWithFilter({
filter,
ignoreTriggers,
cluster,
database,
}) {
let url = `${
Config.apiUrl
Expand All @@ -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',
Expand All @@ -227,6 +237,7 @@ export async function deleteManyRecords({
filter,
ignoreTriggers,
cluster,
database,
}) {
let url = `${
Config.apiUrl
Expand All @@ -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',
Expand All @@ -262,6 +274,7 @@ export async function insertRecord({
waitForFileUpload,
ignoreTriggers,
cluster,
database,
resolveProviderFiles,
responsibleUserId,
}) {
Expand All @@ -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',
Expand All @@ -299,6 +313,7 @@ export async function insertManyRecords({
bypassDocumentValidation,
ignoreTriggers,
cluster,
database,
resolveProviderFiles,
responsibleUserId,
}) {
Expand All @@ -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',
Expand All @@ -344,6 +360,7 @@ export async function updateRecord({
bypassDocumentValidation,
ignoreTriggers,
cluster,
database,
resolveProviderFiles,
}) {
const response = await server.loadJson(
Expand All @@ -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',
Expand All @@ -382,6 +400,7 @@ export async function updateRecordWithFilter({
bypassDocumentValidation,
ignoreTriggers,
cluster,
database,
resolveProviderFiles,
}) {
const response = await server.loadJson(
Expand All @@ -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',
Expand All @@ -421,6 +441,7 @@ export async function updateManyRecords({
bypassDocumentValidation,
ignoreTriggers,
cluster,
database,
resolveProviderFiles,
}) {
const response = await server.loadJson(
Expand All @@ -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',
Expand Down Expand Up @@ -459,6 +481,7 @@ export async function replaceRecord({
ignoreTriggers,
isUpsert,
cluster,
database,
resolveProviderFiles,
}) {
const response = await server.loadJson(
Expand All @@ -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',
Expand Down Expand Up @@ -499,6 +523,7 @@ export async function replaceRecordWithFilter({
ignoreTriggers,
isUpsert,
cluster,
database,
resolveProviderFiles,
}) {
const response = await server.loadJson(
Expand All @@ -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',
Expand All @@ -535,6 +561,7 @@ export async function executeAggregate({
id,
tokens,
cluster,
database,
}) {
const url = `${
Config.apiUrl
Expand All @@ -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',
Expand All @@ -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(
Expand All @@ -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',
Expand All @@ -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(
Expand All @@ -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',
Expand All @@ -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(
Expand 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',
Expand Down Expand Up @@ -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(
Expand All @@ -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',
Expand Down Expand Up @@ -712,6 +748,7 @@ export async function changeResponsibility({
id,
newResponsibleUserId,
cluster,
database,
}) {
const response = await server.loadJson(
`${
Expand All @@ -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',
Expand Down
3 changes: 3 additions & 0 deletions src/components/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ export async function uploadRecordFile({
recordId,
uniqueFieldName,
cluster,
database,
}) {
if (base64) {
const response = await server.loadJson(
Expand All @@ -155,6 +156,7 @@ export async function uploadRecordFile({
recordId,
uniqueFieldName,
cluster,
database,
base64File: {data: base64, contentType: fileType, fileName},
}),
}
Expand Down Expand Up @@ -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,
}
Expand Down
2 changes: 2 additions & 0 deletions src/components/payments.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down