From 5cad5f3d8ec40a77a7edc4c611c4a87a848f6339 Mon Sep 17 00:00:00 2001 From: Francisco Javier Ribo Labrador Date: Tue, 12 Nov 2024 17:32:32 +0100 Subject: [PATCH 1/2] fix: exporting models Signed-off-by: Francisco Javier Ribo Labrador --- src/pluto/rxdb/collections.ts | 32 +++++++++++++++++++++++--------- src/pluto/rxdb/index.ts | 2 ++ 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/pluto/rxdb/collections.ts b/src/pluto/rxdb/collections.ts index 868fd3688..96d08ac87 100644 --- a/src/pluto/rxdb/collections.ts +++ b/src/pluto/rxdb/collections.ts @@ -1,16 +1,30 @@ -import { RxCollectionCreator } from 'rxdb'; +import { MigrationStrategies, RxCollectionCreator, RxJsonSchema } from "rxdb"; import * as Models from "../models"; +import { Schema } from "../models/Schema"; -export type CollectionList = Record; +type CollectionCreate< + RxDocType = any, + SchemaType extends Schema & RxJsonSchema = Schema & + RxJsonSchema +> = { + schema: SchemaType; + migrationStrategies?: + | MigrationStrategies; +}; -type MakeCollections = (additional?: CollectionList) => CollectionList -export const makeCollections: MakeCollections = (additional: CollectionList = {}) => ({ - "credentials": { schema: Models.CredentialSchema, migrationStrategies: Models.CredentialMigration }, +type MakeCollections = (additional?: CollectionList) => CollectionList; + +export type CollectionList = Record; + +export const makeCollections: MakeCollections = ( + additional: CollectionList = {} +) => ({ + credentials: { schema: Models.CredentialSchema, migrationStrategies: Models.CredentialMigration }, "credential-metadata": { schema: Models.CredentialMetadataSchema }, "didkey-link": { schema: Models.DIDKeyLinkSchema }, "did-link": { schema: Models.DIDLinkSchema }, - "dids": { schema: Models.DIDSchema }, - "keys": { schema: Models.KeySchema }, - "messages": { schema: Models.MessageSchema }, - ...(additional), + dids: { schema: Models.DIDSchema }, + keys: { schema: Models.KeySchema }, + messages: { schema: Models.MessageSchema }, + ...additional, }); diff --git a/src/pluto/rxdb/index.ts b/src/pluto/rxdb/index.ts index 2924597f2..8d2b09c58 100644 --- a/src/pluto/rxdb/index.ts +++ b/src/pluto/rxdb/index.ts @@ -1 +1,3 @@ export { RxdbStore as Store } from "./Store"; +export { makeCollections } from "./collections"; +export type { CollectionList } from "./collections"; From 645e40686e6206b7fa99394ebed35daf77f6b19b Mon Sep 17 00:00:00 2001 From: Francisco Javier Ribo Labrador Date: Tue, 12 Nov 2024 17:32:50 +0100 Subject: [PATCH 2/2] fix: small issue Signed-off-by: Francisco Javier Ribo Labrador --- src/pluto/rxdb/collections.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pluto/rxdb/collections.ts b/src/pluto/rxdb/collections.ts index 96d08ac87..9f9aaac0d 100644 --- a/src/pluto/rxdb/collections.ts +++ b/src/pluto/rxdb/collections.ts @@ -1,4 +1,4 @@ -import { MigrationStrategies, RxCollectionCreator, RxJsonSchema } from "rxdb"; +import { MigrationStrategies, RxJsonSchema } from "rxdb"; import * as Models from "../models"; import { Schema } from "../models/Schema";