From a0b7121d59d3b31a20f1dce686136206bddeb82a Mon Sep 17 00:00:00 2001 From: Raffael Campos Date: Wed, 23 Oct 2024 10:33:06 -0300 Subject: [PATCH] Refactor imports and update project structure Refactor import paths across several files to improve project organization. Moved types from `src/types/contractValues.ts` to `src/contracts-api/contractValues.ts` to better align with their usage context. This change streamlines module imports and clarifies file responsibilities. --- .../contractValues.ts | 0 src/contracts-api/deployStream.ts | 12 ++--- src/contracts-api/destroyStream.ts | 10 ++--- src/contracts-api/primitiveStream.ts | 2 +- src/contracts-api/stream.ts | 45 ++++++++++++------- 5 files changed, 41 insertions(+), 28 deletions(-) rename src/{types => contracts-api}/contractValues.ts (100%) diff --git a/src/types/contractValues.ts b/src/contracts-api/contractValues.ts similarity index 100% rename from src/types/contractValues.ts rename to src/contracts-api/contractValues.ts diff --git a/src/contracts-api/deployStream.ts b/src/contracts-api/deployStream.ts index ef1ff59..42345cf 100644 --- a/src/contracts-api/deployStream.ts +++ b/src/contracts-api/deployStream.ts @@ -1,14 +1,14 @@ -import { StreamType } from "../types/contractValues.js"; -import { TxReceipt } from "@kwilteam/kwil-js/dist/core/tx.js"; -import { Kwil } from "@kwilteam/kwil-js/dist/client/kwil.js"; -import { CompiledKuneiform } from "@kwilteam/kwil-js/dist/core/payload.js"; +import { StreamType } from "./contractValues"; +import { TxReceipt } from "@kwilteam/kwil-js/dist/core/tx"; +import { Kwil } from "@kwilteam/kwil-js/dist/client/kwil"; +import { CompiledKuneiform } from "@kwilteam/kwil-js/dist/core/payload"; import { composedStreamTemplate, primitiveStreamTemplate, } from "../contracts/contractsContent.js"; -import { GenericResponse } from "@kwilteam/kwil-js/dist/core/resreq.js"; +import { GenericResponse } from "@kwilteam/kwil-js/dist/core/resreq"; import { KwilSigner } from "@kwilteam/kwil-js"; -import { StreamId } from "../util/StreamId.js"; +import { StreamId } from "../util/StreamId"; export interface DeployStreamInput { streamId: StreamId; diff --git a/src/contracts-api/destroyStream.ts b/src/contracts-api/destroyStream.ts index 11a8414..101ccf8 100644 --- a/src/contracts-api/destroyStream.ts +++ b/src/contracts-api/destroyStream.ts @@ -1,9 +1,9 @@ -import { StreamId } from "../util/StreamId.js"; -import { Kwil } from "@kwilteam/kwil-js/dist/client/kwil.js"; +import { StreamId } from "../util/StreamId"; +import { Kwil } from "@kwilteam/kwil-js/dist/client/kwil"; import { KwilSigner } from "@kwilteam/kwil-js"; -import { TxReceipt } from "@kwilteam/kwil-js/dist/core/tx.js"; -import { GenericResponse } from "@kwilteam/kwil-js/dist/core/resreq.js"; -import { generateDBID } from "@kwilteam/kwil-js/dist/utils/dbid.js"; +import { TxReceipt } from "@kwilteam/kwil-js/dist/core/tx"; +import { GenericResponse } from "@kwilteam/kwil-js/dist/core/resreq"; +import { generateDBID } from "@kwilteam/kwil-js/dist/utils/dbid"; /** * Input parameters for destroying a stream. diff --git a/src/contracts-api/primitiveStream.ts b/src/contracts-api/primitiveStream.ts index eeee74b..4458e59 100644 --- a/src/contracts-api/primitiveStream.ts +++ b/src/contracts-api/primitiveStream.ts @@ -2,7 +2,7 @@ import { KwilSigner, NodeKwil, WebKwil } from "@kwilteam/kwil-js"; import { ActionInput } from "@kwilteam/kwil-js/dist/core/action"; import { GenericResponse } from "@kwilteam/kwil-js/dist/core/resreq"; import { TxReceipt } from "@kwilteam/kwil-js/dist/core/tx"; -import { StreamType } from "../types/contractValues"; +import { StreamType } from "./contractValues"; import { StreamLocator } from "../types/stream"; import { Stream } from "./stream"; diff --git a/src/contracts-api/stream.ts b/src/contracts-api/stream.ts index a3fc0af..0807584 100644 --- a/src/contracts-api/stream.ts +++ b/src/contracts-api/stream.ts @@ -1,27 +1,40 @@ +import { KwilSigner, NodeKwil, WebKwil } from "@kwilteam/kwil-js"; +import { ActionInput } from "@kwilteam/kwil-js/dist/core/action"; +import { Database } from "@kwilteam/kwil-js/dist/core/database"; import { GenericResponse } from "@kwilteam/kwil-js/dist/core/resreq"; import { TxReceipt } from "@kwilteam/kwil-js/dist/core/tx"; -import { - GetFirstRecordInput, - GetRecordInput, - StreamLocator, - StreamRecord, -} from "../types/stream"; +import { generateDBID } from "@kwilteam/kwil-js/dist/utils/dbid"; +import { Either } from "monads-io"; +import { DateString } from "../types/other"; +import { StreamLocator } from "../types/stream"; +import { EthereumAddress } from "../util/EthereumAddress"; +import { head } from "../util/head"; +import { StreamId } from "../util/StreamId"; +import { toVisibilityEnum, VisibilityEnum } from "../util/visibility"; import { MetadataKey, MetadataKeyValueMap, MetadataTableKey, MetadataValueTypeForKey, StreamType, -} from "../types/contractValues"; -import { EthereumAddress } from "../util/EthereumAddress"; -import { toVisibilityEnum, VisibilityEnum } from "../util/visibility"; -import { KwilSigner, NodeKwil, WebKwil } from "@kwilteam/kwil-js"; -import { Database } from "@kwilteam/kwil-js/dist/core/database"; -import { generateDBID } from "@kwilteam/kwil-js/dist/utils/dbid"; -import { ActionInput } from "@kwilteam/kwil-js/dist/core/action"; -import { StreamId } from "../util/StreamId"; -import { Either } from "monads-io"; -import { head } from "../util/head"; +} from "./contractValues"; + +export interface GetRecordInput { + dateFrom?: DateString; + dateTo?: DateString; + frozenAt?: number; + baseDate?: DateString; +} + +export interface GetFirstRecordInput { + afterDate?: DateString; + frozenAt?: DateString; +} + +export interface StreamRecord { + dateValue: DateString; + value: string; +} export class Stream { protected kwilClient: WebKwil | NodeKwil;