@thirdweb-dev/nebula 0.1.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 (47) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +46 -0
  3. package/dist/cjs/client/client.gen.js +9 -0
  4. package/dist/cjs/client/client.gen.js.map +1 -0
  5. package/dist/cjs/client/index.js +7 -0
  6. package/dist/cjs/client/index.js.map +1 -0
  7. package/dist/cjs/client/sdk.gen.js +811 -0
  8. package/dist/cjs/client/sdk.gen.js.map +1 -0
  9. package/dist/cjs/client/types.gen.js +4 -0
  10. package/dist/cjs/client/types.gen.js.map +1 -0
  11. package/dist/cjs/configure.js +57 -0
  12. package/dist/cjs/configure.js.map +1 -0
  13. package/dist/cjs/exports/thirdweb.js +10 -0
  14. package/dist/cjs/exports/thirdweb.js.map +1 -0
  15. package/dist/cjs/package.json +1 -0
  16. package/dist/esm/client/client.gen.js +6 -0
  17. package/dist/esm/client/client.gen.js.map +1 -0
  18. package/dist/esm/client/index.js +4 -0
  19. package/dist/esm/client/index.js.map +1 -0
  20. package/dist/esm/client/sdk.gen.js +765 -0
  21. package/dist/esm/client/sdk.gen.js.map +1 -0
  22. package/dist/esm/client/types.gen.js +3 -0
  23. package/dist/esm/client/types.gen.js.map +1 -0
  24. package/dist/esm/configure.js +52 -0
  25. package/dist/esm/configure.js.map +1 -0
  26. package/dist/esm/exports/thirdweb.js +3 -0
  27. package/dist/esm/exports/thirdweb.js.map +1 -0
  28. package/dist/esm/package.json +1 -0
  29. package/dist/types/client/client.gen.d.ts +13 -0
  30. package/dist/types/client/client.gen.d.ts.map +1 -0
  31. package/dist/types/client/index.d.ts +3 -0
  32. package/dist/types/client/index.d.ts.map +1 -0
  33. package/dist/types/client/sdk.gen.d.ts +225 -0
  34. package/dist/types/client/sdk.gen.d.ts.map +1 -0
  35. package/dist/types/client/types.gen.d.ts +3803 -0
  36. package/dist/types/client/types.gen.d.ts.map +1 -0
  37. package/dist/types/configure.d.ts +13 -0
  38. package/dist/types/configure.d.ts.map +1 -0
  39. package/dist/types/exports/thirdweb.d.ts +4 -0
  40. package/dist/types/exports/thirdweb.d.ts.map +1 -0
  41. package/package.json +62 -0
  42. package/src/client/client.gen.ts +28 -0
  43. package/src/client/index.ts +4 -0
  44. package/src/client/sdk.gen.ts +1213 -0
  45. package/src/client/types.gen.ts +4270 -0
  46. package/src/configure.ts +76 -0
  47. package/src/exports/thirdweb.ts +8 -0
@@ -0,0 +1,76 @@
1
+ import { type Config, createClient, createConfig } from "@hey-api/client-fetch";
2
+ import type { ThirdwebClient } from "thirdweb";
3
+ import { client } from "./client/client.gen.js";
4
+
5
+ export type NebulaClientOptions = {
6
+ readonly clientId?: string;
7
+ readonly secretKey?: string;
8
+ readonly authToken?: string;
9
+ };
10
+
11
+ export function getNebulaClient(baseUrl: string, options: NebulaClientOptions) {
12
+ return createClient(
13
+ createConfig({
14
+ baseUrl,
15
+ headers: {
16
+ ...(options.clientId && { "x-client-id": options.clientId }),
17
+ ...(options.secretKey && { "x-secret-key": options.secretKey }),
18
+ ...(options.authToken && {
19
+ authorization: `Bearer ${options.authToken}`,
20
+ }),
21
+ },
22
+ }),
23
+ );
24
+ }
25
+
26
+ export function configure(
27
+ options: NebulaClientOptions & { override?: Config },
28
+ ) {
29
+ client.setConfig({
30
+ bodySerializer: stringify,
31
+ headers: {
32
+ ...(options.clientId && { "x-client-id": options.clientId }),
33
+ ...(options.secretKey && { "x-secret-key": options.secretKey }),
34
+ ...(options.authToken && {
35
+ authorization: `Bearer ${options.authToken}`,
36
+ }),
37
+ },
38
+ ...(options.override ?? {}),
39
+ });
40
+ }
41
+
42
+ export function configureWithClient(
43
+ twClient: ThirdwebClient,
44
+ options?: NebulaClientOptions,
45
+ override?: Config,
46
+ ) {
47
+ client.setConfig({
48
+ bodySerializer: stringify,
49
+ headers: {
50
+ ...(twClient.clientId && { "x-client-id": twClient.clientId }),
51
+ ...(twClient.secretKey && { "x-secret-key": twClient.secretKey }),
52
+ ...(options?.authToken && {
53
+ authorization: `Bearer ${options.authToken}`,
54
+ }),
55
+ },
56
+ ...(override ?? {}),
57
+ });
58
+ }
59
+
60
+ function stringify(
61
+ // biome-ignore lint/suspicious/noExplicitAny: JSON.stringify signature
62
+ value: any,
63
+ // biome-ignore lint/suspicious/noExplicitAny: JSON.stringify signature
64
+ replacer?: ((this: any, key: string, value: any) => any) | null,
65
+ space?: string | number,
66
+ ) {
67
+ const res = JSON.stringify(
68
+ value,
69
+ (key, value_) => {
70
+ const value__ = typeof value_ === "bigint" ? value_.toString() : value_;
71
+ return typeof replacer === "function" ? replacer(key, value__) : value__;
72
+ },
73
+ space,
74
+ );
75
+ return res;
76
+ }
@@ -0,0 +1,8 @@
1
+ export type { CreateClientConfig } from "../client/client.gen.js";
2
+ export * from "../client/index.js";
3
+ export {
4
+ configure,
5
+ configureWithClient,
6
+ getNebulaClient,
7
+ type NebulaClientOptions,
8
+ } from "../configure.js";