@databricks/sdk-alerts 0.0.0-dev → 0.1.0-dev.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.
Files changed (54) hide show
  1. package/LICENSE +203 -0
  2. package/dist/v1/client.d.ts +23 -0
  3. package/dist/v1/client.d.ts.map +1 -0
  4. package/dist/v1/client.js +185 -0
  5. package/dist/v1/client.js.map +1 -0
  6. package/dist/v1/index.d.ts +5 -0
  7. package/dist/v1/index.d.ts.map +1 -0
  8. package/dist/v1/index.js +5 -0
  9. package/dist/v1/index.js.map +1 -0
  10. package/dist/v1/model.d.ts +235 -0
  11. package/dist/v1/model.d.ts.map +1 -0
  12. package/dist/v1/model.js +384 -0
  13. package/dist/v1/model.js.map +1 -0
  14. package/dist/v1/transport.d.ts +5 -0
  15. package/dist/v1/transport.d.ts.map +1 -0
  16. package/dist/v1/transport.js +57 -0
  17. package/dist/v1/transport.js.map +1 -0
  18. package/dist/v1/utils.d.ts +22 -0
  19. package/dist/v1/utils.d.ts.map +1 -0
  20. package/dist/v1/utils.js +113 -0
  21. package/dist/v1/utils.js.map +1 -0
  22. package/dist/v2/client.d.ts +23 -0
  23. package/dist/v2/client.d.ts.map +1 -0
  24. package/dist/v2/client.js +197 -0
  25. package/dist/v2/client.js.map +1 -0
  26. package/dist/v2/index.d.ts +5 -0
  27. package/dist/v2/index.d.ts.map +1 -0
  28. package/dist/v2/index.js +5 -0
  29. package/dist/v2/index.js.map +1 -0
  30. package/dist/v2/model.d.ts +233 -0
  31. package/dist/v2/model.d.ts.map +1 -0
  32. package/dist/v2/model.js +459 -0
  33. package/dist/v2/model.js.map +1 -0
  34. package/dist/v2/transport.d.ts +5 -0
  35. package/dist/v2/transport.d.ts.map +1 -0
  36. package/dist/v2/transport.js +57 -0
  37. package/dist/v2/transport.js.map +1 -0
  38. package/dist/v2/utils.d.ts +22 -0
  39. package/dist/v2/utils.d.ts.map +1 -0
  40. package/dist/v2/utils.js +113 -0
  41. package/dist/v2/utils.js.map +1 -0
  42. package/package.json +42 -4
  43. package/src/v1/client.ts +237 -0
  44. package/src/v1/index.ts +25 -0
  45. package/src/v1/model.ts +620 -0
  46. package/src/v1/transport.ts +73 -0
  47. package/src/v1/utils.ts +156 -0
  48. package/src/v2/client.ts +253 -0
  49. package/src/v2/index.ts +32 -0
  50. package/src/v2/model.ts +669 -0
  51. package/src/v2/transport.ts +73 -0
  52. package/src/v2/utils.ts +156 -0
  53. package/README.md +0 -1
  54. package/index.js +0 -1
@@ -0,0 +1,113 @@
1
+ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
2
+ import { execute } from '@databricks/sdk-core/api';
3
+ import { ApiError } from '@databricks/sdk-core/apierror';
4
+ import JSONBig from 'json-bigint';
5
+ // JSON codec that preserves int64 precision. On the way in, large integer
6
+ // literals come back as bigint instead of being rounded to JS Number. On the
7
+ // way out, bigint values are emitted as raw JSON number digits.
8
+ const jsonBigint = JSONBig({ useNativeBigInt: true });
9
+ /**
10
+ * Translates public CallOptions to the internal Options shape accepted by
11
+ * execute(). Even though the shapes match today, this isolates the public
12
+ * API from the executor's internal type so they can diverge.
13
+ */
14
+ export async function executeCall(call, options) {
15
+ const opts = {
16
+ ...(options?.retrier !== undefined && { retrier: options.retrier }),
17
+ ...(options?.rateLimiter !== undefined && {
18
+ rateLimiter: options.rateLimiter,
19
+ }),
20
+ ...(options?.timeout !== undefined && { timeout: options.timeout }),
21
+ };
22
+ return execute(options?.signal, call, opts);
23
+ }
24
+ async function readAll(body) {
25
+ if (body === null) {
26
+ return new Uint8Array(0);
27
+ }
28
+ const reader = body.getReader();
29
+ const chunks = [];
30
+ for (;;) {
31
+ const { done, value } = await reader.read();
32
+ if (done) {
33
+ break;
34
+ }
35
+ chunks.push(value);
36
+ }
37
+ const totalLength = chunks.reduce((acc, chunk) => acc + chunk.length, 0);
38
+ const result = new Uint8Array(totalLength);
39
+ let offset = 0;
40
+ for (const chunk of chunks) {
41
+ result.set(chunk, offset);
42
+ offset += chunk.length;
43
+ }
44
+ return result;
45
+ }
46
+ export async function executeHttpCall(opts) {
47
+ opts.logger.debug('HTTP request', {
48
+ method: opts.request.method,
49
+ url: opts.request.url,
50
+ });
51
+ let resp;
52
+ try {
53
+ resp = await opts.httpClient.send(opts.request);
54
+ }
55
+ catch (e) {
56
+ opts.logger.debug('HTTP request failed');
57
+ throw e;
58
+ }
59
+ const body = await readAll(resp.body);
60
+ opts.logger.debug('HTTP response', {
61
+ statusCode: resp.statusCode,
62
+ body: new TextDecoder().decode(body),
63
+ });
64
+ const apiErr = ApiError.fromHttpError(resp.statusCode, resp.headers, body);
65
+ if (apiErr !== undefined) {
66
+ throw apiErr;
67
+ }
68
+ return body;
69
+ }
70
+ export function buildHttpRequest(method, url, headers, signal, body) {
71
+ const req = { url, method, headers };
72
+ if (body !== undefined) {
73
+ req.body = body;
74
+ }
75
+ if (signal !== undefined) {
76
+ req.signal = signal;
77
+ }
78
+ return req;
79
+ }
80
+ export function parseResponse(body, schema) {
81
+ const text = new TextDecoder().decode(body);
82
+ const parsed = jsonBigint.parse(text);
83
+ return schema.parse(parsed);
84
+ }
85
+ export function marshalRequest(data, schema) {
86
+ return jsonBigint.stringify(schema.parse(data));
87
+ }
88
+ export function flattenQueryParams(prefix, value, params) {
89
+ if (value === null || value === undefined) {
90
+ return;
91
+ }
92
+ if (Array.isArray(value)) {
93
+ // arrays of objects are not yet supported
94
+ for (const item of value) {
95
+ params.append(prefix, String(item));
96
+ }
97
+ }
98
+ else if (typeof value === 'object') {
99
+ for (const [key, val] of Object.entries(value)) {
100
+ flattenQueryParams(`${prefix}.${key}`, val, params);
101
+ }
102
+ }
103
+ else if (typeof value === 'string' ||
104
+ typeof value === 'number' ||
105
+ typeof value === 'boolean' ||
106
+ typeof value === 'bigint') {
107
+ params.append(prefix, String(value));
108
+ }
109
+ else {
110
+ throw new Error(`Unsupported query parameter type: ${typeof value}`);
111
+ }
112
+ }
113
+ //# sourceMappingURL=utils.js.map
@@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CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,0CAA0C;QAC1C,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;YACzB,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QACtC,CAAC;IACH,CAAC;SAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACrC,KAAK,MAAM,CAAC,GAAG,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAgC,CAAC,EAAE,CAAC;YAC1E,kBAAkB,CAAC,GAAG,MAAM,IAAI,GAAG,EAAE,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC;QACtD,CAAC;IACH,CAAC;SAAM,IACL,OAAO,KAAK,KAAK,QAAQ;QACzB,OAAO,KAAK,KAAK,QAAQ;QACzB,OAAO,KAAK,KAAK,SAAS;QAC1B,OAAO,KAAK,KAAK,QAAQ,EACzB,CAAC;QACD,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IACvC,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CAAC,qCAAqC,OAAO,KAAK,EAAE,CAAC,CAAC;IACvE,CAAC;AACH,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,45 @@
1
1
  {
2
2
  "name": "@databricks/sdk-alerts",
3
- "version": "0.0.0-dev",
4
- "description": "Bootstrap placeholder; real contents in a later release.",
5
- "main": "index.js",
6
- "license": "Apache-2.0"
3
+ "version": "0.1.0-dev.1",
4
+ "description": "",
5
+ "type": "module",
6
+ "exports": {
7
+ "./v1": {
8
+ "types": "./dist/v1/index.d.ts",
9
+ "import": "./dist/v1/index.js"
10
+ },
11
+ "./v2": {
12
+ "types": "./dist/v2/index.d.ts",
13
+ "import": "./dist/v2/index.js"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist",
18
+ "src",
19
+ "LICENSE"
20
+ ],
21
+ "scripts": {
22
+ "build": "tsc -b",
23
+ "lint": "eslint src --ext .ts",
24
+ "lint:fix": "eslint src --ext .ts --fix",
25
+ "format": "prettier --write \"src/**/*.ts\"",
26
+ "format:check": "prettier --check \"src/**/*.ts\"",
27
+ "typecheck": "tsc --noEmit",
28
+ "clean": "rm -rf dist tsconfig.tsbuildinfo",
29
+ "test": "echo 'no tests'",
30
+ "test:browser": "echo 'no tests'"
31
+ },
32
+ "author": "Databricks",
33
+ "license": "Apache-2.0",
34
+ "dependencies": {
35
+ "@databricks/sdk-auth": ">=0.1.0-dev.2 <1.0.0",
36
+ "@databricks/sdk-core": ">=0.1.0-dev.3 <1.0.0",
37
+ "@databricks/sdk-options": ">=0.1.0-dev.2 <1.0.0",
38
+ "@js-temporal/polyfill": "^0.5.0",
39
+ "json-bigint": "^1.0.0",
40
+ "zod": "^4.3.6"
41
+ },
42
+ "engines": {
43
+ "node": ">=22.0.0"
44
+ }
7
45
  }
@@ -0,0 +1,237 @@
1
+ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
2
+
3
+ import {VERSION as AUTH_VERSION} from '@databricks/sdk-auth';
4
+ import type {Call} from '@databricks/sdk-core/api';
5
+ import {createDefault} from '@databricks/sdk-core/clientinfo';
6
+ import type {Logger} from '@databricks/sdk-core/logger';
7
+ import {NoOpLogger} from '@databricks/sdk-core/logger';
8
+ import type {CallOptions} from '@databricks/sdk-options/call';
9
+ import type {ClientOptions} from '@databricks/sdk-options/client';
10
+ import type {HttpClient} from '@databricks/sdk-core/http';
11
+ import {newHttpClient} from './transport';
12
+ import {
13
+ buildHttpRequest,
14
+ executeCall,
15
+ executeHttpCall,
16
+ marshalRequest,
17
+ parseResponse,
18
+ } from './utils';
19
+ import pkgJson from '../../package.json' with {type: 'json'};
20
+ import type {
21
+ Alert,
22
+ CreateAlertRequest,
23
+ Empty,
24
+ GetAlertRequest,
25
+ ListAlertsRequest,
26
+ ListAlertsResponse,
27
+ ListAlertsResponseAlert,
28
+ TrashAlertRequest,
29
+ UpdateAlertRequest,
30
+ } from './model';
31
+ import {
32
+ marshalCreateAlertRequestSchema,
33
+ marshalUpdateAlertRequestSchema,
34
+ unmarshalAlertSchema,
35
+ unmarshalEmptySchema,
36
+ unmarshalListAlertsResponseSchema,
37
+ } from './model';
38
+
39
+ // Package identity segment for this client to be used in the User-Agent header.
40
+ const PACKAGE_SEGMENT = {
41
+ key: 'sdk-js-' + pkgJson.name.replace(/^@[^/]+\/sdk-/, ''),
42
+ value: pkgJson.version,
43
+ };
44
+
45
+ export class AlertsClient {
46
+ private readonly host: string;
47
+ // Workspace ID used to route workspace-level calls on unified hosts (SPOG).
48
+ // When set, workspace-level methods send X-Databricks-Org-Id on every
49
+ // request.
50
+ private readonly workspaceId: string | undefined;
51
+ private readonly httpClient: HttpClient;
52
+ private readonly logger: Logger;
53
+ // User-Agent header value. Composed once at construction from
54
+ // createDefault() merged with this package's identity and the active
55
+ // credential's name.
56
+ private readonly userAgent: string;
57
+
58
+ constructor(options: ClientOptions) {
59
+ if (options.host === undefined) {
60
+ throw new Error('Host is required.');
61
+ }
62
+ this.host = options.host.replace(/\/$/, '');
63
+ this.workspaceId = options.workspaceId;
64
+ this.logger = options.logger ?? new NoOpLogger();
65
+ const info = createDefault()
66
+ .with(PACKAGE_SEGMENT)
67
+ .with({key: 'sdk-js-auth', value: AUTH_VERSION})
68
+ .with({key: 'auth', value: options.credentials?.name() ?? 'default'});
69
+ this.userAgent = info.toString();
70
+ this.httpClient = newHttpClient(options);
71
+ }
72
+
73
+ /** Creates an alert. */
74
+ async createAlert(
75
+ req: CreateAlertRequest,
76
+ options?: CallOptions
77
+ ): Promise<Alert> {
78
+ const url = `${this.host}/api/2.0/sql/alerts`;
79
+ const body = marshalRequest(req, marshalCreateAlertRequestSchema);
80
+ let resp: Alert | undefined;
81
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
82
+ const headers = new Headers({'Content-Type': 'application/json'});
83
+ if (this.workspaceId !== undefined) {
84
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
85
+ }
86
+ headers.set('User-Agent', this.userAgent);
87
+ const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);
88
+ const respBody = await executeHttpCall({
89
+ request: httpReq,
90
+ httpClient: this.httpClient,
91
+ logger: this.logger,
92
+ });
93
+ resp = parseResponse(respBody, unmarshalAlertSchema);
94
+ };
95
+ await executeCall(call, options);
96
+ if (resp === undefined) {
97
+ throw new Error('API call completed without a result.');
98
+ }
99
+ return resp;
100
+ }
101
+
102
+ /** Gets an alert. */
103
+ async getAlert(req: GetAlertRequest, options?: CallOptions): Promise<Alert> {
104
+ const url = `${this.host}/api/2.0/sql/alerts/${req.id ?? ''}`;
105
+ let resp: Alert | undefined;
106
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
107
+ const headers = new Headers();
108
+ if (this.workspaceId !== undefined) {
109
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
110
+ }
111
+ headers.set('User-Agent', this.userAgent);
112
+ const httpReq = buildHttpRequest('GET', url, headers, callSignal);
113
+ const respBody = await executeHttpCall({
114
+ request: httpReq,
115
+ httpClient: this.httpClient,
116
+ logger: this.logger,
117
+ });
118
+ resp = parseResponse(respBody, unmarshalAlertSchema);
119
+ };
120
+ await executeCall(call, options);
121
+ if (resp === undefined) {
122
+ throw new Error('API call completed without a result.');
123
+ }
124
+ return resp;
125
+ }
126
+
127
+ /** Gets a list of alerts accessible to the user, ordered by creation time. **Warning:** Calling this API concurrently 10 or more times could result in throttling, service degradation, or a temporary ban. */
128
+ async listAlerts(
129
+ req: ListAlertsRequest,
130
+ options?: CallOptions
131
+ ): Promise<ListAlertsResponse> {
132
+ const url = `${this.host}/api/2.0/sql/alerts`;
133
+ const params = new URLSearchParams();
134
+ if (req.pageToken !== undefined) {
135
+ params.append('page_token', req.pageToken);
136
+ }
137
+ if (req.pageSize !== undefined) {
138
+ params.append('page_size', String(req.pageSize));
139
+ }
140
+ const query = params.toString();
141
+ const fullUrl = query !== '' ? `${url}?${query}` : url;
142
+ let resp: ListAlertsResponse | undefined;
143
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
144
+ const headers = new Headers();
145
+ if (this.workspaceId !== undefined) {
146
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
147
+ }
148
+ headers.set('User-Agent', this.userAgent);
149
+ const httpReq = buildHttpRequest('GET', fullUrl, headers, callSignal);
150
+ const respBody = await executeHttpCall({
151
+ request: httpReq,
152
+ httpClient: this.httpClient,
153
+ logger: this.logger,
154
+ });
155
+ resp = parseResponse(respBody, unmarshalListAlertsResponseSchema);
156
+ };
157
+ await executeCall(call, options);
158
+ if (resp === undefined) {
159
+ throw new Error('API call completed without a result.');
160
+ }
161
+ return resp;
162
+ }
163
+
164
+ async *listAlertsIter(
165
+ req: ListAlertsRequest,
166
+ options?: CallOptions
167
+ ): AsyncGenerator<ListAlertsResponseAlert> {
168
+ const pageReq: ListAlertsRequest = {...req};
169
+ for (;;) {
170
+ const resp = await this.listAlerts(pageReq, options);
171
+ for (const item of resp.results ?? []) {
172
+ yield item;
173
+ }
174
+ if (resp.nextPageToken === undefined || resp.nextPageToken === '') {
175
+ return;
176
+ }
177
+ pageReq.pageToken = resp.nextPageToken;
178
+ }
179
+ }
180
+
181
+ /** Moves an alert to the trash. Trashed alerts immediately disappear from searches and list views, and can no longer trigger. You can restore a trashed alert through the UI. A trashed alert is permanently deleted after 30 days. */
182
+ async trashAlert(
183
+ req: TrashAlertRequest,
184
+ options?: CallOptions
185
+ ): Promise<Empty> {
186
+ const url = `${this.host}/api/2.0/sql/alerts/${req.id ?? ''}`;
187
+ let resp: Empty | undefined;
188
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
189
+ const headers = new Headers();
190
+ if (this.workspaceId !== undefined) {
191
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
192
+ }
193
+ headers.set('User-Agent', this.userAgent);
194
+ const httpReq = buildHttpRequest('DELETE', url, headers, callSignal);
195
+ const respBody = await executeHttpCall({
196
+ request: httpReq,
197
+ httpClient: this.httpClient,
198
+ logger: this.logger,
199
+ });
200
+ resp = parseResponse(respBody, unmarshalEmptySchema);
201
+ };
202
+ await executeCall(call, options);
203
+ if (resp === undefined) {
204
+ throw new Error('API call completed without a result.');
205
+ }
206
+ return resp;
207
+ }
208
+
209
+ /** Updates an alert. */
210
+ async updateAlert(
211
+ req: UpdateAlertRequest,
212
+ options?: CallOptions
213
+ ): Promise<Alert> {
214
+ const url = `${this.host}/api/2.0/sql/alerts/${req.id ?? ''}`;
215
+ const body = marshalRequest(req, marshalUpdateAlertRequestSchema);
216
+ let resp: Alert | undefined;
217
+ const call: Call = async (callSignal?: AbortSignal): Promise<void> => {
218
+ const headers = new Headers({'Content-Type': 'application/json'});
219
+ if (this.workspaceId !== undefined) {
220
+ headers.set('X-Databricks-Org-Id', this.workspaceId);
221
+ }
222
+ headers.set('User-Agent', this.userAgent);
223
+ const httpReq = buildHttpRequest('PATCH', url, headers, callSignal, body);
224
+ const respBody = await executeHttpCall({
225
+ request: httpReq,
226
+ httpClient: this.httpClient,
227
+ logger: this.logger,
228
+ });
229
+ resp = parseResponse(respBody, unmarshalAlertSchema);
230
+ };
231
+ await executeCall(call, options);
232
+ if (resp === undefined) {
233
+ throw new Error('API call completed without a result.');
234
+ }
235
+ return resp;
236
+ }
237
+ }
@@ -0,0 +1,25 @@
1
+ // Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.
2
+
3
+ export {AlertsClient} from './client';
4
+
5
+ export {AlertOperator, AlertState, LifecycleState} from './model';
6
+
7
+ export type {
8
+ Alert,
9
+ AlertCondition,
10
+ AlertOperand,
11
+ AlertOperandColumn,
12
+ AlertOperandValue,
13
+ CreateAlertRequest,
14
+ CreateAlertRequestAlert,
15
+ Empty,
16
+ GetAlertRequest,
17
+ ListAlertsRequest,
18
+ ListAlertsResponse,
19
+ ListAlertsResponseAlert,
20
+ TrashAlertRequest,
21
+ UpdateAlertRequest,
22
+ UpdateAlertRequestAlert,
23
+ } from './model';
24
+
25
+ export {updateAlertRequestAlertFieldMask} from './model';