@wix/cli
Version:
CLI tool for building Wix sites and applications
1,239 lines (1,179 loc) • 41.5 kB
JavaScript
import { createRequire as _createRequire } from 'node:module';
const require = _createRequire(import.meta.url);
import {
require_kebabCase
} from "./chunk-7QTVQZAE.js";
import {
createEnv,
extractHttpError
} from "./chunk-U5H3SP3I.js";
import {
require_react
} from "./chunk-QNHANFRW.js";
import {
readUserConfig
} from "./chunk-4EJ5VQTT.js";
import {
getTestOverrides
} from "./chunk-XZUGLEBK.js";
import {
CliSystemErrorCode,
require_lib,
require_verror
} from "./chunk-CO5A7CZG.js";
import {
__commonJS,
__toESM,
init_esm_shims
} from "./chunk-EXLZF52D.js";
// ../../node_modules/@babel/runtime/helpers/typeof.js
var require_typeof = __commonJS({
"../../node_modules/@babel/runtime/helpers/typeof.js"(exports, module) {
"use strict";
init_esm_shims();
function _typeof(o) {
"@babel/helpers - typeof";
return module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o2) {
return typeof o2;
} : function(o2) {
return o2 && "function" == typeof Symbol && o2.constructor === Symbol && o2 !== Symbol.prototype ? "symbol" : typeof o2;
}, module.exports.__esModule = true, module.exports["default"] = module.exports, _typeof(o);
}
module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
}
});
// ../../node_modules/@babel/runtime/helpers/toPrimitive.js
var require_toPrimitive = __commonJS({
"../../node_modules/@babel/runtime/helpers/toPrimitive.js"(exports, module) {
"use strict";
init_esm_shims();
var _typeof = require_typeof()["default"];
function toPrimitive(t, r) {
if ("object" != _typeof(t) || !t) return t;
var e = t[Symbol.toPrimitive];
if (void 0 !== e) {
var i = e.call(t, r || "default");
if ("object" != _typeof(i)) return i;
throw new TypeError("@@toPrimitive must return a primitive value.");
}
return ("string" === r ? String : Number)(t);
}
module.exports = toPrimitive, module.exports.__esModule = true, module.exports["default"] = module.exports;
}
});
// ../../node_modules/@babel/runtime/helpers/toPropertyKey.js
var require_toPropertyKey = __commonJS({
"../../node_modules/@babel/runtime/helpers/toPropertyKey.js"(exports, module) {
"use strict";
init_esm_shims();
var _typeof = require_typeof()["default"];
var toPrimitive = require_toPrimitive();
function toPropertyKey(t) {
var i = toPrimitive(t, "string");
return "symbol" == _typeof(i) ? i : i + "";
}
module.exports = toPropertyKey, module.exports.__esModule = true, module.exports["default"] = module.exports;
}
});
// ../../node_modules/@babel/runtime/helpers/defineProperty.js
var require_defineProperty = __commonJS({
"../../node_modules/@babel/runtime/helpers/defineProperty.js"(exports, module) {
"use strict";
init_esm_shims();
var toPropertyKey = require_toPropertyKey();
function _defineProperty7(e, r, t) {
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
value: t,
enumerable: true,
configurable: true,
writable: true
}) : e[r] = t, e;
}
module.exports = _defineProperty7, module.exports.__esModule = true, module.exports["default"] = module.exports;
}
});
// ../cli-panorama/src/PanoramaContext.tsx
init_esm_shims();
var import_react = __toESM(require_react(), 1);
var PanoramaContext = (0, import_react.createContext)(void 0);
var PanoramaProvider = (props) => {
const { value, children } = props;
return /* @__PURE__ */ import_react.default.createElement(PanoramaContext.Provider, { value }, children);
};
// ../cli-panorama/src/createPanorama.ts
init_esm_shims();
var import_verror = __toESM(require_verror(), 1);
var import_variant = __toESM(require_lib(), 1);
// ../../node_modules/@wix/panorama-client-node/dist/esm/index.js
init_esm_shims();
// ../../node_modules/@wix/panorama-client-node/dist/esm/panorama-client-node.js
init_esm_shims();
// ../../node_modules/@wix/panorama-client-node/node_modules/@wix/panorama-client/dist/esm/index.js
init_esm_shims();
// ../../node_modules/@wix/panorama-client-node/node_modules/@wix/panorama-common-shared/dist/esm/types/index.js
init_esm_shims();
// ../../node_modules/@wix/panorama-client-node/node_modules/@wix/panorama-common-shared/dist/esm/types/enum-types.js
init_esm_shims();
var AlertType;
(function(AlertType2) {
AlertType2["SuccessRate"] = "SuccessRate";
AlertType2["SuccessRateQuality"] = "SuccessRateQuality";
AlertType2["Duration"] = "Duration";
AlertType2["ErrorRate"] = "ErrorRate";
})(AlertType || (AlertType = {}));
var AlertStatus;
(function(AlertStatus2) {
AlertStatus2["Alerting"] = "alerting";
AlertStatus2["Ok"] = "ok";
})(AlertStatus || (AlertStatus = {}));
var LogLevel;
(function(LogLevel2) {
LogLevel2["Info"] = "INFO";
LogLevel2["Warn"] = "WARN";
LogLevel2["Error"] = "ERROR";
LogLevel2["Debug"] = "DEBUG";
})(LogLevel || (LogLevel = {}));
var TransactionAction;
(function(TransactionAction2) {
TransactionAction2["Start"] = "START";
TransactionAction2["Finish"] = "FINISH";
})(TransactionAction || (TransactionAction = {}));
var InternalTransactions = {
ComponentLoad: "PANORAMA_COMPONENT_LOAD",
ComponentPhase: "PANORAMA_COMPONENT_PHASE"
};
var Platform;
(function(Platform2) {
Platform2["Standalone"] = "standalone";
Platform2["BusinessManager"] = "business-manager";
Platform2["Viewer"] = "viewer";
Platform2["Editor"] = "editor";
Platform2["EditorSettings"] = "editor:settings";
Platform2["Mobile"] = "mobile";
Platform2["Standards"] = "standards";
Platform2["DevPortal"] = "dev-portal";
})(Platform || (Platform = {}));
var ErrorSeverity;
(function(ErrorSeverity2) {
ErrorSeverity2["Fatal"] = "fatal";
ErrorSeverity2["Error"] = "error";
ErrorSeverity2["Warning"] = "warning";
ErrorSeverity2["Log"] = "log";
ErrorSeverity2["Info"] = "info";
ErrorSeverity2["Debug"] = "debug";
ErrorSeverity2["Critical"] = "critical";
})(ErrorSeverity || (ErrorSeverity = {}));
// ../../node_modules/@wix/panorama-client-node/node_modules/@wix/panorama-common-shared/dist/esm/types/data-types.js
init_esm_shims();
// ../../node_modules/@wix/panorama-client-node/node_modules/@wix/panorama-common-shared/dist/esm/types/interface-types.js
init_esm_shims();
// ../../node_modules/@wix/panorama-client-node/node_modules/@wix/panorama-common/dist/esm/global-config/index.js
init_esm_shims();
// ../../node_modules/@wix/panorama-client-node/node_modules/@wix/panorama-common/dist/esm/global-config/global-config.js
init_esm_shims();
// ../../node_modules/uuid/dist/esm-node/index.js
init_esm_shims();
// ../../node_modules/uuid/dist/esm-node/rng.js
init_esm_shims();
import crypto from "crypto";
var rnds8Pool = new Uint8Array(256);
var poolPtr = rnds8Pool.length;
function rng() {
if (poolPtr > rnds8Pool.length - 16) {
crypto.randomFillSync(rnds8Pool);
poolPtr = 0;
}
return rnds8Pool.slice(poolPtr, poolPtr += 16);
}
// ../../node_modules/uuid/dist/esm-node/stringify.js
init_esm_shims();
var byteToHex = [];
for (let i = 0; i < 256; ++i) {
byteToHex.push((i + 256).toString(16).slice(1));
}
function unsafeStringify(arr, offset = 0) {
return byteToHex[arr[offset + 0]] + byteToHex[arr[offset + 1]] + byteToHex[arr[offset + 2]] + byteToHex[arr[offset + 3]] + "-" + byteToHex[arr[offset + 4]] + byteToHex[arr[offset + 5]] + "-" + byteToHex[arr[offset + 6]] + byteToHex[arr[offset + 7]] + "-" + byteToHex[arr[offset + 8]] + byteToHex[arr[offset + 9]] + "-" + byteToHex[arr[offset + 10]] + byteToHex[arr[offset + 11]] + byteToHex[arr[offset + 12]] + byteToHex[arr[offset + 13]] + byteToHex[arr[offset + 14]] + byteToHex[arr[offset + 15]];
}
// ../../node_modules/uuid/dist/esm-node/v4.js
init_esm_shims();
// ../../node_modules/uuid/dist/esm-node/native.js
init_esm_shims();
import crypto2 from "crypto";
var native_default = {
randomUUID: crypto2.randomUUID
};
// ../../node_modules/uuid/dist/esm-node/v4.js
function v4(options, buf, offset) {
if (native_default.randomUUID && !buf && !options) {
return native_default.randomUUID();
}
options = options || {};
const rnds = options.random || (options.rng || rng)();
rnds[6] = rnds[6] & 15 | 64;
rnds[8] = rnds[8] & 63 | 128;
if (buf) {
offset = offset || 0;
for (let i = 0; i < 16; ++i) {
buf[offset + i] = rnds[i];
}
return buf;
}
return unsafeStringify(rnds);
}
var v4_default = v4;
// ../../node_modules/@wix/panorama-client-node/node_modules/@wix/panorama-common/dist/esm/duration-tracker/index.js
init_esm_shims();
// ../../node_modules/@wix/panorama-client-node/node_modules/@wix/panorama-common/dist/esm/duration-tracker/duration-tracker.js
init_esm_shims();
var DELIMITER = " | ";
var DurationTrackerImpl = class {
constructor() {
this.transactionStartTimes = {};
this.phaseStartTimes = {};
}
createKey(...args) {
return args.filter((x) => !!x).join(DELIMITER);
}
markTransactionStart(fullArtifactId, componentId, transactionName, transactionId) {
const key = this.createKey(fullArtifactId, componentId, transactionName, transactionId);
this.transactionStartTimes[key] = Date.now();
}
markTransactionFinish(fullArtifactId, componentId, transactionName, transactionId) {
const key = this.createKey(fullArtifactId, componentId, transactionName, transactionId);
const finishTime = Date.now();
const startTime = this.transactionStartTimes[key] || finishTime;
const duration = Math.round(finishTime - startTime);
this.transactionStartTimes[key] = 0;
return duration;
}
markPhaseStart(fullArtifactId, componentId, phaseName) {
const key = this.createKey(fullArtifactId, componentId, phaseName);
this.phaseStartTimes[key] = Date.now();
}
markPhaseFinish(fullArtifactId, componentId, phaseName) {
const key = this.createKey(fullArtifactId, componentId, phaseName);
const finishTime = Date.now();
const startTime = this.phaseStartTimes[key] || finishTime;
const duration = Math.round(finishTime - startTime);
this.phaseStartTimes[key] = 0;
return duration;
}
};
var createDurationTracker = () => new DurationTrackerImpl();
// ../../node_modules/@wix/panorama-client-node/node_modules/@wix/panorama-common/dist/esm/global-config/global-config.js
var GlobalConfigImpl = class {
constructor() {
this.sessionId = "";
this.reporter = null;
this.batchQueue = null;
this.durationTracker = createDurationTracker();
this.state = /* @__PURE__ */ new Map();
this.sessionStart = Date.now();
}
getSessionId() {
this.sessionId = this.sessionId || v4_default();
return this.sessionId;
}
setSessionId(sessionId) {
this.sessionId = sessionId;
}
getSessionTime() {
return Date.now() - this.sessionStart;
}
getReporter() {
return this.reporter;
}
setReporter(reporter) {
this.reporter = reporter;
}
initBatchQueue(batchQueue) {
this.batchQueue = this.batchQueue ?? batchQueue;
}
getBatchQueue() {
return this.batchQueue;
}
getDurationTracker() {
return this.durationTracker;
}
getStateValue(key) {
return this.state.get(key);
}
setStateValue(key, value) {
this.state.set(key, value);
}
clearState() {
this.state.clear();
this.durationTracker = createDurationTracker();
}
};
var createGlobalConfig = () => new GlobalConfigImpl();
// ../../node_modules/@wix/panorama-client-node/node_modules/@wix/panorama-client/dist/esm/panorama-client-factory.js
init_esm_shims();
var import_defineProperty6 = __toESM(require_defineProperty());
// ../../node_modules/@wix/panorama-client-node/node_modules/@wix/panorama-common/dist/esm/utils/index.js
init_esm_shims();
// ../../node_modules/@wix/panorama-client-node/node_modules/@wix/panorama-common/dist/esm/utils/class-utils.js
init_esm_shims();
var bindPrototypeMethodsToSelf = (instance, classFn) => {
const prototype = classFn ? classFn.prototype : Object.getPrototypeOf(instance);
const props = Object.getOwnPropertyNames(prototype);
for (const prop of props) {
if (prop === "constructor" || typeof prototype[prop] !== "function") {
continue;
}
instance[prop] = prototype[prop].bind(instance);
}
};
// ../../node_modules/@wix/panorama-client-node/node_modules/@wix/panorama-client/dist/esm/utils/general-utils.js
init_esm_shims();
var union = function() {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return [...new Set(args.flat()).values()];
};
var defaults = function() {
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
args[_key2] = arguments[_key2];
}
return args.reduce((res, obj) => Object.entries(obj ?? {}).reduce((_res, _ref) => {
let [key, value] = _ref;
if (typeof _res[key] === "undefined" && typeof value !== "undefined") {
_res[key] = value;
}
return _res;
}, res), {});
};
var deepDefaults = function(dest) {
for (var _len3 = arguments.length, rest = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
rest[_key3 - 1] = arguments[_key3];
}
const keys = union(...rest.map((value) => Object.keys(value ?? {})));
const all = [dest, ...rest];
return keys.reduce((res, key) => {
const values = all.map((value) => value == null ? void 0 : value[key]);
const merged = defaults(...values);
const hasValues = Object.values(merged).filter((value) => typeof value !== "undefined").length > 0;
if (hasValues) {
res = res ?? {};
res[key] = merged;
} else {
var _res2;
(_res2 = res) == null || delete _res2[key];
}
return res;
}, dest ? {
...dest
} : dest);
};
// ../../node_modules/@wix/panorama-client-node/node_modules/@wix/panorama-client/dist/esm/panorama-client.js
init_esm_shims();
var import_defineProperty3 = __toESM(require_defineProperty());
// ../../node_modules/@wix/panorama-client-node/node_modules/@wix/panorama-client/dist/esm/panorama-client-component.js
init_esm_shims();
var import_defineProperty = __toESM(require_defineProperty());
// ../../node_modules/@wix/panorama-client-node/node_modules/@wix/panorama-client/dist/esm/panorama-error-monitor.js
init_esm_shims();
var PanoramaErrorMonitorImpl = class {
constructor(baseClient, options) {
this.baseClient = baseClient;
this.options = options;
bindPrototypeMethodsToSelf(this);
}
reportError(error, data) {
this.baseClient.reportError(error, data, this.options);
}
addBreadcrumb(breadcrumb) {
this.baseClient.addBreadcrumb(breadcrumb);
}
};
// ../../node_modules/@wix/panorama-client-node/node_modules/@wix/panorama-client/dist/esm/panorama-logger.js
init_esm_shims();
var PanoramaLoggerImpl = class {
constructor(baseClient) {
this.baseClient = baseClient;
bindPrototypeMethodsToSelf(this);
}
info(message, data) {
this.baseClient.log(LogLevel.Info, message, data);
}
warn(message, data) {
this.baseClient.log(LogLevel.Warn, message, data);
}
error(message, data) {
this.baseClient.log(LogLevel.Error, message, data);
}
debug(message, data) {
this.baseClient.log(LogLevel.Debug, message, data);
}
};
// ../../node_modules/@wix/panorama-client-node/node_modules/@wix/panorama-client/dist/esm/panorama-transaction.js
init_esm_shims();
// ../../node_modules/@wix/panorama-client-node/node_modules/@wix/panorama-common-shared/dist/esm/utils/index.js
init_esm_shims();
// ../../node_modules/@wix/panorama-client-node/node_modules/@wix/panorama-common-shared/dist/esm/utils/transaction-utils.js
init_esm_shims();
var isCustomTransactionName = (name) => !Object.values(InternalTransactions).includes(name);
// ../../node_modules/@wix/panorama-client-node/node_modules/@wix/panorama-common-shared/dist/esm/utils/platform-utils.js
init_esm_shims();
// ../../node_modules/@wix/panorama-client-node/node_modules/@wix/panorama-common-shared/dist/esm/utils/guid.js
init_esm_shims();
// ../../node_modules/@wix/panorama-client-node/node_modules/@wix/panorama-client/dist/esm/panorama-transaction.js
var PanoramaTransactionImpl = class {
constructor(baseClient, name, options) {
this.baseClient = baseClient;
this.name = name;
this.options = options;
if (!isCustomTransactionName(name)) {
throw new Error(`"${name}" is an internal transaction and can't be used`);
}
this.baseClient = baseClient;
bindPrototypeMethodsToSelf(this);
}
start(data, options) {
return this.baseClient.reportTransactionStart(this.name, defaults(options, this.options), data);
}
finish(data, options) {
return this.baseClient.reportTransactionFinish(this.name, defaults(options, this.options), data);
}
};
// ../../node_modules/@wix/panorama-client-node/node_modules/@wix/panorama-client/dist/esm/panorama-client-component.js
var PanoramaClientForComponentImpl = class {
constructor(_ref) {
let {
baseClient
} = _ref;
(0, import_defineProperty.default)(this, "baseClient", void 0);
this.baseClient = baseClient;
bindPrototypeMethodsToSelf(this);
}
transaction(name, options) {
return new PanoramaTransactionImpl(this.baseClient, name, options);
}
errorMonitor(options) {
return new PanoramaErrorMonitorImpl(this.baseClient, options);
}
logger() {
return new PanoramaLoggerImpl(this.baseClient);
}
};
// ../../node_modules/@wix/panorama-client-node/node_modules/@wix/panorama-client/dist/esm/plugins/hooks-manager.js
init_esm_shims();
var import_defineProperty2 = __toESM(require_defineProperty());
var Hook = /* @__PURE__ */ function(Hook2) {
Hook2[Hook2["afterCreateClientForComponent"] = 0] = "afterCreateClientForComponent";
Hook2[Hook2["beforeReport"] = 1] = "beforeReport";
Hook2[Hook2["beforeReportTransactionStart"] = 2] = "beforeReportTransactionStart";
Hook2[Hook2["afterReportTransactionStart"] = 3] = "afterReportTransactionStart";
Hook2[Hook2["beforeReportTransactionFinish"] = 4] = "beforeReportTransactionFinish";
Hook2[Hook2["afterReportTransactionFinish"] = 5] = "afterReportTransactionFinish";
Hook2[Hook2["beforeReportPhaseStart"] = 6] = "beforeReportPhaseStart";
Hook2[Hook2["afterReportPhaseStart"] = 7] = "afterReportPhaseStart";
Hook2[Hook2["beforeReportPhaseFinish"] = 8] = "beforeReportPhaseFinish";
Hook2[Hook2["afterReportPhaseFinish"] = 9] = "afterReportPhaseFinish";
Hook2[Hook2["beforeReportError"] = 10] = "beforeReportError";
Hook2[Hook2["afterReportError"] = 11] = "afterReportError";
Hook2[Hook2["beforeAddBreadcrumb"] = 12] = "beforeAddBreadcrumb";
Hook2[Hook2["afterAddBreadcrumb"] = 13] = "afterAddBreadcrumb";
Hook2[Hook2["beforeReportLog"] = 14] = "beforeReportLog";
Hook2[Hook2["afterReportLog"] = 15] = "afterReportLog";
Hook2[Hook2["beforeUnhandledError"] = 16] = "beforeUnhandledError";
return Hook2;
}({});
var HooksManager = class {
constructor() {
(0, import_defineProperty2.default)(this, "subscribers", {});
}
tap(hook, subscriber) {
this.subscribers[hook] = this.subscribers[hook] || [];
this.subscribers[hook].push(subscriber);
}
invoke(hook) {
const subscribers = this.subscribers[hook];
if (!subscribers) {
return true;
}
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
args[_key - 1] = arguments[_key];
}
for (const subscriber of subscribers) {
if (subscriber(...args) === false) {
return false;
}
}
return true;
}
};
// ../../node_modules/@wix/panorama-client-node/node_modules/@wix/panorama-client/dist/esm/panorama-phase.js
init_esm_shims();
var PanoramaPhaseImpl = class {
constructor(name, baseClient) {
this.name = name;
this.baseClient = baseClient;
this.baseClient = baseClient;
bindPrototypeMethodsToSelf(this);
}
start(data) {
return this.baseClient.reportPhaseStart(this.name, data);
}
finish(data) {
return this.baseClient.reportPhaseFinish(this.name, data);
}
};
// ../../node_modules/@wix/panorama-client-node/node_modules/@wix/panorama-client/dist/esm/panorama-client.js
var PanoramaClientImpl = class {
constructor(_ref) {
let {
hooksManager,
baseClient
} = _ref;
(0, import_defineProperty3.default)(this, "baseClient", void 0);
(0, import_defineProperty3.default)(this, "hooksManager", void 0);
this.baseClient = baseClient;
this.hooksManager = hooksManager;
bindPrototypeMethodsToSelf(this);
}
onUnhandledError(subscriber) {
this.hooksManager.tap(Hook.beforeUnhandledError, subscriber);
}
reportLoadStart(data, options) {
const {
ComponentLoad
} = InternalTransactions;
return this.baseClient.reportTransactionStart(ComponentLoad, options, data);
}
reportLoadFinish(data, options) {
const {
ComponentLoad
} = InternalTransactions;
return this.baseClient.reportTransactionFinish(ComponentLoad, options, data);
}
phase(name) {
return new PanoramaPhaseImpl(name, this.baseClient);
}
transaction(name, options) {
return new PanoramaTransactionImpl(this.baseClient, name, options);
}
errorMonitor(options) {
return new PanoramaErrorMonitorImpl(this.baseClient, options);
}
logger() {
return new PanoramaLoggerImpl(this.baseClient);
}
createClientForComponent() {
const client = new PanoramaClientForComponentImpl({
baseClient: this.baseClient
});
this.hooksManager.invoke(Hook.afterCreateClientForComponent, client);
return client;
}
};
// ../../node_modules/@wix/panorama-client-node/node_modules/@wix/panorama-client/dist/esm/panorama-client-base.js
init_esm_shims();
var import_defineProperty4 = __toESM(require_defineProperty());
// ../../node_modules/@wix/panorama-client-node/node_modules/@wix/panorama-client/dist/esm/lib/payload-builder.js
init_esm_shims();
// ../../node_modules/@wix/panorama-client-node/node_modules/@wix/panorama-client/dist/esm/utils/error-utils.js
init_esm_shims();
var extractWixHttpErrorDetailsRec = (error) => {
var _httpClientError$resp;
if (!(error instanceof Error)) {
return {};
}
const res = extractWixHttpErrorDetailsRec(error.cause);
const httpClientError = error;
return defaults(res, {
isWixHttpError: httpClientError.isWixHttpError,
requestId: ((_httpClientError$resp = httpClientError.response) == null || (_httpClientError$resp = _httpClientError$resp.headers) == null ? void 0 : _httpClientError$resp["x-wix-request-id"]) ?? httpClientError.requestId
});
};
var extractWixHttpErrorDetails = (error) => defaults(extractWixHttpErrorDetailsRec(error), {
isWixHttpError: false,
requestId: ""
});
// ../../node_modules/@wix/panorama-client-node/node_modules/@wix/panorama-client/dist/esm/lib/payload-sanitizer.js
init_esm_shims();
// ../../node_modules/@wix/panorama-client-node/node_modules/@wix/panorama-client/dist/esm/constants.js
init_esm_shims();
var MAX_STACK_TRACE_SIZE_BYTES = 32 * 1024;
var MAX_SESSION_TIME_MS = 24 * 60 * 60 * 1e3;
// ../../node_modules/@wix/panorama-client-node/node_modules/@wix/panorama-client/dist/esm/lib/payload-sanitizer.js
var sanitizePayload = (payload) => {
const {
errorStack,
sessionTime
} = payload;
if (errorStack && errorStack.length > MAX_STACK_TRACE_SIZE_BYTES) {
const truncationMessage = `...[truncated by Panorama client to ${MAX_STACK_TRACE_SIZE_BYTES / 1024}kb]`;
const truncatedErrorStack = errorStack.substring(0, MAX_STACK_TRACE_SIZE_BYTES - truncationMessage.length);
payload = {
...payload,
errorStack: `${truncatedErrorStack}${truncationMessage}`
};
}
if (sessionTime && sessionTime > MAX_SESSION_TIME_MS) {
payload = {
...payload,
sessionTime: MAX_SESSION_TIME_MS
};
}
return payload;
};
// ../../node_modules/@wix/panorama-client-node/node_modules/@wix/panorama-client/dist/esm/lib/payload-builder.js
var getSessionParams = (globalConfig2) => {
const sessionId = globalConfig2.getSessionId();
const sessionTime = Math.round(globalConfig2.getSessionTime());
return {
sessionId,
sessionTime
};
};
var buildTransactionPayload = (globalConfig2, baseParams, transactionParams, data) => {
const {
transactionName,
transactionAction
} = transactionParams;
const {
sessionId,
sessionTime
} = getSessionParams(globalConfig2);
const logLevel = LogLevel.Info;
const message = `Panorama ${transactionName} ${transactionAction}`;
const requestId = "";
return sanitizePayload({
...baseParams,
...transactionParams,
sessionId,
sessionTime,
logLevel,
requestId,
message,
data
});
};
var buildPhasePayload = (globalConfig2, baseParams, phaseParams, data) => {
const transactionName = InternalTransactions.ComponentPhase;
const {
phaseName,
transactionAction
} = phaseParams;
const {
sessionId,
sessionTime
} = getSessionParams(globalConfig2);
const logLevel = LogLevel.Info;
const message = `Panorama ${phaseName} phase ${transactionAction}`;
const requestId = "";
return sanitizePayload({
...baseParams,
...phaseParams,
transactionName,
sessionId,
sessionTime,
logLevel,
requestId,
message,
data
});
};
var buildErrorPayload = (globalConfig2, baseParams, error, data) => {
const {
sessionId,
sessionTime
} = getSessionParams(globalConfig2);
const {
constructor,
message,
stack = ""
} = error;
const logLevel = LogLevel.Error;
const {
requestId
} = extractWixHttpErrorDetails(error);
return sanitizePayload({
...baseParams,
sessionId,
sessionTime,
logLevel,
requestId,
data,
errorName: (data == null ? void 0 : data.errorName) ?? constructor.name,
errorStack: stack,
message
});
};
var buildLoggerPayload = (globalConfig2, baseParams, loggerParams) => {
const {
sessionId,
sessionTime
} = getSessionParams(globalConfig2);
const requestId = "";
return sanitizePayload({
...baseParams,
...loggerParams,
sessionId,
sessionTime,
requestId
});
};
// ../../node_modules/@wix/panorama-client-node/node_modules/@wix/panorama-client/dist/esm/panorama-client-base.js
var BasePanoramaClient = class {
constructor(_ref) {
var _this = this;
let {
baseParams,
globalConfig: globalConfig2,
reporter,
hooksManager,
data,
isMuted
} = _ref;
(0, import_defineProperty4.default)(this, "durationTracker", void 0);
(0, import_defineProperty4.default)(this, "baseParams", void 0);
(0, import_defineProperty4.default)(this, "globalConfig", void 0);
(0, import_defineProperty4.default)(this, "reporter", void 0);
(0, import_defineProperty4.default)(this, "hooksManager", void 0);
(0, import_defineProperty4.default)(this, "data", void 0);
(0, import_defineProperty4.default)(this, "isMuted", void 0);
(0, import_defineProperty4.default)(this, "getErrorMonitorDataWithDefaults", function() {
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _this.data.addDataScope(args).getData();
});
this.baseParams = baseParams;
this.globalConfig = globalConfig2;
this.reporter = reporter;
this.hooksManager = hooksManager;
this.data = data;
this.isMuted = isMuted;
this.durationTracker = typeof globalConfig2.getDurationTracker === "function" ? globalConfig2.getDurationTracker() : createDurationTracker();
}
report(eventPayload) {
if (this.isMuted()) {
return;
}
const reporterOverride = this.globalConfig.getReporter();
const beforeReportHookResult = this.hooksManager.invoke(Hook.beforeReport, eventPayload);
if (typeof reporterOverride === "function") {
reporterOverride(eventPayload);
return;
}
if (!beforeReportHookResult) {
return;
}
this.reporter(eventPayload);
}
reportTransactionStart(name, options, data) {
if (options === void 0) {
options = {};
}
const {
id
} = options;
const dataWithDefault = this.data.addDataScope(data).getData();
if (!this.hooksManager.invoke(Hook.beforeReportTransactionStart, name, dataWithDefault)) {
return;
}
const {
fullArtifactId,
componentId
} = this.baseParams;
this.durationTracker.markTransactionStart(fullArtifactId, componentId, name, id);
const payload = buildTransactionPayload(this.globalConfig, this.baseParams, {
transactionName: name,
transactionAction: TransactionAction.Start
}, dataWithDefault);
this.report(payload);
this.hooksManager.invoke(Hook.afterReportTransactionStart, name, payload);
}
reportTransactionFinish(name, options, data) {
if (options === void 0) {
options = {};
}
const {
id
} = options;
const dataWithDefault = this.data.addDataScope(data).getData();
if (!this.hooksManager.invoke(Hook.beforeReportTransactionFinish, name, dataWithDefault)) {
return;
}
const {
fullArtifactId,
componentId
} = this.baseParams;
const duration = this.durationTracker.markTransactionFinish(fullArtifactId, componentId, name, id);
const payload = buildTransactionPayload(this.globalConfig, this.baseParams, {
transactionName: name,
transactionAction: TransactionAction.Finish,
transactionDuration: duration
}, dataWithDefault);
this.report(payload);
this.hooksManager.invoke(Hook.afterReportTransactionFinish, name, payload);
}
reportPhaseStart(name, data) {
const dataWithDefault = this.data.addDataScope(data).getData();
if (!this.hooksManager.invoke(Hook.beforeReportPhaseStart, name, dataWithDefault)) {
return;
}
const {
fullArtifactId,
componentId
} = this.baseParams;
this.durationTracker.markPhaseStart(fullArtifactId, componentId, name);
const payload = buildPhasePayload(this.globalConfig, this.baseParams, {
phaseName: name,
transactionAction: TransactionAction.Start
}, dataWithDefault);
this.report(payload);
this.hooksManager.invoke(Hook.afterReportPhaseStart, name, payload);
}
reportPhaseFinish(name, data) {
const dataWithDefault = this.data.addDataScope(data).getData();
if (!this.hooksManager.invoke(Hook.beforeReportPhaseFinish, name, dataWithDefault)) {
return;
}
const {
fullArtifactId,
componentId
} = this.baseParams;
const duration = this.durationTracker.markPhaseFinish(fullArtifactId, componentId, name);
const payload = buildPhasePayload(this.globalConfig, this.baseParams, {
phaseName: name,
transactionAction: TransactionAction.Finish,
transactionDuration: duration
}, dataWithDefault);
this.report(payload);
this.hooksManager.invoke(Hook.afterReportPhaseFinish, name, payload);
}
reportError(error, data, options) {
if (!(error instanceof Error)) {
return;
}
data = this.data.addDataScope([data, options == null ? void 0 : options.data]).getData();
if (!this.hooksManager.invoke(Hook.beforeReportError, error, data, options)) {
return;
}
const payload = buildErrorPayload(this.globalConfig, this.baseParams, error, data);
this.report(payload);
this.hooksManager.invoke(Hook.afterReportError, error, data, options);
}
addBreadcrumb(breadcrumb) {
if (!this.hooksManager.invoke(Hook.beforeAddBreadcrumb, breadcrumb)) {
return;
}
this.hooksManager.invoke(Hook.afterAddBreadcrumb, breadcrumb);
}
log(logLevel, message, data) {
if (!message) {
return;
}
const dataWithDefault = this.data.addDataScope(data).getData();
const loggerParams = {
message,
data: dataWithDefault,
logLevel
};
if (!this.hooksManager.invoke(Hook.beforeReportLog, logLevel, message, dataWithDefault)) {
return;
}
const payload = buildLoggerPayload(this.globalConfig, this.baseParams, loggerParams);
this.report(payload);
this.hooksManager.invoke(Hook.afterReportLog, logLevel, message, dataWithDefault);
}
};
// ../../node_modules/@wix/panorama-client-node/node_modules/@wix/panorama-client/dist/esm/lib/scope.js
init_esm_shims();
var import_defineProperty5 = __toESM(require_defineProperty());
var Scope = class _Scope {
constructor(data) {
(0, import_defineProperty5.default)(this, "data", void 0);
this.data = data;
}
getEntriesToDeepDefaults(data) {
if (!data) {
return void 0;
}
return Object.fromEntries(Object.entries(data).filter((_ref) => {
let [key] = _ref;
return _Scope.KEYS_TO_DEEP_DEFAULTS.includes(key);
}));
}
addDataScope(data) {
const outerDataArray = Array.isArray(data) ? data : [data];
const deepDefaultData = deepDefaults(...outerDataArray.map((_data) => this.getEntriesToDeepDefaults(_data)), this.getEntriesToDeepDefaults(this.data));
return new _Scope(defaults(deepDefaultData, ...outerDataArray, this.data));
}
getData() {
return this.data;
}
};
(0, import_defineProperty5.default)(Scope, "KEYS_TO_DEEP_DEFAULTS", ["tags", "context"]);
// ../../node_modules/@wix/panorama-client-node/node_modules/@wix/panorama-client/dist/esm/panorama-client-factory.js
var PanoramaClientFactoryImpl = class {
constructor(options) {
this.options = options;
(0, import_defineProperty6.default)(this, "globalConfig", void 0);
(0, import_defineProperty6.default)(this, "reporter", () => true);
(0, import_defineProperty6.default)(this, "plugins", []);
(0, import_defineProperty6.default)(this, "isMuted", false);
bindPrototypeMethodsToSelf(this);
}
withGlobalConfig(globalConfig2) {
this.globalConfig = globalConfig2;
return this;
}
withReporter(reporter) {
this.reporter = reporter;
return this;
}
setMuted(isMuted) {
this.isMuted = isMuted;
return this;
}
use(plugin) {
this.plugins.push(plugin);
return this;
}
client(options) {
if (options === void 0) {
options = {};
}
const {
pluginParams
} = options;
const globalConfig2 = this.globalConfig ?? createGlobalConfig();
const reporter = this.reporter;
const hooksManager = new HooksManager();
const baseParams = defaults(options.baseParams, this.options.baseParams);
const data = new Scope(this.options.data).addDataScope(options.data);
const pluginClientParams = pluginParams ?? {};
const baseClient = new BasePanoramaClient({
baseParams,
globalConfig: globalConfig2,
isMuted: () => this.isMuted,
reporter,
hooksManager,
data
});
const client = new PanoramaClientImpl({
baseClient,
hooksManager
});
this.plugins.forEach((plugin) => plugin({
hooksManager,
globalConfig: globalConfig2,
reporter,
baseClient,
baseParams,
pluginParams: pluginClientParams
}));
return client;
}
};
var panoramaClient = function(options) {
if (options === void 0) {
options = {};
}
return new PanoramaClientFactoryImpl(options);
};
// ../../node_modules/@wix/panorama-client-node/node_modules/@wix/panorama-common-shared/dist/esm/constants.js
init_esm_shims();
var CLICKHOUSE_REPORT_URL = "https://panorama.wixapps.net/api/v1/log";
// ../../node_modules/@wix/panorama-client-node/dist/esm/reporter.js
init_esm_shims();
var nodeReporter = function(url, _temp) {
let {
silent = false
} = _temp === void 0 ? {
silent: false
} : _temp;
return (eventPayload) => {
const body = JSON.stringify({
logMessage: eventPayload
});
fetch(url, {
method: "POST",
body
}).then((res) => {
if (res.ok || silent) {
return;
}
console.error("Panorama report failed", res.statusText);
}).catch((e) => {
if (silent) {
return;
}
console.error("Panorama report failed", e);
});
return true;
};
};
// ../../node_modules/@wix/panorama-client-node/dist/esm/panorama-client-node.js
var panoramaClientFactory = (options) => {
const {
baseParams,
reporterOptions,
data
} = options;
const factory = panoramaClient({
baseParams,
data
}).withReporter(nodeReporter(CLICKHOUSE_REPORT_URL, reporterOptions));
factory.use = void 0;
return factory;
};
// ../cli-panorama/src/createPanorama.ts
var globalConfig = createGlobalConfig();
var overrides = getTestOverrides();
if (overrides.panoramaReporterUrl) {
globalConfig.setReporter(
nodeReporter(overrides.panoramaReporterUrl, { silent: true })
);
}
function createPanoramaWrapper(factory) {
let defaultData = {};
return {
withGlobalConfig: (...args) => factory.withGlobalConfig(...args),
withReporter: (...args) => factory.withReporter(...args),
setMuted: (...args) => factory.setMuted(...args),
setDefaultClientData(data) {
defaultData = { ...defaultData, ...data };
},
client(options) {
return factory.client({
...options,
data: { ...defaultData, ...options?.data }
});
}
};
}
async function createPanorama(options) {
const {
version,
artifact,
userId,
errorReporter,
cliSessionId,
aiAgentName
} = options;
const userConfig = await readUserConfig();
const env = createEnv();
const factory = panoramaClientFactory({
baseParams: {
platform: Platform.Standalone,
fullArtifactId: `${artifact.groupId}.${artifact.artifactId}`,
componentId: "app",
// This property is mandatory, there is validation on server side
artifactVersion: version,
uuid: userId
},
reporterOptions: {
silent: true
},
data: {
cliTrackingId: env.cliTrackingId,
cliEnvName: env.cliEnvName,
cliSessionId,
aiAgentName,
...env.remoteLogContext
}
}).withGlobalConfig(globalConfig).setMuted(!userConfig.telemetry);
const panorama = createPanoramaWrapper(factory);
if (errorReporter) {
errorReporter.on("errorReported", (cliError) => {
const panoramaClient2 = panorama.client({
baseParams: {
componentId: "error-reporter"
}
});
const errorMonitor = panoramaClient2.errorMonitor();
const error = (0, import_variant.isType)(cliError.cliCode, CliSystemErrorCode.UnknownFailure) && cliError.cliCode.error instanceof Error ? cliError.cliCode.error : cliError;
const errorToReport = new Error(error.message);
errorToReport.name = error.name;
errorToReport.stack = import_verror.default.fullStack(error);
const httpError = extractHttpError(cliError);
if (httpError) {
errorToReport.cause = httpError;
}
errorMonitor.reportError(errorToReport, {
// panorama by default uses constructor.name for errorName
errorName: cliError.name
});
});
}
return panorama;
}
// ../cli-panorama/src/createCommandTransaction.ts
init_esm_shims();
var import_kebabCase = __toESM(require_kebabCase(), 1);
function createCommandTransaction(panorama, command) {
const commandFullName = (0, import_kebabCase.default)(getFullCommandName(command));
panorama.setDefaultClientData({
commandName: command.name(),
commandFullName
});
const client = panorama.client({
baseParams: {
componentId: "command"
}
});
return client.transaction(commandFullName);
}
function getFullCommandName(command) {
if (command.parent) {
return `${getFullCommandName(command.parent)} ${command.name()}`.trim();
}
return command.name();
}
// ../cli-panorama/src/index.ts
init_esm_shims();
// ../cli-panorama/src/usePanoramaMethodLogger.ts
init_esm_shims();
var import_react2 = __toESM(require_react(), 1);
function usePanoramaMethodLogger(target) {
const factory = (0, import_react2.useContext)(PanoramaContext);
if (factory == null) {
throw new Error(
"usePanoramaMethodLogger() cannot be used without a <PanoramaProvider />"
);
}
const componentId = target.constructor.name;
const clientOptions = (0, import_react2.useMemo)(
() => ({ baseParams: { componentId } }),
[componentId]
);
const client = (0, import_react2.useMemo)(() => {
return factory.client(clientOptions);
}, [factory, clientOptions]);
return (0, import_react2.useMemo)(() => {
const cache = /* @__PURE__ */ new Map();
return new Proxy(target, {
get(target2, prop, receiver) {
const value = Reflect.get(target2, prop, receiver);
const isAsyncMethod = typeof value === "function" && typeof prop === "string" && Object.hasOwn(target2, prop) && value.constructor.name === "AsyncFunction";
if (!isAsyncMethod) {
return value;
}
if (!cache.has(prop)) {
const wrapped = async function(...args) {
const transaction = client.transaction(prop);
transaction.start();
const result = await value.apply(target2, args);
transaction.finish();
return result;
};
cache.set(prop, wrapped);
}
return cache.get(prop);
}
});
}, [target, client]);
}
export {
PanoramaProvider,
usePanoramaMethodLogger,
createPanorama,
createCommandTransaction
};
//# sourceMappingURL=chunk-3B6VL2WO.js.map