@databricks/sdk-aifunctions 0.0.0-beta → 0.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/LICENSE ADDED
@@ -0,0 +1,203 @@
1
+ Copyright 2026 Databricks, Inc. All rights reserved.
2
+
3
+ Apache License
4
+ Version 2.0, January 2004
5
+ http://www.apache.org/licenses/
6
+
7
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
8
+
9
+ 1. Definitions.
10
+
11
+ "License" shall mean the terms and conditions for use, reproduction,
12
+ and distribution as defined by Sections 1 through 9 of this document.
13
+
14
+ "Licensor" shall mean the copyright owner or entity authorized by
15
+ the copyright owner that is granting the License.
16
+
17
+ "Legal Entity" shall mean the union of the acting entity and all
18
+ other entities that control, are controlled by, or are under common
19
+ control with that entity. For the purposes of this definition,
20
+ "control" means (i) the power, direct or indirect, to cause the
21
+ direction or management of such entity, whether by contract or
22
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
23
+ outstanding shares, or (iii) beneficial ownership of such entity.
24
+
25
+ "You" (or "Your") shall mean an individual or Legal Entity
26
+ exercising permissions granted by this License.
27
+
28
+ "Source" form shall mean the preferred form for making modifications,
29
+ including but not limited to software source code, documentation
30
+ source, and configuration files.
31
+
32
+ "Object" form shall mean any form resulting from mechanical
33
+ transformation or translation of a Source form, including but
34
+ not limited to compiled object code, generated documentation,
35
+ and conversions to other media types.
36
+
37
+ "Work" shall mean the work of authorship, whether in Source or
38
+ Object form, made available under the License, as indicated by a
39
+ copyright notice that is included in or attached to the work
40
+ (an example is provided in the Appendix below).
41
+
42
+ "Derivative Works" shall mean any work, whether in Source or Object
43
+ form, that is based on (or derived from) the Work and for which the
44
+ editorial revisions, annotations, elaborations, or other modifications
45
+ represent, as a whole, an original work of authorship. For the purposes
46
+ of this License, Derivative Works shall not include works that remain
47
+ separable from, or merely link (or bind by name) to the interfaces of,
48
+ the Work and Derivative Works thereof.
49
+
50
+ "Contribution" shall mean any work of authorship, including
51
+ the original version of the Work and any modifications or additions
52
+ to that Work or Derivative Works thereof, that is intentionally
53
+ submitted to Licensor for inclusion in the Work by the copyright owner
54
+ or by an individual or Legal Entity authorized to submit on behalf of
55
+ the copyright owner. For the purposes of this definition, "submitted"
56
+ means any form of electronic, verbal, or written communication sent
57
+ to the Licensor or its representatives, including but not limited to
58
+ communication on electronic mailing lists, source code control systems,
59
+ and issue tracking systems that are managed by, or on behalf of, the
60
+ Licensor for the purpose of discussing and improving the Work, but
61
+ excluding communication that is conspicuously marked or otherwise
62
+ designated in writing by the copyright owner as "Not a Contribution."
63
+
64
+ "Contributor" shall mean Licensor and any individual or Legal Entity
65
+ on behalf of whom a Contribution has been received by Licensor and
66
+ subsequently incorporated within the Work.
67
+
68
+ 2. Grant of Copyright License. Subject to the terms and conditions of
69
+ this License, each Contributor hereby grants to You a perpetual,
70
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
71
+ copyright license to reproduce, prepare Derivative Works of,
72
+ publicly display, publicly perform, sublicense, and distribute the
73
+ Work and such Derivative Works in Source or Object form.
74
+
75
+ 3. Grant of Patent License. Subject to the terms and conditions of
76
+ this License, each Contributor hereby grants to You a perpetual,
77
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
78
+ (except as stated in this section) patent license to make, have made,
79
+ use, offer to sell, sell, import, and otherwise transfer the Work,
80
+ where such license applies only to those patent claims licensable
81
+ by such Contributor that are necessarily infringed by their
82
+ Contribution(s) alone or by combination of their Contribution(s)
83
+ with the Work to which such Contribution(s) was submitted. If You
84
+ institute patent litigation against any entity (including a
85
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
86
+ or a Contribution incorporated within the Work constitutes direct
87
+ or contributory patent infringement, then any patent licenses
88
+ granted to You under this License for that Work shall terminate
89
+ as of the date such litigation is filed.
90
+
91
+ 4. Redistribution. You may reproduce and distribute copies of the
92
+ Work or Derivative Works thereof in any medium, with or without
93
+ modifications, and in Source or Object form, provided that You
94
+ meet the following conditions:
95
+
96
+ (a) You must give any other recipients of the Work or
97
+ Derivative Works a copy of this License; and
98
+
99
+ (b) You must cause any modified files to carry prominent notices
100
+ stating that You changed the files; and
101
+
102
+ (c) You must retain, in the Source form of any Derivative Works
103
+ that You distribute, all copyright, patent, trademark, and
104
+ attribution notices from the Source form of the Work,
105
+ excluding those notices that do not pertain to any part of
106
+ the Derivative Works; and
107
+
108
+ (d) If the Work includes a "NOTICE" text file as part of its
109
+ distribution, then any Derivative Works that You distribute must
110
+ include a readable copy of the attribution notices contained
111
+ within such NOTICE file, excluding those notices that do not
112
+ pertain to any part of the Derivative Works, in at least one
113
+ of the following places: within a NOTICE text file distributed
114
+ as part of the Derivative Works; within the Source form or
115
+ documentation, if provided along with the Derivative Works; or,
116
+ within a display generated by the Derivative Works, if and
117
+ wherever such third-party notices normally appear. The contents
118
+ of the NOTICE file are for informational purposes only and
119
+ do not modify the License. You may add Your own attribution
120
+ notices within Derivative Works that You distribute, alongside
121
+ or as an addendum to the NOTICE text from the Work, provided
122
+ that such additional attribution notices cannot be construed
123
+ as modifying the License.
124
+
125
+ You may add Your own copyright statement to Your modifications and
126
+ may provide additional or different license terms and conditions
127
+ for use, reproduction, or distribution of Your modifications, or
128
+ for any such Derivative Works as a whole, provided Your use,
129
+ reproduction, and distribution of the Work otherwise complies with
130
+ the conditions stated in this License.
131
+
132
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
133
+ any Contribution intentionally submitted for inclusion in the Work
134
+ by You to the Licensor shall be under the terms and conditions of
135
+ this License, without any additional terms or conditions.
136
+ Notwithstanding the above, nothing herein shall supersede or modify
137
+ the terms of any separate license agreement you may have executed
138
+ with Licensor regarding such Contributions.
139
+
140
+ 6. Trademarks. This License does not grant permission to use the trade
141
+ names, trademarks, service marks, or product names of the Licensor,
142
+ except as required for reasonable and customary use in describing the
143
+ origin of the Work and reproducing the content of the NOTICE file.
144
+
145
+ 7. Disclaimer of Warranty. Unless required by applicable law or
146
+ agreed to in writing, Licensor provides the Work (and each
147
+ Contributor provides its Contributions) on an "AS IS" BASIS,
148
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
149
+ implied, including, without limitation, any warranties or conditions
150
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
151
+ PARTICULAR PURPOSE. You are solely responsible for determining the
152
+ appropriateness of using or redistributing the Work and assume any
153
+ risks associated with Your exercise of permissions under this License.
154
+
155
+ 8. Limitation of Liability. In no event and under no legal theory,
156
+ whether in tort (including negligence), contract, or otherwise,
157
+ unless required by applicable law (such as deliberate and grossly
158
+ negligent acts) or agreed to in writing, shall any Contributor be
159
+ liable to You for damages, including any direct, indirect, special,
160
+ incidental, or consequential damages of any character arising as a
161
+ result of this License or out of the use or inability to use the
162
+ Work (including but not limited to damages for loss of goodwill,
163
+ work stoppage, computer failure or malfunction, or any and all
164
+ other commercial damages or losses), even if such Contributor
165
+ has been advised of the possibility of such damages.
166
+
167
+ 9. Accepting Warranty or Additional Liability. While redistributing
168
+ the Work or Derivative Works thereof, You may choose to offer,
169
+ and charge a fee for, acceptance of support, warranty, indemnity,
170
+ or other liability obligations and/or rights consistent with this
171
+ License. However, in accepting such obligations, You may act only
172
+ on Your own behalf and on Your sole responsibility, not on behalf
173
+ of any other Contributor, and only if You agree to indemnify,
174
+ defend, and hold each Contributor harmless for any liability
175
+ incurred by, or claims asserted against, such Contributor by reason
176
+ of your accepting any such warranty or additional liability.
177
+
178
+ END OF TERMS AND CONDITIONS
179
+
180
+ APPENDIX: How to apply the Apache License to your work.
181
+
182
+ To apply the Apache License to your work, attach the following
183
+ boilerplate notice, with the fields enclosed by brackets "[]"
184
+ replaced with your own identifying information. (Don't include
185
+ the brackets!) The text should be enclosed in the appropriate
186
+ comment syntax for the file format. We also recommend that a
187
+ file or class name and description of purpose be included on the
188
+ same "printed page" as the copyright notice for easier
189
+ identification within third-party archives.
190
+
191
+ Copyright [yyyy] [name of copyright owner]
192
+
193
+ Licensed under the Apache License, Version 2.0 (the "License");
194
+ you may not use this file except in compliance with the License.
195
+ You may obtain a copy of the License at
196
+
197
+ http://www.apache.org/licenses/LICENSE-2.0
198
+
199
+ Unless required by applicable law or agreed to in writing, software
200
+ distributed under the License is distributed on an "AS IS" BASIS,
201
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
202
+ See the License for the specific language governing permissions and
203
+ limitations under the License.
package/README.md CHANGED
@@ -1 +1,23 @@
1
- This is a placeholder release used to enable OIDC trusted publishing. Real code lands in a later version.
1
+ # @databricks/sdk-aifunctions
2
+
3
+ > [!NOTE]
4
+ >
5
+ > ## Beta
6
+ >
7
+ > **This SDK is in Beta and is supported for production use cases.** Interfaces might still change slightly before GA (e.g. name standardization and minor ergonomic tweaks). We are keen to hear feedback from early adopters — please [file issues](https://github.com/databricks/sdk-js/issues), and we will address them.
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ npm install @databricks/sdk-aifunctions
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ```typescript
18
+ import {AiFunctionsClient} from '@databricks/sdk-aifunctions/v1';
19
+
20
+ const client = new AiFunctionsClient({});
21
+ ```
22
+
23
+ For a full getting-started guide, see the [root README](../../README.md).
@@ -0,0 +1,7 @@
1
+ //#region package.json
2
+ var name = "@databricks/sdk-aifunctions";
3
+ var version = "0.1.0";
4
+
5
+ //#endregion
6
+ export { name, version };
7
+ //# sourceMappingURL=package.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"package.js","names":[],"sources":["../package.json"],"sourcesContent":[""],"mappings":""}
@@ -0,0 +1,22 @@
1
+ import { AiClassifyRequest, AiClassifyResponse, AiExtractRequest, AiExtractResponse, AiParseDocumentRequest, AiParseDocumentResponse } from "./model.js";
2
+ import { CallOptions } from "@databricks/sdk-options/call";
3
+ import { ClientOptions } from "@databricks/sdk-options/client";
4
+
5
+ //#region src/v1/client.d.ts
6
+ declare class AiFunctionsClient {
7
+ private readonly options;
8
+ private readonly logger;
9
+ private readonly userAgent;
10
+ private config;
11
+ constructor(options: ClientOptions);
12
+ private resolveConfig;
13
+ /** Classifies content according to a set of provided labels. */
14
+ aiClassify(req: AiClassifyRequest, options?: CallOptions): Promise<AiClassifyResponse>;
15
+ /** Extracts structured data from text and documents according to a provided schema. */
16
+ aiExtract(req: AiExtractRequest, options?: CallOptions): Promise<AiExtractResponse>;
17
+ /** Parse structured content from unstructured documents. */
18
+ aiParseDocument(req: AiParseDocumentRequest, options?: CallOptions): Promise<AiParseDocumentResponse>;
19
+ }
20
+ //#endregion
21
+ export { AiFunctionsClient };
22
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","names":[],"sources":["../../src/v1/client.ts"],"mappings":";;;;;cAyCa,iBAAA;EAAA,iBACM,OAAA;EAAA,iBACA,MAAA;EAAA,iBAIA,SAAA;EAAA,QAIT,MAAA;cAEI,OAAA,EAAS,aAAA;EAAA,QAUb,aAAA;EAQI;EAFN,UAAA,CACJ,GAAA,EAAK,iBAAA,EACL,OAAA,GAAU,WAAA,GACT,OAAA,CAAQ,kBAAA;EAAR;EA2BG,SAAA,CACJ,GAAA,EAAK,gBAAA,EACL,OAAA,GAAU,WAAA,GACT,OAAA,CAAQ,iBAAA;EADC;EA4BN,eAAA,CACJ,GAAA,EAAK,sBAAA,EACL,OAAA,GAAU,WAAA,GACT,OAAA,CAAQ,uBAAA;AAAA"}
@@ -0,0 +1,98 @@
1
+ import { resolveClientConfig } from "./transport.js";
2
+ import { buildHttpRequest, executeCall, executeHttpCall, marshalRequest, parseResponse } from "./utils.js";
3
+ import { name, version } from "../package.js";
4
+ import { marshalAiClassifyRequestSchema, marshalAiExtractRequestSchema, marshalAiParseDocumentRequestSchema, unmarshalAiClassifyResponseSchema, unmarshalAiExtractResponseSchema, unmarshalAiParseDocumentResponseSchema } from "./model.js";
5
+ import { VERSION } from "@databricks/sdk-auth";
6
+ import { createDefault } from "@databricks/sdk-core/clientinfo";
7
+ import { NoOpLogger } from "@databricks/sdk-core/logger";
8
+
9
+ //#region src/v1/client.ts
10
+ const PACKAGE_SEGMENT = {
11
+ key: "sdk-js-" + name.replace(/^@[^/]+\/sdk-/, ""),
12
+ value: version
13
+ };
14
+ var AiFunctionsClient = class {
15
+ options;
16
+ logger;
17
+ userAgent;
18
+ config;
19
+ constructor(options) {
20
+ this.options = options;
21
+ this.logger = options.logger ?? new NoOpLogger();
22
+ this.userAgent = createDefault().with(PACKAGE_SEGMENT).with({
23
+ key: "sdk-js-auth",
24
+ value: VERSION
25
+ }).with({
26
+ key: "auth",
27
+ value: options.credentials?.name() ?? "default"
28
+ }).toString();
29
+ }
30
+ resolveConfig() {
31
+ this.config ??= resolveClientConfig(this.options);
32
+ return this.config;
33
+ }
34
+ /** Classifies content according to a set of provided labels. */
35
+ async aiClassify(req, options) {
36
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
37
+ const url = `${host}/api/2.0/ai-functions/ai-classify`;
38
+ const body = marshalRequest(req, marshalAiClassifyRequestSchema);
39
+ let resp;
40
+ const call = async (callSignal) => {
41
+ const headers = new Headers({ "Content-Type": "application/json" });
42
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
43
+ headers.set("User-Agent", this.userAgent);
44
+ resp = parseResponse(await executeHttpCall({
45
+ request: buildHttpRequest("POST", url, headers, callSignal, body),
46
+ httpClient,
47
+ logger: this.logger
48
+ }), unmarshalAiClassifyResponseSchema);
49
+ };
50
+ await executeCall(call, options);
51
+ if (resp === void 0) throw new Error("operation completed without a result.");
52
+ return resp;
53
+ }
54
+ /** Extracts structured data from text and documents according to a provided schema. */
55
+ async aiExtract(req, options) {
56
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
57
+ const url = `${host}/api/2.0/ai-functions/ai-extract`;
58
+ const body = marshalRequest(req, marshalAiExtractRequestSchema);
59
+ let resp;
60
+ const call = async (callSignal) => {
61
+ const headers = new Headers({ "Content-Type": "application/json" });
62
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
63
+ headers.set("User-Agent", this.userAgent);
64
+ resp = parseResponse(await executeHttpCall({
65
+ request: buildHttpRequest("POST", url, headers, callSignal, body),
66
+ httpClient,
67
+ logger: this.logger
68
+ }), unmarshalAiExtractResponseSchema);
69
+ };
70
+ await executeCall(call, options);
71
+ if (resp === void 0) throw new Error("operation completed without a result.");
72
+ return resp;
73
+ }
74
+ /** Parse structured content from unstructured documents. */
75
+ async aiParseDocument(req, options) {
76
+ const { host, workspaceId, httpClient } = await this.resolveConfig();
77
+ const url = `${host}/api/2.0/ai-functions/ai-parse-document`;
78
+ const body = marshalRequest(req, marshalAiParseDocumentRequestSchema);
79
+ let resp;
80
+ const call = async (callSignal) => {
81
+ const headers = new Headers({ "Content-Type": "application/json" });
82
+ if (workspaceId !== void 0) headers.set("X-Databricks-Workspace-Id", workspaceId);
83
+ headers.set("User-Agent", this.userAgent);
84
+ resp = parseResponse(await executeHttpCall({
85
+ request: buildHttpRequest("POST", url, headers, callSignal, body),
86
+ httpClient,
87
+ logger: this.logger
88
+ }), unmarshalAiParseDocumentResponseSchema);
89
+ };
90
+ await executeCall(call, options);
91
+ if (resp === void 0) throw new Error("operation completed without a result.");
92
+ return resp;
93
+ }
94
+ };
95
+
96
+ //#endregion
97
+ export { AiFunctionsClient };
98
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","names":["pkgJson.version","AUTH_VERSION"],"sources":["../../src/v1/client.ts"],"sourcesContent":["// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.\n\nimport {VERSION as AUTH_VERSION} from '@databricks/sdk-auth';\nimport {createDefault} from '@databricks/sdk-core/clientinfo';\nimport type {Logger} from '@databricks/sdk-core/logger';\nimport {NoOpLogger} from '@databricks/sdk-core/logger';\nimport type {CallOptions} from '@databricks/sdk-options/call';\nimport type {ClientOptions} from '@databricks/sdk-options/client';\nimport type {ResolvedClientConfig} from './transport';\nimport {resolveClientConfig} from './transport';\nimport {\n buildHttpRequest,\n executeCall,\n executeHttpCall,\n marshalRequest,\n parseResponse,\n} from './utils';\nimport pkgJson from '../../package.json' with {type: 'json'};\nimport type {\n AiClassifyRequest,\n AiClassifyResponse,\n AiExtractRequest,\n AiExtractResponse,\n AiParseDocumentRequest,\n AiParseDocumentResponse,\n} from './model';\nimport {\n marshalAiClassifyRequestSchema,\n marshalAiExtractRequestSchema,\n marshalAiParseDocumentRequestSchema,\n unmarshalAiClassifyResponseSchema,\n unmarshalAiExtractResponseSchema,\n unmarshalAiParseDocumentResponseSchema,\n} from './model';\n\n// Package identity segment for this client to be used in the User-Agent header.\nconst PACKAGE_SEGMENT = {\n key: 'sdk-js-' + pkgJson.name.replace(/^@[^/]+\\/sdk-/, ''),\n value: pkgJson.version,\n};\n\nexport class AiFunctionsClient {\n private readonly options: ClientOptions;\n private readonly logger: Logger;\n // User-Agent header value. Composed once at construction from\n // createDefault() merged with this package's identity and the active\n // credential's name.\n private readonly userAgent: string;\n // Memoized configuration. The profile is resolved once, lazily, on the first\n // request, then reused; host, workspaceId/accountId, and credentials are\n // filled from it when not set explicitly on the options.\n private config: Promise<ResolvedClientConfig> | undefined;\n\n constructor(options: ClientOptions) {\n this.options = options;\n this.logger = options.logger ?? new NoOpLogger();\n const info = createDefault()\n .with(PACKAGE_SEGMENT)\n .with({key: 'sdk-js-auth', value: AUTH_VERSION})\n .with({key: 'auth', value: options.credentials?.name() ?? 'default'});\n this.userAgent = info.toString();\n }\n\n private resolveConfig(): Promise<ResolvedClientConfig> {\n this.config ??= resolveClientConfig(this.options);\n return this.config;\n }\n\n /** Classifies content according to a set of provided labels. */\n async aiClassify(\n req: AiClassifyRequest,\n options?: CallOptions\n ): Promise<AiClassifyResponse> {\n const {host, workspaceId, httpClient} = await this.resolveConfig();\n const url = `${host}/api/2.0/ai-functions/ai-classify`;\n const body = marshalRequest(req, marshalAiClassifyRequestSchema);\n let resp: AiClassifyResponse | undefined;\n const call = async (callSignal?: AbortSignal): Promise<void> => {\n const headers = new Headers({'Content-Type': 'application/json'});\n if (workspaceId !== undefined) {\n headers.set('X-Databricks-Workspace-Id', workspaceId);\n }\n headers.set('User-Agent', this.userAgent);\n const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);\n const respBody = await executeHttpCall({\n request: httpReq,\n httpClient,\n logger: this.logger,\n });\n resp = parseResponse(respBody, unmarshalAiClassifyResponseSchema);\n };\n await executeCall(call, options);\n if (resp === undefined) {\n throw new Error('operation completed without a result.');\n }\n return resp;\n }\n\n /** Extracts structured data from text and documents according to a provided schema. */\n async aiExtract(\n req: AiExtractRequest,\n options?: CallOptions\n ): Promise<AiExtractResponse> {\n const {host, workspaceId, httpClient} = await this.resolveConfig();\n const url = `${host}/api/2.0/ai-functions/ai-extract`;\n const body = marshalRequest(req, marshalAiExtractRequestSchema);\n let resp: AiExtractResponse | undefined;\n const call = async (callSignal?: AbortSignal): Promise<void> => {\n const headers = new Headers({'Content-Type': 'application/json'});\n if (workspaceId !== undefined) {\n headers.set('X-Databricks-Workspace-Id', workspaceId);\n }\n headers.set('User-Agent', this.userAgent);\n const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);\n const respBody = await executeHttpCall({\n request: httpReq,\n httpClient,\n logger: this.logger,\n });\n resp = parseResponse(respBody, unmarshalAiExtractResponseSchema);\n };\n await executeCall(call, options);\n if (resp === undefined) {\n throw new Error('operation completed without a result.');\n }\n return resp;\n }\n\n /** Parse structured content from unstructured documents. */\n async aiParseDocument(\n req: AiParseDocumentRequest,\n options?: CallOptions\n ): Promise<AiParseDocumentResponse> {\n const {host, workspaceId, httpClient} = await this.resolveConfig();\n const url = `${host}/api/2.0/ai-functions/ai-parse-document`;\n const body = marshalRequest(req, marshalAiParseDocumentRequestSchema);\n let resp: AiParseDocumentResponse | undefined;\n const call = async (callSignal?: AbortSignal): Promise<void> => {\n const headers = new Headers({'Content-Type': 'application/json'});\n if (workspaceId !== undefined) {\n headers.set('X-Databricks-Workspace-Id', workspaceId);\n }\n headers.set('User-Agent', this.userAgent);\n const httpReq = buildHttpRequest('POST', url, headers, callSignal, body);\n const respBody = await executeHttpCall({\n request: httpReq,\n httpClient,\n logger: this.logger,\n });\n resp = parseResponse(respBody, unmarshalAiParseDocumentResponseSchema);\n };\n await executeCall(call, options);\n if (resp === undefined) {\n throw new Error('operation completed without a result.');\n }\n return resp;\n }\n}\n"],"mappings":";;;;;;;;;AAoCA,MAAM,kBAAkB;CACtB,KAAK,iBAAyB,QAAQ,iBAAiB,GAAG;CAC1D,OAAOA;CACR;AAED,IAAa,oBAAb,MAA+B;CAC7B,AAAiB;CACjB,AAAiB;CAIjB,AAAiB;CAIjB,AAAQ;CAER,YAAY,SAAwB;AAClC,OAAK,UAAU;AACf,OAAK,SAAS,QAAQ,UAAU,IAAI,YAAY;AAKhD,OAAK,YAJQ,eAAe,CACzB,KAAK,gBAAgB,CACrB,KAAK;GAAC,KAAK;GAAe,OAAOC;GAAa,CAAC,CAC/C,KAAK;GAAC,KAAK;GAAQ,OAAO,QAAQ,aAAa,MAAM,IAAI;GAAU,CAAC,CACjD,UAAU;;CAGlC,AAAQ,gBAA+C;AACrD,OAAK,WAAW,oBAAoB,KAAK,QAAQ;AACjD,SAAO,KAAK;;;CAId,MAAM,WACJ,KACA,SAC6B;EAC7B,MAAM,EAAC,MAAM,aAAa,eAAc,MAAM,KAAK,eAAe;EAClE,MAAM,MAAM,GAAG,KAAK;EACpB,MAAM,OAAO,eAAe,KAAK,+BAA+B;EAChE,IAAI;EACJ,MAAM,OAAO,OAAO,eAA4C;GAC9D,MAAM,UAAU,IAAI,QAAQ,EAAC,gBAAgB,oBAAmB,CAAC;AACjE,OAAI,gBAAgB,OAClB,SAAQ,IAAI,6BAA6B,YAAY;AAEvD,WAAQ,IAAI,cAAc,KAAK,UAAU;AAOzC,UAAO,cALU,MAAM,gBAAgB;IACrC,SAFc,iBAAiB,QAAQ,KAAK,SAAS,YAAY,KAAK;IAGtE;IACA,QAAQ,KAAK;I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C,MAAI,SAAS,OACX,OAAM,IAAI,MAAM,wCAAwC;AAE1D,SAAO"}
@@ -0,0 +1,3 @@
1
+ import { AiClassifyOptions, AiClassifyRequest, AiClassifyResponse, AiClassifyResponseMetadata, AiExtractBbox, AiExtractCitation, AiExtractOptions, AiExtractRequest, AiExtractResponse, AiExtractResponseMetadata, AiParseDocumentFileMetadata, AiParseDocumentOptions, AiParseDocumentPageError, AiParseDocumentRequest, AiParseDocumentResponse, AiParseDocumentResponseMetadata } from "./model.js";
2
+ import { AiFunctionsClient } from "./client.js";
3
+ export { type AiClassifyOptions, type AiClassifyRequest, type AiClassifyResponse, type AiClassifyResponseMetadata, type AiExtractBbox, type AiExtractCitation, type AiExtractOptions, type AiExtractRequest, type AiExtractResponse, type AiExtractResponseMetadata, AiFunctionsClient, type AiParseDocumentFileMetadata, type AiParseDocumentOptions, type AiParseDocumentPageError, type AiParseDocumentRequest, type AiParseDocumentResponse, type AiParseDocumentResponseMetadata };
@@ -0,0 +1,3 @@
1
+ import { AiFunctionsClient } from "./client.js";
2
+
3
+ export { AiFunctionsClient };
@@ -0,0 +1,166 @@
1
+ import { z } from "zod";
2
+ import { JsonValue } from "@databricks/sdk-core/wkt";
3
+
4
+ //#region src/v1/model.d.ts
5
+ /** ai_classify */
6
+ interface AiClassifyOptions {
7
+ /** Natural-language guidance that steers how the text is classified (up to 20,000 characters). */
8
+ instructions?: string | undefined;
9
+ /** The function version to invoke. Defaults to the latest version. Supported versions: ["2.1"]. */
10
+ version?: string | undefined;
11
+ /** When true, allows more than one label to be returned per input. */
12
+ multilabel?: boolean | undefined;
13
+ /** When true, includes a per-label confidence score in the response. */
14
+ enableConfidenceScores?: boolean | undefined;
15
+ /** When true, includes a rationale explaining each classification in the response. */
16
+ enableRationales?: boolean | undefined;
17
+ }
18
+ interface AiClassifyRequest {
19
+ /** The content to classify. It accepts a plain string or the response object of [ai_parse_document](:method:AiFunctions/AiParseDocument). */
20
+ content?: JsonValue | undefined;
21
+ /** The label set to classify as. Either a JSON array of label strings (e.g. ["spam", "not_spam"]), or a JSON object mapping each label to a description (e.g. {"spam": "unsolicited bulk message", "not_spam": "a legitimate message"}). Accepts 2 to 500 labels, each 1 to 100 characters. */
22
+ labels?: JsonValue | undefined;
23
+ /** Function options. Omitted fields fall back to their documented defaults. */
24
+ options?: AiClassifyOptions | undefined;
25
+ }
26
+ interface AiClassifyResponse {
27
+ /** The function result as a JSON value. An array of per-label objects: one element in single-label mode (the default), or multiple elements when `multilabel` is true. When `enable_confidence_scores` and `enable_rationales` are true, `confidence_score` and `rationale` are included in each response value, respectively. */
28
+ response?: JsonValue | undefined;
29
+ /** Additional metadata returned by AI Classify. */
30
+ metadata?: AiClassifyResponseMetadata | undefined;
31
+ }
32
+ interface AiClassifyResponseMetadata {
33
+ /** The resolved function version. */
34
+ version?: string | undefined;
35
+ }
36
+ /** A bounding box on a source page; used by bbox-input citations. */
37
+ interface AiExtractBbox {
38
+ /** Pixel coordinates on the page image as [x0, y0, x1, y1]. */
39
+ coord?: bigint[] | undefined;
40
+ /** 0-based page index the box is on. */
41
+ pageId?: bigint | undefined;
42
+ }
43
+ /** A citation locating an extracted value in the source. start/stop are set for span (STRING input) citations, bbox for bbox (parsed-document input) citations. */
44
+ interface AiExtractCitation {
45
+ /** Integer matching a citation_ids entry on an extracted field. */
46
+ id?: bigint | undefined;
47
+ /** Inclusive 0-based character offset into the input string; set for span citations. */
48
+ start?: bigint | undefined;
49
+ /** Exclusive 0-based character offset into the input string; set for span citations. */
50
+ stop?: bigint | undefined;
51
+ /** Bounding boxes locating the citation on the source pages; set for bbox citations. */
52
+ bbox?: AiExtractBbox[] | undefined;
53
+ }
54
+ /** ai_extract */
55
+ interface AiExtractOptions {
56
+ /** Natural-language guidance that steers how data is extracted (up to 20,000 characters). */
57
+ instructions?: string | undefined;
58
+ /** The function version to invoke. Defaults to the latest version. Supported versions: ["2.1"]. */
59
+ version?: string | undefined;
60
+ /** Extraction mode. Supported modes: "precision" — more powerful extraction for complex schemas, long documents, and reasoning-heavy extractions. Defaults to none (standard extraction). */
61
+ mode?: string | undefined;
62
+ /**
63
+ * When true, includes citation metadata locating each extracted value in the source. Depending on the type of input, citations can be one of two types:
64
+ *
65
+ * For raw text (STRING) inputs, a citation is a span of text in the original input. Each object in `metadata.citations` has an `id` (integer matching a `citation_ids` entry on a field), a `start` (inclusive 0-based character offset into the input string), and a `stop` (exclusive 0-based character offset into the input string).
66
+ *
67
+ * For PDF documents and images (when using ai_extract downstream of ai_parse_document), a citation is a bounding box in the original input. Each object in `metadata.citations` has an `id` (integer matching a `citation_ids` entry on a field) and a `bbox` (array of {coord, page_id} objects, identical in shape to element.bbox in ai_parse_document output; coord is pixel coordinates on the page image as [x0, y0, x1, y1], and page_id is a 0-based page index).
68
+ */
69
+ enableCitations?: boolean | undefined;
70
+ /** When true, includes a per-field confidence score in the response. */
71
+ enableConfidenceScores?: boolean | undefined;
72
+ }
73
+ interface AiExtractRequest {
74
+ /** The text to extract from. It accepts a plain string or the response object of [ai_parse_document](:method:AiFunctions/AiParseDocument). */
75
+ content?: JsonValue | undefined;
76
+ /** The extraction schema defining the fields to extract. Either a JSON array of field names, assumed to be strings (e.g. ["company", "valuation"]), or a JSON object mapping each field to its type/description/nullability (e.g. {"company": {"type": "string", "description": "the company name"}}). Accepts up to 256 fields, 12 levels of nesting, and 500 enum values. Supported field types are string, integer, number, boolean, and enum. */
77
+ schema?: JsonValue | undefined;
78
+ /** Function options. Omitted fields fall back to their documented defaults. */
79
+ options?: AiExtractOptions | undefined;
80
+ }
81
+ interface AiExtractResponse {
82
+ /** The function result as a JSON value. When `enable_confidence_scores` and `enable_citations` are true, `confidence` and `citation_ids` are included in each response field, respectively. */
83
+ response?: JsonValue | undefined;
84
+ /** Additional metadata returned by AI Extract. */
85
+ metadata?: AiExtractResponseMetadata | undefined;
86
+ }
87
+ interface AiExtractResponseMetadata {
88
+ /** The resolved function version. */
89
+ version?: string | undefined;
90
+ /** The resolved extraction mode; present when a non-default mode was used. */
91
+ mode?: string | undefined;
92
+ /** How the source was chunked for citation offsets (span for text input, bbox for parsed-document input); present when citations are enabled. */
93
+ chunkType?: string | undefined;
94
+ /** Citation objects locating each result in the source; present when citations are enabled. */
95
+ citations?: AiExtractCitation[] | undefined;
96
+ }
97
+ /** Metadata about the source file; present only for file-path input. */
98
+ interface AiParseDocumentFileMetadata {
99
+ /** Unity Catalog volume path of the source file. */
100
+ filePath?: string | undefined;
101
+ /** Base name of the source file. */
102
+ fileName?: string | undefined;
103
+ /** Size of the source file in bytes. */
104
+ fileSize?: bigint | undefined;
105
+ /** Last-modified timestamp of the source file, as an HTTP date string. */
106
+ fileModificationTime?: string | undefined;
107
+ }
108
+ /** ai_parse_document */
109
+ interface AiParseDocumentOptions {
110
+ /** The ai_parse_document output schema version. Supported value: "2.0". */
111
+ version?: string | undefined;
112
+ /** Element types for which an AI-generated description is produced. Use "*" (default) to generate descriptions for all supported element types, "figure" to generate them for figures only, or "" (empty string) to generate none. Only figure descriptions are supported for version "2.0", so "*" and "figure" produce the same behavior. */
113
+ descriptionElementTypes?: string | undefined;
114
+ /** Unity Catalog volume path where rendered page and element images are written. */
115
+ imageOutputPath?: string | undefined;
116
+ /** Pages to parse (1-indexed), as a comma-separated list of page numbers or ranges (e.g. "1,3,5-10"). */
117
+ pageRange?: string | undefined;
118
+ }
119
+ /** A single page that failed to parse while the overall request succeeded. */
120
+ interface AiParseDocumentPageError {
121
+ /** Message describing why the page failed. */
122
+ errorMessage?: string | undefined;
123
+ /** 0-based index of the page that failed. */
124
+ pageId?: bigint | undefined;
125
+ }
126
+ interface AiParseDocumentRequest {
127
+ /** The document to parse, given as a Unity Catalog volume path to the source file (the REST API accepts only a UC volume path, not inline binary data). Supported formats: PDF, DOCX, DOC, PPTX, PPT, JPG, JPEG, PNG, TIFF. Accepts up to 100 pages and 100 MB per document. */
128
+ content?: string | undefined;
129
+ /** Function options. Omitted fields fall back to their documented defaults. */
130
+ options?: AiParseDocumentOptions | undefined;
131
+ }
132
+ interface AiParseDocumentResponse {
133
+ /** The parsed document as a JSON value, containing the extracted pages and elements. */
134
+ document?: JsonValue | undefined;
135
+ /** Per-page partial-failure details; present when the request succeeds (2xx) but individual pages fail. */
136
+ errorStatus?: AiParseDocumentPageError[] | undefined;
137
+ /** Additional metadata returned by AI Parse Document. */
138
+ metadata?: AiParseDocumentResponseMetadata | undefined;
139
+ }
140
+ interface AiParseDocumentResponseMetadata {
141
+ /** Unique identifier for the parse request. */
142
+ id?: string | undefined;
143
+ /** The resolved function version. */
144
+ version?: string | undefined;
145
+ /** Describes the source file; present only for file-path input. */
146
+ fileMetadata?: AiParseDocumentFileMetadata | undefined;
147
+ }
148
+ declare const unmarshalAiClassifyResponseSchema: z.ZodType<AiClassifyResponse>;
149
+ declare const unmarshalAiClassifyResponseMetadataSchema: z.ZodType<AiClassifyResponseMetadata>;
150
+ declare const unmarshalAiExtractBboxSchema: z.ZodType<AiExtractBbox>;
151
+ declare const unmarshalAiExtractCitationSchema: z.ZodType<AiExtractCitation>;
152
+ declare const unmarshalAiExtractResponseSchema: z.ZodType<AiExtractResponse>;
153
+ declare const unmarshalAiExtractResponseMetadataSchema: z.ZodType<AiExtractResponseMetadata>;
154
+ declare const unmarshalAiParseDocumentFileMetadataSchema: z.ZodType<AiParseDocumentFileMetadata>;
155
+ declare const unmarshalAiParseDocumentPageErrorSchema: z.ZodType<AiParseDocumentPageError>;
156
+ declare const unmarshalAiParseDocumentResponseSchema: z.ZodType<AiParseDocumentResponse>;
157
+ declare const unmarshalAiParseDocumentResponseMetadataSchema: z.ZodType<AiParseDocumentResponseMetadata>;
158
+ declare const marshalAiClassifyOptionsSchema: z.ZodType;
159
+ declare const marshalAiClassifyRequestSchema: z.ZodType;
160
+ declare const marshalAiExtractOptionsSchema: z.ZodType;
161
+ declare const marshalAiExtractRequestSchema: z.ZodType;
162
+ declare const marshalAiParseDocumentOptionsSchema: z.ZodType;
163
+ declare const marshalAiParseDocumentRequestSchema: z.ZodType;
164
+ //#endregion
165
+ export { AiClassifyOptions, AiClassifyRequest, AiClassifyResponse, AiClassifyResponseMetadata, AiExtractBbox, AiExtractCitation, AiExtractOptions, AiExtractRequest, AiExtractResponse, AiExtractResponseMetadata, AiParseDocumentFileMetadata, AiParseDocumentOptions, AiParseDocumentPageError, AiParseDocumentRequest, AiParseDocumentResponse, AiParseDocumentResponseMetadata, marshalAiClassifyOptionsSchema, marshalAiClassifyRequestSchema, marshalAiExtractOptionsSchema, marshalAiExtractRequestSchema, marshalAiParseDocumentOptionsSchema, marshalAiParseDocumentRequestSchema, unmarshalAiClassifyResponseMetadataSchema, unmarshalAiClassifyResponseSchema, unmarshalAiExtractBboxSchema, unmarshalAiExtractCitationSchema, unmarshalAiExtractResponseMetadataSchema, unmarshalAiExtractResponseSchema, unmarshalAiParseDocumentFileMetadataSchema, unmarshalAiParseDocumentPageErrorSchema, unmarshalAiParseDocumentResponseMetadataSchema, unmarshalAiParseDocumentResponseSchema };
166
+ //# sourceMappingURL=model.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.d.ts","names":[],"sources":["../../src/v1/model.ts"],"mappings":";;;;;UAiBiB,iBAAA;EAAA;EAEf,YAAA;;EAEA,OAAA;EAFA;EAIA,UAAA;EAAA;EAEA,sBAAA;EAEA;EAAA,gBAAA;AAAA;AAAA,UAGe,iBAAA;EAAiB;EAEhC,OAAA,GAAU,SAAA;EAAA;EAEV,MAAA,GAAS,SAAA;EAEC;EAAV,OAAA,GAAU,iBAAA;AAAA;AAAA,UAGK,kBAAA;EAPL;EASV,QAAA,GAAW,SAAA;EAPF;EAST,QAAA,GAAW,0BAAA;AAAA;AAAA,UAGI,0BAAA;EAVY;EAY3B,OAAA;AAAA;;UAIe,aAAA;EAXf;EAaA,KAAA;EAXA;EAaA,MAAA;AAAA;;UAIe,iBAAA;EAd0B;EAgBzC,EAAA;EAdA;EAgBA,KAAA;EAZe;EAcf,IAAA;;EAEA,IAAA,GAAO,aAAA;AAAA;AART;AAA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Q,iBAAA;AAAA,cAuB5C,gCAAA,EAAkC,CAAA,CAAE,OAAA,CAAQ,iBAAA;AAAA,cAU5C,wCAAA,EAA0C,CAAA,CAAE,OAAA,CAAQ,yBAAA;AAAA,cAiBpD,0CAAA,EAA4C,CAAA,CAAE,OAAA,CAAQ,2BAAA;AAAA,cAkBtD,uCAAA,EAAyC,CAAA,CAAE,OAAA,CAAQ,wBAAA;AAAA,cAcnD,sCAAA,EAAwC,CAAA,CAAE,OAAA,CAAQ,uBAAA;AAAA,cAiBlD,8CAAA,EAAgD,CAAA,CAAE,OAAA,CAAQ,+BAAA;AAAA,cAe1D,8BAAA,EAAgC,CAAA,CAAE,OAAA;AAAA,cAgBlC,8BAAA,EAAgC,CAAA,CAAE,OAAA;AAAA,cAYlC,6BAAA,EAA+B,CAAA,CAAE,OAAA;AAAA,cAgBjC,6BAAA,EAA+B,CAAA,CAAE,OAAA;AAAA,cAYjC,mCAAA,EAAqC,CAAA,CAAE,OAAA;AAAA,cAcvC,mCAAA,EAAqC,CAAA,CAAE,OAAA"}
@@ -0,0 +1,185 @@
1
+ import { z } from "zod";
2
+
3
+ //#region src/v1/model.ts
4
+ const jsonValueSchema = z.lazy(() => z.union([
5
+ z.null(),
6
+ z.number(),
7
+ z.string(),
8
+ z.boolean(),
9
+ z.record(z.string(), jsonValueSchema),
10
+ z.array(jsonValueSchema)
11
+ ]));
12
+ const unmarshalAiClassifyResponseSchema = z.object({
13
+ response: jsonValueSchema.optional(),
14
+ metadata: z.lazy(() => unmarshalAiClassifyResponseMetadataSchema).optional()
15
+ }).transform((d) => ({
16
+ response: d.response,
17
+ metadata: d.metadata
18
+ }));
19
+ const unmarshalAiClassifyResponseMetadataSchema = z.object({ version: z.string().optional() }).transform((d) => ({ version: d.version }));
20
+ const unmarshalAiExtractBboxSchema = z.object({
21
+ coord: z.array(z.union([
22
+ z.number(),
23
+ z.bigint(),
24
+ z.string()
25
+ ]).transform((v) => BigInt(v))).optional(),
26
+ page_id: z.union([
27
+ z.number(),
28
+ z.bigint(),
29
+ z.string()
30
+ ]).transform((v) => BigInt(v)).optional()
31
+ }).transform((d) => ({
32
+ coord: d.coord,
33
+ pageId: d.page_id
34
+ }));
35
+ const unmarshalAiExtractCitationSchema = z.object({
36
+ id: z.union([
37
+ z.number(),
38
+ z.bigint(),
39
+ z.string()
40
+ ]).transform((v) => BigInt(v)).optional(),
41
+ start: z.union([
42
+ z.number(),
43
+ z.bigint(),
44
+ z.string()
45
+ ]).transform((v) => BigInt(v)).optional(),
46
+ stop: z.union([
47
+ z.number(),
48
+ z.bigint(),
49
+ z.string()
50
+ ]).transform((v) => BigInt(v)).optional(),
51
+ bbox: z.array(z.lazy(() => unmarshalAiExtractBboxSchema)).optional()
52
+ }).transform((d) => ({
53
+ id: d.id,
54
+ start: d.start,
55
+ stop: d.stop,
56
+ bbox: d.bbox
57
+ }));
58
+ const unmarshalAiExtractResponseSchema = z.object({
59
+ response: jsonValueSchema.optional(),
60
+ metadata: z.lazy(() => unmarshalAiExtractResponseMetadataSchema).optional()
61
+ }).transform((d) => ({
62
+ response: d.response,
63
+ metadata: d.metadata
64
+ }));
65
+ const unmarshalAiExtractResponseMetadataSchema = z.object({
66
+ version: z.string().optional(),
67
+ mode: z.string().optional(),
68
+ chunk_type: z.string().optional(),
69
+ citations: z.array(z.lazy(() => unmarshalAiExtractCitationSchema)).optional()
70
+ }).transform((d) => ({
71
+ version: d.version,
72
+ mode: d.mode,
73
+ chunkType: d.chunk_type,
74
+ citations: d.citations
75
+ }));
76
+ const unmarshalAiParseDocumentFileMetadataSchema = z.object({
77
+ file_path: z.string().optional(),
78
+ file_name: z.string().optional(),
79
+ file_size: z.union([
80
+ z.number(),
81
+ z.bigint(),
82
+ z.string()
83
+ ]).transform((v) => BigInt(v)).optional(),
84
+ file_modification_time: z.string().optional()
85
+ }).transform((d) => ({
86
+ filePath: d.file_path,
87
+ fileName: d.file_name,
88
+ fileSize: d.file_size,
89
+ fileModificationTime: d.file_modification_time
90
+ }));
91
+ const unmarshalAiParseDocumentPageErrorSchema = z.object({
92
+ error_message: z.string().optional(),
93
+ page_id: z.union([
94
+ z.number(),
95
+ z.bigint(),
96
+ z.string()
97
+ ]).transform((v) => BigInt(v)).optional()
98
+ }).transform((d) => ({
99
+ errorMessage: d.error_message,
100
+ pageId: d.page_id
101
+ }));
102
+ const unmarshalAiParseDocumentResponseSchema = z.object({
103
+ document: jsonValueSchema.optional(),
104
+ error_status: z.array(z.lazy(() => unmarshalAiParseDocumentPageErrorSchema)).optional(),
105
+ metadata: z.lazy(() => unmarshalAiParseDocumentResponseMetadataSchema).optional()
106
+ }).transform((d) => ({
107
+ document: d.document,
108
+ errorStatus: d.error_status,
109
+ metadata: d.metadata
110
+ }));
111
+ const unmarshalAiParseDocumentResponseMetadataSchema = z.object({
112
+ id: z.string().optional(),
113
+ version: z.string().optional(),
114
+ file_metadata: z.lazy(() => unmarshalAiParseDocumentFileMetadataSchema).optional()
115
+ }).transform((d) => ({
116
+ id: d.id,
117
+ version: d.version,
118
+ fileMetadata: d.file_metadata
119
+ }));
120
+ const marshalAiClassifyOptionsSchema = z.object({
121
+ instructions: z.string().optional(),
122
+ version: z.string().optional(),
123
+ multilabel: z.boolean().optional(),
124
+ enableConfidenceScores: z.boolean().optional(),
125
+ enableRationales: z.boolean().optional()
126
+ }).transform((d) => ({
127
+ instructions: d.instructions,
128
+ version: d.version,
129
+ multilabel: d.multilabel,
130
+ enable_confidence_scores: d.enableConfidenceScores,
131
+ enable_rationales: d.enableRationales
132
+ }));
133
+ const marshalAiClassifyRequestSchema = z.object({
134
+ content: jsonValueSchema.optional(),
135
+ labels: jsonValueSchema.optional(),
136
+ options: z.lazy(() => marshalAiClassifyOptionsSchema).optional()
137
+ }).transform((d) => ({
138
+ content: d.content,
139
+ labels: d.labels,
140
+ options: d.options
141
+ }));
142
+ const marshalAiExtractOptionsSchema = z.object({
143
+ instructions: z.string().optional(),
144
+ version: z.string().optional(),
145
+ mode: z.string().optional(),
146
+ enableCitations: z.boolean().optional(),
147
+ enableConfidenceScores: z.boolean().optional()
148
+ }).transform((d) => ({
149
+ instructions: d.instructions,
150
+ version: d.version,
151
+ mode: d.mode,
152
+ enable_citations: d.enableCitations,
153
+ enable_confidence_scores: d.enableConfidenceScores
154
+ }));
155
+ const marshalAiExtractRequestSchema = z.object({
156
+ content: jsonValueSchema.optional(),
157
+ schema: jsonValueSchema.optional(),
158
+ options: z.lazy(() => marshalAiExtractOptionsSchema).optional()
159
+ }).transform((d) => ({
160
+ content: d.content,
161
+ schema: d.schema,
162
+ options: d.options
163
+ }));
164
+ const marshalAiParseDocumentOptionsSchema = z.object({
165
+ version: z.string().optional(),
166
+ descriptionElementTypes: z.string().optional(),
167
+ imageOutputPath: z.string().optional(),
168
+ pageRange: z.string().optional()
169
+ }).transform((d) => ({
170
+ version: d.version,
171
+ description_element_types: d.descriptionElementTypes,
172
+ image_output_path: d.imageOutputPath,
173
+ page_range: d.pageRange
174
+ }));
175
+ const marshalAiParseDocumentRequestSchema = z.object({
176
+ content: z.string().optional(),
177
+ options: z.lazy(() => marshalAiParseDocumentOptionsSchema).optional()
178
+ }).transform((d) => ({
179
+ content: d.content,
180
+ options: d.options
181
+ }));
182
+
183
+ //#endregion
184
+ export { marshalAiClassifyOptionsSchema, marshalAiClassifyRequestSchema, marshalAiExtractOptionsSchema, marshalAiExtractRequestSchema, marshalAiParseDocumentOptionsSchema, marshalAiParseDocumentRequestSchema, unmarshalAiClassifyResponseMetadataSchema, unmarshalAiClassifyResponseSchema, unmarshalAiExtractBboxSchema, unmarshalAiExtractCitationSchema, unmarshalAiExtractResponseMetadataSchema, unmarshalAiExtractResponseSchema, unmarshalAiParseDocumentFileMetadataSchema, unmarshalAiParseDocumentPageErrorSchema, unmarshalAiParseDocumentResponseMetadataSchema, unmarshalAiParseDocumentResponseSchema };
185
+ //# sourceMappingURL=model.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"model.js","names":[],"sources":["../../src/v1/model.ts"],"sourcesContent":["// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.\n\nimport type {JsonValue} from '@databricks/sdk-core/wkt';\nimport {z} from 'zod';\n\nconst jsonValueSchema: z.ZodType<JsonValue> = z.lazy(() =>\n z.union([\n z.null(),\n z.number(),\n z.string(),\n z.boolean(),\n z.record(z.string(), jsonValueSchema),\n z.array(jsonValueSchema),\n ])\n);\n\n/** ai_classify */\nexport interface AiClassifyOptions {\n /** Natural-language guidance that steers how the text is classified (up to 20,000 characters). */\n instructions?: string | undefined;\n /** The function version to invoke. Defaults to the latest version. Supported versions: [\"2.1\"]. */\n version?: string | undefined;\n /** When true, allows more than one label to be returned per input. */\n multilabel?: boolean | undefined;\n /** When true, includes a per-label confidence score in the response. */\n enableConfidenceScores?: boolean | undefined;\n /** When true, includes a rationale explaining each classification in the response. */\n enableRationales?: boolean | undefined;\n}\n\nexport interface AiClassifyRequest {\n /** The content to classify. It accepts a plain string or the response object of [ai_parse_document](:method:AiFunctions/AiParseDocument). */\n content?: JsonValue | undefined;\n /** The label set to classify as. Either a JSON array of label strings (e.g. [\"spam\", \"not_spam\"]), or a JSON object mapping each label to a description (e.g. {\"spam\": \"unsolicited bulk message\", \"not_spam\": \"a legitimate message\"}). Accepts 2 to 500 labels, each 1 to 100 characters. */\n labels?: JsonValue | undefined;\n /** Function options. Omitted fields fall back to their documented defaults. */\n options?: AiClassifyOptions | undefined;\n}\n\nexport interface AiClassifyResponse {\n /** The function result as a JSON value. An array of per-label objects: one element in single-label mode (the default), or multiple elements when `multilabel` is true. When `enable_confidence_scores` and `enable_rationales` are true, `confidence_score` and `rationale` are included in each response value, respectively. */\n response?: JsonValue | undefined;\n /** Additional metadata returned by AI Classify. */\n metadata?: AiClassifyResponseMetadata | undefined;\n}\n\nexport interface AiClassifyResponseMetadata {\n /** The resolved function version. */\n version?: string | undefined;\n}\n\n/** A bounding box on a source page; used by bbox-input citations. */\nexport interface AiExtractBbox {\n /** Pixel coordinates on the page image as [x0, y0, x1, y1]. */\n coord?: bigint[] | undefined;\n /** 0-based page index the box is on. */\n pageId?: bigint | undefined;\n}\n\n/** A citation locating an extracted value in the source. start/stop are set for span (STRING input) citations, bbox for bbox (parsed-document input) citations. */\nexport interface AiExtractCitation {\n /** Integer matching a citation_ids entry on an extracted field. */\n id?: bigint | undefined;\n /** Inclusive 0-based character offset into the input string; set for span citations. */\n start?: bigint | undefined;\n /** Exclusive 0-based character offset into the input string; set for span citations. */\n stop?: bigint | undefined;\n /** Bounding boxes locating the citation on the source pages; set for bbox citations. */\n bbox?: AiExtractBbox[] | undefined;\n}\n\n/** ai_extract */\nexport interface AiExtractOptions {\n /** Natural-language guidance that steers how data is extracted (up to 20,000 characters). */\n instructions?: string | undefined;\n /** The function version to invoke. Defaults to the latest version. Supported versions: [\"2.1\"]. */\n version?: string | undefined;\n /** Extraction mode. Supported modes: \"precision\" — more powerful extraction for complex schemas, long documents, and reasoning-heavy extractions. Defaults to none (standard extraction). */\n mode?: string | undefined;\n /**\n * When true, includes citation metadata locating each extracted value in the source. Depending on the type of input, citations can be one of two types:\n *\n * For raw text (STRING) inputs, a citation is a span of text in the original input. Each object in `metadata.citations` has an `id` (integer matching a `citation_ids` entry on a field), a `start` (inclusive 0-based character offset into the input string), and a `stop` (exclusive 0-based character offset into the input string).\n *\n * For PDF documents and images (when using ai_extract downstream of ai_parse_document), a citation is a bounding box in the original input. Each object in `metadata.citations` has an `id` (integer matching a `citation_ids` entry on a field) and a `bbox` (array of {coord, page_id} objects, identical in shape to element.bbox in ai_parse_document output; coord is pixel coordinates on the page image as [x0, y0, x1, y1], and page_id is a 0-based page index).\n */\n enableCitations?: boolean | undefined;\n /** When true, includes a per-field confidence score in the response. */\n enableConfidenceScores?: boolean | undefined;\n}\n\nexport interface AiExtractRequest {\n /** The text to extract from. It accepts a plain string or the response object of [ai_parse_document](:method:AiFunctions/AiParseDocument). */\n content?: JsonValue | undefined;\n /** The extraction schema defining the fields to extract. Either a JSON array of field names, assumed to be strings (e.g. [\"company\", \"valuation\"]), or a JSON object mapping each field to its type/description/nullability (e.g. {\"company\": {\"type\": \"string\", \"description\": \"the company name\"}}). Accepts up to 256 fields, 12 levels of nesting, and 500 enum values. Supported field types are string, integer, number, boolean, and enum. */\n schema?: JsonValue | undefined;\n /** Function options. Omitted fields fall back to their documented defaults. */\n options?: AiExtractOptions | undefined;\n}\n\nexport interface AiExtractResponse {\n /** The function result as a JSON value. When `enable_confidence_scores` and `enable_citations` are true, `confidence` and `citation_ids` are included in each response field, respectively. */\n response?: JsonValue | undefined;\n /** Additional metadata returned by AI Extract. */\n metadata?: AiExtractResponseMetadata | undefined;\n}\n\nexport interface AiExtractResponseMetadata {\n /** The resolved function version. */\n version?: string | undefined;\n /** The resolved extraction mode; present when a non-default mode was used. */\n mode?: string | undefined;\n /** How the source was chunked for citation offsets (span for text input, bbox for parsed-document input); present when citations are enabled. */\n chunkType?: string | undefined;\n /** Citation objects locating each result in the source; present when citations are enabled. */\n citations?: AiExtractCitation[] | undefined;\n}\n\n/** Metadata about the source file; present only for file-path input. */\nexport interface AiParseDocumentFileMetadata {\n /** Unity Catalog volume path of the source file. */\n filePath?: string | undefined;\n /** Base name of the source file. */\n fileName?: string | undefined;\n /** Size of the source file in bytes. */\n fileSize?: bigint | undefined;\n /** Last-modified timestamp of the source file, as an HTTP date string. */\n fileModificationTime?: string | undefined;\n}\n\n/** ai_parse_document */\nexport interface AiParseDocumentOptions {\n /** The ai_parse_document output schema version. Supported value: \"2.0\". */\n version?: string | undefined;\n /** Element types for which an AI-generated description is produced. Use \"*\" (default) to generate descriptions for all supported element types, \"figure\" to generate them for figures only, or \"\" (empty string) to generate none. Only figure descriptions are supported for version \"2.0\", so \"*\" and \"figure\" produce the same behavior. */\n descriptionElementTypes?: string | undefined;\n /** Unity Catalog volume path where rendered page and element images are written. */\n imageOutputPath?: string | undefined;\n /** Pages to parse (1-indexed), as a comma-separated list of page numbers or ranges (e.g. \"1,3,5-10\"). */\n pageRange?: string | undefined;\n}\n\n/** A single page that failed to parse while the overall request succeeded. */\nexport interface AiParseDocumentPageError {\n /** Message describing why the page failed. */\n errorMessage?: string | undefined;\n /** 0-based index of the page that failed. */\n pageId?: bigint | undefined;\n}\n\nexport interface AiParseDocumentRequest {\n /** The document to parse, given as a Unity Catalog volume path to the source file (the REST API accepts only a UC volume path, not inline binary data). Supported formats: PDF, DOCX, DOC, PPTX, PPT, JPG, JPEG, PNG, TIFF. Accepts up to 100 pages and 100 MB per document. */\n content?: string | undefined;\n /** Function options. Omitted fields fall back to their documented defaults. */\n options?: AiParseDocumentOptions | undefined;\n}\n\nexport interface AiParseDocumentResponse {\n /** The parsed document as a JSON value, containing the extracted pages and elements. */\n document?: JsonValue | undefined;\n /** Per-page partial-failure details; present when the request succeeds (2xx) but individual pages fail. */\n errorStatus?: AiParseDocumentPageError[] | undefined;\n /** Additional metadata returned by AI Parse Document. */\n metadata?: AiParseDocumentResponseMetadata | undefined;\n}\n\nexport interface AiParseDocumentResponseMetadata {\n /** Unique identifier for the parse request. */\n id?: string | undefined;\n /** The resolved function version. */\n version?: string | undefined;\n /** Describes the source file; present only for file-path input. */\n fileMetadata?: AiParseDocumentFileMetadata | undefined;\n}\n\nexport const unmarshalAiClassifyResponseSchema: z.ZodType<AiClassifyResponse> =\n z\n .object({\n response: jsonValueSchema.optional(),\n metadata: z\n .lazy(() => unmarshalAiClassifyResponseMetadataSchema)\n .optional(),\n })\n .transform(d => ({\n response: d.response,\n metadata: d.metadata,\n }));\n\nexport const unmarshalAiClassifyResponseMetadataSchema: z.ZodType<AiClassifyResponseMetadata> =\n z\n .object({\n version: z.string().optional(),\n })\n .transform(d => ({\n version: d.version,\n }));\n\nexport const unmarshalAiExtractBboxSchema: z.ZodType<AiExtractBbox> = z\n .object({\n coord: z\n .array(\n z.union([z.number(), z.bigint(), z.string()]).transform(v => BigInt(v))\n )\n .optional(),\n page_id: z\n .union([z.number(), z.bigint(), z.string()])\n .transform(v => BigInt(v))\n .optional(),\n })\n .transform(d => ({\n coord: d.coord,\n pageId: d.page_id,\n }));\n\nexport const unmarshalAiExtractCitationSchema: z.ZodType<AiExtractCitation> = z\n .object({\n id: z\n .union([z.number(), z.bigint(), z.string()])\n .transform(v => BigInt(v))\n .optional(),\n start: z\n .union([z.number(), z.bigint(), z.string()])\n .transform(v => BigInt(v))\n .optional(),\n stop: z\n .union([z.number(), z.bigint(), z.string()])\n .transform(v => BigInt(v))\n .optional(),\n bbox: z.array(z.lazy(() => unmarshalAiExtractBboxSchema)).optional(),\n })\n .transform(d => ({\n id: d.id,\n start: d.start,\n stop: d.stop,\n bbox: d.bbox,\n }));\n\nexport const unmarshalAiExtractResponseSchema: z.ZodType<AiExtractResponse> = z\n .object({\n response: jsonValueSchema.optional(),\n metadata: z.lazy(() => unmarshalAiExtractResponseMetadataSchema).optional(),\n })\n .transform(d => ({\n response: d.response,\n metadata: d.metadata,\n }));\n\nexport const unmarshalAiExtractResponseMetadataSchema: z.ZodType<AiExtractResponseMetadata> =\n z\n .object({\n version: z.string().optional(),\n mode: z.string().optional(),\n chunk_type: z.string().optional(),\n citations: z\n .array(z.lazy(() => unmarshalAiExtractCitationSchema))\n .optional(),\n })\n .transform(d => ({\n version: d.version,\n mode: d.mode,\n chunkType: d.chunk_type,\n citations: d.citations,\n }));\n\nexport const unmarshalAiParseDocumentFileMetadataSchema: z.ZodType<AiParseDocumentFileMetadata> =\n z\n .object({\n file_path: z.string().optional(),\n file_name: z.string().optional(),\n file_size: z\n .union([z.number(), z.bigint(), z.string()])\n .transform(v => BigInt(v))\n .optional(),\n file_modification_time: z.string().optional(),\n })\n .transform(d => ({\n filePath: d.file_path,\n fileName: d.file_name,\n fileSize: d.file_size,\n fileModificationTime: d.file_modification_time,\n }));\n\nexport const unmarshalAiParseDocumentPageErrorSchema: z.ZodType<AiParseDocumentPageError> =\n z\n .object({\n error_message: z.string().optional(),\n page_id: z\n .union([z.number(), z.bigint(), z.string()])\n .transform(v => BigInt(v))\n .optional(),\n })\n .transform(d => ({\n errorMessage: d.error_message,\n pageId: d.page_id,\n }));\n\nexport const unmarshalAiParseDocumentResponseSchema: z.ZodType<AiParseDocumentResponse> =\n z\n .object({\n document: jsonValueSchema.optional(),\n error_status: z\n .array(z.lazy(() => unmarshalAiParseDocumentPageErrorSchema))\n .optional(),\n metadata: z\n .lazy(() => unmarshalAiParseDocumentResponseMetadataSchema)\n .optional(),\n })\n .transform(d => ({\n document: d.document,\n errorStatus: d.error_status,\n metadata: d.metadata,\n }));\n\nexport const unmarshalAiParseDocumentResponseMetadataSchema: z.ZodType<AiParseDocumentResponseMetadata> =\n z\n .object({\n id: z.string().optional(),\n version: z.string().optional(),\n file_metadata: z\n .lazy(() => unmarshalAiParseDocumentFileMetadataSchema)\n .optional(),\n })\n .transform(d => ({\n id: d.id,\n version: d.version,\n fileMetadata: d.file_metadata,\n }));\n\nexport const marshalAiClassifyOptionsSchema: z.ZodType = z\n .object({\n instructions: z.string().optional(),\n version: z.string().optional(),\n multilabel: z.boolean().optional(),\n enableConfidenceScores: z.boolean().optional(),\n enableRationales: z.boolean().optional(),\n })\n .transform(d => ({\n instructions: d.instructions,\n version: d.version,\n multilabel: d.multilabel,\n enable_confidence_scores: d.enableConfidenceScores,\n enable_rationales: d.enableRationales,\n }));\n\nexport const marshalAiClassifyRequestSchema: z.ZodType = z\n .object({\n content: jsonValueSchema.optional(),\n labels: jsonValueSchema.optional(),\n options: z.lazy(() => marshalAiClassifyOptionsSchema).optional(),\n })\n .transform(d => ({\n content: d.content,\n labels: d.labels,\n options: d.options,\n }));\n\nexport const marshalAiExtractOptionsSchema: z.ZodType = z\n .object({\n instructions: z.string().optional(),\n version: z.string().optional(),\n mode: z.string().optional(),\n enableCitations: z.boolean().optional(),\n enableConfidenceScores: z.boolean().optional(),\n })\n .transform(d => ({\n instructions: d.instructions,\n version: d.version,\n mode: d.mode,\n enable_citations: d.enableCitations,\n enable_confidence_scores: d.enableConfidenceScores,\n }));\n\nexport const marshalAiExtractRequestSchema: z.ZodType = z\n .object({\n content: jsonValueSchema.optional(),\n schema: jsonValueSchema.optional(),\n options: z.lazy(() => marshalAiExtractOptionsSchema).optional(),\n })\n .transform(d => ({\n content: d.content,\n schema: d.schema,\n options: d.options,\n }));\n\nexport const marshalAiParseDocumentOptionsSchema: z.ZodType = z\n .object({\n version: z.string().optional(),\n descriptionElementTypes: z.string().optional(),\n imageOutputPath: z.string().optional(),\n pageRange: z.string().optional(),\n })\n .transform(d => ({\n version: d.version,\n description_element_types: d.descriptionElementTypes,\n image_output_path: d.imageOutputPath,\n page_range: d.pageRange,\n }));\n\nexport const marshalAiParseDocumentRequestSchema: z.ZodType = z\n .object({\n content: z.string().optional(),\n options: z.lazy(() => marshalAiParseDocumentOptionsSchema).optional(),\n })\n .transform(d => ({\n content: d.content,\n options: d.options,\n }));\n"],"mappings":";;;AAKA,MAAM,kBAAwC,EAAE,WAC9C,EAAE,MAAM;CACN,EAAE,MAAM;CACR,EAAE,QAAQ;CACV,EAAE,QAAQ;CACV,EAAE,SAAS;CACX,EAAE,OAAO,EAAE,QAAQ,EAAE,gBAAgB;CACrC,EAAE,MAAM,gBAAgB;CACzB,CAAC,CACH;AAiKD,MAAa,oCACX,EACG,OAAO;CACN,UAAU,gBAAgB,UAAU;CACpC,UAAU,EACP,WAAW,0CAA0C,CACrD,UAAU;CACd,CAAC,CACD,WAAU,OAAM;CACf,UAAU,EAAE;CACZ,UAAU,EAAE;CACb,EAAE;AAEP,MAAa,4CACX,EACG,OAAO,EACN,SAAS,EAAE,QAAQ,CAAC,UAAU,EAC/B,CAAC,CACD,WAAU,OAAM,EACf,SAAS,EAAE,SACZ,EAAE;AAEP,MAAa,+BAAyD,EACnE,OAAO;CACN,OAAO,EACJ,MACC,EAAE,MAAM;EAAC,EAAE,QAAQ;EAAE,EAAE,QAAQ;EAAE,EAAE,QAAQ;EAAC,CAAC,CAAC,WAAU,MAAK,OAAO,EAAE,CAAC,CACxE,CACA,UAAU;CACb,SAAS,EACN,MAAM;EAAC,EAAE,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,yBAAyB,EAAE,QAAQ,CAAC,UAAU;CAC9C,iBAAiB,EAAE,QAAQ,CAAC,UAAU;CACtC,WAAW,EAAE,QAAQ,CAAC,UAAU;CACjC,CAAC,CACD,WAAU,OAAM;CACf,SAAS,EAAE;CACX,2BAA2B,EAAE;CAC7B,mBAAmB,EAAE;CACrB,YAAY,EAAE;CACf,EAAE;AAEL,MAAa,sCAAiD,EAC3D,OAAO;CACN,SAAS,EAAE,QAAQ,CAAC,UAAU;CAC9B,SAAS,EAAE,WAAW,oCAAoC,CAAC,UAAU;CACtE,CAAC,CACD,WAAU,OAAM;CACf,SAAS,EAAE;CACX,SAAS,EAAE;CACZ,EAAE"}
@@ -0,0 +1,37 @@
1
+ import { HttpClient } from "@databricks/sdk-core/http";
2
+ import { ClientOptions } from "@databricks/sdk-options/client";
3
+
4
+ //#region src/v1/transport.d.ts
5
+ /**
6
+ * The configuration a client needs to issue requests, resolved from
7
+ * {@link ClientOptions} and a configuration profile.
8
+ */
9
+ interface ResolvedClientConfig {
10
+ /** Host with any trailing slash removed. */
11
+ host: string;
12
+ /**
13
+ * Default account ID for account-level paths that contain an account_id
14
+ * segment. A request's own accountId still wins.
15
+ */
16
+ accountId?: string;
17
+ /**
18
+ * Workspace ID used to route workspace-level calls on unified hosts (SPOG).
19
+ */
20
+ workspaceId?: string;
21
+ /** HTTP client with authentication, and any configured timeout, applied. */
22
+ httpClient: HttpClient;
23
+ }
24
+ /**
25
+ * Resolves {@link ClientOptions} into a {@link ResolvedClientConfig}.
26
+ *
27
+ * A configuration profile is always resolved from the config file and
28
+ * environment variables (per options.profileOptions); it supplies host,
29
+ * accountId, workspaceId, and credentials wherever the caller did not set them
30
+ * explicitly. Explicit options always take precedence.
31
+ *
32
+ * @throws if host is neither provided nor present in the resolved profile.
33
+ */
34
+ declare function resolveClientConfig(options: ClientOptions): Promise<ResolvedClientConfig>;
35
+ //#endregion
36
+ export { ResolvedClientConfig, resolveClientConfig };
37
+ //# sourceMappingURL=transport.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transport.d.ts","names":[],"sources":["../../src/v1/transport.ts"],"mappings":";;;;;;AAkBA;;UAAiB,oBAAA;EAgBO;EAdtB,IAAA;EAMA;;;;EAAA,SAAA;EAQsB;AAaxB;;EAhBE,WAAA;EAiBS;EAdT,UAAA,EAAY,UAAA;AAAA;;;;;;;;;;;iBAaQ,mBAAA,CACpB,OAAA,EAAS,aAAA,GACR,OAAA,CAAQ,oBAAA"}
@@ -0,0 +1,65 @@
1
+ import { defaultCredentials } from "@databricks/sdk-auth/credentials";
2
+ import { newFetchHttpClient } from "@databricks/sdk-core/http";
3
+ import { resolve } from "@databricks/sdk-core/profiles";
4
+
5
+ //#region src/v1/transport.ts
6
+ /**
7
+ * Resolves {@link ClientOptions} into a {@link ResolvedClientConfig}.
8
+ *
9
+ * A configuration profile is always resolved from the config file and
10
+ * environment variables (per options.profileOptions); it supplies host,
11
+ * accountId, workspaceId, and credentials wherever the caller did not set them
12
+ * explicitly. Explicit options always take precedence.
13
+ *
14
+ * @throws if host is neither provided nor present in the resolved profile.
15
+ */
16
+ async function resolveClientConfig(options) {
17
+ const profile = await resolve(options.profileOptions);
18
+ const host = options.host ?? profile.host;
19
+ if (host === void 0) throw new Error("Host is required.");
20
+ let httpClient = new AuthHttpClient(options.httpClient ?? newFetchHttpClient(), options.credentials ?? defaultCredentials({ profile }));
21
+ if (options.timeout !== void 0) httpClient = new TimeoutHttpClient(httpClient, options.timeout);
22
+ const accountId = options.accountId ?? profile.accountId;
23
+ const workspaceId = options.workspaceId ?? profile.workspaceId;
24
+ return {
25
+ host: host.replace(/\/$/, ""),
26
+ httpClient,
27
+ ...accountId !== void 0 && { accountId },
28
+ ...workspaceId !== void 0 && { workspaceId }
29
+ };
30
+ }
31
+ /** Wraps an HttpClient and adds authentication headers to requests. */
32
+ var AuthHttpClient = class {
33
+ constructor(base, credentials) {
34
+ this.base = base;
35
+ this.credentials = credentials;
36
+ }
37
+ async send(request) {
38
+ const authHeaders = await this.credentials.authHeaders();
39
+ const headers = new Headers(request.headers);
40
+ for (const h of authHeaders) headers.set(h.key, h.value);
41
+ return this.base.send({
42
+ ...request,
43
+ headers
44
+ });
45
+ }
46
+ };
47
+ /** Wraps an HttpClient and applies a default timeout to requests. */
48
+ var TimeoutHttpClient = class {
49
+ constructor(base, timeout) {
50
+ this.base = base;
51
+ this.timeout = timeout;
52
+ }
53
+ async send(request) {
54
+ const timeoutSignal = AbortSignal.timeout(this.timeout);
55
+ const signal = request.signal !== void 0 ? AbortSignal.any([request.signal, timeoutSignal]) : timeoutSignal;
56
+ return this.base.send({
57
+ ...request,
58
+ signal
59
+ });
60
+ }
61
+ };
62
+
63
+ //#endregion
64
+ export { resolveClientConfig };
65
+ //# sourceMappingURL=transport.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transport.js","names":[],"sources":["../../src/v1/transport.ts"],"sourcesContent":["// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.\n\nimport type {Credentials} from '@databricks/sdk-auth';\nimport {defaultCredentials} from '@databricks/sdk-auth/credentials';\nimport type {\n HttpClient,\n HttpRequest,\n HttpResponse,\n} from '@databricks/sdk-core/http';\nimport {newFetchHttpClient} from '@databricks/sdk-core/http';\nimport type {Profile} from '@databricks/sdk-core/profiles';\nimport {resolve} from '@databricks/sdk-core/profiles';\nimport type {ClientOptions} from '@databricks/sdk-options/client';\n\n/**\n * The configuration a client needs to issue requests, resolved from\n * {@link ClientOptions} and a configuration profile.\n */\nexport interface ResolvedClientConfig {\n /** Host with any trailing slash removed. */\n host: string;\n\n /**\n * Default account ID for account-level paths that contain an account_id\n * segment. A request's own accountId still wins.\n */\n accountId?: string;\n\n /**\n * Workspace ID used to route workspace-level calls on unified hosts (SPOG).\n */\n workspaceId?: string;\n\n /** HTTP client with authentication, and any configured timeout, applied. */\n httpClient: HttpClient;\n}\n\n/**\n * Resolves {@link ClientOptions} into a {@link ResolvedClientConfig}.\n *\n * A configuration profile is always resolved from the config file and\n * environment variables (per options.profileOptions); it supplies host,\n * accountId, workspaceId, and credentials wherever the caller did not set them\n * explicitly. Explicit options always take precedence.\n *\n * @throws if host is neither provided nor present in the resolved profile.\n */\nexport async function resolveClientConfig(\n options: ClientOptions\n): Promise<ResolvedClientConfig> {\n const profile: Profile = await resolve(options.profileOptions);\n\n const host = options.host ?? profile.host;\n if (host === undefined) {\n throw new Error('Host is required.');\n }\n\n // The provided httpClient (or the default fetch client) is the base wire;\n // authentication and the optional timeout are layered on top of it. The\n // default credential chain reuses the profile resolved above so that the\n // same profileOptions govern host and authentication alike.\n const base = options.httpClient ?? newFetchHttpClient();\n const credentials = options.credentials ?? defaultCredentials({profile});\n let httpClient: HttpClient = new AuthHttpClient(base, credentials);\n if (options.timeout !== undefined) {\n httpClient = new TimeoutHttpClient(httpClient, options.timeout);\n }\n\n const accountId = options.accountId ?? profile.accountId;\n const workspaceId = options.workspaceId ?? profile.workspaceId;\n\n return {\n host: host.replace(/\\/$/, ''),\n httpClient,\n ...(accountId !== undefined && {accountId}),\n ...(workspaceId !== undefined && {workspaceId}),\n };\n}\n\n/** Wraps an HttpClient and adds authentication headers to requests. */\nclass AuthHttpClient implements HttpClient {\n constructor(\n private readonly base: HttpClient,\n private readonly credentials: Credentials\n ) {}\n\n async send(request: HttpRequest): Promise<HttpResponse> {\n const authHeaders = await this.credentials.authHeaders();\n // Do not modify the original request.\n const headers = new Headers(request.headers);\n for (const h of authHeaders) {\n headers.set(h.key, h.value);\n }\n return this.base.send({...request, headers});\n }\n}\n\n/** Wraps an HttpClient and applies a default timeout to requests. */\nclass TimeoutHttpClient implements HttpClient {\n constructor(\n private readonly base: HttpClient,\n private readonly timeout: number\n ) {}\n\n async send(request: HttpRequest): Promise<HttpResponse> {\n const timeoutSignal = AbortSignal.timeout(this.timeout);\n const signal =\n request.signal !== undefined\n ? AbortSignal.any([request.signal, timeoutSignal])\n : timeoutSignal;\n return this.base.send({...request, signal});\n }\n}\n"],"mappings":";;;;;;;;;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databricks/sdk-core/logger";
2
+ import { HttpClient, HttpRequest } from "@databricks/sdk-core/http";
3
+ import { z } from "zod";
4
+ import { CallOptions } from "@databricks/sdk-options/call";
5
+
6
+ //#region src/v1/utils.d.ts
7
+ interface HttpCallOptions {
8
+ readonly request: HttpRequest;
9
+ readonly httpClient: HttpClient;
10
+ readonly logger: Logger;
11
+ }
12
+ /**
13
+ * Translates public CallOptions to the internal Options shape accepted by
14
+ * execute(). Even though the shapes match today, this isolates the public
15
+ * API from the executor's internal type so they can diverge.
16
+ */
17
+ declare function executeCall(call: (signal?: AbortSignal) => Promise<void>, options?: CallOptions): Promise<void>;
18
+ declare function executeHttpCall(opts: HttpCallOptions): Promise<Uint8Array>;
19
+ declare function buildHttpRequest(method: string, url: string, headers: Headers, signal?: AbortSignal, body?: string | ReadableStream<Uint8Array>): HttpRequest;
20
+ declare function parseResponse<T>(body: Uint8Array, schema: z.ZodType<T>): T;
21
+ declare function marshalRequest(data: unknown, schema: z.ZodType): string;
22
+ declare function flattenQueryParams(prefix: string, value: unknown, params: URLSearchParams): void;
23
+ //#endregion
24
+ export { HttpCallOptions, buildHttpRequest, executeCall, executeHttpCall, flattenQueryParams, marshalRequest, parseResponse };
25
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","names":[],"sources":["../../src/v1/utils.ts"],"mappings":";;;;;;UAoBiB,eAAA;EAAA,SACN,OAAA,EAAS,WAAA;EAAA,SACT,UAAA,EAAY,UAAA;EAAA,SACZ,MAAA,EAAQ,MAAA;AAAA;;;;;;iBAQG,WAAA,CACpB,IAAA,GAAO,MAAA,GAAS,WAAA,KAAgB,OAAA,QAChC,OAAA,GAAU,WAAA,GACT,OAAA;AAAA,iBAoCmB,eAAA,CACpB,IAAA,EAAM,eAAA,GACL,OAAA,CAAQ,UAAA;AAAA,iBA6BK,gBAAA,CACd,MAAA,UACA,GAAA,UACA,OAAA,EAAS,OAAA,EACT,MAAA,GAAS,WAAA,EACT,IAAA,YAAgB,cAAA,CAAe,UAAA,IAC9B,WAAA;AAAA,iBAWa,aAAA,GAAA,CAAiB,IAAA,EAAM,UAAA,EAAY,MAAA,EAAQ,CAAA,CAAE,OAAA,CAAQ,CAAA,IAAK,CAAA;AAAA,iBAO1D,cAAA,CAAe,IAAA,WAAe,MAAA,EAAQ,CAAA,CAAE,OAAA;AAAA,iBAIxC,kBAAA,CACd,MAAA,UACA,KAAA,WACA,MAAA,EAAQ,eAAA"}
@@ -0,0 +1,87 @@
1
+ import { execute } from "@databricks/sdk-core/ops";
2
+ import { ApiError } from "@databricks/sdk-core/apierror";
3
+ import JSONBig from "json-bigint";
4
+
5
+ //#region src/v1/utils.ts
6
+ const jsonBigint = JSONBig({ useNativeBigInt: true });
7
+ /**
8
+ * Translates public CallOptions to the internal Options shape accepted by
9
+ * execute(). Even though the shapes match today, this isolates the public
10
+ * API from the executor's internal type so they can diverge.
11
+ */
12
+ async function executeCall(call, options) {
13
+ const opts = {
14
+ ...options?.retrier !== void 0 && { retrier: options.retrier },
15
+ ...options?.rateLimiter !== void 0 && { rateLimiter: options.rateLimiter },
16
+ ...options?.timeout !== void 0 && { timeout: options.timeout }
17
+ };
18
+ return execute(options?.signal, call, opts);
19
+ }
20
+ async function readAll(body) {
21
+ if (body === null) return new Uint8Array(0);
22
+ const reader = body.getReader();
23
+ const chunks = [];
24
+ for (;;) {
25
+ const { done, value } = await reader.read();
26
+ if (done) break;
27
+ chunks.push(value);
28
+ }
29
+ const totalLength = chunks.reduce((acc, chunk) => acc + chunk.length, 0);
30
+ const result = new Uint8Array(totalLength);
31
+ let offset = 0;
32
+ for (const chunk of chunks) {
33
+ result.set(chunk, offset);
34
+ offset += chunk.length;
35
+ }
36
+ return result;
37
+ }
38
+ async function executeHttpCall(opts) {
39
+ opts.logger.debug("HTTP request", {
40
+ method: opts.request.method,
41
+ url: opts.request.url
42
+ });
43
+ let resp;
44
+ try {
45
+ resp = await opts.httpClient.send(opts.request);
46
+ } catch (e) {
47
+ opts.logger.debug("HTTP request failed");
48
+ throw e;
49
+ }
50
+ const body = await readAll(resp.body);
51
+ opts.logger.debug("HTTP response", {
52
+ statusCode: resp.statusCode,
53
+ body: new TextDecoder().decode(body)
54
+ });
55
+ const apiErr = ApiError.fromHttpError(resp.statusCode, resp.headers, body);
56
+ if (apiErr !== void 0) throw apiErr;
57
+ return body;
58
+ }
59
+ function buildHttpRequest(method, url, headers, signal, body) {
60
+ const req = {
61
+ url,
62
+ method,
63
+ headers
64
+ };
65
+ if (body !== void 0) req.body = body;
66
+ if (signal !== void 0) req.signal = signal;
67
+ return req;
68
+ }
69
+ function parseResponse(body, schema) {
70
+ const text = new TextDecoder().decode(body);
71
+ const parsed = text === "" ? {} : jsonBigint.parse(text);
72
+ return schema.parse(parsed);
73
+ }
74
+ function marshalRequest(data, schema) {
75
+ return jsonBigint.stringify(schema.parse(data));
76
+ }
77
+ function flattenQueryParams(prefix, value, params) {
78
+ if (value === null || value === void 0) return;
79
+ if (Array.isArray(value)) for (const item of value) params.append(prefix, String(item));
80
+ else if (typeof value === "object") for (const [key, val] of Object.entries(value)) flattenQueryParams(`${prefix}.${key}`, val, params);
81
+ else if (typeof value === "string" || typeof value === "number" || typeof value === "boolean" || typeof value === "bigint") params.append(prefix, String(value));
82
+ else throw new Error(`Unsupported query parameter type: ${typeof value}`);
83
+ }
84
+
85
+ //#endregion
86
+ export { buildHttpRequest, executeCall, executeHttpCall, flattenQueryParams, marshalRequest, parseResponse };
87
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","names":[],"sources":["../../src/v1/utils.ts"],"sourcesContent":["// Code generated from API definition by Databricks SDK Generator. DO NOT EDIT.\n\nimport type {Options} from '@databricks/sdk-core/ops';\nimport {execute} from '@databricks/sdk-core/ops';\nimport {ApiError} from '@databricks/sdk-core/apierror';\nimport type {\n HttpClient,\n HttpRequest,\n HttpResponse,\n} from '@databricks/sdk-core/http';\nimport type {Logger} from '@databricks/sdk-core/logger';\nimport type {CallOptions} from '@databricks/sdk-options/call';\nimport JSONBig from 'json-bigint';\nimport type {z} from 'zod';\n\n// JSON codec that preserves int64 precision. On the way in, large integer\n// literals come back as bigint instead of being rounded to JS Number. On the\n// way out, bigint values are emitted as raw JSON number digits.\nconst jsonBigint = JSONBig({useNativeBigInt: true});\n\nexport interface HttpCallOptions {\n readonly request: HttpRequest;\n readonly httpClient: HttpClient;\n readonly logger: Logger;\n}\n\n/**\n * Translates public CallOptions to the internal Options shape accepted by\n * execute(). Even though the shapes match today, this isolates the public\n * API from the executor's internal type so they can diverge.\n */\nexport async function executeCall(\n call: (signal?: AbortSignal) => Promise<void>,\n options?: CallOptions\n): Promise<void> {\n const opts: Options = {\n ...(options?.retrier !== undefined && {retrier: options.retrier}),\n ...(options?.rateLimiter !== undefined && {\n rateLimiter: options.rateLimiter,\n }),\n ...(options?.timeout !== undefined && {timeout: options.timeout}),\n };\n return execute(options?.signal, call, opts);\n}\n\nasync function readAll(\n body: ReadableStream<Uint8Array> | null\n): Promise<Uint8Array> {\n if (body === null) {\n return new Uint8Array(0);\n }\n const reader = body.getReader();\n const chunks: Uint8Array[] = [];\n for (;;) {\n const {done, value} = await reader.read();\n if (done) {\n break;\n }\n chunks.push(value);\n }\n const totalLength = chunks.reduce((acc, chunk) => acc + chunk.length, 0);\n const result = new Uint8Array(totalLength);\n let offset = 0;\n for (const chunk of chunks) {\n result.set(chunk, offset);\n offset += chunk.length;\n }\n return result;\n}\n\nexport async function executeHttpCall(\n opts: HttpCallOptions\n): Promise<Uint8Array> {\n opts.logger.debug('HTTP request', {\n method: opts.request.method,\n url: opts.request.url,\n });\n\n let resp: HttpResponse;\n try {\n resp = await opts.httpClient.send(opts.request);\n } catch (e: unknown) {\n opts.logger.debug('HTTP request failed');\n throw e;\n }\n\n const body = await readAll(resp.body);\n\n opts.logger.debug('HTTP response', {\n statusCode: resp.statusCode,\n body: new TextDecoder().decode(body),\n });\n\n const apiErr = ApiError.fromHttpError(resp.statusCode, resp.headers, body);\n if (apiErr !== undefined) {\n throw apiErr;\n }\n\n return body;\n}\n\nexport function buildHttpRequest(\n method: string,\n url: string,\n headers: Headers,\n signal?: AbortSignal,\n body?: string | ReadableStream<Uint8Array>\n): HttpRequest {\n const req: HttpRequest = {url, method, headers};\n if (body !== undefined) {\n req.body = body;\n }\n if (signal !== undefined) {\n req.signal = signal;\n }\n return req;\n}\n\nexport function parseResponse<T>(body: Uint8Array, schema: z.ZodType<T>): T {\n const text = new TextDecoder().decode(body);\n // 204 responses return an empty body; treat as `{}`.\n const parsed: unknown = text === '' ? {} : jsonBigint.parse(text);\n return schema.parse(parsed);\n}\n\nexport function marshalRequest(data: unknown, schema: z.ZodType): string {\n return jsonBigint.stringify(schema.parse(data));\n}\n\nexport function flattenQueryParams(\n prefix: string,\n value: unknown,\n params: URLSearchParams\n): void {\n if (value === null || value === undefined) {\n return;\n }\n if (Array.isArray(value)) {\n // arrays of objects are not yet supported\n for (const item of value) {\n params.append(prefix, String(item));\n }\n } else if (typeof value === 'object') {\n for (const [key, val] of Object.entries(value as Record<string, unknown>)) {\n flattenQueryParams(`${prefix}.${key}`, val, params);\n }\n } else if (\n typeof value === 'string' ||\n typeof value === 'number' ||\n typeof value === 'boolean' ||\n typeof value === 'bigint'\n ) {\n params.append(prefix, String(value));\n } else {\n throw new Error(`Unsupported query parameter type: ${typeof value}`);\n }\n}\n"],"mappings":";;;;;AAkBA,MAAM,aAAa,QAAQ,EAAC,iBAAiB,MAAK,CAAC;;;;;;AAanD,eAAsB,YACpB,MACA,SACe;CACf,MAAM,OAAgB;EACpB,GAAI,SAAS,YAAY,UAAa,EAAC,SAAS,QAAQ,SAAQ;EAChE,GAAI,SAAS,gBAAgB,UAAa,EACxC,aAAa,QAAQ,aACtB;EACD,GAAI,SAAS,YAAY,UAAa,EAAC,SAAS,QAAQ,SAAQ;EACjE;AACD,QAAO,QAAQ,SAAS,QAAQ,MAAM,KAAK;;AAG7C,eAAe,Q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E,GAAG,WAAW,MAAM,KAAK;AACjE,QAAO,OAAO,MAAM,OAAO;;AAG7B,SAAgB,eAAe,MAAe,QAA2B;AACvE,QAAO,WAAW,UAAU,OAAO,MAAM,KAAK,CAAC;;AAGjD,SAAgB,mBACd,QACA,OACA,QACM;AACN,KAAI,UAAU,QAAQ,UAAU,OAC9B;AAEF,KAAI,MAAM,QAAQ,MAAM,CAEtB,MAAK,MAAM,QAAQ,MACjB,QAAO,OAAO,QAAQ,OAAO,KAAK,CAAC;UAE5B,OAAO,UAAU,SAC1B,MAAK,MAAM,CAAC,KAAK,QAAQ,OAAO,QAAQ,MAAiC,CACvE,oBAAmB,GAAG,OAAO,GAAG,OAAO,KAAK,OAAO;UAGrD,OAAO,UAAU,YACjB,OAAO,UAAU,YACjB,OAAO,UAAU,aACjB,OAAO,UAAU,SAEjB,QAAO,OAAO,QAAQ,OAAO,MAAM,CAAC;KAEpC,OAAM,IAAI,MAAM,qCAAqC,OAAO,QAAQ"}
package/package.json CHANGED
@@ -1,7 +1,46 @@
1
1
  {
2
2
  "name": "@databricks/sdk-aifunctions",
3
- "version": "0.0.0-beta",
4
- "description": "Bootstrap placeholder; real contents in a later release.",
5
- "main": "index.js",
6
- "license": "Apache-2.0"
3
+ "version": "0.1.0",
4
+ "description": "",
5
+ "type": "module",
6
+ "exports": {
7
+ "./v1": {
8
+ "types": "./dist/v1/index.d.ts",
9
+ "import": "./dist/v1/index.js",
10
+ "default": "./dist/v1/index.js"
11
+ }
12
+ },
13
+ "files": [
14
+ "dist",
15
+ "LICENSE"
16
+ ],
17
+ "scripts": {
18
+ "build": "tsdown",
19
+ "lint": "eslint src --ext .ts",
20
+ "lint:fix": "eslint src --ext .ts --fix",
21
+ "format": "prettier --write \"src/**/*.ts\"",
22
+ "format:check": "prettier --check \"src/**/*.ts\"",
23
+ "typecheck": "tsc --noEmit",
24
+ "clean": "rm -rf dist tsconfig.tsbuildinfo",
25
+ "test": "echo 'no tests'",
26
+ "test:browser": "echo 'no tests'"
27
+ },
28
+ "author": "Databricks",
29
+ "license": "Apache-2.0",
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "https://github.com/databricks/sdk-js.git",
33
+ "directory": "packages/aifunctions"
34
+ },
35
+ "dependencies": {
36
+ "@databricks/sdk-auth": ">=0.50.0 <1.0.0",
37
+ "@databricks/sdk-core": ">=0.50.0 <1.0.0",
38
+ "@databricks/sdk-options": ">=0.50.0 <1.0.0",
39
+ "@js-temporal/polyfill": "^0.5.0",
40
+ "json-bigint": "^1.0.0",
41
+ "zod": "^4.3.6"
42
+ },
43
+ "engines": {
44
+ "node": ">=22.0.0"
45
+ }
7
46
  }
package/index.js DELETED
@@ -1 +0,0 @@
1
- module.exports = {};