waitkit 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.
- package/dist/index-5GjaWT5y.d.cts +27 -0
- package/dist/index-5GjaWT5y.d.ts +27 -0
- package/dist/index.cjs +113 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +86 -0
- package/dist/index.js.map +1 -0
- package/dist/react.cjs +79 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.cts +13 -0
- package/dist/react.d.ts +13 -0
- package/dist/react.js +55 -0
- package/dist/react.js.map +1 -0
- package/package.json +50 -0
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
interface WaitKitConfig {
|
|
2
|
+
apiKey: string;
|
|
3
|
+
projectSlug: string;
|
|
4
|
+
baseUrl?: string;
|
|
5
|
+
}
|
|
6
|
+
interface JoinOptions {
|
|
7
|
+
email: string;
|
|
8
|
+
name?: string;
|
|
9
|
+
source?: string;
|
|
10
|
+
metadata?: Record<string, unknown>;
|
|
11
|
+
}
|
|
12
|
+
interface JoinResult {
|
|
13
|
+
message: string;
|
|
14
|
+
email: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
declare class WaitKit {
|
|
18
|
+
private client;
|
|
19
|
+
private apiKey;
|
|
20
|
+
private projectSlug;
|
|
21
|
+
constructor(config: WaitKitConfig);
|
|
22
|
+
private get headers();
|
|
23
|
+
join(options: JoinOptions): Promise<JoinResult>;
|
|
24
|
+
count(projectSlug?: string): Promise<number>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { type JoinOptions as J, WaitKit as W, type JoinResult as a };
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
interface WaitKitConfig {
|
|
2
|
+
apiKey: string;
|
|
3
|
+
projectSlug: string;
|
|
4
|
+
baseUrl?: string;
|
|
5
|
+
}
|
|
6
|
+
interface JoinOptions {
|
|
7
|
+
email: string;
|
|
8
|
+
name?: string;
|
|
9
|
+
source?: string;
|
|
10
|
+
metadata?: Record<string, unknown>;
|
|
11
|
+
}
|
|
12
|
+
interface JoinResult {
|
|
13
|
+
message: string;
|
|
14
|
+
email: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
declare class WaitKit {
|
|
18
|
+
private client;
|
|
19
|
+
private apiKey;
|
|
20
|
+
private projectSlug;
|
|
21
|
+
constructor(config: WaitKitConfig);
|
|
22
|
+
private get headers();
|
|
23
|
+
join(options: JoinOptions): Promise<JoinResult>;
|
|
24
|
+
count(projectSlug?: string): Promise<number>;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export { type JoinOptions as J, WaitKit as W, type JoinResult as a };
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var src_exports = {};
|
|
22
|
+
__export(src_exports, {
|
|
23
|
+
WaitKit: () => WaitKit
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(src_exports);
|
|
26
|
+
|
|
27
|
+
// src/errors.ts
|
|
28
|
+
var WaitKitError = class _WaitKitError extends Error {
|
|
29
|
+
constructor(message, statusCode, issues) {
|
|
30
|
+
super(message);
|
|
31
|
+
this.statusCode = statusCode;
|
|
32
|
+
this.issues = issues;
|
|
33
|
+
this.name = "WaitKitError";
|
|
34
|
+
}
|
|
35
|
+
statusCode;
|
|
36
|
+
issues;
|
|
37
|
+
static fromResponse(res) {
|
|
38
|
+
return new _WaitKitError(res.message, res.statusCode, res.issues);
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
// src/client.ts
|
|
43
|
+
var HttpClient = class {
|
|
44
|
+
baseUrl;
|
|
45
|
+
constructor(baseUrl) {
|
|
46
|
+
this.baseUrl = baseUrl.replace(/\/+$/, "");
|
|
47
|
+
}
|
|
48
|
+
async request(method, path, options = {}) {
|
|
49
|
+
const url = new URL(`${this.baseUrl}${path}`);
|
|
50
|
+
if (options.query) {
|
|
51
|
+
for (const [key, value] of Object.entries(options.query)) {
|
|
52
|
+
if (value !== void 0) {
|
|
53
|
+
url.searchParams.set(key, String(value));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
const res = await fetch(url.toString(), {
|
|
58
|
+
method,
|
|
59
|
+
headers: {
|
|
60
|
+
"Content-Type": "application/json",
|
|
61
|
+
...options.headers
|
|
62
|
+
},
|
|
63
|
+
body: options.body ? JSON.stringify(options.body) : void 0
|
|
64
|
+
});
|
|
65
|
+
const json = await res.json();
|
|
66
|
+
if (!res.ok || json.status === "error") {
|
|
67
|
+
const err = json;
|
|
68
|
+
throw WaitKitError.fromResponse(err);
|
|
69
|
+
}
|
|
70
|
+
return json.data;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
// src/index.ts
|
|
75
|
+
var DEFAULT_BASE_URL = "https://api.waitkit.dev";
|
|
76
|
+
var WaitKit = class {
|
|
77
|
+
client;
|
|
78
|
+
apiKey;
|
|
79
|
+
projectSlug;
|
|
80
|
+
constructor(config) {
|
|
81
|
+
this.apiKey = config.apiKey;
|
|
82
|
+
this.projectSlug = config.projectSlug;
|
|
83
|
+
this.client = new HttpClient(config.baseUrl ?? DEFAULT_BASE_URL);
|
|
84
|
+
}
|
|
85
|
+
get headers() {
|
|
86
|
+
return { Authorization: `Bearer ${this.apiKey}` };
|
|
87
|
+
}
|
|
88
|
+
async join(options) {
|
|
89
|
+
const data = await this.client.request(
|
|
90
|
+
"POST",
|
|
91
|
+
`/api/waitlist/${this.projectSlug}/join`,
|
|
92
|
+
{ headers: this.headers, body: options }
|
|
93
|
+
);
|
|
94
|
+
return {
|
|
95
|
+
message: "Thank you for joining the waitlist!",
|
|
96
|
+
email: data.email
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
async count(projectSlug) {
|
|
100
|
+
const slug = projectSlug ?? this.projectSlug;
|
|
101
|
+
const data = await this.client.request(
|
|
102
|
+
"GET",
|
|
103
|
+
`/api/waitlist/${slug}/count`,
|
|
104
|
+
{ headers: this.headers }
|
|
105
|
+
);
|
|
106
|
+
return data.count;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
110
|
+
0 && (module.exports = {
|
|
111
|
+
WaitKit
|
|
112
|
+
});
|
|
113
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/errors.ts","../src/client.ts"],"sourcesContent":["import { HttpClient } from \"./client\";\nimport type { JoinOptions, JoinResult, WaitKitConfig } from \"./types\";\n\nconst DEFAULT_BASE_URL = \"https://api.waitkit.dev\";\n\nexport class WaitKit {\n private client: HttpClient;\n private apiKey: string;\n private projectSlug: string;\n\n constructor(config: WaitKitConfig) {\n this.apiKey = config.apiKey;\n this.projectSlug = config.projectSlug;\n this.client = new HttpClient(config.baseUrl ?? DEFAULT_BASE_URL);\n }\n\n private get headers() {\n return { Authorization: `Bearer ${this.apiKey}` };\n }\n\n async join(options: JoinOptions): Promise<JoinResult> {\n const data = await this.client.request<{ email: string }>(\n \"POST\",\n `/api/waitlist/${this.projectSlug}/join`,\n { headers: this.headers, body: options },\n );\n\n return {\n message: \"Thank you for joining the waitlist!\",\n email: data.email,\n };\n }\n\n async count(projectSlug?: string): Promise<number> {\n const slug = projectSlug ?? this.projectSlug;\n const data = await this.client.request<{ count: number }>(\n \"GET\",\n `/api/waitlist/${slug}/count`,\n { headers: this.headers },\n );\n\n return data.count;\n }\n}\n","import type { ErrorResponse } from \"./types\";\n\nexport class WaitKitError extends Error {\n constructor(\n message: string,\n public statusCode?: number,\n public issues?: Array<{ path: string; message: string }>,\n ) {\n super(message);\n this.name = \"WaitKitError\";\n }\n\n static fromResponse(res: ErrorResponse): WaitKitError {\n return new WaitKitError(res.message, res.statusCode, res.issues);\n }\n}\n","import type { ApiResponse, ErrorResponse, SuccessResponse } from \"./types\";\nimport { WaitKitError } from \"./errors\";\n\nexport class HttpClient {\n private baseUrl: string;\n\n constructor(baseUrl: string) {\n this.baseUrl = baseUrl.replace(/\\/+$/, \"\");\n }\n\n async request<T>(\n method: string,\n path: string,\n options: {\n headers?: Record<string, string>;\n body?: unknown;\n query?: Record<string, string | number | undefined>;\n } = {},\n ): Promise<T> {\n const url = new URL(`${this.baseUrl}${path}`);\n\n if (options.query) {\n for (const [key, value] of Object.entries(options.query)) {\n if (value !== undefined) {\n url.searchParams.set(key, String(value));\n }\n }\n }\n\n const res = await fetch(url.toString(), {\n method,\n headers: {\n \"Content-Type\": \"application/json\",\n ...options.headers,\n },\n body: options.body ? JSON.stringify(options.body) : undefined,\n });\n\n const json: ApiResponse<T> = await res.json();\n\n if (!res.ok || json.status === \"error\") {\n const err = json as ErrorResponse;\n throw WaitKitError.fromResponse(err);\n }\n\n return (json as SuccessResponse<T>).data;\n }\n}\n"],"mappings":";;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EAER,YAAY,QAAuB;AACjC,SAAK,SAAS,OAAO;AACrB,SAAK,cAAc,OAAO;AAC1B,SAAK,SAAS,IAAI,WAAW,OAAO,WAAW,gBAAgB;AAAA,EACjE;AAAA,EAEA,IAAY,UAAU;AACpB,WAAO,EAAE,eAAe,UAAU,KAAK,MAAM,GAAG;AAAA,EAClD;AAAA,EAEA,MAAM,KAAK,SAA2C;AACpD,UAAM,OAAO,MAAM,KAAK,OAAO;AAAA,MAC7B;AAAA,MACA,iBAAiB,KAAK,WAAW;AAAA,MACjC,EAAE,SAAS,KAAK,SAAS,MAAM,QAAQ;AAAA,IACzC;AAEA,WAAO;AAAA,MACL,SAAS;AAAA,MACT,OAAO,KAAK;AAAA,IACd;AAAA,EACF;AAAA,EAEA,MAAM,MAAM,aAAuC;AACjD,UAAM,OAAO,eAAe,KAAK;AACjC,UAAM,OAAO,MAAM,KAAK,OAAO;AAAA,MAC7B;AAAA,MACA,iBAAiB,IAAI;AAAA,MACrB,EAAE,SAAS,KAAK,QAAQ;AAAA,IAC1B;AAEA,WAAO,KAAK;AAAA,EACd;AACF;","names":[]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { W as WaitKit } from './index-5GjaWT5y.cjs';
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { W as WaitKit } from './index-5GjaWT5y.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// src/errors.ts
|
|
2
|
+
var WaitKitError = class _WaitKitError extends Error {
|
|
3
|
+
constructor(message, statusCode, issues) {
|
|
4
|
+
super(message);
|
|
5
|
+
this.statusCode = statusCode;
|
|
6
|
+
this.issues = issues;
|
|
7
|
+
this.name = "WaitKitError";
|
|
8
|
+
}
|
|
9
|
+
statusCode;
|
|
10
|
+
issues;
|
|
11
|
+
static fromResponse(res) {
|
|
12
|
+
return new _WaitKitError(res.message, res.statusCode, res.issues);
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
// src/client.ts
|
|
17
|
+
var HttpClient = class {
|
|
18
|
+
baseUrl;
|
|
19
|
+
constructor(baseUrl) {
|
|
20
|
+
this.baseUrl = baseUrl.replace(/\/+$/, "");
|
|
21
|
+
}
|
|
22
|
+
async request(method, path, options = {}) {
|
|
23
|
+
const url = new URL(`${this.baseUrl}${path}`);
|
|
24
|
+
if (options.query) {
|
|
25
|
+
for (const [key, value] of Object.entries(options.query)) {
|
|
26
|
+
if (value !== void 0) {
|
|
27
|
+
url.searchParams.set(key, String(value));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
const res = await fetch(url.toString(), {
|
|
32
|
+
method,
|
|
33
|
+
headers: {
|
|
34
|
+
"Content-Type": "application/json",
|
|
35
|
+
...options.headers
|
|
36
|
+
},
|
|
37
|
+
body: options.body ? JSON.stringify(options.body) : void 0
|
|
38
|
+
});
|
|
39
|
+
const json = await res.json();
|
|
40
|
+
if (!res.ok || json.status === "error") {
|
|
41
|
+
const err = json;
|
|
42
|
+
throw WaitKitError.fromResponse(err);
|
|
43
|
+
}
|
|
44
|
+
return json.data;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// src/index.ts
|
|
49
|
+
var DEFAULT_BASE_URL = "https://api.waitkit.dev";
|
|
50
|
+
var WaitKit = class {
|
|
51
|
+
client;
|
|
52
|
+
apiKey;
|
|
53
|
+
projectSlug;
|
|
54
|
+
constructor(config) {
|
|
55
|
+
this.apiKey = config.apiKey;
|
|
56
|
+
this.projectSlug = config.projectSlug;
|
|
57
|
+
this.client = new HttpClient(config.baseUrl ?? DEFAULT_BASE_URL);
|
|
58
|
+
}
|
|
59
|
+
get headers() {
|
|
60
|
+
return { Authorization: `Bearer ${this.apiKey}` };
|
|
61
|
+
}
|
|
62
|
+
async join(options) {
|
|
63
|
+
const data = await this.client.request(
|
|
64
|
+
"POST",
|
|
65
|
+
`/api/waitlist/${this.projectSlug}/join`,
|
|
66
|
+
{ headers: this.headers, body: options }
|
|
67
|
+
);
|
|
68
|
+
return {
|
|
69
|
+
message: "Thank you for joining the waitlist!",
|
|
70
|
+
email: data.email
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
async count(projectSlug) {
|
|
74
|
+
const slug = projectSlug ?? this.projectSlug;
|
|
75
|
+
const data = await this.client.request(
|
|
76
|
+
"GET",
|
|
77
|
+
`/api/waitlist/${slug}/count`,
|
|
78
|
+
{ headers: this.headers }
|
|
79
|
+
);
|
|
80
|
+
return data.count;
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
export {
|
|
84
|
+
WaitKit
|
|
85
|
+
};
|
|
86
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/errors.ts","../src/client.ts","../src/index.ts"],"sourcesContent":["import type { ErrorResponse } from \"./types\";\n\nexport class WaitKitError extends Error {\n constructor(\n message: string,\n public statusCode?: number,\n public issues?: Array<{ path: string; message: string }>,\n ) {\n super(message);\n this.name = \"WaitKitError\";\n }\n\n static fromResponse(res: ErrorResponse): WaitKitError {\n return new WaitKitError(res.message, res.statusCode, res.issues);\n }\n}\n","import type { ApiResponse, ErrorResponse, SuccessResponse } from \"./types\";\nimport { WaitKitError } from \"./errors\";\n\nexport class HttpClient {\n private baseUrl: string;\n\n constructor(baseUrl: string) {\n this.baseUrl = baseUrl.replace(/\\/+$/, \"\");\n }\n\n async request<T>(\n method: string,\n path: string,\n options: {\n headers?: Record<string, string>;\n body?: unknown;\n query?: Record<string, string | number | undefined>;\n } = {},\n ): Promise<T> {\n const url = new URL(`${this.baseUrl}${path}`);\n\n if (options.query) {\n for (const [key, value] of Object.entries(options.query)) {\n if (value !== undefined) {\n url.searchParams.set(key, String(value));\n }\n }\n }\n\n const res = await fetch(url.toString(), {\n method,\n headers: {\n \"Content-Type\": \"application/json\",\n ...options.headers,\n },\n body: options.body ? JSON.stringify(options.body) : undefined,\n });\n\n const json: ApiResponse<T> = await res.json();\n\n if (!res.ok || json.status === \"error\") {\n const err = json as ErrorResponse;\n throw WaitKitError.fromResponse(err);\n }\n\n return (json as SuccessResponse<T>).data;\n }\n}\n","import { HttpClient } from \"./client\";\nimport type { JoinOptions, JoinResult, WaitKitConfig } from \"./types\";\n\nconst DEFAULT_BASE_URL = \"https://api.waitkit.dev\";\n\nexport class WaitKit {\n private client: HttpClient;\n private apiKey: string;\n private projectSlug: string;\n\n constructor(config: WaitKitConfig) {\n this.apiKey = config.apiKey;\n this.projectSlug = config.projectSlug;\n this.client = new HttpClient(config.baseUrl ?? DEFAULT_BASE_URL);\n }\n\n private get headers() {\n return { Authorization: `Bearer ${this.apiKey}` };\n }\n\n async join(options: JoinOptions): Promise<JoinResult> {\n const data = await this.client.request<{ email: string }>(\n \"POST\",\n `/api/waitlist/${this.projectSlug}/join`,\n { headers: this.headers, body: options },\n );\n\n return {\n message: \"Thank you for joining the waitlist!\",\n email: data.email,\n };\n }\n\n async count(projectSlug?: string): Promise<number> {\n const slug = projectSlug ?? this.projectSlug;\n const data = await this.client.request<{ count: number }>(\n \"GET\",\n `/api/waitlist/${slug}/count`,\n { headers: this.headers },\n );\n\n return data.count;\n }\n}\n"],"mappings":";AAEO,IAAM,eAAN,MAAM,sBAAqB,MAAM;AAAA,EACtC,YACE,SACO,YACA,QACP;AACA,UAAM,OAAO;AAHN;AACA;AAGP,SAAK,OAAO;AAAA,EACd;AAAA,EALS;AAAA,EACA;AAAA,EAMT,OAAO,aAAa,KAAkC;AACpD,WAAO,IAAI,cAAa,IAAI,SAAS,IAAI,YAAY,IAAI,MAAM;AAAA,EACjE;AACF;;;ACZO,IAAM,aAAN,MAAiB;AAAA,EACd;AAAA,EAER,YAAY,SAAiB;AAC3B,SAAK,UAAU,QAAQ,QAAQ,QAAQ,EAAE;AAAA,EAC3C;AAAA,EAEA,MAAM,QACJ,QACA,MACA,UAII,CAAC,GACO;AACZ,UAA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AACjD,UAAM,OAAO,eAAe,KAAK;AACjC,UAAM,OAAO,MAAM,KAAK,OAAO;AAAA,MAC7B;AAAA,MACA,iBAAiB,IAAI;AAAA,MACrB,EAAE,SAAS,KAAK,QAAQ;AAAA,IAC1B;AAEA,WAAO,KAAK;AAAA,EACd;AACF;","names":[]}
|
package/dist/react.cjs
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
"use client";
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
+
|
|
21
|
+
// src/react.ts
|
|
22
|
+
var react_exports = {};
|
|
23
|
+
__export(react_exports, {
|
|
24
|
+
useWaitlist: () => useWaitlist
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(react_exports);
|
|
27
|
+
var import_react = require("react");
|
|
28
|
+
function useWaitlist(wk) {
|
|
29
|
+
const [count, setCount] = (0, import_react.useState)(null);
|
|
30
|
+
const [isLoading, setIsLoading] = (0, import_react.useState)(true);
|
|
31
|
+
const [isJoining, setIsJoining] = (0, import_react.useState)(false);
|
|
32
|
+
const [error, setError] = (0, import_react.useState)(null);
|
|
33
|
+
const fetchCount = (0, import_react.useCallback)(async () => {
|
|
34
|
+
try {
|
|
35
|
+
setIsLoading(true);
|
|
36
|
+
setError(null);
|
|
37
|
+
const result = await wk.count();
|
|
38
|
+
setCount(result);
|
|
39
|
+
} catch (err) {
|
|
40
|
+
setError(err instanceof Error ? err : new Error("Failed to fetch count"));
|
|
41
|
+
} finally {
|
|
42
|
+
setIsLoading(false);
|
|
43
|
+
}
|
|
44
|
+
}, [wk]);
|
|
45
|
+
(0, import_react.useEffect)(() => {
|
|
46
|
+
fetchCount();
|
|
47
|
+
}, [fetchCount]);
|
|
48
|
+
const join = (0, import_react.useCallback)(
|
|
49
|
+
async (data) => {
|
|
50
|
+
setIsJoining(true);
|
|
51
|
+
setError(null);
|
|
52
|
+
try {
|
|
53
|
+
const result = await wk.join(data);
|
|
54
|
+
await fetchCount();
|
|
55
|
+
return result;
|
|
56
|
+
} catch (err) {
|
|
57
|
+
const error2 = err instanceof Error ? err : new Error("Failed to join waitlist");
|
|
58
|
+
setError(error2);
|
|
59
|
+
throw error2;
|
|
60
|
+
} finally {
|
|
61
|
+
setIsJoining(false);
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
[wk, fetchCount]
|
|
65
|
+
);
|
|
66
|
+
return {
|
|
67
|
+
join,
|
|
68
|
+
count,
|
|
69
|
+
isJoining,
|
|
70
|
+
isLoading,
|
|
71
|
+
error,
|
|
72
|
+
refetchCount: fetchCount
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
76
|
+
0 && (module.exports = {
|
|
77
|
+
useWaitlist
|
|
78
|
+
});
|
|
79
|
+
//# sourceMappingURL=react.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/react.ts"],"sourcesContent":["\"use client\";\n\nimport { useState, useEffect, useCallback } from \"react\";\nimport { WaitKit } from \"./index\";\nimport type { JoinOptions, JoinResult } from \"./types\";\n\nexport interface UseWaitlistReturn {\n join: (data: JoinOptions) => Promise<JoinResult>;\n count: number | null;\n isJoining: boolean;\n isLoading: boolean;\n error: Error | null;\n refetchCount: () => Promise<void>;\n}\n\nexport function useWaitlist(wk: WaitKit): UseWaitlistReturn {\n const [count, setCount] = useState<number | null>(null);\n const [isLoading, setIsLoading] = useState(true);\n const [isJoining, setIsJoining] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n\n const fetchCount = useCallback(async () => {\n try {\n setIsLoading(true);\n setError(null);\n const result = await wk.count();\n setCount(result);\n } catch (err) {\n setError(err instanceof Error ? err : new Error(\"Failed to fetch count\"));\n } finally {\n setIsLoading(false);\n }\n }, [wk]);\n\n useEffect(() => {\n fetchCount();\n }, [fetchCount]);\n\n const join = useCallback(\n async (data: JoinOptions): Promise<JoinResult> => {\n setIsJoining(true);\n setError(null);\n try {\n const result = await wk.join(data);\n await fetchCount();\n return result;\n } catch (err) {\n const error =\n err instanceof Error ? err : new Error(\"Failed to join waitlist\");\n setError(error);\n throw error;\n } finally {\n setIsJoining(false);\n }\n },\n [wk, fetchCount],\n );\n\n return {\n join,\n count,\n isJoining,\n isLoading,\n error,\n refetchCount: fetchCount,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAEA,mBAAiD;AAa1C,SAAS,YAAY,IAAgC;AAC1D,QAAM,CAAC,OAAO,QAAQ,QAAI,uBAAwB,IAAI;AACtD,QAAM,CAAC,WAAW,YAAY,QAAI,uBAAS,IAAI;AAC/C,QAAM,CAAC,WAAW,YAAY,QAAI,uBAAS,KAAK;AAChD,QAAM,CAAC,OAAO,QAAQ,QAAI,uBAAuB,IAAI;AAErD,QAAM,iBAAa,0BAAY,YAAY;AACzC,QAAI;AACF,mBAAa,IAAI;AACjB,eAAS,IAAI;AACb,YAAM,SAAS,MAAM,GAAG,MAAM;AAC9B,eAAS,MAAM;AAAA,IACjB,SAAS,KAAK;AACZ,eAAS,eAAe,QAAQ,MAAM,IAAI,MAAM,uBAAuB,CAAC;AAAA,IAC1E,UAAE;AACA,mBAAa,KAAK;AAAA,IACpB;AAAA,EACF,GAAG,CAAC,EAAE,CAAC;AAEP,8BAAU,MAAM;AACd,eAAW;AAAA,EACb,GAAG,CAAC,UAAU,CAAC;AAEf,QAAM,WAAO;AAAA,IACX,OAAO,SAA2C;AAChD,mBAAa,IAAI;AACjB,eAAS,IAAI;AACb,UAAI;AACF,cAAM,SAAS,MAAM,GAAG,KAAK,IAAI;AACjC,cAAM,WAAW;AACjB,eAAO;AAAA,MACT,SAAS,KAAK;AACZ,cAAMA,SACJ,eAAe,QAAQ,MAAM,IAAI,MAAM,yBAAyB;AAClE,iBAASA,MAAK;AACd,cAAMA;AAAA,MACR,UAAE;AACA,qBAAa,KAAK;AAAA,MACpB;AAAA,IACF;AAAA,IACA,CAAC,IAAI,UAAU;AAAA,EACjB;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,cAAc;AAAA,EAChB;AACF;","names":["error"]}
|
package/dist/react.d.cts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { J as JoinOptions, a as JoinResult, W as WaitKit } from './index-5GjaWT5y.cjs';
|
|
2
|
+
|
|
3
|
+
interface UseWaitlistReturn {
|
|
4
|
+
join: (data: JoinOptions) => Promise<JoinResult>;
|
|
5
|
+
count: number | null;
|
|
6
|
+
isJoining: boolean;
|
|
7
|
+
isLoading: boolean;
|
|
8
|
+
error: Error | null;
|
|
9
|
+
refetchCount: () => Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
declare function useWaitlist(wk: WaitKit): UseWaitlistReturn;
|
|
12
|
+
|
|
13
|
+
export { type UseWaitlistReturn, useWaitlist };
|
package/dist/react.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { J as JoinOptions, a as JoinResult, W as WaitKit } from './index-5GjaWT5y.js';
|
|
2
|
+
|
|
3
|
+
interface UseWaitlistReturn {
|
|
4
|
+
join: (data: JoinOptions) => Promise<JoinResult>;
|
|
5
|
+
count: number | null;
|
|
6
|
+
isJoining: boolean;
|
|
7
|
+
isLoading: boolean;
|
|
8
|
+
error: Error | null;
|
|
9
|
+
refetchCount: () => Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
declare function useWaitlist(wk: WaitKit): UseWaitlistReturn;
|
|
12
|
+
|
|
13
|
+
export { type UseWaitlistReturn, useWaitlist };
|
package/dist/react.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/react.ts
|
|
4
|
+
import { useState, useEffect, useCallback } from "react";
|
|
5
|
+
function useWaitlist(wk) {
|
|
6
|
+
const [count, setCount] = useState(null);
|
|
7
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
8
|
+
const [isJoining, setIsJoining] = useState(false);
|
|
9
|
+
const [error, setError] = useState(null);
|
|
10
|
+
const fetchCount = useCallback(async () => {
|
|
11
|
+
try {
|
|
12
|
+
setIsLoading(true);
|
|
13
|
+
setError(null);
|
|
14
|
+
const result = await wk.count();
|
|
15
|
+
setCount(result);
|
|
16
|
+
} catch (err) {
|
|
17
|
+
setError(err instanceof Error ? err : new Error("Failed to fetch count"));
|
|
18
|
+
} finally {
|
|
19
|
+
setIsLoading(false);
|
|
20
|
+
}
|
|
21
|
+
}, [wk]);
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
fetchCount();
|
|
24
|
+
}, [fetchCount]);
|
|
25
|
+
const join = useCallback(
|
|
26
|
+
async (data) => {
|
|
27
|
+
setIsJoining(true);
|
|
28
|
+
setError(null);
|
|
29
|
+
try {
|
|
30
|
+
const result = await wk.join(data);
|
|
31
|
+
await fetchCount();
|
|
32
|
+
return result;
|
|
33
|
+
} catch (err) {
|
|
34
|
+
const error2 = err instanceof Error ? err : new Error("Failed to join waitlist");
|
|
35
|
+
setError(error2);
|
|
36
|
+
throw error2;
|
|
37
|
+
} finally {
|
|
38
|
+
setIsJoining(false);
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
[wk, fetchCount]
|
|
42
|
+
);
|
|
43
|
+
return {
|
|
44
|
+
join,
|
|
45
|
+
count,
|
|
46
|
+
isJoining,
|
|
47
|
+
isLoading,
|
|
48
|
+
error,
|
|
49
|
+
refetchCount: fetchCount
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export {
|
|
53
|
+
useWaitlist
|
|
54
|
+
};
|
|
55
|
+
//# sourceMappingURL=react.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/react.ts"],"sourcesContent":["\"use client\";\n\nimport { useState, useEffect, useCallback } from \"react\";\nimport { WaitKit } from \"./index\";\nimport type { JoinOptions, JoinResult } from \"./types\";\n\nexport interface UseWaitlistReturn {\n join: (data: JoinOptions) => Promise<JoinResult>;\n count: number | null;\n isJoining: boolean;\n isLoading: boolean;\n error: Error | null;\n refetchCount: () => Promise<void>;\n}\n\nexport function useWaitlist(wk: WaitKit): UseWaitlistReturn {\n const [count, setCount] = useState<number | null>(null);\n const [isLoading, setIsLoading] = useState(true);\n const [isJoining, setIsJoining] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n\n const fetchCount = useCallback(async () => {\n try {\n setIsLoading(true);\n setError(null);\n const result = await wk.count();\n setCount(result);\n } catch (err) {\n setError(err instanceof Error ? err : new Error(\"Failed to fetch count\"));\n } finally {\n setIsLoading(false);\n }\n }, [wk]);\n\n useEffect(() => {\n fetchCount();\n }, [fetchCount]);\n\n const join = useCallback(\n async (data: JoinOptions): Promise<JoinResult> => {\n setIsJoining(true);\n setError(null);\n try {\n const result = await wk.join(data);\n await fetchCount();\n return result;\n } catch (err) {\n const error =\n err instanceof Error ? err : new Error(\"Failed to join waitlist\");\n setError(error);\n throw error;\n } finally {\n setIsJoining(false);\n }\n },\n [wk, fetchCount],\n );\n\n return {\n join,\n count,\n isJoining,\n isLoading,\n error,\n refetchCount: fetchCount,\n };\n}\n"],"mappings":";;;AAEA,SAAS,UAAU,WAAW,mBAAmB;AAa1C,SAAS,YAAY,IAAgC;AAC1D,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAwB,IAAI;AACtD,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,IAAI;AAC/C,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,KAAK;AAChD,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAuB,IAAI;AAErD,QAAM,aAAa,YAAY,YAAY;AACzC,QAAI;AACF,mBAAa,IAAI;AACjB,eAAS,IAAI;AACb,YAAM,SAAS,MAAM,GAAG,MAAM;AAC9B,eAAS,MAAM;AAAA,IACjB,SAAS,KAAK;AACZ,eAAS,eAAe,QAAQ,MAAM,IAAI,MAAM,uBAAuB,CAAC;AAAA,IAC1E,UAAE;AACA,mBAAa,KAAK;AAAA,IACpB;AAAA,EACF,GAAG,CAAC,EAAE,CAAC;AAEP,YAAU,MAAM;AACd,eAAW;AAAA,EACb,GAAG,CAAC,UAAU,CAAC;AAEf,QAAM,OAAO;AAAA,IACX,OAAO,SAA2C;AAChD,mBAAa,IAAI;AACjB,eAAS,IAAI;AACb,UAAI;AACF,cAAM,SAAS,MAAM,GAAG,KAAK,IAAI;AACjC,cAAM,WAAW;AACjB,eAAO;AAAA,MACT,SAAS,KAAK;AACZ,cAAMA,SACJ,eAAe,QAAQ,MAAM,IAAI,MAAM,yBAAyB;AAClE,iBAASA,MAAK;AACd,cAAMA;AAAA,MACR,UAAE;AACA,qBAAa,KAAK;AAAA,MACpB;AAAA,IACF;AAAA,IACA,CAAC,IAAI,UAAU;AAAA,EACjB;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,cAAc;AAAA,EAChB;AACF;","names":["error"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "waitkit",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "WaitKit SDK — waitlist infrastructure for your app",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"waitkit",
|
|
7
|
+
"waitlist"
|
|
8
|
+
],
|
|
9
|
+
"license": "ISC",
|
|
10
|
+
"author": "ubeyidah",
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"type": "module",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"import": "./dist/index.js",
|
|
17
|
+
"require": "./dist/index.cjs"
|
|
18
|
+
},
|
|
19
|
+
"./react": {
|
|
20
|
+
"types": "./dist/react.d.ts",
|
|
21
|
+
"import": "./dist/react.js",
|
|
22
|
+
"require": "./dist/react.cjs"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"main": "./dist/index.cjs",
|
|
26
|
+
"module": "./dist/index.js",
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"files": [
|
|
29
|
+
"dist"
|
|
30
|
+
],
|
|
31
|
+
"scripts": {
|
|
32
|
+
"build": "tsup",
|
|
33
|
+
"dev": "tsup --watch",
|
|
34
|
+
"type-check": "tsc --noEmit"
|
|
35
|
+
},
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"react": "^18.0.0 || ^19.0.0"
|
|
38
|
+
},
|
|
39
|
+
"peerDependenciesMeta": {
|
|
40
|
+
"react": {
|
|
41
|
+
"optional": true
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"devDependencies": {
|
|
45
|
+
"@types/react": "^19.0.0",
|
|
46
|
+
"tsup": "^8.4.0",
|
|
47
|
+
"typescript": "5.9.2",
|
|
48
|
+
"react": "^19.2.4"
|
|
49
|
+
}
|
|
50
|
+
}
|