mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
refactor: Add IRequestOptions type to helpers.request for more type safety (no-changelog) (#8563)
Co-authored-by: कारतोफ्फेलस्क्रिप्ट™ <aditya@netroy.in>
This commit is contained in:
@@ -10,7 +10,7 @@ jest.mock('../../../../v2/transport', () => {
|
||||
const originalModule = jest.requireActual('../../../../v2/transport');
|
||||
return {
|
||||
...originalModule,
|
||||
microsoftApiRequest: jest.fn(async function (method: string) {
|
||||
microsoftApiRequest: jest.fn(async function (method: IHttpRequestMethods) {
|
||||
if (method === 'POST') {
|
||||
return {
|
||||
style: 'TableStyleMedium2',
|
||||
|
||||
@@ -10,7 +10,7 @@ jest.mock('../../../../v2/transport', () => {
|
||||
const originalModule = jest.requireActual('../../../../v2/transport');
|
||||
return {
|
||||
...originalModule,
|
||||
microsoftApiRequest: jest.fn(async function (method: string, resource: string) {
|
||||
microsoftApiRequest: jest.fn(async function (method: IHttpRequestMethods, resource: string) {
|
||||
if (method === 'GET') {
|
||||
return {
|
||||
value: [
|
||||
|
||||
@@ -10,7 +10,7 @@ jest.mock('../../../../v2/transport', () => {
|
||||
const originalModule = jest.requireActual('../../../../v2/transport');
|
||||
return {
|
||||
...originalModule,
|
||||
microsoftApiRequest: jest.fn(async function (method: string) {
|
||||
microsoftApiRequest: jest.fn(async function (method: IHttpRequestMethods) {
|
||||
if (method === 'POST') {
|
||||
return {
|
||||
address: 'Sheet4!A1:D5',
|
||||
|
||||
@@ -10,7 +10,7 @@ jest.mock('../../../../v2/transport', () => {
|
||||
const originalModule = jest.requireActual('../../../../v2/transport');
|
||||
return {
|
||||
...originalModule,
|
||||
microsoftApiRequest: jest.fn(async function (method: string) {
|
||||
microsoftApiRequest: jest.fn(async function (method: IHttpRequestMethods) {
|
||||
if (method === 'DELETE') {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ jest.mock('../../../../v2/transport', () => {
|
||||
const originalModule = jest.requireActual('../../../../v2/transport');
|
||||
return {
|
||||
...originalModule,
|
||||
microsoftApiRequest: jest.fn(async function (method: string) {
|
||||
microsoftApiRequest: jest.fn(async function (method: IHttpRequestMethods) {
|
||||
if (method === 'GET') {
|
||||
return {
|
||||
value: [
|
||||
|
||||
@@ -12,7 +12,7 @@ jest.mock('../../../../v2/transport', () => {
|
||||
...originalModule,
|
||||
microsoftApiRequestAllItemsSkip: jest.fn(async function (
|
||||
_property: string,
|
||||
_method: string,
|
||||
_method: IHttpRequestMethods,
|
||||
endpoint: string,
|
||||
) {
|
||||
if (endpoint.includes('columns')) {
|
||||
|
||||
@@ -10,7 +10,7 @@ jest.mock('../../../../v2/transport', () => {
|
||||
const originalModule = jest.requireActual('../../../../v2/transport');
|
||||
return {
|
||||
...originalModule,
|
||||
microsoftApiRequest: jest.fn(async function (method: string, resource: string) {
|
||||
microsoftApiRequest: jest.fn(async function (method: IHttpRequestMethods, resource: string) {
|
||||
if (method === 'POST' && resource.includes('createSession')) {
|
||||
return {
|
||||
id: 12345,
|
||||
|
||||
@@ -10,7 +10,7 @@ jest.mock('../../../../v2/transport', () => {
|
||||
const originalModule = jest.requireActual('../../../../v2/transport');
|
||||
return {
|
||||
...originalModule,
|
||||
microsoftApiRequest: jest.fn(async function (method: string) {
|
||||
microsoftApiRequest: jest.fn(async function (method: IHttpRequestMethods) {
|
||||
if (method === 'DELETE') {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ jest.mock('../../../../v2/transport', () => {
|
||||
const originalModule = jest.requireActual('../../../../v2/transport');
|
||||
return {
|
||||
...originalModule,
|
||||
microsoftApiRequest: jest.fn(async function (method: string) {
|
||||
microsoftApiRequest: jest.fn(async function (method: IHttpRequestMethods) {
|
||||
if (method === 'GET') {
|
||||
return {
|
||||
value: [
|
||||
|
||||
@@ -5,7 +5,7 @@ jest.mock('../../../../v2/transport', () => {
|
||||
const originalModule = jest.requireActual('../../../../v2/transport');
|
||||
return {
|
||||
...originalModule,
|
||||
microsoftApiRequest: jest.fn(async function (method: string, resource: string) {
|
||||
microsoftApiRequest: jest.fn(async function (method: IHttpRequestMethods, resource: string) {
|
||||
if (method === 'GET' && resource.includes('usedRange')) {
|
||||
return {
|
||||
address: 'Sheet4!A1:D6',
|
||||
|
||||
@@ -10,7 +10,7 @@ jest.mock('../../../../v2/transport', () => {
|
||||
const originalModule = jest.requireActual('../../../../v2/transport');
|
||||
return {
|
||||
...originalModule,
|
||||
microsoftApiRequest: jest.fn(async function (method: string) {
|
||||
microsoftApiRequest: jest.fn(async function (method: IHttpRequestMethods) {
|
||||
if (method === 'POST') {
|
||||
return {
|
||||
values: [
|
||||
|
||||
@@ -10,7 +10,7 @@ jest.mock('../../../../v2/transport', () => {
|
||||
const originalModule = jest.requireActual('../../../../v2/transport');
|
||||
return {
|
||||
...originalModule,
|
||||
microsoftApiRequest: jest.fn(async function (method: string) {
|
||||
microsoftApiRequest: jest.fn(async function (method: IHttpRequestMethods) {
|
||||
if (method === 'DELETE') {
|
||||
return {
|
||||
values: [
|
||||
|
||||
@@ -10,7 +10,7 @@ jest.mock('../../../../v2/transport', () => {
|
||||
const originalModule = jest.requireActual('../../../../v2/transport');
|
||||
return {
|
||||
...originalModule,
|
||||
microsoftApiRequest: jest.fn(async function (method: string) {
|
||||
microsoftApiRequest: jest.fn(async function (method: IHttpRequestMethods) {
|
||||
if (method === 'GET') {
|
||||
return {
|
||||
value: [
|
||||
|
||||
@@ -5,7 +5,7 @@ jest.mock('../../../../v2/transport', () => {
|
||||
const originalModule = jest.requireActual('../../../../v2/transport');
|
||||
return {
|
||||
...originalModule,
|
||||
microsoftApiRequest: jest.fn(async function (method: string, resource: string) {
|
||||
microsoftApiRequest: jest.fn(async function (method: IHttpRequestMethods, resource: string) {
|
||||
{
|
||||
if (method === 'GET' && resource.includes('usedRange')) {
|
||||
return {
|
||||
|
||||
@@ -5,7 +5,7 @@ jest.mock('../../../../v2/transport', () => {
|
||||
const originalModule = jest.requireActual('../../../../v2/transport');
|
||||
return {
|
||||
...originalModule,
|
||||
microsoftApiRequest: jest.fn(async function (method: string, resource: string) {
|
||||
microsoftApiRequest: jest.fn(async function (method: IHttpRequestMethods, resource: string) {
|
||||
if (method === 'GET' && resource.includes('usedRange')) {
|
||||
return {
|
||||
address: 'Sheet4!A1:D6',
|
||||
|
||||
@@ -5,7 +5,7 @@ jest.mock('../../../../v2/transport', () => {
|
||||
const originalModule = jest.requireActual('../../../../v2/transport');
|
||||
return {
|
||||
...originalModule,
|
||||
microsoftApiRequest: jest.fn(async function (method: string, resource: string) {
|
||||
microsoftApiRequest: jest.fn(async function (method: IHttpRequestMethods, resource: string) {
|
||||
if (method === 'GET' && resource.includes('usedRange')) {
|
||||
return {
|
||||
address: 'Sheet4!A1:D6',
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
import type { OptionsWithUri } from 'request';
|
||||
import type {
|
||||
IDataObject,
|
||||
IExecuteFunctions,
|
||||
IHttpRequestMethods,
|
||||
ILoadOptionsFunctions,
|
||||
IRequestOptions,
|
||||
JsonObject,
|
||||
} from 'n8n-workflow';
|
||||
import { NodeApiError } from 'n8n-workflow';
|
||||
|
||||
export async function microsoftApiRequest(
|
||||
this: IExecuteFunctions | ILoadOptionsFunctions,
|
||||
method: string,
|
||||
method: IHttpRequestMethods,
|
||||
resource: string,
|
||||
|
||||
body: any = {},
|
||||
@@ -17,7 +18,7 @@ export async function microsoftApiRequest(
|
||||
uri?: string,
|
||||
headers: IDataObject = {},
|
||||
): Promise<any> {
|
||||
const options: OptionsWithUri = {
|
||||
const options: IRequestOptions = {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
@@ -41,7 +42,7 @@ export async function microsoftApiRequest(
|
||||
export async function microsoftApiRequestAllItems(
|
||||
this: IExecuteFunctions | ILoadOptionsFunctions,
|
||||
propertyName: string,
|
||||
method: string,
|
||||
method: IHttpRequestMethods,
|
||||
endpoint: string,
|
||||
|
||||
body: any = {},
|
||||
@@ -68,7 +69,7 @@ export async function microsoftApiRequestAllItems(
|
||||
export async function microsoftApiRequestAllItemsSkip(
|
||||
this: IExecuteFunctions | ILoadOptionsFunctions,
|
||||
propertyName: string,
|
||||
method: string,
|
||||
method: IHttpRequestMethods,
|
||||
endpoint: string,
|
||||
|
||||
body: any = {},
|
||||
|
||||
@@ -1,22 +1,23 @@
|
||||
import type { OptionsWithUri } from 'request';
|
||||
import type {
|
||||
IDataObject,
|
||||
IExecuteFunctions,
|
||||
IHttpRequestMethods,
|
||||
ILoadOptionsFunctions,
|
||||
IRequestOptions,
|
||||
JsonObject,
|
||||
} from 'n8n-workflow';
|
||||
import { NodeApiError } from 'n8n-workflow';
|
||||
|
||||
export async function microsoftApiRequest(
|
||||
this: IExecuteFunctions | ILoadOptionsFunctions,
|
||||
method: string,
|
||||
method: IHttpRequestMethods,
|
||||
resource: string,
|
||||
body: any = {},
|
||||
qs: IDataObject = {},
|
||||
uri?: string,
|
||||
headers: IDataObject = {},
|
||||
): Promise<any> {
|
||||
const options: OptionsWithUri = {
|
||||
const options: IRequestOptions = {
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
@@ -39,7 +40,7 @@ export async function microsoftApiRequest(
|
||||
export async function microsoftApiRequestAllItems(
|
||||
this: IExecuteFunctions | ILoadOptionsFunctions,
|
||||
propertyName: string,
|
||||
method: string,
|
||||
method: IHttpRequestMethods,
|
||||
endpoint: string,
|
||||
body: any = {},
|
||||
query: IDataObject = {},
|
||||
@@ -65,7 +66,7 @@ export async function microsoftApiRequestAllItems(
|
||||
export async function microsoftApiRequestAllItemsSkip(
|
||||
this: IExecuteFunctions | ILoadOptionsFunctions,
|
||||
propertyName: string,
|
||||
method: string,
|
||||
method: IHttpRequestMethods,
|
||||
endpoint: string,
|
||||
body: any = {},
|
||||
query: IDataObject = {},
|
||||
|
||||
Reference in New Issue
Block a user