-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(experience-controls): experience controls module and adapter (#1307
) EMP-1939 --- Co-authored-by: Matías García Gimeno <[email protected]> Co-authored-by: Ana Fernández Ostio <[email protected]> Co-authored-by: Ana Fernández Ostio <[email protected]> Co-authored-by: Ger-28 <[email protected]> Co-authored-by: Ana Fernández Ostio <[email protected]> Co-authored-by: Matias Garcia <[email protected]> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: empathy/x <[email protected]> Co-authored-by: acondal <[email protected]> Co-authored-by: mariorey <[email protected]> Co-authored-by: Gerardo Vázquez <[email protected]> Co-authored-by: lauramargar <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Diego Pascual <[email protected]>
- Loading branch information
1 parent
dce7676
commit 6ae3f6b
Showing
43 changed files
with
3,684 additions
and
8,873 deletions.
There are no files selected for viewing
This file contains 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
26 changes: 26 additions & 0 deletions
26
packages/x-adapter-platform/src/endpoint-adapters/experience-controls.endpoint-adapter.ts
This file contains 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,26 @@ | ||
/* eslint-disable max-len */ | ||
import { endpointAdapterFactory } from '@empathyco/x-adapter'; | ||
import { ExperienceControlsRequest, ExperienceControlsResponse } from '@empathyco/x-types'; | ||
import { experienceControlsRequestMapper } from '../mappers/requests/experience-controls-request.mapper'; | ||
import { experienceControlsResponseMapper } from '../mappers/responses/experience-controls-response.mapper'; | ||
/* eslint-enable max-len */ | ||
|
||
/**. | ||
* Default adapter for the experience controls endpoint. | ||
* | ||
* @public | ||
*/ | ||
export const experienceControlsEndpointAdapter = endpointAdapterFactory< | ||
ExperienceControlsRequest, | ||
ExperienceControlsResponse | ||
>({ | ||
endpoint: 'https://api.{extraParams.env(.)}empathy.co/config/v1/public/configs', | ||
requestMapper: experienceControlsRequestMapper, | ||
responseMapper: experienceControlsResponseMapper, | ||
defaultRequestOptions: { | ||
id: 'experience-controls', | ||
parameters: { | ||
service: 'xcontrols' | ||
} | ||
} | ||
}); |
This file contains 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
16 changes: 16 additions & 0 deletions
16
packages/x-adapter-platform/src/mappers/requests/experience-controls-request.mapper.ts
This file contains 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,16 @@ | ||
/* eslint-disable max-len */ | ||
import { schemaMapperFactory } from '@empathyco/x-adapter'; | ||
import { ExperienceControlsRequest } from '@empathyco/x-types'; | ||
import { PlatformExperienceControlsRequest } from '../../types/requests/experience-controls-request.model'; | ||
import { experienceControlsRequestSchema } from '../../schemas/requests/experience-controls-request.schema'; | ||
/* eslint-enable max-len */ | ||
|
||
/** | ||
* Default implementation for the ExperienceControlsRequestMapper. | ||
* | ||
* @public | ||
*/ | ||
export const experienceControlsRequestMapper = schemaMapperFactory< | ||
ExperienceControlsRequest, | ||
PlatformExperienceControlsRequest | ||
>(experienceControlsRequestSchema); |
This file contains 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
15 changes: 15 additions & 0 deletions
15
packages/x-adapter-platform/src/mappers/responses/experience-controls-response.mapper.ts
This file contains 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,15 @@ | ||
import { schemaMapperFactory } from '@empathyco/x-adapter'; | ||
import { ExperienceControlsResponse } from '@empathyco/x-types'; | ||
import { PlatformExperienceControlsResponse } from '../../types'; | ||
// eslint-disable-next-line max-len | ||
import { experienceControlsResponseSchema } from '../../schemas/responses/experience-controls-response.schema'; | ||
|
||
/** | ||
* Default implementation for the ExperienceControlsResponseMapper. | ||
* | ||
* @public | ||
*/ | ||
export const experienceControlsResponseMapper = schemaMapperFactory< | ||
PlatformExperienceControlsResponse, | ||
ExperienceControlsResponse | ||
>(experienceControlsResponseSchema); |
This file contains 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 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
16 changes: 16 additions & 0 deletions
16
packages/x-adapter-platform/src/schemas/requests/experience-controls-request.schema.ts
This file contains 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,16 @@ | ||
import { createMutableSchema } from '@empathyco/x-adapter'; | ||
import { ExperienceControlsRequest } from '@empathyco/x-types'; | ||
// eslint-disable-next-line max-len | ||
import { PlatformExperienceControlsRequest } from '../../types/requests/experience-controls-request.model'; | ||
|
||
/** | ||
* Default implementation for the ExperienceControlsRequestSchema. | ||
* | ||
* @public | ||
*/ | ||
export const experienceControlsRequestSchema = createMutableSchema< | ||
ExperienceControlsRequest, | ||
PlatformExperienceControlsRequest | ||
>({ | ||
extraParams: 'extraParams' | ||
}); |
This file contains 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
16 changes: 16 additions & 0 deletions
16
packages/x-adapter-platform/src/schemas/responses/experience-controls-response.schema.ts
This file contains 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,16 @@ | ||
import { createMutableSchema } from '@empathyco/x-adapter'; | ||
import { ExperienceControlsResponse } from '@empathyco/x-types'; | ||
import { PlatformExperienceControlsResponse } from '../../types'; | ||
|
||
/** | ||
* Default implementation for the ExperienceControlsResponseSchema. | ||
* | ||
* @public | ||
*/ | ||
export const experienceControlsResponseSchema = createMutableSchema< | ||
PlatformExperienceControlsResponse, | ||
ExperienceControlsResponse | ||
>({ | ||
controls: response => response, | ||
events: {} | ||
}); |
This file contains 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 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
8 changes: 8 additions & 0 deletions
8
packages/x-adapter-platform/src/types/requests/experience-controls-request.model.ts
This file contains 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,8 @@ | ||
import { PlatformExtraParamsRequest } from './request.types'; | ||
|
||
/** | ||
* Request for the `experience controls` endpoint. | ||
* | ||
* @public | ||
*/ | ||
export interface PlatformExperienceControlsRequest extends PlatformExtraParamsRequest {} |
This file contains 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
8 changes: 8 additions & 0 deletions
8
packages/x-adapter-platform/src/types/responses/experience-controls-response.model.ts
This file contains 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,8 @@ | ||
import { Dictionary } from '@empathyco/x-utils'; | ||
|
||
/** | ||
* Response for the `experience controls` endpoint. | ||
* | ||
* @public | ||
*/ | ||
export interface PlatformExperienceControlsResponse extends Dictionary<unknown> {} |
This file contains 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 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 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 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 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 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 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 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
56 changes: 56 additions & 0 deletions
56
packages/x-components/src/x-modules/experience-controls/components/experience-controls.vue
This file contains 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,56 @@ | ||
<script lang="ts"> | ||
import Vue from 'vue'; | ||
import { Component } from 'vue-property-decorator'; | ||
import { XOn } from '../../../components/decorators/bus.decorators'; | ||
import { XEvent, XEventsTypes } from '../../../wiring/events.types'; | ||
import { xComponentMixin } from '../../../components/x-component.mixin'; | ||
import { experienceControlsXModule } from '../x-module'; | ||
/** | ||
* This component subscribes to changes in the ExperienceControls module to fire the events that | ||
* propagate the configuration. | ||
* | ||
* @public | ||
*/ | ||
@Component({ | ||
mixins: [xComponentMixin(experienceControlsXModule)] | ||
}) | ||
export default class ExperienceControls extends Vue { | ||
/**. | ||
* Iterates the list of XEvents received and emits them | ||
* | ||
* @param {Partial<XEventsTypes>} events events to be emitted | ||
*/ | ||
@XOn('ExperienceControlsEventsChanged') | ||
onEventsChanged(events: Partial<XEventsTypes>): void { | ||
Object.entries(events).forEach(([eventName, eventPayload]) => { | ||
this.$x.emit(eventName as XEvent, eventPayload); | ||
}); | ||
} | ||
// eslint-disable-next-line @typescript-eslint/no-empty-function | ||
render(): void {} | ||
} | ||
</script> | ||
|
||
<docs lang="mdx"> | ||
## Examples | ||
|
||
This component will fire the events received in the `ExperienceControlsEventsChanged` event. | ||
|
||
```vue | ||
<template> | ||
<ExperienceControls /> | ||
</template> | ||
<script> | ||
import { ExperienceControls } from '@empathyco/x-components/experience-controls'; | ||
|
||
export default { | ||
name: 'ExperienceControlsDemo', | ||
components: { | ||
ExperienceControls | ||
} | ||
}; | ||
</script> | ||
``` | ||
</docs> |
Oops, something went wrong.