mirror of
https://iceshrimp.dev/crimekillz/iceshrimp-161sh.git
synced 2024-11-21 19:53:50 +01:00
Port native-utils code back to typescript
This commit is contained in:
parent
259f82f251
commit
76aa8eeefb
BIN
.yarn/cache/@napi-rs-cli-npm-2.16.1-620418cc90-5f61712cf1.zip
(Stored with Git LFS)
vendored
BIN
.yarn/cache/@napi-rs-cli-npm-2.16.1-620418cc90-5f61712cf1.zip
(Stored with Git LFS)
vendored
Binary file not shown.
@ -1,3 +0,0 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
|
||||||
oid sha256:2568f59553176da87046b261c2d01823863a39c683ada59c050bf8b570ce5548
|
|
||||||
size 1700912
|
|
BIN
.yarn/cache/@noble-hashes-npm-1.3.2-1e619f9da0-fe23536b43.zip
(Stored with Git LFS)
vendored
Normal file
BIN
.yarn/cache/@noble-hashes-npm-1.3.2-1e619f9da0-fe23536b43.zip
(Stored with Git LFS)
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/@paralleldrive-cuid2-npm-2.2.2-e6061749b2-f7f6ac70e0.zip
(Stored with Git LFS)
vendored
Normal file
BIN
.yarn/cache/@paralleldrive-cuid2-npm-2.2.2-e6061749b2-f7f6ac70e0.zip
(Stored with Git LFS)
vendored
Normal file
Binary file not shown.
BIN
.yarn/cache/aggregate-error-npm-4.0.1-12d0501fb7-bb3ffdfd13.zip
(Stored with Git LFS)
vendored
BIN
.yarn/cache/aggregate-error-npm-4.0.1-12d0501fb7-bb3ffdfd13.zip
(Stored with Git LFS)
vendored
Binary file not shown.
BIN
.yarn/cache/array-find-index-npm-1.0.2-a7d5fbff35-aac128bf36.zip
(Stored with Git LFS)
vendored
BIN
.yarn/cache/array-find-index-npm-1.0.2-a7d5fbff35-aac128bf36.zip
(Stored with Git LFS)
vendored
Binary file not shown.
BIN
.yarn/cache/arrgv-npm-1.0.2-2f5078bb50-470bbb406e.zip
(Stored with Git LFS)
vendored
BIN
.yarn/cache/arrgv-npm-1.0.2-2f5078bb50-470bbb406e.zip
(Stored with Git LFS)
vendored
Binary file not shown.
@ -1,3 +0,0 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
|
||||||
oid sha256:ccd80bba10716f4ee729cab853853857db31f05340fafefe1c81df44138e677f
|
|
||||||
size 2808
|
|
BIN
.yarn/cache/ava-npm-5.1.1-31c6d17423-cae5771ea6.zip
(Stored with Git LFS)
vendored
BIN
.yarn/cache/ava-npm-5.1.1-31c6d17423-cae5771ea6.zip
(Stored with Git LFS)
vendored
Binary file not shown.
BIN
.yarn/cache/blueimp-md5-npm-2.19.0-0a19585c8c-28095dcbd2.zip
(Stored with Git LFS)
vendored
BIN
.yarn/cache/blueimp-md5-npm-2.19.0-0a19585c8c-28095dcbd2.zip
(Stored with Git LFS)
vendored
Binary file not shown.
BIN
.yarn/cache/callsites-npm-4.0.0-a9fc778262-ad3c3a5732.zip
(Stored with Git LFS)
vendored
BIN
.yarn/cache/callsites-npm-4.0.0-a9fc778262-ad3c3a5732.zip
(Stored with Git LFS)
vendored
Binary file not shown.
BIN
.yarn/cache/chunkd-npm-2.0.1-2a1d1afad0-bab8cc08c7.zip
(Stored with Git LFS)
vendored
BIN
.yarn/cache/chunkd-npm-2.0.1-2a1d1afad0-bab8cc08c7.zip
(Stored with Git LFS)
vendored
Binary file not shown.
BIN
.yarn/cache/ci-parallel-vars-npm-1.0.1-27c813d568-ae859831f7.zip
(Stored with Git LFS)
vendored
BIN
.yarn/cache/ci-parallel-vars-npm-1.0.1-27c813d568-ae859831f7.zip
(Stored with Git LFS)
vendored
Binary file not shown.
BIN
.yarn/cache/clean-stack-npm-4.2.0-bb0dff47b2-373f656a31.zip
(Stored with Git LFS)
vendored
BIN
.yarn/cache/clean-stack-npm-4.2.0-bb0dff47b2-373f656a31.zip
(Stored with Git LFS)
vendored
Binary file not shown.
@ -1,3 +0,0 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
|
||||||
oid sha256:b42879f3ead93e5de48fed4ccaab3b4e1e568ac1cabf748fda707ab77f961fc0
|
|
||||||
size 3556
|
|
BIN
.yarn/cache/cli-truncate-npm-3.1.0-654d2989ef-c3243e4197.zip
(Stored with Git LFS)
vendored
BIN
.yarn/cache/cli-truncate-npm-3.1.0-654d2989ef-c3243e4197.zip
(Stored with Git LFS)
vendored
Binary file not shown.
BIN
.yarn/cache/code-excerpt-npm-4.0.0-f453325e6e-d57137d8f4.zip
(Stored with Git LFS)
vendored
BIN
.yarn/cache/code-excerpt-npm-4.0.0-f453325e6e-d57137d8f4.zip
(Stored with Git LFS)
vendored
Binary file not shown.
@ -1,3 +0,0 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
|
||||||
oid sha256:79634527e1bff85656fd8f2e772dea86a3df43b68a4ab1522a89a18a059bbadd
|
|
||||||
size 2957
|
|
BIN
.yarn/cache/concordance-npm-5.0.4-e641405dd9-749153ba71.zip
(Stored with Git LFS)
vendored
BIN
.yarn/cache/concordance-npm-5.0.4-e641405dd9-749153ba71.zip
(Stored with Git LFS)
vendored
Binary file not shown.
BIN
.yarn/cache/convert-to-spaces-npm-2.0.1-c08fae1ac6-bbb324e591.zip
(Stored with Git LFS)
vendored
BIN
.yarn/cache/convert-to-spaces-npm-2.0.1-c08fae1ac6-bbb324e591.zip
(Stored with Git LFS)
vendored
Binary file not shown.
BIN
.yarn/cache/currently-unhandled-npm-0.4.1-38eddab665-1f59fe10b5.zip
(Stored with Git LFS)
vendored
BIN
.yarn/cache/currently-unhandled-npm-0.4.1-38eddab665-1f59fe10b5.zip
(Stored with Git LFS)
vendored
Binary file not shown.
BIN
.yarn/cache/date-time-npm-3.1.0-50f6af7aef-f9cfcd1b15.zip
(Stored with Git LFS)
vendored
BIN
.yarn/cache/date-time-npm-3.1.0-50f6af7aef-f9cfcd1b15.zip
(Stored with Git LFS)
vendored
Binary file not shown.
BIN
.yarn/cache/del-npm-7.0.0-c407e052bc-33e5077f18.zip
(Stored with Git LFS)
vendored
BIN
.yarn/cache/del-npm-7.0.0-c407e052bc-33e5077f18.zip
(Stored with Git LFS)
vendored
Binary file not shown.
BIN
.yarn/cache/emittery-npm-1.0.1-3e4e6ba9b5-d95faee6ff.zip
(Stored with Git LFS)
vendored
BIN
.yarn/cache/emittery-npm-1.0.1-3e4e6ba9b5-d95faee6ff.zip
(Stored with Git LFS)
vendored
Binary file not shown.
@ -1,3 +0,0 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
|
||||||
oid sha256:2e806cf92dba645ebd9fa9e4b38d024fa7aa63e862d1df8737fcb6f5391bda99
|
|
||||||
size 8758
|
|
BIN
.yarn/cache/find-up-npm-6.3.0-e5056fc655-9a21b7f924.zip
(Stored with Git LFS)
vendored
BIN
.yarn/cache/find-up-npm-6.3.0-e5056fc655-9a21b7f924.zip
(Stored with Git LFS)
vendored
Binary file not shown.
@ -1,3 +0,0 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
|
||||||
oid sha256:514f3b56e094d421edc9604c49956bf28e56c5f270d360012c5ac7ced5889b72
|
|
||||||
size 9535
|
|
BIN
.yarn/cache/ignore-by-default-npm-2.1.0-996694cc00-2b2df4622b.zip
(Stored with Git LFS)
vendored
BIN
.yarn/cache/ignore-by-default-npm-2.1.0-996694cc00-2b2df4622b.zip
(Stored with Git LFS)
vendored
Binary file not shown.
BIN
.yarn/cache/indent-string-npm-5.0.0-35eaa3b052-e466c27b63.zip
(Stored with Git LFS)
vendored
BIN
.yarn/cache/indent-string-npm-5.0.0-35eaa3b052-e466c27b63.zip
(Stored with Git LFS)
vendored
Binary file not shown.
@ -1,3 +0,0 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
|
||||||
oid sha256:6657cbf87afc1b6b958a04c5ac96b4a997605a8e29b5b64b6411bc87c09c52c1
|
|
||||||
size 4020
|
|
BIN
.yarn/cache/is-fullwidth-code-point-npm-4.0.0-848488b60d-8ae89bf505.zip
(Stored with Git LFS)
vendored
BIN
.yarn/cache/is-fullwidth-code-point-npm-4.0.0-848488b60d-8ae89bf505.zip
(Stored with Git LFS)
vendored
Binary file not shown.
@ -1,3 +0,0 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
|
||||||
oid sha256:b964ac328d44968d706dc03590dfdabfeb89747b7fa0306ea4c1f13269f7ceca
|
|
||||||
size 2807
|
|
BIN
.yarn/cache/is-path-inside-npm-4.0.0-2af2bde69d-8810fa11c5.zip
(Stored with Git LFS)
vendored
BIN
.yarn/cache/is-path-inside-npm-4.0.0-2af2bde69d-8810fa11c5.zip
(Stored with Git LFS)
vendored
Binary file not shown.
BIN
.yarn/cache/is-promise-npm-4.0.0-1e3c05420c-0b46517ad4.zip
(Stored with Git LFS)
vendored
BIN
.yarn/cache/is-promise-npm-4.0.0-1e3c05420c-0b46517ad4.zip
(Stored with Git LFS)
vendored
Binary file not shown.
BIN
.yarn/cache/is-unicode-supported-npm-1.3.0-9371ea1eda-20a1fc161a.zip
(Stored with Git LFS)
vendored
BIN
.yarn/cache/is-unicode-supported-npm-1.3.0-9371ea1eda-20a1fc161a.zip
(Stored with Git LFS)
vendored
Binary file not shown.
BIN
.yarn/cache/js-string-escape-npm-1.0.1-8b8d76add3-f11e0991bf.zip
(Stored with Git LFS)
vendored
BIN
.yarn/cache/js-string-escape-npm-1.0.1-8b8d76add3-f11e0991bf.zip
(Stored with Git LFS)
vendored
Binary file not shown.
@ -1,3 +0,0 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
|
||||||
oid sha256:a7d8296b9b77252b4ca251cdf96d53a8adcc19d39ef09eeb04c1eb7b95f70d4c
|
|
||||||
size 3751
|
|
BIN
.yarn/cache/locate-path-npm-7.2.0-0e1169e19b-c1b653bdf2.zip
(Stored with Git LFS)
vendored
BIN
.yarn/cache/locate-path-npm-7.2.0-0e1169e19b-c1b653bdf2.zip
(Stored with Git LFS)
vendored
Binary file not shown.
BIN
.yarn/cache/map-age-cleaner-npm-0.1.3-fd9e4b4aff-cb2804a5bc.zip
(Stored with Git LFS)
vendored
BIN
.yarn/cache/map-age-cleaner-npm-0.1.3-fd9e4b4aff-cb2804a5bc.zip
(Stored with Git LFS)
vendored
Binary file not shown.
BIN
.yarn/cache/matcher-npm-5.0.0-426d06a4f6-28f191c2d2.zip
(Stored with Git LFS)
vendored
BIN
.yarn/cache/matcher-npm-5.0.0-426d06a4f6-28f191c2d2.zip
(Stored with Git LFS)
vendored
Binary file not shown.
BIN
.yarn/cache/md5-hex-npm-3.0.1-d9f5f267ed-6799a19e8b.zip
(Stored with Git LFS)
vendored
BIN
.yarn/cache/md5-hex-npm-3.0.1-d9f5f267ed-6799a19e8b.zip
(Stored with Git LFS)
vendored
Binary file not shown.
BIN
.yarn/cache/mem-npm-9.0.2-9614a03e64-07829bb182.zip
(Stored with Git LFS)
vendored
BIN
.yarn/cache/mem-npm-9.0.2-9614a03e64-07829bb182.zip
(Stored with Git LFS)
vendored
Binary file not shown.
BIN
.yarn/cache/p-defer-npm-1.0.0-4dfd0013f5-4271b935c2.zip
(Stored with Git LFS)
vendored
BIN
.yarn/cache/p-defer-npm-1.0.0-4dfd0013f5-4271b935c2.zip
(Stored with Git LFS)
vendored
Binary file not shown.
BIN
.yarn/cache/p-event-npm-5.0.1-1f7dfbcfb3-3bdd8df609.zip
(Stored with Git LFS)
vendored
BIN
.yarn/cache/p-event-npm-5.0.1-1f7dfbcfb3-3bdd8df609.zip
(Stored with Git LFS)
vendored
Binary file not shown.
BIN
.yarn/cache/p-limit-npm-4.0.0-5dccf29b67-01d9d70695.zip
(Stored with Git LFS)
vendored
BIN
.yarn/cache/p-limit-npm-4.0.0-5dccf29b67-01d9d70695.zip
(Stored with Git LFS)
vendored
Binary file not shown.
BIN
.yarn/cache/p-locate-npm-6.0.0-b6cfb720dc-2bfe5234ef.zip
(Stored with Git LFS)
vendored
BIN
.yarn/cache/p-locate-npm-6.0.0-b6cfb720dc-2bfe5234ef.zip
(Stored with Git LFS)
vendored
Binary file not shown.
BIN
.yarn/cache/p-map-npm-5.5.0-9758eb14ee-065cb6fca6.zip
(Stored with Git LFS)
vendored
BIN
.yarn/cache/p-map-npm-5.5.0-9758eb14ee-065cb6fca6.zip
(Stored with Git LFS)
vendored
Binary file not shown.
BIN
.yarn/cache/p-timeout-npm-5.1.0-11ca554b60-f5cd4e1730.zip
(Stored with Git LFS)
vendored
BIN
.yarn/cache/p-timeout-npm-5.1.0-11ca554b60-f5cd4e1730.zip
(Stored with Git LFS)
vendored
Binary file not shown.
BIN
.yarn/cache/parse-ms-npm-3.0.0-3acf02c3f3-fc602bba09.zip
(Stored with Git LFS)
vendored
BIN
.yarn/cache/parse-ms-npm-3.0.0-3acf02c3f3-fc602bba09.zip
(Stored with Git LFS)
vendored
Binary file not shown.
BIN
.yarn/cache/path-exists-npm-5.0.0-0bf403c56c-8ca842868c.zip
(Stored with Git LFS)
vendored
BIN
.yarn/cache/path-exists-npm-5.0.0-0bf403c56c-8ca842868c.zip
(Stored with Git LFS)
vendored
Binary file not shown.
@ -1,3 +0,0 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
|
||||||
oid sha256:253dbc0e41aae061d34578e9a249bb004f65fd81fb3a0d9e17d2e365ea4b4375
|
|
||||||
size 4533
|
|
BIN
.yarn/cache/plur-npm-5.1.0-a8abe6df1b-57e400dc4b.zip
(Stored with Git LFS)
vendored
BIN
.yarn/cache/plur-npm-5.1.0-a8abe6df1b-57e400dc4b.zip
(Stored with Git LFS)
vendored
Binary file not shown.
BIN
.yarn/cache/pretty-ms-npm-8.0.0-7a40e0b54a-b7d2a81828.zip
(Stored with Git LFS)
vendored
BIN
.yarn/cache/pretty-ms-npm-8.0.0-7a40e0b54a-b7d2a81828.zip
(Stored with Git LFS)
vendored
Binary file not shown.
BIN
.yarn/cache/serialize-error-npm-7.0.1-c0b3f881a0-e0aba4dca2.zip
(Stored with Git LFS)
vendored
BIN
.yarn/cache/serialize-error-npm-7.0.1-c0b3f881a0-e0aba4dca2.zip
(Stored with Git LFS)
vendored
Binary file not shown.
BIN
.yarn/cache/slash-npm-4.0.0-ce4bbc4a80-da8e4af737.zip
(Stored with Git LFS)
vendored
BIN
.yarn/cache/slash-npm-4.0.0-ce4bbc4a80-da8e4af737.zip
(Stored with Git LFS)
vendored
Binary file not shown.
@ -1,3 +0,0 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
|
||||||
oid sha256:abea04aaef5bdd25715ccc7aff81cf2c491c4836c35cdc70d10bd75d7b5a1851
|
|
||||||
size 3767
|
|
BIN
.yarn/cache/supertap-npm-3.0.1-d7c04bcbf0-ee3d71c1d2.zip
(Stored with Git LFS)
vendored
BIN
.yarn/cache/supertap-npm-3.0.1-d7c04bcbf0-ee3d71c1d2.zip
(Stored with Git LFS)
vendored
Binary file not shown.
BIN
.yarn/cache/temp-dir-npm-3.0.0-70414c7a63-577211e995.zip
(Stored with Git LFS)
vendored
BIN
.yarn/cache/temp-dir-npm-3.0.0-70414c7a63-577211e995.zip
(Stored with Git LFS)
vendored
Binary file not shown.
BIN
.yarn/cache/time-zone-npm-1.0.0-0522e3467f-e46f5a69b8.zip
(Stored with Git LFS)
vendored
BIN
.yarn/cache/time-zone-npm-1.0.0-0522e3467f-e46f5a69b8.zip
(Stored with Git LFS)
vendored
Binary file not shown.
BIN
.yarn/cache/type-fest-npm-0.13.1-7f4486b973-e6bf2e3c44.zip
(Stored with Git LFS)
vendored
BIN
.yarn/cache/type-fest-npm-0.13.1-7f4486b973-e6bf2e3c44.zip
(Stored with Git LFS)
vendored
Binary file not shown.
BIN
.yarn/cache/well-known-symbols-npm-2.0.0-16fb8dedc6-4f54bbc301.zip
(Stored with Git LFS)
vendored
BIN
.yarn/cache/well-known-symbols-npm-2.0.0-16fb8dedc6-4f54bbc301.zip
(Stored with Git LFS)
vendored
Binary file not shown.
@ -1,3 +0,0 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
|
||||||
oid sha256:8a84e5fcd2bb1bdd00cb25f5ba68da97f21c488991f089b3d5f09203b49636c5
|
|
||||||
size 5454
|
|
@ -1,3 +0,0 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
|
||||||
oid sha256:48db938cf17b3360326470841f32872e2770b9168040cd95f18b53dc49b1dbe3
|
|
||||||
size 4163
|
|
@ -46,7 +46,6 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@bull-board/api": "5.6.0",
|
"@bull-board/api": "5.6.0",
|
||||||
"@bull-board/ui": "5.6.0",
|
"@bull-board/ui": "5.6.0",
|
||||||
"@napi-rs/cli": "^2.16.1",
|
|
||||||
"@tensorflow/tfjs": "^3.21.0",
|
"@tensorflow/tfjs": "^3.21.0",
|
||||||
"js-yaml": "4.1.0",
|
"js-yaml": "4.1.0",
|
||||||
"seedrandom": "^3.0.5"
|
"seedrandom": "^3.0.5"
|
||||||
|
@ -1,57 +0,0 @@
|
|||||||
[package]
|
|
||||||
edition = "2021"
|
|
||||||
name = "native-utils"
|
|
||||||
version = "0.0.0"
|
|
||||||
|
|
||||||
[workspace]
|
|
||||||
members = ["migration"]
|
|
||||||
|
|
||||||
[features]
|
|
||||||
default = []
|
|
||||||
noarray = []
|
|
||||||
napi = ["dep:napi", "dep:napi-derive"]
|
|
||||||
|
|
||||||
[lib]
|
|
||||||
crate-type = ["cdylib", "lib"]
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
async-trait = "0.1.68"
|
|
||||||
cfg-if = "1.0.0"
|
|
||||||
chrono = "0.4.24"
|
|
||||||
cuid2 = "0.1.0"
|
|
||||||
derive_more = "0.99.17"
|
|
||||||
jsonschema = "0.17.0"
|
|
||||||
once_cell = "1.17.1"
|
|
||||||
parse-display = "0.8.0"
|
|
||||||
rand = "0.8.5"
|
|
||||||
schemars = { version = "0.8.12", features = ["chrono"] }
|
|
||||||
sea-orm = { version = "0.11.3", features = ["sqlx-postgres", "postgres-array", "sqlx-sqlite", "runtime-tokio-rustls"] }
|
|
||||||
serde = { version = "1.0.163", features = ["derive"] }
|
|
||||||
serde_json = "1.0.96"
|
|
||||||
thiserror = "1.0.40"
|
|
||||||
tokio = { version = "1.28.1", features = ["full"] }
|
|
||||||
utoipa = "3.3.0"
|
|
||||||
radix_fmt = "1.0.0"
|
|
||||||
|
|
||||||
# Default enable napi4 feature, see https://nodejs.org/api/n-api.html#node-api-version-matrix
|
|
||||||
napi = { version = "2.13.1", default-features = false, features = ["napi6", "tokio_rt"], optional = true }
|
|
||||||
napi-derive = { version = "2.12.0", optional = true }
|
|
||||||
|
|
||||||
[dev-dependencies]
|
|
||||||
pretty_assertions = "1.3.0"
|
|
||||||
|
|
||||||
[build-dependencies]
|
|
||||||
napi-build = "2.0.1"
|
|
||||||
|
|
||||||
[profile.release]
|
|
||||||
lto = true
|
|
||||||
|
|
||||||
[profile.release-no-lto]
|
|
||||||
inherits = "release"
|
|
||||||
lto = false
|
|
||||||
|
|
||||||
[profile.debug-napi]
|
|
||||||
inherits = "dev"
|
|
||||||
|
|
||||||
[profile.debug-migration]
|
|
||||||
inherits = "dev"
|
|
@ -1,32 +0,0 @@
|
|||||||
import test from "ava";
|
|
||||||
|
|
||||||
import {
|
|
||||||
convertId,
|
|
||||||
IdConvertType,
|
|
||||||
nativeInitIdGenerator,
|
|
||||||
nativeCreateId,
|
|
||||||
nativeRandomStr,
|
|
||||||
} from "../built/index.js";
|
|
||||||
|
|
||||||
test("convert to mastodon id", (t) => {
|
|
||||||
t.is(convertId("9gf61ehcxv", IdConvertType.MastodonId), "960365976481219");
|
|
||||||
t.is(
|
|
||||||
convertId("9fbr9z0wbrjqyd3u", IdConvertType.MastodonId),
|
|
||||||
"2083785058661759970208986",
|
|
||||||
);
|
|
||||||
t.is(
|
|
||||||
convertId("9fbs680oyviiqrol9md73p8g", IdConvertType.MastodonId),
|
|
||||||
"5878598648988104013828532260828151168",
|
|
||||||
);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("create cuid2 with timestamp prefix", (t) => {
|
|
||||||
nativeInitIdGenerator(16, "");
|
|
||||||
t.not(nativeCreateId(Date.now()), nativeCreateId(Date.now()));
|
|
||||||
t.is(nativeCreateId(Date.now()).length, 16);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("create random string", (t) => {
|
|
||||||
t.not(nativeRandomStr(16), nativeRandomStr(16));
|
|
||||||
t.is(nativeRandomStr(24).length, 24);
|
|
||||||
});
|
|
199
packages/backend/native-utils/migration/.gitignore
vendored
Normal file
199
packages/backend/native-utils/migration/.gitignore
vendored
Normal file
@ -0,0 +1,199 @@
|
|||||||
|
# Created by https://www.toptal.com/developers/gitignore/api/node
|
||||||
|
# Edit at https://www.toptal.com/developers/gitignore?templates=node
|
||||||
|
|
||||||
|
### Node ###
|
||||||
|
# Logs
|
||||||
|
logs
|
||||||
|
*.log
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
lerna-debug.log*
|
||||||
|
|
||||||
|
# Diagnostic reports (https://nodejs.org/api/report.html)
|
||||||
|
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
|
||||||
|
|
||||||
|
# Runtime data
|
||||||
|
pids
|
||||||
|
*.pid
|
||||||
|
*.seed
|
||||||
|
*.pid.lock
|
||||||
|
|
||||||
|
# Directory for instrumented libs generated by jscoverage/JSCover
|
||||||
|
lib-cov
|
||||||
|
|
||||||
|
# Coverage directory used by tools like istanbul
|
||||||
|
coverage
|
||||||
|
*.lcov
|
||||||
|
|
||||||
|
# nyc test coverage
|
||||||
|
.nyc_output
|
||||||
|
|
||||||
|
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
|
||||||
|
.grunt
|
||||||
|
|
||||||
|
# Bower dependency directory (https://bower.io/)
|
||||||
|
bower_components
|
||||||
|
|
||||||
|
# node-waf configuration
|
||||||
|
.lock-wscript
|
||||||
|
|
||||||
|
# Compiled binary addons (https://nodejs.org/api/addons.html)
|
||||||
|
build/Release
|
||||||
|
|
||||||
|
# Dependency directories
|
||||||
|
node_modules/
|
||||||
|
jspm_packages/
|
||||||
|
|
||||||
|
# TypeScript v1 declaration files
|
||||||
|
typings/
|
||||||
|
|
||||||
|
# TypeScript cache
|
||||||
|
*.tsbuildinfo
|
||||||
|
|
||||||
|
# Optional npm cache directory
|
||||||
|
.npm
|
||||||
|
|
||||||
|
# Optional eslint cache
|
||||||
|
.eslintcache
|
||||||
|
|
||||||
|
# Microbundle cache
|
||||||
|
.rpt2_cache/
|
||||||
|
.rts2_cache_cjs/
|
||||||
|
.rts2_cache_es/
|
||||||
|
.rts2_cache_umd/
|
||||||
|
|
||||||
|
# Optional REPL history
|
||||||
|
.node_repl_history
|
||||||
|
|
||||||
|
# Output of 'npm pack'
|
||||||
|
*.tgz
|
||||||
|
|
||||||
|
# Yarn Integrity file
|
||||||
|
.yarn-integrity
|
||||||
|
|
||||||
|
# dotenv environment variables file
|
||||||
|
.env
|
||||||
|
.env.test
|
||||||
|
|
||||||
|
# parcel-bundler cache (https://parceljs.org/)
|
||||||
|
.cache
|
||||||
|
|
||||||
|
# Next.js build output
|
||||||
|
.next
|
||||||
|
|
||||||
|
# Nuxt.js build / generate output
|
||||||
|
.nuxt
|
||||||
|
dist
|
||||||
|
|
||||||
|
# Gatsby files
|
||||||
|
.cache/
|
||||||
|
# Comment in the public line in if your project uses Gatsby and not Next.js
|
||||||
|
# https://nextjs.org/blog/next-9-1#public-directory-support
|
||||||
|
# public
|
||||||
|
|
||||||
|
# vuepress build output
|
||||||
|
.vuepress/dist
|
||||||
|
|
||||||
|
# Serverless directories
|
||||||
|
.serverless/
|
||||||
|
|
||||||
|
# FuseBox cache
|
||||||
|
.fusebox/
|
||||||
|
|
||||||
|
# DynamoDB Local files
|
||||||
|
.dynamodb/
|
||||||
|
|
||||||
|
# TernJS port file
|
||||||
|
.tern-port
|
||||||
|
|
||||||
|
# Stores VSCode versions used for testing VSCode extensions
|
||||||
|
.vscode-test
|
||||||
|
|
||||||
|
# End of https://www.toptal.com/developers/gitignore/api/node
|
||||||
|
|
||||||
|
# Created by https://www.toptal.com/developers/gitignore/api/macos
|
||||||
|
# Edit at https://www.toptal.com/developers/gitignore?templates=macos
|
||||||
|
|
||||||
|
### macOS ###
|
||||||
|
# General
|
||||||
|
.DS_Store
|
||||||
|
.AppleDouble
|
||||||
|
.LSOverride
|
||||||
|
|
||||||
|
# Icon must end with two
|
||||||
|
Icon
|
||||||
|
|
||||||
|
|
||||||
|
# Thumbnails
|
||||||
|
._*
|
||||||
|
|
||||||
|
# Files that might appear in the root of a volume
|
||||||
|
.DocumentRevisions-V100
|
||||||
|
.fseventsd
|
||||||
|
.Spotlight-V100
|
||||||
|
.TemporaryItems
|
||||||
|
.Trashes
|
||||||
|
.VolumeIcon.icns
|
||||||
|
.com.apple.timemachine.donotpresent
|
||||||
|
|
||||||
|
# Directories potentially created on remote AFP share
|
||||||
|
.AppleDB
|
||||||
|
.AppleDesktop
|
||||||
|
Network Trash Folder
|
||||||
|
Temporary Items
|
||||||
|
.apdisk
|
||||||
|
|
||||||
|
### macOS Patch ###
|
||||||
|
# iCloud generated files
|
||||||
|
*.icloud
|
||||||
|
|
||||||
|
# End of https://www.toptal.com/developers/gitignore/api/macos
|
||||||
|
|
||||||
|
# Created by https://www.toptal.com/developers/gitignore/api/windows
|
||||||
|
# Edit at https://www.toptal.com/developers/gitignore?templates=windows
|
||||||
|
|
||||||
|
### Windows ###
|
||||||
|
# Windows thumbnail cache files
|
||||||
|
Thumbs.db
|
||||||
|
Thumbs.db:encryptable
|
||||||
|
ehthumbs.db
|
||||||
|
ehthumbs_vista.db
|
||||||
|
|
||||||
|
# Dump file
|
||||||
|
*.stackdump
|
||||||
|
|
||||||
|
# Folder config file
|
||||||
|
[Dd]esktop.ini
|
||||||
|
|
||||||
|
# Recycle Bin used on file shares
|
||||||
|
$RECYCLE.BIN/
|
||||||
|
|
||||||
|
# Windows Installer files
|
||||||
|
*.cab
|
||||||
|
*.msi
|
||||||
|
*.msix
|
||||||
|
*.msm
|
||||||
|
*.msp
|
||||||
|
|
||||||
|
# Windows shortcuts
|
||||||
|
*.lnk
|
||||||
|
|
||||||
|
# End of https://www.toptal.com/developers/gitignore/api/windows
|
||||||
|
|
||||||
|
# napi-rs generated files
|
||||||
|
built/
|
||||||
|
|
||||||
|
#Added by cargo
|
||||||
|
|
||||||
|
/target
|
||||||
|
|
||||||
|
.pnp.*
|
||||||
|
.yarn/*
|
||||||
|
!.yarn/patches
|
||||||
|
!.yarn/plugins
|
||||||
|
!.yarn/releases
|
||||||
|
!.yarn/sdks
|
||||||
|
!.yarn/versions
|
||||||
|
|
||||||
|
*.node
|
File diff suppressed because it is too large
Load Diff
@ -10,14 +10,10 @@ path = "src/lib.rs"
|
|||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = []
|
||||||
convert = ["dep:native-utils", "dep:indicatif", "dep:futures"]
|
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
serde_json = "1.0.96"
|
serde_json = "1.0.96"
|
||||||
native-utils = { path = "../", optional = true }
|
|
||||||
indicatif = { version = "0.17.4", features = ["tokio"], optional = true }
|
|
||||||
tokio = { version = "1.28.2", features = ["full"] }
|
tokio = { version = "1.28.2", features = ["full"] }
|
||||||
futures = { version = "0.3.28", optional = true }
|
|
||||||
serde_yaml = "0.9.21"
|
serde_yaml = "0.9.21"
|
||||||
serde = { version = "1.0.163", features = ["derive"] }
|
serde = { version = "1.0.163", features = ["derive"] }
|
||||||
urlencoding = "2.1.2"
|
urlencoding = "2.1.2"
|
||||||
|
@ -9,9 +9,6 @@ const DB_URL_ENV: &str = "DATABASE_URL";
|
|||||||
const CACHE_URL_ENV: &str = "CACHE_URL";
|
const CACHE_URL_ENV: &str = "CACHE_URL";
|
||||||
const CACHE_PREFIX_ENV: &str = "CACHE_PREFIX";
|
const CACHE_PREFIX_ENV: &str = "CACHE_PREFIX";
|
||||||
|
|
||||||
#[cfg(feature = "convert")]
|
|
||||||
mod vec_to_json;
|
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
let cwd = env::current_dir().unwrap();
|
let cwd = env::current_dir().unwrap();
|
||||||
@ -65,9 +62,6 @@ async fn main() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cli::run_cli(migration::Migrator).await;
|
cli::run_cli(migration::Migrator).await;
|
||||||
|
|
||||||
#[cfg(feature = "convert")]
|
|
||||||
vec_to_json::convert().await;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Deserialize)]
|
#[derive(Debug, PartialEq, Deserialize)]
|
||||||
|
@ -1,498 +0,0 @@
|
|||||||
use indicatif::{MultiProgress, ProgressBar, ProgressStyle};
|
|
||||||
use native_utils::model::entity::newtype::{I32Vec, StringVec};
|
|
||||||
use sea_orm_migration::{
|
|
||||||
prelude::*,
|
|
||||||
sea_orm::{Database, DbBackend, DbConn, Statement, TryGetable},
|
|
||||||
};
|
|
||||||
use serde_json::json;
|
|
||||||
use std::env;
|
|
||||||
use std::time::Duration;
|
|
||||||
|
|
||||||
pub async fn convert() {
|
|
||||||
let uri = env::var("DATABASE_URL").expect("Environment variable 'DATABASE_URL' not set");
|
|
||||||
|
|
||||||
let db = Database::connect(uri).await.expect("Unable to connect");
|
|
||||||
let mp = MultiProgress::new();
|
|
||||||
|
|
||||||
let handlers = vec![
|
|
||||||
tokio::spawn(to_json::<AccessToken, Vec<String>, StringVec>(
|
|
||||||
db.clone(),
|
|
||||||
mp.clone(),
|
|
||||||
AccessToken::Table,
|
|
||||||
AccessToken::Id,
|
|
||||||
AccessToken::Permission,
|
|
||||||
)),
|
|
||||||
tokio::spawn(to_json::<Antenna, Vec<String>, StringVec>(
|
|
||||||
db.clone(),
|
|
||||||
mp.clone(),
|
|
||||||
Antenna::Table,
|
|
||||||
Antenna::Id,
|
|
||||||
Antenna::Users,
|
|
||||||
)),
|
|
||||||
tokio::spawn(to_json::<App, Vec<String>, StringVec>(
|
|
||||||
db.clone(),
|
|
||||||
mp.clone(),
|
|
||||||
App::Table,
|
|
||||||
App::Id,
|
|
||||||
App::Permission,
|
|
||||||
)),
|
|
||||||
tokio::spawn(to_json::<Emoji, Vec<String>, StringVec>(
|
|
||||||
db.clone(),
|
|
||||||
mp.clone(),
|
|
||||||
Emoji::Table,
|
|
||||||
Emoji::Id,
|
|
||||||
Emoji::Aliases,
|
|
||||||
)),
|
|
||||||
tokio::spawn(to_json::<GalleryPost, Vec<String>, StringVec>(
|
|
||||||
db.clone(),
|
|
||||||
mp.clone(),
|
|
||||||
GalleryPost::Table,
|
|
||||||
GalleryPost::Id,
|
|
||||||
GalleryPost::FileIds,
|
|
||||||
)),
|
|
||||||
tokio::spawn(to_json::<GalleryPost, Vec<String>, StringVec>(
|
|
||||||
db.clone(),
|
|
||||||
mp.clone(),
|
|
||||||
GalleryPost::Table,
|
|
||||||
GalleryPost::Id,
|
|
||||||
GalleryPost::Tags,
|
|
||||||
)),
|
|
||||||
tokio::spawn(to_json::<Hashtag, Vec<String>, StringVec>(
|
|
||||||
db.clone(),
|
|
||||||
mp.clone(),
|
|
||||||
Hashtag::Table,
|
|
||||||
Hashtag::Id,
|
|
||||||
Hashtag::MentionedUserIds,
|
|
||||||
)),
|
|
||||||
tokio::spawn(to_json::<Hashtag, Vec<String>, StringVec>(
|
|
||||||
db.clone(),
|
|
||||||
mp.clone(),
|
|
||||||
Hashtag::Table,
|
|
||||||
Hashtag::Id,
|
|
||||||
Hashtag::MentionedLocalUserIds,
|
|
||||||
)),
|
|
||||||
tokio::spawn(to_json::<Hashtag, Vec<String>, StringVec>(
|
|
||||||
db.clone(),
|
|
||||||
mp.clone(),
|
|
||||||
Hashtag::Table,
|
|
||||||
Hashtag::Id,
|
|
||||||
Hashtag::MentionedRemoteUserIds,
|
|
||||||
)),
|
|
||||||
tokio::spawn(to_json::<Hashtag, Vec<String>, StringVec>(
|
|
||||||
db.clone(),
|
|
||||||
mp.clone(),
|
|
||||||
Hashtag::Table,
|
|
||||||
Hashtag::Id,
|
|
||||||
Hashtag::AttachedUserIds,
|
|
||||||
)),
|
|
||||||
tokio::spawn(to_json::<Hashtag, Vec<String>, StringVec>(
|
|
||||||
db.clone(),
|
|
||||||
mp.clone(),
|
|
||||||
Hashtag::Table,
|
|
||||||
Hashtag::Id,
|
|
||||||
Hashtag::AttachedLocalUserIds,
|
|
||||||
)),
|
|
||||||
tokio::spawn(to_json::<Hashtag, Vec<String>, StringVec>(
|
|
||||||
db.clone(),
|
|
||||||
mp.clone(),
|
|
||||||
Hashtag::Table,
|
|
||||||
Hashtag::Id,
|
|
||||||
Hashtag::AttachedRemoteUserIds,
|
|
||||||
)),
|
|
||||||
tokio::spawn(to_json::<MessagingMessage, Vec<String>, StringVec>(
|
|
||||||
db.clone(),
|
|
||||||
mp.clone(),
|
|
||||||
MessagingMessage::Table,
|
|
||||||
MessagingMessage::Id,
|
|
||||||
MessagingMessage::Reads,
|
|
||||||
)),
|
|
||||||
tokio::spawn(to_json::<Meta, Vec<String>, StringVec>(
|
|
||||||
db.clone(),
|
|
||||||
mp.clone(),
|
|
||||||
Meta::Table,
|
|
||||||
Meta::Id,
|
|
||||||
Meta::Langs,
|
|
||||||
)),
|
|
||||||
tokio::spawn(to_json::<Meta, Vec<String>, StringVec>(
|
|
||||||
db.clone(),
|
|
||||||
mp.clone(),
|
|
||||||
Meta::Table,
|
|
||||||
Meta::Id,
|
|
||||||
Meta::BlockedHosts,
|
|
||||||
)),
|
|
||||||
tokio::spawn(to_json::<Meta, Vec<String>, StringVec>(
|
|
||||||
db.clone(),
|
|
||||||
mp.clone(),
|
|
||||||
Meta::Table,
|
|
||||||
Meta::Id,
|
|
||||||
Meta::HiddenTags,
|
|
||||||
)),
|
|
||||||
tokio::spawn(to_json::<Meta, Vec<String>, StringVec>(
|
|
||||||
db.clone(),
|
|
||||||
mp.clone(),
|
|
||||||
Meta::Table,
|
|
||||||
Meta::Id,
|
|
||||||
Meta::PinnedUsers,
|
|
||||||
)),
|
|
||||||
tokio::spawn(to_json::<Meta, Vec<String>, StringVec>(
|
|
||||||
db.clone(),
|
|
||||||
mp.clone(),
|
|
||||||
Meta::Table,
|
|
||||||
Meta::Id,
|
|
||||||
Meta::PinnedPages,
|
|
||||||
)),
|
|
||||||
tokio::spawn(to_json::<Meta, Vec<String>, StringVec>(
|
|
||||||
db.clone(),
|
|
||||||
mp.clone(),
|
|
||||||
Meta::Table,
|
|
||||||
Meta::Id,
|
|
||||||
Meta::RecommendedInstances,
|
|
||||||
)),
|
|
||||||
tokio::spawn(to_json::<Meta, Vec<String>, StringVec>(
|
|
||||||
db.clone(),
|
|
||||||
mp.clone(),
|
|
||||||
Meta::Table,
|
|
||||||
Meta::Id,
|
|
||||||
Meta::SilencedHosts,
|
|
||||||
)),
|
|
||||||
tokio::spawn(to_json::<Note, Vec<String>, StringVec>(
|
|
||||||
db.clone(),
|
|
||||||
mp.clone(),
|
|
||||||
Note::Table,
|
|
||||||
Note::Id,
|
|
||||||
Note::FileIds,
|
|
||||||
)),
|
|
||||||
tokio::spawn(to_json::<Note, Vec<String>, StringVec>(
|
|
||||||
db.clone(),
|
|
||||||
mp.clone(),
|
|
||||||
Note::Table,
|
|
||||||
Note::Id,
|
|
||||||
Note::AttachedFileTypes,
|
|
||||||
)),
|
|
||||||
tokio::spawn(to_json::<Note, Vec<String>, StringVec>(
|
|
||||||
db.clone(),
|
|
||||||
mp.clone(),
|
|
||||||
Note::Table,
|
|
||||||
Note::Id,
|
|
||||||
Note::VisibleUserIds,
|
|
||||||
)),
|
|
||||||
tokio::spawn(to_json::<Note, Vec<String>, StringVec>(
|
|
||||||
db.clone(),
|
|
||||||
mp.clone(),
|
|
||||||
Note::Table,
|
|
||||||
Note::Id,
|
|
||||||
Note::Mentions,
|
|
||||||
)),
|
|
||||||
tokio::spawn(to_json::<Note, Vec<String>, StringVec>(
|
|
||||||
db.clone(),
|
|
||||||
mp.clone(),
|
|
||||||
Note::Table,
|
|
||||||
Note::Id,
|
|
||||||
Note::Emojis,
|
|
||||||
)),
|
|
||||||
tokio::spawn(to_json::<Note, Vec<String>, StringVec>(
|
|
||||||
db.clone(),
|
|
||||||
mp.clone(),
|
|
||||||
Note::Table,
|
|
||||||
Note::Id,
|
|
||||||
Note::Tags,
|
|
||||||
)),
|
|
||||||
tokio::spawn(to_json::<NoteEdit, Vec<String>, StringVec>(
|
|
||||||
db.clone(),
|
|
||||||
mp.clone(),
|
|
||||||
NoteEdit::Table,
|
|
||||||
NoteEdit::Id,
|
|
||||||
NoteEdit::FileIds,
|
|
||||||
)),
|
|
||||||
tokio::spawn(to_json::<Page, Vec<String>, StringVec>(
|
|
||||||
db.clone(),
|
|
||||||
mp.clone(),
|
|
||||||
Page::Table,
|
|
||||||
Page::Id,
|
|
||||||
Page::VisibleUserIds,
|
|
||||||
)),
|
|
||||||
tokio::spawn(to_json::<RegistryItem, Vec<String>, StringVec>(
|
|
||||||
db.clone(),
|
|
||||||
mp.clone(),
|
|
||||||
RegistryItem::Table,
|
|
||||||
RegistryItem::Id,
|
|
||||||
RegistryItem::Scope,
|
|
||||||
)),
|
|
||||||
tokio::spawn(to_json::<User, Vec<String>, StringVec>(
|
|
||||||
db.clone(),
|
|
||||||
mp.clone(),
|
|
||||||
User::Table,
|
|
||||||
User::Id,
|
|
||||||
User::Tags,
|
|
||||||
)),
|
|
||||||
tokio::spawn(to_json::<User, Vec<String>, StringVec>(
|
|
||||||
db.clone(),
|
|
||||||
mp.clone(),
|
|
||||||
User::Table,
|
|
||||||
User::Id,
|
|
||||||
User::Emojis,
|
|
||||||
)),
|
|
||||||
tokio::spawn(to_json::<Webhook, Vec<String>, StringVec>(
|
|
||||||
db.clone(),
|
|
||||||
mp.clone(),
|
|
||||||
Webhook::Table,
|
|
||||||
Webhook::Id,
|
|
||||||
Webhook::On,
|
|
||||||
)),
|
|
||||||
tokio::spawn(to_json::<Poll, Vec<String>, StringVec>(
|
|
||||||
db.clone(),
|
|
||||||
mp.clone(),
|
|
||||||
Poll::Table,
|
|
||||||
Poll::NoteId,
|
|
||||||
Poll::Choices,
|
|
||||||
)),
|
|
||||||
tokio::spawn(to_json::<Poll, Vec<i32>, I32Vec>(
|
|
||||||
db.clone(),
|
|
||||||
mp.clone(),
|
|
||||||
Poll::Table,
|
|
||||||
Poll::NoteId,
|
|
||||||
Poll::Votes,
|
|
||||||
)),
|
|
||||||
tokio::spawn(to_json::<UserProfile, Vec<String>, StringVec>(
|
|
||||||
db.clone(),
|
|
||||||
mp.clone(),
|
|
||||||
UserProfile::Table,
|
|
||||||
UserProfile::UserId,
|
|
||||||
UserProfile::MutingNotificationTypes,
|
|
||||||
)),
|
|
||||||
];
|
|
||||||
|
|
||||||
futures::future::join_all(handlers).await;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn select_query<T: Iden + 'static>(table: T, id: T, col: T) -> String {
|
|
||||||
Query::select()
|
|
||||||
.column(id)
|
|
||||||
.column(col)
|
|
||||||
.from(table)
|
|
||||||
.to_string(PostgresQueryBuilder)
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn get_vec<T: TryGetable>(db: &DbConn, query: String) -> Result<Vec<(String, T)>, DbErr> {
|
|
||||||
let res: Vec<(String, T)> = db
|
|
||||||
.query_all(Statement::from_string(DbBackend::Postgres, query))
|
|
||||||
.await?
|
|
||||||
.iter()
|
|
||||||
.filter_map(|r| r.try_get_many_by_index().ok())
|
|
||||||
.collect();
|
|
||||||
Ok(res)
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn convert_col<T: Iden + Clone + 'static>(
|
|
||||||
db: &DbConn,
|
|
||||||
table: T,
|
|
||||||
col: T,
|
|
||||||
) -> Result<(), DbErr> {
|
|
||||||
let stmt = Table::alter()
|
|
||||||
.table(table)
|
|
||||||
.drop_column(col.to_owned())
|
|
||||||
.add_column(
|
|
||||||
ColumnDef::new(col.to_owned())
|
|
||||||
.json_binary()
|
|
||||||
.not_null()
|
|
||||||
.default(json!([])),
|
|
||||||
)
|
|
||||||
.to_string(PostgresQueryBuilder);
|
|
||||||
db.query_one(Statement::from_string(DbBackend::Postgres, stmt))
|
|
||||||
.await?;
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn to_json<T, U, V>(
|
|
||||||
db: DbConn,
|
|
||||||
mp: MultiProgress,
|
|
||||||
table: T,
|
|
||||||
id: T,
|
|
||||||
col: T,
|
|
||||||
) -> Result<(), DbErr>
|
|
||||||
where
|
|
||||||
T: Iden + Clone + 'static,
|
|
||||||
U: TryGetable + IntoIterator + Clone,
|
|
||||||
V: From<U> + Into<SimpleExpr>,
|
|
||||||
{
|
|
||||||
let query = select_query(table.clone(), id.clone(), col.clone());
|
|
||||||
let loading = ProgressBar::new_spinner()
|
|
||||||
.with_style(ProgressStyle::with_template("{prefix} {msg} {spinner}").unwrap())
|
|
||||||
.with_prefix("[-]")
|
|
||||||
.with_message(format!(
|
|
||||||
"Loading data from {}.{}",
|
|
||||||
table.to_string(),
|
|
||||||
col.to_string()
|
|
||||||
));
|
|
||||||
let loading = mp.add(loading);
|
|
||||||
loading.enable_steady_tick(Duration::from_millis(100));
|
|
||||||
let res = get_vec::<U>(&db, query).await?;
|
|
||||||
let models: Vec<(String, V)> = res
|
|
||||||
.iter()
|
|
||||||
.filter(|(_, r)| r.clone().into_iter().count() > 0)
|
|
||||||
.map(|(id, r)| (id.clone(), <V>::from(r.clone())))
|
|
||||||
.collect();
|
|
||||||
loading.finish_and_clear();
|
|
||||||
convert_col(&db, table.clone(), col.clone()).await?;
|
|
||||||
|
|
||||||
let progress = ProgressBar::new(models.len() as u64)
|
|
||||||
.with_style(
|
|
||||||
ProgressStyle::with_template("{prefix} {msg} {wide_bar} {pos}/{len}")
|
|
||||||
.unwrap()
|
|
||||||
.progress_chars("##-"),
|
|
||||||
)
|
|
||||||
.with_prefix("[*]")
|
|
||||||
.with_message(format!("Copying {}.{}", table.to_string(), col.to_string()));
|
|
||||||
let progress = mp.add(progress);
|
|
||||||
|
|
||||||
for model in models {
|
|
||||||
progress.inc(1);
|
|
||||||
let q = Query::update()
|
|
||||||
.table(table.clone())
|
|
||||||
.values([(col.clone(), model.1.into())])
|
|
||||||
.and_where(Expr::col(id.clone()).eq(model.0))
|
|
||||||
.to_string(PostgresQueryBuilder);
|
|
||||||
db.query_one(Statement::from_string(DbBackend::Postgres, q))
|
|
||||||
.await?;
|
|
||||||
}
|
|
||||||
progress.finish_with_message(format!("Done {}.{}", table.to_string(), col.to_string()));
|
|
||||||
|
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Iden, Clone)]
|
|
||||||
enum AccessToken {
|
|
||||||
Table,
|
|
||||||
Id,
|
|
||||||
Permission,
|
|
||||||
}
|
|
||||||
#[derive(Iden, Clone)]
|
|
||||||
enum Antenna {
|
|
||||||
Table,
|
|
||||||
Id,
|
|
||||||
Users,
|
|
||||||
}
|
|
||||||
#[derive(Iden, Clone)]
|
|
||||||
enum App {
|
|
||||||
Table,
|
|
||||||
Id,
|
|
||||||
Permission,
|
|
||||||
}
|
|
||||||
#[derive(Iden, Clone)]
|
|
||||||
enum Emoji {
|
|
||||||
Table,
|
|
||||||
Id,
|
|
||||||
Aliases,
|
|
||||||
}
|
|
||||||
#[derive(Iden, Clone)]
|
|
||||||
enum GalleryPost {
|
|
||||||
Table,
|
|
||||||
Id,
|
|
||||||
#[iden = "fileIds"]
|
|
||||||
FileIds,
|
|
||||||
Tags,
|
|
||||||
}
|
|
||||||
#[derive(Iden, Clone)]
|
|
||||||
enum Hashtag {
|
|
||||||
Table,
|
|
||||||
Id,
|
|
||||||
#[iden = "mentionedUserIds"]
|
|
||||||
MentionedUserIds,
|
|
||||||
#[iden = "mentionedLocalUserIds"]
|
|
||||||
MentionedLocalUserIds,
|
|
||||||
#[iden = "mentionedRemoteUserIds"]
|
|
||||||
MentionedRemoteUserIds,
|
|
||||||
#[iden = "attachedUserIds"]
|
|
||||||
AttachedUserIds,
|
|
||||||
#[iden = "attachedLocalUserIds"]
|
|
||||||
AttachedLocalUserIds,
|
|
||||||
#[iden = "attachedRemoteUserIds"]
|
|
||||||
AttachedRemoteUserIds,
|
|
||||||
}
|
|
||||||
#[derive(Iden, Clone)]
|
|
||||||
enum MessagingMessage {
|
|
||||||
Table,
|
|
||||||
Id,
|
|
||||||
Reads,
|
|
||||||
}
|
|
||||||
#[derive(Iden, Clone)]
|
|
||||||
enum Meta {
|
|
||||||
Table,
|
|
||||||
Id,
|
|
||||||
Langs,
|
|
||||||
#[iden = "hiddenTags"]
|
|
||||||
HiddenTags,
|
|
||||||
#[iden = "blockedHosts"]
|
|
||||||
BlockedHosts,
|
|
||||||
#[iden = "pinnedUsers"]
|
|
||||||
PinnedUsers,
|
|
||||||
#[iden = "pinnedPages"]
|
|
||||||
PinnedPages,
|
|
||||||
#[iden = "recommendedInstances"]
|
|
||||||
RecommendedInstances,
|
|
||||||
#[iden = "silencedHosts"]
|
|
||||||
SilencedHosts,
|
|
||||||
}
|
|
||||||
#[derive(Iden, Clone)]
|
|
||||||
enum Note {
|
|
||||||
Table,
|
|
||||||
Id,
|
|
||||||
#[iden = "fileIds"]
|
|
||||||
FileIds,
|
|
||||||
#[iden = "attachedFileTypes"]
|
|
||||||
AttachedFileTypes,
|
|
||||||
#[iden = "visibleUserIds"]
|
|
||||||
VisibleUserIds,
|
|
||||||
Mentions,
|
|
||||||
Emojis,
|
|
||||||
Tags,
|
|
||||||
}
|
|
||||||
#[derive(Iden, Clone)]
|
|
||||||
enum NoteEdit {
|
|
||||||
Table,
|
|
||||||
Id,
|
|
||||||
#[iden = "fileIds"]
|
|
||||||
FileIds,
|
|
||||||
}
|
|
||||||
#[derive(Iden, Clone)]
|
|
||||||
enum Page {
|
|
||||||
Table,
|
|
||||||
Id,
|
|
||||||
#[iden = "visibleUserIds"]
|
|
||||||
VisibleUserIds,
|
|
||||||
}
|
|
||||||
#[derive(Iden, Clone)]
|
|
||||||
enum Poll {
|
|
||||||
Table,
|
|
||||||
#[iden = "noteId"]
|
|
||||||
NoteId,
|
|
||||||
Choices,
|
|
||||||
Votes, // I32Vec
|
|
||||||
}
|
|
||||||
#[derive(Iden, Clone)]
|
|
||||||
enum RegistryItem {
|
|
||||||
Table,
|
|
||||||
Id,
|
|
||||||
Scope,
|
|
||||||
}
|
|
||||||
#[derive(Iden, Clone)]
|
|
||||||
enum User {
|
|
||||||
Table,
|
|
||||||
Id,
|
|
||||||
Tags,
|
|
||||||
Emojis,
|
|
||||||
}
|
|
||||||
#[derive(Iden, Clone)]
|
|
||||||
enum UserProfile {
|
|
||||||
Table,
|
|
||||||
#[iden = "userId"]
|
|
||||||
UserId,
|
|
||||||
#[iden = "mutingNotificationTypes"]
|
|
||||||
MutingNotificationTypes,
|
|
||||||
}
|
|
||||||
#[derive(Iden, Clone)]
|
|
||||||
enum Webhook {
|
|
||||||
Table,
|
|
||||||
Id,
|
|
||||||
On,
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
# `native-utils-android-arm-eabi`
|
|
||||||
|
|
||||||
This is the **armv7-linux-androideabi** binary for `native-utils`
|
|
@ -1,18 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "native-utils-android-arm-eabi",
|
|
||||||
"version": "0.0.0",
|
|
||||||
"os": [
|
|
||||||
"android"
|
|
||||||
],
|
|
||||||
"cpu": [
|
|
||||||
"arm"
|
|
||||||
],
|
|
||||||
"main": "native-utils.android-arm-eabi.node",
|
|
||||||
"files": [
|
|
||||||
"native-utils.android-arm-eabi.node"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 10"
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
# `native-utils-android-arm64`
|
|
||||||
|
|
||||||
This is the **aarch64-linux-android** binary for `native-utils`
|
|
@ -1,18 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "native-utils-android-arm64",
|
|
||||||
"version": "0.0.0",
|
|
||||||
"os": [
|
|
||||||
"android"
|
|
||||||
],
|
|
||||||
"cpu": [
|
|
||||||
"arm64"
|
|
||||||
],
|
|
||||||
"main": "native-utils.android-arm64.node",
|
|
||||||
"files": [
|
|
||||||
"native-utils.android-arm64.node"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 10"
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
# `native-utils-darwin-arm64`
|
|
||||||
|
|
||||||
This is the **aarch64-apple-darwin** binary for `native-utils`
|
|
@ -1,18 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "native-utils-darwin-arm64",
|
|
||||||
"version": "0.0.0",
|
|
||||||
"os": [
|
|
||||||
"darwin"
|
|
||||||
],
|
|
||||||
"cpu": [
|
|
||||||
"arm64"
|
|
||||||
],
|
|
||||||
"main": "native-utils.darwin-arm64.node",
|
|
||||||
"files": [
|
|
||||||
"native-utils.darwin-arm64.node"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 10"
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
# `native-utils-darwin-universal`
|
|
||||||
|
|
||||||
This is the **universal-apple-darwin** binary for `native-utils`
|
|
@ -1,15 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "native-utils-darwin-universal",
|
|
||||||
"version": "0.0.0",
|
|
||||||
"os": [
|
|
||||||
"darwin"
|
|
||||||
],
|
|
||||||
"main": "native-utils.darwin-universal.node",
|
|
||||||
"files": [
|
|
||||||
"native-utils.darwin-universal.node"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 10"
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
# `native-utils-darwin-x64`
|
|
||||||
|
|
||||||
This is the **x86_64-apple-darwin** binary for `native-utils`
|
|
@ -1,18 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "native-utils-darwin-x64",
|
|
||||||
"version": "0.0.0",
|
|
||||||
"os": [
|
|
||||||
"darwin"
|
|
||||||
],
|
|
||||||
"cpu": [
|
|
||||||
"x64"
|
|
||||||
],
|
|
||||||
"main": "native-utils.darwin-x64.node",
|
|
||||||
"files": [
|
|
||||||
"native-utils.darwin-x64.node"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 10"
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
# `native-utils-freebsd-x64`
|
|
||||||
|
|
||||||
This is the **x86_64-unknown-freebsd** binary for `native-utils`
|
|
@ -1,18 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "native-utils-freebsd-x64",
|
|
||||||
"version": "0.0.0",
|
|
||||||
"os": [
|
|
||||||
"freebsd"
|
|
||||||
],
|
|
||||||
"cpu": [
|
|
||||||
"x64"
|
|
||||||
],
|
|
||||||
"main": "native-utils.freebsd-x64.node",
|
|
||||||
"files": [
|
|
||||||
"native-utils.freebsd-x64.node"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 10"
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
# `native-utils-linux-arm-gnueabihf`
|
|
||||||
|
|
||||||
This is the **armv7-unknown-linux-gnueabihf** binary for `native-utils`
|
|
@ -1,18 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "native-utils-linux-arm-gnueabihf",
|
|
||||||
"version": "0.0.0",
|
|
||||||
"os": [
|
|
||||||
"linux"
|
|
||||||
],
|
|
||||||
"cpu": [
|
|
||||||
"arm"
|
|
||||||
],
|
|
||||||
"main": "native-utils.linux-arm-gnueabihf.node",
|
|
||||||
"files": [
|
|
||||||
"native-utils.linux-arm-gnueabihf.node"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 10"
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
# `native-utils-linux-arm64-gnu`
|
|
||||||
|
|
||||||
This is the **aarch64-unknown-linux-gnu** binary for `native-utils`
|
|
@ -1,21 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "native-utils-linux-arm64-gnu",
|
|
||||||
"version": "0.0.0",
|
|
||||||
"os": [
|
|
||||||
"linux"
|
|
||||||
],
|
|
||||||
"cpu": [
|
|
||||||
"arm64"
|
|
||||||
],
|
|
||||||
"main": "native-utils.linux-arm64-gnu.node",
|
|
||||||
"files": [
|
|
||||||
"native-utils.linux-arm64-gnu.node"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 10"
|
|
||||||
},
|
|
||||||
"libc": [
|
|
||||||
"glibc"
|
|
||||||
]
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
# `native-utils-linux-arm64-musl`
|
|
||||||
|
|
||||||
This is the **aarch64-unknown-linux-musl** binary for `native-utils`
|
|
@ -1,21 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "native-utils-linux-arm64-musl",
|
|
||||||
"version": "0.0.0",
|
|
||||||
"os": [
|
|
||||||
"linux"
|
|
||||||
],
|
|
||||||
"cpu": [
|
|
||||||
"arm64"
|
|
||||||
],
|
|
||||||
"main": "native-utils.linux-arm64-musl.node",
|
|
||||||
"files": [
|
|
||||||
"native-utils.linux-arm64-musl.node"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 10"
|
|
||||||
},
|
|
||||||
"libc": [
|
|
||||||
"musl"
|
|
||||||
]
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
# `native-utils-linux-x64-gnu`
|
|
||||||
|
|
||||||
This is the **x86_64-unknown-linux-gnu** binary for `native-utils`
|
|
@ -1,21 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "native-utils-linux-x64-gnu",
|
|
||||||
"version": "0.0.0",
|
|
||||||
"os": [
|
|
||||||
"linux"
|
|
||||||
],
|
|
||||||
"cpu": [
|
|
||||||
"x64"
|
|
||||||
],
|
|
||||||
"main": "native-utils.linux-x64-gnu.node",
|
|
||||||
"files": [
|
|
||||||
"native-utils.linux-x64-gnu.node"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 10"
|
|
||||||
},
|
|
||||||
"libc": [
|
|
||||||
"glibc"
|
|
||||||
]
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
# `native-utils-linux-x64-musl`
|
|
||||||
|
|
||||||
This is the **x86_64-unknown-linux-musl** binary for `native-utils`
|
|
@ -1,21 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "native-utils-linux-x64-musl",
|
|
||||||
"version": "0.0.0",
|
|
||||||
"os": [
|
|
||||||
"linux"
|
|
||||||
],
|
|
||||||
"cpu": [
|
|
||||||
"x64"
|
|
||||||
],
|
|
||||||
"main": "native-utils.linux-x64-musl.node",
|
|
||||||
"files": [
|
|
||||||
"native-utils.linux-x64-musl.node"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 10"
|
|
||||||
},
|
|
||||||
"libc": [
|
|
||||||
"musl"
|
|
||||||
]
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
# `native-utils-win32-arm64-msvc`
|
|
||||||
|
|
||||||
This is the **aarch64-pc-windows-msvc** binary for `native-utils`
|
|
@ -1,18 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "native-utils-win32-arm64-msvc",
|
|
||||||
"version": "0.0.0",
|
|
||||||
"os": [
|
|
||||||
"win32"
|
|
||||||
],
|
|
||||||
"cpu": [
|
|
||||||
"arm64"
|
|
||||||
],
|
|
||||||
"main": "native-utils.win32-arm64-msvc.node",
|
|
||||||
"files": [
|
|
||||||
"native-utils.win32-arm64-msvc.node"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 10"
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
# `native-utils-win32-ia32-msvc`
|
|
||||||
|
|
||||||
This is the **i686-pc-windows-msvc** binary for `native-utils`
|
|
@ -1,18 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "native-utils-win32-ia32-msvc",
|
|
||||||
"version": "0.0.0",
|
|
||||||
"os": [
|
|
||||||
"win32"
|
|
||||||
],
|
|
||||||
"cpu": [
|
|
||||||
"ia32"
|
|
||||||
],
|
|
||||||
"main": "native-utils.win32-ia32-msvc.node",
|
|
||||||
"files": [
|
|
||||||
"native-utils.win32-ia32-msvc.node"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 10"
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
# `native-utils-win32-x64-msvc`
|
|
||||||
|
|
||||||
This is the **x86_64-pc-windows-msvc** binary for `native-utils`
|
|
@ -1,18 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "native-utils-win32-x64-msvc",
|
|
||||||
"version": "0.0.0",
|
|
||||||
"os": [
|
|
||||||
"win32"
|
|
||||||
],
|
|
||||||
"cpu": [
|
|
||||||
"x64"
|
|
||||||
],
|
|
||||||
"main": "native-utils.win32-x64-msvc.node",
|
|
||||||
"files": [
|
|
||||||
"native-utils.win32-x64-msvc.node"
|
|
||||||
],
|
|
||||||
"license": "MIT",
|
|
||||||
"engines": {
|
|
||||||
"node": ">= 10"
|
|
||||||
}
|
|
||||||
}
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user