UNPKG

@umbraco/playwright-testhelpers

Version:

Test helpers for making playwright tests for Umbraco solutions

745 lines 31.9 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DocumentTypeApiHelper = void 0; const json_models_builders_1 = require("@umbraco/json-models-builders"); const AliasHelper_1 = require("./AliasHelper"); class DocumentTypeApiHelper { api; constructor(api) { this.api = api; } async ensureNameNotExists(name) { const rootDocumentTypes = await this.getAllAtRoot(); const jsonDocumentTypes = await rootDocumentTypes.json(); for (const documentType of jsonDocumentTypes.items) { if (documentType.name === name) { if (documentType.isFolder) { return await this.recurseDeleteChildren(documentType); } return await this.delete(documentType.id); } else if (documentType.hasChildren) { await this.recurseChildren(name, documentType.id, true); } } return null; } async getAllAtRoot() { return await this.api.get(this.api.baseUrl + '/umbraco/management/api/v1/tree/document-type/root?skip=0&take=10000&foldersOnly=false'); } async recurseChildren(name, id, toDelete) { const items = await this.getChildren(id); for (const child of items) { if (child.name === name) { if (!toDelete) { if (child.isFolder) { return await this.getFolder(child.id); } return await this.get(child.id); } if (child.isFolder) { return await this.recurseDeleteChildren(child); } return await this.delete(child.id); } else if (child.hasChildren) { return await this.recurseChildren(name, child.id, toDelete); } } return false; } async recurseDeleteChildren(documentTypeFolder) { if (!documentTypeFolder.hasChildren) { return await this.deleteFolder(documentTypeFolder.id); } const items = await this.getChildren(documentTypeFolder.id); for (const child of items) { if (child.hasChildren) { await this.recurseDeleteChildren(child); } else if (child.isFolder) { await this.deleteFolder(child.id); } else { await this.delete(child.id); } } return await this.deleteFolder(documentTypeFolder.id); } async getChildren(id) { const response = await this.api.get(`${this.api.baseUrl}/umbraco/management/api/v1/tree/document-type/children?parentId=${id}&skip=0&take=10000&foldersOnly=false`); const items = await response.json(); return items.items; } async create(documentType) { if (documentType == null) { return; } const response = await this.api.post(this.api.baseUrl + '/umbraco/management/api/v1/document-type', documentType); return response.headers().location.split("/").pop(); } async get(id) { const response = await this.api.get(this.api.baseUrl + '/umbraco/management/api/v1/document-type/' + id); const json = await response.json(); if (json !== null) { return json; } return null; } async getByName(name) { const rootDocumentTypes = await this.getAllAtRoot(); const jsonDocumentTypes = await rootDocumentTypes.json(); for (const documentType of jsonDocumentTypes.items) { if (documentType.name === name) { if (documentType.isFolder) { return this.getFolder(documentType.id); } return this.get(documentType.id); } else if (documentType.hasChildren) { const result = await this.recurseChildren(name, documentType.id, false); if (result) { return result; } } } return false; } async doesNameExist(name) { return await this.getByName(name); } async delete(id) { if (id == null) { return; } const response = await this.api.delete(this.api.baseUrl + '/umbraco/management/api/v1/document-type/' + id); return response.status(); } // FOLDER async getFolder(id) { const response = await this.api.get(this.api.baseUrl + '/umbraco/management/api/v1/document-type/folder/' + id); return await response.json(); } async deleteFolder(id) { return await this.api.delete(this.api.baseUrl + '/umbraco/management/api/v1/document-type/folder/' + id); } async createFolder(name, parentId) { const folder = { name: name, parent: parentId ? { id: parentId } : null }; const response = await this.api.post(this.api.baseUrl + '/umbraco/management/api/v1/document-type/folder', folder); return response.headers().location.split("/").pop(); } async renameFolder(folderId, folderName) { const folder = { name: folderName }; return await this.api.put(this.api.baseUrl + '/umbraco/management/api/v1/document-type/folder/' + folderId, folder); } async createDefaultDocumentType(documentTypeName) { await this.ensureNameNotExists(documentTypeName); const documentType = new json_models_builders_1.DocumentTypeBuilder() .withName(documentTypeName) .withAlias(AliasHelper_1.AliasHelper.toAlias(documentTypeName)) .build(); return await this.create(documentType); } async createDocumentTypeWithPropertyEditor(documentTypeName, dataTypeName, dataTypeId, groupName = "TestGroup", documentTypeVaryByCulture = false, propertyVaryByCulture = false, isMandatory = false) { const crypto = require('crypto'); const containerId = crypto.randomUUID(); await this.ensureNameNotExists(documentTypeName); const documentType = new json_models_builders_1.DocumentTypeBuilder() .withName(documentTypeName) .withAlias(AliasHelper_1.AliasHelper.toAlias(documentTypeName)) .withAllowedAsRoot(true) .addContainer() .withName(groupName) .withId(containerId) .withType("Group") .done() .addProperty() .withContainerId(containerId) .withAlias(AliasHelper_1.AliasHelper.toAlias(dataTypeName)) .withName(dataTypeName) .withDataTypeId(dataTypeId) .withVariesByCulture(propertyVaryByCulture) .withMandatory(isMandatory) .done() .withVariesByCulture(documentTypeVaryByCulture) .build(); return await this.create(documentType); } async createDocumentTypeWithPropertyEditorAndTwoGroups(documentTypeName, firstPropertyName, firstDataTypeId, firstGroupName = "TestGroup", secondPropertyName, secondDataTypeId, secondGroupName = "SecondGroup") { const crypto = require('crypto'); const firstContainerId = crypto.randomUUID(); const secondContainerId = crypto.randomUUID(); await this.ensureNameNotExists(documentTypeName); const documentType = new json_models_builders_1.DocumentTypeBuilder() .withName(documentTypeName) .withAlias(AliasHelper_1.AliasHelper.toAlias(documentTypeName)) .withAllowedAsRoot(true) .addContainer() .withName(firstGroupName) .withId(firstContainerId) .withType("Group") .done() .addProperty() .withContainerId(firstContainerId) .withAlias(AliasHelper_1.AliasHelper.toAlias(firstPropertyName)) .withName(firstPropertyName) .withDataTypeId(firstDataTypeId) .done() .addContainer() .withName(secondGroupName) .withId(secondContainerId) .withType("Group") .done() .addProperty() .withContainerId(secondContainerId) .withAlias(AliasHelper_1.AliasHelper.toAlias(secondPropertyName)) .withName(secondPropertyName) .withDataTypeId(secondDataTypeId) .done() .build(); return await this.create(documentType); } async createDocumentTypeWithPropertyEditorInTab(documentTypeName, dataTypeName, dataTypeId, tabName, groupName = "TestGroup", varyByCulture = false) { const crypto = require('crypto'); const tabId = crypto.randomUUID(); const groupId = crypto.randomUUID(); await this.ensureNameNotExists(documentTypeName); const documentType = new json_models_builders_1.DocumentTypeBuilder() .withName(documentTypeName) .withAlias(AliasHelper_1.AliasHelper.toAlias(documentTypeName)) .addContainer() .withName(tabName) .withId(tabId) .withType("Tab") .done() .addContainer() .withName(groupName) .withId(groupId) .withType("Group") .withParentId(tabId) .done() .addProperty() .withContainerId(groupId) .withAlias(AliasHelper_1.AliasHelper.toAlias(dataTypeName)) .withName(dataTypeName) .withDataTypeId(dataTypeId) .done() .withVariesByCulture(varyByCulture) .build(); return await this.create(documentType); } async createDocumentTypeWithTwoPropertyEditors(documentTypeName, dataTypeNameOne, dataTypeIdOne, dataTypeNameTwo, dataTypeIdTwo, groupName = "TestGroup") { const crypto = require('crypto'); const containerId = crypto.randomUUID(); await this.ensureNameNotExists(documentTypeName); const documentType = new json_models_builders_1.DocumentTypeBuilder() .withName(documentTypeName) .withAlias(AliasHelper_1.AliasHelper.toAlias(documentTypeName)) .withAllowedAsRoot(true) .addContainer() .withName(groupName) .withId(containerId) .withType("Group") .done() .addProperty() .withContainerId(containerId) .withAlias(AliasHelper_1.AliasHelper.toAlias(dataTypeNameOne)) .withName(dataTypeNameOne) .withDataTypeId(dataTypeIdOne) .done() .addProperty() .withContainerId(containerId) .withAlias(AliasHelper_1.AliasHelper.toAlias(dataTypeNameTwo)) .withName(dataTypeNameTwo) .withDataTypeId(dataTypeIdTwo) .done() .build(); return await this.create(documentType); } async createDefaultDocumentTypeWithAllowAsRoot(documentTypeName) { await this.ensureNameNotExists(documentTypeName); const documentType = new json_models_builders_1.DocumentTypeBuilder() .withName(documentTypeName) .withAlias(AliasHelper_1.AliasHelper.toAlias(documentTypeName)) .withAllowedAsRoot(true) .build(); return await this.create(documentType); } async createDocumentTypeWithAllowedChildNode(documentTypeName, allowedChildNodeId) { await this.ensureNameNotExists(documentTypeName); const documentType = new json_models_builders_1.DocumentTypeBuilder() .withName(documentTypeName) .withAlias(AliasHelper_1.AliasHelper.toAlias(documentTypeName)) .withAllowedAsRoot(true) .addAllowedDocumentType() .withId(allowedChildNodeId) .done() .build(); return await this.create(documentType); } async createDocumentTypeWithAPropertyEditorAndAnAllowedChildNode(documentTypeName, dataTypeName, dataTypeId, allowedChildNodeId, groupName = "TestGroup") { await this.ensureNameNotExists(documentTypeName); const crypto = require('crypto'); const containerId = crypto.randomUUID(); const documentType = new json_models_builders_1.DocumentTypeBuilder() .withName(documentTypeName) .withAlias(AliasHelper_1.AliasHelper.toAlias(documentTypeName)) .withAllowedAsRoot(true) .addContainer() .withName(groupName) .withId(containerId) .withType("Group") .done() .addProperty() .withContainerId(containerId) .withAlias(AliasHelper_1.AliasHelper.toAlias(dataTypeName)) .withName(dataTypeName) .withDataTypeId(dataTypeId) .done() .addAllowedDocumentType() .withId(allowedChildNodeId) .done() .build(); return await this.create(documentType); } async createDocumentTypeWithAllowedTemplate(documentTypeName, allowedTemplateId, isAllowedAsRoot = false) { await this.ensureNameNotExists(documentTypeName); const documentType = new json_models_builders_1.DocumentTypeBuilder() .withName(documentTypeName) .withAlias(AliasHelper_1.AliasHelper.toAlias(documentTypeName)) .withAllowedAsRoot(isAllowedAsRoot) .addAllowedTemplateId() .withId(allowedTemplateId) .done() .withDefaultTemplateId(allowedTemplateId) .build(); return await this.create(documentType); } async createDocumentTypeWithTwoAllowedTemplates(documentTypeName, allowedTemplateOneId, allowedTemplateTwoId, isAllowedAsRoot = false, defaultTemplateId) { await this.ensureNameNotExists(documentTypeName); const defaultTemplate = defaultTemplateId === undefined ? allowedTemplateOneId : defaultTemplateId; const documentType = new json_models_builders_1.DocumentTypeBuilder() .withName(documentTypeName) .withAlias(AliasHelper_1.AliasHelper.toAlias(documentTypeName)) .withAllowedAsRoot(isAllowedAsRoot) .addAllowedTemplateId() .withId(allowedTemplateOneId) .done() .addAllowedTemplateId() .withId(allowedTemplateTwoId) .done() .withDefaultTemplateId(defaultTemplate) .build(); return await this.create(documentType); } async createDocumentTypeWithTwoGroups(documentTypeName, dataType, dataTypeId, groupNameOne, groupNameTwo) { const crypto = require('crypto'); const groupOneId = crypto.randomUUID(); const groupTwoId = crypto.randomUUID(); await this.ensureNameNotExists(documentTypeName); const documentType = new json_models_builders_1.DocumentTypeBuilder() .withName(documentTypeName) .withAlias(AliasHelper_1.AliasHelper.toAlias(documentTypeName)) .addContainer() .withName(groupNameOne) .withId(groupOneId) .withType("Group") .withSortOrder(0) .done() .addContainer() .withName(groupNameTwo) .withId(groupTwoId) .withType("Group") .withSortOrder(1) .done() .addProperty() .withContainerId(groupOneId) .withAlias(AliasHelper_1.AliasHelper.toAlias(dataType + "One")) .withName(dataType + "One") .withDataTypeId(dataTypeId) .done() .addProperty() .withContainerId(groupTwoId) .withAlias(AliasHelper_1.AliasHelper.toAlias(dataType + "Two")) .withName(dataType + "Two") .withDataTypeId(dataTypeId) .done() .build(); return await this.create(documentType); } async createDocumentTypeWithAComposition(documentTypeName, compositionId) { await this.ensureNameNotExists(documentTypeName); const documentType = new json_models_builders_1.DocumentTypeBuilder() .withName(documentTypeName) .withAlias(AliasHelper_1.AliasHelper.toAlias(documentTypeName)) .addComposition() .withDocumentTypeId(compositionId) .done() .build(); return await this.create(documentType); } async createEmptyElementType(elementTypeName) { await this.ensureNameNotExists(elementTypeName); const documentType = new json_models_builders_1.DocumentTypeBuilder() .withName(elementTypeName) .withAlias(AliasHelper_1.AliasHelper.toAlias(elementTypeName)) .withIsElement(true) .withIcon("icon-plugin") .build(); return await this.create(documentType); } async createDocumentTypeWithTwoTabs(documentTypeName, dataType, dataTypeId, tabNameOne, tabNameTwo) { const crypto = require('crypto'); const tabOneId = crypto.randomUUID(); const tabTwoId = crypto.randomUUID(); const groupOneId = crypto.randomUUID(); const groupTwoId = crypto.randomUUID(); await this.ensureNameNotExists(documentTypeName); const documentType = new json_models_builders_1.DocumentTypeBuilder() .withName(documentTypeName) .withAlias(AliasHelper_1.AliasHelper.toAlias(documentTypeName)) .addContainer() .withName(tabNameOne) .withId(tabOneId) .withType("Tab") .withSortOrder(0) .done() .addContainer() .withName(tabNameTwo) .withId(tabTwoId) .withType("Tab") .withSortOrder(1) .done() .addContainer() .withName("GroupTestOne") .withId(groupOneId) .withType("Group") .withParentId(tabOneId) .done() .addProperty() .withContainerId(groupOneId) .withAlias(AliasHelper_1.AliasHelper.toAlias(dataType + "One")) .withName(dataType + "One") .withDataTypeId(dataTypeId) .done() .addContainer() .withName("GroupTestTwo") .withId(groupTwoId) .withType("Group") .withParentId(tabTwoId) .done() .addProperty() .withContainerId(groupTwoId) .withAlias(AliasHelper_1.AliasHelper.toAlias(dataType + "Two")) .withName(dataType + "Two") .withDataTypeId(dataTypeId) .done() .build(); return await this.create(documentType); } async createDefaultElementType(elementName, groupName = 'TestGroup', dataTypeName = 'Textstring', dataTypeId, isMandatory = false) { await this.ensureNameNotExists(elementName); const crypto = require('crypto'); const containerId = crypto.randomUUID(); const documentType = new json_models_builders_1.DocumentTypeBuilder() .withName(elementName) .withAlias(AliasHelper_1.AliasHelper.toAlias(elementName)) .withIsElement(true) .addContainer() .withName(groupName) .withId(containerId) .withType("Group") .done() .addProperty() .withContainerId(containerId) .withAlias(AliasHelper_1.AliasHelper.toAlias(dataTypeName)) .withName(dataTypeName) .withDataTypeId(dataTypeId) .withMandatory(isMandatory) .done() .build(); return await this.create(documentType); } async createDefaultElementTypeWithVaryByCulture(elementName, groupName = 'TestGroup', dataTypeName = 'Textstring', dataTypeId, elementTypeVaryByCulture, dataTypeVaryByCulture) { await this.ensureNameNotExists(elementName); const crypto = require('crypto'); const containerId = crypto.randomUUID(); const documentType = new json_models_builders_1.DocumentTypeBuilder() .withName(elementName) .withAlias(AliasHelper_1.AliasHelper.toAlias(elementName)) .withIsElement(true) .withVariesByCulture(elementTypeVaryByCulture) .addContainer() .withName(groupName) .withId(containerId) .withType("Group") .done() .addProperty() .withContainerId(containerId) .withAlias(AliasHelper_1.AliasHelper.toAlias(dataTypeName)) .withName(dataTypeName) .withDataTypeId(dataTypeId) .withVariesByCulture(dataTypeVaryByCulture) .done() .build(); return await this.create(documentType); } async createElementTypeWithRegexValidation(elementName, groupName = 'TestGroup', dataTypeName = 'Textstring', dataTypeId, regex) { await this.ensureNameNotExists(elementName); const crypto = require('crypto'); const containerId = crypto.randomUUID(); const documentType = new json_models_builders_1.DocumentTypeBuilder() .withName(elementName) .withAlias(AliasHelper_1.AliasHelper.toAlias(elementName)) .withIsElement(true) .addContainer() .withName(groupName) .withId(containerId) .withType("Group") .done() .addProperty() .withContainerId(containerId) .withAlias(AliasHelper_1.AliasHelper.toAlias(dataTypeName)) .withName(dataTypeName) .withDataTypeId(dataTypeId) .withRegEx(regex) .done() .build(); return await this.create(documentType); } async doesGroupContainCorrectPropertyEditor(documentTypeName, dataTypeName, dataTypeId, groupName) { const documentType = await this.getByName(documentTypeName); const group = documentType.containers.find(x => x.name === groupName); // Check if group is defined if (group) { // Check if the document type properties include the specified property, and it belongs to the group return documentType.properties.find(x => x.name === dataTypeName && x.dataType.id === dataTypeId && x.container.id === group.id); } else { // Group not found return false; } } async doesTabContainCorrectPropertyEditorInGroup(documentTypeName, dataTypeName, dataTypeId, tabName, groupName) { const documentType = await this.getByName(documentTypeName); const tab = documentType.containers.find(x => x.name === tabName); // Check if tab is defined if (tab) { const group = documentType.containers.find(x => x.name === groupName && x.parent.id === tab.id); // Check if group is defined if (group) { // Check if the document type properties include the specified property, and it belongs to the group return documentType.properties.find(x => x.name === dataTypeName && x.dataType.id === dataTypeId && x.container.id === group.id); } else { // Group not found return false; } } else { // Tab not found return false; } } async doesDocumentTypeGroupNameContainCorrectSortOrder(documentTypeName, groupName, sortOrder) { const documentType = await this.getByName(documentTypeName); const group = documentType.containers.find(x => x.name === groupName); // Check if group is defined if (group) { return group.sortOrder === sortOrder; } else { // Group not found return false; } } async doesDocumentTypeTabNameContainCorrectSortOrder(documentTypeName, tabName, sortOrder) { const documentType = await this.getByName(documentTypeName); const tab = documentType.containers.find(x => x.name === tabName); // Check if tab is defined if (tab) { return tab.sortOrder === sortOrder; } else { // Tab not found return false; } } async getContainerIdWithName(documentTypeName, containerName) { const documentType = await this.getByName(documentTypeName); const container = documentType.containers.find(x => x.name === containerName); if (container) { return container.id; } else { return null; } } async createDocumentTypeWithAllowedTwoChildNodes(documentTypeName, allowedChildNodeOneId, allowedChildNodeTwoId) { await this.ensureNameNotExists(documentTypeName); const documentType = new json_models_builders_1.DocumentTypeBuilder() .withName(documentTypeName) .withAlias(AliasHelper_1.AliasHelper.toAlias(documentTypeName)) .withAllowedAsRoot(true) .addAllowedDocumentType() .withId(allowedChildNodeOneId) .done() .addAllowedDocumentType() .withId(allowedChildNodeTwoId) .done() .build(); return await this.create(documentType); } async createDocumentTypeWithAllowedChildNodeAndDataType(documentTypeName, allowedChildNodeId, dataTypeName, dataTypeId, groupName = "TestGroup") { const crypto = require('crypto'); const containerId = crypto.randomUUID(); await this.ensureNameNotExists(documentTypeName); const documentType = new json_models_builders_1.DocumentTypeBuilder() .withName(documentTypeName) .withAlias(AliasHelper_1.AliasHelper.toAlias(documentTypeName)) .withAllowedAsRoot(true) .addContainer() .withName(groupName) .withId(containerId) .withType("Group") .done() .addProperty() .withContainerId(containerId) .withAlias(AliasHelper_1.AliasHelper.toAlias(dataTypeName)) .withName(dataTypeName) .withDataTypeId(dataTypeId) .done() .addAllowedDocumentType() .withId(allowedChildNodeId) .done() .build(); return await this.create(documentType); } async createDocumentTypeWithAllowedChildNodeAndCollectionId(documentTypeName, allowedChildNodeId, collectionId) { await this.ensureNameNotExists(documentTypeName); const documentType = new json_models_builders_1.DocumentTypeBuilder() .withName(documentTypeName) .withAlias(AliasHelper_1.AliasHelper.toAlias(documentTypeName)) .withAllowedAsRoot(true) .addAllowedDocumentType() .withId(allowedChildNodeId) .done() .withCollectionId(collectionId) .build(); return await this.create(documentType); } async createDocumentTypeWithCollectionId(documentTypeName, collectionId) { await this.ensureNameNotExists(documentTypeName); const documentType = new json_models_builders_1.DocumentTypeBuilder() .withName(documentTypeName) .withAlias(AliasHelper_1.AliasHelper.toAlias(documentTypeName)) .withAllowedAsRoot(true) .withCollectionId(collectionId) .build(); return await this.create(documentType); } async createDocumentTypeWithAllowVaryByCulture(documentTypeName) { await this.ensureNameNotExists(documentTypeName); const documentType = new json_models_builders_1.DocumentTypeBuilder() .withName(documentTypeName) .withAlias(AliasHelper_1.AliasHelper.toAlias(documentTypeName)) .withAllowedAsRoot(true) .withVariesByCulture(true) .build(); return await this.create(documentType); } async createDocumentTypeWithPropertyEditorAndAllowedTemplate(documentTypeName, dataTypeId, propertyName, templateId) { const crypto = require('crypto'); const containerId = crypto.randomUUID(); await this.ensureNameNotExists(documentTypeName); const documentType = new json_models_builders_1.DocumentTypeBuilder() .withName(documentTypeName) .withAlias(AliasHelper_1.AliasHelper.toAlias(documentTypeName)) .withAllowedAsRoot(true) .addContainer() .withName('TestGroup') .withId(containerId) .withType('Group') .done() .addProperty() .withContainerId(containerId) .withAlias(AliasHelper_1.AliasHelper.toAlias(propertyName)) .withName(propertyName) .withDataTypeId(dataTypeId) .done() .addAllowedTemplateId() .withId(templateId) .done() .withDefaultTemplateId(templateId) .build(); return await this.create(documentType); } async createVariantDocumentTypeWithInvariantPropertyEditor(documentTypeName, dataTypeName, dataTypeId) { const crypto = require('crypto'); const containerId = crypto.randomUUID(); await this.ensureNameNotExists(documentTypeName); const documentType = new json_models_builders_1.DocumentTypeBuilder() .withName(documentTypeName) .withAlias(AliasHelper_1.AliasHelper.toAlias(documentTypeName)) .withAllowedAsRoot(true) .addContainer() .withName('TestGroup') .withId(containerId) .withType("Group") .done() .addProperty() .withContainerId(containerId) .withAlias(AliasHelper_1.AliasHelper.toAlias(dataTypeName)) .withName(dataTypeName) .withDataTypeId(dataTypeId) .withVariesByCulture(false) .done() .withVariesByCulture(true) .build(); return await this.create(documentType); } async createVariantDocumentTypeWithAllowedChildNodeAndInvariantPropertyEditor(documentTypeName, allowedChildNodeId, dataTypeName, dataTypeId, groupName = "TestGroup") { const crypto = require('crypto'); const containerId = crypto.randomUUID(); await this.ensureNameNotExists(documentTypeName); const documentType = new json_models_builders_1.DocumentTypeBuilder() .withName(documentTypeName) .withAlias(AliasHelper_1.AliasHelper.toAlias(documentTypeName)) .withAllowedAsRoot(true) .addContainer() .withName(groupName) .withId(containerId) .withType("Group") .done() .addProperty() .withContainerId(containerId) .withAlias(AliasHelper_1.AliasHelper.toAlias(dataTypeName)) .withName(dataTypeName) .withDataTypeId(dataTypeId) .withVariesByCulture(false) .done() .addAllowedDocumentType() .withId(allowedChildNodeId) .done() .withVariesByCulture(true) .build(); return await this.create(documentType); } async getPropertyIdWithName(documentTypeId, propertyName) { const documentTypeData = await this.get(documentTypeId); const property = documentTypeData.properties.find(x => x.name === propertyName); if (property) { return property.id; } else { return null; } } } exports.DocumentTypeApiHelper = DocumentTypeApiHelper; //# sourceMappingURL=DocumentTypeApiHelper.js.map