@le-space/node 0.1.14 → 0.1.16
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.
package/index.d.ts
CHANGED
|
@@ -160,6 +160,26 @@ interface JsonFetchLikeResponse {
|
|
|
160
160
|
}
|
|
161
161
|
type JsonFetchLike = (url: string, init?: RequestInit) => Promise<JsonFetchLikeResponse>;
|
|
162
162
|
|
|
163
|
+
declare function forgetAlephMessages(args: {
|
|
164
|
+
sender: string;
|
|
165
|
+
hashes?: string[];
|
|
166
|
+
aggregates?: string[];
|
|
167
|
+
reason?: string;
|
|
168
|
+
signer: MessageSigner;
|
|
169
|
+
hasher: MessageHasher;
|
|
170
|
+
fetch: JsonFetchLike;
|
|
171
|
+
channel?: string;
|
|
172
|
+
apiHost?: string;
|
|
173
|
+
sync?: boolean;
|
|
174
|
+
now?: number;
|
|
175
|
+
}): Promise<{
|
|
176
|
+
sender: string;
|
|
177
|
+
itemHash: string;
|
|
178
|
+
response: _shared_aleph_shared_types.AlephBroadcastResponse;
|
|
179
|
+
httpStatus: number;
|
|
180
|
+
status: _shared_aleph_shared_types.MessageStatus;
|
|
181
|
+
}>;
|
|
182
|
+
|
|
163
183
|
interface RetentionRecord {
|
|
164
184
|
instance_item_hash: string;
|
|
165
185
|
rootfs_item_hash: string;
|
|
@@ -197,6 +217,9 @@ declare function retainSuccessfulDeployments(args: {
|
|
|
197
217
|
retainedRecords: RetentionRecord[];
|
|
198
218
|
prunedRecords: RetentionRecord[];
|
|
199
219
|
forgetHashes: string[];
|
|
220
|
+
forgottenHashes: string[];
|
|
221
|
+
outstandingForgetHashes: string[];
|
|
222
|
+
forgetStatuses: Record<string, string>;
|
|
200
223
|
forgetResult: {
|
|
201
224
|
sender: string;
|
|
202
225
|
itemHash: string;
|
|
@@ -204,6 +227,10 @@ declare function retainSuccessfulDeployments(args: {
|
|
|
204
227
|
httpStatus: number;
|
|
205
228
|
status: _shared_aleph_shared_types.MessageStatus;
|
|
206
229
|
} | null;
|
|
230
|
+
followUpForgetResults: {
|
|
231
|
+
hash: string;
|
|
232
|
+
result: Awaited<ReturnType<typeof forgetAlephMessages>>;
|
|
233
|
+
}[];
|
|
207
234
|
}>;
|
|
208
235
|
|
|
209
236
|
declare function buildScaffoldDeployResult(env?: NodeJS.ProcessEnv): DeployOutputResult;
|
package/index.js
CHANGED
|
@@ -948,6 +948,31 @@ async function publishAggregateKey(args) {
|
|
|
948
948
|
httpStatus
|
|
949
949
|
};
|
|
950
950
|
}
|
|
951
|
+
async function fetchMessageStatus(args) {
|
|
952
|
+
const requestUrl = new URL(`/api/v0/messages/${args.hash}`, args.apiHost ?? "https://api2.aleph.im");
|
|
953
|
+
const response = await args.fetch(requestUrl.toString(), { cache: "no-cache" });
|
|
954
|
+
if (response.status === 404) return "missing";
|
|
955
|
+
if (!response.ok) return "unknown";
|
|
956
|
+
const payload = await response.json();
|
|
957
|
+
return asString3(payload?.status) ?? "unknown";
|
|
958
|
+
}
|
|
959
|
+
async function classifyForgetHashes(args) {
|
|
960
|
+
const statuses = {};
|
|
961
|
+
for (const hash of args.hashes) {
|
|
962
|
+
statuses[hash] = await fetchMessageStatus({
|
|
963
|
+
hash,
|
|
964
|
+
fetch: args.fetch,
|
|
965
|
+
apiHost: args.apiHost
|
|
966
|
+
});
|
|
967
|
+
}
|
|
968
|
+
const forgottenHashes = args.hashes.filter((hash) => statuses[hash] === "forgotten");
|
|
969
|
+
const outstandingForgetHashes = args.hashes.filter((hash) => statuses[hash] !== "forgotten");
|
|
970
|
+
return {
|
|
971
|
+
forgottenHashes,
|
|
972
|
+
outstandingForgetHashes,
|
|
973
|
+
statuses
|
|
974
|
+
};
|
|
975
|
+
}
|
|
951
976
|
async function retainSuccessfulDeployments(args) {
|
|
952
977
|
const keepCount = Math.max(0, Number.parseInt(String(args.keepCount ?? 0), 10) || 0);
|
|
953
978
|
const aggregateKey = asString3(args.aggregateKey) ?? SUCCESSFUL_DEPLOYMENTS_AGGREGATE_KEY;
|
|
@@ -995,18 +1020,64 @@ async function retainSuccessfulDeployments(args) {
|
|
|
995
1020
|
now: args.now
|
|
996
1021
|
});
|
|
997
1022
|
let forgetResult = null;
|
|
1023
|
+
let followUpForgetResults = [];
|
|
1024
|
+
let forgottenHashes = [];
|
|
1025
|
+
let outstandingForgetHashes = [];
|
|
1026
|
+
let forgetStatuses = {};
|
|
998
1027
|
if (forgetHashes.length > 0) {
|
|
999
|
-
|
|
1000
|
-
sender: args.sender,
|
|
1028
|
+
const initiallyOutstanding = await classifyForgetHashes({
|
|
1001
1029
|
hashes: forgetHashes,
|
|
1002
|
-
reason: args.reason ?? `Prune successful deployments beyond retention limit ${keepCount}`,
|
|
1003
|
-
signer: args.signer,
|
|
1004
|
-
hasher: args.hasher,
|
|
1005
1030
|
fetch: args.fetch,
|
|
1006
|
-
|
|
1007
|
-
apiHost: args.apiHost,
|
|
1008
|
-
now: args.now
|
|
1031
|
+
apiHost: args.apiHost
|
|
1009
1032
|
});
|
|
1033
|
+
forgottenHashes = initiallyOutstanding.forgottenHashes;
|
|
1034
|
+
outstandingForgetHashes = initiallyOutstanding.outstandingForgetHashes;
|
|
1035
|
+
forgetStatuses = initiallyOutstanding.statuses;
|
|
1036
|
+
if (outstandingForgetHashes.length > 0) {
|
|
1037
|
+
forgetResult = await forgetAlephMessages({
|
|
1038
|
+
sender: args.sender,
|
|
1039
|
+
hashes: outstandingForgetHashes,
|
|
1040
|
+
reason: args.reason ?? `Prune successful deployments beyond retention limit ${keepCount}`,
|
|
1041
|
+
signer: args.signer,
|
|
1042
|
+
hasher: args.hasher,
|
|
1043
|
+
fetch: args.fetch,
|
|
1044
|
+
channel: args.channel,
|
|
1045
|
+
apiHost: args.apiHost,
|
|
1046
|
+
now: args.now
|
|
1047
|
+
});
|
|
1048
|
+
let postBatch = await classifyForgetHashes({
|
|
1049
|
+
hashes: forgetHashes,
|
|
1050
|
+
fetch: args.fetch,
|
|
1051
|
+
apiHost: args.apiHost
|
|
1052
|
+
});
|
|
1053
|
+
forgottenHashes = postBatch.forgottenHashes;
|
|
1054
|
+
outstandingForgetHashes = postBatch.outstandingForgetHashes;
|
|
1055
|
+
forgetStatuses = postBatch.statuses;
|
|
1056
|
+
if (outstandingForgetHashes.length > 0) {
|
|
1057
|
+
for (const hash of outstandingForgetHashes) {
|
|
1058
|
+
const result = await forgetAlephMessages({
|
|
1059
|
+
sender: args.sender,
|
|
1060
|
+
hashes: [hash],
|
|
1061
|
+
reason: args.reason ?? `Prune successful deployments beyond retention limit ${keepCount}`,
|
|
1062
|
+
signer: args.signer,
|
|
1063
|
+
hasher: args.hasher,
|
|
1064
|
+
fetch: args.fetch,
|
|
1065
|
+
channel: args.channel,
|
|
1066
|
+
apiHost: args.apiHost,
|
|
1067
|
+
now: args.now
|
|
1068
|
+
});
|
|
1069
|
+
followUpForgetResults.push({ hash, result });
|
|
1070
|
+
}
|
|
1071
|
+
postBatch = await classifyForgetHashes({
|
|
1072
|
+
hashes: forgetHashes,
|
|
1073
|
+
fetch: args.fetch,
|
|
1074
|
+
apiHost: args.apiHost
|
|
1075
|
+
});
|
|
1076
|
+
forgottenHashes = postBatch.forgottenHashes;
|
|
1077
|
+
outstandingForgetHashes = postBatch.outstandingForgetHashes;
|
|
1078
|
+
forgetStatuses = postBatch.statuses;
|
|
1079
|
+
}
|
|
1080
|
+
}
|
|
1010
1081
|
}
|
|
1011
1082
|
return {
|
|
1012
1083
|
sender: args.sender,
|
|
@@ -1016,7 +1087,11 @@ async function retainSuccessfulDeployments(args) {
|
|
|
1016
1087
|
retainedRecords,
|
|
1017
1088
|
prunedRecords,
|
|
1018
1089
|
forgetHashes,
|
|
1019
|
-
|
|
1090
|
+
forgottenHashes,
|
|
1091
|
+
outstandingForgetHashes,
|
|
1092
|
+
forgetStatuses,
|
|
1093
|
+
forgetResult,
|
|
1094
|
+
followUpForgetResults
|
|
1020
1095
|
};
|
|
1021
1096
|
}
|
|
1022
1097
|
|
|
@@ -2098,7 +2173,8 @@ async function runActionMode(env = process.env, hooks = {}) {
|
|
|
2098
2173
|
`- Keep count: \`${payload.keepCount}\``,
|
|
2099
2174
|
`- Retained deployments: \`${payload.retainedRecords?.length ?? 0}\``,
|
|
2100
2175
|
`- Pruned deployments: \`${payload.prunedRecords?.length ?? 0}\``,
|
|
2101
|
-
`- Forgotten hashes: \`${(payload.forgetHashes ?? []).length}
|
|
2176
|
+
`- Forgotten hashes: \`${(payload.forgottenHashes ?? payload.forgetHashes ?? []).length}\``,
|
|
2177
|
+
`- Outstanding forget hashes: \`${(payload.outstandingForgetHashes ?? []).length}\``
|
|
2102
2178
|
], env);
|
|
2103
2179
|
stdout(`${JSON.stringify(payload)}
|
|
2104
2180
|
`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@le-space/node",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.16",
|
|
4
4
|
"description": "Node and GitHub Actions adapters for shared Aleph tooling.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -16,9 +16,9 @@
|
|
|
16
16
|
"access": "public"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@le-space/core": "0.1.
|
|
20
|
-
"@le-space/shared-types": "0.1.
|
|
21
|
-
"@le-space/rootfs": "0.1.
|
|
19
|
+
"@le-space/core": "0.1.16",
|
|
20
|
+
"@le-space/shared-types": "0.1.16",
|
|
21
|
+
"@le-space/rootfs": "0.1.16",
|
|
22
22
|
"ethers": "^6.15.0"
|
|
23
23
|
}
|
|
24
24
|
}
|
|
@@ -16,6 +16,9 @@ Environment=AUTOTLS_CADDY_READY_FILE=/etc/default/uc-go-peer.caddy-ready
|
|
|
16
16
|
Environment=SERVICE_NAME=uc-go-peer.service
|
|
17
17
|
Environment=WS_BACKEND_PORT=9097
|
|
18
18
|
ExecStart=/usr/bin/python3 /usr/local/sbin/uc-go-peer-autotls-refresh.py
|
|
19
|
+
Restart=on-failure
|
|
20
|
+
RestartSec=43200
|
|
21
|
+
StartLimitIntervalSec=0
|
|
19
22
|
StandardOutput=journal
|
|
20
23
|
StandardError=journal
|
|
21
24
|
|