UNPKG

@apillon/sdk

Version:

▶◀ Apillon SDK for NodeJS ▶◀

67 lines 2.4 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Ipns = void 0; const apillon_1 = require("../../lib/apillon"); const apillon_api_1 = require("../../lib/apillon-api"); const apillon_logger_1 = require("../../lib/apillon-logger"); class Ipns extends apillon_1.ApillonModel { /** * Constructor which should only be called via StorageBucket class. * @param bucketUuid Unique identifier of the file's bucket. * @param ipnsUuid Unique identifier of the IPNS record. * @param data Data to populate the IPNS record with. */ constructor(bucketUuid, ipnsUuid, data) { super(ipnsUuid); /** * Informational IPNS name, which is set by user to easily organize their IPNS records. */ this.name = null; /** * IPNS record description. */ this.description = null; /** * IPNS name that is used to access IPNS content on IPFS gateway. */ this.ipnsName = null; /** * IPFS value (CID), to which this IPNS points. */ this.ipnsValue = null; /** * IPNS link to Apillon IPFS gateway, where it is possible to see content to which this IPNS points. */ this.link = null; /** * Unique identifier of the IPNS record's bucket. */ this.bucketUuid = null; this.bucketUuid = bucketUuid; this.API_PREFIX = `/storage/buckets/${bucketUuid}/ipns/${ipnsUuid}`; this.populate(data); } /** * Publish an IPNS record to IPFS and link it to a CID. * @param {string} cid - CID to which this ipns name will point. * @returns IPNS record with updated data after publish */ async publish(cid) { const data = await apillon_api_1.ApillonApi.post(`${this.API_PREFIX}/publish`, { cid, }); apillon_logger_1.ApillonLogger.log('IPNS record published successfully'); return this.populate(data); } /** * Delete an IPNS record from the bucket. * @returns Deleted IPNS record */ async delete() { const data = await apillon_api_1.ApillonApi.delete(this.API_PREFIX); apillon_logger_1.ApillonLogger.log('IPNS record deleted successfully'); return this.populate(data); } } exports.Ipns = Ipns; //# sourceMappingURL=ipns.js.map