Skip to content

Commit b4800e6

Browse files
Expand Intents API documentation with invoke, types, and examples
1 parent d241b0d commit b4800e6

File tree

1 file changed

+76
-9
lines changed
  • packages/ui-extensions/docs/surfaces/customer-account/reference/apis

1 file changed

+76
-9
lines changed

packages/ui-extensions/docs/surfaces/customer-account/reference/apis/intents.doc.ts

Lines changed: 76 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,14 @@ const data: ReferenceEntityTemplateSchema = {
44
name: 'Intents',
55
overviewPreviewDescription:
66
'The API for invoking Shopify intents to request workflows.',
7-
description: `Entry point for Shopify intents. Intents pair an \`action\` (verb) with a resource \`type\` and optional \`value\` and \`data\` to request a workflow.`,
7+
description: `The Intents API provides a way to invoke existing customer account workflows for managing buyer information.`,
88
isVisualComponent: false,
99
category: 'APIs',
1010
type: 'API',
11-
definitions: [
12-
{
13-
title: 'Intents',
14-
description: 'Intents API for invoking Shopify workflows.',
15-
type: 'Intents',
16-
},
17-
],
1811
defaultExample: {
1912
description: '',
2013
codeblock: {
21-
title: 'Extension.jsx',
14+
title: 'Replace payment method',
2215
tabs: [
2316
{
2417
code: '../examples/apis/intents.example.jsx',
@@ -27,6 +20,80 @@ const data: ReferenceEntityTemplateSchema = {
2720
],
2821
},
2922
},
23+
definitions: [
24+
{
25+
title: 'invoke',
26+
description: `The \`invoke\` API is a function that accepts either a string query or an options object describing the intent to invoke and returns a Promise that resolves to an activity handle for the workflow.
27+
28+
## Intent Format
29+
30+
Intents are invoked using a string query format: \`\${action}:\${type},\${value}\`
31+
32+
Where:
33+
- \`action\` - The operation to perform (\`create\`, \`edit\` or \`open\`)
34+
- \`type\` - The resource type (e.g., \`shopify/SubscriptionContract\`)
35+
- \`value\` - The resource identifier
36+
37+
## Supported Resources
38+
39+
### Subscription Contract
40+
| Action | Type | Value | Data |
41+
|--------|------|-------|------|
42+
| \`open\` | \`shopify/SubscriptionContract\` | \`gid://shopify/SubscriptionContract/{id}\` | \`{ field: 'paymentMethod' }\` |`,
43+
type: 'Intents',
44+
},
45+
{
46+
title: 'IntentAction',
47+
description: `Supported actions that can be performed on resources.
48+
- \`create\`: Opens a creation workflow for a new resource
49+
- \`edit\`: Opens an editing workflow for an existing resource (requires \`value\` parameter)
50+
- \`open\`: Opens a workflow for an existing resource (requires \`value\` parameter)`,
51+
type: 'IntentAction',
52+
},
53+
{
54+
title: 'IntentQuery',
55+
description: `Structured description of an intent to invoke. Use this object form when programmatically composing an intent at runtime.`,
56+
type: 'IntentQuery',
57+
},
58+
{
59+
title: 'IntentQueryOptions',
60+
description: `Options for invoking intents when using the query string format.`,
61+
type: 'IntentQueryOptions',
62+
},
63+
{
64+
title: 'IntentActivity',
65+
description: `Activity handle for tracking intent workflow progress.`,
66+
type: 'IntentActivity',
67+
},
68+
{
69+
title: 'IntentResponse',
70+
description: `Response object returned when the intent workflow completes.`,
71+
type: 'IntentResponse',
72+
},
73+
],
74+
examples: {
75+
description: 'Intents for each Shopify resource type',
76+
exampleGroups: [
77+
{
78+
title: 'Subscription Contract',
79+
examples: [
80+
{
81+
description:
82+
'Replace the payment method on an active subscription contract. Opens a modal with vaulted cards.',
83+
codeblock: {
84+
title: 'Replace payment method',
85+
tabs: [
86+
{
87+
code: '../examples/apis/intents.example.jsx',
88+
language: 'jsx',
89+
},
90+
],
91+
},
92+
},
93+
],
94+
},
95+
],
96+
},
3097
related: [],
3198
};
3299

0 commit comments

Comments
 (0)