Просмотр исходного кода

move external account interfaces to growi core

ryoji-s 2 лет назад
Родитель
Сommit
752fe7748b

+ 1 - 1
apps/app/src/components/Me/DisassociateModal.tsx

@@ -1,5 +1,6 @@
 import React, { useCallback } from 'react';
 import React, { useCallback } from 'react';
 
 
+import type { IExternalAccount } from '@growi/core';
 import { useTranslation } from 'next-i18next';
 import { useTranslation } from 'next-i18next';
 import {
 import {
   Modal,
   Modal,
@@ -9,7 +10,6 @@ import {
 } from 'reactstrap';
 } from 'reactstrap';
 
 
 import { toastSuccess, toastError } from '~/client/util/toastr';
 import { toastSuccess, toastError } from '~/client/util/toastr';
-import { IExternalAccount } from '~/interfaces/external-account';
 import { usePersonalSettings, useSWRxPersonalExternalAccounts } from '~/stores/personal-settings';
 import { usePersonalSettings, useSWRxPersonalExternalAccounts } from '~/stores/personal-settings';
 
 
 type Props = {
 type Props = {

+ 3 - 8
apps/app/src/features/questionnaire/interfaces/growi-info.ts

@@ -1,5 +1,7 @@
 import * as os from 'node:os';
 import * as os from 'node:os';
 
 
+import type { IExternalAuthProviderType } from '@growi/core';
+
 export const GrowiServiceType = {
 export const GrowiServiceType = {
   cloud: 'cloud',
   cloud: 'cloud',
   privateCloud: 'private-cloud',
   privateCloud: 'private-cloud',
@@ -23,19 +25,12 @@ export const GrowiDeploymentType = {
   node: 'node',
   node: 'node',
   others: 'others',
   others: 'others',
 } as const;
 } as const;
-export const GrowiExternalAuthProviderType = {
-  ldap: 'ldap',
-  saml: 'saml',
-  oicd: 'oidc',
-  google: 'google',
-  github: 'github',
-} as const;
 
 
 export type GrowiServiceType = typeof GrowiServiceType[keyof typeof GrowiServiceType]
 export type GrowiServiceType = typeof GrowiServiceType[keyof typeof GrowiServiceType]
 type GrowiWikiType = typeof GrowiWikiType[keyof typeof GrowiWikiType]
 type GrowiWikiType = typeof GrowiWikiType[keyof typeof GrowiWikiType]
 export type GrowiAttachmentType = typeof GrowiAttachmentType[keyof typeof GrowiAttachmentType]
 export type GrowiAttachmentType = typeof GrowiAttachmentType[keyof typeof GrowiAttachmentType]
 export type GrowiDeploymentType = typeof GrowiDeploymentType[keyof typeof GrowiDeploymentType]
 export type GrowiDeploymentType = typeof GrowiDeploymentType[keyof typeof GrowiDeploymentType]
-export type GrowiExternalAuthProviderType = typeof GrowiExternalAuthProviderType[keyof typeof GrowiExternalAuthProviderType]
+export type GrowiExternalAuthProviderType = IExternalAuthProviderType
 
 
 interface IGrowiOSInfo {
 interface IGrowiOSInfo {
   type?: ReturnType<typeof os.type>
   type?: ReturnType<typeof os.type>

+ 0 - 11
apps/app/src/interfaces/external-account.ts

@@ -1,11 +0,0 @@
-import { Ref } from '@growi/core';
-
-import { IUser } from '~/interfaces/user';
-
-
-export type IExternalAccount<ID = string> = {
-  _id: ID,
-  providerType: string,
-  accountId: string,
-  user: Ref<IUser>,
-}

+ 2 - 3
apps/app/src/stores/personal-settings.tsx

@@ -1,8 +1,7 @@
-import { ErrorV3 } from '@growi/core';
+import type { IExternalAccount, IExternalAuthProviderType } from '@growi/core';
 import { useTranslation } from 'next-i18next';
 import { useTranslation } from 'next-i18next';
 import useSWR, { SWRConfiguration, SWRResponse } from 'swr';
 import useSWR, { SWRConfiguration, SWRResponse } from 'swr';
 
 
-import { IExternalAccount } from '~/interfaces/external-account';
 import { IUser } from '~/interfaces/user';
 import { IUser } from '~/interfaces/user';
 import { useIsGuestUser } from '~/stores/context';
 import { useIsGuestUser } from '~/stores/context';
 import loggerFactory from '~/utils/logger';
 import loggerFactory from '~/utils/logger';
@@ -31,7 +30,7 @@ export type IPersonalSettingsInfoOption = {
   sync: () => void,
   sync: () => void,
   updateBasicInfo: () => Promise<void>,
   updateBasicInfo: () => Promise<void>,
   associateLdapAccount: (account: { username: string, password: string }) => Promise<void>,
   associateLdapAccount: (account: { username: string, password: string }) => Promise<void>,
-  disassociateLdapAccount: (account: { providerType: string, accountId: string }) => Promise<void>,
+  disassociateLdapAccount: (account: { providerType: IExternalAuthProviderType, accountId: string }) => Promise<void>,
 }
 }
 
 
 export const usePersonalSettings = (config?: SWRConfiguration): SWRResponse<IUser, Error> & IPersonalSettingsInfoOption => {
 export const usePersonalSettings = (config?: SWRConfiguration): SWRResponse<IUser, Error> & IPersonalSettingsInfoOption => {

+ 19 - 0
packages/core/src/interfaces/external-account.ts

@@ -0,0 +1,19 @@
+import type { Ref } from './common';
+import type { IUser } from './user';
+
+export const IExternalAuthProviderType = {
+  ldap: 'ldap',
+  saml: 'saml',
+  oicd: 'oidc',
+  google: 'google',
+  github: 'github',
+} as const;
+
+export type IExternalAuthProviderType = typeof IExternalAuthProviderType[keyof typeof IExternalAuthProviderType]
+
+export type IExternalAccount<ID = string> = {
+  _id: ID,
+  providerType: IExternalAuthProviderType,
+  accountId: string,
+  user: Ref<IUser>,
+}

+ 1 - 0
packages/core/src/interfaces/index.ts

@@ -1,6 +1,7 @@
 export * from './attachment';
 export * from './attachment';
 export * from './color-scheme';
 export * from './color-scheme';
 export * from './common';
 export * from './common';
+export * from './external-account';
 export * from './growi-facade';
 export * from './growi-facade';
 export * from './growi-theme-metadata';
 export * from './growi-theme-metadata';
 export * from './has-object-id';
 export * from './has-object-id';

+ 2 - 1
packages/core/src/interfaces/user.ts

@@ -1,5 +1,6 @@
 import type { IAttachment } from './attachment';
 import type { IAttachment } from './attachment';
 import type { Ref } from './common';
 import type { Ref } from './common';
+import type { IExternalAuthProviderType } from './external-account';
 import type { HasObjectId } from './has-object-id';
 import type { HasObjectId } from './has-object-id';
 import type { Lang } from './lang';
 import type { Lang } from './lang';
 
 
@@ -54,7 +55,7 @@ export type IUserGroupRelationHasId = IUserGroupRelation & HasObjectId;
 
 
 export type IAdminExternalAccount = {
 export type IAdminExternalAccount = {
   _id: string,
   _id: string,
-  providerType: string,
+  providerType: IExternalAuthProviderType,
   accountId: string,
   accountId: string,
   user: IUser,
   user: IUser,
   createdAt: Date,
   createdAt: Date,