import {z} from 'zod' export type AttributeDefPublic = {name: string, description?: string | undefined, displayName?: string | undefined, datatype: 'STRING' | 'INTEGER' | 'LONG' | 'STRING_REFERENCE' | 'INTEGER_REFERENCE' | 'LONG_REFERENCE' | 'BOOLEAN' | 'DECIMAL' | 'DATE' | 'DATETIME' | 'ENUM' | 'FINGERPRINT' | 'CLOB' | 'BLOB' | 'OBJECT' | 'STRING_ARRAY' | 'INTEGER_ARRAY' | 'LONG_ARRAY' | 'STRING_REFERENCE_ARRAY' | 'INTEGER_REFERENCE_ARRAY' | 'LONG_REFERENCE_ARRAY' | 'BOOLEAN_ARRAY' | 'DECIMAL_ARRAY' | 'DATE_ARRAY' | 'DATETIME_ARRAY' | 'ENUM_ARRAY' | 'BLOB_ARRAY' | 'OBJECT_ARRAY' | 'VECTOR', required?: boolean | undefined, precision?: number | undefined, defaultValue?: string | undefined, min?: number | undefined, max?: number | undefined, regex?: string | undefined, enumValues: Array, fingerprintAttributes: Array, vectorAttributes: Array, referenceDictionaryName?: string | undefined}; export type IndexDefPublic = {name: string, attributes: Array, type: 'PRIMARY' | 'UNIQUE' | 'NORMAL' | 'KEYWORD' | 'FULL' | 'VECTOR', numDimensions: number, partialFilterTql?: string | undefined}; export type DictionaryPublic = {name: string, description?: string | undefined, displayName?: string | undefined, groupName?: string | undefined, layoutMetadata?: Record | undefined, undefinedAttributesAction: 'KEEP' | 'REMOVE' | 'ERROR', attributes: Array, indexes?: Array | undefined, properties?: Record | undefined}; export type DictionaryUploadJobRequestPublic = {dictionary: DictionaryPublic, emailResultsTo?: Array | undefined}; export type CreateApiApiJobsDictionaryArgs = {emailResultsTo?: Array | undefined, body: DictionaryUploadJobRequestPublic}; export type CreateApiApiJobsDictionaryOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const jsonNodePublic = z.unknown(); export const jobResultsPublic = z.object({results: z.object({}).optional(), error: jsonNodePublic.optional(), errorString: z.string().optional(), errorStrings: z.array(z.string()).optional()}); export const dictionaryUploadJobPublic = z.object({jobId: z.string(), name: z.string().min(1), status: z.enum(["NEW", "QUEUED", "RUNNING", "CANCELLED", "COMPLETED_ERROR", "COMPLETED_SUCCESS", "INCOMPLETE_ERROR"]), jobCreated: z.string(), jobQueued: z.string().optional(), jobStarted: z.string().optional(), jobCompleted: z.string().optional(), emailRecipients: z.array(z.string()).optional(), timeout: z.number().int().optional(), timeoutUnit: z.enum(["NANOSECONDS", "MICROSECONDS", "MILLISECONDS", "SECONDS", "MINUTES", "HOURS", "DAYS"]), results: jobResultsPublic.optional(), customerName: z.string().min(1), sdzName: z.string().min(1), effectiveId: z.string(), loggedInId: z.string(), mdc: z.record(z.string(), z.string()), originalFilename: z.string().optional(), key: z.string().optional(), dictName: z.string().optional()}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Allowed user roles:
  • sdzAdmin


load (upsert) a dictionary into the SDZ using 1) POST with JSON body with dictionary and emailResultsTo (optional); or 2) MULTIPART POST with dictionary file and emailResultsTo (optional) as form fields * * POST /api/jobs/dictionary */ export const createApiApiJobsDictionary = async (args: CreateApiApiJobsDictionaryArgs, options?: CreateApiApiJobsDictionaryOptions) => { const {baseUrl = "https://api.burstiq.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") for (const item of args.emailResultsTo ?? []) query.append("emailResultsTo", String(item)) const url = `${baseUrl.replace(/\/+$/, '')}/api/jobs/dictionary${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 validateResponse(dictionaryUploadJobPublic, await res.json()) };