@@ -9,13 +9,41 @@ Serializes JavaScript objects to URLSearchParams.
9
9
10
10
Defines the standard for how the Seam SDKs and other Seam API consumers
11
11
should serialize objects to [ URLSearchParams] in HTTP GET requests.
12
-
13
12
Serves as a reference implementation for Seam SDKs in other languages.
14
13
15
14
See this test for the [ serialization behavior] ( ./test/serialization.test.ts ) .
16
15
17
16
[ URLSearchParams ] : https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams
18
17
18
+ ## Motivation
19
+
20
+ URL search parameters are strings, however the Seam API will parse parameters as complex types.
21
+ The Seam SDK must accept the complex types as input and serialize these
22
+ to search parameters in a way supported by the Seam API.
23
+
24
+ There is no single standard for this serialization.
25
+ This module establishes the serialization standard adopted by the Seam API.
26
+
27
+ ### Why not use [ URLSearchParams] ( https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams ) ?
28
+
29
+ Passing a raw object to URLSearchParams has unpredictable serialization behavior.
30
+
31
+ ### Why not [ qs] ( https://github.com/ljharb/qs ) ?
32
+
33
+ - Not a zero-dependency module. Has quite a few dependency layers.
34
+ - Impractile as a reference implementation.
35
+ Since qs enables complex, non-standard parsing and serialization,
36
+ this makes ensuing SDK parity much harder.
37
+ Similarly, this puts an unreasonable burden on User's of the HTTP API or those implementing their own client.
38
+ - The Seam API must ensure it handles a well defined set of non-string query parameters consistency.
39
+ Using qs would allow the SDK to send unsupported or incorrectly serialized parameter types to the API
40
+ resulting in unexpected behavior.
41
+
42
+ ### Why not use the default [ Axios] ( https://axios-http.com/ ) serializer?
43
+
44
+ Using the default [ Axios] serializer was the original approach,
45
+ however it had similar issues to using URLSearchParams and qs as noted above.
46
+
19
47
## Installation
20
48
21
49
Add this as a dependency to your project using [ npm] with
0 commit comments