diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..d8ac7df --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,16 @@ +name: Publish + +on: + push: + tags: + - '*' + +jobs: + publish: + runs-on: ubuntu-latest + permissions: + contents: read + id-token: write # The OIDC ID token is used for authentication with JSR. + steps: + - uses: actions/checkout@v4 + - run: npx jsr publish \ No newline at end of file diff --git a/.github/workflows/samples.yml b/.github/workflows/samples.yml index 5378534..5efbb46 100644 --- a/.github/workflows/samples.yml +++ b/.github/workflows/samples.yml @@ -42,6 +42,7 @@ jobs: --allow-read --allow-write --allow-net deno-slack-api/scripts/import_map/update.ts --import-map "./sample/import_map.json" + --parent-import-map "./deno-slack-api/deno.jsonc" --api "../deno-slack-api/src/" - name: Deno check **/*.ts diff --git a/deno.jsonc b/deno.jsonc index 79c5520..d1d36e6 100644 --- a/deno.jsonc +++ b/deno.jsonc @@ -1,39 +1,43 @@ { "$schema": "https://deno.land/x/deno/cli/schemas/config-file.v1.json", "fmt": { - "files": { - "include": [ - "src", - "scripts", - "docs", - "README.md", - ".github/maintainers_guide.md", - ".github/CONTRIBUTING.md" - ] - }, - "options": { - "semiColons": true, - "indentWidth": 2, - "lineWidth": 80, - "proseWrap": "always", - "singleQuote": false, - "useTabs": false - } + "include": [ + "src", + "scripts", + "docs", + "README.md", + ".github/maintainers_guide.md", + ".github/CONTRIBUTING.md" + ] }, "lint": { - "files": { - "include": ["src", "scripts"] - } + "include": ["src", "scripts"] + }, + "publish": { + "exclude": ["./README.md"] }, "test": { - "files": { - "include": ["src", "scripts"] - } + "include": ["src", "scripts"] }, "tasks": { "test": "deno fmt --check && deno lint && deno test", "generate-lcov": "rm -rf .coverage && deno test --reporter=dot --coverage=.coverage && deno coverage --exclude=fixtures --exclude=test --exclude=scripts --exclude=src/generated --lcov --output=lcov.info .coverage", "test:coverage": "deno task generate-lcov && deno coverage --exclude=fixtures --exclude=test --exclude=scripts --exclude=src/generated .coverage src" }, - "lock": false + "lock": false, + "name": "@slack/api", + "version": "2.9.0", + "exports": { + ".": "./src/mod.ts", + "./types": "./src/types.ts" + }, + "imports": { + "@deno/dnt": "jsr:@deno/dnt@^0.41", + "@std/assert": "jsr:@std/assert@^1", + "@std/cli": "jsr:@std/cli@^1", + "@std/fs": "jsr:@std/fs@^1", + "@std/http": "jsr:@std/http@^0.206", + "@std/testing": "jsr:@std/testing@^1", + "@std/text": "jsr:@std/text@^1" + } } diff --git a/docs/client.md b/docs/client.md index 521b237..4bdf47e 100644 --- a/docs/client.md +++ b/docs/client.md @@ -11,7 +11,7 @@ To instantiate the Slack API Client, use the top level `SlackAPI` export. default this is set to `"https://slack.com/api/"` ```ts -import { SlackAPI } from "https://deno.land/x/deno_slack_api@0.0.8/mod.ts"; +import { SlackAPI } from "jsr:@slack/api"; // create a client with defaults const client = SlackAPI(token); diff --git a/scripts/build_npm.ts b/scripts/build_npm.ts index ad20ed6..cb273fe 100644 --- a/scripts/build_npm.ts +++ b/scripts/build_npm.ts @@ -1,5 +1,6 @@ // ex. scripts/build_npm.ts -import { build, emptyDir } from "https://deno.land/x/dnt@0.34.0/mod.ts"; +import { emptyDir } from "@std/fs"; +import { build } from "@deno/dnt"; await emptyDir("./npm"); @@ -10,7 +11,7 @@ await build({ outDir: "./npm", // ensures that the emitted package is compatible with node v14 later compilerOptions: { - lib: ["es2022.error"], // fix ErrorOptions not exported in ES2020 + lib: ["ES2022.Error"], // fix ErrorOptions not exported in ES2020 target: "ES2020", }, shims: { diff --git a/scripts/import_map/update.ts b/scripts/import_map/update.ts index 2638530..75f7b55 100644 --- a/scripts/import_map/update.ts +++ b/scripts/import_map/update.ts @@ -1,18 +1,17 @@ -import { parse } from "https://deno.land/std@0.185.0/flags/mod.ts"; -import { - createHttpError, -} from "https://deno.land/std@0.182.0/http/http_errors.ts"; +import { parseArgs } from "@std/cli/parse-args"; +import { createHttpError } from "@std/http/http-errors"; // Regex for https://deno.land/x/deno_slack_api@x.x.x/ const API_REGEX = - /(https:\/\/deno.land\/x\/deno_slack_api@[0-9]+\.[0-9]+\.[0-9]+\/)/g; + /(https:\/\/deno.land\/x\/deno_slack_api@[0-9]\.[0-9]+\.[0-9]+\/)/g; async function main() { - const flags = parse(Deno.args, { - string: ["import-map", "api"], + const flags = parseArgs(Deno.args, { + string: ["import-map", "api", "parent-import-map"], default: { "import-map": `${Deno.cwd()}/import_map.json`, "api": "../deno-slack-api/src/", + "parent-import-map": undefined, }, }); @@ -37,7 +36,18 @@ async function main() { ), }; - const importMapJsonOut = JSON.stringify(importMap); + if (flags["parent-import-map"]) { + const parentImportMapJsonIn = await Deno.readTextFile( + flags["parent-import-map"], + ); + console.log("parent `import_map.json` in content:", parentImportMapJsonIn); + const parentImportMap = JSON.parse(parentImportMapJsonIn); + for (const entry of Object.entries(parentImportMap["imports"])) { + importMap["imports"][entry[0]] = entry[1]; + } + } + + const importMapJsonOut = JSON.stringify(importMap, null, 2); console.log("`import_map.json` out content:", importMapJsonOut); await Deno.writeTextFile(flags["import-map"], importMapJsonOut); diff --git a/scripts/import_map/update_test.ts b/scripts/import_map/update_test.ts index 756f4b1..cc200f2 100644 --- a/scripts/import_map/update_test.ts +++ b/scripts/import_map/update_test.ts @@ -1,11 +1,7 @@ -import { HttpError } from "../../src/deps.ts"; -import { - afterEach, - assertEquals, - assertRejects, - beforeAll, - mf, -} from "../../src/dev_deps.ts"; +import { isHttpError } from "@std/http/http-errors"; +import { mf } from "../../src/dev_deps.ts"; +import { assertEquals, assertRejects } from "@std/assert"; +import { afterEach, beforeAll } from "@std/testing/bdd"; import { apiDepsIn } from "./update.ts"; const depsTsMock = @@ -47,12 +43,8 @@ Deno.test("apiDepsIn should throw http error on response not ok", async () => { return new Response("error", { status: 500 }); }); - await assertRejects( - async () => { - return await apiDepsIn( - "https://deno.land/x/deno_slack_sdk@x.x.x/", - ); - }, - HttpError, + const error = await assertRejects(() => + apiDepsIn("https://deno.land/x/deno_slack_sdk@x.x.x/") ); + isHttpError(error); }); diff --git a/scripts/src/generate.ts b/scripts/src/generate.ts index abaeec8..62545d7 100644 --- a/scripts/src/generate.ts +++ b/scripts/src/generate.ts @@ -1,4 +1,5 @@ -import { emptyDir, ensureDir, pascalCase } from "../../src/deps.ts"; +import { toPascalCase } from "@std/text/to-pascal-case"; +import { emptyDir, ensureDir } from "@std/fs"; import { APIMethodNode } from "./api-method-node.ts"; import { getPublicAPIMethods } from "./public-api-methods.ts"; @@ -67,12 +68,12 @@ run(); const getMainAPICode = (api: APIMethodNode): string => { const imports = api.childNodes.map((node) => { - const groupAPITypeName = `${pascalCase(node.name)}APIType`; + const groupAPITypeName = `${toPascalCase(node.name)}APIType`; return `import { type ${groupAPITypeName} } from "./${node.name}.ts";`; }).join("\n"); const apiTypeMixins = api.childNodes.map((node) => { - const groupAPIName = pascalCase(node.name); + const groupAPIName = toPascalCase(node.name); return `${node.name}: ${groupAPIName}APIType,`; }).join("\n"); @@ -120,7 +121,7 @@ const getTestCode = (api: APIMethodNode) => { visitMethodNodes(api); return ` -import { assertEquals } from "../../dev_deps.ts"; +import { assertEquals } from "@std/assert"; import { SlackAPI } from "../../mod.ts"; Deno.test("SlackAPIMethodsType generated types", () => { diff --git a/src/README.md b/src/README.md index 17bf856..ece3562 100644 --- a/src/README.md +++ b/src/README.md @@ -5,7 +5,7 @@ Slack API Client for Deno Run on Slack projects ```ts -import { SlackAPI } from "https://deno.land/x/deno_slack_api@2.1.1/mod.ts"; +import { SlackAPI } from "jsr:@slack/api"; const client = SlackAPI(token); diff --git a/src/api-proxy.ts b/src/api-proxy.ts index 86730bf..fe976e0 100644 --- a/src/api-proxy.ts +++ b/src/api-proxy.ts @@ -1,5 +1,9 @@ -import { BaseSlackAPIClient } from "./base-client.ts"; -import { BaseResponse, SlackAPIClient, SlackAPIMethodArgs } from "./types.ts"; +import type { BaseSlackAPIClient } from "./base-client.ts"; +import type { + BaseResponse, + SlackAPIClient, + SlackAPIMethodArgs, +} from "./types.ts"; const DO_NOT_PROXY = ["then"]; diff --git a/src/api-proxy_test.ts b/src/api-proxy_test.ts index c9782dc..158a689 100644 --- a/src/api-proxy_test.ts +++ b/src/api-proxy_test.ts @@ -1,7 +1,7 @@ import { APIProxy } from "./api-proxy.ts"; import { BaseSlackAPIClient } from "./base-client.ts"; -import { SlackAPIMethodArgs } from "./types.ts"; -import { assertSpyCall, spy } from "./dev_deps.ts"; +import type { SlackAPIMethodArgs } from "./types.ts"; +import { assertSpyCall, spy } from "@std/testing/mock"; Deno.test("APIProxy", async (t) => { const baseClient = new BaseSlackAPIClient("test-token"); diff --git a/src/api_test.ts b/src/api_test.ts index ddf3e52..533b4e6 100644 --- a/src/api_test.ts +++ b/src/api_test.ts @@ -1,13 +1,12 @@ +import { mf } from "./dev_deps.ts"; import { assertEquals, assertExists, assertInstanceOf, assertRejects, - isHttpError, - mf, -} from "./dev_deps.ts"; +} from "@std/assert"; import { SlackAPI } from "./mod.ts"; -import { HttpError } from "./deps.ts"; +import { HttpError } from "@std/http/http-errors"; Deno.test("SlackAPI class", async (t) => { mf.install(); // mock out calls to `fetch` @@ -73,19 +72,13 @@ Deno.test("SlackAPI class", async (t) => { }); }); - await assertRejects( - async () => { - return await client.apiCall("chat.postMessage", {}); - }, - (error: Error) => { - assertInstanceOf(error, HttpError); - if (isHttpError(error)) { - assertEquals(error.headers?.get("Retry-After"), "120"); - assertEquals(error.status, 429); - assertEquals(error.message, "429: ratelimited"); - } - }, + const error = await assertRejects( + () => client.apiCall("chat.postMessage", {}), + HttpError, + "429: ratelimited", ); + assertEquals(error.headers?.get("Retry-After"), "120"); + assertEquals(error.status, 429); mf.reset(); }, @@ -142,22 +135,14 @@ Deno.test("SlackAPI class", async (t) => { }); }); - await assertRejects( - async () => { - return await client.response( - "https://slack.com/api/chat.postMessage", - {}, - ); - }, - (error: Error) => { - assertInstanceOf(error, HttpError); - if (isHttpError(error)) { - assertEquals(error.headers?.get("Retry-After"), "120"); - assertEquals(error.status, 429); - assertEquals(error.message, "429: ratelimited"); - } - }, + const error = await assertRejects( + () => + client.response("https://slack.com/api/chat.postMessage", {}), + HttpError, ); + assertEquals(error.headers?.get("Retry-After"), "120"); + assertEquals(error.status, 429); + assertEquals(error.message, "429: ratelimited"); mf.reset(); }, diff --git a/src/base-client-helpers_test.ts b/src/base-client-helpers_test.ts index a4a0f57..ebbec48 100644 --- a/src/base-client-helpers_test.ts +++ b/src/base-client-helpers_test.ts @@ -1,10 +1,10 @@ -import { assertEquals } from "https://deno.land/std@0.185.0/testing/asserts.ts"; +import { assertEquals } from "@std/assert"; import { _internals, getUserAgent, serializeData, } from "./base-client-helpers.ts"; -import { assertSpyCalls, stub } from "./dev_deps.ts"; +import { assertSpyCalls, stub } from "@std/testing/mock"; Deno.test(`base-client-helpers.${_internals.getModuleVersion.name}`, async (t) => { await t.step( diff --git a/src/base-client.ts b/src/base-client.ts index c952d75..7f9134d 100644 --- a/src/base-client.ts +++ b/src/base-client.ts @@ -1,10 +1,10 @@ -import { +import type { BaseResponse, BaseSlackClient, SlackAPIMethodArgs, SlackAPIOptions, } from "./types.ts"; -import { createHttpError, HttpError } from "./deps.ts"; +import { createHttpError, type HttpError } from "@std/http/http-errors"; import { getUserAgent, serializeData } from "./base-client-helpers.ts"; export class BaseSlackAPIClient implements BaseSlackClient { diff --git a/src/deps.ts b/src/deps.ts index 088bd97..4cffa09 100644 --- a/src/deps.ts +++ b/src/deps.ts @@ -1,6 +1 @@ -export { pascalCase } from "https://deno.land/x/case@v2.1.0/mod.ts"; -export { emptyDir, ensureDir } from "https://deno.land/std@0.67.0/fs/mod.ts"; -export { - createHttpError, - HttpError, -} from "https://deno.land/std@0.182.0/http/http_errors.ts"; +export { pascalCase } from "jsr:@wok/case@1.0.1"; diff --git a/src/dev_deps.ts b/src/dev_deps.ts index 71ecd76..02ba0ea 100644 --- a/src/dev_deps.ts +++ b/src/dev_deps.ts @@ -1,17 +1 @@ -export { assertSpyCall, spy } from "https://deno.land/x/mock@0.15.2/mod.ts"; -export { - assertEquals, - assertExists, - assertInstanceOf, - assertRejects, -} from "https://deno.land/std@0.132.0/testing/asserts.ts"; export * as mf from "https://deno.land/x/mock_fetch@0.3.0/mod.ts"; -export { isHttpError } from "https://deno.land/std@0.182.0/http/http_errors.ts"; -export { - afterEach, - beforeAll, -} from "https://deno.land/std@0.185.0/testing/bdd.ts"; -export { - assertSpyCalls, - stub, -} from "https://deno.land/std@0.185.0/testing/mock.ts"; diff --git a/src/generated/method-types/api_method_types_test.ts b/src/generated/method-types/api_method_types_test.ts index cc07d14..f2081c1 100644 --- a/src/generated/method-types/api_method_types_test.ts +++ b/src/generated/method-types/api_method_types_test.ts @@ -1,4 +1,4 @@ -import { assertEquals } from "../../dev_deps.ts"; +import { assertEquals } from "@std/assert"; import { SlackAPI } from "../../mod.ts"; Deno.test("SlackAPIMethodsType generated types", () => { diff --git a/src/generated/method-types/mod.ts b/src/generated/method-types/mod.ts index c85ad84..1a5d7f8 100644 --- a/src/generated/method-types/mod.ts +++ b/src/generated/method-types/mod.ts @@ -1,33 +1,33 @@ -import { type AdminAPIType } from "./admin.ts"; -import { type ApiAPIType } from "./api.ts"; -import { type AppsAPIType } from "./apps.ts"; -import { type AuthAPIType } from "./auth.ts"; -import { type BookmarksAPIType } from "./bookmarks.ts"; -import { type BotsAPIType } from "./bots.ts"; -import { type CallsAPIType } from "./calls.ts"; -import { type CanvasesAPIType } from "./canvases.ts"; -import { type ChatAPIType } from "./chat.ts"; -import { type ConversationsAPIType } from "./conversations.ts"; -import { type DialogAPIType } from "./dialog.ts"; -import { type DndAPIType } from "./dnd.ts"; -import { type EmojiAPIType } from "./emoji.ts"; -import { type EnterpriseAPIType } from "./enterprise.ts"; -import { type FilesAPIType } from "./files.ts"; -import { type MigrationAPIType } from "./migration.ts"; -import { type OauthAPIType } from "./oauth.ts"; -import { type OpenidAPIType } from "./openid.ts"; -import { type PinsAPIType } from "./pins.ts"; -import { type ReactionsAPIType } from "./reactions.ts"; -import { type RemindersAPIType } from "./reminders.ts"; -import { type RtmAPIType } from "./rtm.ts"; -import { type SearchAPIType } from "./search.ts"; -import { type StarsAPIType } from "./stars.ts"; -import { type TeamAPIType } from "./team.ts"; -import { type ToolingAPIType } from "./tooling.ts"; -import { type UsergroupsAPIType } from "./usergroups.ts"; -import { type UsersAPIType } from "./users.ts"; -import { type ViewsAPIType } from "./views.ts"; -import { type WorkflowsAPIType } from "./workflows.ts"; +import type { AdminAPIType } from "./admin.ts"; +import type { ApiAPIType } from "./api.ts"; +import type { AppsAPIType } from "./apps.ts"; +import type { AuthAPIType } from "./auth.ts"; +import type { BookmarksAPIType } from "./bookmarks.ts"; +import type { BotsAPIType } from "./bots.ts"; +import type { CallsAPIType } from "./calls.ts"; +import type { CanvasesAPIType } from "./canvases.ts"; +import type { ChatAPIType } from "./chat.ts"; +import type { ConversationsAPIType } from "./conversations.ts"; +import type { DialogAPIType } from "./dialog.ts"; +import type { DndAPIType } from "./dnd.ts"; +import type { EmojiAPIType } from "./emoji.ts"; +import type { EnterpriseAPIType } from "./enterprise.ts"; +import type { FilesAPIType } from "./files.ts"; +import type { MigrationAPIType } from "./migration.ts"; +import type { OauthAPIType } from "./oauth.ts"; +import type { OpenidAPIType } from "./openid.ts"; +import type { PinsAPIType } from "./pins.ts"; +import type { ReactionsAPIType } from "./reactions.ts"; +import type { RemindersAPIType } from "./reminders.ts"; +import type { RtmAPIType } from "./rtm.ts"; +import type { SearchAPIType } from "./search.ts"; +import type { StarsAPIType } from "./stars.ts"; +import type { TeamAPIType } from "./team.ts"; +import type { ToolingAPIType } from "./tooling.ts"; +import type { UsergroupsAPIType } from "./usergroups.ts"; +import type { UsersAPIType } from "./users.ts"; +import type { ViewsAPIType } from "./views.ts"; +import type { WorkflowsAPIType } from "./workflows.ts"; export type SlackAPIMethodsType = { admin: AdminAPIType; diff --git a/src/mod.ts b/src/mod.ts index 1398e3c..ea98ec8 100644 --- a/src/mod.ts +++ b/src/mod.ts @@ -1,5 +1,5 @@ import { BaseSlackAPIClient } from "./base-client.ts"; -import { SlackAPIOptions } from "./types.ts"; +import type { SlackAPIClient, SlackAPIOptions } from "./types.ts"; import { ProxifyAndTypeClient } from "./api-proxy.ts"; export { @@ -8,7 +8,10 @@ export { } from "./typed-method-types/workflows/triggers/mod.ts"; export { TriggerEventTypes } from "./typed-method-types/workflows/triggers/trigger-event-types.ts"; -export const SlackAPI = (token: string, options: SlackAPIOptions = {}) => { +export const SlackAPI = ( + token: string, + options: SlackAPIOptions = {}, +): SlackAPIClient => { // Create our base client instance const baseClient = new BaseSlackAPIClient(token, options); diff --git a/src/typed-method-types/apps.ts b/src/typed-method-types/apps.ts index 0e4f836..722dd14 100644 --- a/src/typed-method-types/apps.ts +++ b/src/typed-method-types/apps.ts @@ -1,4 +1,4 @@ -import { +import type { BaseMethodArgs, BaseResponse, CursorPaginationArgs, diff --git a/src/typed-method-types/chat.ts b/src/typed-method-types/chat.ts index 69d85e5..428b0e0 100644 --- a/src/typed-method-types/chat.ts +++ b/src/typed-method-types/chat.ts @@ -1,4 +1,4 @@ -import { BaseResponse } from "../types.ts"; +import type { BaseResponse } from "../types.ts"; type ChatPostMessageOptionalArgs = { /** @description The formatted text of the message to be published. If blocks are included, this will become the fallback text used in notifications. */ diff --git a/src/typed-method-types/functions.ts b/src/typed-method-types/functions.ts index c6af931..90259da 100644 --- a/src/typed-method-types/functions.ts +++ b/src/typed-method-types/functions.ts @@ -1,4 +1,4 @@ -import { BaseResponse } from "../types.ts"; +import type { BaseResponse } from "../types.ts"; type FunctionCompleteSuccessArgs = { // deno-lint-ignore no-explicit-any diff --git a/src/typed-method-types/mod.ts b/src/typed-method-types/mod.ts index c01f3b3..3fcc899 100644 --- a/src/typed-method-types/mod.ts +++ b/src/typed-method-types/mod.ts @@ -2,10 +2,10 @@ * This file is intended as a way to add custom types for specific methods beyond the autogenerated method types * It is meant to be additive to the SlackClient type */ -import { TypedAppsMethodTypes } from "./apps.ts"; -import { TypedChatMethodTypes } from "./chat.ts"; -import { TypedFunctionMethodTypes } from "./functions.ts"; -import { TypedWorkflowsMethodTypes } from "./workflows/mod.ts"; +import type { TypedAppsMethodTypes } from "./apps.ts"; +import type { TypedChatMethodTypes } from "./chat.ts"; +import type { TypedFunctionMethodTypes } from "./functions.ts"; +import type { TypedWorkflowsMethodTypes } from "./workflows/mod.ts"; /** * When adding a new type here, run `scripts/src/generate` diff --git a/src/typed-method-types/typed-method-tests.ts b/src/typed-method-types/typed-method-tests.ts index ee6ac9f..d396b4c 100644 --- a/src/typed-method-types/typed-method-tests.ts +++ b/src/typed-method-types/typed-method-tests.ts @@ -1,4 +1,4 @@ -import { assertEquals } from "../dev_deps.ts"; +import { assertEquals } from "@std/assert"; import { SlackAPI } from "../mod.ts"; Deno.test("Custom Type Methods are valid functions", () => { diff --git a/src/typed-method-types/workflows/mod.ts b/src/typed-method-types/workflows/mod.ts index f754221..a119ab8 100644 --- a/src/typed-method-types/workflows/mod.ts +++ b/src/typed-method-types/workflows/mod.ts @@ -1,4 +1,4 @@ -import { TypedWorkflowsTriggersMethodTypes } from "./triggers/mod.ts"; +import type { TypedWorkflowsTriggersMethodTypes } from "./triggers/mod.ts"; export type TypedWorkflowsMethodTypes = { workflows: { diff --git a/src/typed-method-types/workflows/triggers/base_response.ts b/src/typed-method-types/workflows/triggers/base_response.ts index ead1fcc..86d099b 100644 --- a/src/typed-method-types/workflows/triggers/base_response.ts +++ b/src/typed-method-types/workflows/triggers/base_response.ts @@ -1,4 +1,4 @@ -import { BaseTrigger, WorkflowSchema } from "./mod.ts"; +import type { BaseTrigger, WorkflowSchema } from "./mod.ts"; export type BaseTriggerResponse< WorkflowDefinition extends WorkflowSchema, diff --git a/src/typed-method-types/workflows/triggers/event.ts b/src/typed-method-types/workflows/triggers/event.ts index 935ebfc..be96480 100644 --- a/src/typed-method-types/workflows/triggers/event.ts +++ b/src/typed-method-types/workflows/triggers/event.ts @@ -1,14 +1,17 @@ -import { BaseResponse } from "../../../types.ts"; -import { BaseTriggerResponse } from "./base_response.ts"; -import { +import type { BaseResponse } from "../../../types.ts"; +import type { BaseTriggerResponse } from "./base_response.ts"; +import type { BaseTrigger, FailedTriggerResponse, TriggerTypes, WorkflowSchema, } from "./mod.ts"; -import { FilterType } from "./trigger-filter.ts"; -import { ObjectValueUnion, PopulatedArray } from "../../../type-helpers.ts"; -import { TriggerEventTypes } from "./trigger-event-types.ts"; +import type { FilterType } from "./trigger-filter.ts"; +import type { + ObjectValueUnion, + PopulatedArray, +} from "../../../type-helpers.ts"; +import type { TriggerEventTypes } from "./trigger-event-types.ts"; type MessageMetadataTypes = ObjectValueUnion< Pick< diff --git a/src/typed-method-types/workflows/triggers/inputs.ts b/src/typed-method-types/workflows/triggers/inputs.ts index 66030b2..0d57658 100644 --- a/src/typed-method-types/workflows/triggers/inputs.ts +++ b/src/typed-method-types/workflows/triggers/inputs.ts @@ -1,4 +1,4 @@ -import { NO_GENERIC_TITLE, WorkflowSchema } from "./mod.ts"; +import type { NO_GENERIC_TITLE, WorkflowSchema } from "./mod.ts"; // deno-lint-ignore no-explicit-any type EmptyObject = Record; diff --git a/src/typed-method-types/workflows/triggers/mod.ts b/src/typed-method-types/workflows/triggers/mod.ts index f957cff..6ffa8ad 100644 --- a/src/typed-method-types/workflows/triggers/mod.ts +++ b/src/typed-method-types/workflows/triggers/mod.ts @@ -1,26 +1,26 @@ -import { +import type { BaseMethodArgs, BaseResponse, CursorPaginationArgs, CursorPaginationResponse, } from "../../../types.ts"; -import { InputParameterSchema, WorkflowInputs } from "./inputs.ts"; -import { +import type { InputParameterSchema, WorkflowInputs } from "./inputs.ts"; +import type { EventTrigger, EventTriggerResponse, EventTriggerResponseObject, } from "./event.ts"; -import { +import type { ScheduledTrigger, ScheduledTriggerResponse, ScheduledTriggerResponseObject, } from "./scheduled.ts"; -import { +import type { ShortcutTrigger, ShortcutTriggerResponse, ShortcutTriggerResponseObject, } from "./shortcut.ts"; -import { +import type { WebhookTrigger, WebhookTriggerResponse, WebhookTriggerResponseObject, diff --git a/src/typed-method-types/workflows/triggers/scheduled.ts b/src/typed-method-types/workflows/triggers/scheduled.ts index c5b97f4..405aaee 100644 --- a/src/typed-method-types/workflows/triggers/scheduled.ts +++ b/src/typed-method-types/workflows/triggers/scheduled.ts @@ -1,6 +1,6 @@ -import { BaseResponse } from "../../../types.ts"; -import { BaseTriggerResponse } from "./base_response.ts"; -import { +import type { BaseResponse } from "../../../types.ts"; +import type { BaseTriggerResponse } from "./base_response.ts"; +import type { BaseTrigger, FailedTriggerResponse, TriggerTypes, diff --git a/src/typed-method-types/workflows/triggers/shortcut.ts b/src/typed-method-types/workflows/triggers/shortcut.ts index 55e8712..79bd306 100644 --- a/src/typed-method-types/workflows/triggers/shortcut.ts +++ b/src/typed-method-types/workflows/triggers/shortcut.ts @@ -1,6 +1,6 @@ -import { BaseResponse } from "../../../types.ts"; -import { BaseTriggerResponse } from "./base_response.ts"; -import { +import type { BaseResponse } from "../../../types.ts"; +import type { BaseTriggerResponse } from "./base_response.ts"; +import type { BaseTrigger, FailedTriggerResponse, TriggerTypes, diff --git a/src/typed-method-types/workflows/triggers/tests/context_test.ts b/src/typed-method-types/workflows/triggers/tests/context_test.ts index 2307ef6..45eb037 100644 --- a/src/typed-method-types/workflows/triggers/tests/context_test.ts +++ b/src/typed-method-types/workflows/triggers/tests/context_test.ts @@ -1,4 +1,4 @@ -import { assertEquals } from "../../../../dev_deps.ts"; +import { assertEquals } from "@std/assert"; import { TriggerContextData } from "../mod.ts"; Deno.test("TriggerContextData Objects allow property access or string references", async (t) => { diff --git a/src/typed-method-types/workflows/triggers/tests/crud_test.ts b/src/typed-method-types/workflows/triggers/tests/crud_test.ts index 901d8f2..47f67a5 100644 --- a/src/typed-method-types/workflows/triggers/tests/crud_test.ts +++ b/src/typed-method-types/workflows/triggers/tests/crud_test.ts @@ -1,4 +1,4 @@ -import { assertEquals } from "https://deno.land/std@0.99.0/testing/asserts.ts"; +import { assertEquals, assertObjectMatch } from "@std/assert"; import { SlackAPI } from "../../../../mod.ts"; import * as mf from "https://deno.land/x/mock_fetch@0.3.0/mod.ts"; import { @@ -71,7 +71,7 @@ Deno.test("Mock CRUD call", async (t) => { }); assertEquals(res.ok, true); if (res.ok) { - assertEquals(res.trigger, shortcut_response.trigger); + assertObjectMatch(res.trigger, shortcut_response.trigger); assertEquals( res.trigger?.shortcut_url, shortcut_response.trigger.shortcut_url, @@ -107,7 +107,7 @@ Deno.test("Mock CRUD call", async (t) => { }); assertEquals(res.ok, true); if (res.ok) { - assertEquals(res.trigger, shortcut_response.trigger); + assertObjectMatch(res.trigger, shortcut_response.trigger); assertEquals( res.trigger?.shortcut_url, shortcut_response.trigger.shortcut_url, diff --git a/src/typed-method-types/workflows/triggers/tests/event_test.ts b/src/typed-method-types/workflows/triggers/tests/event_test.ts index 77baa94..cceceb5 100644 --- a/src/typed-method-types/workflows/triggers/tests/event_test.ts +++ b/src/typed-method-types/workflows/triggers/tests/event_test.ts @@ -1,9 +1,9 @@ -import { assertEquals } from "../../../../dev_deps.ts"; +import { assertEquals, assertObjectMatch } from "@std/assert"; import { SlackAPI, TriggerEventTypes, TriggerTypes } from "../../../../mod.ts"; import * as mf from "https://deno.land/x/mock_fetch@0.3.0/mod.ts"; import { event_response } from "./fixtures/sample_responses.ts"; -import { ExampleWorkflow } from "./fixtures/workflows.ts"; -import { EventTrigger } from "../event.ts"; +import type { ExampleWorkflow } from "./fixtures/workflows.ts"; +import type { EventTrigger } from "../event.ts"; Deno.test("Event trigger type tests", async (t) => { await t.step("Event triggers can set the type using the string", () => { @@ -202,7 +202,7 @@ Deno.test("Mock call for event", async (t) => { }); assertEquals(res.ok, true); if (res.ok) { - assertEquals(res.trigger, event_response.trigger); + assertObjectMatch(res.trigger, event_response.trigger); assertEquals( res.trigger?.event_type, event_response.trigger.event_type, @@ -242,7 +242,7 @@ Deno.test("Mock call for event", async (t) => { }); assertEquals(res.ok, true); if (res.ok) { - assertEquals(res.trigger, event_response.trigger); + assertObjectMatch(res.trigger, event_response.trigger); assertEquals( res.trigger?.event_type, event_response.trigger.event_type, diff --git a/src/typed-method-types/workflows/triggers/tests/scheduled_test.ts b/src/typed-method-types/workflows/triggers/tests/scheduled_test.ts index 99ef32f..9429631 100644 --- a/src/typed-method-types/workflows/triggers/tests/scheduled_test.ts +++ b/src/typed-method-types/workflows/triggers/tests/scheduled_test.ts @@ -1,5 +1,6 @@ -import { assertEquals, mf } from "../../../../dev_deps.ts"; -import { ScheduledTrigger } from "../scheduled.ts"; +import { mf } from "../../../../dev_deps.ts"; +import { assertEquals, assertObjectMatch } from "@std/assert"; +import type { ScheduledTrigger } from "../scheduled.ts"; import { TriggerTypes } from "../mod.ts"; import { SlackAPI } from "../../../../mod.ts"; import { scheduled_response } from "./fixtures/sample_responses.ts"; @@ -233,7 +234,7 @@ Deno.test("Mock call for schedule", async (t) => { }); assertEquals(res.ok, true); if (res.ok) { - assertEquals(res.trigger, scheduled_response.trigger); + assertObjectMatch(res.trigger, scheduled_response.trigger); assertEquals( res.trigger?.schedule, scheduled_response.trigger.schedule, @@ -289,7 +290,7 @@ Deno.test("Mock call for schedule", async (t) => { }); assertEquals(res.ok, true); if (res.ok) { - assertEquals(res.trigger, scheduled_response.trigger); + assertObjectMatch(res.trigger, scheduled_response.trigger); assertEquals( res.trigger?.schedule, scheduled_response.trigger.schedule, diff --git a/src/typed-method-types/workflows/triggers/tests/shortcut_test.ts b/src/typed-method-types/workflows/triggers/tests/shortcut_test.ts index c1064ca..cce9b26 100644 --- a/src/typed-method-types/workflows/triggers/tests/shortcut_test.ts +++ b/src/typed-method-types/workflows/triggers/tests/shortcut_test.ts @@ -1,5 +1,5 @@ -import { assertEquals } from "https://deno.land/std@0.99.0/testing/asserts.ts"; -import { ShortcutTrigger } from "../shortcut.ts"; +import { assertEquals, assertObjectMatch } from "@std/assert"; +import type { ShortcutTrigger } from "../shortcut.ts"; import { TriggerTypes } from "../mod.ts"; import * as mf from "https://deno.land/x/mock_fetch@0.3.0/mod.ts"; import { SlackAPI } from "../../../../mod.ts"; @@ -63,7 +63,7 @@ Deno.test("Mock call for shortcut", async (t) => { }); assertEquals(res.ok, true); if (res.ok) { - assertEquals(res.trigger, shortcut_response.trigger); + assertObjectMatch(res.trigger, shortcut_response.trigger); assertEquals( res.trigger?.shortcut_url, shortcut_response.trigger.shortcut_url, @@ -98,7 +98,7 @@ Deno.test("Mock call for shortcut", async (t) => { }); assertEquals(res.ok, true); if (res.ok) { - assertEquals(res.trigger, shortcut_response.trigger); + assertObjectMatch(res.trigger, shortcut_response.trigger); assertEquals( res.trigger?.shortcut_url, shortcut_response.trigger.shortcut_url, diff --git a/src/typed-method-types/workflows/triggers/tests/trigger-filter_test.ts b/src/typed-method-types/workflows/triggers/tests/trigger-filter_test.ts index e921580..3c54700 100644 --- a/src/typed-method-types/workflows/triggers/tests/trigger-filter_test.ts +++ b/src/typed-method-types/workflows/triggers/tests/trigger-filter_test.ts @@ -1,5 +1,8 @@ -import { assertEquals, assertExists } from "../../../../dev_deps.ts"; -import { FilterType, TriggerFilterOperatorType } from "../trigger-filter.ts"; +import { assertEquals, assertExists } from "@std/assert"; +import { + type FilterType, + TriggerFilterOperatorType, +} from "../trigger-filter.ts"; Deno.test("Trigger Filters can use a single statement", () => { const filter: FilterType = { diff --git a/src/typed-method-types/workflows/triggers/tests/trigger-workflow_test.ts b/src/typed-method-types/workflows/triggers/tests/trigger-workflow_test.ts index f86b7eb..6ea33de 100644 --- a/src/typed-method-types/workflows/triggers/tests/trigger-workflow_test.ts +++ b/src/typed-method-types/workflows/triggers/tests/trigger-workflow_test.ts @@ -1,9 +1,5 @@ import { SlackAPI } from "../../../../mod.ts"; -import { - _format, - assert, - assertEquals, -} from "https://deno.land/std@0.99.0/testing/asserts.ts"; +import { assert, assertEquals } from "@std/assert"; import type { CustomizableInputWorkflow, ExampleWorkflow, @@ -15,7 +11,7 @@ import type { } from "./fixtures/workflows.ts"; import * as mf from "https://deno.land/x/mock_fetch@0.3.0/mod.ts"; import { shortcut_response } from "./fixtures/sample_responses.ts"; -import { Trigger } from "../../../../types.ts"; +import type { Trigger } from "../../../../types.ts"; Deno.test("Trigger inputs are powered by generics", async (t) => { const client = SlackAPI(""); diff --git a/src/typed-method-types/workflows/triggers/tests/webhook_test.ts b/src/typed-method-types/workflows/triggers/tests/webhook_test.ts index 55fd450..e6f5157 100644 --- a/src/typed-method-types/workflows/triggers/tests/webhook_test.ts +++ b/src/typed-method-types/workflows/triggers/tests/webhook_test.ts @@ -1,5 +1,6 @@ -import { assertEquals, mf } from "../../../../dev_deps.ts"; -import { WebhookTrigger } from "../webhook.ts"; +import { mf } from "../../../../dev_deps.ts"; +import { assertEquals, assertObjectMatch } from "@std/assert"; +import type { WebhookTrigger } from "../webhook.ts"; import { TriggerTypes } from "../mod.ts"; import { SlackAPI } from "../../../../mod.ts"; import { webhook_response } from "./fixtures/sample_responses.ts"; @@ -82,7 +83,7 @@ Deno.test("Mock call for webhook", async (t) => { }); assertEquals(res.ok, true); if (res.ok) { - assertEquals(res.trigger, webhook_response.trigger); + assertObjectMatch(res.trigger, webhook_response.trigger); assertEquals( res.trigger?.webhook_url, webhook_response.trigger.webhook_url, @@ -122,7 +123,7 @@ Deno.test("Mock call for webhook", async (t) => { }); assertEquals(res.ok, true); if (res.ok) { - assertEquals(res.trigger, webhook_response.trigger); + assertObjectMatch(res.trigger, webhook_response.trigger); assertEquals( res.trigger?.webhook_url, webhook_response.trigger.webhook_url, diff --git a/src/typed-method-types/workflows/triggers/webhook.ts b/src/typed-method-types/workflows/triggers/webhook.ts index f52efa6..d9b7b1f 100644 --- a/src/typed-method-types/workflows/triggers/webhook.ts +++ b/src/typed-method-types/workflows/triggers/webhook.ts @@ -1,12 +1,12 @@ -import { BaseResponse } from "../../../types.ts"; -import { BaseTriggerResponse } from "./base_response.ts"; -import { +import type { BaseResponse } from "../../../types.ts"; +import type { BaseTriggerResponse } from "./base_response.ts"; +import type { BaseTrigger, FailedTriggerResponse, TriggerTypes, WorkflowSchema, } from "./mod.ts"; -import { FilterType } from "./trigger-filter.ts"; +import type { FilterType } from "./trigger-filter.ts"; export type WebhookTrigger = & BaseTrigger diff --git a/src/types.ts b/src/types.ts index 13159e3..f448fbf 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,5 +1,5 @@ -import { TypedSlackAPIMethodsType } from "./typed-method-types/mod.ts"; -import { SlackAPIMethodsType } from "./generated/method-types/mod.ts"; +import type { TypedSlackAPIMethodsType } from "./typed-method-types/mod.ts"; +import type { SlackAPIMethodsType } from "./generated/method-types/mod.ts"; export type { DatastoreItem } from "./typed-method-types/apps.ts";