@graphrefly/graphrefly 0.5.0 → 0.6.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.
@@ -32,8 +32,8 @@ import {
32
32
  observeSSE,
33
33
  observeSubscription
34
34
  } from "../../chunk-QW7H3ICI.js";
35
- import "../../chunk-HP7OKEOE.js";
36
35
  import "../../chunk-CP6MNKAA.js";
36
+ import "../../chunk-HP7OKEOE.js";
37
37
  import {
38
38
  observeGraph$,
39
39
  observeNode$,
@@ -85,6 +85,7 @@ __export(extra_exports, {
85
85
  fromPulsar: () => fromPulsar,
86
86
  fromRabbitMQ: () => fromRabbitMQ,
87
87
  fromRedisStream: () => fromRedisStream,
88
+ fromSqlite: () => fromSqlite,
88
89
  fromStatsD: () => fromStatsD,
89
90
  fromSyslog: () => fromSyslog,
90
91
  fromTimer: () => fromTimer,
@@ -162,6 +163,7 @@ __export(extra_exports, {
162
163
  toRedisStream: () => toRedisStream,
163
164
  toS3: () => toS3,
164
165
  toSSE: () => toSSE,
166
+ toSqlite: () => toSqlite,
165
167
  toTempo: () => toTempo,
166
168
  toWebSocket: () => toWebSocket,
167
169
  tokenBucket: () => tokenBucket,
@@ -2375,7 +2377,7 @@ function toWebSocket(source, socket, opts) {
2375
2377
  };
2376
2378
  const inner = node([source], () => void 0, {
2377
2379
  describeKind: "effect",
2378
- onMessage(msg) {
2380
+ onMessage(msg, _depIndex, _actions) {
2379
2381
  if (msg[0] === DATA) {
2380
2382
  let serialized;
2381
2383
  try {
@@ -2826,7 +2828,7 @@ function toKafka(source, kafkaProducer, topic, opts) {
2826
2828
  const inner = node([source], () => void 0, {
2827
2829
  describeKind: "effect",
2828
2830
  ...rest,
2829
- onMessage(msg) {
2831
+ onMessage(msg, _depIndex, _actions) {
2830
2832
  if (msg[0] === DATA) {
2831
2833
  const value = msg[1];
2832
2834
  const key = keyExtractor?.(value) ?? null;
@@ -2925,7 +2927,7 @@ function toRedisStream(source, client, key, opts) {
2925
2927
  const inner = node([source], () => void 0, {
2926
2928
  describeKind: "effect",
2927
2929
  ...rest,
2928
- onMessage(msg) {
2930
+ onMessage(msg, _depIndex, _actions) {
2929
2931
  if (msg[0] === DATA) {
2930
2932
  const value = msg[1];
2931
2933
  let fields;
@@ -3183,7 +3185,7 @@ function toPulsar(source, pulsarProducer, opts) {
3183
3185
  const inner = node([source], () => void 0, {
3184
3186
  describeKind: "effect",
3185
3187
  ...rest,
3186
- onMessage(msg) {
3188
+ onMessage(msg, _depIndex, _actions) {
3187
3189
  if (msg[0] === DATA) {
3188
3190
  const value = msg[1];
3189
3191
  let data;
@@ -3273,7 +3275,7 @@ function toNATS(source, client, subject, opts) {
3273
3275
  const inner = node([source], () => void 0, {
3274
3276
  describeKind: "effect",
3275
3277
  ...rest,
3276
- onMessage(msg) {
3278
+ onMessage(msg, _depIndex, _actions) {
3277
3279
  if (msg[0] === DATA) {
3278
3280
  const value = msg[1];
3279
3281
  let data;
@@ -3367,7 +3369,7 @@ function toRabbitMQ(source, channel, exchange, opts) {
3367
3369
  const inner = node([source], () => void 0, {
3368
3370
  describeKind: "effect",
3369
3371
  ...rest,
3370
- onMessage(msg) {
3372
+ onMessage(msg, _depIndex, _actions) {
3371
3373
  if (msg[0] === DATA) {
3372
3374
  const value = msg[1];
3373
3375
  let routingKey;
@@ -3447,7 +3449,7 @@ function toFile(source, writer, opts) {
3447
3449
  const inner = node([source], () => void 0, {
3448
3450
  describeKind: "effect",
3449
3451
  ...rest,
3450
- onMessage(msg) {
3452
+ onMessage(msg, _depIndex, _actions) {
3451
3453
  if (msg[0] === DATA) {
3452
3454
  const value = msg[1];
3453
3455
  let line;
@@ -3586,7 +3588,7 @@ function toClickHouse(source, client, table, opts) {
3586
3588
  const inner = node([source], () => void 0, {
3587
3589
  describeKind: "effect",
3588
3590
  ...rest,
3589
- onMessage(msg) {
3591
+ onMessage(msg, _depIndex, _actions) {
3590
3592
  if (msg[0] === DATA) {
3591
3593
  const value = msg[1];
3592
3594
  try {
@@ -3682,7 +3684,7 @@ function toS3(source, client, bucket, opts) {
3682
3684
  const inner = node([source], () => void 0, {
3683
3685
  describeKind: "effect",
3684
3686
  ...rest,
3685
- onMessage(msg) {
3687
+ onMessage(msg, _depIndex, _actions) {
3686
3688
  if (msg[0] === DATA) {
3687
3689
  const value = msg[1];
3688
3690
  try {
@@ -3732,7 +3734,7 @@ function toPostgres(source, client, table, opts) {
3732
3734
  const inner = node([source], () => void 0, {
3733
3735
  describeKind: "effect",
3734
3736
  ...rest,
3735
- onMessage(msg) {
3737
+ onMessage(msg, _depIndex, _actions) {
3736
3738
  if (msg[0] === DATA) {
3737
3739
  const value = msg[1];
3738
3740
  let query;
@@ -3766,7 +3768,7 @@ function toMongo(source, collection, opts) {
3766
3768
  const inner = node([source], () => void 0, {
3767
3769
  describeKind: "effect",
3768
3770
  ...rest,
3769
- onMessage(msg) {
3771
+ onMessage(msg, _depIndex, _actions) {
3770
3772
  if (msg[0] === DATA) {
3771
3773
  const value = msg[1];
3772
3774
  let doc;
@@ -3806,7 +3808,7 @@ function toLoki(source, client, opts) {
3806
3808
  const inner = node([source], () => void 0, {
3807
3809
  describeKind: "effect",
3808
3810
  ...rest,
3809
- onMessage(msg) {
3811
+ onMessage(msg, _depIndex, _actions) {
3810
3812
  if (msg[0] === DATA) {
3811
3813
  const value = msg[1];
3812
3814
  let line;
@@ -3852,7 +3854,7 @@ function toTempo(source, client, opts) {
3852
3854
  const inner = node([source], () => void 0, {
3853
3855
  describeKind: "effect",
3854
3856
  ...rest,
3855
- onMessage(msg) {
3857
+ onMessage(msg, _depIndex, _actions) {
3856
3858
  if (msg[0] === DATA) {
3857
3859
  const value = msg[1];
3858
3860
  let spans;
@@ -3921,6 +3923,75 @@ function checkpointToRedis(graph, client, opts) {
3921
3923
  };
3922
3924
  return graph.autoCheckpoint(adapter, { debounceMs, compactEvery, onError });
3923
3925
  }
3926
+ function fromSqlite(db, query, opts) {
3927
+ const { mapRow = (r) => r, params, ...rest } = opts ?? {};
3928
+ return producer(
3929
+ (_d, a) => {
3930
+ let mapped;
3931
+ try {
3932
+ const rows = db.query(query, params);
3933
+ mapped = rows.map(mapRow);
3934
+ } catch (err) {
3935
+ a.down([[ERROR, err instanceof Error ? err : new Error(String(err))]]);
3936
+ return void 0;
3937
+ }
3938
+ batch(() => {
3939
+ for (const item of mapped) {
3940
+ a.down([[DATA, item]]);
3941
+ }
3942
+ a.down([[COMPLETE]]);
3943
+ });
3944
+ return void 0;
3945
+ },
3946
+ { describeKind: "producer", completeWhenDepsComplete: false, ...rest }
3947
+ );
3948
+ }
3949
+ function toSqlite(source, db, table, opts) {
3950
+ if (table.includes("\0") || table.length === 0) {
3951
+ throw new Error(`toSqlite: invalid table name: ${JSON.stringify(table)}`);
3952
+ }
3953
+ const {
3954
+ toSQL = (v, t) => ({
3955
+ sql: `INSERT INTO "${t.replace(/"/g, '""')}" (data) VALUES (?)`,
3956
+ params: [JSON.stringify(v)]
3957
+ }),
3958
+ onTransportError,
3959
+ ...rest
3960
+ } = opts ?? {};
3961
+ const inner = node([source], () => void 0, {
3962
+ describeKind: "effect",
3963
+ ...rest,
3964
+ onMessage(msg, _depIndex, _actions) {
3965
+ if (msg[0] === DATA) {
3966
+ const value = msg[1];
3967
+ let query;
3968
+ try {
3969
+ query = toSQL(value, table);
3970
+ } catch (err) {
3971
+ onTransportError?.({
3972
+ stage: "serialize",
3973
+ error: err instanceof Error ? err : new Error(String(err)),
3974
+ value
3975
+ });
3976
+ return true;
3977
+ }
3978
+ try {
3979
+ db.query(query.sql, query.params);
3980
+ } catch (err) {
3981
+ onTransportError?.({
3982
+ stage: "send",
3983
+ error: err instanceof Error ? err : new Error(String(err)),
3984
+ value
3985
+ });
3986
+ }
3987
+ return true;
3988
+ }
3989
+ return false;
3990
+ }
3991
+ });
3992
+ return inner.subscribe(() => {
3993
+ });
3994
+ }
3924
3995
 
3925
3996
  // src/extra/backpressure.ts
3926
3997
  var nextLockId = 0;
@@ -7612,6 +7683,7 @@ function workerSelf(target, opts) {
7612
7683
  fromPulsar,
7613
7684
  fromRabbitMQ,
7614
7685
  fromRedisStream,
7686
+ fromSqlite,
7615
7687
  fromStatsD,
7616
7688
  fromSyslog,
7617
7689
  fromTimer,
@@ -7689,6 +7761,7 @@ function workerSelf(target, opts) {
7689
7761
  toRedisStream,
7690
7762
  toS3,
7691
7763
  toSSE,
7764
+ toSqlite,
7692
7765
  toTempo,
7693
7766
  toWebSocket,
7694
7767
  tokenBucket,