Skip to content

Commit

Permalink
Merge branch 'main' into v1.6066.0
Browse files Browse the repository at this point in the history
  • Loading branch information
yfodil authored Feb 4, 2025
2 parents 494d560 + 5215582 commit 8610f6d
Show file tree
Hide file tree
Showing 7 changed files with 2,300 additions and 5,466 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
"cross-fetch": "4.1.0",
"cz-conventional-changelog": "3.3.0",
"esbuild-plugin-browserslist": "0.15.0",
"eslint": "9.18.0",
"eslint": "9.19.0",
"eslint-plugin-tsdoc": "0.4.0",
"husky": "9.1.7",
"jsdom": "25.0.1",
Expand Down
82 changes: 79 additions & 3 deletions packages/clients/src/api/webhosting/v1/api.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,10 @@ import {
waitForResource,
} from '../../../bridge'
import type { Region as ScwRegion, WaitForOptions } from '../../../bridge'
import { HOSTING_TRANSIENT_STATUSES } from './content.gen'
import {
DOMAIN_TRANSIENT_STATUSES,
HOSTING_TRANSIENT_STATUSES,
} from './content.gen'
import {
marshalDatabaseApiAssignDatabaseUserRequest,
marshalDatabaseApiChangeDatabaseUserPasswordRequest,
Expand All @@ -28,6 +31,7 @@ import {
unmarshalDatabase,
unmarshalDatabaseUser,
unmarshalDnsRecords,
unmarshalDomain,
unmarshalFtpAccount,
unmarshalHosting,
unmarshalListControlPanelsResponse,
Expand All @@ -41,6 +45,7 @@ import {
unmarshalMailAccount,
unmarshalResetHostingPasswordResponse,
unmarshalResourceSummary,
unmarshalSearchDomainsResponse,
unmarshalSession,
} from './marshalling.gen'
import type {
Expand All @@ -61,8 +66,11 @@ import type {
DatabaseUser,
DnsApiCheckUserOwnsDomainRequest,
DnsApiGetDomainDnsRecordsRequest,
DnsApiGetDomainRequest,
DnsApiSearchDomainsRequest,
DnsApiSyncDomainDnsRecordsRequest,
DnsRecords,
Domain,
FtpAccount,
FtpAccountApiChangeFtpAccountPasswordRequest,
FtpAccountApiCreateFtpAccountRequest,
Expand Down Expand Up @@ -93,6 +101,7 @@ import type {
OfferApiListOffersRequest,
ResetHostingPasswordResponse,
ResourceSummary,
SearchDomainsResponse,
Session,
WebsiteApiListWebsitesRequest,
} from './types.gen'
Expand Down Expand Up @@ -427,7 +436,8 @@ export class DnsAPI extends ParentAPI {
)

/**
* "Check whether you own this domain or not.".
* Check whether you own this domain or not.. Check whether you own this
* domain or not.
*
* @param request - The request {@link DnsApiCheckUserOwnsDomainRequest}
* @returns A Promise of CheckUserOwnsDomainResponse
Expand All @@ -449,7 +459,8 @@ export class DnsAPI extends ParentAPI {
)

/**
* "Synchronize your DNS records on the Elements Console and on cPanel.".
* Synchronize your DNS records on the Elements Console and on cPanel..
* Synchronize your DNS records on the Elements Console and on cPanel.
*
* @param request - The request {@link DnsApiSyncDomainDnsRecordsRequest}
* @returns A Promise of DnsRecords
Expand All @@ -471,6 +482,71 @@ export class DnsAPI extends ParentAPI {
},
unmarshalDnsRecords,
)

/**
* Search for available domains based on domain name.. Search for available
* domains based on domain name.
*
* @param request - The request {@link DnsApiSearchDomainsRequest}
* @returns A Promise of SearchDomainsResponse
*/
searchDomains = (request: Readonly<DnsApiSearchDomainsRequest>) =>
this.client.fetch<SearchDomainsResponse>(
{
method: 'GET',
path: `/webhosting/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/search-domains`,
urlParams: urlParams(
['domain_name', request.domainName],
[
'project_id',
request.projectId ?? this.client.settings.defaultProjectId,
],
),
},
unmarshalSearchDomainsResponse,
)

/**
* Retrieve detailed information about a specific domain, including its
* status, DNS configuration, and ownership.. Retrieve detailed information
* about a specific domain, including its status, DNS configuration, and
* ownership.
*
* @param request - The request {@link DnsApiGetDomainRequest}
* @returns A Promise of Domain
*/
getDomain = (request: Readonly<DnsApiGetDomainRequest>) =>
this.client.fetch<Domain>(
{
method: 'GET',
path: `/webhosting/v1/regions/${validatePathParam('region', request.region ?? this.client.settings.defaultRegion)}/domains/${validatePathParam('domainName', request.domainName)}`,
urlParams: urlParams([
'project_id',
request.projectId ?? this.client.settings.defaultProjectId,
]),
},
unmarshalDomain,
)

/**
* Waits for {@link Domain} to be in a final state.
*
* @param request - The request {@link DnsApiGetDomainRequest}
* @param options - The waiting options
* @returns A Promise of Domain
*/
waitForDomain = (
request: Readonly<DnsApiGetDomainRequest>,
options?: Readonly<WaitForOptions<Domain>>,
) =>
waitForResource(
options?.stop ??
(res =>
Promise.resolve(!DOMAIN_TRANSIENT_STATUSES.includes(res.status))),
this.getDomain,
request,
options,
)
}

/**
Expand Down
14 changes: 13 additions & 1 deletion packages/clients/src/api/webhosting/v1/content.gen.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
// This file was automatically generated. DO NOT EDIT.
// If you have any remark or suggestion do not hesitate to open an issue.
import type { HostingStatus, HostingSummaryStatus } from './types.gen'
import type {
DomainAvailabilityStatus,
DomainStatus,
HostingStatus,
HostingSummaryStatus,
} from './types.gen'

/** Lists transient statutes of the enum {@link DomainAvailabilityStatus}. */
export const DOMAIN_AVAILABILITY_TRANSIENT_STATUSES: DomainAvailabilityStatus[] =
['validating']

/** Lists transient statutes of the enum {@link DomainStatus}. */
export const DOMAIN_TRANSIENT_STATUSES: DomainStatus[] = ['validating']

/** Lists transient statutes of the enum {@link HostingStatus}. */
export const HOSTING_TRANSIENT_STATUSES: HostingStatus[] = [
Expand Down
54 changes: 54 additions & 0 deletions packages/clients/src/api/webhosting/v1/marshalling.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ import type {
DnsApiSyncDomainDnsRecordsRequest,
DnsRecord,
DnsRecords,
Domain,
DomainAvailability,
FtpAccount,
FtpAccountApiChangeFtpAccountPasswordRequest,
FtpAccountApiCreateFtpAccountRequest,
Expand Down Expand Up @@ -53,6 +55,7 @@ import type {
PlatformControlPanelUrls,
ResetHostingPasswordResponse,
ResourceSummary,
SearchDomainsResponse,
Session,
SyncDomainDnsRecordsRequestRecord,
Website,
Expand Down Expand Up @@ -170,6 +173,22 @@ export const unmarshalDnsRecords = (data: unknown): DnsRecords => {
} as DnsRecords
}

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

return {
availableActions: data.available_actions,
availableDnsActions: data.available_dns_actions,
name: data.name,
owner: data.owner,
status: data.status,
} as Domain
}

const unmarshalPlatformControlPanelUrls = (
data: unknown,
): PlatformControlPanelUrls => {
Expand Down Expand Up @@ -500,6 +519,40 @@ export const unmarshalResourceSummary = (data: unknown): ResourceSummary => {
} as ResourceSummary
}

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

return {
availableActions: data.available_actions,
canCreateHosting: data.can_create_hosting,
name: data.name,
price: data.price ? unmarshalMoney(data.price) : undefined,
status: data.status,
zoneName: data.zone_name,
} as DomainAvailability
}

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

return {
domainsAvailable: unmarshalArrayOfObject(
data.domains_available,
unmarshalDomainAvailability,
),
} as SearchDomainsResponse
}

export const unmarshalSession = (data: unknown): Session => {
if (!isJSONObject(data)) {
throw new TypeError(
Expand Down Expand Up @@ -593,6 +646,7 @@ export const marshalDnsApiSyncDomainDnsRecordsRequest = (
: undefined,
update_all_records: request.updateAllRecords,
update_mail_records: request.updateMailRecords,
update_nameservers: request.updateNameservers,
update_web_records: request.updateWebRecords,
})

Expand Down
Loading

0 comments on commit 8610f6d

Please sign in to comment.