@event-driven-io/emmett 0.1.1 → 0.1.3

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.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  [<img src="https://img.shields.io/badge/LinkedIn-0077B5?style=for-the-badge&logo=linkedin&logoColor=white" height="20px" />](https://www.linkedin.com/in/oskardudycz/) [![Github Sponsors](https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%A4&logo=GitHub&link=https://github.com/sponsors/oskardudycz/)](https://github.com/sponsors/oskardudycz/) [![blog](https://img.shields.io/badge/blog-event--driven.io-brightgreen)](https://event-driven.io/?utm_source=event_sourcing_nodejs) [![blog](https://img.shields.io/badge/%F0%9F%9A%80-Architecture%20Weekly-important)](https://www.architecture-weekly.com/?utm_source=event_sourcing_nodejs)
2
2
 
3
- ![](./docs/logo.png)
3
+ ![](./docs/public/logo.png)
4
4
 
5
5
  # Emmett - vent Sourcing development made simple
6
6
 
package/dist/index.d.mts CHANGED
@@ -1 +1 @@
1
- export { Brand, Command, Decider, Event, Flavour, Workflow, WorkflowCommand, WorkflowEvent, WorkflowOutput, accept, complete, error, ignore, publish, reply, schedule, send } from './typing/index.mjs';
1
+ export { Brand, Command, Decider, DefaultCommandMetadata, Event, Flavour, Workflow, WorkflowCommand, WorkflowEvent, WorkflowOutput, accept, complete, error, ignore, publish, reply, schedule, send } from './typing/index.mjs';
package/dist/index.d.ts CHANGED
@@ -1 +1 @@
1
- export { Brand, Command, Decider, Event, Flavour, Workflow, WorkflowCommand, WorkflowEvent, WorkflowOutput, accept, complete, error, ignore, publish, reply, schedule, send } from './typing/index.js';
1
+ export { Brand, Command, Decider, DefaultCommandMetadata, Event, Flavour, Workflow, WorkflowCommand, WorkflowEvent, WorkflowOutput, accept, complete, error, ignore, publish, reply, schedule, send } from './typing/index.js';
@@ -1 +1 @@
1
- export { Command } from './index.mjs';
1
+ export { Command, DefaultCommandMetadata } from './index.mjs';
@@ -1 +1 @@
1
- export { Command } from './index.js';
1
+ export { Command, DefaultCommandMetadata } from './index.js';
@@ -1,4 +1,7 @@
1
- type Command<CommandType extends string = string, CommandData extends Record<string, unknown> = Record<string, unknown>, CommandMetaData extends Record<string, unknown> = Record<string, unknown>> = Flavour<Readonly<{
1
+ type DefaultCommandMetadata = {
2
+ now: Date;
3
+ };
4
+ type Command<CommandType extends string = string, CommandData extends Record<string, unknown> = Record<string, unknown>, CommandMetaData extends Record<string, unknown> = DefaultCommandMetadata> = Flavour<Readonly<{
2
5
  type: CommandType;
3
6
  data: Readonly<CommandData>;
4
7
  metadata?: CommandMetaData | undefined;
@@ -79,4 +82,4 @@ type Flavour<K, T> = K & {
79
82
  readonly __brand?: T;
80
83
  };
81
84
 
82
- export { type Brand, type Command, type Decider, type Event, type Flavour, type Workflow, type WorkflowCommand, type WorkflowEvent, type WorkflowOutput, accept, complete, error, ignore, publish, reply, schedule, send };
85
+ export { type Brand, type Command, type Decider, type DefaultCommandMetadata, type Event, type Flavour, type Workflow, type WorkflowCommand, type WorkflowEvent, type WorkflowOutput, accept, complete, error, ignore, publish, reply, schedule, send };
@@ -1,4 +1,7 @@
1
- type Command<CommandType extends string = string, CommandData extends Record<string, unknown> = Record<string, unknown>, CommandMetaData extends Record<string, unknown> = Record<string, unknown>> = Flavour<Readonly<{
1
+ type DefaultCommandMetadata = {
2
+ now: Date;
3
+ };
4
+ type Command<CommandType extends string = string, CommandData extends Record<string, unknown> = Record<string, unknown>, CommandMetaData extends Record<string, unknown> = DefaultCommandMetadata> = Flavour<Readonly<{
2
5
  type: CommandType;
3
6
  data: Readonly<CommandData>;
4
7
  metadata?: CommandMetaData | undefined;
@@ -79,4 +82,4 @@ type Flavour<K, T> = K & {
79
82
  readonly __brand?: T;
80
83
  };
81
84
 
82
- export { type Brand, type Command, type Decider, type Event, type Flavour, type Workflow, type WorkflowCommand, type WorkflowEvent, type WorkflowOutput, accept, complete, error, ignore, publish, reply, schedule, send };
85
+ export { type Brand, type Command, type Decider, type DefaultCommandMetadata, type Event, type Flavour, type Workflow, type WorkflowCommand, type WorkflowEvent, type WorkflowOutput, accept, complete, error, ignore, publish, reply, schedule, send };
@@ -0,0 +1,2 @@
1
+ export { sum } from './iterators.mjs';
2
+ export { merge } from './merge.mjs';
@@ -0,0 +1,2 @@
1
+ export { sum } from './iterators.js';
2
+ export { merge } from './merge.js';
@@ -1,2 +1,3 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _createStarExport(obj) { Object.keys(obj) .filter((key) => key !== "default" && key !== "__esModule") .forEach((key) => { if (exports.hasOwnProperty(key)) { return; } Object.defineProperty(exports, key, {enumerable: true, configurable: true, get: () => obj[key]}); }); }var _merge = require('./merge'); _createStarExport(_merge);
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _createStarExport(obj) { Object.keys(obj) .filter((key) => key !== "default" && key !== "__esModule") .forEach((key) => { if (exports.hasOwnProperty(key)) { return; } Object.defineProperty(exports, key, {enumerable: true, configurable: true, get: () => obj[key]}); }); }var _iterators = require('./iterators'); _createStarExport(_iterators);
2
+ var _merge = require('./merge'); _createStarExport(_merge);
2
3
  //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc;AACd,cAAc","sourcesContent":["export * from './iterators';\nexport * from './merge';\n"]}
@@ -0,0 +1,3 @@
1
+ export * from "./iterators";
2
+ export * from "./merge";
3
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/index.ts"],"sourcesContent":["export * from './iterators';\nexport * from './merge';\n"],"mappings":"AAAA,cAAc;AACd,cAAc;","names":[]}
@@ -0,0 +1,3 @@
1
+ declare const sum: (iterator: Iterator<number, number, number>) => number;
2
+
3
+ export { sum };
@@ -0,0 +1,3 @@
1
+ declare const sum: (iterator: Iterator<number, number, number>) => number;
2
+
3
+ export { sum };
@@ -0,0 +1,12 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});const sum = (iterator) => {
2
+ let value, done, sum2 = 0;
3
+ do {
4
+ ({ value, done } = iterator.next());
5
+ sum2 += value || 0;
6
+ } while (!done);
7
+ return sum2;
8
+ };
9
+
10
+
11
+ exports.sum = sum;
12
+ //# sourceMappingURL=iterators.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/iterators.ts"],"names":["sum"],"mappings":"AAAO,MAAM,MAAM,CAAC,aAA+C;AACjE,MAAI,OACF,MACAA,OAAM;AACR,KAAG;AACD,KAAC,EAAE,OAAO,KAAK,IAAI,SAAS,KAAK;AACjC,IAAAA,QAAO,SAAS;AAAA,EAClB,SAAS,CAAC;AACV,SAAOA;AACT","sourcesContent":["export const sum = (iterator: Iterator<number, number, number>) => {\n let value,\n done,\n sum = 0;\n do {\n ({ value, done } = iterator.next());\n sum += value || 0;\n } while (!done);\n return sum;\n};\n"]}
@@ -0,0 +1,12 @@
1
+ const sum = (iterator) => {
2
+ let value, done, sum2 = 0;
3
+ do {
4
+ ({ value, done } = iterator.next());
5
+ sum2 += value || 0;
6
+ } while (!done);
7
+ return sum2;
8
+ };
9
+ export {
10
+ sum
11
+ };
12
+ //# sourceMappingURL=iterators.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/iterators.ts"],"sourcesContent":["export const sum = (iterator: Iterator<number, number, number>) => {\n let value,\n done,\n sum = 0;\n do {\n ({ value, done } = iterator.next());\n sum += value || 0;\n } while (!done);\n return sum;\n};\n"],"mappings":"AAAO,MAAM,MAAM,CAAC,aAA+C;AACjE,MAAI,OACF,MACAA,OAAM;AACR,KAAG;AACD,KAAC,EAAE,OAAO,KAAK,IAAI,SAAS,KAAK;AACjC,IAAAA,QAAO,SAAS;AAAA,EAClB,SAAS,CAAC;AACV,SAAOA;AACT;","names":["sum"]}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/merge.ts"],"names":["result"],"mappings":"AAAO,MAAM,QAAQ,CACnB,OACA,MACA,OACA,YACA,aAAkC,MAAM,WACrC;AACH,MAAI,WAAW;AAEf,QAAM,SAAS,MAEZ,IAAI,CAAC,MAAS;AACb,QAAI,CAAC,MAAM,CAAC;AAAG,aAAO;AAEtB,eAAW;AACX,WAAO,WAAW,CAAC;AAAA,EACrB,CAAC,EAGA,OAAO,CAAC,MAAM,MAAM,MAAS,EAE7B,IAAI,CAAC,MAAM;AACV,QAAI,CAAC;AAAG,YAAM,MAAM,wBAAwB;AAE5C,WAAO;AAAA,EACT,CAAC;AAIH,MAAI,CAAC,UAAU;AACb,UAAMA,UAAS,WAAW;AAE1B,QAAIA,YAAW;AAAW,aAAO,CAAC,GAAG,OAAO,IAAI;AAAA,EAClD;AAEA,SAAO;AACT","sourcesContent":["export const merge = <T>(\n array: T[],\n item: T,\n where: (current: T) => boolean,\n onExisting: (current: T) => T,\n onNotFound: () => T | undefined = () => undefined,\n) => {\n let wasFound = false;\n\n const result = array\n // merge the existing item if matches condition\n .map((p: T) => {\n if (!where(p)) return p;\n\n wasFound = true;\n return onExisting(p);\n })\n // filter out item if undefined was returned\n // for cases of removal\n .filter((p) => p !== undefined)\n // make TypeScript happy\n .map((p) => {\n if (!p) throw Error('That should not happen');\n\n return p;\n });\n\n // if item was not found and onNotFound action is defined\n // try to generate new item\n if (!wasFound) {\n const result = onNotFound();\n\n if (result !== undefined) return [...array, item];\n }\n\n return result;\n};\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/utils/merge.ts"],"sourcesContent":["export const merge = <T>(\n array: T[],\n item: T,\n where: (current: T) => boolean,\n onExisting: (current: T) => T,\n onNotFound: () => T | undefined = () => undefined,\n) => {\n let wasFound = false;\n\n const result = array\n // merge the existing item if matches condition\n .map((p: T) => {\n if (!where(p)) return p;\n\n wasFound = true;\n return onExisting(p);\n })\n // filter out item if undefined was returned\n // for cases of removal\n .filter((p) => p !== undefined)\n // make TypeScript happy\n .map((p) => {\n if (!p) throw Error('That should not happen');\n\n return p;\n });\n\n // if item was not found and onNotFound action is defined\n // try to generate new item\n if (!wasFound) {\n const result = onNotFound();\n\n if (result !== undefined) return [...array, item];\n }\n\n return result;\n};\n"],"mappings":"AAAO,MAAM,QAAQ,CACnB,OACA,MACA,OACA,YACA,aAAkC,MAAM,WACrC;AACH,MAAI,WAAW;AAEf,QAAM,SAAS,MAEZ,IAAI,CAAC,MAAS;AACb,QAAI,CAAC,MAAM,CAAC;AAAG,aAAO;AAEtB,eAAW;AACX,WAAO,WAAW,CAAC;AAAA,EACrB,CAAC,EAGA,OAAO,CAAC,MAAM,MAAM,MAAS,EAE7B,IAAI,CAAC,MAAM;AACV,QAAI,CAAC;AAAG,YAAM,MAAM,wBAAwB;AAE5C,WAAO;AAAA,EACT,CAAC;AAIH,MAAI,CAAC,UAAU;AACb,UAAMA,UAAS,WAAW;AAE1B,QAAIA,YAAW;AAAW,aAAO,CAAC,GAAG,OAAO,IAAI;AAAA,EAClD;AAEA,SAAO;AACT;","names":["result"]}
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@event-driven-io/emmett",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Emmett - Event Sourcing development made simple",
5
5
  "scripts": {
6
6
  "setup": "cat .nvmrc | nvm install; nvm use",
7
7
  "build": "tsup",
8
- "build:ts": "tsc",
8
+ "build:ts": "tsc --build --verbose tsconfig.build.json",
9
9
  "build:ts:watch": "tsc --watch",
10
10
  "start": "ts-node -r tsconfig-paths/register ./src/index.ts",
11
11
  "lint": "npm run lint:eslint && npm run lint:prettier",
@@ -49,6 +49,7 @@
49
49
  "express-async-errors": "3.1.1"
50
50
  },
51
51
  "devDependencies": {
52
+ "@event-driven-io/emmett": "0.1.1",
52
53
  "@faker-js/faker": "8.4.1",
53
54
  "@types/jest": "29.5.0",
54
55
  "@types/node": "20.11.17",
@@ -68,5 +69,8 @@
68
69
  "tsup": "8.0.2",
69
70
  "typescript": "5.3.3",
70
71
  "vitepress": "1.0.0-rc.42"
71
- }
72
+ },
73
+ "workspaces": [
74
+ "samples/*"
75
+ ]
72
76
  }
@@ -1 +0,0 @@
1
- export { merge } from './merge.mjs';
@@ -1 +0,0 @@
1
- export { merge } from './merge.js';
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/immutable/index.ts"],"names":[],"mappings":"AAAA,cAAc","sourcesContent":["export * from './merge';\n"]}
@@ -1,2 +0,0 @@
1
- export * from "./merge";
2
- //# sourceMappingURL=index.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/immutable/index.ts"],"sourcesContent":["export * from './merge';\n"],"mappings":"AAAA,cAAc;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/immutable/merge.ts"],"names":["result"],"mappings":"AAAO,MAAM,QAAQ,CACnB,OACA,MACA,OACA,YACA,aAAkC,MAAM,WACrC;AACH,MAAI,WAAW;AAEf,QAAM,SAAS,MAEZ,IAAI,CAAC,MAAS;AACb,QAAI,CAAC,MAAM,CAAC;AAAG,aAAO;AAEtB,eAAW;AACX,WAAO,WAAW,CAAC;AAAA,EACrB,CAAC,EAGA,OAAO,CAAC,MAAM,MAAM,MAAS,EAE7B,IAAI,CAAC,MAAM;AACV,QAAI,CAAC;AAAG,YAAM,MAAM,wBAAwB;AAE5C,WAAO;AAAA,EACT,CAAC;AAIH,MAAI,CAAC,UAAU;AACb,UAAMA,UAAS,WAAW;AAE1B,QAAIA,YAAW;AAAW,aAAO,CAAC,GAAG,OAAO,IAAI;AAAA,EAClD;AAEA,SAAO;AACT","sourcesContent":["export const merge = <T>(\n array: T[],\n item: T,\n where: (current: T) => boolean,\n onExisting: (current: T) => T,\n onNotFound: () => T | undefined = () => undefined,\n) => {\n let wasFound = false;\n\n const result = array\n // merge the existing item if matches condition\n .map((p: T) => {\n if (!where(p)) return p;\n\n wasFound = true;\n return onExisting(p);\n })\n // filter out item if undefined was returned\n // for cases of removal\n .filter((p) => p !== undefined)\n // make TypeScript happy\n .map((p) => {\n if (!p) throw Error('That should not happen');\n\n return p;\n });\n\n // if item was not found and onNotFound action is defined\n // try to generate new item\n if (!wasFound) {\n const result = onNotFound();\n\n if (result !== undefined) return [...array, item];\n }\n\n return result;\n};\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/immutable/merge.ts"],"sourcesContent":["export const merge = <T>(\n array: T[],\n item: T,\n where: (current: T) => boolean,\n onExisting: (current: T) => T,\n onNotFound: () => T | undefined = () => undefined,\n) => {\n let wasFound = false;\n\n const result = array\n // merge the existing item if matches condition\n .map((p: T) => {\n if (!where(p)) return p;\n\n wasFound = true;\n return onExisting(p);\n })\n // filter out item if undefined was returned\n // for cases of removal\n .filter((p) => p !== undefined)\n // make TypeScript happy\n .map((p) => {\n if (!p) throw Error('That should not happen');\n\n return p;\n });\n\n // if item was not found and onNotFound action is defined\n // try to generate new item\n if (!wasFound) {\n const result = onNotFound();\n\n if (result !== undefined) return [...array, item];\n }\n\n return result;\n};\n"],"mappings":"AAAO,MAAM,QAAQ,CACnB,OACA,MACA,OACA,YACA,aAAkC,MAAM,WACrC;AACH,MAAI,WAAW;AAEf,QAAM,SAAS,MAEZ,IAAI,CAAC,MAAS;AACb,QAAI,CAAC,MAAM,CAAC;AAAG,aAAO;AAEtB,eAAW;AACX,WAAO,WAAW,CAAC;AAAA,EACrB,CAAC,EAGA,OAAO,CAAC,MAAM,MAAM,MAAS,EAE7B,IAAI,CAAC,MAAM;AACV,QAAI,CAAC;AAAG,YAAM,MAAM,wBAAwB;AAE5C,WAAO;AAAA,EACT,CAAC;AAIH,MAAI,CAAC,UAAU;AACb,UAAMA,UAAS,WAAW;AAE1B,QAAIA,YAAW;AAAW,aAAO,CAAC,GAAG,OAAO,IAAI;AAAA,EAClD;AAEA,SAAO;AACT;","names":["result"]}
File without changes
File without changes
File without changes
File without changes