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

Function getInstanceIdOptionConfig

frontend/src/utils/expr.ts:102–142  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

100};
101
102export const getInstanceIdOptionConfig = (): OptionConfig => {
103 return {
104 options: [],
105 fetch: async (instanceIds: string[]) => {
106 const { useAppStore } = await import("@/react/stores/app");
107 // TODO(ed): batch fetch instances
108 const instances = await Promise.all(
109 instanceIds.map((instanceId) =>
110 useAppStore
111 .getState()
112 .getOrFetchInstanceByName(`${instanceNamePrefix}${instanceId}`)
113 )
114 );
115 const options: LabeledOption[] = [];
116 for (const instance of instances) {
117 if (!isValidInstanceName(instance.name)) {
118 continue;
119 }
120 options.push(getInstanceIdOption(instance));
121 }
122 return options;
123 },
124 search: async (params) => {
125 const { useAppStore } = await import("@/react/stores/app");
126 return useAppStore
127 .getState()
128 .fetchInstanceList({
129 pageSize: params.pageSize,
130 pageToken: params.pageToken,
131 filter: {
132 query: params.search,
133 },
134 silent: true,
135 })
136 .then((resp) => ({
137 nextPageToken: resp.nextPageToken,
138 options: resp.instances.map(getInstanceIdOption),
139 }));
140 },
141 };
142};
143
144export const getDatabaseIdOptionConfig = (parent: string): OptionConfig => {
145 return {

Callers 3

GlobalMaskingPageFunction · 0.90

Calls 2

isValidInstanceNameFunction · 0.90
getInstanceIdOptionFunction · 0.85

Tested by

no test coverage detected