ai.util
함수
방법 | 매개변수 | 반품 | 설명 |
|---|---|---|---|
apply( obj, config ) |
| 오브젝트 | config의 모든 속성을 obj에 복사하고 obj를 반환합니다. |
decodeBase64( encodedBase64 )
2018.3에서 사용가능 |
Base64로 인코딩된 문자열입니다. 예: dGV4dA== | String | 디코딩된 Base64 문자열을 반환합니다.
텍스트 |
decodeHtml( encodedHtml )
2018.3에서 사용가능 |
HTML 리터럴에서 사용하기 위해 예약 문자가 번역된 문자열입니다. 안녕하세요 <b> [ there] >words<! | String | 문자열을 원시 HTML로 반환합니다.
'Hello <b> [ there] >단어<!' |
decodeUrl( encodedUrl )
2018.3에서 사용가능 |
HTML로 인코딩된 URL이 포함된 문자열입니다. 예: https%3a%2f%2fwww.example.com%2ffings%2f%3fid%3d123%26more%3dwords%23hash | String | 원시 URL이 포함된 문자열을 반환합니다.
https://www.example.com/fings/?id=123&more=words#hash |
decrypt( encryptedText ) |
| String | 해독된 원래의 일반 텍스트 문자열을 반환합니다.
ai.util.decrypt() 함수 암호화 프로세스 역순으로 수행하며, 암호화된 문자열(일반적으로 저장된 비밀번호 또는 API 키)을 사용하여 원래의 일반 텍스트 형식으로 다시 변환합니다. 그러면 CCDS(커스텀 클라우드 데이터 소스) 스크립트 내에서 외부 시스템 또는 API 이 방법을 설정하려면 먼저 PGP(Pretty Good Privacy) 암호화를 설정합니다. 참조PGP 암호화 설정 . |
encodeBase64( rawBase64 )
2018.3에서 사용가능 |
텍스트가 있는 문자열입니다. 예: 텍스트 | String | 텍스트를 Base64로 인코딩합니다.
dGV4dA== |
encodeHtml( rawHtml )
2018.3에서 사용가능 |
원시 HTML이 포함된 문자열입니다. 예: 'Hello <b> [ there] >단어<!' | String | HTML 리터럴에서 사용하기 위해 예약 문자가 번역된 문자열을 반환합니다.
안녕하세요 <b> [ there] >words<! |
EncodeUrl( rawUrl )
2018.3에서 사용가능 |
원시 URL이 포함된 문자열 예: https://www.example.com/fins/?id=123&more=words#hash | String | 원시 URL을 인코딩된 HTML로 반환합니다.
https%3a%2f%2fwww.example.com%2ffings%2f%3fid%3d123%26more%3dwords%23hash |
암호화( textToEncrypt ) |
| String | 입력 문자열의 암호화된 표현을 반환합니다. 이 출력은 일반 텍스트 대신 민감한 자격증명을 저장하거나 전달하는 데 사용해야 합니다.
ai.util.encrypt() 함수 제공된 일반 텍스트 문자열에 암호화 알고리즘( Workday Adaptive Planning 플랫폼에서 관리)을 적용합니다. 이는 주로 커스텀 클라우드 데이터 소스(CCDS) 스크립트에서 자격증명을 통합 설정에서 구성 매개변수로 저장하기 전에 자격증명을 보호하는 데 사용됩니다. 이 방법을 설정하려면 먼저 PGP(Pretty Good Privacy) 암호화를 설정합니다. 참조PGP 암호화 설정 . |
format ( formatString, arg1, arg2....argN ) |
| String | 토큰화된 문자열을 정의하고 토큰을 대체할 임의의 수의 인수를 전달하는 데 사용됩니다. 각 토큰 고유해야 하며 {0}, {1} 등의 형식으로 증분되어야 합니다. |
isDate( value ) |
| 부울 | 전달된 값이 JavaScript Date 오브젝트인 경우 true를 반환합니다. |
isUndefined( value ) |
| 부울 | 전달된 값이 '정의되지 않음'이면 true를 반환합니다. |
isDefined( value ) |
| 부울 | 전달된 값이 '정의되지 않음'이 아니면 true를 반환합니다. |
isArray( value ) |
| 부울 | 전달된 값이 JavaScript 배열이면 true를 반환하고, 그렇지 않으면 false를 반환합니다. |
isString( value ) |
| 부울 | 전달된 값이 문자열이면 true를 반환합니다. |
isNumber( value ) |
| 부울 | 전달된 값이 숫자이고 유한한 경우 true를 반환합니다. |
isBoolean( value ) |
| 부울 | 전달된 값이 true 또는 false이면 true를 반환합니다. |
toArray( a, i, j ) | 배열 | ||
isPrimitive( value ) |
| 부울 | 전달된 값이 문자열, 숫자 또는 부울이면 true를 반환합니다. |
예
//Example for ai.util.apply var sourceObj = {department:"Engineering"}; var destObj={}; ai.util.apply(destObj,sourceObj); ai.log.logInfo("Source Properties applied to Destination object: "+JSON.stringify(destObj)); // Source Properties applied to destination object: {department:Engineering} //Example for ai.util.decodeHtml var encodedHtml = "Hello <b> [there] >words<!"; var decodedvalue=ai.util.decodeHtml(encodedHtml); ai.log.logInfo("Decoded HTML is " +decodedvalue); // Decoded HTML is Hello [there] >words //Example for ai.util.encodeHtml var rawHtml = "Hello <b> [there] >words<!"; var encodedvalue=ai.util.encodeHtml(rawHtml); ai.log.logInfo("Encoded HTML is " +encodedvalue); // Encoded HTML is Hello <b> [there] >words<! //Example for ai.util.decodeBase64 var encodedBase64 = "VGhpcyBpcyBhIHNhbXBsZSB0ZXh0IGZvciBlbmNvZGluZw=="; var decodedbasevalue= ai.util.decodeBase64(encodedBase64); ai.log.logInfo("Decoded base64 is: "+decodedbasevalue); //Decoded base64 is:"This is a sample text for encoding" //Example for ai.util.encodeBase64 var rawBase64 = "This is a sample text for encoding"; var encodedbasevalue= ai.util.encodeBase64(rawBase64, ""); ai.log.logInfo("Encoded base64 is: "+encodedbasevalue); //Encoded base64 is:VGhpcyBpcyBhIHNhbXBsZSB0ZXh0IGZvciBlbmNvZGluZw== //Example for ai.util.encodeUrl var rawUrl = "https://docs.postman-echo.com/"; var encodedUrl=ai.util.encodeUrl(rawUrl); ai.log.logInfo("Encoded URL is: "+encodedUrl); //Encoded URL is: https%3a%2f%2fdocs.postman-echo.com%2f //Example for ai.util.decodeUrl var encodedUrl = "https%3a%2f%2fdocs.postman-echo.com%2f"; var decodedUrl=ai.util.decodeUrl(encodedUrl); ai.log.logInfo("Decoded URL is: "+decodedUrl); //Decoded URL is: https://docs.postman-echo.com/ //Example for ai.util.encrypt function testConnection(context) { var message = "-----BEGIN PGP MESSAGE-----" +"Version: GnuPG v2.0.14 (GNU/Linux)" +"Your Message" +"-----END PGP MESSAGE-----"; var text = ai.util.decrypt(message,'myPgp'); ai.log.logInfo("text message", text); return true; } //Example for ai.util.decrypt function testConnection(context) { var text = "Text to encrypt"; var encrypedPgpMessage = ai.util.encrypt(text,'myPgp'); ai.log.logInfo("encrypted message", encrypedPgpMessage ); return true; } //Example for ai.util.format var formatted=ai.util.format('How ar{0} you{1}',"e","?"); ai.log.logInfo("Formatted String is: "+formatted); //How are you? //Example for ai.util.isDate() var d = new Date(); var verifyIfDate=ai.util.isDate(d); ai.log.logInfo("Provided value is: "+verifyIfDate); //Provided value is: true //Example for ai.util.isUndefined var sampleValue; var verifyIfUndefined=ai.util.isUndefined(sampleValue); if (verifyIfUndefined) { ai.log.logInfo("Value is undefined"); } else { ai.log.logInfo("Value is defined"); } //Value is undefined //Example for ai.util.isDefined var sampleValue=6; var verifyIfDefined=ai.util.isDefined(sampleValue); ai.log.logInfo("verifyIfDefined: "+verifyIfDefined) if (verifyIfDefined) { ai.log.logInfo("Value is defined"); } else { ai.log.logInfo("Value is undefined"); } //Value is defined //Example for ai.util.isArray var sampleValue=["a","b"]; var verifyIfArray=ai.util.isArray(sampleValue); if (verifyIfArray) { ai.log.logInfo("Is is an Array"); } else { ai.log.logInfo("Not an Array"); } //It is an array //Example for ai.util.isString var sampleValue="123"; var verifyIfString=ai.util.isString(sampleValue); if (verifyIfString) { ai.log.logInfo("Is is a string"); } else { ai.log.logInfo("Not a string"); } //Example for ai.util.isNumber var sampleValue = {firstName:"Jon", lastName:"Doe"}; var verifyIfNumber=ai.util.isNumber(sampleValue); if (verifyIfNumber) { ai.log.logInfo("Is is a number"); } else { ai.log.logInfo("Not a number. Provided value is of type: "+typeof(sampleValue)); } //Not a number. Provided value is of type: object //Example for ai.util.isBoolean var sampleValue = true; var verifyIfBoolean=ai.util.isBoolean(sampleValue); if (verifyIfBoolean) { ai.log.logInfo("Value is Boolean"); } else { ai.log.logInfo("Not a Boolean. Provided value is of type: "+typeof(sampleValue)); } //Value is Boolean //Example for ai.util.isPrimitive var sampleValue = {firstName:"Jon", lastName:"Doe"}; var verifyIfPrimitive=ai.util.isPrimitive(sampleValue); if (verifyIfPrimitive) { ai.log.logInfo("Provided value is a Primitive Data Type"); } else { ai.log.logInfo("Provided value is not primitive: "+typeof(sampleValue)); } return true;