@n8n/rest-api-client 2.5.1 → 2.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"templates.cjs","names":["get"],"sources":["../src/api/templates.ts"],"sourcesContent":["import type { RawAxiosRequestHeaders } from 'axios';\nimport type { INode, INodeCredentialsDetails } from 'n8n-workflow';\n\nimport type { VersionNode } from './versions';\nimport type { WorkflowData } from './workflows';\nimport { get } from '../utils';\n\nexport interface IWorkflowTemplateNode\n\textends Pick<\n\t\tINode,\n\t\t'name' | 'type' | 'position' | 'parameters' | 'typeVersion' | 'webhookId' | 'id' | 'disabled'\n\t> {\n\t// The credentials in a template workflow have a different type than in a regular workflow\n\tcredentials?: IWorkflowTemplateNodeCredentials;\n}\n\nexport interface IWorkflowTemplateNodeCredentials {\n\t[key: string]: string | INodeCredentialsDetails;\n}\n\nexport interface IWorkflowTemplate {\n\tid: number;\n\tname: string;\n\tworkflow: Pick<WorkflowData, 'connections' | 'settings' | 'pinData'> & {\n\t\tnodes: IWorkflowTemplateNode[];\n\t};\n}\n\nexport interface ITemplatesNode extends VersionNode {\n\tid: number;\n\tcategories?: ITemplatesCategory[];\n}\n\nexport interface ITemplatesCollection {\n\tid: number;\n\tname: string;\n\tnodes: ITemplatesNode[];\n\tworkflows: Array<{ id: number }>;\n}\n\ninterface ITemplatesImage {\n\tid: number;\n\turl: string;\n}\n\ninterface ITemplatesCollectionExtended extends ITemplatesCollection {\n\tdescription: string | null;\n\timage: ITemplatesImage[];\n\tcategories: ITemplatesCategory[];\n\tcreatedAt: string;\n}\n\nexport interface ITemplatesCollectionFull extends ITemplatesCollectionExtended {\n\tfull: true;\n}\n\nexport interface ITemplatesCollectionResponse extends ITemplatesCollectionExtended {\n\tworkflows: ITemplatesWorkflow[];\n}\n\n/**\n * A template without the actual workflow definition\n */\n\nexport interface ITemplatesWorkflow {\n\tid: number;\n\tcreatedAt: string;\n\tname: string;\n\tnodes: ITemplatesNode[];\n\ttotalViews: number;\n\tuser: {\n\t\tusername: string;\n\t};\n}\n\nexport interface ITemplatesWorkflowInfo {\n\tnodeCount: number;\n\tnodeTypes: {\n\t\t[key: string]: {\n\t\t\tcount: number;\n\t\t};\n\t};\n}\n\nexport type TemplateSearchFacet = {\n\tfield_name: string;\n\tsampled: boolean;\n\tstats: {\n\t\ttotal_values: number;\n\t};\n\tcounts: Array<{\n\t\tcount: number;\n\t\thighlighted: string;\n\t\tvalue: string;\n\t}>;\n};\n\nexport interface ITemplatesWorkflowResponse extends ITemplatesWorkflow, IWorkflowTemplate {\n\tdescription: string | null;\n\timage: ITemplatesImage[];\n\tcategories: ITemplatesCategory[];\n\tworkflowInfo: ITemplatesWorkflowInfo;\n}\n\n/**\n * A template with also the full workflow definition\n */\n\nexport interface ITemplatesWorkflowFull extends ITemplatesWorkflowResponse {\n\tfull: true;\n}\n\nexport interface ITemplatesQuery {\n\tcategories: string[];\n\tsearch: string;\n\tapps?: string[];\n\tnodes?: string[];\n\tsort?: string;\n\tcombineWith?: string;\n}\n\nexport interface ITemplatesCategory {\n\tid: number;\n\tname: string;\n}\n\nfunction stringifyArray(arr: string[]) {\n\treturn arr.join(',');\n}\n\nexport async function testHealthEndpoint(apiEndpoint: string) {\n\treturn await get(apiEndpoint, '/health');\n}\n\nexport async function getCategories(\n\tapiEndpoint: string,\n\theaders?: RawAxiosRequestHeaders,\n): Promise<{ categories: ITemplatesCategory[] }> {\n\treturn await get(apiEndpoint, '/templates/categories', undefined, headers);\n}\n\nexport async function getCollections(\n\tapiEndpoint: string,\n\tquery: ITemplatesQuery,\n\theaders?: RawAxiosRequestHeaders,\n): Promise<{ collections: ITemplatesCollection[] }> {\n\treturn await get(\n\t\tapiEndpoint,\n\t\t'/templates/collections',\n\t\t{ category: query.categories, search: query.search },\n\t\theaders,\n\t);\n}\n\nexport async function getWorkflows(\n\tapiEndpoint: string,\n\tquery: {\n\t\tpage: number;\n\t\tlimit: number;\n\t\tcategories: string[];\n\t\tsearch: string;\n\t\tsort?: string;\n\t\tapps?: string[];\n\t\tnodes?: string[];\n\t\tcombineWith?: string;\n\t},\n\theaders?: RawAxiosRequestHeaders,\n): Promise<{\n\ttotalWorkflows: number;\n\tworkflows: ITemplatesWorkflow[];\n\tfilters: TemplateSearchFacet[];\n}> {\n\tconst { apps, sort, combineWith, categories, nodes, ...restQuery } = query;\n\tconst finalQuery = {\n\t\t...restQuery,\n\t\tcategory: stringifyArray(categories),\n\t\t...(apps && { apps: stringifyArray(apps) }),\n\t\t...(nodes && { nodes: stringifyArray(nodes) }),\n\t\t...(sort && { sort }),\n\t\t...(combineWith && { combineWith }),\n\t};\n\n\treturn await get(apiEndpoint, '/templates/search', finalQuery, headers);\n}\n\nexport async function getCollectionById(\n\tapiEndpoint: string,\n\tcollectionId: string,\n\theaders?: RawAxiosRequestHeaders,\n): Promise<{ collection: ITemplatesCollectionResponse }> {\n\treturn await get(apiEndpoint, `/templates/collections/${collectionId}`, undefined, headers);\n}\n\nexport async function getTemplateById(\n\tapiEndpoint: string,\n\ttemplateId: string,\n\theaders?: RawAxiosRequestHeaders,\n): Promise<{ workflow: ITemplatesWorkflowResponse }> {\n\treturn await get(apiEndpoint, `/templates/workflows/${templateId}`, undefined, headers);\n}\n\nexport async function getWorkflowTemplate(\n\tapiEndpoint: string,\n\ttemplateId: string,\n\theaders?: RawAxiosRequestHeaders,\n): Promise<IWorkflowTemplate> {\n\treturn await get(apiEndpoint, `/workflows/templates/${templateId}`, undefined, headers);\n}\n"],"mappings":";;;AA8HA,SAAS,eAAe,KAAe;AACtC,QAAO,IAAI,KAAK,IAAI;;AAGrB,eAAsB,mBAAmB,aAAqB;AAC7D,QAAO,MAAMA,kBAAI,aAAa,UAAU;;AAGzC,eAAsB,cACrB,aACA,SACgD;AAChD,QAAO,MAAMA,kBAAI,aAAa,yBAAyB,QAAW,QAAQ;;AAG3E,eAAsB,eACrB,aACA,OACA,SACmD;AACnD,QAAO,MAAMA,kBACZ,aACA,0BACA;EAAE,UAAU,MAAM;EAAY,QAAQ,MAAM;EAAQ,EACpD,QACA;;AAGF,eAAsB,aACrB,aACA,OAUA,SAKE;CACF,MAAM,EAAE,MAAM,MAAM,aAAa,YAAY,OAAO,GAAG,cAAc;AAUrE,QAAO,MAAMA,kBAAI,aAAa,qBATX;EAClB,GAAG;EACH,UAAU,eAAe,WAAW;EACpC,GAAI,QAAQ,EAAE,MAAM,eAAe,KAAK,EAAE;EAC1C,GAAI,SAAS,EAAE,OAAO,eAAe,MAAM,EAAE;EAC7C,GAAI,QAAQ,EAAE,MAAM;EACpB,GAAI,eAAe,EAAE,aAAa;EAClC,EAE8D,QAAQ;;AAGxE,eAAsB,kBACrB,aACA,cACA,SACwD;AACxD,QAAO,MAAMA,kBAAI,aAAa,0BAA0B,gBAAgB,QAAW,QAAQ;;AAG5F,eAAsB,gBACrB,aACA,YACA,SACoD;AACpD,QAAO,MAAMA,kBAAI,aAAa,wBAAwB,cAAc,QAAW,QAAQ;;AAGxF,eAAsB,oBACrB,aACA,YACA,SAC6B;AAC7B,QAAO,MAAMA,kBAAI,aAAa,wBAAwB,cAAc,QAAW,QAAQ"}
1
+ {"version":3,"file":"templates.cjs","names":["get"],"sources":["../src/api/templates.ts"],"sourcesContent":["import type { RawAxiosRequestHeaders } from 'axios';\nimport type { INode, INodeCredentialsDetails } from 'n8n-workflow';\n\nimport type { VersionNode } from './versions';\nimport type { WorkflowData } from './workflows';\nimport { get } from '../utils';\n\nexport interface IWorkflowTemplateNode\n\textends Pick<\n\t\tINode,\n\t\t'name' | 'type' | 'position' | 'parameters' | 'typeVersion' | 'webhookId' | 'id' | 'disabled'\n\t> {\n\t// The credentials in a template workflow have a different type than in a regular workflow\n\tcredentials?: IWorkflowTemplateNodeCredentials;\n}\n\nexport interface IWorkflowTemplateNodeCredentials {\n\t[key: string]: string | INodeCredentialsDetails;\n}\n\nexport interface IWorkflowTemplate {\n\tid: number;\n\tname: string;\n\tworkflow: Pick<WorkflowData, 'connections' | 'settings' | 'pinData'> & {\n\t\tnodes: IWorkflowTemplateNode[];\n\t};\n}\n\nexport interface ITemplatesNode extends VersionNode {\n\tid: number;\n\tcategories?: ITemplatesCategory[];\n}\n\nexport interface ITemplatesCollection {\n\tid: number;\n\tname: string;\n\tnodes: ITemplatesNode[];\n\tworkflows: Array<{ id: number }>;\n}\n\ninterface ITemplatesImage {\n\tid: number;\n\turl: string;\n}\n\ninterface ITemplatesCollectionExtended extends ITemplatesCollection {\n\tdescription: string | null;\n\timage: ITemplatesImage[];\n\tcategories: ITemplatesCategory[];\n\tcreatedAt: string;\n}\n\nexport interface ITemplatesCollectionFull extends ITemplatesCollectionExtended {\n\tfull: true;\n}\n\nexport interface ITemplatesCollectionResponse extends ITemplatesCollectionExtended {\n\tworkflows: ITemplatesWorkflow[];\n}\n\n/**\n * A template without the actual workflow definition\n */\n\nexport interface ITemplatesWorkflow {\n\tid: number;\n\tcreatedAt: string;\n\tname: string;\n\tnodes: ITemplatesNode[];\n\ttotalViews: number;\n\tuser: {\n\t\tusername: string;\n\t\tname: string;\n\t\tavatar: string;\n\t\tverified: boolean;\n\t};\n}\n\nexport interface ITemplatesWorkflowInfo {\n\tnodeCount: number;\n\tnodeTypes: {\n\t\t[key: string]: {\n\t\t\tcount: number;\n\t\t};\n\t};\n}\n\nexport type TemplateSearchFacet = {\n\tfield_name: string;\n\tsampled: boolean;\n\tstats: {\n\t\ttotal_values: number;\n\t};\n\tcounts: Array<{\n\t\tcount: number;\n\t\thighlighted: string;\n\t\tvalue: string;\n\t}>;\n};\n\nexport interface ITemplatesWorkflowResponse extends ITemplatesWorkflow, IWorkflowTemplate {\n\tdescription: string | null;\n\timage: ITemplatesImage[];\n\tcategories: ITemplatesCategory[];\n\tworkflowInfo: ITemplatesWorkflowInfo;\n}\n\n/**\n * A template with also the full workflow definition\n */\n\nexport interface ITemplatesWorkflowFull extends ITemplatesWorkflowResponse {\n\tfull: true;\n}\n\nexport interface ITemplatesQuery {\n\tcategories: string[];\n\tsearch: string;\n\tapps?: string[];\n\tnodes?: string[];\n\tsort?: string;\n\tcombineWith?: string;\n}\n\nexport interface ITemplatesCategory {\n\tid: number;\n\tname: string;\n}\n\nfunction stringifyArray(arr: string[]) {\n\treturn arr.join(',');\n}\n\nexport async function testHealthEndpoint(apiEndpoint: string) {\n\treturn await get(apiEndpoint, '/health');\n}\n\nexport async function getCategories(\n\tapiEndpoint: string,\n\theaders?: RawAxiosRequestHeaders,\n): Promise<{ categories: ITemplatesCategory[] }> {\n\treturn await get(apiEndpoint, '/templates/categories', undefined, headers);\n}\n\nexport async function getCollections(\n\tapiEndpoint: string,\n\tquery: ITemplatesQuery,\n\theaders?: RawAxiosRequestHeaders,\n): Promise<{ collections: ITemplatesCollection[] }> {\n\treturn await get(\n\t\tapiEndpoint,\n\t\t'/templates/collections',\n\t\t{ category: query.categories, search: query.search },\n\t\theaders,\n\t);\n}\n\nexport async function getWorkflows(\n\tapiEndpoint: string,\n\tquery: {\n\t\tpage: number;\n\t\tlimit: number;\n\t\tcategories: string[];\n\t\tsearch: string;\n\t\tsort?: string;\n\t\tapps?: string[];\n\t\tnodes?: string[];\n\t\tcombineWith?: string;\n\t},\n\theaders?: RawAxiosRequestHeaders,\n): Promise<{\n\ttotalWorkflows: number;\n\tworkflows: ITemplatesWorkflow[];\n\tfilters: TemplateSearchFacet[];\n}> {\n\tconst { apps, sort, combineWith, categories, nodes, ...restQuery } = query;\n\tconst finalQuery = {\n\t\t...restQuery,\n\t\tcategory: stringifyArray(categories),\n\t\t...(apps && { apps: stringifyArray(apps) }),\n\t\t...(nodes && { nodes: stringifyArray(nodes) }),\n\t\t...(sort && { sort }),\n\t\t...(combineWith && { combineWith }),\n\t};\n\n\treturn await get(apiEndpoint, '/templates/search', finalQuery, headers);\n}\n\nexport async function getCollectionById(\n\tapiEndpoint: string,\n\tcollectionId: string,\n\theaders?: RawAxiosRequestHeaders,\n): Promise<{ collection: ITemplatesCollectionResponse }> {\n\treturn await get(apiEndpoint, `/templates/collections/${collectionId}`, undefined, headers);\n}\n\nexport async function getTemplateById(\n\tapiEndpoint: string,\n\ttemplateId: string,\n\theaders?: RawAxiosRequestHeaders,\n): Promise<{ workflow: ITemplatesWorkflowResponse }> {\n\treturn await get(apiEndpoint, `/templates/workflows/${templateId}`, undefined, headers);\n}\n\nexport async function getWorkflowTemplate(\n\tapiEndpoint: string,\n\ttemplateId: string,\n\theaders?: RawAxiosRequestHeaders,\n): Promise<IWorkflowTemplate> {\n\treturn await get(apiEndpoint, `/workflows/templates/${templateId}`, undefined, headers);\n}\n"],"mappings":";;;AAiIA,SAAS,eAAe,KAAe;AACtC,QAAO,IAAI,KAAK,IAAI;;AAGrB,eAAsB,mBAAmB,aAAqB;AAC7D,QAAO,MAAMA,kBAAI,aAAa,UAAU;;AAGzC,eAAsB,cACrB,aACA,SACgD;AAChD,QAAO,MAAMA,kBAAI,aAAa,yBAAyB,QAAW,QAAQ;;AAG3E,eAAsB,eACrB,aACA,OACA,SACmD;AACnD,QAAO,MAAMA,kBACZ,aACA,0BACA;EAAE,UAAU,MAAM;EAAY,QAAQ,MAAM;EAAQ,EACpD,QACA;;AAGF,eAAsB,aACrB,aACA,OAUA,SAKE;CACF,MAAM,EAAE,MAAM,MAAM,aAAa,YAAY,OAAO,GAAG,cAAc;AAUrE,QAAO,MAAMA,kBAAI,aAAa,qBATX;EAClB,GAAG;EACH,UAAU,eAAe,WAAW;EACpC,GAAI,QAAQ,EAAE,MAAM,eAAe,KAAK,EAAE;EAC1C,GAAI,SAAS,EAAE,OAAO,eAAe,MAAM,EAAE;EAC7C,GAAI,QAAQ,EAAE,MAAM;EACpB,GAAI,eAAe,EAAE,aAAa;EAClC,EAE8D,QAAQ;;AAGxE,eAAsB,kBACrB,aACA,cACA,SACwD;AACxD,QAAO,MAAMA,kBAAI,aAAa,0BAA0B,gBAAgB,QAAW,QAAQ;;AAG5F,eAAsB,gBACrB,aACA,YACA,SACoD;AACpD,QAAO,MAAMA,kBAAI,aAAa,wBAAwB,cAAc,QAAW,QAAQ;;AAGxF,eAAsB,oBACrB,aACA,YACA,SAC6B;AAC7B,QAAO,MAAMA,kBAAI,aAAa,wBAAwB,cAAc,QAAW,QAAQ"}
@@ -53,6 +53,9 @@ interface ITemplatesWorkflow {
53
53
  totalViews: number;
54
54
  user: {
55
55
  username: string;
56
+ name: string;
57
+ avatar: string;
58
+ verified: boolean;
56
59
  };
57
60
  }
58
61
  interface ITemplatesWorkflowInfo {
@@ -53,6 +53,9 @@ interface ITemplatesWorkflow {
53
53
  totalViews: number;
54
54
  user: {
55
55
  username: string;
56
+ name: string;
57
+ avatar: string;
58
+ verified: boolean;
56
59
  };
57
60
  }
58
61
  interface ITemplatesWorkflowInfo {
@@ -1 +1 @@
1
- {"version":3,"file":"templates.mjs","names":[],"sources":["../src/api/templates.ts"],"sourcesContent":["import type { RawAxiosRequestHeaders } from 'axios';\nimport type { INode, INodeCredentialsDetails } from 'n8n-workflow';\n\nimport type { VersionNode } from './versions';\nimport type { WorkflowData } from './workflows';\nimport { get } from '../utils';\n\nexport interface IWorkflowTemplateNode\n\textends Pick<\n\t\tINode,\n\t\t'name' | 'type' | 'position' | 'parameters' | 'typeVersion' | 'webhookId' | 'id' | 'disabled'\n\t> {\n\t// The credentials in a template workflow have a different type than in a regular workflow\n\tcredentials?: IWorkflowTemplateNodeCredentials;\n}\n\nexport interface IWorkflowTemplateNodeCredentials {\n\t[key: string]: string | INodeCredentialsDetails;\n}\n\nexport interface IWorkflowTemplate {\n\tid: number;\n\tname: string;\n\tworkflow: Pick<WorkflowData, 'connections' | 'settings' | 'pinData'> & {\n\t\tnodes: IWorkflowTemplateNode[];\n\t};\n}\n\nexport interface ITemplatesNode extends VersionNode {\n\tid: number;\n\tcategories?: ITemplatesCategory[];\n}\n\nexport interface ITemplatesCollection {\n\tid: number;\n\tname: string;\n\tnodes: ITemplatesNode[];\n\tworkflows: Array<{ id: number }>;\n}\n\ninterface ITemplatesImage {\n\tid: number;\n\turl: string;\n}\n\ninterface ITemplatesCollectionExtended extends ITemplatesCollection {\n\tdescription: string | null;\n\timage: ITemplatesImage[];\n\tcategories: ITemplatesCategory[];\n\tcreatedAt: string;\n}\n\nexport interface ITemplatesCollectionFull extends ITemplatesCollectionExtended {\n\tfull: true;\n}\n\nexport interface ITemplatesCollectionResponse extends ITemplatesCollectionExtended {\n\tworkflows: ITemplatesWorkflow[];\n}\n\n/**\n * A template without the actual workflow definition\n */\n\nexport interface ITemplatesWorkflow {\n\tid: number;\n\tcreatedAt: string;\n\tname: string;\n\tnodes: ITemplatesNode[];\n\ttotalViews: number;\n\tuser: {\n\t\tusername: string;\n\t};\n}\n\nexport interface ITemplatesWorkflowInfo {\n\tnodeCount: number;\n\tnodeTypes: {\n\t\t[key: string]: {\n\t\t\tcount: number;\n\t\t};\n\t};\n}\n\nexport type TemplateSearchFacet = {\n\tfield_name: string;\n\tsampled: boolean;\n\tstats: {\n\t\ttotal_values: number;\n\t};\n\tcounts: Array<{\n\t\tcount: number;\n\t\thighlighted: string;\n\t\tvalue: string;\n\t}>;\n};\n\nexport interface ITemplatesWorkflowResponse extends ITemplatesWorkflow, IWorkflowTemplate {\n\tdescription: string | null;\n\timage: ITemplatesImage[];\n\tcategories: ITemplatesCategory[];\n\tworkflowInfo: ITemplatesWorkflowInfo;\n}\n\n/**\n * A template with also the full workflow definition\n */\n\nexport interface ITemplatesWorkflowFull extends ITemplatesWorkflowResponse {\n\tfull: true;\n}\n\nexport interface ITemplatesQuery {\n\tcategories: string[];\n\tsearch: string;\n\tapps?: string[];\n\tnodes?: string[];\n\tsort?: string;\n\tcombineWith?: string;\n}\n\nexport interface ITemplatesCategory {\n\tid: number;\n\tname: string;\n}\n\nfunction stringifyArray(arr: string[]) {\n\treturn arr.join(',');\n}\n\nexport async function testHealthEndpoint(apiEndpoint: string) {\n\treturn await get(apiEndpoint, '/health');\n}\n\nexport async function getCategories(\n\tapiEndpoint: string,\n\theaders?: RawAxiosRequestHeaders,\n): Promise<{ categories: ITemplatesCategory[] }> {\n\treturn await get(apiEndpoint, '/templates/categories', undefined, headers);\n}\n\nexport async function getCollections(\n\tapiEndpoint: string,\n\tquery: ITemplatesQuery,\n\theaders?: RawAxiosRequestHeaders,\n): Promise<{ collections: ITemplatesCollection[] }> {\n\treturn await get(\n\t\tapiEndpoint,\n\t\t'/templates/collections',\n\t\t{ category: query.categories, search: query.search },\n\t\theaders,\n\t);\n}\n\nexport async function getWorkflows(\n\tapiEndpoint: string,\n\tquery: {\n\t\tpage: number;\n\t\tlimit: number;\n\t\tcategories: string[];\n\t\tsearch: string;\n\t\tsort?: string;\n\t\tapps?: string[];\n\t\tnodes?: string[];\n\t\tcombineWith?: string;\n\t},\n\theaders?: RawAxiosRequestHeaders,\n): Promise<{\n\ttotalWorkflows: number;\n\tworkflows: ITemplatesWorkflow[];\n\tfilters: TemplateSearchFacet[];\n}> {\n\tconst { apps, sort, combineWith, categories, nodes, ...restQuery } = query;\n\tconst finalQuery = {\n\t\t...restQuery,\n\t\tcategory: stringifyArray(categories),\n\t\t...(apps && { apps: stringifyArray(apps) }),\n\t\t...(nodes && { nodes: stringifyArray(nodes) }),\n\t\t...(sort && { sort }),\n\t\t...(combineWith && { combineWith }),\n\t};\n\n\treturn await get(apiEndpoint, '/templates/search', finalQuery, headers);\n}\n\nexport async function getCollectionById(\n\tapiEndpoint: string,\n\tcollectionId: string,\n\theaders?: RawAxiosRequestHeaders,\n): Promise<{ collection: ITemplatesCollectionResponse }> {\n\treturn await get(apiEndpoint, `/templates/collections/${collectionId}`, undefined, headers);\n}\n\nexport async function getTemplateById(\n\tapiEndpoint: string,\n\ttemplateId: string,\n\theaders?: RawAxiosRequestHeaders,\n): Promise<{ workflow: ITemplatesWorkflowResponse }> {\n\treturn await get(apiEndpoint, `/templates/workflows/${templateId}`, undefined, headers);\n}\n\nexport async function getWorkflowTemplate(\n\tapiEndpoint: string,\n\ttemplateId: string,\n\theaders?: RawAxiosRequestHeaders,\n): Promise<IWorkflowTemplate> {\n\treturn await get(apiEndpoint, `/workflows/templates/${templateId}`, undefined, headers);\n}\n"],"mappings":";;;AA8HA,SAAS,eAAe,KAAe;AACtC,QAAO,IAAI,KAAK,IAAI;;AAGrB,eAAsB,mBAAmB,aAAqB;AAC7D,QAAO,MAAM,IAAI,aAAa,UAAU;;AAGzC,eAAsB,cACrB,aACA,SACgD;AAChD,QAAO,MAAM,IAAI,aAAa,yBAAyB,QAAW,QAAQ;;AAG3E,eAAsB,eACrB,aACA,OACA,SACmD;AACnD,QAAO,MAAM,IACZ,aACA,0BACA;EAAE,UAAU,MAAM;EAAY,QAAQ,MAAM;EAAQ,EACpD,QACA;;AAGF,eAAsB,aACrB,aACA,OAUA,SAKE;CACF,MAAM,EAAE,MAAM,MAAM,aAAa,YAAY,OAAO,GAAG,cAAc;AAUrE,QAAO,MAAM,IAAI,aAAa,qBATX;EAClB,GAAG;EACH,UAAU,eAAe,WAAW;EACpC,GAAI,QAAQ,EAAE,MAAM,eAAe,KAAK,EAAE;EAC1C,GAAI,SAAS,EAAE,OAAO,eAAe,MAAM,EAAE;EAC7C,GAAI,QAAQ,EAAE,MAAM;EACpB,GAAI,eAAe,EAAE,aAAa;EAClC,EAE8D,QAAQ;;AAGxE,eAAsB,kBACrB,aACA,cACA,SACwD;AACxD,QAAO,MAAM,IAAI,aAAa,0BAA0B,gBAAgB,QAAW,QAAQ;;AAG5F,eAAsB,gBACrB,aACA,YACA,SACoD;AACpD,QAAO,MAAM,IAAI,aAAa,wBAAwB,cAAc,QAAW,QAAQ;;AAGxF,eAAsB,oBACrB,aACA,YACA,SAC6B;AAC7B,QAAO,MAAM,IAAI,aAAa,wBAAwB,cAAc,QAAW,QAAQ"}
1
+ {"version":3,"file":"templates.mjs","names":[],"sources":["../src/api/templates.ts"],"sourcesContent":["import type { RawAxiosRequestHeaders } from 'axios';\nimport type { INode, INodeCredentialsDetails } from 'n8n-workflow';\n\nimport type { VersionNode } from './versions';\nimport type { WorkflowData } from './workflows';\nimport { get } from '../utils';\n\nexport interface IWorkflowTemplateNode\n\textends Pick<\n\t\tINode,\n\t\t'name' | 'type' | 'position' | 'parameters' | 'typeVersion' | 'webhookId' | 'id' | 'disabled'\n\t> {\n\t// The credentials in a template workflow have a different type than in a regular workflow\n\tcredentials?: IWorkflowTemplateNodeCredentials;\n}\n\nexport interface IWorkflowTemplateNodeCredentials {\n\t[key: string]: string | INodeCredentialsDetails;\n}\n\nexport interface IWorkflowTemplate {\n\tid: number;\n\tname: string;\n\tworkflow: Pick<WorkflowData, 'connections' | 'settings' | 'pinData'> & {\n\t\tnodes: IWorkflowTemplateNode[];\n\t};\n}\n\nexport interface ITemplatesNode extends VersionNode {\n\tid: number;\n\tcategories?: ITemplatesCategory[];\n}\n\nexport interface ITemplatesCollection {\n\tid: number;\n\tname: string;\n\tnodes: ITemplatesNode[];\n\tworkflows: Array<{ id: number }>;\n}\n\ninterface ITemplatesImage {\n\tid: number;\n\turl: string;\n}\n\ninterface ITemplatesCollectionExtended extends ITemplatesCollection {\n\tdescription: string | null;\n\timage: ITemplatesImage[];\n\tcategories: ITemplatesCategory[];\n\tcreatedAt: string;\n}\n\nexport interface ITemplatesCollectionFull extends ITemplatesCollectionExtended {\n\tfull: true;\n}\n\nexport interface ITemplatesCollectionResponse extends ITemplatesCollectionExtended {\n\tworkflows: ITemplatesWorkflow[];\n}\n\n/**\n * A template without the actual workflow definition\n */\n\nexport interface ITemplatesWorkflow {\n\tid: number;\n\tcreatedAt: string;\n\tname: string;\n\tnodes: ITemplatesNode[];\n\ttotalViews: number;\n\tuser: {\n\t\tusername: string;\n\t\tname: string;\n\t\tavatar: string;\n\t\tverified: boolean;\n\t};\n}\n\nexport interface ITemplatesWorkflowInfo {\n\tnodeCount: number;\n\tnodeTypes: {\n\t\t[key: string]: {\n\t\t\tcount: number;\n\t\t};\n\t};\n}\n\nexport type TemplateSearchFacet = {\n\tfield_name: string;\n\tsampled: boolean;\n\tstats: {\n\t\ttotal_values: number;\n\t};\n\tcounts: Array<{\n\t\tcount: number;\n\t\thighlighted: string;\n\t\tvalue: string;\n\t}>;\n};\n\nexport interface ITemplatesWorkflowResponse extends ITemplatesWorkflow, IWorkflowTemplate {\n\tdescription: string | null;\n\timage: ITemplatesImage[];\n\tcategories: ITemplatesCategory[];\n\tworkflowInfo: ITemplatesWorkflowInfo;\n}\n\n/**\n * A template with also the full workflow definition\n */\n\nexport interface ITemplatesWorkflowFull extends ITemplatesWorkflowResponse {\n\tfull: true;\n}\n\nexport interface ITemplatesQuery {\n\tcategories: string[];\n\tsearch: string;\n\tapps?: string[];\n\tnodes?: string[];\n\tsort?: string;\n\tcombineWith?: string;\n}\n\nexport interface ITemplatesCategory {\n\tid: number;\n\tname: string;\n}\n\nfunction stringifyArray(arr: string[]) {\n\treturn arr.join(',');\n}\n\nexport async function testHealthEndpoint(apiEndpoint: string) {\n\treturn await get(apiEndpoint, '/health');\n}\n\nexport async function getCategories(\n\tapiEndpoint: string,\n\theaders?: RawAxiosRequestHeaders,\n): Promise<{ categories: ITemplatesCategory[] }> {\n\treturn await get(apiEndpoint, '/templates/categories', undefined, headers);\n}\n\nexport async function getCollections(\n\tapiEndpoint: string,\n\tquery: ITemplatesQuery,\n\theaders?: RawAxiosRequestHeaders,\n): Promise<{ collections: ITemplatesCollection[] }> {\n\treturn await get(\n\t\tapiEndpoint,\n\t\t'/templates/collections',\n\t\t{ category: query.categories, search: query.search },\n\t\theaders,\n\t);\n}\n\nexport async function getWorkflows(\n\tapiEndpoint: string,\n\tquery: {\n\t\tpage: number;\n\t\tlimit: number;\n\t\tcategories: string[];\n\t\tsearch: string;\n\t\tsort?: string;\n\t\tapps?: string[];\n\t\tnodes?: string[];\n\t\tcombineWith?: string;\n\t},\n\theaders?: RawAxiosRequestHeaders,\n): Promise<{\n\ttotalWorkflows: number;\n\tworkflows: ITemplatesWorkflow[];\n\tfilters: TemplateSearchFacet[];\n}> {\n\tconst { apps, sort, combineWith, categories, nodes, ...restQuery } = query;\n\tconst finalQuery = {\n\t\t...restQuery,\n\t\tcategory: stringifyArray(categories),\n\t\t...(apps && { apps: stringifyArray(apps) }),\n\t\t...(nodes && { nodes: stringifyArray(nodes) }),\n\t\t...(sort && { sort }),\n\t\t...(combineWith && { combineWith }),\n\t};\n\n\treturn await get(apiEndpoint, '/templates/search', finalQuery, headers);\n}\n\nexport async function getCollectionById(\n\tapiEndpoint: string,\n\tcollectionId: string,\n\theaders?: RawAxiosRequestHeaders,\n): Promise<{ collection: ITemplatesCollectionResponse }> {\n\treturn await get(apiEndpoint, `/templates/collections/${collectionId}`, undefined, headers);\n}\n\nexport async function getTemplateById(\n\tapiEndpoint: string,\n\ttemplateId: string,\n\theaders?: RawAxiosRequestHeaders,\n): Promise<{ workflow: ITemplatesWorkflowResponse }> {\n\treturn await get(apiEndpoint, `/templates/workflows/${templateId}`, undefined, headers);\n}\n\nexport async function getWorkflowTemplate(\n\tapiEndpoint: string,\n\ttemplateId: string,\n\theaders?: RawAxiosRequestHeaders,\n): Promise<IWorkflowTemplate> {\n\treturn await get(apiEndpoint, `/workflows/templates/${templateId}`, undefined, headers);\n}\n"],"mappings":";;;AAiIA,SAAS,eAAe,KAAe;AACtC,QAAO,IAAI,KAAK,IAAI;;AAGrB,eAAsB,mBAAmB,aAAqB;AAC7D,QAAO,MAAM,IAAI,aAAa,UAAU;;AAGzC,eAAsB,cACrB,aACA,SACgD;AAChD,QAAO,MAAM,IAAI,aAAa,yBAAyB,QAAW,QAAQ;;AAG3E,eAAsB,eACrB,aACA,OACA,SACmD;AACnD,QAAO,MAAM,IACZ,aACA,0BACA;EAAE,UAAU,MAAM;EAAY,QAAQ,MAAM;EAAQ,EACpD,QACA;;AAGF,eAAsB,aACrB,aACA,OAUA,SAKE;CACF,MAAM,EAAE,MAAM,MAAM,aAAa,YAAY,OAAO,GAAG,cAAc;AAUrE,QAAO,MAAM,IAAI,aAAa,qBATX;EAClB,GAAG;EACH,UAAU,eAAe,WAAW;EACpC,GAAI,QAAQ,EAAE,MAAM,eAAe,KAAK,EAAE;EAC1C,GAAI,SAAS,EAAE,OAAO,eAAe,MAAM,EAAE;EAC7C,GAAI,QAAQ,EAAE,MAAM;EACpB,GAAI,eAAe,EAAE,aAAa;EAClC,EAE8D,QAAQ;;AAGxE,eAAsB,kBACrB,aACA,cACA,SACwD;AACxD,QAAO,MAAM,IAAI,aAAa,0BAA0B,gBAAgB,QAAW,QAAQ;;AAG5F,eAAsB,gBACrB,aACA,YACA,SACoD;AACpD,QAAO,MAAM,IAAI,aAAa,wBAAwB,cAAc,QAAW,QAAQ;;AAGxF,eAAsB,oBACrB,aACA,YACA,SAC6B;AAC7B,QAAO,MAAM,IAAI,aAAa,wBAAwB,cAAc,QAAW,QAAQ"}
package/dist/utils2.cjs CHANGED
@@ -49,6 +49,7 @@ var ResponseError = class extends n8n_workflow.ApplicationError {
49
49
  errorCode;
50
50
  serverStackTrace;
51
51
  meta;
52
+ hint;
52
53
  /**
53
54
  * Creates an instance of ResponseError.
54
55
  * @param {string} message The error message
@@ -56,15 +57,17 @@ var ResponseError = class extends n8n_workflow.ApplicationError {
56
57
  * @param {number} [httpStatusCode] The HTTP status code the response should have
57
58
  * @param {string} [stack] The stack trace
58
59
  * @param {Record<string, unknown>} [meta] Additional metadata from the server
60
+ * @param {string} [hint] Additional hint from the server
59
61
  */
60
62
  constructor(message, options = {}) {
61
63
  super(message);
62
64
  this.name = "ResponseError";
63
- const { errorCode, httpStatusCode, stack, meta } = options;
65
+ const { errorCode, httpStatusCode, stack, meta, hint } = options;
64
66
  if (errorCode) this.errorCode = errorCode;
65
67
  if (httpStatusCode) this.httpStatusCode = httpStatusCode;
66
68
  if (stack) this.serverStackTrace = stack;
67
69
  if (meta) this.meta = meta;
70
+ if (hint) this.hint = hint;
68
71
  }
69
72
  };
70
73
  const legacyParamSerializer = (params) => Object.keys(params).filter((key) => params[key] !== void 0).map((key) => {
@@ -106,7 +109,8 @@ async function request(config) {
106
109
  errorCode: errorResponseData.code,
107
110
  httpStatusCode: error.response.status,
108
111
  stack: errorResponseData.stack,
109
- meta: errorResponseData.meta
112
+ meta: errorResponseData.meta,
113
+ hint: errorResponseData.hint
110
114
  });
111
115
  }
112
116
  throw error;
@@ -1 +1 @@
1
- {"version":3,"file":"utils2.cjs","names":["BROWSER_ID_STORAGE_KEY","ApplicationError","options: AxiosRequestConfig","onErrorOnce: ((e: Error) => void) | undefined","assistantRequest: RequestInit","data: T","e: unknown"],"sources":["../src/utils.ts"],"sourcesContent":["import { BROWSER_ID_STORAGE_KEY } from '@n8n/constants';\nimport { assert } from '@n8n/utils/assert';\nimport type { AxiosRequestConfig, Method, RawAxiosRequestHeaders } from 'axios';\nimport axios from 'axios';\nimport { ApplicationError, jsonParse } from 'n8n-workflow';\nimport type { GenericValue, IDataObject } from 'n8n-workflow';\n\nimport type { IRestApiContext } from './types';\n\nconst getBrowserId = () => {\n\tlet browserId = localStorage.getItem(BROWSER_ID_STORAGE_KEY);\n\tif (!browserId) {\n\t\tbrowserId = crypto.randomUUID();\n\t\tlocalStorage.setItem(BROWSER_ID_STORAGE_KEY, browserId);\n\t}\n\treturn browserId;\n};\n\nexport const NO_NETWORK_ERROR_CODE = 999;\nexport const STREAM_SEPARATOR = '⧉⇋⇋➽⌑⧉§§\\n';\n\nexport class MfaRequiredError extends ApplicationError {\n\tconstructor() {\n\t\tsuper('MFA is required to access this resource. Please set up MFA in your user settings.');\n\t\tthis.name = 'MfaRequiredError';\n\t}\n}\n\nexport class ResponseError extends ApplicationError {\n\t// The HTTP status code of response\n\thttpStatusCode?: number;\n\n\t// The error code in the response\n\terrorCode?: number;\n\n\t// The stack trace of the server\n\tserverStackTrace?: string;\n\n\t// Additional metadata from the server (e.g., EULA URL)\n\tmeta?: Record<string, unknown>;\n\n\t/**\n\t * Creates an instance of ResponseError.\n\t * @param {string} message The error message\n\t * @param {number} [errorCode] The error code which can be used by frontend to identify the actual error\n\t * @param {number} [httpStatusCode] The HTTP status code the response should have\n\t * @param {string} [stack] The stack trace\n\t * @param {Record<string, unknown>} [meta] Additional metadata from the server\n\t */\n\tconstructor(\n\t\tmessage: string,\n\t\toptions: {\n\t\t\terrorCode?: number;\n\t\t\thttpStatusCode?: number;\n\t\t\tstack?: string;\n\t\t\tmeta?: Record<string, unknown>;\n\t\t} = {},\n\t) {\n\t\tsuper(message);\n\t\tthis.name = 'ResponseError';\n\n\t\tconst { errorCode, httpStatusCode, stack, meta } = options;\n\t\tif (errorCode) {\n\t\t\tthis.errorCode = errorCode;\n\t\t}\n\t\tif (httpStatusCode) {\n\t\t\tthis.httpStatusCode = httpStatusCode;\n\t\t}\n\t\tif (stack) {\n\t\t\tthis.serverStackTrace = stack;\n\t\t}\n\t\tif (meta) {\n\t\t\tthis.meta = meta;\n\t\t}\n\t}\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst legacyParamSerializer = (params: Record<string, any>) =>\n\tObject.keys(params)\n\t\t.filter((key) => params[key] !== undefined)\n\t\t.map((key) => {\n\t\t\tif (Array.isArray(params[key])) {\n\t\t\t\treturn params[key].map((v: string) => `${key}[]=${encodeURIComponent(v)}`).join('&');\n\t\t\t}\n\t\t\tif (typeof params[key] === 'object') {\n\t\t\t\tparams[key] = JSON.stringify(params[key]);\n\t\t\t}\n\t\t\treturn `${key}=${encodeURIComponent(params[key])}`;\n\t\t})\n\t\t.join('&');\n\nexport async function request(config: {\n\tmethod: Method;\n\tbaseURL: string;\n\tendpoint: string;\n\theaders?: RawAxiosRequestHeaders;\n\tdata?: GenericValue | GenericValue[];\n\twithCredentials?: boolean;\n}) {\n\tconst { method, baseURL, endpoint, headers, data } = config;\n\tconst options: AxiosRequestConfig = {\n\t\tmethod,\n\t\turl: endpoint,\n\t\tbaseURL,\n\t\theaders: headers ?? {},\n\t};\n\tif (baseURL.startsWith('/')) {\n\t\toptions.headers!['browser-id'] = getBrowserId();\n\t}\n\tif (\n\t\timport.meta.env.NODE_ENV !== 'production' &&\n\t\t!baseURL.includes('api.n8n.io') &&\n\t\t!baseURL.includes('n8n.cloud')\n\t) {\n\t\toptions.withCredentials = options.withCredentials ?? true;\n\t}\n\tif (['POST', 'PATCH', 'PUT'].includes(method)) {\n\t\toptions.data = data;\n\t} else if (data) {\n\t\toptions.params = data;\n\t\toptions.paramsSerializer = legacyParamSerializer;\n\t}\n\n\ttry {\n\t\tconst response = await axios.request(options);\n\t\treturn response.data;\n\t} catch (error) {\n\t\tif (error.message === 'Network Error') {\n\t\t\tthrow new ResponseError(\"Can't connect to n8n.\", {\n\t\t\t\terrorCode: NO_NETWORK_ERROR_CODE,\n\t\t\t});\n\t\t}\n\n\t\tconst errorResponseData = error.response?.data;\n\t\tif (errorResponseData?.mfaRequired === true) {\n\t\t\tthrow new MfaRequiredError();\n\t\t}\n\t\tif (errorResponseData?.message !== undefined) {\n\t\t\tif (errorResponseData.name === 'NodeApiError') {\n\t\t\t\terrorResponseData.httpStatusCode = error.response.status;\n\t\t\t\tthrow errorResponseData;\n\t\t\t}\n\n\t\t\tthrow new ResponseError(errorResponseData.message, {\n\t\t\t\terrorCode: errorResponseData.code,\n\t\t\t\thttpStatusCode: error.response.status,\n\t\t\t\tstack: errorResponseData.stack,\n\t\t\t\tmeta: errorResponseData.meta,\n\t\t\t});\n\t\t}\n\n\t\tthrow error;\n\t}\n}\n\n/**\n * Sends a request to the API and returns the response without extracting the data key.\n * @param context Rest API context\n * @param method HTTP method\n * @param endpoint relative path to the API endpoint\n * @param data request data\n * @returns data and total count\n */\nexport async function getFullApiResponse<T>(\n\tcontext: IRestApiContext,\n\tmethod: Method,\n\tendpoint: string,\n\tdata?: GenericValue | GenericValue[],\n) {\n\tconst response = await request({\n\t\tmethod,\n\t\tbaseURL: context.baseUrl,\n\t\tendpoint,\n\t\theaders: { 'push-ref': context.pushRef },\n\t\tdata,\n\t});\n\n\treturn response as { count: number; data: T };\n}\n\nexport async function makeRestApiRequest<T>(\n\tcontext: IRestApiContext,\n\tmethod: Method,\n\tendpoint: string,\n\tdata?: GenericValue | GenericValue[],\n) {\n\tconst response = await request({\n\t\tmethod,\n\t\tbaseURL: context.baseUrl,\n\t\tendpoint,\n\t\theaders: { 'push-ref': context.pushRef },\n\t\tdata,\n\t});\n\n\t// All cli rest api endpoints return data wrapped in `data` key\n\treturn response.data as T;\n}\n\nexport async function get(\n\tbaseURL: string,\n\tendpoint: string,\n\tparams?: IDataObject,\n\theaders?: RawAxiosRequestHeaders,\n) {\n\treturn await request({ method: 'GET', baseURL, endpoint, headers, data: params });\n}\n\nexport async function post(\n\tbaseURL: string,\n\tendpoint: string,\n\tparams?: IDataObject,\n\theaders?: RawAxiosRequestHeaders,\n) {\n\treturn await request({ method: 'POST', baseURL, endpoint, headers, data: params });\n}\n\nexport async function patch(\n\tbaseURL: string,\n\tendpoint: string,\n\tparams?: IDataObject,\n\theaders?: RawAxiosRequestHeaders,\n) {\n\treturn await request({ method: 'PATCH', baseURL, endpoint, headers, data: params });\n}\n\nexport async function streamRequest<T extends object>(\n\tcontext: IRestApiContext,\n\tapiEndpoint: string,\n\tpayload: object,\n\tonChunk?: (chunk: T) => void,\n\tonDone?: () => void,\n\tonError?: (e: Error) => void,\n\tseparator = STREAM_SEPARATOR,\n\tabortSignal?: AbortSignal,\n): Promise<void> {\n\tlet onErrorOnce: ((e: Error) => void) | undefined = (e: Error) => {\n\t\tonErrorOnce = undefined;\n\t\tonError?.(e);\n\t};\n\tconst headers: Record<string, string> = {\n\t\t'browser-id': getBrowserId(),\n\t\t'Content-Type': 'application/json',\n\t};\n\tconst assistantRequest: RequestInit = {\n\t\theaders,\n\t\tmethod: 'POST',\n\t\tcredentials: 'include',\n\t\tbody: JSON.stringify(payload),\n\t\tsignal: abortSignal,\n\t};\n\ttry {\n\t\tconst response = await fetch(`${context.baseUrl}${apiEndpoint}`, assistantRequest);\n\n\t\tif (response.body) {\n\t\t\t// Handle the streaming response\n\t\t\tconst reader = response.body.getReader();\n\t\t\tconst decoder = new TextDecoder('utf-8');\n\n\t\t\tlet buffer = '';\n\n\t\t\tasync function readStream() {\n\t\t\t\tconst { done, value } = await reader.read();\n\t\t\t\tif (done) {\n\t\t\t\t\tif (response.ok) {\n\t\t\t\t\t\tonDone?.();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tonErrorOnce?.(\n\t\t\t\t\t\t\tnew ResponseError(response.statusText, {\n\t\t\t\t\t\t\t\thttpStatusCode: response.status,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst chunk = decoder.decode(value);\n\t\t\t\tbuffer += chunk;\n\n\t\t\t\tconst splitChunks = buffer.split(separator);\n\n\t\t\t\tbuffer = '';\n\t\t\t\tfor (const splitChunk of splitChunks) {\n\t\t\t\t\tif (splitChunk) {\n\t\t\t\t\t\tlet data: T;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tdata = jsonParse<T>(splitChunk, { errorMessage: 'Invalid json' });\n\t\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\t\t// incomplete json. append to buffer to complete\n\t\t\t\t\t\t\tbuffer += splitChunk;\n\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tif (response.ok) {\n\t\t\t\t\t\t\t\t// Call chunk callback if request was successful\n\t\t\t\t\t\t\t\tonChunk?.(data);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// Otherwise, call error callback\n\t\t\t\t\t\t\t\tconst message = 'message' in data ? data.message : response.statusText;\n\t\t\t\t\t\t\t\tonErrorOnce?.(\n\t\t\t\t\t\t\t\t\tnew ResponseError(String(message), {\n\t\t\t\t\t\t\t\t\t\thttpStatusCode: response.status,\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} catch (e: unknown) {\n\t\t\t\t\t\t\tif (e instanceof Error) {\n\t\t\t\t\t\t\t\tonErrorOnce?.(e);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tawait readStream();\n\t\t\t}\n\n\t\t\t// Start reading the stream\n\t\t\tawait readStream();\n\t\t} else if (onErrorOnce) {\n\t\t\tonErrorOnce(new Error(response.statusText));\n\t\t}\n\t} catch (e: unknown) {\n\t\tassert(e instanceof Error);\n\t\tonErrorOnce?.(e);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,MAAM,qBAAqB;CAC1B,IAAI,YAAY,aAAa,QAAQA,uCAAuB;AAC5D,KAAI,CAAC,WAAW;AACf,cAAY,OAAO,YAAY;AAC/B,eAAa,QAAQA,wCAAwB,UAAU;;AAExD,QAAO;;AAGR,MAAa,wBAAwB;AACrC,MAAa,mBAAmB;AAEhC,IAAa,mBAAb,cAAsCC,8BAAiB;CACtD,cAAc;AACb,QAAM,oFAAoF;AAC1F,OAAK,OAAO;;;AAId,IAAa,gBAAb,cAAmCA,8BAAiB;CAEnD;CAGA;CAGA;CAGA;;;;;;;;;CAUA,YACC,SACA,UAKI,EAAE,EACL;AACD,QAAM,QAAQ;AACd,OAAK,OAAO;EAEZ,MAAM,EAAE,WAAW,gBAAgB,OAAO,SAAS;AACnD,MAAI,UACH,MAAK,YAAY;AAElB,MAAI,eACH,MAAK,iBAAiB;AAEvB,MAAI,MACH,MAAK,mBAAmB;AAEzB,MAAI,KACH,MAAK,OAAO;;;AAMf,MAAM,yBAAyB,WAC9B,OAAO,KAAK,OAAO,CACjB,QAAQ,QAAQ,OAAO,SAAS,OAAU,CAC1C,KAAK,QAAQ;AACb,KAAI,MAAM,QAAQ,OAAO,KAAK,CAC7B,QAAO,OAAO,KAAK,KAAK,MAAc,GAAG,IAAI,KAAK,mBAAmB,EAAE,GAAG,CAAC,KAAK,IAAI;AAErF,KAAI,OAAO,OAAO,SAAS,SAC1B,QAAO,OAAO,KAAK,UAAU,OAAO,KAAK;AAE1C,Q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,MAAM,UAAU;AAE3C,aAAS;AACT,SAAK,MAAM,cAAc,YACxB,KAAI,YAAY;KACf,IAAIC;AACJ,SAAI;AACH,yCAAoB,YAAY,EAAE,cAAc,gBAAgB,CAAC;cACzD,GAAG;AAEX,gBAAU;AAEV;;AAGD,SAAI;AACH,UAAI,SAAS,GAEZ,WAAU,KAAK;WACT;OAEN,MAAM,UAAU,aAAa,OAAO,KAAK,UAAU,SAAS;AAC5D,qBACC,IAAI,cAAc,OAAO,QAAQ,EAAE,EAClC,gBAAgB,SAAS,QACzB,CAAC,CACF;;cAEMC,GAAY;AACpB,UAAI,aAAa,MAChB,eAAc,EAAE;;;AAKpB,UAAM,YAAY;;AAInB,SAAM,YAAY;aACR,YACV,aAAY,IAAI,MAAM,SAAS,WAAW,CAAC;UAEpCA,GAAY;AACpB,iCAAO,aAAa,MAAM;AAC1B,gBAAc,EAAE"}
1
+ {"version":3,"file":"utils2.cjs","names":["BROWSER_ID_STORAGE_KEY","ApplicationError","options: AxiosRequestConfig","onErrorOnce: ((e: Error) => void) | undefined","assistantRequest: RequestInit","data: T","e: unknown"],"sources":["../src/utils.ts"],"sourcesContent":["import { BROWSER_ID_STORAGE_KEY } from '@n8n/constants';\nimport { assert } from '@n8n/utils/assert';\nimport type { AxiosRequestConfig, Method, RawAxiosRequestHeaders } from 'axios';\nimport axios from 'axios';\nimport { ApplicationError, jsonParse } from 'n8n-workflow';\nimport type { GenericValue, IDataObject } from 'n8n-workflow';\n\nimport type { IRestApiContext } from './types';\n\nconst getBrowserId = () => {\n\tlet browserId = localStorage.getItem(BROWSER_ID_STORAGE_KEY);\n\tif (!browserId) {\n\t\tbrowserId = crypto.randomUUID();\n\t\tlocalStorage.setItem(BROWSER_ID_STORAGE_KEY, browserId);\n\t}\n\treturn browserId;\n};\n\nexport const NO_NETWORK_ERROR_CODE = 999;\nexport const STREAM_SEPARATOR = '⧉⇋⇋➽⌑⧉§§\\n';\n\nexport class MfaRequiredError extends ApplicationError {\n\tconstructor() {\n\t\tsuper('MFA is required to access this resource. Please set up MFA in your user settings.');\n\t\tthis.name = 'MfaRequiredError';\n\t}\n}\n\nexport class ResponseError extends ApplicationError {\n\t// The HTTP status code of response\n\thttpStatusCode?: number;\n\n\t// The error code in the response\n\terrorCode?: number;\n\n\t// The stack trace of the server\n\tserverStackTrace?: string;\n\n\t// Additional metadata from the server (e.g., EULA URL)\n\tmeta?: Record<string, unknown>;\n\n\t// Additional hint from the server\n\thint?: string;\n\n\t/**\n\t * Creates an instance of ResponseError.\n\t * @param {string} message The error message\n\t * @param {number} [errorCode] The error code which can be used by frontend to identify the actual error\n\t * @param {number} [httpStatusCode] The HTTP status code the response should have\n\t * @param {string} [stack] The stack trace\n\t * @param {Record<string, unknown>} [meta] Additional metadata from the server\n\t * @param {string} [hint] Additional hint from the server\n\t */\n\tconstructor(\n\t\tmessage: string,\n\t\toptions: {\n\t\t\terrorCode?: number;\n\t\t\thttpStatusCode?: number;\n\t\t\tstack?: string;\n\t\t\tmeta?: Record<string, unknown>;\n\t\t\thint?: ResponseError['hint'];\n\t\t} = {},\n\t) {\n\t\tsuper(message);\n\t\tthis.name = 'ResponseError';\n\n\t\tconst { errorCode, httpStatusCode, stack, meta, hint } = options;\n\t\tif (errorCode) {\n\t\t\tthis.errorCode = errorCode;\n\t\t}\n\t\tif (httpStatusCode) {\n\t\t\tthis.httpStatusCode = httpStatusCode;\n\t\t}\n\t\tif (stack) {\n\t\t\tthis.serverStackTrace = stack;\n\t\t}\n\t\tif (meta) {\n\t\t\tthis.meta = meta;\n\t\t}\n\t\tif (hint) {\n\t\t\tthis.hint = hint;\n\t\t}\n\t}\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst legacyParamSerializer = (params: Record<string, any>) =>\n\tObject.keys(params)\n\t\t.filter((key) => params[key] !== undefined)\n\t\t.map((key) => {\n\t\t\tif (Array.isArray(params[key])) {\n\t\t\t\treturn params[key].map((v: string) => `${key}[]=${encodeURIComponent(v)}`).join('&');\n\t\t\t}\n\t\t\tif (typeof params[key] === 'object') {\n\t\t\t\tparams[key] = JSON.stringify(params[key]);\n\t\t\t}\n\t\t\treturn `${key}=${encodeURIComponent(params[key])}`;\n\t\t})\n\t\t.join('&');\n\nexport async function request(config: {\n\tmethod: Method;\n\tbaseURL: string;\n\tendpoint: string;\n\theaders?: RawAxiosRequestHeaders;\n\tdata?: GenericValue | GenericValue[];\n\twithCredentials?: boolean;\n}) {\n\tconst { method, baseURL, endpoint, headers, data } = config;\n\tconst options: AxiosRequestConfig = {\n\t\tmethod,\n\t\turl: endpoint,\n\t\tbaseURL,\n\t\theaders: headers ?? {},\n\t};\n\tif (baseURL.startsWith('/')) {\n\t\toptions.headers!['browser-id'] = getBrowserId();\n\t}\n\tif (\n\t\timport.meta.env.NODE_ENV !== 'production' &&\n\t\t!baseURL.includes('api.n8n.io') &&\n\t\t!baseURL.includes('n8n.cloud')\n\t) {\n\t\toptions.withCredentials = options.withCredentials ?? true;\n\t}\n\tif (['POST', 'PATCH', 'PUT'].includes(method)) {\n\t\toptions.data = data;\n\t} else if (data) {\n\t\toptions.params = data;\n\t\toptions.paramsSerializer = legacyParamSerializer;\n\t}\n\n\ttry {\n\t\tconst response = await axios.request(options);\n\t\treturn response.data;\n\t} catch (error) {\n\t\tif (error.message === 'Network Error') {\n\t\t\tthrow new ResponseError(\"Can't connect to n8n.\", {\n\t\t\t\terrorCode: NO_NETWORK_ERROR_CODE,\n\t\t\t});\n\t\t}\n\n\t\tconst errorResponseData = error.response?.data;\n\t\tif (errorResponseData?.mfaRequired === true) {\n\t\t\tthrow new MfaRequiredError();\n\t\t}\n\t\tif (errorResponseData?.message !== undefined) {\n\t\t\tif (errorResponseData.name === 'NodeApiError') {\n\t\t\t\terrorResponseData.httpStatusCode = error.response.status;\n\t\t\t\tthrow errorResponseData;\n\t\t\t}\n\n\t\t\tthrow new ResponseError(errorResponseData.message, {\n\t\t\t\terrorCode: errorResponseData.code,\n\t\t\t\thttpStatusCode: error.response.status,\n\t\t\t\tstack: errorResponseData.stack,\n\t\t\t\tmeta: errorResponseData.meta,\n\t\t\t\thint: errorResponseData.hint,\n\t\t\t});\n\t\t}\n\n\t\tthrow error;\n\t}\n}\n\n/**\n * Sends a request to the API and returns the response without extracting the data key.\n * @param context Rest API context\n * @param method HTTP method\n * @param endpoint relative path to the API endpoint\n * @param data request data\n * @returns data and total count\n */\nexport async function getFullApiResponse<T>(\n\tcontext: IRestApiContext,\n\tmethod: Method,\n\tendpoint: string,\n\tdata?: GenericValue | GenericValue[],\n) {\n\tconst response = await request({\n\t\tmethod,\n\t\tbaseURL: context.baseUrl,\n\t\tendpoint,\n\t\theaders: { 'push-ref': context.pushRef },\n\t\tdata,\n\t});\n\n\treturn response as { count: number; data: T };\n}\n\nexport async function makeRestApiRequest<T>(\n\tcontext: IRestApiContext,\n\tmethod: Method,\n\tendpoint: string,\n\tdata?: GenericValue | GenericValue[],\n) {\n\tconst response = await request({\n\t\tmethod,\n\t\tbaseURL: context.baseUrl,\n\t\tendpoint,\n\t\theaders: { 'push-ref': context.pushRef },\n\t\tdata,\n\t});\n\n\t// All cli rest api endpoints return data wrapped in `data` key\n\treturn response.data as T;\n}\n\nexport async function get(\n\tbaseURL: string,\n\tendpoint: string,\n\tparams?: IDataObject,\n\theaders?: RawAxiosRequestHeaders,\n) {\n\treturn await request({ method: 'GET', baseURL, endpoint, headers, data: params });\n}\n\nexport async function post(\n\tbaseURL: string,\n\tendpoint: string,\n\tparams?: IDataObject,\n\theaders?: RawAxiosRequestHeaders,\n) {\n\treturn await request({ method: 'POST', baseURL, endpoint, headers, data: params });\n}\n\nexport async function patch(\n\tbaseURL: string,\n\tendpoint: string,\n\tparams?: IDataObject,\n\theaders?: RawAxiosRequestHeaders,\n) {\n\treturn await request({ method: 'PATCH', baseURL, endpoint, headers, data: params });\n}\n\nexport async function streamRequest<T extends object>(\n\tcontext: IRestApiContext,\n\tapiEndpoint: string,\n\tpayload: object,\n\tonChunk?: (chunk: T) => void,\n\tonDone?: () => void,\n\tonError?: (e: Error) => void,\n\tseparator = STREAM_SEPARATOR,\n\tabortSignal?: AbortSignal,\n): Promise<void> {\n\tlet onErrorOnce: ((e: Error) => void) | undefined = (e: Error) => {\n\t\tonErrorOnce = undefined;\n\t\tonError?.(e);\n\t};\n\tconst headers: Record<string, string> = {\n\t\t'browser-id': getBrowserId(),\n\t\t'Content-Type': 'application/json',\n\t};\n\tconst assistantRequest: RequestInit = {\n\t\theaders,\n\t\tmethod: 'POST',\n\t\tcredentials: 'include',\n\t\tbody: JSON.stringify(payload),\n\t\tsignal: abortSignal,\n\t};\n\ttry {\n\t\tconst response = await fetch(`${context.baseUrl}${apiEndpoint}`, assistantRequest);\n\n\t\tif (response.body) {\n\t\t\t// Handle the streaming response\n\t\t\tconst reader = response.body.getReader();\n\t\t\tconst decoder = new TextDecoder('utf-8');\n\n\t\t\tlet buffer = '';\n\n\t\t\tasync function readStream() {\n\t\t\t\tconst { done, value } = await reader.read();\n\t\t\t\tif (done) {\n\t\t\t\t\tif (response.ok) {\n\t\t\t\t\t\tonDone?.();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tonErrorOnce?.(\n\t\t\t\t\t\t\tnew ResponseError(response.statusText, {\n\t\t\t\t\t\t\t\thttpStatusCode: response.status,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst chunk = decoder.decode(value);\n\t\t\t\tbuffer += chunk;\n\n\t\t\t\tconst splitChunks = buffer.split(separator);\n\n\t\t\t\tbuffer = '';\n\t\t\t\tfor (const splitChunk of splitChunks) {\n\t\t\t\t\tif (splitChunk) {\n\t\t\t\t\t\tlet data: T;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tdata = jsonParse<T>(splitChunk, { errorMessage: 'Invalid json' });\n\t\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\t\t// incomplete json. append to buffer to complete\n\t\t\t\t\t\t\tbuffer += splitChunk;\n\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tif (response.ok) {\n\t\t\t\t\t\t\t\t// Call chunk callback if request was successful\n\t\t\t\t\t\t\t\tonChunk?.(data);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// Otherwise, call error callback\n\t\t\t\t\t\t\t\tconst message = 'message' in data ? data.message : response.statusText;\n\t\t\t\t\t\t\t\tonErrorOnce?.(\n\t\t\t\t\t\t\t\t\tnew ResponseError(String(message), {\n\t\t\t\t\t\t\t\t\t\thttpStatusCode: response.status,\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} catch (e: unknown) {\n\t\t\t\t\t\t\tif (e instanceof Error) {\n\t\t\t\t\t\t\t\tonErrorOnce?.(e);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tawait readStream();\n\t\t\t}\n\n\t\t\t// Start reading the stream\n\t\t\tawait readStream();\n\t\t} else if (onErrorOnce) {\n\t\t\tonErrorOnce(new Error(response.statusText));\n\t\t}\n\t} catch (e: unknown) {\n\t\tassert(e instanceof Error);\n\t\tonErrorOnce?.(e);\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AASA,MAAM,qBAAqB;CAC1B,IAAI,YAAY,aAAa,QAAQA,uCAAuB;AAC5D,KAAI,CAAC,WAAW;AACf,cAAY,OAAO,YAAY;AAC/B,eAAa,QAAQA,wCAAwB,UAAU;;AAExD,QAAO;;AAGR,MAAa,wBAAwB;AACrC,MAAa,mBAAmB;AAEhC,IAAa,mBAAb,cAAsCC,8BAAiB;CACtD,cAAc;AACb,QAAM,oFAAoF;AAC1F,OAAK,OAAO;;;AAId,IAAa,gBAAb,cAAmCA,8BAAiB;CAEnD;CAGA;CAGA;CAGA;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ends ApplicationError {
13
13
  errorCode?: number;
14
14
  serverStackTrace?: string;
15
15
  meta?: Record<string, unknown>;
16
+ hint?: string;
16
17
  constructor(message: string, options?: {
17
18
  errorCode?: number;
18
19
  httpStatusCode?: number;
19
20
  stack?: string;
20
21
  meta?: Record<string, unknown>;
22
+ hint?: ResponseError['hint'];
21
23
  });
22
24
  }
23
25
  declare function request(config: {
package/dist/utils2.d.mts CHANGED
@@ -13,11 +13,13 @@ declare class ResponseError extends ApplicationError {
13
13
  errorCode?: number;
14
14
  serverStackTrace?: string;
15
15
  meta?: Record<string, unknown>;
16
+ hint?: string;
16
17
  constructor(message: string, options?: {
17
18
  errorCode?: number;
18
19
  httpStatusCode?: number;
19
20
  stack?: string;
20
21
  meta?: Record<string, unknown>;
22
+ hint?: ResponseError['hint'];
21
23
  });
22
24
  }
23
25
  declare function request(config: {
package/dist/utils2.mjs CHANGED
@@ -25,6 +25,7 @@ var ResponseError = class extends ApplicationError {
25
25
  errorCode;
26
26
  serverStackTrace;
27
27
  meta;
28
+ hint;
28
29
  /**
29
30
  * Creates an instance of ResponseError.
30
31
  * @param {string} message The error message
@@ -32,15 +33,17 @@ var ResponseError = class extends ApplicationError {
32
33
  * @param {number} [httpStatusCode] The HTTP status code the response should have
33
34
  * @param {string} [stack] The stack trace
34
35
  * @param {Record<string, unknown>} [meta] Additional metadata from the server
36
+ * @param {string} [hint] Additional hint from the server
35
37
  */
36
38
  constructor(message, options = {}) {
37
39
  super(message);
38
40
  this.name = "ResponseError";
39
- const { errorCode, httpStatusCode, stack, meta } = options;
41
+ const { errorCode, httpStatusCode, stack, meta, hint } = options;
40
42
  if (errorCode) this.errorCode = errorCode;
41
43
  if (httpStatusCode) this.httpStatusCode = httpStatusCode;
42
44
  if (stack) this.serverStackTrace = stack;
43
45
  if (meta) this.meta = meta;
46
+ if (hint) this.hint = hint;
44
47
  }
45
48
  };
46
49
  const legacyParamSerializer = (params) => Object.keys(params).filter((key) => params[key] !== void 0).map((key) => {
@@ -82,7 +85,8 @@ async function request(config) {
82
85
  errorCode: errorResponseData.code,
83
86
  httpStatusCode: error.response.status,
84
87
  stack: errorResponseData.stack,
85
- meta: errorResponseData.meta
88
+ meta: errorResponseData.meta,
89
+ hint: errorResponseData.hint
86
90
  });
87
91
  }
88
92
  throw error;
@@ -1 +1 @@
1
- {"version":3,"file":"utils2.mjs","names":["options: AxiosRequestConfig","onErrorOnce: ((e: Error) => void) | undefined","assistantRequest: RequestInit","data: T","e: unknown"],"sources":["../src/utils.ts"],"sourcesContent":["import { BROWSER_ID_STORAGE_KEY } from '@n8n/constants';\nimport { assert } from '@n8n/utils/assert';\nimport type { AxiosRequestConfig, Method, RawAxiosRequestHeaders } from 'axios';\nimport axios from 'axios';\nimport { ApplicationError, jsonParse } from 'n8n-workflow';\nimport type { GenericValue, IDataObject } from 'n8n-workflow';\n\nimport type { IRestApiContext } from './types';\n\nconst getBrowserId = () => {\n\tlet browserId = localStorage.getItem(BROWSER_ID_STORAGE_KEY);\n\tif (!browserId) {\n\t\tbrowserId = crypto.randomUUID();\n\t\tlocalStorage.setItem(BROWSER_ID_STORAGE_KEY, browserId);\n\t}\n\treturn browserId;\n};\n\nexport const NO_NETWORK_ERROR_CODE = 999;\nexport const STREAM_SEPARATOR = '⧉⇋⇋➽⌑⧉§§\\n';\n\nexport class MfaRequiredError extends ApplicationError {\n\tconstructor() {\n\t\tsuper('MFA is required to access this resource. Please set up MFA in your user settings.');\n\t\tthis.name = 'MfaRequiredError';\n\t}\n}\n\nexport class ResponseError extends ApplicationError {\n\t// The HTTP status code of response\n\thttpStatusCode?: number;\n\n\t// The error code in the response\n\terrorCode?: number;\n\n\t// The stack trace of the server\n\tserverStackTrace?: string;\n\n\t// Additional metadata from the server (e.g., EULA URL)\n\tmeta?: Record<string, unknown>;\n\n\t/**\n\t * Creates an instance of ResponseError.\n\t * @param {string} message The error message\n\t * @param {number} [errorCode] The error code which can be used by frontend to identify the actual error\n\t * @param {number} [httpStatusCode] The HTTP status code the response should have\n\t * @param {string} [stack] The stack trace\n\t * @param {Record<string, unknown>} [meta] Additional metadata from the server\n\t */\n\tconstructor(\n\t\tmessage: string,\n\t\toptions: {\n\t\t\terrorCode?: number;\n\t\t\thttpStatusCode?: number;\n\t\t\tstack?: string;\n\t\t\tmeta?: Record<string, unknown>;\n\t\t} = {},\n\t) {\n\t\tsuper(message);\n\t\tthis.name = 'ResponseError';\n\n\t\tconst { errorCode, httpStatusCode, stack, meta } = options;\n\t\tif (errorCode) {\n\t\t\tthis.errorCode = errorCode;\n\t\t}\n\t\tif (httpStatusCode) {\n\t\t\tthis.httpStatusCode = httpStatusCode;\n\t\t}\n\t\tif (stack) {\n\t\t\tthis.serverStackTrace = stack;\n\t\t}\n\t\tif (meta) {\n\t\t\tthis.meta = meta;\n\t\t}\n\t}\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst legacyParamSerializer = (params: Record<string, any>) =>\n\tObject.keys(params)\n\t\t.filter((key) => params[key] !== undefined)\n\t\t.map((key) => {\n\t\t\tif (Array.isArray(params[key])) {\n\t\t\t\treturn params[key].map((v: string) => `${key}[]=${encodeURIComponent(v)}`).join('&');\n\t\t\t}\n\t\t\tif (typeof params[key] === 'object') {\n\t\t\t\tparams[key] = JSON.stringify(params[key]);\n\t\t\t}\n\t\t\treturn `${key}=${encodeURIComponent(params[key])}`;\n\t\t})\n\t\t.join('&');\n\nexport async function request(config: {\n\tmethod: Method;\n\tbaseURL: string;\n\tendpoint: string;\n\theaders?: RawAxiosRequestHeaders;\n\tdata?: GenericValue | GenericValue[];\n\twithCredentials?: boolean;\n}) {\n\tconst { method, baseURL, endpoint, headers, data } = config;\n\tconst options: AxiosRequestConfig = {\n\t\tmethod,\n\t\turl: endpoint,\n\t\tbaseURL,\n\t\theaders: headers ?? {},\n\t};\n\tif (baseURL.startsWith('/')) {\n\t\toptions.headers!['browser-id'] = getBrowserId();\n\t}\n\tif (\n\t\timport.meta.env.NODE_ENV !== 'production' &&\n\t\t!baseURL.includes('api.n8n.io') &&\n\t\t!baseURL.includes('n8n.cloud')\n\t) {\n\t\toptions.withCredentials = options.withCredentials ?? true;\n\t}\n\tif (['POST', 'PATCH', 'PUT'].includes(method)) {\n\t\toptions.data = data;\n\t} else if (data) {\n\t\toptions.params = data;\n\t\toptions.paramsSerializer = legacyParamSerializer;\n\t}\n\n\ttry {\n\t\tconst response = await axios.request(options);\n\t\treturn response.data;\n\t} catch (error) {\n\t\tif (error.message === 'Network Error') {\n\t\t\tthrow new ResponseError(\"Can't connect to n8n.\", {\n\t\t\t\terrorCode: NO_NETWORK_ERROR_CODE,\n\t\t\t});\n\t\t}\n\n\t\tconst errorResponseData = error.response?.data;\n\t\tif (errorResponseData?.mfaRequired === true) {\n\t\t\tthrow new MfaRequiredError();\n\t\t}\n\t\tif (errorResponseData?.message !== undefined) {\n\t\t\tif (errorResponseData.name === 'NodeApiError') {\n\t\t\t\terrorResponseData.httpStatusCode = error.response.status;\n\t\t\t\tthrow errorResponseData;\n\t\t\t}\n\n\t\t\tthrow new ResponseError(errorResponseData.message, {\n\t\t\t\terrorCode: errorResponseData.code,\n\t\t\t\thttpStatusCode: error.response.status,\n\t\t\t\tstack: errorResponseData.stack,\n\t\t\t\tmeta: errorResponseData.meta,\n\t\t\t});\n\t\t}\n\n\t\tthrow error;\n\t}\n}\n\n/**\n * Sends a request to the API and returns the response without extracting the data key.\n * @param context Rest API context\n * @param method HTTP method\n * @param endpoint relative path to the API endpoint\n * @param data request data\n * @returns data and total count\n */\nexport async function getFullApiResponse<T>(\n\tcontext: IRestApiContext,\n\tmethod: Method,\n\tendpoint: string,\n\tdata?: GenericValue | GenericValue[],\n) {\n\tconst response = await request({\n\t\tmethod,\n\t\tbaseURL: context.baseUrl,\n\t\tendpoint,\n\t\theaders: { 'push-ref': context.pushRef },\n\t\tdata,\n\t});\n\n\treturn response as { count: number; data: T };\n}\n\nexport async function makeRestApiRequest<T>(\n\tcontext: IRestApiContext,\n\tmethod: Method,\n\tendpoint: string,\n\tdata?: GenericValue | GenericValue[],\n) {\n\tconst response = await request({\n\t\tmethod,\n\t\tbaseURL: context.baseUrl,\n\t\tendpoint,\n\t\theaders: { 'push-ref': context.pushRef },\n\t\tdata,\n\t});\n\n\t// All cli rest api endpoints return data wrapped in `data` key\n\treturn response.data as T;\n}\n\nexport async function get(\n\tbaseURL: string,\n\tendpoint: string,\n\tparams?: IDataObject,\n\theaders?: RawAxiosRequestHeaders,\n) {\n\treturn await request({ method: 'GET', baseURL, endpoint, headers, data: params });\n}\n\nexport async function post(\n\tbaseURL: string,\n\tendpoint: string,\n\tparams?: IDataObject,\n\theaders?: RawAxiosRequestHeaders,\n) {\n\treturn await request({ method: 'POST', baseURL, endpoint, headers, data: params });\n}\n\nexport async function patch(\n\tbaseURL: string,\n\tendpoint: string,\n\tparams?: IDataObject,\n\theaders?: RawAxiosRequestHeaders,\n) {\n\treturn await request({ method: 'PATCH', baseURL, endpoint, headers, data: params });\n}\n\nexport async function streamRequest<T extends object>(\n\tcontext: IRestApiContext,\n\tapiEndpoint: string,\n\tpayload: object,\n\tonChunk?: (chunk: T) => void,\n\tonDone?: () => void,\n\tonError?: (e: Error) => void,\n\tseparator = STREAM_SEPARATOR,\n\tabortSignal?: AbortSignal,\n): Promise<void> {\n\tlet onErrorOnce: ((e: Error) => void) | undefined = (e: Error) => {\n\t\tonErrorOnce = undefined;\n\t\tonError?.(e);\n\t};\n\tconst headers: Record<string, string> = {\n\t\t'browser-id': getBrowserId(),\n\t\t'Content-Type': 'application/json',\n\t};\n\tconst assistantRequest: RequestInit = {\n\t\theaders,\n\t\tmethod: 'POST',\n\t\tcredentials: 'include',\n\t\tbody: JSON.stringify(payload),\n\t\tsignal: abortSignal,\n\t};\n\ttry {\n\t\tconst response = await fetch(`${context.baseUrl}${apiEndpoint}`, assistantRequest);\n\n\t\tif (response.body) {\n\t\t\t// Handle the streaming response\n\t\t\tconst reader = response.body.getReader();\n\t\t\tconst decoder = new TextDecoder('utf-8');\n\n\t\t\tlet buffer = '';\n\n\t\t\tasync function readStream() {\n\t\t\t\tconst { done, value } = await reader.read();\n\t\t\t\tif (done) {\n\t\t\t\t\tif (response.ok) {\n\t\t\t\t\t\tonDone?.();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tonErrorOnce?.(\n\t\t\t\t\t\t\tnew ResponseError(response.statusText, {\n\t\t\t\t\t\t\t\thttpStatusCode: response.status,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst chunk = decoder.decode(value);\n\t\t\t\tbuffer += chunk;\n\n\t\t\t\tconst splitChunks = buffer.split(separator);\n\n\t\t\t\tbuffer = '';\n\t\t\t\tfor (const splitChunk of splitChunks) {\n\t\t\t\t\tif (splitChunk) {\n\t\t\t\t\t\tlet data: T;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tdata = jsonParse<T>(splitChunk, { errorMessage: 'Invalid json' });\n\t\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\t\t// incomplete json. append to buffer to complete\n\t\t\t\t\t\t\tbuffer += splitChunk;\n\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tif (response.ok) {\n\t\t\t\t\t\t\t\t// Call chunk callback if request was successful\n\t\t\t\t\t\t\t\tonChunk?.(data);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// Otherwise, call error callback\n\t\t\t\t\t\t\t\tconst message = 'message' in data ? data.message : response.statusText;\n\t\t\t\t\t\t\t\tonErrorOnce?.(\n\t\t\t\t\t\t\t\t\tnew ResponseError(String(message), {\n\t\t\t\t\t\t\t\t\t\thttpStatusCode: response.status,\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} catch (e: unknown) {\n\t\t\t\t\t\t\tif (e instanceof Error) {\n\t\t\t\t\t\t\t\tonErrorOnce?.(e);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tawait readStream();\n\t\t\t}\n\n\t\t\t// Start reading the stream\n\t\t\tawait readStream();\n\t\t} else if (onErrorOnce) {\n\t\t\tonErrorOnce(new Error(response.statusText));\n\t\t}\n\t} catch (e: unknown) {\n\t\tassert(e instanceof Error);\n\t\tonErrorOnce?.(e);\n\t}\n}\n"],"mappings":";;;;;;AASA,MAAM,qBAAqB;CAC1B,IAAI,YAAY,aAAa,QAAQ,uBAAuB;AAC5D,KAAI,CAAC,WAAW;AACf,cAAY,OAAO,YAAY;AAC/B,eAAa,QAAQ,wBAAwB,UAAU;;AAExD,QAAO;;AAGR,MAAa,wBAAwB;AACrC,MAAa,mBAAmB;AAEhC,IAAa,mBAAb,cAAsC,iBAAiB;CACtD,cAAc;AACb,QAAM,oFAAoF;AAC1F,OAAK,OAAO;;;AAId,IAAa,gBAAb,cAAmC,iBAAiB;CAEnD;CAGA;CAGA;CAGA;;;;;;;;;CAUA,YACC,SACA,UAKI,EAAE,EACL;AACD,QAAM,QAAQ;AACd,OAAK,OAAO;EAEZ,MAAM,EAAE,WAAW,gBAAgB,OAAO,SAAS;AACnD,MAAI,UACH,MAAK,YAAY;AAElB,MAAI,eACH,MAAK,iBAAiB;AAEvB,MAAI,MACH,MAAK,mBAAmB;AAEzB,MAAI,KACH,MAAK,OAAO;;;AAMf,MAAM,yBAAyB,WAC9B,OAAO,KAAK,OAAO,CACjB,QAAQ,QAAQ,OAAO,SAAS,OAAU,CAC1C,KAAK,QAAQ;AACb,KAAI,MAAM,QAAQ,OAAO,KAAK,CAC7B,QAAO,OAAO,KAAK,KAAK,MAAc,GAAG,IAAI,KAAK,mBAAmB,EAAE,GAAG,CAAC,KAAK,IAAI;AAErF,KAAI,OAAO,OAAO,SAAS,SAC1B,QAAO,OAAO,KAAK,UAAU,OAAO,KAAK;AAE1C,QAAO,G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,OAAO,MAAM,UAAU;AAE3C,aAAS;AACT,SAAK,MAAM,cAAc,YACxB,KAAI,YAAY;KACf,IAAIC;AACJ,SAAI;AACH,aAAO,UAAa,YAAY,EAAE,cAAc,gBAAgB,CAAC;cACzD,GAAG;AAEX,gBAAU;AAEV;;AAGD,SAAI;AACH,UAAI,SAAS,GAEZ,WAAU,KAAK;WACT;OAEN,MAAM,UAAU,aAAa,OAAO,KAAK,UAAU,SAAS;AAC5D,qBACC,IAAI,cAAc,OAAO,QAAQ,EAAE,EAClC,gBAAgB,SAAS,QACzB,CAAC,CACF;;cAEMC,GAAY;AACpB,UAAI,aAAa,MAChB,eAAc,EAAE;;;AAKpB,UAAM,YAAY;;AAInB,SAAM,YAAY;aACR,YACV,aAAY,IAAI,MAAM,SAAS,WAAW,CAAC;UAEpCA,GAAY;AACpB,SAAO,aAAa,MAAM;AAC1B,gBAAc,EAAE"}
1
+ {"version":3,"file":"utils2.mjs","names":["options: AxiosRequestConfig","onErrorOnce: ((e: Error) => void) | undefined","assistantRequest: RequestInit","data: T","e: unknown"],"sources":["../src/utils.ts"],"sourcesContent":["import { BROWSER_ID_STORAGE_KEY } from '@n8n/constants';\nimport { assert } from '@n8n/utils/assert';\nimport type { AxiosRequestConfig, Method, RawAxiosRequestHeaders } from 'axios';\nimport axios from 'axios';\nimport { ApplicationError, jsonParse } from 'n8n-workflow';\nimport type { GenericValue, IDataObject } from 'n8n-workflow';\n\nimport type { IRestApiContext } from './types';\n\nconst getBrowserId = () => {\n\tlet browserId = localStorage.getItem(BROWSER_ID_STORAGE_KEY);\n\tif (!browserId) {\n\t\tbrowserId = crypto.randomUUID();\n\t\tlocalStorage.setItem(BROWSER_ID_STORAGE_KEY, browserId);\n\t}\n\treturn browserId;\n};\n\nexport const NO_NETWORK_ERROR_CODE = 999;\nexport const STREAM_SEPARATOR = '⧉⇋⇋➽⌑⧉§§\\n';\n\nexport class MfaRequiredError extends ApplicationError {\n\tconstructor() {\n\t\tsuper('MFA is required to access this resource. Please set up MFA in your user settings.');\n\t\tthis.name = 'MfaRequiredError';\n\t}\n}\n\nexport class ResponseError extends ApplicationError {\n\t// The HTTP status code of response\n\thttpStatusCode?: number;\n\n\t// The error code in the response\n\terrorCode?: number;\n\n\t// The stack trace of the server\n\tserverStackTrace?: string;\n\n\t// Additional metadata from the server (e.g., EULA URL)\n\tmeta?: Record<string, unknown>;\n\n\t// Additional hint from the server\n\thint?: string;\n\n\t/**\n\t * Creates an instance of ResponseError.\n\t * @param {string} message The error message\n\t * @param {number} [errorCode] The error code which can be used by frontend to identify the actual error\n\t * @param {number} [httpStatusCode] The HTTP status code the response should have\n\t * @param {string} [stack] The stack trace\n\t * @param {Record<string, unknown>} [meta] Additional metadata from the server\n\t * @param {string} [hint] Additional hint from the server\n\t */\n\tconstructor(\n\t\tmessage: string,\n\t\toptions: {\n\t\t\terrorCode?: number;\n\t\t\thttpStatusCode?: number;\n\t\t\tstack?: string;\n\t\t\tmeta?: Record<string, unknown>;\n\t\t\thint?: ResponseError['hint'];\n\t\t} = {},\n\t) {\n\t\tsuper(message);\n\t\tthis.name = 'ResponseError';\n\n\t\tconst { errorCode, httpStatusCode, stack, meta, hint } = options;\n\t\tif (errorCode) {\n\t\t\tthis.errorCode = errorCode;\n\t\t}\n\t\tif (httpStatusCode) {\n\t\t\tthis.httpStatusCode = httpStatusCode;\n\t\t}\n\t\tif (stack) {\n\t\t\tthis.serverStackTrace = stack;\n\t\t}\n\t\tif (meta) {\n\t\t\tthis.meta = meta;\n\t\t}\n\t\tif (hint) {\n\t\t\tthis.hint = hint;\n\t\t}\n\t}\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nconst legacyParamSerializer = (params: Record<string, any>) =>\n\tObject.keys(params)\n\t\t.filter((key) => params[key] !== undefined)\n\t\t.map((key) => {\n\t\t\tif (Array.isArray(params[key])) {\n\t\t\t\treturn params[key].map((v: string) => `${key}[]=${encodeURIComponent(v)}`).join('&');\n\t\t\t}\n\t\t\tif (typeof params[key] === 'object') {\n\t\t\t\tparams[key] = JSON.stringify(params[key]);\n\t\t\t}\n\t\t\treturn `${key}=${encodeURIComponent(params[key])}`;\n\t\t})\n\t\t.join('&');\n\nexport async function request(config: {\n\tmethod: Method;\n\tbaseURL: string;\n\tendpoint: string;\n\theaders?: RawAxiosRequestHeaders;\n\tdata?: GenericValue | GenericValue[];\n\twithCredentials?: boolean;\n}) {\n\tconst { method, baseURL, endpoint, headers, data } = config;\n\tconst options: AxiosRequestConfig = {\n\t\tmethod,\n\t\turl: endpoint,\n\t\tbaseURL,\n\t\theaders: headers ?? {},\n\t};\n\tif (baseURL.startsWith('/')) {\n\t\toptions.headers!['browser-id'] = getBrowserId();\n\t}\n\tif (\n\t\timport.meta.env.NODE_ENV !== 'production' &&\n\t\t!baseURL.includes('api.n8n.io') &&\n\t\t!baseURL.includes('n8n.cloud')\n\t) {\n\t\toptions.withCredentials = options.withCredentials ?? true;\n\t}\n\tif (['POST', 'PATCH', 'PUT'].includes(method)) {\n\t\toptions.data = data;\n\t} else if (data) {\n\t\toptions.params = data;\n\t\toptions.paramsSerializer = legacyParamSerializer;\n\t}\n\n\ttry {\n\t\tconst response = await axios.request(options);\n\t\treturn response.data;\n\t} catch (error) {\n\t\tif (error.message === 'Network Error') {\n\t\t\tthrow new ResponseError(\"Can't connect to n8n.\", {\n\t\t\t\terrorCode: NO_NETWORK_ERROR_CODE,\n\t\t\t});\n\t\t}\n\n\t\tconst errorResponseData = error.response?.data;\n\t\tif (errorResponseData?.mfaRequired === true) {\n\t\t\tthrow new MfaRequiredError();\n\t\t}\n\t\tif (errorResponseData?.message !== undefined) {\n\t\t\tif (errorResponseData.name === 'NodeApiError') {\n\t\t\t\terrorResponseData.httpStatusCode = error.response.status;\n\t\t\t\tthrow errorResponseData;\n\t\t\t}\n\n\t\t\tthrow new ResponseError(errorResponseData.message, {\n\t\t\t\terrorCode: errorResponseData.code,\n\t\t\t\thttpStatusCode: error.response.status,\n\t\t\t\tstack: errorResponseData.stack,\n\t\t\t\tmeta: errorResponseData.meta,\n\t\t\t\thint: errorResponseData.hint,\n\t\t\t});\n\t\t}\n\n\t\tthrow error;\n\t}\n}\n\n/**\n * Sends a request to the API and returns the response without extracting the data key.\n * @param context Rest API context\n * @param method HTTP method\n * @param endpoint relative path to the API endpoint\n * @param data request data\n * @returns data and total count\n */\nexport async function getFullApiResponse<T>(\n\tcontext: IRestApiContext,\n\tmethod: Method,\n\tendpoint: string,\n\tdata?: GenericValue | GenericValue[],\n) {\n\tconst response = await request({\n\t\tmethod,\n\t\tbaseURL: context.baseUrl,\n\t\tendpoint,\n\t\theaders: { 'push-ref': context.pushRef },\n\t\tdata,\n\t});\n\n\treturn response as { count: number; data: T };\n}\n\nexport async function makeRestApiRequest<T>(\n\tcontext: IRestApiContext,\n\tmethod: Method,\n\tendpoint: string,\n\tdata?: GenericValue | GenericValue[],\n) {\n\tconst response = await request({\n\t\tmethod,\n\t\tbaseURL: context.baseUrl,\n\t\tendpoint,\n\t\theaders: { 'push-ref': context.pushRef },\n\t\tdata,\n\t});\n\n\t// All cli rest api endpoints return data wrapped in `data` key\n\treturn response.data as T;\n}\n\nexport async function get(\n\tbaseURL: string,\n\tendpoint: string,\n\tparams?: IDataObject,\n\theaders?: RawAxiosRequestHeaders,\n) {\n\treturn await request({ method: 'GET', baseURL, endpoint, headers, data: params });\n}\n\nexport async function post(\n\tbaseURL: string,\n\tendpoint: string,\n\tparams?: IDataObject,\n\theaders?: RawAxiosRequestHeaders,\n) {\n\treturn await request({ method: 'POST', baseURL, endpoint, headers, data: params });\n}\n\nexport async function patch(\n\tbaseURL: string,\n\tendpoint: string,\n\tparams?: IDataObject,\n\theaders?: RawAxiosRequestHeaders,\n) {\n\treturn await request({ method: 'PATCH', baseURL, endpoint, headers, data: params });\n}\n\nexport async function streamRequest<T extends object>(\n\tcontext: IRestApiContext,\n\tapiEndpoint: string,\n\tpayload: object,\n\tonChunk?: (chunk: T) => void,\n\tonDone?: () => void,\n\tonError?: (e: Error) => void,\n\tseparator = STREAM_SEPARATOR,\n\tabortSignal?: AbortSignal,\n): Promise<void> {\n\tlet onErrorOnce: ((e: Error) => void) | undefined = (e: Error) => {\n\t\tonErrorOnce = undefined;\n\t\tonError?.(e);\n\t};\n\tconst headers: Record<string, string> = {\n\t\t'browser-id': getBrowserId(),\n\t\t'Content-Type': 'application/json',\n\t};\n\tconst assistantRequest: RequestInit = {\n\t\theaders,\n\t\tmethod: 'POST',\n\t\tcredentials: 'include',\n\t\tbody: JSON.stringify(payload),\n\t\tsignal: abortSignal,\n\t};\n\ttry {\n\t\tconst response = await fetch(`${context.baseUrl}${apiEndpoint}`, assistantRequest);\n\n\t\tif (response.body) {\n\t\t\t// Handle the streaming response\n\t\t\tconst reader = response.body.getReader();\n\t\t\tconst decoder = new TextDecoder('utf-8');\n\n\t\t\tlet buffer = '';\n\n\t\t\tasync function readStream() {\n\t\t\t\tconst { done, value } = await reader.read();\n\t\t\t\tif (done) {\n\t\t\t\t\tif (response.ok) {\n\t\t\t\t\t\tonDone?.();\n\t\t\t\t\t} else {\n\t\t\t\t\t\tonErrorOnce?.(\n\t\t\t\t\t\t\tnew ResponseError(response.statusText, {\n\t\t\t\t\t\t\t\thttpStatusCode: response.status,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst chunk = decoder.decode(value);\n\t\t\t\tbuffer += chunk;\n\n\t\t\t\tconst splitChunks = buffer.split(separator);\n\n\t\t\t\tbuffer = '';\n\t\t\t\tfor (const splitChunk of splitChunks) {\n\t\t\t\t\tif (splitChunk) {\n\t\t\t\t\t\tlet data: T;\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tdata = jsonParse<T>(splitChunk, { errorMessage: 'Invalid json' });\n\t\t\t\t\t\t} catch (e) {\n\t\t\t\t\t\t\t// incomplete json. append to buffer to complete\n\t\t\t\t\t\t\tbuffer += splitChunk;\n\n\t\t\t\t\t\t\tcontinue;\n\t\t\t\t\t\t}\n\n\t\t\t\t\t\ttry {\n\t\t\t\t\t\t\tif (response.ok) {\n\t\t\t\t\t\t\t\t// Call chunk callback if request was successful\n\t\t\t\t\t\t\t\tonChunk?.(data);\n\t\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\t\t// Otherwise, call error callback\n\t\t\t\t\t\t\t\tconst message = 'message' in data ? data.message : response.statusText;\n\t\t\t\t\t\t\t\tonErrorOnce?.(\n\t\t\t\t\t\t\t\t\tnew ResponseError(String(message), {\n\t\t\t\t\t\t\t\t\t\thttpStatusCode: response.status,\n\t\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t\t\t);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} catch (e: unknown) {\n\t\t\t\t\t\t\tif (e instanceof Error) {\n\t\t\t\t\t\t\t\tonErrorOnce?.(e);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tawait readStream();\n\t\t\t}\n\n\t\t\t// Start reading the stream\n\t\t\tawait readStream();\n\t\t} else if (onErrorOnce) {\n\t\t\tonErrorOnce(new Error(response.statusText));\n\t\t}\n\t} catch (e: unknown) {\n\t\tassert(e instanceof Error);\n\t\tonErrorOnce?.(e);\n\t}\n}\n"],"mappings":";;;;;;AASA,MAAM,qBAAqB;CAC1B,IAAI,YAAY,aAAa,QAAQ,uBAAuB;AAC5D,KAAI,CAAC,WAAW;AACf,cAAY,OAAO,YAAY;AAC/B,eAAa,QAAQ,wBAAwB,UAAU;;AAExD,QAAO;;AAGR,MAAa,wBAAwB;AACrC,MAAa,mBAAmB;AAEhC,IAAa,mBAAb,cAAsC,iBAAiB;CACtD,cAAc;AACb,QAAM,oFAAoF;AAC1F,OAAK,OAAO;;;AAId,IAAa,gBAAb,cAAmC,iBAAiB;CAEnD;CAGA;CAGA;CAGA;CAGA;;;;;;;;;;CAWA,YACC,SACA,UAMI,EAAE,EACL;AACD,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5.1",
4
+ "version": "2.6.1",
5
5
  "files": [
6
6
  "dist",
7
7
  "LICENSE.md",
@@ -26,11 +26,11 @@
26
26
  "js-base64": "3.7.2",
27
27
  "axios": "1.12.0",
28
28
  "flatted": "3.2.7",
29
+ "@n8n/api-types": "1.6.1",
29
30
  "@n8n/constants": "0.16.0",
30
- "@n8n/api-types": "1.5.1",
31
- "@n8n/permissions": "0.47.0",
32
- "@n8n/utils": "1.22.0",
33
- "n8n-workflow": "2.5.1"
31
+ "@n8n/permissions": "0.47.1",
32
+ "n8n-workflow": "2.6.1",
33
+ "@n8n/utils": "1.22.0"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@testing-library/jest-dom": "^6.6.3",
@@ -39,10 +39,10 @@
39
39
  "typescript": "5.9.2",
40
40
  "vite": "npm:rolldown-vite@latest",
41
41
  "vitest": "^3.1.3",
42
+ "@n8n/eslint-config": "0.0.1",
42
43
  "@n8n/typescript-config": "1.3.0",
43
- "@n8n/i18n": "2.5.1",
44
- "@n8n/vitest-config": "1.5.0",
45
- "@n8n/eslint-config": "0.0.1"
44
+ "@n8n/vitest-config": "1.6.0",
45
+ "@n8n/i18n": "2.6.1"
46
46
  },
47
47
  "license": "SEE LICENSE IN LICENSE.md",
48
48
  "homepage": "https://n8n.io",