MCPcopy Create free account
hub / github.com/atomicdata-dev/atomic-data-browser / renameSubject

Method renameSubject

lib/src/store.ts:262–274  ·  view source on GitHub ↗

* Changes the Subject of a Resource. Checks if the new name is already taken, * errors if so.

(oldSubject: string, newSubject: string)

Source from the content-addressed store, hash-verified

260 * errors if so.
261 */
262 async renameSubject(oldSubject: string, newSubject: string): Promise<void> {
263 tryValidURL(newSubject);
264 const old = this.resources.get(oldSubject);
265 if (old == undefined) {
266 throw Error(`Old subject does not exist in store: ${oldSubject}`);
267 }
268 if (await this.checkSubjectTaken(newSubject)) {
269 throw Error(`New subject name is already taken: ${newSubject}`);
270 }
271 old.setSubject(newSubject);
272 this.resources.set(newSubject, old);
273 this.removeResource(oldSubject);
274 }
275
276 /**
277 * Sets the current Agent, used for signing commits. Warning: doing this

Callers 1

handleSetSubjectFunction · 0.80

Calls 6

checkSubjectTakenMethod · 0.95
removeResourceMethod · 0.95
tryValidURLFunction · 0.90
getMethod · 0.80
setSubjectMethod · 0.80
setMethod · 0.80

Tested by

no test coverage detected