import {z} from 'zod' export type EntityID = string; export type EntityType = 'INDIVIDUAL' | 'ORGANIZATION' | 'UNKNOWN'; export type AddressTypeEnum = 'OTHER' | 'RESIDENTIAL' | 'BUSINESS' | 'POSTAL' | 'REGISTERED_OFFICE' | 'PLACE_OF_BUSINESS' | 'OFFICIAL_CORRESPONDANCE' | 'PLACE_OF_BIRTH' | 'OFFICE_LOCALITY'; export type DateType = 'BUDDHIST' | 'DISCORDIAN' | 'GREGORIAN' | 'HEBREW' | 'ISLAMIC' | 'JULIAN' | 'LUNAR' | 'MESO_AMERICAN' | 'PERSIAN' | 'OTHER'; export type Date = {year?: string | undefined, month?: string | undefined, day?: string | undefined, unstructured?: string | undefined, type?: DateType | undefined, normalized?: string | undefined}; export type AddressStatusEnum = 'CURRENT' | 'PREVIOUS' | 'FUTURE'; export type Address = {addressId?: string | undefined, sourceId?: string | undefined, type?: AddressTypeEnum | undefined, typeDescription?: string | undefined, validFrom?: Date | undefined, validTo?: Date | undefined, longForm?: string | undefined, unitNumber?: string | undefined, buildingName?: string | undefined, streetName?: string | undefined, streetNumber?: string | undefined, streetType?: string | undefined, neighborhood?: string | undefined, locality?: string | undefined, district?: string | undefined, subdivision?: string | undefined, country: string, postalCode?: string | undefined, careOf?: string | undefined, status?: AddressStatusEnum | undefined, unstructuredLongForm?: string | undefined}; export type PhoneNumberID = string; export type PhoneNumber = {phoneNumberId?: PhoneNumberID | undefined, isPreferred?: boolean | undefined, type?: ('OTHER' | 'WORK' | 'HOME' | 'MOBILE' | 'BUSINESS' | 'FAX') | undefined, sourceId?: string | undefined, country?: string | undefined, number?: string | undefined, linkedAddresses?: (Array<{addressId?: string | undefined}>) | undefined, unstructuredLongForm?: string | undefined}; export type EmailAddressID = string; export type Email = {emailAddressId?: EmailAddressID | undefined, type?: ('OTHER' | 'WORK' | 'PERSONAL' | 'BUSINESS') | undefined, sourceId?: string | undefined, email?: string | undefined, isPreferred?: boolean | undefined, linkedAddresses?: (Array<{addressId?: string | undefined}>) | undefined}; export type Attribute = {type: string, value: string}; export type CustomAttributes = {[key: string]: Attribute}; export type ExternalReference = {referenceId?: string | undefined, type?: ('SYSTEM' | 'CUSTOMER' | 'OTHER') | undefined, sourceId?: string | undefined, name: string, value: string, description?: string | undefined}; export type DocumentID = string; export type DocumentType = 'OTHER' | 'DRIVERS_LICENSE' | 'PASSPORT' | 'VISA' | 'IMMIGRATION' | 'NATIONAL_ID' | 'TAX_ID' | 'NATIONAL_HEALTH_ID' | 'CONCESSION' | 'HEALTH_CONCESSION' | 'PENSION' | 'MILITARY_ID' | 'BIRTH_CERT' | 'CITIZENSHIP' | 'MARRIAGE_CERT' | 'DEATH_CERT' | 'NAME_CHANGE' | 'UTILITY_BILL' | 'BANK_STATEMENT' | 'BANK_ACCOUNT' | 'INTENT_PROOF' | 'ATTESTATION' | 'SELF_IMAGE' | 'DEVICE' | 'VEHICLE_REGISTRATION' | 'PROOF_OF_ADDRESS' | 'HOUSE_REGISTRATION' | 'YELLOW_HOUSE_REGISTRATION' | 'WORK_PERMIT' | 'EMPLOYMENT_CERTIFICATE' | 'NOTARY_PUBLIC_ID' | 'EXTERNAL_ADMIN' | 'CHARGES' | 'PRE_ASIC' | 'ANNUAL_RETURN' | 'REPORT' | 'TRUST_DEED' | 'PARTNERSHIP_AGREEMENT' | 'ADMIN_CHANGE' | 'COMPANY_REPORT' | 'CHECK_RESULTS' | 'AVIATION_SECURITY_ID' | 'MARITIME_SECURITY_ID'; export type DocumentSupplementaryData = {type: 'NATIONAL_HEALTH_ID' | 'BIRTH_CERT' | 'NATIONAL_ID' | 'CITIZENSHIP' | 'PASSPORT' | 'MARRIAGE_CERT', reference?: string | undefined, nameOnCardLine1?: string | undefined, nameOnCardLine2?: string | undefined, nameOnCardLine3?: string | undefined, nameOnCardLine4?: string | undefined, middleNameOnCard?: string | undefined} | {type: 'NATIONAL_HEALTH_ID' | 'BIRTH_CERT' | 'NATIONAL_ID' | 'CITIZENSHIP' | 'PASSPORT' | 'MARRIAGE_CERT', registrationDate?: string | undefined, registrationDistrict?: string | undefined, dateOfPrint?: string | undefined, givenName?: string | undefined, otherNames?: string | undefined, familyName?: string | undefined} | {type: 'NATIONAL_HEALTH_ID' | 'BIRTH_CERT' | 'NATIONAL_ID' | 'CITIZENSHIP' | 'PASSPORT' | 'MARRIAGE_CERT', homeCountryFullName?: string | undefined, paternalFamilyName?: string | undefined, maternalFamilyName?: string | undefined} | {type: 'NATIONAL_HEALTH_ID' | 'BIRTH_CERT' | 'NATIONAL_ID' | 'CITIZENSHIP' | 'PASSPORT' | 'MARRIAGE_CERT', acquisitionDate?: string | undefined, primaryCountry?: string | undefined, secondaryCountry?: string | undefined} | {type: 'NATIONAL_HEALTH_ID' | 'BIRTH_CERT' | 'NATIONAL_ID' | 'CITIZENSHIP' | 'PASSPORT' | 'MARRIAGE_CERT', homeCountryFullName?: string | undefined} | {type: 'NATIONAL_HEALTH_ID' | 'BIRTH_CERT' | 'NATIONAL_ID' | 'CITIZENSHIP' | 'PASSPORT' | 'MARRIAGE_CERT', partner1GivenName?: string | undefined, partner1FamilyName?: string | undefined, partner1OtherName?: string | undefined, partner2GivenName?: string | undefined, partner2FamilyName?: string | undefined, partner2OtherName?: string | undefined, registrationDate?: string | undefined, marriageDate?: string | undefined, dateOfPrint?: string | undefined}; export type DocumentAttachmentID = string; export type DocumentAttachmentSide = 'FRONT' | 'BACK'; export type DocumentAttachmentType = string; export type DataURIBase64 = {uri: string} | {base64: string}; export type DocumentAttachmentRetrievalStatus = 'NORMAL' | 'EXCLUDED' | 'FAILED'; export type DocumentAttachment = {attachmentId?: DocumentAttachmentID | undefined, sourceId?: string | undefined, createdAt?: string | undefined, updatedAt?: string | undefined, filename?: string | undefined, mimeType?: string | undefined, pageNumber?: number | undefined, side?: DocumentAttachmentSide | undefined, type?: DocumentAttachmentType | undefined, location?: string | undefined, data: DataURIBase64, lastMalwareScanAt?: string | undefined, retrievalStatus?: DocumentAttachmentRetrievalStatus | undefined}; export type DocumentInformation = {documentId?: DocumentID | undefined, entityId?: EntityID | undefined, expiryDate?: Date | undefined, issueDate?: Date | undefined, primaryIdentifier?: string | undefined, secondaryIdentifier?: string | undefined, type: DocumentType, subtype?: string | undefined, subdivision?: string | undefined, country: string, createdAt?: string | undefined, updatedAt?: string | undefined, validFrom?: Date | undefined, validTo?: Date | undefined, sourceId?: string | undefined, supplementaryData?: DocumentSupplementaryData | undefined, customAttributes?: CustomAttributes | undefined, attachments?: Array | undefined}; export type EntityDocuments = {REPORT?: Array | undefined, SUPPORTING?: Array | undefined, IDENTITY?: Array | undefined, OTHER?: Array | undefined}; export type IndividualName = {nameId?: string | undefined, language?: string | undefined, givenName?: string | undefined, middleName?: string | undefined, familyName: string, otherName?: string | undefined, prefix?: string | undefined, suffix?: string | undefined, sourceId?: string | undefined, displayName?: string | undefined}; export type IndividualNameAlternate = {nameId?: string | undefined, language?: string | undefined, givenName?: string | undefined, middleName?: string | undefined, familyName: string, otherName?: string | undefined, prefix?: string | undefined, suffix?: string | undefined, sourceId?: string | undefined, displayName?: string | undefined, type?: ('OTHER' | 'ALIAS' | 'PREVIOUS') | undefined}; export type DateOfBirth = {dateOfBirthId?: string | undefined, sourceId?: string | undefined, year?: string | undefined, month?: string | undefined, day?: string | undefined, unstructured?: string | undefined, type?: DateType | undefined, normalized?: string | undefined}; export type DateOfBirthAlternate = {dateOfBirthId?: string | undefined, sourceId?: string | undefined, year?: string | undefined, month?: string | undefined, day?: string | undefined, unstructured?: string | undefined, type?: DateType | undefined, normalized?: string | undefined}; export type GenderEnum = 'MALE' | 'FEMALE' | 'NON_BINARY' | 'OTHER' | 'UNSPECIFIED'; export type Gender = {genderId?: string | undefined, gender?: GenderEnum | undefined, sourceId?: string | undefined}; export type AddressPlaceOfBirth = {addressId?: string | undefined, sourceId?: string | undefined, longForm?: string | undefined, unstructuredLongForm?: string | undefined, unitNumber?: string | undefined, buildingName?: string | undefined, streetName?: string | undefined, streetNumber?: string | undefined, streetType?: string | undefined, neighborhood?: string | undefined, locality?: string | undefined, district?: string | undefined, subdivision?: string | undefined, country: string, postalCode?: string | undefined}; export type Consent = {type?: ('GENERAL' | 'DOCS' | 'CREDITHEADER' | 'UNDER18' | 'PAYROLL' | 'INSURANCE' | 'SUPERANNUATION') | undefined, schemaVersion?: number | undefined, sourceId?: string | undefined}; export type InformationSource = {sourceId?: string | undefined, type?: string | undefined, source?: string | undefined, description?: string | undefined, provider?: string | undefined, providerReference?: string | undefined, createdAt?: string | undefined, requestedAt?: string | undefined, generatedAt?: string | undefined, retrievedAt?: string | undefined, updatedAt?: string | undefined, isAuthoritative?: boolean | undefined, isManual?: boolean | undefined}; export type ProcessResultID = string; export type RelationshipOrigin = {entityId?: EntityID | undefined, entityType?: EntityType | undefined, processResultId?: ProcessResultID | undefined, createdAt?: string | undefined}; export type Relationship = {entityId?: EntityID | undefined, entityType?: EntityType | undefined, origin?: RelationshipOrigin | undefined}; export type IndividualRelationships = {duplicates?: Array | undefined}; export type Individual = {entityId?: EntityID | undefined, entityType?: EntityType | undefined, createdAt?: string | undefined, schemaVersion?: number | undefined, addresses?: Array
| undefined, phoneNumbers?: Array | undefined, emailAddresses?: Array | undefined, customAttributes?: CustomAttributes | undefined, externalReferences?: Array | undefined, documents?: EntityDocuments | undefined, sourceId?: string | undefined, name?: IndividualName | undefined, alternateNames?: Array | undefined, dateOfBirth?: DateOfBirth | undefined, alternateDatesOfBirth?: Array | undefined, gender?: Gender | undefined, placeOfBirth?: AddressPlaceOfBirth | undefined, nationality?: string | undefined, consents?: Array | undefined, informationSources?: {[key: string]: InformationSource} | undefined, relationships?: IndividualRelationships | undefined}; export type Comment = {commentId?: string | undefined, text?: string | undefined}; export type IndividualsCreate = {individual?: Individual | undefined, serviceName?: string | undefined, workflowName?: string | undefined, comment?: Comment | undefined}; export type CreateApiV2IndividualsArgs = {api_key: string, 'X-Frankie-CustomerID': string, 'X-Frankie-CustomerChildID'?: string | undefined, 'X-Frankie-Channel'?: string | undefined, 'X-Frankie-Username'?: string | undefined, body: IndividualsCreate}; export type CreateApiV2IndividualsOptions = {baseUrl?: string | undefined, ApiKey?: string | undefined, fetch?: typeof fetch | undefined}; export const entityID = z.string(); export const entityType = z.enum(["INDIVIDUAL", "ORGANIZATION", "UNKNOWN"]); export const addressTypeEnum = z.enum(["OTHER", "RESIDENTIAL", "BUSINESS", "POSTAL", "REGISTERED_OFFICE", "PLACE_OF_BUSINESS", "OFFICIAL_CORRESPONDANCE", "PLACE_OF_BIRTH", "OFFICE_LOCALITY"]); export const dateType = z.enum(["BUDDHIST", "DISCORDIAN", "GREGORIAN", "HEBREW", "ISLAMIC", "JULIAN", "LUNAR", "MESO_AMERICAN", "PERSIAN", "OTHER"]); export const date = z.object({year: z.string().optional(), month: z.string().optional(), day: z.string().optional(), unstructured: z.string().optional(), type: dateType.optional(), normalized: z.string().optional()}); export const addressStatusEnum = z.enum(["CURRENT", "PREVIOUS", "FUTURE"]); export const address = z.object({addressId: z.string().optional(), sourceId: z.string().optional(), type: addressTypeEnum.optional(), typeDescription: z.string().optional(), validFrom: date.optional(), validTo: date.optional(), longForm: z.string().optional(), unitNumber: z.string().optional(), buildingName: z.string().optional(), streetName: z.string().optional(), streetNumber: z.string().optional(), streetType: z.string().optional(), neighborhood: z.string().optional(), locality: z.string().optional(), district: z.string().optional(), subdivision: z.string().optional(), country: z.string(), postalCode: z.string().optional(), careOf: z.string().optional(), status: addressStatusEnum.optional(), unstructuredLongForm: z.string().optional()}); export const phoneNumberID = z.string(); export const phoneNumber = z.object({phoneNumberId: phoneNumberID.optional(), isPreferred: z.boolean().optional(), type: z.enum(["OTHER", "WORK", "HOME", "MOBILE", "BUSINESS", "FAX"]).optional(), sourceId: z.string().optional(), country: z.string().optional(), number: z.string().optional(), linkedAddresses: z.array(z.object({addressId: z.string().optional()})).optional(), unstructuredLongForm: z.string().optional()}); export const emailAddressID = z.string(); export const email = z.object({emailAddressId: emailAddressID.optional(), type: z.enum(["OTHER", "WORK", "PERSONAL", "BUSINESS"]).optional(), sourceId: z.string().optional(), email: z.string().optional(), isPreferred: z.boolean().optional(), linkedAddresses: z.array(z.object({addressId: z.string().optional()})).optional()}); export const attribute = z.object({type: z.string().max(64), value: z.string()}); export const customAttributes = z.record(z.string(), attribute); export const externalReference = z.object({referenceId: z.string().optional(), type: z.enum(["SYSTEM", "CUSTOMER", "OTHER"]).optional(), sourceId: z.string().optional(), name: z.string(), value: z.string(), description: z.string().optional()}); export const documentID = z.string(); export const documentType = z.enum(["OTHER", "DRIVERS_LICENSE", "PASSPORT", "VISA", "IMMIGRATION", "NATIONAL_ID", "TAX_ID", "NATIONAL_HEALTH_ID", "CONCESSION", "HEALTH_CONCESSION", "PENSION", "MILITARY_ID", "BIRTH_CERT", "CITIZENSHIP", "MARRIAGE_CERT", "DEATH_CERT", "NAME_CHANGE", "UTILITY_BILL", "BANK_STATEMENT", "BANK_ACCOUNT", "INTENT_PROOF", "ATTESTATION", "SELF_IMAGE", "DEVICE", "VEHICLE_REGISTRATION", "PROOF_OF_ADDRESS", "HOUSE_REGISTRATION", "YELLOW_HOUSE_REGISTRATION", "WORK_PERMIT", "EMPLOYMENT_CERTIFICATE", "NOTARY_PUBLIC_ID", "EXTERNAL_ADMIN", "CHARGES", "PRE_ASIC", "ANNUAL_RETURN", "REPORT", "TRUST_DEED", "PARTNERSHIP_AGREEMENT", "ADMIN_CHANGE", "COMPANY_REPORT", "CHECK_RESULTS", "AVIATION_SECURITY_ID", "MARITIME_SECURITY_ID"]); export const documentSupplementaryData = z.discriminatedUnion("type", [z.object({type: z.enum(["NATIONAL_HEALTH_ID", "BIRTH_CERT", "NATIONAL_ID", "CITIZENSHIP", "PASSPORT", "MARRIAGE_CERT"]), reference: z.string().optional(), nameOnCardLine1: z.string().optional(), nameOnCardLine2: z.string().optional(), nameOnCardLine3: z.string().optional(), nameOnCardLine4: z.string().optional(), middleNameOnCard: z.string().optional()}), z.object({type: z.enum(["NATIONAL_HEALTH_ID", "BIRTH_CERT", "NATIONAL_ID", "CITIZENSHIP", "PASSPORT", "MARRIAGE_CERT"]), registrationDate: z.string().optional(), registrationDistrict: z.string().optional(), dateOfPrint: z.string().optional(), givenName: z.string().optional(), otherNames: z.string().optional(), familyName: z.string().optional()}), z.object({type: z.enum(["NATIONAL_HEALTH_ID", "BIRTH_CERT", "NATIONAL_ID", "CITIZENSHIP", "PASSPORT", "MARRIAGE_CERT"]), homeCountryFullName: z.string().optional(), paternalFamilyName: z.string().optional(), maternalFamilyName: z.string().optional()}), z.object({type: z.enum(["NATIONAL_HEALTH_ID", "BIRTH_CERT", "NATIONAL_ID", "CITIZENSHIP", "PASSPORT", "MARRIAGE_CERT"]), acquisitionDate: z.string().optional(), primaryCountry: z.string().optional(), secondaryCountry: z.string().optional()}), z.object({type: z.enum(["NATIONAL_HEALTH_ID", "BIRTH_CERT", "NATIONAL_ID", "CITIZENSHIP", "PASSPORT", "MARRIAGE_CERT"]), homeCountryFullName: z.string().optional()}), z.object({type: z.enum(["NATIONAL_HEALTH_ID", "BIRTH_CERT", "NATIONAL_ID", "CITIZENSHIP", "PASSPORT", "MARRIAGE_CERT"]), partner1GivenName: z.string().optional(), partner1FamilyName: z.string().optional(), partner1OtherName: z.string().optional(), partner2GivenName: z.string().optional(), partner2FamilyName: z.string().optional(), partner2OtherName: z.string().optional(), registrationDate: z.string().optional(), marriageDate: z.string().optional(), dateOfPrint: z.string().optional()})]); export const documentAttachmentID = z.string(); export const documentAttachmentSide = z.enum(["FRONT", "BACK"]); export const documentAttachmentType = z.string(); export const dataURIBase64 = z.union([z.object({uri: z.string()}), z.object({base64: z.string()})]); export const documentAttachmentRetrievalStatus = z.enum(["NORMAL", "EXCLUDED", "FAILED"]); export const documentAttachment = z.object({attachmentId: documentAttachmentID.optional(), sourceId: z.string().optional(), createdAt: z.string().optional(), updatedAt: z.string().optional(), filename: z.string().optional(), mimeType: z.string().optional(), pageNumber: z.number().int().optional(), side: documentAttachmentSide.optional(), type: documentAttachmentType.optional(), location: z.string().optional(), data: dataURIBase64, lastMalwareScanAt: z.string().optional(), retrievalStatus: documentAttachmentRetrievalStatus.optional()}); export const documentInformation = z.object({documentId: documentID.optional(), entityId: entityID.optional(), expiryDate: date.optional(), issueDate: date.optional(), primaryIdentifier: z.string().optional(), secondaryIdentifier: z.string().optional(), type: documentType, subtype: z.string().optional(), subdivision: z.string().optional(), country: z.string().max(3), createdAt: z.string().optional(), updatedAt: z.string().optional(), validFrom: date.optional(), validTo: date.optional(), sourceId: z.string().optional(), supplementaryData: documentSupplementaryData.optional(), customAttributes: customAttributes.optional(), attachments: z.array(documentAttachment).optional()}); export const entityDocuments = z.object({REPORT: z.array(documentInformation).optional(), SUPPORTING: z.array(documentInformation).optional(), IDENTITY: z.array(documentInformation).optional(), OTHER: z.array(documentInformation).optional()}); export const individualName = z.object({nameId: z.string().optional(), language: z.string().optional(), givenName: z.string().optional(), middleName: z.string().optional(), familyName: z.string(), otherName: z.string().optional(), prefix: z.string().optional(), suffix: z.string().optional(), sourceId: z.string().optional(), displayName: z.string().optional()}); export const individualNameAlternate = z.object({nameId: z.string().optional(), language: z.string().optional(), givenName: z.string().optional(), middleName: z.string().optional(), familyName: z.string(), otherName: z.string().optional(), prefix: z.string().optional(), suffix: z.string().optional(), sourceId: z.string().optional(), displayName: z.string().optional(), type: z.enum(["OTHER", "ALIAS", "PREVIOUS"]).optional()}); export const dateOfBirth = z.object({dateOfBirthId: z.string().optional(), sourceId: z.string().optional(), year: z.string().optional(), month: z.string().optional(), day: z.string().optional(), unstructured: z.string().optional(), type: dateType.optional(), normalized: z.string().optional()}); export const dateOfBirthAlternate = z.object({dateOfBirthId: z.string().optional(), sourceId: z.string().optional(), year: z.string().optional(), month: z.string().optional(), day: z.string().optional(), unstructured: z.string().optional(), type: dateType.optional(), normalized: z.string().optional()}); export const genderEnum = z.enum(["MALE", "FEMALE", "NON_BINARY", "OTHER", "UNSPECIFIED"]); export const gender = z.object({genderId: z.string().optional(), gender: genderEnum.optional(), sourceId: z.string().optional()}); export const addressPlaceOfBirth = z.object({addressId: z.string().optional(), sourceId: z.string().optional(), longForm: z.string().optional(), unstructuredLongForm: z.string().optional(), unitNumber: z.string().optional(), buildingName: z.string().optional(), streetName: z.string().optional(), streetNumber: z.string().optional(), streetType: z.string().optional(), neighborhood: z.string().optional(), locality: z.string().optional(), district: z.string().optional(), subdivision: z.string().optional(), country: z.string(), postalCode: z.string().optional()}); export const consent = z.object({type: z.enum(["GENERAL", "DOCS", "CREDITHEADER", "UNDER18", "PAYROLL", "INSURANCE", "SUPERANNUATION"]).optional(), schemaVersion: z.number().int().optional(), sourceId: z.string().optional()}); export const informationSource = z.object({sourceId: z.string().optional(), type: z.string().optional(), source: z.string().optional(), description: z.string().optional(), provider: z.string().optional(), providerReference: z.string().optional(), createdAt: z.string().optional(), requestedAt: z.string().optional(), generatedAt: z.string().optional(), retrievedAt: z.string().optional(), updatedAt: z.string().optional(), isAuthoritative: z.boolean().optional(), isManual: z.boolean().optional()}); export const processResultID = z.string(); export const relationshipOrigin = z.object({entityId: entityID.optional(), entityType: entityType.optional(), processResultId: processResultID.optional(), createdAt: z.string().optional()}); export const relationship = z.object({entityId: entityID.optional(), entityType: entityType.optional(), origin: relationshipOrigin.optional()}); export const individualRelationships = z.object({duplicates: z.array(relationship).optional()}); export const individual = z.object({entityId: entityID.optional(), entityType: entityType.optional(), createdAt: z.string().optional(), schemaVersion: z.number().int().optional(), addresses: z.array(address).optional(), phoneNumbers: z.array(phoneNumber).optional(), emailAddresses: z.array(email).optional(), customAttributes: customAttributes.optional(), externalReferences: z.array(externalReference).optional(), documents: entityDocuments.optional(), sourceId: z.string().optional(), name: individualName.optional(), alternateNames: z.array(individualNameAlternate).optional(), dateOfBirth: dateOfBirth.optional(), alternateDatesOfBirth: z.array(dateOfBirthAlternate).optional(), gender: gender.optional(), placeOfBirth: addressPlaceOfBirth.optional(), nationality: z.string().optional(), consents: z.array(consent).optional(), informationSources: z.record(z.string(), informationSource).optional(), relationships: individualRelationships.optional()}); export const riskAssessmentID = z.string(); export const workflowExecutionStateEnum = z.enum(["COMPLETED", "CANCELED", "TERMINATED", "ERROR", "TIMEOUT", "IN_PROGRESS"]); export const workflowExecutionResultEnum = z.enum(["UNCHECKED", "IN_PROGRESS", "REVIEW", "PASS", "FAIL", "COMPLETE", "INCOMPLETE", "NEEDS_APPROVAL", "APPROVED", "REJECTED", "BLOCKED", "CLEAR", "URGENT", "MONITOR"]); export const profileID = z.string(); export const riskLevel = z.enum(["UNKNOWN", "LOW", "MEDIUM", "HIGH", "UNACCEPTABLE"]); export const riskFactorID = z.string(); export const riskFactorStatus = z.enum(["VALID", "STALE", "OVERRIDDEN", "DISCARDED"]); export const riskFactor = z.object({riskFactorId: riskFactorID.optional(), factor: z.string().optional(), value: z.string().optional(), score: z.number().optional(), description: z.string().optional(), workflowExecutionId: z.string().optional(), stepResultId: z.string().optional(), manualOverrideScore: z.number().optional(), status: riskFactorStatus.optional(), createdAt: z.string().optional(), updatedAt: z.string().optional(), updatedBy: z.string().optional(), updatedRequestId: z.string().optional(), createdServiceProfileId: z.string().optional(), createdWorkflowExecutionId: z.string().optional(), createdStepResultId: z.string().optional()}); export const riskAssessment = z.object({serviceProfileId: profileID, riskAssessmentId: riskAssessmentID.optional(), workflowId: z.string(), workflowExecutionId: z.string(), entityId: z.string(), schemaVersion: z.number().int().optional(), createdAt: z.string().optional(), updatedAt: z.string().optional(), updatedBy: z.string().optional(), updatedRequestId: z.string().optional(), workflowRiskScore: z.number().optional(), workflowRiskLevel: riskLevel.optional(), riskScore: z.number().optional(), riskLevel: riskLevel.optional(), isOutdated: z.boolean().optional(), riskFactors: z.array(riskFactor).optional()}); export const workflowExecutionSteps = z.object({order: z.array(z.string()).optional(), passed: z.array(z.string()).optional(), failed: z.array(z.string()).optional(), incomplete: z.array(z.string()).optional(), notApplicable: z.array(z.string()).optional()}); export const issueID = z.string(); export const workflowIssueCategory = z.enum(["AML", "BAD_DATA", "BIOMETRICS", "BLOCKLISTED", "DECEASED", "DEVICE", "DOCUMENT", "DUPLICATE", "EXPIRY", "FRAUD", "IDV", "INFORMATIONAL", "KYC", "SYSTEM", "VERIFY", "VISA", "WATCHLIST", "ACTIVITY"]); export const workflowIssueType = z.enum(["AML_ISSUE", "BAD_DATA_ADDRESS", "BAD_DATA_DOB", "BAD_DATA_EMAIL", "BAD_DATA_ID", "BAD_DATA_MOBILE", "BAD_DATA_NAME", "BLOCKED", "COMPROMISED_DOCUMENT", "CREDIT_HEADER", "DATA_COMPARISON", "DATA_CONSISTENCY", "DATA_VALIDATION", "DENY_LIST", "DECEASED", "DEVICE_FRAUD_MATCH", "DEVICE_INVALID", "DOCUMENT_COMPARISON", "DUPLICATE", "FRAUD_CHECK", "FRAUD_DEVICE", "FRAUD_IP_ADDRESS", "FRAUD_EMAIL_ADDRESS", "FRAUD_PHONE_NUMBER", "FRAUD_ISSUE", "FRAUD_LIST", "IMAGE_INTEGRITY", "INTERNAL_MATCH", "LIVENESS_DETECTION", "MATCHED_EXTERNAL", "MATCHED_INTERNAL", "MATCHED_SHARED", "MEDIA", "NOT_FOUND", "OCR", "PARTIAL", "PEP", "REQUIRES_AML", "REQUIRES_IDV", "REQUIRES_KYC", "REQUIRES_VISA", "SANCTION", "SERVICE_ERROR", "SERVICE_TIMEOUT", "VISA_FAILED", "VISUAL_AUTHENTICITY", "WATCHLIST", "ACTIVITY_AML", "ACTIVITY_FRAUD", "ACTIVITY_DEVICE"]); export const workflowIssueSeverity = z.enum(["INFO", "REVIEW", "BLOCK", "WARNING", "CRITICAL", "ERROR"]); export const workflowIssue = z.object({issueId: issueID.optional(), category: workflowIssueCategory, issue: workflowIssueType, workflowExecutionId: z.string().optional(), stepResultId: z.string().optional(), isCleared: z.boolean().optional(), createdBy: z.string().optional(), createdAt: z.string().optional(), updatedAt: z.string().optional(), updatedBy: z.string().optional(), updatedRequestId: z.string().optional(), severity: workflowIssueSeverity}); export const workflowLifecyclePhaseEnum = z.enum(["ONBOARDING", "MONITORING", "OTHER"]); export const monitoringType = z.enum(["AML", "ACTIVITY"]); export const workflowExecutionSummary = z.object({schemaVersion: z.number().int().optional(), workflowName: z.string().optional(), workflowExecutionId: z.string().optional(), workflowExecutionState: workflowExecutionStateEnum.optional(), status: workflowExecutionResultEnum.optional(), statusOverrideAt: z.string().optional(), statusOverrideRequestId: z.string().optional(), statusOverrideBy: z.string().optional(), riskAssessment: riskAssessment.optional(), isManual: z.boolean().optional(), steps: workflowExecutionSteps.optional(), startedAt: z.string().optional(), endedAt: z.string().optional(), issues: z.array(workflowIssue).optional(), lifecyclePhase: workflowLifecyclePhaseEnum.optional(), monitoringTypes: z.array(monitoringType).optional()}); export const subscriptionType = z.enum(["AML", "ACTIVITY"]); export const serviceProfileSubscription = z.object({serviceProfileId: z.string().optional(), status: z.enum(["ENABLED", "DISABLED"]).optional(), type: subscriptionType.optional(), workflowName: z.string().optional(), workflowId: z.string().optional(), enabledAt: z.string().optional(), enabledRequestId: z.string().optional(), enabledBy: z.string().optional(), disabledAt: z.string().optional(), disabledRequestId: z.string().optional(), disabledBy: z.string().optional()}); export const serviceProfileState = z.enum(["INIT", "AUTO", "ACTIVE", "ARCHIVED", "BLOCKLISTED", "INACTIVE", "DELETED", "DUPLICATE"]); export const serviceProfile = z.object({serviceProfileId: z.string().optional(), latestRiskAssessmentId: riskAssessmentID.optional(), latestWorkflowExecutionId: z.string().optional(), entityId: z.string().optional(), entityName: z.string().optional(), entityType: z.string().optional(), organizationType: z.string().optional(), country: z.string().optional(), schemaVersion: z.number().int().optional(), createdAt: z.string().optional(), createdRequestId: z.string().optional(), createdBy: z.string().optional(), updatedAt: z.string().optional(), updatedBy: z.string().optional(), updatedRequestId: z.string().optional(), assignee: z.string().optional(), reviewer: z.string().optional(), currentWorkflowId: z.string().optional(), currentWorkflowName: z.string().optional(), workflowSummaries: z.array(workflowExecutionSummary).optional(), serviceName: z.string().optional(), customerReference: z.string().optional(), subscriptions: z.array(serviceProfileSubscription).optional(), state: serviceProfileState.optional()}); export const requestID = z.string(); export const individualsEntityResponse = z.object({individual: individual.optional(), serviceProfiles: z.array(serviceProfile).optional(), requestId: requestID}); 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 }; /** * Create an individual entity * * POST /v2/individuals * * Also accepts auth: jwt */ export const createApiV2Individuals = async (args: CreateApiV2IndividualsArgs, options?: CreateApiV2IndividualsOptions) => { const {baseUrl = "https://api.uat.frankie.one", 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 (args.api_key != null) headers.set("api_key", String(args.api_key)) if (args['X-Frankie-CustomerID'] != null) headers.set("X-Frankie-CustomerID", String(args['X-Frankie-CustomerID'])) if (args['X-Frankie-CustomerChildID'] != null) headers.set("X-Frankie-CustomerChildID", String(args['X-Frankie-CustomerChildID'])) if (args['X-Frankie-Channel'] != null) headers.set("X-Frankie-Channel", String(args['X-Frankie-Channel'])) if (args['X-Frankie-Username'] != null) headers.set("X-Frankie-Username", String(args['X-Frankie-Username'])) if (ApiKey !== undefined) headers.set("api_key", ApiKey) const url = `${baseUrl.replace(/\/+$/, '')}/v2/individuals${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(individualsEntityResponse, await res.json()) };