-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ENG-4688] Addon service models (#2048)
* Add config variable for new addon service * WIP models for addon service * More WIP models * WIP * Remove unneeded model
- Loading branch information
1 parent
c8c2ed9
commit 81d0846
Showing
18 changed files
with
221 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import JSONAPIAdapter from '@ember-data/adapter/json-api'; | ||
import config from 'ember-osf-web/config/environment'; | ||
|
||
const addonServiceUrl = config.OSF.url; | ||
|
||
export default class AddonServiceAdapter extends JSONAPIAdapter { | ||
host = addonServiceUrl.replace(/\/$/, ''); // Remove trailing slash to avoid // in URLs | ||
// TODO: namespace?? | ||
} |
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,10 @@ | ||
import AddonServiceAdapter from './addon-service'; | ||
|
||
export default class AuthorizedStorageAccountAdapter extends AddonServiceAdapter { | ||
} | ||
|
||
declare module 'ember-data/types/registries/adapter' { | ||
export default interface AdapterRegistry { | ||
'authorized-storage-account': AuthorizedStorageAccountAdapter; | ||
} // eslint-disable-line semi | ||
} |
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,10 @@ | ||
import AddonServiceAdapter from './addon-service'; | ||
|
||
export default class ConfiguredStorageAddonAdapter extends AddonServiceAdapter { | ||
} | ||
|
||
declare module 'ember-data/types/registries/adapter' { | ||
export default interface AdapterRegistry { | ||
'configured-storage-addon': ConfiguredStorageAddonAdapter; | ||
} // eslint-disable-line semi | ||
} |
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,10 @@ | ||
import AddonServiceAdapter from './addon-service'; | ||
|
||
export default class OsfResourceAdapter extends AddonServiceAdapter { | ||
} | ||
|
||
declare module 'ember-data/types/registries/adapter' { | ||
export default interface AdapterRegistry { | ||
'osf-resource': OsfResourceAdapter; | ||
} // eslint-disable-line semi | ||
} |
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,10 @@ | ||
import AddonServiceAdapter from './addon-service'; | ||
|
||
export default class OsfUserAdapter extends AddonServiceAdapter { | ||
} | ||
|
||
declare module 'ember-data/types/registries/adapter' { | ||
export default interface AdapterRegistry { | ||
'osf-user': OsfUserAdapter; | ||
} // eslint-disable-line semi | ||
} |
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,13 @@ | ||
import AddonServiceAdapter from './addon-service'; | ||
|
||
export default class StorageAddonProviderAdapter extends AddonServiceAdapter { | ||
pathForType() { | ||
return 'storage_providers'; | ||
} | ||
} | ||
|
||
declare module 'ember-data/types/registries/adapter' { | ||
export default interface AdapterRegistry { | ||
'storage-addon-provider': StorageAddonProviderAdapter; | ||
} // eslint-disable-line semi | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { AsyncBelongsTo, attr, belongsTo } from '@ember-data/model'; | ||
|
||
import OsfUserModel from './osf-user'; | ||
import OsfModel from './osf-model'; | ||
|
||
export default class AuthorizedStorageAccountModel extends OsfModel { | ||
@attr('fixstring') storageProvider!: string; | ||
@attr('fixstring') externalUserId!: string; | ||
@attr('fixstring') externalUserDisplayName!: string; | ||
@attr('fixstringarray') scopes!: string[]; | ||
@attr('fixstring') defaultRootFolder!: string; | ||
|
||
@belongsTo('osf-user', { inverse: 'authorizedStorageAccounts' }) | ||
configuringUser!: AsyncBelongsTo<OsfUserModel> & OsfUserModel; | ||
} | ||
|
||
declare module 'ember-data/types/registries/model' { | ||
export default interface ModelRegistry { | ||
'authorized-storage-account': AuthorizedStorageAccountModel; | ||
} // eslint-disable-line semi | ||
} |
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,28 @@ | ||
import { AsyncBelongsTo, attr, belongsTo } from '@ember-data/model'; | ||
import OsfResourceModel from 'ember-osf-web/models/osf-resource'; | ||
import OsfUserModel from 'ember-osf-web/models/osf-user'; | ||
|
||
import OsfModel from './osf-model'; | ||
import AuthorizedStorageAccountModel from './authorized-storage-account'; | ||
|
||
export default class ConfiguredStorageAddonModel extends OsfModel { | ||
@attr('fixstring') storageProvider!: string; | ||
@attr('fixstring') externalUserId!: string; | ||
@attr('fixstring') externalUserDisplayName!: string; | ||
@attr('fixstring') rootFolder!: string; | ||
|
||
@belongsTo('osf-user', { inverse: 'configuredResources' }) | ||
accountOwner!: AsyncBelongsTo<OsfUserModel> & OsfUserModel; | ||
|
||
@belongsTo('osf-resource', { inverse: 'configuredStorageAddons' }) | ||
authorizedResource!: AsyncBelongsTo<OsfResourceModel> & OsfResourceModel; | ||
|
||
@belongsTo('authorized-storage-account') | ||
baseAccount!: AsyncBelongsTo<AuthorizedStorageAccountModel> & AuthorizedStorageAccountModel; | ||
} | ||
|
||
declare module 'ember-data/types/registries/model' { | ||
export default interface ModelRegistry { | ||
'configured-storage-addon': ConfiguredStorageAddonModel; | ||
} // eslint-disable-line semi | ||
} |
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 { AsyncHasMany, hasMany } from '@ember-data/model'; | ||
|
||
import OsfModel from './osf-model'; | ||
import ConfiguredStorageAccountModel from './configured-storage-addon'; | ||
|
||
export default class OsfResourceModel extends OsfModel { | ||
@hasMany('configured-storage-account', { inverse: 'authorizedResource' }) | ||
configuredStorageAddons!: AsyncHasMany<ConfiguredStorageAccountModel> & ConfiguredStorageAccountModel[]; | ||
} | ||
|
||
declare module 'ember-data/types/registries/model' { | ||
export default interface ModelRegistry { | ||
'osf-resource': OsfResourceModel; | ||
} // eslint-disable-line semi | ||
} |
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,19 @@ | ||
import { AsyncHasMany, hasMany } from '@ember-data/model'; | ||
|
||
import AuthorizedStorageAccountModel from './authorized-storage-account'; | ||
import OsfResourceModel from './osf-resource'; | ||
import OsfModel from './osf-model'; | ||
|
||
export default class OsfUserModel extends OsfModel { | ||
@hasMany('authorized-storage-account', { inverse: 'configuringUser' }) | ||
authorizedStorageAccounts!: AsyncHasMany<AuthorizedStorageAccountModel> & AuthorizedStorageAccountModel[]; | ||
|
||
@hasMany('osf-resource') | ||
configuredResources!: AsyncHasMany<OsfResourceModel> & OsfResourceModel[]; | ||
} | ||
|
||
declare module 'ember-data/types/registries/model' { | ||
export default interface ModelRegistry { | ||
'osf-user': OsfUserModel; | ||
} // eslint-disable-line semi | ||
} |
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,22 @@ | ||
import { attr } from '@ember-data/model'; | ||
|
||
import OsfModel from './osf-model'; | ||
|
||
export default class StorageAddonProviderModel extends OsfModel { | ||
@attr('fixstring') name!: string; | ||
@attr('fixstring') iconUri!: string; | ||
@attr('fixstring') authUri!: string; | ||
@attr('boolean') readOnly!: boolean; | ||
@attr('boolean') supportsCopy!: boolean; | ||
@attr('boolean') supportsUserSpecifiedRootFolder!: boolean; | ||
@attr('boolean') supportsFileVersioning!: boolean; | ||
@attr('boolean') supportsBulkDownload!: boolean; | ||
@attr('number') maxConcurrentDownloads!: number; | ||
@attr('number') maxUploadMb!: number; | ||
} | ||
|
||
declare module 'ember-data/types/registries/model' { | ||
export default interface ModelRegistry { | ||
'storage-addon-provider': StorageAddonProviderModel; | ||
} // eslint-disable-line semi | ||
} |
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,10 @@ | ||
import OsfSerializer from './osf-serializer'; | ||
|
||
export default class AuthorizedStorageAccountSerializer extends OsfSerializer { | ||
} | ||
|
||
declare module 'ember-data/types/registries/serializer' { | ||
export default interface SerializerRegistry { | ||
'authorized-storage-account': AuthorizedStorageAccountSerializer; | ||
} // eslint-disable-line semi | ||
} |
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,10 @@ | ||
import OsfSerializer from './osf-serializer'; | ||
|
||
export default class ConfiguredStorageAddonSerializer extends OsfSerializer { | ||
} | ||
|
||
declare module 'ember-data/types/registries/serializer' { | ||
export default interface SerializerRegistry { | ||
'configured-storage-addon': ConfiguredStorageAddonSerializer; | ||
} // eslint-disable-line semi | ||
} |
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,10 @@ | ||
import OsfSerializer from './osf-serializer'; | ||
|
||
export default class OsfResourceSerializer extends OsfSerializer { | ||
} | ||
|
||
declare module 'ember-data/types/registries/serializer' { | ||
export default interface SerializerRegistry { | ||
'osf-resource': OsfResourceSerializer; | ||
} // eslint-disable-line semi | ||
} |
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,10 @@ | ||
import OsfSerializer from './osf-serializer'; | ||
|
||
export default class OsfUserSerializer extends OsfSerializer { | ||
} | ||
|
||
declare module 'ember-data/types/registries/serializer' { | ||
export default interface SerializerRegistry { | ||
'osf-user': OsfUserSerializer; | ||
} // eslint-disable-line semi | ||
} |
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,10 @@ | ||
import OsfSerializer from './osf-serializer'; | ||
|
||
export default class StorageAddonProviderSerializer extends OsfSerializer { | ||
} | ||
|
||
declare module 'ember-data/types/registries/serializer' { | ||
export default interface SerializerRegistry { | ||
'storage-addon-provider': StorageAddonProviderSerializer; | ||
} // eslint-disable-line semi | ||
} |
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