Skip to content

Commit

Permalink
feat: updated document-drive dep (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
acaldas authored Feb 6, 2024
1 parent 6cbdcc9 commit 2ce57e2
Show file tree
Hide file tree
Showing 10 changed files with 4,618 additions and 19 deletions.
2 changes: 1 addition & 1 deletion api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"body-parser": "^1.20.2",
"cookie-parser": "^1.4.6",
"cors": "^2.8.5",
"document-drive": "^0.0.27",
"document-drive": "powerhouse-inc/document-drive#ec00335",
"document-model": "^1.0.24",
"document-model-libs": "^1.1.37",
"dotenv": "^16.0.3",
Expand Down
32 changes: 31 additions & 1 deletion api/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ model Document {
operations Operation[]
initialState Json // json object with the scope as keys of the root object
documentType String
syncronizationUnits SyncronizationUnit[]
@@id([id, driveId])
}
Expand All @@ -70,17 +71,36 @@ model Operation {
scope String
branch String
index Int
skip Int
hash String
timestamp DateTime
input Json
type String
attachments Attachment[]
syncId String?
SyncronizationUnit SyncronizationUnit? @relation(fields: [syncId, driveId], references: [id, driveId])
@@id([driveId, documentId, scope, branch, index])
}

model SyncronizationUnit {
id String
driveId String
documentId String
Document Document @relation(fields: [documentId, driveId], references: [id, driveId])
scope String
branch String
operations Operation[]
@@id([id, driveId])
}

model Attachment {
id String @id @default(uuid())
driveId String
documentId String
scope String
Expand All @@ -93,6 +113,16 @@ model Attachment {
filename String
extension String
hash String
}

model Listener {
listenerId String @id @default(uuid())
driveId String
label String?
block Boolean
system Boolean
@@id([driveId, documentId, scope, branch, index, hash])
filter Json
callInfo Json
}
8 changes: 4 additions & 4 deletions api/src/generated/nexus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export interface NexusGenInputs {
icon?: string | null; // String
id: string; // ID!
name: string; // String!
remoteUrl?: string | null; // String
slug?: string | null; // String
}
InputListenerFilter: { // input type
branch?: Array<string | null> | null; // [String]
Expand Down Expand Up @@ -129,7 +129,7 @@ export interface NexusGenObjects {
id: string; // ID!
name: string; // String!
nodes: Array<NexusGenRootTypes['Node'] | null>; // [Node]!
remoteUrl?: string | null; // String
slug?: string | null; // String
}
Listener: { // root type
block: boolean; // Boolean!
Expand Down Expand Up @@ -242,7 +242,7 @@ export interface NexusGenFieldTypes {
id: string; // ID!
name: string; // String!
nodes: Array<NexusGenRootTypes['Node'] | null>; // [Node]!
remoteUrl: string | null; // String
slug: string | null; // String
}
Listener: { // field return type
block: boolean; // Boolean!
Expand Down Expand Up @@ -364,7 +364,7 @@ export interface NexusGenFieldTypeNames {
id: 'ID'
name: 'String'
nodes: 'Node'
remoteUrl: 'String'
slug: 'String'
}
Listener: { // field return type name
block: 'Boolean'
Expand Down
4 changes: 2 additions & 2 deletions api/src/generated/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ type DocumentDriveState {
id: ID!
name: String!
nodes: [Node]!
remoteUrl: String
slug: String
}

input DocumentDriveStateInput {
icon: String
id: ID!
name: String!
remoteUrl: String
slug: String
}

input InputListenerFilter {
Expand Down
4 changes: 2 additions & 2 deletions api/src/modules/DocumentDrive/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export const DocumentDriveStateInput = inputObjectType({
t.nonNull.id("id");
t.nonNull.string("name");
t.string("icon");
t.string("remoteUrl");
t.string("slug");
},
});

Expand Down Expand Up @@ -138,7 +138,7 @@ export const DocumentDriveState = objectType({
t.nonNull.string("name");
t.nonNull.list.field("nodes", { type: Node });
t.string("icon");
t.string("remoteUrl");
t.string("slug");
},
});

Expand Down
10 changes: 4 additions & 6 deletions api/src/modules/DocumentDrive/model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@ import {
DocumentDriveServer,
DriveInput,
ListenerRevision,
MemoryStorage,
PrismaStorage,
StrandUpdate,
generateUUID,
PullResponderTransmitter
} from "document-drive";
import { PrismaStorage } from "document-drive/storage/prisma";
import * as DocumentModelsLibs from "document-model-libs/document-models";
import { module as DocumentModelLib } from "document-model/document-model";
import { DocumentModel, Operation } from "document-model/document";
import { PullResponderTransmitter } from "document-drive";
import {
utils as DocumentDriveUtils,
Listener,
ListenerFilter,
actions,
Expand Down Expand Up @@ -146,7 +144,7 @@ export function getDocumentDriveCRUD(prisma: Prisma.TransactionClient) {
return result;
},

acknowledgeStrands: async (
processAcknowledge: async (
driveId: string,
listenerId: string,
revisions: ListenerRevision[]
Expand All @@ -158,7 +156,7 @@ export function getDocumentDriveCRUD(prisma: Prisma.TransactionClient) {
if (!transmitter) {
throw new Error(`Transmitter with id ${listenerId} not found`);
}
return await transmitter.acknowledgeStrands(
return await transmitter.processAcknowledge(
driveId,
listenerId,
revisions
Expand Down
2 changes: 1 addition & 1 deletion api/src/modules/DocumentDrive/mutations/acknowledge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const acknowledge = mutationField("acknowledge", {
status: e!.status as UpdateStatus,
}));

return await ctx.prisma.document.acknowledgeStrands(
return await ctx.prisma.document.processAcknowledge(
ctx.driveId ?? "1",
listenerId,
validEntries
Expand Down
2 changes: 1 addition & 1 deletion api/src/modules/DocumentDrive/mutations/addDrive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const addDrive = mutationField("addDrive", {
await ctx;
return await ctx.prisma.document.addDrive({
global: { ...global, nodes: [] },
local: { ...local, listeners: [] },
local: { ...local, listeners: [], triggers: [] },
});
},
});
1 change: 0 additions & 1 deletion api/src/modules/DocumentDrive/mutations/pushUpdates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ export const pushUpdates = mutationField("pushUpdates", {
s.documentId ?? undefined
);

console.log(result);
listenerRevisions.push({
branch: s.branch,
documentId: s.documentId ?? "",
Expand Down
Loading

0 comments on commit 2ce57e2

Please sign in to comment.