@adobe/spacecat-shared-data-access 2.30.0 → 2.31.0
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/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [@adobe/spacecat-shared-data-access-v2.31.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v2.30.1...@adobe/spacecat-shared-data-access-v2.31.0) (2025-06-27)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* introduce authoring type ([#826](https://github.com/adobe/spacecat-shared/issues/826)) ([36202ec](https://github.com/adobe/spacecat-shared/commit/36202ec19be415043ae333b2a3428d69595d920b))
|
|
7
|
+
|
|
8
|
+
# [@adobe/spacecat-shared-data-access-v2.30.1](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v2.30.0...@adobe/spacecat-shared-data-access-v2.30.1) (2025-06-26)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* add setter for cdn logs condfig ([#828](https://github.com/adobe/spacecat-shared/issues/828)) ([094edf3](https://github.com/adobe/spacecat-shared/commit/094edf3edf362531930294b5195c55239f8b3efc))
|
|
14
|
+
|
|
1
15
|
# [@adobe/spacecat-shared-data-access-v2.30.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v2.29.1...@adobe/spacecat-shared-data-access-v2.30.0) (2025-06-26)
|
|
2
16
|
|
|
3
17
|
|
package/package.json
CHANGED
|
@@ -126,6 +126,7 @@ export interface Site extends BaseModel {
|
|
|
126
126
|
getName(): string;
|
|
127
127
|
getConfig(): SiteConfig;
|
|
128
128
|
getDeliveryType(): string;
|
|
129
|
+
getAuthoringType(): string;
|
|
129
130
|
getExperiments(): Promise<Experiment[]>;
|
|
130
131
|
getExperimentsByExpId(expId: string): Promise<Experiment[]>;
|
|
131
132
|
getExperimentsByExpIdAndUrl(expId: string, url: string): Promise<Experiment[]>;
|
|
@@ -158,6 +159,7 @@ export interface Site extends BaseModel {
|
|
|
158
159
|
setName(name: string): Site;
|
|
159
160
|
setConfig(config: object): Site;
|
|
160
161
|
setDeliveryType(deliveryType: string): Site;
|
|
162
|
+
setAuthoringType(authoringType: string): Site;
|
|
161
163
|
setGitHubURL(gitHubURL: string): Site;
|
|
162
164
|
setHlxConfig(hlxConfig: HlxConfig): Site;
|
|
163
165
|
setDeliveryConfig(deliveryConfig: object): Site;
|
|
@@ -15,7 +15,7 @@ import { hasText, isValidHelixPreviewUrl, isValidUrl } from '@adobe/spacecat-sha
|
|
|
15
15
|
import DataAccessError from '../../errors/data-access.error.js';
|
|
16
16
|
import BaseCollection from '../base/base.collection.js';
|
|
17
17
|
|
|
18
|
-
import Site, { AEM_CS_HOST,
|
|
18
|
+
import Site, { AEM_CS_HOST, getAuthoringType } from './site.model.js';
|
|
19
19
|
|
|
20
20
|
/**
|
|
21
21
|
* SiteCollection - A collection class responsible for managing Site entities.
|
|
@@ -78,10 +78,12 @@ class SiteCollection extends BaseCollection {
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
const { hostname } = new URL(previewURL);
|
|
81
|
-
const previewType =
|
|
81
|
+
const previewType = getAuthoringType(hostname, Site.AUTHORING_TYPES);
|
|
82
82
|
|
|
83
83
|
switch (previewType) {
|
|
84
|
-
case Site.
|
|
84
|
+
case Site.AUTHORING_TYPES.SP:
|
|
85
|
+
case Site.AUTHORING_TYPES.GD:
|
|
86
|
+
case Site.AUTHORING_TYPES.DA: {
|
|
85
87
|
if (!isValidHelixPreviewUrl(previewURL)) {
|
|
86
88
|
throw new DataAccessError(`Invalid Helix preview URL: ${previewURL}`, this);
|
|
87
89
|
}
|
|
@@ -90,7 +92,8 @@ class SiteCollection extends BaseCollection {
|
|
|
90
92
|
const externalOwnerId = `${ref}#${owner}`;
|
|
91
93
|
return this.findByExternalOwnerIdAndExternalSiteId(externalOwnerId, site);
|
|
92
94
|
}
|
|
93
|
-
case Site.
|
|
95
|
+
case Site.AUTHORING_TYPES.CS_CW:
|
|
96
|
+
case Site.AUTHORING_TYPES.CS: {
|
|
94
97
|
const [, programId, envId] = AEM_CS_HOST.exec(hostname);
|
|
95
98
|
const externalOwnerId = `p${programId}`;
|
|
96
99
|
const externalSiteId = `e${envId}`;
|
|
@@ -19,10 +19,10 @@ export const AEM_CS_HOST = /^author-p(\d+)-e(\d+)/i;
|
|
|
19
19
|
/**
|
|
20
20
|
* Computes external IDs based on delivery type and configuration
|
|
21
21
|
*/
|
|
22
|
-
export const computeExternalIds = (attrs) => {
|
|
23
|
-
const { hlxConfig, deliveryConfig } = attrs;
|
|
22
|
+
export const computeExternalIds = (attrs, authoringTypes) => {
|
|
23
|
+
const { authoringType, hlxConfig, deliveryConfig } = attrs;
|
|
24
24
|
|
|
25
|
-
if (hlxConfig) {
|
|
25
|
+
if (hlxConfig && (authoringType === authoringTypes.DA)) {
|
|
26
26
|
const rso = hlxConfig.rso ?? {};
|
|
27
27
|
const { ref, owner, site } = rso;
|
|
28
28
|
|
|
@@ -32,7 +32,8 @@ export const computeExternalIds = (attrs) => {
|
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
if (deliveryConfig
|
|
35
|
+
if (deliveryConfig
|
|
36
|
+
&& (authoringType === authoringTypes.CS || authoringType === authoringTypes.CW)) {
|
|
36
37
|
const { programId, environmentId } = deliveryConfig;
|
|
37
38
|
|
|
38
39
|
return {
|
|
@@ -45,14 +46,14 @@ export const computeExternalIds = (attrs) => {
|
|
|
45
46
|
};
|
|
46
47
|
|
|
47
48
|
/**
|
|
48
|
-
* Determines the
|
|
49
|
+
* Determines the authoring type based on hostname
|
|
49
50
|
*/
|
|
50
|
-
export const
|
|
51
|
+
export const getAuthoringType = (hostname, authoringTypes) => {
|
|
51
52
|
if (HLX_HOST.test(hostname)) {
|
|
52
|
-
return
|
|
53
|
+
return authoringTypes.DA;
|
|
53
54
|
}
|
|
54
55
|
if (AEM_CS_HOST.test(hostname)) {
|
|
55
|
-
return
|
|
56
|
+
return authoringTypes.CS;
|
|
56
57
|
}
|
|
57
58
|
return null;
|
|
58
59
|
};
|
|
@@ -72,6 +73,14 @@ class Site extends BaseModel {
|
|
|
72
73
|
|
|
73
74
|
static DEFAULT_DELIVERY_TYPE = Site.DELIVERY_TYPES.AEM_EDGE;
|
|
74
75
|
|
|
76
|
+
static AUTHORING_TYPES = {
|
|
77
|
+
CS_CW: 'cs/crosswalk',
|
|
78
|
+
CS: 'cs',
|
|
79
|
+
SP: 'sharepoint',
|
|
80
|
+
GD: 'googledocs',
|
|
81
|
+
DA: 'documentauthoring',
|
|
82
|
+
};
|
|
83
|
+
|
|
75
84
|
async toggleLive() {
|
|
76
85
|
const newIsLive = !this.getIsLive();
|
|
77
86
|
this.setIsLive(newIsLive);
|
|
@@ -63,6 +63,10 @@ const schema = new SchemaBuilder(Site, SiteCollection)
|
|
|
63
63
|
default: Site.DEFAULT_DELIVERY_TYPE,
|
|
64
64
|
required: true,
|
|
65
65
|
})
|
|
66
|
+
.addAttribute('authoringType', {
|
|
67
|
+
type: Object.values(Site.AUTHORING_TYPES),
|
|
68
|
+
required: false,
|
|
69
|
+
})
|
|
66
70
|
.addAttribute('gitHubURL', {
|
|
67
71
|
type: 'string',
|
|
68
72
|
validate: (value) => !value || isValidUrl(value),
|
|
@@ -98,15 +102,15 @@ const schema = new SchemaBuilder(Site, SiteCollection)
|
|
|
98
102
|
type: 'string',
|
|
99
103
|
hidden: true,
|
|
100
104
|
readOnly: true,
|
|
101
|
-
watch: ['hlxConfig', 'deliveryConfig'],
|
|
102
|
-
set: (_, attrs) => computeExternalIds(attrs).externalOwnerId,
|
|
105
|
+
watch: ['authoringType', 'hlxConfig', 'deliveryConfig'],
|
|
106
|
+
set: (_, attrs) => computeExternalIds(attrs, Site.AUTHORING_TYPES).externalOwnerId,
|
|
103
107
|
})
|
|
104
108
|
.addAttribute('externalSiteId', {
|
|
105
109
|
type: 'string',
|
|
106
110
|
hidden: true,
|
|
107
111
|
readOnly: true,
|
|
108
|
-
watch: ['hlxConfig', 'deliveryConfig'],
|
|
109
|
-
set: (_, attrs) => computeExternalIds(attrs).externalSiteId,
|
|
112
|
+
watch: ['authoringType', 'hlxConfig', 'deliveryConfig'],
|
|
113
|
+
set: (_, attrs) => computeExternalIds(attrs, Site.AUTHORING_TYPES).externalSiteId,
|
|
110
114
|
})
|
|
111
115
|
.addAllIndex(['baseURL'])
|
|
112
116
|
.addIndex(
|