mirror of
https://github.com/hcengineering/platform.git
synced 2024-11-26 04:23:58 +03:00
introduce "contributing" client
Signed-off-by: Andrey Platov <andrey@hardcoreeng.com>
This commit is contained in:
parent
fd6c4064c1
commit
d764d18a4a
@ -10,6 +10,7 @@ specifiers:
|
||||
'@rush-temp/client-resources': file:./projects/client-resources.tgz
|
||||
'@rush-temp/contact': file:./projects/contact.tgz
|
||||
'@rush-temp/contact-resources': file:./projects/contact-resources.tgz
|
||||
'@rush-temp/contrib': file:./projects/contrib.tgz
|
||||
'@rush-temp/core': file:./projects/core.tgz
|
||||
'@rush-temp/dev-account': file:./projects/dev-account.tgz
|
||||
'@rush-temp/dev-client-resources': file:./projects/dev-client-resources.tgz
|
||||
@ -124,6 +125,7 @@ dependencies:
|
||||
'@rush-temp/client-resources': file:projects/client-resources.tgz_6c259fadfeb3a4b20890aefe87070b8b
|
||||
'@rush-temp/contact': file:projects/contact.tgz_6c259fadfeb3a4b20890aefe87070b8b
|
||||
'@rush-temp/contact-resources': file:projects/contact-resources.tgz_c38cf1a7a413db8918b0b4754c21e4c5
|
||||
'@rush-temp/contrib': file:projects/contrib.tgz_6c259fadfeb3a4b20890aefe87070b8b
|
||||
'@rush-temp/core': file:projects/core.tgz_6c259fadfeb3a4b20890aefe87070b8b
|
||||
'@rush-temp/dev-account': file:projects/dev-account.tgz_6c259fadfeb3a4b20890aefe87070b8b
|
||||
'@rush-temp/dev-client-resources': file:projects/dev-client-resources.tgz_6c259fadfeb3a4b20890aefe87070b8b
|
||||
@ -8662,6 +8664,19 @@ packages:
|
||||
optional: true
|
||||
dev: false
|
||||
|
||||
/ws/8.2.0:
|
||||
resolution: {integrity: sha512-uYhVJ/m9oXwEI04iIVmgLmugh2qrZihkywG9y5FfZV2ATeLIzHf93qs+tUNqlttbQK957/VX3mtwAS+UfIwA4g==}
|
||||
engines: {node: '>=10.0.0'}
|
||||
peerDependencies:
|
||||
bufferutil: ^4.0.1
|
||||
utf-8-validate: ^5.0.2
|
||||
peerDependenciesMeta:
|
||||
bufferutil:
|
||||
optional: true
|
||||
utf-8-validate:
|
||||
optional: true
|
||||
dev: false
|
||||
|
||||
/xml-name-validator/3.0.0:
|
||||
resolution: {integrity: sha512-A5CUptxDsvxKJEU3yO6DuWBSJz/qizqzJKOMIfUJHETbBw/sFaDxgd6fxm1ewUaM0jZ444Fc5vC5ROYurg/4Pw==}
|
||||
dev: false
|
||||
@ -8887,6 +8902,29 @@ packages:
|
||||
- typescript
|
||||
dev: false
|
||||
|
||||
file:projects/contrib.tgz_6c259fadfeb3a4b20890aefe87070b8b:
|
||||
resolution: {integrity: sha512-TRDsaFqjTSL/z6QaCR7OY5xKYJlr936zX/c4ODZRBDSU3CH4wcpbux4ZW2p5wIbCGdx8r/p2CBjXjOj73xnrgQ==, tarball: file:projects/contrib.tgz}
|
||||
id: file:projects/contrib.tgz
|
||||
name: '@rush-temp/contrib'
|
||||
version: 0.0.0
|
||||
dependencies:
|
||||
'@types/heft-jest': 1.0.2
|
||||
'@types/node': 16.7.1
|
||||
'@types/ws': 7.4.7
|
||||
'@typescript-eslint/eslint-plugin': 4.28.5_a8e83fcad666e1ba86be4b2e27a20aea
|
||||
eslint: 7.32.0
|
||||
eslint-plugin-import: 2.23.4_eslint@7.32.0
|
||||
eslint-plugin-node: 11.1.0_eslint@7.32.0
|
||||
eslint-plugin-promise: 4.3.1
|
||||
ws: 8.2.0
|
||||
transitivePeerDependencies:
|
||||
- '@typescript-eslint/parser'
|
||||
- bufferutil
|
||||
- supports-color
|
||||
- typescript
|
||||
- utf-8-validate
|
||||
dev: false
|
||||
|
||||
file:projects/core.tgz_6c259fadfeb3a4b20890aefe87070b8b:
|
||||
resolution: {integrity: sha512-fWkoCr8TR72MHkEELoLb1Gb1qp+mSrXOa0TlBvE4pPBdJ8nH1T96tmJ+1NYe3t2Q2PkZ/RueIqNrmgP5ky589A==, tarball: file:projects/core.tgz}
|
||||
id: file:projects/core.tgz
|
||||
@ -9005,7 +9043,7 @@ packages:
|
||||
dev: false
|
||||
|
||||
file:projects/elastic.tgz_6c259fadfeb3a4b20890aefe87070b8b:
|
||||
resolution: {integrity: sha512-ywnrb5JlC7rhYSRd+y+/YNf4qa61yvKdCuNb/ziAhTvk12tMUjUP/Hsek+HU2G74wsnF9CPq485JMfPmj+yWXQ==, tarball: file:projects/elastic.tgz}
|
||||
resolution: {integrity: sha512-uoPGQmOAopNC8F64rYWrRDU1s3/u70CNQeBYz7EH/PE6mR0QsYIFJW3U6/LgeDWsMXNge+5fKkjwAJh0+EQtBA==, tarball: file:projects/elastic.tgz}
|
||||
id: file:projects/elastic.tgz
|
||||
name: '@rush-temp/elastic'
|
||||
version: 0.0.0
|
||||
@ -9555,7 +9593,7 @@ packages:
|
||||
dev: false
|
||||
|
||||
file:projects/server-ws.tgz_6c259fadfeb3a4b20890aefe87070b8b:
|
||||
resolution: {integrity: sha512-H1VGzXhd0bwjhPTgLipWT8+qeWPDN2cjTXLKy1dClGYuoeqBe2m9udt4hJU8DVvZn5Y8sPZcUcwSOMrjfYf+nQ==, tarball: file:projects/server-ws.tgz}
|
||||
resolution: {integrity: sha512-D4Gk6WhLEC6JSfzT/shF0G6me10SIGRK5UVtBN2t+Z/mi15VcGegrKDV0Q4yuQkfLYX1jSYJwok948W/3kyRtw==, tarball: file:projects/server-ws.tgz}
|
||||
id: file:projects/server-ws.tgz
|
||||
name: '@rush-temp/server-ws'
|
||||
version: 0.0.0
|
||||
@ -9570,7 +9608,7 @@ packages:
|
||||
eslint-plugin-promise: 4.3.1
|
||||
jwt-simple: 0.5.6
|
||||
winston: 3.3.3
|
||||
ws: 8.0.0
|
||||
ws: 8.2.0
|
||||
transitivePeerDependencies:
|
||||
- '@typescript-eslint/parser'
|
||||
- bufferutil
|
||||
|
@ -731,5 +731,10 @@
|
||||
"projectFolder": "server/workspace",
|
||||
"shouldPublish": true
|
||||
},
|
||||
{
|
||||
"packageName": "@anticrm/contrib",
|
||||
"projectFolder": "server/contrib",
|
||||
"shouldPublish": true
|
||||
},
|
||||
]
|
||||
}
|
||||
|
6
server/contrib/.eslintrc.js
Normal file
6
server/contrib/.eslintrc.js
Normal file
@ -0,0 +1,6 @@
|
||||
module.exports = {
|
||||
extends: ['./node_modules/@anticrm/platform-rig/profiles/default/config/eslint.config.json'],
|
||||
parserOptions: {
|
||||
project: './tsconfig.json'
|
||||
}
|
||||
}
|
4
server/contrib/.npmignore
Normal file
4
server/contrib/.npmignore
Normal file
@ -0,0 +1,4 @@
|
||||
*
|
||||
!/lib/**
|
||||
!CHANGELOG.md
|
||||
/lib/**/__tests__/
|
18
server/contrib/config/rig.json
Normal file
18
server/contrib/config/rig.json
Normal file
@ -0,0 +1,18 @@
|
||||
// The "rig.json" file directs tools to look for their config files in an external package.
|
||||
// Documentation for this system: https://www.npmjs.com/package/@rushstack/rig-package
|
||||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/rig-package/rig.schema.json",
|
||||
|
||||
/**
|
||||
* (Required) The name of the rig package to inherit from.
|
||||
* It should be an NPM package name with the "-rig" suffix.
|
||||
*/
|
||||
"rigPackageName": "@anticrm/platform-rig"
|
||||
|
||||
/**
|
||||
* (Optional) Selects a config profile from the rig package. The name must consist of
|
||||
* lowercase alphanumeric words separated by hyphens, for example "sample-profile".
|
||||
* If omitted, then the "default" profile will be used."
|
||||
*/
|
||||
// "rigProfile": "your-profile-name"
|
||||
}
|
27
server/contrib/package.json
Normal file
27
server/contrib/package.json
Normal file
@ -0,0 +1,27 @@
|
||||
{
|
||||
"name": "@anticrm/contrib",
|
||||
"version": "0.6.0",
|
||||
"main": "lib/index.js",
|
||||
"author": "Anticrm Platform Contributors",
|
||||
"license": "EPL-2.0",
|
||||
"scripts": {
|
||||
"build": "heft build",
|
||||
"lint:fix": "eslint --fix src"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@anticrm/platform-rig":"~0.6.0",
|
||||
"@types/heft-jest":"^1.0.2",
|
||||
"@types/node": "^16.4.10",
|
||||
"@typescript-eslint/eslint-plugin":"4",
|
||||
"eslint-plugin-import":"2",
|
||||
"eslint-plugin-promise":"4",
|
||||
"eslint-plugin-node":"11",
|
||||
"eslint":"^7.32.0",
|
||||
"@types/ws":"^7.4.7"
|
||||
},
|
||||
"dependencies": {
|
||||
"@anticrm/core": "~0.6.11",
|
||||
"@anticrm/platform": "~0.6.5",
|
||||
"ws": "^8.2.0"
|
||||
}
|
||||
}
|
51
server/contrib/src/connection.ts
Normal file
51
server/contrib/src/connection.ts
Normal file
@ -0,0 +1,51 @@
|
||||
//
|
||||
// Copyright © 2020, 2021 Anticrm Platform Contributors.
|
||||
// Copyright © 2021 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 { Tx, WithTx } from '@anticrm/core'
|
||||
import { serialize } from '@anticrm/platform'
|
||||
import WebSocket from 'ws'
|
||||
|
||||
/**
|
||||
* @public
|
||||
*/
|
||||
export class ContributingClient implements WithTx {
|
||||
constructor (private readonly websocket: WebSocket) {
|
||||
}
|
||||
|
||||
async tx (tx: Tx): Promise<void> {
|
||||
this.websocket.send(serialize({
|
||||
method: 'tx',
|
||||
params: [tx]
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @public
|
||||
* @param url -
|
||||
* @returns
|
||||
*/
|
||||
export async function createContributingClient (url: string): Promise<ContributingClient> {
|
||||
return await new Promise((resolve, reject) => {
|
||||
const websocket = new WebSocket(url)
|
||||
websocket.on('open', () => {
|
||||
resolve(new ContributingClient(websocket))
|
||||
})
|
||||
websocket.on('error', (err) => {
|
||||
reject(err)
|
||||
})
|
||||
})
|
||||
}
|
17
server/contrib/src/index.ts
Normal file
17
server/contrib/src/index.ts
Normal file
@ -0,0 +1,17 @@
|
||||
//
|
||||
// Copyright © 2020, 2021 Anticrm Platform Contributors.
|
||||
// Copyright © 2021 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.
|
||||
//
|
||||
|
||||
export * from './connection'
|
10
server/contrib/tsconfig.json
Normal file
10
server/contrib/tsconfig.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"extends": "./node_modules/@anticrm/platform-rig/profiles/default/tsconfig.json",
|
||||
|
||||
"compilerOptions": {
|
||||
"target": "ES2019",
|
||||
"rootDir": "./src",
|
||||
"outDir": "./lib",
|
||||
"esModuleInterop": true
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user