waitkit 0.2.0 → 0.3.2
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 +25 -7
- package/dist/{index-B-G7fuyH.d.cts → index-3alZWsam.d.cts} +5 -2
- package/dist/{index-B-G7fuyH.d.ts → index-3alZWsam.d.ts} +5 -2
- package/dist/index.cjs +12 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +11 -3
- package/dist/index.js.map +1 -1
- package/dist/react.d.cts +1 -1
- package/dist/react.d.ts +1 -1
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -18,9 +18,12 @@ const wk = new WaitKit({
|
|
|
18
18
|
projectSlug: "my-project",
|
|
19
19
|
});
|
|
20
20
|
|
|
21
|
-
// Add a subscriber
|
|
21
|
+
// Add a subscriber (source defaults to "landing-page")
|
|
22
22
|
await wk.subscribers.create({ email: "user@example.com" });
|
|
23
23
|
|
|
24
|
+
// Override source per-signup
|
|
25
|
+
await wk.subscribers.create({ email: "user@example.com", source: "referral" });
|
|
26
|
+
|
|
24
27
|
// Get subscriber count
|
|
25
28
|
const count = await wk.subscribers.count();
|
|
26
29
|
```
|
|
@@ -50,14 +53,29 @@ function WaitlistForm() {
|
|
|
50
53
|
|
|
51
54
|
## API
|
|
52
55
|
|
|
56
|
+
### `WaitKitConfig`
|
|
57
|
+
|
|
58
|
+
| Param | Type | Default | Description |
|
|
59
|
+
| ------------- | -------- | ------------------------- | ------------------------------ |
|
|
60
|
+
| `apiKey` | `string` | — | API key |
|
|
61
|
+
| `projectSlug` | `string` | — | Project slug |
|
|
62
|
+
| `baseUrl` | `string` | `https://api.waitkit.dev` | API base URL |
|
|
63
|
+
| `source` | `string` | `landing-page` | Default source for all signups |
|
|
64
|
+
|
|
53
65
|
### `wk.subscribers.create(options)`
|
|
54
66
|
|
|
55
|
-
| Param | Type | Required |
|
|
56
|
-
| ---------- | ------------------------- | -------- |
|
|
57
|
-
| `email` | `string` | yes |
|
|
58
|
-
| `name` | `string` | no |
|
|
59
|
-
| `source` | `string` | no |
|
|
60
|
-
| `metadata` | `Record<string, unknown>` | no |
|
|
67
|
+
| Param | Type | Required | Description |
|
|
68
|
+
| ---------- | ------------------------- | -------- | -------------------------------------------- |
|
|
69
|
+
| `email` | `string` | yes | Subscriber email |
|
|
70
|
+
| `name` | `string` | no | Subscriber name |
|
|
71
|
+
| `source` | `string` | no | Overrides the default source for this signup |
|
|
72
|
+
| `metadata` | `Record<string, unknown>` | no | Arbitrary metadata |
|
|
73
|
+
|
|
74
|
+
The `source` value is resolved with this precedence:
|
|
75
|
+
|
|
76
|
+
1. `create({ source })` — per-call override
|
|
77
|
+
2. `new WaitKit({ source })` — instance default
|
|
78
|
+
3. `"landing-page"` — built-in fallback
|
|
61
79
|
|
|
62
80
|
### `wk.subscribers.count(projectSlug?)`
|
|
63
81
|
|
|
@@ -12,6 +12,7 @@ interface WaitKitConfig {
|
|
|
12
12
|
apiKey: string;
|
|
13
13
|
projectSlug: string;
|
|
14
14
|
baseUrl?: string;
|
|
15
|
+
source?: string;
|
|
15
16
|
}
|
|
16
17
|
interface JoinOptions {
|
|
17
18
|
email: string;
|
|
@@ -28,12 +29,14 @@ declare class SubscribersResource {
|
|
|
28
29
|
private client;
|
|
29
30
|
private apiKey;
|
|
30
31
|
private projectSlug;
|
|
31
|
-
|
|
32
|
+
private defaultSource;
|
|
33
|
+
constructor(client: HttpClient, apiKey: string, projectSlug: string, defaultSource?: string);
|
|
32
34
|
private get headers();
|
|
33
35
|
create(options: JoinOptions): Promise<JoinResult>;
|
|
34
36
|
count(projectSlug?: string): Promise<number>;
|
|
35
37
|
}
|
|
36
38
|
|
|
39
|
+
declare const DEFAULT_BASE_URL = "https://api.waitkit.dev";
|
|
37
40
|
declare class WaitKit {
|
|
38
41
|
subscribers: SubscribersResource;
|
|
39
42
|
private client;
|
|
@@ -42,4 +45,4 @@ declare class WaitKit {
|
|
|
42
45
|
constructor(config: WaitKitConfig);
|
|
43
46
|
}
|
|
44
47
|
|
|
45
|
-
export { type JoinOptions as J, WaitKit as W, type JoinResult as a };
|
|
48
|
+
export { DEFAULT_BASE_URL as D, type JoinOptions as J, WaitKit as W, type JoinResult as a };
|
|
@@ -12,6 +12,7 @@ interface WaitKitConfig {
|
|
|
12
12
|
apiKey: string;
|
|
13
13
|
projectSlug: string;
|
|
14
14
|
baseUrl?: string;
|
|
15
|
+
source?: string;
|
|
15
16
|
}
|
|
16
17
|
interface JoinOptions {
|
|
17
18
|
email: string;
|
|
@@ -28,12 +29,14 @@ declare class SubscribersResource {
|
|
|
28
29
|
private client;
|
|
29
30
|
private apiKey;
|
|
30
31
|
private projectSlug;
|
|
31
|
-
|
|
32
|
+
private defaultSource;
|
|
33
|
+
constructor(client: HttpClient, apiKey: string, projectSlug: string, defaultSource?: string);
|
|
32
34
|
private get headers();
|
|
33
35
|
create(options: JoinOptions): Promise<JoinResult>;
|
|
34
36
|
count(projectSlug?: string): Promise<number>;
|
|
35
37
|
}
|
|
36
38
|
|
|
39
|
+
declare const DEFAULT_BASE_URL = "https://api.waitkit.dev";
|
|
37
40
|
declare class WaitKit {
|
|
38
41
|
subscribers: SubscribersResource;
|
|
39
42
|
private client;
|
|
@@ -42,4 +45,4 @@ declare class WaitKit {
|
|
|
42
45
|
constructor(config: WaitKitConfig);
|
|
43
46
|
}
|
|
44
47
|
|
|
45
|
-
export { type JoinOptions as J, WaitKit as W, type JoinResult as a };
|
|
48
|
+
export { DEFAULT_BASE_URL as D, type JoinOptions as J, WaitKit as W, type JoinResult as a };
|
package/dist/index.cjs
CHANGED
|
@@ -20,6 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var src_exports = {};
|
|
22
22
|
__export(src_exports, {
|
|
23
|
+
DEFAULT_BASE_URL: () => DEFAULT_BASE_URL,
|
|
23
24
|
WaitKit: () => WaitKit
|
|
24
25
|
});
|
|
25
26
|
module.exports = __toCommonJS(src_exports);
|
|
@@ -72,14 +73,17 @@ var HttpClient = class {
|
|
|
72
73
|
};
|
|
73
74
|
|
|
74
75
|
// src/resources/subscribers.ts
|
|
76
|
+
var DEFAULT_SOURCE = "landing-page";
|
|
75
77
|
var SubscribersResource = class {
|
|
76
78
|
client;
|
|
77
79
|
apiKey;
|
|
78
80
|
projectSlug;
|
|
79
|
-
|
|
81
|
+
defaultSource;
|
|
82
|
+
constructor(client, apiKey, projectSlug, defaultSource) {
|
|
80
83
|
this.client = client;
|
|
81
84
|
this.apiKey = apiKey;
|
|
82
85
|
this.projectSlug = projectSlug;
|
|
86
|
+
this.defaultSource = defaultSource ?? DEFAULT_SOURCE;
|
|
83
87
|
}
|
|
84
88
|
get headers() {
|
|
85
89
|
return { Authorization: `Bearer ${this.apiKey}` };
|
|
@@ -88,7 +92,10 @@ var SubscribersResource = class {
|
|
|
88
92
|
const data = await this.client.request(
|
|
89
93
|
"POST",
|
|
90
94
|
`/api/waitlist/${this.projectSlug}/join`,
|
|
91
|
-
{
|
|
95
|
+
{
|
|
96
|
+
headers: this.headers,
|
|
97
|
+
body: { ...options, source: options.source ?? this.defaultSource }
|
|
98
|
+
}
|
|
92
99
|
);
|
|
93
100
|
return {
|
|
94
101
|
message: "Thank you for joining the waitlist!",
|
|
@@ -120,12 +127,14 @@ var WaitKit = class {
|
|
|
120
127
|
this.subscribers = new SubscribersResource(
|
|
121
128
|
this.client,
|
|
122
129
|
this.apiKey,
|
|
123
|
-
this.projectSlug
|
|
130
|
+
this.projectSlug,
|
|
131
|
+
config.source
|
|
124
132
|
);
|
|
125
133
|
}
|
|
126
134
|
};
|
|
127
135
|
// Annotate the CommonJS export names for ESM import in node:
|
|
128
136
|
0 && (module.exports = {
|
|
137
|
+
DEFAULT_BASE_URL,
|
|
129
138
|
WaitKit
|
|
130
139
|
});
|
|
131
140
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/errors.ts","../src/client.ts","../src/resources/subscribers.ts"],"sourcesContent":["import { HttpClient } from \"./client\";\nimport { SubscribersResource } from \"./resources/subscribers\";\nimport type { WaitKitConfig } from \"./types\";\n\
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/errors.ts","../src/client.ts","../src/resources/subscribers.ts"],"sourcesContent":["import { HttpClient } from \"./client\";\nimport { SubscribersResource } from \"./resources/subscribers\";\nimport type { WaitKitConfig } from \"./types\";\n\nexport const DEFAULT_BASE_URL = \"https://api.waitkit.dev\";\n\nexport class WaitKit {\n subscribers: SubscribersResource;\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 this.subscribers = new SubscribersResource(\n this.client,\n this.apiKey,\n this.projectSlug,\n config.source,\n );\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","import { HttpClient } from \"../client\";\nimport type { JoinOptions, JoinResult } from \"../types\";\n\nconst DEFAULT_SOURCE = \"landing-page\";\n\nexport class SubscribersResource {\n private client: HttpClient;\n private apiKey: string;\n private projectSlug: string;\n private defaultSource: string;\n\n constructor(\n client: HttpClient,\n apiKey: string,\n projectSlug: string,\n defaultSource?: string,\n ) {\n this.client = client;\n this.apiKey = apiKey;\n this.projectSlug = projectSlug;\n this.defaultSource = defaultSource ?? DEFAULT_SOURCE;\n }\n\n private get headers() {\n return { Authorization: `Bearer ${this.apiKey}` };\n }\n\n async create(options: JoinOptions): Promise<JoinResult> {\n const data = await this.client.request<{ email: string }>(\n \"POST\",\n `/api/waitlist/${this.projectSlug}/join`,\n {\n headers: this.headers,\n body: { ...options, source: options.source ?? this.defaultSource },\n },\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":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACEO,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,IAA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M,KAAK,OAAO;AAAA,MAC7B;AAAA,MACA,iBAAiB,KAAK,WAAW;AAAA,MACjC;AAAA,QACE,SAAS,KAAK;AAAA,QACd,MAAM,EAAE,GAAG,SAAS,QAAQ,QAAQ,UAAU,KAAK,cAAc;AAAA,MACnE;AAAA,IACF;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;;;AHjDO,IAAM,mBAAmB;AAEzB,IAAM,UAAN,MAAc;AAAA,EACnB;AAAA,EACQ;AAAA,EACA;AAAA,EACA;AAAA,EAER,YAAY,QAAuB;AACjC,SAAK,SAAS,OAAO;AACrB,SAAK,cAAc,OAAO;AAC1B,SAAK,SAAS,IAAI,WAAW,OAAO,WAAW,gBAAgB;AAC/D,SAAK,cAAc,IAAI;AAAA,MACrB,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,OAAO;AAAA,IACT;AAAA,EACF;AACF;","names":[]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { W as WaitKit } from './index-
|
|
1
|
+
export { D as DEFAULT_BASE_URL, W as WaitKit } from './index-3alZWsam.cjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { W as WaitKit } from './index-
|
|
1
|
+
export { D as DEFAULT_BASE_URL, W as WaitKit } from './index-3alZWsam.js';
|
package/dist/index.js
CHANGED
|
@@ -46,14 +46,17 @@ var HttpClient = class {
|
|
|
46
46
|
};
|
|
47
47
|
|
|
48
48
|
// src/resources/subscribers.ts
|
|
49
|
+
var DEFAULT_SOURCE = "landing-page";
|
|
49
50
|
var SubscribersResource = class {
|
|
50
51
|
client;
|
|
51
52
|
apiKey;
|
|
52
53
|
projectSlug;
|
|
53
|
-
|
|
54
|
+
defaultSource;
|
|
55
|
+
constructor(client, apiKey, projectSlug, defaultSource) {
|
|
54
56
|
this.client = client;
|
|
55
57
|
this.apiKey = apiKey;
|
|
56
58
|
this.projectSlug = projectSlug;
|
|
59
|
+
this.defaultSource = defaultSource ?? DEFAULT_SOURCE;
|
|
57
60
|
}
|
|
58
61
|
get headers() {
|
|
59
62
|
return { Authorization: `Bearer ${this.apiKey}` };
|
|
@@ -62,7 +65,10 @@ var SubscribersResource = class {
|
|
|
62
65
|
const data = await this.client.request(
|
|
63
66
|
"POST",
|
|
64
67
|
`/api/waitlist/${this.projectSlug}/join`,
|
|
65
|
-
{
|
|
68
|
+
{
|
|
69
|
+
headers: this.headers,
|
|
70
|
+
body: { ...options, source: options.source ?? this.defaultSource }
|
|
71
|
+
}
|
|
66
72
|
);
|
|
67
73
|
return {
|
|
68
74
|
message: "Thank you for joining the waitlist!",
|
|
@@ -94,11 +100,13 @@ var WaitKit = class {
|
|
|
94
100
|
this.subscribers = new SubscribersResource(
|
|
95
101
|
this.client,
|
|
96
102
|
this.apiKey,
|
|
97
|
-
this.projectSlug
|
|
103
|
+
this.projectSlug,
|
|
104
|
+
config.source
|
|
98
105
|
);
|
|
99
106
|
}
|
|
100
107
|
};
|
|
101
108
|
export {
|
|
109
|
+
DEFAULT_BASE_URL,
|
|
102
110
|
WaitKit
|
|
103
111
|
};
|
|
104
112
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/errors.ts","../src/client.ts","../src/resources/subscribers.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 } from \"../types\";\n\nexport class SubscribersResource {\n private client: HttpClient;\n private apiKey: string;\n private projectSlug: string;\n\n constructor(client: HttpClient
|
|
1
|
+
{"version":3,"sources":["../src/errors.ts","../src/client.ts","../src/resources/subscribers.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 } from \"../types\";\n\nconst DEFAULT_SOURCE = \"landing-page\";\n\nexport class SubscribersResource {\n private client: HttpClient;\n private apiKey: string;\n private projectSlug: string;\n private defaultSource: string;\n\n constructor(\n client: HttpClient,\n apiKey: string,\n projectSlug: string,\n defaultSource?: string,\n ) {\n this.client = client;\n this.apiKey = apiKey;\n this.projectSlug = projectSlug;\n this.defaultSource = defaultSource ?? DEFAULT_SOURCE;\n }\n\n private get headers() {\n return { Authorization: `Bearer ${this.apiKey}` };\n }\n\n async create(options: JoinOptions): Promise<JoinResult> {\n const data = await this.client.request<{ email: string }>(\n \"POST\",\n `/api/waitlist/${this.projectSlug}/join`,\n {\n headers: this.headers,\n body: { ...options, source: options.source ?? this.defaultSource },\n },\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 { HttpClient } from \"./client\";\nimport { SubscribersResource } from \"./resources/subscribers\";\nimport type { WaitKitConfig } from \"./types\";\n\nexport const DEFAULT_BASE_URL = \"https://api.waitkit.dev\";\n\nexport class WaitKit {\n subscribers: SubscribersResource;\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 this.subscribers = new SubscribersResource(\n this.client,\n this.apiKey,\n this.projectSlug,\n config.source,\n );\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,UAAM,MAAM,IAAI,IAAI,GAAG,KAAK,OAAO,GAAG,IAAI,EAAE;AAE5C,QAAI,QAAQ,OAAO;AACjB,iBAAW,CAAC,KAAK,KAAK,KAAK,OAAO,QAAQ,QAAQ,KAAK,GAAG;AACxD,YAAI,UAAU,QAAW;AACvB,cAAI,aAAa,IAAI,KAAK,OAAO,KAAK,CAAC;AAAA,QACzC;AAAA,MACF;AAAA,IACF;AAEA,UAAM,MAAM,MAAM,MAAM,IAAI,SAAS,GAAG;AAAA,MACtC;AAAA,MACA,SAAS;AAAA,QACP,gBAAgB;AAAA,QAChB,GAAG,QAAQ;AAAA,MACb;AAAA,MACA,MAAM,QAAQ,OAAO,KAAK,UAAU,QAAQ,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AAS,IAAI,WAAW,OAAO,WAAW,gBAAgB;AAC/D,SAAK,cAAc,IAAI;AAAA,MACrB,KAAK;AAAA,MACL,KAAK;AAAA,MACL,KAAK;AAAA,MACL,OAAO;AAAA,IACT;AAAA,EACF;AACF;","names":[]}
|
package/dist/react.d.cts
CHANGED
package/dist/react.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "waitkit",
|
|
3
|
-
"version": "0.2
|
|
3
|
+
"version": "0.3.2",
|
|
4
4
|
"description": "WaitKit SDK — waitlist infrastructure for your app",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"waitkit",
|
|
@@ -44,11 +44,6 @@
|
|
|
44
44
|
"files": [
|
|
45
45
|
"dist"
|
|
46
46
|
],
|
|
47
|
-
"scripts": {
|
|
48
|
-
"build": "tsup",
|
|
49
|
-
"dev": "tsup --watch",
|
|
50
|
-
"type-check": "tsc --noEmit"
|
|
51
|
-
},
|
|
52
47
|
"peerDependencies": {
|
|
53
48
|
"react": "^18.0.0 || ^19.0.0"
|
|
54
49
|
},
|
|
@@ -62,5 +57,10 @@
|
|
|
62
57
|
"tsup": "^8.4.0",
|
|
63
58
|
"typescript": "5.9.2",
|
|
64
59
|
"react": "^19.2.4"
|
|
60
|
+
},
|
|
61
|
+
"scripts": {
|
|
62
|
+
"build": "tsup",
|
|
63
|
+
"dev": "tsup --watch",
|
|
64
|
+
"type-check": "tsc --noEmit"
|
|
65
65
|
}
|
|
66
|
-
}
|
|
66
|
+
}
|