@credo-ts/drizzle-storage 0.6.0-pr-2324-20250708122805 → 0.6.0-pr-2324-20250709075226
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/drizzle.config.ts +1 -1
- package/cli-build/drizzle.config.js +1 -1
- package/cli-build/drizzle.config.js.map +1 -1
- package/package.json +18 -17
- 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.drizzle.e2e.test.ts +330 -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.drizzle.e2e.test.ts +70 -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.drizzle.e2e.test.ts +104 -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.drizzle.e2e.test.ts +88 -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,71 @@
|
|
|
1
|
+
import { DidRecord, JsonTransformer } 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 DrizzleDidAdapterValues = DrizzleAdapterRecordValues<(typeof sqlite)['did']>
|
|
10
|
+
export class DrizzleDidRecordAdapter extends BaseDrizzleRecordAdapter<
|
|
11
|
+
DidRecord,
|
|
12
|
+
typeof postgres.did,
|
|
13
|
+
typeof postgres,
|
|
14
|
+
typeof sqlite.did,
|
|
15
|
+
typeof sqlite
|
|
16
|
+
> {
|
|
17
|
+
public constructor(database: DrizzleDatabase<typeof postgres, typeof sqlite>) {
|
|
18
|
+
super(database, { postgres: postgres.did, sqlite: sqlite.did }, 'DidRecord')
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public getValues(record: DidRecord) {
|
|
22
|
+
const {
|
|
23
|
+
// Default Tags
|
|
24
|
+
recipientKeyFingerprints,
|
|
25
|
+
method,
|
|
26
|
+
methodSpecificIdentifier,
|
|
27
|
+
alternativeDids,
|
|
28
|
+
did,
|
|
29
|
+
legacyUnqualifiedDid,
|
|
30
|
+
role,
|
|
31
|
+
...customTags
|
|
32
|
+
} = record.getTags()
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
did: record.did,
|
|
36
|
+
role: role,
|
|
37
|
+
didDocument: record.didDocument,
|
|
38
|
+
keys: record.keys,
|
|
39
|
+
|
|
40
|
+
// Tags
|
|
41
|
+
recipientKeyFingerprints,
|
|
42
|
+
method,
|
|
43
|
+
methodSpecificIdentifier,
|
|
44
|
+
alternativeDids,
|
|
45
|
+
customTags,
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
public toRecord(values: DrizzleDidAdapterValues): DidRecord {
|
|
50
|
+
const {
|
|
51
|
+
// Default Tags
|
|
52
|
+
recipientKeyFingerprints,
|
|
53
|
+
method,
|
|
54
|
+
methodSpecificIdentifier,
|
|
55
|
+
alternativeDids,
|
|
56
|
+
customTags,
|
|
57
|
+
...remainingValues
|
|
58
|
+
} = values
|
|
59
|
+
|
|
60
|
+
const record = JsonTransformer.fromJSON(remainingValues, DidRecord)
|
|
61
|
+
record.setTags({
|
|
62
|
+
recipientKeyFingerprints: recipientKeyFingerprints ?? undefined,
|
|
63
|
+
method,
|
|
64
|
+
methodSpecificIdentifier,
|
|
65
|
+
alternativeDids: alternativeDids ?? undefined,
|
|
66
|
+
...customTags,
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
return record
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DrizzleRecord } from '../../DrizzleRecord'
|
|
2
|
+
import { DrizzleDidRecordAdapter } from './DrizzleDidRecordAdapter'
|
|
3
|
+
import * as postgres from './postgres'
|
|
4
|
+
import * as sqlite from './sqlite'
|
|
5
|
+
|
|
6
|
+
export const didDrizzleRecord = {
|
|
7
|
+
adapter: DrizzleDidRecordAdapter,
|
|
8
|
+
postgres,
|
|
9
|
+
sqlite,
|
|
10
|
+
} satisfies DrizzleRecord
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { DidDocumentKey, DidDocumentRole } 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 didRoleEnum = pgEnum('didRole', DidDocumentRole)
|
|
6
|
+
|
|
7
|
+
export const did = pgTable(
|
|
8
|
+
'Did',
|
|
9
|
+
{
|
|
10
|
+
...getPostgresBaseRecordTable(),
|
|
11
|
+
|
|
12
|
+
did: text().notNull(),
|
|
13
|
+
role: didRoleEnum().notNull(),
|
|
14
|
+
didDocument: jsonb('did_document'),
|
|
15
|
+
keys: jsonb().$type<DidDocumentKey[]>(),
|
|
16
|
+
|
|
17
|
+
// Default Tags
|
|
18
|
+
recipientKeyFingerprints: jsonb('recipient_key_fingerprints'),
|
|
19
|
+
method: text().notNull(),
|
|
20
|
+
methodSpecificIdentifier: text('method_specific_identifier').notNull(),
|
|
21
|
+
// Not adding this here, since it's legacy
|
|
22
|
+
// legacyUnqualifiedDid
|
|
23
|
+
|
|
24
|
+
// Custom Tags
|
|
25
|
+
alternativeDids: text('alternative_dids').array(),
|
|
26
|
+
},
|
|
27
|
+
(table) => postgresBaseRecordIndexes(table, 'did')
|
|
28
|
+
)
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { DidDocumentKey, DidDocumentRole } from '@credo-ts/core'
|
|
2
|
+
import { sqliteTable, text } from 'drizzle-orm/sqlite-core'
|
|
3
|
+
import { getSqliteBaseRecordTable, sqliteBaseRecordIndexes } from '../../sqlite/baseRecord'
|
|
4
|
+
|
|
5
|
+
export const did = sqliteTable(
|
|
6
|
+
'Did',
|
|
7
|
+
{
|
|
8
|
+
...getSqliteBaseRecordTable(),
|
|
9
|
+
|
|
10
|
+
did: text().notNull(),
|
|
11
|
+
role: text().$type<DidDocumentRole.Created | DidDocumentRole.Received>().notNull(),
|
|
12
|
+
didDocument: text('did_document', { mode: 'json' }),
|
|
13
|
+
keys: text({ mode: 'json' }).$type<DidDocumentKey[]>(),
|
|
14
|
+
|
|
15
|
+
// Default Tags
|
|
16
|
+
recipientKeyFingerprints: text('recipient_key_fingerprints', { mode: 'json' }).$type<string[]>(),
|
|
17
|
+
method: text().notNull(),
|
|
18
|
+
methodSpecificIdentifier: text('method_specific_identifier').notNull(),
|
|
19
|
+
// Not adding this here, since it's legacy
|
|
20
|
+
// legacyUnqualifiedDid
|
|
21
|
+
|
|
22
|
+
// Custom Tags
|
|
23
|
+
alternativeDids: text('alternative_dids', { mode: 'json' }).$type<string[]>(),
|
|
24
|
+
},
|
|
25
|
+
(table) => sqliteBaseRecordIndexes(table, 'did')
|
|
26
|
+
)
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { GenericRecord, JsonTransformer, TagsBase } 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 DrizzleGenericRecordAdapterValues = DrizzleAdapterRecordValues<(typeof sqlite)['genericRecord']>
|
|
10
|
+
export class DrizzleGenericRecordAdapter extends BaseDrizzleRecordAdapter<
|
|
11
|
+
GenericRecord,
|
|
12
|
+
typeof postgres.genericRecord,
|
|
13
|
+
typeof postgres,
|
|
14
|
+
typeof sqlite.genericRecord,
|
|
15
|
+
typeof sqlite
|
|
16
|
+
> {
|
|
17
|
+
public constructor(database: DrizzleDatabase<typeof postgres, typeof sqlite>) {
|
|
18
|
+
super(database, { postgres: postgres.genericRecord, sqlite: sqlite.genericRecord }, 'GenericRecord')
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public getValues(record: GenericRecord) {
|
|
22
|
+
return {
|
|
23
|
+
content: record.content,
|
|
24
|
+
customTags: record.getTags() as Record<string, string>,
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public toRecord(values: DrizzleGenericRecordAdapterValues): GenericRecord {
|
|
29
|
+
const { customTags, ...remainingValues } = values
|
|
30
|
+
|
|
31
|
+
const record = JsonTransformer.fromJSON(remainingValues, GenericRecord)
|
|
32
|
+
record.setTags(customTags as TagsBase)
|
|
33
|
+
|
|
34
|
+
return record
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DrizzleRecord } from '../../DrizzleRecord'
|
|
2
|
+
import { DrizzleGenericRecordAdapter } from './DrizzleGenericRecordAdapter'
|
|
3
|
+
import * as postgres from './postgres'
|
|
4
|
+
import * as sqlite from './sqlite'
|
|
5
|
+
|
|
6
|
+
export const genericRecordDrizzleRecord = {
|
|
7
|
+
adapter: DrizzleGenericRecordAdapter,
|
|
8
|
+
postgres,
|
|
9
|
+
sqlite,
|
|
10
|
+
} satisfies DrizzleRecord
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { jsonb, pgTable } from 'drizzle-orm/pg-core'
|
|
2
|
+
import { getPostgresBaseRecordTable, postgresBaseRecordIndexes } from '../../postgres/baseRecord'
|
|
3
|
+
|
|
4
|
+
export const genericRecord = pgTable(
|
|
5
|
+
'GenericRecord',
|
|
6
|
+
{
|
|
7
|
+
...getPostgresBaseRecordTable(),
|
|
8
|
+
|
|
9
|
+
content: jsonb().notNull().$type<Record<string, unknown>>(),
|
|
10
|
+
},
|
|
11
|
+
(table) => postgresBaseRecordIndexes(table, 'genericRecord')
|
|
12
|
+
)
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { sqliteTable, text } from 'drizzle-orm/sqlite-core'
|
|
2
|
+
import { getSqliteBaseRecordTable, sqliteBaseRecordIndexes } from '../../sqlite/baseRecord'
|
|
3
|
+
|
|
4
|
+
export const genericRecord = sqliteTable(
|
|
5
|
+
'GenericRecord',
|
|
6
|
+
{
|
|
7
|
+
...getSqliteBaseRecordTable(),
|
|
8
|
+
|
|
9
|
+
content: text({ mode: 'json' }).notNull().$type<Record<string, unknown>>(),
|
|
10
|
+
},
|
|
11
|
+
(table) => sqliteBaseRecordIndexes(table, 'genericRecord')
|
|
12
|
+
)
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { JsonTransformer, MdocRecord } 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 DrizzleMdocAdapterValues = DrizzleAdapterRecordValues<(typeof sqlite)['mdoc']>
|
|
10
|
+
export class DrizzleMdocRecordAdapter extends BaseDrizzleRecordAdapter<
|
|
11
|
+
MdocRecord,
|
|
12
|
+
typeof postgres.mdoc,
|
|
13
|
+
typeof postgres,
|
|
14
|
+
typeof sqlite.mdoc,
|
|
15
|
+
typeof sqlite
|
|
16
|
+
> {
|
|
17
|
+
public constructor(database: DrizzleDatabase<typeof postgres, typeof sqlite>) {
|
|
18
|
+
super(database, { postgres: postgres.mdoc, sqlite: sqlite.mdoc }, 'MdocRecord')
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public getValues(record: MdocRecord) {
|
|
22
|
+
const { alg, docType, ...customTags } = record.getTags()
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
alg,
|
|
26
|
+
docType,
|
|
27
|
+
base64Url: record.base64Url,
|
|
28
|
+
customTags,
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public toRecord(values: DrizzleMdocAdapterValues): MdocRecord {
|
|
33
|
+
const { alg, docType, customTags, ...remainingValues } = values
|
|
34
|
+
|
|
35
|
+
const record = JsonTransformer.fromJSON(remainingValues, MdocRecord)
|
|
36
|
+
record.setTags({
|
|
37
|
+
alg,
|
|
38
|
+
docType,
|
|
39
|
+
...customTags,
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
return record
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DrizzleRecord } from '../../DrizzleRecord'
|
|
2
|
+
import { DrizzleMdocRecordAdapter } from './DrizzleMdocRecordAdapter'
|
|
3
|
+
import * as postgres from './postgres'
|
|
4
|
+
import * as sqlite from './sqlite'
|
|
5
|
+
|
|
6
|
+
export const mdocDrizzleRecord = {
|
|
7
|
+
adapter: DrizzleMdocRecordAdapter,
|
|
8
|
+
postgres,
|
|
9
|
+
sqlite,
|
|
10
|
+
} satisfies DrizzleRecord
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Kms } from '@credo-ts/core'
|
|
2
|
+
import { pgTable, text } from 'drizzle-orm/pg-core'
|
|
3
|
+
import { getPostgresBaseRecordTable, postgresBaseRecordIndexes } from '../../postgres/baseRecord'
|
|
4
|
+
|
|
5
|
+
export const mdoc = pgTable(
|
|
6
|
+
'Mdoc',
|
|
7
|
+
{
|
|
8
|
+
...getPostgresBaseRecordTable(),
|
|
9
|
+
|
|
10
|
+
base64Url: text('base64_url').notNull(),
|
|
11
|
+
alg: text().$type<Kms.KnownJwaSignatureAlgorithm>().notNull(),
|
|
12
|
+
docType: text('doc_type').notNull(),
|
|
13
|
+
},
|
|
14
|
+
(table) => postgresBaseRecordIndexes(table, 'mdoc')
|
|
15
|
+
)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Kms } from '@credo-ts/core'
|
|
2
|
+
import { sqliteTable, text } from 'drizzle-orm/sqlite-core'
|
|
3
|
+
import { getSqliteBaseRecordTable, sqliteBaseRecordIndexes } from '../../sqlite/baseRecord'
|
|
4
|
+
|
|
5
|
+
export const mdoc = sqliteTable(
|
|
6
|
+
'Mdoc',
|
|
7
|
+
{
|
|
8
|
+
...getSqliteBaseRecordTable(),
|
|
9
|
+
|
|
10
|
+
base64Url: text('base64_url').notNull(),
|
|
11
|
+
alg: text().$type<Kms.KnownJwaSignatureAlgorithm>().notNull(),
|
|
12
|
+
docType: text('doc_type').notNull(),
|
|
13
|
+
},
|
|
14
|
+
(table) => sqliteBaseRecordIndexes(table, 'mdoc')
|
|
15
|
+
)
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './context/postgres'
|
|
2
|
+
export * from './did/postgres'
|
|
3
|
+
export * from './genericRecord/postgres'
|
|
4
|
+
export * from './mdoc/postgres'
|
|
5
|
+
export * from './sdJwtVc/postgres'
|
|
6
|
+
export * from './singleContextLruCache/postgres'
|
|
7
|
+
export * from './storageVersion/postgres'
|
|
8
|
+
export * from './w3cCredential/postgres'
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { JsonTransformer, SdJwtVcRecord } 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 DrizzleSdJwtVcAdapterValues = DrizzleAdapterRecordValues<(typeof sqlite)['sdJwtVc']>
|
|
10
|
+
export class DrizzleSdJwtVcRecordAdapter extends BaseDrizzleRecordAdapter<
|
|
11
|
+
SdJwtVcRecord,
|
|
12
|
+
typeof postgres.sdJwtVc,
|
|
13
|
+
typeof postgres,
|
|
14
|
+
typeof sqlite.sdJwtVc,
|
|
15
|
+
typeof sqlite
|
|
16
|
+
> {
|
|
17
|
+
public constructor(database: DrizzleDatabase<typeof postgres, typeof sqlite>) {
|
|
18
|
+
super(database, { postgres: postgres.sdJwtVc, sqlite: sqlite.sdJwtVc }, 'SdJwtVcRecord')
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public getValues(record: SdJwtVcRecord) {
|
|
22
|
+
const { alg, sdAlg, vct, ...customTags } = record.getTags()
|
|
23
|
+
|
|
24
|
+
return {
|
|
25
|
+
alg,
|
|
26
|
+
sdAlg,
|
|
27
|
+
vct,
|
|
28
|
+
compactSdJwtVc: record.compactSdJwtVc,
|
|
29
|
+
customTags,
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
public toRecord(values: DrizzleSdJwtVcAdapterValues): SdJwtVcRecord {
|
|
34
|
+
const { sdAlg, alg, vct, customTags, ...remainingValues } = values
|
|
35
|
+
|
|
36
|
+
const record = JsonTransformer.fromJSON(remainingValues, SdJwtVcRecord)
|
|
37
|
+
record.setTags({
|
|
38
|
+
alg,
|
|
39
|
+
vct,
|
|
40
|
+
sdAlg,
|
|
41
|
+
...customTags,
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
return record
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DrizzleRecord } from '../../DrizzleRecord'
|
|
2
|
+
import { DrizzleSdJwtVcRecordAdapter } from './DrizzleSdJwtVcRecordAdapter'
|
|
3
|
+
import * as postgres from './postgres'
|
|
4
|
+
import * as sqlite from './sqlite'
|
|
5
|
+
|
|
6
|
+
export const sdJwtVcDrizzleRecord = {
|
|
7
|
+
adapter: DrizzleSdJwtVcRecordAdapter,
|
|
8
|
+
postgres,
|
|
9
|
+
sqlite,
|
|
10
|
+
} satisfies DrizzleRecord
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { Kms } from '@credo-ts/core'
|
|
2
|
+
import { pgTable, text } from 'drizzle-orm/pg-core'
|
|
3
|
+
import { getPostgresBaseRecordTable, postgresBaseRecordIndexes } from '../../postgres/baseRecord'
|
|
4
|
+
|
|
5
|
+
export const sdJwtVc = pgTable(
|
|
6
|
+
'SdJwtVc',
|
|
7
|
+
{
|
|
8
|
+
...getPostgresBaseRecordTable(),
|
|
9
|
+
|
|
10
|
+
vct: text().notNull(),
|
|
11
|
+
alg: text().$type<Kms.KnownJwaSignatureAlgorithm>().notNull(),
|
|
12
|
+
sdAlg: text('sd_alg').$type<string>().notNull(),
|
|
13
|
+
|
|
14
|
+
compactSdJwtVc: text('compact_sd_jwt_vc').notNull(),
|
|
15
|
+
},
|
|
16
|
+
(table) => postgresBaseRecordIndexes(table, 'sdJwtVc')
|
|
17
|
+
)
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Kms } from '@credo-ts/core'
|
|
2
|
+
import { sqliteTable, text } from 'drizzle-orm/sqlite-core'
|
|
3
|
+
import { getSqliteBaseRecordTable, sqliteBaseRecordIndexes } from '../../sqlite/baseRecord'
|
|
4
|
+
|
|
5
|
+
export const sdJwtVc = sqliteTable(
|
|
6
|
+
'SdJwtVc',
|
|
7
|
+
{
|
|
8
|
+
...getSqliteBaseRecordTable(),
|
|
9
|
+
|
|
10
|
+
vct: text().notNull(),
|
|
11
|
+
alg: text().$type<Kms.KnownJwaSignatureAlgorithm>().notNull(),
|
|
12
|
+
sdAlg: text('sd_alg').$type<string>().notNull(),
|
|
13
|
+
|
|
14
|
+
compactSdJwtVc: text('compact_sd_jwt_vc').notNull(),
|
|
15
|
+
},
|
|
16
|
+
(table) => sqliteBaseRecordIndexes(table, 'sdJwtVc')
|
|
17
|
+
)
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { JsonTransformer, SingleContextLruCacheRecord, TagsBase } 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 DrizzleSingleContextLruCacheAdapterValues = DrizzleAdapterRecordValues<(typeof sqlite)['singleContextLruCache']>
|
|
10
|
+
export class DrizzleSingleContextLruCacheRecordAdapter extends BaseDrizzleRecordAdapter<
|
|
11
|
+
SingleContextLruCacheRecord,
|
|
12
|
+
typeof postgres.singleContextLruCache,
|
|
13
|
+
typeof postgres,
|
|
14
|
+
typeof sqlite.singleContextLruCache,
|
|
15
|
+
typeof sqlite
|
|
16
|
+
> {
|
|
17
|
+
public constructor(database: DrizzleDatabase<typeof postgres, typeof sqlite>) {
|
|
18
|
+
super(
|
|
19
|
+
database,
|
|
20
|
+
{ postgres: postgres.singleContextLruCache, sqlite: sqlite.singleContextLruCache },
|
|
21
|
+
'SingleContextLruCacheRecord'
|
|
22
|
+
)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
public getValues(record: SingleContextLruCacheRecord) {
|
|
26
|
+
return {
|
|
27
|
+
entries: Object.fromEntries(record.entries.entries()),
|
|
28
|
+
customTags: record.getTags(),
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public toRecord(values: DrizzleSingleContextLruCacheAdapterValues): SingleContextLruCacheRecord {
|
|
33
|
+
const { entries, customTags, ...remainingValues } = values
|
|
34
|
+
|
|
35
|
+
const record = JsonTransformer.fromJSON(
|
|
36
|
+
{ entries: Object.entries(entries), ...remainingValues },
|
|
37
|
+
SingleContextLruCacheRecord
|
|
38
|
+
)
|
|
39
|
+
record.setTags(customTags as TagsBase)
|
|
40
|
+
|
|
41
|
+
return record
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DrizzleRecord } from '../../DrizzleRecord'
|
|
2
|
+
import { DrizzleSingleContextLruCacheRecordAdapter } from './DrizzleSingleContextLruCacheRecordAdapter'
|
|
3
|
+
import * as postgres from './postgres'
|
|
4
|
+
import * as sqlite from './sqlite'
|
|
5
|
+
|
|
6
|
+
export const singleContextLruCacheDrizzleRecord = {
|
|
7
|
+
adapter: DrizzleSingleContextLruCacheRecordAdapter,
|
|
8
|
+
postgres,
|
|
9
|
+
sqlite,
|
|
10
|
+
} satisfies DrizzleRecord
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { SingleContextLruCacheItem } from '@credo-ts/core'
|
|
2
|
+
import { jsonb, pgTable } from 'drizzle-orm/pg-core'
|
|
3
|
+
import { getPostgresBaseRecordTable, postgresBaseRecordIndexes } from '../../postgres/baseRecord'
|
|
4
|
+
|
|
5
|
+
export const singleContextLruCache = pgTable(
|
|
6
|
+
'SingleContextLruCache',
|
|
7
|
+
{
|
|
8
|
+
...getPostgresBaseRecordTable(),
|
|
9
|
+
entries: jsonb().notNull().$type<Record<string, SingleContextLruCacheItem>>(),
|
|
10
|
+
},
|
|
11
|
+
(table) => postgresBaseRecordIndexes(table, 'singleContextLruCache')
|
|
12
|
+
)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SingleContextLruCacheItem } from '@credo-ts/core'
|
|
2
|
+
import { sqliteTable, text } from 'drizzle-orm/sqlite-core'
|
|
3
|
+
import { getSqliteBaseRecordTable, sqliteBaseRecordIndexes } from '../../sqlite/baseRecord'
|
|
4
|
+
|
|
5
|
+
export const singleContextLruCache = sqliteTable(
|
|
6
|
+
'SingleContextLruCache',
|
|
7
|
+
{
|
|
8
|
+
...getSqliteBaseRecordTable(),
|
|
9
|
+
|
|
10
|
+
entries: text({ mode: 'json' }).notNull().$type<Record<string, SingleContextLruCacheItem>>(),
|
|
11
|
+
},
|
|
12
|
+
(table) => sqliteBaseRecordIndexes(table, 'singleContextLruCache')
|
|
13
|
+
)
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export * from './context/sqlite'
|
|
2
|
+
export * from './did/sqlite'
|
|
3
|
+
export * from './genericRecord/sqlite'
|
|
4
|
+
export * from './mdoc/sqlite'
|
|
5
|
+
export * from './sdJwtVc/sqlite'
|
|
6
|
+
export * from './singleContextLruCache/sqlite'
|
|
7
|
+
export * from './storageVersion/sqlite'
|
|
8
|
+
export * from './w3cCredential/sqlite'
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { JsonTransformer, StorageVersionRecord, TagsBase } 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 DrizzleStorageVersionRecordAdapterValues = DrizzleAdapterRecordValues<(typeof sqlite)['storageVersion']>
|
|
10
|
+
export class DrizzleStorageVersionRecordAdapter extends BaseDrizzleRecordAdapter<
|
|
11
|
+
StorageVersionRecord,
|
|
12
|
+
typeof postgres.storageVersion,
|
|
13
|
+
typeof postgres,
|
|
14
|
+
typeof sqlite.storageVersion,
|
|
15
|
+
typeof sqlite
|
|
16
|
+
> {
|
|
17
|
+
public constructor(database: DrizzleDatabase<typeof postgres, typeof sqlite>) {
|
|
18
|
+
super(database, { postgres: postgres.storageVersion, sqlite: sqlite.storageVersion }, 'StorageVersionRecord')
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public getValues(record: StorageVersionRecord) {
|
|
22
|
+
return {
|
|
23
|
+
storageVersion: record.storageVersion,
|
|
24
|
+
customTags: record.getTags() as Record<string, string>,
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public toRecord(values: DrizzleStorageVersionRecordAdapterValues): StorageVersionRecord {
|
|
29
|
+
const { customTags, ...remainingValues } = values
|
|
30
|
+
|
|
31
|
+
const record = JsonTransformer.fromJSON(remainingValues, StorageVersionRecord)
|
|
32
|
+
record.setTags(customTags as TagsBase)
|
|
33
|
+
|
|
34
|
+
return record
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { DrizzleRecord } from '../../DrizzleRecord'
|
|
2
|
+
import { DrizzleStorageVersionRecordAdapter } from './DrizzleStorageVersionRecordAdapter'
|
|
3
|
+
import * as postgres from './postgres'
|
|
4
|
+
import * as sqlite from './sqlite'
|
|
5
|
+
|
|
6
|
+
export const storageVersionDrizzleRecord = {
|
|
7
|
+
adapter: DrizzleStorageVersionRecordAdapter,
|
|
8
|
+
postgres,
|
|
9
|
+
sqlite,
|
|
10
|
+
} satisfies DrizzleRecord
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { VersionString } from '@credo-ts/core'
|
|
2
|
+
import { pgTable, text } from 'drizzle-orm/pg-core'
|
|
3
|
+
import { getPostgresBaseRecordTable, postgresBaseRecordIndexes } from '../../postgres/baseRecord'
|
|
4
|
+
|
|
5
|
+
export const storageVersion = pgTable(
|
|
6
|
+
'StorageVersion',
|
|
7
|
+
{
|
|
8
|
+
...getPostgresBaseRecordTable(),
|
|
9
|
+
|
|
10
|
+
storageVersion: text('storage_version').notNull().$type<VersionString>(),
|
|
11
|
+
},
|
|
12
|
+
(table) => postgresBaseRecordIndexes(table, 'storageVersion')
|
|
13
|
+
)
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { VersionString } from '@credo-ts/core'
|
|
2
|
+
import { sqliteTable, text } from 'drizzle-orm/sqlite-core'
|
|
3
|
+
import { getSqliteBaseRecordTable, sqliteBaseRecordIndexes } from '../../sqlite/baseRecord'
|
|
4
|
+
|
|
5
|
+
export const storageVersion = sqliteTable(
|
|
6
|
+
'StorageVersion',
|
|
7
|
+
{
|
|
8
|
+
...getSqliteBaseRecordTable(),
|
|
9
|
+
|
|
10
|
+
storageVersion: text('storage_version').notNull().$type<VersionString>(),
|
|
11
|
+
},
|
|
12
|
+
(table) => sqliteBaseRecordIndexes(table, 'storageVersion')
|
|
13
|
+
)
|