1.0.12 • Published 1 year ago

heq-migrate v1.0.12

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

heq-migrate

Migration tools for heq server

Usage

using npx

$ npx heq-migrate http://origin.server http://destination.server --transform=transform.js --pulseCount=200
// migration.js

// map: (event: Event) => Event|false|undefined|true
// return true or a transformed event to commit it, return false or undefined to discard it.
// when no function provided, default to x => x
module.exports = function (event) {
  // there is no id key in event
  // event.id === undefined

  if (event.type === "type_1") return true; // keep this type
  if (event.meta.occurred_at <= 1512345123456) return false; // discard events older than this time

  // modified an event and commit the changes
  if (event.type === "type_2" && event.payload.key !== "value") {
    event.type = "modified_type_2";
    event.payload.key = "new_value";
    return true;
  }

  // return an object to shallowly merge with original event
  if (event.type === "type_3") {
    return {
      type: "modified_type_3",
      payload: { new: "payload" },
      // as no meta is provided, new event copies original meta
    };
  }

  // if you return nothing (undefined) or false, the event will be discarded
};
1.0.12

1 year ago

1.0.11

2 years ago

1.0.9

3 years ago

1.0.10

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago