firebase-tools-with-isolate 15.28.2 → 15.30.0
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/lib/api.js +4 -2
- package/lib/apphosting/config.js +10 -8
- package/lib/apphosting/localbuilds.js +8 -0
- package/lib/apphosting/yaml.js +27 -0
- package/lib/bin/cli.js +1 -1
- package/lib/bin/mcp.js +8 -3
- package/lib/commands/ext-export.js +52 -14
- package/lib/commands/ext-migrate.js +70 -4
- package/lib/commands/ext-uninstall.js +2 -28
- package/lib/commands/functions-delete.js +6 -67
- package/lib/commands/functions-kits-install.js +7 -0
- package/lib/commands/functions-kits-uninstall.js +30 -86
- package/lib/crashlytics/onboarding.js +23 -2
- package/lib/deploy/apphosting/deploy.js +2 -1
- package/lib/deploy/apphosting/prepare.js +12 -3
- package/lib/deploy/apphosting/release.js +3 -0
- package/lib/deploy/apphosting/util.js +3 -1
- package/lib/deploy/extensions/secrets.js +10 -0
- package/lib/deploy/functions/delete.js +105 -0
- package/lib/deploy/functions/release/executor.js +14 -8
- package/lib/deploy/functions/release/fabricator.js +42 -20
- package/lib/deploy/functions/release/sourceTokenScraper.js +16 -2
- package/lib/emulator/downloadableEmulatorInfo.json +24 -24
- package/lib/emulator/tasksEmulator.js +2 -2
- package/lib/emulator/types.js +3 -1
- package/lib/extensions/askUserForParam.js +9 -8
- package/lib/extensions/export.js +47 -10
- package/lib/extensions/extensionsHelper.js +29 -2
- package/lib/extensions/manifest.js +5 -4
- package/lib/extensions/migrate.js +176 -2
- package/lib/extensions/paramHelper.js +78 -25
- package/lib/extensions/secretsUtils.js +3 -0
- package/lib/extensions/updateHelper.js +3 -1
- package/lib/functions/kits/install.js +322 -70
- package/lib/gcp/apikeys.js +89 -0
- package/lib/gcp/resourceManager.js +31 -22
- package/lib/gcp/run.js +2 -2
- package/lib/gcp/storage.js +3 -2
- package/lib/logger.js +83 -9
- package/lib/mcp/onemcp/index.js +19 -0
- package/lib/mcp/onemcp/onemcp_server.js +12 -7
- package/lib/mcp/tools/apphosting/fetch_logs.js +1 -0
- package/lib/mcp/tools/apphosting/list_backends.js +1 -0
- package/lib/mcp/tools/apptesting/tests.js +2 -0
- package/lib/mcp/tools/auth/get_users.js +1 -0
- package/lib/mcp/tools/auth/set_sms_region_policy.js +1 -0
- package/lib/mcp/tools/auth/update_user.js +1 -0
- package/lib/mcp/tools/core/create_android_sha.js +1 -0
- package/lib/mcp/tools/core/create_app.js +1 -0
- package/lib/mcp/tools/core/create_project.js +1 -0
- package/lib/mcp/tools/core/deploy.js +1 -0
- package/lib/mcp/tools/core/deploy_status.js +1 -0
- package/lib/mcp/tools/core/get_environment.js +1 -0
- package/lib/mcp/tools/core/get_project.js +1 -0
- package/lib/mcp/tools/core/get_sdk_config.js +1 -0
- package/lib/mcp/tools/core/get_security_rules.js +1 -0
- package/lib/mcp/tools/core/init.js +1 -0
- package/lib/mcp/tools/core/list_apps.js +1 -0
- package/lib/mcp/tools/core/list_projects.js +1 -0
- package/lib/mcp/tools/core/login.js +1 -0
- package/lib/mcp/tools/core/logout.js +1 -0
- package/lib/mcp/tools/core/read_resources.js +1 -0
- package/lib/mcp/tools/core/update_environment.js +1 -0
- package/lib/mcp/tools/core/validate_security_rules.js +1 -0
- package/lib/mcp/tools/crashlytics/events.js +2 -0
- package/lib/mcp/tools/crashlytics/issues.js +2 -0
- package/lib/mcp/tools/crashlytics/notes.js +3 -0
- package/lib/mcp/tools/crashlytics/reports.js +1 -0
- package/lib/mcp/tools/dataconnect/compile.js +1 -0
- package/lib/mcp/tools/dataconnect/execute.js +34 -19
- package/lib/mcp/tools/dataconnect/index.js +1 -1
- package/lib/mcp/tools/dataconnect/list_services.js +1 -0
- package/lib/mcp/tools/firestore/query_collection.js +1 -0
- package/lib/mcp/tools/functions/get_logs.js +1 -0
- package/lib/mcp/tools/functions/list_functions.js +1 -0
- package/lib/mcp/tools/index.js +3 -1
- package/lib/mcp/tools/messaging/send_message.js +1 -0
- package/lib/mcp/tools/realtime_database/get_data.js +1 -0
- package/lib/mcp/tools/realtime_database/set_data.js +1 -0
- package/lib/mcp/tools/remoteconfig/get_template.js +1 -0
- package/lib/mcp/tools/remoteconfig/update_template.js +1 -0
- package/lib/mcp/tools/storage/get_download_url.js +1 -0
- package/lib/prompt.js +10 -1
- package/lib/throttler/throttler.js +2 -11
- package/lib/tsconfig.publish.tsbuildinfo +1 -1
- package/lib/utils.js +26 -0
- package/package.json +5 -5
- package/templates/init/functions/typescript/index-kit-migration.ts +21 -2
- package/templates/init/functions/typescript/index-kit.ts +1 -0
- package/templates/init/functions/typescript/package-kit.json +21 -0
|
@@ -11,6 +11,7 @@ const app_id_1 = require("../../resources/guides/app_id");
|
|
|
11
11
|
exports.get_issue = (0, tool_1.tool)("crashlytics", {
|
|
12
12
|
name: "get_issue",
|
|
13
13
|
description: `Gets data for a Crashlytics issue, which can be used as a starting point for debugging.`,
|
|
14
|
+
humanReadableDescription: "Retrieve details and metadata for a specific Crashlytics issue.",
|
|
14
15
|
inputSchema: zod_1.z.object({
|
|
15
16
|
appId: filters_1.ApplicationIdSchema,
|
|
16
17
|
issueId: filters_1.IssueIdSchema,
|
|
@@ -41,6 +42,7 @@ exports.get_issue = (0, tool_1.tool)("crashlytics", {
|
|
|
41
42
|
exports.update_issue = (0, tool_1.tool)("crashlytics", {
|
|
42
43
|
name: "update_issue",
|
|
43
44
|
description: "Use this to update the state of Crashlytics issue.",
|
|
45
|
+
humanReadableDescription: "Update the state (OPEN or CLOSED) of a Crashlytics issue.",
|
|
44
46
|
inputSchema: zod_1.z.object({
|
|
45
47
|
appId: filters_1.ApplicationIdSchema,
|
|
46
48
|
issueId: filters_1.IssueIdSchema,
|
|
@@ -9,6 +9,7 @@ const util_1 = require("../../util");
|
|
|
9
9
|
exports.create_note = (0, tool_1.tool)("crashlytics", {
|
|
10
10
|
name: "create_note",
|
|
11
11
|
description: "Add a note to an issue from crashlytics. Only supported for mobile (Android and iOS) apps.",
|
|
12
|
+
humanReadableDescription: "Add a note to a Crashlytics issue for an Android or iOS app.",
|
|
12
13
|
inputSchema: zod_1.z.object({
|
|
13
14
|
appId: filters_1.ApplicationIdSchema,
|
|
14
15
|
issueId: filters_1.IssueIdSchema,
|
|
@@ -33,6 +34,7 @@ exports.create_note = (0, tool_1.tool)("crashlytics", {
|
|
|
33
34
|
exports.list_notes = (0, tool_1.tool)("crashlytics", {
|
|
34
35
|
name: "list_notes",
|
|
35
36
|
description: "Use this to list all notes for an issue in Crashlytics. Only supported for mobile (Android and iOS) apps.",
|
|
37
|
+
humanReadableDescription: "List all notes attached to a Crashlytics issue for an Android or iOS app.",
|
|
36
38
|
inputSchema: zod_1.z.object({
|
|
37
39
|
appId: filters_1.ApplicationIdSchema,
|
|
38
40
|
issueId: filters_1.IssueIdSchema,
|
|
@@ -55,6 +57,7 @@ exports.list_notes = (0, tool_1.tool)("crashlytics", {
|
|
|
55
57
|
exports.delete_note = (0, tool_1.tool)("crashlytics", {
|
|
56
58
|
name: "delete_note",
|
|
57
59
|
description: "Delete a note from a Crashlytics issue. Only supported for mobile (Android and iOS) apps.",
|
|
60
|
+
humanReadableDescription: "Delete a note from a Crashlytics issue for an Android or iOS app.",
|
|
58
61
|
inputSchema: zod_1.z.object({
|
|
59
62
|
appId: filters_1.ApplicationIdSchema,
|
|
60
63
|
issueId: filters_1.IssueIdSchema,
|
|
@@ -35,6 +35,7 @@ exports.get_report = (0, tool_1.tool)("crashlytics", {
|
|
|
35
35
|
name: "get_report",
|
|
36
36
|
description: `Use this to request numerical reports from Crashlytics. The result aggregates the sum of events and impacted users, grouped by a dimension appropriate for that report. Agents must read the [Firebase Crashlytics Reports Guide](firebase://guides/crashlytics/reports) using the \`firebase_read_resources\` tool before calling to understand critical prerequisites for requesting reports and how to interpret the results.
|
|
37
37
|
`.trim(),
|
|
38
|
+
humanReadableDescription: "Generate aggregated numerical reports for Crashlytics issues and events.",
|
|
38
39
|
inputSchema: reports_1.ReportInputSchema,
|
|
39
40
|
annotations: {
|
|
40
41
|
title: "Get Crashlytics Report",
|
|
@@ -29,6 +29,7 @@ Resolves service directories defined in the project's \`firebase.json\` under \`
|
|
|
29
29
|
"error_filter": "schema"
|
|
30
30
|
}
|
|
31
31
|
\`\`\``,
|
|
32
|
+
humanReadableDescription: "Compile Firebase SQL Connect schemas, operations, and connectors to validate syntax and types.",
|
|
32
33
|
inputSchema: zod_1.z.object({
|
|
33
34
|
error_filter: zod_1.z
|
|
34
35
|
.enum(["all", "schema", "operations"])
|
|
@@ -1,18 +1,43 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.execute_in_emulator = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const tool_1 = require("../../tool");
|
|
6
6
|
const dataplane = require("../../../dataconnect/dataplaneClient");
|
|
7
7
|
const load_1 = require("../../../dataconnect/load");
|
|
8
8
|
const converter_1 = require("../../util/dataconnect/converter");
|
|
9
9
|
const emulator_1 = require("../../util/dataconnect/emulator");
|
|
10
|
-
exports.
|
|
11
|
-
name: "
|
|
12
|
-
description:
|
|
10
|
+
exports.execute_in_emulator = (0, tool_1.tool)("dataconnect", {
|
|
11
|
+
name: "execute_in_emulator",
|
|
12
|
+
description: `Executes a GraphQL operation against a local Firebase SQL Connect Service instance emulator.
|
|
13
|
+
|
|
14
|
+
Grants access to run queries and mutations on the local emulator.
|
|
15
|
+
|
|
16
|
+
**Prerequisites:**
|
|
17
|
+
* The Firebase local emulators must be running (run \`firebase emulators:start\` in your project directory).
|
|
18
|
+
* A \`firebase.json\` file configured with a \`dataconnect\` service.
|
|
19
|
+
* A \`dataconnect.yaml\` configuration file inside the service's source directory.
|
|
20
|
+
* A defined SQL Connect schema (configured via the schema/schemas fields in \`dataconnect.yaml\`).
|
|
21
|
+
* Note: These files are ideally generated using the \`firebase_init\` MCP tool, or must follow the standard structure described in the \`firebase-data-connect-basics\` skill.
|
|
22
|
+
|
|
23
|
+
**When to use it:**
|
|
24
|
+
* Use this tool to execute local GraphQL queries or mutations for development and testing.
|
|
25
|
+
|
|
26
|
+
**How to use it:**
|
|
27
|
+
* Call \`execute_in_emulator\` with the GraphQL \`query\` string.
|
|
28
|
+
* Optionally provide \`service_id\`, \`location_id\`, \`variables_json\`, and \`auth_token_json\`.
|
|
29
|
+
|
|
30
|
+
**JSON Example:**
|
|
31
|
+
\`\`\`json
|
|
32
|
+
{
|
|
33
|
+
"query": "query GetUser($id: UUID!) { user(id: $id) { name } }",
|
|
34
|
+
"variables_json": "{\\"id\\": \\"123e4567-e89b-12d3-a456-426614174000\\"}"
|
|
35
|
+
}
|
|
36
|
+
\`\`\`
|
|
37
|
+
`,
|
|
38
|
+
humanReadableDescription: "Execute a GraphQL query or mutation against a Firebase SQL Connect service or emulator.",
|
|
13
39
|
inputSchema: zod_1.z.object({
|
|
14
40
|
query: zod_1.z.string().describe(`A Firebase SQL Connect GraphQL query or mutation to execute.
|
|
15
|
-
You can use the \`dataconnect_generate_operation\` tool to generate a query.
|
|
16
41
|
Example SQL Connect schema and example queries can be found in files ending in \`.graphql\` or \`.gql\`.
|
|
17
42
|
`),
|
|
18
43
|
service_id: zod_1.z
|
|
@@ -33,27 +58,17 @@ Example SQL Connect schema and example queries can be found in files ending in \
|
|
|
33
58
|
.describe("Firebase Auth Token JWT to use in this query. MUST be a valid stringified JSON object." +
|
|
34
59
|
'Importantly, when executing queries with `@auth(level: USER)` or `auth.uid`, a valid Firebase Auth Token JWT with "sub" field is required. ' +
|
|
35
60
|
'"auth.uid" expression in the query evaluates to the value of "sub" field in Firebase Auth token.'),
|
|
36
|
-
use_emulator: zod_1.z
|
|
37
|
-
.boolean()
|
|
38
|
-
.default(false)
|
|
39
|
-
.describe("If true, target the DataConnect emulator. Run `firebase emulators:start` to start it"),
|
|
40
61
|
}),
|
|
41
62
|
annotations: {
|
|
42
|
-
title: "Execute Firebase SQL Connect Query",
|
|
63
|
+
title: "Execute Firebase SQL Connect Query in Emulator",
|
|
43
64
|
},
|
|
44
65
|
_meta: {
|
|
45
66
|
requiresProject: true,
|
|
46
|
-
requiresAuth:
|
|
67
|
+
requiresAuth: false,
|
|
47
68
|
},
|
|
48
|
-
}, async ({ query, service_id, location_id, variables_json: unparsedVariables,
|
|
69
|
+
}, async ({ query, service_id, location_id, variables_json: unparsedVariables, auth_token_json: unparsedAuthToken, }, { projectId, config, host }) => {
|
|
49
70
|
const serviceInfo = await (0, load_1.pickOneService)(projectId, config, service_id || undefined, location_id || undefined);
|
|
50
|
-
|
|
51
|
-
if (use_emulator) {
|
|
52
|
-
apiClient = await (0, emulator_1.getDataConnectEmulatorClient)(host);
|
|
53
|
-
}
|
|
54
|
-
else {
|
|
55
|
-
apiClient = dataplane.dataconnectDataplaneClient();
|
|
56
|
-
}
|
|
71
|
+
const apiClient = await (0, emulator_1.getDataConnectEmulatorClient)(host);
|
|
57
72
|
let executeGraphQL = dataplane.executeGraphQL;
|
|
58
73
|
if (query.startsWith("query")) {
|
|
59
74
|
executeGraphQL = dataplane.executeGraphQLRead;
|
|
@@ -4,4 +4,4 @@ exports.dataconnectTools = void 0;
|
|
|
4
4
|
const list_services_1 = require("./list_services");
|
|
5
5
|
const compile_1 = require("./compile");
|
|
6
6
|
const execute_1 = require("./execute");
|
|
7
|
-
exports.dataconnectTools = [compile_1.compile, list_services_1.list_services, execute_1.
|
|
7
|
+
exports.dataconnectTools = [compile_1.compile, list_services_1.list_services, execute_1.execute_in_emulator];
|
|
@@ -12,6 +12,7 @@ const js_yaml_1 = require("js-yaml");
|
|
|
12
12
|
exports.list_services = (0, tool_1.tool)("dataconnect", {
|
|
13
13
|
name: "list_services",
|
|
14
14
|
description: "Use this to list existing local and backend Firebase SQL Connect services",
|
|
15
|
+
humanReadableDescription: "List local and deployed Firebase SQL Connect services, schemas, and connectors.",
|
|
15
16
|
inputSchema: zod_1.z.object({}),
|
|
16
17
|
annotations: {
|
|
17
18
|
title: "List existing Firebase SQL Connect services",
|
|
@@ -10,6 +10,7 @@ const types_1 = require("../../../emulator/types");
|
|
|
10
10
|
exports.query_collection = (0, tool_1.tool)("firestore", {
|
|
11
11
|
name: "query_collection",
|
|
12
12
|
description: "Use this to retrieve one or more Firestore documents from a collection in a database in the current project by a collection with a full document path. Use this if you know the exact path of a collection and the filtering clause you would like for the document.",
|
|
13
|
+
humanReadableDescription: "Query Firestore documents from a collection with optional filters and ordering.",
|
|
13
14
|
inputSchema: zod_1.z.object({
|
|
14
15
|
database: zod_1.z
|
|
15
16
|
.string()
|
|
@@ -41,6 +41,7 @@ function validateTimestamp(label, value) {
|
|
|
41
41
|
exports.get_logs = (0, tool_1.tool)("functions", {
|
|
42
42
|
name: "get_logs",
|
|
43
43
|
description: "Use this to retrieve a page of Cloud Functions log entries using Google Cloud Logging advanced filters.",
|
|
44
|
+
humanReadableDescription: "Retrieve and filter Cloud Functions log entries from Google Cloud Logging.",
|
|
44
45
|
inputSchema: zod_1.z.object({
|
|
45
46
|
function_names: zod_1.z
|
|
46
47
|
.array(zod_1.z.string())
|
|
@@ -9,6 +9,7 @@ const error_1 = require("../../../error");
|
|
|
9
9
|
exports.list_functions = (0, tool_1.tool)("functions", {
|
|
10
10
|
name: "list_functions",
|
|
11
11
|
description: "List all deployed functions in your Firebase project.",
|
|
12
|
+
humanReadableDescription: "List all deployed Cloud Functions in your Firebase project.",
|
|
12
13
|
inputSchema: zod_1.z.object({}),
|
|
13
14
|
annotations: {
|
|
14
15
|
title: "List Deployed Functions",
|
package/lib/mcp/tools/index.js
CHANGED
|
@@ -107,7 +107,9 @@ async function markdownDocsOfTools() {
|
|
|
107
107
|
if (feature === "firebase") {
|
|
108
108
|
feature = "core";
|
|
109
109
|
}
|
|
110
|
-
const description = (tool.mcp
|
|
110
|
+
const description = (tool.mcp.humanReadableDescription ||
|
|
111
|
+
tool.mcp.description ||
|
|
112
|
+
"").replaceAll("\n", "<br>");
|
|
111
113
|
doc += `
|
|
112
114
|
| ${tool.mcp.name} | ${feature} | ${description} |`;
|
|
113
115
|
}
|
|
@@ -8,6 +8,7 @@ const sendMessage_1 = require("../../../messaging/sendMessage");
|
|
|
8
8
|
exports.send_message = (0, tool_1.tool)("messaging", {
|
|
9
9
|
name: "send_message",
|
|
10
10
|
description: "Use this to send a message to a Firebase Cloud Messaging registration token or topic. ONLY ONE of `registration_token` or `topic` may be supplied in a specific call.",
|
|
11
|
+
humanReadableDescription: "Send a Firebase Cloud Messaging push notification to a device registration token or topic.",
|
|
11
12
|
inputSchema: zod_1.z.object({
|
|
12
13
|
registration_token: zod_1.z
|
|
13
14
|
.string()
|
|
@@ -11,6 +11,7 @@ const node_path_1 = require("node:path");
|
|
|
11
11
|
exports.get_data = (0, tool_1.tool)("database", {
|
|
12
12
|
name: "get_data",
|
|
13
13
|
description: "Use this to retrieve data from the specified location in a Firebase Realtime Database.",
|
|
14
|
+
humanReadableDescription: "Read data from a specified path in the Firebase Realtime Database.",
|
|
14
15
|
inputSchema: zod_1.z.object({
|
|
15
16
|
databaseUrl: zod_1.z
|
|
16
17
|
.string()
|
|
@@ -12,6 +12,7 @@ const node_path_1 = require("node:path");
|
|
|
12
12
|
exports.set_data = (0, tool_1.tool)("database", {
|
|
13
13
|
name: "set_data",
|
|
14
14
|
description: "Use this to write data to the specified location in a Firebase Realtime Database.",
|
|
15
|
+
humanReadableDescription: "Write JSON data to a specified path in the Firebase Realtime Database.",
|
|
15
16
|
inputSchema: zod_1.z.object({
|
|
16
17
|
databaseUrl: zod_1.z
|
|
17
18
|
.string()
|
|
@@ -8,6 +8,7 @@ const get_1 = require("../../../remoteconfig/get");
|
|
|
8
8
|
exports.get_template = (0, tool_1.tool)("remoteconfig", {
|
|
9
9
|
name: "get_template",
|
|
10
10
|
description: "Use this to retrieve the specified Firebase Remote Config template from the currently active Firebase Project.",
|
|
11
|
+
humanReadableDescription: "Retrieve the active or specified version of the Firebase Remote Config template.",
|
|
11
12
|
inputSchema: zod_1.z.object({
|
|
12
13
|
version_number: zod_1.z
|
|
13
14
|
.string()
|
|
@@ -9,6 +9,7 @@ const rollback_1 = require("../../../remoteconfig/rollback");
|
|
|
9
9
|
exports.update_template = (0, tool_1.tool)("remoteconfig", {
|
|
10
10
|
name: "update_template",
|
|
11
11
|
description: "Use this to publish a new remote config template or roll back to a specific version for the project",
|
|
12
|
+
humanReadableDescription: "Publish a new Firebase Remote Config template or rollback to a previous version.",
|
|
12
13
|
inputSchema: zod_1.z
|
|
13
14
|
.object({
|
|
14
15
|
template: zod_1.z.object({}).optional().describe("The Remote Config template object to publish."),
|
|
@@ -9,6 +9,7 @@ const types_1 = require("../../../emulator/types");
|
|
|
9
9
|
exports.get_object_download_url = (0, tool_1.tool)("storage", {
|
|
10
10
|
name: "get_object_download_url",
|
|
11
11
|
description: "Use this to retrieve the download URL for an object in a Cloud Storage for Firebase bucket.",
|
|
12
|
+
humanReadableDescription: "Retrieve the download URL for an object in a Cloud Storage bucket.",
|
|
12
13
|
inputSchema: zod_1.z.object({
|
|
13
14
|
bucket: zod_1.z
|
|
14
15
|
.string()
|
package/lib/prompt.js
CHANGED
|
@@ -59,7 +59,16 @@ async function confirm(opts) {
|
|
|
59
59
|
return inquirer.confirm(opts);
|
|
60
60
|
}
|
|
61
61
|
async function checkbox(opts) {
|
|
62
|
-
|
|
62
|
+
let optsWithDefault = opts;
|
|
63
|
+
if (opts.default === undefined && Array.isArray(opts.choices)) {
|
|
64
|
+
const checkedValues = opts.choices
|
|
65
|
+
.filter((c) => c && typeof c === "object" && "checked" in c && c.checked)
|
|
66
|
+
.map((c) => c.value);
|
|
67
|
+
if (checkedValues.length > 0) {
|
|
68
|
+
optsWithDefault = { ...opts, default: checkedValues };
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
const { shouldReturn, value } = guard(optsWithDefault);
|
|
63
72
|
if (shouldReturn) {
|
|
64
73
|
return value;
|
|
65
74
|
}
|
|
@@ -1,19 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Throttler = void 0;
|
|
4
|
-
exports.backoff = backoff;
|
|
5
|
-
exports.timeToWait = timeToWait;
|
|
6
4
|
const logger_1 = require("../logger");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
7
6
|
const retries_exhausted_error_1 = require("./errors/retries-exhausted-error");
|
|
8
7
|
const timeout_error_1 = require("./errors/timeout-error");
|
|
9
|
-
function backoff(retryNumber, delay, maxDelay) {
|
|
10
|
-
return new Promise((resolve) => {
|
|
11
|
-
setTimeout(resolve, timeToWait(retryNumber, delay, maxDelay));
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
function timeToWait(retryNumber, delay, maxDelay) {
|
|
15
|
-
return Math.min(delay * Math.pow(2, retryNumber), maxDelay);
|
|
16
|
-
}
|
|
17
8
|
function DEFAULT_HANDLER(task) {
|
|
18
9
|
return task();
|
|
19
10
|
}
|
|
@@ -184,7 +175,7 @@ class Throttler {
|
|
|
184
175
|
if (taskData.retryCount === this.retries) {
|
|
185
176
|
throw new retries_exhausted_error_1.default(this.taskName(cursorIndex), this.retries, err);
|
|
186
177
|
}
|
|
187
|
-
await backoff(taskData.retryCount + 1, this.backoff, this.maxBackoff);
|
|
178
|
+
await (0, utils_1.backoff)(taskData.retryCount + 1, this.backoff, this.maxBackoff);
|
|
188
179
|
if (taskData.isTimedOut) {
|
|
189
180
|
throw new timeout_error_1.default(this.taskName(cursorIndex), taskData.timeoutMillis);
|
|
190
181
|
}
|