Skip to content

Commit

Permalink
[ENG-4687] Add v2 models, adapters, and serializers (#2045)
Browse files Browse the repository at this point in the history
Purpose

Add models, adapters, and serializers for various v2 endpoints we'll need for addons. Note that some of this does not reflect the BE as it exists today, but is a bit aspirational. That being said, it does not include all the changes we ultimately want, just the ones that are necessary to make this function in a sane manner.

Summary of Changes

Add addon, external-account, node-addon, and user-addon models, adapters, and serializers
  • Loading branch information
brianjgeiger authored Nov 8, 2023
1 parent ffb16e4 commit c8c2ed9
Show file tree
Hide file tree
Showing 12 changed files with 145 additions and 0 deletions.
10 changes: 10 additions & 0 deletions app/adapters/addon.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import OsfAdapter from './osf-adapter';

export default class AddonAdapter extends OsfAdapter {
}

declare module 'ember-data/types/registries/adapter' {
export default interface AdapterRegistry {
addon: AddonAdapter;
} // eslint-disable-line semi
}
10 changes: 10 additions & 0 deletions app/adapters/external-account.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import OsfAdapter from './osf-adapter';

export default class ExternalAccountAdapter extends OsfAdapter {
}

declare module 'ember-data/types/registries/adapter' {
export default interface AdapterRegistry {
'external-account': ExternalAccountAdapter;
} // eslint-disable-line semi
}
10 changes: 10 additions & 0 deletions app/adapters/node-addon.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import OsfAdapter from './osf-adapter';

export default class NodeAddonAdapter extends OsfAdapter {
}

declare module 'ember-data/types/registries/adapter' {
export default interface AdapterRegistry {
'node-addon': NodeAddonAdapter;
} // eslint-disable-line semi
}
10 changes: 10 additions & 0 deletions app/adapters/user-addon.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import OsfAdapter from './osf-adapter';

export default class UserAddonAdapter extends OsfAdapter {
}

declare module 'ember-data/types/registries/adapter' {
export default interface AdapterRegistry {
'user-addon': UserAddonAdapter;
} // eslint-disable-line semi
}
14 changes: 14 additions & 0 deletions app/models/addon.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { attr } from '@ember-data/model';

import OsfModel from './osf-model';

export default class AddonModel extends OsfModel {
@attr('string') name!: string;
@attr('array') categories!: string[];
}

declare module 'ember-data/types/registries/model' {
export default interface ModelRegistry {
addon: AddonModel;
} // eslint-disable-line semi
}
15 changes: 15 additions & 0 deletions app/models/external-accounts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { attr } from '@ember-data/model';

import OsfModel from './osf-model';

export default class ExternalAccountsModel extends OsfModel {
@attr('string') provider!: string;
@attr('fixstring') profileUrl?: string;
@attr('fixstring') displayName!: string;
}

declare module 'ember-data/types/registries/model' {
export default interface ModelRegistry {
'external-account': ExternalAccountsModel;
} // eslint-disable-line semi
}
17 changes: 17 additions & 0 deletions app/models/node-addon.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { attr } from '@ember-data/model';

import OsfModel from './osf-model';

export default class NodeAddonModel extends OsfModel {
@attr('boolean') nodeHasAuth!: boolean;
@attr('boolean') configured!: boolean;
@attr('string') externalAccountId!: string;
@attr('string') folderId?: string;
@attr('string') folderPath?: string;
}

declare module 'ember-data/types/registries/model' {
export default interface ModelRegistry {
'node-addon': NodeAddonModel;
} // eslint-disable-line semi
}
19 changes: 19 additions & 0 deletions app/models/user-addon.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { AsyncHasMany, attr, hasMany } from '@ember-data/model';

import ExternalAccountsModel from 'ember-osf-web/models/external-accounts';

import OsfModel from './osf-model';


export default class UserAddonModel extends OsfModel {
@attr('boolean') userHasAuth!: boolean;

@hasMany('external-accounts', { inverse: null })
externalAccounts!: AsyncHasMany<ExternalAccountsModel> & ExternalAccountsModel[];
}

declare module 'ember-data/types/registries/model' {
export default interface ModelRegistry {
'user-addon': UserAddonModel;
} // eslint-disable-line semi
}
10 changes: 10 additions & 0 deletions app/serializers/addon.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import OsfSerializer from './osf-serializer';

export default class AddonSerializer extends OsfSerializer {
}

declare module 'ember-data/types/registries/serializer' {
export default interface SerializerRegistry {
addon: AddonSerializer;
} // eslint-disable-line semi
}
10 changes: 10 additions & 0 deletions app/serializers/external-account.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import OsfSerializer from './osf-serializer';

export default class ExternalAccountSerializer extends OsfSerializer {
}

declare module 'ember-data/types/registries/serializer' {
export default interface SerializerRegistry {
'external-account': ExternalAccountSerializer;
} // eslint-disable-line semi
}
10 changes: 10 additions & 0 deletions app/serializers/node-addon.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import OsfSerializer from './osf-serializer';

export default class NodeAddonSerializer extends OsfSerializer {
}

declare module 'ember-data/types/registries/serializer' {
export default interface SerializerRegistry {
'node-addon': NodeAddonSerializer;
} // eslint-disable-line semi
}
10 changes: 10 additions & 0 deletions app/serializers/user-addon.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import OsfSerializer from './osf-serializer';

export default class UserAddonSerializer extends OsfSerializer {
}

declare module 'ember-data/types/registries/serializer' {
export default interface SerializerRegistry {
'user-addon': UserAddonSerializer;
} // eslint-disable-line semi
}

0 comments on commit c8c2ed9

Please sign in to comment.