Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions packages/clients/src/api/tem/v1alpha1/api.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,21 @@ import {
marshalCreateEmailRequest,
unmarshalCreateEmailResponse,
unmarshalDomain,
unmarshalDomainLastStatus,
unmarshalEmail,
unmarshalListDomainsResponse,
unmarshalListEmailsResponse,
unmarshalStatistics,
} from './marshalling.gen'
import type {
CancelEmailRequest,
CheckDomainLastStatusRequest,
CheckDomainRequest,
CreateDomainRequest,
CreateEmailRequest,
CreateEmailResponse,
Domain,
DomainLastStatus,
Email,
GetDomainRequest,
GetEmailRequest,
Expand Down Expand Up @@ -339,4 +342,29 @@ export class API extends ParentAPI {
},
unmarshalDomain,
)

/**
* Display SPF and DKIM records status and potential errors. Display SPF and
* DKIM records status and potential errors, including the found records to
* make debugging easier.
*
* @param request - The request {@link CheckDomainLastStatusRequest}
* @returns A Promise of DomainLastStatus
*/
checkDomainLastStatus = (request: Readonly<CheckDomainLastStatusRequest>) =>
this.client.fetch<DomainLastStatus>(
{
body: '{}',
headers: jsonContentHeaders,
method: 'POST',
path: `/transactional-email/v1alpha1/regions/${validatePathParam(
'region',
request.region ?? this.client.settings.defaultRegion,
)}/domains/${validatePathParam(
'domainId',
request.domainId,
)}/verification`,
},
unmarshalDomainLastStatus,
)
}
5 changes: 5 additions & 0 deletions packages/clients/src/api/tem/v1alpha1/index.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,18 @@ export { API } from './api.gen'
export * from './content.gen'
export type {
CancelEmailRequest,
CheckDomainLastStatusRequest,
CheckDomainRequest,
CreateDomainRequest,
CreateEmailRequest,
CreateEmailRequestAddress,
CreateEmailRequestAttachment,
CreateEmailResponse,
Domain,
DomainLastStatus,
DomainLastStatusDkimRecord,
DomainLastStatusRecordStatus,
DomainLastStatusSpfRecord,
DomainStatistics,
DomainStatus,
Email,
Expand Down
50 changes: 50 additions & 0 deletions packages/clients/src/api/tem/v1alpha1/marshalling.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ import type {
CreateEmailRequestAttachment,
CreateEmailResponse,
Domain,
DomainLastStatus,
DomainLastStatusDkimRecord,
DomainLastStatusSpfRecord,
DomainStatistics,
Email,
EmailTry,
Expand Down Expand Up @@ -78,6 +81,34 @@ export const unmarshalDomain = (data: unknown) => {
} as Domain
}

const unmarshalDomainLastStatusDkimRecord = (data: unknown) => {
if (!isJSONObject(data)) {
throw new TypeError(
`Unmarshalling the type 'DomainLastStatusDkimRecord' failed as data isn't a dictionary.`,
)
}

return {
error: data.error,
lastValidAt: unmarshalDate(data.last_valid_at),
status: data.status,
} as DomainLastStatusDkimRecord
}

const unmarshalDomainLastStatusSpfRecord = (data: unknown) => {
if (!isJSONObject(data)) {
throw new TypeError(
`Unmarshalling the type 'DomainLastStatusSpfRecord' failed as data isn't a dictionary.`,
)
}

return {
error: data.error,
lastValidAt: unmarshalDate(data.last_valid_at),
status: data.status,
} as DomainLastStatusSpfRecord
}

export const unmarshalEmail = (data: unknown) => {
if (!isJSONObject(data)) {
throw new TypeError(
Expand Down Expand Up @@ -115,6 +146,25 @@ export const unmarshalCreateEmailResponse = (data: unknown) => {
} as CreateEmailResponse
}

export const unmarshalDomainLastStatus = (data: unknown) => {
if (!isJSONObject(data)) {
throw new TypeError(
`Unmarshalling the type 'DomainLastStatus' failed as data isn't a dictionary.`,
)
}

return {
dkimRecord: data.dkim_record
? unmarshalDomainLastStatusDkimRecord(data.dkim_record)
: undefined,
domainId: data.domain_id,
domainName: data.domain_name,
spfRecord: data.spf_record
? unmarshalDomainLastStatusSpfRecord(data.spf_record)
: undefined,
} as DomainLastStatus
}

export const unmarshalListDomainsResponse = (data: unknown) => {
if (!isJSONObject(data)) {
throw new TypeError(
Expand Down
57 changes: 51 additions & 6 deletions packages/clients/src/api/tem/v1alpha1/types.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@
// If you have any remark or suggestion do not hesitate to open an issue.
import type { Region } from '../../../bridge'

export type DomainLastStatusRecordStatus =
| 'unknown_record_status'
| 'valid'
| 'invalid'
| 'not_found'

export type DomainStatus =
| 'unknown'
| 'checked'
Expand Down Expand Up @@ -79,7 +85,7 @@ export interface Domain {
lastValidAt?: Date
/** Date and time of the domain's deletion. */
revokedAt?: Date
/** Error message returned if the last check failed. */
/** @deprecated Error message returned if the last check failed. */
lastError?: string
/** Snippet of the SPF record to register in the DNS zone. */
spfConfig: string
Expand All @@ -90,6 +96,38 @@ export interface Domain {
region: Region
}

/** Domain last status. */
export interface DomainLastStatus {
/** The id of the domain. */
domainId: string
/** The domain name (example.com). */
domainName: string
/** The SPF record verification data. */
spfRecord?: DomainLastStatusSpfRecord
/** The DKIM record verification data. */
dkimRecord?: DomainLastStatusDkimRecord
}

/** Domain last status. dkim record. */
export interface DomainLastStatusDkimRecord {
/** Status of the DKIM record's configurartion. */
status: DomainLastStatusRecordStatus
/** Time and date the DKIM record was last valid. */
lastValidAt?: Date
/** An error text displays in case the record is not valid. */
error?: string
}

/** Domain last status. spf record. */
export interface DomainLastStatusSpfRecord {
/** Status of the SPF record's configurartion. */
status: DomainLastStatusRecordStatus
/** Time and date the SPF record was last valid. */
lastValidAt?: Date
/** An error text displays in case the record is not valid. */
error?: string
}

export interface DomainStatistics {
totalCount: number
sentCount: number
Expand All @@ -107,7 +145,7 @@ export interface Email {
projectId: string
/** Email address of the sender. */
mailFrom: string
/** @deprecated (Deprecated) Email address of the recipient. */
/** @deprecated Email address of the recipient. */
rcptTo?: string
/** Email address of the recipient. */
mailRcpt: string
Expand Down Expand Up @@ -251,10 +289,7 @@ export type ListEmailsRequest = {
until?: Date
/** (Optional) List emails sent with this sender's email address. */
mailFrom?: string
/**
* @deprecated (Deprecated) List emails sent to this recipient's email
* address.
*/
/** @deprecated List emails sent to this recipient's email address. */
mailTo?: string
/** (Optional) List emails sent to this recipient's email address. */
mailRcpt?: string
Expand Down Expand Up @@ -358,3 +393,13 @@ export type CheckDomainRequest = {
/** ID of the domain to check. */
domainId: string
}

export type CheckDomainLastStatusRequest = {
/**
* Region to target. If none is passed will use default region from the
* config.
*/
region?: Region
/** ID of the domain to delete. */
domainId: string
}