Skip to content

Commit

Permalink
Revert "Add loading state while seam API is requested (#242)" (#246)
Browse files Browse the repository at this point in the history
This reverts commit 3378ae7.
  • Loading branch information
razor-x authored Nov 4, 2024
1 parent dd81bb2 commit 76bd03f
Show file tree
Hide file tree
Showing 14 changed files with 23 additions and 292 deletions.
9 changes: 3 additions & 6 deletions lib/interact-for-access-code.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import prompts from "prompts"
import { getSeam } from "./get-seam"
import { interactForDevice } from "./interact-for-device"
import { withLoading } from "./util/with-loading"

export const interactForAccessCode = async ({
device_id,
Expand All @@ -14,11 +13,9 @@ export const interactForAccessCode = async ({
device_id = await interactForDevice()
}

const accessCodes = await withLoading("Fetching access codes...", () =>
seam.accessCodes.list({
device_id,
})
)
const accessCodes = await seam.accessCodes.list({
device_id,
})

const { accessCodeId } = await prompts({
name: "accessCodeId",
Expand Down
5 changes: 1 addition & 4 deletions lib/interact-for-acs-entrance.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import prompts from "prompts"
import { getSeam } from "./get-seam"
import { withLoading } from "./util/with-loading"

export const interactForAcsEntrance = async () => {
const seam = await getSeam()

const entrances = await withLoading("Fetching ACS entrances...", () =>
seam.acs.entrances.list()
)
const entrances = await seam.acs.entrances.list()

const { acsEntranceId } = await prompts({
name: "acsEntranceId",
Expand Down
5 changes: 1 addition & 4 deletions lib/interact-for-acs-system.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import prompts from "prompts"
import { getSeam } from "./get-seam"
import { withLoading } from "./util/with-loading"

export const interactForAcsSystem = async (message?: string) => {
const seam = await getSeam()

const systems = await withLoading("Fetching ACS systems...", () =>
seam.acs.systems.list()
)
const systems = await seam.acs.systems.list()

const { acsSystemId } = await prompts({
name: "acsSystemId",
Expand Down
9 changes: 3 additions & 6 deletions lib/interact-for-acs-user.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import prompts from "prompts"
import { getSeam } from "./get-seam"
import { interactForAcsSystem } from "./interact-for-acs-system"
import { withLoading } from "./util/with-loading"

export const interactForAcsUser = async () => {
const seam = await getSeam()
Expand All @@ -10,11 +9,9 @@ export const interactForAcsUser = async () => {
"What acs_system does the acs_user belong to?"
)

const users = await withLoading("Fetching ACS users...", () =>
seam.acs.users.list({
acs_system_id,
})
)
const users = await seam.acs.users.list({
acs_system_id,
})

const { acsUserId } = await prompts({
name: "acsUserId",
Expand Down
11 changes: 3 additions & 8 deletions lib/interact-for-action-attempt-poll.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import prompts from "prompts"
import { getSeam } from "./get-seam"
import { ActionAttemptsGetResponse } from "@seamapi/http/connect"
import { withLoading } from "./util/with-loading"

export const interactForActionAttemptPoll = async (
action_attempt: ActionAttemptsGetResponse["action_attempt"]
Expand All @@ -20,13 +19,9 @@ export const interactForActionAttemptPoll = async (
const seam = await getSeam()
const { action_attempt_id } = action_attempt

const updated_action_attempt = await withLoading(
"Polling action attempt...",
() =>
seam.actionAttempts.get(
{ action_attempt_id },
{ waitForActionAttempt: { pollingInterval: 240, timeout: 10_000 } }
)
const updated_action_attempt = await seam.actionAttempts.get(
{ action_attempt_id },
{ waitForActionAttempt: { pollingInterval: 240, timeout: 10_000 } }
)

console.dir(updated_action_attempt, { depth: null })
Expand Down
6 changes: 1 addition & 5 deletions lib/interact-for-connected-account.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import prompts from "prompts"
import { getSeam } from "./get-seam"
import { getConfigStore } from "./get-config-store"
import { withLoading } from "./util/with-loading"
export const interactForConnectedAccount = async () => {
const seam = await getSeam()

const connected_accounts = await withLoading(
"Fetching connected accounts...",
() => seam.connectedAccounts.list()
)
const connected_accounts = await seam.connectedAccounts.list()

const { connectedAccountId } = await prompts({
name: "connectedAccountId",
Expand Down
11 changes: 3 additions & 8 deletions lib/interact-for-credential-pool.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import prompts from "prompts"
import { getSeam } from "./get-seam"
import { interactForAcsSystem } from "./interact-for-acs-system"
import { withLoading } from "./util/with-loading"

export const interactForCredentialPool = async () => {
const seam = await getSeam()
Expand All @@ -10,13 +9,9 @@ export const interactForCredentialPool = async () => {
"What acs_system does the credential pool belong to?"
)

const credentialPools = await withLoading(
"Fetching ACS credential pools...",
() =>
seam.acs.credentialPools.list({
acs_system_id,
})
)
const credentialPools = await seam.acs.credentialPools.list({
acs_system_id,
})

const { credentialPoolId } = await prompts({
name: "credentialPoolId",
Expand Down
5 changes: 1 addition & 4 deletions lib/interact-for-device.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import prompts from "prompts"
import { getSeam } from "./get-seam"
import { getConfigStore } from "./get-config-store"
import { withLoading } from "./util/with-loading"
export const interactForDevice = async () => {
const seam = await getSeam()

const devices = await withLoading("Fetching devices...", () =>
seam.devices.list()
)
const devices = await seam.devices.list()

const { deviceId } = await prompts({
name: "deviceId",
Expand Down
5 changes: 1 addition & 4 deletions lib/interact-for-user-identity.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
import prompts from "prompts"
import { getSeam } from "./get-seam"
import { withLoading } from "./util/with-loading"

export const interactForUserIdentity = async () => {
const seam = await getSeam()

const uis = await withLoading("Fetching user identities...", () =>
seam.userIdentities.list()
)
const uis = await seam.userIdentities.list()

const { userIdentityId } = await prompts({
name: "userIdentityId",
Expand Down
5 changes: 1 addition & 4 deletions lib/interact-for-workspace-id.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
import { getConfigStore } from "./get-config-store"
import prompts from "prompts"
import { getSeam, getSeamMultiWorkspace } from "./get-seam"
import { withLoading } from "./util/with-loading"

export const interactForWorkspaceId = async () => {
const config = getConfigStore()
const seam = await getSeamMultiWorkspace()

const workspaces = await withLoading("Fetching workspaces...", () =>
seam.workspaces.list()
)
const workspaces = await seam.workspaces.list()

const { workspaceId } = await prompts({
name: "workspaceId",
Expand Down
9 changes: 3 additions & 6 deletions lib/util/request-seam-api.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import type { AxiosResponse } from "axios"
import chalk from "chalk"
import { getSeam } from "../get-seam"
import { withLoading } from "./with-loading"

export const RequestSeamApi = async ({
path,
Expand All @@ -14,11 +13,9 @@ export const RequestSeamApi = async ({

logRequest(path, params)

const response = await withLoading("Making request...", () =>
seam.client.post(path, params, {
validateStatus: () => true,
})
)
const response = await seam.client.post(path, params, {
validateStatus: () => true,
})

logResponse(response)

Expand Down
16 changes: 0 additions & 16 deletions lib/util/with-loading.ts

This file was deleted.

Loading

0 comments on commit 76bd03f

Please sign in to comment.