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

Feature/dpp 90 #144

Merged
merged 6 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions packages/data-store/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"typeorm-postgres:migration:run": "pnpm run typeorm -- migration:run -c migration-postgres"
},
"dependencies": {
"@sphereon/ssi-sdk.core": "workspace:*",
nklomp marked this conversation as resolved.
Show resolved Hide resolved
"@sphereon/ssi-types": "workspace:*",
"@veramo/core": "4.2.0",
"class-validator": "^0.14.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/data-store/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export { AbstractContactStore } from './contact/AbstractContactStore'
export { AbstractIssuanceBrandingStore } from './issuanceBranding/AbstractIssuanceBrandingStore'
export { IssuanceBrandingStore } from './issuanceBranding/IssuanceBrandingStore'
export { StatusListStore } from './statusList/StatusListStore'
export { DataStoreMigrations, enableUuidv4 } from './migrations'
export { DataStoreMigrations } from './migrations'
export * from './types'
export * from './utils/contact/MappingUtils'

Expand Down
1 change: 0 additions & 1 deletion packages/data-store/src/migrations/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export { DataStoreMigrations } from './generic'
export { enableUuidv4 } from './postgres/uuid'
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { MigrationInterface, QueryRunner } from 'typeorm'
import { enableUuidv4 } from './uuid'
import { enablePostgresUuidExtension } from '@sphereon/ssi-sdk.core'

export class CreateContacts1659463079428 implements MigrationInterface {
name = 'CreateContacts1659463079428'

public async up(queryRunner: QueryRunner): Promise<void> {
await enableUuidv4(queryRunner)
await enablePostgresUuidExtension(queryRunner)
await queryRunner.query(
`CREATE TABLE "BaseConfigEntity" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "client_id" character varying(255), "client_secret" character varying(255), "scopes" text, "issuer" character varying(255), "redirect_url" text, "dangerously_allow_insecure_http_requests" boolean, "client_auth_method" text, "identifier" character varying(255), "session_id" character varying(255), "type" character varying NOT NULL, "connectionId" uuid, CONSTRAINT "REL_BaseConfig_connectionId" UNIQUE ("connectionId"), CONSTRAINT "PK_BaseConfigEntity_id" PRIMARY KEY ("id"))`
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { MigrationInterface, QueryRunner } from 'typeorm'
import { enableUuidv4 } from './uuid'
import { enablePostgresUuidExtension } from '@sphereon/ssi-sdk.core'

export class CreateIssuanceBranding1685628974232 implements MigrationInterface {
name = 'CreateIssuanceBranding1685628974232'

public async up(queryRunner: QueryRunner): Promise<void> {
await enableUuidv4(queryRunner)
await enablePostgresUuidExtension(queryRunner)
await queryRunner.query(
`CREATE TABLE "ImageDimensions" ("id" uuid NOT NULL DEFAULT uuid_generate_v4(), "width" integer NOT NULL, "height" integer NOT NULL, CONSTRAINT "PK_ImageDimensions_id" PRIMARY KEY ("id"))`
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { MigrationInterface, QueryRunner } from 'typeorm'
import { enableUuidv4 } from './uuid'
import { enablePostgresUuidExtension } from '@sphereon/ssi-sdk.core'

export class CreateContacts1690925872592 implements MigrationInterface {
name = 'CreateContacts1690925872592'

public async up(queryRunner: QueryRunner): Promise<void> {
await enableUuidv4(queryRunner)
await enablePostgresUuidExtension(queryRunner)
await queryRunner.query(`ALTER TABLE "CorrelationIdentifier" DROP CONSTRAINT "FK_CorrelationIdentifier_identityId"`)
await queryRunner.query(`ALTER TABLE "IdentityMetadata" DROP CONSTRAINT "FK_IdentityMetadata_identityId"`)
await queryRunner.query(`ALTER TABLE "Identity" DROP CONSTRAINT "FK_Identity_contactId"`)
Expand Down
12 changes: 0 additions & 12 deletions packages/data-store/src/migrations/postgres/uuid.ts

This file was deleted.

2 changes: 2 additions & 0 deletions packages/data-store/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
},
"references": [
{
"path": "../ssi-sdk-core"
}, {
"path": "../ssi-types"
}
]
Expand Down
19 changes: 19 additions & 0 deletions packages/ssi-sdk-core/src/utils/database.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,22 @@
export const flattenArray = <T>(args: { items: Array<T | Array<T>> }): Array<T> => args.items.flat() as Array<T>

export const flattenMigrations = <T>(args: { migrations: Array<T | Array<T>> }): Array<T> => args.migrations.flat() as Array<T>

type QueryRunnerType = {
query(query: string, parameters: any[] | undefined, useStructuredResult: true): Promise<any>
query(query: string, parameters?: any[]): Promise<any>
}

/**
* It should accept the type QueryRunner from the typeorm
*/
export const enablePostgresUuidExtension = async (queryRunner: QueryRunnerType) => {
try {
await queryRunner.query(`CREATE EXTENSION IF NOT EXISTS "uuid-ossp";`)
} catch (error) {
console.error(
`Please enable the uuid-ossp.control extension in your PostgreSQL installation. It enables generating V4 UUID and can be found in the postgresql-contrib package`
)
throw error
}
}
2 changes: 1 addition & 1 deletion packages/ssi-sdk-core/src/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * from './encoding'
export { flattenArray, flattenMigrations } from './database'
export { enablePostgresUuidExtension, flattenArray, flattenMigrations } from './database'
export { getImageMediaType, getImageDimensions, downloadImage } from './image'
export * from './vc'
5 changes: 4 additions & 1 deletion pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading