@valtown/sdk 2.0.0 → 2.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.
Files changed (73) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/index.d.mts +7 -3
  3. package/index.d.ts +7 -3
  4. package/index.d.ts.map +1 -1
  5. package/index.js.map +1 -1
  6. package/index.mjs.map +1 -1
  7. package/package.json +1 -1
  8. package/pagination.d.ts +20 -0
  9. package/pagination.d.ts.map +1 -1
  10. package/pagination.js +35 -1
  11. package/pagination.js.map +1 -1
  12. package/pagination.mjs +33 -0
  13. package/pagination.mjs.map +1 -1
  14. package/resources/index.d.ts +1 -1
  15. package/resources/index.d.ts.map +1 -1
  16. package/resources/index.js.map +1 -1
  17. package/resources/index.mjs.map +1 -1
  18. package/resources/search/index.d.ts +1 -1
  19. package/resources/search/index.d.ts.map +1 -1
  20. package/resources/search/index.js +1 -2
  21. package/resources/search/index.js.map +1 -1
  22. package/resources/search/index.mjs +1 -1
  23. package/resources/search/index.mjs.map +1 -1
  24. package/resources/search/search.d.ts +2 -2
  25. package/resources/search/search.d.ts.map +1 -1
  26. package/resources/search/search.js +0 -1
  27. package/resources/search/search.js.map +1 -1
  28. package/resources/search/search.mjs +1 -2
  29. package/resources/search/search.mjs.map +1 -1
  30. package/resources/search/vals.d.ts +6 -78
  31. package/resources/search/vals.d.ts.map +1 -1
  32. package/resources/search/vals.js +4 -7
  33. package/resources/search/vals.js.map +1 -1
  34. package/resources/search/vals.mjs +3 -5
  35. package/resources/search/vals.mjs.map +1 -1
  36. package/resources/shared.d.ts +161 -1
  37. package/resources/shared.d.ts.map +1 -1
  38. package/resources/shared.js +7 -1
  39. package/resources/shared.js.map +1 -1
  40. package/resources/shared.mjs +5 -1
  41. package/resources/shared.mjs.map +1 -1
  42. package/resources/vals/environment-variables.d.ts +137 -0
  43. package/resources/vals/environment-variables.d.ts.map +1 -0
  44. package/resources/vals/environment-variables.js +81 -0
  45. package/resources/vals/environment-variables.js.map +1 -0
  46. package/resources/vals/environment-variables.mjs +76 -0
  47. package/resources/vals/environment-variables.mjs.map +1 -0
  48. package/resources/vals/index.d.ts +2 -1
  49. package/resources/vals/index.d.ts.map +1 -1
  50. package/resources/vals/index.js +4 -1
  51. package/resources/vals/index.js.map +1 -1
  52. package/resources/vals/index.mjs +1 -0
  53. package/resources/vals/index.mjs.map +1 -1
  54. package/resources/vals/vals.d.ts +14 -18
  55. package/resources/vals/vals.d.ts.map +1 -1
  56. package/resources/vals/vals.js +13 -3
  57. package/resources/vals/vals.js.map +1 -1
  58. package/resources/vals/vals.mjs +12 -2
  59. package/resources/vals/vals.mjs.map +1 -1
  60. package/src/index.ts +13 -8
  61. package/src/pagination.ts +61 -0
  62. package/src/resources/index.ts +1 -1
  63. package/src/resources/search/index.ts +1 -1
  64. package/src/resources/search/search.ts +2 -8
  65. package/src/resources/search/vals.ts +8 -103
  66. package/src/resources/shared.ts +201 -1
  67. package/src/resources/vals/environment-variables.ts +199 -0
  68. package/src/resources/vals/index.ts +11 -1
  69. package/src/resources/vals/vals.ts +38 -26
  70. package/src/version.ts +1 -1
  71. package/version.d.ts +1 -1
  72. package/version.js +1 -1
  73. package/version.mjs +1 -1
@@ -1,6 +1,202 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
- import { PageCursorURL } from '../pagination';
3
+ import { Cursor, PageCursorURL } from '../pagination';
4
+
5
+ /**
6
+ * A Val
7
+ */
8
+ export interface BasicVal {
9
+ /**
10
+ * This val's id
11
+ */
12
+ id: string;
13
+
14
+ /**
15
+ * The user who created this val
16
+ */
17
+ author: BasicVal.Author | null;
18
+
19
+ /**
20
+ * TypeScript code associated with this val
21
+ */
22
+ code: string | null;
23
+
24
+ createdAt: string;
25
+
26
+ links: BasicVal.Links;
27
+
28
+ /**
29
+ * The name of this val
30
+ */
31
+ name: string;
32
+
33
+ /**
34
+ * This resource's privacy setting. Unlisted resources do not appear on profile
35
+ * pages or elsewhere, but you can link to them.
36
+ */
37
+ privacy: 'public' | 'unlisted' | 'private';
38
+
39
+ /**
40
+ * Whether this val is available publicly on Val Town
41
+ */
42
+ public: boolean;
43
+
44
+ /**
45
+ * The type of a val. HTTP can receive web requests, Email can receive emails, Cron
46
+ * runs periodically, and Script can be used for libraries or one-off calculations
47
+ */
48
+ type: 'interval' | 'http' | 'express' | 'email' | 'script' | 'rpc' | 'httpnext';
49
+
50
+ updatedAt: string;
51
+
52
+ /**
53
+ * The URL of this resource on the Val Town website
54
+ */
55
+ url: string;
56
+
57
+ /**
58
+ * The version of this val, starting at zero
59
+ */
60
+ version: number;
61
+ }
62
+
63
+ export namespace BasicVal {
64
+ /**
65
+ * The user who created this val
66
+ */
67
+ export interface Author {
68
+ id: string;
69
+
70
+ username: string | null;
71
+ }
72
+
73
+ export interface Links {
74
+ /**
75
+ * The URL of this Val's source code as a module
76
+ */
77
+ module: string;
78
+
79
+ /**
80
+ * The URL of this val on this API
81
+ */
82
+ self: string;
83
+
84
+ /**
85
+ * The endpoint to retrieve this val's versions
86
+ */
87
+ versions: string;
88
+
89
+ /**
90
+ * This val's web endpoint, where it serves a website or API
91
+ */
92
+ endpoint?: string;
93
+ }
94
+ }
95
+
96
+ /**
97
+ * A Legacy Val
98
+ */
99
+ export interface ExtendedVal {
100
+ /**
101
+ * This val's id
102
+ */
103
+ id: string;
104
+
105
+ /**
106
+ * The user who created this val
107
+ */
108
+ author: ExtendedVal.Author | null;
109
+
110
+ /**
111
+ * TypeScript code associated with this val
112
+ */
113
+ code: string | null;
114
+
115
+ createdAt: string;
116
+
117
+ /**
118
+ * How many likes this val has received
119
+ */
120
+ likeCount: number;
121
+
122
+ links: ExtendedVal.Links;
123
+
124
+ /**
125
+ * The name of this val
126
+ */
127
+ name: string;
128
+
129
+ /**
130
+ * This resource's privacy setting. Unlisted resources do not appear on profile
131
+ * pages or elsewhere, but you can link to them.
132
+ */
133
+ privacy: 'public' | 'unlisted' | 'private';
134
+
135
+ /**
136
+ * Whether this val is available publicly on Val Town
137
+ */
138
+ public: boolean;
139
+
140
+ /**
141
+ * This val's readme, as Markdown
142
+ */
143
+ readme: string | null;
144
+
145
+ referenceCount: number;
146
+
147
+ /**
148
+ * The type of a val. HTTP can receive web requests, Email can receive emails, Cron
149
+ * runs periodically, and Script can be used for libraries or one-off calculations
150
+ */
151
+ type: 'interval' | 'http' | 'express' | 'email' | 'script' | 'rpc' | 'httpnext';
152
+
153
+ updatedAt: string;
154
+
155
+ /**
156
+ * The URL of this resource on the Val Town website
157
+ */
158
+ url: string;
159
+
160
+ /**
161
+ * The version of this val, starting at zero
162
+ */
163
+ version: number;
164
+
165
+ versionCreatedAt?: string;
166
+ }
167
+
168
+ export namespace ExtendedVal {
169
+ /**
170
+ * The user who created this val
171
+ */
172
+ export interface Author {
173
+ id: string;
174
+
175
+ username: string | null;
176
+ }
177
+
178
+ export interface Links {
179
+ /**
180
+ * The URL of this Val's source code as a module
181
+ */
182
+ module: string;
183
+
184
+ /**
185
+ * The URL of this val on this API
186
+ */
187
+ self: string;
188
+
189
+ /**
190
+ * The endpoint to retrieve this val's versions
191
+ */
192
+ versions: string;
193
+
194
+ /**
195
+ * This val's web endpoint, where it serves a website or API
196
+ */
197
+ endpoint?: string;
198
+ }
199
+ }
4
200
 
5
201
  /**
6
202
  * Links to use for pagination
@@ -165,4 +361,8 @@ export namespace Val {
165
361
  }
166
362
  }
167
363
 
364
+ export class BasicValsPageCursorURL extends PageCursorURL<BasicVal> {}
365
+
168
366
  export class ValsPageCursorURL extends PageCursorURL<Val> {}
367
+
368
+ export class ValsCursor extends Cursor<Val> {}
@@ -0,0 +1,199 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../../resource';
4
+ import * as Core from '../../core';
5
+ import { PageCursorURL, type PageCursorURLParams } from '../../pagination';
6
+
7
+ export class EnvironmentVariables extends APIResource {
8
+ /**
9
+ * Create a new environment variable scoped to this project.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * const environmentVariable =
14
+ * await client.vals.environmentVariables.create(
15
+ * '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
16
+ * { key: 'key', value: 'value' },
17
+ * );
18
+ * ```
19
+ */
20
+ create(
21
+ valId: string,
22
+ body: EnvironmentVariableCreateParams,
23
+ options?: Core.RequestOptions,
24
+ ): Core.APIPromise<EnvironmentVariableCreateResponse> {
25
+ return this._client.post(`/v2/vals/${valId}/environment_variables`, { body, ...options });
26
+ }
27
+
28
+ /**
29
+ * Update a environment variable scoped to this project.
30
+ *
31
+ * @example
32
+ * ```ts
33
+ * const environmentVariable =
34
+ * await client.vals.environmentVariables.update(
35
+ * '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
36
+ * 'key',
37
+ * { value: 'value' },
38
+ * );
39
+ * ```
40
+ */
41
+ update(
42
+ valId: string,
43
+ key: string,
44
+ body: EnvironmentVariableUpdateParams,
45
+ options?: Core.RequestOptions,
46
+ ): Core.APIPromise<EnvironmentVariableUpdateResponse> {
47
+ return this._client.put(`/v2/vals/${valId}/environment_variables/${key}`, { body, ...options });
48
+ }
49
+
50
+ /**
51
+ * List environment variables defined in this project. This only includes names,
52
+ * not values.
53
+ *
54
+ * @example
55
+ * ```ts
56
+ * // Automatically fetches more pages as needed.
57
+ * for await (const environmentVariableListResponse of client.vals.environmentVariables.list(
58
+ * '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
59
+ * { limit: 1, offset: 0 },
60
+ * )) {
61
+ * // ...
62
+ * }
63
+ * ```
64
+ */
65
+ list(
66
+ valId: string,
67
+ query: EnvironmentVariableListParams,
68
+ options?: Core.RequestOptions,
69
+ ): Core.PagePromise<EnvironmentVariableListResponsesPageCursorURL, EnvironmentVariableListResponse> {
70
+ return this._client.getAPIList(
71
+ `/v2/vals/${valId}/environment_variables`,
72
+ EnvironmentVariableListResponsesPageCursorURL,
73
+ { query, ...options },
74
+ );
75
+ }
76
+
77
+ /**
78
+ * Delete a environment variable scoped to this project.
79
+ *
80
+ * @example
81
+ * ```ts
82
+ * await client.vals.environmentVariables.delete(
83
+ * '182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e',
84
+ * 'key',
85
+ * );
86
+ * ```
87
+ */
88
+ delete(valId: string, key: string, options?: Core.RequestOptions): Core.APIPromise<void> {
89
+ return this._client.delete(`/v2/vals/${valId}/environment_variables/${key}`, {
90
+ ...options,
91
+ headers: { Accept: '*/*', ...options?.headers },
92
+ });
93
+ }
94
+ }
95
+
96
+ export class EnvironmentVariableListResponsesPageCursorURL extends PageCursorURL<EnvironmentVariableListResponse> {}
97
+
98
+ /**
99
+ * An environment variable
100
+ */
101
+ export interface EnvironmentVariableCreateResponse {
102
+ createdAt: string;
103
+
104
+ /**
105
+ * Optional description of the environment variable
106
+ */
107
+ description: string | null;
108
+
109
+ /**
110
+ * Name or key of the environment variable, accessible via Deno.env or process.env
111
+ */
112
+ key: string;
113
+
114
+ updatedAt: string;
115
+ }
116
+
117
+ /**
118
+ * An environment variable
119
+ */
120
+ export interface EnvironmentVariableUpdateResponse {
121
+ createdAt: string;
122
+
123
+ /**
124
+ * Optional description of the environment variable
125
+ */
126
+ description: string | null;
127
+
128
+ /**
129
+ * Name or key of the environment variable, accessible via Deno.env or process.env
130
+ */
131
+ key: string;
132
+
133
+ updatedAt: string;
134
+ }
135
+
136
+ /**
137
+ * An environment variable
138
+ */
139
+ export interface EnvironmentVariableListResponse {
140
+ createdAt: string;
141
+
142
+ /**
143
+ * Optional description of the environment variable
144
+ */
145
+ description: string | null;
146
+
147
+ /**
148
+ * Name or key of the environment variable, accessible via Deno.env or process.env
149
+ */
150
+ key: string;
151
+
152
+ updatedAt: string;
153
+ }
154
+
155
+ export interface EnvironmentVariableCreateParams {
156
+ /**
157
+ * Name or key of the environment variable, accessible via Deno.env or process.env
158
+ */
159
+ key: string;
160
+
161
+ /**
162
+ * Value of the environment variable.
163
+ */
164
+ value: string;
165
+
166
+ /**
167
+ * Optional description of the environment variable
168
+ */
169
+ description?: string;
170
+ }
171
+
172
+ export interface EnvironmentVariableUpdateParams {
173
+ /**
174
+ * Value of the environment variable.
175
+ */
176
+ value: string;
177
+
178
+ /**
179
+ * Optional description of the environment variable
180
+ */
181
+ description?: string;
182
+ }
183
+
184
+ export interface EnvironmentVariableListParams extends PageCursorURLParams {}
185
+
186
+ EnvironmentVariables.EnvironmentVariableListResponsesPageCursorURL =
187
+ EnvironmentVariableListResponsesPageCursorURL;
188
+
189
+ export declare namespace EnvironmentVariables {
190
+ export {
191
+ type EnvironmentVariableCreateResponse as EnvironmentVariableCreateResponse,
192
+ type EnvironmentVariableUpdateResponse as EnvironmentVariableUpdateResponse,
193
+ type EnvironmentVariableListResponse as EnvironmentVariableListResponse,
194
+ EnvironmentVariableListResponsesPageCursorURL as EnvironmentVariableListResponsesPageCursorURL,
195
+ type EnvironmentVariableCreateParams as EnvironmentVariableCreateParams,
196
+ type EnvironmentVariableUpdateParams as EnvironmentVariableUpdateParams,
197
+ type EnvironmentVariableListParams as EnvironmentVariableListParams,
198
+ };
199
+ }
@@ -9,6 +9,16 @@ export {
9
9
  type BranchCreateParams,
10
10
  type BranchListParams,
11
11
  } from './branches';
12
+ export {
13
+ EnvironmentVariableListResponsesPageCursorURL,
14
+ EnvironmentVariables,
15
+ type EnvironmentVariableCreateResponse,
16
+ type EnvironmentVariableUpdateResponse,
17
+ type EnvironmentVariableListResponse,
18
+ type EnvironmentVariableCreateParams,
19
+ type EnvironmentVariableUpdateParams,
20
+ type EnvironmentVariableListParams,
21
+ } from './environment-variables';
12
22
  export {
13
23
  FileRetrieveResponsesPageCursorURL,
14
24
  Files,
@@ -21,4 +31,4 @@ export {
21
31
  type FileDeleteParams,
22
32
  type FileGetContentParams,
23
33
  } from './files';
24
- export { Vals, type ValListResponse, type ValCreateParams, type ValListParams } from './vals';
34
+ export { Vals, type ValCreateParams, type ValListParams } from './vals';
@@ -3,6 +3,7 @@
3
3
  import { APIResource } from '../../resource';
4
4
  import * as Core from '../../core';
5
5
  import * as Shared from '../shared';
6
+ import { ValsCursor } from '../shared';
6
7
  import * as BranchesAPI from './branches';
7
8
  import {
8
9
  BranchCreateParams,
@@ -13,6 +14,17 @@ import {
13
14
  BranchRetrieveResponse,
14
15
  Branches,
15
16
  } from './branches';
17
+ import * as EnvironmentVariablesAPI from './environment-variables';
18
+ import {
19
+ EnvironmentVariableCreateParams,
20
+ EnvironmentVariableCreateResponse,
21
+ EnvironmentVariableListParams,
22
+ EnvironmentVariableListResponse,
23
+ EnvironmentVariableListResponsesPageCursorURL,
24
+ EnvironmentVariableUpdateParams,
25
+ EnvironmentVariableUpdateResponse,
26
+ EnvironmentVariables,
27
+ } from './environment-variables';
16
28
  import * as FilesAPI from './files';
17
29
  import {
18
30
  FileCreateParams,
@@ -26,6 +38,7 @@ import {
26
38
  FileUpdateResponse,
27
39
  Files,
28
40
  } from './files';
41
+ import { type CursorParams } from '../../pagination';
29
42
 
30
43
  /**
31
44
  * Vals are a collaborative folder of runnable JavaScript, TypeScript, and JSX modules
@@ -33,6 +46,8 @@ import {
33
46
  export class Vals extends APIResource {
34
47
  branches: BranchesAPI.Branches = new BranchesAPI.Branches(this._client);
35
48
  files: FilesAPI.Files = new FilesAPI.Files(this._client);
49
+ environmentVariables: EnvironmentVariablesAPI.EnvironmentVariables =
50
+ new EnvironmentVariablesAPI.EnvironmentVariables(this._client);
36
51
 
37
52
  /**
38
53
  * Create a new val
@@ -69,11 +84,14 @@ export class Vals extends APIResource {
69
84
  *
70
85
  * @example
71
86
  * ```ts
72
- * const vals = await client.vals.list({ limit: 1 });
87
+ * // Automatically fetches more pages as needed.
88
+ * for await (const val of client.vals.list({ limit: 1 })) {
89
+ * // ...
90
+ * }
73
91
  * ```
74
92
  */
75
- list(query: ValListParams, options?: Core.RequestOptions): Core.APIPromise<ValListResponse> {
76
- return this._client.get('/v2/vals', { query, ...options });
93
+ list(query: ValListParams, options?: Core.RequestOptions): Core.PagePromise<ValsCursor, Shared.Val> {
94
+ return this._client.getAPIList('/v2/vals', ValsCursor, { query, ...options });
77
95
  }
78
96
 
79
97
  /**
@@ -94,18 +112,6 @@ export class Vals extends APIResource {
94
112
  }
95
113
  }
96
114
 
97
- /**
98
- * A paginated result set
99
- */
100
- export interface ValListResponse {
101
- data: Array<Shared.Val>;
102
-
103
- /**
104
- * Links to use for pagination
105
- */
106
- links: Shared.PaginationLinks;
107
- }
108
-
109
115
  export interface ValCreateParams {
110
116
  name: string;
111
117
 
@@ -119,17 +125,12 @@ export interface ValCreateParams {
119
125
  orgId?: string;
120
126
  }
121
127
 
122
- export interface ValListParams {
128
+ export interface ValListParams extends CursorParams {
123
129
  /**
124
130
  * Maximum items to return in each paginated response
125
131
  */
126
132
  limit: number;
127
133
 
128
- /**
129
- * Cursor to start the pagination from
130
- */
131
- cursor?: string;
132
-
133
134
  /**
134
135
  * This resource's privacy setting. Unlisted resources do not appear on profile
135
136
  * pages or elsewhere, but you can link to them.
@@ -146,13 +147,11 @@ Vals.Branches = Branches;
146
147
  Vals.BranchListResponsesPageCursorURL = BranchListResponsesPageCursorURL;
147
148
  Vals.Files = Files;
148
149
  Vals.FileRetrieveResponsesPageCursorURL = FileRetrieveResponsesPageCursorURL;
150
+ Vals.EnvironmentVariables = EnvironmentVariables;
151
+ Vals.EnvironmentVariableListResponsesPageCursorURL = EnvironmentVariableListResponsesPageCursorURL;
149
152
 
150
153
  export declare namespace Vals {
151
- export {
152
- type ValListResponse as ValListResponse,
153
- type ValCreateParams as ValCreateParams,
154
- type ValListParams as ValListParams,
155
- };
154
+ export { type ValCreateParams as ValCreateParams, type ValListParams as ValListParams };
156
155
 
157
156
  export {
158
157
  Branches as Branches,
@@ -176,4 +175,17 @@ export declare namespace Vals {
176
175
  type FileDeleteParams as FileDeleteParams,
177
176
  type FileGetContentParams as FileGetContentParams,
178
177
  };
178
+
179
+ export {
180
+ EnvironmentVariables as EnvironmentVariables,
181
+ type EnvironmentVariableCreateResponse as EnvironmentVariableCreateResponse,
182
+ type EnvironmentVariableUpdateResponse as EnvironmentVariableUpdateResponse,
183
+ type EnvironmentVariableListResponse as EnvironmentVariableListResponse,
184
+ EnvironmentVariableListResponsesPageCursorURL as EnvironmentVariableListResponsesPageCursorURL,
185
+ type EnvironmentVariableCreateParams as EnvironmentVariableCreateParams,
186
+ type EnvironmentVariableUpdateParams as EnvironmentVariableUpdateParams,
187
+ type EnvironmentVariableListParams as EnvironmentVariableListParams,
188
+ };
179
189
  }
190
+
191
+ export { ValsCursor };
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '2.0.0'; // x-release-please-version
1
+ export const VERSION = '2.1.0'; // x-release-please-version
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "2.0.0";
1
+ export declare const VERSION = "2.1.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '2.0.0'; // x-release-please-version
4
+ exports.VERSION = '2.1.0'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '2.0.0'; // x-release-please-version
1
+ export const VERSION = '2.1.0'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map