@scaleway/sdk-search 1.1.0

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-search
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@scaleway/sdk-search.svg)](https://www.npmjs.com/package/@scaleway/sdk-search)
4
+ [![npm downloads](https://img.shields.io/npm/dm/@scaleway/sdk-search.svg)](https://www.npmjs.com/package/@scaleway/sdk-search)
5
+ [![license](https://img.shields.io/npm/l/@scaleway/sdk-search.svg)](https://github.com/scaleway/scaleway-sdk-js/blob/master/LICENSE)
6
+
7
+ Scaleway SDK for Search 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-search @scaleway/sdk-client
16
+ ```
17
+
18
+ or with pnpm:
19
+
20
+ ```bash
21
+ pnpm add @scaleway/sdk-search @scaleway/sdk-client
22
+ ```
23
+
24
+ or with yarn:
25
+
26
+ ```bash
27
+ yarn add @scaleway/sdk-search @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 { Search } from '@scaleway/sdk-search'
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 Search.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 { Search } from '@scaleway/sdk-search'
62
+
63
+ const profile = loadProfileFromConfigurationFile()
64
+ const client = createClient(profile)
65
+ const api = new Search.v1.API(client)
66
+ ```
67
+
68
+ ## Documentation
69
+
70
+ - 📚 [Scaleway SDK Reference Documentation](https://scaleway.github.io/scaleway-sdk-js)
71
+ - 🌐 [Scaleway Search API Documentation](https://www.scaleway.com/en/developers/api/search/)
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
+
87
+ - [Scaleway Slack community](https://slack.scaleway.com/) - Join us on [#opensource](https://scaleway-community.slack.com/app_redirect?channel=opensource)
88
+ - [GitHub Issues](https://github.com/scaleway/scaleway-sdk-js/issues)
89
+
90
+ ## Contributing
91
+
92
+ 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).
93
+
94
+ ## License
95
+
96
+ This project is Apache 2.0 licensed. See the [LICENSE](https://github.com/scaleway/scaleway-sdk-js/blob/master/LICENSE) file for details.
@@ -0,0 +1,3 @@
1
+ # Licenses
2
+
3
+ The app does not bundle any dependencies with licenses.
@@ -0,0 +1,13 @@
1
+ //#region \0rolldown/runtime.js
2
+ var __defProp = Object.defineProperty;
3
+ var __exportAll = (all, no_symbols) => {
4
+ let target = {};
5
+ for (var name in all) __defProp(target, name, {
6
+ get: all[name],
7
+ enumerable: true
8
+ });
9
+ if (!no_symbols) __defProp(target, Symbol.toStringTag, { value: "Module" });
10
+ return target;
11
+ };
12
+ //#endregion
13
+ export { __exportAll };
@@ -0,0 +1,5 @@
1
+ /**
2
+ * This file is automatically generated
3
+ * PLEASE DO NOT EDIT HERE
4
+ */
5
+ export * as Searchv1alpha1 from './v1alpha1/index.gen.js';
@@ -0,0 +1,2 @@
1
+ import { index_gen_exports } from "./v1alpha1/index.gen.js";
2
+ export { index_gen_exports as Searchv1alpha1 };
@@ -0,0 +1,14 @@
1
+ import { API as ParentAPI } from '@scaleway/sdk-client';
2
+ import type { SearchResourcesRequest, SearchResourcesResponse } from './types.gen.js';
3
+ /**
4
+ * Search API.
5
+ */
6
+ export declare class API extends ParentAPI {
7
+ /**
8
+ * Search API.
9
+ *
10
+ * @param request - The request {@link SearchResourcesRequest}
11
+ * @returns A Promise of SearchResourcesResponse
12
+ */
13
+ searchResources: (request: Readonly<SearchResourcesRequest>) => Promise<SearchResourcesResponse>;
14
+ }
@@ -0,0 +1,18 @@
1
+ import { unmarshalSearchResourcesResponse } from "./marshalling.gen.js";
2
+ import { API as API$1, urlParams } from "@scaleway/sdk-client";
3
+ //#region src/v1alpha1/api.gen.ts
4
+ /**
5
+ * Search API.
6
+ */
7
+ var API = class extends API$1 {
8
+ constructor(..._args) {
9
+ super(..._args);
10
+ this.searchResources = (request) => this.client.fetch({
11
+ method: "GET",
12
+ path: `/search/v1alpha1/resources`,
13
+ urlParams: urlParams(["organization_id", request.organizationId ?? this.client.settings.defaultOrganizationId], ["query", request.query])
14
+ }, unmarshalSearchResourcesResponse);
15
+ }
16
+ };
17
+ //#endregion
18
+ export { API };
@@ -0,0 +1,4 @@
1
+ export { API, } from './api.gen.js';
2
+ export * from './marshalling.gen.js';
3
+ export type { BrmServerInfo, Resource, ResourceType, SearchResourcesRequest, SearchResourcesResponse, ServerlessContainersContainerInfo, ServerlessFunctionsFunctionInfo, ServerlessSqldbBackupInfo, VpcPrivateNetworkInfo, } from './types.gen.js';
4
+ export * as ValidationRules from './validation-rules.gen.js';
@@ -0,0 +1,12 @@
1
+ import { __exportAll } from "../_virtual/_rolldown/runtime.js";
2
+ import { unmarshalSearchResourcesResponse } from "./marshalling.gen.js";
3
+ import { API } from "./api.gen.js";
4
+ import { validation_rules_gen_exports } from "./validation-rules.gen.js";
5
+ //#region src/v1alpha1/index.gen.ts
6
+ var index_gen_exports = /* @__PURE__ */ __exportAll({
7
+ API: () => API,
8
+ ValidationRules: () => validation_rules_gen_exports,
9
+ unmarshalSearchResourcesResponse: () => unmarshalSearchResourcesResponse
10
+ });
11
+ //#endregion
12
+ export { API, validation_rules_gen_exports as ValidationRules, index_gen_exports, unmarshalSearchResourcesResponse };
@@ -0,0 +1,2 @@
1
+ import type { SearchResourcesResponse } from './types.gen.js';
2
+ export declare const unmarshalSearchResourcesResponse: (data: unknown) => SearchResourcesResponse;
@@ -0,0 +1,46 @@
1
+ import { isJSONObject, unmarshalArrayOfObject } from "@scaleway/sdk-client";
2
+ //#region src/v1alpha1/marshalling.gen.ts
3
+ const unmarshalBrmServerInfo = (data) => {
4
+ if (!isJSONObject(data)) throw new TypeError(`Unmarshalling the type 'BrmServerInfo' failed as data isn't a dictionary.`);
5
+ return { ip: data.ip };
6
+ };
7
+ const unmarshalServerlessContainersContainerInfo = (data) => {
8
+ if (!isJSONObject(data)) throw new TypeError(`Unmarshalling the type 'ServerlessContainersContainerInfo' failed as data isn't a dictionary.`);
9
+ return { namespaceId: data.namespace_id };
10
+ };
11
+ const unmarshalServerlessFunctionsFunctionInfo = (data) => {
12
+ if (!isJSONObject(data)) throw new TypeError(`Unmarshalling the type 'ServerlessFunctionsFunctionInfo' failed as data isn't a dictionary.`);
13
+ return { namespaceId: data.namespace_id };
14
+ };
15
+ const unmarshalServerlessSqldbBackupInfo = (data) => {
16
+ if (!isJSONObject(data)) throw new TypeError(`Unmarshalling the type 'ServerlessSqldbBackupInfo' failed as data isn't a dictionary.`);
17
+ return { databaseId: data.database_id };
18
+ };
19
+ const unmarshalVpcPrivateNetworkInfo = (data) => {
20
+ if (!isJSONObject(data)) throw new TypeError(`Unmarshalling the type 'VpcPrivateNetworkInfo' failed as data isn't a dictionary.`);
21
+ return { vpcId: data.vpc_id };
22
+ };
23
+ const unmarshalResource = (data) => {
24
+ if (!isJSONObject(data)) throw new TypeError(`Unmarshalling the type 'Resource' failed as data isn't a dictionary.`);
25
+ return {
26
+ baremetalServerInfo: data.baremetal_server_info ? unmarshalBrmServerInfo(data.baremetal_server_info) : void 0,
27
+ global: data.global,
28
+ id: data.id,
29
+ name: data.name,
30
+ organizationId: data.organization_id,
31
+ projectId: data.project_id,
32
+ region: data.region,
33
+ serverlessContainersContainerInfo: data.serverless_containers_container_info ? unmarshalServerlessContainersContainerInfo(data.serverless_containers_container_info) : void 0,
34
+ serverlessFunctionsFunctionInfo: data.serverless_functions_function_info ? unmarshalServerlessFunctionsFunctionInfo(data.serverless_functions_function_info) : void 0,
35
+ serverlessSqldbBackupInfo: data.serverless_sqldb_backup_info ? unmarshalServerlessSqldbBackupInfo(data.serverless_sqldb_backup_info) : void 0,
36
+ type: data.type,
37
+ vpcPrivateNetworkInfo: data.vpc_private_network_info ? unmarshalVpcPrivateNetworkInfo(data.vpc_private_network_info) : void 0,
38
+ zone: data.zone
39
+ };
40
+ };
41
+ const unmarshalSearchResourcesResponse = (data) => {
42
+ if (!isJSONObject(data)) throw new TypeError(`Unmarshalling the type 'SearchResourcesResponse' failed as data isn't a dictionary.`);
43
+ return { resources: unmarshalArrayOfObject(data.resources, unmarshalResource) };
44
+ };
45
+ //#endregion
46
+ export { unmarshalSearchResourcesResponse };
@@ -0,0 +1,19 @@
1
+ export declare const queriesMetadata: {
2
+ readonly namespace: 'search';
3
+ readonly version: 'v1alpha1';
4
+ readonly folderName: 'searchv1alpha1';
5
+ readonly services: readonly [{
6
+ readonly apiClass: 'API';
7
+ readonly methods: readonly [{
8
+ readonly methodName: 'searchResources';
9
+ readonly protoName: 'SearchResources';
10
+ readonly paramsType: 'SearchResourcesRequest';
11
+ readonly returnType: 'SearchResourcesResponse';
12
+ readonly isList: false;
13
+ readonly paginationType: 'none';
14
+ readonly isPrivate: false;
15
+ readonly description: '"';
16
+ }];
17
+ }];
18
+ };
19
+ export type QueriesMetadata = typeof queriesMetadata;
@@ -0,0 +1,21 @@
1
+ //#region src/v1alpha1/metadata.gen.ts
2
+ const queriesMetadata = {
3
+ namespace: "search",
4
+ version: "v1alpha1",
5
+ folderName: "searchv1alpha1",
6
+ services: [{
7
+ apiClass: "API",
8
+ methods: [{
9
+ methodName: "searchResources",
10
+ protoName: "SearchResources",
11
+ paramsType: "SearchResourcesRequest",
12
+ returnType: "SearchResourcesResponse",
13
+ isList: false,
14
+ paginationType: "none",
15
+ isPrivate: false,
16
+ description: "\""
17
+ }]
18
+ }]
19
+ };
20
+ //#endregion
21
+ export { queriesMetadata };
@@ -0,0 +1,110 @@
1
+ import type { Region as ScwRegion, Zone as ScwZone } from '@scaleway/sdk-client';
2
+ export type ResourceType = 'unknown_type' | 'instance_server' | 'instance_volume' | 'instance_image' | 'instance_security_group' | 'k8s_cluster' | 'k8s_pool' | 'k8s_node' | 'domain_domain' | 'dns_zone' | 'vpc_private_network' | 'vpc_vpc' | 'vpg_gateway' | 'apple_silicon_server' | 'rdb_instance' | 'rdb_snapshot' | 'rdb_backup' | 'baremetal_server' | 'tem_domain' | 'lb_server' | 'serverless_functions_function' | 'serverless_containers_container' | 'wbh_hosting' | 'redis_cluster' | 'sm_secret' | 'kms_key' | 'edg_pipeline' | 'mnq_nats_account' | 'sbs_volume' | 'sbs_snapshot' | 'serverless_job_definition' | 'serverless_sqldb_database' | 'serverless_sqldb_backup' | 'ddl_datalab' | 'mgdb_instance' | 'mgdb_snapshot' | 'ifr_deployment' | 'ifr_model' | 'gapi_batch' | 'dtwh_deployment' | 'obs_datasource' | 'obs_token' | 'obs_alert' | 'svpn_vpn_gateway' | 'svpn_customer_gateway' | 'svpn_connection' | 'svpn_routing_policy';
3
+ export interface BrmServerInfo {
4
+ ip: string;
5
+ }
6
+ export interface ServerlessContainersContainerInfo {
7
+ /**
8
+ * ID of the Namespace the Serverless Container belongs to.
9
+ */
10
+ namespaceId: string;
11
+ }
12
+ export interface ServerlessFunctionsFunctionInfo {
13
+ /**
14
+ * ID of the Namespace the Serverless Function belongs to.
15
+ */
16
+ namespaceId: string;
17
+ }
18
+ export interface ServerlessSqldbBackupInfo {
19
+ databaseId: string;
20
+ }
21
+ export interface VpcPrivateNetworkInfo {
22
+ /**
23
+ * ID of the VPC the Private Network belongs to.
24
+ */
25
+ vpcId: string;
26
+ }
27
+ export interface Resource {
28
+ /**
29
+ * ID of the resource.
30
+ */
31
+ id: string;
32
+ /**
33
+ * Name of the resource.
34
+ */
35
+ name?: string;
36
+ /**
37
+ * ID of the Project the resource belongs to.
38
+ */
39
+ projectId?: string;
40
+ /**
41
+ * ID of the Organization the resource belongs to.
42
+ */
43
+ organizationId: string;
44
+ /**
45
+ * Type of the resource.
46
+ */
47
+ type: ResourceType;
48
+ /**
49
+ * Locality the resource is in if this is a global resource.
50
+ *
51
+ * One-of ('locality'): at most one of 'global', 'zone', 'region' could be set.
52
+ */
53
+ global?: boolean;
54
+ /**
55
+ * Locality the resource is in if this is a zonal resource.
56
+ *
57
+ * One-of ('locality'): at most one of 'global', 'zone', 'region' could be set.
58
+ */
59
+ zone?: ScwZone;
60
+ /**
61
+ * Locality the resource is in if this is a regional resource.
62
+ *
63
+ * One-of ('locality'): at most one of 'global', 'zone', 'region' could be set.
64
+ */
65
+ region?: ScwRegion;
66
+ /**
67
+ * Additional information for a VPC Private Network.
68
+ *
69
+ * One-of ('info'): at most one of 'vpcPrivateNetworkInfo', 'serverlessFunctionsFunctionInfo', 'serverlessContainersContainerInfo', 'baremetalServerInfo', 'serverlessSqldbBackupInfo' could be set.
70
+ */
71
+ vpcPrivateNetworkInfo?: VpcPrivateNetworkInfo;
72
+ /**
73
+ * Additional information for a Serverless Function.
74
+ *
75
+ * One-of ('info'): at most one of 'vpcPrivateNetworkInfo', 'serverlessFunctionsFunctionInfo', 'serverlessContainersContainerInfo', 'baremetalServerInfo', 'serverlessSqldbBackupInfo' could be set.
76
+ */
77
+ serverlessFunctionsFunctionInfo?: ServerlessFunctionsFunctionInfo;
78
+ /**
79
+ * Additional information for a Serverless Container.
80
+ *
81
+ * One-of ('info'): at most one of 'vpcPrivateNetworkInfo', 'serverlessFunctionsFunctionInfo', 'serverlessContainersContainerInfo', 'baremetalServerInfo', 'serverlessSqldbBackupInfo' could be set.
82
+ */
83
+ serverlessContainersContainerInfo?: ServerlessContainersContainerInfo;
84
+ /**
85
+ *
86
+ * One-of ('info'): at most one of 'vpcPrivateNetworkInfo', 'serverlessFunctionsFunctionInfo', 'serverlessContainersContainerInfo', 'baremetalServerInfo', 'serverlessSqldbBackupInfo' could be set.
87
+ */
88
+ baremetalServerInfo?: BrmServerInfo;
89
+ /**
90
+ *
91
+ * One-of ('info'): at most one of 'vpcPrivateNetworkInfo', 'serverlessFunctionsFunctionInfo', 'serverlessContainersContainerInfo', 'baremetalServerInfo', 'serverlessSqldbBackupInfo' could be set.
92
+ */
93
+ serverlessSqldbBackupInfo?: ServerlessSqldbBackupInfo;
94
+ }
95
+ export type SearchResourcesRequest = {
96
+ /**
97
+ * Search query.
98
+ */
99
+ query: string;
100
+ /**
101
+ * ID of the Organization to search in.
102
+ */
103
+ organizationId?: string;
104
+ };
105
+ export interface SearchResourcesResponse {
106
+ /**
107
+ * Top resources found.
108
+ */
109
+ resources: Resource[];
110
+ }
File without changes
@@ -0,0 +1,6 @@
1
+ export declare const SearchResourcesRequest: {
2
+ query: {
3
+ maxLength: number;
4
+ minLength: number;
5
+ };
6
+ };
@@ -0,0 +1,9 @@
1
+ import { __exportAll } from "../_virtual/_rolldown/runtime.js";
2
+ //#region src/v1alpha1/validation-rules.gen.ts
3
+ var validation_rules_gen_exports = /* @__PURE__ */ __exportAll({ SearchResourcesRequest: () => SearchResourcesRequest });
4
+ const SearchResourcesRequest = { query: {
5
+ maxLength: 100,
6
+ minLength: 2
7
+ } };
8
+ //#endregion
9
+ export { SearchResourcesRequest, validation_rules_gen_exports };
package/package.json ADDED
@@ -0,0 +1,53 @@
1
+ {
2
+ "name": "@scaleway/sdk-search",
3
+ "version": "1.1.0",
4
+ "description": "Scaleway SDK search",
5
+ "license": "Apache-2.0",
6
+ "repository": {
7
+ "type": "git",
8
+ "directory": "packages_generated/search"
9
+ },
10
+ "files": [
11
+ "dist",
12
+ "README.md"
13
+ ],
14
+ "type": "module",
15
+ "exports": {
16
+ ".": {
17
+ "types": "./dist/index.gen.d.ts",
18
+ "default": "./dist/index.gen.js"
19
+ },
20
+ "./*": {
21
+ "types": "./dist/*/index.gen.d.ts",
22
+ "default": "./dist/*/index.gen.js"
23
+ },
24
+ "./metadata": {
25
+ "types": "./dist/metadata.gen.d.ts",
26
+ "default": "./dist/metadata.gen.js"
27
+ },
28
+ "./*/metadata": {
29
+ "types": "./dist/*/metadata.gen.d.ts",
30
+ "default": "./dist/*/metadata.gen.js"
31
+ }
32
+ },
33
+ "dependencies": {
34
+ "@scaleway/random-name": "5.1.4",
35
+ "@scaleway/sdk-std": "2.4.2"
36
+ },
37
+ "devDependencies": {
38
+ "@scaleway/sdk-client": "^2.4.0"
39
+ },
40
+ "peerDependencies": {
41
+ "@scaleway/sdk-client": "^2.4.0"
42
+ },
43
+ "engines": {
44
+ "node": ">=20.20.2"
45
+ },
46
+ "scripts": {
47
+ "package:check": "pnpm publint",
48
+ "typecheck": "tsgo --noEmit",
49
+ "type:generate": "tsgo --declaration -p tsconfig.build.json",
50
+ "build": "vite build --config vite.config.ts && pnpm run type:generate",
51
+ "build:profile": "npx vite-bundle-visualizer -c vite.config.ts"
52
+ }
53
+ }