@commercetools/cli-topic-integration-layer 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/commands/integration-layer/extension/invoke-api-extension.d.ts +13 -4
- package/dist/commands/integration-layer/extension/invoke-api-extension.js +81 -36
- package/dist/commands/integration-layer/extension/invoke-api-extension.js.map +1 -1
- package/dist/commands/integration-layer/extension/serve-api-extension.d.ts +35 -0
- package/dist/commands/integration-layer/extension/serve-api-extension.js +379 -0
- package/dist/commands/integration-layer/extension/serve-api-extension.js.map +1 -0
- package/dist/commands/integration-layer/extension/serve.js +6 -0
- package/dist/commands/integration-layer/extension/serve.js.map +1 -1
- package/dist/lib/apiExtensionServer.d.ts +22 -0
- package/dist/lib/apiExtensionServer.js +97 -0
- package/dist/lib/apiExtensionServer.js.map +1 -0
- package/dist/lib/ctExtensions.d.ts +102 -0
- package/dist/lib/ctExtensions.js +162 -0
- package/dist/lib/ctExtensions.js.map +1 -0
- package/dist/lib/ilClient.d.ts +28 -0
- package/dist/lib/ilClient.js +37 -0
- package/dist/lib/ilClient.js.map +1 -1
- package/dist/lib/tooling/apiExtensionDispatch.d.ts +32 -0
- package/dist/lib/tooling/apiExtensionDispatch.js +71 -0
- package/dist/lib/tooling/apiExtensionDispatch.js.map +1 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@ commercetools integration-layer init [DIR] # scaffold an extens
|
|
|
30
30
|
|
|
31
31
|
commercetools integration-layer extension build # bundle src/extension.ts → dist [offline]
|
|
32
32
|
commercetools integration-layer extension serve # local dev server; allowlist-gated fetch when online + logged in
|
|
33
|
-
commercetools integration-layer extension invoke-api-extension # fire an API-Extension callback
|
|
33
|
+
commercetools integration-layer extension invoke-api-extension # fire an API-Extension callback at the local bundle [offline], or --deployed via the IL
|
|
34
34
|
|
|
35
35
|
commercetools integration-layer explore # local GraphQL explorer over your deployed edge
|
|
36
36
|
commercetools integration-layer schema fetch # the Project's core-subgraph SDL
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export default class ExtensionInvokeApiExtension extends
|
|
1
|
+
import { IntegrationLayerCommand } from "../../../lib/base.js";
|
|
2
|
+
export default class ExtensionInvokeApiExtension extends IntegrationLayerCommand {
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
|
+
protected authorized: boolean;
|
|
5
6
|
static flags: {
|
|
6
|
-
"env-file": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
7
|
entry: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
8
|
out: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
9
|
all: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
@@ -11,9 +11,18 @@ export default class ExtensionInvokeApiExtension extends Command {
|
|
|
11
11
|
input: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
12
|
key: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
13
|
config: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
14
|
+
deployed: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
14
15
|
};
|
|
15
|
-
protected init(): Promise<void>;
|
|
16
16
|
/** Read and validate the `--input` ExtensionInput JSON file. */
|
|
17
17
|
private loadInput;
|
|
18
18
|
run(): Promise<void>;
|
|
19
|
+
/**
|
|
20
|
+
* Fire the callback at the project's DEPLOYED extension via the integration layer's
|
|
21
|
+
* signing proxy, and print the connector's verdict. The IL is the only party that can
|
|
22
|
+
* sign the connector's `/api-extensions` call (the shared secret never leaves it), so
|
|
23
|
+
* the CLI hands it the payload and renders what comes back. Nothing is persisted.
|
|
24
|
+
*/
|
|
25
|
+
private runDeployed;
|
|
26
|
+
/** Invoke the bundle's handlers IN-PROCESS against the supplied payload (offline). */
|
|
27
|
+
private runLocal;
|
|
19
28
|
}
|
|
@@ -1,43 +1,38 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
|
-
import {
|
|
2
|
+
import { Flags } from "@oclif/core";
|
|
3
3
|
import { defaultEntry, defaultOutfile } from "../../../lib/tooling/build.js";
|
|
4
4
|
import { bundleForFlags } from "../../../lib/tooling/extensions.js";
|
|
5
5
|
import { loadBundleSource } from "../../../lib/tooling/loadBundle.js";
|
|
6
|
+
import { describeResult, extractApiExtensions, handlerMatches, } from "../../../lib/tooling/apiExtensionDispatch.js";
|
|
6
7
|
import { extensionConfigFromEnv, extensionConfigFromPairs } from "../../../lib/extensionConfig.js";
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
return `BLOCK — ${result.errors.map((e) => `${e.code}: ${e.message}`).join("; ")}`;
|
|
12
|
-
}
|
|
13
|
-
if (Array.isArray(result.actions) && result.actions.length > 0) {
|
|
14
|
-
return `MODIFY — ${JSON.stringify(result.actions)}`;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
return "APPROVE";
|
|
18
|
-
}
|
|
19
|
-
export default class ExtensionInvokeApiExtension extends Command {
|
|
20
|
-
static description = "Fire a commercetools API-Extension callback from a supplied payload at the bundle's handlers";
|
|
8
|
+
import { IntegrationLayerCommand } from "../../../lib/base.js";
|
|
9
|
+
import { invokeDeployedApiExtension } from "../../../lib/ilClient.js";
|
|
10
|
+
export default class ExtensionInvokeApiExtension extends IntegrationLayerCommand {
|
|
11
|
+
static description = "Fire a commercetools API-Extension callback from a supplied payload — at the LOCAL bundle's handlers, or (with --deployed) at the project's DEPLOYED extension through the Commerce Integration Layer";
|
|
21
12
|
static examples = [
|
|
22
13
|
"<%= config.bin %> integration-layer extension invoke-api-extension --input ./payloads/cart-create.json",
|
|
23
14
|
"<%= config.bin %> integration-layer extension invoke-api-extension --input ./payloads/order-create.json --key order-tagger",
|
|
24
15
|
"<%= config.bin %> integration-layer extension invoke-api-extension --all --input ./payload.json --config MAX_QTY=5",
|
|
16
|
+
"<%= config.bin %> integration-layer extension invoke-api-extension --deployed --input ./payloads/cart-create.json",
|
|
25
17
|
];
|
|
18
|
+
// Local (in-process) invocation needs no login; --deployed resolves the context
|
|
19
|
+
// lazily and then requires a logged-in principal (see run → runDeployed).
|
|
20
|
+
authorized = false;
|
|
26
21
|
static flags = {
|
|
27
|
-
"env-file": Flags.string({
|
|
28
|
-
description: "dotenv file to load before the command runs (default: .env in the cwd, if present); does not override variables already set in the environment",
|
|
29
|
-
}),
|
|
30
22
|
entry: Flags.string({
|
|
31
|
-
description: "extension entry source file (with --all: the per-package source segment applied under each ./extensions/*)",
|
|
23
|
+
description: "extension entry source file (with --all: the per-package source segment applied under each ./extensions/*); local invocation only",
|
|
32
24
|
default: defaultEntry(),
|
|
33
25
|
}),
|
|
34
|
-
out: Flags.string({
|
|
26
|
+
out: Flags.string({
|
|
27
|
+
description: "bundle output file; local invocation only",
|
|
28
|
+
default: defaultOutfile(),
|
|
29
|
+
}),
|
|
35
30
|
all: Flags.boolean({
|
|
36
|
-
description: "invoke the ONE combined bundle merged from every extension under ./extensions/* (the deployed shape)",
|
|
31
|
+
description: "invoke the ONE combined bundle merged from every extension under ./extensions/* (the deployed shape); local invocation only",
|
|
37
32
|
default: false,
|
|
38
33
|
}),
|
|
39
34
|
"extensions-dir": Flags.string({
|
|
40
|
-
description: "directory holding the extension packages (used with --all)",
|
|
35
|
+
description: "directory holding the extension packages (used with --all); local invocation only",
|
|
41
36
|
default: "extensions",
|
|
42
37
|
}),
|
|
43
38
|
input: Flags.string({
|
|
@@ -45,22 +40,20 @@ export default class ExtensionInvokeApiExtension extends Command {
|
|
|
45
40
|
required: true,
|
|
46
41
|
}),
|
|
47
42
|
key: Flags.string({
|
|
48
|
-
description: "only invoke handlers with this key (repeatable)",
|
|
43
|
+
description: "only invoke handlers with this key (repeatable); local invocation only — the deployed connector returns one merged verdict",
|
|
49
44
|
multiple: true,
|
|
50
45
|
delimiter: ",",
|
|
51
46
|
}),
|
|
52
47
|
config: Flags.string({
|
|
53
|
-
description: "a ctx.config entry as KEY=VALUE (repeatable); overrides EXTENSION_CONFIG_* from the environment / .env",
|
|
48
|
+
description: "a ctx.config entry as KEY=VALUE (repeatable); overrides EXTENSION_CONFIG_* from the environment / .env; local invocation only — --deployed uses the project's stored config",
|
|
54
49
|
multiple: true,
|
|
55
50
|
delimiter: ",",
|
|
56
51
|
}),
|
|
52
|
+
deployed: Flags.boolean({
|
|
53
|
+
description: "fire the callback at the project's DEPLOYED extension through the Commerce Integration Layer (requires `commercetools auth login`) instead of running the local bundle in-process",
|
|
54
|
+
default: false,
|
|
55
|
+
}),
|
|
57
56
|
};
|
|
58
|
-
async init() {
|
|
59
|
-
// Load `.env` / `--env-file` into process.env before flags parse, so
|
|
60
|
-
// EXTENSION_CONFIG_* is visible below (an already-set shell variable still wins).
|
|
61
|
-
loadLocalEnv();
|
|
62
|
-
await super.init();
|
|
63
|
-
}
|
|
64
57
|
/** Read and validate the `--input` ExtensionInput JSON file. */
|
|
65
58
|
async loadInput(inputPath) {
|
|
66
59
|
let parsed;
|
|
@@ -84,7 +77,62 @@ export default class ExtensionInvokeApiExtension extends Command {
|
|
|
84
77
|
return { action: obj.action, resource };
|
|
85
78
|
}
|
|
86
79
|
async run() {
|
|
87
|
-
const { flags } = await this.parse(ExtensionInvokeApiExtension);
|
|
80
|
+
const { flags, metadata } = await this.parse(ExtensionInvokeApiExtension);
|
|
81
|
+
if (flags.deployed) {
|
|
82
|
+
// --deployed reaches the DEPLOYED extension through the integration layer, so the
|
|
83
|
+
// local-bundle knobs (which build/merge/configure a bundle here) are meaningless
|
|
84
|
+
// — reject them loudly rather than silently ignore. `entry`/`out`/`extensions-dir`
|
|
85
|
+
// carry defaults, so only complain when the user set them explicitly.
|
|
86
|
+
const localOnly = [];
|
|
87
|
+
if (flags.all)
|
|
88
|
+
localOnly.push("--all");
|
|
89
|
+
if (flags.config && flags.config.length > 0)
|
|
90
|
+
localOnly.push("--config");
|
|
91
|
+
if (flags.key && flags.key.length > 0)
|
|
92
|
+
localOnly.push("--key");
|
|
93
|
+
for (const name of ["entry", "out", "extensions-dir"]) {
|
|
94
|
+
if (metadata.flags[name] && !metadata.flags[name].setFromDefault)
|
|
95
|
+
localOnly.push(`--${name}`);
|
|
96
|
+
}
|
|
97
|
+
if (localOnly.length > 0) {
|
|
98
|
+
this.error(`--deployed fires the callback at the DEPLOYED extension through the Commerce Integration Layer, ` +
|
|
99
|
+
`so it can't be combined with the local-bundle flag(s): ${localOnly.join(", ")}. ` +
|
|
100
|
+
`--deployed uses the deployed code and the project's stored config, and returns the ` +
|
|
101
|
+
`connector's single merged verdict (there is no per-key breakdown).`);
|
|
102
|
+
}
|
|
103
|
+
await this.runDeployed(flags);
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
await this.runLocal(flags);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Fire the callback at the project's DEPLOYED extension via the integration layer's
|
|
110
|
+
* signing proxy, and print the connector's verdict. The IL is the only party that can
|
|
111
|
+
* sign the connector's `/api-extensions` call (the shared secret never leaves it), so
|
|
112
|
+
* the CLI hands it the payload and renders what comes back. Nothing is persisted.
|
|
113
|
+
*/
|
|
114
|
+
async runDeployed(flags) {
|
|
115
|
+
const input = await this.loadInput(flags.input);
|
|
116
|
+
const { action, resource } = input;
|
|
117
|
+
const { baseUrl, projectKey, authFetch } = await this.resolveIlContext(flags);
|
|
118
|
+
// Deployed is ALWAYS the live extension — say so before firing. It runs the real
|
|
119
|
+
// callback against the deployed connector; it just doesn't persist the write.
|
|
120
|
+
this.warn(`invoking the LIVE deployed extension for project '${projectKey}' — this runs the real ` +
|
|
121
|
+
`API-Extension callback against the deployed connector (no write is persisted to commercetools)`);
|
|
122
|
+
this.log(`Invoking the deployed extension with a ${action} on ${resource.typeId} …`);
|
|
123
|
+
const { status, result } = await invokeDeployedApiExtension(baseUrl, projectKey, authFetch, input);
|
|
124
|
+
// 200 (approve/modify) and 400 (block) are the extension's VERDICT — render them.
|
|
125
|
+
// Any other status is the connector failing to answer cleanly, not a decision.
|
|
126
|
+
if (status === 200 || status === 400) {
|
|
127
|
+
this.log(` → ${describeResult(result)} (connector HTTP ${status})`);
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
this.warn(`the deployed extension returned HTTP ${status} (not an approve/modify/block verdict): ` +
|
|
131
|
+
`${typeof result === "string" ? result : JSON.stringify(result)}`);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
/** Invoke the bundle's handlers IN-PROCESS against the supplied payload (offline). */
|
|
135
|
+
async runLocal(flags) {
|
|
88
136
|
// Environment / `.env` first; an explicit `--config` wins on the same key.
|
|
89
137
|
const config = {
|
|
90
138
|
...extensionConfigFromEnv(),
|
|
@@ -102,10 +150,7 @@ export default class ExtensionInvokeApiExtension extends Command {
|
|
|
102
150
|
catch (err) {
|
|
103
151
|
this.error(err.message);
|
|
104
152
|
}
|
|
105
|
-
const
|
|
106
|
-
const handlers = Array.isArray(mod.apiExtensions)
|
|
107
|
-
? mod.apiExtensions
|
|
108
|
-
: [];
|
|
153
|
+
const handlers = extractApiExtensions(loadBundleSource(await readFile(outfile, "utf8")));
|
|
109
154
|
if (handlers.length === 0) {
|
|
110
155
|
this.error("this bundle declares no `apiExtensions`.");
|
|
111
156
|
}
|
|
@@ -128,7 +173,7 @@ export default class ExtensionInvokeApiExtension extends Command {
|
|
|
128
173
|
const ctx = { now: () => Date.now(), config };
|
|
129
174
|
this.log(`Invoking ${selected.length} handler(s) with a ${action} on ${resourceType}`);
|
|
130
175
|
for (const h of selected) {
|
|
131
|
-
if (h
|
|
176
|
+
if (!handlerMatches(h, resourceType, action)) {
|
|
132
177
|
this.log(` · ${h.key}: skipped (does not trigger on ${resourceType}/${action})`);
|
|
133
178
|
continue;
|
|
134
179
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invoke-api-extension.js","sourceRoot":"","sources":["../../../../src/commands/integration-layer/extension/invoke-api-extension.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"invoke-api-extension.js","sourceRoot":"","sources":["../../../../src/commands/integration-layer/extension/invoke-api-extension.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,MAAM,oCAAoC,CAAC;AACpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oCAAoC,CAAC;AAMtE,OAAO,EACL,cAAc,EACd,oBAAoB,EACpB,cAAc,GACf,MAAM,8CAA8C,CAAC;AACtD,OAAO,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AACnG,OAAO,EAAE,uBAAuB,EAAqB,MAAM,sBAAsB,CAAC;AAClF,OAAO,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AAQtE,MAAM,CAAC,OAAO,OAAO,2BAA4B,SAAQ,uBAAuB;IAC9E,MAAM,CAAU,WAAW,GACzB,uMAAuM,CAAC;IAE1M,MAAM,CAAU,QAAQ,GAAG;QACzB,wGAAwG;QACxG,4HAA4H;QAC5H,oHAAoH;QACpH,mHAAmH;KACpH,CAAC;IAEF,gFAAgF;IAChF,0EAA0E;IACvD,UAAU,GAAG,KAAK,CAAC;IAEtC,MAAM,CAAU,KAAK,GAAG;QACtB,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC;YAClB,WAAW,EACT,mIAAmI;YACrI,OAAO,EAAE,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CAAC,YAAY,QAAQ,CAAC,MAAM,sBAAsB,MAAM,OAAO,YAAY,EAAE,CAAC,CAAC;QAEvF,KAAK,MAAM,CAAC,IAAI,QAAQ,EAAE,CAAC;YACzB,IAAI,CAAC,cAAc,CAAC,CAAC,EAAE,YAAY,EAAE,MAA4B,CAAC,EAAE,CAAC;gBACnE,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,GAAG,kCAAkC,YAAY,IAAI,MAAM,GAAG,CAAC,CAAC;gBAClF,SAAS;YACX,CAAC;YACD,MAAM,MAAM,GAAG,MAAM,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;YAC3C,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,GAAG,KAAK,cAAc,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;QACtD,CAAC;IACH,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { IntegrationLayerCommand } from "../../../lib/base.js";
|
|
2
|
+
export default class ExtensionServeApiExtension extends IntegrationLayerCommand {
|
|
3
|
+
static description: string;
|
|
4
|
+
static examples: string[];
|
|
5
|
+
static flags: {
|
|
6
|
+
"public-url": import("@oclif/core/interfaces").OptionFlag<string | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
port: import("@oclif/core/interfaces").OptionFlag<number, import("@oclif/core/interfaces").CustomOptions>;
|
|
8
|
+
entry: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
9
|
+
out: import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
10
|
+
all: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
11
|
+
"extensions-dir": import("@oclif/core/interfaces").OptionFlag<string, import("@oclif/core/interfaces").CustomOptions>;
|
|
12
|
+
config: import("@oclif/core/interfaces").OptionFlag<string[] | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
13
|
+
cleanup: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
14
|
+
};
|
|
15
|
+
run(): Promise<void>;
|
|
16
|
+
/** Apply {@link planReconcile}: delete superseded/removed Extensions, create new ones. */
|
|
17
|
+
private reconcile;
|
|
18
|
+
/** Delete every `il-localdev-*` Extension currently on the project (best-effort). */
|
|
19
|
+
private cleanupLeftovers;
|
|
20
|
+
/**
|
|
21
|
+
* Concatenate every package's `apiExtensions` into the one set a project deploys (the
|
|
22
|
+
* same flatMap `buildCombinedBundle` does), rejecting a key declared by two different
|
|
23
|
+
* extensions: a project ships one bundle, so each API-Extension key — and thus its
|
|
24
|
+
* `il-localdev-` registration — must be unique across packages.
|
|
25
|
+
*/
|
|
26
|
+
private combineApiExtensions;
|
|
27
|
+
/** One-shot build + load; returns the bundle's declared handlers. */
|
|
28
|
+
private buildOnce;
|
|
29
|
+
/**
|
|
30
|
+
* esbuild-watch `entry`; on every successful (re)build load the bundle and hand the
|
|
31
|
+
* raw module to `onReload`. Resolves once the first build completes. Mirrors the
|
|
32
|
+
* `serve` command's watcher, with the same bundle options as `buildBundle`.
|
|
33
|
+
*/
|
|
34
|
+
private watchEntry;
|
|
35
|
+
}
|