Skip to content
Open
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
Binary file not shown.
Binary file not shown.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
"@urql/exchange-request-policy": "^2.0.0",
"@urql/exchange-retry": "^2.0.0",
"ansicolor": "^2.0.1",
"data-plane-gateway": "file:__inline-deps__/data-plane-gateway-0.0.0-20251201-150928.tgz",
"data-plane-gateway": "file:__inline-deps__/data-plane-gateway-0.0.0-20260622-190856.tgz",
"date-fns": "^4.1.0",
"dayjs": "^1.11.19",
"echarts": "^5.4.3",
Expand Down
46 changes: 21 additions & 25 deletions src/hooks/journals/useJournalData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,15 @@ import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { useShallow } from 'zustand/react/shallow';

import { JournalClient, JournalSelector } from 'data-plane-gateway';
import { isEmpty } from 'lodash';
import { useCounter } from 'react-use';
import useSWR from 'swr';

import { singleCallSettings } from 'src/context/SWR';
import { useUserStore } from 'src/context/User/useUserContextStore';
import { loadDocuments } from 'src/hooks/journals/shared';
import { logRocketEvent } from 'src/services/shared';
import { FETCH_DEFAULT_ERROR, logRocketEvent } from 'src/services/shared';
import useJournalStore from 'src/stores/JournalData/Store';
import {
getJournals,
isNestedProtocolListResponse,
MAX_DOCUMENT_SIZE,
shouldRefreshToken,
} from 'src/utils/dataPlane-utils';
Expand Down Expand Up @@ -54,31 +51,30 @@ const useJournalsForCollection = (collectionName: string | undefined) => {
brokerAddress &&
brokerToken
) {
const journalSelector = new JournalSelector().collection(
collectionName
);
try {
const result = await journalClient.list(
new JournalSelector().collection(collectionName)
);

const dataPlaneListResponse = await getJournals(
brokerAddress,
brokerToken,
{
include: journalSelector.toLabelSet(),
// Returning the rejected promise (rather than throwing) keeps
// this out of the catch below, so the broker's error message
// reaches SWR's onError for token-refresh handling.
if (result.err()) {
return Promise.reject({
message:
result.unwrap_err().body.message ??
FETCH_DEFAULT_ERROR,
});
}
);

if (isEmpty(dataPlaneListResponse)) {
return Promise.reject(dataPlaneListResponse);
return {
journals: result.unwrap().journals ?? [],
};
} catch {
// The gateway client throws on transport-level failures it
// cannot parse into a ResponseError, e.g. a network error.
return Promise.reject({ message: FETCH_DEFAULT_ERROR });
}

const journals = isNestedProtocolListResponse(
dataPlaneListResponse
)
? dataPlaneListResponse.result.journals
: dataPlaneListResponse.journals;

return {
journals: journals ?? [],
};
} else {
return null;
}
Expand Down
21 changes: 0 additions & 21 deletions src/utils/dataPlane-utils.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
import type { Session } from '@supabase/supabase-js';
import type {
ProtocolLabelSelector,
ProtocolListResponse,
} from 'data-plane-gateway/types/gen/broker/protocol/broker';
import type { Shard } from 'data-plane-gateway/types/shard_client';
import type { ResponseError } from 'data-plane-gateway/types/util';
import type { BaseDataPlaneQuery } from 'src/api/dataPlanes';
Expand Down Expand Up @@ -188,23 +184,6 @@ export const authorizeCollection = async (
accessToken
);

// Streaming RPC responses going through grpc-gateway have a `result` vs `error` top-level property added,
// which wraps the actual response. The old data-plane gateway returns unary RPC responses from the /list APIs,
// which don't have a top-level `result` property.
export const isNestedProtocolListResponse = (
response: { result: ProtocolListResponse } | ProtocolListResponse
): response is { result: ProtocolListResponse } => 'result' in response;

export const getJournals = async (
brokerAddress: string,
brokerToken: string,
selector: ProtocolLabelSelector
): Promise<{ result: ProtocolListResponse } | ProtocolListResponse> =>
client(
`${brokerAddress}/v1/journals/list`,
{ data: { selector } },
brokerToken
);
/** @deprecated Scope is returned by dataplane gql query */
export const getDataPlaneScope = (
dataPlaneName: string
Expand Down
Loading