-
Notifications
You must be signed in to change notification settings - Fork 0
feat: experimentation engine #1446
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
3362eee
fix: experimentation engine
dipratap eb33d8f
fix: experimentation engine
dipratap 010252b
fix: refactor
dipratap 381bbde
fix: geo-experiment model schema changes
dipratap 37ccb9b
fix: tests
dipratap b9a7d31
fix: merge main
dipratap 9949fa6
fix: tests
dipratap 5d84427
fix: updates
dipratap eaa08b5
fix: merge main
dipratap f74fb20
fix: updates
dipratap e6274aa
fix: updates
dipratap e709006
fix: updates
dipratap 8582cfb
fix: minor details
dipratap df7c12a
fix: updated flow
dipratap a195c35
Merge branch 'main' of github.com:adobe/spacecat-shared into expe
dipratap 5cc898e
fix: updated flow
dipratap 0b9a73a
fix: updated flow
dipratap e98f4e2
fix: merge main
dipratap 401f7f3
fix: updated flow
dipratap 6cf1475
fix: added completion date
dipratap 8889918
fix: merge main
dipratap f1467d4
fix: update fields
dipratap 6a2b2b8
fix: update fields
dipratap 4fa8f17
fix: updated db fields
dipratap 6384aed
fix: merge main
dipratap 525b183
fix: updated db fields
dipratap 7547129
fix: updated db fields
dipratap aaa76ce
fix: merge main
dipratap File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
packages/spacecat-shared-data-access/src/models/geo-experiment/geo-experiment.collection.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| /* | ||
| * Copyright 2026 Adobe. All rights reserved. | ||
| * This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. You may obtain a copy | ||
| * of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software distributed under | ||
| * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
| * OF ANY KIND, either express or implied. See the License for the specific language | ||
| * governing permissions and limitations under the License. | ||
| */ | ||
|
|
||
| import { hasText } from '@adobe/spacecat-shared-utils'; | ||
| import BaseCollection from '../base/base.collection.js'; | ||
|
|
||
| class GeoExperimentCollection extends BaseCollection { | ||
| static COLLECTION_NAME = 'GeoExperimentCollection'; | ||
|
|
||
| /** | ||
| * Gets all geo experiments for a site, ordered by most recently updated. | ||
| * | ||
| * @param {string} siteId - The site ID. | ||
| * @param {object} [options={}] - Query options (limit, cursor). | ||
| * @returns {Promise<{data: GeoExperiment[], cursor: string|null}>} Paginated results. | ||
| */ | ||
| async allBySiteId(siteId, options = {}) { | ||
| if (!hasText(siteId)) { | ||
| throw new Error('SiteId is required'); | ||
| } | ||
|
|
||
| const result = await this.allByIndexKeys( | ||
| { siteId }, | ||
| { ...options, returnCursor: true }, | ||
| ); | ||
|
|
||
| return { | ||
| data: result.data || [], | ||
| cursor: result.cursor, | ||
| }; | ||
| } | ||
| } | ||
|
|
||
| export default GeoExperimentCollection; |
41 changes: 41 additions & 0 deletions
41
packages/spacecat-shared-data-access/src/models/geo-experiment/geo-experiment.model.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| /* | ||
| * Copyright 2026 Adobe. All rights reserved. | ||
| * This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. You may obtain a copy | ||
| * of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software distributed under | ||
| * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
| * OF ANY KIND, either express or implied. See the License for the specific language | ||
| * governing permissions and limitations under the License. | ||
| */ | ||
|
|
||
| import BaseModel from '../base/base.model.js'; | ||
|
|
||
| class GeoExperiment extends BaseModel { | ||
| static ENTITY_NAME = 'GeoExperiment'; | ||
|
|
||
| static DEFAULT_UPDATED_BY = 'spacecat'; | ||
|
|
||
| static TYPES = { | ||
| ONSITE_OPPORTUNITY_DEPLOYMENT: 'onsite_opportunity_deployment', | ||
| }; | ||
|
|
||
| static STATUSES = { | ||
| GENERATING_BASELINE: 'GENERATING_BASELINE', | ||
| IN_PROGRESS: 'IN_PROGRESS', | ||
| COMPLETED: 'COMPLETED', | ||
| FAILED: 'FAILED', | ||
| }; | ||
|
|
||
| static PHASES = { | ||
| PRE_ANALYSIS_SUBMITTED: 'pre_analysis_submitted', | ||
| PRE_ANALYSIS_DONE: 'pre_analysis_done', | ||
| DEPLOYMENT_STARTED: 'deployment_started', | ||
| DEPLOYMENT_COMPLETED: 'deployment_completed', | ||
| POST_ANALYSIS_SUBMITTED: 'post_analysis_submitted', | ||
| POST_ANALYSIS_DONE: 'post_analysis_done', | ||
| }; | ||
| } | ||
|
|
||
| export default GeoExperiment; |
93 changes: 93 additions & 0 deletions
93
packages/spacecat-shared-data-access/src/models/geo-experiment/geo-experiment.schema.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,93 @@ | ||
| /* | ||
| * Copyright 2026 Adobe. All rights reserved. | ||
| * This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. You may obtain a copy | ||
| * of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software distributed under | ||
| * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
| * OF ANY KIND, either express or implied. See the License for the specific language | ||
| * governing permissions and limitations under the License. | ||
| */ | ||
|
|
||
| /* c8 ignore start */ | ||
|
|
||
| import { | ||
| hasText, | ||
| isInteger, | ||
| isObject, | ||
| isValidUUID, | ||
| } from '@adobe/spacecat-shared-utils'; | ||
|
|
||
| import SchemaBuilder from '../base/schema.builder.js'; | ||
| import GeoExperiment from './geo-experiment.model.js'; | ||
| import GeoExperimentCollection from './geo-experiment.collection.js'; | ||
|
|
||
| const schema = new SchemaBuilder(GeoExperiment, GeoExperimentCollection) | ||
| .addReference('belongs_to', 'Site') | ||
| .addReference('belongs_to', 'Opportunity', [], { required: false }) | ||
| .addAttribute('preScheduleId', { | ||
| type: 'string', | ||
| validate: (value) => !value || hasText(value), | ||
| }) | ||
| .addAttribute('postScheduleId', { | ||
| type: 'string', | ||
| validate: (value) => !value || hasText(value), | ||
| }) | ||
| .addAttribute('type', { | ||
| type: Object.values(GeoExperiment.TYPES), | ||
| required: true, | ||
| }) | ||
| .addAttribute('status', { | ||
| type: Object.values(GeoExperiment.STATUSES), | ||
| required: true, | ||
| }) | ||
| .addAttribute('phase', { | ||
| type: Object.values(GeoExperiment.PHASES), | ||
| required: true, | ||
| }) | ||
| .addAttribute('suggestionIds', { | ||
| type: 'list', | ||
| items: { | ||
| type: 'string', | ||
| validate: (value) => isValidUUID(value), | ||
| }, | ||
| default: () => [], | ||
| }) | ||
| .addAttribute('name', { | ||
| type: 'string', | ||
| required: true, | ||
| validate: (value) => hasText(value), | ||
| }) | ||
| .addAttribute('promptsCount', { | ||
| type: 'number', | ||
| default: 0, | ||
| validate: (value) => isInteger(value) && value >= 0, | ||
| }) | ||
| .addAttribute('promptsLocation', { | ||
| type: 'string', | ||
| validate: (value) => !value || hasText(value), | ||
| }) | ||
| .addAttribute('startTime', { | ||
|
nit23uec marked this conversation as resolved.
|
||
| type: 'string', | ||
| validate: (value) => !value || hasText(value), | ||
| }) | ||
| .addAttribute('endTime', { | ||
| type: 'string', | ||
| validate: (value) => !value || hasText(value), | ||
| }) | ||
| .addAttribute('metadata', { | ||
| type: 'any', | ||
| validate: (value) => !value || isObject(value), | ||
| }) | ||
| .addAttribute('error', { | ||
| type: 'any', | ||
| validate: (value) => !value || isObject(value), | ||
| }) | ||
| .addAttribute('updatedBy', { | ||
| type: 'string', | ||
| default: GeoExperiment.DEFAULT_UPDATED_BY, | ||
| validate: (value) => hasText(value), | ||
| }); | ||
|
|
||
| export default schema.build(); | ||
71 changes: 71 additions & 0 deletions
71
packages/spacecat-shared-data-access/src/models/geo-experiment/index.d.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| /* | ||
| * Copyright 2026 Adobe. All rights reserved. | ||
| * This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. You may obtain a copy | ||
| * of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software distributed under | ||
| * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
| * OF ANY KIND, either express or implied. See the License for the specific language | ||
| * governing permissions and limitations under the License. | ||
| */ | ||
|
|
||
| import type { | ||
| BaseCollection, | ||
| BaseModel, | ||
| Opportunity, | ||
| PaginatedResult, | ||
| QueryOptions, | ||
| Site, | ||
| } from '../index'; | ||
|
|
||
| export interface GeoExperiment extends BaseModel { | ||
| getSiteId(): string; | ||
| getOpportunityId(): string | undefined; | ||
| getSite(): Promise<Site>; | ||
| getOpportunity(): Promise<Opportunity>; | ||
| getPreScheduleId(): string | undefined; | ||
| getPostScheduleId(): string | undefined; | ||
| getType(): string; | ||
| getPhase(): string; | ||
| getStatus(): string; | ||
| getSuggestionIds(): string[]; | ||
| getPromptsLocation(): string | undefined; | ||
| getName(): string; | ||
| getPromptsCount(): number; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. getPromptsLocation() is missing
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added |
||
| getStartTime(): string | undefined; | ||
| getEndTime(): string | undefined; | ||
| getMetadata(): object | undefined; | ||
| getError(): object | undefined; | ||
| getUpdatedBy(): string; | ||
|
|
||
| setSiteId(siteId: string): GeoExperiment; | ||
| setOpportunityId(opportunityId?: string): GeoExperiment; | ||
| setPreScheduleId(preScheduleId?: string): GeoExperiment; | ||
| setPostScheduleId(postScheduleId?: string): GeoExperiment; | ||
| setType(type: string): GeoExperiment; | ||
| setPhase(phase: string): GeoExperiment; | ||
| setStatus(status: string): GeoExperiment; | ||
| setSuggestionIds(suggestionIds: string[]): GeoExperiment; | ||
| setPromptsLocation(promptsLocation?: string): GeoExperiment; | ||
| setName(name: string): GeoExperiment; | ||
| setPromptsCount(promptsCount: number): GeoExperiment; | ||
| setStartTime(startTime?: string): GeoExperiment; | ||
| setEndTime(endTime?: string): GeoExperiment; | ||
| setMetadata(metadata?: object): GeoExperiment; | ||
| setError(error?: object): GeoExperiment; | ||
| setUpdatedBy(updatedBy: string): GeoExperiment; | ||
| } | ||
|
|
||
| export interface GeoExperimentCollection extends BaseCollection<GeoExperiment> { | ||
| allBySiteId(siteId: string, options?: QueryOptions): Promise<PaginatedResult<GeoExperiment>>; | ||
| findBySiteId(siteId: string): Promise<GeoExperiment | null>; | ||
| allByOpportunityId( | ||
| opportunityId: string, | ||
| options?: QueryOptions, | ||
| ): Promise<GeoExperiment[] | PaginatedResult<GeoExperiment>>; | ||
| findByOpportunityId( | ||
| opportunityId: string, | ||
| options?: QueryOptions, | ||
| ): Promise<GeoExperiment | null>; | ||
| } | ||
19 changes: 19 additions & 0 deletions
19
packages/spacecat-shared-data-access/src/models/geo-experiment/index.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| /* | ||
| * Copyright 2026 Adobe. All rights reserved. | ||
| * This file is licensed to you under the Apache License, Version 2.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. You may obtain a copy | ||
| * of the License at http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software distributed under | ||
| * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS | ||
| * OF ANY KIND, either express or implied. See the License for the specific language | ||
| * governing permissions and limitations under the License. | ||
| */ | ||
|
|
||
| import GeoExperiment from './geo-experiment.model.js'; | ||
| import GeoExperimentCollection from './geo-experiment.collection.js'; | ||
|
|
||
| export { | ||
| GeoExperiment, | ||
| GeoExperimentCollection, | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.