diff --git a/analysis/cleanup-worklog-2026-04-29.md b/analysis/cleanup-worklog-2026-04-29.md index daccdd7..e619741 100644 --- a/analysis/cleanup-worklog-2026-04-29.md +++ b/analysis/cleanup-worklog-2026-04-29.md @@ -618,6 +618,35 @@ Результат проверки: - синтаксических ошибок в `v1/Application.cfc` не обнаружено +## Обновление: собраны итоговые markdown-артефакты + +Дата фиксации: 2026-04-29. + +### Что собрано + +Созданы два итоговых файла в `analysis`: +- `analysis/source-toc-2026-04-29.md` +- `analysis/source-bundle-2026-04-29.md` + +### Принятый состав bundle + +В единый markdown включен только прикладной слой проекта: +- `health.cfm` +- `v1/Application.cfc` +- `v1/index.cfm` +- `v1/lib/*` +- `v1/resources/*` без `v1/resources/bk/*` + +Что сознательно исключено: +- `v1/taffy/*` как vendor framework, его примеры и тесты +- удаленные backup-сериализаторы из `v1/resources/bk/*` +- оставшийся `v1/etc/bk/*`, который пока выделен как backup-слой вне основного bundle + +### Результат + +- оглавление собрано отдельным компактным файлом +- единый markdown-бандл собран по актуальному прикладному CFML-слою после cleanup + ### Следующий мини-этап Для следующего такого же безопасного прохода выбраны: diff --git a/analysis/source-bundle-2026-04-29.md b/analysis/source-bundle-2026-04-29.md new file mode 100644 index 0000000..81f6a5c --- /dev/null +++ b/analysis/source-bundle-2026-04-29.md @@ -0,0 +1,9647 @@ +# Исходники svc-api-x + +Дата сборки: 2026-04-29 + +В bundle включен только прикладной слой после cleanup: корневые CFML-файлы, v1/Application.cfc, v1/lib/* и v1/resources/* без vendor Taffy и без backup-каталогов. + +## health.cfm + +```cfml + +``` + +## v1/Application.cfc + +```cfml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + this.name = hash(getCurrentTemplatePath()); + variables.framework.debugKey = "debug"; + variables.framework.reloadKey = "reload"; + variables.framework.reloadPassword = "true"; + variables.framework.reloadOnEveryRequest = true; + variables.framework.serializer = "taffy.core.nativeJsonSerializer"; + variables.framework.dashboardKey = "dashboard"; + variables.framework.disableDashboard = false; + variables.framework.unhandledPaths = "/flex2gateway"; + variables.framework.allowCrossDomain = true; + + variables.framework.docs.APIName="svc-api"; + variables.framework.docs.APIVersion="0.234"; + + variables.framework.globalHeaders = structNew(); + variables.framework.globalHeaders["Access-Control-Expose-Headers"] = "Location"; + variables.framework.globalHeaders["Access-Control-Allow-Credentials"] = "true"; + variables.framework.globalHeaders["X-Application-Version"] = variables.framework.docs.APIVersion; + + request.UNDEFINED_USR_ID=-1; + request.ANONYMOUS_USR_ID=2; + request.GUEST_USR_ID=3; + request.USER_AGENT="#variables.framework.docs.APIName# #variables.framework.docs.APIVersion# stand:#this.getStand()#"; + + request.ORCHESTRATOR_AUTH = createObject("java", "java.lang.System").getEnv("ORCHESTRATOR_AUTH"); + if (isNull(request.ORCHESTRATOR_AUTH)) { + request.ORCHESTRATOR_AUTH = "Basic ...no data"; + } + request.vault_login_url="https://vault.lk.adl.nubes.ru/v1/auth/approle/login"; + request.vault_role_id=createObject("java", "java.lang.System").getEnv("VAULT_ROLE_ID"); + request.vault_secret_id=createObject("java", "java.lang.System").getEnv("VAULT_SECRET_ID"); + + request.auth_header=""; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select value as stand from config + where name='STAND' + + + + + + + + + + + + + + + + + + + + + + + select value as stand from config + where name='STAND' + + + + + + + + + + + + + + + + + + + + + + + + + ---> + + + + + + function onTaffyRequest(verb, cfc, requestArguments, mimeExt, headers){ + /* https://docs.taffy.io/#/3.5.0 */ +/* + //allow white-listed requests through + + if (cfc == "login"){ + return true; + } + + //otherwise require a device token + if (!structKeyExists(requestArguments, "deviceToken")){ + return newRepresentation().noData().withStatus(401, "Authentication Required"); + + //and make sure it's valid + }else if (!validateToken(requestArguments.deviceToken)){ + + return newRepresentation().noData().withStatus(403, "Not Authorized"); + } + + //return representationOf(requestArguments); + //if a token is included, and valid, allow the request to continue + return true; +*/ +//////////////////////////////////////////////// +// самым грубым образом получаем данные от IDP, не обрабатывая исключения + + + //if (variables.framework.allowCrossDomain EQ "") { + //corsHeaders(); // *** нужно, чтобы variables.framework.allowCrossDomain="" иначе задвоятся заголовки + //} + + //if (UCase(arguments.verb) EQ 'OPTIONS') return newRepresentation().noData().withStatus("204","No Data").withHeaders({"Content-Type":"application/json;charset=utf-8"}); + request.stand=this.getStand(); + request.iam_service_url=this.iamServiceUrl; + + if (uCase(arguments.verb) EQ 'OPTIONS') return true; + if (lCase(arguments.cfc) EQ 'err') return true; + if (lCase(arguments.cfc) EQ 'throw') return true; + + + if (structKeyExists(headers,"Authorization")) { + request.auth_header=headers.Authorization; + } else { + return representationOf("Authorization header expected").withStatus(401); + } + var result=""; + try { + var authUrl = "#this.iamServiceUrl#/auth/user"; + var httpService = new http(method = "GET", charset = "utf-8", url = #authUrl#, timeout="5"); + httpService.addParam(type = "HEADER", name = "Accept", value = "application/json"); + httpService.addParam(type = "HEADER", name = "Authorization", value = "#request.auth_header#"); //passthrough + //writedump(authUrl);abort; + var resp = httpService.send(); + //if (resp.status_code NEQ 200) throw("IDP response not OK"); + //writedump(resp);abort; + var prefix = resp.getPrefix(); + if (prefix.status_code NEQ 200) { + //writedump(authUrl); + //writedump(resp); + var iamStatusCode = (isValid("integer", prefix.status_code)) ? val(prefix.status_code) : 500; + return representationOf( {"IAM URL"=#authUrl#, "idpResponse"=resp} ).withStatus(iamStatusCode); + //abort; + //throw("IDP response not OK"); + } + result = prefix.filecontent; + //writedump(result);abort; + } catch (e) { + + return representationOf( {"exception"=e, "idpResponse"=result} ).withStatus(200); + } + + //writeDump(result); abort; + try { + var idpUserData=deserializeJson(result); + "arguments.requestArguments.companyUid"=idpUserData.userInfo.companyId;//GUID! + "arguments.requestArguments.usrUid"=idpUserData.userInfo.contactId;//userId; //GUID! + + var usrCustomerInfo=getUsrCustomerInfo(idpUserData.userInfo.contactId, idpUserData.userInfo.companyId); + } catch (e) { + return representationOf( {"exception.Message"=e.Message, "exception.Detail"=e.Detail, "idpResponse"=result} ).withStatus(422); + } + //dump(idpUserData);dump(usrCustomerInfo);abort; + + if (lCase(arguments.cfc) EQ 'user') { + if (structIsEmpty(usrCustomerInfo)) return representationOf("User information not found").withStatus(404); + } + + if (lCase(arguments.cfc) EQ 'notification_ls') { //*** костыль: для нотификаций можно адресоваться к пользователю без контракта + if (structIsEmpty(usrCustomerInfo)) { + "arguments.requestArguments.usrId"=-1; //Integer! + "arguments.requestArguments.contragentId"=-1; //Integer + "arguments.requestArguments.contractId"=-1; //Integer + "arguments.requestArguments.specificationId"=-1; //Integer + "arguments.requestArguments.isImpersonated"=false; + "arguments.requestArguments.clientID"=""; + "arguments.requestArguments.login"=""; + + return true; + } + } + + if (structIsEmpty(usrCustomerInfo)) return representationOf("Cannot find default specification for current user #result#").withStatus(422); //это создает довольно много лишних движений при отладке + + "arguments.requestArguments.usrId"=usrCustomerInfo.usrId; //Integer + "arguments.requestArguments.contragentId"=usrCustomerInfo.contragentId; //Integer + "arguments.requestArguments.contractId"=usrCustomerInfo.contractId; //Integer + "arguments.requestArguments.specificationId"=usrCustomerInfo.specificationId; //Integer + + try { + "arguments.requestArguments.isImpersonated"=idpUserData.impersonation.is_impersonated; + } catch (e) { + "arguments.requestArguments.isImpersonated"=false; // так себе решение, надо было бы NULL + } + + try { + "arguments.requestArguments.clientID"=idpUserData.userInfo.clientID; + } catch (e) { + "arguments.requestArguments.clientID"=""; + } + + try { + "arguments.requestArguments.login"=idpUserData.userInfo.login; + } catch (e) { + "arguments.requestArguments.login"=""; + } + + return true; + + + + } + + + + + + + + + + + + + + + + + + + + + select usr_id from usr where login= + + + + + + + + + + + + #cfcatch.message# : #cfcatch.detail# + + + + + + #cfcatch.message# : #cfcatch.detail# + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select z.contragent_id, c.contract_id, s.specification_id + from contragent z + join contract c on (z.contragent_id=c.contragent_id) + join specification s on (c.contract_id=s.contract_id) + where z.external_uid= + order by s.specification_id desc + limit 1; + + + + + + select z.contragent_id + from contragent z + where z.external_uid= + + + + + + + select z.contragent_id, c.contract_id + from contragent z + join contract c on (z.contragent_id=c.contragent_id) + where z.external_uid= + + + + + + + + + + select u.usr_id, u.contragent_id, k.contragent_id as c_contragent_id + from usr u + left outer join contragent k on (u.contragent_id=k.contragent_id) + where u.idp_usr_uid= + limit 1; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + #local.resultSerialized# + + + +

Request Details:

+
+ + +
+ + + + + +
+ +``` + +## v1/index.cfm + +```cfml +this file index.cfm is a placeholder for Tomcat, it's content doesn't matter +``` + +## v1/lib/JsonSerializer.cfc + +```cfml +component + output = false + hint = "I provide a way to serialize complex ColdFusion data values as case-sensitive JavaScript Object Notation (JSON) strings." + { + //2024-06-27 modified by msyu: added server timezone + + // I return the initialized component. + public any function init() { + + // Every key is added to the full key list - used for one-time key serialization. + fullKeyList = {}; + + // Every key is added to the hint list so that we don't have to switch on the lists. + fullHintList = {}; + + // These key lists determine special data serialization. + stringKeyList = {}; + booleanKeyList = {}; + integerKeyList = {}; + floatKeyList = {}; + dateKeyList = {}; + + // These keys will NOT be used in serialization (ie. the key/value pairs will not be + // added to the serialized output). + blockedKeyList = {}; + + // Return the initialized component. + return( this ); + + } + + + // --- + // PUBLIC METHODS. + // --- + + + // I define the given key without a type. This is here to provide key-casing without caring + // about why type of data conversion takes place. Returns serializer. + public any function asAny( required string key ) { + + return( defineKey( fullKeyList, key, "any" ) ); + + } + + + // I define the given key as a boolean. Returns serializer. + public any function asBoolean( required string key ) { + + return( defineKey( booleanKeyList, key, "boolean" ) ); + + } + + + // I define the given key as a date. Returns serializer. + public any function asDate( required string key ) { + + return( defineKey( dateKeyList, key, "date" ) ); + + } + + + // I define the given key as a float / decimal. Returns serializer. + public any function asFloat( required string key ) { + + return( defineKey( floatKeyList, key, "float" ) ); + + } + + + // I define the given key as an integer. Returns serializer. + public any function asInteger( required string key ) { + + return( defineKey( integerKeyList, key, "integer" ) ); + + } + + + // I define the given key as a string. Returns serializer. + public any function asString( required string key ) { + + return( defineKey( stringKeyList, key, "string" ) ); + + } + + + // I define the key as one that should not be included in the serialized response. + public any function exclude( required string key ) { + + blockedKeyList[ key ] = true; + + return( this ); + + } + + + /** + * I serialize the given input as JavaScript Object Notation (JSON) using the case-sensitive + * values defined in the key-list. + * + * @output false + */ + public string function serialize( required any input ) { + + // Write the serialized value to the output buffer. + savecontent variable = "local.serializedInput" { + + serializeInput( input, "any" ); + + } + + return( serializedInput ); + + } + + + // --- + // PRIVATE METHODS. + // --- + + + // I define the given key within the given key list. + private any function defineKey( + required struct keyList, + required string key, + required string hint + ) { + + if ( structKeyExists( fullKeyList, key ) ) { + + throw( + type = "DuplicateKey", + message = "The key [#key#] has already been defined within the serializer.", + detail = "The current key list is: #structKeyList( fullKeyList, ', ' )#" + ); + + } + + // Add to the appropriate data-type lists. This one is used for existence checking. + keyList[ key ] = key; + + // Add all keys to the full key list as well. This one is used to store the serialization + // of the key so that it doesn't have to be recalculated each time the object is serialized. + fullKeyList[ key ] = serializeString( key ); + + // If we have a specific type, then add the hint to the full hint list as well. This will + // allow us to quickly look up the pass-through data type hint during serialization. + // -- + // NOTE: The reason we don't want to pass through "any" is that we want parent types to be + // able to "fall through" during the object traversal. If we added "any" to the type list, + // then it would always overwrite the parent data type. + if ( hint != "any" ) { + + fullHintList[ key ] = hint; + + } + + // Return this reference for method chaining. + return( this ); + + } + + + // I walk the given object, writing the serialized value to the output (which is expected to + // be a content buffer). + // --- + // NOTE: THIS METHOD IS HUGE - this is on purpose. Since serialization is a rather intense + // process, I am trying to cut out as much overhead as possible. In this case, we're cutting + // out extra stack space by inlining and duplicating a lot of functionality. This is being done + // at the COST of clarity and non-repetitive code. + private void function serializeInput( + required any input, + required string hint + ) { + + // Serialize the data base on the type of input. We are organizing this in terms of the + // most commonly-used values first. The anticipation is that the vast majority of data + // types will be simple values. + if ( isSimpleValue( input ) ) { + + if ( ( hint == "string" ) || ( hint == "any" ) ) { + + // If the string appears to be numeric, then we have to prefix it to make sure + // ColdFusion doesn't accidentally convert it to a number. + if ( isNumeric( input ) ) { + + writeOutput( """" & input & """" ); + + } else { + + serializeInputString( input ); + + } + + } else if ( ( hint == "boolean" ) && isBoolean( input ) ) { + + writeOutput( input ? "true" : "false" ); + + } else if ( ( ( hint == "integer" ) || ( hint == "float" ) ) && isNumeric( input ) ) { + + writeOutput( input ); + + } else if ( ( ( hint == "integer" ) || ( hint == "float" ) ) && isBoolean( input ) ) { + + writeOutput( input ? "1" : "0" ); + + } else if ( ( hint == "date" ) && ( isDate( input ) || isNumericDate( input ) ) ) { + + // Write the date in ISO 8601 time string format. We're going to assume that the + // date is already in the desired timezone. + ///writeOutput( """" & dateFormat( input, "yyyy-mm-dd" ) & "T" & timeFormat( input, "HH:mm:ss.l" ) & "Z""" ); + //2024-06-27 modified by msyu: added server timezone + writeOutput( """" & dateFormat( input, "yyyy-mm-dd" ) & "T" & timeFormat( input, "HH:mm:ss.lXX" ) & """" ); + + } else { + + serializeInputString( input ); + + } + + return; + + } // END: isSimpleValue(). + + + // I'm expecting the struct to be the next most common data type since it will likely be + // the container for the majority of data values. + if ( isStruct( input ) ) { + + writeOutput( "{" ); + + var isFirst = true; + + for ( var key in input ) { + + // Skip any black-listed keys. + if ( structKeyExists( blockedKeyList, key ) ) { + + continue; + + } + + // Handle the item delimiter. + if ( isFirst ) { + + isFirst = false; + + } else { + + writeOutput( "," ); + + } + + // Ensure that the given key can be referenced on the full-key list. This way, + // the subsequent logic will be easier. + if ( ! structKeyExists( fullKeyList, key ) ) { + + asAny( lcase( key ) ); + + } + + writeOutput( fullKeyList[ key ] & ":" ); + + // Pass in the most appropriate data-type hint based on the parent key. + if ( structKeyExists( fullHintList, key ) ) { + + serializeInput( input[ key ], fullHintList[ key ] ); + + // If the given key is unknown, just pass through the most recent hint as + // it may be defining the type for an entire structure. + } else { + + serializeInput( input[ key ], hint ); + + } + + } + + writeOutput( "}" ); + + return; + + } // END: isStruct(). + + + if ( isArray( input ) ) { + + writeOutput( "[" ); + + var isFirst = true; + + // Handle the item delimiter. + for ( var value in input ) { + + if ( isFirst ) { + + isFirst = false; + + } else { + + writeOutput( "," ); + + } + + // Since we don't have a key to go off of, pass-through the most recent hint. + serializeInput( value, hint ); + + } + + writeOutput( "]" ); + + return; + + } // END: isArray(). + + + // When we serialize a query, we're going to treat it like an array of structs. + if ( isQuery( input ) ) { + + var keys = listToArray( input.columnList ); + + // Make sure each column is defined as a known key - makes the subsequent logic easier. + for ( var key in keys ) { + + if ( ! structKeyExists( fullKeyList, key ) ) { + + asAny( lcase( key ) ); + + } + + } + + writeOutput( "[" ); + + // Serialize each row of the query as a struct. + for ( var i = 1 ; i <= input.recordCount ; i++ ) { + + // Handle the row delimiter. + if ( i > 1 ) { + + writeOutput( "," ); + + } + + writeOutput( "{" ); + + var isFirst = true; + + for ( var key in keys ) { + + // Skip any black-listed keys. + if ( structKeyExists( blockedKeyList, key ) ) { + + continue; + + } + + // Handle the item delimiter (in the current row). + if ( isFirst ) { + + isFirst = false; + + } else { + + writeOutput( "," ); + + } + + writeOutput( fullKeyList[ key ] & ":" ); + + // Pass in the most appropriate data-type hint based on the parent key. + if ( structKeyExists( fullHintList, key ) ) { + + serializeInput( input[ key ][ i ], fullHintList[ key ] ); + + // If the given key is unknown, just pass through the most recent hint as + // it may be defining the type for an entire structure. + } else { + + serializeInput( input[ key ][ i ], hint ); + + } + + } // END: Key list. + + writeOutput( "}" ); + + } // END: Row list. + + writeOutput( "]" ); + + return; + + } // END: isQuery(). + + + // If we made it this far, we were given a data type that we're not actively supporting. + // As such, we just have to hand this off to the native serializer. + writeOutput( serializeJson( input ) ); + + } + + + /** + * I serialize and write the given string to the current output context, escaping all appropriate + * characters for the JSON specification. + * + * NOTE: We are using this manual-encoding process rather than the built-in serializeJson() function + * as there is a rather nasty bug that corrupts certain patterns in the output. Read more: + * + * http://www.bennadel.com/blog/2842-serializejson-and-the-input-and-output-encodings-are-not-same-errors-in-coldfusion.htm + * + * @input I am the string being serialized. + */ + private void function serializeInputString( required string input ) { + + // While this may not be technically needed, this will ensure that we are not using any + // "undocumented features" of the language. If we explicitly cast to a Java string, and + // something goes wrong due to odd type-casting, it's a ColdFusion bug, at that point, not + // a logic error ;) + input = javaCast( "string", input ); + + var length = input.length(); + + writeOutput( """" ); + + for ( var i = 1 ; i <= length ; i++ ) { + + var charCode = input.codePointAt( javaCast( "int", i - 1 ) ); + + // Check for the most common case first (normal characters). + if ( + ( charCode >= 32 ) && + ( charCode != 34 ) && + ( charCode != 47 ) && + ( charCode != 92 ) && + ( charCode != 8232 ) && + ( charCode != 8233 ) + ) { + + writeOutput( chr( charCode ) ); + + // Check for the special cases next (control characters, characters that + // need to be escaped, and characters that need to be encoded nicely). + } else if ( charCode == 8 ) { + + writeOutput( "\b" ); + + } else if ( charCode == 9 ) { + + writeOutput( "\t" ); + + } else if ( charCode == 10 ) { + + writeOutput( "\n" ); + + } else if ( charCode == 12 ) { + + writeOutput( "\f" ); + + } else if ( charCode == 13 ) { + + writeOutput( "\r" ); + + } else if ( + ( charCode < 32 ) || + ( charCode == 8232 ) || + ( charCode == 8233 ) + ) { + + // For Unicode hex values, we need to enforce a 4-digit code. + writeOutput( "\u" & right( ( "000" & formatBaseN( charCode, 16 ) ), 4 ) ); + + } else if ( charCode == 34 ) { + + writeOutput( "\""" ); + + } else if ( charCode == 47 ) { + + writeOutput( "\/" ); + + } else if ( charCode == 92 ) { + + writeOutput( "\\" ); + + } + + } + + writeOutput( """" ); + + } + + + /** + * I serialize and return the given string, escaping all appropriate characters for the + * JSON specification. + * + * @input I am the string being serialized. + * @output false + */ + private string function serializeString( required string input ) { + + savecontent variable = "local.json" { + + serializeInputString( input ); + + } + + return( json ); + + } + +} +``` + +## v1/lib/TokenGenerator.cfc + +```cfml +component /*https://www.bennadel.com/blog/2976-trying-to-generate-cryptographically-strong-random-tokens-in-coldfusion.htm*/ + output = false + hint = "Генерирует случайные токены с помощью Java SecureRandom." + { + + /** + * Инициализирует генератор токенов. + * + * @output false + */ + public any function init() { + + // Реализация генератора, используемая для построения случайных токенов. + // SHA1PRNG не является алгоритмом по умолчанию во всех реализациях JVM, + // поэтому он задается явно для предсказуемого поведения. + generator = createObject( "java", "java.security.SecureRandom" ) + .getInstance( + javaCast( "string", "SHA1PRNG" ), + javaCast( "string", "SUN" ) + ) + ; + + // После инициализации нужно сгенерировать случайный байт, + // чтобы генератор сам засеялся через общий источник seed. + // Это может блокироваться до накопления достаточной энтропии, + // поэтому операция выполняется при инициализации, а не при первом использовании. + generator.nextBytes( charsetDecode( " ", "utf-8" ) ); + + // Момент следующего пересева генератора. + // Это снижает риск слишком долгой работы с одним и тем же seed. + reseedAt = getNextReseedAt(); + + return( this ); + + } + + + // Публичные методы. + + + /** + * Генерирует криптографически стойкий токен из заданного числа случайных байтов. + * Байт-массив кодируется в форму, пригодную для использования в URL. + * + * @byteCount Количество случайных байтов для генерации токена. + * @output false + */ + public string function nextToken( numeric byteCount = 32 ) { + + // Проверяем, нужен ли пересев генератора. + if ( now() >= reseedAt ) { + + // Пересев выполняется под lock, чтобы уменьшить гонки между потоками. + // Если lock не получен вовремя, поток продолжает работу с текущим состоянием генератора. + lock + name = "TokenGenerator.reseedCheck" + type = "exclusive" + timeout = 1 + throwOnTimeout = false + { + + // Повторная проверка внутри lock: другой поток мог уже обновить seed. + if ( now() >= reseedAt ) { + + reseedAt = getNextReseedAt(); + + // Новый seed добавляется к уже существующему внутреннему состоянию генератора. + generator.setSeed( generator.generateSeed( javaCast( "int", 32 ) ) ); + + } + + } + + } + + // Создаем буфер байтов, в который будут записаны случайные значения. + var byteBuffer = charsetDecode( repeatString( " ", byteCount ), "utf-8" ); + + generator.nextBytes( byteBuffer ); + + return( encodeBytes( byteBuffer ) ); + + } + + + // Приватные методы. + + + /** + * Кодирует массив байтов в строку токена. + * + * @bytes Кодируемый массив байтов. + * @output false + */ + private string function encodeBytes( required binary bytes ) { + + var token = binaryEncode( bytes, "base64" ); // *** вот поэтому длина отличается от заявленной + + // мы хотим убрать все спецсимволы, потому что мы используем токен в качестве псевдослучайного суффикса + token = replace( token, "+", "a", "all" ); + token = replace( token, "/", "b", "all" ); + token = replace( token, "=", "c", "all" ); + + return( token ); + + } + + + /** + * Вычисляет время следующего пересева генератора. + * + * @output false + */ + private date function getNextReseedAt() { + + return( dateAdd( "h", 1, now() ) ); + + } + +} +``` + +## v1/lib/encodingUtils.cfc + +```cfml +component { + + public any function init() { + variables.utcBaseDate = createObject( 'java', 'java.util.Date' ).init( javacast( 'int', 0 ) ); + variables.ECParameterSpecCache = { }; + } + + function convertDateToUnixTimestamp( required date dateToConvert ) { + return dateDiff( 's', utcBaseDate, parseDateTime( dateToConvert ) ); + } + + function convertUnixTimestampToDate( required numeric timestamp ) { + return dateAdd( 's', timestamp, utcBaseDate ); + } + + function base64UrlToBinary( base64url ) { + var base64 = base64url.replace( '-', '+', 'all' ).replace( '_', '/', 'all' ); + var padded = base64 & repeatString( '=', 4 - ( len( base64 ) % 4 ) ); + return binaryDecode( padded, 'base64' ); + } + + function binaryToBase64Url( source ) { + return binaryEncode( source, 'base64' ) + .replace( '+', '-', 'all' ) + .replace( '/', '_', 'all' ) + .replace( '=', '', 'all' ); + } + + /** + * The INTEGER encoding for DER consists of a 02 tag a length encoding of the value + * and then a signed, minimum sized, big endian encoding of the encoded number. + * + * - https://stackoverflow.com/questions/54718741/how-to-der-encode-an-ecdsa-signature + */ + function derEncodeIntegerBytes( byteArray ) { + // first remove any padding + for ( var i = 1; i <= arrayLen( byteArray ); i++ ) { + if ( byteArray[ i ] != 0 ) break; + } + var unpadded = arraySlice( byteArray, i ); + + // add sign if negative + if ( unpadded[ 1 ] < 0 ) { + unpadded.prepend( 0 ); + } + + // if len > 127 the length encoding will be wrong, but that won't happen for the supported signature sizes + var derEncoded = [ 2, unpadded.len() ]; + + derEncoded.append( unpadded, true ); + + return derEncoded; + } + + + /** + * The SEQUENCE encoding is simply a tag set to the byte value 30, the + * length encoding and then the concatenation of the two INTEGER + * structures. + * + * https://stackoverflow.com/questions/54718741/how-to-der-encode-an-ecdsa-signature + * + * Also see: + * https://crypto.stackexchange.com/questions/57731/ecdsa-signature-rs-to-asn1-der-encoding-question + */ + function convertP1363ToDER( signature ) { + var split = len( signature ) / 2; + var r = derEncodeIntegerBytes( arraySlice( signature, 1, split ) ); + var s = derEncodeIntegerBytes( arraySlice( signature, split + 1, split ) ); + + var DERSignature = [ 48 ]; + + var length = r.len() + s.len(); + + if ( length > 255 ) { + throw( + type = 'jwtcfml.InvalidSignature', + message = 'Invalid P1363 key.', + detail = 'The P1363 signature is too long.' + ); + } + + /* + The length is simply a single byte if it is smaller than 128 (or hex 80) + of the size. If it is larger then it is two byte: one byte set to 81, + which indicates that one length byte will follow, and one byte + containing the actual value. + + https://stackoverflow.com/questions/54718741/how-to-der-encode-an-ecdsa-signature + */ + if ( length > 127 ) { + DERSignature.append( -127 ); + length -= 256; + } + DERSignature.append( length ); + + DERSignature.append( r, true ); + DERSignature.append( s, true ); + + return javacast( 'byte[]', DERSignature ); + } + + function convertDERtoP1363( required any signature, required string algorithm ) { + // extract the two integers from the DER signature + // assuming a 02 tag byte followed by a single length byte since we should not see + // anything larger in the supported algorithms + var start = 3; + while ( signature[ start ] != 2 ) start++; + var r = arraySlice( signature, start + 2, signature[ start + 1 ] ); + var s = arraySlice( signature, start + 2 + r.len() + 2 ); + + if ( r[ 1 ] == 0 ) r = arraySlice( r, 2 ); + if ( s[ 1 ] == 0 ) s = arraySlice( s, 2 ); + + var lengthMap = { + ES256: 32, + ES384: 48, + ES512: 64 + }; + + var P1363Signature = [ ]; + + for ( var i = 1; i <= lengthMap[ algorithm ] - r.len(); i++ ) P1363Signature.append( 0 ); + P1363Signature.append( r, true ); + + for ( var i = 1; i <= lengthMap[ algorithm ] - s.len(); i++ ) P1363Signature.append( 0 ); + P1363Signature.append( s, true ); + + return javacast( 'byte[]', P1363Signature ); + } + + function parsePEMEncodedKey( required string pemKey ) { + if ( reFind( '^-----BEGIN (RSA|EC) (PARAMETERS|PRIVATE)', pemKey ) ) { + throw( + type = 'jwtcfml.InvalidPrivateKey', + message = 'Invalid private key format.', + detail = 'Please encode your private key in PKCS8 format, e.g.: `openssl pkcs8 -topk8 -nocrypt -in privatekey.pem -out privatekey.pk8' + ) + } + + var binaryKey = binaryDecode( + trim( pemKey ).reReplace( '-----[A-Z\s]+-----', '', 'all' ).reReplace( '[\r\n]', '', 'all' ), + 'base64' + ); + + if ( find( '-----BEGIN CERTIFICATE-----', pemKey ) ) { + var bis = createObject( 'java', 'java.io.ByteArrayInputStream' ).init( binaryKey ); + return createObject( 'java', 'java.security.cert.CertificateFactory' ) + .getInstance( 'X.509' ) + .generateCertificate( bis ) + .getPublicKey(); + } + + if ( find( '-----BEGIN PUBLIC KEY-----', pemKey ) ) { + var publicKeySpec = createObject( 'java', 'java.security.spec.X509EncodedKeySpec' ).init( binaryKey ); + try { + return createObject( 'java', 'java.security.KeyFactory' ) + .getInstance( 'RSA' ) + .generatePublic( publicKeySpec ); + } catch ( any e ) { + } + try { + return createObject( 'java', 'java.security.KeyFactory' ) + .getInstance( 'EC' ) + .generatePublic( publicKeySpec ); + } catch ( any e ) { + } + } + + if ( find( '-----BEGIN PRIVATE KEY-----', pemKey ) ) { + var privateKeySpec = createObject( 'java', 'java.security.spec.PKCS8EncodedKeySpec' ).init( binaryKey ); + try { + return createObject( 'java', 'java.security.KeyFactory' ) + .getInstance( 'RSA' ) + .generatePrivate( privateKeySpec ); + } catch ( any e ) { + } + try { + return createObject( 'java', 'java.security.KeyFactory' ) + .getInstance( 'EC' ) + .generatePrivate( privateKeySpec ); + } catch ( any e ) { + } + } + + throw( + type = 'jwtcfml.InvalidPEMKey', + message = 'Invalid PEM key.', + detail = 'Please ensure you are using an RSA or EC public or private key or certificate.' + ) + } + + function parseJWK( required struct jwk ) { + if ( jwk.kty == 'RSA' ) { + if ( jwk.keyExists( 'd' ) ) { + try { + var bigInts = bigIntegers( jwk, [ 'n', 'e', 'd', 'p', 'q', 'dp', 'dq', 'qi' ] ); + var keySpec = createObject( 'java', 'java.security.spec.RSAPrivateCrtKeySpec' ).init( + bigInts.n, + bigInts.e, + bigInts.d, + bigInts.p, + bigInts.q, + bigInts.dp, + bigInts.dq, + bigInts.qi + ); + var kf = createObject( 'java', 'java.security.KeyFactory' ).getInstance( 'RSA' ); + return kf.generatePrivate( keySpec ); + } catch ( any e ) { + } + + try { + var bigInts = bigIntegers( jwk, [ 'n', 'd' ] ); + var keySpec = createObject( 'java', 'java.security.spec.RSAPrivateKeySpec' ).init( + bigInts.n, + bigInts.d + ); + var kf = createObject( 'java', 'java.security.KeyFactory' ).getInstance( 'RSA' ); + return kf.generatePrivate( keySpec ); + } catch ( any e ) { + } + } else { + try { + var bigInts = bigIntegers( jwk, [ 'n', 'e' ] ); + var ks = createObject( 'java', 'java.security.spec.RSAPublicKeySpec' ).init( bigInts.n, bigInts.e ); + var kf = createObject( 'java', 'java.security.KeyFactory' ).getInstance( 'RSA' ); + return kf.generatePublic( ks ); + } catch ( any e ) { + } + } + } + + if ( jwk.kty == 'EC' ) { + var kf = createObject( 'java', 'java.security.KeyFactory' ).getInstance( 'EC' ); + var ECParameterSpec = getECParameterSpec( jwk.crv ); + + if ( jwk.keyExists( 'd' ) ) { + var bigInts = bigIntegers( jwk, [ 'd' ] ); + var ks = createObject( 'java', 'java.security.spec.ECPrivateKeySpec' ).init( + bigInts.d, + ECParameterSpec + ); + return kf.generatePrivate( ks ); + } else { + var bigInts = bigIntegers( jwk, [ 'x', 'y' ] ); + var ECPoint = createObject( 'java', 'java.security.spec.ECPoint' ).init( bigInts.x, bigInts.y ); + var ks = createObject( 'java', 'java.security.spec.ECPublicKeySpec' ).init( ECPoint, ECParameterSpec ); + return kf.generatePublic( ks ); + } + } + + throw( + type = 'jwtcfml.InvalidJWK', + message = 'Invalid JWK key.', + detail = 'Please ensure you are using an valid JWK RSA or EC public or private key.' + ) + } + + private function bigIntegers( jwk, keys ) { + var bigInts = { }; + for ( var key in keys ) { + bigInts[ key ] = createObject( 'java', 'java.math.BigInteger' ).init( 1, base64UrlToBinary( jwk[ key ] ) ); + } + return bigInts; + } + + private function getECParameterSpec( crv ) { + if ( !variables.ECParameterSpecCache.keyExists( crv ) ) { + var kpg = createObject( 'java', 'java.security.KeyPairGenerator' ).getInstance( 'EC' ); + var ecgp = createObject( 'java', 'java.security.spec.ECGenParameterSpec' ).init( + 'secp#crv.listLast( '-' )#r1' + ); + kpg.initialize( ecgp ); + variables.ECParameterSpecCache[ crv ] = kpg + .generateKeyPair() + .getPublic() + .getParams(); + } + return variables.ECParameterSpecCache[ crv ]; + } + +} + +``` + +## v1/lib/expression_parser.cfc + +```cfml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +``` + +## v1/lib/field.cfm + +```cfml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +``` + +## v1/lib/field_set.cfm + +```cfml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +``` + +## v1/lib/filter_build.cfm + +```cfml + + + + + + + + + + + + + AND #listGetAt(fltr.expression,i,"?")##fltr.field# + = <> <= < >= > LIKE ILIKE LIKE ILIKE IN () = #fltr.field# + + + + + + + + + + + + + + + + + + + + + + + + + + + + +``` + +## v1/lib/index.cfm + +```cfml +index *** +``` + +## v1/lib/jwt.cfc + +```cfml +component { + + variables.algorithmMap = { + HS256: 'HmacSHA256', + HS384: 'HmacSHA384', + HS512: 'HmacSHA512', + RS256: 'SHA256withRSA', + RS384: 'SHA384withRSA', + RS512: 'SHA512withRSA', + ES256: 'SHA256withECDSA', + ES384: 'SHA384withECDSA', + ES512: 'SHA512withECDSA' + }; + + public any function init() { + variables.encodingUtils = new encodingUtils(); + variables.jss = createObject( 'java', 'java.security.Signature' ); + variables.messageDigest = createObject( 'java', 'java.security.MessageDigest' ); + return this; + } + + public string function encode( + required struct payload, + required any key, + required string algorithm, + struct headers = { } + ) { + if ( !algorithmMap.keyExists( algorithm ) ) { + throw( + type = 'jwtcfml.InvalidAlgorithm', + message = 'Invalid JWT Algorithm.', + detail = 'The passed in algorithm is not supported.' + ); + } + + var header = { }; + header.append( headers ); + header.append( { + 'typ': 'JWT', + 'alg': algorithm + } ); + + var duplicatedPayload = duplicate( payload ); + for ( var claim in [ 'iat', 'exp', 'nbf' ] ) { + if ( duplicatedPayload.keyExists( claim ) && isDate( duplicatedPayload[ claim ] ) ) { + duplicatedPayload[ claim ] = encodingUtils.convertDateToUnixTimestamp( duplicatedPayload[ claim ] ); + } + } + + var stringToSignParts = [ + encodingUtils.binaryToBase64Url( charsetDecode( serializeJSON( header ), 'utf-8' ) ), + encodingUtils.binaryToBase64Url( charsetDecode( serializeJSON( duplicatedPayload ), 'utf-8' ) ) + ]; + var stringToSign = stringToSignParts.toList( '.' ); + + return stringToSign & '.' & encodingUtils.binaryToBase64Url( sign( stringToSign, key, algorithm ) ); + } + + public struct function decode( + required string token, + any key, + any algorithms = [ ], + struct claims = { }, + boolean verify = true + ) { + var parts = listToArray( token, '.' ); + + if ( arrayLen( parts ) != 3 ) { + throw( + type = 'jwtcfml.InvalidToken', + message = 'Invalid JWT.', + detail = 'The passed in token does not have three `.` delimited parts.' + ); + } + + algorithms = isArray( algorithms ) ? algorithms : [ algorithms ]; + + var decoded = { + header: deserializeJSON( charsetEncode( encodingUtils.base64UrlToBinary( parts[ 1 ] ), 'utf-8' ) ), + payload: deserializeJSON( charsetEncode( encodingUtils.base64UrlToBinary( parts[ 2 ] ), 'utf-8' ) ) + }; + + if ( verify ) { + if ( + !algorithms.find( decoded.header.alg ) || + !algorithmMap.keyExists( decoded.header.alg ) + ) { + throw( + type = 'jwtcfml.InvalidAlgorithm', + message = 'Unsupported or invalid algorithm', + detail = 'The passed in token does not have an algorithm declaration or its declared algorithm (#decoded.header.alg#) does not match the specified algorithms of #serializeJSON( algorithms )#.' + ); + } + + var stringToSign = parts[ 1 ] & '.' & parts[ 2 ]; + var signature = encodingUtils.base64UrlToBinary( parts[ 3 ] ); + + if ( + !verifySignature( + stringToSign, + key, + signature, + decoded.header.alg + ) + ) { + throw( + type = 'jwtcfml.InvalidSignature', + message = 'Signature is Invalid', + detail = 'The signature of the passed in token is invalid.' + ); + } + + var baseClaims = { + 'exp': true, + 'nbf': true + }; + baseClaims.append( claims ); + verifyClaims( decoded.payload, baseClaims ); + } + + for ( var claim in [ 'iat', 'exp', 'nbf' ] ) { + if ( decoded.payload.keyExists( claim ) ) { + decoded.payload[ claim ] = encodingUtils.convertUnixTimestampToDate( decoded.payload[ claim ] ); + } + } + + return decoded.payload; + } + + public struct function getHeader( required string token ) { + return deserializeJSON( charsetEncode( encodingUtils.base64UrlToBinary( listFirst( token, '.' ) ), 'utf-8' ) ); + } + + public function parsePEMEncodedKey( required string pemKey ) { + return encodingUtils.parsePEMEncodedKey( pemKey ); + } + + public function parseJWK( required struct jwk ) { + return encodingUtils.parseJWK( jwk ); + } + + private function sign( message, key, algorithm ) { + if ( left( algorithm, 1 ) == 'H' ) { + var sig = binaryDecode( + hmac( + message, + key, + algorithmMap[ algorithm ], + 'utf-8' + ), + 'hex' + ); + } else { + if ( isSimpleValue( key ) ) { + key = encodingUtils.parsePEMEncodedKey( key ); + } else if ( isStruct( key ) ) { + key = encodingUtils.parseJWK( key ); + } + + var jssInstance = variables.jss.getInstance( algorithmMap[ algorithm ] ); + jssInstance.initSign( key ); + jssInstance.update( charsetDecode( message, 'utf-8' ) ); + var sig = jssInstance.sign(); + if ( left( algorithm, 1 ) == 'E' ) { + sig = encodingUtils.convertDERtoP1363( sig, algorithm ); + } + } + return sig; + } + + private function verifySignature( message, key, signature, algorithm ) { + if ( left( algorithm, 1 ) == 'H' ) { + var sig = binaryDecode( + hmac( + message, + key, + algorithmMap[ algorithm ], + 'utf-8' + ), + 'hex' + ); + return MessageDigest.isEqual( signature, sig ); + } + + if ( left( algorithm, 1 ) == 'E' ) { + signature = encodingUtils.convertP1363ToDER( signature ); + } + + if ( isSimpleValue( key ) ) { + key = encodingUtils.parsePEMEncodedKey( key ); + } else if ( isStruct( key ) ) { + key = encodingUtils.parseJWK( key ); + } + + var jssInstance = variables.jss.getInstance( algorithmMap[ algorithm ] ); + jssInstance.initVerify( key ); + jssInstance.update( charsetDecode( message, 'utf-8' ) ); + return jssInstance.verify( signature ); + } + + private function verifyClaims( payload, claims ) { + if ( + structKeyExists( payload, 'exp' ) + && !verifyDateClaim( payload.exp, claims.exp, -1 ) + ) { + throw( + type = 'jwtcfml.ExpiredSignature', + message = 'Token has expired', + detail = 'The passed in token has expired.' + ); + } + + if ( + structKeyExists( payload, 'nbf' ) + && !verifyDateClaim( payload.nbf, claims.nbf, 1 ) + ) { + throw( + type = 'jwtcfml.NotBeforeException', + message = 'Token is not valid', + detail = 'The passed in token has not yet become valid.' + ); + } + + + + if ( structKeyExists( claims, 'iss' ) ) { + if ( !structKeyExists( payload, 'iss' ) || compare( payload.iss, claims.iss ) != 0 ) { + throw( + type = 'jwtcfml.InvalidIssuer', + message = 'Token has an invalid issuer', + detail = 'The passed in token either does not specify an issuer or the claimed issuer is not valid.' + ); + } + } + + if ( structKeyExists( claims, 'aud' ) ) { + var audArray = isArray( claims.aud ) ? claims.aud : [ claims.aud ]; + if ( !structKeyExists( payload, 'aud' ) || !audArray.find( payload.aud ) ) { + throw( + type = 'jwtcfml.InvalidAudience', + message = 'Token has an invalid audience', + detail = 'The passed in token either does not specify an audience or the claimed audience is not valid.' + ); + } + } + } + + private function verifyDateClaim( payloadDate, claim, failState ) { + var pd = encodingUtils.convertUnixTimestampToDate( payloadDate ); + var cd = claim; + if ( !isBoolean( cd ) || cd ) { + if ( isNumeric( cd ) ) { + cd = encodingUtils.convertUnixTimestampToDate( cd ); + } else if ( !isDate( cd ) ) { + cd = now(); + } + return dateCompare( pd, cd ) != failState; + } + return true; + } + +} + +``` + +## v1/lib/notifier.cfc + +```cfml + + + + + + + + + + + + + + + + + + + + + + + + + +``` + +## v1/lib/order_build.cfm + +```cfml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +``` + +## v1/lib/rest_api_helper.cfc + +```cfml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +``` + +## v1/resources/available_resource_realms.cfc + +```cfml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select + + s.specification_id + s.specification + c.contract_id + c.contract + u.usr_id + u.login + z.contragent_id + z.contragent + z.external_code + + from specification s + left outer join contract c on (s.contract_id=c.contract_id) + left outer join usr u on (c.contragent_id=u.contragent_id) + left outer join contragent z on (u.contragent_id=z.contragent_id) + where u.usr_id= + order by specification_id desc; + + + + + + + + + + + + + + + + + + + + + + + + + + + + +``` + +## v1/resources/bookmark.cfc + +```cfml + + + + + + + + + + + + + + + + + + + + + + + select + + b.bookmark_uid::text as bookmark_uid + b.bookmark + b.descr + b.url + b.icon_url + b.contragent_id + b.sort + b.is_enabled + to_char(b.dt_created, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as dt_created + to_char(b.dt_updated, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as dt_updated + + from bookmark b + where b.bookmark_uid= + AND (b.contragent_id = OR b.contragent_id=-1) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + update bookmark set + dt_updated= + ,updater_id= + + ,bookmark= + + + ,descr= + + + ,url= + + + ,icon_url= + + + ,sort= + + + ,is_enabled= + + where + contragent_id= + AND bookmark_uid=; + + + + + + + + + + + + + + + + +``` + +## v1/resources/bookmark_ls.cfc + +```cfml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select + + b.bookmark_uid::text as bookmark_uid + b.bookmark + b.descr + b.url + b.icon_url + b.contragent_id + b.sort + b.is_enabled + to_char(b.dt_created, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as dt_created + to_char(b.dt_updated, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as dt_updated + + from bookmark b + where 1=1 + AND (b.contragent_id = + OR b.contragent_id=-1)/*общая букмарка*/ + order by b.contragent_id desc, b.sort asc + limit #maxrows# + + + + select count(*) as cnt + from bookmark b + where 1=1 + AND (b.contragent_id = ) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + insert into bookmark ( + bookmark_uid,contragent_id, bookmark,url,icon_url,descr,sort,is_enabled,dt_created,creator_id + ) values ( + + , + , + , + , + , + , + , + , + , + ); + + + + + + + + + + + + function plain2htm(s) { + return replace(replace(s, chr(13),'',"ALL"),chr(10),'
', "ALL"); + } + + function htm2plain(s) { + return replaceNoCase(s, '
', '#chr(13)##chr(10)#', "ALL"); + } + + function cleanHtm(s) { + return replaceList(s, '<,>,"', '<,>,"'); + } +
+ + + + + + + + + + + +
+``` + +## v1/resources/catalog_service_ls.cfc + +```cfml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select + + service_id + business_line_id + business_line + area_id + area + area_code + analytic_code + abstract_service_id + abstract_service + abstract_service_code + abstract_service_status_id + abstract_service_status + service_code + service + modifier + modifier_code + measure_id + service_status_id + service_status + measure_short + sort + vat_perc + vat_free + vat_rate + capacity_legend + commercial_note + is_published + dt_load + + from service_catalog.service s + where 1=1 + order by analytic_code + , abstract_service + , service_id + , coalesce(sort,0) + limit #maxrows# + + + select count(*) as cnt + from service_catalog.service s + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + function plain2htm(s) { + return replace(replace(s, chr(13),'',"ALL"),chr(10),'
', "ALL"); + } + + function htm2plain(s) { + return replaceNoCase(s, '
', '#chr(13)##chr(10)#', "ALL"); + } + + function cleanHtm(s) { + return replaceList(s, '<,>,"', '<,>,"'); + } +
+ + + + + + + + + + + +
+``` + +## v1/resources/catalog_service_param_ls.cfc + +```cfml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select + + p.service_param_id + p.service_id + p.param + p.component_code + p.component + p.measure_id + p.measure_short + p.min_value + p.max_value + p.incr + p.param_class_sort + p.param_sort + p.sku + p.is_multiple + p.dt_load + + s.business_line_id + s.business_line + s.area_id + s.area + s.area_code + s.analytic_code + s.abstract_service_id + s.abstract_service + s.abstract_service_code + s.abstract_service_status_id + s.abstract_service_status + s.service_code + s.service + s.modifier + s.modifier_code + s.service_status_id + s.service_status + s.sort + s.vat_perc + s.vat_free + s.vat_rate + s.capacity_legend + commercial_note + s.is_published + + from service_catalog.service_param p + join service_catalog.service s on (p.service_id=s.service_id) + where 1=1 + order by analytic_code + , abstract_service + , service_id + , coalesce(sort,0) + limit #maxrows# + + + select count(*) as cnt + from service_catalog.service_param p + join service_catalog.service s on (p.service_id=s.service_id) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + function plain2htm(s) { + return replace(replace(s, chr(13),'',"ALL"),chr(10),'
', "ALL"); + } + + function htm2plain(s) { + return replaceNoCase(s, '
', '#chr(13)##chr(10)#', "ALL"); + } + + function cleanHtm(s) { + return replaceList(s, '<,>,"', '<,>,"'); + } +
+ + + + + + + + + + + +
+``` + +## v1/resources/err.cfc + +```cfml + + + + + + + + + + +``` + +## v1/resources/instance.cfc + +```cfml + + + + + + + + + + + + + + + + + + + + + select + + e.instance_uid::text as instance_uid + e.display_name + e.service_id + e.descr + e.specification_item_id + e.is_auxiliary + to_char(e.dt_created, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as instance_config_dt_created + to_char(e.dt_updated, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as instance_config_dt_updated + d.contract_id + i.specification_id + s.specification + i.quantity + i.price + v.svc + v.code + v.man + + + e.updater_id + u.login as updater_login + u.shortname as updater_shortname + cast(st.instance_data->>'params' as json)->>'resourceRealm' as resource_realm + coalesce((io.dt_start IS NOT NULL AND io.dt_finish IS NULL AND io.submit_result='201'),false) as operation_is_in_progress + coalesce((io.dt_start IS NULL AND io.submit_result='201'),false) as operation_is_pending + case + when io.operation IN ('delete', 'suspend') AND io.is_successful then 0 /*null*/ + when io.is_successful then extract('epoch' from CURRENT_TIMESTAMP - coalesce(io.dt_finish,CURRENT_TIMESTAMP)) + else 0 end + as uptime + (case + when st.instance_uid IS NULL then 'not created' + when st.is_deleted = 'true' then 'deleted' + when st.is_suspended = 'true' then 'suspended' + /*when coalesce(st.is_deleted,'false') = 'false' AND coalesce(st.is_suspended, 'false') = 'false' then 'running'*/ + when coalesce(st.is_deleted,'false') = 'false' AND coalesce(st.is_suspended, 'false') = 'false' then 'running' + when io.instance_uid IS NULL then 'not configured' + else null end + ) as explained_status + + (select count(distinct r.resource_realm) + from resource_realm r + join resource_realm_access a on ( + r.resource_realm_id=a.resource_realm_id + AND (a.contract_id IN ( + select contract_id + from contract d + where d.contragent_id=k.contragent_id AND NOT d.is_closed + ) OR a.contract_id=0) /*0 means access to any contract*/ + AND a.is_enabled) + where r.resource_realm_type_id=v.resource_realm_type_id) as resource_realm_cnt + + + + from instance e + left outer join specification_item i on (e.specification_item_id=i.specification_item_id) + left outer join specification s on (i.specification_id=s.specification_id) + left outer join contract d on (s.contract_id=d.contract_id) + left outer join contragent k on (d.contragent_id=k.contragent_id) + left outer join svc v on (e.service_id=v.svc_id) + left outer join usr u on (e.updater_id=u.usr_id) + left outer join (select ist.instance_state_uid, ist.instance_uid, ist.version, ist.dt_state, ist.is_test + ,(ist.instance_data->>'isSuspended') as is_suspended + ,(ist.instance_data->>'isDeleted') as is_deleted + ,ist.instance_data + from instance_state ist join (select instance_uid, max(version) as version from instance_state group by 1) lastv + on (ist.instance_uid=lastv.instance_uid AND ist.version=lastv.version) ) st + on (e.instance_uid=st.instance_uid) + left outer join (select o.instance_operation_uid, o.instance_uid, o.operation, o.dt_submit, o.submit_result, o.dt_start, o.dt_finish, o.is_successful + from instance_operation o join (select instance_uid, max(dt_submit) as dt_submit from instance_operation group by 1) lastv + on (o.instance_uid=lastv.instance_uid AND o.dt_submit=lastv.dt_submit) ) io + on (e.instance_uid=io.instance_uid) + where e.instance_uid= + AND s.specification_id= + + + + + + + + + + select + + st.instance_state_uid::text as instance_state_uid + st.version + st.creator_id + to_char(st.dt_state, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as dt_state + st.is_test + st.instance_operation_uid::text as instance_operation_uid + + st.instance_data->>'out' as out + st.instance_data->>'params' as params + st.instance_data->>'vault' as vault + (st.instance_data->>'isDeleted')::boolean as is_deleted + (st.instance_data->>'isSuspended')::boolean as is_suspended + + from instance_state st + where st.instance_uid= + order by st.version desc + limit 1 + + + + + + + + + + + + select + + o.instance_operation_uid::text as instance_operation_uid + status.instance_state_uid::text as instance_state_uid + status.version as state_version + o.operation + o.resource_realm_id + r.resource_realm + to_char(o.dt_submit, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as dt_submit + o.submit_result + to_char(o.dt_start, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as dt_start + to_char(o.dt_finish, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as dt_finish + extract('epoch' from coalesce(o.dt_finish,CURRENT_TIMESTAMP)- o.dt_start) as duration + round(extract('epoch' from CURRENT_TIMESTAMP - coalesce(o.dt_finish,CURRENT_TIMESTAMP)),1) as seconds_passed + o.is_successful + to_char(o.dt_created, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as dt_created + o.error_log + o.note + u.login as updater_login + u.shortname as updater_shortname + coalesce((o.dt_start IS NOT NULL AND o.dt_finish IS NULL AND o.submit_result='201'),false) as is_in_progress + coalesce((o.dt_start IS NULL AND o.submit_result='201'),false) as is_pending + + from instance_operation o + left outer join usr u on (o.updater_id=u.usr_id) + left outer join resource_realm r on o.resource_realm_id=r.resource_realm_id + left outer join (select instance_operation_uid, max(version) as version from instance_state + group by instance_operation_uid) sts on (o.instance_operation_uid=sts.instance_operation_uid) + left outer join instance_state status on (sts.instance_operation_uid=status.instance_operation_uid AND sts.version=status.version) + where o.instance_uid= + --order by status.version desc + order by o.dt_created desc + + + + + + + (select io.operation from instance_operation io where io.instance_uid=e.instance_uid order by dt_submit desc limit 1) as current_operation ---> + + + + select + + so.svc_operation_id + so.operation + + (select instance_operation_uid::text + from instance_operation io + where io.instance_uid= + AND io.operation=so.operation AND io.dt_submit IS NULL + order by io.dt_created desc + limit 1 + )as instance_operation_uid + + + from svc_operation so + where so.svc_id= + + AND NOT so.operation='create' + + AND so.operation='create' + + + AND 1=0 + + order by so.svc_operation_id + + + + + + + + + + select + + p.param + sop.descr + s.svc_id + s.svc + s.code + sop.label + p.param_value as uid + r.display_name + r.is_auxiliary + c.contract_id + c.contract + to_char(c.dt_contract, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as dt_contract + k.external_code + + from instance_cfs_param p + left outer join instance_operation_cfs_param iop on (p.instance_operation_cfs_param_uid=iop.instance_operation_cfs_param_uid) + left outer join instance_operation o on (iop.instance_operation_uid=o.instance_operation_uid) + left outer join instance e on (o.instance_uid=e.instance_uid) + left outer join svc_operation so on (o.operation=so.operation AND e.service_id=so.svc_id) + left outer join svc_operation_cfs_param sop on (so.svc_operation_id=sop.svc_operation_id AND p.param=sop.svc_operation_cfs_param) + left outer join svc s on (sop.ref_svc_id=s.svc_id) + + join instance r on (p.param_value=r.instance_uid::text) + left outer join specification_item si on (r.specification_item_id=si.specification_item_id) + left outer join specification sp on (si.specification_id=sp.specification_id) + left outer join contract c on (sp.contract_id=c.contract_id) + left outer join contragent k on (c.contragent_id=k.contragent_id) + where p.instance_uid= + AND sop.ref_svc_id > 0 + order by sop.sort, p.param + + + + + select + + p.param + sop.descr + s.svc_id + s.svc + s.code + sop.label + e.instance_uid::text as uid + e.display_name + e.is_auxiliary + c.contract_id + c.contract + to_char(c.dt_contract, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as dt_contract + k.external_code + + from instance_cfs_param p + left outer join instance_operation_cfs_param iop on (p.instance_operation_cfs_param_uid=iop.instance_operation_cfs_param_uid) + left outer join instance_operation o on (iop.instance_operation_uid=o.instance_operation_uid) + left outer join instance e on (o.instance_uid=e.instance_uid) + left outer join svc s on (e.service_id=s.svc_id) + left outer join svc_operation so on (o.operation=so.operation AND e.service_id=so.svc_id) + left outer join svc_operation_cfs_param sop on (so.svc_operation_id=sop.svc_operation_id AND p.param=sop.svc_operation_cfs_param) + left outer join svc r on (sop.ref_svc_id=r.svc_id) + left outer join specification_item si on (e.specification_item_id=si.specification_item_id) + left outer join specification sp on (si.specification_id=sp.specification_id) + left outer join contract c on (sp.contract_id=c.contract_id) + left outer join contragent k on (c.contragent_id=k.contragent_id) + where + p.param_value= + AND r.svc_id=(select i.service_id + from instance i + where i.instance_uid= + ) + + + + + + + + + + + select + p.svc_operation_cfs_param + ,p.svc_operation_cfs_param_id + ,p.label + ,p.descr + ,p.is_sensitive + ,p.data_type + ,null as data_descriptor + ,(select instance_operation_cfs_param_uid from instance_operation_cfs_param iop + join svc_operation_cfs_param sop on (iop.svc_operation_cfs_param_id=sop.svc_operation_cfs_param_id) + join instance_operation io on (iop.instance_operation_uid=io.instance_operation_uid) + where sop.svc_operation_cfs_param_id=p.svc_operation_cfs_param_id AND + io.instance_uid= AND + io.instance_operation_uid= + --limit 1 + ) + from svc_operation_cfs_param p + join svc_operation o on (p.svc_operation_id=o.svc_operation_id) + join svc on (o.svc_id=svc.svc_id) + where svc.svc_id= + AND o.operation='create' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + update instance set + dt_updated= + ,updater_id= + + ,display_name= + + + + ,descr= + + where instance_uid=; + --select @@rowcount as cnt; + + + + + + + + + + + + + + + + + + + + + + + + + + + + select count(*) as cnt + from instance e + join specification_item si on (e.specification_item_id=si.specification_item_id) + where e.instance_uid= + AND si.specification_id= + + + + + + + + select count(*) as cnt + from instance_operation io + where io.dt_finish IS NULL AND + io.submit_result like '2%' /*201 etc*/ AND + io.instance_uid= + + + + + + + select count(*) as cnt + from instance_state st + where + st.instance_uid= + + + + + + + + delete from instance_state + where instance_uid=; + delete from instance_operation + where instance_uid=; + delete from instance + where instance_uid=; + + + + + + + + + + + + + + + + + + + + + + + +``` + +## v1/resources/instance_default.cfc + +```cfml + + + + + + + + + + + + + + + + + + + select + + s.svc_id + s.svc + s.descr + s.man + + from svc s + where s.svc_id= + order by 1 + + + + + + + + + + + + + + + + + + + + + + + +``` + +## v1/resources/instance_ls.cfc + +```cfml + + + + + + + + + + "monitoring_url"={prefix="inr", type="string"}, + "instance_state_uid"={prefix="inr", type="guid"}, + "is_deleted"={prefix="inr", type="string"}, + "is_suspended"={prefix="inr", type="string"}, + "job_is_pending"={prefix="inr", type="string"}, + "resource_realm"={prefix="inr", type="string"}, + "resource_realm_type_id"={prefix="inr", type="integer"}, + "operation_is_in_progress"={prefix="inr", type="boolean"}, + "operation_is_pending"={prefix="inr", type="boolean"}, + "is_test"={prefix="inr", type="boolean"}, + "is_auxiliary"={prefix="inr", type="boolean"}, + "explained_status"={prefix="inr", type="string"}, + "dt_state"={prefix="inr", type="date"}, + "version"={prefix="inr", type="integer"} + } + /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + to_char(e.dt_created, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as instance_config_dt_created + to_char(e.dt_updated, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as instance_config_dt_updated + e.instance_uid::text as instance_uid + e.display_name + e.service_id + e.specification_item_id + e.is_auxiliary + d.contract_id + i.specification_id + s.specification + i.quantity + i.price + v.svc + v.code + v.resource_realm_type_id + + e.updater_id + u.login as updater_login + u.shortname as updater_shortname + io.operation as last_operation + io.instance_operation_uid::text as last_operation_uid + io.submit_result as submit_result + + coalesce((io.dt_start IS NOT NULL AND io.dt_finish IS NULL AND io.submit_result='201'),false) as operation_is_in_progress + coalesce((io.dt_start IS NULL AND io.submit_result='201'),false) as operation_is_pending + + to_char(io.dt_start, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as operation_dt_start + to_char(io.dt_finish, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as operation_dt_finish + round(extract('epoch' from coalesce(io.dt_finish,CURRENT_TIMESTAMP)- io.dt_start),1) as duration + + case + when io.operation IN ('delete', 'suspend') AND io.is_successful then 0 /*null*/ + when io.is_successful then extract('epoch' from CURRENT_TIMESTAMP - coalesce(io.dt_finish,CURRENT_TIMESTAMP)) + else 0 end + as uptime + + to_char(io.dt_finish, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as dt_deploy + + st.instance_state_uid::text as instance_state_uid + st.is_test as is_test + coalesce(st.instance_data->>'isDeleted','false') as is_deleted + st.instance_data->>'isSuspended' as is_suspended + st.instance_data->'job'->>'pending' as job_is_pending + st.instance_data->'out'->'monitoring'->>'resourceMetrics' as monitoring_url + st.instance_data->'params'->>'resourceRealm' as resource_realm + to_char(st.dt_state, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as dt_state + + (case + when st.instance_uid IS NULL then 'not created' + when job_is_pending = 'true' then 'pending' + when st.is_deleted = 'true' then 'deleted' + when st.is_suspended = 'true' then 'suspended' + when coalesce(st.is_deleted,'false') = 'false' AND coalesce(st.is_suspended, 'false') = 'false' then 'running' + when io.instance_uid IS NULL then 'not configured' + else null end + ) as explained_status + st.version + + + + + select count(*) as cnt + from ( + select + + + '' as placeholder + + #preserveSingleQuotes(definedQueryFields)# + + from instance e + join specification_item i on (e.specification_item_id=i.specification_item_id) + join specification s on (i.specification_id=s.specification_id) + join contract d on (s.contract_id=d.contract_id) + join contragent k on (d.contragent_id=k.contragent_id) + join svc v on (e.service_id=v.svc_id) + left outer join usr u on (e.updater_id=u.usr_id) + left outer join (select ist.instance_state_uid, ist.instance_uid, ist.version, ist.dt_state, ist.is_test + ,(ist.instance_data->>'isSuspended') as is_suspended + ,(ist.instance_data->>'isDeleted') as is_deleted + ,(ist.instance_data->'job'->>'pending') as job_is_pending + ,(ist.instance_data->'out'->'monitoring'->>'resourceMetrics') as monitoring_url + ,ist.instance_data + from instance_state ist + join (select instance_uid, max(version) as version from instance_state group by 1) lastv + on (ist.instance_uid=lastv.instance_uid AND ist.version=lastv.version) + ) st on (e.instance_uid=st.instance_uid) + left outer join (select o.instance_operation_uid, o.instance_uid, o.operation, o.dt_submit, o.submit_result, o.dt_start, o.dt_finish, o.is_successful + from instance_operation o join (select instance_uid, max(dt_submit) as dt_submit from instance_operation group by 1 + ) lastv on (o.instance_uid=lastv.instance_uid AND o.dt_submit=lastv.dt_submit) + ) io on (e.instance_uid=io.instance_uid) + + where s.specification_id= + + AND ( + (e.display_name) ilike () + OR ((coalesce(v.svc,'') ||' '|| coalesce(v.svc_short,'') ||' '|| coalesce(v.synonyms,''))) ilike () + ) + + ) inr + where 1=1 + + + + + + + select + #local.fieldsToOutput#* + from ( + select + #preserveSingleQuotes(definedQueryFields)# + from instance e + join specification_item i on (e.specification_item_id=i.specification_item_id) + join specification s on (i.specification_id=s.specification_id) + join contract d on (s.contract_id=d.contract_id) + join contragent k on (d.contragent_id=k.contragent_id) + join svc v on (e.service_id=v.svc_id) + left outer join usr u on (e.updater_id=u.usr_id) + left outer join (select ist.instance_state_uid, ist.instance_uid, ist.version, ist.dt_state, ist.is_test + ,(ist.instance_data->>'isSuspended') as is_suspended + ,(ist.instance_data->>'isDeleted') as is_deleted + ,(ist.instance_data->'job'->>'pending') as job_is_pending + ,ist.instance_data + from instance_state ist join (select instance_uid, max(version) as version from instance_state group by 1) lastv + on (ist.instance_uid=lastv.instance_uid AND ist.version=lastv.version) ) st + on (e.instance_uid=st.instance_uid) + left outer join (select o.instance_operation_uid, o.instance_uid, o.operation, o.dt_submit, o.submit_result, o.dt_start, o.dt_finish, o.is_successful + from instance_operation o join (select instance_uid, max(dt_submit) as dt_submit from instance_operation group by 1) lastv + on (o.instance_uid=lastv.instance_uid AND o.dt_submit=lastv.dt_submit) ) io + on (e.instance_uid=io.instance_uid) + + where s.specification_id= + + + AND ( + (e.display_name) ilike () + OR ((coalesce(v.svc,'') ||' '|| coalesce(v.svc_short,'') ||' '|| coalesce(v.synonyms,''))) ilike () + ) + + + ) inr + where 1=1 + + order by + limit #arguments.pageSize# + offset #arguments.pageSize*(arguments.page-1)# + + + + + select count(*) as cnt + from instance e + join specification_item i on (e.specification_item_id=i.specification_item_id) + join specification s on (i.specification_id=s.specification_id) + join contract d on (s.contract_id=d.contract_id) + join contragent k on (d.contragent_id=k.contragent_id) + join svc v on (e.service_id=v.svc_id) + + left outer join (select ist.instance_state_uid, ist.instance_uid, ist.version, ist.dt_state, ist.is_test + ,(ist.instance_data->>'isSuspended') as is_suspended + ,(ist.instance_data->>'isDeleted') as is_deleted + ,ist.instance_data + from instance_state ist join (select instance_uid, max(version) as version from instance_state group by 1) lastv + on (ist.instance_uid=lastv.instance_uid AND ist.version=lastv.version) ) st + on (st.instance_uid=e.instance_uid) + left outer join (select o.instance_operation_uid, o.instance_uid, o.operation, o.dt_submit, o.submit_result, o.dt_start, o.dt_finish, o.is_successful + from instance_operation o join (select instance_uid, max(dt_submit) as dt_submit from instance_operation group by 1) lastv + on (o.instance_uid=lastv.instance_uid AND o.dt_submit=lastv.dt_submit) ) io + on (e.instance_uid=io.instance_uid) + + + where s.specification_id= + + + + + + + + + + + + + + > + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + insert into specification_item + (specification_id, specification_item, svc_id, quantity, price, dt_created, creator_id, dt_updated, updater_id) + values + ( + + , + , + , + , + , + , + , + , + ) returning specification_item_id; + + + + insert into instance + (instance_uid, display_name, service_id, specification_item_id, descr, dt_created, creator_id, dt_updated, updater_id) + values + ( + + , + , + , + , + , + , + , + , + ); + + + + + + + + + + + + + + + + + + + + + + + + + + + select count(*) as cnt from instance e + join specification_item i on (e.specification_item_id=i.specification_item_id) + join specification s on (i.specification_id=s.specification_id) + join contract d on (s.contract_id=d.contract_id) + join contragent k on (d.contragent_id=k.contragent_id) + join usr u on (k.contragent_id=u.contragent_id) + where u.usr_id= + AND lower(e.display_name)=lower() + AND e.instance_uid <> + AND (select cast(st.instance_data->>'isDeleted' as boolean) from instance_state st where st.instance_uid=e.instance_uid order by version desc limit 1) IS NOT TRUE + /*postgre specific. should take into account instances without state, ignoring explicitly deleted only*/ + + + + + + + + + + + + + + + + + + select coalesce(svc_short,svc) as svc_short from svc where svc_id= + + + + select display_name + from instance e + join specification_item i on (e.specification_item_id=i.specification_item_id) + join specification s on (i.specification_id=s.specification_id) + join contract d on (s.contract_id=d.contract_id) + join contragent k on (d.contragent_id=k.contragent_id) + join usr u on (k.contragent_id=u.contragent_id) + where u.usr_id= + AND lower(e.display_name) like lower() + AND service_id= + + + + + + + + + + + + + + + + + + + +``` + +## v1/resources/instance_operation.cfc + +```cfml + + + + + + + + + + + + + + + + + + + + + + select + + o.instance_operation_uid::text as instance_operation_uid + o.operation + o.instance_uid::text as instance_uid + to_char(o.dt_submit, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as dt_submit + o.submit_result + o.error_log + o.note + to_char(o.dt_start, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as dt_start + to_char(o.dt_finish, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as dt_finish + extract('epoch' from coalesce(o.dt_finish,CURRENT_TIMESTAMP)- o.dt_start) as duration + o.is_successful + e.display_name + e.service_id + e.specification_item_id + to_char(o.dt_created, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as dt_created + to_char(o.dt_updated, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as dt_updated + o.updater_id + u.login as updater_login + u.shortname as updater_shortname + v.svc + so.man + so.svc_operation_id + coalesce((o.dt_start IS NOT NULL AND o.dt_finish IS NULL AND o.submit_result='201'),false) as is_in_progress + coalesce((o.dt_start IS NULL AND o.submit_result='201'),false) as is_pending + + from instance_operation o + join instance e on (o.instance_uid=e.instance_uid) + join specification_item i on (e.specification_item_id=i.specification_item_id) + join specification s on (i.specification_id=s.specification_id) + join contract d on (s.contract_id=d.contract_id) + join contragent k on (d.contragent_id=k.contragent_id) + join svc v on (e.service_id=v.svc_id) + join svc_operation so on (v.svc_id=so.svc_id AND o.operation=so.operation) + left outer join usr u on (o.updater_id=u.usr_id) + where + o.instance_operation_uid= + AND s.specification_id= + + + + + + + + select + + ios.instance_operation_stage_uid::text as instance_operation_stage_uid + ios.stage + ios.is_successful + to_char(ios.dt_start, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as dt_start + to_char(ios.dt_finish, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as dt_finish + round(extract('epoch' from coalesce(ios.dt_finish,CURRENT_TIMESTAMP)- ios.dt_start),1) as duration + ios.stage_msg + + from instance_operation_stage ios + where ios.instance_operation_uid= + order by dt_start asc + + + + select + + st.instance_state_uid::text as instance_state_uid + st.version + st.creator_id + to_char(st.dt_state, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as dt_state + st.is_test + st.instance_operation_uid::text as instance_operation_uid + st.instance_data::text as instance_data + + from instance_state st + where st.instance_operation_uid= + order by st.version desc limit 1 + + + + select + + st.instance_state_uid::text as instance_state_uid + st.version + st.creator_id + to_char(st.dt_state, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as dt_state + st.is_test + st.instance_operation_uid::text as instance_operation_uid + st.instance_data::text as instance_data + + from instance_state st + where st.instance_uid= + order by st.version desc limit 1 + + + + + + + + + + + + select + + iop.instance_operation_cfs_param_uid::text as instance_operation_cfs_param_uid + sop.svc_operation_cfs_param_id + case when sop.is_sensitive then '********' else iop.param_value end as param_value + to_char(iop.dt_created, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as dt_created + iop.creator_id + sop.svc_operation_cfs_param + sop.label + sop.data_type + null as data_descriptor + ((isArray(x) OR isEmpty(x))? x : listToArray(x))#>sop.value_list + sop.ref_svc_id + + sop.func + sop.nested_ref + sop.state_path + sop.expression + sop.depends_on_cfs_params + + sop.is_required + sop.default_value + sop.regex + sop.unique_scope + sop.maxlength + sop.minlength + sop.maxvalue + sop.minvalue + sop.descr + sop.man + sop.sort + iop.note + sop.config::text as config + null as nested_ref_data + sop.is_sensitive + + from svc_operation_cfs_param sop + left outer join instance_operation_cfs_param iop + on (sop.svc_operation_cfs_param_id=iop.svc_operation_cfs_param_id + AND iop.instance_operation_uid = + ) + where sop.svc_operation_id = + order by sop.sort, sop.svc_operation_cfs_param_id + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select sop.svc_operation_cfs_param_id, sop.svc_operation_cfs_param, sop.unique_scope + from svc_operation_cfs_param sop + join instance_operation_cfs_param iop on (sop.svc_operation_cfs_param_id=iop.svc_operation_cfs_param_id) + where iop.instance_operation_uid = + + + select io.instance_uid + from instance_operation io + join instance_operation_cfs_param iop on (io.instance_operation_uid=iop.instance_operation_uid) + where iop.instance_operation_uid = + + + + + + + SELECT p.param_value, sp.svc_operation_cfs_param, re.display_name + FROM instance_operation o + JOIN instance_operation_cfs_param p on (o.instance_operation_uid=p.instance_operation_uid) + join svc_operation_cfs_param sp on (p.svc_operation_cfs_param_id=sp.svc_operation_cfs_param_id) + + JOIN instance_operation_cfs_param p2 on (p.instance_operation_uid=p2.instance_operation_uid) + JOIN instance re on (p2.param_value=re.instance_uid::text) + LEFT OUTER JOIN instance_cfs_param p3 on (re.instance_uid::text=p3.param_value) + LEFT OUTER JOIN instance_cfs_param p4 on (p3.instance_uid=p4.instance_uid AND sp.svc_operation_cfs_param=p4.param) + + WHERE p.param_value=p4.param_value + AND p.instance_operation_uid= + AND p.svc_operation_cfs_param_id= + AND p4.instance_uid <> + AND (select cast(st.instance_data->>'isDeleted' as boolean) from instance_state st where st.instance_uid=p4.instance_uid order by version desc limit 1) IS NOT TRUE + + + + + + + + + + + + + + +``` + +## v1/resources/instance_operation_cfs_param.cfc + +```cfml + + + + + + + + + + + + + + + + + + + + + + + + + + + select p.instance_operation_uid, o.instance_uid, p.svc_operation_cfs_param_id + from instance_operation_cfs_param p + join instance_operation o on (p.instance_operation_uid=o.instance_operation_uid) + where p.instance_operation_cfs_param_uid= + + + + + + + + + + select o.instance_uid + from instance_operation o + where o.instance_operation_uid= + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select p.param_value + from svc_operation_cfs_param s + join instance_operation_cfs_param p on (s.svc_operation_cfs_param_id = p.svc_operation_cfs_param_id) + where s.svc_operation_cfs_param = 'resourceRealm' + AND p.instance_operation_uid = + + + + + + + + + + + + + + + + + select r.svc_operation_cfs_param + from svc_operation_cfs_param r + join svc_operation o on (r.svc_operation_id=o.svc_operation_id) + join svc_operation_cfs_param p on (o.svc_operation_id=p.svc_operation_id) + where p.svc_operation_cfs_param_id = + AND r.ref_svc_id > 0 + + + + + + + + + + + + + + + WITH RECURSIVE r AS ( + SELECT + 1 AS i + ,e.display_name + ,s.svc + ,p.param + ,p.param_value + ,p.instance_uid::text + FROM instance e + JOIN instance_cfs_param p on (e.instance_uid=p.instance_uid) + JOIN svc s on (e.service_id=s.svc_id) + JOIN instance_operation_cfs_param op on (p.instance_operation_cfs_param_uid=op.instance_operation_cfs_param_uid) + LEFT JOIN svc_operation_cfs_param sp on (op.svc_operation_cfs_param_id=sp.svc_operation_cfs_param_id) + LEFT JOIN instance_cfs_param rp on (e.instance_uid=rp.instance_uid ) + LEFT JOIN instance ri on (rp.instance_uid=ri.instance_uid) + WHERE e.instance_uid= + + UNION + + SELECT + i+1 AS i + ,e.display_name + ,s.svc + ,p.param + ,p.param_value + ,p.instance_uid::text + FROM instance_cfs_param p + JOIN instance e on (p.instance_uid=e.instance_uid) + JOIN svc s on (e.service_id=s.svc_id) + JOIN r on (r.param_value=p.instance_uid::text) + WHERE r.i < 10 + ) + select param, param_value from r + order by r.i desc + + + + + + WITH RECURSIVE r AS ( + SELECT + 1 AS i + ,e.display_name + ,s.svc + ,sp.svc_operation_cfs_param as param + ,p.param_value::text + ,o.instance_uid::text + FROM instance e + JOIN instance_operation o ON (e.instance_uid=o.instance_uid AND o.operation='create') + JOIN instance_operation_cfs_param p on (o.instance_operation_uid=p.instance_operation_uid) + JOIN svc s on (e.service_id=s.svc_id) + --JOIN instance_operation_cfs_param op on (p.instance_operation_cfs_param_uid=op.instance_operation_cfs_param_uid) + JOIN svc_operation_cfs_param sp on (p.svc_operation_cfs_param_id=sp.svc_operation_cfs_param_id AND sp.ref_svc_id > 0) + --LEFT JOIN instance_cfs_param rp on (e.instance_uid=rp.instance_uid ) + --LEFT JOIN instance ri on (rp.instance_uid=ri.instance_uid) + WHERE e.instance_uid= + + UNION + + SELECT + i+1 AS i + ,e.display_name + ,s.svc + ,p.param + ,p.param_value + ,p.instance_uid::text + FROM instance_cfs_param p + JOIN instance e on (p.instance_uid=e.instance_uid) + JOIN svc s on (e.service_id=s.svc_id) + JOIN r on (r.param_value=p.instance_uid::text) + WHERE r.i < 10 + ) + select param, param_value from r + order by r.i desc + + + + + + + + + + + + + + + + + + + + + + + + + + this.params[arguments.param] + + + + + + select p.param_value + from instance_operation_cfs_param p + join svc_operation_cfs_param s on (p.svc_operation_cfs_param_id = s.svc_operation_cfs_param_id) + where p.instance_operation_uid = + AND s.svc_operation_cfs_param = + + + + + + + + + + + + + + + + + + + ---> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select g.instance_state_uid, g.version, g.dt_state, g.instance_data, g.is_test, g.instance_uid + from instance_state g + where g.instance_uid= + order by g.version desc + limit 1 + + + + + + + + + + + + + + + + + + + + + select r.resource_realm_id, r.properties + from resource_realm r + where r.resource_realm= + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select + + iop.instance_operation_cfs_param_uid::text as instance_operation_cfs_param_uid + iop.instance_operation_uid::text as instance_operation_uid + iop.svc_operation_cfs_param_id + + case when sop.is_sensitive then '********' else iop.param_value end as param_value + iop.note + to_char(iop.dt_created, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as dt_created + iop.creator_id + sop.svc_operation_cfs_param + sop.data_type + null as data_descriptor + ((isArray(x) OR isEmpty(x))? x : listToArray(x))#>sop.value_list + u.login as creator_login + u.shortname as creator_shortname + sop.is_sensitive + sop.is_hidden + sop.is_disabled + sop.man + + sop.func + sop.expression + sop.nested_ref + sop.state_path + sop.depends_on_cfs_params + + + sop.config::text as config + e.service_id + e.instance_uid::text as instance_uid + + from instance_operation_cfs_param iop + join svc_operation_cfs_param sop on (iop.svc_operation_cfs_param_id=sop.svc_operation_cfs_param_id) + join instance_operation io on (iop.instance_operation_uid=io.instance_operation_uid) + join instance e on (io.instance_uid=e.instance_uid) + join specification_item si on (e.specification_item_id=si.specification_item_id) + left outer join usr u on (iop.creator_id=u.usr_id) + where iop.instance_operation_cfs_param_uid= + AND si.specification_id= + + + + + + + + + + + + + + + + + + + + select g.instance_state_uid, g.version, g.instance_data, g.is_test, g.instance_uid + from instance_state g + where g.instance_uid= + order by g.version desc + limit 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select + io.dt_submit, io.submit_result + from instance_operation_cfs_param iop + join instance_operation io on iop.instance_operation_uid=io.instance_operation_uid + where iop.instance_operation_cfs_param_uid= + + + + + + + + select count(*) as cnt + from instance_operation_cfs_param iop + join instance_operation io on (iop.instance_operation_uid=io.instance_operation_uid) + join instance e on (io.instance_uid=e.instance_uid) + join specification_item si on (e.specification_item_id=si.specification_item_id) + where iop.instance_operation_cfs_param_uid= + AND si.specification_id= + + + + + + + delete from instance_operation_cfs_param + where instance_operation_cfs_param_uid= + + + + + + + + + + + + + + + + + + + + + + + + + + update instance_operation_cfs_param set + dt_created= + ,creator_id= + ,param_value= + ,note= + where instance_operation_cfs_param_uid= + + + + + + + + + + + + + + + select svc_operation_cfs_param_id + from instance_operation_cfs_param + where instance_operation_cfs_param_uid= + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select + sp.svc_operation_cfs_param_id + ,sp.svc_operation_cfs_subparam_id + ,sp.svc_operation_cfs_subparam + ,sp.label + ,sp.data_type + ,sp.value_list + ,sp.is_required + ,sp.descr + ,sp.man + ,sp.default_value + ,sp.minlength + ,sp.maxlength + ,sp.regex + ,sp.sort + ,sp.is_sensitive + ,sp.depends_on_cfs_params + ,sp.expression + ,sp.ref_svc_id + ,sp.unique_scope + ,sp.default_compute + ,sp.is_hidden + ,sp.is_disabled + from svc_operation_cfs_subparam sp + where sp.svc_operation_cfs_param_id= + order by sp.sort + + + + + select + sp.instance_operation_cfs_param_uid::text as instance_operation_cfs_param_uid + ,sp.instance_operation_cfs_subparam + ,sp.note + ,sp.sort + ,sp.is_sensitive + from instance_operation_cfs_subparam sp + where sp.instance_operation_cfs_param_uid= + order by sp.sort + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select distinct r.resource_realm, r.sort + from resource_realm r + join resource_realm_access a on + (r.resource_realm_id=a.resource_realm_id + AND (a.contract_id= + OR a.contract_id=0) /*0 means access to any contract*/ + AND a.is_enabled) + join svc s on r.resource_realm_type_id=s.resource_realm_type_id + where s.svc_id= + order by r.sort, r.resource_realm + + + + + + + + + + + + + + + + + + select iop.param_value + from instance_operation_cfs_param iop + join svc_operation_cfs_param sop on (iop.svc_operation_cfs_param_id=sop.svc_operation_cfs_param_id) + where iop.instance_operation_uid= + AND sop.svc_operation_cfs_param='resourceRealm' + order by 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select properties::text + from resource_realm + where resource_realm='ngcloud.ru' + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +``` + +## v1/resources/instance_operation_cfs_param_ls.cfc + +```cfml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select + + iop.instance_operation_cfs_param_uid::text as instance_operation_cfs_param_uid + iop.instance_operation_uid::text as instance_operation_uid + iop.svc_operation_cfs_param_id + case when sop.is_sensitive then '********' else iop.param_value end as param_value + iop.note + to_char(iop.dt_created, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as dt_created + iop.creator_id + u.login as creator_login + u.shortname as creator_shortname + sop.svc_operation_cfs_param + sop.sort + sop.is_sensitive + sop.is_required + sop.is_hidden + sop.is_disabled + sop.data_type + ((isArray(x) OR isEmpty(x))? x : listToArray(x))#>sop.value_list + sop.default_value + + sop.func + p.state_path + p.nested_ref + p.expression + sop.depends_on_cfs_params + + sop.man + null as data_descriptor + e.service_id + + from instance_operation_cfs_param iop + join instance_operation io on (iop.instance_operation_uid=io.instance_operation_uid) + join instance e on (io.instance_uid=e.instance_uid) + join specification_item si on (e.specification_item_id=si.specification_item_id) + join svc_operation_cfs_param sop on (iop.svc_operation_cfs_param_id=sop.svc_operation_cfs_param_id) + left outer join usr u on (iop.creator_id=u.usr_id) + where iop.instance_operation_uid= + AND si.specification_id= + + order by + --limit #maxrows# + + + + select count(*) as cnt + from instance_operation_cfs_param iop + where iop.instance_operation_uid= + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select io.dt_submit, io.dt_finish, io.submit_result + from instance_operation io + where io.instance_operation_uid= + + + + + + + + select e.service_id, io.operation, si.specification_id + from instance_operation io + join instance e on (io.instance_uid=e.instance_uid) + left outer join specification_item si on (e.specification_item_id=si.specification_item_id) + where io.instance_operation_uid= + + + + select so.svc_id, so.operation, sop.is_disabled + from svc_operation_cfs_param sop + join svc_operation so on (sop.svc_operation_id=so.svc_operation_id) + where sop.svc_operation_cfs_param_id= + + + + + + + + + + + + + + insert into instance_operation_cfs_param ( + instance_operation_cfs_param_uid,instance_operation_uid,svc_operation_cfs_param_id,param_value,note,dt_created,creator_id + ) values ( + + , + , + , + , + , + , + ); + + + + + + + + + + + + + + + + + + + + + + + + select sop.svc_operation_cfs_param_id + ,sop.svc_operation_cfs_param + ,sop.value_list + ,sop.data_type + ,sop.is_required + ,sop.maxlength + ,sop.minlength + ,sop.regex + ,sop.unique_scope + ,sop.maxvalue + ,sop.minvalue + from svc_operation_cfs_param sop + where sop.svc_operation_cfs_param_id= + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select count(*) as cnt + from instance_operation_cfs_param p + join instance_operation o on (p.instance_operation_uid=o.instance_operation_uid) + join instance e on (o.instance_uid=e.instance_uid) + where p.param_value= + AND p.svc_operation_cfs_param_id=/*limit to the current svc param*/ + + AND p.instance_operation_cfs_param_uid <> /*exclude itself*/ + + AND (select cast(st.instance_data->>'isDeleted' as boolean) from instance_state st where st.instance_uid=e.instance_uid order by version desc limit 1) IS NOT TRUE /*ignore deleted instances*/ + + + + + + + + + select count(*) as cnt + from instance_operation_cfs_param p + join instance_operation o on (p.instance_operation_uid=o.instance_operation_uid) + join instance e on (o.instance_uid=e.instance_uid) + join specification_item i on (e.specification_item_id=i.specification_item_id) + join specification s on (i.specification_id=s.specification_id) + join contract d on (s.contract_id=d.contract_id) + join contragent k on (d.contragent_id=k.contragent_id) + join usr u on (k.contragent_id=u.contragent_id) + where p.param_value= + AND svc_operation_cfs_param_id=/*limit to the current svc param*/ + AND u.usr_id=/*limit to the contragent of current user*/ + + AND p.instance_operation_cfs_param_uid <> /*exclude itself*/ + + AND (select cast(st.instance_data->>'isDeleted' as boolean) from instance_state st where st.instance_uid=e.instance_uid order by version desc limit 1) IS NOT TRUE /*ignore deleted instances*/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select sop.svc_operation_cfs_param_id + ,sop.svc_operation_cfs_param + from svc_operation_cfs_param sop + where sop.svc_operation_cfs_param_id= + + + + + + + select c.contract_id + from instance_operation io + join instance e on (io.instance_uid=e.instance_uid) + join specification_item si on (e.specification_item_id=si.specification_item_id) + join specification s on (si.specification_id=s.specification_id) + join contract c on (s.contract_id=c.contract_id) + where io.instance_operation_uid= + + + + select r.resource_realm_id, r.resource_realm, a.contract_id, a.is_enabled + from resource_realm r + join resource_realm_access a on (r.resource_realm_id=a.resource_realm_id) + where r.resource_realm = + AND (a.contract_id= OR a.contract_id=0) + AND a.is_enabled + + + + + + + + + + +``` + +## v1/resources/instance_operation_cfs_subparam.cfc + +```cfml + + + + + + + + + + + + + + + + + + + + + + + select + + ios.instance_operation_cfs_param_uid::text as instance_operation_cfs_param_uid + ios.instance_operation_cfs_subparam + ios.is_sensitive + ios.note + + to_char(ios.dt_created, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as dt_created + + from instance_operation_cfs_subparam ios + join instance_operation_cfs_param iop on (ios.instance_operation_cfs_param_uid=iop.instance_operation_cfs_param_uid) + join instance_operation io on (iop.instance_operation_uid=io.instance_operation_uid) + join instance e on (io.instance_uid=e.instance_uid) + join specification_item si on (e.specification_item_id=si.specification_item_id) + where ios.instance_operation_cfs_param_uid= + AND ios.instance_operation_cfs_subparam= + AND si.specification_id= /*tenant isolation, из конфиденциального тут заметки... может быть, имена переменных окружения*/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select count(*) as cnt + from instance_operation_cfs_subparam ios + where ios.instance_operation_cfs_param_uid= + AND ios.instance_operation_cfs_subparam= + + + + + + + select count(*) as cnt + from instance_operation_cfs_param iop + join instance_operation io on (iop.instance_operation_uid=io.instance_operation_uid) + join instance e on (io.instance_uid=e.instance_uid) + join specification_item si on (e.specification_item_id=si.specification_item_id) + where iop.instance_operation_cfs_param_uid= + AND si.specification_id= + + + + + + + delete from instance_operation_cfs_subparam + where instance_operation_cfs_param_uid= + AND instance_operation_cfs_subparam= + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select count(*) as cnt + from instance_operation_cfs_param iop + join instance_operation io on (iop.instance_operation_uid=io.instance_operation_uid) + join instance e on (io.instance_uid=e.instance_uid) + join specification_item si on (e.specification_item_id=si.specification_item_id) + where iop.instance_operation_cfs_param_uid= + AND si.specification_id= + + + + + + + select count(*) as cnt + from instance_operation_cfs_subparam iop + where iop.instance_operation_cfs_param_uid= + AND iop.instance_operation_cfs_subparam= + + + + + + + update instance_operation_cfs_subparam set + dt_updated= + ,updater_id= + ,is_sensitive= + ,note= + where instance_operation_cfs_param_uid= + AND instance_operation_cfs_subparam= + + + + + + +``` + +## v1/resources/instance_operation_cfs_subparam_ls.cfc + +```cfml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select count(*) as cnt + from instance_operation_cfs_param iop + join instance_operation io on (iop.instance_operation_uid=io.instance_operation_uid) + join instance e on (io.instance_uid=e.instance_uid) + join specification_item si on (e.specification_item_id=si.specification_item_id) + where iop.instance_operation_cfs_param_uid= + AND si.specification_id= + + + + + + + select count(*) as cnt + from instance_operation_cfs_subparam ios + where ios.instance_operation_cfs_param_uid= + AND ios.instance_operation_cfs_subparam= + + + + + + + insert into instance_operation_cfs_subparam + (instance_operation_cfs_param_uid, instance_operation_cfs_subparam, is_sensitive, note, dt_created, creator_id, dt_updated, updater_id) + values + ( + + , + , + , + , + , + , + , + ); + + + + + + + + + + +``` + +## v1/resources/instance_operation_default.cfc + +```cfml + + + + + + + + + + + + + + + + + + + + + + + + + + + select + + o.svc_operation_id + o.svc_id + o.operation + o.url + o.descr + o.man + + from svc_operation o + where o.svc_operation_id= + + + + + + + + + + + select instance_data->'params' as params, + instance_data::text as instance_data + from instance_state + where instance_uid= + order by version desc + limit 1 + + + + + + + + + + + + + + + select + + p.svc_operation_cfs_param_id + + p.svc_operation_cfs_param + p.label + p.data_type + null as data_descriptor + + ((isArray(x) OR isEmpty(x))? x : listToArray(x))#> p.value_list + >p.func + p.ref_svc_id + p.is_required + p.is_hidden + p.is_disabled + p.default_value + p.default_compute + p.regex + p.unique_scope + p.maxlength + p.minlength + p.maxvalue + p.minvalue + p.descr + p.man + p.sort + p.nested_ref + + p.config::text + null as nested_ref_data + p.state_path + p.depends_on_cfs_params + p.expression + ( + select 1 from svc_operation_cfs_param m + join svc_operation om on (m.svc_operation_id=om.svc_operation_id) + join svc_operation oc on (om.svc_id=oc.svc_id AND om.operation='modify' AND oc.operation='create') + join svc_operation_cfs_param c on (oc.svc_operation_id=c.svc_operation_id AND m.svc_operation_cfs_param=c.svc_operation_cfs_param) + where c.svc_operation_cfs_param_id=p.svc_operation_cfs_param_id + order by c.svc_operation_cfs_param_id + limit 1 + ) as is_modifiable + p.is_sensitive + + from svc_operation_cfs_param p + where p.svc_operation_id= + AND p.is_actual + order by p.sort, p.svc_operation_cfs_param_id + + + + + + + + + + + + + + + + + + + + + + + + + + + + select + sp.svc_operation_cfs_param_id + ,sp.svc_operation_cfs_subparam_id + ,sp.svc_operation_cfs_subparam + ,sp.label + ,sp.data_type + ,sp.value_list + ,sp.depends_on_cfs_params + ,sp.expression + ,sp.is_required + ,sp.is_hidden + ,sp.is_disabled + ,sp.descr + ,sp.man + ,sp.default_value + ,sp.minlength + ,sp.maxlength + ,sp.regex + ,sp.sort + ,sp.is_sensitive + ,sp.ref_svc_id + ,sp.unique_scope + ,sp.default_compute + ,sp.func + from svc_operation_cfs_subparam sp + where sp.svc_operation_cfs_param_id= + order by sp.sort + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ---> + + + "isModifiableDefinition":false + }, true + ) + /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +``` + +## v1/resources/instance_operation_ls.cfc + +```cfml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select + + o.operation + o.instance_operation_uid::text as instance_operation_uid + o.instance_uid::text as instance_uid + to_char(o.dt_created, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as dt_created + to_char(o.dt_created, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as dt_updated + to_char(o.dt_submit, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as dt_submit + o.submit_result + to_char(o.dt_start, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as dt_start + to_char(o.dt_finish, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as dt_finish + extract('epoch' from coalesce(o.dt_finish,CURRENT_TIMESTAMP)- o.dt_start) as duration + o.is_successful + e.display_name + e.service_id + v.svc + o.error_log + o.note + i.specification_item_id + s.specification_id + d.contract_id + o.creator_id + o.updater_id + c.login as creator_login + c.email as creator_email + c.shortname as creator_shortname + u.login as updater_login + u.email as updater_email + u.shortname as updater_shortname + + + from instance_operation o + join instance e on (o.instance_uid=e.instance_uid) + left outer join specification_item i on (e.specification_item_id=i.specification_item_id) + left outer join specification s on (i.specification_id=s.specification_id) + left outer join contract d on (s.contract_id=d.contract_id) + left outer join svc v on (e.service_id=v.svc_id) + left outer join usr c on (e.creator_id=c.usr_id) + left outer join usr u on (e.updater_id=u.usr_id) + #local.fromClause# + where + s.specification_id= + + order by + + + limit #arguments.pageSize# + offset #arguments.pageSize*(arguments.page-1)# + + + + + select count(*) as cnt + #local.fromClause# + where + s.specification_id= + + + + + select count(*) as cnt + #local.fromClause# + + where + s.specification_id= + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select count(*) as cnt + from svc_operation so + join svc s on so.svc_id=s.svc_id + join instance e on (s.svc_id=e.service_id) + where e.instance_uid= + AND so.operation= + + + + + + + select count(*) as cnt + from instance e + join specification_item si on (e.specification_item_id=si.specification_item_id) + where e.instance_uid= + AND si.specification_id= + + + + + + + + + + + + + + + + + + + + insert into instance_operation + (instance_uid, instance_operation_uid, operation, note, dt_created, creator_id, dt_updated, updater_id) + values + ( + + , + , + , + , + , + , + , + ); + + + + + + + + + + + + + + + + + + + + + + + + select c.contract_id + from instance e + join specification_item si on (e.specification_item_id=si.specification_item_id) + join specification s on (si.specification_id=s.specification_id) + join contract c on (s.contract_id=c.contract_id) + where e.instance_uid= + + + + select r.resource_realm_type_id + from resource_realm r + join resource_realm_type t on (r.resource_realm_type_id=t.resource_realm_type_id) + join svc s on (t.resource_realm_type_id=s.resource_realm_type_id) + join instance e on (s.svc_id=e.service_id) + where r.resource_realm_id= + AND e.instance_uid= + + + + + + + select r.resource_realm_id + from resource_realm r + join resource_realm_access a on (r.resource_realm_id=a.resource_realm_id) + where r.resource_realm_id= + AND (a.contract_id= + OR a.contract_id=0) + AND a.is_enabled + + + + + + + + + + +``` + +## v1/resources/instance_operation_run.cfc + +```cfml + + + + + + + + + + + + + + + + + + select count(*) as cnt + from instance_operation io + join instance e on (io.instance_uid=e.instance_uid) + join specification_item si on (e.specification_item_id=si.specification_item_id) + where io.instance_operation_uid= + AND si.specification_id= + + + + + + + select io.operation, s.svc_id, so.svc_operation_id + from instance_operation io + join instance e on (io.instance_uid=e.instance_uid) + join svc s on (e.service_id=s.svc_id) + join svc_operation so on (s.svc_id=so.svc_id AND io.operation=so.operation) + where io.instance_operation_uid= + + + + select io.instance_uid + from instance_operation io + where io.instance_operation_uid= + + + + select io.dt_submit, io.dt_finish, io.dt_start, io.submit_result, io.status_url + from instance_operation io + where io.instance_operation_uid= + + + + + + + + select io.dt_submit, io.dt_finish, io.dt_start, io.submit_result, io.status_url + from instance_operation io + where io.instance_uid= + AND left(io.submit_result,1)='2' AND io.dt_finish IS NULL + + + + + + + update instance_operation + set is_successful=false, dt_finish=CURRENT_TIMESTAMP + where instance_operation_uid= + + + + + + + select sop.svc_operation_cfs_param_id, sop.svc_operation_cfs_param, sop.is_required, + iop.instance_operation_cfs_param_uid::text as instance_operation_cfs_param_uid, iop.param_value + from svc_operation_cfs_param sop + left outer join instance_operation_cfs_param iop on (sop.svc_operation_cfs_param_id=iop.svc_operation_cfs_param_id AND iop.instance_operation_uid=) + where sop.svc_operation_id= + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select so.svc_operation_id, io.instance_uid, so.operation, r.resource_realm, io.resource_realm_id + from instance_operation io + join instance e on (io.instance_uid=e.instance_uid) + join svc_operation so on (e.service_id=so.svc_id AND io.operation=so.operation) + left outer join resource_realm r on io.resource_realm_id=r.resource_realm_id + where io.instance_operation_uid= + + + + + + + + + + + + + + insert into instance_operation_param (instance_operation_uid,param,param_value) + select + iocp.instance_operation_uid + ,sop.svc_operation_param + ,iocp.param_value + from instance_operation_cfs_param iocp + join svc_operation_cfs_param socp on (iocp.svc_operation_cfs_param_id=socp.svc_operation_cfs_param_id) + join svc_operation_param sop on (socp.svc_operation_id=sop.svc_operation_id AND socp.svc_operation_cfs_param=sop.svc_operation_param) + where iocp.instance_operation_uid= + /*PostgreSQL specific*/ + ON CONFLICT (instance_operation_uid,param) + DO UPDATE SET param_value = EXCLUDED.param_value; + + + + + insert into instance_operation_param (instance_operation_uid,param,param_value) + select + + ,sop.svc_operation_param + ,sop.default_value + from svc_operation_param sop + where sop.svc_operation_id= AND length(sop.default_value)>0 /***null will be better*/ + /*PostgreSQL specific*/ + ON CONFLICT (instance_operation_uid,param) + DO NOTHING; + + + + + + + + + + select so.url_prefix, so.url_suffix, o.operation, svc.version + from instance_operation o + join instance i on (o.instance_uid=i.instance_uid) + join svc on (i.service_id=svc.svc_id) + left outer join svc_operation so on (i.service_id=so.svc_id AND o.operation=so.operation) + where o.instance_operation_uid= + + + + select s.instance_data->'job'->>'jobAppVersion' as jobAppVersion + from instance_operation o + join instance_state s on (o.instance_uid=s.instance_uid) + where o.instance_operation_uid= + order by s.version desc + limit 1 + + + + select iop.param, iop.param_value + from instance_operation_param iop + where iop.instance_operation_uid= + AND length(iop.param)>0 + + + + + + + + + + + + update instance_operation + set dt_submit= + ,dt_start=null, dt_finish=null, submit_result='0' + ,url= + where instance_operation_uid= + + + + + + + + + + + + + + + + + + + + + + + + + update instance_operation + set submit_result= + where instance_operation_uid= + + + + + + + + + + + + + + + + + update instance_operation + set status_url= + where instance_operation_uid= + + + + + + + + + + + + + + + + + insert into instance_operation_param (instance_operation_uid,param,param_value) + values ( + + , + , + ) + /*PostgreSQL specific*/ + ON CONFLICT (instance_operation_uid,param) + DO UPDATE SET param_value = EXCLUDED.param_value; + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select external_code + from contragent + where contragent_id= + + + + + + + + + + + + + select sop.svc_operation_cfs_param + from instance_operation io + join instance e on (io.instance_uid=e.instance_uid) + join svc_operation so on (e.service_id=so.svc_id AND io.operation=so.operation) + join svc_operation_cfs_param sop on (so.svc_operation_id=sop.svc_operation_id) + where io.instance_operation_uid= + AND LOWER(sop.svc_operation_cfs_param)=LOWER('resourceRealm') + + + + + + + + select io.operation + from instance_operation io + where io.instance_operation_uid= + + + + select c.contract_id + from instance_operation io + join instance e on (io.instance_uid=e.instance_uid) + join specification_item si on (e.specification_item_id=si.specification_item_id) + join specification s on (si.specification_id=s.specification_id) + join contract c on (s.contract_id=c.contract_id) + where io.instance_operation_uid= + + + + select r.resource_realm_id, r.resource_realm, sop.svc_operation_cfs_param, iop.param_value, a.contract_id, a.is_enabled + from instance_operation_cfs_param iop + join svc_operation_cfs_param sop on (iop.svc_operation_cfs_param_id=sop.svc_operation_cfs_param_id) + join resource_realm r on (sop.svc_operation_cfs_param='resourceRealm' AND iop.param_value=r.resource_realm) + join resource_realm_access a on (r.resource_realm_id=a.resource_realm_id) + where iop.instance_operation_uid= + AND (a.contract_id= OR a.contract_id=0) + AND a.is_enabled + + + + + + + + + + + + + + select count(*) as cnt + from instance_operation_param iop + where iop.param='resourceRealm' AND + iop.instance_operation_uid= + + + + + + + select c.contract_id + from instance_operation io + join instance e on (io.instance_uid=e.instance_uid) + join specification_item si on (e.specification_item_id=si.specification_item_id) + join specification s on (si.specification_id=s.specification_id) + join contract c on (s.contract_id=c.contract_id) + where io.instance_operation_uid= + + + + + select r.resource_realm_id, r.resource_realm, iop.param, iop.param_value, a.contract_id, a.is_enabled + from resource_realm r + join resource_realm_access a on (r.resource_realm_id=a.resource_realm_id) + join instance_operation_param iop on (r.resource_realm=iop.param_value AND iop.param='resourceRealm') + where iop.instance_operation_uid= + AND (a.contract_id= OR a.contract_id=0) + AND a.is_enabled + + + + + + + + +``` + +## v1/resources/instance_operation_validate.cfc + +```cfml + + + + + + + + + + + + + + + + + + + + + + + + + +``` + +## v1/resources/notification_ls.cfc + +```cfml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select + + n.notification_uid::text as notification_uid + n.notification + n.descr + n.url + n.timeout_sec + n.contragent_id + k.external_uid + to_char(n.dt_show_from, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as dt_show_from + to_char(n.dt_show_to, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as dt_show_to + + from notification n + left outer join contragent k on (n.contragent_id=k.contragent_id) + where 1=1 + AND (n.dt_show_from <= CURRENT_TIMESTAMP OR n.dt_show_from IS NULL) + AND (n.dt_show_to >= CURRENT_TIMESTAMP OR n.dt_show_to IS NULL) + AND (k.external_uid = OR n.contragent_id IS NULL) + order by dt_show_from desc + limit #maxrows# + + + + select count(*) as cnt + from notification n + left outer join contragent k on (n.contragent_id=k.contragent_id) + where 1=1 + AND (n.dt_show_from <= CURRENT_TIMESTAMP OR n.dt_show_from IS NULL) + AND (n.dt_show_to >= CURRENT_TIMESTAMP OR n.dt_show_to IS NULL) + AND (k.external_uid = OR n.contragent_id IS NULL) + + + + + + + + + + + + + + + + + + + + + + + + + + + + +``` + +## v1/resources/param_value_list.cfc + +```cfml + + + + + + + + + + + + + + + + select p.depends_on_params + from svc_operation_cfs_param p + where p.svc_operation_cfs_param_id = + + + + + + + + +``` + +## v1/resources/resource_realm.cfc + +```cfml + + + + + + + + + + + + + + + + + + + select + + r.resource_realm_id + r.resource_realm_type_id + r.parent_id + r.resource_realm + r.mgmt_api_url + p.resource_realm as parent + t.resource_realm_type + r.descr + r.man + to_char(r.dt_created, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as dt_created + to_char(r.dt_updated, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as dt_updated + + from resource_realm r + join resource_realm_type t on (r.resource_realm_type_id=t.resource_realm_type_id) + left outer join resource_realm p on (r.parent_id=p.resource_realm_id) + where r.resource_realm_id= + + + + select + + m.resource_realm_metric_id + m.resource_realm_type_metric_id + m.dashboard_url + t.metric + u.measure + u.measure_short + + from resource_realm_metric m + join resource_realm_type_metric t on (m.resource_realm_type_metric_id=t.resource_realm_type_metric_id) + join measure u on (t.measure_id=u.measure_id) + where m.resource_realm_id= + + + + + + + + + + + + + + + + + + + + + +``` + +## v1/resources/resource_realm_ls.cfc + +```cfml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select + + r.resource_realm_id + r.resource_realm_type_id + r.parent_id + r.resource_realm + r.mgmt_api_url + p.resource_realm as parent + t.resource_realm_type + r.descr + r.man + to_char(r.dt_created, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as dt_created + to_char(r.dt_updated, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as dt_updated + + from resource_realm r + join resource_realm_type t on (r.resource_realm_type_id=t.resource_realm_type_id) + left outer join resource_realm p on (r.parent_id=p.resource_realm_id) + join resource_realm_access a on + (r.resource_realm_id=a.resource_realm_id + AND (a.contract_id= + OR a.contract_id=0) + AND a.is_enabled) + where 1=1 + order by + limit #maxrows# + + + + + select count(*) as cnt + from resource_realm + where 1=1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + +``` + +## v1/resources/resource_realm_type_ls.cfc + +```cfml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select + + t.resource_realm_type_id + t.resource_realm_type + t.man + + from resource_realm_type t + where 1=1 + order by + limit #maxrows# + + + + + select count(*) as cnt + from resource_realm_type + where 1=1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + +``` + +## v1/resources/svc.cfc + +```cfml + + + + + + + + + + + + + + + + + + + + + + select + + s.svc_id + s.svc + s.svc_short + s.code + s.version + s.orchestrator_name + (select url from svc_operation so where so.operation='create' AND so.svc_id=s.svc_id limit 1) as create_url + s.is_production_ready + s.resource_realm_type_id + s.icon_src + s.descr + s.man + + from svc s + where svc_id= + + + + select + + j.svc_operation_id + j.operation + j.url + j.descr + j.man + + from svc_operation j + where j.svc_id= + + + + + + + + + + + + + + + + + + + + + + + +``` + +## v1/resources/svc_default.cfc + +```cfml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +``` + +## v1/resources/svc_grouped_ls.cfc + +```cfml + + + + + + + + + + + + code={prefix="s", type="string"}, + version={prefix="s", type="string"}, + descr={prefix="s", type="string"}, + man={prefix="s", type="string"}, + svc_group_id={prefix="sg", type="integer"}, + svc_group={prefix="g", type="string"}, + resource_realm_cnt={type="integer"} + } + /> + + + + + + + + + + + + + + + + + + + + + + + + + + select + + s.svc_id + s.svc + s.svc_short + + s.code + (select url from svc_operation so where so.operation='create' AND so.svc_id=s.svc_id limit 1) as create_url + s.is_production_ready + s.resource_realm_type_id + s.sort + s.version + s.icon_src + s.descr + s.man + to_char(s.dt_created, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as dt_created + to_char(s.dt_updated, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as dt_updated + sg.svc_group_id + g.svc_group + (coalesce(s.svc,'') ||' '|| coalesce(s.svc_short,'') ||' '|| coalesce(s.synonyms,'')) as svc_extended_name + (select count(distinct r.resource_realm) + from resource_realm r + join resource_realm_access a on ( + r.resource_realm_id=a.resource_realm_id + AND (a.contract_id IN ( + select contract_id + from contract d + where d.contragent_id=k.contragent_id AND NOT d.is_closed + ) OR a.contract_id=0) /*0 means access to any contract*/ + AND a.is_enabled) + where r.resource_realm_type_id=s.resource_realm_type_id) as resource_realm_cnt + + + from svc s + left outer join svc_group_svc sg on (s.svc_id=sg.svc_id AND sg.is_enabled) + left outer join svc_group g on (sg.svc_group_id=g.svc_group_id) + left outer join contragent k on ( + k.external_uid= + ) + where 1=1 + order by g.sort, g.svc_group_id + length limit---> + + + + + + + + + + + + + + + + + > + + + + + + + + + + + + почему-то здесь работает без structCopy + + + + + + + + + + + + + + + + + + + + + + + + + + + + +``` + +## v1/resources/svc_ls.cfc + +```cfml + + + + + + + + + + + "resource_realm_type_id"={prefix="sv", type="integer"}, + "sort"={prefix="sv", type="integer"}, + "is_production_ready"={prefix="sv", type="boolean"}, + "svc"={prefix="sv", type="string"}, + "svc_short"={prefix="sv", type="string"}, + "svc_extended_name"={prefix="sv", type="string"}, + "orchestrator_name"={prefix="sv", type="string"}, + "synonyms"={prefix="sv", type="string"}, + "code"={prefix="sv", type="string"}, + "version"={prefix="sv", type="string"}, + "descr"={prefix="sv", type="string"}, + "man"={prefix="sv", type="string"}, + "resource_realm_cnt"={prefix="sv", type="integer"} + } + /> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + s.svc_id + s.svc + s.svc_short + s.orchestrator_name + s.synonyms + s.code + (select url from svc_operation so where so.operation='create' AND so.svc_id=s.svc_id limit 1) as create_url + s.is_production_ready + s.resource_realm_type_id + s.sort + s.version + s.icon_src + s.descr + s.man + (select count(distinct r.resource_realm) + from resource_realm r + join resource_realm_access a on ( + r.resource_realm_id=a.resource_realm_id + AND (a.contract_id IN ( + select contract_id + from contract d + where d.contragent_id=k.contragent_id AND NOT d.is_closed + ) OR a.contract_id=0) /*0 means access to any contract*/ + AND a.is_enabled) + where r.resource_realm_type_id=s.resource_realm_type_id) as resource_realm_cnt + to_char(s.dt_created, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as dt_created + to_char(s.dt_updated, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as dt_updated + (coalesce(s.svc,'') ||' '|| coalesce(s.svc_short,'') ||' '|| coalesce(s.synonyms,'')) as svc_extended_name + + + + + + + select #local.definedRecordFields#* from + ( + select + + #preserveSingleQuotes(local.definedQueryFields)# + + '' as placeholder + + from svc s + left outer join contragent k on ( + k.external_uid= + ) /*эти хитрости для того, чтобы втащить cfqueryparam внутрь cfqery*/ + where 1=1 + + AND ( + lower((coalesce(s.svc,'') ||' '|| coalesce(s.svc_short,'') ||' '|| coalesce(s.synonyms,''))) like lower() + ) + + ) sv + where 1=1 + order by + + + + + + select count(*) as cnt + from svc + where 1=1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +``` + +## v1/resources/svc_operation.cfc + +```cfml + + + + + + + + + + + + + + + + + + + select + + o.svc_operation_id + o.operation + o.url + o.descr + o.man + + from svc_operation o + where o.svc_operation_id= + + + + select + + p.svc_operation_cfs_param_id + + p.svc_operation_cfs_param + p.label + p.data_type + ((isArray(x) OR isEmpty(x))? x : listToArray(x))#>p.value_list + p.ref_svc_id + p.is_required + p.is_hidden + p.is_disabled + p.default_value + p.default_compute + p.func + p.expression + p.state_path + p.nested_ref + p.regex + p.unique_scope + p.maxlength + p.minlength + p.maxvalue + p.minvalue + p.descr + p.man + p.sort + p.depends_on_cfs_params + ( + select 1 from svc_operation_cfs_param m + join svc_operation om on (m.svc_operation_id=om.svc_operation_id) + join svc_operation oc on (om.svc_id=oc.svc_id AND om.operation='modify' AND oc.operation='create') + join svc_operation_cfs_param c on (oc.svc_operation_id=c.svc_operation_id AND m.svc_operation_cfs_param=c.svc_operation_cfs_param) + where c.svc_operation_cfs_param_id=p.svc_operation_cfs_param_id + order by c.svc_operation_cfs_param_id + limit 1 + ) as is_modifiable + p.is_sensitive + + from svc_operation_cfs_param p + where p.svc_operation_id= + AND p.is_actual + order by p.sort, p.svc_operation_cfs_param_id + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +``` + +## v1/resources/svc_operation_cfs_param_compute.cfc + +```cfml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select + + sop.data_type + sop.svc_operation_cfs_param + sop.expression + + from svc_operation_cfs_param sop + where sop.svc_operation_cfs_param_id + = + + + + + + + + + + + + + + + + + + + + + + + + + +``` + +## v1/resources/svc_operation_cfs_subparam_compute.cfc + +```cfml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select + + sop.svc_operation_cfs_param_id + sop.data_type + sop.svc_operation_cfs_subparam + sop.expression + + from svc_operation_cfs_subparam sop + where sop.svc_operation_cfs_subparam_id + = + + + + + + + + + + + + + + + + + + + + + + + + + +``` + +## v1/resources/user.cfc + +```cfml + + + + + + + + + + + + + + + + + + + + + + + + + + select + + s.specification_id + + c.contract_id + c.contragent_id + + + from specification s + join contract c on (s.contract_id=c.contract_id) + join usr u on (c.contragent_id=u.contragent_id) + where u.usr_id= + order by specification_id desc + limit 1; + + + + + select + + u.usr_id + + k.contragent_id + + + + + from usr u + left outer join contragent k on u.contragent_id=k.contragent_id + where u.usr_id= + + + + + + + + + + + + + + + + + + + + + + + + +``` + +## v1/resources/vault_record.cfc + +```cfml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + select + + st.instance_state_uid::text as instance_state_uid + st.version + st.creator_id + to_char(st.dt_state, 'YYYY-MM-DD"T"HH24:MI:SS.FF3TZHTZM') as dt_state + st.is_test + st.instance_operation_uid::text as instance_operation_uid + st.instance_data::text as instance_data + (st.instance_data->>'isDeleted')::boolean as is_deleted + + from instance_state st + join instance e on (st.instance_uid=e.instance_uid) + join specification_item i on (e.specification_item_id=i.specification_item_id) + where st.instance_uid= + AND i.specification_id= + order by st.version desc + limit 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +``` + diff --git a/analysis/source-toc-2026-04-29.md b/analysis/source-toc-2026-04-29.md new file mode 100644 index 0000000..0297e42 --- /dev/null +++ b/analysis/source-toc-2026-04-29.md @@ -0,0 +1,63 @@ +# Оглавление исходников svc-api-x + +Дата сборки: 2026-04-29 + +## Прикладной слой + +- health.cfm +- v1/Application.cfc +- v1/index.cfm +- v1/lib/JsonSerializer.cfc +- v1/lib/TokenGenerator.cfc +- v1/lib/encodingUtils.cfc +- v1/lib/expression_parser.cfc +- v1/lib/field.cfm +- v1/lib/field_set.cfm +- v1/lib/filter_build.cfm +- v1/lib/index.cfm +- v1/lib/jwt.cfc +- v1/lib/notifier.cfc +- v1/lib/order_build.cfm +- v1/lib/rest_api_helper.cfc +- v1/resources/available_resource_realms.cfc +- v1/resources/bookmark.cfc +- v1/resources/bookmark_ls.cfc +- v1/resources/catalog_service_ls.cfc +- v1/resources/catalog_service_param_ls.cfc +- v1/resources/err.cfc +- v1/resources/instance.cfc +- v1/resources/instance_default.cfc +- v1/resources/instance_ls.cfc +- v1/resources/instance_operation.cfc +- v1/resources/instance_operation_cfs_param.cfc +- v1/resources/instance_operation_cfs_param_ls.cfc +- v1/resources/instance_operation_cfs_subparam.cfc +- v1/resources/instance_operation_cfs_subparam_ls.cfc +- v1/resources/instance_operation_default.cfc +- v1/resources/instance_operation_ls.cfc +- v1/resources/instance_operation_run.cfc +- v1/resources/instance_operation_validate.cfc +- v1/resources/notification_ls.cfc +- v1/resources/param_value_list.cfc +- v1/resources/resource_realm.cfc +- v1/resources/resource_realm_ls.cfc +- v1/resources/resource_realm_type_ls.cfc +- v1/resources/svc.cfc +- v1/resources/svc_default.cfc +- v1/resources/svc_grouped_ls.cfc +- v1/resources/svc_ls.cfc +- v1/resources/svc_operation.cfc +- v1/resources/svc_operation_cfs_param_compute.cfc +- v1/resources/svc_operation_cfs_subparam_compute.cfc +- v1/resources/user.cfc +- v1/resources/vault_record.cfc + +## Backup-слой, исключенный из основного bundle + +- v1/etc/bk/login.cfc +- v1/etc/bk/user.cfc + +## Исключено из bundle + +- v1/resources/bk/* как удаленные backup-сериализаторы +- v1/taffy/* как vendor framework, примеры и тесты