Skip to content

Commit

Permalink
fix: Typescript types
Browse files Browse the repository at this point in the history
  • Loading branch information
simonas-notcat committed Feb 28, 2020
1 parent af6c381 commit 72c1899
Show file tree
Hide file tree
Showing 39 changed files with 317 additions and 68 deletions.
16 changes: 16 additions & 0 deletions api-extractor-base.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",

"apiReport": {
"enabled": false
},

"docModel": {
"enabled": true,
"apiJsonFilePath": "./tmpapi/<unscopedPackageName>.api.json"
},

"dtsRollup": {
"enabled": false
}
}
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"build": "lerna run build",
"publish": "lerna publish",
"bootstrap": "lerna bootstrap",
"docs": "ts-node ./scripts/generate-docs.ts && api-documenter markdown -i ./tmpapi -o ./docs/api && rm -rf ./tmpapi",
"test": "jest --config=jest.json",
"test:watch": "jest --config=jest.json --watch",
"daf": "./packages/daf-cli/bin/daf.js"
Expand All @@ -21,6 +22,8 @@
"devDependencies": {
"@commitlint/cli": "^8.2.0",
"@commitlint/config-conventional": "^8.2.0",
"@microsoft/api-documenter": "^7.7.12",
"@microsoft/api-extractor": "^7.7.8",
"@types/jest": "^24.0.23",
"husky": "^3.0.9",
"jest": "^24.9.0",
Expand All @@ -30,6 +33,7 @@
"pretty-quick": "^2.0.1",
"semantic-release": "^16.0.0-beta.31",
"ts-jest": "^24.1.0",
"ts-node": "^8.6.2",
"typescript": "^3.7.5"
},
"repository": {
Expand Down
6 changes: 3 additions & 3 deletions packages/daf-cli/src/graphql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as Daf from 'daf-core'
import * as W3c from 'daf-w3c'
import * as TG from 'daf-trust-graph'
import * as SRD from 'daf-selective-disclosure'
import { Gql as DataGql } from 'daf-data-store'
import { resolvers, typeDefs } from 'daf-data-store'
import merge from 'lodash.merge'
import { core, dataStore } from './setup'
import { listen } from './services'
Expand All @@ -20,15 +20,15 @@ program
Daf.Gql.baseTypeDefs,
Daf.Gql.Core.typeDefs,
Daf.Gql.IdentityManager.typeDefs,
DataGql.typeDefs,
typeDefs,
TG.Gql.typeDefs,
W3c.Gql.typeDefs,
SRD.Gql.typeDefs,
],
resolvers: merge(
Daf.Gql.Core.resolvers,
Daf.Gql.IdentityManager.resolvers,
DataGql.resolvers,
resolvers,
TG.Gql.resolvers,
W3c.Gql.resolvers,
SRD.Gql.resolvers,
Expand Down
5 changes: 5 additions & 0 deletions packages/daf-core/api-extractor.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
"extends": "../../api-extractor-base.json",
"mainEntryPointFilePath": "<projectFolder>/build/index.d.ts"
}
2 changes: 1 addition & 1 deletion packages/daf-core/src/graphql/graphql-core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { LastMessageTimestampForInstance } from '../service/service-manager'

import { Message } from '../message/message'

interface Context {
export interface Context {
core: Core
}

Expand Down
20 changes: 20 additions & 0 deletions packages/daf-core/src/graphql/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { baseTypeDefs } from './graphql-base-type-defs'
import { resolvers as CoreResolvers, typeDefs as CoreTypeDefs } from './graphql-core'
import {
resolvers as IdentityManagerResolvers,
typeDefs as IdentityManagerTypeDefs,
} from './graphql-identity-manager'

const Gql = {
baseTypeDefs,
Core: {
resolvers: CoreResolvers,
typeDefs: CoreTypeDefs,
},
IdentityManager: {
resolvers: IdentityManagerResolvers,
typeDefs: IdentityManagerTypeDefs,
},
}

export { Gql }
14 changes: 2 additions & 12 deletions packages/daf-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,5 @@ export { AbstractMessageValidator } from './message/abstract-message-validator'
export { Message } from './message/message'
export { ServiceManager, LastMessageTimestampForInstance, ServiceEventTypes } from './service/service-manager'
export { AbstractServiceController } from './service/abstract-service-controller'
import * as Types from './types'
import { baseTypeDefs } from './graphql/graphql-base-type-defs'
import * as GqlCore from './graphql/graphql-core'
import * as GqlIdentityManager from './graphql/graphql-identity-manager'

const Gql = {
baseTypeDefs,
Core: GqlCore,
IdentityManager: GqlIdentityManager,
}

export { Types, Gql }
export { Action } from './types'
export { Gql } from './graphql/index'
5 changes: 5 additions & 0 deletions packages/daf-data-store/api-extractor.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json",
"extends": "../../api-extractor-base.json",
"mainEntryPointFilePath": "<projectFolder>/build/index.d.ts"
}
2 changes: 1 addition & 1 deletion packages/daf-data-store/src/graphql.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DataStore } from './data-store'

interface Context {
export interface Context {
dataStore: DataStore
}

Expand Down
5 changes: 2 additions & 3 deletions packages/daf-data-store/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export { DataStore } from './data-store'
import * as Gql from './graphql'
import * as Types from './types'
export { Types, Gql }
export { resolvers, typeDefs } from './graphql'
export { DbDriver, Migration, Identity, VerifiableClaim, VerifiableClaimField } from './types'
3 changes: 2 additions & 1 deletion packages/daf-data-store/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"extends": "../tsconfig.settings.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "build"
"outDir": "build",
"declarationDir": "build"
},
"references": [{ "path": "../daf-core" }]
}
4 changes: 2 additions & 2 deletions packages/daf-debug/src/action-handler.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Core, AbstractActionHandler, Types } from 'daf-core'
import { Core, AbstractActionHandler, Action } from 'daf-core'

import Debug from 'debug'
const debug = Debug('daf:debug:action-handler')

export class ActionHandler extends AbstractActionHandler {
public async handleAction(action: Types.Action, core: Core) {
public async handleAction(action: Action, core: Core) {
debug('%o', action)
return super.handleAction(action, core)
}
Expand Down
1 change: 1 addition & 0 deletions packages/daf-debug/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"compilerOptions": {
"rootDir": "src",
"outDir": "build",
"declarationDir": "build",
"baseUrl": "."
},
"references": [{ "path": "../daf-core" }]
Expand Down
6 changes: 3 additions & 3 deletions packages/daf-did-comm/src/action-handler.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Core, AbstractActionHandler, Types, Message } from 'daf-core'
import { Core, AbstractActionHandler, Action, Message } from 'daf-core'
import uuid from 'uuid'
import Debug from 'debug'

Expand All @@ -8,7 +8,7 @@ export const ActionTypes = {
sendJwt: 'action.sendJwt',
}

export interface ActionSendJWT extends Types.Action {
export interface ActionSendJWT extends Action {
data: {
from: string
to: string
Expand All @@ -21,7 +21,7 @@ export class ActionHandler extends AbstractActionHandler {
super()
}

public async handleAction(action: Types.Action, core: Core) {
public async handleAction(action: Action, core: Core) {
if (action.type === ActionTypes.sendJwt) {
const { data } = action as ActionSendJWT

Expand Down
3 changes: 2 additions & 1 deletion packages/daf-did-comm/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"extends": "../tsconfig.settings.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "build"
"outDir": "build",
"declarationDir": "build"
},
"references": [{ "path": "../daf-core" }]
}
3 changes: 2 additions & 1 deletion packages/daf-did-jwt/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"extends": "../tsconfig.settings.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "build"
"outDir": "build",
"declarationDir": "build"
},
"references": [{ "path": "../daf-core" }]
}
2 changes: 1 addition & 1 deletion packages/daf-ethr-did/src/identity-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import Debug from 'debug'
const debug = Debug('daf:ethr-did:identity-provider')

export function toEthereumAddress(hexPublicKey: string): string {
return `0x${Buffer.from(keccak_256.arrayBuffer(Buffer.from(hexPublicKey.slice(2), 'hex')))
return `0x${Buffer.from(keccak_256(Buffer.from(hexPublicKey.slice(2), 'hex')))
.slice(-20)
.toString('hex')}`
}
Expand Down
3 changes: 2 additions & 1 deletion packages/daf-ethr-did/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"extends": "../tsconfig.settings.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "build"
"outDir": "build",
"declarationDir": "build"
},
"references": [{ "path": "../daf-core" }]
}
3 changes: 2 additions & 1 deletion packages/daf-fs/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"extends": "../tsconfig.settings.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "build"
"outDir": "build",
"declarationDir": "build"
},
"references": [{ "path": "../daf-core" }]
}
3 changes: 2 additions & 1 deletion packages/daf-libsodium/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"extends": "../tsconfig.settings.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "build"
"outDir": "build",
"declarationDir": "build"
},
"references": [{ "path": "../daf-core" }]
}
3 changes: 2 additions & 1 deletion packages/daf-local-storage/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"extends": "../tsconfig.settings.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "build"
"outDir": "build",
"declarationDir": "build"
},
"references": [{ "path": "../daf-core" }]
}
4 changes: 2 additions & 2 deletions packages/daf-node-sqlite3/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import sqlite3 from 'sqlite3'
import { Types } from 'daf-data-store'
import { DbDriver } from 'daf-data-store'

import Debug from 'debug'
const debug = Debug('daf:node-sqlite3')

export class NodeSqlite3 implements Types.DbDriver {
export class NodeSqlite3 implements DbDriver {
private db: any

constructor(filename: string) {
Expand Down
3 changes: 2 additions & 1 deletion packages/daf-node-sqlite3/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"extends": "../tsconfig.settings.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "build"
"outDir": "build",
"declarationDir": "build"
},
"references": [{ "path": "../daf-data-store" }, { "path": "../daf-core" }]
}
3 changes: 2 additions & 1 deletion packages/daf-react-native-async-storage/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"extends": "../tsconfig.settings.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "build"
"outDir": "build",
"declarationDir": "build"
},
"references": [{ "path": "../daf-core" }]
}
3 changes: 2 additions & 1 deletion packages/daf-react-native-libsodium/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"extends": "../tsconfig.settings.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "build"
"outDir": "build",
"declarationDir": "build"
},
"references": [{ "path": "../daf-core" }]
}
4 changes: 2 additions & 2 deletions packages/daf-react-native-sqlite3/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { openDatabase } from 'react-native-sqlite-storage'
import { Types } from 'daf-data-store'
import { DbDriver } from 'daf-data-store'
import Debug from 'debug'

const debug = Debug('daf:react-native-sqlite3')

class RnSqlite3 implements Types.DbDriver {
class RnSqlite3 implements DbDriver {
private db: any
private filename: string

Expand Down
3 changes: 2 additions & 1 deletion packages/daf-react-native-sqlite3/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"extends": "../tsconfig.settings.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "build"
"outDir": "build",
"declarationDir": "build"
},
"references": [{ "path": "../daf-data-store" }]
}
3 changes: 2 additions & 1 deletion packages/daf-resolver-universal/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"extends": "../tsconfig.settings.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "build"
"outDir": "build",
"declarationDir": "build"
},
"references": [{ "path": "../daf-core" }]
}
3 changes: 2 additions & 1 deletion packages/daf-resolver/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"extends": "../tsconfig.settings.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "build"
"outDir": "build",
"declarationDir": "build"
},
"references": [{ "path": "../daf-core" }]
}
6 changes: 3 additions & 3 deletions packages/daf-selective-disclosure/src/action-handler.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Core, AbstractActionHandler, Types } from 'daf-core'
import { Core, AbstractActionHandler, Action } from 'daf-core'
import { createJWT } from 'did-jwt'
import Debug from 'debug'

Expand Down Expand Up @@ -26,7 +26,7 @@ export interface CredentialRequestInput {
iss?: Iss[]
}

export interface ActionSignSdr extends Types.Action {
export interface ActionSignSdr extends Action {
did: string
data: {
sub?: string
Expand All @@ -36,7 +36,7 @@ export interface ActionSignSdr extends Types.Action {
}

export class ActionHandler extends AbstractActionHandler {
public async handleAction(action: Types.Action, core: Core) {
public async handleAction(action: Action, core: Core) {
if (action.type === ActionTypes.signSdr) {
const { did, data } = action as ActionSignSdr
try {
Expand Down
3 changes: 2 additions & 1 deletion packages/daf-selective-disclosure/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
"extends": "../tsconfig.settings.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "build"
"outDir": "build",
"declarationDir": "build"
},
"references": [{ "path": "../daf-core" }, { "path": "../daf-did-jwt" }]
}
Loading

0 comments on commit 72c1899

Please sign in to comment.