MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / getUniqueSecretId

Function getUniqueSecretId

packages/react/src/plugins/secret-id.tsx:27–41  ·  view source on GitHub ↗
(
  baseName: string,
  existingSecretIds: Iterable<string>,
  fallbackId = "secret",
)

Source from the content-addressed store, hash-verified

25}
26
27export function getUniqueSecretId(
28 baseName: string,
29 existingSecretIds: Iterable<string>,
30 fallbackId = "secret",
31): string {
32 const baseId = slugifyForSecretId(baseName) || fallbackId;
33 if (!baseId) return "";
34 if (!isSecretIdTaken(baseId, existingSecretIds)) return baseId;
35
36 let suffix = 2;
37 while (isSecretIdTaken(`${baseId}-${suffix}`, existingSecretIds)) {
38 suffix += 1;
39 }
40 return `${baseId}-${suffix}`;
41}

Callers 2

SecretFormProviderFunction · 0.90
secret-id.test.tsFile · 0.90

Calls 2

slugifyForSecretIdFunction · 0.85
isSecretIdTakenFunction · 0.85

Tested by

no test coverage detected