Skip to content

Commit 8d34b86

Browse files
authored
Merge branch 'main' into v1.7110.0
2 parents 5bbae40 + c8c424e commit 8d34b86

File tree

4 files changed

+58
-21
lines changed

4 files changed

+58
-21
lines changed

packages/sdk/src/index.gen.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import { Interlinkv1beta1 } from '@scaleway/sdk-interlink'
2626
import { Iotv1 } from '@scaleway/sdk-iot'
2727
import { Ipamv1 } from '@scaleway/sdk-ipam'
2828
import { Jobsv1alpha1 } from '@scaleway/sdk-jobs'
29-
import { K8sv1 } from '@scaleway/sdk-k8s'
29+
import { K8Sv1 } from '@scaleway/sdk-k8s'
3030
import { KeyManagerv1alpha1 } from '@scaleway/sdk-key-manager'
3131
import { Lbv1 } from '@scaleway/sdk-lb'
3232
import { Marketplacev2 } from '@scaleway/sdk-marketplace'
@@ -37,7 +37,7 @@ import { Qaasv1alpha1 } from '@scaleway/sdk-qaas'
3737
import { Rdbv1 } from '@scaleway/sdk-rdb'
3838
import { Redisv1 } from '@scaleway/sdk-redis'
3939
import { Registryv1 } from '@scaleway/sdk-registry'
40-
import { S2sVpnv1alpha1 } from '@scaleway/sdk-s2s-vpn'
40+
import { S2SVpnv1alpha1 } from '@scaleway/sdk-s2s-vpn'
4141
import { Secretv1beta1 } from '@scaleway/sdk-secret'
4242
import { ServerlessSqldbv1alpha1 } from '@scaleway/sdk-serverless-sqldb'
4343
import { Temv1alpha1 } from '@scaleway/sdk-tem'
@@ -246,9 +246,9 @@ export const Jobs = {
246246
/**
247247
* @deprecated Direct version exports are deprecated. Use the 'K8s' namespace instead (e.g., K8s.v1).
248248
*/
249-
export { K8sv1 }
249+
export { K8Sv1 }
250250
export const K8s = {
251-
v1: K8sv1,
251+
v1: K8Sv1,
252252
}
253253

254254
/**
@@ -335,9 +335,9 @@ export const Registry = {
335335
/**
336336
* @deprecated Direct version exports are deprecated. Use the 'S2sVpn' namespace instead (e.g., S2sVpn.v1).
337337
*/
338-
export { S2sVpnv1alpha1 }
338+
export { S2SVpnv1alpha1 }
339339
export const S2sVpn = {
340-
v1alpha1: S2sVpnv1alpha1,
340+
v1alpha1: S2SVpnv1alpha1,
341341
}
342342

343343
/**

packages_generated/webhosting/src/v1/marshalling.gen.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,7 @@ const unmarshalOffer = (data: unknown): Offer => {
418418
options: unmarshalArrayOfObject(data.options, unmarshalOfferOption),
419419
price: data.price ? unmarshalMoney(data.price) : undefined,
420420
quotaWarning: data.quota_warning,
421+
region: data.region,
421422
} as Offer
422423
}
423424

packages_generated/webhosting/src/v1/types.gen.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,10 @@ export interface Offer {
420420
* Defines a warning if the maximum value for an option in the offer is exceeded.
421421
*/
422422
quotaWarning: OfferOptionWarning
423+
/**
424+
* Region where the offer is hosted.
425+
*/
426+
region: ScwRegion
423427
}
424428

425429
export interface Platform {

scripts/generateAlias.ts

Lines changed: 47 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
import { appendFileSync, readdirSync, statSync, writeFileSync } from 'node:fs'
1+
import {
2+
appendFileSync,
3+
readdirSync,
4+
readFileSync,
5+
statSync,
6+
writeFileSync,
7+
} from 'node:fs'
28
import { join } from 'node:path'
39

410
const GENERATED_PATH = 'packages_generated'
@@ -12,6 +18,28 @@ const toPascal = (s: string) =>
1218

1319
const toSlug = (s: string) => s.replace(/_/g, '-')
1420

21+
/**
22+
* Extract real export names from package's index.gen.ts
23+
* This ensures we use the exact same names as exported by the package
24+
*/
25+
const getExportsFromPackage = (packagePath: string): string[] => {
26+
const indexPath = join(packagePath, 'src', 'index.gen.ts')
27+
try {
28+
const content = readFileSync(indexPath, 'utf8')
29+
const exportPattern = /export \* as (\w+) from/g
30+
const exports: string[] = []
31+
let match
32+
33+
while ((match = exportPattern.exec(content)) !== null) {
34+
exports.push(match[1])
35+
}
36+
37+
return exports
38+
} catch (err: unknown) {
39+
throw new Error(`Error reading exports from ${indexPath}: ${err.message}`)
40+
}
41+
}
42+
1543
const services = readdirSync(GENERATED_PATH).filter(folder => {
1644
const fullPath = join(GENERATED_PATH, folder)
1745

@@ -29,34 +57,38 @@ let importsOutput = ''
2957
for (const service of services) {
3058
const slug = toSlug(service)
3159
const pascal = toPascal(service)
32-
const srcPath = join(GENERATED_PATH, service, 'src')
60+
const packagePath = join(GENERATED_PATH, service)
3361

34-
let versions: string[] = []
62+
// Get real exports from the package
63+
let exportedNames: string[] = []
3564
try {
36-
versions = readdirSync(srcPath).filter(vFolder => {
37-
const vPath = join(srcPath, vFolder)
38-
39-
return statSync(vPath).isDirectory() && /^v[0-9a-z]+$/i.test(vFolder)
40-
})
65+
exportedNames = getExportsFromPackage(packagePath)
4166
} catch (err: unknown) {
4267
throw new Error(
43-
`Error: missing or unreadable 'src' folder for package '${service}': ${err.message}`,
68+
`Error getting exports for package '${service}': ${err.message}`,
4469
)
4570
}
4671

4772
writeFileSync(OUTPUT_PATH, AUTO_GENERATE_MESSAGE)
4873

49-
if (versions.length > 0) {
74+
if (exportedNames.length > 0) {
5075
const imports: string[] = []
5176
const versionsImport: string[] = []
5277
const mappings: string[] = []
5378

54-
for (const version of versions) {
55-
const importName = `${pascal}${version}`
56-
versionsImport.push(`${importName}`)
57-
mappings.push(` ${version}: ${importName},`)
79+
for (const exportName of exportedNames) {
80+
// Extract version from export name (e.g., K8Sv1 -> v1, S2SVpnv1alpha1 -> v1alpha1)
81+
// Version must start with lowercase 'v' followed by digits
82+
const versionMatch = exportName.match(/(v\d+[a-z]*\d*)$/)
83+
if (versionMatch) {
84+
const version = versionMatch[1]
85+
versionsImport.push(exportName)
86+
mappings.push(` ${version}: ${exportName},`)
87+
}
5888
}
59-
imports.push(`import { ${versionsImport} } from '@scaleway/sdk-${slug}'`)
89+
imports.push(
90+
`import { ${versionsImport.join(', ')} } from '@scaleway/sdk-${slug}'`,
91+
)
6092

6193
importsOutput += `${imports.join('\n')}\n`
6294
const importedNames = imports

0 commit comments

Comments
 (0)