allure-js-commons
Advanced tools
Comparing version 3.0.0-beta.11 to 3.0.0-beta.12
@@ -66,2 +66,8 @@ "use strict"; | ||
}); | ||
Object.defineProperty(exports, "serialize", { | ||
enumerable: true, | ||
get: function get() { | ||
return _utils.serialize; | ||
} | ||
}); | ||
Object.defineProperty(exports, "stripAnsi", { | ||
@@ -68,0 +74,0 @@ enumerable: true, |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.stringifyProperties = exports.serialize = exports.readImageAsBase64 = exports.randomUuid = exports.parseProperties = exports.md5 = exports.getWorstStepResultStatusPriority = exports.getWorstStepResultStatus = exports.getTestResultTestCaseId = exports.getTestResultHistoryId = exports.getSuiteLabels = exports.getRelativePath = exports.formatLinks = exports.formatLink = exports.escapeRegExp = exports.ensureSuiteLabels = exports.deepClone = exports.createDefaultWriter = exports.applyLinkTemplate = void 0; | ||
exports.stringifyProperties = exports.readImageAsBase64 = exports.randomUuid = exports.parseProperties = exports.md5 = exports.getWorstStepResultStatusPriority = exports.getWorstStepResultStatus = exports.getTestResultTestCaseId = exports.getTestResultHistoryId = exports.getSuiteLabels = exports.getRelativePath = exports.formatLinks = exports.formatLink = exports.escapeRegExp = exports.ensureSuiteLabels = exports.deepClone = exports.createDefaultWriter = exports.applyLinkTemplate = void 0; | ||
var _promises = require("fs/promises"); | ||
@@ -142,12 +142,2 @@ var _nodeCrypto = require("node:crypto"); | ||
exports.deepClone = deepClone; | ||
var serialize = val => { | ||
if (typeof val === "object" && !(val instanceof Map || val instanceof Set)) { | ||
return JSON.stringify(val); | ||
} | ||
if (val === undefined) { | ||
return "undefined"; | ||
} | ||
return val.toString(); | ||
}; | ||
exports.serialize = serialize; | ||
var getSuiteLabels = suites => { | ||
@@ -154,0 +144,0 @@ if (suites.length === 0) { |
@@ -6,3 +6,3 @@ "use strict"; | ||
}); | ||
exports.stripAnsi = exports.isPromise = exports.isMetadataTag = exports.isAnyStepFailed = exports.isAllStepsEnded = exports.hasStepMessage = exports.hasLabel = exports.getUnfinishedStepsMessages = exports.getStepsMessagesPair = exports.getStatusFromError = exports.getMessageAndTraceFromError = exports.extractMetadataFromString = exports.allureLabelRegexpGlobal = exports.allureLabelRegexp = exports.allureIdRegexpGlobal = exports.allureIdRegexp = void 0; | ||
exports.stripAnsi = exports.serialize = exports.isPromise = exports.isMetadataTag = exports.isAnyStepFailed = exports.isAllStepsEnded = exports.hasStepMessage = exports.hasLabel = exports.getUnfinishedStepsMessages = exports.getStepsMessagesPair = exports.getStatusFromError = exports.getMessageAndTraceFromError = exports.extractMetadataFromString = exports.allureLabelRegexpGlobal = exports.allureLabelRegexp = exports.allureIdRegexpGlobal = exports.allureIdRegexp = void 0; | ||
var _model = require("../model.js"); | ||
@@ -148,2 +148,38 @@ function _wrapRegExp() { _wrapRegExp = function _wrapRegExp(e, r) { return new BabelRegExp(e, void 0, r); }; var e = RegExp.prototype, r = new WeakMap(); function BabelRegExp(e, t, p) { var o = RegExp(e, t); return r.set(o, p || r.get(e)), _setPrototypeOf(o, BabelRegExp.prototype); } function buildGroups(e, t) { var p = r.get(t); return Object.keys(p).reduce(function (r, t) { var o = p[t]; if ("number" == typeof o) r[t] = e[o];else { for (var i = 0; void 0 === e[o[i]] && i + 1 < o.length;) i++; r[t] = e[o[i]]; } return r; }, Object.create(null)); } return _inherits(BabelRegExp, RegExp), BabelRegExp.prototype.exec = function (r) { var t = e.exec.call(this, r); if (t) { t.groups = buildGroups(t, this); var p = t.indices; p && (p.groups = buildGroups(p, this)); } return t; }, BabelRegExp.prototype[Symbol.replace] = function (t, p) { if ("string" == typeof p) { var o = r.get(this); return e[Symbol.replace].call(this, t, p.replace(/\$<([^>]+)>/g, function (e, r) { var t = o[r]; return "$" + (Array.isArray(t) ? t.join("$") : t); })); } if ("function" == typeof p) { var i = this; return e[Symbol.replace].call(this, t, function () { var e = arguments; return "object" != typeof e[e.length - 1] && (e = [].slice.call(e)).push(buildGroups(e, i)), p.apply(this, e); }); } return e[Symbol.replace].call(this, t, p); }, _wrapRegExp.apply(this, arguments); } | ||
exports.isPromise = isPromise; | ||
var serialize = exports.serialize = function serialize(value) { | ||
var { | ||
maxDepth = 0, | ||
maxLength = 0 | ||
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
return limitString(typeof value === "object" ? JSON.stringify(value, createSerializeReplacer(maxDepth)) : String(value), maxLength); | ||
}; | ||
var createSerializeReplacer = maxDepth => { | ||
var parents = []; | ||
return function (_, value) { | ||
if (typeof value !== "object" || value === null) { | ||
return value; | ||
} | ||
while (parents.length > 0 && !Object.is(parents.at(-1), this)) { | ||
parents.pop(); | ||
} | ||
if (maxDepth && parents.length >= maxDepth || parents.includes(value)) { | ||
return undefined; | ||
} | ||
parents.push(value); | ||
return value instanceof Map ? excludeCircularRefsFromMap(parents, value) : value instanceof Set ? excludeCircularRefsFromSet(parents, value) : value; | ||
}; | ||
}; | ||
var excludeCircularRefsFromMap = (parents, map) => { | ||
return Array.from(map).filter(_ref => { | ||
var [k] = _ref; | ||
return !parents.includes(k); | ||
}).map(_ref2 => { | ||
var [k, v] = _ref2; | ||
return [k, parents.includes(v) ? undefined : v]; | ||
}); | ||
}; | ||
var excludeCircularRefsFromSet = (parents, set) => { | ||
return Array.from(set).map(v => parents.includes(v) ? undefined : v); | ||
}; | ||
var limitString = (value, maxLength) => maxLength && value.length > maxLength ? "".concat(value.substring(0, maxLength), "...") : value; | ||
//# sourceMappingURL=utils.js.map |
@@ -1,2 +0,2 @@ | ||
export { getStatusFromError, getMessageAndTraceFromError, isMetadataTag, extractMetadataFromString, isAllStepsEnded, isAnyStepFailed, getUnfinishedStepsMessages, hasStepMessage, isPromise, hasLabel, stripAnsi } from "./utils.js"; | ||
export { getStatusFromError, getMessageAndTraceFromError, isMetadataTag, extractMetadataFromString, isAllStepsEnded, isAnyStepFailed, getUnfinishedStepsMessages, hasStepMessage, isPromise, hasLabel, stripAnsi, serialize } from "./utils.js"; | ||
//# sourceMappingURL=index.js.map |
@@ -126,11 +126,2 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } | ||
export var deepClone = obj => JSON.parse(JSON.stringify(obj)); | ||
export var serialize = val => { | ||
if (typeof val === "object" && !(val instanceof Map || val instanceof Set)) { | ||
return JSON.stringify(val); | ||
} | ||
if (val === undefined) { | ||
return "undefined"; | ||
} | ||
return val.toString(); | ||
}; | ||
export var getSuiteLabels = suites => { | ||
@@ -137,0 +128,0 @@ if (suites.length === 0) { |
@@ -129,2 +129,38 @@ function _wrapRegExp() { _wrapRegExp = function _wrapRegExp(e, r) { return new BabelRegExp(e, void 0, r); }; var e = RegExp.prototype, r = new WeakMap(); function BabelRegExp(e, t, p) { var o = RegExp(e, t); return r.set(o, p || r.get(e)), _setPrototypeOf(o, BabelRegExp.prototype); } function buildGroups(e, t) { var p = r.get(t); return Object.keys(p).reduce(function (r, t) { var o = p[t]; if ("number" == typeof o) r[t] = e[o];else { for (var i = 0; void 0 === e[o[i]] && i + 1 < o.length;) i++; r[t] = e[o[i]]; } return r; }, Object.create(null)); } return _inherits(BabelRegExp, RegExp), BabelRegExp.prototype.exec = function (r) { var t = e.exec.call(this, r); if (t) { t.groups = buildGroups(t, this); var p = t.indices; p && (p.groups = buildGroups(p, this)); } return t; }, BabelRegExp.prototype[Symbol.replace] = function (t, p) { if ("string" == typeof p) { var o = r.get(this); return e[Symbol.replace].call(this, t, p.replace(/\$<([^>]+)>/g, function (e, r) { var t = o[r]; return "$" + (Array.isArray(t) ? t.join("$") : t); })); } if ("function" == typeof p) { var i = this; return e[Symbol.replace].call(this, t, function () { var e = arguments; return "object" != typeof e[e.length - 1] && (e = [].slice.call(e)).push(buildGroups(e, i)), p.apply(this, e); }); } return e[Symbol.replace].call(this, t, p); }, _wrapRegExp.apply(this, arguments); } | ||
export var isPromise = obj => !!obj && (typeof obj === "object" || typeof obj === "function") && typeof obj.then === "function"; | ||
export var serialize = function serialize(value) { | ||
var { | ||
maxDepth = 0, | ||
maxLength = 0 | ||
} = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
return limitString(typeof value === "object" ? JSON.stringify(value, createSerializeReplacer(maxDepth)) : String(value), maxLength); | ||
}; | ||
var createSerializeReplacer = maxDepth => { | ||
var parents = []; | ||
return function (_, value) { | ||
if (typeof value !== "object" || value === null) { | ||
return value; | ||
} | ||
while (parents.length > 0 && !Object.is(parents.at(-1), this)) { | ||
parents.pop(); | ||
} | ||
if (maxDepth && parents.length >= maxDepth || parents.includes(value)) { | ||
return undefined; | ||
} | ||
parents.push(value); | ||
return value instanceof Map ? excludeCircularRefsFromMap(parents, value) : value instanceof Set ? excludeCircularRefsFromSet(parents, value) : value; | ||
}; | ||
}; | ||
var excludeCircularRefsFromMap = (parents, map) => { | ||
return Array.from(map).filter(_ref => { | ||
var [k] = _ref; | ||
return !parents.includes(k); | ||
}).map(_ref2 => { | ||
var [k, v] = _ref2; | ||
return [k, parents.includes(v) ? undefined : v]; | ||
}); | ||
}; | ||
var excludeCircularRefsFromSet = (parents, set) => { | ||
return Array.from(set).map(v => parents.includes(v) ? undefined : v); | ||
}; | ||
var limitString = (value, maxLength) => maxLength && value.length > maxLength ? "".concat(value.substring(0, maxLength), "...") : value; | ||
//# sourceMappingURL=utils.js.map |
export type { AllureResults, Category, EnvironmentInfo, ExecutorInfo, RuntimeMessage, RuntimeMetadataMessage, RuntimeAttachmentContentMessage, RuntimeAttachmentPathMessage, RuntimeStartStepMessage, RuntimeStepMetadataMessage, RuntimeStopStepMessage, TestPlanV1Test, TestPlanV1, } from "./types.js"; | ||
export { getStatusFromError, getMessageAndTraceFromError, isMetadataTag, extractMetadataFromString, isAllStepsEnded, isAnyStepFailed, getUnfinishedStepsMessages, hasStepMessage, isPromise, hasLabel, stripAnsi, } from "./utils.js"; | ||
export { getStatusFromError, getMessageAndTraceFromError, isMetadataTag, extractMetadataFromString, isAllStepsEnded, isAnyStepFailed, getUnfinishedStepsMessages, hasStepMessage, isPromise, hasLabel, stripAnsi, serialize, } from "./utils.js"; |
@@ -18,3 +18,2 @@ /// <reference path="../../../../src/types/properties.d.ts" /> | ||
export declare const deepClone: <T>(obj: T) => T; | ||
export declare const serialize: (val: unknown) => string; | ||
export declare const getSuiteLabels: (suites: readonly string[]) => Label[]; | ||
@@ -21,0 +20,0 @@ export declare const ensureSuiteLabels: (test: Partial<TestResult>, defaultSuites: readonly string[]) => void; |
@@ -94,2 +94,6 @@ /// <reference types="node" /> | ||
} | ||
export type SerializeOptions = { | ||
maxDepth?: number; | ||
maxLength?: number; | ||
}; | ||
export {}; |
import type { FixtureResult, Label, StatusDetails, StepResult, TestResult } from "../model.js"; | ||
import { LabelName, Status } from "../model.js"; | ||
import type { RuntimeMessage } from "./types.js"; | ||
import type { RuntimeMessage, SerializeOptions } from "./types.js"; | ||
export declare const getStatusFromError: (error: Error) => Status; | ||
@@ -29,1 +29,2 @@ /** | ||
export declare const isPromise: <T = any>(obj: any) => obj is PromiseLike<T>; | ||
export declare const serialize: (value: any, { maxDepth, maxLength }?: SerializeOptions) => string; |
{ | ||
"name": "allure-js-commons", | ||
"version": "3.0.0-beta.11", | ||
"version": "3.0.0-beta.12", | ||
"description": "Allure JS Commons", | ||
@@ -91,3 +91,3 @@ "homepage": "https://allurereport.org/", | ||
"peerDependencies": { | ||
"allure-playwright": "3.0.0-beta.11" | ||
"allure-playwright": "3.0.0-beta.12" | ||
}, | ||
@@ -94,0 +94,0 @@ "peerDependenciesMeta": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
756869
7405