From 614ef7136c93b43cfa138d3d951c0ad7b3dd8f86 Mon Sep 17 00:00:00 2001 From: Mark Krasner <70119343+mzkrasner@users.noreply.github.com> Date: Fri, 6 Dec 2024 16:37:23 -0500 Subject: [PATCH] Consistent naming of ModelInstanceClient class (#37) --- docs/@ceramic-sdk/model-instance-client/README.md | 2 +- .../{DocumentClient.md => ModelInstanceClient.md} | 10 +++++----- packages/model-instance-client/src/client.ts | 2 +- packages/model-instance-client/src/index.ts | 2 +- packages/model-instance-client/test/lib.test.ts | 12 ++++++------ tests/c1-integration/test/classes.test.ts | 6 +++--- 6 files changed, 17 insertions(+), 17 deletions(-) rename docs/@ceramic-sdk/model-instance-client/classes/{DocumentClient.md => ModelInstanceClient.md} (93%) diff --git a/docs/@ceramic-sdk/model-instance-client/README.md b/docs/@ceramic-sdk/model-instance-client/README.md index 38c9b07..c89c725 100644 --- a/docs/@ceramic-sdk/model-instance-client/README.md +++ b/docs/@ceramic-sdk/model-instance-client/README.md @@ -8,7 +8,7 @@ ## Classes -- [DocumentClient](classes/DocumentClient.md) +- [ModelInstanceClient](classes/ModelInstanceClient.md) ## Type Aliases diff --git a/docs/@ceramic-sdk/model-instance-client/classes/DocumentClient.md b/docs/@ceramic-sdk/model-instance-client/classes/ModelInstanceClient.md similarity index 93% rename from docs/@ceramic-sdk/model-instance-client/classes/DocumentClient.md rename to docs/@ceramic-sdk/model-instance-client/classes/ModelInstanceClient.md index 467fbd1..fd2faaa 100644 --- a/docs/@ceramic-sdk/model-instance-client/classes/DocumentClient.md +++ b/docs/@ceramic-sdk/model-instance-client/classes/ModelInstanceClient.md @@ -2,9 +2,9 @@ *** -[Ceramic SDK](../../../README.md) / [@ceramic-sdk/model-instance-client](../README.md) / DocumentClient +[Ceramic SDK](../../../README.md) / [@ceramic-sdk/model-instance-client](../README.md) / ModelInstanceClient -# Class: DocumentClient +# Class: ModelInstanceClient ## Extends @@ -12,9 +12,9 @@ ## Constructors -### new DocumentClient() +### new ModelInstanceClient() -> **new DocumentClient**(`params`): [`DocumentClient`](DocumentClient.md) +> **new ModelInstanceClient**(`params`): [`ModelInstanceClient`](ModelInstanceClient.md) #### Parameters @@ -22,7 +22,7 @@ #### Returns -[`DocumentClient`](DocumentClient.md) +[`ModelInstanceClient`](ModelInstanceClient.md) #### Inherited from diff --git a/packages/model-instance-client/src/client.ts b/packages/model-instance-client/src/client.ts index 3d2172b..91d417d 100644 --- a/packages/model-instance-client/src/client.ts +++ b/packages/model-instance-client/src/client.ts @@ -35,7 +35,7 @@ export type PostDataParams = Omit< controller?: DID } -export class DocumentClient extends StreamClient { +export class ModelInstanceClient extends StreamClient { /** Get a DocumentEvent based on its commit ID */ async getEvent(commitID: CommitID | string): Promise { const id = diff --git a/packages/model-instance-client/src/index.ts b/packages/model-instance-client/src/index.ts index 06bee5d..8fa19fa 100644 --- a/packages/model-instance-client/src/index.ts +++ b/packages/model-instance-client/src/index.ts @@ -1,5 +1,5 @@ export { - DocumentClient, + ModelInstanceClient, type PostDataParams, type PostDeterministicInitParams, type PostSignedInitParams, diff --git a/packages/model-instance-client/test/lib.test.ts b/packages/model-instance-client/test/lib.test.ts index d6783f3..3ae5abc 100644 --- a/packages/model-instance-client/test/lib.test.ts +++ b/packages/model-instance-client/test/lib.test.ts @@ -12,7 +12,7 @@ import { jest } from '@jest/globals' import { equals } from 'uint8arrays' import { - DocumentClient, + ModelInstanceClient, createDataEvent, createInitEvent, getDeterministicInitEvent, @@ -136,14 +136,14 @@ describe('createDataEvent()', () => { }) }) -describe('DocumentClient', () => { +describe('ModelInstanceClient', () => { describe('getEvent() method', () => { test('gets a MID event by commit ID', async () => { const streamID = randomStreamID() const docEvent = getDeterministicInitEvent(streamID, 'did:key:123') const getEventType = jest.fn(() => docEvent) const ceramic = { getEventType } as unknown as CeramicClient - const client = new DocumentClient({ ceramic, did: authenticatedDID }) + const client = new ModelInstanceClient({ ceramic, did: authenticatedDID }) const commitID = CommitID.fromStream(streamID) const event = await client.getEvent(CommitID.fromStream(streamID)) @@ -159,7 +159,7 @@ describe('DocumentClient', () => { test('posts the deterministic init event and returns the MID init CommitID', async () => { const postEventType = jest.fn(() => randomCID()) const ceramic = { postEventType } as unknown as CeramicClient - const client = new DocumentClient({ ceramic, did: authenticatedDID }) + const client = new ModelInstanceClient({ ceramic, did: authenticatedDID }) const id = await client.postDeterministicInit({ controller: 'did:key:123', @@ -175,7 +175,7 @@ describe('DocumentClient', () => { test('posts the signed init event and returns the MID init CommitID', async () => { const postEventType = jest.fn(() => randomCID()) const ceramic = { postEventType } as unknown as CeramicClient - const client = new DocumentClient({ ceramic, did: authenticatedDID }) + const client = new ModelInstanceClient({ ceramic, did: authenticatedDID }) const id = await client.postSignedInit({ content: { test: true }, @@ -192,7 +192,7 @@ describe('DocumentClient', () => { test('posts the signed data event and returns the CommitID', async () => { const postEventType = jest.fn(() => randomCID()) const ceramic = { postEventType } as unknown as CeramicClient - const client = new DocumentClient({ ceramic, did: authenticatedDID }) + const client = new ModelInstanceClient({ ceramic, did: authenticatedDID }) const initCommitID = await client.postSignedInit({ content: { test: 0 }, diff --git a/tests/c1-integration/test/classes.test.ts b/tests/c1-integration/test/classes.test.ts index 90af5b8..7517e1a 100644 --- a/tests/c1-integration/test/classes.test.ts +++ b/tests/c1-integration/test/classes.test.ts @@ -5,7 +5,7 @@ import { type ModelState, handleInitEvent as handleModel, } from '@ceramic-sdk/model-handler' -import { DocumentClient } from '@ceramic-sdk/model-instance-client' +import { ModelInstanceClient } from '@ceramic-sdk/model-instance-client' import { type DocumentState, handleEvent as handleDocument, @@ -80,7 +80,7 @@ describe('stream classes', () => { context, ) - const docClient = new DocumentClient({ + const docClient = new ModelInstanceClient({ ceramic: client, did: authenticatedDID, }) @@ -169,7 +169,7 @@ describe('stream classes', () => { context, ) - const docClient = new DocumentClient({ + const docClient = new ModelInstanceClient({ ceramic: client, did: authenticatedDID, })