Skip to content

Commit 35b8dc3

Browse files
feat: add staging deploy command and update config page with call to a gdoc app function (#10248)
1 parent a2139e9 commit 35b8dc3

4 files changed

Lines changed: 38 additions & 13 deletions

File tree

apps/google-docs/contentful-app-manifest.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
]
3434
},
3535
{
36-
"id": "initiateOauth",
37-
"name": "Initiate OAuth",
36+
"id": "initiateGdocOauth",
37+
"name": "Initiate Gdoc OAuth Flow",
3838
"description": "Initiates the OAuth flow for Google Docs",
3939
"path": "functions/initiateOauth.js",
4040
"entryFile": "functions/initiateOauth.ts",
@@ -46,8 +46,8 @@
4646
]
4747
},
4848
{
49-
"id": "completeOauth",
50-
"name": "Complete OAuth",
49+
"id": "completeGdocOauth",
50+
"name": "Complete Gdoc OAuth Flow",
5151
"description": "Completes the OAuth flow for Google Docs",
5252
"path": "functions/completeOauth.js",
5353
"entryFile": "functions/completeOauth.ts",
@@ -59,9 +59,9 @@
5959
]
6060
},
6161
{
62-
"id": "disconnect",
63-
"name": "Disconnect",
64-
"description": "Disconnects the Google Docs app",
62+
"id": "revokeGdocOauthToken",
63+
"name": "Revoke Gdoc OAuth Token",
64+
"description": "Revoke token for the Google Docs app to disconnect from the app",
6565
"path": "functions/disconnect.js",
6666
"entryFile": "functions/disconnect.ts",
6767
"allowNetworks": [
@@ -72,9 +72,9 @@
7272
]
7373
},
7474
{
75-
"id": "checkStatus",
76-
"name": "Check Status",
77-
"description": "Checks the status of the Google Docs app",
75+
"id": "checkGdocOauthTokenStatus",
76+
"name": "Check Gdoc OAuth Token Status",
77+
"description": "Checks the status of the Google Docs OAuth token to see if it is valid",
7878
"path": "functions/checkStatus.js",
7979
"entryFile": "functions/checkStatus.ts",
8080
"allowNetworks": [

apps/google-docs/functions/createEntriesFromDocument.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { createDocument } from './agents/documentParser.agent';
1212
// import { createEntries, createAssets } from './service/entryService';
1313

1414
export type AppActionParameters = {
15-
contentType: string;
15+
contentTypeId: string;
1616
prompt: string;
1717
};
1818
interface AppInstallationParameters {
@@ -30,7 +30,7 @@ export const handler: FunctionEventHandler<
3030
event: AppActionRequest<'Custom', AppActionParameters>,
3131
context: FunctionEventContext
3232
) => {
33-
const { contentType, prompt } = event.body;
33+
const { contentTypeId, prompt } = event.body;
3434
const { openAiApiKey } = context.appInstallationParameters as AppInstallationParameters;
3535

3636
// INTEG-3262 and INTEG-3263: Take in Content Type, Prompt, and Upload File from user

apps/google-docs/package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@
2828
"upload": "contentful-app-scripts upload --bundle-dir ./build",
2929
"upload-ci": "contentful-app-scripts upload --ci --bundle-dir ./build --organization-id $CONTENTFUL_ORG_ID --definition-id $CONTENTFUL_APP_DEF_ID --token $CONTENTFUL_ACCESS_TOKEN",
3030
"deploy": "contentful-app-scripts upload --ci --bundle-dir ./build --organization-id ${DEFINITIONS_ORG_ID} --definition-id 3EaGZUMKRKVZUyrcoNJ4o4 --token ${CONTENTFUL_CMA_TOKEN}",
31-
"deploy:dev": "npm run build && source .env && contentful-app-scripts upload --ci --bundle-dir ./build --organization-id \"$DEFINITIONS_ORG_ID\" --definition-id 653vTnuQw3j5onU1tUoH6t --token \"$CONTENTFUL_CMA_TOKEN\""
31+
"deploy:dev": "npm run build && source .env && contentful-app-scripts upload --ci --bundle-dir ./build --organization-id $CONTENTFUL_ORG_ID --definition-id 653vTnuQw3j5onU1tUoH6t --token \"$CONTENTFUL_CMA_TOKEN\"",
32+
"deploy:staging": "npm run build && source .env && contentful-app-scripts upload --ci --bundle-dir ./build --organization-id $CONTENTFUL_ORG_ID --definition-id 4i0mp5lQtgNsHYVrD5jIkj --token \"$CONTENTFUL_CMA_TOKEN\""
33+
3234
},
3335
"eslintConfig": {
3436
"extends": "react-app"

apps/google-docs/src/locations/ConfigScreen.tsx

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,29 @@ const ConfigScreen = () => {
404404
style={{ flex: 1 }}
405405
/>
406406
</Box>
407+
<Button
408+
onClick={async () => {
409+
const appActions = await sdk.cma.appAction.getManyForEnvironment({
410+
environmentId: sdk.ids.environment,
411+
spaceId: sdk.ids.space,
412+
});
413+
const initiateOauthAppAction = appActions.items.find(
414+
(action) => action.name === 'createEntriesFromDocumentAction'
415+
);
416+
const response = await sdk.cma.appActionCall.createWithResponse(
417+
{
418+
appActionId: initiateOauthAppAction?.sys.id || '',
419+
appDefinitionId: sdk.ids.app,
420+
},
421+
{
422+
parameters: {},
423+
}
424+
);
425+
426+
console.log(JSON.parse(response.response.body));
427+
}}>
428+
Create entries from document
429+
</Button>
407430
<Paragraph marginTop="spacingS">
408431
Find your OpenAPI key{' '}
409432
<a

0 commit comments

Comments
 (0)