Fix imports and remove some unused files
This commit is contained in:
parent
8d1528de23
commit
87ce76e13f
@ -2,11 +2,11 @@ import type {
|
||||
AsyncResult,
|
||||
MaybePromise,
|
||||
PosixDate,
|
||||
UUID,
|
||||
VariantFromTag,
|
||||
VariantTag,
|
||||
} from "@fabric/core";
|
||||
import type { StoreQueryError } from "../errors/query-error.ts";
|
||||
import type { UUID } from "../types/uuid.ts";
|
||||
import type { Event } from "./event.ts";
|
||||
import type { StoredEvent } from "./stored-event.ts";
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
// deno-lint-ignore-file no-explicit-any
|
||||
import type { VariantTag } from "@fabric/core";
|
||||
import type { UUID } from "../types/uuid.ts";
|
||||
import type { UUID } from "../../core/types/uuid.ts";
|
||||
|
||||
/**
|
||||
* An event is a tagged variant with a payload and a timestamp.
|
||||
|
||||
@ -1,9 +0,0 @@
|
||||
import type { ImageMimeType } from "./mime-type.ts";
|
||||
import type { StoredFile } from "./stored-file.ts";
|
||||
|
||||
/**
|
||||
* Represents an image file.
|
||||
*/
|
||||
export interface ImageFile extends StoredFile {
|
||||
mimeType: ImageMimeType;
|
||||
}
|
||||
@ -1,9 +0,0 @@
|
||||
import type { Base64String } from "../types/base-64.ts";
|
||||
import type { BaseFile } from "./base-file.ts";
|
||||
|
||||
/**
|
||||
* Represents a file with its contents in memory.
|
||||
*/
|
||||
export interface InMemoryFile extends BaseFile {
|
||||
data: Base64String;
|
||||
}
|
||||
@ -1,10 +1,5 @@
|
||||
export * from "./base-file.ts";
|
||||
export * from "./bytes.ts";
|
||||
export * from "./image-file.ts";
|
||||
export * from "./in-memory-file.ts";
|
||||
export * from "./invalid-file-type-error.ts";
|
||||
export * from "./is-in-memory-file.ts";
|
||||
export * from "./is-mime-type.ts";
|
||||
export * from "./media-file.ts";
|
||||
export * from "./mime-type.ts";
|
||||
export * from "./stored-file.ts";
|
||||
|
||||
@ -1,21 +0,0 @@
|
||||
import { isRecord } from "@fabric/core";
|
||||
import type { InMemoryFile } from "./in-memory-file.ts";
|
||||
|
||||
export function isInMemoryFile(value: unknown): value is InMemoryFile {
|
||||
try {
|
||||
return (
|
||||
isRecord(value) &&
|
||||
"data" in value &&
|
||||
typeof value.data === "string" &&
|
||||
"mimeType" in value &&
|
||||
typeof value.mimeType === "string" &&
|
||||
"name" in value &&
|
||||
typeof value.name === "string" &&
|
||||
"sizeInBytes" in value &&
|
||||
typeof value.sizeInBytes === "number" &&
|
||||
value.sizeInBytes >= 1
|
||||
);
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -1,8 +0,0 @@
|
||||
import type { StoredFile } from "./stored-file.ts";
|
||||
|
||||
/**
|
||||
* Represents a media file, either an image, a video or an audio file.
|
||||
*/
|
||||
export interface MediaFile extends StoredFile {
|
||||
mimeType: `image/${string}` | `video/${string}` | `audio/${string}`;
|
||||
}
|
||||
@ -1,9 +0,0 @@
|
||||
import type { Entity } from "../types/entity.ts";
|
||||
import type { BaseFile } from "./base-file.ts";
|
||||
|
||||
/**
|
||||
* Represents a file as managed by the domain.
|
||||
*/
|
||||
export interface StoredFile extends BaseFile, Entity {
|
||||
url: string;
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
import type { UUID } from "../types/uuid.ts";
|
||||
import type { UUID } from "../../core/types/uuid.ts";
|
||||
import type { UUIDGenerator } from "./uuid-generator.ts";
|
||||
|
||||
export const UUIDGeneratorMock: UUIDGenerator = {
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
import type { UUID } from "../types/uuid.ts";
|
||||
import type { UUID } from "../../core/types/uuid.ts";
|
||||
|
||||
export interface UUIDGenerator {
|
||||
generate(): UUID;
|
||||
|
||||
@ -1,10 +1,9 @@
|
||||
import { expect } from "@std/expect";
|
||||
import { describe, it } from "@std/testing/bdd";
|
||||
import { describe, expect, test } from "@fabric/testing";
|
||||
import { CircularDependencyError } from "../errors/circular-dependency-error.ts";
|
||||
import { sortByDependencies } from "./sort-by-dependencies.ts";
|
||||
|
||||
describe("sortByDependencies", () => {
|
||||
it("should sort an array of objects by their dependencies", () => {
|
||||
test("should sort an array of objects by their dependencies", () => {
|
||||
const array = [
|
||||
{ id: 1, name: "A", dependencies: ["C", "D"] },
|
||||
{ id: 2, name: "B", dependencies: ["A", "D"] },
|
||||
@ -25,7 +24,7 @@ describe("sortByDependencies", () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it("should throw a CircularDependencyError when circular dependencies are detected", () => {
|
||||
test("should throw a CircularDependencyError when circular dependencies are detected", () => {
|
||||
const array = [
|
||||
{ id: 1, name: "A", dependencies: ["B"] },
|
||||
{ id: 2, name: "B", dependencies: ["A"] },
|
||||
@ -39,7 +38,7 @@ describe("sortByDependencies", () => {
|
||||
).toBeInstanceOf(CircularDependencyError);
|
||||
});
|
||||
|
||||
it("should return an empty array when the input array is empty", () => {
|
||||
test("should return an empty array when the input array is empty", () => {
|
||||
// deno-lint-ignore no-explicit-any
|
||||
const array: any[] = [];
|
||||
|
||||
|
||||
@ -1,6 +1,9 @@
|
||||
import { Result } from "@fabric/core";
|
||||
import { CircularDependencyError } from "../errors/circular-dependency-error.ts";
|
||||
|
||||
/**
|
||||
* Sorts an array of elements based on their dependencies.
|
||||
*/
|
||||
export function sortByDependencies<T>(
|
||||
array: T[],
|
||||
{
|
||||
|
||||
@ -3,6 +3,7 @@ import {
|
||||
MaybePromise,
|
||||
PosixDate,
|
||||
Run,
|
||||
UUID,
|
||||
VariantTag,
|
||||
} from "@fabric/core";
|
||||
import {
|
||||
@ -13,7 +14,6 @@ import {
|
||||
JSONUtils,
|
||||
StoredEvent,
|
||||
StoreQueryError,
|
||||
UUID,
|
||||
} from "@fabric/domain";
|
||||
import { SQLiteDatabase } from "../sqlite/sqlite-database.ts";
|
||||
|
||||
|
||||
@ -46,6 +46,9 @@ const FieldSQLDefinitionMap: FieldSQLDefinitionMap = {
|
||||
EmbeddedField: (n, f): string => {
|
||||
return [n, "TEXT", modifiersFromOpts(f)].join(" ");
|
||||
},
|
||||
BooleanField: (n, f): string => {
|
||||
return [n, "BOOLEAN", modifiersFromOpts(f)].join(" ");
|
||||
},
|
||||
};
|
||||
function fieldDefinitionToSQL(name: string, field: FieldDefinition) {
|
||||
return FieldSQLDefinitionMap[field[VariantTag]](name, field as any);
|
||||
|
||||
@ -41,4 +41,5 @@ const FieldSQLInsertMap: FieldSQLInsertMap = {
|
||||
DecimalField: (_, v) => v,
|
||||
TimestampField: (_, v) => new PosixDate(v),
|
||||
EmbeddedField: (_, v: string) => JSON.parse(v),
|
||||
BooleanField: (_, v) => v,
|
||||
};
|
||||
|
||||
@ -22,6 +22,7 @@ const FieldSQLInsertMap: FieldSQLInsertMap = {
|
||||
DecimalField: (_, v) => v,
|
||||
TimestampField: (_, v) => v.timestamp,
|
||||
EmbeddedField: (_, v: string) => JSON.stringify(v),
|
||||
BooleanField: (_, v) => v,
|
||||
};
|
||||
|
||||
export function fieldValueToSQL(field: FieldDefinition, value: any) {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { PosixDate, Run } from "@fabric/core";
|
||||
import { defineAggregateModel, Field, isLike, UUID } from "@fabric/domain";
|
||||
import { PosixDate, Run, UUID } from "@fabric/core";
|
||||
import { defineAggregateModel, Field, isLike } from "@fabric/domain";
|
||||
import { UUIDGeneratorMock } from "@fabric/domain/mocks";
|
||||
import {
|
||||
afterEach,
|
||||
|
||||
@ -1,11 +1,10 @@
|
||||
import { AsyncResult, UnexpectedError } from "@fabric/core";
|
||||
import { AsyncResult, UnexpectedError, UUID } from "@fabric/core";
|
||||
import {
|
||||
type Model,
|
||||
type AggregateModel,
|
||||
ModelSchemaFromModels,
|
||||
ModelToType,
|
||||
StoreQuery,
|
||||
StoreQueryError,
|
||||
UUID,
|
||||
WritableStateStore,
|
||||
} from "@fabric/domain";
|
||||
import { modelToSql } from "../sqlite/model-to-sql.ts";
|
||||
@ -19,7 +18,7 @@ import {
|
||||
import { SQLiteDatabase } from "../sqlite/sqlite-database.ts";
|
||||
import { QueryBuilder } from "./query-builder.ts";
|
||||
|
||||
export class SQLiteStateStore<TModel extends Model>
|
||||
export class SQLiteStateStore<TModel extends AggregateModel>
|
||||
implements WritableStateStore<TModel> {
|
||||
private schema: ModelSchemaFromModels<TModel>;
|
||||
private db: SQLiteDatabase;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user