@anduril-industries/lattice-sdk 4.12.0 → 4.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/cjs/BaseClient.js +2 -2
  2. package/dist/cjs/api/errors/BadRequestError.js +1 -1
  3. package/dist/cjs/api/errors/ContentTooLargeError.js +1 -1
  4. package/dist/cjs/api/errors/InsufficientStorageError.js +1 -1
  5. package/dist/cjs/api/errors/InternalServerError.js +1 -1
  6. package/dist/cjs/api/errors/NotFoundError.js +1 -1
  7. package/dist/cjs/api/errors/RequestTimeoutError.js +1 -1
  8. package/dist/cjs/api/errors/TooManyRequestsError.js +1 -1
  9. package/dist/cjs/api/errors/UnauthorizedError.js +1 -1
  10. package/dist/cjs/api/types/Color.d.ts +3 -3
  11. package/dist/cjs/api/types/GeoDetails.d.ts +1 -0
  12. package/dist/cjs/api/types/GeoVisualDetails.d.ts +10 -0
  13. package/dist/cjs/api/types/GeoVisualDetails.js +3 -0
  14. package/dist/cjs/api/types/index.d.ts +1 -0
  15. package/dist/cjs/api/types/index.js +1 -0
  16. package/dist/cjs/core/stream/Stream.d.ts +7 -0
  17. package/dist/cjs/core/stream/Stream.js +54 -10
  18. package/dist/cjs/core/stream/index.d.ts +1 -0
  19. package/dist/cjs/errors/LatticeError.js +1 -1
  20. package/dist/cjs/errors/LatticeTimeoutError.js +1 -1
  21. package/dist/cjs/version.d.ts +1 -1
  22. package/dist/cjs/version.js +1 -1
  23. package/dist/esm/BaseClient.mjs +2 -2
  24. package/dist/esm/api/errors/BadRequestError.mjs +1 -1
  25. package/dist/esm/api/errors/ContentTooLargeError.mjs +1 -1
  26. package/dist/esm/api/errors/InsufficientStorageError.mjs +1 -1
  27. package/dist/esm/api/errors/InternalServerError.mjs +1 -1
  28. package/dist/esm/api/errors/NotFoundError.mjs +1 -1
  29. package/dist/esm/api/errors/RequestTimeoutError.mjs +1 -1
  30. package/dist/esm/api/errors/TooManyRequestsError.mjs +1 -1
  31. package/dist/esm/api/errors/UnauthorizedError.mjs +1 -1
  32. package/dist/esm/api/types/Color.d.mts +3 -3
  33. package/dist/esm/api/types/GeoDetails.d.mts +1 -0
  34. package/dist/esm/api/types/GeoVisualDetails.d.mts +10 -0
  35. package/dist/esm/api/types/GeoVisualDetails.mjs +2 -0
  36. package/dist/esm/api/types/index.d.mts +1 -0
  37. package/dist/esm/api/types/index.mjs +1 -0
  38. package/dist/esm/core/stream/Stream.d.mts +7 -0
  39. package/dist/esm/core/stream/Stream.mjs +54 -10
  40. package/dist/esm/core/stream/index.d.mts +1 -0
  41. package/dist/esm/errors/LatticeError.mjs +1 -1
  42. package/dist/esm/errors/LatticeTimeoutError.mjs +1 -1
  43. package/dist/esm/version.d.mts +1 -1
  44. package/dist/esm/version.mjs +1 -1
  45. package/package.json +1 -1
@@ -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.12.0",
47
- "User-Agent": "@anduril-industries/lattice-sdk/4.12.0",
46
+ "X-Fern-SDK-Version": "4.14.0",
47
+ "User-Agent": "@anduril-industries/lattice-sdk/4.14.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);
@@ -48,7 +48,7 @@ class BadRequestError extends errors.LatticeError {
48
48
  if (Error.captureStackTrace) {
49
49
  Error.captureStackTrace(this, this.constructor);
50
50
  }
51
- this.name = this.constructor.name;
51
+ this.name = "BadRequestError";
52
52
  }
53
53
  }
54
54
  exports.BadRequestError = BadRequestError;
@@ -48,7 +48,7 @@ class ContentTooLargeError extends errors.LatticeError {
48
48
  if (Error.captureStackTrace) {
49
49
  Error.captureStackTrace(this, this.constructor);
50
50
  }
51
- this.name = this.constructor.name;
51
+ this.name = "ContentTooLargeError";
52
52
  }
53
53
  }
54
54
  exports.ContentTooLargeError = ContentTooLargeError;
@@ -48,7 +48,7 @@ class InsufficientStorageError extends errors.LatticeError {
48
48
  if (Error.captureStackTrace) {
49
49
  Error.captureStackTrace(this, this.constructor);
50
50
  }
51
- this.name = this.constructor.name;
51
+ this.name = "InsufficientStorageError";
52
52
  }
53
53
  }
54
54
  exports.InsufficientStorageError = InsufficientStorageError;
@@ -48,7 +48,7 @@ class InternalServerError extends errors.LatticeError {
48
48
  if (Error.captureStackTrace) {
49
49
  Error.captureStackTrace(this, this.constructor);
50
50
  }
51
- this.name = this.constructor.name;
51
+ this.name = "InternalServerError";
52
52
  }
53
53
  }
54
54
  exports.InternalServerError = InternalServerError;
@@ -48,7 +48,7 @@ class NotFoundError extends errors.LatticeError {
48
48
  if (Error.captureStackTrace) {
49
49
  Error.captureStackTrace(this, this.constructor);
50
50
  }
51
- this.name = this.constructor.name;
51
+ this.name = "NotFoundError";
52
52
  }
53
53
  }
54
54
  exports.NotFoundError = NotFoundError;
@@ -48,7 +48,7 @@ class RequestTimeoutError extends errors.LatticeError {
48
48
  if (Error.captureStackTrace) {
49
49
  Error.captureStackTrace(this, this.constructor);
50
50
  }
51
- this.name = this.constructor.name;
51
+ this.name = "RequestTimeoutError";
52
52
  }
53
53
  }
54
54
  exports.RequestTimeoutError = RequestTimeoutError;
@@ -48,7 +48,7 @@ class TooManyRequestsError extends errors.LatticeError {
48
48
  if (Error.captureStackTrace) {
49
49
  Error.captureStackTrace(this, this.constructor);
50
50
  }
51
- this.name = this.constructor.name;
51
+ this.name = "TooManyRequestsError";
52
52
  }
53
53
  }
54
54
  exports.TooManyRequestsError = TooManyRequestsError;
@@ -48,7 +48,7 @@ class UnauthorizedError extends errors.LatticeError {
48
48
  if (Error.captureStackTrace) {
49
49
  Error.captureStackTrace(this, this.constructor);
50
50
  }
51
- this.name = this.constructor.name;
51
+ this.name = "UnauthorizedError";
52
52
  }
53
53
  }
54
54
  exports.UnauthorizedError = UnauthorizedError;
@@ -1,9 +1,9 @@
1
1
  export interface Color {
2
- /** The amount of red in the color as a value in the interval [0, 1]. */
2
+ /** The amount of red in the color as a value in the interval [0, 255]. */
3
3
  red?: number | undefined;
4
- /** The amount of green in the color as a value in the interval [0, 1]. */
4
+ /** The amount of green in the color as a value in the interval [0, 255]. */
5
5
  green?: number | undefined;
6
- /** The amount of blue in the color as a value in the interval [0, 1]. */
6
+ /** The amount of blue in the color as a value in the interval [0, 255]. */
7
7
  blue?: number | undefined;
8
8
  /**
9
9
  * The fraction of this color that should be applied to the pixel. That is,
@@ -6,6 +6,7 @@ export interface GeoDetails {
6
6
  type?: GeoDetails.Type | undefined;
7
7
  controlArea?: Lattice.ControlAreaDetails | undefined;
8
8
  acm?: Lattice.AcmDetails | undefined;
9
+ visualDetails?: Lattice.GeoVisualDetails | undefined;
9
10
  }
10
11
  export declare namespace GeoDetails {
11
12
  const Type: {
@@ -0,0 +1,10 @@
1
+ import type * as Lattice from "../index.js";
2
+ /**
3
+ * Details specific to displaying a geo-entity
4
+ */
5
+ export interface GeoVisualDetails {
6
+ /** Describes the fill color of a geo-entity. */
7
+ fillColor?: Lattice.Color | undefined;
8
+ /** Describes the line color of a geo-entity. */
9
+ lineColor?: Lattice.Color | undefined;
10
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ // This file was auto-generated from our API Definition.
3
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -61,6 +61,7 @@ export * from "./GeoPoint.js";
61
61
  export * from "./GeoPolygon.js";
62
62
  export * from "./GeoPolygonPosition.js";
63
63
  export * from "./GeoShape.js";
64
+ export * from "./GeoVisualDetails.js";
64
65
  export * from "./GoogleProtobufAny.js";
65
66
  export * from "./GroupChild.js";
66
67
  export * from "./GroupDetails.js";
@@ -77,6 +77,7 @@ __exportStar(require("./GeoPoint.js"), exports);
77
77
  __exportStar(require("./GeoPolygon.js"), exports);
78
78
  __exportStar(require("./GeoPolygonPosition.js"), exports);
79
79
  __exportStar(require("./GeoShape.js"), exports);
80
+ __exportStar(require("./GeoVisualDetails.js"), exports);
80
81
  __exportStar(require("./GoogleProtobufAny.js"), exports);
81
82
  __exportStar(require("./GroupChild.js"), exports);
82
83
  __exportStar(require("./GroupDetails.js"), exports);
@@ -23,6 +23,12 @@ export declare namespace Stream {
23
23
  eventDiscriminator?: string;
24
24
  }
25
25
  }
26
+ export interface ServerSentEvent<T> {
27
+ data: T;
28
+ id?: string;
29
+ retry?: number;
30
+ event?: string;
31
+ }
26
32
  export declare class Stream<T> implements AsyncIterable<T> {
27
33
  private stream;
28
34
  private parse;
@@ -46,6 +52,7 @@ export declare class Stream<T> implements AsyncIterable<T> {
46
52
  * Parses and returns a single SSE event, or returns null if the event is a stream terminator.
47
53
  */
48
54
  private dispatchSseEvent;
55
+ withMetadata(): AsyncIterable<ServerSentEvent<T>>;
49
56
  private injectDiscriminator;
50
57
  [Symbol.asyncIterator](): AsyncIterator<T, void, unknown>;
51
58
  private decodeChunk;
@@ -40,6 +40,8 @@ const json_js_1 = require("../json.js");
40
40
  const index_js_1 = require("../runtime/index.js");
41
41
  const DATA_PREFIX = "data:";
42
42
  const EVENT_PREFIX = "event:";
43
+ const ID_PREFIX = "id:";
44
+ const RETRY_PREFIX = "retry:";
43
45
  class Stream {
44
46
  constructor({ stream, parse, eventShape, signal }) {
45
47
  this.controller = new AbortController();
@@ -76,6 +78,8 @@ class Stream {
76
78
  const stream = readableStreamAsyncIterable(this.stream);
77
79
  let buf = "";
78
80
  let prefixSeen = false;
81
+ let lastId;
82
+ let lastRetry;
79
83
  try {
80
84
  for (var _d = true, stream_1 = __asyncValues(stream), stream_1_1; stream_1_1 = yield __await(stream_1.next()), _a = stream_1_1.done, !_a; _d = true) {
81
85
  _c = stream_1_1.value;
@@ -89,6 +93,21 @@ class Stream {
89
93
  if (!line.trim()) {
90
94
  continue;
91
95
  }
96
+ if (line.startsWith(ID_PREFIX)) {
97
+ const idValue = line.slice(ID_PREFIX.length).trim();
98
+ if (!idValue.includes("\0")) {
99
+ lastId = idValue;
100
+ }
101
+ continue;
102
+ }
103
+ if (line.startsWith(RETRY_PREFIX)) {
104
+ const retryValue = line.slice(RETRY_PREFIX.length).trim();
105
+ const parsed = parseInt(retryValue, 10);
106
+ if (!Number.isNaN(parsed) && String(parsed) === retryValue) {
107
+ lastRetry = parsed;
108
+ }
109
+ continue;
110
+ }
92
111
  if (!prefixSeen && this.prefix != null) {
93
112
  const prefixIndex = line.indexOf(this.prefix);
94
113
  if (prefixIndex === -1) {
@@ -100,8 +119,8 @@ class Stream {
100
119
  if (this.streamTerminator != null && line.includes(this.streamTerminator)) {
101
120
  return yield __await(void 0);
102
121
  }
103
- const message = yield __await(this.parse((0, json_js_1.fromJson)(line)));
104
- yield yield __await(message);
122
+ const data = yield __await(this.parse((0, json_js_1.fromJson)(line)));
123
+ yield yield __await({ data, id: lastId, retry: lastRetry, event: undefined });
105
124
  prefixSeen = false;
106
125
  }
107
126
  }
@@ -122,6 +141,8 @@ class Stream {
122
141
  let buf = "";
123
142
  let eventType;
124
143
  let dataValue;
144
+ let lastId;
145
+ let lastRetry;
125
146
  try {
126
147
  for (var _d = true, stream_2 = __asyncValues(stream), stream_2_1; stream_2_1 = yield __await(stream_2.next()), _a = stream_2_1.done, !_a; _d = true) {
127
148
  _c = stream_2_1.value;
@@ -134,11 +155,11 @@ class Stream {
134
155
  buf = buf.slice(terminatorIndex + 1);
135
156
  if (!line.trim()) {
136
157
  if (dataValue != null) {
137
- const message = yield __await(this.dispatchSseEvent(dataValue, eventType));
138
- if (message == null) {
158
+ const data = yield __await(this.dispatchSseEvent(dataValue, eventType));
159
+ if (data == null) {
139
160
  return yield __await(void 0);
140
161
  }
141
- yield yield __await(message);
162
+ yield yield __await({ data, id: lastId, retry: lastRetry, event: eventType });
142
163
  }
143
164
  eventType = undefined;
144
165
  dataValue = undefined;
@@ -151,6 +172,19 @@ class Stream {
151
172
  const val = line.slice(DATA_PREFIX.length).trim();
152
173
  dataValue = dataValue != null ? `${dataValue}\n${val}` : val;
153
174
  }
175
+ else if (line.startsWith(ID_PREFIX)) {
176
+ const idValue = line.slice(ID_PREFIX.length).trim();
177
+ if (!idValue.includes("\0")) {
178
+ lastId = idValue;
179
+ }
180
+ }
181
+ else if (line.startsWith(RETRY_PREFIX)) {
182
+ const retryValue = line.slice(RETRY_PREFIX.length).trim();
183
+ const parsed = parseInt(retryValue, 10);
184
+ if (!Number.isNaN(parsed) && String(parsed) === retryValue) {
185
+ lastRetry = parsed;
186
+ }
187
+ }
154
188
  }
155
189
  }
156
190
  }
@@ -162,9 +196,9 @@ class Stream {
162
196
  finally { if (e_2) throw e_2.error; }
163
197
  }
164
198
  if (dataValue != null) {
165
- const message = yield __await(this.dispatchSseEvent(dataValue, eventType));
166
- if (message != null) {
167
- yield yield __await(message);
199
+ const data = yield __await(this.dispatchSseEvent(dataValue, eventType));
200
+ if (data != null) {
201
+ yield yield __await({ data, id: lastId, retry: lastRetry, event: eventType });
168
202
  }
169
203
  }
170
204
  });
@@ -180,6 +214,16 @@ class Stream {
180
214
  return this.parse(this.injectDiscriminator((0, json_js_1.fromJson)(dataValue), eventType));
181
215
  });
182
216
  }
217
+ withMetadata() {
218
+ const self = this;
219
+ return {
220
+ [Symbol.asyncIterator]() {
221
+ return __asyncGenerator(this, arguments, function* _a() {
222
+ yield __await(yield* __asyncDelegator(__asyncValues(self.iterMessages())));
223
+ });
224
+ },
225
+ };
226
+ }
183
227
  injectDiscriminator(parsed, eventType) {
184
228
  if (this.eventDiscriminator == null || eventType == null) {
185
229
  return parsed;
@@ -200,8 +244,8 @@ class Stream {
200
244
  for (var _e = true, _f = __asyncValues(this.iterMessages()), _g; _g = yield __await(_f.next()), _b = _g.done, !_b; _e = true) {
201
245
  _d = _g.value;
202
246
  _e = false;
203
- const message = _d;
204
- yield yield __await(message);
247
+ const event = _d;
248
+ yield yield __await(event.data);
205
249
  }
206
250
  }
207
251
  catch (e_3_1) { e_3 = { error: e_3_1 }; }
@@ -1 +1,2 @@
1
+ export type { ServerSentEvent } from "./Stream.js";
1
2
  export { Stream } from "./Stream.js";
@@ -10,7 +10,7 @@ class LatticeError extends Error {
10
10
  if (Error.captureStackTrace) {
11
11
  Error.captureStackTrace(this, this.constructor);
12
12
  }
13
- this.name = this.constructor.name;
13
+ this.name = "LatticeError";
14
14
  this.statusCode = statusCode;
15
15
  this.body = body;
16
16
  this.rawResponse = rawResponse;
@@ -9,7 +9,7 @@ class LatticeTimeoutError extends Error {
9
9
  if (Error.captureStackTrace) {
10
10
  Error.captureStackTrace(this, this.constructor);
11
11
  }
12
- this.name = this.constructor.name;
12
+ this.name = "LatticeTimeoutError";
13
13
  if ((opts === null || opts === void 0 ? void 0 : opts.cause) != null) {
14
14
  this.cause = opts.cause;
15
15
  }
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "4.12.0";
1
+ export declare const SDK_VERSION = "4.14.0";
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.SDK_VERSION = void 0;
4
- exports.SDK_VERSION = "4.12.0";
4
+ exports.SDK_VERSION = "4.14.0";
@@ -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.12.0",
10
- "User-Agent": "@anduril-industries/lattice-sdk/4.12.0",
9
+ "X-Fern-SDK-Version": "4.14.0",
10
+ "User-Agent": "@anduril-industries/lattice-sdk/4.14.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);
@@ -12,6 +12,6 @@ export class BadRequestError extends errors.LatticeError {
12
12
  if (Error.captureStackTrace) {
13
13
  Error.captureStackTrace(this, this.constructor);
14
14
  }
15
- this.name = this.constructor.name;
15
+ this.name = "BadRequestError";
16
16
  }
17
17
  }
@@ -12,6 +12,6 @@ export class ContentTooLargeError extends errors.LatticeError {
12
12
  if (Error.captureStackTrace) {
13
13
  Error.captureStackTrace(this, this.constructor);
14
14
  }
15
- this.name = this.constructor.name;
15
+ this.name = "ContentTooLargeError";
16
16
  }
17
17
  }
@@ -12,6 +12,6 @@ export class InsufficientStorageError extends errors.LatticeError {
12
12
  if (Error.captureStackTrace) {
13
13
  Error.captureStackTrace(this, this.constructor);
14
14
  }
15
- this.name = this.constructor.name;
15
+ this.name = "InsufficientStorageError";
16
16
  }
17
17
  }
@@ -12,6 +12,6 @@ export class InternalServerError extends errors.LatticeError {
12
12
  if (Error.captureStackTrace) {
13
13
  Error.captureStackTrace(this, this.constructor);
14
14
  }
15
- this.name = this.constructor.name;
15
+ this.name = "InternalServerError";
16
16
  }
17
17
  }
@@ -12,6 +12,6 @@ export class NotFoundError extends errors.LatticeError {
12
12
  if (Error.captureStackTrace) {
13
13
  Error.captureStackTrace(this, this.constructor);
14
14
  }
15
- this.name = this.constructor.name;
15
+ this.name = "NotFoundError";
16
16
  }
17
17
  }
@@ -12,6 +12,6 @@ export class RequestTimeoutError extends errors.LatticeError {
12
12
  if (Error.captureStackTrace) {
13
13
  Error.captureStackTrace(this, this.constructor);
14
14
  }
15
- this.name = this.constructor.name;
15
+ this.name = "RequestTimeoutError";
16
16
  }
17
17
  }
@@ -12,6 +12,6 @@ export class TooManyRequestsError extends errors.LatticeError {
12
12
  if (Error.captureStackTrace) {
13
13
  Error.captureStackTrace(this, this.constructor);
14
14
  }
15
- this.name = this.constructor.name;
15
+ this.name = "TooManyRequestsError";
16
16
  }
17
17
  }
@@ -12,6 +12,6 @@ export class UnauthorizedError extends errors.LatticeError {
12
12
  if (Error.captureStackTrace) {
13
13
  Error.captureStackTrace(this, this.constructor);
14
14
  }
15
- this.name = this.constructor.name;
15
+ this.name = "UnauthorizedError";
16
16
  }
17
17
  }
@@ -1,9 +1,9 @@
1
1
  export interface Color {
2
- /** The amount of red in the color as a value in the interval [0, 1]. */
2
+ /** The amount of red in the color as a value in the interval [0, 255]. */
3
3
  red?: number | undefined;
4
- /** The amount of green in the color as a value in the interval [0, 1]. */
4
+ /** The amount of green in the color as a value in the interval [0, 255]. */
5
5
  green?: number | undefined;
6
- /** The amount of blue in the color as a value in the interval [0, 1]. */
6
+ /** The amount of blue in the color as a value in the interval [0, 255]. */
7
7
  blue?: number | undefined;
8
8
  /**
9
9
  * The fraction of this color that should be applied to the pixel. That is,
@@ -6,6 +6,7 @@ export interface GeoDetails {
6
6
  type?: GeoDetails.Type | undefined;
7
7
  controlArea?: Lattice.ControlAreaDetails | undefined;
8
8
  acm?: Lattice.AcmDetails | undefined;
9
+ visualDetails?: Lattice.GeoVisualDetails | undefined;
9
10
  }
10
11
  export declare namespace GeoDetails {
11
12
  const Type: {
@@ -0,0 +1,10 @@
1
+ import type * as Lattice from "../index.mjs";
2
+ /**
3
+ * Details specific to displaying a geo-entity
4
+ */
5
+ export interface GeoVisualDetails {
6
+ /** Describes the fill color of a geo-entity. */
7
+ fillColor?: Lattice.Color | undefined;
8
+ /** Describes the line color of a geo-entity. */
9
+ lineColor?: Lattice.Color | undefined;
10
+ }
@@ -0,0 +1,2 @@
1
+ // This file was auto-generated from our API Definition.
2
+ export {};
@@ -61,6 +61,7 @@ export * from "./GeoPoint.mjs";
61
61
  export * from "./GeoPolygon.mjs";
62
62
  export * from "./GeoPolygonPosition.mjs";
63
63
  export * from "./GeoShape.mjs";
64
+ export * from "./GeoVisualDetails.mjs";
64
65
  export * from "./GoogleProtobufAny.mjs";
65
66
  export * from "./GroupChild.mjs";
66
67
  export * from "./GroupDetails.mjs";
@@ -61,6 +61,7 @@ export * from "./GeoPoint.mjs";
61
61
  export * from "./GeoPolygon.mjs";
62
62
  export * from "./GeoPolygonPosition.mjs";
63
63
  export * from "./GeoShape.mjs";
64
+ export * from "./GeoVisualDetails.mjs";
64
65
  export * from "./GoogleProtobufAny.mjs";
65
66
  export * from "./GroupChild.mjs";
66
67
  export * from "./GroupDetails.mjs";
@@ -23,6 +23,12 @@ export declare namespace Stream {
23
23
  eventDiscriminator?: string;
24
24
  }
25
25
  }
26
+ export interface ServerSentEvent<T> {
27
+ data: T;
28
+ id?: string;
29
+ retry?: number;
30
+ event?: string;
31
+ }
26
32
  export declare class Stream<T> implements AsyncIterable<T> {
27
33
  private stream;
28
34
  private parse;
@@ -46,6 +52,7 @@ export declare class Stream<T> implements AsyncIterable<T> {
46
52
  * Parses and returns a single SSE event, or returns null if the event is a stream terminator.
47
53
  */
48
54
  private dispatchSseEvent;
55
+ withMetadata(): AsyncIterable<ServerSentEvent<T>>;
49
56
  private injectDiscriminator;
50
57
  [Symbol.asyncIterator](): AsyncIterator<T, void, unknown>;
51
58
  private decodeChunk;
@@ -36,6 +36,8 @@ import { fromJson } from "../json.mjs";
36
36
  import { RUNTIME } from "../runtime/index.mjs";
37
37
  const DATA_PREFIX = "data:";
38
38
  const EVENT_PREFIX = "event:";
39
+ const ID_PREFIX = "id:";
40
+ const RETRY_PREFIX = "retry:";
39
41
  export class Stream {
40
42
  constructor({ stream, parse, eventShape, signal }) {
41
43
  this.controller = new AbortController();
@@ -72,6 +74,8 @@ export class Stream {
72
74
  const stream = readableStreamAsyncIterable(this.stream);
73
75
  let buf = "";
74
76
  let prefixSeen = false;
77
+ let lastId;
78
+ let lastRetry;
75
79
  try {
76
80
  for (var _d = true, stream_1 = __asyncValues(stream), stream_1_1; stream_1_1 = yield __await(stream_1.next()), _a = stream_1_1.done, !_a; _d = true) {
77
81
  _c = stream_1_1.value;
@@ -85,6 +89,21 @@ export class Stream {
85
89
  if (!line.trim()) {
86
90
  continue;
87
91
  }
92
+ if (line.startsWith(ID_PREFIX)) {
93
+ const idValue = line.slice(ID_PREFIX.length).trim();
94
+ if (!idValue.includes("\0")) {
95
+ lastId = idValue;
96
+ }
97
+ continue;
98
+ }
99
+ if (line.startsWith(RETRY_PREFIX)) {
100
+ const retryValue = line.slice(RETRY_PREFIX.length).trim();
101
+ const parsed = parseInt(retryValue, 10);
102
+ if (!Number.isNaN(parsed) && String(parsed) === retryValue) {
103
+ lastRetry = parsed;
104
+ }
105
+ continue;
106
+ }
88
107
  if (!prefixSeen && this.prefix != null) {
89
108
  const prefixIndex = line.indexOf(this.prefix);
90
109
  if (prefixIndex === -1) {
@@ -96,8 +115,8 @@ export class Stream {
96
115
  if (this.streamTerminator != null && line.includes(this.streamTerminator)) {
97
116
  return yield __await(void 0);
98
117
  }
99
- const message = yield __await(this.parse(fromJson(line)));
100
- yield yield __await(message);
118
+ const data = yield __await(this.parse(fromJson(line)));
119
+ yield yield __await({ data, id: lastId, retry: lastRetry, event: undefined });
101
120
  prefixSeen = false;
102
121
  }
103
122
  }
@@ -118,6 +137,8 @@ export class Stream {
118
137
  let buf = "";
119
138
  let eventType;
120
139
  let dataValue;
140
+ let lastId;
141
+ let lastRetry;
121
142
  try {
122
143
  for (var _d = true, stream_2 = __asyncValues(stream), stream_2_1; stream_2_1 = yield __await(stream_2.next()), _a = stream_2_1.done, !_a; _d = true) {
123
144
  _c = stream_2_1.value;
@@ -130,11 +151,11 @@ export class Stream {
130
151
  buf = buf.slice(terminatorIndex + 1);
131
152
  if (!line.trim()) {
132
153
  if (dataValue != null) {
133
- const message = yield __await(this.dispatchSseEvent(dataValue, eventType));
134
- if (message == null) {
154
+ const data = yield __await(this.dispatchSseEvent(dataValue, eventType));
155
+ if (data == null) {
135
156
  return yield __await(void 0);
136
157
  }
137
- yield yield __await(message);
158
+ yield yield __await({ data, id: lastId, retry: lastRetry, event: eventType });
138
159
  }
139
160
  eventType = undefined;
140
161
  dataValue = undefined;
@@ -147,6 +168,19 @@ export class Stream {
147
168
  const val = line.slice(DATA_PREFIX.length).trim();
148
169
  dataValue = dataValue != null ? `${dataValue}\n${val}` : val;
149
170
  }
171
+ else if (line.startsWith(ID_PREFIX)) {
172
+ const idValue = line.slice(ID_PREFIX.length).trim();
173
+ if (!idValue.includes("\0")) {
174
+ lastId = idValue;
175
+ }
176
+ }
177
+ else if (line.startsWith(RETRY_PREFIX)) {
178
+ const retryValue = line.slice(RETRY_PREFIX.length).trim();
179
+ const parsed = parseInt(retryValue, 10);
180
+ if (!Number.isNaN(parsed) && String(parsed) === retryValue) {
181
+ lastRetry = parsed;
182
+ }
183
+ }
150
184
  }
151
185
  }
152
186
  }
@@ -158,9 +192,9 @@ export class Stream {
158
192
  finally { if (e_2) throw e_2.error; }
159
193
  }
160
194
  if (dataValue != null) {
161
- const message = yield __await(this.dispatchSseEvent(dataValue, eventType));
162
- if (message != null) {
163
- yield yield __await(message);
195
+ const data = yield __await(this.dispatchSseEvent(dataValue, eventType));
196
+ if (data != null) {
197
+ yield yield __await({ data, id: lastId, retry: lastRetry, event: eventType });
164
198
  }
165
199
  }
166
200
  });
@@ -176,6 +210,16 @@ export class Stream {
176
210
  return this.parse(this.injectDiscriminator(fromJson(dataValue), eventType));
177
211
  });
178
212
  }
213
+ withMetadata() {
214
+ const self = this;
215
+ return {
216
+ [Symbol.asyncIterator]() {
217
+ return __asyncGenerator(this, arguments, function* _a() {
218
+ yield __await(yield* __asyncDelegator(__asyncValues(self.iterMessages())));
219
+ });
220
+ },
221
+ };
222
+ }
179
223
  injectDiscriminator(parsed, eventType) {
180
224
  if (this.eventDiscriminator == null || eventType == null) {
181
225
  return parsed;
@@ -196,8 +240,8 @@ export class Stream {
196
240
  for (var _e = true, _f = __asyncValues(this.iterMessages()), _g; _g = yield __await(_f.next()), _b = _g.done, !_b; _e = true) {
197
241
  _d = _g.value;
198
242
  _e = false;
199
- const message = _d;
200
- yield yield __await(message);
243
+ const event = _d;
244
+ yield yield __await(event.data);
201
245
  }
202
246
  }
203
247
  catch (e_3_1) { e_3 = { error: e_3_1 }; }
@@ -1 +1,2 @@
1
+ export type { ServerSentEvent } from "./Stream.mjs";
1
2
  export { Stream } from "./Stream.mjs";
@@ -7,7 +7,7 @@ export class LatticeError extends Error {
7
7
  if (Error.captureStackTrace) {
8
8
  Error.captureStackTrace(this, this.constructor);
9
9
  }
10
- this.name = this.constructor.name;
10
+ this.name = "LatticeError";
11
11
  this.statusCode = statusCode;
12
12
  this.body = body;
13
13
  this.rawResponse = rawResponse;
@@ -6,7 +6,7 @@ export class LatticeTimeoutError extends Error {
6
6
  if (Error.captureStackTrace) {
7
7
  Error.captureStackTrace(this, this.constructor);
8
8
  }
9
- this.name = this.constructor.name;
9
+ this.name = "LatticeTimeoutError";
10
10
  if ((opts === null || opts === void 0 ? void 0 : opts.cause) != null) {
11
11
  this.cause = opts.cause;
12
12
  }
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "4.12.0";
1
+ export declare const SDK_VERSION = "4.14.0";
@@ -1 +1 @@
1
- export const SDK_VERSION = "4.12.0";
1
+ export const SDK_VERSION = "4.14.0";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anduril-industries/lattice-sdk",
3
- "version": "4.12.0",
3
+ "version": "4.14.0",
4
4
  "private": false,
5
5
  "repository": {
6
6
  "type": "git",