constructs#IConstruct TypeScript Examples

The following examples show how to use constructs#IConstruct. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: manifest.ts    From cloudstructs with Apache License 2.0 5 votes vote down vote up
public render(construct: IConstruct): string {
    const schema: SlackAppManifestSchema = {
      _metadata: {
        major_version: this.props.majorVersion,
        minor_version: this.props.minorVersion,
      },
      display_information: {
        name: this.props.name,
        description: this.props.description,
        long_description: this.props.longDescription,
        background_color: prefixWith('#', this.props.backgroundColor)?.toLowerCase(),
      },
      settings: {
        allowed_ip_address_ranges: this.props.allowedIpAddressRanges,
        event_subscriptions: {
          request_url: this.props.eventSubscriptions?.requestUrl,
          bot_events: this.props.eventSubscriptions?.botEvents,
          user_events: this.props.eventSubscriptions?.userEvents,
        },
        interactivity: this.props.interactivity
          ? {
            is_enabled: this.props.interactivity?.enabled ?? true,
            request_url: this.props.interactivity?.requestUrl,
            message_menu_options_url: this.props.interactivity?.messageMenuOptionsUrl,
          }
          : undefined,
        org_deploy_enabled: this.props.orgDeploy,
        socket_mode_enabled: this.props.socketMode,
      },
      features: {
        app_home: {
          home_tab_enabled: this.props.appHome?.homeTab,
          messages_tab_enabled: this.props.appHome?.messagesTab,
          messages_tab_read_only_enabled: this.props.appHome?.messagesTabReadOnly,
        },
        bot_user: this.props.botUser
          ? {
            display_name: this.props.botUser?.displayName,
            always_online: this.props.botUser?.alwaysOnline,
          }
          : undefined,
        shortcuts: this.props.shortcuts?.map((shortcut) => ({
          name: shortcut.name,
          type: shortcut.type,
          callback_id: shortcut.callbackId,
          description: shortcut.description,
        })),
        slash_commands: this.props.slashCommands?.map((command) => ({
          command: prefixWith('/', command.command),
          description: command.description,
          url: command.url,
          usage_hint: command.usageHint,
          should_escape: command.shouldEscape,
        })),
        workflow_steps: this.props.workflowSteps?.map((step) => ({
          name: step.name,
          callback_id: step.callbackId,
        })),
        unfurl_domains: this.props.unfurlDomains,
      },
      oauth_config: {
        redirect_urls: this.props.oauthConfig?.redirectUrls,
        scopes: {
          bot: this.props.oauthConfig?.botScopes,
          users: this.props.oauthConfig?.userScopes,
        },
      },
    };

    return Stack.of(construct).toJsonString(removeUndefined(schema));
  }
Example #2
Source File: slack-app.ts    From cloudstructs with Apache License 2.0 5 votes vote down vote up
/**
   * Renders the JSON app manifest encoded as a string
   */
  public abstract render(construct: IConstruct): string;
Example #3
Source File: slack-app.ts    From cloudstructs with Apache License 2.0 5 votes vote down vote up
public render(_construct: IConstruct): string {
    return this.manifest;
  }
Example #4
Source File: slack-app.ts    From cloudstructs with Apache License 2.0 5 votes vote down vote up
public render(_construct: IConstruct): string {
    return fs.readFileSync(this.file, 'utf8');
  }