feat: version 2 beta
This commit is contained in:
49
adapters/mongo/collections/events.ts
Normal file
49
adapters/mongo/collections/events.ts
Normal file
@@ -0,0 +1,49 @@
|
||||
import z from "zod";
|
||||
|
||||
import type { CollectionRegistrar } from "../types.ts";
|
||||
|
||||
export const registrar: CollectionRegistrar = {
|
||||
name: "events",
|
||||
indexes: [
|
||||
[
|
||||
{
|
||||
stream: 1,
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
type: 1,
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
recorded: 1,
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
created: 1,
|
||||
},
|
||||
],
|
||||
],
|
||||
};
|
||||
|
||||
export const schema = z.object({
|
||||
id: z.string(),
|
||||
stream: z.string(),
|
||||
type: z.string(),
|
||||
data: z.any(),
|
||||
meta: z.any(),
|
||||
recorded: z.string(),
|
||||
created: z.string(),
|
||||
});
|
||||
|
||||
export type EventSchema = {
|
||||
id: string;
|
||||
stream: string;
|
||||
type: string;
|
||||
data: Record<string, any> | null;
|
||||
meta: Record<string, any> | null;
|
||||
recorded: string;
|
||||
created: string;
|
||||
};
|
||||
10
adapters/mongo/collections/mod.ts
Normal file
10
adapters/mongo/collections/mod.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
import { CollectionRegistrar } from "../types.ts";
|
||||
import { registrar as events } from "./events.ts";
|
||||
import { registrar as relations } from "./relations.ts";
|
||||
import { registrar as snapshots } from "./snapshots.ts";
|
||||
|
||||
export const registrars: CollectionRegistrar[] = [
|
||||
events,
|
||||
relations,
|
||||
snapshots,
|
||||
];
|
||||
38
adapters/mongo/collections/relations.ts
Normal file
38
adapters/mongo/collections/relations.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import z from "zod";
|
||||
|
||||
import type { CollectionRegistrar } from "../types.ts";
|
||||
|
||||
export const registrar: CollectionRegistrar = {
|
||||
name: "relations",
|
||||
indexes: [
|
||||
[
|
||||
{
|
||||
key: 1,
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
stream: 1,
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
key: 1,
|
||||
stream: 1,
|
||||
},
|
||||
{
|
||||
unique: true,
|
||||
},
|
||||
],
|
||||
],
|
||||
};
|
||||
|
||||
export const schema = z.object({
|
||||
key: z.string(),
|
||||
streams: z.string().array(),
|
||||
});
|
||||
|
||||
export type RelationSchema = {
|
||||
key: string;
|
||||
streams: string[];
|
||||
};
|
||||
30
adapters/mongo/collections/snapshots.ts
Normal file
30
adapters/mongo/collections/snapshots.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import z from "zod";
|
||||
|
||||
import type { CollectionRegistrar } from "../types.ts";
|
||||
|
||||
export const registrar: CollectionRegistrar = {
|
||||
name: "snapshots",
|
||||
indexes: [
|
||||
[
|
||||
{
|
||||
name: 1,
|
||||
stream: 1,
|
||||
cursor: 1,
|
||||
},
|
||||
],
|
||||
],
|
||||
};
|
||||
|
||||
export const schema = z.object({
|
||||
name: z.string(),
|
||||
stream: z.string(),
|
||||
cursor: z.string(),
|
||||
state: z.record(z.string(), z.any()),
|
||||
});
|
||||
|
||||
export type SnapshotSchema = {
|
||||
name: string;
|
||||
stream: string;
|
||||
cursor: string;
|
||||
state: Record<string, any>;
|
||||
};
|
||||
Reference in New Issue
Block a user