Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/desci-labs/nodes into re…
Browse files Browse the repository at this point in the history
…po-service
  • Loading branch information
hubsmoke committed Jan 25, 2024
2 parents ebb513d + 6631eaa commit d3ec76f
Show file tree
Hide file tree
Showing 16 changed files with 241 additions and 65 deletions.
35 changes: 35 additions & 0 deletions .ceramicDev.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"anchor": { },
"http-api": {
"cors-allowed-origins": [
".*"
],
"admin-dids": [
"did:key:z6MktbKJrMnhVJ37QFTo12911ycm2juKDUzWHDVETu9s5a9T"
]
},
"ipfs": {
"mode": "remote",
"host": "http://host.docker.internal:5001"
},
"logger": {
"log-level": 2
},
"metrics": {
"metrics-exporter-enabled": false,
"metrics-port": 9090
},
"network": {
"name": "inmemory"
},
"node": {},
"state-store": {
"mode": "fs",
"local-directory": "/root/.ceramic/statestore"
},
"indexing": {
"db": "postgres://walter:white@db_postgres:5432/postgres",
"allow-queries-before-historical-sync": true,
"models": []
}
}
6 changes: 5 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,8 @@ ORCID_CLIENT_ID=
ORCID_CLIENT_SECRET=

REPO_SERVER_URL=http://host.docker.internal:5445
REPO_SERVICE_SECRET_KEY=secretrepo
REPO_SERVICE_SECRET_KEY=secretrepo
# Ceramic publish feature toggle, set to 1 for active
TOGGLE_CERAMIC=
# If above is set, clone `@desci-labs/desci-codex` and put the path to it here
CODEX_REPO_PATH=
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ This starts:
4. expedition explorer for local dev (http://localhost:3001)
5. graph index pointing to latest deployed contract (http://localhost:8080)
6. Local IPFS node (private, swarm key enabled) (http://localhost:5001 or http://localhost:8089)
7. Local Ceramic node, run `bootstrapCeramic.sh` to initialize (http://localhost:7007)

**Note:** The Ceramic publish functionality needs to be activated by setting the corresponding environment variable, see `.env.example` for instructions.

**Note:** nodes-media (http://localhost:5454, responsible for DOI / PDF downloads, and for media transcoding) is disabled in the dev cluster by default, but can be uncommented in `docker-compose.dev.yml` for local development
<br>
Expand Down
60 changes: 60 additions & 0 deletions bootstrapCeramic.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#! /usr/bin/env bash

# This script will try to find the `desci-codex` repo and run the
# model deployments. This yields a runtime definition file, which is
# necessary to instantiate the composeDB client used for publishing.
#
# This needs to be re-run when local-data is cleaned, as the models will
# get new streamIDs, and hence the runtime definition file is changed.
#
# There is no damage trying to run this multiple times in a row; it's
# idempotent.

CTX="[bootstrapCeramic.sh]"

set -euo pipefail
trap catch ERR
catch() {
echo "$CTX script failed"
exit 1
}

# Assert running from repo root
if [[ ! -f .env ]]; then
echo "$CTX Must run from repo root, aborting!"
exit 1
fi

# Assert desci-codex repo available
CODEX_REPO_PATH=$(grep "CODEX_REPO_PATH" .env | cut -d"=" -f2)
if [[ -z "$CODEX_REPO_PATH" ]]; then
echo "$CTX CODEX_REPO_PATH not set in .env, aborting!"
exit 1
else
echo "$CTX Found codex repo path: $CODEX_REPO_PATH"
fi

# Assert ceramic service is running
RUNNING_SERVICES=$(docker compose --project-name desci ps --services)
if ! grep -q ceramic <<<"$RUNNING_SERVICES"; then
echo "$CTX the ceramic compose service doesn't seem to be running, aborting!"
exit 1
fi

# Setup desci-codex and deploy composites
pushd "$CODEX_REPO_PATH"
if [[ ! -d "node_modules" ]]; then
echo "$CTX installing deps desci-codex..."
npm ci
fi

echo "$CTX deploying composites..."
npm run --workspace packages/composedb deployComposites
popd

echo "$CTX composites deployed! Copying composite runtime definition to local-data/ceramic..."
cp \
"$CODEX_REPO_PATH/packages/composedb/src/__generated__/definition.js" \
local-data/ceramic/definition.js

echo "$CTX Done! Re-run this script if local state is cleaned."
2 changes: 1 addition & 1 deletion desci-contracts/scripts/seed.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ check() {
done

echo "[seed:$CONTRACT_NAME] deployment found, killing ganache..."
ps aux | grep ganache-cli | grep -v grep | awk '{print $2}' | xargs -r -t kill || echo "[seed:$CONTRACT_NAME] ganache not running"
pkill -f "npm exec ganache" || echo "[seed:$CONTRACT_NAME] ganache not running"
echo "[seed:$CONTRACT_NAME] ganache killed"
}

Expand Down
1 change: 1 addition & 0 deletions desci-models/.prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist
6 changes: 6 additions & 0 deletions desci-models/.prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"printWidth": 120,
"semi": true,
"singleQuote": true,
"trailingComma": "all"
}
2 changes: 1 addition & 1 deletion desci-models/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@desci-labs/desci-models",
"version": "0.1.22",
"version": "0.2.1",
"description": "Data models for DeSci Nodes",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
108 changes: 62 additions & 46 deletions desci-models/src/ResearchObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ export interface ResearchObjectPreviewResult {
}

export interface IpldUrl {
["/"]: string;
['/']: string;
}

export interface ResearchObjectV1 extends ResearchObject {
version: "desci-nodes-0.1.0" | "desci-nodes-0.2.0" | 1;
version: 'desci-nodes-0.1.0' | 'desci-nodes-0.2.0' | 1;
title?: string;
description?: string;
defaultLicense?: string;
Expand Down Expand Up @@ -80,12 +80,12 @@ export interface ResearchObjectTransaction {
}

export enum ResearchObjectValidationType {
GRANT = "grant",
REVIEW = "review",
CONFERENCE = "conference",
AUDIT = "audit",
CERTIFICATION = "certification",
CERTIFICATION_ARC = "certification-arc",
GRANT = 'grant',
REVIEW = 'review',
CONFERENCE = 'conference',
AUDIT = 'audit',
CERTIFICATION = 'certification',
CERTIFICATION_ARC = 'certification-arc',
}
export interface ResearchObjectValidationDeposit {
token: string;
Expand All @@ -105,13 +105,13 @@ export interface ResearchObjectV1Validation {
}

export enum ResearchObjectAttributeKey {
ACM_AVAILABLE = "available",
ACM_FUNCTIONAL = "functional",
ACM_REUSABLE = "reusable",
ACM_REPRODUCED = "reproduced",
ACM_REPLICATED = "replicated",
AUTHORSHIP_VERIFIED = "authorship-verified",
COMPUTATIONAL_REPRODUCIBILITY = "computational-reproducibility",
ACM_AVAILABLE = 'available',
ACM_FUNCTIONAL = 'functional',
ACM_REUSABLE = 'reusable',
ACM_REPRODUCED = 'reproduced',
ACM_REPLICATED = 'replicated',
AUTHORSHIP_VERIFIED = 'authorship-verified',
COMPUTATIONAL_REPRODUCIBILITY = 'computational-reproducibility',
}

export interface ResearchObjectV1Attributes {
Expand All @@ -120,36 +120,55 @@ export interface ResearchObjectV1Attributes {
}

export enum ResearchObjectComponentType {
DATA_BUCKET = "data-bucket",
UNKNOWN = "unknown",
PDF = "pdf",
CODE = "code",
VIDEO = "video",
TERMINAL = "terminal", // not used, TODO: remove
DATA = "data",
LINK = "link", // external link
DATA_BUCKET = 'data-bucket',
UNKNOWN = 'unknown',
PDF = 'pdf',
CODE = 'code',
VIDEO = 'video',
TERMINAL = 'terminal', // not used, TODO: remove
DATA = 'data',
LINK = 'link', // external link
}

export enum ResearchObjectComponentDocumentSubtype {
RESEARCH_ARTICLE = "research-article",
PREREGISTERED_REPORT = "preregistered-report",
PREREGISTERED_ANALYSIS_PLAN = "preregistered-analysis-plan",
SUPPLEMENTARY_INFORMATION = "supplementary-information",
PRESENTATION_DECK = "presentation-deck",
OTHER = "other",
RESEARCH_ARTICLE = 'research-article',
PREREGISTERED_REPORT = 'preregistered-report',
PREREGISTERED_ANALYSIS_PLAN = 'preregistered-analysis-plan',
SUPPLEMENTARY_INFORMATION = 'supplementary-information',
PRESENTATION_DECK = 'presentation-deck',
AUTHOR_ACCEPTED = 'author-accepted',
PREPRINT = 'preprint',
REVIEW_REPORT = 'review-report',
MANUSCRIPT = 'manuscript',
OTHER = 'other',
}

export enum ResearchObjectComponentDataSubtype {
PROCESSED_DATA = 'processed-data',
RAW_DATA = 'raw-data',
IMAGE = 'image',
OTHER = 'other',
}

export enum ResearchObjectComponentCodeSubtype {
CODE_SCRIPTS = 'code-scripts',
SOFTWARE_PACKAGE = 'software-package',
OTHER = 'other',
}

export enum ResearchObjectComponentLinkSubtype {
COMMUNITY_DISCUSSION = "community-discussion",
VIDEO_RESOURCE = "video-resource",
EXTERNAL_API = "external-api",
RESTRICTED_DATA = "restricted",
PRESENTATION_DECK = "presentation-deck",
OTHER = "other",
COMMUNITY_DISCUSSION = 'community-discussion',
VIDEO_RESOURCE = 'video-resource',
EXTERNAL_API = 'external-api',
RESTRICTED_DATA = 'restricted',
PRESENTATION_DECK = 'presentation-deck',
OTHER = 'other',
}

export type ResearchObjectComponentSubtypes =
| ResearchObjectComponentDocumentSubtype
| ResearchObjectComponentDataSubtype
| ResearchObjectComponentCodeSubtype
| ResearchObjectComponentLinkSubtype;

export interface CommonComponentPayload {
Expand Down Expand Up @@ -189,8 +208,8 @@ export interface DataComponentPayload {

export interface DataBucketComponent extends ResearchObjectV1Component {
type: ResearchObjectComponentType.DATA_BUCKET;
id: "root";
name: "root";
id: 'root';
name: 'root';
payload: DataBucketComponentPayload;
}
export interface DataBucketComponentPayload {
Expand All @@ -211,11 +230,13 @@ export interface ExternalLinkComponent extends ResearchObjectV1Component {

export interface DataComponent extends ResearchObjectV1Component {
type: ResearchObjectComponentType.DATA;
subtype?: ResearchObjectComponentDataSubtype;
payload: DataComponentPayload & DataComponentMetadata;
}

export interface CodeComponent extends ResearchObjectV1Component {
type: ResearchObjectComponentType.CODE;
subtype?: ResearchObjectComponentCodeSubtype;
payload: {
language?: string;
code?: string;
Expand Down Expand Up @@ -247,9 +268,7 @@ export interface Scaled {
pageIndex?: number;
}

export interface PdfAnnotation
extends ResearchObjectComponentAnnotation,
Scaled {
export interface PdfAnnotation extends ResearchObjectComponentAnnotation, Scaled {
move?: boolean;
text?: string;
title?: string;
Expand All @@ -264,8 +283,8 @@ export interface ResearchObjectComponentAnnotation {
}

export enum ResearchObjectV1AuthorRole {
AUTHOR = "Author",
NODE_STEWARD = "Node Steward",
AUTHOR = 'Author',
NODE_STEWARD = 'Node Steward',
}

/**
Expand All @@ -277,8 +296,5 @@ export enum ResearchObjectV1AuthorRole {
* '.pdf': ResearchObjectComponentType.PDF
* }
*/
export type ResearchObjectComponentTypeMap = Record<
FileExtension,
ResearchObjectComponentType
>;
export type ResearchObjectComponentTypeMap = Record<FileExtension, ResearchObjectComponentType>;
export type FileExtension = string;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "Node" ADD COLUMN "ceramicStream" TEXT;
1 change: 1 addition & 0 deletions desci-server/prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ model Node {
deletedAt DateTime?
UploadJobs UploadJobs[]
DraftNodeTree DraftNodeTree[]
ceramicStream String?
@@index([ownerId])
@@index([uuid])
Expand Down
3 changes: 3 additions & 0 deletions desci-server/src/controllers/nodes/prepublish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface PrepublishSuccessResponse {
updatedManifestCid: string;
updatedManifest: ResearchObjectV1;
version?: NodeVersion;
ceramicStream?: string;
}

export interface PrepublishErrorResponse {
Expand All @@ -39,6 +40,7 @@ export const prepublish = async (req: RequestWithNode, res: Response<PrepublishR
body: req.body,
uuid,
user: (req as any).user,
ceramicStream: node.ceramicStream,
});
if (!uuid) {
return res.status(400).json({ ok: false, error: 'UUID is required.' });
Expand Down Expand Up @@ -89,6 +91,7 @@ export const prepublish = async (req: RequestWithNode, res: Response<PrepublishR
updatedManifestCid: persistedManifestCid,
updatedManifest: updatedManifest,
version: nodeVersion,
ceramicStream: node.ceramicStream,
});
} catch (err) {
logger.error({ err }, '[prepublish::prepublish] node-pre-publish-err');
Expand Down
Loading

0 comments on commit d3ec76f

Please sign in to comment.