@flowcore/data-pump 0.1.10 → 0.2.0

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.
Files changed (36) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/esm/deps/jsr.io/@flowcore/time-uuid/0.1.1/src/lib/time-uuid.d.ts +25 -0
  3. package/esm/deps/jsr.io/@flowcore/time-uuid/0.1.1/src/lib/time-uuid.d.ts.map +1 -0
  4. package/esm/deps/jsr.io/@flowcore/time-uuid/0.1.1/src/lib/time-uuid.js +201 -0
  5. package/esm/deps/jsr.io/@flowcore/time-uuid/0.1.1/src/lib/uuid.d.ts +51 -0
  6. package/esm/deps/jsr.io/@flowcore/time-uuid/0.1.1/src/lib/uuid.d.ts.map +1 -0
  7. package/esm/deps/jsr.io/@flowcore/time-uuid/0.1.1/src/lib/uuid.js +131 -0
  8. package/esm/deps/jsr.io/@flowcore/time-uuid/0.1.1/src/mod.d.ts +3 -0
  9. package/esm/deps/jsr.io/@flowcore/time-uuid/0.1.1/src/mod.d.ts.map +1 -0
  10. package/esm/deps/jsr.io/@flowcore/time-uuid/0.1.1/src/mod.js +2 -0
  11. package/esm/lib/data-pump.d.ts.map +1 -1
  12. package/esm/lib/data-pump.js +14 -7
  13. package/esm/mod.d.ts +0 -1
  14. package/esm/mod.d.ts.map +1 -1
  15. package/esm/mod.js +0 -1
  16. package/package.json +2 -2
  17. package/script/deps/jsr.io/@flowcore/time-uuid/0.1.1/src/lib/time-uuid.d.ts +25 -0
  18. package/script/deps/jsr.io/@flowcore/time-uuid/0.1.1/src/lib/time-uuid.d.ts.map +1 -0
  19. package/script/deps/jsr.io/@flowcore/time-uuid/0.1.1/src/lib/time-uuid.js +230 -0
  20. package/script/deps/jsr.io/@flowcore/time-uuid/0.1.1/src/lib/uuid.d.ts +51 -0
  21. package/script/deps/jsr.io/@flowcore/time-uuid/0.1.1/src/lib/uuid.d.ts.map +1 -0
  22. package/script/deps/jsr.io/@flowcore/time-uuid/0.1.1/src/lib/uuid.js +157 -0
  23. package/script/deps/jsr.io/@flowcore/time-uuid/0.1.1/src/mod.d.ts +3 -0
  24. package/script/deps/jsr.io/@flowcore/time-uuid/0.1.1/src/mod.d.ts.map +1 -0
  25. package/script/deps/jsr.io/@flowcore/time-uuid/0.1.1/src/mod.js +18 -0
  26. package/script/lib/data-pump.d.ts.map +1 -1
  27. package/script/lib/data-pump.js +16 -9
  28. package/script/mod.d.ts +0 -1
  29. package/script/mod.d.ts.map +1 -1
  30. package/script/mod.js +0 -1
  31. package/esm/lib/time-uuid.d.ts +0 -15
  32. package/esm/lib/time-uuid.d.ts.map +0 -1
  33. package/esm/lib/time-uuid.js +0 -43
  34. package/script/lib/time-uuid.d.ts +0 -15
  35. package/script/lib/time-uuid.d.ts.map +0 -1
  36. package/script/lib/time-uuid.js +0 -47
package/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.2.0](https://github.com/flowcore-io/data-pump/compare/v0.1.11...v0.2.0) (2025-02-20)
4
+
5
+
6
+ ### Features
7
+
8
+ * remove time-uuid and cassandra driver util and use package ([3b35efa](https://github.com/flowcore-io/data-pump/commit/3b35efa912f430d6404ce30500b7582a2e200526))
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * logging changes ([5ac7fa3](https://github.com/flowcore-io/data-pump/commit/5ac7fa3daba5876ea2194c3bb87c2a5819c32159))
14
+
15
+ ## [0.1.11](https://github.com/flowcore-io/data-pump/compare/v0.1.10...v0.1.11) (2025-02-19)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * fix for stop at ([efded7a](https://github.com/flowcore-io/data-pump/commit/efded7ad473e9b533378eb0b0c629ca7805ba2e4))
21
+
3
22
  ## [0.1.10](https://github.com/flowcore-io/data-pump/compare/v0.1.9...v0.1.10) (2025-02-19)
4
23
 
5
24
 
@@ -0,0 +1,25 @@
1
+ import { Buffer } from "node:buffer";
2
+ import { Uuid } from "./uuid.js";
3
+ interface DatePrecision {
4
+ date: Date;
5
+ ticks: number;
6
+ }
7
+ export declare class TimeUuid extends Uuid {
8
+ /**
9
+ * Creates a new instance of TimeUuid based on the parameters provided according to rfc4122.
10
+ */
11
+ constructor(value?: Date | Buffer, ticks?: number, nodeId?: string | Buffer, clockId?: string | Buffer);
12
+ static fromDate(date?: Date, ticks?: number, nodeId?: string | Buffer, clockId?: string | Buffer): TimeUuid;
13
+ static fromString(value: string): TimeUuid;
14
+ static min(date: Date, ticks?: number): TimeUuid;
15
+ static max(date: Date, ticks?: number): TimeUuid;
16
+ static now(nodeId?: string | Buffer, clockId?: string | Buffer): TimeUuid;
17
+ getDatePrecision(): DatePrecision;
18
+ getDate(): Date;
19
+ getNodeId(): Buffer;
20
+ getClockId(): Buffer;
21
+ getNodeIdString(): string;
22
+ getBefore(): TimeUuid;
23
+ }
24
+ export {};
25
+ //# sourceMappingURL=time-uuid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"time-uuid.d.ts","sourceRoot":"","sources":["../../../../../../../../src/deps/jsr.io/@flowcore/time-uuid/0.1.1/src/lib/time-uuid.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,UAAU,aAAa;IACrB,IAAI,EAAE,IAAI,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;CACd;AA0CD,qBAAa,QAAS,SAAQ,IAAI;IAChC;;OAEG;gBAED,KAAK,CAAC,EAAE,IAAI,GAAG,MAAM,EACrB,KAAK,CAAC,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EACxB,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM;IAc3B,MAAM,CAAC,QAAQ,CACb,IAAI,CAAC,EAAE,IAAI,EACX,KAAK,CAAC,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EACxB,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,GACxB,QAAQ;WAIK,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ;IAInD,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,QAAQ;IAIhD,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,QAAQ;IAIhD,MAAM,CAAC,GAAG,CACR,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EACxB,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,GACxB,QAAQ;IAIX,gBAAgB,IAAI,aAAa;IAsBjC,OAAO,IAAI,IAAI;IAIf,SAAS,IAAI,MAAM;IAInB,UAAU,IAAI,MAAM;IAIpB,eAAe,IAAI,MAAM;IAIzB,SAAS,IAAI,QAAQ;CAItB"}
@@ -0,0 +1,201 @@
1
+ /*
2
+ * Copyright DataStax, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ "use strict";
17
+ import * as crypto from "node:crypto";
18
+ import Long from "long";
19
+ import { Buffer } from "node:buffer";
20
+ import { Uuid } from "./uuid.js";
21
+ /** @module types */
22
+ /**
23
+ * Oct 15, 1582 in milliseconds since unix epoch
24
+ * @const
25
+ * @private
26
+ */
27
+ const _unixToGregorian = 12219292800000;
28
+ /**
29
+ * 10,000 ticks in a millisecond
30
+ * @const
31
+ * @private
32
+ */
33
+ const _ticksInMs = 10000;
34
+ const minNodeId = Buffer.from("808080808080", "hex");
35
+ const minClockId = Buffer.from("8080", "hex");
36
+ const maxNodeId = Buffer.from("7f7f7f7f7f7f", "hex");
37
+ const maxClockId = Buffer.from("7f7f", "hex");
38
+ /**
39
+ * Counter used to generate up to 10000 different timeuuid values with the same Date
40
+ * @private
41
+ */
42
+ let _ticks = 0;
43
+ /**
44
+ * Counter used to generate ticks for the current time
45
+ * @private
46
+ */
47
+ let _ticksForCurrentTime = 0;
48
+ /**
49
+ * Remember the last time when a ticks for the current time so that it can be reset
50
+ * @private
51
+ */
52
+ let _lastTimestamp = 0;
53
+ export class TimeUuid extends Uuid {
54
+ /**
55
+ * Creates a new instance of TimeUuid based on the parameters provided according to rfc4122.
56
+ */
57
+ constructor(value, ticks, nodeId, clockId) {
58
+ let buffer;
59
+ if (value instanceof Buffer) {
60
+ if (value.length !== 16) {
61
+ throw new Error("Buffer for v1 uuid not valid");
62
+ }
63
+ buffer = value;
64
+ }
65
+ else {
66
+ buffer = generateBuffer(value, ticks, nodeId, clockId);
67
+ }
68
+ super(buffer);
69
+ }
70
+ static fromDate(date, ticks, nodeId, clockId) {
71
+ return new TimeUuid(date, ticks, nodeId, clockId);
72
+ }
73
+ static fromString(value) {
74
+ return new TimeUuid(Uuid.fromString(value).getBuffer());
75
+ }
76
+ static min(date, ticks) {
77
+ return new TimeUuid(date, ticks, minNodeId, minClockId);
78
+ }
79
+ static max(date, ticks) {
80
+ return new TimeUuid(date, ticks, maxNodeId, maxClockId);
81
+ }
82
+ static now(nodeId, clockId) {
83
+ return TimeUuid.fromDate(undefined, undefined, nodeId, clockId);
84
+ }
85
+ getDatePrecision() {
86
+ const timeLow = this.buffer.readUInt32BE(0);
87
+ let timeHigh = 0;
88
+ timeHigh |= (this.buffer[4] & 0xff) << 8;
89
+ timeHigh |= this.buffer[5] & 0xff;
90
+ timeHigh |= (this.buffer[6] & 0x0f) << 24;
91
+ timeHigh |= (this.buffer[7] & 0xff) << 16;
92
+ const val = Long.fromBits(timeLow, timeHigh);
93
+ const ticksInMsLong = Long.fromNumber(_ticksInMs);
94
+ const ticks = val.modulo(ticksInMsLong);
95
+ const time = val
96
+ .div(ticksInMsLong)
97
+ .subtract(Long.fromNumber(_unixToGregorian));
98
+ return {
99
+ date: new Date(time.toNumber()),
100
+ ticks: ticks.toNumber(),
101
+ };
102
+ }
103
+ getDate() {
104
+ return this.getDatePrecision().date;
105
+ }
106
+ getNodeId() {
107
+ return this.buffer.subarray(10);
108
+ }
109
+ getClockId() {
110
+ return this.buffer.subarray(8, 10);
111
+ }
112
+ getNodeIdString() {
113
+ return this.buffer.subarray(10).toString("ascii");
114
+ }
115
+ getBefore() {
116
+ const { date: beforeDate, ticks } = this.getDatePrecision();
117
+ return TimeUuid.fromDate(beforeDate, ticks - 1, this.getNodeId(), this.getClockId());
118
+ }
119
+ }
120
+ // Helper functions
121
+ function writeTime(buffer, time, ticks) {
122
+ const val = Long
123
+ .fromNumber(time + _unixToGregorian)
124
+ .multiply(Long.fromNumber(10000))
125
+ .add(Long.fromNumber(ticks));
126
+ const timeHigh = val.getHighBitsUnsigned();
127
+ buffer.writeUInt32BE(val.getLowBitsUnsigned(), 0);
128
+ buffer.writeUInt16BE(timeHigh & 0xffff, 4);
129
+ buffer.writeUInt16BE(timeHigh >>> 16 & 0xffff, 6);
130
+ }
131
+ function getClockId(clockId) {
132
+ let buffer = clockId;
133
+ if (typeof clockId === "string") {
134
+ buffer = Buffer.from(clockId, "ascii");
135
+ }
136
+ if (!(buffer instanceof Buffer)) {
137
+ buffer = getRandomBytes(2);
138
+ }
139
+ else if (buffer.length !== 2) {
140
+ throw new Error("Clock identifier must have 2 bytes");
141
+ }
142
+ return buffer;
143
+ }
144
+ function getNodeId(nodeId) {
145
+ let buffer = nodeId;
146
+ if (typeof nodeId === "string") {
147
+ buffer = Buffer.from(nodeId, "ascii");
148
+ }
149
+ if (!(buffer instanceof Buffer)) {
150
+ buffer = getRandomBytes(6);
151
+ }
152
+ else if (buffer.length !== 6) {
153
+ throw new Error("Node identifier must have 6 bytes");
154
+ }
155
+ return buffer;
156
+ }
157
+ function getTicks(ticks) {
158
+ if (typeof ticks !== "number" || ticks >= _ticksInMs) {
159
+ _ticks++;
160
+ if (_ticks >= _ticksInMs) {
161
+ _ticks = 0;
162
+ }
163
+ ticks = _ticks;
164
+ }
165
+ return ticks;
166
+ }
167
+ function getTimeWithTicks(date, ticks) {
168
+ if (!(date instanceof Date) || isNaN(date.getTime())) {
169
+ date = new Date();
170
+ const time = date.getTime();
171
+ _ticksForCurrentTime++;
172
+ if (_ticksForCurrentTime > _ticksInMs || time > _lastTimestamp) {
173
+ _ticksForCurrentTime = 0;
174
+ _lastTimestamp = time;
175
+ }
176
+ ticks = _ticksForCurrentTime;
177
+ }
178
+ return {
179
+ time: date.getTime(),
180
+ ticks: getTicks(ticks),
181
+ };
182
+ }
183
+ function getRandomBytes(length) {
184
+ return crypto.randomBytes(length);
185
+ }
186
+ function generateBuffer(date, ticks, nodeId, clockId) {
187
+ const timeWithTicks = getTimeWithTicks(date, ticks);
188
+ const nodeBuffer = getNodeId(nodeId);
189
+ const clockBuffer = getClockId(clockId);
190
+ const buffer = Buffer.alloc(16);
191
+ writeTime(buffer, timeWithTicks.time, timeWithTicks.ticks);
192
+ clockBuffer.copy(buffer, 8, 0);
193
+ nodeBuffer.copy(buffer, 10, 0);
194
+ // Version Byte: Time based
195
+ buffer[6] = buffer[6] & 0x0f;
196
+ buffer[6] = buffer[6] | 0x10;
197
+ // IETF Variant Byte
198
+ buffer[8] = buffer[8] & 0x3f;
199
+ buffer[8] = buffer[8] | 0x80;
200
+ return buffer;
201
+ }
@@ -0,0 +1,51 @@
1
+ import { Buffer } from "node:buffer";
2
+ /** @module types */
3
+ /**
4
+ * Represents an immutable universally unique identifier (UUID).
5
+ * A UUID represents a 128-bit value.
6
+ */
7
+ export declare class Uuid {
8
+ protected buffer: Buffer;
9
+ /**
10
+ * Creates a new instance of Uuid based on a Buffer
11
+ * @param buffer The 16-length buffer.
12
+ */
13
+ constructor(buffer: Buffer);
14
+ /**
15
+ * Parses a string representation of a Uuid
16
+ * @param value The string representation of UUID
17
+ * @returns A new Uuid instance
18
+ */
19
+ static fromString(value: string): Uuid;
20
+ /**
21
+ * Creates a new random (version 4) Uuid.
22
+ */
23
+ static random(): Uuid;
24
+ /**
25
+ * Gets the bytes representation of a Uuid
26
+ * @returns The buffer containing the bytes
27
+ */
28
+ getBuffer(): Buffer;
29
+ /**
30
+ * Compares this object to the specified object.
31
+ * The result is true if and only if the argument is not null, is a UUID object,
32
+ * and contains the same value, bit for bit, as this UUID.
33
+ * @param other The other value to test for equality.
34
+ */
35
+ equals(other: Uuid): boolean;
36
+ /**
37
+ * Returns a string representation of the value of this Uuid instance.
38
+ * 32 hex separated by hyphens, in the form of 00000000-0000-0000-0000-000000000000.
39
+ */
40
+ toString(): string;
41
+ /**
42
+ * Provide the name of the constructor and the string representation
43
+ */
44
+ inspect(): string;
45
+ /**
46
+ * Returns the string representation.
47
+ * Method used by the native JSON.stringify() to serialize this instance.
48
+ */
49
+ toJSON(): string;
50
+ }
51
+ //# sourceMappingURL=uuid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"uuid.d.ts","sourceRoot":"","sources":["../../../../../../../../src/deps/jsr.io/@flowcore/time-uuid/0.1.1/src/lib/uuid.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,oBAAoB;AAEpB;;;GAGG;AACH,qBAAa,IAAI;IACf,SAAS,CAAC,MAAM,EAAE,MAAM,CAAA;IAExB;;;OAGG;gBACS,MAAM,EAAE,MAAM;IAO1B;;;;OAIG;IACH,MAAM,CAAC,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAQtC;;OAEG;IACH,MAAM,CAAC,MAAM,IAAI,IAAI;IAKrB;;;OAGG;IACH,SAAS,IAAI,MAAM;IAInB;;;;;OAKG;IACH,MAAM,CAAC,KAAK,EAAE,IAAI,GAAG,OAAO;IAI5B;;;OAGG;IACH,QAAQ,IAAI,MAAM;IAYlB;;OAEG;IACH,OAAO,IAAI,MAAM;IAIjB;;;OAGG;IACH,MAAM,IAAI,MAAM;CAGjB"}
@@ -0,0 +1,131 @@
1
+ /*
2
+ * Copyright DataStax, Inc.
3
+ *
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * you may not use this file except in compliance with the License.
6
+ * You may obtain a copy of the License at
7
+ *
8
+ * http://www.apache.org/licenses/LICENSE-2.0
9
+ *
10
+ * Unless required by applicable law or agreed to in writing, software
11
+ * distributed under the License is distributed on an "AS IS" BASIS,
12
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ * See the License for the specific language governing permissions and
14
+ * limitations under the License.
15
+ */
16
+ "use strict";
17
+ import * as crypto from "node:crypto";
18
+ import { Buffer } from "node:buffer";
19
+ /** @module types */
20
+ /**
21
+ * Represents an immutable universally unique identifier (UUID).
22
+ * A UUID represents a 128-bit value.
23
+ */
24
+ export class Uuid {
25
+ /**
26
+ * Creates a new instance of Uuid based on a Buffer
27
+ * @param buffer The 16-length buffer.
28
+ */
29
+ constructor(buffer) {
30
+ Object.defineProperty(this, "buffer", {
31
+ enumerable: true,
32
+ configurable: true,
33
+ writable: true,
34
+ value: void 0
35
+ });
36
+ if (!buffer || buffer.length !== 16) {
37
+ throw new Error("You must provide a buffer containing 16 bytes");
38
+ }
39
+ this.buffer = buffer;
40
+ }
41
+ /**
42
+ * Parses a string representation of a Uuid
43
+ * @param value The string representation of UUID
44
+ * @returns A new Uuid instance
45
+ */
46
+ static fromString(value) {
47
+ //36 chars: 32 + 4 hyphens
48
+ if (typeof value !== "string" || value.length !== 36) {
49
+ throw new Error("Invalid string representation of Uuid, it should be in the 00000000-0000-0000-0000-000000000000");
50
+ }
51
+ return new Uuid(Buffer.from(value.replace(/-/g, ""), "hex"));
52
+ }
53
+ /**
54
+ * Creates a new random (version 4) Uuid.
55
+ */
56
+ static random() {
57
+ const buffer = getRandomBytes();
58
+ return createUuidFromBuffer(buffer);
59
+ }
60
+ /**
61
+ * Gets the bytes representation of a Uuid
62
+ * @returns The buffer containing the bytes
63
+ */
64
+ getBuffer() {
65
+ return this.buffer;
66
+ }
67
+ /**
68
+ * Compares this object to the specified object.
69
+ * The result is true if and only if the argument is not null, is a UUID object,
70
+ * and contains the same value, bit for bit, as this UUID.
71
+ * @param other The other value to test for equality.
72
+ */
73
+ equals(other) {
74
+ return other instanceof Uuid && this.buffer.equals(other.buffer);
75
+ }
76
+ /**
77
+ * Returns a string representation of the value of this Uuid instance.
78
+ * 32 hex separated by hyphens, in the form of 00000000-0000-0000-0000-000000000000.
79
+ */
80
+ toString() {
81
+ //32 hex representation of the Buffer
82
+ const hexValue = getHex(this);
83
+ return (hexValue.substr(0, 8) + "-" +
84
+ hexValue.substr(8, 4) + "-" +
85
+ hexValue.substr(12, 4) + "-" +
86
+ hexValue.substr(16, 4) + "-" +
87
+ hexValue.substr(20, 12));
88
+ }
89
+ /**
90
+ * Provide the name of the constructor and the string representation
91
+ */
92
+ inspect() {
93
+ return this.constructor.name + ": " + this.toString();
94
+ }
95
+ /**
96
+ * Returns the string representation.
97
+ * Method used by the native JSON.stringify() to serialize this instance.
98
+ */
99
+ toJSON() {
100
+ return this.toString();
101
+ }
102
+ }
103
+ /**
104
+ * Returns new Uuid
105
+ * @private
106
+ */
107
+ function createUuidFromBuffer(buffer) {
108
+ //clear the version
109
+ buffer[6] &= 0x0f;
110
+ //set the version 4
111
+ buffer[6] |= 0x40;
112
+ //clear the variant
113
+ buffer[8] &= 0x3f;
114
+ //set the IETF variant
115
+ buffer[8] |= 0x80;
116
+ return new Uuid(buffer);
117
+ }
118
+ /**
119
+ * @private
120
+ * @returns 32 hex representation of the instance, without separators
121
+ */
122
+ function getHex(uuid) {
123
+ return uuid.getBuffer().toString("hex");
124
+ }
125
+ /**
126
+ * Gets a crypto generated 16 bytes
127
+ * @private
128
+ */
129
+ function getRandomBytes() {
130
+ return crypto.randomBytes(16);
131
+ }
@@ -0,0 +1,3 @@
1
+ export * from "./lib/time-uuid.js";
2
+ export * from "./lib/uuid.js";
3
+ //# sourceMappingURL=mod.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../../../../../../../src/deps/jsr.io/@flowcore/time-uuid/0.1.1/src/mod.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAA;AAClC,cAAc,eAAe,CAAA"}
@@ -0,0 +1,2 @@
1
+ export * from "./lib/time-uuid.js";
2
+ export * from "./lib/uuid.js";
@@ -1 +1 @@
1
- {"version":3,"file":"data-pump.d.ts","sourceRoot":"","sources":["../../src/lib/data-pump.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,KAAK,cAAc,EACnB,KAAK,aAAa,EAEnB,MAAM,iDAAiD,CAAA;AAiBxD,MAAM,WAAW,MAAM;IACrB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAA;IAChD,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAA;IAC/C,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAA;IAC/C,KAAK,CAAC,OAAO,EAAE,MAAM,GAAG,KAAK,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,GAAG,IAAI,CAAA;CACzD;AAED,UAAU,eAAe;IACvB,cAAc,EAAE,cAAc,CAAA;IAC9B,YAAY,EAAE,oBAAoB,CAAA;IAClC,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,gBAAgB,CAAA;IAC1B,UAAU,EAAE;QACV,MAAM,EAAE,MAAM,CAAA;QACd,QAAQ,EAAE,MAAM,CAAA;QAChB,QAAQ,EAAE,MAAM,CAAA;QAChB,UAAU,EAAE,MAAM,EAAE,CAAA;KACrB,CA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AM,WAAW,gBAAgB;IAC/B,IAAI,CAAC,UAAU,EAAE,eAAe,CAAC,YAAY,CAAC,GAAG;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE,EAAE,MAAM,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAC9G;AAED,qBAAa,QAAQ;IAgBP,OAAO,CAAC,OAAO;IAf3B,OAAO,CAAC,MAAM,CAAC,CAAQ;IACvB,OAAO,CAAC,KAAK,CAAe;IAC5B,OAAO,CAAC,YAAY,CAAe;IACnC,OAAO,CAAC,MAAM,CAA4B;IAC1C,OAAO,CAAC,YAAY,CAA8C;IAClE,OAAO,CAAC,MAAM,CAA8C;IAC5D,OAAO,CAAC,OAAO,CAAQ;IACvB,OAAO,CAAC,uBAAuB,CAAC,CAAiB;IACjD,OAAO,CAAC,UAAU,CAAC,CAAQ;IAC3B,OAAO,CAAC,MAAM,CAAC,CAId;gBAEmB,OAAO,EAAE,eAAe;IAO/B,KAAK;IAiDX,IAAI;YAWG,SAAS;YAqBT,eAAe;YAsGf,MAAM;IAsCpB,OAAO,CAAC,WAAW;IAenB,OAAO,KAAK,WAAW,GAMtB;IAED,OAAO,CAAC,oBAAoB;YAgBd,iBAAiB;YAoBjB,SAAS;YA4CT,gBAAgB;YA2BhB,eAAe;YAUf,aAAa;YAab,sBAAsB;IAepC,OAAO,CAAC,gBAAgB;YAIV,aAAa;IAmBpB,IAAI,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAO9C,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC;CAMtD"}
@@ -1,5 +1,5 @@
1
1
  import { DataCoreFetchCommand, EventsFetchCommand, EventsFetchTimeBucketsByNamesCommand, TenantFetchCommand, } from "../deps/jsr.io/@flowcore/sdk/1.11.10/src/mod.js";
2
- import { TimeUuid } from "./time-uuid.js";
2
+ import { TimeUuid } from "../deps/jsr.io/@flowcore/time-uuid/0.1.1/src/mod.js";
3
3
  import { format, startOfHour } from "date-fns";
4
4
  import { utc } from "@date-fns/utc";
5
5
  var FlowcoreBufferEventStatus;
@@ -99,7 +99,7 @@ export class DataPump {
99
99
  const newState = await this.options.stateManager.getState();
100
100
  if (!newState) {
101
101
  this.state.timeBucket = this.getClosestTimeBucket(this.getNowTimeBucket());
102
- this.state.eventId = TimeUuid.fromNow().toString();
102
+ this.state.eventId = TimeUuid.now().toString();
103
103
  }
104
104
  else {
105
105
  this.state.timeBucket = this.getClosestTimeBucket(newState.timeBucket);
@@ -173,7 +173,7 @@ export class DataPump {
173
173
  }
174
174
  // How many events should we fetch
175
175
  const eventsToFetch = this.options.buffer.size - this.buffer.length;
176
- this.logger?.debug(`fetching ${eventsToFetch} events from ${this.state.timeBucket} @ ${this.state.eventId ?? "-"}`);
176
+ this.logger?.info(`fetching events from ${this.state.timeBucket} @ ${this.state.eventId ?? "-"}`);
177
177
  const timeStart = Date.now();
178
178
  const command = new EventsFetchCommand({
179
179
  tenant: this.options.dataSource.tenant,
@@ -201,7 +201,7 @@ export class DataPump {
201
201
  this.buffer.push(...events);
202
202
  // Check if we have a waiter and if we have events, notify the waiter
203
203
  events.length && this.waiter?.();
204
- this.logger?.debug(`Got ${result.events.length} events from ${this.state.timeBucket} @ ${this.state.eventId ?? "-"} in ${time}ms. Buffer size ${this.buffer.length}`);
204
+ this.logger?.info(`Got ${result.events.length} events from ${this.state.timeBucket} @ ${this.state.eventId ?? "-"} in ${time}ms. Buffer size ${this.buffer.length}`);
205
205
  // Update buffer state
206
206
  this.state.eventId = result.events[result.events.length - 1]?.eventId ?? this.state.eventId;
207
207
  // If we don't have a next cursor move to next time bucket
@@ -210,6 +210,7 @@ export class DataPump {
210
210
  if (this.state.timeBucket === this.stopAt?.timeBucket) {
211
211
  this.stopAt.eventBufferReached = true;
212
212
  this.logger?.debug("Reached stop at");
213
+ this.waiter?.();
213
214
  return this.eventBufferLoop();
214
215
  }
215
216
  // Get next time bucket
@@ -268,8 +269,9 @@ export class DataPump {
268
269
  const firstEvent = this.buffer[0];
269
270
  if (!firstEvent) {
270
271
  if (eventId) {
271
- const timeUuid = TimeUuid.fromString(eventId);
272
- return this.options.stateManager.setState?.({ timeBucket: timeUuid.getTimeBucket(), eventId });
272
+ const date = TimeUuid.fromString(eventId).getDate();
273
+ const timeBucket = format(startOfHour(utc(date)), "yyyyMMddHH0000");
274
+ return this.options.stateManager.setState?.({ timeBucket, eventId });
273
275
  }
274
276
  return;
275
277
  }
@@ -318,6 +320,11 @@ export class DataPump {
318
320
  if (!this.running) {
319
321
  throw new Error("Data pump not running");
320
322
  }
323
+ if (this.stopAt?.eventBufferReached && this.buffer.length === 0) {
324
+ await this.options.processor?.onDone?.();
325
+ await this.stop();
326
+ return [];
327
+ }
321
328
  const deliveryId = crypto.randomUUID();
322
329
  const events = [];
323
330
  for (const event of this.buffer) {
@@ -370,7 +377,7 @@ export class DataPump {
370
377
  }
371
378
  }
372
379
  async waitForNotifier() {
373
- this.logger?.debug("No more events, waiting for notifier...");
380
+ this.logger?.info("No more events, waiting for notifier...");
374
381
  this.notifierAbortController = new AbortController();
375
382
  await this.options.notifier.wait({ ...this.options.dataSource, dataCoreId: await this.getDataCoreId() }, this.notifierAbortController.signal);
376
383
  this.notifierAbortController = undefined;
package/esm/mod.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  import "./_dnt.polyfills.js";
2
2
  export * from "./lib/data-pump.js";
3
3
  export * from "./lib/data-pump-create.js";
4
- export * from "./lib/time-uuid.js";
5
4
  //# sourceMappingURL=mod.d.ts.map
package/esm/mod.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAC7B,cAAc,oBAAoB,CAAA;AAClC,cAAc,2BAA2B,CAAA;AAEzC,cAAc,oBAAoB,CAAA"}
1
+ {"version":3,"file":"mod.d.ts","sourceRoot":"","sources":["../src/mod.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAC;AAC7B,cAAc,oBAAoB,CAAA;AAClC,cAAc,2BAA2B,CAAA"}
package/esm/mod.js CHANGED
@@ -1,4 +1,3 @@
1
1
  import "./_dnt.polyfills.js";
2
2
  export * from "./lib/data-pump.js";
3
3
  export * from "./lib/data-pump-create.js";
4
- export * from "./lib/time-uuid.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowcore/data-pump",
3
- "version": "0.1.10",
3
+ "version": "0.2.0",
4
4
  "description": "Flowcore Data Pump",
5
5
  "homepage": "https://github.com/flowcore-io/flowcore-data-pump#readme",
6
6
  "repository": {
@@ -22,8 +22,8 @@
22
22
  "dependencies": {
23
23
  "@date-fns/utc": "^2.1.0",
24
24
  "@sinclair/typebox": "0.32.15",
25
- "cassandra-driver": "^4.7.2",
26
25
  "date-fns": "^4.1.0",
26
+ "long": "^5.3.1",
27
27
  "nats": "^2.29.1",
28
28
  "rxjs": "^7.8.1",
29
29
  "@deno/shim-deno": "~0.18.0",
@@ -0,0 +1,25 @@
1
+ import { Buffer } from "node:buffer";
2
+ import { Uuid } from "./uuid.js";
3
+ interface DatePrecision {
4
+ date: Date;
5
+ ticks: number;
6
+ }
7
+ export declare class TimeUuid extends Uuid {
8
+ /**
9
+ * Creates a new instance of TimeUuid based on the parameters provided according to rfc4122.
10
+ */
11
+ constructor(value?: Date | Buffer, ticks?: number, nodeId?: string | Buffer, clockId?: string | Buffer);
12
+ static fromDate(date?: Date, ticks?: number, nodeId?: string | Buffer, clockId?: string | Buffer): TimeUuid;
13
+ static fromString(value: string): TimeUuid;
14
+ static min(date: Date, ticks?: number): TimeUuid;
15
+ static max(date: Date, ticks?: number): TimeUuid;
16
+ static now(nodeId?: string | Buffer, clockId?: string | Buffer): TimeUuid;
17
+ getDatePrecision(): DatePrecision;
18
+ getDate(): Date;
19
+ getNodeId(): Buffer;
20
+ getClockId(): Buffer;
21
+ getNodeIdString(): string;
22
+ getBefore(): TimeUuid;
23
+ }
24
+ export {};
25
+ //# sourceMappingURL=time-uuid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"time-uuid.d.ts","sourceRoot":"","sources":["../../../../../../../../src/deps/jsr.io/@flowcore/time-uuid/0.1.1/src/lib/time-uuid.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,UAAU,aAAa;IACrB,IAAI,EAAE,IAAI,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;CACd;AA0CD,qBAAa,QAAS,SAAQ,IAAI;IAChC;;OAEG;gBAED,KAAK,CAAC,EAAE,IAAI,GAAG,MAAM,EACrB,KAAK,CAAC,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EACxB,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM;IAc3B,MAAM,CAAC,QAAQ,CACb,IAAI,CAAC,EAAE,IAAI,EACX,KAAK,CAAC,EAAE,MAAM,EACd,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EACxB,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,GACxB,QAAQ;WAIK,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,QAAQ;IAInD,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,QAAQ;IAIhD,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,QAAQ;IAIhD,MAAM,CAAC,GAAG,CACR,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,EACxB,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,GACxB,QAAQ;IAIX,gBAAgB,IAAI,aAAa;IAsBjC,OAAO,IAAI,IAAI;IAIf,SAAS,IAAI,MAAM;IAIn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