Cloud API Overview > @adpt/cloud > makeResourceName
makeResourceName() function
Creates a function for generating unique names for Adapt Elements.
Signature:
export declare function makeResourceName(invalidChars: RegExp, maxLen: number, sep?: string): (elemKey: string, elemID: string, deployID: string) => string;
Parameters
Parameter | Type | Description |
---|---|---|
invalidChars | RegExp | A regular expression that matches all invalid characters that should NOT be included in the resulting name. Must have the global flag set. For example, if only alphabetic characters and dashes are allowed, set invalidChars to: /[^a-zA-Z-]/g |
maxLen | number | The maximum allowed length of name that should be generated. |
sep | string | The separator string to be used between they key and the hash. |
Returns:
(elemKey: string, elemID: string, deployID: string) => string
Remarks
The unique names are unique by probability, based on a SHA256 hash. They are are made up of:
The Element's key, with any invalid characters removed.
A separator character (or string)
A portion of the SHA256 hash of the Element's ID and the deployID.