@umbraco/playwright-testhelpers 17.1.0-beta.6 → 17.1.0-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lib/helpers/BaseApiHelper.d.ts +19 -0
- package/dist/lib/helpers/BaseApiHelper.js +87 -0
- package/dist/lib/helpers/BaseApiHelper.js.map +1 -0
- package/dist/lib/helpers/ConstantHelper.d.ts +0 -17
- package/dist/lib/helpers/ConstantHelper.js +0 -17
- package/dist/lib/helpers/ConstantHelper.js.map +1 -1
- package/dist/lib/helpers/ContentRenderUiHelper.js +3 -3
- package/dist/lib/helpers/ContentRenderUiHelper.js.map +1 -1
- package/dist/lib/helpers/ContentUiHelper.js +487 -353
- package/dist/lib/helpers/ContentUiHelper.js.map +1 -1
- package/dist/lib/helpers/CurrentUserProfileUiHelper.js +10 -4
- package/dist/lib/helpers/CurrentUserProfileUiHelper.js.map +1 -1
- package/dist/lib/helpers/DataTypeApiHelper.d.ts +9 -21
- package/dist/lib/helpers/DataTypeApiHelper.js +32 -125
- package/dist/lib/helpers/DataTypeApiHelper.js.map +1 -1
- package/dist/lib/helpers/DataTypeUiHelper.js +332 -193
- package/dist/lib/helpers/DataTypeUiHelper.js.map +1 -1
- package/dist/lib/helpers/DictionaryApiHelper.d.ts +8 -15
- package/dist/lib/helpers/DictionaryApiHelper.js +49 -77
- package/dist/lib/helpers/DictionaryApiHelper.js.map +1 -1
- package/dist/lib/helpers/DictionaryUiHelper.js +23 -17
- package/dist/lib/helpers/DictionaryUiHelper.js.map +1 -1
- package/dist/lib/helpers/DocumentBlueprintApiHelper.d.ts +7 -13
- package/dist/lib/helpers/DocumentBlueprintApiHelper.js +44 -69
- package/dist/lib/helpers/DocumentBlueprintApiHelper.js.map +1 -1
- package/dist/lib/helpers/DocumentBlueprintUiHelper.js +10 -8
- package/dist/lib/helpers/DocumentBlueprintUiHelper.js.map +1 -1
- package/dist/lib/helpers/DocumentTypeApiHelper.d.ts +4 -18
- package/dist/lib/helpers/DocumentTypeApiHelper.js +4 -134
- package/dist/lib/helpers/DocumentTypeApiHelper.js.map +1 -1
- package/dist/lib/helpers/DocumentTypeUiHelper.js +34 -22
- package/dist/lib/helpers/DocumentTypeUiHelper.js.map +1 -1
- package/dist/lib/helpers/ExamineManagementUiHelper.js +6 -5
- package/dist/lib/helpers/ExamineManagementUiHelper.js.map +1 -1
- package/dist/lib/helpers/FormsUiHelper.js +159 -119
- package/dist/lib/helpers/FormsUiHelper.js.map +1 -1
- package/dist/lib/helpers/HealthCheckUiHelper.js +7 -7
- package/dist/lib/helpers/HealthCheckUiHelper.js.map +1 -1
- package/dist/lib/helpers/LanguageApiHelper.d.ts +10 -12
- package/dist/lib/helpers/LanguageApiHelper.js +34 -35
- package/dist/lib/helpers/LanguageApiHelper.js.map +1 -1
- package/dist/lib/helpers/LanguageUiHelper.js +19 -16
- package/dist/lib/helpers/LanguageUiHelper.js.map +1 -1
- package/dist/lib/helpers/LogViewerUiHelper.js +31 -22
- package/dist/lib/helpers/LogViewerUiHelper.js.map +1 -1
- package/dist/lib/helpers/LoginUiHelper.js +7 -4
- package/dist/lib/helpers/LoginUiHelper.js.map +1 -1
- package/dist/lib/helpers/MediaTypeApiHelper.d.ts +4 -18
- package/dist/lib/helpers/MediaTypeApiHelper.js +4 -134
- package/dist/lib/helpers/MediaTypeApiHelper.js.map +1 -1
- package/dist/lib/helpers/MediaTypeUiHelper.js +17 -11
- package/dist/lib/helpers/MediaTypeUiHelper.js.map +1 -1
- package/dist/lib/helpers/MediaUiHelper.js +45 -36
- package/dist/lib/helpers/MediaUiHelper.js.map +1 -1
- package/dist/lib/helpers/MemberApiHelper.d.ts +4 -12
- package/dist/lib/helpers/MemberApiHelper.js +6 -54
- package/dist/lib/helpers/MemberApiHelper.js.map +1 -1
- package/dist/lib/helpers/MemberGroupApiHelper.d.ts +6 -11
- package/dist/lib/helpers/MemberGroupApiHelper.js +20 -35
- package/dist/lib/helpers/MemberGroupApiHelper.js.map +1 -1
- package/dist/lib/helpers/MemberGroupUiHelper.js +16 -13
- package/dist/lib/helpers/MemberGroupUiHelper.js.map +1 -1
- package/dist/lib/helpers/MemberTypeApiHelper.d.ts +5 -12
- package/dist/lib/helpers/MemberTypeApiHelper.js +16 -49
- package/dist/lib/helpers/MemberTypeApiHelper.js.map +1 -1
- package/dist/lib/helpers/MemberTypeUiHelper.js +3 -2
- package/dist/lib/helpers/MemberTypeUiHelper.js.map +1 -1
- package/dist/lib/helpers/MemberUiHelper.js +43 -25
- package/dist/lib/helpers/MemberUiHelper.js.map +1 -1
- package/dist/lib/helpers/ModelsBuilderUiHelper.js +3 -2
- package/dist/lib/helpers/ModelsBuilderUiHelper.js.map +1 -1
- package/dist/lib/helpers/PackageApiHelper.d.ts +5 -4
- package/dist/lib/helpers/PackageApiHelper.js +47 -75
- package/dist/lib/helpers/PackageApiHelper.js.map +1 -1
- package/dist/lib/helpers/PackageUiHelper.js +36 -30
- package/dist/lib/helpers/PackageUiHelper.js.map +1 -1
- package/dist/lib/helpers/PartialViewApiHelper.d.ts +5 -20
- package/dist/lib/helpers/PartialViewApiHelper.js +12 -146
- package/dist/lib/helpers/PartialViewApiHelper.js.map +1 -1
- package/dist/lib/helpers/PartialViewUiHelper.js +17 -14
- package/dist/lib/helpers/PartialViewUiHelper.js.map +1 -1
- package/dist/lib/helpers/PathBasedTreeApiHelper.d.ts +32 -0
- package/dist/lib/helpers/PathBasedTreeApiHelper.js +164 -0
- package/dist/lib/helpers/PathBasedTreeApiHelper.js.map +1 -0
- package/dist/lib/helpers/ProfilingUiHelper.js +5 -3
- package/dist/lib/helpers/ProfilingUiHelper.js.map +1 -1
- package/dist/lib/helpers/PublishedStatusUiHelper.js +8 -7
- package/dist/lib/helpers/PublishedStatusUiHelper.js.map +1 -1
- package/dist/lib/helpers/RedirectManagementUiHelper.js +12 -7
- package/dist/lib/helpers/RedirectManagementUiHelper.js.map +1 -1
- package/dist/lib/helpers/RelationTypeApiHelper.d.ts +7 -12
- package/dist/lib/helpers/RelationTypeApiHelper.js +28 -49
- package/dist/lib/helpers/RelationTypeApiHelper.js.map +1 -1
- package/dist/lib/helpers/RelationTypeUiHelper.js +16 -13
- package/dist/lib/helpers/RelationTypeUiHelper.js.map +1 -1
- package/dist/lib/helpers/ScriptApiHelper.d.ts +6 -22
- package/dist/lib/helpers/ScriptApiHelper.js +12 -165
- package/dist/lib/helpers/ScriptApiHelper.js.map +1 -1
- package/dist/lib/helpers/ScriptUiHelper.js +13 -9
- package/dist/lib/helpers/ScriptUiHelper.js.map +1 -1
- package/dist/lib/helpers/StylesheetApiHelper.d.ts +5 -20
- package/dist/lib/helpers/StylesheetApiHelper.js +13 -154
- package/dist/lib/helpers/StylesheetApiHelper.js.map +1 -1
- package/dist/lib/helpers/StylesheetUiHelper.js +14 -9
- package/dist/lib/helpers/StylesheetUiHelper.js.map +1 -1
- package/dist/lib/helpers/TelemetryDataUiHelper.js +3 -2
- package/dist/lib/helpers/TelemetryDataUiHelper.js.map +1 -1
- package/dist/lib/helpers/TemplateApiHelper.d.ts +8 -15
- package/dist/lib/helpers/TemplateApiHelper.js +51 -83
- package/dist/lib/helpers/TemplateApiHelper.js.map +1 -1
- package/dist/lib/helpers/TemplateUiHelper.js +25 -19
- package/dist/lib/helpers/TemplateUiHelper.js.map +1 -1
- package/dist/lib/helpers/TreeApiHelper.d.ts +15 -0
- package/dist/lib/helpers/TreeApiHelper.js +116 -0
- package/dist/lib/helpers/TreeApiHelper.js.map +1 -0
- package/dist/lib/helpers/UiBaseLocators.d.ts +228 -230
- package/dist/lib/helpers/UiBaseLocators.js +871 -834
- package/dist/lib/helpers/UiBaseLocators.js.map +1 -1
- package/dist/lib/helpers/UserGroupApiHelper.d.ts +3 -13
- package/dist/lib/helpers/UserGroupApiHelper.js +3 -69
- package/dist/lib/helpers/UserGroupApiHelper.js.map +1 -1
- package/dist/lib/helpers/UserGroupUiHelper.js +49 -32
- package/dist/lib/helpers/UserGroupUiHelper.js.map +1 -1
- package/dist/lib/helpers/UserUiHelper.js +46 -43
- package/dist/lib/helpers/UserUiHelper.js.map +1 -1
- package/dist/lib/helpers/VariantBasedApiHelper.d.ts +23 -0
- package/dist/lib/helpers/VariantBasedApiHelper.js +81 -0
- package/dist/lib/helpers/VariantBasedApiHelper.js.map +1 -0
- package/dist/lib/helpers/WebhookApiHelper.d.ts +1 -0
- package/dist/lib/helpers/WebhookApiHelper.js +10 -11
- package/dist/lib/helpers/WebhookApiHelper.js.map +1 -1
- package/dist/lib/helpers/WebhookUiHelper.js +27 -11
- package/dist/lib/helpers/WebhookUiHelper.js.map +1 -1
- package/dist/lib/helpers/WelcomeDashboardUiHelper.js +1 -1
- package/dist/lib/helpers/WelcomeDashboardUiHelper.js.map +1 -1
- package/dist/lib/helpers/differentAppSettingsHelpers/ExternalLoginUiHelpers.js +9 -4
- package/dist/lib/helpers/differentAppSettingsHelpers/ExternalLoginUiHelpers.js.map +1 -1
- package/dist/lib/helpers/differentAppSettingsHelpers/InstallUiHelper.js +10 -5
- package/dist/lib/helpers/differentAppSettingsHelpers/InstallUiHelper.js.map +1 -1
- package/dist/lib/helpers/index.d.ts +4 -1
- package/dist/lib/helpers/index.js +9 -3
- package/dist/lib/helpers/index.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/dist/lib/helpers/BasePage.d.ts +0 -449
- package/dist/lib/helpers/BasePage.js +0 -547
- package/dist/lib/helpers/BasePage.js.map +0 -1
|
@@ -1,61 +1,69 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DictionaryApiHelper = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
async
|
|
10
|
-
const response = await this.api.get(this.api.baseUrl + '/umbraco/management/api/v1/dictionary/' + id);
|
|
11
|
-
return await response.json();
|
|
12
|
-
}
|
|
13
|
-
async doesExist(id) {
|
|
14
|
-
const response = await this.api.get(this.api.baseUrl + '/umbraco/management/api/v1/dictionary/' + id);
|
|
15
|
-
return response.status() === 200;
|
|
16
|
-
}
|
|
17
|
-
async create(name, translations, parentId) {
|
|
4
|
+
const TreeApiHelper_1 = require("./TreeApiHelper");
|
|
5
|
+
class DictionaryApiHelper extends TreeApiHelper_1.TreeApiHelper {
|
|
6
|
+
resourcePath = 'dictionary';
|
|
7
|
+
treePath = 'tree/dictionary';
|
|
8
|
+
// Dictionary-specific create with translations
|
|
9
|
+
async createDictionary(name, translations, parentId) {
|
|
18
10
|
const dictionary = {
|
|
19
11
|
"name": name,
|
|
20
12
|
"translations": translations,
|
|
21
13
|
"parent": parentId ? { "id": parentId } : null
|
|
22
14
|
};
|
|
23
|
-
const response = await this.api.post(this.
|
|
24
|
-
// Returns the id of the created dictionary
|
|
15
|
+
const response = await this.api.post(this.buildUrl(), dictionary);
|
|
25
16
|
return response.headers().location.split("/").pop();
|
|
26
17
|
}
|
|
27
|
-
async update(id, dictionary) {
|
|
28
|
-
return await this.api.put(this.api.baseUrl + '/umbraco/management/api/v1/dictionary/' + id, dictionary);
|
|
29
|
-
}
|
|
30
|
-
async delete(id) {
|
|
31
|
-
return await this.api.delete(this.api.baseUrl + '/umbraco/management/api/v1/dictionary/' + id);
|
|
32
|
-
}
|
|
33
|
-
async getAllAtRoot() {
|
|
34
|
-
return await this.api.get(this.api.baseUrl + '/umbraco/management/api/v1/tree/dictionary/root?skip=0&take=10000');
|
|
35
|
-
}
|
|
36
18
|
async getItems(ids) {
|
|
37
19
|
let idArray = 'id=' + ids[0];
|
|
38
|
-
let i;
|
|
39
|
-
for (i = 1; i < ids.length; ++i) {
|
|
20
|
+
for (let i = 1; i < ids.length; ++i) {
|
|
40
21
|
idArray += '&id=' + ids[i];
|
|
41
22
|
}
|
|
42
|
-
const response = await this.api.get(this.api.baseUrl
|
|
23
|
+
const response = await this.api.get(`${this.api.baseUrl}/umbraco/management/api/v1/${this.treePath}/item?${idArray}`);
|
|
43
24
|
const json = await response.json();
|
|
44
|
-
|
|
45
|
-
|
|
25
|
+
return json !== null ? json : null;
|
|
26
|
+
}
|
|
27
|
+
// Override - Dictionary uses isContainer check
|
|
28
|
+
async getByName(name) {
|
|
29
|
+
const rootItems = await this.getAllAtRoot();
|
|
30
|
+
const jsonItems = await rootItems.json();
|
|
31
|
+
for (const item of jsonItems.items) {
|
|
32
|
+
if (item.name === name) {
|
|
33
|
+
return this.get(item.id);
|
|
34
|
+
}
|
|
35
|
+
else if (item.isContainer || item.hasChildren) {
|
|
36
|
+
const result = await this.recurseDictionaryChildren(name, item.id, false);
|
|
37
|
+
if (result) {
|
|
38
|
+
return result;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
46
41
|
}
|
|
47
|
-
return
|
|
42
|
+
return false;
|
|
48
43
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const
|
|
52
|
-
|
|
44
|
+
// Override - Dictionary uses isContainer check
|
|
45
|
+
async ensureNameNotExists(name) {
|
|
46
|
+
const rootItems = await this.getAllAtRoot();
|
|
47
|
+
const jsonItems = await rootItems.json();
|
|
48
|
+
for (const item of jsonItems.items) {
|
|
49
|
+
if (item.name === name) {
|
|
50
|
+
if (item.isContainer || item.hasChildren) {
|
|
51
|
+
await this.recurseDeleteDictionaryChildren(item.id);
|
|
52
|
+
}
|
|
53
|
+
await this.delete(item.id);
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
if (item.isContainer || item.hasChildren) {
|
|
57
|
+
await this.recurseDictionaryChildren(name, item.id, true);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
53
61
|
}
|
|
54
|
-
async
|
|
62
|
+
async recurseDeleteDictionaryChildren(id) {
|
|
55
63
|
const items = await this.getChildren(id);
|
|
56
64
|
for (const child of items) {
|
|
57
65
|
if (child.isContainer || child.hasChildren) {
|
|
58
|
-
await this.
|
|
66
|
+
await this.recurseDeleteDictionaryChildren(child.id);
|
|
59
67
|
}
|
|
60
68
|
else {
|
|
61
69
|
await this.delete(child.id);
|
|
@@ -63,7 +71,7 @@ class DictionaryApiHelper {
|
|
|
63
71
|
}
|
|
64
72
|
return await this.delete(id);
|
|
65
73
|
}
|
|
66
|
-
async
|
|
74
|
+
async recurseDictionaryChildren(name, id, toDelete) {
|
|
67
75
|
const items = await this.getChildren(id);
|
|
68
76
|
for (const child of items) {
|
|
69
77
|
if (child.name === name) {
|
|
@@ -71,54 +79,18 @@ class DictionaryApiHelper {
|
|
|
71
79
|
return await this.get(child.id);
|
|
72
80
|
}
|
|
73
81
|
if (child.isContainer || child.hasChildren) {
|
|
74
|
-
return await this.
|
|
82
|
+
return await this.recurseDeleteDictionaryChildren(child.id);
|
|
75
83
|
}
|
|
76
84
|
else {
|
|
77
85
|
return await this.delete(child.id);
|
|
78
86
|
}
|
|
79
87
|
}
|
|
80
88
|
else if (child.isContainer || child.hasChildren) {
|
|
81
|
-
await this.
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
async getByName(name) {
|
|
87
|
-
const rootDictionary = await this.getAllAtRoot();
|
|
88
|
-
const jsonDictionary = await rootDictionary.json();
|
|
89
|
-
for (const dictionaryItem of jsonDictionary.items) {
|
|
90
|
-
if (dictionaryItem.name === name) {
|
|
91
|
-
return this.get(dictionaryItem.id);
|
|
92
|
-
}
|
|
93
|
-
else if (dictionaryItem.isContainer || dictionaryItem.hasChildren) {
|
|
94
|
-
const result = await this.recurseChildren(name, dictionaryItem.id, false);
|
|
95
|
-
if (result) {
|
|
96
|
-
return result;
|
|
97
|
-
}
|
|
89
|
+
await this.recurseDictionaryChildren(name, child.id, toDelete);
|
|
98
90
|
}
|
|
99
91
|
}
|
|
100
92
|
return false;
|
|
101
93
|
}
|
|
102
|
-
async doesNameExist(name) {
|
|
103
|
-
return await this.getByName(name);
|
|
104
|
-
}
|
|
105
|
-
async ensureNameNotExists(name) {
|
|
106
|
-
const rootDictionary = await this.getAllAtRoot();
|
|
107
|
-
const jsonDictionary = await rootDictionary.json();
|
|
108
|
-
for (const dictionaryItem of jsonDictionary.items) {
|
|
109
|
-
if (dictionaryItem.name === name) {
|
|
110
|
-
if (dictionaryItem.isContainer || dictionaryItem.hasChildren) {
|
|
111
|
-
await this.recurseDeleteChildren(dictionaryItem.id);
|
|
112
|
-
}
|
|
113
|
-
await this.delete(dictionaryItem.id);
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
if (dictionaryItem.isContainer || dictionaryItem.hasChildren) {
|
|
117
|
-
await this.recurseChildren(name, dictionaryItem.id, true);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
94
|
async export(id, includeChildren) {
|
|
123
95
|
return await this.api.get(this.api.baseUrl + '/umbraco/management/api/v1/dictionary/' + id + '/export?includeChidren=' + includeChildren);
|
|
124
96
|
}
|
|
@@ -140,7 +112,7 @@ class DictionaryApiHelper {
|
|
|
140
112
|
"translation": name
|
|
141
113
|
}
|
|
142
114
|
];
|
|
143
|
-
return await this.
|
|
115
|
+
return await this.createDictionary(name, translations);
|
|
144
116
|
}
|
|
145
117
|
}
|
|
146
118
|
exports.DictionaryApiHelper = DictionaryApiHelper;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DictionaryApiHelper.js","sourceRoot":"","sources":["../../../lib/helpers/DictionaryApiHelper.ts"],"names":[],"mappings":";;;AAEA,MAAa,mBAAmB;IAC9B,GAAG,CAAY;IAEf,YAAY,GAAe;QACzB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,EAAU;QAClB,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,GAAG,wCAAwC,GAAG,EAAE,CAAC,CAAC;QACtG,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAE,C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BAAyB,GAAG,eAAe,CAAC,CAAC;IAC5I,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,eAAuB,EAAE,QAAgB;QACpD,MAAM,gBAAgB,GAAG;YACvB,eAAe,EAAE,eAAe,CAAC,CAAC,CAAC,EAAC,IAAI,EAAG,eAAe,EAAC,CAAC,CAAC,CAAC,IAAI;YAClE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC,EAAC,IAAI,EAAG,QAAQ,EAAC,CAAC,CAAC,CAAC,IAAI;SAC9C,CAAA;QACD,OAAO,MAAM,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,GAAG,8CAA8C,EAAE,gBAAgB,CAAC,CAAC;IAClH,CAAC;IAED,KAAK,CAAC,uBAAuB,CAAC,IAAY;QACxC,MAAM,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,CAAC;QACrC,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC;QACtD,MAAM,aAAa,GAAG,MAAM,YAAY,CAAC,IAAI,EAAE,CAAC;QAChD,MAAM,eAAe,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;QACvD,MAAM,YAAY,GAAG;YACnB;gBACE,SAAS,EAAE,eAAe;gBAC1B,aAAa,EAAE,IAAI;aACpB;SACF,CAAC;QAEF,OAAO,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IAC/C,CAAC;CACF;AAhKD,kDAgKC","sourcesContent":["import {ApiHelpers} from \"./ApiHelpers\";\n\nexport class DictionaryApiHelper {\n api: ApiHelpers\n\n constructor(api: ApiHelpers) {\n this.api = api;\n }\n\n async get(id: string) {\n const response = await this.api.get(this.api.baseUrl + '/umbraco/management/api/v1/dictionary/' + id);\n return await response.json();\n }\n\n async doesExist(id: string) {\n const response = await this.api.get(this.api.baseUrl + '/umbraco/management/api/v1/dictionary/' + id);\n return response.status() === 200;\n }\n\n async create(name: string, translations?: { isoCode: string, translation: string }[], parentId?: string) {\n const dictionary = {\n \"name\": name,\n \"translations\": translations,\n \"parent\": parentId ? {\"id\" : parentId} : null\n }\n const response = await this.api.post(this.api.baseUrl + '/umbraco/management/api/v1/dictionary', dictionary);\n // Returns the id of the created dictionary\n return response.headers().location.split(\"/\").pop();\n }\n\n async update(id: string, dictionary: object) {\n return await this.api.put(this.api.baseUrl + '/umbraco/management/api/v1/dictionary/' + id, dictionary);\n }\n\n async delete(id: string) {\n return await this.api.delete(this.api.baseUrl + '/umbraco/management/api/v1/dictionary/' + id);\n }\n\n async getAllAtRoot() {\n return await this.api.get(this.api.baseUrl + '/umbraco/management/api/v1/tree/dictionary/root?skip=0&take=10000');\n }\n\n async getItems(ids: string[]) {\n let idArray = 'id=' + ids[0];\n let i: number;\n\n for (i = 1; i < ids.length; ++i) {\n idArray += '&id=' + ids[i];\n }\n const response = await this.api.get(this.api.baseUrl + '/umbraco/management/api/v1/tree/dictionary/item?' + idArray);\n const json = await response.json();\n\n if (json !== null) {\n return json;\n }\n return null;\n }\n\n async getChildren(id: string) {\n const response = await this.api.get(this.api.baseUrl + '/umbraco/management/api/v1/tree/dictionary/children?parentId=' + id + '&skip=0&take=10000');\n const items = await response.json();\n return items.items;\n }\n\n private async recurseDeleteChildren(id: string) {\n const items = await this.getChildren(id);\n\n for (const child of items) {\n if (child.isContainer || child.hasChildren) {\n await this.recurseDeleteChildren(child.id);\n } else {\n await this.delete(child.id);\n }\n }\n return await this.delete(id);\n }\n\n private async recurseChildren(name: string, id: string, toDelete: boolean) {\n const items = await this.getChildren(id);\n\n for (const child of items) {\n if (child.name === name) {\n if (!toDelete) {\n return await this.get(child.id);\n }\n if (child.isContainer || child.hasChildren) {\n return await this.recurseDeleteChildren(child.id);\n } else {\n return await this.delete(child.id);\n }\n } else if (child.isContainer || child.hasChildren) {\n await this.recurseChildren(name, child.id, toDelete);\n }\n }\n return false;\n }\n\n async getByName(name: string) {\n const rootDictionary = await this.getAllAtRoot();\n const jsonDictionary = await rootDictionary.json();\n\n for (const dictionaryItem of jsonDictionary.items) {\n if (dictionaryItem.name === name) {\n return this.get(dictionaryItem.id);\n } else if (dictionaryItem.isContainer || dictionaryItem.hasChildren) {\n const result = await this.recurseChildren(name, dictionaryItem.id, false);\n if (result) {\n return result;\n }\n }\n }\n return false;\n }\n\n async doesNameExist(name: string) {\n return await this.getByName(name);\n }\n\n async ensureNameNotExists(name: string) {\n const rootDictionary = await this.getAllAtRoot();\n const jsonDictionary = await rootDictionary.json();\n\n for (const dictionaryItem of jsonDictionary.items) {\n if (dictionaryItem.name === name) {\n if (dictionaryItem.isContainer || dictionaryItem.hasChildren) {\n await this.recurseDeleteChildren(dictionaryItem.id);\n }\n await this.delete(dictionaryItem.id);\n } else {\n if (dictionaryItem.isContainer || dictionaryItem.hasChildren) {\n await this.recurseChildren(name, dictionaryItem.id, true);\n }\n }\n }\n }\n\n async export(id: string, includeChildren: boolean) {\n return await this.api.get(this.api.baseUrl + '/umbraco/management/api/v1/dictionary/' + id + '/export?includeChidren=' + includeChildren);\n }\n\n async import(temporaryFileId: string, parentId: string) {\n const importDictionary = {\n \"temporaryFile\": temporaryFileId ? {\"id\" : temporaryFileId} : null,\n \"parent\": parentId ? {\"id\" : parentId} : null\n }\n return await this.api.post(this.api.baseUrl + '/umbraco/management/api/v1/dictionary/import', importDictionary);\n }\n\n async createDefaultDictionary(name: string) {\n await this.ensureNameNotExists(name);\n const allLanguages = await this.api.language.getAll();\n const jsonLanguages = await allLanguages.json();\n const languageIsoCode = jsonLanguages.items[0].isoCode;\n const translations = [\n {\n \"isoCode\": languageIsoCode,\n \"translation\": name\n }\n ];\n\n return await this.create(name, translations);\n }\n}"]}
|
|
1
|
+
{"version":3,"file":"DictionaryApiHelper.js","sourceRoot":"","sources":["../../../lib/helpers/DictionaryApiHelper.ts"],"names":[],"mappings":";;;AAAA,mDAA8C;AAE9C,MAAa,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eApiHelper {\n protected resourcePath = 'dictionary';\n protected treePath = 'tree/dictionary';\n\n // Dictionary-specific create with translations\n async createDictionary(name: string, translations?: { isoCode: string, translation: string }[], parentId?: string) {\n const dictionary = {\n \"name\": name,\n \"translations\": translations,\n \"parent\": parentId ? {\"id\": parentId} : null\n };\n const response = await this.api.post(this.buildUrl(), dictionary);\n return response.headers().location.split(\"/\").pop();\n }\n\n async getItems(ids: string[]) {\n let idArray = 'id=' + ids[0];\n for (let i = 1; i < ids.length; ++i) {\n idArray += '&id=' + ids[i];\n }\n const response = await this.api.get(`${this.api.baseUrl}/umbraco/management/api/v1/${this.treePath}/item?${idArray}`);\n const json = await response.json();\n return json !== null ? json : null;\n }\n\n // Override - Dictionary uses isContainer check\n async getByName(name: string): Promise<any> {\n const rootItems = await this.getAllAtRoot();\n const jsonItems = await rootItems.json();\n\n for (const item of jsonItems.items) {\n if (item.name === name) {\n return this.get(item.id);\n } else if (item.isContainer || item.hasChildren) {\n const result = await this.recurseDictionaryChildren(name, item.id, false);\n if (result) {\n return result;\n }\n }\n }\n return false;\n }\n\n // Override - Dictionary uses isContainer check\n async ensureNameNotExists(name: string): Promise<any> {\n const rootItems = await this.getAllAtRoot();\n const jsonItems = await rootItems.json();\n\n for (const item of jsonItems.items) {\n if (item.name === name) {\n if (item.isContainer || item.hasChildren) {\n await this.recurseDeleteDictionaryChildren(item.id);\n }\n await this.delete(item.id);\n } else {\n if (item.isContainer || item.hasChildren) {\n await this.recurseDictionaryChildren(name, item.id, true);\n }\n }\n }\n }\n\n private async recurseDeleteDictionaryChildren(id: string) {\n const items = await this.getChildren(id);\n\n for (const child of items) {\n if (child.isContainer || child.hasChildren) {\n await this.recurseDeleteDictionaryChildren(child.id);\n } else {\n await this.delete(child.id);\n }\n }\n return await this.delete(id);\n }\n\n private async recurseDictionaryChildren(name: string, id: string, toDelete: boolean) {\n const items = await this.getChildren(id);\n\n for (const child of items) {\n if (child.name === name) {\n if (!toDelete) {\n return await this.get(child.id);\n }\n if (child.isContainer || child.hasChildren) {\n return await this.recurseDeleteDictionaryChildren(child.id);\n } else {\n return await this.delete(child.id);\n }\n } else if (child.isContainer || child.hasChildren) {\n await this.recurseDictionaryChildren(name, child.id, toDelete);\n }\n }\n return false;\n }\n\n async export(id: string, includeChildren: boolean) {\n return await this.api.get(this.api.baseUrl + '/umbraco/management/api/v1/dictionary/' + id + '/export?includeChidren=' + includeChildren);\n }\n\n async import(temporaryFileId: string, parentId: string) {\n const importDictionary = {\n \"temporaryFile\": temporaryFileId ? {\"id\" : temporaryFileId} : null,\n \"parent\": parentId ? {\"id\" : parentId} : null\n }\n return await this.api.post(this.api.baseUrl + '/umbraco/management/api/v1/dictionary/import', importDictionary);\n }\n\n async createDefaultDictionary(name: string) {\n await this.ensureNameNotExists(name);\n const allLanguages = await this.api.language.getAll();\n const jsonLanguages = await allLanguages.json();\n const languageIsoCode = jsonLanguages.items[0].isoCode;\n const translations = [\n {\n \"isoCode\": languageIsoCode,\n \"translation\": name\n }\n ];\n\n return await this.createDictionary(name, translations);\n }\n}"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DictionaryUiHelper = void 0;
|
|
4
|
+
const test_1 = require("@playwright/test");
|
|
4
5
|
const UiBaseLocators_1 = require("./UiBaseLocators");
|
|
5
6
|
class DictionaryUiHelper extends UiBaseLocators_1.UiBaseLocators {
|
|
6
7
|
createDictionaryItemBtn;
|
|
@@ -35,39 +36,43 @@ class DictionaryUiHelper extends UiBaseLocators_1.UiBaseLocators {
|
|
|
35
36
|
this.dictionaryCollection = page.locator('umb-dictionary-collection');
|
|
36
37
|
}
|
|
37
38
|
async clickCreateDictionaryItemButton() {
|
|
38
|
-
await
|
|
39
|
+
await (0, test_1.expect)(this.createDictionaryItemBtn).toBeVisible();
|
|
40
|
+
await this.createDictionaryItemBtn.click();
|
|
39
41
|
}
|
|
40
42
|
async enterDictionaryName(name) {
|
|
41
|
-
await
|
|
43
|
+
await (0, test_1.expect)(this.dictionaryNameTxt).toBeVisible();
|
|
44
|
+
await this.dictionaryNameTxt.clear();
|
|
45
|
+
await this.dictionaryNameTxt.fill(name);
|
|
42
46
|
}
|
|
43
47
|
async clickActionsMenuForDictionary(name) {
|
|
44
48
|
await this.clickActionsMenuForName(name);
|
|
45
49
|
}
|
|
46
50
|
async enterSearchKeywordAndPressEnter(keyword) {
|
|
47
|
-
await this.
|
|
48
|
-
await this.
|
|
51
|
+
await this.searchTxt.clear();
|
|
52
|
+
await this.searchTxt.fill(keyword);
|
|
53
|
+
await this.page.keyboard.press('Enter');
|
|
49
54
|
}
|
|
50
55
|
async clickExportButton() {
|
|
51
|
-
await this.click(
|
|
56
|
+
await this.exportBtn.click();
|
|
52
57
|
}
|
|
53
58
|
async clickImportButton() {
|
|
54
|
-
await this.click(
|
|
59
|
+
await this.importBtn.click();
|
|
55
60
|
}
|
|
56
61
|
async waitForDictionaryToBeCreated() {
|
|
57
|
-
await this.waitForLoadState();
|
|
62
|
+
await this.page.waitForLoadState();
|
|
58
63
|
}
|
|
59
64
|
async waitForDictionaryToBeDeleted() {
|
|
60
|
-
await this.waitForLoadState();
|
|
65
|
+
await this.page.waitForLoadState();
|
|
61
66
|
}
|
|
62
67
|
async waitForDictionaryToBeImported() {
|
|
63
|
-
await this.waitForLoadState();
|
|
68
|
+
await this.page.waitForLoadState();
|
|
64
69
|
}
|
|
65
70
|
async deleteDictionary() {
|
|
66
71
|
await this.clickDeleteActionMenuOption();
|
|
67
|
-
await this.click(
|
|
72
|
+
await this.confirmToDeleteBtn.click();
|
|
68
73
|
}
|
|
69
74
|
async doesDictionaryListHaveText(text) {
|
|
70
|
-
await
|
|
75
|
+
await (0, test_1.expect)(this.dictionaryList).toBeVisible();
|
|
71
76
|
const allRows = await this.dictionaryListRows.all();
|
|
72
77
|
for (let currentRow of allRows) {
|
|
73
78
|
const currentText = await currentRow.innerText();
|
|
@@ -80,26 +85,27 @@ class DictionaryUiHelper extends UiBaseLocators_1.UiBaseLocators {
|
|
|
80
85
|
// This function will export dictionary and return the file name
|
|
81
86
|
async exportDictionary(includesDescendants) {
|
|
82
87
|
if (includesDescendants) {
|
|
83
|
-
await this.click(
|
|
88
|
+
await this.includeDescendantsCheckbox.click();
|
|
84
89
|
}
|
|
85
90
|
const [downloadPromise] = await Promise.all([
|
|
86
91
|
this.page.waitForEvent('download'),
|
|
87
|
-
await this.click(
|
|
92
|
+
await this.exportModalBtn.click()
|
|
88
93
|
]);
|
|
89
94
|
return downloadPromise.suggestedFilename();
|
|
90
95
|
}
|
|
91
96
|
async importDictionary(filePath) {
|
|
92
97
|
await this.importFileTxt.setInputFiles(filePath);
|
|
93
|
-
await
|
|
98
|
+
await (0, test_1.expect)(this.importModalBtn).toBeVisible();
|
|
99
|
+
await this.importModalBtn.click();
|
|
94
100
|
}
|
|
95
101
|
async isSearchResultMessageDisplayEmpty(message) {
|
|
96
|
-
await
|
|
102
|
+
return await (0, test_1.expect)(this.emptySearchResultMessage).toHaveText(message);
|
|
97
103
|
}
|
|
98
104
|
async isDictionaryTreeItemVisible(dictionaryName, isVisible = true) {
|
|
99
|
-
await
|
|
105
|
+
return await (0, test_1.expect)(this.dictionaryTree.getByText(dictionaryName, { exact: true })).toBeVisible({ visible: isVisible });
|
|
100
106
|
}
|
|
101
107
|
async doesDictionaryCollectionContainText(text) {
|
|
102
|
-
await
|
|
108
|
+
return await (0, test_1.expect)(this.dictionaryCollection).toContainText(text);
|
|
103
109
|
}
|
|
104
110
|
}
|
|
105
111
|
exports.DictionaryUiHelper = DictionaryUiHelper;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DictionaryUiHelper.js","sourceRoot":"","sources":["../../../lib/helpers/DictionaryUiHelper.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"DictionaryUiHelper.js","sourceRoot":"","sources":["../../../lib/helpers/DictionaryUiHelper.ts"],"names":[],"mappings":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AK,EAAE,CAAC;SAC/C;QACD,MAAM,CAAC,eAAe,CAAC,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC;YAC1C,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC;YAClC,MAAM,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE;SAClC,CAAC,CAAC;QACH,OAAO,eAAe,CAAC,iBAAiB,EAAE,CAAC;IAC7C,CAAC;IAED,KAAK,CAAC,gBAAgB,CAAC,QAAgB;QACrC,MAAM,IAAI,CAAC,aAAa,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;QACjD,MAAM,IAAA,aAAM,EAAC,IAAI,CAAC,cAAc,CAAC,CAAC,WAAW,EAAE,CAAC;QAChD,MAAM,IAAI,CAAC,cAAc,CAAC,KAAK,EAAE,CAAC;IACpC,CAAC;IAED,KAAK,CAAC,iCAAiC,CAAC,OAAe;QACrD,OAAO,MAAM,IAAA,aAAM,EAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IACzE,CAAC;IAED,KAAK,CAAC,2BAA2B,CAAC,cAAsB,EAAE,YAAqB,IAAI;QACjF,OAAO,MAAM,IAAA,aAAM,EAAC,IAAI,CAAC,cAAc,CAAC,SAAS,CAAC,cAAc,EAAE,EAAC,KAAK,EAAE,IAAI,EAAC,CAAC,CAAC,CAAC,WAAW,CAAC,EAAC,OAAO,EAAE,SAAS,EAAC,CAAC,CAAC;IACtH,CAAC;IAED,KAAK,CAAC,mCAAmC,CAAC,IAAY;QACpD,OAAO,MAAM,IAAA,aAAM,EAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IACrE,CAAC;CACF;AAzHD,gDAyHC","sourcesContent":["import {Page, Locator, expect} from \"@playwright/test\";\nimport {UiBaseLocators} from \"./UiBaseLocators\";\n\nexport class DictionaryUiHelper extends UiBaseLocators {\n private readonly createDictionaryItemBtn: Locator;\n private readonly dictionaryNameTxt: Locator;\n private readonly searchTxt: Locator;\n private readonly exportBtn: Locator;\n private readonly includeDescendantsCheckbox: Locator;\n private readonly importBtn: Locator;\n private readonly importFileTxt: Locator;\n private readonly emptySearchResultMessage: Locator;\n private readonly dictionaryList: Locator;\n private readonly dictionaryListRows: Locator;\n private readonly dictionaryTree: Locator;\n private readonly dictionaryCollection: Locator;\n private readonly exportModalBtn: Locator;\n private readonly importModalBtn: Locator;\n\n constructor(page: Page) {\n super(page);\n this.createDictionaryItemBtn = page.getByLabel('Create dictionary item', {exact: true});\n this.dictionaryNameTxt = page.locator('umb-workspace-header-name-editable').locator('input');\n this.exportBtn = page.getByRole('button', {name: /^Export(…)?$/});\n this.importBtn = page.getByRole('button', {name: /^Import(…)?$/});\n this.searchTxt = page.locator('uui-input').getByLabel('Search');\n this.dictionaryList = page.locator('umb-dictionary-table-collection-view');\n this.dictionaryListRows = this.dictionaryList.locator('uui-table-row');\n this.exportModalBtn = page.locator('umb-export-dictionary-modal').getByLabel('Export');\n this.includeDescendantsCheckbox = page.locator('umb-export-dictionary-modal #includeDescendants');\n this.importModalBtn = page.locator('uui-button').filter({hasText: 'Import'}).getByLabel('Import');\n this.importFileTxt = page.locator('umb-import-dictionary-modal #input');\n this.emptySearchResultMessage = page.locator('#empty-state');\n this.dictionaryTree = page.locator('umb-tree[alias=\"Umb.Tree.Dictionary\"]');\n this.dictionaryCollection = page.locator('umb-dictionary-collection');\n }\n\n async clickCreateDictionaryItemButton() {\n await expect(this.createDictionaryItemBtn).toBeVisible();\n await this.createDictionaryItemBtn.click();\n }\n\n async enterDictionaryName(name: string) {\n await expect(this.dictionaryNameTxt).toBeVisible();\n await this.dictionaryNameTxt.clear();\n await this.dictionaryNameTxt.fill(name);\n }\n\n async clickActionsMenuForDictionary(name: string) {\n await this.clickActionsMenuForName(name);\n }\n\n async enterSearchKeywordAndPressEnter(keyword: string) {\n await this.searchTxt.clear();\n await this.searchTxt.fill(keyword);\n await this.page.keyboard.press('Enter');\n }\n\n async clickExportButton() {\n await this.exportBtn.click();\n }\n\n async clickImportButton() {\n await this.importBtn.click();\n }\n\n async waitForDictionaryToBeCreated() {\n await this.page.waitForLoadState();\n }\n \n async waitForDictionaryToBeDeleted() {\n await this.page.waitForLoadState();\n }\n \n async waitForDictionaryToBeImported() {\n await this.page.waitForLoadState();\n }\n \n async deleteDictionary() {\n await this.clickDeleteActionMenuOption();\n await this.confirmToDeleteBtn.click();\n }\n\n async doesDictionaryListHaveText(text: string) {\n await expect(this.dictionaryList).toBeVisible();\n const allRows = await this.dictionaryListRows.all();\n for (let currentRow of allRows) {\n const currentText = await currentRow.innerText();\n if (currentText.includes(text)) {\n return true;\n }\n }\n return false;\n }\n\n // This function will export dictionary and return the file name\n async exportDictionary(includesDescendants: boolean) {\n if (includesDescendants) {\n await this.includeDescendantsCheckbox.click();\n }\n const [downloadPromise] = await Promise.all([\n this.page.waitForEvent('download'),\n await this.exportModalBtn.click()\n ]);\n return downloadPromise.suggestedFilename();\n }\n\n async importDictionary(filePath: string) {\n await this.importFileTxt.setInputFiles(filePath);\n await expect(this.importModalBtn).toBeVisible();\n await this.importModalBtn.click();\n }\n\n async isSearchResultMessageDisplayEmpty(message: string) {\n return await expect(this.emptySearchResultMessage).toHaveText(message);\n }\n\n async isDictionaryTreeItemVisible(dictionaryName: string, isVisible: boolean = true) {\n return await expect(this.dictionaryTree.getByText(dictionaryName, {exact: true})).toBeVisible({visible: isVisible});\n }\n\n async doesDictionaryCollectionContainText(text: string) {\n return await expect(this.dictionaryCollection).toContainText(text);\n }\n}"]}
|
|
@@ -1,19 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare class DocumentBlueprintApiHelper {
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
import { TreeApiHelper } from "./TreeApiHelper";
|
|
2
|
+
export declare class DocumentBlueprintApiHelper extends TreeApiHelper {
|
|
3
|
+
protected resourcePath: string;
|
|
4
|
+
protected treePath: string;
|
|
5
5
|
get(id: string): Promise<any>;
|
|
6
|
-
doesExist(id: string): Promise<boolean>;
|
|
7
6
|
create(documentBlueprint: any): Promise<string | undefined>;
|
|
8
|
-
delete(id: string): Promise<number | undefined>;
|
|
9
|
-
update(id: string, documentBlueprint: any): Promise<import("playwright-core").APIResponse | undefined>;
|
|
10
|
-
getAllAtRoot(): Promise<import("playwright-core").APIResponse>;
|
|
11
|
-
getChildren(id: string): Promise<any>;
|
|
12
|
-
doesNameExist(name: string): Promise<any>;
|
|
13
|
-
private recurseDeleteChildren;
|
|
14
|
-
private recurseChildren;
|
|
15
7
|
getByName(name: string): Promise<any>;
|
|
16
|
-
ensureNameNotExists(name: string): Promise<
|
|
8
|
+
ensureNameNotExists(name: string): Promise<any>;
|
|
9
|
+
private recurseDeleteBlueprintChildren;
|
|
10
|
+
private recurseBlueprintChildren;
|
|
17
11
|
createDefaultDocumentBlueprint(documentBlueprintName: string, documentTypeId: string): Promise<string | undefined>;
|
|
18
12
|
createFromDocument(documentBlueprintName: string, documentId: string, parentId?: string): Promise<string | undefined>;
|
|
19
13
|
createDocumentBlueprintWithTextBoxValue(documentBlueprintName: string, documentTypeId: string, dataTypeName: string, text: string): Promise<string | undefined>;
|
|
@@ -1,56 +1,63 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.DocumentBlueprintApiHelper = void 0;
|
|
4
|
+
const TreeApiHelper_1 = require("./TreeApiHelper");
|
|
4
5
|
const json_models_builders_1 = require("@umbraco/json-models-builders");
|
|
5
|
-
class DocumentBlueprintApiHelper {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
6
|
+
class DocumentBlueprintApiHelper extends TreeApiHelper_1.TreeApiHelper {
|
|
7
|
+
resourcePath = 'document-blueprint';
|
|
8
|
+
treePath = 'tree/document-blueprint';
|
|
9
|
+
// Override - return json directly instead of null check
|
|
10
10
|
async get(id) {
|
|
11
|
-
const response = await this.api.get(this.
|
|
11
|
+
const response = await this.api.get(this.buildUrl('/' + id));
|
|
12
12
|
return await response.json();
|
|
13
13
|
}
|
|
14
|
-
|
|
15
|
-
const response = await this.api.get(this.api.baseUrl + '/umbraco/management/api/v1/document-blueprint/' + id);
|
|
16
|
-
return response.status() === 200;
|
|
17
|
-
}
|
|
14
|
+
// Override - different location split pattern
|
|
18
15
|
async create(documentBlueprint) {
|
|
19
16
|
if (documentBlueprint == null) {
|
|
20
17
|
return;
|
|
21
18
|
}
|
|
22
|
-
const response = await this.api.post(this.
|
|
19
|
+
const response = await this.api.post(this.buildUrl(), documentBlueprint);
|
|
23
20
|
return response.headers().location.split("v1/document-blueprint/").pop();
|
|
24
21
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
// Override - DocumentBlueprint has no folders
|
|
23
|
+
async getByName(name) {
|
|
24
|
+
const rootItems = await this.getAllAtRoot();
|
|
25
|
+
const jsonItems = await rootItems.json();
|
|
26
|
+
for (const item of jsonItems.items) {
|
|
27
|
+
if (item.name === name) {
|
|
28
|
+
return this.get(item.id);
|
|
29
|
+
}
|
|
30
|
+
else if (item.hasChildren) {
|
|
31
|
+
const result = await this.recurseBlueprintChildren(name, item.id, false);
|
|
32
|
+
if (result) {
|
|
33
|
+
return result;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
28
36
|
}
|
|
29
|
-
|
|
30
|
-
return response.status();
|
|
37
|
+
return false;
|
|
31
38
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
39
|
+
// Override - DocumentBlueprint has no folders
|
|
40
|
+
async ensureNameNotExists(name) {
|
|
41
|
+
const rootItems = await this.getAllAtRoot();
|
|
42
|
+
const jsonItems = await rootItems.json();
|
|
43
|
+
for (const item of jsonItems.items) {
|
|
44
|
+
if (item.name === name) {
|
|
45
|
+
if (item.hasChildren) {
|
|
46
|
+
await this.recurseDeleteBlueprintChildren(item.id);
|
|
47
|
+
}
|
|
48
|
+
return await this.delete(item.id);
|
|
49
|
+
}
|
|
50
|
+
else if (item.hasChildren) {
|
|
51
|
+
await this.recurseBlueprintChildren(name, item.id, true);
|
|
52
|
+
}
|
|
35
53
|
}
|
|
36
|
-
return
|
|
37
|
-
}
|
|
38
|
-
async getAllAtRoot() {
|
|
39
|
-
return await this.api.get(this.api.baseUrl + '/umbraco/management/api/v1/tree/document-blueprint/root?skip=0&take=1000&foldersOnly=false');
|
|
40
|
-
}
|
|
41
|
-
async getChildren(id) {
|
|
42
|
-
const response = await this.api.get(`${this.api.baseUrl}/umbraco/management/api/v1/tree/document-blueprint/children?parentId=${id}&skip=0&take=10000&foldersOnly=false`);
|
|
43
|
-
const items = await response.json();
|
|
44
|
-
return items.items;
|
|
45
|
-
}
|
|
46
|
-
async doesNameExist(name) {
|
|
47
|
-
return await this.getByName(name);
|
|
54
|
+
return null;
|
|
48
55
|
}
|
|
49
|
-
async
|
|
56
|
+
async recurseDeleteBlueprintChildren(id) {
|
|
50
57
|
const items = await this.getChildren(id);
|
|
51
58
|
for (const child of items) {
|
|
52
59
|
if (child.hasChildren) {
|
|
53
|
-
await this.
|
|
60
|
+
await this.recurseDeleteBlueprintChildren(child.id);
|
|
54
61
|
}
|
|
55
62
|
else {
|
|
56
63
|
await this.delete(child.id);
|
|
@@ -58,7 +65,7 @@ class DocumentBlueprintApiHelper {
|
|
|
58
65
|
}
|
|
59
66
|
return await this.delete(id);
|
|
60
67
|
}
|
|
61
|
-
async
|
|
68
|
+
async recurseBlueprintChildren(name, id, toDelete) {
|
|
62
69
|
const items = await this.getChildren(id);
|
|
63
70
|
for (const child of items) {
|
|
64
71
|
if (child.name === name) {
|
|
@@ -66,50 +73,18 @@ class DocumentBlueprintApiHelper {
|
|
|
66
73
|
return await this.get(child.id);
|
|
67
74
|
}
|
|
68
75
|
if (child.hasChildren) {
|
|
69
|
-
return await this.
|
|
76
|
+
return await this.recurseDeleteBlueprintChildren(child.id);
|
|
70
77
|
}
|
|
71
78
|
else {
|
|
72
79
|
return await this.delete(child.id);
|
|
73
80
|
}
|
|
74
81
|
}
|
|
75
82
|
else if (child.hasChildren) {
|
|
76
|
-
await this.
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
return false;
|
|
80
|
-
}
|
|
81
|
-
async getByName(name) {
|
|
82
|
-
const rootDocumentBlueprints = await this.getAllAtRoot();
|
|
83
|
-
const jsonDocumentBlueprints = await rootDocumentBlueprints.json();
|
|
84
|
-
for (const blueprint of jsonDocumentBlueprints.items) {
|
|
85
|
-
if (blueprint.name === name) {
|
|
86
|
-
return this.get(blueprint.id);
|
|
87
|
-
}
|
|
88
|
-
else if (blueprint.hasChildren) {
|
|
89
|
-
const result = await this.recurseChildren(name, blueprint.id, false);
|
|
90
|
-
if (result) {
|
|
91
|
-
return result;
|
|
92
|
-
}
|
|
83
|
+
await this.recurseBlueprintChildren(name, child.id, toDelete);
|
|
93
84
|
}
|
|
94
85
|
}
|
|
95
86
|
return false;
|
|
96
87
|
}
|
|
97
|
-
async ensureNameNotExists(name) {
|
|
98
|
-
const rootDocumentBlueprints = await this.getAllAtRoot();
|
|
99
|
-
const jsonDocumentBlueprints = await rootDocumentBlueprints.json();
|
|
100
|
-
for (const blueprint of jsonDocumentBlueprints.items) {
|
|
101
|
-
if (blueprint.name === name) {
|
|
102
|
-
if (blueprint.hasChildren) {
|
|
103
|
-
await this.recurseDeleteChildren(blueprint.id);
|
|
104
|
-
}
|
|
105
|
-
return await this.delete(blueprint.id);
|
|
106
|
-
}
|
|
107
|
-
else if (blueprint.hasChildren) {
|
|
108
|
-
await this.recurseChildren(name, blueprint.id, true);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
return null;
|
|
112
|
-
}
|
|
113
88
|
async createDefaultDocumentBlueprint(documentBlueprintName, documentTypeId) {
|
|
114
89
|
await this.ensureNameNotExists(documentBlueprintName);
|
|
115
90
|
const documentBlueprint = new json_models_builders_1.DocumentBlueprintsBuilder()
|
|
@@ -128,7 +103,7 @@ class DocumentBlueprintApiHelper {
|
|
|
128
103
|
"id": documentId
|
|
129
104
|
}
|
|
130
105
|
};
|
|
131
|
-
const response = await this.api.post(this.
|
|
106
|
+
const response = await this.api.post(this.buildUrl('/from-document'), documentBlueprintData);
|
|
132
107
|
return response.headers().location.split("v1/document-blueprint/").pop();
|
|
133
108
|
}
|
|
134
109
|
async createDocumentBlueprintWithTextBoxValue(documentBlueprintName, documentTypeId, dataTypeName, text) {
|