diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index c61c11bfc9..77a9cff5b9 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -3,13 +3,15 @@ lockfileVersion: 5.3 specifiers: '@microsoft/api-extractor': ^7.18.4 '@rush-temp/core': file:./projects/core.tgz + '@rush-temp/dev-storage': file:./projects/dev-storage.tgz '@rush-temp/platform': file:./projects/platform.tgz '@rush-temp/platform-rig': file:./projects/platform-rig.tgz - '@rush-temp/server': file:./projects/server.tgz + '@rush-temp/server-ws': file:./projects/server-ws.tgz '@rushstack/heft': ^0.35.0 '@rushstack/heft-jest-plugin': ~0.1.15 '@types/heft-jest': ^1.0.2 '@types/node': ^16.4.10 + '@types/ws': ^7.4.7 '@typescript-eslint/eslint-plugin': '4' '@typescript-eslint/parser': ^4.0.0 eslint: ^7.32.0 @@ -26,13 +28,15 @@ specifiers: dependencies: '@microsoft/api-extractor': 7.18.4 '@rush-temp/core': file:projects/core.tgz_6c259fadfeb3a4b20890aefe87070b8b + '@rush-temp/dev-storage': file:projects/dev-storage.tgz_6c259fadfeb3a4b20890aefe87070b8b '@rush-temp/platform': file:projects/platform.tgz_6c259fadfeb3a4b20890aefe87070b8b '@rush-temp/platform-rig': file:projects/platform-rig.tgz_6ab28797e7a22071465f7d680ae81ae5 - '@rush-temp/server': file:projects/server.tgz_6c259fadfeb3a4b20890aefe87070b8b + '@rush-temp/server-ws': file:projects/server-ws.tgz_6c259fadfeb3a4b20890aefe87070b8b '@rushstack/heft': 0.35.0 '@rushstack/heft-jest-plugin': 0.1.15_@rushstack+heft@0.35.0 '@types/heft-jest': 1.0.2 '@types/node': 16.4.10 + '@types/ws': 7.4.7 '@typescript-eslint/eslint-plugin': 4.28.5_a8e83fcad666e1ba86be4b2e27a20aea '@typescript-eslint/parser': 4.28.5_eslint@7.32.0+typescript@4.3.5 eslint: 7.32.0 @@ -5197,6 +5201,25 @@ packages: - typescript dev: false + file:projects/dev-storage.tgz_6c259fadfeb3a4b20890aefe87070b8b: + resolution: {integrity: sha512-Jf/W4dvCH5kUvK2ItxuijWJM4IGZf8Hi1noFrzk9PLL+2WNrD5t7sPB9c/lv4KzKEhX5gTV4ZkLBHNyD+lo2oQ==, tarball: file:projects/dev-storage.tgz} + id: file:projects/dev-storage.tgz + name: '@rush-temp/dev-storage' + 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 + simplytyped: 3.3.0_typescript@4.3.5 + transitivePeerDependencies: + - '@typescript-eslint/parser' + - supports-color + - typescript + dev: false + file:projects/platform-rig.tgz_6ab28797e7a22071465f7d680ae81ae5: resolution: {integrity: sha512-VwGZVPcf2apIoa4sxQkIvW90B4otxf7ayw1jlTiZKQsQfwnLRKXvInMbIIAP0zCPRWIZdXXBYpUDm3dOJ/2bYQ==, tarball: file:projects/platform-rig.tgz} id: file:projects/platform-rig.tgz @@ -5240,10 +5263,10 @@ packages: - typescript dev: false - file:projects/server.tgz_6c259fadfeb3a4b20890aefe87070b8b: - resolution: {integrity: sha512-RNLOYCrfV7DpGNDy74lWtChPLzJkaP/Tb10vh3usOUf8kjByj8MXjhnKRgb8ZMn2MkkquQ+Pdz5Hi/tfcSsvxw==, tarball: file:projects/server.tgz} - id: file:projects/server.tgz - name: '@rush-temp/server' + file:projects/server-ws.tgz_6c259fadfeb3a4b20890aefe87070b8b: + resolution: {integrity: sha512-FPRBEhZQsqM1RubaIKALYn07JyvdHC23q2lG6gdEbMDtPAo4p7lO7KeUp6ObshvRfLx7+50Idl8c8xDBGbz41Q==, tarball: file:projects/server-ws.tgz} + id: file:projects/server-ws.tgz + name: '@rush-temp/server-ws' version: 0.0.0 dependencies: '@types/heft-jest': 1.0.2 diff --git a/server/server/.eslintrc.js b/dev/storage/.eslintrc.js similarity index 100% rename from server/server/.eslintrc.js rename to dev/storage/.eslintrc.js diff --git a/server/server/config/rig.json b/dev/storage/config/rig.json similarity index 100% rename from server/server/config/rig.json rename to dev/storage/config/rig.json diff --git a/dev/storage/package.json b/dev/storage/package.json new file mode 100644 index 0000000000..5b94b9d599 --- /dev/null +++ b/dev/storage/package.json @@ -0,0 +1,28 @@ +{ + "name": "@anticrm/dev-storage", + "version": "0.6.0", + "main": "lib/index.js", + "author": "Anticrm Platform Contributors", + "license": "EPL-2.0", + "scripts": { + "build": "heft build", + "build:docs": "api-extractor run --local", + "test": "jest", + "lint": "ts-standard src", + "lint:fix": "eslint --fix ./src", + "format": "prettier --write 'src/**/*.{ts*,js*,yml}' && ts-standard --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/core": "~0.6.0", + "@anticrm/platform": "~0.6.0" + } +} diff --git a/server/server/src/index.ts b/dev/storage/src/index.ts similarity index 77% rename from server/server/src/index.ts rename to dev/storage/src/index.ts index a700de9f8e..c3c1cdb151 100644 --- a/server/server/src/index.ts +++ b/dev/storage/src/index.ts @@ -14,14 +14,6 @@ // limitations under the License. // -// import { start } from './server' - -// const mongodbUri = process.env.MONGODB_URI || 'mongodb://localhost:27017' - -// console.log('mongodb uri: ...' + mongodbUri.substring(25)) - -// start(18080, mongodbUri) - /** * @public */ diff --git a/dev/storage/src/model.tx.json b/dev/storage/src/model.tx.json new file mode 100644 index 0000000000..f8f795b450 --- /dev/null +++ b/dev/storage/src/model.tx.json @@ -0,0 +1,1018 @@ +[ + { + "_id": "610828bdad975a4e5f24b461", + "_class": "core.class.TxCreateDoc", + "space": "core.space.Tx", + "objectId": "core.class.Obj", + "objectClass": "core.class.Class", + "objectSpace": "core.space.Model", + "modifiedOn": 1627924669333, + "modifiedBy": "core.account.System", + "attributes": { + "kind": 0 + } + }, + { + "_id": "610828bdad975a4e5f24b462", + "_class": "core.class.TxCreateDoc", + "space": "core.space.Tx", + "objectId": "core.class.Doc", + "objectClass": "core.class.Class", + "objectSpace": "core.space.Model", + "modifiedOn": 1627924669333, + "modifiedBy": "core.account.System", + "attributes": { + "kind": 0, + "extends": "core.class.Obj" + } + }, + { + "_id": "610828bdad975a4e5f24b463", + "_class": "core.class.TxCreateDoc", + "space": "core.space.Tx", + "objectId": "core.class.Type", + "objectClass": "core.class.Class", + "objectSpace": "core.space.Model", + "modifiedOn": 1627924669333, + "modifiedBy": "core.account.System", + "attributes": { + "kind": 0, + "extends": "core.class.Doc" + } + }, + { + "_id": "610828bdad975a4e5f24b464", + "_class": "core.class.TxCreateDoc", + "space": "core.space.Tx", + "objectId": "core.class.TypeString", + "objectClass": "core.class.Class", + "objectSpace": "core.space.Model", + "modifiedOn": 1627924669333, + "modifiedBy": "core.account.System", + "attributes": { + "kind": 0, + "extends": "core.class.Type" + } + }, + { + "_id": "610828bdad975a4e5f24b465", + "_class": "core.class.TxCreateDoc", + "space": "core.space.Tx", + "objectId": "core.class.Attribute", + "objectClass": "core.class.Class", + "objectSpace": "core.space.Model", + "modifiedOn": 1627924669333, + "modifiedBy": "core.account.System", + "attributes": { + "kind": 0, + "extends": "core.class.Doc" + } + }, + { + "_id": "610828bdad975a4e5f24b466", + "_class": "core.class.TxCreateDoc", + "space": "core.space.Tx", + "objectId": "core.class.Account", + "objectClass": "core.class.Class", + "objectSpace": "core.space.Model", + "modifiedOn": 1627924669333, + "modifiedBy": "core.account.System", + "attributes": { + "domain": "model", + "kind": 0, + "extends": "core.class.Doc" + } + }, + { + "_id": "610828bdad975a4e5f24b467", + "_class": "core.class.TxCreateDoc", + "space": "core.space.Tx", + "objectId": "core.class.Space", + "objectClass": "core.class.Class", + "objectSpace": "core.space.Model", + "modifiedOn": 1627924669333, + "modifiedBy": "core.account.System", + "attributes": { + "domain": "model", + "kind": 0, + "extends": "core.class.Doc" + } + }, + { + "_id": "610828bdad975a4e5f24b468", + "_class": "core.class.TxCreateDoc", + "space": "core.space.Tx", + "objectId": "core.class.Tx", + "objectClass": "core.class.Class", + "objectSpace": "core.space.Model", + "modifiedOn": 1627924669333, + "modifiedBy": "core.account.System", + "attributes": { + "domain": "tx", + "kind": 0, + "extends": "core.class.Doc" + } + }, + { + "_id": "610828bdad975a4e5f24b469", + "_class": "core.class.TxCreateDoc", + "space": "core.space.Tx", + "objectId": "core.class.TxUpdateDoc", + "objectClass": "core.class.Class", + "objectSpace": "core.space.Model", + "modifiedOn": 1627924669333, + "modifiedBy": "core.account.System", + "attributes": { + "kind": 0, + "extends": "core.class.Tx" + } + }, + { + "_id": "610828bdad975a4e5f24b46a", + "_class": "core.class.TxCreateDoc", + "space": "core.space.Tx", + "objectId": "core.class.TxMixin", + "objectClass": "core.class.Class", + "objectSpace": "core.space.Model", + "modifiedOn": 1627924669333, + "modifiedBy": "core.account.System", + "attributes": { + "kind": 0, + "extends": "core.class.Tx" + } + }, + { + "_id": "610828bdad975a4e5f24b46b", + "_class": "core.class.TxCreateDoc", + "space": "core.space.Tx", + "objectId": "core.class.TxCreateDoc", + "objectClass": "core.class.Class", + "objectSpace": "core.space.Model", + "modifiedOn": 1627924669333, + "modifiedBy": "core.account.System", + "attributes": { + "kind": 0, + "extends": "core.class.Tx" + } + }, + { + "_id": "610828bdad975a4e5f24b46c", + "_class": "core.class.TxCreateDoc", + "space": "core.space.Tx", + "objectId": "core.class.Class", + "objectClass": "core.class.Class", + "objectSpace": "core.space.Model", + "modifiedOn": 1627924669333, + "modifiedBy": "core.account.System", + "attributes": { + "domain": "model", + "kind": 0, + "extends": "core.class.Doc" + } + }, + { + "_id": "610828bdad975a4e5f24b46d", + "_class": "core.class.TxCreateDoc", + "space": "core.space.Tx", + "objectId": "core.class.Mixin", + "objectClass": "core.class.Class", + "objectSpace": "core.space.Model", + "modifiedOn": 1627924669333, + "modifiedBy": "core.account.System", + "attributes": { + "kind": 0, + "extends": "core.class.Class" + } + }, + { + "_id": "610828bdad975a4e5f24b46e", + "_class": "core.class.TxCreateDoc", + "space": "core.space.Tx", + "objectId": "view.class.Viewlet", + "objectClass": "core.class.Class", + "objectSpace": "core.space.Model", + "modifiedOn": 1627924669333, + "modifiedBy": "core.account.System", + "attributes": { + "domain": "model", + "kind": 0, + "extends": "core.class.Doc" + } + }, + { + "_id": "610828bdad975a4e5f24b46f", + "_class": "core.class.TxCreateDoc", + "space": "core.space.Tx", + "objectId": "view.class.ViewletDescriptor", + "objectClass": "core.class.Class", + "objectSpace": "core.space.Model", + "modifiedOn": 1627924669333, + "modifiedBy": "core.account.System", + "attributes": { + "domain": "model", + "kind": 0, + "extends": "core.class.Doc" + } + }, + { + "_id": "610828bdad975a4e5f24b470", + "_class": "core.class.TxCreateDoc", + "space": "core.space.Tx", + "objectId": "view.mixin.AttributePresenter", + "objectClass": "core.class.Class", + "objectSpace": "core.space.Model", + "modifiedOn": 1627924669333, + "modifiedBy": "core.account.System", + "attributes": { + "kind": 0, + "extends": "core.class.Class" + } + }, + { + "_id": "610828bdad975a4e5f24b471", + "_class": "core.class.TxCreateDoc", + "space": "core.space.Tx", + "objectId": "view.mixin.AttributeEditor", + "objectClass": "core.class.Class", + "objectSpace": "core.space.Model", + "modifiedOn": 1627924669333, + "modifiedBy": "core.account.System", + "attributes": { + "kind": 0, + "extends": "core.class.Class" + } + }, + { + "_id": "610828bdad975a4e5f24b472", + "_class": "core.class.TxMixin", + "space": "core.space.Tx", + "modifiedBy": "core.account.System", + "modifiedOn": 1627924669333, + "objectId": "core.class.TypeString", + "objectClass": "core.class.Class", + "objectSpace": "core.space.Model", + "mixin": "view.mixin.AttributeEditor", + "attributes": { + "editor": "view.component.StringEditor" + } + }, + { + "_id": "610828bdad975a4e5f24b473", + "_class": "core.class.TxMixin", + "space": "core.space.Tx", + "modifiedBy": "core.account.System", + "modifiedOn": 1627924669333, + "objectId": "core.class.TypeString", + "objectClass": "core.class.Class", + "objectSpace": "core.space.Model", + "mixin": "view.mixin.AttributePresenter", + "attributes": { + "presenter": "view.component.StringPresenter" + } + }, + { + "_id": "610828bdad975a4e5f24b474", + "_class": "core.class.TxCreateDoc", + "space": "core.space.Tx", + "objectId": "view.viewlet.Table", + "objectClass": "view.class.ViewletDescriptor", + "objectSpace": "core.space.Model", + "modifiedOn": 1627924669334, + "modifiedBy": "core.account.System", + "attributes": { + "label": "Table", + "icon": "view.icon.Table", + "component": "table.component.TableView" + } + }, + { + "_id": "610828bdad975a4e5f24b475", + "_class": "core.class.TxCreateDoc", + "space": "core.space.Tx", + "objectId": "workbench.mixin.SpaceView", + "objectClass": "core.class.Class", + "objectSpace": "core.space.Model", + "modifiedOn": 1627924669334, + "modifiedBy": "core.account.System", + "attributes": { + "kind": 0, + "extends": "core.class.Class" + } + }, + { + "_id": "610828bdad975a4e5f24b476", + "_class": "core.class.TxCreateDoc", + "space": "core.space.Tx", + "objectId": "workbench.class.Application", + "objectClass": "core.class.Class", + "objectSpace": "core.space.Model", + "modifiedOn": 1627924669334, + "modifiedBy": "core.account.System", + "attributes": { + "domain": "model", + "kind": 0, + "extends": "core.class.Doc" + } + }, + { + "_id": "610828bdad975a4e5f24b477", + "_class": "core.class.TxCreateDoc", + "space": "core.space.Tx", + "objectId": "contact.class.Contact", + "objectClass": "core.class.Class", + "objectSpace": "core.space.Model", + "modifiedOn": 1627924669334, + "modifiedBy": "core.account.System", + "attributes": { + "kind": 0, + "extends": "core.class.Doc" + } + }, + { + "_id": "610828bdad975a4e5f24b478", + "_class": "core.class.TxCreateDoc", + "space": "core.space.Tx", + "objectId": "contact.class.Organization", + "objectClass": "core.class.Class", + "objectSpace": "core.space.Model", + "modifiedOn": 1627924669334, + "modifiedBy": "core.account.System", + "attributes": { + "kind": 0, + "extends": "contact.class.Contact" + } + }, + { + "_id": "610828bdad975a4e5f24b479", + "_class": "core.class.TxCreateDoc", + "space": "core.space.Tx", + "objectId": "contact.class.Person", + "objectClass": "core.class.Class", + "objectSpace": "core.space.Model", + "modifiedOn": 1627924669334, + "modifiedBy": "core.account.System", + "attributes": { + "kind": 0, + "extends": "contact.class.Contact", + "label": "Person" + } + }, + { + "_id": "610828bdad975a4e5f24b47a", + "objectId": "610828bdad975a4e5f24b47b", + "_class": "core.class.TxCreateDoc", + "space": "core.space.Tx", + "modifiedBy": "core.account.System", + "modifiedOn": 1627924669178, + "objectSpace": "core.space.Model", + "objectClass": "core.class.Attribute", + "attributes": { + "type": { + "_class": "core.class.TypeString" + }, + "name": "firstName", + "label": "First name", + "attributeOf": "contact.class.Person" + } + }, + { + "_id": "610828bdad975a4e5f24b47c", + "objectId": "610828bdad975a4e5f24b47d", + "_class": "core.class.TxCreateDoc", + "space": "core.space.Tx", + "modifiedBy": "core.account.System", + "modifiedOn": 1627924669178, + "objectSpace": "core.space.Model", + "objectClass": "core.class.Attribute", + "attributes": { + "type": { + "_class": "core.class.TypeString" + }, + "name": "lastName", + "label": "Last name", + "attributeOf": "contact.class.Person" + } + }, + { + "_id": "610828bdad975a4e5f24b47e", + "objectId": "610828bdad975a4e5f24b47f", + "_class": "core.class.TxCreateDoc", + "space": "core.space.Tx", + "modifiedBy": "core.account.System", + "modifiedOn": 1627924669178, + "objectSpace": "core.space.Model", + "objectClass": "core.class.Attribute", + "attributes": { + "type": { + "_class": "core.class.TypeString" + }, + "name": "email", + "label": "Email", + "attributeOf": "contact.class.Person" + } + }, + { + "_id": "610828bdad975a4e5f24b480", + "objectId": "610828bdad975a4e5f24b481", + "_class": "core.class.TxCreateDoc", + "space": "core.space.Tx", + "modifiedBy": "core.account.System", + "modifiedOn": 1627924669178, + "objectSpace": "core.space.Model", + "objectClass": "core.class.Attribute", + "attributes": { + "type": { + "_class": "core.class.TypeString" + }, + "name": "phone", + "label": "Phone", + "attributeOf": "contact.class.Person" + } + }, + { + "_id": "610828bdad975a4e5f24b482", + "objectId": "610828bdad975a4e5f24b483", + "_class": "core.class.TxCreateDoc", + "space": "core.space.Tx", + "modifiedBy": "core.account.System", + "modifiedOn": 1627924669178, + "objectSpace": "core.space.Model", + "objectClass": "core.class.Attribute", + "attributes": { + "type": { + "_class": "core.class.TypeString" + }, + "name": "city", + "label": "City", + "attributeOf": "contact.class.Person" + } + }, + { + "_id": "610828bdad975a4e5f24b484", + "_class": "core.class.TxMixin", + "space": "core.space.Tx", + "modifiedBy": "core.account.System", + "modifiedOn": 1627924669334, + "objectId": "contact.class.Person", + "objectClass": "core.class.Class", + "objectSpace": "core.space.Model", + "mixin": "view.mixin.AttributePresenter", + "attributes": { + "presenter": "contact.component.PersonPresenter" + } + }, + { + "_id": "610828bdad975a4e5f24b485", + "_class": "core.class.TxCreateDoc", + "space": "core.space.Tx", + "objectId": "chunter.class.Backlink", + "objectClass": "core.class.Class", + "objectSpace": "core.space.Model", + "modifiedOn": 1627924669334, + "modifiedBy": "core.account.System", + "attributes": { + "kind": 0, + "extends": "core.class.Doc" + } + }, + { + "_id": "610828bdad975a4e5f24b486", + "_class": "core.class.TxCreateDoc", + "space": "core.space.Tx", + "objectId": "chunter.class.Message", + "objectClass": "core.class.Class", + "objectSpace": "core.space.Model", + "modifiedOn": 1627924669334, + "modifiedBy": "core.account.System", + "attributes": { + "kind": 0, + "extends": "core.class.Doc", + "triggers": [ + "chunter-server.trigger.OnMessage" + ] + } + }, + { + "_id": "610828bdad975a4e5f24b487", + "_class": "core.class.TxCreateDoc", + "space": "core.space.Tx", + "objectId": "chunter.class.Channel", + "objectClass": "core.class.Class", + "objectSpace": "core.space.Model", + "modifiedOn": 1627924669334, + "modifiedBy": "core.account.System", + "attributes": { + "kind": 0, + "extends": "core.class.Space", + "label": "chunter.string.Channel", + "icon": "chunter.icon.Hashtag" + } + }, + { + "_id": "610828bdad975a4e5f24b488", + "_class": "core.class.TxMixin", + "space": "core.space.Tx", + "modifiedBy": "core.account.System", + "modifiedOn": 1627924669334, + "objectId": "chunter.class.Channel", + "objectClass": "core.class.Class", + "objectSpace": "core.space.Model", + "mixin": "workbench.mixin.SpaceView", + "attributes": { + "view": { + "class": "chunter.class.Message" + } + } + }, + { + "_id": "610828bdad975a4e5f24b489", + "_class": "core.class.TxCreateDoc", + "space": "core.space.Tx", + "objectId": "chunter.viewlet.Chat", + "objectClass": "view.class.ViewletDescriptor", + "objectSpace": "core.space.Model", + "modifiedOn": 1627924669334, + "modifiedBy": "core.account.System", + "attributes": { + "label": "Chat", + "icon": "view.icon.Table", + "component": "chunter.component.ChannelView" + } + }, + { + "_id": "610828bdad975a4e5f24b48a", + "_class": "core.class.TxCreateDoc", + "space": "core.space.Tx", + "objectId": "610828bdad975a4e5f24b48b", + "objectClass": "view.class.Viewlet", + "objectSpace": "core.space.Model", + "modifiedOn": 1627924669334, + "modifiedBy": "core.account.System", + "attributes": { + "attachTo": "chunter.class.Message", + "descriptor": "chunter.viewlet.Chat", + "open": "X", + "config": {} + } + }, + { + "_id": "610828bdad975a4e5f24b48c", + "_class": "core.class.TxCreateDoc", + "space": "core.space.Tx", + "objectId": "610828bdad975a4e5f24b48d", + "objectClass": "workbench.class.Application", + "objectSpace": "core.space.Model", + "modifiedOn": 1627924669334, + "modifiedBy": "core.account.System", + "attributes": { + "label": "chunter.string.ApplicationLabelChunter", + "icon": "chunter.icon.Chunter", + "navigatorModel": { + "spaces": [ + { + "label": "chunter.string.Channels", + "spaceClass": "chunter.class.Channel", + "addSpaceLabel": "chunter.string.CreateChannel", + "createComponent": "chunter.component.CreateChannel" + } + ] + } + } + }, + { + "_id": "610828bdad975a4e5f24b48e", + "_class": "core.class.TxCreateDoc", + "space": "core.space.Tx", + "objectId": "610828bdad975a4e5f24b48f", + "objectClass": "chunter.class.Channel", + "objectSpace": "core.space.Model", + "modifiedOn": 1627924669334, + "modifiedBy": "core.account.System", + "attributes": { + "name": "general", + "description": "General Channel", + "private": false, + "members": [] + } + }, + { + "_id": "610828bdad975a4e5f24b490", + "_class": "core.class.TxCreateDoc", + "space": "core.space.Tx", + "objectId": "610828bdad975a4e5f24b491", + "objectClass": "chunter.class.Channel", + "objectSpace": "core.space.Model", + "modifiedOn": 1627924669334, + "modifiedBy": "core.account.System", + "attributes": { + "name": "random", + "description": "Random Talks", + "private": false, + "members": [] + } + }, + { + "_id": "610828bdad975a4e5f24b492", + "_class": "core.class.TxCreateDoc", + "space": "core.space.Tx", + "objectId": "task.class.Task", + "objectClass": "core.class.Class", + "objectSpace": "core.space.Model", + "modifiedOn": 1627924669334, + "modifiedBy": "core.account.System", + "attributes": { + "kind": 0, + "extends": "core.class.Doc" + } + }, + { + "_id": "610828bdad975a4e5f24b493", + "objectId": "610828bdad975a4e5f24b494", + "_class": "core.class.TxCreateDoc", + "space": "core.space.Tx", + "modifiedBy": "core.account.System", + "modifiedOn": 1627924669332, + "objectSpace": "core.space.Model", + "objectClass": "core.class.Attribute", + "attributes": { + "type": { + "_class": "core.class.TypeString" + }, + "name": "title", + "label": "Title", + "attributeOf": "task.class.Task" + } + }, + { + "_id": "610828bdad975a4e5f24b495", + "objectId": "610828bdad975a4e5f24b496", + "_class": "core.class.TxCreateDoc", + "space": "core.space.Tx", + "modifiedBy": "core.account.System", + "modifiedOn": 1627924669332, + "objectSpace": "core.space.Model", + "objectClass": "core.class.Attribute", + "attributes": { + "type": { + "_class": "core.class.TypeString" + }, + "name": "description", + "label": "Description", + "attributeOf": "task.class.Task" + } + }, + { + "_id": "610828bdad975a4e5f24b497", + "objectId": "610828bdad975a4e5f24b498", + "_class": "core.class.TxCreateDoc", + "space": "core.space.Tx", + "modifiedBy": "core.account.System", + "modifiedOn": 1627924669332, + "objectSpace": "core.space.Model", + "objectClass": "core.class.Attribute", + "attributes": { + "type": { + "_class": "core.class.TypeString" + }, + "name": "assignee", + "label": "Assignee", + "attributeOf": "task.class.Task" + } + }, + { + "_id": "610828bdad975a4e5f24b499", + "_class": "core.class.TxCreateDoc", + "space": "core.space.Tx", + "objectId": "task.class.Project", + "objectClass": "core.class.Class", + "objectSpace": "core.space.Model", + "modifiedOn": 1627924669334, + "modifiedBy": "core.account.System", + "attributes": { + "kind": 0, + "extends": "core.class.Space", + "label": "Project", + "icon": "task.icon.Task" + } + }, + { + "_id": "610828bdad975a4e5f24b49a", + "_class": "core.class.TxMixin", + "space": "core.space.Tx", + "modifiedBy": "core.account.System", + "modifiedOn": 1627924669334, + "objectId": "task.class.Project", + "objectClass": "core.class.Class", + "objectSpace": "core.space.Model", + "mixin": "workbench.mixin.SpaceView", + "attributes": { + "view": { + "class": "task.class.Task", + "createItemDialog": "task.component.CreateTask" + } + } + }, + { + "_id": "610828bdad975a4e5f24b49b", + "_class": "core.class.TxCreateDoc", + "space": "core.space.Tx", + "objectId": "610828bdad975a4e5f24b49c", + "objectClass": "view.class.Viewlet", + "objectSpace": "core.space.Model", + "modifiedOn": 1627924669334, + "modifiedBy": "core.account.System", + "attributes": { + "attachTo": "task.class.Task", + "descriptor": "view.viewlet.Table", + "open": "ZX", + "options": { + "lookup": { + "assignee": "contact.class.Person" + } + }, + "config": [ + "title", + "$lookup.assignee" + ] + } + }, + { + "_id": "610828bdad975a4e5f24b49d", + "_class": "core.class.TxCreateDoc", + "space": "core.space.Tx", + "objectId": "610828bdad975a4e5f24b49e", + "objectClass": "workbench.class.Application", + "objectSpace": "core.space.Model", + "modifiedOn": 1627924669334, + "modifiedBy": "core.account.System", + "attributes": { + "label": "task.string.ApplicationLabelTask", + "icon": "task.icon.Task", + "navigatorModel": { + "spaces": [ + { + "label": "task.string.Projects", + "spaceClass": "task.class.Project", + "addSpaceLabel": "task.string.CreateProject", + "createComponent": "task.component.CreateProject" + } + ] + } + } + }, + { + "_id": "610828bdad975a4e5f24b49f", + "_class": "core.class.TxCreateDoc", + "space": "core.space.Tx", + "objectId": "610828bdad975a4e5f24b4a0", + "objectClass": "task.class.Project", + "objectSpace": "core.space.Model", + "modifiedOn": 1627924669334, + "modifiedBy": "core.account.System", + "attributes": { + "name": "demo", + "description": "Demo Project", + "private": false, + "members": [] + } + }, + { + "_id": "610828bdad975a4e5f24b4a1", + "_class": "core.class.TxCreateDoc", + "space": "core.space.Tx", + "objectId": "recruit.class.Applicant", + "objectClass": "core.class.Class", + "objectSpace": "core.space.Model", + "modifiedOn": 1627924669334, + "modifiedBy": "core.account.System", + "attributes": { + "kind": 0, + "extends": "core.class.Doc" + } + }, + { + "_id": "610828bdad975a4e5f24b4a2", + "objectId": "610828bdad975a4e5f24b4a3", + "_class": "core.class.TxCreateDoc", + "space": "core.space.Tx", + "modifiedBy": "core.account.System", + "modifiedOn": 1627924669299, + "objectSpace": "core.space.Model", + "objectClass": "core.class.Attribute", + "attributes": { + "type": { + "_class": "core.class.TypeString" + }, + "name": "candidate", + "label": "Candidate", + "attributeOf": "recruit.class.Applicant" + } + }, + { + "_id": "610828bdad975a4e5f24b4a4", + "_class": "core.class.TxCreateDoc", + "space": "core.space.Tx", + "objectId": "recruit.class.Candidate", + "objectClass": "core.class.Class", + "objectSpace": "core.space.Model", + "modifiedOn": 1627924669334, + "modifiedBy": "core.account.System", + "attributes": { + "kind": 0, + "extends": "contact.class.Person", + "label": "Candidate" + } + }, + { + "_id": "610828bdad975a4e5f24b4a5", + "_class": "core.class.TxCreateDoc", + "space": "core.space.Tx", + "objectId": "recruit.class.Candidates", + "objectClass": "core.class.Class", + "objectSpace": "core.space.Model", + "modifiedOn": 1627924669334, + "modifiedBy": "core.account.System", + "attributes": { + "kind": 0, + "extends": "core.class.Space", + "label": "recruit.string.CandidatePools", + "icon": "recruit.icon.RecruitApplication" + } + }, + { + "_id": "610828bdad975a4e5f24b4a6", + "_class": "core.class.TxCreateDoc", + "space": "core.space.Tx", + "objectId": "recruit.class.Vacancy", + "objectClass": "core.class.Class", + "objectSpace": "core.space.Model", + "modifiedOn": 1627924669334, + "modifiedBy": "core.account.System", + "attributes": { + "kind": 0, + "extends": "core.class.Space", + "label": "recruit.string.Vacancy", + "icon": "recruit.icon.Vacancy" + } + }, + { + "_id": "610828bdad975a4e5f24b4a7", + "_class": "core.class.TxMixin", + "space": "core.space.Tx", + "modifiedBy": "core.account.System", + "modifiedOn": 1627924669334, + "objectId": "recruit.class.Vacancy", + "objectClass": "core.class.Class", + "objectSpace": "core.space.Model", + "mixin": "workbench.mixin.SpaceView", + "attributes": { + "view": { + "class": "recruit.class.Applicant", + "createItemDialog": "recruit.component.CreateApplication" + } + } + }, + { + "_id": "610828bdad975a4e5f24b4a8", + "_class": "core.class.TxMixin", + "space": "core.space.Tx", + "modifiedBy": "core.account.System", + "modifiedOn": 1627924669334, + "objectId": "recruit.class.Candidates", + "objectClass": "core.class.Class", + "objectSpace": "core.space.Model", + "mixin": "workbench.mixin.SpaceView", + "attributes": { + "view": { + "class": "recruit.class.Candidate", + "createItemDialog": "recruit.component.CreateCandidate" + } + } + }, + { + "_id": "610828bdad975a4e5f24b4a9", + "_class": "core.class.TxCreateDoc", + "space": "core.space.Tx", + "objectId": "610828bdad975a4e5f24b4aa", + "objectClass": "workbench.class.Application", + "objectSpace": "core.space.Model", + "modifiedOn": 1627924669334, + "modifiedBy": "core.account.System", + "attributes": { + "label": "recruit.string.RecruitApplication", + "icon": "recruit.icon.RecruitApplication", + "navigatorModel": { + "spaces": [ + { + "label": "recruit.string.Vacancies", + "spaceClass": "recruit.class.Vacancy", + "addSpaceLabel": "recruit.string.CreateVacancy", + "createComponent": "recruit.component.CreateVacancy" + }, + { + "label": "recruit.string.CandidatePools", + "spaceClass": "recruit.class.Candidates", + "addSpaceLabel": "recruit.string.CreateCandidates", + "createComponent": "recruit.component.CreateCandidates" + } + ] + } + } + }, + { + "_id": "610828bdad975a4e5f24b4ab", + "_class": "core.class.TxCreateDoc", + "space": "core.space.Tx", + "objectId": "recruit.space.CandidatesPublic", + "objectClass": "recruit.class.Candidates", + "objectSpace": "core.space.Model", + "modifiedOn": 1627924669334, + "modifiedBy": "core.account.System", + "attributes": { + "name": "public", + "description": "Public Candidates", + "private": false, + "members": [] + } + }, + { + "_id": "610828bdad975a4e5f24b4ac", + "_class": "core.class.TxCreateDoc", + "space": "core.space.Tx", + "objectId": "610828bdad975a4e5f24b4ad", + "objectClass": "view.class.Viewlet", + "objectSpace": "core.space.Model", + "modifiedOn": 1627924669334, + "modifiedBy": "core.account.System", + "attributes": { + "attachTo": "recruit.class.Candidate", + "descriptor": "view.viewlet.Table", + "open": "recruit.component.EditCandidate", + "config": [ + "", + "email", + "phone", + "city" + ] + } + }, + { + "_id": "610828bdad975a4e5f24b4ae", + "_class": "core.class.TxCreateDoc", + "space": "core.space.Tx", + "objectId": "610828bdad975a4e5f24b4af", + "objectClass": "view.class.Viewlet", + "objectSpace": "core.space.Model", + "modifiedOn": 1627924669334, + "modifiedBy": "core.account.System", + "attributes": { + "attachTo": "recruit.class.Applicant", + "descriptor": "view.viewlet.Table", + "open": "recruit.component.EditCandidate", + "options": { + "lookup": { + "candidate": "recruit.class.Candidate" + } + }, + "config": [ + "$lookup.candidate", + "$lookup.candidate.email", + "$lookup.candidate.city" + ] + } + }, + { + "_id": "610828bdad975a4e5f24b4b0", + "_class": "core.class.TxCreateDoc", + "space": "core.space.Tx", + "objectId": "610828bdad975a4e5f24b4b1", + "objectClass": "recruit.class.Candidate", + "objectSpace": "recruit.space.CandidatesPublic", + "modifiedOn": 1627924669334, + "modifiedBy": "core.account.System", + "attributes": { + "firstName": "Andrey", + "lastName": "P.", + "email": "andrey@hc.engineering", + "phone": "+1 646 667 6832", + "city": "Monte Carlo" + } + }, + { + "_id": "610828bdad975a4e5f24b4b2", + "_class": "core.class.TxCreateDoc", + "space": "core.space.Tx", + "objectId": "610828bdad975a4e5f24b4b3", + "objectClass": "recruit.class.Candidate", + "objectSpace": "recruit.space.CandidatesPublic", + "modifiedOn": 1627924669334, + "modifiedBy": "core.account.System", + "attributes": { + "firstName": "Marina", + "lastName": "M.", + "email": "marina@hc.engineering", + "phone": "+1 646 777 3333", + "city": "Los Angeles" + } + } +] \ No newline at end of file diff --git a/dev/storage/src/storage.ts b/dev/storage/src/storage.ts new file mode 100644 index 0000000000..16add392d4 --- /dev/null +++ b/dev/storage/src/storage.ts @@ -0,0 +1,87 @@ +// +// 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 +} from '@anticrm/core' +import { getResource } from '@anticrm/platform' +import core, { ModelDb, TxDb, Hierarchy, DOMAIN_TX, DefaultTxFactory } from '@anticrm/core' + +async function getModel (): Promise { + return import('./model.tx.json') as unknown as Tx[] +} + +class DevStorage implements Storage { + private readonly txFactory: DefaultTxFactory + + constructor ( + private readonly hierarchy: Hierarchy, + private readonly txdb: TxDb, + private readonly modeldb: ModelDb, + private readonly handler: (tx: Tx) => void) { + this.txFactory = new DefaultTxFactory(core.account.System) + } + + async findAll ( + _class: Ref>, + query: DocumentQuery, + options?: FindOptions + ): Promise> { + const domain = this.hierarchy.getClass(_class).domain + if (domain === DOMAIN_TX) return await this.txdb.findAll(_class, query, options) + return await this.modeldb.findAll(_class, query, options) + } + + async tx (tx: Tx): Promise { + if (tx.objectSpace === core.space.Model) { + this.hierarchy.tx(tx) + } + await Promise.all([this.modeldb.tx(tx), this.txdb.tx(tx)]) + // invoke triggers + const triggers = this.hierarchy.getClass(tx.objectClass).triggers + if (triggers !== undefined) { + for (const trigger of triggers) { + const impl = await getResource(trigger) + const txes = await impl(tx, this.txFactory) + for (const tx of txes) { + await Promise.all([this.modeldb.tx(tx), this.txdb.tx(tx)]) + this.handler(tx) + } + } + } + } +} + +export async function connect (handler: (tx: Tx) => void): Promise { + const txes = await getModel() + + const hierarchy = new Hierarchy() + for (const tx of txes) hierarchy.tx(tx) + + const transactions = new TxDb(hierarchy) + const model = new ModelDb(hierarchy) + for (const tx of txes) { + await Promise.all([transactions.tx(tx), model.tx(tx)]) + } + + return new DevStorage(hierarchy, transactions, model, handler) +} diff --git a/dev/storage/tsconfig.json b/dev/storage/tsconfig.json new file mode 100644 index 0000000000..aeb0517b13 --- /dev/null +++ b/dev/storage/tsconfig.json @@ -0,0 +1,8 @@ +{ + "extends": "./node_modules/@anticrm/platform-rig/profiles/default/tsconfig.json", + + "compilerOptions": { + "rootDir": "./src", + "outDir": "./lib" + } +} \ No newline at end of file diff --git a/rush.json b/rush.json index 0a412a810b..5e73f4f559 100644 --- a/rush.json +++ b/rush.json @@ -462,15 +462,14 @@ "shouldPublish": true }, { - "packageName": "@anticrm/server", - "projectFolder": "server/server", + "packageName": "@anticrm/server-ws", + "projectFolder": "server/ws", + "shouldPublish": true + }, + { + "packageName": "@anticrm/dev-storage", + "projectFolder": "dev/storage", "shouldPublish": true } - // - // { - // "packageName": "my-toolchain", - // "projectFolder": "tools/my-toolchain", - // "reviewCategory": "tools" - // } ] } diff --git a/server/ws/.eslintrc.js b/server/ws/.eslintrc.js new file mode 100644 index 0000000000..89f8151bd4 --- /dev/null +++ b/server/ws/.eslintrc.js @@ -0,0 +1,6 @@ +module.exports = { + extends: ['./node_modules/@anticrm/platform-rig/profiles/default/config/eslint.config.json'], + parserOptions: { + project: './tsconfig.json' + } +} \ No newline at end of file diff --git a/server/ws/config/rig.json b/server/ws/config/rig.json new file mode 100644 index 0000000000..af1257a896 --- /dev/null +++ b/server/ws/config/rig.json @@ -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" +} diff --git a/server/server/package.json b/server/ws/package.json similarity index 96% rename from server/server/package.json rename to server/ws/package.json index 5b9902e280..38c79f4d1d 100644 --- a/server/server/package.json +++ b/server/ws/package.json @@ -1,5 +1,5 @@ { - "name": "@anticrm/server", + "name": "@anticrm/server-ws", "version": "0.6.0", "main": "lib/index.js", "author": "Anticrm Platform Contributors", diff --git a/server/server/src/__tests__/server.test.ts b/server/ws/src/__tests__/server.test.ts similarity index 100% rename from server/server/src/__tests__/server.test.ts rename to server/ws/src/__tests__/server.test.ts diff --git a/server/ws/src/index.ts b/server/ws/src/index.ts new file mode 100644 index 0000000000..65ead4648c --- /dev/null +++ b/server/ws/src/index.ts @@ -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 { start } from './server' diff --git a/server/server/src/server.ts b/server/ws/src/server.ts similarity index 97% rename from server/server/src/server.ts rename to server/ws/src/server.ts index 2dba9785d0..caf2d4e43c 100644 --- a/server/server/src/server.ts +++ b/server/ws/src/server.ts @@ -38,9 +38,9 @@ async function handleRequest (service: S, ws: WebSocket, msg: string): Promis /** * @public - * @param serviceFactory - * @param port - * @param host + * @param serviceFactory - + * @param port - + * @param host - */ export function start (serviceFactory: () => Promise, port: number, host?: string): void { // console.log('starting server on port ' + port + '...') diff --git a/server/server/tsconfig.json b/server/ws/tsconfig.json similarity index 100% rename from server/server/tsconfig.json rename to server/ws/tsconfig.json