Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions nodes/Crowdin/methods/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,13 @@ export function createCommonLoadOptions(config: ApiConfig): LoadOptionsMethods {
(ctx) => `/projects/${getProjectId(ctx)}/comments`,
(item) => String(item.text),
);
// Advisor insights have no name/title — inspectorKey is the most human-readable
// label and can repeat across insights, so show it with the ID.
const projectAdvisorInsights = createTextFormattedMethodPair(
config,
(ctx) => `/projects/${getProjectId(ctx)}/advisors/insights`,
(item) => String(item.inspectorKey ?? item.category ?? item.id),
);

return {
// ===== Account/Organization-level resources =====
Expand Down Expand Up @@ -564,6 +571,8 @@ export function createCommonLoadOptions(config: ApiConfig): LoadOptionsMethods {
getProjectStringsMulti: projectStrings.multi,
getProjectComments: projectComments.regular,
getProjectCommentsMulti: projectComments.multi,
getProjectAdvisorInsights: projectAdvisorInsights.regular,
getProjectAdvisorInsightsMulti: projectAdvisorInsights.multi,

// ===== Special methods that can't use the pattern =====

Expand Down
136 changes: 136 additions & 0 deletions nodes/Crowdin/properties/common/extensions/advisors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
import type { INodeProperties } from 'n8n-workflow';
import { transformToJsonPatch } from '../../../utils/preSend';

// Hand-written extension: api.projects.advisors.insights.patch
//
// The generator skips this PATCH because it is a JSON Patch operation with no
// corresponding POST (insights are produced by Crowdin's advisor, not created via
// the API) and no reachable response schema, so it cannot infer the field type for
// the only patchable path, `/isDismissed`. See transformPatchOperationsInSpec in
// scripts/generate-properties.mjs. We mirror what the generator would emit: an
// `updateFields` collection plus the transformToJsonPatch preSend.
export const advisorsProperties: INodeProperties[] = [
{
displayName: 'Operation',
name: 'operation',
type: 'options',
noDataExpression: true,
displayOptions: {
show: {
resource: [
'advisor'
]
}
},
options: [
{
name: 'Edit Advisor Insight',
value: 'api.projects.advisors.insights.patch',
action: 'Edit Advisor Insight',
description: '**Required scopes:** `project.advisor` (Read and Write).\n\nUser-facing mutation of a single Advisor Insight row. Currently only `/isDismissed` is patchable (dismiss ↔ reactivate). For dispatching a fresh check, see POST `/advisors/checks`. For app-pushed insight updates, see PUT `/applications/.../insight`.',
routing: {
request: {
method: 'PATCH',
url: '=/projects/{{$parameter["projectId"]}}/advisors/insights/{{$parameter["insightId"]}}'
},
send: {
preSend: [
transformToJsonPatch
]
}
}
}
],
default: 'api.projects.advisors.insights.patch'
},
{
displayName: 'PATCH /projects/{projectId}/advisors/insights/{insightId}',
name: 'operation',
type: 'notice',
typeOptions: {
theme: 'info'
},
default: '',
displayOptions: {
show: {
resource: [
'advisor'
],
operation: [
'api.projects.advisors.insights.patch'
]
}
}
},
{
displayName: 'Project Id',
name: 'projectId',
required: true,
description: 'Project Identifier. Get via [List Projects](#operation/api.projects.getMany)',
default: '',
type: 'options',
displayOptions: {
show: {
resource: [
'advisor'
],
operation: [
'api.projects.advisors.insights.patch'
]
}
},
typeOptions: {
loadOptionsMethod: 'getProjects'
}
},
{
displayName: 'Insight Id',
name: 'insightId',
required: true,
description: 'Insight Identifier',
default: '',
type: 'options',
displayOptions: {
show: {
resource: [
'advisor'
],
operation: [
'api.projects.advisors.insights.patch'
]
}
},
typeOptions: {
loadOptionsMethod: 'getProjectAdvisorInsights',
loadOptionsDependsOn: [
'projectId'
]
}
},
{
displayName: 'Update Fields',
name: 'updateFields',
type: 'collection',
placeholder: 'Add Field',
default: {},
displayOptions: {
show: {
resource: [
'advisor'
],
operation: [
'api.projects.advisors.insights.patch'
]
}
},
options: [
{
displayName: 'Is Dismissed',
name: 'isDismissed',
type: 'boolean',
default: false,
description: 'Whether the insight is dismissed. Set to true to dismiss the insight, false to reactivate it.'
}
]
}
];
3 changes: 2 additions & 1 deletion nodes/Crowdin/properties/common/extensions/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import type { ExtensionModule } from '../../../utils/extendProperties';
import { advisorsProperties } from './advisors';
import { dictionariesProperties } from './dictionaries';
import { sourceStringsProperties } from './sourceStrings';
import { storageProperties } from './storage';
import { stringAssetCommentsProperties } from './stringAssetComments';
import { tasksProperties } from './tasks';
import { translationMemoryProperties } from './translationMemory';

export const extensions: ExtensionModule[] = [dictionariesProperties, sourceStringsProperties, storageProperties, stringAssetCommentsProperties, tasksProperties, translationMemoryProperties];
export const extensions: ExtensionModule[] = [advisorsProperties, dictionariesProperties, sourceStringsProperties, storageProperties, stringAssetCommentsProperties, tasksProperties, translationMemoryProperties];
Loading
Loading