mirror of
https://github.com/hcengineering/platform.git
synced 2026-10-01 22:15:04 +02:00
UBERF-5603 (#4754)
Signed-off-by: Denis Bykhov <bykhov.denis@gmail.com>
This commit is contained in:
@@ -83,6 +83,8 @@
|
||||
"@hcengineering/model-server-activity": "^0.6.0",
|
||||
"@hcengineering/model-server-openai": "^0.6.0",
|
||||
"@hcengineering/model-server-translate": "^0.6.0",
|
||||
"@hcengineering/model-support": "^0.6.0"
|
||||
"@hcengineering/model-support": "^0.6.0",
|
||||
"@hcengineering/model-guest": "^0.6.0",
|
||||
"@hcengineering/model-server-guest": "^0.6.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,6 +67,8 @@ import { textEditorId, createModel as textEditorModel } from '@hcengineering/mod
|
||||
import tracker, { trackerId, createModel as trackerModel } from '@hcengineering/model-tracker'
|
||||
import view, { viewId, createModel as viewModel } from '@hcengineering/model-view'
|
||||
import workbench, { workbenchId, createModel as workbenchModel } from '@hcengineering/model-workbench'
|
||||
import { guestId, createModel as guestModel } from '@hcengineering/model-guest'
|
||||
import { serverGuestId, createModel as serverGuestModel } from '@hcengineering/model-server-guest'
|
||||
|
||||
import { openAIId, createModel as serverOpenAI } from '@hcengineering/model-server-openai'
|
||||
import { createModel as serverTranslate, translateId } from '@hcengineering/model-server-translate'
|
||||
@@ -111,6 +113,7 @@ export default function buildModel (enabled: string[] = ['*'], disabled: string[
|
||||
[coreModel, coreId],
|
||||
[activityModel, activityId],
|
||||
[attachmentModel, attachmentId],
|
||||
[guestModel, guestId],
|
||||
[tagsModel, tagsId],
|
||||
[viewModel, viewId],
|
||||
[workbenchModel, workbenchId],
|
||||
@@ -298,7 +301,8 @@ export default function buildModel (enabled: string[] = ['*'], disabled: string[
|
||||
[serverViewModel, serverViewId],
|
||||
[serverActivityModel, serverActivityId],
|
||||
[serverTranslate, translateId],
|
||||
[serverOpenAI, openAIId]
|
||||
[serverOpenAI, openAIId],
|
||||
[serverGuestModel, serverGuestId]
|
||||
]
|
||||
|
||||
for (const [b, id, config] of builders) {
|
||||
|
||||
@@ -18,6 +18,7 @@ import { type MigrateOperation } from '@hcengineering/model'
|
||||
import { attachmentOperation } from '@hcengineering/model-attachment'
|
||||
import { chunterOperation } from '@hcengineering/model-chunter'
|
||||
import { contactOperation } from '@hcengineering/model-contact'
|
||||
import { guestOperation } from '@hcengineering/model-guest'
|
||||
import { coreOperation } from '@hcengineering/model-core'
|
||||
import { gmailOperation } from '@hcengineering/model-gmail'
|
||||
import { leadOperation } from '@hcengineering/model-lead'
|
||||
@@ -54,6 +55,7 @@ export const migrateOperations: [string, MigrateOperation][] = [
|
||||
['recruit', recruitOperation],
|
||||
['view', viewOperation],
|
||||
['contact', contactOperation],
|
||||
['guest', guestOperation],
|
||||
['tags', tagsOperation],
|
||||
['setting', settingOperation],
|
||||
['tracker', trackerOperation],
|
||||
|
||||
@@ -48,6 +48,7 @@
|
||||
"@hcengineering/templates": "^0.6.7",
|
||||
"@hcengineering/ui": "^0.6.11",
|
||||
"@hcengineering/view": "^0.6.9",
|
||||
"@hcengineering/model-guest": "^0.6.0",
|
||||
"cross-fetch": "^3.1.5"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -73,6 +73,7 @@ import templates from '@hcengineering/templates'
|
||||
import { type AnyComponent } from '@hcengineering/ui/src/types'
|
||||
import { type Action } from '@hcengineering/view'
|
||||
import contact from './plugin'
|
||||
import { createPublicLinkAction } from '@hcengineering/model-guest'
|
||||
|
||||
export { contactId } from '@hcengineering/contact'
|
||||
export { contactOperation } from './migration'
|
||||
@@ -1088,4 +1089,6 @@ export function createModel (builder: Builder): void {
|
||||
[],
|
||||
['comments', 'attachments']
|
||||
)
|
||||
|
||||
createPublicLinkAction(builder, contact.class.Contact, contact.action.PublicLink)
|
||||
}
|
||||
|
||||
@@ -123,7 +123,8 @@ export default mergeIds(contactId, contact, {
|
||||
KickEmployee: '' as Ref<Action>,
|
||||
DeleteEmployee: '' as Ref<Action>,
|
||||
MergePersons: '' as Ref<Action<Doc, any>>,
|
||||
OpenChannel: '' as Ref<Action>
|
||||
OpenChannel: '' as Ref<Action>,
|
||||
PublicLink: '' as Ref<Action<Doc, any>>
|
||||
},
|
||||
actionImpl: {
|
||||
KickEmployee: '' as ViewAction,
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
module.exports = {
|
||||
extends: ['./node_modules/@hcengineering/platform-rig/profiles/model/eslint.config.json'],
|
||||
parserOptions: {
|
||||
tsconfigRootDir: __dirname,
|
||||
project: './tsconfig.json'
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
*
|
||||
!/lib/**
|
||||
!CHANGELOG.md
|
||||
/lib/**/__tests__/
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/rig-package/rig.schema.json",
|
||||
"rigPackageName": "@hcengineering/platform-rig",
|
||||
"rigProfile": "model"
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"name": "@hcengineering/model-guest",
|
||||
"version": "0.6.0",
|
||||
"main": "lib/index.js",
|
||||
"author": "Anticrm Platform Contributors",
|
||||
"svelte": "src/index.ts",
|
||||
"types": "types/index.d.ts",
|
||||
"template": "@hcengineering/model-package",
|
||||
"license": "EPL-2.0",
|
||||
"scripts": {
|
||||
"build": "compile",
|
||||
"build:watch": "compile",
|
||||
"format": "format src",
|
||||
"_phase:build": "compile transpile src",
|
||||
"_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",
|
||||
"@typescript-eslint/parser": "^6.11.0",
|
||||
"eslint-config-standard-with-typescript": "^40.0.0",
|
||||
"prettier": "^3.1.0",
|
||||
"prettier-plugin-svelte": "^3.1.0",
|
||||
"typescript": "^5.3.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@hcengineering/core": "^0.6.28",
|
||||
"@hcengineering/model": "^0.6.7",
|
||||
"@hcengineering/model-core": "^0.6.0",
|
||||
"@hcengineering/model-view": "^0.6.0",
|
||||
"@hcengineering/guest": "^0.6.0",
|
||||
"@hcengineering/guest-resources": "^0.6.0",
|
||||
"@hcengineering/platform": "^0.6.9",
|
||||
"@hcengineering/ui": "^0.6.11",
|
||||
"@hcengineering/view": "^0.6.9"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
import { AccountRole, type Doc, type Domain, type Ref } from '@hcengineering/core'
|
||||
import { type PublicLink, type Restrictions, guestAccountEmail } from '@hcengineering/guest'
|
||||
import { type Builder, Model } from '@hcengineering/model'
|
||||
import core, { TDoc } from '@hcengineering/model-core'
|
||||
import { type Location } from '@hcengineering/ui'
|
||||
import guest from './plugin'
|
||||
|
||||
const GUEST_DOMAIN = 'guest' as Domain
|
||||
|
||||
@Model(guest.class.PublicLink, core.class.Doc, GUEST_DOMAIN)
|
||||
export class TPublicLink extends TDoc implements PublicLink {
|
||||
url!: string
|
||||
location!: Location
|
||||
restrictions!: Restrictions
|
||||
revokable!: boolean
|
||||
attachedTo!: Ref<Doc>
|
||||
}
|
||||
|
||||
export function createModel (builder: Builder): void {
|
||||
builder.createModel(TPublicLink)
|
||||
|
||||
builder.createDoc(
|
||||
core.class.Account,
|
||||
core.space.Model,
|
||||
{
|
||||
email: guestAccountEmail,
|
||||
role: AccountRole.Guest
|
||||
},
|
||||
guest.account.Guest
|
||||
)
|
||||
}
|
||||
|
||||
export { guestId } from '@hcengineering/guest'
|
||||
export * from './migration'
|
||||
export * from './utils'
|
||||
@@ -0,0 +1,97 @@
|
||||
import {
|
||||
type Account,
|
||||
AccountRole,
|
||||
DOMAIN_TX,
|
||||
type TxCreateDoc,
|
||||
TxOperations,
|
||||
type TxUpdateDoc
|
||||
} from '@hcengineering/core'
|
||||
import { guestId } from '@hcengineering/guest'
|
||||
import {
|
||||
type MigrateOperation,
|
||||
type MigrationClient,
|
||||
type MigrationUpgradeClient,
|
||||
type ModelLogger,
|
||||
tryMigrate
|
||||
} from '@hcengineering/model'
|
||||
import core from '@hcengineering/model-core'
|
||||
import guest from './plugin'
|
||||
|
||||
async function createSpace (tx: TxOperations): Promise<void> {
|
||||
const current = await tx.findOne(core.class.Space, {
|
||||
_id: guest.space.Links
|
||||
})
|
||||
if (current === undefined) {
|
||||
await tx.createDoc(
|
||||
core.class.Space,
|
||||
core.space.Space,
|
||||
{
|
||||
name: 'Links',
|
||||
description: 'Space for all guest links',
|
||||
private: false,
|
||||
archived: false,
|
||||
members: []
|
||||
},
|
||||
guest.space.Links
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
async function createDefaults (client: MigrationUpgradeClient): Promise<void> {
|
||||
const txOp = new TxOperations(client, core.account.System)
|
||||
await createSpace(txOp)
|
||||
}
|
||||
|
||||
export const guestOperation: MigrateOperation = {
|
||||
async migrate (client: MigrationClient, logger: ModelLogger): Promise<void> {
|
||||
await tryMigrate(client, guestId, [
|
||||
{
|
||||
state: 'migrateRoles',
|
||||
func: async (client) => {
|
||||
const stateMap = {
|
||||
0: AccountRole.User,
|
||||
1: AccountRole.Maintainer,
|
||||
2: AccountRole.Owner
|
||||
}
|
||||
const createTxes = await client.find<TxCreateDoc<Account>>(DOMAIN_TX, {
|
||||
_class: core.class.TxCreateDoc,
|
||||
'attributes.role': { $in: [0, 1, 2] }
|
||||
})
|
||||
for (const tx of createTxes) {
|
||||
await client.update(
|
||||
DOMAIN_TX,
|
||||
{
|
||||
_id: tx._id
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
'attributes.role': (stateMap as any)[tx.attributes.role]
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
const updateTxes = await client.find<TxUpdateDoc<Account>>(DOMAIN_TX, {
|
||||
_class: core.class.TxUpdateDoc,
|
||||
'operations.role': { $in: [0, 1, 2] }
|
||||
})
|
||||
for (const tx of updateTxes) {
|
||||
await client.update(
|
||||
DOMAIN_TX,
|
||||
{
|
||||
_id: tx._id
|
||||
},
|
||||
{
|
||||
$set: {
|
||||
'operations.role': (stateMap as any)[(tx.operations as any).role]
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
])
|
||||
},
|
||||
async upgrade (client: MigrationUpgradeClient): Promise<void> {
|
||||
await createDefaults(client)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import { type Account, type Doc, type Ref } from '@hcengineering/core'
|
||||
import { guestId } from '@hcengineering/guest'
|
||||
import guest from '@hcengineering/guest-resources/src/plugin'
|
||||
import { mergeIds } from '@hcengineering/platform'
|
||||
import { type AnyComponent } from '@hcengineering/ui'
|
||||
import { type Action, type ActionCategory } from '@hcengineering/view'
|
||||
|
||||
export default mergeIds(guestId, guest, {
|
||||
account: {
|
||||
Guest: '' as Ref<Account>
|
||||
},
|
||||
action: {
|
||||
CreatePublicLink: '' as Ref<Action<Doc, any>>
|
||||
},
|
||||
category: {
|
||||
Guest: '' as Ref<ActionCategory>
|
||||
},
|
||||
component: {
|
||||
CreatePublicLink: '' as AnyComponent
|
||||
}
|
||||
})
|
||||
@@ -0,0 +1,31 @@
|
||||
import { type Class, type Doc, type Ref } from '@hcengineering/core'
|
||||
import { type Builder } from '@hcengineering/model'
|
||||
import view, { createAction } from '@hcengineering/model-view'
|
||||
import { type Action } from '@hcengineering/view'
|
||||
import guest from './plugin'
|
||||
|
||||
export function createPublicLinkAction (builder: Builder, _class: Ref<Class<Doc>>, _id: Ref<Action<Doc, any>>): void {
|
||||
createAction(
|
||||
builder,
|
||||
{
|
||||
action: view.actionImpl.ShowPopup,
|
||||
actionProps: {
|
||||
component: guest.component.CreatePublicLink,
|
||||
element: 'top',
|
||||
fillProps: {
|
||||
_objects: 'value'
|
||||
}
|
||||
},
|
||||
label: guest.string.PublicLink,
|
||||
icon: guest.icon.Link,
|
||||
keyBinding: [],
|
||||
input: 'any',
|
||||
category: guest.category.Guest,
|
||||
target: _class,
|
||||
context: {
|
||||
mode: ['context', 'browser']
|
||||
}
|
||||
},
|
||||
_id
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"extends": "./node_modules/@hcengineering/platform-rig/profiles/model/tsconfig.json",
|
||||
|
||||
"compilerOptions": {
|
||||
"rootDir": "./src",
|
||||
"outDir": "./lib",
|
||||
"tsBuildInfoFile": ".build/build.tsbuildinfo"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
module.exports = {
|
||||
extends: ['./node_modules/@hcengineering/platform-rig/profiles/model/eslint.config.json'],
|
||||
parserOptions: {
|
||||
tsconfigRootDir: __dirname,
|
||||
project: './tsconfig.json'
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
*
|
||||
!/lib/**
|
||||
!CHANGELOG.md
|
||||
/lib/**/__tests__/
|
||||
@@ -0,0 +1,5 @@
|
||||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/rig-package/rig.schema.json",
|
||||
"rigPackageName": "@hcengineering/platform-rig",
|
||||
"rigProfile": "model"
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
{
|
||||
"name": "@hcengineering/model-server-guest",
|
||||
"version": "0.6.0",
|
||||
"main": "lib/index.js",
|
||||
"svelte": "src/index.ts",
|
||||
"types": "types/index.d.ts",
|
||||
"author": "Anticrm Platform Contributors",
|
||||
"template": "@hcengineering/model-package",
|
||||
"license": "EPL-2.0",
|
||||
"scripts": {
|
||||
"build": "compile",
|
||||
"build:watch": "compile",
|
||||
"format": "format src",
|
||||
"_phase:build": "compile transpile src",
|
||||
"_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",
|
||||
"@typescript-eslint/parser": "^6.11.0",
|
||||
"eslint-config-standard-with-typescript": "^40.0.0",
|
||||
"prettier": "^3.1.0",
|
||||
"prettier-plugin-svelte": "^3.1.0",
|
||||
"typescript": "^5.3.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@hcengineering/core": "^0.6.28",
|
||||
"@hcengineering/model": "^0.6.7",
|
||||
"@hcengineering/platform": "^0.6.9",
|
||||
"@hcengineering/guest": "^0.6.0",
|
||||
"@hcengineering/server-guest": "^0.6.0",
|
||||
"@hcengineering/server-core": "^0.6.1"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
//
|
||||
// Copyright © 2024 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 Builder } from '@hcengineering/model'
|
||||
|
||||
import core from '@hcengineering/core'
|
||||
import guest from '@hcengineering/guest'
|
||||
import serverCore from '@hcengineering/server-core'
|
||||
import serverGuest from '@hcengineering/server-guest'
|
||||
|
||||
export { serverGuestId } from '@hcengineering/server-guest'
|
||||
|
||||
export function createModel (builder: Builder): void {
|
||||
builder.createDoc(serverCore.class.Trigger, core.space.Model, {
|
||||
trigger: serverGuest.trigger.OnPublicLinkCreate,
|
||||
txMatch: {
|
||||
_class: core.class.TxCreateDoc,
|
||||
objectClass: guest.class.PublicLink,
|
||||
'attributes.url': ''
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"extends": "./node_modules/@hcengineering/platform-rig/profiles/model/tsconfig.json",
|
||||
|
||||
"compilerOptions": {
|
||||
"rootDir": "./src",
|
||||
"outDir": "./lib",
|
||||
"tsBuildInfoFile": ".build/build.tsbuildinfo"
|
||||
}
|
||||
}
|
||||
@@ -38,6 +38,7 @@
|
||||
"@hcengineering/model-core": "^0.6.0",
|
||||
"@hcengineering/model-presentation": "^0.6.0",
|
||||
"@hcengineering/model-tags": "^0.6.0",
|
||||
"@hcengineering/model-guest": "^0.6.0",
|
||||
"@hcengineering/model-view": "^0.6.0",
|
||||
"@hcengineering/model-workbench": "^0.6.1",
|
||||
"@hcengineering/platform": "^0.6.9",
|
||||
|
||||
@@ -83,6 +83,7 @@ import {
|
||||
import type { AnyComponent } from '@hcengineering/ui'
|
||||
import { PaletteColorIndexes } from '@hcengineering/ui/src/colors'
|
||||
import { type ViewAction } from '@hcengineering/view'
|
||||
import { createPublicLinkAction } from '@hcengineering/model-guest'
|
||||
|
||||
import task from './plugin'
|
||||
|
||||
@@ -557,6 +558,8 @@ export function createModel (builder: Builder): void {
|
||||
},
|
||||
task.ids.ManageProjects
|
||||
)
|
||||
|
||||
createPublicLinkAction(builder, task.class.Task, task.action.PublicLink)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
//
|
||||
|
||||
import {} from '@hcengineering/notification'
|
||||
import type { Ref, Space } from '@hcengineering/core'
|
||||
import type { Doc, Ref, Space } from '@hcengineering/core'
|
||||
import { mergeIds, type IntlString } from '@hcengineering/platform'
|
||||
import { type TagCategory } from '@hcengineering/tags'
|
||||
import { taskId } from '@hcengineering/task'
|
||||
@@ -28,7 +28,8 @@ export default mergeIds(taskId, task, {
|
||||
EditStatuses: '' as Ref<Action>,
|
||||
ArchiveSpace: '' as Ref<Action>,
|
||||
UnarchiveSpace: '' as Ref<Action>,
|
||||
ArchiveState: '' as Ref<Action>
|
||||
ArchiveState: '' as Ref<Action>,
|
||||
PublicLink: '' as Ref<Action<Doc, any>>
|
||||
},
|
||||
actionImpl: {
|
||||
EditStatuses: '' as ViewAction,
|
||||
|
||||
@@ -233,7 +233,6 @@ export class TIssue extends TTask implements Issue {
|
||||
estimation!: number
|
||||
|
||||
@Prop(TypeReportedTime(), tracker.string.ReportedTime)
|
||||
@ReadOnly()
|
||||
reportedTime!: number
|
||||
|
||||
@Prop(TypeRemainingTime(), tracker.string.RemainingTime)
|
||||
|
||||
Reference in New Issue
Block a user