@credo-ts/drizzle-storage 0.6.0-pr-2324-20250708122332 → 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/cli-build/utils.js +4 -1
- package/cli-build/utils.js.map +1 -1
- 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,95 @@
|
|
|
1
|
+
import { JsonTransformer, W3cCredentialRecord } from '@credo-ts/core'
|
|
2
|
+
|
|
3
|
+
import { BaseDrizzleRecordAdapter, DrizzleAdapterRecordValues } from '../../adapter/BaseDrizzleRecordAdapter'
|
|
4
|
+
|
|
5
|
+
import { DrizzleDatabase } from '../../DrizzleDatabase'
|
|
6
|
+
import * as postgres from './postgres'
|
|
7
|
+
import * as sqlite from './sqlite'
|
|
8
|
+
|
|
9
|
+
type DrizzleW3cCredentialAdapterValues = DrizzleAdapterRecordValues<(typeof sqlite)['w3cCredential']>
|
|
10
|
+
export class DrizzleW3cCredentialRecordAdapter extends BaseDrizzleRecordAdapter<
|
|
11
|
+
W3cCredentialRecord,
|
|
12
|
+
typeof postgres.w3cCredential,
|
|
13
|
+
typeof postgres,
|
|
14
|
+
typeof sqlite.w3cCredential,
|
|
15
|
+
typeof sqlite
|
|
16
|
+
> {
|
|
17
|
+
public constructor(database: DrizzleDatabase<typeof postgres, typeof sqlite>) {
|
|
18
|
+
super(database, { postgres: postgres.w3cCredential, sqlite: sqlite.w3cCredential }, 'W3cCredentialRecord')
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public getValues(record: W3cCredentialRecord) {
|
|
22
|
+
const {
|
|
23
|
+
// Default Tags
|
|
24
|
+
issuerId,
|
|
25
|
+
subjectIds,
|
|
26
|
+
schemaIds,
|
|
27
|
+
contexts,
|
|
28
|
+
types,
|
|
29
|
+
givenId,
|
|
30
|
+
claimFormat,
|
|
31
|
+
proofTypes,
|
|
32
|
+
cryptosuites,
|
|
33
|
+
algs,
|
|
34
|
+
|
|
35
|
+
// Custom Tags
|
|
36
|
+
expandedTypes,
|
|
37
|
+
...customTags
|
|
38
|
+
} = record.getTags()
|
|
39
|
+
|
|
40
|
+
return {
|
|
41
|
+
// JWT vc is string, JSON-LD vc is object
|
|
42
|
+
credential: record.credential.encoded,
|
|
43
|
+
|
|
44
|
+
// Tags
|
|
45
|
+
issuerId,
|
|
46
|
+
subjectIds,
|
|
47
|
+
schemaIds,
|
|
48
|
+
contexts,
|
|
49
|
+
types,
|
|
50
|
+
givenId,
|
|
51
|
+
claimFormat,
|
|
52
|
+
proofTypes,
|
|
53
|
+
cryptosuites,
|
|
54
|
+
algs,
|
|
55
|
+
customTags,
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
public toRecord(values: DrizzleW3cCredentialAdapterValues): W3cCredentialRecord {
|
|
60
|
+
const {
|
|
61
|
+
// Tags
|
|
62
|
+
issuerId,
|
|
63
|
+
subjectIds,
|
|
64
|
+
schemaIds,
|
|
65
|
+
contexts,
|
|
66
|
+
types,
|
|
67
|
+
givenId,
|
|
68
|
+
claimFormat,
|
|
69
|
+
proofTypes,
|
|
70
|
+
cryptosuites,
|
|
71
|
+
algs,
|
|
72
|
+
expandedTypes,
|
|
73
|
+
customTags,
|
|
74
|
+
...remainingValues
|
|
75
|
+
} = values
|
|
76
|
+
|
|
77
|
+
const record = JsonTransformer.fromJSON(remainingValues, W3cCredentialRecord)
|
|
78
|
+
record.setTags({
|
|
79
|
+
issuerId,
|
|
80
|
+
subjectIds,
|
|
81
|
+
schemaIds,
|
|
82
|
+
contexts,
|
|
83
|
+
types,
|
|
84
|
+
givenId: givenId ?? undefined,
|
|
85
|
+
claimFormat,
|
|
86
|
+
proofTypes: proofTypes ?? undefined,
|
|
87
|
+
cryptosuites: cryptosuites ?? undefined,
|
|
88
|
+
algs: algs ?? undefined,
|
|
89
|
+
expandedTypes: expandedTypes ?? undefined,
|
|
90
|
+
...customTags,
|
|
91
|
+
})
|
|
92
|
+
|
|
93
|
+
return record
|
|
94
|
+
}
|
|
95
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DrizzleRecord } from '../../DrizzleRecord'
|
|
2
|
+
import { DrizzleW3cCredentialRecordAdapter } from './DrizzleW3cCredentialRecordAdapter'
|
|
3
|
+
import * as postgres from './postgres'
|
|
4
|
+
import * as sqlite from './sqlite'
|
|
5
|
+
|
|
6
|
+
export const w3cCredentialDrizzleRecord = {
|
|
7
|
+
adapter: DrizzleW3cCredentialRecordAdapter,
|
|
8
|
+
postgres,
|
|
9
|
+
sqlite,
|
|
10
|
+
} satisfies DrizzleRecord
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { ClaimFormat, W3cVerifiableCredential } from '@credo-ts/core'
|
|
2
|
+
import { jsonb, pgEnum, pgTable, text } from 'drizzle-orm/pg-core'
|
|
3
|
+
import { getPostgresBaseRecordTable, postgresBaseRecordIndexes } from '../../postgres/baseRecord'
|
|
4
|
+
|
|
5
|
+
export const w3cCredentialClaimFormat = pgEnum('W3cClaimFormat', [ClaimFormat.LdpVc, ClaimFormat.JwtVc])
|
|
6
|
+
|
|
7
|
+
export const w3cCredential = pgTable(
|
|
8
|
+
'W3cCredential',
|
|
9
|
+
{
|
|
10
|
+
...getPostgresBaseRecordTable(),
|
|
11
|
+
|
|
12
|
+
// JWT vc is string, JSON-LD vc is object
|
|
13
|
+
credential: jsonb().$type<W3cVerifiableCredential['encoded']>().notNull(),
|
|
14
|
+
|
|
15
|
+
// Default Tags
|
|
16
|
+
issuerId: text('issuer_id').notNull(),
|
|
17
|
+
subjectIds: text('subject_ids').array().notNull(),
|
|
18
|
+
schemaIds: text('schema_ids').array().notNull(),
|
|
19
|
+
contexts: text().array().notNull(),
|
|
20
|
+
types: text().array().notNull(),
|
|
21
|
+
givenId: text('given_id'),
|
|
22
|
+
claimFormat: w3cCredentialClaimFormat('claim_format').notNull(),
|
|
23
|
+
proofTypes: text('proof_types').array(),
|
|
24
|
+
cryptosuites: text('crypto_suites').array(),
|
|
25
|
+
algs: text().array(),
|
|
26
|
+
|
|
27
|
+
// Custom Tags
|
|
28
|
+
expandedTypes: text('expanded_types').array(),
|
|
29
|
+
},
|
|
30
|
+
(table) => postgresBaseRecordIndexes(table, 'w3cCredential')
|
|
31
|
+
)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ClaimFormat, W3cVerifiableCredential } from '@credo-ts/core'
|
|
2
|
+
import { sqliteTable, text } from 'drizzle-orm/sqlite-core'
|
|
3
|
+
import { getSqliteBaseRecordTable, sqliteBaseRecordIndexes } from '../../sqlite/baseRecord'
|
|
4
|
+
|
|
5
|
+
export const w3cCredential = sqliteTable(
|
|
6
|
+
'W3cCredential',
|
|
7
|
+
{
|
|
8
|
+
...getSqliteBaseRecordTable(),
|
|
9
|
+
|
|
10
|
+
// JWT vc is string, JSON-LD vc is object
|
|
11
|
+
credential: text({ mode: 'json' }).$type<W3cVerifiableCredential['encoded']>().notNull(),
|
|
12
|
+
|
|
13
|
+
// Default Tags
|
|
14
|
+
issuerId: text('issuer_id').notNull(),
|
|
15
|
+
subjectIds: text('subject_ids', { mode: 'json' }).$type<string[]>().notNull(),
|
|
16
|
+
schemaIds: text('schema_ids', { mode: 'json' }).$type<string[]>().notNull(),
|
|
17
|
+
contexts: text({ mode: 'json' }).$type<string[]>().notNull(),
|
|
18
|
+
types: text({ mode: 'json' }).$type<string[]>().notNull(),
|
|
19
|
+
givenId: text('given_id'),
|
|
20
|
+
claimFormat: text('claim_format').$type<ClaimFormat.LdpVc | ClaimFormat.JwtVc>().notNull(),
|
|
21
|
+
proofTypes: text('proof_types', { mode: 'json' }).$type<string[]>(),
|
|
22
|
+
cryptosuites: text('crypto_suites', { mode: 'json' }).$type<string[]>(),
|
|
23
|
+
algs: text({ mode: 'json' }).$type<string[]>(),
|
|
24
|
+
|
|
25
|
+
// Custom Tags
|
|
26
|
+
expandedTypes: text('expanded_types', { mode: 'json' }).$type<string[]>(),
|
|
27
|
+
},
|
|
28
|
+
(table) => sqliteBaseRecordIndexes(table, 'w3cCredential')
|
|
29
|
+
)
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { JsonTransformer, TagsBase } from '@credo-ts/core'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
BaseDrizzleRecordAdapter,
|
|
5
|
+
DrizzleAdapterRecordValues,
|
|
6
|
+
DrizzleAdapterValues,
|
|
7
|
+
} from '../../adapter/BaseDrizzleRecordAdapter'
|
|
8
|
+
|
|
9
|
+
import { BasicMessageRecord } from '@credo-ts/didcomm'
|
|
10
|
+
import { DrizzleDatabase } from '../../DrizzleDatabase'
|
|
11
|
+
import * as postgres from './postgres'
|
|
12
|
+
import * as sqlite from './sqlite'
|
|
13
|
+
|
|
14
|
+
type DrizzleDidcommBasicMessageAdapterValues = DrizzleAdapterRecordValues<(typeof sqlite)['didcommBasicMessage']>
|
|
15
|
+
export class DrizzleDidcommBasicMessageRecordAdapter extends BaseDrizzleRecordAdapter<
|
|
16
|
+
BasicMessageRecord,
|
|
17
|
+
typeof postgres.didcommBasicMessage,
|
|
18
|
+
typeof postgres,
|
|
19
|
+
typeof sqlite.didcommBasicMessage,
|
|
20
|
+
typeof sqlite
|
|
21
|
+
> {
|
|
22
|
+
public constructor(database: DrizzleDatabase<typeof postgres, typeof sqlite>) {
|
|
23
|
+
super(
|
|
24
|
+
database,
|
|
25
|
+
{ postgres: postgres.didcommBasicMessage, sqlite: sqlite.didcommBasicMessage },
|
|
26
|
+
'BasicMessageRecord'
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
public getValues(record: BasicMessageRecord): DrizzleAdapterValues<(typeof sqlite)['didcommBasicMessage']> {
|
|
31
|
+
const { role, connectionId, parentThreadId, threadId, ...customTags } = record.getTags()
|
|
32
|
+
|
|
33
|
+
return {
|
|
34
|
+
content: record.content,
|
|
35
|
+
sentTime: record.sentTime,
|
|
36
|
+
|
|
37
|
+
connectionId,
|
|
38
|
+
role,
|
|
39
|
+
threadId,
|
|
40
|
+
parentThreadId,
|
|
41
|
+
|
|
42
|
+
customTags,
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
public toRecord(values: DrizzleDidcommBasicMessageAdapterValues): BasicMessageRecord {
|
|
47
|
+
const { customTags, ...remainingValues } = values
|
|
48
|
+
|
|
49
|
+
const record = JsonTransformer.fromJSON(remainingValues, BasicMessageRecord)
|
|
50
|
+
record.setTags(customTags as TagsBase)
|
|
51
|
+
|
|
52
|
+
return record
|
|
53
|
+
}
|
|
54
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DrizzleRecord } from '../../DrizzleRecord'
|
|
2
|
+
import { DrizzleDidcommBasicMessageRecordAdapter } from './DrizzleDidcommBasicMessageRecordAdapter'
|
|
3
|
+
import * as postgres from './postgres'
|
|
4
|
+
import * as sqlite from './sqlite'
|
|
5
|
+
|
|
6
|
+
export const didcommBasicMessageDrizzleRecord = {
|
|
7
|
+
adapter: DrizzleDidcommBasicMessageRecordAdapter,
|
|
8
|
+
postgres,
|
|
9
|
+
sqlite,
|
|
10
|
+
} satisfies DrizzleRecord
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { BasicMessageRole } from '@credo-ts/didcomm'
|
|
2
|
+
import { 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 didcommBasicMessageRoleEnum = pgEnum('DidcommBasicMessageRole', BasicMessageRole)
|
|
7
|
+
|
|
8
|
+
export const didcommBasicMessage = pgTable(
|
|
9
|
+
'DidcommBasicMessage',
|
|
10
|
+
{
|
|
11
|
+
...getPostgresBaseRecordTable(),
|
|
12
|
+
|
|
13
|
+
content: text().notNull(),
|
|
14
|
+
|
|
15
|
+
// Not stored as date in Credo?
|
|
16
|
+
sentTime: text('sent_time').notNull(),
|
|
17
|
+
|
|
18
|
+
role: didcommBasicMessageRoleEnum().notNull(),
|
|
19
|
+
connectionId: text('connection_id'),
|
|
20
|
+
threadId: text('thread_id'),
|
|
21
|
+
parentThreadId: text('parent_thread_id'),
|
|
22
|
+
},
|
|
23
|
+
(table) => [
|
|
24
|
+
...postgresBaseRecordIndexes(table, 'didcommBasicMessage'),
|
|
25
|
+
foreignKey({
|
|
26
|
+
columns: [table.connectionId, table.contextCorrelationId],
|
|
27
|
+
foreignColumns: [didcommConnection.id, didcommConnection.contextCorrelationId],
|
|
28
|
+
}).onDelete('cascade'),
|
|
29
|
+
]
|
|
30
|
+
)
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { foreignKey, sqliteTable, text } from 'drizzle-orm/sqlite-core'
|
|
2
|
+
|
|
3
|
+
import { BasicMessageRole } from '@credo-ts/didcomm'
|
|
4
|
+
import { getSqliteBaseRecordTable, sqliteBaseRecordIndexes } from '../../sqlite/baseRecord'
|
|
5
|
+
import { didcommConnection } from '../sqlite'
|
|
6
|
+
|
|
7
|
+
export const didcommBasicMessage = sqliteTable(
|
|
8
|
+
'DidcommBasicMessage',
|
|
9
|
+
{
|
|
10
|
+
...getSqliteBaseRecordTable(),
|
|
11
|
+
|
|
12
|
+
content: text().notNull(),
|
|
13
|
+
|
|
14
|
+
// Not stored as date in Credo?
|
|
15
|
+
sentTime: text('sent_time').notNull(),
|
|
16
|
+
|
|
17
|
+
connectionId: text('connection_id'),
|
|
18
|
+
role: text().$type<BasicMessageRole>().notNull(),
|
|
19
|
+
threadId: text('thread_id'),
|
|
20
|
+
parentThreadId: text('parent_thread_id'),
|
|
21
|
+
},
|
|
22
|
+
(table) => [
|
|
23
|
+
...sqliteBaseRecordIndexes(table, 'didcommBasicMessage'),
|
|
24
|
+
foreignKey({
|
|
25
|
+
columns: [table.connectionId, table.contextCorrelationId],
|
|
26
|
+
foreignColumns: [didcommConnection.id, didcommConnection.contextCorrelationId],
|
|
27
|
+
}).onDelete('cascade'),
|
|
28
|
+
]
|
|
29
|
+
)
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { DrizzleRecordBundle } from '../DrizzleRecord'
|
|
2
|
+
import { didcommBasicMessageDrizzleRecord } from './basic-message'
|
|
3
|
+
import { didcommConnectionDrizzleRecord } from './connection'
|
|
4
|
+
import { didcommCredentialExchangeDrizzleRecord } from './credential-exchange'
|
|
5
|
+
import { didcommMessageDrizzleRecord } from './didcomm-message'
|
|
6
|
+
import { didcommMediationDrizzleRecord } from './mediation'
|
|
7
|
+
import { didcommMediatorRoutingDrizzleRecord } from './mediator-routing'
|
|
8
|
+
import { didcommOutOfBandDrizzleRecord } from './out-of-band'
|
|
9
|
+
import { didcommProofExchangeDrizzleRecord } from './proof-exchange'
|
|
10
|
+
|
|
11
|
+
export default {
|
|
12
|
+
name: 'didcomm',
|
|
13
|
+
records: [
|
|
14
|
+
didcommBasicMessageDrizzleRecord,
|
|
15
|
+
didcommConnectionDrizzleRecord,
|
|
16
|
+
didcommCredentialExchangeDrizzleRecord,
|
|
17
|
+
didcommMessageDrizzleRecord,
|
|
18
|
+
didcommMediationDrizzleRecord,
|
|
19
|
+
didcommMediatorRoutingDrizzleRecord,
|
|
20
|
+
didcommOutOfBandDrizzleRecord,
|
|
21
|
+
didcommProofExchangeDrizzleRecord,
|
|
22
|
+
],
|
|
23
|
+
|
|
24
|
+
migrations: {
|
|
25
|
+
postgres: {
|
|
26
|
+
schemaModule: '@credo-ts/drizzle-storage/didcomm/postgres',
|
|
27
|
+
migrationsPath: '../../migrations/didcomm/postgres',
|
|
28
|
+
},
|
|
29
|
+
sqlite: {
|
|
30
|
+
schemaModule: '@credo-ts/drizzle-storage/didcomm/sqlite',
|
|
31
|
+
migrationsPath: '../../migrations/didcomm/sqlite',
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
} as const satisfies DrizzleRecordBundle
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { JsonTransformer, TagsBase } from '@credo-ts/core'
|
|
2
|
+
|
|
3
|
+
import { BaseDrizzleRecordAdapter, DrizzleAdapterRecordValues } from '../../adapter/BaseDrizzleRecordAdapter'
|
|
4
|
+
|
|
5
|
+
import { ConnectionRecord } from '@credo-ts/didcomm'
|
|
6
|
+
import { DrizzleDatabase } from '../../DrizzleDatabase'
|
|
7
|
+
import * as postgres from './postgres'
|
|
8
|
+
import * as sqlite from './sqlite'
|
|
9
|
+
|
|
10
|
+
type DrizzleDidcommConnectionAdapterValues = DrizzleAdapterRecordValues<(typeof sqlite)['didcommConnection']>
|
|
11
|
+
export class DrizzleDidcommConnectionRecordAdapter extends BaseDrizzleRecordAdapter<
|
|
12
|
+
ConnectionRecord,
|
|
13
|
+
typeof postgres.didcommConnection,
|
|
14
|
+
typeof postgres,
|
|
15
|
+
typeof sqlite.didcommConnection,
|
|
16
|
+
typeof sqlite
|
|
17
|
+
> {
|
|
18
|
+
public constructor(database: DrizzleDatabase<typeof postgres, typeof sqlite>) {
|
|
19
|
+
super(database, { postgres: postgres.didcommConnection, sqlite: sqlite.didcommConnection }, 'ConnectionRecord')
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public getValues(record: ConnectionRecord) {
|
|
23
|
+
const {
|
|
24
|
+
state,
|
|
25
|
+
role,
|
|
26
|
+
threadId,
|
|
27
|
+
mediatorId,
|
|
28
|
+
did,
|
|
29
|
+
theirDid,
|
|
30
|
+
outOfBandId,
|
|
31
|
+
invitationDid,
|
|
32
|
+
connectionTypes,
|
|
33
|
+
previousDids,
|
|
34
|
+
previousTheirDids,
|
|
35
|
+
...customTags
|
|
36
|
+
} = record.getTags()
|
|
37
|
+
|
|
38
|
+
return {
|
|
39
|
+
state,
|
|
40
|
+
role,
|
|
41
|
+
threadId,
|
|
42
|
+
mediatorId,
|
|
43
|
+
did,
|
|
44
|
+
theirDid,
|
|
45
|
+
outOfBandId,
|
|
46
|
+
invitationDid,
|
|
47
|
+
connectionTypes,
|
|
48
|
+
previousDids,
|
|
49
|
+
previousTheirDids,
|
|
50
|
+
alias: record.alias,
|
|
51
|
+
autoAcceptConnection: record.autoAcceptConnection,
|
|
52
|
+
errorMessage: record.errorMessage,
|
|
53
|
+
imageUrl: record.imageUrl,
|
|
54
|
+
theirLabel: record.theirLabel,
|
|
55
|
+
protocol: record.protocol,
|
|
56
|
+
// TOOD: Fix types
|
|
57
|
+
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
58
|
+
customTags: customTags as any,
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
public toRecord(values: DrizzleDidcommConnectionAdapterValues): ConnectionRecord {
|
|
63
|
+
const { customTags, ...remainingValues } = values
|
|
64
|
+
|
|
65
|
+
const record = JsonTransformer.fromJSON(remainingValues, ConnectionRecord)
|
|
66
|
+
record.setTags(customTags as TagsBase)
|
|
67
|
+
|
|
68
|
+
return record
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DrizzleRecord } from '../../DrizzleRecord'
|
|
2
|
+
import { DrizzleDidcommConnectionRecordAdapter } from './DrizzleDidcommConnectionRecordAdapter'
|
|
3
|
+
import * as postgres from './postgres'
|
|
4
|
+
import * as sqlite from './sqlite'
|
|
5
|
+
|
|
6
|
+
export const didcommConnectionDrizzleRecord = {
|
|
7
|
+
adapter: DrizzleDidcommConnectionRecordAdapter,
|
|
8
|
+
postgres,
|
|
9
|
+
sqlite,
|
|
10
|
+
} satisfies DrizzleRecord
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { boolean, pgEnum, pgTable, text, unique } from 'drizzle-orm/pg-core'
|
|
2
|
+
import { getPostgresBaseRecordTable, postgresBaseRecordIndexes } from '../../postgres/baseRecord'
|
|
3
|
+
|
|
4
|
+
export const didcommConnectionStateEnum = pgEnum('DidcommConnectionState', [
|
|
5
|
+
'start',
|
|
6
|
+
'invitation-sent',
|
|
7
|
+
'invitation-received',
|
|
8
|
+
'request-sent',
|
|
9
|
+
'request-received',
|
|
10
|
+
'response-sent',
|
|
11
|
+
'response-received',
|
|
12
|
+
'abandoned',
|
|
13
|
+
'completed',
|
|
14
|
+
])
|
|
15
|
+
|
|
16
|
+
export const didcommConnectionRoleEnum = pgEnum('DidcommConnectionRole', ['requester', 'responder'])
|
|
17
|
+
|
|
18
|
+
export const didcommConnectionHandshakeProtocolEnum = pgEnum('DidcommConnectionHandshakeProtocol', [
|
|
19
|
+
'https://didcomm.org/didexchange/1.x',
|
|
20
|
+
'https://didcomm.org/connections/1.x',
|
|
21
|
+
])
|
|
22
|
+
|
|
23
|
+
export const didcommConnection = pgTable(
|
|
24
|
+
'DidcommConnection',
|
|
25
|
+
{
|
|
26
|
+
...getPostgresBaseRecordTable(),
|
|
27
|
+
|
|
28
|
+
state: didcommConnectionStateEnum().notNull(),
|
|
29
|
+
role: didcommConnectionRoleEnum().notNull(),
|
|
30
|
+
|
|
31
|
+
did: text(),
|
|
32
|
+
theirDid: text('their_did'),
|
|
33
|
+
theirLabel: text('their_label'),
|
|
34
|
+
alias: text(),
|
|
35
|
+
autoAcceptConnection: boolean('auto_accept_connection'),
|
|
36
|
+
imageUrl: text('image_url'),
|
|
37
|
+
threadId: text('thread_id'),
|
|
38
|
+
invitationDid: text('invitation_did'),
|
|
39
|
+
|
|
40
|
+
// TODO: references mediator/oob record
|
|
41
|
+
mediatorId: text('mediator_id'),
|
|
42
|
+
outOfBandId: text('out_of_band_id'),
|
|
43
|
+
|
|
44
|
+
errorMessage: text('error_message'),
|
|
45
|
+
protocol: didcommConnectionHandshakeProtocolEnum(),
|
|
46
|
+
connectionTypes: text('connection_types').array(),
|
|
47
|
+
|
|
48
|
+
previousDids: text('previous_dids').array(),
|
|
49
|
+
previousTheirDids: text('previous_their_dids').array(),
|
|
50
|
+
},
|
|
51
|
+
(table) => [
|
|
52
|
+
...postgresBaseRecordIndexes(table, 'didcommConnection'),
|
|
53
|
+
unique().on(table.contextCorrelationId, table.threadId),
|
|
54
|
+
]
|
|
55
|
+
)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { integer, sqliteTable, text, unique } from 'drizzle-orm/sqlite-core'
|
|
2
|
+
|
|
3
|
+
import type { DidExchangeRole, DidExchangeState, HandshakeProtocol } from '@credo-ts/didcomm'
|
|
4
|
+
import { getSqliteBaseRecordTable, sqliteBaseRecordIndexes } from '../../sqlite/baseRecord'
|
|
5
|
+
|
|
6
|
+
export const didcommConnection = sqliteTable(
|
|
7
|
+
'DidcommConnection',
|
|
8
|
+
{
|
|
9
|
+
...getSqliteBaseRecordTable(),
|
|
10
|
+
|
|
11
|
+
state: text('state').$type<DidExchangeState>().notNull(),
|
|
12
|
+
role: text('role').$type<DidExchangeRole>().notNull(),
|
|
13
|
+
|
|
14
|
+
did: text('did'),
|
|
15
|
+
theirDid: text('their_did'),
|
|
16
|
+
theirLabel: text('their_label'),
|
|
17
|
+
alias: text('alias'),
|
|
18
|
+
autoAcceptConnection: integer('auto_accept_connection', { mode: 'boolean' }),
|
|
19
|
+
imageUrl: text('image_url'),
|
|
20
|
+
threadId: text('thread_id'),
|
|
21
|
+
invitationDid: text('invitation_did'),
|
|
22
|
+
|
|
23
|
+
// TODO: references mediator/oob record
|
|
24
|
+
mediatorId: text('mediator_id'),
|
|
25
|
+
outOfBandId: text('out_of_band_id'),
|
|
26
|
+
|
|
27
|
+
errorMessage: text('error_message'),
|
|
28
|
+
protocol: text('protocol').$type<HandshakeProtocol>(),
|
|
29
|
+
|
|
30
|
+
// Using JSON for array storage
|
|
31
|
+
connectionTypes: text('connection_types', { mode: 'json' }).$type<string[]>(),
|
|
32
|
+
previousDids: text('previous_dids', { mode: 'json' }).$type<string[]>(),
|
|
33
|
+
previousTheirDids: text('previous_their_dids', { mode: 'json' }).$type<string[]>(),
|
|
34
|
+
},
|
|
35
|
+
(table) => [
|
|
36
|
+
...sqliteBaseRecordIndexes(table, 'didcommConnection'),
|
|
37
|
+
unique().on(table.contextCorrelationId, table.threadId),
|
|
38
|
+
]
|
|
39
|
+
)
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { JsonObject, JsonTransformer, TagsBase } from '@credo-ts/core'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
BaseDrizzleRecordAdapter,
|
|
5
|
+
DrizzleAdapterRecordValues,
|
|
6
|
+
DrizzleAdapterValues,
|
|
7
|
+
} from '../../adapter/BaseDrizzleRecordAdapter'
|
|
8
|
+
|
|
9
|
+
import { CredentialExchangeRecord } from '@credo-ts/didcomm'
|
|
10
|
+
import { DrizzleDatabase } from '../../DrizzleDatabase'
|
|
11
|
+
import * as postgres from './postgres'
|
|
12
|
+
import * as sqlite from './sqlite'
|
|
13
|
+
|
|
14
|
+
type DrizzleDidcommCredentialExchangeAdapterValues = DrizzleAdapterRecordValues<
|
|
15
|
+
(typeof sqlite)['didcommCredentialExchange']
|
|
16
|
+
>
|
|
17
|
+
export class DrizzleDidcommCredentialExchangeRecordAdapter extends BaseDrizzleRecordAdapter<
|
|
18
|
+
CredentialExchangeRecord,
|
|
19
|
+
typeof postgres.didcommCredentialExchange,
|
|
20
|
+
typeof postgres,
|
|
21
|
+
typeof sqlite.didcommCredentialExchange,
|
|
22
|
+
typeof sqlite
|
|
23
|
+
> {
|
|
24
|
+
public constructor(database: DrizzleDatabase<typeof postgres, typeof sqlite>) {
|
|
25
|
+
super(
|
|
26
|
+
database,
|
|
27
|
+
{ postgres: postgres.didcommCredentialExchange, sqlite: sqlite.didcommCredentialExchange },
|
|
28
|
+
'CredentialRecord'
|
|
29
|
+
)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public getValues(
|
|
33
|
+
record: CredentialExchangeRecord
|
|
34
|
+
): DrizzleAdapterValues<(typeof sqlite)['didcommCredentialExchange']> {
|
|
35
|
+
const { connectionId, threadId, parentThreadId, state, role, credentialIds, ...customTags } = record.getTags()
|
|
36
|
+
|
|
37
|
+
return {
|
|
38
|
+
connectionId,
|
|
39
|
+
threadId,
|
|
40
|
+
parentThreadId,
|
|
41
|
+
state,
|
|
42
|
+
role,
|
|
43
|
+
autoAcceptCredential: record.autoAcceptCredential,
|
|
44
|
+
revocationNotification: JsonTransformer.toJSON(record.revocationNotification),
|
|
45
|
+
errorMessage: record.errorMessage,
|
|
46
|
+
protocolVersion: record.protocolVersion,
|
|
47
|
+
credentials: record.credentials,
|
|
48
|
+
credentialIds,
|
|
49
|
+
credentialAttributes: JsonTransformer.toJSON(record.credentialAttributes) as JsonObject[],
|
|
50
|
+
linkedAttachments: record.linkedAttachments?.map((a) => JsonTransformer.toJSON(a)),
|
|
51
|
+
|
|
52
|
+
customTags,
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
public toRecord(values: DrizzleDidcommCredentialExchangeAdapterValues): CredentialExchangeRecord {
|
|
57
|
+
const { customTags, credentialIds, ...remainingValues } = values
|
|
58
|
+
|
|
59
|
+
const record = JsonTransformer.fromJSON(remainingValues, CredentialExchangeRecord)
|
|
60
|
+
record.setTags(customTags as TagsBase)
|
|
61
|
+
|
|
62
|
+
return record
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { Agent, JsonTransformer } from '@credo-ts/core'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
AutoAcceptCredential,
|
|
5
|
+
CredentialExchangeRecord,
|
|
6
|
+
CredentialRepository,
|
|
7
|
+
CredentialRole,
|
|
8
|
+
CredentialState,
|
|
9
|
+
} from '@credo-ts/didcomm'
|
|
10
|
+
import { setupDrizzleRecordTest } from '../../../../tests/testDatabase'
|
|
11
|
+
import { didcommCredentialExchangeDrizzleRecord } from '../index'
|
|
12
|
+
|
|
13
|
+
describe.each(['postgres', 'sqlite'] as const)('CredentialExchangeRecord with %s', (type) => {
|
|
14
|
+
let agent: Agent
|
|
15
|
+
|
|
16
|
+
beforeAll(async () => {
|
|
17
|
+
agent = await setupDrizzleRecordTest(type, didcommCredentialExchangeDrizzleRecord)
|
|
18
|
+
})
|
|
19
|
+
|
|
20
|
+
test('create, retrieve, update, query and delete credential exchange record', async () => {
|
|
21
|
+
const credentialExchange = JsonTransformer.fromJSON(
|
|
22
|
+
{
|
|
23
|
+
id: '6e7fcaf3-ebb9-45ed-9261-7b893f732bc1',
|
|
24
|
+
connectionId: '1eb24dc2-1d81-4249-baf9-783e03176fd3',
|
|
25
|
+
threadId: '1c92f4ff-e859-4086-bb09-ad979c63d6e5',
|
|
26
|
+
parentThreadId: '4b99cdca-847c-4083-8ea0-8880f2c410ff',
|
|
27
|
+
state: CredentialState.Abandoned,
|
|
28
|
+
role: CredentialRole.Holder,
|
|
29
|
+
autoAcceptCredential: AutoAcceptCredential.Always,
|
|
30
|
+
revocationNotification: {
|
|
31
|
+
revocationDate: new Date(),
|
|
32
|
+
comment: 'hello',
|
|
33
|
+
},
|
|
34
|
+
errorMessage: 'hello',
|
|
35
|
+
protocolVersion: '2',
|
|
36
|
+
credentials: [
|
|
37
|
+
{
|
|
38
|
+
credentialRecordType: 'w3c',
|
|
39
|
+
credentialRecordId: '8633f56d-abc9-4229-ba09-9ca6611ad8e4',
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
credentialAttributes: [
|
|
43
|
+
{
|
|
44
|
+
name: 'hello',
|
|
45
|
+
'mime-type': 'application/json',
|
|
46
|
+
value: 'something',
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
linkedAttachments: [
|
|
50
|
+
{
|
|
51
|
+
'@id': 'a402b029-6dfb-4840-97f3-b3b0f8e7ac49',
|
|
52
|
+
'mime-type': 'hello',
|
|
53
|
+
data: {
|
|
54
|
+
json: { some: 'key' },
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
CredentialExchangeRecord
|
|
60
|
+
)
|
|
61
|
+
const credentialExchangeRepository = agent.context.resolve(CredentialRepository)
|
|
62
|
+
|
|
63
|
+
await credentialExchangeRepository.save(agent.context, credentialExchange)
|
|
64
|
+
|
|
65
|
+
const credentialExchange2 = await credentialExchangeRepository.findById(agent.context, credentialExchange.id)
|
|
66
|
+
expect(credentialExchange).toEqual(credentialExchange2)
|
|
67
|
+
|
|
68
|
+
credentialExchange.setTags({
|
|
69
|
+
myCustomTag: 'hello',
|
|
70
|
+
isMorning: false,
|
|
71
|
+
})
|
|
72
|
+
await credentialExchangeRepository.update(agent.context, credentialExchange)
|
|
73
|
+
|
|
74
|
+
const [credentialExchange3] = await credentialExchangeRepository.findByQuery(agent.context, {
|
|
75
|
+
isMorning: false,
|
|
76
|
+
credentialIds: ['8633f56d-abc9-4229-ba09-9ca6611ad8e4'],
|
|
77
|
+
})
|
|
78
|
+
expect(credentialExchange3).toEqual(credentialExchange)
|
|
79
|
+
|
|
80
|
+
const [credentialExchange4] = await credentialExchangeRepository.findByQuery(agent.context, {
|
|
81
|
+
isMorning: false,
|
|
82
|
+
// Id does not exist
|
|
83
|
+
credentialIds: ['a0b7c554-0beb-4a4c-808a-fd4495241770'],
|
|
84
|
+
})
|
|
85
|
+
expect(credentialExchange4).toBeUndefined()
|
|
86
|
+
|
|
87
|
+
expect(
|
|
88
|
+
await credentialExchangeRepository.findByQuery(agent.context, {
|
|
89
|
+
myCustomTag: 'not-hello',
|
|
90
|
+
})
|
|
91
|
+
).toHaveLength(0)
|
|
92
|
+
|
|
93
|
+
await credentialExchangeRepository.deleteById(agent.context, credentialExchange.id)
|
|
94
|
+
|
|
95
|
+
expect(await credentialExchangeRepository.findByQuery(agent.context, {})).toHaveLength(0)
|
|
96
|
+
})
|
|
97
|
+
})
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DrizzleRecord } from '../../DrizzleRecord'
|
|
2
|
+
import { DrizzleDidcommCredentialExchangeRecordAdapter } from './DrizzleDidcommCredentialExchangeRecordAdapter'
|
|
3
|
+
import * as postgres from './postgres'
|
|
4
|
+
import * as sqlite from './sqlite'
|
|
5
|
+
|
|
6
|
+
export const didcommCredentialExchangeDrizzleRecord = {
|
|
7
|
+
adapter: DrizzleDidcommCredentialExchangeRecordAdapter,
|
|
8
|
+
postgres,
|
|
9
|
+
sqlite,
|
|
10
|
+
} satisfies DrizzleRecord
|