@launchdarkly/js-sdk-common 2.29.0 → 2.31.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 (46) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/dist/cjs/api/data/LDEvaluationReason.d.ts +11 -0
  3. package/dist/cjs/api/data/LDEvaluationReason.d.ts.map +1 -1
  4. package/dist/cjs/api/platform/Filesystem.d.ts +31 -1
  5. package/dist/cjs/api/platform/Filesystem.d.ts.map +1 -1
  6. package/dist/cjs/api/platform/Requests.d.ts +85 -0
  7. package/dist/cjs/api/platform/Requests.d.ts.map +1 -1
  8. package/dist/cjs/index.cjs +153 -8
  9. package/dist/cjs/index.cjs.map +1 -1
  10. package/dist/cjs/internal/evaluation/EventFactoryBase.d.ts +1 -0
  11. package/dist/cjs/internal/evaluation/EventFactoryBase.d.ts.map +1 -1
  12. package/dist/cjs/internal/events/EventProcessor.d.ts.map +1 -1
  13. package/dist/cjs/internal/events/InputEvalEvent.d.ts +7 -1
  14. package/dist/cjs/internal/events/InputEvalEvent.d.ts.map +1 -1
  15. package/dist/cjs/internal/events/LDEventSummarizer.d.ts.map +1 -1
  16. package/dist/cjs/internal/fetch/StreamingResponse.d.ts +83 -0
  17. package/dist/cjs/internal/fetch/StreamingResponse.d.ts.map +1 -0
  18. package/dist/cjs/internal/fetch/index.d.ts +3 -0
  19. package/dist/cjs/internal/fetch/index.d.ts.map +1 -0
  20. package/dist/cjs/internal/fetch/toRequestInit.d.ts +12 -0
  21. package/dist/cjs/internal/fetch/toRequestInit.d.ts.map +1 -0
  22. package/dist/cjs/internal/index.d.ts +1 -0
  23. package/dist/cjs/internal/index.d.ts.map +1 -1
  24. package/dist/esm/api/data/LDEvaluationReason.d.ts +11 -0
  25. package/dist/esm/api/data/LDEvaluationReason.d.ts.map +1 -1
  26. package/dist/esm/api/platform/Filesystem.d.ts +31 -1
  27. package/dist/esm/api/platform/Filesystem.d.ts.map +1 -1
  28. package/dist/esm/api/platform/Requests.d.ts +85 -0
  29. package/dist/esm/api/platform/Requests.d.ts.map +1 -1
  30. package/dist/esm/index.mjs +153 -8
  31. package/dist/esm/index.mjs.map +1 -1
  32. package/dist/esm/internal/evaluation/EventFactoryBase.d.ts +1 -0
  33. package/dist/esm/internal/evaluation/EventFactoryBase.d.ts.map +1 -1
  34. package/dist/esm/internal/events/EventProcessor.d.ts.map +1 -1
  35. package/dist/esm/internal/events/InputEvalEvent.d.ts +7 -1
  36. package/dist/esm/internal/events/InputEvalEvent.d.ts.map +1 -1
  37. package/dist/esm/internal/events/LDEventSummarizer.d.ts.map +1 -1
  38. package/dist/esm/internal/fetch/StreamingResponse.d.ts +83 -0
  39. package/dist/esm/internal/fetch/StreamingResponse.d.ts.map +1 -0
  40. package/dist/esm/internal/fetch/index.d.ts +3 -0
  41. package/dist/esm/internal/fetch/index.d.ts.map +1 -0
  42. package/dist/esm/internal/fetch/toRequestInit.d.ts +12 -0
  43. package/dist/esm/internal/fetch/toRequestInit.d.ts.map +1 -0
  44. package/dist/esm/internal/index.d.ts +1 -0
  45. package/dist/esm/internal/index.d.ts.map +1 -1
  46. package/package.json +1 -1
@@ -0,0 +1,83 @@
1
+ import type { Response, ResponseBody } from '../../api/platform/Requests';
2
+ /**
3
+ * The shape of raw HTTP headers: names mapped to a value, a list of values, or no value.
4
+ * A Node `IncomingHttpHeaders` object satisfies this shape.
5
+ */
6
+ export type RawHeaders = Record<string, string | string[] | undefined>;
7
+ /**
8
+ * The source of response chunks. A platform provides the iterator from its own stream type.
9
+ * For example, a Node `IncomingMessage` provides a compatible iterator through its
10
+ * `Symbol.asyncIterator` method.
11
+ */
12
+ export interface ResponseChunkIterator {
13
+ /**
14
+ * Resolves with the next chunk, or with `done: true` when the stream ends. Rejects when
15
+ * the connection terminates before the server ends the stream. A chunk delivered together
16
+ * with `done: true` is discarded, so the iterator must deliver the last chunk on its own.
17
+ */
18
+ next(): Promise<{
19
+ done?: boolean;
20
+ value?: Uint8Array;
21
+ }>;
22
+ /**
23
+ * Releases the iterator. A Node `Readable` iterator queues this call behind a pending
24
+ * read, so this call alone does not release an idle stream.
25
+ */
26
+ return?(): Promise<{
27
+ done?: boolean;
28
+ value?: Uint8Array;
29
+ }>;
30
+ }
31
+ /**
32
+ * The key of the chunk iterator on a streaming response source. A consumer's compile-time
33
+ * lib may not declare `Symbol.asyncIterator`. This conditional resolves to that symbol when
34
+ * the lib declares it, and to no key at all otherwise. That keeps these declarations valid
35
+ * for every consumer, like `AbortSignalLike` does for the abort signal. Without the symbol,
36
+ * the source type cannot require the iterator, and a source without a stream fails at run
37
+ * time instead of compile time.
38
+ */
39
+ type AsyncIteratorKey = typeof Symbol extends {
40
+ readonly asyncIterator: infer S;
41
+ } ? S extends keyof any ? S : never : never;
42
+ /**
43
+ * The source of a streaming response: the metadata and the chunk stream. A Node
44
+ * `IncomingMessage` satisfies this shape, so a platform can pass its message directly.
45
+ */
46
+ export type StreamingResponseSource = {
47
+ headers: RawHeaders;
48
+ statusCode?: number;
49
+ statusMessage?: string;
50
+ /**
51
+ * Destroys the underlying stream. `cancel` uses it to release the connection even while
52
+ * a read is in progress. A Node `Readable` provides it. A source without it must release
53
+ * through the iterator `return` method; a source whose `return` queues behind a pending
54
+ * read, like a Node readable iterator, must provide `destroy` or `cancel` cannot release
55
+ * it mid-read.
56
+ */
57
+ destroy?(): void;
58
+ } & {
59
+ [K in AsyncIteratorKey]: () => ResponseChunkIterator;
60
+ };
61
+ /**
62
+ * A response for a streaming request. Unlike the base response, the body and the status
63
+ * message are always present.
64
+ */
65
+ export interface StreamingResponse extends Response {
66
+ body: ResponseBody;
67
+ statusText: string;
68
+ }
69
+ /**
70
+ * Creates a response for a streaming request. The response does not buffer the body. Each
71
+ * read hands out the next chunk from the source iterator. The body does not enforce a
72
+ * consumer lock: every `getReader`, `text`, and `json` call reads from the same iterator,
73
+ * so the caller uses one consumer per response. The `cancel` methods on the body and the
74
+ * reader call every release function the source provides: they destroy the source when it
75
+ * has a `destroy` method, and they also call the iterator's `return` method when one
76
+ * exists. The body passes through as-is, so the caller decodes any content encoding first.
77
+ *
78
+ * @param source The raw platform response, for example a Node `IncomingMessage`. A missing
79
+ * status code maps to 0, and a missing status message maps to an empty string.
80
+ */
81
+ export declare function createStreamingResponse(source: StreamingResponseSource): StreamingResponse;
82
+ export {};
83
+ //# sourceMappingURL=StreamingResponse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StreamingResponse.d.ts","sourceRoot":"","sources":["../../../src/internal/fetch/StreamingResponse.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAW,QAAQ,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AASnF;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC,CAAC;AAEvE;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;;OAIG;IACH,IAAI,IAAI,OAAO,CAAC;QAAE,IAAI,CAAC,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,UAAU,CAAA;KAAE,CAAC,CAAC;IAExD;;;OAGG;IACH,MAAM,CAAC,IAAI,OAAO,CAAC;QAAE,IAAI,CAAC,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,UAAU,CAAA;KAAE,CAAC,CAAC;CAC5D;AAED;;;;;;;GAOG;AACH,KAAK,gBAAgB,GAAG,OAAO,MAAM,SAAS;IAAE,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC,CAAA;CAAE,GAC7E,CAAC,SAAS,MAAM,GAAG,GACjB,CAAC,GACD,KAAK,GACP,KAAK,CAAC;AAEV;;;GAGG;AACH,MAAM,MAAM,uBAAuB,GAAG;IACpC,OAAO,EAAE,UAAU,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IAEvB;;;;;;OAMG;IACH,OAAO,CAAC,IAAI,IAAI,CAAC;CAClB,GAAG;KAAG,CAAC,IAAI,gBAAgB,GAAG,MAAM,qBAAqB;CAAE,CAAC;AA+B7D;;;GAGG;AACH,MAAM,WAAW,iBAAkB,SAAQ,QAAQ;IACjD,IAAI,EAAE,YAAY,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,uBAAuB,GAAG,iBAAiB,CA6E1F"}
@@ -0,0 +1,3 @@
1
+ export * from './StreamingResponse';
2
+ export * from './toRequestInit';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/internal/fetch/index.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC;AACpC,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,12 @@
1
+ import { Options } from '../../api/platform/Requests';
2
+ /**
3
+ * Converts the request options into the init shape a platform's native `fetch` accepts. A
4
+ * platform can declare its `AbortSignal` as a lexical class, which `AbortSignalLike`
5
+ * cannot resolve to, so the `signal` member widens here. The caller must pass a signal
6
+ * created by the running platform. The widening then only restores the type the runtime
7
+ * already has.
8
+ */
9
+ export declare function toRequestInit(options: Options): Omit<Options, 'signal'> & {
10
+ signal?: any;
11
+ };
12
+ //# sourceMappingURL=toRequestInit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"toRequestInit.d.ts","sourceRoot":"","sources":["../../../src/internal/fetch/toRequestInit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAEtD;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC,OAAO,EAAE,QAAQ,CAAC,GAAG;IAAE,MAAM,CAAC,EAAE,GAAG,CAAA;CAAE,CAE1F"}
@@ -3,6 +3,7 @@ export * from './diagnostics';
3
3
  export * from './evaluation';
4
4
  export * from './events';
5
5
  export * from './fdv2';
6
+ export * from './fetch';
6
7
  export * from './metadata';
7
8
  export * from './plugins';
8
9
  export * from './json';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/internal/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/internal/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,YAAY,CAAC;AAC3B,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@launchdarkly/js-sdk-common",
3
- "version": "2.29.0",
3
+ "version": "2.31.0",
4
4
  "type": "module",
5
5
  "main": "./dist/esm/index.mjs",
6
6
  "types": "./dist/esm/index.d.ts",