@opensea/sdk 12.5.0 → 12.7.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 +53 -0
- package/lib/api/api.d.ts +19 -3
- package/lib/api/api.js +24 -13
- package/lib/api/api.js.map +1 -1
- package/lib/api/nfts.d.ts +7 -2
- package/lib/api/nfts.js +10 -1
- package/lib/api/nfts.js.map +1 -1
- package/lib/api/types.d.ts +37 -1
- package/lib/api/types.js.map +1 -1
- package/lib/auth/index.d.ts +2 -0
- package/lib/auth/index.js +13 -10
- package/lib/auth/index.js.map +1 -1
- package/lib/auth/oauth-types.d.ts +10 -0
- package/lib/auth/oauth.d.ts +16 -0
- package/lib/auth/oauth.js +61 -22
- package/lib/auth/oauth.js.map +1 -1
- package/lib/auth/siwx.d.ts +17 -1
- package/lib/auth/siwx.js +10 -4
- package/lib/auth/siwx.js.map +1 -1
- package/lib/auth/types.d.ts +11 -0
- package/lib/sdk/base.d.ts +9 -2
- package/lib/sdk/base.js +7 -2
- package/lib/sdk/base.js.map +1 -1
- package/lib/sdk/orders.d.ts +27 -3
- package/lib/sdk/orders.js +142 -176
- package/lib/sdk/orders.js.map +1 -1
- package/lib/types.d.ts +8 -3
- package/lib/types.js.map +1 -1
- package/lib/utils/case.d.ts +22 -0
- package/lib/utils/fetchTransport.d.ts +29 -0
- package/lib/utils/fetchTransport.js +26 -0
- package/lib/utils/fetchTransport.js.map +1 -0
- package/lib/utils/index.d.ts +1 -0
- package/lib/utils/index.js +7 -0
- package/lib/utils/index.js.map +1 -1
- package/package.json +2 -2
- package/src/api/api.ts +36 -18
- package/src/api/nfts.ts +11 -0
- package/src/api/types.ts +43 -0
- package/src/auth/index.ts +45 -26
- package/src/auth/oauth-types.ts +11 -0
- package/src/auth/oauth.ts +70 -26
- package/src/auth/siwx.ts +30 -10
- package/src/auth/types.ts +12 -0
- package/src/sdk/base.ts +8 -1
- package/src/sdk/orders.ts +196 -226
- package/src/types.ts +9 -3
- package/src/utils/case.ts +22 -0
- package/src/utils/fetchTransport.ts +36 -0
- package/src/utils/index.ts +7 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Transport used to perform an HTTP request, defaulting to the global `fetch`.
|
|
3
|
+
*
|
|
4
|
+
* Accepted by {@link OpenSeaAPIConfig.fetch} and by the auth helpers' configs, so a consumer can
|
|
5
|
+
* install a cache, a shared rate limiter, retries or request-level instrumentation once instead
|
|
6
|
+
* of wrapping each call site.
|
|
7
|
+
*
|
|
8
|
+
* @category API Models
|
|
9
|
+
*/
|
|
10
|
+
export type FetchImpl = typeof globalThis.fetch
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Perform a request through `impl`, or through the global `fetch` when no transport was
|
|
14
|
+
* configured.
|
|
15
|
+
*
|
|
16
|
+
* The receiver is always `globalThis`, so a caller can pass native fetch unbound
|
|
17
|
+
* (`fetch: globalThis.fetch`). Per Web IDL, an operation hanging off the global replaces a `null`
|
|
18
|
+
* or `undefined` receiver with the global object, so a bare `impl(...args)` happens to work for
|
|
19
|
+
* unbound native fetch; a receiver that is some *other* object does not. Verified in Chrome 152:
|
|
20
|
+
* `fetch.call(undefined, url)` and `fetch.call(null, url)` both resolve, while `fetch.call({}, url)`
|
|
21
|
+
* rejects with "Failed to execute 'fetch' on 'Window': Illegal invocation". Passing `globalThis`
|
|
22
|
+
* explicitly is what keeps that distinction from depending on how each call site is written.
|
|
23
|
+
*
|
|
24
|
+
* A bound function or an arrow ignores the `thisArg`, so a transport the caller deliberately bound
|
|
25
|
+
* keeps its own receiver.
|
|
26
|
+
*
|
|
27
|
+
* The global is read at call time rather than captured, so a caller who swaps `globalThis.fetch`
|
|
28
|
+
* after construction still takes effect.
|
|
29
|
+
*/
|
|
30
|
+
export function fetchWith(
|
|
31
|
+
impl: FetchImpl | undefined,
|
|
32
|
+
...args: Parameters<FetchImpl>
|
|
33
|
+
): Promise<Response> {
|
|
34
|
+
const transport = impl ?? globalThis.fetch
|
|
35
|
+
return transport.call(globalThis, ...args)
|
|
36
|
+
}
|
package/src/utils/index.ts
CHANGED
|
@@ -1,2 +1,9 @@
|
|
|
1
|
+
// `./case` carries the SDK's response-casing contract: the API speaks
|
|
2
|
+
// snake_case, the SDK hands back camelCase. Consumers need `Camelize` by name
|
|
3
|
+
// to write down the shape of anything they get back whose camelized view has
|
|
4
|
+
// no dedicated alias in this package. Without it the only spelled-out type for
|
|
5
|
+
// such a response is the raw `@opensea/api-types` one, which is the wrong
|
|
6
|
+
// shape at runtime and, for some schemas, still type-checks.
|
|
7
|
+
export * from "./case"
|
|
1
8
|
export * from "./dateHelper"
|
|
2
9
|
export * from "./utils"
|