@adobe/spacecat-shared-data-access 1.59.2 → 1.60.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 +7 -0
- package/package.json +2 -2
- package/src/models/site/config.js +1 -1
- package/src/service/audits/accessPatterns.js +7 -7
- package/src/service/experiments/accessPatterns.js +2 -2
- package/src/service/import-job/accessPatterns.js +1 -1
- package/src/service/import-url/accessPatterns.js +2 -2
- package/src/service/index.js +10 -18
- package/src/service/key-events/accessPatterns.js +3 -3
- package/src/service/organizations/accessPatterns.js +3 -3
- package/src/service/site-candidates/accessPatterns.js +1 -1
- package/src/service/sites/accessPatterns.js +11 -11
- package/src/v2/models/api-key/api-key.collection.js +26 -0
- package/src/v2/models/api-key/api-key.model.js +59 -0
- package/src/v2/models/api-key/api-key.schema.js +82 -0
- package/src/v2/models/api-key/index.d.ts +37 -0
- package/src/v2/models/api-key/index.js +19 -0
- package/src/v2/models/audit/audit.collection.js +26 -0
- package/src/v2/models/audit/audit.model.js +89 -0
- package/src/v2/models/audit/audit.schema.js +66 -0
- package/src/v2/models/audit/index.d.ts +40 -0
- package/src/v2/models/audit/index.js +19 -0
- package/src/v2/models/base/base.collection.js +450 -0
- package/src/v2/models/{base.model.js → base/base.model.js} +109 -89
- package/src/v2/models/base/constants.js +17 -0
- package/src/v2/models/base/entity.registry.js +137 -0
- package/src/v2/models/base/index.d.ts +83 -0
- package/src/v2/models/base/index.js +27 -0
- package/src/v2/models/base/reference.js +159 -0
- package/src/v2/models/base/schema.builder.js +420 -0
- package/src/v2/models/base/schema.js +283 -0
- package/src/v2/models/configuration/configuration.collection.js +39 -0
- package/src/v2/models/configuration/configuration.model.js +160 -0
- package/src/v2/models/configuration/configuration.schema.js +103 -0
- package/src/v2/models/configuration/index.d.ts +111 -0
- package/src/v2/models/configuration/index.js +19 -0
- package/src/v2/models/experiment/experiment.collection.js +26 -0
- package/src/v2/models/experiment/experiment.model.js +28 -0
- package/src/v2/models/experiment/experiment.schema.js +70 -0
- package/src/v2/models/experiment/index.d.ts +49 -0
- package/src/v2/models/experiment/index.js +19 -0
- package/src/v2/models/import-job/import-job.collection.js +45 -0
- package/src/v2/models/import-job/import-job.model.js +55 -0
- package/src/v2/models/import-job/import-job.schema.js +152 -0
- package/src/v2/models/import-job/index.d.ts +51 -0
- package/src/v2/models/import-job/index.js +19 -0
- package/src/v2/models/import-url/import-url.collection.js +26 -0
- package/src/v2/models/import-url/import-url.model.js +28 -0
- package/src/v2/models/import-url/import-url.schema.js +59 -0
- package/src/v2/models/import-url/index.d.ts +35 -0
- package/src/v2/models/import-url/index.js +19 -0
- package/src/v2/models/index.d.ts +11 -99
- package/src/v2/models/index.js +14 -15
- package/src/v2/models/key-event/index.d.ts +28 -0
- package/src/v2/models/key-event/index.js +19 -0
- package/src/v2/models/key-event/key-event.collection.js +26 -0
- package/src/v2/models/key-event/key-event.model.js +37 -0
- package/src/v2/models/key-event/key-event.schema.js +45 -0
- package/src/v2/models/opportunity/index.d.ts +46 -0
- package/src/v2/models/opportunity/index.js +19 -0
- package/src/v2/models/opportunity/opportunity.collection.js +26 -0
- package/src/v2/models/{opportunity.model.js → opportunity/opportunity.model.js} +15 -2
- package/src/v2/models/opportunity/opportunity.schema.js +69 -0
- package/src/v2/models/organization/index.d.ts +28 -0
- package/src/v2/models/organization/index.js +19 -0
- package/src/v2/models/organization/organization.collection.js +26 -0
- package/src/v2/models/organization/organization.model.js +31 -0
- package/src/v2/models/organization/organization.schema.js +51 -0
- package/src/v2/models/site/index.d.ts +43 -0
- package/src/v2/models/site/index.js +20 -0
- package/src/v2/models/site/site.collection.js +28 -0
- package/src/v2/models/site/site.model.js +47 -0
- package/src/v2/models/site/site.schema.js +91 -0
- package/src/v2/models/site-candidate/index.d.ts +38 -0
- package/src/v2/models/site-candidate/index.js +19 -0
- package/src/v2/models/site-candidate/site-candidate.collection.js +27 -0
- package/src/v2/models/site-candidate/site-candidate.model.js +41 -0
- package/src/v2/models/site-candidate/site-candidate.schema.js +59 -0
- package/src/v2/models/site-top-page/index.d.ts +35 -0
- package/src/v2/models/site-top-page/index.js +19 -0
- package/src/v2/models/site-top-page/site-top-page.collection.js +44 -0
- package/src/v2/models/site-top-page/site-top-page.model.js +28 -0
- package/src/v2/models/site-top-page/site-top-page.schema.js +65 -0
- package/src/v2/models/suggestion/index.d.ts +34 -0
- package/src/v2/models/suggestion/index.js +19 -0
- package/src/v2/models/suggestion/suggestion.collection.js +55 -0
- package/src/v2/models/{suggestion.model.js → suggestion/suggestion.model.js} +16 -1
- package/src/v2/models/suggestion/suggestion.schema.js +53 -0
- package/src/v2/readme.md +201 -256
- package/src/v2/util/accessor.utils.js +158 -0
- package/src/v2/util/guards.d.ts +7 -0
- package/src/v2/util/guards.js +21 -4
- package/src/v2/util/index.js +1 -0
- package/src/v2/util/patcher.js +54 -25
- package/src/v2/util/util.js +84 -0
- package/src/v2/models/base.collection.js +0 -275
- package/src/v2/models/model.factory.js +0 -74
- package/src/v2/models/opportunity.collection.js +0 -74
- package/src/v2/models/suggestion.collection.js +0 -104
- package/src/v2/schema/opportunity.schema.js +0 -159
- package/src/v2/schema/suggestion.schema.js +0 -132
- package/src/v2/util/reference.js +0 -41
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import type { BaseCollection, BaseModel } from '../base';
|
|
14
|
+
|
|
15
|
+
export interface ImportUrl extends BaseModel {
|
|
16
|
+
getExpiresAt(): number,
|
|
17
|
+
getFile(): string,
|
|
18
|
+
getImportJobId(): string,
|
|
19
|
+
getPath(): string,
|
|
20
|
+
getReason(): string,
|
|
21
|
+
getStatus(): string,
|
|
22
|
+
getUrl(): string,
|
|
23
|
+
setExpiresAt(expiresAt: number): void,
|
|
24
|
+
setFile(file: string): void,
|
|
25
|
+
setImportJobId(importJobId: string): void,
|
|
26
|
+
setPath(path: string): void,
|
|
27
|
+
setReason(reason: string): void,
|
|
28
|
+
setStatus(status: string): void,
|
|
29
|
+
setUrl(url: string): void,
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface ImportUrlCollection extends BaseCollection<ImportUrl> {
|
|
33
|
+
allByImportJobId(importJobId: string): Promise<ImportUrl[]>;
|
|
34
|
+
allByImportUrlsByJobIdAndStatus(importJobId: string, status: string): Promise<ImportUrl[]>;
|
|
35
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import ImportUrl from './import-url.model.js';
|
|
14
|
+
import ImportUrlCollection from './import-url.collection.js';
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
ImportUrl,
|
|
18
|
+
ImportUrlCollection,
|
|
19
|
+
};
|
package/src/v2/models/index.d.ts
CHANGED
|
@@ -10,102 +10,14 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
*
|
|
17
|
-
|
|
18
|
-
export
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export interface MultiStatusCreateResult<T> {
|
|
27
|
-
createdItems: T[],
|
|
28
|
-
errorItems: { item: object, error: ValidationError }[],
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Interface representing an Opportunity model, extending BaseModel.
|
|
33
|
-
*/
|
|
34
|
-
export interface Opportunity extends BaseModel { /* eslint-disable no-use-before-define */
|
|
35
|
-
addSuggestions(suggestions: object[]): Promise<MultiStatusCreateResult<Suggestion>>;
|
|
36
|
-
// eslint-disable-next-line no-use-before-define
|
|
37
|
-
getSuggestions(): Promise<Suggestion[]>;
|
|
38
|
-
getSiteId(): string;
|
|
39
|
-
setSiteId(siteId: string): Opportunity;
|
|
40
|
-
getAuditId(): string;
|
|
41
|
-
setAuditId(auditId: string): Opportunity;
|
|
42
|
-
getRunbook(): string;
|
|
43
|
-
setRunbook(runbook: string): Opportunity;
|
|
44
|
-
getGuidance(): string;
|
|
45
|
-
setGuidance(guidance: string): Opportunity;
|
|
46
|
-
getTitle(): string;
|
|
47
|
-
setTitle(title: string): Opportunity;
|
|
48
|
-
getDescription(): string;
|
|
49
|
-
setDescription(description: string): Opportunity;
|
|
50
|
-
getType(): string;
|
|
51
|
-
getStatus(): string;
|
|
52
|
-
setStatus(status: string): Opportunity;
|
|
53
|
-
getOrigin(): string;
|
|
54
|
-
setOrigin(origin: string): Opportunity;
|
|
55
|
-
getTags(): string[];
|
|
56
|
-
setTags(tags: string[]): Opportunity;
|
|
57
|
-
getData(): object;
|
|
58
|
-
setData(data: object): Opportunity;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* Interface representing a Suggestion model, extending BaseModel.
|
|
63
|
-
*/
|
|
64
|
-
export interface Suggestion extends BaseModel {
|
|
65
|
-
getOpportunity(): Promise<Opportunity>;
|
|
66
|
-
getOpportunityId(): string;
|
|
67
|
-
setOpportunityId(opportunityId: string): Suggestion;
|
|
68
|
-
getType(): string;
|
|
69
|
-
getStatus(): string;
|
|
70
|
-
setStatus(status: string): Suggestion;
|
|
71
|
-
getRank(): number;
|
|
72
|
-
setRank(rank: number): Suggestion;
|
|
73
|
-
getData(): object;
|
|
74
|
-
setData(data: object): Suggestion;
|
|
75
|
-
getKpiDeltas(): object;
|
|
76
|
-
setKpiDeltas(kpiDeltas: object): Suggestion;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Interface representing a base collection for interacting with data entities.
|
|
81
|
-
*/
|
|
82
|
-
export interface BaseCollection<T extends BaseModel> {
|
|
83
|
-
findById(id: string): Promise<T>;
|
|
84
|
-
findByIndexKeys(indexKeys: object): Promise<T[]>;
|
|
85
|
-
create(item: object): Promise<T>;
|
|
86
|
-
createMany(items: object[]): Promise<MultiStatusCreateResult<T>>;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Interface representing the Opportunity collection, extending BaseCollection.
|
|
91
|
-
*/
|
|
92
|
-
export interface OpportunityCollection extends BaseCollection<Opportunity> {
|
|
93
|
-
allBySiteId(siteId: string): Promise<Opportunity[]>;
|
|
94
|
-
allBySiteIdAndStatus(siteId: string, status: string): Promise<Opportunity[]>;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* Interface representing the Suggestion collection, extending BaseCollection.
|
|
99
|
-
*/
|
|
100
|
-
export interface SuggestionCollection extends BaseCollection<Suggestion> {
|
|
101
|
-
allByOpportunityId(opportunityId: string): Promise<Suggestion[]>;
|
|
102
|
-
allByOpportunityIdAndStatus(opportunityId: string, status: string): Promise<Suggestion[]>;
|
|
103
|
-
bulkUpdateStatus(suggestions: Suggestion[], status: string): Promise<Suggestion[]>;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Interface representing the Model Factory for creating and managing model collections.
|
|
108
|
-
*/
|
|
109
|
-
export interface ModelFactory {
|
|
110
|
-
getCollection<T extends BaseModel>(collectionName: string): BaseCollection<T>;
|
|
111
|
-
}
|
|
13
|
+
export type * from './audit/index.d.ts';
|
|
14
|
+
export type * from './configuration/index.d.ts';
|
|
15
|
+
export type * from './base/index.d.ts';
|
|
16
|
+
export type * from './experiment/index.d.ts';
|
|
17
|
+
export type * from './key-event/index.d.ts';
|
|
18
|
+
export type * from './opportunity/index.d.ts';
|
|
19
|
+
export type * from './organization/index.d.ts';
|
|
20
|
+
export type * from './site/index.d.ts';
|
|
21
|
+
export type * from './site-candidate/index.d.ts';
|
|
22
|
+
export type * from './site-top-page/index.d.ts';
|
|
23
|
+
export type * from './suggestion/index.d.ts';
|
package/src/v2/models/index.js
CHANGED
|
@@ -10,18 +10,17 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
export
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
};
|
|
13
|
+
export * from './api-key/index.js';
|
|
14
|
+
export * from './audit/index.js';
|
|
15
|
+
export * from './base/index.js';
|
|
16
|
+
export * from './configuration/index.js';
|
|
17
|
+
export * from './experiment/index.js';
|
|
18
|
+
export * from './import-job/index.js';
|
|
19
|
+
export * from './import-url/index.js';
|
|
20
|
+
export * from './key-event/index.js';
|
|
21
|
+
export * from './opportunity/index.js';
|
|
22
|
+
export * from './organization/index.js';
|
|
23
|
+
export * from './site-candidate/index.js';
|
|
24
|
+
export * from './site-top-page/index.js';
|
|
25
|
+
export * from './site/index.js';
|
|
26
|
+
export * from './suggestion/index.js';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import type { BaseCollection, BaseModel } from '../index';
|
|
14
|
+
|
|
15
|
+
export interface KeyEvent extends BaseModel {
|
|
16
|
+
getName(): string;
|
|
17
|
+
getSiteId(): string;
|
|
18
|
+
getTime(): number;
|
|
19
|
+
getType(): string;
|
|
20
|
+
setName(name: string): KeyEvent;
|
|
21
|
+
setSiteId(siteId: string): KeyEvent;
|
|
22
|
+
setTime(time: number): KeyEvent;
|
|
23
|
+
setType(type: string): KeyEvent;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface KeyEventCollection extends BaseCollection<KeyEvent> {
|
|
27
|
+
allBySiteId(siteId: string): Promise<KeyEvent[]>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import KeyEvent from './key-event.model.js';
|
|
14
|
+
import KeyEventCollection from './key-event.collection.js';
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
KeyEvent,
|
|
18
|
+
KeyEventCollection,
|
|
19
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import BaseCollection from '../base/base.collection.js';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* KeyEventCollection - A collection class responsible for managing KeyEvent entities.
|
|
17
|
+
* Extends the BaseCollection to provide specific methods for interacting with KeyEvent records.
|
|
18
|
+
*
|
|
19
|
+
* @class KeyEventCollection
|
|
20
|
+
* @extends BaseCollection
|
|
21
|
+
*/
|
|
22
|
+
class KeyEventCollection extends BaseCollection {
|
|
23
|
+
// add custom methods here
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default KeyEventCollection;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import BaseModel from '../base/base.model.js';
|
|
14
|
+
|
|
15
|
+
export const KEY_EVENT_TYPES = {
|
|
16
|
+
PERFORMANCE: 'PERFORMANCE',
|
|
17
|
+
SEO: 'SEO',
|
|
18
|
+
CONTENT: 'CONTENT',
|
|
19
|
+
CODE: 'CODE',
|
|
20
|
+
THIRD_PARTY: 'THIRD PARTY',
|
|
21
|
+
EXPERIMENTATION: 'EXPERIMENTATION',
|
|
22
|
+
NETWORK: 'NETWORK',
|
|
23
|
+
STATUS_CHANGE: 'STATUS CHANGE',
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* KeyEvent - A class representing an KeyEvent entity.
|
|
28
|
+
* Provides methods to access and manipulate KeyEvent-specific data.
|
|
29
|
+
*
|
|
30
|
+
* @class KeyEvent
|
|
31
|
+
* @extends BaseModel
|
|
32
|
+
*/
|
|
33
|
+
class KeyEvent extends BaseModel {
|
|
34
|
+
// add your custom methods or overrides here
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export default KeyEvent;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/* c8 ignore start */
|
|
14
|
+
|
|
15
|
+
import { hasText, isIsoDate } from '@adobe/spacecat-shared-utils';
|
|
16
|
+
|
|
17
|
+
import SchemaBuilder from '../base/schema.builder.js';
|
|
18
|
+
import { KEY_EVENT_TYPES } from '../../../models/key-event.js';
|
|
19
|
+
import KeyEvent from './key-event.model.js';
|
|
20
|
+
import KeyEventCollection from './key-event.collection.js';
|
|
21
|
+
|
|
22
|
+
/*
|
|
23
|
+
Schema Doc: https://electrodb.dev/en/modeling/schema/
|
|
24
|
+
Attribute Doc: https://electrodb.dev/en/modeling/attributes/
|
|
25
|
+
Indexes Doc: https://electrodb.dev/en/modeling/indexes/
|
|
26
|
+
*/
|
|
27
|
+
|
|
28
|
+
const schema = new SchemaBuilder(KeyEvent, KeyEventCollection)
|
|
29
|
+
.addReference('belongs_to', 'Site', ['time'])
|
|
30
|
+
.addAttribute('name', {
|
|
31
|
+
type: 'string',
|
|
32
|
+
required: true,
|
|
33
|
+
validate: (value) => hasText(value),
|
|
34
|
+
})
|
|
35
|
+
.addAttribute('type', {
|
|
36
|
+
type: Object.values(KEY_EVENT_TYPES),
|
|
37
|
+
required: true,
|
|
38
|
+
})
|
|
39
|
+
.addAttribute('time', {
|
|
40
|
+
type: 'string',
|
|
41
|
+
required: true,
|
|
42
|
+
validate: (value) => isIsoDate(value),
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
export default schema.build();
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import type {
|
|
14
|
+
BaseCollection, BaseModel, MultiStatusCreateResult, Suggestion,
|
|
15
|
+
} from '../index';
|
|
16
|
+
|
|
17
|
+
export interface Opportunity extends BaseModel {
|
|
18
|
+
addSuggestions(suggestions: object[]): Promise<MultiStatusCreateResult<Suggestion>>;
|
|
19
|
+
getAuditId(): string;
|
|
20
|
+
getData(): object;
|
|
21
|
+
getDescription(): string;
|
|
22
|
+
getGuidance(): string;
|
|
23
|
+
getOrigin(): string;
|
|
24
|
+
getRunbook(): string;
|
|
25
|
+
getSiteId(): string;
|
|
26
|
+
getStatus(): string;
|
|
27
|
+
getSuggestions(): Promise<Suggestion[]>;
|
|
28
|
+
getTags(): string[];
|
|
29
|
+
getTitle(): string;
|
|
30
|
+
getType(): string;
|
|
31
|
+
setAuditId(auditId: string): Opportunity;
|
|
32
|
+
setData(data: object): Opportunity;
|
|
33
|
+
setDescription(description: string): Opportunity;
|
|
34
|
+
setGuidance(guidance: string): Opportunity;
|
|
35
|
+
setOrigin(origin: string): Opportunity;
|
|
36
|
+
setRunbook(runbook: string): Opportunity;
|
|
37
|
+
setSiteId(siteId: string): Opportunity;
|
|
38
|
+
setStatus(status: string): Opportunity;
|
|
39
|
+
setTags(tags: string[]): Opportunity;
|
|
40
|
+
setTitle(title: string): Opportunity;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface OpportunityCollection extends BaseCollection<Opportunity> {
|
|
44
|
+
allBySiteId(siteId: string): Promise<Opportunity[]>;
|
|
45
|
+
allBySiteIdAndStatus(siteId: string, status: string): Promise<Opportunity[]>;
|
|
46
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import Opportunity from './opportunity.model.js';
|
|
14
|
+
import OpportunityCollection from './opportunity.collection.js';
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
Opportunity,
|
|
18
|
+
OpportunityCollection,
|
|
19
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import BaseCollection from '../base/base.collection.js';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* OpportunityCollection - A collection class responsible for managing Opportunity entities.
|
|
17
|
+
* Extends the BaseCollection to provide specific methods for interacting with Opportunity records.
|
|
18
|
+
*
|
|
19
|
+
* @class OpportunityCollection
|
|
20
|
+
* @extends BaseCollection
|
|
21
|
+
*/
|
|
22
|
+
class OpportunityCollection extends BaseCollection {
|
|
23
|
+
// add custom methods here
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default OpportunityCollection;
|
|
@@ -10,7 +10,20 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import BaseModel from '
|
|
13
|
+
import BaseModel from '../base/base.model.js';
|
|
14
|
+
|
|
15
|
+
export const ORIGINS = {
|
|
16
|
+
ESS_OPS: 'ESS_OPS',
|
|
17
|
+
AI: 'AI',
|
|
18
|
+
AUTOMATION: 'AUTOMATION',
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export const STATUSES = {
|
|
22
|
+
NEW: 'NEW',
|
|
23
|
+
IN_PROGRESS: 'IN_PROGRESS',
|
|
24
|
+
IGNORED: 'IGNORED',
|
|
25
|
+
RESOLVED: 'RESOLVED',
|
|
26
|
+
};
|
|
14
27
|
|
|
15
28
|
/**
|
|
16
29
|
* Opportunity - A class representing an Opportunity entity.
|
|
@@ -38,7 +51,7 @@ class Opportunity extends BaseModel {
|
|
|
38
51
|
...suggestion,
|
|
39
52
|
[this.idName]: this.getId(),
|
|
40
53
|
}));
|
|
41
|
-
return this.
|
|
54
|
+
return this.entityRegistry
|
|
42
55
|
.getCollection('SuggestionCollection')
|
|
43
56
|
.createMany(childSuggestions, this);
|
|
44
57
|
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
/* c8 ignore start */
|
|
14
|
+
|
|
15
|
+
import { isNonEmptyObject, isValidUrl } from '@adobe/spacecat-shared-utils';
|
|
16
|
+
|
|
17
|
+
import SchemaBuilder from '../base/schema.builder.js';
|
|
18
|
+
import Opportunity, { ORIGINS, STATUSES } from './opportunity.model.js';
|
|
19
|
+
import OpportunityCollection from './opportunity.collection.js';
|
|
20
|
+
|
|
21
|
+
/*
|
|
22
|
+
Schema Doc: https://electrodb.dev/en/modeling/schema/
|
|
23
|
+
Attribute Doc: https://electrodb.dev/en/modeling/attributes/
|
|
24
|
+
Indexes Doc: https://electrodb.dev/en/modeling/indexes/
|
|
25
|
+
*/
|
|
26
|
+
|
|
27
|
+
const schema = new SchemaBuilder(Opportunity, OpportunityCollection)
|
|
28
|
+
.addReference('belongs_to', 'Site', ['status', 'updatedAt'])
|
|
29
|
+
.addReference('belongs_to', 'Audit', ['updatedAt'], { required: false })
|
|
30
|
+
.addReference('has_many', 'Suggestions', ['updatedAt'], { removeDependents: true })
|
|
31
|
+
.addAttribute('runbook', {
|
|
32
|
+
type: 'string',
|
|
33
|
+
validate: (value) => !value || isValidUrl(value),
|
|
34
|
+
})
|
|
35
|
+
.addAttribute('type', {
|
|
36
|
+
type: 'string',
|
|
37
|
+
readOnly: true,
|
|
38
|
+
required: true,
|
|
39
|
+
})
|
|
40
|
+
.addAttribute('data', {
|
|
41
|
+
type: 'any',
|
|
42
|
+
validate: (value) => !value || isNonEmptyObject(value),
|
|
43
|
+
})
|
|
44
|
+
.addAttribute('origin', {
|
|
45
|
+
type: Object.values(ORIGINS),
|
|
46
|
+
required: true,
|
|
47
|
+
})
|
|
48
|
+
.addAttribute('title', {
|
|
49
|
+
type: 'string',
|
|
50
|
+
required: true,
|
|
51
|
+
})
|
|
52
|
+
.addAttribute('description', {
|
|
53
|
+
type: 'string',
|
|
54
|
+
})
|
|
55
|
+
.addAttribute('status', {
|
|
56
|
+
type: Object.values(STATUSES),
|
|
57
|
+
required: true,
|
|
58
|
+
default: 'NEW',
|
|
59
|
+
})
|
|
60
|
+
.addAttribute('guidance', {
|
|
61
|
+
type: 'any',
|
|
62
|
+
validate: (value) => !value || isNonEmptyObject(value),
|
|
63
|
+
})
|
|
64
|
+
.addAttribute('tags', {
|
|
65
|
+
type: 'set',
|
|
66
|
+
items: 'string',
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
export default schema.build();
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import type { BaseCollection, BaseModel } from '../index';
|
|
14
|
+
|
|
15
|
+
export interface Organization extends BaseModel {
|
|
16
|
+
getConfig(): object;
|
|
17
|
+
getFulfillableItems(): object;
|
|
18
|
+
getImsOrgId(): string;
|
|
19
|
+
getName(): string;
|
|
20
|
+
setConfig(config: object): Organization;
|
|
21
|
+
setFulfillableItems(fulfillableItems: object): Organization;
|
|
22
|
+
setImsOrgId(imsOrgId: string): Organization;
|
|
23
|
+
setName(name: string): Organization;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface OrganizationCollection extends BaseCollection<Organization> {
|
|
27
|
+
allByImsOrgId(imsOrgId: string): Promise<Organization[]>;
|
|
28
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import Organization from './organization.model.js';
|
|
14
|
+
import OrganizationCollection from './organization.collection.js';
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
Organization,
|
|
18
|
+
OrganizationCollection,
|
|
19
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import BaseCollection from '../base/base.collection.js';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* OrganizationCollection - A collection class responsible for managing Organization entities.
|
|
17
|
+
* Extends the BaseCollection to provide specific methods for interacting with Organization records.
|
|
18
|
+
*
|
|
19
|
+
* @class OrganizationCollection
|
|
20
|
+
* @extends BaseCollection
|
|
21
|
+
*/
|
|
22
|
+
class OrganizationCollection extends BaseCollection {
|
|
23
|
+
// add custom methods here
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default OrganizationCollection;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2024 Adobe. All rights reserved.
|
|
3
|
+
* This file is licensed to you under the Apache License, Version 2.0 (the "License");
|
|
4
|
+
* you may not use this file except in compliance with the License. You may obtain a copy
|
|
5
|
+
* of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
6
|
+
*
|
|
7
|
+
* Unless required by applicable law or agreed to in writing, software distributed under
|
|
8
|
+
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
9
|
+
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
10
|
+
* governing permissions and limitations under the License.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { Config } from '../../../models/site/config.js';
|
|
14
|
+
import BaseModel from '../base/base.model.js';
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Organization - A class representing an Organization entity.
|
|
18
|
+
* Provides methods to access and manipulate Organization-specific data.
|
|
19
|
+
*
|
|
20
|
+
* @class Organization
|
|
21
|
+
* @extends BaseModel
|
|
22
|
+
*/
|
|
23
|
+
class Organization extends BaseModel {
|
|
24
|
+
// add your custom methods or overrides here
|
|
25
|
+
|
|
26
|
+
getConfig() {
|
|
27
|
+
return Config(this.record.config);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export default Organization;
|