@adobe/spacecat-shared-data-access 2.57.0 → 2.58.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 +14 -0
- package/README.md +43 -0
- package/package.json +2 -2
- package/src/models/base/entity.registry.js +18 -0
- package/src/models/entitlement/entitlement.collection.js +26 -0
- package/src/models/entitlement/entitlement.model.js +36 -0
- package/src/models/entitlement/entitlement.schema.js +49 -0
- package/src/models/entitlement/index.d.ts +47 -0
- package/src/models/entitlement/index.js +19 -0
- package/src/models/index.d.ts +5 -0
- package/src/models/index.js +5 -0
- package/src/models/organization/index.d.ts +6 -1
- package/src/models/organization/organization.schema.js +3 -0
- package/src/models/organization-identity-provider/index.d.ts +40 -0
- package/src/models/organization-identity-provider/index.js +19 -0
- package/src/models/organization-identity-provider/organization-identity-provider.collection.js +28 -0
- package/src/models/organization-identity-provider/organization-identity-provider.model.js +32 -0
- package/src/models/organization-identity-provider/organization-identity-provider.schema.js +48 -0
- package/src/models/site/index.d.ts +2 -0
- package/src/models/site/site.model.js +7 -7
- package/src/models/site/site.schema.js +2 -0
- package/src/models/site-enrollment/index.d.ts +33 -0
- package/src/models/site-enrollment/index.js +15 -0
- package/src/models/site-enrollment/site-enrollment.collection.js +26 -0
- package/src/models/site-enrollment/site-enrollment.model.js +26 -0
- package/src/models/site-enrollment/site-enrollment.schema.js +29 -0
- package/src/models/trial-user/index.d.ts +51 -0
- package/src/models/trial-user/index.js +19 -0
- package/src/models/trial-user/trial-user.collection.js +26 -0
- package/src/models/trial-user/trial-user.model.js +35 -0
- package/src/models/trial-user/trial-user.schema.js +68 -0
- package/src/models/trial-user-activity/index.d.ts +44 -0
- package/src/models/trial-user-activity/index.js +19 -0
- package/src/models/trial-user-activity/trial-user-activity.collection.js +28 -0
- package/src/models/trial-user-activity/trial-user-activity.model.js +37 -0
- package/src/models/trial-user-activity/trial-user-activity.schema.js +47 -0
- package/src/util/util.js +8 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [@adobe/spacecat-shared-data-access-v2.58.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v2.57.1...@adobe/spacecat-shared-data-access-v2.58.0) (2025-08-28)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* **dataAccess:** Add entities for LLMO trial onboarding ([#928](https://github.com/adobe/spacecat-shared/issues/928)) ([b5acc3c](https://github.com/adobe/spacecat-shared/commit/b5acc3c3af49d5fd45b8abf91b851fe23da60bc7))
|
|
7
|
+
|
|
8
|
+
# [@adobe/spacecat-shared-data-access-v2.57.1](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v2.57.0...@adobe/spacecat-shared-data-access-v2.57.1) (2025-08-26)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* use DELIVERY_TYPES from shared-utils ([#933](https://github.com/adobe/spacecat-shared/issues/933)) ([3592540](https://github.com/adobe/spacecat-shared/commit/3592540fc3cee05333fbf854447755b727dafae1))
|
|
14
|
+
|
|
1
15
|
# [@adobe/spacecat-shared-data-access-v2.57.0](https://github.com/adobe/spacecat-shared/compare/@adobe/spacecat-shared-data-access-v2.56.1...@adobe/spacecat-shared-data-access-v2.57.0) (2025-08-22)
|
|
2
16
|
|
|
3
17
|
|
package/README.md
CHANGED
|
@@ -42,6 +42,49 @@ npm install @adobe/spacecat-shared-data-access
|
|
|
42
42
|
- **geo** (String): Geo of the top page.
|
|
43
43
|
- **importedAt** (String): Timestamp of the import.
|
|
44
44
|
|
|
45
|
+
### Organization
|
|
46
|
+
- **id** (String): Unique identifier for an organization.
|
|
47
|
+
- **createdAt** (String): Timestamp of creation.
|
|
48
|
+
- **updatedAt** (String): Timestamp of the last update.
|
|
49
|
+
|
|
50
|
+
### OrganizationIdentityProvider
|
|
51
|
+
- **id** (String): Unique identifier for the identity provider.
|
|
52
|
+
- **metadata** (Map): Metadata for the identity provider.
|
|
53
|
+
- **provider** (String): Type of identity provider. (IMS, MICROSOFT, GOOGLE)
|
|
54
|
+
- **externalId** (String): External identifier from the provider.
|
|
55
|
+
- **createdAt** (String): Timestamp of creation.
|
|
56
|
+
|
|
57
|
+
### TrialUser
|
|
58
|
+
- **id** (String): Unique identifier for the trial user.
|
|
59
|
+
- **externalUserId** (String): External user identifier.
|
|
60
|
+
- **status** (String): Status of the trial user. (REGISTERED, VERIFIED, BLOCKED, DELETED)
|
|
61
|
+
- **provider** (String): Type of identity provider. (IMS, MICROSOFT, GOOGLE)
|
|
62
|
+
- **lastSeenAt** (String): Timestamp of last activity.
|
|
63
|
+
- **createdAt** (String): Timestamp of creation.
|
|
64
|
+
- **metadata** (Map): Metadata for the trial user.
|
|
65
|
+
- **updatedAt** (String): Timestamp of the last update.
|
|
66
|
+
|
|
67
|
+
### TrialUserActivity
|
|
68
|
+
- **id** (String): Unique identifier for the trial user activity.
|
|
69
|
+
- **type** (String): Type of activity performed. (SIGN_UP, SIGN_IN, CREATE_SITE, RUN_AUDIT, PROMPT_RUN, DOWNLOAD)
|
|
70
|
+
- **details** (Map): Details of the activity.
|
|
71
|
+
- **createdAt** (String): Timestamp of creation.
|
|
72
|
+
- **productCode** (String): Product code associated with the activity. (LLMO, ASO, etc.)
|
|
73
|
+
|
|
74
|
+
### Entitlement
|
|
75
|
+
- **id** (String): Unique identifier for the entitlement.
|
|
76
|
+
- **productCode** (String): Product code for the entitlement. (LLMO, ASO, etc.)
|
|
77
|
+
- **tier** (String): Tier level of the entitlement. (FREE_TRIAL, PAID)
|
|
78
|
+
- **status** (String): Status of the entitlement. (ACTIVE, SUSPENDED, ENDED)
|
|
79
|
+
- **createdAt** (String): Timestamp of creation.
|
|
80
|
+
- **updatedAt** (String): Timestamp of the last update.
|
|
81
|
+
- **quotas** (Map): Quota information for the entitlement.
|
|
82
|
+
|
|
83
|
+
### SiteEnrollment
|
|
84
|
+
- **id** (String): Unique identifier for the site enrollment.
|
|
85
|
+
- **status** (String): Status of the enrollment. (ACTIVE, SUSPENDED, ENDED)
|
|
86
|
+
- **createdAt** (String): Timestamp of creation.
|
|
87
|
+
|
|
45
88
|
## DynamoDB Data Model
|
|
46
89
|
|
|
47
90
|
The module is designed to work with the following DynamoDB tables:
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adobe/spacecat-shared-data-access",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.58.0",
|
|
4
4
|
"description": "Shared modules of the Spacecat Services - Data Access",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"engines": {
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"access": "public"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@adobe/spacecat-shared-utils": "1.
|
|
38
|
+
"@adobe/spacecat-shared-utils": "1.49.0",
|
|
39
39
|
"@aws-sdk/client-dynamodb": "3.864.0",
|
|
40
40
|
"@aws-sdk/lib-dynamodb": "3.864.0",
|
|
41
41
|
"@types/joi": "17.2.3",
|
|
@@ -18,6 +18,7 @@ import AsyncJobCollection from '../async-job/async-job.collection.js';
|
|
|
18
18
|
import AuditCollection from '../audit/audit.collection.js';
|
|
19
19
|
import ConfigurationCollection from '../configuration/configuration.collection.js';
|
|
20
20
|
import ExperimentCollection from '../experiment/experiment.collection.js';
|
|
21
|
+
import EntitlementCollection from '../entitlement/entitlement.collection.js';
|
|
21
22
|
import FixEntityCollection from '../fix-entity/fix-entity.collection.js';
|
|
22
23
|
import ImportJobCollection from '../import-job/import-job.collection.js';
|
|
23
24
|
import ImportUrlCollection from '../import-url/import-url.collection.js';
|
|
@@ -25,20 +26,25 @@ import KeyEventCollection from '../key-event/key-event.collection.js';
|
|
|
25
26
|
import LatestAuditCollection from '../latest-audit/latest-audit.collection.js';
|
|
26
27
|
import OpportunityCollection from '../opportunity/opportunity.collection.js';
|
|
27
28
|
import OrganizationCollection from '../organization/organization.collection.js';
|
|
29
|
+
import OrganizationIdentityProviderCollection from '../organization-identity-provider/organization-identity-provider.collection.js';
|
|
28
30
|
import ScrapeJobCollection from '../scrape-job/scrape-job.collection.js';
|
|
29
31
|
import ScrapeUrlCollection from '../scrape-url/scrape-url.collection.js';
|
|
30
32
|
import SiteCandidateCollection from '../site-candidate/site-candidate.collection.js';
|
|
31
33
|
import SiteCollection from '../site/site.collection.js';
|
|
34
|
+
import SiteEnrollmentCollection from '../site-enrollment/site-enrollment.collection.js';
|
|
32
35
|
import SiteTopFormCollection from '../site-top-form/site-top-form.collection.js';
|
|
33
36
|
import SiteTopPageCollection from '../site-top-page/site-top-page.collection.js';
|
|
34
37
|
import SuggestionCollection from '../suggestion/suggestion.collection.js';
|
|
35
38
|
import PageIntentCollection from '../page-intent/page-intent.collection.js';
|
|
36
39
|
import ReportCollection from '../report/report.collection.js';
|
|
40
|
+
import TrialUserCollection from '../trial-user/trial-user.collection.js';
|
|
41
|
+
import TrialUserActivityCollection from '../trial-user-activity/trial-user-activity.collection.js';
|
|
37
42
|
|
|
38
43
|
import ApiKeySchema from '../api-key/api-key.schema.js';
|
|
39
44
|
import AsyncJobSchema from '../async-job/async-job.schema.js';
|
|
40
45
|
import AuditSchema from '../audit/audit.schema.js';
|
|
41
46
|
import ConfigurationSchema from '../configuration/configuration.schema.js';
|
|
47
|
+
import EntitlementSchema from '../entitlement/entitlement.schema.js';
|
|
42
48
|
import FixEntitySchema from '../fix-entity/fix-entity.schema.js';
|
|
43
49
|
import ExperimentSchema from '../experiment/experiment.schema.js';
|
|
44
50
|
import ImportJobSchema from '../import-job/import-job.schema.js';
|
|
@@ -47,15 +53,19 @@ import KeyEventSchema from '../key-event/key-event.schema.js';
|
|
|
47
53
|
import LatestAuditSchema from '../latest-audit/latest-audit.schema.js';
|
|
48
54
|
import OpportunitySchema from '../opportunity/opportunity.schema.js';
|
|
49
55
|
import OrganizationSchema from '../organization/organization.schema.js';
|
|
56
|
+
import OrganizationIdentityProviderSchema from '../organization-identity-provider/organization-identity-provider.schema.js';
|
|
50
57
|
import ScrapeJobSchema from '../scrape-job/scrape-job.schema.js';
|
|
51
58
|
import ScrapeUrlSchema from '../scrape-url/scrape-url.schema.js';
|
|
52
59
|
import SiteSchema from '../site/site.schema.js';
|
|
53
60
|
import SiteCandidateSchema from '../site-candidate/site-candidate.schema.js';
|
|
61
|
+
import SiteEnrollmentSchema from '../site-enrollment/site-enrollment.schema.js';
|
|
54
62
|
import SiteTopFormSchema from '../site-top-form/site-top-form.schema.js';
|
|
55
63
|
import SiteTopPageSchema from '../site-top-page/site-top-page.schema.js';
|
|
56
64
|
import SuggestionSchema from '../suggestion/suggestion.schema.js';
|
|
57
65
|
import PageIntentSchema from '../page-intent/page-intent.schema.js';
|
|
58
66
|
import ReportSchema from '../report/report.schema.js';
|
|
67
|
+
import TrialUserSchema from '../trial-user/trial-user.schema.js';
|
|
68
|
+
import TrialUserActivitySchema from '../trial-user-activity/trial-user-activity.schema.js';
|
|
59
69
|
|
|
60
70
|
/**
|
|
61
71
|
* EntityRegistry - A registry class responsible for managing entities, their schema and collection.
|
|
@@ -142,6 +152,7 @@ EntityRegistry.registerEntity(ApiKeySchema, ApiKeyCollection);
|
|
|
142
152
|
EntityRegistry.registerEntity(AsyncJobSchema, AsyncJobCollection);
|
|
143
153
|
EntityRegistry.registerEntity(AuditSchema, AuditCollection);
|
|
144
154
|
EntityRegistry.registerEntity(ConfigurationSchema, ConfigurationCollection);
|
|
155
|
+
EntityRegistry.registerEntity(EntitlementSchema, EntitlementCollection);
|
|
145
156
|
EntityRegistry.registerEntity(FixEntitySchema, FixEntityCollection);
|
|
146
157
|
EntityRegistry.registerEntity(ExperimentSchema, ExperimentCollection);
|
|
147
158
|
EntityRegistry.registerEntity(ImportJobSchema, ImportJobCollection);
|
|
@@ -150,14 +161,21 @@ EntityRegistry.registerEntity(KeyEventSchema, KeyEventCollection);
|
|
|
150
161
|
EntityRegistry.registerEntity(LatestAuditSchema, LatestAuditCollection);
|
|
151
162
|
EntityRegistry.registerEntity(OpportunitySchema, OpportunityCollection);
|
|
152
163
|
EntityRegistry.registerEntity(OrganizationSchema, OrganizationCollection);
|
|
164
|
+
EntityRegistry.registerEntity(
|
|
165
|
+
OrganizationIdentityProviderSchema,
|
|
166
|
+
OrganizationIdentityProviderCollection,
|
|
167
|
+
);
|
|
153
168
|
EntityRegistry.registerEntity(ScrapeJobSchema, ScrapeJobCollection);
|
|
154
169
|
EntityRegistry.registerEntity(ScrapeUrlSchema, ScrapeUrlCollection);
|
|
155
170
|
EntityRegistry.registerEntity(SiteSchema, SiteCollection);
|
|
156
171
|
EntityRegistry.registerEntity(SiteCandidateSchema, SiteCandidateCollection);
|
|
172
|
+
EntityRegistry.registerEntity(SiteEnrollmentSchema, SiteEnrollmentCollection);
|
|
157
173
|
EntityRegistry.registerEntity(SiteTopFormSchema, SiteTopFormCollection);
|
|
158
174
|
EntityRegistry.registerEntity(SiteTopPageSchema, SiteTopPageCollection);
|
|
159
175
|
EntityRegistry.registerEntity(SuggestionSchema, SuggestionCollection);
|
|
160
176
|
EntityRegistry.registerEntity(PageIntentSchema, PageIntentCollection);
|
|
161
177
|
EntityRegistry.registerEntity(ReportSchema, ReportCollection);
|
|
178
|
+
EntityRegistry.registerEntity(TrialUserSchema, TrialUserCollection);
|
|
179
|
+
EntityRegistry.registerEntity(TrialUserActivitySchema, TrialUserActivityCollection);
|
|
162
180
|
|
|
163
181
|
export default EntityRegistry;
|
|
@@ -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
|
+
* EntitlementCollection - A collection class responsible for managing Entitlement entities.
|
|
17
|
+
* Extends the BaseCollection to provide specific methods for interacting with Entitlement records.
|
|
18
|
+
*
|
|
19
|
+
* @class EntitlementCollection
|
|
20
|
+
* @extends BaseCollection
|
|
21
|
+
*/
|
|
22
|
+
class EntitlementCollection extends BaseCollection {
|
|
23
|
+
// add custom methods here
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default EntitlementCollection;
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
/**
|
|
16
|
+
* Entitlement - A class representing an Entitlement entity.
|
|
17
|
+
* Provides methods to access and manipulate Entitlement-specific data.
|
|
18
|
+
*
|
|
19
|
+
* @class Entitlement
|
|
20
|
+
* @extends BaseModel
|
|
21
|
+
*/
|
|
22
|
+
class Entitlement extends BaseModel {
|
|
23
|
+
static TIERS = {
|
|
24
|
+
FREE_TRIAL: 'FREE_TRIAL',
|
|
25
|
+
PAID: 'PAID',
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
static PRODUCT_CODES = {
|
|
29
|
+
LLMO: 'LLMO',
|
|
30
|
+
ASO: 'ASO',
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// add your custom methods or overrides here
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export default Entitlement;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 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 SchemaBuilder from '../base/schema.builder.js';
|
|
14
|
+
import Entitlement from './entitlement.model.js';
|
|
15
|
+
import EntitlementCollection from './entitlement.collection.js';
|
|
16
|
+
|
|
17
|
+
/*
|
|
18
|
+
Schema Doc: https://electrodb.dev/en/modeling/schema/
|
|
19
|
+
Attribute Doc: https://electrodb.dev/en/modeling/attributes/
|
|
20
|
+
Indexes Doc: https://electrodb.dev/en/modeling/indexes/
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
const schema = new SchemaBuilder(Entitlement, EntitlementCollection)
|
|
24
|
+
// Reference to Organization (many-to-one relationship)
|
|
25
|
+
.addReference('belongs_to', 'Organization')
|
|
26
|
+
// Reference to SiteEnrollments (one-to-many relationship)
|
|
27
|
+
.addReference('has_many', 'SiteEnrollments')
|
|
28
|
+
.addReference('has_many', 'TrialUserActivities')
|
|
29
|
+
.addAttribute('productCode', {
|
|
30
|
+
type: Object.values(Entitlement.PRODUCT_CODES),
|
|
31
|
+
required: true,
|
|
32
|
+
})
|
|
33
|
+
.addAttribute('tier', {
|
|
34
|
+
type: Object.values(Entitlement.TIERS),
|
|
35
|
+
required: true,
|
|
36
|
+
})
|
|
37
|
+
.addAttribute('quotas', {
|
|
38
|
+
type: 'map',
|
|
39
|
+
required: false,
|
|
40
|
+
properties: {
|
|
41
|
+
llmo_trial_prompts: { type: 'number' },
|
|
42
|
+
},
|
|
43
|
+
})
|
|
44
|
+
.addIndex(
|
|
45
|
+
{ composite: ['organizationId'] },
|
|
46
|
+
{ composite: ['productCode'] },
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
export default schema.build();
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 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, Organization, SiteEnrollment,
|
|
15
|
+
} from '../index';
|
|
16
|
+
|
|
17
|
+
export type EntitlementStatus = 'ACTIVE' | 'SUSPENDED' | 'ENDED';
|
|
18
|
+
export type EntitlementTier = 'FREE_TRIAL' | 'PAID';
|
|
19
|
+
export type EntitlementProductCode = 'LLMO' | 'ASO';
|
|
20
|
+
|
|
21
|
+
export interface Entitlement extends BaseModel {
|
|
22
|
+
getProductCode(): EntitlementProductCode;
|
|
23
|
+
getTier(): EntitlementTier;
|
|
24
|
+
getStatus(): EntitlementStatus;
|
|
25
|
+
getQuotas(): object | null;
|
|
26
|
+
getOrganization(): Promise<Organization>;
|
|
27
|
+
getSiteEnrollments(): Promise<SiteEnrollment[]>;
|
|
28
|
+
setProductCode(productCode: EntitlementProductCode): Entitlement;
|
|
29
|
+
setTier(tier: EntitlementTier): Entitlement;
|
|
30
|
+
setStatus(status: EntitlementStatus): Entitlement;
|
|
31
|
+
setQuotas(quotas: object): Entitlement;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export interface EntitlementCollection extends
|
|
35
|
+
BaseCollection<Entitlement> {
|
|
36
|
+
allByOrganizationId(organizationId: string): Promise<Entitlement[]>;
|
|
37
|
+
allByOrganizationIdAndProductCode(
|
|
38
|
+
organizationId: string,
|
|
39
|
+
productCode: EntitlementProductCode,
|
|
40
|
+
): Promise<Entitlement[]>;
|
|
41
|
+
|
|
42
|
+
findByOrganizationId(organizationId: string): Promise<Entitlement[]>;
|
|
43
|
+
findByOrganizationIdAndProductCode(
|
|
44
|
+
organizationId: string,
|
|
45
|
+
productCode: EntitlementProductCode,
|
|
46
|
+
): Promise<Entitlement[]>;
|
|
47
|
+
}
|
|
@@ -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 Entitlement from './entitlement.model.js';
|
|
14
|
+
import EntitlementCollection from './entitlement.collection.js';
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
Entitlement,
|
|
18
|
+
EntitlementCollection,
|
|
19
|
+
};
|
package/src/models/index.d.ts
CHANGED
|
@@ -16,17 +16,22 @@ export type * from './configuration';
|
|
|
16
16
|
export type * from './base';
|
|
17
17
|
export type * from './fix-entity';
|
|
18
18
|
export type * from './experiment';
|
|
19
|
+
export type * from './entitlement';
|
|
19
20
|
export type * from './import-job';
|
|
20
21
|
export type * from './import-url';
|
|
21
22
|
export type * from './key-event';
|
|
22
23
|
export type * from './latest-audit';
|
|
23
24
|
export type * from './opportunity';
|
|
24
25
|
export type * from './organization';
|
|
26
|
+
export type * from './organization-identity-provider';
|
|
25
27
|
export type * from './scrape-job';
|
|
26
28
|
export type * from './scrape-url';
|
|
27
29
|
export type * from './site';
|
|
28
30
|
export type * from './site-candidate';
|
|
31
|
+
export type * from './site-enrollment';
|
|
29
32
|
export type * from './site-top-form';
|
|
30
33
|
export type * from './site-top-page';
|
|
31
34
|
export type * from './suggestion';
|
|
32
35
|
export type * from './report';
|
|
36
|
+
export type * from './trial-user';
|
|
37
|
+
export type * from './trial-user-activity';
|
package/src/models/index.js
CHANGED
|
@@ -15,6 +15,7 @@ export * from './async-job/index.js';
|
|
|
15
15
|
export * from './audit/index.js';
|
|
16
16
|
export * from './base/index.js';
|
|
17
17
|
export * from './configuration/index.js';
|
|
18
|
+
export * from './entitlement/index.js';
|
|
18
19
|
export * from './fix-entity/index.js';
|
|
19
20
|
export * from './experiment/index.js';
|
|
20
21
|
export * from './import-job/index.js';
|
|
@@ -23,12 +24,16 @@ export * from './key-event/index.js';
|
|
|
23
24
|
export * from './latest-audit/index.js';
|
|
24
25
|
export * from './opportunity/index.js';
|
|
25
26
|
export * from './organization/index.js';
|
|
27
|
+
export * from './organization-identity-provider/index.js';
|
|
26
28
|
export * from './scrape-job/index.js';
|
|
27
29
|
export * from './scrape-url/index.js';
|
|
28
30
|
export * from './site-candidate/index.js';
|
|
31
|
+
export * from './site-enrollment/index.js';
|
|
29
32
|
export * from './site-top-form/index.js';
|
|
30
33
|
export * from './site-top-page/index.js';
|
|
31
34
|
export * from './site/index.js';
|
|
32
35
|
export * from './suggestion/index.js';
|
|
33
36
|
export * from './page-intent/index.js';
|
|
34
37
|
export * from './report/index.js';
|
|
38
|
+
export * from './trial-user/index.js';
|
|
39
|
+
export * from './trial-user-activity/index.js';
|
|
@@ -10,7 +10,9 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import type {
|
|
13
|
+
import type {
|
|
14
|
+
BaseCollection, BaseModel, Site, Entitlement, OrganizationIdentityProvider, TrialUser,
|
|
15
|
+
} from '../index';
|
|
14
16
|
|
|
15
17
|
export interface Organization extends BaseModel {
|
|
16
18
|
getConfig(): object;
|
|
@@ -18,6 +20,9 @@ export interface Organization extends BaseModel {
|
|
|
18
20
|
getImsOrgId(): string;
|
|
19
21
|
getName(): string;
|
|
20
22
|
getSites(): Promise<Site[]>;
|
|
23
|
+
getEntitlements(): Promise<Entitlement[]>;
|
|
24
|
+
getOrganizationIdentityProviders(): Promise<OrganizationIdentityProvider[]>;
|
|
25
|
+
getTrialUsers(): Promise<TrialUser[]>;
|
|
21
26
|
setConfig(config: object): Organization;
|
|
22
27
|
setFulfillableItems(fulfillableItems: object): Organization;
|
|
23
28
|
setImsOrgId(imsOrgId: string): Organization;
|
|
@@ -28,6 +28,9 @@ Indexes Doc: https://electrodb.dev/en/modeling/indexes/
|
|
|
28
28
|
const schema = new SchemaBuilder(Organization, OrganizationCollection)
|
|
29
29
|
// this will add an attribute 'organizationId' as well as an index 'byOrganizationId'
|
|
30
30
|
.addReference('has_many', 'Sites')
|
|
31
|
+
.addReference('has_many', 'Entitlements')
|
|
32
|
+
.addReference('has_many', 'OrganizationIdentityProviders')
|
|
33
|
+
.addReference('has_many', 'TrialUsers')
|
|
31
34
|
.addAttribute('config', {
|
|
32
35
|
type: 'any',
|
|
33
36
|
required: true,
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 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, Organization, TrialUser,
|
|
15
|
+
} from '../index';
|
|
16
|
+
|
|
17
|
+
export type ProviderType = 'IMS' | 'MICROSOFT' | 'GOOGLE';
|
|
18
|
+
|
|
19
|
+
export interface OrganizationIdentityProvider extends BaseModel {
|
|
20
|
+
getMetadata(): object | null;
|
|
21
|
+
getProvider(): ProviderType;
|
|
22
|
+
getExternalId(): string;
|
|
23
|
+
getOrganization(): Promise<Organization>;
|
|
24
|
+
getTrialUsers(): Promise<TrialUser[]>;
|
|
25
|
+
setMetadata(metadata: object): OrganizationIdentityProvider;
|
|
26
|
+
setProvider(provider: ProviderType): OrganizationIdentityProvider;
|
|
27
|
+
setExternalId(externalId: string): OrganizationIdentityProvider;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface OrganizationIdentityProviderCollection extends
|
|
31
|
+
BaseCollection<OrganizationIdentityProvider> {
|
|
32
|
+
allByProvider(provider: ProviderType): Promise<OrganizationIdentityProvider[]>;
|
|
33
|
+
allByProviderAndExternalId(provider: ProviderType, externalId: string):
|
|
34
|
+
Promise<OrganizationIdentityProvider[]>;
|
|
35
|
+
allByOrganizationId(organizationId: string): Promise<OrganizationIdentityProvider[]>;
|
|
36
|
+
findByProvider(provider: ProviderType): Promise<OrganizationIdentityProvider[]>;
|
|
37
|
+
findByProviderAndExternalId(provider: ProviderType, externalId: string):
|
|
38
|
+
Promise<OrganizationIdentityProvider | null>;
|
|
39
|
+
findByOrganizationId(organizationId: string): Promise<OrganizationIdentityProvider[]>;
|
|
40
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 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 OrganizationIdentityProvider from './organization-identity-provider.model.js';
|
|
14
|
+
import OrganizationIdentityProviderCollection from './organization-identity-provider.collection.js';
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
OrganizationIdentityProvider,
|
|
18
|
+
OrganizationIdentityProviderCollection,
|
|
19
|
+
};
|
package/src/models/organization-identity-provider/organization-identity-provider.collection.js
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 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
|
+
* OrganizationIdentityProviderCollection - A collection class responsible for
|
|
17
|
+
* managing OrganizationIdentityProvider entities.
|
|
18
|
+
* Extends the BaseCollection to provide specific methods for interacting with
|
|
19
|
+
* OrganizationIdentityProvider records.
|
|
20
|
+
*
|
|
21
|
+
* @class OrganizationIdentityProviderCollection
|
|
22
|
+
* @extends BaseCollection
|
|
23
|
+
*/
|
|
24
|
+
class OrganizationIdentityProviderCollection extends BaseCollection {
|
|
25
|
+
// add custom methods here
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default OrganizationIdentityProviderCollection;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 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
|
+
/**
|
|
16
|
+
* OrganizationIdentityProvider - A class representing an OrganizationIdentityProvider entity.
|
|
17
|
+
* Provides methods to access and manipulate OrganizationIdentityProvider-specific data.
|
|
18
|
+
*
|
|
19
|
+
* @class OrganizationIdentityProvider
|
|
20
|
+
* @extends BaseModel
|
|
21
|
+
*/
|
|
22
|
+
class OrganizationIdentityProvider extends BaseModel {
|
|
23
|
+
static PROVIDER_TYPES = {
|
|
24
|
+
IMS: 'IMS',
|
|
25
|
+
MICROSOFT: 'MICROSOFT',
|
|
26
|
+
GOOGLE: 'GOOGLE',
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
// add your custom methods or overrides here
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default OrganizationIdentityProvider;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 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 { isObject } from '@adobe/spacecat-shared-utils';
|
|
14
|
+
import SchemaBuilder from '../base/schema.builder.js';
|
|
15
|
+
import OrganizationIdentityProvider from './organization-identity-provider.model.js';
|
|
16
|
+
import OrganizationIdentityProviderCollection from './organization-identity-provider.collection.js';
|
|
17
|
+
|
|
18
|
+
/*
|
|
19
|
+
Schema Doc: https://electrodb.dev/en/modeling/schema/
|
|
20
|
+
Attribute Doc: https://electrodb.dev/en/modeling/attributes/
|
|
21
|
+
Indexes Doc: https://electrodb.dev/en/modeling/indexes/
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
const schema = new SchemaBuilder(
|
|
25
|
+
OrganizationIdentityProvider,
|
|
26
|
+
OrganizationIdentityProviderCollection,
|
|
27
|
+
)
|
|
28
|
+
// Reference to Organization (many-to-one relationship)
|
|
29
|
+
.addReference('belongs_to', 'Organization')
|
|
30
|
+
.addAttribute('metadata', {
|
|
31
|
+
type: 'any',
|
|
32
|
+
required: false,
|
|
33
|
+
validate: (value) => !value || isObject(value),
|
|
34
|
+
})
|
|
35
|
+
.addAttribute('provider', {
|
|
36
|
+
type: Object.values(OrganizationIdentityProvider.PROVIDER_TYPES),
|
|
37
|
+
required: true,
|
|
38
|
+
})
|
|
39
|
+
.addAttribute('externalId', {
|
|
40
|
+
type: 'string',
|
|
41
|
+
required: true,
|
|
42
|
+
})
|
|
43
|
+
.addIndex(
|
|
44
|
+
{ composite: ['provider'] },
|
|
45
|
+
{ composite: ['externalId'] },
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
export default schema.build();
|
|
@@ -20,6 +20,7 @@ import type {
|
|
|
20
20
|
Opportunity,
|
|
21
21
|
Organization,
|
|
22
22
|
SiteCandidate,
|
|
23
|
+
SiteEnrollment,
|
|
23
24
|
SiteTopPage,
|
|
24
25
|
} from '../index.js';
|
|
25
26
|
|
|
@@ -214,6 +215,7 @@ export interface Site extends BaseModel {
|
|
|
214
215
|
getOrganization(): Promise<Organization>;
|
|
215
216
|
getOrganizationId(): string;
|
|
216
217
|
getSiteCandidates(): Promise<SiteCandidate[]>;
|
|
218
|
+
getSiteEnrollments(): Promise<SiteEnrollment[]>;
|
|
217
219
|
getSiteTopPages(): Promise<SiteTopPage[]>;
|
|
218
220
|
getSiteTopPagesBySource(source: string): Promise<SiteTopPage[]>;
|
|
219
221
|
getSiteTopPagesBySourceAndGeo(source: string, geo: string): Promise<SiteTopPage[]>;
|
|
@@ -10,7 +10,12 @@
|
|
|
10
10
|
* governing permissions and limitations under the License.
|
|
11
11
|
*/
|
|
12
12
|
|
|
13
|
-
import {
|
|
13
|
+
import {
|
|
14
|
+
composeAuditURL,
|
|
15
|
+
hasText,
|
|
16
|
+
isValidUrl,
|
|
17
|
+
DELIVERY_TYPES,
|
|
18
|
+
} from '@adobe/spacecat-shared-utils';
|
|
14
19
|
import BaseModel from '../base/base.model.js';
|
|
15
20
|
|
|
16
21
|
const HLX_HOST = /\.(?:aem|hlx)\.(?:page|live)$/i;
|
|
@@ -64,12 +69,7 @@ export const getAuthoringType = (hostname, authoringTypes) => {
|
|
|
64
69
|
* @extends BaseModel
|
|
65
70
|
*/
|
|
66
71
|
class Site extends BaseModel {
|
|
67
|
-
static DELIVERY_TYPES =
|
|
68
|
-
AEM_CS: 'aem_cs',
|
|
69
|
-
AEM_EDGE: 'aem_edge',
|
|
70
|
-
AEM_AMS: 'aem_ams',
|
|
71
|
-
OTHER: 'other',
|
|
72
|
-
};
|
|
72
|
+
static DELIVERY_TYPES = DELIVERY_TYPES;
|
|
73
73
|
|
|
74
74
|
static DEFAULT_DELIVERY_TYPE = Site.DELIVERY_TYPES.AEM_EDGE;
|
|
75
75
|
|
|
@@ -42,8 +42,10 @@ const schema = new SchemaBuilder(Site, SiteCollection)
|
|
|
42
42
|
.addReference('has_one', 'LatestAudit', ['auditType'], { required: false })
|
|
43
43
|
.addReference('has_many', 'Opportunities')
|
|
44
44
|
.addReference('has_many', 'SiteCandidates')
|
|
45
|
+
.addReference('has_many', 'SiteEnrollments')
|
|
45
46
|
.addReference('has_many', 'SiteTopForms')
|
|
46
47
|
.addReference('has_many', 'SiteTopPages')
|
|
48
|
+
.addReference('has_many', 'TrialUserActivities')
|
|
47
49
|
.addReference('has_many', 'PageIntents')
|
|
48
50
|
.addAttribute('baseURL', {
|
|
49
51
|
type: 'string',
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 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, Site, Entitlement,
|
|
15
|
+
} from '../index';
|
|
16
|
+
|
|
17
|
+
export type SiteEnrollmentStatus = 'ACTIVE' | 'SUSPENDED' | 'ENDED';
|
|
18
|
+
|
|
19
|
+
export interface SiteEnrollment extends BaseModel {
|
|
20
|
+
getStatus(): SiteEnrollmentStatus;
|
|
21
|
+
getSite(): Promise<Site>;
|
|
22
|
+
getEntitlement(): Promise<Entitlement>;
|
|
23
|
+
setStatus(status: SiteEnrollmentStatus): SiteEnrollment;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface SiteEnrollmentCollection extends
|
|
27
|
+
BaseCollection<SiteEnrollment> {
|
|
28
|
+
allBySiteId(siteId: string): Promise<SiteEnrollment[]>;
|
|
29
|
+
allByEntitlementId(entitlementId: string): Promise<SiteEnrollment[]>;
|
|
30
|
+
|
|
31
|
+
findBySiteId(siteId: string): Promise<SiteEnrollment[]>;
|
|
32
|
+
findByEntitlementId(entitlementId: string): Promise<SiteEnrollment[]>;
|
|
33
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 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
|
+
export { default as SiteEnrollment } from './site-enrollment.model.js';
|
|
14
|
+
export { default as SiteEnrollmentCollection } from './site-enrollment.collection.js';
|
|
15
|
+
export { default as SiteEnrollmentSchema } from './site-enrollment.schema.js';
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 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
|
+
* SiteEnrollmentCollection - A class representing a collection of SiteEnrollment entities.
|
|
17
|
+
* Provides methods to query and manipulate collections of SiteEnrollment data.
|
|
18
|
+
*
|
|
19
|
+
* @class SiteEnrollmentCollection
|
|
20
|
+
* @extends BaseCollection
|
|
21
|
+
*/
|
|
22
|
+
class SiteEnrollmentCollection extends BaseCollection {
|
|
23
|
+
// add your custom collection methods here
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default SiteEnrollmentCollection;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 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
|
+
/**
|
|
16
|
+
* SiteEnrollment - A class representing a SiteEnrollment entity.
|
|
17
|
+
* Provides methods to access and manipulate SiteEnrollment-specific data.
|
|
18
|
+
*
|
|
19
|
+
* @class SiteEnrollment
|
|
20
|
+
* @extends BaseModel
|
|
21
|
+
*/
|
|
22
|
+
class SiteEnrollment extends BaseModel {
|
|
23
|
+
// add your custom methods or overrides here
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default SiteEnrollment;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 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 SchemaBuilder from '../base/schema.builder.js';
|
|
14
|
+
import SiteEnrollment from './site-enrollment.model.js';
|
|
15
|
+
import SiteEnrollmentCollection from './site-enrollment.collection.js';
|
|
16
|
+
|
|
17
|
+
/*
|
|
18
|
+
Schema Doc: https://electrodb.dev/en/modeling/schema/
|
|
19
|
+
Attribute Doc: https://electrodb.dev/en/modeling/attributes/
|
|
20
|
+
Indexes Doc: https://electrodb.dev/en/modeling/indexes/
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
const schema = new SchemaBuilder(SiteEnrollment, SiteEnrollmentCollection)
|
|
24
|
+
// Reference to Site (many-to-one relationship)
|
|
25
|
+
.addReference('belongs_to', 'Site')
|
|
26
|
+
// Reference to Entitlement (many-to-one relationship)
|
|
27
|
+
.addReference('belongs_to', 'Entitlement');
|
|
28
|
+
|
|
29
|
+
export default schema.build();
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 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, Organization,
|
|
15
|
+
} from '../index';
|
|
16
|
+
import type { ProviderType } from '../organization-identity-provider';
|
|
17
|
+
|
|
18
|
+
export type Status = 'INVITED' | 'REGISTERED' | 'BLOCKED' | 'DELETED';
|
|
19
|
+
|
|
20
|
+
export interface TrialUser extends BaseModel {
|
|
21
|
+
getExternalUserId(): string;
|
|
22
|
+
getStatus(): Status;
|
|
23
|
+
getProvider(): ProviderType;
|
|
24
|
+
getLastSeenAt(): Date | null;
|
|
25
|
+
getMetadata(): object | null;
|
|
26
|
+
getOrganization(): Promise<Organization>;
|
|
27
|
+
getEmailId(): string;
|
|
28
|
+
getFirstName(): string | null;
|
|
29
|
+
getLastName(): string | null;
|
|
30
|
+
getTrialUserActivities(): Promise<TrialUserActivity[]>;
|
|
31
|
+
setExternalUserId(externalUserId: string): TrialUser;
|
|
32
|
+
setStatus(status: Status): TrialUser;
|
|
33
|
+
setProvider(provider: ProviderType): TrialUser;
|
|
34
|
+
setLastSeenAt(lastSeenAt: Date): TrialUser;
|
|
35
|
+
setMetadata(metadata: object): TrialUser;
|
|
36
|
+
setEmailId(emailId: string): TrialUser;
|
|
37
|
+
setFirstName(firstName: string): TrialUser;
|
|
38
|
+
setLastName(lastName: string): TrialUser;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface TrialUserCollection extends BaseCollection<TrialUser> {
|
|
42
|
+
allByProvider(provider: ProviderType): Promise<TrialUser[]>;
|
|
43
|
+
allByProviderAndExternalUserId(provider: ProviderType, externalId: string): Promise<TrialUser[]>;
|
|
44
|
+
allByOrganizationId(organizationId: string): Promise<TrialUser[]>;
|
|
45
|
+
allByEmailId(emailId: string): Promise<TrialUser[]>;
|
|
46
|
+
findByProvider(provider: ProviderType): Promise<TrialUser[]>;
|
|
47
|
+
findByProviderAndExternalUserId(provider: ProviderType, externalId: string):
|
|
48
|
+
Promise<TrialUser[]>;
|
|
49
|
+
findByOrganizationId(organizationId: string): Promise<TrialUser[]>;
|
|
50
|
+
findByEmailId(emailId: string): Promise<TrialUser[]>;
|
|
51
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 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 TrialUser from './trial-user.model.js';
|
|
14
|
+
import TrialUserCollection from './trial-user.collection.js';
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
TrialUser,
|
|
18
|
+
TrialUserCollection,
|
|
19
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 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
|
+
* TrialUserCollection - A collection class responsible for managing TrialUser entities.
|
|
17
|
+
* Extends the BaseCollection to provide specific methods for interacting with TrialUser records.
|
|
18
|
+
*
|
|
19
|
+
* @class TrialUserCollection
|
|
20
|
+
* @extends BaseCollection
|
|
21
|
+
*/
|
|
22
|
+
class TrialUserCollection extends BaseCollection {
|
|
23
|
+
// add custom methods here
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default TrialUserCollection;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 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
|
+
/**
|
|
16
|
+
* TrialUser - A class representing a trial user entity.
|
|
17
|
+
* Provides methods to access and manipulate trial user-specific data.
|
|
18
|
+
*
|
|
19
|
+
* @class TrialUser
|
|
20
|
+
* @extends BaseModel
|
|
21
|
+
*/
|
|
22
|
+
class TrialUser extends BaseModel {
|
|
23
|
+
/**
|
|
24
|
+
* Trial user status types.
|
|
25
|
+
* Any change to this object needs to be reflected in the index.d.ts file as well.
|
|
26
|
+
*/
|
|
27
|
+
static STATUSES = {
|
|
28
|
+
INVITED: 'INVITED',
|
|
29
|
+
REGISTERED: 'REGISTERED', // User has logged in at least once
|
|
30
|
+
BLOCKED: 'BLOCKED',
|
|
31
|
+
DELETED: 'DELETED',
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export default TrialUser;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 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 { isIsoDate, isObject } from '@adobe/spacecat-shared-utils';
|
|
14
|
+
import SchemaBuilder from '../base/schema.builder.js';
|
|
15
|
+
import TrialUser from './trial-user.model.js';
|
|
16
|
+
import TrialUserCollection from './trial-user.collection.js';
|
|
17
|
+
import OrganizationIdentityProvider from '../organization-identity-provider/organization-identity-provider.model.js';
|
|
18
|
+
|
|
19
|
+
/*
|
|
20
|
+
Schema Doc: https://electrodb.dev/en/modeling/schema/
|
|
21
|
+
Attribute Doc: https://electrodb.dev/en/modeling/attributes/
|
|
22
|
+
Indexes Doc: https://electrodb.dev/en/modeling/indexes/
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
const schema = new SchemaBuilder(TrialUser, TrialUserCollection)
|
|
26
|
+
// Reference to Organization (many-to-one relationship)
|
|
27
|
+
.addReference('belongs_to', 'Organization')
|
|
28
|
+
// Reference to TrialUserActivity (one-to-many relationship)
|
|
29
|
+
.addReference('has_many', 'TrialUserActivities')
|
|
30
|
+
.addAttribute('externalUserId', {
|
|
31
|
+
type: 'string',
|
|
32
|
+
required: false,
|
|
33
|
+
})
|
|
34
|
+
.addAttribute('status', {
|
|
35
|
+
type: Object.values(TrialUser.STATUSES),
|
|
36
|
+
required: true,
|
|
37
|
+
})
|
|
38
|
+
.addAttribute('provider', {
|
|
39
|
+
type: Object.values(OrganizationIdentityProvider.PROVIDER_TYPES),
|
|
40
|
+
required: false,
|
|
41
|
+
})
|
|
42
|
+
.addAttribute('lastSeenAt', {
|
|
43
|
+
type: 'string',
|
|
44
|
+
validate: (value) => !value || isIsoDate(value),
|
|
45
|
+
})
|
|
46
|
+
.addAttribute('emailId', {
|
|
47
|
+
type: 'string',
|
|
48
|
+
required: true,
|
|
49
|
+
})
|
|
50
|
+
.addAttribute('firstName', {
|
|
51
|
+
type: 'string',
|
|
52
|
+
required: false,
|
|
53
|
+
})
|
|
54
|
+
.addAttribute('lastName', {
|
|
55
|
+
type: 'string',
|
|
56
|
+
required: false,
|
|
57
|
+
})
|
|
58
|
+
.addAttribute('metadata', {
|
|
59
|
+
type: 'any',
|
|
60
|
+
validate: (value) => !value || isObject(value),
|
|
61
|
+
})
|
|
62
|
+
.addAllIndex(['emailId'])
|
|
63
|
+
.addIndex(
|
|
64
|
+
{ composite: ['provider'] },
|
|
65
|
+
{ composite: ['externalUserId'] },
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
export default schema.build();
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 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,
|
|
15
|
+
} from '../base';
|
|
16
|
+
import type { EntitlementProductCode } from '../entitlement';
|
|
17
|
+
|
|
18
|
+
export type Type = 'SIGN_UP' | 'SIGN_IN' | 'CREATE_SITE' | 'RUN_AUDIT' | 'PROMPT_RUN' | 'DOWNLOAD';
|
|
19
|
+
|
|
20
|
+
export interface TrialUserActivity extends BaseModel {
|
|
21
|
+
getType(): Type;
|
|
22
|
+
getDetails(): object | null;
|
|
23
|
+
getProductCode(): EntitlementProductCode;
|
|
24
|
+
getEntitlementId(): string;
|
|
25
|
+
getTrialUserId(): string;
|
|
26
|
+
getSiteId(): string;
|
|
27
|
+
setType(type: Type): TrialUserActivity;
|
|
28
|
+
setDetails(details: object): TrialUserActivity;
|
|
29
|
+
setProductCode(productCode: string): TrialUserActivity;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface TrialUserActivityCollection extends BaseCollection<TrialUserActivity> {
|
|
33
|
+
allByEntitlementId(entitlementId: string): Promise<TrialUserActivity[]>;
|
|
34
|
+
allByProductCode(productCode: EntitlementProductCode): Promise<TrialUserActivity[]>;
|
|
35
|
+
allByProductCodeAndCreatedAt(productCode: EntitlementProductCode, createdAt: string):
|
|
36
|
+
Promise<TrialUserActivity[]>;
|
|
37
|
+
allBySiteId(siteId: string): Promise<TrialUserActivity[]>;
|
|
38
|
+
|
|
39
|
+
findByEntitlementId(entitlementId: string): Promise<TrialUserActivity[]>;
|
|
40
|
+
findByProductCode(productCode: EntitlementProductCode): Promise<TrialUserActivity[]>;
|
|
41
|
+
findByProductCodeAndCreatedAt(productCode: EntitlementProductCode, createdAt: string):
|
|
42
|
+
Promise<TrialUserActivity[]>;
|
|
43
|
+
findBySiteId(siteId: string): Promise<TrialUserActivity[]>;
|
|
44
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 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 TrialUserActivity from './trial-user-activity.model.js';
|
|
14
|
+
import TrialUserActivityCollection from './trial-user-activity.collection.js';
|
|
15
|
+
|
|
16
|
+
export {
|
|
17
|
+
TrialUserActivity,
|
|
18
|
+
TrialUserActivityCollection,
|
|
19
|
+
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 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
|
+
* TrialUserActivityCollection - A collection class responsible for managing TrialUserActivity
|
|
17
|
+
* entities.
|
|
18
|
+
* Extends the BaseCollection to provide specific methods for interacting with TrialUserActivity
|
|
19
|
+
* records.
|
|
20
|
+
*
|
|
21
|
+
* @class TrialUserActivityCollection
|
|
22
|
+
* @extends BaseCollection
|
|
23
|
+
*/
|
|
24
|
+
class TrialUserActivityCollection extends BaseCollection {
|
|
25
|
+
// add custom methods here
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default TrialUserActivityCollection;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 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
|
+
/**
|
|
16
|
+
* TrialUserActivity - A class representing a trial user activity entity.
|
|
17
|
+
* Provides methods to access and manipulate trial user activity-specific data.
|
|
18
|
+
*
|
|
19
|
+
* @class TrialUserActivity
|
|
20
|
+
* @extends BaseModel
|
|
21
|
+
*/
|
|
22
|
+
class TrialUserActivity extends BaseModel {
|
|
23
|
+
/**
|
|
24
|
+
* Trial user activity types.
|
|
25
|
+
* Any change to this object needs to be reflected in the index.d.ts file as well.
|
|
26
|
+
*/
|
|
27
|
+
static TYPES = {
|
|
28
|
+
SIGN_UP: 'SIGN_UP',
|
|
29
|
+
SIGN_IN: 'SIGN_IN',
|
|
30
|
+
CREATE_SITE: 'CREATE_SITE',
|
|
31
|
+
RUN_AUDIT: 'RUN_AUDIT',
|
|
32
|
+
PROMPT_RUN: 'PROMPT_RUN',
|
|
33
|
+
DOWNLOAD: 'DOWNLOAD',
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export default TrialUserActivity;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright 2025 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 SchemaBuilder from '../base/schema.builder.js';
|
|
14
|
+
import TrialUserActivity from './trial-user-activity.model.js';
|
|
15
|
+
import TrialUserActivityCollection from './trial-user-activity.collection.js';
|
|
16
|
+
import Entitlement from '../entitlement/entitlement.model.js';
|
|
17
|
+
|
|
18
|
+
/*
|
|
19
|
+
Schema Doc: https://electrodb.dev/en/modeling/schema/
|
|
20
|
+
Attribute Doc: https://electrodb.dev/en/modeling/attributes/
|
|
21
|
+
Indexes Doc: https://electrodb.dev/en/modeling/indexes/
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
const schema = new SchemaBuilder(TrialUserActivity, TrialUserActivityCollection)
|
|
25
|
+
// Reference to OrganizationIdentityProvider (many-to-one relationship)
|
|
26
|
+
.addReference('belongs_to', 'TrialUser')
|
|
27
|
+
// Reference to Organization (many-to-one relationship)
|
|
28
|
+
.addReference('belongs_to', 'Entitlement')
|
|
29
|
+
// Reference to Site (many-to-one relationship)
|
|
30
|
+
.addReference('belongs_to', 'Site')
|
|
31
|
+
.addAttribute('type', {
|
|
32
|
+
type: Object.values(TrialUserActivity.TYPES),
|
|
33
|
+
required: true,
|
|
34
|
+
})
|
|
35
|
+
.addAttribute('details', {
|
|
36
|
+
type: 'any',
|
|
37
|
+
})
|
|
38
|
+
.addAttribute('productCode', {
|
|
39
|
+
type: Object.values(Entitlement.PRODUCT_CODES),
|
|
40
|
+
required: true,
|
|
41
|
+
})
|
|
42
|
+
.addIndex(
|
|
43
|
+
{ composite: ['productCode'] },
|
|
44
|
+
{ composite: ['createdAt'] },
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
export default schema.build();
|
package/src/util/util.js
CHANGED
|
@@ -36,7 +36,14 @@ const referenceToBaseMethodName = (reference) => {
|
|
|
36
36
|
|
|
37
37
|
const entityNameToAllPKValue = (entityName) => `ALL_${pluralize.plural(entityName.toUpperCase())}`;
|
|
38
38
|
|
|
39
|
-
const idNameToEntityName = (idName) =>
|
|
39
|
+
const idNameToEntityName = (idName) => {
|
|
40
|
+
let result = idName;
|
|
41
|
+
if (idName.endsWith('Id')) {
|
|
42
|
+
result = result.replace('Id', '');
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return capitalize(pluralize.singular(result));
|
|
46
|
+
};
|
|
40
47
|
|
|
41
48
|
const isPositiveInteger = (value) => isInteger(value) && value > 0;
|
|
42
49
|
|