@databricks/sdk-core 0.0.0-dev → 0.1.0-dev.2
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 +203 -0
- package/README.md +11 -1
- package/dist/api/execute.d.ts +12 -0
- package/dist/api/execute.d.ts.map +1 -0
- package/dist/api/execute.js +77 -0
- package/dist/api/execute.js.map +1 -0
- package/dist/api/index.d.ts +12 -0
- package/dist/api/index.d.ts.map +1 -0
- package/dist/api/index.js +8 -0
- package/dist/api/index.js.map +1 -0
- package/dist/api/limiter.d.ts +9 -0
- package/dist/api/limiter.d.ts.map +1 -0
- package/dist/api/limiter.js +2 -0
- package/dist/api/limiter.js.map +1 -0
- package/dist/api/options.d.ts +22 -0
- package/dist/api/options.d.ts.map +1 -0
- package/dist/api/options.js +2 -0
- package/dist/api/options.js.map +1 -0
- package/dist/api/retrier.d.ts +58 -0
- package/dist/api/retrier.d.ts.map +1 -0
- package/dist/api/retrier.js +70 -0
- package/dist/api/retrier.js.map +1 -0
- package/dist/apierror/apierror.d.ts +53 -0
- package/dist/apierror/apierror.d.ts.map +1 -0
- package/dist/apierror/apierror.js +217 -0
- package/dist/apierror/apierror.js.map +1 -0
- package/dist/apierror/codes/codes.d.ts +140 -0
- package/dist/apierror/codes/codes.d.ts.map +1 -0
- package/dist/apierror/codes/codes.js +167 -0
- package/dist/apierror/codes/codes.js.map +1 -0
- package/dist/apierror/codes/index.d.ts +7 -0
- package/dist/apierror/codes/index.d.ts.map +1 -0
- package/dist/apierror/codes/index.js +7 -0
- package/dist/apierror/codes/index.js.map +1 -0
- package/dist/apierror/details.d.ts +177 -0
- package/dist/apierror/details.d.ts.map +1 -0
- package/dist/apierror/details.js +250 -0
- package/dist/apierror/details.js.map +1 -0
- package/dist/apierror/index.d.ts +8 -0
- package/dist/apierror/index.d.ts.map +1 -0
- package/dist/apierror/index.js +7 -0
- package/dist/apierror/index.js.map +1 -0
- package/dist/clientinfo/agent.d.ts +56 -0
- package/dist/clientinfo/agent.d.ts.map +1 -0
- package/dist/clientinfo/agent.js +114 -0
- package/dist/clientinfo/agent.js.map +1 -0
- package/dist/clientinfo/base.d.ts +39 -0
- package/dist/clientinfo/base.d.ts.map +1 -0
- package/dist/clientinfo/base.js +62 -0
- package/dist/clientinfo/base.js.map +1 -0
- package/dist/clientinfo/clientinfo.d.ts +61 -0
- package/dist/clientinfo/clientinfo.d.ts.map +1 -0
- package/dist/clientinfo/clientinfo.js +96 -0
- package/dist/clientinfo/clientinfo.js.map +1 -0
- package/dist/clientinfo/default.browser.d.ts +17 -0
- package/dist/clientinfo/default.browser.d.ts.map +1 -0
- package/dist/clientinfo/default.browser.js +20 -0
- package/dist/clientinfo/default.browser.js.map +1 -0
- package/dist/clientinfo/default.d.ts +14 -0
- package/dist/clientinfo/default.d.ts.map +1 -0
- package/dist/clientinfo/default.js +104 -0
- package/dist/clientinfo/default.js.map +1 -0
- package/dist/clientinfo/index.browser.d.ts +5 -0
- package/dist/clientinfo/index.browser.d.ts.map +1 -0
- package/dist/clientinfo/index.browser.js +4 -0
- package/dist/clientinfo/index.browser.js.map +1 -0
- package/dist/clientinfo/index.d.ts +5 -0
- package/dist/clientinfo/index.d.ts.map +1 -0
- package/dist/clientinfo/index.js +4 -0
- package/dist/clientinfo/index.js.map +1 -0
- package/dist/http/http.d.ts +40 -0
- package/dist/http/http.d.ts.map +1 -0
- package/dist/http/http.js +37 -0
- package/dist/http/http.js.map +1 -0
- package/dist/http/index.d.ts +8 -0
- package/dist/http/index.d.ts.map +1 -0
- package/dist/http/index.js +7 -0
- package/dist/http/index.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/logger/index.d.ts +8 -0
- package/dist/logger/index.d.ts.map +1 -0
- package/dist/logger/index.js +7 -0
- package/dist/logger/index.js.map +1 -0
- package/dist/logger/logger.d.ts +49 -0
- package/dist/logger/logger.d.ts.map +1 -0
- package/dist/logger/logger.js +65 -0
- package/dist/logger/logger.js.map +1 -0
- package/dist/profiles/errors.d.ts +17 -0
- package/dist/profiles/errors.d.ts.map +1 -0
- package/dist/profiles/errors.js +19 -0
- package/dist/profiles/errors.js.map +1 -0
- package/dist/profiles/index.browser.d.ts +10 -0
- package/dist/profiles/index.browser.d.ts.map +1 -0
- package/dist/profiles/index.browser.js +8 -0
- package/dist/profiles/index.browser.js.map +1 -0
- package/dist/profiles/index.d.ts +15 -0
- package/dist/profiles/index.d.ts.map +1 -0
- package/dist/profiles/index.js +13 -0
- package/dist/profiles/index.js.map +1 -0
- package/dist/profiles/ini.d.ts +36 -0
- package/dist/profiles/ini.d.ts.map +1 -0
- package/dist/profiles/ini.js +113 -0
- package/dist/profiles/ini.js.map +1 -0
- package/dist/profiles/profile.d.ts +131 -0
- package/dist/profiles/profile.d.ts.map +1 -0
- package/dist/profiles/profile.js +307 -0
- package/dist/profiles/profile.js.map +1 -0
- package/dist/profiles/resolve.d.ts +29 -0
- package/dist/profiles/resolve.d.ts.map +1 -0
- package/dist/profiles/resolve.js +206 -0
- package/dist/profiles/resolve.js.map +1 -0
- package/dist/profiles/secret.d.ts +25 -0
- package/dist/profiles/secret.d.ts.map +1 -0
- package/dist/profiles/secret.js +38 -0
- package/dist/profiles/secret.js.map +1 -0
- package/dist/wkt/fieldmask.d.ts +32 -0
- package/dist/wkt/fieldmask.d.ts.map +1 -0
- package/dist/wkt/fieldmask.js +68 -0
- package/dist/wkt/fieldmask.js.map +1 -0
- package/dist/wkt/index.d.ts +4 -0
- package/dist/wkt/index.d.ts.map +1 -0
- package/dist/wkt/index.js +2 -0
- package/dist/wkt/index.js.map +1 -0
- package/dist/wkt/value.d.ts +13 -0
- package/dist/wkt/value.d.ts.map +1 -0
- package/dist/wkt/value.js +2 -0
- package/dist/wkt/value.js.map +1 -0
- package/package.json +82 -4
- package/src/api/execute.ts +102 -0
- package/src/api/index.ts +12 -0
- package/src/api/limiter.ts +8 -0
- package/src/api/options.ts +22 -0
- package/src/api/retrier.ts +108 -0
- package/src/apierror/apierror.ts +253 -0
- package/src/apierror/codes/codes.ts +189 -0
- package/src/apierror/codes/index.ts +7 -0
- package/src/apierror/details.ts +459 -0
- package/src/apierror/index.ts +24 -0
- package/src/clientinfo/agent.ts +125 -0
- package/src/clientinfo/base.ts +73 -0
- package/src/clientinfo/clientinfo.ts +129 -0
- package/src/clientinfo/default.browser.ts +24 -0
- package/src/clientinfo/default.ts +128 -0
- package/src/clientinfo/index.browser.ts +4 -0
- package/src/clientinfo/index.ts +4 -0
- package/src/http/http.ts +75 -0
- package/src/http/index.ts +8 -0
- package/src/index.ts +5 -0
- package/src/logger/index.ts +8 -0
- package/src/logger/logger.ts +99 -0
- package/src/profiles/errors.ts +28 -0
- package/src/profiles/index.browser.ts +10 -0
- package/src/profiles/index.ts +15 -0
- package/src/profiles/ini.ts +126 -0
- package/src/profiles/profile.ts +467 -0
- package/src/profiles/resolve.ts +251 -0
- package/src/profiles/secret.ts +40 -0
- package/src/wkt/fieldmask.ts +89 -0
- package/src/wkt/index.ts +3 -0
- package/src/wkt/value.ts +19 -0
- package/index.js +0 -1
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared state management for {@link ClientInfo} defaults. This module
|
|
3
|
+
* is browser-safe and contains no Node.js-specific APIs.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import { ClientInfo } from './clientinfo';
|
|
8
|
+
export declare const MODULE_NAME = "sdk-js-core";
|
|
9
|
+
export declare const VERSION: string;
|
|
10
|
+
/**
|
|
11
|
+
* Sets the product name and version globally. The version must be a
|
|
12
|
+
* valid semver string.
|
|
13
|
+
*
|
|
14
|
+
* Must be called before any client is created. Not safe for concurrent
|
|
15
|
+
* use.
|
|
16
|
+
*/
|
|
17
|
+
export declare function setProduct(name: string, version: string): void;
|
|
18
|
+
/**
|
|
19
|
+
* Adds a partner identifier globally. Partner attribution is a
|
|
20
|
+
* first-class concept used for support ticket routing.
|
|
21
|
+
*
|
|
22
|
+
* Must be called before any client is created. Not safe for concurrent
|
|
23
|
+
* use.
|
|
24
|
+
*/
|
|
25
|
+
export declare function setPartner(partner: string): void;
|
|
26
|
+
/**
|
|
27
|
+
* Adds a global key/value segment that will be included in every
|
|
28
|
+
* {@link createDefault} call. Same key with different values is allowed
|
|
29
|
+
* (e.g., multiple partners). Exact key+value duplicates are silently
|
|
30
|
+
* ignored.
|
|
31
|
+
*
|
|
32
|
+
* Must be called before any client is created. Not safe for concurrent
|
|
33
|
+
* use.
|
|
34
|
+
*/
|
|
35
|
+
export declare function addToDefault(key: string, value: string): void;
|
|
36
|
+
export declare function getBase(): ClientInfo;
|
|
37
|
+
export declare function resetBase(): void;
|
|
38
|
+
export declare function baseToString(): string;
|
|
39
|
+
//# sourceMappingURL=base.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.d.ts","sourceRoot":"","sources":["../../src/clientinfo/base.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,UAAU,EAA4B,MAAM,cAAc,CAAC;AAGnE,eAAO,MAAM,WAAW,gBAAgB,CAAC;AACzC,eAAO,MAAM,OAAO,EAAE,MAAwB,CAAC;AAM/C;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAQ9D;AAED;;;;;;GAMG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAEhD;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAE7D;AAGD,wBAAgB,OAAO,IAAI,UAAU,CAEpC;AAGD,wBAAgB,SAAS,IAAI,IAAI,CAEhC;AAID,wBAAgB,YAAY,IAAI,MAAM,CAErC"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared state management for {@link ClientInfo} defaults. This module
|
|
3
|
+
* is browser-safe and contains no Node.js-specific APIs.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
import { ClientInfo, ClientInfoError, isSemVer } from './clientinfo';
|
|
8
|
+
import pkgJson from '../../package.json' with { type: 'json' };
|
|
9
|
+
export const MODULE_NAME = 'sdk-js-core';
|
|
10
|
+
export const VERSION = pkgJson.version;
|
|
11
|
+
// Holds segments added via addToDefault, setProduct, and setPartner.
|
|
12
|
+
// createDefault returns a copy of this with env detection appended.
|
|
13
|
+
let base = ClientInfo.EMPTY;
|
|
14
|
+
/**
|
|
15
|
+
* Sets the product name and version globally. The version must be a
|
|
16
|
+
* valid semver string.
|
|
17
|
+
*
|
|
18
|
+
* Must be called before any client is created. Not safe for concurrent
|
|
19
|
+
* use.
|
|
20
|
+
*/
|
|
21
|
+
export function setProduct(name, version) {
|
|
22
|
+
if (!isSemVer(version)) {
|
|
23
|
+
throw new ClientInfoError('INVALID_VERSION', `Invalid version: ${version}.`);
|
|
24
|
+
}
|
|
25
|
+
addToDefault(name, version);
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Adds a partner identifier globally. Partner attribution is a
|
|
29
|
+
* first-class concept used for support ticket routing.
|
|
30
|
+
*
|
|
31
|
+
* Must be called before any client is created. Not safe for concurrent
|
|
32
|
+
* use.
|
|
33
|
+
*/
|
|
34
|
+
export function setPartner(partner) {
|
|
35
|
+
addToDefault('partner', partner);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Adds a global key/value segment that will be included in every
|
|
39
|
+
* {@link createDefault} call. Same key with different values is allowed
|
|
40
|
+
* (e.g., multiple partners). Exact key+value duplicates are silently
|
|
41
|
+
* ignored.
|
|
42
|
+
*
|
|
43
|
+
* Must be called before any client is created. Not safe for concurrent
|
|
44
|
+
* use.
|
|
45
|
+
*/
|
|
46
|
+
export function addToDefault(key, value) {
|
|
47
|
+
base = base.with({ key, value });
|
|
48
|
+
}
|
|
49
|
+
// Returns the base ClientInfo for use in createDefault.
|
|
50
|
+
export function getBase() {
|
|
51
|
+
return base;
|
|
52
|
+
}
|
|
53
|
+
// Resets the base segments. Exported for testing only.
|
|
54
|
+
export function resetBase() {
|
|
55
|
+
base = ClientInfo.EMPTY;
|
|
56
|
+
}
|
|
57
|
+
// Returns the base segments as a formatted string. Exported for
|
|
58
|
+
// testing only.
|
|
59
|
+
export function baseToString() {
|
|
60
|
+
return base.toString();
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base.js","sourceRoot":"","sources":["../../src/clientinfo/base.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAC,UAAU,EAAE,eAAe,EAAE,QAAQ,EAAC,MAAM,cAAc,CAAC;AACnE,OAAO,OAAO,MAAM,oBAAoB,CAAC,OAAM,IAAI,EAAE,MAAM,EAAC,CAAC;AAE7D,MAAM,CAAC,MAAM,WAAW,GAAG,aAAa,CAAC;AACzC,MAAM,CAAC,MAAM,OAAO,GAAW,OAAO,CAAC,OAAO,CAAC;AAE/C,qEAAqE;AACrE,oEAAoE;AACpE,IAAI,IAAI,GAAG,UAAU,CAAC,KAAK,CAAC;AAE5B;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,IAAY,EAAE,OAAe;IACtD,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,eAAe,CACvB,iBAAiB,EACjB,oBAAoB,OAAO,GAAG,CAC/B,CAAC;IACJ,CAAC;IACD,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;AAC9B,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,UAAU,CAAC,OAAe;IACxC,YAAY,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;AACnC,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,YAAY,CAAC,GAAW,EAAE,KAAa;IACrD,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,EAAC,GAAG,EAAE,KAAK,EAAC,CAAC,CAAC;AACjC,CAAC;AAED,wDAAwD;AACxD,MAAM,UAAU,OAAO;IACrB,OAAO,IAAI,CAAC;AACd,CAAC;AAED,uDAAuD;AACvD,MAAM,UAAU,SAAS;IACvB,IAAI,GAAG,UAAU,CAAC,KAAK,CAAC;AAC1B,CAAC;AAED,gEAAgE;AAChE,gBAAgB;AAChB,MAAM,UAAU,YAAY;IAC1B,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Collects information about the client and its environment into an
|
|
3
|
+
* immutable {@link ClientInfo} value.
|
|
4
|
+
*
|
|
5
|
+
* {@link ClientInfo.with} derives a new value with additional key/value
|
|
6
|
+
* segments; it never mutates the original.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
export type ClientInfoErrorCode = 'INVALID_KEY' | 'INVALID_VALUE' | 'INVALID_VERSION';
|
|
11
|
+
export declare class ClientInfoError extends Error {
|
|
12
|
+
readonly code: ClientInfoErrorCode;
|
|
13
|
+
constructor(code: ClientInfoErrorCode, message: string);
|
|
14
|
+
}
|
|
15
|
+
interface Segment {
|
|
16
|
+
readonly key: string;
|
|
17
|
+
readonly value: string;
|
|
18
|
+
}
|
|
19
|
+
export declare function isSemVer(s: string): boolean;
|
|
20
|
+
export declare function isValidSegment(s: string): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Replaces characters that are not valid in segment values with
|
|
23
|
+
* hyphens. Used for environment-sourced values (runtime version,
|
|
24
|
+
* upstream) that we do not control and cannot reject.
|
|
25
|
+
*/
|
|
26
|
+
export declare function sanitize(s: string): string;
|
|
27
|
+
/**
|
|
28
|
+
* ClientInfo is an immutable, ordered list of key/value segments. Use
|
|
29
|
+
* {@link ClientInfo.with} to derive new values with additional segments.
|
|
30
|
+
*/
|
|
31
|
+
export declare class ClientInfo {
|
|
32
|
+
static readonly EMPTY: ClientInfo;
|
|
33
|
+
readonly segments: readonly Segment[];
|
|
34
|
+
private constructor();
|
|
35
|
+
/**
|
|
36
|
+
* Returns a new {@link ClientInfo} with the given items appended. Accepts
|
|
37
|
+
* either individual key/value pairs or another {@link ClientInfo} whose
|
|
38
|
+
* segments are merged in order. The original is not modified; mixing the
|
|
39
|
+
* two forms in a single call is supported.
|
|
40
|
+
*
|
|
41
|
+
* Keys and values on pair arguments must contain only alphanumeric
|
|
42
|
+
* characters plus `_`, `.`, `+`, or `-`. Exact key+value duplicates are
|
|
43
|
+
* silently ignored. On error, an exception is thrown (all-or-nothing).
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* base.with({key: 'partner', value: 'acme'});
|
|
48
|
+
* base.with(pkgClientInfo);
|
|
49
|
+
* base.with(pkgClientInfo, {key: 'sdk-feature', value: 'pagination'});
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
with(...items: (ClientInfo | Segment)[]): ClientInfo;
|
|
53
|
+
/**
|
|
54
|
+
* Returns a string representation of the client info suitable for
|
|
55
|
+
* inclusion in HTTP headers. Key/value pairs are formatted as
|
|
56
|
+
* "key/value" and joined by spaces in the order they were inserted.
|
|
57
|
+
*/
|
|
58
|
+
toString(): string;
|
|
59
|
+
}
|
|
60
|
+
export {};
|
|
61
|
+
//# sourceMappingURL=clientinfo.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"clientinfo.d.ts","sourceRoot":"","sources":["../../src/clientinfo/clientinfo.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,MAAM,mBAAmB,GAC3B,aAAa,GACb,eAAe,GACf,iBAAiB,CAAC;AAEtB,qBAAa,eAAgB,SAAQ,KAAK;IACxC,QAAQ,CAAC,IAAI,EAAE,mBAAmB,CAAC;gBAEvB,IAAI,EAAE,mBAAmB,EAAE,OAAO,EAAE,MAAM;CAKvD;AAED,UAAU,OAAO;IACf,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAcD,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAE3C;AAED,wBAAgB,cAAc,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAEjD;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAE1C;AAED;;;GAGG;AACH,qBAAa,UAAU;IACrB,MAAM,CAAC,QAAQ,CAAC,KAAK,aAAoB;IAEzC,QAAQ,CAAC,QAAQ,EAAE,SAAS,OAAO,EAAE,CAAC;IAEtC,OAAO;IAMP;;;;;;;;;;;;;;;;OAgBG;IACH,IAAI,CAAC,GAAG,KAAK,EAAE,CAAC,UAAU,GAAG,OAAO,CAAC,EAAE,GAAG,UAAU;IA6BpD;;;;OAIG;IACH,QAAQ,IAAI,MAAM;CAGnB"}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Collects information about the client and its environment into an
|
|
3
|
+
* immutable {@link ClientInfo} value.
|
|
4
|
+
*
|
|
5
|
+
* {@link ClientInfo.with} derives a new value with additional key/value
|
|
6
|
+
* segments; it never mutates the original.
|
|
7
|
+
*
|
|
8
|
+
* @module
|
|
9
|
+
*/
|
|
10
|
+
export class ClientInfoError extends Error {
|
|
11
|
+
code;
|
|
12
|
+
constructor(code, message) {
|
|
13
|
+
super(message);
|
|
14
|
+
this.name = 'ClientInfoError';
|
|
15
|
+
this.code = code;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
const SEMVER_CORE = String.raw `(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)`;
|
|
19
|
+
const SEMVER_PRERELEASE = String.raw `(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?`;
|
|
20
|
+
const SEMVER_BUILDMETADATA = String.raw `(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?`;
|
|
21
|
+
const REGEXP_SEMVER = new RegExp('^' + SEMVER_CORE + SEMVER_PRERELEASE + SEMVER_BUILDMETADATA + '$');
|
|
22
|
+
const REGEXP_VALID_SEGMENT = /^[-0-9A-Za-z_.+]+$/;
|
|
23
|
+
const REGEXP_INVALID_SEGMENT_CHAR = /[^-0-9A-Za-z_.+]/g;
|
|
24
|
+
export function isSemVer(s) {
|
|
25
|
+
return REGEXP_SEMVER.test(s);
|
|
26
|
+
}
|
|
27
|
+
export function isValidSegment(s) {
|
|
28
|
+
return REGEXP_VALID_SEGMENT.test(s);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Replaces characters that are not valid in segment values with
|
|
32
|
+
* hyphens. Used for environment-sourced values (runtime version,
|
|
33
|
+
* upstream) that we do not control and cannot reject.
|
|
34
|
+
*/
|
|
35
|
+
export function sanitize(s) {
|
|
36
|
+
return s.replace(REGEXP_INVALID_SEGMENT_CHAR, '-');
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* ClientInfo is an immutable, ordered list of key/value segments. Use
|
|
40
|
+
* {@link ClientInfo.with} to derive new values with additional segments.
|
|
41
|
+
*/
|
|
42
|
+
export class ClientInfo {
|
|
43
|
+
static EMPTY = new ClientInfo();
|
|
44
|
+
segments;
|
|
45
|
+
constructor(segments = []) {
|
|
46
|
+
this.segments = [...segments];
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Returns a new {@link ClientInfo} with the given items appended. Accepts
|
|
50
|
+
* either individual key/value pairs or another {@link ClientInfo} whose
|
|
51
|
+
* segments are merged in order. The original is not modified; mixing the
|
|
52
|
+
* two forms in a single call is supported.
|
|
53
|
+
*
|
|
54
|
+
* Keys and values on pair arguments must contain only alphanumeric
|
|
55
|
+
* characters plus `_`, `.`, `+`, or `-`. Exact key+value duplicates are
|
|
56
|
+
* silently ignored. On error, an exception is thrown (all-or-nothing).
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* base.with({key: 'partner', value: 'acme'});
|
|
61
|
+
* base.with(pkgClientInfo);
|
|
62
|
+
* base.with(pkgClientInfo, {key: 'sdk-feature', value: 'pagination'});
|
|
63
|
+
* ```
|
|
64
|
+
*/
|
|
65
|
+
with(...items) {
|
|
66
|
+
if (items.length === 0) {
|
|
67
|
+
return this;
|
|
68
|
+
}
|
|
69
|
+
const newSegments = [...this.segments];
|
|
70
|
+
for (const item of items) {
|
|
71
|
+
const pairs = item instanceof ClientInfo ? item.segments : [item];
|
|
72
|
+
for (const { key, value } of pairs) {
|
|
73
|
+
if (!isValidSegment(key)) {
|
|
74
|
+
throw new ClientInfoError('INVALID_KEY', `Invalid key: ${key}.`);
|
|
75
|
+
}
|
|
76
|
+
if (!isValidSegment(value)) {
|
|
77
|
+
throw new ClientInfoError('INVALID_VALUE', `Invalid value for "${key}": ${value}.`);
|
|
78
|
+
}
|
|
79
|
+
if (newSegments.some(s => s.key === key && s.value === value)) {
|
|
80
|
+
continue;
|
|
81
|
+
}
|
|
82
|
+
newSegments.push({ key, value });
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return new ClientInfo(newSegments);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Returns a string representation of the client info suitable for
|
|
89
|
+
* inclusion in HTTP headers. Key/value pairs are formatted as
|
|
90
|
+
* "key/value" and joined by spaces in the order they were inserted.
|
|
91
|
+
*/
|
|
92
|
+
toString() {
|
|
93
|
+
return this.segments.map(s => `${s.key}/${s.value}`).join(' ');
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
//# source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AC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACjE,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser-compatible {@link createDefault}. Contains no Node.js-specific
|
|
3
|
+
* APIs (no `process.version`, `process.platform`, or `process.env`); only
|
|
4
|
+
* the segments registered via {@link setProduct}, {@link setPartner}, and
|
|
5
|
+
* {@link addToDefault} are returned, plus the core SDK identity.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import { ClientInfo } from './clientinfo';
|
|
10
|
+
/**
|
|
11
|
+
* Returns a {@link ClientInfo} populated with SDK metadata and segments
|
|
12
|
+
* registered via {@link addToDefault}. Unlike the Node.js variant, this
|
|
13
|
+
* does not auto-detect runtime, OS, CI/CD, or agent because those signals
|
|
14
|
+
* are not available in a browser.
|
|
15
|
+
*/
|
|
16
|
+
export declare function createDefault(): ClientInfo;
|
|
17
|
+
//# sourceMappingURL=default.browser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default.browser.d.ts","sourceRoot":"","sources":["../../src/clientinfo/default.browser.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AAGxC;;;;;GAKG;AACH,wBAAgB,aAAa,IAAI,UAAU,CAK1C"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Browser-compatible {@link createDefault}. Contains no Node.js-specific
|
|
3
|
+
* APIs (no `process.version`, `process.platform`, or `process.env`); only
|
|
4
|
+
* the segments registered via {@link setProduct}, {@link setPartner}, and
|
|
5
|
+
* {@link addToDefault} are returned, plus the core SDK identity.
|
|
6
|
+
*
|
|
7
|
+
* @module
|
|
8
|
+
*/
|
|
9
|
+
import { ClientInfo } from './clientinfo';
|
|
10
|
+
import { MODULE_NAME, VERSION, getBase } from './base';
|
|
11
|
+
/**
|
|
12
|
+
* Returns a {@link ClientInfo} populated with SDK metadata and segments
|
|
13
|
+
* registered via {@link addToDefault}. Unlike the Node.js variant, this
|
|
14
|
+
* does not auto-detect runtime, OS, CI/CD, or agent because those signals
|
|
15
|
+
* are not available in a browser.
|
|
16
|
+
*/
|
|
17
|
+
export function createDefault() {
|
|
18
|
+
return ClientInfo.EMPTY.with({ key: MODULE_NAME, value: VERSION }, ...getBase().segments);
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=default.browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default.browser.js","sourceRoot":"","sources":["../../src/clientinfo/default.browser.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAC,UAAU,EAAC,MAAM,cAAc,CAAC;AACxC,OAAO,EAAC,WAAW,EAAE,OAAO,EAAE,OAAO,EAAC,MAAM,QAAQ,CAAC;AAErD;;;;;GAKG;AACH,MAAM,UAAU,aAAa;IAC3B,OAAO,UAAU,CAAC,KAAK,CAAC,IAAI,CAC1B,EAAC,GAAG,EAAE,WAAW,EAAE,KAAK,EAAE,OAAO,EAAC,EAClC,GAAG,OAAO,EAAE,CAAC,QAAQ,CACtB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ClientInfo } from './clientinfo';
|
|
2
|
+
/**
|
|
3
|
+
* Converts a Node.js version string (e.g., "v22.0.0") into a bare
|
|
4
|
+
* semver string (e.g., "22.0.0").
|
|
5
|
+
*/
|
|
6
|
+
export declare function normalizeNodeVersion(raw: string): string;
|
|
7
|
+
export declare const CACHED_NODE_VERSION: string;
|
|
8
|
+
/**
|
|
9
|
+
* Returns a {@link ClientInfo} populated with SDK metadata, runtime
|
|
10
|
+
* information, segments registered via {@link addToDefault}, and
|
|
11
|
+
* automatically detected environment properties.
|
|
12
|
+
*/
|
|
13
|
+
export declare function createDefault(): ClientInfo;
|
|
14
|
+
//# sourceMappingURL=default.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default.d.ts","sourceRoot":"","sources":["../../src/clientinfo/default.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAW,MAAM,cAAc,CAAC;AAoElD;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAKxD;AAID,eAAO,MAAM,mBAAmB,QAAwC,CAAC;AAEzE;;;;GAIG;AACH,wBAAgB,aAAa,IAAI,UAAU,CAuC1C"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { ClientInfo, sanitize } from './clientinfo';
|
|
2
|
+
import { MODULE_NAME, VERSION, getBase } from './base';
|
|
3
|
+
import { agentProvider } from './agent';
|
|
4
|
+
const CICD_PROVIDERS = [
|
|
5
|
+
{
|
|
6
|
+
name: 'github',
|
|
7
|
+
envVars: [{ name: 'GITHUB_ACTIONS', expectedValue: 'true' }],
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
name: 'gitlab',
|
|
11
|
+
envVars: [{ name: 'GITLAB_CI', expectedValue: 'true' }],
|
|
12
|
+
},
|
|
13
|
+
{ name: 'jenkins', envVars: [{ name: 'JENKINS_URL', expectedValue: '' }] },
|
|
14
|
+
{
|
|
15
|
+
name: 'azure-devops',
|
|
16
|
+
envVars: [{ name: 'TF_BUILD', expectedValue: 'True' }],
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: 'circle',
|
|
20
|
+
envVars: [{ name: 'CIRCLECI', expectedValue: 'true' }],
|
|
21
|
+
},
|
|
22
|
+
{ name: 'travis', envVars: [{ name: 'TRAVIS', expectedValue: 'true' }] },
|
|
23
|
+
{
|
|
24
|
+
name: 'bitbucket',
|
|
25
|
+
envVars: [{ name: 'BITBUCKET_BUILD_NUMBER', expectedValue: '' }],
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
name: 'google-cloud-build',
|
|
29
|
+
envVars: [
|
|
30
|
+
{ name: 'PROJECT_ID', expectedValue: '' },
|
|
31
|
+
{ name: 'BUILD_ID', expectedValue: '' },
|
|
32
|
+
{ name: 'PROJECT_NUMBER', expectedValue: '' },
|
|
33
|
+
{ name: 'LOCATION', expectedValue: '' },
|
|
34
|
+
],
|
|
35
|
+
},
|
|
36
|
+
{
|
|
37
|
+
name: 'aws-code-build',
|
|
38
|
+
envVars: [{ name: 'CODEBUILD_BUILD_ARN', expectedValue: '' }],
|
|
39
|
+
},
|
|
40
|
+
{ name: 'tf-cloud', envVars: [{ name: 'TFC_RUN_ID', expectedValue: '' }] },
|
|
41
|
+
];
|
|
42
|
+
function detectCicd() {
|
|
43
|
+
for (const p of CICD_PROVIDERS) {
|
|
44
|
+
const allMatch = p.envVars.every(ev => {
|
|
45
|
+
const v = process.env[ev.name];
|
|
46
|
+
return (v !== undefined && (ev.expectedValue === '' || v === ev.expectedValue));
|
|
47
|
+
});
|
|
48
|
+
if (allMatch) {
|
|
49
|
+
return p.name;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return '';
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Converts a Node.js version string (e.g., "v22.0.0") into a bare
|
|
56
|
+
* semver string (e.g., "22.0.0").
|
|
57
|
+
*/
|
|
58
|
+
export function normalizeNodeVersion(raw) {
|
|
59
|
+
if (!raw.startsWith('v')) {
|
|
60
|
+
return '0.0.0-dev';
|
|
61
|
+
}
|
|
62
|
+
return raw.slice(1);
|
|
63
|
+
}
|
|
64
|
+
// Computed once at module load because process.version never changes
|
|
65
|
+
// during a process lifetime.
|
|
66
|
+
export const CACHED_NODE_VERSION = normalizeNodeVersion(process.version);
|
|
67
|
+
/**
|
|
68
|
+
* Returns a {@link ClientInfo} populated with SDK metadata, runtime
|
|
69
|
+
* information, segments registered via {@link addToDefault}, and
|
|
70
|
+
* automatically detected environment properties.
|
|
71
|
+
*/
|
|
72
|
+
export function createDefault() {
|
|
73
|
+
const pairs = [
|
|
74
|
+
{ key: MODULE_NAME, value: VERSION },
|
|
75
|
+
{ key: 'node', value: CACHED_NODE_VERSION },
|
|
76
|
+
{ key: 'os', value: process.platform },
|
|
77
|
+
...getBase().segments,
|
|
78
|
+
];
|
|
79
|
+
// DATABRICKS_SDK_UPSTREAM and DATABRICKS_SDK_UPSTREAM_VERSION are set
|
|
80
|
+
// by tools built on top of this SDK (e.g. Terraform provider, Pulumi)
|
|
81
|
+
// to identify themselves as the upstream product. Both must be present
|
|
82
|
+
// for the upstream segment to be included.
|
|
83
|
+
const upstream = process.env.DATABRICKS_SDK_UPSTREAM;
|
|
84
|
+
if (upstream !== undefined) {
|
|
85
|
+
const upstreamVersion = process.env.DATABRICKS_SDK_UPSTREAM_VERSION;
|
|
86
|
+
if (upstreamVersion !== undefined) {
|
|
87
|
+
pairs.push({ key: 'upstream', value: sanitize(upstream) }, { key: 'upstream-version', value: sanitize(upstreamVersion) });
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
const cicd = detectCicd();
|
|
91
|
+
if (cicd !== '') {
|
|
92
|
+
pairs.push({ key: 'cicd', value: cicd });
|
|
93
|
+
}
|
|
94
|
+
const runtime = process.env.DATABRICKS_RUNTIME_VERSION;
|
|
95
|
+
if (runtime !== undefined && runtime !== '') {
|
|
96
|
+
pairs.push({ key: 'runtime', value: sanitize(runtime) });
|
|
97
|
+
}
|
|
98
|
+
const agent = agentProvider();
|
|
99
|
+
if (agent !== '') {
|
|
100
|
+
pairs.push({ key: 'agent', value: agent });
|
|
101
|
+
}
|
|
102
|
+
return ClientInfo.EMPTY.with(...pairs);
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=default.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default.js","sourceRoot":"","sources":["../../src/clientinfo/default.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAA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AAG,aAAa,EAAE,CAAC;IAC9B,IAAI,KAAK,KAAK,EAAE,EAAE,CAAC;QACjB,KAAK,CAAC,IAAI,CAAC,EAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAC,CAAC,CAAC;IAC3C,CAAC;IAED,OAAO,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC;AACzC,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type { ClientInfoErrorCode } from './clientinfo';
|
|
2
|
+
export { ClientInfo, ClientInfoError } from './clientinfo';
|
|
3
|
+
export { addToDefault, setPartner, setProduct } from './base';
|
|
4
|
+
export { createDefault } from './default.browser';
|
|
5
|
+
//# sourceMappingURL=index.browser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.browser.d.ts","sourceRoot":"","sources":["../../src/clientinfo/index.browser.ts"],"names":[],"mappings":"AAAA,YAAY,EAAC,mBAAmB,EAAC,MAAM,cAAc,CAAC;AACtD,OAAO,EAAC,UAAU,EAAE,eAAe,EAAC,MAAM,cAAc,CAAC;AACzD,OAAO,EAAC,YAAY,EAAE,UAAU,EAAE,UAAU,EAAC,MAAM,QAAQ,CAAC;AAC5D,OAAO,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.browser.js","sourceRoot":"","sources":["../../src/clientinfo/index.browser.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,UAAU,EAAE,eAAe,EAAC,MAAM,cAAc,CAAC;AACzD,OAAO,EAAC,YAAY,EAAE,UAAU,EAAE,UAAU,EAAC,MAAM,QAAQ,CAAC;AAC5D,OAAO,EAAC,aAAa,EAAC,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/clientinfo/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAC,mBAAmB,EAAC,MAAM,cAAc,CAAC;AACtD,OAAO,EAAC,UAAU,EAAE,eAAe,EAAC,MAAM,cAAc,CAAC;AACzD,OAAO,EAAC,YAAY,EAAE,UAAU,EAAE,UAAU,EAAC,MAAM,QAAQ,CAAC;AAC5D,OAAO,EAAC,aAAa,EAAC,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/clientinfo/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,UAAU,EAAE,eAAe,EAAC,MAAM,cAAc,CAAC;AACzD,OAAO,EAAC,YAAY,EAAE,UAAU,EAAE,UAAU,EAAC,MAAM,QAAQ,CAAC;AAC5D,OAAO,EAAC,aAAa,EAAC,MAAM,WAAW,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP transport primitives. Defines the {@link HttpClient} interface and a
|
|
3
|
+
* {@link newFetchHttpClient} implementation backed by the Fetch API.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
/** HttpRequest represents an outgoing HTTP request. */
|
|
8
|
+
export interface HttpRequest {
|
|
9
|
+
/** The URL to send the request to. */
|
|
10
|
+
url: string;
|
|
11
|
+
/** The HTTP method (GET, POST, etc.). */
|
|
12
|
+
method: string;
|
|
13
|
+
/** The request headers. */
|
|
14
|
+
headers: Headers;
|
|
15
|
+
/** The request body. */
|
|
16
|
+
body?: string | ArrayBuffer | Uint8Array | ReadableStream<Uint8Array> | null;
|
|
17
|
+
/** An optional signal to abort the request. */
|
|
18
|
+
signal?: AbortSignal;
|
|
19
|
+
}
|
|
20
|
+
/** HttpResponse represents the response from an HTTP request. */
|
|
21
|
+
export interface HttpResponse {
|
|
22
|
+
/** The HTTP status code. */
|
|
23
|
+
statusCode: number;
|
|
24
|
+
/** The response headers. */
|
|
25
|
+
headers: Headers;
|
|
26
|
+
/** The raw response body stream. */
|
|
27
|
+
body: ReadableStream<Uint8Array> | null;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* HttpClient sends HTTP requests and returns responses.
|
|
31
|
+
*/
|
|
32
|
+
export interface HttpClient {
|
|
33
|
+
/** Sends an HTTP request and returns the response. */
|
|
34
|
+
send(request: HttpRequest): Promise<HttpResponse>;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Creates a new HttpClient that uses the Fetch API as its transport.
|
|
38
|
+
*/
|
|
39
|
+
export declare function newFetchHttpClient(): HttpClient;
|
|
40
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/http/http.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,uDAAuD;AACvD,MAAM,WAAW,WAAW;IAC1B,sCAAsC;IACtC,GAAG,EAAE,MAAM,CAAC;IAEZ,yCAAyC;IACzC,MAAM,EAAE,MAAM,CAAC;IAEf,2BAA2B;IAC3B,OAAO,EAAE,OAAO,CAAC;IAEjB,wBAAwB;IACxB,IAAI,CAAC,EAAE,MAAM,GAAG,WAAW,GAAG,UAAU,GAAG,cAAc,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;IAE7E,+CAA+C;IAC/C,MAAM,CAAC,EAAE,WAAW,CAAC;CACtB;AAED,iEAAiE;AACjE,MAAM,WAAW,YAAY;IAC3B,4BAA4B;IAC5B,UAAU,EAAE,MAAM,CAAC;IAEnB,4BAA4B;IAC5B,OAAO,EAAE,OAAO,CAAC;IAEjB,oCAAoC;IACpC,IAAI,EAAE,cAAc,CAAC,UAAU,CAAC,GAAG,IAAI,CAAC;CACzC;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,sDAAsD;IACtD,IAAI,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,YAAY,CAAC,CAAC;CACnD;AAED;;GAEG;AACH,wBAAgB,kBAAkB,IAAI,UAAU,CA0B/C"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* HTTP transport primitives. Defines the {@link HttpClient} interface and a
|
|
3
|
+
* {@link newFetchHttpClient} implementation backed by the Fetch API.
|
|
4
|
+
*
|
|
5
|
+
* @module
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Creates a new HttpClient that uses the Fetch API as its transport.
|
|
9
|
+
*/
|
|
10
|
+
export function newFetchHttpClient() {
|
|
11
|
+
return {
|
|
12
|
+
async send(request) {
|
|
13
|
+
const init = {
|
|
14
|
+
method: request.method,
|
|
15
|
+
headers: request.headers,
|
|
16
|
+
};
|
|
17
|
+
if (request.body !== undefined) {
|
|
18
|
+
init.body = request.body;
|
|
19
|
+
// The Fetch spec requires duplex: 'half' for streaming request bodies.
|
|
20
|
+
// See https://fetch.spec.whatwg.org/#dom-requestinit-duplex.
|
|
21
|
+
if (request.body instanceof ReadableStream) {
|
|
22
|
+
init.duplex = 'half';
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (request.signal !== undefined) {
|
|
26
|
+
init.signal = request.signal;
|
|
27
|
+
}
|
|
28
|
+
const response = await fetch(request.url, init);
|
|
29
|
+
return {
|
|
30
|
+
statusCode: response.status,
|
|
31
|
+
headers: response.headers,
|
|
32
|
+
body: response.body,
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=http.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.js","sourceRoot":"","sources":["../../src/http/http.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAwCH;;GAEG;AACH,MAAM,UAAU,kBAAkB;IAChC,OAAO;QACL,KAAK,CAAC,IAAI,CAAC,OAAoB;YAC7B,MAAM,IAAI,GAAgB;gBACxB,MAAM,EAAE,OAAO,CAAC,MAAM;gBACtB,OAAO,EAAE,OAAO,CAAC,OAAO;aACzB,CAAC;YACF,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;gBAC/B,IAAI,CAAC,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;gBACzB,uEAAuE;gBACvE,6DAA6D;gBAC7D,IAAI,OAAO,CAAC,IAAI,YAAY,cAAc,EAAE,CAAC;oBAC3C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;gBACvB,CAAC;YACH,CAAC;YACD,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;gBACjC,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;YAC/B,CAAC;YACD,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;YAChD,OAAO;gBACL,UAAU,EAAE,QAAQ,CAAC,MAAM;gBAC3B,OAAO,EAAE,QAAQ,CAAC,OAAO;gBACzB,IAAI,EAAE,QAAQ,CAAC,IAAI;aACpB,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/http/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,kBAAkB,EAAC,MAAM,QAAQ,CAAC;AAC1C,YAAY,EAAC,UAAU,EAAE,WAAW,EAAE,YAAY,EAAC,MAAM,QAAQ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/http/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAC,kBAAkB,EAAC,MAAM,QAAQ,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG"}
|