Skip to content

Commit d20ac2f

Browse files
committed
feat(windchill): add update common properties
Name, Number, and Organization are rejected by the PATCH-based update operation, and the rejection message told users to reach for Windchill's UpdateCommonProperties action that the integration did not expose. Add it. PTC documents UpdateCommonProperties as a bound DocMgmt action taking an Updates wrapper, available when hasCommonProperties is set on the Documents entity, and refused while the document is checked out. The subblock and param descriptions carry that constraint, and the rejection message now names the operation that does the job.
1 parent 1d51f92 commit d20ac2f

15 files changed

Lines changed: 194 additions & 10 deletions

File tree

apps/docs/content/docs/en/integrations/windchill.mdx

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import { BlockInfoCard } from "@/components/ui/block-info-card"
1616
This integration talks to Windchill REST Services (WRS) 2.7 over OData — the query protocol Windchill exposes its data through — using a Basic-authenticated service account. Point it at a complete versioned service root — `https://your-host/Windchill/servlet/odata/v6` — and your agents can:
1717

1818
- **Find and read documents**: list documents with an OData filter, sort order, field selection, page size, and a latest-version-only switch; fetch a single document by its object identifier (OID); and walk a document's structure through its usage links to see child documents with their versions and states.
19-
- **Create and update**: create one document or a batch of them in a container and optional folder, and patch editable attributes on one or many documents. Name, Number, and Organization are deliberately rejected — Windchill requires its own `UpdateCommonProperties` action for those.
19+
- **Create and update**: create one document or a batch of them in a container and optional folder, and patch editable attributes on one or many documents. Name, Number, and Organization are rejected here and have their own operation, because Windchill changes those through a separate action and refuses it while a document is checked out.
2020
- **Run the version and lifecycle cycle**: check documents out and back in with notes, undo a checkout, revise to the next revision, read the lifecycle states a document is actually allowed to move to, and transition it to one of them.
2121
- **Move files**: download a document's primary content, or a specific attachment by its OID, into a Sim file — and upload files as primary content or attachments. Sim handles Windchill's CSRF token and its multi-step upload handshake for you.
2222

@@ -347,7 +347,43 @@ Update one document's editable attributes
347347
| `username` | string | Yes | Windchill service-account username |
348348
| `password` | string | Yes | Windchill service-account password |
349349
| `documentOid` | string | Yes | WT.Document OID, for example OR:wt.doc.WTDocument:48796581 |
350-
| `attributes` | json | Yes | Editable attributes as a JSON object. Name, Number, and Organization require Windchill UpdateCommonProperties and are not supported here. |
350+
| `attributes` | json | Yes | Editable attributes as a JSON object. Name, Number, and Organization require the Update Common Properties operation and are not supported here. |
351+
352+
#### Output
353+
354+
| Parameter | Type | Description |
355+
| --------- | ---- | ----------- |
356+
| `operation` | string | Windchill operation that was executed |
357+
| `affectedIds` | array | Document identifiers affected by the operation |
358+
| `document` | object | Document returned by Windchill when the operation returns one |
359+
|`id` | string | Windchill object identifier |
360+
|`name` | string | Document name |
361+
|`number` | string | Document number |
362+
|`title` | string | Document title |
363+
|`description` | string | Document description |
364+
|`state` | string | Internal life cycle state value |
365+
|`stateDisplay` | string | Displayed life cycle state value |
366+
|`versionId` | string | Version identifier |
367+
|`revision` | string | Revision identifier |
368+
|`version` | string | Version and iteration |
369+
|`latest` | boolean | Whether this is the latest version |
370+
|`checkoutState` | string | Checkout state |
371+
|`folderName` | string | Folder name |
372+
|`folderLocation` | string | Folder path |
373+
374+
### Windchill Update Common Properties
375+
376+
Update a document's Name, Number, and other common properties
377+
378+
#### Input
379+
380+
| Parameter | Type | Required | Description |
381+
| --------- | ---- | -------- | ----------- |
382+
| `baseUrl` | string | Yes | Complete WRS 2.7 versioned service root using Basic authentication, for example https://host/Windchill/servlet/odata/v6 |
383+
| `username` | string | Yes | Windchill service-account username |
384+
| `password` | string | Yes | Windchill service-account password |
385+
| `documentOid` | string | Yes | WT.Document OID, for example OR:wt.doc.WTDocument:48796581. The document must not be checked out. |
386+
| `commonProperties` | json | Yes | Common properties as a JSON object, for example \{"Name":"New name","Number":"NEW-001"\}. Enumerated properties take a value/display pair. |
351387

352388
#### Output
353389

apps/sim/app/api/tools/windchill/route.test.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,12 @@ const MUTATION_CASES = [
137137
url: '/DocMgmt/UpdateDocuments',
138138
method: 'POST',
139139
},
140+
{
141+
operation: 'windchill_update_common_properties',
142+
input: { documentOid: DOCUMENT_OID, commonProperties: { Name: 'Renamed' } },
143+
url: '/PTC.DocMgmt.UpdateCommonProperties',
144+
method: 'POST',
145+
},
140146
{
141147
operation: 'windchill_delete_document',
142148
input: { documentOid: DOCUMENT_OID },
@@ -238,6 +244,14 @@ const MUTATION_PAYLOAD_CASES = [
238244
input: { documentOid: DOCUMENT_OID, versionId: 'B' },
239245
body: { VersionId: 'B' },
240246
},
247+
{
248+
operation: 'windchill_update_common_properties',
249+
input: {
250+
documentOid: DOCUMENT_OID,
251+
commonProperties: { Name: 'Renamed', Number: 'DOC-001' },
252+
},
253+
body: { Updates: { Name: 'Renamed', Number: 'DOC-001' } },
254+
},
241255
{
242256
operation: 'windchill_revise_documents',
243257
input: { documentOids: [DOCUMENT_OID] },

apps/sim/app/api/tools/windchill/route.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,17 @@ async function executeMutation(
225225
})
226226
return mutationOutput(body.operation, data, [body.documentOid])
227227
}
228+
case 'windchill_update_common_properties': {
229+
const data = await windchillMutationRequest({
230+
params: body,
231+
session,
232+
url: `${windchillDocumentUrl(root, body.documentOid)}/PTC.DocMgmt.UpdateCommonProperties`,
233+
method: 'POST',
234+
body: { Updates: body.commonProperties },
235+
signal,
236+
})
237+
return mutationOutput(body.operation, data, [body.documentOid])
238+
}
228239
case 'windchill_update_documents': {
229240
const data = await windchillMutationRequest({
230241
params: body,

apps/sim/blocks/blocks/windchill.ts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ const SINGLE_DOCUMENT_OPERATIONS = [
1212
'windchill_get_primary_content',
1313
'windchill_list_attachments',
1414
'windchill_update_document',
15+
'windchill_update_common_properties',
1516
'windchill_delete_document',
1617
'windchill_check_out_document',
1718
'windchill_check_in_document',
@@ -46,6 +47,7 @@ const DOWNLOAD_OPERATIONS = ['windchill_download_primary_content', 'windchill_do
4647
const SINGLE_MUTATION_OPERATIONS = [
4748
'windchill_create_document',
4849
'windchill_update_document',
50+
'windchill_update_common_properties',
4951
'windchill_check_out_document',
5052
'windchill_check_in_document',
5153
'windchill_undo_check_out_document',
@@ -163,6 +165,9 @@ export const WindchillBlock: BlockConfig<WindchillResponse> = {
163165
{ text: 'Update document', field: 'documentOid', core: true },
164166
{ text: 'with', field: 'attributes' },
165167
],
168+
windchill_update_common_properties: [
169+
{ text: 'Update common properties on', field: 'documentOid', core: true },
170+
],
166171
windchill_update_documents: [{ text: 'Update', field: 'documents', core: true }],
167172
windchill_delete_document: [{ text: 'Delete document', field: 'documentOid', core: true }],
168173
windchill_delete_documents: [{ text: 'Delete', field: 'documentOids', core: true }],
@@ -258,6 +263,11 @@ export const WindchillBlock: BlockConfig<WindchillResponse> = {
258263
id: 'windchill_update_document',
259264
description: "Update a document's editable attributes",
260265
},
266+
{
267+
label: 'Update Common Properties',
268+
id: 'windchill_update_common_properties',
269+
description: "Update a document's Name, Number, and other common properties",
270+
},
261271
{
262272
label: 'Update Documents',
263273
id: 'windchill_update_documents',
@@ -456,7 +466,18 @@ export const WindchillBlock: BlockConfig<WindchillResponse> = {
456466
},
457467
required: { field: 'operation', value: 'windchill_update_document' },
458468
description:
459-
'Installed JSON attributes supported by PATCH. Name, Number, and Organization require Windchill UpdateCommonProperties and are rejected here.',
469+
'Editable attributes as JSON. Name, Number, and Organization require the Update Common Properties operation and are rejected here.',
470+
},
471+
{
472+
id: 'commonProperties',
473+
title: 'Common Properties',
474+
type: 'code',
475+
language: 'json',
476+
placeholder: '{"Name":"Updated name","Number":"DOC-001"}',
477+
condition: { field: 'operation', value: 'windchill_update_common_properties' },
478+
required: true,
479+
description:
480+
'Common properties as a JSON object. This is the only operation that can change Name, Number, and Organization, and Windchill rejects it while the document is checked out.',
460481
},
461482
{
462483
id: 'documents',
@@ -713,6 +734,7 @@ export const WindchillBlock: BlockConfig<WindchillResponse> = {
713734
'windchill_create_document',
714735
'windchill_create_documents',
715736
'windchill_update_document',
737+
'windchill_update_common_properties',
716738
'windchill_update_documents',
717739
'windchill_delete_document',
718740
'windchill_delete_documents',
@@ -738,6 +760,7 @@ export const WindchillBlock: BlockConfig<WindchillResponse> = {
738760
operation,
739761
documents,
740762
attributes,
763+
commonProperties,
741764
documentOids,
742765
securityLabelUpdates,
743766
primaryFile,
@@ -759,6 +782,11 @@ export const WindchillBlock: BlockConfig<WindchillResponse> = {
759782
...(attributes === undefined || attributes === ''
760783
? {}
761784
: { attributes: parseJsonField(attributes, 'attributes', 'object') }),
785+
...(commonProperties === undefined || commonProperties === ''
786+
? {}
787+
: {
788+
commonProperties: parseJsonField(commonProperties, 'commonProperties', 'object'),
789+
}),
762790
...(documentOids === undefined || documentOids === ''
763791
? {}
764792
: { documentOids: parseJsonField(documentOids, 'documentOids', 'array') }),
@@ -800,6 +828,7 @@ export const WindchillBlock: BlockConfig<WindchillResponse> = {
800828
containerOid: { type: 'string', description: 'Container OID' },
801829
folderOid: { type: 'string', description: 'Folder OID' },
802830
attributes: { type: 'json', description: 'Document attributes' },
831+
commonProperties: { type: 'json', description: 'Common document properties' },
803832
documents: { type: 'array', description: 'Bulk document inputs' },
804833
checkOutNote: { type: 'string', description: 'Checkout note' },
805834
checkInNote: { type: 'string', description: 'Check-in note' },

apps/sim/lib/api/contracts/tools/windchill.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,14 @@ const patchAttributesSchema = attributesSchema
130130
})
131131
.refine(
132132
(attributes) => !Object.keys(attributes).some((key) => COMMON_DOCUMENT_PROPERTIES.has(key)),
133-
'Name, Number, and Organization must be changed with Windchill UpdateCommonProperties and are not supported by this operation'
133+
'Name, Number, and Organization must be changed with the Update Common Properties operation and are not supported here'
134134
)
135135

136+
const commonPropertiesSchema = attributesSchema.refine(
137+
(properties) => Object.keys(properties).length > 0,
138+
{ message: 'At least one common property is required' }
139+
)
140+
136141
const credentialsSchema = z.object({
137142
baseUrl: baseUrlSchema,
138143
username: credentialSchema,
@@ -183,6 +188,11 @@ const commonMutationShapes = {
183188
documentOid: oidSchema,
184189
attributes: patchAttributesSchema,
185190
}),
191+
updateCommonProperties: credentialsSchema.extend({
192+
operation: z.literal('windchill_update_common_properties'),
193+
documentOid: oidSchema,
194+
commonProperties: commonPropertiesSchema,
195+
}),
186196
updateDocuments: credentialsSchema.extend({
187197
operation: z.literal('windchill_update_documents'),
188198
documents: z
@@ -298,6 +308,7 @@ export const windchillOperationBodySchema = z.discriminatedUnion('operation', [
298308
commonMutationShapes.createDocument,
299309
commonMutationShapes.createDocuments,
300310
commonMutationShapes.updateDocument,
311+
commonMutationShapes.updateCommonProperties,
301312
commonMutationShapes.updateDocuments,
302313
commonMutationShapes.deleteDocument,
303314
commonMutationShapes.deleteDocuments,
@@ -346,6 +357,7 @@ const affectedIdsSchema = z.array(returnedOidSchema)
346357
const singleMutationOperationSchema = z.enum([
347358
'windchill_create_document',
348359
'windchill_update_document',
360+
'windchill_update_common_properties',
349361
'windchill_check_out_document',
350362
'windchill_check_in_document',
351363
'windchill_undo_check_out_document',

apps/sim/lib/integrations/integrations.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21986,6 +21986,10 @@
2198621986
"name": "Update Document",
2198721987
"description": "Update one document's editable attributes"
2198821988
},
21989+
{
21990+
"name": "Update Common Properties",
21991+
"description": "Update a document's Name, Number, and other common properties"
21992+
},
2198921993
{
2199021994
"name": "Update Documents",
2199121995
"description": "Update several documents' editable attributes in one atomic request"
@@ -22055,7 +22059,7 @@
2205522059
"description": "Upload one or more files as document attachments"
2205622060
}
2205722061
],
22058-
"operationCount": 26,
22062+
"operationCount": 27,
2205922063
"triggers": [],
2206022064
"triggerCount": 0,
2206122065
"authType": "api-key",

apps/sim/tools/generated/tool-ids.ts

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

apps/sim/tools/generated/tool-metadata.ts

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

apps/sim/tools/generated/tool-outputs.ts

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

apps/sim/tools/registry.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4790,6 +4790,7 @@ import {
47904790
windchillSetLifecycleStateTool,
47914791
windchillUndoCheckOutDocumentsTool,
47924792
windchillUndoCheckOutDocumentTool,
4793+
windchillUpdateCommonPropertiesTool,
47934794
windchillUpdateDocumentSecurityLabelsTool,
47944795
windchillUpdateDocumentsTool,
47954796
windchillUpdateDocumentTool,
@@ -8682,6 +8683,7 @@ export const tools: Record<string, ToolConfig> = {
86828683
windchill_set_lifecycle_state: windchillSetLifecycleStateTool,
86838684
windchill_undo_check_out_document: windchillUndoCheckOutDocumentTool,
86848685
windchill_undo_check_out_documents: windchillUndoCheckOutDocumentsTool,
8686+
windchill_update_common_properties: windchillUpdateCommonPropertiesTool,
86858687
windchill_update_document: windchillUpdateDocumentTool,
86868688
windchill_update_document_security_labels: windchillUpdateDocumentSecurityLabelsTool,
86878689
windchill_update_documents: windchillUpdateDocumentsTool,

0 commit comments

Comments
 (0)