Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions interface/package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "@polywrap/http-interface",
"description": "Polywrap Http Interface",
"description": "Polywrap HTTP Interface",
"version": "0.10.0",
"scripts": {
"build": "npx polywrap build",
"deploy": "npx polywrap deploy -o deployment.json"
},
"devDependencies": {
"polywrap": "0.10.2"
"polywrap": "0.10.3"
},
"publishConfig": {
"access": "public"
Expand Down
3 changes: 1 addition & 2 deletions interface/polywrap.deploy.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
format: 0.3.0
primaryJobName: ipfs_deploy
format: 0.2.0
jobs:
ipfs_deploy:
steps:
Expand Down
133 changes: 101 additions & 32 deletions interface/polywrap.graphql
Original file line number Diff line number Diff line change
@@ -1,42 +1,111 @@
"""
Response: Represents the server's response to an HTTP request.
"""
type Response {
status: Int!
statusText: String!
headers: Map @annotate(type: "Map<String!, String!>")
body: String
"""
status: HTTP status code of the response.
"""
status: Int!

"""
statusText: The text phrase corresponding to the status code.
"""
statusText: String!

"""
headers: HTTP headers in the response.
"""
headers: Map @annotate(type: "Map<String!, String!>")

"""
body: The body of the response, if any.
"""
body: String
}

"""
Request: Represents an HTTP request to be sent to a server.
"""
type Request {
headers: Map @annotate(type: "Map<String!, String!>")
urlParams: Map @annotate(type: "Map<String!, String!>")
responseType: ResponseType!
"""The body of the request. If present, the `formData` property will be ignored."""
body: String
"""
An alternative to the standard request body, 'formData' is expected to be in the 'multipart/form-data' format.
If present, the `body` property is not null, `formData` will be ignored.
Otherwise, if formData is not null, the following header will be added to the request: 'Content-Type: multipart/form-data'.
"""
formData: [FormDataEntry!]
timeout: UInt32
}
"""
The request destination
"""
url: String!,

type FormDataEntry {
"""FormData entry key"""
name: String!
"""If 'type' is defined, value is treated as a base64 byte string"""
value: String
"""File name to report to the server"""
fileName: String
"""MIME type (https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types). Defaults to empty string."""
type: String
"""
The HTTP request method to use
"""
method: HTTPMethod!,

"""
HTTP headers to be included in the request.
"""
headers: Map @annotate(type: "Map<String!, String!>")

"""
The body of the request, if any.
"""
body: String

"""
Timeout for the request in milliseconds. If not set, the request will not timeout.
"""
timeout: Int
}

enum ResponseType {
TEXT
BINARY
"""
Specifies the HTTP method to be used when making the request.
"""
enum HTTPMethod {
"""
The HTTP GET method requests a representation of the specified resource.
"""
GET

"""
The HTTP POST method sends data to the server to create a new resource.
"""
POST

"""
The HTTP PUT method updates a current resource with new data.
"""
PUT

"""
The HTTP DELETE method deletes the specified resource.
"""
DELETE

"""
The HTTP HEAD method asks for a response identical to that of a GET request, but without the response body.
"""
HEAD

"""
The HTTP PATCH method is used to apply partial modifications to a resource.
"""
PATCH

"""
The HTTP OPTIONS method describes the communication options for the target resource.
"""
OPTIONS

"""
The HTTP CONNECT method is used by the client to establish a network connection to a web resource via HTTP, usually to facilitate HTTPS-secured communication (SSL Tunneling).
"""
CONNECT

"""
The HTTP TRACE method performs a message loop-back test along the path to the target resource, providing a useful diagnostic tool for seeing what's being received at the other end.
"""
TRACE
}

type Module {
get(url: String!, request: Request): Response
post(url: String!, request: Request): Response
}
"""
Send an HTTP Request to the specified URL using the specified method.
"""
request(request: Request): Response
}
1 change: 0 additions & 1 deletion interface/polywrap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,3 @@ project:
type: interface
source:
schema: ./polywrap.graphql
resources: ./resources
55 changes: 21 additions & 34 deletions interface/resources/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# HTTP Wrapper Interface
# Datetime Wrapper Interface

| Version | URI | WRAP Version |
|-|-|-|
| 1.0.0 | [`wrap://ens/wraps.eth:http@1.0.0`](https://wrappers.io/v/ens/wraps.eth:http@1.0.0) | 0.1 |
| 1.1.0 | [`wrap://ens/wraps.eth:http@1.1.0`](https://wrappers.io/v/ens/wraps.eth:http@1.1.0) | 0.1 |
| Version | URI | WRAP Version |
|---------|-------------------------------------------------------------------------------------|-|
| 2.0.0 | [`wrap://ens/wraps.eth:http@2.0.0`](https://wrappers.io/v/ens/wraps.eth:http@2.0.0) | 0.1 |

## Interface
```graphql
Expand All @@ -15,51 +14,39 @@ type Response {
}

type Request {
url: String!
method: HTTPMethod!
headers: Map @annotate(type: "Map<String!, String!>")
urlParams: Map @annotate(type: "Map<String!, String!>")
responseType: ResponseType!
"""The body of the request. If present, the `formData` property will be ignored."""
body: String
"""
An alternative to the standard request body, 'formData' is expected to be in the 'multipart/form-data' format.
If present, the `body` property is not null, `formData` will be ignored.
Otherwise, if formData is not null, the following header will be added to the request: 'Content-Type: multipart/form-data'.
"""
formData: [FormDataEntry!]
timeout: UInt32
timeout: Int
}

type FormDataEntry {
"""FormData entry key"""
name: String!
"""If 'type' is defined, value is treated as a base64 byte string"""
value: String
"""File name to report to the server"""
fileName: String
"""MIME type (https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types). Defaults to empty string."""
type: String
}

enum ResponseType {
TEXT
BINARY
enum HTTPMethod {
GET
POST
PUT
DELETE
HEAD
PATCH
OPTIONS
CONNECT
TRACE
}

type Module {
get(url: String!, request: Request): Response
post(url: String!, request: Request): Response
request(request: Request): Response
}
```

## Usage
```graphql
#import * from "ens/wraps.eth:http@1.1.0"
#import * from "ens/wraps.eth:http@2.0.0"
```

And implement the `get` + `post` methods within your programming language of choice.
And implement the interface methods within your programming language of choice.

## Source Code
[Link](https://github.com/polywrap/http)
[Link](https://github.com/polywrap/std/http)

## Known Implementations
[Link](https://github.com/polywrap/http/tree/master/implementations)
86 changes: 43 additions & 43 deletions interface/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -728,10 +728,10 @@
"@polywrap/core-js" "0.10.0-pre.10"
"@polywrap/plugin-js" "0.10.0-pre.10"

"@polywrap/logging-js@0.10.2":
version "0.10.2"
resolved "https://registry.yarnpkg.com/@polywrap/logging-js/-/logging-js-0.10.2.tgz#cc89544e82440400de682ed7af4ad0eaef89f864"
integrity sha512-mglQRHNJULl3F4YPRPkUUL1Zp/IjRfaNarXgXR4NLlEINU3+pzshGuJoMGCj2/mUWjsox3L8OjfzCjVBy+N+vw==
"@polywrap/logging-js@0.10.3":
version "0.10.3"
resolved "https://registry.yarnpkg.com/@polywrap/logging-js/-/logging-js-0.10.3.tgz#356524d3b7381da3621138e2b68363055e253e71"
integrity sha512-3zQe6cWz5RWXttoPLlQiWOHKHwrYixKV80Ob49+ntpLxJ2ymEa2ZZMQChFCBYyl/F39JMolKNX4qWGjSK0V86w==

"@polywrap/msgpack-js@0.10.0":
version "0.10.0"
Expand All @@ -754,10 +754,10 @@
dependencies:
"@msgpack/msgpack" "2.7.2"

"@polywrap/os-js@0.10.2":
version "0.10.2"
resolved "https://registry.yarnpkg.com/@polywrap/os-js/-/os-js-0.10.2.tgz#26ea20d96ffbe328900bc6bf6b646a9d1cbcac9a"
integrity sha512-bTShjmw9vBcI6ZdC/rLdFlWuWXh2Xha6B/He+vzA4/vF5I9eyAxABfrsl4/ySqFFSsLdMITeQRzyFQXfcd0+FQ==
"@polywrap/os-js@0.10.3":
version "0.10.3"
resolved "https://registry.yarnpkg.com/@polywrap/os-js/-/os-js-0.10.3.tgz#980ca439c25265ef1450467286324edae650c3c2"
integrity sha512-if6LYsRsRGJcMl65nBVTimjzPpz4xfa7OjhfYzRdmASTVeOSEn4bdIm5PVAGOA+jEzVv1HQ0pFnF+n08tfjlUA==

"@polywrap/plugin-js@0.10.0":
version "0.10.0"
Expand Down Expand Up @@ -792,18 +792,18 @@
"@polywrap/tracing-js" "0.10.0-pre.12"
"@polywrap/wrap-manifest-types-js" "0.10.0-pre.12"

"@polywrap/polywrap-manifest-schemas@0.10.2":
version "0.10.2"
resolved "https://registry.yarnpkg.com/@polywrap/polywrap-manifest-schemas/-/polywrap-manifest-schemas-0.10.2.tgz#369c9e12d9260b971ac2ff57dda2b886595435bb"
integrity sha512-5AggU1dz6pIXs0FfpxToyXcZdF31+3Ap3TdmOCnlOImhTDiYBaHj9wnvaffIm5TCe97QTTiND7KSljKtMd51Pg==
"@polywrap/polywrap-manifest-schemas@0.10.3":
version "0.10.3"
resolved "https://registry.yarnpkg.com/@polywrap/polywrap-manifest-schemas/-/polywrap-manifest-schemas-0.10.3.tgz#4da56f8d35849366e6f66bbcaf90c95b468d9fb2"
integrity sha512-XzIzDbtQLqa6/W+130r/STTnSbphn23gfdkKiyju6Yws9NSW5zFwnr26CcHEuQLIHXjacTcV2ULYDOTwoJLXlA==

"@polywrap/polywrap-manifest-types-js@0.10.2":
version "0.10.2"
resolved "https://registry.yarnpkg.com/@polywrap/polywrap-manifest-types-js/-/polywrap-manifest-types-js-0.10.2.tgz#5777888497429db6767c68ba2cf8ae1e4c0a44b3"
integrity sha512-bHlCp74W0dXMPI3ZZslTIWIuHMVaWKRv/OQ6UAS+d1pMoIgDdAA5xkNorW+rfRaRQWeGMTRdqBi7i/PPh+mrYA==
"@polywrap/polywrap-manifest-types-js@0.10.3":
version "0.10.3"
resolved "https://registry.yarnpkg.com/@polywrap/polywrap-manifest-types-js/-/polywrap-manifest-types-js-0.10.3.tgz#9be5d23f0efa93ebd500fa4f9c3af1ff75124d07"
integrity sha512-oPlUNh++goGoWPmZvdt4fv10JpHARf5Yniwt6JTGVqb/JdhKjQggRU92NIFMRs+KHDx1qqivwl1FtQV5Dk/cyQ==
dependencies:
"@polywrap/logging-js" "0.10.2"
"@polywrap/polywrap-manifest-schemas" "0.10.2"
"@polywrap/logging-js" "0.10.3"
"@polywrap/polywrap-manifest-schemas" "0.10.3"
jsonschema "1.4.0"
semver "7.5.0"
yaml "2.2.2"
Expand All @@ -823,30 +823,30 @@
resolved "https://registry.yarnpkg.com/@polywrap/result/-/result-0.10.0-pre.12.tgz#530f8f5ced2bef189466f9fb8b41a520b12e9372"
integrity sha512-KnGRJMBy1SCJt3mymO3ob0e1asqYOyY+NNKySQ5ocvG/iMlhtODs4dy2EeEtcIFZ+c7TyBPVD4SI863qHQGOUQ==

"@polywrap/schema-bind@0.10.2":
version "0.10.2"
resolved "https://registry.yarnpkg.com/@polywrap/schema-bind/-/schema-bind-0.10.2.tgz#219c5fe618357be2d83a28739cf7048706cbbd7d"
integrity sha512-7PObwLAgdd/uwReG1yi70SvtlFlL4KtYqBaLtjQeDO8Iocx0y+MnI11VnGdAI/vY+Qu8L5IlG3yFN/hhXZu5hQ==
"@polywrap/schema-bind@0.10.3":
version "0.10.3"
resolved "https://registry.yarnpkg.com/@polywrap/schema-bind/-/schema-bind-0.10.3.tgz#15b35bed1f045ca817184e7b897678d7eb810ef2"
integrity sha512-TLyX+nVXr/Hw18KC58KJvKYNxF888wjaqtrQvPN8ZmSCu++pRhZDMG0WaBDid+NKELrFpnRkBSnC7SKDRyBzBQ==
dependencies:
"@polywrap/os-js" "0.10.2"
"@polywrap/schema-parse" "0.10.2"
"@polywrap/os-js" "0.10.3"
"@polywrap/schema-parse" "0.10.3"
"@polywrap/wrap-manifest-types-js" "0.10.0"
mustache "4.0.1"

"@polywrap/schema-compose@0.10.2":
version "0.10.2"
resolved "https://registry.yarnpkg.com/@polywrap/schema-compose/-/schema-compose-0.10.2.tgz#6a4bf769605d5508e4ab5655b8e5a3526b1640b3"
integrity sha512-S1b0W2yhqLZduXVVh2k18aQ96SFoqmmQOxXL8zG4dbOOFs1k5VvO45rKHhC/Yy8TmT0TGs0IWSiU5Iq5P6KdGA==
"@polywrap/schema-compose@0.10.3":
version "0.10.3"
resolved "https://registry.yarnpkg.com/@polywrap/schema-compose/-/schema-compose-0.10.3.tgz#44c5540e4dca823cea3ac892d110c665ce6c10d1"
integrity sha512-heMq61cKvSQB6PORRjYnKDwGIVqcSHM1Co5v994vf3eBwGHNTmfkeTGspmdotgF9uwRp2yG038Leijni55o4cQ==
dependencies:
"@polywrap/schema-parse" "0.10.2"
"@polywrap/schema-parse" "0.10.3"
"@polywrap/wrap-manifest-types-js" "0.10.0"
graphql "15.5.0"
mustache "4.0.1"

"@polywrap/schema-parse@0.10.2":
version "0.10.2"
resolved "https://registry.yarnpkg.com/@polywrap/schema-parse/-/schema-parse-0.10.2.tgz#d4436555602dbd645051a5686ec05a342f749a99"
integrity sha512-9lO5l4pOlc4+VW4XJrWEXkiXjtsUvqiiZRJAX57Q58zRXenUrDq/DS4SukmY+Bls8By+4+WMya+Mgfg4LZS7kQ==
"@polywrap/schema-parse@0.10.3":
version "0.10.3"
resolved "https://registry.yarnpkg.com/@polywrap/schema-parse/-/schema-parse-0.10.3.tgz#9dbb146eb9fbac8a4e4fd258500d0658a2c3a718"
integrity sha512-3ksFvk/adVsR5StLJ5OK26OYhP9lYIBr0ipZMVMyA3c+2DGN7LH8i9Hn3v5tJgjvojzwAIWyNWBrbUBTIV2Tsg==
dependencies:
"@dorgjelli/graphql-schema-cycles" "1.1.4"
"@polywrap/wrap-manifest-types-js" "0.10.0"
Expand Down Expand Up @@ -2457,10 +2457,10 @@ picomatch@^2.0.4, picomatch@^2.2.1:
resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42"
integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==

polywrap@0.10.2:
version "0.10.2"
resolved "https://registry.yarnpkg.com/polywrap/-/polywrap-0.10.2.tgz#ed70f76459c7a57c99932aea220b1ccba054e778"
integrity sha512-MH28MdM9XcdE2Y3kvK8wyvJ7GXKe9X34i3IdbcrGzy/tc1ki3RAzUazse7tLMX1qnatUsJSgNC+wF8Bfae/Jhg==
polywrap@0.10.3:
version "0.10.3"
resolved "https://registry.yarnpkg.com/polywrap/-/polywrap-0.10.3.tgz#3c476b2116fa4a0351406df0cc86165bff8edff5"
integrity sha512-3VC+CKaLgYLjsnvJGK9TAhYESXpFOk2BrtQAnkK2J+/B0ppqT0DfNLcHeutOjqPQ/9TMmXbLQ7ljnAov2hzyMQ==
dependencies:
"@apidevtools/json-schema-ref-parser" "9.0.9"
"@ethersproject/providers" "5.6.8"
Expand All @@ -2471,13 +2471,13 @@ polywrap@0.10.2:
"@polywrap/client-js" "0.10.0"
"@polywrap/core-js" "0.10.0"
"@polywrap/ethereum-provider-js-v1" "npm:@polywrap/ethereum-provider-js@~0.2.4"
"@polywrap/logging-js" "0.10.2"
"@polywrap/os-js" "0.10.2"
"@polywrap/polywrap-manifest-types-js" "0.10.2"
"@polywrap/logging-js" "0.10.3"
"@polywrap/os-js" "0.10.3"
"@polywrap/polywrap-manifest-types-js" "0.10.3"
"@polywrap/result" "0.10.0"
"@polywrap/schema-bind" "0.10.2"
"@polywrap/schema-compose" "0.10.2"
"@polywrap/schema-parse" "0.10.2"
"@polywrap/schema-bind" "0.10.3"
"@polywrap/schema-compose" "0.10.3"
"@polywrap/schema-parse" "0.10.3"
"@polywrap/uri-resolver-extensions-js" "0.10.0"
"@polywrap/uri-resolvers-js" "0.10.0"
"@polywrap/wasm-js" "0.10.0"
Expand Down