// src/automations-v2-automation-automations-v-2.universal.ts
import { transformError as sdkTransformError } from "@wix/sdk-runtime/transform-error";
import { queryBuilder } from "@wix/sdk-runtime/query-builder";
import {
  renameKeysFromSDKRequestToRESTRequest,
  renameKeysFromRESTResponseToSDKResponse
} from "@wix/sdk-runtime/rename-all-nested-keys";

// src/automations-v2-automation-automations-v-2.http.ts
import { toURLSearchParams } from "@wix/sdk-runtime/rest-modules";
import { transformSDKTimestampToRESTTimestamp } from "@wix/sdk-runtime/transformations/timestamp";
import { transformRESTTimestampToSDKTimestamp } from "@wix/sdk-runtime/transformations/timestamp";
import { transformSDKFieldMaskToRESTFieldMask } from "@wix/sdk-runtime/transformations/field-mask";
import { transformPaths } from "@wix/sdk-runtime/transformations/transform-paths";
import { resolveUrl } from "@wix/sdk-runtime/rest-modules";
function resolveWixAutomationsV2AutomationsServiceUrl(opts) {
  const domainToMappings = {
    "manage._base_domain_": [
      {
        srcPath: "/automations-service",
        destPath: ""
      },
      {
        srcPath: "/_api/automations-service",
        destPath: "/api"
      }
    ],
    "platform.rise.ai": [
      {
        srcPath: "/v2/automations",
        destPath: ""
      }
    ],
    "www.wixapis.com": [
      {
        srcPath: "/automations-service",
        destPath: ""
      }
    ],
    "*.dev.wix-code.com": [
      {
        srcPath: "/automations-service",
        destPath: ""
      }
    ],
    _: [
      {
        srcPath: "/automations-service",
        destPath: ""
      }
    ],
    "payments.base44.com": [
      {
        srcPath: "/_api/automations-service",
        destPath: "/api"
      },
      {
        srcPath: "/automations-service",
        destPath: ""
      }
    ]
  };
  return resolveUrl(Object.assign(opts, { domainToMappings }));
}
function resolveWixAutomationsV2AutomationRevisionsServiceUrl(opts) {
  const domainToMappings = {
    "manage._base_domain_": [
      {
        srcPath: "/automations-service",
        destPath: ""
      },
      {
        srcPath: "/_api/automations-service",
        destPath: "/api"
      }
    ],
    "platform.rise.ai": [
      {
        srcPath: "/v2/automations",
        destPath: ""
      }
    ],
    "www.wixapis.com": [
      {
        srcPath: "/automations-service",
        destPath: ""
      }
    ],
    "*.dev.wix-code.com": [
      {
        srcPath: "/automations-service",
        destPath: ""
      }
    ],
    _: [
      {
        srcPath: "/automations-service",
        destPath: ""
      }
    ],
    "payments.base44.com": [
      {
        srcPath: "/_api/automations-service",
        destPath: "/api"
      },
      {
        srcPath: "/automations-service",
        destPath: ""
      }
    ]
  };
  return resolveUrl(Object.assign(opts, { domainToMappings }));
}
var PACKAGE_NAME = "@wix/auto_sdk_automations_automations-v-2";
function getAutomationRevision(payload) {
  function __getAutomationRevision({ host }) {
    const metadata = {
      entityFqdn: "wix.automations.v2.automation",
      method: "GET",
      methodFqn: "wix.automations.v2.AutomationRevisionsService.GetAutomationRevision",
      packageName: PACKAGE_NAME,
      migrationOptions: {
        optInTransformResponse: true
      },
      url: resolveWixAutomationsV2AutomationRevisionsServiceUrl({
        protoPath: "/v1/automation-revisions/{automationId}",
        data: payload,
        host
      }),
      params: toURLSearchParams(payload),
      transformResponse: (payload2) => transformPaths(payload2, [
        {
          transformFn: transformRESTTimestampToSDKTimestamp,
          paths: [
            { path: "automation.createdDate" },
            { path: "automation.updatedDate" },
            { path: "automation.draftUpdatedDate" },
            { path: "automation.autoArchivePolicy.archiveDate" }
          ]
        }
      ])
    };
    return metadata;
  }
  return __getAutomationRevision;
}
function createAutomation(payload) {
  function __createAutomation({ host }) {
    const serializedData = transformPaths(payload, [
      {
        transformFn: transformSDKTimestampToRESTTimestamp,
        paths: [
          { path: "automation.createdDate" },
          { path: "automation.updatedDate" },
          { path: "automation.draftUpdatedDate" },
          { path: "automation.autoArchivePolicy.archiveDate" }
        ]
      }
    ]);
    const metadata = {
      entityFqdn: "wix.automations.v2.automation",
      method: "POST",
      methodFqn: "wix.automations.v2.AutomationsService.CreateAutomation",
      packageName: PACKAGE_NAME,
      migrationOptions: {
        optInTransformResponse: true
      },
      url: resolveWixAutomationsV2AutomationsServiceUrl({
        protoPath: "/v2/automations",
        data: serializedData,
        host
      }),
      data: serializedData,
      transformResponse: (payload2) => transformPaths(payload2, [
        {
          transformFn: transformRESTTimestampToSDKTimestamp,
          paths: [
            { path: "automation.createdDate" },
            { path: "automation.updatedDate" },
            { path: "automation.draftUpdatedDate" },
            { path: "automation.autoArchivePolicy.archiveDate" }
          ]
        }
      ])
    };
    return metadata;
  }
  return __createAutomation;
}
function createAutomationFromTemplateId(payload) {
  function __createAutomationFromTemplateId({ host }) {
    const metadata = {
      entityFqdn: "wix.automations.v2.automation",
      method: "POST",
      methodFqn: "wix.automations.v2.AutomationsService.CreateAutomationFromTemplateId",
      packageName: PACKAGE_NAME,
      migrationOptions: {
        optInTransformResponse: true
      },
      url: resolveWixAutomationsV2AutomationsServiceUrl({
        protoPath: "/v2/automations/from-template/{automationTemplateId}",
        data: payload,
        host
      }),
      data: payload,
      transformResponse: (payload2) => transformPaths(payload2, [
        {
          transformFn: transformRESTTimestampToSDKTimestamp,
          paths: [
            { path: "automation.createdDate" },
            { path: "automation.updatedDate" },
            { path: "automation.draftUpdatedDate" },
            { path: "automation.autoArchivePolicy.archiveDate" }
          ]
        }
      ])
    };
    return metadata;
  }
  return __createAutomationFromTemplateId;
}
function getAutomation(payload) {
  function __getAutomation({ host }) {
    const metadata = {
      entityFqdn: "wix.automations.v2.automation",
      method: "GET",
      methodFqn: "wix.automations.v2.AutomationsService.GetAutomation",
      packageName: PACKAGE_NAME,
      migrationOptions: {
        optInTransformResponse: true
      },
      url: resolveWixAutomationsV2AutomationsServiceUrl({
        protoPath: "/v2/automations/{automationId}",
        data: payload,
        host
      }),
      params: toURLSearchParams(payload),
      transformResponse: (payload2) => transformPaths(payload2, [
        {
          transformFn: transformRESTTimestampToSDKTimestamp,
          paths: [
            { path: "automation.createdDate" },
            { path: "automation.updatedDate" },
            { path: "automation.draftUpdatedDate" },
            { path: "automation.autoArchivePolicy.archiveDate" }
          ]
        }
      ])
    };
    return metadata;
  }
  return __getAutomation;
}
function updateAutomation(payload) {
  function __updateAutomation({ host }) {
    const serializedData = transformPaths(payload, [
      {
        transformFn: transformSDKFieldMaskToRESTFieldMask,
        paths: [{ path: "fieldMask" }]
      },
      {
        transformFn: transformSDKTimestampToRESTTimestamp,
        paths: [
          { path: "automation.createdDate" },
          { path: "automation.updatedDate" },
          { path: "automation.draftUpdatedDate" },
          { path: "automation.autoArchivePolicy.archiveDate" }
        ]
      }
    ]);
    const metadata = {
      entityFqdn: "wix.automations.v2.automation",
      method: "PATCH",
      methodFqn: "wix.automations.v2.AutomationsService.UpdateAutomation",
      packageName: PACKAGE_NAME,
      migrationOptions: {
        optInTransformResponse: true
      },
      url: resolveWixAutomationsV2AutomationsServiceUrl({
        protoPath: "/v2/automations/{automation.id}",
        data: serializedData,
        host
      }),
      data: serializedData,
      transformResponse: (payload2) => transformPaths(payload2, [
        {
          transformFn: transformRESTTimestampToSDKTimestamp,
          paths: [
            { path: "automation.createdDate" },
            { path: "automation.updatedDate" },
            { path: "automation.draftUpdatedDate" },
            { path: "automation.autoArchivePolicy.archiveDate" }
          ]
        }
      ])
    };
    return metadata;
  }
  return __updateAutomation;
}
function deleteAutomation(payload) {
  function __deleteAutomation({ host }) {
    const metadata = {
      entityFqdn: "wix.automations.v2.automation",
      method: "DELETE",
      methodFqn: "wix.automations.v2.AutomationsService.DeleteAutomation",
      packageName: PACKAGE_NAME,
      migrationOptions: {
        optInTransformResponse: true
      },
      url: resolveWixAutomationsV2AutomationsServiceUrl({
        protoPath: "/v2/automations/{automationId}",
        data: payload,
        host
      }),
      params: toURLSearchParams(payload)
    };
    return metadata;
  }
  return __deleteAutomation;
}
function bulkDeleteAutomations(payload) {
  function __bulkDeleteAutomations({ host }) {
    const metadata = {
      entityFqdn: "wix.automations.v2.automation",
      method: "POST",
      methodFqn: "wix.automations.v2.AutomationsService.BulkDeleteAutomations",
      packageName: PACKAGE_NAME,
      migrationOptions: {
        optInTransformResponse: true
      },
      url: resolveWixAutomationsV2AutomationsServiceUrl({
        protoPath: "/v2/bulk/automations/delete",
        data: payload,
        host
      }),
      data: payload
    };
    return metadata;
  }
  return __bulkDeleteAutomations;
}
function createPreinstalledAutomation(payload) {
  function __createPreinstalledAutomation({ host }) {
    const serializedData = transformPaths(payload, [
      {
        transformFn: transformSDKTimestampToRESTTimestamp,
        paths: [
          { path: "automation.createdDate" },
          { path: "automation.updatedDate" },
          { path: "automation.draftUpdatedDate" },
          { path: "automation.autoArchivePolicy.archiveDate" }
        ]
      }
    ]);
    const metadata = {
      entityFqdn: "wix.automations.v2.automation",
      method: "POST",
      methodFqn: "wix.automations.v2.AutomationsService.CreatePreinstalledAutomation",
      packageName: PACKAGE_NAME,
      migrationOptions: {
        optInTransformResponse: true
      },
      url: resolveWixAutomationsV2AutomationsServiceUrl({
        protoPath: "/v2/preinstalled-automation",
        data: serializedData,
        host
      }),
      data: serializedData,
      transformResponse: (payload2) => transformPaths(payload2, [
        {
          transformFn: transformRESTTimestampToSDKTimestamp,
          paths: [
            { path: "automation.createdDate" },
            { path: "automation.updatedDate" },
            { path: "automation.draftUpdatedDate" },
            { path: "automation.autoArchivePolicy.archiveDate" }
          ]
        }
      ])
    };
    return metadata;
  }
  return __createPreinstalledAutomation;
}
function updatePreinstalledAutomation(payload) {
  function __updatePreinstalledAutomation({ host }) {
    const serializedData = transformPaths(payload, [
      {
        transformFn: transformSDKTimestampToRESTTimestamp,
        paths: [
          { path: "automation.createdDate" },
          { path: "automation.updatedDate" },
          { path: "automation.draftUpdatedDate" },
          { path: "automation.autoArchivePolicy.archiveDate" }
        ]
      }
    ]);
    const metadata = {
      entityFqdn: "wix.automations.v2.automation",
      method: "PATCH",
      methodFqn: "wix.automations.v2.AutomationsService.UpdatePreinstalledAutomation",
      packageName: PACKAGE_NAME,
      migrationOptions: {
        optInTransformResponse: true
      },
      url: resolveWixAutomationsV2AutomationsServiceUrl({
        protoPath: "/v2/preinstalled-automation",
        data: serializedData,
        host
      }),
      data: serializedData,
      transformResponse: (payload2) => transformPaths(payload2, [
        {
          transformFn: transformRESTTimestampToSDKTimestamp,
          paths: [
            { path: "automation.createdDate" },
            { path: "automation.updatedDate" },
            { path: "automation.draftUpdatedDate" },
            { path: "automation.autoArchivePolicy.archiveDate" }
          ]
        }
      ])
    };
    return metadata;
  }
  return __updatePreinstalledAutomation;
}
function deletePreinstalledAutomation(payload) {
  function __deletePreinstalledAutomation({ host }) {
    const metadata = {
      entityFqdn: "wix.automations.v2.automation",
      method: "DELETE",
      methodFqn: "wix.automations.v2.AutomationsService.DeletePreinstalledAutomation",
      packageName: PACKAGE_NAME,
      migrationOptions: {
        optInTransformResponse: true
      },
      url: resolveWixAutomationsV2AutomationsServiceUrl({
        protoPath: "/v2/preinstalled-automation/{componentId}",
        data: payload,
        host
      }),
      params: toURLSearchParams(payload)
    };
    return metadata;
  }
  return __deletePreinstalledAutomation;
}
function generatePreinstalledAutomation(payload) {
  function __generatePreinstalledAutomation({ host }) {
    const serializedData = transformPaths(payload, [
      {
        transformFn: transformSDKTimestampToRESTTimestamp,
        paths: [
          { path: "automation.createdDate" },
          { path: "automation.updatedDate" },
          { path: "automation.draftUpdatedDate" },
          { path: "automation.autoArchivePolicy.archiveDate" }
        ]
      }
    ]);
    const metadata = {
      entityFqdn: "wix.automations.v2.automation",
      method: "POST",
      methodFqn: "wix.automations.v2.AutomationsService.GeneratePreinstalledAutomation",
      packageName: PACKAGE_NAME,
      migrationOptions: {
        optInTransformResponse: true
      },
      url: resolveWixAutomationsV2AutomationsServiceUrl({
        protoPath: "/v2/preinstalled-automation/generate",
        data: serializedData,
        host
      }),
      data: serializedData,
      transformResponse: (payload2) => transformPaths(payload2, [
        {
          transformFn: transformRESTTimestampToSDKTimestamp,
          paths: [
            { path: "automation.createdDate" },
            { path: "automation.updatedDate" },
            { path: "automation.draftUpdatedDate" },
            { path: "automation.autoArchivePolicy.archiveDate" }
          ]
        }
      ])
    };
    return metadata;
  }
  return __generatePreinstalledAutomation;
}
function queryPreinstalledAutomationsForApp(payload) {
  function __queryPreinstalledAutomationsForApp({ host }) {
    const metadata = {
      entityFqdn: "wix.automations.v2.automation",
      method: "POST",
      methodFqn: "wix.automations.v2.AutomationsService.QueryPreinstalledAutomationsForApp",
      packageName: PACKAGE_NAME,
      migrationOptions: {
        optInTransformResponse: true
      },
      url: resolveWixAutomationsV2AutomationsServiceUrl({
        protoPath: "/v2/preinstalled-automations/query",
        data: payload,
        host
      }),
      data: payload,
      transformResponse: (payload2) => transformPaths(payload2, [
        {
          transformFn: transformRESTTimestampToSDKTimestamp,
          paths: [
            { path: "automations.createdDate" },
            { path: "automations.updatedDate" },
            { path: "automations.draftUpdatedDate" },
            { path: "automations.autoArchivePolicy.archiveDate" }
          ]
        }
      ])
    };
    return metadata;
  }
  return __queryPreinstalledAutomationsForApp;
}
function queryPreinstalledAutomations(payload) {
  function __queryPreinstalledAutomations({ host }) {
    const metadata = {
      entityFqdn: "wix.automations.v2.automation",
      method: "POST",
      methodFqn: "wix.automations.v2.AutomationsService.QueryPreinstalledAutomations",
      packageName: PACKAGE_NAME,
      migrationOptions: {
        optInTransformResponse: true
      },
      url: resolveWixAutomationsV2AutomationsServiceUrl({
        protoPath: "/v2/preinstalled-automations/global/query",
        data: payload,
        host
      }),
      data: payload,
      transformResponse: (payload2) => transformPaths(payload2, [
        {
          transformFn: transformRESTTimestampToSDKTimestamp,
          paths: [
            { path: "automations.createdDate" },
            { path: "automations.updatedDate" },
            { path: "automations.draftUpdatedDate" },
            { path: "automations.autoArchivePolicy.archiveDate" }
          ]
        }
      ])
    };
    return metadata;
  }
  return __queryPreinstalledAutomations;
}
function queryAutomations(payload) {
  function __queryAutomations({ host }) {
    const metadata = {
      entityFqdn: "wix.automations.v2.automation",
      method: "POST",
      methodFqn: "wix.automations.v2.AutomationsService.QueryAutomations",
      packageName: PACKAGE_NAME,
      migrationOptions: {
        optInTransformResponse: true
      },
      url: resolveWixAutomationsV2AutomationsServiceUrl({
        protoPath: "/v2/automations/query",
        data: payload,
        host
      }),
      data: payload,
      transformResponse: (payload2) => transformPaths(payload2, [
        {
          transformFn: transformRESTTimestampToSDKTimestamp,
          paths: [
            { path: "automations.createdDate" },
            { path: "automations.updatedDate" },
            { path: "automations.draftUpdatedDate" },
            { path: "automations.autoArchivePolicy.archiveDate" }
          ]
        }
      ])
    };
    return metadata;
  }
  return __queryAutomations;
}
function getAggregatedUsageInfo(payload) {
  function __getAggregatedUsageInfo({ host }) {
    const metadata = {
      entityFqdn: "wix.automations.v2.automation",
      method: "GET",
      methodFqn: "wix.automations.v2.AutomationsService.GetAggregatedUsageInfo",
      packageName: PACKAGE_NAME,
      migrationOptions: {
        optInTransformResponse: true
      },
      url: resolveWixAutomationsV2AutomationsServiceUrl({
        protoPath: "/v2/automations/usage",
        data: payload,
        host
      }),
      params: toURLSearchParams(payload, true)
    };
    return metadata;
  }
  return __getAggregatedUsageInfo;
}
function copyAutomation(payload) {
  function __copyAutomation({ host }) {
    const serializedData = transformPaths(payload, [
      {
        transformFn: transformSDKTimestampToRESTTimestamp,
        paths: [
          { path: "automation.createdDate" },
          { path: "automation.updatedDate" },
          { path: "automation.draftUpdatedDate" },
          { path: "automation.autoArchivePolicy.archiveDate" }
        ]
      }
    ]);
    const metadata = {
      entityFqdn: "wix.automations.v2.automation",
      method: "POST",
      methodFqn: "wix.automations.v2.AutomationsService.CopyAutomation",
      packageName: PACKAGE_NAME,
      migrationOptions: {
        optInTransformResponse: true
      },
      url: resolveWixAutomationsV2AutomationsServiceUrl({
        protoPath: "/v2/automations/{automationId}/copy",
        data: serializedData,
        host
      }),
      data: serializedData,
      transformResponse: (payload2) => transformPaths(payload2, [
        {
          transformFn: transformRESTTimestampToSDKTimestamp,
          paths: [
            { path: "automation.createdDate" },
            { path: "automation.updatedDate" },
            { path: "automation.draftUpdatedDate" },
            { path: "automation.autoArchivePolicy.archiveDate" }
          ]
        }
      ])
    };
    return metadata;
  }
  return __copyAutomation;
}
function createDraftAutomation(payload) {
  function __createDraftAutomation({ host }) {
    const serializedData = transformPaths(payload, [
      {
        transformFn: transformSDKTimestampToRESTTimestamp,
        paths: [
          { path: "automation.createdDate" },
          { path: "automation.updatedDate" },
          { path: "automation.draftUpdatedDate" },
          { path: "automation.autoArchivePolicy.archiveDate" }
        ]
      }
    ]);
    const metadata = {
      entityFqdn: "wix.automations.v2.automation",
      method: "POST",
      methodFqn: "wix.automations.v2.AutomationsService.CreateDraftAutomation",
      packageName: PACKAGE_NAME,
      migrationOptions: {
        optInTransformResponse: true
      },
      url: resolveWixAutomationsV2AutomationsServiceUrl({
        protoPath: "/v2/automations/drafts",
        data: serializedData,
        host
      }),
      data: serializedData,
      transformResponse: (payload2) => transformPaths(payload2, [
        {
          transformFn: transformRESTTimestampToSDKTimestamp,
          paths: [
            { path: "automation.createdDate" },
            { path: "automation.updatedDate" },
            { path: "automation.draftUpdatedDate" },
            { path: "automation.autoArchivePolicy.archiveDate" }
          ]
        }
      ])
    };
    return metadata;
  }
  return __createDraftAutomation;
}
function createDraftAutomationFromTemplateId(payload) {
  function __createDraftAutomationFromTemplateId({ host }) {
    const metadata = {
      entityFqdn: "wix.automations.v2.automation",
      method: "POST",
      methodFqn: "wix.automations.v2.AutomationsService.CreateDraftAutomationFromTemplateId",
      packageName: PACKAGE_NAME,
      migrationOptions: {
        optInTransformResponse: true
      },
      url: resolveWixAutomationsV2AutomationsServiceUrl({
        protoPath: "/v2/automations/drafts/from-template/{automationTemplateId}",
        data: payload,
        host
      }),
      data: payload,
      transformResponse: (payload2) => transformPaths(payload2, [
        {
          transformFn: transformRESTTimestampToSDKTimestamp,
          paths: [
            { path: "automation.createdDate" },
            { path: "automation.updatedDate" },
            { path: "automation.draftUpdatedDate" },
            { path: "automation.autoArchivePolicy.archiveDate" }
          ]
        }
      ])
    };
    return metadata;
  }
  return __createDraftAutomationFromTemplateId;
}
function getOrCreateDraftAutomation(payload) {
  function __getOrCreateDraftAutomation({ host }) {
    const metadata = {
      entityFqdn: "wix.automations.v2.automation",
      method: "POST",
      methodFqn: "wix.automations.v2.AutomationsService.GetOrCreateDraftAutomation",
      packageName: PACKAGE_NAME,
      migrationOptions: {
        optInTransformResponse: true
      },
      url: resolveWixAutomationsV2AutomationsServiceUrl({
        protoPath: "/v2/automations/drafts/get-or-create/original-automation-id/{originalAutomationId}",
        data: payload,
        host
      }),
      data: payload,
      transformResponse: (payload2) => transformPaths(payload2, [
        {
          transformFn: transformRESTTimestampToSDKTimestamp,
          paths: [
            { path: "automation.createdDate" },
            { path: "automation.updatedDate" },
            { path: "automation.draftUpdatedDate" },
            { path: "automation.autoArchivePolicy.archiveDate" }
          ]
        }
      ])
    };
    return metadata;
  }
  return __getOrCreateDraftAutomation;
}
function updateDraftAutomation(payload) {
  function __updateDraftAutomation({ host }) {
    const serializedData = transformPaths(payload, [
      {
        transformFn: transformSDKFieldMaskToRESTFieldMask,
        paths: [{ path: "fieldMask" }]
      },
      {
        transformFn: transformSDKTimestampToRESTTimestamp,
        paths: [
          { path: "automation.createdDate" },
          { path: "automation.updatedDate" },
          { path: "automation.draftUpdatedDate" },
          { path: "automation.autoArchivePolicy.archiveDate" }
        ]
      }
    ]);
    const metadata = {
      entityFqdn: "wix.automations.v2.automation",
      method: "PATCH",
      methodFqn: "wix.automations.v2.AutomationsService.UpdateDraftAutomation",
      packageName: PACKAGE_NAME,
      migrationOptions: {
        optInTransformResponse: true
      },
      url: resolveWixAutomationsV2AutomationsServiceUrl({
        protoPath: "/v2/automations/drafts/{automation.id}",
        data: serializedData,
        host
      }),
      data: serializedData,
      transformResponse: (payload2) => transformPaths(payload2, [
        {
          transformFn: transformRESTTimestampToSDKTimestamp,
          paths: [
            { path: "automation.createdDate" },
            { path: "automation.updatedDate" },
            { path: "automation.draftUpdatedDate" },
            { path: "automation.autoArchivePolicy.archiveDate" }
          ]
        }
      ])
    };
    return metadata;
  }
  return __updateDraftAutomation;
}
function queryAutomationsWithDrafts(payload) {
  function __queryAutomationsWithDrafts({ host }) {
    const metadata = {
      entityFqdn: "wix.automations.v2.automation",
      method: "POST",
      methodFqn: "wix.automations.v2.AutomationsService.QueryAutomationsWithDrafts",
      packageName: PACKAGE_NAME,
      migrationOptions: {
        optInTransformResponse: true
      },
      url: resolveWixAutomationsV2AutomationsServiceUrl({
        protoPath: "/v2/automations/query-with-drafts",
        data: payload,
        host
      }),
      data: payload,
      transformResponse: (payload2) => transformPaths(payload2, [
        {
          transformFn: transformRESTTimestampToSDKTimestamp,
          paths: [
            { path: "automations.createdDate" },
            { path: "automations.updatedDate" },
            { path: "automations.draftUpdatedDate" },
            { path: "automations.autoArchivePolicy.archiveDate" }
          ]
        }
      ])
    };
    return metadata;
  }
  return __queryAutomationsWithDrafts;
}
function bulkCountAutomationsWithDrafts(payload) {
  function __bulkCountAutomationsWithDrafts({ host }) {
    const metadata = {
      entityFqdn: "wix.automations.v2.automation",
      method: "POST",
      methodFqn: "wix.automations.v2.AutomationsService.BulkCountAutomationsWithDrafts",
      packageName: PACKAGE_NAME,
      migrationOptions: {
        optInTransformResponse: true
      },
      url: resolveWixAutomationsV2AutomationsServiceUrl({
        protoPath: "/v2/automations/bulk-count-with-drafts",
        data: payload,
        host
      }),
      data: payload
    };
    return metadata;
  }
  return __bulkCountAutomationsWithDrafts;
}
function deleteDraftAutomation(payload) {
  function __deleteDraftAutomation({ host }) {
    const metadata = {
      entityFqdn: "wix.automations.v2.automation",
      method: "DELETE",
      methodFqn: "wix.automations.v2.AutomationsService.DeleteDraftAutomation",
      packageName: PACKAGE_NAME,
      migrationOptions: {
        optInTransformResponse: true
      },
      url: resolveWixAutomationsV2AutomationsServiceUrl({
        protoPath: "/v2/automations/drafts/{automationId}",
        data: payload,
        host
      }),
      params: toURLSearchParams(payload)
    };
    return metadata;
  }
  return __deleteDraftAutomation;
}
function publishDraftAutomation(payload) {
  function __publishDraftAutomation({ host }) {
    const metadata = {
      entityFqdn: "wix.automations.v2.automation",
      method: "POST",
      methodFqn: "wix.automations.v2.AutomationsService.PublishDraftAutomation",
      packageName: PACKAGE_NAME,
      migrationOptions: {
        optInTransformResponse: true
      },
      url: resolveWixAutomationsV2AutomationsServiceUrl({
        protoPath: "/v2/automations/drafts/{automationId}/publish",
        data: payload,
        host
      }),
      data: payload,
      transformResponse: (payload2) => transformPaths(payload2, [
        {
          transformFn: transformRESTTimestampToSDKTimestamp,
          paths: [
            { path: "automation.createdDate" },
            { path: "automation.updatedDate" },
            { path: "automation.draftUpdatedDate" },
            { path: "automation.autoArchivePolicy.archiveDate" }
          ]
        }
      ])
    };
    return metadata;
  }
  return __publishDraftAutomation;
}
function validateAutomation(payload) {
  function __validateAutomation({ host }) {
    const serializedData = transformPaths(payload, [
      {
        transformFn: transformSDKTimestampToRESTTimestamp,
        paths: [
          { path: "automation.createdDate" },
          { path: "automation.updatedDate" },
          { path: "automation.draftUpdatedDate" },
          { path: "automation.autoArchivePolicy.archiveDate" }
        ]
      }
    ]);
    const metadata = {
      entityFqdn: "wix.automations.v2.automation",
      method: "POST",
      methodFqn: "wix.automations.v2.AutomationsService.ValidateAutomation",
      packageName: PACKAGE_NAME,
      migrationOptions: {
        optInTransformResponse: true
      },
      url: resolveWixAutomationsV2AutomationsServiceUrl({
        protoPath: "/v2/automations/validate",
        data: serializedData,
        host
      }),
      data: serializedData
    };
    return metadata;
  }
  return __validateAutomation;
}
function validateAutomationById(payload) {
  function __validateAutomationById({ host }) {
    const metadata = {
      entityFqdn: "wix.automations.v2.automation",
      method: "POST",
      methodFqn: "wix.automations.v2.AutomationsService.ValidateAutomationById",
      packageName: PACKAGE_NAME,
      migrationOptions: {
        optInTransformResponse: true
      },
      url: resolveWixAutomationsV2AutomationsServiceUrl({
        protoPath: "/v2/automations/{automationId}/validate",
        data: payload,
        host
      }),
      data: payload
    };
    return metadata;
  }
  return __validateAutomationById;
}
function getActionsQuotaInfo(payload) {
  function __getActionsQuotaInfo({ host }) {
    const metadata = {
      entityFqdn: "wix.automations.v2.automation",
      method: "GET",
      methodFqn: "wix.automations.v2.AutomationsService.GetActionsQuotaInfo",
      packageName: PACKAGE_NAME,
      migrationOptions: {
        optInTransformResponse: true
      },
      url: resolveWixAutomationsV2AutomationsServiceUrl({
        protoPath: "/v2/automations/actions/quota",
        data: payload,
        host
      }),
      params: toURLSearchParams(payload),
      transformResponse: (payload2) => transformPaths(payload2, [
        {
          transformFn: transformRESTTimestampToSDKTimestamp,
          paths: [
            {
              path: "actionProviderQuotaInfo.actionQuotaInfo.quotaInfo.quotas.renewalDate"
            }
          ]
        }
      ])
    };
    return metadata;
  }
  return __getActionsQuotaInfo;
}
function generateActionInputMappingFromTemplate(payload) {
  function __generateActionInputMappingFromTemplate({ host }) {
    const metadata = {
      entityFqdn: "wix.automations.v2.automation",
      method: "POST",
      methodFqn: "wix.automations.v2.AutomationsService.GenerateActionInputMappingFromTemplate",
      packageName: PACKAGE_NAME,
      migrationOptions: {
        optInTransformResponse: true
      },
      url: resolveWixAutomationsV2AutomationsServiceUrl({
        protoPath: "/v2/automations/actions/generate-action-input-mapping-from-template",
        data: payload,
        host
      }),
      data: payload
    };
    return metadata;
  }
  return __generateActionInputMappingFromTemplate;
}

// src/automations-v2-automation-automations-v-2.universal.ts
import { transformPaths as transformPaths2 } from "@wix/sdk-runtime/transformations/transform-paths";
import { createQueryUtils } from "@wix/sdk-runtime/query-builder-utils";
var Domain = /* @__PURE__ */ ((Domain2) => {
  Domain2["USER"] = "USER";
  Domain2["WIX"] = "WIX";
  Domain2["WIX_ACCOUNT"] = "WIX_ACCOUNT";
  return Domain2;
})(Domain || {});
var TimeUnit = /* @__PURE__ */ ((TimeUnit2) => {
  TimeUnit2["MINUTES"] = "MINUTES";
  TimeUnit2["HOURS"] = "HOURS";
  TimeUnit2["DAYS"] = "DAYS";
  TimeUnit2["WEEKS"] = "WEEKS";
  TimeUnit2["MONTHS"] = "MONTHS";
  return TimeUnit2;
})(TimeUnit || {});
var Operator = /* @__PURE__ */ ((Operator2) => {
  Operator2["OR"] = "OR";
  Operator2["AND"] = "AND";
  return Operator2;
})(Operator || {});
var Language = /* @__PURE__ */ ((Language2) => {
  Language2["JAVASCRIPT"] = "JAVASCRIPT";
  return Language2;
})(Language || {});
var Type = /* @__PURE__ */ ((Type2) => {
  Type2["APP_DEFINED"] = "APP_DEFINED";
  Type2["CONDITION"] = "CONDITION";
  Type2["CODE_CONDITION"] = "CODE_CONDITION";
  Type2["DELAY"] = "DELAY";
  Type2["RATE_LIMIT"] = "RATE_LIMIT";
  return Type2;
})(Type || {});
var Status = /* @__PURE__ */ ((Status2) => {
  Status2["ACTIVE"] = "ACTIVE";
  Status2["INACTIVE"] = "INACTIVE";
  return Status2;
})(Status || {});
var Origin = /* @__PURE__ */ ((Origin2) => {
  Origin2["USER"] = "USER";
  Origin2["APPLICATION"] = "APPLICATION";
  Origin2["PREINSTALLED"] = "PREINSTALLED";
  return Origin2;
})(Origin || {});
var WebhookIdentityType = /* @__PURE__ */ ((WebhookIdentityType2) => {
  WebhookIdentityType2["UNKNOWN"] = "UNKNOWN";
  WebhookIdentityType2["ANONYMOUS_VISITOR"] = "ANONYMOUS_VISITOR";
  WebhookIdentityType2["MEMBER"] = "MEMBER";
  WebhookIdentityType2["WIX_USER"] = "WIX_USER";
  WebhookIdentityType2["APP"] = "APP";
  return WebhookIdentityType2;
})(WebhookIdentityType || {});
var RequestedFields = /* @__PURE__ */ ((RequestedFields2) => {
  RequestedFields2["OVERRIDE_SCHEMA"] = "OVERRIDE_SCHEMA";
  return RequestedFields2;
})(RequestedFields || {});
var SortOrder = /* @__PURE__ */ ((SortOrder2) => {
  SortOrder2["ASC"] = "ASC";
  SortOrder2["DESC"] = "DESC";
  return SortOrder2;
})(SortOrder || {});
var State = /* @__PURE__ */ ((State2) => {
  State2["UNKNOWN"] = "UNKNOWN";
  State2["ENABLED"] = "ENABLED";
  State2["DISABLED"] = "DISABLED";
  State2["PENDING"] = "PENDING";
  State2["DEMO"] = "DEMO";
  return State2;
})(State || {});
var SiteCreatedContext = /* @__PURE__ */ ((SiteCreatedContext2) => {
  SiteCreatedContext2["OTHER"] = "OTHER";
  SiteCreatedContext2["FROM_TEMPLATE"] = "FROM_TEMPLATE";
  SiteCreatedContext2["DUPLICATE_BY_SITE_TRANSFER"] = "DUPLICATE_BY_SITE_TRANSFER";
  SiteCreatedContext2["DUPLICATE"] = "DUPLICATE";
  SiteCreatedContext2["OLD_SITE_TRANSFER"] = "OLD_SITE_TRANSFER";
  SiteCreatedContext2["FLASH"] = "FLASH";
  return SiteCreatedContext2;
})(SiteCreatedContext || {});
var Namespace = /* @__PURE__ */ ((Namespace2) => {
  Namespace2["UNKNOWN_NAMESPACE"] = "UNKNOWN_NAMESPACE";
  Namespace2["WIX"] = "WIX";
  Namespace2["SHOUT_OUT"] = "SHOUT_OUT";
  Namespace2["ALBUMS"] = "ALBUMS";
  Namespace2["WIX_STORES_TEST_DRIVE"] = "WIX_STORES_TEST_DRIVE";
  Namespace2["HOTELS"] = "HOTELS";
  Namespace2["CLUBS"] = "CLUBS";
  Namespace2["ONBOARDING_DRAFT"] = "ONBOARDING_DRAFT";
  Namespace2["DEV_SITE"] = "DEV_SITE";
  Namespace2["LOGOS"] = "LOGOS";
  Namespace2["VIDEO_MAKER"] = "VIDEO_MAKER";
  Namespace2["PARTNER_DASHBOARD"] = "PARTNER_DASHBOARD";
  Namespace2["DEV_CENTER_COMPANY"] = "DEV_CENTER_COMPANY";
  Namespace2["HTML_DRAFT"] = "HTML_DRAFT";
  Namespace2["SITELESS_BUSINESS"] = "SITELESS_BUSINESS";
  Namespace2["CREATOR_ECONOMY"] = "CREATOR_ECONOMY";
  Namespace2["DASHBOARD_FIRST"] = "DASHBOARD_FIRST";
  Namespace2["ANYWHERE"] = "ANYWHERE";
  Namespace2["HEADLESS"] = "HEADLESS";
  Namespace2["ACCOUNT_MASTER_CMS"] = "ACCOUNT_MASTER_CMS";
  Namespace2["RISE"] = "RISE";
  Namespace2["BRANDED_FIRST"] = "BRANDED_FIRST";
  Namespace2["NOWNIA"] = "NOWNIA";
  Namespace2["UGC_TEMPLATE"] = "UGC_TEMPLATE";
  Namespace2["CODUX"] = "CODUX";
  Namespace2["MEDIA_DESIGN_CREATOR"] = "MEDIA_DESIGN_CREATOR";
  Namespace2["SHARED_BLOG_ENTERPRISE"] = "SHARED_BLOG_ENTERPRISE";
  Namespace2["STANDALONE_FORMS"] = "STANDALONE_FORMS";
  Namespace2["STANDALONE_EVENTS"] = "STANDALONE_EVENTS";
  Namespace2["MIMIR"] = "MIMIR";
  Namespace2["TWINS"] = "TWINS";
  Namespace2["NANO"] = "NANO";
  Namespace2["BASE44"] = "BASE44";
  Namespace2["CHANNELS"] = "CHANNELS";
  Namespace2["NAUTILUS"] = "NAUTILUS";
  Namespace2["SYMPHONY"] = "SYMPHONY";
  return Namespace2;
})(Namespace || {});
var DeleteStatus = /* @__PURE__ */ ((DeleteStatus2) => {
  DeleteStatus2["UNKNOWN"] = "UNKNOWN";
  DeleteStatus2["TRASH"] = "TRASH";
  DeleteStatus2["DELETED"] = "DELETED";
  DeleteStatus2["PENDING_PURGE"] = "PENDING_PURGE";
  DeleteStatus2["PURGED_EXTERNALLY"] = "PURGED_EXTERNALLY";
  return DeleteStatus2;
})(DeleteStatus || {});
var ValidationResultStatus = /* @__PURE__ */ ((ValidationResultStatus2) => {
  ValidationResultStatus2["VALID"] = "VALID";
  ValidationResultStatus2["VALID_WITH_WARNINGS"] = "VALID_WITH_WARNINGS";
  ValidationResultStatus2["INVALID"] = "INVALID";
  return ValidationResultStatus2;
})(ValidationResultStatus || {});
var TriggerValidationErrorValidationErrorType = /* @__PURE__ */ ((TriggerValidationErrorValidationErrorType2) => {
  TriggerValidationErrorValidationErrorType2["UNKNOWN_VALIDATION_ERROR_TYPE"] = "UNKNOWN_VALIDATION_ERROR_TYPE";
  TriggerValidationErrorValidationErrorType2["CONFIGURATION_ERROR"] = "CONFIGURATION_ERROR";
  TriggerValidationErrorValidationErrorType2["PROVIDER_ERROR"] = "PROVIDER_ERROR";
  return TriggerValidationErrorValidationErrorType2;
})(TriggerValidationErrorValidationErrorType || {});
var TriggerErrorType = /* @__PURE__ */ ((TriggerErrorType2) => {
  TriggerErrorType2["UNKNOWN_TRIGGER_ERROR_TYPE"] = "UNKNOWN_TRIGGER_ERROR_TYPE";
  TriggerErrorType2["NOT_FOUND"] = "NOT_FOUND";
  TriggerErrorType2["APP_NOT_INSTALLED"] = "APP_NOT_INSTALLED";
  TriggerErrorType2["INVALID_TRIGGER_KEY"] = "INVALID_TRIGGER_KEY";
  TriggerErrorType2["INVALID_FILTER_FIELD_KEY"] = "INVALID_FILTER_FIELD_KEY";
  TriggerErrorType2["INVALID_FILTER_EXPRESSION"] = "INVALID_FILTER_EXPRESSION";
  TriggerErrorType2["MISSING_REQUIRED_FILTER"] = "MISSING_REQUIRED_FILTER";
  return TriggerErrorType2;
})(TriggerErrorType || {});
var ValidationErrorSeverity = /* @__PURE__ */ ((ValidationErrorSeverity2) => {
  ValidationErrorSeverity2["UNKNOWN_VALIDATION_ERROR_SEVERITY"] = "UNKNOWN_VALIDATION_ERROR_SEVERITY";
  ValidationErrorSeverity2["WARNING"] = "WARNING";
  ValidationErrorSeverity2["ERROR"] = "ERROR";
  return ValidationErrorSeverity2;
})(ValidationErrorSeverity || {});
var Severity = /* @__PURE__ */ ((Severity2) => {
  Severity2["UNKNOWN_SEVERITY"] = "UNKNOWN_SEVERITY";
  Severity2["WARNING"] = "WARNING";
  Severity2["CRITICAL"] = "CRITICAL";
  return Severity2;
})(Severity || {});
var ValidationErrorType = /* @__PURE__ */ ((ValidationErrorType2) => {
  ValidationErrorType2["UNKNOWN_VALIDATION_ERROR_TYPE"] = "UNKNOWN_VALIDATION_ERROR_TYPE";
  ValidationErrorType2["CONFIGURATION_ERROR"] = "CONFIGURATION_ERROR";
  ValidationErrorType2["PROVIDER_ERROR"] = "PROVIDER_ERROR";
  return ValidationErrorType2;
})(ValidationErrorType || {});
var ActionErrorType = /* @__PURE__ */ ((ActionErrorType2) => {
  ActionErrorType2["UNKNOWN_ACTION_ERROR_TYPE"] = "UNKNOWN_ACTION_ERROR_TYPE";
  ActionErrorType2["NOT_FOUND"] = "NOT_FOUND";
  ActionErrorType2["APP_NOT_INSTALLED"] = "APP_NOT_INSTALLED";
  ActionErrorType2["INVALID_ACTION_KEY"] = "INVALID_ACTION_KEY";
  ActionErrorType2["INVALID_MAPPING"] = "INVALID_MAPPING";
  ActionErrorType2["MAPPING_TYPE_MISMATCH"] = "MAPPING_TYPE_MISMATCH";
  ActionErrorType2["MAPPING_MISSING_REQUIRED_FIELD"] = "MAPPING_MISSING_REQUIRED_FIELD";
  ActionErrorType2["MAPPING_SCHEMA_MISMATCH"] = "MAPPING_SCHEMA_MISMATCH";
  ActionErrorType2["MAPPING_VARIABLE_MISSING_FROM_SCHEMA"] = "MAPPING_VARIABLE_MISSING_FROM_SCHEMA";
  ActionErrorType2["POST_ACTION_NOT_FOUND"] = "POST_ACTION_NOT_FOUND";
  return ActionErrorType2;
})(ActionErrorType || {});
var AutomationValidationErrorValidationErrorType = /* @__PURE__ */ ((AutomationValidationErrorValidationErrorType2) => {
  AutomationValidationErrorValidationErrorType2["UNKNOWN_VALIDATION_ERROR_TYPE"] = "UNKNOWN_VALIDATION_ERROR_TYPE";
  AutomationValidationErrorValidationErrorType2["CONFIGURATION_ERROR"] = "CONFIGURATION_ERROR";
  AutomationValidationErrorValidationErrorType2["PROVIDER_ERROR"] = "PROVIDER_ERROR";
  return AutomationValidationErrorValidationErrorType2;
})(AutomationValidationErrorValidationErrorType || {});
var AutomationErrorType = /* @__PURE__ */ ((AutomationErrorType2) => {
  return AutomationErrorType2;
})(AutomationErrorType || {});
async function getAutomationRevision2(automationId, options) {
  const { httpClient, sideEffects } = arguments[2];
  const payload = renameKeysFromSDKRequestToRESTRequest({
    automationId,
    revision: options?.revision,
    fields: options?.fields
  });
  const reqOpts = getAutomationRevision(payload);
  sideEffects?.onSiteCall?.();
  try {
    const result = await httpClient.request(reqOpts);
    sideEffects?.onSuccess?.(result);
    return renameKeysFromRESTResponseToSDKResponse(result.data);
  } catch (err) {
    const transformedError = sdkTransformError(
      err,
      {
        spreadPathsToArguments: {},
        explicitPathsToArguments: {
          automationId: "$[0]",
          revision: "$[1].revision",
          fields: "$[1].fields"
        },
        singleArgumentUnchanged: false
      },
      ["automationId", "options"]
    );
    sideEffects?.onError?.(err);
    throw transformedError;
  }
}
async function createAutomation2(automation) {
  const { httpClient, sideEffects } = arguments[1];
  const payload = renameKeysFromSDKRequestToRESTRequest({
    automation
  });
  const reqOpts = createAutomation(payload);
  sideEffects?.onSiteCall?.();
  try {
    const result = await httpClient.request(reqOpts);
    sideEffects?.onSuccess?.(result);
    return renameKeysFromRESTResponseToSDKResponse(result.data)?.automation;
  } catch (err) {
    const transformedError = sdkTransformError(
      err,
      {
        spreadPathsToArguments: {},
        explicitPathsToArguments: { automation: "$[0]" },
        singleArgumentUnchanged: false
      },
      ["automation"]
    );
    sideEffects?.onError?.(err);
    throw transformedError;
  }
}
async function createAutomationFromTemplateId2(automationTemplateId) {
  const { httpClient, sideEffects } = arguments[1];
  const payload = renameKeysFromSDKRequestToRESTRequest({
    automationTemplateId
  });
  const reqOpts = createAutomationFromTemplateId(
    payload
  );
  sideEffects?.onSiteCall?.();
  try {
    const result = await httpClient.request(reqOpts);
    sideEffects?.onSuccess?.(result);
    return renameKeysFromRESTResponseToSDKResponse(result.data);
  } catch (err) {
    const transformedError = sdkTransformError(
      err,
      {
        spreadPathsToArguments: {},
        explicitPathsToArguments: { automationTemplateId: "$[0]" },
        singleArgumentUnchanged: false
      },
      ["automationTemplateId"]
    );
    sideEffects?.onError?.(err);
    throw transformedError;
  }
}
async function getAutomation2(automationId) {
  const { httpClient, sideEffects } = arguments[1];
  const payload = renameKeysFromSDKRequestToRESTRequest({
    automationId
  });
  const reqOpts = getAutomation(payload);
  sideEffects?.onSiteCall?.();
  try {
    const result = await httpClient.request(reqOpts);
    sideEffects?.onSuccess?.(result);
    return renameKeysFromRESTResponseToSDKResponse(result.data)?.automation;
  } catch (err) {
    const transformedError = sdkTransformError(
      err,
      {
        spreadPathsToArguments: {},
        explicitPathsToArguments: { automationId: "$[0]" },
        singleArgumentUnchanged: false
      },
      ["automationId"]
    );
    sideEffects?.onError?.(err);
    throw transformedError;
  }
}
async function updateAutomation2(_id, automation) {
  const { httpClient, sideEffects } = arguments[2];
  const payload = renameKeysFromSDKRequestToRESTRequest({
    automation: { ...automation, id: _id }
  });
  const reqOpts = updateAutomation(payload);
  sideEffects?.onSiteCall?.();
  try {
    const result = await httpClient.request(reqOpts);
    sideEffects?.onSuccess?.(result);
    return renameKeysFromRESTResponseToSDKResponse(result.data)?.automation;
  } catch (err) {
    const transformedError = sdkTransformError(
      err,
      {
        spreadPathsToArguments: { automation: "$[1]" },
        explicitPathsToArguments: { "automation.id": "$[0]" },
        singleArgumentUnchanged: false
      },
      ["_id", "automation"]
    );
    sideEffects?.onError?.(err);
    throw transformedError;
  }
}
async function deleteAutomation2(automationId) {
  const { httpClient, sideEffects } = arguments[1];
  const payload = renameKeysFromSDKRequestToRESTRequest({
    automationId
  });
  const reqOpts = deleteAutomation(payload);
  sideEffects?.onSiteCall?.();
  try {
    const result = await httpClient.request(reqOpts);
    sideEffects?.onSuccess?.(result);
  } catch (err) {
    const transformedError = sdkTransformError(
      err,
      {
        spreadPathsToArguments: {},
        explicitPathsToArguments: { automationId: "$[0]" },
        singleArgumentUnchanged: false
      },
      ["automationId"]
    );
    sideEffects?.onError?.(err);
    throw transformedError;
  }
}
async function bulkDeleteAutomations2(automationIds) {
  const { httpClient, sideEffects } = arguments[1];
  const payload = renameKeysFromSDKRequestToRESTRequest({
    automationIds
  });
  const reqOpts = bulkDeleteAutomations(payload);
  sideEffects?.onSiteCall?.();
  try {
    const result = await httpClient.request(reqOpts);
    sideEffects?.onSuccess?.(result);
    return renameKeysFromRESTResponseToSDKResponse(result.data);
  } catch (err) {
    const transformedError = sdkTransformError(
      err,
      {
        spreadPathsToArguments: {},
        explicitPathsToArguments: { automationIds: "$[0]" },
        singleArgumentUnchanged: false
      },
      ["automationIds"]
    );
    sideEffects?.onError?.(err);
    throw transformedError;
  }
}
async function createPreinstalledAutomation2(automation, options) {
  const { httpClient, sideEffects } = arguments[2];
  const payload = renameKeysFromSDKRequestToRESTRequest({
    automation,
    specInfo: options?.specInfo,
    originAutomationInfo: options?.originAutomationInfo,
    appId: options?.appId
  });
  const reqOpts = createPreinstalledAutomation(payload);
  sideEffects?.onSiteCall?.();
  try {
    const result = await httpClient.request(reqOpts);
    sideEffects?.onSuccess?.(result);
    return renameKeysFromRESTResponseToSDKResponse(result.data);
  } catch (err) {
    const transformedError = sdkTransformError(
      err,
      {
        spreadPathsToArguments: {},
        explicitPathsToArguments: {
          automation: "$[0]",
          specInfo: "$[1].specInfo",
          originAutomationInfo: "$[1].originAutomationInfo",
          appId: "$[1].appId"
        },
        singleArgumentUnchanged: false
      },
      ["automation", "options"]
    );
    sideEffects?.onError?.(err);
    throw transformedError;
  }
}
async function updatePreinstalledAutomation2(automation, options) {
  const { httpClient, sideEffects } = arguments[2];
  const payload = renameKeysFromSDKRequestToRESTRequest({
    automation,
    specInfo: options?.specInfo,
    appId: options?.appId
  });
  const reqOpts = updatePreinstalledAutomation(payload);
  sideEffects?.onSiteCall?.();
  try {
    const result = await httpClient.request(reqOpts);
    sideEffects?.onSuccess?.(result);
    return renameKeysFromRESTResponseToSDKResponse(result.data);
  } catch (err) {
    const transformedError = sdkTransformError(
      err,
      {
        spreadPathsToArguments: {},
        explicitPathsToArguments: {
          automation: "$[0]",
          specInfo: "$[1].specInfo",
          appId: "$[1].appId"
        },
        singleArgumentUnchanged: false
      },
      ["automation", "options"]
    );
    sideEffects?.onError?.(err);
    throw transformedError;
  }
}
async function deletePreinstalledAutomation2(componentId, options) {
  const { httpClient, sideEffects } = arguments[2];
  const payload = renameKeysFromSDKRequestToRESTRequest({
    componentId,
    specInfo: options?.specInfo,
    appId: options?.appId
  });
  const reqOpts = deletePreinstalledAutomation(payload);
  sideEffects?.onSiteCall?.();
  try {
    const result = await httpClient.request(reqOpts);
    sideEffects?.onSuccess?.(result);
  } catch (err) {
    const transformedError = sdkTransformError(
      err,
      {
        spreadPathsToArguments: {},
        explicitPathsToArguments: {
          componentId: "$[0]",
          specInfo: "$[1].specInfo",
          appId: "$[1].appId"
        },
        singleArgumentUnchanged: false
      },
      ["componentId", "options"]
    );
    sideEffects?.onError?.(err);
    throw transformedError;
  }
}
async function generatePreinstalledAutomation2(automation, options) {
  const { httpClient, sideEffects } = arguments[2];
  const payload = renameKeysFromSDKRequestToRESTRequest({
    automation,
    appId: options?.appId
  });
  const reqOpts = generatePreinstalledAutomation(
    payload
  );
  sideEffects?.onSiteCall?.();
  try {
    const result = await httpClient.request(reqOpts);
    sideEffects?.onSuccess?.(result);
    return renameKeysFromRESTResponseToSDKResponse(result.data);
  } catch (err) {
    const transformedError = sdkTransformError(
      err,
      {
        spreadPathsToArguments: {},
        explicitPathsToArguments: { automation: "$[0]", appId: "$[1].appId" },
        singleArgumentUnchanged: false
      },
      ["automation", "options"]
    );
    sideEffects?.onError?.(err);
    throw transformedError;
  }
}
async function queryPreinstalledAutomationsForApp2(options) {
  const { httpClient, sideEffects } = arguments[1];
  const payload = renameKeysFromSDKRequestToRESTRequest({
    query: options?.query,
    appId: options?.appId
  });
  const reqOpts = queryPreinstalledAutomationsForApp(
    payload
  );
  sideEffects?.onSiteCall?.();
  try {
    const result = await httpClient.request(reqOpts);
    sideEffects?.onSuccess?.(result);
    return renameKeysFromRESTResponseToSDKResponse(result.data);
  } catch (err) {
    const transformedError = sdkTransformError(
      err,
      {
        spreadPathsToArguments: {},
        explicitPathsToArguments: { query: "$[0].query", appId: "$[0].appId" },
        singleArgumentUnchanged: false
      },
      ["options"]
    );
    sideEffects?.onError?.(err);
    throw transformedError;
  }
}
async function queryPreinstalledAutomations2(query) {
  const { httpClient, sideEffects } = arguments[1];
  const payload = renameKeysFromSDKRequestToRESTRequest({ query });
  const reqOpts = queryPreinstalledAutomations(payload);
  sideEffects?.onSiteCall?.();
  try {
    const result = await httpClient.request(reqOpts);
    sideEffects?.onSuccess?.(result);
    return renameKeysFromRESTResponseToSDKResponse(result.data);
  } catch (err) {
    const transformedError = sdkTransformError(
      err,
      {
        spreadPathsToArguments: {},
        explicitPathsToArguments: { query: "$[0]" },
        singleArgumentUnchanged: false
      },
      ["query"]
    );
    sideEffects?.onError?.(err);
    throw transformedError;
  }
}
function queryAutomations2(options) {
  const { httpClient, sideEffects } = arguments[1];
  return queryBuilder({
    func: async (payload) => {
      const reqOpts = queryAutomations({
        ...payload,
        ...options ?? {}
      });
      sideEffects?.onSiteCall?.();
      try {
        const result = await httpClient.request(reqOpts);
        sideEffects?.onSuccess?.(result);
        return result;
      } catch (err) {
        sideEffects?.onError?.(err);
        throw err;
      }
    },
    requestTransformer: (query) => {
      const args = [query, options];
      return renameKeysFromSDKRequestToRESTRequest({
        ...args?.[1],
        query: args?.[0]
      });
    },
    responseTransformer: ({ data }) => {
      const transformedData = renameKeysFromRESTResponseToSDKResponse(
        transformPaths2(data, [])
      );
      return {
        items: transformedData?.automations,
        pagingMetadata: transformedData?.pagingMetadata
      };
    },
    errorTransformer: (err) => {
      const transformedError = sdkTransformError(err, {
        spreadPathsToArguments: {},
        explicitPathsToArguments: { query: "$[0]" },
        singleArgumentUnchanged: false
      });
      throw transformedError;
    },
    pagingMethod: "CURSOR",
    transformationPaths: {}
  });
}
async function typedQueryAutomations(query, options) {
  const { httpClient, sideEffects } = arguments[2];
  const payload = renameKeysFromSDKRequestToRESTRequest({
    query,
    ...options
  });
  const reqOpts = queryAutomations(payload);
  sideEffects?.onSiteCall?.();
  try {
    const result = await httpClient.request(reqOpts);
    sideEffects?.onSuccess?.(result);
    return renameKeysFromRESTResponseToSDKResponse(result.data);
  } catch (err) {
    const transformedError = sdkTransformError(
      err,
      {
        spreadPathsToArguments: {},
        explicitPathsToArguments: { query: "$[0]" },
        singleArgumentUnchanged: false
      },
      ["query", "options"]
    );
    sideEffects?.onError?.(err);
    throw transformedError;
  }
}
var utils = {
  query: {
    ...createQueryUtils()
  }
};
async function getAggregatedUsageInfo2(options) {
  const { httpClient, sideEffects } = arguments[1];
  const payload = renameKeysFromSDKRequestToRESTRequest({
    filter: options?.filter
  });
  const reqOpts = getAggregatedUsageInfo(payload);
  sideEffects?.onSiteCall?.();
  try {
    const result = await httpClient.request(reqOpts);
    sideEffects?.onSuccess?.(result);
    return renameKeysFromRESTResponseToSDKResponse(result.data);
  } catch (err) {
    const transformedError = sdkTransformError(
      err,
      {
        spreadPathsToArguments: {},
        explicitPathsToArguments: { filter: "$[0].filter" },
        singleArgumentUnchanged: false
      },
      ["options"]
    );
    sideEffects?.onError?.(err);
    throw transformedError;
  }
}
async function copyAutomation2(automationId, options) {
  const { httpClient, sideEffects } = arguments[2];
  const payload = renameKeysFromSDKRequestToRESTRequest({
    automationId,
    origin: options?.origin,
    automation: options?.automation
  });
  const reqOpts = copyAutomation(payload);
  sideEffects?.onSiteCall?.();
  try {
    const result = await httpClient.request(reqOpts);
    sideEffects?.onSuccess?.(result);
    return renameKeysFromRESTResponseToSDKResponse(result.data);
  } catch (err) {
    const transformedError = sdkTransformError(
      err,
      {
        spreadPathsToArguments: {},
        explicitPathsToArguments: {
          automationId: "$[0]",
          origin: "$[1].origin",
          automation: "$[1].automation"
        },
        singleArgumentUnchanged: false
      },
      ["automationId", "options"]
    );
    sideEffects?.onError?.(err);
    throw transformedError;
  }
}
async function createDraftAutomation2(options) {
  const { httpClient, sideEffects } = arguments[1];
  const payload = renameKeysFromSDKRequestToRESTRequest({
    automation: options?.automation
  });
  const reqOpts = createDraftAutomation(payload);
  sideEffects?.onSiteCall?.();
  try {
    const result = await httpClient.request(reqOpts);
    sideEffects?.onSuccess?.(result);
    return renameKeysFromRESTResponseToSDKResponse(result.data);
  } catch (err) {
    const transformedError = sdkTransformError(
      err,
      {
        spreadPathsToArguments: {},
        explicitPathsToArguments: { automation: "$[0].automation" },
        singleArgumentUnchanged: false
      },
      ["options"]
    );
    sideEffects?.onError?.(err);
    throw transformedError;
  }
}
async function createDraftAutomationFromTemplateId2(automationTemplateId) {
  const { httpClient, sideEffects } = arguments[1];
  const payload = renameKeysFromSDKRequestToRESTRequest({
    automationTemplateId
  });
  const reqOpts = createDraftAutomationFromTemplateId(
    payload
  );
  sideEffects?.onSiteCall?.();
  try {
    const result = await httpClient.request(reqOpts);
    sideEffects?.onSuccess?.(result);
    return renameKeysFromRESTResponseToSDKResponse(result.data);
  } catch (err) {
    const transformedError = sdkTransformError(
      err,
      {
        spreadPathsToArguments: {},
        explicitPathsToArguments: { automationTemplateId: "$[0]" },
        singleArgumentUnchanged: false
      },
      ["automationTemplateId"]
    );
    sideEffects?.onError?.(err);
    throw transformedError;
  }
}
async function getOrCreateDraftAutomation2(originalAutomationId) {
  const { httpClient, sideEffects } = arguments[1];
  const payload = renameKeysFromSDKRequestToRESTRequest({
    originalAutomationId
  });
  const reqOpts = getOrCreateDraftAutomation(payload);
  sideEffects?.onSiteCall?.();
  try {
    const result = await httpClient.request(reqOpts);
    sideEffects?.onSuccess?.(result);
    return renameKeysFromRESTResponseToSDKResponse(result.data);
  } catch (err) {
    const transformedError = sdkTransformError(
      err,
      {
        spreadPathsToArguments: {},
        explicitPathsToArguments: { originalAutomationId: "$[0]" },
        singleArgumentUnchanged: false
      },
      ["originalAutomationId"]
    );
    sideEffects?.onError?.(err);
    throw transformedError;
  }
}
async function updateDraftAutomation2(_id, automation) {
  const { httpClient, sideEffects } = arguments[2];
  const payload = renameKeysFromSDKRequestToRESTRequest({
    automation: { ...automation, id: _id }
  });
  const reqOpts = updateDraftAutomation(payload);
  sideEffects?.onSiteCall?.();
  try {
    const result = await httpClient.request(reqOpts);
    sideEffects?.onSuccess?.(result);
    return renameKeysFromRESTResponseToSDKResponse(result.data);
  } catch (err) {
    const transformedError = sdkTransformError(
      err,
      {
        spreadPathsToArguments: { automation: "$[1]" },
        explicitPathsToArguments: { "automation.id": "$[0]" },
        singleArgumentUnchanged: false
      },
      ["_id", "automation"]
    );
    sideEffects?.onError?.(err);
    throw transformedError;
  }
}
async function queryAutomationsWithDrafts2(options) {
  const { httpClient, sideEffects } = arguments[1];
  const payload = renameKeysFromSDKRequestToRESTRequest({
    query: options?.query
  });
  const reqOpts = queryAutomationsWithDrafts(payload);
  sideEffects?.onSiteCall?.();
  try {
    const result = await httpClient.request(reqOpts);
    sideEffects?.onSuccess?.(result);
    return renameKeysFromRESTResponseToSDKResponse(result.data);
  } catch (err) {
    const transformedError = sdkTransformError(
      err,
      {
        spreadPathsToArguments: {},
        explicitPathsToArguments: { query: "$[0].query" },
        singleArgumentUnchanged: false
      },
      ["options"]
    );
    sideEffects?.onError?.(err);
    throw transformedError;
  }
}
async function bulkCountAutomationsWithDrafts2(options) {
  const { httpClient, sideEffects } = arguments[1];
  const payload = renameKeysFromSDKRequestToRESTRequest({
    filters: options?.filters
  });
  const reqOpts = bulkCountAutomationsWithDrafts(
    payload
  );
  sideEffects?.onSiteCall?.();
  try {
    const result = await httpClient.request(reqOpts);
    sideEffects?.onSuccess?.(result);
    return renameKeysFromRESTResponseToSDKResponse(result.data);
  } catch (err) {
    const transformedError = sdkTransformError(
      err,
      {
        spreadPathsToArguments: {},
        explicitPathsToArguments: { filters: "$[0].filters" },
        singleArgumentUnchanged: false
      },
      ["options"]
    );
    sideEffects?.onError?.(err);
    throw transformedError;
  }
}
async function deleteDraftAutomation2(automationId) {
  const { httpClient, sideEffects } = arguments[1];
  const payload = renameKeysFromSDKRequestToRESTRequest({
    automationId
  });
  const reqOpts = deleteDraftAutomation(payload);
  sideEffects?.onSiteCall?.();
  try {
    const result = await httpClient.request(reqOpts);
    sideEffects?.onSuccess?.(result);
  } catch (err) {
    const transformedError = sdkTransformError(
      err,
      {
        spreadPathsToArguments: {},
        explicitPathsToArguments: { automationId: "$[0]" },
        singleArgumentUnchanged: false
      },
      ["automationId"]
    );
    sideEffects?.onError?.(err);
    throw transformedError;
  }
}
async function publishDraftAutomation2(automationId) {
  const { httpClient, sideEffects } = arguments[1];
  const payload = renameKeysFromSDKRequestToRESTRequest({
    automationId
  });
  const reqOpts = publishDraftAutomation(payload);
  sideEffects?.onSiteCall?.();
  try {
    const result = await httpClient.request(reqOpts);
    sideEffects?.onSuccess?.(result);
    return renameKeysFromRESTResponseToSDKResponse(result.data);
  } catch (err) {
    const transformedError = sdkTransformError(
      err,
      {
        spreadPathsToArguments: {},
        explicitPathsToArguments: { automationId: "$[0]" },
        singleArgumentUnchanged: false
      },
      ["automationId"]
    );
    sideEffects?.onError?.(err);
    throw transformedError;
  }
}
async function validateAutomation2(automation, options) {
  const { httpClient, sideEffects } = arguments[2];
  const payload = renameKeysFromSDKRequestToRESTRequest({
    automation,
    validationSettings: options?.validationSettings
  });
  const reqOpts = validateAutomation(payload);
  sideEffects?.onSiteCall?.();
  try {
    const result = await httpClient.request(reqOpts);
    sideEffects?.onSuccess?.(result);
    return renameKeysFromRESTResponseToSDKResponse(result.data);
  } catch (err) {
    const transformedError = sdkTransformError(
      err,
      {
        spreadPathsToArguments: {},
        explicitPathsToArguments: {
          automation: "$[0]",
          validationSettings: "$[1].validationSettings"
        },
        singleArgumentUnchanged: false
      },
      ["automation", "options"]
    );
    sideEffects?.onError?.(err);
    throw transformedError;
  }
}
async function validateAutomationById2(automationId, options) {
  const { httpClient, sideEffects } = arguments[2];
  const payload = renameKeysFromSDKRequestToRESTRequest({
    automationId,
    validationSettings: options?.validationSettings
  });
  const reqOpts = validateAutomationById(payload);
  sideEffects?.onSiteCall?.();
  try {
    const result = await httpClient.request(reqOpts);
    sideEffects?.onSuccess?.(result);
    return renameKeysFromRESTResponseToSDKResponse(result.data);
  } catch (err) {
    const transformedError = sdkTransformError(
      err,
      {
        spreadPathsToArguments: {},
        explicitPathsToArguments: {
          automationId: "$[0]",
          validationSettings: "$[1].validationSettings"
        },
        singleArgumentUnchanged: false
      },
      ["automationId", "options"]
    );
    sideEffects?.onError?.(err);
    throw transformedError;
  }
}
async function getActionsQuotaInfo2() {
  const { httpClient, sideEffects } = arguments[0];
  const payload = renameKeysFromSDKRequestToRESTRequest({});
  const reqOpts = getActionsQuotaInfo(payload);
  sideEffects?.onSiteCall?.();
  try {
    const result = await httpClient.request(reqOpts);
    sideEffects?.onSuccess?.(result);
    return renameKeysFromRESTResponseToSDKResponse(result.data);
  } catch (err) {
    const transformedError = sdkTransformError(
      err,
      {
        spreadPathsToArguments: {},
        explicitPathsToArguments: {},
        singleArgumentUnchanged: false
      },
      []
    );
    sideEffects?.onError?.(err);
    throw transformedError;
  }
}
async function generateActionInputMappingFromTemplate2(appId, options) {
  const { httpClient, sideEffects } = arguments[2];
  const payload = renameKeysFromSDKRequestToRESTRequest({
    appId,
    actionKey: options?.actionKey,
    actionInputMappingTemplate: options?.actionInputMappingTemplate
  });
  const reqOpts = generateActionInputMappingFromTemplate(
    payload
  );
  sideEffects?.onSiteCall?.();
  try {
    const result = await httpClient.request(reqOpts);
    sideEffects?.onSuccess?.(result);
    return renameKeysFromRESTResponseToSDKResponse(result.data);
  } catch (err) {
    const transformedError = sdkTransformError(
      err,
      {
        spreadPathsToArguments: {},
        explicitPathsToArguments: {
          appId: "$[0]",
          actionKey: "$[1].actionKey",
          actionInputMappingTemplate: "$[1].actionInputMappingTemplate"
        },
        singleArgumentUnchanged: false
      },
      ["appId", "options"]
    );
    sideEffects?.onError?.(err);
    throw transformedError;
  }
}
export {
  ActionErrorType,
  AutomationErrorType,
  AutomationValidationErrorValidationErrorType,
  DeleteStatus,
  Domain,
  Language,
  Namespace,
  Operator,
  Origin,
  RequestedFields,
  Severity,
  SiteCreatedContext,
  SortOrder,
  State,
  Status,
  TimeUnit,
  TriggerErrorType,
  TriggerValidationErrorValidationErrorType,
  Type,
  ValidationErrorSeverity,
  ValidationErrorType,
  ValidationResultStatus,
  WebhookIdentityType,
  bulkCountAutomationsWithDrafts2 as bulkCountAutomationsWithDrafts,
  bulkDeleteAutomations2 as bulkDeleteAutomations,
  copyAutomation2 as copyAutomation,
  createAutomation2 as createAutomation,
  createAutomationFromTemplateId2 as createAutomationFromTemplateId,
  createDraftAutomation2 as createDraftAutomation,
  createDraftAutomationFromTemplateId2 as createDraftAutomationFromTemplateId,
  createPreinstalledAutomation2 as createPreinstalledAutomation,
  deleteAutomation2 as deleteAutomation,
  deleteDraftAutomation2 as deleteDraftAutomation,
  deletePreinstalledAutomation2 as deletePreinstalledAutomation,
  generateActionInputMappingFromTemplate2 as generateActionInputMappingFromTemplate,
  generatePreinstalledAutomation2 as generatePreinstalledAutomation,
  getActionsQuotaInfo2 as getActionsQuotaInfo,
  getAggregatedUsageInfo2 as getAggregatedUsageInfo,
  getAutomation2 as getAutomation,
  getAutomationRevision2 as getAutomationRevision,
  getOrCreateDraftAutomation2 as getOrCreateDraftAutomation,
  publishDraftAutomation2 as publishDraftAutomation,
  queryAutomations2 as queryAutomations,
  queryAutomationsWithDrafts2 as queryAutomationsWithDrafts,
  queryPreinstalledAutomations2 as queryPreinstalledAutomations,
  queryPreinstalledAutomationsForApp2 as queryPreinstalledAutomationsForApp,
  typedQueryAutomations,
  updateAutomation2 as updateAutomation,
  updateDraftAutomation2 as updateDraftAutomation,
  updatePreinstalledAutomation2 as updatePreinstalledAutomation,
  utils,
  validateAutomation2 as validateAutomation,
  validateAutomationById2 as validateAutomationById
};
//# sourceMappingURL=index.typings.mjs.map