feat: spec to platform
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { RoleSchema } from "@spec/schemas/account/role.ts";
|
||||
import { RoleSchema } from "@platform/spec/account/role.ts";
|
||||
import { PrincipalProvider } from "@valkyr/auth";
|
||||
|
||||
import { db } from "~stores/read-store/database.ts";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ServerError } from "@spec/relay";
|
||||
import { ServerError } from "@platform/relay";
|
||||
|
||||
import type { Level } from "../level.ts";
|
||||
import { getTracedAt } from "../stack.ts";
|
||||
|
||||
@@ -10,7 +10,7 @@ import {
|
||||
type ServerErrorResponse,
|
||||
UnauthorizedError,
|
||||
ZodValidationError,
|
||||
} from "@spec/relay";
|
||||
} from "@platform/relay";
|
||||
import { treeifyError } from "zod";
|
||||
|
||||
import { logger } from "~libraries/logger/mod.ts";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { ServerContext } from "@spec/relay";
|
||||
import { ServerContext } from "@platform/relay";
|
||||
|
||||
import type { Sockets } from "~libraries/socket/sockets.ts";
|
||||
|
||||
@@ -7,7 +7,7 @@ import { Session } from "../auth/auth.ts";
|
||||
import { Principal } from "../auth/principal.ts";
|
||||
import { req } from "./request.ts";
|
||||
|
||||
declare module "@spec/relay" {
|
||||
declare module "@platform/relay" {
|
||||
interface ServerContext {
|
||||
/**
|
||||
* Current request instance being handled.
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Route } from "@spec/relay";
|
||||
import { Route } from "@platform/relay";
|
||||
|
||||
/**
|
||||
* Resolve and return all routes that has been created under any 'routes'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { InternalServerError, UnauthorizedError } from "@spec/relay";
|
||||
import { InternalServerError, UnauthorizedError } from "@platform/relay";
|
||||
|
||||
import { Session } from "../auth/auth.ts";
|
||||
import { storage } from "./storage.ts";
|
||||
|
||||
@@ -7,15 +7,15 @@
|
||||
"dependencies": {
|
||||
"@cerbos/http": "0.23.1",
|
||||
"@felix/bcrypt": "npm:@jsr/felix__bcrypt@1.0.5",
|
||||
"@spec/modules": "workspace:*",
|
||||
"@spec/relay": "workspace:*",
|
||||
"@spec/shared": "workspace:*",
|
||||
"@platform/models": "workspace:*",
|
||||
"@platform/relay": "workspace:*",
|
||||
"@platform/spec": "workspace:*",
|
||||
"@std/cli": "npm:@jsr/std__cli@1.0.22",
|
||||
"@std/dotenv": "npm:@jsr/std__dotenv@0.225.5",
|
||||
"@std/fs": "npm:@jsr/std__fs@1.0.19",
|
||||
"@std/path": "npm:@jsr/std__path@1.1.2",
|
||||
"@valkyr/auth": "npm:@jsr/valkyr__auth@2.1.4",
|
||||
"@valkyr/event-store": "npm:@jsr/valkyr__event-store@2",
|
||||
"@valkyr/event-store": "npm:@jsr/valkyr__event-store@2.0.1",
|
||||
"@valkyr/inverse": "npm:@jsr/valkyr__inverse@1.0.1",
|
||||
"@valkyr/json-rpc": "npm:@jsr/valkyr__json-rpc@1.1.0",
|
||||
"cookie": "1.0.2",
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { procedure } from "@spec/relay/mod.ts";
|
||||
import { procedure } from "@platform/relay";
|
||||
import z from "zod";
|
||||
|
||||
const EventSchema = z.object({
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { AccountEmailClaimedError } from "@spec/schemas/account/errors.ts";
|
||||
import { create } from "@spec/schemas/account/routes.ts";
|
||||
import { AccountEmailClaimedError } from "@platform/spec/account/errors.ts";
|
||||
import { create } from "@platform/spec/account/routes.ts";
|
||||
|
||||
import { Account, isEmailClaimed } from "~stores/event-store/aggregates/account.ts";
|
||||
import { eventStore } from "~stores/event-store/event-store.ts";
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { ForbiddenError } from "@spec/relay/mod.ts";
|
||||
import { NotFoundError } from "@spec/relay/mod.ts";
|
||||
import { getById } from "@spec/schemas/account/routes.ts";
|
||||
import { ForbiddenError, NotFoundError } from "@platform/relay";
|
||||
import { getById } from "@platform/spec/account/routes.ts";
|
||||
|
||||
import { db } from "~stores/read-store/database.ts";
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { code } from "@spec/schemas/auth/routes.ts";
|
||||
import { code } from "@platform/spec/auth/routes.ts";
|
||||
import cookie from "cookie";
|
||||
|
||||
import { auth, config } from "~libraries/auth/mod.ts";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { email } from "@spec/schemas/auth/routes.ts";
|
||||
import { email } from "@platform/spec/auth/routes.ts";
|
||||
|
||||
import { logger } from "~libraries/logger/mod.ts";
|
||||
import { Account, getAccountEmailRelation } from "~stores/event-store/aggregates/account.ts";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { BadRequestError } from "@spec/relay";
|
||||
import { password as route } from "@spec/schemas/auth/routes.ts";
|
||||
import { BadRequestError } from "@platform/relay";
|
||||
import { password as route } from "@platform/spec/auth/routes.ts";
|
||||
import cookie from "cookie";
|
||||
|
||||
import { config } from "~config";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { UnauthorizedError } from "@spec/relay/mod.ts";
|
||||
import { session } from "@spec/schemas/auth/routes.ts";
|
||||
import { UnauthorizedError } from "@platform/relay";
|
||||
import { session } from "@platform/spec/auth/routes.ts";
|
||||
|
||||
import { getAccountById } from "~stores/read-store/methods.ts";
|
||||
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
import { toAccountDocument } from "@spec/schemas/account/account.ts";
|
||||
import { Role } from "@spec/schemas/account/role.ts";
|
||||
import { Strategy } from "@spec/schemas/account/strategies.ts";
|
||||
import { Avatar } from "@spec/schemas/avatar.ts";
|
||||
import { Contact } from "@spec/schemas/contact.ts";
|
||||
import { Email } from "@spec/schemas/email.ts";
|
||||
import { Name } from "@spec/schemas/name.ts";
|
||||
import { toAccountDocument } from "@platform/models/account.ts";
|
||||
import { Avatar } from "@platform/models/value-objects/avatar.ts";
|
||||
import { Contact } from "@platform/models/value-objects/contact.ts";
|
||||
import { Email } from "@platform/models/value-objects/email.ts";
|
||||
import { Name } from "@platform/models/value-objects/name.ts";
|
||||
import { Role } from "@platform/spec/account/role.ts";
|
||||
import { Strategy } from "@platform/spec/account/strategies.ts";
|
||||
import { AggregateRoot, getDate } from "@valkyr/event-store";
|
||||
|
||||
import { db } from "~stores/read-store/database.ts";
|
||||
|
||||
import { eventStore } from "../event-store.ts";
|
||||
import { Auditor, systemAuditor } from "../events/auditor.ts";
|
||||
import { EventStoreFactory } from "../events/mod.ts";
|
||||
import { EventRecord, EventStoreFactory } from "../events/mod.ts";
|
||||
import { projector } from "../projector.ts";
|
||||
|
||||
export class Account extends AggregateRoot<EventStoreFactory> {
|
||||
@@ -32,11 +32,12 @@ export class Account extends AggregateRoot<EventStoreFactory> {
|
||||
// Reducer
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
with(event: EventStoreFactory["$events"][number]["$record"]): void {
|
||||
with(event: EventRecord): void {
|
||||
switch (event.type) {
|
||||
case "account:created": {
|
||||
this.id = event.stream;
|
||||
this.createdAt = getDate(event.created);
|
||||
break;
|
||||
}
|
||||
case "account:avatar:added": {
|
||||
this.avatar = { url: event.data };
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { AggregateRoot, getDate } from "@valkyr/event-store";
|
||||
|
||||
import { CodeIdentity } from "../events/code.ts";
|
||||
import { EventStoreFactory } from "../events/mod.ts";
|
||||
import { EventRecord, EventStoreFactory } from "../events/mod.ts";
|
||||
|
||||
export class Code extends AggregateRoot<EventStoreFactory> {
|
||||
static override readonly name = "code";
|
||||
@@ -24,7 +24,7 @@ export class Code extends AggregateRoot<EventStoreFactory> {
|
||||
// Folder
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
with(event: EventStoreFactory["$events"][number]["$record"]): void {
|
||||
with(event: EventRecord): void {
|
||||
switch (event.type) {
|
||||
case "code:created": {
|
||||
this.value = event.data.value;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { RoleSchema } from "@spec/schemas/account/role.ts";
|
||||
import { EmailSchema } from "@spec/schemas/email.ts";
|
||||
import { NameSchema } from "@spec/schemas/name.ts";
|
||||
import { EmailSchema } from "@platform/models/value-objects/email.ts";
|
||||
import { NameSchema } from "@platform/models/value-objects/name.ts";
|
||||
import { RoleSchema } from "@platform/spec/account/role.ts";
|
||||
import { event } from "@valkyr/event-store";
|
||||
import z from "zod";
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { EventFactory } from "@valkyr/event-store";
|
||||
import { EventFactory, Prettify } from "@valkyr/event-store";
|
||||
|
||||
import account from "./account.ts";
|
||||
import code from "./code.ts";
|
||||
@@ -8,3 +8,5 @@ import strategy from "./strategy.ts";
|
||||
export const events = new EventFactory([...account, ...code, ...organization, ...strategy]);
|
||||
|
||||
export type EventStoreFactory = typeof events;
|
||||
|
||||
export type EventRecord = Prettify<EventStoreFactory["$events"][number]["$record"]>;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import type { AccountDocument } from "@spec/schemas/account/account.ts";
|
||||
import type { AccountDocument } from "@platform/models/account.ts";
|
||||
|
||||
import { config } from "~config";
|
||||
import { getDatabaseAccessor } from "~libraries/database/accessor.ts";
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { type Account, fromAccountDocument } from "@spec/schemas/account/account.ts";
|
||||
import { PasswordStrategy } from "@spec/schemas/auth/strategies.ts";
|
||||
import { Account, fromAccountDocument } from "@platform/models/account.ts";
|
||||
import { PasswordStrategy } from "@platform/spec/auth/strategies.ts";
|
||||
|
||||
import { db, takeOne } from "./database.ts";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user