@fullstory/server-api-client
Advanced tools
Comparing version 1.0.0-beta.6 to 1.0.0-beta.7
# Changelog | ||
## 1.0.0-beta.7 | ||
- [#53](https://github.com/fullstorydev/fullstory-node-sdk/pull/53) Rename exported interface names to better match TS conventions | ||
- [#54] (https://github.com/fullstorydev/fullstory-node-sdk/pull/54) | ||
- Change method signatures to allow parameter additions to each function, without breaking changes. | ||
- Change per-request option overrides to use `withOptions` method instead of tagging at the end of each request method | ||
- [#56](https://github.com/fullstorydev/fullstory-node-sdk/pull/56) Update specs to use the latest server API specs. Move `Idempotency-Key` as a header parameter for APIs that supports it. | ||
- [#59](https://github.com/fullstorydev/fullstory-node-sdk/pull/59) update plural `CreateEvents` names including request and response types to `CreateEvent` | ||
## 1.0.0-beta.6 | ||
@@ -4,0 +12,0 @@ |
@@ -1,3 +0,3 @@ | ||
import { CreateEventsRequest } from '../../model/index'; | ||
import { FSRequestOptions, FSResponse, FullStoryOptions } from '../../http'; | ||
import { CreateEventRequest } from '../../model/index'; | ||
import { FSResponse, FullStoryOptions } from '../../http'; | ||
export declare class EventsApi { | ||
@@ -9,7 +9,11 @@ readonly defaultBasePath = "https://api.fullstory.com"; | ||
/** | ||
* Creates one event with the specified details. This request can be [made idempotent](../../idempotent-requests). | ||
* @summary Create Events | ||
* Creates one event with the specified details. | ||
* @summary Create Event | ||
* @param body | ||
* @param idempotencyKey Optional header for making the request idempotent | ||
*/ | ||
createEvents(body: CreateEventsRequest, options?: FSRequestOptions): Promise<FSResponse<void>>; | ||
createEvent(request: { | ||
body: CreateEventRequest; | ||
idempotencyKey?: string; | ||
}): Promise<FSResponse<void>>; | ||
} |
@@ -29,8 +29,10 @@ "use strict"; | ||
/** | ||
* Creates one event with the specified details. This request can be [made idempotent](../../idempotent-requests). | ||
* @summary Create Events | ||
* Creates one event with the specified details. | ||
* @summary Create Event | ||
* @param body | ||
* @param idempotencyKey Optional header for making the request idempotent | ||
*/ | ||
createEvents(body, options) { | ||
createEvent(request) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { body, idempotencyKey, } = request; | ||
const apiPath = `${this.basePath}/v2/events`; | ||
@@ -40,2 +42,5 @@ const url = new URL(apiPath); | ||
const headerParams = {}; | ||
if (idempotencyKey !== undefined) { | ||
headerParams['Idempotency-Key'] = idempotencyKey; | ||
} | ||
const consumes = ['application/json']; | ||
@@ -60,3 +65,3 @@ // prefer 'application/json' if supported | ||
try { | ||
return yield this.httpClient.request(requestOptions, body, options); | ||
return yield this.httpClient.request(requestOptions, body); | ||
} | ||
@@ -63,0 +68,0 @@ catch (e) { |
import { JobStatusResponse, GetBatchEventsImportErrorsResponse, CreateBatchEventsImportJobRequest, GetBatchEventsImportsResponse, CreateBatchEventsImportJobResponse } from '../../model/index'; | ||
import { FSRequestOptions, FSResponse, FullStoryOptions } from '../../http'; | ||
import { FSResponse, FullStoryOptions } from '../../http'; | ||
export declare class EventsBatchImportApi { | ||
@@ -9,7 +9,11 @@ readonly defaultBasePath = "https://api.fullstory.com"; | ||
/** | ||
* Creates a batch events import job with the given list of event information. The maximum number of request objects that can be included in a single batch request is `50,000`. This request can be [made idempotent](../../idempotent-requests). | ||
* Creates a batch events import job with the given list of event information. | ||
* @summary Create Events Batch Import | ||
* @param body The request payloads contains the list of events to be imported | ||
* @param idempotencyKey Optional header for marking the request to be idempotent | ||
*/ | ||
createBatchEventsImportJob(body: CreateBatchEventsImportJobRequest, options?: FSRequestOptions): Promise<FSResponse<CreateBatchEventsImportJobResponse>>; | ||
createBatchEventsImportJob(request: { | ||
body: CreateBatchEventsImportJobRequest; | ||
idempotencyKey?: string; | ||
}): Promise<FSResponse<CreateBatchEventsImportJobResponse>>; | ||
/** | ||
@@ -21,3 +25,6 @@ * Get the error message and code for any events that failed from an events import job. | ||
*/ | ||
getBatchEventsImportErrors(jobId: string, pageToken?: string, options?: FSRequestOptions): Promise<FSResponse<GetBatchEventsImportErrorsResponse>>; | ||
getBatchEventsImportErrors(request: { | ||
jobId: string; | ||
pageToken?: string; | ||
}): Promise<FSResponse<GetBatchEventsImportErrorsResponse>>; | ||
/** | ||
@@ -28,3 +35,5 @@ * Get the status for a batch events import job with job details. | ||
*/ | ||
getBatchEventsImportStatus(jobId: string, options?: FSRequestOptions): Promise<FSResponse<JobStatusResponse>>; | ||
getBatchEventsImportStatus(request: { | ||
jobId: string; | ||
}): Promise<FSResponse<JobStatusResponse>>; | ||
/** | ||
@@ -37,3 +46,7 @@ * Get the event details for successful events imported from a batch events import job. | ||
*/ | ||
getBatchEventsImports(jobId: string, pageToken?: string, includeSchema?: boolean, options?: FSRequestOptions): Promise<FSResponse<GetBatchEventsImportsResponse>>; | ||
getBatchEventsImports(request: { | ||
jobId: string; | ||
pageToken?: string; | ||
includeSchema?: boolean; | ||
}): Promise<FSResponse<GetBatchEventsImportsResponse>>; | ||
} |
@@ -29,8 +29,10 @@ "use strict"; | ||
/** | ||
* Creates a batch events import job with the given list of event information. The maximum number of request objects that can be included in a single batch request is `50,000`. This request can be [made idempotent](../../idempotent-requests). | ||
* Creates a batch events import job with the given list of event information. | ||
* @summary Create Events Batch Import | ||
* @param body The request payloads contains the list of events to be imported | ||
* @param idempotencyKey Optional header for marking the request to be idempotent | ||
*/ | ||
createBatchEventsImportJob(body, options) { | ||
createBatchEventsImportJob(request) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { body, idempotencyKey, } = request; | ||
const apiPath = `${this.basePath}/v2/events/batch`; | ||
@@ -40,2 +42,5 @@ const url = new URL(apiPath); | ||
const headerParams = {}; | ||
if (idempotencyKey !== undefined) { | ||
headerParams['Idempotency-Key'] = idempotencyKey; | ||
} | ||
const consumes = ['application/json']; | ||
@@ -60,3 +65,3 @@ // prefer 'application/json' if supported | ||
try { | ||
return yield this.httpClient.request(requestOptions, body, options); | ||
return yield this.httpClient.request(requestOptions, body); | ||
} | ||
@@ -76,4 +81,5 @@ catch (e) { | ||
*/ | ||
getBatchEventsImportErrors(jobId, pageToken, options) { | ||
getBatchEventsImportErrors(request) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { jobId, pageToken, } = request; | ||
const apiPath = `${this.basePath}/v2/events/batch/{job_id}/errors` | ||
@@ -98,3 +104,3 @@ .replace('{' + 'job_id' + '}', encodeURIComponent(String(jobId))); | ||
try { | ||
return yield this.httpClient.request(requestOptions, undefined, options); | ||
return yield this.httpClient.request(requestOptions, undefined); | ||
} | ||
@@ -113,4 +119,5 @@ catch (e) { | ||
*/ | ||
getBatchEventsImportStatus(jobId, options) { | ||
getBatchEventsImportStatus(request) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { jobId, } = request; | ||
const apiPath = `${this.basePath}/v2/events/batch/{job_id}` | ||
@@ -132,3 +139,3 @@ .replace('{' + 'job_id' + '}', encodeURIComponent(String(jobId))); | ||
try { | ||
return yield this.httpClient.request(requestOptions, undefined, options); | ||
return yield this.httpClient.request(requestOptions, undefined); | ||
} | ||
@@ -149,4 +156,5 @@ catch (e) { | ||
*/ | ||
getBatchEventsImports(jobId, pageToken, includeSchema, options) { | ||
getBatchEventsImports(request) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { jobId, pageToken, includeSchema, } = request; | ||
const apiPath = `${this.basePath}/v2/events/batch/{job_id}/imports` | ||
@@ -174,3 +182,3 @@ .replace('{' + 'job_id' + '}', encodeURIComponent(String(jobId))); | ||
try { | ||
return yield this.httpClient.request(requestOptions, undefined, options); | ||
return yield this.httpClient.request(requestOptions, undefined); | ||
} | ||
@@ -177,0 +185,0 @@ catch (e) { |
import { GetUserResponse, ListUsersResponse, CreateUserResponse, UpdateUserResponse, CreateUserRequest, UpdateUserRequest } from '../../model/index'; | ||
import { FSRequestOptions, FSResponse, FullStoryOptions } from '../../http'; | ||
import { FSResponse, FullStoryOptions } from '../../http'; | ||
export declare class UsersApi { | ||
@@ -9,7 +9,11 @@ readonly defaultBasePath = "https://api.fullstory.com"; | ||
/** | ||
* Creates a user with the specified details. This request can be [made idempotent](../../idempotent-requests). | ||
* Creates a user with the specified details. | ||
* @summary Create User | ||
* @param body | ||
* @param idempotencyKey Optional header for making the request idempotent | ||
*/ | ||
createUser(body: CreateUserRequest, options?: FSRequestOptions): Promise<FSResponse<CreateUserResponse>>; | ||
createUser(request: { | ||
body: CreateUserRequest; | ||
idempotencyKey?: string; | ||
}): Promise<FSResponse<CreateUserResponse>>; | ||
/** | ||
@@ -20,3 +24,5 @@ * Delete a single user by FullStory generated user ID. | ||
*/ | ||
deleteUser(id: string, options?: FSRequestOptions): Promise<FSResponse<void>>; | ||
deleteUser(request: { | ||
id: string; | ||
}): Promise<FSResponse<void>>; | ||
/** | ||
@@ -27,3 +33,5 @@ * Delete a single user by uid. | ||
*/ | ||
deleteUserByUid(uid?: string, options?: FSRequestOptions): Promise<FSResponse<void>>; | ||
deleteUserByUid(request: { | ||
uid?: string; | ||
}): Promise<FSResponse<void>>; | ||
/** | ||
@@ -35,3 +43,6 @@ * Retrieve details for a single user | ||
*/ | ||
getUser(id: string, includeSchema?: boolean, options?: FSRequestOptions): Promise<FSResponse<GetUserResponse>>; | ||
getUser(request: { | ||
id: string; | ||
includeSchema?: boolean; | ||
}): Promise<FSResponse<GetUserResponse>>; | ||
/** | ||
@@ -47,3 +58,10 @@ * Retrieve a list of users matching the supplied filter criteria | ||
*/ | ||
listUsers(uid?: string, email?: string, displayName?: string, isIdentified?: boolean, pageToken?: string, includeSchema?: boolean, options?: FSRequestOptions): Promise<FSResponse<ListUsersResponse>>; | ||
listUsers(request: { | ||
uid?: string; | ||
email?: string; | ||
displayName?: string; | ||
isIdentified?: boolean; | ||
pageToken?: string; | ||
includeSchema?: boolean; | ||
}): Promise<FSResponse<ListUsersResponse>>; | ||
/** | ||
@@ -55,3 +73,6 @@ * Updates a user with the specified details | ||
*/ | ||
updateUser(id: string, body: UpdateUserRequest, options?: FSRequestOptions): Promise<FSResponse<UpdateUserResponse>>; | ||
updateUser(request: { | ||
id: string; | ||
body: UpdateUserRequest; | ||
}): Promise<FSResponse<UpdateUserResponse>>; | ||
} |
@@ -29,8 +29,10 @@ "use strict"; | ||
/** | ||
* Creates a user with the specified details. This request can be [made idempotent](../../idempotent-requests). | ||
* Creates a user with the specified details. | ||
* @summary Create User | ||
* @param body | ||
* @param idempotencyKey Optional header for making the request idempotent | ||
*/ | ||
createUser(body, options) { | ||
createUser(request) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { body, idempotencyKey, } = request; | ||
const apiPath = `${this.basePath}/v2/users`; | ||
@@ -40,2 +42,5 @@ const url = new URL(apiPath); | ||
const headerParams = {}; | ||
if (idempotencyKey !== undefined) { | ||
headerParams['Idempotency-Key'] = idempotencyKey; | ||
} | ||
const consumes = ['application/json']; | ||
@@ -60,3 +65,3 @@ // prefer 'application/json' if supported | ||
try { | ||
return yield this.httpClient.request(requestOptions, body, options); | ||
return yield this.httpClient.request(requestOptions, body); | ||
} | ||
@@ -75,4 +80,5 @@ catch (e) { | ||
*/ | ||
deleteUser(id, options) { | ||
deleteUser(request) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { id, } = request; | ||
const apiPath = `${this.basePath}/v2/users/{id}` | ||
@@ -94,3 +100,3 @@ .replace('{' + 'id' + '}', encodeURIComponent(String(id))); | ||
try { | ||
return yield this.httpClient.request(requestOptions, undefined, options); | ||
return yield this.httpClient.request(requestOptions, undefined); | ||
} | ||
@@ -109,4 +115,5 @@ catch (e) { | ||
*/ | ||
deleteUserByUid(uid, options) { | ||
deleteUserByUid(request) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { uid, } = request; | ||
const apiPath = `${this.basePath}/v2/users`; | ||
@@ -130,3 +137,3 @@ const url = new URL(apiPath); | ||
try { | ||
return yield this.httpClient.request(requestOptions, undefined, options); | ||
return yield this.httpClient.request(requestOptions, undefined); | ||
} | ||
@@ -146,4 +153,5 @@ catch (e) { | ||
*/ | ||
getUser(id, includeSchema, options) { | ||
getUser(request) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { id, includeSchema, } = request; | ||
const apiPath = `${this.basePath}/v2/users/{id}` | ||
@@ -168,3 +176,3 @@ .replace('{' + 'id' + '}', encodeURIComponent(String(id))); | ||
try { | ||
return yield this.httpClient.request(requestOptions, undefined, options); | ||
return yield this.httpClient.request(requestOptions, undefined); | ||
} | ||
@@ -188,4 +196,5 @@ catch (e) { | ||
*/ | ||
listUsers(uid, email, displayName, isIdentified, pageToken, includeSchema, options) { | ||
listUsers(request) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { uid, email, displayName, isIdentified, pageToken, includeSchema, } = request; | ||
const apiPath = `${this.basePath}/v2/users`; | ||
@@ -224,3 +233,3 @@ const url = new URL(apiPath); | ||
try { | ||
return yield this.httpClient.request(requestOptions, undefined, options); | ||
return yield this.httpClient.request(requestOptions, undefined); | ||
} | ||
@@ -240,4 +249,5 @@ catch (e) { | ||
*/ | ||
updateUser(id, body, options) { | ||
updateUser(request) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { id, body, } = request; | ||
const apiPath = `${this.basePath}/v2/users/{id}` | ||
@@ -267,3 +277,3 @@ .replace('{' + 'id' + '}', encodeURIComponent(String(id))); | ||
try { | ||
return yield this.httpClient.request(requestOptions, body, options); | ||
return yield this.httpClient.request(requestOptions, body); | ||
} | ||
@@ -270,0 +280,0 @@ catch (e) { |
import { JobStatusResponse, CreateBatchUserImportJobRequest, GetBatchUserImportsResponse, GetBatchUserImportErrorsResponse, CreateBatchUserImportJobResponse } from '../../model/index'; | ||
import { FSRequestOptions, FSResponse, FullStoryOptions } from '../../http'; | ||
import { FSResponse, FullStoryOptions } from '../../http'; | ||
export declare class UsersBatchImportApi { | ||
@@ -9,7 +9,11 @@ readonly defaultBasePath = "https://api.fullstory.com"; | ||
/** | ||
* Creates a batch user import job with the given list of users\' information. Users are upserted (created if they do not exist or updated if they do exist). ### Payload Limits The number of request objects that can be included in a single batch request is `50,000`. This request can be [made idempotent](../../idempotent-requests). | ||
* Creates a batch user import job with the given list of users\' information. | ||
* @summary Create Batch Import | ||
* @param body | ||
* @param idempotencyKey Optional header for making the request idempotent | ||
*/ | ||
createBatchUserImportJob(body: CreateBatchUserImportJobRequest, options?: FSRequestOptions): Promise<FSResponse<CreateBatchUserImportJobResponse>>; | ||
createBatchUserImportJob(request: { | ||
body: CreateBatchUserImportJobRequest; | ||
idempotencyKey?: string; | ||
}): Promise<FSResponse<CreateBatchUserImportJobResponse>>; | ||
/** | ||
@@ -21,3 +25,6 @@ * Get the error message and code for any users that failed from a user import job. | ||
*/ | ||
getBatchUserImportErrors(jobId: string, pageToken?: string, options?: FSRequestOptions): Promise<FSResponse<GetBatchUserImportErrorsResponse>>; | ||
getBatchUserImportErrors(request: { | ||
jobId: string; | ||
pageToken?: string; | ||
}): Promise<FSResponse<GetBatchUserImportErrorsResponse>>; | ||
/** | ||
@@ -28,5 +35,7 @@ * Get the status for a batch user import job with job details. | ||
*/ | ||
getBatchUserImportStatus(jobId: string, options?: FSRequestOptions): Promise<FSResponse<JobStatusResponse>>; | ||
getBatchUserImportStatus(request: { | ||
jobId: string; | ||
}): Promise<FSResponse<JobStatusResponse>>; | ||
/** | ||
* Get the FullStory uid and user details for successful users imported from a batch user import job. | ||
* Get the FullStory id and user details for successful users imported from a batch user import job. | ||
* @summary Get Batch Imported Users | ||
@@ -37,3 +46,7 @@ * @param jobId ID that can be used to check the status and retrieve results for the batch import | ||
*/ | ||
getBatchUserImports(jobId: string, pageToken?: string, includeSchema?: boolean, options?: FSRequestOptions): Promise<FSResponse<GetBatchUserImportsResponse>>; | ||
getBatchUserImports(request: { | ||
jobId: string; | ||
pageToken?: string; | ||
includeSchema?: boolean; | ||
}): Promise<FSResponse<GetBatchUserImportsResponse>>; | ||
} |
@@ -29,8 +29,10 @@ "use strict"; | ||
/** | ||
* Creates a batch user import job with the given list of users\' information. Users are upserted (created if they do not exist or updated if they do exist). ### Payload Limits The number of request objects that can be included in a single batch request is `50,000`. This request can be [made idempotent](../../idempotent-requests). | ||
* Creates a batch user import job with the given list of users\' information. | ||
* @summary Create Batch Import | ||
* @param body | ||
* @param idempotencyKey Optional header for making the request idempotent | ||
*/ | ||
createBatchUserImportJob(body, options) { | ||
createBatchUserImportJob(request) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { body, idempotencyKey, } = request; | ||
const apiPath = `${this.basePath}/v2/users/batch`; | ||
@@ -40,2 +42,5 @@ const url = new URL(apiPath); | ||
const headerParams = {}; | ||
if (idempotencyKey !== undefined) { | ||
headerParams['Idempotency-Key'] = idempotencyKey; | ||
} | ||
const consumes = ['application/json']; | ||
@@ -60,3 +65,3 @@ // prefer 'application/json' if supported | ||
try { | ||
return yield this.httpClient.request(requestOptions, body, options); | ||
return yield this.httpClient.request(requestOptions, body); | ||
} | ||
@@ -76,4 +81,5 @@ catch (e) { | ||
*/ | ||
getBatchUserImportErrors(jobId, pageToken, options) { | ||
getBatchUserImportErrors(request) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { jobId, pageToken, } = request; | ||
const apiPath = `${this.basePath}/v2/users/batch/{job_id}/errors` | ||
@@ -98,3 +104,3 @@ .replace('{' + 'job_id' + '}', encodeURIComponent(String(jobId))); | ||
try { | ||
return yield this.httpClient.request(requestOptions, undefined, options); | ||
return yield this.httpClient.request(requestOptions, undefined); | ||
} | ||
@@ -113,4 +119,5 @@ catch (e) { | ||
*/ | ||
getBatchUserImportStatus(jobId, options) { | ||
getBatchUserImportStatus(request) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { jobId, } = request; | ||
const apiPath = `${this.basePath}/v2/users/batch/{job_id}` | ||
@@ -132,3 +139,3 @@ .replace('{' + 'job_id' + '}', encodeURIComponent(String(jobId))); | ||
try { | ||
return yield this.httpClient.request(requestOptions, undefined, options); | ||
return yield this.httpClient.request(requestOptions, undefined); | ||
} | ||
@@ -143,3 +150,3 @@ catch (e) { | ||
/** | ||
* Get the FullStory uid and user details for successful users imported from a batch user import job. | ||
* Get the FullStory id and user details for successful users imported from a batch user import job. | ||
* @summary Get Batch Imported Users | ||
@@ -150,4 +157,5 @@ * @param jobId ID that can be used to check the status and retrieve results for the batch import | ||
*/ | ||
getBatchUserImports(jobId, pageToken, includeSchema, options) { | ||
getBatchUserImports(request) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { jobId, pageToken, includeSchema, } = request; | ||
const apiPath = `${this.basePath}/v2/users/batch/{job_id}/imports` | ||
@@ -175,3 +183,3 @@ .replace('{' + 'job_id' + '}', encodeURIComponent(String(jobId))); | ||
try { | ||
return yield this.httpClient.request(requestOptions, undefined, options); | ||
return yield this.httpClient.request(requestOptions, undefined); | ||
} | ||
@@ -178,0 +186,0 @@ catch (e) { |
import { JobMetadata, JobStatus } from '../model/index'; | ||
import { FSRequestOptions } from '../http'; | ||
export interface IBatchRequester<REQ, RSP, STATUS_RSP, IMPORTS_RSP, ERRORS_RSP> { | ||
requestCreateJob(req: REQ): Promise<RSP>; | ||
export interface BatchRequester<REQ, RSP, STATUS_RSP, IMPORTS_RSP, ERRORS_RSP> { | ||
requestCreateJob(request: { | ||
body: REQ; | ||
idempotencyKey?: string; | ||
}): Promise<RSP>; | ||
requestImports(id: string, pageToken?: string): Promise<IMPORTS_RSP>; | ||
@@ -14,3 +17,3 @@ requestImportErrors(id: string, pageToken?: string): Promise<ERRORS_RSP>; | ||
export declare const DefaultBatchJobOpts: Required<BatchJobOptions>; | ||
export interface IBatchJob<REQUEST extends { | ||
export interface BatchJob<REQUEST extends { | ||
requests: SINGLE_REQ[]; | ||
@@ -37,3 +40,3 @@ }, SINGLE_REQ, IMPORT, FAILURE> { | ||
} | ||
export declare class BatchJob<REQUEST extends { | ||
export declare class BatchJobImpl<REQUEST extends { | ||
requests: SINGLE_REQ[]; | ||
@@ -44,3 +47,3 @@ }, SINGLE_REQ, CREATE_RSP extends { | ||
job?: JobMetadata; | ||
}, IMPORT, FAILURE> implements IBatchJob<REQUEST, SINGLE_REQ, IMPORT, FAILURE> { | ||
}, IMPORT, FAILURE> implements BatchJob<REQUEST, SINGLE_REQ, IMPORT, FAILURE> { | ||
private requester; | ||
@@ -63,3 +66,3 @@ readonly options: Required<BatchJobOptions> & FSRequestOptions; | ||
private _numRetries; | ||
constructor(request: REQUEST, requester: IBatchRequester<REQUEST, CREATE_RSP, STATUS_RSP, { | ||
constructor(request: REQUEST, requester: BatchRequester<REQUEST, CREATE_RSP, STATUS_RSP, { | ||
results?: IMPORT[]; | ||
@@ -66,0 +69,0 @@ next_page_token?: string; |
@@ -12,3 +12,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.BatchJob = exports.DefaultBatchJobOpts = void 0; | ||
exports.BatchJobImpl = exports.DefaultBatchJobOpts = void 0; | ||
//////////////////////////////////// | ||
@@ -25,3 +25,3 @@ // Batch Imports | ||
}; | ||
class BatchJob { | ||
class BatchJobImpl { | ||
constructor(request, | ||
@@ -95,3 +95,3 @@ // TODO(sabrina):these could be better typed | ||
} | ||
(0, retry_1.withRetry)(() => this.requester.requestCreateJob(this.request), this.handleError.bind(this), this.options.maxRetry) | ||
(0, retry_1.withRetry)(() => this.requester.requestCreateJob({ body: this.request }), this.handleError.bind(this), this.options.maxRetry) | ||
.then(response => { | ||
@@ -286,3 +286,3 @@ var _a; | ||
} | ||
exports.BatchJob = BatchJob; | ||
exports.BatchJobImpl = BatchJobImpl; | ||
//# sourceMappingURL=index.js.map |
import { EventsApi as FSEventsApi } from './api/index'; | ||
import { BatchCreateEventsResponse, CreateBatchEventsImportJobRequest, CreateBatchEventsImportJobResponse, CreateEventsRequest, FailedEventsImport, GetBatchEventsImportErrorsResponse, GetBatchEventsImportsResponse, JobStatusResponse } from './model/index'; | ||
import { BatchJob, BatchJobOptions, IBatchJob, IBatchRequester } from './batch'; | ||
import { FSRequestOptions, FSResponse, FullStoryOptions } from './http'; | ||
import { BatchCreateEventsResponse, CreateBatchEventsImportJobRequest, CreateBatchEventsImportJobResponse, CreateEventRequest, FailedEventsImport, GetBatchEventsImportErrorsResponse, GetBatchEventsImportsResponse, JobStatusResponse } from './model/index'; | ||
import { BatchJob, BatchJobOptions, BatchRequester } from './batch'; | ||
import { FSResponse, FullStoryOptions, WithOptions } from './http'; | ||
/** | ||
* @interface IEventsApi - create events within a single context. | ||
* @interface EventsApi - create events within a single context. | ||
*/ | ||
export interface IEventsApi { | ||
create(...req: Parameters<typeof FSEventsApi.prototype.createEvents>): Promise<FSResponse<void>>; | ||
interface EventsApi { | ||
create(...req: Parameters<typeof FSEventsApi.prototype.createEvent>): Promise<FSResponse<void>>; | ||
} | ||
/** | ||
* @interface IBatchEventsApi - batch import events across multiple context. | ||
* @interface BatchEventsApi - batch import events across multiple context. | ||
*/ | ||
export interface IBatchEventsApi { | ||
batchCreate(request?: CreateBatchEventsImportJobRequest, jobOptions?: BatchJobOptions): BatchEventsJob; | ||
interface BatchEventsApi { | ||
batchCreate(request: { | ||
body: CreateBatchEventsImportJobRequest; | ||
includeSchema?: boolean; | ||
}, jobOptions?: BatchJobOptions): BatchEventsJob; | ||
} | ||
/** | ||
* @interface IBatchEventsJob - a job for batch import events, providing job management and callbacks. | ||
* @interface BatchEventsJob - a job for batch import events, providing job management and callbacks. | ||
*/ | ||
export type IBatchEventsJob = IBatchJob<CreateBatchEventsImportJobRequest, CreateEventsRequest, BatchCreateEventsResponse, FailedEventsImport>; | ||
export type BatchEventsJob = BatchJob<CreateBatchEventsImportJobRequest, CreateEventRequest, BatchCreateEventsResponse, FailedEventsImport>; | ||
/** | ||
* @interface IEvents - create or batch import events. | ||
* @interface Events - create or batch import events. | ||
*/ | ||
export type IEvents = IBatchEventsApi & IEventsApi; | ||
declare class BatchEventsJob extends BatchJob<CreateBatchEventsImportJobRequest, CreateEventsRequest, CreateBatchEventsImportJobResponse, JobStatusResponse, BatchCreateEventsResponse, FailedEventsImport> { | ||
constructor(fsOpts: FullStoryOptions, request: CreateBatchEventsImportJobRequest, opts?: BatchJobOptions, includeSchema?: boolean); | ||
} | ||
export type IBatchEventRequester = IBatchRequester<CreateBatchEventsImportJobRequest, CreateBatchEventsImportJobResponse, JobStatusResponse, GetBatchEventsImportsResponse, GetBatchEventsImportErrorsResponse>; | ||
export declare class Events implements IEvents { | ||
export type Events = BatchEventsApi & EventsApi; | ||
export type BatchEventRequester = BatchRequester<CreateBatchEventsImportJobRequest, CreateBatchEventsImportJobResponse, JobStatusResponse, GetBatchEventsImportsResponse, GetBatchEventsImportErrorsResponse>; | ||
export declare class EventsImpl implements Events, WithOptions<Events> { | ||
private opts; | ||
protected readonly eventsImpl: FSEventsApi; | ||
constructor(opts: FullStoryOptions); | ||
create(body: CreateEventsRequest, options?: FSRequestOptions | undefined): Promise<FSResponse<void>>; | ||
batchCreate(request?: CreateBatchEventsImportJobRequest, jobOptions?: BatchJobOptions, includeSchema?: boolean): BatchEventsJob; | ||
withOptions(opts: Partial<FullStoryOptions>): Events; | ||
create(...request: Parameters<typeof FSEventsApi.prototype.createEvent>): Promise<FSResponse<void>>; | ||
batchCreate(request: { | ||
body: CreateBatchEventsImportJobRequest; | ||
includeSchema?: boolean; | ||
}, jobOptions?: BatchJobOptions): BatchEventsJob; | ||
} | ||
export {}; |
@@ -12,11 +12,11 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Events = void 0; | ||
exports.EventsImpl = void 0; | ||
const index_1 = require("./api/index"); | ||
const batch_1 = require("./batch"); | ||
class BatchEventsJob extends batch_1.BatchJob { | ||
class BatchEventsJobImpl extends batch_1.BatchJobImpl { | ||
constructor(fsOpts, request, opts = {}, includeSchema = false) { | ||
super(request, new BatchEventsRequester(fsOpts, includeSchema), opts); | ||
super(request, new BatchEventsRequesterImpl(fsOpts, includeSchema), opts); | ||
} | ||
} | ||
class BatchEventsRequester { | ||
class BatchEventsRequesterImpl { | ||
constructor(fsOpts, includeSchema) { | ||
@@ -27,6 +27,6 @@ this.fsOpts = fsOpts; | ||
} | ||
requestCreateJob(req) { | ||
requestCreateJob(request) { | ||
var _a; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const rsp = yield this.batchEventsImpl.createBatchEventsImportJob(req, this.fsOpts); | ||
const rsp = yield this.batchEventsImpl.createBatchEventsImportJob(request); | ||
// make sure job metadata exist | ||
@@ -40,5 +40,5 @@ const job = rsp.body; | ||
} | ||
requestImports(id, pageToken) { | ||
requestImports(jobId, pageToken) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const res = yield this.batchEventsImpl.getBatchEventsImports(id, pageToken, this.includeSchema, this.fsOpts); | ||
const res = yield this.batchEventsImpl.getBatchEventsImports({ jobId, pageToken, includeSchema: this.includeSchema }); | ||
const results = res.body; | ||
@@ -51,5 +51,5 @@ if (!results) { | ||
} | ||
requestImportErrors(id, pageToken) { | ||
requestImportErrors(jobId, pageToken) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const res = yield this.batchEventsImpl.getBatchEventsImportErrors(id, pageToken); | ||
const res = yield this.batchEventsImpl.getBatchEventsImportErrors({ jobId, pageToken }); | ||
const results = res.body; | ||
@@ -62,5 +62,5 @@ if (!results) { | ||
} | ||
requestJobStatus(id) { | ||
requestJobStatus(jobId) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const rsp = yield this.batchEventsImpl.getBatchEventsImportStatus(id); | ||
const rsp = yield this.batchEventsImpl.getBatchEventsImportStatus({ jobId }); | ||
const body = rsp.body; | ||
@@ -75,5 +75,5 @@ if (!body) { | ||
//////////////////////////////////// | ||
// Exported User Interface | ||
// Exported Event Interface | ||
//////////////////////////////////// | ||
class Events { | ||
class EventsImpl { | ||
constructor(opts) { | ||
@@ -83,12 +83,15 @@ this.opts = opts; | ||
} | ||
create(body, options) { | ||
withOptions(opts) { | ||
return new EventsImpl(Object.assign(Object.assign({}, this.opts), opts)); | ||
} | ||
create(...request) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.eventsImpl.createEvents(body, options); | ||
return this.eventsImpl.createEvent(...request); | ||
}); | ||
} | ||
batchCreate(request = { requests: [] }, jobOptions, includeSchema) { | ||
return new BatchEventsJob(this.opts, request, jobOptions, includeSchema); | ||
batchCreate(request, jobOptions) { | ||
return new BatchEventsJobImpl(this.opts, request.body, jobOptions, request.includeSchema); | ||
} | ||
} | ||
exports.Events = Events; | ||
exports.EventsImpl = EventsImpl; | ||
//# sourceMappingURL=events.js.map |
@@ -1,13 +0,14 @@ | ||
import { IBatchEventsApi, IEventsApi } from './events'; | ||
import { FullStoryOptions } from './http'; | ||
import { IBatchUsersApi, IUsersApi } from './users'; | ||
import { Events } from './events'; | ||
import { FullStoryOptions, WithOptions } from './http'; | ||
import { Users } from './users'; | ||
export interface FullStoryClient { | ||
readonly users: IBatchUsersApi & IUsersApi; | ||
readonly events: IBatchEventsApi & IEventsApi; | ||
readonly users: Users & WithOptions<Users>; | ||
readonly events: Events & WithOptions<Events>; | ||
} | ||
export declare class FullStoryImpl implements FullStoryClient { | ||
private opts; | ||
readonly users: IBatchUsersApi & IUsersApi; | ||
readonly events: IBatchEventsApi & IEventsApi; | ||
readonly users: Users & WithOptions<Users>; | ||
readonly events: Events & WithOptions<Events>; | ||
constructor(opts: FullStoryOptions); | ||
} | ||
export declare function init(opts: FullStoryOptions): FullStoryClient; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.FullStoryImpl = void 0; | ||
exports.init = exports.FullStoryImpl = void 0; | ||
const invalidArgument_1 = require("./errors/invalidArgument"); | ||
const events_1 = require("./events"); | ||
@@ -9,7 +10,15 @@ const users_1 = require("./users"); | ||
this.opts = opts; | ||
this.users = new users_1.Users(opts); | ||
this.events = new events_1.Events(opts); | ||
this.users = new users_1.UsersImpl(opts); | ||
this.events = new events_1.EventsImpl(opts); | ||
} | ||
} | ||
exports.FullStoryImpl = FullStoryImpl; | ||
function init(opts) { | ||
if (!opts.apiKey) { | ||
throw new invalidArgument_1.FSInvalidArgumentError('The apiKey is required in opts.'); | ||
} | ||
const apiKey = opts.apiKey.indexOf(' ') < 0 ? `Basic ${opts.apiKey}` : opts.apiKey; | ||
return new FullStoryImpl(Object.assign(Object.assign({}, opts), { apiKey })); | ||
} | ||
exports.init = init; | ||
//# sourceMappingURL=fullstory.js.map |
@@ -46,3 +46,2 @@ "use strict"; | ||
const integrationSourceKey = 'Integration-Source'; | ||
const idempotencyKey = 'Idempotency-Key'; | ||
// TODO(sabrina): separate out the error handling stuff out from the http client | ||
@@ -77,6 +76,2 @@ class FSHttpClientImpl { | ||
} | ||
if (!req.hasHeader(idempotencyKey) && (fsReq === null || fsReq === void 0 ? void 0 : fsReq.idempotencyKey)) { | ||
// only allow per-request idempotency key | ||
req.setHeader(idempotencyKey, fsReq.idempotencyKey); | ||
} | ||
req.once('socket', (socket) => { | ||
@@ -83,0 +78,0 @@ if (socket.connecting) { |
@@ -7,6 +7,2 @@ /** | ||
readonly integrationSource?: string; | ||
/** An optional per-request Idempotency-Key string to be passed as a header | ||
* to kae non-idempotent HTTP methods such as POST or PATCH idempotent. | ||
* Please see FullStory's developer doc for methods available and more information */ | ||
readonly idempotencyKey?: string; | ||
} | ||
@@ -19,1 +15,4 @@ /** | ||
} | ||
export interface WithOptions<T> { | ||
withOptions(opts: Partial<FullStoryOptions>): T; | ||
} |
@@ -1,11 +0,5 @@ | ||
import { FullStoryClient } from './fullstory'; | ||
import { FullStoryOptions } from './http'; | ||
export declare function init(opts: FullStoryOptions): FullStoryClient; | ||
export { BatchJobOptions } from './batch'; | ||
export { FSError, FSErrorName, isFSError } from './errors'; | ||
export { IBatchEventsJob as BatchEventsJob, IEvents as Events } from './events'; | ||
export { FullStoryClient } from './fullstory'; | ||
export { FullStoryOptions } from './http'; | ||
export { IBatchUsersJob as BatchUsersJob, IUsers as Users } from './users'; | ||
export * from './events'; | ||
export * from './fullstory'; | ||
export * from './users'; | ||
export * from './api/index'; | ||
export * from './model/index'; |
@@ -17,18 +17,7 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isFSError = exports.FSErrorName = exports.init = void 0; | ||
const invalidArgument_1 = require("./errors/invalidArgument"); | ||
const fullstory_1 = require("./fullstory"); | ||
function init(opts) { | ||
if (!opts.apiKey) { | ||
throw new invalidArgument_1.FSInvalidArgumentError('The apiKey is required in opts.'); | ||
} | ||
const apiKey = opts.apiKey.indexOf(' ') < 0 ? `Basic ${opts.apiKey}` : opts.apiKey; | ||
return new fullstory_1.FullStoryImpl(Object.assign(Object.assign({}, opts), { apiKey })); | ||
} | ||
exports.init = init; | ||
var errors_1 = require("./errors"); | ||
Object.defineProperty(exports, "FSErrorName", { enumerable: true, get: function () { return errors_1.FSErrorName; } }); | ||
Object.defineProperty(exports, "isFSError", { enumerable: true, get: function () { return errors_1.isFSError; } }); | ||
__exportStar(require("./events"), exports); | ||
__exportStar(require("./fullstory"), exports); | ||
__exportStar(require("./users"), exports); | ||
__exportStar(require("./api/index"), exports); | ||
__exportStar(require("./model/index"), exports); | ||
//# sourceMappingURL=index.js.map |
@@ -10,3 +10,3 @@ /** | ||
export * from './events/CreateBatchEventsImportJobResponse'; | ||
export * from './events/CreateEventsRequest'; | ||
export * from './events/CreateEventRequest'; | ||
export * from './events/DeviceContext'; | ||
@@ -13,0 +13,0 @@ export * from './apierror/ErrorResponse'; |
@@ -28,3 +28,3 @@ "use strict"; | ||
__exportStar(require("./events/CreateBatchEventsImportJobResponse"), exports); | ||
__exportStar(require("./events/CreateEventsRequest"), exports); | ||
__exportStar(require("./events/CreateEventRequest"), exports); | ||
__exportStar(require("./events/DeviceContext"), exports); | ||
@@ -31,0 +31,0 @@ __exportStar(require("./apierror/ErrorResponse"), exports); |
@@ -22,3 +22,3 @@ /** | ||
/** | ||
* Optional. The event's timestamp, defaults to current time. | ||
* Optional. The event's timestamp represented in ISO 8601 format. If not provided, the current FullStory server time will be used. | ||
*/ | ||
@@ -25,0 +25,0 @@ 'timestamp'?: string; |
@@ -6,3 +6,3 @@ /** | ||
*/ | ||
import { CreateEventsRequest } from '../events/CreateEventsRequest'; | ||
import { CreateEventRequest } from '../events/CreateEventRequest'; | ||
import { SharedData } from '../events/SharedData'; | ||
@@ -16,4 +16,4 @@ /** | ||
*/ | ||
'requests': Array<CreateEventsRequest>; | ||
'requests': Array<CreateEventRequest>; | ||
'shared'?: SharedData; | ||
} |
@@ -6,3 +6,3 @@ /** | ||
*/ | ||
import { CreateEventsRequest } from '../events/CreateEventsRequest'; | ||
import { CreateEventRequest } from '../events/CreateEventRequest'; | ||
import { SharedData } from '../events/SharedData'; | ||
@@ -21,4 +21,4 @@ /** | ||
'code'?: string; | ||
'event'?: CreateEventsRequest; | ||
'event'?: CreateEventRequest; | ||
'shared'?: SharedData; | ||
} |
@@ -19,5 +19,5 @@ /** | ||
/** | ||
* The FullStory assigned user ID. | ||
* The FullStory-assigned user ID. This value is returned in a `POST /v2/users` (create user) response. | ||
*/ | ||
'id'?: string; | ||
} |
import { UsersApi as FSUsersApi } from './api/index'; | ||
import { BatchUserImportRequest, BatchUserImportResponse, CreateBatchUserImportJobRequest, CreateBatchUserImportJobResponse, CreateUserRequest, CreateUserResponse, FailedUserImport, GetBatchEventsImportErrorsResponse, GetBatchUserImportsResponse, GetUserResponse, JobStatusResponse, ListUsersResponse, UpdateUserRequest, UpdateUserResponse } from './model/index'; | ||
import { BatchJob, BatchJobOptions, IBatchJob, IBatchRequester } from './batch'; | ||
import { FSRequestOptions, FSResponse, FullStoryOptions } from './http'; | ||
import { BatchUserImportRequest, BatchUserImportResponse, CreateBatchUserImportJobRequest, CreateBatchUserImportJobResponse, CreateUserResponse, FailedUserImport, GetBatchEventsImportErrorsResponse, GetBatchUserImportsResponse, GetUserResponse, JobStatusResponse, ListUsersResponse, UpdateUserResponse } from './model/index'; | ||
import { BatchJob, BatchJobOptions, BatchRequester } from './batch'; | ||
import { FSResponse, FullStoryOptions, WithOptions } from './http'; | ||
/** | ||
* @interface IUsersApi - single CRUD operations for a user. | ||
* @interface UsersApi - single CRUD operations for a user. | ||
*/ | ||
export interface IUsersApi { | ||
interface UsersApi { | ||
get(...req: Parameters<typeof FSUsersApi.prototype.getUser>): Promise<FSResponse<GetUserResponse>>; | ||
create(...req: Parameters<typeof FSUsersApi.prototype.createUser>): Promise<FSResponse<CreateUserResponse>>; | ||
list(...req: Parameters<typeof FSUsersApi.prototype.listUsers>): Promise<FSResponse<ListUsersResponse>>; | ||
delete(id?: string, uid?: string, options?: FSRequestOptions): Promise<FSResponse<void>>; | ||
delete(request: { | ||
id?: string; | ||
uid?: string; | ||
}): Promise<FSResponse<void>>; | ||
update(...req: Parameters<typeof FSUsersApi.prototype.updateUser>): Promise<FSResponse<UpdateUserResponse>>; | ||
} | ||
/** | ||
* @interface IBatchUsersApi - batch import users. | ||
* @interface BatchUsersApi - batch import users. | ||
*/ | ||
export interface IBatchUsersApi { | ||
batchCreate(request?: CreateBatchUserImportJobRequest, jobOptions?: BatchJobOptions): BatchUsersJob; | ||
interface BatchUsersApi { | ||
batchCreate(request: { | ||
body: CreateBatchUserImportJobRequest; | ||
includeSchema?: boolean; | ||
}, jobOptions?: BatchJobOptions): BatchUsersJob; | ||
} | ||
/** | ||
* @interface IBatchUsersJob - a job for batch import users, providing job management and callbacks. | ||
* @interface BatchUsersJob - a job for batch import users, providing job management and callbacks. | ||
*/ | ||
export type IBatchUsersJob = IBatchJob<CreateBatchUserImportJobRequest, BatchUserImportRequest, BatchUserImportResponse, FailedUserImport>; | ||
export type BatchUsersJob = BatchJob<CreateBatchUserImportJobRequest, BatchUserImportRequest, BatchUserImportResponse, FailedUserImport>; | ||
/** | ||
* @interface IUsers - CRUD operations or batch import users. | ||
* @interface Users - CRUD operations or batch import users. | ||
*/ | ||
export type IUsers = IBatchUsersApi & IUsersApi; | ||
declare class BatchUsersJob extends BatchJob<CreateBatchUserImportJobRequest, BatchUserImportRequest, CreateBatchUserImportJobResponse, JobStatusResponse, BatchUserImportResponse, FailedUserImport> { | ||
constructor(fsOpts: FullStoryOptions, request: CreateBatchUserImportJobRequest, opts?: BatchJobOptions, includeSchema?: boolean); | ||
} | ||
export type IBatchUsersRequester = IBatchRequester<CreateBatchUserImportJobRequest, CreateBatchUserImportJobResponse, JobStatusResponse, GetBatchUserImportsResponse, GetBatchEventsImportErrorsResponse>; | ||
export declare class Users implements IUsers { | ||
export type Users = BatchUsersApi & UsersApi; | ||
export type BatchUsersRequester = BatchRequester<CreateBatchUserImportJobRequest, CreateBatchUserImportJobResponse, JobStatusResponse, GetBatchUserImportsResponse, GetBatchEventsImportErrorsResponse>; | ||
export declare class UsersImpl implements Users, WithOptions<Users> { | ||
private opts; | ||
protected readonly usersImpl: FSUsersApi; | ||
constructor(opts: FullStoryOptions); | ||
get(id: string, includeSchema?: boolean, options?: FSRequestOptions | undefined): Promise<FSResponse<GetUserResponse>>; | ||
create(body: CreateUserRequest, options?: FSRequestOptions | undefined): Promise<FSResponse<CreateUserResponse>>; | ||
list(uid?: string | undefined, email?: string | undefined, displayName?: string | undefined, isIdentified?: boolean | undefined, pageToken?: string | undefined, includeSchema?: boolean, options?: FSRequestOptions | undefined): Promise<FSResponse<ListUsersResponse>>; | ||
delete(id?: string, uid?: string, options?: FSRequestOptions | undefined): Promise<FSResponse<void>>; | ||
update(id: string, body: UpdateUserRequest, options?: FSRequestOptions | undefined): Promise<FSResponse<UpdateUserResponse>>; | ||
batchCreate(request?: CreateBatchUserImportJobRequest, jobOptions?: BatchJobOptions, includeSchema?: boolean): BatchUsersJob; | ||
withOptions(opts: Partial<FullStoryOptions>): Users; | ||
get(...request: Parameters<typeof FSUsersApi.prototype.getUser>): Promise<FSResponse<GetUserResponse>>; | ||
create(...request: Parameters<typeof FSUsersApi.prototype.createUser>): Promise<FSResponse<CreateUserResponse>>; | ||
list(...request: Parameters<typeof FSUsersApi.prototype.listUsers>): Promise<FSResponse<ListUsersResponse>>; | ||
delete(request: { | ||
id?: string; | ||
uid?: string; | ||
}): Promise<FSResponse<void>>; | ||
update(...request: Parameters<typeof FSUsersApi.prototype.updateUser>): Promise<FSResponse<UpdateUserResponse>>; | ||
batchCreate(request: { | ||
body: CreateBatchUserImportJobRequest; | ||
includeSchema?: boolean; | ||
}, jobOptions?: BatchJobOptions): BatchUsersJob; | ||
} | ||
export {}; |
@@ -12,12 +12,12 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.Users = void 0; | ||
exports.UsersImpl = void 0; | ||
const index_1 = require("./api/index"); | ||
const batch_1 = require("./batch"); | ||
const invalidArgument_1 = require("./errors/invalidArgument"); | ||
class BatchUsersJob extends batch_1.BatchJob { | ||
class BatchUsersJobImpl extends batch_1.BatchJobImpl { | ||
constructor(fsOpts, request, opts = {}, includeSchema = false) { | ||
super(request, new BatchUsersRequester(fsOpts, includeSchema), opts); | ||
super(request, new BatchUsersRequesterImpl(fsOpts, includeSchema), opts); | ||
} | ||
} | ||
class BatchUsersRequester { | ||
class BatchUsersRequesterImpl { | ||
constructor(fsOpts, includeSchema) { | ||
@@ -28,6 +28,6 @@ this.fsOpts = fsOpts; | ||
} | ||
requestCreateJob(req) { | ||
requestCreateJob(request) { | ||
var _a; | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const rsp = yield this.batchUsersImpl.createBatchUserImportJob(req, this.fsOpts); | ||
const rsp = yield this.batchUsersImpl.createBatchUserImportJob(request); | ||
// make sure job metadata and id exist | ||
@@ -41,5 +41,5 @@ const job = rsp.body; | ||
} | ||
requestImports(id, pageToken) { | ||
requestImports(jobId, pageToken) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const res = yield this.batchUsersImpl.getBatchUserImports(id, pageToken, this.includeSchema, this.fsOpts); | ||
const res = yield this.batchUsersImpl.getBatchUserImports({ jobId, pageToken, includeSchema: this.includeSchema }); | ||
const results = res.body; | ||
@@ -52,5 +52,5 @@ if (!results) { | ||
} | ||
requestImportErrors(id, pageToken) { | ||
requestImportErrors(jobId, pageToken) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const res = yield this.batchUsersImpl.getBatchUserImportErrors(id, pageToken, this.fsOpts); | ||
const res = yield this.batchUsersImpl.getBatchUserImportErrors({ jobId, pageToken }); | ||
const results = res.body; | ||
@@ -63,5 +63,5 @@ if (!results) { | ||
} | ||
requestJobStatus(id) { | ||
requestJobStatus(jobId) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const rsp = yield this.batchUsersImpl.getBatchUserImportStatus(id, this.fsOpts); | ||
const rsp = yield this.batchUsersImpl.getBatchUserImportStatus({ jobId }); | ||
const body = rsp.body; | ||
@@ -78,3 +78,3 @@ if (!body) { | ||
//////////////////////////////////// | ||
class Users { | ||
class UsersImpl { | ||
constructor(opts) { | ||
@@ -84,25 +84,29 @@ this.opts = opts; | ||
} | ||
withOptions(opts) { | ||
return new UsersImpl(Object.assign(Object.assign({}, this.opts), opts)); | ||
} | ||
//TODO(sabrina): move options or make query param a typed object, to make call signature backward compatible when adding query params | ||
get(id, includeSchema, options) { | ||
get(...request) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.usersImpl.getUser(id, includeSchema, options); | ||
return this.usersImpl.getUser(...request); | ||
}); | ||
} | ||
create(body, options) { | ||
create(...request) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.usersImpl.createUser(body, options); | ||
return this.usersImpl.createUser(...request); | ||
}); | ||
} | ||
list(uid, email, displayName, isIdentified, pageToken, includeSchema, options) { | ||
list(...request) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.usersImpl.listUsers(uid, email, displayName, isIdentified, pageToken, includeSchema, options); | ||
return this.usersImpl.listUsers(...request); | ||
}); | ||
} | ||
delete(id, uid, options) { | ||
delete(request) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const { id, uid } = request; | ||
if (id && !uid) { | ||
return this.usersImpl.deleteUser(id, options); | ||
return this.usersImpl.deleteUser({ id }); | ||
} | ||
if (uid && !id) { | ||
return this.usersImpl.deleteUserByUid(uid, options); | ||
return this.usersImpl.deleteUserByUid({ uid }); | ||
} | ||
@@ -112,12 +116,12 @@ throw new invalidArgument_1.FSInvalidArgumentError('At least one and only one of id or uid is required.'); | ||
} | ||
update(id, body, options) { | ||
update(...request) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return this.usersImpl.updateUser(id, body, options); | ||
return this.usersImpl.updateUser(...request); | ||
}); | ||
} | ||
batchCreate(request = { requests: [] }, jobOptions, includeSchema) { | ||
return new BatchUsersJob(this.opts, request, jobOptions, includeSchema); | ||
batchCreate(request, jobOptions) { | ||
return new BatchUsersJobImpl(this.opts, request.body, jobOptions, request.includeSchema); | ||
} | ||
} | ||
exports.Users = Users; | ||
exports.UsersImpl = UsersImpl; | ||
//# sourceMappingURL=users.js.map |
{ | ||
"name": "@fullstory/server-api-client", | ||
"version": "1.0.0-beta.6", | ||
"version": "1.0.0-beta.7", | ||
"description": "The official FullStory server API client SDK for NodeJS.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
169
README.md
@@ -50,11 +50,16 @@ # FullStory NodeJS Client SDK | ||
const createResponse = await users.create({ | ||
uid: 'user123', | ||
display_name: 'Display Name', | ||
email: 'user123@example.com', | ||
properties: { | ||
pricing_plan: 'paid', | ||
popup_help: true, | ||
total_spent: 14.55, | ||
}, | ||
}); | ||
body: { | ||
uid: 'user123', | ||
display_name: 'Display Name', | ||
email: 'user123@example.com', | ||
properties: { | ||
pricing_plan: 'paid', | ||
popup_help: true, | ||
total_spent: 14.55, | ||
}, | ||
}, | ||
// optionally provide an idempotencyKey to make | ||
// the request idempotent | ||
idempotencyKey: "YOUR_KEY" | ||
}); | ||
``` | ||
@@ -65,4 +70,7 @@ | ||
```ts | ||
// get user by the fullstory assigned id | ||
const getResponse = await users.get('123456'); | ||
// get user by the FullStory assigned id | ||
const getResponse = await users.get({ | ||
id: '123456', | ||
includeSchema: true | ||
}); | ||
``` | ||
@@ -73,4 +81,4 @@ | ||
```ts | ||
// get user by the application-specific uid | ||
const listResponse = await users.list('user123'); | ||
// get all users by the application-specified uid | ||
const listResponse = await users.list({ uid: 'user123' }); | ||
``` | ||
@@ -82,4 +90,6 @@ | ||
// update user by the fullstory assigned id | ||
const updatedResponse = await users.update('123456', | ||
{ display_name: 'New Display Name' }); | ||
const updatedResponse = await users.update({ | ||
id: '123456', | ||
body: { display_name: 'New Display Name' } | ||
}); | ||
``` | ||
@@ -90,4 +100,7 @@ | ||
```ts | ||
// delete user by the fullstory assigned id | ||
await users.delete('123456'); | ||
// delete user by the FullStory assigned id | ||
await users.delete({ id: '123456' }); | ||
// delete user by the application-specified uid | ||
await users.delete({ uid: 'xyz123' }); | ||
``` | ||
@@ -107,10 +120,8 @@ | ||
const createResponse = await events.create({ | ||
user: { | ||
id: '123456', | ||
}, | ||
body: { | ||
session: { | ||
use_most_recent: true, | ||
id: '123:456', | ||
}, | ||
context: { | ||
web: { | ||
browser: { | ||
url: 'https://www.example.com', | ||
@@ -120,4 +131,4 @@ initial_referrer: 'https://www.referrer.com', | ||
location: { | ||
latitude: 33.80177165865808, | ||
longitude: -84.39222238465959, | ||
latitude: 33.748997, | ||
longitude: -84.387985, | ||
}, | ||
@@ -132,4 +143,5 @@ }, | ||
title: 'Account locked out', | ||
}, | ||
}); | ||
} | ||
} | ||
}); | ||
``` | ||
@@ -139,4 +151,6 @@ | ||
- [Create a batch users import job](https://developer.fullstory.com/server/v2/users/create-batch-user-import-job/) | ||
- Creating import job objects allows clients to batch import items such as users or events. First create a job object: | ||
- [Create a batch users import job](https://developer.fullstory.com/server/v2/users/create-batch-user-import-job/) | ||
```ts | ||
@@ -165,3 +179,8 @@ // array of users to be imported | ||
// create a job object | ||
const job = users.batchCreate({ requests }); | ||
const job = users.batchCreate({ | ||
body: { requests }, | ||
// include schema in the server response | ||
// when retrieving imported users | ||
includeSchema: true, | ||
}); | ||
@@ -202,3 +221,6 @@ // you can add more requests before executing | ||
// create a job object | ||
const job = events.batchCreate({ requests }); | ||
const job = events.batchCreate({ | ||
body: { requests } | ||
includeSchema: true, | ||
}); | ||
@@ -221,38 +243,27 @@ // you can add more requests before executing | ||
- Batch Import Options | ||
- Batch import job lifecycle. | ||
Optional events listeners can be added for the batch import job. The batch import job will manage the following lifecycle: | ||
Each job can be created with different options: | ||
```ts | ||
const options = { | ||
// poll job status every one minute | ||
pollInterval: 60000, | ||
// retry 5 times on API errors before aborting | ||
maxRetry: 5, | ||
} | ||
``` | ||
- Adding listeners for a batch import job and executing the job | ||
1. When the job's execute method is called, an API request is made to the server to create the import the job: | ||
1. When the job's `execute` method is called, an API request is made to the server to create the import the job: | ||
- [users](https://developer.fullstory.com/server/v2/users/create-batch-user-import-job/) | ||
- [events](https://developer.fullstory.com/server/v2/events/create-batch-events-import-job/) | ||
2. Once the job is created successfully, `created` listeners are invoked with the job's information. | ||
2. Once the job is created successfully, `created` listeners are invoked with the job's metadata. | ||
3. The job then starts to poll on the server to get the latest job status at an interval: | ||
3. The job then starts to poll on the server API to get the latest job status at an interval: | ||
- [users](https://developer.fullstory.com/server/v2/users/get-batch-user-import-status/) | ||
- [events](https://developer.fullstory.com/server/v2/events/get-batch-events-import-status/) | ||
Each successful poll will result in `processing` listeners being invoked. | ||
Each successful poll will invoke the `processing` listeners. | ||
4. When the job status reaches a `done` state (`COMPLETED` or `FAILED`), we automatically retrieve the results, by calling get batch imports: | ||
4. When the job status reaches a `done` state (either `COMPLETED` or `FAILED`), the job automatically starts to retrieve the imported items, by calling the "get batch imports" APIs: | ||
- [users](https://developer.fullstory.com/server/v2/users/get-batch-user-imports/) | ||
- [events](https://developer.fullstory.com/server/v2/events/get-batch-events-imports/) | ||
or get batch errors: | ||
or "get batch errors" APIs if there were errors: | ||
- [users](https://developer.fullstory.com/server/v2/users/get-batch-user-import-errors/) | ||
- [events](https://developer.fullstory.com/server/v2/events/get-batch-events-import-errors/) | ||
And the `done` listeners are invoked with the results. | ||
And lastly the `done` listeners are invoked with the results. | ||
@@ -291,7 +302,12 @@ 5. The `error` listeners are called anytime an error is encountered, may be called more than once. | ||
- Restart a job | ||
If a job had been successfully created, but aborted for some reason, you may restart the polling of the same job by calling `restart`. | ||
```ts | ||
// restart failed job | ||
const job = events.batchCreate({ requests }); | ||
const job = events.batchCreate({ | ||
body: { requests } | ||
}); | ||
job.on('abort', () => { | ||
// if should restart | ||
// logic to determine if should restart | ||
baseJob.restart(); | ||
@@ -304,3 +320,52 @@ }); | ||
``` | ||
#### Request Options | ||
If there is a need to override the options from the initially provided options during `init`, the `withOptions` method can be used to apply per-request options to your request. | ||
Using `withOptions` will **not** modify the options initially provided, but returns a new instance. | ||
```ts | ||
const { events } = init({ apiKey: '<YOUR_API_KEY>' }); | ||
const options: FSRequestOptions = { | ||
// integrationSource is generally intended for FullStory | ||
// or FullStory partners while building integrations. | ||
//Generally it should be left empty. | ||
integrationSource: 'SPECIAL_INTEGRATION_SOURCE' | ||
}; | ||
// to apply the options to the create event API | ||
events.withOptions(options).create(...); | ||
// to apply the options to the batch create events API | ||
events.withOptions(options).batchCreate(...); | ||
// the original options will not be modified | ||
// below request will not use the SPECIAL_INTEGRATION_SOURCE | ||
events.create(...); | ||
``` | ||
#### Batch Job Options | ||
- Batch Import Options | ||
Each job can be created with different options. Additional request options can also be provided when creating the job, the request options will be applied to all server API requests such as requests to check for job status. | ||
```ts | ||
const options: BatchJobOptions = { | ||
// poll job status every one minute | ||
pollInterval: 60000, | ||
// retry 5 times on API errors before aborting | ||
maxRetry: 5, | ||
} | ||
const createResponse = await users.batchCreate( | ||
{ | ||
body: { requests: [{ uid: 'user123' }] }, | ||
includeSchema: true, | ||
}, | ||
options | ||
); | ||
``` | ||
### Multiple batch import jobs | ||
@@ -307,0 +372,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
218268
3604
409
199