atomservices 0.12.0-alpha.0 → 0.12.0-alpha.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,33 @@
1
+ interface IEvent<Payload = any, Metadata = any> {
2
+ _id: string;
3
+ name: string;
4
+ aggregateID: string;
5
+ aggregateType: string;
6
+ payload: Payload;
7
+ _version: number;
8
+ _createdAt: Date;
9
+ _createdBy: string;
10
+ _metadata: {} & Metadata;
11
+ }
12
+
13
+ interface IEventStore {
14
+ /**
15
+ * Loads the entire event stream for a specific aggregate.
16
+ * Returns an empty array if no events exist.
17
+ */
18
+ load(aggregateID: string): Promise<IEvent[]>;
19
+ /**
20
+ * Appends new events to the stream.
21
+ * * @param expectedVersion - The version of the aggregate *before* these new events.
22
+ * Used for Optimistic Concurrency Control.
23
+ * If the DB version != expectedVersion, throw ConcurrencyError.
24
+ * @param events - The list of events to append.
25
+ */
26
+ save(expectedVersion: number, events: IEvent[]): Promise<void>;
27
+ /**
28
+ * Optional: Hook for infrastructure setup (indexes, tables).
29
+ */
30
+ init?(): Promise<void>;
31
+ }
32
+
33
+ export type { IEvent, IEventStore };
@@ -0,0 +1,33 @@
1
+ interface IEvent<Payload = any, Metadata = any> {
2
+ _id: string;
3
+ name: string;
4
+ aggregateID: string;
5
+ aggregateType: string;
6
+ payload: Payload;
7
+ _version: number;
8
+ _createdAt: Date;
9
+ _createdBy: string;
10
+ _metadata: {} & Metadata;
11
+ }
12
+
13
+ interface IEventStore {
14
+ /**
15
+ * Loads the entire event stream for a specific aggregate.
16
+ * Returns an empty array if no events exist.
17
+ */
18
+ load(aggregateID: string): Promise<IEvent[]>;
19
+ /**
20
+ * Appends new events to the stream.
21
+ * * @param expectedVersion - The version of the aggregate *before* these new events.
22
+ * Used for Optimistic Concurrency Control.
23
+ * If the DB version != expectedVersion, throw ConcurrencyError.
24
+ * @param events - The list of events to append.
25
+ */
26
+ save(expectedVersion: number, events: IEvent[]): Promise<void>;
27
+ /**
28
+ * Optional: Hook for infrastructure setup (indexes, tables).
29
+ */
30
+ init?(): Promise<void>;
31
+ }
32
+
33
+ export type { IEvent, IEventStore };
package/dist/index.js ADDED
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+
16
+ // src/index.ts
17
+ var index_exports = {};
18
+ module.exports = __toCommonJS(index_exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export { IEvent } from \"./IEvent\";\r\nexport { IEventStore } from \"./IEventStore\";\r\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
package/dist/index.mjs ADDED
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/package.json CHANGED
@@ -1,17 +1,23 @@
1
1
  {
2
2
  "name": "atomservices",
3
- "version": "0.12.0-alpha.0",
4
- "description": "",
3
+ "version": "0.12.0-alpha.1",
4
+ "description": "EventSourcing Core Infrastructure",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
7
7
  "types": "./dist/index.d.ts",
8
8
  "license": "ISC",
9
- "author": "",
9
+ "files": [
10
+ "dist",
11
+ "package.json",
12
+ "README.md"
13
+ ],
14
+ "author": "Architecode",
10
15
  "type": "commonjs",
11
16
  "scripts": {
12
17
  "build": "tsup",
13
18
  "dev": "tsup --watch",
14
- "test": "vitest"
19
+ "test": "vitest",
20
+ "prepublishOnly": "npm run build"
15
21
  },
16
22
  "devDependencies": {
17
23
  "@types/node": "^25.0.3",
package/src/IEvent.ts DELETED
@@ -1,33 +0,0 @@
1
- // src/IEvent.ts
2
-
3
- export interface IEvent<Payload, Metadata = any> {
4
- _id: string; // UUID of the event
5
- name: string; // Event Name (e.g., UserCreated)
6
- aggregateID: string; // ID of the aggregate root (Stream ID)
7
- aggregateType: string; // Type of the aggregate (e.g., User)
8
- payload: Payload; // The Domain Data
9
-
10
- // Infrastructure
11
- _version: number; // Optimistic Concurrency Version (1, 2, 3...)
12
- _createdAt: Date;
13
- _createdBy: string; // User ID
14
- _metadata: {} & Metadata; // Tracing/Context data
15
- }
16
-
17
- /**
18
- * ------------------------------------------------------------------
19
- * INFRASTRUCTURE REQUIREMENT: MONGODB INDEXES
20
- * ------------------------------------------------------------------
21
- * To ensure data integrity and performance, the implementation of
22
- * the EventStore MUST apply the following indexes to the collection:
23
- *
24
- * 1. CONCURRENCY CONTROL (Critical):
25
- * Ensures that for any given Aggregate, versions are unique and sequential.
26
- * Index: { aggregateID: 1, _version: 1 }
27
- * Options: { unique: true }
28
- *
29
- * 2. PERFORMANCE (Recommended):
30
- * Allows fast filtering by aggregate type for admin views/projections.
31
- * Index: { aggregateType: 1, _createdAt: -1 }
32
- * ------------------------------------------------------------------
33
- */
package/src/index.ts DELETED
@@ -1 +0,0 @@
1
- export { IEvent } from "./IEvent";
package/tsconfig.json DELETED
@@ -1,24 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "ES2020",
4
- "module": "ESNext",
5
- "lib": [
6
- "ES2020",
7
- "DOM"
8
- ],
9
- "moduleResolution": "node",
10
- "esModuleInterop": true,
11
- "strict": true,
12
- "skipLibCheck": true,
13
- "declaration": true,
14
- "sourceMap": true,
15
- "outDir": "dist"
16
- },
17
- "include": [
18
- "src"
19
- ],
20
- "exclude": [
21
- "node_modules",
22
- "**/*.test.ts"
23
- ]
24
- }
package/tsup.config.ts DELETED
@@ -1,9 +0,0 @@
1
- import { defineConfig } from "tsup";
2
-
3
- export default defineConfig({
4
- entry: ["src/index.ts"],
5
- format: ["cjs", "esm"],
6
- dts: true,
7
- clean: true,
8
- sourcemap: true,
9
- });