export type EgressTopic = 'JOBS' | 'MONITORS' | 'RULES'; export type EgressOperator = 'EQ' | 'NE' | 'IN' | 'NOT_IN' | 'LIKE' | 'GTE' | 'LTE' | 'GT' | 'LT' | 'IS_NULL' | 'IS_NOT_NULL'; export type EgressFilter = {field: string, op: EgressOperator, value: unknown, values?: Array | undefined}; export type EgressRequest = {topics?: Array | undefined, filters?: Array | undefined, includeCatalogAssets?: boolean | undefined}; export type CreateApiEgressExportArgs = {window?: number | undefined, includeCatalogAssets?: boolean | undefined, excludeRuleAssets?: boolean | undefined, excludeColumnAssets?: boolean | undefined, completionMarker?: boolean | undefined, body: EgressRequest}; export type CreateApiEgressExportOptions = {baseUrl: string, basicAuth?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * Export joined data across multiple DQ topics * * POST /egress/export * * Also accepts auth: jwtAuth, oauth2, oauth2 */ export const createApiEgressExport = async (args: CreateApiEgressExportArgs, options: CreateApiEgressExportOptions) => { const {baseUrl, fetch: fetchFn = fetch, basicAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/x-ndjson") if (args.window != null) query.append("window", String(args.window)) if (args.includeCatalogAssets != null) query.append("includeCatalogAssets", String(args.includeCatalogAssets)) if (args.excludeRuleAssets != null) query.append("excludeRuleAssets", String(args.excludeRuleAssets)) if (args.excludeColumnAssets != null) query.append("excludeColumnAssets", String(args.excludeColumnAssets)) if (args.completionMarker != null) query.append("completionMarker", String(args.completionMarker)) if (basicAuth !== undefined) headers.set('authorization', `Basic ${btoa(`${basicAuth.username}:${basicAuth.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/egress/export${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };