import {z} from 'zod' export type LabelRelationSelectSchema = {_id?: boolean | undefined, createdAt?: boolean | undefined, updatedAt?: boolean | undefined, deletedAt?: boolean | undefined, name?: boolean | undefined, projectId?: boolean | undefined, color?: boolean | undefined, isArchived?: boolean | undefined}; export type DataStoreSelectSchema = {_id?: boolean | undefined, createdAt?: boolean | undefined, updatedAt?: boolean | undefined, deletedAt?: boolean | undefined, projectId?: boolean | undefined, name?: boolean | undefined, description?: boolean | undefined, storeKey?: boolean | undefined, kind?: boolean | undefined, provider?: boolean | undefined, family?: boolean | undefined, discoveredFrom?: boolean | undefined, cloudAccountId?: boolean | undefined, cloudResourceId?: boolean | undefined, cloudConnectionId?: boolean | undefined, databaseServerId?: boolean | undefined, serviceId?: boolean | undefined, providerResourceId?: boolean | undefined, cloudAccountNumber?: boolean | undefined, region?: boolean | undefined, environment?: boolean | undefined, sensitivity?: boolean | undefined, sensitivityOverride?: boolean | undefined, dataTypeIds?: boolean | undefined, dataCategories?: boolean | undefined, subjectCountries?: boolean | undefined, exposure?: boolean | undefined, posture?: boolean | undefined, cloudTags?: boolean | undefined, sizeInBytes?: boolean | undefined, objectCount?: boolean | undefined, estimatedRecords?: boolean | undefined, lastActivityAt?: boolean | undefined, isPublicByDesign?: boolean | undefined, isAiData?: boolean | undefined, isContentScanEnabled?: boolean | undefined, scanProbeId?: boolean | undefined, probeConnectionVariable?: boolean | undefined, scanExclusions?: boolean | undefined, watchedPaths?: boolean | undefined, purpose?: boolean | undefined, retention?: boolean | undefined, configurationReadAt?: boolean | undefined, contentScannedAt?: boolean | undefined, contentScanStatus?: boolean | undefined, nextContentScanAt?: boolean | undefined, isTableHealthEnabled?: boolean | undefined, tableHealthCollectedAt?: boolean | undefined, tableHealthStatus?: boolean | undefined, tableHealthMessage?: boolean | undefined, tableHealthAssetCount?: boolean | undefined, newPersonalDataColumns?: boolean | undefined, findingCount?: boolean | undefined, openIssueCount?: boolean | undefined, highestIssueSeverity?: boolean | undefined, riskScore?: boolean | undefined, isArchived?: boolean | undefined, firstSeenAt?: boolean | undefined, lastSeenAt?: boolean | undefined, labels?: LabelRelationSelectSchema | undefined, createdByUserId?: boolean | undefined, deletedByUserId?: boolean | undefined}; export type CreateApiDataStoreIdGetItemArgs = {id: string, body: {select?: DataStoreSelectSchema | undefined}}; export type CreateApiDataStoreIdGetItemOptions = {baseUrl?: string | undefined, ApiKey?: string | undefined, fetch?: typeof fetch | undefined}; export const dataStore = z.object({_id: z.string().optional(), createdAt: z.object({}).optional(), updatedAt: z.object({}).optional(), deletedAt: z.object({}).optional(), version: z.number().optional(), projectId: z.string(), name: z.string(), description: z.string().optional(), storeKey: z.string(), kind: z.enum(["AWS S3 Bucket", "AWS RDS Instance", "AWS Aurora Cluster", "AWS RDS Snapshot", "AWS DynamoDB Table", "AWS Redshift Cluster", "AWS DocumentDB Cluster", "AWS OpenSearch Domain", "AWS ElastiCache Cluster", "AWS EFS File System", "Azure Storage Account", "Azure SQL Database", "Azure Cosmos DB Account", "Azure PostgreSQL Server", "Azure MySQL Server", "Google Cloud Storage Bucket", "Google Cloud SQL Instance", "Google BigQuery Dataset", "Google Firestore Database", "Google Spanner Instance", "Google Bigtable Instance", "PostgreSQL", "MySQL", "MongoDB", "SQL Server", "Oracle", "Redis", "Elasticsearch", "Snowflake", "ClickHouse", "Databricks", "Amazon Athena", "Logs", "Traces", "Exceptions", "Session Replays", "AI Conversations"]), provider: z.string().optional(), family: z.string().optional(), discoveredFrom: z.string().optional(), cloudAccountId: z.string().optional(), cloudResourceId: z.string().optional(), cloudConnectionId: z.string().optional(), databaseServerId: z.string().optional(), serviceId: z.string().optional(), providerResourceId: z.string().optional(), cloudAccountNumber: z.string().optional(), region: z.string().optional(), environment: z.enum(["Production", "Staging", "Development", "Test", "Unknown"]), sensitivity: z.enum(["Restricted", "Confidential", "Internal", "Public"]), sensitivityOverride: z.enum(["Restricted", "Confidential", "Internal", "Public"]).optional(), dataTypeIds: z.object({}).optional(), dataCategories: z.object({}).optional(), subjectCountries: z.object({}).optional(), exposure: z.enum(["Public", "Other accounts", "Internet reachable", "Private", "Unknown"]), posture: z.object({}).optional(), cloudTags: z.object({}).optional(), sizeInBytes: z.number().optional(), objectCount: z.number().optional(), estimatedRecords: z.number().optional(), lastActivityAt: z.object({}).optional(), isPublicByDesign: z.boolean(), isAiData: z.boolean(), isContentScanEnabled: z.boolean(), scanProbeId: z.string().optional(), probeConnectionVariable: z.string().optional(), scanExclusions: z.object({}).optional(), watchedPaths: z.string().optional(), purpose: z.string().optional(), retention: z.string().optional(), configurationReadAt: z.object({}).optional(), contentScannedAt: z.object({}).optional(), contentScanStatus: z.string().optional(), nextContentScanAt: z.object({}).optional(), isTableHealthEnabled: z.boolean(), tableHealthCollectedAt: z.object({}).optional(), tableHealthStatus: z.string().optional(), tableHealthMessage: z.string().optional(), tableHealthAssetCount: z.number().optional(), newPersonalDataColumns: z.object({}).optional(), findingCount: z.number(), openIssueCount: z.number(), highestIssueSeverity: z.enum(["Critical", "High", "Medium", "Low"]).optional(), riskScore: z.number(), isArchived: z.boolean(), firstSeenAt: z.object({}).optional(), lastSeenAt: z.object({}).optional(), labels: z.array(z.object({_id: z.string().optional()})).optional(), createdByUserId: z.string().optional(), deletedByUserId: z.string().optional()}); export const createApiDataStoreIdGetItemResponse = z.object({data: dataStore.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 }; /** * Get Data Store * * POST /data-store/{id}/get-item */ export const createApiDataStoreIdGetItem = async (args: CreateApiDataStoreIdGetItemArgs, options?: CreateApiDataStoreIdGetItemOptions) => { const {baseUrl = "https://oneuptime.com/api", fetch: fetchFn = fetch, ApiKey} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (ApiKey !== undefined) headers.set("APIKey", ApiKey) const url = `${baseUrl.replace(/\/+$/, '')}/data-store/${encodeURIComponent(String(args.id))}/get-item${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(createApiDataStoreIdGetItemResponse, await res.json()) };