Skip to content

Commit

Permalink
feat: update to credo-ts
Browse files Browse the repository at this point in the history
  • Loading branch information
genaris committed Feb 3, 2024
1 parent 9f69cd6 commit 18a300d
Show file tree
Hide file tree
Showing 22 changed files with 1,194 additions and 217 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/release-canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ on:
# Ideally we only add this to the 'release' job so it doesn't limit PR runs, but github can't guarantee the job order in that case:
# "When concurrency is specified at the job level, order is not guaranteed for jobs or runs that queue within 5 minutes of each other."
concurrency:
group: aries-javascript-media-sharing${{ github.ref }}-${{ github.repository }}-{{ github.event_name }}
group: credo-ts-media-sharing${{ github.ref }}-${{ github.repository }}-{{ github.event_name }}
cancel-in-progress: true

jobs:
validate:
runs-on: ubuntu-20.04
name: Validate
steps:
- name: Checkout aries-javascript-media-sharing
- name: Checkout credo-ts-media-sharing
uses: actions/checkout@v2

- name: Get yarn cache directory path
Expand Down Expand Up @@ -53,7 +53,7 @@ jobs:
name: Release
needs: [validate]
steps:
- name: Checkout aries-javascript-media-sharing
- name: Checkout credo-ts-media-sharing
uses: actions/checkout@v2
with:
fetch-depth: 0
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release-stable.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ on:
# Ideally we only add this to the 'release' job so it doesn't limit PR runs, but github can't guarantee the job order in that case:
# "When concurrency is specified at the job level, order is not guaranteed for jobs or runs that queue within 5 minutes of each other."
concurrency:
group: aries-javascript-media-sharing${{ github.ref }}-${{ github.repository }}-{{ github.event_name }}
group: credo-ts-media-sharing${{ github.ref }}-${{ github.repository }}-{{ github.event_name }}
cancel-in-progress: true

jobs:
validate:
runs-on: ubuntu-20.04
name: Validate
steps:
- name: Checkout aries-javascript-media-sharing
- name: Checkout credo-ts-media-sharing
uses: actions/checkout@v2

- name: Get yarn cache directory path
Expand Down Expand Up @@ -56,9 +56,9 @@ jobs:
name: Release
needs: [validate]
# Only run on workflow dispatch to main branch
if: github.ref == 'refs/heads/main' && github.repository == '2060-io/aries-javascript-media-sharing' && github.event_name == 'workflow_dispatch'
if: github.ref == 'refs/heads/main' && github.repository == '2060-io/credo-ts-media-sharing' && github.event_name == 'workflow_dispatch'
steps:
- name: Checkout aries-javascript-media-sharing
- name: Checkout credo-ts-media-sharing
uses: actions/checkout@v2
with:
fetch-depth: 0
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This module is used to provide an Aries Agent built with Aries Framework JavaScr
It's conceived as an extension module for Aries Framework JavaScript which can be injected to an existing agent instance:

```ts
import { MediaSharingModule } from 'aries-javascript-media-sharing'
import { MediaSharingModule } from 'credo-ts-media-sharing'

const agent = new Agent({
config: {
Expand Down
28 changes: 12 additions & 16 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"name": "aries-framework-media-sharing",
"name": "credo-ts-media-sharing",
"version": "0.0.0.alpha-0",
"description": "Media sharing protocol implementation for aries-framework",
"description": "Media sharing protocol implementation for credo-ts",
"author": "2060.io",
"homepage": "https://github.com/2060-io/aries-javascript-media-sharing",
"homepage": "https://github.com/2060-io/credo-ts-media-sharing",
"license": "ISC",
"main": "build/index.js",
"types": "build/index.js",
Expand All @@ -23,22 +23,21 @@
},
"repository": {
"type": "git",
"url": "https://github.com/2060-io/aries-javascript-media-sharing"
"url": "https://github.com/2060-io/credo-ts-media-sharing"
},
"bugs": {
"url": "https://github.com/2060-io/aries-javascript-media-sharing/issues"
"url": "https://github.com/2060-io/credo-ts-media-sharing/issues"
},
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org/"
},
"devDependencies": {
"@aries-framework/askar": "^0.4.0",
"@aries-framework/node": "^0.4.0",
"@hyperledger/aries-askar-nodejs": "^0.1.0",
"@credo-ts/askar": "^0.5.0-alpha.116",
"@credo-ts/node": "^0.5.0-alpha.116",
"@hyperledger/aries-askar-nodejs": "^0.2.0-dev.6",
"@types/jest": "^26.0.23",
"@types/node": "^16.11.7",
"@types/node-fetch": "^2.6.4",
"@types/node": "^20.11.16",
"@types/uuid": "^9.0.0",
"@typescript-eslint/eslint-plugin": "^5.48.1",
"@typescript-eslint/parser": "^5.48.1",
Expand All @@ -51,17 +50,14 @@
"typescript": "~4.9.4"
},
"dependencies": {
"@aries-framework/core": "^0.4.0",
"@credo-ts/core": "^0.5.0-alpha.116",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.0",
"class-validator": "^0.14.1",
"reflect-metadata": "^0.1.13",
"rxjs": "^7.2.0",
"tsyringe": "^4.7.0",
"tsyringe": "^4.8.0",
"uuid": "^9.0.0"
},
"resolutions": {
"ref-napi": "npm:@2060.io/ref-napi"
},
"release-it": {
"github": {
"release": true
Expand Down
8 changes: 1 addition & 7 deletions src/MediaSharingApi.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
import {
AgentContext,
ConnectionService,
injectable,
MessageSender,
OutboundMessageContext,
} from '@aries-framework/core'
import { AgentContext, ConnectionService, injectable, MessageSender, OutboundMessageContext } from '@credo-ts/core'
import { RequestMediaHandler, ShareMediaHandler } from './handlers'
import { MediaSharingRecord, SharedMediaItem, SharedMediaItemOptions } from './repository'
import { MediaSharingService } from './services'
Expand Down
2 changes: 1 addition & 1 deletion src/MediaSharingEvents.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { MediaSharingRecord } from './repository'
import { MediaSharingState } from './model'
import { BaseEvent } from '@aries-framework/core'
import { BaseEvent } from '@credo-ts/core'

export enum MediaSharingEventTypes {
StateChanged = 'MediaSharingStateChangedEvent',
Expand Down
4 changes: 2 additions & 2 deletions src/MediaSharingModule.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { DependencyManager, FeatureRegistry, Module } from '@aries-framework/core'
import type { DependencyManager, FeatureRegistry, Module } from '@credo-ts/core'

import { Protocol } from '@aries-framework/core'
import { Protocol } from '@credo-ts/core'

import { MediaSharingApi } from './MediaSharingApi'
import { MediaSharingRole } from './model'
Expand Down
2 changes: 1 addition & 1 deletion src/handlers/RequestMediaHandler.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MessageHandler, MessageHandlerInboundMessage } from '@aries-framework/core'
import { MessageHandler, MessageHandlerInboundMessage } from '@credo-ts/core'
import { MediaSharingService } from '../services'
import { RequestMediaMessage } from '../messages'

Expand Down
2 changes: 1 addition & 1 deletion src/handlers/ShareMediaHandler.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MessageHandler, MessageHandlerInboundMessage } from '@aries-framework/core'
import { MessageHandler, MessageHandlerInboundMessage } from '@credo-ts/core'
import { ShareMediaMessage } from '../messages/ShareMediaMessage'
import { MediaSharingService } from '../services'

Expand Down
4 changes: 2 additions & 2 deletions src/messages/RequestMediaMessage.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AgentMessage, IsValidMessageType, parseMessageType } from '@aries-framework/core'
import { DateParser } from '@aries-framework/core/build/utils/transformers'
import { AgentMessage, IsValidMessageType, parseMessageType } from '@credo-ts/core'
import { DateParser } from '@credo-ts/core/build/utils/transformers'
import { Expose, Transform } from 'class-transformer'
import { IsDate, IsOptional, IsString } from 'class-validator'

Expand Down
4 changes: 2 additions & 2 deletions src/messages/ShareMediaMessage.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AgentMessage, Attachment, IsValidMessageType, parseMessageType } from '@aries-framework/core'
import { DateParser } from '@aries-framework/core/build/utils/transformers'
import { AgentMessage, Attachment, IsValidMessageType, parseMessageType } from '@credo-ts/core'
import { DateParser } from '@credo-ts/core/build/utils/transformers'
import { Expose, Transform, Type } from 'class-transformer'
import { IsDate, IsOptional, IsString } from 'class-validator'
import { CipheringInfo, SharedMediaItem } from '../repository'
Expand Down
6 changes: 2 additions & 4 deletions src/repository/MediaSharingRecord.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { v4 as uuid } from 'uuid'
import { AriesFrameworkError, BaseRecord, utils } from '@aries-framework/core'
import { CredoError, BaseRecord, utils } from '@credo-ts/core'
import { MediaSharingRole, MediaSharingState } from '../model'
import { Type } from 'class-transformer'

Expand Down Expand Up @@ -106,9 +106,7 @@ export class MediaSharingRecord extends BaseRecord<any, any, any> {

public assertRole(expectedRole: MediaSharingRole) {
if (this.role !== expectedRole) {
throw new AriesFrameworkError(
`Media sharing record has invalid role ${this.role}. Expected role ${expectedRole}.`
)
throw new CredoError(`Media sharing record has invalid role ${this.role}. Expected role ${expectedRole}.`)
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/repository/MediaSharingRepository.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EventEmitter, InjectionSymbols, Repository, StorageService } from '@aries-framework/core'
import { EventEmitter, InjectionSymbols, Repository, StorageService } from '@credo-ts/core'
import { inject, scoped, Lifecycle } from 'tsyringe'
import { MediaSharingRecord } from './MediaSharingRecord'

Expand Down
14 changes: 7 additions & 7 deletions src/services/MediaSharingService.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AgentContext, AriesFrameworkError, EventEmitter, MessageHandlerInboundMessage } from '@aries-framework/core'
import { AgentContext, CredoError, EventEmitter, MessageHandlerInboundMessage } from '@credo-ts/core'
import { Lifecycle, scoped } from 'tsyringe'

import { MediaSharingEventTypes, MediaSharingStateChangedEvent } from '../MediaSharingEvents'
Expand Down Expand Up @@ -75,7 +75,7 @@ export class MediaSharingService {
}

if (!record.items) {
throw new AriesFrameworkError('MediaSharingRecord does not contain any item to share')
throw new CredoError('MediaSharingRecord does not contain any item to share')
}

// Create message
Expand Down Expand Up @@ -127,12 +127,12 @@ export class MediaSharingService {

// Media sharing record already exists
if (record) {
throw new AriesFrameworkError(`There is already a MediaSharingRecord with thread Id ${message.threadId}`)
throw new CredoError(`There is already a MediaSharingRecord with thread Id ${message.threadId}`)
} else {
const connection = messageContext.assertReadyConnection()

if (message.items.length === 0) {
throw new AriesFrameworkError('There are no valid items in MediaSharingRecord')
throw new CredoError('There are no valid items in MediaSharingRecord')
}

// Process items
Expand All @@ -141,15 +141,15 @@ export class MediaSharingService {
for (const item of message.items) {
const relatedAttachment = message.appendedAttachments?.find((attachment) => attachment.id === item.attachmentId)
if (!relatedAttachment) {
throw new AriesFrameworkError(`No attachment found for shared item ${item.id}`)
throw new CredoError(`No attachment found for shared item ${item.id}`)
}

if (!relatedAttachment.mimeType) {
throw new AriesFrameworkError(`Missing MIME type for shared item ${item.id}`)
throw new CredoError(`Missing MIME type for shared item ${item.id}`)
}

if (!relatedAttachment.data.links || !relatedAttachment.data.links.length) {
throw new AriesFrameworkError(`Missing URI for for shared item ${item.id}`)
throw new CredoError(`Missing URI for for shared item ${item.id}`)
}

items.push({
Expand Down
2 changes: 1 addition & 1 deletion src/services/MediaSharingServiceOptions.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ConnectionRecord } from '@aries-framework/core'
import { ConnectionRecord } from '@credo-ts/core'
import { MediaSharingRecord, SharedMediaItem } from '../repository'

export interface CreateMediaSharingRecordOptions {
Expand Down
6 changes: 3 additions & 3 deletions test/mediasharing.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { agentDependencies } from '@aries-framework/node'
import { AskarModule } from '@aries-framework/askar'
import { agentDependencies } from '@credo-ts/node'
import { AskarModule } from '@credo-ts/askar'
import { ariesAskar } from '@hyperledger/aries-askar-nodejs'
import { Agent, ConnectionRecord, ConsoleLogger, EncryptedMessage, LogLevel } from '@aries-framework/core'
import { Agent, ConnectionRecord, ConsoleLogger, EncryptedMessage, LogLevel } from '@credo-ts/core'
import { v4 as uuid } from 'uuid'
import { firstValueFrom, ReplaySubject, Subject } from 'rxjs'
import { MediaSharingModule } from '../src/MediaSharingModule'
Expand Down
6 changes: 3 additions & 3 deletions test/recordUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import type {
RecordUpdatedEvent,
Agent,
BaseEvent,
} from '@aries-framework/core'
import type { Constructor } from '@aries-framework/core/build/utils/mixins'
} from '@credo-ts/core'
import type { Constructor } from '@credo-ts/core/build/utils/mixins'

import { RepositoryEventTypes } from '@aries-framework/core'
import { RepositoryEventTypes } from '@credo-ts/core'
import { map, filter, pipe } from 'rxjs'

// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down
2 changes: 1 addition & 1 deletion test/transport/SubjectInboundTransport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
TransportService,
TransportSession,
utils,
} from '@aries-framework/core'
} from '@credo-ts/core'
import type { Subscription } from 'rxjs'

import { Subject } from 'rxjs'
Expand Down
8 changes: 4 additions & 4 deletions test/transport/SubjectOutboundTransport.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import type { SubjectMessage } from './SubjectInboundTransport'
import type { OutboundPackage, OutboundTransport, Agent, Logger } from '@aries-framework/core'
import type { OutboundPackage, OutboundTransport, Agent, Logger } from '@credo-ts/core'

import { takeUntil, Subject, take } from 'rxjs'

import { MessageReceiver, InjectionSymbols, AriesFrameworkError } from '@aries-framework/core'
import { MessageReceiver, InjectionSymbols, CredoError } from '@credo-ts/core'

export class SubjectOutboundTransport implements OutboundTransport {
private logger!: Logger
Expand Down Expand Up @@ -36,13 +36,13 @@ export class SubjectOutboundTransport implements OutboundTransport {
const { payload, endpoint } = outboundPackage

if (!endpoint) {
throw new AriesFrameworkError('Cannot send message to subject without endpoint')
throw new CredoError('Cannot send message to subject without endpoint')
}

const subject = this.subjectMap[endpoint]

if (!subject) {
throw new AriesFrameworkError(`No subject found for endpoint ${endpoint}`)
throw new CredoError(`No subject found for endpoint ${endpoint}`)
}

// Create a replySubject just for this session. Both ends will be able to close it,
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.eslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"compilerOptions": {
"baseUrl": ".",
"paths": {
"aries-javascript-media-sharing/*": ["src"]
"credo-ts-media-sharing/*": ["src"]
}
},
"include": ["packages", "./.eslintrc.js", "./jest.config.ts", "./jest.config.base.ts", "types", "test", "samples"],
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"compilerOptions": {
"baseUrl": ".",
"paths": {
"aries-javascript-media-sharing/*": ["src"]
"credo-ts-media-sharing/*": ["src"]
},
"types": ["jest", "node"]
},
Expand Down
Loading

0 comments on commit 18a300d

Please sign in to comment.