Scalable and distributed custom feed generator, ott - on that topic

Add uri extractor smartmodule

+3
smart-modules/contruct-post-uri/.gitignore
··· 1 + /target 2 + /.hub 3 + .DS_Store
+486
smart-modules/contruct-post-uri/Cargo.lock
··· 1 + # This file is automatically @generated by Cargo. 2 + # It is not intended for manual editing. 3 + version = 4 4 + 5 + [[package]] 6 + name = "bytes" 7 + version = "1.10.1" 8 + source = "registry+https://github.com/rust-lang/crates.io-index" 9 + checksum = "d71b6127be86fdcfddb610f7182ac57211d4b18a3e9c82eb2d17662f2227ad6a" 10 + 11 + [[package]] 12 + name = "cfg-if" 13 + version = "1.0.3" 14 + source = "registry+https://github.com/rust-lang/crates.io-index" 15 + checksum = "2fd1289c04a9ea8cb22300a459a72a385d7c73d3259e2ed7dcb2af674838cfa9" 16 + 17 + [[package]] 18 + name = "content_inspector" 19 + version = "0.2.4" 20 + source = "registry+https://github.com/rust-lang/crates.io-index" 21 + checksum = "b7bda66e858c683005a53a9a60c69a4aca7eeaa45d124526e389f7aec8e62f38" 22 + dependencies = [ 23 + "memchr", 24 + ] 25 + 26 + [[package]] 27 + name = "contruct-post-uri" 28 + version = "0.1.0" 29 + dependencies = [ 30 + "eyre", 31 + "fluvio-smartmodule", 32 + "serde", 33 + "serde_json", 34 + ] 35 + 36 + [[package]] 37 + name = "crc32c" 38 + version = "0.6.8" 39 + source = "registry+https://github.com/rust-lang/crates.io-index" 40 + checksum = "3a47af21622d091a8f0fb295b88bc886ac74efcc613efc19f5d0b21de5c89e47" 41 + dependencies = [ 42 + "rustc_version", 43 + ] 44 + 45 + [[package]] 46 + name = "dyn-clone" 47 + version = "1.0.20" 48 + source = "registry+https://github.com/rust-lang/crates.io-index" 49 + checksum = "d0881ea181b1df73ff77ffaaf9c7544ecc11e82fba9b5f27b262a3c73a332555" 50 + 51 + [[package]] 52 + name = "equivalent" 53 + version = "1.0.2" 54 + source = "registry+https://github.com/rust-lang/crates.io-index" 55 + checksum = "877a4ace8713b0bcf2a4e7eec82529c029f1d0619886d18145fea96c3ffe5c0f" 56 + 57 + [[package]] 58 + name = "eyre" 59 + version = "0.6.12" 60 + source = "registry+https://github.com/rust-lang/crates.io-index" 61 + checksum = "7cd915d99f24784cdc19fd37ef22b97e3ff0ae756c7e492e9fbfe897d61e2aec" 62 + dependencies = [ 63 + "indenter", 64 + "once_cell", 65 + ] 66 + 67 + [[package]] 68 + name = "fluvio-compression" 69 + version = "0.50.1" 70 + source = "registry+https://github.com/rust-lang/crates.io-index" 71 + checksum = "eac2a78ba630aaba295f925bede1aa55ab7685f81d62372e18c7228381dec0b0" 72 + dependencies = [ 73 + "bytes", 74 + "fluvio-types", 75 + "serde", 76 + "thiserror", 77 + ] 78 + 79 + [[package]] 80 + name = "fluvio-protocol" 81 + version = "0.50.1" 82 + source = "registry+https://github.com/rust-lang/crates.io-index" 83 + checksum = "67fdc736c98b204aeac7b2416af7f7589afd76da12799c941a17cf39a8061cb0" 84 + dependencies = [ 85 + "bytes", 86 + "cfg-if", 87 + "content_inspector", 88 + "crc32c", 89 + "eyre", 90 + "fluvio-compression", 91 + "fluvio-protocol-derive", 92 + "fluvio-types", 93 + "flv-util", 94 + "once_cell", 95 + "semver", 96 + "thiserror", 97 + "tracing", 98 + ] 99 + 100 + [[package]] 101 + name = "fluvio-protocol-derive" 102 + version = "0.50.1" 103 + source = "registry+https://github.com/rust-lang/crates.io-index" 104 + checksum = "02d16052eeee04bcb6d68cf9e565cc504e7c2d69a4e758f9844974a8d3d1f0aa" 105 + dependencies = [ 106 + "proc-macro2", 107 + "quote", 108 + "syn 1.0.109", 109 + "tracing", 110 + ] 111 + 112 + [[package]] 113 + name = "fluvio-smartmodule" 114 + version = "0.50.1" 115 + source = "registry+https://github.com/rust-lang/crates.io-index" 116 + checksum = "9dc29b7f867ac122f393fc1f39f5e14bd77cd874febdeb136d8309901e69a4a3" 117 + dependencies = [ 118 + "eyre", 119 + "fluvio-protocol", 120 + "fluvio-smartmodule-derive", 121 + "thiserror", 122 + "tracing", 123 + ] 124 + 125 + [[package]] 126 + name = "fluvio-smartmodule-derive" 127 + version = "0.50.1" 128 + source = "registry+https://github.com/rust-lang/crates.io-index" 129 + checksum = "35af0ba75ba657d41252e0417cc5424e5dbf174c4ccdf59b8347d428ff6e9f46" 130 + dependencies = [ 131 + "proc-macro2", 132 + "quote", 133 + "syn 2.0.106", 134 + ] 135 + 136 + [[package]] 137 + name = "fluvio-types" 138 + version = "0.50.1" 139 + source = "registry+https://github.com/rust-lang/crates.io-index" 140 + checksum = "abe5675758c2ae542f6c2c64cca1f187b26c22708c2a7358d6454dd9c6d8561d" 141 + dependencies = [ 142 + "schemars", 143 + "serde", 144 + "thiserror", 145 + "toml", 146 + "tracing", 147 + ] 148 + 149 + [[package]] 150 + name = "flv-util" 151 + version = "0.5.2" 152 + source = "registry+https://github.com/rust-lang/crates.io-index" 153 + checksum = "de89447c8b4aecfa4c0614d1a7be1c6ab4a0266b59bb2713fd746901f28d124e" 154 + dependencies = [ 155 + "log", 156 + "tracing", 157 + ] 158 + 159 + [[package]] 160 + name = "hashbrown" 161 + version = "0.16.0" 162 + source = "registry+https://github.com/rust-lang/crates.io-index" 163 + checksum = "5419bdc4f6a9207fbeba6d11b604d481addf78ecd10c11ad51e76c2f6482748d" 164 + 165 + [[package]] 166 + name = "indenter" 167 + version = "0.3.4" 168 + source = "registry+https://github.com/rust-lang/crates.io-index" 169 + checksum = "964de6e86d545b246d84badc0fef527924ace5134f30641c203ef52ba83f58d5" 170 + 171 + [[package]] 172 + name = "indexmap" 173 + version = "2.11.4" 174 + source = "registry+https://github.com/rust-lang/crates.io-index" 175 + checksum = "4b0f83760fb341a774ed326568e19f5a863af4a952def8c39f9ab92fd95b88e5" 176 + dependencies = [ 177 + "equivalent", 178 + "hashbrown", 179 + ] 180 + 181 + [[package]] 182 + name = "itoa" 183 + version = "1.0.15" 184 + source = "registry+https://github.com/rust-lang/crates.io-index" 185 + checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c" 186 + 187 + [[package]] 188 + name = "log" 189 + version = "0.4.28" 190 + source = "registry+https://github.com/rust-lang/crates.io-index" 191 + checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432" 192 + 193 + [[package]] 194 + name = "memchr" 195 + version = "2.7.6" 196 + source = "registry+https://github.com/rust-lang/crates.io-index" 197 + checksum = "f52b00d39961fc5b2736ea853c9cc86238e165017a493d1d5c8eac6bdc4cc273" 198 + 199 + [[package]] 200 + name = "once_cell" 201 + version = "1.21.3" 202 + source = "registry+https://github.com/rust-lang/crates.io-index" 203 + checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d" 204 + 205 + [[package]] 206 + name = "pin-project-lite" 207 + version = "0.2.16" 208 + source = "registry+https://github.com/rust-lang/crates.io-index" 209 + checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b" 210 + 211 + [[package]] 212 + name = "proc-macro2" 213 + version = "1.0.101" 214 + source = "registry+https://github.com/rust-lang/crates.io-index" 215 + checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de" 216 + dependencies = [ 217 + "unicode-ident", 218 + ] 219 + 220 + [[package]] 221 + name = "quote" 222 + version = "1.0.41" 223 + source = "registry+https://github.com/rust-lang/crates.io-index" 224 + checksum = "ce25767e7b499d1b604768e7cde645d14cc8584231ea6b295e9c9eb22c02e1d1" 225 + dependencies = [ 226 + "proc-macro2", 227 + ] 228 + 229 + [[package]] 230 + name = "ref-cast" 231 + version = "1.0.25" 232 + source = "registry+https://github.com/rust-lang/crates.io-index" 233 + checksum = "f354300ae66f76f1c85c5f84693f0ce81d747e2c3f21a45fef496d89c960bf7d" 234 + dependencies = [ 235 + "ref-cast-impl", 236 + ] 237 + 238 + [[package]] 239 + name = "ref-cast-impl" 240 + version = "1.0.25" 241 + source = "registry+https://github.com/rust-lang/crates.io-index" 242 + checksum = "b7186006dcb21920990093f30e3dea63b7d6e977bf1256be20c3563a5db070da" 243 + dependencies = [ 244 + "proc-macro2", 245 + "quote", 246 + "syn 2.0.106", 247 + ] 248 + 249 + [[package]] 250 + name = "rustc_version" 251 + version = "0.4.1" 252 + source = "registry+https://github.com/rust-lang/crates.io-index" 253 + checksum = "cfcb3a22ef46e85b45de6ee7e79d063319ebb6594faafcf1c225ea92ab6e9b92" 254 + dependencies = [ 255 + "semver", 256 + ] 257 + 258 + [[package]] 259 + name = "ryu" 260 + version = "1.0.20" 261 + source = "registry+https://github.com/rust-lang/crates.io-index" 262 + checksum = "28d3b2b1366ec20994f1fd18c3c594f05c5dd4bc44d8bb0c1c632c8d6829481f" 263 + 264 + [[package]] 265 + name = "schemars" 266 + version = "1.0.4" 267 + source = "registry+https://github.com/rust-lang/crates.io-index" 268 + checksum = "82d20c4491bc164fa2f6c5d44565947a52ad80b9505d8e36f8d54c27c739fcd0" 269 + dependencies = [ 270 + "dyn-clone", 271 + "ref-cast", 272 + "schemars_derive", 273 + "serde", 274 + "serde_json", 275 + ] 276 + 277 + [[package]] 278 + name = "schemars_derive" 279 + version = "1.0.4" 280 + source = "registry+https://github.com/rust-lang/crates.io-index" 281 + checksum = "33d020396d1d138dc19f1165df7545479dcd58d93810dc5d646a16e55abefa80" 282 + dependencies = [ 283 + "proc-macro2", 284 + "quote", 285 + "serde_derive_internals", 286 + "syn 2.0.106", 287 + ] 288 + 289 + [[package]] 290 + name = "semver" 291 + version = "1.0.27" 292 + source = "registry+https://github.com/rust-lang/crates.io-index" 293 + checksum = "d767eb0aabc880b29956c35734170f26ed551a859dbd361d140cdbeca61ab1e2" 294 + 295 + [[package]] 296 + name = "serde" 297 + version = "1.0.228" 298 + source = "registry+https://github.com/rust-lang/crates.io-index" 299 + checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e" 300 + dependencies = [ 301 + "serde_core", 302 + "serde_derive", 303 + ] 304 + 305 + [[package]] 306 + name = "serde_core" 307 + version = "1.0.228" 308 + source = "registry+https://github.com/rust-lang/crates.io-index" 309 + checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad" 310 + dependencies = [ 311 + "serde_derive", 312 + ] 313 + 314 + [[package]] 315 + name = "serde_derive" 316 + version = "1.0.228" 317 + source = "registry+https://github.com/rust-lang/crates.io-index" 318 + checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79" 319 + dependencies = [ 320 + "proc-macro2", 321 + "quote", 322 + "syn 2.0.106", 323 + ] 324 + 325 + [[package]] 326 + name = "serde_derive_internals" 327 + version = "0.29.1" 328 + source = "registry+https://github.com/rust-lang/crates.io-index" 329 + checksum = "18d26a20a969b9e3fdf2fc2d9f21eda6c40e2de84c9408bb5d3b05d499aae711" 330 + dependencies = [ 331 + "proc-macro2", 332 + "quote", 333 + "syn 2.0.106", 334 + ] 335 + 336 + [[package]] 337 + name = "serde_json" 338 + version = "1.0.145" 339 + source = "registry+https://github.com/rust-lang/crates.io-index" 340 + checksum = "402a6f66d8c709116cf22f558eab210f5a50187f702eb4d7e5ef38d9a7f1c79c" 341 + dependencies = [ 342 + "itoa", 343 + "memchr", 344 + "ryu", 345 + "serde", 346 + "serde_core", 347 + ] 348 + 349 + [[package]] 350 + name = "serde_spanned" 351 + version = "0.6.9" 352 + source = "registry+https://github.com/rust-lang/crates.io-index" 353 + checksum = "bf41e0cfaf7226dca15e8197172c295a782857fcb97fad1808a166870dee75a3" 354 + dependencies = [ 355 + "serde", 356 + ] 357 + 358 + [[package]] 359 + name = "syn" 360 + version = "1.0.109" 361 + source = "registry+https://github.com/rust-lang/crates.io-index" 362 + checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" 363 + dependencies = [ 364 + "proc-macro2", 365 + "quote", 366 + "unicode-ident", 367 + ] 368 + 369 + [[package]] 370 + name = "syn" 371 + version = "2.0.106" 372 + source = "registry+https://github.com/rust-lang/crates.io-index" 373 + checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6" 374 + dependencies = [ 375 + "proc-macro2", 376 + "quote", 377 + "unicode-ident", 378 + ] 379 + 380 + [[package]] 381 + name = "thiserror" 382 + version = "2.0.17" 383 + source = "registry+https://github.com/rust-lang/crates.io-index" 384 + checksum = "f63587ca0f12b72a0600bcba1d40081f830876000bb46dd2337a3051618f4fc8" 385 + dependencies = [ 386 + "thiserror-impl", 387 + ] 388 + 389 + [[package]] 390 + name = "thiserror-impl" 391 + version = "2.0.17" 392 + source = "registry+https://github.com/rust-lang/crates.io-index" 393 + checksum = "3ff15c8ecd7de3849db632e14d18d2571fa09dfc5ed93479bc4485c7a517c913" 394 + dependencies = [ 395 + "proc-macro2", 396 + "quote", 397 + "syn 2.0.106", 398 + ] 399 + 400 + [[package]] 401 + name = "toml" 402 + version = "0.8.23" 403 + source = "registry+https://github.com/rust-lang/crates.io-index" 404 + checksum = "dc1beb996b9d83529a9e75c17a1686767d148d70663143c7854d8b4a09ced362" 405 + dependencies = [ 406 + "indexmap", 407 + "serde", 408 + "serde_spanned", 409 + "toml_datetime", 410 + "toml_edit", 411 + ] 412 + 413 + [[package]] 414 + name = "toml_datetime" 415 + version = "0.6.11" 416 + source = "registry+https://github.com/rust-lang/crates.io-index" 417 + checksum = "22cddaf88f4fbc13c51aebbf5f8eceb5c7c5a9da2ac40a13519eb5b0a0e8f11c" 418 + dependencies = [ 419 + "serde", 420 + ] 421 + 422 + [[package]] 423 + name = "toml_edit" 424 + version = "0.22.27" 425 + source = "registry+https://github.com/rust-lang/crates.io-index" 426 + checksum = "41fe8c660ae4257887cf66394862d21dbca4a6ddd26f04a3560410406a2f819a" 427 + dependencies = [ 428 + "indexmap", 429 + "serde", 430 + "serde_spanned", 431 + "toml_datetime", 432 + "toml_write", 433 + "winnow", 434 + ] 435 + 436 + [[package]] 437 + name = "toml_write" 438 + version = "0.1.2" 439 + source = "registry+https://github.com/rust-lang/crates.io-index" 440 + checksum = "5d99f8c9a7727884afe522e9bd5edbfc91a3312b36a77b5fb8926e4c31a41801" 441 + 442 + [[package]] 443 + name = "tracing" 444 + version = "0.1.41" 445 + source = "registry+https://github.com/rust-lang/crates.io-index" 446 + checksum = "784e0ac535deb450455cbfa28a6f0df145ea1bb7ae51b821cf5e7927fdcfbdd0" 447 + dependencies = [ 448 + "pin-project-lite", 449 + "tracing-attributes", 450 + "tracing-core", 451 + ] 452 + 453 + [[package]] 454 + name = "tracing-attributes" 455 + version = "0.1.30" 456 + source = "registry+https://github.com/rust-lang/crates.io-index" 457 + checksum = "81383ab64e72a7a8b8e13130c49e3dab29def6d0c7d76a03087b3cf71c5c6903" 458 + dependencies = [ 459 + "proc-macro2", 460 + "quote", 461 + "syn 2.0.106", 462 + ] 463 + 464 + [[package]] 465 + name = "tracing-core" 466 + version = "0.1.34" 467 + source = "registry+https://github.com/rust-lang/crates.io-index" 468 + checksum = "b9d12581f227e93f094d3af2ae690a574abb8a2b9b7a96e7cfe9647b2b617678" 469 + dependencies = [ 470 + "once_cell", 471 + ] 472 + 473 + [[package]] 474 + name = "unicode-ident" 475 + version = "1.0.19" 476 + source = "registry+https://github.com/rust-lang/crates.io-index" 477 + checksum = "f63a545481291138910575129486daeaf8ac54aee4387fe7906919f7830c7d9d" 478 + 479 + [[package]] 480 + name = "winnow" 481 + version = "0.7.13" 482 + source = "registry+https://github.com/rust-lang/crates.io-index" 483 + checksum = "21a0236b59786fed61e2a80582dd500fe61f18b5dca67a4a067d0bc9039339cf" 484 + dependencies = [ 485 + "memchr", 486 + ]
+20
smart-modules/contruct-post-uri/Cargo.toml
··· 1 + [package] 2 + name = "contruct-post-uri" 3 + version = "0.1.0" 4 + authors = ["Alex Evert <alex.evert@eghed.se>"] 5 + edition = "2024" 6 + 7 + [lib] 8 + crate-type = ['cdylib'] 9 + 10 + [dependencies] 11 + eyre = "0.6.12" 12 + fluvio-smartmodule = "0.50.1" 13 + serde = { version = "1", features = ["derive"] } 14 + serde_json = "1" 15 + 16 + 17 + [profile.release-lto] 18 + inherits = "release" 19 + lto = true 20 + strip = "symbols"
+4
smart-modules/contruct-post-uri/README.md
··· 1 + # Construct post uri 2 + 3 + Small smart module that takes a atproto record and adds the uri as 4 + a toplevel field called 'uri'
+8
smart-modules/contruct-post-uri/SmartModule.toml
··· 1 + [package] 2 + name = "contruct-post-uri" 3 + group = "aleeve" 4 + version = "0.1.0" 5 + apiVersion = "0.1.0" 6 + description = "" 7 + license = "Apache-2.0" 8 + visibility = "private"
+30
smart-modules/contruct-post-uri/example.json
··· 1 + { 2 + "did": "did:plc:23eugfl5qkv67xln44keke3l", 3 + "time_us": 1759348166016963, 4 + "kind": "commit", 5 + "commit": { 6 + "rev": "3m25spbh4gf2a", 7 + "operation": "create", 8 + "collection": "app.bsky.feed.post", 9 + "rkey": "3m25spaetqc2q", 10 + "record": { 11 + "$type": "app.bsky.feed.post", 12 + "createdAt": "2025-10-01T19:49:24.749Z", 13 + "langs": [ 14 + "en" 15 + ], 16 + "reply": { 17 + "parent": { 18 + "cid": "bafyreihkl7txnmufbr6rsts4amqimeyks3k5tn3p5kov5d7ffggf3aa3em", 19 + "uri": "at://did:plc:4kgmeckzmywlrgz6z4tet3mm/app.bsky.feed.post/3m25ryuhqw22b" 20 + }, 21 + "root": { 22 + "cid": "bafyreihmvowtsqzqkzdgq64vuvbmm5h4n464gwo3iayotbqmpjuwlim6ay", 23 + "uri": "at://did:plc:23eugfl5qkv67xln44keke3l/app.bsky.feed.post/3m25q2cvuac27" 24 + } 25 + }, 26 + "text": "Nope. I use it when kidnapping peeps to play games! x3" 27 + }, 28 + "cid": "bafyreifrbik5jhqhpnrjjni6ziee5knzrfawxgg5fbrepajgzi4whlq7zq" 29 + } 30 + }
+3
smart-modules/contruct-post-uri/rust-toolchain.toml
··· 1 + [toolchain] 2 + channel = "stable" 3 + targets = ["wasm32-unknown-unknown", "wasm32-wasip1"]
+42
smart-modules/contruct-post-uri/src/lib.rs
··· 1 + use eyre::eyre; 2 + use fluvio_smartmodule::{RecordData, Result, SmartModuleRecord, smartmodule}; 3 + use serde_json::{Map, Value}; 4 + use std::str::FromStr; 5 + 6 + #[smartmodule(map)] 7 + pub fn map(record: &SmartModuleRecord) -> Result<(Option<RecordData>, RecordData)> { 8 + let key = record.key.clone(); 9 + 10 + let string = std::str::from_utf8(record.value.as_ref())?; 11 + let mut value: Value = serde_json::from_str(string)?; 12 + let obj = value 13 + .as_object_mut() 14 + .ok_or(eyre!("Failed to parse value"))?; 15 + 16 + let uri = get_uri(obj)?; 17 + let uri_value = Value::String(uri); 18 + obj.insert("uri".to_string(), uri_value); 19 + 20 + Ok((key, value.to_string().as_str().into())) 21 + } 22 + 23 + fn get_uri(obj: &Map<String, Value>) -> Result<String> { 24 + let did = obj 25 + .get("did") 26 + .and_then(|v| v.as_str()) 27 + .ok_or(eyre!("did missing or not a string"))?; 28 + 29 + let commit = obj.get("commit").ok_or(eyre!("commit missing"))?; 30 + 31 + let collection = commit 32 + .get("collection") 33 + .and_then(|v| v.as_str()) 34 + .ok_or(eyre!("commit.collection missing or not a string"))?; 35 + 36 + let rkey = commit 37 + .get("rkey") 38 + .and_then(|v| v.as_str()) 39 + .ok_or(eyre!("commit.rkey missing or not a string"))?; 40 + 41 + Ok(format!("at://{did}/{collection}/{rkey}")) 42 + }