Skip to content

Commit 15eb0ac

Browse files
authored
Merge branch 'main' into v1.6439.0
2 parents dc3f67e + d0db4ba commit 15eb0ac

File tree

410 files changed

+989
-124154
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

410 files changed

+989
-124154
lines changed

eslint.config.mjs

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export default [
2020
'packages/client/src/vendor/base64/index.js',
2121
'packages/configuration-loader/.eslintrc.cjs',
2222
'scripts/generatePackages.ts',
23+
'scripts/*.ts',
2324
],
2425
},
2526
{

lerna.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"packages": ["packages/*"],
2+
"packages": ["packages/*", "packages_generated/*"],
33
"npmClient": "pnpm",
44
"version": "independent",
55
"command": {

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111
},
1212
"type": "module",
1313
"scripts": {
14-
"generateIndex": "pnpm dlx tsx ./scripts/generatePackages.ts",
14+
"generateAlias": "pnpm dlx tsx ./scripts/generateAlias.ts",
15+
"generatePackages": "pnpm dlx tsx ./scripts/generatePackages.ts",
1516
"generateGlobalSdkPackage": "pnpm dlx tsx ./scripts/updateGlobalSdkPackage.ts",
16-
"prebuild": "pnpm run generateIndex && pnpm run generateGlobalSdkPackage && pnpm format",
17+
"prebuild": "pnpm run generatePackages && pnpm run generateAlias && pnpm format",
1718
"build": "pnpm turbo build",
1819
"typecheck": "pnpm turbo typecheck",
1920
"build:profile": "cross-env PROFILE=true pnpm run build",

packages/client/CHANGELOG.md

+13
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,19 @@
33
All notable changes to this project will be documented in this file.
44
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
55

6+
## [1.2.1](https://github.com/scaleway/scaleway-sdk-js/compare/@scaleway/[email protected]...@scaleway/[email protected]) (2025-04-24)
7+
8+
### Bug Fixes
9+
10+
- sdk client deps ([#2056](https://github.com/scaleway/scaleway-sdk-js/issues/2056)) ([82ee89e](https://github.com/scaleway/scaleway-sdk-js/commit/82ee89e9745fc52875d81fbd0a6e277e1b0f4fa8))
11+
12+
## 1.2.0 (2025-04-24)
13+
14+
### Features
15+
16+
- **client:** add pl-waw-3 zone, add headers, add sessionheader ([#2016](https://github.com/scaleway/scaleway-sdk-js/issues/2016)) ([332b58f](https://github.com/scaleway/scaleway-sdk-js/commit/332b58ff08798c661b323d32ac425c8e3ae0f203))
17+
- **marshalling:** add any marshalling ([#2054](https://github.com/scaleway/scaleway-sdk-js/issues/2054)) ([5cbcf99](https://github.com/scaleway/scaleway-sdk-js/commit/5cbcf99834dcb6293825ae96fc34cd2c4e012183))
18+
619
## [1.1.1](https://github.com/scaleway/scaleway-sdk-js/compare/@scaleway/[email protected]...@scaleway/[email protected]) (2025-03-31)
720

821
**Note:** Version bump only for package @scaleway/sdk-client

packages/client/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@scaleway/sdk-client",
3-
"version": "1.1.1",
3+
"version": "1.2.1",
44
"license": "Apache-2.0",
55
"description": "Scaleway SDK Client",
66
"keywords": [

packages/client/src/helpers/json.ts

+65
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,68 @@ export const isJSONObject = (obj: unknown): obj is JSONObject => {
4242
objT === 'object'
4343
)
4444
}
45+
46+
/**
47+
* Camelizes a string.
48+
*
49+
* @param str - The string to camelize
50+
* @returns The camelized string
51+
*
52+
* @internal
53+
*/
54+
export const camelize = (str: string): string => {
55+
const strLength = str.length
56+
if (strLength <= 0) {
57+
return str
58+
}
59+
let out = ''
60+
for (let capNext = false, index = 0; index < strLength; index += 1) {
61+
const char = str.charAt(index)
62+
if (char >= 'a' && char <= 'z') {
63+
if (capNext) {
64+
out += char.toUpperCase()
65+
} else {
66+
out += char
67+
}
68+
} else if (char >= 'A' && char <= 'Z') {
69+
out += char
70+
} else if (char >= '0' && char <= '9') {
71+
out += char
72+
}
73+
capNext = char === '_' || char === ' ' || char === '-' || char === '.'
74+
}
75+
76+
return out.charAt(0).toLowerCase() + out.substring(1)
77+
}
78+
79+
/**
80+
* Camelizes keys of an object (deeply).
81+
*
82+
* @param obj - The object
83+
* @param ignoreKeys - The keys to ignore
84+
* @returns The object with camelized keys
85+
*
86+
* @internal
87+
*/
88+
export const camelizeKeys = <T>(
89+
obj: object | unknown[] | unknown,
90+
ignoreKeys: string[] = [],
91+
): T => {
92+
if (Array.isArray(obj)) {
93+
return obj.map(v => camelizeKeys(v, ignoreKeys)) as unknown as T
94+
}
95+
96+
if (obj && typeof obj === 'object' && !(obj instanceof Date)) {
97+
return Object.entries(obj).reduce(
98+
(acc, [key, value]) => ({
99+
...acc,
100+
[camelize(key)]: ignoreKeys.includes(key)
101+
? (value as unknown)
102+
: camelizeKeys(value, ignoreKeys),
103+
}),
104+
{},
105+
) as T
106+
}
107+
108+
return obj as T
109+
}

packages/client/src/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ export {
2626
export type { ClientConfig } from './scw/client-ini-factory'
2727
export { Decimal } from './scw/custom-types'
2828
export type { Money, ScwFile, TimeSeries } from './scw/custom-types'
29-
3029
export * as Errors from './scw/errors/standard'
3130
export type { Region, Zone } from './scw/locality'
3231
export * from './internals'

packages/client/src/internals.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@ export { authenticateWithSessionToken } from './scw/auth'
1111

1212
export type { DefaultValues } from './scw/client-settings'
1313
export {
14+
marshalBlobToScwFile,
1415
marshalDecimal,
15-
marshalScwFile,
1616
marshalMoney,
17+
marshalScwFile,
1718
marshalTimeSeries,
18-
marshalBlobToScwFile,
19+
unmarshalAnyRes,
1920
unmarshalDecimal,
2021
unmarshalMoney,
2122
unmarshalScwFile,

packages/client/src/scw/custom-marshalling.ts

+59-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { isJSONObject } from '../helpers/json'
1+
import { camelizeKeys, isJSONObject } from '../helpers/json'
22
import { unmarshalArrayOfObject, unmarshalDate } from '../helpers/marshalling'
33
import { fromByteArray } from '../vendor/base64'
44
import type {
@@ -207,3 +207,61 @@ export const marshalTimeSeries = (
207207
export const marshalDecimal = (obj: Decimal): { value: string } => ({
208208
value: obj.toString(),
209209
})
210+
211+
/**
212+
* Unmarshals record to convert iso dates from string to Dates.
213+
*
214+
* @param obj - The input
215+
* @param keys - The keys requiring a conversion
216+
* @returns The updated input
217+
*
218+
* @internal
219+
*/
220+
export const unmarshalDates = <T>(obj: unknown, keys: string[]): T => {
221+
if (Array.isArray(obj)) {
222+
return obj.map(v => unmarshalDates(v, keys)) as unknown as T
223+
}
224+
225+
if (obj && typeof obj === 'object') {
226+
return Object.entries(obj).reduce(
227+
(acc, [key, value]) => ({
228+
...acc,
229+
[key]:
230+
typeof value === 'string' && keys.includes(key)
231+
? new Date(value)
232+
: unmarshalDates(value, keys),
233+
}),
234+
{},
235+
) as T
236+
}
237+
238+
return obj as T
239+
}
240+
241+
/**
242+
* Unmarshals input to a record with camilized keys and instanciated Date.
243+
*
244+
* @param obj - The input
245+
* @param ignoreKeys - The keys which should be not be transformed
246+
* @param dateKeys - The keys which should be transformed to Date
247+
* @returns The record
248+
*
249+
* @throws TypeError
250+
* Thrown if the input isn't {@link JSONObject}.
251+
*
252+
* @internal
253+
*/
254+
export const unmarshalAnyRes = <T>(
255+
obj: unknown,
256+
ignoreKeys: string[] = [],
257+
dateKeys?: string[],
258+
): T => {
259+
if (!isJSONObject(obj)) {
260+
throw new TypeError(`Data isn't a dictionary.`)
261+
}
262+
263+
return camelizeKeys(
264+
dateKeys && dateKeys.length > 0 ? unmarshalDates(obj, dateKeys) : obj,
265+
ignoreKeys,
266+
)
267+
}

packages/clients/.eslintrc.cjs

-10
This file was deleted.

packages/clients/.npmignore

-5
This file was deleted.

0 commit comments

Comments
 (0)