Skip to content

Commit

Permalink
Added additional types for Typescript
Browse files Browse the repository at this point in the history
This continues work from #286, adding Typescript type info for other
features that have been added.
  • Loading branch information
jroper committed Apr 6, 2022
1 parent 99236d0 commit da59163
Show file tree
Hide file tree
Showing 3 changed files with 309 additions and 0 deletions.
91 changes: 91 additions & 0 deletions sdk/src/cloudevent.jsdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
/*
* Copyright 2022 Lightbend Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* @classdesc CloudEvent data.
*
* This exposes CloudEvent data from metadata. Changes made to the Cloudevent are reflected in the backing metadata,
* as are changes to the backing metadata reflected in this CloudEvent.
*
* @class module:akkaserverless.Cloudevent
* @param {module:akkaserverless.Metadata} metadata The metadata backing this CloudEvent.
*/

/**
* The metadata backing this CloudEvent.
*
* @name module:akkaserverless.Cloudevent#metadata
* @type {module:akkaserverless.Metadata}
* @readonly
*/

/**
* The spec version
*
* @name module:akkaserverless.Cloudevent#specversion
* @type {string | undefined}
* @readonly
*/

/**
* The id
*
* @name module:akkaserverless.Cloudevent#id
* @type {string | undefined}
*/

/**
* The source
*
* @name module:akkaserverless.Cloudevent#source
* @type {string | undefined}
*/

/**
* The type
*
* @name module:akkaserverless.Cloudevent#type
* @type {string | undefined}
*/

/**
* The datacontenttype
*
* @name module:akkaserverless.Cloudevent#datacontenttype
* @type {string | undefined}
*/

/**
* The dataschema
*
* @name module:akkaserverless.Cloudevent#dataschema
* @type {string | undefined}
*/

/**
* The subject
*
* @name module:akkaserverless.Cloudevent#subject
* @type {string | undefined}
*/

/**
* The time
*
* @name module:akkaserverless.Cloudevent#time
* @type {Date | undefined}
*/

176 changes: 176 additions & 0 deletions sdk/src/jwt-claims.jsdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
/*
* Copyright 2022 Lightbend Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/**
* @classdesc JWT claims.
*
* This exposes an JWT claims that were extracted from the bearer token.
*
* @class module:akkaserverless.JwtClaims
* @param {module:akkaserverless.Metadata} metadata The metadata that the JWT claims com efrom.
*/

/**
* The metadata backing this JWT claims object.
*
* @name module:akkaserverless.JwtClaims#metadata
* @type {module:akkaserverless.Metadata}
* @readonly
*/

/**
* The issuer
*
* @name module:akkaserverless.JwtClaims#issuer
* @type {string | undefined}
* @readonly
*/

/**
* The subject
*
* @name module:akkaserverless.JwtClaims#subject
* @type {string | undefined}
* @readonly
*/

/**
* The audience
*
* @name module:akkaserverless.JwtClaims#audience
* @type {string | undefined}
* @readonly
*/

/**
* The expiration time
*
* @name module:akkaserverless.JwtClaims#expirationTime
* @type {Date | undefined}
* @readonly
*/

/**
* The not before
*
* @name module:akkaserverless.JwtClaims#notBefore
* @type {Date | undefined}
* @readonly
*/

/**
* The issued at
*
* @name module:akkaserverless.JwtClaims#issuedAt
* @type {Date | undefined}
* @readonly
*/

/**
* The jwt id
*
* @name module:akkaserverless.JwtClaims#jwtId
* @type {string | undefined}
* @readonly
*/

/**
* Get the string claim with the given name.
*
* @function module:akkaserverless.JwtClaims#getString
* @param {string} name The name of the claim.
* @returns {string | undefined} the claim, or undefined if it doesn't exist or is not of the right type.
*/

/**
* Get the numeric claim with the given name.
*
* @function module:akkaserverless.JwtClaims#getNumber
* @param {string} name The name of the claim.
* @returns {number | undefined} the claim, or undefined if it doesn't exist or is not of the right type.
*/

/**
* Get the numeric date claim with the given name.
*
* @function module:akkaserverless.JwtClaims#getNumericDate
* @param {string} name The name of the claim.
* @returns {Date | undefined} the claim, or undefined if it doesn't exist or is not of the right type.
*/

/**
* Get the boolean claim with the given name.
*
* @function module:akkaserverless.JwtClaims#getBoolean
* @param {string} name The name of the claim.
* @returns {boolean | undefined} the claim, or undefined if it doesn't exist or is not of the right type.
*/

/**
* Get the object claim with the given name.
*
* @function module:akkaserverless.JwtClaims#getObject
* @param {string} name The name of the claim.
* @returns {object | undefined} the claim, or undefined if it doesn't exist or is not of the right type.
*/

/**
* Get the string array claim with the given name.
*
* @function module:akkaserverless.JwtClaims#getStringArray
* @param {string} name The name of the claim.
* @returns {string[] | undefined} the claim, or undefined if it doesn't exist or is not of the right type.
*/

/**
* Get the numeric array claim with the given name.
*
* @function module:akkaserverless.JwtClaims#getNumberArray
* @param {string} name The name of the claim.
* @returns {number[] | undefined} the claim, or undefined if it doesn't exist or is not of the right type.
*/

/**
* Get the boolean array claim with the given name.
*
* @function module:akkaserverless.JwtClaims#getBooleanArray
* @param {string} name The name of the claim.
* @returns {boolean[] | undefined} the claim, or undefined if it doesn't exist or is not of the right type.
*/

/**
* Get the object array claim with the given name.
*
* @function module:akkaserverless.JwtClaims#getObjectArray
* @param {string} name The name of the claim.
* @returns {object[] | undefined} the claim, or undefined if it doesn't exist or is not of the right type.
*/

/**
* Get the numeric date array claim with the given name.
*
* @function module:akkaserverless.JwtClaims#getNumericDateArray
* @param {string} name The name of the claim.
* @returns {Date[] | undefined} the claim, or undefined if it doesn't exist or is not of the right type.
*/








42 changes: 42 additions & 0 deletions sdk/src/metadata.jsdoc
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,53 @@
* @param {module:akkaserverless.MetadataEntry[]} [entries=[]] The list of entries
*/

/**
* The entries as a map of keys to single values.
*
* This allows working with the metadata as if it's just a map with single values for each key.
*
* Modifications to the object will be reflected by replacing all values for a given key with a single value for the\
* key.
*
* Keys are also treated case insensitively.
*
* @name module:akkaserverless.Metadata#asMap
* @type {Object.<string,string|Buffer|undefined>}
* @readonly
*/

/**
* The CloudEvent information extracted from the metadata.
*
* @name module:akkaserverless.Metadata#cloudevent
* @type {module:akkaserverless.Cloudevent}
* @readonly
*/


/**
* The JWT claims information extracted from the metadata.
*
* @name module:akkaserverless.Metadata#jwtClaims
* @type {module:akkaserverless.JwtClaims}
* @readonly
*/

/**
* @function module:akkaserverless.Metadata#getSubject
* @returns {module:akkaserverless.MetadataValue|undefined} CloudEvent subject value.
*/

/**
* Set the HTTP status code for the response when sending a successful response using HTTP transcoding.
*
* This will only apply to responses that are being transcoded to plain HTTP from gRPC using the protobuf HTTP
* annotations. When gRPC is being used, calling this has no effect.
*
* @function module:akkaserverless.Metadata#setHttpStatusCode
* @param {number} code The HTTP status code.
*/

/**
* Create a new MetadataEntry.
*
Expand Down

0 comments on commit da59163

Please sign in to comment.