Skip to content

Commit

Permalink
adding deprecation notices to Steps from Apps stuff, and dropping rem…
Browse files Browse the repository at this point in the history
…inder removal todos for eventual removal
  • Loading branch information
filmaj committed Sep 27, 2024
1 parent 80dc2c6 commit e0988da
Show file tree
Hide file tree
Showing 7 changed files with 88 additions and 7 deletions.
3 changes: 3 additions & 0 deletions src/App.ts
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,8 @@ export default class App<AppCustomContext extends StringIndexed = StringIndexed>
* Register WorkflowStep middleware
*
* @param workflowStep global workflow step middleware function
* @deprecated Steps from Apps are no longer supported and support for them will be removed in the next major bolt-js
* version.
*/
public step(workflowStep: WorkflowStep): this {
const m = workflowStep.getMiddleware();
Expand Down Expand Up @@ -997,6 +999,7 @@ export default class App<AppCustomContext extends StringIndexed = StringIndexed>

// Set body and payload
// TODO: this value should eventually conform to AnyMiddlewareArgs
// TODO: remove workflow step stuff in bolt v5
let payload: DialogSubmitAction | WorkflowStepEdit | SlackShortcut | KnownEventFromType<string> | SlashCommand
| KnownOptionsPayloadFromType<string> | BlockElementAction | ViewOutput | InteractiveAction;
// TODO: can we instead use type predicates in these switch cases to allow for narrowing of the body simultaneously? we have isEvent, isView, isShortcut, isAction already in types/utilities / helpers
Expand Down
72 changes: 68 additions & 4 deletions src/WorkflowStep.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,19 @@ import { WorkflowStepInitializationError } from './errors';

/** Interfaces */

/** @deprecated Steps from Apps are no longer supported and support for them will be removed in the next major bolt-js
* version.
*/
export interface StepConfigureArguments {
blocks: (KnownBlock | Block)[];
private_metadata?: string;
submit_disabled?: boolean;
external_id?: string;
}

/** @deprecated Steps from Apps are no longer supported and support for them will be removed in the next major bolt-js
* version.
*/
export interface StepUpdateArguments {
inputs?: {
[key: string]: {
Expand All @@ -50,50 +56,80 @@ export interface StepUpdateArguments {
step_image_url?: string;
}

/** @deprecated Steps from Apps are no longer supported and support for them will be removed in the next major bolt-js
* version.
*/
export interface StepCompleteArguments {
outputs?: {
[key: string]: any;
};
}

/** @deprecated Steps from Apps are no longer supported and support for them will be removed in the next major bolt-js
* version.
*/
export interface StepFailArguments {
error: {
message: string;
};
}

/** @deprecated Steps from Apps are no longer supported and support for them will be removed in the next major bolt-js
* version.
*/
export interface StepConfigureFn {
(params: StepConfigureArguments): Promise<ViewsOpenResponse>;
}

/** @deprecated Steps from Apps are no longer supported and support for them will be removed in the next major bolt-js
* version.
*/
export interface StepUpdateFn {
(params?: StepUpdateArguments): Promise<WorkflowsUpdateStepResponse>;
}

/** @deprecated Steps from Apps are no longer supported and support for them will be removed in the next major bolt-js
* version.
*/
export interface StepCompleteFn {
(params?: StepCompleteArguments): Promise<WorkflowsStepCompletedResponse>;
}

/** @deprecated Steps from Apps are no longer supported and support for them will be removed in the next major bolt-js
* version.
*/
export interface StepFailFn {
(params: StepFailArguments): Promise<WorkflowsStepFailedResponse>;
}

/** @deprecated Steps from Apps are no longer supported and support for them will be removed in the next major bolt-js
* version.
*/
export interface WorkflowStepConfig {
edit: WorkflowStepEditMiddleware | WorkflowStepEditMiddleware[];
save: WorkflowStepSaveMiddleware | WorkflowStepSaveMiddleware[];
execute: WorkflowStepExecuteMiddleware | WorkflowStepExecuteMiddleware[];
}

/** @deprecated Steps from Apps are no longer supported and support for them will be removed in the next major bolt-js
* version.
*/
export interface WorkflowStepEditMiddlewareArgs extends SlackActionMiddlewareArgs<WorkflowStepEdit> {
step: WorkflowStepEdit['workflow_step'];
configure: StepConfigureFn;
}

/** @deprecated Steps from Apps are no longer supported and support for them will be removed in the next major bolt-js
* version.
*/
export interface WorkflowStepSaveMiddlewareArgs extends SlackViewMiddlewareArgs<ViewWorkflowStepSubmitAction> {
step: ViewWorkflowStepSubmitAction['workflow_step'];
update: StepUpdateFn;
}

/** @deprecated Steps from Apps are no longer supported and support for them will be removed in the next major bolt-js
* version.
*/
export interface WorkflowStepExecuteMiddlewareArgs extends SlackEventMiddlewareArgs<'workflow_step_execute'> {
step: WorkflowStepExecuteEvent['workflow_step'];
complete: StepCompleteFn;
Expand All @@ -102,29 +138,48 @@ export interface WorkflowStepExecuteMiddlewareArgs extends SlackEventMiddlewareA

/** Types */

/** @deprecated Steps from Apps are no longer supported and support for them will be removed in the next major bolt-js
* version.
*/
export type SlackWorkflowStepMiddlewareArgs =
| WorkflowStepEditMiddlewareArgs
| WorkflowStepSaveMiddlewareArgs
| WorkflowStepExecuteMiddlewareArgs;

/** @deprecated Steps from Apps are no longer supported and support for them will be removed in the next major bolt-js
* version.
*/
export type WorkflowStepEditMiddleware = Middleware<WorkflowStepEditMiddlewareArgs>;
/** @deprecated Steps from Apps are no longer supported and support for them will be removed in the next major bolt-js
* version.
*/
export type WorkflowStepSaveMiddleware = Middleware<WorkflowStepSaveMiddlewareArgs>;
/** @deprecated Steps from Apps are no longer supported and support for them will be removed in the next major bolt-js
* version.
*/
export type WorkflowStepExecuteMiddleware = Middleware<WorkflowStepExecuteMiddlewareArgs>;

/** @deprecated Steps from Apps are no longer supported and support for them will be removed in the next major bolt-js
* version.
*/
export type WorkflowStepMiddleware =
| WorkflowStepEditMiddleware[]
| WorkflowStepSaveMiddleware[]
| WorkflowStepExecuteMiddleware[];

/** @deprecated Steps from Apps are no longer supported and support for them will be removed in the next major bolt-js
* version.
*/
export type AllWorkflowStepMiddlewareArgs<T extends SlackWorkflowStepMiddlewareArgs = SlackWorkflowStepMiddlewareArgs> =
T & AllMiddlewareArgs;

/** Constants */

const VALID_PAYLOAD_TYPES = new Set(['workflow_step_edit', 'workflow_step', 'workflow_step_execute']);

/** Class */

/** @deprecated Steps from Apps are no longer supported and support for them will be removed in the next major bolt-js
* version.
*/
export class WorkflowStep {
/** Step callback_id */
private callbackId: string;
Expand Down Expand Up @@ -185,6 +240,9 @@ export class WorkflowStep {

/** Helper Functions */

/** @deprecated Steps from Apps are no longer supported and support for them will be removed in the next major bolt-js
* version.
*/
export function validate(callbackId: string, config: WorkflowStepConfig): void {
// Ensure callbackId is valid
if (typeof callbackId !== 'string') {
Expand Down Expand Up @@ -224,6 +282,8 @@ export function validate(callbackId: string, config: WorkflowStepConfig): void {

/**
* `processStepMiddleware()` invokes each callback for lifecycle event
* @deprecated Steps from Apps are no longer supported and support for them will be removed in the next major bolt-js
* version.
* @param args workflow_step_edit action
*/
export async function processStepMiddleware(
Expand All @@ -243,6 +303,9 @@ export async function processStepMiddleware(
}
}

/** @deprecated Steps from Apps are no longer supported and support for them will be removed in the next major bolt-js
* version.
*/
export function isStepEvent(args: AnyMiddlewareArgs): args is AllWorkflowStepMiddlewareArgs {
return VALID_PAYLOAD_TYPES.has(args.payload.type);
}
Expand Down Expand Up @@ -345,8 +408,9 @@ function createStepFail(args: AllWorkflowStepMiddlewareArgs<WorkflowStepExecuteM
* 1. removes the next() passed in from App-level middleware processing
* - events will *not* continue down global middleware chain to subsequent listeners
* 2. augments args with step lifecycle-specific properties/utilities
* */
// TODO :: refactor to incorporate a generic parameter
* @deprecated Steps from Apps are no longer supported and support for them will be removed in the next major bolt-js
* version.
*/
export function prepareStepArgs(args: any): AllWorkflowStepMiddlewareArgs {
const { next: _next, ...stepArgs } = args;
const preparedArgs: any = { ...stepArgs };
Expand Down
6 changes: 5 additions & 1 deletion src/errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export enum ErrorCode {
*/
UnknownError = 'slack_bolt_unknown_error',

// TODO: remove workflow step stuff in bolt v5
WorkflowStepInitializationError = 'slack_bolt_workflow_step_initialization_error',

CustomFunctionInitializationError = 'slack_bolt_custom_function_initialization_error',
Expand Down Expand Up @@ -143,7 +144,10 @@ export class MultipleListenerError extends Error implements CodedError {
this.originals = originals;
}
}

/**
* @deprecated Steps from Apps are no longer supported and support for them will be removed in the next major bolt-js
* version.
*/
export class WorkflowStepInitializationError extends Error implements CodedError {
public code = ErrorCode.WorkflowStepInitializationError;
}
Expand Down
1 change: 1 addition & 0 deletions src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ export function getTypeAndConversation(body: any): { type?: IncomingEventType; c
conversationId: optionsBody.channel !== undefined ? optionsBody.channel.id : undefined,
};
}
// TODO: remove workflow_step stuff in v5
if (body.actions !== undefined || body.type === 'dialog_submission' || body.type === 'workflow_step_edit') {
const actionBody = body as SlackActionMiddlewareArgs<SlackAction>['body'];
return {
Expand Down
3 changes: 3 additions & 0 deletions src/types/actions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { FunctionInputs } from '../events';
export * from './block-action';
export * from './interactive-message';
export * from './dialog-action';
// TODO: remove workflow step stuff in bolt v5
export * from './workflow-step-edit';

/**
Expand All @@ -25,6 +26,7 @@ export * from './workflow-step-edit';
* offered when no generic parameter is bound would be limited to BasicElementAction rather than the union of known
* actions - ElementAction.
*/
// TODO: remove workflow step stuff in bolt v5
export type SlackAction = BlockAction | InteractiveMessage | DialogSubmitAction | WorkflowStepEdit;

/**
Expand Down Expand Up @@ -54,6 +56,7 @@ export type SlackActionMiddlewareArgs<Action extends SlackAction = SlackAction>
complete?: FunctionCompleteFn;
fail?: FunctionFailFn;
inputs?: FunctionInputs;
// TODO: remove workflow step stuff in bolt v5
} & (Action extends Exclude<SlackAction, DialogSubmitAction | WorkflowStepEdit>
// all action types except dialog submission and steps from apps have a channel context
? { say: SayFn }
Expand Down
2 changes: 2 additions & 0 deletions src/types/actions/workflow-step-edit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
* A Slack step from app action wrapped in the standard metadata.
*
* This describes the entire JSON-encoded body of a request from Slack step from app actions.
* @deprecated Steps from Apps are no longer supported and support for them will be removed in the next major bolt-js
* version.
*/
export interface WorkflowStepEdit {
type: 'workflow_step_edit';
Expand Down
8 changes: 6 additions & 2 deletions src/types/view/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { AckFn, RespondFn } from '../utilities';
export type SlackViewAction =
| ViewSubmitAction
| ViewClosedAction
| ViewWorkflowStepSubmitAction
| ViewWorkflowStepSubmitAction // TODO: remove workflow step stuff in bolt v5
| ViewWorkflowStepClosedAction;
// <ViewAction extends SlackViewAction = ViewSubmitAction>
/**
Expand Down Expand Up @@ -101,8 +101,9 @@ export interface ViewClosedAction {
* A Slack view_submission step from app event
*
* This describes the additional JSON-encoded body details for a step's view_submission event
* @deprecated Steps from Apps are no longer supported and support for them will be removed in the next major bolt-js
* version.
*/

export interface ViewWorkflowStepSubmitAction extends ViewSubmitAction {
trigger_id: string;
response_urls?: ViewResponseUrl[];
Expand All @@ -117,6 +118,8 @@ export interface ViewWorkflowStepSubmitAction extends ViewSubmitAction {
* A Slack view_closed step from app event
*
* This describes the additional JSON-encoded body details for a step's view_closed event
* @deprecated Steps from Apps are no longer supported and support for them will be removed in the next major bolt-js
* version.
*/
export interface ViewWorkflowStepClosedAction extends ViewClosedAction {
workflow_step: {
Expand All @@ -131,6 +134,7 @@ export interface ViewStateSelectedOption {
value: string;
}

// TODO: this should probably exist in @slack/types
export interface UploadedFile {
id: string;
created: number;
Expand Down

0 comments on commit e0988da

Please sign in to comment.