MCPcopy Create free account
hub / github.com/bytebase/bytebase / extractDatabaseResourceName

Function extractDatabaseResourceName

frontend/src/utils/v1/database.ts:34–58  ·  view source on GitHub ↗
(
  resource: string
)

Source from the content-addressed store, hash-verified

32};
33
34export const extractDatabaseResourceName = (
35 resource: string
36): {
37 // instance full name
38 instance: string;
39 // database full name
40 database: string;
41 databaseName: string;
42 instanceName: string;
43} => {
44 const pattern =
45 /(?:^|\/)instances\/(?<instanceName>[^/]+)\/databases\/(?<databaseName>[^/]+)(?:$|\/)/;
46 const matches = resource.match(pattern);
47
48 const {
49 databaseName = String(UNKNOWN_ID),
50 instanceName = String(UNKNOWN_ID),
51 } = matches?.groups ?? {};
52 return {
53 instance: `${instanceNamePrefix}${instanceName}`,
54 instanceName,
55 database: `${instanceNamePrefix}${instanceName}/${databaseNamePrefix}${databaseName}`,
56 databaseName,
57 };
58};
59
60// isDatabaseV1Queryable checks if database allowed to query in SQL Editor.
61export const isDatabaseV1Queryable = (

Callers 15

DatabaseSelectFunction · 0.90
DatabaseTargetDisplayFunction · 0.90
resourceLabelFunction · 0.90
DatabaseResourceSelectorFunction · 0.90
DatabaseTableViewFunction · 0.90
MonacoEditorFunction · 0.90
BodyFunction · 0.90
getTabNameFunction · 0.90
buildInstanceNodeListFunction · 0.90
buildDatabaseNodeListFunction · 0.90
gotoCreateIssueFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected