@boltix/sdk 0.0.8 → 0.0.9
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/resources/audit/client/Client.d.ts +1 -2
- package/dist/api/resources/audit/client/Client.js +62 -48
- package/dist/api/resources/auth/client/Client.d.ts +0 -15
- package/dist/api/resources/auth/client/Client.js +0 -46
- package/dist/api/resources/auth/client/requests/index.d.ts +0 -1
- package/dist/api/resources/identity/client/Client.d.ts +0 -14
- package/dist/api/resources/identity/client/Client.js +0 -46
- package/dist/api/resources/identity/client/requests/index.d.ts +0 -1
- package/dist/api/resources/index.d.ts +0 -1
- package/dist/api/resources/index.js +0 -1
- package/dist/api/resources/messages/client/Client.d.ts +1 -2
- package/dist/api/resources/messages/client/Client.js +54 -40
- package/dist/api/resources/organizations/client/Client.d.ts +0 -14
- package/dist/api/resources/organizations/client/Client.js +0 -46
- package/dist/api/resources/organizations/client/index.d.ts +1 -1
- package/dist/api/resources/organizations/client/index.js +1 -1
- package/dist/api/{resources/identity/client/requests → types}/CreateAccountInputBody.d.ts +3 -8
- package/dist/api/{resources/organizations/client/requests → types}/CreateOrganizationInputBody.d.ts +3 -8
- package/dist/api/types/ListEventsOutputBody.d.ts +1 -1
- package/dist/api/types/ListMessagesOutputBody.d.ts +1 -1
- package/dist/api/{resources/auth/client/requests → types}/RegisterInputBody.d.ts +3 -9
- package/dist/api/types/index.d.ts +3 -0
- package/dist/api/types/index.js +3 -0
- package/dist/core/exports.d.ts +1 -0
- package/dist/core/exports.js +1 -0
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.js +2 -0
- package/dist/core/pagination/Page.d.ts +33 -0
- package/dist/core/pagination/Page.js +55 -0
- package/dist/core/pagination/exports.d.ts +1 -0
- package/dist/core/pagination/index.d.ts +1 -0
- package/dist/core/pagination/index.js +1 -0
- package/dist/core/utils/index.d.ts +1 -0
- package/dist/core/utils/index.js +1 -0
- package/dist/core/utils/setObjectProperty.d.ts +11 -0
- package/dist/core/utils/setObjectProperty.js +39 -0
- package/dist/environments.d.ts +2 -1
- package/dist/environments.js +1 -0
- package/package.json +1 -1
- package/dist/api/resources/organizations/client/requests/index.d.ts +0 -1
- /package/dist/api/{resources/identity/client/requests → types}/CreateAccountInputBody.js +0 -0
- /package/dist/api/{resources/organizations/client/requests → types}/CreateOrganizationInputBody.js +0 -0
- /package/dist/api/{resources/auth/client/requests → types}/RegisterInputBody.js +0 -0
- /package/dist/{api/resources/organizations/client/requests/index.js → core/pagination/exports.js} +0 -0
|
@@ -19,8 +19,7 @@ export declare class AuditClient {
|
|
|
19
19
|
* @example
|
|
20
20
|
* await client.audit.listEvents()
|
|
21
21
|
*/
|
|
22
|
-
listEvents(request?: BoltixApi.ListEventsAuditRequest, requestOptions?: AuditClient.RequestOptions): core.
|
|
23
|
-
private __listEvents;
|
|
22
|
+
listEvents(request?: BoltixApi.ListEventsAuditRequest, requestOptions?: AuditClient.RequestOptions): Promise<core.Page<BoltixApi.EventResponse, BoltixApi.ListEventsOutputBody>>;
|
|
24
23
|
/**
|
|
25
24
|
* Returns a single audit event by ID.
|
|
26
25
|
*
|
|
@@ -19,55 +19,69 @@ export class AuditClient {
|
|
|
19
19
|
* @example
|
|
20
20
|
* await client.audit.listEvents()
|
|
21
21
|
*/
|
|
22
|
-
listEvents(request = {}, requestOptions) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
.
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
fetchFn: this._options?.fetch,
|
|
58
|
-
logging: this._options.logging,
|
|
59
|
-
});
|
|
60
|
-
if (_response.ok) {
|
|
61
|
-
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
62
|
-
}
|
|
63
|
-
if (_response.error.reason === "status-code") {
|
|
64
|
-
throw new errors.BoltixApiError({
|
|
65
|
-
statusCode: _response.error.statusCode,
|
|
66
|
-
body: _response.error.body,
|
|
67
|
-
rawResponse: _response.rawResponse,
|
|
22
|
+
async listEvents(request = {}, requestOptions) {
|
|
23
|
+
const list = core.HttpResponsePromise.interceptFunction(async (request) => {
|
|
24
|
+
const { resource_type: resourceType, resource_id: resourceId, account_id: accountId, action, limit, offset, } = request;
|
|
25
|
+
const _queryParams = {
|
|
26
|
+
resource_type: resourceType,
|
|
27
|
+
resource_id: resourceId,
|
|
28
|
+
account_id: accountId,
|
|
29
|
+
action,
|
|
30
|
+
limit,
|
|
31
|
+
offset,
|
|
32
|
+
};
|
|
33
|
+
const _authRequest = await this._options.authProvider.getAuthRequest();
|
|
34
|
+
const _headers = mergeHeaders(_authRequest.headers, this._options?.headers, requestOptions?.headers);
|
|
35
|
+
const _response = await core.fetcher({
|
|
36
|
+
url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??
|
|
37
|
+
(await core.Supplier.get(this._options.environment)) ??
|
|
38
|
+
environments.BoltixApiEnvironment.Production, "v1/events"),
|
|
39
|
+
method: "GET",
|
|
40
|
+
headers: _headers,
|
|
41
|
+
queryString: core.url
|
|
42
|
+
.queryBuilder()
|
|
43
|
+
.addMany(_queryParams)
|
|
44
|
+
.add("resource_type", _queryParams.resource_type, { style: "comma" })
|
|
45
|
+
.add("resource_id", _queryParams.resource_id, { style: "comma" })
|
|
46
|
+
.add("account_id", _queryParams.account_id, { style: "comma" })
|
|
47
|
+
.add("action", _queryParams.action, { style: "comma" })
|
|
48
|
+
.add("limit", _queryParams.limit, { style: "comma" })
|
|
49
|
+
.add("offset", _queryParams.offset, { style: "comma" })
|
|
50
|
+
.mergeAdditional(requestOptions?.queryParams)
|
|
51
|
+
.build(),
|
|
52
|
+
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
|
|
53
|
+
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
54
|
+
abortSignal: requestOptions?.abortSignal,
|
|
55
|
+
fetchFn: this._options?.fetch,
|
|
56
|
+
logging: this._options.logging,
|
|
68
57
|
});
|
|
69
|
-
|
|
70
|
-
|
|
58
|
+
if (_response.ok) {
|
|
59
|
+
return {
|
|
60
|
+
data: _response.body,
|
|
61
|
+
rawResponse: _response.rawResponse,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
if (_response.error.reason === "status-code") {
|
|
65
|
+
throw new errors.BoltixApiError({
|
|
66
|
+
statusCode: _response.error.statusCode,
|
|
67
|
+
body: _response.error.body,
|
|
68
|
+
rawResponse: _response.rawResponse,
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/events");
|
|
72
|
+
});
|
|
73
|
+
let _offset = request?.offset != null ? request?.offset : 1;
|
|
74
|
+
const dataWithRawResponse = await list(request).withRawResponse();
|
|
75
|
+
return new core.Page({
|
|
76
|
+
response: dataWithRawResponse.data,
|
|
77
|
+
rawResponse: dataWithRawResponse.rawResponse,
|
|
78
|
+
hasNextPage: (response) => (response?.events ?? []).length >= Math.floor(request?.limit ?? 1),
|
|
79
|
+
getItems: (response) => response?.events ?? [],
|
|
80
|
+
loadPage: (response) => {
|
|
81
|
+
_offset += response?.events != null ? response.events.length : 1;
|
|
82
|
+
return list(core.setObjectProperty(request, "offset", _offset));
|
|
83
|
+
},
|
|
84
|
+
});
|
|
71
85
|
}
|
|
72
86
|
/**
|
|
73
87
|
* Returns a single audit event by ID.
|
|
@@ -37,19 +37,4 @@ export declare class AuthClient {
|
|
|
37
37
|
*/
|
|
38
38
|
refresh(request: BoltixApi.RefreshInputBody, requestOptions?: AuthClient.RequestOptions): core.HttpResponsePromise<BoltixApi.RefreshOutputBody>;
|
|
39
39
|
private __refresh;
|
|
40
|
-
/**
|
|
41
|
-
* Creates a new account in the specified organization.
|
|
42
|
-
*
|
|
43
|
-
* @param {BoltixApi.RegisterInputBody} request
|
|
44
|
-
* @param {AuthClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
45
|
-
*
|
|
46
|
-
* @example
|
|
47
|
-
* await client.auth.register({
|
|
48
|
-
* email: "email",
|
|
49
|
-
* organization_name: "organization_name",
|
|
50
|
-
* password: "password"
|
|
51
|
-
* })
|
|
52
|
-
*/
|
|
53
|
-
register(request: BoltixApi.RegisterInputBody, requestOptions?: AuthClient.RequestOptions): core.HttpResponsePromise<BoltixApi.RegisterOutputBody>;
|
|
54
|
-
private __register;
|
|
55
40
|
}
|
|
@@ -99,50 +99,4 @@ export class AuthClient {
|
|
|
99
99
|
}
|
|
100
100
|
return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/auth/refresh");
|
|
101
101
|
}
|
|
102
|
-
/**
|
|
103
|
-
* Creates a new account in the specified organization.
|
|
104
|
-
*
|
|
105
|
-
* @param {BoltixApi.RegisterInputBody} request
|
|
106
|
-
* @param {AuthClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
107
|
-
*
|
|
108
|
-
* @example
|
|
109
|
-
* await client.auth.register({
|
|
110
|
-
* email: "email",
|
|
111
|
-
* organization_name: "organization_name",
|
|
112
|
-
* password: "password"
|
|
113
|
-
* })
|
|
114
|
-
*/
|
|
115
|
-
register(request, requestOptions) {
|
|
116
|
-
return core.HttpResponsePromise.fromPromise(this.__register(request, requestOptions));
|
|
117
|
-
}
|
|
118
|
-
async __register(request, requestOptions) {
|
|
119
|
-
const _headers = mergeHeaders(this._options?.headers, requestOptions?.headers);
|
|
120
|
-
const _response = await core.fetcher({
|
|
121
|
-
url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??
|
|
122
|
-
(await core.Supplier.get(this._options.environment)) ??
|
|
123
|
-
environments.BoltixApiEnvironment.Production, "v1/auth/register"),
|
|
124
|
-
method: "POST",
|
|
125
|
-
headers: _headers,
|
|
126
|
-
contentType: "application/json",
|
|
127
|
-
queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
|
|
128
|
-
requestType: "json",
|
|
129
|
-
body: request,
|
|
130
|
-
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
|
|
131
|
-
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
132
|
-
abortSignal: requestOptions?.abortSignal,
|
|
133
|
-
fetchFn: this._options?.fetch,
|
|
134
|
-
logging: this._options.logging,
|
|
135
|
-
});
|
|
136
|
-
if (_response.ok) {
|
|
137
|
-
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
138
|
-
}
|
|
139
|
-
if (_response.error.reason === "status-code") {
|
|
140
|
-
throw new errors.BoltixApiError({
|
|
141
|
-
statusCode: _response.error.statusCode,
|
|
142
|
-
body: _response.error.body,
|
|
143
|
-
rawResponse: _response.rawResponse,
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/auth/register");
|
|
147
|
-
}
|
|
148
102
|
}
|
|
@@ -20,20 +20,6 @@ export declare class IdentityClient {
|
|
|
20
20
|
*/
|
|
21
21
|
listAccounts(requestOptions?: IdentityClient.RequestOptions): core.HttpResponsePromise<BoltixApi.ListAccountsOutputBody>;
|
|
22
22
|
private __listAccounts;
|
|
23
|
-
/**
|
|
24
|
-
* Creates a new account in the current organization.
|
|
25
|
-
*
|
|
26
|
-
* @param {BoltixApi.CreateAccountInputBody} request
|
|
27
|
-
* @param {IdentityClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* await client.identity.createAccount({
|
|
31
|
-
* email: "email",
|
|
32
|
-
* password: "password"
|
|
33
|
-
* })
|
|
34
|
-
*/
|
|
35
|
-
createAccount(request: BoltixApi.CreateAccountInputBody, requestOptions?: IdentityClient.RequestOptions): core.HttpResponsePromise<BoltixApi.IdentityAccountResponse>;
|
|
36
|
-
private __createAccount;
|
|
37
23
|
/**
|
|
38
24
|
* Returns the authenticated user's profile.
|
|
39
25
|
*
|
|
@@ -49,52 +49,6 @@ export class IdentityClient {
|
|
|
49
49
|
}
|
|
50
50
|
return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/accounts");
|
|
51
51
|
}
|
|
52
|
-
/**
|
|
53
|
-
* Creates a new account in the current organization.
|
|
54
|
-
*
|
|
55
|
-
* @param {BoltixApi.CreateAccountInputBody} request
|
|
56
|
-
* @param {IdentityClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
57
|
-
*
|
|
58
|
-
* @example
|
|
59
|
-
* await client.identity.createAccount({
|
|
60
|
-
* email: "email",
|
|
61
|
-
* password: "password"
|
|
62
|
-
* })
|
|
63
|
-
*/
|
|
64
|
-
createAccount(request, requestOptions) {
|
|
65
|
-
return core.HttpResponsePromise.fromPromise(this.__createAccount(request, requestOptions));
|
|
66
|
-
}
|
|
67
|
-
async __createAccount(request, requestOptions) {
|
|
68
|
-
const _authRequest = await this._options.authProvider.getAuthRequest();
|
|
69
|
-
const _headers = mergeHeaders(_authRequest.headers, this._options?.headers, requestOptions?.headers);
|
|
70
|
-
const _response = await core.fetcher({
|
|
71
|
-
url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??
|
|
72
|
-
(await core.Supplier.get(this._options.environment)) ??
|
|
73
|
-
environments.BoltixApiEnvironment.Production, "v1/accounts"),
|
|
74
|
-
method: "POST",
|
|
75
|
-
headers: _headers,
|
|
76
|
-
contentType: "application/json",
|
|
77
|
-
queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
|
|
78
|
-
requestType: "json",
|
|
79
|
-
body: request,
|
|
80
|
-
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
|
|
81
|
-
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
82
|
-
abortSignal: requestOptions?.abortSignal,
|
|
83
|
-
fetchFn: this._options?.fetch,
|
|
84
|
-
logging: this._options.logging,
|
|
85
|
-
});
|
|
86
|
-
if (_response.ok) {
|
|
87
|
-
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
88
|
-
}
|
|
89
|
-
if (_response.error.reason === "status-code") {
|
|
90
|
-
throw new errors.BoltixApiError({
|
|
91
|
-
statusCode: _response.error.statusCode,
|
|
92
|
-
body: _response.error.body,
|
|
93
|
-
rawResponse: _response.rawResponse,
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/accounts");
|
|
97
|
-
}
|
|
98
52
|
/**
|
|
99
53
|
* Returns the authenticated user's profile.
|
|
100
54
|
*
|
|
@@ -22,7 +22,6 @@ export * from "./media/client/requests/index.js";
|
|
|
22
22
|
export * as media from "./media/index.js";
|
|
23
23
|
export * from "./messages/client/requests/index.js";
|
|
24
24
|
export * as messages from "./messages/index.js";
|
|
25
|
-
export * from "./organizations/client/requests/index.js";
|
|
26
25
|
export * as organizations from "./organizations/index.js";
|
|
27
26
|
export * from "./routing/client/requests/index.js";
|
|
28
27
|
export * as routing from "./routing/index.js";
|
|
@@ -22,7 +22,6 @@ export * from "./media/client/requests/index.js";
|
|
|
22
22
|
export * as media from "./media/index.js";
|
|
23
23
|
export * from "./messages/client/requests/index.js";
|
|
24
24
|
export * as messages from "./messages/index.js";
|
|
25
|
-
export * from "./organizations/client/requests/index.js";
|
|
26
25
|
export * as organizations from "./organizations/index.js";
|
|
27
26
|
export * from "./routing/client/requests/index.js";
|
|
28
27
|
export * as routing from "./routing/index.js";
|
|
@@ -21,8 +21,7 @@ export declare class MessagesClient {
|
|
|
21
21
|
* id: "id"
|
|
22
22
|
* })
|
|
23
23
|
*/
|
|
24
|
-
list(request: BoltixApi.ListMessagesRequest, requestOptions?: MessagesClient.RequestOptions): core.
|
|
25
|
-
private __list;
|
|
24
|
+
list(request: BoltixApi.ListMessagesRequest, requestOptions?: MessagesClient.RequestOptions): Promise<core.Page<BoltixApi.MessageResponse, BoltixApi.ListMessagesOutputBody>>;
|
|
26
25
|
/**
|
|
27
26
|
* Sends a message to a contact.
|
|
28
27
|
*
|
|
@@ -21,47 +21,61 @@ export class MessagesClient {
|
|
|
21
21
|
* id: "id"
|
|
22
22
|
* })
|
|
23
23
|
*/
|
|
24
|
-
list(request, requestOptions) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
.
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
fetchFn: this._options?.fetch,
|
|
52
|
-
logging: this._options.logging,
|
|
53
|
-
});
|
|
54
|
-
if (_response.ok) {
|
|
55
|
-
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
56
|
-
}
|
|
57
|
-
if (_response.error.reason === "status-code") {
|
|
58
|
-
throw new errors.BoltixApiError({
|
|
59
|
-
statusCode: _response.error.statusCode,
|
|
60
|
-
body: _response.error.body,
|
|
61
|
-
rawResponse: _response.rawResponse,
|
|
24
|
+
async list(request, requestOptions) {
|
|
25
|
+
const list = core.HttpResponsePromise.interceptFunction(async (request) => {
|
|
26
|
+
const { id, limit, offset } = request;
|
|
27
|
+
const _queryParams = {
|
|
28
|
+
limit,
|
|
29
|
+
offset,
|
|
30
|
+
};
|
|
31
|
+
const _authRequest = await this._options.authProvider.getAuthRequest();
|
|
32
|
+
const _headers = mergeHeaders(_authRequest.headers, this._options?.headers, requestOptions?.headers);
|
|
33
|
+
const _response = await core.fetcher({
|
|
34
|
+
url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??
|
|
35
|
+
(await core.Supplier.get(this._options.environment)) ??
|
|
36
|
+
environments.BoltixApiEnvironment.Production, `v1/contacts/${core.url.encodePathParam(id)}/messages`),
|
|
37
|
+
method: "GET",
|
|
38
|
+
headers: _headers,
|
|
39
|
+
queryString: core.url
|
|
40
|
+
.queryBuilder()
|
|
41
|
+
.addMany(_queryParams)
|
|
42
|
+
.add("limit", _queryParams.limit, { style: "comma" })
|
|
43
|
+
.add("offset", _queryParams.offset, { style: "comma" })
|
|
44
|
+
.mergeAdditional(requestOptions?.queryParams)
|
|
45
|
+
.build(),
|
|
46
|
+
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
|
|
47
|
+
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
48
|
+
abortSignal: requestOptions?.abortSignal,
|
|
49
|
+
fetchFn: this._options?.fetch,
|
|
50
|
+
logging: this._options.logging,
|
|
62
51
|
});
|
|
63
|
-
|
|
64
|
-
|
|
52
|
+
if (_response.ok) {
|
|
53
|
+
return {
|
|
54
|
+
data: _response.body,
|
|
55
|
+
rawResponse: _response.rawResponse,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
if (_response.error.reason === "status-code") {
|
|
59
|
+
throw new errors.BoltixApiError({
|
|
60
|
+
statusCode: _response.error.statusCode,
|
|
61
|
+
body: _response.error.body,
|
|
62
|
+
rawResponse: _response.rawResponse,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/contacts/{id}/messages");
|
|
66
|
+
});
|
|
67
|
+
let _offset = request?.offset != null ? request?.offset : 1;
|
|
68
|
+
const dataWithRawResponse = await list(request).withRawResponse();
|
|
69
|
+
return new core.Page({
|
|
70
|
+
response: dataWithRawResponse.data,
|
|
71
|
+
rawResponse: dataWithRawResponse.rawResponse,
|
|
72
|
+
hasNextPage: (response) => (response?.messages ?? []).length >= Math.floor(request?.limit ?? 1),
|
|
73
|
+
getItems: (response) => response?.messages ?? [],
|
|
74
|
+
loadPage: (response) => {
|
|
75
|
+
_offset += response?.messages != null ? response.messages.length : 1;
|
|
76
|
+
return list(core.setObjectProperty(request, "offset", _offset));
|
|
77
|
+
},
|
|
78
|
+
});
|
|
65
79
|
}
|
|
66
80
|
/**
|
|
67
81
|
* Sends a message to a contact.
|
|
@@ -30,18 +30,4 @@ export declare class OrganizationsClient {
|
|
|
30
30
|
*/
|
|
31
31
|
list(requestOptions?: OrganizationsClient.RequestOptions): core.HttpResponsePromise<BoltixApi.ListOrganizationsOutputBody>;
|
|
32
32
|
private __list;
|
|
33
|
-
/**
|
|
34
|
-
* Creates a new organization.
|
|
35
|
-
*
|
|
36
|
-
* @param {BoltixApi.CreateOrganizationInputBody} request
|
|
37
|
-
* @param {OrganizationsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
38
|
-
*
|
|
39
|
-
* @example
|
|
40
|
-
* await client.organizations.create({
|
|
41
|
-
* name: "name",
|
|
42
|
-
* slug: "slug"
|
|
43
|
-
* })
|
|
44
|
-
*/
|
|
45
|
-
create(request: BoltixApi.CreateOrganizationInputBody, requestOptions?: OrganizationsClient.RequestOptions): core.HttpResponsePromise<BoltixApi.OrganizationResponse>;
|
|
46
|
-
private __create;
|
|
47
33
|
}
|
|
@@ -91,50 +91,4 @@ export class OrganizationsClient {
|
|
|
91
91
|
}
|
|
92
92
|
return handleNonStatusCodeError(_response.error, _response.rawResponse, "GET", "/v1/organizations");
|
|
93
93
|
}
|
|
94
|
-
/**
|
|
95
|
-
* Creates a new organization.
|
|
96
|
-
*
|
|
97
|
-
* @param {BoltixApi.CreateOrganizationInputBody} request
|
|
98
|
-
* @param {OrganizationsClient.RequestOptions} requestOptions - Request-specific configuration.
|
|
99
|
-
*
|
|
100
|
-
* @example
|
|
101
|
-
* await client.organizations.create({
|
|
102
|
-
* name: "name",
|
|
103
|
-
* slug: "slug"
|
|
104
|
-
* })
|
|
105
|
-
*/
|
|
106
|
-
create(request, requestOptions) {
|
|
107
|
-
return core.HttpResponsePromise.fromPromise(this.__create(request, requestOptions));
|
|
108
|
-
}
|
|
109
|
-
async __create(request, requestOptions) {
|
|
110
|
-
const _authRequest = await this._options.authProvider.getAuthRequest();
|
|
111
|
-
const _headers = mergeHeaders(_authRequest.headers, this._options?.headers, requestOptions?.headers);
|
|
112
|
-
const _response = await core.fetcher({
|
|
113
|
-
url: core.url.join((await core.Supplier.get(this._options.baseUrl)) ??
|
|
114
|
-
(await core.Supplier.get(this._options.environment)) ??
|
|
115
|
-
environments.BoltixApiEnvironment.Production, "v1/organizations"),
|
|
116
|
-
method: "POST",
|
|
117
|
-
headers: _headers,
|
|
118
|
-
contentType: "application/json",
|
|
119
|
-
queryString: core.url.queryBuilder().mergeAdditional(requestOptions?.queryParams).build(),
|
|
120
|
-
requestType: "json",
|
|
121
|
-
body: request,
|
|
122
|
-
timeoutMs: (requestOptions?.timeoutInSeconds ?? this._options?.timeoutInSeconds ?? 60) * 1000,
|
|
123
|
-
maxRetries: requestOptions?.maxRetries ?? this._options?.maxRetries,
|
|
124
|
-
abortSignal: requestOptions?.abortSignal,
|
|
125
|
-
fetchFn: this._options?.fetch,
|
|
126
|
-
logging: this._options.logging,
|
|
127
|
-
});
|
|
128
|
-
if (_response.ok) {
|
|
129
|
-
return { data: _response.body, rawResponse: _response.rawResponse };
|
|
130
|
-
}
|
|
131
|
-
if (_response.error.reason === "status-code") {
|
|
132
|
-
throw new errors.BoltixApiError({
|
|
133
|
-
statusCode: _response.error.statusCode,
|
|
134
|
-
body: _response.error.body,
|
|
135
|
-
rawResponse: _response.rawResponse,
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
return handleNonStatusCodeError(_response.error, _response.rawResponse, "POST", "/v1/organizations");
|
|
139
|
-
}
|
|
140
94
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export {};
|
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @example
|
|
3
|
-
* {
|
|
4
|
-
* email: "email",
|
|
5
|
-
* password: "password"
|
|
6
|
-
* }
|
|
7
|
-
*/
|
|
8
1
|
export interface CreateAccountInputBody {
|
|
2
|
+
/** A URL to the JSON Schema for this object. */
|
|
3
|
+
$schema?: string | undefined;
|
|
9
4
|
/** Optional display name */
|
|
10
|
-
display_name?: string;
|
|
5
|
+
display_name?: string | undefined;
|
|
11
6
|
/** Account email address */
|
|
12
7
|
email: string;
|
|
13
8
|
/** Account password (min 8 characters) */
|
package/dist/api/{resources/organizations/client/requests → types}/CreateOrganizationInputBody.d.ts
RENAMED
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @example
|
|
3
|
-
* {
|
|
4
|
-
* name: "name",
|
|
5
|
-
* slug: "slug"
|
|
6
|
-
* }
|
|
7
|
-
*/
|
|
8
1
|
export interface CreateOrganizationInputBody {
|
|
2
|
+
/** A URL to the JSON Schema for this object. */
|
|
3
|
+
$schema?: string | undefined;
|
|
9
4
|
/** Organization configuration (arbitrary JSON) */
|
|
10
|
-
config?: unknown;
|
|
5
|
+
config?: unknown | undefined;
|
|
11
6
|
/** Organization name */
|
|
12
7
|
name: string;
|
|
13
8
|
/** Organization slug (lowercase alphanumeric with hyphens) */
|
|
@@ -1,14 +1,8 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @example
|
|
3
|
-
* {
|
|
4
|
-
* email: "email",
|
|
5
|
-
* organization_name: "organization_name",
|
|
6
|
-
* password: "password"
|
|
7
|
-
* }
|
|
8
|
-
*/
|
|
9
1
|
export interface RegisterInputBody {
|
|
2
|
+
/** A URL to the JSON Schema for this object. */
|
|
3
|
+
$schema?: string | undefined;
|
|
10
4
|
/** Optional display name */
|
|
11
|
-
display_name?: string;
|
|
5
|
+
display_name?: string | undefined;
|
|
12
6
|
/** Account email address */
|
|
13
7
|
email: string;
|
|
14
8
|
/** Organization name for the new account */
|
|
@@ -8,7 +8,9 @@ export * from "./CampaignResponse.js";
|
|
|
8
8
|
export * from "./ChannelResponse.js";
|
|
9
9
|
export * from "./ChartDataPointResponse.js";
|
|
10
10
|
export * from "./ContactResponse.js";
|
|
11
|
+
export * from "./CreateAccountInputBody.js";
|
|
11
12
|
export * from "./CreateDownloadUrlOutputBody.js";
|
|
13
|
+
export * from "./CreateOrganizationInputBody.js";
|
|
12
14
|
export * from "./CreateUploadUrlOutputBody.js";
|
|
13
15
|
export * from "./ErrorDetail.js";
|
|
14
16
|
export * from "./ErrorModel.js";
|
|
@@ -49,6 +51,7 @@ export * from "./ProductResponse.js";
|
|
|
49
51
|
export * from "./RecipientInput.js";
|
|
50
52
|
export * from "./RecipientResponse.js";
|
|
51
53
|
export * from "./RefreshOutputBody.js";
|
|
54
|
+
export * from "./RegisterInputBody.js";
|
|
52
55
|
export * from "./RegisterOutputBody.js";
|
|
53
56
|
export * from "./SnippetResponse.js";
|
|
54
57
|
export * from "./StoreResponse.js";
|
package/dist/api/types/index.js
CHANGED
|
@@ -8,7 +8,9 @@ export * from "./CampaignResponse.js";
|
|
|
8
8
|
export * from "./ChannelResponse.js";
|
|
9
9
|
export * from "./ChartDataPointResponse.js";
|
|
10
10
|
export * from "./ContactResponse.js";
|
|
11
|
+
export * from "./CreateAccountInputBody.js";
|
|
11
12
|
export * from "./CreateDownloadUrlOutputBody.js";
|
|
13
|
+
export * from "./CreateOrganizationInputBody.js";
|
|
12
14
|
export * from "./CreateUploadUrlOutputBody.js";
|
|
13
15
|
export * from "./ErrorDetail.js";
|
|
14
16
|
export * from "./ErrorModel.js";
|
|
@@ -49,6 +51,7 @@ export * from "./ProductResponse.js";
|
|
|
49
51
|
export * from "./RecipientInput.js";
|
|
50
52
|
export * from "./RecipientResponse.js";
|
|
51
53
|
export * from "./RefreshOutputBody.js";
|
|
54
|
+
export * from "./RegisterInputBody.js";
|
|
52
55
|
export * from "./RegisterOutputBody.js";
|
|
53
56
|
export * from "./SnippetResponse.js";
|
|
54
57
|
export * from "./StoreResponse.js";
|
package/dist/core/exports.d.ts
CHANGED
package/dist/core/exports.js
CHANGED
package/dist/core/index.d.ts
CHANGED
|
@@ -2,5 +2,7 @@ export * from "./auth/index.js";
|
|
|
2
2
|
export * from "./base64.js";
|
|
3
3
|
export * from "./fetcher/index.js";
|
|
4
4
|
export * as logging from "./logging/index.js";
|
|
5
|
+
export * from "./pagination/index.js";
|
|
5
6
|
export * from "./runtime/index.js";
|
|
6
7
|
export * as url from "./url/index.js";
|
|
8
|
+
export * from "./utils/index.js";
|
package/dist/core/index.js
CHANGED
|
@@ -2,5 +2,7 @@ export * from "./auth/index.js";
|
|
|
2
2
|
export * from "./base64.js";
|
|
3
3
|
export * from "./fetcher/index.js";
|
|
4
4
|
export * as logging from "./logging/index.js";
|
|
5
|
+
export * from "./pagination/index.js";
|
|
5
6
|
export * from "./runtime/index.js";
|
|
6
7
|
export * as url from "./url/index.js";
|
|
8
|
+
export * from "./utils/index.js";
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import type { HttpResponsePromise, RawResponse } from "../fetcher/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* A page of results from a paginated API.
|
|
4
|
+
*
|
|
5
|
+
* @template T The type of the items in the page.
|
|
6
|
+
* @template R The type of the API response.
|
|
7
|
+
*/
|
|
8
|
+
export declare class Page<T, R = unknown> implements AsyncIterable<T> {
|
|
9
|
+
data: T[];
|
|
10
|
+
rawResponse: RawResponse;
|
|
11
|
+
response: R;
|
|
12
|
+
private _hasNextPage;
|
|
13
|
+
private getItems;
|
|
14
|
+
private loadNextPage;
|
|
15
|
+
constructor({ response, rawResponse, hasNextPage, getItems, loadPage, }: {
|
|
16
|
+
response: R;
|
|
17
|
+
rawResponse: RawResponse;
|
|
18
|
+
hasNextPage: (response: R) => boolean;
|
|
19
|
+
getItems: (response: R) => T[];
|
|
20
|
+
loadPage: (response: R) => HttpResponsePromise<R>;
|
|
21
|
+
});
|
|
22
|
+
/**
|
|
23
|
+
* Retrieves the next page
|
|
24
|
+
* @returns this
|
|
25
|
+
*/
|
|
26
|
+
getNextPage(): Promise<this>;
|
|
27
|
+
/**
|
|
28
|
+
* @returns whether there is a next page to load
|
|
29
|
+
*/
|
|
30
|
+
hasNextPage(): boolean;
|
|
31
|
+
private iterMessages;
|
|
32
|
+
[Symbol.asyncIterator](): AsyncIterator<T, void, unknown>;
|
|
33
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A page of results from a paginated API.
|
|
3
|
+
*
|
|
4
|
+
* @template T The type of the items in the page.
|
|
5
|
+
* @template R The type of the API response.
|
|
6
|
+
*/
|
|
7
|
+
export class Page {
|
|
8
|
+
data;
|
|
9
|
+
rawResponse;
|
|
10
|
+
response;
|
|
11
|
+
_hasNextPage;
|
|
12
|
+
getItems;
|
|
13
|
+
loadNextPage;
|
|
14
|
+
constructor({ response, rawResponse, hasNextPage, getItems, loadPage, }) {
|
|
15
|
+
this.response = response;
|
|
16
|
+
this.rawResponse = rawResponse;
|
|
17
|
+
this.data = getItems(response);
|
|
18
|
+
this._hasNextPage = hasNextPage;
|
|
19
|
+
this.getItems = getItems;
|
|
20
|
+
this.loadNextPage = loadPage;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Retrieves the next page
|
|
24
|
+
* @returns this
|
|
25
|
+
*/
|
|
26
|
+
async getNextPage() {
|
|
27
|
+
const { data, rawResponse } = await this.loadNextPage(this.response).withRawResponse();
|
|
28
|
+
this.response = data;
|
|
29
|
+
this.rawResponse = rawResponse;
|
|
30
|
+
this.data = this.getItems(this.response);
|
|
31
|
+
return this;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* @returns whether there is a next page to load
|
|
35
|
+
*/
|
|
36
|
+
hasNextPage() {
|
|
37
|
+
return this._hasNextPage(this.response);
|
|
38
|
+
}
|
|
39
|
+
async *iterMessages() {
|
|
40
|
+
for (const item of this.data) {
|
|
41
|
+
yield item;
|
|
42
|
+
}
|
|
43
|
+
while (this.hasNextPage()) {
|
|
44
|
+
await this.getNextPage();
|
|
45
|
+
for (const item of this.data) {
|
|
46
|
+
yield item;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
async *[Symbol.asyncIterator]() {
|
|
51
|
+
for await (const message of this.iterMessages()) {
|
|
52
|
+
yield message;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type { Page } from "./Page.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Page } from "./Page.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Page } from "./Page.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { setObjectProperty } from "./setObjectProperty.js";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { setObjectProperty } from "./setObjectProperty.js";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sets the value at path of object. If a portion of path doesn’t exist it’s created. This is
|
|
3
|
+
* inspired by Lodash's set function, but is simplified to accommodate our use case.
|
|
4
|
+
* For more details, see https://lodash.com/docs/4.17.15#set.
|
|
5
|
+
*
|
|
6
|
+
* @param object The object to modify.
|
|
7
|
+
* @param path The path of the property to set.
|
|
8
|
+
* @param value The value to set.
|
|
9
|
+
* @return Returns object.
|
|
10
|
+
*/
|
|
11
|
+
export declare function setObjectProperty<T extends object>(object: T, path: string, value: any): T;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sets the value at path of object. If a portion of path doesn’t exist it’s created. This is
|
|
3
|
+
* inspired by Lodash's set function, but is simplified to accommodate our use case.
|
|
4
|
+
* For more details, see https://lodash.com/docs/4.17.15#set.
|
|
5
|
+
*
|
|
6
|
+
* @param object The object to modify.
|
|
7
|
+
* @param path The path of the property to set.
|
|
8
|
+
* @param value The value to set.
|
|
9
|
+
* @return Returns object.
|
|
10
|
+
*/
|
|
11
|
+
export function setObjectProperty(object, path, value) {
|
|
12
|
+
if (object == null) {
|
|
13
|
+
return object;
|
|
14
|
+
}
|
|
15
|
+
const keys = path.split(".");
|
|
16
|
+
if (keys.length === 0) {
|
|
17
|
+
// Invalid path; do nothing.
|
|
18
|
+
return object;
|
|
19
|
+
}
|
|
20
|
+
let current = object;
|
|
21
|
+
for (let i = 0; i < keys.length - 1; i++) {
|
|
22
|
+
const key = keys[i];
|
|
23
|
+
if (key == null) {
|
|
24
|
+
// Unreachable.
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
if (!current[key] || typeof current[key] !== "object") {
|
|
28
|
+
current[key] = {};
|
|
29
|
+
}
|
|
30
|
+
current = current[key];
|
|
31
|
+
}
|
|
32
|
+
const lastKey = keys[keys.length - 1];
|
|
33
|
+
if (lastKey == null) {
|
|
34
|
+
// Unreachable.
|
|
35
|
+
return object;
|
|
36
|
+
}
|
|
37
|
+
current[lastKey] = value;
|
|
38
|
+
return object;
|
|
39
|
+
}
|
package/dist/environments.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare const BoltixApiEnvironment: {
|
|
2
2
|
readonly Production: "https://api.boltix.app";
|
|
3
|
+
readonly Local: "http://localhost:8080";
|
|
3
4
|
};
|
|
4
|
-
export type BoltixApiEnvironment = typeof BoltixApiEnvironment.Production;
|
|
5
|
+
export type BoltixApiEnvironment = typeof BoltixApiEnvironment.Production | typeof BoltixApiEnvironment.Local;
|
package/dist/environments.js
CHANGED
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type { CreateOrganizationInputBody } from "./CreateOrganizationInputBody.js";
|
|
File without changes
|
/package/dist/api/{resources/organizations/client/requests → types}/CreateOrganizationInputBody.js
RENAMED
|
File without changes
|
|
File without changes
|
/package/dist/{api/resources/organizations/client/requests/index.js → core/pagination/exports.js}
RENAMED
|
File without changes
|