@whitewall/blip-warehouse 0.0.1 → 0.0.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/dist/api/src/client.d.ts +4 -2
- package/dist/api/src/types.d.ts +16 -0
- package/dist/index.cjs +28 -16
- package/dist/index.js +28 -16
- package/package.json +1 -1
package/dist/api/src/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { GetMessagesOptions, MessagesByIdentityResult, SearchRequest, SearchResult } from './types';
|
|
1
|
+
import type { CreateTokenRequest, CreateTokenResponse, GetMessagesOptions, HistoricalIngestRequest, HistoricalIngestResponse, MessagesByIdentityResult, SearchRequest, SearchResult } from './types';
|
|
2
2
|
export declare class WarehouseClient {
|
|
3
3
|
private readonly baseUrl;
|
|
4
4
|
private readonly token;
|
|
@@ -6,8 +6,10 @@ export declare class WarehouseClient {
|
|
|
6
6
|
baseUrl?: string;
|
|
7
7
|
token: string;
|
|
8
8
|
});
|
|
9
|
-
private request;
|
|
10
9
|
getContactsCount(): Promise<number>;
|
|
11
10
|
search(request: SearchRequest): Promise<SearchResult>;
|
|
12
11
|
getMessagesByIdentity(identity: string, options?: GetMessagesOptions): Promise<MessagesByIdentityResult>;
|
|
12
|
+
createToken(request: CreateTokenRequest): Promise<CreateTokenResponse>;
|
|
13
|
+
historicalIngest(request: HistoricalIngestRequest): Promise<HistoricalIngestResponse>;
|
|
14
|
+
private request;
|
|
13
15
|
}
|
package/dist/api/src/types.d.ts
CHANGED
|
@@ -12,3 +12,19 @@ export interface GetMessagesOptions {
|
|
|
12
12
|
limit?: number;
|
|
13
13
|
cursor?: string;
|
|
14
14
|
}
|
|
15
|
+
export interface CreateTokenRequest {
|
|
16
|
+
clientIdentifier: string;
|
|
17
|
+
scopes: Array<'warehouse:read' | 'warehouse:write' | 'warehouse:admin'>;
|
|
18
|
+
}
|
|
19
|
+
export interface CreateTokenResponse {
|
|
20
|
+
success: boolean;
|
|
21
|
+
token?: string;
|
|
22
|
+
error?: string;
|
|
23
|
+
}
|
|
24
|
+
export interface HistoricalIngestRequest {
|
|
25
|
+
accessKey: string;
|
|
26
|
+
tenantId: string;
|
|
27
|
+
}
|
|
28
|
+
export interface HistoricalIngestResponse {
|
|
29
|
+
success: boolean;
|
|
30
|
+
}
|
package/dist/index.cjs
CHANGED
|
@@ -7,22 +7,6 @@ var WarehouseClient = class {
|
|
|
7
7
|
this.baseUrl = config.baseUrl?.replace(/\/$/, "") ?? "https://api.warehouse.whitewall.dev";
|
|
8
8
|
this.token = config.token;
|
|
9
9
|
}
|
|
10
|
-
async request(path, options = {}) {
|
|
11
|
-
const url = `${this.baseUrl}${path}`;
|
|
12
|
-
const response = await fetch(url, {
|
|
13
|
-
...options,
|
|
14
|
-
headers: {
|
|
15
|
-
"Content-Type": "application/json",
|
|
16
|
-
Authorization: `Bearer ${this.token}`,
|
|
17
|
-
...options.headers
|
|
18
|
-
}
|
|
19
|
-
});
|
|
20
|
-
if (!response.ok) {
|
|
21
|
-
const errorData = await response.json().catch(() => ({ error: "Unknown error" }));
|
|
22
|
-
throw new Error(`API request failed: ${response.status} ${response.statusText} - ${JSON.stringify(errorData)}`);
|
|
23
|
-
}
|
|
24
|
-
return response.json();
|
|
25
|
-
}
|
|
26
10
|
async getContactsCount() {
|
|
27
11
|
return (await this.request("/warehouse/contacts")).count;
|
|
28
12
|
}
|
|
@@ -44,6 +28,34 @@ var WarehouseClient = class {
|
|
|
44
28
|
const path = `/warehouse/contacts/${encodeURIComponent(identity)}/messages${queryString ? `?${queryString}` : ""}`;
|
|
45
29
|
return this.request(path);
|
|
46
30
|
}
|
|
31
|
+
async createToken(request) {
|
|
32
|
+
return this.request("/auth/tokens", {
|
|
33
|
+
method: "POST",
|
|
34
|
+
body: JSON.stringify(request)
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
async historicalIngest(request) {
|
|
38
|
+
return this.request("/blip/historical-ingest", {
|
|
39
|
+
method: "POST",
|
|
40
|
+
body: JSON.stringify(request)
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
async request(path, options = {}) {
|
|
44
|
+
const url = `${this.baseUrl}${path}`;
|
|
45
|
+
const response = await fetch(url, {
|
|
46
|
+
...options,
|
|
47
|
+
headers: {
|
|
48
|
+
"Content-Type": "application/json",
|
|
49
|
+
Authorization: `Bearer ${this.token}`,
|
|
50
|
+
...options.headers
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
if (!response.ok) {
|
|
54
|
+
const errorData = await response.json().catch(() => ({ error: "Unknown error" }));
|
|
55
|
+
throw new Error(`API request failed: ${response.status} ${response.statusText} - ${JSON.stringify(errorData)}`);
|
|
56
|
+
}
|
|
57
|
+
return response.json();
|
|
58
|
+
}
|
|
47
59
|
};
|
|
48
60
|
|
|
49
61
|
//#endregion
|
package/dist/index.js
CHANGED
|
@@ -6,22 +6,6 @@ var WarehouseClient = class {
|
|
|
6
6
|
this.baseUrl = config.baseUrl?.replace(/\/$/, "") ?? "https://api.warehouse.whitewall.dev";
|
|
7
7
|
this.token = config.token;
|
|
8
8
|
}
|
|
9
|
-
async request(path, options = {}) {
|
|
10
|
-
const url = `${this.baseUrl}${path}`;
|
|
11
|
-
const response = await fetch(url, {
|
|
12
|
-
...options,
|
|
13
|
-
headers: {
|
|
14
|
-
"Content-Type": "application/json",
|
|
15
|
-
Authorization: `Bearer ${this.token}`,
|
|
16
|
-
...options.headers
|
|
17
|
-
}
|
|
18
|
-
});
|
|
19
|
-
if (!response.ok) {
|
|
20
|
-
const errorData = await response.json().catch(() => ({ error: "Unknown error" }));
|
|
21
|
-
throw new Error(`API request failed: ${response.status} ${response.statusText} - ${JSON.stringify(errorData)}`);
|
|
22
|
-
}
|
|
23
|
-
return response.json();
|
|
24
|
-
}
|
|
25
9
|
async getContactsCount() {
|
|
26
10
|
return (await this.request("/warehouse/contacts")).count;
|
|
27
11
|
}
|
|
@@ -43,6 +27,34 @@ var WarehouseClient = class {
|
|
|
43
27
|
const path = `/warehouse/contacts/${encodeURIComponent(identity)}/messages${queryString ? `?${queryString}` : ""}`;
|
|
44
28
|
return this.request(path);
|
|
45
29
|
}
|
|
30
|
+
async createToken(request) {
|
|
31
|
+
return this.request("/auth/tokens", {
|
|
32
|
+
method: "POST",
|
|
33
|
+
body: JSON.stringify(request)
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
async historicalIngest(request) {
|
|
37
|
+
return this.request("/blip/historical-ingest", {
|
|
38
|
+
method: "POST",
|
|
39
|
+
body: JSON.stringify(request)
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
async request(path, options = {}) {
|
|
43
|
+
const url = `${this.baseUrl}${path}`;
|
|
44
|
+
const response = await fetch(url, {
|
|
45
|
+
...options,
|
|
46
|
+
headers: {
|
|
47
|
+
"Content-Type": "application/json",
|
|
48
|
+
Authorization: `Bearer ${this.token}`,
|
|
49
|
+
...options.headers
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
if (!response.ok) {
|
|
53
|
+
const errorData = await response.json().catch(() => ({ error: "Unknown error" }));
|
|
54
|
+
throw new Error(`API request failed: ${response.status} ${response.statusText} - ${JSON.stringify(errorData)}`);
|
|
55
|
+
}
|
|
56
|
+
return response.json();
|
|
57
|
+
}
|
|
46
58
|
};
|
|
47
59
|
|
|
48
60
|
//#endregion
|