@deepgram/sdk 1.0.2 → 1.2.1
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/CHANGELOG.md +53 -1
- package/README.md +39 -791
- package/dist/helpers/index.d.ts +1 -0
- package/dist/helpers/index.js +14 -0
- package/dist/helpers/index.js.map +1 -0
- package/dist/helpers/secondsToTimestamp.d.ts +1 -0
- package/dist/helpers/secondsToTimestamp.js +8 -0
- package/dist/helpers/secondsToTimestamp.js.map +1 -0
- package/dist/httpRequest.d.ts +2 -1
- package/dist/httpRequest.js +22 -14
- package/dist/httpRequest.js.map +1 -1
- package/dist/keys.d.ts +3 -2
- package/dist/keys.js +19 -5
- package/dist/keys.js.map +1 -1
- package/dist/projects.js +3 -3
- package/dist/projects.js.map +1 -1
- package/dist/transcription/index.js +1 -1
- package/dist/transcription/index.js.map +1 -1
- package/dist/transcription/liveTranscription.js +2 -2
- package/dist/transcription/liveTranscription.js.map +1 -1
- package/dist/transcription/preRecordedTranscription.js +35 -10
- package/dist/transcription/preRecordedTranscription.js.map +1 -1
- package/dist/types/createKeyOptions.d.ts +13 -0
- package/dist/types/createKeyOptions.js +3 -0
- package/dist/types/createKeyOptions.js.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +1 -1
- package/dist/types/prerecordedTranscriptionResponse.d.ts +16 -2
- package/dist/types/prerecordedTranscriptionResponse.js +48 -0
- package/dist/types/prerecordedTranscriptionResponse.js.map +1 -1
- package/dist/types/transcriptionSource.d.ts +6 -1
- package/dist/usage.js +4 -4
- package/dist/usage.js.map +1 -1
- package/package.json +18 -18
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./secondsToTimestamp";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./secondsToTimestamp"), exports);
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,uDAAqC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function secondsToTimestamp(seconds: number): string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.secondsToTimestamp = void 0;
|
|
4
|
+
function secondsToTimestamp(seconds) {
|
|
5
|
+
return new Date(seconds * 1000).toISOString().substr(11, 12);
|
|
6
|
+
}
|
|
7
|
+
exports.secondsToTimestamp = secondsToTimestamp;
|
|
8
|
+
//# sourceMappingURL=secondsToTimestamp.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secondsToTimestamp.js","sourceRoot":"","sources":["../../src/helpers/secondsToTimestamp.ts"],"names":[],"mappings":";;;AAAA,SAAgB,kBAAkB,CAAC,OAAe;IAChD,OAAO,IAAI,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,CAAC,WAAW,EAAE,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAC/D,CAAC;AAFD,gDAEC"}
|
package/dist/httpRequest.d.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
|
|
2
|
+
import { ReadStream } from "fs";
|
|
3
|
+
export declare function _request<T>(method: string, api_key: string, apiUrl: string, path: string, payload?: string | Buffer | ReadStream, options?: Object): Promise<T>;
|
package/dist/httpRequest.js
CHANGED
|
@@ -12,25 +12,22 @@ var __assign = (this && this.__assign) || function () {
|
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
14
|
exports._request = void 0;
|
|
15
|
+
var fs_1 = require("fs");
|
|
15
16
|
var https_1 = require("https");
|
|
16
17
|
var userAgent_1 = require("./userAgent");
|
|
17
18
|
var _requestOptions = function (api_key, apiUrl, path, method, payload,
|
|
18
19
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
19
20
|
override_options) {
|
|
21
|
+
var additionalHeaders = {};
|
|
22
|
+
if (payload && !(payload instanceof fs_1.ReadStream)) {
|
|
23
|
+
additionalHeaders["Content-Length"] = Buffer.byteLength(payload);
|
|
24
|
+
}
|
|
20
25
|
var options = {
|
|
21
26
|
host: apiUrl,
|
|
22
27
|
path: path,
|
|
23
28
|
method: method,
|
|
24
|
-
headers: {
|
|
25
|
-
"User-Agent": userAgent_1.userAgent(),
|
|
26
|
-
"Content-Type": "application/json",
|
|
27
|
-
Authorization: "token " + api_key,
|
|
28
|
-
"Content-Length": payload ? Buffer.byteLength(payload) : undefined,
|
|
29
|
-
},
|
|
29
|
+
headers: __assign({ "User-Agent": (0, userAgent_1.userAgent)(), "Content-Type": "application/json", Authorization: "token " + api_key }, additionalHeaders),
|
|
30
30
|
};
|
|
31
|
-
if (payload === undefined) {
|
|
32
|
-
delete options.headers["Content-Length"];
|
|
33
|
-
}
|
|
34
31
|
var headers = options.headers;
|
|
35
32
|
if (override_options && override_options.headers) {
|
|
36
33
|
headers = __assign(__assign({}, headers), override_options.headers);
|
|
@@ -43,7 +40,7 @@ options) {
|
|
|
43
40
|
var requestOptions = _requestOptions(api_key, apiUrl, path, method, payload, options);
|
|
44
41
|
return new Promise(function (resolve, reject) {
|
|
45
42
|
try {
|
|
46
|
-
var
|
|
43
|
+
var httpRequest_1 = (0, https_1.request)(requestOptions, function (dgRes) {
|
|
47
44
|
var dgResContent = "";
|
|
48
45
|
dgRes.on("data", function (chunk) {
|
|
49
46
|
dgResContent += chunk;
|
|
@@ -51,7 +48,6 @@ options) {
|
|
|
51
48
|
dgRes.on("end", function () {
|
|
52
49
|
var dgResponse;
|
|
53
50
|
try {
|
|
54
|
-
console.log("content: " + dgResContent);
|
|
55
51
|
dgResponse = JSON.parse(dgResContent);
|
|
56
52
|
}
|
|
57
53
|
catch (err) {
|
|
@@ -66,13 +62,25 @@ options) {
|
|
|
66
62
|
reject("DG: " + err);
|
|
67
63
|
});
|
|
68
64
|
});
|
|
69
|
-
|
|
65
|
+
httpRequest_1.on("error", function (err) {
|
|
70
66
|
reject("DG: " + err);
|
|
71
67
|
});
|
|
72
68
|
if (payload) {
|
|
73
|
-
|
|
69
|
+
if (payload instanceof fs_1.ReadStream) {
|
|
70
|
+
payload.pipe(httpRequest_1);
|
|
71
|
+
payload.on("finish", function () {
|
|
72
|
+
httpRequest_1.end();
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
// It's a buffer
|
|
77
|
+
httpRequest_1.write(payload);
|
|
78
|
+
httpRequest_1.end();
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
httpRequest_1.end();
|
|
74
83
|
}
|
|
75
|
-
httpRequest.end();
|
|
76
84
|
}
|
|
77
85
|
catch (err) {
|
|
78
86
|
reject("DG: " + err);
|
package/dist/httpRequest.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"httpRequest.js","sourceRoot":"","sources":["../src/httpRequest.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,+BAAgD;AAChD,yCAAwC;AAExC,IAAM,eAAe,GA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BACnB;aACF;iBAAM;gBACL,aAAW,CAAC,GAAG,EAAE,CAAC;aACnB;SACF;QAAC,OAAO,GAAG,EAAE;YACZ,MAAM,CAAC,SAAO,GAAK,CAAC,CAAC;SACtB;IACH,CAAC,CAAC,CAAC;AACL,CAAC;AAnED,4BAmEC"}
|
package/dist/keys.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { KeyResponse, Key } from "./types";
|
|
1
|
+
import { CreateKeyOptions, KeyResponse, Key } from "./types";
|
|
2
2
|
export declare class Keys {
|
|
3
3
|
private _credentials;
|
|
4
4
|
private _apiUrl;
|
|
@@ -20,8 +20,9 @@ export declare class Keys {
|
|
|
20
20
|
* @param projectId Unique identifier of the project to create an API key under
|
|
21
21
|
* @param comment Comment to describe the key
|
|
22
22
|
* @param scopes Permission scopes associated with the API key
|
|
23
|
+
* @param options Optional options used when creating API keys
|
|
23
24
|
*/
|
|
24
|
-
create(projectId: string, comment: string, scopes: Array<string
|
|
25
|
+
create(projectId: string, comment: string, scopes: Array<string>, options?: CreateKeyOptions): Promise<Key>;
|
|
25
26
|
/**
|
|
26
27
|
* Deletes an API key
|
|
27
28
|
* @param projectId Unique identifier of the project to create an API key under
|
package/dist/keys.js
CHANGED
|
@@ -51,7 +51,7 @@ var Keys = /** @class */ (function () {
|
|
|
51
51
|
Keys.prototype.list = function (projectId) {
|
|
52
52
|
return __awaiter(this, void 0, void 0, function () {
|
|
53
53
|
return __generator(this, function (_a) {
|
|
54
|
-
return [2 /*return*/, httpRequest_1._request("GET", this._credentials, this._apiUrl, this.apiPath + "/" + projectId + "/keys")];
|
|
54
|
+
return [2 /*return*/, (0, httpRequest_1._request)("GET", this._credentials, this._apiUrl, this.apiPath + "/" + projectId + "/keys")];
|
|
55
55
|
});
|
|
56
56
|
});
|
|
57
57
|
};
|
|
@@ -63,7 +63,7 @@ var Keys = /** @class */ (function () {
|
|
|
63
63
|
Keys.prototype.get = function (projectId, keyId) {
|
|
64
64
|
return __awaiter(this, void 0, void 0, function () {
|
|
65
65
|
return __generator(this, function (_a) {
|
|
66
|
-
return [2 /*return*/, httpRequest_1._request("GET", this._credentials, this._apiUrl, this.apiPath + "/" + projectId + "/keys/" + keyId)];
|
|
66
|
+
return [2 /*return*/, (0, httpRequest_1._request)("GET", this._credentials, this._apiUrl, this.apiPath + "/" + projectId + "/keys/" + keyId)];
|
|
67
67
|
});
|
|
68
68
|
});
|
|
69
69
|
};
|
|
@@ -72,11 +72,25 @@ var Keys = /** @class */ (function () {
|
|
|
72
72
|
* @param projectId Unique identifier of the project to create an API key under
|
|
73
73
|
* @param comment Comment to describe the key
|
|
74
74
|
* @param scopes Permission scopes associated with the API key
|
|
75
|
+
* @param options Optional options used when creating API keys
|
|
75
76
|
*/
|
|
76
|
-
Keys.prototype.create = function (projectId, comment, scopes) {
|
|
77
|
+
Keys.prototype.create = function (projectId, comment, scopes, options) {
|
|
77
78
|
return __awaiter(this, void 0, void 0, function () {
|
|
78
79
|
return __generator(this, function (_a) {
|
|
79
|
-
|
|
80
|
+
/** Throw an error if the user provided both expirationDate and timeToLive */
|
|
81
|
+
if (options &&
|
|
82
|
+
options.expirationDate !== undefined &&
|
|
83
|
+
options.timeToLive !== undefined) {
|
|
84
|
+
throw new Error("Please provide expirationDate or timeToLive or neither. Providing both is not allowed.");
|
|
85
|
+
}
|
|
86
|
+
return [2 /*return*/, (0, httpRequest_1._request)("POST", this._credentials, this._apiUrl, this.apiPath + "/" + projectId + "/keys", JSON.stringify({
|
|
87
|
+
comment: comment,
|
|
88
|
+
scopes: scopes,
|
|
89
|
+
expiration_date: options && options.expirationDate
|
|
90
|
+
? options.expirationDate
|
|
91
|
+
: undefined,
|
|
92
|
+
time_to_live_in_seconds: options && options.timeToLive ? options.timeToLive : undefined,
|
|
93
|
+
}))];
|
|
80
94
|
});
|
|
81
95
|
});
|
|
82
96
|
};
|
|
@@ -88,7 +102,7 @@ var Keys = /** @class */ (function () {
|
|
|
88
102
|
Keys.prototype.delete = function (projectId, keyId) {
|
|
89
103
|
return __awaiter(this, void 0, void 0, function () {
|
|
90
104
|
return __generator(this, function (_a) {
|
|
91
|
-
return [2 /*return*/, httpRequest_1._request("DELETE", this._credentials, this._apiUrl, this.apiPath + "/" + projectId + "/keys/" + keyId)];
|
|
105
|
+
return [2 /*return*/, (0, httpRequest_1._request)("DELETE", this._credentials, this._apiUrl, this.apiPath + "/" + projectId + "/keys/" + keyId)];
|
|
92
106
|
});
|
|
93
107
|
});
|
|
94
108
|
};
|
package/dist/keys.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../src/keys.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAyC;AAGzC;IACE,cAAoB,YAAoB,EAAU,OAAe;QAA7C,iBAAY,GAAZ,YAAY,CAAQ;QAAU,YAAO,GAAP,OAAO,CAAQ;QAEzD,YAAO,GAAG,cAAc,CAAC;IAFmC,CAAC;IAIrE;;;OAGG;IACG,mBAAI,GAAV,UAAW,SAAiB;;;gBAC1B,sBAAO,sBAAQ,
|
|
1
|
+
{"version":3,"file":"keys.js","sourceRoot":"","sources":["../src/keys.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAyC;AAGzC;IACE,cAAoB,YAAoB,EAAU,OAAe;QAA7C,iBAAY,GAAZ,YAAY,CAAQ;QAAU,YAAO,GAAP,OAAO,CAAQ;QAEzD,YAAO,GAAG,cAAc,CAAC;IAFmC,CAAC;IAIrE;;;OAGG;IACG,mBAAI,GAAV,UAAW,SAAiB;;;gBAC1B,sBAAO,IAAA,sBAAQ,EACb,KAAK,EACL,IAAI,CAAC,YAAY,EACjB,IAAI,CAAC,OAAO,EACT,IAAI,CAAC,OAAO,SAAI,SAAS,UAAO,CACpC,EAAC;;;KACH;IAED;;;;OAIG;IACG,kBAAG,GAAT,UAAU,SAAiB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list = function () {
|
|
51
51
|
return __awaiter(this, void 0, void 0, function () {
|
|
52
52
|
return __generator(this, function (_a) {
|
|
53
|
-
return [2 /*return*/, httpRequest_1._request("GET", this._credentials, this._apiUrl, this.apiPath)];
|
|
53
|
+
return [2 /*return*/, (0, httpRequest_1._request)("GET", this._credentials, this._apiUrl, this.apiPath)];
|
|
54
54
|
});
|
|
55
55
|
});
|
|
56
56
|
};
|
|
@@ -61,7 +61,7 @@ var Projects = /** @class */ (function () {
|
|
|
61
61
|
Projects.prototype.get = function (projectId) {
|
|
62
62
|
return __awaiter(this, void 0, void 0, function () {
|
|
63
63
|
return __generator(this, function (_a) {
|
|
64
|
-
return [2 /*return*/, httpRequest_1._request("GET", this._credentials, this._apiUrl, this.apiPath + "/" + projectId)];
|
|
64
|
+
return [2 /*return*/, (0, httpRequest_1._request)("GET", this._credentials, this._apiUrl, this.apiPath + "/" + projectId)];
|
|
65
65
|
});
|
|
66
66
|
});
|
|
67
67
|
};
|
|
@@ -72,7 +72,7 @@ var Projects = /** @class */ (function () {
|
|
|
72
72
|
Projects.prototype.update = function (project) {
|
|
73
73
|
return __awaiter(this, void 0, void 0, function () {
|
|
74
74
|
return __generator(this, function (_a) {
|
|
75
|
-
return [2 /*return*/, httpRequest_1._request("PATCH", this._credentials, this._apiUrl, this.apiPath + "/" + project.project_id)];
|
|
75
|
+
return [2 /*return*/, (0, httpRequest_1._request)("PATCH", this._credentials, this._apiUrl, this.apiPath + "/" + project.project_id)];
|
|
76
76
|
});
|
|
77
77
|
});
|
|
78
78
|
};
|
package/dist/projects.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"projects.js","sourceRoot":"","sources":["../src/projects.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAyC;AAGzC;IACE,kBAAoB,YAAoB,EAAU,OAAe;QAA7C,iBAAY,GAAZ,YAAY,CAAQ;QAAU,YAAO,GAAP,OAAO,CAAQ;QAEzD,YAAO,GAAG,cAAc,CAAC;IAFmC,CAAC;IAIrE;;OAEG;IACG,uBAAI,GAAV;;;gBACE,sBAAO,sBAAQ,
|
|
1
|
+
{"version":3,"file":"projects.js","sourceRoot":"","sources":["../src/projects.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAyC;AAGzC;IACE,kBAAoB,YAAoB,EAAU,OAAe;QAA7C,iBAAY,GAAZ,YAAY,CAAQ;QAAU,YAAO,GAAP,OAAO,CAAQ;QAEzD,YAAO,GAAG,cAAc,CAAC;IAFmC,CAAC;IAIrE;;OAEG;IACG,uBAAI,GAAV;;;gBACE,sBAAO,IAAA,sBAAQ,EACb,KAAK,EACL,IAAI,CAAC,YAAY,EACjB,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,OAAO,CACb,EAAC;;;KACH;IAED;;;OAGG;IACG,sBAAG,GAAT,UAAU,SAAiB;;;gBACzB,sBAAO,IAAA,sBAAQ,EACb,KAAK,EACL,IAAI,CAAC,YAAY,EACjB,IAAI,CAAC,OAAO,EACT,IAAI,CAAC,OAAO,SAAI,SAAW,CAC/B,EAAC;;;KACH;IAED;;;OAGG;IACG,yBAAM,GAAZ,UAAa,OAAgB;;;gBAC3B,sBAAO,IAAA,sBAAQ,EACb,OAAO,EACP,IAAI,CAAC,YAAY,EACjB,IAAI,CAAC,OAAO,EACT,IAAI,CAAC,OAAO,SAAI,OAAO,CAAC,UAAY,CACxC,EAAC;;;KACH;IACH,eAAC;AAAD,CAAC,AA1CD,IA0CC;AA1CY,4BAAQ"}
|
|
@@ -53,7 +53,7 @@ var Transcriber = /** @class */ (function () {
|
|
|
53
53
|
return __awaiter(this, void 0, void 0, function () {
|
|
54
54
|
return __generator(this, function (_a) {
|
|
55
55
|
switch (_a.label) {
|
|
56
|
-
case 0: return [4 /*yield*/, preRecordedTranscription_1.preRecordedTranscription(this._credentials, this._apiUrl || "", source, options)];
|
|
56
|
+
case 0: return [4 /*yield*/, (0, preRecordedTranscription_1.preRecordedTranscription)(this._credentials, this._apiUrl || "", source, options)];
|
|
57
57
|
case 1: return [2 /*return*/, _a.sent()];
|
|
58
58
|
}
|
|
59
59
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/transcription/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,yDAAwD;AACxD,uEAAsE;AAEtE;IACE,qBAAoB,YAAoB,EAAU,OAAe;QAA7C,iBAAY,GAAZ,YAAY,CAAQ;QAAU,YAAO,GAAP,OAAO,CAAQ;IAAG,CAAC;IAErE;;;;OAIG;IACG,iCAAW,GAAjB,UACE,MAA2B,EAC3B,OAAyC;;;;4BAElC,qBAAM,mDAAwB,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/transcription/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAMA,yDAAwD;AACxD,uEAAsE;AAEtE;IACE,qBAAoB,YAAoB,EAAU,OAAe;QAA7C,iBAAY,GAAZ,YAAY,CAAQ;QAAU,YAAO,GAAP,OAAO,CAAQ;IAAG,CAAC;IAErE;;;;OAIG;IACG,iCAAW,GAAjB,UACE,MAA2B,EAC3B,OAAyC;;;;4BAElC,qBAAM,IAAA,mDAAwB,EACnC,IAAI,CAAC,YAAY,EACjB,IAAI,CAAC,OAAO,IAAI,EAAE,EAClB,MAAM,EACN,OAAO,CACR,EAAA;4BALD,sBAAO,SAKN,EAAC;;;;KACH;IAED;;;OAGG;IACH,0BAAI,GAAJ,UAAK,OAAkC;QACrC,OAAO,IAAI,qCAAiB,CAC1B,IAAI,CAAC,YAAY,EACjB,IAAI,CAAC,OAAO,IAAI,EAAE,EAClB,OAAO,CACR,CAAC;IACJ,CAAC;IACH,kBAAC;AAAD,CAAC,AA/BD,IA+BC;AA/BY,kCAAW"}
|
|
@@ -31,7 +31,7 @@ var LiveTranscription = /** @class */ (function (_super) {
|
|
|
31
31
|
_this._socket = new ws_1.default("wss://" + apiUrl + "/v1/listen?" + querystring_1.default.stringify(options), {
|
|
32
32
|
headers: {
|
|
33
33
|
Authorization: "token " + credentials,
|
|
34
|
-
"User-Agent": userAgent_1.userAgent(),
|
|
34
|
+
"User-Agent": (0, userAgent_1.userAgent)(),
|
|
35
35
|
},
|
|
36
36
|
});
|
|
37
37
|
_this._bindSocketEvents();
|
|
@@ -75,7 +75,7 @@ var LiveTranscription = /** @class */ (function (_super) {
|
|
|
75
75
|
* the websocket connection when transcription is finished
|
|
76
76
|
*/
|
|
77
77
|
LiveTranscription.prototype.finish = function () {
|
|
78
|
-
this._socket.
|
|
78
|
+
this._socket.send(new Uint8Array(0));
|
|
79
79
|
};
|
|
80
80
|
return LiveTranscription;
|
|
81
81
|
}(events_1.default));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"liveTranscription.js","sourceRoot":"","sources":["../../src/transcription/liveTranscription.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,kDAAkC;AAClC,4DAAsC;AACtC,0CAA2B;AAC3B,kCAAoE;AAEpE,0CAAyC;AAEzC;IAAuC,qCAAY;IAGjD,2BACE,WAAmB,EACnB,MAAc,EACd,OAAkC;QAHpC,YAKE,kBAAM,SAAS,CAAC,SAWjB;QAVC,KAAI,CAAC,OAAO,GAAG,IAAI,YAAS,CAC1B,WAAS,MAAM,mBAAc,qBAAW,CAAC,SAAS,CAAC,OAAO,CAAG,EAC7D;YACE,OAAO,EAAE;gBACP,aAAa,EAAE,WAAS,WAAa;gBACrC,YAAY,EAAE,qBAAS,
|
|
1
|
+
{"version":3,"file":"liveTranscription.js","sourceRoot":"","sources":["../../src/transcription/liveTranscription.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,kDAAkC;AAClC,4DAAsC;AACtC,0CAA2B;AAC3B,kCAAoE;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IAAI,sBAEP,sCAAsC,CACvC,CAAC;SACH;IACH,CAAC;IAED;;;OAGG;IACI,kCAAM,GAAb;QACE,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;IACvC,CAAC;IACH,wBAAC;AAAD,CAAC,AApED,CAAuC,gBAAY,GAoElD;AApEY,8CAAiB"}
|
|
@@ -52,12 +52,23 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
52
52
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
53
|
exports.preRecordedTranscription = void 0;
|
|
54
54
|
var querystring_1 = __importDefault(require("querystring"));
|
|
55
|
+
var types_1 = require("../types");
|
|
55
56
|
var httpRequest_1 = require("../httpRequest");
|
|
56
57
|
function isUrlSource(providedSource) {
|
|
57
58
|
if (providedSource.url)
|
|
58
59
|
return true;
|
|
59
60
|
return false;
|
|
60
61
|
}
|
|
62
|
+
function isBufferSource(providedSource) {
|
|
63
|
+
if (providedSource.buffer)
|
|
64
|
+
return true;
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
function isReadStreamSource(providedSource) {
|
|
68
|
+
if (providedSource.stream)
|
|
69
|
+
return true;
|
|
70
|
+
return false;
|
|
71
|
+
}
|
|
61
72
|
/**
|
|
62
73
|
* Transcribes audio from a file or buffer
|
|
63
74
|
* @param credentials Base64 encoded API key & secret
|
|
@@ -65,23 +76,37 @@ function isUrlSource(providedSource) {
|
|
|
65
76
|
* @param options Options to modify transcriptions
|
|
66
77
|
*/
|
|
67
78
|
var preRecordedTranscription = function (apiKey, apiUrl, source, options) { return __awaiter(void 0, void 0, void 0, function () {
|
|
68
|
-
var transcriptionOptions;
|
|
79
|
+
var transcriptionOptions, body, requestOptions, response;
|
|
69
80
|
return __generator(this, function (_a) {
|
|
70
81
|
switch (_a.label) {
|
|
71
82
|
case 0:
|
|
72
83
|
transcriptionOptions = __assign({}, options);
|
|
73
84
|
if (!isUrlSource(source) &&
|
|
74
85
|
(source.mimetype === undefined || source.mimetype.length === 0)) {
|
|
75
|
-
throw new Error("DG: Mimetype must be provided if the source is a Buffer");
|
|
86
|
+
throw new Error("DG: Mimetype must be provided if the source is a Buffer or a ReadStream");
|
|
87
|
+
}
|
|
88
|
+
if (isUrlSource(source)) {
|
|
89
|
+
body = JSON.stringify(source);
|
|
90
|
+
}
|
|
91
|
+
else if (isBufferSource(source)) {
|
|
92
|
+
body = source.buffer;
|
|
93
|
+
}
|
|
94
|
+
else if (isReadStreamSource(source)) {
|
|
95
|
+
body = source.stream;
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
throw new Error("Unknown TranscriptionSource type");
|
|
99
|
+
}
|
|
100
|
+
requestOptions = {};
|
|
101
|
+
if (!isUrlSource(source)) {
|
|
102
|
+
requestOptions.headers = {
|
|
103
|
+
"Content-Type": source.mimetype,
|
|
104
|
+
};
|
|
76
105
|
}
|
|
77
|
-
return [4 /*yield*/, httpRequest_1._request("POST", apiKey, apiUrl, "/v1/listen?" + querystring_1.default.stringify(transcriptionOptions),
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
"Content-Type": source.mimetype,
|
|
82
|
-
},
|
|
83
|
-
})];
|
|
84
|
-
case 1: return [2 /*return*/, _a.sent()];
|
|
106
|
+
return [4 /*yield*/, (0, httpRequest_1._request)("POST", apiKey, apiUrl, "/v1/listen?" + querystring_1.default.stringify(transcriptionOptions), body, requestOptions)];
|
|
107
|
+
case 1:
|
|
108
|
+
response = _a.sent();
|
|
109
|
+
return [2 /*return*/, Object.assign(new types_1.PrerecordedTranscriptionResponse(), response)];
|
|
85
110
|
}
|
|
86
111
|
});
|
|
87
112
|
}); };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"preRecordedTranscription.js","sourceRoot":"","sources":["../../src/transcription/preRecordedTranscription.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4DAAsC;
|
|
1
|
+
{"version":3,"file":"preRecordedTranscription.js","sourceRoot":"","sources":["../../src/transcription/preRecordedTranscription.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4DAAsC;AACtC,kCAOkB;AAClB,8CAA0C;AAE1C,SAAS,WAAW,CAClB,cAAmC;IAEnC,IAAK,cAA4B,CAAC,GAAG;QAAE,OAAO,IAAI,CAAC;IACnD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,cAAc,CACrB,cAAmC;IAEnC,IAAK,cAA+B,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IACzD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,kBAAkB,CACzB,cAAmC;IAEnC,IAAK,cAAmC,CAAC,MAAM;QAAE,OAAO,IAAI,CAAC;IAC7D,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;GAKG;AACI,IAAM,wBAAwB,GAAG,UACtC,MAAc,EACd,MAAc,EACd,MAA2B,EAC3B,OAAyC;;;;;gBAEnC,oBAAoB,YAAQ,EAAE,EAAK,OAAO,CAAE,CAAC;gBAEnD,IACE,CAAC,WAAW,CAAC,MAAM,CAAC;oBACpB,CAAC,MAAM,CAAC,QAAQ,KAAK,SAAS,IAAI,MAAM,CAAC,QAAQ,CAAC,MAAM,KAAK,CAAC,CAAC,EAC/D;oBACA,MAAM,IAAI,KAAK,CACb,yEAAyE,CAC1E,CAAC;iBACH;gBAGD,IAAI,WAAW,CAAC,MAAM,CAAC,EAAE;oBACvB,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;iBAC/B;qBAAM,IAAI,cAAc,CAAC,MAAM,CAAC,EAAE;oBACjC,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC;iBACtB;qBAAM,IAAI,kBAAkB,CAAC,MAAM,CAAC,EAAE;oBACrC,IAAI,GAAG,MAAM,CAAC,MAAM,CAAC;iBACtB;qBAAM;oBACL,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAC;iBACrD;gBAEK,cAAc,GAAkD,EAAE,CAAC;gBACzE,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,EAAE;oBACxB,cAAc,CAAC,OAAO,GAAG;wBACvB,cAAc,EAAE,MAAM,CAAC,QAAQ;qBAChC,CAAC;iBACH;gBAEgB,qBAAM,IAAA,sBAAQ,EAC7B,MAAM,EACN,MAAM,EACN,MAAM,EACN,gBAAc,qBAAW,CAAC,SAAS,CAAC,oBAAoB,CAAG,EAC3D,IAAI,EACJ,cAAc,CACf,EAAA;;gBAPK,QAAQ,GAAG,SAOhB;gBAED,sBAAO,MAAM,CAAC,MAAM,CAAC,IAAI,wCAAgC,EAAE,EAAE,QAAQ,CAAC,EAAC;;;KACxE,CAAC;AA7CW,QAAA,wBAAwB,4BA6CnC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Optional options used when creating an API key
|
|
3
|
+
*/
|
|
4
|
+
export declare type CreateKeyOptions = {
|
|
5
|
+
/**
|
|
6
|
+
* Date on which the key you would like to create should expire.
|
|
7
|
+
*/
|
|
8
|
+
expirationDate?: Date;
|
|
9
|
+
/**
|
|
10
|
+
* Length of time (in seconds) during which the key you would like to create will remain valid.
|
|
11
|
+
*/
|
|
12
|
+
timeToLive?: number;
|
|
13
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createKeyOptions.js","sourceRoot":"","sources":["../../src/types/createKeyOptions.ts"],"names":[],"mappings":""}
|
package/dist/types/index.d.ts
CHANGED
package/dist/types/index.js
CHANGED
|
@@ -11,6 +11,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
11
11
|
};
|
|
12
12
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
13
|
__exportStar(require("./channel"), exports);
|
|
14
|
+
__exportStar(require("./createKeyOptions"), exports);
|
|
14
15
|
__exportStar(require("./hit"), exports);
|
|
15
16
|
__exportStar(require("./key"), exports);
|
|
16
17
|
__exportStar(require("./keyResponse"), exports);
|
package/dist/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4CAA0B;AAC1B,wCAAsB;AACtB,wCAAsB;AACtB,gDAA8B;AAC9B,6DAA2C;AAC3C,8DAA4C;AAC5C,2CAAyB;AACzB,6CAA2B;AAC3B,oEAAkD;AAClD,qEAAmD;AACnD,4CAA0B;AAC1B,yDAAuC;AACvC,oDAAkC;AAClC,2CAAyB;AACzB,wDAAsC;AACtC,kDAAgC;AAChC,+CAA6B;AAC7B,sDAAoC;AACpC,iDAA+B;AAC/B,iDAA+B;AAC/B,uDAAqC;AACrC,qDAAmC;AACnC,4DAA0C;AAC1C,kDAAgC;AAChC,wDAAsC;AACtC,8CAA4B;AAC5B,6CAA2B"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4CAA0B;AAC1B,qDAAmC;AACnC,wCAAsB;AACtB,wCAAsB;AACtB,gDAA8B;AAC9B,6DAA2C;AAC3C,8DAA4C;AAC5C,2CAAyB;AACzB,6CAA2B;AAC3B,oEAAkD;AAClD,qEAAmD;AACnD,4CAA0B;AAC1B,yDAAuC;AACvC,oDAAkC;AAClC,2CAAyB;AACzB,wDAAsC;AACtC,kDAAgC;AAChC,+CAA6B;AAC7B,sDAAoC;AACpC,iDAA+B;AAC/B,iDAA+B;AAC/B,uDAAqC;AACrC,qDAAmC;AACnC,4DAA0C;AAC1C,kDAAgC;AAChC,wDAAsC;AACtC,8CAA4B;AAC5B,6CAA2B"}
|
|
@@ -1,11 +1,25 @@
|
|
|
1
1
|
import { Metadata } from "./metadata";
|
|
2
2
|
import { Channel } from "./channel";
|
|
3
3
|
import { Utterance } from "./utterance";
|
|
4
|
-
export declare
|
|
4
|
+
export declare class PrerecordedTranscriptionResponse {
|
|
5
5
|
request_id?: string;
|
|
6
6
|
metadata?: Metadata;
|
|
7
7
|
results?: {
|
|
8
8
|
channels: Array<Channel>;
|
|
9
9
|
utterances?: Array<Utterance>;
|
|
10
10
|
};
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Converts the transcription to the WebVTT format
|
|
13
|
+
* @remarks In order to translate the transcription to WebVTT, the utterances
|
|
14
|
+
* feature must be used.
|
|
15
|
+
* @returns A string with the transcription in the WebVTT format
|
|
16
|
+
*/
|
|
17
|
+
toWebVTT(): string;
|
|
18
|
+
/**
|
|
19
|
+
* Converts the transcription to the SRT format
|
|
20
|
+
* @remarks In order to translate the transcription to SRT, the utterances
|
|
21
|
+
* feature must be used.
|
|
22
|
+
* @returns A string with the transcription in the SRT format
|
|
23
|
+
*/
|
|
24
|
+
toSRT(): string;
|
|
25
|
+
}
|
|
@@ -1,3 +1,51 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PrerecordedTranscriptionResponse = void 0;
|
|
4
|
+
var helpers_1 = require("../helpers");
|
|
5
|
+
var PrerecordedTranscriptionResponse = /** @class */ (function () {
|
|
6
|
+
function PrerecordedTranscriptionResponse() {
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Converts the transcription to the WebVTT format
|
|
10
|
+
* @remarks In order to translate the transcription to WebVTT, the utterances
|
|
11
|
+
* feature must be used.
|
|
12
|
+
* @returns A string with the transcription in the WebVTT format
|
|
13
|
+
*/
|
|
14
|
+
PrerecordedTranscriptionResponse.prototype.toWebVTT = function () {
|
|
15
|
+
var _a, _b, _c, _d;
|
|
16
|
+
if (!this.results || !this.results.utterances) {
|
|
17
|
+
throw new Error("This function requires a transcript that was generated with the utterances feature.");
|
|
18
|
+
}
|
|
19
|
+
var webVTT = "WEBVTT\n\n";
|
|
20
|
+
webVTT += "NOTE\nTranscription provided by Deepgram\nRequest Id: " + ((_a = this.metadata) === null || _a === void 0 ? void 0 : _a.request_id) + "\nCreated: " + ((_b = this.metadata) === null || _b === void 0 ? void 0 : _b.created) + "\nDuration: " + ((_c = this.metadata) === null || _c === void 0 ? void 0 : _c.duration) + "\nChannels: " + ((_d = this.metadata) === null || _d === void 0 ? void 0 : _d.channels) + "\n\n";
|
|
21
|
+
for (var i = 0; i < this.results.utterances.length; i++) {
|
|
22
|
+
var utterance = this.results.utterances[i];
|
|
23
|
+
var start = (0, helpers_1.secondsToTimestamp)(utterance.start);
|
|
24
|
+
var end = (0, helpers_1.secondsToTimestamp)(utterance.end);
|
|
25
|
+
webVTT += i + 1 + "\n" + start + " --> " + end + "\n- " + utterance.transcript + "\n\n";
|
|
26
|
+
}
|
|
27
|
+
return webVTT;
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Converts the transcription to the SRT format
|
|
31
|
+
* @remarks In order to translate the transcription to SRT, the utterances
|
|
32
|
+
* feature must be used.
|
|
33
|
+
* @returns A string with the transcription in the SRT format
|
|
34
|
+
*/
|
|
35
|
+
PrerecordedTranscriptionResponse.prototype.toSRT = function () {
|
|
36
|
+
if (!this.results || !this.results.utterances) {
|
|
37
|
+
throw new Error("This function requires a transcript that was generated with the utterances feature.");
|
|
38
|
+
}
|
|
39
|
+
var srt = "";
|
|
40
|
+
for (var i = 0; i < this.results.utterances.length; i++) {
|
|
41
|
+
var utterance = this.results.utterances[i];
|
|
42
|
+
var start = (0, helpers_1.secondsToTimestamp)(utterance.start).replace(".", ",");
|
|
43
|
+
var end = (0, helpers_1.secondsToTimestamp)(utterance.end).replace(".", ",");
|
|
44
|
+
srt += i + 1 + "\n" + start + " --> " + end + "\n" + utterance.transcript + "\n\n";
|
|
45
|
+
}
|
|
46
|
+
return srt;
|
|
47
|
+
};
|
|
48
|
+
return PrerecordedTranscriptionResponse;
|
|
49
|
+
}());
|
|
50
|
+
exports.PrerecordedTranscriptionResponse = PrerecordedTranscriptionResponse;
|
|
3
51
|
//# sourceMappingURL=prerecordedTranscriptionResponse.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prerecordedTranscriptionResponse.js","sourceRoot":"","sources":["../../src/types/prerecordedTranscriptionResponse.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"prerecordedTranscriptionResponse.js","sourceRoot":"","sources":["../../src/types/prerecordedTranscriptionResponse.ts"],"names":[],"mappings":";;;AAGA,sCAAgD;AAEhD;IAAA;IA2DA,CAAC;IAnDC;;;;;OAKG;IACI,mDAAQ,GAAf;;QACE,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE;YAC7C,MAAM,IAAI,KAAK,CACb,qFAAqF,CACtF,CAAC;SACH;QAED,IAAI,MAAM,GAAG,YAAY,CAAC;QAE1B,MAAM,IAAI,4DAAyD,MAAA,IAAI,CAAC,QAAQ,0CAAE,UAAU,qBAAc,MAAA,IAAI,CAAC,QAAQ,0CAAE,OAAO,sBAAe,MAAA,IAAI,CAAC,QAAQ,0CAAE,QAAQ,sBAAe,MAAA,IAAI,CAAC,QAAQ,0CAAE,QAAQ,UAAM,CAAC;QAEnN,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACvD,IAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;YAC7C,IAAM,KAAK,GAAG,IAAA,4BAAkB,EAAC,SAAS,CAAC,KAAK,CAAC,CAAC;YAClD,IAAM,GAAG,GAAG,IAAA,4BAAkB,EAAC,SAAS,CAAC,GAAG,CAAC,CAAC;YAC9C,MAAM,IAAO,CAAC,GAAG,CAAC,UAAK,KAAK,aAAQ,GAAG,YAAO,SAAS,CAAC,UAAU,SAAM,CAAC;SAC1E;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;IAED;;;;;OAKG;IACI,gDAAK,GAAZ;QACE,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE;YAC7C,MAAM,IAAI,KAAK,CACb,qFAAqF,CACtF,CAAC;SACH;QAED,IAAI,GAAG,GAAG,EAAE,CAAC;QAEb,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YACvD,IAAM,SAAS,GAAG,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;YAC7C,IAAM,KAAK,GAAG,IAAA,4BAAkB,EAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;YACpE,IAAM,GAAG,GAAG,IAAA,4BAAkB,EAAC,SAAS,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;YAChE,GAAG,IAAO,CAAC,GAAG,CAAC,UAAK,KAAK,aAAQ,GAAG,UAAK,SAAS,CAAC,UAAU,SAAM,CAAC;SACrE;QAED,OAAO,GAAG,CAAC;IACb,CAAC;IACH,uCAAC;AAAD,CAAC,AA3DD,IA2DC;AA3DY,4EAAgC"}
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
|
|
2
|
+
import { ReadStream } from "fs";
|
|
3
|
+
export declare type TranscriptionSource = UrlSource | BufferSource | ReadStreamSource;
|
|
4
|
+
export declare type ReadStreamSource = {
|
|
5
|
+
stream: ReadStream;
|
|
6
|
+
mimetype: string;
|
|
7
|
+
};
|
|
3
8
|
export declare type UrlSource = {
|
|
4
9
|
url: string;
|
|
5
10
|
};
|
package/dist/usage.js
CHANGED
|
@@ -70,7 +70,7 @@ var Usage = /** @class */ (function () {
|
|
|
70
70
|
var requestOptions;
|
|
71
71
|
return __generator(this, function (_a) {
|
|
72
72
|
requestOptions = __assign({}, options);
|
|
73
|
-
return [2 /*return*/, httpRequest_1._request("GET", this._credentials, this._apiUrl, this.apiPath + "/" + projectId + "/requests?" + querystring_1.default.stringify(requestOptions))];
|
|
73
|
+
return [2 /*return*/, (0, httpRequest_1._request)("GET", this._credentials, this._apiUrl, this.apiPath + "/" + projectId + "/requests?" + querystring_1.default.stringify(requestOptions))];
|
|
74
74
|
});
|
|
75
75
|
});
|
|
76
76
|
};
|
|
@@ -82,7 +82,7 @@ var Usage = /** @class */ (function () {
|
|
|
82
82
|
Usage.prototype.getRequest = function (projectId, requestId) {
|
|
83
83
|
return __awaiter(this, void 0, void 0, function () {
|
|
84
84
|
return __generator(this, function (_a) {
|
|
85
|
-
return [2 /*return*/, httpRequest_1._request("GET", this._credentials, this._apiUrl, this.apiPath + "/" + projectId + "/requests/" + requestId)];
|
|
85
|
+
return [2 /*return*/, (0, httpRequest_1._request)("GET", this._credentials, this._apiUrl, this.apiPath + "/" + projectId + "/requests/" + requestId)];
|
|
86
86
|
});
|
|
87
87
|
});
|
|
88
88
|
};
|
|
@@ -97,7 +97,7 @@ var Usage = /** @class */ (function () {
|
|
|
97
97
|
var requestOptions;
|
|
98
98
|
return __generator(this, function (_a) {
|
|
99
99
|
requestOptions = __assign({}, options);
|
|
100
|
-
return [2 /*return*/, httpRequest_1._request("GET", this._credentials, this._apiUrl, this.apiPath + "/" + projectId + "/usage?" + querystring_1.default.stringify(requestOptions))];
|
|
100
|
+
return [2 /*return*/, (0, httpRequest_1._request)("GET", this._credentials, this._apiUrl, this.apiPath + "/" + projectId + "/usage?" + querystring_1.default.stringify(requestOptions))];
|
|
101
101
|
});
|
|
102
102
|
});
|
|
103
103
|
};
|
|
@@ -112,7 +112,7 @@ var Usage = /** @class */ (function () {
|
|
|
112
112
|
var requestOptions;
|
|
113
113
|
return __generator(this, function (_a) {
|
|
114
114
|
requestOptions = __assign({}, options);
|
|
115
|
-
return [2 /*return*/, httpRequest_1._request("GET", this._credentials, this._apiUrl, this.apiPath + "/" + projectId + "/usage/fields?" + querystring_1.default.stringify(requestOptions))];
|
|
115
|
+
return [2 /*return*/, (0, httpRequest_1._request)("GET", this._credentials, this._apiUrl, this.apiPath + "/" + projectId + "/usage/fields?" + querystring_1.default.stringify(requestOptions))];
|
|
116
116
|
});
|
|
117
117
|
});
|
|
118
118
|
};
|
package/dist/usage.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usage.js","sourceRoot":"","sources":["../src/usage.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4DAAsC;AACtC,6CAAyC;AAWzC;IACE,eAAoB,YAAoB,EAAU,OAAe;QAA7C,iBAAY,GAAZ,YAAY,CAAQ;QAAU,YAAO,GAAP,OAAO,CAAQ;QAEzD,YAAO,GAAG,cAAc,CAAC;IAFmC,CAAC;IAIrE;;;;;OAKG;IACG,4BAAY,GAAlB,UACE,SAAiB,EACjB,OAAiC;;;;gBAE3B,cAAc,YAAQ,EAAE,EAAK,OAAO,CAAE,CAAC;gBAC7C,sBAAO,sBAAQ,
|
|
1
|
+
{"version":3,"file":"usage.js","sourceRoot":"","sources":["../src/usage.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4DAAsC;AACtC,6CAAyC;AAWzC;IACE,eAAoB,YAAoB,EAAU,OAAe;QAA7C,iBAAY,GAAZ,YAAY,CAAQ;QAAU,YAAO,GAAP,OAAO,CAAQ;QAEzD,YAAO,GAAG,cAAc,CAAC;IAFmC,CAAC;IAIrE;;;;;OAKG;IACG,4BAAY,GAAlB,UACE,SAAiB,EACjB,OAAiC;;;;gBAE3B,cAAc,YAAQ,EAAE,EAAK,OAAO,CAAE,CAAC;gBAC7C,s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