alfresco-ng2-components/tools/doc/sourceInfoClasses.js
Eugenio Romano 4043d55fc4
[AAE-10778] Refactor Viewer (#7992)
* refactor version 1 many todo

* split render from viewer
move alfresco render in content pack

* refactor part 2

* test fixed

* fix doc

* [AAE-10778] Fix lint issues

* [AAE-10778] Fix lint issue: remove duplicated declaration

* [AAE-10778] Fix lint issue: use flex shorthand rule

* [AAE-10778] Fix FormService and WidgetComponent imports

* [AAE-10778] Fix import FormModel, FormService, FormFieldModel from adf-core

* [AAE-10778] Implement missing oninit, onchanges and ondestroy

* [AAE-10778] Replace adf-viewer with adf-alfresco-viewer, update escape command to close the viewer

* [AAE-10778] Fix unit test: fix the class name to match the 'adf-viewer-render.image-viewer-scaling' get from the appConfigService

* [AAE-10778] Fix image-viewer unit tests: replace ContentService with UrlService

* [AAE-10778] Fix unit test 'should if the extension change extension Change event be fired': emit file extension when the filename extension change

* [AAE-10778] Fix unit test: expect for internalFileName value instead of display-name id because the display name logic has been moved to the alfresco-viewer.component

* [AAE-10778] Fix unit test: remove display name it because the unknown display name value is no longer handled after refactoring

* [AAE-10778] Fix e2e: [C260096] Should the Viewer able to accept a customToolbar

* [AAE-10778] Update selector to fix e2e: '[C362265] Should the Viewer be able to download a previous version of a file'

* [AAE-10778] Update selector to fix e2e: '[C260038] Should display first page, toolbar and pagination when opening a .pdf file'

* fix aftrer rebase

* fix unit test

* [AAE-10778] Add adf viewer component that is node agnostic, show adf-alfresco-viewer or adf-viewer into file-view-component if blob or node are set

* [AAE-10778] Update viewer export path

* [AAE-10778] Update selectors since have been updated in the viewer component

* [AAE-10778] Call adf-viewer from alfresco-viewer, project adf-alfresco-viewer content to adf-viewer

* [AAE-10778] Remove full screen unit tests from alfresco-viewer component becase that logic is handled in the viewer.component

* [AAE-10778] Export toolbar custom actions component

* [AAE-10778] Pass mimeType as input to adf-viewer to update mime icon

* [AAE-10778] Remove e2e because the custom name behaviour has been removed from the file-view.component (9f21b6dc69\#diff-4b438dc59784dce9eb7634cfeca6d8db61362966343bd3d6895a3edafdf4cfd5L129)

* [AAE-10778] Use two-way binding for showViewer change to fix C260100

* [AAE-10778] Update prefix css selectors to adf-viewer because are related to the adf-viewer component

* [AAE-10778] Update prefix css selectors to adf-viewer in the unit tests because are related to the adf-viewer component

* [AAE-10778] Update the output name to showViewerChange to navigate to primary url after closing the viewer

* [AAE-10778] Pass right and left sidebar template context to viewer component (fix C362242)

* [AAE-10778] Add allowFullScreen input to disable/enable full screen behaviour

* [AAE-10778] Handle loading visualization only inside the viewer-render component

* [AAE-10778] PDF viewer: fix mat-progress-bar is not showed during the pdf loading, center progress bar

* [AAE-10778] Remove isLoading from unit tests because no longer exists

* [AAE-10778] Remove viewerType input from adf-viewer, viewerType will be handled by viewer-render

* [AAE-10778] Remove console.log

* [AAE-10778] Remove check full screen button is not displayed on the media file because is not needed anymore, we don't need to check for the fullscreen button in the viewer component

* [AAE-10778] Check for node rendtion before to assign to urlFileContent and mimeType

* [AAE-10778] Process Services Cloud: register file-viewer widget that uses adf-alfresco-viewer component to display content from ACS

* [AAE-10778] Core: rename file-viewer widget into base-viewer, base-viewer no longer accept nodeId, but will accept urlFile and blobFile

* [AAE-10778] Process Services: register file-viewer widget that uses adf-alfresco-viewer component to display content from ACS

* [AAE-10778] Base viewer widget: show viewer only if there's a file input

* [AAE-10778] Viewer component: check for fileName when urlFile is provided as Input

* [AAE-10778] Viewer component documentation

* [AAE-10778] Update upgrade guide with viewer changes

* [AAE-10778] Fix double quote lint issue after rebase

---------

Co-authored-by: Amedeo Lepore <amedeo.lepore@hyland.com>
Co-authored-by: Amedeo Lepore <amedeo.lepore85@gmail.com>
2023-02-01 17:25:43 +01:00

203 lines
8.2 KiB
JavaScript

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ComponentInfo = exports.MethodSigInfo = exports.ParamInfo = exports.PropInfo = void 0;
var skipMethodNames = [
'ngOnChanges',
'ngOnDestroy',
'ngOnInit'
];
var PropInfo = /** @class */ (function () {
function PropInfo(sourceData) {
var _this = this;
this.errorMessages = [];
this.name = sourceData.name;
this.docText = sourceData.summary || '';
this.docText = this.docText.replace(/[\n\r]+/g, ' ').trim();
var tempDefaultVal = sourceData.syntax['return'].defaultValue;
this.defaultValue = tempDefaultVal ? tempDefaultVal.toString() : '';
this.defaultValue = this.defaultValue.replace(/\|/, '\\|');
this.type = sourceData.syntax['return'].type || '';
this.type = this.type.toString().replace(/\|/, '\\|').replace('unknown', '');
if (sourceData.tags) {
var depTag = sourceData.tags.find(function (tag) { return tag.name === 'deprecated'; });
if (depTag) {
this.isDeprecated = true;
this.docText = '(**Deprecated:** ' + depTag.text.replace(/[\n\r]+/g, ' ').trim() + ') ' + this.docText;
}
}
this.isInput = false;
this.isOutput = false;
if (sourceData.decorators) {
sourceData.decorators.forEach(function (dec) {
if (dec.name === 'Input') {
_this.isInput = true;
if (dec.arguments) {
var bindingName = dec.arguments['bindingPropertyName'];
if (bindingName && (bindingName !== '')) {
_this.name = bindingName.replace(/['"]/g, '');
}
}
if (!_this.docText && !_this.isDeprecated) {
_this.errorMessages.push("Warning: Input \"".concat(sourceData.name, "\" has no doc text."));
}
}
if (dec.name === 'Output') {
_this.isOutput = true;
if (!_this.docText && !_this.isDeprecated) {
_this.errorMessages.push("Warning: Output \"".concat(sourceData.name, "\" has no doc text."));
}
}
});
}
}
Object.defineProperty(PropInfo.prototype, "errors", {
get: function () {
return this.errorMessages;
},
enumerable: false,
configurable: true
});
return PropInfo;
}());
exports.PropInfo = PropInfo;
var ParamInfo = /** @class */ (function () {
function ParamInfo(sourceData) {
this.name = sourceData.id;
this.type = sourceData.type.toString().replace(/\s/g, '');
this.defaultValue = sourceData.defaultValue;
this.docText = sourceData.description.replace(/[\n\r]+/g, ' ').trim();
this.isOptional = false;
if (sourceData.flags) {
var flag = sourceData.flags.find(function (sourceFlag) { return sourceFlag.name === 'isOptional'; });
if (flag) {
this.isOptional = true;
}
}
this.combined = this.name;
if (this.isOptional) {
this.combined += '?';
}
this.combined += ": `".concat(this.type, "`");
if (this.defaultValue !== '') {
this.combined += " = `".concat(this.defaultValue, "`");
}
}
return ParamInfo;
}());
exports.ParamInfo = ParamInfo;
var MethodSigInfo = /** @class */ (function () {
function MethodSigInfo(sourceData) {
var _this = this;
this.errorMessages = [];
this.name = sourceData.name;
this.docText = sourceData.summary || '';
this.docText = this.docText.replace(/[\n\r]+/g, ' ').trim();
if (!this.docText && this.name.indexOf('service') > 0) {
this.errorMessages.push("Warning: method \"".concat(sourceData.name, "\" has no doc text."));
}
this.returnType = sourceData.syntax['return'].type || '';
this.returnType = this.returnType.toString().replace(/\s/g, '');
this.returnsSomething = this.returnType && (this.returnType !== 'void');
this.returnDocText = sourceData.syntax['return'].summary || '';
if (this.returnDocText.toLowerCase() === 'nothing') {
this.returnsSomething = false;
}
if (this.returnsSomething && !this.returnDocText && this.name.indexOf('service') > 0) {
this.errorMessages.push("Warning: Return value of method \"".concat(sourceData.name, "\" has no doc text."));
}
this.isDeprecated = false;
if (sourceData.tags) {
var depTag = sourceData.tags.find(function (tag) { return tag.name === 'deprecated'; });
if (depTag) {
this.isDeprecated = true;
this.docText = '(**Deprecated:** ' + depTag.text.replace(/[\n\r]+/g, ' ').trim() + ') ' + this.docText;
}
}
this.params = [];
var paramStrings = [];
if (sourceData.syntax.parameters) {
sourceData.syntax.parameters.forEach(function (rawParam) {
if (rawParam.name && !rawParam.description && !rawParam.name.startWith('on')) {
_this.errorMessages.push("Warning: parameter \"".concat(rawParam.name, "\" of method \"").concat(sourceData.name, "\" has no doc text."));
}
var param = new ParamInfo(rawParam);
_this.params.push(param);
paramStrings.push(param.combined);
});
}
this.signature = '(' + paramStrings.join(', ') + ')';
}
Object.defineProperty(MethodSigInfo.prototype, "errors", {
get: function () {
return this.errorMessages;
},
enumerable: false,
configurable: true
});
return MethodSigInfo;
}());
exports.MethodSigInfo = MethodSigInfo;
var ComponentInfo = /** @class */ (function () {
function ComponentInfo(sourceData) {
var _this = this;
this.name = sourceData.items[0].name;
this.itemType = sourceData.items[0].type;
this.hasInputs = false;
this.hasOutputs = false;
this.hasMethods = false;
this.sourcePath = sourceData.items[0].source.path;
this.sourceLine = sourceData.items[0].source.line;
if (this.itemType === 'type alias') {
return;
}
this.properties = [];
this.methods = [];
sourceData.items.forEach(function (item) {
switch (item.type) {
case 'property':
case 'accessor':
var prop = new PropInfo(item);
_this.properties.push(prop);
if (prop.isInput) {
_this.hasInputs = true;
}
if (prop.isOutput) {
_this.hasOutputs = true;
}
break;
case 'method':
if (item.flags && (item.flags.length > 0) &&
!item.flags.find(function (flag) { return flag.name === 'isPrivate'; }) &&
!item.flags.find(function (flag) { return flag.name === 'isProtected'; }) &&
!skipMethodNames.includes(item.name)) {
_this.methods.push(new MethodSigInfo(item));
_this.hasMethods = true;
}
break;
default:
break;
}
});
}
Object.defineProperty(ComponentInfo.prototype, "errors", {
get: function () {
var combinedErrors = [];
this.methods.forEach(function (method) {
method.errors.forEach(function (err) {
combinedErrors.push(err);
});
});
this.properties.forEach(function (prop) {
prop.errors.forEach(function (err) {
combinedErrors.push(err);
});
});
return combinedErrors;
},
enumerable: false,
configurable: true
});
return ComponentInfo;
}());
exports.ComponentInfo = ComponentInfo;