npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@hamedstack/azure-logic-apps

v1.0.0

Published

A library to access all details of a workflow run with executing JSONPath query on the details.

Downloads

1

Readme

HamedStack.AzureLogicApps.TypeScript

A library to access all details of a workflow run with executing JSONPath query on the details.

Usage

You have access to the following APIs.

Login

By using this API you can login and fetch the workflow details.

let alam = new AzureLogicAppsManagement(
  /*AzureAccountInfo*/
  {
    // Your Azure security info
    clientId: "",
    clientSecret: "",
    subscriptionId: "",
    tenantId: "",
  }
);
export interface AzureAccountInfo {
    tenantId: string;
    clientId: string;
    clientSecret: string;
    subscriptionId: string;
    apiVersion?: string;
}

Workflow Detail

By call it you will get all information of most recent workflow run of your workflow.

AzureWorkflowDetail details = await alam.getLastWorkflowDetail(
    /*(azureWorkflowInfo: AzureWorkflowInfo, actionsFilter: "input" | "output" | "both" = "both"): Promise<AzureWorkflowDetail | undefined>*/
    {
        // Available via Azure Portal
        workflowName: '',
        resourceGroup: '',
    });

it returns

export interface AzureWorkflowDetail {
    trigger: AzureTriggerData;
    actions: AzureWorkflowRunActionData[];
    workflowRun: WorkflowRun;
}
export interface AzureTriggerData {
    name: string | undefined;
    input: Json | undefined;
    output: Json | undefined;
    trigger: WorkflowRunTrigger | undefined;
    isSuccessful: boolean;
    status: string | undefined;
}
export interface AzureWorkflowRunActionData {
    order: number,
    name: string;
    input?: Json | undefined;
    output?: Json | undefined;
    action?: WorkflowRunAction;
    status: string | undefined;
    parents?: string[];
    isSuccessful: boolean;
}

Query Execution

// Returns any
const result = await alam.executeQueryOnWorkflowDetail(
  /* (AzureWorkflowDetail, string | undefined, JsonPathQuerySection, string): Promise<any[] | undefined> */

  details, // Workflow details

  // Action name, trigger name or undefind for WorkflowRun
  // Same name of Azure Logic App UI but with underscore instead of whitespace.
  "Initialize_variable_2",

  // Query on Action, ActionInput, ActionOutput, Trigger, TriggerInput, TriggerOutput, WorkflowRun
  // Items of Workflow details object.
  JsonPathQuerySection.ActionInput,

  "$..value" // JSONPath
);

Get First Match

This method find first match workflow among all available workflows based on conditions.

WorkflowRun wf = await alam.findWorkflowRunOnFirstMatch({
    /* (AzureWorkflowInfo, string | undefined, string, conditions: ((v: any) => boolean)[], filter?: string, top?: number): Promise<WorkflowRun | undefined>*/
    workflowName: '...',
    resourceGroup: '...'
  }, "Initialize_variable", // Action Name
    "$..value", // Json path inside your Input Action
    [x => x == ?], // array of conditions to match (if one of them matches you will get result)
    undefined // filter you can pass
    undefined // top option
    );
getWorkflowRunOnFirstMatch(azureWorkflowInfo: AzureWorkflowInfo, workflowRuns: WorkflowRun[], inputActionName: string | undefined, jsonPath: string, conditions: ((v: any) => boolean)[]): Promise<WorkflowRun | undefined>

Same as findWorkflowRunOnFirstMatch but accepts workflowRuns as a parameter to check your in-memory object.

Analysis the workflow run

analysisAzureWorkflowDetail(azureWorkflowDetail: AzureWorkflowDetail): AzureWorkflowDetailResult

To analysis and get report from an AzureWorkflowDetail you should use it.

export interface AzureWorkflowDetailResult {
    isSuccessful: boolean; //overal status
    details: AzureWorkflowDetailItemResult[];
    errors: string[] | undefined; // error messages
}
export interface AzureWorkflowDetailItemResult {
    isSuccessful: boolean;
    type: "WorkflowRun" | "Action" | "Trigger";
    object: AzureTriggerData | AzureWorkflowRunActionData | WorkflowRun
}

Sample

import {
  AzureLogicAppsManagement,
  AzureWorkflowDetail,
  JsonPathQuerySection,
} from "@hamedstack/azure-logic-apps";

let alam: AzureLogicAppManagement;
let details: AzureWorkflowDetails;
describe("Sample", () => {
  beforeAll(async () => {
    alam = new AzureLogicAppsManagement({
      clientId: "...",
      clientSecret: "...",
      subscriptionId: "...",
      tenantId: "...",
    });

    detail = await alam.getLastWorkflowDetail({
      workflowName: "my-wf",
      resourceGroup: "rg-testing",
    });
  });
  it("getting data from Logic App", async () => {

    // Always returns an array
    const result = await alam.executeQueryOnWorkflowDetail(
      detail,
      "Initialize_variable_2" /* or 'Initialize variable 2' */,
      JsonPathQuerySection.ActionInput,
      "$..value"
    );

    const report = alam.analysisAzureWorkflowDetail(detail);
    
    // Checking overal status
    expect(report.isSuccessful).toEqual(true);

    // Checking details
    expect(result[0]).toEqual(3); // value should be 3
  });
});