Edits history of script submission #3482 for ' Validate update workflows (jira)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Jira = {
      username: string;
      password: string;
      domain: string;
    };
    /**
     * Validate update workflows
     * Validate the payload for bulk update workflows.
    
    **[Permissions](#permissions) required:**
    
     *  *Administer Jira* project permission to create all, including global-scoped, workflows
     *  *Administer projects* project permissions to create project-scoped workflows
     */
    export async function main(
      auth: Jira,
      body: {
        payload: {
          statuses: {
            description?: string;
            id?: string;
            name: string;
            statusCategory: "TODO" | "IN_PROGRESS" | "DONE";
            statusReference: string;
            [k: string]: unknown;
          }[];
          workflows: {
            defaultStatusMappings?: {
              newStatusReference: string;
              oldStatusReference: string;
              [k: string]: unknown;
            }[];
            description?: string;
            id: string;
            startPointLayout?: { x?: number; y?: number };
            statusMappings?: {
              issueTypeId: string;
              projectId: string;
              statusMigrations: {
                newStatusReference: string;
                oldStatusReference: string;
                [k: string]: unknown;
              }[];
              [k: string]: unknown;
            }[];
            statuses: {
              layout?: { x?: number; y?: number };
              properties: { [k: string]: string };
              statusReference: string;
              [k: string]: unknown;
            }[];
            transitions: {
              actions?: {
                id?: string;
                parameters?: { [k: string]: string };
                ruleKey: string;
              }[];
              conditions?: {
                conditionGroups?: {}[];
                conditions?: {
                  id?: string;
                  parameters?: { [k: string]: string };
                  ruleKey: string;
                }[];
                operation: "ANY" | "ALL";
              };
              customIssueEventId?: string;
              description?: string;
              from?: { port?: number; statusReference: string }[];
              id: string;
              name: string;
              properties?: { [k: string]: string };
              to?: { port?: number; statusReference: string };
              transitionScreen?: {
                id?: string;
                parameters?: { [k: string]: string };
                ruleKey: string;
              };
              triggers?: {
                id?: string;
                parameters: { [k: string]: string };
                ruleKey: string;
              }[];
              type: "INITIAL" | "GLOBAL" | "DIRECTED";
              validators?: {
                id?: string;
                parameters?: { [k: string]: string };
                ruleKey: string;
              }[];
              [k: string]: unknown;
            }[];
            version: { id: string; versionNumber: number };
            [k: string]: unknown;
          }[];
        };
        validationOptions?: { levels?: ("WARNING" | "ERROR")[] };
      }
    ) {
      const url = new URL(
        `https://${auth.domain}.atlassian.net/rest/api/2/workflows/update/validation`
      );
    
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 396 days ago

  • nativets
    type Jira = {
      username: string;
      password: string;
      domain: string;
    };
    /**
     * Validate update workflows
     * Validate the payload for bulk update workflows.
    
    **[Permissions](#permissions) required:**
    
     *  *Administer Jira* project permission to create all, including global-scoped, workflows
     *  *Administer projects* project permissions to create project-scoped workflows
     */
    export async function main(
      auth: Jira,
      body: {
        payload: {
          statuses: {
            description?: string;
            id?: string;
            name: string;
            statusCategory: "TODO" | "IN_PROGRESS" | "DONE";
            statusReference: string;
            [k: string]: unknown;
          }[];
          workflows: {
            defaultStatusMappings?: {
              newStatusReference: string;
              oldStatusReference: string;
              [k: string]: unknown;
            }[];
            description?: string;
            id: string;
            startPointLayout?: { x?: number; y?: number };
            statusMappings?: {
              issueTypeId: string;
              projectId: string;
              statusMigrations: {
                newStatusReference: string;
                oldStatusReference: string;
                [k: string]: unknown;
              }[];
              [k: string]: unknown;
            }[];
            statuses: {
              layout?: { x?: number; y?: number };
              properties: { [k: string]: string };
              statusReference: string;
              [k: string]: unknown;
            }[];
            transitions: {
              actions?: {
                id?: string;
                parameters?: { [k: string]: string };
                ruleKey: string;
              }[];
              conditions?: {
                conditionGroups?: {}[];
                conditions?: {
                  id?: string;
                  parameters?: { [k: string]: string };
                  ruleKey: string;
                }[];
                operation: "ANY" | "ALL";
              };
              customIssueEventId?: string;
              description?: string;
              from?: { port?: number; statusReference: string }[];
              id: string;
              name: string;
              properties?: { [k: string]: string };
              to?: { port?: number; statusReference: string };
              transitionScreen?: {
                id?: string;
                parameters?: { [k: string]: string };
                ruleKey: string;
              };
              triggers?: {
                id?: string;
                parameters: { [k: string]: string };
                ruleKey: string;
              }[];
              type: "INITIAL" | "GLOBAL" | "DIRECTED";
              validators?: {
                id?: string;
                parameters?: { [k: string]: string };
                ruleKey: string;
              }[];
              [k: string]: unknown;
            }[];
            version: { id: string; versionNumber: number };
            [k: string]: unknown;
          }[];
        };
        validationOptions?: { levels?: ("WARNING" | "ERROR")[] };
      }
    ) {
      const url = new URL(
        `https://${auth.domain}.atlassian.net/rest/api/2/workflows/update/validation`
      );
    
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 823 days ago

  • nativets
    type Jira = {
      username: string;
      password: string;
      domain: string;
    };
    /**
     * Validate update workflows
     * Validate the payload for bulk update workflows.
    
    **[Permissions](#permissions) required:**
    
     *  *Administer Jira* project permission to create all, including global-scoped, workflows
     *  *Administer projects* project permissions to create project-scoped workflows
     */
    export async function main(
      auth: Jira,
      body: {
        payload: {
          statuses: {
            description?: string;
            id?: string;
            name: string;
            statusCategory: "TODO" | "IN_PROGRESS" | "DONE";
            statusReference: string;
            [k: string]: unknown;
          }[];
          workflows: {
            defaultStatusMappings?: {
              newStatusReference: string;
              oldStatusReference: string;
              [k: string]: unknown;
            }[];
            description?: string;
            id: string;
            startPointLayout?: { x?: number; y?: number };
            statusMappings?: {
              issueTypeId: string;
              projectId: string;
              statusMigrations: {
                newStatusReference: string;
                oldStatusReference: string;
                [k: string]: unknown;
              }[];
              [k: string]: unknown;
            }[];
            statuses: {
              layout?: { x?: number; y?: number };
              properties: { [k: string]: string };
              statusReference: string;
              [k: string]: unknown;
            }[];
            transitions: {
              actions?: {
                id?: string;
                parameters?: { [k: string]: string };
                ruleKey: string;
              }[];
              conditions?: {
                conditionGroups?: {}[];
                conditions?: {
                  id?: string;
                  parameters?: { [k: string]: string };
                  ruleKey: string;
                }[];
                operation: "ANY" | "ALL";
              };
              customIssueEventId?: string;
              description?: string;
              from?: { port?: number; statusReference: string }[];
              id: string;
              name: string;
              properties?: { [k: string]: string };
              to?: { port?: number; statusReference: string };
              transitionScreen?: {
                id?: string;
                parameters?: { [k: string]: string };
                ruleKey: string;
              };
              triggers?: {
                id?: string;
                parameters: { [k: string]: string };
                ruleKey: string;
              }[];
              type: "INITIAL" | "GLOBAL" | "DIRECTED";
              validators?: {
                id?: string;
                parameters?: { [k: string]: string };
                ruleKey: string;
              }[];
              [k: string]: unknown;
            }[];
            version: { id?: string; versionNumber?: number };
            [k: string]: unknown;
          }[];
        };
        validationOptions?: {
          levels?:
            | []
            | ["WARNING" | "ERROR"]
            | ["WARNING" | "ERROR", "WARNING" | "ERROR"];
        };
      }
    ) {
      const url = new URL(
        `https://${auth.domain}.atlassian.net/rest/api/2/workflows/update/validation`
      );
    
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Basic " + btoa(`${auth.username}:${auth.password}`),
        },
        body: JSON.stringify(body),
      });
      if (!response.ok) {
        const text = await response.text();
        throw new Error(`${response.status} ${text}`);
      }
      return await response.json();
    }
    

    Submitted by hugo697 948 days ago