UNPKG

3.02 kBJavaScriptView Raw
1"use strict";
2// The MIT License (MIT)
3//
4// Copyright (c) 2022 Firebase
5//
6// Permission is hereby granted, free of charge, to any person obtaining a copy
7// of this software and associated documentation files (the "Software"), to deal
8// in the Software without restriction, including without limitation the rights
9// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10// copies of the Software, and to permit persons to whom the Software is
11// furnished to do so, subject to the following conditions:
12//
13// The above copyright notice and this permission notice shall be included in all
14// copies or substantial portions of the Software.
15//
16// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22// SOFTWARE.
23Object.defineProperty(exports, "__esModule", { value: true });
24exports.onTestMatrixCompleted = exports.eventType = void 0;
25const onInit_1 = require("../../common/onInit");
26const manifest_1 = require("../../runtime/manifest");
27const options_1 = require("../options");
28const trace_1 = require("../trace");
29/** @internal */
30exports.eventType = "google.firebase.testlab.testMatrix.v1.completed";
31/**
32 * Event handler which triggers when a Firebase test matrix completes.
33 *
34 * @param optsOrHandler - Options or an event handler.
35 * @param handler - Event handler which is run every time a Firebase test matrix completes.
36 * @returns A Cloud Function that you can export and deploy.
37 * @alpha
38 */
39function onTestMatrixCompleted(optsOrHandler, handler) {
40 var _a;
41 if (typeof optsOrHandler === "function") {
42 handler = optsOrHandler;
43 optsOrHandler = {};
44 }
45 const baseOpts = (0, options_1.optionsToEndpoint)((0, options_1.getGlobalOptions)());
46 const specificOpts = (0, options_1.optionsToEndpoint)(optsOrHandler);
47 const func = (raw) => {
48 return (0, trace_1.wrapTraceContext)((0, onInit_1.withInit)(handler))(raw);
49 };
50 func.run = handler;
51 const ep = {
52 ...(0, manifest_1.initV2Endpoint)((0, options_1.getGlobalOptions)(), optsOrHandler),
53 platform: "gcfv2",
54 ...baseOpts,
55 ...specificOpts,
56 labels: {
57 ...baseOpts === null || baseOpts === void 0 ? void 0 : baseOpts.labels,
58 ...specificOpts === null || specificOpts === void 0 ? void 0 : specificOpts.labels,
59 },
60 eventTrigger: {
61 eventType: exports.eventType,
62 eventFilters: {},
63 retry: (_a = optsOrHandler.retry) !== null && _a !== void 0 ? _a : false,
64 },
65 };
66 func.__endpoint = ep;
67 return func;
68}
69exports.onTestMatrixCompleted = onTestMatrixCompleted;