Skip to content

Commit

Permalink
feat: add home location [EXT-3684] (#1322)
Browse files Browse the repository at this point in the history
* feat: add home location api

* chore: add explicit tests for shape of home and page apis

* Update lib/types/api.types.ts

Co-authored-by: Andi Pätzold <[email protected]>

* fix: export HomeExtensionSDK type

Co-authored-by: Andi Pätzold <[email protected]>
  • Loading branch information
martin3walker and andipaetzold authored Aug 10, 2022
1 parent cd5de88 commit 527ad19
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const LOCATION_TO_API_PRODUCERS: { [location: string]: ProducerFunc[] } = {
[locations.LOCATION_ENTRY_EDITOR]: [makeSharedAPI, makeEntryAPI, makeEditorAPI],
[locations.LOCATION_DIALOG]: [makeSharedAPI, makeDialogAPI, makeWindowAPI],
[locations.LOCATION_PAGE]: [makeSharedAPI],
[locations.LOCATION_HOME]: [makeSharedAPI],
[locations.LOCATION_APP_CONFIG]: [makeSharedAPI, makeAppAPI],
}

Expand Down
1 change: 1 addition & 0 deletions lib/locations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const locations: Locations = {
LOCATION_ENTRY_EDITOR: 'entry-editor',
LOCATION_PAGE: 'page',
LOCATION_APP_CONFIG: 'app-config',
LOCATION_HOME: 'home',
}

export default locations
6 changes: 6 additions & 0 deletions lib/types/api.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,10 @@ export type PageExtensionSDK = Omit<BaseExtensionSDK, 'ids'> & {
ids: Omit<IdsAPI, EntryScopedIds>
}

export type HomeExtensionSDK = Omit<BaseExtensionSDK, 'ids'> & {
ids: Omit<IdsAPI, EntryScopedIds>
}

export type AppExtensionSDK = Omit<BaseExtensionSDK, 'ids'> & {
/** A set of IDs actual for the app */
ids: Omit<IdsAPI, EntryScopedIds | 'extension' | 'app'> & { app: string }
Expand All @@ -245,6 +249,7 @@ export type KnownSDK =
| EditorExtensionSDK
| PageExtensionSDK
| AppExtensionSDK
| HomeExtensionSDK

export interface Locations {
LOCATION_ENTRY_FIELD: 'entry-field'
Expand All @@ -253,6 +258,7 @@ export interface Locations {
LOCATION_DIALOG: 'dialog'
LOCATION_ENTRY_EDITOR: 'entry-editor'
LOCATION_PAGE: 'page'
LOCATION_HOME: 'home'
LOCATION_APP_CONFIG: 'app-config'
}

Expand Down
1 change: 1 addition & 0 deletions lib/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export type {
EditorExtensionSDK,
EditorLocaleSettings,
FieldExtensionSDK,
HomeExtensionSDK,
IdsAPI,
KnownSDK,
LocalesAPI,
Expand Down
12 changes: 12 additions & 0 deletions test/unit/api.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,18 @@ describe('createAPI()', () => {
test(expected, locations.LOCATION_DIALOG)
})

it('returns correct shape of the home API (home)', () => {
const expected = []

test(expected, locations.LOCATION_HOME)
})

it('returns correct shape of the page API (page)', () => {
const expected = []

test(expected, locations.LOCATION_PAGE)
})

it('returns correct shape of the app API (app)', () => {
const expected = ['app']

Expand Down

0 comments on commit 527ad19

Please sign in to comment.