Skip to content

Commit

Permalink
refactor: remove owncloud-sdk
Browse files Browse the repository at this point in the history
Removed the owncloud-sdk dependency as it's deprecated. It has been replaced by the `web-client` package.
  • Loading branch information
JammingBen committed Mar 26, 2024
1 parent d1154ee commit 30c819e
Show file tree
Hide file tree
Showing 15 changed files with 11 additions and 188 deletions.
3 changes: 0 additions & 3 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
auto-install-peers=true
shared-workspace-lockfile=true

# apps
public-hoist-pattern[]=owncloud-sdk

# @vue/component-compiler-utils
hoist-pattern[]=sass

Expand Down
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<% } %>
<script type="module" src="./packages/web-runtime/src/index.ts"></script>
<script type="module">
// Fix Buffer usage in or indirectly via owncloud-sdk in production (!)
// Fix Buffer usage in production (!)
// If single file downloads work in production after removing this, it can probably be removed permanently
import { Buffer } from "buffer";
window.Buffer = Buffer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,21 +227,8 @@ export default defineComponent({
})
}
const notifyShare = async () => {
try {
const response = await clientService.owncloudSdk.shares.notifyShare(props.share.id)
showMessage({
title: $gettext('Success'),
desc: $gettext('Email reminder sent to %{ recipient }', { recipient: response[0] }),
status: 'success'
})
} catch (error) {
console.error(error)
showErrorMessage({
title: $gettext('An error occurred'),
desc: $gettext('Email notification could not be sent'),
errors: [error]
})
}
// FIXME: cern code
// const response = await clientService.owncloudSdk.shares.notifyShare(props.share.id)
}
return {
Expand Down
81 changes: 0 additions & 81 deletions packages/web-client/src/types.ts

This file was deleted.

2 changes: 0 additions & 2 deletions packages/web-client/src/webdav/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { OwnCloudSdk } from '../types'
import { CreateFolderFactory } from './createFolder'
import { GetFileContentsFactory } from './getFileContents'
import { GetFileInfoFactory } from './getFileInfo'
Expand All @@ -23,7 +22,6 @@ import { SetFavoriteFactory } from './setFavorite'
import { ListFavoriteFilesFactory } from './listFavoriteFiles'

export interface WebDavOptions {
sdk: OwnCloudSdk
accessToken: Ref<string>
baseUrl: string
capabilities: Ref<Capabilities['capabilities']>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export function useAppFileHandling({
return clientService.webdav.revokeUrl(url)
}

// TODO: support query parameters, possibly needs porting away from owncloud-sdk
// TODO: support query parameters
const getFileContents = (
fileContext: MaybeRef<FileContext>,
options: { responseType?: 'arrayBuffer' | 'blob' | 'text' } & Record<string, any>
Expand Down
10 changes: 0 additions & 10 deletions packages/web-pkg/src/services/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { Auth, AuthParameters } from './auth'
import axios, { AxiosInstance } from 'axios'
import { v4 as uuidV4 } from 'uuid'
import { WebDAV } from '@ownclouders/web-client/src/webdav'
import { OwnCloudSdk } from '@ownclouders/web-client/src/types'
import { Language } from 'vue3-gettext'
import { FetchEventSourceInit } from '@microsoft/fetch-event-source'
import { sse } from '@ownclouders/web-client/src/sse'
Expand Down Expand Up @@ -69,7 +68,6 @@ export class ClientService {
private ocUserContextClient: OcClient
private ocPublicLinkContextClient: OcClient

private owncloudSdkClient: OwnCloudSdk
private webdavClient: WebDAV

constructor(options: ClientServiceOptions) {
Expand Down Expand Up @@ -162,14 +160,6 @@ export class ClientService {
)
}

public get owncloudSdk(): OwnCloudSdk {
return this.owncloudSdkClient
}

public set owncloudSdk(owncloudSdk: OwnCloudSdk) {
this.owncloudSdkClient = owncloudSdk
}

public get webdav(): WebDAV {
return this.webdavClient
}
Expand Down
1 change: 0 additions & 1 deletion packages/web-runtime/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
"lodash-es": "^4.17.21",
"luxon": "3.2.1",
"oidc-client-ts": "^2.4.0",
"owncloud-sdk": "3.1.0-alpha.10",
"p-queue": "^6.6.2",
"pinia": "2.1.7",
"portal-vue": "3.0.0",
Expand Down
9 changes: 1 addition & 8 deletions packages/web-runtime/src/container/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { buildApplication, NextApplication } from './application'
import { RouteLocationRaw, Router, RouteRecordNormalized } from 'vue-router'
import { App, computed, watch } from 'vue'
import { loadTheme } from '../helpers/theme'
import OwnCloud from 'owncloud-sdk'
import { createGettext, GetTextOptions, Language } from 'vue3-gettext'
import { getBackendVersion, getWebVersion } from './versions'
import {
Expand Down Expand Up @@ -379,7 +378,7 @@ export const announceAdditionalTranslations = ({
}

/**
* announce clientService and owncloud SDK and inject it into vue
* announce clientService and inject it into vue
*
* @param vue
* @param configStore
Expand All @@ -397,19 +396,14 @@ export const announceClientService = ({
authStore: AuthStore
capabilityStore: CapabilityStore
}): void => {
const sdk = new OwnCloud()
sdk.init({ baseUrl: configStore.serverUrl })
const clientService = new ClientService({
configStore,
language: app.config.globalProperties.$language,
authStore,
userStore
})
app.config.globalProperties.$client = sdk
app.config.globalProperties.$clientService = clientService
app.config.globalProperties.$clientService.owncloudSdk = sdk
app.config.globalProperties.$clientService.webdav = webdav({
sdk,
accessToken: computed(() => authStore.accessToken),
baseUrl: configStore.serverUrl,
capabilities: computed(() => capabilityStore.capabilities),
Expand All @@ -418,7 +412,6 @@ export const announceClientService = ({
user: computed(() => userStore.user)
})

app.provide('$client', sdk)
app.provide('$clientService', clientService)
}

Expand Down
24 changes: 0 additions & 24 deletions packages/web-runtime/src/services/auth/userManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,6 @@ export class UserManager extends OidcUserManager {
return
}

this.initializeOwnCloudSdk(accessToken)

if (this.capabilityStore.supportSSE) {
;(this.clientService.sseAuthenticated as SSEAdapter).updateAccessToken(accessToken)
}
Expand All @@ -179,27 +177,6 @@ export class UserManager extends OidcUserManager {
return this.updateAccessTokenPromise
}

private initializeOwnCloudSdk(accessToken: string): void {
const options: Record<string, unknown> = {
baseUrl: this.configStore.serverUrl,
auth: {
bearer: accessToken
},
headers: {
'Accept-Language': this.language.current
}
}
if (this.userStore.user) {
options.userInfo = {
id: this.userStore.user.onPremisesSamAccountName,
'display-name': this.userStore.user.displayName,
email: this.userStore.user.mail
}
}

this.clientService.owncloudSdk.init(options)
}

private async fetchUserInfo(accessToken: string): Promise<void> {
await this.fetchCapabilities()

Expand All @@ -222,7 +199,6 @@ export class UserManager extends OidcUserManager {
language: this.language,
languageSetting: graphUser.data.preferredLanguage
})
this.initializeOwnCloudSdk(accessToken)
}
}

Expand Down
2 changes: 0 additions & 2 deletions packages/web-test-helpers/src/mocks/defaultComponentMocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
UppyService
} from '../../../web-pkg/src/'
import { Router, RouteLocationNormalizedLoaded, RouteLocationRaw } from 'vue-router'
import { OwnCloudSdk } from '../../../web-client/src/types'
import { ref } from 'vue'

export interface ComponentMocksOptions {
Expand All @@ -28,7 +27,6 @@ export const defaultComponentMocks = ({ currentRoute = undefined }: ComponentMoc
$route,
$clientService: mockDeep<ClientService>(),
$previewService: mockDeep<PreviewService>(),
$client: mockDeep<OwnCloudSdk>(),
$uppyService: mockDeep<UppyService>(),
$loadingService: mock<LoadingService>({
addTask: (callback) => {
Expand Down
37 changes: 4 additions & 33 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion tests/unit/config/vitest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export default defineConfig({
],
alias: {
'vue-inline-svg': `${root}/tests/unit/stubs/empty.ts`,
'owncloud-sdk': `${root}/tests/unit/stubs/empty.ts`,
webfontloader: `${root}/tests/unit/stubs/webfontloader.ts`
},
coverage: {
Expand Down
4 changes: 2 additions & 2 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,10 @@ export default defineConfig(({ mode, command }) => {
crypto: join(projectRootDir, 'polyfills/crypto.js'),
buffer: 'rollup-plugin-node-polyfills/polyfills/buffer-es6',
path: 'rollup-plugin-node-polyfills/polyfills/path',
util: 'rollup-plugin-node-polyfills/polyfills/util',

// owncloud-sdk // sax
// xml-js
stream: 'rollup-plugin-node-polyfills/polyfills/stream',
util: 'rollup-plugin-node-polyfills/polyfills/util',
string_decoder: 'rollup-plugin-node-polyfills/polyfills/string-decoder',
process: 'rollup-plugin-node-polyfills/polyfills/process-es6',
events: 'rollup-plugin-node-polyfills/polyfills/events'
Expand Down
Loading

0 comments on commit 30c819e

Please sign in to comment.