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
4 changes: 2 additions & 2 deletions .github/workflows/check-pull-request.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Check Pull Request
on:
pull_request:
types: ["opened", "edited", "reopened", "synchronize"]
types: ['opened', 'edited', 'reopened', 'synchronize']
merge_group:

jobs:
Expand All @@ -15,7 +15,7 @@ jobs:
with:
node-version: 20
check-latest: true
cache: "pnpm"
cache: 'pnpm'
- run: pnpm install
- name: Check title
run: |
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/deploy-doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
# Runs on tags
push:
tags:
- "**"
- '**'

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand All @@ -17,7 +17,7 @@ permissions:

# Allow one concurrent deployment
concurrency:
group: "pages"
group: 'pages'
cancel-in-progress: true

# Default to bash
Expand All @@ -41,7 +41,7 @@ jobs:
with:
node-version: 20
check-latest: true
cache: "pnpm"
cache: 'pnpm'
- name: Setup Pages
id: pages
uses: actions/configure-pages@v5
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/deploy-package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Deploy to NPM
on:
workflow_dispatch:
schedule:
- cron: "0 12 * * MON"
- cron: '0 12 * * MON'

jobs:
deploy:
Expand All @@ -12,7 +12,7 @@ jobs:
steps:
- uses: actions/checkout@v4.2.2
with:
fetch-depth: "0"
fetch-depth: '0'
persist-credentials: false
- run: git fetch --depth=1 origin +refs/tags/*:refs/tags/*
- name: Git Identity
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "Pull Request Labeler"
name: 'Pull Request Labeler'
on:
- pull_request_target

Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/run-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
with:
node-version: 20
check-latest: true
cache: "pnpm"
cache: 'pnpm'
- run: pnpm install
- run: pnpm run build
- run: pnpm tsc --noEmit
Expand All @@ -32,7 +32,7 @@ jobs:
with:
node-version: 20
check-latest: true
cache: "pnpm"
cache: 'pnpm'
- run: pnpm install
- run: pnpm run build
- run: pnpm run lint
Expand All @@ -44,8 +44,8 @@ jobs:
- node
- jsdom
node:
- "18"
- "20"
- '18'
- '20'
steps:
- uses: actions/checkout@v4.2.2
- uses: pnpm/action-setup@v4.0.0
Expand All @@ -54,7 +54,7 @@ jobs:
with:
node-version: ${{ matrix.node }}
check-latest: true
cache: "pnpm"
cache: 'pnpm'
- run: pnpm install
- run: pnpm run build
- run: pnpm run test:coverage --environment ${{ matrix.test-environment }}
Expand Down
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ This SDK enables you to interact with Scaleway APIs.
> The SDK works exclusively within a Node.js environment, as browser requests are limited by CORS restrictions.

**🔗  Important links:**
* [Reference documentation](https://scaleway.github.io/scaleway-sdk-js)
* [Example projects](./examples)
* [Developers website](https://developers.scaleway.com) (API documentation)

- [Reference documentation](https://scaleway.github.io/scaleway-sdk-js)
- [Example projects](./examples)
- [Developers website](https://developers.scaleway.com) (API documentation)

## Getting Started

Expand All @@ -33,8 +34,8 @@ const api = new Registry.v1.API(client)
**For a simpler setup**, you could retrieve the profile from either the configuration file or the environment variables:

```ts
import {
loadProfileFromConfigurationFile,
import {
loadProfileFromConfigurationFile,
// loadProfileFromEnvironmentValues,
} from '@scaleway/configuration-loader'

Expand All @@ -55,14 +56,16 @@ const namespaces = await api.listNamespaces(/*{ page: 1 }*/)
```

Retrieve **all the pages**:

```ts
const allNamespaces = await api.listNamespaces().all()
```

**Iterate** over the pages:

```ts
for await (const page of api.listNamespaces()) {
//
//
}
```

Expand Down
70 changes: 70 additions & 0 deletions biome.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"$schema": "./node_modules/@biomejs/biome/configuration_schema.json",
"organizeImports": {
"enabled": true
},
"linter": {
"enabled": false
},
"vcs": {
"clientKind": "git",
"useIgnoreFile": false,
"defaultBranch": "main"
},
"files": {
"ignore": [
".next/",
".pnpm-store/",
"coverage/",
"/public/outdated",
"/public/.well-known",
"**/node_modules/",
"**/storybook-static",
".turbo/**",
"dist",
"build",
"out",
"node_modules/**",
"**/pnpm-lock.yaml",
"**/package.json",
"**/CHANGELOG.md",
"*.snap",
"**/__snapshots__/",
".docusaurus",
".vitest-reports"
]
},
"formatter": {
"enabled": true,
"formatWithErrors": false,
"indentStyle": "space",
"indentWidth": 2,
"lineEnding": "lf",
"lineWidth": 80,
"attributePosition": "auto"
},
"javascript": {
"formatter": {
"jsxQuoteStyle": "double",
"quoteProperties": "asNeeded",
"trailingCommas": "all",
"semicolons": "asNeeded",
"arrowParentheses": "asNeeded",
"bracketSpacing": true,
"bracketSameLine": false,
"quoteStyle": "single",
"attributePosition": "auto"
}
},
"json": {
"formatter": {
"enabled": true
},
"parser": {
"allowComments": true
},
"linter": {
"enabled": true
}
}
}
24 changes: 12 additions & 12 deletions examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

## Project Templates

* [NodeJS](./nodejs-minimal)
* [Serverless Function](./serverless-function-minimal/)
- [NodeJS](./nodejs-minimal)
- [Serverless Function](./serverless-function-minimal/)

## Snippets

Expand Down Expand Up @@ -34,8 +34,8 @@ console.log(`\tCreated, ID=${server.id} ; State=${server.state}`)

// Power on the server.
console.log(`Powering on server...`)
server = await api.serverActionAndWait({
serverId: server.id,
server = await api.serverActionAndWait({
serverId: server.id,
action: 'poweron',
})
console.log(`\tPowered ON (now ${server.state})`)
Expand All @@ -52,21 +52,21 @@ const client = createClient(profile)
const api = new Instance.v1.API(client)

// List servers.
console.log(`Listing servers...`);
const servers = await api.listServers().then((res) => res.servers!);
console.log(`Listing servers...`)
const servers = await api.listServers().then(res => res.servers!)

// Check how many servers need a reboot.
const serversToReboot = servers.filter((obj) => obj.state === 'running');
console.log(`\t${serversToReboot.length}/${servers.length} will be rebooted`);
const serversToReboot = servers.filter(obj => obj.state === 'running')
console.log(`\t${serversToReboot.length}/${servers.length} will be rebooted`)

// Reboot all servers at once.
console.log(
`Rebooting servers ${serversToReboot.map((obj) => obj.id).join(', ')}...`
`Rebooting servers ${serversToReboot.map(obj => obj.id).join(', ')}...`,
)
const updatedServers = await Promise.allSettled(
serversToReboot.map((obj) =>
api.serverActionAndWait({ serverId: obj.id, action: 'reboot' })
)
serversToReboot.map(obj =>
api.serverActionAndWait({ serverId: obj.id, action: 'reboot' }),
),
)
for (const result of updatedServers) {
switch (result.status) {
Expand Down
6 changes: 4 additions & 2 deletions examples/serverless-function-minimal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ We assume that you have the dependency [serverless](https://www.serverless.com/)
## A. How to run

⚠️ **Important:** this example creates your Scaleway profile (required by the Javascript client) using environment variables: please rename `.env.template` to `.env` (git ignored) and update the variables.
* Note: by design, Serverless framework overrides environment variables already defined in your Scaleway account.

- Note: by design, Serverless framework overrides environment variables already defined in your Scaleway account.

**Steps:**

1. Install dependencies: `pnpm install`.
2. Build the project: `pnpm run build`.
3. Deploy in production: `SCW_DEFAULT_PROJECT_ID= SCW_SECRET_KEY= serverless deploy`
* Or just `serverless deploy` if you already defined `SCW_DEFAULT_PROJECT_ID` and `SCW_SECRET_KEY` in your bash profile.

- Or just `serverless deploy` if you already defined `SCW_DEFAULT_PROJECT_ID` and `SCW_SECRET_KEY` in your bash profile.
18 changes: 12 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
"build:profile": "cross-env PROFILE=true pnpm run build",
"commit": "npx git-cz -a",
"doc": "typedoc",
"format": "prettier --write '**/*.ts'",
"format": "biome check --linter-enabled=false --write .",
"format:check": "biome check --linter-enabled=false --verbose .",
"prettier": "prettier --write '**/*.{md,mdx,yml,yaml}'",
"lint": "eslint --cache .",
"prepare": "husky",
"test": "vitest run",
Expand All @@ -23,14 +25,17 @@
},
"lint-staged": {
"*.ts": [
"prettier --write",
"pnpm run format",
"eslint --fix ."
],
"*.yaml": [
"prettier --write"
],
"*.json": [
"prettier --write"
"pnpm run format"
],
"*.y?(a)ml": [
"prettier --write '**/*.{yml,yaml}'"
],
".md?(x)": [
"prettier --write '**/*.{md,mdx}'"
]
},
"config": {
Expand Down Expand Up @@ -74,6 +79,7 @@
"packageManager": "pnpm@9.4.0",
"dependencies": {
"@scaleway/random-name": "5.1.1",
"biome": "^0.3.3",
"react": "^19.0.0"
}
}
7 changes: 4 additions & 3 deletions packages/client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
This SDK Client enables you to interact with Scaleway APIs.

**🔗  Important links:**
* [Reference documentation](https://scaleway.github.io/scaleway-sdk-js)
* [Example projects](https://github.com/scaleway/scaleway-sdk-js/tree/master/examples)
* [Developers website](https://developers.scaleway.com) (API documentation)

- [Reference documentation](https://scaleway.github.io/scaleway-sdk-js)
- [Example projects](https://github.com/scaleway/scaleway-sdk-js/tree/master/examples)
- [Developers website](https://developers.scaleway.com) (API documentation)

## Getting Started

Expand Down
11 changes: 6 additions & 5 deletions packages/clients/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
This SDK enables you to interact with Scaleway APIs.

**🔗  Important links:**
* [Reference documentation](https://scaleway.github.io/scaleway-sdk-js)
* [Example projects](https://github.com/scaleway/scaleway-sdk-js/tree/master/examples)
* [Developers website](https://developers.scaleway.com) (API documentation)

- [Reference documentation](https://scaleway.github.io/scaleway-sdk-js)
- [Example projects](https://github.com/scaleway/scaleway-sdk-js/tree/master/examples)
- [Developers website](https://developers.scaleway.com) (API documentation)

## Getting Started

Expand All @@ -30,8 +31,8 @@ const api = new Registry.v1.API(client)
**For a simpler setup**, you could retrieve the profile from either the configuration file or the environment variables:

```ts
import {
loadProfileFromConfigurationFile,
import {
loadProfileFromConfigurationFile,
// loadProfileFromEnvironmentValues,
} from '@scaleway/configuration-loader'

Expand Down
Loading
Loading