@scaleway/sdk-test 1.1.0 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,96 @@
1
+ # @scaleway/sdk-test
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@scaleway/sdk-test.svg)](https://www.npmjs.com/package/@scaleway/sdk-test)
4
+ [![npm downloads](https://img.shields.io/npm/dm/@scaleway/sdk-test.svg)](https://www.npmjs.com/package/@scaleway/sdk-test)
5
+ [![license](https://img.shields.io/npm/l/@scaleway/sdk-test.svg)](https://github.com/scaleway/scaleway-sdk-js/blob/master/LICENSE)
6
+
7
+ Scaleway SDK for Test API.
8
+
9
+ > **Note**
10
+ > This is an automatically generated package that is part of the [Scaleway SDK for JavaScript](https://github.com/scaleway/scaleway-sdk-js).
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ npm install @scaleway/sdk-test @scaleway/sdk-client
16
+ ```
17
+
18
+ or with pnpm:
19
+
20
+ ```bash
21
+ pnpm add @scaleway/sdk-test @scaleway/sdk-client
22
+ ```
23
+
24
+ or with yarn:
25
+
26
+ ```bash
27
+ yarn add @scaleway/sdk-test @scaleway/sdk-client
28
+ ```
29
+
30
+ ## Getting Started
31
+
32
+ You'll need a pair of access and secret keys to connect to Scaleway API. Please check the [documentation](https://www.scaleway.com/en/docs/identity-and-access-management/iam/how-to/create-api-keys/) on how to retrieve them.
33
+
34
+ ### Basic Usage
35
+
36
+ ```typescript
37
+ import { createClient } from '@scaleway/sdk-client'
38
+ import { Test } from '@scaleway/sdk-test'
39
+
40
+ const client = createClient({
41
+ accessKey: 'SCWXXXXXXXXXXXXXXXXX',
42
+ secretKey: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
43
+ defaultProjectId: 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
44
+ defaultRegion: 'fr-par',
45
+ defaultZone: 'fr-par-1',
46
+ })
47
+
48
+ const api = new Test.v1.API(client)
49
+
50
+ // Use the API
51
+ // Example: await api.listServers()
52
+ ```
53
+
54
+ ### Using Configuration Loader
55
+
56
+ For a simpler setup, you can load credentials from the configuration file or environment variables:
57
+
58
+ ```typescript
59
+ import { createClient } from '@scaleway/sdk-client'
60
+ import { loadProfileFromConfigurationFile } from '@scaleway/configuration-loader'
61
+ import { Test } from '@scaleway/sdk-test'
62
+
63
+ const profile = loadProfileFromConfigurationFile()
64
+ const client = createClient(profile)
65
+ const api = new Test.v1.API(client)
66
+ ```
67
+
68
+ ## Documentation
69
+
70
+ - 📚 [Scaleway SDK Reference Documentation](https://scaleway.github.io/scaleway-sdk-js)
71
+ - 🌐 [Scaleway Test API Documentation](https://www.scaleway.com/en/developers/api/test/)
72
+ - 📖 [Main Repository](https://github.com/scaleway/scaleway-sdk-js)
73
+ - 💡 [Example Projects](https://github.com/scaleway/scaleway-sdk-js/tree/master/examples)
74
+
75
+ ## Features
76
+
77
+ - ✅ Full TypeScript support with complete type definitions
78
+ - ✅ Promise-based API
79
+ - ✅ Automatic pagination helpers
80
+ - ✅ Built-in error handling
81
+ - ✅ Compatible with Node.js ≥ 20
82
+
83
+ ## Support
84
+
85
+ We love feedback! Feel free to reach us on:
86
+ - [Scaleway Slack community](https://slack.scaleway.com/) - Join us on [#opensource](https://scaleway-community.slack.com/app_redirect?channel=opensource)
87
+ - [GitHub Issues](https://github.com/scaleway/scaleway-sdk-js/issues)
88
+
89
+ ## Contributing
90
+
91
+ This repository is at its early stage and is still in active development. If you are looking for a way to contribute, please read [CONTRIBUTING.md](https://github.com/scaleway/scaleway-sdk-js/blob/master/CONTRIBUTING.md).
92
+
93
+ ## License
94
+
95
+ This project is Apache 2.0 licensed. See the [LICENSE](https://github.com/scaleway/scaleway-sdk-js/blob/master/LICENSE) file for details.
96
+
@@ -1,5 +1,5 @@
1
- import { API as ParentAPI } from '@scaleway/sdk-client';
2
1
  import type { WaitForOptions } from '@scaleway/sdk-client';
2
+ import { API as ParentAPI } from '@scaleway/sdk-client';
3
3
  import type { CreateHumanRequest, DeleteHumanRequest, GetHumanRequest, Human, ListHumansRequest, ListHumansResponse, RegisterRequest, RegisterResponse, RunHumanRequest, SmokeHumanRequest, UpdateHumanRequest } from './types.gen.js';
4
4
  /**
5
5
  * Fake API.
@@ -32,10 +32,7 @@ class API extends API$1 {
32
32
  ["order_by", request.orderBy],
33
33
  ["organization_id", request.organizationId],
34
34
  ["page", request.page],
35
- [
36
- "page_size",
37
- request.pageSize ?? this.client.settings.defaultPageSize
38
- ],
35
+ ["page_size", request.pageSize ?? this.client.settings.defaultPageSize],
39
36
  ["project_id", request.projectId]
40
37
  )
41
38
  },
@@ -1,4 +1,6 @@
1
- const HUMAN_TRANSIENT_STATUSES = ["running"];
1
+ const HUMAN_TRANSIENT_STATUSES = [
2
+ "running"
3
+ ];
2
4
  export {
3
5
  HUMAN_TRANSIENT_STATUSES
4
6
  };
@@ -1,4 +1,4 @@
1
- export { API } from './api.gen.js';
1
+ export { API, } from './api.gen.js';
2
2
  export * from './content.gen.js';
3
3
  export * from './marshalling.gen.js';
4
4
  export type { CreateHumanRequest, DeleteHumanRequest, EyeColors, GetHumanRequest, Human, HumanStatus, ListHumansRequest, ListHumansRequestOrderBy, ListHumansResponse, RegisterRequest, RegisterResponse, RunHumanRequest, SmokeHumanRequest, UpdateHumanRequest, } from './types.gen.js';
package/package.json CHANGED
@@ -1,23 +1,20 @@
1
1
  {
2
2
  "name": "@scaleway/sdk-test",
3
- "version": "1.1.0",
3
+ "version": "2.1.1",
4
4
  "description": "Scaleway SDK test",
5
5
  "license": "Apache-2.0",
6
6
  "files": [
7
+ "README.md",
7
8
  "dist"
8
9
  ],
9
10
  "type": "module",
10
11
  "exports": {
11
12
  ".": {
12
13
  "types": "./dist/index.gen.d.ts",
13
- "import": "./dist/index.gen.js",
14
- "require": "./dist/index.gen.cjs",
15
14
  "default": "./dist/index.gen.js"
16
15
  },
17
16
  "./*": {
18
17
  "types": "./dist/*/index.gen.d.ts",
19
- "import": "./dist/*/index.gen.js",
20
- "require": "./dist/*/index.gen.cjs",
21
18
  "default": "./dist/*/index.gen.js"
22
19
  }
23
20
  },
@@ -26,17 +23,17 @@
26
23
  "directory": "packages_generated/test"
27
24
  },
28
25
  "engines": {
29
- "node": ">=20.19.4"
26
+ "node": ">=20.19.6"
30
27
  },
31
28
  "dependencies": {
32
29
  "@scaleway/random-name": "5.1.2",
33
- "@scaleway/sdk-std": "1.1.0"
30
+ "@scaleway/sdk-std": "2.1.0"
34
31
  },
35
32
  "peerDependencies": {
36
- "@scaleway/sdk-client": "^1.3.2"
33
+ "@scaleway/sdk-client": "^2.1.0"
37
34
  },
38
35
  "devDependencies": {
39
- "@scaleway/sdk-client": "^1.3.2"
36
+ "@scaleway/sdk-client": "^2.1.0"
40
37
  },
41
38
  "scripts": {
42
39
  "package:check": "pnpm publint",
@@ -1,4 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const index_gen = require("./v1/index.gen.cjs");
4
- exports.Testv1 = index_gen;
@@ -1,158 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const sdkClient = require("@scaleway/sdk-client");
4
- const content_gen = require("./content.gen.cjs");
5
- const marshalling_gen = require("./marshalling.gen.cjs");
6
- const jsonContentHeaders = {
7
- "Content-Type": "application/json; charset=utf-8"
8
- };
9
- class API extends sdkClient.API {
10
- /**
11
- * Register a user. Register a human and return a access-key and a secret-key that must be used in all other commands.
12
-
13
- Hint: you can use other test commands by setting the SCW_SECRET_KEY env variable.
14
- *
15
- * @param request - The request {@link RegisterRequest}
16
- * @returns A Promise of RegisterResponse
17
- */
18
- register = (request) => this.client.fetch(
19
- {
20
- body: JSON.stringify(
21
- marshalling_gen.marshalRegisterRequest(request, this.client.settings)
22
- ),
23
- headers: jsonContentHeaders,
24
- method: "POST",
25
- path: `/test/v1/register`
26
- },
27
- marshalling_gen.unmarshalRegisterResponse
28
- );
29
- pageOfListHumans = (request = {}) => this.client.fetch(
30
- {
31
- method: "GET",
32
- path: `/test/v1/humans`,
33
- urlParams: sdkClient.urlParams(
34
- ["order_by", request.orderBy],
35
- ["organization_id", request.organizationId],
36
- ["page", request.page],
37
- [
38
- "page_size",
39
- request.pageSize ?? this.client.settings.defaultPageSize
40
- ],
41
- ["project_id", request.projectId]
42
- )
43
- },
44
- marshalling_gen.unmarshalListHumansResponse
45
- );
46
- /**
47
- * List all your humans.
48
- *
49
- * @param request - The request {@link ListHumansRequest}
50
- * @returns A Promise of ListHumansResponse
51
- */
52
- listHumans = (request = {}) => sdkClient.enrichForPagination("humans", this.pageOfListHumans, request);
53
- /**
54
- * Get human details. Get the human details associated with the given id.
55
- *
56
- * @param request - The request {@link GetHumanRequest}
57
- * @returns A Promise of Human
58
- */
59
- getHuman = (request) => this.client.fetch(
60
- {
61
- method: "GET",
62
- path: `/test/v1/humans/${sdkClient.validatePathParam("humanId", request.humanId)}`
63
- },
64
- marshalling_gen.unmarshalHuman
65
- );
66
- /**
67
- * Waits for {@link Human} to be in a final state.
68
- *
69
- * @param request - The request {@link GetHumanRequest}
70
- * @param options - The waiting options
71
- * @returns A Promise of Human
72
- */
73
- waitForHuman = (request, options) => sdkClient.waitForResource(
74
- options?.stop ?? ((res) => Promise.resolve(!content_gen.HUMAN_TRANSIENT_STATUSES.includes(res.status))),
75
- this.getHuman,
76
- request,
77
- options
78
- );
79
- /**
80
- * Create a new human.
81
- *
82
- * @param request - The request {@link CreateHumanRequest}
83
- * @returns A Promise of Human
84
- */
85
- createHuman = (request) => this.client.fetch(
86
- {
87
- body: JSON.stringify(
88
- marshalling_gen.marshalCreateHumanRequest(request, this.client.settings)
89
- ),
90
- headers: jsonContentHeaders,
91
- method: "POST",
92
- path: `/test/v1/humans`
93
- },
94
- marshalling_gen.unmarshalHuman
95
- );
96
- /**
97
- * Update an existing human. Update the human associated with the given id.
98
- *
99
- * @param request - The request {@link UpdateHumanRequest}
100
- * @returns A Promise of Human
101
- */
102
- updateHuman = (request) => this.client.fetch(
103
- {
104
- body: JSON.stringify(
105
- marshalling_gen.marshalUpdateHumanRequest(request, this.client.settings)
106
- ),
107
- headers: jsonContentHeaders,
108
- method: "PATCH",
109
- path: `/test/v1/humans/${sdkClient.validatePathParam("humanId", request.humanId)}`
110
- },
111
- marshalling_gen.unmarshalHuman
112
- );
113
- /**
114
- * Delete an existing human. Delete the human associated with the given id.
115
- *
116
- * @param request - The request {@link DeleteHumanRequest}
117
- * @returns A Promise of Human
118
- */
119
- deleteHuman = (request) => this.client.fetch(
120
- {
121
- method: "DELETE",
122
- path: `/test/v1/humans/${sdkClient.validatePathParam("humanId", request.humanId)}`
123
- },
124
- marshalling_gen.unmarshalHuman
125
- );
126
- /**
127
- * Start a 1h running for the given human. Start a one hour running for the given human.
128
- *
129
- * @param request - The request {@link RunHumanRequest}
130
- * @returns A Promise of Human
131
- */
132
- runHuman = (request) => this.client.fetch(
133
- {
134
- body: "{}",
135
- headers: jsonContentHeaders,
136
- method: "POST",
137
- path: `/test/v1/humans/${sdkClient.validatePathParam("humanId", request.humanId)}/run`
138
- },
139
- marshalling_gen.unmarshalHuman
140
- );
141
- /**
142
- * Make a human smoke.
143
- *
144
- * @deprecated
145
- * @param request - The request {@link SmokeHumanRequest}
146
- * @returns A Promise of Human
147
- */
148
- smokeHuman = (request) => this.client.fetch(
149
- {
150
- body: "{}",
151
- headers: jsonContentHeaders,
152
- method: "POST",
153
- path: `/test/v1/humans/${sdkClient.validatePathParam("humanId", request.humanId)}/smoke`
154
- },
155
- marshalling_gen.unmarshalHuman
156
- );
157
- }
158
- exports.API = API;
@@ -1,4 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const HUMAN_TRANSIENT_STATUSES = ["running"];
4
- exports.HUMAN_TRANSIENT_STATUSES = HUMAN_TRANSIENT_STATUSES;
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const api_gen = require("./api.gen.cjs");
4
- const content_gen = require("./content.gen.cjs");
5
- const marshalling_gen = require("./marshalling.gen.cjs");
6
- exports.API = api_gen.API;
7
- exports.HUMAN_TRANSIENT_STATUSES = content_gen.HUMAN_TRANSIENT_STATUSES;
8
- exports.marshalCreateHumanRequest = marshalling_gen.marshalCreateHumanRequest;
9
- exports.marshalRegisterRequest = marshalling_gen.marshalRegisterRequest;
10
- exports.marshalUpdateHumanRequest = marshalling_gen.marshalUpdateHumanRequest;
11
- exports.unmarshalHuman = marshalling_gen.unmarshalHuman;
12
- exports.unmarshalListHumansResponse = marshalling_gen.unmarshalListHumansResponse;
13
- exports.unmarshalRegisterResponse = marshalling_gen.unmarshalRegisterResponse;
@@ -1,92 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const sdkClient = require("@scaleway/sdk-client");
4
- const unmarshalHuman = (data) => {
5
- if (!sdkClient.isJSONObject(data)) {
6
- throw new TypeError(
7
- `Unmarshalling the type 'Human' failed as data isn't a dictionary.`
8
- );
9
- }
10
- return {
11
- altitudeInMeter: data.altitude_in_meter,
12
- altitudeInMillimeter: data.altitude_in_millimeter,
13
- createdAt: sdkClient.unmarshalDate(data.created_at),
14
- eyesColor: data.eyes_color,
15
- fingersCount: data.fingers_count,
16
- hairCount: data.hair_count,
17
- height: data.height,
18
- id: data.id,
19
- isHappy: data.is_happy,
20
- name: data.name,
21
- organizationId: data.organization_id,
22
- projectId: data.project_id,
23
- shoeSize: data.shoe_size,
24
- status: data.status,
25
- updatedAt: sdkClient.unmarshalDate(data.updated_at)
26
- };
27
- };
28
- const unmarshalListHumansResponse = (data) => {
29
- if (!sdkClient.isJSONObject(data)) {
30
- throw new TypeError(
31
- `Unmarshalling the type 'ListHumansResponse' failed as data isn't a dictionary.`
32
- );
33
- }
34
- return {
35
- humans: sdkClient.unmarshalArrayOfObject(data.humans, unmarshalHuman),
36
- totalCount: data.total_count
37
- };
38
- };
39
- const unmarshalRegisterResponse = (data) => {
40
- if (!sdkClient.isJSONObject(data)) {
41
- throw new TypeError(
42
- `Unmarshalling the type 'RegisterResponse' failed as data isn't a dictionary.`
43
- );
44
- }
45
- return {
46
- accessKey: data.access_key,
47
- secretKey: data.secret_key
48
- };
49
- };
50
- const marshalCreateHumanRequest = (request, defaults) => ({
51
- altitude_in_meter: request.altitudeInMeter,
52
- altitude_in_millimeter: request.altitudeInMillimeter,
53
- eyes_color: request.eyesColor,
54
- fingers_count: request.fingersCount,
55
- hair_count: request.hairCount,
56
- height: request.height,
57
- is_happy: request.isHappy,
58
- name: request.name,
59
- shoe_size: request.shoeSize,
60
- ...sdkClient.resolveOneOf([
61
- {
62
- default: defaults.defaultProjectId,
63
- param: "project_id",
64
- value: request.projectId
65
- },
66
- {
67
- default: defaults.defaultOrganizationId,
68
- param: "organization_id",
69
- value: request.organizationId
70
- }
71
- ])
72
- });
73
- const marshalRegisterRequest = (request, defaults) => ({
74
- username: request.username
75
- });
76
- const marshalUpdateHumanRequest = (request, defaults) => ({
77
- altitude_in_meter: request.altitudeInMeter,
78
- altitude_in_millimeter: request.altitudeInMillimeter,
79
- eyes_color: request.eyesColor,
80
- fingers_count: request.fingersCount,
81
- hair_count: request.hairCount,
82
- height: request.height,
83
- is_happy: request.isHappy,
84
- name: request.name,
85
- shoe_size: request.shoeSize
86
- });
87
- exports.marshalCreateHumanRequest = marshalCreateHumanRequest;
88
- exports.marshalRegisterRequest = marshalRegisterRequest;
89
- exports.marshalUpdateHumanRequest = marshalUpdateHumanRequest;
90
- exports.unmarshalHuman = unmarshalHuman;
91
- exports.unmarshalListHumansResponse = unmarshalListHumansResponse;
92
- exports.unmarshalRegisterResponse = unmarshalRegisterResponse;