@le-space/core 0.1.33 → 0.1.34
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 +39 -1
- package/index.js +36 -0
- package/package.json +2 -2
package/index.d.ts
CHANGED
|
@@ -381,6 +381,18 @@ declare function ensureInstancePortForwards(args: {
|
|
|
381
381
|
}>;
|
|
382
382
|
|
|
383
383
|
declare const SSH_PUBLIC_KEY_PATTERN: RegExp;
|
|
384
|
+
interface TierSpec {
|
|
385
|
+
vcpus: number;
|
|
386
|
+
memoryMiB: number;
|
|
387
|
+
diskMiB: number;
|
|
388
|
+
}
|
|
389
|
+
interface PaymentQuote {
|
|
390
|
+
required: number;
|
|
391
|
+
available: number;
|
|
392
|
+
computeUnits: number;
|
|
393
|
+
unitPrice: number;
|
|
394
|
+
label: 'credits';
|
|
395
|
+
}
|
|
384
396
|
declare function normalizeSshPublicKey(value: string): string;
|
|
385
397
|
declare function isValidSshPublicKey(value: string): boolean;
|
|
386
398
|
declare function createReleaseMetadata(name: string, rootfsVersion: string, deployer?: string): {
|
|
@@ -388,6 +400,32 @@ declare function createReleaseMetadata(name: string, rootfsVersion: string, depl
|
|
|
388
400
|
rootfs_version: string;
|
|
389
401
|
deployer: string;
|
|
390
402
|
};
|
|
403
|
+
declare function selectedTier<TTier extends {
|
|
404
|
+
id: string;
|
|
405
|
+
}>(pricing: {
|
|
406
|
+
tiers: TTier[];
|
|
407
|
+
} | null, tierId: string): TTier | null;
|
|
408
|
+
declare function tierSpec<TTier extends {
|
|
409
|
+
compute_units: number;
|
|
410
|
+
}>(pricing: {
|
|
411
|
+
compute_unit: {
|
|
412
|
+
vcpus: number;
|
|
413
|
+
memory_mib: number;
|
|
414
|
+
disk_mib: number;
|
|
415
|
+
};
|
|
416
|
+
}, tier: TTier): TierSpec;
|
|
417
|
+
declare function buildPaymentQuote<TTier extends {
|
|
418
|
+
compute_units: number;
|
|
419
|
+
}>(tier: TTier, pricing: {
|
|
420
|
+
price: {
|
|
421
|
+
compute_unit?: {
|
|
422
|
+
credit?: string | number | null;
|
|
423
|
+
} | null;
|
|
424
|
+
};
|
|
425
|
+
}, balance: {
|
|
426
|
+
credit_balance?: number | null;
|
|
427
|
+
}): PaymentQuote | null;
|
|
428
|
+
declare function quoteRequiredBudgetUnits(quote: PaymentQuote | null): bigint;
|
|
391
429
|
declare function createInstanceContent(args: {
|
|
392
430
|
address: string;
|
|
393
431
|
name: string;
|
|
@@ -553,4 +591,4 @@ declare function verifyUcGoPeerReachability(args: {
|
|
|
553
591
|
checks: Record<string, Record<string, unknown>>;
|
|
554
592
|
}>;
|
|
555
593
|
|
|
556
|
-
export { DEFAULT_ALEPH_API_HOST, DEFAULT_ALEPH_CHANNEL, DEFAULT_COUNTRY_LOOKUP_BASE_URL, DEFAULT_CRN_LIST_URL, DEFAULT_DNS_RESOLVE_URL, DEFAULT_INSTANCE_PORT_FORWARDS, DEFAULT_IPFS_GATEWAY_BASE_URL, DEFAULT_SCHEDULER_ALLOCATION_URL, DEFAULT_TWO_N_SIX_HASH_URL, type FetchLike, type FetchLikeResponse, type HttpProbeResult, ITEM_HASH_RE, type JsonFetchLike, type JsonFetchLikeResponse, type RetentionRecord, SSH_PUBLIC_KEY_PATTERN, SUCCESSFUL_DEPLOYMENTS_AGGREGATE_KEY, type TcpProbeResult, broadcastAlephMessage, cleanupFailedDeployment, configureUcGoPeer, createDeploymentIntent, createInstanceContent, createPortForwardAggregateContent, createReleaseMetadata, createUnsignedAggregateMessage, createUnsignedForgetMessage, createUnsignedInstanceMessage, deployInstance, describeRejectedDeployment, describeRuntimeAvailability, enrichCrnsWithGeo, ensureInstancePortForwards, extractProxyUrl, extractReferenceHashes, fetch2n6WebAccessUrl, fetchAggregateKey, fetchCrnExecutionMap, fetchCrns, fetchMessageEnvelope, fetchPortForwardAggregate, fetchSchedulerAllocation, fetchUcGoPeerMetadata, fetchVmRuntime, findCrnByHash, forgetAlephMessages, inspectDeploymentResult, inspectMessageResult, isInvalidMessageFormatResponse, isRetryableBroadcastFailure, isValidSshPublicKey, listGeocodedCrns, mergePortFlagMaps, mergeRequiredPortForwards, messageTypeFromEnvelope, normalizeBroadcastStatus, normalizeExecution, normalizeExistingPortForwardEntry, normalizeMessageStatus, normalizeProxyUrl, normalizeSshPublicKey, notifyCrnAllocation, portForwardLabel, postBroadcastPayload, probeRootfsGateway, publishAggregateKey, rankCandidateCrns, requestedPortFlags, requiredInstancePortForwards, resolveRootfsReference, retainSuccessfulDeployments, selectPreferredCrn, signAlephMessage, signaturePayload, validateRootfsManifest, verifyRootfsExists, verifyUcGoPeerReachability, waitForDeploymentResult, waitForSetupEndpoint, waitForVmRuntime };
|
|
594
|
+
export { DEFAULT_ALEPH_API_HOST, DEFAULT_ALEPH_CHANNEL, DEFAULT_COUNTRY_LOOKUP_BASE_URL, DEFAULT_CRN_LIST_URL, DEFAULT_DNS_RESOLVE_URL, DEFAULT_INSTANCE_PORT_FORWARDS, DEFAULT_IPFS_GATEWAY_BASE_URL, DEFAULT_SCHEDULER_ALLOCATION_URL, DEFAULT_TWO_N_SIX_HASH_URL, type FetchLike, type FetchLikeResponse, type HttpProbeResult, ITEM_HASH_RE, type JsonFetchLike, type JsonFetchLikeResponse, type PaymentQuote, type RetentionRecord, SSH_PUBLIC_KEY_PATTERN, SUCCESSFUL_DEPLOYMENTS_AGGREGATE_KEY, type TcpProbeResult, type TierSpec, broadcastAlephMessage, buildPaymentQuote, cleanupFailedDeployment, configureUcGoPeer, createDeploymentIntent, createInstanceContent, createPortForwardAggregateContent, createReleaseMetadata, createUnsignedAggregateMessage, createUnsignedForgetMessage, createUnsignedInstanceMessage, deployInstance, describeRejectedDeployment, describeRuntimeAvailability, enrichCrnsWithGeo, ensureInstancePortForwards, extractProxyUrl, extractReferenceHashes, fetch2n6WebAccessUrl, fetchAggregateKey, fetchCrnExecutionMap, fetchCrns, fetchMessageEnvelope, fetchPortForwardAggregate, fetchSchedulerAllocation, fetchUcGoPeerMetadata, fetchVmRuntime, findCrnByHash, forgetAlephMessages, inspectDeploymentResult, inspectMessageResult, isInvalidMessageFormatResponse, isRetryableBroadcastFailure, isValidSshPublicKey, listGeocodedCrns, mergePortFlagMaps, mergeRequiredPortForwards, messageTypeFromEnvelope, normalizeBroadcastStatus, normalizeExecution, normalizeExistingPortForwardEntry, normalizeMessageStatus, normalizeProxyUrl, normalizeSshPublicKey, notifyCrnAllocation, portForwardLabel, postBroadcastPayload, probeRootfsGateway, publishAggregateKey, quoteRequiredBudgetUnits, rankCandidateCrns, requestedPortFlags, requiredInstancePortForwards, resolveRootfsReference, retainSuccessfulDeployments, selectPreferredCrn, selectedTier, signAlephMessage, signaturePayload, tierSpec, validateRootfsManifest, verifyRootfsExists, verifyUcGoPeerReachability, waitForDeploymentResult, waitForSetupEndpoint, waitForVmRuntime };
|
package/index.js
CHANGED
|
@@ -1210,6 +1210,11 @@ async function ensureInstancePortForwards(args) {
|
|
|
1210
1210
|
|
|
1211
1211
|
// src/instance-deployment.ts
|
|
1212
1212
|
var SSH_PUBLIC_KEY_PATTERN = /^(ssh-rsa|ssh-ed25519|ecdsa-sha2-nistp256|ecdsa-sha2-nistp384|ecdsa-sha2-nistp521|sk-ssh-ed25519@openssh\.com|sk-ecdsa-sha2-nistp256@openssh\.com)\s+[A-Za-z0-9+/]+={0,3}(?:\s+.+)?$/;
|
|
1213
|
+
function toFiniteNumber(value) {
|
|
1214
|
+
if (typeof value === "number") return value;
|
|
1215
|
+
if (typeof value === "string" && value.trim()) return Number(value);
|
|
1216
|
+
return Number.NaN;
|
|
1217
|
+
}
|
|
1213
1218
|
function normalizeSshPublicKey(value) {
|
|
1214
1219
|
return value.split(/\r?\n/g).map((line) => line.trim()).filter(Boolean).join(" ").replace(/\s+/g, " ").trim();
|
|
1215
1220
|
}
|
|
@@ -1223,6 +1228,33 @@ function createReleaseMetadata(name, rootfsVersion, deployer = "shared-aleph-too
|
|
|
1223
1228
|
deployer
|
|
1224
1229
|
};
|
|
1225
1230
|
}
|
|
1231
|
+
function selectedTier(pricing, tierId) {
|
|
1232
|
+
return pricing?.tiers.find((tier) => tier.id === tierId) ?? null;
|
|
1233
|
+
}
|
|
1234
|
+
function tierSpec(pricing, tier) {
|
|
1235
|
+
return {
|
|
1236
|
+
vcpus: pricing.compute_unit.vcpus * tier.compute_units,
|
|
1237
|
+
memoryMiB: pricing.compute_unit.memory_mib * tier.compute_units,
|
|
1238
|
+
diskMiB: pricing.compute_unit.disk_mib * tier.compute_units
|
|
1239
|
+
};
|
|
1240
|
+
}
|
|
1241
|
+
function buildPaymentQuote(tier, pricing, balance) {
|
|
1242
|
+
const computeUnitPrice = pricing.price.compute_unit;
|
|
1243
|
+
if (!computeUnitPrice) return null;
|
|
1244
|
+
const unitPrice = toFiniteNumber(computeUnitPrice.credit);
|
|
1245
|
+
if (!Number.isFinite(unitPrice)) return null;
|
|
1246
|
+
return {
|
|
1247
|
+
required: unitPrice * tier.compute_units,
|
|
1248
|
+
available: Number(balance.credit_balance ?? 0),
|
|
1249
|
+
computeUnits: tier.compute_units,
|
|
1250
|
+
unitPrice,
|
|
1251
|
+
label: "credits"
|
|
1252
|
+
};
|
|
1253
|
+
}
|
|
1254
|
+
function quoteRequiredBudgetUnits(quote) {
|
|
1255
|
+
if (!quote) return 0n;
|
|
1256
|
+
return BigInt(Math.ceil(quote.required * 1e18));
|
|
1257
|
+
}
|
|
1226
1258
|
function createInstanceContent(args) {
|
|
1227
1259
|
const sshKey = normalizeSshPublicKey(args.sshPublicKey);
|
|
1228
1260
|
if (!sshKey) {
|
|
@@ -1785,6 +1817,7 @@ export {
|
|
|
1785
1817
|
SSH_PUBLIC_KEY_PATTERN,
|
|
1786
1818
|
SUCCESSFUL_DEPLOYMENTS_AGGREGATE_KEY,
|
|
1787
1819
|
broadcastAlephMessage,
|
|
1820
|
+
buildPaymentQuote,
|
|
1788
1821
|
cleanupFailedDeployment,
|
|
1789
1822
|
configureUcGoPeer,
|
|
1790
1823
|
createDeploymentIntent,
|
|
@@ -1832,14 +1865,17 @@ export {
|
|
|
1832
1865
|
postBroadcastPayload,
|
|
1833
1866
|
probeRootfsGateway,
|
|
1834
1867
|
publishAggregateKey,
|
|
1868
|
+
quoteRequiredBudgetUnits,
|
|
1835
1869
|
rankCandidateCrns,
|
|
1836
1870
|
requestedPortFlags,
|
|
1837
1871
|
requiredInstancePortForwards,
|
|
1838
1872
|
resolveRootfsReference,
|
|
1839
1873
|
retainSuccessfulDeployments,
|
|
1840
1874
|
selectPreferredCrn,
|
|
1875
|
+
selectedTier,
|
|
1841
1876
|
signAlephMessage,
|
|
1842
1877
|
signaturePayload,
|
|
1878
|
+
tierSpec,
|
|
1843
1879
|
validateRootfsManifest,
|
|
1844
1880
|
verifyRootfsExists,
|
|
1845
1881
|
verifyUcGoPeerReachability,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@le-space/core",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.34",
|
|
4
4
|
"description": "Reusable Aleph deployment, runtime, and guest lifecycle logic.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -16,6 +16,6 @@
|
|
|
16
16
|
"access": "public"
|
|
17
17
|
},
|
|
18
18
|
"dependencies": {
|
|
19
|
-
"@le-space/shared-types": "0.1.
|
|
19
|
+
"@le-space/shared-types": "0.1.34"
|
|
20
20
|
}
|
|
21
21
|
}
|