-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Extract storage client #8860
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
kristina-fefelova
wants to merge
1
commit into
develop
Choose a base branch
from
extract-storage-api
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Extract storage client #8860
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,7 @@ | ||
module.exports = { | ||
extends: ['./node_modules/@hcengineering/platform-rig/profiles/default/eslint.config.json'], | ||
parserOptions: { | ||
tsconfigRootDir: __dirname, | ||
project: './tsconfig.json' | ||
} | ||
} |
This file contains hidden or 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,4 @@ | ||
* | ||
!/lib/** | ||
!CHANGELOG.md | ||
/lib/**/__tests__/ |
This file contains hidden or 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,11 @@ | ||
# Huly Storage API Client | ||
|
||
A TypeScript client library for interacting with the Huly Storage API. | ||
|
||
## Installation | ||
|
||
In order to be able to install required packages, you will need to obtain GitHub access token. You can create a token by following the instructions [here](https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry#authenticating-with-a-personal-access-token). | ||
|
||
```bash | ||
npm install @hcengineering/stotage-client | ||
``` |
This file contains hidden or 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,4 @@ | ||
{ | ||
"$schema": "https://developer.microsoft.com/json-schemas/rig-package/rig.schema.json", | ||
"rigPackageName": "@hcengineering/platform-rig" | ||
} |
This file contains hidden or 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,7 @@ | ||
module.exports = { | ||
preset: 'ts-jest', | ||
testEnvironment: 'node', | ||
testMatch: ['**/?(*.)+(spec|test).[jt]s?(x)'], | ||
roots: ["./src"], | ||
coverageReporters: ["text-summary", "html"] | ||
} |
This file contains hidden or 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,61 @@ | ||
{ | ||
"name": "@hcengineering/storage-client", | ||
"version": "0.6.0", | ||
"main": "lib/index.js", | ||
"exports": { | ||
".": { | ||
"types": "./types/index.d.ts", | ||
"require": "./lib/index.js", | ||
"import": "./lib/index.js" | ||
} | ||
}, | ||
"svelte": "src/index.ts", | ||
"types": "types/index.d.ts", | ||
"files": [ | ||
"lib/**/*", | ||
"types/**/*", | ||
"tsconfig.json" | ||
], | ||
"author": "Anticrm Platform Contributors", | ||
"template": "@hcengineering/api-package", | ||
"license": "EPL-2.0", | ||
"scripts": { | ||
"build": "compile", | ||
"build:watch": "compile", | ||
"test": "jest --passWithNoTests --silent", | ||
"format": "format src", | ||
"_phase:build": "compile transpile src", | ||
"_phase:test": "jest --passWithNoTests --silent", | ||
"_phase:format": "format src", | ||
"_phase:validate": "compile validate" | ||
}, | ||
"devDependencies": { | ||
"@hcengineering/platform-rig": "^0.6.0", | ||
"@typescript-eslint/eslint-plugin": "^6.11.0", | ||
"eslint-plugin-import": "^2.26.0", | ||
"eslint-plugin-promise": "^6.1.1", | ||
"eslint-plugin-n": "^15.4.0", | ||
"eslint": "^8.54.0", | ||
"simplytyped": "^3.3.0", | ||
"@typescript-eslint/parser": "^6.11.0", | ||
"eslint-config-standard-with-typescript": "^40.0.0", | ||
"prettier": "^3.1.0", | ||
"typescript": "^5.3.3", | ||
"jest": "^29.7.0", | ||
"ts-jest": "^29.1.1", | ||
"ts-node": "^10.8.0", | ||
"@types/node": "~20.11.16", | ||
"@types/jest": "^29.5.5", | ||
"@types/node-fetch": "~2.6.2" | ||
}, | ||
"dependencies": { | ||
"@hcengineering/account-client": "^0.6.0", | ||
"@hcengineering/core": "^0.6.32", | ||
"form-data": "^4.0.0", | ||
"node-fetch": "^2.6.6" | ||
}, | ||
"repository": "https://github.com/hcengineering/platform", | ||
"publishConfig": { | ||
"registry": "https://npm.pkg.github.com" | ||
} | ||
} |
This file contains hidden or 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 hidden or 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,29 @@ | ||
// Copyright © 2025 Hardcore Engineering Inc. | ||
// | ||
// Licensed under the Eclipse Public License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. You may | ||
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
import { concatLink } from '@hcengineering/core' | ||
|
||
export interface ServerConfig { | ||
ACCOUNTS_URL: string | ||
FILES_URL: string | ||
UPLOAD_URL: string | ||
} | ||
|
||
export async function loadServerConfig (url: string): Promise<ServerConfig> { | ||
const configUrl = concatLink(url, '/config.json') | ||
const res = await fetch(configUrl, { keepalive: true }) | ||
if (res.ok) { | ||
return (await res.json()) as ServerConfig | ||
} | ||
throw new Error('Failed to fetch config') | ||
} |
File renamed without changes.
This file contains hidden or 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 hidden or 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 hidden or 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,53 @@ | ||
// Copyright © 2025 Hardcore Engineering Inc. | ||
// | ||
// Licensed under the Eclipse Public License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. You may | ||
// obtain a copy of the License at https://www.eclipse.org/legal/epl-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
import { type WorkspaceLoginInfo, getClient as getAccountClient } from '@hcengineering/account-client' | ||
import { WorkspaceUuid } from '@hcengineering/core' | ||
import { AuthOptions } from './types' | ||
import { loadServerConfig, ServerConfig } from './config' | ||
|
||
export interface WorkspaceToken { | ||
endpoint: string | ||
token: string | ||
workspaceId: WorkspaceUuid | ||
info: WorkspaceLoginInfo | ||
} | ||
|
||
export async function getWorkspaceToken ( | ||
url: string, | ||
options: AuthOptions, | ||
config?: ServerConfig | ||
): Promise<WorkspaceToken> { | ||
config ??= await loadServerConfig(url) | ||
|
||
let token: string | undefined | ||
|
||
if ('token' in options) { | ||
token = options.token | ||
} else { | ||
const { email, password } = options | ||
const loginInfo = await getAccountClient(config.ACCOUNTS_URL).login(email, password) | ||
token = loginInfo.token | ||
} | ||
|
||
if (token === undefined) { | ||
throw new Error('Login failed') | ||
} | ||
|
||
const ws = await getAccountClient(config.ACCOUNTS_URL, token).selectWorkspace(options.workspace) | ||
if (ws === undefined) { | ||
throw new Error('Workspace not found') | ||
} | ||
|
||
return { endpoint: ws.endpoint, token: ws.token, workspaceId: ws.workspace, info: ws } | ||
} |
This file contains hidden or 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,11 @@ | ||
{ | ||
"extends": "./node_modules/@hcengineering/platform-rig/profiles/default/tsconfig.json", | ||
|
||
"compilerOptions": { | ||
"rootDir": "./src", | ||
"outDir": "./lib", | ||
"declarationDir": "./types", | ||
"tsBuildInfoFile": ".build/build.tsbuildinfo", | ||
"types": ["node", "jest"] | ||
} | ||
} |
This file contains hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo:
stotage
->storage