@xoxno/sdk-js 0.1.355 → 1.0.1

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.
@@ -0,0 +1,19 @@
1
+ import type { CollectionMintProfileDocWithStages, EventProfile } from '@xoxno/types';
2
+ export declare const routes: {
3
+ readonly '/collection/:creatorTag/:collectionTag/drop-info': {
4
+ readonly input: {};
5
+ readonly output: CollectionMintProfileDocWithStages;
6
+ };
7
+ readonly '/user/me/event': {
8
+ readonly input: {
9
+ extended: boolean;
10
+ };
11
+ readonly output: EventProfile[];
12
+ readonly securityMode: "requiredAny";
13
+ };
14
+ readonly '/user/me/event/badge': {
15
+ readonly input: {};
16
+ readonly output: string;
17
+ readonly securityMode: "requiredAny";
18
+ };
19
+ };
@@ -0,0 +1,86 @@
1
+ import { XOXNOClient } from '../utils/api';
2
+ import { endpoints as routes } from './swagger';
3
+ type RemoveColon<S extends string> = S extends `:${infer R}` ? R : S;
4
+ type CamelCase<S extends string> = S extends `${infer H}-${infer T}${infer Rest}` ? `${H}${Capitalize<`${T}${Rest}`>}` : S;
5
+ type IsEmptyObj<T> = keyof T extends never ? true : false;
6
+ type NeedsDefault<I, O> = IsEmptyObj<I> extends true ? IsEmptyObj<O> extends true ? false : true : true;
7
+ type CollectParams<S extends string> = S extends `${string}:${infer P}/${infer R}` ? {
8
+ [K in P]: string;
9
+ } & CollectParams<`/${R}`> : S extends `${string}:${infer P}` ? {
10
+ [K in P]: string;
11
+ } : object;
12
+ type RequireAtLeastOne<T> = {
13
+ [K in keyof T]: Required<Pick<T, K>> & Partial<Omit<T, K>>;
14
+ }[keyof T];
15
+ type BodyBag<VB, Defined extends boolean> = Defined extends true ? IsEmptyObj<VB> extends true ? {
16
+ body?: never;
17
+ } : {
18
+ body: RequireAtLeastOne<VB>;
19
+ } : {
20
+ body?: RequireAtLeastOne<VB>;
21
+ };
22
+ type SafeHeaders = Record<string, string> & {
23
+ authorization?: never;
24
+ Authorization?: never;
25
+ };
26
+ type OurRequestInit = Omit<RequestInit, 'body' | 'headers'> & {
27
+ headers?: SafeHeaders;
28
+ };
29
+ type SecurityModeOf<T> = T extends {
30
+ securityMode: infer S;
31
+ } ? S : undefined;
32
+ type AuthBag<M> = M extends 'optionalAny' ? {
33
+ auth?: string;
34
+ } : M extends 'requiredAny' | 'requiredWeb2' | 'requiredJwt' ? {
35
+ auth: string;
36
+ } : {
37
+ auth?: never;
38
+ };
39
+ type VerbExtras<Full, PBag> = {
40
+ [Verb in keyof Full as Verb extends 'input' | 'body' | 'output' | 'securityMode' ? never : Verb]: Full[Verb] extends {
41
+ input: infer VI;
42
+ output: infer VO;
43
+ } ? (args: VI & PBag & BodyBag<Full[Verb] extends {
44
+ body: infer VB;
45
+ } ? VB : never, 'body' extends keyof Full[Verb] ? true : false> & AuthBag<SecurityModeOf<Full[Verb]>> & OurRequestInit) => Promise<VO> : never;
46
+ };
47
+ type DropKey<T, K extends PropertyKey> = {
48
+ [P in Exclude<keyof T, K>]: T[P];
49
+ };
50
+ type RequiredKeys<T> = {
51
+ [K in keyof T]-?: {} extends Pick<T, K> ? never : K;
52
+ }[keyof T];
53
+ type HasRequiredKeys<T> = [RequiredKeys<T>] extends [never] ? false : true;
54
+ type PathToTree<P extends string, I, O, Full = {
55
+ input: I;
56
+ output: O;
57
+ }, Root extends string = P, Bag extends object = CollectParams<Root>> = P extends `/${infer Head}/${infer Rest}` ? Head extends `:${infer Param}` ? {
58
+ [K in CamelCase<Param>]: (value: string) => PathToTree<`/${Rest}`, I, O, Full, Root, DropKey<Bag, Param>>;
59
+ } : {
60
+ [K in CamelCase<Head>]: PathToTree<`/${Rest}`, I, O, Full, Root, Bag>;
61
+ } : P extends `/:${infer Param}` ? {
62
+ [K in CamelCase<Param>]: (value: string) => (NeedsDefault<I, O> extends true ? HasRequiredKeys<DropKey<Bag, Param> & I> extends true ? (args: I & DropKey<Bag, Param> & AuthBag<SecurityModeOf<Full>> & OurRequestInit) => Promise<O> : (args?: I & DropKey<Bag, Param> & AuthBag<SecurityModeOf<Full>> & OurRequestInit) => Promise<O> : object) & VerbExtras<Full, DropKey<Bag, Param>>;
63
+ } : P extends `/${infer Leaf}` ? {
64
+ [K in CamelCase<RemoveColon<Leaf>>]: (NeedsDefault<I, O> extends true ? HasRequiredKeys<I & Bag> extends true ? (args: I & Bag & AuthBag<SecurityModeOf<Full>> & OurRequestInit) => Promise<O> : (args?: I & Bag & AuthBag<SecurityModeOf<Full>> & OurRequestInit) => Promise<O> : object) & VerbExtras<Full, Bag>;
65
+ } : never;
66
+ type AnyFn = (...a: any[]) => any;
67
+ type IsFn<T> = T extends AnyFn ? true : false;
68
+ type U2I<U> = (U extends any ? (k: U) => 0 : never) extends (k: infer I) => 0 ? I : never;
69
+ type UnionKeys<U> = U extends any ? keyof U : never;
70
+ type CollapseFnUnion<F> = (...a: Parameters<Extract<F, AnyFn>>) => U2I<F extends AnyFn ? ReturnType<F> : never>;
71
+ type ValuesForKey<U, K extends PropertyKey> = Exclude<U extends any ? (K extends keyof U ? U[K] : never) : never, never>;
72
+ type FnUnion<U> = Extract<U, AnyFn>;
73
+ type ObjUnion<U> = Exclude<U, AnyFn>;
74
+ type CollapseFnUnionOrNever<U> = [FnUnion<U>] extends [never] ? {} : CollapseFnUnion<FnUnion<U>>;
75
+ type MergeRec<U> = [U] extends [object] ? {
76
+ [K in UnionKeys<ObjUnion<U>>]: MergeRec<ValuesForKey<ObjUnion<U>, K>>;
77
+ } & CollapseFnUnionOrNever<U> : U;
78
+ type SimplifyDeep<T> = IsFn<T> extends true ? T : T extends object ? {
79
+ [K in keyof T]: SimplifyDeep<T[K]>;
80
+ } : T;
81
+ type SDKUnion = {
82
+ [R in keyof typeof routes]: PathToTree<R, (typeof routes)[R]['input'], (typeof routes)[R]['output'], (typeof routes)[R]>;
83
+ }[keyof typeof routes];
84
+ export type SDK = SimplifyDeep<MergeRec<SDKUnion>>;
85
+ export declare function buildSdk(client: XOXNOClient): SDK;
86
+ export {};