@ascendkit/cli 0.1.10
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/LICENSE +21 -0
- package/dist/api/client.d.ts +34 -0
- package/dist/api/client.js +155 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +1153 -0
- package/dist/commands/auth.d.ts +17 -0
- package/dist/commands/auth.js +29 -0
- package/dist/commands/content.d.ts +25 -0
- package/dist/commands/content.js +28 -0
- package/dist/commands/email.d.ts +37 -0
- package/dist/commands/email.js +39 -0
- package/dist/commands/journeys.d.ts +86 -0
- package/dist/commands/journeys.js +69 -0
- package/dist/commands/platform.d.ts +35 -0
- package/dist/commands/platform.js +517 -0
- package/dist/commands/surveys.d.ts +51 -0
- package/dist/commands/surveys.js +41 -0
- package/dist/commands/webhooks.d.ts +16 -0
- package/dist/commands/webhooks.js +28 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +29 -0
- package/dist/mcp.d.ts +2 -0
- package/dist/mcp.js +40 -0
- package/dist/tools/auth.d.ts +3 -0
- package/dist/tools/auth.js +75 -0
- package/dist/tools/content.d.ts +3 -0
- package/dist/tools/content.js +64 -0
- package/dist/tools/email.d.ts +3 -0
- package/dist/tools/email.js +57 -0
- package/dist/tools/journeys.d.ts +3 -0
- package/dist/tools/journeys.js +302 -0
- package/dist/tools/platform.d.ts +3 -0
- package/dist/tools/platform.js +63 -0
- package/dist/tools/surveys.d.ts +3 -0
- package/dist/tools/surveys.js +212 -0
- package/dist/tools/webhooks.d.ts +3 -0
- package/dist/tools/webhooks.js +56 -0
- package/dist/types.d.ts +96 -0
- package/dist/types.js +4 -0
- package/dist/utils/credentials.d.ts +27 -0
- package/dist/utils/credentials.js +90 -0
- package/dist/utils/duration.d.ts +16 -0
- package/dist/utils/duration.js +47 -0
- package/dist/utils/journey-format.d.ts +112 -0
- package/dist/utils/journey-format.js +200 -0
- package/dist/utils/survey-format.d.ts +60 -0
- package/dist/utils/survey-format.js +164 -0
- package/package.json +37 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ascendkit.dev
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* REST client for AscendKit API.
|
|
3
|
+
*/
|
|
4
|
+
export declare class AscendKitClient {
|
|
5
|
+
private baseUrl;
|
|
6
|
+
private publicKey;
|
|
7
|
+
private platformToken;
|
|
8
|
+
constructor(options?: {
|
|
9
|
+
apiUrl?: string;
|
|
10
|
+
publicKey?: string;
|
|
11
|
+
});
|
|
12
|
+
get configured(): boolean;
|
|
13
|
+
get currentPublicKey(): string | null;
|
|
14
|
+
get platformConfigured(): boolean;
|
|
15
|
+
configure(publicKey: string, apiUrl?: string): void;
|
|
16
|
+
configurePlatform(token: string, apiUrl?: string): void;
|
|
17
|
+
private get headers();
|
|
18
|
+
private get platformHeaders();
|
|
19
|
+
/** Headers with both public key and Bearer token for management write operations. */
|
|
20
|
+
private get managedHeaders();
|
|
21
|
+
request<T = unknown>(method: string, path: string, body?: unknown): Promise<T>;
|
|
22
|
+
platformRequest<T = unknown>(method: string, path: string, body?: unknown): Promise<T>;
|
|
23
|
+
/** Unauthenticated request (for login). */
|
|
24
|
+
publicRequest<T = unknown>(method: string, path: string, body?: unknown): Promise<T>;
|
|
25
|
+
get<T = unknown>(path: string): Promise<T>;
|
|
26
|
+
post<T = unknown>(path: string, body?: unknown): Promise<T>;
|
|
27
|
+
put<T = unknown>(path: string, body?: unknown): Promise<T>;
|
|
28
|
+
delete<T = unknown>(path: string): Promise<T>;
|
|
29
|
+
/** Write operation requiring both public key and platform auth. */
|
|
30
|
+
managedRequest<T = unknown>(method: string, path: string, body?: unknown): Promise<T>;
|
|
31
|
+
managedPut<T = unknown>(path: string, body?: unknown): Promise<T>;
|
|
32
|
+
managedPost<T = unknown>(path: string, body?: unknown): Promise<T>;
|
|
33
|
+
managedDelete<T = unknown>(path: string): Promise<T>;
|
|
34
|
+
}
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* REST client for AscendKit API.
|
|
3
|
+
*/
|
|
4
|
+
export class AscendKitClient {
|
|
5
|
+
baseUrl;
|
|
6
|
+
publicKey;
|
|
7
|
+
platformToken;
|
|
8
|
+
constructor(options) {
|
|
9
|
+
this.baseUrl = options?.apiUrl ?? "https://api.ascendkit.com";
|
|
10
|
+
this.publicKey = options?.publicKey ?? null;
|
|
11
|
+
this.platformToken = null;
|
|
12
|
+
}
|
|
13
|
+
get configured() {
|
|
14
|
+
return this.publicKey !== null;
|
|
15
|
+
}
|
|
16
|
+
get currentPublicKey() {
|
|
17
|
+
return this.publicKey;
|
|
18
|
+
}
|
|
19
|
+
get platformConfigured() {
|
|
20
|
+
return this.platformToken !== null;
|
|
21
|
+
}
|
|
22
|
+
configure(publicKey, apiUrl) {
|
|
23
|
+
this.publicKey = publicKey;
|
|
24
|
+
if (apiUrl)
|
|
25
|
+
this.baseUrl = apiUrl;
|
|
26
|
+
}
|
|
27
|
+
configurePlatform(token, apiUrl) {
|
|
28
|
+
this.platformToken = token;
|
|
29
|
+
if (apiUrl)
|
|
30
|
+
this.baseUrl = apiUrl;
|
|
31
|
+
}
|
|
32
|
+
get headers() {
|
|
33
|
+
if (!this.publicKey) {
|
|
34
|
+
throw new Error("Not configured. Call ascendkit_configure with your public key first.");
|
|
35
|
+
}
|
|
36
|
+
return {
|
|
37
|
+
"Content-Type": "application/json",
|
|
38
|
+
"X-AscendKit-Public-Key": this.publicKey,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
get platformHeaders() {
|
|
42
|
+
if (!this.platformToken) {
|
|
43
|
+
throw new Error("Not logged in. Call platform_login first.");
|
|
44
|
+
}
|
|
45
|
+
return {
|
|
46
|
+
"Content-Type": "application/json",
|
|
47
|
+
"Authorization": `Bearer ${this.platformToken}`,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
/** Headers with both public key and Bearer token for management write operations. */
|
|
51
|
+
get managedHeaders() {
|
|
52
|
+
if (!this.publicKey) {
|
|
53
|
+
throw new Error("Not configured. Call ascendkit_configure with your public key first.");
|
|
54
|
+
}
|
|
55
|
+
if (!this.platformToken) {
|
|
56
|
+
throw new Error("Not logged in. Call platform_login first. Management operations require platform auth.");
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
"Content-Type": "application/json",
|
|
60
|
+
"X-AscendKit-Public-Key": this.publicKey,
|
|
61
|
+
"Authorization": `Bearer ${this.platformToken}`,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
async request(method, path, body) {
|
|
65
|
+
const url = `${this.baseUrl}${path}`;
|
|
66
|
+
const init = {
|
|
67
|
+
method,
|
|
68
|
+
headers: this.headers,
|
|
69
|
+
};
|
|
70
|
+
if (body !== undefined) {
|
|
71
|
+
init.body = JSON.stringify(body);
|
|
72
|
+
}
|
|
73
|
+
const response = await fetch(url, init);
|
|
74
|
+
if (!response.ok) {
|
|
75
|
+
const text = await response.text();
|
|
76
|
+
throw new Error(`AscendKit API error ${response.status}: ${text}`);
|
|
77
|
+
}
|
|
78
|
+
const json = (await response.json());
|
|
79
|
+
return json.data;
|
|
80
|
+
}
|
|
81
|
+
async platformRequest(method, path, body) {
|
|
82
|
+
const url = `${this.baseUrl}${path}`;
|
|
83
|
+
const init = {
|
|
84
|
+
method,
|
|
85
|
+
headers: this.platformHeaders,
|
|
86
|
+
};
|
|
87
|
+
if (body !== undefined) {
|
|
88
|
+
init.body = JSON.stringify(body);
|
|
89
|
+
}
|
|
90
|
+
const response = await fetch(url, init);
|
|
91
|
+
if (!response.ok) {
|
|
92
|
+
const text = await response.text();
|
|
93
|
+
throw new Error(`AscendKit API error ${response.status}: ${text}`);
|
|
94
|
+
}
|
|
95
|
+
const json = (await response.json());
|
|
96
|
+
return json.data;
|
|
97
|
+
}
|
|
98
|
+
/** Unauthenticated request (for login). */
|
|
99
|
+
async publicRequest(method, path, body) {
|
|
100
|
+
const url = `${this.baseUrl}${path}`;
|
|
101
|
+
const init = {
|
|
102
|
+
method,
|
|
103
|
+
headers: { "Content-Type": "application/json" },
|
|
104
|
+
};
|
|
105
|
+
if (body !== undefined) {
|
|
106
|
+
init.body = JSON.stringify(body);
|
|
107
|
+
}
|
|
108
|
+
const response = await fetch(url, init);
|
|
109
|
+
if (!response.ok) {
|
|
110
|
+
const text = await response.text();
|
|
111
|
+
throw new Error(`AscendKit API error ${response.status}: ${text}`);
|
|
112
|
+
}
|
|
113
|
+
const json = (await response.json());
|
|
114
|
+
return json.data;
|
|
115
|
+
}
|
|
116
|
+
get(path) {
|
|
117
|
+
return this.request("GET", path);
|
|
118
|
+
}
|
|
119
|
+
post(path, body) {
|
|
120
|
+
return this.request("POST", path, body);
|
|
121
|
+
}
|
|
122
|
+
put(path, body) {
|
|
123
|
+
return this.request("PUT", path, body);
|
|
124
|
+
}
|
|
125
|
+
delete(path) {
|
|
126
|
+
return this.request("DELETE", path);
|
|
127
|
+
}
|
|
128
|
+
/** Write operation requiring both public key and platform auth. */
|
|
129
|
+
async managedRequest(method, path, body) {
|
|
130
|
+
const url = `${this.baseUrl}${path}`;
|
|
131
|
+
const init = {
|
|
132
|
+
method,
|
|
133
|
+
headers: this.managedHeaders,
|
|
134
|
+
};
|
|
135
|
+
if (body !== undefined) {
|
|
136
|
+
init.body = JSON.stringify(body);
|
|
137
|
+
}
|
|
138
|
+
const response = await fetch(url, init);
|
|
139
|
+
if (!response.ok) {
|
|
140
|
+
const text = await response.text();
|
|
141
|
+
throw new Error(`AscendKit API error ${response.status}: ${text}`);
|
|
142
|
+
}
|
|
143
|
+
const json = (await response.json());
|
|
144
|
+
return json.data;
|
|
145
|
+
}
|
|
146
|
+
managedPut(path, body) {
|
|
147
|
+
return this.managedRequest("PUT", path, body);
|
|
148
|
+
}
|
|
149
|
+
managedPost(path, body) {
|
|
150
|
+
return this.managedRequest("POST", path, body);
|
|
151
|
+
}
|
|
152
|
+
managedDelete(path) {
|
|
153
|
+
return this.managedRequest("DELETE", path);
|
|
154
|
+
}
|
|
155
|
+
}
|
package/dist/cli.d.ts
ADDED