Skip to content
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

Model update #42

Merged
merged 12 commits into from
Mar 20, 2024
Merged
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
22 changes: 22 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -12,6 +12,28 @@ By default, the tests and scripts run against a local Ceramic/ComposeDB node wit

The protocol documentation can be found [here](https://codex.desci.com)!

## State of models
There is still iteration on the design of the models as we are starting with backwards-compatible rollout on the ResearchObject with intact manifests. As we experiment with putting more and more of the manifest content on streams, the model design will stabilise.

**Alpha** means that the model, and hence the ID, will likely change.
**Beta** means that the model is somewhat stable, but there may be an upgrade requiring a migration.
**Stable** means the model is stable, and if any change is necessary we are commited in solving for backward compatibility.

| Model | Status | ID (Clay) | ID (Mainnet) |
|-----------------------|--------|-----------------------------------------------------------------|--------------|
| ResearchObject | beta | kjzl6hvfrbw6cbe01it6hlcwopsv4cqrqysho4f1xd7rtqxew9yag3x2wxczhz0 | N/A |
| Profile | alpha | kjzl6hvfrbw6cba0l4xuvi4ll36h3s21kcau1wpq51ha6k8ttc8yw5kzx2g40in | N/A |
| Claim | alpha | kjzl6hvfrbw6c6hz18jqthpsvvjvixg8xkvrec10l5nbwqc67vi6lvhgkc7j0ti | N/A |
| Attestation | alpha | kjzl6hvfrbw6c9gw5pagxy4ig2f9lqpexycdl5lq9jfy11itm38f3nco4ud8699 | N/A |
| ResearchComponent | alpha | kjzl6hvfrbw6c9mh61r73r6o7lfmo8u7d2ygka8yqgwn4wwtl45xsv51uds87dh | N/A |
| SocialHandle | alpha | kjzl6hvfrbw6c6t1shl3fextieopqswv96xuhmfh4c3h66eqj3zx3ivddg9axq2 | N/A |
| Annotation | alpha | kjzl6hvfrbw6c5j2xqk6s2hraoxs49pk1hfsrj6ht5tqmqhwupqarjvafx9l6n6 | N/A |
| ContributorRelation | alpha | kjzl6hvfrbw6c5qmeyibuvf351c9gcpmbvjmclzgz74wwskd8pr3jzuy8anvz1h | N/A |
| ReferenceRelation | alpha | kjzl6hvfrbw6cackjf6z5qcaz9zhh9sezssa7usx4r9rc7to5xowogxr3ssbpor | N/A |
| ResearchField | alpha | kjzl6hvfrbw6caae58yly0aahfzqewu1dfhlc00042i08wg4anar5xj7lbahzz8 | N/A |
| ResearchFieldRelation | alpha | kjzl6hvfrbw6c7aug8sphy4eae684t9wbqb5g15r0grssurt51sllba689318co | N/A |


## Getting started

1. Install dependencies:
38,865 changes: 22,848 additions & 16,017 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -25,8 +25,5 @@
"prettier": "^3.1.0",
"typedoc": "^0.25.4",
"typescript": "^5.2.2"
},
"dependencies": {
"@desci-labs/desci-models": "^0.1.22"
}
}
1 change: 0 additions & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -40,7 +40,6 @@
"mocha": "^10",
"oclif": "^4.0.4",
"shx": "^0.3.4",
"ts-node": "^10.9.1",
"typescript": "^5"
},
"engines": {
6 changes: 6 additions & 0 deletions packages/cli/src/commands/create/research-object.ts
Original file line number Diff line number Diff line change
@@ -8,6 +8,11 @@ export default class ResearchObject extends BaseCommand {
static description = 'Create a new research object'

static flags = {
license: Flags.string({
chat: 'l',
description: 'Default license on content',
required: true,
}),
manifest: Flags.string({
char: 'm',
description: 'Manifest file CID',
@@ -26,6 +31,7 @@ export default class ResearchObject extends BaseCommand {
const ceramic = await authenticatedCeramicClient(flags.didSeed, flags.ceramicNode)
const client = newComposeClient({ceramic})
const ids = await createResearchObject(client, {
license: flags.license,
manifest: flags.manifest,
title: flags.title,
})
5 changes: 5 additions & 0 deletions packages/cli/src/commands/update/research-object.ts
Original file line number Diff line number Diff line change
@@ -12,6 +12,10 @@ export default class ResearchObject extends BaseCommand {
description: 'ID of the research object to update',
required: true,
}),
license: Flags.string({
char: 'l',
description: 'License for research object contents',
}),
manifest: Flags.string({
char: 'm',
description: 'Manifest file CID',
@@ -29,6 +33,7 @@ export default class ResearchObject extends BaseCommand {
const client = newComposeClient({ceramic})
const ids = await updateResearchObject(client, {
id: flags.id,
license: flags.license,
manifest: flags.manifest,
title: flags.title,
})
4 changes: 2 additions & 2 deletions packages/composedb/Makefile
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@ clean:
rm -rf local-data

clean-test:
rm -rf packages/composedb/local-data/ceramic-test
rm -rf local-data/ceramic-test

start-test-env: clean-test generate
if pgrep --older 1 --count --full "ceramic daemon|ipfs daemon"; then \
@@ -17,7 +17,7 @@ start-test-env: clean-test generate
sed 's|local-data/ceramic|local-data/ceramic-test|' composedb.config.json \
> test.config.json
npx ceramic daemon --config test.config.json &>/dev/null &
sleep 5
sleep 10

npm run deployComposites

3 changes: 1 addition & 2 deletions packages/composedb/composites/1-claim.graphql
Original file line number Diff line number Diff line change
@@ -3,8 +3,7 @@ type Claim
accountRelation: LIST
description: "A reusable claim to be granted via attestation"
)
# @createIndex(fields: [{ path: "title" }])
# @createIndex(fields: [{ path: "badge" }])
@createIndex(fields: [{ path: "title" }])
{
owner: DID! @documentAccount
version: CommitID! @documentVersion
5 changes: 4 additions & 1 deletion packages/composedb/composites/1-researchObject.graphql
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
type ResearchObject
@createModel(accountRelation: LIST, description: "A research object")
# @createIndex(fields: [{ path: "title" }])
@createIndex(fields: [{ path: "title" }])
@createIndex(fields: [{ path: "license" }])
@createIndex(fields: [{ path: "manifest" }])
{
owner: DID! @documentAccount
version: CommitID! @documentVersion
title: String! @string(maxLength: 250)
license: String! @string(maxLength: 100)
manifest: CID!
metadata: CID
}
4 changes: 2 additions & 2 deletions packages/composedb/composites/1-socialHandle.graphql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
type SocialHandle
@createModel(accountRelation: LIST, description: "A social handle on other platforms")
# @createIndex(fields: [{ path: "platform"}])
# @createIndex(fields: [{ path: "handle"}])
@createIndex(fields: [{ path: "platform"}])
@createIndex(fields: [{ path: "handle"}])
{
owner: DID! @documentAccount
version: CommitID! @documentVersion
34 changes: 13 additions & 21 deletions packages/composedb/composites/2-annotation.graphql
Original file line number Diff line number Diff line change
@@ -8,27 +8,27 @@ type ResearchObject @loadModel(id: "$RESEARCH_OBJECT_ID") {

type Annotation
@createModel(accountRelation: LIST, description: "Textual commentary")
# @createIndex(fields: [{ path: "targetID" }])
# @createIndex(fields: [{ path: "claimID" }])
# @createIndex(fields: [{ path: "researchObjectID" }])
# @createIndex(fields: [{ path: "dagNode" }])
@createIndex(fields: [{ path: "parentID" }])
@createIndex(fields: [{ path: "claimID" }])
@createIndex(fields: [{ path: "dagNode" }])
{
owner: DID! @documentAccount
version: CommitID! @documentVersion

# Textual commentary on target
comment: String! @string(maxLength: 1024)

# Research object context
researchObjectID: StreamID! @documentReference(model: "ResearchObject")
researchObject: ResearchObject!
@relationDocument(property: "researchObjectID")
researchObjectVersion: CommitID!
# Optionally tag a claim to contextualise the annotation
claimID: StreamID @documentReference(model: "Claim") @immutable
claim: Claim @relationDocument(property: "claimID")
claimVersion: CommitID

# Research component or annotation as reply
# TODO: interface
targetID: StreamID
targetVersion: CommitID
# Annotation (indicates a reply)
parentID: StreamID @immutable
# direct self-references are non-trivial apparently
#parentID: StreamID @documentReference(model: "Annotation") @immutable
parent: Annotation @relationDocument(property: "parentID")
parentVersion: CommitID

# Alternatively, directly annotate a raw DAG node without a component.
# Path is necessary because CID is not necessarily unique.
@@ -38,12 +38,4 @@ type Annotation
# Localization of the annotation payload, depending on file type.
# For example a JSON path, line number, or coordinates.
locationOnFile: String @string(maxLength: 512)

# Optionally tag a claim to contextualise the annotation
claimID: StreamID @documentReference(model: "Claim")
claim: Claim @relationDocument(property: "claimID")
claimVersion: CommitID

# Optionally suggest changes to metadata with a diff
metadataPayload: CID
}
12 changes: 6 additions & 6 deletions packages/composedb/composites/2-attestation.graphql
Original file line number Diff line number Diff line change
@@ -4,22 +4,22 @@ type Claim @loadModel(id: "$CLAIM_ID") {

type Attestation
@createModel(accountRelation: LIST, description: "General attestation")
# @createIndex(fields: [{ path: "revoked" }])
# @createIndex(fields: [{ path: "targetVersion" }])
# @createIndex(fields: [{ path: "claimVersion" }])
@createIndex(fields: [{ path: "targetID" }])
@createIndex(fields: [{ path: "claimID" }])
@createIndex(fields: [{ path: "revoked" }])
{
owner: DID! @documentAccount
version: CommitID! @documentVersion
# 1. Any type of document, shown with relation on reciever end but cannot use
# @documentRelation without specifying the target type before interfaces land
# 2. This cannot be a DID, so attestations to people target the Profile
targetID: StreamID!
targetID: StreamID! @immutable
targetVersion: CommitID!

claimID: StreamID! @documentReference(model: "Claim")
claimID: StreamID! @documentReference(model: "Claim") @immutable
claim: Claim! @relationDocument(property: "claimID")
claimVersion: CommitID!

# Revoke this attestation
revoked: Boolean
revoked: Boolean!
}
12 changes: 7 additions & 5 deletions packages/composedb/composites/2-contributorRelation.graphql
Original file line number Diff line number Diff line change
@@ -11,17 +11,19 @@ type ContributorRelation
accountRelation: LIST
description: "List a contributor on a research object"
)
# @createIndex(fields: [{ path: "role" }])
# @createIndex(fields: [{ path: "revoked" }])
# @createIndex(fields: [{ path: "researchObjectVersion" }])
@createIndex(fields: [{ path: "role" }])
@createIndex(fields: [{ path: "researchObjectID" }])
@createIndex(fields: [{ path: "revoked" }])
{
owner: DID! @documentAccount
version: CommitID! @documentVersion

# E.g. credit taxonomy
role: String! @string(maxLength: 256)

researchObjectID: StreamID! @documentReference(model: "ResearchObject")
researchObjectID: StreamID!
@documentReference(model: "ResearchObject")
@immutable
researchObject: ResearchObject!
@relationDocument(property: "researchObjectID")
researchObjectVersion: CommitID!
@@ -36,5 +38,5 @@ type ContributorRelation
fallbackInfo: String @string(maxLength: 1024)

# Revoke this relation
revoked: Boolean
revoked: Boolean!
}
12 changes: 6 additions & 6 deletions packages/composedb/composites/2-referenceRelation.graphql
Original file line number Diff line number Diff line change
@@ -7,21 +7,21 @@ type ReferenceRelation
accountRelation: LIST
description: "Indicate a reference between research objects"
)
# @createIndex(fields: [{ path: "fromVersion" }])
# @createIndex(fields: [{ path: "toVersion" }])
# @createIndex(fields: [{ path: "revoked" }])
@createIndex(fields: [{ path: "fromID" }])
@createIndex(fields: [{ path: "toID" }])
@createIndex(fields: [{ path: "revoked" }])
{
owner: DID! @documentAccount
version: CommitID! @documentVersion

fromID: StreamID! @documentReference(model: "ResearchObject")
fromID: StreamID! @documentReference(model: "ResearchObject") @immutable
from: ResearchObject! @relationDocument(property: "fromID")
fromVersion: CommitID!

toID: StreamID! @documentReference(model: "ResearchObject")
toID: StreamID! @documentReference(model: "ResearchObject") @immutable
to: ResearchObject! @relationDocument(property: "toID")
toVersion: CommitID!

# Revoke this relation
revoked: Boolean
revoked: Boolean!
}
10 changes: 6 additions & 4 deletions packages/composedb/composites/2-researchComponent.graphql
Original file line number Diff line number Diff line change
@@ -7,10 +7,10 @@ type ResearchComponent
accountRelation: LIST
description: "A contextualized DAG pointer for a research object"
)
# @createIndex(fields: [{ path: "mimeType" }])
# @createIndex(fields: [{ path: "researchObjectVersion" }])
@createIndex(fields: [{ path: "mimeType" }])
@createIndex(fields: [{ path: "researchObjectVersion" }])
# Don't join index with path as it prevents efficient reverse CID lookups
# @createIndex(fields: [{ path: "dagNode" }])
@createIndex(fields: [{ path: "dagNode" }])
{
owner: DID! @documentAccount
version: CommitID! @documentVersion
@@ -23,7 +23,9 @@ type ResearchComponent
pathToNode: String! @string(maxLength: 512)

# The associated research object
researchObjectID: StreamID! @documentReference(model: "ResearchObject")
researchObjectID: StreamID!
@documentReference(model: "ResearchObject")
@immutable
researchObject: ResearchObject!
@relationDocument(property: "researchObjectID")
researchObjectVersion: CommitID!
9 changes: 5 additions & 4 deletions packages/composedb/composites/2-researchFieldRelation.graphql
Original file line number Diff line number Diff line change
@@ -14,15 +14,16 @@ type ResearchFieldRelation
owner: DID! @documentAccount
version: CommitID! @documentVersion

researchObjectID: StreamID! @documentReference(model: "ResearchObject")
researchObjectID: StreamID!
@documentReference(model: "ResearchObject")
@immutable
researchObject: ResearchObject!
@relationDocument(property: "researchObjectID")
researchObjectVersion: CommitID!

# Skipping stream versioning on field refs
fieldID: StreamID! @documentReference(model: "ResearchField")
fieldID: StreamID! @documentReference(model: "ResearchField") @immutable
field: ResearchField! @relationDocument(property: "fieldID")

# Revoke this relation
revoked: Boolean
revoked: Boolean!
}
19 changes: 6 additions & 13 deletions packages/composedb/composites/3-additionalRelations.graphql
Original file line number Diff line number Diff line change
@@ -15,18 +15,16 @@ type ResearchFieldRelation @loadModel(id: "$RESEARCH_FIELD_RELATION_ID") {
id: ID!
}

type Annotation @loadModel(id: "$ANNOTATION_ID") {
replies: [Annotation] @relationFrom(model: "Annotation", property: "targetID")
replyCount: Int! @relationCountFrom(model: "Annotation", property: "targetID")
type ResearchComponent @loadModel(id: "$RESEARCH_COMPONENT_ID") {
id: ID!
}

type ResearchComponent @loadModel(id: "$RESEARCH_COMPONENT_ID") {
annotations: [Annotation]
@relationFrom(model: "Annotation", property: "targetID")
annotationCount: Int!
@relationCountFrom(model: "Annotation", property: "targetID")
type Annotation @loadModel(id: "$ANNOTATION_ID") {
replies: [Annotation] @relationFrom(model: "Annotation", property: "parentID")
replyCount: Int! @relationCountFrom(model: "Annotation", property: "parentID")
}


type Claim @loadModel(id: "$CLAIM_ID") {
attestations: [Attestation]
@relationFrom(model: "Attestation", property: "claimID")
@@ -69,11 +67,6 @@ type ResearchObject @loadModel(id: "$RESEARCH_OBJECT_ID") {

researchFields: [ResearchFieldRelation]
@relationFrom(model: "ResearchFieldRelation", property: "researchObjectID")

annotations: [Annotation]
@relationFrom(model: "Annotation", property: "researchObjectID")
annotationCount: Int!
@relationCountFrom(model: "Annotation", property: "researchObjectID")
}

# Support for incoming relations on CeramicAccounts is coming, but we'd need a separate
Loading