@anduril-industries/lattice-sdk 4.7.1 → 4.8.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/README.md +10 -2
- package/dist/cjs/BaseClient.d.ts +3 -0
- package/dist/cjs/BaseClient.js +17 -2
- package/dist/cjs/api/types/TransponderCodes.d.ts +6 -1
- package/dist/cjs/core/auth/AuthProvider.d.ts +1 -0
- package/dist/cjs/core/auth/AuthProvider.js +7 -0
- package/dist/cjs/core/auth/index.d.ts +1 -1
- package/dist/cjs/core/auth/index.js +3 -1
- package/dist/cjs/core/fetcher/requestWithRetries.js +4 -1
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/BaseClient.d.mts +3 -0
- package/dist/esm/BaseClient.mjs +17 -2
- package/dist/esm/api/types/TransponderCodes.d.mts +6 -1
- package/dist/esm/core/auth/AuthProvider.d.mts +1 -0
- package/dist/esm/core/auth/AuthProvider.mjs +6 -1
- package/dist/esm/core/auth/index.d.mts +1 -1
- package/dist/esm/core/auth/index.mjs +1 -0
- package/dist/esm/core/fetcher/requestWithRetries.mjs +4 -1
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -670,11 +670,19 @@ The SDK is instrumented with automatic retries with exponential backoff. A reque
|
|
|
670
670
|
as the request is deemed retryable and the number of retry attempts has not grown larger than the configured
|
|
671
671
|
retry limit (default: 2).
|
|
672
672
|
|
|
673
|
-
|
|
673
|
+
Which status codes are retried depends on the `retryStatusCodes` generator configuration:
|
|
674
674
|
|
|
675
|
+
**`legacy`** (current default): retries on
|
|
675
676
|
- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
|
|
676
677
|
- [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
|
|
677
|
-
- [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
|
|
678
|
+
- [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status#server_error_responses) (All server errors, including 500)
|
|
679
|
+
|
|
680
|
+
**`recommended`**: retries on
|
|
681
|
+
- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
|
|
682
|
+
- [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
|
|
683
|
+
- [502](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/502) (Bad Gateway)
|
|
684
|
+
- [503](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/503) (Service Unavailable)
|
|
685
|
+
- [504](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/504) (Gateway Timeout)
|
|
678
686
|
|
|
679
687
|
Use the `maxRetries` request option to configure this behavior.
|
|
680
688
|
|
package/dist/cjs/BaseClient.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { OAuthAuthProvider } from "./auth/OAuthAuthProvider.js";
|
|
2
2
|
import * as core from "./core/index.js";
|
|
3
3
|
import type * as environments from "./environments.js";
|
|
4
|
+
export type AuthOption = false | core.AuthProvider["getAuthRequest"] | core.AuthProvider | OAuthAuthProvider.AuthOptions;
|
|
4
5
|
export type BaseClientOptions = {
|
|
5
6
|
environment?: core.Supplier<environments.LatticeEnvironment | string>;
|
|
6
7
|
/** Specify a custom URL to connect the client to. */
|
|
@@ -15,6 +16,8 @@ export type BaseClientOptions = {
|
|
|
15
16
|
fetch?: typeof fetch;
|
|
16
17
|
/** Configure logging for the client. */
|
|
17
18
|
logging?: core.logging.LogConfig | core.logging.Logger;
|
|
19
|
+
/** Override auth. Pass false to disable, a function returning auth headers, an AuthProvider, or auth options. */
|
|
20
|
+
auth?: AuthOption;
|
|
18
21
|
} & OAuthAuthProvider.AuthOptions;
|
|
19
22
|
export interface BaseRequestOptions {
|
|
20
23
|
/** The maximum time to wait for a response in seconds. */
|
package/dist/cjs/BaseClient.js
CHANGED
|
@@ -43,8 +43,8 @@ function normalizeClientOptions(options) {
|
|
|
43
43
|
const headers = (0, headers_js_1.mergeHeaders)({
|
|
44
44
|
"X-Fern-Language": "JavaScript",
|
|
45
45
|
"X-Fern-SDK-Name": "@anduril-industries/lattice-sdk",
|
|
46
|
-
"X-Fern-SDK-Version": "4.
|
|
47
|
-
"User-Agent": "@anduril-industries/lattice-sdk/4.
|
|
46
|
+
"X-Fern-SDK-Version": "4.8.0",
|
|
47
|
+
"User-Agent": "@anduril-industries/lattice-sdk/4.8.0",
|
|
48
48
|
"X-Fern-Runtime": core.RUNTIME.type,
|
|
49
49
|
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
50
50
|
}, options === null || options === void 0 ? void 0 : options.headers);
|
|
@@ -53,6 +53,21 @@ function normalizeClientOptions(options) {
|
|
|
53
53
|
function normalizeClientOptionsWithAuth(options) {
|
|
54
54
|
var _a;
|
|
55
55
|
const normalized = normalizeClientOptions(options);
|
|
56
|
+
if (options.auth === false) {
|
|
57
|
+
normalized.authProvider = new core.NoOpAuthProvider();
|
|
58
|
+
return normalized;
|
|
59
|
+
}
|
|
60
|
+
if (options.auth != null) {
|
|
61
|
+
if (typeof options.auth === "function") {
|
|
62
|
+
normalized.authProvider = { getAuthRequest: options.auth };
|
|
63
|
+
return normalized;
|
|
64
|
+
}
|
|
65
|
+
if (core.isAuthProvider(options.auth)) {
|
|
66
|
+
normalized.authProvider = options.auth;
|
|
67
|
+
return normalized;
|
|
68
|
+
}
|
|
69
|
+
Object.assign(normalized, options.auth);
|
|
70
|
+
}
|
|
56
71
|
const normalizedWithNoOpAuthProvider = withNoOpAuthProvider(normalized);
|
|
57
72
|
(_a = normalized.authProvider) !== null && _a !== void 0 ? _a : (normalized.authProvider = OAuthAuthProvider_js_1.OAuthAuthProvider.createInstance(normalizedWithNoOpAuthProvider));
|
|
58
73
|
return normalized;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type * as Lattice from "../index.js";
|
|
2
2
|
/**
|
|
3
|
-
* A message describing any transponder codes associated with Mode 1, 2, 3, 4, 5, S interrogations.
|
|
3
|
+
* A message describing any transponder codes associated with Mode 1, 2, 3, 4, 5, S, C interrogations.
|
|
4
4
|
*/
|
|
5
5
|
export interface TransponderCodes {
|
|
6
6
|
/** The mode 1 code assigned to military assets. */
|
|
@@ -15,6 +15,11 @@ export interface TransponderCodes {
|
|
|
15
15
|
mode5?: Lattice.Mode5 | undefined;
|
|
16
16
|
/** The Mode S transponder codes. */
|
|
17
17
|
modeS?: Lattice.ModeS | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* The Mode C altitude reported by the transponder in feet. Mode C provides pressure altitude
|
|
20
|
+
* in 100-foot increments up to 10,000 feet MSL. A zero value indicates No Statement.
|
|
21
|
+
*/
|
|
22
|
+
modeCAltitudeFt?: number | undefined;
|
|
18
23
|
}
|
|
19
24
|
export declare namespace TransponderCodes {
|
|
20
25
|
/** The validity of the response from the Mode 4 interrogation. */
|
|
@@ -1,2 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isAuthProvider = isAuthProvider;
|
|
4
|
+
function isAuthProvider(value) {
|
|
5
|
+
return (typeof value === "object" &&
|
|
6
|
+
value !== null &&
|
|
7
|
+
"getAuthRequest" in value &&
|
|
8
|
+
typeof value.getAuthRequest === "function");
|
|
9
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type
|
|
1
|
+
export { type AuthProvider, isAuthProvider } from "./AuthProvider.js";
|
|
2
2
|
export type { AuthRequest } from "./AuthRequest.js";
|
|
3
3
|
export { BasicAuth } from "./BasicAuth.js";
|
|
4
4
|
export { BearerToken } from "./BearerToken.js";
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.NoOpAuthProvider = exports.BearerToken = exports.BasicAuth = void 0;
|
|
3
|
+
exports.NoOpAuthProvider = exports.BearerToken = exports.BasicAuth = exports.isAuthProvider = void 0;
|
|
4
|
+
var AuthProvider_js_1 = require("./AuthProvider.js");
|
|
5
|
+
Object.defineProperty(exports, "isAuthProvider", { enumerable: true, get: function () { return AuthProvider_js_1.isAuthProvider; } });
|
|
4
6
|
var BasicAuth_js_1 = require("./BasicAuth.js");
|
|
5
7
|
Object.defineProperty(exports, "BasicAuth", { enumerable: true, get: function () { return BasicAuth_js_1.BasicAuth; } });
|
|
6
8
|
var BearerToken_js_1 = require("./BearerToken.js");
|
|
@@ -14,6 +14,9 @@ const INITIAL_RETRY_DELAY = 1000; // in milliseconds
|
|
|
14
14
|
const MAX_RETRY_DELAY = 60000; // in milliseconds
|
|
15
15
|
const DEFAULT_MAX_RETRIES = 2;
|
|
16
16
|
const JITTER_FACTOR = 0.2; // 20% random jitter
|
|
17
|
+
function isRetryableStatusCode(statusCode) {
|
|
18
|
+
return [408, 429].includes(statusCode) || statusCode >= 500;
|
|
19
|
+
}
|
|
17
20
|
function addPositiveJitter(delay) {
|
|
18
21
|
const jitterMultiplier = 1 + Math.random() * JITTER_FACTOR;
|
|
19
22
|
return delay * jitterMultiplier;
|
|
@@ -53,7 +56,7 @@ function requestWithRetries(requestFn_1) {
|
|
|
53
56
|
return __awaiter(this, arguments, void 0, function* (requestFn, maxRetries = DEFAULT_MAX_RETRIES) {
|
|
54
57
|
let response = yield requestFn();
|
|
55
58
|
for (let i = 0; i < maxRetries; ++i) {
|
|
56
|
-
if (
|
|
59
|
+
if (isRetryableStatusCode(response.status)) {
|
|
57
60
|
const delay = getRetryDelayFromHeaders(response, i);
|
|
58
61
|
yield new Promise((resolve) => setTimeout(resolve, delay));
|
|
59
62
|
response = yield requestFn();
|
package/dist/cjs/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "4.
|
|
1
|
+
export declare const SDK_VERSION = "4.8.0";
|
package/dist/cjs/version.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { OAuthAuthProvider } from "./auth/OAuthAuthProvider.mjs";
|
|
2
2
|
import * as core from "./core/index.mjs";
|
|
3
3
|
import type * as environments from "./environments.mjs";
|
|
4
|
+
export type AuthOption = false | core.AuthProvider["getAuthRequest"] | core.AuthProvider | OAuthAuthProvider.AuthOptions;
|
|
4
5
|
export type BaseClientOptions = {
|
|
5
6
|
environment?: core.Supplier<environments.LatticeEnvironment | string>;
|
|
6
7
|
/** Specify a custom URL to connect the client to. */
|
|
@@ -15,6 +16,8 @@ export type BaseClientOptions = {
|
|
|
15
16
|
fetch?: typeof fetch;
|
|
16
17
|
/** Configure logging for the client. */
|
|
17
18
|
logging?: core.logging.LogConfig | core.logging.Logger;
|
|
19
|
+
/** Override auth. Pass false to disable, a function returning auth headers, an AuthProvider, or auth options. */
|
|
20
|
+
auth?: AuthOption;
|
|
18
21
|
} & OAuthAuthProvider.AuthOptions;
|
|
19
22
|
export interface BaseRequestOptions {
|
|
20
23
|
/** The maximum time to wait for a response in seconds. */
|
package/dist/esm/BaseClient.mjs
CHANGED
|
@@ -6,8 +6,8 @@ export function normalizeClientOptions(options) {
|
|
|
6
6
|
const headers = mergeHeaders({
|
|
7
7
|
"X-Fern-Language": "JavaScript",
|
|
8
8
|
"X-Fern-SDK-Name": "@anduril-industries/lattice-sdk",
|
|
9
|
-
"X-Fern-SDK-Version": "4.
|
|
10
|
-
"User-Agent": "@anduril-industries/lattice-sdk/4.
|
|
9
|
+
"X-Fern-SDK-Version": "4.8.0",
|
|
10
|
+
"User-Agent": "@anduril-industries/lattice-sdk/4.8.0",
|
|
11
11
|
"X-Fern-Runtime": core.RUNTIME.type,
|
|
12
12
|
"X-Fern-Runtime-Version": core.RUNTIME.version,
|
|
13
13
|
}, options === null || options === void 0 ? void 0 : options.headers);
|
|
@@ -16,6 +16,21 @@ export function normalizeClientOptions(options) {
|
|
|
16
16
|
export function normalizeClientOptionsWithAuth(options) {
|
|
17
17
|
var _a;
|
|
18
18
|
const normalized = normalizeClientOptions(options);
|
|
19
|
+
if (options.auth === false) {
|
|
20
|
+
normalized.authProvider = new core.NoOpAuthProvider();
|
|
21
|
+
return normalized;
|
|
22
|
+
}
|
|
23
|
+
if (options.auth != null) {
|
|
24
|
+
if (typeof options.auth === "function") {
|
|
25
|
+
normalized.authProvider = { getAuthRequest: options.auth };
|
|
26
|
+
return normalized;
|
|
27
|
+
}
|
|
28
|
+
if (core.isAuthProvider(options.auth)) {
|
|
29
|
+
normalized.authProvider = options.auth;
|
|
30
|
+
return normalized;
|
|
31
|
+
}
|
|
32
|
+
Object.assign(normalized, options.auth);
|
|
33
|
+
}
|
|
19
34
|
const normalizedWithNoOpAuthProvider = withNoOpAuthProvider(normalized);
|
|
20
35
|
(_a = normalized.authProvider) !== null && _a !== void 0 ? _a : (normalized.authProvider = OAuthAuthProvider.createInstance(normalizedWithNoOpAuthProvider));
|
|
21
36
|
return normalized;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type * as Lattice from "../index.mjs";
|
|
2
2
|
/**
|
|
3
|
-
* A message describing any transponder codes associated with Mode 1, 2, 3, 4, 5, S interrogations.
|
|
3
|
+
* A message describing any transponder codes associated with Mode 1, 2, 3, 4, 5, S, C interrogations.
|
|
4
4
|
*/
|
|
5
5
|
export interface TransponderCodes {
|
|
6
6
|
/** The mode 1 code assigned to military assets. */
|
|
@@ -15,6 +15,11 @@ export interface TransponderCodes {
|
|
|
15
15
|
mode5?: Lattice.Mode5 | undefined;
|
|
16
16
|
/** The Mode S transponder codes. */
|
|
17
17
|
modeS?: Lattice.ModeS | undefined;
|
|
18
|
+
/**
|
|
19
|
+
* The Mode C altitude reported by the transponder in feet. Mode C provides pressure altitude
|
|
20
|
+
* in 100-foot increments up to 10,000 feet MSL. A zero value indicates No Statement.
|
|
21
|
+
*/
|
|
22
|
+
modeCAltitudeFt?: number | undefined;
|
|
18
23
|
}
|
|
19
24
|
export declare namespace TransponderCodes {
|
|
20
25
|
/** The validity of the response from the Mode 4 interrogation. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type
|
|
1
|
+
export { type AuthProvider, isAuthProvider } from "./AuthProvider.mjs";
|
|
2
2
|
export type { AuthRequest } from "./AuthRequest.mjs";
|
|
3
3
|
export { BasicAuth } from "./BasicAuth.mjs";
|
|
4
4
|
export { BearerToken } from "./BearerToken.mjs";
|
|
@@ -11,6 +11,9 @@ const INITIAL_RETRY_DELAY = 1000; // in milliseconds
|
|
|
11
11
|
const MAX_RETRY_DELAY = 60000; // in milliseconds
|
|
12
12
|
const DEFAULT_MAX_RETRIES = 2;
|
|
13
13
|
const JITTER_FACTOR = 0.2; // 20% random jitter
|
|
14
|
+
function isRetryableStatusCode(statusCode) {
|
|
15
|
+
return [408, 429].includes(statusCode) || statusCode >= 500;
|
|
16
|
+
}
|
|
14
17
|
function addPositiveJitter(delay) {
|
|
15
18
|
const jitterMultiplier = 1 + Math.random() * JITTER_FACTOR;
|
|
16
19
|
return delay * jitterMultiplier;
|
|
@@ -50,7 +53,7 @@ export function requestWithRetries(requestFn_1) {
|
|
|
50
53
|
return __awaiter(this, arguments, void 0, function* (requestFn, maxRetries = DEFAULT_MAX_RETRIES) {
|
|
51
54
|
let response = yield requestFn();
|
|
52
55
|
for (let i = 0; i < maxRetries; ++i) {
|
|
53
|
-
if (
|
|
56
|
+
if (isRetryableStatusCode(response.status)) {
|
|
54
57
|
const delay = getRetryDelayFromHeaders(response, i);
|
|
55
58
|
yield new Promise((resolve) => setTimeout(resolve, delay));
|
|
56
59
|
response = yield requestFn();
|
package/dist/esm/version.d.mts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "4.
|
|
1
|
+
export declare const SDK_VERSION = "4.8.0";
|
package/dist/esm/version.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "4.
|
|
1
|
+
export const SDK_VERSION = "4.8.0";
|