@whitewall/blip-warehouse 0.0.1 → 0.0.3
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 +5 -3
- package/dist/api/src/index.d.ts +1 -1
- package/dist/api/src/types.d.ts +16 -0
- package/dist/index.cjs +30 -18
- package/dist/index.js +30 -18
- package/package.json +3 -3
package/dist/api/src/client.d.ts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import type { GetMessagesOptions, MessagesByIdentityResult, SearchRequest, SearchResult } from './types';
|
|
2
|
-
export declare class
|
|
1
|
+
import type { CreateTokenRequest, CreateTokenResponse, GetMessagesOptions, HistoricalIngestRequest, HistoricalIngestResponse, MessagesByIdentityResult, SearchRequest, SearchResult } from './types';
|
|
2
|
+
export declare class BlipWarehouseClient {
|
|
3
3
|
private readonly baseUrl;
|
|
4
4
|
private readonly token;
|
|
5
5
|
constructor(config: {
|
|
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/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { BlipWarehouseClient } from './client';
|
|
2
2
|
export type { ContactsCountResponse, GetMessagesOptions, IndexedContact, IndexedMessage, MessageRow, MessagesByIdentityResult, PaginationCursor, SearchRequest, SearchResult, } from './types';
|
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
|
@@ -1,28 +1,12 @@
|
|
|
1
1
|
|
|
2
2
|
//#region src/client.ts
|
|
3
|
-
var
|
|
3
|
+
var BlipWarehouseClient = class {
|
|
4
4
|
baseUrl;
|
|
5
5
|
token;
|
|
6
6
|
constructor(config) {
|
|
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,7 +28,35 @@ 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
|
|
50
|
-
exports.
|
|
62
|
+
exports.BlipWarehouseClient = BlipWarehouseClient;
|
package/dist/index.js
CHANGED
|
@@ -1,27 +1,11 @@
|
|
|
1
1
|
//#region src/client.ts
|
|
2
|
-
var
|
|
2
|
+
var BlipWarehouseClient = class {
|
|
3
3
|
baseUrl;
|
|
4
4
|
token;
|
|
5
5
|
constructor(config) {
|
|
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,7 +27,35 @@ 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
|
|
49
|
-
export {
|
|
61
|
+
export { BlipWarehouseClient };
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@whitewall/blip-warehouse",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
7
|
-
"types": "./dist/index.d.ts",
|
|
7
|
+
"types": "./dist/api/src/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
10
|
"import": "./dist/index.js",
|
|
11
11
|
"require": "./dist/index.cjs",
|
|
12
|
-
"types": "./dist/index.d.ts"
|
|
12
|
+
"types": "./dist/api/src/index.d.ts"
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
15
|
"files": [
|