Skip to content

Commit 9a11434

Browse files
fix action and add clientVersion
1 parent 2105a54 commit 9a11434

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

src/oc-client.js

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* globals __REGISTERED_TEMPLATES_PLACEHOLDER__, __DEFAULT_RETRY_INTERVAL__, __DEFAULT_RETRY_LIMIT__, __DEFAULT_DISABLE_LOADER__, __DISABLE_LEGACY_TEMPLATES__, __EXTERNALS__ */
1+
/* globals __CLIENT_VERSION__, __REGISTERED_TEMPLATES_PLACEHOLDER__, __DEFAULT_RETRY_INTERVAL__, __DEFAULT_RETRY_LIMIT__, __DEFAULT_DISABLE_LOADER__, __DISABLE_LEGACY_TEMPLATES__, __EXTERNALS__ */
22
import { decode } from "turbo-stream";
33

44
export function createOc(oc) {
@@ -10,6 +10,7 @@ export function createOc(oc) {
1010
oc.conf = oc.conf || {};
1111
oc.cmd = oc.cmd || [];
1212
oc.renderedComponents = oc.renderedComponents || {};
13+
oc.clientVersion = __CLIENT_VERSION__;
1314

1415
let isRequired = (name, value) => {
1516
if (!value) {
@@ -236,21 +237,26 @@ export function createOc(oc) {
236237
cb = cb || noop;
237238
let version = options.version,
238239
baseUrl = options.baseUrl,
239-
name = options.name,
240-
json = options.json;
240+
name = options.name;
241241
isRequired("version", version);
242242
isRequired("baseUrl", baseUrl);
243243
isRequired("name", name);
244-
let data = {
245-
components: [
246-
{
247-
action: options.action,
248-
name: name,
249-
version: version,
250-
parameters: { ...ocConf.globalParameters, ...options.parameters },
251-
},
252-
],
253-
};
244+
if (options.action) {
245+
baseUrl = `${baseUrl}~actions/${options.action}/${options.name}/${options.version || ""}`;
246+
}
247+
let parameters = { ...ocConf.globalParameters, ...options.parameters };
248+
let data = options.action
249+
? parameters
250+
: {
251+
components: [
252+
{
253+
action: options.action,
254+
name: name,
255+
version: version,
256+
parameters,
257+
},
258+
],
259+
};
254260
let headers = getHeaders();
255261

256262
fetch(baseUrl, {

tasks/compile.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,7 @@ function getBuildOptions(conf = {}) {
8888
__DISABLE_LEGACY_TEMPLATES__: JSON.stringify(
8989
parsedConf.disableLegacyTemplates,
9090
),
91+
__CLIENT_VERSION__: JSON.stringify(packageJson.version),
9192
},
9293
bundle: true,
9394
minify: false,

0 commit comments

Comments
 (0)