Skip to content

Conversation

@field123
Copy link
Collaborator

Summary

Add support for updating global context props via the updateProjectData API endpoint. This enables commerce-manager to configure global
context providers (like the Elastic Path Provider) when cloning templates.

Changes

  • Add UpdateGlobalContextReq type to ApiSchema.ts
  • Add updateGlobalContexts field to UpdateProjectReq
  • Extract global context update logic to global-context-utils.ts module
  • Integrate with updateProjectData endpoint in projects.ts

Testing

  • Unit tests (global-context-utils.spec.ts): 8 tests covering pure function logic

    • Empty updates
    • Successful prop updates
    • Warning when global context not found
    • Warning when prop not found
    • Multiple updates with warnings
    • No variant settings edge case
    • Null and boolean prop values
  • Integration tests (projects.spec.ts): 6 tests covering API endpoint

    • Warning when global context not found
    • Empty updates succeed
    • Multiple non-existent contexts
    • Warning when prop not found on global context
    • Successfully update global context props
    • Persist global context updates

Usage

await updateProjectData({                                                                                                                     
  client: plasmic.client,                                                                                                                     
  path: { projectId },                                                                                                                        
  body: {                                                                                                                                     
    updateGlobalContexts: [{                                                                                                                  
      name: "plasmic-commerce-elastic-path-provider",                                                                                         
      props: {                                                                                                                                
        clientId: "my-client-id",                                                                                                             
        host: "https://api.elasticpath.com"                                                                                                   
      }                                                                                                                                       
    }]                                                                                                                                        
  }                                                                                                                                           
})                                                                                                                                            

Test Plan

  • Unit tests pass: yarn test global-context-utils.spec
  • Integration tests pass: yarn test projects.spec

Add support for updating global context props via the updateProjectData API.
This enables the commerce-manager to configure global context providers
(like the Elastic Path Provider) when cloning templates.

Changes:
- Add UpdateGlobalContextReq type to ApiSchema
- Extract global context update logic to global-context-utils.ts
- Add unit tests for pure functions (8 tests)
- Add integration tests for API endpoint (6 tests)
@field123 field123 merged commit ceedab3 into master Jan 26, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants