@valtown/sdk 1.2.0 → 1.4.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 (94) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +12 -24
  3. package/index.d.mts +7 -0
  4. package/index.d.ts +7 -0
  5. package/index.d.ts.map +1 -1
  6. package/index.js +10 -0
  7. package/index.js.map +1 -1
  8. package/index.mjs +10 -0
  9. package/index.mjs.map +1 -1
  10. package/internal/qs/formats.d.ts +6 -0
  11. package/internal/qs/formats.d.ts.map +1 -0
  12. package/internal/qs/formats.js +11 -0
  13. package/internal/qs/formats.js.map +1 -0
  14. package/internal/qs/formats.mjs +8 -0
  15. package/internal/qs/formats.mjs.map +1 -0
  16. package/internal/qs/index.d.ts +10 -0
  17. package/internal/qs/index.d.ts.map +1 -0
  18. package/internal/qs/index.js +14 -0
  19. package/internal/qs/index.js.map +1 -0
  20. package/internal/qs/index.mjs +10 -0
  21. package/internal/qs/index.mjs.map +1 -0
  22. package/internal/qs/stringify.d.ts +3 -0
  23. package/internal/qs/stringify.d.ts.map +1 -0
  24. package/internal/qs/stringify.js +280 -0
  25. package/internal/qs/stringify.js.map +1 -0
  26. package/internal/qs/stringify.mjs +276 -0
  27. package/internal/qs/stringify.mjs.map +1 -0
  28. package/internal/qs/types.d.ts +57 -0
  29. package/internal/qs/types.d.ts.map +1 -0
  30. package/internal/qs/types.js +3 -0
  31. package/internal/qs/types.js.map +1 -0
  32. package/internal/qs/types.mjs +2 -0
  33. package/internal/qs/types.mjs.map +1 -0
  34. package/internal/qs/utils.d.ts +14 -0
  35. package/internal/qs/utils.d.ts.map +1 -0
  36. package/internal/qs/utils.js +229 -0
  37. package/internal/qs/utils.js.map +1 -0
  38. package/internal/qs/utils.mjs +217 -0
  39. package/internal/qs/utils.mjs.map +1 -0
  40. package/package.json +1 -1
  41. package/resources/index.d.ts +1 -0
  42. package/resources/index.d.ts.map +1 -1
  43. package/resources/index.js +3 -1
  44. package/resources/index.js.map +1 -1
  45. package/resources/index.mjs +1 -0
  46. package/resources/index.mjs.map +1 -1
  47. package/resources/telemetry/index.d.ts +4 -0
  48. package/resources/telemetry/index.d.ts.map +1 -0
  49. package/resources/telemetry/index.js +11 -0
  50. package/resources/telemetry/index.js.map +1 -0
  51. package/resources/telemetry/index.mjs +5 -0
  52. package/resources/telemetry/index.mjs.map +1 -0
  53. package/resources/telemetry/logs.d.ts +85 -0
  54. package/resources/telemetry/logs.d.ts.map +1 -0
  55. package/resources/telemetry/logs.js +19 -0
  56. package/resources/telemetry/logs.js.map +1 -0
  57. package/resources/telemetry/logs.mjs +15 -0
  58. package/resources/telemetry/logs.mjs.map +1 -0
  59. package/resources/telemetry/telemetry.d.ts +17 -0
  60. package/resources/telemetry/telemetry.d.ts.map +1 -0
  61. package/resources/telemetry/telemetry.js +46 -0
  62. package/resources/telemetry/telemetry.js.map +1 -0
  63. package/resources/telemetry/telemetry.mjs +19 -0
  64. package/resources/telemetry/telemetry.mjs.map +1 -0
  65. package/resources/telemetry/traces.d.ts +80 -0
  66. package/resources/telemetry/traces.d.ts.map +1 -0
  67. package/resources/telemetry/traces.js +19 -0
  68. package/resources/telemetry/traces.js.map +1 -0
  69. package/resources/telemetry/traces.mjs +15 -0
  70. package/resources/telemetry/traces.mjs.map +1 -0
  71. package/resources/telemetry.d.ts +2 -0
  72. package/resources/telemetry.d.ts.map +1 -0
  73. package/resources/telemetry.js +19 -0
  74. package/resources/telemetry.js.map +1 -0
  75. package/resources/telemetry.mjs +3 -0
  76. package/resources/telemetry.mjs.map +1 -0
  77. package/src/index.ts +13 -0
  78. package/src/internal/qs/LICENSE.md +13 -0
  79. package/src/internal/qs/README.md +3 -0
  80. package/src/internal/qs/formats.ts +9 -0
  81. package/src/internal/qs/index.ts +13 -0
  82. package/src/internal/qs/stringify.ts +388 -0
  83. package/src/internal/qs/types.ts +71 -0
  84. package/src/internal/qs/utils.ts +265 -0
  85. package/src/resources/index.ts +1 -0
  86. package/src/resources/telemetry/index.ts +5 -0
  87. package/src/resources/telemetry/logs.ts +119 -0
  88. package/src/resources/telemetry/telemetry.ts +28 -0
  89. package/src/resources/telemetry/traces.ts +109 -0
  90. package/src/resources/telemetry.ts +3 -0
  91. package/src/version.ts +1 -1
  92. package/version.d.ts +1 -1
  93. package/version.js +1 -1
  94. package/version.mjs +1 -1
@@ -0,0 +1,265 @@
1
+ import { RFC1738 } from './formats';
2
+ import type { DefaultEncoder, Format } from './types';
3
+
4
+ const has = Object.prototype.hasOwnProperty;
5
+ const is_array = Array.isArray;
6
+
7
+ const hex_table = (() => {
8
+ const array = [];
9
+ for (let i = 0; i < 256; ++i) {
10
+ array.push('%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase());
11
+ }
12
+
13
+ return array;
14
+ })();
15
+
16
+ function compact_queue<T extends Record<string, any>>(queue: Array<{ obj: T; prop: string }>) {
17
+ while (queue.length > 1) {
18
+ const item = queue.pop();
19
+ if (!item) continue;
20
+
21
+ const obj = item.obj[item.prop];
22
+
23
+ if (is_array(obj)) {
24
+ const compacted: unknown[] = [];
25
+
26
+ for (let j = 0; j < obj.length; ++j) {
27
+ if (typeof obj[j] !== 'undefined') {
28
+ compacted.push(obj[j]);
29
+ }
30
+ }
31
+
32
+ // @ts-ignore
33
+ item.obj[item.prop] = compacted;
34
+ }
35
+ }
36
+ }
37
+
38
+ function array_to_object(source: any[], options: { plainObjects: boolean }) {
39
+ const obj = options && options.plainObjects ? Object.create(null) : {};
40
+ for (let i = 0; i < source.length; ++i) {
41
+ if (typeof source[i] !== 'undefined') {
42
+ obj[i] = source[i];
43
+ }
44
+ }
45
+
46
+ return obj;
47
+ }
48
+
49
+ export function merge(
50
+ target: any,
51
+ source: any,
52
+ options: { plainObjects?: boolean; allowPrototypes?: boolean } = {},
53
+ ) {
54
+ if (!source) {
55
+ return target;
56
+ }
57
+
58
+ if (typeof source !== 'object') {
59
+ if (is_array(target)) {
60
+ target.push(source);
61
+ } else if (target && typeof target === 'object') {
62
+ if (
63
+ (options && (options.plainObjects || options.allowPrototypes)) ||
64
+ !has.call(Object.prototype, source)
65
+ ) {
66
+ target[source] = true;
67
+ }
68
+ } else {
69
+ return [target, source];
70
+ }
71
+
72
+ return target;
73
+ }
74
+
75
+ if (!target || typeof target !== 'object') {
76
+ return [target].concat(source);
77
+ }
78
+
79
+ let mergeTarget = target;
80
+ if (is_array(target) && !is_array(source)) {
81
+ // @ts-ignore
82
+ mergeTarget = array_to_object(target, options);
83
+ }
84
+
85
+ if (is_array(target) && is_array(source)) {
86
+ source.forEach(function (item, i) {
87
+ if (has.call(target, i)) {
88
+ const targetItem = target[i];
89
+ if (targetItem && typeof targetItem === 'object' && item && typeof item === 'object') {
90
+ target[i] = merge(targetItem, item, options);
91
+ } else {
92
+ target.push(item);
93
+ }
94
+ } else {
95
+ target[i] = item;
96
+ }
97
+ });
98
+ return target;
99
+ }
100
+
101
+ return Object.keys(source).reduce(function (acc, key) {
102
+ const value = source[key];
103
+
104
+ if (has.call(acc, key)) {
105
+ acc[key] = merge(acc[key], value, options);
106
+ } else {
107
+ acc[key] = value;
108
+ }
109
+ return acc;
110
+ }, mergeTarget);
111
+ }
112
+
113
+ export function assign_single_source(target: any, source: any) {
114
+ return Object.keys(source).reduce(function (acc, key) {
115
+ acc[key] = source[key];
116
+ return acc;
117
+ }, target);
118
+ }
119
+
120
+ export function decode(str: string, _: any, charset: string) {
121
+ const strWithoutPlus = str.replace(/\+/g, ' ');
122
+ if (charset === 'iso-8859-1') {
123
+ // unescape never throws, no try...catch needed:
124
+ return strWithoutPlus.replace(/%[0-9a-f]{2}/gi, unescape);
125
+ }
126
+ // utf-8
127
+ try {
128
+ return decodeURIComponent(strWithoutPlus);
129
+ } catch (e) {
130
+ return strWithoutPlus;
131
+ }
132
+ }
133
+
134
+ const limit = 1024;
135
+
136
+ export const encode: (
137
+ str: any,
138
+ defaultEncoder: DefaultEncoder,
139
+ charset: string,
140
+ type: 'key' | 'value',
141
+ format: Format,
142
+ ) => string = (str, _defaultEncoder, charset, _kind, format: Format) => {
143
+ // This code was originally written by Brian White for the io.js core querystring library.
144
+ // It has been adapted here for stricter adherence to RFC 3986
145
+ if (str.length === 0) {
146
+ return str;
147
+ }
148
+
149
+ let string = str;
150
+ if (typeof str === 'symbol') {
151
+ string = Symbol.prototype.toString.call(str);
152
+ } else if (typeof str !== 'string') {
153
+ string = String(str);
154
+ }
155
+
156
+ if (charset === 'iso-8859-1') {
157
+ return escape(string).replace(/%u[0-9a-f]{4}/gi, function ($0) {
158
+ return '%26%23' + parseInt($0.slice(2), 16) + '%3B';
159
+ });
160
+ }
161
+
162
+ let out = '';
163
+ for (let j = 0; j < string.length; j += limit) {
164
+ const segment = string.length >= limit ? string.slice(j, j + limit) : string;
165
+ const arr = [];
166
+
167
+ for (let i = 0; i < segment.length; ++i) {
168
+ let c = segment.charCodeAt(i);
169
+ if (
170
+ c === 0x2d || // -
171
+ c === 0x2e || // .
172
+ c === 0x5f || // _
173
+ c === 0x7e || // ~
174
+ (c >= 0x30 && c <= 0x39) || // 0-9
175
+ (c >= 0x41 && c <= 0x5a) || // a-z
176
+ (c >= 0x61 && c <= 0x7a) || // A-Z
177
+ (format === RFC1738 && (c === 0x28 || c === 0x29)) // ( )
178
+ ) {
179
+ arr[arr.length] = segment.charAt(i);
180
+ continue;
181
+ }
182
+
183
+ if (c < 0x80) {
184
+ arr[arr.length] = hex_table[c];
185
+ continue;
186
+ }
187
+
188
+ if (c < 0x800) {
189
+ arr[arr.length] = hex_table[0xc0 | (c >> 6)]! + hex_table[0x80 | (c & 0x3f)];
190
+ continue;
191
+ }
192
+
193
+ if (c < 0xd800 || c >= 0xe000) {
194
+ arr[arr.length] =
195
+ hex_table[0xe0 | (c >> 12)]! + hex_table[0x80 | ((c >> 6) & 0x3f)] + hex_table[0x80 | (c & 0x3f)];
196
+ continue;
197
+ }
198
+
199
+ i += 1;
200
+ c = 0x10000 + (((c & 0x3ff) << 10) | (segment.charCodeAt(i) & 0x3ff));
201
+
202
+ arr[arr.length] =
203
+ hex_table[0xf0 | (c >> 18)]! +
204
+ hex_table[0x80 | ((c >> 12) & 0x3f)] +
205
+ hex_table[0x80 | ((c >> 6) & 0x3f)] +
206
+ hex_table[0x80 | (c & 0x3f)];
207
+ }
208
+
209
+ out += arr.join('');
210
+ }
211
+
212
+ return out;
213
+ };
214
+
215
+ export function compact(value: any) {
216
+ const queue = [{ obj: { o: value }, prop: 'o' }];
217
+ const refs = [];
218
+
219
+ for (let i = 0; i < queue.length; ++i) {
220
+ const item = queue[i];
221
+ // @ts-ignore
222
+ const obj = item.obj[item.prop];
223
+
224
+ const keys = Object.keys(obj);
225
+ for (let j = 0; j < keys.length; ++j) {
226
+ const key = keys[j]!;
227
+ const val = obj[key];
228
+ if (typeof val === 'object' && val !== null && refs.indexOf(val) === -1) {
229
+ queue.push({ obj: obj, prop: key });
230
+ refs.push(val);
231
+ }
232
+ }
233
+ }
234
+
235
+ compact_queue(queue);
236
+
237
+ return value;
238
+ }
239
+
240
+ export function is_regexp(obj: any) {
241
+ return Object.prototype.toString.call(obj) === '[object RegExp]';
242
+ }
243
+
244
+ export function is_buffer(obj: any) {
245
+ if (!obj || typeof obj !== 'object') {
246
+ return false;
247
+ }
248
+
249
+ return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj));
250
+ }
251
+
252
+ export function combine(a: any, b: any) {
253
+ return [].concat(a, b);
254
+ }
255
+
256
+ export function maybe_map<T>(val: T[], fn: (v: T) => T) {
257
+ if (is_array(val)) {
258
+ const mapped = [];
259
+ for (let i = 0; i < val.length; i += 1) {
260
+ mapped.push(fn(val[i]!));
261
+ }
262
+ return mapped;
263
+ }
264
+ return fn(val);
265
+ }
@@ -7,5 +7,6 @@ export { Emails, type EmailSendResponse, type EmailSendParams } from './emails';
7
7
  export { Me } from './me/me';
8
8
  export { Search } from './search/search';
9
9
  export { Sqlite, type SqliteBatchResponse, type SqliteBatchParams, type SqliteExecuteParams } from './sqlite';
10
+ export { Telemetry } from './telemetry/telemetry';
10
11
  export { Users } from './users';
11
12
  export { Vals, type ValListResponse, type ValCreateParams, type ValListParams } from './vals/vals';
@@ -0,0 +1,5 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ export { Logs, type LogListResponse, type LogListParams } from './logs';
4
+ export { Telemetry } from './telemetry';
5
+ export { Traces, type TraceListResponse, type TraceListParams } from './traces';
@@ -0,0 +1,119 @@
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 * as Shared from '../shared';
6
+
7
+ export class Logs extends APIResource {
8
+ /**
9
+ * Get OpenTelemetry logs within a specified time window with flexible pagination
10
+ * options: Pass in only the end time to paginate backwards from there. Pass in a
11
+ * start time to paginate backwards from now until the start time. Pass in both to
12
+ * get resources within the time window. Filter additionally by branch_ids or
13
+ * file_id.
14
+ */
15
+ list(query: LogListParams, options?: Core.RequestOptions): Core.APIPromise<LogListResponse> {
16
+ return this._client.get('/v1/telemetry/logs', { query, ...options });
17
+ }
18
+ }
19
+
20
+ /**
21
+ * A paginated result set
22
+ */
23
+ export interface LogListResponse {
24
+ data: Array<LogListResponse.Data>;
25
+
26
+ /**
27
+ * Links to use for pagination
28
+ */
29
+ links: Shared.PaginationLinks;
30
+ }
31
+
32
+ export namespace LogListResponse {
33
+ export interface Data {
34
+ attributes: Array<Data.Attribute>;
35
+
36
+ body: Data.Body;
37
+
38
+ severityText: string;
39
+
40
+ timeUnixNano: string;
41
+
42
+ traceId: string;
43
+ }
44
+
45
+ export namespace Data {
46
+ export interface Attribute {
47
+ key: string;
48
+
49
+ value: Attribute.Value;
50
+ }
51
+
52
+ export namespace Attribute {
53
+ export interface Value {
54
+ arrayValue?: unknown;
55
+
56
+ boolValue?: boolean;
57
+
58
+ bytesValue?: string;
59
+
60
+ doubleValue?: number;
61
+
62
+ intValue?: string;
63
+
64
+ kvlistValue?: unknown;
65
+
66
+ stringValue?: string;
67
+ }
68
+ }
69
+
70
+ export interface Body {
71
+ arrayValue?: unknown;
72
+
73
+ boolValue?: boolean;
74
+
75
+ bytesValue?: string;
76
+
77
+ doubleValue?: number;
78
+
79
+ intValue?: string;
80
+
81
+ kvlistValue?: unknown;
82
+
83
+ stringValue?: string;
84
+ }
85
+ }
86
+ }
87
+
88
+ export interface LogListParams {
89
+ /**
90
+ * Maximum items to return in each paginated response
91
+ */
92
+ limit: number;
93
+
94
+ trace_ids: Array<string>;
95
+
96
+ /**
97
+ * Branch IDs to filter by
98
+ */
99
+ branch_ids?: Array<string>;
100
+
101
+ /**
102
+ * End date of the time window (latest time)
103
+ */
104
+ end?: string;
105
+
106
+ /**
107
+ * Include only resources from a given file identified by its ID
108
+ */
109
+ file_id?: string;
110
+
111
+ /**
112
+ * Start date of the time window (earliest time)
113
+ */
114
+ start?: string;
115
+ }
116
+
117
+ export declare namespace Logs {
118
+ export { type LogListResponse as LogListResponse, type LogListParams as LogListParams };
119
+ }
@@ -0,0 +1,28 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../../resource';
4
+ import * as LogsAPI from './logs';
5
+ import { LogListParams, LogListResponse, Logs } from './logs';
6
+ import * as TracesAPI from './traces';
7
+ import { TraceListParams, TraceListResponse, Traces } from './traces';
8
+
9
+ /**
10
+ * OpenTelemetry traces and logs for your val executions
11
+ */
12
+ export class Telemetry extends APIResource {
13
+ traces: TracesAPI.Traces = new TracesAPI.Traces(this._client);
14
+ logs: LogsAPI.Logs = new LogsAPI.Logs(this._client);
15
+ }
16
+
17
+ Telemetry.Traces = Traces;
18
+ Telemetry.Logs = Logs;
19
+
20
+ export declare namespace Telemetry {
21
+ export {
22
+ Traces as Traces,
23
+ type TraceListResponse as TraceListResponse,
24
+ type TraceListParams as TraceListParams,
25
+ };
26
+
27
+ export { Logs as Logs, type LogListResponse as LogListResponse, type LogListParams as LogListParams };
28
+ }
@@ -0,0 +1,109 @@
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 * as Shared from '../shared';
6
+
7
+ export class Traces extends APIResource {
8
+ /**
9
+ * Get OpenTelemetry traces within a specified time window with flexible pagination
10
+ * options: Pass in only the end time to paginate backwards from there. Pass in a
11
+ * start time to paginate backwards from now until the start time. Pass in both to
12
+ * get resources within the time window. Filter additionally by branch_ids or
13
+ * file_id.
14
+ */
15
+ list(query: TraceListParams, options?: Core.RequestOptions): Core.APIPromise<TraceListResponse> {
16
+ return this._client.get('/v1/telemetry/traces', { query, ...options });
17
+ }
18
+ }
19
+
20
+ /**
21
+ * A paginated result set
22
+ */
23
+ export interface TraceListResponse {
24
+ data: Array<TraceListResponse.Data>;
25
+
26
+ /**
27
+ * Links to use for pagination
28
+ */
29
+ links: Shared.PaginationLinks;
30
+ }
31
+
32
+ export namespace TraceListResponse {
33
+ export interface Data {
34
+ attributes: Array<Data.Attribute>;
35
+
36
+ endTimeUnixNano: string;
37
+
38
+ name: string;
39
+
40
+ startTimeUnixNano: string;
41
+
42
+ status: Data.Status;
43
+
44
+ traceId: string;
45
+ }
46
+
47
+ export namespace Data {
48
+ export interface Attribute {
49
+ key: string;
50
+
51
+ value: Attribute.Value;
52
+ }
53
+
54
+ export namespace Attribute {
55
+ export interface Value {
56
+ arrayValue?: unknown;
57
+
58
+ boolValue?: boolean;
59
+
60
+ bytesValue?: string;
61
+
62
+ doubleValue?: number;
63
+
64
+ intValue?: string;
65
+
66
+ kvlistValue?: unknown;
67
+
68
+ stringValue?: string;
69
+ }
70
+ }
71
+
72
+ export interface Status {
73
+ code: number;
74
+
75
+ message: string;
76
+ }
77
+ }
78
+ }
79
+
80
+ export interface TraceListParams {
81
+ /**
82
+ * Maximum items to return in each paginated response
83
+ */
84
+ limit: number;
85
+
86
+ /**
87
+ * Branch IDs to filter by
88
+ */
89
+ branch_ids?: Array<string>;
90
+
91
+ /**
92
+ * End date of the time window (latest time)
93
+ */
94
+ end?: string;
95
+
96
+ /**
97
+ * Include only resources from a given file identified by its ID
98
+ */
99
+ file_id?: string;
100
+
101
+ /**
102
+ * Start date of the time window (earliest time)
103
+ */
104
+ start?: string;
105
+ }
106
+
107
+ export declare namespace Traces {
108
+ export { type TraceListResponse as TraceListResponse, type TraceListParams as TraceListParams };
109
+ }
@@ -0,0 +1,3 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ export * from './telemetry/index';
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '1.2.0'; // x-release-please-version
1
+ export const VERSION = '1.4.0'; // x-release-please-version
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "1.2.0";
1
+ export declare const VERSION = "1.4.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 = '1.2.0'; // x-release-please-version
4
+ exports.VERSION = '1.4.0'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '1.2.0'; // x-release-please-version
1
+ export const VERSION = '1.4.0'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map