From 950d8c5a710c4163efdc1e49e1fbef7581ed82ca Mon Sep 17 00:00:00 2001 From: raphael-goetz Date: Mon, 18 Aug 2025 17:42:14 +0200 Subject: [PATCH 1/3] ref: renamed rest into http --- README.md | 2 +- definitions/{rest => http}/data_type/array/http_header_map.json | 0 .../{rest => http}/data_type/object/http_header_entry.json | 0 .../{rest => http}/data_type/object/http_request_object.json | 0 .../{rest => http}/data_type/object/http_response_object.json | 0 definitions/{rest => http}/data_type/type/http_method.json | 0 definitions/{rest => http}/data_type/type/http_url.json | 0 .../{rest/flow_type/rest.json => http/flow_type/http.json} | 2 +- 8 files changed, 2 insertions(+), 2 deletions(-) rename definitions/{rest => http}/data_type/array/http_header_map.json (100%) rename definitions/{rest => http}/data_type/object/http_header_entry.json (100%) rename definitions/{rest => http}/data_type/object/http_request_object.json (100%) rename definitions/{rest => http}/data_type/object/http_response_object.json (100%) rename definitions/{rest => http}/data_type/type/http_method.json (100%) rename definitions/{rest => http}/data_type/type/http_url.json (100%) rename definitions/{rest/flow_type/rest.json => http/flow_type/http.json} (96%) diff --git a/README.md b/README.md index ea822a4..6226674 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ npm i @code0-tech/code0-definition-reader --save-dev const features = Definition("./path/to/definitions") for (const feature in features) { - const name = feature.name; //name of the feature (e.g. rest) + const name = feature.name; //name of the feature (e.g. http) const dataTypes = fearture.dataTypes; //dataTypes of this feature const flowTypes = fearture.flowTypes; //flowTypes of this feature const functions = fearture.runtimeFunctions; //runtimeFunctions of this feature diff --git a/definitions/rest/data_type/array/http_header_map.json b/definitions/http/data_type/array/http_header_map.json similarity index 100% rename from definitions/rest/data_type/array/http_header_map.json rename to definitions/http/data_type/array/http_header_map.json diff --git a/definitions/rest/data_type/object/http_header_entry.json b/definitions/http/data_type/object/http_header_entry.json similarity index 100% rename from definitions/rest/data_type/object/http_header_entry.json rename to definitions/http/data_type/object/http_header_entry.json diff --git a/definitions/rest/data_type/object/http_request_object.json b/definitions/http/data_type/object/http_request_object.json similarity index 100% rename from definitions/rest/data_type/object/http_request_object.json rename to definitions/http/data_type/object/http_request_object.json diff --git a/definitions/rest/data_type/object/http_response_object.json b/definitions/http/data_type/object/http_response_object.json similarity index 100% rename from definitions/rest/data_type/object/http_response_object.json rename to definitions/http/data_type/object/http_response_object.json diff --git a/definitions/rest/data_type/type/http_method.json b/definitions/http/data_type/type/http_method.json similarity index 100% rename from definitions/rest/data_type/type/http_method.json rename to definitions/http/data_type/type/http_method.json diff --git a/definitions/rest/data_type/type/http_url.json b/definitions/http/data_type/type/http_url.json similarity index 100% rename from definitions/rest/data_type/type/http_url.json rename to definitions/http/data_type/type/http_url.json diff --git a/definitions/rest/flow_type/rest.json b/definitions/http/flow_type/http.json similarity index 96% rename from definitions/rest/flow_type/rest.json rename to definitions/http/flow_type/http.json index 1f7383d..9a4c509 100644 --- a/definitions/rest/flow_type/rest.json +++ b/definitions/http/flow_type/http.json @@ -1,5 +1,5 @@ { - "identifier": "REST", + "identifier": "HTTP", "settings": [], "input_type_identifier": "HTTP_REQUEST_OBJECT", "return_type_identifier": "HTTP_RESPONSE_OBJECT", From 1b77c325c8da1ea6127c75643eaf77e93ace320a Mon Sep 17 00:00:00 2001 From: raphael-goetz Date: Mon, 18 Aug 2025 21:20:37 +0200 Subject: [PATCH 2/3] feat: added create functions for http request/response and status code --- ..._request_object.json => http_request.json} | 2 +- ...esponse_object.json => http_response.json} | 2 +- .../http/data_type/type/http_status_code.json | 210 ++++++++++++++++++ definitions/http/flow_type/http.json | 4 +- .../request/http_request_create.json | 141 ++++++++++++ .../response/http_response_create.json | 114 ++++++++++ 6 files changed, 469 insertions(+), 4 deletions(-) rename definitions/http/data_type/object/{http_request_object.json => http_request.json} (97%) rename definitions/http/data_type/object/{http_response_object.json => http_response.json} (95%) create mode 100644 definitions/http/data_type/type/http_status_code.json create mode 100644 definitions/http/runtime_definition/request/http_request_create.json create mode 100644 definitions/http/runtime_definition/response/http_response_create.json diff --git a/definitions/http/data_type/object/http_request_object.json b/definitions/http/data_type/object/http_request.json similarity index 97% rename from definitions/http/data_type/object/http_request_object.json rename to definitions/http/data_type/object/http_request.json index 7e071f8..f4c1bbb 100644 --- a/definitions/http/data_type/object/http_request_object.json +++ b/definitions/http/data_type/object/http_request.json @@ -1,6 +1,6 @@ { "variant": 3, - "identifier": "HTTP_REQUEST_OBJECT", + "identifier": "HTTP_REQUEST", "name": [ { "code": "en-US", diff --git a/definitions/http/data_type/object/http_response_object.json b/definitions/http/data_type/object/http_response.json similarity index 95% rename from definitions/http/data_type/object/http_response_object.json rename to definitions/http/data_type/object/http_response.json index 28c53a5..7aee05b 100644 --- a/definitions/http/data_type/object/http_response_object.json +++ b/definitions/http/data_type/object/http_response.json @@ -1,6 +1,6 @@ { "variant": 3, - "identifier": "HTTP_RESPONSE_OBJECT", + "identifier": "HTTP_RESPONSE", "name": [ { "code": "en-US", diff --git a/definitions/http/data_type/type/http_status_code.json b/definitions/http/data_type/type/http_status_code.json new file mode 100644 index 0000000..7114c64 --- /dev/null +++ b/definitions/http/data_type/type/http_status_code.json @@ -0,0 +1,210 @@ +{ + "variant": 2, + "identifier": "HTTP_STATUS_CODE", + "name": [ + { + "code": "en-US", + "content": "HTTP Status Code" + } + ], + "rules": [ + { + "config": { + "ItemOfCollection": { + "items": [ + { + "kind": { "StringValue": "100 Continue" } + }, + { + "kind": { "StringValue": "101 Switching Protocols" } + }, + { + "kind": { "StringValue": "102 Processing" } + }, + { + "kind": { "StringValue": "103 Early Hints" } + }, + { + "kind": { "StringValue": "200 OK" } + }, + { + "kind": { "StringValue": "201 Created" } + }, + { + "kind": { "StringValue": "202 Accepted" } + }, + { + "kind": { "StringValue": "203 Non-Authoritative Information" } + }, + { + "kind": { "StringValue": "204 No Content" } + }, + { + "kind": { "StringValue": "205 Reset Content" } + }, + { + "kind": { "StringValue": "206 Partial Content" } + }, + { + "kind": { "StringValue": "207 Multi-Status" } + }, + { + "kind": { "StringValue": "208 Already Reported" } + }, + { + "kind": { "StringValue": "226 IM Used" } + }, + { + "kind": { "StringValue": "300 Multiple Choices" } + }, + { + "kind": { "StringValue": "301 Moved Permanently" } + }, + { + "kind": { "StringValue": "302 Found" } + }, + { + "kind": { "StringValue": "303 See Other" } + }, + { + "kind": { "StringValue": "304 Not Modified" } + }, + { + "kind": { "StringValue": "305 Use Proxy" } + }, + { + "kind": { "StringValue": "306 Switch Proxy" } + }, + { + "kind": { "StringValue": "307 Temporary Redirect" } + }, + { + "kind": { "StringValue": "308 Permanent Redirect" } + }, + { + "kind": { "StringValue": "400 Bad Request" } + }, + { + "kind": { "StringValue": "401 Unauthorized" } + }, + { + "kind": { "StringValue": "402 Payment Required" } + }, + { + "kind": { "StringValue": "403 Forbidden" } + }, + { + "kind": { "StringValue": "404 Not Found" } + }, + { + "kind": { "StringValue": "405 Method Not Allowed" } + }, + { + "kind": { "StringValue": "406 Not Acceptable" } + }, + { + "kind": { "StringValue": "407 Proxy Authentication Required" } + }, + { + "kind": { "StringValue": "408 Request Timeout" } + }, + { + "kind": { "StringValue": "409 Conflict" } + }, + { + "kind": { "StringValue": "410 Gone" } + }, + { + "kind": { "StringValue": "411 Length Required" } + }, + { + "kind": { "StringValue": "412 Precondition Failed" } + }, + { + "kind": { "StringValue": "413 Payload Too Large" } + }, + { + "kind": { "StringValue": "414 URI Too Long" } + }, + { + "kind": { "StringValue": "415 Unsupported Media Type" } + }, + { + "kind": { "StringValue": "416 Range Not Satisfiable" } + }, + { + "kind": { "StringValue": "417 Expectation Failed" } + }, + { + "kind": { "StringValue": "418 I'm a teapot" } + }, + { + "kind": { "StringValue": "421 Misdirected Request" } + }, + { + "kind": { "StringValue": "422 Unprocessable Entity" } + }, + { + "kind": { "StringValue": "423 Locked" } + }, + { + "kind": { "StringValue": "424 Failed Dependency" } + }, + { + "kind": { "StringValue": "425 Too Early" } + }, + { + "kind": { "StringValue": "426 Upgrade Required" } + }, + { + "kind": { "StringValue": "428 Precondition Required" } + }, + { + "kind": { "StringValue": "429 Too Many Requests" } + }, + { + "kind": { "StringValue": "431 Request Header Fields Too Large" } + }, + { + "kind": { "StringValue": "451 Unavailable For Legal Reasons" } + }, + { + "kind": { "StringValue": "500 Internal Server Error" } + }, + { + "kind": { "StringValue": "501 Not Implemented" } + }, + { + "kind": { "StringValue": "502 Bad Gateway" } + }, + { + "kind": { "StringValue": "503 Service Unavailable" } + }, + { + "kind": { "StringValue": "504 Gateway Timeout" } + }, + { + "kind": { "StringValue": "505 HTTP Version Not Supported" } + }, + { + "kind": { "StringValue": "506 Variant Also Negotiates" } + }, + { + "kind": { "StringValue": "507 Insufficient Storage" } + }, + { + "kind": { "StringValue": "508 Loop Detected" } + }, + { + "kind": { "StringValue": "510 Not Extended" } + }, + { + "kind": { "StringValue": "511 Network Authentication Required" } + } + ] + } + } + } + ], + "generic_keys": [] +} \ No newline at end of file diff --git a/definitions/http/flow_type/http.json b/definitions/http/flow_type/http.json index 9a4c509..0a6b997 100644 --- a/definitions/http/flow_type/http.json +++ b/definitions/http/flow_type/http.json @@ -1,8 +1,8 @@ { "identifier": "HTTP", "settings": [], - "input_type_identifier": "HTTP_REQUEST_OBJECT", - "return_type_identifier": "HTTP_RESPONSE_OBJECT", + "input_type_identifier": "HTTP_REQUEST", + "return_type_identifier": "HTTP_RESPONSE", "editable": false, "name": [ { diff --git a/definitions/http/runtime_definition/request/http_request_create.json b/definitions/http/runtime_definition/request/http_request_create.json new file mode 100644 index 0000000..6ee8056 --- /dev/null +++ b/definitions/http/runtime_definition/request/http_request_create.json @@ -0,0 +1,141 @@ +{ + "runtime_name": "http::request::create", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "type": { + "DataTypeIdentifier": "HTTP_METHOD" + } + }, + "runtime_name": "http_method", + "default_value": null, + "name": [ + { + "code": "en-US", + "content": "HTTP Method" + } + ], + "description": [ + { + "code": "en-US", + "content": "Defines the HTTP method to be used, such as GET, POST, PUT, or DELETE." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Specifies the request method that determines the type of HTTP operation to perform." + } + ] + }, + { + "data_type_identifier": { + "type": { + "DataTypeIdentifier": "HTTP_HEADER_MAP" + } + }, + "runtime_name": "headers", + "default_value": null, + "name": [ + { + "code": "en-US", + "content": "HTTP Headers" + } + ], + "description": [ + { + "code": "en-US", + "content": "A collection of key-value pairs containing additional request metadata." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Optional headers that can define content type, authorization, cookies, caching policies, and more." + } + ] + }, + { + "data_type_identifier": { + "type": { + "DataTypeIdentifier": "HTTP_URL" + } + }, + "runtime_name": "url", + "default_value": null, + "name": [ + { + "code": "en-US", + "content": "Request URL" + } + ], + "description": [ + { + "code": "en-US", + "content": "The target URL to which the HTTP request will be sent." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Specifies the endpoint address, including protocol, host, path, and query parameters, where the request is directed." + } + ] + }, + { + "data_type_identifier": { + "type": { + "GenericKey": "P" + } + }, + "runtime_name": "payload", + "default_value": null, + "name": [ + { + "code": "en-US", + "content": "Request Body" + } + ], + "description": [ + { + "code": "en-US", + "content": "The data to include in the body of the request, typically used with methods like POST or PUT." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Contains the request payload, such as JSON, XML, form data, or binary content, depending on the Content-Type header." + } + ] + } + ], + "return_type_identifier": { + "type": { + "DataTypeIdentifier": "HTTP_REQUEST" + } + }, + "throws_error": false, + "generic_keys": [ + "P" + ], + "name": [ + { + "code": "en-US", + "content": "Construct HTTP Request" + } + ], + "description": [ + { + "code": "en-US", + "content": "Constructs an HTTP request object using the specified method, headers, URL, and payload." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Generates an HTTP request object that can be sent to a server. The request includes an HTTP method, optional headers, a destination URL, and an optional request body." + } + ], + "deprecation_message": [] +} diff --git a/definitions/http/runtime_definition/response/http_response_create.json b/definitions/http/runtime_definition/response/http_response_create.json new file mode 100644 index 0000000..4318208 --- /dev/null +++ b/definitions/http/runtime_definition/response/http_response_create.json @@ -0,0 +1,114 @@ +{ + "runtime_name": "http::response::create", + "runtime_parameter_definitions": [ + { + "data_type_identifier": { + "type": { + "DataTypeIdentifier": "HTTP_STATUS_CODE" + } + }, + "runtime_name": "http_status_code", + "default_value": null, + "name": [ + { + "code": "en-US", + "content": "HTTP Status Code" + } + ], + "description": [ + { + "code": "en-US", + "content": "Represents the numeric status code returned by the server in response to an HTTP request." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Indicates the outcome of an HTTP request. Common codes include 200 (OK), 201 (Created), 400 (Bad Request), 401 (Unauthorized), 404 (Not Found), and 500 (Internal Server Error)." + } + ] + }, + { + "data_type_identifier": { + "type": { + "DataTypeIdentifier": "HTTP_HEADER_MAP" + } + }, + "runtime_name": "headers", + "default_value": null, + "name": [ + { + "code": "en-US", + "content": "HTTP Headers" + } + ], + "description": [ + { + "code": "en-US", + "content": "A collection of key-value pairs containing additional request metadata." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Optional headers that can define content type, authorization, cookies, caching policies, and more." + } + ] + }, + { + "data_type_identifier": { + "type": { + "GenericKey": "P" + } + }, + "runtime_name": "payload", + "default_value": null, + "name": [ + { + "code": "en-US", + "content": "Request Body" + } + ], + "description": [ + { + "code": "en-US", + "content": "The data to include in the body of the request, typically used with methods like POST or PUT." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Contains the request payload, such as JSON, XML, form data, or binary content, depending on the Content-Type header." + } + ] + } + ], + "return_type_identifier": { + "type": { + "DataTypeIdentifier": "HTTP_RESPONSE" + } + }, + "throws_error": false, + "generic_keys": [ + "P" + ], + "name": [ + { + "code": "en-US", + "content": "Construct HTTP Response" + } + ], + "description": [ + { + "code": "en-US", + "content": "Builds an HTTP response object using the specified status code, headers, and optional response body." + } + ], + "documentation": [ + { + "code": "en-US", + "content": "Creates a complete HTTP response object to be returned from a server. The response includes a status code, headers, and an optional body containing the response content." + } + ], + "deprecation_message": [] +} From 87c06ea4296304f5978a4546eb98737887f35cdd Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 19 Aug 2025 11:18:50 +0200 Subject: [PATCH 3/3] fix: made http status code to a number range --- .../http/data_type/type/http_status_code.json | 195 +----------------- 1 file changed, 3 insertions(+), 192 deletions(-) diff --git a/definitions/http/data_type/type/http_status_code.json b/definitions/http/data_type/type/http_status_code.json index 7114c64..0efc379 100644 --- a/definitions/http/data_type/type/http_status_code.json +++ b/definitions/http/data_type/type/http_status_code.json @@ -10,198 +10,9 @@ "rules": [ { "config": { - "ItemOfCollection": { - "items": [ - { - "kind": { "StringValue": "100 Continue" } - }, - { - "kind": { "StringValue": "101 Switching Protocols" } - }, - { - "kind": { "StringValue": "102 Processing" } - }, - { - "kind": { "StringValue": "103 Early Hints" } - }, - { - "kind": { "StringValue": "200 OK" } - }, - { - "kind": { "StringValue": "201 Created" } - }, - { - "kind": { "StringValue": "202 Accepted" } - }, - { - "kind": { "StringValue": "203 Non-Authoritative Information" } - }, - { - "kind": { "StringValue": "204 No Content" } - }, - { - "kind": { "StringValue": "205 Reset Content" } - }, - { - "kind": { "StringValue": "206 Partial Content" } - }, - { - "kind": { "StringValue": "207 Multi-Status" } - }, - { - "kind": { "StringValue": "208 Already Reported" } - }, - { - "kind": { "StringValue": "226 IM Used" } - }, - { - "kind": { "StringValue": "300 Multiple Choices" } - }, - { - "kind": { "StringValue": "301 Moved Permanently" } - }, - { - "kind": { "StringValue": "302 Found" } - }, - { - "kind": { "StringValue": "303 See Other" } - }, - { - "kind": { "StringValue": "304 Not Modified" } - }, - { - "kind": { "StringValue": "305 Use Proxy" } - }, - { - "kind": { "StringValue": "306 Switch Proxy" } - }, - { - "kind": { "StringValue": "307 Temporary Redirect" } - }, - { - "kind": { "StringValue": "308 Permanent Redirect" } - }, - { - "kind": { "StringValue": "400 Bad Request" } - }, - { - "kind": { "StringValue": "401 Unauthorized" } - }, - { - "kind": { "StringValue": "402 Payment Required" } - }, - { - "kind": { "StringValue": "403 Forbidden" } - }, - { - "kind": { "StringValue": "404 Not Found" } - }, - { - "kind": { "StringValue": "405 Method Not Allowed" } - }, - { - "kind": { "StringValue": "406 Not Acceptable" } - }, - { - "kind": { "StringValue": "407 Proxy Authentication Required" } - }, - { - "kind": { "StringValue": "408 Request Timeout" } - }, - { - "kind": { "StringValue": "409 Conflict" } - }, - { - "kind": { "StringValue": "410 Gone" } - }, - { - "kind": { "StringValue": "411 Length Required" } - }, - { - "kind": { "StringValue": "412 Precondition Failed" } - }, - { - "kind": { "StringValue": "413 Payload Too Large" } - }, - { - "kind": { "StringValue": "414 URI Too Long" } - }, - { - "kind": { "StringValue": "415 Unsupported Media Type" } - }, - { - "kind": { "StringValue": "416 Range Not Satisfiable" } - }, - { - "kind": { "StringValue": "417 Expectation Failed" } - }, - { - "kind": { "StringValue": "418 I'm a teapot" } - }, - { - "kind": { "StringValue": "421 Misdirected Request" } - }, - { - "kind": { "StringValue": "422 Unprocessable Entity" } - }, - { - "kind": { "StringValue": "423 Locked" } - }, - { - "kind": { "StringValue": "424 Failed Dependency" } - }, - { - "kind": { "StringValue": "425 Too Early" } - }, - { - "kind": { "StringValue": "426 Upgrade Required" } - }, - { - "kind": { "StringValue": "428 Precondition Required" } - }, - { - "kind": { "StringValue": "429 Too Many Requests" } - }, - { - "kind": { "StringValue": "431 Request Header Fields Too Large" } - }, - { - "kind": { "StringValue": "451 Unavailable For Legal Reasons" } - }, - { - "kind": { "StringValue": "500 Internal Server Error" } - }, - { - "kind": { "StringValue": "501 Not Implemented" } - }, - { - "kind": { "StringValue": "502 Bad Gateway" } - }, - { - "kind": { "StringValue": "503 Service Unavailable" } - }, - { - "kind": { "StringValue": "504 Gateway Timeout" } - }, - { - "kind": { "StringValue": "505 HTTP Version Not Supported" } - }, - { - "kind": { "StringValue": "506 Variant Also Negotiates" } - }, - { - "kind": { "StringValue": "507 Insufficient Storage" } - }, - { - "kind": { "StringValue": "508 Loop Detected" } - }, - { - "kind": { "StringValue": "510 Not Extended" } - }, - { - "kind": { "StringValue": "511 Network Authentication Required" } - } - ] + "NumberRange": { + "from": 100, + "to": 599 } } }