Skip to content

Commit

Permalink
Merge pull request #33 from desci-labs/m0ar/disable-indexes
Browse files Browse the repository at this point in the history
Temporarily disable query indexes as bug workaround
  • Loading branch information
m0ar authored Jan 15, 2024
2 parents c652afc + a1ce9ef commit 67d5f60
Show file tree
Hide file tree
Showing 21 changed files with 745 additions and 439 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Publish codex-lib to npmjs
on:
release:
types: [published]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: "npm"
cache-dependency-path: "package-lock.json"
check-latest: false
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
1,038 changes: 637 additions & 401 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,8 @@
"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/composedb/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
src/__generated__/*
!src/__generates__/*.d.ts

5 changes: 3 additions & 2 deletions packages/composedb/composites/1-claim.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ 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" }])
# @createIndex(fields: [{ path: "badge" }])
{
owner: DID! @documentAccount
version: CommitID! @documentVersion
title: String! @string(maxLength: 100)
Expand Down
3 changes: 2 additions & 1 deletion packages/composedb/composites/1-researchObject.graphql
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
type ResearchObject
@createModel(accountRelation: LIST, description: "A research object")
@createIndex(fields: [{ path: "title" }]) {
# @createIndex(fields: [{ path: "title" }])
{
owner: DID! @documentAccount
version: CommitID! @documentVersion
title: String! @string(maxLength: 250)
Expand Down
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
Expand Down
9 changes: 5 additions & 4 deletions packages/composedb/composites/2-annotation.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ 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: "targetID" }])
# @createIndex(fields: [{ path: "claimID" }])
# @createIndex(fields: [{ path: "researchObjectID" }])
# @createIndex(fields: [{ path: "dagNode" }])
{
owner: DID! @documentAccount
version: CommitID! @documentVersion

Expand Down
7 changes: 4 additions & 3 deletions packages/composedb/composites/2-attestation.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ 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: "revoked" }])
# @createIndex(fields: [{ path: "targetVersion" }])
# @createIndex(fields: [{ path: "claimVersion" }])
{
owner: DID! @documentAccount
version: CommitID! @documentVersion
# 1. Any type of document, shown with relation on reciever end but cannot use
Expand Down
7 changes: 4 additions & 3 deletions packages/composedb/composites/2-contributorRelation.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ 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: "revoked" }])
# @createIndex(fields: [{ path: "researchObjectVersion" }])
{
owner: DID! @documentAccount
version: CommitID! @documentVersion

Expand Down
7 changes: 4 additions & 3 deletions packages/composedb/composites/2-referenceRelation.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ 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: "fromVersion" }])
# @createIndex(fields: [{ path: "toVersion" }])
# @createIndex(fields: [{ path: "revoked" }])
{
owner: DID! @documentAccount
version: CommitID! @documentVersion

Expand Down
7 changes: 4 additions & 3 deletions packages/composedb/composites/2-researchComponent.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ 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
name: String! @string(maxLength: 512)
Expand Down
8 changes: 4 additions & 4 deletions packages/composedb/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
"kill": "pkill --full \"ceramic daemon|ipfs daemon\""
},
"devDependencies": {
"@ceramicnetwork/cli": "^3.0.0",
"@ceramicnetwork/http-client": "^3.0.0",
"@composedb/devtools": "^0.6.0",
"@composedb/devtools-node": "^0.6.0",
"@ceramicnetwork/cli": "^3.1.0",
"@ceramicnetwork/http-client": "^3.1.0",
"@composedb/devtools": "^0.6.1",
"@composedb/devtools-node": "^0.6.1",
"dids": "^4.0.4",
"key-did-provider-ed25519": "^3.0.2",
"key-did-resolver": "^3.0.0",
Expand Down
9 changes: 9 additions & 0 deletions packages/lib/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
node_modules
admin_seed.txt
local-data
composedb.config.json
test.config.json
*.tsbuildinfo
.vscode
dist/test/
dist/scripts/
21 changes: 21 additions & 0 deletions packages/lib/LICENCE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 DeSci Labs

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
18 changes: 15 additions & 3 deletions packages/lib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,24 @@
This package implements a typed API for interacting directly with Codex, by
talking directly with a Ceramic and/or ComposeDB node.

## Usage
## Installation
Install as dependency:

> Note: this package is currently not automatically published, but this works
regardless within the repo.
> Note: this package is currently not automatically published, but this will
work regardless for the other packages inside the repo (`-composedb` and `-cli`).

```bash
npm install @desci-labs/desci-codex-lib
```

## Usage
Most functions require passing in a Ceramic or composeDB client, which can be
instantiated using the tools in `clients.ts`. Without explicit configuration,
the clients will default to a Ceramic node at `localhost:7007`.

Do note that when running against a local node, you likely want to compile
and deploy the composites in `desci-codex-composedb`.

### Tests
The test suite depends on the models in `desci-codex-composedb`, and are
easiest to invoke my running `make test` in the repo root instead of here.
2 changes: 2 additions & 0 deletions packages/lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"license": "MIT",
"author": "Edvard Hübinette",
"type": "module",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"scripts": {
"build": "rm -rf ./dist && tsc --project tsconfig.build.json",
"populate": "node --no-warnings=ExperimentalWarning --loader ts-node/esm scripts/populate.ts",
Expand Down
2 changes: 2 additions & 0 deletions packages/lib/src/clients.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,5 @@ export const didFromSeed = async (seed: string) => {
await did.authenticate();
return did;
};

export type { ComposeClient, CeramicClient };
2 changes: 1 addition & 1 deletion packages/lib/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ export type PartialWithID<T> = Partial<T> & {
/**
* Get all keys of a union type, conditional to get union distribution.
*/
type UnionKeys<T> = T extends unknown ? keyof T : never;
export type UnionKeys<T> = T extends unknown ? keyof T : never;

/**
* Omit from all subtypes in a union, like mapping `Omit` over all members.
Expand Down
2 changes: 2 additions & 0 deletions packages/lib/test/root.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,7 @@ describe("ComposeDB nodes", () => {
composeClient,
contributionData,
);
await waitAndSync(contribution.streamID);
await updateContributorRelation(composeClient, {
id: contribution.streamID,
revoked: true,
Expand Down Expand Up @@ -763,6 +764,7 @@ describe("ComposeDB nodes", () => {
composeClient,
referenceData,
);
await waitAndSync(reference.streamID);
await updateReferenceRelation(composeClient, {
id: reference.streamID,
revoked: true,
Expand Down
9 changes: 1 addition & 8 deletions packages/lib/tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,5 @@
"test/**/*",
"vitest*",
"dist"
],
"compilerOptions": {
"noEmit": false,
"outDir": "dist",
"declaration": true,
"declarationMap": true,
"sourceMap": true
}
]
}

0 comments on commit 67d5f60

Please sign in to comment.