Skip to content
Merged
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
3 changes: 0 additions & 3 deletions eslint.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ export default [
{
files: ['src/bin/**/*.ts', 'src/lib/**/*.ts'],
rules: {
// TODO: Rename the identifiers that mirror the snake_case parameter names
// of the Seam API so that everything here is camelCase.
camelcase: 'off',
// TODO: Replace the console calls with a logger wrapper.
'no-console': 'off',
},
Expand Down
8 changes: 4 additions & 4 deletions src/bin/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,10 +126,10 @@ async function cli(args: ParsedArgs) {
args[k.toLowerCase().replace(/-/g, '_')] = args[k]
}

const use_remote_api_defs =
const useRemoteApiDefs =
args['remote_api_defs'] ?? config.get('use_remote_api_defs')

const blueprint = await getApiBlueprint(use_remote_api_defs ?? false, {
const blueprint = await getApiBlueprint(useRemoteApiDefs ?? false, {
update,
})

Expand Down Expand Up @@ -287,10 +287,10 @@ const toCommandWord = (arg: string): string =>
arg.toLowerCase().replace(/_/g, '-')

const handleConnectWebviewResponse = async (
connect_webview: any,
connectWebview: any,
interactivity: Interactivity,
) => {
const url = connect_webview.url
const url = connectWebview.url

if (
interactivity !== 'non-interactive' &&
Expand Down
10 changes: 6 additions & 4 deletions src/lib/interact-for-access-code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,21 @@ import { interactForDevice } from './interact-for-device.js'
import { interactForResource } from './interact-for-resource.js'

export const interactForAccessCode = async ({
device_id,
// The key is a Seam API parameter name: callers pass the blueprint params
// bag through as-is, so only the binding may be camelCase.
device_id: deviceId,
}: {
device_id?: string
}) => {
const seam = await getSeam()

if (!device_id) {
device_id = await interactForDevice()
if (!deviceId) {
deviceId = await interactForDevice()
}

return interactForResource({
resourceName: 'access_code',
fetchResources: () => seam.accessCodes.list({ device_id }),
fetchResources: () => seam.accessCodes.list({ device_id: deviceId }),
toChoice: (accessCode) => ({
title: accessCode.name ?? '<No Name>',
value: accessCode.access_code_id,
Expand Down
4 changes: 2 additions & 2 deletions src/lib/interact-for-acs-user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import { interactForResource } from './interact-for-resource.js'
export const interactForAcsUser = async () => {
const seam = await getSeam()

const acs_system_id = await interactForAcsSystem(
const acsSystemId = await interactForAcsSystem(
'What acs_system does the acs_user belong to?',
)

return interactForResource({
resourceName: 'ACS user',
fetchResources: () => seam.acs.users.list({ acs_system_id }),
fetchResources: () => seam.acs.users.list({ acs_system_id: acsSystemId }),
toChoice: (user) => ({
title: `${user.display_name} ${user.email_address}`,
value: user.acs_user_id,
Expand Down
18 changes: 9 additions & 9 deletions src/lib/interact-for-action-attempt-poll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,31 @@ import { prompt } from './util/prompt.js'
import { withLoading } from './util/with-loading.js'

export const interactForActionAttemptPoll = async (
action_attempt: ActionAttemptsGetResponse['action_attempt'],
actionAttempt: ActionAttemptsGetResponse['action_attempt'],
) => {
if (action_attempt.status === 'pending') {
const { poll_for_action_attempt } = await prompt({
name: 'poll_for_action_attempt',
if (actionAttempt.status === 'pending') {
const { pollForActionAttempt } = await prompt({
name: 'pollForActionAttempt',
message: "Would you like to poll the action attempt until it's ready?",
type: 'toggle',
initial: true,
active: 'yes',
inactive: 'no',
})

if (poll_for_action_attempt) {
if (pollForActionAttempt) {
const seam = await getSeam()
const { action_attempt_id } = action_attempt
const { action_attempt_id: actionAttemptId } = actionAttempt

const updated_action_attempt = await withLoading(
const updatedActionAttempt = await withLoading(
'Polling action attempt...',
() =>
seam.actionAttempts.get(
{ action_attempt_id },
{ action_attempt_id: actionAttemptId },
{ waitForActionAttempt: { pollingInterval: 240, timeout: 10_000 } },
),
)
getOutput().data({ action_attempt: updated_action_attempt })
getOutput().data({ action_attempt: updatedActionAttempt })
}
}
}
14 changes: 6 additions & 8 deletions src/lib/interact-for-blueprint-object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ export const interactForBlueprintObject = async (

const cmdPath = `/${args.command.join('/').replace(/-/g, '_')}`

const should_auto_submit =
const shouldAutoSubmit =
ctx.interactivity !== 'interactive' &&
haveAllRequiredParams &&
!args.isSubProperty
if (should_auto_submit) {
if (shouldAutoSubmit) {
return args.params
}

Expand Down Expand Up @@ -160,18 +160,16 @@ export const interactForBlueprintObject = async (
args.params[paramToEdit] = await interactForAccessCode(args.params as any)
return interactForBlueprintObject(args, ctx)
} else if (paramToEdit === 'connected_account_id') {
const connected_account_id = await interactForConnectedAccount()
args.params[paramToEdit] = connected_account_id
const connectedAccountId = await interactForConnectedAccount()
args.params[paramToEdit] = connectedAccountId
return interactForBlueprintObject(args, ctx)
} else if (
paramToEdit === 'user_identity_id' ||
paramToEdit === 'user_identity_ids'
) {
const user_identity_id = await interactForUserIdentity()
const userIdentityId = await interactForUserIdentity()
args.params[paramToEdit] =
paramToEdit === 'user_identity_ids'
? [user_identity_id]
: user_identity_id
paramToEdit === 'user_identity_ids' ? [userIdentityId] : userIdentityId
return interactForBlueprintObject(args, ctx)
} else if (paramToEdit.endsWith('acs_system_id')) {
args.params[paramToEdit] = await interactForAcsSystem()
Expand Down
38 changes: 18 additions & 20 deletions src/lib/interact-for-custom-metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ type UpdatedCustomMetadata = {
}

export const interactForCustomMetadata = async (
custom_metadata: CustomMetadata,
customMetadata: CustomMetadata,
) => {
const updated_custom_metadata: UpdatedCustomMetadata = { ...custom_metadata }
const updatedCustomMetadata: UpdatedCustomMetadata = { ...customMetadata }
const output = getOutput()

const displayCurrentCustomMetadata = () => {
output.info('custom_metadata:')
if (Object.keys(updated_custom_metadata).length > 0) {
Object.keys(updated_custom_metadata).forEach((key, index) => {
output.info(`${index + 1}: ${key}: ${updated_custom_metadata[key]}`)
if (Object.keys(updatedCustomMetadata).length > 0) {
Object.keys(updatedCustomMetadata).forEach((key, index) => {
output.info(`${index + 1}: ${key}: ${updatedCustomMetadata[key]}`)
})
} else {
output.info('The custom metadata param is empty.')
Expand Down Expand Up @@ -61,31 +61,29 @@ export const interactForCustomMetadata = async (
newValue = Boolean(newValue)
}
if (newValue === 'null') {
updated_custom_metadata[newKey] = null
updatedCustomMetadata[newKey] = null
} else {
updated_custom_metadata[newKey] = newValue
updatedCustomMetadata[newKey] = newValue
}
}
} else if (action === 'remove') {
const { custom_key_to_remove } = await prompt({
const { customKeyToRemove } = await prompt({
type: 'select',
name: 'custom_key_to_remove',
name: 'customKeyToRemove',
message: 'Choose a key-value pair to remove from params:',
choices: Object.keys(updated_custom_metadata).map(
(custom_metadata_key) => {
return {
title: `${custom_metadata_key}: ${updated_custom_metadata[custom_metadata_key]}`,
value: custom_metadata_key,
}
},
),
choices: Object.keys(updatedCustomMetadata).map((customMetadataKey) => {
return {
title: `${customMetadataKey}: ${updatedCustomMetadata[customMetadataKey]}`,
value: customMetadataKey,
}
}),
})

if (custom_key_to_remove) {
delete custom_metadata[custom_key_to_remove]
if (customKeyToRemove) {
delete customMetadata[customKeyToRemove]
}
}
} while (action !== 'done')

return updated_custom_metadata
return updatedCustomMetadata
}
8 changes: 4 additions & 4 deletions src/lib/interact-for-use-remote-api-defs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { getOutput } from './output/get-output.js'
import { prompt } from './util/prompt.js'

export async function interactForUseRemoteApiDefs() {
const { use_remote_api_defs } = await prompt([
const { useRemoteApiDefs } = await prompt([
{
type: 'select',
name: 'use_remote_api_defs',
name: 'useRemoteApiDefs',
message: 'Always use remote API Definitions?',
choices: [
{
Expand All @@ -22,6 +22,6 @@ export async function interactForUseRemoteApiDefs() {
])

const config = getConfigStore()
config.set('use_remote_api_defs', use_remote_api_defs)
getOutput().info(`Use remote API Definitions: ${use_remote_api_defs}`)
config.set('use_remote_api_defs', useRemoteApiDefs)
getOutput().info(`Use remote API Definitions: ${useRemoteApiDefs}`)
}
Loading