Skip to content

Commit

Permalink
Add v2 models, adapters, and serializers
Browse files Browse the repository at this point in the history
  • Loading branch information
brianjgeiger committed Nov 7, 2023
1 parent ffb16e4 commit 0c41c31
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('string') profileUrl?: string;
@attr('string') 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') external_account_id!: string;
@attr('string') folder_id?: string;
@attr('string') folder_path?: 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 0c41c31

Please sign in to comment.