diff --git a/src/events/index.js b/src/events/index.js index c949ea89..c3c2e48d 100644 --- a/src/events/index.js +++ b/src/events/index.js @@ -4,26 +4,5 @@ let subFactory = require('./subscribe') module.exports = function eventsAndQueuesFactory (arc, type) { let publish = pubFactory(arc, type) let subscribe = subFactory(type) - return { - /** - * `arc.events|queues.publish` - * publish events and queues - * - * @param {Object} params - * @param {String} params.name - the event name (required) - * @param {Object} params.payload - a json event payload (required) - * @param {Function} callback - a node style errback (optional) - * @returns {Promise} - returned if no callback is supplied - */ - publish, - - /** - * `arc.events|queues.subscribe` - * listen for events and queues - * - * @param {Function} handler - a single event handler function - * @returns {Lambda} - a Lambda function sig - */ - subscribe - } + return { publish, subscribe } } diff --git a/src/static/index.js b/src/static/index.js index 7e57bc87..e25387e2 100644 --- a/src/static/index.js +++ b/src/static/index.js @@ -8,7 +8,7 @@ let { join } = require('path') * In order to keep this method sync, it does not use reflection to get fingerprint status * - Not checking @static fingerprint true (which we used to read from the .arc file) is possibly dangerous, so ensure asset path is valid * - ? TODO: add fingerprint state to env vars in Arc 6 to restore config safety? - * @param {string} path - the path to the asset (eg. /index.js) + * @param {string} asset - the path to the asset (eg. /index.js) * @returns {string} path - the resolved asset path (eg. /_static/index-xxx.js) */ module.exports = function _static (asset, options = {}) { diff --git a/src/ws/index.js b/src/ws/index.js index bd1d1589..80be0b52 100644 --- a/src/ws/index.js +++ b/src/ws/index.js @@ -28,14 +28,6 @@ function instantiateAPI () { }) } -/** - * arc.ws._api - * - * Get the raw WebSocket client - * - * @param {Function} callback - a node style errback (optional) - * @returns {Promise} - returned if no callback is supplied - */ function _api (callback) { if (callback) instantiateAPI() .then(client => callback(null, client.ApiGatewayManagementApi)) @@ -48,17 +40,6 @@ function _api (callback) { }) } -/** - * arc.ws.send - * - * Publish WebSocket events - * - * @param {Object} params - * @param {String} params.id - the ws connection id (required) - * @param {Object} params.payload - an event payload (required) - * @param {Function} callback - a node style errback (optional) - * @returns {Promise} - returned if no callback is supplied - */ function send ({ id, payload }, callback) { if (callback) instantiateAPI() .then(client => { @@ -87,16 +68,6 @@ function send ({ id, payload }, callback) { }) } -/** - * arc.ws.close - * - * Terminate a WebSocket client connection - * - * @param {Object} params - * @param {String} params.id - the ws connection id (required) - * @param {Function} callback - a node style errback (optional) - * @returns {Promise} - returned if no callback is supplied - */ function close ({ id }, callback) { if (callback) instantiateAPI() .then(client => { @@ -123,16 +94,6 @@ function close ({ id }, callback) { }) } -/** - * arc.ws.info - * - * Get info on a WebSocket client connection - * - * @param {Object} params - * @param {String} params.id - the ws connection id (required) - * @param {Function} callback - a node style errback (optional) - * @returns {Promise} - returned if no callback is supplied - */ function info ({ id }, callback) { if (callback) instantiateAPI() .then(client => { diff --git a/types/events.d.ts b/types/events.d.ts index 6de8fe75..5c5fada3 100644 --- a/types/events.d.ts +++ b/types/events.d.ts @@ -5,21 +5,6 @@ import type { SendMessageResponse as SqsPublishResponse } from "@aws-lite/sqs-ty // Turn off automatic exporting export { }; -// // import { PublishResponse } from "@aws-sdk/client-sns"; // @3.503.1 -// interface PublishResponse { -// MessageId?: string; -// SequenceNumber?: string; -// } - -// // import { SendMessageResult } from "@aws-sdk/client-sqs"; // @3.503.1 -// interface SendMessageResult { -// MD5OfMessageBody?: string; -// MD5OfMessageAttributes?: string; -// MD5OfMessageSystemAttributes?: string; -// MessageId?: string; -// SequenceNumber?: string; -// } - interface Params { name: string; payload: Payload; diff --git a/types/index.test-d.ts b/types/index.test-d.ts index 5ba5de3e..7e5b8e57 100644 --- a/types/index.test-d.ts +++ b/types/index.test-d.ts @@ -8,6 +8,10 @@ import arc from "../"; import type { HttpHandler, HttpAsyncHandler } from "../" import type { HttpMethods, HttpRequest, HttpResponse } from "./http"; +// SERVICES +const servicesResult = await arc.services(); +expectType>(servicesResult); + // EVENTS const eventsPublishArg = { name: "test", payload: { foo: "bar" } }; const eventsPublishResult = await arc.events.publish(eventsPublishArg); @@ -124,7 +128,7 @@ await myTable.scanAll({ }) // WS -expectType(arc.ws._api); +expectType(await arc.ws._api()); expectType(await arc.ws.send({ id: "foo", payload: { bar: "baz" } })); expectType(await arc.ws.close({ id: "foo" })); expectType( diff --git a/types/ws.d.ts b/types/ws.d.ts index 18e6e4d9..bef3fdb9 100644 --- a/types/ws.d.ts +++ b/types/ws.d.ts @@ -10,7 +10,8 @@ type CloseParams = { id: string }; type InfoParams = { id: string }; export interface ArcWebSocket { - _api: AwsLiteClient["ApiGatewayManagementApi"]; + _api(): Promise; + _api(callback: Callback): void; send(params: SendParams): Promise; send(params: SendParams, callback: Callback): void;