mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-23 00:37:47 +00:00
add dev-client-resources
Signed-off-by: Andrey Platov <andrey@hardcoreeng.com>
This commit is contained in:
parent
5e6544c943
commit
825ade52f7
@ -6,6 +6,7 @@ specifiers:
|
||||
'@rush-temp/client-resources': file:./projects/client-resources.tgz
|
||||
'@rush-temp/contact': file:./projects/contact.tgz
|
||||
'@rush-temp/core': file:./projects/core.tgz
|
||||
'@rush-temp/dev-client-resources': file:./projects/dev-client-resources.tgz
|
||||
'@rush-temp/dev-server': file:./projects/dev-server.tgz
|
||||
'@rush-temp/dev-storage': file:./projects/dev-storage.tgz
|
||||
'@rush-temp/login': file:./projects/login.tgz
|
||||
@ -75,6 +76,7 @@ dependencies:
|
||||
'@rush-temp/client-resources': file:projects/client-resources.tgz_6c259fadfeb3a4b20890aefe87070b8b
|
||||
'@rush-temp/contact': file:projects/contact.tgz_6c259fadfeb3a4b20890aefe87070b8b
|
||||
'@rush-temp/core': file:projects/core.tgz_6c259fadfeb3a4b20890aefe87070b8b
|
||||
'@rush-temp/dev-client-resources': file:projects/dev-client-resources.tgz_6c259fadfeb3a4b20890aefe87070b8b
|
||||
'@rush-temp/dev-server': file:projects/dev-server.tgz_6c259fadfeb3a4b20890aefe87070b8b
|
||||
'@rush-temp/dev-storage': file:projects/dev-storage.tgz_6c259fadfeb3a4b20890aefe87070b8b
|
||||
'@rush-temp/login': file:projects/login.tgz_6c259fadfeb3a4b20890aefe87070b8b
|
||||
@ -7889,6 +7891,24 @@ packages:
|
||||
- typescript
|
||||
dev: false
|
||||
|
||||
file:projects/dev-client-resources.tgz_6c259fadfeb3a4b20890aefe87070b8b:
|
||||
resolution: {integrity: sha512-EUDIrb3wXy6PHSbUnxEkKagNVsM5jKUBg0qSdd6/BriulwYZ5C1BlLqS58oDWxaySjHBSMGyaKN4Ath5QYrI8A==, tarball: file:projects/dev-client-resources.tgz}
|
||||
id: file:projects/dev-client-resources.tgz
|
||||
name: '@rush-temp/dev-client-resources'
|
||||
version: 0.0.0
|
||||
dependencies:
|
||||
'@types/heft-jest': 1.0.2
|
||||
'@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
|
||||
transitivePeerDependencies:
|
||||
- '@typescript-eslint/parser'
|
||||
- supports-color
|
||||
- typescript
|
||||
dev: false
|
||||
|
||||
file:projects/dev-server.tgz_6c259fadfeb3a4b20890aefe87070b8b:
|
||||
resolution: {integrity: sha512-Zj6rBT3x7MGKM3H4RDuT7heWMI14fruf/LO0bAuLaJf99SWtkug9mNgFSnrLJyxoKUimhOBT1BHNVOH53MNOCg==, tarball: file:projects/dev-server.tgz}
|
||||
id: file:projects/dev-server.tgz
|
||||
|
6
dev/client-resources/.eslintrc.js
Normal file
6
dev/client-resources/.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
dev/client-resources/.npmignore
Normal file
4
dev/client-resources/.npmignore
Normal file
@ -0,0 +1,4 @@
|
||||
*
|
||||
!/lib/**
|
||||
!CHANGELOG.md
|
||||
/lib/**/__tests__/
|
18
dev/client-resources/config/rig.json
Normal file
18
dev/client-resources/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"
|
||||
}
|
26
dev/client-resources/package.json
Normal file
26
dev/client-resources/package.json
Normal file
@ -0,0 +1,26 @@
|
||||
{
|
||||
"name": "@anticrm/dev-client-resources",
|
||||
"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",
|
||||
"@typescript-eslint/eslint-plugin":"4",
|
||||
"eslint-plugin-import":"2",
|
||||
"eslint-plugin-promise":"4",
|
||||
"eslint-plugin-node":"11",
|
||||
"eslint":"^7.32.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@anticrm/platform":"~0.6.3",
|
||||
"@anticrm/core":"~0.6.0",
|
||||
"@anticrm/client":"~0.6.0",
|
||||
"@anticrm/dev-storage":"~0.6.3"
|
||||
}
|
||||
}
|
31
dev/client-resources/src/__tests__/client.test.ts
Normal file
31
dev/client-resources/src/__tests__/client.test.ts
Normal file
@ -0,0 +1,31 @@
|
||||
//
|
||||
// Copyright © 2020 Anticrm Platform Contributors.
|
||||
//
|
||||
// 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 { connect } from '../connection'
|
||||
import core, { createClient } from '@anticrm/core'
|
||||
|
||||
describe('client', () => {
|
||||
it('should create connection', async () => {
|
||||
const conn = await connect(() => {})
|
||||
const txes = await conn.findAll(core.class.Tx, {})
|
||||
expect(txes.length).toBe(25)
|
||||
})
|
||||
|
||||
it('should create client', async () => {
|
||||
const client = await createClient(connect)
|
||||
const txes = await client.findAll(core.class.Class, {})
|
||||
expect(txes.length).toBe(18)
|
||||
})
|
||||
})
|
45
dev/client-resources/src/connection.ts
Normal file
45
dev/client-resources/src/connection.ts
Normal file
@ -0,0 +1,45 @@
|
||||
//
|
||||
// Copyright © 2020 Anticrm Platform Contributors.
|
||||
//
|
||||
// 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,
|
||||
Storage,
|
||||
Ref,
|
||||
Doc,
|
||||
Class,
|
||||
DocumentQuery,
|
||||
FindResult,
|
||||
FindOptions,
|
||||
TxHander
|
||||
} from '@anticrm/core'
|
||||
import { createStorage, ServerStorage } from '@anticrm/dev-storage'
|
||||
|
||||
class ServerStorageWrapper implements Storage {
|
||||
constructor (private readonly storage: ServerStorage, private readonly handler: TxHander) {}
|
||||
|
||||
findAll <T extends Doc>(_class: Ref<Class<T>>, query: DocumentQuery<T>, options?: FindOptions<T>): Promise<FindResult<T>> {
|
||||
return this.storage.findAll(_class, query, options)
|
||||
}
|
||||
|
||||
async tx (tx: Tx): Promise<void> {
|
||||
const derived = await this.storage.tx(tx)
|
||||
for (const tx of derived) { this.handler(tx) }
|
||||
}
|
||||
}
|
||||
|
||||
export async function connect (handler: (tx: Tx) => void): Promise<Storage> {
|
||||
const serverStorage = await createStorage()
|
||||
return new ServerStorageWrapper(serverStorage, handler)
|
||||
}
|
37
dev/client-resources/src/index.ts
Normal file
37
dev/client-resources/src/index.ts
Normal file
@ -0,0 +1,37 @@
|
||||
//
|
||||
// Copyright © 2020 Anticrm Platform Contributors.
|
||||
//
|
||||
// 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 { createClient, Client } from '@anticrm/core'
|
||||
import { connect } from './connection'
|
||||
|
||||
/*!
|
||||
* Anticrm Platform™ Client Dev Plugin
|
||||
* © 2020 Anticrm Platform Contributors. All Rights Reserved.
|
||||
* Licensed under the Eclipse Public License, Version 2.0
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
||||
export default async () => {
|
||||
let client: Client
|
||||
return {
|
||||
function: {
|
||||
GetClient: async (): Promise<Client> => {
|
||||
if (client === undefined) {
|
||||
client = await createClient(connect)
|
||||
}
|
||||
return client
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
1018
dev/client-resources/src/model.tx.json
Normal file
1018
dev/client-resources/src/model.tx.json
Normal file
File diff suppressed because it is too large
Load Diff
8
dev/client-resources/tsconfig.json
Normal file
8
dev/client-resources/tsconfig.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"extends": "./node_modules/@anticrm/platform-rig/profiles/default/tsconfig.json",
|
||||
|
||||
"compilerOptions": {
|
||||
"rootDir": "./src",
|
||||
"outDir": "./lib",
|
||||
}
|
||||
}
|
@ -55,6 +55,7 @@ export function addLocation<R extends Resources> (
|
||||
function getLocation (plugin: Plugin): PluginLoader<Resources> {
|
||||
const location = locations.get(plugin)
|
||||
if (location === undefined) {
|
||||
console.log(plugin)
|
||||
throw new PlatformError(
|
||||
new Status(Severity.ERROR, platform.status.NoLocationForPlugin, {
|
||||
plugin
|
||||
|
@ -4,6 +4,6 @@
|
||||
"compilerOptions": {
|
||||
"rootDir": "./src",
|
||||
"outDir": "./lib",
|
||||
"lib": ["esnext", "esnext.intl"]
|
||||
"lib": ["esnext", "esnext.intl", "dom"]
|
||||
}
|
||||
}
|
@ -4,6 +4,5 @@
|
||||
"compilerOptions": {
|
||||
"rootDir": "./src",
|
||||
"outDir": "./lib",
|
||||
"lib": ["esnext", "dom"]
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user