Skip to content

Commit 973bf25

Browse files
committed
Bunch of fixes the OpenBlocks team included in the EE Docker images, but not on their GitHub.
1 parent 28540e7 commit 973bf25

File tree

5 files changed

+37
-9
lines changed

5 files changed

+37
-9
lines changed

server/node-service/src/plugins/bigQuery/dataSourceConfig.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export const dataSourceConfig = {
55
params: [
66
{
77
key: "privateKey",
8-
label: "Private Key",
8+
label: "Service Account",
99
type: "password",
1010
tooltip:
1111
"The private key associated with a Service Account with Big Query privileges, [Documentation](https://cloud.google.com/iam/docs/service-accounts) for service accounts.",

server/node-service/src/plugins/openApi/index.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const dataSourceConfig = {
2525
label: "Spec URL",
2626
key: "url",
2727
type: "textInput",
28-
updatable: true,
28+
updatable: false,
2929
rules: [
3030
{
3131
required: true,
@@ -146,11 +146,18 @@ const openApiPlugin: DataSourcePlugin<ActionDataType, DataSourceDataType> = {
146146
dataSourceConfig: {
147147
...dataSourceConfig,
148148
extra: async (dataSourceConfig) => {
149-
// called whenever datasource config opens or changes
150-
const { url} = dataSourceConfig;
151-
const { spec: specObj} = await retrieveSpec(url);
149+
const { url, extra } = dataSourceConfig;
150+
let spec: string = extra?.spec;
151+
let specObj: OpenAPI.Document;
152+
if (!spec) {
153+
// retrieve spec from remote only once
154+
const { spec: remoteSpec } = await retrieveSpec(url);
155+
specObj = remoteSpec;
156+
spec = JSON.stringify(remoteSpec);
157+
} else {
158+
specObj = safeJsonParse(spec);
159+
}
152160
const extraParams = await authParamsConfig(specObj);
153-
const spec = JSON.stringify(specObj);
154161
return {
155162
data: {
156163
spec,

server/node-service/src/plugins/sendGrid/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,10 @@ const dataSourceConfig = {
2121

2222
const parseOptions: ParseOpenApiOptions = {
2323
actionLabel: (method: string, path: string, operation: OpenAPI.Operation) =>
24-
operation.operationId?.replace("_", " ") || "",
24+
operation.summary || "",
25+
actionDescription: (method: string, path: string, operation: OpenAPI.Operation) => {
26+
return operation.description || "";
27+
}
2528
};
2629

2730
type DataSourceConfigType = ConfigToType<typeof dataSourceConfig>;

server/node-service/src/plugins/shopify/index.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,14 @@ export const dataSourceConfig = {
1111
label: "Endpoint",
1212
key: "endpoint",
1313
rules: [{ required: true }],
14+
placeholder: "https://{shop}.myshopify.com/admin/api/2023-01/graphql.json",
1415
},
16+
{
17+
type: "password",
18+
label: "Access Token",
19+
key: "token",
20+
rules: [{ required: true }],
21+
}
1522
],
1623
} as const;
1724

@@ -28,7 +35,11 @@ const shopifyPlugin: DataSourcePlugin<
2835
run: function (actionData, dataSourceConfig, context: PluginContext): Promise<any> {
2936
const { query, variables: variableKvs, headers: queryHeaders } = actionData;
3037
const variables = kvToRecord(variableKvs);
31-
return runGraphQL(dataSourceConfig.endpoint, query, variables, {});
38+
const headers = {
39+
...kvToRecord(queryHeaders),
40+
'X-Shopify-Access-Token': dataSourceConfig.token
41+
};
42+
return runGraphQL(dataSourceConfig.endpoint, query, variables, headers);
3243
},
3344
};
3445

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { DataSourceDataType } from "./dataSourceConfig";
22
import { ActionDataType } from "./queryConfig";
33
import { fetch } from "../../common/fetch";
4+
import { ServiceError } from "../../common/error";
45

56
export default async function run(action: ActionDataType, dataSourceConfig: DataSourceDataType) {
67
const params = new URLSearchParams();
@@ -9,5 +10,11 @@ export default async function run(action: ActionDataType, dataSourceConfig: Data
910
return await fetch(dataSourceConfig.webhookURL, {
1011
method: "POST",
1112
body: params,
12-
}).then((value) => value.text());
13+
}).then(async (value) => {
14+
const msg = await value.text();
15+
if (!value.ok) {
16+
throw new ServiceError(msg, value.status)
17+
}
18+
return msg;
19+
});
1320
}

0 commit comments

Comments
 (0)