@credo-ts/drizzle-storage 0.6.0-pr-2324-20250708122805 → 0.6.0-pr-2324-20250708123651
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +15 -14
- package/src/DrizzleDatabase.ts +29 -0
- package/src/DrizzleRecord.ts +73 -0
- package/src/DrizzleStorageModule.ts +112 -0
- package/src/DrizzleStorageModuleConfig.ts +48 -0
- package/src/action-menu/action-menu/DrizzleDidcommActionMenuRecordAdapter.ts +46 -0
- package/src/action-menu/action-menu/index.ts +10 -0
- package/src/action-menu/action-menu/postgres.ts +31 -0
- package/src/action-menu/action-menu/sqlite.ts +34 -0
- package/src/action-menu/bundle.ts +18 -0
- package/src/action-menu/postgres.ts +1 -0
- package/src/action-menu/sqlite.ts +1 -0
- package/src/adapter/BaseDrizzleRecordAdapter.ts +319 -0
- package/src/adapter/__tests__/queryToDrizzlePostgres.test.ts +328 -0
- package/src/adapter/__tests__/queryToDrizzleSqlite.test.ts +324 -0
- package/src/adapter/index.ts +6 -0
- package/src/adapter/queryToDrizzlePostgres.ts +217 -0
- package/src/adapter/queryToDrizzleSqlite.ts +213 -0
- package/src/anoncreds/bundle.ts +34 -0
- package/src/anoncreds/credential/DrizzleAnonCredsCredentialRecordAdapter.ts +93 -0
- package/src/anoncreds/credential/index.ts +10 -0
- package/src/anoncreds/credential/postgres.ts +27 -0
- package/src/anoncreds/credential/sqlite.ts +27 -0
- package/src/anoncreds/credential-definition/DrizzleAnonCredsCredentialDefinitionRecordAdapter.ts +72 -0
- package/src/anoncreds/credential-definition/index.ts +10 -0
- package/src/anoncreds/credential-definition/postgres.ts +23 -0
- package/src/anoncreds/credential-definition/sqlite.ts +23 -0
- package/src/anoncreds/credential-definition-private/DrizzleAnonCredsCredentialDefinitionPrivateRecordAdapter.ts +48 -0
- package/src/anoncreds/credential-definition-private/index.ts +10 -0
- package/src/anoncreds/credential-definition-private/postgres.ts +14 -0
- package/src/anoncreds/credential-definition-private/sqlite.ts +14 -0
- package/src/anoncreds/key-correctness-proof/DrizzleAnonCredsKeyCorrectnessProofRecordAdapter.ts +46 -0
- package/src/anoncreds/key-correctness-proof/index.ts +10 -0
- package/src/anoncreds/key-correctness-proof/postgres.ts +13 -0
- package/src/anoncreds/key-correctness-proof/sqlite.ts +14 -0
- package/src/anoncreds/link-secret/DrizzleAnonCredsLinkSecretRecordAdapter.ts +45 -0
- package/src/anoncreds/link-secret/index.ts +10 -0
- package/src/anoncreds/link-secret/postgres.ts +18 -0
- package/src/anoncreds/link-secret/sqlite.ts +18 -0
- package/src/anoncreds/postgres.ts +8 -0
- package/src/anoncreds/revocation-registry-definition/DrizzleAnonCredsRevocationRegistryDefinitionRecordAdapter.ts +52 -0
- package/src/anoncreds/revocation-registry-definition/index.ts +10 -0
- package/src/anoncreds/revocation-registry-definition/postgres.ts +18 -0
- package/src/anoncreds/revocation-registry-definition/sqlite.ts +20 -0
- package/src/anoncreds/revocation-registry-definition-private/DrizzleAnonCredsRevocationRegistryDefinitionPrivateRecordAdapter.ts +53 -0
- package/src/anoncreds/revocation-registry-definition-private/index.ts +10 -0
- package/src/anoncreds/revocation-registry-definition-private/postgres.ts +22 -0
- package/src/anoncreds/revocation-registry-definition-private/sqlite.ts +18 -0
- package/src/anoncreds/schema/DrizzleAnonCredsSchemaRecordAdapter.ts +54 -0
- package/src/anoncreds/schema/__tests__/schema.test.ts +66 -0
- package/src/anoncreds/schema/index.ts +10 -0
- package/src/anoncreds/schema/postgres.ts +22 -0
- package/src/anoncreds/schema/sqlite.ts +22 -0
- package/src/anoncreds/sqlite.ts +8 -0
- package/src/applyReactNativeMigrations.ts +24 -0
- package/src/combineSchemas.ts +44 -0
- package/src/core/bundle.ts +33 -0
- package/src/core/context/index.ts +8 -0
- package/src/core/context/postgres.ts +5 -0
- package/src/core/context/sqlite.ts +5 -0
- package/src/core/did/DrizzleDidRecordAdapter.ts +71 -0
- package/src/core/did/index.ts +10 -0
- package/src/core/did/postgres.ts +28 -0
- package/src/core/did/sqlite.ts +26 -0
- package/src/core/genericRecord/DrizzleGenericRecordAdapter.ts +36 -0
- package/src/core/genericRecord/index.ts +10 -0
- package/src/core/genericRecord/postgres.ts +12 -0
- package/src/core/genericRecord/sqlite.ts +12 -0
- package/src/core/mdoc/DrizzleMdocRecordAdapter.ts +44 -0
- package/src/core/mdoc/index.ts +10 -0
- package/src/core/mdoc/postgres.ts +15 -0
- package/src/core/mdoc/sqlite.ts +15 -0
- package/src/core/postgres.ts +8 -0
- package/src/core/sdJwtVc/DrizzleSdJwtVcRecordAdapter.ts +46 -0
- package/src/core/sdJwtVc/index.ts +10 -0
- package/src/core/sdJwtVc/postgres.ts +17 -0
- package/src/core/sdJwtVc/sqlite.ts +17 -0
- package/src/core/singleContextLruCache/DrizzleSingleContextLruCacheRecordAdapter.ts +43 -0
- package/src/core/singleContextLruCache/index.ts +10 -0
- package/src/core/singleContextLruCache/postgres.ts +12 -0
- package/src/core/singleContextLruCache/sqlite.ts +13 -0
- package/src/core/sqlite.ts +8 -0
- package/src/core/storageVersion/DrizzleStorageVersionRecordAdapter.ts +36 -0
- package/src/core/storageVersion/index.ts +10 -0
- package/src/core/storageVersion/postgres.ts +13 -0
- package/src/core/storageVersion/sqlite.ts +13 -0
- package/src/core/w3cCredential/DrizzleW3cCredentialRecordAdapter.ts +95 -0
- package/src/core/w3cCredential/index.ts +10 -0
- package/src/core/w3cCredential/postgres.ts +31 -0
- package/src/core/w3cCredential/sqlite.ts +29 -0
- package/src/didcomm/basic-message/DrizzleDidcommBasicMessageRecordAdapter.ts +54 -0
- package/src/didcomm/basic-message/index.ts +10 -0
- package/src/didcomm/basic-message/postgres.ts +30 -0
- package/src/didcomm/basic-message/sqlite.ts +29 -0
- package/src/didcomm/bundle.ts +34 -0
- package/src/didcomm/connection/DrizzleDidcommConnectionRecordAdapter.ts +70 -0
- package/src/didcomm/connection/index.ts +10 -0
- package/src/didcomm/connection/postgres.ts +55 -0
- package/src/didcomm/connection/sqlite.ts +39 -0
- package/src/didcomm/credential-exchange/DrizzleDidcommCredentialExchangeRecordAdapter.ts +64 -0
- package/src/didcomm/credential-exchange/__tests__/credentialExchange.test.ts +97 -0
- package/src/didcomm/credential-exchange/index.ts +10 -0
- package/src/didcomm/credential-exchange/postgres.ts +45 -0
- package/src/didcomm/credential-exchange/sqlite.ts +39 -0
- package/src/didcomm/didcomm-message/DrizzleDidcommMessageRecordAdapter.ts +75 -0
- package/src/didcomm/didcomm-message/index.ts +10 -0
- package/src/didcomm/didcomm-message/postgres.ts +27 -0
- package/src/didcomm/didcomm-message/sqlite.ts +26 -0
- package/src/didcomm/mediation/DrizzleDidcommMediationRecordAdapter.ts +51 -0
- package/src/didcomm/mediation/index.ts +10 -0
- package/src/didcomm/mediation/postgres.ts +33 -0
- package/src/didcomm/mediation/sqlite.ts +31 -0
- package/src/didcomm/mediator-routing/DrizzleDidcommMediatorRoutingRecordAdapter.ts +49 -0
- package/src/didcomm/mediator-routing/index.ts +10 -0
- package/src/didcomm/mediator-routing/postgres.ts +14 -0
- package/src/didcomm/mediator-routing/sqlite.ts +17 -0
- package/src/didcomm/out-of-band/DrizzleDidcommOutOfBandRecordAdapter.ts +85 -0
- package/src/didcomm/out-of-band/__tests__/outOfBand.test.ts +84 -0
- package/src/didcomm/out-of-band/index.ts +10 -0
- package/src/didcomm/out-of-band/postgres.ts +46 -0
- package/src/didcomm/out-of-band/sqlite.ts +46 -0
- package/src/didcomm/postgres.ts +8 -0
- package/src/didcomm/proof-exchange/DrizzleDidcommProofExchangeRecordAdapter.ts +51 -0
- package/src/didcomm/proof-exchange/index.ts +10 -0
- package/src/didcomm/proof-exchange/postgres.ts +33 -0
- package/src/didcomm/proof-exchange/sqlite.ts +29 -0
- package/src/didcomm/sqlite.ts +8 -0
- package/src/drpc/bundle.ts +18 -0
- package/src/drpc/drpc/DrizzleDidcommDrpcRecordAdapter.ts +44 -0
- package/src/drpc/drpc/index.ts +10 -0
- package/src/drpc/drpc/postgres.ts +31 -0
- package/src/drpc/drpc/sqlite.ts +29 -0
- package/src/drpc/postgres.ts +1 -0
- package/src/drpc/sqlite.ts +1 -0
- package/src/error/CredoDrizzleColumnDoesNotExistError.ts +21 -0
- package/src/error/CredoDrizzleStorageError.ts +7 -0
- package/src/error/index.ts +2 -0
- package/src/index.ts +29 -0
- package/src/openid4vc/bundle.ts +26 -0
- package/src/openid4vc/openid4vc-issuance-session/DrizzleOpenId4VcIssuanceSessionRecordAdapter.ts +90 -0
- package/src/openid4vc/openid4vc-issuance-session/index.ts +10 -0
- package/src/openid4vc/openid4vc-issuance-session/postgres.ts +54 -0
- package/src/openid4vc/openid4vc-issuance-session/sqlite.ts +54 -0
- package/src/openid4vc/openid4vc-issuer/DrizzleOpenid4vcIssuerRecordAdapter.ts +50 -0
- package/src/openid4vc/openid4vc-issuer/index.ts +10 -0
- package/src/openid4vc/openid4vc-issuer/postgres.ts +31 -0
- package/src/openid4vc/openid4vc-issuer/sqlite.ts +40 -0
- package/src/openid4vc/openid4vc-verification-session/DrizzleOpenId4VcVerificationSessionRecordAdapter.ts +62 -0
- package/src/openid4vc/openid4vc-verification-session/index.ts +10 -0
- package/src/openid4vc/openid4vc-verification-session/postgres.ts +46 -0
- package/src/openid4vc/openid4vc-verification-session/sqlite.ts +40 -0
- package/src/openid4vc/openid4vc-verifier/DrizzleOpenid4vcVerifierRecordAdapter.ts +43 -0
- package/src/openid4vc/openid4vc-verifier/index.ts +10 -0
- package/src/openid4vc/openid4vc-verifier/postgres.ts +14 -0
- package/src/openid4vc/openid4vc-verifier/sqlite.ts +19 -0
- package/src/openid4vc/postgres.ts +4 -0
- package/src/openid4vc/sqlite.ts +4 -0
- package/src/postgres/baseRecord.ts +44 -0
- package/src/postgres/index.ts +1 -0
- package/src/question-answer/bundle.ts +18 -0
- package/src/question-answer/postgres.ts +1 -0
- package/src/question-answer/question-answer/DrizzleDidcommQuestionAnswerRecordAdapter.ts +52 -0
- package/src/question-answer/question-answer/index.ts +10 -0
- package/src/question-answer/question-answer/postgres.ts +34 -0
- package/src/question-answer/question-answer/sqlite.ts +32 -0
- package/src/question-answer/sqlite.ts +1 -0
- package/src/sqlite/baseRecord.ts +38 -0
- package/src/sqlite/index.ts +1 -0
- package/src/storage/DrizzleStorageService.ts +87 -0
- package/src/storage/index.ts +1 -0
- package/src/tenants/bundle.ts +19 -0
- package/src/tenants/postgres.ts +2 -0
- package/src/tenants/sqlite.ts +2 -0
- package/src/tenants/tenant/DrizzleTenantRecordAdapter.ts +45 -0
- package/src/tenants/tenant/index.ts +10 -0
- package/src/tenants/tenant/postgres.ts +16 -0
- package/src/tenants/tenant/sqlite.ts +16 -0
- package/src/tenants/tenant-routing/DrizzleTenantRoutingRecordAdapter.ts +44 -0
- package/src/tenants/tenant-routing/index.ts +10 -0
- package/src/tenants/tenant-routing/postgres.ts +20 -0
- package/src/tenants/tenant-routing/sqlite.ts +20 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { JsonObject } from '@credo-ts/core'
|
|
2
|
+
import { AutoAcceptCredential, CredentialRecordBinding, CredentialRole, CredentialState } from '@credo-ts/didcomm'
|
|
3
|
+
import { jsonb, pgEnum, pgTable, text } from 'drizzle-orm/pg-core'
|
|
4
|
+
import { getPostgresBaseRecordTable, postgresBaseRecordIndexes } from '../../postgres/baseRecord'
|
|
5
|
+
|
|
6
|
+
export const didcommCredentialExchangeStateEnum = pgEnum('DidcommCredentialExchangeState', CredentialState)
|
|
7
|
+
export const didcommCredentialExchangeRoleEnum = pgEnum('DidcommCredentialExchangeRole', CredentialRole)
|
|
8
|
+
export const didcommCredentialExchangeAutoAcceptEnum = pgEnum(
|
|
9
|
+
'DidcommCredentialExchangeAutoAccept',
|
|
10
|
+
AutoAcceptCredential
|
|
11
|
+
)
|
|
12
|
+
|
|
13
|
+
export const didcommCredentialExchange = pgTable(
|
|
14
|
+
'DidcommCredentialExchange',
|
|
15
|
+
{
|
|
16
|
+
...getPostgresBaseRecordTable(),
|
|
17
|
+
|
|
18
|
+
connectionId: text('connection_id'),
|
|
19
|
+
threadId: text('thread_id').notNull(),
|
|
20
|
+
parentThreadId: text('parent_thread_id'),
|
|
21
|
+
|
|
22
|
+
state: didcommCredentialExchangeStateEnum().notNull(),
|
|
23
|
+
role: didcommCredentialExchangeRoleEnum().notNull(),
|
|
24
|
+
autoAcceptCredential: didcommCredentialExchangeAutoAcceptEnum('auto_accept_credential'),
|
|
25
|
+
revocationNotification: jsonb('revocation_notification').$type<JsonObject>(),
|
|
26
|
+
errorMessage: text('error_message'),
|
|
27
|
+
protocolVersion: text('protocol_version'),
|
|
28
|
+
|
|
29
|
+
credentials: jsonb().$type<CredentialRecordBinding[]>(),
|
|
30
|
+
credentialIds: text('credential_ids').array(), // same as credentials, but queryable
|
|
31
|
+
|
|
32
|
+
credentialAttributes: jsonb('credential_attributes').$type<JsonObject[]>(),
|
|
33
|
+
linkedAttachments: jsonb('linked_attachments').$type<JsonObject[]>(),
|
|
34
|
+
},
|
|
35
|
+
(table) => [
|
|
36
|
+
...postgresBaseRecordIndexes(table, 'didcommCredentialExchange'),
|
|
37
|
+
// TODO: we only want to set the `connectionId` to null on delete of
|
|
38
|
+
// the associated connection, but that's not possible with composite foreign keys
|
|
39
|
+
// so we need to add a custom trigger for that.
|
|
40
|
+
// foreignKey({
|
|
41
|
+
// columns: [table.connectionId, table.contextCorrelationId],
|
|
42
|
+
// foreignColumns: [didcommConnection.id, didcommConnection.contextCorrelationId],
|
|
43
|
+
// }).onDelete('cascade'),
|
|
44
|
+
]
|
|
45
|
+
)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { sqliteTable, text } from 'drizzle-orm/sqlite-core'
|
|
2
|
+
|
|
3
|
+
import { JsonObject } from '@credo-ts/core'
|
|
4
|
+
import { AutoAcceptCredential, CredentialRecordBinding, CredentialRole, CredentialState } from '@credo-ts/didcomm'
|
|
5
|
+
import { getSqliteBaseRecordTable, sqliteBaseRecordIndexes } from '../../sqlite/baseRecord'
|
|
6
|
+
|
|
7
|
+
export const didcommCredentialExchange = sqliteTable(
|
|
8
|
+
'DidcommCredentialExchange',
|
|
9
|
+
{
|
|
10
|
+
...getSqliteBaseRecordTable(),
|
|
11
|
+
|
|
12
|
+
connectionId: text('connection_id'),
|
|
13
|
+
threadId: text('thread_id').notNull(),
|
|
14
|
+
parentThreadId: text('parent_thread_id'),
|
|
15
|
+
|
|
16
|
+
state: text().$type<CredentialState>().notNull(),
|
|
17
|
+
role: text().$type<CredentialRole>().notNull(),
|
|
18
|
+
autoAcceptCredential: text('auto_accept_credential').$type<AutoAcceptCredential>(),
|
|
19
|
+
revocationNotification: text('revocation_notification', { mode: 'json' }).$type<JsonObject>(),
|
|
20
|
+
errorMessage: text('error_message'),
|
|
21
|
+
protocolVersion: text('protocol_version'),
|
|
22
|
+
|
|
23
|
+
credentials: text({ mode: 'json' }).$type<CredentialRecordBinding[]>(),
|
|
24
|
+
credentialIds: text('credential_ids', { mode: 'json' }).$type<string[]>(), // same as credentials, but queryable
|
|
25
|
+
|
|
26
|
+
credentialAttributes: text('credential_attributes', { mode: 'json' }).$type<JsonObject[]>(),
|
|
27
|
+
linkedAttachments: text('linked_attachments', { mode: 'json' }).$type<JsonObject[]>(),
|
|
28
|
+
},
|
|
29
|
+
(table) => [
|
|
30
|
+
...sqliteBaseRecordIndexes(table, 'didcommCredentialExchange'),
|
|
31
|
+
// TODO: we only want to set the `connectionId` to null on delete of
|
|
32
|
+
// the associated connection, but that's not possible with composite foreign keys
|
|
33
|
+
// so we need to add a custom trigger for that.
|
|
34
|
+
// foreignKey({
|
|
35
|
+
// columns: [table.connectionId, table.contextCorrelationId],
|
|
36
|
+
// foreignColumns: [didcommConnection.id, didcommConnection.contextCorrelationId],
|
|
37
|
+
// }).onDelete('cascade'),
|
|
38
|
+
]
|
|
39
|
+
)
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { JsonTransformer, TagsBase } from '@credo-ts/core'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
BaseDrizzleRecordAdapter,
|
|
5
|
+
DrizzleAdapterRecordValues,
|
|
6
|
+
DrizzleAdapterValues,
|
|
7
|
+
} from '../../adapter/BaseDrizzleRecordAdapter'
|
|
8
|
+
|
|
9
|
+
import { DidCommMessageRecord } from '@credo-ts/didcomm'
|
|
10
|
+
import { DrizzleDatabase } from '../../DrizzleDatabase'
|
|
11
|
+
import * as postgres from './postgres'
|
|
12
|
+
import * as sqlite from './sqlite'
|
|
13
|
+
|
|
14
|
+
type DrizzleDidcommMessageAdapterValues = DrizzleAdapterRecordValues<(typeof sqlite)['didcommMessage']>
|
|
15
|
+
export class DrizzleDidcommMessageRecordAdapter extends BaseDrizzleRecordAdapter<
|
|
16
|
+
DidCommMessageRecord,
|
|
17
|
+
typeof postgres.didcommMessage,
|
|
18
|
+
typeof postgres,
|
|
19
|
+
typeof sqlite.didcommMessage,
|
|
20
|
+
typeof sqlite
|
|
21
|
+
> {
|
|
22
|
+
public constructor(database: DrizzleDatabase<typeof postgres, typeof sqlite>) {
|
|
23
|
+
super(database, { postgres: postgres.didcommMessage, sqlite: sqlite.didcommMessage }, 'DidCommMessageRecord')
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public tagKeyMapping = {
|
|
27
|
+
messageType: ['message', '@type'],
|
|
28
|
+
messageId: ['message', '@id'],
|
|
29
|
+
} as const
|
|
30
|
+
|
|
31
|
+
public getValues(record: DidCommMessageRecord): DrizzleAdapterValues<(typeof sqlite)['didcommMessage']> {
|
|
32
|
+
const {
|
|
33
|
+
role,
|
|
34
|
+
associatedRecordId,
|
|
35
|
+
messageId,
|
|
36
|
+
messageName,
|
|
37
|
+
messageType,
|
|
38
|
+
protocolMajorVersion,
|
|
39
|
+
protocolMinorVersion,
|
|
40
|
+
protocolName,
|
|
41
|
+
threadId,
|
|
42
|
+
...customTags
|
|
43
|
+
} = record.getTags()
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
message: record.message,
|
|
47
|
+
role,
|
|
48
|
+
|
|
49
|
+
associatedRecordId,
|
|
50
|
+
|
|
51
|
+
// These are access on message['@type'] and message['@id']
|
|
52
|
+
// messageType,
|
|
53
|
+
// messageId,
|
|
54
|
+
|
|
55
|
+
threadId,
|
|
56
|
+
protocolName,
|
|
57
|
+
messageName,
|
|
58
|
+
|
|
59
|
+
protocolMajorVersion,
|
|
60
|
+
protocolMinorVersion,
|
|
61
|
+
|
|
62
|
+
customTags,
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
public toRecord(values: DrizzleDidcommMessageAdapterValues): DidCommMessageRecord {
|
|
67
|
+
const { customTags, messageName, protocolMajorVersion, protocolMinorVersion, protocolName, ...remainingValues } =
|
|
68
|
+
values
|
|
69
|
+
|
|
70
|
+
const record = JsonTransformer.fromJSON(remainingValues, DidCommMessageRecord)
|
|
71
|
+
record.setTags(customTags as TagsBase)
|
|
72
|
+
|
|
73
|
+
return record
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DrizzleRecord } from '../../DrizzleRecord'
|
|
2
|
+
import { DrizzleDidcommMessageRecordAdapter } from './DrizzleDidcommMessageRecordAdapter'
|
|
3
|
+
import * as postgres from './postgres'
|
|
4
|
+
import * as sqlite from './sqlite'
|
|
5
|
+
|
|
6
|
+
export const didcommMessageDrizzleRecord = {
|
|
7
|
+
adapter: DrizzleDidcommMessageRecordAdapter,
|
|
8
|
+
postgres,
|
|
9
|
+
sqlite,
|
|
10
|
+
} satisfies DrizzleRecord
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { DidCommMessageRole, PlaintextMessage } from '@credo-ts/didcomm'
|
|
2
|
+
import { jsonb, pgEnum, pgTable, text } from 'drizzle-orm/pg-core'
|
|
3
|
+
import { getPostgresBaseRecordTable, postgresBaseRecordIndexes } from '../../postgres/baseRecord'
|
|
4
|
+
|
|
5
|
+
export const didcommMessageRoleEnum = pgEnum('DidcommMessageRole', DidCommMessageRole)
|
|
6
|
+
|
|
7
|
+
export const didcommMessage = pgTable(
|
|
8
|
+
'DidcommMessage',
|
|
9
|
+
{
|
|
10
|
+
...getPostgresBaseRecordTable(),
|
|
11
|
+
|
|
12
|
+
message: jsonb().$type<PlaintextMessage>().notNull(),
|
|
13
|
+
role: didcommMessageRoleEnum().notNull(),
|
|
14
|
+
|
|
15
|
+
// We can't really put a foreign key on this...
|
|
16
|
+
// in that case we need to create a separate column for each possible record
|
|
17
|
+
associatedRecordId: text('associated_record_id'),
|
|
18
|
+
|
|
19
|
+
// Tags we can't query directy
|
|
20
|
+
threadId: text('thread_id').notNull(),
|
|
21
|
+
protocolName: text('protocol_name').notNull(),
|
|
22
|
+
messageName: text('message_name').notNull(),
|
|
23
|
+
protocolMajorVersion: text('protocol_major_version').notNull(),
|
|
24
|
+
protocolMinorVersion: text('protocol_minor_version').notNull(),
|
|
25
|
+
},
|
|
26
|
+
(table) => postgresBaseRecordIndexes(table, 'didcommMessage')
|
|
27
|
+
)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { sqliteTable, text } from 'drizzle-orm/sqlite-core'
|
|
2
|
+
|
|
3
|
+
import { DidCommMessageRole, PlaintextMessage } from '@credo-ts/didcomm'
|
|
4
|
+
import { getSqliteBaseRecordTable, sqliteBaseRecordIndexes } from '../../sqlite/baseRecord'
|
|
5
|
+
|
|
6
|
+
export const didcommMessage = sqliteTable(
|
|
7
|
+
'DidcommMessage',
|
|
8
|
+
{
|
|
9
|
+
...getSqliteBaseRecordTable(),
|
|
10
|
+
|
|
11
|
+
message: text({ mode: 'json' }).$type<PlaintextMessage>().notNull(),
|
|
12
|
+
role: text().$type<DidCommMessageRole>().notNull(),
|
|
13
|
+
|
|
14
|
+
// We can't really put a foreign key on this...
|
|
15
|
+
// in that case we need to create a separate column for each possible record
|
|
16
|
+
associatedRecordId: text('associated_record_id'),
|
|
17
|
+
|
|
18
|
+
// Tags we can't query directy
|
|
19
|
+
threadId: text('thread_id').notNull(),
|
|
20
|
+
protocolName: text('protocol_name').notNull(),
|
|
21
|
+
messageName: text('message_name').notNull(),
|
|
22
|
+
protocolMajorVersion: text('protocol_major_version').notNull(),
|
|
23
|
+
protocolMinorVersion: text('protocol_minor_version').notNull(),
|
|
24
|
+
},
|
|
25
|
+
(table) => sqliteBaseRecordIndexes(table, 'didcommMessage')
|
|
26
|
+
)
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { JsonTransformer } from '@credo-ts/core'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
BaseDrizzleRecordAdapter,
|
|
5
|
+
DrizzleAdapterRecordValues,
|
|
6
|
+
DrizzleAdapterValues,
|
|
7
|
+
} from '../../adapter/BaseDrizzleRecordAdapter'
|
|
8
|
+
|
|
9
|
+
import { MediationRecord } from '@credo-ts/didcomm'
|
|
10
|
+
import { DrizzleDatabase } from '../../DrizzleDatabase'
|
|
11
|
+
import * as postgres from './postgres'
|
|
12
|
+
import * as sqlite from './sqlite'
|
|
13
|
+
|
|
14
|
+
type DrizzleDidcommMediationAdapterValues = DrizzleAdapterRecordValues<(typeof sqlite)['didcommMediation']>
|
|
15
|
+
export class DrizzleDidcommMediationRecordAdapter extends BaseDrizzleRecordAdapter<
|
|
16
|
+
MediationRecord,
|
|
17
|
+
typeof postgres.didcommMediation,
|
|
18
|
+
typeof postgres,
|
|
19
|
+
typeof sqlite.didcommMediation,
|
|
20
|
+
typeof sqlite
|
|
21
|
+
> {
|
|
22
|
+
public constructor(database: DrizzleDatabase<typeof postgres, typeof sqlite>) {
|
|
23
|
+
super(database, { postgres: postgres.didcommMediation, sqlite: sqlite.didcommMediation }, 'MediationRecord')
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public getValues(record: MediationRecord): DrizzleAdapterValues<(typeof sqlite)['didcommMediation']> {
|
|
27
|
+
const { connectionId, recipientKeys, role, state, threadId, default: defaultTag, ...customTags } = record.getTags()
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
connectionId,
|
|
31
|
+
recipientKeys,
|
|
32
|
+
role,
|
|
33
|
+
state,
|
|
34
|
+
threadId,
|
|
35
|
+
default: defaultTag,
|
|
36
|
+
routingKeys: record.routingKeys,
|
|
37
|
+
endpoint: record.endpoint,
|
|
38
|
+
pickupStrategy: record.pickupStrategy,
|
|
39
|
+
customTags,
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public toRecord(values: DrizzleDidcommMediationAdapterValues): MediationRecord {
|
|
44
|
+
const { customTags, default: defaultTag, ...remainingValues } = values
|
|
45
|
+
|
|
46
|
+
const record = JsonTransformer.fromJSON(remainingValues, MediationRecord)
|
|
47
|
+
record.setTags({ ...customTags, default: defaultTag ?? undefined })
|
|
48
|
+
|
|
49
|
+
return record
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DrizzleRecord } from '../../DrizzleRecord'
|
|
2
|
+
import { DrizzleDidcommMediationRecordAdapter } from './DrizzleDidcommMediationRecordAdapter'
|
|
3
|
+
import * as postgres from './postgres'
|
|
4
|
+
import * as sqlite from './sqlite'
|
|
5
|
+
|
|
6
|
+
export const didcommMediationDrizzleRecord = {
|
|
7
|
+
adapter: DrizzleDidcommMediationRecordAdapter,
|
|
8
|
+
postgres,
|
|
9
|
+
sqlite,
|
|
10
|
+
} satisfies DrizzleRecord
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { MediationRole, MediationState, MediatorPickupStrategy } from '@credo-ts/didcomm'
|
|
2
|
+
import { boolean, foreignKey, pgEnum, pgTable, text } from 'drizzle-orm/pg-core'
|
|
3
|
+
import { getPostgresBaseRecordTable, postgresBaseRecordIndexes } from '../../postgres/baseRecord'
|
|
4
|
+
import { didcommConnection } from '../postgres'
|
|
5
|
+
|
|
6
|
+
export const didcommMediationStateEnum = pgEnum('DidcommMediationState', MediationState)
|
|
7
|
+
export const didcommMediationRoleEnum = pgEnum('DidcommMediationRole', MediationRole)
|
|
8
|
+
export const didcommMediationPickupStrategyEnum = pgEnum('DidcommMediationPickupStrategry', MediatorPickupStrategy)
|
|
9
|
+
|
|
10
|
+
export const didcommMediation = pgTable(
|
|
11
|
+
'DidcommMediation',
|
|
12
|
+
{
|
|
13
|
+
...getPostgresBaseRecordTable(),
|
|
14
|
+
state: didcommMediationStateEnum().notNull(),
|
|
15
|
+
role: didcommMediationRoleEnum().notNull(),
|
|
16
|
+
connectionId: text('connection_id').notNull(),
|
|
17
|
+
threadId: text('thread_id').notNull(),
|
|
18
|
+
endpoint: text(),
|
|
19
|
+
|
|
20
|
+
recipientKeys: text('recipient_keys').array().notNull(),
|
|
21
|
+
routingKeys: text('routing_keys').array().notNull(),
|
|
22
|
+
pickupStrategy: didcommMediationPickupStrategyEnum('pickup_strategy'),
|
|
23
|
+
|
|
24
|
+
default: boolean(),
|
|
25
|
+
},
|
|
26
|
+
(table) => [
|
|
27
|
+
...postgresBaseRecordIndexes(table, 'didcommMediation'),
|
|
28
|
+
foreignKey({
|
|
29
|
+
columns: [table.connectionId, table.contextCorrelationId],
|
|
30
|
+
foreignColumns: [didcommConnection.id, didcommConnection.contextCorrelationId],
|
|
31
|
+
}).onDelete('cascade'),
|
|
32
|
+
]
|
|
33
|
+
)
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { foreignKey, integer, sqliteTable, text } from 'drizzle-orm/sqlite-core'
|
|
2
|
+
|
|
3
|
+
import { MediationRole, MediationState, MediatorPickupStrategy } from '@credo-ts/didcomm'
|
|
4
|
+
import { getSqliteBaseRecordTable, sqliteBaseRecordIndexes } from '../../sqlite/baseRecord'
|
|
5
|
+
import { didcommConnection } from '../sqlite'
|
|
6
|
+
|
|
7
|
+
export const didcommMediation = sqliteTable(
|
|
8
|
+
'DidcommMediation',
|
|
9
|
+
{
|
|
10
|
+
...getSqliteBaseRecordTable(),
|
|
11
|
+
|
|
12
|
+
state: text().$type<MediationState>().notNull(),
|
|
13
|
+
role: text().$type<MediationRole>().notNull(),
|
|
14
|
+
connectionId: text('connection_id').notNull(),
|
|
15
|
+
threadId: text('thread_id').notNull(),
|
|
16
|
+
endpoint: text(),
|
|
17
|
+
|
|
18
|
+
recipientKeys: text('recipient_keys', { mode: 'json' }).$type<string[]>().notNull(),
|
|
19
|
+
routingKeys: text('routing_keys', { mode: 'json' }).$type<string[]>().notNull(),
|
|
20
|
+
pickupStrategy: text('pickup_strategy').$type<MediatorPickupStrategy>(),
|
|
21
|
+
|
|
22
|
+
default: integer({ mode: 'boolean' }),
|
|
23
|
+
},
|
|
24
|
+
(table) => [
|
|
25
|
+
...sqliteBaseRecordIndexes(table, 'didcommMediation'),
|
|
26
|
+
foreignKey({
|
|
27
|
+
columns: [table.connectionId, table.contextCorrelationId],
|
|
28
|
+
foreignColumns: [didcommConnection.id, didcommConnection.contextCorrelationId],
|
|
29
|
+
}).onDelete('cascade'),
|
|
30
|
+
]
|
|
31
|
+
)
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { JsonTransformer, TagsBase } from '@credo-ts/core'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
BaseDrizzleRecordAdapter,
|
|
5
|
+
DrizzleAdapterRecordValues,
|
|
6
|
+
DrizzleAdapterValues,
|
|
7
|
+
} from '../../adapter/BaseDrizzleRecordAdapter'
|
|
8
|
+
|
|
9
|
+
import { MediatorRoutingRecord } from '@credo-ts/didcomm'
|
|
10
|
+
import { DrizzleDatabase } from '../../DrizzleDatabase'
|
|
11
|
+
import * as postgres from './postgres'
|
|
12
|
+
import * as sqlite from './sqlite'
|
|
13
|
+
|
|
14
|
+
type DrizzleDidcommMediatorRoutingAdapterValues = DrizzleAdapterRecordValues<(typeof sqlite)['didcommMediatorRouting']>
|
|
15
|
+
export class DrizzleDidcommMediatorRoutingRecordAdapter extends BaseDrizzleRecordAdapter<
|
|
16
|
+
MediatorRoutingRecord,
|
|
17
|
+
typeof postgres.didcommMediatorRouting,
|
|
18
|
+
typeof postgres,
|
|
19
|
+
typeof sqlite.didcommMediatorRouting,
|
|
20
|
+
typeof sqlite
|
|
21
|
+
> {
|
|
22
|
+
public constructor(database: DrizzleDatabase<typeof postgres, typeof sqlite>) {
|
|
23
|
+
super(
|
|
24
|
+
database,
|
|
25
|
+
{ postgres: postgres.didcommMediatorRouting, sqlite: sqlite.didcommMediatorRouting },
|
|
26
|
+
'MediatorRoutingRecord'
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public getValues(record: MediatorRoutingRecord): DrizzleAdapterValues<(typeof sqlite)['didcommMediatorRouting']> {
|
|
31
|
+
const { routingKeyFingerprints, ...customTags } = record.getTags()
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
routingKeyFingerprints,
|
|
35
|
+
routingKeys: record.routingKeys,
|
|
36
|
+
|
|
37
|
+
customTags,
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public toRecord(values: DrizzleDidcommMediatorRoutingAdapterValues): MediatorRoutingRecord {
|
|
42
|
+
const { customTags, ...remainingValues } = values
|
|
43
|
+
|
|
44
|
+
const record = JsonTransformer.fromJSON(remainingValues, MediatorRoutingRecord)
|
|
45
|
+
record.setTags(customTags as TagsBase)
|
|
46
|
+
|
|
47
|
+
return record
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DrizzleRecord } from '../../DrizzleRecord'
|
|
2
|
+
import { DrizzleDidcommMediatorRoutingRecordAdapter } from './DrizzleDidcommMediatorRoutingRecordAdapter'
|
|
3
|
+
import * as postgres from './postgres'
|
|
4
|
+
import * as sqlite from './sqlite'
|
|
5
|
+
|
|
6
|
+
export const didcommMediatorRoutingDrizzleRecord = {
|
|
7
|
+
adapter: DrizzleDidcommMediatorRoutingRecordAdapter,
|
|
8
|
+
postgres,
|
|
9
|
+
sqlite,
|
|
10
|
+
} satisfies DrizzleRecord
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { MediatorRoutingRecordRoutingKey } from '@credo-ts/didcomm'
|
|
2
|
+
import { jsonb, pgTable, text } from 'drizzle-orm/pg-core'
|
|
3
|
+
import { getPostgresBaseRecordTable, postgresBaseRecordIndexes } from '../../postgres/baseRecord'
|
|
4
|
+
|
|
5
|
+
export const didcommMediatorRouting = pgTable(
|
|
6
|
+
'DidcommMediatorRouting',
|
|
7
|
+
{
|
|
8
|
+
...getPostgresBaseRecordTable(),
|
|
9
|
+
|
|
10
|
+
routingKeys: jsonb('routing_keys').$type<Array<string | MediatorRoutingRecordRoutingKey>>().notNull(),
|
|
11
|
+
routingKeyFingerprints: text('routing_key_fingerprints').array().notNull(),
|
|
12
|
+
},
|
|
13
|
+
(table) => postgresBaseRecordIndexes(table, 'didcommMediatorRouting')
|
|
14
|
+
)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { sqliteTable, text } from 'drizzle-orm/sqlite-core'
|
|
2
|
+
|
|
3
|
+
import { MediatorRoutingRecordRoutingKey } from '@credo-ts/didcomm'
|
|
4
|
+
import { getSqliteBaseRecordTable, sqliteBaseRecordIndexes } from '../../sqlite/baseRecord'
|
|
5
|
+
|
|
6
|
+
export const didcommMediatorRouting = sqliteTable(
|
|
7
|
+
'DidcommMediatorRouting',
|
|
8
|
+
{
|
|
9
|
+
...getSqliteBaseRecordTable(),
|
|
10
|
+
|
|
11
|
+
routingKeys: text('routing_keys', { mode: 'json' })
|
|
12
|
+
.$type<Array<string | MediatorRoutingRecordRoutingKey>>()
|
|
13
|
+
.notNull(),
|
|
14
|
+
routingKeyFingerprints: text('routing_key_fingerprints', { mode: 'json' }).$type<string[]>().notNull(),
|
|
15
|
+
},
|
|
16
|
+
(table) => sqliteBaseRecordIndexes(table, 'didcommMediatorRouting')
|
|
17
|
+
)
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { JsonTransformer } from '@credo-ts/core'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
BaseDrizzleRecordAdapter,
|
|
5
|
+
DrizzleAdapterRecordValues,
|
|
6
|
+
DrizzleAdapterValues,
|
|
7
|
+
} from '../../adapter/BaseDrizzleRecordAdapter'
|
|
8
|
+
|
|
9
|
+
import { OutOfBandRecord } from '@credo-ts/didcomm'
|
|
10
|
+
import { DrizzleDatabase } from '../../DrizzleDatabase'
|
|
11
|
+
import * as postgres from './postgres'
|
|
12
|
+
import * as sqlite from './sqlite'
|
|
13
|
+
|
|
14
|
+
type DrizzleDidcommOutOfBandAdapterValues = DrizzleAdapterRecordValues<(typeof sqlite)['didcommOutOfBand']>
|
|
15
|
+
export class DrizzleDidcommOutOfBandRecordAdapter extends BaseDrizzleRecordAdapter<
|
|
16
|
+
OutOfBandRecord,
|
|
17
|
+
typeof postgres.didcommOutOfBand,
|
|
18
|
+
typeof postgres,
|
|
19
|
+
typeof sqlite.didcommOutOfBand,
|
|
20
|
+
typeof sqlite
|
|
21
|
+
> {
|
|
22
|
+
public constructor(database: DrizzleDatabase<typeof postgres, typeof sqlite>) {
|
|
23
|
+
super(database, { postgres: postgres.didcommOutOfBand, sqlite: sqlite.didcommOutOfBand }, 'OutOfBandRecord')
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public tagKeyMapping = {
|
|
27
|
+
invitationId: ['outOfBandInvitation', '@id'],
|
|
28
|
+
} as const
|
|
29
|
+
|
|
30
|
+
public getValues(record: OutOfBandRecord): DrizzleAdapterValues<(typeof sqlite)['didcommOutOfBand']> {
|
|
31
|
+
const {
|
|
32
|
+
invitationRequestsThreadIds,
|
|
33
|
+
recipientKeyFingerprints,
|
|
34
|
+
role,
|
|
35
|
+
state,
|
|
36
|
+
threadId,
|
|
37
|
+
recipientRoutingKeyFingerprint,
|
|
38
|
+
|
|
39
|
+
// Queried based on `outOfBandInvitation.@id`
|
|
40
|
+
invitationId,
|
|
41
|
+
|
|
42
|
+
...customTags
|
|
43
|
+
} = record.getTags()
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
invitationRequestsThreadIds,
|
|
47
|
+
role,
|
|
48
|
+
state,
|
|
49
|
+
threadId,
|
|
50
|
+
|
|
51
|
+
recipientKeyFingerprints,
|
|
52
|
+
recipientRoutingKeyFingerprint,
|
|
53
|
+
|
|
54
|
+
outOfBandInvitation: record.outOfBandInvitation.toJSON(),
|
|
55
|
+
reusable: record.reusable,
|
|
56
|
+
alias: record.alias,
|
|
57
|
+
autoAcceptConnection: record.autoAcceptConnection,
|
|
58
|
+
invitationInlineServiceKeys: record.invitationInlineServiceKeys,
|
|
59
|
+
mediatorId: record.mediatorId,
|
|
60
|
+
reuseConnectionId: record.reuseConnectionId,
|
|
61
|
+
|
|
62
|
+
customTags,
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
public toRecord(values: DrizzleDidcommOutOfBandAdapterValues): OutOfBandRecord {
|
|
67
|
+
const {
|
|
68
|
+
customTags,
|
|
69
|
+
recipientKeyFingerprints,
|
|
70
|
+
recipientRoutingKeyFingerprint,
|
|
71
|
+
threadId,
|
|
72
|
+
invitationRequestsThreadIds,
|
|
73
|
+
...remainingValues
|
|
74
|
+
} = values
|
|
75
|
+
|
|
76
|
+
const record = JsonTransformer.fromJSON(remainingValues, OutOfBandRecord)
|
|
77
|
+
record.setTags({
|
|
78
|
+
...customTags,
|
|
79
|
+
recipientKeyFingerprints: recipientKeyFingerprints ?? undefined,
|
|
80
|
+
recipientRoutingKeyFingerprint: recipientRoutingKeyFingerprint ?? undefined,
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
return record
|
|
84
|
+
}
|
|
85
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { Agent, JsonTransformer } from '@credo-ts/core'
|
|
2
|
+
|
|
3
|
+
import { OutOfBandRecord, OutOfBandRepository } from '@credo-ts/didcomm'
|
|
4
|
+
import { setupDrizzleRecordTest } from '../../../../tests/testDatabase'
|
|
5
|
+
import { didcommOutOfBandDrizzleRecord } from '../index'
|
|
6
|
+
|
|
7
|
+
describe.each(['postgres', 'sqlite'] as const)('OutOfBandRecord with %s', (type) => {
|
|
8
|
+
let agent: Agent
|
|
9
|
+
|
|
10
|
+
beforeAll(async () => {
|
|
11
|
+
agent = await setupDrizzleRecordTest(type, didcommOutOfBandDrizzleRecord)
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
test('create, retrieve, update, query and delete out of band record', async () => {
|
|
15
|
+
const outOfBand = JsonTransformer.fromJSON(
|
|
16
|
+
{
|
|
17
|
+
_tags: {},
|
|
18
|
+
metadata: {},
|
|
19
|
+
id: 'd565b4d8-3e5d-42da-a87c-4454fdfbaff0',
|
|
20
|
+
createdAt: '2022-06-02T18:35:06.374Z',
|
|
21
|
+
outOfBandInvitation: {
|
|
22
|
+
'@type': 'https://didcomm.org/out-of-band/1.1/invitation',
|
|
23
|
+
'@id': '5d57ca2d-80ed-432c-8def-c40c75e8ab09',
|
|
24
|
+
label: 'Faber College',
|
|
25
|
+
goalCode: 'p2p-messaging',
|
|
26
|
+
goal: 'To make a connection',
|
|
27
|
+
accept: ['didcomm/aip1', 'didcomm/aip2;env=rfc19'],
|
|
28
|
+
handshake_protocols: ['https://didcomm.org/didexchange/1.0', 'https://didcomm.org/connections/1.0'],
|
|
29
|
+
services: [
|
|
30
|
+
{
|
|
31
|
+
id: '#inline-0',
|
|
32
|
+
serviceEndpoint: 'rxjs:faber',
|
|
33
|
+
type: 'did-communication',
|
|
34
|
+
recipientKeys: ['did:key:z6MkhngxtGfzTvGVbFjVVqBHvniY1f2XrTMZLM5BZvPh31Dc'],
|
|
35
|
+
routingKeys: [],
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
},
|
|
39
|
+
role: 'sender',
|
|
40
|
+
state: 'await-response',
|
|
41
|
+
autoAcceptConnection: true,
|
|
42
|
+
reusable: false,
|
|
43
|
+
},
|
|
44
|
+
OutOfBandRecord
|
|
45
|
+
)
|
|
46
|
+
const outOfBandRepository = agent.context.resolve(OutOfBandRepository)
|
|
47
|
+
|
|
48
|
+
await outOfBandRepository.save(agent.context, outOfBand)
|
|
49
|
+
|
|
50
|
+
const outOfBand2 = await outOfBandRepository.findById(agent.context, outOfBand.id)
|
|
51
|
+
expect(outOfBand.toJSON()).toEqual(outOfBand2?.toJSON())
|
|
52
|
+
|
|
53
|
+
outOfBand.setTags({
|
|
54
|
+
myCustomTag: 'hello',
|
|
55
|
+
isMorning: false,
|
|
56
|
+
})
|
|
57
|
+
await outOfBandRepository.update(agent.context, outOfBand)
|
|
58
|
+
|
|
59
|
+
const [outOfBand3] = await outOfBandRepository.findByQuery(agent.context, {
|
|
60
|
+
isMorning: false,
|
|
61
|
+
|
|
62
|
+
// Tests custom tag mapping (invitationId -> outOfBandInvitation[@id])
|
|
63
|
+
invitationId: '5d57ca2d-80ed-432c-8def-c40c75e8ab09',
|
|
64
|
+
})
|
|
65
|
+
expect(outOfBand3.toJSON()).toEqual(outOfBand.toJSON())
|
|
66
|
+
|
|
67
|
+
const [outOfBand4] = await outOfBandRepository.findByQuery(agent.context, {
|
|
68
|
+
isMorning: false,
|
|
69
|
+
// Id does not exist
|
|
70
|
+
invitationId: 'a0b7c554-0beb-4a4c-808a-fd4495241770',
|
|
71
|
+
})
|
|
72
|
+
expect(outOfBand4).toBeUndefined()
|
|
73
|
+
|
|
74
|
+
expect(
|
|
75
|
+
await outOfBandRepository.findByQuery(agent.context, {
|
|
76
|
+
myCustomTag: 'not-hello',
|
|
77
|
+
})
|
|
78
|
+
).toHaveLength(0)
|
|
79
|
+
|
|
80
|
+
await outOfBandRepository.deleteById(agent.context, outOfBand.id)
|
|
81
|
+
|
|
82
|
+
expect(await outOfBandRepository.findByQuery(agent.context, {})).toHaveLength(0)
|
|
83
|
+
})
|
|
84
|
+
})
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DrizzleRecord } from '../../DrizzleRecord'
|
|
2
|
+
import { DrizzleDidcommOutOfBandRecordAdapter } from './DrizzleDidcommOutOfBandRecordAdapter'
|
|
3
|
+
import * as postgres from './postgres'
|
|
4
|
+
import * as sqlite from './sqlite'
|
|
5
|
+
|
|
6
|
+
export const didcommOutOfBandDrizzleRecord = {
|
|
7
|
+
adapter: DrizzleDidcommOutOfBandRecordAdapter,
|
|
8
|
+
postgres,
|
|
9
|
+
sqlite,
|
|
10
|
+
} satisfies DrizzleRecord
|