Skip to content

Use rowid for message id and allow provide date #44

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

Merged
merged 3 commits into from
Apr 16, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.1.168
0.1.170
4 changes: 3 additions & 1 deletion bun.lock
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"@hcengineering/communication-shared": "workspace:*",
"@hcengineering/communication-types": "workspace:*",
"postgres": "^3.4.4",
"uuid": "^11.0.3",
"uuid": "^11.1.0",
},
"devDependencies": {
"@types/bun": "^1.1.14",
Expand All @@ -57,6 +57,7 @@
"@hcengineering/communication-types": "workspace:*",
"@hcengineering/communication-yaml": "workspace:*",
"fast-equals": "^5.0.1",
"uuid": "^11.1.0",
},
"devDependencies": {
"@types/bun": "^1.1.14",
Expand Down Expand Up @@ -125,6 +126,7 @@
"name": "@hcengineering/communication-shared",
"version": "0.1.0",
"dependencies": {
"@hcengineering/communication-sdk-types": "workspace:*",
"@hcengineering/communication-types": "workspace:*",
},
"devDependencies": {
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"lint": "turbo run lint",
"format": "turbo run format",
"reformat": "turbo run format && turbo run lint -- --fix",
"format:check": "prettier --check \"**/*.ts\""
"format:check": "prettier --check \"**/*.ts\"",
"clean": "turbo run clean"
},
"devDependencies": {
"@eslint/js": "^9.24.0",
Expand Down
5 changes: 3 additions & 2 deletions packages/client-query/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@hcengineering/communication-client-query",
"version": "0.1.0",
"main": "src/index.ts",
"main": "dist/index.js",
"module": "dist/index.js",
"types": "./types/index.d.ts",
"files": [
Expand All @@ -14,7 +14,8 @@
"build:types": "tsc --project ./tsconfig.json --emitDeclarationOnly --declarationDir ./types",
"build:browser": "bun build src/index.ts --outdir dist --target browser",
"lint": "eslint src/*.ts",
"format": "prettier --write src/**/*.ts "
"format": "prettier --write src/**/*.ts ",
"clean": "rm -rf dist && rm -rf types && rm -rf .turbo"
},
"devDependencies": {
"@types/bun": "^1.1.14"
Expand Down
5 changes: 3 additions & 2 deletions packages/client-query/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@
// limitations under the License.
//

import { LiveQueries, type QueryClient } from '@hcengineering/communication-query'
import { LiveQueries } from '@hcengineering/communication-query'
import type { WorkspaceID } from '@hcengineering/communication-types'
import type { FindClient } from '@hcengineering/communication-sdk-types'

import { LabelsQuery, MessagesQuery, NotificationContextsQuery, NotificationsQuery } from './query'

Expand All @@ -38,7 +39,7 @@ export function createLabelsQuery(): LabelsQuery {
}

export function initLiveQueries(
client: QueryClient,
client: FindClient,
workspace: WorkspaceID,
filesUrl: string,
destroyFn?: (fn: () => void) => void
Expand Down
7 changes: 4 additions & 3 deletions packages/cockroach/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@hcengineering/communication-cockroach",
"version": "0.1.0",
"main": "src/index.ts",
"main": "dist/index.js",
"module": "dist/index.js",
"types": "./types/index.d.ts",
"files": [
Expand All @@ -14,7 +14,8 @@
"build:types": "tsc --project ./tsconfig.json --emitDeclarationOnly --declarationDir ./types",
"build:node": "bun build src/index.ts --target node --format cjs --outfile dist/index.js",
"lint": "eslint src/*.ts",
"format": "prettier --write src/**/*.ts"
"format": "prettier --write src/**/*.ts",
"clean": "rm -rf dist && rm -rf types && rm -rf .turbo"
},
"devDependencies": {
"@types/bun": "^1.1.14"
Expand All @@ -24,7 +25,7 @@
"@hcengineering/communication-sdk-types": "workspace:*",
"@hcengineering/communication-types": "workspace:*",
"postgres": "^3.4.4",
"uuid": "^11.0.3"
"uuid": "^11.1.0"
},
"peerDependencies": {
"typescript": "^5.6.3"
Expand Down
29 changes: 22 additions & 7 deletions packages/cockroach/src/adapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,13 @@ export class CockroachAdapter implements DbAdapter {
async createPatch(
card: CardID,
message: MessageID,
messageCreated: Date,
type: PatchType,
content: RichText,
creator: SocialID,
created: Date
): Promise<void> {
await this.message.createPatch(card, message, type, content, creator, created)
await this.message.createPatch(card, message, messageCreated, type, content, creator, created)
}

async createMessagesGroup(card: CardID, blobId: BlobID, fromDate: Date, toDate: Date, count: number): Promise<void> {
Expand All @@ -108,36 +109,50 @@ export class CockroachAdapter implements DbAdapter {
async createReaction(
card: CardID,
message: MessageID,
messageCreated: Date,
reaction: string,
creator: SocialID,
created: Date
): Promise<void> {
await this.message.createReaction(card, message, reaction, creator, created)
await this.message.createReaction(card, message, messageCreated, reaction, creator, created)
}

async removeReaction(card: CardID, message: MessageID, reaction: string, creator: SocialID): Promise<void> {
await this.message.removeReaction(card, message, reaction, creator, new Date())
async removeReaction(
card: CardID,
message: MessageID,
messageCreated: Date,
reaction: string,
creator: SocialID
): Promise<void> {
await this.message.removeReaction(card, message, messageCreated, reaction, creator, new Date())
}

async createFile(
card: CardID,
message: MessageID,
messageCreated: Date,
blobId: BlobID,
fileType: string,
filename: string,
size: number,
creator: SocialID,
created: Date
): Promise<void> {
await this.message.createFile(card, message, blobId, fileType, filename, size, creator, created)
await this.message.createFile(card, message, messageCreated, blobId, fileType, filename, size, creator, created)
}

async removeFile(card: CardID, message: MessageID, blobId: BlobID): Promise<void> {
await this.message.removeFile(card, message, blobId)
}

async createThread(card: CardID, message: MessageID, thread: CardID, created: Date): Promise<void> {
await this.message.createThread(card, message, thread, created)
async createThread(
card: CardID,
message: MessageID,
messageCreated: Date,
thread: CardID,
created: Date
): Promise<void> {
await this.message.createThread(card, message, messageCreated, thread, created)
}

async updateThread(thread: CardID, op: 'increment' | 'decrement', lastReply?: Date): Promise<void> {
Expand Down
20 changes: 12 additions & 8 deletions packages/cockroach/src/db/mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,8 @@ interface RawNotification extends NotificationDb {
message_external_id?: string
message_created?: Date
message_group_blob_id?: BlobID
message_group_from_sec?: Date
message_group_to_sec?: Date
message_group_from_date?: Date
message_group_to_date?: Date
message_group_count?: number
message_patches?: {
patch_type: PatchType
Expand Down Expand Up @@ -100,6 +100,7 @@ export function toMessage(raw: RawMessage): Message {
? {
card: raw.card_id,
message: String(raw.id) as MessageID,
messageCreated: new Date(raw.created),
thread: raw.thread_id,
repliesCount: raw.replies_count ?? 0,
lastReply: raw.last_reply ?? new Date()
Expand All @@ -123,6 +124,7 @@ export function toFile(raw: FileDb): File {
return {
card: raw.card_id,
message: String(raw.message_id) as MessageID,
messageCreated: new Date(raw.message_created),
blobId: raw.blob_id,
type: raw.type,
filename: raw.filename,
Expand All @@ -136,16 +138,17 @@ export function toMessagesGroup(raw: MessagesGroupDb): MessagesGroup {
return {
card: raw.card_id,
blobId: raw.blob_id,
fromSec: raw.from_sec,
toSec: raw.to_sec,
count: raw.count,
fromDate: raw.from_date,
toDate: raw.to_date,
count: Number(raw.count),
patches: raw.patches == null ? [] : raw.patches.filter((it: any) => it.message_id != null).map(toPatch)
}
}

export function toPatch(raw: PatchDb): Patch {
return {
type: raw.type,
messageCreated: new Date(raw.message_created),
message: String(raw.message_id) as MessageID,
content: raw.content,
creator: raw.creator,
Expand All @@ -157,6 +160,7 @@ export function toThread(raw: ThreadDb): Thread {
return {
card: raw.card_id,
message: String(raw.message_id) as MessageID,
messageCreated: new Date(raw.message_created),
thread: raw.thread_id,
repliesCount: raw.replies_count,
lastReply: raw.last_reply
Expand Down Expand Up @@ -223,12 +227,12 @@ function toNotificationRaw(

let messageGroup: MessagesGroup | undefined

if (raw.message_group_blob_id != null && raw.message_group_from_sec != null && raw.message_group_to_sec != null) {
if (raw.message_group_blob_id != null && raw.message_group_from_date != null && raw.message_group_to_date != null) {
messageGroup = {
card,
blobId: raw.message_group_blob_id,
fromSec: new Date(raw.message_group_from_sec),
toSec: new Date(raw.message_group_to_sec),
fromDate: new Date(raw.message_group_from_date),
toDate: new Date(raw.message_group_to_date),
count: raw.message_group_count ?? 0
}
}
Expand Down
Loading
Loading